2008-08-25 15:11:06 -07:00
/*
*
* Copyright 2008 ( c ) Intel Corporation
* Jesse Barnes < jbarnes @ virtuousgeek . org >
*
* Permission is hereby granted , free of charge , to any person obtaining a
* copy of this software and associated documentation files ( the
* " Software " ) , to deal in the Software without restriction , including
* without limitation the rights to use , copy , modify , merge , publish ,
* distribute , sub license , and / or sell copies of the Software , and to
* permit persons to whom the Software is furnished to do so , subject to
* the following conditions :
*
* The above copyright notice and this permission notice ( including the
* next paragraph ) shall be included in all copies or substantial portions
* of the Software .
*
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS
* OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NON - INFRINGEMENT .
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND / OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT ,
* TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE .
*/
2019-06-13 11:44:16 +03:00
# include "display/intel_fbc.h"
2019-06-13 11:44:15 +03:00
# include "display/intel_gmbus.h"
2019-10-01 18:25:06 +03:00
# include "display/intel_vga.h"
2019-06-13 11:44:15 +03:00
2019-08-06 13:07:30 +03:00
# include "i915_drv.h"
2012-01-07 23:40:34 -02:00
# include "i915_reg.h"
2019-08-08 16:42:46 +03:00
# include "i915_suspend.h"
2008-08-25 15:11:06 -07:00
2016-11-16 08:55:39 +00:00
static void i915_save_display ( struct drm_i915_private * dev_priv )
2009-07-08 14:13:14 +08:00
{
2020-09-10 12:52:26 +03:00
struct pci_dev * pdev = dev_priv - > drm . pdev ;
2009-07-08 14:13:14 +08:00
/* Display arbitration control */
2016-11-16 08:55:39 +00:00
if ( INTEL_GEN ( dev_priv ) < = 4 )
2013-01-18 18:29:03 -02:00
dev_priv - > regfile . saveDSPARB = I915_READ ( DSPARB ) ;
2009-07-08 14:13:14 +08:00
2020-09-10 12:52:26 +03:00
if ( IS_GEN ( dev_priv , 4 ) )
pci_read_config_word ( pdev , GCDGMBUS ,
& dev_priv - > regfile . saveGCDGMBUS ) ;
2008-08-25 15:11:06 -07:00
}
2016-11-16 08:55:39 +00:00
static void i915_restore_display ( struct drm_i915_private * dev_priv )
2008-08-25 15:11:06 -07:00
{
2020-09-10 12:52:26 +03:00
struct pci_dev * pdev = dev_priv - > drm . pdev ;
if ( IS_GEN ( dev_priv , 4 ) )
pci_write_config_word ( pdev , GCDGMBUS ,
dev_priv - > regfile . saveGCDGMBUS ) ;
2008-11-02 23:08:44 -08:00
/* Display arbitration */
2016-11-16 08:55:39 +00:00
if ( INTEL_GEN ( dev_priv ) < = 4 )
2013-01-18 18:29:03 -02:00
I915_WRITE ( DSPARB , dev_priv - > regfile . saveDSPARB ) ;
2008-08-25 15:11:06 -07:00
2010-03-19 17:05:10 +08:00
/* only restore FBC info on the platform that supports FBC*/
2016-01-19 11:35:46 -02:00
intel_fbc_global_disable ( dev_priv ) ;
2014-01-23 16:49:15 +02:00
2019-10-01 18:25:06 +03:00
intel_vga_redisable ( dev_priv ) ;
2020-09-10 12:52:27 +03:00
intel_gmbus_reset ( dev_priv ) ;
2009-09-14 17:48:42 -04:00
}
2016-12-01 14:16:44 +00:00
int i915_save_state ( struct drm_i915_private * dev_priv )
2009-09-14 17:48:42 -04:00
{
int i ;
2016-11-16 08:55:39 +00:00
i915_save_display ( dev_priv ) ;
2009-09-14 17:48:42 -04:00
/* Scratch space */
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 10:10:43 -08:00
if ( IS_GEN ( dev_priv , 2 ) & & IS_MOBILE ( dev_priv ) ) {
2015-09-18 20:03:43 +03:00
for ( i = 0 ; i < 7 ; i + + ) {
dev_priv - > regfile . saveSWF0 [ i ] = I915_READ ( SWF0 ( i ) ) ;
dev_priv - > regfile . saveSWF1 [ i ] = I915_READ ( SWF1 ( i ) ) ;
}
for ( i = 0 ; i < 3 ; i + + )
dev_priv - > regfile . saveSWF3 [ i ] = I915_READ ( SWF3 ( i ) ) ;
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 10:10:43 -08:00
} else if ( IS_GEN ( dev_priv , 2 ) ) {
2015-09-18 20:03:43 +03:00
for ( i = 0 ; i < 7 ; i + + )
dev_priv - > regfile . saveSWF1 [ i ] = I915_READ ( SWF1 ( i ) ) ;
2019-02-04 14:25:38 -08:00
} else if ( HAS_GMCH ( dev_priv ) ) {
2015-09-18 20:03:43 +03:00
for ( i = 0 ; i < 16 ; i + + ) {
dev_priv - > regfile . saveSWF0 [ i ] = I915_READ ( SWF0 ( i ) ) ;
dev_priv - > regfile . saveSWF1 [ i ] = I915_READ ( SWF1 ( i ) ) ;
}
for ( i = 0 ; i < 3 ; i + + )
dev_priv - > regfile . saveSWF3 [ i ] = I915_READ ( SWF3 ( i ) ) ;
2009-09-14 17:48:42 -04:00
}
return 0 ;
}
2016-12-01 14:16:44 +00:00
int i915_restore_state ( struct drm_i915_private * dev_priv )
2009-09-14 17:48:42 -04:00
{
int i ;
2016-11-16 08:55:39 +00:00
i915_restore_display ( dev_priv ) ;
2009-09-14 17:48:42 -04:00
2015-09-18 20:03:43 +03:00
/* Scratch space */
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 10:10:43 -08:00
if ( IS_GEN ( dev_priv , 2 ) & & IS_MOBILE ( dev_priv ) ) {
2015-09-18 20:03:43 +03:00
for ( i = 0 ; i < 7 ; i + + ) {
I915_WRITE ( SWF0 ( i ) , dev_priv - > regfile . saveSWF0 [ i ] ) ;
I915_WRITE ( SWF1 ( i ) , dev_priv - > regfile . saveSWF1 [ i ] ) ;
}
for ( i = 0 ; i < 3 ; i + + )
I915_WRITE ( SWF3 ( i ) , dev_priv - > regfile . saveSWF3 [ i ] ) ;
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-12 10:10:43 -08:00
} else if ( IS_GEN ( dev_priv , 2 ) ) {
2015-09-18 20:03:43 +03:00
for ( i = 0 ; i < 7 ; i + + )
I915_WRITE ( SWF1 ( i ) , dev_priv - > regfile . saveSWF1 [ i ] ) ;
2019-02-04 14:25:38 -08:00
} else if ( HAS_GMCH ( dev_priv ) ) {
2015-09-18 20:03:43 +03:00
for ( i = 0 ; i < 16 ; i + + ) {
I915_WRITE ( SWF0 ( i ) , dev_priv - > regfile . saveSWF0 [ i ] ) ;
I915_WRITE ( SWF1 ( i ) , dev_priv - > regfile . saveSWF1 [ i ] ) ;
}
for ( i = 0 ; i < 3 ; i + + )
I915_WRITE ( SWF3 ( i ) , dev_priv - > regfile . saveSWF3 [ i ] ) ;
2008-08-25 15:11:06 -07:00
}
return 0 ;
}