Lines Matching +full:codec +full:- +full:0
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
150 * bit 0 means the first playback PCM (PCM3);
163 bool intel_hsw_fixup; /* apply Intel platform-specific fixups */
165 * Non-generic VIA/NVIDIA specific
184 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
186 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
187 return spec->use_acomp_notifier; in codec_has_acomp()
190 #define codec_has_acomp(codec) false argument
194 u8 type; /* 0x84 */
195 u8 ver; /* 0x01 */
196 u8 len; /* 0x0a */
200 u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */
208 u8 type; /* 0x84 */
209 u8 len; /* 0x1b */
210 u8 ver; /* 0x11 << 2 */
222 u8 bytes[0];
230 ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx))
232 ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx))
234 #define get_hdmi_pcm(spec, idx) (&(spec)->pcm_rec[idx])
236 #define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm)
238 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
241 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
246 * (dev_id == -1) means it is NON-MST pin in pin_id_to_pin_index()
249 if (dev_id == -1) in pin_id_to_pin_index()
250 dev_id = 0; in pin_id_to_pin_index()
252 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in pin_id_to_pin_index()
254 if ((per_pin->pin_nid == pin_nid) && in pin_id_to_pin_index()
255 (per_pin->dev_id == dev_id)) in pin_id_to_pin_index()
259 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid); in pin_id_to_pin_index()
260 return -EINVAL; in pin_id_to_pin_index()
263 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
266 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
269 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) in hinfo_to_pcm_index()
270 if (get_pcm_rec(spec, pcm_idx)->stream == hinfo) in hinfo_to_pcm_index()
273 codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo); in hinfo_to_pcm_index()
274 return -EINVAL; in hinfo_to_pcm_index()
277 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
280 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
284 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in hinfo_to_pin_index()
286 if (per_pin->pcm && in hinfo_to_pin_index()
287 per_pin->pcm->pcm->stream == hinfo) in hinfo_to_pin_index()
291 codec_dbg(codec, "HDMI: hinfo %p (pcm %d) not registered\n", hinfo, in hinfo_to_pin_index()
292 hinfo_to_pcm_index(codec, hinfo)); in hinfo_to_pin_index()
293 return -EINVAL; in hinfo_to_pin_index()
302 for (i = 0; i < spec->num_pins; i++) { in pcm_idx_to_pin()
304 if (per_pin->pcm_idx == pcm_idx) in pcm_idx_to_pin()
310 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
312 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
315 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) in cvt_nid_to_cvt_index()
316 if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid) in cvt_nid_to_cvt_index()
319 codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
320 return -EINVAL; in cvt_nid_to_cvt_index()
326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
327 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
332 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdmi_eld_ctl_info()
334 pcm_idx = kcontrol->private_value; in hdmi_eld_ctl_info()
335 mutex_lock(&spec->pcm_lock); in hdmi_eld_ctl_info()
339 uinfo->count = 0; in hdmi_eld_ctl_info()
342 eld = &per_pin->sink_eld; in hdmi_eld_ctl_info()
343 uinfo->count = eld->eld_valid ? eld->eld_size : 0; in hdmi_eld_ctl_info()
346 mutex_unlock(&spec->pcm_lock); in hdmi_eld_ctl_info()
347 return 0; in hdmi_eld_ctl_info()
353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
354 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
358 int err = 0; in hdmi_eld_ctl_get()
360 pcm_idx = kcontrol->private_value; in hdmi_eld_ctl_get()
361 mutex_lock(&spec->pcm_lock); in hdmi_eld_ctl_get()
365 memset(ucontrol->value.bytes.data, 0, in hdmi_eld_ctl_get()
366 ARRAY_SIZE(ucontrol->value.bytes.data)); in hdmi_eld_ctl_get()
370 eld = &per_pin->sink_eld; in hdmi_eld_ctl_get()
371 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) || in hdmi_eld_ctl_get()
372 eld->eld_size > ELD_MAX_SIZE) { in hdmi_eld_ctl_get()
374 err = -EINVAL; in hdmi_eld_ctl_get()
378 memset(ucontrol->value.bytes.data, 0, in hdmi_eld_ctl_get()
379 ARRAY_SIZE(ucontrol->value.bytes.data)); in hdmi_eld_ctl_get()
380 if (eld->eld_valid) in hdmi_eld_ctl_get()
381 memcpy(ucontrol->value.bytes.data, eld->eld_buffer, in hdmi_eld_ctl_get()
382 eld->eld_size); in hdmi_eld_ctl_get()
385 mutex_unlock(&spec->pcm_lock); in hdmi_eld_ctl_get()
398 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
402 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
405 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
407 return -ENOMEM; in hdmi_create_eld_ctl()
408 kctl->private_value = pcm_idx; in hdmi_create_eld_ctl()
409 kctl->id.device = device; in hdmi_create_eld_ctl()
414 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
415 if (err < 0) in hdmi_create_eld_ctl()
418 get_hdmi_pcm(spec, pcm_idx)->eld_ctl = kctl; in hdmi_create_eld_ctl()
419 return 0; in hdmi_create_eld_ctl()
423 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
428 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
429 AC_VERB_GET_HDMI_DIP_INDEX, 0); in hdmi_get_dip_index()
432 *byte_index = val & 0x1f; in hdmi_get_dip_index()
436 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
441 val = (packet_index << 5) | (byte_index & 0x1f); in hdmi_set_dip_index()
443 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
446 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
449 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
452 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
454 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
458 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
459 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
462 if (spec->dyn_pin_out) in hdmi_init_pin()
464 pin_out = 0; in hdmi_init_pin()
471 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
483 struct hdmi_spec_per_pin *per_pin = entry->private_data; in print_eld_info()
485 mutex_lock(&per_pin->lock); in print_eld_info()
486 snd_hdmi_print_eld_info(&per_pin->sink_eld, buffer); in print_eld_info()
487 mutex_unlock(&per_pin->lock); in print_eld_info()
493 struct hdmi_spec_per_pin *per_pin = entry->private_data; in write_eld_info()
495 mutex_lock(&per_pin->lock); in write_eld_info()
496 snd_hdmi_write_eld_info(&per_pin->sink_eld, buffer); in write_eld_info()
497 mutex_unlock(&per_pin->lock); in write_eld_info()
503 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
507 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
508 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
509 if (err < 0) in eld_proc_new()
513 entry->c.text.write = write_eld_info; in eld_proc_new()
514 entry->mode |= 0200; in eld_proc_new()
515 per_pin->proc_entry = entry; in eld_proc_new()
517 return 0; in eld_proc_new()
522 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
523 snd_info_free_entry(per_pin->proc_entry); in eld_proc_free()
524 per_pin->proc_entry = NULL; in eld_proc_free()
531 return 0; in eld_proc_new()
545 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
548 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
549 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
556 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
559 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
560 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
564 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
570 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
571 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
573 for (i = 0; i < 8; i++) { in hdmi_debug_dip_size()
574 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
576 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
581 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
587 for (i = 0; i < 8; i++) { in hdmi_clear_dip_buffers()
588 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
590 if (size == 0) in hdmi_clear_dip_buffers()
593 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
595 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
596 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
598 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
600 if (bi == 0) /* byte index wrapped around */ in hdmi_clear_dip_buffers()
603 codec_dbg(codec, in hdmi_clear_dip_buffers()
613 u8 sum = 0; in hdmi_checksum_audio_infoframe()
616 hdmi_ai->checksum = 0; in hdmi_checksum_audio_infoframe()
618 for (i = 0; i < sizeof(*hdmi_ai); i++) in hdmi_checksum_audio_infoframe()
621 hdmi_ai->checksum = -sum; in hdmi_checksum_audio_infoframe()
624 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
630 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
631 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
633 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
634 for (i = 0; i < size; i++) in hdmi_fill_audio_infoframe()
635 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
638 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
644 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
648 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
649 for (i = 0; i < size; i++) { in hdmi_infoframe_uptodate()
650 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
651 AC_VERB_GET_HDMI_DIP_DATA, 0); in hdmi_infoframe_uptodate()
659 static int hdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in hdmi_pin_get_eld() argument
662 snd_hda_set_dev_select(codec, nid, dev_id); in hdmi_pin_get_eld()
664 return snd_hdmi_get_eld(codec, nid, buf, eld_size); in hdmi_pin_get_eld()
667 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
672 struct hdmi_spec *spec = codec->spec; in hdmi_pin_setup_infoframe()
675 memset(&ai, 0, sizeof(ai)); in hdmi_pin_setup_infoframe()
676 if ((conn_type == 0) || /* HDMI */ in hdmi_pin_setup_infoframe()
678 (conn_type == 1 && spec->nv_dp_workaround)) { in hdmi_pin_setup_infoframe()
681 if (conn_type == 0) { /* HDMI */ in hdmi_pin_setup_infoframe()
682 hdmi_ai->type = 0x84; in hdmi_pin_setup_infoframe()
683 hdmi_ai->ver = 0x01; in hdmi_pin_setup_infoframe()
684 hdmi_ai->len = 0x0a; in hdmi_pin_setup_infoframe()
686 hdmi_ai->type = 0x84; in hdmi_pin_setup_infoframe()
687 hdmi_ai->ver = 0x1b; in hdmi_pin_setup_infoframe()
688 hdmi_ai->len = 0x11 << 2; in hdmi_pin_setup_infoframe()
690 hdmi_ai->CC02_CT47 = active_channels - 1; in hdmi_pin_setup_infoframe()
691 hdmi_ai->CA = ca; in hdmi_pin_setup_infoframe()
696 dp_ai->type = 0x84; in hdmi_pin_setup_infoframe()
697 dp_ai->len = 0x1b; in hdmi_pin_setup_infoframe()
698 dp_ai->ver = 0x11 << 2; in hdmi_pin_setup_infoframe()
699 dp_ai->CC02_CT47 = active_channels - 1; in hdmi_pin_setup_infoframe()
700 dp_ai->CA = ca; in hdmi_pin_setup_infoframe()
702 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n", in hdmi_pin_setup_infoframe()
707 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_setup_infoframe()
714 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
716 codec_dbg(codec, in hdmi_pin_setup_infoframe()
717 "hdmi_pin_setup_infoframe: pin=%d channels=%d ca=0x%02x\n", in hdmi_pin_setup_infoframe()
720 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
721 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
723 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
727 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
731 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
732 struct hdac_chmap *chmap = &spec->chmap; in hdmi_setup_audio_infoframe()
733 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_setup_audio_infoframe()
734 int dev_id = per_pin->dev_id; in hdmi_setup_audio_infoframe()
735 int channels = per_pin->channels; in hdmi_setup_audio_infoframe()
743 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_setup_audio_infoframe()
746 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
747 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
751 eld = &per_pin->sink_eld; in hdmi_setup_audio_infoframe()
753 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
754 eld->info.spk_alloc, channels, in hdmi_setup_audio_infoframe()
755 per_pin->chmap_set, non_pcm, per_pin->chmap); in hdmi_setup_audio_infoframe()
759 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
766 snd_hdac_setup_channel_mapping(&spec->chmap, in hdmi_setup_audio_infoframe()
768 per_pin->chmap, per_pin->chmap_set); in hdmi_setup_audio_infoframe()
770 spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id, in hdmi_setup_audio_infoframe()
771 ca, active_channels, eld->info.conn_type); in hdmi_setup_audio_infoframe()
773 per_pin->non_pcm = non_pcm; in hdmi_setup_audio_infoframe()
782 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
785 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
786 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
788 if (pin_idx < 0) in check_presence_and_report()
790 mutex_lock(&spec->pcm_lock); in check_presence_and_report()
792 mutex_unlock(&spec->pcm_lock); in check_presence_and_report()
795 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
799 if (codec_has_acomp(codec)) in jack_callback()
802 check_presence_and_report(codec, jack->nid, jack->dev_id); in jack_callback()
805 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res, in hdmi_intrinsic_event() argument
808 jack->jack_dirty = 1; in hdmi_intrinsic_event()
810 codec_dbg(codec, in hdmi_intrinsic_event()
811 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_intrinsic_event()
812 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
815 check_presence_and_report(codec, jack->nid, jack->dev_id); in hdmi_intrinsic_event()
818 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
825 codec_info(codec, in hdmi_non_intrinsic_event()
826 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", in hdmi_non_intrinsic_event()
827 codec->addr, in hdmi_non_intrinsic_event()
843 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
849 if (codec_has_acomp(codec)) in hdmi_unsol_event()
852 if (codec->dp_mst) { in hdmi_unsol_event()
856 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in hdmi_unsol_event()
858 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in hdmi_unsol_event()
862 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
866 if (subtag == 0) in hdmi_unsol_event()
867 hdmi_intrinsic_event(codec, res, jack); in hdmi_unsol_event()
869 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
872 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
878 * thus pins could only choose converter 0 for use. Make sure the in haswell_verify_D0()
880 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
881 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
883 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
884 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
887 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
889 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
897 /* HBR should be Non-PCM, 8 channels */
901 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
906 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
907 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_hbr_setup()
908 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
909 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); in hdmi_pin_hbr_setup()
911 if (pinctl < 0) in hdmi_pin_hbr_setup()
912 return hbr ? -EINVAL : 0; in hdmi_pin_hbr_setup()
920 codec_dbg(codec, in hdmi_pin_hbr_setup()
921 "hdmi_pin_hbr_setup: NID=0x%x, %spinctl=0x%x\n", in hdmi_pin_hbr_setup()
923 pinctl == new_pinctl ? "" : "new-", in hdmi_pin_hbr_setup()
927 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
931 return -EINVAL; in hdmi_pin_hbr_setup()
933 return 0; in hdmi_pin_hbr_setup()
936 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
940 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
944 err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id, in hdmi_setup_stream()
948 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
952 if (spec->intel_hsw_fixup) { in hdmi_setup_stream()
959 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
960 AC_VERB_GET_DIGI_CONVERT_1, 0); in hdmi_setup_stream()
966 param |= 0x1; in hdmi_setup_stream()
968 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
972 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
973 return 0; in hdmi_setup_stream()
981 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
984 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
987 int cvt_idx, mux_idx = 0; in hdmi_choose_cvt()
989 /* pin_idx < 0 means no pin will be bound to the converter */ in hdmi_choose_cvt()
990 if (pin_idx < 0) in hdmi_choose_cvt()
995 if (per_pin && per_pin->silent_stream) { in hdmi_choose_cvt()
996 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in hdmi_choose_cvt()
999 return 0; in hdmi_choose_cvt()
1003 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in hdmi_choose_cvt()
1007 if (per_cvt->assigned) in hdmi_choose_cvt()
1012 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++) in hdmi_choose_cvt()
1013 if (per_pin->mux_nids[mux_idx] == per_cvt->cvt_nid) in hdmi_choose_cvt()
1016 if (mux_idx == per_pin->num_mux_nids) in hdmi_choose_cvt()
1022 if (cvt_idx == spec->num_cvts) in hdmi_choose_cvt()
1023 return -EBUSY; in hdmi_choose_cvt()
1026 per_pin->mux_idx = mux_idx; in hdmi_choose_cvt()
1031 return 0; in hdmi_choose_cvt()
1035 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1038 hda_nid_t pin_nid = per_pin->pin_nid; in intel_verify_pin_cvt_connect()
1041 mux_idx = per_pin->mux_idx; in intel_verify_pin_cvt_connect()
1042 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1043 AC_VERB_GET_CONNECT_SEL, 0); in intel_verify_pin_cvt_connect()
1045 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1058 for (i = 0; i < spec->num_cvts; i++) in intel_cvt_id_to_mux_idx()
1059 if (spec->cvt_nids[i] == cvt_nid) in intel_cvt_id_to_mux_idx()
1061 return -EINVAL; in intel_cvt_id_to_mux_idx()
1073 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1077 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1085 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in intel_not_share_assigned_cvt()
1094 if (!per_pin->pcm) in intel_not_share_assigned_cvt()
1097 if ((per_pin->pin_nid == pin_nid) && in intel_not_share_assigned_cvt()
1098 (per_pin->dev_id == dev_id)) in intel_not_share_assigned_cvt()
1102 * if per_pin->dev_id >= dev_num, in intel_not_share_assigned_cvt()
1107 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1108 if (per_pin->dev_id >= dev_num) in intel_not_share_assigned_cvt()
1111 nid = per_pin->pin_nid; in intel_not_share_assigned_cvt()
1119 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1120 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1121 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1122 AC_VERB_GET_CONNECT_SEL, 0); in intel_not_share_assigned_cvt()
1124 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1130 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
1132 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in intel_not_share_assigned_cvt()
1134 if (!per_cvt->assigned) { in intel_not_share_assigned_cvt()
1135 codec_dbg(codec, in intel_not_share_assigned_cvt()
1138 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1144 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1149 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1153 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1157 * The pin nid may be 0, this means all pins will not in intel_not_share_assigned_cvt_nid()
1161 if (mux_idx >= 0) in intel_not_share_assigned_cvt_nid()
1162 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1166 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1170 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1172 if (spec->ops.pin_cvt_fixup) in pin_cvt_fixup()
1173 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1180 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1183 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1184 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_pcm_open_no_pin()
1189 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1190 if (pcm_idx < 0) in hdmi_pcm_open_no_pin()
1191 return -EINVAL; in hdmi_pcm_open_no_pin()
1193 err = hdmi_choose_cvt(codec, -1, &cvt_idx); in hdmi_pcm_open_no_pin()
1198 per_cvt->assigned = 1; in hdmi_pcm_open_no_pin()
1199 hinfo->nid = per_cvt->cvt_nid; in hdmi_pcm_open_no_pin()
1201 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1203 set_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_open_no_pin()
1207 hinfo->channels_min = per_cvt->channels_min; in hdmi_pcm_open_no_pin()
1208 hinfo->channels_max = per_cvt->channels_max; in hdmi_pcm_open_no_pin()
1209 hinfo->rates = per_cvt->rates; in hdmi_pcm_open_no_pin()
1210 hinfo->formats = per_cvt->formats; in hdmi_pcm_open_no_pin()
1211 hinfo->maxbps = per_cvt->maxbps; in hdmi_pcm_open_no_pin()
1214 runtime->hw.channels_min = hinfo->channels_min; in hdmi_pcm_open_no_pin()
1215 runtime->hw.channels_max = hinfo->channels_max; in hdmi_pcm_open_no_pin()
1216 runtime->hw.formats = hinfo->formats; in hdmi_pcm_open_no_pin()
1217 runtime->hw.rates = hinfo->rates; in hdmi_pcm_open_no_pin()
1219 snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_pcm_open_no_pin()
1221 return 0; in hdmi_pcm_open_no_pin()
1228 struct hda_codec *codec, in hdmi_pcm_open() argument
1231 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1232 struct snd_pcm_runtime *runtime = substream->runtime; in hdmi_pcm_open()
1240 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1241 if (pcm_idx < 0) in hdmi_pcm_open()
1242 return -EINVAL; in hdmi_pcm_open()
1244 mutex_lock(&spec->pcm_lock); in hdmi_pcm_open()
1245 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1246 if (!spec->dyn_pcm_assign) { in hdmi_pcm_open()
1247 if (snd_BUG_ON(pin_idx < 0)) { in hdmi_pcm_open()
1248 err = -EINVAL; in hdmi_pcm_open()
1255 if (pin_idx < 0) { in hdmi_pcm_open()
1256 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1261 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in hdmi_pcm_open()
1262 if (err < 0) in hdmi_pcm_open()
1267 per_cvt->assigned = 1; in hdmi_pcm_open()
1269 set_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_open()
1271 per_pin->cvt_nid = per_cvt->cvt_nid; in hdmi_pcm_open()
1272 per_pin->silent_stream = false; in hdmi_pcm_open()
1273 hinfo->nid = per_cvt->cvt_nid; in hdmi_pcm_open()
1276 if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE) in hdmi_pcm_open()
1277 azx_stream(get_azx_dev(substream))->stripe = 1; in hdmi_pcm_open()
1279 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1280 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1282 per_pin->mux_idx); in hdmi_pcm_open()
1285 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1287 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1290 hinfo->channels_min = per_cvt->channels_min; in hdmi_pcm_open()
1291 hinfo->channels_max = per_cvt->channels_max; in hdmi_pcm_open()
1292 hinfo->rates = per_cvt->rates; in hdmi_pcm_open()
1293 hinfo->formats = per_cvt->formats; in hdmi_pcm_open()
1294 hinfo->maxbps = per_cvt->maxbps; in hdmi_pcm_open()
1296 eld = &per_pin->sink_eld; in hdmi_pcm_open()
1298 if (!static_hdmi_pcm && eld->eld_valid) { in hdmi_pcm_open()
1299 snd_hdmi_eld_update_pcm_info(&eld->info, hinfo); in hdmi_pcm_open()
1300 if (hinfo->channels_min > hinfo->channels_max || in hdmi_pcm_open()
1301 !hinfo->rates || !hinfo->formats) { in hdmi_pcm_open()
1302 per_cvt->assigned = 0; in hdmi_pcm_open()
1303 hinfo->nid = 0; in hdmi_pcm_open()
1304 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1305 err = -ENODEV; in hdmi_pcm_open()
1311 runtime->hw.channels_min = hinfo->channels_min; in hdmi_pcm_open()
1312 runtime->hw.channels_max = hinfo->channels_max; in hdmi_pcm_open()
1313 runtime->hw.formats = hinfo->formats; in hdmi_pcm_open()
1314 runtime->hw.rates = hinfo->rates; in hdmi_pcm_open()
1316 snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_pcm_open()
1319 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_open()
1326 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1328 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1330 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_read_pin_conn()
1331 int dev_id = per_pin->dev_id; in hdmi_read_pin_conn()
1334 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1335 codec_warn(codec, in hdmi_read_pin_conn()
1337 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1338 return -EINVAL; in hdmi_read_pin_conn()
1341 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_read_pin_conn()
1343 if (spec->intel_hsw_fixup) { in hdmi_read_pin_conn()
1344 conns = spec->num_cvts; in hdmi_read_pin_conn()
1345 memcpy(per_pin->mux_nids, spec->cvt_nids, in hdmi_read_pin_conn()
1348 conns = snd_hda_get_raw_connections(codec, pin_nid, in hdmi_read_pin_conn()
1349 per_pin->mux_nids, in hdmi_read_pin_conn()
1354 per_pin->num_mux_nids = conns; in hdmi_read_pin_conn()
1356 return 0; in hdmi_read_pin_conn()
1367 if (spec->dyn_pcm_no_legacy) in hdmi_find_pcm_slot()
1372 * platforms (with maximum of 'num_nids + dev_num - 1') in hdmi_find_pcm_slot()
1374 * The per_pin of pin_nid_idx=n and dev_id=m prefers to get pcm-n in hdmi_find_pcm_slot()
1375 * if m==0. This guarantees that dynamic pcm assignments are compatible in hdmi_find_pcm_slot()
1376 * with the legacy static per_pin-pcm assignment that existed in the in hdmi_find_pcm_slot()
1377 * days before DP-MST. in hdmi_find_pcm_slot()
1379 * Intel DP-MST prefers this legacy behavior for compatibility, too. in hdmi_find_pcm_slot()
1381 * per_pin of m!=0 prefers to get pcm=(num_nids + (m - 1)). in hdmi_find_pcm_slot()
1384 if (per_pin->dev_id == 0 || spec->intel_hsw_fixup) { in hdmi_find_pcm_slot()
1385 if (!test_bit(per_pin->pin_nid_idx, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1386 return per_pin->pin_nid_idx; in hdmi_find_pcm_slot()
1388 i = spec->num_nids + (per_pin->dev_id - 1); in hdmi_find_pcm_slot()
1389 if (i < spec->pcm_used && !(test_bit(i, &spec->pcm_bitmap))) in hdmi_find_pcm_slot()
1394 for (i = spec->num_nids; i < spec->pcm_used; i++) { in hdmi_find_pcm_slot()
1395 if (!test_bit(i, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1401 for (i = 0; i < spec->pcm_used; i++) { in hdmi_find_pcm_slot()
1402 if (!test_bit(i, &spec->pcm_bitmap)) in hdmi_find_pcm_slot()
1405 return -EBUSY; in hdmi_find_pcm_slot()
1414 if (per_pin->pcm) in hdmi_attach_hda_pcm()
1417 if (idx == -EBUSY) in hdmi_attach_hda_pcm()
1419 per_pin->pcm_idx = idx; in hdmi_attach_hda_pcm()
1420 per_pin->pcm = get_hdmi_pcm(spec, idx); in hdmi_attach_hda_pcm()
1421 set_bit(idx, &spec->pcm_bitmap); in hdmi_attach_hda_pcm()
1430 if (!per_pin->pcm) in hdmi_detach_hda_pcm()
1432 idx = per_pin->pcm_idx; in hdmi_detach_hda_pcm()
1433 per_pin->pcm_idx = -1; in hdmi_detach_hda_pcm()
1434 per_pin->pcm = NULL; in hdmi_detach_hda_pcm()
1435 if (idx >= 0 && idx < spec->pcm_used) in hdmi_detach_hda_pcm()
1436 clear_bit(idx, &spec->pcm_bitmap); in hdmi_detach_hda_pcm()
1444 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++) in hdmi_get_pin_cvt_mux()
1445 if (per_pin->mux_nids[mux_idx] == cvt_nid) in hdmi_get_pin_cvt_mux()
1450 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1455 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1462 if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used) in hdmi_pcm_setup_pin()
1463 pcm = get_pcm_rec(spec, per_pin->pcm_idx); in hdmi_pcm_setup_pin()
1466 if (!pcm->pcm) in hdmi_pcm_setup_pin()
1468 if (!test_bit(per_pin->pcm_idx, &spec->pcm_in_use)) in hdmi_pcm_setup_pin()
1472 hinfo = pcm->stream; in hdmi_pcm_setup_pin()
1473 substream = pcm->pcm->streams[0].substream; in hdmi_pcm_setup_pin()
1475 per_pin->cvt_nid = hinfo->nid; in hdmi_pcm_setup_pin()
1477 mux_idx = hdmi_get_pin_cvt_mux(spec, per_pin, hinfo->nid); in hdmi_pcm_setup_pin()
1478 if (mux_idx < per_pin->num_mux_nids) { in hdmi_pcm_setup_pin()
1479 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1480 per_pin->dev_id); in hdmi_pcm_setup_pin()
1481 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1485 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1487 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1488 if (substream->runtime) in hdmi_pcm_setup_pin()
1489 per_pin->channels = substream->runtime->channels; in hdmi_pcm_setup_pin()
1490 per_pin->setup = true; in hdmi_pcm_setup_pin()
1491 per_pin->mux_idx = mux_idx; in hdmi_pcm_setup_pin()
1493 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1499 if (per_pin->pcm_idx >= 0 && per_pin->pcm_idx < spec->pcm_used) in hdmi_pcm_reset_pin()
1500 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1502 per_pin->chmap_set = false; in hdmi_pcm_reset_pin()
1503 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_reset_pin()
1505 per_pin->setup = false; in hdmi_pcm_reset_pin()
1506 per_pin->channels = 0; in hdmi_pcm_reset_pin()
1509 static struct snd_jack *pin_idx_to_pcm_jack(struct hda_codec *codec, in pin_idx_to_pcm_jack() argument
1512 struct hdmi_spec *spec = codec->spec; in pin_idx_to_pcm_jack()
1514 if (per_pin->pcm_idx >= 0) in pin_idx_to_pcm_jack()
1515 return spec->pcm_rec[per_pin->pcm_idx].jack; in pin_idx_to_pcm_jack()
1524 static void update_eld(struct hda_codec *codec, in update_eld() argument
1529 struct hdmi_eld *pin_eld = &per_pin->sink_eld; in update_eld()
1530 struct hdmi_spec *spec = codec->spec; in update_eld()
1532 bool old_eld_valid = pin_eld->eld_valid; in update_eld()
1536 if (eld->eld_valid) { in update_eld()
1537 if (eld->eld_size <= 0 || in update_eld()
1538 snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in update_eld()
1539 eld->eld_size) < 0) { in update_eld()
1540 eld->eld_valid = false; in update_eld()
1542 schedule_delayed_work(&per_pin->work, in update_eld()
1549 if (!eld->eld_valid || eld->eld_size <= 0) { in update_eld()
1550 eld->eld_valid = false; in update_eld()
1551 eld->eld_size = 0; in update_eld()
1555 pcm_idx = per_pin->pcm_idx; in update_eld()
1558 * pcm_idx >=0 before update_eld() means it is in monitor in update_eld()
1561 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1563 if (spec->dyn_pcm_assign) { in update_eld()
1564 if (eld->eld_valid) { in update_eld()
1572 /* if pcm_idx == -1, it means this is in monitor connection event in update_eld()
1575 if (pcm_idx == -1) in update_eld()
1576 pcm_idx = per_pin->pcm_idx; in update_eld()
1578 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1580 if (eld->eld_valid) in update_eld()
1581 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1583 eld_changed = (pin_eld->eld_valid != eld->eld_valid); in update_eld()
1584 eld_changed |= (pin_eld->monitor_present != eld->monitor_present); in update_eld()
1585 if (!eld_changed && eld->eld_valid && pin_eld->eld_valid) in update_eld()
1586 if (pin_eld->eld_size != eld->eld_size || in update_eld()
1587 memcmp(pin_eld->eld_buffer, eld->eld_buffer, in update_eld()
1588 eld->eld_size) != 0) in update_eld()
1592 pin_eld->monitor_present = eld->monitor_present; in update_eld()
1593 pin_eld->eld_valid = eld->eld_valid; in update_eld()
1594 pin_eld->eld_size = eld->eld_size; in update_eld()
1595 if (eld->eld_valid) in update_eld()
1596 memcpy(pin_eld->eld_buffer, eld->eld_buffer, in update_eld()
1597 eld->eld_size); in update_eld()
1598 pin_eld->info = eld->info; in update_eld()
1602 * Re-setup pin and infoframe. This is needed e.g. when in update_eld()
1603 * - sink is first plugged-in in update_eld()
1604 * - transcoder can change during stream playback on Haswell in update_eld()
1607 if (eld->eld_valid && !old_eld_valid && per_pin->setup) { in update_eld()
1608 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1609 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1612 if (eld_changed && pcm_idx >= 0) in update_eld()
1613 snd_ctl_notify(codec->card, in update_eld()
1616 &get_hdmi_pcm(spec, pcm_idx)->eld_ctl->id); in update_eld()
1620 (eld->monitor_present && eld->eld_valid) ? in update_eld()
1621 SND_JACK_AVOUT : 0); in update_eld()
1624 /* update ELD and jack state via HD-audio verbs */
1628 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1629 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1630 struct hdmi_eld *eld = &spec->temp_eld; in hdmi_present_sense_via_verbs()
1631 struct device *dev = hda_codec_dev(codec); in hdmi_present_sense_via_verbs()
1632 hda_nid_t pin_nid = per_pin->pin_nid; in hdmi_present_sense_via_verbs()
1633 int dev_id = per_pin->dev_id; in hdmi_present_sense_via_verbs()
1638 * the real PD value changed. An older version of the HD-audio in hdmi_present_sense_via_verbs()
1646 if (dev->power.runtime_status == RPM_SUSPENDING) in hdmi_present_sense_via_verbs()
1650 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense_via_verbs()
1651 if (ret < 0 && pm_runtime_suspended(dev)) in hdmi_present_sense_via_verbs()
1654 present = snd_hda_jack_pin_sense(codec, pin_nid, dev_id); in hdmi_present_sense_via_verbs()
1656 mutex_lock(&per_pin->lock); in hdmi_present_sense_via_verbs()
1657 eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); in hdmi_present_sense_via_verbs()
1658 if (eld->monitor_present) in hdmi_present_sense_via_verbs()
1659 eld->eld_valid = !!(present & AC_PINSENSE_ELDV); in hdmi_present_sense_via_verbs()
1661 eld->eld_valid = false; in hdmi_present_sense_via_verbs()
1663 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1664 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_present_sense_via_verbs()
1665 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1667 if (eld->eld_valid) { in hdmi_present_sense_via_verbs()
1668 if (spec->ops.pin_get_eld(codec, pin_nid, dev_id, in hdmi_present_sense_via_verbs()
1669 eld->eld_buffer, &eld->eld_size) < 0) in hdmi_present_sense_via_verbs()
1670 eld->eld_valid = false; in hdmi_present_sense_via_verbs()
1673 update_eld(codec, per_pin, eld, repoll); in hdmi_present_sense_via_verbs()
1674 mutex_unlock(&per_pin->lock); in hdmi_present_sense_via_verbs()
1676 snd_hda_power_down_pm(codec); in hdmi_present_sense_via_verbs()
1683 #define I915_SILENT_FMT_MASK 0xf
1685 static void silent_stream_enable(struct hda_codec *codec, in silent_stream_enable() argument
1688 struct hdmi_spec *spec = codec->spec; in silent_stream_enable()
1693 mutex_lock(&per_pin->lock); in silent_stream_enable()
1695 if (per_pin->setup) { in silent_stream_enable()
1696 codec_dbg(codec, "hdmi: PCM already open, no silent stream\n"); in silent_stream_enable()
1700 pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1701 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in silent_stream_enable()
1703 codec_err(codec, "hdmi: no free converter to enable silent mode\n"); in silent_stream_enable()
1708 per_cvt->assigned = 1; in silent_stream_enable()
1709 per_pin->cvt_nid = per_cvt->cvt_nid; in silent_stream_enable()
1710 per_pin->silent_stream = true; in silent_stream_enable()
1712 codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_enable()
1713 per_pin->pin_nid, per_cvt->cvt_nid); in silent_stream_enable()
1715 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1716 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1718 per_pin->mux_idx); in silent_stream_enable()
1721 pin_cvt_fixup(codec, per_pin, 0); in silent_stream_enable()
1723 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in silent_stream_enable()
1724 per_pin->dev_id, I915_SILENT_RATE); in silent_stream_enable()
1728 I915_SILENT_FORMAT, I915_SILENT_FORMAT_BITS, 0); in silent_stream_enable()
1729 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, in silent_stream_enable()
1732 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format); in silent_stream_enable()
1734 per_pin->channels = I915_SILENT_CHANNELS; in silent_stream_enable()
1735 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable()
1738 mutex_unlock(&per_pin->lock); in silent_stream_enable()
1741 static void silent_stream_disable(struct hda_codec *codec, in silent_stream_disable() argument
1744 struct hdmi_spec *spec = codec->spec; in silent_stream_disable()
1748 mutex_lock(&per_pin->lock); in silent_stream_disable()
1749 if (!per_pin->silent_stream) in silent_stream_disable()
1752 codec_dbg(codec, "HDMI: disable silent stream on pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_disable()
1753 per_pin->pin_nid, per_pin->cvt_nid); in silent_stream_disable()
1755 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in silent_stream_disable()
1756 if (cvt_idx >= 0 && cvt_idx < spec->num_cvts) { in silent_stream_disable()
1758 per_cvt->assigned = 0; in silent_stream_disable()
1761 per_pin->cvt_nid = 0; in silent_stream_disable()
1762 per_pin->silent_stream = false; in silent_stream_disable()
1765 mutex_unlock(&per_pin->lock); in silent_stream_disable()
1769 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1772 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1773 struct hdmi_eld *eld = &spec->temp_eld; in sync_eld_via_acomp()
1776 mutex_lock(&per_pin->lock); in sync_eld_via_acomp()
1777 eld->monitor_present = false; in sync_eld_via_acomp()
1778 monitor_prev = per_pin->sink_eld.monitor_present; in sync_eld_via_acomp()
1779 eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1780 per_pin->dev_id, &eld->monitor_present, in sync_eld_via_acomp()
1781 eld->eld_buffer, ELD_MAX_SIZE); in sync_eld_via_acomp()
1782 eld->eld_valid = (eld->eld_size > 0); in sync_eld_via_acomp()
1783 update_eld(codec, per_pin, eld, 0); in sync_eld_via_acomp()
1784 monitor_next = per_pin->sink_eld.monitor_present; in sync_eld_via_acomp()
1785 mutex_unlock(&per_pin->lock); in sync_eld_via_acomp()
1788 * Power-up will call hdmi_present_sense, so the PM calls in sync_eld_via_acomp()
1792 if (spec->send_silent_stream) { in sync_eld_via_acomp()
1796 pm_ret = snd_hda_power_up_pm(codec); in sync_eld_via_acomp()
1797 if (pm_ret < 0) in sync_eld_via_acomp()
1798 codec_err(codec, in sync_eld_via_acomp()
1799 "Monitor plugged-in, Failed to power up codec ret=[%d]\n", in sync_eld_via_acomp()
1801 silent_stream_enable(codec, per_pin); in sync_eld_via_acomp()
1803 silent_stream_disable(codec, per_pin); in sync_eld_via_acomp()
1804 pm_ret = snd_hda_power_down_pm(codec); in sync_eld_via_acomp()
1805 if (pm_ret < 0) in sync_eld_via_acomp()
1806 codec_err(codec, in sync_eld_via_acomp()
1807 "Monitor plugged-out, Failed to power down codec ret=[%d]\n", in sync_eld_via_acomp()
1815 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1817 if (!codec_has_acomp(codec)) in hdmi_present_sense()
1820 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1827 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1828 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1831 jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, in hdmi_repoll_eld()
1832 per_pin->dev_id); in hdmi_repoll_eld()
1834 jack->jack_dirty = 1; in hdmi_repoll_eld()
1836 if (per_pin->repoll_count++ > 6) in hdmi_repoll_eld()
1837 per_pin->repoll_count = 0; in hdmi_repoll_eld()
1839 mutex_lock(&spec->pcm_lock); in hdmi_repoll_eld()
1840 hdmi_present_sense(per_pin, per_pin->repoll_count); in hdmi_repoll_eld()
1841 mutex_unlock(&spec->pcm_lock); in hdmi_repoll_eld()
1844 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1846 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1853 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1855 return 0; in hdmi_add_pin()
1861 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1863 !spec->force_connect) in hdmi_add_pin()
1864 return 0; in hdmi_add_pin()
1870 if (spec->intel_hsw_fixup) { in hdmi_add_pin()
1881 spec->dev_num = 3; in hdmi_add_pin()
1882 } else if (spec->dyn_pcm_assign && codec->dp_mst) { in hdmi_add_pin()
1883 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1885 * spec->dev_num is the maxinum number of device entries in hdmi_add_pin()
1888 spec->dev_num = (spec->dev_num > dev_num) ? in hdmi_add_pin()
1889 spec->dev_num : dev_num; in hdmi_add_pin()
1897 spec->dev_num = 1; in hdmi_add_pin()
1900 for (i = 0; i < dev_num; i++) { in hdmi_add_pin()
1901 pin_idx = spec->num_pins; in hdmi_add_pin()
1902 per_pin = snd_array_new(&spec->pins); in hdmi_add_pin()
1905 return -ENOMEM; in hdmi_add_pin()
1907 if (spec->dyn_pcm_assign) { in hdmi_add_pin()
1908 per_pin->pcm = NULL; in hdmi_add_pin()
1909 per_pin->pcm_idx = -1; in hdmi_add_pin()
1911 per_pin->pcm = get_hdmi_pcm(spec, pin_idx); in hdmi_add_pin()
1912 per_pin->pcm_idx = pin_idx; in hdmi_add_pin()
1914 per_pin->pin_nid = pin_nid; in hdmi_add_pin()
1915 per_pin->pin_nid_idx = spec->num_nids; in hdmi_add_pin()
1916 per_pin->dev_id = i; in hdmi_add_pin()
1917 per_pin->non_pcm = false; in hdmi_add_pin()
1918 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1919 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1920 if (err < 0) in hdmi_add_pin()
1922 spec->num_pins++; in hdmi_add_pin()
1924 spec->num_nids++; in hdmi_add_pin()
1926 return 0; in hdmi_add_pin()
1929 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1931 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1936 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1939 per_cvt = snd_array_new(&spec->cvts); in hdmi_add_cvt()
1941 return -ENOMEM; in hdmi_add_cvt()
1943 per_cvt->cvt_nid = cvt_nid; in hdmi_add_cvt()
1944 per_cvt->channels_min = 2; in hdmi_add_cvt()
1946 per_cvt->channels_max = chans; in hdmi_add_cvt()
1947 if (chans > spec->chmap.channels_max) in hdmi_add_cvt()
1948 spec->chmap.channels_max = chans; in hdmi_add_cvt()
1951 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1952 &per_cvt->rates, in hdmi_add_cvt()
1953 &per_cvt->formats, in hdmi_add_cvt()
1954 &per_cvt->maxbps); in hdmi_add_cvt()
1955 if (err < 0) in hdmi_add_cvt()
1958 if (spec->num_cvts < ARRAY_SIZE(spec->cvt_nids)) in hdmi_add_cvt()
1959 spec->cvt_nids[spec->num_cvts] = cvt_nid; in hdmi_add_cvt()
1960 spec->num_cvts++; in hdmi_add_cvt()
1962 return 0; in hdmi_add_cvt()
1966 SND_PCI_QUIRK(0x103c, 0x870f, "HP", 1),
1967 SND_PCI_QUIRK(0x103c, 0x871a, "HP", 1),
1968 SND_PCI_QUIRK(0x103c, 0x8711, "HP", 1),
1969 SND_PCI_QUIRK(0x103c, 0x8715, "HP", 1),
1970 SND_PCI_QUIRK(0x1043, 0x86ae, "ASUS", 1), /* Z170 PRO */
1971 SND_PCI_QUIRK(0x1043, 0x86c7, "ASUS", 1), /* Z170M PLUS */
1972 SND_PCI_QUIRK(0x1462, 0xec94, "MS-7C94", 1),
1973 SND_PCI_QUIRK(0x8086, 0x2060, "Intel NUC5CPYB", 1),
1974 SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", 1),
1978 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1980 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
1986 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
1987 if (!start_nid || nodes < 0) { in hdmi_parse_codec()
1988 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1989 return -EINVAL; in hdmi_parse_codec()
1992 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
1994 if (q && q->value) in hdmi_parse_codec()
1995 spec->force_connect = true; in hdmi_parse_codec()
2001 for (i = 0; i < nodes; i++) { in hdmi_parse_codec()
2004 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2010 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
2014 for (i = 0; i < nodes; i++) { in hdmi_parse_codec()
2017 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2023 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
2026 return 0; in hdmi_parse_codec()
2031 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
2036 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2037 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
2042 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2045 non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO); in check_non_pcm_per_cvt()
2046 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2055 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
2060 hda_nid_t cvt_nid = hinfo->nid; in generic_hdmi_playback_pcm_prepare()
2061 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
2064 struct snd_pcm_runtime *runtime = substream->runtime; in generic_hdmi_playback_pcm_prepare()
2067 int err = 0; in generic_hdmi_playback_pcm_prepare()
2069 mutex_lock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2070 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
2071 if (spec->dyn_pcm_assign && pin_idx < 0) { in generic_hdmi_playback_pcm_prepare()
2073 * skip pin setup and return 0 to make audio playback in generic_hdmi_playback_pcm_prepare()
2076 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2077 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
2078 stream_tag, 0, format); in generic_hdmi_playback_pcm_prepare()
2082 if (snd_BUG_ON(pin_idx < 0)) { in generic_hdmi_playback_pcm_prepare()
2083 err = -EINVAL; in generic_hdmi_playback_pcm_prepare()
2096 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
2100 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
2101 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2102 per_pin->dev_id, runtime->rate); in generic_hdmi_playback_pcm_prepare()
2104 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2105 mutex_lock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2106 per_pin->channels = substream->runtime->channels; in generic_hdmi_playback_pcm_prepare()
2107 per_pin->setup = true; in generic_hdmi_playback_pcm_prepare()
2109 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
2110 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2112 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
2117 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
2118 mutex_unlock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2119 if (spec->dyn_pin_out) { in generic_hdmi_playback_pcm_prepare()
2120 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2121 per_pin->dev_id); in generic_hdmi_playback_pcm_prepare()
2122 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2123 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); in generic_hdmi_playback_pcm_prepare()
2124 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2130 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2131 per_pin->dev_id, stream_tag, format); in generic_hdmi_playback_pcm_prepare()
2133 mutex_unlock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2138 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
2141 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2142 return 0; in generic_hdmi_playback_pcm_cleanup()
2146 struct hda_codec *codec, in hdmi_pcm_close() argument
2149 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2154 int err = 0; in hdmi_pcm_close()
2156 mutex_lock(&spec->pcm_lock); in hdmi_pcm_close()
2157 if (hinfo->nid) { in hdmi_pcm_close()
2158 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
2159 if (snd_BUG_ON(pcm_idx < 0)) { in hdmi_pcm_close()
2160 err = -EINVAL; in hdmi_pcm_close()
2163 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2164 if (snd_BUG_ON(cvt_idx < 0)) { in hdmi_pcm_close()
2165 err = -EINVAL; in hdmi_pcm_close()
2169 per_cvt->assigned = 0; in hdmi_pcm_close()
2170 hinfo->nid = 0; in hdmi_pcm_close()
2172 azx_stream(get_azx_dev(substream))->stripe = 0; in hdmi_pcm_close()
2174 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
2175 clear_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_close()
2176 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
2177 if (spec->dyn_pcm_assign && pin_idx < 0) in hdmi_pcm_close()
2180 if (snd_BUG_ON(pin_idx < 0)) { in hdmi_pcm_close()
2181 err = -EINVAL; in hdmi_pcm_close()
2186 if (spec->dyn_pin_out) { in hdmi_pcm_close()
2187 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2188 per_pin->dev_id); in hdmi_pcm_close()
2189 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2190 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); in hdmi_pcm_close()
2191 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2196 mutex_lock(&per_pin->lock); in hdmi_pcm_close()
2197 per_pin->chmap_set = false; in hdmi_pcm_close()
2198 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_close()
2200 per_pin->setup = false; in hdmi_pcm_close()
2201 per_pin->channels = 0; in hdmi_pcm_close()
2202 mutex_unlock(&per_pin->lock); in hdmi_pcm_close()
2206 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_close()
2220 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_spk_alloc() local
2221 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2225 return 0; in hdmi_get_spk_alloc()
2227 return per_pin->sink_eld.info.spk_alloc; in hdmi_get_spk_alloc()
2233 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_chmap() local
2234 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2237 /* chmap is already set to 0 in caller */ in hdmi_get_chmap()
2241 memcpy(chmap, per_pin->chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_get_chmap()
2247 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_set_chmap() local
2248 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2253 mutex_lock(&per_pin->lock); in hdmi_set_chmap()
2254 per_pin->chmap_set = true; in hdmi_set_chmap()
2255 memcpy(per_pin->chmap, chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_set_chmap()
2257 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2258 mutex_unlock(&per_pin->lock); in hdmi_set_chmap()
2263 struct hda_codec *codec = hdac_to_hda_codec(hdac); in is_hdmi_pcm_attached() local
2264 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2270 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2272 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2276 * for non-mst mode, pcm number is the same as before in generic_hdmi_build_pcms()
2279 * (nid number + dev_num - 1) in generic_hdmi_build_pcms()
2283 if (spec->dyn_pcm_no_legacy && codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2284 pcm_num = spec->num_cvts; in generic_hdmi_build_pcms()
2285 else if (codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2286 pcm_num = spec->num_nids; in generic_hdmi_build_pcms()
2288 pcm_num = spec->num_nids + spec->dev_num - 1; in generic_hdmi_build_pcms()
2290 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); in generic_hdmi_build_pcms()
2292 for (idx = 0; idx < pcm_num; idx++) { in generic_hdmi_build_pcms()
2296 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2298 return -ENOMEM; in generic_hdmi_build_pcms()
2300 spec->pcm_rec[idx].pcm = info; in generic_hdmi_build_pcms()
2301 spec->pcm_used++; in generic_hdmi_build_pcms()
2302 info->pcm_type = HDA_PCM_TYPE_HDMI; in generic_hdmi_build_pcms()
2303 info->own_chmap = true; in generic_hdmi_build_pcms()
2305 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in generic_hdmi_build_pcms()
2306 pstr->substreams = 1; in generic_hdmi_build_pcms()
2307 pstr->ops = generic_ops; in generic_hdmi_build_pcms()
2309 if (spec->pcm_used >= 16) in generic_hdmi_build_pcms()
2314 return 0; in generic_hdmi_build_pcms()
2319 struct hdmi_pcm *pcm = jack->private_data; in free_hdmi_jack_priv()
2321 pcm->jack = NULL; in free_hdmi_jack_priv()
2324 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2327 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2330 int pcmdev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_jack()
2333 if (pcmdev > 0) in generic_hdmi_build_jack()
2335 if (!spec->dyn_pcm_assign && in generic_hdmi_build_jack()
2336 !is_jack_detectable(codec, per_pin->pin_nid)) in generic_hdmi_build_jack()
2338 sizeof(hdmi_str) - strlen(hdmi_str) - 1); in generic_hdmi_build_jack()
2340 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2342 if (err < 0) in generic_hdmi_build_jack()
2345 spec->pcm_rec[pcm_idx].jack = jack; in generic_hdmi_build_jack()
2346 jack->private_data = &spec->pcm_rec[pcm_idx]; in generic_hdmi_build_jack()
2347 jack->private_free = free_hdmi_jack_priv; in generic_hdmi_build_jack()
2348 return 0; in generic_hdmi_build_jack()
2351 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2353 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2357 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2358 if (!get_pcm_rec(spec, pcm_idx)->pcm) { in generic_hdmi_build_controls()
2360 set_bit(pcm_idx, &spec->pcm_bitmap); in generic_hdmi_build_controls()
2364 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2365 if (err < 0) in generic_hdmi_build_controls()
2371 if (spec->dyn_pcm_assign) in generic_hdmi_build_controls()
2372 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2373 0, spec->cvt_nids[0], in generic_hdmi_build_controls()
2378 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2379 per_pin->pin_nid, in generic_hdmi_build_controls()
2380 per_pin->mux_nids[0], in generic_hdmi_build_controls()
2383 if (err < 0) in generic_hdmi_build_controls()
2385 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2387 dev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_controls()
2390 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2391 if (err < 0) in generic_hdmi_build_controls()
2396 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_build_controls()
2398 struct hdmi_eld *pin_eld = &per_pin->sink_eld; in generic_hdmi_build_controls()
2400 pin_eld->eld_valid = false; in generic_hdmi_build_controls()
2401 hdmi_present_sense(per_pin, 0); in generic_hdmi_build_controls()
2405 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2409 if (!pcm || !pcm->pcm) in generic_hdmi_build_controls()
2411 err = snd_hdac_add_chmap_ctls(pcm->pcm, pcm_idx, &spec->chmap); in generic_hdmi_build_controls()
2412 if (err < 0) in generic_hdmi_build_controls()
2416 return 0; in generic_hdmi_build_controls()
2419 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2421 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2424 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init_per_pins()
2427 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2428 mutex_init(&per_pin->lock); in generic_hdmi_init_per_pins()
2429 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); in generic_hdmi_init_per_pins()
2432 return 0; in generic_hdmi_init_per_pins()
2435 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2437 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2440 mutex_lock(&spec->bind_lock); in generic_hdmi_init()
2441 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init()
2443 hda_nid_t pin_nid = per_pin->pin_nid; in generic_hdmi_init()
2444 int dev_id = per_pin->dev_id; in generic_hdmi_init()
2446 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2447 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2448 if (codec_has_acomp(codec)) in generic_hdmi_init()
2450 snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id, in generic_hdmi_init()
2453 mutex_unlock(&spec->bind_lock); in generic_hdmi_init()
2454 return 0; in generic_hdmi_init()
2459 snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums); in hdmi_array_init()
2460 snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums); in hdmi_array_init()
2465 snd_array_free(&spec->pins); in hdmi_array_free()
2466 snd_array_free(&spec->cvts); in hdmi_array_free()
2469 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2471 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2476 codec->spec = NULL; in generic_spec_free()
2478 codec->dp_mst = false; in generic_spec_free()
2481 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2483 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2486 if (spec->acomp_registered) { in generic_hdmi_free()
2487 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2488 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2489 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2491 codec->relaxed_resume = 0; in generic_hdmi_free()
2493 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_free()
2495 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_free()
2499 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_free()
2500 if (spec->pcm_rec[pcm_idx].jack == NULL) in generic_hdmi_free()
2502 if (spec->dyn_pcm_assign) in generic_hdmi_free()
2503 snd_device_free(codec->card, in generic_hdmi_free()
2504 spec->pcm_rec[pcm_idx].jack); in generic_hdmi_free()
2506 spec->pcm_rec[pcm_idx].jack = NULL; in generic_hdmi_free()
2509 generic_spec_free(codec); in generic_hdmi_free()
2513 static int generic_hdmi_suspend(struct hda_codec *codec) in generic_hdmi_suspend() argument
2515 struct hdmi_spec *spec = codec->spec; in generic_hdmi_suspend()
2518 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_suspend()
2520 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_suspend()
2522 return 0; in generic_hdmi_suspend()
2525 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2527 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2530 codec->patch_ops.init(codec); in generic_hdmi_resume()
2531 snd_hda_regmap_sync(codec); in generic_hdmi_resume()
2533 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_resume()
2537 return 0; in generic_hdmi_resume()
2560 /* allocate codec->spec and assign/initialize generic parser ops */
2561 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2567 return -ENOMEM; in alloc_generic_hdmi()
2569 spec->codec = codec; in alloc_generic_hdmi()
2570 spec->ops = generic_standard_hdmi_ops; in alloc_generic_hdmi()
2571 spec->dev_num = 1; /* initialize to 1 */ in alloc_generic_hdmi()
2572 mutex_init(&spec->pcm_lock); in alloc_generic_hdmi()
2573 mutex_init(&spec->bind_lock); in alloc_generic_hdmi()
2574 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2576 spec->chmap.ops.get_chmap = hdmi_get_chmap; in alloc_generic_hdmi()
2577 spec->chmap.ops.set_chmap = hdmi_set_chmap; in alloc_generic_hdmi()
2578 spec->chmap.ops.is_pcm_attached = is_hdmi_pcm_attached; in alloc_generic_hdmi()
2579 spec->chmap.ops.get_spk_alloc = hdmi_get_spk_alloc; in alloc_generic_hdmi()
2581 codec->spec = spec; in alloc_generic_hdmi()
2584 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2586 return 0; in alloc_generic_hdmi()
2590 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2594 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2595 if (err < 0) in patch_generic_hdmi()
2598 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2599 if (err < 0) { in patch_generic_hdmi()
2600 generic_spec_free(codec); in patch_generic_hdmi()
2604 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2605 return 0; in patch_generic_hdmi()
2613 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2618 tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in reprogram_jack_detect()
2620 /* clear unsol even if component notifier is used, or re-enable in reprogram_jack_detect()
2623 unsigned int val = use_acomp ? 0 : (AC_USRSP_EN | tbl->tag); in reprogram_jack_detect()
2624 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2636 spec = container_of(acomp->audio_ops, struct hdmi_spec, drm_audio_ops); in generic_acomp_notifier_set()
2637 mutex_lock(&spec->bind_lock); in generic_acomp_notifier_set()
2638 spec->use_acomp_notifier = use_acomp; in generic_acomp_notifier_set()
2639 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2640 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2642 for (i = 0; i < spec->num_pins; i++) in generic_acomp_notifier_set()
2643 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2644 get_pin(spec, i)->pin_nid, in generic_acomp_notifier_set()
2645 get_pin(spec, i)->dev_id, in generic_acomp_notifier_set()
2647 mutex_unlock(&spec->bind_lock); in generic_acomp_notifier_set()
2655 return 0; in generic_acomp_master_bind()
2664 /* check whether both HD-audio and DRM PCI devices belong to the same bus */
2670 if (!dev_is_pci(dev) || !dev_is_pci(bus->dev)) in match_bound_vga()
2671 return 0; in match_bound_vga()
2672 master = to_pci_dev(bus->dev); in match_bound_vga()
2674 return master->bus == pci->bus; in match_bound_vga()
2680 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2681 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2682 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2686 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2691 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in generic_acomp_pin_eld_notify()
2694 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2698 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2701 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2703 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2709 spec->drm_audio_ops.pin2port = ops->pin2port; in setup_drm_audio_ops()
2710 spec->drm_audio_ops.pin_eld_notify = ops->pin_eld_notify; in setup_drm_audio_ops()
2711 spec->drm_audio_ops.master_bind = ops->master_bind; in setup_drm_audio_ops()
2712 spec->drm_audio_ops.master_unbind = ops->master_unbind; in setup_drm_audio_ops()
2716 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2720 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2723 codec_info(codec, "audio component disabled by module option\n"); in generic_acomp_init()
2727 spec->port2pin = port2pin; in generic_acomp_init()
2728 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2729 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2730 match_bound_vga, 0)) { in generic_acomp_init()
2731 spec->acomp_registered = true; in generic_acomp_init()
2736 * Intel codec parsers and helpers
2739 #define INTEL_GET_VENDOR_VERB 0xf81
2740 #define INTEL_SET_VENDOR_VERB 0x781
2741 #define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */
2742 #define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */
2744 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2748 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2750 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2751 INTEL_GET_VENDOR_VERB, 0); in intel_haswell_enable_all_pins()
2752 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) in intel_haswell_enable_all_pins()
2756 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2758 if (vendor_param == -1) in intel_haswell_enable_all_pins()
2762 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2765 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2768 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2770 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2771 INTEL_GET_VENDOR_VERB, 0); in intel_haswell_fixup_enable_dp12()
2772 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) in intel_haswell_fixup_enable_dp12()
2777 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2778 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2782 /* Haswell needs to re-issue the vendor-specific verbs before turning to D0.
2785 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2789 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2790 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2793 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2794 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2799 * Pin Widget 5 - PORT B (port = 1 in i915 driver)
2800 * Pin Widget 6 - PORT C (port = 2 in i915 driver)
2801 * Pin Widget 7 - PORT D (port = 3 in i915 driver)
2804 * Pin Widget 4 - PORT B (port = 1 in i915 driver)
2805 * Pin Widget 5 - PORT C (port = 2 in i915 driver)
2806 * Pin Widget 6 - PORT D (port = 3 in i915 driver)
2808 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2810 switch (codec->core.vendor_id) { in intel_base_nid()
2811 case 0x80860054: /* ILK */ in intel_base_nid()
2812 case 0x80862804: /* ILK */ in intel_base_nid()
2813 case 0x80862882: /* VLV */ in intel_base_nid()
2822 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2823 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2826 if (!spec->port_num) { in intel_pin2port()
2827 base_nid = intel_base_nid(codec); in intel_pin2port()
2829 return -1; in intel_pin2port()
2830 return pin_nid - base_nid + 1; in intel_pin2port()
2837 for (i = 0; i < spec->port_num; i++) { in intel_pin2port()
2838 if (pin_nid == spec->port_map[i]) in intel_pin2port()
2842 codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid); in intel_pin2port()
2843 return -1; in intel_pin2port()
2846 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2848 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2850 if (!spec->port_num) { in intel_port2pin()
2851 /* we assume only from port-B to port-D */ in intel_port2pin()
2853 return 0; in intel_port2pin()
2854 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2857 if (port < 0 || port >= spec->port_num) in intel_port2pin()
2858 return 0; in intel_port2pin()
2859 return spec->port_map[port]; in intel_port2pin()
2864 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2868 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2874 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
2877 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2878 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2887 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2889 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2891 spec->use_acomp_notifier = true; in register_i915_notifier()
2892 spec->port2pin = intel_port2pin; in register_i915_notifier()
2893 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2894 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2895 &spec->drm_audio_ops); in register_i915_notifier()
2897 codec->relaxed_resume = 1; in register_i915_notifier()
2901 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2905 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2906 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
2911 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2916 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2917 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2918 per_pin->dev_id); in i915_pin_cvt_fixup()
2919 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2920 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2921 per_pin->dev_id, per_pin->mux_idx); in i915_pin_cvt_fixup()
2923 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2928 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2933 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2934 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2936 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2937 return -ENODEV; in alloc_intel_hdmi()
2940 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2941 if (err < 0) in alloc_intel_hdmi()
2944 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
2945 return 0; in alloc_intel_hdmi()
2948 /* parse and post-process for Intel codecs */
2949 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2954 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2955 } while (err < 0 && retries--); in parse_intel_hdmi()
2957 if (err < 0) { in parse_intel_hdmi()
2958 generic_spec_free(codec); in parse_intel_hdmi()
2962 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2963 register_i915_notifier(codec); in parse_intel_hdmi()
2964 return 0; in parse_intel_hdmi()
2968 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
2974 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2975 if (err < 0) in intel_hsw_common_init()
2977 spec = codec->spec; in intel_hsw_common_init()
2978 codec->dp_mst = true; in intel_hsw_common_init()
2979 spec->dyn_pcm_assign = true; in intel_hsw_common_init()
2980 spec->vendor_nid = vendor_nid; in intel_hsw_common_init()
2981 spec->port_map = port_map; in intel_hsw_common_init()
2982 spec->port_num = port_num; in intel_hsw_common_init()
2983 spec->intel_hsw_fixup = true; in intel_hsw_common_init()
2985 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2986 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2988 codec->display_power_control = 1; in intel_hsw_common_init()
2990 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2991 codec->depop_delay = 0; in intel_hsw_common_init()
2992 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2994 spec->ops.setup_stream = i915_hsw_setup_stream; in intel_hsw_common_init()
2995 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in intel_hsw_common_init()
3002 spec->send_silent_stream = true; in intel_hsw_common_init()
3004 return parse_intel_hdmi(codec); in intel_hsw_common_init()
3007 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
3009 return intel_hsw_common_init(codec, 0x08, NULL, 0); in patch_i915_hsw_hdmi()
3012 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
3014 return intel_hsw_common_init(codec, 0x0b, NULL, 0); in patch_i915_glk_hdmi()
3017 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
3023 static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb}; in patch_i915_icl_hdmi()
3025 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_icl_hdmi()
3028 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
3034 static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; in patch_i915_tgl_hdmi()
3037 ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_tgl_hdmi()
3039 struct hdmi_spec *spec = codec->spec; in patch_i915_tgl_hdmi()
3041 spec->dyn_pcm_no_legacy = true; in patch_i915_tgl_hdmi()
3048 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
3053 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
3054 if (err < 0) in patch_i915_byt_hdmi()
3056 spec = codec->spec; in patch_i915_byt_hdmi()
3058 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
3061 codec->display_power_control = 1; in patch_i915_byt_hdmi()
3063 codec->depop_delay = 0; in patch_i915_byt_hdmi()
3064 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
3066 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in patch_i915_byt_hdmi()
3068 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
3072 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
3076 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3077 if (err < 0) in patch_i915_cpt_hdmi()
3079 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3083 * Shared non-generic implementations
3086 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
3088 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
3094 per_cvt = get_cvt(spec, 0); in simple_playback_build_pcms()
3095 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
3098 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
3100 return -ENOMEM; in simple_playback_build_pcms()
3101 spec->pcm_rec[0].pcm = info; in simple_playback_build_pcms()
3102 info->pcm_type = HDA_PCM_TYPE_HDMI; in simple_playback_build_pcms()
3103 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in simple_playback_build_pcms()
3104 *pstr = spec->pcm_playback; in simple_playback_build_pcms()
3105 pstr->nid = per_cvt->cvt_nid; in simple_playback_build_pcms()
3106 if (pstr->channels_max <= 2 && chans && chans <= 16) in simple_playback_build_pcms()
3107 pstr->channels_max = chans; in simple_playback_build_pcms()
3109 return 0; in simple_playback_build_pcms()
3113 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
3116 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
3117 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
3121 * as long as spec->pins[] is set correctly
3125 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
3127 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3131 per_cvt = get_cvt(spec, 0); in simple_playback_build_controls()
3132 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3133 per_cvt->cvt_nid, in simple_playback_build_controls()
3135 if (err < 0) in simple_playback_build_controls()
3137 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
3140 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
3142 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3143 struct hdmi_spec_per_pin *per_pin = get_pin(spec, 0); in simple_playback_init()
3144 hda_nid_t pin = per_pin->pin_nid; in simple_playback_init()
3146 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
3149 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
3150 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
3152 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3153 return 0; in simple_playback_init()
3156 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
3158 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3168 #define Nv_VERB_SET_Channel_Allocation 0xF79
3169 #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A
3170 #define Nv_VERB_SET_Audio_Protection_On 0xF98
3171 #define Nv_VERB_SET_Audio_Protection_Off 0xF99
3173 #define nvhdmi_master_con_nid_7x 0x04
3174 #define nvhdmi_master_pin_nid_7x 0x05
3178 0x6, 0x8, 0xa, 0xc,
3183 { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
3185 { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3191 { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
3193 { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3194 { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3195 { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3196 { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3197 { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3217 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3219 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3220 return 0; in nvhdmi_7x_init_2ch()
3223 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3225 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3226 return 0; in nvhdmi_7x_init_8ch()
3240 .mask = 0,
3246 .mask = 0,
3250 struct hda_codec *codec, in simple_playback_pcm_open() argument
3253 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3256 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3257 case 0x10de0002: in simple_playback_pcm_open()
3258 case 0x10de0003: in simple_playback_pcm_open()
3259 case 0x10de0005: in simple_playback_pcm_open()
3260 case 0x10de0006: in simple_playback_pcm_open()
3263 case 0x10de0007: in simple_playback_pcm_open()
3271 snd_pcm_hw_constraint_list(substream->runtime, 0, in simple_playback_pcm_open()
3275 snd_pcm_hw_constraint_step(substream->runtime, 0, in simple_playback_pcm_open()
3279 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3283 struct hda_codec *codec, in simple_playback_pcm_close() argument
3286 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3287 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3291 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3296 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3297 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3320 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3329 return -ENOMEM; in patch_simple_hdmi()
3331 spec->codec = codec; in patch_simple_hdmi()
3332 codec->spec = spec; in patch_simple_hdmi()
3335 spec->multiout.num_dacs = 0; /* no analog */ in patch_simple_hdmi()
3336 spec->multiout.max_channels = 2; in patch_simple_hdmi()
3337 spec->multiout.dig_out_nid = cvt_nid; in patch_simple_hdmi()
3338 spec->num_cvts = 1; in patch_simple_hdmi()
3339 spec->num_pins = 1; in patch_simple_hdmi()
3340 per_pin = snd_array_new(&spec->pins); in patch_simple_hdmi()
3341 per_cvt = snd_array_new(&spec->cvts); in patch_simple_hdmi()
3343 simple_playback_free(codec); in patch_simple_hdmi()
3344 return -ENOMEM; in patch_simple_hdmi()
3346 per_cvt->cvt_nid = cvt_nid; in patch_simple_hdmi()
3347 per_pin->pin_nid = pin_nid; in patch_simple_hdmi()
3348 spec->pcm_playback = simple_pcm_playback; in patch_simple_hdmi()
3350 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3352 return 0; in patch_simple_hdmi()
3355 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3359 int chan = channels ? (channels - 1) : 1; in nvhdmi_8ch_7x_set_info_frame_parameters()
3363 case 0: in nvhdmi_8ch_7x_set_info_frame_parameters()
3365 chanmask = 0x00; in nvhdmi_8ch_7x_set_info_frame_parameters()
3368 chanmask = 0x08; in nvhdmi_8ch_7x_set_info_frame_parameters()
3371 chanmask = 0x0b; in nvhdmi_8ch_7x_set_info_frame_parameters()
3374 chanmask = 0x13; in nvhdmi_8ch_7x_set_info_frame_parameters()
3380 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3383 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3385 (0x71 - chan - chanmask)); in nvhdmi_8ch_7x_set_info_frame_parameters()
3389 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3392 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3395 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3396 0, AC_VERB_SET_CHANNEL_STREAMID, 0); in nvhdmi_8ch_7x_pcm_close()
3397 for (i = 0; i < 4; i++) { in nvhdmi_8ch_7x_pcm_close()
3399 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3400 AC_VERB_SET_CHANNEL_STREAMID, 0); in nvhdmi_8ch_7x_pcm_close()
3402 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3403 AC_VERB_SET_STREAM_FORMAT, 0); in nvhdmi_8ch_7x_pcm_close()
3406 /* The audio hardware sends a channel count of 0x7 (8ch) when all the in nvhdmi_8ch_7x_pcm_close()
3408 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3410 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3414 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3422 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3426 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3427 per_cvt = get_cvt(spec, 0); in nvhdmi_8ch_7x_pcm_prepare()
3428 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3430 chs = substream->runtime->channels; in nvhdmi_8ch_7x_pcm_prepare()
3432 dataDCC2 = 0x2; in nvhdmi_8ch_7x_pcm_prepare()
3435 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3436 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3438 0, in nvhdmi_8ch_7x_pcm_prepare()
3440 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3443 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3444 AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); in nvhdmi_8ch_7x_pcm_prepare()
3447 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3452 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3453 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3455 0, in nvhdmi_8ch_7x_pcm_prepare()
3457 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3458 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3460 0, in nvhdmi_8ch_7x_pcm_prepare()
3464 for (i = 0; i < 4; i++) { in nvhdmi_8ch_7x_pcm_prepare()
3466 channel_id = 0; in nvhdmi_8ch_7x_pcm_prepare()
3473 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3474 (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3475 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3477 0, in nvhdmi_8ch_7x_pcm_prepare()
3479 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3481 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3483 0, in nvhdmi_8ch_7x_pcm_prepare()
3487 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3489 0, in nvhdmi_8ch_7x_pcm_prepare()
3494 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3495 (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3496 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3498 0, in nvhdmi_8ch_7x_pcm_prepare()
3500 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3501 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3503 0, in nvhdmi_8ch_7x_pcm_prepare()
3508 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3510 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3511 return 0; in nvhdmi_8ch_7x_pcm_prepare()
3529 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3532 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3534 if (err < 0) in patch_nvhdmi_2ch()
3537 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3538 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3539 spec = codec->spec; in patch_nvhdmi_2ch()
3540 spec->pcm_playback.rates = SUPPORTED_RATES; in patch_nvhdmi_2ch()
3541 spec->pcm_playback.maxbps = SUPPORTED_MAXBPS; in patch_nvhdmi_2ch()
3542 spec->pcm_playback.formats = SUPPORTED_FORMATS; in patch_nvhdmi_2ch()
3543 spec->nv_dp_workaround = true; in patch_nvhdmi_2ch()
3544 return 0; in patch_nvhdmi_2ch()
3547 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3549 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3550 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3552 struct hda_pcm *info = get_pcm_rec(spec, 0); in nvhdmi_7x_8ch_build_pcms()
3553 info->own_chmap = true; in nvhdmi_7x_8ch_build_pcms()
3558 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3560 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3565 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3566 if (err < 0) in nvhdmi_7x_8ch_build_controls()
3570 info = get_pcm_rec(spec, 0); in nvhdmi_7x_8ch_build_controls()
3571 err = snd_pcm_add_chmap_ctls(info->pcm, in nvhdmi_7x_8ch_build_controls()
3573 snd_pcm_alt_chmaps, 8, 0, &chmap); in nvhdmi_7x_8ch_build_controls()
3574 if (err < 0) in nvhdmi_7x_8ch_build_controls()
3576 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3577 case 0x10de0002: in nvhdmi_7x_8ch_build_controls()
3578 case 0x10de0003: in nvhdmi_7x_8ch_build_controls()
3579 case 0x10de0005: in nvhdmi_7x_8ch_build_controls()
3580 case 0x10de0006: in nvhdmi_7x_8ch_build_controls()
3581 chmap->channel_mask = (1U << 2) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3583 case 0x10de0007: in nvhdmi_7x_8ch_build_controls()
3584 chmap->channel_mask = (1U << 2) | (1U << 6) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3586 return 0; in nvhdmi_7x_8ch_build_controls()
3589 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3592 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3593 if (err < 0) in patch_nvhdmi_8ch_7x()
3595 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3596 spec->multiout.max_channels = 8; in patch_nvhdmi_8ch_7x()
3597 spec->pcm_playback = nvhdmi_pcm_playback_8ch_7x; in patch_nvhdmi_8ch_7x()
3598 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3599 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3600 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3604 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3606 return 0; in patch_nvhdmi_8ch_7x()
3610 * NVIDIA codecs ignore ASP mapping for 2ch - confirmed on:
3611 * - 0x10de0015
3612 * - 0x10de0040
3617 if (cap->ca_index == 0x00 && channels == 2) in nvhdmi_chmap_cea_alloc_validate_get_type()
3621 if (cap->channels != channels) in nvhdmi_chmap_cea_alloc_validate_get_type()
3622 return -1; in nvhdmi_chmap_cea_alloc_validate_get_type()
3631 if (ca == 0x00 && (map[0] != SNDRV_CHMAP_FL || map[1] != SNDRV_CHMAP_FR)) in nvhdmi_chmap_validate()
3632 return -EINVAL; in nvhdmi_chmap_validate()
3634 return 0; in nvhdmi_chmap_validate()
3637 /* map from pin NID to port; port is 0-based */
3641 return pin_nid - 4; in nvhdmi_pin2port()
3644 /* reverse-map from port to pin NID: see above */
3645 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3657 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3662 err = alloc_generic_hdmi(codec); in patch_nvhdmi()
3663 if (err < 0) in patch_nvhdmi()
3665 codec->dp_mst = true; in patch_nvhdmi()
3667 spec = codec->spec; in patch_nvhdmi()
3668 spec->dyn_pcm_assign = true; in patch_nvhdmi()
3670 err = hdmi_parse_codec(codec); in patch_nvhdmi()
3671 if (err < 0) { in patch_nvhdmi()
3672 generic_spec_free(codec); in patch_nvhdmi()
3676 generic_hdmi_init_per_pins(codec); in patch_nvhdmi()
3678 spec->dyn_pin_out = true; in patch_nvhdmi()
3680 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi()
3682 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi()
3683 spec->nv_dp_workaround = true; in patch_nvhdmi()
3685 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3687 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3689 return 0; in patch_nvhdmi()
3692 static int patch_nvhdmi_legacy(struct hda_codec *codec) in patch_nvhdmi_legacy() argument
3697 err = patch_generic_hdmi(codec); in patch_nvhdmi_legacy()
3701 spec = codec->spec; in patch_nvhdmi_legacy()
3702 spec->dyn_pin_out = true; in patch_nvhdmi_legacy()
3704 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi_legacy()
3706 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi_legacy()
3707 spec->nv_dp_workaround = true; in patch_nvhdmi_legacy()
3709 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3711 return 0; in patch_nvhdmi_legacy()
3715 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3716 * accessed using vendor-defined verbs. These registers can be used for
3721 #define NVIDIA_AFG_NID 0x01
3724 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3726 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3727 * implementation stores the HDA format (see AC_FMT_*) in bits [15:0] and an
3730 * | 31 | 30 | 29 16 | 15 0 |
3731 * +---------+-------+--------+--------+
3733 * +-----------------------------------|
3738 #define NVIDIA_GET_SCRATCH0 0xfa6
3739 #define NVIDIA_SET_SCRATCH0_BYTE0 0xfa7
3740 #define NVIDIA_SET_SCRATCH0_BYTE1 0xfa8
3741 #define NVIDIA_SET_SCRATCH0_BYTE2 0xfa9
3742 #define NVIDIA_SET_SCRATCH0_BYTE3 0xfaa
3746 #define NVIDIA_GET_SCRATCH1 0xfab
3747 #define NVIDIA_SET_SCRATCH1_BYTE0 0xfac
3748 #define NVIDIA_SET_SCRATCH1_BYTE1 0xfad
3749 #define NVIDIA_SET_SCRATCH1_BYTE2 0xfae
3750 #define NVIDIA_SET_SCRATCH1_BYTE3 0xfaf
3753 * The format parameter is the HDA audio format (see AC_FMT_*). If set to 0,
3754 * the format is invalidated so that the HDMI codec can be disabled.
3756 static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) in tegra_hdmi_set_format() argument
3761 value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3762 NVIDIA_GET_SCRATCH0, 0); in tegra_hdmi_set_format()
3763 value = (value >> 24) & 0xff; in tegra_hdmi_set_format()
3765 /* bits [15:0] are used to store the HDA format */ in tegra_hdmi_set_format()
3766 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3768 (format >> 0) & 0xff); in tegra_hdmi_set_format()
3769 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3771 (format >> 8) & 0xff); in tegra_hdmi_set_format()
3774 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3775 NVIDIA_SET_SCRATCH0_BYTE2, 0); in tegra_hdmi_set_format()
3781 if (format == 0) in tegra_hdmi_set_format()
3788 * HDMI codec. The HDMI driver will use that as trigger to update its in tegra_hdmi_set_format()
3793 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3798 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3805 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3807 if (err < 0) in tegra_hdmi_pcm_prepare()
3810 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3811 tegra_hdmi_set_format(codec, format); in tegra_hdmi_pcm_prepare()
3813 return 0; in tegra_hdmi_pcm_prepare()
3817 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3820 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3821 tegra_hdmi_set_format(codec, 0); in tegra_hdmi_pcm_cleanup()
3823 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3826 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3828 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3831 for (i = 0; i < spec->num_pins; i++) { in hda_find_pcm_by_type()
3834 if (pcm->pcm_type == type) in hda_find_pcm_by_type()
3841 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3847 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3848 if (err < 0) in tegra_hdmi_build_pcms()
3851 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3853 return -ENODEV; in tegra_hdmi_build_pcms()
3856 * Override ->prepare() and ->cleanup() operations to notify the HDMI in tegra_hdmi_build_pcms()
3857 * codec about format changes. in tegra_hdmi_build_pcms()
3859 stream = &pcm->stream[SNDRV_PCM_STREAM_PLAYBACK]; in tegra_hdmi_build_pcms()
3860 stream->ops.prepare = tegra_hdmi_pcm_prepare; in tegra_hdmi_build_pcms()
3861 stream->ops.cleanup = tegra_hdmi_pcm_cleanup; in tegra_hdmi_build_pcms()
3863 return 0; in tegra_hdmi_build_pcms()
3866 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3871 err = patch_generic_hdmi(codec); in patch_tegra_hdmi()
3875 codec->depop_delay = 10; in patch_tegra_hdmi()
3876 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in patch_tegra_hdmi()
3877 spec = codec->spec; in patch_tegra_hdmi()
3878 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_tegra_hdmi()
3880 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_tegra_hdmi()
3881 spec->nv_dp_workaround = true; in patch_tegra_hdmi()
3883 return 0; in patch_tegra_hdmi()
3887 * ATI/AMD-specific implementations
3890 #define is_amdhdmi_rev3_or_later(codec) \ argument
3891 ((codec)->core.vendor_id == 0x1002aa01 && \
3892 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3893 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3896 #define ATI_VERB_SET_CHANNEL_ALLOCATION 0x771
3897 #define ATI_VERB_SET_DOWNMIX_INFO 0x772
3898 #define ATI_VERB_SET_MULTICHANNEL_01 0x777
3899 #define ATI_VERB_SET_MULTICHANNEL_23 0x778
3900 #define ATI_VERB_SET_MULTICHANNEL_45 0x779
3901 #define ATI_VERB_SET_MULTICHANNEL_67 0x77a
3902 #define ATI_VERB_SET_HBR_CONTROL 0x77c
3903 #define ATI_VERB_SET_MULTICHANNEL_1 0x785
3904 #define ATI_VERB_SET_MULTICHANNEL_3 0x786
3905 #define ATI_VERB_SET_MULTICHANNEL_5 0x787
3906 #define ATI_VERB_SET_MULTICHANNEL_7 0x788
3907 #define ATI_VERB_SET_MULTICHANNEL_MODE 0x789
3908 #define ATI_VERB_GET_CHANNEL_ALLOCATION 0xf71
3909 #define ATI_VERB_GET_DOWNMIX_INFO 0xf72
3910 #define ATI_VERB_GET_MULTICHANNEL_01 0xf77
3911 #define ATI_VERB_GET_MULTICHANNEL_23 0xf78
3912 #define ATI_VERB_GET_MULTICHANNEL_45 0xf79
3913 #define ATI_VERB_GET_MULTICHANNEL_67 0xf7a
3914 #define ATI_VERB_GET_HBR_CONTROL 0xf7c
3915 #define ATI_VERB_GET_MULTICHANNEL_1 0xf85
3916 #define ATI_VERB_GET_MULTICHANNEL_3 0xf86
3917 #define ATI_VERB_GET_MULTICHANNEL_5 0xf87
3918 #define ATI_VERB_GET_MULTICHANNEL_7 0xf88
3919 #define ATI_VERB_GET_MULTICHANNEL_MODE 0xf89
3922 #define ATI_VERB_SET_RAMP_RATE 0x770
3923 #define ATI_VERB_GET_RAMP_RATE 0xf70
3925 #define ATI_OUT_ENABLE 0x1
3927 #define ATI_MULTICHANNEL_MODE_PAIRED 0
3930 #define ATI_HBR_CAPABLE 0x01
3931 #define ATI_HBR_ENABLE 0x10
3933 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3936 WARN_ON(dev_id != 0); in atihdmi_pin_get_eld()
3937 /* call hda_eld.c ATI/AMD-specific function */ in atihdmi_pin_get_eld()
3938 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
3939 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
3942 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, in atihdmi_pin_setup_infoframe() argument
3946 WARN_ON(dev_id != 0); in atihdmi_pin_setup_infoframe()
3947 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3953 * ATI/AMD have automatic FC/LFE swap built-in in atihdmi_paired_swap_fc_lfe()
3973 /* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */ in atihdmi_paired_chmap_validate()
3976 for (i = 0; i < chs; ++i) { in atihdmi_paired_chmap_validate()
3984 for (j = 0 + i % 2; j < 8; j += 2) { in atihdmi_paired_chmap_validate()
3985 int chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j); in atihdmi_paired_chmap_validate()
3986 if (cap->speakers[chan_idx] == mask) { in atihdmi_paired_chmap_validate()
3990 if (i % 2 == 0 && i + 1 < chs) { in atihdmi_paired_chmap_validate()
3992 int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1); in atihdmi_paired_chmap_validate()
3994 int comp_mask_act = cap->speakers[comp_chan_idx]; in atihdmi_paired_chmap_validate()
3999 return -EINVAL; in atihdmi_paired_chmap_validate()
4006 return -EINVAL; in atihdmi_paired_chmap_validate()
4012 return 0; in atihdmi_paired_chmap_validate()
4018 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_set_slot_channel() local
4020 int ati_channel_setup = 0; in atihdmi_pin_set_slot_channel()
4023 return -EINVAL; in atihdmi_pin_set_slot_channel()
4025 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
4032 if (hdmi_slot % 2 != 0 && stream_channel == 0xf) in atihdmi_pin_set_slot_channel()
4033 return 0; in atihdmi_pin_set_slot_channel()
4035 hdmi_slot -= hdmi_slot % 2; in atihdmi_pin_set_slot_channel()
4037 if (stream_channel != 0xf) in atihdmi_pin_set_slot_channel()
4038 stream_channel -= stream_channel % 2; in atihdmi_pin_set_slot_channel()
4041 verb = ATI_VERB_SET_MULTICHANNEL_01 + hdmi_slot/2 + (hdmi_slot % 2) * 0x00e; in atihdmi_pin_set_slot_channel()
4043 /* ati_channel_setup format: [7..4] = stream_channel_id, [1] = mute, [0] = enable */ in atihdmi_pin_set_slot_channel()
4045 if (stream_channel != 0xf) in atihdmi_pin_set_slot_channel()
4048 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
4054 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_get_slot_channel() local
4061 return -EINVAL; in atihdmi_pin_get_slot_channel()
4063 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
4065 if (ati_asp_slot % 2 != 0) { in atihdmi_pin_get_slot_channel()
4066 ati_asp_slot -= 1; in atihdmi_pin_get_slot_channel()
4071 verb = ATI_VERB_GET_MULTICHANNEL_01 + ati_asp_slot/2 + (ati_asp_slot % 2) * 0x00e; in atihdmi_pin_get_slot_channel()
4073 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
4076 return 0xf; in atihdmi_pin_get_slot_channel()
4078 return ((ati_channel_setup & 0xf0) >> 4) + !!was_odd; in atihdmi_pin_get_slot_channel()
4089 * Pre-rev3 ATI/AMD codecs operate in a paired channel mode, so in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4094 int chanpairs = 0; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4096 /* We only produce even-numbered channel count TLVs */ in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4097 if ((channels % 2) != 0) in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4098 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4100 for (c = 0; c < 7; c += 2) { in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4101 if (cap->speakers[c] || cap->speakers[c+1]) in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4106 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4115 /* produce paired maps for pre-rev3 ATI/AMD codecs */ in atihdmi_paired_cea_alloc_to_tlv_chmap()
4116 int count = 0; in atihdmi_paired_cea_alloc_to_tlv_chmap()
4119 for (c = 7; c >= 0; c--) { in atihdmi_paired_cea_alloc_to_tlv_chmap()
4120 int chan = 7 - atihdmi_paired_swap_fc_lfe(7 - c); in atihdmi_paired_cea_alloc_to_tlv_chmap()
4121 int spk = cap->speakers[chan]; in atihdmi_paired_cea_alloc_to_tlv_chmap()
4124 if (cap->speakers[chan + (chan % 2 ? -1 : 1)]) in atihdmi_paired_cea_alloc_to_tlv_chmap()
4136 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
4141 WARN_ON(dev_id != 0); in atihdmi_pin_hbr_setup()
4143 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
4144 if (hbr_ctl >= 0 && (hbr_ctl & ATI_HBR_CAPABLE)) { in atihdmi_pin_hbr_setup()
4150 codec_dbg(codec, in atihdmi_pin_hbr_setup()
4151 "atihdmi_pin_hbr_setup: NID=0x%x, %shbr-ctl=0x%x\n", in atihdmi_pin_hbr_setup()
4153 hbr_ctl == hbr_ctl_new ? "" : "new-", in atihdmi_pin_hbr_setup()
4157 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
4162 return -EINVAL; in atihdmi_pin_hbr_setup()
4164 return 0; in atihdmi_pin_hbr_setup()
4167 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
4171 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
4173 /* disable ramp-up/down for non-pcm as per AMD spec */ in atihdmi_setup_stream()
4175 ramp_rate = 0; in atihdmi_setup_stream()
4177 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
4180 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in atihdmi_setup_stream()
4185 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
4187 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4190 err = generic_hdmi_init(codec); in atihdmi_init()
4195 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in atihdmi_init()
4199 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4201 /* enable channel-wise remap mode if supported */ in atihdmi_init()
4202 if (has_amd_full_remap_support(codec)) in atihdmi_init()
4203 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4207 codec->auto_runtime_pm = 1; in atihdmi_init()
4209 return 0; in atihdmi_init()
4212 /* map from pin NID to port; port is 0-based */
4216 return pin_nid / 2 - 1; in atihdmi_pin2port()
4219 /* reverse-map from port to pin NID: see above */
4220 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4232 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4238 err = patch_generic_hdmi(codec); in patch_atihdmi()
4243 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4245 spec = codec->spec; in patch_atihdmi()
4247 spec->ops.pin_get_eld = atihdmi_pin_get_eld; in patch_atihdmi()
4248 spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe; in patch_atihdmi()
4249 spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup; in patch_atihdmi()
4250 spec->ops.setup_stream = atihdmi_setup_stream; in patch_atihdmi()
4252 spec->chmap.ops.pin_get_slot_channel = atihdmi_pin_get_slot_channel; in patch_atihdmi()
4253 spec->chmap.ops.pin_set_slot_channel = atihdmi_pin_set_slot_channel; in patch_atihdmi()
4255 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4256 /* override to ATI/AMD-specific versions with pairwise mapping */ in patch_atihdmi()
4257 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_atihdmi()
4259 spec->chmap.ops.cea_alloc_to_tlv_chmap = in patch_atihdmi()
4261 spec->chmap.ops.chmap_validate = atihdmi_paired_chmap_validate; in patch_atihdmi()
4265 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in patch_atihdmi()
4267 per_cvt->channels_max = max(per_cvt->channels_max, 8u); in patch_atihdmi()
4268 per_cvt->rates |= SUPPORTED_RATES; in patch_atihdmi()
4269 per_cvt->formats |= SUPPORTED_FORMATS; in patch_atihdmi()
4270 per_cvt->maxbps = max(per_cvt->maxbps, 24u); in patch_atihdmi()
4273 spec->chmap.channels_max = max(spec->chmap.channels_max, 8u); in patch_atihdmi()
4276 * the link-down as is. Tell the core to allow it. in patch_atihdmi()
4278 codec->link_down_at_suspend = 1; in patch_atihdmi()
4280 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4282 return 0; in patch_atihdmi()
4286 #define VIAHDMI_CVT_NID 0x02 /* audio converter1 */
4287 #define VIAHDMI_PIN_NID 0x03 /* HDMI output pin1 */
4289 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4291 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4294 static int patch_gf_hdmi(struct hda_codec *codec) in patch_gf_hdmi() argument
4298 err = patch_generic_hdmi(codec); in patch_gf_hdmi()
4303 * Glenfly GPUs have two codecs, stream switches from one codec to in patch_gf_hdmi()
4304 * another, need to do actual clean-ups in codec_cleanup_stream in patch_gf_hdmi()
4306 codec->no_sticky_stream = 1; in patch_gf_hdmi()
4307 return 0; in patch_gf_hdmi()
4314 HDA_CODEC_ENTRY(0x00147a47, "Loongson HDMI", patch_generic_hdmi),
4315 HDA_CODEC_ENTRY(0x1002793c, "RS600 HDMI", patch_atihdmi),
4316 HDA_CODEC_ENTRY(0x10027919, "RS600 HDMI", patch_atihdmi),
4317 HDA_CODEC_ENTRY(0x1002791a, "RS690/780 HDMI", patch_atihdmi),
4318 HDA_CODEC_ENTRY(0x1002aa01, "R6xx HDMI", patch_atihdmi),
4319 HDA_CODEC_ENTRY(0x10951390, "SiI1390 HDMI", patch_generic_hdmi),
4320 HDA_CODEC_ENTRY(0x10951392, "SiI1392 HDMI", patch_generic_hdmi),
4321 HDA_CODEC_ENTRY(0x17e80047, "Chrontel HDMI", patch_generic_hdmi),
4322 HDA_CODEC_ENTRY(0x10de0001, "MCP73 HDMI", patch_nvhdmi_2ch),
4323 HDA_CODEC_ENTRY(0x10de0002, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
4324 HDA_CODEC_ENTRY(0x10de0003, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
4325 HDA_CODEC_ENTRY(0x10de0004, "GPU 04 HDMI", patch_nvhdmi_8ch_7x),
4326 HDA_CODEC_ENTRY(0x10de0005, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
4327 HDA_CODEC_ENTRY(0x10de0006, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
4328 HDA_CODEC_ENTRY(0x10de0007, "MCP79/7A HDMI", patch_nvhdmi_8ch_7x),
4329 HDA_CODEC_ENTRY(0x10de0008, "GPU 08 HDMI/DP", patch_nvhdmi_legacy),
4330 HDA_CODEC_ENTRY(0x10de0009, "GPU 09 HDMI/DP", patch_nvhdmi_legacy),
4331 HDA_CODEC_ENTRY(0x10de000a, "GPU 0a HDMI/DP", patch_nvhdmi_legacy),
4332 HDA_CODEC_ENTRY(0x10de000b, "GPU 0b HDMI/DP", patch_nvhdmi_legacy),
4333 HDA_CODEC_ENTRY(0x10de000c, "MCP89 HDMI", patch_nvhdmi_legacy),
4334 HDA_CODEC_ENTRY(0x10de000d, "GPU 0d HDMI/DP", patch_nvhdmi_legacy),
4335 HDA_CODEC_ENTRY(0x10de0010, "GPU 10 HDMI/DP", patch_nvhdmi_legacy),
4336 HDA_CODEC_ENTRY(0x10de0011, "GPU 11 HDMI/DP", patch_nvhdmi_legacy),
4337 HDA_CODEC_ENTRY(0x10de0012, "GPU 12 HDMI/DP", patch_nvhdmi_legacy),
4338 HDA_CODEC_ENTRY(0x10de0013, "GPU 13 HDMI/DP", patch_nvhdmi_legacy),
4339 HDA_CODEC_ENTRY(0x10de0014, "GPU 14 HDMI/DP", patch_nvhdmi_legacy),
4340 HDA_CODEC_ENTRY(0x10de0015, "GPU 15 HDMI/DP", patch_nvhdmi_legacy),
4341 HDA_CODEC_ENTRY(0x10de0016, "GPU 16 HDMI/DP", patch_nvhdmi_legacy),
4343 HDA_CODEC_ENTRY(0x10de0018, "GPU 18 HDMI/DP", patch_nvhdmi_legacy),
4344 HDA_CODEC_ENTRY(0x10de0019, "GPU 19 HDMI/DP", patch_nvhdmi_legacy),
4345 HDA_CODEC_ENTRY(0x10de001a, "GPU 1a HDMI/DP", patch_nvhdmi_legacy),
4346 HDA_CODEC_ENTRY(0x10de001b, "GPU 1b HDMI/DP", patch_nvhdmi_legacy),
4347 HDA_CODEC_ENTRY(0x10de001c, "GPU 1c HDMI/DP", patch_nvhdmi_legacy),
4348 HDA_CODEC_ENTRY(0x10de0020, "Tegra30 HDMI", patch_tegra_hdmi),
4349 HDA_CODEC_ENTRY(0x10de0022, "Tegra114 HDMI", patch_tegra_hdmi),
4350 HDA_CODEC_ENTRY(0x10de0028, "Tegra124 HDMI", patch_tegra_hdmi),
4351 HDA_CODEC_ENTRY(0x10de0029, "Tegra210 HDMI/DP", patch_tegra_hdmi),
4352 HDA_CODEC_ENTRY(0x10de002d, "Tegra186 HDMI/DP0", patch_tegra_hdmi),
4353 HDA_CODEC_ENTRY(0x10de002e, "Tegra186 HDMI/DP1", patch_tegra_hdmi),
4354 HDA_CODEC_ENTRY(0x10de002f, "Tegra194 HDMI/DP2", patch_tegra_hdmi),
4355 HDA_CODEC_ENTRY(0x10de0030, "Tegra194 HDMI/DP3", patch_tegra_hdmi),
4356 HDA_CODEC_ENTRY(0x10de0040, "GPU 40 HDMI/DP", patch_nvhdmi),
4357 HDA_CODEC_ENTRY(0x10de0041, "GPU 41 HDMI/DP", patch_nvhdmi),
4358 HDA_CODEC_ENTRY(0x10de0042, "GPU 42 HDMI/DP", patch_nvhdmi),
4359 HDA_CODEC_ENTRY(0x10de0043, "GPU 43 HDMI/DP", patch_nvhdmi),
4360 HDA_CODEC_ENTRY(0x10de0044, "GPU 44 HDMI/DP", patch_nvhdmi),
4361 HDA_CODEC_ENTRY(0x10de0045, "GPU 45 HDMI/DP", patch_nvhdmi),
4362 HDA_CODEC_ENTRY(0x10de0050, "GPU 50 HDMI/DP", patch_nvhdmi),
4363 HDA_CODEC_ENTRY(0x10de0051, "GPU 51 HDMI/DP", patch_nvhdmi),
4364 HDA_CODEC_ENTRY(0x10de0052, "GPU 52 HDMI/DP", patch_nvhdmi),
4365 HDA_CODEC_ENTRY(0x10de0060, "GPU 60 HDMI/DP", patch_nvhdmi),
4366 HDA_CODEC_ENTRY(0x10de0061, "GPU 61 HDMI/DP", patch_nvhdmi),
4367 HDA_CODEC_ENTRY(0x10de0062, "GPU 62 HDMI/DP", patch_nvhdmi),
4368 HDA_CODEC_ENTRY(0x10de0067, "MCP67 HDMI", patch_nvhdmi_2ch),
4369 HDA_CODEC_ENTRY(0x10de0070, "GPU 70 HDMI/DP", patch_nvhdmi),
4370 HDA_CODEC_ENTRY(0x10de0071, "GPU 71 HDMI/DP", patch_nvhdmi),
4371 HDA_CODEC_ENTRY(0x10de0072, "GPU 72 HDMI/DP", patch_nvhdmi),
4372 HDA_CODEC_ENTRY(0x10de0073, "GPU 73 HDMI/DP", patch_nvhdmi),
4373 HDA_CODEC_ENTRY(0x10de0074, "GPU 74 HDMI/DP", patch_nvhdmi),
4374 HDA_CODEC_ENTRY(0x10de0076, "GPU 76 HDMI/DP", patch_nvhdmi),
4375 HDA_CODEC_ENTRY(0x10de007b, "GPU 7b HDMI/DP", patch_nvhdmi),
4376 HDA_CODEC_ENTRY(0x10de007c, "GPU 7c HDMI/DP", patch_nvhdmi),
4377 HDA_CODEC_ENTRY(0x10de007d, "GPU 7d HDMI/DP", patch_nvhdmi),
4378 HDA_CODEC_ENTRY(0x10de007e, "GPU 7e HDMI/DP", patch_nvhdmi),
4379 HDA_CODEC_ENTRY(0x10de0080, "GPU 80 HDMI/DP", patch_nvhdmi),
4380 HDA_CODEC_ENTRY(0x10de0081, "GPU 81 HDMI/DP", patch_nvhdmi),
4381 HDA_CODEC_ENTRY(0x10de0082, "GPU 82 HDMI/DP", patch_nvhdmi),
4382 HDA_CODEC_ENTRY(0x10de0083, "GPU 83 HDMI/DP", patch_nvhdmi),
4383 HDA_CODEC_ENTRY(0x10de0084, "GPU 84 HDMI/DP", patch_nvhdmi),
4384 HDA_CODEC_ENTRY(0x10de0090, "GPU 90 HDMI/DP", patch_nvhdmi),
4385 HDA_CODEC_ENTRY(0x10de0091, "GPU 91 HDMI/DP", patch_nvhdmi),
4386 HDA_CODEC_ENTRY(0x10de0092, "GPU 92 HDMI/DP", patch_nvhdmi),
4387 HDA_CODEC_ENTRY(0x10de0093, "GPU 93 HDMI/DP", patch_nvhdmi),
4388 HDA_CODEC_ENTRY(0x10de0094, "GPU 94 HDMI/DP", patch_nvhdmi),
4389 HDA_CODEC_ENTRY(0x10de0095, "GPU 95 HDMI/DP", patch_nvhdmi),
4390 HDA_CODEC_ENTRY(0x10de0097, "GPU 97 HDMI/DP", patch_nvhdmi),
4391 HDA_CODEC_ENTRY(0x10de0098, "GPU 98 HDMI/DP", patch_nvhdmi),
4392 HDA_CODEC_ENTRY(0x10de0099, "GPU 99 HDMI/DP", patch_nvhdmi),
4393 HDA_CODEC_ENTRY(0x10de009a, "GPU 9a HDMI/DP", patch_nvhdmi),
4394 HDA_CODEC_ENTRY(0x10de009d, "GPU 9d HDMI/DP", patch_nvhdmi),
4395 HDA_CODEC_ENTRY(0x10de009e, "GPU 9e HDMI/DP", patch_nvhdmi),
4396 HDA_CODEC_ENTRY(0x10de009f, "GPU 9f HDMI/DP", patch_nvhdmi),
4397 HDA_CODEC_ENTRY(0x10de00a0, "GPU a0 HDMI/DP", patch_nvhdmi),
4398 HDA_CODEC_ENTRY(0x10de00a3, "GPU a3 HDMI/DP", patch_nvhdmi),
4399 HDA_CODEC_ENTRY(0x10de00a4, "GPU a4 HDMI/DP", patch_nvhdmi),
4400 HDA_CODEC_ENTRY(0x10de00a5, "GPU a5 HDMI/DP", patch_nvhdmi),
4401 HDA_CODEC_ENTRY(0x10de00a6, "GPU a6 HDMI/DP", patch_nvhdmi),
4402 HDA_CODEC_ENTRY(0x10de00a7, "GPU a7 HDMI/DP", patch_nvhdmi),
4403 HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI", patch_nvhdmi_2ch),
4404 HDA_CODEC_ENTRY(0x10de8067, "MCP67/68 HDMI", patch_nvhdmi_2ch),
4405 HDA_CODEC_ENTRY(0x67663d82, "Arise 82 HDMI/DP", patch_gf_hdmi),
4406 HDA_CODEC_ENTRY(0x67663d83, "Arise 83 HDMI/DP", patch_gf_hdmi),
4407 HDA_CODEC_ENTRY(0x67663d84, "Arise 84 HDMI/DP", patch_gf_hdmi),
4408 HDA_CODEC_ENTRY(0x67663d85, "Arise 85 HDMI/DP", patch_gf_hdmi),
4409 HDA_CODEC_ENTRY(0x67663d86, "Arise 86 HDMI/DP", patch_gf_hdmi),
4410 HDA_CODEC_ENTRY(0x67663d87, "Arise 87 HDMI/DP", patch_gf_hdmi),
4411 HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP", patch_via_hdmi),
4412 HDA_CODEC_ENTRY(0x11069f81, "VX900 HDMI/DP", patch_via_hdmi),
4413 HDA_CODEC_ENTRY(0x11069f84, "VX11 HDMI/DP", patch_generic_hdmi),
4414 HDA_CODEC_ENTRY(0x11069f85, "VX11 HDMI/DP", patch_generic_hdmi),
4415 HDA_CODEC_ENTRY(0x80860054, "IbexPeak HDMI", patch_i915_cpt_hdmi),
4416 HDA_CODEC_ENTRY(0x80862800, "Geminilake HDMI", patch_i915_glk_hdmi),
4417 HDA_CODEC_ENTRY(0x80862801, "Bearlake HDMI", patch_generic_hdmi),
4418 HDA_CODEC_ENTRY(0x80862802, "Cantiga HDMI", patch_generic_hdmi),
4419 HDA_CODEC_ENTRY(0x80862803, "Eaglelake HDMI", patch_generic_hdmi),
4420 HDA_CODEC_ENTRY(0x80862804, "IbexPeak HDMI", patch_i915_cpt_hdmi),
4421 HDA_CODEC_ENTRY(0x80862805, "CougarPoint HDMI", patch_i915_cpt_hdmi),
4422 HDA_CODEC_ENTRY(0x80862806, "PantherPoint HDMI", patch_i915_cpt_hdmi),
4423 HDA_CODEC_ENTRY(0x80862807, "Haswell HDMI", patch_i915_hsw_hdmi),
4424 HDA_CODEC_ENTRY(0x80862808, "Broadwell HDMI", patch_i915_hsw_hdmi),
4425 HDA_CODEC_ENTRY(0x80862809, "Skylake HDMI", patch_i915_hsw_hdmi),
4426 HDA_CODEC_ENTRY(0x8086280a, "Broxton HDMI", patch_i915_hsw_hdmi),
4427 HDA_CODEC_ENTRY(0x8086280b, "Kabylake HDMI", patch_i915_hsw_hdmi),
4428 HDA_CODEC_ENTRY(0x8086280c, "Cannonlake HDMI", patch_i915_glk_hdmi),
4429 HDA_CODEC_ENTRY(0x8086280d, "Geminilake HDMI", patch_i915_glk_hdmi),
4430 HDA_CODEC_ENTRY(0x8086280f, "Icelake HDMI", patch_i915_icl_hdmi),
4431 HDA_CODEC_ENTRY(0x80862812, "Tigerlake HDMI", patch_i915_tgl_hdmi),
4432 HDA_CODEC_ENTRY(0x80862814, "DG1 HDMI", patch_i915_tgl_hdmi),
4433 HDA_CODEC_ENTRY(0x80862815, "Alderlake HDMI", patch_i915_tgl_hdmi),
4434 HDA_CODEC_ENTRY(0x80862816, "Rocketlake HDMI", patch_i915_tgl_hdmi),
4435 HDA_CODEC_ENTRY(0x80862819, "DG2 HDMI", patch_i915_tgl_hdmi),
4436 HDA_CODEC_ENTRY(0x8086281a, "Jasperlake HDMI", patch_i915_icl_hdmi),
4437 HDA_CODEC_ENTRY(0x8086281b, "Elkhartlake HDMI", patch_i915_icl_hdmi),
4438 HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi),
4439 HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi),
4440 HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_i915_byt_hdmi),
4441 HDA_CODEC_ENTRY(0x80862883, "Braswell HDMI", patch_i915_byt_hdmi),
4442 HDA_CODEC_ENTRY(0x808629fb, "Crestline HDMI", patch_generic_hdmi),
4450 MODULE_DESCRIPTION("HDMI HD-audio codec");
4451 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4452 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4453 MODULE_ALIAS("snd-hda-codec-atihdmi");