• Home
  • Raw
  • Download

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(0x1462, 0xec94, "MS-7C94", 1),
1974 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1976 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
1982 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
1983 if (!start_nid || nodes < 0) { in hdmi_parse_codec()
1984 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1985 return -EINVAL; in hdmi_parse_codec()
1988 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
1990 if (q && q->value) in hdmi_parse_codec()
1991 spec->force_connect = true; in hdmi_parse_codec()
1997 for (i = 0; i < nodes; i++) { in hdmi_parse_codec()
2000 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2006 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
2010 for (i = 0; i < nodes; i++) { in hdmi_parse_codec()
2013 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2019 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
2022 return 0; in hdmi_parse_codec()
2027 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
2032 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2033 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
2038 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2041 non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO); in check_non_pcm_per_cvt()
2042 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2051 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
2056 hda_nid_t cvt_nid = hinfo->nid; in generic_hdmi_playback_pcm_prepare()
2057 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
2060 struct snd_pcm_runtime *runtime = substream->runtime; in generic_hdmi_playback_pcm_prepare()
2063 int err = 0; in generic_hdmi_playback_pcm_prepare()
2065 mutex_lock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2066 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
2067 if (spec->dyn_pcm_assign && pin_idx < 0) { in generic_hdmi_playback_pcm_prepare()
2069 * skip pin setup and return 0 to make audio playback in generic_hdmi_playback_pcm_prepare()
2072 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2073 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
2074 stream_tag, 0, format); in generic_hdmi_playback_pcm_prepare()
2078 if (snd_BUG_ON(pin_idx < 0)) { in generic_hdmi_playback_pcm_prepare()
2079 err = -EINVAL; in generic_hdmi_playback_pcm_prepare()
2092 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
2096 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
2097 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2098 per_pin->dev_id, runtime->rate); in generic_hdmi_playback_pcm_prepare()
2100 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2101 mutex_lock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2102 per_pin->channels = substream->runtime->channels; in generic_hdmi_playback_pcm_prepare()
2103 per_pin->setup = true; in generic_hdmi_playback_pcm_prepare()
2105 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
2106 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2108 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
2113 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
2114 mutex_unlock(&per_pin->lock); in generic_hdmi_playback_pcm_prepare()
2115 if (spec->dyn_pin_out) { in generic_hdmi_playback_pcm_prepare()
2116 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2117 per_pin->dev_id); in generic_hdmi_playback_pcm_prepare()
2118 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2119 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); in generic_hdmi_playback_pcm_prepare()
2120 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2126 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2127 per_pin->dev_id, stream_tag, format); in generic_hdmi_playback_pcm_prepare()
2129 mutex_unlock(&spec->pcm_lock); in generic_hdmi_playback_pcm_prepare()
2134 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
2137 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2138 return 0; in generic_hdmi_playback_pcm_cleanup()
2142 struct hda_codec *codec, in hdmi_pcm_close() argument
2145 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2150 int err = 0; in hdmi_pcm_close()
2152 mutex_lock(&spec->pcm_lock); in hdmi_pcm_close()
2153 if (hinfo->nid) { in hdmi_pcm_close()
2154 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
2155 if (snd_BUG_ON(pcm_idx < 0)) { in hdmi_pcm_close()
2156 err = -EINVAL; in hdmi_pcm_close()
2159 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2160 if (snd_BUG_ON(cvt_idx < 0)) { in hdmi_pcm_close()
2161 err = -EINVAL; in hdmi_pcm_close()
2165 per_cvt->assigned = 0; in hdmi_pcm_close()
2166 hinfo->nid = 0; in hdmi_pcm_close()
2168 azx_stream(get_azx_dev(substream))->stripe = 0; in hdmi_pcm_close()
2170 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
2171 clear_bit(pcm_idx, &spec->pcm_in_use); in hdmi_pcm_close()
2172 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
2173 if (spec->dyn_pcm_assign && pin_idx < 0) in hdmi_pcm_close()
2176 if (snd_BUG_ON(pin_idx < 0)) { in hdmi_pcm_close()
2177 err = -EINVAL; in hdmi_pcm_close()
2182 if (spec->dyn_pin_out) { in hdmi_pcm_close()
2183 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2184 per_pin->dev_id); in hdmi_pcm_close()
2185 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2186 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); in hdmi_pcm_close()
2187 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2192 mutex_lock(&per_pin->lock); in hdmi_pcm_close()
2193 per_pin->chmap_set = false; in hdmi_pcm_close()
2194 memset(per_pin->chmap, 0, sizeof(per_pin->chmap)); in hdmi_pcm_close()
2196 per_pin->setup = false; in hdmi_pcm_close()
2197 per_pin->channels = 0; in hdmi_pcm_close()
2198 mutex_unlock(&per_pin->lock); in hdmi_pcm_close()
2202 mutex_unlock(&spec->pcm_lock); in hdmi_pcm_close()
2216 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_spk_alloc() local
2217 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2221 return 0; in hdmi_get_spk_alloc()
2223 return per_pin->sink_eld.info.spk_alloc; in hdmi_get_spk_alloc()
2229 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_chmap() local
2230 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2233 /* chmap is already set to 0 in caller */ in hdmi_get_chmap()
2237 memcpy(chmap, per_pin->chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_get_chmap()
2243 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_set_chmap() local
2244 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2249 mutex_lock(&per_pin->lock); in hdmi_set_chmap()
2250 per_pin->chmap_set = true; in hdmi_set_chmap()
2251 memcpy(per_pin->chmap, chmap, ARRAY_SIZE(per_pin->chmap)); in hdmi_set_chmap()
2253 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2254 mutex_unlock(&per_pin->lock); in hdmi_set_chmap()
2259 struct hda_codec *codec = hdac_to_hda_codec(hdac); in is_hdmi_pcm_attached() local
2260 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2266 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2268 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2272 * for non-mst mode, pcm number is the same as before in generic_hdmi_build_pcms()
2275 * (nid number + dev_num - 1) in generic_hdmi_build_pcms()
2279 if (spec->dyn_pcm_no_legacy && codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2280 pcm_num = spec->num_cvts; in generic_hdmi_build_pcms()
2281 else if (codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2282 pcm_num = spec->num_nids; in generic_hdmi_build_pcms()
2284 pcm_num = spec->num_nids + spec->dev_num - 1; in generic_hdmi_build_pcms()
2286 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); in generic_hdmi_build_pcms()
2288 for (idx = 0; idx < pcm_num; idx++) { in generic_hdmi_build_pcms()
2292 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2294 return -ENOMEM; in generic_hdmi_build_pcms()
2296 spec->pcm_rec[idx].pcm = info; in generic_hdmi_build_pcms()
2297 spec->pcm_used++; in generic_hdmi_build_pcms()
2298 info->pcm_type = HDA_PCM_TYPE_HDMI; in generic_hdmi_build_pcms()
2299 info->own_chmap = true; in generic_hdmi_build_pcms()
2301 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in generic_hdmi_build_pcms()
2302 pstr->substreams = 1; in generic_hdmi_build_pcms()
2303 pstr->ops = generic_ops; in generic_hdmi_build_pcms()
2305 if (spec->pcm_used >= 16) in generic_hdmi_build_pcms()
2310 return 0; in generic_hdmi_build_pcms()
2315 struct hdmi_pcm *pcm = jack->private_data; in free_hdmi_jack_priv()
2317 pcm->jack = NULL; in free_hdmi_jack_priv()
2320 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2323 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2326 int pcmdev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_jack()
2329 if (pcmdev > 0) in generic_hdmi_build_jack()
2331 if (!spec->dyn_pcm_assign && in generic_hdmi_build_jack()
2332 !is_jack_detectable(codec, per_pin->pin_nid)) in generic_hdmi_build_jack()
2334 sizeof(hdmi_str) - strlen(hdmi_str) - 1); in generic_hdmi_build_jack()
2336 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2338 if (err < 0) in generic_hdmi_build_jack()
2341 spec->pcm_rec[pcm_idx].jack = jack; in generic_hdmi_build_jack()
2342 jack->private_data = &spec->pcm_rec[pcm_idx]; in generic_hdmi_build_jack()
2343 jack->private_free = free_hdmi_jack_priv; in generic_hdmi_build_jack()
2344 return 0; in generic_hdmi_build_jack()
2347 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2349 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2353 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2354 if (!get_pcm_rec(spec, pcm_idx)->pcm) { in generic_hdmi_build_controls()
2356 set_bit(pcm_idx, &spec->pcm_bitmap); in generic_hdmi_build_controls()
2360 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2361 if (err < 0) in generic_hdmi_build_controls()
2367 if (spec->dyn_pcm_assign) in generic_hdmi_build_controls()
2368 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2369 0, spec->cvt_nids[0], in generic_hdmi_build_controls()
2374 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2375 per_pin->pin_nid, in generic_hdmi_build_controls()
2376 per_pin->mux_nids[0], in generic_hdmi_build_controls()
2379 if (err < 0) in generic_hdmi_build_controls()
2381 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2383 dev = get_pcm_rec(spec, pcm_idx)->device; in generic_hdmi_build_controls()
2386 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2387 if (err < 0) in generic_hdmi_build_controls()
2392 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_build_controls()
2394 struct hdmi_eld *pin_eld = &per_pin->sink_eld; in generic_hdmi_build_controls()
2396 pin_eld->eld_valid = false; in generic_hdmi_build_controls()
2397 hdmi_present_sense(per_pin, 0); in generic_hdmi_build_controls()
2401 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_build_controls()
2405 if (!pcm || !pcm->pcm) in generic_hdmi_build_controls()
2407 err = snd_hdac_add_chmap_ctls(pcm->pcm, pcm_idx, &spec->chmap); in generic_hdmi_build_controls()
2408 if (err < 0) in generic_hdmi_build_controls()
2412 return 0; in generic_hdmi_build_controls()
2415 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2417 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2420 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init_per_pins()
2423 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2424 mutex_init(&per_pin->lock); in generic_hdmi_init_per_pins()
2425 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld); in generic_hdmi_init_per_pins()
2428 return 0; in generic_hdmi_init_per_pins()
2431 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2433 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2436 mutex_lock(&spec->bind_lock); in generic_hdmi_init()
2437 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_init()
2439 hda_nid_t pin_nid = per_pin->pin_nid; in generic_hdmi_init()
2440 int dev_id = per_pin->dev_id; in generic_hdmi_init()
2442 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2443 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2444 if (codec_has_acomp(codec)) in generic_hdmi_init()
2446 snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id, in generic_hdmi_init()
2449 mutex_unlock(&spec->bind_lock); in generic_hdmi_init()
2450 return 0; in generic_hdmi_init()
2455 snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums); in hdmi_array_init()
2456 snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums); in hdmi_array_init()
2461 snd_array_free(&spec->pins); in hdmi_array_free()
2462 snd_array_free(&spec->cvts); in hdmi_array_free()
2465 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2467 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2472 codec->spec = NULL; in generic_spec_free()
2474 codec->dp_mst = false; in generic_spec_free()
2477 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2479 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2482 if (spec->acomp_registered) { in generic_hdmi_free()
2483 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2484 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2485 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2487 codec->relaxed_resume = 0; in generic_hdmi_free()
2489 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_free()
2491 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_free()
2495 for (pcm_idx = 0; pcm_idx < spec->pcm_used; pcm_idx++) { in generic_hdmi_free()
2496 if (spec->pcm_rec[pcm_idx].jack == NULL) in generic_hdmi_free()
2498 if (spec->dyn_pcm_assign) in generic_hdmi_free()
2499 snd_device_free(codec->card, in generic_hdmi_free()
2500 spec->pcm_rec[pcm_idx].jack); in generic_hdmi_free()
2502 spec->pcm_rec[pcm_idx].jack = NULL; in generic_hdmi_free()
2505 generic_spec_free(codec); in generic_hdmi_free()
2509 static int generic_hdmi_suspend(struct hda_codec *codec) in generic_hdmi_suspend() argument
2511 struct hdmi_spec *spec = codec->spec; in generic_hdmi_suspend()
2514 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_suspend()
2516 cancel_delayed_work_sync(&per_pin->work); in generic_hdmi_suspend()
2518 return 0; in generic_hdmi_suspend()
2521 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2523 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2526 codec->patch_ops.init(codec); in generic_hdmi_resume()
2527 snd_hda_regmap_sync(codec); in generic_hdmi_resume()
2529 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in generic_hdmi_resume()
2533 return 0; in generic_hdmi_resume()
2556 /* allocate codec->spec and assign/initialize generic parser ops */
2557 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2563 return -ENOMEM; in alloc_generic_hdmi()
2565 spec->codec = codec; in alloc_generic_hdmi()
2566 spec->ops = generic_standard_hdmi_ops; in alloc_generic_hdmi()
2567 spec->dev_num = 1; /* initialize to 1 */ in alloc_generic_hdmi()
2568 mutex_init(&spec->pcm_lock); in alloc_generic_hdmi()
2569 mutex_init(&spec->bind_lock); in alloc_generic_hdmi()
2570 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2572 spec->chmap.ops.get_chmap = hdmi_get_chmap; in alloc_generic_hdmi()
2573 spec->chmap.ops.set_chmap = hdmi_set_chmap; in alloc_generic_hdmi()
2574 spec->chmap.ops.is_pcm_attached = is_hdmi_pcm_attached; in alloc_generic_hdmi()
2575 spec->chmap.ops.get_spk_alloc = hdmi_get_spk_alloc; in alloc_generic_hdmi()
2577 codec->spec = spec; in alloc_generic_hdmi()
2580 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2582 return 0; in alloc_generic_hdmi()
2586 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2590 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2591 if (err < 0) in patch_generic_hdmi()
2594 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2595 if (err < 0) { in patch_generic_hdmi()
2596 generic_spec_free(codec); in patch_generic_hdmi()
2600 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2601 return 0; in patch_generic_hdmi()
2609 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2614 tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in reprogram_jack_detect()
2616 /* clear unsol even if component notifier is used, or re-enable in reprogram_jack_detect()
2619 unsigned int val = use_acomp ? 0 : (AC_USRSP_EN | tbl->tag); in reprogram_jack_detect()
2620 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2632 spec = container_of(acomp->audio_ops, struct hdmi_spec, drm_audio_ops); in generic_acomp_notifier_set()
2633 mutex_lock(&spec->bind_lock); in generic_acomp_notifier_set()
2634 spec->use_acomp_notifier = use_acomp; in generic_acomp_notifier_set()
2635 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2636 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2638 for (i = 0; i < spec->num_pins; i++) in generic_acomp_notifier_set()
2639 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2640 get_pin(spec, i)->pin_nid, in generic_acomp_notifier_set()
2641 get_pin(spec, i)->dev_id, in generic_acomp_notifier_set()
2643 mutex_unlock(&spec->bind_lock); in generic_acomp_notifier_set()
2651 return 0; in generic_acomp_master_bind()
2660 /* check whether both HD-audio and DRM PCI devices belong to the same bus */
2666 if (!dev_is_pci(dev) || !dev_is_pci(bus->dev)) in match_bound_vga()
2667 return 0; in match_bound_vga()
2668 master = to_pci_dev(bus->dev); in match_bound_vga()
2670 return master->bus == pci->bus; in match_bound_vga()
2676 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2677 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2678 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2682 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2687 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in generic_acomp_pin_eld_notify()
2690 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2694 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2697 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2699 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2705 spec->drm_audio_ops.pin2port = ops->pin2port; in setup_drm_audio_ops()
2706 spec->drm_audio_ops.pin_eld_notify = ops->pin_eld_notify; in setup_drm_audio_ops()
2707 spec->drm_audio_ops.master_bind = ops->master_bind; in setup_drm_audio_ops()
2708 spec->drm_audio_ops.master_unbind = ops->master_unbind; in setup_drm_audio_ops()
2712 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2716 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2719 codec_info(codec, "audio component disabled by module option\n"); in generic_acomp_init()
2723 spec->port2pin = port2pin; in generic_acomp_init()
2724 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2725 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2726 match_bound_vga, 0)) { in generic_acomp_init()
2727 spec->acomp_registered = true; in generic_acomp_init()
2732 * Intel codec parsers and helpers
2735 #define INTEL_GET_VENDOR_VERB 0xf81
2736 #define INTEL_SET_VENDOR_VERB 0x781
2737 #define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */
2738 #define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */
2740 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2744 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2746 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2747 INTEL_GET_VENDOR_VERB, 0); in intel_haswell_enable_all_pins()
2748 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) in intel_haswell_enable_all_pins()
2752 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2754 if (vendor_param == -1) in intel_haswell_enable_all_pins()
2758 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2761 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2764 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2766 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2767 INTEL_GET_VENDOR_VERB, 0); in intel_haswell_fixup_enable_dp12()
2768 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) in intel_haswell_fixup_enable_dp12()
2773 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2774 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2778 /* Haswell needs to re-issue the vendor-specific verbs before turning to D0.
2781 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2785 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2786 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2789 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2790 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2795 * Pin Widget 5 - PORT B (port = 1 in i915 driver)
2796 * Pin Widget 6 - PORT C (port = 2 in i915 driver)
2797 * Pin Widget 7 - PORT D (port = 3 in i915 driver)
2800 * Pin Widget 4 - PORT B (port = 1 in i915 driver)
2801 * Pin Widget 5 - PORT C (port = 2 in i915 driver)
2802 * Pin Widget 6 - PORT D (port = 3 in i915 driver)
2804 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2806 switch (codec->core.vendor_id) { in intel_base_nid()
2807 case 0x80860054: /* ILK */ in intel_base_nid()
2808 case 0x80862804: /* ILK */ in intel_base_nid()
2809 case 0x80862882: /* VLV */ in intel_base_nid()
2818 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2819 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2822 if (!spec->port_num) { in intel_pin2port()
2823 base_nid = intel_base_nid(codec); in intel_pin2port()
2825 return -1; in intel_pin2port()
2826 return pin_nid - base_nid + 1; in intel_pin2port()
2833 for (i = 0; i < spec->port_num; i++) { in intel_pin2port()
2834 if (pin_nid == spec->port_map[i]) in intel_pin2port()
2838 codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid); in intel_pin2port()
2839 return -1; in intel_pin2port()
2842 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2844 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2846 if (!spec->port_num) { in intel_port2pin()
2847 /* we assume only from port-B to port-D */ in intel_port2pin()
2849 return 0; in intel_port2pin()
2850 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2853 if (port < 0 || port >= spec->port_num) in intel_port2pin()
2854 return 0; in intel_port2pin()
2855 return spec->port_map[port]; in intel_port2pin()
2860 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2864 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2870 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
2873 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2874 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2883 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2885 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2887 spec->use_acomp_notifier = true; in register_i915_notifier()
2888 spec->port2pin = intel_port2pin; in register_i915_notifier()
2889 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2890 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2891 &spec->drm_audio_ops); in register_i915_notifier()
2893 codec->relaxed_resume = 1; in register_i915_notifier()
2897 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2901 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2902 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
2907 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2912 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2913 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2914 per_pin->dev_id); in i915_pin_cvt_fixup()
2915 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2916 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2917 per_pin->dev_id, per_pin->mux_idx); in i915_pin_cvt_fixup()
2919 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2924 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2929 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2930 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2932 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2933 return -ENODEV; in alloc_intel_hdmi()
2936 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2937 if (err < 0) in alloc_intel_hdmi()
2940 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
2941 return 0; in alloc_intel_hdmi()
2944 /* parse and post-process for Intel codecs */
2945 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2950 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2951 } while (err < 0 && retries--); in parse_intel_hdmi()
2953 if (err < 0) { in parse_intel_hdmi()
2954 generic_spec_free(codec); in parse_intel_hdmi()
2958 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2959 register_i915_notifier(codec); in parse_intel_hdmi()
2960 return 0; in parse_intel_hdmi()
2964 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
2970 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2971 if (err < 0) in intel_hsw_common_init()
2973 spec = codec->spec; in intel_hsw_common_init()
2974 codec->dp_mst = true; in intel_hsw_common_init()
2975 spec->dyn_pcm_assign = true; in intel_hsw_common_init()
2976 spec->vendor_nid = vendor_nid; in intel_hsw_common_init()
2977 spec->port_map = port_map; in intel_hsw_common_init()
2978 spec->port_num = port_num; in intel_hsw_common_init()
2979 spec->intel_hsw_fixup = true; in intel_hsw_common_init()
2981 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2982 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2984 codec->display_power_control = 1; in intel_hsw_common_init()
2986 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2987 codec->depop_delay = 0; in intel_hsw_common_init()
2988 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2990 spec->ops.setup_stream = i915_hsw_setup_stream; in intel_hsw_common_init()
2991 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in intel_hsw_common_init()
2998 spec->send_silent_stream = true; in intel_hsw_common_init()
3000 return parse_intel_hdmi(codec); in intel_hsw_common_init()
3003 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
3005 return intel_hsw_common_init(codec, 0x08, NULL, 0); in patch_i915_hsw_hdmi()
3008 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
3010 return intel_hsw_common_init(codec, 0x0b, NULL, 0); in patch_i915_glk_hdmi()
3013 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
3019 static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb}; in patch_i915_icl_hdmi()
3021 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_icl_hdmi()
3024 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
3030 static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; in patch_i915_tgl_hdmi()
3033 ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_tgl_hdmi()
3035 struct hdmi_spec *spec = codec->spec; in patch_i915_tgl_hdmi()
3037 spec->dyn_pcm_no_legacy = true; in patch_i915_tgl_hdmi()
3044 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
3049 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
3050 if (err < 0) in patch_i915_byt_hdmi()
3052 spec = codec->spec; in patch_i915_byt_hdmi()
3054 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
3057 codec->display_power_control = 1; in patch_i915_byt_hdmi()
3059 codec->depop_delay = 0; in patch_i915_byt_hdmi()
3060 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
3062 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup; in patch_i915_byt_hdmi()
3064 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
3068 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
3072 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3073 if (err < 0) in patch_i915_cpt_hdmi()
3075 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3079 * Shared non-generic implementations
3082 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
3084 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
3090 per_cvt = get_cvt(spec, 0); in simple_playback_build_pcms()
3091 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
3094 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
3096 return -ENOMEM; in simple_playback_build_pcms()
3097 spec->pcm_rec[0].pcm = info; in simple_playback_build_pcms()
3098 info->pcm_type = HDA_PCM_TYPE_HDMI; in simple_playback_build_pcms()
3099 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; in simple_playback_build_pcms()
3100 *pstr = spec->pcm_playback; in simple_playback_build_pcms()
3101 pstr->nid = per_cvt->cvt_nid; in simple_playback_build_pcms()
3102 if (pstr->channels_max <= 2 && chans && chans <= 16) in simple_playback_build_pcms()
3103 pstr->channels_max = chans; in simple_playback_build_pcms()
3105 return 0; in simple_playback_build_pcms()
3109 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
3112 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
3113 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
3117 * as long as spec->pins[] is set correctly
3121 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
3123 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3127 per_cvt = get_cvt(spec, 0); in simple_playback_build_controls()
3128 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3129 per_cvt->cvt_nid, in simple_playback_build_controls()
3131 if (err < 0) in simple_playback_build_controls()
3133 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
3136 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
3138 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3139 struct hdmi_spec_per_pin *per_pin = get_pin(spec, 0); in simple_playback_init()
3140 hda_nid_t pin = per_pin->pin_nid; in simple_playback_init()
3142 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
3145 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
3146 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
3148 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3149 return 0; in simple_playback_init()
3152 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
3154 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3164 #define Nv_VERB_SET_Channel_Allocation 0xF79
3165 #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A
3166 #define Nv_VERB_SET_Audio_Protection_On 0xF98
3167 #define Nv_VERB_SET_Audio_Protection_Off 0xF99
3169 #define nvhdmi_master_con_nid_7x 0x04
3170 #define nvhdmi_master_pin_nid_7x 0x05
3174 0x6, 0x8, 0xa, 0xc,
3179 { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
3181 { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3187 { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
3189 { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3190 { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3191 { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3192 { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3193 { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
3213 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3215 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3216 return 0; in nvhdmi_7x_init_2ch()
3219 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3221 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3222 return 0; in nvhdmi_7x_init_8ch()
3236 .mask = 0,
3242 .mask = 0,
3246 struct hda_codec *codec, in simple_playback_pcm_open() argument
3249 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3252 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3253 case 0x10de0002: in simple_playback_pcm_open()
3254 case 0x10de0003: in simple_playback_pcm_open()
3255 case 0x10de0005: in simple_playback_pcm_open()
3256 case 0x10de0006: in simple_playback_pcm_open()
3259 case 0x10de0007: in simple_playback_pcm_open()
3267 snd_pcm_hw_constraint_list(substream->runtime, 0, in simple_playback_pcm_open()
3271 snd_pcm_hw_constraint_step(substream->runtime, 0, in simple_playback_pcm_open()
3275 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3279 struct hda_codec *codec, in simple_playback_pcm_close() argument
3282 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3283 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3287 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3292 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3293 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3316 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3325 return -ENOMEM; in patch_simple_hdmi()
3327 spec->codec = codec; in patch_simple_hdmi()
3328 codec->spec = spec; in patch_simple_hdmi()
3331 spec->multiout.num_dacs = 0; /* no analog */ in patch_simple_hdmi()
3332 spec->multiout.max_channels = 2; in patch_simple_hdmi()
3333 spec->multiout.dig_out_nid = cvt_nid; in patch_simple_hdmi()
3334 spec->num_cvts = 1; in patch_simple_hdmi()
3335 spec->num_pins = 1; in patch_simple_hdmi()
3336 per_pin = snd_array_new(&spec->pins); in patch_simple_hdmi()
3337 per_cvt = snd_array_new(&spec->cvts); in patch_simple_hdmi()
3339 simple_playback_free(codec); in patch_simple_hdmi()
3340 return -ENOMEM; in patch_simple_hdmi()
3342 per_cvt->cvt_nid = cvt_nid; in patch_simple_hdmi()
3343 per_pin->pin_nid = pin_nid; in patch_simple_hdmi()
3344 spec->pcm_playback = simple_pcm_playback; in patch_simple_hdmi()
3346 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3348 return 0; in patch_simple_hdmi()
3351 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3355 int chan = channels ? (channels - 1) : 1; in nvhdmi_8ch_7x_set_info_frame_parameters()
3359 case 0: in nvhdmi_8ch_7x_set_info_frame_parameters()
3361 chanmask = 0x00; in nvhdmi_8ch_7x_set_info_frame_parameters()
3364 chanmask = 0x08; in nvhdmi_8ch_7x_set_info_frame_parameters()
3367 chanmask = 0x0b; in nvhdmi_8ch_7x_set_info_frame_parameters()
3370 chanmask = 0x13; in nvhdmi_8ch_7x_set_info_frame_parameters()
3376 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3379 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3381 (0x71 - chan - chanmask)); in nvhdmi_8ch_7x_set_info_frame_parameters()
3385 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3388 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3391 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3392 0, AC_VERB_SET_CHANNEL_STREAMID, 0); in nvhdmi_8ch_7x_pcm_close()
3393 for (i = 0; i < 4; i++) { in nvhdmi_8ch_7x_pcm_close()
3395 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3396 AC_VERB_SET_CHANNEL_STREAMID, 0); in nvhdmi_8ch_7x_pcm_close()
3398 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3399 AC_VERB_SET_STREAM_FORMAT, 0); in nvhdmi_8ch_7x_pcm_close()
3402 /* The audio hardware sends a channel count of 0x7 (8ch) when all the in nvhdmi_8ch_7x_pcm_close()
3404 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3406 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3410 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3418 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3422 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3423 per_cvt = get_cvt(spec, 0); in nvhdmi_8ch_7x_pcm_prepare()
3424 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3426 chs = substream->runtime->channels; in nvhdmi_8ch_7x_pcm_prepare()
3428 dataDCC2 = 0x2; in nvhdmi_8ch_7x_pcm_prepare()
3431 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3432 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3434 0, in nvhdmi_8ch_7x_pcm_prepare()
3436 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3439 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3440 AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); in nvhdmi_8ch_7x_pcm_prepare()
3443 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3448 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3449 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3451 0, in nvhdmi_8ch_7x_pcm_prepare()
3453 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3454 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3456 0, in nvhdmi_8ch_7x_pcm_prepare()
3460 for (i = 0; i < 4; i++) { in nvhdmi_8ch_7x_pcm_prepare()
3462 channel_id = 0; in nvhdmi_8ch_7x_pcm_prepare()
3469 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3470 (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3471 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3473 0, in nvhdmi_8ch_7x_pcm_prepare()
3475 spdif->ctls & ~AC_DIG1_ENABLE & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3477 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3479 0, in nvhdmi_8ch_7x_pcm_prepare()
3483 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3485 0, in nvhdmi_8ch_7x_pcm_prepare()
3490 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3491 (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3492 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3494 0, in nvhdmi_8ch_7x_pcm_prepare()
3496 spdif->ctls & 0xff); in nvhdmi_8ch_7x_pcm_prepare()
3497 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3499 0, in nvhdmi_8ch_7x_pcm_prepare()
3504 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3506 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3507 return 0; in nvhdmi_8ch_7x_pcm_prepare()
3525 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3528 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3530 if (err < 0) in patch_nvhdmi_2ch()
3533 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3534 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3535 spec = codec->spec; in patch_nvhdmi_2ch()
3536 spec->pcm_playback.rates = SUPPORTED_RATES; in patch_nvhdmi_2ch()
3537 spec->pcm_playback.maxbps = SUPPORTED_MAXBPS; in patch_nvhdmi_2ch()
3538 spec->pcm_playback.formats = SUPPORTED_FORMATS; in patch_nvhdmi_2ch()
3539 spec->nv_dp_workaround = true; in patch_nvhdmi_2ch()
3540 return 0; in patch_nvhdmi_2ch()
3543 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3545 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3546 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3548 struct hda_pcm *info = get_pcm_rec(spec, 0); in nvhdmi_7x_8ch_build_pcms()
3549 info->own_chmap = true; in nvhdmi_7x_8ch_build_pcms()
3554 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3556 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3561 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3562 if (err < 0) in nvhdmi_7x_8ch_build_controls()
3566 info = get_pcm_rec(spec, 0); in nvhdmi_7x_8ch_build_controls()
3567 err = snd_pcm_add_chmap_ctls(info->pcm, in nvhdmi_7x_8ch_build_controls()
3569 snd_pcm_alt_chmaps, 8, 0, &chmap); in nvhdmi_7x_8ch_build_controls()
3570 if (err < 0) in nvhdmi_7x_8ch_build_controls()
3572 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3573 case 0x10de0002: in nvhdmi_7x_8ch_build_controls()
3574 case 0x10de0003: in nvhdmi_7x_8ch_build_controls()
3575 case 0x10de0005: in nvhdmi_7x_8ch_build_controls()
3576 case 0x10de0006: in nvhdmi_7x_8ch_build_controls()
3577 chmap->channel_mask = (1U << 2) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3579 case 0x10de0007: in nvhdmi_7x_8ch_build_controls()
3580 chmap->channel_mask = (1U << 2) | (1U << 6) | (1U << 8); in nvhdmi_7x_8ch_build_controls()
3582 return 0; in nvhdmi_7x_8ch_build_controls()
3585 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3588 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3589 if (err < 0) in patch_nvhdmi_8ch_7x()
3591 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3592 spec->multiout.max_channels = 8; in patch_nvhdmi_8ch_7x()
3593 spec->pcm_playback = nvhdmi_pcm_playback_8ch_7x; in patch_nvhdmi_8ch_7x()
3594 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3595 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3596 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3600 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3602 return 0; in patch_nvhdmi_8ch_7x()
3606 * NVIDIA codecs ignore ASP mapping for 2ch - confirmed on:
3607 * - 0x10de0015
3608 * - 0x10de0040
3613 if (cap->ca_index == 0x00 && channels == 2) in nvhdmi_chmap_cea_alloc_validate_get_type()
3617 if (cap->channels != channels) in nvhdmi_chmap_cea_alloc_validate_get_type()
3618 return -1; in nvhdmi_chmap_cea_alloc_validate_get_type()
3627 if (ca == 0x00 && (map[0] != SNDRV_CHMAP_FL || map[1] != SNDRV_CHMAP_FR)) in nvhdmi_chmap_validate()
3628 return -EINVAL; in nvhdmi_chmap_validate()
3630 return 0; in nvhdmi_chmap_validate()
3633 /* map from pin NID to port; port is 0-based */
3637 return pin_nid - 4; in nvhdmi_pin2port()
3640 /* reverse-map from port to pin NID: see above */
3641 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3653 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3658 err = alloc_generic_hdmi(codec); in patch_nvhdmi()
3659 if (err < 0) in patch_nvhdmi()
3661 codec->dp_mst = true; in patch_nvhdmi()
3663 spec = codec->spec; in patch_nvhdmi()
3664 spec->dyn_pcm_assign = true; in patch_nvhdmi()
3666 err = hdmi_parse_codec(codec); in patch_nvhdmi()
3667 if (err < 0) { in patch_nvhdmi()
3668 generic_spec_free(codec); in patch_nvhdmi()
3672 generic_hdmi_init_per_pins(codec); in patch_nvhdmi()
3674 spec->dyn_pin_out = true; in patch_nvhdmi()
3676 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi()
3678 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi()
3679 spec->nv_dp_workaround = true; in patch_nvhdmi()
3681 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3683 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3685 return 0; in patch_nvhdmi()
3688 static int patch_nvhdmi_legacy(struct hda_codec *codec) in patch_nvhdmi_legacy() argument
3693 err = patch_generic_hdmi(codec); in patch_nvhdmi_legacy()
3697 spec = codec->spec; in patch_nvhdmi_legacy()
3698 spec->dyn_pin_out = true; in patch_nvhdmi_legacy()
3700 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_nvhdmi_legacy()
3702 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_nvhdmi_legacy()
3703 spec->nv_dp_workaround = true; in patch_nvhdmi_legacy()
3705 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3707 return 0; in patch_nvhdmi_legacy()
3711 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3712 * accessed using vendor-defined verbs. These registers can be used for
3717 #define NVIDIA_AFG_NID 0x01
3720 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3722 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3723 * implementation stores the HDA format (see AC_FMT_*) in bits [15:0] and an
3726 * | 31 | 30 | 29 16 | 15 0 |
3727 * +---------+-------+--------+--------+
3729 * +-----------------------------------|
3734 #define NVIDIA_GET_SCRATCH0 0xfa6
3735 #define NVIDIA_SET_SCRATCH0_BYTE0 0xfa7
3736 #define NVIDIA_SET_SCRATCH0_BYTE1 0xfa8
3737 #define NVIDIA_SET_SCRATCH0_BYTE2 0xfa9
3738 #define NVIDIA_SET_SCRATCH0_BYTE3 0xfaa
3742 #define NVIDIA_GET_SCRATCH1 0xfab
3743 #define NVIDIA_SET_SCRATCH1_BYTE0 0xfac
3744 #define NVIDIA_SET_SCRATCH1_BYTE1 0xfad
3745 #define NVIDIA_SET_SCRATCH1_BYTE2 0xfae
3746 #define NVIDIA_SET_SCRATCH1_BYTE3 0xfaf
3749 * The format parameter is the HDA audio format (see AC_FMT_*). If set to 0,
3750 * the format is invalidated so that the HDMI codec can be disabled.
3752 static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) in tegra_hdmi_set_format() argument
3757 value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3758 NVIDIA_GET_SCRATCH0, 0); in tegra_hdmi_set_format()
3759 value = (value >> 24) & 0xff; in tegra_hdmi_set_format()
3761 /* bits [15:0] are used to store the HDA format */ in tegra_hdmi_set_format()
3762 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3764 (format >> 0) & 0xff); in tegra_hdmi_set_format()
3765 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3767 (format >> 8) & 0xff); in tegra_hdmi_set_format()
3770 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3771 NVIDIA_SET_SCRATCH0_BYTE2, 0); in tegra_hdmi_set_format()
3777 if (format == 0) in tegra_hdmi_set_format()
3784 * HDMI codec. The HDMI driver will use that as trigger to update its in tegra_hdmi_set_format()
3789 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3794 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3801 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3803 if (err < 0) in tegra_hdmi_pcm_prepare()
3806 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3807 tegra_hdmi_set_format(codec, format); in tegra_hdmi_pcm_prepare()
3809 return 0; in tegra_hdmi_pcm_prepare()
3813 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3816 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3817 tegra_hdmi_set_format(codec, 0); in tegra_hdmi_pcm_cleanup()
3819 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3822 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3824 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3827 for (i = 0; i < spec->num_pins; i++) { in hda_find_pcm_by_type()
3830 if (pcm->pcm_type == type) in hda_find_pcm_by_type()
3837 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3843 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3844 if (err < 0) in tegra_hdmi_build_pcms()
3847 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3849 return -ENODEV; in tegra_hdmi_build_pcms()
3852 * Override ->prepare() and ->cleanup() operations to notify the HDMI in tegra_hdmi_build_pcms()
3853 * codec about format changes. in tegra_hdmi_build_pcms()
3855 stream = &pcm->stream[SNDRV_PCM_STREAM_PLAYBACK]; in tegra_hdmi_build_pcms()
3856 stream->ops.prepare = tegra_hdmi_pcm_prepare; in tegra_hdmi_build_pcms()
3857 stream->ops.cleanup = tegra_hdmi_pcm_cleanup; in tegra_hdmi_build_pcms()
3859 return 0; in tegra_hdmi_build_pcms()
3862 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3867 err = patch_generic_hdmi(codec); in patch_tegra_hdmi()
3871 codec->depop_delay = 10; in patch_tegra_hdmi()
3872 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in patch_tegra_hdmi()
3873 spec = codec->spec; in patch_tegra_hdmi()
3874 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_tegra_hdmi()
3876 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; in patch_tegra_hdmi()
3877 spec->nv_dp_workaround = true; in patch_tegra_hdmi()
3879 return 0; in patch_tegra_hdmi()
3883 * ATI/AMD-specific implementations
3886 #define is_amdhdmi_rev3_or_later(codec) \ argument
3887 ((codec)->core.vendor_id == 0x1002aa01 && \
3888 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3889 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3892 #define ATI_VERB_SET_CHANNEL_ALLOCATION 0x771
3893 #define ATI_VERB_SET_DOWNMIX_INFO 0x772
3894 #define ATI_VERB_SET_MULTICHANNEL_01 0x777
3895 #define ATI_VERB_SET_MULTICHANNEL_23 0x778
3896 #define ATI_VERB_SET_MULTICHANNEL_45 0x779
3897 #define ATI_VERB_SET_MULTICHANNEL_67 0x77a
3898 #define ATI_VERB_SET_HBR_CONTROL 0x77c
3899 #define ATI_VERB_SET_MULTICHANNEL_1 0x785
3900 #define ATI_VERB_SET_MULTICHANNEL_3 0x786
3901 #define ATI_VERB_SET_MULTICHANNEL_5 0x787
3902 #define ATI_VERB_SET_MULTICHANNEL_7 0x788
3903 #define ATI_VERB_SET_MULTICHANNEL_MODE 0x789
3904 #define ATI_VERB_GET_CHANNEL_ALLOCATION 0xf71
3905 #define ATI_VERB_GET_DOWNMIX_INFO 0xf72
3906 #define ATI_VERB_GET_MULTICHANNEL_01 0xf77
3907 #define ATI_VERB_GET_MULTICHANNEL_23 0xf78
3908 #define ATI_VERB_GET_MULTICHANNEL_45 0xf79
3909 #define ATI_VERB_GET_MULTICHANNEL_67 0xf7a
3910 #define ATI_VERB_GET_HBR_CONTROL 0xf7c
3911 #define ATI_VERB_GET_MULTICHANNEL_1 0xf85
3912 #define ATI_VERB_GET_MULTICHANNEL_3 0xf86
3913 #define ATI_VERB_GET_MULTICHANNEL_5 0xf87
3914 #define ATI_VERB_GET_MULTICHANNEL_7 0xf88
3915 #define ATI_VERB_GET_MULTICHANNEL_MODE 0xf89
3918 #define ATI_VERB_SET_RAMP_RATE 0x770
3919 #define ATI_VERB_GET_RAMP_RATE 0xf70
3921 #define ATI_OUT_ENABLE 0x1
3923 #define ATI_MULTICHANNEL_MODE_PAIRED 0
3926 #define ATI_HBR_CAPABLE 0x01
3927 #define ATI_HBR_ENABLE 0x10
3929 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3932 WARN_ON(dev_id != 0); in atihdmi_pin_get_eld()
3933 /* call hda_eld.c ATI/AMD-specific function */ in atihdmi_pin_get_eld()
3934 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
3935 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
3938 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, in atihdmi_pin_setup_infoframe() argument
3942 WARN_ON(dev_id != 0); in atihdmi_pin_setup_infoframe()
3943 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3949 * ATI/AMD have automatic FC/LFE swap built-in in atihdmi_paired_swap_fc_lfe()
3969 /* check that only channel pairs need to be remapped on old pre-rev3 ATI/AMD */ in atihdmi_paired_chmap_validate()
3972 for (i = 0; i < chs; ++i) { in atihdmi_paired_chmap_validate()
3980 for (j = 0 + i % 2; j < 8; j += 2) { in atihdmi_paired_chmap_validate()
3981 int chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j); in atihdmi_paired_chmap_validate()
3982 if (cap->speakers[chan_idx] == mask) { in atihdmi_paired_chmap_validate()
3986 if (i % 2 == 0 && i + 1 < chs) { in atihdmi_paired_chmap_validate()
3988 int comp_chan_idx = 7 - atihdmi_paired_swap_fc_lfe(j + 1); in atihdmi_paired_chmap_validate()
3990 int comp_mask_act = cap->speakers[comp_chan_idx]; in atihdmi_paired_chmap_validate()
3995 return -EINVAL; in atihdmi_paired_chmap_validate()
4002 return -EINVAL; in atihdmi_paired_chmap_validate()
4008 return 0; in atihdmi_paired_chmap_validate()
4014 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_set_slot_channel() local
4016 int ati_channel_setup = 0; in atihdmi_pin_set_slot_channel()
4019 return -EINVAL; in atihdmi_pin_set_slot_channel()
4021 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
4028 if (hdmi_slot % 2 != 0 && stream_channel == 0xf) in atihdmi_pin_set_slot_channel()
4029 return 0; in atihdmi_pin_set_slot_channel()
4031 hdmi_slot -= hdmi_slot % 2; in atihdmi_pin_set_slot_channel()
4033 if (stream_channel != 0xf) in atihdmi_pin_set_slot_channel()
4034 stream_channel -= stream_channel % 2; in atihdmi_pin_set_slot_channel()
4037 verb = ATI_VERB_SET_MULTICHANNEL_01 + hdmi_slot/2 + (hdmi_slot % 2) * 0x00e; in atihdmi_pin_set_slot_channel()
4039 /* ati_channel_setup format: [7..4] = stream_channel_id, [1] = mute, [0] = enable */ in atihdmi_pin_set_slot_channel()
4041 if (stream_channel != 0xf) in atihdmi_pin_set_slot_channel()
4044 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
4050 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_get_slot_channel() local
4057 return -EINVAL; in atihdmi_pin_get_slot_channel()
4059 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
4061 if (ati_asp_slot % 2 != 0) { in atihdmi_pin_get_slot_channel()
4062 ati_asp_slot -= 1; in atihdmi_pin_get_slot_channel()
4067 verb = ATI_VERB_GET_MULTICHANNEL_01 + ati_asp_slot/2 + (ati_asp_slot % 2) * 0x00e; in atihdmi_pin_get_slot_channel()
4069 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
4072 return 0xf; in atihdmi_pin_get_slot_channel()
4074 return ((ati_channel_setup & 0xf0) >> 4) + !!was_odd; in atihdmi_pin_get_slot_channel()
4085 * Pre-rev3 ATI/AMD codecs operate in a paired channel mode, so in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4090 int chanpairs = 0; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4092 /* We only produce even-numbered channel count TLVs */ in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4093 if ((channels % 2) != 0) in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4094 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4096 for (c = 0; c < 7; c += 2) { in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4097 if (cap->speakers[c] || cap->speakers[c+1]) in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4102 return -1; in atihdmi_paired_chmap_cea_alloc_validate_get_type()
4111 /* produce paired maps for pre-rev3 ATI/AMD codecs */ in atihdmi_paired_cea_alloc_to_tlv_chmap()
4112 int count = 0; in atihdmi_paired_cea_alloc_to_tlv_chmap()
4115 for (c = 7; c >= 0; c--) { in atihdmi_paired_cea_alloc_to_tlv_chmap()
4116 int chan = 7 - atihdmi_paired_swap_fc_lfe(7 - c); in atihdmi_paired_cea_alloc_to_tlv_chmap()
4117 int spk = cap->speakers[chan]; in atihdmi_paired_cea_alloc_to_tlv_chmap()
4120 if (cap->speakers[chan + (chan % 2 ? -1 : 1)]) in atihdmi_paired_cea_alloc_to_tlv_chmap()
4132 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
4137 WARN_ON(dev_id != 0); in atihdmi_pin_hbr_setup()
4139 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
4140 if (hbr_ctl >= 0 && (hbr_ctl & ATI_HBR_CAPABLE)) { in atihdmi_pin_hbr_setup()
4146 codec_dbg(codec, in atihdmi_pin_hbr_setup()
4147 "atihdmi_pin_hbr_setup: NID=0x%x, %shbr-ctl=0x%x\n", in atihdmi_pin_hbr_setup()
4149 hbr_ctl == hbr_ctl_new ? "" : "new-", in atihdmi_pin_hbr_setup()
4153 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
4158 return -EINVAL; in atihdmi_pin_hbr_setup()
4160 return 0; in atihdmi_pin_hbr_setup()
4163 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
4167 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
4169 /* disable ramp-up/down for non-pcm as per AMD spec */ in atihdmi_setup_stream()
4171 ramp_rate = 0; in atihdmi_setup_stream()
4173 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
4176 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in atihdmi_setup_stream()
4181 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
4183 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4186 err = generic_hdmi_init(codec); in atihdmi_init()
4191 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { in atihdmi_init()
4195 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4197 /* enable channel-wise remap mode if supported */ in atihdmi_init()
4198 if (has_amd_full_remap_support(codec)) in atihdmi_init()
4199 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4203 codec->auto_runtime_pm = 1; in atihdmi_init()
4205 return 0; in atihdmi_init()
4208 /* map from pin NID to port; port is 0-based */
4212 return pin_nid / 2 - 1; in atihdmi_pin2port()
4215 /* reverse-map from port to pin NID: see above */
4216 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4228 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4234 err = patch_generic_hdmi(codec); in patch_atihdmi()
4239 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4241 spec = codec->spec; in patch_atihdmi()
4243 spec->ops.pin_get_eld = atihdmi_pin_get_eld; in patch_atihdmi()
4244 spec->ops.pin_setup_infoframe = atihdmi_pin_setup_infoframe; in patch_atihdmi()
4245 spec->ops.pin_hbr_setup = atihdmi_pin_hbr_setup; in patch_atihdmi()
4246 spec->ops.setup_stream = atihdmi_setup_stream; in patch_atihdmi()
4248 spec->chmap.ops.pin_get_slot_channel = atihdmi_pin_get_slot_channel; in patch_atihdmi()
4249 spec->chmap.ops.pin_set_slot_channel = atihdmi_pin_set_slot_channel; in patch_atihdmi()
4251 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4252 /* override to ATI/AMD-specific versions with pairwise mapping */ in patch_atihdmi()
4253 spec->chmap.ops.chmap_cea_alloc_validate_get_type = in patch_atihdmi()
4255 spec->chmap.ops.cea_alloc_to_tlv_chmap = in patch_atihdmi()
4257 spec->chmap.ops.chmap_validate = atihdmi_paired_chmap_validate; in patch_atihdmi()
4261 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { in patch_atihdmi()
4263 per_cvt->channels_max = max(per_cvt->channels_max, 8u); in patch_atihdmi()
4264 per_cvt->rates |= SUPPORTED_RATES; in patch_atihdmi()
4265 per_cvt->formats |= SUPPORTED_FORMATS; in patch_atihdmi()
4266 per_cvt->maxbps = max(per_cvt->maxbps, 24u); in patch_atihdmi()
4269 spec->chmap.channels_max = max(spec->chmap.channels_max, 8u); in patch_atihdmi()
4272 * the link-down as is. Tell the core to allow it. in patch_atihdmi()
4274 codec->link_down_at_suspend = 1; in patch_atihdmi()
4276 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4278 return 0; in patch_atihdmi()
4282 #define VIAHDMI_CVT_NID 0x02 /* audio converter1 */
4283 #define VIAHDMI_PIN_NID 0x03 /* HDMI output pin1 */
4285 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4287 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4294 HDA_CODEC_ENTRY(0x1002793c, "RS600 HDMI", patch_atihdmi),
4295 HDA_CODEC_ENTRY(0x10027919, "RS600 HDMI", patch_atihdmi),
4296 HDA_CODEC_ENTRY(0x1002791a, "RS690/780 HDMI", patch_atihdmi),
4297 HDA_CODEC_ENTRY(0x1002aa01, "R6xx HDMI", patch_atihdmi),
4298 HDA_CODEC_ENTRY(0x10951390, "SiI1390 HDMI", patch_generic_hdmi),
4299 HDA_CODEC_ENTRY(0x10951392, "SiI1392 HDMI", patch_generic_hdmi),
4300 HDA_CODEC_ENTRY(0x17e80047, "Chrontel HDMI", patch_generic_hdmi),
4301 HDA_CODEC_ENTRY(0x10de0001, "MCP73 HDMI", patch_nvhdmi_2ch),
4302 HDA_CODEC_ENTRY(0x10de0002, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
4303 HDA_CODEC_ENTRY(0x10de0003, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
4304 HDA_CODEC_ENTRY(0x10de0004, "GPU 04 HDMI", patch_nvhdmi_8ch_7x),
4305 HDA_CODEC_ENTRY(0x10de0005, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
4306 HDA_CODEC_ENTRY(0x10de0006, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
4307 HDA_CODEC_ENTRY(0x10de0007, "MCP79/7A HDMI", patch_nvhdmi_8ch_7x),
4308 HDA_CODEC_ENTRY(0x10de0008, "GPU 08 HDMI/DP", patch_nvhdmi_legacy),
4309 HDA_CODEC_ENTRY(0x10de0009, "GPU 09 HDMI/DP", patch_nvhdmi_legacy),
4310 HDA_CODEC_ENTRY(0x10de000a, "GPU 0a HDMI/DP", patch_nvhdmi_legacy),
4311 HDA_CODEC_ENTRY(0x10de000b, "GPU 0b HDMI/DP", patch_nvhdmi_legacy),
4312 HDA_CODEC_ENTRY(0x10de000c, "MCP89 HDMI", patch_nvhdmi_legacy),
4313 HDA_CODEC_ENTRY(0x10de000d, "GPU 0d HDMI/DP", patch_nvhdmi_legacy),
4314 HDA_CODEC_ENTRY(0x10de0010, "GPU 10 HDMI/DP", patch_nvhdmi_legacy),
4315 HDA_CODEC_ENTRY(0x10de0011, "GPU 11 HDMI/DP", patch_nvhdmi_legacy),
4316 HDA_CODEC_ENTRY(0x10de0012, "GPU 12 HDMI/DP", patch_nvhdmi_legacy),
4317 HDA_CODEC_ENTRY(0x10de0013, "GPU 13 HDMI/DP", patch_nvhdmi_legacy),
4318 HDA_CODEC_ENTRY(0x10de0014, "GPU 14 HDMI/DP", patch_nvhdmi_legacy),
4319 HDA_CODEC_ENTRY(0x10de0015, "GPU 15 HDMI/DP", patch_nvhdmi_legacy),
4320 HDA_CODEC_ENTRY(0x10de0016, "GPU 16 HDMI/DP", patch_nvhdmi_legacy),
4322 HDA_CODEC_ENTRY(0x10de0018, "GPU 18 HDMI/DP", patch_nvhdmi_legacy),
4323 HDA_CODEC_ENTRY(0x10de0019, "GPU 19 HDMI/DP", patch_nvhdmi_legacy),
4324 HDA_CODEC_ENTRY(0x10de001a, "GPU 1a HDMI/DP", patch_nvhdmi_legacy),
4325 HDA_CODEC_ENTRY(0x10de001b, "GPU 1b HDMI/DP", patch_nvhdmi_legacy),
4326 HDA_CODEC_ENTRY(0x10de001c, "GPU 1c HDMI/DP", patch_nvhdmi_legacy),
4327 HDA_CODEC_ENTRY(0x10de0020, "Tegra30 HDMI", patch_tegra_hdmi),
4328 HDA_CODEC_ENTRY(0x10de0022, "Tegra114 HDMI", patch_tegra_hdmi),
4329 HDA_CODEC_ENTRY(0x10de0028, "Tegra124 HDMI", patch_tegra_hdmi),
4330 HDA_CODEC_ENTRY(0x10de0029, "Tegra210 HDMI/DP", patch_tegra_hdmi),
4331 HDA_CODEC_ENTRY(0x10de002d, "Tegra186 HDMI/DP0", patch_tegra_hdmi),
4332 HDA_CODEC_ENTRY(0x10de002e, "Tegra186 HDMI/DP1", patch_tegra_hdmi),
4333 HDA_CODEC_ENTRY(0x10de002f, "Tegra194 HDMI/DP2", patch_tegra_hdmi),
4334 HDA_CODEC_ENTRY(0x10de0030, "Tegra194 HDMI/DP3", patch_tegra_hdmi),
4335 HDA_CODEC_ENTRY(0x10de0040, "GPU 40 HDMI/DP", patch_nvhdmi),
4336 HDA_CODEC_ENTRY(0x10de0041, "GPU 41 HDMI/DP", patch_nvhdmi),
4337 HDA_CODEC_ENTRY(0x10de0042, "GPU 42 HDMI/DP", patch_nvhdmi),
4338 HDA_CODEC_ENTRY(0x10de0043, "GPU 43 HDMI/DP", patch_nvhdmi),
4339 HDA_CODEC_ENTRY(0x10de0044, "GPU 44 HDMI/DP", patch_nvhdmi),
4340 HDA_CODEC_ENTRY(0x10de0045, "GPU 45 HDMI/DP", patch_nvhdmi),
4341 HDA_CODEC_ENTRY(0x10de0050, "GPU 50 HDMI/DP", patch_nvhdmi),
4342 HDA_CODEC_ENTRY(0x10de0051, "GPU 51 HDMI/DP", patch_nvhdmi),
4343 HDA_CODEC_ENTRY(0x10de0052, "GPU 52 HDMI/DP", patch_nvhdmi),
4344 HDA_CODEC_ENTRY(0x10de0060, "GPU 60 HDMI/DP", patch_nvhdmi),
4345 HDA_CODEC_ENTRY(0x10de0061, "GPU 61 HDMI/DP", patch_nvhdmi),
4346 HDA_CODEC_ENTRY(0x10de0062, "GPU 62 HDMI/DP", patch_nvhdmi),
4347 HDA_CODEC_ENTRY(0x10de0067, "MCP67 HDMI", patch_nvhdmi_2ch),
4348 HDA_CODEC_ENTRY(0x10de0070, "GPU 70 HDMI/DP", patch_nvhdmi),
4349 HDA_CODEC_ENTRY(0x10de0071, "GPU 71 HDMI/DP", patch_nvhdmi),
4350 HDA_CODEC_ENTRY(0x10de0072, "GPU 72 HDMI/DP", patch_nvhdmi),
4351 HDA_CODEC_ENTRY(0x10de0073, "GPU 73 HDMI/DP", patch_nvhdmi),
4352 HDA_CODEC_ENTRY(0x10de0074, "GPU 74 HDMI/DP", patch_nvhdmi),
4353 HDA_CODEC_ENTRY(0x10de0076, "GPU 76 HDMI/DP", patch_nvhdmi),
4354 HDA_CODEC_ENTRY(0x10de007b, "GPU 7b HDMI/DP", patch_nvhdmi),
4355 HDA_CODEC_ENTRY(0x10de007c, "GPU 7c HDMI/DP", patch_nvhdmi),
4356 HDA_CODEC_ENTRY(0x10de007d, "GPU 7d HDMI/DP", patch_nvhdmi),
4357 HDA_CODEC_ENTRY(0x10de007e, "GPU 7e HDMI/DP", patch_nvhdmi),
4358 HDA_CODEC_ENTRY(0x10de0080, "GPU 80 HDMI/DP", patch_nvhdmi),
4359 HDA_CODEC_ENTRY(0x10de0081, "GPU 81 HDMI/DP", patch_nvhdmi),
4360 HDA_CODEC_ENTRY(0x10de0082, "GPU 82 HDMI/DP", patch_nvhdmi),
4361 HDA_CODEC_ENTRY(0x10de0083, "GPU 83 HDMI/DP", patch_nvhdmi),
4362 HDA_CODEC_ENTRY(0x10de0084, "GPU 84 HDMI/DP", patch_nvhdmi),
4363 HDA_CODEC_ENTRY(0x10de0090, "GPU 90 HDMI/DP", patch_nvhdmi),
4364 HDA_CODEC_ENTRY(0x10de0091, "GPU 91 HDMI/DP", patch_nvhdmi),
4365 HDA_CODEC_ENTRY(0x10de0092, "GPU 92 HDMI/DP", patch_nvhdmi),
4366 HDA_CODEC_ENTRY(0x10de0093, "GPU 93 HDMI/DP", patch_nvhdmi),
4367 HDA_CODEC_ENTRY(0x10de0094, "GPU 94 HDMI/DP", patch_nvhdmi),
4368 HDA_CODEC_ENTRY(0x10de0095, "GPU 95 HDMI/DP", patch_nvhdmi),
4369 HDA_CODEC_ENTRY(0x10de0097, "GPU 97 HDMI/DP", patch_nvhdmi),
4370 HDA_CODEC_ENTRY(0x10de0098, "GPU 98 HDMI/DP", patch_nvhdmi),
4371 HDA_CODEC_ENTRY(0x10de0099, "GPU 99 HDMI/DP", patch_nvhdmi),
4372 HDA_CODEC_ENTRY(0x10de009a, "GPU 9a HDMI/DP", patch_nvhdmi),
4373 HDA_CODEC_ENTRY(0x10de009d, "GPU 9d HDMI/DP", patch_nvhdmi),
4374 HDA_CODEC_ENTRY(0x10de009e, "GPU 9e HDMI/DP", patch_nvhdmi),
4375 HDA_CODEC_ENTRY(0x10de009f, "GPU 9f HDMI/DP", patch_nvhdmi),
4376 HDA_CODEC_ENTRY(0x10de00a0, "GPU a0 HDMI/DP", patch_nvhdmi),
4377 HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI", patch_nvhdmi_2ch),
4378 HDA_CODEC_ENTRY(0x10de8067, "MCP67/68 HDMI", patch_nvhdmi_2ch),
4379 HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP", patch_via_hdmi),
4380 HDA_CODEC_ENTRY(0x11069f81, "VX900 HDMI/DP", patch_via_hdmi),
4381 HDA_CODEC_ENTRY(0x11069f84, "VX11 HDMI/DP", patch_generic_hdmi),
4382 HDA_CODEC_ENTRY(0x11069f85, "VX11 HDMI/DP", patch_generic_hdmi),
4383 HDA_CODEC_ENTRY(0x80860054, "IbexPeak HDMI", patch_i915_cpt_hdmi),
4384 HDA_CODEC_ENTRY(0x80862800, "Geminilake HDMI", patch_i915_glk_hdmi),
4385 HDA_CODEC_ENTRY(0x80862801, "Bearlake HDMI", patch_generic_hdmi),
4386 HDA_CODEC_ENTRY(0x80862802, "Cantiga HDMI", patch_generic_hdmi),
4387 HDA_CODEC_ENTRY(0x80862803, "Eaglelake HDMI", patch_generic_hdmi),
4388 HDA_CODEC_ENTRY(0x80862804, "IbexPeak HDMI", patch_i915_cpt_hdmi),
4389 HDA_CODEC_ENTRY(0x80862805, "CougarPoint HDMI", patch_i915_cpt_hdmi),
4390 HDA_CODEC_ENTRY(0x80862806, "PantherPoint HDMI", patch_i915_cpt_hdmi),
4391 HDA_CODEC_ENTRY(0x80862807, "Haswell HDMI", patch_i915_hsw_hdmi),
4392 HDA_CODEC_ENTRY(0x80862808, "Broadwell HDMI", patch_i915_hsw_hdmi),
4393 HDA_CODEC_ENTRY(0x80862809, "Skylake HDMI", patch_i915_hsw_hdmi),
4394 HDA_CODEC_ENTRY(0x8086280a, "Broxton HDMI", patch_i915_hsw_hdmi),
4395 HDA_CODEC_ENTRY(0x8086280b, "Kabylake HDMI", patch_i915_hsw_hdmi),
4396 HDA_CODEC_ENTRY(0x8086280c, "Cannonlake HDMI", patch_i915_glk_hdmi),
4397 HDA_CODEC_ENTRY(0x8086280d, "Geminilake HDMI", patch_i915_glk_hdmi),
4398 HDA_CODEC_ENTRY(0x8086280f, "Icelake HDMI", patch_i915_icl_hdmi),
4399 HDA_CODEC_ENTRY(0x80862812, "Tigerlake HDMI", patch_i915_tgl_hdmi),
4400 HDA_CODEC_ENTRY(0x80862814, "DG1 HDMI", patch_i915_tgl_hdmi),
4401 HDA_CODEC_ENTRY(0x80862815, "Alderlake HDMI", patch_i915_tgl_hdmi),
4402 HDA_CODEC_ENTRY(0x80862816, "Rocketlake HDMI", patch_i915_tgl_hdmi),
4403 HDA_CODEC_ENTRY(0x80862819, "DG2 HDMI", patch_i915_tgl_hdmi),
4404 HDA_CODEC_ENTRY(0x8086281a, "Jasperlake HDMI", patch_i915_icl_hdmi),
4405 HDA_CODEC_ENTRY(0x8086281b, "Elkhartlake HDMI", patch_i915_icl_hdmi),
4406 HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi),
4407 HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi),
4408 HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_i915_byt_hdmi),
4409 HDA_CODEC_ENTRY(0x80862883, "Braswell HDMI", patch_i915_byt_hdmi),
4410 HDA_CODEC_ENTRY(0x808629fb, "Crestline HDMI", patch_generic_hdmi),
4418 MODULE_DESCRIPTION("HDMI HD-audio codec");
4419 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4420 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4421 MODULE_ALIAS("snd-hda-codec-atihdmi");