Skip to content

Commit 18442d0

Browse files
vsyrjaladanvet
authored andcommitted
drm/i915: Fix port_clock and adjusted_mode.clock readout all over
Now that adjusted_mode.clock no longer contains the pixel_multiplier, we can kill the get_clock() callback and instead do the clock readout in get_pipe_config(). Also i9xx_crtc_clock_get() can now extract the frequency of the PCH DPLL, so use it to populate port_clock accurately for PCH encoders. For DP in port A the encoder is still responsible for filling in port_clock. The FDI adjusted_mode.clock extraction is kept in place for some extra sanity checking, but we no longer need to pretend it's also the port_clock. In the encoder get_config() functions fill out adjusted_mode.clock based on port_clock and other details such as the DP M/N values, HDMI 12bpc and SDVO pixel_multiplier. For PCH encoders we will then do an extra sanity check to make sure the dotclock we derived from the FDI configuratiuon matches the one we derive from port_clock. DVO doesn't exist on PCH platforms, so it doesn't need to anything but assign adjusted_mode.clock=port_clock. And DDI is HSW only, so none of the changes apply there. v2: Use hdmi_reg color format to detect 12bpc HDMI case v3: Set adjusted_mode.clock for LVDS too v4: Rename ironlake_crtc_clock_get to ironlake_pch_clock_get, eliminate the useless link_freq variable. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent da4a1ef commit 18442d0

10 files changed

Lines changed: 86 additions & 40 deletions

File tree

‎drivers/gpu/drm/i915/i915_drv.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ struct drm_i915_display_funcs {
371371
* fills out the pipe-config with the hw state. */
372372
bool (*get_pipe_config)(struct intel_crtc *,
373373
struct intel_crtc_config *);
374-
void (*get_clock)(struct intel_crtc *, struct intel_crtc_config *);
375374
int (*crtc_mode_set)(struct drm_crtc *crtc,
376375
int x, int y,
377376
struct drm_framebuffer *old_fb);

‎drivers/gpu/drm/i915/i915_reg.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,7 @@
20712071

20722072
/* Gen 4 SDVO/HDMI bits: */
20732073
#define SDVO_COLOR_FORMAT_8bpc (0 << 26)
2074+
#define SDVO_COLOR_FORMAT_MASK (7 << 26)
20742075
#define SDVO_ENCODING_SDVO (0 << 10)
20752076
#define SDVO_ENCODING_HDMI (2 << 10)
20762077
#define HDMI_MODE_SELECT_HDMI (1 << 9) /* HDMI only */

‎drivers/gpu/drm/i915/intel_crt.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static void intel_crt_get_config(struct intel_encoder *encoder,
8989
struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
9090
struct intel_crt *crt = intel_encoder_to_crt(encoder);
9191
u32 tmp, flags = 0;
92+
int dotclock;
9293

9394
tmp = I915_READ(crt->adpa_reg);
9495

@@ -103,6 +104,13 @@ static void intel_crt_get_config(struct intel_encoder *encoder,
103104
flags |= DRM_MODE_FLAG_NVSYNC;
104105

105106
pipe_config->adjusted_mode.flags |= flags;
107+
108+
dotclock = pipe_config->port_clock;
109+
110+
if (HAS_PCH_SPLIT(dev_priv->dev))
111+
ironlake_check_encoder_dotclock(pipe_config, dotclock);
112+
113+
pipe_config->adjusted_mode.clock = dotclock;
106114
}
107115

108116
/* Note: The caller is required to filter out dpms modes not supported by the

‎drivers/gpu/drm/i915/intel_display.c‎

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on);
4747

4848
static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
4949
struct intel_crtc_config *pipe_config);
50-
static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
51-
struct intel_crtc_config *pipe_config);
50+
static void ironlake_pch_clock_get(struct intel_crtc *crtc,
51+
struct intel_crtc_config *pipe_config);
5252

5353
static int intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
5454
int x, int y, struct drm_framebuffer *old_fb);
@@ -5068,6 +5068,8 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
50685068
DPLL_PORTB_READY_MASK);
50695069
}
50705070

5071+
i9xx_crtc_clock_get(crtc, pipe_config);
5072+
50715073
return true;
50725074
}
50735075

@@ -6026,6 +6028,8 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
60266028
pipe_config->pixel_multiplier =
60276029
((tmp & PLL_REF_SDVO_HDMI_MULTIPLIER_MASK)
60286030
>> PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT) + 1;
6031+
6032+
ironlake_pch_clock_get(crtc, pipe_config);
60296033
} else {
60306034
pipe_config->pixel_multiplier = 1;
60316035
}
@@ -7433,7 +7437,12 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
74337437
i9xx_clock(refclk, &clock);
74347438
}
74357439

7436-
pipe_config->adjusted_mode.clock = clock.dot;
7440+
/*
7441+
* This value includes pixel_multiplier. We will use
7442+
* port_clock to compute adjusted_mode.clock in the
7443+
* encoder's get_config() function.
7444+
*/
7445+
pipe_config->port_clock = clock.dot;
74377446
}
74387447

74397448
int intel_dotclock_calculate(int link_freq,
@@ -7455,31 +7464,23 @@ int intel_dotclock_calculate(int link_freq,
74557464
return div_u64((u64)m_n->link_m * link_freq, m_n->link_n);
74567465
}
74577466

7458-
static void ironlake_crtc_clock_get(struct intel_crtc *crtc,
7459-
struct intel_crtc_config *pipe_config)
7467+
static void ironlake_pch_clock_get(struct intel_crtc *crtc,
7468+
struct intel_crtc_config *pipe_config)
74607469
{
74617470
struct drm_device *dev = crtc->base.dev;
7462-
int link_freq;
7471+
7472+
/* read out port_clock from the DPLL */
7473+
i9xx_crtc_clock_get(crtc, pipe_config);
74637474

74647475
/*
7465-
* We need to get the FDI or DP link clock here to derive
7466-
* the M/N dividers.
7467-
*
7468-
* For FDI, we read it from the BIOS or use a fixed 2.7GHz.
7469-
* For DP, it's either 1.62GHz or 2.7GHz.
7470-
* We do our calculations in 10*MHz since we don't need much precison.
7476+
* This value does not include pixel_multiplier.
7477+
* We will check that port_clock and adjusted_mode.clock
7478+
* agree once we know their relationship in the encoder's
7479+
* get_config() function.
74717480
*/
7472-
if (pipe_config->has_pch_encoder) {
7473-
link_freq = intel_fdi_link_freq(dev) * 10000;
7474-
7475-
pipe_config->adjusted_mode.clock =
7476-
intel_dotclock_calculate(link_freq, &pipe_config->fdi_m_n);
7477-
} else {
7478-
link_freq = pipe_config->port_clock;
7479-
7480-
pipe_config->adjusted_mode.clock =
7481-
intel_dotclock_calculate(link_freq, &pipe_config->dp_m_n);
7482-
}
7481+
pipe_config->adjusted_mode.clock =
7482+
intel_dotclock_calculate(intel_fdi_link_freq(dev) * 10000,
7483+
&pipe_config->fdi_m_n);
74837484
}
74847485

74857486
/** Returns the currently programmed mode of the given pipe. */
@@ -8895,9 +8896,6 @@ check_crtc_state(struct drm_device *dev)
88958896
encoder->get_config(encoder, &pipe_config);
88968897
}
88978898

8898-
if (dev_priv->display.get_clock)
8899-
dev_priv->display.get_clock(crtc, &pipe_config);
8900-
89018899
WARN(crtc->active != active,
89028900
"crtc active state doesn't match with hw state "
89038901
"(expected %i, found %i)\n", crtc->active, active);
@@ -8972,6 +8970,18 @@ intel_modeset_check_state(struct drm_device *dev)
89728970
check_shared_dpll_state(dev);
89738971
}
89748972

8973+
void ironlake_check_encoder_dotclock(const struct intel_crtc_config *pipe_config,
8974+
int dotclock)
8975+
{
8976+
/*
8977+
* FDI already provided one idea for the dotclock.
8978+
* Yell if the encoder disagrees.
8979+
*/
8980+
WARN(!intel_fuzzy_clock_check(pipe_config->adjusted_mode.clock, dotclock),
8981+
"FDI dotclock and encoder dotclock mismatch, fdi: %i, encoder: %i\n",
8982+
pipe_config->adjusted_mode.clock, dotclock);
8983+
}
8984+
89758985
static int __intel_set_mode(struct drm_crtc *crtc,
89768986
struct drm_display_mode *mode,
89778987
int x, int y, struct drm_framebuffer *fb)
@@ -9923,23 +9933,20 @@ static void intel_init_display(struct drm_device *dev)
99239933
dev_priv->display.update_plane = ironlake_update_plane;
99249934
} else if (HAS_PCH_SPLIT(dev)) {
99259935
dev_priv->display.get_pipe_config = ironlake_get_pipe_config;
9926-
dev_priv->display.get_clock = ironlake_crtc_clock_get;
99279936
dev_priv->display.crtc_mode_set = ironlake_crtc_mode_set;
99289937
dev_priv->display.crtc_enable = ironlake_crtc_enable;
99299938
dev_priv->display.crtc_disable = ironlake_crtc_disable;
99309939
dev_priv->display.off = ironlake_crtc_off;
99319940
dev_priv->display.update_plane = ironlake_update_plane;
99329941
} else if (IS_VALLEYVIEW(dev)) {
99339942
dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
9934-
dev_priv->display.get_clock = i9xx_crtc_clock_get;
99359943
dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
99369944
dev_priv->display.crtc_enable = valleyview_crtc_enable;
99379945
dev_priv->display.crtc_disable = i9xx_crtc_disable;
99389946
dev_priv->display.off = i9xx_crtc_off;
99399947
dev_priv->display.update_plane = i9xx_update_plane;
99409948
} else {
99419949
dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
9942-
dev_priv->display.get_clock = i9xx_crtc_clock_get;
99439950
dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
99449951
dev_priv->display.crtc_enable = i9xx_crtc_enable;
99459952
dev_priv->display.crtc_disable = i9xx_crtc_disable;
@@ -10553,15 +10560,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
1055310560
pipe);
1055410561
}
1055510562

10556-
list_for_each_entry(crtc, &dev->mode_config.crtc_list,
10557-
base.head) {
10558-
if (!crtc->active)
10559-
continue;
10560-
if (dev_priv->display.get_clock)
10561-
dev_priv->display.get_clock(crtc,
10562-
&crtc->config);
10563-
}
10564-
1056510563
list_for_each_entry(connector, &dev->mode_config.connector_list,
1056610564
base.head) {
1056710565
if (connector->get_hw_state(connector)) {

‎drivers/gpu/drm/i915/intel_dp.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,7 @@ static void intel_dp_get_config(struct intel_encoder *encoder,
14171417
struct drm_i915_private *dev_priv = dev->dev_private;
14181418
enum port port = dp_to_dig_port(intel_dp)->port;
14191419
struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
1420+
int dotclock;
14201421

14211422
if ((port == PORT_A) || !HAS_PCH_CPT(dev)) {
14221423
tmp = I915_READ(intel_dp->output_reg);
@@ -1448,12 +1449,20 @@ static void intel_dp_get_config(struct intel_encoder *encoder,
14481449

14491450
intel_dp_get_m_n(crtc, pipe_config);
14501451

1451-
if (dp_to_dig_port(intel_dp)->port == PORT_A) {
1452+
if (port == PORT_A) {
14521453
if ((I915_READ(DP_A) & DP_PLL_FREQ_MASK) == DP_PLL_FREQ_160MHZ)
14531454
pipe_config->port_clock = 162000;
14541455
else
14551456
pipe_config->port_clock = 270000;
14561457
}
1458+
1459+
dotclock = intel_dotclock_calculate(pipe_config->port_clock,
1460+
&pipe_config->dp_m_n);
1461+
1462+
if (HAS_PCH_SPLIT(dev_priv->dev) && port != PORT_A)
1463+
ironlake_check_encoder_dotclock(pipe_config, dotclock);
1464+
1465+
pipe_config->adjusted_mode.clock = dotclock;
14571466
}
14581467

14591468
static bool is_edp_psr(struct intel_dp *intel_dp)

‎drivers/gpu/drm/i915/intel_drv.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,5 +805,7 @@ extern void intel_dp_get_m_n(struct intel_crtc *crtc,
805805
struct intel_crtc_config *pipe_config);
806806
extern int intel_dotclock_calculate(int link_freq,
807807
const struct intel_link_m_n *m_n);
808+
extern void ironlake_check_encoder_dotclock(const struct intel_crtc_config *pipe_config,
809+
int dotclock);
808810

809811
#endif /* __INTEL_DRV_H__ */

‎drivers/gpu/drm/i915/intel_dvo.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ static void intel_dvo_get_config(struct intel_encoder *encoder,
153153
flags |= DRM_MODE_FLAG_NVSYNC;
154154

155155
pipe_config->adjusted_mode.flags |= flags;
156+
157+
pipe_config->adjusted_mode.clock = pipe_config->port_clock;
156158
}
157159

158160
static void intel_disable_dvo(struct intel_encoder *encoder)

‎drivers/gpu/drm/i915/intel_hdmi.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ static void intel_hdmi_get_config(struct intel_encoder *encoder,
713713
struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
714714
struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
715715
u32 tmp, flags = 0;
716+
int dotclock;
716717

717718
tmp = I915_READ(intel_hdmi->hdmi_reg);
718719

@@ -727,6 +728,16 @@ static void intel_hdmi_get_config(struct intel_encoder *encoder,
727728
flags |= DRM_MODE_FLAG_NVSYNC;
728729

729730
pipe_config->adjusted_mode.flags |= flags;
731+
732+
if ((tmp & SDVO_COLOR_FORMAT_MASK) == HDMI_COLOR_FORMAT_12bpc)
733+
dotclock = pipe_config->port_clock * 2 / 3;
734+
else
735+
dotclock = pipe_config->port_clock;
736+
737+
if (HAS_PCH_SPLIT(dev_priv->dev))
738+
ironlake_check_encoder_dotclock(pipe_config, dotclock);
739+
740+
pipe_config->adjusted_mode.clock = dotclock;
730741
}
731742

732743
static void intel_enable_hdmi(struct intel_encoder *encoder)

‎drivers/gpu/drm/i915/intel_lvds.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static void intel_lvds_get_config(struct intel_encoder *encoder,
9292
struct drm_device *dev = encoder->base.dev;
9393
struct drm_i915_private *dev_priv = dev->dev_private;
9494
u32 lvds_reg, tmp, flags = 0;
95+
int dotclock;
9596

9697
if (HAS_PCH_SPLIT(dev))
9798
lvds_reg = PCH_LVDS;
@@ -116,6 +117,13 @@ static void intel_lvds_get_config(struct intel_encoder *encoder,
116117

117118
pipe_config->gmch_pfit.control |= tmp & PANEL_8TO6_DITHER_ENABLE;
118119
}
120+
121+
dotclock = pipe_config->port_clock;
122+
123+
if (HAS_PCH_SPLIT(dev_priv->dev))
124+
ironlake_check_encoder_dotclock(pipe_config, dotclock);
125+
126+
pipe_config->adjusted_mode.clock = dotclock;
119127
}
120128

121129
/* The LVDS pin pair needs to be on before the DPLLs are enabled.

‎drivers/gpu/drm/i915/intel_sdvo.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,7 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
13161316
struct intel_sdvo *intel_sdvo = to_sdvo(encoder);
13171317
struct intel_sdvo_dtd dtd;
13181318
int encoder_pixel_multiplier = 0;
1319+
int dotclock;
13191320
u32 flags = 0, sdvox;
13201321
u8 val;
13211322
bool ret;
@@ -1354,6 +1355,13 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
13541355
>> SDVO_PORT_MULTIPLY_SHIFT) + 1;
13551356
}
13561357

1358+
dotclock = pipe_config->port_clock / pipe_config->pixel_multiplier;
1359+
1360+
if (HAS_PCH_SPLIT(dev))
1361+
ironlake_check_encoder_dotclock(pipe_config, dotclock);
1362+
1363+
pipe_config->adjusted_mode.clock = dotclock;
1364+
13571365
/* Cross check the port pixel multiplier with the sdvo encoder state. */
13581366
if (intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT,
13591367
&val, 1)) {

0 commit comments

Comments
 (0)