Skip to content

Commit 2c29141

Browse files
aditya23788vsyrjala
authored andcommitted
drm/i915: Add N & CTS values for 10/12 bit deep color
Adding N & CTS values for 10/12 bit deep color from Appendix C table in HDMI 2.0 spec. The correct values for N is not chosen automatically by hardware for deep color modes. v2: Remove unnecessary initialization of size Signed-off-by: Aditya Swarup <[email protected]> Cc: Clint Taylor <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Ville Syrjälä <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4a49c2b commit 2c29141

File tree

1 file changed

+68
-11
lines changed

1 file changed

+68
-11
lines changed

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

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ struct dp_aud_n_m {
7272
u16 n;
7373
};
7474

75+
struct hdmi_aud_ncts {
76+
int sample_rate;
77+
int clock;
78+
int n;
79+
int cts;
80+
};
81+
7582
/* Values according to DP 1.4 Table 2-104 */
7683
static const struct dp_aud_n_m dp_aud_n_m[] = {
7784
{ 32000, LC_162M, 1024, 10125 },
@@ -148,12 +155,7 @@ static const struct {
148155
#define TMDS_594M 594000
149156
#define TMDS_593M 593407
150157

151-
static const struct {
152-
int sample_rate;
153-
int clock;
154-
int n;
155-
int cts;
156-
} hdmi_aud_ncts[] = {
158+
static const struct hdmi_aud_ncts hdmi_aud_ncts_24bpp[] = {
157159
{ 32000, TMDS_296M, 5824, 421875 },
158160
{ 32000, TMDS_297M, 3072, 222750 },
159161
{ 32000, TMDS_593M, 5824, 843750 },
@@ -184,6 +186,49 @@ static const struct {
184186
{ 192000, TMDS_594M, 24576, 594000 },
185187
};
186188

189+
/* Appendix C - N & CTS values for deep color from HDMI 2.0 spec*/
190+
/* HDMI N/CTS table for 10 bit deep color(30 bpp)*/
191+
#define TMDS_371M 371250
192+
#define TMDS_370M 370878
193+
194+
static const struct hdmi_aud_ncts hdmi_aud_ncts_30bpp[] = {
195+
{ 32000, TMDS_370M, 5824, 527344 },
196+
{ 32000, TMDS_371M, 6144, 556875 },
197+
{ 44100, TMDS_370M, 8918, 585938 },
198+
{ 44100, TMDS_371M, 4704, 309375 },
199+
{ 88200, TMDS_370M, 17836, 585938 },
200+
{ 88200, TMDS_371M, 9408, 309375 },
201+
{ 176400, TMDS_370M, 35672, 585938 },
202+
{ 176400, TMDS_371M, 18816, 309375 },
203+
{ 48000, TMDS_370M, 11648, 703125 },
204+
{ 48000, TMDS_371M, 5120, 309375 },
205+
{ 96000, TMDS_370M, 23296, 703125 },
206+
{ 96000, TMDS_371M, 10240, 309375 },
207+
{ 192000, TMDS_370M, 46592, 703125 },
208+
{ 192000, TMDS_371M, 20480, 309375 },
209+
};
210+
211+
/* HDMI N/CTS table for 12 bit deep color(36 bpp)*/
212+
#define TMDS_445_5M 445500
213+
#define TMDS_445M 445054
214+
215+
static const struct hdmi_aud_ncts hdmi_aud_ncts_36bpp[] = {
216+
{ 32000, TMDS_445M, 5824, 632813 },
217+
{ 32000, TMDS_445_5M, 4096, 445500 },
218+
{ 44100, TMDS_445M, 8918, 703125 },
219+
{ 44100, TMDS_445_5M, 4704, 371250 },
220+
{ 88200, TMDS_445M, 17836, 703125 },
221+
{ 88200, TMDS_445_5M, 9408, 371250 },
222+
{ 176400, TMDS_445M, 35672, 703125 },
223+
{ 176400, TMDS_445_5M, 18816, 371250 },
224+
{ 48000, TMDS_445M, 5824, 421875 },
225+
{ 48000, TMDS_445_5M, 5120, 371250 },
226+
{ 96000, TMDS_445M, 11648, 421875 },
227+
{ 96000, TMDS_445_5M, 10240, 371250 },
228+
{ 192000, TMDS_445M, 23296, 421875 },
229+
{ 192000, TMDS_445_5M, 20480, 371250 },
230+
};
231+
187232
/* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */
188233
static u32 audio_config_hdmi_pixel_clock(const struct intel_crtc_state *crtc_state)
189234
{
@@ -212,12 +257,24 @@ static u32 audio_config_hdmi_pixel_clock(const struct intel_crtc_state *crtc_sta
212257
static int audio_config_hdmi_get_n(const struct intel_crtc_state *crtc_state,
213258
int rate)
214259
{
215-
int i;
260+
const struct hdmi_aud_ncts *hdmi_ncts_table;
261+
int i, size;
262+
263+
if (crtc_state->pipe_bpp == 36) {
264+
hdmi_ncts_table = hdmi_aud_ncts_36bpp;
265+
size = ARRAY_SIZE(hdmi_aud_ncts_36bpp);
266+
} else if (crtc_state->pipe_bpp == 30) {
267+
hdmi_ncts_table = hdmi_aud_ncts_30bpp;
268+
size = ARRAY_SIZE(hdmi_aud_ncts_30bpp);
269+
} else {
270+
hdmi_ncts_table = hdmi_aud_ncts_24bpp;
271+
size = ARRAY_SIZE(hdmi_aud_ncts_24bpp);
272+
}
216273

217-
for (i = 0; i < ARRAY_SIZE(hdmi_aud_ncts); i++) {
218-
if (rate == hdmi_aud_ncts[i].sample_rate &&
219-
crtc_state->port_clock == hdmi_aud_ncts[i].clock) {
220-
return hdmi_aud_ncts[i].n;
274+
for (i = 0; i < size; i++) {
275+
if (rate == hdmi_ncts_table[i].sample_rate &&
276+
crtc_state->port_clock == hdmi_ncts_table[i].clock) {
277+
return hdmi_ncts_table[i].n;
221278
}
222279
}
223280
return 0;

0 commit comments

Comments
 (0)