Skip to content

Commit 594c05a

Browse files
committed
drm/i915/audio: Fix audio time stamp programming for DP
jira LE-1907 Rebuild_History Non-Buildable kernel-5.14.0-427.31.1.el9_4 commit-author Chaitanya Kumar Borah <[email protected]> commit 8e056b5 Intel hardware is capable of programming the Maud/Naud SDPs on its own based on real-time clocks. While doing so, it takes care of any deviations from the theoretical values. Programming the registers explicitly with static values can interfere with this logic. Therefore, let the HW decide the Maud and Naud SDPs on it's own. Cc: [email protected] # v5.17 Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8097 Co-developed-by: Kai Vehmanen <[email protected]> Signed-off-by: Kai Vehmanen <[email protected]> Signed-off-by: Chaitanya Kumar Borah <[email protected]> Reviewed-by: Uma Shankar <[email protected]> Signed-off-by: Animesh Manna <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 8e056b5) Signed-off-by: Jonathan Maple <[email protected]>
1 parent c89b250 commit 594c05a

File tree

1 file changed

+8
-105
lines changed

1 file changed

+8
-105
lines changed

drivers/gpu/drm/i915/display/intel_audio.c

Lines changed: 8 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -75,80 +75,13 @@ struct intel_audio_funcs {
7575
struct intel_crtc_state *crtc_state);
7676
};
7777

78-
/* DP N/M table */
79-
#define LC_810M 810000
80-
#define LC_540M 540000
81-
#define LC_270M 270000
82-
#define LC_162M 162000
83-
84-
struct dp_aud_n_m {
85-
int sample_rate;
86-
int clock;
87-
u16 m;
88-
u16 n;
89-
};
90-
9178
struct hdmi_aud_ncts {
9279
int sample_rate;
9380
int clock;
9481
int n;
9582
int cts;
9683
};
9784

98-
/* Values according to DP 1.4 Table 2-104 */
99-
static const struct dp_aud_n_m dp_aud_n_m[] = {
100-
{ 32000, LC_162M, 1024, 10125 },
101-
{ 44100, LC_162M, 784, 5625 },
102-
{ 48000, LC_162M, 512, 3375 },
103-
{ 64000, LC_162M, 2048, 10125 },
104-
{ 88200, LC_162M, 1568, 5625 },
105-
{ 96000, LC_162M, 1024, 3375 },
106-
{ 128000, LC_162M, 4096, 10125 },
107-
{ 176400, LC_162M, 3136, 5625 },
108-
{ 192000, LC_162M, 2048, 3375 },
109-
{ 32000, LC_270M, 1024, 16875 },
110-
{ 44100, LC_270M, 784, 9375 },
111-
{ 48000, LC_270M, 512, 5625 },
112-
{ 64000, LC_270M, 2048, 16875 },
113-
{ 88200, LC_270M, 1568, 9375 },
114-
{ 96000, LC_270M, 1024, 5625 },
115-
{ 128000, LC_270M, 4096, 16875 },
116-
{ 176400, LC_270M, 3136, 9375 },
117-
{ 192000, LC_270M, 2048, 5625 },
118-
{ 32000, LC_540M, 1024, 33750 },
119-
{ 44100, LC_540M, 784, 18750 },
120-
{ 48000, LC_540M, 512, 11250 },
121-
{ 64000, LC_540M, 2048, 33750 },
122-
{ 88200, LC_540M, 1568, 18750 },
123-
{ 96000, LC_540M, 1024, 11250 },
124-
{ 128000, LC_540M, 4096, 33750 },
125-
{ 176400, LC_540M, 3136, 18750 },
126-
{ 192000, LC_540M, 2048, 11250 },
127-
{ 32000, LC_810M, 1024, 50625 },
128-
{ 44100, LC_810M, 784, 28125 },
129-
{ 48000, LC_810M, 512, 16875 },
130-
{ 64000, LC_810M, 2048, 50625 },
131-
{ 88200, LC_810M, 1568, 28125 },
132-
{ 96000, LC_810M, 1024, 16875 },
133-
{ 128000, LC_810M, 4096, 50625 },
134-
{ 176400, LC_810M, 3136, 28125 },
135-
{ 192000, LC_810M, 2048, 16875 },
136-
};
137-
138-
static const struct dp_aud_n_m *
139-
audio_config_dp_get_n_m(const struct intel_crtc_state *crtc_state, int rate)
140-
{
141-
int i;
142-
143-
for (i = 0; i < ARRAY_SIZE(dp_aud_n_m); i++) {
144-
if (rate == dp_aud_n_m[i].sample_rate &&
145-
crtc_state->port_clock == dp_aud_n_m[i].clock)
146-
return &dp_aud_n_m[i];
147-
}
148-
149-
return NULL;
150-
}
151-
15285
static const struct {
15386
int clock;
15487
u32 config;
@@ -386,47 +319,17 @@ hsw_dp_audio_config_update(struct intel_encoder *encoder,
386319
const struct intel_crtc_state *crtc_state)
387320
{
388321
struct drm_i915_private *i915 = to_i915(encoder->base.dev);
389-
struct i915_audio_component *acomp = i915->display.audio.component;
390322
enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
391-
enum port port = encoder->port;
392-
const struct dp_aud_n_m *nm;
393-
int rate;
394-
u32 tmp;
395-
396-
rate = acomp ? acomp->aud_sample_rate[port] : 0;
397-
nm = audio_config_dp_get_n_m(crtc_state, rate);
398-
if (nm)
399-
drm_dbg_kms(&i915->drm, "using Maud %u, Naud %u\n", nm->m,
400-
nm->n);
401-
else
402-
drm_dbg_kms(&i915->drm, "using automatic Maud, Naud\n");
403-
404-
tmp = intel_de_read(i915, HSW_AUD_CFG(cpu_transcoder));
405-
tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
406-
tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
407-
tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
408-
tmp |= AUD_CONFIG_N_VALUE_INDEX;
409323

410-
if (nm) {
411-
tmp &= ~AUD_CONFIG_N_MASK;
412-
tmp |= AUD_CONFIG_N(nm->n);
413-
tmp |= AUD_CONFIG_N_PROG_ENABLE;
414-
}
415-
416-
intel_de_write(i915, HSW_AUD_CFG(cpu_transcoder), tmp);
417-
418-
tmp = intel_de_read(i915, HSW_AUD_M_CTS_ENABLE(cpu_transcoder));
419-
tmp &= ~AUD_CONFIG_M_MASK;
420-
tmp &= ~AUD_M_CTS_M_VALUE_INDEX;
421-
tmp &= ~AUD_M_CTS_M_PROG_ENABLE;
422-
423-
if (nm) {
424-
tmp |= nm->m;
425-
tmp |= AUD_M_CTS_M_VALUE_INDEX;
426-
tmp |= AUD_M_CTS_M_PROG_ENABLE;
427-
}
324+
/* Enable time stamps. Let HW calculate Maud/Naud values */
325+
intel_de_rmw(i915, HSW_AUD_CFG(cpu_transcoder),
326+
AUD_CONFIG_N_VALUE_INDEX |
327+
AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK |
328+
AUD_CONFIG_UPPER_N_MASK |
329+
AUD_CONFIG_LOWER_N_MASK |
330+
AUD_CONFIG_N_PROG_ENABLE,
331+
AUD_CONFIG_N_VALUE_INDEX);
428332

429-
intel_de_write(i915, HSW_AUD_M_CTS_ENABLE(cpu_transcoder), tmp);
430333
}
431334

432335
static void

0 commit comments

Comments
 (0)