2009-04-07 16:16:42 -07:00
/*
* Copyright © 2008 Intel Corporation
*
* 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 , sublicense ,
* 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 NONINFRINGEMENT . IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS 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 .
*
* Authors :
* Keith Packard < keithp @ keithp . com >
*
*/
2011-08-30 18:16:33 -04:00
# include <linux/export.h>
2019-04-05 14:00:03 +03:00
# include <linux/i2c.h>
2014-07-07 13:01:46 -07:00
# include <linux/notifier.h>
2019-04-05 14:00:03 +03:00
# include <linux/slab.h>
# include <linux/types.h>
2019-04-26 09:17:22 +01:00
2017-01-24 08:21:49 -08:00
# include <asm/byteorder.h>
2019-04-05 14:00:03 +03:00
2015-01-22 16:50:32 -08:00
# include <drm/drm_atomic_helper.h>
2012-10-02 18:01:07 +01:00
# include <drm/drm_crtc.h>
2018-01-08 14:55:43 -05:00
# include <drm/drm_dp_helper.h>
2012-10-02 18:01:07 +01:00
# include <drm/drm_edid.h>
2019-01-17 22:03:34 +01:00
# include <drm/drm_probe_helper.h>
2019-04-05 14:00:03 +03:00
2019-05-02 18:02:43 +03:00
# include "i915_debugfs.h"
2009-04-07 16:16:42 -07:00
# include "i915_drv.h"
2019-08-06 13:07:28 +03:00
# include "i915_trace.h"
2019-04-29 15:53:31 +03:00
# include "intel_atomic.h"
2019-04-05 14:00:03 +03:00
# include "intel_audio.h"
2019-04-05 14:00:06 +03:00
# include "intel_connector.h"
2019-04-05 14:00:05 +03:00
# include "intel_ddi.h"
2019-08-06 14:39:33 +03:00
# include "intel_display_types.h"
2019-04-05 14:00:17 +03:00
# include "intel_dp.h"
2019-04-29 15:29:25 +03:00
# include "intel_dp_link_training.h"
2019-04-29 15:29:33 +03:00
# include "intel_dp_mst.h"
2019-05-02 18:02:40 +03:00
# include "intel_dpio_phy.h"
2019-04-29 15:29:24 +03:00
# include "intel_fifo_underrun.h"
2019-04-05 14:00:13 +03:00
# include "intel_hdcp.h"
2019-04-05 14:00:18 +03:00
# include "intel_hdmi.h"
2019-04-29 15:50:11 +03:00
# include "intel_hotplug.h"
2019-04-05 14:00:11 +03:00
# include "intel_lspcon.h"
2019-04-05 14:00:22 +03:00
# include "intel_lvds.h"
2019-04-05 14:00:14 +03:00
# include "intel_panel.h"
2021-01-08 19:44:09 +02:00
# include "intel_pps.h"
2019-04-05 14:00:09 +03:00
# include "intel_psr.h"
2019-04-26 09:17:22 +01:00
# include "intel_sideband.h"
2019-06-28 17:36:15 +03:00
# include "intel_tc.h"
2019-04-29 15:29:32 +03:00
# include "intel_vdsc.h"
2009-04-07 16:16:42 -07:00
2017-09-18 15:21:39 -07:00
# define DP_DPRX_ESI_LEN 14
2009-04-07 16:16:42 -07:00
2018-10-30 17:19:21 -07:00
/* DP DSC throughput values used for slice count calculations KPixels/s */
# define DP_DSC_PEAK_PIXEL_RATE 2720000
# define DP_DSC_MAX_ENC_THROUGHPUT_0 340000
# define DP_DSC_MAX_ENC_THROUGHPUT_1 400000
2019-09-25 10:21:09 +02:00
/* DP DSC FEC Overhead factor = 1/(0.972261) */
# define DP_DSC_FEC_OVERHEAD_FACTOR 972261
2018-10-30 17:19:21 -07:00
2015-05-04 07:48:20 -07:00
/* Compliance test status bits */
# define INTEL_DP_RESOLUTION_SHIFT_MASK 0
# define INTEL_DP_RESOLUTION_PREFERRED (1 << INTEL_DP_RESOLUTION_SHIFT_MASK)
# define INTEL_DP_RESOLUTION_STANDARD (2 << INTEL_DP_RESOLUTION_SHIFT_MASK)
# define INTEL_DP_RESOLUTION_FAILSAFE (3 << INTEL_DP_RESOLUTION_SHIFT_MASK)
2013-09-04 01:30:37 +08:00
struct dp_link_dpll {
2015-08-11 20:21:46 +03:00
int clock ;
2013-09-04 01:30:37 +08:00
struct dpll dpll ;
} ;
2018-05-17 20:03:09 +03:00
static const struct dp_link_dpll g4x_dpll [ ] = {
2015-08-11 20:21:46 +03:00
{ 162000 ,
2013-09-04 01:30:37 +08:00
{ . p1 = 2 , . p2 = 10 , . n = 2 , . m1 = 23 , . m2 = 8 } } ,
2015-08-11 20:21:46 +03:00
{ 270000 ,
2013-09-04 01:30:37 +08:00
{ . p1 = 1 , . p2 = 10 , . n = 1 , . m1 = 14 , . m2 = 2 } }
} ;
static const struct dp_link_dpll pch_dpll [ ] = {
2015-08-11 20:21:46 +03:00
{ 162000 ,
2013-09-04 01:30:37 +08:00
{ . p1 = 2 , . p2 = 10 , . n = 1 , . m1 = 12 , . m2 = 9 } } ,
2015-08-11 20:21:46 +03:00
{ 270000 ,
2013-09-04 01:30:37 +08:00
{ . p1 = 1 , . p2 = 10 , . n = 2 , . m1 = 14 , . m2 = 8 } }
} ;
2013-09-04 01:30:38 +08:00
static const struct dp_link_dpll vlv_dpll [ ] = {
2015-08-11 20:21:46 +03:00
{ 162000 ,
2013-09-25 15:47:51 +08:00
{ . p1 = 3 , . p2 = 2 , . n = 5 , . m1 = 3 , . m2 = 81 } } ,
2015-08-11 20:21:46 +03:00
{ 270000 ,
2013-09-04 01:30:38 +08:00
{ . p1 = 2 , . p2 = 2 , . n = 1 , . m1 = 2 , . m2 = 27 } }
} ;
2014-04-09 13:28:18 +03:00
/*
* CHV supports eDP 1.4 that have more link rates .
* Below only provides the fixed rate but exclude variable rate .
*/
static const struct dp_link_dpll chv_dpll [ ] = {
/*
* CHV requires to program fractional division for m2 .
* m2 is stored in fixed point format using formula below
* ( m2_int < < 22 ) | m2_fraction
*/
2015-08-11 20:21:46 +03:00
{ 162000 , /* m2_int = 32, m2_fraction = 1677722 */
2014-04-09 13:28:18 +03:00
{ . p1 = 4 , . p2 = 2 , . n = 1 , . m1 = 2 , . m2 = 0x819999a } } ,
2015-08-11 20:21:46 +03:00
{ 270000 , /* m2_int = 27, m2_fraction = 0 */
2014-04-09 13:28:18 +03:00
{ . p1 = 4 , . p2 = 1 , . n = 1 , . m1 = 2 , . m2 = 0x6c00000 } } ,
} ;
2015-05-07 09:52:08 +05:30
2021-01-08 19:44:09 +02:00
const struct dpll * vlv_get_dpll ( struct drm_i915_private * i915 )
{
return IS_CHERRYVIEW ( i915 ) ? & chv_dpll [ 0 ] . dpll : & vlv_dpll [ 0 ] . dpll ;
}
2018-10-30 17:19:21 -07:00
/* Constants for DP DSC configurations */
static const u8 valid_dsc_bpp [ ] = { 6 , 8 , 10 , 12 , 15 } ;
/* With Single pipe configuration, HW is capable of supporting maximum
* of 4 slices per line .
*/
static const u8 valid_dsc_slicecount [ ] = { 1 , 2 , 4 } ;
2010-10-07 16:01:06 -07:00
/**
2017-08-18 12:30:20 +03:00
* intel_dp_is_edp - is the given port attached to an eDP panel ( either CPU or PCH )
2010-10-07 16:01:06 -07:00
* @ intel_dp : DP struct
*
* If a CPU or PCH DP output is attached to an eDP panel , this function
* will return true , and false otherwise .
*/
2017-08-18 12:30:20 +03:00
bool intel_dp_is_edp ( struct intel_dp * intel_dp )
2010-10-07 16:01:06 -07:00
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2012-10-26 19:05:46 -02:00
2020-06-30 21:50:54 -07:00
return dig_port - > base . type = = INTEL_OUTPUT_EDP ;
2010-10-07 16:01:06 -07:00
}
2017-10-31 22:51:14 +02:00
static void intel_dp_link_down ( struct intel_encoder * encoder ,
const struct intel_crtc_state * old_crtc_state ) ;
2016-03-30 18:05:22 +05:30
static void intel_dp_unset_edid ( struct intel_dp * intel_dp ) ;
2009-04-07 16:16:42 -07:00
2017-03-28 17:59:05 +03:00
/* update sink rates from dpcd */
static void intel_dp_set_sink_rates ( struct intel_dp * intel_dp )
{
2018-02-27 12:59:11 +02:00
static const int dp_rates [ ] = {
2018-02-28 14:31:50 -08:00
162000 , 270000 , 540000 , 810000
2018-02-27 12:59:11 +02:00
} ;
2017-10-09 12:29:59 +03:00
int i , max_rate ;
2020-10-07 20:09:17 +03:00
int max_lttpr_rate ;
2017-03-28 17:59:05 +03:00
2020-03-16 05:23:40 +01:00
if ( drm_dp_has_quirk ( & intel_dp - > desc , 0 ,
DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS ) ) {
/* Needed, e.g., for Apple MBP 2017, 15 inch eDP Retina panel */
static const int quirk_rates [ ] = { 162000 , 270000 , 324000 } ;
memcpy ( intel_dp - > sink_rates , quirk_rates , sizeof ( quirk_rates ) ) ;
intel_dp - > num_sink_rates = ARRAY_SIZE ( quirk_rates ) ;
return ;
}
2017-10-09 12:29:59 +03:00
max_rate = drm_dp_bw_code_to_link_rate ( intel_dp - > dpcd [ DP_MAX_LINK_RATE ] ) ;
2020-10-07 20:09:17 +03:00
max_lttpr_rate = drm_dp_lttpr_max_link_rate ( intel_dp - > lttpr_common_caps ) ;
if ( max_lttpr_rate )
max_rate = min ( max_rate , max_lttpr_rate ) ;
2017-03-28 17:59:05 +03:00
2018-02-27 12:59:11 +02:00
for ( i = 0 ; i < ARRAY_SIZE ( dp_rates ) ; i + + ) {
if ( dp_rates [ i ] > max_rate )
2017-10-09 12:29:59 +03:00
break ;
2018-02-27 12:59:11 +02:00
intel_dp - > sink_rates [ i ] = dp_rates [ i ] ;
2017-10-09 12:29:59 +03:00
}
2017-03-28 17:59:05 +03:00
2017-10-09 12:29:59 +03:00
intel_dp - > num_sink_rates = i ;
2017-03-28 17:59:05 +03:00
}
2018-02-01 13:03:41 +02:00
/* Get length of rates array potentially limited by max_rate. */
static int intel_dp_rate_limit_len ( const int * rates , int len , int max_rate )
{
int i ;
/* Limit results by potentially reduced max rate */
for ( i = 0 ; i < len ; i + + ) {
if ( rates [ len - i - 1 ] < = max_rate )
return len - i ;
}
return 0 ;
}
/* Get length of common rates array potentially limited by max_rate. */
static int intel_dp_common_len_rate_limit ( const struct intel_dp * intel_dp ,
int max_rate )
{
return intel_dp_rate_limit_len ( intel_dp - > common_rates ,
intel_dp - > num_common_rates , max_rate ) ;
}
2017-04-06 16:44:13 +03:00
/* Theoretical max between source and sink */
static int intel_dp_max_common_rate ( struct intel_dp * intel_dp )
2009-04-07 16:16:42 -07:00
{
2017-04-06 16:44:13 +03:00
return intel_dp - > common_rates [ intel_dp - > num_common_rates - 1 ] ;
2009-04-07 16:16:42 -07:00
}
2017-04-06 16:44:13 +03:00
/* Theoretical max between source and sink */
static int intel_dp_max_common_lane_count ( struct intel_dp * intel_dp )
2014-05-06 14:56:50 +03:00
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
int source_max = dig_port - > max_lanes ;
2017-04-06 16:44:13 +03:00
int sink_max = drm_dp_max_lane_count ( intel_dp - > dpcd ) ;
2020-06-30 21:50:54 -07:00
int fia_max = intel_tc_port_fia_max_lane_count ( dig_port ) ;
2020-10-07 20:09:17 +03:00
int lttpr_max = drm_dp_lttpr_max_lane_count ( intel_dp - > lttpr_common_caps ) ;
if ( lttpr_max )
sink_max = min ( sink_max , lttpr_max ) ;
2014-05-06 14:56:50 +03:00
2018-07-24 17:28:11 -07:00
return min3 ( source_max , sink_max , fia_max ) ;
2014-05-06 14:56:50 +03:00
}
2017-04-06 16:44:14 +03:00
int intel_dp_max_lane_count ( struct intel_dp * intel_dp )
2017-04-06 16:44:13 +03:00
{
return intel_dp - > max_link_lane_count ;
}
2016-11-15 12:59:06 -08:00
int
2012-01-25 08:16:25 -08:00
intel_dp_link_required ( int pixel_clock , int bpp )
2009-04-07 16:16:42 -07:00
{
drm/i915: Fix DP link rate math
We store DP link rates as link clock frequencies in kHz, just like all
other clock values. But, DP link rates in the DP Spec. are expressed in
Gbps/lane, which seems to have led to some confusion.
E.g., for HBR2
Max. data rate = 5.4 Gbps/lane x 4 lane x 8/10 x 1/8 = 2160000 kBps
where, 8/10 is for channel encoding and 1/8 is for bit to Byte conversion
Using link clock frequency, like we do
Max. data rate = 540000 kHz * 4 lanes = 2160000 kSymbols/s
Because, each symbol has 8 bit of data, this is 2160000 kBps
and there is no need to account for channel encoding here.
But, currently we do 540000 kHz * 4 lanes * (8/10) = 1728000 kBps
Similarly, while computing the required link bandwidth for a mode,
there is a mysterious 1/10 term.
This should simply be pixel_clock kHz * (bpp/8) to give the final result in
kBps
v2: Changed to DIV_ROUND_UP() and comment changes (Ville)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1479160220-17794-1-git-send-email-dhinakaran.pandiyan@intel.com
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2016-11-14 13:50:20 -08:00
/* pixel_clock is in kHz, divide bpp by 8 for bit to Byte conversion */
return DIV_ROUND_UP ( pixel_clock * bpp , 8 ) ;
2009-04-07 16:16:42 -07:00
}
2016-11-15 12:59:06 -08:00
int
2010-06-30 11:46:17 +10:00
intel_dp_max_data_rate ( int max_link_clock , int max_lanes )
{
drm/i915: Fix DP link rate math
We store DP link rates as link clock frequencies in kHz, just like all
other clock values. But, DP link rates in the DP Spec. are expressed in
Gbps/lane, which seems to have led to some confusion.
E.g., for HBR2
Max. data rate = 5.4 Gbps/lane x 4 lane x 8/10 x 1/8 = 2160000 kBps
where, 8/10 is for channel encoding and 1/8 is for bit to Byte conversion
Using link clock frequency, like we do
Max. data rate = 540000 kHz * 4 lanes = 2160000 kSymbols/s
Because, each symbol has 8 bit of data, this is 2160000 kBps
and there is no need to account for channel encoding here.
But, currently we do 540000 kHz * 4 lanes * (8/10) = 1728000 kBps
Similarly, while computing the required link bandwidth for a mode,
there is a mysterious 1/10 term.
This should simply be pixel_clock kHz * (bpp/8) to give the final result in
kBps
v2: Changed to DIV_ROUND_UP() and comment changes (Ville)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1479160220-17794-1-git-send-email-dhinakaran.pandiyan@intel.com
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2016-11-14 13:50:20 -08:00
/* max_link_clock is the link symbol clock (LS_Clk) in kHz and not the
* link rate that is generally expressed in Gbps . Since , 8 bits of data
* is transmitted every LS_Clk per lane , there is no need to account for
* the channel encoding that is done in the PHY layer here .
*/
return max_link_clock * max_lanes ;
2010-06-30 11:46:17 +10:00
}
2020-11-17 11:47:05 -08:00
bool intel_dp_can_bigjoiner ( struct intel_dp * intel_dp )
{
struct intel_digital_port * intel_dig_port = dp_to_dig_port ( intel_dp ) ;
struct intel_encoder * encoder = & intel_dig_port - > base ;
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
return INTEL_GEN ( dev_priv ) > = 12 | |
( INTEL_GEN ( dev_priv ) = = 11 & &
encoder - > port ! = PORT_A ) ;
}
2018-02-01 13:03:42 +02:00
static int cnl_max_source_rate ( struct intel_dp * intel_dp )
2018-01-29 15:22:23 -08:00
{
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct drm_i915_private * dev_priv = to_i915 ( dig_port - > base . base . dev ) ;
enum port port = dig_port - > base . port ;
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
u32 voltage = intel_de_read ( dev_priv , CNL_PORT_COMP_DW3 ) & VOLTAGE_INFO_MASK ;
2018-01-29 15:22:23 -08:00
/* Low voltage SKUs are limited to max of 5.4G */
if ( voltage = = VOLTAGE_INFO_0_85V )
2018-02-01 13:03:42 +02:00
return 540000 ;
2018-01-29 15:22:23 -08:00
/* For this SKU 8.1G is supported in all ports */
if ( IS_CNL_WITH_PORT_F ( dev_priv ) )
2018-02-01 13:03:42 +02:00
return 810000 ;
2018-01-29 15:22:23 -08:00
2018-02-09 15:07:55 +02:00
/* For other SKUs, max rate on ports A and D is 5.4G */
2018-01-29 15:22:23 -08:00
if ( port = = PORT_A | | port = = PORT_D )
2018-02-01 13:03:42 +02:00
return 540000 ;
2018-01-29 15:22:23 -08:00
2018-02-01 13:03:42 +02:00
return 810000 ;
2018-01-29 15:22:23 -08:00
}
2018-06-11 15:26:54 -07:00
static int icl_max_source_rate ( struct intel_dp * intel_dp )
{
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2018-12-17 14:13:47 -08:00
struct drm_i915_private * dev_priv = to_i915 ( dig_port - > base . base . dev ) ;
2019-07-09 11:39:33 -07:00
enum phy phy = intel_port_to_phy ( dev_priv , dig_port - > base . port ) ;
2018-06-11 15:26:54 -07:00
2019-07-09 11:39:33 -07:00
if ( intel_phy_is_combo ( dev_priv , phy ) & &
2018-12-17 14:13:47 -08:00
! intel_dp_is_edp ( intel_dp ) )
2018-06-11 15:26:54 -07:00
return 540000 ;
return 810000 ;
}
2020-10-05 10:54:47 -07:00
static int ehl_max_source_rate ( struct intel_dp * intel_dp )
{
if ( intel_dp_is_edp ( intel_dp ) )
return 540000 ;
return 810000 ;
}
2017-03-28 17:59:04 +03:00
static void
intel_dp_set_source_rates ( struct intel_dp * intel_dp )
2016-10-26 16:25:55 -07:00
{
2018-02-27 12:59:11 +02:00
/* The values must be in increasing order */
static const int cnl_rates [ ] = {
162000 , 216000 , 270000 , 324000 , 432000 , 540000 , 648000 , 810000
} ;
static const int bxt_rates [ ] = {
162000 , 216000 , 243000 , 270000 , 324000 , 432000 , 540000
} ;
static const int skl_rates [ ] = {
162000 , 216000 , 270000 , 324000 , 432000 , 540000
} ;
static const int hsw_rates [ ] = {
162000 , 270000 , 540000
} ;
static const int g4x_rates [ ] = {
162000 , 270000
} ;
2016-10-26 16:25:55 -07:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2020-01-17 16:29:25 +02:00
struct intel_encoder * encoder = & dig_port - > base ;
2016-10-26 16:25:55 -07:00
struct drm_i915_private * dev_priv = to_i915 ( dig_port - > base . base . dev ) ;
2017-03-28 17:59:04 +03:00
const int * source_rates ;
2020-01-17 16:29:25 +02:00
int size , max_rate = 0 , vbt_max_rate ;
2016-10-26 16:25:55 -07:00
2017-03-28 17:59:04 +03:00
/* This should only be done once */
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
drm_WARN_ON ( & dev_priv - > drm ,
intel_dp - > source_rates | | intel_dp - > num_source_rates ) ;
2017-03-28 17:59:04 +03:00
2018-06-11 15:26:54 -07:00
if ( INTEL_GEN ( dev_priv ) > = 10 ) {
2017-08-10 15:40:08 -07:00
source_rates = cnl_rates ;
2018-02-01 13:03:42 +02:00
size = ARRAY_SIZE ( cnl_rates ) ;
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 , 10 ) )
2018-06-11 15:26:54 -07:00
max_rate = cnl_max_source_rate ( intel_dp ) ;
2020-10-14 00:59:48 +05:30
else if ( IS_JSL_EHL ( dev_priv ) )
2020-10-05 10:54:47 -07:00
max_rate = ehl_max_source_rate ( intel_dp ) ;
2018-06-11 15:26:54 -07:00
else
max_rate = icl_max_source_rate ( intel_dp ) ;
2018-02-26 19:11:15 -08:00
} else if ( IS_GEN9_LP ( dev_priv ) ) {
source_rates = bxt_rates ;
size = ARRAY_SIZE ( bxt_rates ) ;
2017-01-23 10:32:37 -08:00
} else if ( IS_GEN9_BC ( dev_priv ) ) {
2017-03-28 17:59:04 +03:00
source_rates = skl_rates ;
2016-10-26 16:25:55 -07:00
size = ARRAY_SIZE ( skl_rates ) ;
2017-10-09 12:29:58 +03:00
} else if ( ( IS_HASWELL ( dev_priv ) & & ! IS_HSW_ULX ( dev_priv ) ) | |
IS_BROADWELL ( dev_priv ) ) {
2018-02-27 12:59:11 +02:00
source_rates = hsw_rates ;
size = ARRAY_SIZE ( hsw_rates ) ;
2017-10-09 12:29:58 +03:00
} else {
2018-02-27 12:59:11 +02:00
source_rates = g4x_rates ;
size = ARRAY_SIZE ( g4x_rates ) ;
2016-10-26 16:25:55 -07:00
}
2020-01-17 16:29:25 +02:00
vbt_max_rate = intel_bios_dp_max_link_rate ( encoder ) ;
2018-02-01 13:03:43 +02:00
if ( max_rate & & vbt_max_rate )
max_rate = min ( max_rate , vbt_max_rate ) ;
else if ( vbt_max_rate )
max_rate = vbt_max_rate ;
2018-02-01 13:03:42 +02:00
if ( max_rate )
size = intel_dp_rate_limit_len ( source_rates , size , max_rate ) ;
2017-03-28 17:59:04 +03:00
intel_dp - > source_rates = source_rates ;
intel_dp - > num_source_rates = size ;
2016-10-26 16:25:55 -07:00
}
static int intersect_rates ( const int * source_rates , int source_len ,
const int * sink_rates , int sink_len ,
int * common_rates )
{
int i = 0 , j = 0 , k = 0 ;
while ( i < source_len & & j < sink_len ) {
if ( source_rates [ i ] = = sink_rates [ j ] ) {
if ( WARN_ON ( k > = DP_MAX_SUPPORTED_RATES ) )
return k ;
common_rates [ k ] = source_rates [ i ] ;
+ + k ;
+ + i ;
+ + j ;
} else if ( source_rates [ i ] < sink_rates [ j ] ) {
+ + i ;
} else {
+ + j ;
}
}
return k ;
}
2017-03-28 17:59:03 +03:00
/* return index of rate in rates array, or -1 if not found */
static int intel_dp_rate_index ( const int * rates , int len , int rate )
{
int i ;
for ( i = 0 ; i < len ; i + + )
if ( rate = = rates [ i ] )
return i ;
return - 1 ;
}
2017-04-06 16:44:10 +03:00
static void intel_dp_set_common_rates ( struct intel_dp * intel_dp )
2016-10-26 16:25:55 -07:00
{
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
drm_WARN_ON ( & i915 - > drm ,
! intel_dp - > num_source_rates | | ! intel_dp - > num_sink_rates ) ;
2016-10-26 16:25:55 -07:00
2017-04-06 16:44:10 +03:00
intel_dp - > num_common_rates = intersect_rates ( intel_dp - > source_rates ,
intel_dp - > num_source_rates ,
intel_dp - > sink_rates ,
intel_dp - > num_sink_rates ,
intel_dp - > common_rates ) ;
/* Paranoia, there should always be something in common. */
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
if ( drm_WARN_ON ( & i915 - > drm , intel_dp - > num_common_rates = = 0 ) ) {
2018-02-27 12:59:11 +02:00
intel_dp - > common_rates [ 0 ] = 162000 ;
2017-04-06 16:44:10 +03:00
intel_dp - > num_common_rates = 1 ;
}
}
2017-06-08 13:41:02 -07:00
static bool intel_dp_link_params_valid ( struct intel_dp * intel_dp , int link_rate ,
2019-01-16 11:15:27 +02:00
u8 lane_count )
2017-04-06 14:00:12 -07:00
{
/*
* FIXME : we need to synchronize the current link parameters with
* hardware readout . Currently fast link training doesn ' t work on
* boot - up .
*/
2017-06-08 13:41:02 -07:00
if ( link_rate = = 0 | |
link_rate > intel_dp - > max_link_rate )
2017-04-06 14:00:12 -07:00
return false ;
2017-06-08 13:41:02 -07:00
if ( lane_count = = 0 | |
lane_count > intel_dp_max_lane_count ( intel_dp ) )
2017-04-06 14:00:12 -07:00
return false ;
return true ;
}
2018-10-09 14:28:04 -07:00
static bool intel_dp_can_link_train_fallback_for_edp ( struct intel_dp * intel_dp ,
int link_rate ,
2019-01-16 11:15:27 +02:00
u8 lane_count )
2018-10-09 14:28:04 -07:00
{
const struct drm_display_mode * fixed_mode =
intel_dp - > attached_connector - > panel . fixed_mode ;
int mode_rate , max_rate ;
mode_rate = intel_dp_link_required ( fixed_mode - > clock , 18 ) ;
max_rate = intel_dp_max_data_rate ( link_rate , lane_count ) ;
if ( mode_rate > max_rate )
return false ;
return true ;
}
2016-12-08 19:05:12 -08:00
int intel_dp_get_link_train_fallback_values ( struct intel_dp * intel_dp ,
2019-01-16 11:15:27 +02:00
int link_rate , u8 lane_count )
2016-12-08 19:05:12 -08:00
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2017-04-06 16:44:11 +03:00
int index ;
2016-12-08 19:05:12 -08:00
2020-06-17 00:11:45 +03:00
/*
* TODO : Enable fallback on MST links once MST link compute can handle
* the fallback params .
*/
if ( intel_dp - > is_mst ) {
drm_err ( & i915 - > drm , " Link Training Unsuccessful \n " ) ;
return - 1 ;
}
2021-01-07 20:20:25 +02:00
if ( intel_dp_is_edp ( intel_dp ) & & ! intel_dp - > use_max_params ) {
drm_dbg_kms ( & i915 - > drm ,
" Retrying Link training for eDP with max parameters \n " ) ;
intel_dp - > use_max_params = true ;
return 0 ;
}
2017-04-06 16:44:11 +03:00
index = intel_dp_rate_index ( intel_dp - > common_rates ,
intel_dp - > num_common_rates ,
link_rate ) ;
if ( index > 0 ) {
2018-10-09 14:28:04 -07:00
if ( intel_dp_is_edp ( intel_dp ) & &
! intel_dp_can_link_train_fallback_for_edp ( intel_dp ,
intel_dp - > common_rates [ index - 1 ] ,
lane_count ) ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" Retrying Link training for eDP with same parameters \n " ) ;
2018-10-09 14:28:04 -07:00
return 0 ;
}
2017-04-06 16:44:12 +03:00
intel_dp - > max_link_rate = intel_dp - > common_rates [ index - 1 ] ;
intel_dp - > max_link_lane_count = lane_count ;
2016-12-08 19:05:12 -08:00
} else if ( lane_count > 1 ) {
2018-10-09 14:28:04 -07:00
if ( intel_dp_is_edp ( intel_dp ) & &
! intel_dp_can_link_train_fallback_for_edp ( intel_dp ,
intel_dp_max_common_rate ( intel_dp ) ,
lane_count > > 1 ) ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" Retrying Link training for eDP with same parameters \n " ) ;
2018-10-09 14:28:04 -07:00
return 0 ;
}
2017-04-06 16:44:13 +03:00
intel_dp - > max_link_rate = intel_dp_max_common_rate ( intel_dp ) ;
2017-04-06 16:44:12 +03:00
intel_dp - > max_link_lane_count = lane_count > > 1 ;
2016-12-08 19:05:12 -08:00
} else {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_err ( & i915 - > drm , " Link Training Unsuccessful \n " ) ;
2016-12-08 19:05:12 -08:00
return - 1 ;
}
return 0 ;
}
2019-09-25 10:21:09 +02:00
u32 intel_dp_mode_to_fec_clock ( u32 mode_clock )
{
return div_u64 ( mul_u32_u32 ( mode_clock , 1000000U ) ,
DP_DSC_FEC_OVERHEAD_FACTOR ) ;
}
2019-09-25 16:45:42 -07:00
static int
small_joiner_ram_size_bits ( struct drm_i915_private * i915 )
{
if ( INTEL_GEN ( i915 ) > = 11 )
return 7680 * 8 ;
else
return 6144 * 8 ;
}
static u16 intel_dp_dsc_get_output_bpp ( struct drm_i915_private * i915 ,
u32 link_clock , u32 lane_count ,
2020-11-17 11:47:05 -08:00
u32 mode_clock , u32 mode_hdisplay ,
bool bigjoiner )
2019-09-25 10:21:09 +02:00
{
u32 bits_per_pixel , max_bpp_small_joiner_ram ;
int i ;
/*
* Available Link Bandwidth ( Kbits / sec ) = ( NumberOfLanes ) *
* ( LinkSymbolClock ) * 8 * ( TimeSlotsPerMTP )
* for SST - > TimeSlotsPerMTP is 1 ,
* for MST - > TimeSlotsPerMTP has to be calculated
*/
bits_per_pixel = ( link_clock * lane_count * 8 ) /
intel_dp_mode_to_fec_clock ( mode_clock ) ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & i915 - > drm , " Max link bpp: %u \n " , bits_per_pixel ) ;
2019-09-25 10:21:09 +02:00
/* Small Joiner Check: output bpp <= joiner RAM (bits) / Horiz. width */
2019-09-25 16:45:42 -07:00
max_bpp_small_joiner_ram = small_joiner_ram_size_bits ( i915 ) /
mode_hdisplay ;
2020-11-17 11:47:05 -08:00
if ( bigjoiner )
max_bpp_small_joiner_ram * = 2 ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & i915 - > drm , " Max small joiner bpp: %u \n " ,
max_bpp_small_joiner_ram ) ;
2019-09-25 10:21:09 +02:00
/*
* Greatest allowed DSC BPP = MIN ( output BPP from available Link BW
* check , output bpp from small joiner RAM check )
*/
bits_per_pixel = min ( bits_per_pixel , max_bpp_small_joiner_ram ) ;
2020-11-17 11:47:05 -08:00
if ( bigjoiner ) {
u32 max_bpp_bigjoiner =
i915 - > max_cdclk_freq * 48 /
intel_dp_mode_to_fec_clock ( mode_clock ) ;
DRM_DEBUG_KMS ( " Max big joiner bpp: %u \n " , max_bpp_bigjoiner ) ;
bits_per_pixel = min ( bits_per_pixel , max_bpp_bigjoiner ) ;
}
2019-09-25 10:21:09 +02:00
/* Error out if the max bpp is less than smallest allowed valid bpp */
if ( bits_per_pixel < valid_dsc_bpp [ 0 ] ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & i915 - > drm , " Unsupported BPP %u, min %u \n " ,
bits_per_pixel , valid_dsc_bpp [ 0 ] ) ;
2019-09-25 10:21:09 +02:00
return 0 ;
}
/* Find the nearest match in the array of known BPPs from VESA */
for ( i = 0 ; i < ARRAY_SIZE ( valid_dsc_bpp ) - 1 ; i + + ) {
if ( bits_per_pixel < valid_dsc_bpp [ i + 1 ] )
break ;
}
bits_per_pixel = valid_dsc_bpp [ i ] ;
/*
* Compressed BPP in U6 .4 format so multiply by 16 , for Gen 11 ,
* fractional part is 0
*/
return bits_per_pixel < < 4 ;
}
static u8 intel_dp_dsc_get_slice_count ( struct intel_dp * intel_dp ,
2020-11-17 11:47:05 -08:00
int mode_clock , int mode_hdisplay ,
bool bigjoiner )
2019-09-25 10:21:09 +02:00
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2019-09-25 10:21:09 +02:00
u8 min_slice_count , i ;
int max_slice_width ;
if ( mode_clock < = DP_DSC_PEAK_PIXEL_RATE )
min_slice_count = DIV_ROUND_UP ( mode_clock ,
DP_DSC_MAX_ENC_THROUGHPUT_0 ) ;
else
min_slice_count = DIV_ROUND_UP ( mode_clock ,
DP_DSC_MAX_ENC_THROUGHPUT_1 ) ;
max_slice_width = drm_dp_dsc_sink_max_slice_width ( intel_dp - > dsc_dpcd ) ;
if ( max_slice_width < DP_DSC_MIN_SLICE_WIDTH_VALUE ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" Unsupported slice width %d by DP DSC Sink device \n " ,
max_slice_width ) ;
2019-09-25 10:21:09 +02:00
return 0 ;
}
/* Also take into account max slice width */
2020-12-04 12:58:04 -08:00
min_slice_count = max_t ( u8 , min_slice_count ,
2019-09-25 10:21:09 +02:00
DIV_ROUND_UP ( mode_hdisplay ,
max_slice_width ) ) ;
/* Find the closest match to the valid slice count values */
for ( i = 0 ; i < ARRAY_SIZE ( valid_dsc_slicecount ) ; i + + ) {
2020-11-17 11:47:05 -08:00
u8 test_slice_count = valid_dsc_slicecount [ i ] < < bigjoiner ;
if ( test_slice_count >
drm_dp_dsc_sink_max_slice_count ( intel_dp - > dsc_dpcd , false ) )
2019-09-25 10:21:09 +02:00
break ;
2020-11-17 11:47:05 -08:00
/* big joiner needs small joiner to be enabled */
if ( bigjoiner & & test_slice_count < 4 )
continue ;
if ( min_slice_count < = test_slice_count )
return test_slice_count ;
2019-09-25 10:21:09 +02:00
}
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Unsupported Slice Count %d \n " ,
min_slice_count ) ;
2019-09-25 10:21:09 +02:00
return 0 ;
}
2020-09-18 00:43:33 +03:00
static enum intel_output_format
intel_dp_output_format ( struct drm_connector * connector ,
const struct drm_display_mode * mode )
{
struct intel_dp * intel_dp = intel_attached_dp ( to_intel_connector ( connector ) ) ;
const struct drm_display_info * info = & connector - > display_info ;
2020-09-24 21:41:56 +03:00
if ( ! connector - > ycbcr_420_allowed | |
! drm_mode_is_420_only ( info , mode ) )
2020-09-18 00:43:33 +03:00
return INTEL_OUTPUT_FORMAT_RGB ;
2020-12-18 16:07:23 +05:30
if ( intel_dp - > dfp . rgb_to_ycbcr & &
intel_dp - > dfp . ycbcr_444_to_420 )
return INTEL_OUTPUT_FORMAT_RGB ;
2020-09-18 00:43:33 +03:00
if ( intel_dp - > dfp . ycbcr_444_to_420 )
return INTEL_OUTPUT_FORMAT_YCBCR444 ;
else
return INTEL_OUTPUT_FORMAT_YCBCR420 ;
}
2020-09-18 00:43:35 +03:00
int intel_dp_min_bpp ( enum intel_output_format output_format )
{
if ( output_format = = INTEL_OUTPUT_FORMAT_RGB )
return 6 * 3 ;
else
return 8 * 3 ;
}
static int intel_dp_output_bpp ( enum intel_output_format output_format , int bpp )
{
/*
* bpp value was assumed to RGB format . And YCbCr 4 : 2 : 0 output
* format of the number of bytes per pixel will be half the number
* of bytes of RGB pixel .
*/
if ( output_format = = INTEL_OUTPUT_FORMAT_YCBCR420 )
bpp / = 2 ;
return bpp ;
}
static int
intel_dp_mode_min_output_bpp ( struct drm_connector * connector ,
const struct drm_display_mode * mode )
{
enum intel_output_format output_format =
intel_dp_output_format ( connector , mode ) ;
return intel_dp_output_bpp ( output_format , intel_dp_min_bpp ( output_format ) ) ;
}
2019-07-18 17:43:39 +03:00
static bool intel_dp_hdisplay_bad ( struct drm_i915_private * dev_priv ,
int hdisplay )
{
/*
* Older platforms don ' t like hdisplay = = 4096 with DP .
*
* On ILK / SNB / IVB the pipe seems to be somewhat running ( scanline
* and frame counter increment ) , but we don ' t get vblank interrupts ,
* and the pipe underruns immediately . The link also doesn ' t seem
* to get trained properly .
*
* On CHV the vblank interrupts don ' t seem to disappear but
* otherwise the symptoms are similar .
*
* TODO : confirm the behaviour on HSW +
*/
return hdisplay = = 4096 & & ! HAS_DDI ( dev_priv ) ;
}
2020-09-04 14:53:45 +03:00
static enum drm_mode_status
intel_dp_mode_valid_downstream ( struct intel_connector * connector ,
2020-09-04 14:53:47 +03:00
const struct drm_display_mode * mode ,
2020-09-04 14:53:45 +03:00
int target_clock )
{
struct intel_dp * intel_dp = intel_attached_dp ( connector ) ;
2020-09-04 14:53:47 +03:00
const struct drm_display_info * info = & connector - > base . display_info ;
int tmds_clock ;
2020-09-04 14:53:45 +03:00
2020-12-18 16:07:16 +05:30
/* If PCON supports FRL MODE, check FRL bandwidth constraints */
if ( intel_dp - > dfp . pcon_max_frl_bw ) {
int target_bw ;
int max_frl_bw ;
int bpp = intel_dp_mode_min_output_bpp ( & connector - > base , mode ) ;
target_bw = bpp * target_clock ;
max_frl_bw = intel_dp - > dfp . pcon_max_frl_bw ;
/* converting bw from Gbps to Kbps*/
max_frl_bw = max_frl_bw * 1000000 ;
if ( target_bw > max_frl_bw )
return MODE_CLOCK_HIGH ;
return MODE_OK ;
}
2020-09-04 14:53:45 +03:00
if ( intel_dp - > dfp . max_dotclock & &
target_clock > intel_dp - > dfp . max_dotclock )
return MODE_CLOCK_HIGH ;
2020-09-04 14:53:47 +03:00
/* Assume 8bpc for the DP++/HDMI/DVI TMDS clock check */
tmds_clock = target_clock ;
if ( drm_mode_is_420_only ( info , mode ) )
tmds_clock / = 2 ;
if ( intel_dp - > dfp . min_tmds_clock & &
tmds_clock < intel_dp - > dfp . min_tmds_clock )
return MODE_CLOCK_LOW ;
if ( intel_dp - > dfp . max_tmds_clock & &
tmds_clock > intel_dp - > dfp . max_tmds_clock )
return MODE_CLOCK_HIGH ;
2020-09-04 14:53:45 +03:00
return MODE_OK ;
}
2013-11-28 15:29:18 +00:00
static enum drm_mode_status
2009-04-07 16:16:42 -07:00
intel_dp_mode_valid ( struct drm_connector * connector ,
struct drm_display_mode * mode )
{
2019-12-04 20:05:42 +02:00
struct intel_dp * intel_dp = intel_attached_dp ( to_intel_connector ( connector ) ) ;
2012-10-19 14:51:50 +03:00
struct intel_connector * intel_connector = to_intel_connector ( connector ) ;
struct drm_display_mode * fixed_mode = intel_connector - > panel . fixed_mode ;
2018-10-30 17:19:22 -07:00
struct drm_i915_private * dev_priv = to_i915 ( connector - > dev ) ;
2013-03-27 00:44:59 +01:00
int target_clock = mode - > clock ;
int max_rate , mode_rate , max_lanes , max_link_clock ;
2020-09-04 14:53:45 +03:00
int max_dotclk = dev_priv - > max_dotclk_freq ;
2018-10-30 17:19:22 -07:00
u16 dsc_max_output_bpp = 0 ;
u8 dsc_slice_count = 0 ;
2020-09-04 14:53:45 +03:00
enum drm_mode_status status ;
2020-11-17 11:47:05 -08:00
bool dsc = false , bigjoiner = false ;
2016-09-09 14:10:55 +03:00
2018-05-24 15:54:03 +03:00
if ( mode - > flags & DRM_MODE_FLAG_DBLSCAN )
return MODE_NO_DBLESCAN ;
2020-11-11 18:39:49 -08:00
if ( mode - > flags & DRM_MODE_FLAG_DBLCLK )
return MODE_H_ILLEGAL ;
2017-08-18 12:30:20 +03:00
if ( intel_dp_is_edp ( intel_dp ) & & fixed_mode ) {
2012-10-19 14:51:50 +03:00
if ( mode - > hdisplay > fixed_mode - > hdisplay )
2010-07-19 09:43:14 +01:00
return MODE_PANEL ;
2012-10-19 14:51:50 +03:00
if ( mode - > vdisplay > fixed_mode - > vdisplay )
2010-07-19 09:43:14 +01:00
return MODE_PANEL ;
2013-04-02 23:42:31 +02:00
target_clock = fixed_mode - > clock ;
2010-07-19 09:43:14 +01:00
}
2020-11-11 18:39:49 -08:00
if ( mode - > clock < 10000 )
return MODE_CLOCK_LOW ;
2020-11-17 11:47:05 -08:00
if ( ( target_clock > max_dotclk | | mode - > hdisplay > 5120 ) & &
intel_dp_can_bigjoiner ( intel_dp ) ) {
bigjoiner = true ;
max_dotclk * = 2 ;
}
if ( target_clock > max_dotclk )
return MODE_CLOCK_HIGH ;
2015-03-12 17:10:34 +02:00
max_link_clock = intel_dp_max_link_rate ( intel_dp ) ;
2014-05-06 14:56:50 +03:00
max_lanes = intel_dp_max_lane_count ( intel_dp ) ;
2013-03-27 00:44:59 +01:00
max_rate = intel_dp_max_data_rate ( max_link_clock , max_lanes ) ;
2020-09-18 00:43:35 +03:00
mode_rate = intel_dp_link_required ( target_clock ,
intel_dp_mode_min_output_bpp ( connector , mode ) ) ;
2013-03-27 00:44:59 +01:00
2019-07-18 17:43:39 +03:00
if ( intel_dp_hdisplay_bad ( dev_priv , mode - > hdisplay ) )
return MODE_H_ILLEGAL ;
2018-10-30 17:19:22 -07:00
/*
* Output bpp is stored in 6.4 format so right shift by 4 to get the
* integer value since we support only integer values of bpp .
*/
if ( ( INTEL_GEN ( dev_priv ) > = 10 | | IS_GEMINILAKE ( dev_priv ) ) & &
drm_dp_sink_supports_dsc ( intel_dp - > dsc_dpcd ) ) {
if ( intel_dp_is_edp ( intel_dp ) ) {
dsc_max_output_bpp =
drm_edp_dsc_sink_output_bpp ( intel_dp - > dsc_dpcd ) > > 4 ;
dsc_slice_count =
drm_dp_dsc_sink_max_slice_count ( intel_dp - > dsc_dpcd ,
true ) ;
2018-11-28 12:26:25 -08:00
} else if ( drm_dp_sink_supports_fec ( intel_dp - > fec_capable ) ) {
2018-10-30 17:19:22 -07:00
dsc_max_output_bpp =
2019-09-25 16:45:42 -07:00
intel_dp_dsc_get_output_bpp ( dev_priv ,
max_link_clock ,
2018-10-30 17:19:22 -07:00
max_lanes ,
target_clock ,
2020-11-17 11:47:05 -08:00
mode - > hdisplay ,
bigjoiner ) > > 4 ;
2018-10-30 17:19:22 -07:00
dsc_slice_count =
intel_dp_dsc_get_slice_count ( intel_dp ,
target_clock ,
2020-11-17 11:47:05 -08:00
mode - > hdisplay ,
bigjoiner ) ;
2018-10-30 17:19:22 -07:00
}
2020-11-17 11:47:05 -08:00
dsc = dsc_max_output_bpp & & dsc_slice_count ;
2018-10-30 17:19:22 -07:00
}
2020-11-17 11:47:05 -08:00
/* big joiner configuration needs DSC */
if ( bigjoiner & & ! dsc )
2012-04-10 10:42:36 +02:00
return MODE_CLOCK_HIGH ;
2009-04-07 16:16:42 -07:00
2020-11-17 11:47:05 -08:00
if ( mode_rate > max_rate & & ! dsc )
2012-04-10 10:42:36 +02:00
return MODE_CLOCK_HIGH ;
2012-05-23 11:30:55 +02:00
2020-09-04 14:53:47 +03:00
status = intel_dp_mode_valid_downstream ( intel_connector ,
mode , target_clock ) ;
2020-09-04 14:53:45 +03:00
if ( status ! = MODE_OK )
return status ;
2020-11-17 11:47:05 -08:00
return intel_mode_valid_max_plane_size ( dev_priv , mode , bigjoiner ) ;
2009-04-07 16:16:42 -07:00
}
2019-01-16 11:15:27 +02:00
u32 intel_dp_pack_aux ( const u8 * src , int src_bytes )
2009-04-07 16:16:42 -07:00
{
2019-01-16 11:15:27 +02:00
int i ;
u32 v = 0 ;
2009-04-07 16:16:42 -07:00
if ( src_bytes > 4 )
src_bytes = 4 ;
for ( i = 0 ; i < src_bytes ; i + + )
2019-01-16 11:15:27 +02:00
v | = ( ( u32 ) src [ i ] ) < < ( ( 3 - i ) * 8 ) ;
2009-04-07 16:16:42 -07:00
return v ;
}
2019-01-16 11:15:27 +02:00
static void intel_dp_unpack_aux ( u32 src , u8 * dst , int dst_bytes )
2009-04-07 16:16:42 -07:00
{
int i ;
if ( dst_bytes > 4 )
dst_bytes = 4 ;
for ( i = 0 ; i < dst_bytes ; i + + )
dst [ i ] = src > > ( ( 3 - i ) * 8 ) ;
}
2019-01-16 11:15:27 +02:00
static u32
2018-05-23 11:04:35 -07:00
intel_dp_aux_wait_done ( struct intel_dp * intel_dp )
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
{
2019-06-11 11:45:47 +01:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2018-02-22 20:10:31 +02:00
i915_reg_t ch_ctl = intel_dp - > aux_ch_ctl_reg ( intel_dp ) ;
2019-10-29 10:31:02 -07:00
const unsigned int timeout_ms = 10 ;
2019-01-16 11:15:27 +02:00
u32 status ;
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
bool done ;
2019-06-11 11:45:47 +01:00
# define C (((status = intel_uncore_read_notrace(&i915->uncore, ch_ctl)) & DP_AUX_CH_CTL_SEND_BUSY) == 0)
done = wait_event_timeout ( i915 - > gmbus_wait_queue , C ,
2019-10-29 10:31:02 -07:00
msecs_to_jiffies_timeout ( timeout_ms ) ) ;
2019-02-04 23:16:44 +02:00
/* just trace the final value */
trace_i915_reg_rw ( false , ch_ctl , status , sizeof ( status ) , true ) ;
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
if ( ! done )
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_err ( & i915 - > drm ,
2020-01-23 17:45:41 +02:00
" %s: did not complete or timeout within %ums (status 0x%08x) \n " ,
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
intel_dp - > aux . name , timeout_ms , status ) ;
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
# undef C
return status ;
}
2019-01-16 11:15:27 +02:00
static u32 g4x_get_aux_clock_divider ( struct intel_dp * intel_dp , int index )
2009-04-07 16:16:42 -07:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
2016-03-02 17:22:17 +02:00
if ( index )
return 0 ;
2014-01-21 13:35:39 +00:00
/*
* The clock divider is based off the hrawclk , and would like to run at
2016-03-02 17:22:17 +02:00
* 2 MHz . So , take the hrawclk value and divide by 2000 and use that
2009-04-07 16:16:42 -07:00
*/
2020-02-16 16:34:45 +00:00
return DIV_ROUND_CLOSEST ( RUNTIME_INFO ( dev_priv ) - > rawclk_freq , 2000 ) ;
2014-01-21 13:35:39 +00:00
}
2019-01-16 11:15:27 +02:00
static u32 ilk_get_aux_clock_divider ( struct intel_dp * intel_dp , int index )
2014-01-21 13:35:39 +00:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2020-02-16 16:34:45 +00:00
u32 freq ;
2014-01-21 13:35:39 +00:00
if ( index )
return 0 ;
2016-03-02 17:22:17 +02:00
/*
* The clock divider is based off the cdclk or PCH rawclk , and would
* like to run at 2 MHz . So , take the cdclk or PCH rawclk value and
* divide by 2000 and use that
*/
2018-11-01 16:04:21 +02:00
if ( dig_port - > aux_ch = = AUX_CH_A )
2020-02-16 16:34:45 +00:00
freq = dev_priv - > cdclk . hw . cdclk ;
2016-03-02 17:22:13 +02:00
else
2020-02-16 16:34:45 +00:00
freq = RUNTIME_INFO ( dev_priv ) - > rawclk_freq ;
return DIV_ROUND_CLOSEST ( freq , 2000 ) ;
2014-01-21 13:35:39 +00:00
}
2019-01-16 11:15:27 +02:00
static u32 hsw_get_aux_clock_divider ( struct intel_dp * intel_dp , int index )
2014-01-21 13:35:39 +00:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2014-01-21 13:35:39 +00:00
2018-11-01 16:04:21 +02:00
if ( dig_port - > aux_ch ! = AUX_CH_A & & HAS_PCH_LPT_H ( dev_priv ) ) {
2013-04-09 08:11:00 +03:00
/* Workaround for non-ULT HSW */
2013-07-21 16:00:03 +01:00
switch ( index ) {
case 0 : return 63 ;
case 1 : return 72 ;
default : return 0 ;
}
2013-04-09 08:11:00 +03:00
}
2016-03-02 17:22:17 +02:00
return ilk_get_aux_clock_divider ( intel_dp , index ) ;
2013-07-11 18:44:57 -03:00
}
2019-01-16 11:15:27 +02:00
static u32 skl_get_aux_clock_divider ( struct intel_dp * intel_dp , int index )
2014-01-20 16:00:59 +00:00
{
/*
* SKL doesn ' t need us to program the AUX clock divider ( Hardware will
* derive the clock from CDCLK automatically ) . We still implement the
* get_aux_clock_divider vfunc to plug - in into the existing code .
*/
return index ? 0 : 1 ;
}
2019-01-16 11:15:27 +02:00
static u32 g4x_get_aux_send_ctl ( struct intel_dp * intel_dp ,
int send_bytes ,
u32 aux_clock_divider )
2014-01-20 15:52:30 +00:00
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2016-10-13 11:03:00 +01:00
struct drm_i915_private * dev_priv =
2020-06-30 21:50:54 -07:00
to_i915 ( dig_port - > base . base . dev ) ;
2019-01-16 11:15:27 +02:00
u32 precharge , timeout ;
2014-01-20 15:52:30 +00:00
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 , 6 ) )
2014-01-20 15:52:30 +00:00
precharge = 3 ;
else
precharge = 5 ;
2017-10-12 14:30:37 -07:00
if ( IS_BROADWELL ( dev_priv ) )
2014-01-20 15:52:30 +00:00
timeout = DP_AUX_CH_CTL_TIME_OUT_600us ;
else
timeout = DP_AUX_CH_CTL_TIME_OUT_400us ;
return DP_AUX_CH_CTL_SEND_BUSY |
2014-01-20 15:52:31 +00:00
DP_AUX_CH_CTL_DONE |
2018-05-23 11:04:35 -07:00
DP_AUX_CH_CTL_INTERRUPT |
2014-01-20 15:52:31 +00:00
DP_AUX_CH_CTL_TIME_OUT_ERROR |
2014-01-20 15:52:30 +00:00
timeout |
2014-01-20 15:52:31 +00:00
DP_AUX_CH_CTL_RECEIVE_ERROR |
2014-01-20 15:52:30 +00:00
( send_bytes < < DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT ) |
( precharge < < DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT ) |
2014-01-20 15:52:31 +00:00
( aux_clock_divider < < DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT ) ;
2014-01-20 15:52:30 +00:00
}
2019-01-16 11:15:27 +02:00
static u32 skl_get_aux_send_ctl ( struct intel_dp * intel_dp ,
int send_bytes ,
u32 unused )
2014-01-20 16:01:00 +00:00
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2019-10-28 18:10:14 -07:00
struct drm_i915_private * i915 =
2020-06-30 21:50:54 -07:00
to_i915 ( dig_port - > base . base . dev ) ;
enum phy phy = intel_port_to_phy ( i915 , dig_port - > base . port ) ;
2019-01-16 11:15:27 +02:00
u32 ret ;
2018-07-26 16:35:15 -07:00
ret = DP_AUX_CH_CTL_SEND_BUSY |
DP_AUX_CH_CTL_DONE |
DP_AUX_CH_CTL_INTERRUPT |
DP_AUX_CH_CTL_TIME_OUT_ERROR |
DP_AUX_CH_CTL_TIME_OUT_MAX |
DP_AUX_CH_CTL_RECEIVE_ERROR |
( send_bytes < < DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT ) |
DP_AUX_CH_CTL_FW_SYNC_PULSE_SKL ( 32 ) |
DP_AUX_CH_CTL_SYNC_PULSE_SKL ( 32 ) ;
2019-10-28 18:10:14 -07:00
if ( intel_phy_is_tc ( i915 , phy ) & &
2020-06-30 21:50:54 -07:00
dig_port - > tc_mode = = TC_PORT_TBT_ALT )
2018-07-26 16:35:15 -07:00
ret | = DP_AUX_CH_CTL_TBT_IO ;
return ret ;
2014-01-20 16:01:00 +00:00
}
2013-07-11 18:44:57 -03:00
static int
2018-02-22 20:10:34 +02:00
intel_dp_aux_xfer ( struct intel_dp * intel_dp ,
2019-01-16 11:15:27 +02:00
const u8 * send , int send_bytes ,
u8 * recv , int recv_size ,
2018-02-22 23:27:32 +02:00
u32 aux_send_ctl_flags )
2013-07-11 18:44:57 -03:00
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2019-06-11 11:45:47 +01:00
struct drm_i915_private * i915 =
2020-06-30 21:50:54 -07:00
to_i915 ( dig_port - > base . base . dev ) ;
2019-06-11 11:45:47 +01:00
struct intel_uncore * uncore = & i915 - > uncore ;
2020-06-30 21:50:54 -07:00
enum phy phy = intel_port_to_phy ( i915 , dig_port - > base . port ) ;
2019-07-09 11:39:33 -07:00
bool is_tc_port = intel_phy_is_tc ( i915 , phy ) ;
2018-02-22 20:10:31 +02:00
i915_reg_t ch_ctl , ch_data [ 5 ] ;
2019-01-16 11:15:27 +02:00
u32 aux_clock_divider ;
2020-05-14 23:45:53 +03:00
enum intel_display_power_domain aux_domain ;
2019-05-09 20:34:40 +03:00
intel_wakeref_t aux_wakeref ;
intel_wakeref_t pps_wakeref ;
2013-07-11 18:44:57 -03:00
int i , ret , recv_bytes ;
2014-01-20 15:52:30 +00:00
int try , clock = 0 ;
2019-01-16 11:15:27 +02:00
u32 status ;
2014-03-14 16:51:14 +02:00
bool vdd ;
2018-02-22 20:10:31 +02:00
ch_ctl = intel_dp - > aux_ch_ctl_reg ( intel_dp ) ;
for ( i = 0 ; i < ARRAY_SIZE ( ch_data ) ; i + + )
ch_data [ i ] = intel_dp - > aux_ch_data_reg ( intel_dp , i ) ;
2019-06-28 17:36:26 +03:00
if ( is_tc_port )
2020-06-30 21:50:54 -07:00
intel_tc_port_lock ( dig_port ) ;
2019-06-28 17:36:26 +03:00
2020-06-30 21:50:54 -07:00
aux_domain = intel_aux_power_domain ( dig_port ) ;
2020-05-14 23:45:53 +03:00
2019-06-11 11:45:47 +01:00
aux_wakeref = intel_display_power_get ( i915 , aux_domain ) ;
2021-01-08 19:44:10 +02:00
pps_wakeref = intel_pps_lock ( intel_dp ) ;
2014-09-04 14:53:14 +03:00
2014-08-18 22:16:00 +03:00
/*
* We will be called with VDD already enabled for dpcd / edid / oui reads .
* In such cases we want to leave VDD enabled and it ' s up to upper layers
* to turn it off . But for eg . i2c - dev access we need to turn it on / off
* ourselves .
*/
2021-01-08 19:44:13 +02:00
vdd = intel_pps_vdd_on_unlocked ( intel_dp ) ;
2013-07-11 18:44:57 -03:00
/* dp aux is extremely sensitive to irq latency, hence request the
* lowest possible wakeup latency and so prevent the cpu from going into
* deep sleep states .
*/
2020-12-30 20:23:09 +00:00
cpu_latency_qos_update_request ( & intel_dp - > pm_qos , 0 ) ;
2013-07-11 18:44:57 -03:00
intel_dp_check_edp ( intel_dp ) ;
2009-07-24 01:00:31 +08:00
2011-08-01 15:02:20 -07:00
/* Try to wait for any previous AUX channel activity */
for ( try = 0 ; try < 3 ; try + + ) {
2019-06-11 11:45:47 +01:00
status = intel_uncore_read_notrace ( uncore , ch_ctl ) ;
2011-08-01 15:02:20 -07:00
if ( ( status & DP_AUX_CH_CTL_SEND_BUSY ) = = 0 )
break ;
msleep ( 1 ) ;
}
2019-02-04 23:16:44 +02:00
/* just trace the final value */
trace_i915_reg_rw ( false , ch_ctl , status , sizeof ( status ) , true ) ;
2011-08-01 15:02:20 -07:00
if ( try = = 3 ) {
2019-06-11 11:45:47 +01:00
const u32 status = intel_uncore_read ( uncore , ch_ctl ) ;
2015-08-06 16:48:58 +03:00
2019-10-02 17:41:38 +03:00
if ( status ! = intel_dp - > aux_busy_last_status ) {
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
drm_WARN ( & i915 - > drm , 1 ,
" %s: not started (status 0x%08x) \n " ,
intel_dp - > aux . name , status ) ;
2019-10-02 17:41:38 +03:00
intel_dp - > aux_busy_last_status = status ;
2015-08-06 16:48:58 +03:00
}
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
ret = - EBUSY ;
goto out ;
2010-08-18 18:12:56 +01:00
}
2013-09-17 11:14:10 -03:00
/* Only 5 data registers! */
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
if ( drm_WARN_ON ( & i915 - > drm , send_bytes > 20 | | recv_size > 20 ) ) {
2013-09-17 11:14:10 -03:00
ret = - E2BIG ;
goto out ;
}
2014-01-21 13:35:39 +00:00
while ( ( aux_clock_divider = intel_dp - > get_aux_clock_divider ( intel_dp , clock + + ) ) ) {
2018-02-22 23:27:32 +02:00
u32 send_ctl = intel_dp - > get_aux_send_ctl ( intel_dp ,
send_bytes ,
aux_clock_divider ) ;
send_ctl | = aux_send_ctl_flags ;
2014-01-20 15:52:30 +00:00
2013-07-21 16:00:03 +01:00
/* Must try at least 3 times according to DP spec */
for ( try = 0 ; try < 5 ; try + + ) {
/* Load the send data into the aux channel data registers */
for ( i = 0 ; i < send_bytes ; i + = 4 )
2019-06-11 11:45:47 +01:00
intel_uncore_write ( uncore ,
ch_data [ i > > 2 ] ,
intel_dp_pack_aux ( send + i ,
send_bytes - i ) ) ;
2013-07-21 16:00:03 +01:00
/* Send the command and wait for it to complete */
2019-06-11 11:45:47 +01:00
intel_uncore_write ( uncore , ch_ctl , send_ctl ) ;
2013-07-21 16:00:03 +01:00
2018-05-23 11:04:35 -07:00
status = intel_dp_aux_wait_done ( intel_dp ) ;
2013-07-21 16:00:03 +01:00
/* Clear done status and any errors */
2019-06-11 11:45:47 +01:00
intel_uncore_write ( uncore ,
ch_ctl ,
status |
DP_AUX_CH_CTL_DONE |
DP_AUX_CH_CTL_TIME_OUT_ERROR |
DP_AUX_CH_CTL_RECEIVE_ERROR ) ;
2013-07-21 16:00:03 +01:00
2015-04-15 08:38:41 -07:00
/* DP CTS 1.2 Core Rev 1.1, 4.2.1.1 & 4.2.1.2
* 400u s delay required for errors and timeouts
* Timeout errors from the HW already meet this
* requirement so skip to next iteration
*/
2018-02-23 14:15:20 -08:00
if ( status & DP_AUX_CH_CTL_TIME_OUT_ERROR )
continue ;
2015-04-15 08:38:41 -07:00
if ( status & DP_AUX_CH_CTL_RECEIVE_ERROR ) {
usleep_range ( 400 , 500 ) ;
2013-07-21 16:00:03 +01:00
continue ;
2015-04-15 08:38:41 -07:00
}
2013-07-21 16:00:03 +01:00
if ( status & DP_AUX_CH_CTL_DONE )
2015-05-27 10:21:48 -07:00
goto done ;
2013-07-21 16:00:03 +01:00
}
2009-04-07 16:16:42 -07:00
}
if ( ( status & DP_AUX_CH_CTL_DONE ) = = 0 ) {
2020-01-23 17:45:41 +02:00
drm_err ( & i915 - > drm , " %s: not done (status 0x%08x) \n " ,
intel_dp - > aux . name , status ) ;
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
ret = - EBUSY ;
goto out ;
2009-04-07 16:16:42 -07:00
}
2015-05-27 10:21:48 -07:00
done :
2009-04-07 16:16:42 -07:00
/* Check for timeout or receive error.
* Timeouts occur when the sink is not connected
*/
2009-06-11 22:30:32 -07:00
if ( status & DP_AUX_CH_CTL_RECEIVE_ERROR ) {
2020-01-23 17:45:41 +02:00
drm_err ( & i915 - > drm , " %s: receive error (status 0x%08x) \n " ,
intel_dp - > aux . name , status ) ;
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
ret = - EIO ;
goto out ;
2009-06-11 22:30:32 -07:00
}
2009-06-28 15:42:17 -07:00
/* Timeouts occur when the device isn't connected, so they're
* " normal " - - don ' t fill the kernel log with these */
2009-06-11 22:30:32 -07:00
if ( status & DP_AUX_CH_CTL_TIME_OUT_ERROR ) {
2020-01-23 17:45:41 +02:00
drm_dbg_kms ( & i915 - > drm , " %s: timeout (status 0x%08x) \n " ,
intel_dp - > aux . name , status ) ;
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
ret = - ETIMEDOUT ;
goto out ;
2009-04-07 16:16:42 -07:00
}
/* Unload any bytes sent back from the other side */
recv_bytes = ( ( status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK ) > >
DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT ) ;
2015-12-10 11:12:27 -08:00
/*
* By BSpec : " Message sizes of 0 or >20 are not allowed. "
* We have no idea of what happened so we return - EBUSY so
* drm layer takes care for the necessary retries .
*/
if ( recv_bytes = = 0 | | recv_bytes > 20 ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & i915 - > drm ,
2020-01-23 17:45:41 +02:00
" %s: Forbidden recv_bytes = %d on aux transaction \n " ,
intel_dp - > aux . name , recv_bytes ) ;
2015-12-10 11:12:27 -08:00
ret = - EBUSY ;
goto out ;
}
2009-04-07 16:16:42 -07:00
if ( recv_bytes > recv_size )
recv_bytes = recv_size ;
2011-08-16 15:34:10 -04:00
2010-08-18 18:12:56 +01:00
for ( i = 0 ; i < recv_bytes ; i + = 4 )
2019-06-11 11:45:47 +01:00
intel_dp_unpack_aux ( intel_uncore_read ( uncore , ch_data [ i > > 2 ] ) ,
2014-11-14 08:52:27 -08:00
recv + i , recv_bytes - i ) ;
2009-04-07 16:16:42 -07:00
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
ret = recv_bytes ;
out :
2020-12-30 20:23:09 +00:00
cpu_latency_qos_update_request ( & intel_dp - > pm_qos , PM_QOS_DEFAULT_VALUE ) ;
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
2014-03-14 16:51:14 +02:00
if ( vdd )
2021-01-08 19:44:13 +02:00
intel_pps_vdd_off_unlocked ( intel_dp , false ) ;
2014-03-14 16:51:14 +02:00
2021-01-08 19:44:10 +02:00
intel_pps_unlock ( intel_dp , pps_wakeref ) ;
2019-06-11 11:45:47 +01:00
intel_display_power_put_async ( i915 , aux_domain , aux_wakeref ) ;
2014-09-04 14:53:14 +03:00
2019-06-28 17:36:26 +03:00
if ( is_tc_port )
2020-06-30 21:50:54 -07:00
intel_tc_port_unlock ( dig_port ) ;
2019-06-28 17:36:26 +03:00
drm/i915: irq-drive the dp aux communication
At least on the platforms that have a dp aux irq and also have it
enabled - vlvhsw should have one, too. But I don't have a machine to
test this on. Judging from docs there's no dp aux interrupt for gm45.
Also, I only have an ivb cpu edp machine, so the dp aux A code for
snb/ilk is untested.
For dpcd probing when nothing is connected it slashes about 5ms of cpu
time (cpu time is now negligible), which agrees with 3 * 5 400 usec
timeouts.
A previous version of this patch increases the time required to go
through the dp_detect cycle (which includes reading the edid) from
around 33 ms to around 40 ms. Experiments indicated that this is
purely due to the irq latency - the hw doesn't allow us to queue up
dp aux transactions and hence irq latency directly affects throughput.
gmbus is much better, there we have a 8 byte buffer, and we get the
irq once another 4 bytes can be queued up.
But by using the pm_qos interface to request the lowest possible cpu
wake-up latency this slowdown completely disappeared.
Since all our output detection logic is single-threaded with the
mode_config mutex right now anyway, I've decide not ot play fancy and
to just reuse the gmbus wait queue. But this would definitely prep the
way to run dp detection on different ports in parallel
v2: Add a timeout for dp aux transfers when using interrupts - the hw
_does_ prevent this with the hw-based 400 usec timeout, but if the
irq somehow doesn't arrive we're screwed. Lesson learned while
developing this ;-)
v3: While at it also convert the busy-loop to wait_for_atomic, so that
we don't run the risk of an infinite loop any more.
v4: Ensure we have the smallest possible irq latency by using the
pm_qos interface.
v5: Add a comment to the code to explain why we frob pm_qos. Suggested
by Chris Wilson.
v6: Disable dp irq for vlv, that's easier than trying to get at docs
and hw.
v7: Squash in a fix for Haswell that Paulo Zanoni tracked down - the
dp aux registers aren't at a fixed offset any more, but can be on the
PCH while the DP port is on the cpu die.
Reviewed-by: Imre Deak <imre.deak@intel.com> (v6)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-12-01 13:53:48 +01:00
return ret ;
2009-04-07 16:16:42 -07:00
}
2014-04-07 12:37:25 +03:00
# define BARE_ADDRESS_SIZE 3
# define HEADER_SIZE (BARE_ADDRESS_SIZE + 1)
2018-02-22 23:28:02 +02:00
static void
intel_dp_aux_header ( u8 txbuf [ HEADER_SIZE ] ,
const struct drm_dp_aux_msg * msg )
{
txbuf [ 0 ] = ( msg - > request < < 4 ) | ( ( msg - > address > > 16 ) & 0xf ) ;
txbuf [ 1 ] = ( msg - > address > > 8 ) & 0xff ;
txbuf [ 2 ] = msg - > address & 0xff ;
txbuf [ 3 ] = msg - > size - 1 ;
}
2020-08-18 11:38:52 -04:00
static u32 intel_dp_aux_xfer_flags ( const struct drm_dp_aux_msg * msg )
{
/*
* If we ' re trying to send the HDCP Aksv , we need to set a the Aksv
* select bit to inform the hardware to send the Aksv after our header
* since we can ' t access that data from software .
*/
if ( ( msg - > request & ~ DP_AUX_I2C_MOT ) = = DP_AUX_NATIVE_WRITE & &
msg - > address = = DP_AUX_HDCP_AKSV )
return DP_AUX_CH_CTL_AUX_AKSV_SELECT ;
return 0 ;
}
2014-03-14 16:51:15 +02:00
static ssize_t
intel_dp_aux_transfer ( struct drm_dp_aux * aux , struct drm_dp_aux_msg * msg )
2009-04-07 16:16:42 -07:00
{
2014-03-14 16:51:15 +02:00
struct intel_dp * intel_dp = container_of ( aux , struct intel_dp , aux ) ;
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2019-01-16 11:15:27 +02:00
u8 txbuf [ 20 ] , rxbuf [ 20 ] ;
2014-03-14 16:51:15 +02:00
size_t txsize , rxsize ;
2020-08-18 11:38:52 -04:00
u32 flags = intel_dp_aux_xfer_flags ( msg ) ;
2009-04-07 16:16:42 -07:00
int ret ;
2018-02-22 23:28:02 +02:00
intel_dp_aux_header ( txbuf , msg ) ;
2013-09-17 11:14:10 -03:00
2014-03-14 16:51:15 +02:00
switch ( msg - > request & ~ DP_AUX_I2C_MOT ) {
case DP_AUX_NATIVE_WRITE :
case DP_AUX_I2C_WRITE :
2015-08-27 17:23:27 +03:00
case DP_AUX_I2C_WRITE_STATUS_UPDATE :
2014-04-07 12:37:25 +03:00
txsize = msg - > size ? HEADER_SIZE + msg - > size : BARE_ADDRESS_SIZE ;
2015-03-17 17:18:54 +02:00
rxsize = 2 ; /* 0 or 1 data bytes */
2014-02-11 11:52:05 +02:00
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
if ( drm_WARN_ON ( & i915 - > drm , txsize > 20 ) )
2014-03-14 16:51:15 +02:00
return - E2BIG ;
2009-04-07 16:16:42 -07:00
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
drm_WARN_ON ( & i915 - > drm , ! msg - > buffer ! = ! msg - > size ) ;
2016-07-28 17:55:04 +03:00
2016-01-29 14:52:26 +02:00
if ( msg - > buffer )
memcpy ( txbuf + HEADER_SIZE , msg - > buffer , msg - > size ) ;
2009-04-07 16:16:42 -07:00
2018-02-22 20:10:34 +02:00
ret = intel_dp_aux_xfer ( intel_dp , txbuf , txsize ,
2020-08-18 11:38:52 -04:00
rxbuf , rxsize , flags ) ;
2014-03-14 16:51:15 +02:00
if ( ret > 0 ) {
msg - > reply = rxbuf [ 0 ] > > 4 ;
2009-04-07 16:16:42 -07:00
2015-03-17 17:18:54 +02:00
if ( ret > 1 ) {
/* Number of bytes written in a short write. */
ret = clamp_t ( int , rxbuf [ 1 ] , 0 , msg - > size ) ;
} else {
/* Return payload size. */
ret = msg - > size ;
}
2014-03-14 16:51:15 +02:00
}
break ;
2013-09-17 11:14:10 -03:00
2014-03-14 16:51:15 +02:00
case DP_AUX_NATIVE_READ :
case DP_AUX_I2C_READ :
2014-04-07 12:37:25 +03:00
txsize = msg - > size ? HEADER_SIZE : BARE_ADDRESS_SIZE ;
2014-03-14 16:51:15 +02:00
rxsize = msg - > size + 1 ;
2009-04-07 16:16:42 -07:00
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
if ( drm_WARN_ON ( & i915 - > drm , rxsize > 20 ) )
2014-03-14 16:51:15 +02:00
return - E2BIG ;
2009-04-07 16:16:42 -07:00
2018-02-22 20:10:34 +02:00
ret = intel_dp_aux_xfer ( intel_dp , txbuf , txsize ,
2020-08-18 11:38:52 -04:00
rxbuf , rxsize , flags ) ;
2014-03-14 16:51:15 +02:00
if ( ret > 0 ) {
msg - > reply = rxbuf [ 0 ] > > 4 ;
/*
* Assume happy day , and copy the data . The caller is
* expected to check msg - > reply before touching it .
*
* Return payload size .
*/
ret - - ;
memcpy ( msg - > buffer , rxbuf + 1 , ret ) ;
2009-04-07 16:16:42 -07:00
}
2014-03-14 16:51:15 +02:00
break ;
default :
ret = - EINVAL ;
break ;
2009-04-07 16:16:42 -07:00
}
2014-02-11 11:52:05 +02:00
2014-03-14 16:51:15 +02:00
return ret ;
2009-04-07 16:16:42 -07:00
}
2016-10-11 20:52:45 +03:00
2018-02-22 20:10:31 +02:00
static i915_reg_t g4x_aux_ctl_reg ( struct intel_dp * intel_dp )
2015-11-11 20:34:13 +02:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
enum aux_ch aux_ch = dig_port - > aux_ch ;
2018-02-22 20:10:31 +02:00
2018-02-22 20:10:30 +02:00
switch ( aux_ch ) {
case AUX_CH_B :
case AUX_CH_C :
case AUX_CH_D :
return DP_AUX_CH_CTL ( aux_ch ) ;
2015-11-11 20:34:13 +02:00
default :
2018-02-22 20:10:30 +02:00
MISSING_CASE ( aux_ch ) ;
return DP_AUX_CH_CTL ( AUX_CH_B ) ;
2015-11-11 20:34:13 +02:00
}
}
2018-02-22 20:10:31 +02:00
static i915_reg_t g4x_aux_data_reg ( struct intel_dp * intel_dp , int index )
2015-11-11 20:34:14 +02:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
enum aux_ch aux_ch = dig_port - > aux_ch ;
2018-02-22 20:10:31 +02:00
2018-02-22 20:10:30 +02:00
switch ( aux_ch ) {
case AUX_CH_B :
case AUX_CH_C :
case AUX_CH_D :
return DP_AUX_CH_DATA ( aux_ch , index ) ;
2015-11-11 20:34:14 +02:00
default :
2018-02-22 20:10:30 +02:00
MISSING_CASE ( aux_ch ) ;
return DP_AUX_CH_DATA ( AUX_CH_B , index ) ;
2015-11-11 20:34:14 +02:00
}
}
2018-02-22 20:10:31 +02:00
static i915_reg_t ilk_aux_ctl_reg ( struct intel_dp * intel_dp )
2018-02-22 20:10:30 +02:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
enum aux_ch aux_ch = dig_port - > aux_ch ;
2018-02-22 20:10:31 +02:00
2018-02-22 20:10:30 +02:00
switch ( aux_ch ) {
case AUX_CH_A :
return DP_AUX_CH_CTL ( aux_ch ) ;
case AUX_CH_B :
case AUX_CH_C :
case AUX_CH_D :
return PCH_DP_AUX_CH_CTL ( aux_ch ) ;
2015-11-11 20:34:13 +02:00
default :
2018-02-22 20:10:30 +02:00
MISSING_CASE ( aux_ch ) ;
return DP_AUX_CH_CTL ( AUX_CH_A ) ;
2015-11-11 20:34:13 +02:00
}
}
2018-02-22 20:10:31 +02:00
static i915_reg_t ilk_aux_data_reg ( struct intel_dp * intel_dp , int index )
2018-02-22 20:10:30 +02:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
enum aux_ch aux_ch = dig_port - > aux_ch ;
2018-02-22 20:10:31 +02:00
2018-02-22 20:10:30 +02:00
switch ( aux_ch ) {
case AUX_CH_A :
return DP_AUX_CH_DATA ( aux_ch , index ) ;
case AUX_CH_B :
case AUX_CH_C :
case AUX_CH_D :
return PCH_DP_AUX_CH_DATA ( aux_ch , index ) ;
2015-11-11 20:34:14 +02:00
default :
2018-02-22 20:10:30 +02:00
MISSING_CASE ( aux_ch ) ;
return DP_AUX_CH_DATA ( AUX_CH_A , index ) ;
2015-11-11 20:34:14 +02:00
}
}
2018-02-22 20:10:31 +02:00
static i915_reg_t skl_aux_ctl_reg ( struct intel_dp * intel_dp )
2018-02-22 20:10:30 +02:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
enum aux_ch aux_ch = dig_port - > aux_ch ;
2018-02-22 20:10:31 +02:00
2018-02-22 20:10:30 +02:00
switch ( aux_ch ) {
case AUX_CH_A :
case AUX_CH_B :
case AUX_CH_C :
case AUX_CH_D :
2018-06-11 17:25:12 -07:00
case AUX_CH_E :
2018-02-22 20:10:30 +02:00
case AUX_CH_F :
return DP_AUX_CH_CTL ( aux_ch ) ;
2015-11-11 20:34:13 +02:00
default :
2018-02-22 20:10:30 +02:00
MISSING_CASE ( aux_ch ) ;
return DP_AUX_CH_CTL ( AUX_CH_A ) ;
2015-11-11 20:34:13 +02:00
}
}
2018-02-22 20:10:31 +02:00
static i915_reg_t skl_aux_data_reg ( struct intel_dp * intel_dp , int index )
2018-02-22 20:10:30 +02:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
enum aux_ch aux_ch = dig_port - > aux_ch ;
2018-02-22 20:10:31 +02:00
2018-02-22 20:10:30 +02:00
switch ( aux_ch ) {
case AUX_CH_A :
case AUX_CH_B :
case AUX_CH_C :
case AUX_CH_D :
2018-06-11 17:25:12 -07:00
case AUX_CH_E :
2018-02-22 20:10:30 +02:00
case AUX_CH_F :
2020-10-28 23:33:08 +02:00
return DP_AUX_CH_DATA ( aux_ch , index ) ;
default :
MISSING_CASE ( aux_ch ) ;
return DP_AUX_CH_DATA ( AUX_CH_A , index ) ;
}
}
static i915_reg_t tgl_aux_ctl_reg ( struct intel_dp * intel_dp )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
enum aux_ch aux_ch = dig_port - > aux_ch ;
switch ( aux_ch ) {
case AUX_CH_A :
case AUX_CH_B :
case AUX_CH_C :
case AUX_CH_USBC1 :
case AUX_CH_USBC2 :
case AUX_CH_USBC3 :
case AUX_CH_USBC4 :
case AUX_CH_USBC5 :
case AUX_CH_USBC6 :
return DP_AUX_CH_CTL ( aux_ch ) ;
default :
MISSING_CASE ( aux_ch ) ;
return DP_AUX_CH_CTL ( AUX_CH_A ) ;
}
}
static i915_reg_t tgl_aux_data_reg ( struct intel_dp * intel_dp , int index )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
enum aux_ch aux_ch = dig_port - > aux_ch ;
switch ( aux_ch ) {
case AUX_CH_A :
case AUX_CH_B :
case AUX_CH_C :
case AUX_CH_USBC1 :
case AUX_CH_USBC2 :
case AUX_CH_USBC3 :
case AUX_CH_USBC4 :
case AUX_CH_USBC5 :
case AUX_CH_USBC6 :
2018-02-22 20:10:30 +02:00
return DP_AUX_CH_DATA ( aux_ch , index ) ;
2015-11-11 20:34:14 +02:00
default :
2018-02-22 20:10:30 +02:00
MISSING_CASE ( aux_ch ) ;
return DP_AUX_CH_DATA ( AUX_CH_A , index ) ;
2015-11-11 20:34:14 +02:00
}
}
2018-02-22 20:10:32 +02:00
static void
intel_dp_aux_fini ( struct intel_dp * intel_dp )
{
2020-12-30 20:23:09 +00:00
if ( cpu_latency_qos_request_active ( & intel_dp - > pm_qos ) )
cpu_latency_qos_remove_request ( & intel_dp - > pm_qos ) ;
2018-02-22 20:10:32 +02:00
kfree ( intel_dp - > aux . name ) ;
}
static void
intel_dp_aux_init ( struct intel_dp * intel_dp )
2015-11-11 20:34:14 +02:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-11-01 16:04:21 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct intel_encoder * encoder = & dig_port - > base ;
2020-10-28 23:33:09 +02:00
enum aux_ch aux_ch = dig_port - > aux_ch ;
2018-02-22 20:10:32 +02:00
2020-10-28 23:33:08 +02:00
if ( INTEL_GEN ( dev_priv ) > = 12 ) {
intel_dp - > aux_ch_ctl_reg = tgl_aux_ctl_reg ;
intel_dp - > aux_ch_data_reg = tgl_aux_data_reg ;
} else if ( INTEL_GEN ( dev_priv ) > = 9 ) {
2018-02-22 20:10:31 +02:00
intel_dp - > aux_ch_ctl_reg = skl_aux_ctl_reg ;
intel_dp - > aux_ch_data_reg = skl_aux_data_reg ;
} else if ( HAS_PCH_SPLIT ( dev_priv ) ) {
intel_dp - > aux_ch_ctl_reg = ilk_aux_ctl_reg ;
intel_dp - > aux_ch_data_reg = ilk_aux_data_reg ;
} else {
intel_dp - > aux_ch_ctl_reg = g4x_aux_ctl_reg ;
intel_dp - > aux_ch_data_reg = g4x_aux_data_reg ;
}
2015-11-11 20:34:14 +02:00
2018-02-22 20:10:32 +02:00
if ( INTEL_GEN ( dev_priv ) > = 9 )
intel_dp - > get_aux_clock_divider = skl_get_aux_clock_divider ;
else if ( IS_BROADWELL ( dev_priv ) | | IS_HASWELL ( dev_priv ) )
intel_dp - > get_aux_clock_divider = hsw_get_aux_clock_divider ;
else if ( HAS_PCH_SPLIT ( dev_priv ) )
intel_dp - > get_aux_clock_divider = ilk_get_aux_clock_divider ;
else
intel_dp - > get_aux_clock_divider = g4x_get_aux_clock_divider ;
2018-02-22 20:10:30 +02:00
2018-02-22 20:10:32 +02:00
if ( INTEL_GEN ( dev_priv ) > = 9 )
intel_dp - > get_aux_send_ctl = skl_get_aux_send_ctl ;
else
intel_dp - > get_aux_send_ctl = g4x_get_aux_send_ctl ;
2009-12-04 10:55:24 +10:00
2016-06-24 14:00:14 +01:00
drm_dp_aux_init ( & intel_dp - > aux ) ;
2010-12-08 16:10:21 +00:00
2016-06-24 14:00:14 +01:00
/* Failure to allocate our preferred name is not critical */
2020-10-28 23:33:09 +02:00
if ( INTEL_GEN ( dev_priv ) > = 12 & & aux_ch > = AUX_CH_USBC1 )
intel_dp - > aux . name = kasprintf ( GFP_KERNEL , " AUX USBC%c/%s " ,
aux_ch - AUX_CH_USBC1 + ' 1 ' ,
encoder - > base . name ) ;
else
intel_dp - > aux . name = kasprintf ( GFP_KERNEL , " AUX %c/%s " ,
aux_ch_name ( aux_ch ) ,
encoder - > base . name ) ;
2014-03-14 16:51:15 +02:00
intel_dp - > aux . transfer = intel_dp_aux_transfer ;
2020-12-30 20:23:09 +00:00
cpu_latency_qos_add_request ( & intel_dp - > pm_qos , PM_QOS_DEFAULT_VALUE ) ;
2009-04-07 16:16:42 -07:00
}
2015-10-23 13:01:50 +03:00
bool intel_dp_source_supports_hbr2 ( struct intel_dp * intel_dp )
2015-08-18 15:30:37 +05:30
{
2017-10-09 12:29:58 +03:00
int max_rate = intel_dp - > source_rates [ intel_dp - > num_source_rates - 1 ] ;
2015-10-23 13:01:50 +03:00
2017-10-09 12:29:58 +03:00
return max_rate > = 540000 ;
2015-08-18 15:30:37 +05:30
}
2018-06-11 15:26:55 -07:00
bool intel_dp_source_supports_hbr3 ( struct intel_dp * intel_dp )
{
int max_rate = intel_dp - > source_rates [ intel_dp - > num_source_rates - 1 ] ;
return max_rate > = 810000 ;
}
2013-04-19 11:14:33 +02:00
static void
intel_dp_set_clock ( struct intel_encoder * encoder ,
2015-08-11 20:21:46 +03:00
struct intel_crtc_state * pipe_config )
2013-04-19 11:14:33 +02:00
{
2017-11-09 17:27:58 +02:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2013-09-04 01:30:37 +08:00
const struct dp_link_dpll * divisor = NULL ;
int i , count = 0 ;
2013-04-19 11:14:33 +02:00
2016-10-13 11:03:06 +01:00
if ( IS_G4X ( dev_priv ) ) {
2018-05-17 20:03:09 +03:00
divisor = g4x_dpll ;
count = ARRAY_SIZE ( g4x_dpll ) ;
2016-10-13 11:02:53 +01:00
} else if ( HAS_PCH_SPLIT ( dev_priv ) ) {
2013-09-04 01:30:37 +08:00
divisor = pch_dpll ;
count = ARRAY_SIZE ( pch_dpll ) ;
2016-10-14 10:13:44 +01:00
} else if ( IS_CHERRYVIEW ( dev_priv ) ) {
2014-04-09 13:28:18 +03:00
divisor = chv_dpll ;
count = ARRAY_SIZE ( chv_dpll ) ;
2016-10-13 11:03:08 +01:00
} else if ( IS_VALLEYVIEW ( dev_priv ) ) {
2013-09-04 01:30:38 +08:00
divisor = vlv_dpll ;
count = ARRAY_SIZE ( vlv_dpll ) ;
2013-04-19 11:14:33 +02:00
}
2013-09-04 01:30:37 +08:00
if ( divisor & & count ) {
for ( i = 0 ; i < count ; i + + ) {
2015-08-11 20:21:46 +03:00
if ( pipe_config - > port_clock = = divisor [ i ] . clock ) {
2013-09-04 01:30:37 +08:00
pipe_config - > dpll = divisor [ i ] . dpll ;
pipe_config - > clock_set = true ;
break ;
}
}
2013-04-19 11:14:33 +02:00
}
}
2015-03-12 17:10:39 +02:00
static void snprintf_int_array ( char * str , size_t len ,
const int * array , int nelem )
{
int i ;
str [ 0 ] = ' \0 ' ;
for ( i = 0 ; i < nelem ; i + + ) {
drm/i915/dp: make link rate printing prettier
Turn
[drm:intel_dp_print_rates] source rates: 162000,270000,540000,
[drm:intel_dp_print_rates] sink rates: 162000,270000,
[drm:intel_dp_print_rates] common rates: 162000,270000,
into
[drm:intel_dp_print_rates] source rates: 162000, 270000, 540000
[drm:intel_dp_print_rates] sink rates: 162000, 270000
[drm:intel_dp_print_rates] common rates: 162000, 270000
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-05-18 16:01:45 +03:00
int r = snprintf ( str , len , " %s%d " , i ? " , " : " " , array [ i ] ) ;
2015-03-12 17:10:39 +02:00
if ( r > = len )
return ;
str + = r ;
len - = r ;
}
}
static void intel_dp_print_rates ( struct intel_dp * intel_dp )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2015-03-12 17:10:39 +02:00
char str [ 128 ] ; /* FIXME: too big for stack? */
2019-10-28 12:38:15 +02:00
if ( ! drm_debug_enabled ( DRM_UT_KMS ) )
2015-03-12 17:10:39 +02:00
return ;
2017-03-28 17:59:04 +03:00
snprintf_int_array ( str , sizeof ( str ) ,
intel_dp - > source_rates , intel_dp - > num_source_rates ) ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " source rates: %s \n " , str ) ;
2015-03-12 17:10:39 +02:00
2017-03-28 17:59:05 +03:00
snprintf_int_array ( str , sizeof ( str ) ,
intel_dp - > sink_rates , intel_dp - > num_sink_rates ) ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " sink rates: %s \n " , str ) ;
2015-03-12 17:10:39 +02:00
2017-04-06 16:44:10 +03:00
snprintf_int_array ( str , sizeof ( str ) ,
intel_dp - > common_rates , intel_dp - > num_common_rates ) ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " common rates: %s \n " , str ) ;
2015-03-12 17:10:39 +02:00
}
2015-03-12 17:10:34 +02:00
int
intel_dp_max_link_rate ( struct intel_dp * intel_dp )
{
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2015-03-12 17:10:34 +02:00
int len ;
2017-04-06 16:44:12 +03:00
len = intel_dp_common_len_rate_limit ( intel_dp , intel_dp - > max_link_rate ) ;
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
if ( drm_WARN_ON ( & i915 - > drm , len < = 0 ) )
2015-03-12 17:10:34 +02:00
return 162000 ;
2017-04-06 16:44:10 +03:00
return intel_dp - > common_rates [ len - 1 ] ;
2015-03-12 17:10:34 +02:00
}
2015-03-12 17:10:36 +02:00
int intel_dp_rate_select ( struct intel_dp * intel_dp , int rate )
{
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2017-03-28 17:59:03 +03:00
int i = intel_dp_rate_index ( intel_dp - > sink_rates ,
intel_dp - > num_sink_rates , rate ) ;
2017-03-28 17:59:02 +03:00
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
if ( drm_WARN_ON ( & i915 - > drm , i < 0 ) )
2017-03-28 17:59:02 +03:00
i = 0 ;
return i ;
2015-03-12 17:10:36 +02:00
}
2015-10-23 13:01:48 +03:00
void intel_dp_compute_rate ( struct intel_dp * intel_dp , int port_clock ,
2019-01-16 11:15:27 +02:00
u8 * link_bw , u8 * rate_select )
2015-07-06 15:10:06 +03:00
{
2017-03-28 17:59:05 +03:00
/* eDP 1.4 rate select method. */
if ( intel_dp - > use_rate_select ) {
2015-07-06 15:10:06 +03:00
* link_bw = 0 ;
* rate_select =
intel_dp_rate_select ( intel_dp , port_clock ) ;
} else {
* link_bw = drm_dp_link_rate_to_bw_code ( port_clock ) ;
* rate_select = 0 ;
}
}
2018-11-28 12:26:25 -08:00
static bool intel_dp_source_supports_fec ( struct intel_dp * intel_dp ,
2018-11-28 13:36:21 -08:00
const struct intel_crtc_state * pipe_config )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2019-08-22 17:46:55 -07:00
/* On TGL, FEC is supported on all Pipes */
if ( INTEL_GEN ( dev_priv ) > = 12 )
return true ;
if ( IS_GEN ( dev_priv , 11 ) & & pipe_config - > cpu_transcoder ! = TRANSCODER_A )
return true ;
return false ;
2018-11-28 12:26:25 -08:00
}
static bool intel_dp_supports_fec ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * pipe_config )
{
return intel_dp_source_supports_fec ( intel_dp , pipe_config ) & &
drm_dp_sink_supports_fec ( intel_dp - > fec_capable ) ;
}
2018-11-28 13:36:21 -08:00
static bool intel_dp_supports_dsc ( struct intel_dp * intel_dp ,
2019-12-10 12:50:51 +02:00
const struct intel_crtc_state * crtc_state )
2018-11-28 13:36:21 -08:00
{
2020-11-17 11:47:07 -08:00
if ( intel_crtc_has_type ( crtc_state , INTEL_OUTPUT_DP ) & & ! crtc_state - > fec_enable )
2018-11-28 12:26:25 -08:00
return false ;
2020-11-17 11:47:07 -08:00
return intel_dsc_source_support ( crtc_state ) & &
2018-11-28 13:36:21 -08:00
drm_dp_sink_supports_dsc ( intel_dp - > dsc_dpcd ) ;
}
2020-09-04 14:53:52 +03:00
static bool intel_dp_hdmi_ycbcr420 ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
{
2020-09-04 14:53:54 +03:00
return crtc_state - > output_format = = INTEL_OUTPUT_FORMAT_YCBCR420 | |
( crtc_state - > output_format = = INTEL_OUTPUT_FORMAT_YCBCR444 & &
intel_dp - > dfp . ycbcr_444_to_420 ) ;
2020-09-04 14:53:52 +03:00
}
static int intel_dp_hdmi_tmds_clock ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state , int bpc )
{
int clock = crtc_state - > hw . adjusted_mode . crtc_clock * bpc / 8 ;
if ( intel_dp_hdmi_ycbcr420 ( intel_dp , crtc_state ) )
clock / = 2 ;
return clock ;
}
static bool intel_dp_hdmi_tmds_clock_valid ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state , int bpc )
{
int tmds_clock = intel_dp_hdmi_tmds_clock ( intel_dp , crtc_state , bpc ) ;
if ( intel_dp - > dfp . min_tmds_clock & &
tmds_clock < intel_dp - > dfp . min_tmds_clock )
return false ;
if ( intel_dp - > dfp . max_tmds_clock & &
tmds_clock > intel_dp - > dfp . max_tmds_clock )
return false ;
return true ;
}
static bool intel_dp_hdmi_deep_color_possible ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state ,
int bpc )
{
2020-09-04 14:53:54 +03:00
return intel_hdmi_deep_color_possible ( crtc_state , bpc ,
intel_dp - > has_hdmi_sink ,
intel_dp_hdmi_ycbcr420 ( intel_dp , crtc_state ) ) & &
2020-09-04 14:53:52 +03:00
intel_dp_hdmi_tmds_clock_valid ( intel_dp , crtc_state , bpc ) ;
}
static int intel_dp_max_bpp ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2016-09-09 14:10:56 +03:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-04-26 11:25:27 +03:00
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
2020-09-04 14:53:52 +03:00
int bpp , bpc ;
2016-09-09 14:10:56 +03:00
2020-09-04 14:53:52 +03:00
bpc = crtc_state - > pipe_bpp / 3 ;
2016-09-09 14:10:56 +03:00
2020-09-04 14:53:41 +03:00
if ( intel_dp - > dfp . max_bpc )
2020-09-04 14:53:52 +03:00
bpc = min_t ( int , bpc , intel_dp - > dfp . max_bpc ) ;
if ( intel_dp - > dfp . min_tmds_clock ) {
for ( ; bpc > = 10 ; bpc - = 2 ) {
if ( intel_dp_hdmi_deep_color_possible ( intel_dp , crtc_state , bpc ) )
break ;
}
}
2016-09-09 14:10:56 +03:00
2020-09-04 14:53:52 +03:00
bpp = bpc * 3 ;
2018-04-26 11:25:27 +03:00
if ( intel_dp_is_edp ( intel_dp ) ) {
/* Get bpp from vbt only for panels that dont have bpp in edid */
if ( intel_connector - > base . display_info . bpc = = 0 & &
dev_priv - > vbt . edp . bpp & & dev_priv - > vbt . edp . bpp < bpp ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" clamping bpp for eDP panel to BIOS-provided %i \n " ,
dev_priv - > vbt . edp . bpp ) ;
2018-04-26 11:25:27 +03:00
bpp = dev_priv - > vbt . edp . bpp ;
}
}
2016-09-09 14:10:56 +03:00
return bpp ;
}
2018-04-26 11:25:30 +03:00
/* Adjust link config limits based on compliance test requests. */
2019-03-26 16:25:53 +02:00
void
2018-04-26 11:25:30 +03:00
intel_dp_adjust_compliance_config ( struct intel_dp * intel_dp ,
struct intel_crtc_state * pipe_config ,
struct link_config_limits * limits )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2018-04-26 11:25:30 +03:00
/* For DP Compliance we override the computed bpp for the pipe */
if ( intel_dp - > compliance . test_data . bpc ! = 0 ) {
int bpp = 3 * intel_dp - > compliance . test_data . bpc ;
limits - > min_bpp = limits - > max_bpp = bpp ;
pipe_config - > dither_force_disable = bpp = = 6 * 3 ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Setting pipe_bpp to %d \n " , bpp ) ;
2018-04-26 11:25:30 +03:00
}
/* Use values requested by Compliance Test Request */
if ( intel_dp - > compliance . test_type = = DP_TEST_LINK_TRAINING ) {
int index ;
/* Validate the compliance test data since max values
* might have changed due to link train fallback .
*/
if ( intel_dp_link_params_valid ( intel_dp , intel_dp - > compliance . test_link_rate ,
intel_dp - > compliance . test_lane_count ) ) {
index = intel_dp_rate_index ( intel_dp - > common_rates ,
intel_dp - > num_common_rates ,
intel_dp - > compliance . test_link_rate ) ;
if ( index > = 0 )
limits - > min_clock = limits - > max_clock = index ;
limits - > min_lane_count = limits - > max_lane_count =
intel_dp - > compliance . test_lane_count ;
}
}
}
2018-04-26 11:25:29 +03:00
/* Optimize link config in order: max bpp, min clock, min lanes */
2019-01-15 15:08:00 -05:00
static int
2018-04-26 11:25:29 +03:00
intel_dp_compute_link_config_wide ( struct intel_dp * intel_dp ,
struct intel_crtc_state * pipe_config ,
const struct link_config_limits * limits )
{
2019-10-31 12:26:02 +01:00
struct drm_display_mode * adjusted_mode = & pipe_config - > hw . adjusted_mode ;
2018-04-26 11:25:29 +03:00
int bpp , clock , lane_count ;
int mode_rate , link_clock , link_avail ;
for ( bpp = limits - > max_bpp ; bpp > = limits - > min_bpp ; bpp - = 2 * 3 ) {
2020-09-18 00:43:34 +03:00
int output_bpp = intel_dp_output_bpp ( pipe_config - > output_format , bpp ) ;
2019-07-10 15:58:51 +03:00
2018-04-26 11:25:29 +03:00
mode_rate = intel_dp_link_required ( adjusted_mode - > crtc_clock ,
2019-07-10 15:58:51 +03:00
output_bpp ) ;
2018-04-26 11:25:29 +03:00
for ( clock = limits - > min_clock ; clock < = limits - > max_clock ; clock + + ) {
for ( lane_count = limits - > min_lane_count ;
lane_count < = limits - > max_lane_count ;
lane_count < < = 1 ) {
link_clock = intel_dp - > common_rates [ clock ] ;
link_avail = intel_dp_max_data_rate ( link_clock ,
lane_count ) ;
if ( mode_rate < = link_avail ) {
pipe_config - > lane_count = lane_count ;
pipe_config - > pipe_bpp = bpp ;
pipe_config - > port_clock = link_clock ;
2019-01-15 15:08:00 -05:00
return 0 ;
2018-04-26 11:25:29 +03:00
}
}
}
}
2019-01-15 15:08:00 -05:00
return - EINVAL ;
2018-04-26 11:25:29 +03:00
}
2021-01-07 20:20:25 +02:00
/* Optimize link config in order: max bpp, min lanes, min clock */
static int
intel_dp_compute_link_config_fast ( struct intel_dp * intel_dp ,
struct intel_crtc_state * pipe_config ,
const struct link_config_limits * limits )
{
const struct drm_display_mode * adjusted_mode = & pipe_config - > hw . adjusted_mode ;
int bpp , clock , lane_count ;
int mode_rate , link_clock , link_avail ;
for ( bpp = limits - > max_bpp ; bpp > = limits - > min_bpp ; bpp - = 2 * 3 ) {
int output_bpp = intel_dp_output_bpp ( pipe_config - > output_format , bpp ) ;
mode_rate = intel_dp_link_required ( adjusted_mode - > crtc_clock ,
output_bpp ) ;
for ( lane_count = limits - > min_lane_count ;
lane_count < = limits - > max_lane_count ;
lane_count < < = 1 ) {
for ( clock = limits - > min_clock ; clock < = limits - > max_clock ; clock + + ) {
link_clock = intel_dp - > common_rates [ clock ] ;
link_avail = intel_dp_max_data_rate ( link_clock ,
lane_count ) ;
if ( mode_rate < = link_avail ) {
pipe_config - > lane_count = lane_count ;
pipe_config - > pipe_bpp = bpp ;
pipe_config - > port_clock = link_clock ;
return 0 ;
}
}
}
}
return - EINVAL ;
}
2018-11-28 13:36:21 -08:00
static int intel_dp_dsc_compute_bpp ( struct intel_dp * intel_dp , u8 dsc_max_bpc )
{
int i , num_bpc ;
u8 dsc_bpc [ 3 ] = { 0 } ;
num_bpc = drm_dp_dsc_sink_supported_input_bpcs ( intel_dp - > dsc_dpcd ,
dsc_bpc ) ;
for ( i = 0 ; i < num_bpc ; i + + ) {
if ( dsc_max_bpc > = dsc_bpc [ i ] )
return dsc_bpc [ i ] * 3 ;
}
return 0 ;
}
2019-12-10 12:50:48 +02:00
# define DSC_SUPPORTED_VERSION_MIN 1
static int intel_dp_dsc_compute_params ( struct intel_encoder * encoder ,
struct intel_crtc_state * crtc_state )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = to_i915 ( encoder - > base . dev ) ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2019-12-10 12:50:48 +02:00
struct drm_dsc_config * vdsc_cfg = & crtc_state - > dsc . config ;
u8 line_buf_depth ;
int ret ;
2020-12-08 14:33:52 +02:00
/*
* RC_MODEL_SIZE is currently a constant across all configurations .
*
* FIXME : Look into using sink defined DPCD DP_DSC_RC_BUF_BLK_SIZE and
* DP_DSC_RC_BUF_SIZE for this .
*/
vdsc_cfg - > rc_model_size = DSC_RC_MODEL_SIZE_CONST ;
2019-12-10 12:50:48 +02:00
ret = intel_dsc_compute_params ( encoder , crtc_state ) ;
if ( ret )
return ret ;
2019-12-10 12:50:49 +02:00
/*
* Slice Height of 8 works for all currently available panels . So start
* with that if pic_height is an integral multiple of 8. Eventually add
* logic to try multiple slice heights .
*/
if ( vdsc_cfg - > pic_height % 8 = = 0 )
vdsc_cfg - > slice_height = 8 ;
else if ( vdsc_cfg - > pic_height % 4 = = 0 )
vdsc_cfg - > slice_height = 4 ;
else
vdsc_cfg - > slice_height = 2 ;
2019-12-10 12:50:48 +02:00
vdsc_cfg - > dsc_version_major =
( intel_dp - > dsc_dpcd [ DP_DSC_REV - DP_DSC_SUPPORT ] &
DP_DSC_MAJOR_MASK ) > > DP_DSC_MAJOR_SHIFT ;
vdsc_cfg - > dsc_version_minor =
min ( DSC_SUPPORTED_VERSION_MIN ,
( intel_dp - > dsc_dpcd [ DP_DSC_REV - DP_DSC_SUPPORT ] &
DP_DSC_MINOR_MASK ) > > DP_DSC_MINOR_SHIFT ) ;
vdsc_cfg - > convert_rgb = intel_dp - > dsc_dpcd [ DP_DSC_DEC_COLOR_FORMAT_CAP - DP_DSC_SUPPORT ] &
DP_DSC_RGB ;
line_buf_depth = drm_dp_dsc_sink_line_buf_depth ( intel_dp - > dsc_dpcd ) ;
if ( ! line_buf_depth ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" DSC Sink Line Buffer Depth invalid \n " ) ;
2019-12-10 12:50:48 +02:00
return - EINVAL ;
}
if ( vdsc_cfg - > dsc_version_minor = = 2 )
vdsc_cfg - > line_buf_depth = ( line_buf_depth = = DSC_1_2_MAX_LINEBUF_DEPTH_BITS ) ?
DSC_1_2_MAX_LINEBUF_DEPTH_VAL : line_buf_depth ;
else
vdsc_cfg - > line_buf_depth = ( line_buf_depth > DSC_1_1_MAX_LINEBUF_DEPTH_BITS ) ?
DSC_1_1_MAX_LINEBUF_DEPTH_BITS : line_buf_depth ;
vdsc_cfg - > block_pred_enable =
intel_dp - > dsc_dpcd [ DP_DSC_BLK_PREDICTION_SUPPORT - DP_DSC_SUPPORT ] &
DP_DSC_BLK_PREDICTION_IS_SUPPORTED ;
return drm_dsc_compute_rc_parameters ( vdsc_cfg ) ;
}
2019-01-15 15:08:00 -05:00
static int intel_dp_dsc_compute_config ( struct intel_dp * intel_dp ,
struct intel_crtc_state * pipe_config ,
struct drm_connector_state * conn_state ,
struct link_config_limits * limits )
2018-11-28 13:36:21 -08:00
{
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct drm_i915_private * dev_priv = to_i915 ( dig_port - > base . base . dev ) ;
2020-03-19 18:38:44 +02:00
const struct drm_display_mode * adjusted_mode =
& pipe_config - > hw . adjusted_mode ;
2018-11-28 13:36:21 -08:00
u8 dsc_max_bpc ;
int pipe_bpp ;
2019-01-15 15:08:00 -05:00
int ret ;
2018-11-28 13:36:21 -08:00
2019-03-26 16:49:02 +02:00
pipe_config - > fec_enable = ! intel_dp_is_edp ( intel_dp ) & &
intel_dp_supports_fec ( intel_dp , pipe_config ) ;
2018-11-28 13:36:21 -08:00
if ( ! intel_dp_supports_dsc ( intel_dp , pipe_config ) )
2019-01-15 15:08:00 -05:00
return - EINVAL ;
2018-11-28 13:36:21 -08:00
2019-08-20 15:30:59 -07:00
/* Max DSC Input BPC for ICL is 10 and for TGL+ is 12 */
if ( INTEL_GEN ( dev_priv ) > = 12 )
dsc_max_bpc = min_t ( u8 , 12 , conn_state - > max_requested_bpc ) ;
else
dsc_max_bpc = min_t ( u8 , 10 ,
conn_state - > max_requested_bpc ) ;
2018-11-28 13:36:21 -08:00
pipe_bpp = intel_dp_dsc_compute_bpp ( intel_dp , dsc_max_bpc ) ;
2019-08-20 15:30:59 -07:00
/* Min Input BPC for ICL+ is 8 */
if ( pipe_bpp < 8 * 3 ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" No DSC support for less than 8bpc \n " ) ;
2019-01-15 15:08:00 -05:00
return - EINVAL ;
2018-11-28 13:36:21 -08:00
}
/*
* For now enable DSC for max bpp , max link rate , max lane count .
* Optimize this later for the minimum possible link rate / lane count
* with DSC enabled for the requested mode .
*/
pipe_config - > pipe_bpp = pipe_bpp ;
pipe_config - > port_clock = intel_dp - > common_rates [ limits - > max_clock ] ;
pipe_config - > lane_count = limits - > max_lane_count ;
if ( intel_dp_is_edp ( intel_dp ) ) {
2019-10-22 16:34:13 +03:00
pipe_config - > dsc . compressed_bpp =
2018-11-28 13:36:21 -08:00
min_t ( u16 , drm_edp_dsc_sink_output_bpp ( intel_dp - > dsc_dpcd ) > > 4 ,
pipe_config - > pipe_bpp ) ;
2019-10-22 16:34:13 +03:00
pipe_config - > dsc . slice_count =
2018-11-28 13:36:21 -08:00
drm_dp_dsc_sink_max_slice_count ( intel_dp - > dsc_dpcd ,
true ) ;
} else {
u16 dsc_max_output_bpp ;
u8 dsc_dp_slice_count ;
dsc_max_output_bpp =
2019-09-25 16:45:42 -07:00
intel_dp_dsc_get_output_bpp ( dev_priv ,
pipe_config - > port_clock ,
2018-11-28 13:36:21 -08:00
pipe_config - > lane_count ,
adjusted_mode - > crtc_clock ,
2020-11-17 11:47:05 -08:00
adjusted_mode - > crtc_hdisplay ,
2020-11-17 11:47:06 -08:00
pipe_config - > bigjoiner ) ;
2018-11-28 13:36:21 -08:00
dsc_dp_slice_count =
intel_dp_dsc_get_slice_count ( intel_dp ,
adjusted_mode - > crtc_clock ,
2020-11-17 11:47:05 -08:00
adjusted_mode - > crtc_hdisplay ,
2020-11-17 11:47:06 -08:00
pipe_config - > bigjoiner ) ;
2018-11-28 13:36:21 -08:00
if ( ! dsc_max_output_bpp | | ! dsc_dp_slice_count ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" Compressed BPP/Slice Count not supported \n " ) ;
2019-01-15 15:08:00 -05:00
return - EINVAL ;
2018-11-28 13:36:21 -08:00
}
2019-10-22 16:34:13 +03:00
pipe_config - > dsc . compressed_bpp = min_t ( u16 ,
2018-11-28 13:36:21 -08:00
dsc_max_output_bpp > > 4 ,
pipe_config - > pipe_bpp ) ;
2019-10-22 16:34:13 +03:00
pipe_config - > dsc . slice_count = dsc_dp_slice_count ;
2018-11-28 13:36:21 -08:00
}
/*
* VDSC engine operates at 1 Pixel per clock , so if peak pixel rate
* is greater than the maximum Cdclock and if slice count is even
* then we need to use 2 VDSC instances .
*/
2020-11-17 11:47:06 -08:00
if ( adjusted_mode - > crtc_clock > dev_priv - > max_cdclk_freq | |
pipe_config - > bigjoiner ) {
if ( pipe_config - > dsc . slice_count < 2 ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" Cannot split stream to use 2 VDSC instances \n " ) ;
2019-01-15 15:08:00 -05:00
return - EINVAL ;
2018-11-28 13:36:21 -08:00
}
2020-11-17 11:47:06 -08:00
pipe_config - > dsc . dsc_split = true ;
2018-11-28 13:36:21 -08:00
}
2019-01-15 15:08:00 -05:00
2019-12-10 12:50:48 +02:00
ret = intel_dp_dsc_compute_params ( & dig_port - > base , pipe_config ) ;
2019-01-15 15:08:00 -05:00
if ( ret < 0 ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" Cannot compute valid DSC parameters for Input Bpp = %d "
" Compressed BPP = %d \n " ,
pipe_config - > pipe_bpp ,
pipe_config - > dsc . compressed_bpp ) ;
2019-01-15 15:08:00 -05:00
return ret ;
2018-11-29 11:38:27 -08:00
}
2019-01-15 15:08:00 -05:00
2019-10-22 16:34:13 +03:00
pipe_config - > dsc . compression_enable = true ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " DP DSC computed with Input Bpp = %d "
" Compressed Bpp = %d Slice Count = %d \n " ,
pipe_config - > pipe_bpp ,
pipe_config - > dsc . compressed_bpp ,
pipe_config - > dsc . slice_count ) ;
2018-11-28 13:36:21 -08:00
2019-01-15 15:08:00 -05:00
return 0 ;
2018-11-28 13:36:21 -08:00
}
2019-01-15 15:08:00 -05:00
static int
2018-04-26 11:25:26 +03:00
intel_dp_compute_link_config ( struct intel_encoder * encoder ,
2018-11-28 13:36:21 -08:00
struct intel_crtc_state * pipe_config ,
struct drm_connector_state * conn_state )
2009-04-07 16:16:42 -07:00
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = to_i915 ( encoder - > base . dev ) ;
2020-03-19 18:38:44 +02:00
const struct drm_display_mode * adjusted_mode =
& pipe_config - > hw . adjusted_mode ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2018-04-26 11:25:28 +03:00
struct link_config_limits limits ;
2015-03-13 19:40:31 +02:00
int common_len ;
2019-01-15 15:08:00 -05:00
int ret ;
2018-04-26 11:25:28 +03:00
2017-04-06 16:44:10 +03:00
common_len = intel_dp_common_len_rate_limit ( intel_dp ,
2017-04-06 16:44:12 +03:00
intel_dp - > max_link_rate ) ;
2015-03-05 10:02:30 +05:30
/* No common link rates between source and sink */
drm/i915/display: Make WARN* drm specific where encoder ptr is available
Drm specific drm_WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where intel_encoder struct pointer is available.
The conversion was done automatically with below coccinelle semantic
patch.
@@
identifier func, T;
@@
func(...) {
...
struct intel_encoder *T = ...;
<...
(
-WARN(
+drm_WARN(T->base.dev,
...)
|
-WARN_ON(
+drm_WARN_ON(T->base.dev,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T->base.dev,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T->base.dev,
...)
)
...>
}
@@
identifier func, T;
@@
func(struct intel_encoder *T,...) {
<...
(
-WARN(
+drm_WARN(T->base.dev,
...)
|
-WARN_ON(
+drm_WARN_ON(T->base.dev,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T->base.dev,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T->base.dev,
...)
)
...>
}
command: spatch --sp-file <script> --dir drivers/gpu/drm/i915/display \
--linux-spacing --in-place
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200115034455.17658-5-pankaj.laxminarayan.bharadiya@intel.com
2020-01-15 09:14:48 +05:30
drm_WARN_ON ( encoder - > base . dev , common_len < = 0 ) ;
2015-03-05 10:02:30 +05:30
2018-04-26 11:25:28 +03:00
limits . min_clock = 0 ;
limits . max_clock = common_len - 1 ;
limits . min_lane_count = 1 ;
limits . max_lane_count = intel_dp_max_lane_count ( intel_dp ) ;
2020-09-18 00:43:34 +03:00
limits . min_bpp = intel_dp_min_bpp ( pipe_config - > output_format ) ;
2020-09-04 14:53:52 +03:00
limits . max_bpp = intel_dp_max_bpp ( intel_dp , pipe_config ) ;
2009-04-07 16:16:42 -07:00
2021-01-07 20:20:25 +02:00
if ( intel_dp - > use_max_params ) {
2014-09-09 11:25:13 +03:00
/*
* Use the maximum clock and number of lanes the eDP panel
2021-01-07 20:20:25 +02:00
* advertizes being capable of in case the initial fast
* optimal params failed us . The panels are generally
2019-04-05 10:52:20 +03:00
* designed to support only a single clock and lane
2021-01-07 20:20:25 +02:00
* configuration , and typically on older panels these
* values correspond to the native resolution of the panel .
2014-09-09 11:25:13 +03:00
*/
2018-04-26 11:25:28 +03:00
limits . min_lane_count = limits . max_lane_count ;
limits . min_clock = limits . max_clock ;
2013-07-18 17:44:13 +03:00
}
2013-05-04 10:09:18 +02:00
2018-04-26 11:25:30 +03:00
intel_dp_adjust_compliance_config ( intel_dp , pipe_config , & limits ) ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " DP link computation with max lane count %i "
" max rate %d max bpp %d pixel clock %iKHz \n " ,
limits . max_lane_count ,
intel_dp - > common_rates [ limits . max_clock ] ,
limits . max_bpp , adjusted_mode - > crtc_clock ) ;
2018-04-26 11:25:28 +03:00
2020-11-17 11:47:06 -08:00
if ( ( adjusted_mode - > crtc_clock > i915 - > max_dotclk_freq | |
adjusted_mode - > crtc_hdisplay > 5120 ) & &
intel_dp_can_bigjoiner ( intel_dp ) )
pipe_config - > bigjoiner = true ;
2021-01-07 20:20:25 +02:00
if ( intel_dp_is_edp ( intel_dp ) )
/*
* Optimize for fast and narrow . eDP 1.3 section 3.3 and eDP 1.4
* section A .1 : " It is recommended that the minimum number of
* lanes be used , using the minimum link rate allowed for that
* lane configuration . "
*
* Note that we fall back to the max clock and lane count for eDP
* panels that fail with the fast optimal settings ( see
* intel_dp - > use_max_params ) , in which case the fast vs . wide
* choice doesn ' t matter .
*/
ret = intel_dp_compute_link_config_fast ( intel_dp , pipe_config , & limits ) ;
else
/* Optimize for slow and wide. */
ret = intel_dp_compute_link_config_wide ( intel_dp , pipe_config , & limits ) ;
2018-11-28 13:36:21 -08:00
/* enable compression if the mode doesn't fit available BW */
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Force DSC en = %d \n " , intel_dp - > force_dsc_en ) ;
2020-11-17 11:47:06 -08:00
if ( ret | | intel_dp - > force_dsc_en | | pipe_config - > bigjoiner ) {
2019-01-15 15:08:00 -05:00
ret = intel_dp_dsc_compute_config ( intel_dp , pipe_config ,
conn_state , & limits ) ;
if ( ret < 0 )
return ret ;
drm/i915/dp: optimize eDP 1.4+ link config fast and narrow
We've opted to use the maximum link rate and lane count for eDP panels,
because typically the maximum supported configuration reported by the
panel has matched the native resolution requirements of the panel, and
optimizing the link has lead to problems.
With eDP 1.4 rate select method and DSC features, this is decreasingly
the case. There's a need to optimize the link parameters. Moreover,
already eDP 1.3 states fast link with fewer lanes is preferred over the
wide and slow. (Wide and slow should still be more reliable for longer
cable lengths.)
Additionally, there have been reports of panels failing on arbitrary
link configurations, although arguably all configurations they claim to
support should work.
Optimize eDP 1.4+ link config fast and narrow.
Side note: The implementation has a near duplicate of the link config
function, with just the two inner for loops turned inside out. Perhaps
there'd be a way to make this, say, more table driven to reduce the
duplication, but seems like that would lead to duplication in the table
generation. We'll also have to see how the link config optimization for
DSC turns out.
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Matt Atwood <matthew.s.atwood@intel.com>
Cc: "Lee, Shawn C" <shawn.c.lee@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Manasi Navare <manasi.d.navare@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105267
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180905095321.13843-1-jani.nikula@intel.com
2018-09-05 12:53:21 +03:00
}
2018-04-26 11:25:26 +03:00
2019-10-22 16:34:13 +03:00
if ( pipe_config - > dsc . compression_enable ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" DP lane count %d clock %d Input bpp %d Compressed bpp %d \n " ,
pipe_config - > lane_count , pipe_config - > port_clock ,
pipe_config - > pipe_bpp ,
pipe_config - > dsc . compressed_bpp ) ;
drm_dbg_kms ( & i915 - > drm ,
" DP link rate required %i available %i \n " ,
intel_dp_link_required ( adjusted_mode - > crtc_clock ,
pipe_config - > dsc . compressed_bpp ) ,
intel_dp_max_data_rate ( pipe_config - > port_clock ,
pipe_config - > lane_count ) ) ;
2018-11-28 13:36:21 -08:00
} else {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " DP lane count %d clock %d bpp %d \n " ,
pipe_config - > lane_count , pipe_config - > port_clock ,
pipe_config - > pipe_bpp ) ;
2018-11-28 13:36:21 -08:00
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" DP link rate required %i available %i \n " ,
intel_dp_link_required ( adjusted_mode - > crtc_clock ,
pipe_config - > pipe_bpp ) ,
intel_dp_max_data_rate ( pipe_config - > port_clock ,
pipe_config - > lane_count ) ) ;
2018-11-28 13:36:21 -08:00
}
2019-01-15 15:08:00 -05:00
return 0 ;
2018-04-26 11:25:26 +03:00
}
2019-03-26 16:25:51 +02:00
bool intel_dp_limited_color_range ( const struct intel_crtc_state * crtc_state ,
const struct drm_connector_state * conn_state )
{
const struct intel_digital_connector_state * intel_conn_state =
to_intel_digital_connector_state ( conn_state ) ;
const struct drm_display_mode * adjusted_mode =
2019-10-31 12:26:02 +01:00
& crtc_state - > hw . adjusted_mode ;
2019-03-26 16:25:51 +02:00
2019-07-18 19:45:23 +03:00
/*
* Our YCbCr output is always limited range .
* crtc_state - > limited_color_range only applies to RGB ,
* and it must never be set for YCbCr or we risk setting
* some conflicting bits in PIPECONF which will mess up
* the colors on the monitor .
*/
if ( crtc_state - > output_format ! = INTEL_OUTPUT_FORMAT_RGB )
return false ;
2019-03-26 16:25:51 +02:00
if ( intel_conn_state - > broadcast_rgb = = INTEL_BROADCAST_RGB_AUTO ) {
/*
* See :
* CEA - 861 - E - 5.1 Default Encoding Parameters
* VESA DisplayPort Ver .1 .2 a - 5.1 .1 .1 Video Colorimetry
*/
return crtc_state - > pipe_bpp ! = 18 & &
drm_default_rgb_quant_range ( adjusted_mode ) = =
HDMI_QUANTIZATION_RANGE_LIMITED ;
} else {
return intel_conn_state - > broadcast_rgb = =
INTEL_BROADCAST_RGB_LIMITED ;
}
}
2019-11-25 14:53:12 +02:00
static bool intel_dp_port_has_audio ( struct drm_i915_private * dev_priv ,
enum port port )
{
if ( IS_G4X ( dev_priv ) )
return false ;
if ( INTEL_GEN ( dev_priv ) < 12 & & port = = PORT_A )
return false ;
return true ;
}
2020-02-11 09:46:41 +02:00
static void intel_dp_compute_vsc_colorimetry ( const struct intel_crtc_state * crtc_state ,
const struct drm_connector_state * conn_state ,
struct drm_dp_vsc_sdp * vsc )
{
struct intel_crtc * crtc = to_intel_crtc ( crtc_state - > uapi . crtc ) ;
struct drm_i915_private * dev_priv = to_i915 ( crtc - > base . dev ) ;
/*
* Prepare VSC Header for SU as per DP 1.4 spec , Table 2 - 118
* VSC SDP supporting 3 D stereo , PSR2 , and Pixel Encoding /
* Colorimetry Format indication .
*/
vsc - > revision = 0x5 ;
vsc - > length = 0x13 ;
/* DP 1.4a spec, Table 2-120 */
switch ( crtc_state - > output_format ) {
case INTEL_OUTPUT_FORMAT_YCBCR444 :
vsc - > pixelformat = DP_PIXELFORMAT_YUV444 ;
break ;
case INTEL_OUTPUT_FORMAT_YCBCR420 :
vsc - > pixelformat = DP_PIXELFORMAT_YUV420 ;
break ;
case INTEL_OUTPUT_FORMAT_RGB :
default :
vsc - > pixelformat = DP_PIXELFORMAT_RGB ;
}
switch ( conn_state - > colorspace ) {
case DRM_MODE_COLORIMETRY_BT709_YCC :
vsc - > colorimetry = DP_COLORIMETRY_BT709_YCC ;
break ;
case DRM_MODE_COLORIMETRY_XVYCC_601 :
vsc - > colorimetry = DP_COLORIMETRY_XVYCC_601 ;
break ;
case DRM_MODE_COLORIMETRY_XVYCC_709 :
vsc - > colorimetry = DP_COLORIMETRY_XVYCC_709 ;
break ;
case DRM_MODE_COLORIMETRY_SYCC_601 :
vsc - > colorimetry = DP_COLORIMETRY_SYCC_601 ;
break ;
case DRM_MODE_COLORIMETRY_OPYCC_601 :
vsc - > colorimetry = DP_COLORIMETRY_OPYCC_601 ;
break ;
case DRM_MODE_COLORIMETRY_BT2020_CYCC :
vsc - > colorimetry = DP_COLORIMETRY_BT2020_CYCC ;
break ;
case DRM_MODE_COLORIMETRY_BT2020_RGB :
vsc - > colorimetry = DP_COLORIMETRY_BT2020_RGB ;
break ;
case DRM_MODE_COLORIMETRY_BT2020_YCC :
vsc - > colorimetry = DP_COLORIMETRY_BT2020_YCC ;
break ;
case DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65 :
case DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER :
vsc - > colorimetry = DP_COLORIMETRY_DCI_P3_RGB ;
break ;
default :
/*
* RGB - > YCBCR color conversion uses the BT .709
* color space .
*/
if ( crtc_state - > output_format = = INTEL_OUTPUT_FORMAT_YCBCR420 )
vsc - > colorimetry = DP_COLORIMETRY_BT709_YCC ;
else
vsc - > colorimetry = DP_COLORIMETRY_DEFAULT ;
break ;
}
vsc - > bpc = crtc_state - > pipe_bpp / 3 ;
/* only RGB pixelformat supports 6 bpc */
drm_WARN_ON ( & dev_priv - > drm ,
vsc - > bpc = = 6 & & vsc - > pixelformat ! = DP_PIXELFORMAT_RGB ) ;
/* all YCbCr are always limited range */
vsc - > dynamic_range = DP_DYNAMIC_RANGE_CTA ;
vsc - > content_type = DP_CONTENT_TYPE_NOT_DEFINED ;
}
static void intel_dp_compute_vsc_sdp ( struct intel_dp * intel_dp ,
struct intel_crtc_state * crtc_state ,
const struct drm_connector_state * conn_state )
{
struct drm_dp_vsc_sdp * vsc = & crtc_state - > infoframes . vsc ;
2020-05-14 09:07:31 +03:00
/* When a crtc state has PSR, VSC SDP will be handled by PSR routine */
if ( crtc_state - > has_psr )
2020-02-11 09:46:41 +02:00
return ;
if ( ! intel_dp_needs_vsc_sdp ( crtc_state , conn_state ) )
return ;
crtc_state - > infoframes . enable | = intel_hdmi_infoframe_enable ( DP_SDP_VSC ) ;
vsc - > sdp_type = DP_SDP_VSC ;
intel_dp_compute_vsc_colorimetry ( crtc_state , conn_state ,
& crtc_state - > infoframes . vsc ) ;
}
2020-05-14 09:07:31 +03:00
void intel_dp_compute_psr_vsc_sdp ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state ,
const struct drm_connector_state * conn_state ,
struct drm_dp_vsc_sdp * vsc )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
vsc - > sdp_type = DP_SDP_VSC ;
if ( dev_priv - > psr . psr2_enabled ) {
if ( dev_priv - > psr . colorimetry_support & &
intel_dp_needs_vsc_sdp ( crtc_state , conn_state ) ) {
/* [PSR2, +Colorimetry] */
intel_dp_compute_vsc_colorimetry ( crtc_state , conn_state ,
vsc ) ;
} else {
/*
* [ PSR2 , - Colorimetry ]
* Prepare VSC Header for SU as per eDP 1.4 spec , Table 6 - 11
* 3 D stereo + PSR / PSR2 + Y - coordinate .
*/
vsc - > revision = 0x4 ;
vsc - > length = 0xe ;
}
} else {
/*
* [ PSR1 ]
* Prepare VSC Header for SU as per DP 1.4 spec , Table 2 - 118
* VSC SDP supporting 3 D stereo + PSR ( applies to eDP v1 .3 or
* higher ) .
*/
vsc - > revision = 0x2 ;
vsc - > length = 0x8 ;
}
}
2020-02-11 09:46:42 +02:00
static void
intel_dp_compute_hdr_metadata_infoframe_sdp ( struct intel_dp * intel_dp ,
struct intel_crtc_state * crtc_state ,
const struct drm_connector_state * conn_state )
{
int ret ;
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
struct hdmi_drm_infoframe * drm_infoframe = & crtc_state - > infoframes . drm . drm ;
if ( ! conn_state - > hdr_output_metadata )
return ;
ret = drm_hdmi_infoframe_set_hdr_metadata ( drm_infoframe , conn_state ) ;
if ( ret ) {
drm_dbg_kms ( & dev_priv - > drm , " couldn't set HDR metadata in infoframe \n " ) ;
return ;
}
crtc_state - > infoframes . enable | =
intel_hdmi_infoframe_enable ( HDMI_PACKET_TYPE_GAMUT_METADATA ) ;
}
2020-08-25 10:13:29 -07:00
static void
intel_dp_drrs_compute_config ( struct intel_dp * intel_dp ,
struct intel_crtc_state * pipe_config ,
int output_bpp , bool constant_n )
{
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
/*
* DRRS and PSR can ' t be enable together , so giving preference to PSR
* as it allows more power - savings by complete shutting down display ,
* so to guarantee this , intel_dp_drrs_compute_config ( ) must be called
* after intel_psr_compute_config ( ) .
*/
if ( pipe_config - > has_psr )
return ;
if ( ! intel_connector - > panel . downclock_mode | |
dev_priv - > drrs . type ! = SEAMLESS_DRRS_SUPPORT )
return ;
pipe_config - > has_drrs = true ;
intel_link_compute_m_n ( output_bpp , pipe_config - > lane_count ,
intel_connector - > panel . downclock_mode - > clock ,
pipe_config - > port_clock , & pipe_config - > dp_m2_n2 ,
constant_n , pipe_config - > fec_enable ) ;
}
2019-01-15 15:08:00 -05:00
int
2018-04-26 11:25:26 +03:00
intel_dp_compute_config ( struct intel_encoder * encoder ,
struct intel_crtc_state * pipe_config ,
struct drm_connector_state * conn_state )
{
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2019-10-31 12:26:02 +01:00
struct drm_display_mode * adjusted_mode = & pipe_config - > hw . adjusted_mode ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2018-04-26 11:25:26 +03:00
enum port port = encoder - > port ;
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
struct intel_digital_connector_state * intel_conn_state =
to_intel_digital_connector_state ( conn_state ) ;
2020-02-11 13:33:46 -05:00
bool constant_n = drm_dp_has_quirk ( & intel_dp - > desc , 0 ,
2018-09-11 23:22:50 -07:00
DP_DPCD_QUIRK_CONSTANT_N ) ;
2019-05-21 15:17:16 +03:00
int ret = 0 , output_bpp ;
2018-04-26 11:25:26 +03:00
if ( HAS_PCH_SPLIT ( dev_priv ) & & ! HAS_DDI ( dev_priv ) & & port ! = PORT_A )
pipe_config - > has_pch_encoder = true ;
2020-09-24 21:41:56 +03:00
pipe_config - > output_format = intel_dp_output_format ( & intel_connector - > base ,
adjusted_mode ) ;
2019-09-19 22:53:05 +03:00
2020-09-24 21:41:56 +03:00
if ( pipe_config - > output_format = = INTEL_OUTPUT_FORMAT_YCBCR420 ) {
ret = intel_pch_panel_fitting ( pipe_config , conn_state ) ;
if ( ret )
return ret ;
}
2018-10-12 11:53:14 +05:30
2019-11-25 14:53:12 +02:00
if ( ! intel_dp_port_has_audio ( dev_priv , port ) )
2018-04-26 11:25:26 +03:00
pipe_config - > has_audio = false ;
else if ( intel_conn_state - > force_audio = = HDMI_AUDIO_AUTO )
pipe_config - > has_audio = intel_dp - > has_audio ;
else
pipe_config - > has_audio = intel_conn_state - > force_audio = = HDMI_AUDIO_ON ;
if ( intel_dp_is_edp ( intel_dp ) & & intel_connector - > panel . fixed_mode ) {
Revert "drm/i915/edp: Allow alternate fixed mode for eDP if available."
This reverts commit dc911f5bd8aacfcf8aabd5c26c88e04c837a938e.
Per the report, no matter what display mode you select with xrandr, the
i915 driver will always select the alternate fixed mode. For the
reporter this means that the display will always run at 40Hz which is
quite annoying. This may be due to the mode comparison.
But there are some other potential issues. The choice of alt_fixed_mode
seems dubious. It's the first non-preferred mode, but there are no
guarantees that the only difference would be refresh rate. Similarly,
there may be more than one preferred mode in the probed modes list, and
the commit changes the preferred mode selection to choose the last one
on the list instead of the first.
(Note that the probed modes list is the raw, unfiltered, unsorted list
of modes from drm_add_edid_modes(), not the pretty result after a
drm_helper_probe_single_connector_modes() call.)
Finally, we already have eerily similar code in place to find the
downclock mode for DRRS that seems like could be reused here.
Back to the drawing board.
Note: This is a hand-crafted revert due to conflicts. If it fails to
backport, please just try reverting the original commit directly.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105469
Reported-by: Rune Petersen <rune@megahurts.dk>
Reported-by: Mark Spencer <n7u4722r35@ynzlx.anonbox.net>
Fixes: dc911f5bd8aa ("drm/i915/edp: Allow alternate fixed mode for eDP if available.")
Cc: Clint Taylor <clinton.a.taylor@intel.com>
Cc: David Weinehall <david.weinehall@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jim Bride <jim.bride@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180516080110.22770-1-jani.nikula@intel.com
2018-05-16 11:01:10 +03:00
intel_fixed_panel_mode ( intel_connector - > panel . fixed_mode ,
adjusted_mode ) ;
2018-04-26 11:25:26 +03:00
2019-02-04 14:25:38 -08:00
if ( HAS_GMCH ( dev_priv ) )
2020-04-22 19:19:17 +03:00
ret = intel_gmch_panel_fitting ( pipe_config , conn_state ) ;
2018-04-26 11:25:26 +03:00
else
2020-04-22 19:19:17 +03:00
ret = intel_pch_panel_fitting ( pipe_config , conn_state ) ;
if ( ret )
return ret ;
2018-04-26 11:25:26 +03:00
}
2018-05-24 15:54:03 +03:00
if ( adjusted_mode - > flags & DRM_MODE_FLAG_DBLSCAN )
2019-01-15 15:08:00 -05:00
return - EINVAL ;
2018-05-24 15:54:03 +03:00
2019-02-04 14:25:38 -08:00
if ( HAS_GMCH ( dev_priv ) & &
2018-04-26 11:25:26 +03:00
adjusted_mode - > flags & DRM_MODE_FLAG_INTERLACE )
2019-01-15 15:08:00 -05:00
return - EINVAL ;
2018-04-26 11:25:26 +03:00
if ( adjusted_mode - > flags & DRM_MODE_FLAG_DBLCLK )
2019-01-15 15:08:00 -05:00
return - EINVAL ;
2018-04-26 11:25:26 +03:00
2019-07-18 17:43:39 +03:00
if ( intel_dp_hdisplay_bad ( dev_priv , adjusted_mode - > crtc_hdisplay ) )
return - EINVAL ;
2019-01-15 15:08:00 -05:00
ret = intel_dp_compute_link_config ( encoder , pipe_config , conn_state ) ;
if ( ret < 0 )
return ret ;
2018-04-26 11:25:26 +03:00
2019-03-26 16:25:51 +02:00
pipe_config - > limited_color_range =
intel_dp_limited_color_range ( pipe_config , conn_state ) ;
2013-01-17 16:31:29 +02:00
2019-10-22 16:34:13 +03:00
if ( pipe_config - > dsc . compression_enable )
output_bpp = pipe_config - > dsc . compressed_bpp ;
2018-11-28 13:36:21 -08:00
else
2020-09-18 00:43:34 +03:00
output_bpp = intel_dp_output_bpp ( pipe_config - > output_format ,
pipe_config - > pipe_bpp ) ;
2019-03-26 16:49:03 +02:00
intel_link_compute_m_n ( output_bpp ,
pipe_config - > lane_count ,
adjusted_mode - > crtc_clock ,
pipe_config - > port_clock ,
& pipe_config - > dp_m_n ,
2019-09-25 10:21:09 +02:00
constant_n , pipe_config - > fec_enable ) ;
2013-03-18 11:25:36 +01:00
2016-10-13 11:02:52 +01:00
if ( ! HAS_DDI ( dev_priv ) )
2015-08-11 20:21:46 +03:00
intel_dp_set_clock ( encoder , pipe_config ) ;
2013-04-19 11:14:33 +02:00
2017-10-12 16:02:01 +03:00
intel_psr_compute_config ( intel_dp , pipe_config ) ;
2020-08-25 10:13:29 -07:00
intel_dp_drrs_compute_config ( intel_dp , pipe_config , output_bpp ,
constant_n ) ;
2020-02-11 09:46:41 +02:00
intel_dp_compute_vsc_sdp ( intel_dp , pipe_config , conn_state ) ;
2020-02-11 09:46:42 +02:00
intel_dp_compute_hdr_metadata_infoframe_sdp ( intel_dp , pipe_config , conn_state ) ;
2017-10-12 16:02:01 +03:00
2019-01-15 15:08:00 -05:00
return 0 ;
2009-04-07 16:16:42 -07:00
}
2015-08-17 18:05:12 +03:00
void intel_dp_set_link_params ( struct intel_dp * intel_dp ,
2020-10-01 14:10:53 +03:00
int link_rate , int lane_count )
2015-08-17 18:05:12 +03:00
{
2018-01-17 21:21:49 +02:00
intel_dp - > link_trained = false ;
2016-09-01 15:08:06 -07:00
intel_dp - > link_rate = link_rate ;
intel_dp - > lane_count = lane_count ;
2015-08-17 18:05:12 +03:00
}
2016-08-09 17:04:13 +02:00
static void intel_dp_prepare ( struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config )
2009-04-07 16:16:42 -07:00
{
2017-11-09 17:27:58 +02:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2017-11-09 17:24:34 +02:00
enum port port = encoder - > port ;
2019-10-31 12:26:03 +01:00
struct intel_crtc * crtc = to_intel_crtc ( pipe_config - > uapi . crtc ) ;
2019-10-31 12:26:02 +01:00
const struct drm_display_mode * adjusted_mode = & pipe_config - > hw . adjusted_mode ;
2009-04-07 16:16:42 -07:00
2020-10-01 14:10:53 +03:00
intel_dp_set_link_params ( intel_dp ,
pipe_config - > port_clock ,
pipe_config - > lane_count ) ;
2015-08-17 18:05:12 +03:00
2011-11-01 19:54:11 -07:00
/*
2011-11-16 16:26:07 -08:00
* There are four kinds of DP registers :
2011-11-01 19:54:11 -07:00
*
2021-01-08 19:44:09 +02:00
* IBX PCH
* SNB CPU
* IVB CPU
* CPT PCH
*
* IBX PCH and CPU are the same for almost everything ,
* except that the CPU DP PLL is configured in this
* register
*
* CPT PCH is quite different , having many bits moved
* to the TRANS_DP_CTL register instead . That
* configuration happens ( oddly ) in ilk_pch_enable
*/
2014-03-07 20:05:20 -03:00
2021-01-08 19:44:09 +02:00
/* Preserve the BIOS-computed detected bit. This is
* supposed to be read - only .
*/
intel_dp - > DP = intel_de_read ( dev_priv , intel_dp - > output_reg ) & DP_DETECTED ;
2010-07-22 13:18:19 -07:00
2021-01-08 19:44:09 +02:00
/* Handle DP bits in common between all three register formats */
intel_dp - > DP | = DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0 ;
intel_dp - > DP | = DP_PORT_WIDTH ( pipe_config - > lane_count ) ;
2014-03-07 20:05:20 -03:00
2021-01-08 19:44:09 +02:00
/* Split out the IBX/CPU vs CPT settings */
2014-09-04 14:53:14 +03:00
2021-01-08 19:44:09 +02:00
if ( IS_IVYBRIDGE ( dev_priv ) & & port = = PORT_A ) {
if ( adjusted_mode - > flags & DRM_MODE_FLAG_PHSYNC )
intel_dp - > DP | = DP_SYNC_HS_HIGH ;
if ( adjusted_mode - > flags & DRM_MODE_FLAG_PVSYNC )
intel_dp - > DP | = DP_SYNC_VS_HIGH ;
intel_dp - > DP | = DP_LINK_TRAIN_OFF_CPT ;
2019-01-14 14:21:26 +00:00
2021-01-08 19:44:09 +02:00
if ( drm_dp_enhanced_frame_cap ( intel_dp - > dpcd ) )
intel_dp - > DP | = DP_ENHANCED_FRAMING ;
2014-09-04 14:53:14 +03:00
2021-01-08 19:44:09 +02:00
intel_dp - > DP | = DP_PIPE_SEL_IVB ( crtc - > pipe ) ;
} else if ( HAS_PCH_CPT ( dev_priv ) & & port ! = PORT_A ) {
u32 trans_dp ;
2010-07-22 13:18:19 -07:00
2021-01-08 19:44:09 +02:00
intel_dp - > DP | = DP_LINK_TRAIN_OFF_CPT ;
2009-07-24 01:00:32 +08:00
2021-01-08 19:44:09 +02:00
trans_dp = intel_de_read ( dev_priv , TRANS_DP_CTL ( crtc - > pipe ) ) ;
if ( drm_dp_enhanced_frame_cap ( intel_dp - > dpcd ) )
trans_dp | = TRANS_DP_ENH_FRAMING ;
else
trans_dp & = ~ TRANS_DP_ENH_FRAMING ;
intel_de_write ( dev_priv , TRANS_DP_CTL ( crtc - > pipe ) , trans_dp ) ;
} else {
if ( IS_G4X ( dev_priv ) & & pipe_config - > limited_color_range )
intel_dp - > DP | = DP_COLOR_RANGE_16_235 ;
2014-09-04 14:53:14 +03:00
2021-01-08 19:44:09 +02:00
if ( adjusted_mode - > flags & DRM_MODE_FLAG_PHSYNC )
intel_dp - > DP | = DP_SYNC_HS_HIGH ;
if ( adjusted_mode - > flags & DRM_MODE_FLAG_PVSYNC )
intel_dp - > DP | = DP_SYNC_VS_HIGH ;
intel_dp - > DP | = DP_LINK_TRAIN_OFF ;
2013-03-28 09:55:41 -07:00
2021-01-08 19:44:09 +02:00
if ( drm_dp_enhanced_frame_cap ( intel_dp - > dpcd ) )
intel_dp - > DP | = DP_ENHANCED_FRAMING ;
2013-03-28 09:55:41 -07:00
2021-01-08 19:44:09 +02:00
if ( IS_CHERRYVIEW ( dev_priv ) )
intel_dp - > DP | = DP_PIPE_SEL_CHV ( crtc - > pipe ) ;
else
intel_dp - > DP | = DP_PIPE_SEL ( crtc - > pipe ) ;
2019-01-14 14:21:26 +00:00
}
2009-07-24 01:00:32 +08:00
}
2021-01-08 19:44:09 +02:00
2014-08-12 17:11:39 +03:00
/* Enable backlight PWM and backlight PP control. */
2017-06-12 12:21:13 +02:00
void intel_edp_backlight_on ( const struct intel_crtc_state * crtc_state ,
const struct drm_connector_state * conn_state )
2014-08-12 17:11:39 +03:00
{
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( to_intel_encoder ( conn_state - > best_encoder ) ) ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2017-06-12 12:21:13 +02:00
2017-08-18 12:30:20 +03:00
if ( ! intel_dp_is_edp ( intel_dp ) )
2014-08-12 17:11:39 +03:00
return ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " \n " ) ;
2014-08-12 17:11:39 +03:00
2017-06-12 12:21:13 +02:00
intel_panel_enable_backlight ( crtc_state , conn_state ) ;
2021-01-08 19:44:11 +02:00
intel_pps_backlight_on ( intel_dp ) ;
2014-08-12 17:11:39 +03:00
}
/* Disable backlight PP control and backlight PWM. */
2017-06-12 12:21:13 +02:00
void intel_edp_backlight_off ( const struct drm_connector_state * old_conn_state )
2014-08-12 17:11:39 +03:00
{
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( to_intel_encoder ( old_conn_state - > best_encoder ) ) ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2017-06-12 12:21:13 +02:00
2017-08-18 12:30:20 +03:00
if ( ! intel_dp_is_edp ( intel_dp ) )
2014-08-12 17:11:39 +03:00
return ;
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " \n " ) ;
2014-03-31 11:13:56 -07:00
2021-01-08 19:44:11 +02:00
intel_pps_backlight_off ( intel_dp ) ;
2017-06-12 12:21:13 +02:00
intel_panel_disable_backlight ( old_conn_state ) ;
2009-07-24 01:00:32 +08:00
}
2009-04-07 16:16:42 -07:00
2015-10-29 21:26:01 +02:00
static void assert_dp_port ( struct intel_dp * intel_dp , bool state )
{
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct drm_i915_private * dev_priv = to_i915 ( dig_port - > base . base . dev ) ;
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
bool cur_state = intel_de_read ( dev_priv , intel_dp - > output_reg ) & DP_PORT_EN ;
2015-10-29 21:26:01 +02:00
I915_STATE_WARN ( cur_state ! = state ,
2019-08-30 21:27:19 +03:00
" [ENCODER:%d:%s] state assertion failure (expected %s, current %s) \n " ,
dig_port - > base . base . base . id , dig_port - > base . base . name ,
2016-01-14 12:53:34 +02:00
onoff ( state ) , onoff ( cur_state ) ) ;
2015-10-29 21:26:01 +02:00
}
# define assert_dp_port_disabled(d) assert_dp_port((d), false)
static void assert_edp_pll ( struct drm_i915_private * dev_priv , bool state )
{
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
bool cur_state = intel_de_read ( dev_priv , DP_A ) & DP_PLL_ENABLE ;
2015-10-29 21:26:01 +02:00
I915_STATE_WARN ( cur_state ! = state ,
" eDP PLL state assertion failure (expected %s, current %s) \n " ,
2016-01-14 12:53:34 +02:00
onoff ( state ) , onoff ( cur_state ) ) ;
2015-10-29 21:26:01 +02:00
}
# define assert_edp_pll_enabled(d) assert_edp_pll((d), true)
# define assert_edp_pll_disabled(d) assert_edp_pll((d), false)
2019-12-24 00:40:09 -08:00
static void ilk_edp_pll_on ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * pipe_config )
2010-08-13 15:43:26 -07:00
{
2019-10-31 12:26:03 +01:00
struct intel_crtc * crtc = to_intel_crtc ( pipe_config - > uapi . crtc ) ;
2015-10-29 21:26:01 +02:00
struct drm_i915_private * dev_priv = to_i915 ( crtc - > base . dev ) ;
2010-08-13 15:43:26 -07:00
2020-01-08 16:56:16 +02:00
assert_pipe_disabled ( dev_priv , pipe_config - > cpu_transcoder ) ;
2015-10-29 21:26:01 +02:00
assert_dp_port_disabled ( intel_dp ) ;
assert_edp_pll_disabled ( dev_priv ) ;
2012-09-06 22:15:41 +02:00
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " enabling eDP PLL for clock %d \n " ,
pipe_config - > port_clock ) ;
2015-10-29 21:26:03 +02:00
intel_dp - > DP & = ~ DP_PLL_FREQ_MASK ;
2016-08-09 17:04:13 +02:00
if ( pipe_config - > port_clock = = 162000 )
2015-10-29 21:26:03 +02:00
intel_dp - > DP | = DP_PLL_FREQ_162MHZ ;
else
intel_dp - > DP | = DP_PLL_FREQ_270MHZ ;
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , DP_A , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , DP_A ) ;
2015-10-29 21:26:03 +02:00
udelay ( 500 ) ;
2016-04-01 21:53:19 +03:00
/*
* [ DevILK ] Work around required when enabling DP PLL
* while a pipe is enabled going to FDI :
* 1. Wait for the start of vertical blank on the enabled pipe going to FDI
* 2. Program DP PLL enable
*/
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 , 5 ) )
2016-10-31 22:37:06 +02:00
intel_wait_for_vblank_if_active ( dev_priv , ! crtc - > pipe ) ;
2016-04-01 21:53:19 +03:00
2012-09-06 22:15:42 +02:00
intel_dp - > DP | = DP_PLL_ENABLE ;
2015-11-10 16:16:17 +02:00
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , DP_A , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , DP_A ) ;
2010-10-07 16:01:24 -07:00
udelay ( 200 ) ;
2010-08-13 15:43:26 -07:00
}
2019-12-24 00:40:09 -08:00
static void ilk_edp_pll_off ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * old_crtc_state )
2010-08-13 15:43:26 -07:00
{
2019-10-31 12:26:03 +01:00
struct intel_crtc * crtc = to_intel_crtc ( old_crtc_state - > uapi . crtc ) ;
2015-10-29 21:26:01 +02:00
struct drm_i915_private * dev_priv = to_i915 ( crtc - > base . dev ) ;
2010-08-13 15:43:26 -07:00
2020-01-08 16:56:16 +02:00
assert_pipe_disabled ( dev_priv , old_crtc_state - > cpu_transcoder ) ;
2015-10-29 21:26:01 +02:00
assert_dp_port_disabled ( intel_dp ) ;
assert_edp_pll_enabled ( dev_priv ) ;
2012-09-06 22:15:41 +02:00
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " disabling eDP PLL \n " ) ;
2015-10-29 21:26:03 +02:00
2015-11-10 16:16:17 +02:00
intel_dp - > DP & = ~ DP_PLL_ENABLE ;
2012-09-06 22:15:42 +02:00
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , DP_A , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , DP_A ) ;
2010-08-13 15:43:26 -07:00
udelay ( 200 ) ;
}
2017-10-27 12:45:23 +03:00
static bool downstream_hpd_needs_d0 ( struct intel_dp * intel_dp )
{
/*
* DPCD 1.2 + should support BRANCH_DEVICE_CTRL , and thus
* be capable of signalling downstream hpd with a long pulse .
* Whether or not that means D3 is safe to use is not clear ,
* but let ' s assume so until proven otherwise .
*
* FIXME should really check all downstream ports . . .
*/
return intel_dp - > dpcd [ DP_DPCD_REV ] = = 0x11 & &
2019-08-29 14:48:49 +03:00
drm_dp_is_branch ( intel_dp - > dpcd ) & &
2017-10-27 12:45:23 +03:00
intel_dp - > downstream_ports [ 0 ] & DP_DS_PORT_HPD ;
}
2018-11-28 12:26:17 -08:00
void intel_dp_sink_set_decompression_state ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state ,
bool enable )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2018-11-28 12:26:17 -08:00
int ret ;
2019-10-22 16:34:13 +03:00
if ( ! crtc_state - > dsc . compression_enable )
2018-11-28 12:26:17 -08:00
return ;
ret = drm_dp_dpcd_writeb ( & intel_dp - > aux , DP_DSC_ENABLE ,
enable ? DP_DECOMPRESSION_EN : 0 ) ;
if ( ret < 0 )
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" Failed to %s sink decompression state \n " ,
enable ? " enable " : " disable " ) ;
2018-11-28 12:26:17 -08:00
}
2020-12-04 17:35:55 -05:00
static void
intel_edp_init_source_oui ( struct intel_dp * intel_dp , bool careful )
{
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
u8 oui [ ] = { 0x00 , 0xaa , 0x01 } ;
u8 buf [ 3 ] = { 0 } ;
/*
* During driver init , we want to be careful and avoid changing the source OUI if it ' s
* already set to what we want , so as to avoid clearing any state by accident
*/
if ( careful ) {
if ( drm_dp_dpcd_read ( & intel_dp - > aux , DP_SOURCE_OUI , buf , sizeof ( buf ) ) < 0 )
drm_err ( & i915 - > drm , " Failed to read source OUI \n " ) ;
if ( memcmp ( oui , buf , sizeof ( oui ) ) = = 0 )
return ;
}
if ( drm_dp_dpcd_write ( & intel_dp - > aux , DP_SOURCE_OUI , oui , sizeof ( oui ) ) < 0 )
drm_err ( & i915 - > drm , " Failed to write source OUI \n " ) ;
}
2020-10-16 22:48:00 +03:00
/* If the device supports it, try to set the power state appropriately */
void intel_dp_set_power ( struct intel_dp * intel_dp , u8 mode )
2011-07-07 11:11:03 -07:00
{
2020-10-16 22:48:00 +03:00
struct intel_encoder * encoder = & dp_to_dig_port ( intel_dp ) - > base ;
struct drm_i915_private * i915 = to_i915 ( encoder - > base . dev ) ;
2011-07-07 11:11:03 -07:00
int ret , i ;
/* Should have a valid DPCD by this point */
if ( intel_dp - > dpcd [ DP_DPCD_REV ] < 0x11 )
return ;
2020-10-16 22:48:00 +03:00
if ( mode ! = DP_SET_POWER_D0 ) {
2017-10-27 12:45:23 +03:00
if ( downstream_hpd_needs_d0 ( intel_dp ) )
return ;
2020-10-16 22:48:00 +03:00
ret = drm_dp_dpcd_writeb ( & intel_dp - > aux , DP_SET_POWER , mode ) ;
2011-07-07 11:11:03 -07:00
} else {
2016-11-21 21:15:06 +02:00
struct intel_lspcon * lspcon = dp_to_lspcon ( intel_dp ) ;
2020-10-16 22:47:59 +03:00
lspcon_resume ( dp_to_dig_port ( intel_dp ) ) ;
2020-12-04 17:35:55 -05:00
/* Write the source OUI as early as possible */
if ( intel_dp_is_edp ( intel_dp ) )
intel_edp_init_source_oui ( intel_dp , false ) ;
2011-07-07 11:11:03 -07:00
/*
* When turning on , we need to retry for 1 ms to give the sink
* time to wake up .
*/
for ( i = 0 ; i < 3 ; i + + ) {
2020-10-16 22:48:00 +03:00
ret = drm_dp_dpcd_writeb ( & intel_dp - > aux , DP_SET_POWER , mode ) ;
2011-07-07 11:11:03 -07:00
if ( ret = = 1 )
break ;
msleep ( 1 ) ;
}
2016-11-21 21:15:06 +02:00
if ( ret = = 1 & & lspcon - > active )
lspcon_wait_pcon_mode ( lspcon ) ;
2011-07-07 11:11:03 -07:00
}
2014-09-02 16:33:52 +03:00
if ( ret ! = 1 )
2020-10-16 22:48:00 +03:00
drm_dbg_kms ( & i915 - > drm , " [ENCODER:%d:%s] Set power to %s failed \n " ,
encoder - > base . base . id , encoder - > base . name ,
mode = = DP_SET_POWER_D0 ? " D0 " : " D3 " ) ;
2011-07-07 11:11:03 -07:00
}
2018-05-18 18:29:28 +03:00
static bool cpt_dp_port_selected ( struct drm_i915_private * dev_priv ,
enum port port , enum pipe * pipe )
{
enum pipe p ;
for_each_pipe ( dev_priv , p ) {
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
u32 val = intel_de_read ( dev_priv , TRANS_DP_CTL ( p ) ) ;
2018-05-18 18:29:28 +03:00
if ( ( val & TRANS_DP_PORT_SEL_MASK ) = = TRANS_DP_PORT_SEL ( port ) ) {
* pipe = p ;
return true ;
}
}
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " No pipe for DP port %c found \n " ,
port_name ( port ) ) ;
2018-05-18 18:29:28 +03:00
/* must initialize pipe to something for the asserts */
* pipe = PIPE_A ;
return false ;
}
bool intel_dp_port_enabled ( struct drm_i915_private * dev_priv ,
i915_reg_t dp_reg , enum port port ,
enum pipe * pipe )
{
bool ret ;
u32 val ;
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
val = intel_de_read ( dev_priv , dp_reg ) ;
2018-05-18 18:29:28 +03:00
ret = val & DP_PORT_EN ;
/* asserts want to know the pipe even if the port is disabled */
if ( IS_IVYBRIDGE ( dev_priv ) & & port = = PORT_A )
* pipe = ( val & DP_PIPE_SEL_MASK_IVB ) > > DP_PIPE_SEL_SHIFT_IVB ;
else if ( HAS_PCH_CPT ( dev_priv ) & & port ! = PORT_A )
ret & = cpt_dp_port_selected ( dev_priv , port , pipe ) ;
else if ( IS_CHERRYVIEW ( dev_priv ) )
* pipe = ( val & DP_PIPE_SEL_MASK_CHV ) > > DP_PIPE_SEL_SHIFT_CHV ;
else
* pipe = ( val & DP_PIPE_SEL_MASK ) > > DP_PIPE_SEL_SHIFT ;
return ret ;
}
2012-07-02 13:26:27 +02:00
static bool intel_dp_get_hw_state ( struct intel_encoder * encoder ,
enum pipe * pipe )
2010-08-13 15:43:26 -07:00
{
2017-11-09 17:27:58 +02:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2019-01-14 14:21:24 +00:00
intel_wakeref_t wakeref ;
2016-02-12 18:55:18 +02:00
bool ret ;
2014-03-05 16:20:54 +02:00
2019-01-14 14:21:24 +00:00
wakeref = intel_display_power_get_if_enabled ( dev_priv ,
encoder - > power_domain ) ;
if ( ! wakeref )
2014-03-05 16:20:54 +02:00
return false ;
2018-05-18 18:29:28 +03:00
ret = intel_dp_port_enabled ( dev_priv , intel_dp - > output_reg ,
encoder - > port , pipe ) ;
2016-02-12 18:55:18 +02:00
2019-01-14 14:21:24 +00:00
intel_display_power_put ( dev_priv , encoder - > power_domain , wakeref ) ;
2016-02-12 18:55:18 +02:00
return ret ;
2012-07-02 13:26:27 +02:00
}
2010-08-13 15:43:26 -07:00
2013-05-14 17:08:26 -07:00
static void intel_dp_get_config ( struct intel_encoder * encoder ,
2015-01-15 14:55:21 +02:00
struct intel_crtc_state * pipe_config )
2013-05-14 17:08:26 -07:00
{
2017-11-09 17:27:58 +02:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2013-05-14 17:08:26 -07:00
u32 tmp , flags = 0 ;
2017-11-09 17:24:34 +02:00
enum port port = encoder - > port ;
2019-10-31 12:26:03 +01:00
struct intel_crtc * crtc = to_intel_crtc ( pipe_config - > uapi . crtc ) ;
2013-05-14 17:08:26 -07:00
2017-10-27 22:31:23 +03:00
if ( encoder - > type = = INTEL_OUTPUT_EDP )
pipe_config - > output_types | = BIT ( INTEL_OUTPUT_EDP ) ;
else
pipe_config - > output_types | = BIT ( INTEL_OUTPUT_DP ) ;
2013-05-14 17:08:26 -07:00
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
tmp = intel_de_read ( dev_priv , intel_dp - > output_reg ) ;
2015-05-05 16:32:12 +03:00
pipe_config - > has_audio = tmp & DP_AUDIO_OUTPUT_ENABLE & & port ! = PORT_A ;
2014-04-24 23:54:52 +02:00
2016-10-13 11:02:53 +01:00
if ( HAS_PCH_CPT ( dev_priv ) & & port ! = PORT_A ) {
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
u32 trans_dp = intel_de_read ( dev_priv ,
TRANS_DP_CTL ( crtc - > pipe ) ) ;
2015-07-06 15:10:03 +03:00
if ( trans_dp & TRANS_DP_HSYNC_ACTIVE_HIGH )
2013-06-28 12:59:06 +08:00
flags | = DRM_MODE_FLAG_PHSYNC ;
else
flags | = DRM_MODE_FLAG_NHSYNC ;
2013-05-14 17:08:26 -07:00
2015-07-06 15:10:03 +03:00
if ( trans_dp & TRANS_DP_VSYNC_ACTIVE_HIGH )
2013-06-28 12:59:06 +08:00
flags | = DRM_MODE_FLAG_PVSYNC ;
else
flags | = DRM_MODE_FLAG_NVSYNC ;
} else {
2015-05-05 17:17:29 +03:00
if ( tmp & DP_SYNC_HS_HIGH )
2013-06-28 12:59:06 +08:00
flags | = DRM_MODE_FLAG_PHSYNC ;
else
flags | = DRM_MODE_FLAG_NHSYNC ;
2013-05-14 17:08:26 -07:00
2015-05-05 17:17:29 +03:00
if ( tmp & DP_SYNC_VS_HIGH )
2013-06-28 12:59:06 +08:00
flags | = DRM_MODE_FLAG_PVSYNC ;
else
flags | = DRM_MODE_FLAG_NVSYNC ;
}
2013-05-14 17:08:26 -07:00
2019-10-31 12:26:02 +01:00
pipe_config - > hw . adjusted_mode . flags | = flags ;
2013-06-27 00:39:25 +03:00
2016-11-14 19:44:07 +02:00
if ( IS_G4X ( dev_priv ) & & tmp & DP_COLOR_RANGE_16_235 )
2014-09-12 15:46:29 +03:00
pipe_config - > limited_color_range = true ;
2015-07-06 16:39:15 +03:00
pipe_config - > lane_count =
( ( tmp & DP_PORT_WIDTH_MASK ) > > DP_PORT_WIDTH_SHIFT ) + 1 ;
2013-09-10 17:02:54 +03:00
intel_dp_get_m_n ( crtc , pipe_config ) ;
2013-09-13 16:00:08 +03:00
if ( port = = PORT_A ) {
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
if ( ( intel_de_read ( dev_priv , DP_A ) & DP_PLL_FREQ_MASK ) = = DP_PLL_FREQ_162MHZ )
2013-06-27 00:39:25 +03:00
pipe_config - > port_clock = 162000 ;
else
pipe_config - > port_clock = 270000 ;
}
2013-09-13 16:00:08 +03:00
2019-10-31 12:26:02 +01:00
pipe_config - > hw . adjusted_mode . crtc_clock =
2016-02-17 21:41:09 +02:00
intel_dotclock_calculate ( pipe_config - > port_clock ,
& pipe_config - > dp_m_n ) ;
2013-11-04 16:28:47 +01:00
2017-08-18 12:30:20 +03:00
if ( intel_dp_is_edp ( intel_dp ) & & dev_priv - > vbt . edp . bpp & &
2016-03-24 17:50:20 +02:00
pipe_config - > pipe_bpp > dev_priv - > vbt . edp . bpp ) {
drm/i915/dp: workaround BIOS eDP bpp clamping issue
This isn't a real fix to the problem, but rather a stopgap measure while
trying to find a proper solution.
There are several laptops out there that fail to light up the eDP panel
in UEFI boot mode. They seem to be mostly IVB machines, including but
apparently not limited to Dell XPS 13, Asus TX300, Asus UX31A, Asus
UX32VD, Acer Aspire S7. They seem to work in CSM or legacy boot.
The difference between UEFI and CSM is that the BIOS provides a
different VBT to the kernel. The UEFI VBT typically specifies 18 bpp and
1.62 GHz link for eDP, while CSM VBT has 24 bpp and 2.7 GHz link. We end
up clamping to 18 bpp in UEFI mode, which we can fit in the 1.62 Ghz
link, and for reasons yet unknown fail to light up the panel.
Dithering from 24 to 18 bpp itself seems to work; if we use 18 bpp with
2.7 GHz link, the eDP panel lights up. So essentially this is a link
speed issue, and *not* a bpp clamping issue.
The bug raised its head since
commit 657445fe8660100ad174600ebfa61536392b7624
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Sat May 4 10:09:18 2013 +0200
Revert "drm/i915: revert eDP bpp clamping code changes"
which started clamping bpp *before* computing the link requirements, and
thus affecting the required bandwidth. Clamping after the computations
kept the link at 2.7 GHz.
Even though the BIOS tells us to use 18 bpp through the VBT, it happily
boots up at 24 bpp and 2.7 GHz itself! Use this information to
selectively ignore the VBT provided value.
We can't ignore the VBT eDP bpp altogether, as there are other laptops
that do require the clamping to be used due to EDID reporting higher bpp
than the panel can support.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=59841
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67950
Tested-by: Ulf Winkelvos <ulf@winkelvos.de>
Tested-by: jkp <jkp@iki.fi>
CC: stable@vger.kernel.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-10-21 10:52:07 +03:00
/*
* This is a big fat ugly hack .
*
* Some machines in UEFI boot mode provide us a VBT that has 18
* bpp and 1.62 GHz link bandwidth for eDP , which for reasons
* unknown we fail to light up . Yet the same BIOS boots up with
* 24 bpp and 2.7 GHz link . Use the same bpp as the BIOS uses as
* max , not what it tells us to use .
*
* Note : This will still be broken if the eDP panel is not lit
* up by the BIOS , and thus we can ' t get the mode at module
* load .
*/
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp \n " ,
pipe_config - > pipe_bpp , dev_priv - > vbt . edp . bpp ) ;
2016-03-24 17:50:20 +02:00
dev_priv - > vbt . edp . bpp = pipe_config - > pipe_bpp ;
drm/i915/dp: workaround BIOS eDP bpp clamping issue
This isn't a real fix to the problem, but rather a stopgap measure while
trying to find a proper solution.
There are several laptops out there that fail to light up the eDP panel
in UEFI boot mode. They seem to be mostly IVB machines, including but
apparently not limited to Dell XPS 13, Asus TX300, Asus UX31A, Asus
UX32VD, Acer Aspire S7. They seem to work in CSM or legacy boot.
The difference between UEFI and CSM is that the BIOS provides a
different VBT to the kernel. The UEFI VBT typically specifies 18 bpp and
1.62 GHz link for eDP, while CSM VBT has 24 bpp and 2.7 GHz link. We end
up clamping to 18 bpp in UEFI mode, which we can fit in the 1.62 Ghz
link, and for reasons yet unknown fail to light up the panel.
Dithering from 24 to 18 bpp itself seems to work; if we use 18 bpp with
2.7 GHz link, the eDP panel lights up. So essentially this is a link
speed issue, and *not* a bpp clamping issue.
The bug raised its head since
commit 657445fe8660100ad174600ebfa61536392b7624
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Sat May 4 10:09:18 2013 +0200
Revert "drm/i915: revert eDP bpp clamping code changes"
which started clamping bpp *before* computing the link requirements, and
thus affecting the required bandwidth. Clamping after the computations
kept the link at 2.7 GHz.
Even though the BIOS tells us to use 18 bpp through the VBT, it happily
boots up at 24 bpp and 2.7 GHz itself! Use this information to
selectively ignore the VBT provided value.
We can't ignore the VBT eDP bpp altogether, as there are other laptops
that do require the clamping to be used due to EDID reporting higher bpp
than the panel can support.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=59841
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67950
Tested-by: Ulf Winkelvos <ulf@winkelvos.de>
Tested-by: jkp <jkp@iki.fi>
CC: stable@vger.kernel.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-10-21 10:52:07 +03:00
}
2013-05-14 17:08:26 -07:00
}
2020-10-06 02:01:54 +03:00
static bool
intel_dp_get_dpcd ( struct intel_dp * intel_dp ) ;
/**
* intel_dp_sync_state - sync the encoder state during init / resume
* @ encoder : intel encoder to sync
* @ crtc_state : state for the CRTC connected to the encoder
*
* Sync any state stored in the encoder wrt . HW state during driver init
* and system resume .
*/
void intel_dp_sync_state ( struct intel_encoder * encoder ,
const struct intel_crtc_state * crtc_state )
{
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
/*
* Don ' t clobber DPCD if it ' s been already read out during output
* setup ( eDP ) or detect .
*/
if ( intel_dp - > dpcd [ DP_DPCD_REV ] = = 0 )
intel_dp_get_dpcd ( intel_dp ) ;
intel_dp - > max_link_lane_count = intel_dp_max_common_lane_count ( intel_dp ) ;
intel_dp - > max_link_rate = intel_dp_max_common_rate ( intel_dp ) ;
}
2020-10-06 00:53:10 +03:00
bool intel_dp_initial_fastset_check ( struct intel_encoder * encoder ,
struct intel_crtc_state * crtc_state )
{
struct drm_i915_private * i915 = to_i915 ( encoder - > base . dev ) ;
2020-10-03 03:18:44 +03:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
/*
* If BIOS has set an unsupported or non - standard link rate for some
* reason force an encoder recompute and full modeset .
*/
if ( intel_dp_rate_index ( intel_dp - > source_rates , intel_dp - > num_source_rates ,
crtc_state - > port_clock ) < 0 ) {
drm_dbg_kms ( & i915 - > drm , " Forcing full modeset due to unsupported link rate \n " ) ;
crtc_state - > uapi . connectors_changed = true ;
return false ;
}
2020-10-06 00:53:10 +03:00
/*
* FIXME hack to force full modeset when DSC is being used .
*
* As long as we do not have full state readout and config comparison
* of crtc_state - > dsc , we have no way to ensure reliable fastset .
* Remove once we have readout for DSC .
*/
if ( crtc_state - > dsc . compression_enable ) {
drm_dbg_kms ( & i915 - > drm , " Forcing full modeset due to DSC being enabled \n " ) ;
crtc_state - > uapi . mode_changed = true ;
return false ;
}
2020-11-02 14:10:48 -08:00
if ( CAN_PSR ( i915 ) & & intel_dp_is_edp ( intel_dp ) ) {
drm_dbg_kms ( & i915 - > drm , " Forcing full modeset to compute PSR state \n " ) ;
crtc_state - > uapi . mode_changed = true ;
return false ;
}
2020-10-06 00:53:10 +03:00
return true ;
}
2020-03-13 18:48:30 +02:00
static void intel_disable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * old_crtc_state ,
const struct drm_connector_state * old_conn_state )
2010-08-13 15:43:26 -07:00
{
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2014-10-27 16:26:55 +02:00
2018-01-17 21:21:49 +02:00
intel_dp - > link_trained = false ;
2016-08-09 17:04:13 +02:00
if ( old_crtc_state - > has_audio )
2017-10-30 20:46:53 +02:00
intel_audio_codec_disable ( encoder ,
old_crtc_state , old_conn_state ) ;
2012-05-20 17:14:50 +02:00
/* Make sure the panel is off before trying to change the mode. But also
* ensure that we have vdd while we switch off the panel . */
2021-01-08 19:44:12 +02:00
intel_pps_vdd_on ( intel_dp ) ;
2017-06-12 12:21:13 +02:00
intel_edp_backlight_off ( old_conn_state ) ;
2020-10-16 22:48:00 +03:00
intel_dp_set_power ( intel_dp , DP_SET_POWER_D3 ) ;
2021-01-08 19:44:12 +02:00
intel_pps_off ( intel_dp ) ;
2020-12-18 16:07:17 +05:30
intel_dp - > frl . is_trained = false ;
intel_dp - > frl . trained_rate_gbps = 0 ;
2017-09-20 18:12:51 +03:00
}
2020-03-13 18:48:30 +02:00
static void g4x_disable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-09-20 18:12:51 +03:00
const struct intel_crtc_state * old_crtc_state ,
const struct drm_connector_state * old_conn_state )
{
2020-03-13 18:48:30 +02:00
intel_disable_dp ( state , encoder , old_crtc_state , old_conn_state ) ;
2017-09-20 18:12:51 +03:00
}
2020-03-13 18:48:30 +02:00
static void vlv_disable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-09-20 18:12:51 +03:00
const struct intel_crtc_state * old_crtc_state ,
const struct drm_connector_state * old_conn_state )
{
2020-03-13 18:48:30 +02:00
intel_disable_dp ( state , encoder , old_crtc_state , old_conn_state ) ;
2010-08-13 15:43:26 -07:00
}
2020-03-13 18:48:30 +02:00
static void g4x_post_disable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * old_crtc_state ,
const struct drm_connector_state * old_conn_state )
2010-08-13 15:43:26 -07:00
{
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2017-10-31 22:51:14 +02:00
enum port port = encoder - > port ;
2012-09-06 22:15:41 +02:00
2018-06-13 19:05:53 +03:00
/*
* Bspec does not list a specific disable sequence for g4x DP .
* Follow the ilk + sequence ( disable pipe before the port ) for
* g4x DP as it does not suffer from underruns like the normal
* g4x modeset sequence ( disable pipe after the port ) .
*/
2017-10-31 22:51:14 +02:00
intel_dp_link_down ( encoder , old_crtc_state ) ;
2015-10-29 21:26:03 +02:00
/* Only ilk+ has port A */
2014-08-18 22:16:09 +03:00
if ( port = = PORT_A )
2019-12-24 00:40:09 -08:00
ilk_edp_pll_off ( intel_dp , old_crtc_state ) ;
2014-03-31 18:21:26 +03:00
}
2020-03-13 18:48:30 +02:00
static void vlv_post_disable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * old_crtc_state ,
const struct drm_connector_state * old_conn_state )
2014-03-31 18:21:26 +03:00
{
2017-10-31 22:51:14 +02:00
intel_dp_link_down ( encoder , old_crtc_state ) ;
2012-09-06 22:15:41 +02:00
}
2020-03-13 18:48:30 +02:00
static void chv_post_disable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * old_crtc_state ,
const struct drm_connector_state * old_conn_state )
2015-07-09 20:14:11 +03:00
{
2017-10-31 22:51:14 +02:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2014-04-09 13:29:02 +03:00
2017-10-31 22:51:14 +02:00
intel_dp_link_down ( encoder , old_crtc_state ) ;
2015-07-09 20:14:11 +03:00
2019-04-26 09:17:19 +01:00
vlv_dpio_get ( dev_priv ) ;
2015-07-09 20:14:11 +03:00
/* Assert data lane reset */
2017-10-31 22:51:18 +02:00
chv_data_lane_soft_reset ( encoder , old_crtc_state , true ) ;
2014-04-09 13:29:00 +03:00
2019-04-26 09:17:19 +01:00
vlv_dpio_put ( dev_priv ) ;
2014-04-09 13:29:00 +03:00
}
2014-08-18 22:16:08 +03:00
static void
2020-04-20 23:06:07 +03:00
cpt_set_link_train ( struct intel_dp * intel_dp ,
2020-10-01 14:10:53 +03:00
const struct intel_crtc_state * crtc_state ,
2020-04-20 23:06:07 +03:00
u8 dp_train_pat )
2014-08-18 22:16:08 +03:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2020-04-20 23:06:07 +03:00
u32 * DP = & intel_dp - > DP ;
2016-08-04 13:48:35 -07:00
2020-04-20 23:06:07 +03:00
* DP & = ~ DP_LINK_TRAIN_MASK_CPT ;
2014-08-18 22:16:08 +03:00
2020-10-07 20:09:12 +03:00
switch ( intel_dp_training_pattern_symbol ( dp_train_pat ) ) {
2020-04-20 23:06:07 +03:00
case DP_TRAINING_PATTERN_DISABLE :
* DP | = DP_LINK_TRAIN_OFF_CPT ;
break ;
case DP_TRAINING_PATTERN_1 :
* DP | = DP_LINK_TRAIN_PAT_1_CPT ;
break ;
case DP_TRAINING_PATTERN_2 :
* DP | = DP_LINK_TRAIN_PAT_2_CPT ;
break ;
case DP_TRAINING_PATTERN_3 :
drm_dbg_kms ( & dev_priv - > drm ,
" TPS3 not supported, using TPS2 instead \n " ) ;
* DP | = DP_LINK_TRAIN_PAT_2_CPT ;
break ;
}
2014-08-18 22:16:08 +03:00
2020-04-20 23:06:07 +03:00
intel_de_write ( dev_priv , intel_dp - > output_reg , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
}
2014-08-18 22:16:08 +03:00
2020-12-18 16:07:20 +05:30
static void intel_dp_get_pcon_dsc_cap ( struct intel_dp * intel_dp )
{
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
/* Clear the cached register set to avoid using stale values */
memset ( intel_dp - > pcon_dsc_dpcd , 0 , sizeof ( intel_dp - > pcon_dsc_dpcd ) ) ;
if ( drm_dp_dpcd_read ( & intel_dp - > aux , DP_PCON_DSC_ENCODER ,
intel_dp - > pcon_dsc_dpcd ,
sizeof ( intel_dp - > pcon_dsc_dpcd ) ) < 0 )
drm_err ( & i915 - > drm , " Failed to read DPCD register 0x%x \n " ,
DP_PCON_DSC_ENCODER ) ;
drm_dbg_kms ( & i915 - > drm , " PCON ENCODER DSC DPCD: %*ph \n " ,
( int ) sizeof ( intel_dp - > pcon_dsc_dpcd ) , intel_dp - > pcon_dsc_dpcd ) ;
}
2020-12-18 16:07:17 +05:30
static int intel_dp_pcon_get_frl_mask ( u8 frl_bw_mask )
{
int bw_gbps [ ] = { 9 , 18 , 24 , 32 , 40 , 48 } ;
int i ;
for ( i = ARRAY_SIZE ( bw_gbps ) - 1 ; i > = 0 ; i - - ) {
if ( frl_bw_mask & ( 1 < < i ) )
return bw_gbps [ i ] ;
}
return 0 ;
}
static int intel_dp_pcon_set_frl_mask ( int max_frl )
{
switch ( max_frl ) {
case 48 :
return DP_PCON_FRL_BW_MASK_48GBPS ;
case 40 :
return DP_PCON_FRL_BW_MASK_40GBPS ;
case 32 :
return DP_PCON_FRL_BW_MASK_32GBPS ;
case 24 :
return DP_PCON_FRL_BW_MASK_24GBPS ;
case 18 :
return DP_PCON_FRL_BW_MASK_18GBPS ;
case 9 :
return DP_PCON_FRL_BW_MASK_9GBPS ;
}
return 0 ;
}
static int intel_dp_hdmi_sink_max_frl ( struct intel_dp * intel_dp )
{
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
struct drm_connector * connector = & intel_connector - > base ;
2020-12-18 16:07:22 +05:30
int max_frl_rate ;
int max_lanes , rate_per_lane ;
int max_dsc_lanes , dsc_rate_per_lane ;
2020-12-18 16:07:17 +05:30
2020-12-18 16:07:22 +05:30
max_lanes = connector - > display_info . hdmi . max_lanes ;
rate_per_lane = connector - > display_info . hdmi . max_frl_rate_per_lane ;
max_frl_rate = max_lanes * rate_per_lane ;
if ( connector - > display_info . hdmi . dsc_cap . v_1p2 ) {
max_dsc_lanes = connector - > display_info . hdmi . dsc_cap . max_lanes ;
dsc_rate_per_lane = connector - > display_info . hdmi . dsc_cap . max_frl_rate_per_lane ;
if ( max_dsc_lanes & & dsc_rate_per_lane )
max_frl_rate = min ( max_frl_rate , max_dsc_lanes * dsc_rate_per_lane ) ;
}
return max_frl_rate ;
2020-12-18 16:07:17 +05:30
}
static int intel_dp_pcon_start_frl_training ( struct intel_dp * intel_dp )
{
# define PCON_EXTENDED_TRAIN_MODE (1 > 0)
# define PCON_CONCURRENT_MODE (1 > 0)
# define PCON_SEQUENTIAL_MODE !PCON_CONCURRENT_MODE
# define PCON_NORMAL_TRAIN_MODE !PCON_EXTENDED_TRAIN_MODE
# define TIMEOUT_FRL_READY_MS 500
# define TIMEOUT_HDMI_LINK_ACTIVE_MS 1000
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
int max_frl_bw , max_pcon_frl_bw , max_edid_frl_bw , ret ;
u8 max_frl_bw_mask = 0 , frl_trained_mask ;
bool is_active ;
ret = drm_dp_pcon_reset_frl_config ( & intel_dp - > aux ) ;
if ( ret < 0 )
return ret ;
max_pcon_frl_bw = intel_dp - > dfp . pcon_max_frl_bw ;
drm_dbg ( & i915 - > drm , " PCON max rate = %d Gbps \n " , max_pcon_frl_bw ) ;
max_edid_frl_bw = intel_dp_hdmi_sink_max_frl ( intel_dp ) ;
drm_dbg ( & i915 - > drm , " Sink max rate from EDID = %d Gbps \n " , max_edid_frl_bw ) ;
max_frl_bw = min ( max_edid_frl_bw , max_pcon_frl_bw ) ;
if ( max_frl_bw < = 0 )
return - EINVAL ;
ret = drm_dp_pcon_frl_prepare ( & intel_dp - > aux , false ) ;
if ( ret < 0 )
return ret ;
/* Wait for PCON to be FRL Ready */
wait_for ( is_active = drm_dp_pcon_is_frl_ready ( & intel_dp - > aux ) = = true , TIMEOUT_FRL_READY_MS ) ;
if ( ! is_active )
return - ETIMEDOUT ;
max_frl_bw_mask = intel_dp_pcon_set_frl_mask ( max_frl_bw ) ;
ret = drm_dp_pcon_frl_configure_1 ( & intel_dp - > aux , max_frl_bw , PCON_SEQUENTIAL_MODE ) ;
if ( ret < 0 )
return ret ;
ret = drm_dp_pcon_frl_configure_2 ( & intel_dp - > aux , max_frl_bw_mask , PCON_NORMAL_TRAIN_MODE ) ;
if ( ret < 0 )
return ret ;
ret = drm_dp_pcon_frl_enable ( & intel_dp - > aux ) ;
if ( ret < 0 )
return ret ;
/*
* Wait for FRL to be completed
* Check if the HDMI Link is up and active .
*/
wait_for ( is_active = drm_dp_pcon_hdmi_link_active ( & intel_dp - > aux ) = = true , TIMEOUT_HDMI_LINK_ACTIVE_MS ) ;
if ( ! is_active )
return - ETIMEDOUT ;
/* Verify HDMI Link configuration shows FRL Mode */
if ( drm_dp_pcon_hdmi_link_mode ( & intel_dp - > aux , & frl_trained_mask ) ! =
DP_PCON_HDMI_MODE_FRL ) {
drm_dbg ( & i915 - > drm , " HDMI couldn't be trained in FRL Mode \n " ) ;
return - EINVAL ;
}
drm_dbg ( & i915 - > drm , " MAX_FRL_MASK = %u, FRL_TRAINED_MASK = %u \n " , max_frl_bw_mask , frl_trained_mask ) ;
intel_dp - > frl . trained_rate_gbps = intel_dp_pcon_get_frl_mask ( frl_trained_mask ) ;
intel_dp - > frl . is_trained = true ;
drm_dbg ( & i915 - > drm , " FRL trained with : %d Gbps \n " , intel_dp - > frl . trained_rate_gbps ) ;
return 0 ;
}
static bool intel_dp_is_hdmi_2_1_sink ( struct intel_dp * intel_dp )
{
if ( drm_dp_is_branch ( intel_dp - > dpcd ) & &
intel_dp - > has_hdmi_sink & &
intel_dp_hdmi_sink_max_frl ( intel_dp ) > 0 )
return true ;
return false ;
}
void intel_dp_check_frl_training ( struct intel_dp * intel_dp )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
/* Always go for FRL training if supported */
if ( ! intel_dp_is_hdmi_2_1_sink ( intel_dp ) | |
intel_dp - > frl . is_trained )
return ;
if ( intel_dp_pcon_start_frl_training ( intel_dp ) < 0 ) {
int ret , mode ;
drm_dbg ( & dev_priv - > drm , " Couldnt set FRL mode, continuing with TMDS mode \n " ) ;
ret = drm_dp_pcon_reset_frl_config ( & intel_dp - > aux ) ;
mode = drm_dp_pcon_hdmi_link_mode ( & intel_dp - > aux , NULL ) ;
if ( ret < 0 | | mode ! = DP_PCON_HDMI_MODE_TMDS )
drm_dbg ( & dev_priv - > drm , " Issue with PCON, cannot set TMDS mode \n " ) ;
} else {
drm_dbg ( & dev_priv - > drm , " FRL training Completed \n " ) ;
}
}
2020-12-18 16:07:22 +05:30
static int
intel_dp_pcon_dsc_enc_slice_height ( const struct intel_crtc_state * crtc_state )
{
int vactive = crtc_state - > hw . adjusted_mode . vdisplay ;
return intel_hdmi_dsc_get_slice_height ( vactive ) ;
}
static int
intel_dp_pcon_dsc_enc_slices ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
{
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
struct drm_connector * connector = & intel_connector - > base ;
int hdmi_throughput = connector - > display_info . hdmi . dsc_cap . clk_per_slice ;
int hdmi_max_slices = connector - > display_info . hdmi . dsc_cap . max_slices ;
int pcon_max_slices = drm_dp_pcon_dsc_max_slices ( intel_dp - > pcon_dsc_dpcd ) ;
int pcon_max_slice_width = drm_dp_pcon_dsc_max_slice_width ( intel_dp - > pcon_dsc_dpcd ) ;
return intel_hdmi_dsc_get_num_slices ( crtc_state , pcon_max_slices ,
pcon_max_slice_width ,
hdmi_max_slices , hdmi_throughput ) ;
}
static int
intel_dp_pcon_dsc_enc_bpp ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state ,
int num_slices , int slice_width )
{
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
struct drm_connector * connector = & intel_connector - > base ;
int output_format = crtc_state - > output_format ;
bool hdmi_all_bpp = connector - > display_info . hdmi . dsc_cap . all_bpp ;
int pcon_fractional_bpp = drm_dp_pcon_dsc_bpp_incr ( intel_dp - > pcon_dsc_dpcd ) ;
int hdmi_max_chunk_bytes =
connector - > display_info . hdmi . dsc_cap . total_chunk_kbytes * 1024 ;
return intel_hdmi_dsc_get_bpp ( pcon_fractional_bpp , slice_width ,
num_slices , output_format , hdmi_all_bpp ,
hdmi_max_chunk_bytes ) ;
}
void
intel_dp_pcon_dsc_configure ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
{
u8 pps_param [ 6 ] ;
int slice_height ;
int slice_width ;
int num_slices ;
int bits_per_pixel ;
int ret ;
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
struct drm_connector * connector ;
bool hdmi_is_dsc_1_2 ;
if ( ! intel_dp_is_hdmi_2_1_sink ( intel_dp ) )
return ;
if ( ! intel_connector )
return ;
connector = & intel_connector - > base ;
hdmi_is_dsc_1_2 = connector - > display_info . hdmi . dsc_cap . v_1p2 ;
if ( ! drm_dp_pcon_enc_is_dsc_1_2 ( intel_dp - > pcon_dsc_dpcd ) | |
! hdmi_is_dsc_1_2 )
return ;
slice_height = intel_dp_pcon_dsc_enc_slice_height ( crtc_state ) ;
if ( ! slice_height )
return ;
num_slices = intel_dp_pcon_dsc_enc_slices ( intel_dp , crtc_state ) ;
if ( ! num_slices )
return ;
slice_width = DIV_ROUND_UP ( crtc_state - > hw . adjusted_mode . hdisplay ,
num_slices ) ;
bits_per_pixel = intel_dp_pcon_dsc_enc_bpp ( intel_dp , crtc_state ,
num_slices , slice_width ) ;
if ( ! bits_per_pixel )
return ;
pps_param [ 0 ] = slice_height & 0xFF ;
pps_param [ 1 ] = slice_height > > 8 ;
pps_param [ 2 ] = slice_width & 0xFF ;
pps_param [ 3 ] = slice_width > > 8 ;
pps_param [ 4 ] = bits_per_pixel & 0xFF ;
pps_param [ 5 ] = ( bits_per_pixel > > 8 ) & 0x3 ;
ret = drm_dp_pcon_pps_override_param ( & intel_dp - > aux , pps_param ) ;
if ( ret < 0 )
drm_dbg_kms ( & i915 - > drm , " Failed to set pcon DSC \n " ) ;
}
2020-04-20 23:06:07 +03:00
static void
g4x_set_link_train ( struct intel_dp * intel_dp ,
2020-10-01 14:10:53 +03:00
const struct intel_crtc_state * crtc_state ,
2020-04-20 23:06:07 +03:00
u8 dp_train_pat )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
u32 * DP = & intel_dp - > DP ;
2014-08-18 22:16:08 +03:00
2020-04-20 23:06:07 +03:00
* DP & = ~ DP_LINK_TRAIN_MASK ;
2014-08-18 22:16:08 +03:00
2020-10-07 20:09:12 +03:00
switch ( intel_dp_training_pattern_symbol ( dp_train_pat ) ) {
2020-04-20 23:06:07 +03:00
case DP_TRAINING_PATTERN_DISABLE :
* DP | = DP_LINK_TRAIN_OFF ;
break ;
case DP_TRAINING_PATTERN_1 :
* DP | = DP_LINK_TRAIN_PAT_1 ;
break ;
case DP_TRAINING_PATTERN_2 :
* DP | = DP_LINK_TRAIN_PAT_2 ;
break ;
case DP_TRAINING_PATTERN_3 :
drm_dbg_kms ( & dev_priv - > drm ,
" TPS3 not supported, using TPS2 instead \n " ) ;
* DP | = DP_LINK_TRAIN_PAT_2 ;
break ;
2014-08-18 22:16:08 +03:00
}
2020-04-20 23:06:07 +03:00
intel_de_write ( dev_priv , intel_dp - > output_reg , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
2014-08-18 22:16:08 +03:00
}
2016-08-09 17:04:13 +02:00
static void intel_dp_enable_port ( struct intel_dp * intel_dp ,
2020-09-30 02:34:40 +03:00
const struct intel_crtc_state * crtc_state )
2014-08-18 22:16:08 +03:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2014-08-18 22:16:08 +03:00
/* enable with pattern 1 (as per spec) */
2020-10-01 14:10:53 +03:00
intel_dp_program_link_training_pattern ( intel_dp , crtc_state ,
DP_TRAINING_PATTERN_1 ) ;
2014-10-16 21:27:35 +03:00
/*
* Magic for VLV / CHV . We _must_ first set up the register
* without actually enabling the port , and then do another
* write to enable the port . Otherwise link training will
* fail when the power sequencer is freshly used for this port .
*/
intel_dp - > DP | = DP_PORT_EN ;
2020-09-30 02:34:40 +03:00
if ( crtc_state - > has_audio )
2015-11-10 16:16:17 +02:00
intel_dp - > DP | = DP_AUDIO_OUTPUT_ENABLE ;
2014-10-16 21:27:35 +03:00
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , intel_dp - > output_reg , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
2014-04-09 13:29:00 +03:00
}
2020-12-18 16:07:23 +05:30
void intel_dp_configure_protocol_converter ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2020-09-04 14:53:48 +03:00
{
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
u8 tmp ;
if ( intel_dp - > dpcd [ DP_DPCD_REV ] < 0x13 )
return ;
if ( ! drm_dp_is_branch ( intel_dp - > dpcd ) )
return ;
tmp = intel_dp - > has_hdmi_sink ?
DP_HDMI_DVI_OUTPUT_CONFIG : 0 ;
if ( drm_dp_dpcd_writeb ( & intel_dp - > aux ,
2020-09-04 14:53:54 +03:00
DP_PROTOCOL_CONVERTER_CONTROL_0 , tmp ) ! = 1 )
2020-09-04 14:53:48 +03:00
drm_dbg_kms ( & i915 - > drm , " Failed to set protocol converter HDMI mode to %s \n " ,
enableddisabled ( intel_dp - > has_hdmi_sink ) ) ;
2020-09-04 14:53:54 +03:00
tmp = intel_dp - > dfp . ycbcr_444_to_420 ?
DP_CONVERSION_TO_YCBCR420_ENABLE : 0 ;
if ( drm_dp_dpcd_writeb ( & intel_dp - > aux ,
DP_PROTOCOL_CONVERTER_CONTROL_1 , tmp ) ! = 1 )
drm_dbg_kms ( & i915 - > drm ,
" Failed to set protocol converter YCbCr 4:2:0 conversion mode to %s \n " ,
enableddisabled ( intel_dp - > dfp . ycbcr_444_to_420 ) ) ;
tmp = 0 ;
2020-12-18 16:07:23 +05:30
if ( intel_dp - > dfp . rgb_to_ycbcr ) {
bool bt2020 , bt709 ;
2020-09-04 14:53:54 +03:00
2020-12-18 16:07:23 +05:30
/*
* FIXME : Currently if userspace selects BT2020 or BT709 , but PCON supports only
* RGB - > YCbCr for BT601 colorspace , we go ahead with BT601 , as default .
*
*/
tmp = DP_CONVERSION_BT601_RGB_YCBCR_ENABLE ;
bt2020 = drm_dp_downstream_rgb_to_ycbcr_conversion ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ,
DP_DS_HDMI_BT2020_RGB_YCBCR_CONV ) ;
bt709 = drm_dp_downstream_rgb_to_ycbcr_conversion ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ,
DP_DS_HDMI_BT709_RGB_YCBCR_CONV ) ;
switch ( crtc_state - > infoframes . vsc . colorimetry ) {
case DP_COLORIMETRY_BT2020_RGB :
case DP_COLORIMETRY_BT2020_YCC :
if ( bt2020 )
tmp = DP_CONVERSION_BT2020_RGB_YCBCR_ENABLE ;
break ;
case DP_COLORIMETRY_BT709_YCC :
case DP_COLORIMETRY_XVYCC_709 :
if ( bt709 )
tmp = DP_CONVERSION_BT709_RGB_YCBCR_ENABLE ;
break ;
default :
break ;
}
}
if ( drm_dp_pcon_convert_rgb_to_ycbcr ( & intel_dp - > aux , tmp ) < 0 )
2020-09-04 14:53:54 +03:00
drm_dbg_kms ( & i915 - > drm ,
2020-12-18 16:07:23 +05:30
" Failed to set protocol converter RGB->YCbCr conversion mode to %s \n " ,
enableddisabled ( tmp ? true : false ) ) ;
2020-09-04 14:53:48 +03:00
}
2020-03-13 18:48:30 +02:00
static void intel_enable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config ,
const struct drm_connector_state * conn_state )
2010-08-13 15:43:26 -07:00
{
2017-11-09 17:27:58 +02:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2019-10-31 12:26:03 +01:00
struct intel_crtc * crtc = to_intel_crtc ( pipe_config - > uapi . crtc ) ;
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
u32 dp_reg = intel_de_read ( dev_priv , intel_dp - > output_reg ) ;
2015-10-29 21:25:58 +02:00
enum pipe pipe = crtc - > pipe ;
2019-01-14 14:21:26 +00:00
intel_wakeref_t wakeref ;
2011-01-24 17:10:54 -08:00
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
if ( drm_WARN_ON ( & dev_priv - > drm , dp_reg & DP_PORT_EN ) )
2012-09-06 22:15:43 +02:00
return ;
2011-01-24 17:10:54 -08:00
2021-01-08 19:44:10 +02:00
with_intel_pps_lock ( intel_dp , wakeref ) {
2019-01-14 14:21:26 +00:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) )
vlv_init_panel_power_sequencer ( encoder , pipe_config ) ;
2014-10-16 21:27:33 +03:00
2019-01-14 14:21:26 +00:00
intel_dp_enable_port ( intel_dp , pipe_config ) ;
2014-10-16 21:27:33 +03:00
2021-01-08 19:44:13 +02:00
intel_pps_vdd_on_unlocked ( intel_dp ) ;
intel_pps_on_unlocked ( intel_dp ) ;
intel_pps_vdd_off_unlocked ( intel_dp , true ) ;
2019-01-14 14:21:26 +00:00
}
2014-10-16 21:27:33 +03:00
2016-10-14 10:13:44 +01:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) ) {
2015-07-08 23:45:54 +03:00
unsigned int lane_mask = 0x0 ;
2016-10-14 10:13:44 +01:00
if ( IS_CHERRYVIEW ( dev_priv ) )
2016-08-09 17:04:13 +02:00
lane_mask = intel_dp_unused_lane_mask ( pipe_config - > lane_count ) ;
2015-07-08 23:45:54 +03:00
2015-04-10 18:21:31 +03:00
vlv_wait_port_ready ( dev_priv , dp_to_dig_port ( intel_dp ) ,
lane_mask ) ;
2015-07-08 23:45:54 +03:00
}
2014-10-16 21:27:34 +03:00
2020-10-16 22:48:00 +03:00
intel_dp_set_power ( intel_dp , DP_SET_POWER_D0 ) ;
2020-12-18 16:07:23 +05:30
intel_dp_configure_protocol_converter ( intel_dp , pipe_config ) ;
2020-12-18 16:07:18 +05:30
intel_dp_check_frl_training ( intel_dp ) ;
2020-12-18 16:07:22 +05:30
intel_dp_pcon_dsc_configure ( intel_dp , pipe_config ) ;
2020-10-01 14:10:53 +03:00
intel_dp_start_link_train ( intel_dp , pipe_config ) ;
intel_dp_stop_link_train ( intel_dp , pipe_config ) ;
2014-10-27 16:26:56 +02:00
2016-08-09 17:04:13 +02:00
if ( pipe_config - > has_audio ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg ( & dev_priv - > drm , " Enabling DP audio on pipe %c \n " ,
pipe_name ( pipe ) ) ;
2016-11-08 13:55:38 +01:00
intel_audio_codec_enable ( encoder , pipe_config , conn_state ) ;
2014-10-27 16:26:56 +02:00
}
2013-07-30 12:20:30 +03:00
}
2013-04-18 14:51:36 -07:00
2020-03-13 18:48:30 +02:00
static void g4x_enable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config ,
const struct drm_connector_state * conn_state )
2013-09-06 07:38:29 +03:00
{
2020-03-13 18:48:30 +02:00
intel_enable_dp ( state , encoder , pipe_config , conn_state ) ;
2017-06-12 12:21:13 +02:00
intel_edp_backlight_on ( pipe_config , conn_state ) ;
2013-07-30 12:20:30 +03:00
}
2013-04-18 14:51:36 -07:00
2020-03-13 18:48:30 +02:00
static void vlv_enable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config ,
const struct drm_connector_state * conn_state )
2013-07-30 12:20:30 +03:00
{
2017-06-12 12:21:13 +02:00
intel_edp_backlight_on ( pipe_config , conn_state ) ;
2010-08-13 15:43:26 -07:00
}
2020-03-13 18:48:30 +02:00
static void g4x_pre_enable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config ,
const struct drm_connector_state * conn_state )
2013-07-30 12:20:30 +03:00
{
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2017-11-09 17:24:34 +02:00
enum port port = encoder - > port ;
2013-07-30 12:20:30 +03:00
2016-08-09 17:04:13 +02:00
intel_dp_prepare ( encoder , pipe_config ) ;
2014-04-24 23:54:54 +02:00
2014-04-24 23:54:53 +02:00
/* Only ilk+ has port A */
2015-10-29 21:26:03 +02:00
if ( port = = PORT_A )
2019-12-24 00:40:09 -08:00
ilk_edp_pll_on ( intel_dp , pipe_config ) ;
2013-07-30 12:20:30 +03:00
}
2020-03-13 18:48:30 +02:00
static void vlv_pre_enable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config ,
const struct drm_connector_state * conn_state )
2009-04-07 16:16:42 -07:00
{
2017-10-31 22:51:18 +02:00
vlv_phy_pre_encoder_enable ( encoder , pipe_config ) ;
2013-07-30 12:20:30 +03:00
2020-03-13 18:48:30 +02:00
intel_enable_dp ( state , encoder , pipe_config , conn_state ) ;
2013-04-18 14:51:36 -07:00
}
2020-03-13 18:48:30 +02:00
static void vlv_dp_pre_pll_enable ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config ,
const struct drm_connector_state * conn_state )
2013-04-18 14:51:36 -07:00
{
2016-08-09 17:04:13 +02:00
intel_dp_prepare ( encoder , pipe_config ) ;
2014-04-24 23:54:54 +02:00
2017-10-31 22:51:18 +02:00
vlv_phy_pre_pll_enable ( encoder , pipe_config ) ;
2009-04-07 16:16:42 -07:00
}
2020-03-13 18:48:30 +02:00
static void chv_pre_enable_dp ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config ,
const struct drm_connector_state * conn_state )
2014-04-09 13:28:20 +03:00
{
2017-10-31 22:51:18 +02:00
chv_phy_pre_encoder_enable ( encoder , pipe_config ) ;
2014-04-09 13:28:20 +03:00
2020-03-13 18:48:30 +02:00
intel_enable_dp ( state , encoder , pipe_config , conn_state ) ;
drm/i915: Trick CL2 into life on CHV when using pipe B with port B
Normmally the common lane in a PHY channel gets powered up when some
of the data lanes get powered up. But when we're driving port B with
pipe B we don't want to enabled any of the data lanes, and just want
the DPLL in the common lane to be active.
To make that happens we have to temporarily enable some data lanes
after which we can access the DPLL registers in the common lane. Once
the pipe is up and running we can drop the power override on the data
lanes allowing them to shut down. From this point forward the common
lane will in fact stay powered on until the data lanes in the other
channel get powered down.
Ville's extended explanation from the review thread:
On Wed, Aug 19, 2015 at 07:47:41AM +0530, Deepak wrote:
> One Q, why only for port B? Port C is also in same common lane right?
Port B is in the first PHY channel which also houses CL1. CL1 always
powers up whenever any lanes in either PHY channel are powered up.
CL2 only powers up if lanes in the second channel (ie. the one with
port C) powers up.
So in this scenario (pipe B->port B) we want the DPLL from CL2, but
ideally we only want to power up the lanes for port B. Powering up
port B lanes will only power up CL1, but as we need CL2 instead we
need to, temporarily, power up some lanes in port C as well.
Crossing the streams the other way (pipe A->port C) is not a problem
since CL1 powers up whenever anything else powers up. So powering up
some port C lanes is enough on its own to make the CL1 DPLL
operational, even though CL1 and the lanes live in separate channels.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Deepak S <deepak.s@linux.intel.com>
[danvet: Amend commit message with extended explanation.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-07-08 23:45:55 +03:00
/* Second common lane will stay alive on its own now */
2016-04-27 15:44:20 +03:00
chv_phy_release_cl2_override ( encoder ) ;
2014-04-09 13:28:20 +03:00
}
2020-03-13 18:48:30 +02:00
static void chv_dp_pre_pll_enable ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * pipe_config ,
const struct drm_connector_state * conn_state )
2014-04-09 13:29:05 +03:00
{
2016-08-09 17:04:13 +02:00
intel_dp_prepare ( encoder , pipe_config ) ;
2014-06-28 02:04:02 +03:00
2017-10-31 22:51:18 +02:00
chv_phy_pre_pll_enable ( encoder , pipe_config ) ;
2014-04-09 13:29:05 +03:00
}
2020-03-13 18:48:30 +02:00
static void chv_dp_post_pll_disable ( struct intel_atomic_state * state ,
struct intel_encoder * encoder ,
2017-10-31 22:51:18 +02:00
const struct intel_crtc_state * old_crtc_state ,
const struct drm_connector_state * old_conn_state )
2015-07-08 23:45:49 +03:00
{
2017-10-31 22:51:18 +02:00
chv_phy_post_pll_disable ( encoder , old_crtc_state ) ;
2015-07-08 23:45:49 +03:00
}
2020-10-01 14:10:53 +03:00
static u8 intel_dp_voltage_max_2 ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2009-04-07 16:16:42 -07:00
{
2020-05-12 20:41:42 +03:00
return DP_TRAIN_VOLTAGE_SWING_LEVEL_2 ;
}
2011-11-16 16:26:07 -08:00
2020-10-01 14:10:53 +03:00
static u8 intel_dp_voltage_max_3 ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2020-05-12 20:41:42 +03:00
{
return DP_TRAIN_VOLTAGE_SWING_LEVEL_3 ;
2011-11-16 16:26:07 -08:00
}
2020-09-30 02:34:39 +03:00
static u8 intel_dp_preemph_max_2 ( struct intel_dp * intel_dp )
2011-11-16 16:26:07 -08:00
{
2020-05-12 20:41:42 +03:00
return DP_TRAIN_PRE_EMPH_LEVEL_2 ;
}
2011-11-16 16:26:07 -08:00
2020-09-30 02:34:39 +03:00
static u8 intel_dp_preemph_max_3 ( struct intel_dp * intel_dp )
2020-05-12 20:41:42 +03:00
{
return DP_TRAIN_PRE_EMPH_LEVEL_3 ;
2009-04-07 16:16:42 -07:00
}
2020-10-01 14:10:53 +03:00
static void vlv_set_signal_levels ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2013-04-18 14:44:28 -07:00
{
2016-04-27 15:44:22 +03:00
struct intel_encoder * encoder = & dp_to_dig_port ( intel_dp ) - > base ;
2013-04-18 14:44:28 -07:00
unsigned long demph_reg_value , preemph_reg_value ,
uniqtranscale_reg_value ;
2019-01-16 11:15:27 +02:00
u8 train_set = intel_dp - > train_set [ 0 ] ;
2013-04-18 14:44:28 -07:00
switch ( train_set & DP_TRAIN_PRE_EMPHASIS_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_0 :
2013-04-18 14:44:28 -07:00
preemph_reg_value = 0x0004000 ;
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B405555 ;
uniqtranscale_reg_value = 0x552AB83A ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B404040 ;
uniqtranscale_reg_value = 0x5548B83A ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B245555 ;
uniqtranscale_reg_value = 0x5560B83A ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_3 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B405555 ;
uniqtranscale_reg_value = 0x5598DA3A ;
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2013-04-18 14:44:28 -07:00
}
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_1 :
2013-04-18 14:44:28 -07:00
preemph_reg_value = 0x0002000 ;
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B404040 ;
uniqtranscale_reg_value = 0x5552B83A ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B404848 ;
uniqtranscale_reg_value = 0x5580B83A ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B404040 ;
uniqtranscale_reg_value = 0x55ADDA3A ;
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2013-04-18 14:44:28 -07:00
}
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_2 :
2013-04-18 14:44:28 -07:00
preemph_reg_value = 0x0000000 ;
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B305555 ;
uniqtranscale_reg_value = 0x5570B83A ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x2B2B4040 ;
uniqtranscale_reg_value = 0x55ADDA3A ;
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2013-04-18 14:44:28 -07:00
}
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_3 :
2013-04-18 14:44:28 -07:00
preemph_reg_value = 0x0006000 ;
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2013-04-18 14:44:28 -07:00
demph_reg_value = 0x1B405555 ;
uniqtranscale_reg_value = 0x55ADDA3A ;
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2013-04-18 14:44:28 -07:00
}
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2013-04-18 14:44:28 -07:00
}
2020-10-01 14:10:53 +03:00
vlv_set_phy_signal_level ( encoder , crtc_state ,
demph_reg_value , preemph_reg_value ,
2016-04-27 15:44:22 +03:00
uniqtranscale_reg_value , 0 ) ;
2013-04-18 14:44:28 -07:00
}
2020-10-01 14:10:53 +03:00
static void chv_set_signal_levels ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2014-04-09 13:28:20 +03:00
{
2016-04-27 15:44:17 +03:00
struct intel_encoder * encoder = & dp_to_dig_port ( intel_dp ) - > base ;
u32 deemph_reg_value , margin_reg_value ;
bool uniq_trans_scale = false ;
2019-01-16 11:15:27 +02:00
u8 train_set = intel_dp - > train_set [ 0 ] ;
2014-04-09 13:28:20 +03:00
switch ( train_set & DP_TRAIN_PRE_EMPHASIS_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_0 :
2014-04-09 13:28:20 +03:00
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 128 ;
margin_reg_value = 52 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 128 ;
margin_reg_value = 77 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 128 ;
margin_reg_value = 102 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_3 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 128 ;
margin_reg_value = 154 ;
2016-04-27 15:44:17 +03:00
uniq_trans_scale = true ;
2014-04-09 13:28:20 +03:00
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2014-04-09 13:28:20 +03:00
}
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_1 :
2014-04-09 13:28:20 +03:00
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 85 ;
margin_reg_value = 78 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 85 ;
margin_reg_value = 116 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 85 ;
margin_reg_value = 154 ;
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2014-04-09 13:28:20 +03:00
}
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_2 :
2014-04-09 13:28:20 +03:00
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 64 ;
margin_reg_value = 104 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 64 ;
margin_reg_value = 154 ;
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2014-04-09 13:28:20 +03:00
}
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_3 :
2014-04-09 13:28:20 +03:00
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2014-04-09 13:28:20 +03:00
deemph_reg_value = 43 ;
margin_reg_value = 154 ;
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2014-04-09 13:28:20 +03:00
}
break ;
default :
2020-04-20 23:06:08 +03:00
return ;
2014-04-09 13:28:20 +03:00
}
2020-10-01 14:10:53 +03:00
chv_set_phy_signal_level ( encoder , crtc_state ,
deemph_reg_value , margin_reg_value ,
uniq_trans_scale ) ;
2014-04-09 13:28:20 +03:00
}
2020-04-20 23:06:08 +03:00
static u32 g4x_signal_levels ( u8 train_set )
2009-04-07 16:16:42 -07:00
{
2019-01-16 11:15:27 +02:00
u32 signal_levels = 0 ;
2009-04-07 16:16:42 -07:00
2010-11-29 10:09:55 +00:00
switch ( train_set & DP_TRAIN_VOLTAGE_SWING_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 :
2009-04-07 16:16:42 -07:00
default :
signal_levels | = DP_VOLTAGE_0_4 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 :
2009-04-07 16:16:42 -07:00
signal_levels | = DP_VOLTAGE_0_6 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 :
2009-04-07 16:16:42 -07:00
signal_levels | = DP_VOLTAGE_0_8 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_3 :
2009-04-07 16:16:42 -07:00
signal_levels | = DP_VOLTAGE_1_2 ;
break ;
}
2010-11-29 10:09:55 +00:00
switch ( train_set & DP_TRAIN_PRE_EMPHASIS_MASK ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_0 :
2009-04-07 16:16:42 -07:00
default :
signal_levels | = DP_PRE_EMPHASIS_0 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_1 :
2009-04-07 16:16:42 -07:00
signal_levels | = DP_PRE_EMPHASIS_3_5 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_2 :
2009-04-07 16:16:42 -07:00
signal_levels | = DP_PRE_EMPHASIS_6 ;
break ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_PRE_EMPH_LEVEL_3 :
2009-04-07 16:16:42 -07:00
signal_levels | = DP_PRE_EMPHASIS_9_5 ;
break ;
}
return signal_levels ;
}
2020-04-20 23:06:08 +03:00
static void
2020-10-01 14:10:53 +03:00
g4x_set_signal_levels ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2020-04-20 23:06:08 +03:00
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
u8 train_set = intel_dp - > train_set [ 0 ] ;
u32 signal_levels ;
signal_levels = g4x_signal_levels ( train_set ) ;
drm_dbg_kms ( & dev_priv - > drm , " Using signal levels %08x \n " ,
signal_levels ) ;
intel_dp - > DP & = ~ ( DP_VOLTAGE_MASK | DP_PRE_EMPHASIS_MASK ) ;
intel_dp - > DP | = signal_levels ;
intel_de_write ( dev_priv , intel_dp - > output_reg , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
}
2018-05-17 20:03:08 +03:00
/* SNB CPU eDP voltage swing and pre-emphasis control */
2020-04-20 23:06:08 +03:00
static u32 snb_cpu_edp_signal_levels ( u8 train_set )
2010-04-08 09:43:27 +08:00
{
2020-04-20 23:06:08 +03:00
u8 signal_levels = train_set & ( DP_TRAIN_VOLTAGE_SWING_MASK |
DP_TRAIN_PRE_EMPHASIS_MASK ) ;
2011-01-06 18:26:08 +08:00
switch ( signal_levels ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0 :
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0 :
2011-01-06 18:26:08 +08:00
return EDP_LINK_TRAIN_400_600MV_0DB_SNB_B ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1 :
2011-01-06 18:26:08 +08:00
return EDP_LINK_TRAIN_400MV_3_5DB_SNB_B ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2 :
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_2 :
2011-01-06 18:26:08 +08:00
return EDP_LINK_TRAIN_400_600MV_6DB_SNB_B ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1 :
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1 :
2011-01-06 18:26:08 +08:00
return EDP_LINK_TRAIN_600_800MV_3_5DB_SNB_B ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0 :
case DP_TRAIN_VOLTAGE_SWING_LEVEL_3 | DP_TRAIN_PRE_EMPH_LEVEL_0 :
2011-01-06 18:26:08 +08:00
return EDP_LINK_TRAIN_800_1200MV_0DB_SNB_B ;
2010-04-08 09:43:27 +08:00
default :
2011-01-06 18:26:08 +08:00
DRM_DEBUG_KMS ( " Unsupported voltage swing/pre-emphasis level: "
" 0x%x \n " , signal_levels ) ;
return EDP_LINK_TRAIN_400_600MV_0DB_SNB_B ;
2010-04-08 09:43:27 +08:00
}
}
2020-04-20 23:06:08 +03:00
static void
2020-10-01 14:10:53 +03:00
snb_cpu_edp_set_signal_levels ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2020-04-20 23:06:08 +03:00
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
u8 train_set = intel_dp - > train_set [ 0 ] ;
u32 signal_levels ;
signal_levels = snb_cpu_edp_signal_levels ( train_set ) ;
drm_dbg_kms ( & dev_priv - > drm , " Using signal levels %08x \n " ,
signal_levels ) ;
intel_dp - > DP & = ~ EDP_LINK_TRAIN_VOL_EMP_MASK_SNB ;
intel_dp - > DP | = signal_levels ;
intel_de_write ( dev_priv , intel_dp - > output_reg , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
}
2018-05-17 20:03:08 +03:00
/* IVB CPU eDP voltage swing and pre-emphasis control */
2020-04-20 23:06:08 +03:00
static u32 ivb_cpu_edp_signal_levels ( u8 train_set )
2011-11-16 16:26:07 -08:00
{
2020-04-20 23:06:08 +03:00
u8 signal_levels = train_set & ( DP_TRAIN_VOLTAGE_SWING_MASK |
DP_TRAIN_PRE_EMPHASIS_MASK ) ;
2011-11-16 16:26:07 -08:00
switch ( signal_levels ) {
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0 :
2011-11-16 16:26:07 -08:00
return EDP_LINK_TRAIN_400MV_0DB_IVB ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1 :
2011-11-16 16:26:07 -08:00
return EDP_LINK_TRAIN_400MV_3_5DB_IVB ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2 :
2020-05-12 20:41:41 +03:00
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_2 :
2011-11-16 16:26:07 -08:00
return EDP_LINK_TRAIN_400MV_6DB_IVB ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0 :
2011-11-16 16:26:07 -08:00
return EDP_LINK_TRAIN_600MV_0DB_IVB ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1 :
2011-11-16 16:26:07 -08:00
return EDP_LINK_TRAIN_600MV_3_5DB_IVB ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0 :
2011-11-16 16:26:07 -08:00
return EDP_LINK_TRAIN_800MV_0DB_IVB ;
2014-08-08 16:23:41 +05:30
case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1 :
2011-11-16 16:26:07 -08:00
return EDP_LINK_TRAIN_800MV_3_5DB_IVB ;
default :
DRM_DEBUG_KMS ( " Unsupported voltage swing/pre-emphasis level: "
" 0x%x \n " , signal_levels ) ;
return EDP_LINK_TRAIN_500MV_0DB_IVB ;
}
}
2020-04-20 23:06:08 +03:00
static void
2020-10-01 14:10:53 +03:00
ivb_cpu_edp_set_signal_levels ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2012-12-06 16:51:50 -02:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2019-01-16 11:15:27 +02:00
u8 train_set = intel_dp - > train_set [ 0 ] ;
2020-04-20 23:06:08 +03:00
u32 signal_levels ;
2012-12-06 16:51:50 -02:00
2020-04-20 23:06:08 +03:00
signal_levels = ivb_cpu_edp_signal_levels ( train_set ) ;
drm_dbg_kms ( & dev_priv - > drm , " Using signal levels %08x \n " ,
signal_levels ) ;
intel_dp - > DP & = ~ EDP_LINK_TRAIN_VOL_EMP_MASK_IVB ;
intel_dp - > DP | = signal_levels ;
2012-12-06 16:51:50 -02:00
2020-04-20 23:06:08 +03:00
intel_de_write ( dev_priv , intel_dp - > output_reg , intel_dp - > DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
}
2015-10-23 13:01:48 +03:00
void
2015-10-23 13:01:45 +03:00
intel_dp_program_link_training_pattern ( struct intel_dp * intel_dp ,
2020-10-01 14:10:53 +03:00
const struct intel_crtc_state * crtc_state ,
2019-01-16 11:15:27 +02:00
u8 dp_train_pat )
2009-04-07 16:16:42 -07:00
{
2020-04-20 23:06:07 +03:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2009-04-07 16:16:42 -07:00
2020-10-07 20:09:12 +03:00
if ( ( intel_dp_training_pattern_symbol ( dp_train_pat ) ) ! =
DP_TRAINING_PATTERN_DISABLE )
2020-04-20 23:06:07 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" Using DP training pattern TPS%d \n " ,
2020-10-07 20:09:12 +03:00
intel_dp_training_pattern_symbol ( dp_train_pat ) ) ;
2015-10-23 13:01:45 +03:00
2020-10-01 14:10:53 +03:00
intel_dp - > set_link_train ( intel_dp , crtc_state , dp_train_pat ) ;
2013-05-03 12:57:41 +03:00
}
2009-04-07 16:16:42 -07:00
static void
2017-10-31 22:51:14 +02:00
intel_dp_link_down ( struct intel_encoder * encoder ,
const struct intel_crtc_state * old_crtc_state )
2009-04-07 16:16:42 -07:00
{
2017-10-31 22:51:14 +02:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2019-10-31 12:26:03 +01:00
struct intel_crtc * crtc = to_intel_crtc ( old_crtc_state - > uapi . crtc ) ;
2017-10-31 22:51:14 +02:00
enum port port = encoder - > port ;
2019-01-16 11:15:27 +02:00
u32 DP = intel_dp - > DP ;
2009-04-07 16:16:42 -07:00
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
if ( drm_WARN_ON ( & dev_priv - > drm ,
( intel_de_read ( dev_priv , intel_dp - > output_reg ) &
DP_PORT_EN ) = = 0 ) )
2010-12-06 11:20:45 +00:00
return ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " \n " ) ;
2009-07-24 01:00:32 +08:00
2018-05-17 20:03:07 +03:00
if ( ( IS_IVYBRIDGE ( dev_priv ) & & port = = PORT_A ) | |
2016-10-13 11:02:53 +01:00
( HAS_PCH_CPT ( dev_priv ) & & port ! = PORT_A ) ) {
2010-04-08 09:43:27 +08:00
DP & = ~ DP_LINK_TRAIN_MASK_CPT ;
2015-05-05 17:17:34 +03:00
DP | = DP_LINK_TRAIN_PAT_IDLE_CPT ;
2010-04-08 09:43:27 +08:00
} else {
2018-03-02 11:56:56 +02:00
DP & = ~ DP_LINK_TRAIN_MASK ;
2015-05-05 17:17:34 +03:00
DP | = DP_LINK_TRAIN_PAT_IDLE ;
2010-04-08 09:43:27 +08:00
}
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , intel_dp - > output_reg , DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
2009-07-24 01:00:31 +08:00
2015-05-05 17:17:34 +03:00
DP & = ~ ( DP_PORT_EN | DP_AUDIO_OUTPUT_ENABLE ) ;
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , intel_dp - > output_reg , DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
2015-05-05 17:17:34 +03:00
/*
* HW workaround for IBX , we need to move the port
* to transcoder A after disabling it to allow the
* matching HDMI port to be enabled on transcoder A .
*/
2016-10-13 11:02:53 +01:00
if ( HAS_PCH_IBX ( dev_priv ) & & crtc - > pipe = = PIPE_B & & port ! = PORT_A ) {
2015-10-30 19:23:22 +02:00
/*
* We get CPU / PCH FIFO underruns on the other pipe when
* doing the workaround . Sweep them under the rug .
*/
intel_set_cpu_fifo_underrun_reporting ( dev_priv , PIPE_A , false ) ;
intel_set_pch_fifo_underrun_reporting ( dev_priv , PIPE_A , false ) ;
2015-05-05 17:17:34 +03:00
/* always enable with pattern 1 (as per spec) */
2018-05-18 18:29:28 +03:00
DP & = ~ ( DP_PIPE_SEL_MASK | DP_LINK_TRAIN_MASK ) ;
DP | = DP_PORT_EN | DP_PIPE_SEL ( PIPE_A ) |
DP_LINK_TRAIN_PAT_1 ;
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , intel_dp - > output_reg , DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
2015-05-05 17:17:34 +03:00
DP & = ~ DP_PORT_EN ;
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , intel_dp - > output_reg , DP ) ;
intel_de_posting_read ( dev_priv , intel_dp - > output_reg ) ;
2015-10-30 19:23:22 +02:00
2016-10-31 22:37:06 +02:00
intel_wait_for_vblank_if_active ( dev_priv , PIPE_A ) ;
2015-10-30 19:23:22 +02:00
intel_set_cpu_fifo_underrun_reporting ( dev_priv , PIPE_A , true ) ;
intel_set_pch_fifo_underrun_reporting ( dev_priv , PIPE_A , true ) ;
2010-11-18 09:32:59 +08:00
}
drm/i915: Correct eDP panel power sequencing delay computations
Store the panel power sequencing delays in the dp private structure,
rather than the global device structure. Who knows, maybe we'll get
more than one eDP device in the future.
From the eDP spec, we need the following numbers:
T1 + T3 Power on to Aux Channel operation (panel_power_up_delay)
This marks how long it takes the panel to boot up and
get ready to receive aux channel communications.
T8 Video signal to backlight on (backlight_on_delay)
Once a valid video signal is being sent to the device,
it can take a while before the panel is actuall
showing useful data. This delay allows the panel
to get something reasonable up before the backlight
is turned on.
T9 Backlight off to video off (backlight_off_delay)
Turning the backlight off can take a moment, so
this delay makes sure there is still valid video
data on the screen.
T10 Video off to power off (panel_power_down_delay)
Presumably this delay allows the panel to perform
an orderly shutdown of the display.
T11 + T12 Power off to power on (panel_power_cycle_delay)
So, once you turn the panel off, you have to wait a
while before you can turn it back on. This delay is
usually the longest in the entire sequence.
Neither the VBIOS source code nor the hardware documentation has a
clear mapping between the delay values they provide and those required
by the eDP spec. The VBIOS code actually uses two different labels for
the delay values in the five words of the relevant VBT table.
**** MORE LATER ***
Look at both the current hardware register settings and the VBT
specified panel power sequencing timings. Use the maximum of the two
delays, to make sure things work reliably. If there is no VBT data,
then those values will be initialized to zero, so we'll just use the
values as programmed in the hardware. Note that the BIOS just fetches
delays from the VBT table to place in the hardware registers, so we
should get the same values from both places, except for rounding.
VBT doesn't provide any values for T1 or T2, so we'll always just use
the hardware value for that.
The panel power up delay is thus T1 + T2 + T3, which should be
sufficient in all cases.
The panel power down delay is T1 + T2 + T12, using T1+T2 as a proxy
for T11, which isn't available anywhere.
For the backlight delays, the eDP spec says T6 + T8 is the delay from the
end of link training to backlight on and T9 is the delay from
backlight off until video off. The hardware provides a 'backlight on'
delay, which I'm taking to be T6 + T8 while the VBT provides something
called 'T7', which I'm assuming is s
On the macbook air I'm testing with, this yields a power-up delay of
over 200ms and a power-down delay of over 600ms. It all works now, but
we're frobbing these power controls several times during mode setting,
making the whole process take an awfully long time.
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-09-28 16:48:10 -07:00
msleep ( intel_dp - > panel_power_down_delay ) ;
2015-11-10 16:16:17 +02:00
intel_dp - > DP = DP ;
2016-12-14 20:00:23 +02:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) ) {
2019-01-14 14:21:26 +00:00
intel_wakeref_t wakeref ;
2021-01-08 19:44:10 +02:00
with_intel_pps_lock ( intel_dp , wakeref )
2019-01-14 14:21:26 +00:00
intel_dp - > active_pipe = INVALID_PIPE ;
2016-12-14 20:00:23 +02:00
}
2009-04-07 16:16:42 -07:00
}
2019-05-21 15:17:16 +03:00
bool intel_dp_get_colorimetry_status ( struct intel_dp * intel_dp )
{
u8 dprx = 0 ;
if ( drm_dp_dpcd_readb ( & intel_dp - > aux , DP_DPRX_FEATURE_ENUMERATION_LIST ,
& dprx ) ! = 1 )
return false ;
return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED ;
}
2018-10-30 17:19:19 -07:00
static void intel_dp_get_dsc_sink_cap ( struct intel_dp * intel_dp )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2018-10-30 17:19:19 -07:00
/*
* Clear the cached register set to avoid using stale values
* for the sinks that do not support DSC .
*/
memset ( intel_dp - > dsc_dpcd , 0 , sizeof ( intel_dp - > dsc_dpcd ) ) ;
2018-11-01 21:14:54 -07:00
/* Clear fec_capable to avoid using stale values */
intel_dp - > fec_capable = 0 ;
2018-10-30 17:19:19 -07:00
/* Cache the DSC DPCD if eDP or DP rev >= 1.4 */
if ( intel_dp - > dpcd [ DP_DPCD_REV ] > = 0x14 | |
intel_dp - > edp_dpcd [ 0 ] > = DP_EDP_14 ) {
if ( drm_dp_dpcd_read ( & intel_dp - > aux , DP_DSC_SUPPORT ,
intel_dp - > dsc_dpcd ,
sizeof ( intel_dp - > dsc_dpcd ) ) < 0 )
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_err ( & i915 - > drm ,
" Failed to read DPCD register 0x%x \n " ,
DP_DSC_SUPPORT ) ;
2018-10-30 17:19:19 -07:00
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " DSC DPCD: %*ph \n " ,
( int ) sizeof ( intel_dp - > dsc_dpcd ) ,
intel_dp - > dsc_dpcd ) ;
2018-11-20 20:24:39 +00:00
2018-11-01 21:14:54 -07:00
/* FEC is supported only on DP 1.4 */
2018-11-20 20:24:39 +00:00
if ( ! intel_dp_is_edp ( intel_dp ) & &
drm_dp_dpcd_readb ( & intel_dp - > aux , DP_FEC_CAPABILITY ,
& intel_dp - > fec_capable ) < 0 )
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_err ( & i915 - > drm ,
" Failed to read FEC DPCD register \n " ) ;
2018-11-01 21:14:54 -07:00
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " FEC CAPABILITY: %x \n " ,
intel_dp - > fec_capable ) ;
2018-10-30 17:19:19 -07:00
}
}
2016-07-29 16:52:39 +03:00
static bool
intel_edp_init_dpcd ( struct intel_dp * intel_dp )
{
struct drm_i915_private * dev_priv =
to_i915 ( dp_to_dig_port ( intel_dp ) - > base . base . dev ) ;
2016-03-30 18:05:25 +05:30
2016-07-29 16:52:39 +03:00
/* this function is meant to be called only once */
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
drm_WARN_ON ( & dev_priv - > drm , intel_dp - > dpcd [ DP_DPCD_REV ] ! = 0 ) ;
2016-03-30 18:05:25 +05:30
2020-08-26 14:24:55 -04:00
if ( drm_dp_read_dpcd_caps ( & intel_dp - > aux , intel_dp - > dpcd ) ! = 0 )
2016-03-30 18:05:25 +05:30
return false ;
2017-05-18 14:10:23 +03:00
drm_dp_read_desc ( & intel_dp - > aux , & intel_dp - > desc ,
drm_dp_is_branch ( intel_dp - > dpcd ) ) ;
2016-10-24 19:33:29 +03:00
2017-10-26 17:29:31 +03:00
/*
* Read the eDP display control registers .
*
* Do this independent of DP_DPCD_DISPLAY_CONTROL_CAPABLE bit in
* DP_EDP_CONFIGURATION_CAP , because some buggy displays do not have it
* set , but require eDP 1.4 + detection ( e . g . for supported link rates
* method ) . The display control registers should read zero if they ' re
* not supported anyway .
*/
if ( drm_dp_dpcd_read ( & intel_dp - > aux , DP_EDP_DPCD_REV ,
2016-10-13 11:55:08 +03:00
intel_dp - > edp_dpcd , sizeof ( intel_dp - > edp_dpcd ) ) = =
sizeof ( intel_dp - > edp_dpcd ) )
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " eDP DPCD: %*ph \n " ,
( int ) sizeof ( intel_dp - > edp_dpcd ) ,
intel_dp - > edp_dpcd ) ;
2014-01-20 10:19:39 -07:00
2018-05-11 12:51:41 -07:00
/*
* This has to be called after intel_dp - > edp_dpcd is filled , PSR checks
* for SET_POWER_CAPABLE bit in intel_dp - > edp_dpcd [ 1 ]
*/
intel_psr_init_dpcd ( intel_dp ) ;
2017-10-26 17:29:32 +03:00
/* Read the eDP 1.4+ supported link rates. */
if ( intel_dp - > edp_dpcd [ 0 ] > = DP_EDP_14 ) {
2015-03-13 19:40:31 +02:00
__le16 sink_rates [ DP_MAX_SUPPORTED_RATES ] ;
2015-03-12 17:10:28 +02:00
int i ;
2016-04-13 10:58:33 -04:00
drm_dp_dpcd_read ( & intel_dp - > aux , DP_SUPPORTED_LINK_RATES ,
sink_rates , sizeof ( sink_rates ) ) ;
2015-03-12 17:10:28 +02:00
2015-03-13 19:40:31 +02:00
for ( i = 0 ; i < ARRAY_SIZE ( sink_rates ) ; i + + ) {
int val = le16_to_cpu ( sink_rates [ i ] ) ;
2015-03-12 17:10:28 +02:00
if ( val = = 0 )
break ;
drm/i915: Fix DP link rate math
We store DP link rates as link clock frequencies in kHz, just like all
other clock values. But, DP link rates in the DP Spec. are expressed in
Gbps/lane, which seems to have led to some confusion.
E.g., for HBR2
Max. data rate = 5.4 Gbps/lane x 4 lane x 8/10 x 1/8 = 2160000 kBps
where, 8/10 is for channel encoding and 1/8 is for bit to Byte conversion
Using link clock frequency, like we do
Max. data rate = 540000 kHz * 4 lanes = 2160000 kSymbols/s
Because, each symbol has 8 bit of data, this is 2160000 kBps
and there is no need to account for channel encoding here.
But, currently we do 540000 kHz * 4 lanes * (8/10) = 1728000 kBps
Similarly, while computing the required link bandwidth for a mode,
there is a mysterious 1/10 term.
This should simply be pixel_clock kHz * (bpp/8) to give the final result in
kBps
v2: Changed to DIV_ROUND_UP() and comment changes (Ville)
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1479160220-17794-1-git-send-email-dhinakaran.pandiyan@intel.com
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2016-11-14 13:50:20 -08:00
/* Value read multiplied by 200kHz gives the per-lane
* link rate in kHz . The source rates are , however ,
* stored in terms of LS_Clk kHz . The full conversion
* back to symbols is
* ( val * 200 kHz ) * ( 8 / 10 ch . encoding ) * ( 1 / 8 bit to Byte )
*/
2015-05-07 13:59:28 +05:30
intel_dp - > sink_rates [ i ] = ( val * 200 ) / 10 ;
2015-03-12 17:10:28 +02:00
}
2015-03-13 19:40:31 +02:00
intel_dp - > num_sink_rates = i ;
2015-03-05 10:03:58 +05:30
}
2015-03-12 17:10:39 +02:00
2017-10-26 17:29:32 +03:00
/*
* Use DP_LINK_RATE_SET if DP_SUPPORTED_LINK_RATES are available ,
* default to DP_MAX_LINK_RATE and DP_LINK_BW_SET otherwise .
*/
2017-03-28 17:59:05 +03:00
if ( intel_dp - > num_sink_rates )
intel_dp - > use_rate_select = true ;
else
intel_dp_set_sink_rates ( intel_dp ) ;
2017-04-06 16:44:10 +03:00
intel_dp_set_common_rates ( intel_dp ) ;
2018-10-30 17:19:19 -07:00
/* Read the eDP DSC DPCD registers */
if ( INTEL_GEN ( dev_priv ) > = 10 | | IS_GEMINILAKE ( dev_priv ) )
intel_dp_get_dsc_sink_cap ( intel_dp ) ;
2020-12-04 17:35:55 -05:00
/*
* If needed , program our source OUI so we can make various Intel - specific AUX services
* available ( such as HDR backlight controls )
*/
intel_edp_init_source_oui ( intel_dp , true ) ;
2016-07-29 16:52:39 +03:00
return true ;
}
2020-08-26 14:24:51 -04:00
static bool
intel_dp_has_sink_count ( struct intel_dp * intel_dp )
{
if ( ! intel_dp - > attached_connector )
return false ;
return drm_dp_read_sink_count_cap ( & intel_dp - > attached_connector - > base ,
intel_dp - > dpcd ,
& intel_dp - > desc ) ;
}
2016-07-29 16:52:39 +03:00
static bool
intel_dp_get_dpcd ( struct intel_dp * intel_dp )
{
2020-08-26 14:24:52 -04:00
int ret ;
2020-10-07 20:09:16 +03:00
intel_dp_lttpr_init ( intel_dp ) ;
2020-08-26 14:24:55 -04:00
if ( drm_dp_read_dpcd_caps ( & intel_dp - > aux , intel_dp - > dpcd ) )
2016-07-29 16:52:39 +03:00
return false ;
2019-05-28 17:06:50 +03:00
/*
* Don ' t clobber cached eDP rates . Also skip re - reading
* the OUI / ID since we know it won ' t change .
*/
2017-08-18 12:30:20 +03:00
if ( ! intel_dp_is_edp ( intel_dp ) ) {
2019-05-28 17:06:50 +03:00
drm_dp_read_desc ( & intel_dp - > aux , & intel_dp - > desc ,
drm_dp_is_branch ( intel_dp - > dpcd ) ) ;
2017-03-28 17:59:05 +03:00
intel_dp_set_sink_rates ( intel_dp ) ;
2017-04-06 16:44:10 +03:00
intel_dp_set_common_rates ( intel_dp ) ;
}
2017-03-28 17:59:05 +03:00
2020-08-26 14:24:51 -04:00
if ( intel_dp_has_sink_count ( intel_dp ) ) {
2020-08-26 14:24:52 -04:00
ret = drm_dp_read_sink_count ( & intel_dp - > aux ) ;
if ( ret < 0 )
2018-11-21 14:54:36 -08:00
return false ;
/*
* Sink count can change between short pulse hpd hence
* a member variable in intel_dp will track any changes
* between short pulse interrupts .
*/
2020-08-26 14:24:52 -04:00
intel_dp - > sink_count = ret ;
2018-11-21 14:54:36 -08:00
/*
* SINK_COUNT = = 0 and DOWNSTREAM_PORT_PRESENT = = 1 implies that
* a dongle is present but no display . Unless we require to know
* if a dongle is present or not , we don ' t need to update
* downstream port information . So , an early return here saves
* time from performing other operations which are not required .
*/
if ( ! intel_dp - > sink_count )
return false ;
}
2015-03-12 17:10:39 +02:00
2020-08-26 14:24:49 -04:00
return drm_dp_read_downstream_info ( & intel_dp - > aux , intel_dp - > dpcd ,
intel_dp - > downstream_ports ) = = 0 ;
2016-07-29 16:51:16 +03:00
}
2018-10-03 21:42:10 +03:00
static bool
intel_dp_can_mst ( struct intel_dp * intel_dp )
{
2020-06-18 18:04:02 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
return i915 - > params . enable_dp_mst & &
2018-10-03 21:42:10 +03:00
intel_dp - > can_mst & &
2020-08-26 14:24:45 -04:00
drm_dp_read_mst_cap ( & intel_dp - > aux , intel_dp - > dpcd ) ;
2018-10-03 21:42:10 +03:00
}
2016-07-29 16:51:16 +03:00
static void
intel_dp_configure_mst ( struct intel_dp * intel_dp )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2018-10-03 21:42:10 +03:00
struct intel_encoder * encoder =
& dp_to_dig_port ( intel_dp ) - > base ;
2020-08-26 14:24:45 -04:00
bool sink_can_mst = drm_dp_read_mst_cap ( & intel_dp - > aux , intel_dp - > dpcd ) ;
2018-10-03 21:42:10 +03:00
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" [ENCODER:%d:%s] MST support: port: %s, sink: %s, modparam: %s \n " ,
encoder - > base . base . id , encoder - > base . name ,
yesno ( intel_dp - > can_mst ) , yesno ( sink_can_mst ) ,
2020-06-18 18:04:02 +03:00
yesno ( i915 - > params . enable_dp_mst ) ) ;
2016-07-29 16:51:16 +03:00
if ( ! intel_dp - > can_mst )
return ;
2018-10-03 21:42:10 +03:00
intel_dp - > is_mst = sink_can_mst & &
2020-06-18 18:04:02 +03:00
i915 - > params . enable_dp_mst ;
2016-07-29 16:51:16 +03:00
drm_dp_mst_topology_mgr_set_mst ( & intel_dp - > mst_mgr ,
intel_dp - > is_mst ) ;
2014-05-02 14:02:48 +10:00
}
static bool
intel_dp_get_sink_irq_esi ( struct intel_dp * intel_dp , u8 * sink_irq_vector )
{
2017-09-18 15:21:39 -07:00
return drm_dp_dpcd_read ( & intel_dp - > aux , DP_SINK_COUNT_ESI ,
sink_irq_vector , DP_DPRX_ESI_LEN ) = =
DP_DPRX_ESI_LEN ;
2014-05-02 14:02:48 +10:00
}
2019-09-19 22:53:05 +03:00
bool
intel_dp_needs_vsc_sdp ( const struct intel_crtc_state * crtc_state ,
const struct drm_connector_state * conn_state )
{
/*
* As per DP 1.4 a spec section 2.2 .4 .3 [ MSA Field for Indication
* of Color Encoding Format and Content Color Gamut ] , in order to
* sending YCBCR 420 or HDR BT .2020 signals we should use DP VSC SDP .
*/
if ( crtc_state - > output_format = = INTEL_OUTPUT_FORMAT_YCBCR420 )
return true ;
switch ( conn_state - > colorspace ) {
case DRM_MODE_COLORIMETRY_SYCC_601 :
case DRM_MODE_COLORIMETRY_OPYCC_601 :
case DRM_MODE_COLORIMETRY_BT2020_YCC :
case DRM_MODE_COLORIMETRY_BT2020_RGB :
case DRM_MODE_COLORIMETRY_BT2020_CYCC :
return true ;
default :
break ;
}
return false ;
}
2020-02-11 09:46:43 +02:00
static ssize_t intel_dp_vsc_sdp_pack ( const struct drm_dp_vsc_sdp * vsc ,
struct dp_sdp * sdp , size_t size )
{
size_t length = sizeof ( struct dp_sdp ) ;
if ( size < length )
return - ENOSPC ;
memset ( sdp , 0 , size ) ;
/*
* Prepare VSC Header for SU as per DP 1.4 a spec , Table 2 - 119
* VSC SDP Header Bytes
*/
sdp - > sdp_header . HB0 = 0 ; /* Secondary-Data Packet ID = 0 */
sdp - > sdp_header . HB1 = vsc - > sdp_type ; /* Secondary-data Packet Type */
sdp - > sdp_header . HB2 = vsc - > revision ; /* Revision Number */
sdp - > sdp_header . HB3 = vsc - > length ; /* Number of Valid Data Bytes */
2020-05-14 09:07:31 +03:00
/*
* Only revision 0x5 supports Pixel Encoding / Colorimetry Format as
* per DP 1.4 a spec .
*/
if ( vsc - > revision ! = 0x5 )
goto out ;
2020-02-11 09:46:43 +02:00
/* VSC SDP Payload for DB16 through DB18 */
/* Pixel Encoding and Colorimetry Formats */
sdp - > db [ 16 ] = ( vsc - > pixelformat & 0xf ) < < 4 ; /* DB16[7:4] */
sdp - > db [ 16 ] | = vsc - > colorimetry & 0xf ; /* DB16[3:0] */
switch ( vsc - > bpc ) {
case 6 :
/* 6bpc: 0x0 */
break ;
case 8 :
sdp - > db [ 17 ] = 0x1 ; /* DB17[3:0] */
break ;
case 10 :
sdp - > db [ 17 ] = 0x2 ;
break ;
case 12 :
sdp - > db [ 17 ] = 0x3 ;
break ;
case 16 :
sdp - > db [ 17 ] = 0x4 ;
break ;
default :
MISSING_CASE ( vsc - > bpc ) ;
break ;
}
/* Dynamic Range and Component Bit Depth */
if ( vsc - > dynamic_range = = DP_DYNAMIC_RANGE_CTA )
sdp - > db [ 17 ] | = 0x80 ; /* DB17[7] */
/* Content Type */
sdp - > db [ 18 ] = vsc - > content_type & 0x7 ;
2020-05-14 09:07:31 +03:00
out :
2020-02-11 09:46:43 +02:00
return length ;
}
static ssize_t
intel_dp_hdr_metadata_infoframe_sdp_pack ( const struct hdmi_drm_infoframe * drm_infoframe ,
struct dp_sdp * sdp ,
size_t size )
{
size_t length = sizeof ( struct dp_sdp ) ;
const int infoframe_size = HDMI_INFOFRAME_HEADER_SIZE + HDMI_DRM_INFOFRAME_SIZE ;
unsigned char buf [ HDMI_INFOFRAME_HEADER_SIZE + HDMI_DRM_INFOFRAME_SIZE ] ;
ssize_t len ;
if ( size < length )
return - ENOSPC ;
memset ( sdp , 0 , size ) ;
len = hdmi_drm_infoframe_pack_only ( drm_infoframe , buf , sizeof ( buf ) ) ;
if ( len < 0 ) {
DRM_DEBUG_KMS ( " buffer size is smaller than hdr metadata infoframe \n " ) ;
return - ENOSPC ;
}
if ( len ! = infoframe_size ) {
DRM_DEBUG_KMS ( " wrong static hdr metadata size \n " ) ;
return - ENOSPC ;
}
/*
* Set up the infoframe sdp packet for HDR static metadata .
* Prepare VSC Header for SU as per DP 1.4 a spec ,
* Table 2 - 100 and Table 2 - 101
*/
/* Secondary-Data Packet ID, 00h for non-Audio INFOFRAME */
sdp - > sdp_header . HB0 = 0 ;
/*
* Packet Type 80 h + Non - audio INFOFRAME Type value
* HDMI_INFOFRAME_TYPE_DRM : 0x87
* - 80 h + Non - audio INFOFRAME Type value
* - InfoFrame Type : 0x07
* [ CTA - 861 - G Table - 42 Dynamic Range and Mastering InfoFrame ]
*/
sdp - > sdp_header . HB1 = drm_infoframe - > type ;
/*
* Least Significant Eight Bits of ( Data Byte Count – 1 )
* infoframe_size - 1
*/
sdp - > sdp_header . HB2 = 0x1D ;
/* INFOFRAME SDP Version Number */
sdp - > sdp_header . HB3 = ( 0x13 < < 2 ) ;
/* CTA Header Byte 2 (INFOFRAME Version Number) */
sdp - > db [ 0 ] = drm_infoframe - > version ;
/* CTA Header Byte 3 (Length of INFOFRAME): HDMI_DRM_INFOFRAME_SIZE */
sdp - > db [ 1 ] = drm_infoframe - > length ;
/*
* Copy HDMI_DRM_INFOFRAME_SIZE size from a buffer after
* HDMI_INFOFRAME_HEADER_SIZE
*/
BUILD_BUG_ON ( sizeof ( sdp - > db ) < HDMI_DRM_INFOFRAME_SIZE + 2 ) ;
memcpy ( & sdp - > db [ 2 ] , & buf [ HDMI_INFOFRAME_HEADER_SIZE ] ,
HDMI_DRM_INFOFRAME_SIZE ) ;
/*
* Size of DP infoframe sdp packet for HDR static metadata consists of
* - DP SDP Header ( struct dp_sdp_header ) : 4 bytes
* - Two Data Blocks : 2 bytes
* CTA Header Byte2 ( INFOFRAME Version Number )
* CTA Header Byte3 ( Length of INFOFRAME )
* - HDMI_DRM_INFOFRAME_SIZE : 26 bytes
*
* Prior to GEN11 ' s GMP register size is identical to DP HDR static metadata
* infoframe size . But GEN11 + has larger than that size , write_infoframe
* will pad rest of the size .
*/
return sizeof ( struct dp_sdp_header ) + 2 + HDMI_DRM_INFOFRAME_SIZE ;
}
static void intel_write_dp_sdp ( struct intel_encoder * encoder ,
const struct intel_crtc_state * crtc_state ,
unsigned int type )
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = enc_to_dig_port ( encoder ) ;
2020-02-11 09:46:43 +02:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
struct dp_sdp sdp = { } ;
ssize_t len ;
if ( ( crtc_state - > infoframes . enable &
intel_hdmi_infoframe_enable ( type ) ) = = 0 )
return ;
switch ( type ) {
case DP_SDP_VSC :
len = intel_dp_vsc_sdp_pack ( & crtc_state - > infoframes . vsc , & sdp ,
sizeof ( sdp ) ) ;
break ;
case HDMI_PACKET_TYPE_GAMUT_METADATA :
len = intel_dp_hdr_metadata_infoframe_sdp_pack ( & crtc_state - > infoframes . drm . drm ,
& sdp , sizeof ( sdp ) ) ;
break ;
default :
MISSING_CASE ( type ) ;
2020-03-25 14:07:54 +00:00
return ;
2020-02-11 09:46:43 +02:00
}
if ( drm_WARN_ON ( & dev_priv - > drm , len < 0 ) )
return ;
2020-06-30 21:50:54 -07:00
dig_port - > write_infoframe ( encoder , crtc_state , type , & sdp , len ) ;
2020-02-11 09:46:43 +02:00
}
2020-05-14 09:07:31 +03:00
void intel_write_dp_vsc_sdp ( struct intel_encoder * encoder ,
const struct intel_crtc_state * crtc_state ,
struct drm_dp_vsc_sdp * vsc )
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = enc_to_dig_port ( encoder ) ;
2020-05-14 09:07:31 +03:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
struct dp_sdp sdp = { } ;
ssize_t len ;
len = intel_dp_vsc_sdp_pack ( vsc , & sdp , sizeof ( sdp ) ) ;
if ( drm_WARN_ON ( & dev_priv - > drm , len < 0 ) )
return ;
2020-06-30 21:50:54 -07:00
dig_port - > write_infoframe ( encoder , crtc_state , DP_SDP_VSC ,
2020-05-14 09:07:31 +03:00
& sdp , len ) ;
}
2020-02-11 09:46:43 +02:00
void intel_dp_set_infoframes ( struct intel_encoder * encoder ,
bool enable ,
const struct intel_crtc_state * crtc_state ,
const struct drm_connector_state * conn_state )
{
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
i915_reg_t reg = HSW_TVIDEO_DIP_CTL ( crtc_state - > cpu_transcoder ) ;
u32 dip_enable = VIDEO_DIP_ENABLE_AVI_HSW | VIDEO_DIP_ENABLE_GCP_HSW |
VIDEO_DIP_ENABLE_VS_HSW | VIDEO_DIP_ENABLE_GMP_HSW |
VIDEO_DIP_ENABLE_SPD_HSW | VIDEO_DIP_ENABLE_DRM_GLK ;
u32 val = intel_de_read ( dev_priv , reg ) ;
/* TODO: Add DSC case (DIP_ENABLE_PPS) */
/* When PSR is enabled, this routine doesn't disable VSC DIP */
if ( intel_psr_enabled ( intel_dp ) )
val & = ~ dip_enable ;
else
val & = ~ ( dip_enable | VIDEO_DIP_ENABLE_VSC_HSW ) ;
if ( ! enable ) {
intel_de_write ( dev_priv , reg , val ) ;
intel_de_posting_read ( dev_priv , reg ) ;
return ;
}
intel_de_write ( dev_priv , reg , val ) ;
intel_de_posting_read ( dev_priv , reg ) ;
/* When PSR is enabled, VSC SDP is handled by PSR routine */
if ( ! intel_psr_enabled ( intel_dp ) )
intel_write_dp_sdp ( encoder , crtc_state , DP_SDP_VSC ) ;
intel_write_dp_sdp ( encoder , crtc_state , HDMI_PACKET_TYPE_GAMUT_METADATA ) ;
}
2020-05-14 09:07:20 +03:00
static int intel_dp_vsc_sdp_unpack ( struct drm_dp_vsc_sdp * vsc ,
const void * buffer , size_t size )
{
const struct dp_sdp * sdp = buffer ;
if ( size < sizeof ( struct dp_sdp ) )
return - EINVAL ;
memset ( vsc , 0 , size ) ;
if ( sdp - > sdp_header . HB0 ! = 0 )
return - EINVAL ;
if ( sdp - > sdp_header . HB1 ! = DP_SDP_VSC )
return - EINVAL ;
vsc - > sdp_type = sdp - > sdp_header . HB1 ;
vsc - > revision = sdp - > sdp_header . HB2 ;
vsc - > length = sdp - > sdp_header . HB3 ;
if ( ( sdp - > sdp_header . HB2 = = 0x2 & & sdp - > sdp_header . HB3 = = 0x8 ) | |
( sdp - > sdp_header . HB2 = = 0x4 & & sdp - > sdp_header . HB3 = = 0xe ) ) {
/*
* - HB2 = 0x2 , HB3 = 0x8
* VSC SDP supporting 3 D stereo + PSR
* - HB2 = 0x4 , HB3 = 0xe
* VSC SDP supporting 3 D stereo + PSR2 with Y - coordinate of
* first scan line of the SU region ( applies to eDP v1 .4 b
* and higher ) .
*/
return 0 ;
} else if ( sdp - > sdp_header . HB2 = = 0x5 & & sdp - > sdp_header . HB3 = = 0x13 ) {
/*
* - HB2 = 0x5 , HB3 = 0x13
* VSC SDP supporting 3 D stereo + PSR2 + Pixel Encoding / Colorimetry
* Format .
*/
vsc - > pixelformat = ( sdp - > db [ 16 ] > > 4 ) & 0xf ;
vsc - > colorimetry = sdp - > db [ 16 ] & 0xf ;
vsc - > dynamic_range = ( sdp - > db [ 17 ] > > 7 ) & 0x1 ;
switch ( sdp - > db [ 17 ] & 0x7 ) {
case 0x0 :
vsc - > bpc = 6 ;
break ;
case 0x1 :
vsc - > bpc = 8 ;
break ;
case 0x2 :
vsc - > bpc = 10 ;
break ;
case 0x3 :
vsc - > bpc = 12 ;
break ;
case 0x4 :
vsc - > bpc = 16 ;
break ;
default :
MISSING_CASE ( sdp - > db [ 17 ] & 0x7 ) ;
return - EINVAL ;
}
vsc - > content_type = sdp - > db [ 18 ] & 0x7 ;
} else {
return - EINVAL ;
}
return 0 ;
}
static int
intel_dp_hdr_metadata_infoframe_sdp_unpack ( struct hdmi_drm_infoframe * drm_infoframe ,
const void * buffer , size_t size )
{
int ret ;
const struct dp_sdp * sdp = buffer ;
if ( size < sizeof ( struct dp_sdp ) )
return - EINVAL ;
if ( sdp - > sdp_header . HB0 ! = 0 )
return - EINVAL ;
if ( sdp - > sdp_header . HB1 ! = HDMI_INFOFRAME_TYPE_DRM )
return - EINVAL ;
/*
* Least Significant Eight Bits of ( Data Byte Count – 1 )
* 1 Dh ( i . e . , Data Byte Count = 30 bytes ) .
*/
if ( sdp - > sdp_header . HB2 ! = 0x1D )
return - EINVAL ;
/* Most Significant Two Bits of (Data Byte Count – 1), Clear to 00b. */
if ( ( sdp - > sdp_header . HB3 & 0x3 ) ! = 0 )
return - EINVAL ;
/* INFOFRAME SDP Version Number */
if ( ( ( sdp - > sdp_header . HB3 > > 2 ) & 0x3f ) ! = 0x13 )
return - EINVAL ;
/* CTA Header Byte 2 (INFOFRAME Version Number) */
if ( sdp - > db [ 0 ] ! = 1 )
return - EINVAL ;
/* CTA Header Byte 3 (Length of INFOFRAME): HDMI_DRM_INFOFRAME_SIZE */
if ( sdp - > db [ 1 ] ! = HDMI_DRM_INFOFRAME_SIZE )
return - EINVAL ;
ret = hdmi_drm_infoframe_unpack_only ( drm_infoframe , & sdp - > db [ 2 ] ,
HDMI_DRM_INFOFRAME_SIZE ) ;
return ret ;
}
static void intel_read_dp_vsc_sdp ( struct intel_encoder * encoder ,
struct intel_crtc_state * crtc_state ,
struct drm_dp_vsc_sdp * vsc )
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = enc_to_dig_port ( encoder ) ;
2020-05-14 09:07:20 +03:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
unsigned int type = DP_SDP_VSC ;
struct dp_sdp sdp = { } ;
int ret ;
/* When PSR is enabled, VSC SDP is handled by PSR routine */
if ( intel_psr_enabled ( intel_dp ) )
return ;
if ( ( crtc_state - > infoframes . enable &
intel_hdmi_infoframe_enable ( type ) ) = = 0 )
return ;
2020-06-30 21:50:54 -07:00
dig_port - > read_infoframe ( encoder , crtc_state , type , & sdp , sizeof ( sdp ) ) ;
2020-05-14 09:07:20 +03:00
ret = intel_dp_vsc_sdp_unpack ( vsc , & sdp , sizeof ( sdp ) ) ;
if ( ret )
drm_dbg_kms ( & dev_priv - > drm , " Failed to unpack DP VSC SDP \n " ) ;
}
static void intel_read_dp_hdr_metadata_infoframe_sdp ( struct intel_encoder * encoder ,
struct intel_crtc_state * crtc_state ,
struct hdmi_drm_infoframe * drm_infoframe )
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = enc_to_dig_port ( encoder ) ;
2020-05-14 09:07:20 +03:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
unsigned int type = HDMI_PACKET_TYPE_GAMUT_METADATA ;
struct dp_sdp sdp = { } ;
int ret ;
if ( ( crtc_state - > infoframes . enable &
intel_hdmi_infoframe_enable ( type ) ) = = 0 )
return ;
2020-06-30 21:50:54 -07:00
dig_port - > read_infoframe ( encoder , crtc_state , type , & sdp ,
sizeof ( sdp ) ) ;
2020-05-14 09:07:20 +03:00
ret = intel_dp_hdr_metadata_infoframe_sdp_unpack ( drm_infoframe , & sdp ,
sizeof ( sdp ) ) ;
if ( ret )
drm_dbg_kms ( & dev_priv - > drm ,
" Failed to unpack DP HDR Metadata Infoframe SDP \n " ) ;
}
void intel_read_dp_sdp ( struct intel_encoder * encoder ,
struct intel_crtc_state * crtc_state ,
unsigned int type )
{
2020-05-25 13:49:12 +01:00
if ( encoder - > type ! = INTEL_OUTPUT_DDI )
return ;
2020-05-14 09:07:20 +03:00
switch ( type ) {
case DP_SDP_VSC :
intel_read_dp_vsc_sdp ( encoder , crtc_state ,
& crtc_state - > infoframes . vsc ) ;
break ;
case HDMI_PACKET_TYPE_GAMUT_METADATA :
intel_read_dp_hdr_metadata_infoframe_sdp ( encoder , crtc_state ,
& crtc_state - > infoframes . drm . drm ) ;
break ;
default :
MISSING_CASE ( type ) ;
break ;
}
}
2019-01-16 11:15:27 +02:00
static u8 intel_dp_autotest_link_training ( struct intel_dp * intel_dp )
2015-04-15 08:38:38 -07:00
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2017-01-24 08:16:34 -08:00
int status = 0 ;
2017-06-08 13:41:03 -07:00
int test_link_rate ;
2019-01-16 11:15:27 +02:00
u8 test_lane_count , test_link_bw ;
2017-01-24 08:16:34 -08:00
/* (DP CTS 1.2)
* 4.3 .1 .11
*/
/* Read the TEST_LANE_COUNT and TEST_LINK_RTAE fields (DP CTS 3.1.4) */
status = drm_dp_dpcd_readb ( & intel_dp - > aux , DP_TEST_LANE_COUNT ,
& test_lane_count ) ;
if ( status < = 0 ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Lane count read failed \n " ) ;
2017-01-24 08:16:34 -08:00
return DP_TEST_NAK ;
}
test_lane_count & = DP_MAX_LANE_COUNT_MASK ;
status = drm_dp_dpcd_readb ( & intel_dp - > aux , DP_TEST_LINK_RATE ,
& test_link_bw ) ;
if ( status < = 0 ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Link Rate read failed \n " ) ;
2017-01-24 08:16:34 -08:00
return DP_TEST_NAK ;
}
test_link_rate = drm_dp_bw_code_to_link_rate ( test_link_bw ) ;
2017-06-08 13:41:03 -07:00
/* Validate the requested link rate and lane count */
if ( ! intel_dp_link_params_valid ( intel_dp , test_link_rate ,
test_lane_count ) )
2017-01-24 08:16:34 -08:00
return DP_TEST_NAK ;
intel_dp - > compliance . test_lane_count = test_lane_count ;
intel_dp - > compliance . test_link_rate = test_link_rate ;
return DP_TEST_ACK ;
2015-04-15 08:38:38 -07:00
}
2019-01-16 11:15:27 +02:00
static u8 intel_dp_autotest_video_pattern ( struct intel_dp * intel_dp )
2015-04-15 08:38:38 -07:00
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2019-01-16 11:15:27 +02:00
u8 test_pattern ;
u8 test_misc ;
2017-01-24 08:21:49 -08:00
__be16 h_width , v_height ;
int status = 0 ;
/* Read the TEST_PATTERN (DP CTS 3.1.5) */
2017-04-06 16:44:16 +03:00
status = drm_dp_dpcd_readb ( & intel_dp - > aux , DP_TEST_PATTERN ,
& test_pattern ) ;
2017-01-24 08:21:49 -08:00
if ( status < = 0 ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Test pattern read failed \n " ) ;
2017-01-24 08:21:49 -08:00
return DP_TEST_NAK ;
}
if ( test_pattern ! = DP_COLOR_RAMP )
return DP_TEST_NAK ;
status = drm_dp_dpcd_read ( & intel_dp - > aux , DP_TEST_H_WIDTH_HI ,
& h_width , 2 ) ;
if ( status < = 0 ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " H Width read failed \n " ) ;
2017-01-24 08:21:49 -08:00
return DP_TEST_NAK ;
}
status = drm_dp_dpcd_read ( & intel_dp - > aux , DP_TEST_V_HEIGHT_HI ,
& v_height , 2 ) ;
if ( status < = 0 ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " V Height read failed \n " ) ;
2017-01-24 08:21:49 -08:00
return DP_TEST_NAK ;
}
2017-04-06 16:44:16 +03:00
status = drm_dp_dpcd_readb ( & intel_dp - > aux , DP_TEST_MISC0 ,
& test_misc ) ;
2017-01-24 08:21:49 -08:00
if ( status < = 0 ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " TEST MISC read failed \n " ) ;
2017-01-24 08:21:49 -08:00
return DP_TEST_NAK ;
}
if ( ( test_misc & DP_TEST_COLOR_FORMAT_MASK ) ! = DP_COLOR_FORMAT_RGB )
return DP_TEST_NAK ;
if ( test_misc & DP_TEST_DYNAMIC_RANGE_CEA )
return DP_TEST_NAK ;
switch ( test_misc & DP_TEST_BIT_DEPTH_MASK ) {
case DP_TEST_BIT_DEPTH_6 :
intel_dp - > compliance . test_data . bpc = 6 ;
break ;
case DP_TEST_BIT_DEPTH_8 :
intel_dp - > compliance . test_data . bpc = 8 ;
break ;
default :
return DP_TEST_NAK ;
}
intel_dp - > compliance . test_data . video_pattern = test_pattern ;
intel_dp - > compliance . test_data . hdisplay = be16_to_cpu ( h_width ) ;
intel_dp - > compliance . test_data . vdisplay = be16_to_cpu ( v_height ) ;
/* Set test active flag here so userspace doesn't interrupt things */
2020-01-03 09:12:38 +08:00
intel_dp - > compliance . test_active = true ;
2017-01-24 08:21:49 -08:00
return DP_TEST_ACK ;
2015-04-15 08:38:38 -07:00
}
2019-01-16 11:15:27 +02:00
static u8 intel_dp_autotest_edid ( struct intel_dp * intel_dp )
2011-10-20 15:09:17 -07:00
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2019-01-16 11:15:27 +02:00
u8 test_result = DP_TEST_ACK ;
2015-05-04 07:48:20 -07:00
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
struct drm_connector * connector = & intel_connector - > base ;
if ( intel_connector - > detect_edid = = NULL | |
2015-05-08 16:15:41 +02:00
connector - > edid_corrupt | |
2015-05-04 07:48:20 -07:00
intel_dp - > aux . i2c_defer_count > 6 ) {
/* Check EDID read for NACKs, DEFERs and corruption
* ( DP CTS 1.2 Core r1 .1 )
* 4.2 .2 .4 : Failed EDID read , I2C_NAK
* 4.2 .2 .5 : Failed EDID read , I2C_DEFER
* 4.2 .2 .6 : EDID corruption detected
* Use failsafe mode for all cases
*/
if ( intel_dp - > aux . i2c_nack_count > 0 | |
intel_dp - > aux . i2c_defer_count > 0 )
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" EDID read had %d NACKs, %d DEFERs \n " ,
intel_dp - > aux . i2c_nack_count ,
intel_dp - > aux . i2c_defer_count ) ;
2016-12-09 16:22:50 -08:00
intel_dp - > compliance . test_data . edid = INTEL_DP_RESOLUTION_FAILSAFE ;
2015-05-04 07:48:20 -07:00
} else {
2015-08-07 15:14:30 +05:30
struct edid * block = intel_connector - > detect_edid ;
/* We have to write the checksum
* of the last block read
*/
block + = intel_connector - > detect_edid - > extensions ;
2017-04-06 16:44:16 +03:00
if ( drm_dp_dpcd_writeb ( & intel_dp - > aux , DP_TEST_EDID_CHECKSUM ,
block - > checksum ) < = 0 )
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" Failed to write EDID checksum \n " ) ;
2015-05-04 07:48:20 -07:00
test_result = DP_TEST_ACK | DP_TEST_EDID_CHECKSUM_WRITE ;
2017-01-20 19:09:28 -08:00
intel_dp - > compliance . test_data . edid = INTEL_DP_RESOLUTION_PREFERRED ;
2015-05-04 07:48:20 -07:00
}
/* Set test active flag here so userspace doesn't interrupt things */
2020-01-03 09:12:38 +08:00
intel_dp - > compliance . test_active = true ;
2015-05-04 07:48:20 -07:00
2015-04-15 08:38:38 -07:00
return test_result ;
}
2020-10-01 14:10:53 +03:00
static void intel_dp_phy_pattern_update ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2020-03-16 16:07:59 +05:30
{
struct drm_i915_private * dev_priv =
to_i915 ( dp_to_dig_port ( intel_dp ) - > base . base . dev ) ;
struct drm_dp_phy_test_params * data =
& intel_dp - > compliance . test_data . phytest ;
2020-10-01 14:10:53 +03:00
struct intel_crtc * crtc = to_intel_crtc ( crtc_state - > uapi . crtc ) ;
2020-03-16 16:07:59 +05:30
enum pipe pipe = crtc - > pipe ;
u32 pattern_val ;
switch ( data - > phy_pattern ) {
case DP_PHY_TEST_PATTERN_NONE :
DRM_DEBUG_KMS ( " Disable Phy Test Pattern \n " ) ;
intel_de_write ( dev_priv , DDI_DP_COMP_CTL ( pipe ) , 0x0 ) ;
break ;
case DP_PHY_TEST_PATTERN_D10_2 :
DRM_DEBUG_KMS ( " Set D10.2 Phy Test Pattern \n " ) ;
intel_de_write ( dev_priv , DDI_DP_COMP_CTL ( pipe ) ,
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_D10_2 ) ;
break ;
case DP_PHY_TEST_PATTERN_ERROR_COUNT :
DRM_DEBUG_KMS ( " Set Error Count Phy Test Pattern \n " ) ;
intel_de_write ( dev_priv , DDI_DP_COMP_CTL ( pipe ) ,
DDI_DP_COMP_CTL_ENABLE |
DDI_DP_COMP_CTL_SCRAMBLED_0 ) ;
break ;
case DP_PHY_TEST_PATTERN_PRBS7 :
DRM_DEBUG_KMS ( " Set PRBS7 Phy Test Pattern \n " ) ;
intel_de_write ( dev_priv , DDI_DP_COMP_CTL ( pipe ) ,
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_PRBS7 ) ;
break ;
case DP_PHY_TEST_PATTERN_80BIT_CUSTOM :
/*
* FIXME : Ideally pattern should come from DPCD 0x250 . As
* current firmware of DPR - 100 could not set it , so hardcoding
* now for complaince test .
*/
DRM_DEBUG_KMS ( " Set 80Bit Custom Phy Test Pattern 0x3e0f83e0 0x0f83e0f8 0x0000f83e \n " ) ;
pattern_val = 0x3e0f83e0 ;
intel_de_write ( dev_priv , DDI_DP_COMP_PAT ( pipe , 0 ) , pattern_val ) ;
pattern_val = 0x0f83e0f8 ;
intel_de_write ( dev_priv , DDI_DP_COMP_PAT ( pipe , 1 ) , pattern_val ) ;
pattern_val = 0x0000f83e ;
intel_de_write ( dev_priv , DDI_DP_COMP_PAT ( pipe , 2 ) , pattern_val ) ;
intel_de_write ( dev_priv , DDI_DP_COMP_CTL ( pipe ) ,
DDI_DP_COMP_CTL_ENABLE |
DDI_DP_COMP_CTL_CUSTOM80 ) ;
break ;
case DP_PHY_TEST_PATTERN_CP2520 :
/*
* FIXME : Ideally pattern should come from DPCD 0x24A . As
* current firmware of DPR - 100 could not set it , so hardcoding
* now for complaince test .
*/
DRM_DEBUG_KMS ( " Set HBR2 compliance Phy Test Pattern \n " ) ;
pattern_val = 0xFB ;
intel_de_write ( dev_priv , DDI_DP_COMP_CTL ( pipe ) ,
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_HBR2 |
pattern_val ) ;
break ;
default :
WARN ( 1 , " Invalid Phy Test Pattern \n " ) ;
}
}
static void
2020-10-01 14:10:53 +03:00
intel_dp_autotest_phy_ddi_disable ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2020-03-16 16:07:59 +05:30
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct drm_device * dev = dig_port - > base . base . dev ;
2020-03-16 16:07:59 +05:30
struct drm_i915_private * dev_priv = to_i915 ( dev ) ;
2020-06-30 21:50:54 -07:00
struct intel_crtc * crtc = to_intel_crtc ( dig_port - > base . base . crtc ) ;
2020-03-16 16:07:59 +05:30
enum pipe pipe = crtc - > pipe ;
u32 trans_ddi_func_ctl_value , trans_conf_value , dp_tp_ctl_value ;
trans_ddi_func_ctl_value = intel_de_read ( dev_priv ,
TRANS_DDI_FUNC_CTL ( pipe ) ) ;
trans_conf_value = intel_de_read ( dev_priv , PIPECONF ( pipe ) ) ;
dp_tp_ctl_value = intel_de_read ( dev_priv , TGL_DP_TP_CTL ( pipe ) ) ;
trans_ddi_func_ctl_value & = ~ ( TRANS_DDI_FUNC_ENABLE |
TGL_TRANS_DDI_PORT_MASK ) ;
trans_conf_value & = ~ PIPECONF_ENABLE ;
dp_tp_ctl_value & = ~ DP_TP_CTL_ENABLE ;
intel_de_write ( dev_priv , PIPECONF ( pipe ) , trans_conf_value ) ;
intel_de_write ( dev_priv , TRANS_DDI_FUNC_CTL ( pipe ) ,
trans_ddi_func_ctl_value ) ;
intel_de_write ( dev_priv , TGL_DP_TP_CTL ( pipe ) , dp_tp_ctl_value ) ;
}
static void
2020-10-01 14:10:53 +03:00
intel_dp_autotest_phy_ddi_enable ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2020-03-16 16:07:59 +05:30
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct drm_device * dev = dig_port - > base . base . dev ;
2020-03-16 16:07:59 +05:30
struct drm_i915_private * dev_priv = to_i915 ( dev ) ;
2020-06-30 21:50:54 -07:00
enum port port = dig_port - > base . port ;
struct intel_crtc * crtc = to_intel_crtc ( dig_port - > base . base . crtc ) ;
2020-03-16 16:07:59 +05:30
enum pipe pipe = crtc - > pipe ;
u32 trans_ddi_func_ctl_value , trans_conf_value , dp_tp_ctl_value ;
trans_ddi_func_ctl_value = intel_de_read ( dev_priv ,
TRANS_DDI_FUNC_CTL ( pipe ) ) ;
trans_conf_value = intel_de_read ( dev_priv , PIPECONF ( pipe ) ) ;
dp_tp_ctl_value = intel_de_read ( dev_priv , TGL_DP_TP_CTL ( pipe ) ) ;
trans_ddi_func_ctl_value | = TRANS_DDI_FUNC_ENABLE |
TGL_TRANS_DDI_SELECT_PORT ( port ) ;
trans_conf_value | = PIPECONF_ENABLE ;
dp_tp_ctl_value | = DP_TP_CTL_ENABLE ;
intel_de_write ( dev_priv , PIPECONF ( pipe ) , trans_conf_value ) ;
intel_de_write ( dev_priv , TGL_DP_TP_CTL ( pipe ) , dp_tp_ctl_value ) ;
intel_de_write ( dev_priv , TRANS_DDI_FUNC_CTL ( pipe ) ,
trans_ddi_func_ctl_value ) ;
}
2020-10-01 14:10:53 +03:00
static void intel_dp_process_phy_request ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
2020-03-16 16:07:59 +05:30
{
struct drm_dp_phy_test_params * data =
& intel_dp - > compliance . test_data . phytest ;
u8 link_status [ DP_LINK_STATUS_SIZE ] ;
2020-10-07 20:09:17 +03:00
if ( drm_dp_dpcd_read_phy_link_status ( & intel_dp - > aux , DP_PHY_DPRX ,
link_status ) < 0 ) {
2020-03-16 16:07:59 +05:30
DRM_DEBUG_KMS ( " failed to get link status \n " ) ;
return ;
}
/* retrieve vswing & pre-emphasis setting */
2020-10-07 20:09:17 +03:00
intel_dp_get_adjust_train ( intel_dp , crtc_state , DP_PHY_DPRX ,
link_status ) ;
2020-03-16 16:07:59 +05:30
2020-10-01 14:10:53 +03:00
intel_dp_autotest_phy_ddi_disable ( intel_dp , crtc_state ) ;
2020-03-16 16:07:59 +05:30
2020-12-29 19:22:01 +02:00
intel_dp_set_signal_levels ( intel_dp , crtc_state , DP_PHY_DPRX ) ;
2020-03-16 16:07:59 +05:30
2020-10-01 14:10:53 +03:00
intel_dp_phy_pattern_update ( intel_dp , crtc_state ) ;
2020-03-16 16:07:59 +05:30
2020-10-01 14:10:53 +03:00
intel_dp_autotest_phy_ddi_enable ( intel_dp , crtc_state ) ;
2020-03-16 16:07:59 +05:30
drm_dp_set_phy_test_pattern ( & intel_dp - > aux , data ,
link_status [ DP_DPCD_REV ] ) ;
}
2019-01-16 11:15:27 +02:00
static u8 intel_dp_autotest_phy_pattern ( struct intel_dp * intel_dp )
2011-10-20 15:09:17 -07:00
{
2020-09-30 13:04:12 +03:00
struct drm_dp_phy_test_params * data =
& intel_dp - > compliance . test_data . phytest ;
2020-03-16 16:07:56 +05:30
2020-09-30 13:04:12 +03:00
if ( drm_dp_get_phy_test_pattern ( & intel_dp - > aux , data ) ) {
DRM_DEBUG_KMS ( " DP Phy Test pattern AUX read failure \n " ) ;
return DP_TEST_NAK ;
}
2020-03-16 16:07:56 +05:30
2020-09-30 13:04:12 +03:00
/* Set test active flag here so userspace doesn't interrupt things */
intel_dp - > compliance . test_active = true ;
2020-03-16 16:07:59 +05:30
2020-09-30 13:04:12 +03:00
return DP_TEST_ACK ;
2015-04-15 08:38:38 -07:00
}
static void intel_dp_handle_test_request ( struct intel_dp * intel_dp )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2019-01-16 11:15:27 +02:00
u8 response = DP_TEST_NAK ;
u8 request = 0 ;
2017-01-20 19:04:06 +02:00
int status ;
2015-04-15 08:38:38 -07:00
2017-01-20 19:04:06 +02:00
status = drm_dp_dpcd_readb ( & intel_dp - > aux , DP_TEST_REQUEST , & request ) ;
2015-04-15 08:38:38 -07:00
if ( status < = 0 ) {
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" Could not read test request from sink \n " ) ;
2015-04-15 08:38:38 -07:00
goto update_status ;
}
2017-01-20 19:04:06 +02:00
switch ( request ) {
2015-04-15 08:38:38 -07:00
case DP_TEST_LINK_TRAINING :
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " LINK_TRAINING test requested \n " ) ;
2015-04-15 08:38:38 -07:00
response = intel_dp_autotest_link_training ( intel_dp ) ;
break ;
case DP_TEST_LINK_VIDEO_PATTERN :
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " TEST_PATTERN test requested \n " ) ;
2015-04-15 08:38:38 -07:00
response = intel_dp_autotest_video_pattern ( intel_dp ) ;
break ;
case DP_TEST_LINK_EDID_READ :
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " EDID test requested \n " ) ;
2015-04-15 08:38:38 -07:00
response = intel_dp_autotest_edid ( intel_dp ) ;
break ;
case DP_TEST_LINK_PHY_TEST_PATTERN :
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " PHY_PATTERN test requested \n " ) ;
2015-04-15 08:38:38 -07:00
response = intel_dp_autotest_phy_pattern ( intel_dp ) ;
break ;
default :
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Invalid test request '%02x' \n " ,
request ) ;
2015-04-15 08:38:38 -07:00
break ;
}
2017-01-20 19:04:06 +02:00
if ( response & DP_TEST_ACK )
intel_dp - > compliance . test_type = request ;
2015-04-15 08:38:38 -07:00
update_status :
2017-01-20 19:04:06 +02:00
status = drm_dp_dpcd_writeb ( & intel_dp - > aux , DP_TEST_RESPONSE , response ) ;
2015-04-15 08:38:38 -07:00
if ( status < = 0 )
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" Could not write test response to sink \n " ) ;
2011-10-20 15:09:17 -07:00
}
2021-01-11 13:41:04 +05:30
static void
intel_dp_mst_hpd_irq ( struct intel_dp * intel_dp , u8 * esi , bool * handled )
{
drm_dp_mst_hpd_irq ( & intel_dp - > mst_mgr , esi , handled ) ;
if ( esi [ 1 ] & DP_CP_IRQ ) {
intel_hdcp_handle_cp_irq ( intel_dp - > attached_connector ) ;
* handled = true ;
}
}
2020-06-05 12:48:01 +03:00
/**
* intel_dp_check_mst_status - service any pending MST interrupts , check link status
* @ intel_dp : Intel DP struct
*
* Read any pending MST interrupts , call MST core to handle these and ack the
* interrupts . Check if the main and AUX link state is ok .
*
* Returns :
* - % true if pending interrupts were serviced ( or no interrupts were
* pending ) w / o detecting an error condition .
* - % false if an error condition - like AUX failure or a loss of link - is
* detected , which needs servicing from the hotplug work .
*/
static bool
2014-05-02 14:02:48 +10:00
intel_dp_check_mst_status ( struct intel_dp * intel_dp )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2020-06-05 12:48:01 +03:00
bool link_ok = true ;
2020-04-17 18:27:33 +03:00
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
drm_WARN_ON_ONCE ( & i915 - > drm , intel_dp - > active_mst_links < 0 ) ;
2020-04-17 18:27:33 +03:00
for ( ; ; ) {
u8 esi [ DP_DPRX_ESI_LEN ] = { } ;
2020-06-05 12:48:01 +03:00
bool handled ;
2014-05-02 14:02:48 +10:00
int retry ;
2018-07-18 10:19:42 -07:00
2020-06-05 12:48:01 +03:00
if ( ! intel_dp_get_sink_irq_esi ( intel_dp , esi ) ) {
2020-04-17 18:27:33 +03:00
drm_dbg_kms ( & i915 - > drm ,
" failed to get ESI - device may have failed \n " ) ;
2020-06-05 12:48:01 +03:00
link_ok = false ;
break ;
2020-04-17 18:27:33 +03:00
}
2014-05-02 14:02:48 +10:00
2020-04-17 18:27:33 +03:00
/* check link status - esi[10] = 0x200c */
2020-06-05 12:48:01 +03:00
if ( intel_dp - > active_mst_links > 0 & & link_ok & &
2020-04-17 18:27:33 +03:00
! drm_dp_channel_eq_ok ( & esi [ 10 ] , intel_dp - > lane_count ) ) {
drm_dbg_kms ( & i915 - > drm ,
" channel EQ not ok, retraining \n " ) ;
2020-06-05 12:48:01 +03:00
link_ok = false ;
2020-04-17 18:27:33 +03:00
}
2014-05-02 14:02:48 +10:00
2020-04-17 18:27:33 +03:00
drm_dbg_kms ( & i915 - > drm , " got esi %3ph \n " , esi ) ;
2014-05-02 14:02:48 +10:00
2021-01-11 13:41:04 +05:30
intel_dp_mst_hpd_irq ( intel_dp , esi , & handled ) ;
2020-04-17 18:27:33 +03:00
if ( ! handled )
break ;
for ( retry = 0 ; retry < 3 ; retry + + ) {
int wret ;
wret = drm_dp_dpcd_write ( & intel_dp - > aux ,
DP_SINK_COUNT_ESI + 1 ,
& esi [ 1 ] , 3 ) ;
if ( wret = = 3 )
break ;
2014-05-02 14:02:48 +10:00
}
}
2020-04-17 18:27:33 +03:00
2020-06-05 12:48:01 +03:00
return link_ok ;
2014-05-02 14:02:48 +10:00
}
2020-12-18 16:07:19 +05:30
static void
intel_dp_handle_hdmi_link_status_change ( struct intel_dp * intel_dp )
{
bool is_active ;
u8 buf = 0 ;
is_active = drm_dp_pcon_hdmi_link_active ( & intel_dp - > aux ) ;
if ( intel_dp - > frl . is_trained & & ! is_active ) {
if ( drm_dp_dpcd_readb ( & intel_dp - > aux , DP_PCON_HDMI_LINK_CONFIG_1 , & buf ) < 0 )
return ;
buf & = ~ DP_PCON_ENABLE_HDMI_LINK ;
if ( drm_dp_dpcd_writeb ( & intel_dp - > aux , DP_PCON_HDMI_LINK_CONFIG_1 , buf ) < 0 )
return ;
drm_dp_pcon_hdmi_frl_link_error_count ( & intel_dp - > aux , & intel_dp - > attached_connector - > base ) ;
/* Restart FRL training or fall back to TMDS mode */
intel_dp_check_frl_training ( intel_dp ) ;
}
}
2018-01-17 21:21:47 +02:00
static bool
intel_dp_needs_link_retrain ( struct intel_dp * intel_dp )
{
u8 link_status [ DP_LINK_STATUS_SIZE ] ;
2018-01-17 21:21:49 +02:00
if ( ! intel_dp - > link_trained )
2018-11-21 14:54:37 -08:00
return false ;
/*
* While PSR source HW is enabled , it will control main - link sending
* frames , enabling and disabling it so trying to do a retrain will fail
* as the link would or not be on or it could mix training patterns
* and frame data at the same time causing retrain to fail .
* Also when exiting PSR , HW will retrain the link anyways fixing
* any link status error .
*/
if ( intel_psr_enabled ( intel_dp ) )
2018-01-17 21:21:49 +02:00
return false ;
2020-10-07 20:09:17 +03:00
if ( drm_dp_dpcd_read_phy_link_status ( & intel_dp - > aux , DP_PHY_DPRX ,
link_status ) < 0 )
2018-01-17 21:21:47 +02:00
return false ;
/*
* Validate the cached values of intel_dp - > link_rate and
* intel_dp - > lane_count before attempting to retrain .
2020-10-01 14:10:53 +03:00
*
* FIXME would be nice to user the crtc state here , but since
* we need to call this from the short HPD handler that seems
* a bit hard .
2018-01-17 21:21:47 +02:00
*/
if ( ! intel_dp_link_params_valid ( intel_dp , intel_dp - > link_rate ,
intel_dp - > lane_count ) )
return false ;
/* Retrain if Channel EQ or CR not ok */
return ! drm_dp_channel_eq_ok ( link_status , intel_dp - > lane_count ) ;
}
2020-04-17 18:27:34 +03:00
static bool intel_dp_has_connector ( struct intel_dp * intel_dp ,
const struct drm_connector_state * conn_state )
{
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
struct intel_encoder * encoder ;
enum pipe pipe ;
if ( ! conn_state - > best_encoder )
return false ;
/* SST */
encoder = & dp_to_dig_port ( intel_dp ) - > base ;
if ( conn_state - > best_encoder = = & encoder - > base )
return true ;
/* MST */
for_each_pipe ( i915 , pipe ) {
encoder = & intel_dp - > mst_encoders [ pipe ] - > base ;
if ( conn_state - > best_encoder = = & encoder - > base )
return true ;
}
return false ;
}
static int intel_dp_prep_link_retrain ( struct intel_dp * intel_dp ,
struct drm_modeset_acquire_ctx * ctx ,
u32 * crtc_mask )
{
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
struct drm_connector_list_iter conn_iter ;
struct intel_connector * connector ;
int ret = 0 ;
* crtc_mask = 0 ;
if ( ! intel_dp_needs_link_retrain ( intel_dp ) )
return 0 ;
drm_connector_list_iter_begin ( & i915 - > drm , & conn_iter ) ;
for_each_intel_connector_iter ( connector , & conn_iter ) {
struct drm_connector_state * conn_state =
connector - > base . state ;
struct intel_crtc_state * crtc_state ;
struct intel_crtc * crtc ;
if ( ! intel_dp_has_connector ( intel_dp , conn_state ) )
continue ;
crtc = to_intel_crtc ( conn_state - > crtc ) ;
if ( ! crtc )
continue ;
ret = drm_modeset_lock ( & crtc - > base . mutex , ctx ) ;
if ( ret )
break ;
crtc_state = to_intel_crtc_state ( crtc - > base . state ) ;
drm_WARN_ON ( & i915 - > drm , ! intel_crtc_has_dp_encoder ( crtc_state ) ) ;
if ( ! crtc_state - > hw . active )
continue ;
if ( conn_state - > commit & &
! try_wait_for_completion ( & conn_state - > commit - > hw_done ) )
continue ;
* crtc_mask | = drm_crtc_mask ( & crtc - > base ) ;
}
drm_connector_list_iter_end ( & conn_iter ) ;
if ( ! intel_dp_needs_link_retrain ( intel_dp ) )
* crtc_mask = 0 ;
return ret ;
}
static bool intel_dp_is_connected ( struct intel_dp * intel_dp )
{
struct intel_connector * connector = intel_dp - > attached_connector ;
return connector - > base . status = = connector_status_connected | |
intel_dp - > is_mst ;
}
2018-01-17 21:21:47 +02:00
int intel_dp_retrain_link ( struct intel_encoder * encoder ,
struct drm_modeset_acquire_ctx * ctx )
2016-10-14 20:02:54 +03:00
{
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2018-01-17 21:21:47 +02:00
struct intel_crtc * crtc ;
2020-04-17 18:27:34 +03:00
u32 crtc_mask ;
2018-01-17 21:21:47 +02:00
int ret ;
2020-04-17 18:27:34 +03:00
if ( ! intel_dp_is_connected ( intel_dp ) )
2018-01-17 21:21:47 +02:00
return 0 ;
ret = drm_modeset_lock ( & dev_priv - > drm . mode_config . connection_mutex ,
ctx ) ;
if ( ret )
return ret ;
2020-04-17 18:27:34 +03:00
ret = intel_dp_prep_link_retrain ( intel_dp , ctx , & crtc_mask ) ;
2018-01-17 21:21:47 +02:00
if ( ret )
return ret ;
2020-04-17 18:27:34 +03:00
if ( crtc_mask = = 0 )
2018-01-17 21:21:47 +02:00
return 0 ;
2020-04-17 18:27:34 +03:00
drm_dbg_kms ( & dev_priv - > drm , " [ENCODER:%d:%s] retraining link \n " ,
encoder - > base . base . id , encoder - > base . name ) ;
2018-01-17 21:21:47 +02:00
2020-04-17 18:27:34 +03:00
for_each_intel_crtc_mask ( & dev_priv - > drm , crtc , crtc_mask ) {
const struct intel_crtc_state * crtc_state =
to_intel_crtc_state ( crtc - > base . state ) ;
2016-10-14 20:02:54 +03:00
2020-04-17 18:27:34 +03:00
/* Suppress underruns caused by re-training */
intel_set_cpu_fifo_underrun_reporting ( dev_priv , crtc - > pipe , false ) ;
if ( crtc_state - > has_pch_encoder )
intel_set_pch_fifo_underrun_reporting ( dev_priv ,
intel_crtc_pch_transcoder ( crtc ) , false ) ;
}
2016-10-14 20:02:54 +03:00
2020-10-01 14:10:53 +03:00
for_each_intel_crtc_mask ( & dev_priv - > drm , crtc , crtc_mask ) {
const struct intel_crtc_state * crtc_state =
to_intel_crtc_state ( crtc - > base . state ) ;
/* retrain on the MST master transcoder */
if ( INTEL_GEN ( dev_priv ) > = 12 & &
intel_crtc_has_type ( crtc_state , INTEL_OUTPUT_DP_MST ) & &
! intel_dp_mst_is_master_trans ( crtc_state ) )
continue ;
2020-12-18 16:07:18 +05:30
intel_dp_check_frl_training ( intel_dp ) ;
2020-12-18 16:07:22 +05:30
intel_dp_pcon_dsc_configure ( intel_dp , crtc_state ) ;
2020-10-01 14:10:53 +03:00
intel_dp_start_link_train ( intel_dp , crtc_state ) ;
intel_dp_stop_link_train ( intel_dp , crtc_state ) ;
break ;
}
2016-10-14 20:02:54 +03:00
2020-04-17 18:27:34 +03:00
for_each_intel_crtc_mask ( & dev_priv - > drm , crtc , crtc_mask ) {
const struct intel_crtc_state * crtc_state =
to_intel_crtc_state ( crtc - > base . state ) ;
2016-10-14 20:02:54 +03:00
2020-04-17 18:27:34 +03:00
/* Keep underrun reporting disabled until things are stable */
intel_wait_for_vblank ( dev_priv , crtc - > pipe ) ;
intel_set_cpu_fifo_underrun_reporting ( dev_priv , crtc - > pipe , true ) ;
if ( crtc_state - > has_pch_encoder )
intel_set_pch_fifo_underrun_reporting ( dev_priv ,
intel_crtc_pch_transcoder ( crtc ) , true ) ;
}
2018-01-17 21:21:47 +02:00
return 0 ;
2016-10-14 20:02:54 +03:00
}
2020-09-30 13:04:12 +03:00
static int intel_dp_prep_phy_test ( struct intel_dp * intel_dp ,
struct drm_modeset_acquire_ctx * ctx ,
u32 * crtc_mask )
{
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
struct drm_connector_list_iter conn_iter ;
struct intel_connector * connector ;
int ret = 0 ;
* crtc_mask = 0 ;
drm_connector_list_iter_begin ( & i915 - > drm , & conn_iter ) ;
for_each_intel_connector_iter ( connector , & conn_iter ) {
struct drm_connector_state * conn_state =
connector - > base . state ;
struct intel_crtc_state * crtc_state ;
struct intel_crtc * crtc ;
if ( ! intel_dp_has_connector ( intel_dp , conn_state ) )
continue ;
crtc = to_intel_crtc ( conn_state - > crtc ) ;
if ( ! crtc )
continue ;
ret = drm_modeset_lock ( & crtc - > base . mutex , ctx ) ;
if ( ret )
break ;
crtc_state = to_intel_crtc_state ( crtc - > base . state ) ;
drm_WARN_ON ( & i915 - > drm , ! intel_crtc_has_dp_encoder ( crtc_state ) ) ;
if ( ! crtc_state - > hw . active )
continue ;
if ( conn_state - > commit & &
! try_wait_for_completion ( & conn_state - > commit - > hw_done ) )
continue ;
* crtc_mask | = drm_crtc_mask ( & crtc - > base ) ;
}
drm_connector_list_iter_end ( & conn_iter ) ;
return ret ;
}
static int intel_dp_do_phy_test ( struct intel_encoder * encoder ,
struct drm_modeset_acquire_ctx * ctx )
{
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2020-10-01 14:10:53 +03:00
struct intel_crtc * crtc ;
2020-09-30 13:04:12 +03:00
u32 crtc_mask ;
int ret ;
ret = drm_modeset_lock ( & dev_priv - > drm . mode_config . connection_mutex ,
ctx ) ;
if ( ret )
return ret ;
ret = intel_dp_prep_phy_test ( intel_dp , ctx , & crtc_mask ) ;
if ( ret )
return ret ;
if ( crtc_mask = = 0 )
return 0 ;
drm_dbg_kms ( & dev_priv - > drm , " [ENCODER:%d:%s] PHY test \n " ,
encoder - > base . base . id , encoder - > base . name ) ;
2020-10-01 14:10:53 +03:00
for_each_intel_crtc_mask ( & dev_priv - > drm , crtc , crtc_mask ) {
const struct intel_crtc_state * crtc_state =
to_intel_crtc_state ( crtc - > base . state ) ;
/* test on the MST master transcoder */
if ( INTEL_GEN ( dev_priv ) > = 12 & &
intel_crtc_has_type ( crtc_state , INTEL_OUTPUT_DP_MST ) & &
! intel_dp_mst_is_master_trans ( crtc_state ) )
continue ;
intel_dp_process_phy_request ( intel_dp , crtc_state ) ;
break ;
}
2020-09-30 13:04:12 +03:00
return 0 ;
}
static void intel_dp_phy_test ( struct intel_encoder * encoder )
{
struct drm_modeset_acquire_ctx ctx ;
int ret ;
drm_modeset_acquire_init ( & ctx , 0 ) ;
for ( ; ; ) {
ret = intel_dp_do_phy_test ( encoder , & ctx ) ;
if ( ret = = - EDEADLK ) {
drm_modeset_backoff ( & ctx ) ;
continue ;
}
break ;
}
drm_modeset_drop_locks ( & ctx ) ;
drm_modeset_acquire_fini ( & ctx ) ;
drm_WARN ( encoder - > base . dev , ret ,
" Acquiring modeset locks failed with %i \n " , ret ) ;
}
2018-01-17 21:21:47 +02:00
/*
* If display is now connected check links status ,
* there has been known issues of link loss triggering
* long pulse .
*
* Some sinks ( eg . ASUS PB287Q ) seem to perform some
* weird HPD ping pong during modesets . So we can apparently
* end up with HPD going low during a modeset , and then
* going back up soon after . And once that happens we must
* retrain the link to get a picture . That ' s in case no
* userspace component reacted to intermittent HPD dip .
*/
2019-07-11 17:53:42 -07:00
static enum intel_hotplug_state
intel_dp_hotplug ( struct intel_encoder * encoder ,
2020-03-30 12:54:24 +03:00
struct intel_connector * connector )
2016-03-30 18:05:24 +05:30
{
2020-09-30 13:04:12 +03:00
struct intel_dp * intel_dp = enc_to_intel_dp ( encoder ) ;
2018-01-17 21:21:47 +02:00
struct drm_modeset_acquire_ctx ctx ;
2019-07-11 17:53:42 -07:00
enum intel_hotplug_state state ;
2018-01-17 21:21:47 +02:00
int ret ;
2016-03-30 18:05:24 +05:30
2020-09-30 13:04:12 +03:00
if ( intel_dp - > compliance . test_active & &
intel_dp - > compliance . test_type = = DP_TEST_LINK_PHY_TEST_PATTERN ) {
intel_dp_phy_test ( encoder ) ;
/* just do the PHY test and nothing else */
return INTEL_HOTPLUG_UNCHANGED ;
}
2020-03-30 12:54:24 +03:00
state = intel_encoder_hotplug ( encoder , connector ) ;
2016-03-30 18:05:24 +05:30
2018-01-17 21:21:47 +02:00
drm_modeset_acquire_init ( & ctx , 0 ) ;
2017-11-13 17:01:40 +01:00
2018-01-17 21:21:47 +02:00
for ( ; ; ) {
ret = intel_dp_retrain_link ( encoder , & ctx ) ;
2016-03-30 18:05:24 +05:30
2018-01-17 21:21:47 +02:00
if ( ret = = - EDEADLK ) {
drm_modeset_backoff ( & ctx ) ;
continue ;
}
2016-03-30 18:05:24 +05:30
2018-01-17 21:21:47 +02:00
break ;
}
2016-10-19 22:29:53 +01:00
2018-01-17 21:21:47 +02:00
drm_modeset_drop_locks ( & ctx ) ;
drm_modeset_acquire_fini ( & ctx ) ;
drm/i915/display: Make WARN* drm specific where encoder ptr is available
Drm specific drm_WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where intel_encoder struct pointer is available.
The conversion was done automatically with below coccinelle semantic
patch.
@@
identifier func, T;
@@
func(...) {
...
struct intel_encoder *T = ...;
<...
(
-WARN(
+drm_WARN(T->base.dev,
...)
|
-WARN_ON(
+drm_WARN_ON(T->base.dev,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T->base.dev,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T->base.dev,
...)
)
...>
}
@@
identifier func, T;
@@
func(struct intel_encoder *T,...) {
<...
(
-WARN(
+drm_WARN(T->base.dev,
...)
|
-WARN_ON(
+drm_WARN_ON(T->base.dev,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T->base.dev,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T->base.dev,
...)
)
...>
}
command: spatch --sp-file <script> --dir drivers/gpu/drm/i915/display \
--linux-spacing --in-place
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200115034455.17658-5-pankaj.laxminarayan.bharadiya@intel.com
2020-01-15 09:14:48 +05:30
drm_WARN ( encoder - > base . dev , ret ,
" Acquiring modeset locks failed with %i \n " , ret ) ;
2016-10-14 20:02:54 +03:00
2019-07-11 17:53:43 -07:00
/*
* Keeping it consistent with intel_ddi_hotplug ( ) and
* intel_hdmi_hotplug ( ) .
*/
2020-03-30 12:54:24 +03:00
if ( state = = INTEL_HOTPLUG_UNCHANGED & & ! connector - > hotplug_retries )
2019-07-11 17:53:43 -07:00
state = INTEL_HOTPLUG_RETRY ;
2019-07-11 17:53:42 -07:00
return state ;
2016-03-30 18:05:24 +05:30
}
2020-12-18 16:07:19 +05:30
static void intel_dp_check_device_service_irq ( struct intel_dp * intel_dp )
2018-09-27 13:57:35 -07:00
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2018-09-27 13:57:35 -07:00
u8 val ;
if ( intel_dp - > dpcd [ DP_DPCD_REV ] < 0x11 )
return ;
if ( drm_dp_dpcd_readb ( & intel_dp - > aux ,
DP_DEVICE_SERVICE_IRQ_VECTOR , & val ) ! = 1 | | ! val )
return ;
drm_dp_dpcd_writeb ( & intel_dp - > aux , DP_DEVICE_SERVICE_IRQ_VECTOR , val ) ;
if ( val & DP_AUTOMATED_TEST_REQUEST )
intel_dp_handle_test_request ( intel_dp ) ;
2018-10-23 14:52:28 +05:30
if ( val & DP_CP_IRQ )
2019-02-16 23:06:52 +05:30
intel_hdcp_handle_cp_irq ( intel_dp - > attached_connector ) ;
2018-10-23 14:52:28 +05:30
if ( val & DP_SINK_SPECIFIC_IRQ )
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Sink specific irq unhandled \n " ) ;
2018-09-27 13:57:35 -07:00
}
2020-12-18 16:07:19 +05:30
static void intel_dp_check_link_service_irq ( struct intel_dp * intel_dp )
{
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
u8 val ;
if ( intel_dp - > dpcd [ DP_DPCD_REV ] < 0x11 )
return ;
if ( drm_dp_dpcd_readb ( & intel_dp - > aux ,
DP_LINK_SERVICE_IRQ_VECTOR_ESI0 , & val ) ! = 1 | | ! val ) {
drm_dbg_kms ( & i915 - > drm , " Error in reading link service irq vector \n " ) ;
return ;
}
if ( drm_dp_dpcd_writeb ( & intel_dp - > aux ,
DP_LINK_SERVICE_IRQ_VECTOR_ESI0 , val ) ! = 1 ) {
drm_dbg_kms ( & i915 - > drm , " Error in writing link service irq vector \n " ) ;
return ;
}
if ( val & HDMI_LINK_STATUS_CHANGED )
intel_dp_handle_hdmi_link_status_change ( intel_dp ) ;
}
2009-04-07 16:16:42 -07:00
/*
* According to DP spec
* 5.1 .2 :
* 1. Read DPCD
* 2. Configure link according to Receiver Capabilities
* 3. Use Link Training from 2.5 .3 .3 and 3.5 .1 .3
* 4. Check link status on receipt of hot - plug interrupt
2016-03-30 18:05:26 +05:30
*
* intel_dp_short_pulse - handles short pulse interrupts
* when full detection is not required .
* Returns % true if short pulse is handled and full detection
* is NOT required and % false otherwise .
2009-04-07 16:16:42 -07:00
*/
2016-03-30 18:05:26 +05:30
static bool
2016-03-30 18:05:24 +05:30
intel_dp_short_pulse ( struct intel_dp * intel_dp )
2009-04-07 16:16:42 -07:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2016-03-30 18:05:26 +05:30
u8 old_sink_count = intel_dp - > sink_count ;
bool ret ;
2014-08-05 10:40:20 +10:00
2015-10-28 15:30:36 +05:30
/*
* Clearing compliance test variables to allow capturing
* of values for next automated test request .
*/
2016-12-09 16:22:50 -08:00
memset ( & intel_dp - > compliance , 0 , sizeof ( intel_dp - > compliance ) ) ;
2015-10-28 15:30:36 +05:30
2016-03-30 18:05:26 +05:30
/*
* Now read the DPCD to see if it ' s actually running
* If the current value of sink count doesn ' t match with
* the value that was stored earlier or dpcd read failed
* we need to do full detection
*/
ret = intel_dp_get_dpcd ( intel_dp ) ;
if ( ( old_sink_count ! = intel_dp - > sink_count ) | | ! ret ) {
/* No need to proceed if we are going to do full detect */
return false ;
2011-07-07 11:10:59 -07:00
}
2020-12-18 16:07:19 +05:30
intel_dp_check_device_service_irq ( intel_dp ) ;
intel_dp_check_link_service_irq ( intel_dp ) ;
2011-10-20 15:09:17 -07:00
2018-07-11 15:29:09 +02:00
/* Handle CEC interrupts, if any */
drm_dp_cec_irq ( & intel_dp - > aux ) ;
2018-01-17 21:21:47 +02:00
/* defer to the hotplug work for link retraining if needed */
if ( intel_dp_needs_link_retrain ( intel_dp ) )
return false ;
2017-11-13 17:01:40 +01:00
2018-06-26 13:16:41 -07:00
intel_psr_short_pulse ( intel_dp ) ;
2020-09-30 13:04:12 +03:00
switch ( intel_dp - > compliance . test_type ) {
case DP_TEST_LINK_TRAINING :
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" Link Training Compliance Test requested \n " ) ;
2017-01-24 08:16:34 -08:00
/* Send a Hotplug Uevent to userspace to start modeset */
2017-11-09 17:27:58 +02:00
drm_kms_helper_hotplug_event ( & dev_priv - > drm ) ;
2020-09-30 13:04:12 +03:00
break ;
case DP_TEST_LINK_PHY_TEST_PATTERN :
drm_dbg_kms ( & dev_priv - > drm ,
" PHY test pattern Compliance Test requested \n " ) ;
/*
* Schedule long hpd to do the test
*
* FIXME get rid of the ad - hoc phy test modeset code
* and properly incorporate it into the normal modeset .
*/
return false ;
2017-01-24 08:16:34 -08:00
}
2016-03-30 18:05:26 +05:30
return true ;
2009-04-07 16:16:42 -07:00
}
2012-09-18 10:58:50 -04:00
/* XXX this is probably wrong for multiple downstream ports */
2011-07-12 17:38:04 -04:00
static enum drm_connector_status
2011-07-25 20:01:09 -07:00
intel_dp_detect_dpcd ( struct intel_dp * intel_dp )
2011-07-12 17:38:04 -04:00
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
2020-06-10 15:55:10 +08:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
2019-01-16 11:15:27 +02:00
u8 * dpcd = intel_dp - > dpcd ;
u8 type ;
2012-09-18 10:58:50 -04:00
drm/i915/display/dp: Prefer drm_WARN* over WARN*
struct drm_device specific drm_WARN* macros include device information
in the backtrace, so we know what device the warnings originate from.
Prefer drm_WARN* over WARN* at places where struct intel_dp or struct
drm_i915_private pointer is available.
Conversion is done with below sementic patch:
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule2@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule3@
identifier func, T;
@@
func(struct intel_dp *T,...) {
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(...) {
...
struct intel_dp *T = ...;
+ struct drm_i915_private *i915 = dp_to_i915(T);
<+...
(
-WARN_ON(
+drm_WARN_ON(&i915->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&i915->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200504181600.18503-3-pankaj.laxminarayan.bharadiya@intel.com
2020-05-04 23:45:53 +05:30
if ( drm_WARN_ON ( & i915 - > drm , intel_dp_is_edp ( intel_dp ) ) )
2019-05-09 20:34:41 +03:00
return connector_status_connected ;
2020-06-10 15:55:10 +08:00
lspcon_resume ( dig_port ) ;
2017-02-22 17:10:52 +02:00
2012-09-18 10:58:50 -04:00
if ( ! intel_dp_get_dpcd ( intel_dp ) )
return connector_status_disconnected ;
/* if there's no downstream port, we're done */
2016-10-24 19:33:24 +03:00
if ( ! drm_dp_is_branch ( dpcd ) )
2011-07-25 20:01:09 -07:00
return connector_status_connected ;
2012-09-18 10:58:50 -04:00
/* If we're HPD-aware, SINK_COUNT changes dynamically */
2020-08-26 14:24:51 -04:00
if ( intel_dp_has_sink_count ( intel_dp ) & &
2013-09-27 14:48:42 +03:00
intel_dp - > downstream_ports [ 0 ] & DP_DS_PORT_HPD ) {
2016-03-30 18:05:25 +05:30
return intel_dp - > sink_count ?
connector_status_connected : connector_status_disconnected ;
2012-09-18 10:58:50 -04:00
}
2016-07-29 16:51:16 +03:00
if ( intel_dp_can_mst ( intel_dp ) )
return connector_status_connected ;
2012-09-18 10:58:50 -04:00
/* If no HPD, poke DDC gently */
2014-03-14 16:51:17 +02:00
if ( drm_probe_ddc ( & intel_dp - > aux . ddc ) )
2011-07-25 20:01:09 -07:00
return connector_status_connected ;
2012-09-18 10:58:50 -04:00
/* Well we tried, say unknown for unreliable port types */
2013-09-27 14:48:42 +03:00
if ( intel_dp - > dpcd [ DP_DPCD_REV ] > = 0x11 ) {
type = intel_dp - > downstream_ports [ 0 ] & DP_DS_PORT_TYPE_MASK ;
if ( type = = DP_DS_PORT_TYPE_VGA | |
type = = DP_DS_PORT_TYPE_NON_EDID )
return connector_status_unknown ;
} else {
type = intel_dp - > dpcd [ DP_DOWNSTREAMPORT_PRESENT ] &
DP_DWN_STRM_PORT_TYPE_MASK ;
if ( type = = DP_DWN_STRM_PORT_TYPE_ANALOG | |
type = = DP_DWN_STRM_PORT_TYPE_OTHER )
return connector_status_unknown ;
}
2012-09-18 10:58:50 -04:00
/* Anything else is out of spec, warn and ignore */
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " Broken DP branch device, ignoring \n " ) ;
2011-07-25 20:01:09 -07:00
return connector_status_disconnected ;
2011-07-12 17:38:04 -04:00
}
2014-09-02 20:03:59 +01:00
static enum drm_connector_status
edp_detect ( struct intel_dp * intel_dp )
{
2018-07-17 20:42:15 +03:00
return connector_status_connected ;
2014-09-02 20:03:59 +01:00
}
2018-01-29 15:22:20 -08:00
static bool ibx_digital_port_connected ( struct intel_encoder * encoder )
2009-07-24 01:00:31 +08:00
{
2018-01-29 15:22:20 -08:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2020-03-11 17:54:22 +02:00
u32 bit = dev_priv - > hotplug . pch_hpd [ encoder - > hpd_pin ] ;
2017-06-15 20:12:52 +03:00
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
return intel_de_read ( dev_priv , SDEISR ) & bit ;
2017-06-15 20:12:52 +03:00
}
2018-01-29 15:22:20 -08:00
static bool g4x_digital_port_connected ( struct intel_encoder * encoder )
2009-04-07 16:16:42 -07:00
{
2018-01-29 15:22:20 -08:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2015-08-20 10:47:41 +03:00
u32 bit ;
2009-07-24 01:00:31 +08:00
2018-01-29 15:22:20 -08:00
switch ( encoder - > hpd_pin ) {
case HPD_PORT_B :
2015-08-20 10:47:41 +03:00
bit = PORTB_HOTPLUG_LIVE_STATUS_G4X ;
break ;
2018-01-29 15:22:20 -08:00
case HPD_PORT_C :
2015-08-20 10:47:41 +03:00
bit = PORTC_HOTPLUG_LIVE_STATUS_G4X ;
break ;
2018-01-29 15:22:20 -08:00
case HPD_PORT_D :
2015-08-20 10:47:41 +03:00
bit = PORTD_HOTPLUG_LIVE_STATUS_G4X ;
break ;
default :
2018-01-29 15:22:20 -08:00
MISSING_CASE ( encoder - > hpd_pin ) ;
2015-08-20 10:47:41 +03:00
return false ;
}
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
return intel_de_read ( dev_priv , PORT_HOTPLUG_STAT ) & bit ;
2015-08-20 10:47:41 +03:00
}
2018-01-29 15:22:20 -08:00
static bool gm45_digital_port_connected ( struct intel_encoder * encoder )
2015-08-20 10:47:41 +03:00
{
2018-01-29 15:22:20 -08:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2015-08-20 10:47:41 +03:00
u32 bit ;
2018-01-29 15:22:20 -08:00
switch ( encoder - > hpd_pin ) {
case HPD_PORT_B :
2016-02-10 19:59:05 +02:00
bit = PORTB_HOTPLUG_LIVE_STATUS_GM45 ;
2015-08-20 10:47:41 +03:00
break ;
2018-01-29 15:22:20 -08:00
case HPD_PORT_C :
2016-02-10 19:59:05 +02:00
bit = PORTC_HOTPLUG_LIVE_STATUS_GM45 ;
2015-08-20 10:47:41 +03:00
break ;
2018-01-29 15:22:20 -08:00
case HPD_PORT_D :
2016-02-10 19:59:05 +02:00
bit = PORTD_HOTPLUG_LIVE_STATUS_GM45 ;
2015-08-20 10:47:41 +03:00
break ;
default :
2018-01-29 15:22:20 -08:00
MISSING_CASE ( encoder - > hpd_pin ) ;
2015-08-20 10:47:41 +03:00
return false ;
2009-04-07 16:16:42 -07:00
}
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
return intel_de_read ( dev_priv , PORT_HOTPLUG_STAT ) & bit ;
2014-09-01 16:58:12 +10:00
}
2018-01-29 15:22:20 -08:00
static bool ilk_digital_port_connected ( struct intel_encoder * encoder )
2017-06-15 20:12:52 +03:00
{
2018-01-29 15:22:20 -08:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2020-03-11 17:54:22 +02:00
u32 bit = dev_priv - > hotplug . hpd [ encoder - > hpd_pin ] ;
2018-01-29 15:22:20 -08:00
2020-03-11 17:54:22 +02:00
return intel_de_read ( dev_priv , DEISR ) & bit ;
2018-07-25 12:59:27 -07:00
}
2015-08-20 10:47:39 +03:00
/*
* intel_digital_port_connected - is the specified port connected ?
2018-01-29 15:22:20 -08:00
* @ encoder : intel_encoder
2015-08-20 10:47:39 +03:00
*
2018-08-01 10:34:41 -07:00
* In cases where there ' s a connector physically connected but it can ' t be used
* by our hardware we also return false , since the rest of the driver should
* pretty much treat the port as disconnected . This is relevant for type - C
* ( starting on ICL ) where there ' s ownership involved .
*
2018-01-29 15:22:20 -08:00
* Return % true if port is connected , % false otherwise .
2015-08-20 10:47:39 +03:00
*/
2019-05-09 20:34:42 +03:00
bool intel_digital_port_connected ( struct intel_encoder * encoder )
{
struct drm_i915_private * dev_priv = to_i915 ( encoder - > base . dev ) ;
2020-03-11 17:54:20 +02:00
struct intel_digital_port * dig_port = enc_to_dig_port ( encoder ) ;
2019-05-17 11:22:24 +01:00
bool is_connected = false ;
2019-05-09 20:34:42 +03:00
intel_wakeref_t wakeref ;
with_intel_display_power ( dev_priv , POWER_DOMAIN_DISPLAY_CORE , wakeref )
2020-03-11 17:54:20 +02:00
is_connected = dig_port - > connected ( encoder ) ;
2019-05-09 20:34:42 +03:00
return is_connected ;
}
2011-09-28 16:38:44 -07:00
static struct edid *
2014-09-02 20:04:00 +01:00
intel_dp_get_edid ( struct intel_dp * intel_dp )
2011-09-28 16:38:44 -07:00
{
2014-09-02 20:04:00 +01:00
struct intel_connector * intel_connector = intel_dp - > attached_connector ;
2012-06-14 15:28:33 -04:00
2012-10-19 14:51:52 +03:00
/* use cached edid if we have one */
if ( intel_connector - > edid ) {
/* invalid edid */
if ( IS_ERR ( intel_connector - > edid ) )
2012-06-14 15:28:33 -04:00
return NULL ;
2013-10-01 10:38:54 +03:00
return drm_edid_duplicate ( intel_connector - > edid ) ;
2014-09-02 20:04:00 +01:00
} else
return drm_get_edid ( & intel_connector - > base ,
& intel_dp - > aux . ddc ) ;
}
2011-09-28 16:38:44 -07:00
2014-09-02 20:04:00 +01:00
static void
2020-09-04 14:53:54 +03:00
intel_dp_update_dfp ( struct intel_dp * intel_dp ,
const struct edid * edid )
2014-09-02 20:04:00 +01:00
{
2020-09-04 14:53:41 +03:00
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
struct intel_connector * connector = intel_dp - > attached_connector ;
intel_dp - > dfp . max_bpc =
drm_dp_downstream_max_bpc ( intel_dp - > dpcd ,
2020-09-04 14:53:43 +03:00
intel_dp - > downstream_ports , edid ) ;
2020-09-04 14:53:41 +03:00
2020-09-04 14:53:45 +03:00
intel_dp - > dfp . max_dotclock =
drm_dp_downstream_max_dotclock ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ) ;
2020-09-04 14:53:47 +03:00
intel_dp - > dfp . min_tmds_clock =
drm_dp_downstream_min_tmds_clock ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ,
edid ) ;
intel_dp - > dfp . max_tmds_clock =
drm_dp_downstream_max_tmds_clock ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ,
edid ) ;
2020-12-18 16:07:16 +05:30
intel_dp - > dfp . pcon_max_frl_bw =
drm_dp_get_pcon_max_frl_bw ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ) ;
2020-09-04 14:53:45 +03:00
drm_dbg_kms ( & i915 - > drm ,
2020-12-18 16:07:16 +05:30
" [CONNECTOR:%d:%s] DFP max bpc %d, max dotclock %d, TMDS clock %d-%d, PCON Max FRL BW %dGbps \n " ,
2020-09-04 14:53:41 +03:00
connector - > base . base . id , connector - > base . name ,
2020-09-04 14:53:47 +03:00
intel_dp - > dfp . max_bpc ,
intel_dp - > dfp . max_dotclock ,
intel_dp - > dfp . min_tmds_clock ,
2020-12-18 16:07:16 +05:30
intel_dp - > dfp . max_tmds_clock ,
intel_dp - > dfp . pcon_max_frl_bw ) ;
2020-12-18 16:07:20 +05:30
intel_dp_get_pcon_dsc_cap ( intel_dp ) ;
2020-09-04 14:53:54 +03:00
}
static void
intel_dp_update_420 ( struct intel_dp * intel_dp )
{
struct drm_i915_private * i915 = dp_to_i915 ( intel_dp ) ;
struct intel_connector * connector = intel_dp - > attached_connector ;
2020-12-18 16:07:23 +05:30
bool is_branch , ycbcr_420_passthrough , ycbcr_444_to_420 , rgb_to_ycbcr ;
2020-09-04 14:53:54 +03:00
/* No YCbCr output support on gmch platforms */
if ( HAS_GMCH ( i915 ) )
return ;
/*
* ILK doesn ' t seem capable of DP YCbCr output . The
* displayed image is severly corrupted . SNB + is fine .
*/
if ( IS_GEN ( i915 , 5 ) )
return ;
is_branch = drm_dp_is_branch ( intel_dp - > dpcd ) ;
ycbcr_420_passthrough =
drm_dp_downstream_420_passthrough ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ) ;
2020-09-24 21:41:55 +03:00
/* on-board LSPCON always assumed to support 4:4:4->4:2:0 conversion */
2020-09-04 14:53:54 +03:00
ycbcr_444_to_420 =
2020-09-24 21:41:55 +03:00
dp_to_dig_port ( intel_dp ) - > lspcon . active | |
2020-09-04 14:53:54 +03:00
drm_dp_downstream_444_to_420_conversion ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ) ;
2020-12-18 16:07:23 +05:30
rgb_to_ycbcr = drm_dp_downstream_rgb_to_ycbcr_conversion ( intel_dp - > dpcd ,
intel_dp - > downstream_ports ,
DP_DS_HDMI_BT601_RGB_YCBCR_CONV | |
DP_DS_HDMI_BT709_RGB_YCBCR_CONV | |
DP_DS_HDMI_BT2020_RGB_YCBCR_CONV ) ;
2020-09-04 14:53:54 +03:00
if ( INTEL_GEN ( i915 ) > = 11 ) {
2020-12-18 16:07:23 +05:30
/* Let PCON convert from RGB->YCbCr if possible */
if ( is_branch & & rgb_to_ycbcr & & ycbcr_444_to_420 ) {
intel_dp - > dfp . rgb_to_ycbcr = true ;
intel_dp - > dfp . ycbcr_444_to_420 = true ;
connector - > base . ycbcr_420_allowed = true ;
} else {
2020-09-04 14:53:54 +03:00
/* Prefer 4:2:0 passthrough over 4:4:4->4:2:0 conversion */
2020-12-18 16:07:23 +05:30
intel_dp - > dfp . ycbcr_444_to_420 =
ycbcr_444_to_420 & & ! ycbcr_420_passthrough ;
2020-09-04 14:53:54 +03:00
2020-12-18 16:07:23 +05:30
connector - > base . ycbcr_420_allowed =
! is_branch | | ycbcr_444_to_420 | | ycbcr_420_passthrough ;
}
2020-09-04 14:53:54 +03:00
} else {
/* 4:4:4->4:2:0 conversion is the only way */
intel_dp - > dfp . ycbcr_444_to_420 = ycbcr_444_to_420 ;
connector - > base . ycbcr_420_allowed = ycbcr_444_to_420 ;
}
drm_dbg_kms ( & i915 - > drm ,
2020-12-18 16:07:23 +05:30
" [CONNECTOR:%d:%s] RGB->YcbCr conversion? %s, YCbCr 4:2:0 allowed? %s, YCbCr 4:4:4->4:2:0 conversion? %s \n " ,
2020-09-04 14:53:54 +03:00
connector - > base . base . id , connector - > base . name ,
2020-12-18 16:07:23 +05:30
yesno ( intel_dp - > dfp . rgb_to_ycbcr ) ,
2020-09-04 14:53:54 +03:00
yesno ( connector - > base . ycbcr_420_allowed ) ,
yesno ( intel_dp - > dfp . ycbcr_444_to_420 ) ) ;
}
static void
intel_dp_set_edid ( struct intel_dp * intel_dp )
{
struct intel_connector * connector = intel_dp - > attached_connector ;
struct edid * edid ;
intel_dp_unset_edid ( intel_dp ) ;
edid = intel_dp_get_edid ( intel_dp ) ;
connector - > detect_edid = edid ;
intel_dp_update_dfp ( intel_dp , edid ) ;
intel_dp_update_420 ( intel_dp ) ;
2014-09-02 20:04:00 +01:00
2020-09-04 14:53:38 +03:00
if ( edid & & edid - > input & DRM_EDID_INPUT_DIGITAL ) {
intel_dp - > has_hdmi_sink = drm_detect_hdmi_monitor ( edid ) ;
intel_dp - > has_audio = drm_detect_monitor_audio ( edid ) ;
}
2018-07-11 15:29:09 +02:00
drm_dp_cec_set_edid ( & intel_dp - > aux , edid ) ;
2020-02-11 13:33:46 -05:00
intel_dp - > edid_quirks = drm_dp_get_edid_quirks ( edid ) ;
2011-09-28 16:38:44 -07:00
}
2014-09-02 20:04:00 +01:00
static void
intel_dp_unset_edid ( struct intel_dp * intel_dp )
2011-09-28 16:38:44 -07:00
{
2020-09-04 14:53:54 +03:00
struct intel_connector * connector = intel_dp - > attached_connector ;
2011-09-28 16:38:44 -07:00
2018-07-11 15:29:09 +02:00
drm_dp_cec_unset_edid ( & intel_dp - > aux ) ;
2020-09-04 14:53:54 +03:00
kfree ( connector - > detect_edid ) ;
connector - > detect_edid = NULL ;
2012-10-19 14:51:52 +03:00
2020-09-04 14:53:38 +03:00
intel_dp - > has_hdmi_sink = false ;
2014-09-02 20:04:00 +01:00
intel_dp - > has_audio = false ;
2020-02-11 13:33:46 -05:00
intel_dp - > edid_quirks = 0 ;
2020-09-04 14:53:41 +03:00
intel_dp - > dfp . max_bpc = 0 ;
2020-09-04 14:53:45 +03:00
intel_dp - > dfp . max_dotclock = 0 ;
2020-09-04 14:53:47 +03:00
intel_dp - > dfp . min_tmds_clock = 0 ;
intel_dp - > dfp . max_tmds_clock = 0 ;
2020-09-04 14:53:54 +03:00
2020-12-18 16:07:16 +05:30
intel_dp - > dfp . pcon_max_frl_bw = 0 ;
2020-09-04 14:53:54 +03:00
intel_dp - > dfp . ycbcr_444_to_420 = false ;
connector - > base . ycbcr_420_allowed = false ;
2014-09-02 20:04:00 +01:00
}
2012-06-14 15:28:33 -04:00
2017-04-06 20:55:20 +02:00
static int
2018-09-27 13:57:34 -07:00
intel_dp_detect ( struct drm_connector * connector ,
struct drm_modeset_acquire_ctx * ctx ,
bool force )
2010-09-19 13:09:06 +08:00
{
2018-09-27 13:57:34 -07:00
struct drm_i915_private * dev_priv = to_i915 ( connector - > dev ) ;
2019-12-04 20:05:42 +02:00
struct intel_dp * intel_dp = intel_attached_dp ( to_intel_connector ( connector ) ) ;
2018-11-01 16:04:23 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct intel_encoder * encoder = & dig_port - > base ;
2010-09-19 13:09:06 +08:00
enum drm_connector_status status ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " [CONNECTOR:%d:%s] \n " ,
connector - > base . id , connector - > name ) ;
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
drm_WARN_ON ( & dev_priv - > drm ,
! drm_modeset_is_locked ( & dev_priv - > drm . mode_config . connection_mutex ) ) ;
2017-04-06 20:55:20 +02:00
2020-09-10 19:42:56 +03:00
if ( ! INTEL_DISPLAY_ENABLED ( dev_priv ) )
return connector_status_disconnected ;
2018-07-17 20:42:15 +03:00
/* Can't disconnect eDP */
2017-08-18 12:30:20 +03:00
if ( intel_dp_is_edp ( intel_dp ) )
2014-09-02 20:03:59 +01:00
status = edp_detect ( intel_dp ) ;
2018-09-27 13:57:32 -07:00
else if ( intel_digital_port_connected ( encoder ) )
2015-11-18 17:19:30 +02:00
status = intel_dp_detect_dpcd ( intel_dp ) ;
2010-09-19 13:09:06 +08:00
else
2015-11-18 17:19:30 +02:00
status = connector_status_disconnected ;
2016-10-03 10:55:16 +03:00
if ( status = = connector_status_disconnected ) {
2016-12-09 16:22:50 -08:00
memset ( & intel_dp - > compliance , 0 , sizeof ( intel_dp - > compliance ) ) ;
2018-10-30 17:19:19 -07:00
memset ( intel_dp - > dsc_dpcd , 0 , sizeof ( intel_dp - > dsc_dpcd ) ) ;
2015-10-28 15:30:36 +05:30
2016-04-11 10:11:24 -07:00
if ( intel_dp - > is_mst ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" MST device may have disappeared %d vs %d \n " ,
intel_dp - > is_mst ,
intel_dp - > mst_mgr . mst_state ) ;
2016-04-11 10:11:24 -07:00
intel_dp - > is_mst = false ;
drm_dp_mst_topology_mgr_set_mst ( & intel_dp - > mst_mgr ,
intel_dp - > is_mst ) ;
}
2013-11-27 18:21:54 -02:00
goto out ;
2015-10-28 15:30:36 +05:30
}
2010-09-19 13:09:06 +08:00
2020-06-17 00:11:45 +03:00
/* Read DP Sink DSC Cap DPCD regs for DP v1.4 */
if ( INTEL_GEN ( dev_priv ) > = 11 )
intel_dp_get_dsc_sink_cap ( intel_dp ) ;
intel_dp_configure_mst ( intel_dp ) ;
/*
* TODO : Reset link params when switching to MST mode , until MST
* supports link training fallback params .
*/
if ( intel_dp - > reset_link_params | | intel_dp - > is_mst ) {
2017-04-06 16:44:13 +03:00
/* Initial max link lane count */
intel_dp - > max_link_lane_count = intel_dp_max_common_lane_count ( intel_dp ) ;
2016-12-05 16:27:36 -08:00
2017-04-06 16:44:13 +03:00
/* Initial max link rate */
intel_dp - > max_link_rate = intel_dp_max_common_rate ( intel_dp ) ;
2017-02-07 16:54:11 -08:00
intel_dp - > reset_link_params = false ;
}
2016-12-05 16:27:36 -08:00
2016-07-29 16:52:39 +03:00
intel_dp_print_rates ( intel_dp ) ;
2016-07-29 16:51:16 +03:00
if ( intel_dp - > is_mst ) {
2016-03-30 18:05:22 +05:30
/*
* If we are in MST mode then this connector
* won ' t appear connected or have anything
* with EDID on it
*/
2014-05-02 14:02:48 +10:00
status = connector_status_disconnected ;
goto out ;
2018-09-27 13:57:31 -07:00
}
/*
* Some external monitors do not signal loss of link synchronization
* with an IRQ_HPD , so force a link status check .
*/
2018-09-27 13:57:33 -07:00
if ( ! intel_dp_is_edp ( intel_dp ) ) {
int ret ;
ret = intel_dp_retrain_link ( encoder , ctx ) ;
2019-05-09 20:34:42 +03:00
if ( ret )
2018-09-27 13:57:33 -07:00
return ret ;
}
2014-05-02 14:02:48 +10:00
2015-10-28 15:30:36 +05:30
/*
* Clearing NACK and defer counts to get their exact values
* while reading EDID which are required by Compliance tests
* 4.2 .2 .4 and 4.2 .2 .5
*/
intel_dp - > aux . i2c_nack_count = 0 ;
intel_dp - > aux . i2c_defer_count = 0 ;
2014-09-02 20:04:00 +01:00
intel_dp_set_edid ( intel_dp ) ;
2018-09-27 13:57:34 -07:00
if ( intel_dp_is_edp ( intel_dp ) | |
to_intel_connector ( connector ) - > detect_edid )
2016-10-03 10:55:16 +03:00
status = connector_status_connected ;
2013-11-27 18:21:54 -02:00
2020-12-18 16:07:19 +05:30
intel_dp_check_device_service_irq ( intel_dp ) ;
drm/i915: Move Displayport test request and sink IRQ logic to intel_dp_detect()
Due to changes in the driver and to support Displayport compliance testing,
the test request and sink IRQ logic has been relocated from
intel_dp_check_link_status to intel_dp_detect. This is because the bulk of the
compliance tests that set the TEST_REQUEST bit in the DEVICE_IRQ field of the
DPCD issue a long pulse / hot plug event to signify the start of the test.
Currently, for a long pulse, intel_dp_check_link_status is not called for a
long HPD pulse, so if test requests come in, they cannot be detected by the
driver.
Once located in the intel_dp_detect, in the regular hot plug event path,
proper detection of Displayport compliance test requests occurs which then
invokes the test handler to support them. Additionally, this places compliance
testing in the normal operational paths, eliminating as much special case code
as possible.
The only change in intel_dp_check_link_status with this patch is that when
the IRQ is the result of a test request from the sink, the test handler is not
invoked during the short pulse path. Short pulse test requests are for a
particular variety of tests (mainly link training) that will be implemented
in the future. Once those tests are available, the test request handler will
be called from here as well.
V2:
- Rewored the commit message to be more clear about the content and intent
of this patch
- Restore IRQ detection logic to intel_dp_check_link_status(). Continue to
detect and clear sink IRQs in the short pulse case. Ignore test requests
in the short pulses for now since they are for future test implementations.
Signed-off-by: Todd Previte <tprevite@gmail.com>
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-04-20 15:27:34 -07:00
2013-11-27 18:21:54 -02:00
out :
2016-10-03 10:55:16 +03:00
if ( status ! = connector_status_connected & & ! intel_dp - > is_mst )
2016-03-30 18:05:22 +05:30
intel_dp_unset_edid ( intel_dp ) ;
2016-03-30 18:05:23 +05:30
2019-10-28 20:15:17 +02:00
/*
* Make sure the refs for power wells enabled during detect are
* dropped to avoid a new detect cycle triggered by HPD polling .
*/
intel_display_power_flush_work ( dev_priv ) ;
2020-04-24 18:20:52 +05:30
if ( ! intel_dp_is_edp ( intel_dp ) )
drm_dp_set_subconnector_property ( connector ,
status ,
intel_dp - > dpcd ,
intel_dp - > downstream_ports ) ;
2016-10-03 10:55:16 +03:00
return status ;
2016-03-30 18:05:22 +05:30
}
2014-09-02 20:04:00 +01:00
static void
intel_dp_force ( struct drm_connector * connector )
2009-04-07 16:16:42 -07:00
{
2019-12-04 20:05:42 +02:00
struct intel_dp * intel_dp = intel_attached_dp ( to_intel_connector ( connector ) ) ;
2018-11-01 16:04:23 +02:00
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct intel_encoder * intel_encoder = & dig_port - > base ;
2015-11-16 15:01:04 +01:00
struct drm_i915_private * dev_priv = to_i915 ( intel_encoder - > base . dev ) ;
2018-11-01 16:04:23 +02:00
enum intel_display_power_domain aux_domain =
intel_aux_power_domain ( dig_port ) ;
2019-01-14 14:21:24 +00:00
intel_wakeref_t wakeref ;
2009-04-07 16:16:42 -07:00
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " [CONNECTOR:%d:%s] \n " ,
connector - > base . id , connector - > name ) ;
2014-09-02 20:04:00 +01:00
intel_dp_unset_edid ( intel_dp ) ;
2009-04-07 16:16:42 -07:00
2014-09-02 20:04:00 +01:00
if ( connector - > status ! = connector_status_connected )
return ;
2014-03-05 16:20:53 +02:00
2019-01-14 14:21:24 +00:00
wakeref = intel_display_power_get ( dev_priv , aux_domain ) ;
2014-09-02 20:04:00 +01:00
intel_dp_set_edid ( intel_dp ) ;
2019-01-14 14:21:24 +00:00
intel_display_power_put ( dev_priv , aux_domain , wakeref ) ;
2014-09-02 20:04:00 +01:00
}
static int intel_dp_get_modes ( struct drm_connector * connector )
{
struct intel_connector * intel_connector = to_intel_connector ( connector ) ;
struct edid * edid ;
edid = intel_connector - > detect_edid ;
if ( edid ) {
int ret = intel_connector_update_modes ( connector , edid ) ;
if ( ret )
return ret ;
}
2009-07-24 01:00:32 +08:00
2012-10-19 14:51:48 +03:00
/* if eDP has no EDID, fall back to fixed mode */
2020-09-04 14:53:50 +03:00
if ( intel_dp_is_edp ( intel_attached_dp ( intel_connector ) ) & &
2014-09-02 20:04:00 +01:00
intel_connector - > panel . fixed_mode ) {
2012-10-19 14:51:48 +03:00
struct drm_display_mode * mode ;
2014-09-02 20:04:00 +01:00
mode = drm_mode_duplicate ( connector - > dev ,
2012-10-19 14:51:50 +03:00
intel_connector - > panel . fixed_mode ) ;
2012-10-19 14:51:48 +03:00
if ( mode ) {
2009-07-24 01:00:32 +08:00
drm_mode_probed_add ( connector , mode ) ;
return 1 ;
}
}
2014-09-02 20:04:00 +01:00
2020-09-04 14:53:50 +03:00
if ( ! edid ) {
struct intel_dp * intel_dp = intel_attached_dp ( intel_connector ) ;
struct drm_display_mode * mode ;
mode = drm_dp_downstream_mode ( connector - > dev ,
intel_dp - > dpcd ,
intel_dp - > downstream_ports ) ;
if ( mode ) {
drm_mode_probed_add ( connector , mode ) ;
return 1 ;
}
}
2009-07-24 01:00:32 +08:00
return 0 ;
2009-04-07 16:16:42 -07:00
}
2016-06-24 14:00:14 +01:00
static int
intel_dp_connector_register ( struct drm_connector * connector )
{
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
struct drm_i915_private * i915 = to_i915 ( connector - > dev ) ;
2019-12-04 20:05:42 +02:00
struct intel_dp * intel_dp = intel_attached_dp ( to_intel_connector ( connector ) ) ;
2020-12-01 02:17:26 +05:30
struct intel_digital_port * dig_port = dp_to_dig_port ( intel_dp ) ;
struct intel_lspcon * lspcon = & dig_port - > lspcon ;
2016-06-24 14:00:15 +01:00
int ret ;
ret = intel_connector_register ( connector ) ;
if ( ret )
return ret ;
2016-06-24 14:00:14 +01:00
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " registering %s bus for %s \n " ,
intel_dp - > aux . name , connector - > kdev - > kobj . name ) ;
2016-06-24 14:00:14 +01:00
intel_dp - > aux . dev = connector - > kdev ;
2018-07-11 15:29:09 +02:00
ret = drm_dp_aux_register ( & intel_dp - > aux ) ;
if ( ! ret )
2019-08-14 12:44:59 +02:00
drm_dp_cec_register_connector ( & intel_dp - > aux , connector ) ;
2020-12-01 02:17:26 +05:30
if ( ! intel_bios_is_lspcon_present ( i915 , dig_port - > base . port ) )
return ret ;
/*
* ToDo : Clean this up to handle lspcon init and resume more
* efficiently and streamlined .
*/
if ( lspcon_init ( dig_port ) ) {
lspcon_detect_hdr_capability ( lspcon ) ;
if ( lspcon - > hdr_supported )
drm_object_attach_property ( & connector - > base ,
connector - > dev - > mode_config . hdr_output_metadata_property ,
0 ) ;
}
2018-07-11 15:29:09 +02:00
return ret ;
2016-06-24 14:00:14 +01:00
}
2016-06-17 11:40:33 +01:00
static void
intel_dp_connector_unregister ( struct drm_connector * connector )
{
2019-12-04 20:05:42 +02:00
struct intel_dp * intel_dp = intel_attached_dp ( to_intel_connector ( connector ) ) ;
2018-07-11 15:29:09 +02:00
drm_dp_cec_unregister_connector ( & intel_dp - > aux ) ;
drm_dp_aux_unregister ( & intel_dp - > aux ) ;
2016-06-17 11:40:33 +01:00
intel_connector_unregister ( connector ) ;
}
2018-12-14 20:27:02 +02:00
void intel_dp_encoder_flush_work ( struct drm_encoder * encoder )
2010-08-20 18:08:28 +02:00
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port = enc_to_dig_port ( to_intel_encoder ( encoder ) ) ;
struct intel_dp * intel_dp = & dig_port - > dp ;
2010-08-20 18:08:28 +02:00
2020-06-30 21:50:54 -07:00
intel_dp_mst_encoder_cleanup ( dig_port ) ;
2017-08-18 12:30:20 +03:00
if ( intel_dp_is_edp ( intel_dp ) ) {
2019-01-14 14:21:26 +00:00
intel_wakeref_t wakeref ;
2011-09-18 23:09:52 -07:00
cancel_delayed_work_sync ( & intel_dp - > panel_vdd_work ) ;
2014-09-04 14:55:31 +03:00
/*
* vdd might still be enabled do to the delayed vdd off .
* Make sure vdd is actually turned off here .
*/
2021-01-08 19:44:10 +02:00
with_intel_pps_lock ( intel_dp , wakeref )
2021-01-08 19:44:13 +02:00
intel_pps_vdd_off_sync_unlocked ( intel_dp ) ;
2011-09-18 23:09:52 -07:00
}
2016-06-20 09:29:17 +01:00
intel_dp_aux_fini ( intel_dp ) ;
2018-12-14 20:27:02 +02:00
}
static void intel_dp_encoder_destroy ( struct drm_encoder * encoder )
{
intel_dp_encoder_flush_work ( encoder ) ;
2016-06-20 09:29:17 +01:00
2014-12-12 17:57:38 +02:00
drm_encoder_cleanup ( encoder ) ;
2019-12-04 20:05:43 +02:00
kfree ( enc_to_dig_port ( to_intel_encoder ( encoder ) ) ) ;
2010-08-20 18:08:28 +02:00
}
2016-04-18 10:04:21 +03:00
void intel_dp_encoder_suspend ( struct intel_encoder * intel_encoder )
2014-08-18 14:42:45 +03:00
{
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( intel_encoder ) ;
2019-01-14 14:21:26 +00:00
intel_wakeref_t wakeref ;
2014-08-18 14:42:45 +03:00
2017-08-18 12:30:20 +03:00
if ( ! intel_dp_is_edp ( intel_dp ) )
2014-08-18 14:42:45 +03:00
return ;
2014-09-04 14:55:31 +03:00
/*
* vdd might still be enabled do to the delayed vdd off .
* Make sure vdd is actually turned off here .
*/
2014-11-25 15:43:48 +02:00
cancel_delayed_work_sync ( & intel_dp - > panel_vdd_work ) ;
2021-01-08 19:44:10 +02:00
with_intel_pps_lock ( intel_dp , wakeref )
2021-01-08 19:44:13 +02:00
intel_pps_vdd_off_sync_unlocked ( intel_dp ) ;
2014-08-18 14:42:45 +03:00
}
2020-10-01 18:16:38 +03:00
void intel_dp_encoder_shutdown ( struct intel_encoder * intel_encoder )
2020-10-01 18:16:37 +03:00
{
struct intel_dp * intel_dp = enc_to_intel_dp ( intel_encoder ) ;
intel_wakeref_t wakeref ;
if ( ! intel_dp_is_edp ( intel_dp ) )
return ;
2021-01-08 19:44:10 +02:00
with_intel_pps_lock ( intel_dp , wakeref )
2020-10-01 18:16:37 +03:00
wait_panel_power_cycle ( intel_dp ) ;
}
2016-12-14 20:00:23 +02:00
static enum pipe vlv_active_pipe ( struct intel_dp * intel_dp )
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2018-05-18 18:29:28 +03:00
struct intel_encoder * encoder = & dp_to_dig_port ( intel_dp ) - > base ;
enum pipe pipe ;
2016-12-14 20:00:23 +02:00
2018-05-18 18:29:28 +03:00
if ( intel_dp_port_enabled ( dev_priv , intel_dp - > output_reg ,
encoder - > port , & pipe ) )
return pipe ;
2016-12-14 20:00:23 +02:00
2018-05-18 18:29:28 +03:00
return INVALID_PIPE ;
2016-12-14 20:00:23 +02:00
}
2016-04-18 10:04:21 +03:00
void intel_dp_encoder_reset ( struct drm_encoder * encoder )
2014-07-31 14:03:36 +03:00
{
2016-05-13 20:53:56 +03:00
struct drm_i915_private * dev_priv = to_i915 ( encoder - > dev ) ;
2019-12-04 20:05:43 +02:00
struct intel_dp * intel_dp = enc_to_intel_dp ( to_intel_encoder ( encoder ) ) ;
2019-01-14 14:21:26 +00:00
intel_wakeref_t wakeref ;
2016-05-13 20:53:56 +03:00
if ( ! HAS_DDI ( dev_priv ) )
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_dp - > DP = intel_de_read ( dev_priv , intel_dp - > output_reg ) ;
2014-10-28 16:15:52 +02:00
2017-02-07 16:54:11 -08:00
intel_dp - > reset_link_params = true ;
2019-05-09 20:34:45 +03:00
if ( ! IS_VALLEYVIEW ( dev_priv ) & & ! IS_CHERRYVIEW ( dev_priv ) & &
! intel_dp_is_edp ( intel_dp ) )
return ;
2021-01-08 19:44:10 +02:00
with_intel_pps_lock ( intel_dp , wakeref ) {
2019-01-14 14:21:26 +00:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) )
intel_dp - > active_pipe = vlv_active_pipe ( intel_dp ) ;
2014-10-28 16:15:52 +02:00
2019-01-14 14:21:26 +00:00
if ( intel_dp_is_edp ( intel_dp ) ) {
/*
* Reinit the power sequencer , in case BIOS did
* something nasty with it .
*/
intel_dp_pps_init ( intel_dp ) ;
2021-01-08 19:44:12 +02:00
intel_pps_vdd_sanitize ( intel_dp ) ;
2019-01-14 14:21:26 +00:00
}
2016-12-14 20:00:23 +02:00
}
2014-07-31 14:03:36 +03:00
}
2020-02-14 03:41:26 -08:00
static int intel_modeset_tile_group ( struct intel_atomic_state * state ,
int tile_group_id )
{
struct drm_i915_private * dev_priv = to_i915 ( state - > base . dev ) ;
struct drm_connector_list_iter conn_iter ;
struct drm_connector * connector ;
int ret = 0 ;
drm_connector_list_iter_begin ( & dev_priv - > drm , & conn_iter ) ;
drm_for_each_connector_iter ( connector , & conn_iter ) {
struct drm_connector_state * conn_state ;
struct intel_crtc_state * crtc_state ;
struct intel_crtc * crtc ;
if ( ! connector - > has_tile | |
connector - > tile_group - > id ! = tile_group_id )
continue ;
conn_state = drm_atomic_get_connector_state ( & state - > base ,
connector ) ;
if ( IS_ERR ( conn_state ) ) {
ret = PTR_ERR ( conn_state ) ;
break ;
}
crtc = to_intel_crtc ( conn_state - > crtc ) ;
if ( ! crtc )
continue ;
crtc_state = intel_atomic_get_new_crtc_state ( state , crtc ) ;
crtc_state - > uapi . mode_changed = true ;
ret = drm_atomic_add_affected_planes ( & state - > base , & crtc - > base ) ;
if ( ret )
break ;
}
2020-02-21 17:43:10 +02:00
drm_connector_list_iter_end ( & conn_iter ) ;
2020-02-14 03:41:26 -08:00
return ret ;
}
static int intel_modeset_affected_transcoders ( struct intel_atomic_state * state , u8 transcoders )
{
struct drm_i915_private * dev_priv = to_i915 ( state - > base . dev ) ;
struct intel_crtc * crtc ;
if ( transcoders = = 0 )
return 0 ;
for_each_intel_crtc ( & dev_priv - > drm , crtc ) {
struct intel_crtc_state * crtc_state ;
int ret ;
crtc_state = intel_atomic_get_crtc_state ( & state - > base , crtc ) ;
if ( IS_ERR ( crtc_state ) )
return PTR_ERR ( crtc_state ) ;
if ( ! crtc_state - > hw . enable )
continue ;
if ( ! ( transcoders & BIT ( crtc_state - > cpu_transcoder ) ) )
continue ;
crtc_state - > uapi . mode_changed = true ;
ret = drm_atomic_add_affected_connectors ( & state - > base , & crtc - > base ) ;
if ( ret )
return ret ;
ret = drm_atomic_add_affected_planes ( & state - > base , & crtc - > base ) ;
if ( ret )
return ret ;
transcoders & = ~ BIT ( crtc_state - > cpu_transcoder ) ;
}
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
drm_WARN_ON ( & dev_priv - > drm , transcoders ! = 0 ) ;
2020-02-14 03:41:26 -08:00
return 0 ;
}
static int intel_modeset_synced_crtcs ( struct intel_atomic_state * state ,
struct drm_connector * connector )
{
const struct drm_connector_state * old_conn_state =
drm_atomic_get_old_connector_state ( & state - > base , connector ) ;
const struct intel_crtc_state * old_crtc_state ;
struct intel_crtc * crtc ;
u8 transcoders ;
crtc = to_intel_crtc ( old_conn_state - > crtc ) ;
if ( ! crtc )
return 0 ;
old_crtc_state = intel_atomic_get_old_crtc_state ( state , crtc ) ;
if ( ! old_crtc_state - > hw . active )
return 0 ;
transcoders = old_crtc_state - > sync_mode_slaves_mask ;
if ( old_crtc_state - > master_transcoder ! = INVALID_TRANSCODER )
transcoders | = BIT ( old_crtc_state - > master_transcoder ) ;
return intel_modeset_affected_transcoders ( state ,
transcoders ) ;
}
static int intel_dp_connector_atomic_check ( struct drm_connector * conn ,
struct drm_atomic_state * _state )
{
struct drm_i915_private * dev_priv = to_i915 ( conn - > dev ) ;
struct intel_atomic_state * state = to_intel_atomic_state ( _state ) ;
int ret ;
ret = intel_digital_connector_atomic_check ( conn , & state - > base ) ;
if ( ret )
return ret ;
2020-03-13 18:48:26 +02:00
/*
* We don ' t enable port sync on BDW due to missing w / as and
* due to not having adjusted the modeset sequence appropriately .
*/
if ( INTEL_GEN ( dev_priv ) < 9 )
2020-02-14 03:41:26 -08:00
return 0 ;
if ( ! intel_connector_needs_modeset ( state , conn ) )
return 0 ;
if ( conn - > has_tile ) {
ret = intel_modeset_tile_group ( state , conn - > tile_group - > id ) ;
if ( ret )
return ret ;
}
return intel_modeset_synced_crtcs ( state , conn ) ;
}
2009-04-07 16:16:42 -07:00
static const struct drm_connector_funcs intel_dp_connector_funcs = {
2014-09-02 20:04:00 +01:00
. force = intel_dp_force ,
2009-04-07 16:16:42 -07:00
. fill_modes = drm_helper_probe_single_connector_modes ,
2017-05-01 15:38:01 +02:00
. atomic_get_property = intel_digital_connector_atomic_get_property ,
. atomic_set_property = intel_digital_connector_atomic_set_property ,
2016-06-24 14:00:14 +01:00
. late_register = intel_dp_connector_register ,
2016-06-17 11:40:33 +01:00
. early_unregister = intel_dp_connector_unregister ,
2018-10-09 17:11:03 +03:00
. destroy = intel_connector_destroy ,
2015-01-22 16:50:32 -08:00
. atomic_destroy_state = drm_atomic_helper_connector_destroy_state ,
2017-05-01 15:38:01 +02:00
. atomic_duplicate_state = intel_digital_connector_duplicate_state ,
2009-04-07 16:16:42 -07:00
} ;
static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = {
2017-04-06 20:55:20 +02:00
. detect_ctx = intel_dp_detect ,
2009-04-07 16:16:42 -07:00
. get_modes = intel_dp_get_modes ,
. mode_valid = intel_dp_mode_valid ,
2020-02-14 03:41:26 -08:00
. atomic_check = intel_dp_connector_atomic_check ,
2009-04-07 16:16:42 -07:00
} ;
static const struct drm_encoder_funcs intel_dp_enc_funcs = {
2014-07-31 14:03:36 +03:00
. reset = intel_dp_encoder_reset ,
2010-08-20 18:08:28 +02:00
. destroy = intel_dp_encoder_destroy ,
2009-04-07 16:16:42 -07:00
} ;
2015-01-23 06:00:31 +01:00
enum irqreturn
2020-06-30 21:50:54 -07:00
intel_dp_hpd_pulse ( struct intel_digital_port * dig_port , bool long_hpd )
2014-06-18 11:29:35 +10:00
{
2020-06-30 21:50:54 -07:00
struct drm_i915_private * i915 = to_i915 ( dig_port - > base . base . dev ) ;
struct intel_dp * intel_dp = & dig_port - > dp ;
2014-08-18 14:42:42 +03:00
2020-06-30 21:50:54 -07:00
if ( dig_port - > base . type = = INTEL_OUTPUT_EDP & &
2021-01-08 19:44:12 +02:00
( long_hpd | | ! intel_pps_have_power ( intel_dp ) ) ) {
2014-10-16 20:46:10 +03:00
/*
2020-03-18 13:48:37 +05:30
* vdd off can generate a long / short pulse on eDP which
2014-10-16 20:46:10 +03:00
* would require vdd on to handle it , and thus we
* would end up in an endless cycle of
2020-03-18 13:48:37 +05:30
* " vdd off -> long/short hpd -> vdd on -> detect -> vdd off -> ... "
2014-10-16 20:46:10 +03:00
*/
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm ,
" ignoring %s hpd on eDP [ENCODER:%d:%s] \n " ,
long_hpd ? " long " : " short " ,
2020-06-30 21:50:54 -07:00
dig_port - > base . base . base . id ,
dig_port - > base . base . name ) ;
2015-02-10 14:11:46 +02:00
return IRQ_HANDLED ;
2014-10-16 20:46:10 +03:00
}
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
drm_dbg_kms ( & i915 - > drm , " got hpd irq on [ENCODER:%d:%s] - %s \n " ,
2020-06-30 21:50:54 -07:00
dig_port - > base . base . base . id ,
dig_port - > base . base . name ,
drm/i915/dp: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200402114819.17232-4-jani.nikula@intel.com
2020-04-02 14:48:06 +03:00
long_hpd ? " long " : " short " ) ;
2014-06-18 11:29:35 +10:00
2016-10-03 10:55:15 +03:00
if ( long_hpd ) {
2017-02-07 16:54:11 -08:00
intel_dp - > reset_link_params = true ;
2016-10-03 10:55:15 +03:00
return IRQ_NONE ;
}
if ( intel_dp - > is_mst ) {
2020-06-05 12:48:01 +03:00
if ( ! intel_dp_check_mst_status ( intel_dp ) )
2019-05-09 20:34:43 +03:00
return IRQ_NONE ;
2020-06-05 12:48:01 +03:00
} else if ( ! intel_dp_short_pulse ( intel_dp ) ) {
return IRQ_NONE ;
2014-05-02 14:02:48 +10:00
}
2015-01-23 06:00:31 +01:00
2019-05-09 20:34:43 +03:00
return IRQ_HANDLED ;
2014-06-18 11:29:35 +10:00
}
2015-08-06 15:51:39 +08:00
/* check the VBT to see whether the eDP is on another port */
2017-08-18 12:30:19 +03:00
bool intel_dp_is_port_edp ( struct drm_i915_private * dev_priv , enum port port )
2010-06-12 14:32:21 +08:00
{
2015-09-11 21:04:38 +03:00
/*
* eDP not supported on g4x . so bail out early just
* for a bit extra safety in case the VBT is bonkers .
*/
2016-11-16 08:55:41 +00:00
if ( INTEL_GEN ( dev_priv ) < 5 )
2015-09-11 21:04:38 +03:00
return false ;
2016-12-21 12:17:24 +02:00
if ( INTEL_GEN ( dev_priv ) < 9 & & port = = PORT_A )
2013-11-01 18:22:41 +02:00
return true ;
2016-03-16 12:43:31 +02:00
return intel_bios_is_port_edp ( dev_priv , port ) ;
2010-06-12 14:32:21 +08:00
}
2017-04-10 12:51:10 +02:00
static void
2010-09-19 09:29:33 +01:00
intel_dp_add_properties ( struct intel_dp * intel_dp , struct drm_connector * connector )
{
2017-05-01 15:37:56 +02:00
struct drm_i915_private * dev_priv = to_i915 ( connector - > dev ) ;
2017-11-29 18:43:02 +02:00
enum port port = dp_to_dig_port ( intel_dp ) - > base . port ;
2020-04-24 18:20:52 +05:30
if ( ! intel_dp_is_edp ( intel_dp ) )
drm_connector_attach_dp_subconnector_property ( connector ) ;
2017-11-29 18:43:02 +02:00
if ( ! IS_G4X ( dev_priv ) & & port ! = PORT_A )
intel_attach_force_audio_property ( connector ) ;
2017-05-01 15:37:56 +02:00
2011-02-21 22:23:52 +00:00
intel_attach_broadcast_rgb_property ( connector ) ;
2019-02-04 14:25:38 -08:00
if ( HAS_GMCH ( dev_priv ) )
2018-10-22 18:44:00 -07:00
drm_connector_attach_max_bpc_property ( connector , 6 , 10 ) ;
else if ( INTEL_GEN ( dev_priv ) > = 5 )
drm_connector_attach_max_bpc_property ( connector , 6 , 12 ) ;
2012-10-26 12:04:00 +03:00
2020-12-01 02:17:31 +05:30
/* Register HDMI colorspace for case of lspcon */
if ( intel_bios_is_lspcon_present ( dev_priv , port ) ) {
2020-12-01 02:17:29 +05:30
drm_connector_attach_content_type_property ( connector ) ;
2020-12-01 02:17:31 +05:30
intel_attach_hdmi_colorspace_property ( connector ) ;
} else {
intel_attach_dp_colorspace_property ( connector ) ;
}
2019-09-19 22:53:08 +03:00
2019-09-19 22:53:11 +03:00
if ( IS_GEMINILAKE ( dev_priv ) | | INTEL_GEN ( dev_priv ) > = 11 )
drm_object_attach_property ( & connector - > base ,
connector - > dev - > mode_config . hdr_output_metadata_property ,
0 ) ;
2017-08-18 12:30:20 +03:00
if ( intel_dp_is_edp ( intel_dp ) ) {
2017-05-01 15:37:56 +02:00
u32 allowed_scalers ;
allowed_scalers = BIT ( DRM_MODE_SCALE_ASPECT ) | BIT ( DRM_MODE_SCALE_FULLSCREEN ) ;
2019-02-04 14:25:38 -08:00
if ( ! HAS_GMCH ( dev_priv ) )
2017-05-01 15:37:56 +02:00
allowed_scalers | = BIT ( DRM_MODE_SCALE_CENTER ) ;
drm_connector_attach_scaling_mode_property ( connector , allowed_scalers ) ;
2017-05-01 15:37:55 +02:00
connector - > state - > scaling_mode = DRM_MODE_SCALE_ASPECT ;
2017-05-01 15:37:56 +02:00
2012-10-26 12:04:00 +03:00
}
2010-09-19 09:29:33 +01:00
}
2015-02-13 15:33:03 +05:30
/**
* intel_dp_set_drrs_state - program registers for RR switch to take effect
2016-08-31 11:01:36 +02:00
* @ dev_priv : i915 device
2016-08-25 11:07:02 +02:00
* @ crtc_state : a pointer to the active intel_crtc_state
2015-02-13 15:33:03 +05:30
* @ refresh_rate : RR to be programmed
*
* This function gets called when refresh rate ( RR ) has to be changed from
* one frequency to another . Switches can be between high and low RR
* supported by the panel or to any other RR based on media playback ( in
* this case , RR value needs to be passed from user space ) .
*
* The caller of this function needs to take a lock on dev_priv - > drrs .
*/
2016-08-09 17:04:13 +02:00
static void intel_dp_set_drrs_state ( struct drm_i915_private * dev_priv ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * crtc_state ,
2016-08-09 17:04:13 +02:00
int refresh_rate )
2014-04-05 12:13:28 +05:30
{
2015-01-10 02:25:56 +05:30
struct intel_dp * intel_dp = dev_priv - > drrs . dp ;
2019-10-31 12:26:03 +01:00
struct intel_crtc * intel_crtc = to_intel_crtc ( crtc_state - > uapi . crtc ) ;
2015-01-10 02:25:56 +05:30
enum drrs_refresh_rate_type index = DRRS_HIGH_RR ;
2014-04-05 12:13:28 +05:30
if ( refresh_rate < = 0 ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" Refresh rate should be positive non-zero. \n " ) ;
2014-04-05 12:13:28 +05:30
return ;
}
2015-01-10 02:25:56 +05:30
if ( intel_dp = = NULL ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " DRRS not supported. \n " ) ;
2014-04-05 12:13:28 +05:30
return ;
}
if ( ! intel_crtc ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" DRRS: intel_crtc not initialized \n " ) ;
2014-04-05 12:13:28 +05:30
return ;
}
2015-01-10 02:25:56 +05:30
if ( dev_priv - > drrs . type < SEAMLESS_DRRS_SUPPORT ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " Only Seamless DRRS supported. \n " ) ;
2014-04-05 12:13:28 +05:30
return ;
}
2020-04-28 20:19:27 +03:00
if ( drm_mode_vrefresh ( intel_dp - > attached_connector - > panel . downclock_mode ) = =
2015-01-10 02:25:56 +05:30
refresh_rate )
2014-04-05 12:13:28 +05:30
index = DRRS_LOW_RR ;
2015-01-10 02:25:56 +05:30
if ( index = = dev_priv - > drrs . refresh_rate_type ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" DRRS requested for previously set RR...ignoring \n " ) ;
2014-04-05 12:13:28 +05:30
return ;
}
2019-10-31 12:26:02 +01:00
if ( ! crtc_state - > hw . active ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" eDP encoder disabled. CRTC not Active \n " ) ;
2014-04-05 12:13:28 +05:30
return ;
}
2016-08-09 17:04:13 +02:00
if ( INTEL_GEN ( dev_priv ) > = 8 & & ! IS_CHERRYVIEW ( dev_priv ) ) {
2015-02-13 15:33:00 +05:30
switch ( index ) {
case DRRS_HIGH_RR :
2018-10-11 12:04:49 +02:00
intel_dp_set_m_n ( crtc_state , M1_N1 ) ;
2015-02-13 15:33:00 +05:30
break ;
case DRRS_LOW_RR :
2018-10-11 12:04:49 +02:00
intel_dp_set_m_n ( crtc_state , M2_N2 ) ;
2015-02-13 15:33:00 +05:30
break ;
case DRRS_MAX_RR :
default :
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_err ( & dev_priv - > drm ,
" Unsupported refreshrate type \n " ) ;
2015-02-13 15:33:00 +05:30
}
2016-08-09 17:04:13 +02:00
} else if ( INTEL_GEN ( dev_priv ) > 6 ) {
i915_reg_t reg = PIPECONF ( crtc_state - > cpu_transcoder ) ;
2015-09-22 19:50:01 +03:00
u32 val ;
2015-02-13 15:33:00 +05:30
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
val = intel_de_read ( dev_priv , reg ) ;
2014-04-05 12:13:28 +05:30
if ( index > DRRS_HIGH_RR ) {
2016-08-09 17:04:13 +02:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) )
2015-02-13 15:33:01 +05:30
val | = PIPECONF_EDP_RR_MODE_SWITCH_VLV ;
else
val | = PIPECONF_EDP_RR_MODE_SWITCH ;
2014-04-05 12:13:28 +05:30
} else {
2016-08-09 17:04:13 +02:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) )
2015-02-13 15:33:01 +05:30
val & = ~ PIPECONF_EDP_RR_MODE_SWITCH_VLV ;
else
val & = ~ PIPECONF_EDP_RR_MODE_SWITCH ;
2014-04-05 12:13:28 +05:30
}
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_de_write ( dev_priv , reg , val ) ;
2014-04-05 12:13:28 +05:30
}
2015-01-22 15:14:45 +05:30
dev_priv - > drrs . refresh_rate_type = index ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " eDP Refresh Rate set to : %dHz \n " ,
refresh_rate ) ;
2015-01-22 15:14:45 +05:30
}
2020-08-25 10:13:30 -07:00
static void
intel_edp_drrs_enable_locked ( struct intel_dp * intel_dp )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
dev_priv - > drrs . busy_frontbuffer_bits = 0 ;
dev_priv - > drrs . dp = intel_dp ;
}
2015-02-13 15:33:03 +05:30
/**
* intel_edp_drrs_enable - init drrs struct if supported
* @ intel_dp : DP struct
2016-08-31 11:01:36 +02:00
* @ crtc_state : A pointer to the active crtc state .
2015-02-13 15:33:03 +05:30
*
* Initializes frontbuffer_bits and drrs . dp
*/
2016-08-09 17:04:13 +02:00
void intel_edp_drrs_enable ( struct intel_dp * intel_dp ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * crtc_state )
2015-01-22 15:17:40 +05:30
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2015-01-22 15:17:40 +05:30
2020-08-25 10:13:29 -07:00
if ( ! crtc_state - > has_drrs )
2015-01-22 15:17:40 +05:30
return ;
2020-08-25 10:13:29 -07:00
drm_dbg_kms ( & dev_priv - > drm , " Enabling DRRS \n " ) ;
2017-09-14 11:16:41 -07:00
2015-01-22 15:17:40 +05:30
mutex_lock ( & dev_priv - > drrs . mutex ) ;
2020-08-25 10:13:30 -07:00
2018-12-20 14:21:19 +01:00
if ( dev_priv - > drrs . dp ) {
2020-08-25 10:13:30 -07:00
drm_warn ( & dev_priv - > drm , " DRRS already enabled \n " ) ;
2015-01-22 15:17:40 +05:30
goto unlock ;
}
2020-08-25 10:13:30 -07:00
intel_edp_drrs_enable_locked ( intel_dp ) ;
2015-01-22 15:17:40 +05:30
unlock :
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
}
2020-08-25 10:13:30 -07:00
static void
intel_edp_drrs_disable_locked ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
if ( dev_priv - > drrs . refresh_rate_type = = DRRS_LOW_RR ) {
int refresh ;
refresh = drm_mode_vrefresh ( intel_dp - > attached_connector - > panel . fixed_mode ) ;
intel_dp_set_drrs_state ( dev_priv , crtc_state , refresh ) ;
}
dev_priv - > drrs . dp = NULL ;
}
2015-02-13 15:33:03 +05:30
/**
* intel_edp_drrs_disable - Disable DRRS
* @ intel_dp : DP struct
2016-08-31 11:01:36 +02:00
* @ old_crtc_state : Pointer to old crtc_state .
2015-02-13 15:33:03 +05:30
*
*/
2016-08-09 17:04:13 +02:00
void intel_edp_drrs_disable ( struct intel_dp * intel_dp ,
2017-08-18 16:49:58 +03:00
const struct intel_crtc_state * old_crtc_state )
2015-01-22 15:17:40 +05:30
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
2015-01-22 15:17:40 +05:30
2016-08-09 17:04:13 +02:00
if ( ! old_crtc_state - > has_drrs )
2015-01-22 15:17:40 +05:30
return ;
mutex_lock ( & dev_priv - > drrs . mutex ) ;
if ( ! dev_priv - > drrs . dp ) {
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
return ;
}
2020-08-25 10:13:30 -07:00
intel_edp_drrs_disable_locked ( intel_dp , old_crtc_state ) ;
2015-01-22 15:17:40 +05:30
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
cancel_delayed_work_sync ( & dev_priv - > drrs . work ) ;
}
2020-08-25 10:13:30 -07:00
/**
* intel_edp_drrs_update - Update DRRS state
* @ intel_dp : Intel DP
* @ crtc_state : new CRTC state
*
* This function will update DRRS states , disabling or enabling DRRS when
* executing fastsets . For full modeset , intel_edp_drrs_disable ( ) and
* intel_edp_drrs_enable ( ) should be called instead .
*/
void
intel_edp_drrs_update ( struct intel_dp * intel_dp ,
const struct intel_crtc_state * crtc_state )
{
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
if ( dev_priv - > drrs . type ! = SEAMLESS_DRRS_SUPPORT )
return ;
mutex_lock ( & dev_priv - > drrs . mutex ) ;
/* New state matches current one? */
if ( crtc_state - > has_drrs = = ! ! dev_priv - > drrs . dp )
goto unlock ;
if ( crtc_state - > has_drrs )
intel_edp_drrs_enable_locked ( intel_dp ) ;
else
intel_edp_drrs_disable_locked ( intel_dp , crtc_state ) ;
unlock :
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
}
2015-01-22 15:14:45 +05:30
static void intel_edp_drrs_downclock_work ( struct work_struct * work )
{
struct drm_i915_private * dev_priv =
container_of ( work , typeof ( * dev_priv ) , drrs . work . work ) ;
struct intel_dp * intel_dp ;
mutex_lock ( & dev_priv - > drrs . mutex ) ;
intel_dp = dev_priv - > drrs . dp ;
if ( ! intel_dp )
goto unlock ;
2014-04-05 12:13:28 +05:30
/*
2015-01-22 15:14:45 +05:30
* The delayed work can race with an invalidate hence we need to
* recheck .
2014-04-05 12:13:28 +05:30
*/
2015-01-22 15:14:45 +05:30
if ( dev_priv - > drrs . busy_frontbuffer_bits )
goto unlock ;
2014-04-05 12:13:28 +05:30
2016-08-09 17:04:13 +02:00
if ( dev_priv - > drrs . refresh_rate_type ! = DRRS_LOW_RR ) {
struct drm_crtc * crtc = dp_to_dig_port ( intel_dp ) - > base . base . crtc ;
intel_dp_set_drrs_state ( dev_priv , to_intel_crtc ( crtc ) - > config ,
2020-04-28 20:19:27 +03:00
drm_mode_vrefresh ( intel_dp - > attached_connector - > panel . downclock_mode ) ) ;
2016-08-09 17:04:13 +02:00
}
2014-04-05 12:13:28 +05:30
2015-01-22 15:14:45 +05:30
unlock :
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
2014-04-05 12:13:28 +05:30
}
2015-02-13 15:33:03 +05:30
/**
2015-06-15 20:50:05 +05:30
* intel_edp_drrs_invalidate - Disable Idleness DRRS
2016-08-04 16:32:38 +01:00
* @ dev_priv : i915 device
2015-02-13 15:33:03 +05:30
* @ frontbuffer_bits : frontbuffer plane tracking bits
*
2015-06-15 20:50:05 +05:30
* This function gets called everytime rendering on the given planes start .
* Hence DRRS needs to be Upclocked , i . e . ( LOW_RR - > HIGH_RR ) .
2015-02-13 15:33:03 +05:30
*
* Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bits .
*/
2016-08-04 16:32:38 +01:00
void intel_edp_drrs_invalidate ( struct drm_i915_private * dev_priv ,
unsigned int frontbuffer_bits )
2015-01-10 02:25:59 +05:30
{
2020-04-28 20:19:26 +03:00
struct intel_dp * intel_dp ;
2015-01-10 02:25:59 +05:30
struct drm_crtc * crtc ;
enum pipe pipe ;
2015-04-09 16:44:15 +02:00
if ( dev_priv - > drrs . type = = DRRS_NOT_SUPPORTED )
2015-01-10 02:25:59 +05:30
return ;
2015-04-09 16:44:16 +02:00
cancel_delayed_work ( & dev_priv - > drrs . work ) ;
2015-03-03 12:11:46 +05:30
2015-01-10 02:25:59 +05:30
mutex_lock ( & dev_priv - > drrs . mutex ) ;
2020-04-28 20:19:26 +03:00
intel_dp = dev_priv - > drrs . dp ;
if ( ! intel_dp ) {
2015-04-09 16:44:15 +02:00
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
return ;
}
2020-04-28 20:19:26 +03:00
crtc = dp_to_dig_port ( intel_dp ) - > base . base . crtc ;
2015-01-10 02:25:59 +05:30
pipe = to_intel_crtc ( crtc ) - > pipe ;
2015-06-18 10:30:25 +02:00
frontbuffer_bits & = INTEL_FRONTBUFFER_ALL_MASK ( pipe ) ;
dev_priv - > drrs . busy_frontbuffer_bits | = frontbuffer_bits ;
2015-06-15 20:50:05 +05:30
/* invalidate means busy screen hence upclock */
2015-06-18 10:30:25 +02:00
if ( frontbuffer_bits & & dev_priv - > drrs . refresh_rate_type = = DRRS_LOW_RR )
2016-08-09 17:04:13 +02:00
intel_dp_set_drrs_state ( dev_priv , to_intel_crtc ( crtc ) - > config ,
2020-04-28 20:19:27 +03:00
drm_mode_vrefresh ( intel_dp - > attached_connector - > panel . fixed_mode ) ) ;
2015-01-10 02:25:59 +05:30
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
}
2015-02-13 15:33:03 +05:30
/**
2015-06-15 20:50:05 +05:30
* intel_edp_drrs_flush - Restart Idleness DRRS
2016-08-04 16:32:38 +01:00
* @ dev_priv : i915 device
2015-02-13 15:33:03 +05:30
* @ frontbuffer_bits : frontbuffer plane tracking bits
*
2015-06-15 20:50:05 +05:30
* This function gets called every time rendering on the given planes has
* completed or flip on a crtc is completed . So DRRS should be upclocked
* ( LOW_RR - > HIGH_RR ) . And also Idleness detection should be started again ,
* if no other planes are dirty .
2015-02-13 15:33:03 +05:30
*
* Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bits .
*/
2016-08-04 16:32:38 +01:00
void intel_edp_drrs_flush ( struct drm_i915_private * dev_priv ,
unsigned int frontbuffer_bits )
2015-01-10 02:25:59 +05:30
{
2020-04-28 20:19:26 +03:00
struct intel_dp * intel_dp ;
2015-01-10 02:25:59 +05:30
struct drm_crtc * crtc ;
enum pipe pipe ;
2015-04-09 16:44:15 +02:00
if ( dev_priv - > drrs . type = = DRRS_NOT_SUPPORTED )
2015-01-10 02:25:59 +05:30
return ;
2015-04-09 16:44:16 +02:00
cancel_delayed_work ( & dev_priv - > drrs . work ) ;
2015-03-03 12:11:46 +05:30
2015-01-10 02:25:59 +05:30
mutex_lock ( & dev_priv - > drrs . mutex ) ;
2020-04-28 20:19:26 +03:00
intel_dp = dev_priv - > drrs . dp ;
if ( ! intel_dp ) {
2015-04-09 16:44:15 +02:00
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
return ;
}
2020-04-28 20:19:26 +03:00
crtc = dp_to_dig_port ( intel_dp ) - > base . base . crtc ;
2015-01-10 02:25:59 +05:30
pipe = to_intel_crtc ( crtc ) - > pipe ;
2015-06-18 10:30:25 +02:00
frontbuffer_bits & = INTEL_FRONTBUFFER_ALL_MASK ( pipe ) ;
2015-01-10 02:25:59 +05:30
dev_priv - > drrs . busy_frontbuffer_bits & = ~ frontbuffer_bits ;
2015-06-15 20:50:05 +05:30
/* flush means busy screen hence upclock */
2015-06-18 10:30:25 +02:00
if ( frontbuffer_bits & & dev_priv - > drrs . refresh_rate_type = = DRRS_LOW_RR )
2016-08-09 17:04:13 +02:00
intel_dp_set_drrs_state ( dev_priv , to_intel_crtc ( crtc ) - > config ,
2020-04-28 20:19:27 +03:00
drm_mode_vrefresh ( intel_dp - > attached_connector - > panel . fixed_mode ) ) ;
2015-06-15 20:50:05 +05:30
/*
* flush also means no more activity hence schedule downclock , if all
* other fbs are quiescent too
*/
if ( ! dev_priv - > drrs . busy_frontbuffer_bits )
2015-01-10 02:25:59 +05:30
schedule_delayed_work ( & dev_priv - > drrs . work ,
msecs_to_jiffies ( 1000 ) ) ;
mutex_unlock ( & dev_priv - > drrs . mutex ) ;
}
2015-02-13 15:33:03 +05:30
/**
* DOC : Display Refresh Rate Switching ( DRRS )
*
* Display Refresh Rate Switching ( DRRS ) is a power conservation feature
* which enables swtching between low and high refresh rates ,
* dynamically , based on the usage scenario . This feature is applicable
* for internal panels .
*
* Indication that the panel supports DRRS is given by the panel EDID , which
* would list multiple refresh rates for one resolution .
*
* DRRS is of 2 types - static and seamless .
* Static DRRS involves changing refresh rate ( RR ) by doing a full modeset
* ( may appear as a blink on screen ) and is used in dock - undock scenario .
* Seamless DRRS involves changing RR without any visual effect to the user
* and can be used during normal system usage . This is done by programming
* certain registers .
*
* Support for static / seamless DRRS may be indicated in the VBT based on
* inputs from the panel spec .
*
* DRRS saves power by switching to low RR based on usage scenarios .
*
2016-06-01 23:40:36 +02:00
* The implementation is based on frontbuffer tracking implementation . When
* there is a disturbance on the screen triggered by user activity or a periodic
* system activity , DRRS is disabled ( RR is changed to high RR ) . When there is
* no movement on screen , after a timeout of 1 second , a switch to low RR is
* made .
*
* For integration with frontbuffer tracking code , intel_edp_drrs_invalidate ( )
* and intel_edp_drrs_flush ( ) are called .
2015-02-13 15:33:03 +05:30
*
* DRRS can be further extended to support other internal panels and also
* the scenario of video playback wherein RR is set based on the rate
* requested by userspace .
*/
/**
* intel_dp_drrs_init - Init basic DRRS work and mutex .
2017-11-09 17:27:58 +02:00
* @ connector : eDP connector
2015-02-13 15:33:03 +05:30
* @ fixed_mode : preferred mode of panel
*
* This function is called only once at driver load to initialize basic
* DRRS stuff .
*
* Returns :
* Downclock mode if panel supports it , else return NULL .
* DRRS support is determined by the presence of downclock mode ( apart
* from VBT setting ) .
*/
2014-04-05 12:12:31 +05:30
static struct drm_display_mode *
2017-11-09 17:27:58 +02:00
intel_dp_drrs_init ( struct intel_connector * connector ,
struct drm_display_mode * fixed_mode )
2014-04-05 12:12:31 +05:30
{
2017-11-09 17:27:58 +02:00
struct drm_i915_private * dev_priv = to_i915 ( connector - > base . dev ) ;
2014-04-05 12:12:31 +05:30
struct drm_display_mode * downclock_mode = NULL ;
2015-04-09 16:44:15 +02:00
INIT_DELAYED_WORK ( & dev_priv - > drrs . work , intel_edp_drrs_downclock_work ) ;
mutex_init ( & dev_priv - > drrs . mutex ) ;
2016-11-16 08:55:41 +00:00
if ( INTEL_GEN ( dev_priv ) < = 6 ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" DRRS supported for Gen7 and above \n " ) ;
2014-04-05 12:12:31 +05:30
return NULL ;
}
if ( dev_priv - > vbt . drrs_type ! = SEAMLESS_DRRS_SUPPORT ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm , " VBT doesn't support DRRS \n " ) ;
2014-04-05 12:12:31 +05:30
return NULL ;
}
2019-03-21 15:24:46 +02:00
downclock_mode = intel_panel_edid_downclock_mode ( connector , fixed_mode ) ;
2014-04-05 12:12:31 +05:30
if ( ! downclock_mode ) {
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" Downclock mode is not found. DRRS not supported \n " ) ;
2014-04-05 12:12:31 +05:30
return NULL ;
}
2015-01-10 02:25:56 +05:30
dev_priv - > drrs . type = dev_priv - > vbt . drrs_type ;
2014-04-05 12:12:31 +05:30
2015-01-10 02:25:56 +05:30
dev_priv - > drrs . refresh_rate_type = DRRS_HIGH_RR ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" seamless DRRS supported for eDP panel. \n " ) ;
2014-04-05 12:12:31 +05:30
return downclock_mode ;
}
2013-06-12 17:27:24 -03:00
static bool intel_edp_init_connector ( struct intel_dp * intel_dp ,
2014-10-16 21:27:30 +03:00
struct intel_connector * intel_connector )
2013-06-12 17:27:24 -03:00
{
2018-08-27 15:30:20 -07:00
struct drm_i915_private * dev_priv = dp_to_i915 ( intel_dp ) ;
struct drm_device * dev = & dev_priv - > drm ;
2017-11-09 17:27:58 +02:00
struct drm_connector * connector = & intel_connector - > base ;
2013-06-12 17:27:24 -03:00
struct drm_display_mode * fixed_mode = NULL ;
2014-04-05 12:12:31 +05:30
struct drm_display_mode * downclock_mode = NULL ;
2013-06-12 17:27:24 -03:00
bool has_dpcd ;
2014-11-07 11:16:02 +02:00
enum pipe pipe = INVALID_PIPE ;
2019-01-14 14:21:26 +00:00
intel_wakeref_t wakeref ;
struct edid * edid ;
2013-06-12 17:27:24 -03:00
2017-08-18 12:30:20 +03:00
if ( ! intel_dp_is_edp ( intel_dp ) )
2013-06-12 17:27:24 -03:00
return true ;
2018-10-30 14:57:49 -07:00
INIT_DELAYED_WORK ( & intel_dp - > panel_vdd_work , edp_panel_vdd_work ) ;
2016-06-21 11:51:47 +03:00
/*
* On IBX / CPT we may get here with LVDS already registered . Since the
* driver uses the only internal power sequencer available for both
* eDP and LVDS bail out early in this case to prevent interfering
* with an already powered - on LVDS power sequencer .
*/
2019-03-18 22:26:52 +02:00
if ( intel_get_lvds_encoder ( dev_priv ) ) {
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
drm_WARN_ON ( dev ,
! ( HAS_PCH_IBX ( dev_priv ) | | HAS_PCH_CPT ( dev_priv ) ) ) ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_info ( & dev_priv - > drm ,
" LVDS was detected, not registering eDP \n " ) ;
2016-06-21 11:51:47 +03:00
return false ;
}
2021-01-08 19:44:10 +02:00
with_intel_pps_lock ( intel_dp , wakeref ) {
2019-01-14 14:21:26 +00:00
intel_dp_init_panel_power_timestamps ( intel_dp ) ;
intel_dp_pps_init ( intel_dp ) ;
2021-01-08 19:44:12 +02:00
intel_pps_vdd_sanitize ( intel_dp ) ;
2019-01-14 14:21:26 +00:00
}
2014-04-22 19:55:42 -03:00
2013-06-12 17:27:24 -03:00
/* Cache DPCD and EDID for edp. */
2016-07-29 16:52:39 +03:00
has_dpcd = intel_edp_init_dpcd ( intel_dp ) ;
2013-06-12 17:27:24 -03:00
2016-07-29 16:52:39 +03:00
if ( ! has_dpcd ) {
2013-06-12 17:27:24 -03:00
/* if this fails, presume the device is a ghost */
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_info ( & dev_priv - > drm ,
" failed to retrieve link info, disabling eDP \n " ) ;
2016-06-21 11:51:49 +03:00
goto out_vdd_off ;
2013-06-12 17:27:24 -03:00
}
2014-03-21 23:22:35 +01:00
mutex_lock ( & dev - > mode_config . mutex ) ;
2014-03-14 16:51:17 +02:00
edid = drm_get_edid ( connector , & intel_dp - > aux . ddc ) ;
2013-06-12 17:27:24 -03:00
if ( edid ) {
if ( drm_add_edid_modes ( connector , edid ) ) {
2020-02-11 13:33:46 -05:00
drm_connector_update_edid_property ( connector , edid ) ;
intel_dp - > edid_quirks = drm_dp_get_edid_quirks ( edid ) ;
2013-06-12 17:27:24 -03:00
} else {
kfree ( edid ) ;
edid = ERR_PTR ( - EINVAL ) ;
}
} else {
edid = ERR_PTR ( - ENOENT ) ;
}
intel_connector - > edid = edid ;
2019-03-21 15:24:41 +02:00
fixed_mode = intel_panel_edid_fixed_mode ( intel_connector ) ;
if ( fixed_mode )
downclock_mode = intel_dp_drrs_init ( intel_connector , fixed_mode ) ;
2013-06-12 17:27:24 -03:00
/* fallback to VBT if available for eDP */
2019-03-21 15:24:43 +02:00
if ( ! fixed_mode )
fixed_mode = intel_panel_vbt_fixed_mode ( intel_connector ) ;
2014-03-21 23:22:35 +01:00
mutex_unlock ( & dev - > mode_config . mutex ) ;
2013-06-12 17:27:24 -03:00
2016-10-14 10:13:44 +01:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) ) {
2014-11-07 11:16:02 +02:00
/*
* Figure out the current pipe for the initial backlight setup .
* If the current pipe isn ' t valid , try the PPS pipe , and if that
* fails just assume pipe A .
*/
2016-12-14 20:00:23 +02:00
pipe = vlv_active_pipe ( intel_dp ) ;
2014-11-07 11:16:02 +02:00
if ( pipe ! = PIPE_A & & pipe ! = PIPE_B )
pipe = intel_dp - > pps_pipe ;
if ( pipe ! = PIPE_A & & pipe ! = PIPE_B )
pipe = PIPE_A ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" using pipe %c for initial backlight setup \n " ,
pipe_name ( pipe ) ) ;
2014-07-07 13:01:46 -07:00
}
Revert "drm/i915/edp: Allow alternate fixed mode for eDP if available."
This reverts commit dc911f5bd8aacfcf8aabd5c26c88e04c837a938e.
Per the report, no matter what display mode you select with xrandr, the
i915 driver will always select the alternate fixed mode. For the
reporter this means that the display will always run at 40Hz which is
quite annoying. This may be due to the mode comparison.
But there are some other potential issues. The choice of alt_fixed_mode
seems dubious. It's the first non-preferred mode, but there are no
guarantees that the only difference would be refresh rate. Similarly,
there may be more than one preferred mode in the probed modes list, and
the commit changes the preferred mode selection to choose the last one
on the list instead of the first.
(Note that the probed modes list is the raw, unfiltered, unsorted list
of modes from drm_add_edid_modes(), not the pretty result after a
drm_helper_probe_single_connector_modes() call.)
Finally, we already have eerily similar code in place to find the
downclock mode for DRRS that seems like could be reused here.
Back to the drawing board.
Note: This is a hand-crafted revert due to conflicts. If it fails to
backport, please just try reverting the original commit directly.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105469
Reported-by: Rune Petersen <rune@megahurts.dk>
Reported-by: Mark Spencer <n7u4722r35@ynzlx.anonbox.net>
Fixes: dc911f5bd8aa ("drm/i915/edp: Allow alternate fixed mode for eDP if available.")
Cc: Clint Taylor <clinton.a.taylor@intel.com>
Cc: David Weinehall <david.weinehall@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jim Bride <jim.bride@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180516080110.22770-1-jani.nikula@intel.com
2018-05-16 11:01:10 +03:00
intel_panel_init ( & intel_connector - > panel , fixed_mode , downclock_mode ) ;
2021-01-08 19:44:11 +02:00
intel_connector - > panel . backlight . power = intel_pps_backlight_power ;
2014-11-07 11:16:02 +02:00
intel_panel_setup_backlight ( connector , pipe ) ;
2013-06-12 17:27:24 -03:00
2020-01-05 16:51:19 +01:00
if ( fixed_mode ) {
drm_connector_set_panel_orientation_with_quirk ( connector ,
2020-02-28 12:41:10 +01:00
dev_priv - > vbt . orientation ,
2020-01-05 16:51:19 +01:00
fixed_mode - > hdisplay , fixed_mode - > vdisplay ) ;
}
2018-09-09 15:34:56 +02:00
2013-06-12 17:27:24 -03:00
return true ;
2016-06-21 11:51:49 +03:00
out_vdd_off :
cancel_delayed_work_sync ( & intel_dp - > panel_vdd_work ) ;
/*
* vdd might still be enabled do to the delayed vdd off .
* Make sure vdd is actually turned off here .
*/
2021-01-08 19:44:10 +02:00
with_intel_pps_lock ( intel_dp , wakeref )
2021-01-08 19:44:13 +02:00
intel_pps_vdd_off_sync_unlocked ( intel_dp ) ;
2016-06-21 11:51:49 +03:00
return false ;
2013-06-12 17:27:24 -03:00
}
2017-04-06 16:44:19 +03:00
static void intel_dp_modeset_retry_work_fn ( struct work_struct * work )
{
struct intel_connector * intel_connector ;
struct drm_connector * connector ;
intel_connector = container_of ( work , typeof ( * intel_connector ) ,
modeset_retry_work ) ;
connector = & intel_connector - > base ;
DRM_DEBUG_KMS ( " [CONNECTOR:%d:%s] \n " , connector - > base . id ,
connector - > name ) ;
/* Grab the locks before changing connector property*/
mutex_lock ( & connector - > dev - > mode_config . mutex ) ;
/* Set connector link status to BAD and send a Uevent to notify
* userspace to do a modeset .
*/
2018-07-09 10:40:08 +02:00
drm_connector_set_link_status_property ( connector ,
DRM_MODE_LINK_STATUS_BAD ) ;
2017-04-06 16:44:19 +03:00
mutex_unlock ( & connector - > dev - > mode_config . mutex ) ;
/* Send Hotplug uevent so userspace can reprobe */
drm_kms_helper_hotplug_event ( connector - > dev ) ;
}
2013-06-12 17:27:25 -03:00
bool
2020-06-30 21:50:54 -07:00
intel_dp_init_connector ( struct intel_digital_port * dig_port ,
2012-10-26 19:05:48 -02:00
struct intel_connector * intel_connector )
2009-04-07 16:16:42 -07:00
{
2012-10-26 19:05:48 -02:00
struct drm_connector * connector = & intel_connector - > base ;
2020-06-30 21:50:54 -07:00
struct intel_dp * intel_dp = & dig_port - > dp ;
struct intel_encoder * intel_encoder = & dig_port - > base ;
2012-10-26 19:05:48 -02:00
struct drm_device * dev = intel_encoder - > base . dev ;
2016-07-04 11:34:36 +01:00
struct drm_i915_private * dev_priv = to_i915 ( dev ) ;
2017-11-09 17:24:34 +02:00
enum port port = intel_encoder - > port ;
2019-07-09 11:39:33 -07:00
enum phy phy = intel_port_to_phy ( dev_priv , port ) ;
2016-06-24 14:00:14 +01:00
int type ;
2009-04-07 16:16:42 -07:00
2017-04-06 16:44:19 +03:00
/* Initialize the work for modeset in case of link train failure */
INIT_WORK ( & intel_connector - > modeset_retry_work ,
intel_dp_modeset_retry_work_fn ) ;
2020-06-30 21:50:54 -07:00
if ( drm_WARN ( dev , dig_port - > max_lanes < 1 ,
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
" Not enough lanes (%d) for DP on [ENCODER:%d:%s] \n " ,
2020-06-30 21:50:54 -07:00
dig_port - > max_lanes , intel_encoder - > base . base . id ,
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
intel_encoder - > base . name ) )
2015-12-08 19:59:38 +02:00
return false ;
2020-07-02 16:09:57 -07:00
intel_dp_set_source_rates ( intel_dp ) ;
2017-02-07 16:54:11 -08:00
intel_dp - > reset_link_params = true ;
2014-09-04 14:54:20 +03:00
intel_dp - > pps_pipe = INVALID_PIPE ;
2016-12-14 20:00:23 +02:00
intel_dp - > active_pipe = INVALID_PIPE ;
2014-09-04 14:54:20 +03:00
2012-09-06 22:15:42 +02:00
/* Preserve the current hw state. */
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
intel_dp - > DP = intel_de_read ( dev_priv , intel_dp - > output_reg ) ;
2012-10-19 14:51:50 +03:00
intel_dp - > attached_connector = intel_connector ;
2011-02-12 10:33:12 +00:00
2019-05-09 20:34:46 +03:00
if ( intel_dp_is_port_edp ( dev_priv , port ) ) {
/*
* Currently we don ' t support eDP on TypeC ports , although in
* theory it could work on TypeC legacy ports .
*/
drm/i915/display/dp: Make WARN* drm specific where drm_device ptr is available
drm specific WARN* calls include device information in the
backtrace, so we know what device the warnings originate from.
Covert all the calls of WARN* with device specific drm_WARN*
variants in functions where drm_device or drm_i915_private struct
pointer is readily available.
The conversion was done automatically with below coccinelle semantic
patch. checkpatch errors/warnings are fixed manually.
@rule1@
identifier func, T;
@@
func(...) {
...
struct drm_device *T = ...;
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule2@
identifier func, T;
@@
func(struct drm_device *T,...) {
<...
(
-WARN(
+drm_WARN(T,
...)
|
-WARN_ON(
+drm_WARN_ON(T,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(T,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(T,
...)
)
...>
}
@rule3@
identifier func, T;
@@
func(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
@rule4@
identifier func, T;
@@
func(struct drm_i915_private *T,...) {
<+...
(
-WARN(
+drm_WARN(&T->drm,
...)
|
-WARN_ON(
+drm_WARN_ON(&T->drm,
...)
|
-WARN_ONCE(
+drm_WARN_ONCE(&T->drm,
...)
|
-WARN_ON_ONCE(
+drm_WARN_ON_ONCE(&T->drm,
...)
)
...+>
}
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200220165507.16823-6-pankaj.laxminarayan.bharadiya@intel.com
2020-02-20 22:25:04 +05:30
drm_WARN_ON ( dev , intel_phy_is_tc ( dev_priv , phy ) ) ;
2010-07-16 14:46:28 -04:00
type = DRM_MODE_CONNECTOR_eDP ;
2019-05-09 20:34:46 +03:00
} else {
2013-11-01 18:22:41 +02:00
type = DRM_MODE_CONNECTOR_DisplayPort ;
2019-05-09 20:34:46 +03:00
}
2010-07-16 14:46:28 -04:00
2016-12-14 20:00:23 +02:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) )
intel_dp - > active_pipe = vlv_active_pipe ( intel_dp ) ;
2020-07-02 16:09:57 -07:00
/*
* For eDP we always set the encoder type to INTEL_OUTPUT_EDP , but
* for DP the encoder type can be set by the caller to
* INTEL_OUTPUT_UNKNOWN for DDI , so don ' t rewrite it .
*/
if ( type = = DRM_MODE_CONNECTOR_eDP )
intel_encoder - > type = INTEL_OUTPUT_EDP ;
/* eDP only on port B and/or C on vlv/chv */
if ( drm_WARN_ON ( dev , ( IS_VALLEYVIEW ( dev_priv ) | |
IS_CHERRYVIEW ( dev_priv ) ) & &
intel_dp_is_edp ( intel_dp ) & &
port ! = PORT_B & & port ! = PORT_C ) )
return false ;
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" Adding %s connector on [ENCODER:%d:%s] \n " ,
type = = DRM_MODE_CONNECTOR_eDP ? " eDP " : " DP " ,
intel_encoder - > base . base . id , intel_encoder - > base . name ) ;
2013-05-08 13:14:08 +03:00
2010-07-16 14:46:28 -04:00
drm_connector_init ( dev , connector , & intel_dp_connector_funcs , type ) ;
2009-04-07 16:16:42 -07:00
drm_connector_helper_add ( connector , & intel_dp_connector_helper_funcs ) ;
2019-02-04 14:25:38 -08:00
if ( ! HAS_GMCH ( dev_priv ) )
2017-11-29 20:08:47 +02:00
connector - > interlace_allowed = true ;
2009-04-07 16:16:42 -07:00
connector - > doublescan_allowed = 0 ;
2020-02-05 20:35:43 +02:00
intel_connector - > polled = DRM_CONNECTOR_POLL_HPD ;
2017-02-22 08:34:26 +02:00
2016-09-09 14:10:52 +03:00
intel_dp_aux_init ( intel_dp ) ;
2016-06-24 14:00:14 +01:00
2010-09-09 16:20:55 +01:00
intel_connector_attach_encoder ( intel_connector , intel_encoder ) ;
2009-04-07 16:16:42 -07:00
2016-10-13 11:02:52 +01:00
if ( HAS_DDI ( dev_priv ) )
2012-10-26 19:05:51 -02:00
intel_connector - > get_hw_state = intel_ddi_connector_get_hw_state ;
else
intel_connector - > get_hw_state = intel_connector_get_hw_state ;
2014-05-02 14:02:48 +10:00
/* init MST on ports that can support it */
2020-06-30 21:50:54 -07:00
intel_dp_mst_encoder_init ( dig_port ,
2019-10-10 18:09:03 -07:00
intel_connector - > base . base . id ) ;
2014-05-02 14:02:48 +10:00
2014-10-16 21:27:30 +03:00
if ( ! intel_edp_init_connector ( intel_dp , intel_connector ) ) {
2015-11-11 20:34:11 +02:00
intel_dp_aux_fini ( intel_dp ) ;
2020-06-30 21:50:54 -07:00
intel_dp_mst_encoder_cleanup ( dig_port ) ;
2015-11-11 20:34:11 +02:00
goto fail ;
2013-06-12 17:27:26 -03:00
}
2009-07-24 01:00:32 +08:00
2010-09-19 09:29:33 +01:00
intel_dp_add_properties ( intel_dp , connector ) ;
2018-01-08 14:55:43 -05:00
2018-01-18 11:18:05 +05:30
if ( is_hdcp_supported ( dev_priv , port ) & & ! intel_dp_is_edp ( intel_dp ) ) {
2020-08-18 11:39:00 -04:00
int ret = intel_dp_init_hdcp ( dig_port , intel_connector ) ;
2018-01-08 14:55:43 -05:00
if ( ret )
drm/i915/dp: conversion to struct drm_device logging macros.
This converts various instances of printk based logging macros in
i915/display/intel_dp.c with the new struct drm_device based logging
macros using the following coccinelle script:
@rule1@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@rule2@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
New checkpatch warnings were fixed manually.
v2: fix merge conflict with new changes in file.
Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200122110844.2022-5-wambui.karugax@gmail.com
2020-01-22 14:08:42 +03:00
drm_dbg_kms ( & dev_priv - > drm ,
" HDCP init failed, skipping. \n " ) ;
2018-01-08 14:55:43 -05:00
}
2010-09-19 09:29:33 +01:00
2009-04-07 16:16:42 -07:00
/* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written
* 0xd . Failure to do so will result in spurious interrupts being
* generated on the port when a cable is not attached .
*/
2018-06-14 21:05:00 +03:00
if ( IS_G45 ( dev_priv ) ) {
drm/i915/dp: use intel_de_*() functions for register access
The implicit "dev_priv" local variable use has been a long-standing pain
point in the register access macros I915_READ(), I915_WRITE(),
POSTING_READ(), I915_READ_FW(), and I915_WRITE_FW().
Replace them with the corresponding new display engine register
accessors intel_de_read(), intel_de_write(), intel_de_posting_read(),
intel_de_read_fw(), and intel_de_write_fw().
No functional changes.
Generated using the following semantic patch:
@@
expression REG, OFFSET;
@@
- I915_READ(REG)
+ intel_de_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- POSTING_READ(REG)
+ intel_de_posting_read(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE(REG, OFFSET)
+ intel_de_write(dev_priv, REG, OFFSET)
@@
expression REG;
@@
- I915_READ_FW(REG)
+ intel_de_read_fw(dev_priv, REG)
@@
expression REG, OFFSET;
@@
- I915_WRITE_FW(REG, OFFSET)
+ intel_de_write_fw(dev_priv, REG, OFFSET)
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/abcb2d44fd4d6e5f995a3520b327f746ae90428a.1580149467.git.jani.nikula@intel.com
2020-01-27 20:26:08 +02:00
u32 temp = intel_de_read ( dev_priv , PEG_BAND_GAP_DATA ) ;
intel_de_write ( dev_priv , PEG_BAND_GAP_DATA ,
( temp & ~ 0xf ) | 0xd ) ;
2009-04-07 16:16:42 -07:00
}
2013-06-12 17:27:25 -03:00
2020-12-18 16:07:17 +05:30
intel_dp - > frl . is_trained = false ;
intel_dp - > frl . trained_rate_gbps = 0 ;
2013-06-12 17:27:25 -03:00
return true ;
2015-11-11 20:34:11 +02:00
fail :
drm_connector_cleanup ( connector ) ;
return false ;
2009-04-07 16:16:42 -07:00
}
2012-10-26 19:05:48 -02:00
2016-11-23 16:21:44 +02:00
bool intel_dp_init ( struct drm_i915_private * dev_priv ,
2016-06-01 08:27:50 +01:00
i915_reg_t output_reg ,
enum port port )
2012-10-26 19:05:48 -02:00
{
2020-06-30 21:50:54 -07:00
struct intel_digital_port * dig_port ;
2012-10-26 19:05:48 -02:00
struct intel_encoder * intel_encoder ;
struct drm_encoder * encoder ;
struct intel_connector * intel_connector ;
2020-06-30 21:50:54 -07:00
dig_port = kzalloc ( sizeof ( * dig_port ) , GFP_KERNEL ) ;
if ( ! dig_port )
2016-06-01 08:27:50 +01:00
return false ;
2012-10-26 19:05:48 -02:00
2015-04-10 10:59:10 +03:00
intel_connector = intel_connector_alloc ( ) ;
2015-10-08 19:27:59 +05:30
if ( ! intel_connector )
goto err_connector_alloc ;
2012-10-26 19:05:48 -02:00
2020-06-30 21:50:54 -07:00
intel_encoder = & dig_port - > base ;
2012-10-26 19:05:48 -02:00
encoder = & intel_encoder - > base ;
2020-08-18 11:38:57 -04:00
mutex_init ( & dig_port - > hdcp_mutex ) ;
2016-11-23 16:21:44 +02:00
if ( drm_encoder_init ( & dev_priv - > drm , & intel_encoder - > base ,
& intel_dp_enc_funcs , DRM_MODE_ENCODER_TMDS ,
" DP %c " , port_name ( port ) ) )
2015-10-08 19:28:00 +05:30
goto err_encoder_init ;
2012-10-26 19:05:48 -02:00
2018-01-17 21:21:47 +02:00
intel_encoder - > hotplug = intel_dp_hotplug ;
2013-03-27 00:44:55 +01:00
intel_encoder - > compute_config = intel_dp_compute_config ;
2012-10-26 19:05:52 -02:00
intel_encoder - > get_hw_state = intel_dp_get_hw_state ;
2013-05-14 17:08:26 -07:00
intel_encoder - > get_config = intel_dp_get_config ;
2020-10-06 02:01:54 +03:00
intel_encoder - > sync_state = intel_dp_sync_state ;
2020-10-06 00:53:10 +03:00
intel_encoder - > initial_fastset_check = intel_dp_initial_fastset_check ;
2019-01-08 17:08:38 +01:00
intel_encoder - > update_pipe = intel_panel_update_backlight ;
2014-08-18 14:42:45 +03:00
intel_encoder - > suspend = intel_dp_encoder_suspend ;
2020-10-01 18:16:38 +03:00
intel_encoder - > shutdown = intel_dp_encoder_shutdown ;
2016-10-14 10:13:44 +01:00
if ( IS_CHERRYVIEW ( dev_priv ) ) {
2014-04-09 13:29:05 +03:00
intel_encoder - > pre_pll_enable = chv_dp_pre_pll_enable ;
2014-04-09 13:28:20 +03:00
intel_encoder - > pre_enable = chv_pre_enable_dp ;
intel_encoder - > enable = vlv_enable_dp ;
2017-09-20 18:12:51 +03:00
intel_encoder - > disable = vlv_disable_dp ;
2014-04-09 13:29:00 +03:00
intel_encoder - > post_disable = chv_post_disable_dp ;
2015-07-08 23:45:49 +03:00
intel_encoder - > post_pll_disable = chv_dp_post_pll_disable ;
2016-10-13 11:03:08 +01:00
} else if ( IS_VALLEYVIEW ( dev_priv ) ) {
2013-09-06 07:38:29 +03:00
intel_encoder - > pre_pll_enable = vlv_dp_pre_pll_enable ;
2013-07-30 12:20:30 +03:00
intel_encoder - > pre_enable = vlv_pre_enable_dp ;
intel_encoder - > enable = vlv_enable_dp ;
2017-09-20 18:12:51 +03:00
intel_encoder - > disable = vlv_disable_dp ;
2014-03-31 18:21:26 +03:00
intel_encoder - > post_disable = vlv_post_disable_dp ;
2013-07-30 12:20:30 +03:00
} else {
2013-09-06 07:38:29 +03:00
intel_encoder - > pre_enable = g4x_pre_enable_dp ;
intel_encoder - > enable = g4x_enable_dp ;
2017-09-20 18:12:51 +03:00
intel_encoder - > disable = g4x_disable_dp ;
2018-06-13 19:05:53 +03:00
intel_encoder - > post_disable = g4x_post_disable_dp ;
2013-07-30 12:20:30 +03:00
}
2012-10-26 19:05:48 -02:00
2020-04-20 23:06:07 +03:00
if ( ( IS_IVYBRIDGE ( dev_priv ) & & port = = PORT_A ) | |
( HAS_PCH_CPT ( dev_priv ) & & port ! = PORT_A ) )
2020-06-30 21:50:54 -07:00
dig_port - > dp . set_link_train = cpt_set_link_train ;
2020-04-20 23:06:07 +03:00
else
2020-06-30 21:50:54 -07:00
dig_port - > dp . set_link_train = g4x_set_link_train ;
2020-04-20 23:06:07 +03:00
2020-04-20 23:06:08 +03:00
if ( IS_CHERRYVIEW ( dev_priv ) )
2020-06-30 21:50:54 -07:00
dig_port - > dp . set_signal_levels = chv_set_signal_levels ;
2020-04-20 23:06:08 +03:00
else if ( IS_VALLEYVIEW ( dev_priv ) )
2020-06-30 21:50:54 -07:00
dig_port - > dp . set_signal_levels = vlv_set_signal_levels ;
2020-04-20 23:06:08 +03:00
else if ( IS_IVYBRIDGE ( dev_priv ) & & port = = PORT_A )
2020-06-30 21:50:54 -07:00
dig_port - > dp . set_signal_levels = ivb_cpu_edp_set_signal_levels ;
2020-04-20 23:06:08 +03:00
else if ( IS_GEN ( dev_priv , 6 ) & & port = = PORT_A )
2020-06-30 21:50:54 -07:00
dig_port - > dp . set_signal_levels = snb_cpu_edp_set_signal_levels ;
2020-04-20 23:06:08 +03:00
else
2020-06-30 21:50:54 -07:00
dig_port - > dp . set_signal_levels = g4x_set_signal_levels ;
2020-04-20 23:06:08 +03:00
2020-05-12 20:41:42 +03:00
if ( IS_VALLEYVIEW ( dev_priv ) | | IS_CHERRYVIEW ( dev_priv ) | |
( HAS_PCH_SPLIT ( dev_priv ) & & port ! = PORT_A ) ) {
2020-09-30 02:34:39 +03:00
dig_port - > dp . preemph_max = intel_dp_preemph_max_3 ;
2020-06-30 21:50:54 -07:00
dig_port - > dp . voltage_max = intel_dp_voltage_max_3 ;
2020-05-12 20:41:42 +03:00
} else {
2020-09-30 02:34:39 +03:00
dig_port - > dp . preemph_max = intel_dp_preemph_max_2 ;
2020-06-30 21:50:54 -07:00
dig_port - > dp . voltage_max = intel_dp_voltage_max_2 ;
2020-05-12 20:41:42 +03:00
}
2020-06-30 21:50:54 -07:00
dig_port - > dp . output_reg = output_reg ;
dig_port - > max_lanes = 4 ;
2012-10-26 19:05:48 -02:00
2016-06-22 21:57:06 +03:00
intel_encoder - > type = INTEL_OUTPUT_DP ;
2017-02-22 08:34:27 +02:00
intel_encoder - > power_domain = intel_port_to_power_domain ( port ) ;
2016-10-14 10:13:44 +01:00
if ( IS_CHERRYVIEW ( dev_priv ) ) {
2014-04-28 14:07:43 +03:00
if ( port = = PORT_D )
2019-10-02 19:25:02 +03:00
intel_encoder - > pipe_mask = BIT ( PIPE_C ) ;
2014-04-28 14:07:43 +03:00
else
2019-10-02 19:25:02 +03:00
intel_encoder - > pipe_mask = BIT ( PIPE_A ) | BIT ( PIPE_B ) ;
2014-04-28 14:07:43 +03:00
} else {
2019-10-02 19:25:04 +03:00
intel_encoder - > pipe_mask = ~ 0 ;
2014-04-28 14:07:43 +03:00
}
2014-03-03 16:15:28 +02:00
intel_encoder - > cloneable = 0 ;
2016-09-19 18:24:38 -07:00
intel_encoder - > port = port ;
2020-07-01 00:55:58 +03:00
intel_encoder - > hpd_pin = intel_hpd_pin_default ( dev_priv , port ) ;
2012-10-26 19:05:48 -02:00
2020-06-30 21:50:54 -07:00
dig_port - > hpd_pulse = intel_dp_hpd_pulse ;
2014-06-18 11:29:35 +10:00
2020-03-11 17:54:20 +02:00
if ( HAS_GMCH ( dev_priv ) ) {
if ( IS_GM45 ( dev_priv ) )
2020-06-30 21:50:54 -07:00
dig_port - > connected = gm45_digital_port_connected ;
2020-03-11 17:54:20 +02:00
else
2020-06-30 21:50:54 -07:00
dig_port - > connected = g4x_digital_port_connected ;
2020-03-11 17:54:20 +02:00
} else {
2020-03-11 17:54:22 +02:00
if ( port = = PORT_A )
2020-06-30 21:50:54 -07:00
dig_port - > connected = ilk_digital_port_connected ;
2020-03-11 17:54:20 +02:00
else
2020-06-30 21:50:54 -07:00
dig_port - > connected = ibx_digital_port_connected ;
2020-03-11 17:54:20 +02:00
}
2017-08-18 16:49:55 +03:00
if ( port ! = PORT_A )
2020-06-30 21:50:54 -07:00
intel_infoframe_init ( dig_port ) ;
2017-08-18 16:49:55 +03:00
2020-06-30 21:50:54 -07:00
dig_port - > aux_ch = intel_bios_port_aux_ch ( dev_priv , port ) ;
if ( ! intel_dp_init_connector ( dig_port , intel_connector ) )
2015-10-08 19:27:59 +05:30
goto err_init_connector ;
2016-06-01 08:27:50 +01:00
return true ;
2015-10-08 19:27:59 +05:30
err_init_connector :
drm_encoder_cleanup ( encoder ) ;
2015-10-08 19:28:00 +05:30
err_encoder_init :
2015-10-08 19:27:59 +05:30
kfree ( intel_connector ) ;
err_connector_alloc :
2020-06-30 21:50:54 -07:00
kfree ( dig_port ) ;
2016-06-01 08:27:50 +01:00
return false ;
2012-10-26 19:05:48 -02:00
}
2014-05-02 14:02:48 +10:00
2018-07-05 19:43:52 +03:00
void intel_dp_mst_suspend ( struct drm_i915_private * dev_priv )
2014-05-02 14:02:48 +10:00
{
2018-07-05 19:43:52 +03:00
struct intel_encoder * encoder ;
for_each_intel_encoder ( & dev_priv - > drm , encoder ) {
struct intel_dp * intel_dp ;
2014-05-02 14:02:48 +10:00
2018-07-05 19:43:52 +03:00
if ( encoder - > type ! = INTEL_OUTPUT_DDI )
continue ;
2016-06-22 21:57:00 +03:00
2019-12-04 20:05:43 +02:00
intel_dp = enc_to_intel_dp ( encoder ) ;
2016-06-22 21:57:00 +03:00
2018-07-05 19:43:52 +03:00
if ( ! intel_dp - > can_mst )
2014-05-02 14:02:48 +10:00
continue ;
2018-07-05 19:43:52 +03:00
if ( intel_dp - > is_mst )
drm_dp_mst_topology_mgr_suspend ( & intel_dp - > mst_mgr ) ;
2014-05-02 14:02:48 +10:00
}
}
2018-07-05 19:43:52 +03:00
void intel_dp_mst_resume ( struct drm_i915_private * dev_priv )
2014-05-02 14:02:48 +10:00
{
2018-07-05 19:43:52 +03:00
struct intel_encoder * encoder ;
2014-05-02 14:02:48 +10:00
2018-07-05 19:43:52 +03:00
for_each_intel_encoder ( & dev_priv - > drm , encoder ) {
struct intel_dp * intel_dp ;
2016-06-22 21:57:00 +03:00
int ret ;
2014-05-02 14:02:48 +10:00
2018-07-05 19:43:52 +03:00
if ( encoder - > type ! = INTEL_OUTPUT_DDI )
continue ;
2019-12-04 20:05:43 +02:00
intel_dp = enc_to_intel_dp ( encoder ) ;
2018-07-05 19:43:52 +03:00
if ( ! intel_dp - > can_mst )
2016-06-22 21:57:00 +03:00
continue ;
2014-05-02 14:02:48 +10:00
drm/dp_mst: Add basic topology reprobing when resuming
Finally! For a very long time, our MST helpers have had one very
annoying issue: They don't know how to reprobe the topology state when
coming out of suspend. This means that if a user has a machine connected
to an MST topology and decides to suspend their machine, we lose all
topology changes that happened during that period. That can be a big
problem if the machine was connected to a different topology on the same
port before resuming, as we won't bother reprobing any of the ports and
likely cause the user's monitors not to come back up as expected.
So, we start fixing this by teaching our MST helpers how to reprobe the
link addresses of each connected topology when resuming. As it turns
out, the behavior that we want here is identical to the behavior we want
when initially probing a newly connected MST topology, with a couple of
important differences:
- We need to be more careful about handling the potential races between
events from the MST hub that could change the topology state as we're
performing the link address reprobe
- We need to be more careful about handling unlikely state changes on
ports - such as an input port turning into an output port, something
that would be far more likely to happen in situations like the MST hub
we're connected to being changed while we're suspend
Both of which have been solved by previous commits. That leaves one
requirement:
- We need to prune any MST ports in our in-memory topology state that
were present when suspending, but have not appeared in the post-resume
link address response from their parent branch device
Which we can now handle in this commit by modifying
drm_dp_send_link_address(). We then introduce suspend/resume reprobing
by introducing drm_dp_mst_topology_mgr_invalidate_mstb(), which we call
in drm_dp_mst_topology_mgr_suspend() to traverse the in-memory topology
state to indicate that each mstb needs it's link address resent and PBN
resources reprobed.
On resume, we start back up &mgr->work and have it reprobe the topology
in the same way we would on a hotplug, removing any leftover ports that
no longer appear in the topology state.
Changes since v4:
* Split indenting changes in drm_dp_mst_topology_mgr_resume() into a
separate patch
* Only fire hotplugs when something has actually changed after a link
address probe
* Don't try to change port->connector at all on ports, just throw out
ports that need their connectors removed to make things easier.
Cc: Juston Li <juston.li@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Harry Wentland <hwentlan@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Sean Paul <sean@poorly.run>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191022023641.8026-14-lyude@redhat.com
2019-06-17 19:57:33 -04:00
ret = drm_dp_mst_topology_mgr_resume ( & intel_dp - > mst_mgr ,
true ) ;
2019-01-29 14:10:00 -05:00
if ( ret ) {
intel_dp - > is_mst = false ;
drm_dp_mst_topology_mgr_set_mst ( & intel_dp - > mst_mgr ,
false ) ;
}
2014-05-02 14:02:48 +10:00
}
}