drm/i915: LVDS channel mode fixes
Subsystems (2)
v4 cover drm/i915: LVDS channel mode fixes
Hi,
this is the revised patch for fixing the wrong LVDS channel mode, e.g. when booted while the lid is closed. Also, a new module option to override the LVDS channel mode is added in the second patch.
v1->v2: Fix the register for gen<=4v2->v3: Check the resolution of the entry to be sure v3->v4: Optimize the register reference; add a module option
thanks,
Takashi
PATCH v4 1/2 drm/i915: Check VBIOS value for determining LVDS dual channel mode, too
Currently i915 driver checks [PCH_]LVDS register bits to decide whether to set up the dual-link or the single-link mode. This relies implicitly on that BIOS initializes the register properly at boot. However, BIOS doesn't initialize it always. When the machine is booted with the closed lid, BIOS skips the LVDS reg initialization. This ends up in blank output on a machine with a dual-link LVDS when you open the lid after the boot.
This patch adds a workaround for that problem by checking the initial LVDS register value in VBT.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_bios.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_display.c | 26 ++++++++++++++++++++------ 3 files changed, 47 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -376,6 +376,7 @@ typedef struct drm_i915_private { unsigned int lvds_use_ssc:1; unsigned int display_clock_mode:1;int lvds_ssc_freq; +unsigned int bios_lvds_val;/* initial [PCH_]LVDS reg val in VBIOS */ struct {int rate;int lanes;
drivers/gpu/drm/i915/intel_bios.c +26 -0
@@ -173,6 +173,27 @@ get_lvds_dvo_timing(const struct bdb_lvds_lfp_data *lvds_lfp_data,return (struct lvds_dvo_timing *)(entry + dvo_timing_offset); } +/* read the initial LVDS register value for the given panel mode */ +static unsigned int get_lvds_reg_val (const struct bdb_header *bdb, +const struct bdb_lvds_lfp_data_ptrs *ptrs, +int index, +struct drm_display_mode *mode) +{ +unsigned int ofs; +const struct lvds_fp_timing *timing; + +if (index >=ARRAY_SIZE (ptrs->ptr)) +return 0 ; + ofs = ptrs->ptr[index].fp_timing_offset; +if (ofs +sizeof (*timing) > bdb->bdb_size) +return 0 ; + timing = (const struct lvds_fp_timing *)((const u8 *)bdb + ofs); +/* check the resolution, just to be sure */ +if (timing->x_res != mode->hdisplay || timing->y_res != mode->vdisplay) +return 0 ; +return timing->lvds_reg_val; +} +/* Try to find integrated panel data */ static void parse_lfp_panel_data(struct drm_i915_private *dev_priv,
@@ -243,6 +264,11 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,"Normal Clock %dKHz, downclock %dKHz\n" , panel_fixed_mode->clock, 10*downclock); } + + dev_priv->bios_lvds_val =get_lvds_reg_val (bdb, lvds_lfp_data_ptrs, + lvds_options->panel_type, + panel_fixed_mode); +DRM_DEBUG_KMS ("VBT initial LVDS value %x\n" , dev_priv->bios_lvds_val); }/* Try to find sdvo panel data */
drivers/gpu/drm/i915/intel_display.c +20 -6
@@ -356,6 +356,23 @@ static const intel_limit_t intel_limits_ironlake_display_port = { .find_pll = intel_find_pll_ironlake_dp, }; +static bool is_dual_link_lvds (struct drm_i915_private *dev_priv, +unsigned int reg) +{ +unsigned int val; +/* BIOS should set the proper LVDS register value at boot, but +* in reality, it doesn't set the value when the lid is closed; +* thus when a machine is booted with the lid closed, the LVDS +* reg value can't be trusted. So we need to check "the value +* to be set" in VBT at first. +*/ +if (dev_priv->bios_lvds_val) + val = dev_priv->bios_lvds_val; +else + val =I915_READ (reg); +return (val &LVDS_CLKB_POWER_MASK ) ==LVDS_CLKB_POWER_UP ; +} +static const intel_limit_t *intel_ironlake_limit (struct drm_crtc *crtc,int refclk) {
@@ -364,8 +381,7 @@ static const intel_limit_t *intel_ironlake_limit(struct drm_crtc *crtc,const intel_limit_t *limit;if (intel_pipe_has_type (crtc,INTEL_OUTPUT_LVDS )) { -if ((I915_READ (PCH_LVDS ) &LVDS_CLKB_POWER_MASK ) == -LVDS_CLKB_POWER_UP ) { +if (is_dual_link_lvds (dev_priv,PCH_LVDS )) {/* LVDS dual channel */ if (refclk ==100000 ) limit = &intel_limits_ironlake_dual_lvds_100m;
@@ -393,8 +409,7 @@ static const intel_limit_t *intel_g4x_limit(struct drm_crtc *crtc)const intel_limit_t *limit;if (intel_pipe_has_type (crtc,INTEL_OUTPUT_LVDS )) { -if ((I915_READ (LVDS ) &LVDS_CLKB_POWER_MASK ) == -LVDS_CLKB_POWER_UP ) +if (is_dual_link_lvds (dev_priv,LVDS ))/* LVDS with dual channel */ limit = &intel_limits_g4x_dual_channel_lvds;else
@@ -531,8 +546,7 @@ intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,* reliably set up different single/dual channel state, if we * even can. */ -if ((I915_READ (LVDS ) &LVDS_CLKB_POWER_MASK ) == -LVDS_CLKB_POWER_UP ) +if (is_dual_link_lvds (dev_priv,LVDS )) clock.p2 = limit->p2.p2_fast;else clock.p2 = limit->p2.p2_slow;
Signature · 1 line
1.7.9.2
Re: [PATCH 1/2] drm/i915: Check VBIOS value for determining LVDS dual channel mode, too
<#part sign=pgpmime>
drivers/gpu/drm/i915/intel_bios.c get_lvds_dvo_timing(const struct bdb_lvds_lfp_data *lvds_lfp_data, · line 180
Quoted 5 lines · Takashi Iwai
drivers/gpu/drm/i915/intel_bios.c +5
-0+/* read the initial LVDS register value for the given panel mode */ +static unsigned int get_lvds_reg_val (const struct bdb_header *bdb, +const struct bdb_lvds_lfp_data_ptrs *ptrs, +int index, +struct drm_display_mode *mode)
To follow the style of intel_bios.c, I think it would make sense to have the function:
static const struct lvds_dvo_timing *
get_lvds_fp_timing(const struct bdb_lvds_lfp_data *lvds_lfp_data,
const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs, int index)
then use the results of this in parse_lfp_panel_data, instead of putting the whole computation into this new function.
I'd also like to see this code only use the BDB value when the LVDS is disabled at startup time; otherwise, we'll be changing the behavior for all LVDS users, and as BIOS tables are notoriously unreliable, I fear that we'll cause a lot more problems than we solve.
Signature · 1 line
[email protected]
Re: [PATCH 1/2] drm/i915: Check VBIOS value for determining LVDS dual channel mode, too
At Fri, 16 Mar 2012 16:18:03 -0700,
Quoted 13 lines · Keith Packard
<#part sign=pgpmime>
drivers/gpu/drm/i915/intel_bios.c get_lvds_dvo_timing(const struct bdb_lvds_lfp_data *lvds_lfp_data, · line 180
Quoted 5 lines · Takashi Iwai
drivers/gpu/drm/i915/intel_bios.c +5
-0+/* read the initial LVDS register value for the given panel mode */ +static unsigned int get_lvds_reg_val (const struct bdb_header *bdb, +const struct bdb_lvds_lfp_data_ptrs *ptrs, +int index, +struct drm_display_mode *mode)To follow the style of
intel_bios.c, I think it would make sense to have the function:
Quoted 7 lines
static const struct
lvds_dvo_timing*
get_lvds_fp_timing(const structbdb_lvds_lfp_data*lvds_lfp_data,
const structbdb_lvds_lfp_data_ptrs*lvds_lfp_data_ptrs, int index)then use the results of this in
parse_lfp_panel_data, instead of putting the whole computation into this new function.
Well, the LVDS reg data isn't in lvds_dvo_timing but in lvds_fp_timing, thus you need to look at a different entry in anyway.
Quoted 4 lines
I'd also like to see this code only use the BDB value when the LVDS is disabled at startup time; otherwise, we'll be changing the behavior for all LVDS users, and as BIOS tables are notoriously unreliable, I fear that we'll cause a lot more problems than we solve.
I skipped it to simplify the code, but that'd be safer, indeed.
(Though, the chance of getting a wrong value is fairly small since
the function verifies whether the resolution of the entry matches with the given mode, too.)
thanks,
Takashi
Re: [PATCH 1/2] drm/i915: Check VBIOS value for determining LVDS dual channel mode, too
<#part sign=pgpmime>
Quoted 2 lines · Takashi Iwai
Well, the LVDS reg data isn't in
lvds_dvo_timingbut inlvds_fp_timing, thus you need to look at a different entry in anyway.
Right, a parallel function which returns the lvds_fp_timing structure instead of pulling the data out of it. Just makes the code look more like the existing stuff. And, if we need more data from the lvds_fp_timing in the future, we'll have it available directly.
Quoted 1 line
I skipped it to simplify the code, but that'd be safer, indeed.
Reducing the chances for regressions is my primary concern here; most people boot their machines with the lid open, so if we avoid the new code in that case, we'll be more likely to not break things.
Signature · 1 line
[email protected]
Re: [PATCH 1/2] drm/i915: Check VBIOS value for determining LVDS dual channel mode, too
At Sat, 17 Mar 2012 12:01:17 -0700,
Quoted 11 lines · Keith Packard
<#part sign=pgpmime>
Quoted 2 lines · Takashi Iwai
Well, the LVDS reg data isn't in
lvds_dvo_timingbut inlvds_fp_timing, thus you need to look at a different entry in anyway.Right, a parallel function which returns the
lvds_fp_timingstructure instead of pulling the data out of it. Just makes the code look more like the existing stuff. And, if we need more data from thelvds_fp_timingin the future, we'll have it available directly.
Ah, OK I got your point now. This makes sense.
I'll rewrite the patch tomorrow.
Quoted 5 lines
Quoted 1 line
I skipped it to simplify the code, but that'd be safer, indeed.
Reducing the chances for regressions is my primary concern here; most people boot their machines with the lid open, so if we avoid the new code in that case, we'll be more likely to not break things.
Yes, that's my biggest concern too.
So I'd really appreciate if anyone else checks whether the patch doesn't break, at least (and helps sometimes).
thanks,
Takashi
Quoted 4 lines
Signature · 2 lines
-- [email protected]
PATCH v4 2/2 drm/i915: Add lvds_channel module option
In reply to Takashi IwaiAdd a new module optoin lvds_channel to specify the LVDS channel mode explicitly instead of probing the LVDS register value set by BIOS. This will be helpful when VBT is broken or incompatible with the current code.
--- drivers/gpu/drm/i915/i915_drv.c | 6 ++++++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 5 +++++ 3 files changed, 12 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +6 -0
@@ -80,6 +80,12 @@ MODULE_PARM_DESC(lvds_downclock,"Use panel (LVDS/eDP) downclocking for power savings " "(default: false)"); +int i915_lvds_channel__read_mostly ; +module_param_named (lvds_channel, i915_lvds_channel, int,0400 ); +MODULE_PARM_DESC (lvds_channel, +"Specify LVDS channel mode " +"(0=probe BIOS [default], 1=single-channel, 2=dual-channel)" ); +int i915_panel_use_ssc__read_mostly =-1 ;module_param_named (lvds_use_ssc, i915_panel_use_ssc, int,0600 ); MODULE_PARM_DESC(lvds_use_ssc,
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1014,6 +1014,7 @@ extern int i915_panel_ignore_lid __read_mostly;extern unsigned int i915_powersave__read_mostly ;extern int i915_semaphores__read_mostly ;extern unsigned int i915_lvds_downclock__read_mostly ; +extern int i915_lvds_channel__read_mostly ;extern int i915_panel_use_ssc__read_mostly ;extern int i915_vbt_sdvo_panel_type__read_mostly ;extern int i915_enable_rc6__read_mostly ;
drivers/gpu/drm/i915/intel_display.c +5 -0
@@ -360,6 +360,11 @@ static bool is_dual_link_lvds(struct drm_i915_private *dev_priv, unsigned int reg) {unsigned int val; + +/* use the module option value if specified */ +if (i915_lvds_channel >0 ) +return i915_lvds_channel ==2 ; +/* BIOS should set the proper LVDS register value at boot, but * in reality, it doesn't set the value when the lid is closed; * thus when a machine is booted with the lid closed, the LVDS
Signature · 1 line
1.7.9.2
Re: [PATCH 2/2] drm/i915: Add lvds_channel module option
Quoted 18 lines · Takashi Iwai
Add a new module optoin
lvds_channelto specify the LVDS channel mode explicitly instead of probing the LVDS register value set by BIOS. This will be helpful when VBT is broken or incompatible with the current code.Signed-off-by Takashi Iwai <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 6 ++++++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 5 +++++ 3 files changed, 12 insertions(+)drivers/gpu/drm/i915/i915_drv.c +0
-0
drivers/gpu/drm/i915/i915_drv.c MODULE_PARM_DESC(lvds_downclock, · line 85
Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.c +2
-0@@ -80,6 +80,12 @@ MODULE_PARM_DESC(lvds_downclock,"Use panel (LVDS/eDP) downclocking for power savings " "(default: false)"); +int i915_lvds_channel__read_mostly ; +module_param_named (lvds_channel, i915_lvds_channel, int,0400 );
As a minor bikeshedding, perhaps this variable would make more sense if called 'i915_lvds_channel_mode' instead?
I am fine with either spelling though, it just looks more semantically correct to me. But in any case,
Signature · 2 lines
Eugeni Dodonov <http://eugeni.dodonov.net/>
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Add lvds_channel module option
At Fri, 16 Mar 2012 22:51:22 -0300,
Quoted 32 lines · Eugeni Dodonov
[1 <text/plain; ISO-8859-1 (7bit)>]
Quoted 18 lines · Takashi Iwai
Add a new module optoin
lvds_channelto specify the LVDS channel mode explicitly instead of probing the LVDS register value set by BIOS. This will be helpful when VBT is broken or incompatible with the current code.Signed-off-by Takashi Iwai <[email protected]>--- drivers/gpu/drm/i915/i915_drv.c | 6 ++++++ drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 5 +++++ 3 files changed, 12 insertions(+)drivers/gpu/drm/i915/i915_drv.c +0
-0drivers/gpu/drm/i915/i915_drv.c MODULE_PARM_DESC(lvds_downclock, · line 85
Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.c +2
-0@@ -80,6 +80,12 @@ MODULE_PARM_DESC(lvds_downclock,"Use panel (LVDS/eDP) downclocking for power savings " "(default: false)"); +int i915_lvds_channel__read_mostly ; +module_param_named (lvds_channel, i915_lvds_channel, int,0400 );As a minor bikeshedding, perhaps this variable would make more sense if called '
i915_lvds_channel_mode' instead?
Quoted 2 lines
I am fine with either spelling though, it just looks more semantically correct to me. But in any case,
OK, I'll fix in the next spin.
thanks,
Takashi
Quoted 8 lines
Reviewed-by Eugeni Dodonov <[email protected]>Signature · 3 lines
Eugeni Dodonov <http://eugeni.dodonov.net/> [2 <text/html; ISO-8859-1 (quoted-printable)>]
Quoted 9 lines · Takashi Iwai
Hi,
this is the revised patch for fixing the wrong LVDS channel mode, e.g. when booted while the lid is closed. Also, a new module option to override the LVDS channel mode is added in the second patch.
v1->v2: Fix the register for gen<=4v2->v3: Check the resolution of the entry to be surev3->v4: Optimize the register reference; add a module option
For the series:
- ajax
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx