33 #include <linux/slab.h>
34 #include <linux/module.h>
43 static bool static_hdmi_pcm;
45 MODULE_PARM_DESC(static_hdmi_pcm,
"Don't restrict PCM parameters per ELD info");
54 #define MAX_HDMI_CVTS 8
55 #define MAX_HDMI_PINS 8
167 static int eld_speaker_allocation_bits[] = {
206 static int hdmi_channel_mapping[0x32][8] = {
208 [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
210 [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
212 [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 },
214 [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 },
216 [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 },
218 [0x09] = { 0x00, 0x11, 0x24, 0x35, 0x42, 0xf3, 0xf6, 0xf7 },
220 [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 },
222 [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 },
224 [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 },
235 { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0,
FR,
FL } },
237 { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0,
LFE,
FR,
FL } },
239 { .ca_index = 0x02, .speakers = { 0, 0, 0, 0,
FC, 0,
FR,
FL } },
241 { .ca_index = 0x08, .speakers = { 0, 0,
RR,
RL, 0, 0,
FR,
FL } },
243 { .ca_index = 0x09, .speakers = { 0, 0,
RR,
RL, 0,
LFE,
FR,
FL } },
245 { .ca_index = 0x0a, .speakers = { 0, 0,
RR,
RL,
FC, 0,
FR,
FL } },
247 { .ca_index = 0x0b, .speakers = { 0, 0,
RR,
RL,
FC,
LFE,
FR,
FL } },
253 { .ca_index = 0x03, .speakers = { 0, 0, 0, 0,
FC,
LFE,
FR,
FL } },
254 { .ca_index = 0x04, .speakers = { 0, 0, 0,
RC, 0, 0,
FR,
FL } },
255 { .ca_index = 0x05, .speakers = { 0, 0, 0,
RC, 0,
LFE,
FR,
FL } },
256 { .ca_index = 0x06, .speakers = { 0, 0, 0,
RC,
FC, 0,
FR,
FL } },
257 { .ca_index = 0x07, .speakers = { 0, 0, 0,
RC,
FC,
LFE,
FR,
FL } },
258 { .ca_index = 0x0c, .speakers = { 0,
RC,
RR,
RL, 0, 0,
FR,
FL } },
259 { .ca_index = 0x0d, .speakers = { 0,
RC,
RR,
RL, 0,
LFE,
FR,
FL } },
260 { .ca_index = 0x0e, .speakers = { 0,
RC,
RR,
RL,
FC, 0,
FR,
FL } },
261 { .ca_index = 0x10, .speakers = {
RRC,
RLC,
RR,
RL, 0, 0,
FR,
FL } },
264 { .ca_index = 0x14, .speakers = {
FRC,
FLC, 0, 0, 0, 0,
FR,
FL } },
265 { .ca_index = 0x15, .speakers = {
FRC,
FLC, 0, 0, 0,
LFE,
FR,
FL } },
266 { .ca_index = 0x16, .speakers = {
FRC,
FLC, 0, 0,
FC, 0,
FR,
FL } },
268 { .ca_index = 0x18, .speakers = {
FRC,
FLC, 0,
RC, 0, 0,
FR,
FL } },
270 { .ca_index = 0x1a, .speakers = {
FRC,
FLC, 0,
RC,
FC, 0,
FR,
FL } },
272 { .ca_index = 0x1c, .speakers = {
FRC,
FLC,
RR,
RL, 0, 0,
FR,
FL } },
276 { .ca_index = 0x20, .speakers = { 0,
FCH,
RR,
RL,
FC, 0,
FR,
FL } },
278 { .ca_index = 0x22, .speakers = {
TC, 0,
RR,
RL,
FC, 0,
FR,
FL } },
280 { .ca_index = 0x24, .speakers = {
FRH,
FLH,
RR,
RL, 0, 0,
FR,
FL } },
282 { .ca_index = 0x26, .speakers = {
FRW,
FLW,
RR,
RL, 0, 0,
FR,
FL } },
284 { .ca_index = 0x28, .speakers = {
TC,
RC,
RR,
RL,
FC, 0,
FR,
FL } },
305 for (pin_idx = 0; pin_idx < spec->
num_pins; pin_idx++)
306 if (spec->
pins[pin_idx].pin_nid == pin_nid)
313 static int hinfo_to_pin_index(
struct hdmi_spec *spec,
318 for (pin_idx = 0; pin_idx < spec->
num_pins; pin_idx++)
319 if (&spec->
pcm_rec[pin_idx].stream[0] == hinfo)
330 for (cvt_idx = 0; cvt_idx < spec->
num_cvts; cvt_idx++)
331 if (spec->
cvts[cvt_idx].cvt_nid == cvt_nid)
338 static int hdmi_eld_ctl_info(
struct snd_kcontrol *kcontrol,
349 uinfo->
count = spec->
pins[pin_idx].sink_eld.eld_size;
354 static int hdmi_eld_ctl_get(
struct snd_kcontrol *kcontrol,
374 .info = hdmi_eld_ctl_info,
375 .get = hdmi_eld_ctl_get,
378 static int hdmi_create_eld_ctl(
struct hda_codec *
codec,
int pin_idx,
389 kctl->
id.device = device;
407 *packet_index = val >> 5;
408 *byte_index = val & 0x1f;
417 val = (packet_index << 5) | (byte_index & 0x1f);
445 static void hdmi_set_channel_count(
struct hda_codec *codec,
448 if (chs != hdmi_get_channel_count(codec, cvt_nid))
461 static void init_channel_allocations(
void)
466 for (i = 0; i <
ARRAY_SIZE(channel_allocations); i++) {
467 p = channel_allocations +
i;
478 static int get_channel_allocation_order(
int ca)
482 for (i = 0; i <
ARRAY_SIZE(channel_allocations); i++) {
483 if (channel_allocations[i].
ca_index == ca)
516 for (i = 0; i <
ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
518 spk_mask |= eld_speaker_allocation_bits[i];
522 for (i = 0; i <
ARRAY_SIZE(channel_allocations); i++) {
523 if (channels == channel_allocations[i].channels &&
524 (spk_mask & channel_allocations[i].spk_mask) ==
532 snd_printdd(
"HDMI: select CA 0x%x for %d-channel allocation: %s\n",
538 static void hdmi_debug_channel_mapping(
struct hda_codec *codec,
541 #ifdef CONFIG_SND_DEBUG_VERBOSE
545 for (i = 0; i < 8; i++) {
549 slot >> 4, slot & 0xf);
555 static void hdmi_std_setup_channel_mapping(
struct hda_codec *codec,
563 int non_pcm_mapping[8];
565 order = get_channel_allocation_order(ca);
567 if (hdmi_channel_mapping[ca][1] == 0) {
569 hdmi_channel_mapping[ca][i] = i | (i << 4);
571 hdmi_channel_mapping[ca][i] = 0xf | (i << 4);
576 non_pcm_mapping[i] = i | (i << 4);
578 non_pcm_mapping[i] = 0xf | (i << 4);
581 for (i = 0; i < 8; i++) {
584 non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]);
587 "HDMI: channel mapping failed\n");
592 hdmi_debug_channel_mapping(codec, pin_nid);
614 static int to_spk_mask(
unsigned char c)
617 for (; t->
map; t++) {
625 static int to_cea_slot(
unsigned char c)
628 for (; t->
map; t++) {
636 static int from_cea_slot(
unsigned char c)
639 for (; t->
map; t++) {
647 static int spk_to_chmap(
int spk)
650 for (; t->
map; t++) {
658 static int hdmi_manual_channel_allocation(
int chs,
unsigned char *
map)
660 int i, spks = 0, spk_mask = 0;
662 for (i = 0; i < chs; i++) {
663 int mask = to_spk_mask(map[i]);
670 for (i = 0; i <
ARRAY_SIZE(channel_allocations); i++) {
671 if ((chs == channel_allocations[i].channels ||
672 spks == channel_allocations[i].channels) &&
673 (spk_mask & channel_allocations[
i].
spk_mask) ==
674 channel_allocations[i].spk_mask)
681 static int hdmi_manual_setup_channel_mapping(
struct hda_codec *codec,
683 int chs,
unsigned char *map)
686 for (i = 0; i < 8; i++) {
689 val = to_cea_slot(map[i]);
702 static void hdmi_setup_fake_chmap(
unsigned char *map,
int ca)
705 for (i = 0; i < 8; i++) {
706 if (i < channel_allocations[ca].channels)
707 map[
i] = from_cea_slot((hdmi_channel_mapping[ca][i] >> 4) & 0x0f);
713 static void hdmi_setup_channel_mapping(
struct hda_codec *codec,
715 int channels,
unsigned char *map)
717 if (!non_pcm && map) {
718 hdmi_manual_setup_channel_mapping(codec, pin_nid,
721 hdmi_std_setup_channel_mapping(codec, pin_nid, non_pcm, ca);
722 hdmi_setup_fake_chmap(map, ca);
733 static void hdmi_start_infoframe_trans(
struct hda_codec *codec,
736 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
744 static void hdmi_stop_infoframe_trans(
struct hda_codec *codec,
747 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
754 #ifdef CONFIG_SND_DEBUG_VERBOSE
761 for (i = 0; i < 8; i++) {
775 for (i = 0; i < 8; i++) {
781 hdmi_set_dip_index(codec, pin_nid, i, 0x0);
782 for (j = 1; j < 1000; j++) {
783 hdmi_write_dip_byte(codec, pin_nid, 0x0);
784 hdmi_get_dip_index(codec, pin_nid, &pi, &bi);
792 "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n",
806 for (i = 0; i <
sizeof(*hdmi_ai); i++)
809 hdmi_ai->checksum = -
sum;
812 static void hdmi_fill_audio_infoframe(
struct hda_codec *codec,
818 hdmi_debug_dip_size(codec, pin_nid);
819 hdmi_clear_dip_buffers(codec, pin_nid);
821 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
822 for (i = 0; i <
size; i++)
823 hdmi_write_dip_byte(codec, pin_nid, dip[i]);
836 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
837 for (i = 0; i <
size; i++) {
847 static void hdmi_setup_audio_infoframe(
struct hda_codec *codec,
int pin_idx,
854 int channels = substream->
runtime->channels;
859 eld = &spec->
pins[pin_idx].sink_eld;
860 if (!eld->monitor_present)
864 ca = hdmi_manual_channel_allocation(channels, per_pin->
chmap);
866 ca = hdmi_channel_allocation(eld, channels);
870 memset(&ai, 0,
sizeof(ai));
871 if (eld->conn_type == 0) {
874 hdmi_ai->
type = 0x84;
879 hdmi_checksum_audio_infoframe(hdmi_ai);
880 }
else if (eld->conn_type == 1) {
885 dp_ai->
ver = 0x11 << 2;
889 snd_printd(
"HDMI: unknown connection type at pin %d\n",
899 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
902 "pin=%d channels=%d\n",
905 hdmi_setup_channel_mapping(codec, pin_nid, non_pcm, ca,
906 channels, per_pin->
chmap);
907 hdmi_stop_infoframe_trans(codec, pin_nid);
908 hdmi_fill_audio_infoframe(codec, pin_nid,
909 ai.bytes,
sizeof(ai));
910 hdmi_start_infoframe_trans(codec, pin_nid);
914 if (per_pin->
non_pcm != non_pcm)
915 hdmi_setup_channel_mapping(codec, pin_nid, non_pcm, ca,
916 channels, per_pin->
chmap);
929 static void hdmi_intrinsic_event(
struct hda_codec *codec,
unsigned int res)
944 "HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
945 codec->
addr, pin_nid,
948 pin_idx = pin_nid_to_pin_index(spec, pin_nid);
952 hdmi_present_sense(&spec->
pins[pin_idx], 1);
956 static void hdmi_non_intrinsic_event(
struct hda_codec *codec,
unsigned int res)
964 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n",
979 static void hdmi_unsol_event(
struct hda_codec *codec,
unsigned int res)
990 hdmi_intrinsic_event(codec, res);
992 hdmi_non_intrinsic_event(codec, res);
1000 #define is_hbr_format(format) \
1001 ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7)
1020 "NID=0x%x, %spinctl=0x%x\n",
1022 pinctl == new_pinctl ?
"" :
"new-",
1025 if (pinctl != new_pinctl)
1032 snd_printdd(
"hdmi_setup_stream: HBR is not supported\n");
1049 int pin_idx, cvt_idx, mux_idx = 0;
1055 pin_idx = hinfo_to_pin_index(spec, hinfo);
1058 per_pin = &spec->
pins[pin_idx];
1062 for (cvt_idx = 0; cvt_idx < spec->
num_cvts; cvt_idx++) {
1063 per_cvt = &spec->
cvts[cvt_idx];
1069 for (mux_idx = 0; mux_idx < per_pin->
num_mux_nids; mux_idx++)
1098 if (!static_hdmi_pcm && eld->
eld_valid) {
1109 runtime->
hw.rates = hinfo->
rates;
1119 static int hdmi_read_pin_conn(
struct hda_codec *codec,
int pin_idx)
1127 "HDMI: pin %d wcaps %#x "
1128 "does not support connection list\n",
1129 pin_nid, get_wcaps(codec, pin_nid));
1163 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
1209 per_pin = &spec->
pins[pin_idx];
1214 err = hdmi_read_pin_conn(codec, pin_idx);
1234 chans = get_wcaps(codec, cvt_nid);
1235 chans = get_wcaps_channels(chans);
1238 per_cvt = &spec->
cvts[cvt_idx];
1260 static int hdmi_parse_codec(
struct hda_codec *codec)
1266 if (!nid || nodes < 0) {
1271 for (i = 0; i < nodes; i++, nid++) {
1276 type = get_wcaps_type(caps);
1283 hdmi_add_cvt(codec, nid);
1286 hdmi_add_pin(codec, nid);
1299 codec->
bus->power_keep_link_on = 1;
1307 static char *get_hdmi_pcm_name(
int idx)
1310 sprintf(&names[idx][0],
"HDMI %d", idx);
1311 return &names[
idx][0];
1331 static int generic_hdmi_playback_pcm_prepare(
struct hda_pcm_stream *hinfo,
1333 unsigned int stream_tag,
1339 int pin_idx = hinfo_to_pin_index(spec, hinfo);
1344 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
1346 hdmi_set_channel_count(codec, cvt_nid, substream->
runtime->channels);
1348 hdmi_setup_audio_infoframe(codec, pin_idx, non_pcm, substream);
1355 return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
1358 static int generic_hdmi_playback_pcm_cleanup(
struct hda_pcm_stream *hinfo,
1371 int cvt_idx, pin_idx;
1377 cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->
nid);
1380 per_cvt = &spec->
cvts[cvt_idx];
1386 pin_idx = hinfo_to_pin_index(spec, hinfo);
1389 per_pin = &spec->
pins[pin_idx];
1405 .open = hdmi_pcm_open,
1406 .close = hdmi_pcm_close,
1407 .prepare = generic_hdmi_playback_pcm_prepare,
1408 .cleanup = generic_hdmi_playback_pcm_cleanup,
1414 static int hdmi_chmap_ctl_info(
struct snd_kcontrol *kcontrol,
1427 static int hdmi_chmap_ctl_tlv(
struct snd_kcontrol *kcontrol,
int op_flag,
1428 unsigned int size,
unsigned int __user *
tlv)
1433 const unsigned int valid_mask =
1447 cap = channel_allocations;
1448 for (i = 0; i <
ARRAY_SIZE(channel_allocations); i++, cap++) {
1449 int chs_bytes = chs * 4;
1462 if (size < chs_bytes)
1466 for (c = 7; c >= 0; c--) {
1470 if (
put_user(spk_to_chmap(spk), dst))
1481 static int hdmi_chmap_ctl_get(
struct snd_kcontrol *kcontrol,
1492 ucontrol->
value.integer.value[i] = per_pin->
chmap[i];
1496 static int hdmi_chmap_ctl_put(
struct snd_kcontrol *kcontrol,
1504 unsigned int ctl_idx;
1506 unsigned char chmap[8];
1507 int i,
ca, prepared = 0;
1509 ctl_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
1510 substream = snd_pcm_chmap_substream(info, ctl_idx);
1511 if (!substream || !substream->
runtime)
1513 switch (substream->
runtime->status->state) {
1523 memset(chmap, 0,
sizeof(chmap));
1525 chmap[i] = ucontrol->
value.integer.value[i];
1528 ca = hdmi_manual_channel_allocation(
ARRAY_SIZE(chmap), chmap);
1534 hdmi_setup_audio_infoframe(codec, pin_idx, per_pin->
non_pcm,
1540 static int generic_hdmi_build_pcms(
struct hda_codec *codec)
1545 for (pin_idx = 0; pin_idx < spec->
num_pins; pin_idx++) {
1549 info = &spec->
pcm_rec[pin_idx];
1550 info->
name = get_hdmi_pcm_name(pin_idx);
1556 pstr->
ops = generic_ops;
1566 static int generic_hdmi_build_jack(
struct hda_codec *codec,
int pin_idx)
1568 char hdmi_str[32] =
"HDMI/DP";
1571 int pcmdev = spec->
pcm_rec[pin_idx].device;
1579 static int generic_hdmi_build_controls(
struct hda_codec *codec)
1585 for (pin_idx = 0; pin_idx < spec->
num_pins; pin_idx++) {
1588 err = generic_hdmi_build_jack(codec, pin_idx);
1600 err = hdmi_create_eld_ctl(codec,
1602 spec->
pcm_rec[pin_idx].device);
1607 hdmi_present_sense(per_pin, 0);
1611 for (pin_idx = 0; pin_idx < spec->
num_pins; pin_idx++) {
1617 NULL, 0, pin_idx, &chmap);
1623 for (i = 0; i < kctl->
count; i++)
1625 kctl->
info = hdmi_chmap_ctl_info;
1626 kctl->
get = hdmi_chmap_ctl_get;
1627 kctl->
put = hdmi_chmap_ctl_put;
1628 kctl->
tlv.
c = hdmi_chmap_ctl_tlv;
1634 static int generic_hdmi_init_per_pins(
struct hda_codec *codec)
1639 for (pin_idx = 0; pin_idx < spec->
num_pins; pin_idx++) {
1645 snd_hda_eld_proc_new(codec, eld, pin_idx);
1650 static int generic_hdmi_init(
struct hda_codec *codec)
1655 for (pin_idx = 0; pin_idx < spec->
num_pins; pin_idx++) {
1659 hdmi_init_pin(codec, pin_nid);
1665 static void generic_hdmi_free(
struct hda_codec *codec)
1670 for (pin_idx = 0; pin_idx < spec->
num_pins; pin_idx++) {
1675 snd_hda_eld_proc_free(codec, eld);
1682 static const struct hda_codec_ops generic_hdmi_patch_ops = {
1683 .init = generic_hdmi_init,
1684 .free = generic_hdmi_free,
1685 .build_pcms = generic_hdmi_build_pcms,
1686 .build_controls = generic_hdmi_build_controls,
1687 .unsol_event = hdmi_unsol_event,
1690 static int patch_generic_hdmi(
struct hda_codec *codec)
1699 if (hdmi_parse_codec(codec) < 0) {
1704 codec->
patch_ops = generic_hdmi_patch_ops;
1705 generic_hdmi_init_per_pins(codec);
1707 init_channel_allocations();
1716 static int simple_playback_build_pcms(
struct hda_codec *codec)
1726 chans = get_wcaps(codec, spec->
cvts[0].cvt_nid);
1727 chans = get_wcaps_channels(chans);
1729 info->
name = get_hdmi_pcm_name(0);
1733 pstr->
nid = spec->
cvts[0].cvt_nid;
1741 static void simple_hdmi_unsol_event(
struct hda_codec *codec,
1751 #define simple_hdmi_build_jack generic_hdmi_build_jack
1753 static int simple_playback_build_controls(
struct hda_codec *codec)
1759 spec->
cvts[0].cvt_nid,
1760 spec->
cvts[0].cvt_nid);
1766 static int simple_playback_init(
struct hda_codec *codec)
1781 static void simple_playback_free(
struct hda_codec *codec)
1792 #define Nv_VERB_SET_Channel_Allocation 0xF79
1793 #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A
1794 #define Nv_VERB_SET_Audio_Protection_On 0xF98
1795 #define Nv_VERB_SET_Audio_Protection_Off 0xF99
1797 #define nvhdmi_master_con_nid_7x 0x04
1798 #define nvhdmi_master_pin_nid_7x 0x05
1800 static const hda_nid_t nvhdmi_con_nids_7x[4] = {
1805 static const struct hda_verb nvhdmi_basic_init_7x_2ch[] = {
1813 static const struct hda_verb nvhdmi_basic_init_7x_8ch[] = {
1825 #ifdef LIMITED_RATE_FMT_SUPPORT
1827 #define SUPPORTED_RATES SNDRV_PCM_RATE_48000
1828 #define SUPPORTED_MAXBPS 16
1829 #define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE
1832 #define SUPPORTED_RATES \
1833 (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
1834 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\
1835 SNDRV_PCM_RATE_192000)
1836 #define SUPPORTED_MAXBPS 24
1837 #define SUPPORTED_FORMATS \
1838 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
1841 static int nvhdmi_7x_init_2ch(
struct hda_codec *codec)
1847 static int nvhdmi_7x_init_8ch(
struct hda_codec *codec)
1853 static unsigned int channels_2_6_8[] = {
1857 static unsigned int channels_2_8[] = {
1863 .list = channels_2_6_8,
1869 .list = channels_2_8,
1873 static int simple_playback_pcm_open(
struct hda_pcm_stream *hinfo,
1880 switch (codec->
preset->id) {
1885 hw_constraints_channels = &hw_constraints_2_8_channels;
1888 hw_constraints_channels = &hw_constraints_2_6_8_channels;
1894 if (hw_constraints_channels !=
NULL) {
1897 hw_constraints_channels);
1906 static int simple_playback_pcm_close(
struct hda_pcm_stream *hinfo,
1914 static int simple_playback_pcm_prepare(
struct hda_pcm_stream *hinfo,
1916 unsigned int stream_tag,
1922 stream_tag, format, substream);
1930 .open = simple_playback_pcm_open,
1931 .close = simple_playback_pcm_close,
1932 .prepare = simple_playback_pcm_prepare
1937 .build_controls = simple_playback_build_controls,
1938 .build_pcms = simple_playback_build_pcms,
1939 .init = simple_playback_init,
1940 .free = simple_playback_free,
1941 .unsol_event = simple_hdmi_unsol_event,
1944 static int patch_simple_hdmi(
struct hda_codec *codec,
1957 spec->
multiout.dig_out_nid = cvt_nid;
1960 spec->
cvts[0].cvt_nid = cvt_nid;
1961 spec->
pins[0].pin_nid = pin_nid;
1964 codec->
patch_ops = simple_hdmi_patch_ops;
1969 static void nvhdmi_8ch_7x_set_info_frame_parameters(
struct hda_codec *codec,
1972 unsigned int chanmask;
1973 int chan = channels ? (channels - 1) : 1;
1999 (0x71 - chan - chanmask));
2011 for (i = 0; i < 4; i++) {
2022 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8);
2027 static int nvhdmi_8ch_7x_pcm_prepare(
struct hda_pcm_stream *hinfo,
2029 unsigned int stream_tag,
2034 unsigned int dataDCC2, channel_id;
2042 chs = substream->
runtime->channels;
2069 spdif->
ctls & 0xff);
2076 for (i = 0; i < 4; i++) {
2088 nvhdmi_con_nids_7x[i],
2094 nvhdmi_con_nids_7x[i],
2097 (stream_tag << 4) | channel_id);
2100 nvhdmi_con_nids_7x[i],
2109 nvhdmi_con_nids_7x[i],
2112 spdif->
ctls & 0xff);
2114 nvhdmi_con_nids_7x[i],
2120 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs);
2126 static const struct hda_pcm_stream nvhdmi_pcm_playback_8ch_7x = {
2135 .open = simple_playback_pcm_open,
2136 .close = nvhdmi_8ch_7x_pcm_close,
2137 .prepare = nvhdmi_8ch_7x_pcm_prepare
2141 static int patch_nvhdmi_2ch(
struct hda_codec *codec)
2149 codec->
patch_ops.init = nvhdmi_7x_init_2ch;
2158 static int nvhdmi_7x_8ch_build_pcms(
struct hda_codec *codec)
2161 int err = simple_playback_build_pcms(codec);
2162 spec->
pcm_rec[0].own_chmap =
true;
2166 static int nvhdmi_7x_8ch_build_controls(
struct hda_codec *codec)
2172 err = simple_playback_build_controls(codec);
2182 switch (codec->
preset->id) {
2195 static int patch_nvhdmi_8ch_7x(
struct hda_codec *codec)
2198 int err = patch_nvhdmi_2ch(codec);
2204 codec->
patch_ops.init = nvhdmi_7x_init_8ch;
2205 codec->
patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms;
2206 codec->
patch_ops.build_controls = nvhdmi_7x_8ch_build_controls;
2210 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8);
2222 #define ATIHDMI_CVT_NID 0x02
2223 #define ATIHDMI_PIN_NID 0x03
2225 static int atihdmi_playback_pcm_prepare(
struct hda_pcm_stream *hinfo,
2227 unsigned int stream_tag,
2228 unsigned int format,
2232 int chans = substream->
runtime->channels;
2235 err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format,
2242 for (i = 0; i < chans; i++) {
2250 static int patch_atihdmi(
struct hda_codec *codec)
2257 spec->
pcm_playback.ops.prepare = atihdmi_playback_pcm_prepare;
2262 #define VIAHDMI_CVT_NID 0x02
2263 #define VIAHDMI_PIN_NID 0x03
2265 static int patch_via_hdmi(
struct hda_codec *codec)
2274 { .id = 0x1002793c, .name =
"RS600 HDMI", .patch = patch_atihdmi },
2275 { .id = 0x10027919, .name =
"RS600 HDMI", .patch = patch_atihdmi },
2276 { .id = 0x1002791a, .name =
"RS690/780 HDMI", .patch = patch_atihdmi },
2277 { .id = 0x1002aa01, .name =
"R6xx HDMI", .patch = patch_generic_hdmi },
2278 { .id = 0x10951390, .name =
"SiI1390 HDMI", .patch = patch_generic_hdmi },
2279 { .id = 0x10951392, .name =
"SiI1392 HDMI", .patch = patch_generic_hdmi },
2280 { .id = 0x17e80047, .name =
"Chrontel HDMI", .patch = patch_generic_hdmi },
2281 { .id = 0x10de0002, .name =
"MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
2282 { .id = 0x10de0003, .name =
"MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
2283 { .id = 0x10de0005, .name =
"MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
2284 { .id = 0x10de0006, .name =
"MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
2285 { .id = 0x10de0007, .name =
"MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x },
2286 { .id = 0x10de000a, .name =
"GPU 0a HDMI/DP", .patch = patch_generic_hdmi },
2287 { .id = 0x10de000b, .name =
"GPU 0b HDMI/DP", .patch = patch_generic_hdmi },
2288 { .id = 0x10de000c, .name =
"MCP89 HDMI", .patch = patch_generic_hdmi },
2289 { .id = 0x10de000d, .name =
"GPU 0d HDMI/DP", .patch = patch_generic_hdmi },
2290 { .id = 0x10de0010, .name =
"GPU 10 HDMI/DP", .patch = patch_generic_hdmi },
2291 { .id = 0x10de0011, .name =
"GPU 11 HDMI/DP", .patch = patch_generic_hdmi },
2292 { .id = 0x10de0012, .name =
"GPU 12 HDMI/DP", .patch = patch_generic_hdmi },
2293 { .id = 0x10de0013, .name =
"GPU 13 HDMI/DP", .patch = patch_generic_hdmi },
2294 { .id = 0x10de0014, .name =
"GPU 14 HDMI/DP", .patch = patch_generic_hdmi },
2295 { .id = 0x10de0015, .name =
"GPU 15 HDMI/DP", .patch = patch_generic_hdmi },
2296 { .id = 0x10de0016, .name =
"GPU 16 HDMI/DP", .patch = patch_generic_hdmi },
2298 { .id = 0x10de0018, .name =
"GPU 18 HDMI/DP", .patch = patch_generic_hdmi },
2299 { .id = 0x10de0019, .name =
"GPU 19 HDMI/DP", .patch = patch_generic_hdmi },
2300 { .id = 0x10de001a, .name =
"GPU 1a HDMI/DP", .patch = patch_generic_hdmi },
2301 { .id = 0x10de001b, .name =
"GPU 1b HDMI/DP", .patch = patch_generic_hdmi },
2302 { .id = 0x10de001c, .name =
"GPU 1c HDMI/DP", .patch = patch_generic_hdmi },
2303 { .id = 0x10de0040, .name =
"GPU 40 HDMI/DP", .patch = patch_generic_hdmi },
2304 { .id = 0x10de0041, .name =
"GPU 41 HDMI/DP", .patch = patch_generic_hdmi },
2305 { .id = 0x10de0042, .name =
"GPU 42 HDMI/DP", .patch = patch_generic_hdmi },
2306 { .id = 0x10de0043, .name =
"GPU 43 HDMI/DP", .patch = patch_generic_hdmi },
2307 { .id = 0x10de0044, .name =
"GPU 44 HDMI/DP", .patch = patch_generic_hdmi },
2308 { .id = 0x10de0051, .name =
"GPU 51 HDMI/DP", .patch = patch_generic_hdmi },
2309 { .id = 0x10de0067, .name =
"MCP67 HDMI", .patch = patch_nvhdmi_2ch },
2310 { .id = 0x10de8001, .name =
"MCP73 HDMI", .patch = patch_nvhdmi_2ch },
2311 { .id = 0x11069f80, .name =
"VX900 HDMI/DP", .patch = patch_via_hdmi },
2312 { .id = 0x11069f81, .name =
"VX900 HDMI/DP", .patch = patch_via_hdmi },
2313 { .id = 0x11069f84, .name =
"VX11 HDMI/DP", .patch = patch_generic_hdmi },
2314 { .id = 0x11069f85, .name =
"VX11 HDMI/DP", .patch = patch_generic_hdmi },
2315 { .id = 0x80860054, .name =
"IbexPeak HDMI", .patch = patch_generic_hdmi },
2316 { .id = 0x80862801, .name =
"Bearlake HDMI", .patch = patch_generic_hdmi },
2317 { .id = 0x80862802, .name =
"Cantiga HDMI", .patch = patch_generic_hdmi },
2318 { .id = 0x80862803, .name =
"Eaglelake HDMI", .patch = patch_generic_hdmi },
2319 { .id = 0x80862804, .name =
"IbexPeak HDMI", .patch = patch_generic_hdmi },
2320 { .id = 0x80862805, .name =
"CougarPoint HDMI", .patch = patch_generic_hdmi },
2321 { .id = 0x80862806, .name =
"PantherPoint HDMI", .patch = patch_generic_hdmi },
2322 { .id = 0x80862807, .name =
"Haswell HDMI", .patch = patch_generic_hdmi },
2323 { .id = 0x80862880, .name =
"CedarTrail HDMI", .patch = patch_generic_hdmi },
2324 { .id = 0x808629fb, .name =
"Crestline HDMI", .patch = patch_generic_hdmi },
2386 .preset = snd_hda_preset_hdmi,
2390 static int __init patch_hdmi_init(
void)
2395 static void __exit patch_hdmi_exit(
void)