Lines Matching +full:tegra186 +full:- +full:display
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * patch_hdmi.c - routines for HDMI/DisplayPort codecs
6 * Copyright(c) 2008-2010 Intel Corporation. All rights reserved.
82 struct hdmi_pcm *pcm; /* pointer to spec->pcm_rec[n] dynamically*/
83 int pcm_idx; /* which pcm is attached. -1 means no pcm is attached */
90 bool chmap_set; /* channel-map override by ALSA API? */
91 unsigned char chmap[8]; /* ALSA API channel-map */
127 SILENT_STREAM_KAE, /* use standard HDA Keep-Alive */
176 bool intel_hsw_fixup; /* apply Intel platform-specific fixups */
178 * Non-generic VIA/NVIDIA specific
199 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
200 return spec->use_acomp_notifier; in codec_has_acomp()
243 ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx))
245 ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx))
247 #define get_hdmi_pcm(spec, idx) (&(spec)->pcm_rec[idx])
249 #define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm)
254 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
259 * (dev_id == -1) means it is NON-MST pin in pin_id_to_pin_index()
262 if (dev_id == -1) in pin_id_to_pin_index()
265 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in pin_id_to_pin_index()
267 if ((per_pin->pin_nid == pin_nid) && in pin_id_to_pin_index()
268 (per_pin->dev_id == dev_id)) in pin_id_to_pin_index()
273 return -EINVAL; in pin_id_to_pin_index()
279 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
282 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) in hinfo_to_pcm_index()
283 if (get_pcm_rec(spec, pcm_idx)->stream == hinfo) in hinfo_to_pcm_index()
287 return -EINVAL; in hinfo_to_pcm_index()
293 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
297 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in hinfo_to_pin_index()
299 if (per_pin->pcm && in hinfo_to_pin_index()
300 per_pin->pcm->pcm->stream == hinfo) in hinfo_to_pin_index()
306 return -EINVAL; in hinfo_to_pin_index()
315 for (i = 0; i < spec->num_pins; i++) { in pcm_idx_to_pin()
317 if (per_pin->pcm_idx == pcm_idx) in pcm_idx_to_pin()
325 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
328 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) in cvt_nid_to_cvt_index()
329 if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid) in cvt_nid_to_cvt_index()
333 return -EINVAL; in cvt_nid_to_cvt_index()
340 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
345 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdmi_eld_ctl_info()
347 pcm_idx = kcontrol->private_value; in hdmi_eld_ctl_info()
348 mutex_lock(&spec->pcm_lock); in hdmi_eld_ctl_info()
352 uinfo->count = 0; in hdmi_eld_ctl_info()
355 eld = &per_pin->sink_eld; in hdmi_eld_ctl_info()
356 uinfo->count = eld->eld_valid ? eld->eld_size : 0; in hdmi_eld_ctl_info()
359 mutex_unlock(&spec->pcm_lock); in hdmi_eld_ctl_info()
367 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
373 pcm_idx = kcontrol->private_value; in hdmi_eld_ctl_get()
374 mutex_lock(&spec->pcm_lock); in hdmi_eld_ctl_get()
378 memset(ucontrol->value.bytes.data, 0, in hdmi_eld_ctl_get()
379 ARRAY_SIZE(ucontrol->value.bytes.data)); in hdmi_eld_ctl_get()
383 eld = &per_pin->sink_eld; in hdmi_eld_ctl_get()
384 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) || in hdmi_eld_ctl_get()
385 eld->eld_size > ELD_MAX_SIZE) { in hdmi_eld_ctl_get()
387 err = -EINVAL; in hdmi_eld_ctl_get()
391 memset(ucontrol->value.bytes.data, 0, in hdmi_eld_ctl_get()
392 ARRAY_SIZE(ucontrol->value.bytes.data)); in hdmi_eld_ctl_get()
393 if (eld->eld_valid) in hdmi_eld_ctl_get()
394 memcpy(ucontrol->value.bytes.data, eld->eld_buffer, in hdmi_eld_ctl_get()
395 eld->eld_size); in hdmi_eld_ctl_get()
398 mutex_unlock(&spec->pcm_lock); in hdmi_eld_ctl_get()
415 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
420 return -ENOMEM; in hdmi_create_eld_ctl()
421 kctl->private_value = pcm_idx; in hdmi_create_eld_ctl()
422 kctl->id.device = device; in hdmi_create_eld_ctl()
431 get_hdmi_pcm(spec, pcm_idx)->eld_ctl = kctl; in hdmi_create_eld_ctl()
467 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
475 if (spec->dyn_pin_out) in hdmi_init_pin()
496 struct hdmi_spec_per_pin *per_pin = entry->private_data; in print_eld_info()
498 mutex_lock(&per_pin->lock); in print_eld_info()
499 snd_hdmi_print_eld_info(&per_pin->sink_eld, buffer, per_pin->pin_nid, in print_eld_info()
500 per_pin->dev_id, per_pin->cvt_nid); in print_eld_info()
501 mutex_unlock(&per_pin->lock); in print_eld_info()
507 struct hdmi_spec_per_pin *per_pin = entry->private_data; in write_eld_info()
509 mutex_lock(&per_pin->lock); in write_eld_info()
510 snd_hdmi_write_eld_info(&per_pin->sink_eld, buffer); in write_eld_info()
511 mutex_unlock(&per_pin->lock); in write_eld_info()
517 struct hda_codec *codec = per_pin->codec; in eld_proc_new()
521 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
522 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
527 entry->c.text.write = write_eld_info; in eld_proc_new()
528 entry->mode |= 0200; in eld_proc_new()
529 per_pin->proc_entry = entry; in eld_proc_new()
536 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
537 snd_info_free_entry(per_pin->proc_entry); in eld_proc_free()
538 per_pin->proc_entry = NULL; in eld_proc_free()
630 hdmi_ai->checksum = 0; in hdmi_checksum_audio_infoframe()
635 hdmi_ai->checksum = -sum; in hdmi_checksum_audio_infoframe()
686 struct hdmi_spec *spec = codec->spec; in hdmi_pin_setup_infoframe()
692 (conn_type == 1 && spec->nv_dp_workaround)) { in hdmi_pin_setup_infoframe()
696 hdmi_ai->type = 0x84; in hdmi_pin_setup_infoframe()
697 hdmi_ai->ver = 0x01; in hdmi_pin_setup_infoframe()
698 hdmi_ai->len = 0x0a; in hdmi_pin_setup_infoframe()
700 hdmi_ai->type = 0x84; in hdmi_pin_setup_infoframe()
701 hdmi_ai->ver = 0x1b; in hdmi_pin_setup_infoframe()
702 hdmi_ai->len = 0x11 << 2; in hdmi_pin_setup_infoframe()
704 hdmi_ai->CC02_CT47 = active_channels - 1; in hdmi_pin_setup_infoframe()
705 hdmi_ai->CA = ca; in hdmi_pin_setup_infoframe()
710 dp_ai->type = 0x84; in hdmi_pin_setup_infoframe()
711 dp_ai->len = 0x1b; in hdmi_pin_setup_infoframe()
712 dp_ai->ver = 0x11 << 2; in hdmi_pin_setup_infoframe()
713 dp_ai->CC02_CT47 = active_channels - 1; in hdmi_pin_setup_infoframe()
714 dp_ai->CA = ca; in hdmi_pin_setup_infoframe()
742 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
743 struct hdac_chmap *chmap = &spec->chmap; in hdmi_setup_audio_infoframe()
744 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_setup_audio_infoframe()
745 int dev_id = per_pin->dev_id; in hdmi_setup_audio_infoframe()
746 int channels = per_pin->channels; in hdmi_setup_audio_infoframe()
762 eld = &per_pin->sink_eld; in hdmi_setup_audio_infoframe()
764 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
765 eld->info.spk_alloc, channels, in hdmi_setup_audio_infoframe()
766 per_pin->chmap_set, non_pcm, per_pin->chmap); in hdmi_setup_audio_infoframe()
770 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
777 snd_hdac_setup_channel_mapping(&spec->chmap, in hdmi_setup_audio_infoframe()
779 per_pin->chmap, per_pin->chmap_set); in hdmi_setup_audio_infoframe()
781 spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id, in hdmi_setup_audio_infoframe()
782 ca, active_channels, eld->info.conn_type); in hdmi_setup_audio_infoframe()
784 per_pin->non_pcm = non_pcm; in hdmi_setup_audio_infoframe()
796 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
801 mutex_lock(&spec->pcm_lock); in check_presence_and_report()
803 mutex_unlock(&spec->pcm_lock); in check_presence_and_report()
813 check_presence_and_report(codec, jack->nid, jack->dev_id); in jack_callback()
819 jack->jack_dirty = 1; in hdmi_intrinsic_event()
823 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
826 check_presence_and_report(codec, jack->nid, jack->dev_id); in hdmi_intrinsic_event()
838 codec->addr, in hdmi_non_intrinsic_event()
863 if (codec->dp_mst) { in hdmi_unsol_event()
908 /* HBR should be Non-PCM, 8 channels */
923 return hbr ? -EINVAL : 0; in hdmi_pin_hbr_setup()
934 pinctl == new_pinctl ? "" : "new-", in hdmi_pin_hbr_setup()
942 return -EINVAL; in hdmi_pin_hbr_setup()
951 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
955 err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id, in hdmi_setup_stream()
963 if (spec->intel_hsw_fixup) { in hdmi_setup_stream()
996 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
1007 if (per_pin && per_pin->silent_stream) { in hdmi_choose_cvt()
1008 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in hdmi_choose_cvt()
1010 if (per_cvt->assigned && !silent) in hdmi_choose_cvt()
1011 return -EBUSY; in hdmi_choose_cvt()
1018 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in hdmi_choose_cvt()
1022 if (per_cvt->assigned || per_cvt->silent_stream) in hdmi_choose_cvt()
1027 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++) in hdmi_choose_cvt()
1028 if (per_pin->mux_nids[mux_idx] == per_cvt->cvt_nid) in hdmi_choose_cvt()
1031 if (mux_idx == per_pin->num_mux_nids) in hdmi_choose_cvt()
1037 if (cvt_idx == spec->num_cvts) in hdmi_choose_cvt()
1038 return -EBUSY; in hdmi_choose_cvt()
1041 per_pin->mux_idx = mux_idx; in hdmi_choose_cvt()
1053 hda_nid_t pin_nid = per_pin->pin_nid; in intel_verify_pin_cvt_connect()
1056 mux_idx = per_pin->mux_idx; in intel_verify_pin_cvt_connect()
1073 for (i = 0; i < spec->num_cvts; i++) in intel_cvt_id_to_mux_idx()
1074 if (spec->cvt_nids[i] == cvt_nid) in intel_cvt_id_to_mux_idx()
1076 return -EINVAL; in intel_cvt_id_to_mux_idx()
1080 * For some Intel display codecs, pins share the same connection list.
1082 * pins will generate sound on the external display, because audio flows from
1083 * the same converter to the display pipeline. Also muting one pin may make
1092 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1100 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in intel_not_share_assigned_cvt()
1109 if (!per_pin->pcm) in intel_not_share_assigned_cvt()
1112 if ((per_pin->pin_nid == pin_nid) && in intel_not_share_assigned_cvt()
1113 (per_pin->dev_id == dev_id)) in intel_not_share_assigned_cvt()
1117 * if per_pin->dev_id >= dev_num, in intel_not_share_assigned_cvt()
1122 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1123 if (per_pin->dev_id >= dev_num) in intel_not_share_assigned_cvt()
1126 nid = per_pin->pin_nid; in intel_not_share_assigned_cvt()
1135 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1147 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in intel_not_share_assigned_cvt()
1149 if (!per_cvt->assigned) { in intel_not_share_assigned_cvt()
1168 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1185 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1187 if (spec->ops.pin_cvt_fixup) in pin_cvt_fixup()
1188 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1196 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1197 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_pcm_open_no_pin()
1204 return -EINVAL; in hdmi_pcm_open_no_pin()
1206 err = hdmi_choose_cvt(codec, -1, &cvt_idx, false); in hdmi_pcm_open_no_pin()
1211 per_cvt->assigned = true; in hdmi_pcm_open_no_pin()
1212 hinfo->nid = per_cvt->cvt_nid; in hdmi_pcm_open_no_pin()
1214 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1216 set_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_open_no_pin()
1220 hinfo->channels_min = per_cvt->channels_min; in hdmi_pcm_open_no_pin()
1221 hinfo->channels_max = per_cvt->channels_max; in hdmi_pcm_open_no_pin()
1222 hinfo->rates = per_cvt->rates; in hdmi_pcm_open_no_pin()
1223 hinfo->formats = per_cvt->formats; in hdmi_pcm_open_no_pin()
1224 hinfo->maxbps = per_cvt->maxbps; in hdmi_pcm_open_no_pin()
1227 runtime->hw.channels_min = hinfo->channels_min; in hdmi_pcm_open_no_pin()
1228 runtime->hw.channels_max = hinfo->channels_max; in hdmi_pcm_open_no_pin()
1229 runtime->hw.formats = hinfo->formats; in hdmi_pcm_open_no_pin()
1230 runtime->hw.rates = hinfo->rates; in hdmi_pcm_open_no_pin()
1232 snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_pcm_open_no_pin()
1244 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1245 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_pcm_open()
1255 return -EINVAL; in hdmi_pcm_open()
1257 mutex_lock(&spec->pcm_lock); in hdmi_pcm_open()
1273 per_cvt->assigned = true; in hdmi_pcm_open()
1275 set_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_open()
1277 per_pin->cvt_nid = per_cvt->cvt_nid; in hdmi_pcm_open()
1278 hinfo->nid = per_cvt->cvt_nid; in hdmi_pcm_open()
1281 if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE) in hdmi_pcm_open()
1282 azx_stream(get_azx_dev(substream))->stripe = 1; in hdmi_pcm_open()
1284 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1285 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1287 per_pin->mux_idx); in hdmi_pcm_open()
1292 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1295 hinfo->channels_min = per_cvt->channels_min; in hdmi_pcm_open()
1296 hinfo->channels_max = per_cvt->channels_max; in hdmi_pcm_open()
1297 hinfo->rates = per_cvt->rates; in hdmi_pcm_open()
1298 hinfo->formats = per_cvt->formats; in hdmi_pcm_open()
1299 hinfo->maxbps = per_cvt->maxbps; in hdmi_pcm_open()
1301 eld = &per_pin->sink_eld; in hdmi_pcm_open()
1303 if (!static_hdmi_pcm && eld->eld_valid) { in hdmi_pcm_open()
1304 snd_hdmi_eld_update_pcm_info(&eld->info, hinfo); in hdmi_pcm_open()
1305 if (hinfo->channels_min > hinfo->channels_max || in hdmi_pcm_open()
1306 !hinfo->rates || !hinfo->formats) { in hdmi_pcm_open()
1307 per_cvt->assigned = false; in hdmi_pcm_open()
1308 hinfo->nid = 0; in hdmi_pcm_open()
1310 err = -ENODEV; in hdmi_pcm_open()
1316 runtime->hw.channels_min = hinfo->channels_min; in hdmi_pcm_open()
1317 runtime->hw.channels_max = hinfo->channels_max; in hdmi_pcm_open()
1318 runtime->hw.formats = hinfo->formats; in hdmi_pcm_open()
1319 runtime->hw.rates = hinfo->rates; in hdmi_pcm_open()
1321 snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_pcm_open()
1324 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_open()
1333 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1335 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_read_pin_conn()
1336 int dev_id = per_pin->dev_id; in hdmi_read_pin_conn()
1343 return -EINVAL; in hdmi_read_pin_conn()
1348 if (spec->intel_hsw_fixup) { in hdmi_read_pin_conn()
1349 conns = spec->num_cvts; in hdmi_read_pin_conn()
1350 memcpy(per_pin->mux_nids, spec->cvt_nids, in hdmi_read_pin_conn()
1354 per_pin->mux_nids, in hdmi_read_pin_conn()
1359 per_pin->num_mux_nids = conns; in hdmi_read_pin_conn()
1369 for (i = 0; i < spec->pcm_used; i++) { in hdmi_find_pcm_slot()
1370 if (!test_bit(i, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1373 return -EBUSY; in hdmi_find_pcm_slot()
1382 if (per_pin->pcm) in hdmi_attach_hda_pcm()
1385 idx = per_pin->prev_pcm_idx; in hdmi_attach_hda_pcm()
1387 if (!test_bit(idx, &spec->pcm_bitmap)) in hdmi_attach_hda_pcm()
1389 per_pin->prev_pcm_idx = -1; /* no longer valid, clear it */ in hdmi_attach_hda_pcm()
1392 if (idx == -EBUSY) in hdmi_attach_hda_pcm()
1395 per_pin->pcm_idx = idx; in hdmi_attach_hda_pcm()
1396 per_pin->pcm = get_hdmi_pcm(spec, idx); in hdmi_attach_hda_pcm()
1397 set_bit(idx, &spec->pcm_bitmap); in hdmi_attach_hda_pcm()
1406 if (!per_pin->pcm) in hdmi_detach_hda_pcm()
1408 idx = per_pin->pcm_idx; in hdmi_detach_hda_pcm()
1409 per_pin->pcm_idx = -1; in hdmi_detach_hda_pcm()
1410 per_pin->prev_pcm_idx = idx; /* remember the previous index */ in hdmi_detach_hda_pcm()
1411 per_pin->pcm = NULL; in hdmi_detach_hda_pcm()
1412 if (idx >= 0 && idx < spec->pcm_used) in hdmi_detach_hda_pcm()
1413 clear_bit(idx, &spec->pcm_bitmap); in hdmi_detach_hda_pcm()
1421 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++) in hdmi_get_pin_cvt_mux()
1422 if (per_pin->mux_nids[mux_idx] == cvt_nid) in hdmi_get_pin_cvt_mux()
1432 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin()
1439 if (per_pin->pcm_idx < 0 || per_pin->pcm_idx >= spec->pcm_used) in hdmi_pcm_setup_pin()
1441 pcm = get_pcm_rec(spec, per_pin->pcm_idx); in hdmi_pcm_setup_pin()
1442 if (!pcm->pcm) in hdmi_pcm_setup_pin()
1444 if (!test_bit(per_pin->pcm_idx, &spec->pcm_in_use)) in hdmi_pcm_setup_pin()
1448 hinfo = pcm->stream; in hdmi_pcm_setup_pin()
1449 substream = pcm->pcm->streams[0].substream; in hdmi_pcm_setup_pin()
1451 per_pin->cvt_nid = hinfo->nid; in hdmi_pcm_setup_pin()
1453 mux_idx = hdmi_get_pin_cvt_mux(spec, per_pin, hinfo->nid); in hdmi_pcm_setup_pin()
1454 if (mux_idx < per_pin->num_mux_nids) { in hdmi_pcm_setup_pin()
1455 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1456 per_pin->dev_id); in hdmi_pcm_setup_pin()
1457 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1461 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1463 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1464 if (substream->runtime) in hdmi_pcm_setup_pin()
1465 per_pin->channels = substream->runtime->channels; in hdmi_pcm_setup_pin()
1466 per_pin->setup = true; in hdmi_pcm_setup_pin()
1467 per_pin->mux_idx = mux_idx; in hdmi_pcm_setup_pin()
1475 if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used) in hdmi_pcm_reset_pin()
1476 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1478 per_pin->chmap_set = false; in hdmi_pcm_reset_pin()
1479 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_reset_pin()
1481 per_pin->setup = false; in hdmi_pcm_reset_pin()
1482 per_pin->channels = 0; in hdmi_pcm_reset_pin()
1488 struct hdmi_spec *spec = codec->spec; in pin_idx_to_pcm_jack()
1490 if (per_pin->pcm_idx >= 0) in pin_idx_to_pcm_jack()
1491 return spec->pcm_rec[per_pin->pcm_idx].jack; in pin_idx_to_pcm_jack()
1505 struct hdmi_eld *pin_eld = &per_pin->sink_eld; in update_eld()
1506 struct hdmi_spec *spec = codec->spec; in update_eld()
1508 bool old_eld_valid = pin_eld->eld_valid; in update_eld()
1512 if (eld->eld_valid) { in update_eld()
1513 if (eld->eld_size <= 0 || in update_eld()
1514 snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in update_eld()
1515 eld->eld_size) < 0) { in update_eld()
1516 eld->eld_valid = false; in update_eld()
1518 schedule_delayed_work(&per_pin->work, in update_eld()
1525 if (!eld->eld_valid || eld->eld_size <= 0 || eld->info.sad_count <= 0) { in update_eld()
1526 eld->eld_valid = false; in update_eld()
1527 eld->eld_size = 0; in update_eld()
1531 pcm_idx = per_pin->pcm_idx; in update_eld()
1539 if (!spec->static_pcm_mapping) { in update_eld()
1540 if (eld->eld_valid) { in update_eld()
1549 /* if pcm_idx == -1, it means this is in monitor connection event in update_eld()
1552 if (pcm_idx == -1) in update_eld()
1553 pcm_idx = per_pin->pcm_idx; in update_eld()
1557 if (eld->eld_valid) in update_eld()
1558 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1560 eld_changed = (pin_eld->eld_valid != eld->eld_valid); in update_eld()
1561 eld_changed |= (pin_eld->monitor_present != eld->monitor_present); in update_eld()
1562 if (!eld_changed && eld->eld_valid && pin_eld->eld_valid) in update_eld()
1563 if (pin_eld->eld_size != eld->eld_size || in update_eld()
1564 memcmp(pin_eld->eld_buffer, eld->eld_buffer, in update_eld()
1565 eld->eld_size) != 0) in update_eld()
1569 pin_eld->monitor_present = eld->monitor_present; in update_eld()
1570 pin_eld->eld_valid = eld->eld_valid; in update_eld()
1571 pin_eld->eld_size = eld->eld_size; in update_eld()
1572 if (eld->eld_valid) in update_eld()
1573 memcpy(pin_eld->eld_buffer, eld->eld_buffer, in update_eld()
1574 eld->eld_size); in update_eld()
1575 pin_eld->info = eld->info; in update_eld()
1579 * Re-setup pin and infoframe. This is needed e.g. when in update_eld()
1580 * - sink is first plugged-in in update_eld()
1581 * - transcoder can change during stream playback on Haswell in update_eld()
1584 if (eld->eld_valid && !old_eld_valid && per_pin->setup) { in update_eld()
1586 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1590 snd_ctl_notify(codec->card, in update_eld()
1593 &get_hdmi_pcm(spec, pcm_idx)->eld_ctl->id); in update_eld()
1597 (eld->monitor_present && eld->eld_valid) ? in update_eld()
1601 /* update ELD and jack state via HD-audio verbs */
1605 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs()
1606 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1607 struct hdmi_eld *eld = &spec->temp_eld; in hdmi_present_sense_via_verbs()
1609 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_present_sense_via_verbs()
1610 int dev_id = per_pin->dev_id; in hdmi_present_sense_via_verbs()
1615 * the real PD value changed. An older version of the HD-audio in hdmi_present_sense_via_verbs()
1623 if (dev->power.runtime_status == RPM_SUSPENDING) in hdmi_present_sense_via_verbs()
1633 mutex_lock(&per_pin->lock); in hdmi_present_sense_via_verbs()
1634 eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); in hdmi_present_sense_via_verbs()
1635 if (eld->monitor_present) in hdmi_present_sense_via_verbs()
1636 eld->eld_valid = !!(present & AC_PINSENSE_ELDV); in hdmi_present_sense_via_verbs()
1638 eld->eld_valid = false; in hdmi_present_sense_via_verbs()
1642 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1644 if (eld->eld_valid) { in hdmi_present_sense_via_verbs()
1645 if (spec->ops.pin_get_eld(codec, pin_nid, dev_id, in hdmi_present_sense_via_verbs()
1646 eld->eld_buffer, &eld->eld_size) < 0) in hdmi_present_sense_via_verbs()
1647 eld->eld_valid = false; in hdmi_present_sense_via_verbs()
1651 mutex_unlock(&per_pin->lock); in hdmi_present_sense_via_verbs()
1667 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in silent_stream_enable_i915()
1668 per_pin->dev_id, I915_SILENT_RATE); in silent_stream_enable_i915()
1673 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, in silent_stream_enable_i915()
1676 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format); in silent_stream_enable_i915()
1678 per_pin->channels = I915_SILENT_CHANNELS; in silent_stream_enable_i915()
1679 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable_i915()
1688 codec_dbg(codec, "HDMI: KAE %d cvt-NID=0x%x\n", enable, per_pin->cvt_nid); in silent_stream_set_kae()
1690 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, AC_VERB_GET_DIGI_CONVERT_1, 0); in silent_stream_set_kae()
1698 snd_hda_codec_write(codec, per_pin->cvt_nid, 0, AC_VERB_SET_DIGI_CONVERT_3, param); in silent_stream_set_kae()
1704 struct hdmi_spec *spec = codec->spec; in silent_stream_enable()
1710 * Power-up will call hdmi_present_sense, so the PM calls in silent_stream_enable()
1715 if (err < 0 && err != -EACCES) { in silent_stream_enable()
1722 mutex_lock(&per_pin->lock); in silent_stream_enable()
1724 if (per_pin->setup) { in silent_stream_enable()
1726 err = -EBUSY; in silent_stream_enable()
1730 pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1738 per_cvt->silent_stream = true; in silent_stream_enable()
1739 per_pin->cvt_nid = per_cvt->cvt_nid; in silent_stream_enable()
1740 per_pin->silent_stream = true; in silent_stream_enable()
1742 codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_enable()
1743 per_pin->pin_nid, per_cvt->cvt_nid); in silent_stream_enable()
1745 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1746 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1748 per_pin->mux_idx); in silent_stream_enable()
1753 switch (spec->silent_stream_type) { in silent_stream_enable()
1767 mutex_unlock(&per_pin->lock); in silent_stream_enable()
1776 struct hdmi_spec *spec = codec->spec; in silent_stream_disable()
1781 if (err < 0 && err != -EACCES) { in silent_stream_disable()
1789 mutex_lock(&per_pin->lock); in silent_stream_disable()
1790 if (!per_pin->silent_stream) in silent_stream_disable()
1793 codec_dbg(codec, "HDMI: disable silent stream on pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_disable()
1794 per_pin->pin_nid, per_pin->cvt_nid); in silent_stream_disable()
1796 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in silent_stream_disable()
1797 if (cvt_idx >= 0 && cvt_idx < spec->num_cvts) { in silent_stream_disable()
1799 per_cvt->silent_stream = false; in silent_stream_disable()
1802 if (spec->silent_stream_type == SILENT_STREAM_I915) { in silent_stream_disable()
1805 } else if (spec->silent_stream_type == SILENT_STREAM_KAE) { in silent_stream_disable()
1809 per_pin->cvt_nid = 0; in silent_stream_disable()
1810 per_pin->silent_stream = false; in silent_stream_disable()
1813 mutex_unlock(&per_pin->lock); in silent_stream_disable()
1822 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1823 struct hdmi_eld *eld = &spec->temp_eld; in sync_eld_via_acomp()
1826 mutex_lock(&per_pin->lock); in sync_eld_via_acomp()
1827 eld->monitor_present = false; in sync_eld_via_acomp()
1828 monitor_prev = per_pin->sink_eld.monitor_present; in sync_eld_via_acomp()
1829 eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1830 per_pin->dev_id, &eld->monitor_present, in sync_eld_via_acomp()
1831 eld->eld_buffer, ELD_MAX_SIZE); in sync_eld_via_acomp()
1832 eld->eld_valid = (eld->eld_size > 0); in sync_eld_via_acomp()
1834 monitor_next = per_pin->sink_eld.monitor_present; in sync_eld_via_acomp()
1835 mutex_unlock(&per_pin->lock); in sync_eld_via_acomp()
1837 if (spec->silent_stream_type) { in sync_eld_via_acomp()
1847 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense()
1859 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld()
1860 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1863 jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, in hdmi_repoll_eld()
1864 per_pin->dev_id); in hdmi_repoll_eld()
1866 jack->jack_dirty = 1; in hdmi_repoll_eld()
1868 if (per_pin->repoll_count++ > 6) in hdmi_repoll_eld()
1869 per_pin->repoll_count = 0; in hdmi_repoll_eld()
1871 mutex_lock(&spec->pcm_lock); in hdmi_repoll_eld()
1872 hdmi_present_sense(per_pin, per_pin->repoll_count); in hdmi_repoll_eld()
1873 mutex_unlock(&spec->pcm_lock); in hdmi_repoll_eld()
1878 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1895 !spec->force_connect) in hdmi_add_pin()
1902 if (spec->intel_hsw_fixup) { in hdmi_add_pin()
1909 dev_num = spec->dev_num; in hdmi_add_pin()
1910 } else if (codec->dp_mst) { in hdmi_add_pin()
1913 * spec->dev_num is the maxinum number of device entries in hdmi_add_pin()
1916 spec->dev_num = (spec->dev_num > dev_num) ? in hdmi_add_pin()
1917 spec->dev_num : dev_num; in hdmi_add_pin()
1925 spec->dev_num = 1; in hdmi_add_pin()
1929 pin_idx = spec->num_pins; in hdmi_add_pin()
1930 per_pin = snd_array_new(&spec->pins); in hdmi_add_pin()
1933 return -ENOMEM; in hdmi_add_pin()
1935 per_pin->pcm = NULL; in hdmi_add_pin()
1936 per_pin->pcm_idx = -1; in hdmi_add_pin()
1937 per_pin->prev_pcm_idx = -1; in hdmi_add_pin()
1938 per_pin->pin_nid = pin_nid; in hdmi_add_pin()
1939 per_pin->pin_nid_idx = spec->num_nids; in hdmi_add_pin()
1940 per_pin->dev_id = i; in hdmi_add_pin()
1941 per_pin->non_pcm = false; in hdmi_add_pin()
1947 codec_warn(codec, "HDMI: pin NID 0x%x - jack not detectable\n", pin_nid); in hdmi_add_pin()
1948 spec->num_pins++; in hdmi_add_pin()
1950 spec->num_nids++; in hdmi_add_pin()
1957 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1965 per_cvt = snd_array_new(&spec->cvts); in hdmi_add_cvt()
1967 return -ENOMEM; in hdmi_add_cvt()
1969 per_cvt->cvt_nid = cvt_nid; in hdmi_add_cvt()
1970 per_cvt->channels_min = 2; in hdmi_add_cvt()
1972 per_cvt->channels_max = chans; in hdmi_add_cvt()
1973 if (chans > spec->chmap.channels_max) in hdmi_add_cvt()
1974 spec->chmap.channels_max = chans; in hdmi_add_cvt()
1978 &per_cvt->rates, in hdmi_add_cvt()
1979 &per_cvt->formats, in hdmi_add_cvt()
1980 &per_cvt->maxbps); in hdmi_add_cvt()
1984 if (spec->num_cvts < ARRAY_SIZE(spec->cvt_nids)) in hdmi_add_cvt()
1985 spec->cvt_nids[spec->num_cvts] = cvt_nid; in hdmi_add_cvt()
1986 spec->num_cvts++; in hdmi_add_cvt()
1996 SND_PCI_QUIRK(0x1462, 0xec94, "MS-7C94", 1),
2003 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
2009 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
2012 return -EINVAL; in hdmi_parse_codec()
2016 spec->force_connect = true; in hdmi_parse_codec()
2018 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
2020 if (q && q->value) in hdmi_parse_codec()
2021 spec->force_connect = true; in hdmi_parse_codec()
2062 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2068 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2071 non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO); in check_non_pcm_per_cvt()
2072 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2086 hda_nid_t cvt_nid = hinfo->nid; in generic_hdmi_playback_pcm_prepare()
2087 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
2090 struct snd_pcm_runtime *runtime = substream->runtime; in generic_hdmi_playback_pcm_prepare()
2095 mutex_lock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2122 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2123 per_pin->dev_id, runtime->rate); in generic_hdmi_playback_pcm_prepare()
2126 mutex_lock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2127 per_pin->channels = substream->runtime->channels; in generic_hdmi_playback_pcm_prepare()
2128 per_pin->setup = true; in generic_hdmi_playback_pcm_prepare()
2131 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2139 mutex_unlock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2140 if (spec->dyn_pin_out) { in generic_hdmi_playback_pcm_prepare()
2141 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2142 per_pin->dev_id); in generic_hdmi_playback_pcm_prepare()
2143 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2145 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2151 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2152 per_pin->dev_id, stream_tag, format); in generic_hdmi_playback_pcm_prepare()
2154 mutex_unlock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2162 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2170 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2177 mutex_lock(&spec->pcm_lock); in hdmi_pcm_close()
2178 if (hinfo->nid) { in hdmi_pcm_close()
2181 err = -EINVAL; in hdmi_pcm_close()
2184 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2186 err = -EINVAL; in hdmi_pcm_close()
2190 per_cvt->assigned = false; in hdmi_pcm_close()
2191 hinfo->nid = 0; in hdmi_pcm_close()
2193 azx_stream(get_azx_dev(substream))->stripe = 0; in hdmi_pcm_close()
2196 clear_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_close()
2207 if (spec->dyn_pin_out) { in hdmi_pcm_close()
2208 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2209 per_pin->dev_id); in hdmi_pcm_close()
2210 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2212 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2217 mutex_lock(&per_pin->lock); in hdmi_pcm_close()
2218 per_pin->chmap_set = false; in hdmi_pcm_close()
2219 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_close()
2221 per_pin->setup = false; in hdmi_pcm_close()
2222 per_pin->channels = 0; in hdmi_pcm_close()
2223 mutex_unlock(&per_pin->lock); in hdmi_pcm_close()
2227 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_close()
2242 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2248 return per_pin->sink_eld.info.spk_alloc; in hdmi_get_spk_alloc()
2255 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2262 memcpy(chmap, per_pin->chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_get_chmap()
2269 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2274 mutex_lock(&per_pin->lock); in hdmi_set_chmap()
2275 per_pin->chmap_set = true; in hdmi_set_chmap()
2276 memcpy(per_pin->chmap, chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_set_chmap()
2278 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2279 mutex_unlock(&per_pin->lock); in hdmi_set_chmap()
2285 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2293 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2297 pcm_num = min(spec->num_cvts, spec->num_pins); in generic_hdmi_build_pcms()
2306 return -ENOMEM; in generic_hdmi_build_pcms()
2308 spec->pcm_rec[idx].pcm = info; in generic_hdmi_build_pcms()
2309 spec->pcm_used++; in generic_hdmi_build_pcms()
2310 info->pcm_type = HDA_PCM_TYPE_HDMI; in generic_hdmi_build_pcms()
2311 info->own_chmap = true; in generic_hdmi_build_pcms()
2313 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in generic_hdmi_build_pcms()
2314 pstr->substreams = 1; in generic_hdmi_build_pcms()
2315 pstr->ops = generic_ops; in generic_hdmi_build_pcms()
2317 if (spec->pcm_used >= ARRAY_SIZE(spec->pcm_rec)) in generic_hdmi_build_pcms()
2327 struct hdmi_pcm *pcm = jack->private_data; in free_hdmi_jack_priv()
2329 pcm->jack = NULL; in free_hdmi_jack_priv()
2335 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2337 int pcmdev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_jack()
2343 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2348 spec->pcm_rec[pcm_idx].jack = jack; in generic_hdmi_build_jack()
2349 jack->private_data = &spec->pcm_rec[pcm_idx]; in generic_hdmi_build_jack()
2350 jack->private_free = free_hdmi_jack_priv; in generic_hdmi_build_jack()
2356 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2360 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2361 if (!get_pcm_rec(spec, pcm_idx)->pcm) { in generic_hdmi_build_controls()
2363 set_bit(pcm_idx, &spec->pcm_bitmap); in generic_hdmi_build_controls()
2375 0, spec->cvt_nids[0], in generic_hdmi_build_controls()
2381 dev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_controls()
2390 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_build_controls()
2392 struct hdmi_eld *pin_eld = &per_pin->sink_eld; in generic_hdmi_build_controls()
2394 if (spec->static_pcm_mapping) { in generic_hdmi_build_controls()
2399 pin_eld->eld_valid = false; in generic_hdmi_build_controls()
2404 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2408 if (!pcm || !pcm->pcm) in generic_hdmi_build_controls()
2410 err = snd_hdac_add_chmap_ctls(pcm->pcm, pcm_idx, &spec->chmap); in generic_hdmi_build_controls()
2420 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2423 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init_per_pins()
2426 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2427 mutex_init(&per_pin->lock); in generic_hdmi_init_per_pins()
2428 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); in generic_hdmi_init_per_pins()
2436 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2439 mutex_lock(&spec->bind_lock); in generic_hdmi_init()
2440 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init()
2442 hda_nid_t pin_nid = per_pin->pin_nid; in generic_hdmi_init()
2443 int dev_id = per_pin->dev_id; in generic_hdmi_init()
2452 mutex_unlock(&spec->bind_lock); in generic_hdmi_init()
2458 snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums); in hdmi_array_init()
2459 snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums); in hdmi_array_init()
2464 snd_array_free(&spec->pins); in hdmi_array_free()
2465 snd_array_free(&spec->cvts); in hdmi_array_free()
2470 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2475 codec->spec = NULL; in generic_spec_free()
2477 codec->dp_mst = false; in generic_spec_free()
2482 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2485 if (spec->acomp_registered) { in generic_hdmi_free()
2486 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2488 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2490 codec->relaxed_resume = 0; in generic_hdmi_free()
2492 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_free()
2494 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_free()
2498 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_free()
2499 if (spec->pcm_rec[pcm_idx].jack == NULL) in generic_hdmi_free()
2501 snd_device_free(codec->card, spec->pcm_rec[pcm_idx].jack); in generic_hdmi_free()
2510 struct hdmi_spec *spec = codec->spec; in generic_hdmi_suspend()
2513 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_suspend()
2515 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_suspend()
2522 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2525 codec->patch_ops.init(codec); in generic_hdmi_resume()
2528 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_resume()
2555 /* allocate codec->spec and assign/initialize generic parser ops */
2562 return -ENOMEM; in alloc_generic_hdmi()
2564 spec->codec = codec; in alloc_generic_hdmi()
2565 spec->ops = generic_standard_hdmi_ops; in alloc_generic_hdmi()
2566 spec->dev_num = 1; /* initialize to 1 */ in alloc_generic_hdmi()
2567 mutex_init(&spec->pcm_lock); in alloc_generic_hdmi()
2568 mutex_init(&spec->bind_lock); in alloc_generic_hdmi()
2569 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2571 spec->chmap.ops.get_chmap = hdmi_get_chmap; in alloc_generic_hdmi()
2572 spec->chmap.ops.set_chmap = hdmi_set_chmap; in alloc_generic_hdmi()
2573 spec->chmap.ops.is_pcm_attached = is_hdmi_pcm_attached; in alloc_generic_hdmi()
2574 spec->chmap.ops.get_spk_alloc = hdmi_get_spk_alloc; in alloc_generic_hdmi()
2576 codec->spec = spec; in alloc_generic_hdmi()
2579 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2615 /* clear unsol even if component notifier is used, or re-enable in reprogram_jack_detect()
2618 unsigned int val = use_acomp ? 0 : (AC_USRSP_EN | tbl->tag); in reprogram_jack_detect()
2631 spec = container_of(acomp->audio_ops, struct hdmi_spec, drm_audio_ops); in generic_acomp_notifier_set()
2632 mutex_lock(&spec->bind_lock); in generic_acomp_notifier_set()
2633 spec->use_acomp_notifier = use_acomp; in generic_acomp_notifier_set()
2634 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2635 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2637 for (i = 0; i < spec->num_pins; i++) in generic_acomp_notifier_set()
2638 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2639 get_pin(spec, i)->pin_nid, in generic_acomp_notifier_set()
2640 get_pin(spec, i)->dev_id, in generic_acomp_notifier_set()
2642 mutex_unlock(&spec->bind_lock); in generic_acomp_notifier_set()
2659 /* check whether both HD-audio and DRM PCI devices belong to the same bus */
2665 if (!dev_is_pci(dev) || !dev_is_pci(bus->dev)) in match_bound_vga()
2667 master = to_pci_dev(bus->dev); in match_bound_vga()
2669 return master->bus == pci->bus; in match_bound_vga()
2676 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2677 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2686 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in generic_acomp_pin_eld_notify()
2696 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2698 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2704 spec->drm_audio_ops.pin2port = ops->pin2port; in setup_drm_audio_ops()
2705 spec->drm_audio_ops.pin_eld_notify = ops->pin_eld_notify; in setup_drm_audio_ops()
2706 spec->drm_audio_ops.master_bind = ops->master_bind; in setup_drm_audio_ops()
2707 spec->drm_audio_ops.master_unbind = ops->master_unbind; in setup_drm_audio_ops()
2715 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2722 spec->port2pin = port2pin; in generic_acomp_init()
2724 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2726 spec->acomp_registered = true; in generic_acomp_init()
2743 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2745 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2747 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) in intel_haswell_enable_all_pins()
2751 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2753 if (vendor_param == -1) in intel_haswell_enable_all_pins()
2763 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2765 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2767 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) in intel_haswell_fixup_enable_dp12()
2772 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2773 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2777 /* Haswell needs to re-issue the vendor-specific verbs before turning to D0.
2792 /* There is a fixed mapping between audio pin node and display port.
2794 * Pin Widget 5 - PORT B (port = 1 in i915 driver)
2795 * Pin Widget 6 - PORT C (port = 2 in i915 driver)
2796 * Pin Widget 7 - PORT D (port = 3 in i915 driver)
2799 * Pin Widget 4 - PORT B (port = 1 in i915 driver)
2800 * Pin Widget 5 - PORT C (port = 2 in i915 driver)
2801 * Pin Widget 6 - PORT D (port = 3 in i915 driver)
2805 switch (codec->core.vendor_id) { in intel_base_nid()
2818 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2821 if (!spec->port_num) { in intel_pin2port()
2824 return -1; in intel_pin2port()
2825 return pin_nid - base_nid + 1; in intel_pin2port()
2832 for (i = 0; i < spec->port_num; i++) { in intel_pin2port()
2833 if (pin_nid == spec->port_map[i]) in intel_pin2port()
2838 return -1; in intel_pin2port()
2843 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2845 if (!spec->port_num) { in intel_port2pin()
2846 /* we assume only from port-B to port-D */ in intel_port2pin()
2849 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2852 if (port < 0 || port >= spec->port_num) in intel_port2pin()
2854 return spec->port_map[port]; in intel_port2pin()
2869 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
2872 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2884 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2886 spec->use_acomp_notifier = true; in register_i915_notifier()
2887 spec->port2pin = intel_port2pin; in register_i915_notifier()
2889 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2890 &spec->drm_audio_ops); in register_i915_notifier()
2892 codec->relaxed_resume = 1; in register_i915_notifier()
2900 struct hdmi_spec *spec = codec->spec; in i915_hsw_setup_stream()
2912 if (spec->silent_stream_type == SILENT_STREAM_KAE && per_pin && per_pin->silent_stream) { in i915_hsw_setup_stream()
2921 if (spec->silent_stream_type == SILENT_STREAM_KAE && per_pin && per_pin->silent_stream) { in i915_hsw_setup_stream()
2935 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2936 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2937 per_pin->dev_id); in i915_pin_cvt_fixup()
2939 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2940 per_pin->dev_id, per_pin->mux_idx); in i915_pin_cvt_fixup()
2949 struct hdmi_spec *spec = codec->spec; in i915_adlp_hdmi_suspend()
2955 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in i915_adlp_hdmi_suspend()
2958 if (per_pin->silent_stream) { in i915_adlp_hdmi_suspend()
2964 if (silent_streams && spec->silent_stream_type == SILENT_STREAM_KAE) { in i915_adlp_hdmi_suspend()
2966 * stream-id should remain programmed when codec goes in i915_adlp_hdmi_suspend()
2969 codec->no_stream_clean_at_suspend = 1; in i915_adlp_hdmi_suspend()
2972 * the system might go to S3, in which case keep-alive in i915_adlp_hdmi_suspend()
2975 codec->forced_resume = 1; in i915_adlp_hdmi_suspend()
2979 codec->no_stream_clean_at_suspend = 0; in i915_adlp_hdmi_suspend()
2980 codec->forced_resume = 0; in i915_adlp_hdmi_suspend()
2988 struct hdmi_spec *spec = codec->spec; in i915_adlp_hdmi_resume()
2994 if (!codec->no_stream_clean_at_suspend) in i915_adlp_hdmi_resume()
2997 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in i915_adlp_hdmi_resume()
3002 * the codec setting may have been lost. Re-enable in i915_adlp_hdmi_resume()
3003 * keep-alive. in i915_adlp_hdmi_resume()
3005 if (per_pin->silent_stream) { in i915_adlp_hdmi_resume()
3008 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, in i915_adlp_hdmi_resume()
3015 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, in i915_adlp_hdmi_resume()
3034 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
3037 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
3038 return -ENODEV; in alloc_intel_hdmi()
3045 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
3049 /* parse and post-process for Intel codecs */
3056 } while (err < 0 && retries--); in parse_intel_hdmi()
3079 spec = codec->spec; in intel_hsw_common_init()
3080 codec->dp_mst = true; in intel_hsw_common_init()
3081 spec->vendor_nid = vendor_nid; in intel_hsw_common_init()
3082 spec->port_map = port_map; in intel_hsw_common_init()
3083 spec->port_num = port_num; in intel_hsw_common_init()
3084 spec->intel_hsw_fixup = true; in intel_hsw_common_init()
3085 spec->dev_num = dev_num; in intel_hsw_common_init()
3090 codec->display_power_control = 1; in intel_hsw_common_init()
3092 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
3093 codec->depop_delay = 0; in intel_hsw_common_init()
3094 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
3096 spec->ops.setup_stream = i915_hsw_setup_stream; in intel_hsw_common_init()
3097 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in intel_hsw_common_init()
3104 spec->silent_stream_type = SILENT_STREAM_I915; in intel_hsw_common_init()
3156 spec = codec->spec; in patch_i915_adlp_hdmi()
3158 if (spec->silent_stream_type) { in patch_i915_adlp_hdmi()
3159 spec->silent_stream_type = SILENT_STREAM_KAE; in patch_i915_adlp_hdmi()
3162 codec->patch_ops.resume = i915_adlp_hdmi_resume; in patch_i915_adlp_hdmi()
3163 codec->patch_ops.suspend = i915_adlp_hdmi_suspend; in patch_i915_adlp_hdmi()
3180 spec = codec->spec; in patch_i915_byt_hdmi()
3182 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
3185 codec->display_power_control = 1; in patch_i915_byt_hdmi()
3187 codec->depop_delay = 0; in patch_i915_byt_hdmi()
3188 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
3190 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in patch_i915_byt_hdmi()
3207 * Shared non-generic implementations
3212 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
3219 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
3224 return -ENOMEM; in simple_playback_build_pcms()
3225 spec->pcm_rec[0].pcm = info; in simple_playback_build_pcms()
3226 info->pcm_type = HDA_PCM_TYPE_HDMI; in simple_playback_build_pcms()
3227 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in simple_playback_build_pcms()
3228 *pstr = spec->pcm_playback; in simple_playback_build_pcms()
3229 pstr->nid = per_cvt->cvt_nid; in simple_playback_build_pcms()
3230 if (pstr->channels_max <= 2 && chans && chans <= 16) in simple_playback_build_pcms()
3231 pstr->channels_max = chans; in simple_playback_build_pcms()
3245 * as long as spec->pins[] is set correctly
3251 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3256 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3257 per_cvt->cvt_nid, in simple_playback_build_controls()
3266 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3268 hda_nid_t pin = per_pin->pin_nid; in simple_playback_init()
3276 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3282 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3377 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3380 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3395 snd_pcm_hw_constraint_list(substream->runtime, 0, in simple_playback_pcm_open()
3399 snd_pcm_hw_constraint_step(substream->runtime, 0, in simple_playback_pcm_open()
3403 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3410 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3411 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3420 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3421 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3453 return -ENOMEM; in patch_simple_hdmi()
3455 spec->codec = codec; in patch_simple_hdmi()
3456 codec->spec = spec; in patch_simple_hdmi()
3459 spec->multiout.num_dacs = 0; /* no analog */ in patch_simple_hdmi()
3460 spec->multiout.max_channels = 2; in patch_simple_hdmi()
3461 spec->multiout.dig_out_nid = cvt_nid; in patch_simple_hdmi()
3462 spec->num_cvts = 1; in patch_simple_hdmi()
3463 spec->num_pins = 1; in patch_simple_hdmi()
3464 per_pin = snd_array_new(&spec->pins); in patch_simple_hdmi()
3465 per_cvt = snd_array_new(&spec->cvts); in patch_simple_hdmi()
3468 return -ENOMEM; in patch_simple_hdmi()
3470 per_cvt->cvt_nid = cvt_nid; in patch_simple_hdmi()
3471 per_pin->pin_nid = pin_nid; in patch_simple_hdmi()
3472 spec->pcm_playback = simple_pcm_playback; in patch_simple_hdmi()
3474 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3483 int chan = channels ? (channels - 1) : 1; in nvhdmi_8ch_7x_set_info_frame_parameters()
3509 (0x71 - chan - chanmask)); in nvhdmi_8ch_7x_set_info_frame_parameters()
3516 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3534 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3546 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3550 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3552 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3554 chs = substream->runtime->channels; in nvhdmi_8ch_7x_pcm_prepare()
3559 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3564 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3576 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3581 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3597 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3598 (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3603 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3618 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3619 (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3624 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3634 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3661 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3663 spec = codec->spec; in patch_nvhdmi_2ch()
3664 spec->pcm_playback.rates = SUPPORTED_RATES; in patch_nvhdmi_2ch()
3665 spec->pcm_playback.maxbps = SUPPORTED_MAXBPS; in patch_nvhdmi_2ch()
3666 spec->pcm_playback.formats = SUPPORTED_FORMATS; in patch_nvhdmi_2ch()
3667 spec->nv_dp_workaround = true; in patch_nvhdmi_2ch()
3673 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3677 info->own_chmap = true; in nvhdmi_7x_8ch_build_pcms()
3684 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3695 err = snd_pcm_add_chmap_ctls(info->pcm, in nvhdmi_7x_8ch_build_controls()
3700 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3705 chmap->channel_mask = (1U << 2) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3708 chmap->channel_mask = (1U << 2) | (1U << 6) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3719 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3720 spec->multiout.max_channels = 8; in patch_nvhdmi_8ch_7x()
3721 spec->pcm_playback = nvhdmi_pcm_playback_8ch_7x; in patch_nvhdmi_8ch_7x()
3722 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3723 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3724 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3734 * NVIDIA codecs ignore ASP mapping for 2ch - confirmed on:
3735 * - 0x10de0015
3736 * - 0x10de0040
3741 if (cap->ca_index == 0x00 && channels == 2) in nvhdmi_chmap_cea_alloc_validate_get_type()
3745 if (cap->channels != channels) in nvhdmi_chmap_cea_alloc_validate_get_type()
3746 return -1; in nvhdmi_chmap_cea_alloc_validate_get_type()
3756 return -EINVAL; in nvhdmi_chmap_validate()
3761 /* map from pin NID to port; port is 0-based */
3765 return pin_nid - 4; in nvhdmi_pin2port()
3768 /* reverse-map from port to pin NID: see above */
3789 codec->dp_mst = true; in patch_nvhdmi()
3791 spec = codec->spec; in patch_nvhdmi()
3801 spec->dyn_pin_out = true; in patch_nvhdmi()
3803 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi()
3805 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi()
3806 spec->nv_dp_workaround = true; in patch_nvhdmi()
3808 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3824 spec = codec->spec; in patch_nvhdmi_legacy()
3825 spec->dyn_pin_out = true; in patch_nvhdmi_legacy()
3827 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi_legacy()
3829 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi_legacy()
3830 spec->nv_dp_workaround = true; in patch_nvhdmi_legacy()
3832 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3839 * accessed using vendor-defined verbs. These registers can be used for
3854 * +---------+-------+--------+--------+
3856 * +-----------------------------------|
3888 struct hdmi_spec *spec = codec->spec; in tegra_hdmi_set_format()
3896 if (codec->dp_mst) in tegra_hdmi_set_format()
3925 if (spec->hdmi_intr_trig_ctrl) { in tegra_hdmi_set_format()
3929 * non-zero values to verb 0xF80 instead of 31st bit of in tegra_hdmi_set_format()
3963 tegra_hdmi_set_format(codec, hinfo->nid, format); in tegra_hdmi_pcm_prepare()
3973 tegra_hdmi_set_format(codec, hinfo->nid, 0); in tegra_hdmi_pcm_cleanup()
3980 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3983 for (i = 0; i < spec->num_pins; i++) { in hda_find_pcm_by_type()
3986 if (pcm->pcm_type == type) in hda_find_pcm_by_type()
4005 return -ENODEV; in tegra_hdmi_build_pcms()
4008 * Override ->prepare() and ->cleanup() operations to notify the HDMI in tegra_hdmi_build_pcms()
4011 stream = &pcm->stream[SNDRV_PCM_STREAM_PLAYBACK]; in tegra_hdmi_build_pcms()
4012 stream->ops.prepare = tegra_hdmi_pcm_prepare; in tegra_hdmi_build_pcms()
4013 stream->ops.cleanup = tegra_hdmi_pcm_cleanup; in tegra_hdmi_build_pcms()
4020 struct hdmi_spec *spec = codec->spec; in tegra_hdmi_init()
4029 for (i = 0; i < spec->num_cvts; i++) in tegra_hdmi_init()
4030 snd_hda_codec_write(codec, spec->cvt_nids[i], 0, in tegra_hdmi_init()
4036 codec->depop_delay = 10; in tegra_hdmi_init()
4037 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in tegra_hdmi_init()
4038 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in tegra_hdmi_init()
4040 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in tegra_hdmi_init()
4042 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in tegra_hdmi_init()
4044 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in tegra_hdmi_init()
4045 spec->nv_dp_workaround = true; in tegra_hdmi_init()
4070 codec->dp_mst = true; in patch_tegra234_hdmi()
4071 spec = codec->spec; in patch_tegra234_hdmi()
4072 spec->dyn_pin_out = true; in patch_tegra234_hdmi()
4073 spec->hdmi_intr_trig_ctrl = true; in patch_tegra234_hdmi()
4079 * ATI/AMD-specific implementations
4083 ((codec)->core.vendor_id == 0x1002aa01 && \
4084 ((codec)->core.revision_id & 0xff00) >= 0x0300)
4129 /* call hda_eld.c ATI/AMD-specific function */ in atihdmi_pin_get_eld()
4145 * ATI/AMD have automatic FC/LFE swap built-in in atihdmi_paired_swap_fc_lfe()
4165 /* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */ in atihdmi_paired_chmap_validate()
4177 int chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j); in atihdmi_paired_chmap_validate()
4178 if (cap->speakers[chan_idx] == mask) { in atihdmi_paired_chmap_validate()
4184 int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1); in atihdmi_paired_chmap_validate()
4186 int comp_mask_act = cap->speakers[comp_chan_idx]; in atihdmi_paired_chmap_validate()
4191 return -EINVAL; in atihdmi_paired_chmap_validate()
4198 return -EINVAL; in atihdmi_paired_chmap_validate()
4215 return -EINVAL; in atihdmi_pin_set_slot_channel()
4227 hdmi_slot -= hdmi_slot % 2; in atihdmi_pin_set_slot_channel()
4230 stream_channel -= stream_channel % 2; in atihdmi_pin_set_slot_channel()
4253 return -EINVAL; in atihdmi_pin_get_slot_channel()
4258 ati_asp_slot -= 1; in atihdmi_pin_get_slot_channel()
4281 * Pre-rev3 ATI/AMD codecs operate in a paired channel mode, so in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4288 /* We only produce even-numbered channel count TLVs */ in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4290 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4293 if (cap->speakers[c] || cap->speakers[c+1]) in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4298 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4307 /* produce paired maps for pre-rev3 ATI/AMD codecs */ in atihdmi_paired_cea_alloc_to_tlv_chmap()
4311 for (c = 7; c >= 0; c--) { in atihdmi_paired_cea_alloc_to_tlv_chmap()
4312 int chan = 7 - atihdmi_paired_swap_fc_lfe(7 - c); in atihdmi_paired_cea_alloc_to_tlv_chmap()
4313 int spk = cap->speakers[chan]; in atihdmi_paired_cea_alloc_to_tlv_chmap()
4316 if (cap->speakers[chan + (chan % 2 ? -1 : 1)]) in atihdmi_paired_cea_alloc_to_tlv_chmap()
4343 "atihdmi_pin_hbr_setup: NID=0x%x, %shbr-ctl=0x%x\n", in atihdmi_pin_hbr_setup()
4345 hbr_ctl == hbr_ctl_new ? "" : "new-", in atihdmi_pin_hbr_setup()
4354 return -EINVAL; in atihdmi_pin_hbr_setup()
4365 /* disable ramp-up/down for non-pcm as per AMD spec */ in atihdmi_setup_stream()
4379 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4387 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in atihdmi_init()
4391 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4393 /* enable channel-wise remap mode if supported */ in atihdmi_init()
4395 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4399 codec->auto_runtime_pm = 1; in atihdmi_init()
4404 /* map from pin NID to port; port is 0-based */
4408 return pin_nid / 2 - 1; in atihdmi_pin2port()
4411 /* reverse-map from port to pin NID: see above */
4435 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4437 spec = codec->spec; in patch_atihdmi()
4439 spec->static_pcm_mapping = true; in patch_atihdmi()
4441 spec->ops.pin_get_eld = atihdmi_pin_get_eld; in patch_atihdmi()
4442 spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe; in patch_atihdmi()
4443 spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup; in patch_atihdmi()
4444 spec->ops.setup_stream = atihdmi_setup_stream; in patch_atihdmi()
4446 spec->chmap.ops.pin_get_slot_channel = atihdmi_pin_get_slot_channel; in patch_atihdmi()
4447 spec->chmap.ops.pin_set_slot_channel = atihdmi_pin_set_slot_channel; in patch_atihdmi()
4450 /* override to ATI/AMD-specific versions with pairwise mapping */ in patch_atihdmi()
4451 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_atihdmi()
4453 spec->chmap.ops.cea_alloc_to_tlv_chmap = in patch_atihdmi()
4455 spec->chmap.ops.chmap_validate = atihdmi_paired_chmap_validate; in patch_atihdmi()
4459 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in patch_atihdmi()
4461 per_cvt->channels_max = max(per_cvt->channels_max, 8u); in patch_atihdmi()
4462 per_cvt->rates |= SUPPORTED_RATES; in patch_atihdmi()
4463 per_cvt->formats |= SUPPORTED_FORMATS; in patch_atihdmi()
4464 per_cvt->maxbps = max(per_cvt->maxbps, 24u); in patch_atihdmi()
4467 spec->chmap.channels_max = max(spec->chmap.channels_max, 8u); in patch_atihdmi()
4470 * the link-down as is. Tell the core to allow it. in patch_atihdmi()
4472 codec->link_down_at_suspend = 1; in patch_atihdmi()
4498 * another, need to do actual clean-ups in codec_cleanup_stream in patch_gf_hdmi()
4500 codec->no_sticky_stream = 1; in patch_gf_hdmi()
4546 HDA_CODEC_ENTRY(0x10de002d, "Tegra186 HDMI/DP0", patch_tegra_hdmi),
4547 HDA_CODEC_ENTRY(0x10de002e, "Tegra186 HDMI/DP1", patch_tegra_hdmi),
4634 HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_adlp_hdmi),
4649 MODULE_DESCRIPTION("HDMI HD-audio codec");
4650 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4651 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4652 MODULE_ALIAS("snd-hda-codec-atihdmi");