Lines Matching +full:codec +full:- +full:1
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.
73 struct hda_codec *codec; member
77 struct hdmi_pcm *pcm; /* pointer to spec->pcm_rec[n] dynamically*/
78 int pcm_idx; /* which pcm is attached. -1 means no pcm is attached */
84 bool chmap_set; /* channel-map override by ALSA API? */
85 unsigned char chmap[8]; /* ALSA API channel-map */
93 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
96 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
101 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid,
104 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
108 void (*pin_cvt_fixup)(struct hda_codec *codec,
120 struct hda_codec *codec; member
151 * bit 1 means the second playback PCM, and so on.
163 bool intel_hsw_fixup; /* apply Intel platform-specific fixups */
165 * Non-generic VIA/NVIDIA specific
184 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
186 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
187 return spec->use_acomp_notifier; in codec_has_acomp()
190 #define codec_has_acomp(codec) false argument
230 ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx))
232 ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx))
234 #define get_hdmi_pcm(spec, idx) (&(spec)->pcm_rec[idx])
236 #define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm)
238 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
241 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
246 * (dev_id == -1) means it is NON-MST pin in pin_id_to_pin_index()
249 if (dev_id == -1) in pin_id_to_pin_index()
252 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in pin_id_to_pin_index()
254 if ((per_pin->pin_nid == pin_nid) && in pin_id_to_pin_index()
255 (per_pin->dev_id == dev_id)) in pin_id_to_pin_index()
259 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid); in pin_id_to_pin_index()
260 return -EINVAL; in pin_id_to_pin_index()
263 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
266 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
269 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) in hinfo_to_pcm_index()
270 if (get_pcm_rec(spec, pcm_idx)->stream == hinfo) in hinfo_to_pcm_index()
273 codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo); in hinfo_to_pcm_index()
274 return -EINVAL; in hinfo_to_pcm_index()
277 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
280 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
284 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in hinfo_to_pin_index()
286 if (per_pin->pcm && in hinfo_to_pin_index()
287 per_pin->pcm->pcm->stream == hinfo) in hinfo_to_pin_index()
291 codec_dbg(codec, "HDMI: hinfo %p (pcm %d) not registered\n", hinfo, in hinfo_to_pin_index()
292 hinfo_to_pcm_index(codec, hinfo)); in hinfo_to_pin_index()
293 return -EINVAL; in hinfo_to_pin_index()
302 for (i = 0; i < spec->num_pins; i++) { in pcm_idx_to_pin()
304 if (per_pin->pcm_idx == pcm_idx) in pcm_idx_to_pin()
310 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
312 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
315 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) in cvt_nid_to_cvt_index()
316 if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid) in cvt_nid_to_cvt_index()
319 codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
320 return -EINVAL; in cvt_nid_to_cvt_index()
326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
327 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
332 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdmi_eld_ctl_info()
334 pcm_idx = kcontrol->private_value; in hdmi_eld_ctl_info()
335 mutex_lock(&spec->pcm_lock); in hdmi_eld_ctl_info()
339 uinfo->count = 0; in hdmi_eld_ctl_info()
342 eld = &per_pin->sink_eld; in hdmi_eld_ctl_info()
343 uinfo->count = eld->eld_valid ? eld->eld_size : 0; in hdmi_eld_ctl_info()
346 mutex_unlock(&spec->pcm_lock); in hdmi_eld_ctl_info()
353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
354 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
360 pcm_idx = kcontrol->private_value; in hdmi_eld_ctl_get()
361 mutex_lock(&spec->pcm_lock); in hdmi_eld_ctl_get()
365 memset(ucontrol->value.bytes.data, 0, in hdmi_eld_ctl_get()
366 ARRAY_SIZE(ucontrol->value.bytes.data)); in hdmi_eld_ctl_get()
370 eld = &per_pin->sink_eld; in hdmi_eld_ctl_get()
371 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) || in hdmi_eld_ctl_get()
372 eld->eld_size > ELD_MAX_SIZE) { in hdmi_eld_ctl_get()
374 err = -EINVAL; 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()
380 if (eld->eld_valid) in hdmi_eld_ctl_get()
381 memcpy(ucontrol->value.bytes.data, eld->eld_buffer, in hdmi_eld_ctl_get()
382 eld->eld_size); in hdmi_eld_ctl_get()
385 mutex_unlock(&spec->pcm_lock); in hdmi_eld_ctl_get()
398 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
402 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
405 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
407 return -ENOMEM; in hdmi_create_eld_ctl()
408 kctl->private_value = pcm_idx; in hdmi_create_eld_ctl()
409 kctl->id.device = device; in hdmi_create_eld_ctl()
414 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
418 get_hdmi_pcm(spec, pcm_idx)->eld_ctl = kctl; in hdmi_create_eld_ctl()
423 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
428 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
436 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
443 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
446 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
449 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
452 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
454 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
458 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
459 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
462 if (spec->dyn_pin_out) in hdmi_init_pin()
471 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
483 struct hdmi_spec_per_pin *per_pin = entry->private_data; in print_eld_info()
485 mutex_lock(&per_pin->lock); in print_eld_info()
486 snd_hdmi_print_eld_info(&per_pin->sink_eld, buffer); in print_eld_info()
487 mutex_unlock(&per_pin->lock); in print_eld_info()
493 struct hdmi_spec_per_pin *per_pin = entry->private_data; in write_eld_info()
495 mutex_lock(&per_pin->lock); in write_eld_info()
496 snd_hdmi_write_eld_info(&per_pin->sink_eld, buffer); in write_eld_info()
497 mutex_unlock(&per_pin->lock); in write_eld_info()
503 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
507 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
508 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
513 entry->c.text.write = write_eld_info; in eld_proc_new()
514 entry->mode |= 0200; in eld_proc_new()
515 per_pin->proc_entry = entry; in eld_proc_new()
522 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
523 snd_info_free_entry(per_pin->proc_entry); in eld_proc_free()
524 per_pin->proc_entry = NULL; in eld_proc_free()
545 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
548 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
549 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
556 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
559 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
560 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
564 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
570 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
571 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
574 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
576 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
581 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
588 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
593 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
594 for (j = 1; j < 1000; j++) { in hdmi_clear_dip_buffers()
595 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
596 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
598 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
603 codec_dbg(codec, in hdmi_clear_dip_buffers()
616 hdmi_ai->checksum = 0; in hdmi_checksum_audio_infoframe()
621 hdmi_ai->checksum = -sum; in hdmi_checksum_audio_infoframe()
624 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
630 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
631 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
633 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
635 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
638 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
644 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
648 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
650 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
659 static int hdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in hdmi_pin_get_eld() argument
662 snd_hda_set_dev_select(codec, nid, dev_id); in hdmi_pin_get_eld()
664 return snd_hdmi_get_eld(codec, nid, buf, eld_size); in hdmi_pin_get_eld()
667 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
672 struct hdmi_spec *spec = codec->spec; in hdmi_pin_setup_infoframe()
678 (conn_type == 1 && spec->nv_dp_workaround)) { in hdmi_pin_setup_infoframe()
682 hdmi_ai->type = 0x84; in hdmi_pin_setup_infoframe()
683 hdmi_ai->ver = 0x01; in hdmi_pin_setup_infoframe()
684 hdmi_ai->len = 0x0a; in hdmi_pin_setup_infoframe()
686 hdmi_ai->type = 0x84; in hdmi_pin_setup_infoframe()
687 hdmi_ai->ver = 0x1b; in hdmi_pin_setup_infoframe()
688 hdmi_ai->len = 0x11 << 2; in hdmi_pin_setup_infoframe()
690 hdmi_ai->CC02_CT47 = active_channels - 1; in hdmi_pin_setup_infoframe()
691 hdmi_ai->CA = ca; in hdmi_pin_setup_infoframe()
693 } else if (conn_type == 1) { /* DisplayPort */ in hdmi_pin_setup_infoframe()
696 dp_ai->type = 0x84; in hdmi_pin_setup_infoframe()
697 dp_ai->len = 0x1b; in hdmi_pin_setup_infoframe()
698 dp_ai->ver = 0x11 << 2; in hdmi_pin_setup_infoframe()
699 dp_ai->CC02_CT47 = active_channels - 1; in hdmi_pin_setup_infoframe()
700 dp_ai->CA = ca; in hdmi_pin_setup_infoframe()
702 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n", in hdmi_pin_setup_infoframe()
707 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_setup_infoframe()
714 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
716 codec_dbg(codec, in hdmi_pin_setup_infoframe()
720 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
721 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
723 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
727 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
731 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
732 struct hdac_chmap *chmap = &spec->chmap; in hdmi_setup_audio_infoframe()
733 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_setup_audio_infoframe()
734 int dev_id = per_pin->dev_id; in hdmi_setup_audio_infoframe()
735 int channels = per_pin->channels; in hdmi_setup_audio_infoframe()
743 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_setup_audio_infoframe()
746 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
747 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
751 eld = &per_pin->sink_eld; in hdmi_setup_audio_infoframe()
753 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
754 eld->info.spk_alloc, channels, in hdmi_setup_audio_infoframe()
755 per_pin->chmap_set, non_pcm, per_pin->chmap); in hdmi_setup_audio_infoframe()
759 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
766 snd_hdac_setup_channel_mapping(&spec->chmap, in hdmi_setup_audio_infoframe()
768 per_pin->chmap, per_pin->chmap_set); in hdmi_setup_audio_infoframe()
770 spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id, in hdmi_setup_audio_infoframe()
771 ca, active_channels, eld->info.conn_type); in hdmi_setup_audio_infoframe()
773 per_pin->non_pcm = non_pcm; in hdmi_setup_audio_infoframe()
782 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
785 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
786 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
790 mutex_lock(&spec->pcm_lock); in check_presence_and_report()
791 hdmi_present_sense(get_pin(spec, pin_idx), 1); in check_presence_and_report()
792 mutex_unlock(&spec->pcm_lock); in check_presence_and_report()
795 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
799 if (codec_has_acomp(codec)) in jack_callback()
802 check_presence_and_report(codec, jack->nid, jack->dev_id); in jack_callback()
805 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res, in hdmi_intrinsic_event() argument
808 jack->jack_dirty = 1; in hdmi_intrinsic_event()
810 codec_dbg(codec, in hdmi_intrinsic_event()
811 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_intrinsic_event()
812 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
815 check_presence_and_report(codec, jack->nid, jack->dev_id); in hdmi_intrinsic_event()
818 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
825 codec_info(codec, in hdmi_non_intrinsic_event()
826 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", in hdmi_non_intrinsic_event()
827 codec->addr, in hdmi_non_intrinsic_event()
843 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
849 if (codec_has_acomp(codec)) in hdmi_unsol_event()
852 if (codec->dp_mst) { in hdmi_unsol_event()
856 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in hdmi_unsol_event()
858 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in hdmi_unsol_event()
862 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
867 hdmi_intrinsic_event(codec, res, jack); in hdmi_unsol_event()
869 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
872 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
877 /* For Haswell, the converter 1/2 may keep in D3 state after bootup, in haswell_verify_D0()
880 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
881 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
883 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
884 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
887 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
889 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
897 /* HBR should be Non-PCM, 8 channels */
901 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
906 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
907 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_hbr_setup()
908 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
912 return hbr ? -EINVAL : 0; in hdmi_pin_hbr_setup()
920 codec_dbg(codec, in hdmi_pin_hbr_setup()
923 pinctl == new_pinctl ? "" : "new-", in hdmi_pin_hbr_setup()
927 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
931 return -EINVAL; in hdmi_pin_hbr_setup()
936 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
940 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
944 err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id, in hdmi_setup_stream()
948 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
952 if (spec->intel_hsw_fixup) { in hdmi_setup_stream()
959 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
968 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
972 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
981 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
984 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
995 if (per_pin && per_pin->silent_stream) { in hdmi_choose_cvt()
996 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in hdmi_choose_cvt()
1003 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in hdmi_choose_cvt()
1007 if (per_cvt->assigned) in hdmi_choose_cvt()
1012 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++) in hdmi_choose_cvt()
1013 if (per_pin->mux_nids[mux_idx] == per_cvt->cvt_nid) in hdmi_choose_cvt()
1016 if (mux_idx == per_pin->num_mux_nids) in hdmi_choose_cvt()
1022 if (cvt_idx == spec->num_cvts) in hdmi_choose_cvt()
1023 return -EBUSY; in hdmi_choose_cvt()
1026 per_pin->mux_idx = mux_idx; in hdmi_choose_cvt()
1035 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1038 hda_nid_t pin_nid = per_pin->pin_nid; in intel_verify_pin_cvt_connect()
1041 mux_idx = per_pin->mux_idx; in intel_verify_pin_cvt_connect()
1042 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1045 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1058 for (i = 0; i < spec->num_cvts; i++) in intel_cvt_id_to_mux_idx()
1059 if (spec->cvt_nids[i] == cvt_nid) in intel_cvt_id_to_mux_idx()
1061 return -EINVAL; in intel_cvt_id_to_mux_idx()
1073 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1077 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1085 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in intel_not_share_assigned_cvt()
1094 if (!per_pin->pcm) in intel_not_share_assigned_cvt()
1097 if ((per_pin->pin_nid == pin_nid) && in intel_not_share_assigned_cvt()
1098 (per_pin->dev_id == dev_id)) in intel_not_share_assigned_cvt()
1102 * if per_pin->dev_id >= dev_num, in intel_not_share_assigned_cvt()
1107 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1108 if (per_pin->dev_id >= dev_num) in intel_not_share_assigned_cvt()
1111 nid = per_pin->pin_nid; in intel_not_share_assigned_cvt()
1119 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1120 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1121 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1124 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1130 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
1132 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in intel_not_share_assigned_cvt()
1134 if (!per_cvt->assigned) { in intel_not_share_assigned_cvt()
1135 codec_dbg(codec, in intel_not_share_assigned_cvt()
1138 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1144 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1149 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1153 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1162 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1166 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1170 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1172 if (spec->ops.pin_cvt_fixup) in pin_cvt_fixup()
1173 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1180 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1183 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1184 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_pcm_open_no_pin()
1189 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1191 return -EINVAL; in hdmi_pcm_open_no_pin()
1193 err = hdmi_choose_cvt(codec, -1, &cvt_idx); in hdmi_pcm_open_no_pin()
1198 per_cvt->assigned = 1; in hdmi_pcm_open_no_pin()
1199 hinfo->nid = per_cvt->cvt_nid; in hdmi_pcm_open_no_pin()
1201 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1203 set_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_open_no_pin()
1207 hinfo->channels_min = per_cvt->channels_min; in hdmi_pcm_open_no_pin()
1208 hinfo->channels_max = per_cvt->channels_max; in hdmi_pcm_open_no_pin()
1209 hinfo->rates = per_cvt->rates; in hdmi_pcm_open_no_pin()
1210 hinfo->formats = per_cvt->formats; in hdmi_pcm_open_no_pin()
1211 hinfo->maxbps = per_cvt->maxbps; in hdmi_pcm_open_no_pin()
1214 runtime->hw.channels_min = hinfo->channels_min; in hdmi_pcm_open_no_pin()
1215 runtime->hw.channels_max = hinfo->channels_max; in hdmi_pcm_open_no_pin()
1216 runtime->hw.formats = hinfo->formats; in hdmi_pcm_open_no_pin()
1217 runtime->hw.rates = hinfo->rates; in hdmi_pcm_open_no_pin()
1219 snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_pcm_open_no_pin()
1228 struct hda_codec *codec, in hdmi_pcm_open() argument
1231 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1232 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_pcm_open()
1240 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1242 return -EINVAL; in hdmi_pcm_open()
1244 mutex_lock(&spec->pcm_lock); in hdmi_pcm_open()
1245 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1246 if (!spec->dyn_pcm_assign) { in hdmi_pcm_open()
1248 err = -EINVAL; in hdmi_pcm_open()
1256 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1261 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in hdmi_pcm_open()
1267 per_cvt->assigned = 1; in hdmi_pcm_open()
1269 set_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_open()
1271 per_pin->cvt_nid = per_cvt->cvt_nid; in hdmi_pcm_open()
1272 per_pin->silent_stream = false; in hdmi_pcm_open()
1273 hinfo->nid = per_cvt->cvt_nid; in hdmi_pcm_open()
1276 if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE) in hdmi_pcm_open()
1277 azx_stream(get_azx_dev(substream))->stripe = 1; in hdmi_pcm_open()
1279 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1280 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1282 per_pin->mux_idx); in hdmi_pcm_open()
1285 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1287 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1290 hinfo->channels_min = per_cvt->channels_min; in hdmi_pcm_open()
1291 hinfo->channels_max = per_cvt->channels_max; in hdmi_pcm_open()
1292 hinfo->rates = per_cvt->rates; in hdmi_pcm_open()
1293 hinfo->formats = per_cvt->formats; in hdmi_pcm_open()
1294 hinfo->maxbps = per_cvt->maxbps; in hdmi_pcm_open()
1296 eld = &per_pin->sink_eld; in hdmi_pcm_open()
1298 if (!static_hdmi_pcm && eld->eld_valid) { in hdmi_pcm_open()
1299 snd_hdmi_eld_update_pcm_info(&eld->info, hinfo); in hdmi_pcm_open()
1300 if (hinfo->channels_min > hinfo->channels_max || in hdmi_pcm_open()
1301 !hinfo->rates || !hinfo->formats) { in hdmi_pcm_open()
1302 per_cvt->assigned = 0; in hdmi_pcm_open()
1303 hinfo->nid = 0; in hdmi_pcm_open()
1304 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1305 err = -ENODEV; in hdmi_pcm_open()
1311 runtime->hw.channels_min = hinfo->channels_min; in hdmi_pcm_open()
1312 runtime->hw.channels_max = hinfo->channels_max; in hdmi_pcm_open()
1313 runtime->hw.formats = hinfo->formats; in hdmi_pcm_open()
1314 runtime->hw.rates = hinfo->rates; in hdmi_pcm_open()
1316 snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_pcm_open()
1319 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_open()
1326 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1328 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1330 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_read_pin_conn()
1331 int dev_id = per_pin->dev_id; in hdmi_read_pin_conn()
1334 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1335 codec_warn(codec, in hdmi_read_pin_conn()
1337 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1338 return -EINVAL; in hdmi_read_pin_conn()
1341 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_read_pin_conn()
1343 if (spec->intel_hsw_fixup) { in hdmi_read_pin_conn()
1344 conns = spec->num_cvts; in hdmi_read_pin_conn()
1345 memcpy(per_pin->mux_nids, spec->cvt_nids, in hdmi_read_pin_conn()
1348 conns = snd_hda_get_raw_connections(codec, pin_nid, in hdmi_read_pin_conn()
1349 per_pin->mux_nids, in hdmi_read_pin_conn()
1354 per_pin->num_mux_nids = conns; in hdmi_read_pin_conn()
1367 if (spec->dyn_pcm_no_legacy) in hdmi_find_pcm_slot()
1372 * platforms (with maximum of 'num_nids + dev_num - 1') in hdmi_find_pcm_slot()
1374 * The per_pin of pin_nid_idx=n and dev_id=m prefers to get pcm-n in hdmi_find_pcm_slot()
1376 * with the legacy static per_pin-pcm assignment that existed in the in hdmi_find_pcm_slot()
1377 * days before DP-MST. in hdmi_find_pcm_slot()
1379 * Intel DP-MST prefers this legacy behavior for compatibility, too. in hdmi_find_pcm_slot()
1381 * per_pin of m!=0 prefers to get pcm=(num_nids + (m - 1)). in hdmi_find_pcm_slot()
1384 if (per_pin->dev_id == 0 || spec->intel_hsw_fixup) { in hdmi_find_pcm_slot()
1385 if (!test_bit(per_pin->pin_nid_idx, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1386 return per_pin->pin_nid_idx; in hdmi_find_pcm_slot()
1388 i = spec->num_nids + (per_pin->dev_id - 1); in hdmi_find_pcm_slot()
1389 if (i < spec->pcm_used && !(test_bit(i, &spec->pcm_bitmap))) in hdmi_find_pcm_slot()
1394 for (i = spec->num_nids; i < spec->pcm_used; i++) { in hdmi_find_pcm_slot()
1395 if (!test_bit(i, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1401 for (i = 0; i < spec->pcm_used; i++) { in hdmi_find_pcm_slot()
1402 if (!test_bit(i, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1405 return -EBUSY; in hdmi_find_pcm_slot()
1414 if (per_pin->pcm) in hdmi_attach_hda_pcm()
1417 if (idx == -EBUSY) in hdmi_attach_hda_pcm()
1419 per_pin->pcm_idx = idx; in hdmi_attach_hda_pcm()
1420 per_pin->pcm = get_hdmi_pcm(spec, idx); in hdmi_attach_hda_pcm()
1421 set_bit(idx, &spec->pcm_bitmap); in hdmi_attach_hda_pcm()
1430 if (!per_pin->pcm) in hdmi_detach_hda_pcm()
1432 idx = per_pin->pcm_idx; in hdmi_detach_hda_pcm()
1433 per_pin->pcm_idx = -1; in hdmi_detach_hda_pcm()
1434 per_pin->pcm = NULL; in hdmi_detach_hda_pcm()
1435 if (idx >= 0 && idx < spec->pcm_used) in hdmi_detach_hda_pcm()
1436 clear_bit(idx, &spec->pcm_bitmap); in hdmi_detach_hda_pcm()
1444 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++) in hdmi_get_pin_cvt_mux()
1445 if (per_pin->mux_nids[mux_idx] == cvt_nid) in hdmi_get_pin_cvt_mux()
1450 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1455 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1462 if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used) in hdmi_pcm_setup_pin()
1463 pcm = get_pcm_rec(spec, per_pin->pcm_idx); in hdmi_pcm_setup_pin()
1466 if (!pcm->pcm) in hdmi_pcm_setup_pin()
1468 if (!test_bit(per_pin->pcm_idx, &spec->pcm_in_use)) in hdmi_pcm_setup_pin()
1472 hinfo = pcm->stream; in hdmi_pcm_setup_pin()
1473 substream = pcm->pcm->streams[0].substream; in hdmi_pcm_setup_pin()
1475 per_pin->cvt_nid = hinfo->nid; in hdmi_pcm_setup_pin()
1477 mux_idx = hdmi_get_pin_cvt_mux(spec, per_pin, hinfo->nid); in hdmi_pcm_setup_pin()
1478 if (mux_idx < per_pin->num_mux_nids) { in hdmi_pcm_setup_pin()
1479 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1480 per_pin->dev_id); in hdmi_pcm_setup_pin()
1481 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1485 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1487 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1488 if (substream->runtime) in hdmi_pcm_setup_pin()
1489 per_pin->channels = substream->runtime->channels; in hdmi_pcm_setup_pin()
1490 per_pin->setup = true; in hdmi_pcm_setup_pin()
1491 per_pin->mux_idx = mux_idx; in hdmi_pcm_setup_pin()
1493 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1499 if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used) in hdmi_pcm_reset_pin()
1500 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1502 per_pin->chmap_set = false; in hdmi_pcm_reset_pin()
1503 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_reset_pin()
1505 per_pin->setup = false; in hdmi_pcm_reset_pin()
1506 per_pin->channels = 0; in hdmi_pcm_reset_pin()
1509 static struct snd_jack *pin_idx_to_pcm_jack(struct hda_codec *codec, in pin_idx_to_pcm_jack() argument
1512 struct hdmi_spec *spec = codec->spec; in pin_idx_to_pcm_jack()
1514 if (per_pin->pcm_idx >= 0) in pin_idx_to_pcm_jack()
1515 return spec->pcm_rec[per_pin->pcm_idx].jack; in pin_idx_to_pcm_jack()
1524 static void update_eld(struct hda_codec *codec, in update_eld() argument
1529 struct hdmi_eld *pin_eld = &per_pin->sink_eld; in update_eld()
1530 struct hdmi_spec *spec = codec->spec; in update_eld()
1532 bool old_eld_valid = pin_eld->eld_valid; in update_eld()
1536 if (eld->eld_valid) { in update_eld()
1537 if (eld->eld_size <= 0 || in update_eld()
1538 snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in update_eld()
1539 eld->eld_size) < 0) { in update_eld()
1540 eld->eld_valid = false; in update_eld()
1542 schedule_delayed_work(&per_pin->work, in update_eld()
1549 if (!eld->eld_valid || eld->eld_size <= 0) { in update_eld()
1550 eld->eld_valid = false; in update_eld()
1551 eld->eld_size = 0; in update_eld()
1555 pcm_idx = per_pin->pcm_idx; in update_eld()
1561 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1563 if (spec->dyn_pcm_assign) { in update_eld()
1564 if (eld->eld_valid) { in update_eld()
1572 /* if pcm_idx == -1, it means this is in monitor connection event in update_eld()
1575 if (pcm_idx == -1) in update_eld()
1576 pcm_idx = per_pin->pcm_idx; in update_eld()
1578 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1580 if (eld->eld_valid) in update_eld()
1581 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1583 eld_changed = (pin_eld->eld_valid != eld->eld_valid); in update_eld()
1584 eld_changed |= (pin_eld->monitor_present != eld->monitor_present); in update_eld()
1585 if (!eld_changed && eld->eld_valid && pin_eld->eld_valid) in update_eld()
1586 if (pin_eld->eld_size != eld->eld_size || in update_eld()
1587 memcmp(pin_eld->eld_buffer, eld->eld_buffer, in update_eld()
1588 eld->eld_size) != 0) in update_eld()
1592 pin_eld->monitor_present = eld->monitor_present; in update_eld()
1593 pin_eld->eld_valid = eld->eld_valid; in update_eld()
1594 pin_eld->eld_size = eld->eld_size; in update_eld()
1595 if (eld->eld_valid) in update_eld()
1596 memcpy(pin_eld->eld_buffer, eld->eld_buffer, in update_eld()
1597 eld->eld_size); in update_eld()
1598 pin_eld->info = eld->info; in update_eld()
1602 * Re-setup pin and infoframe. This is needed e.g. when in update_eld()
1603 * - sink is first plugged-in in update_eld()
1604 * - transcoder can change during stream playback on Haswell in update_eld()
1607 if (eld->eld_valid && !old_eld_valid && per_pin->setup) { in update_eld()
1608 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1609 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1613 snd_ctl_notify(codec->card, in update_eld()
1616 &get_hdmi_pcm(spec, pcm_idx)->eld_ctl->id); in update_eld()
1620 (eld->monitor_present && eld->eld_valid) ? in update_eld()
1624 /* update ELD and jack state via HD-audio verbs */
1628 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1629 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1630 struct hdmi_eld *eld = &spec->temp_eld; in hdmi_present_sense_via_verbs()
1631 struct device *dev = hda_codec_dev(codec); in hdmi_present_sense_via_verbs()
1632 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_present_sense_via_verbs()
1633 int dev_id = per_pin->dev_id; in hdmi_present_sense_via_verbs()
1638 * the real PD value changed. An older version of the HD-audio in hdmi_present_sense_via_verbs()
1646 if (dev->power.runtime_status == RPM_SUSPENDING) in hdmi_present_sense_via_verbs()
1650 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense_via_verbs()
1654 present = snd_hda_jack_pin_sense(codec, pin_nid, dev_id); in hdmi_present_sense_via_verbs()
1656 mutex_lock(&per_pin->lock); in hdmi_present_sense_via_verbs()
1657 eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); in hdmi_present_sense_via_verbs()
1658 if (eld->monitor_present) in hdmi_present_sense_via_verbs()
1659 eld->eld_valid = !!(present & AC_PINSENSE_ELDV); in hdmi_present_sense_via_verbs()
1661 eld->eld_valid = false; in hdmi_present_sense_via_verbs()
1663 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1664 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_present_sense_via_verbs()
1665 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1667 if (eld->eld_valid) { in hdmi_present_sense_via_verbs()
1668 if (spec->ops.pin_get_eld(codec, pin_nid, dev_id, in hdmi_present_sense_via_verbs()
1669 eld->eld_buffer, &eld->eld_size) < 0) in hdmi_present_sense_via_verbs()
1670 eld->eld_valid = false; in hdmi_present_sense_via_verbs()
1673 update_eld(codec, per_pin, eld, repoll); in hdmi_present_sense_via_verbs()
1674 mutex_unlock(&per_pin->lock); in hdmi_present_sense_via_verbs()
1676 snd_hda_power_down_pm(codec); in hdmi_present_sense_via_verbs()
1685 static void silent_stream_enable(struct hda_codec *codec, in silent_stream_enable() argument
1688 struct hdmi_spec *spec = codec->spec; in silent_stream_enable()
1693 mutex_lock(&per_pin->lock); in silent_stream_enable()
1695 if (per_pin->setup) { in silent_stream_enable()
1696 codec_dbg(codec, "hdmi: PCM already open, no silent stream\n"); in silent_stream_enable()
1700 pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1701 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in silent_stream_enable()
1703 codec_err(codec, "hdmi: no free converter to enable silent mode\n"); in silent_stream_enable()
1708 per_cvt->assigned = 1; in silent_stream_enable()
1709 per_pin->cvt_nid = per_cvt->cvt_nid; in silent_stream_enable()
1710 per_pin->silent_stream = true; in silent_stream_enable()
1712 codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_enable()
1713 per_pin->pin_nid, per_cvt->cvt_nid); in silent_stream_enable()
1715 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1716 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1718 per_pin->mux_idx); in silent_stream_enable()
1721 pin_cvt_fixup(codec, per_pin, 0); in silent_stream_enable()
1723 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in silent_stream_enable()
1724 per_pin->dev_id, I915_SILENT_RATE); in silent_stream_enable()
1729 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, in silent_stream_enable()
1732 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format); in silent_stream_enable()
1734 per_pin->channels = I915_SILENT_CHANNELS; in silent_stream_enable()
1735 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable()
1738 mutex_unlock(&per_pin->lock); in silent_stream_enable()
1741 static void silent_stream_disable(struct hda_codec *codec, in silent_stream_disable() argument
1744 struct hdmi_spec *spec = codec->spec; in silent_stream_disable()
1748 mutex_lock(&per_pin->lock); in silent_stream_disable()
1749 if (!per_pin->silent_stream) in silent_stream_disable()
1752 codec_dbg(codec, "HDMI: disable silent stream on pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_disable()
1753 per_pin->pin_nid, per_pin->cvt_nid); in silent_stream_disable()
1755 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in silent_stream_disable()
1756 if (cvt_idx >= 0 && cvt_idx < spec->num_cvts) { in silent_stream_disable()
1758 per_cvt->assigned = 0; in silent_stream_disable()
1761 per_pin->cvt_nid = 0; in silent_stream_disable()
1762 per_pin->silent_stream = false; in silent_stream_disable()
1765 mutex_unlock(&per_pin->lock); in silent_stream_disable()
1769 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1772 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1773 struct hdmi_eld *eld = &spec->temp_eld; in sync_eld_via_acomp()
1776 mutex_lock(&per_pin->lock); in sync_eld_via_acomp()
1777 eld->monitor_present = false; in sync_eld_via_acomp()
1778 monitor_prev = per_pin->sink_eld.monitor_present; in sync_eld_via_acomp()
1779 eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1780 per_pin->dev_id, &eld->monitor_present, in sync_eld_via_acomp()
1781 eld->eld_buffer, ELD_MAX_SIZE); in sync_eld_via_acomp()
1782 eld->eld_valid = (eld->eld_size > 0); in sync_eld_via_acomp()
1783 update_eld(codec, per_pin, eld, 0); in sync_eld_via_acomp()
1784 monitor_next = per_pin->sink_eld.monitor_present; in sync_eld_via_acomp()
1785 mutex_unlock(&per_pin->lock); in sync_eld_via_acomp()
1788 * Power-up will call hdmi_present_sense, so the PM calls in sync_eld_via_acomp()
1792 if (spec->send_silent_stream) { in sync_eld_via_acomp()
1796 pm_ret = snd_hda_power_up_pm(codec); in sync_eld_via_acomp()
1798 codec_err(codec, in sync_eld_via_acomp()
1799 "Monitor plugged-in, Failed to power up codec ret=[%d]\n", in sync_eld_via_acomp()
1801 silent_stream_enable(codec, per_pin); in sync_eld_via_acomp()
1803 silent_stream_disable(codec, per_pin); in sync_eld_via_acomp()
1804 pm_ret = snd_hda_power_down_pm(codec); in sync_eld_via_acomp()
1806 codec_err(codec, in sync_eld_via_acomp()
1807 "Monitor plugged-out, Failed to power down codec ret=[%d]\n", in sync_eld_via_acomp()
1815 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1817 if (!codec_has_acomp(codec)) in hdmi_present_sense()
1820 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1827 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1828 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1831 jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, in hdmi_repoll_eld()
1832 per_pin->dev_id); in hdmi_repoll_eld()
1834 jack->jack_dirty = 1; in hdmi_repoll_eld()
1836 if (per_pin->repoll_count++ > 6) in hdmi_repoll_eld()
1837 per_pin->repoll_count = 0; in hdmi_repoll_eld()
1839 mutex_lock(&spec->pcm_lock); in hdmi_repoll_eld()
1840 hdmi_present_sense(per_pin, per_pin->repoll_count); in hdmi_repoll_eld()
1841 mutex_unlock(&spec->pcm_lock); in hdmi_repoll_eld()
1844 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1846 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1853 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1861 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1863 !spec->force_connect) in hdmi_add_pin()
1870 if (spec->intel_hsw_fixup) { in hdmi_add_pin()
1875 * Otherwise, it is 1. in hdmi_add_pin()
1881 spec->dev_num = 3; in hdmi_add_pin()
1882 } else if (spec->dyn_pcm_assign && codec->dp_mst) { in hdmi_add_pin()
1883 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1885 * spec->dev_num is the maxinum number of device entries in hdmi_add_pin()
1888 spec->dev_num = (spec->dev_num > dev_num) ? in hdmi_add_pin()
1889 spec->dev_num : dev_num; in hdmi_add_pin()
1893 * manually set dev_num to 1. This means in hdmi_add_pin()
1896 dev_num = 1; in hdmi_add_pin()
1897 spec->dev_num = 1; in hdmi_add_pin()
1901 pin_idx = spec->num_pins; in hdmi_add_pin()
1902 per_pin = snd_array_new(&spec->pins); in hdmi_add_pin()
1905 return -ENOMEM; in hdmi_add_pin()
1907 if (spec->dyn_pcm_assign) { in hdmi_add_pin()
1908 per_pin->pcm = NULL; in hdmi_add_pin()
1909 per_pin->pcm_idx = -1; in hdmi_add_pin()
1911 per_pin->pcm = get_hdmi_pcm(spec, pin_idx); in hdmi_add_pin()
1912 per_pin->pcm_idx = pin_idx; in hdmi_add_pin()
1914 per_pin->pin_nid = pin_nid; in hdmi_add_pin()
1915 per_pin->pin_nid_idx = spec->num_nids; in hdmi_add_pin()
1916 per_pin->dev_id = i; in hdmi_add_pin()
1917 per_pin->non_pcm = false; in hdmi_add_pin()
1918 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1919 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1922 spec->num_pins++; in hdmi_add_pin()
1924 spec->num_nids++; in hdmi_add_pin()
1929 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1931 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1936 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1939 per_cvt = snd_array_new(&spec->cvts); in hdmi_add_cvt()
1941 return -ENOMEM; in hdmi_add_cvt()
1943 per_cvt->cvt_nid = cvt_nid; in hdmi_add_cvt()
1944 per_cvt->channels_min = 2; in hdmi_add_cvt()
1946 per_cvt->channels_max = chans; in hdmi_add_cvt()
1947 if (chans > spec->chmap.channels_max) in hdmi_add_cvt()
1948 spec->chmap.channels_max = chans; in hdmi_add_cvt()
1951 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1952 &per_cvt->rates, in hdmi_add_cvt()
1953 &per_cvt->formats, in hdmi_add_cvt()
1954 &per_cvt->maxbps); in hdmi_add_cvt()
1958 if (spec->num_cvts < ARRAY_SIZE(spec->cvt_nids)) in hdmi_add_cvt()
1959 spec->cvt_nids[spec->num_cvts] = cvt_nid; in hdmi_add_cvt()
1960 spec->num_cvts++; in hdmi_add_cvt()
1966 SND_PCI_QUIRK(0x103c, 0x870f, "HP", 1),
1967 SND_PCI_QUIRK(0x103c, 0x871a, "HP", 1),
1968 SND_PCI_QUIRK(0x1462, 0xec94, "MS-7C94", 1),
1972 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1974 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
1980 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
1982 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1983 return -EINVAL; in hdmi_parse_codec()
1986 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
1988 if (q && q->value) in hdmi_parse_codec()
1989 spec->force_connect = true; in hdmi_parse_codec()
1998 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2004 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
2011 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2017 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
2025 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
2030 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2031 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
2036 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2039 non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO); in check_non_pcm_per_cvt()
2040 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2049 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
2054 hda_nid_t cvt_nid = hinfo->nid; in generic_hdmi_playback_pcm_prepare()
2055 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
2058 struct snd_pcm_runtime *runtime = substream->runtime; in generic_hdmi_playback_pcm_prepare()
2063 mutex_lock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2064 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
2065 if (spec->dyn_pcm_assign && pin_idx < 0) { in generic_hdmi_playback_pcm_prepare()
2070 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2071 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
2077 err = -EINVAL; in generic_hdmi_playback_pcm_prepare()
2090 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
2094 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
2095 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2096 per_pin->dev_id, runtime->rate); in generic_hdmi_playback_pcm_prepare()
2098 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2099 mutex_lock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2100 per_pin->channels = substream->runtime->channels; in generic_hdmi_playback_pcm_prepare()
2101 per_pin->setup = true; in generic_hdmi_playback_pcm_prepare()
2103 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
2104 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2106 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
2111 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
2112 mutex_unlock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2113 if (spec->dyn_pin_out) { in generic_hdmi_playback_pcm_prepare()
2114 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2115 per_pin->dev_id); in generic_hdmi_playback_pcm_prepare()
2116 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2118 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2124 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2125 per_pin->dev_id, stream_tag, format); in generic_hdmi_playback_pcm_prepare()
2127 mutex_unlock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2132 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
2135 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2140 struct hda_codec *codec, in hdmi_pcm_close() argument
2143 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2150 mutex_lock(&spec->pcm_lock); in hdmi_pcm_close()
2151 if (hinfo->nid) { in hdmi_pcm_close()
2152 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
2154 err = -EINVAL; in hdmi_pcm_close()
2157 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2159 err = -EINVAL; in hdmi_pcm_close()
2163 per_cvt->assigned = 0; in hdmi_pcm_close()
2164 hinfo->nid = 0; in hdmi_pcm_close()
2166 azx_stream(get_azx_dev(substream))->stripe = 0; in hdmi_pcm_close()
2168 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
2169 clear_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_close()
2170 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
2171 if (spec->dyn_pcm_assign && pin_idx < 0) in hdmi_pcm_close()
2175 err = -EINVAL; in hdmi_pcm_close()
2180 if (spec->dyn_pin_out) { in hdmi_pcm_close()
2181 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2182 per_pin->dev_id); in hdmi_pcm_close()
2183 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2185 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2190 mutex_lock(&per_pin->lock); in hdmi_pcm_close()
2191 per_pin->chmap_set = false; in hdmi_pcm_close()
2192 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_close()
2194 per_pin->setup = false; in hdmi_pcm_close()
2195 per_pin->channels = 0; in hdmi_pcm_close()
2196 mutex_unlock(&per_pin->lock); in hdmi_pcm_close()
2200 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_close()
2214 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_spk_alloc() local
2215 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2221 return per_pin->sink_eld.info.spk_alloc; in hdmi_get_spk_alloc()
2227 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_chmap() local
2228 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2235 memcpy(chmap, per_pin->chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_get_chmap()
2241 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_set_chmap() local
2242 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2247 mutex_lock(&per_pin->lock); in hdmi_set_chmap()
2248 per_pin->chmap_set = true; in hdmi_set_chmap()
2249 memcpy(per_pin->chmap, chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_set_chmap()
2251 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2252 mutex_unlock(&per_pin->lock); in hdmi_set_chmap()
2257 struct hda_codec *codec = hdac_to_hda_codec(hdac); in is_hdmi_pcm_attached() local
2258 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2264 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2266 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2270 * for non-mst mode, pcm number is the same as before in generic_hdmi_build_pcms()
2273 * (nid number + dev_num - 1) in generic_hdmi_build_pcms()
2277 if (spec->dyn_pcm_no_legacy && codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2278 pcm_num = spec->num_cvts; in generic_hdmi_build_pcms()
2279 else if (codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2280 pcm_num = spec->num_nids; in generic_hdmi_build_pcms()
2282 pcm_num = spec->num_nids + spec->dev_num - 1; in generic_hdmi_build_pcms()
2284 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); in generic_hdmi_build_pcms()
2290 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2292 return -ENOMEM; in generic_hdmi_build_pcms()
2294 spec->pcm_rec[idx].pcm = info; in generic_hdmi_build_pcms()
2295 spec->pcm_used++; in generic_hdmi_build_pcms()
2296 info->pcm_type = HDA_PCM_TYPE_HDMI; in generic_hdmi_build_pcms()
2297 info->own_chmap = true; in generic_hdmi_build_pcms()
2299 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in generic_hdmi_build_pcms()
2300 pstr->substreams = 1; in generic_hdmi_build_pcms()
2301 pstr->ops = generic_ops; in generic_hdmi_build_pcms()
2303 if (spec->pcm_used >= 16) in generic_hdmi_build_pcms()
2313 struct hdmi_pcm *pcm = jack->private_data; in free_hdmi_jack_priv()
2315 pcm->jack = NULL; in free_hdmi_jack_priv()
2318 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2321 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2324 int pcmdev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_jack()
2329 if (!spec->dyn_pcm_assign && in generic_hdmi_build_jack()
2330 !is_jack_detectable(codec, per_pin->pin_nid)) in generic_hdmi_build_jack()
2332 sizeof(hdmi_str) - strlen(hdmi_str) - 1); in generic_hdmi_build_jack()
2334 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2339 spec->pcm_rec[pcm_idx].jack = jack; in generic_hdmi_build_jack()
2340 jack->private_data = &spec->pcm_rec[pcm_idx]; in generic_hdmi_build_jack()
2341 jack->private_free = free_hdmi_jack_priv; in generic_hdmi_build_jack()
2345 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2347 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2351 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2352 if (!get_pcm_rec(spec, pcm_idx)->pcm) { in generic_hdmi_build_controls()
2354 set_bit(pcm_idx, &spec->pcm_bitmap); in generic_hdmi_build_controls()
2358 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2365 if (spec->dyn_pcm_assign) in generic_hdmi_build_controls()
2366 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2367 0, spec->cvt_nids[0], in generic_hdmi_build_controls()
2372 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2373 per_pin->pin_nid, in generic_hdmi_build_controls()
2374 per_pin->mux_nids[0], in generic_hdmi_build_controls()
2379 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2381 dev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_controls()
2384 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); 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 pin_eld->eld_valid = false; in generic_hdmi_build_controls()
2399 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2403 if (!pcm || !pcm->pcm) in generic_hdmi_build_controls()
2405 err = snd_hdac_add_chmap_ctls(pcm->pcm, pcm_idx, &spec->chmap); in generic_hdmi_build_controls()
2413 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2415 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2418 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init_per_pins()
2421 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2422 mutex_init(&per_pin->lock); in generic_hdmi_init_per_pins()
2423 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); in generic_hdmi_init_per_pins()
2429 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2431 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2434 mutex_lock(&spec->bind_lock); in generic_hdmi_init()
2435 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init()
2437 hda_nid_t pin_nid = per_pin->pin_nid; in generic_hdmi_init()
2438 int dev_id = per_pin->dev_id; in generic_hdmi_init()
2440 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2441 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2442 if (codec_has_acomp(codec)) in generic_hdmi_init()
2444 snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id, in generic_hdmi_init()
2447 mutex_unlock(&spec->bind_lock); in generic_hdmi_init()
2453 snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums); in hdmi_array_init()
2454 snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums); in hdmi_array_init()
2459 snd_array_free(&spec->pins); in hdmi_array_free()
2460 snd_array_free(&spec->cvts); in hdmi_array_free()
2463 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2465 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2470 codec->spec = NULL; in generic_spec_free()
2472 codec->dp_mst = false; in generic_spec_free()
2475 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2477 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2480 if (spec->acomp_registered) { in generic_hdmi_free()
2481 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2482 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2483 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2485 codec->relaxed_resume = 0; in generic_hdmi_free()
2487 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_free()
2489 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_free()
2493 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_free()
2494 if (spec->pcm_rec[pcm_idx].jack == NULL) in generic_hdmi_free()
2496 if (spec->dyn_pcm_assign) in generic_hdmi_free()
2497 snd_device_free(codec->card, in generic_hdmi_free()
2498 spec->pcm_rec[pcm_idx].jack); in generic_hdmi_free()
2500 spec->pcm_rec[pcm_idx].jack = NULL; in generic_hdmi_free()
2503 generic_spec_free(codec); in generic_hdmi_free()
2507 static int generic_hdmi_suspend(struct hda_codec *codec) in generic_hdmi_suspend() argument
2509 struct hdmi_spec *spec = codec->spec; in generic_hdmi_suspend()
2512 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_suspend()
2514 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_suspend()
2519 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2521 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2524 codec->patch_ops.init(codec); in generic_hdmi_resume()
2525 snd_hda_regmap_sync(codec); in generic_hdmi_resume()
2527 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_resume()
2529 hdmi_present_sense(per_pin, 1); in generic_hdmi_resume()
2554 /* allocate codec->spec and assign/initialize generic parser ops */
2555 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2561 return -ENOMEM; in alloc_generic_hdmi()
2563 spec->codec = codec; in alloc_generic_hdmi()
2564 spec->ops = generic_standard_hdmi_ops; in alloc_generic_hdmi()
2565 spec->dev_num = 1; /* initialize to 1 */ in alloc_generic_hdmi()
2566 mutex_init(&spec->pcm_lock); in alloc_generic_hdmi()
2567 mutex_init(&spec->bind_lock); in alloc_generic_hdmi()
2568 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2570 spec->chmap.ops.get_chmap = hdmi_get_chmap; in alloc_generic_hdmi()
2571 spec->chmap.ops.set_chmap = hdmi_set_chmap; in alloc_generic_hdmi()
2572 spec->chmap.ops.is_pcm_attached = is_hdmi_pcm_attached; in alloc_generic_hdmi()
2573 spec->chmap.ops.get_spk_alloc = hdmi_get_spk_alloc; in alloc_generic_hdmi()
2575 codec->spec = spec; in alloc_generic_hdmi()
2578 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2584 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2588 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2592 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2594 generic_spec_free(codec); in patch_generic_hdmi()
2598 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2607 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2612 tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in reprogram_jack_detect()
2614 /* clear unsol even if component notifier is used, or re-enable in reprogram_jack_detect()
2617 unsigned int val = use_acomp ? 0 : (AC_USRSP_EN | tbl->tag); in reprogram_jack_detect()
2618 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2630 spec = container_of(acomp->audio_ops, struct hdmi_spec, drm_audio_ops); in generic_acomp_notifier_set()
2631 mutex_lock(&spec->bind_lock); in generic_acomp_notifier_set()
2632 spec->use_acomp_notifier = use_acomp; in generic_acomp_notifier_set()
2633 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2634 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2636 for (i = 0; i < spec->num_pins; i++) in generic_acomp_notifier_set()
2637 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2638 get_pin(spec, i)->pin_nid, in generic_acomp_notifier_set()
2639 get_pin(spec, i)->dev_id, in generic_acomp_notifier_set()
2641 mutex_unlock(&spec->bind_lock); in generic_acomp_notifier_set()
2658 /* check whether both HD-audio and DRM PCI devices belong to the same bus */
2664 if (!dev_is_pci(dev) || !dev_is_pci(bus->dev)) in match_bound_vga()
2666 master = to_pci_dev(bus->dev); in match_bound_vga()
2668 return master->bus == pci->bus; in match_bound_vga()
2674 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2675 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2676 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2680 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2685 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in generic_acomp_pin_eld_notify()
2688 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2692 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2695 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2697 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2703 spec->drm_audio_ops.pin2port = ops->pin2port; in setup_drm_audio_ops()
2704 spec->drm_audio_ops.pin_eld_notify = ops->pin_eld_notify; in setup_drm_audio_ops()
2705 spec->drm_audio_ops.master_bind = ops->master_bind; in setup_drm_audio_ops()
2706 spec->drm_audio_ops.master_unbind = ops->master_unbind; in setup_drm_audio_ops()
2710 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2714 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2717 codec_info(codec, "audio component disabled by module option\n"); in generic_acomp_init()
2721 spec->port2pin = port2pin; in generic_acomp_init()
2722 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2723 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2725 spec->acomp_registered = true; in generic_acomp_init()
2730 * Intel codec parsers and helpers
2738 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2742 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2744 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2746 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) in intel_haswell_enable_all_pins()
2750 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2752 if (vendor_param == -1) in intel_haswell_enable_all_pins()
2756 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2759 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2762 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2764 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2766 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) in intel_haswell_fixup_enable_dp12()
2771 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2772 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2776 /* Haswell needs to re-issue the vendor-specific verbs before turning to D0.
2779 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2783 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2784 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2787 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2788 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2793 * Pin Widget 5 - PORT B (port = 1 in i915 driver)
2794 * Pin Widget 6 - PORT C (port = 2 in i915 driver)
2795 * Pin Widget 7 - PORT D (port = 3 in i915 driver)
2798 * Pin Widget 4 - PORT B (port = 1 in i915 driver)
2799 * Pin Widget 5 - PORT C (port = 2 in i915 driver)
2800 * Pin Widget 6 - PORT D (port = 3 in i915 driver)
2802 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2804 switch (codec->core.vendor_id) { in intel_base_nid()
2816 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2817 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2820 if (!spec->port_num) { in intel_pin2port()
2821 base_nid = intel_base_nid(codec); in intel_pin2port()
2823 return -1; in intel_pin2port()
2824 return pin_nid - base_nid + 1; in intel_pin2port()
2831 for (i = 0; i < spec->port_num; i++) { in intel_pin2port()
2832 if (pin_nid == spec->port_map[i]) in intel_pin2port()
2836 codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid); in intel_pin2port()
2837 return -1; in intel_pin2port()
2840 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2842 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2844 if (!spec->port_num) { in intel_port2pin()
2845 /* we assume only from port-B to port-D */ in intel_port2pin()
2846 if (port < 1 || port > 3) in intel_port2pin()
2848 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2851 if (port < 0 || port >= spec->port_num) in intel_port2pin()
2853 return spec->port_map[port]; in intel_port2pin()
2858 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2862 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2868 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
2871 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2872 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2881 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2883 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2885 spec->use_acomp_notifier = true; in register_i915_notifier()
2886 spec->port2pin = intel_port2pin; in register_i915_notifier()
2887 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2888 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2889 &spec->drm_audio_ops); in register_i915_notifier()
2891 codec->relaxed_resume = 1; in register_i915_notifier()
2895 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2899 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2900 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
2905 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2910 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2911 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2912 per_pin->dev_id); in i915_pin_cvt_fixup()
2913 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2914 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2915 per_pin->dev_id, per_pin->mux_idx); in i915_pin_cvt_fixup()
2917 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2922 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2927 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2928 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2930 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2931 return -ENODEV; in alloc_intel_hdmi()
2934 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2938 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
2942 /* parse and post-process for Intel codecs */
2943 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2948 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2949 } while (err < 0 && retries--); in parse_intel_hdmi()
2952 generic_spec_free(codec); in parse_intel_hdmi()
2956 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2957 register_i915_notifier(codec); in parse_intel_hdmi()
2962 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
2968 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2971 spec = codec->spec; in intel_hsw_common_init()
2972 codec->dp_mst = true; in intel_hsw_common_init()
2973 spec->dyn_pcm_assign = true; in intel_hsw_common_init()
2974 spec->vendor_nid = vendor_nid; in intel_hsw_common_init()
2975 spec->port_map = port_map; in intel_hsw_common_init()
2976 spec->port_num = port_num; in intel_hsw_common_init()
2977 spec->intel_hsw_fixup = true; in intel_hsw_common_init()
2979 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2980 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2982 codec->display_power_control = 1; in intel_hsw_common_init()
2984 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2985 codec->depop_delay = 0; in intel_hsw_common_init()
2986 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2988 spec->ops.setup_stream = i915_hsw_setup_stream; in intel_hsw_common_init()
2989 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in intel_hsw_common_init()
2996 spec->send_silent_stream = true; in intel_hsw_common_init()
2998 return parse_intel_hdmi(codec); in intel_hsw_common_init()
3001 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
3003 return intel_hsw_common_init(codec, 0x08, NULL, 0); in patch_i915_hsw_hdmi()
3006 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
3008 return intel_hsw_common_init(codec, 0x0b, NULL, 0); in patch_i915_glk_hdmi()
3011 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
3019 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_icl_hdmi()
3022 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
3031 ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_tgl_hdmi()
3033 struct hdmi_spec *spec = codec->spec; in patch_i915_tgl_hdmi()
3035 spec->dyn_pcm_no_legacy = true; in patch_i915_tgl_hdmi()
3042 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
3047 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
3050 spec = codec->spec; in patch_i915_byt_hdmi()
3052 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
3055 codec->display_power_control = 1; in patch_i915_byt_hdmi()
3057 codec->depop_delay = 0; in patch_i915_byt_hdmi()
3058 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
3060 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in patch_i915_byt_hdmi()
3062 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
3066 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
3070 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3073 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3077 * Shared non-generic implementations
3080 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
3082 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
3089 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
3092 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
3094 return -ENOMEM; in simple_playback_build_pcms()
3095 spec->pcm_rec[0].pcm = info; in simple_playback_build_pcms()
3096 info->pcm_type = HDA_PCM_TYPE_HDMI; in simple_playback_build_pcms()
3097 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in simple_playback_build_pcms()
3098 *pstr = spec->pcm_playback; in simple_playback_build_pcms()
3099 pstr->nid = per_cvt->cvt_nid; in simple_playback_build_pcms()
3100 if (pstr->channels_max <= 2 && chans && chans <= 16) in simple_playback_build_pcms()
3101 pstr->channels_max = chans; in simple_playback_build_pcms()
3107 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
3110 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
3111 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
3115 * as long as spec->pins[] is set correctly
3119 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
3121 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3126 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3127 per_cvt->cvt_nid, in simple_playback_build_controls()
3131 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
3134 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
3136 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3138 hda_nid_t pin = per_pin->pin_nid; in simple_playback_init()
3140 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
3143 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
3144 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
3146 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3150 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
3152 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3211 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3213 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3217 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3219 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3244 struct hda_codec *codec, in simple_playback_pcm_open() argument
3247 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3250 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3265 snd_pcm_hw_constraint_list(substream->runtime, 0, in simple_playback_pcm_open()
3269 snd_pcm_hw_constraint_step(substream->runtime, 0, in simple_playback_pcm_open()
3273 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3277 struct hda_codec *codec, in simple_playback_pcm_close() argument
3280 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3281 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3285 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3290 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3291 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3296 .substreams = 1,
3314 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3323 return -ENOMEM; in patch_simple_hdmi()
3325 spec->codec = codec; in patch_simple_hdmi()
3326 codec->spec = spec; in patch_simple_hdmi()
3327 hdmi_array_init(spec, 1); in patch_simple_hdmi()
3329 spec->multiout.num_dacs = 0; /* no analog */ in patch_simple_hdmi()
3330 spec->multiout.max_channels = 2; in patch_simple_hdmi()
3331 spec->multiout.dig_out_nid = cvt_nid; in patch_simple_hdmi()
3332 spec->num_cvts = 1; in patch_simple_hdmi()
3333 spec->num_pins = 1; in patch_simple_hdmi()
3334 per_pin = snd_array_new(&spec->pins); in patch_simple_hdmi()
3335 per_cvt = snd_array_new(&spec->cvts); in patch_simple_hdmi()
3337 simple_playback_free(codec); in patch_simple_hdmi()
3338 return -ENOMEM; in patch_simple_hdmi()
3340 per_cvt->cvt_nid = cvt_nid; in patch_simple_hdmi()
3341 per_pin->pin_nid = pin_nid; in patch_simple_hdmi()
3342 spec->pcm_playback = simple_pcm_playback; in patch_simple_hdmi()
3344 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3349 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3353 int chan = channels ? (channels - 1) : 1; in nvhdmi_8ch_7x_set_info_frame_parameters()
3374 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3377 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3379 (0x71 - chan - chanmask)); in nvhdmi_8ch_7x_set_info_frame_parameters()
3383 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3386 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3389 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3393 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3396 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3402 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3404 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3408 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3416 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3420 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3422 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3424 chs = substream->runtime->channels; in nvhdmi_8ch_7x_pcm_prepare()
3429 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3430 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3434 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3437 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3441 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3446 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3447 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3451 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3452 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3467 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3468 (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3469 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3473 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3475 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3481 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3488 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3489 (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3490 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3494 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3495 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3502 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3504 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3509 .substreams = 1,
3523 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3526 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3531 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3532 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3533 spec = codec->spec; in patch_nvhdmi_2ch()
3534 spec->pcm_playback.rates = SUPPORTED_RATES; in patch_nvhdmi_2ch()
3535 spec->pcm_playback.maxbps = SUPPORTED_MAXBPS; in patch_nvhdmi_2ch()
3536 spec->pcm_playback.formats = SUPPORTED_FORMATS; in patch_nvhdmi_2ch()
3537 spec->nv_dp_workaround = true; in patch_nvhdmi_2ch()
3541 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3543 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3544 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3547 info->own_chmap = true; in nvhdmi_7x_8ch_build_pcms()
3552 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3554 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3559 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3565 err = snd_pcm_add_chmap_ctls(info->pcm, in nvhdmi_7x_8ch_build_controls()
3570 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3575 chmap->channel_mask = (1U << 2) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3578 chmap->channel_mask = (1U << 2) | (1U << 6) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3583 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3586 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3589 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3590 spec->multiout.max_channels = 8; in patch_nvhdmi_8ch_7x()
3591 spec->pcm_playback = nvhdmi_pcm_playback_8ch_7x; in patch_nvhdmi_8ch_7x()
3592 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3593 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3594 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3598 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3604 * NVIDIA codecs ignore ASP mapping for 2ch - confirmed on:
3605 * - 0x10de0015
3606 * - 0x10de0040
3611 if (cap->ca_index == 0x00 && channels == 2) in nvhdmi_chmap_cea_alloc_validate_get_type()
3615 if (cap->channels != channels) in nvhdmi_chmap_cea_alloc_validate_get_type()
3616 return -1; in nvhdmi_chmap_cea_alloc_validate_get_type()
3625 if (ca == 0x00 && (map[0] != SNDRV_CHMAP_FL || map[1] != SNDRV_CHMAP_FR)) in nvhdmi_chmap_validate()
3626 return -EINVAL; in nvhdmi_chmap_validate()
3631 /* map from pin NID to port; port is 0-based */
3632 /* for Nvidia: assume widget NID starting from 4, with step 1 (4, 5, 6, ...) */
3635 return pin_nid - 4; in nvhdmi_pin2port()
3638 /* reverse-map from port to pin NID: see above */
3639 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3651 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3656 err = alloc_generic_hdmi(codec); in patch_nvhdmi()
3659 codec->dp_mst = true; in patch_nvhdmi()
3661 spec = codec->spec; in patch_nvhdmi()
3662 spec->dyn_pcm_assign = true; in patch_nvhdmi()
3664 err = hdmi_parse_codec(codec); in patch_nvhdmi()
3666 generic_spec_free(codec); in patch_nvhdmi()
3670 generic_hdmi_init_per_pins(codec); in patch_nvhdmi()
3672 spec->dyn_pin_out = true; in patch_nvhdmi()
3674 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi()
3676 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi()
3677 spec->nv_dp_workaround = true; in patch_nvhdmi()
3679 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3681 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3686 static int patch_nvhdmi_legacy(struct hda_codec *codec) in patch_nvhdmi_legacy() argument
3691 err = patch_generic_hdmi(codec); in patch_nvhdmi_legacy()
3695 spec = codec->spec; in patch_nvhdmi_legacy()
3696 spec->dyn_pin_out = true; in patch_nvhdmi_legacy()
3698 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi_legacy()
3700 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi_legacy()
3701 spec->nv_dp_workaround = true; in patch_nvhdmi_legacy()
3703 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3709 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3710 * accessed using vendor-defined verbs. These registers can be used for
3718 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3720 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3725 * +---------+-------+--------+--------+
3727 * +-----------------------------------|
3737 #define NVIDIA_SCRATCH_TRIGGER (1 << 7)
3738 #define NVIDIA_SCRATCH_VALID (1 << 6)
3748 * the format is invalidated so that the HDMI codec can be disabled.
3750 static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) in tegra_hdmi_set_format() argument
3755 value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3760 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3763 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3768 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3782 * HDMI codec. The HDMI driver will use that as trigger to update its in tegra_hdmi_set_format()
3787 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3792 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3799 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3804 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3805 tegra_hdmi_set_format(codec, format); in tegra_hdmi_pcm_prepare()
3811 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3814 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3815 tegra_hdmi_set_format(codec, 0); in tegra_hdmi_pcm_cleanup()
3817 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3820 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3822 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3825 for (i = 0; i < spec->num_pins; i++) { in hda_find_pcm_by_type()
3828 if (pcm->pcm_type == type) in hda_find_pcm_by_type()
3835 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3841 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3845 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3847 return -ENODEV; in tegra_hdmi_build_pcms()
3850 * Override ->prepare() and ->cleanup() operations to notify the HDMI in tegra_hdmi_build_pcms()
3851 * codec about format changes. in tegra_hdmi_build_pcms()
3853 stream = &pcm->stream[SNDRV_PCM_STREAM_PLAYBACK]; in tegra_hdmi_build_pcms()
3854 stream->ops.prepare = tegra_hdmi_pcm_prepare; in tegra_hdmi_build_pcms()
3855 stream->ops.cleanup = tegra_hdmi_pcm_cleanup; in tegra_hdmi_build_pcms()
3860 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3865 err = patch_generic_hdmi(codec); in patch_tegra_hdmi()
3869 codec->depop_delay = 10; in patch_tegra_hdmi()
3870 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in patch_tegra_hdmi()
3871 spec = codec->spec; in patch_tegra_hdmi()
3872 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_tegra_hdmi()
3874 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_tegra_hdmi()
3875 spec->nv_dp_workaround = true; in patch_tegra_hdmi()
3881 * ATI/AMD-specific implementations
3884 #define is_amdhdmi_rev3_or_later(codec) \ argument
3885 ((codec)->core.vendor_id == 0x1002aa01 && \
3886 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3887 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3922 #define ATI_MULTICHANNEL_MODE_SINGLE 1
3927 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3931 /* call hda_eld.c ATI/AMD-specific function */ in atihdmi_pin_get_eld()
3932 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
3933 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
3936 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, in atihdmi_pin_setup_infoframe() argument
3941 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3947 * ATI/AMD have automatic FC/LFE swap built-in in atihdmi_paired_swap_fc_lfe()
3967 /* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */ in atihdmi_paired_chmap_validate()
3979 int chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j); in atihdmi_paired_chmap_validate()
3980 if (cap->speakers[chan_idx] == mask) { in atihdmi_paired_chmap_validate()
3984 if (i % 2 == 0 && i + 1 < chs) { in atihdmi_paired_chmap_validate()
3986 int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1); in atihdmi_paired_chmap_validate()
3987 int comp_mask_req = snd_hdac_chmap_to_spk_mask(map[i+1]); in atihdmi_paired_chmap_validate()
3988 int comp_mask_act = cap->speakers[comp_chan_idx]; in atihdmi_paired_chmap_validate()
3993 return -EINVAL; in atihdmi_paired_chmap_validate()
4000 return -EINVAL; in atihdmi_paired_chmap_validate()
4012 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_set_slot_channel() local
4017 return -EINVAL; in atihdmi_pin_set_slot_channel()
4019 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
4029 hdmi_slot -= hdmi_slot % 2; in atihdmi_pin_set_slot_channel()
4032 stream_channel -= stream_channel % 2; in atihdmi_pin_set_slot_channel()
4037 /* ati_channel_setup format: [7..4] = stream_channel_id, [1] = mute, [0] = enable */ in atihdmi_pin_set_slot_channel()
4042 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
4048 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_get_slot_channel() local
4055 return -EINVAL; in atihdmi_pin_get_slot_channel()
4057 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
4060 ati_asp_slot -= 1; in atihdmi_pin_get_slot_channel()
4067 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
4083 * Pre-rev3 ATI/AMD codecs operate in a paired channel mode, so in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4090 /* We only produce even-numbered channel count TLVs */ in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4092 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4095 if (cap->speakers[c] || cap->speakers[c+1]) in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4100 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4109 /* produce paired maps for pre-rev3 ATI/AMD codecs */ in atihdmi_paired_cea_alloc_to_tlv_chmap()
4113 for (c = 7; c >= 0; c--) { in atihdmi_paired_cea_alloc_to_tlv_chmap()
4114 int chan = 7 - atihdmi_paired_swap_fc_lfe(7 - c); in atihdmi_paired_cea_alloc_to_tlv_chmap()
4115 int spk = cap->speakers[chan]; in atihdmi_paired_cea_alloc_to_tlv_chmap()
4118 if (cap->speakers[chan + (chan % 2 ? -1 : 1)]) in atihdmi_paired_cea_alloc_to_tlv_chmap()
4130 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
4137 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
4144 codec_dbg(codec, in atihdmi_pin_hbr_setup()
4145 "atihdmi_pin_hbr_setup: NID=0x%x, %shbr-ctl=0x%x\n", in atihdmi_pin_hbr_setup()
4147 hbr_ctl == hbr_ctl_new ? "" : "new-", in atihdmi_pin_hbr_setup()
4151 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
4156 return -EINVAL; in atihdmi_pin_hbr_setup()
4161 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
4165 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
4167 /* disable ramp-up/down for non-pcm as per AMD spec */ in atihdmi_setup_stream()
4171 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
4174 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in atihdmi_setup_stream()
4179 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
4181 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4184 err = generic_hdmi_init(codec); in atihdmi_init()
4189 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in atihdmi_init()
4193 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4195 /* enable channel-wise remap mode if supported */ in atihdmi_init()
4196 if (has_amd_full_remap_support(codec)) in atihdmi_init()
4197 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4201 codec->auto_runtime_pm = 1; in atihdmi_init()
4206 /* map from pin NID to port; port is 0-based */
4210 return pin_nid / 2 - 1; in atihdmi_pin2port()
4213 /* reverse-map from port to pin NID: see above */
4214 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4226 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4232 err = patch_generic_hdmi(codec); in patch_atihdmi()
4237 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4239 spec = codec->spec; in patch_atihdmi()
4241 spec->ops.pin_get_eld = atihdmi_pin_get_eld; in patch_atihdmi()
4242 spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe; in patch_atihdmi()
4243 spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup; in patch_atihdmi()
4244 spec->ops.setup_stream = atihdmi_setup_stream; in patch_atihdmi()
4246 spec->chmap.ops.pin_get_slot_channel = atihdmi_pin_get_slot_channel; in patch_atihdmi()
4247 spec->chmap.ops.pin_set_slot_channel = atihdmi_pin_set_slot_channel; in patch_atihdmi()
4249 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4250 /* override to ATI/AMD-specific versions with pairwise mapping */ in patch_atihdmi()
4251 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_atihdmi()
4253 spec->chmap.ops.cea_alloc_to_tlv_chmap = in patch_atihdmi()
4255 spec->chmap.ops.chmap_validate = atihdmi_paired_chmap_validate; in patch_atihdmi()
4259 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in patch_atihdmi()
4261 per_cvt->channels_max = max(per_cvt->channels_max, 8u); in patch_atihdmi()
4262 per_cvt->rates |= SUPPORTED_RATES; in patch_atihdmi()
4263 per_cvt->formats |= SUPPORTED_FORMATS; in patch_atihdmi()
4264 per_cvt->maxbps = max(per_cvt->maxbps, 24u); in patch_atihdmi()
4267 spec->chmap.channels_max = max(spec->chmap.channels_max, 8u); in patch_atihdmi()
4270 * the link-down as is. Tell the core to allow it. in patch_atihdmi()
4272 codec->link_down_at_suspend = 1; in patch_atihdmi()
4274 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4283 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4285 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4322 HDA_CODEC_ENTRY(0x10de001a, "GPU 1a HDMI/DP", patch_nvhdmi_legacy),
4323 HDA_CODEC_ENTRY(0x10de001b, "GPU 1b HDMI/DP", patch_nvhdmi_legacy),
4324 HDA_CODEC_ENTRY(0x10de001c, "GPU 1c HDMI/DP", patch_nvhdmi_legacy),
4404 HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi),
4416 MODULE_DESCRIPTION("HDMI HD-audio codec");
4417 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4418 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4419 MODULE_ALIAS("snd-hda-codec-atihdmi");