• Home
  • Raw
  • Download

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.
160 bool intel_hsw_fixup; /* apply Intel platform-specific fixups */
162 * Non-generic VIA/NVIDIA specific
181 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
183 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
184 return spec->use_acomp_notifier; in codec_has_acomp()
187 #define codec_has_acomp(codec) false argument
227 ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx))
229 ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx))
231 #define get_hdmi_pcm(spec, idx) (&(spec)->pcm_rec[idx])
233 #define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm)
235 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
238 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
243 * (dev_id == -1) means it is NON-MST pin in pin_id_to_pin_index()
246 if (dev_id == -1) in pin_id_to_pin_index()
249 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in pin_id_to_pin_index()
251 if ((per_pin->pin_nid == pin_nid) && in pin_id_to_pin_index()
252 (per_pin->dev_id == dev_id)) in pin_id_to_pin_index()
256 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid); in pin_id_to_pin_index()
257 return -EINVAL; in pin_id_to_pin_index()
260 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
263 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
266 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) in hinfo_to_pcm_index()
267 if (get_pcm_rec(spec, pcm_idx)->stream == hinfo) in hinfo_to_pcm_index()
270 codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo); in hinfo_to_pcm_index()
271 return -EINVAL; in hinfo_to_pcm_index()
274 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
277 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
281 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in hinfo_to_pin_index()
283 if (per_pin->pcm && in hinfo_to_pin_index()
284 per_pin->pcm->pcm->stream == hinfo) in hinfo_to_pin_index()
288 codec_dbg(codec, "HDMI: hinfo %p (pcm %d) not registered\n", hinfo, in hinfo_to_pin_index()
289 hinfo_to_pcm_index(codec, hinfo)); in hinfo_to_pin_index()
290 return -EINVAL; in hinfo_to_pin_index()
299 for (i = 0; i < spec->num_pins; i++) { in pcm_idx_to_pin()
301 if (per_pin->pcm_idx == pcm_idx) in pcm_idx_to_pin()
307 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
309 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
312 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) in cvt_nid_to_cvt_index()
313 if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid) in cvt_nid_to_cvt_index()
316 codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
317 return -EINVAL; in cvt_nid_to_cvt_index()
323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
324 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
329 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdmi_eld_ctl_info()
331 pcm_idx = kcontrol->private_value; in hdmi_eld_ctl_info()
332 mutex_lock(&spec->pcm_lock); in hdmi_eld_ctl_info()
336 uinfo->count = 0; in hdmi_eld_ctl_info()
339 eld = &per_pin->sink_eld; in hdmi_eld_ctl_info()
340 uinfo->count = eld->eld_valid ? eld->eld_size : 0; in hdmi_eld_ctl_info()
343 mutex_unlock(&spec->pcm_lock); in hdmi_eld_ctl_info()
350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
351 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
357 pcm_idx = kcontrol->private_value; in hdmi_eld_ctl_get()
358 mutex_lock(&spec->pcm_lock); in hdmi_eld_ctl_get()
362 memset(ucontrol->value.bytes.data, 0, in hdmi_eld_ctl_get()
363 ARRAY_SIZE(ucontrol->value.bytes.data)); in hdmi_eld_ctl_get()
367 eld = &per_pin->sink_eld; in hdmi_eld_ctl_get()
368 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) || in hdmi_eld_ctl_get()
369 eld->eld_size > ELD_MAX_SIZE) { in hdmi_eld_ctl_get()
371 err = -EINVAL; in hdmi_eld_ctl_get()
375 memset(ucontrol->value.bytes.data, 0, in hdmi_eld_ctl_get()
376 ARRAY_SIZE(ucontrol->value.bytes.data)); in hdmi_eld_ctl_get()
377 if (eld->eld_valid) in hdmi_eld_ctl_get()
378 memcpy(ucontrol->value.bytes.data, eld->eld_buffer, in hdmi_eld_ctl_get()
379 eld->eld_size); in hdmi_eld_ctl_get()
382 mutex_unlock(&spec->pcm_lock); in hdmi_eld_ctl_get()
395 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
399 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
402 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
404 return -ENOMEM; in hdmi_create_eld_ctl()
405 kctl->private_value = pcm_idx; in hdmi_create_eld_ctl()
406 kctl->id.device = device; in hdmi_create_eld_ctl()
411 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
415 get_hdmi_pcm(spec, pcm_idx)->eld_ctl = kctl; in hdmi_create_eld_ctl()
420 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
425 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
433 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
440 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
443 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
446 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
449 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
451 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
455 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
456 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
459 if (spec->dyn_pin_out) in hdmi_init_pin()
468 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
480 struct hdmi_spec_per_pin *per_pin = entry->private_data; in print_eld_info()
482 mutex_lock(&per_pin->lock); in print_eld_info()
483 snd_hdmi_print_eld_info(&per_pin->sink_eld, buffer); in print_eld_info()
484 mutex_unlock(&per_pin->lock); in print_eld_info()
490 struct hdmi_spec_per_pin *per_pin = entry->private_data; in write_eld_info()
492 mutex_lock(&per_pin->lock); in write_eld_info()
493 snd_hdmi_write_eld_info(&per_pin->sink_eld, buffer); in write_eld_info()
494 mutex_unlock(&per_pin->lock); in write_eld_info()
500 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
504 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
505 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
510 entry->c.text.write = write_eld_info; in eld_proc_new()
511 entry->mode |= 0200; in eld_proc_new()
512 per_pin->proc_entry = entry; in eld_proc_new()
519 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
520 snd_info_free_entry(per_pin->proc_entry); in eld_proc_free()
521 per_pin->proc_entry = NULL; in eld_proc_free()
542 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
545 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
546 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
553 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
556 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
557 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
561 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
567 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
568 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
571 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
573 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
578 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
585 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
590 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
591 for (j = 1; j < 1000; j++) { in hdmi_clear_dip_buffers()
592 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
593 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
595 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
600 codec_dbg(codec, in hdmi_clear_dip_buffers()
613 hdmi_ai->checksum = 0; in hdmi_checksum_audio_infoframe()
618 hdmi_ai->checksum = -sum; in hdmi_checksum_audio_infoframe()
621 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
627 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
628 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
630 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
632 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
635 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
641 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
645 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
647 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
656 static int hdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in hdmi_pin_get_eld() argument
659 snd_hda_set_dev_select(codec, nid, dev_id); in hdmi_pin_get_eld()
661 return snd_hdmi_get_eld(codec, nid, buf, eld_size); in hdmi_pin_get_eld()
664 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
675 hdmi_ai->type = 0x84; in hdmi_pin_setup_infoframe()
676 hdmi_ai->ver = 0x01; in hdmi_pin_setup_infoframe()
677 hdmi_ai->len = 0x0a; in hdmi_pin_setup_infoframe()
678 hdmi_ai->CC02_CT47 = active_channels - 1; in hdmi_pin_setup_infoframe()
679 hdmi_ai->CA = ca; in hdmi_pin_setup_infoframe()
681 } else if (conn_type == 1) { /* DisplayPort */ in hdmi_pin_setup_infoframe()
684 dp_ai->type = 0x84; in hdmi_pin_setup_infoframe()
685 dp_ai->len = 0x1b; in hdmi_pin_setup_infoframe()
686 dp_ai->ver = 0x11 << 2; in hdmi_pin_setup_infoframe()
687 dp_ai->CC02_CT47 = active_channels - 1; in hdmi_pin_setup_infoframe()
688 dp_ai->CA = ca; in hdmi_pin_setup_infoframe()
690 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n", in hdmi_pin_setup_infoframe()
695 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_setup_infoframe()
702 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
704 codec_dbg(codec, in hdmi_pin_setup_infoframe()
708 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
709 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
711 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
715 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
719 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
720 struct hdac_chmap *chmap = &spec->chmap; in hdmi_setup_audio_infoframe()
721 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_setup_audio_infoframe()
722 int dev_id = per_pin->dev_id; in hdmi_setup_audio_infoframe()
723 int channels = per_pin->channels; in hdmi_setup_audio_infoframe()
731 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_setup_audio_infoframe()
734 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
735 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
739 eld = &per_pin->sink_eld; in hdmi_setup_audio_infoframe()
741 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
742 eld->info.spk_alloc, channels, in hdmi_setup_audio_infoframe()
743 per_pin->chmap_set, non_pcm, per_pin->chmap); in hdmi_setup_audio_infoframe()
747 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
754 snd_hdac_setup_channel_mapping(&spec->chmap, in hdmi_setup_audio_infoframe()
756 per_pin->chmap, per_pin->chmap_set); in hdmi_setup_audio_infoframe()
758 spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id, in hdmi_setup_audio_infoframe()
759 ca, active_channels, eld->info.conn_type); in hdmi_setup_audio_infoframe()
761 per_pin->non_pcm = non_pcm; in hdmi_setup_audio_infoframe()
770 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
773 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
774 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
778 mutex_lock(&spec->pcm_lock); in check_presence_and_report()
779 hdmi_present_sense(get_pin(spec, pin_idx), 1); in check_presence_and_report()
780 mutex_unlock(&spec->pcm_lock); in check_presence_and_report()
783 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
787 if (codec_has_acomp(codec)) in jack_callback()
790 check_presence_and_report(codec, jack->nid, jack->dev_id); in jack_callback()
793 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res, in hdmi_intrinsic_event() argument
796 jack->jack_dirty = 1; in hdmi_intrinsic_event()
798 codec_dbg(codec, in hdmi_intrinsic_event()
799 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_intrinsic_event()
800 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
803 check_presence_and_report(codec, jack->nid, jack->dev_id); in hdmi_intrinsic_event()
806 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
813 codec_info(codec, in hdmi_non_intrinsic_event()
814 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", in hdmi_non_intrinsic_event()
815 codec->addr, in hdmi_non_intrinsic_event()
831 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
837 if (codec_has_acomp(codec)) in hdmi_unsol_event()
840 if (codec->dp_mst) { in hdmi_unsol_event()
844 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in hdmi_unsol_event()
846 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in hdmi_unsol_event()
850 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
855 hdmi_intrinsic_event(codec, res, jack); in hdmi_unsol_event()
857 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
860 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
865 /* For Haswell, the converter 1/2 may keep in D3 state after bootup, in haswell_verify_D0()
868 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
869 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
871 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
872 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
875 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
877 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
885 /* HBR should be Non-PCM, 8 channels */
889 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
894 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
895 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_hbr_setup()
896 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
900 return hbr ? -EINVAL : 0; in hdmi_pin_hbr_setup()
908 codec_dbg(codec, in hdmi_pin_hbr_setup()
911 pinctl == new_pinctl ? "" : "new-", in hdmi_pin_hbr_setup()
915 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
919 return -EINVAL; in hdmi_pin_hbr_setup()
924 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
928 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
932 err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id, in hdmi_setup_stream()
936 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
940 if (spec->intel_hsw_fixup) { in hdmi_setup_stream()
947 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
956 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
960 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
969 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
972 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
983 if (per_pin && per_pin->silent_stream) { in hdmi_choose_cvt()
984 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in hdmi_choose_cvt()
991 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in hdmi_choose_cvt()
995 if (per_cvt->assigned) in hdmi_choose_cvt()
1000 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++) in hdmi_choose_cvt()
1001 if (per_pin->mux_nids[mux_idx] == per_cvt->cvt_nid) in hdmi_choose_cvt()
1004 if (mux_idx == per_pin->num_mux_nids) in hdmi_choose_cvt()
1010 if (cvt_idx == spec->num_cvts) in hdmi_choose_cvt()
1011 return -EBUSY; in hdmi_choose_cvt()
1014 per_pin->mux_idx = mux_idx; in hdmi_choose_cvt()
1023 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1026 hda_nid_t pin_nid = per_pin->pin_nid; in intel_verify_pin_cvt_connect()
1029 mux_idx = per_pin->mux_idx; in intel_verify_pin_cvt_connect()
1030 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1033 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1046 for (i = 0; i < spec->num_cvts; i++) in intel_cvt_id_to_mux_idx()
1047 if (spec->cvt_nids[i] == cvt_nid) in intel_cvt_id_to_mux_idx()
1049 return -EINVAL; in intel_cvt_id_to_mux_idx()
1061 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1065 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1073 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in intel_not_share_assigned_cvt()
1082 if (!per_pin->pcm) in intel_not_share_assigned_cvt()
1085 if ((per_pin->pin_nid == pin_nid) && in intel_not_share_assigned_cvt()
1086 (per_pin->dev_id == dev_id)) in intel_not_share_assigned_cvt()
1090 * if per_pin->dev_id >= dev_num, in intel_not_share_assigned_cvt()
1095 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1096 if (per_pin->dev_id >= dev_num) in intel_not_share_assigned_cvt()
1099 nid = per_pin->pin_nid; in intel_not_share_assigned_cvt()
1107 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1108 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1109 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1112 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1118 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
1120 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in intel_not_share_assigned_cvt()
1122 if (!per_cvt->assigned) { in intel_not_share_assigned_cvt()
1123 codec_dbg(codec, in intel_not_share_assigned_cvt()
1126 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1132 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1137 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1141 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1150 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1154 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1158 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1160 if (spec->ops.pin_cvt_fixup) in pin_cvt_fixup()
1161 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1168 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1171 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1172 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_pcm_open_no_pin()
1177 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1179 return -EINVAL; in hdmi_pcm_open_no_pin()
1181 err = hdmi_choose_cvt(codec, -1, &cvt_idx); in hdmi_pcm_open_no_pin()
1186 per_cvt->assigned = 1; in hdmi_pcm_open_no_pin()
1187 hinfo->nid = per_cvt->cvt_nid; in hdmi_pcm_open_no_pin()
1189 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1191 set_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_open_no_pin()
1195 hinfo->channels_min = per_cvt->channels_min; in hdmi_pcm_open_no_pin()
1196 hinfo->channels_max = per_cvt->channels_max; in hdmi_pcm_open_no_pin()
1197 hinfo->rates = per_cvt->rates; in hdmi_pcm_open_no_pin()
1198 hinfo->formats = per_cvt->formats; in hdmi_pcm_open_no_pin()
1199 hinfo->maxbps = per_cvt->maxbps; in hdmi_pcm_open_no_pin()
1202 runtime->hw.channels_min = hinfo->channels_min; in hdmi_pcm_open_no_pin()
1203 runtime->hw.channels_max = hinfo->channels_max; in hdmi_pcm_open_no_pin()
1204 runtime->hw.formats = hinfo->formats; in hdmi_pcm_open_no_pin()
1205 runtime->hw.rates = hinfo->rates; in hdmi_pcm_open_no_pin()
1207 snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_pcm_open_no_pin()
1216 struct hda_codec *codec, in hdmi_pcm_open() argument
1219 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1220 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_pcm_open()
1228 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1230 return -EINVAL; in hdmi_pcm_open()
1232 mutex_lock(&spec->pcm_lock); in hdmi_pcm_open()
1233 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1234 if (!spec->dyn_pcm_assign) { in hdmi_pcm_open()
1236 err = -EINVAL; in hdmi_pcm_open()
1244 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1249 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in hdmi_pcm_open()
1255 per_cvt->assigned = 1; in hdmi_pcm_open()
1257 set_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_open()
1259 per_pin->cvt_nid = per_cvt->cvt_nid; in hdmi_pcm_open()
1260 hinfo->nid = per_cvt->cvt_nid; in hdmi_pcm_open()
1263 if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE) in hdmi_pcm_open()
1264 azx_stream(get_azx_dev(substream))->stripe = 1; in hdmi_pcm_open()
1266 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1267 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1269 per_pin->mux_idx); in hdmi_pcm_open()
1272 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1274 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1277 hinfo->channels_min = per_cvt->channels_min; in hdmi_pcm_open()
1278 hinfo->channels_max = per_cvt->channels_max; in hdmi_pcm_open()
1279 hinfo->rates = per_cvt->rates; in hdmi_pcm_open()
1280 hinfo->formats = per_cvt->formats; in hdmi_pcm_open()
1281 hinfo->maxbps = per_cvt->maxbps; in hdmi_pcm_open()
1283 eld = &per_pin->sink_eld; in hdmi_pcm_open()
1285 if (!static_hdmi_pcm && eld->eld_valid) { in hdmi_pcm_open()
1286 snd_hdmi_eld_update_pcm_info(&eld->info, hinfo); in hdmi_pcm_open()
1287 if (hinfo->channels_min > hinfo->channels_max || in hdmi_pcm_open()
1288 !hinfo->rates || !hinfo->formats) { in hdmi_pcm_open()
1289 per_cvt->assigned = 0; in hdmi_pcm_open()
1290 hinfo->nid = 0; in hdmi_pcm_open()
1291 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1292 err = -ENODEV; in hdmi_pcm_open()
1298 runtime->hw.channels_min = hinfo->channels_min; in hdmi_pcm_open()
1299 runtime->hw.channels_max = hinfo->channels_max; in hdmi_pcm_open()
1300 runtime->hw.formats = hinfo->formats; in hdmi_pcm_open()
1301 runtime->hw.rates = hinfo->rates; in hdmi_pcm_open()
1303 snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_pcm_open()
1306 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_open()
1313 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1315 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1317 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_read_pin_conn()
1318 int dev_id = per_pin->dev_id; in hdmi_read_pin_conn()
1321 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1322 codec_warn(codec, in hdmi_read_pin_conn()
1324 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1325 return -EINVAL; in hdmi_read_pin_conn()
1328 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_read_pin_conn()
1330 if (spec->intel_hsw_fixup) { in hdmi_read_pin_conn()
1331 conns = spec->num_cvts; in hdmi_read_pin_conn()
1332 memcpy(per_pin->mux_nids, spec->cvt_nids, in hdmi_read_pin_conn()
1335 conns = snd_hda_get_raw_connections(codec, pin_nid, in hdmi_read_pin_conn()
1336 per_pin->mux_nids, in hdmi_read_pin_conn()
1341 per_pin->num_mux_nids = conns; in hdmi_read_pin_conn()
1353 * platforms (with maximum of 'num_nids + dev_num - 1') in hdmi_find_pcm_slot()
1355 * The per_pin of pin_nid_idx=n and dev_id=m prefers to get pcm-n in hdmi_find_pcm_slot()
1357 * with the legacy static per_pin-pcm assignment that existed in the in hdmi_find_pcm_slot()
1358 * days before DP-MST. in hdmi_find_pcm_slot()
1360 * Intel DP-MST prefers this legacy behavior for compatibility, too. in hdmi_find_pcm_slot()
1362 * per_pin of m!=0 prefers to get pcm=(num_nids + (m - 1)). in hdmi_find_pcm_slot()
1365 if (per_pin->dev_id == 0 || spec->intel_hsw_fixup) { in hdmi_find_pcm_slot()
1366 if (!test_bit(per_pin->pin_nid_idx, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1367 return per_pin->pin_nid_idx; in hdmi_find_pcm_slot()
1369 i = spec->num_nids + (per_pin->dev_id - 1); in hdmi_find_pcm_slot()
1370 if (i < spec->pcm_used && !(test_bit(i, &spec->pcm_bitmap))) in hdmi_find_pcm_slot()
1375 for (i = spec->num_nids; i < spec->pcm_used; i++) { in hdmi_find_pcm_slot()
1376 if (!test_bit(i, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1381 for (i = 0; i < spec->num_nids; i++) { in hdmi_find_pcm_slot()
1382 if (!test_bit(i, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1385 return -EBUSY; in hdmi_find_pcm_slot()
1394 if (per_pin->pcm) in hdmi_attach_hda_pcm()
1397 if (idx == -EBUSY) in hdmi_attach_hda_pcm()
1399 per_pin->pcm_idx = idx; in hdmi_attach_hda_pcm()
1400 per_pin->pcm = get_hdmi_pcm(spec, idx); in hdmi_attach_hda_pcm()
1401 set_bit(idx, &spec->pcm_bitmap); in hdmi_attach_hda_pcm()
1410 if (!per_pin->pcm) in hdmi_detach_hda_pcm()
1412 idx = per_pin->pcm_idx; in hdmi_detach_hda_pcm()
1413 per_pin->pcm_idx = -1; in hdmi_detach_hda_pcm()
1414 per_pin->pcm = NULL; in hdmi_detach_hda_pcm()
1415 if (idx >= 0 && idx < spec->pcm_used) in hdmi_detach_hda_pcm()
1416 clear_bit(idx, &spec->pcm_bitmap); in hdmi_detach_hda_pcm()
1424 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++) in hdmi_get_pin_cvt_mux()
1425 if (per_pin->mux_nids[mux_idx] == cvt_nid) in hdmi_get_pin_cvt_mux()
1430 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1435 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1442 if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used) in hdmi_pcm_setup_pin()
1443 pcm = get_pcm_rec(spec, per_pin->pcm_idx); in hdmi_pcm_setup_pin()
1446 if (!pcm->pcm) in hdmi_pcm_setup_pin()
1448 if (!test_bit(per_pin->pcm_idx, &spec->pcm_in_use)) in hdmi_pcm_setup_pin()
1452 hinfo = pcm->stream; in hdmi_pcm_setup_pin()
1453 substream = pcm->pcm->streams[0].substream; in hdmi_pcm_setup_pin()
1455 per_pin->cvt_nid = hinfo->nid; in hdmi_pcm_setup_pin()
1457 mux_idx = hdmi_get_pin_cvt_mux(spec, per_pin, hinfo->nid); in hdmi_pcm_setup_pin()
1458 if (mux_idx < per_pin->num_mux_nids) { in hdmi_pcm_setup_pin()
1459 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1460 per_pin->dev_id); in hdmi_pcm_setup_pin()
1461 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1465 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1467 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1468 if (substream->runtime) in hdmi_pcm_setup_pin()
1469 per_pin->channels = substream->runtime->channels; in hdmi_pcm_setup_pin()
1470 per_pin->setup = true; in hdmi_pcm_setup_pin()
1471 per_pin->mux_idx = mux_idx; in hdmi_pcm_setup_pin()
1473 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1479 if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used) in hdmi_pcm_reset_pin()
1480 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1482 per_pin->chmap_set = false; in hdmi_pcm_reset_pin()
1483 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_reset_pin()
1485 per_pin->setup = false; in hdmi_pcm_reset_pin()
1486 per_pin->channels = 0; in hdmi_pcm_reset_pin()
1489 static struct snd_jack *pin_idx_to_pcm_jack(struct hda_codec *codec, in pin_idx_to_pcm_jack() argument
1492 struct hdmi_spec *spec = codec->spec; in pin_idx_to_pcm_jack()
1494 if (per_pin->pcm_idx >= 0) in pin_idx_to_pcm_jack()
1495 return spec->pcm_rec[per_pin->pcm_idx].jack; in pin_idx_to_pcm_jack()
1504 static void update_eld(struct hda_codec *codec, in update_eld() argument
1509 struct hdmi_eld *pin_eld = &per_pin->sink_eld; in update_eld()
1510 struct hdmi_spec *spec = codec->spec; in update_eld()
1512 bool old_eld_valid = pin_eld->eld_valid; in update_eld()
1516 if (eld->eld_valid) { in update_eld()
1517 if (eld->eld_size <= 0 || in update_eld()
1518 snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in update_eld()
1519 eld->eld_size) < 0) { in update_eld()
1520 eld->eld_valid = false; in update_eld()
1522 schedule_delayed_work(&per_pin->work, in update_eld()
1529 if (!eld->eld_valid || eld->eld_size <= 0) { in update_eld()
1530 eld->eld_valid = false; in update_eld()
1531 eld->eld_size = 0; in update_eld()
1535 pcm_idx = per_pin->pcm_idx; in update_eld()
1541 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1543 if (spec->dyn_pcm_assign) { in update_eld()
1544 if (eld->eld_valid) { in update_eld()
1552 /* if pcm_idx == -1, it means this is in monitor connection event in update_eld()
1555 if (pcm_idx == -1) in update_eld()
1556 pcm_idx = per_pin->pcm_idx; in update_eld()
1558 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1560 if (eld->eld_valid) in update_eld()
1561 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1563 eld_changed = (pin_eld->eld_valid != eld->eld_valid); in update_eld()
1564 eld_changed |= (pin_eld->monitor_present != eld->monitor_present); in update_eld()
1565 if (!eld_changed && eld->eld_valid && pin_eld->eld_valid) in update_eld()
1566 if (pin_eld->eld_size != eld->eld_size || in update_eld()
1567 memcmp(pin_eld->eld_buffer, eld->eld_buffer, in update_eld()
1568 eld->eld_size) != 0) in update_eld()
1572 pin_eld->monitor_present = eld->monitor_present; in update_eld()
1573 pin_eld->eld_valid = eld->eld_valid; in update_eld()
1574 pin_eld->eld_size = eld->eld_size; in update_eld()
1575 if (eld->eld_valid) in update_eld()
1576 memcpy(pin_eld->eld_buffer, eld->eld_buffer, in update_eld()
1577 eld->eld_size); in update_eld()
1578 pin_eld->info = eld->info; in update_eld()
1582 * Re-setup pin and infoframe. This is needed e.g. when in update_eld()
1583 * - sink is first plugged-in in update_eld()
1584 * - transcoder can change during stream playback on Haswell in update_eld()
1587 if (eld->eld_valid && !old_eld_valid && per_pin->setup) { in update_eld()
1588 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1589 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1593 snd_ctl_notify(codec->card, in update_eld()
1596 &get_hdmi_pcm(spec, pcm_idx)->eld_ctl->id); in update_eld()
1600 (eld->monitor_present && eld->eld_valid) ? in update_eld()
1604 /* update ELD and jack state via HD-audio verbs */
1608 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1609 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1610 struct hdmi_eld *eld = &spec->temp_eld; in hdmi_present_sense_via_verbs()
1611 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_present_sense_via_verbs()
1612 int dev_id = per_pin->dev_id; in hdmi_present_sense_via_verbs()
1617 * the real PD value changed. An older version of the HD-audio in hdmi_present_sense_via_verbs()
1624 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense_via_verbs()
1625 if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) in hdmi_present_sense_via_verbs()
1628 present = snd_hda_jack_pin_sense(codec, pin_nid, dev_id); in hdmi_present_sense_via_verbs()
1630 mutex_lock(&per_pin->lock); in hdmi_present_sense_via_verbs()
1631 eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); in hdmi_present_sense_via_verbs()
1632 if (eld->monitor_present) in hdmi_present_sense_via_verbs()
1633 eld->eld_valid = !!(present & AC_PINSENSE_ELDV); in hdmi_present_sense_via_verbs()
1635 eld->eld_valid = false; in hdmi_present_sense_via_verbs()
1637 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1638 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_present_sense_via_verbs()
1639 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1641 if (eld->eld_valid) { in hdmi_present_sense_via_verbs()
1642 if (spec->ops.pin_get_eld(codec, pin_nid, dev_id, in hdmi_present_sense_via_verbs()
1643 eld->eld_buffer, &eld->eld_size) < 0) in hdmi_present_sense_via_verbs()
1644 eld->eld_valid = false; in hdmi_present_sense_via_verbs()
1647 update_eld(codec, per_pin, eld, repoll); in hdmi_present_sense_via_verbs()
1648 mutex_unlock(&per_pin->lock); in hdmi_present_sense_via_verbs()
1650 snd_hda_power_down_pm(codec); in hdmi_present_sense_via_verbs()
1659 static void silent_stream_enable(struct hda_codec *codec, in silent_stream_enable() argument
1662 struct hdmi_spec *spec = codec->spec; in silent_stream_enable()
1667 mutex_lock(&per_pin->lock); in silent_stream_enable()
1669 if (per_pin->setup) { in silent_stream_enable()
1670 codec_dbg(codec, "hdmi: PCM already open, no silent stream\n"); in silent_stream_enable()
1674 pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1675 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in silent_stream_enable()
1677 codec_err(codec, "hdmi: no free converter to enable silent mode\n"); in silent_stream_enable()
1682 per_cvt->assigned = 1; in silent_stream_enable()
1683 per_pin->cvt_nid = per_cvt->cvt_nid; in silent_stream_enable()
1684 per_pin->silent_stream = true; in silent_stream_enable()
1686 codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_enable()
1687 per_pin->pin_nid, per_cvt->cvt_nid); in silent_stream_enable()
1689 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1690 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1692 per_pin->mux_idx); in silent_stream_enable()
1695 pin_cvt_fixup(codec, per_pin, 0); in silent_stream_enable()
1697 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in silent_stream_enable()
1698 per_pin->dev_id, I915_SILENT_RATE); in silent_stream_enable()
1703 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, in silent_stream_enable()
1706 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format); in silent_stream_enable()
1708 per_pin->channels = I915_SILENT_CHANNELS; in silent_stream_enable()
1709 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable()
1712 mutex_unlock(&per_pin->lock); in silent_stream_enable()
1715 static void silent_stream_disable(struct hda_codec *codec, in silent_stream_disable() argument
1718 struct hdmi_spec *spec = codec->spec; in silent_stream_disable()
1722 mutex_lock(&per_pin->lock); in silent_stream_disable()
1723 if (!per_pin->silent_stream) in silent_stream_disable()
1726 codec_dbg(codec, "HDMI: disable silent stream on pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_disable()
1727 per_pin->pin_nid, per_pin->cvt_nid); in silent_stream_disable()
1729 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in silent_stream_disable()
1730 if (cvt_idx >= 0 && cvt_idx < spec->num_cvts) { in silent_stream_disable()
1732 per_cvt->assigned = 0; in silent_stream_disable()
1735 per_pin->cvt_nid = 0; in silent_stream_disable()
1736 per_pin->silent_stream = false; in silent_stream_disable()
1739 mutex_unlock(&per_pin->lock); in silent_stream_disable()
1743 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1746 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1747 struct hdmi_eld *eld = &spec->temp_eld; in sync_eld_via_acomp()
1750 mutex_lock(&per_pin->lock); in sync_eld_via_acomp()
1751 eld->monitor_present = false; in sync_eld_via_acomp()
1752 monitor_prev = per_pin->sink_eld.monitor_present; in sync_eld_via_acomp()
1753 eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1754 per_pin->dev_id, &eld->monitor_present, in sync_eld_via_acomp()
1755 eld->eld_buffer, ELD_MAX_SIZE); in sync_eld_via_acomp()
1756 eld->eld_valid = (eld->eld_size > 0); in sync_eld_via_acomp()
1757 update_eld(codec, per_pin, eld, 0); in sync_eld_via_acomp()
1758 monitor_next = per_pin->sink_eld.monitor_present; in sync_eld_via_acomp()
1759 mutex_unlock(&per_pin->lock); in sync_eld_via_acomp()
1762 * Power-up will call hdmi_present_sense, so the PM calls in sync_eld_via_acomp()
1766 if (spec->send_silent_stream) { in sync_eld_via_acomp()
1770 pm_ret = snd_hda_power_up_pm(codec); in sync_eld_via_acomp()
1772 codec_err(codec, in sync_eld_via_acomp()
1773 "Monitor plugged-in, Failed to power up codec ret=[%d]\n", in sync_eld_via_acomp()
1775 silent_stream_enable(codec, per_pin); in sync_eld_via_acomp()
1777 silent_stream_disable(codec, per_pin); in sync_eld_via_acomp()
1778 pm_ret = snd_hda_power_down_pm(codec); in sync_eld_via_acomp()
1780 codec_err(codec, in sync_eld_via_acomp()
1781 "Monitor plugged-out, Failed to power down codec ret=[%d]\n", in sync_eld_via_acomp()
1789 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1791 if (!codec_has_acomp(codec)) in hdmi_present_sense()
1794 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1801 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1802 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1805 jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, in hdmi_repoll_eld()
1806 per_pin->dev_id); in hdmi_repoll_eld()
1808 jack->jack_dirty = 1; in hdmi_repoll_eld()
1810 if (per_pin->repoll_count++ > 6) in hdmi_repoll_eld()
1811 per_pin->repoll_count = 0; in hdmi_repoll_eld()
1813 mutex_lock(&spec->pcm_lock); in hdmi_repoll_eld()
1814 hdmi_present_sense(per_pin, per_pin->repoll_count); in hdmi_repoll_eld()
1815 mutex_unlock(&spec->pcm_lock); in hdmi_repoll_eld()
1818 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1820 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1827 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1835 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1837 !spec->force_connect) in hdmi_add_pin()
1844 if (spec->intel_hsw_fixup) { in hdmi_add_pin()
1849 * Otherwise, it is 1. in hdmi_add_pin()
1855 spec->dev_num = 3; in hdmi_add_pin()
1856 } else if (spec->dyn_pcm_assign && codec->dp_mst) { in hdmi_add_pin()
1857 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1859 * spec->dev_num is the maxinum number of device entries in hdmi_add_pin()
1862 spec->dev_num = (spec->dev_num > dev_num) ? in hdmi_add_pin()
1863 spec->dev_num : dev_num; in hdmi_add_pin()
1867 * manually set dev_num to 1. This means in hdmi_add_pin()
1870 dev_num = 1; in hdmi_add_pin()
1871 spec->dev_num = 1; in hdmi_add_pin()
1875 pin_idx = spec->num_pins; in hdmi_add_pin()
1876 per_pin = snd_array_new(&spec->pins); in hdmi_add_pin()
1879 return -ENOMEM; in hdmi_add_pin()
1881 if (spec->dyn_pcm_assign) { in hdmi_add_pin()
1882 per_pin->pcm = NULL; in hdmi_add_pin()
1883 per_pin->pcm_idx = -1; in hdmi_add_pin()
1885 per_pin->pcm = get_hdmi_pcm(spec, pin_idx); in hdmi_add_pin()
1886 per_pin->pcm_idx = pin_idx; in hdmi_add_pin()
1888 per_pin->pin_nid = pin_nid; in hdmi_add_pin()
1889 per_pin->pin_nid_idx = spec->num_nids; in hdmi_add_pin()
1890 per_pin->dev_id = i; in hdmi_add_pin()
1891 per_pin->non_pcm = false; in hdmi_add_pin()
1892 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1893 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1896 spec->num_pins++; in hdmi_add_pin()
1898 spec->num_nids++; in hdmi_add_pin()
1903 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1905 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1910 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1913 per_cvt = snd_array_new(&spec->cvts); in hdmi_add_cvt()
1915 return -ENOMEM; in hdmi_add_cvt()
1917 per_cvt->cvt_nid = cvt_nid; in hdmi_add_cvt()
1918 per_cvt->channels_min = 2; in hdmi_add_cvt()
1920 per_cvt->channels_max = chans; in hdmi_add_cvt()
1921 if (chans > spec->chmap.channels_max) in hdmi_add_cvt()
1922 spec->chmap.channels_max = chans; in hdmi_add_cvt()
1925 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1926 &per_cvt->rates, in hdmi_add_cvt()
1927 &per_cvt->formats, in hdmi_add_cvt()
1928 &per_cvt->maxbps); in hdmi_add_cvt()
1932 if (spec->num_cvts < ARRAY_SIZE(spec->cvt_nids)) in hdmi_add_cvt()
1933 spec->cvt_nids[spec->num_cvts] = cvt_nid; in hdmi_add_cvt()
1934 spec->num_cvts++; in hdmi_add_cvt()
1940 SND_PCI_QUIRK(0x103c, 0x870f, "HP", 1),
1941 SND_PCI_QUIRK(0x103c, 0x871a, "HP", 1),
1942 SND_PCI_QUIRK(0x1462, 0xec94, "MS-7C94", 1),
1946 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1948 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
1954 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
1956 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1957 return -EINVAL; in hdmi_parse_codec()
1960 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
1962 if (q && q->value) in hdmi_parse_codec()
1963 spec->force_connect = true; in hdmi_parse_codec()
1972 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
1978 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
1985 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
1991 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
1999 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
2004 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2005 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
2010 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2013 non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO); in check_non_pcm_per_cvt()
2014 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2023 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
2028 hda_nid_t cvt_nid = hinfo->nid; in generic_hdmi_playback_pcm_prepare()
2029 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
2032 struct snd_pcm_runtime *runtime = substream->runtime; in generic_hdmi_playback_pcm_prepare()
2037 mutex_lock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2038 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
2039 if (spec->dyn_pcm_assign && pin_idx < 0) { in generic_hdmi_playback_pcm_prepare()
2044 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2045 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
2051 err = -EINVAL; in generic_hdmi_playback_pcm_prepare()
2064 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
2068 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
2069 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2070 per_pin->dev_id, runtime->rate); in generic_hdmi_playback_pcm_prepare()
2072 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2073 mutex_lock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2074 per_pin->channels = substream->runtime->channels; in generic_hdmi_playback_pcm_prepare()
2075 per_pin->setup = true; in generic_hdmi_playback_pcm_prepare()
2077 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
2078 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2080 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
2085 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
2086 mutex_unlock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2087 if (spec->dyn_pin_out) { in generic_hdmi_playback_pcm_prepare()
2088 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2089 per_pin->dev_id); in generic_hdmi_playback_pcm_prepare()
2090 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2092 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2098 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2099 per_pin->dev_id, stream_tag, format); in generic_hdmi_playback_pcm_prepare()
2101 mutex_unlock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2106 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
2109 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2114 struct hda_codec *codec, in hdmi_pcm_close() argument
2117 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2124 mutex_lock(&spec->pcm_lock); in hdmi_pcm_close()
2125 if (hinfo->nid) { in hdmi_pcm_close()
2126 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
2128 err = -EINVAL; in hdmi_pcm_close()
2131 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2133 err = -EINVAL; in hdmi_pcm_close()
2137 per_cvt->assigned = 0; in hdmi_pcm_close()
2138 hinfo->nid = 0; in hdmi_pcm_close()
2140 azx_stream(get_azx_dev(substream))->stripe = 0; in hdmi_pcm_close()
2142 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
2143 clear_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_close()
2144 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
2145 if (spec->dyn_pcm_assign && pin_idx < 0) in hdmi_pcm_close()
2149 err = -EINVAL; in hdmi_pcm_close()
2154 if (spec->dyn_pin_out) { in hdmi_pcm_close()
2155 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2156 per_pin->dev_id); in hdmi_pcm_close()
2157 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2159 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2164 mutex_lock(&per_pin->lock); in hdmi_pcm_close()
2165 per_pin->chmap_set = false; in hdmi_pcm_close()
2166 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_close()
2168 per_pin->setup = false; in hdmi_pcm_close()
2169 per_pin->channels = 0; in hdmi_pcm_close()
2170 mutex_unlock(&per_pin->lock); in hdmi_pcm_close()
2174 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_close()
2188 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_spk_alloc() local
2189 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2195 return per_pin->sink_eld.info.spk_alloc; in hdmi_get_spk_alloc()
2201 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_chmap() local
2202 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2209 memcpy(chmap, per_pin->chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_get_chmap()
2215 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_set_chmap() local
2216 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2221 mutex_lock(&per_pin->lock); in hdmi_set_chmap()
2222 per_pin->chmap_set = true; in hdmi_set_chmap()
2223 memcpy(per_pin->chmap, chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_set_chmap()
2225 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2226 mutex_unlock(&per_pin->lock); in hdmi_set_chmap()
2231 struct hda_codec *codec = hdac_to_hda_codec(hdac); in is_hdmi_pcm_attached() local
2232 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2238 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2240 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2244 * for non-mst mode, pcm number is the same as before in generic_hdmi_build_pcms()
2247 * (nid number + dev_num - 1) in generic_hdmi_build_pcms()
2251 if (codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2252 pcm_num = spec->num_nids; in generic_hdmi_build_pcms()
2254 pcm_num = spec->num_nids + spec->dev_num - 1; in generic_hdmi_build_pcms()
2256 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); in generic_hdmi_build_pcms()
2262 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2264 return -ENOMEM; in generic_hdmi_build_pcms()
2266 spec->pcm_rec[idx].pcm = info; in generic_hdmi_build_pcms()
2267 spec->pcm_used++; in generic_hdmi_build_pcms()
2268 info->pcm_type = HDA_PCM_TYPE_HDMI; in generic_hdmi_build_pcms()
2269 info->own_chmap = true; in generic_hdmi_build_pcms()
2271 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in generic_hdmi_build_pcms()
2272 pstr->substreams = 1; in generic_hdmi_build_pcms()
2273 pstr->ops = generic_ops; in generic_hdmi_build_pcms()
2275 if (spec->pcm_used >= 16) in generic_hdmi_build_pcms()
2285 struct hdmi_pcm *pcm = jack->private_data; in free_hdmi_jack_priv()
2287 pcm->jack = NULL; in free_hdmi_jack_priv()
2290 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2293 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2296 int pcmdev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_jack()
2301 if (!spec->dyn_pcm_assign && in generic_hdmi_build_jack()
2302 !is_jack_detectable(codec, per_pin->pin_nid)) in generic_hdmi_build_jack()
2304 sizeof(hdmi_str) - strlen(hdmi_str) - 1); in generic_hdmi_build_jack()
2306 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2311 spec->pcm_rec[pcm_idx].jack = jack; in generic_hdmi_build_jack()
2312 jack->private_data = &spec->pcm_rec[pcm_idx]; in generic_hdmi_build_jack()
2313 jack->private_free = free_hdmi_jack_priv; in generic_hdmi_build_jack()
2317 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2319 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2323 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2324 if (!get_pcm_rec(spec, pcm_idx)->pcm) { in generic_hdmi_build_controls()
2326 set_bit(pcm_idx, &spec->pcm_bitmap); in generic_hdmi_build_controls()
2330 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2337 if (spec->dyn_pcm_assign) in generic_hdmi_build_controls()
2338 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2339 0, spec->cvt_nids[0], in generic_hdmi_build_controls()
2344 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2345 per_pin->pin_nid, in generic_hdmi_build_controls()
2346 per_pin->mux_nids[0], in generic_hdmi_build_controls()
2351 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2353 dev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_controls()
2356 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2362 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_build_controls()
2364 struct hdmi_eld *pin_eld = &per_pin->sink_eld; in generic_hdmi_build_controls()
2366 pin_eld->eld_valid = false; in generic_hdmi_build_controls()
2371 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2375 if (!pcm || !pcm->pcm) in generic_hdmi_build_controls()
2377 err = snd_hdac_add_chmap_ctls(pcm->pcm, pcm_idx, &spec->chmap); in generic_hdmi_build_controls()
2385 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2387 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2390 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init_per_pins()
2393 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2394 mutex_init(&per_pin->lock); in generic_hdmi_init_per_pins()
2395 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); in generic_hdmi_init_per_pins()
2401 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2403 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2406 mutex_lock(&spec->bind_lock); in generic_hdmi_init()
2407 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init()
2409 hda_nid_t pin_nid = per_pin->pin_nid; in generic_hdmi_init()
2410 int dev_id = per_pin->dev_id; in generic_hdmi_init()
2412 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2413 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2414 if (codec_has_acomp(codec)) in generic_hdmi_init()
2416 snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id, in generic_hdmi_init()
2419 mutex_unlock(&spec->bind_lock); in generic_hdmi_init()
2425 snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums); in hdmi_array_init()
2426 snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums); in hdmi_array_init()
2431 snd_array_free(&spec->pins); in hdmi_array_free()
2432 snd_array_free(&spec->cvts); in hdmi_array_free()
2435 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2437 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2442 codec->spec = NULL; in generic_spec_free()
2444 codec->dp_mst = false; in generic_spec_free()
2447 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2449 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2452 if (spec->acomp_registered) { in generic_hdmi_free()
2453 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2454 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2455 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2457 codec->relaxed_resume = 0; in generic_hdmi_free()
2459 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_free()
2461 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_free()
2465 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_free()
2466 if (spec->pcm_rec[pcm_idx].jack == NULL) in generic_hdmi_free()
2468 if (spec->dyn_pcm_assign) in generic_hdmi_free()
2469 snd_device_free(codec->card, in generic_hdmi_free()
2470 spec->pcm_rec[pcm_idx].jack); in generic_hdmi_free()
2472 spec->pcm_rec[pcm_idx].jack = NULL; in generic_hdmi_free()
2475 generic_spec_free(codec); in generic_hdmi_free()
2479 static int generic_hdmi_suspend(struct hda_codec *codec) in generic_hdmi_suspend() argument
2481 struct hdmi_spec *spec = codec->spec; in generic_hdmi_suspend()
2484 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_suspend()
2486 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_suspend()
2491 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2493 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2496 codec->patch_ops.init(codec); in generic_hdmi_resume()
2497 snd_hda_regmap_sync(codec); in generic_hdmi_resume()
2499 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_resume()
2501 hdmi_present_sense(per_pin, 1); in generic_hdmi_resume()
2526 /* allocate codec->spec and assign/initialize generic parser ops */
2527 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2533 return -ENOMEM; in alloc_generic_hdmi()
2535 spec->codec = codec; in alloc_generic_hdmi()
2536 spec->ops = generic_standard_hdmi_ops; in alloc_generic_hdmi()
2537 spec->dev_num = 1; /* initialize to 1 */ in alloc_generic_hdmi()
2538 mutex_init(&spec->pcm_lock); in alloc_generic_hdmi()
2539 mutex_init(&spec->bind_lock); in alloc_generic_hdmi()
2540 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2542 spec->chmap.ops.get_chmap = hdmi_get_chmap; in alloc_generic_hdmi()
2543 spec->chmap.ops.set_chmap = hdmi_set_chmap; in alloc_generic_hdmi()
2544 spec->chmap.ops.is_pcm_attached = is_hdmi_pcm_attached; in alloc_generic_hdmi()
2545 spec->chmap.ops.get_spk_alloc = hdmi_get_spk_alloc; in alloc_generic_hdmi()
2547 codec->spec = spec; in alloc_generic_hdmi()
2550 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2556 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2560 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2564 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2566 generic_spec_free(codec); in patch_generic_hdmi()
2570 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2579 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2584 tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in reprogram_jack_detect()
2586 /* clear unsol even if component notifier is used, or re-enable in reprogram_jack_detect()
2589 unsigned int val = use_acomp ? 0 : (AC_USRSP_EN | tbl->tag); in reprogram_jack_detect()
2590 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2602 spec = container_of(acomp->audio_ops, struct hdmi_spec, drm_audio_ops); in generic_acomp_notifier_set()
2603 mutex_lock(&spec->bind_lock); in generic_acomp_notifier_set()
2604 spec->use_acomp_notifier = use_acomp; in generic_acomp_notifier_set()
2605 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2606 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2608 for (i = 0; i < spec->num_pins; i++) in generic_acomp_notifier_set()
2609 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2610 get_pin(spec, i)->pin_nid, in generic_acomp_notifier_set()
2611 get_pin(spec, i)->dev_id, in generic_acomp_notifier_set()
2613 mutex_unlock(&spec->bind_lock); in generic_acomp_notifier_set()
2630 /* check whether both HD-audio and DRM PCI devices belong to the same bus */
2636 if (!dev_is_pci(dev) || !dev_is_pci(bus->dev)) in match_bound_vga()
2638 master = to_pci_dev(bus->dev); in match_bound_vga()
2640 return master->bus == pci->bus; in match_bound_vga()
2646 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2647 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2648 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2652 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2657 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in generic_acomp_pin_eld_notify()
2660 if (snd_hdac_is_in_pm(&codec->core)) in generic_acomp_pin_eld_notify()
2663 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2667 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2670 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2672 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2678 spec->drm_audio_ops.pin2port = ops->pin2port; in setup_drm_audio_ops()
2679 spec->drm_audio_ops.pin_eld_notify = ops->pin_eld_notify; in setup_drm_audio_ops()
2680 spec->drm_audio_ops.master_bind = ops->master_bind; in setup_drm_audio_ops()
2681 spec->drm_audio_ops.master_unbind = ops->master_unbind; in setup_drm_audio_ops()
2685 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2689 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2692 codec_info(codec, "audio component disabled by module option\n"); in generic_acomp_init()
2696 spec->port2pin = port2pin; in generic_acomp_init()
2697 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2698 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2700 spec->acomp_registered = true; in generic_acomp_init()
2705 * Intel codec parsers and helpers
2713 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2717 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2719 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2721 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) in intel_haswell_enable_all_pins()
2725 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2727 if (vendor_param == -1) in intel_haswell_enable_all_pins()
2731 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2734 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2737 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2739 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2741 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) in intel_haswell_fixup_enable_dp12()
2746 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2747 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2751 /* Haswell needs to re-issue the vendor-specific verbs before turning to D0.
2754 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2758 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2759 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2762 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2763 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2768 * Pin Widget 5 - PORT B (port = 1 in i915 driver)
2769 * Pin Widget 6 - PORT C (port = 2 in i915 driver)
2770 * Pin Widget 7 - PORT D (port = 3 in i915 driver)
2773 * Pin Widget 4 - PORT B (port = 1 in i915 driver)
2774 * Pin Widget 5 - PORT C (port = 2 in i915 driver)
2775 * Pin Widget 6 - PORT D (port = 3 in i915 driver)
2777 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2779 switch (codec->core.vendor_id) { in intel_base_nid()
2791 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2792 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2795 if (!spec->port_num) { in intel_pin2port()
2796 base_nid = intel_base_nid(codec); in intel_pin2port()
2798 return -1; in intel_pin2port()
2799 return pin_nid - base_nid + 1; in intel_pin2port()
2806 for (i = 0; i < spec->port_num; i++) { in intel_pin2port()
2807 if (pin_nid == spec->port_map[i]) in intel_pin2port()
2811 codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid); in intel_pin2port()
2812 return -1; in intel_pin2port()
2815 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2817 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2819 if (!spec->port_num) { in intel_port2pin()
2820 /* we assume only from port-B to port-D */ in intel_port2pin()
2821 if (port < 1 || port > 3) in intel_port2pin()
2823 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2826 if (port < 0 || port >= spec->port_num) in intel_port2pin()
2828 return spec->port_map[port]; in intel_port2pin()
2833 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2837 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2843 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
2846 if (snd_hdac_is_in_pm(&codec->core)) in intel_pin_eld_notify()
2849 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2850 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2859 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2861 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2863 spec->use_acomp_notifier = true; in register_i915_notifier()
2864 spec->port2pin = intel_port2pin; in register_i915_notifier()
2865 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2866 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2867 &spec->drm_audio_ops); in register_i915_notifier()
2869 codec->relaxed_resume = 1; in register_i915_notifier()
2873 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2877 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2878 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
2883 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2888 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2889 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2890 per_pin->dev_id); in i915_pin_cvt_fixup()
2891 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2892 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2893 per_pin->dev_id, per_pin->mux_idx); in i915_pin_cvt_fixup()
2895 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2900 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2905 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2906 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2908 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2909 return -ENODEV; in alloc_intel_hdmi()
2912 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2916 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
2920 /* parse and post-process for Intel codecs */
2921 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2926 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2927 } while (err < 0 && retries--); in parse_intel_hdmi()
2930 generic_spec_free(codec); in parse_intel_hdmi()
2934 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2935 register_i915_notifier(codec); in parse_intel_hdmi()
2940 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
2946 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2949 spec = codec->spec; in intel_hsw_common_init()
2950 codec->dp_mst = true; in intel_hsw_common_init()
2951 spec->dyn_pcm_assign = true; in intel_hsw_common_init()
2952 spec->vendor_nid = vendor_nid; in intel_hsw_common_init()
2953 spec->port_map = port_map; in intel_hsw_common_init()
2954 spec->port_num = port_num; in intel_hsw_common_init()
2955 spec->intel_hsw_fixup = true; in intel_hsw_common_init()
2957 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2958 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2960 codec->display_power_control = 1; in intel_hsw_common_init()
2962 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2963 codec->depop_delay = 0; in intel_hsw_common_init()
2964 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2966 spec->ops.setup_stream = i915_hsw_setup_stream; in intel_hsw_common_init()
2967 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in intel_hsw_common_init()
2974 spec->send_silent_stream = true; in intel_hsw_common_init()
2976 return parse_intel_hdmi(codec); in intel_hsw_common_init()
2979 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
2981 return intel_hsw_common_init(codec, 0x08, NULL, 0); in patch_i915_hsw_hdmi()
2984 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
2986 return intel_hsw_common_init(codec, 0x0b, NULL, 0); in patch_i915_glk_hdmi()
2989 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
2997 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_icl_hdmi()
3000 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
3008 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_tgl_hdmi()
3012 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
3017 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
3020 spec = codec->spec; in patch_i915_byt_hdmi()
3022 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
3025 codec->display_power_control = 1; in patch_i915_byt_hdmi()
3027 codec->depop_delay = 0; in patch_i915_byt_hdmi()
3028 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
3030 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in patch_i915_byt_hdmi()
3032 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
3036 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
3040 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3043 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3047 * Shared non-generic implementations
3050 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
3052 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
3059 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
3062 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
3064 return -ENOMEM; in simple_playback_build_pcms()
3065 spec->pcm_rec[0].pcm = info; in simple_playback_build_pcms()
3066 info->pcm_type = HDA_PCM_TYPE_HDMI; in simple_playback_build_pcms()
3067 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in simple_playback_build_pcms()
3068 *pstr = spec->pcm_playback; in simple_playback_build_pcms()
3069 pstr->nid = per_cvt->cvt_nid; in simple_playback_build_pcms()
3070 if (pstr->channels_max <= 2 && chans && chans <= 16) in simple_playback_build_pcms()
3071 pstr->channels_max = chans; in simple_playback_build_pcms()
3077 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
3080 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
3081 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
3085 * as long as spec->pins[] is set correctly
3089 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
3091 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3096 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3097 per_cvt->cvt_nid, in simple_playback_build_controls()
3101 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
3104 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
3106 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3108 hda_nid_t pin = per_pin->pin_nid; in simple_playback_init()
3110 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
3113 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
3114 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
3116 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3120 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
3122 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3181 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3183 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3187 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3189 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3214 struct hda_codec *codec, in simple_playback_pcm_open() argument
3217 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3220 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3235 snd_pcm_hw_constraint_list(substream->runtime, 0, in simple_playback_pcm_open()
3239 snd_pcm_hw_constraint_step(substream->runtime, 0, in simple_playback_pcm_open()
3243 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3247 struct hda_codec *codec, in simple_playback_pcm_close() argument
3250 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3251 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3255 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3260 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3261 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3266 .substreams = 1,
3284 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3293 return -ENOMEM; in patch_simple_hdmi()
3295 spec->codec = codec; in patch_simple_hdmi()
3296 codec->spec = spec; in patch_simple_hdmi()
3297 hdmi_array_init(spec, 1); in patch_simple_hdmi()
3299 spec->multiout.num_dacs = 0; /* no analog */ in patch_simple_hdmi()
3300 spec->multiout.max_channels = 2; in patch_simple_hdmi()
3301 spec->multiout.dig_out_nid = cvt_nid; in patch_simple_hdmi()
3302 spec->num_cvts = 1; in patch_simple_hdmi()
3303 spec->num_pins = 1; in patch_simple_hdmi()
3304 per_pin = snd_array_new(&spec->pins); in patch_simple_hdmi()
3305 per_cvt = snd_array_new(&spec->cvts); in patch_simple_hdmi()
3307 simple_playback_free(codec); in patch_simple_hdmi()
3308 return -ENOMEM; in patch_simple_hdmi()
3310 per_cvt->cvt_nid = cvt_nid; in patch_simple_hdmi()
3311 per_pin->pin_nid = pin_nid; in patch_simple_hdmi()
3312 spec->pcm_playback = simple_pcm_playback; in patch_simple_hdmi()
3314 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3319 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3323 int chan = channels ? (channels - 1) : 1; in nvhdmi_8ch_7x_set_info_frame_parameters()
3344 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3347 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3349 (0x71 - chan - chanmask)); in nvhdmi_8ch_7x_set_info_frame_parameters()
3353 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3356 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3359 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3363 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3366 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3372 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3374 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3378 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3386 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3390 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3392 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3394 chs = substream->runtime->channels; in nvhdmi_8ch_7x_pcm_prepare()
3399 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3400 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3404 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3407 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3411 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3416 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3417 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3421 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3422 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3437 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3438 (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3439 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3443 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3445 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3451 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3458 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3459 (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3460 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3464 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3465 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3472 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3474 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3479 .substreams = 1,
3493 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3496 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3501 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3502 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3503 spec = codec->spec; in patch_nvhdmi_2ch()
3504 spec->pcm_playback.rates = SUPPORTED_RATES; in patch_nvhdmi_2ch()
3505 spec->pcm_playback.maxbps = SUPPORTED_MAXBPS; in patch_nvhdmi_2ch()
3506 spec->pcm_playback.formats = SUPPORTED_FORMATS; in patch_nvhdmi_2ch()
3510 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3512 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3513 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3516 info->own_chmap = true; in nvhdmi_7x_8ch_build_pcms()
3521 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3523 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3528 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3534 err = snd_pcm_add_chmap_ctls(info->pcm, in nvhdmi_7x_8ch_build_controls()
3539 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3544 chmap->channel_mask = (1U << 2) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3547 chmap->channel_mask = (1U << 2) | (1U << 6) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3552 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3555 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3558 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3559 spec->multiout.max_channels = 8; in patch_nvhdmi_8ch_7x()
3560 spec->pcm_playback = nvhdmi_pcm_playback_8ch_7x; in patch_nvhdmi_8ch_7x()
3561 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3562 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3563 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3567 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3573 * NVIDIA codecs ignore ASP mapping for 2ch - confirmed on:
3574 * - 0x10de0015
3575 * - 0x10de0040
3580 if (cap->ca_index == 0x00 && channels == 2) in nvhdmi_chmap_cea_alloc_validate_get_type()
3584 if (cap->channels != channels) in nvhdmi_chmap_cea_alloc_validate_get_type()
3585 return -1; in nvhdmi_chmap_cea_alloc_validate_get_type()
3594 if (ca == 0x00 && (map[0] != SNDRV_CHMAP_FL || map[1] != SNDRV_CHMAP_FR)) in nvhdmi_chmap_validate()
3595 return -EINVAL; in nvhdmi_chmap_validate()
3600 /* map from pin NID to port; port is 0-based */
3601 /* for Nvidia: assume widget NID starting from 4, with step 1 (4, 5, 6, ...) */
3604 return pin_nid - 4; in nvhdmi_pin2port()
3607 /* reverse-map from port to pin NID: see above */
3608 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3620 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3625 err = alloc_generic_hdmi(codec); in patch_nvhdmi()
3628 codec->dp_mst = true; in patch_nvhdmi()
3630 spec = codec->spec; in patch_nvhdmi()
3631 spec->dyn_pcm_assign = true; in patch_nvhdmi()
3633 err = hdmi_parse_codec(codec); in patch_nvhdmi()
3635 generic_spec_free(codec); in patch_nvhdmi()
3639 generic_hdmi_init_per_pins(codec); in patch_nvhdmi()
3641 spec->dyn_pin_out = true; in patch_nvhdmi()
3643 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi()
3645 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi()
3647 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3649 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3654 static int patch_nvhdmi_legacy(struct hda_codec *codec) in patch_nvhdmi_legacy() argument
3659 err = patch_generic_hdmi(codec); in patch_nvhdmi_legacy()
3663 spec = codec->spec; in patch_nvhdmi_legacy()
3664 spec->dyn_pin_out = true; in patch_nvhdmi_legacy()
3666 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi_legacy()
3668 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi_legacy()
3670 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3676 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3677 * accessed using vendor-defined verbs. These registers can be used for
3685 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3687 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3692 * +---------+-------+--------+--------+
3694 * +-----------------------------------|
3704 #define NVIDIA_SCRATCH_TRIGGER (1 << 7)
3705 #define NVIDIA_SCRATCH_VALID (1 << 6)
3715 * the format is invalidated so that the HDMI codec can be disabled.
3717 static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) in tegra_hdmi_set_format() argument
3722 value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3727 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3730 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3735 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3749 * HDMI codec. The HDMI driver will use that as trigger to update its in tegra_hdmi_set_format()
3754 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3759 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3766 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3771 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3772 tegra_hdmi_set_format(codec, format); in tegra_hdmi_pcm_prepare()
3778 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3781 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3782 tegra_hdmi_set_format(codec, 0); in tegra_hdmi_pcm_cleanup()
3784 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3787 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3789 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3792 for (i = 0; i < spec->num_pins; i++) { in hda_find_pcm_by_type()
3795 if (pcm->pcm_type == type) in hda_find_pcm_by_type()
3802 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3808 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3812 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3814 return -ENODEV; in tegra_hdmi_build_pcms()
3817 * Override ->prepare() and ->cleanup() operations to notify the HDMI in tegra_hdmi_build_pcms()
3818 * codec about format changes. in tegra_hdmi_build_pcms()
3820 stream = &pcm->stream[SNDRV_PCM_STREAM_PLAYBACK]; in tegra_hdmi_build_pcms()
3821 stream->ops.prepare = tegra_hdmi_pcm_prepare; in tegra_hdmi_build_pcms()
3822 stream->ops.cleanup = tegra_hdmi_pcm_cleanup; in tegra_hdmi_build_pcms()
3827 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3832 err = patch_generic_hdmi(codec); in patch_tegra_hdmi()
3836 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in patch_tegra_hdmi()
3837 spec = codec->spec; in patch_tegra_hdmi()
3838 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_tegra_hdmi()
3840 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_tegra_hdmi()
3846 * ATI/AMD-specific implementations
3849 #define is_amdhdmi_rev3_or_later(codec) \ argument
3850 ((codec)->core.vendor_id == 0x1002aa01 && \
3851 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3852 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3887 #define ATI_MULTICHANNEL_MODE_SINGLE 1
3892 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3896 /* call hda_eld.c ATI/AMD-specific function */ in atihdmi_pin_get_eld()
3897 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
3898 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
3901 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, in atihdmi_pin_setup_infoframe() argument
3906 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3912 * ATI/AMD have automatic FC/LFE swap built-in in atihdmi_paired_swap_fc_lfe()
3932 /* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */ in atihdmi_paired_chmap_validate()
3944 int chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j); in atihdmi_paired_chmap_validate()
3945 if (cap->speakers[chan_idx] == mask) { in atihdmi_paired_chmap_validate()
3949 if (i % 2 == 0 && i + 1 < chs) { in atihdmi_paired_chmap_validate()
3951 int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1); in atihdmi_paired_chmap_validate()
3952 int comp_mask_req = snd_hdac_chmap_to_spk_mask(map[i+1]); in atihdmi_paired_chmap_validate()
3953 int comp_mask_act = cap->speakers[comp_chan_idx]; in atihdmi_paired_chmap_validate()
3958 return -EINVAL; in atihdmi_paired_chmap_validate()
3965 return -EINVAL; in atihdmi_paired_chmap_validate()
3977 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_set_slot_channel() local
3982 return -EINVAL; in atihdmi_pin_set_slot_channel()
3984 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
3994 hdmi_slot -= hdmi_slot % 2; in atihdmi_pin_set_slot_channel()
3997 stream_channel -= stream_channel % 2; in atihdmi_pin_set_slot_channel()
4002 /* ati_channel_setup format: [7..4] = stream_channel_id, [1] = mute, [0] = enable */ in atihdmi_pin_set_slot_channel()
4007 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
4013 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_get_slot_channel() local
4020 return -EINVAL; in atihdmi_pin_get_slot_channel()
4022 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
4025 ati_asp_slot -= 1; in atihdmi_pin_get_slot_channel()
4032 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
4048 * Pre-rev3 ATI/AMD codecs operate in a paired channel mode, so in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4055 /* We only produce even-numbered channel count TLVs */ in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4057 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4060 if (cap->speakers[c] || cap->speakers[c+1]) in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4065 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4074 /* produce paired maps for pre-rev3 ATI/AMD codecs */ in atihdmi_paired_cea_alloc_to_tlv_chmap()
4078 for (c = 7; c >= 0; c--) { in atihdmi_paired_cea_alloc_to_tlv_chmap()
4079 int chan = 7 - atihdmi_paired_swap_fc_lfe(7 - c); in atihdmi_paired_cea_alloc_to_tlv_chmap()
4080 int spk = cap->speakers[chan]; in atihdmi_paired_cea_alloc_to_tlv_chmap()
4083 if (cap->speakers[chan + (chan % 2 ? -1 : 1)]) in atihdmi_paired_cea_alloc_to_tlv_chmap()
4095 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
4102 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
4109 codec_dbg(codec, in atihdmi_pin_hbr_setup()
4110 "atihdmi_pin_hbr_setup: NID=0x%x, %shbr-ctl=0x%x\n", in atihdmi_pin_hbr_setup()
4112 hbr_ctl == hbr_ctl_new ? "" : "new-", in atihdmi_pin_hbr_setup()
4116 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
4121 return -EINVAL; in atihdmi_pin_hbr_setup()
4126 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
4130 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
4132 /* disable ramp-up/down for non-pcm as per AMD spec */ in atihdmi_setup_stream()
4136 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
4139 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in atihdmi_setup_stream()
4144 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
4146 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4149 err = generic_hdmi_init(codec); in atihdmi_init()
4154 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in atihdmi_init()
4158 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4160 /* enable channel-wise remap mode if supported */ in atihdmi_init()
4161 if (has_amd_full_remap_support(codec)) in atihdmi_init()
4162 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4166 codec->auto_runtime_pm = 1; in atihdmi_init()
4171 /* map from pin NID to port; port is 0-based */
4175 return pin_nid / 2 - 1; in atihdmi_pin2port()
4178 /* reverse-map from port to pin NID: see above */
4179 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4191 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4197 err = patch_generic_hdmi(codec); in patch_atihdmi()
4202 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4204 spec = codec->spec; in patch_atihdmi()
4206 spec->ops.pin_get_eld = atihdmi_pin_get_eld; in patch_atihdmi()
4207 spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe; in patch_atihdmi()
4208 spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup; in patch_atihdmi()
4209 spec->ops.setup_stream = atihdmi_setup_stream; in patch_atihdmi()
4211 spec->chmap.ops.pin_get_slot_channel = atihdmi_pin_get_slot_channel; in patch_atihdmi()
4212 spec->chmap.ops.pin_set_slot_channel = atihdmi_pin_set_slot_channel; in patch_atihdmi()
4214 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4215 /* override to ATI/AMD-specific versions with pairwise mapping */ in patch_atihdmi()
4216 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_atihdmi()
4218 spec->chmap.ops.cea_alloc_to_tlv_chmap = in patch_atihdmi()
4220 spec->chmap.ops.chmap_validate = atihdmi_paired_chmap_validate; in patch_atihdmi()
4224 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in patch_atihdmi()
4226 per_cvt->channels_max = max(per_cvt->channels_max, 8u); in patch_atihdmi()
4227 per_cvt->rates |= SUPPORTED_RATES; in patch_atihdmi()
4228 per_cvt->formats |= SUPPORTED_FORMATS; in patch_atihdmi()
4229 per_cvt->maxbps = max(per_cvt->maxbps, 24u); in patch_atihdmi()
4232 spec->chmap.channels_max = max(spec->chmap.channels_max, 8u); in patch_atihdmi()
4235 * the link-down as is. Tell the core to allow it. in patch_atihdmi()
4237 codec->link_down_at_suspend = 1; in patch_atihdmi()
4239 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4248 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4250 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4287 HDA_CODEC_ENTRY(0x10de001a, "GPU 1a HDMI/DP", patch_nvhdmi_legacy),
4288 HDA_CODEC_ENTRY(0x10de001b, "GPU 1b HDMI/DP", patch_nvhdmi_legacy),
4289 HDA_CODEC_ENTRY(0x10de001c, "GPU 1c HDMI/DP", patch_nvhdmi_legacy),
4369 HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi),
4381 MODULE_DESCRIPTION("HDMI HD-audio codec");
4382 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4383 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4384 MODULE_ALIAS("snd-hda-codec-atihdmi");