forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/pci/hda/patch_hdmi.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * patch_hdmi.c - routines for HDMI/DisplayPort codecs
....@@ -13,24 +14,11 @@
1314 *
1415 * Maintained by:
1516 * Wu Fengguang <wfg@linux.intel.com>
16
- *
17
- * This program is free software; you can redistribute it and/or modify it
18
- * under the terms of the GNU General Public License as published by the Free
19
- * Software Foundation; either version 2 of the License, or (at your option)
20
- * any later version.
21
- *
22
- * This program is distributed in the hope that it will be useful, but
23
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25
- * for more details.
26
- *
27
- * You should have received a copy of the GNU General Public License
28
- * along with this program; if not, write to the Free Software Foundation,
29
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3017 */
3118
3219 #include <linux/init.h>
3320 #include <linux/delay.h>
21
+#include <linux/pci.h>
3422 #include <linux/slab.h>
3523 #include <linux/module.h>
3624 #include <linux/pm_runtime.h>
....@@ -41,29 +29,23 @@
4129 #include <sound/hdaudio.h>
4230 #include <sound/hda_i915.h>
4331 #include <sound/hda_chmap.h>
44
-#include "hda_codec.h"
32
+#include <sound/hda_codec.h>
4533 #include "hda_local.h"
4634 #include "hda_jack.h"
35
+#include "hda_controller.h"
4736
4837 static bool static_hdmi_pcm;
4938 module_param(static_hdmi_pcm, bool, 0644);
5039 MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info");
5140
52
-#define is_haswell(codec) ((codec)->core.vendor_id == 0x80862807)
53
-#define is_broadwell(codec) ((codec)->core.vendor_id == 0x80862808)
54
-#define is_skylake(codec) ((codec)->core.vendor_id == 0x80862809)
55
-#define is_broxton(codec) ((codec)->core.vendor_id == 0x8086280a)
56
-#define is_kabylake(codec) ((codec)->core.vendor_id == 0x8086280b)
57
-#define is_geminilake(codec) (((codec)->core.vendor_id == 0x8086280d) || \
58
- ((codec)->core.vendor_id == 0x80862800))
59
-#define is_cannonlake(codec) ((codec)->core.vendor_id == 0x8086280c)
60
-#define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \
61
- || is_skylake(codec) || is_broxton(codec) \
62
- || is_kabylake(codec)) || is_geminilake(codec) \
63
- || is_cannonlake(codec)
64
-#define is_valleyview(codec) ((codec)->core.vendor_id == 0x80862882)
65
-#define is_cherryview(codec) ((codec)->core.vendor_id == 0x80862883)
66
-#define is_valleyview_plus(codec) (is_valleyview(codec) || is_cherryview(codec))
41
+static bool enable_acomp = true;
42
+module_param(enable_acomp, bool, 0444);
43
+MODULE_PARM_DESC(enable_acomp, "Enable audio component binding (default=yes)");
44
+
45
+static bool enable_silent_stream =
46
+IS_ENABLED(CONFIG_SND_HDA_INTEL_HDMI_SILENT_STREAM);
47
+module_param(enable_silent_stream, bool, 0644);
48
+MODULE_PARM_DESC(enable_silent_stream, "Enable Silent Stream for HDMI devices");
6749
6850 struct hdmi_spec_per_cvt {
6951 hda_nid_t cvt_nid;
....@@ -96,6 +78,7 @@
9678 int pcm_idx; /* which pcm is attached. -1 means no pcm is attached */
9779 int repoll_count;
9880 bool setup; /* the stream has been set up by prepare callback */
81
+ bool silent_stream;
9982 int channels; /* current number of channels */
10083 bool non_pcm;
10184 bool chmap_set; /* channel-map override by ALSA API? */
....@@ -108,16 +91,19 @@
10891 /* operations used by generic code that can be overridden by patches */
10992 struct hdmi_ops {
11093 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
111
- unsigned char *buf, int *eld_size);
94
+ int dev_id, unsigned char *buf, int *eld_size);
11295
11396 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
97
+ int dev_id,
11498 int ca, int active_channels, int conn_type);
11599
116100 /* enable/disable HBR (HD passthrough) */
117
- int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid, bool hbr);
101
+ int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid,
102
+ int dev_id, bool hbr);
118103
119104 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
120
- hda_nid_t pin_nid, u32 stream_tag, int format);
105
+ hda_nid_t pin_nid, int dev_id, u32 stream_tag,
106
+ int format);
121107
122108 void (*pin_cvt_fixup)(struct hda_codec *codec,
123109 struct hdmi_spec_per_pin *per_pin,
....@@ -131,6 +117,7 @@
131117 };
132118
133119 struct hdmi_spec {
120
+ struct hda_codec *codec;
134121 int num_cvts;
135122 struct snd_array cvts; /* struct hdmi_spec_per_cvt */
136123 hda_nid_t cvt_nids[4]; /* only for haswell fix */
....@@ -155,6 +142,7 @@
155142 struct snd_array pins; /* struct hdmi_spec_per_pin */
156143 struct hdmi_pcm pcm_rec[16];
157144 struct mutex pcm_lock;
145
+ struct mutex bind_lock; /* for audio component binding */
158146 /* pcm_bitmap means which pcms have been assigned to pins*/
159147 unsigned long pcm_bitmap;
160148 int pcm_used; /* counter of pcm_rec[] */
....@@ -169,18 +157,27 @@
169157
170158 bool dyn_pin_out;
171159 bool dyn_pcm_assign;
160
+ bool dyn_pcm_no_legacy;
161
+ bool nv_dp_workaround; /* workaround DP audio infoframe for Nvidia */
162
+
163
+ bool intel_hsw_fixup; /* apply Intel platform-specific fixups */
172164 /*
173165 * Non-generic VIA/NVIDIA specific
174166 */
175167 struct hda_multi_out multiout;
176168 struct hda_pcm_stream pcm_playback;
177169
178
- /* i915/powerwell (Haswell+/Valleyview+) specific */
179
- bool use_acomp_notifier; /* use i915 eld_notify callback for hotplug */
170
+ bool use_acomp_notifier; /* use eld_notify callback for hotplug */
171
+ bool acomp_registered; /* audio component registered in this driver */
172
+ bool force_connect; /* force connectivity */
180173 struct drm_audio_component_audio_ops drm_audio_ops;
174
+ int (*port2pin)(struct hda_codec *, int); /* reverse port/pin mapping */
181175
182176 struct hdac_chmap chmap;
183177 hda_nid_t vendor_nid;
178
+ const int *port_map;
179
+ int port_num;
180
+ bool send_silent_stream; /* Flag to enable silent stream feature */
184181 };
185182
186183 #ifdef CONFIG_SND_HDA_COMPONENT
....@@ -273,7 +270,7 @@
273270 if (get_pcm_rec(spec, pcm_idx)->stream == hinfo)
274271 return pcm_idx;
275272
276
- codec_warn(codec, "HDMI: hinfo %p not registered\n", hinfo);
273
+ codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo);
277274 return -EINVAL;
278275 }
279276
....@@ -291,7 +288,8 @@
291288 return pin_idx;
292289 }
293290
294
- codec_dbg(codec, "HDMI: hinfo %p not registered\n", hinfo);
291
+ codec_dbg(codec, "HDMI: hinfo %p (pcm %d) not registered\n", hinfo,
292
+ hinfo_to_pcm_index(codec, hinfo));
295293 return -EINVAL;
296294 }
297295
....@@ -389,7 +387,8 @@
389387 }
390388
391389 static const struct snd_kcontrol_new eld_bytes_ctl = {
392
- .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
390
+ .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE |
391
+ SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK,
393392 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
394393 .name = "ELD",
395394 .info = hdmi_eld_ctl_info,
....@@ -657,20 +656,37 @@
657656 return true;
658657 }
659658
659
+static int hdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid,
660
+ int dev_id, unsigned char *buf, int *eld_size)
661
+{
662
+ snd_hda_set_dev_select(codec, nid, dev_id);
663
+
664
+ return snd_hdmi_get_eld(codec, nid, buf, eld_size);
665
+}
666
+
660667 static void hdmi_pin_setup_infoframe(struct hda_codec *codec,
661
- hda_nid_t pin_nid,
668
+ hda_nid_t pin_nid, int dev_id,
662669 int ca, int active_channels,
663670 int conn_type)
664671 {
672
+ struct hdmi_spec *spec = codec->spec;
665673 union audio_infoframe ai;
666674
667675 memset(&ai, 0, sizeof(ai));
668
- if (conn_type == 0) { /* HDMI */
676
+ if ((conn_type == 0) || /* HDMI */
677
+ /* Nvidia DisplayPort: Nvidia HW expects same layout as HDMI */
678
+ (conn_type == 1 && spec->nv_dp_workaround)) {
669679 struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi;
670680
671
- hdmi_ai->type = 0x84;
672
- hdmi_ai->ver = 0x01;
673
- hdmi_ai->len = 0x0a;
681
+ if (conn_type == 0) { /* HDMI */
682
+ hdmi_ai->type = 0x84;
683
+ hdmi_ai->ver = 0x01;
684
+ hdmi_ai->len = 0x0a;
685
+ } else {/* Nvidia DP */
686
+ hdmi_ai->type = 0x84;
687
+ hdmi_ai->ver = 0x1b;
688
+ hdmi_ai->len = 0x11 << 2;
689
+ }
674690 hdmi_ai->CC02_CT47 = active_channels - 1;
675691 hdmi_ai->CA = ca;
676692 hdmi_checksum_audio_infoframe(hdmi_ai);
....@@ -687,6 +703,8 @@
687703 pin_nid);
688704 return;
689705 }
706
+
707
+ snd_hda_set_dev_select(codec, pin_nid, dev_id);
690708
691709 /*
692710 * sizeof(ai) is used instead of sizeof(*hdmi_ai) or
....@@ -713,6 +731,7 @@
713731 struct hdmi_spec *spec = codec->spec;
714732 struct hdac_chmap *chmap = &spec->chmap;
715733 hda_nid_t pin_nid = per_pin->pin_nid;
734
+ int dev_id = per_pin->dev_id;
716735 int channels = per_pin->channels;
717736 int active_channels;
718737 struct hdmi_eld *eld;
....@@ -720,6 +739,8 @@
720739
721740 if (!channels)
722741 return;
742
+
743
+ snd_hda_set_dev_select(codec, pin_nid, dev_id);
723744
724745 /* some HW (e.g. HSW+) needs reprogramming the amp at each time */
725746 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
....@@ -746,8 +767,8 @@
746767 pin_nid, non_pcm, ca, channels,
747768 per_pin->chmap, per_pin->chmap_set);
748769
749
- spec->ops.pin_setup_infoframe(codec, pin_nid, ca, active_channels,
750
- eld->info.conn_type);
770
+ spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id,
771
+ ca, active_channels, eld->info.conn_type);
751772
752773 per_pin->non_pcm = non_pcm;
753774 }
....@@ -756,7 +777,7 @@
756777 * Unsolicited events
757778 */
758779
759
-static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
780
+static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
760781
761782 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid,
762783 int dev_id)
....@@ -767,42 +788,31 @@
767788 if (pin_idx < 0)
768789 return;
769790 mutex_lock(&spec->pcm_lock);
770
- if (hdmi_present_sense(get_pin(spec, pin_idx), 1))
771
- snd_hda_jack_report_sync(codec);
791
+ hdmi_present_sense(get_pin(spec, pin_idx), 1);
772792 mutex_unlock(&spec->pcm_lock);
773793 }
774794
775795 static void jack_callback(struct hda_codec *codec,
776796 struct hda_jack_callback *jack)
777797 {
778
- /* hda_jack don't support DP MST */
779
- check_presence_and_report(codec, jack->nid, 0);
798
+ /* stop polling when notification is enabled */
799
+ if (codec_has_acomp(codec))
800
+ return;
801
+
802
+ check_presence_and_report(codec, jack->nid, jack->dev_id);
780803 }
781804
782
-static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
805
+static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res,
806
+ struct hda_jack_tbl *jack)
783807 {
784
- int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
785
- struct hda_jack_tbl *jack;
786
- int dev_entry = (res & AC_UNSOL_RES_DE) >> AC_UNSOL_RES_DE_SHIFT;
787
-
788
- /*
789
- * assume DP MST uses dyn_pcm_assign and acomp and
790
- * never comes here
791
- * if DP MST supports unsol event, below code need
792
- * consider dev_entry
793
- */
794
- jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
795
- if (!jack)
796
- return;
797808 jack->jack_dirty = 1;
798809
799810 codec_dbg(codec,
800811 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n",
801
- codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA),
812
+ codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA),
802813 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV));
803814
804
- /* hda_jack don't support DP MST */
805
- check_presence_and_report(codec, jack->nid, 0);
815
+ check_presence_and_report(codec, jack->nid, jack->dev_id);
806816 }
807817
808818 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
....@@ -821,10 +831,12 @@
821831 cp_ready);
822832
823833 /* TODO */
824
- if (cp_state)
834
+ if (cp_state) {
825835 ;
826
- if (cp_ready)
836
+ }
837
+ if (cp_ready) {
827838 ;
839
+ }
828840 }
829841
830842
....@@ -832,14 +844,27 @@
832844 {
833845 int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
834846 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
847
+ struct hda_jack_tbl *jack;
835848
836
- if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) {
849
+ if (codec_has_acomp(codec))
850
+ return;
851
+
852
+ if (codec->dp_mst) {
853
+ int dev_entry =
854
+ (res & AC_UNSOL_RES_DE) >> AC_UNSOL_RES_DE_SHIFT;
855
+
856
+ jack = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry);
857
+ } else {
858
+ jack = snd_hda_jack_tbl_get_from_tag(codec, tag, 0);
859
+ }
860
+
861
+ if (!jack) {
837862 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag);
838863 return;
839864 }
840865
841866 if (subtag == 0)
842
- hdmi_intrinsic_event(codec, res);
867
+ hdmi_intrinsic_event(codec, res, jack);
843868 else
844869 hdmi_non_intrinsic_event(codec, res);
845870 }
....@@ -874,11 +899,12 @@
874899 ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7)
875900
876901 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
877
- bool hbr)
902
+ int dev_id, bool hbr)
878903 {
879904 int pinctl, new_pinctl;
880905
881906 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) {
907
+ snd_hda_set_dev_select(codec, pin_nid, dev_id);
882908 pinctl = snd_hda_codec_read(codec, pin_nid, 0,
883909 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
884910
....@@ -908,20 +934,22 @@
908934 }
909935
910936 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
911
- hda_nid_t pin_nid, u32 stream_tag, int format)
937
+ hda_nid_t pin_nid, int dev_id,
938
+ u32 stream_tag, int format)
912939 {
913940 struct hdmi_spec *spec = codec->spec;
914941 unsigned int param;
915942 int err;
916943
917
- err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format));
944
+ err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id,
945
+ is_hbr_format(format));
918946
919947 if (err) {
920948 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n");
921949 return err;
922950 }
923951
924
- if (is_haswell_plus(codec)) {
952
+ if (spec->intel_hsw_fixup) {
925953
926954 /*
927955 * on recent platforms IEC Coding Type is required for HBR
....@@ -963,6 +991,13 @@
963991 per_pin = NULL;
964992 else
965993 per_pin = get_pin(spec, pin_idx);
994
+
995
+ if (per_pin && per_pin->silent_stream) {
996
+ cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid);
997
+ if (cvt_id)
998
+ *cvt_id = cvt_idx;
999
+ return 0;
1000
+ }
9661001
9671002 /* Dynamically assign converter to stream */
9681003 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) {
....@@ -1234,7 +1269,12 @@
12341269 set_bit(pcm_idx, &spec->pcm_in_use);
12351270 per_pin = get_pin(spec, pin_idx);
12361271 per_pin->cvt_nid = per_cvt->cvt_nid;
1272
+ per_pin->silent_stream = false;
12371273 hinfo->nid = per_cvt->cvt_nid;
1274
+
1275
+ /* flip stripe flag for the assigned stream if supported */
1276
+ if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE)
1277
+ azx_stream(get_azx_dev(substream))->stripe = 1;
12381278
12391279 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id);
12401280 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
....@@ -1288,6 +1328,8 @@
12881328 struct hdmi_spec *spec = codec->spec;
12891329 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
12901330 hda_nid_t pin_nid = per_pin->pin_nid;
1331
+ int dev_id = per_pin->dev_id;
1332
+ int conns;
12911333
12921334 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
12931335 codec_warn(codec,
....@@ -1296,31 +1338,67 @@
12961338 return -EINVAL;
12971339 }
12981340
1341
+ snd_hda_set_dev_select(codec, pin_nid, dev_id);
1342
+
1343
+ if (spec->intel_hsw_fixup) {
1344
+ conns = spec->num_cvts;
1345
+ memcpy(per_pin->mux_nids, spec->cvt_nids,
1346
+ sizeof(hda_nid_t) * conns);
1347
+ } else {
1348
+ conns = snd_hda_get_raw_connections(codec, pin_nid,
1349
+ per_pin->mux_nids,
1350
+ HDA_MAX_CONNECTIONS);
1351
+ }
1352
+
12991353 /* all the device entries on the same pin have the same conn list */
1300
- per_pin->num_mux_nids = snd_hda_get_connections(codec, pin_nid,
1301
- per_pin->mux_nids,
1302
- HDA_MAX_CONNECTIONS);
1354
+ per_pin->num_mux_nids = conns;
13031355
13041356 return 0;
13051357 }
13061358
13071359 static int hdmi_find_pcm_slot(struct hdmi_spec *spec,
1308
- struct hdmi_spec_per_pin *per_pin)
1360
+ struct hdmi_spec_per_pin *per_pin)
13091361 {
13101362 int i;
13111363
1312
- /* try the prefer PCM */
1313
- if (!test_bit(per_pin->pin_nid_idx, &spec->pcm_bitmap))
1314
- return per_pin->pin_nid_idx;
1364
+ /* on the new machines, try to assign the pcm slot dynamically,
1365
+ * not use the preferred fixed map (legacy way) anymore.
1366
+ */
1367
+ if (spec->dyn_pcm_no_legacy)
1368
+ goto last_try;
13151369
1316
- /* have a second try; check the "reserved area" over num_pins */
1370
+ /*
1371
+ * generic_hdmi_build_pcms() may allocate extra PCMs on some
1372
+ * platforms (with maximum of 'num_nids + dev_num - 1')
1373
+ *
1374
+ * The per_pin of pin_nid_idx=n and dev_id=m prefers to get pcm-n
1375
+ * if m==0. This guarantees that dynamic pcm assignments are compatible
1376
+ * with the legacy static per_pin-pcm assignment that existed in the
1377
+ * days before DP-MST.
1378
+ *
1379
+ * Intel DP-MST prefers this legacy behavior for compatibility, too.
1380
+ *
1381
+ * per_pin of m!=0 prefers to get pcm=(num_nids + (m - 1)).
1382
+ */
1383
+
1384
+ if (per_pin->dev_id == 0 || spec->intel_hsw_fixup) {
1385
+ if (!test_bit(per_pin->pin_nid_idx, &spec->pcm_bitmap))
1386
+ return per_pin->pin_nid_idx;
1387
+ } else {
1388
+ i = spec->num_nids + (per_pin->dev_id - 1);
1389
+ if (i < spec->pcm_used && !(test_bit(i, &spec->pcm_bitmap)))
1390
+ return i;
1391
+ }
1392
+
1393
+ /* have a second try; check the area over num_nids */
13171394 for (i = spec->num_nids; i < spec->pcm_used; i++) {
13181395 if (!test_bit(i, &spec->pcm_bitmap))
13191396 return i;
13201397 }
13211398
1399
+ last_try:
13221400 /* the last try; check the empty slots in pins */
1323
- for (i = 0; i < spec->num_nids; i++) {
1401
+ for (i = 0; i < spec->pcm_used; i++) {
13241402 if (!test_bit(i, &spec->pcm_bitmap))
13251403 return i;
13261404 }
....@@ -1428,21 +1506,60 @@
14281506 per_pin->channels = 0;
14291507 }
14301508
1509
+static struct snd_jack *pin_idx_to_pcm_jack(struct hda_codec *codec,
1510
+ struct hdmi_spec_per_pin *per_pin)
1511
+{
1512
+ struct hdmi_spec *spec = codec->spec;
1513
+
1514
+ if (per_pin->pcm_idx >= 0)
1515
+ return spec->pcm_rec[per_pin->pcm_idx].jack;
1516
+ else
1517
+ return NULL;
1518
+}
1519
+
14311520 /* update per_pin ELD from the given new ELD;
14321521 * setup info frame and notification accordingly
1522
+ * also notify ELD kctl and report jack status changes
14331523 */
14341524 static void update_eld(struct hda_codec *codec,
14351525 struct hdmi_spec_per_pin *per_pin,
1436
- struct hdmi_eld *eld)
1526
+ struct hdmi_eld *eld,
1527
+ int repoll)
14371528 {
14381529 struct hdmi_eld *pin_eld = &per_pin->sink_eld;
14391530 struct hdmi_spec *spec = codec->spec;
1531
+ struct snd_jack *pcm_jack;
14401532 bool old_eld_valid = pin_eld->eld_valid;
14411533 bool eld_changed;
1442
- int pcm_idx = -1;
1534
+ int pcm_idx;
1535
+
1536
+ if (eld->eld_valid) {
1537
+ if (eld->eld_size <= 0 ||
1538
+ snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer,
1539
+ eld->eld_size) < 0) {
1540
+ eld->eld_valid = false;
1541
+ if (repoll) {
1542
+ schedule_delayed_work(&per_pin->work,
1543
+ msecs_to_jiffies(300));
1544
+ return;
1545
+ }
1546
+ }
1547
+ }
1548
+
1549
+ if (!eld->eld_valid || eld->eld_size <= 0) {
1550
+ eld->eld_valid = false;
1551
+ eld->eld_size = 0;
1552
+ }
14431553
14441554 /* for monitor disconnection, save pcm_idx firstly */
14451555 pcm_idx = per_pin->pcm_idx;
1556
+
1557
+ /*
1558
+ * pcm_idx >=0 before update_eld() means it is in monitor
1559
+ * disconnected event. Jack must be fetched before update_eld().
1560
+ */
1561
+ pcm_jack = pin_idx_to_pcm_jack(codec, per_pin);
1562
+
14461563 if (spec->dyn_pcm_assign) {
14471564 if (eld->eld_valid) {
14481565 hdmi_attach_hda_pcm(spec, per_pin);
....@@ -1457,23 +1574,29 @@
14571574 */
14581575 if (pcm_idx == -1)
14591576 pcm_idx = per_pin->pcm_idx;
1577
+ if (!pcm_jack)
1578
+ pcm_jack = pin_idx_to_pcm_jack(codec, per_pin);
14601579
14611580 if (eld->eld_valid)
14621581 snd_hdmi_show_eld(codec, &eld->info);
14631582
14641583 eld_changed = (pin_eld->eld_valid != eld->eld_valid);
1465
- if (eld->eld_valid && pin_eld->eld_valid)
1584
+ eld_changed |= (pin_eld->monitor_present != eld->monitor_present);
1585
+ if (!eld_changed && eld->eld_valid && pin_eld->eld_valid)
14661586 if (pin_eld->eld_size != eld->eld_size ||
14671587 memcmp(pin_eld->eld_buffer, eld->eld_buffer,
14681588 eld->eld_size) != 0)
14691589 eld_changed = true;
14701590
1471
- pin_eld->monitor_present = eld->monitor_present;
1472
- pin_eld->eld_valid = eld->eld_valid;
1473
- pin_eld->eld_size = eld->eld_size;
1474
- if (eld->eld_valid)
1475
- memcpy(pin_eld->eld_buffer, eld->eld_buffer, eld->eld_size);
1476
- pin_eld->info = eld->info;
1591
+ if (eld_changed) {
1592
+ pin_eld->monitor_present = eld->monitor_present;
1593
+ pin_eld->eld_valid = eld->eld_valid;
1594
+ pin_eld->eld_size = eld->eld_size;
1595
+ if (eld->eld_valid)
1596
+ memcpy(pin_eld->eld_buffer, eld->eld_buffer,
1597
+ eld->eld_size);
1598
+ pin_eld->info = eld->info;
1599
+ }
14771600
14781601 /*
14791602 * Re-setup pin and infoframe. This is needed e.g. when
....@@ -1491,17 +1614,23 @@
14911614 SNDRV_CTL_EVENT_MASK_VALUE |
14921615 SNDRV_CTL_EVENT_MASK_INFO,
14931616 &get_hdmi_pcm(spec, pcm_idx)->eld_ctl->id);
1617
+
1618
+ if (eld_changed && pcm_jack)
1619
+ snd_jack_report(pcm_jack,
1620
+ (eld->monitor_present && eld->eld_valid) ?
1621
+ SND_JACK_AVOUT : 0);
14941622 }
14951623
14961624 /* update ELD and jack state via HD-audio verbs */
1497
-static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
1625
+static void hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
14981626 int repoll)
14991627 {
1500
- struct hda_jack_tbl *jack;
15011628 struct hda_codec *codec = per_pin->codec;
15021629 struct hdmi_spec *spec = codec->spec;
15031630 struct hdmi_eld *eld = &spec->temp_eld;
1631
+ struct device *dev = hda_codec_dev(codec);
15041632 hda_nid_t pin_nid = per_pin->pin_nid;
1633
+ int dev_id = per_pin->dev_id;
15051634 /*
15061635 * Always execute a GetPinSense verb here, even when called from
15071636 * hdmi_intrinsic_event; for some NVIDIA HW, the unsolicited
....@@ -1511,10 +1640,18 @@
15111640 * the unsolicited response to avoid custom WARs.
15121641 */
15131642 int present;
1514
- bool ret;
1515
- bool do_repoll = false;
1643
+ int ret;
15161644
1517
- present = snd_hda_pin_sense(codec, pin_nid);
1645
+#ifdef CONFIG_PM
1646
+ if (dev->power.runtime_status == RPM_SUSPENDING)
1647
+ return;
1648
+#endif
1649
+
1650
+ ret = snd_hda_power_up_pm(codec);
1651
+ if (ret < 0 && pm_runtime_suspended(dev))
1652
+ goto out;
1653
+
1654
+ present = snd_hda_jack_pin_sense(codec, pin_nid, dev_id);
15181655
15191656 mutex_lock(&per_pin->lock);
15201657 eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
....@@ -1528,61 +1665,104 @@
15281665 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid);
15291666
15301667 if (eld->eld_valid) {
1531
- if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer,
1532
- &eld->eld_size) < 0)
1668
+ if (spec->ops.pin_get_eld(codec, pin_nid, dev_id,
1669
+ eld->eld_buffer, &eld->eld_size) < 0)
15331670 eld->eld_valid = false;
1534
- else {
1535
- if (snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer,
1536
- eld->eld_size) < 0)
1537
- eld->eld_valid = false;
1538
- }
1539
- if (!eld->eld_valid && repoll)
1540
- do_repoll = true;
15411671 }
15421672
1543
- if (do_repoll)
1544
- schedule_delayed_work(&per_pin->work, msecs_to_jiffies(300));
1545
- else
1546
- update_eld(codec, per_pin, eld);
1547
-
1548
- ret = !repoll || !eld->monitor_present || eld->eld_valid;
1549
-
1550
- jack = snd_hda_jack_tbl_get(codec, pin_nid);
1551
- if (jack) {
1552
- jack->block_report = !ret;
1553
- jack->pin_sense = (eld->monitor_present && eld->eld_valid) ?
1554
- AC_PINSENSE_PRESENCE : 0;
1555
- }
1673
+ update_eld(codec, per_pin, eld, repoll);
15561674 mutex_unlock(&per_pin->lock);
1557
- return ret;
1675
+ out:
1676
+ snd_hda_power_down_pm(codec);
15581677 }
15591678
1560
-static struct snd_jack *pin_idx_to_jack(struct hda_codec *codec,
1679
+#define I915_SILENT_RATE 48000
1680
+#define I915_SILENT_CHANNELS 2
1681
+#define I915_SILENT_FORMAT SNDRV_PCM_FORMAT_S16_LE
1682
+#define I915_SILENT_FORMAT_BITS 16
1683
+#define I915_SILENT_FMT_MASK 0xf
1684
+
1685
+static void silent_stream_enable(struct hda_codec *codec,
15611686 struct hdmi_spec_per_pin *per_pin)
15621687 {
15631688 struct hdmi_spec *spec = codec->spec;
1564
- struct snd_jack *jack = NULL;
1565
- struct hda_jack_tbl *jack_tbl;
1689
+ struct hdmi_spec_per_cvt *per_cvt;
1690
+ int cvt_idx, pin_idx, err;
1691
+ unsigned int format;
15661692
1567
- /* if !dyn_pcm_assign, get jack from hda_jack_tbl
1568
- * in !dyn_pcm_assign case, spec->pcm_rec[].jack is not
1569
- * NULL even after snd_hda_jack_tbl_clear() is called to
1570
- * free snd_jack. This may cause access invalid memory
1571
- * when calling snd_jack_report
1572
- */
1573
- if (per_pin->pcm_idx >= 0 && spec->dyn_pcm_assign)
1574
- jack = spec->pcm_rec[per_pin->pcm_idx].jack;
1575
- else if (!spec->dyn_pcm_assign) {
1576
- /*
1577
- * jack tbl doesn't support DP MST
1578
- * DP MST will use dyn_pcm_assign,
1579
- * so DP MST will never come here
1580
- */
1581
- jack_tbl = snd_hda_jack_tbl_get(codec, per_pin->pin_nid);
1582
- if (jack_tbl)
1583
- jack = jack_tbl->jack;
1693
+ mutex_lock(&per_pin->lock);
1694
+
1695
+ if (per_pin->setup) {
1696
+ codec_dbg(codec, "hdmi: PCM already open, no silent stream\n");
1697
+ goto unlock_out;
15841698 }
1585
- return jack;
1699
+
1700
+ pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id);
1701
+ err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx);
1702
+ if (err) {
1703
+ codec_err(codec, "hdmi: no free converter to enable silent mode\n");
1704
+ goto unlock_out;
1705
+ }
1706
+
1707
+ per_cvt = get_cvt(spec, cvt_idx);
1708
+ per_cvt->assigned = 1;
1709
+ per_pin->cvt_nid = per_cvt->cvt_nid;
1710
+ per_pin->silent_stream = true;
1711
+
1712
+ codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n",
1713
+ per_pin->pin_nid, per_cvt->cvt_nid);
1714
+
1715
+ snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id);
1716
+ snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
1717
+ AC_VERB_SET_CONNECT_SEL,
1718
+ per_pin->mux_idx);
1719
+
1720
+ /* configure unused pins to choose other converters */
1721
+ pin_cvt_fixup(codec, per_pin, 0);
1722
+
1723
+ snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid,
1724
+ per_pin->dev_id, I915_SILENT_RATE);
1725
+
1726
+ /* trigger silent stream generation in hw */
1727
+ format = snd_hdac_calc_stream_format(I915_SILENT_RATE, I915_SILENT_CHANNELS,
1728
+ I915_SILENT_FORMAT, I915_SILENT_FORMAT_BITS, 0);
1729
+ snd_hda_codec_setup_stream(codec, per_pin->cvt_nid,
1730
+ I915_SILENT_FMT_MASK, I915_SILENT_FMT_MASK, format);
1731
+ usleep_range(100, 200);
1732
+ snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format);
1733
+
1734
+ per_pin->channels = I915_SILENT_CHANNELS;
1735
+ hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm);
1736
+
1737
+ unlock_out:
1738
+ mutex_unlock(&per_pin->lock);
1739
+}
1740
+
1741
+static void silent_stream_disable(struct hda_codec *codec,
1742
+ struct hdmi_spec_per_pin *per_pin)
1743
+{
1744
+ struct hdmi_spec *spec = codec->spec;
1745
+ struct hdmi_spec_per_cvt *per_cvt;
1746
+ int cvt_idx;
1747
+
1748
+ mutex_lock(&per_pin->lock);
1749
+ if (!per_pin->silent_stream)
1750
+ goto unlock_out;
1751
+
1752
+ codec_dbg(codec, "HDMI: disable silent stream on pin-NID=0x%x cvt-NID=0x%x\n",
1753
+ per_pin->pin_nid, per_pin->cvt_nid);
1754
+
1755
+ cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid);
1756
+ if (cvt_idx >= 0 && cvt_idx < spec->num_cvts) {
1757
+ per_cvt = get_cvt(spec, cvt_idx);
1758
+ per_cvt->assigned = 0;
1759
+ }
1760
+
1761
+ per_pin->cvt_nid = 0;
1762
+ per_pin->silent_stream = false;
1763
+
1764
+ unlock_out:
1765
+ mutex_unlock(&per_pin->lock);
15861766 }
15871767
15881768 /* update ELD and jack state via audio component */
....@@ -1591,69 +1771,53 @@
15911771 {
15921772 struct hdmi_spec *spec = codec->spec;
15931773 struct hdmi_eld *eld = &spec->temp_eld;
1594
- struct snd_jack *jack = NULL;
1595
- int size;
1774
+ bool monitor_prev, monitor_next;
15961775
15971776 mutex_lock(&per_pin->lock);
15981777 eld->monitor_present = false;
1599
- size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid,
1778
+ monitor_prev = per_pin->sink_eld.monitor_present;
1779
+ eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid,
16001780 per_pin->dev_id, &eld->monitor_present,
16011781 eld->eld_buffer, ELD_MAX_SIZE);
1602
- if (size > 0) {
1603
- size = min(size, ELD_MAX_SIZE);
1604
- if (snd_hdmi_parse_eld(codec, &eld->info,
1605
- eld->eld_buffer, size) < 0)
1606
- size = -EINVAL;
1607
- }
1608
-
1609
- if (size > 0) {
1610
- eld->eld_valid = true;
1611
- eld->eld_size = size;
1612
- } else {
1613
- eld->eld_valid = false;
1614
- eld->eld_size = 0;
1615
- }
1616
-
1617
- /* pcm_idx >=0 before update_eld() means it is in monitor
1618
- * disconnected event. Jack must be fetched before update_eld()
1619
- */
1620
- jack = pin_idx_to_jack(codec, per_pin);
1621
- update_eld(codec, per_pin, eld);
1622
- if (jack == NULL)
1623
- jack = pin_idx_to_jack(codec, per_pin);
1624
- if (jack == NULL)
1625
- goto unlock;
1626
- snd_jack_report(jack,
1627
- eld->monitor_present ? SND_JACK_AVOUT : 0);
1628
- unlock:
1782
+ eld->eld_valid = (eld->eld_size > 0);
1783
+ update_eld(codec, per_pin, eld, 0);
1784
+ monitor_next = per_pin->sink_eld.monitor_present;
16291785 mutex_unlock(&per_pin->lock);
1630
-}
16311786
1632
-static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
1633
-{
1634
- struct hda_codec *codec = per_pin->codec;
1635
- int ret;
1787
+ /*
1788
+ * Power-up will call hdmi_present_sense, so the PM calls
1789
+ * have to be done without mutex held.
1790
+ */
16361791
1637
- /* no temporary power up/down needed for component notifier */
1638
- if (!codec_has_acomp(codec)) {
1639
- ret = snd_hda_power_up_pm(codec);
1640
- if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) {
1641
- snd_hda_power_down_pm(codec);
1642
- return false;
1792
+ if (spec->send_silent_stream) {
1793
+ int pm_ret;
1794
+
1795
+ if (!monitor_prev && monitor_next) {
1796
+ pm_ret = snd_hda_power_up_pm(codec);
1797
+ if (pm_ret < 0)
1798
+ codec_err(codec,
1799
+ "Monitor plugged-in, Failed to power up codec ret=[%d]\n",
1800
+ pm_ret);
1801
+ silent_stream_enable(codec, per_pin);
1802
+ } else if (monitor_prev && !monitor_next) {
1803
+ silent_stream_disable(codec, per_pin);
1804
+ pm_ret = snd_hda_power_down_pm(codec);
1805
+ if (pm_ret < 0)
1806
+ codec_err(codec,
1807
+ "Monitor plugged-out, Failed to power down codec ret=[%d]\n",
1808
+ pm_ret);
16431809 }
16441810 }
1811
+}
16451812
1646
- if (codec_has_acomp(codec)) {
1647
- sync_eld_via_acomp(codec, per_pin);
1648
- ret = false; /* don't call snd_hda_jack_report_sync() */
1649
- } else {
1650
- ret = hdmi_present_sense_via_verbs(per_pin, repoll);
1651
- }
1813
+static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
1814
+{
1815
+ struct hda_codec *codec = per_pin->codec;
16521816
16531817 if (!codec_has_acomp(codec))
1654
- snd_hda_power_down_pm(codec);
1655
-
1656
- return ret;
1818
+ hdmi_present_sense_via_verbs(per_pin, repoll);
1819
+ else
1820
+ sync_eld_via_acomp(codec, per_pin);
16571821 }
16581822
16591823 static void hdmi_repoll_eld(struct work_struct *work)
....@@ -1664,7 +1828,8 @@
16641828 struct hdmi_spec *spec = codec->spec;
16651829 struct hda_jack_tbl *jack;
16661830
1667
- jack = snd_hda_jack_tbl_get(codec, per_pin->pin_nid);
1831
+ jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid,
1832
+ per_pin->dev_id);
16681833 if (jack)
16691834 jack->jack_dirty = 1;
16701835
....@@ -1672,13 +1837,9 @@
16721837 per_pin->repoll_count = 0;
16731838
16741839 mutex_lock(&spec->pcm_lock);
1675
- if (hdmi_present_sense(per_pin, per_pin->repoll_count))
1676
- snd_hda_jack_report_sync(per_pin->codec);
1840
+ hdmi_present_sense(per_pin, per_pin->repoll_count);
16771841 mutex_unlock(&spec->pcm_lock);
16781842 }
1679
-
1680
-static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
1681
- hda_nid_t nid);
16821843
16831844 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
16841845 {
....@@ -1698,14 +1859,15 @@
16981859 * all device entries on the same pin
16991860 */
17001861 config = snd_hda_codec_get_pincfg(codec, pin_nid);
1701
- if (get_defcfg_connect(config) == AC_JACK_PORT_NONE)
1862
+ if (get_defcfg_connect(config) == AC_JACK_PORT_NONE &&
1863
+ !spec->force_connect)
17021864 return 0;
17031865
17041866 /*
17051867 * To simplify the implementation, malloc all
17061868 * the virtual pins in the initialization statically
17071869 */
1708
- if (is_haswell_plus(codec)) {
1870
+ if (spec->intel_hsw_fixup) {
17091871 /*
17101872 * On Intel platforms, device entries number is
17111873 * changed dynamically. If there is a DP MST
....@@ -1754,8 +1916,6 @@
17541916 per_pin->dev_id = i;
17551917 per_pin->non_pcm = false;
17561918 snd_hda_set_dev_select(codec, pin_nid, i);
1757
- if (is_haswell_plus(codec))
1758
- intel_haswell_fixup_connect_list(codec, pin_nid);
17591919 err = hdmi_read_pin_conn(codec, pin_idx);
17601920 if (err < 0)
17611921 return err;
....@@ -1802,35 +1962,61 @@
18021962 return 0;
18031963 }
18041964
1965
+static const struct snd_pci_quirk force_connect_list[] = {
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),
1971
+ {}
1972
+};
1973
+
18051974 static int hdmi_parse_codec(struct hda_codec *codec)
18061975 {
1807
- hda_nid_t nid;
1976
+ struct hdmi_spec *spec = codec->spec;
1977
+ hda_nid_t start_nid;
1978
+ unsigned int caps;
18081979 int i, nodes;
1980
+ const struct snd_pci_quirk *q;
18091981
1810
- nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &nid);
1811
- if (!nid || nodes < 0) {
1982
+ nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid);
1983
+ if (!start_nid || nodes < 0) {
18121984 codec_warn(codec, "HDMI: failed to get afg sub nodes\n");
18131985 return -EINVAL;
18141986 }
18151987
1816
- for (i = 0; i < nodes; i++, nid++) {
1817
- unsigned int caps;
1818
- unsigned int type;
1988
+ q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list);
1989
+
1990
+ if (q && q->value)
1991
+ spec->force_connect = true;
1992
+
1993
+ /*
1994
+ * hdmi_add_pin() assumes total amount of converters to
1995
+ * be known, so first discover all converters
1996
+ */
1997
+ for (i = 0; i < nodes; i++) {
1998
+ hda_nid_t nid = start_nid + i;
18191999
18202000 caps = get_wcaps(codec, nid);
1821
- type = get_wcaps_type(caps);
18222001
18232002 if (!(caps & AC_WCAP_DIGITAL))
18242003 continue;
18252004
1826
- switch (type) {
1827
- case AC_WID_AUD_OUT:
2005
+ if (get_wcaps_type(caps) == AC_WID_AUD_OUT)
18282006 hdmi_add_cvt(codec, nid);
1829
- break;
1830
- case AC_WID_PIN:
2007
+ }
2008
+
2009
+ /* discover audio pins */
2010
+ for (i = 0; i < nodes; i++) {
2011
+ hda_nid_t nid = start_nid + i;
2012
+
2013
+ caps = get_wcaps(codec, nid);
2014
+
2015
+ if (!(caps & AC_WCAP_DIGITAL))
2016
+ continue;
2017
+
2018
+ if (get_wcaps_type(caps) == AC_WID_PIN)
18312019 hdmi_add_pin(codec, nid);
1832
- break;
1833
- }
18342020 }
18352021
18362022 return 0;
....@@ -1871,10 +2057,9 @@
18712057 struct hdmi_spec *spec = codec->spec;
18722058 int pin_idx;
18732059 struct hdmi_spec_per_pin *per_pin;
1874
- hda_nid_t pin_nid;
18752060 struct snd_pcm_runtime *runtime = substream->runtime;
18762061 bool non_pcm;
1877
- int pinctl;
2062
+ int pinctl, stripe;
18782063 int err = 0;
18792064
18802065 mutex_lock(&spec->pcm_lock);
....@@ -1895,7 +2080,6 @@
18952080 goto unlock;
18962081 }
18972082 per_pin = get_pin(spec, pin_idx);
1898
- pin_nid = per_pin->pin_nid;
18992083
19002084 /* Verify pin:cvt selections to avoid silent audio after S3.
19012085 * After S3, the audio driver restores pin:cvt selections
....@@ -1910,27 +2094,37 @@
19102094 /* Call sync_audio_rate to set the N/CTS/M manually if necessary */
19112095 /* Todo: add DP1.2 MST audio support later */
19122096 if (codec_has_acomp(codec))
1913
- snd_hdac_sync_audio_rate(&codec->core, pin_nid, per_pin->dev_id,
1914
- runtime->rate);
2097
+ snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid,
2098
+ per_pin->dev_id, runtime->rate);
19152099
19162100 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
19172101 mutex_lock(&per_pin->lock);
19182102 per_pin->channels = substream->runtime->channels;
19192103 per_pin->setup = true;
19202104
2105
+ if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) {
2106
+ stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core,
2107
+ substream);
2108
+ snd_hda_codec_write(codec, cvt_nid, 0,
2109
+ AC_VERB_SET_STRIPE_CONTROL,
2110
+ stripe);
2111
+ }
2112
+
19212113 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm);
19222114 mutex_unlock(&per_pin->lock);
19232115 if (spec->dyn_pin_out) {
1924
- pinctl = snd_hda_codec_read(codec, pin_nid, 0,
2116
+ snd_hda_set_dev_select(codec, per_pin->pin_nid,
2117
+ per_pin->dev_id);
2118
+ pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
19252119 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1926
- snd_hda_codec_write(codec, pin_nid, 0,
2120
+ snd_hda_codec_write(codec, per_pin->pin_nid, 0,
19272121 AC_VERB_SET_PIN_WIDGET_CONTROL,
19282122 pinctl | PIN_OUT);
19292123 }
19302124
19312125 /* snd_hda_set_dev_select() has been called before */
1932
- err = spec->ops.setup_stream(codec, cvt_nid, pin_nid,
1933
- stream_tag, format);
2126
+ err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid,
2127
+ per_pin->dev_id, stream_tag, format);
19342128 unlock:
19352129 mutex_unlock(&spec->pcm_lock);
19362130 return err;
....@@ -1968,9 +2162,10 @@
19682162 goto unlock;
19692163 }
19702164 per_cvt = get_cvt(spec, cvt_idx);
1971
- snd_BUG_ON(!per_cvt->assigned);
19722165 per_cvt->assigned = 0;
19732166 hinfo->nid = 0;
2167
+
2168
+ azx_stream(get_azx_dev(substream))->stripe = 0;
19742169
19752170 snd_hda_spdif_ctls_unassign(codec, pcm_idx);
19762171 clear_bit(pcm_idx, &spec->pcm_in_use);
....@@ -1985,6 +2180,8 @@
19852180 per_pin = get_pin(spec, pin_idx);
19862181
19872182 if (spec->dyn_pin_out) {
2183
+ snd_hda_set_dev_select(codec, per_pin->pin_nid,
2184
+ per_pin->dev_id);
19882185 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0,
19892186 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
19902187 snd_hda_codec_write(codec, per_pin->pin_nid, 0,
....@@ -2016,7 +2213,7 @@
20162213
20172214 static int hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx)
20182215 {
2019
- struct hda_codec *codec = container_of(hdac, struct hda_codec, core);
2216
+ struct hda_codec *codec = hdac_to_hda_codec(hdac);
20202217 struct hdmi_spec *spec = codec->spec;
20212218 struct hdmi_spec_per_pin *per_pin = pcm_idx_to_pin(spec, pcm_idx);
20222219
....@@ -2029,7 +2226,7 @@
20292226 static void hdmi_get_chmap(struct hdac_device *hdac, int pcm_idx,
20302227 unsigned char *chmap)
20312228 {
2032
- struct hda_codec *codec = container_of(hdac, struct hda_codec, core);
2229
+ struct hda_codec *codec = hdac_to_hda_codec(hdac);
20332230 struct hdmi_spec *spec = codec->spec;
20342231 struct hdmi_spec_per_pin *per_pin = pcm_idx_to_pin(spec, pcm_idx);
20352232
....@@ -2043,7 +2240,7 @@
20432240 static void hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
20442241 unsigned char *chmap, int prepared)
20452242 {
2046
- struct hda_codec *codec = container_of(hdac, struct hda_codec, core);
2243
+ struct hda_codec *codec = hdac_to_hda_codec(hdac);
20472244 struct hdmi_spec *spec = codec->spec;
20482245 struct hdmi_spec_per_pin *per_pin = pcm_idx_to_pin(spec, pcm_idx);
20492246
....@@ -2059,7 +2256,7 @@
20592256
20602257 static bool is_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)
20612258 {
2062
- struct hda_codec *codec = container_of(hdac, struct hda_codec, core);
2259
+ struct hda_codec *codec = hdac_to_hda_codec(hdac);
20632260 struct hdmi_spec *spec = codec->spec;
20642261 struct hdmi_spec_per_pin *per_pin = pcm_idx_to_pin(spec, pcm_idx);
20652262
....@@ -2069,15 +2266,26 @@
20692266 static int generic_hdmi_build_pcms(struct hda_codec *codec)
20702267 {
20712268 struct hdmi_spec *spec = codec->spec;
2072
- int idx;
2269
+ int idx, pcm_num;
20732270
20742271 /*
20752272 * for non-mst mode, pcm number is the same as before
2076
- * for DP MST mode, pcm number is (nid number + dev_num - 1)
2077
- * dev_num is the device entry number in a pin
2078
- *
2273
+ * for DP MST mode without extra PCM, pcm number is same
2274
+ * for DP MST mode with extra PCMs, pcm number is
2275
+ * (nid number + dev_num - 1)
2276
+ * dev_num is the device entry number in a pin
20792277 */
2080
- for (idx = 0; idx < spec->num_nids + spec->dev_num - 1; idx++) {
2278
+
2279
+ if (spec->dyn_pcm_no_legacy && codec->mst_no_extra_pcms)
2280
+ pcm_num = spec->num_cvts;
2281
+ else if (codec->mst_no_extra_pcms)
2282
+ pcm_num = spec->num_nids;
2283
+ else
2284
+ pcm_num = spec->num_nids + spec->dev_num - 1;
2285
+
2286
+ codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num);
2287
+
2288
+ for (idx = 0; idx < pcm_num; idx++) {
20812289 struct hda_pcm *info;
20822290 struct hda_pcm_stream *pstr;
20832291
....@@ -2109,15 +2317,23 @@
21092317 pcm->jack = NULL;
21102318 }
21112319
2112
-static int add_hdmi_jack_kctl(struct hda_codec *codec,
2113
- struct hdmi_spec *spec,
2114
- int pcm_idx,
2115
- const char *name)
2320
+static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx)
21162321 {
2322
+ char hdmi_str[32] = "HDMI/DP";
2323
+ struct hdmi_spec *spec = codec->spec;
2324
+ struct hdmi_spec_per_pin *per_pin = get_pin(spec, pcm_idx);
21172325 struct snd_jack *jack;
2326
+ int pcmdev = get_pcm_rec(spec, pcm_idx)->device;
21182327 int err;
21192328
2120
- err = snd_jack_new(codec->card, name, SND_JACK_AVOUT, &jack,
2329
+ if (pcmdev > 0)
2330
+ sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
2331
+ if (!spec->dyn_pcm_assign &&
2332
+ !is_jack_detectable(codec, per_pin->pin_nid))
2333
+ strncat(hdmi_str, " Phantom",
2334
+ sizeof(hdmi_str) - strlen(hdmi_str) - 1);
2335
+
2336
+ err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack,
21212337 true, false);
21222338 if (err < 0)
21232339 return err;
....@@ -2125,46 +2341,6 @@
21252341 spec->pcm_rec[pcm_idx].jack = jack;
21262342 jack->private_data = &spec->pcm_rec[pcm_idx];
21272343 jack->private_free = free_hdmi_jack_priv;
2128
- return 0;
2129
-}
2130
-
2131
-static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx)
2132
-{
2133
- char hdmi_str[32] = "HDMI/DP";
2134
- struct hdmi_spec *spec = codec->spec;
2135
- struct hdmi_spec_per_pin *per_pin;
2136
- struct hda_jack_tbl *jack;
2137
- int pcmdev = get_pcm_rec(spec, pcm_idx)->device;
2138
- bool phantom_jack;
2139
- int ret;
2140
-
2141
- if (pcmdev > 0)
2142
- sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
2143
-
2144
- if (spec->dyn_pcm_assign)
2145
- return add_hdmi_jack_kctl(codec, spec, pcm_idx, hdmi_str);
2146
-
2147
- /* for !dyn_pcm_assign, we still use hda_jack for compatibility */
2148
- /* if !dyn_pcm_assign, it must be non-MST mode.
2149
- * This means pcms and pins are statically mapped.
2150
- * And pcm_idx is pin_idx.
2151
- */
2152
- per_pin = get_pin(spec, pcm_idx);
2153
- phantom_jack = !is_jack_detectable(codec, per_pin->pin_nid);
2154
- if (phantom_jack)
2155
- strncat(hdmi_str, " Phantom",
2156
- sizeof(hdmi_str) - strlen(hdmi_str) - 1);
2157
- ret = snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str,
2158
- phantom_jack);
2159
- if (ret < 0)
2160
- return ret;
2161
- jack = snd_hda_jack_tbl_get(codec, per_pin->pin_nid);
2162
- if (jack == NULL)
2163
- return 0;
2164
- /* assign jack->jack to pcm_rec[].jack to
2165
- * align with dyn_pcm_assign mode
2166
- */
2167
- spec->pcm_rec[pcm_idx].jack = jack->jack;
21682344 return 0;
21692345 }
21702346
....@@ -2257,6 +2433,7 @@
22572433 struct hdmi_spec *spec = codec->spec;
22582434 int pin_idx;
22592435
2436
+ mutex_lock(&spec->bind_lock);
22602437 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
22612438 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
22622439 hda_nid_t pin_nid = per_pin->pin_nid;
....@@ -2264,11 +2441,12 @@
22642441
22652442 snd_hda_set_dev_select(codec, pin_nid, dev_id);
22662443 hdmi_init_pin(codec, pin_nid);
2267
- if (!codec_has_acomp(codec))
2268
- snd_hda_jack_detect_enable_callback(codec, pin_nid,
2269
- codec->jackpoll_interval > 0 ?
2270
- jack_callback : NULL);
2444
+ if (codec_has_acomp(codec))
2445
+ continue;
2446
+ snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id,
2447
+ jack_callback);
22712448 }
2449
+ mutex_unlock(&spec->bind_lock);
22722450 return 0;
22732451 }
22742452
....@@ -2301,10 +2479,12 @@
23012479 struct hdmi_spec *spec = codec->spec;
23022480 int pin_idx, pcm_idx;
23032481
2304
- if (codec_has_acomp(codec)) {
2482
+ if (spec->acomp_registered) {
2483
+ snd_hdac_acomp_exit(&codec->bus->core);
2484
+ } else if (codec_has_acomp(codec)) {
23052485 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL);
2306
- codec->relaxed_resume = 0;
23072486 }
2487
+ codec->relaxed_resume = 0;
23082488
23092489 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
23102490 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
....@@ -2344,7 +2524,7 @@
23442524 int pin_idx;
23452525
23462526 codec->patch_ops.init(codec);
2347
- regcache_sync(codec->core.regmap);
2527
+ snd_hda_regmap_sync(codec);
23482528
23492529 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
23502530 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
....@@ -2367,7 +2547,7 @@
23672547 };
23682548
23692549 static const struct hdmi_ops generic_standard_hdmi_ops = {
2370
- .pin_get_eld = snd_hdmi_get_eld,
2550
+ .pin_get_eld = hdmi_pin_get_eld,
23712551 .pin_setup_infoframe = hdmi_pin_setup_infoframe,
23722552 .pin_hbr_setup = hdmi_pin_hbr_setup,
23732553 .setup_stream = hdmi_setup_stream,
....@@ -2382,15 +2562,17 @@
23822562 if (!spec)
23832563 return -ENOMEM;
23842564
2565
+ spec->codec = codec;
23852566 spec->ops = generic_standard_hdmi_ops;
23862567 spec->dev_num = 1; /* initialize to 1 */
23872568 mutex_init(&spec->pcm_lock);
2569
+ mutex_init(&spec->bind_lock);
23882570 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap);
23892571
23902572 spec->chmap.ops.get_chmap = hdmi_get_chmap;
23912573 spec->chmap.ops.set_chmap = hdmi_set_chmap;
23922574 spec->chmap.ops.is_pcm_attached = is_hdmi_pcm_attached;
2393
- spec->chmap.ops.get_spk_alloc = hdmi_get_spk_alloc,
2575
+ spec->chmap.ops.get_spk_alloc = hdmi_get_spk_alloc;
23942576
23952577 codec->spec = spec;
23962578 hdmi_array_init(spec, 4);
....@@ -2420,32 +2602,140 @@
24202602 }
24212603
24222604 /*
2605
+ * generic audio component binding
2606
+ */
2607
+
2608
+/* turn on / off the unsol event jack detection dynamically */
2609
+static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid,
2610
+ int dev_id, bool use_acomp)
2611
+{
2612
+ struct hda_jack_tbl *tbl;
2613
+
2614
+ tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id);
2615
+ if (tbl) {
2616
+ /* clear unsol even if component notifier is used, or re-enable
2617
+ * if notifier is cleared
2618
+ */
2619
+ unsigned int val = use_acomp ? 0 : (AC_USRSP_EN | tbl->tag);
2620
+ snd_hda_codec_write_cache(codec, nid, 0,
2621
+ AC_VERB_SET_UNSOLICITED_ENABLE, val);
2622
+ }
2623
+}
2624
+
2625
+/* set up / clear component notifier dynamically */
2626
+static void generic_acomp_notifier_set(struct drm_audio_component *acomp,
2627
+ bool use_acomp)
2628
+{
2629
+ struct hdmi_spec *spec;
2630
+ int i;
2631
+
2632
+ spec = container_of(acomp->audio_ops, struct hdmi_spec, drm_audio_ops);
2633
+ mutex_lock(&spec->bind_lock);
2634
+ spec->use_acomp_notifier = use_acomp;
2635
+ spec->codec->relaxed_resume = use_acomp;
2636
+ spec->codec->bus->keep_power = 0;
2637
+ /* reprogram each jack detection logic depending on the notifier */
2638
+ for (i = 0; i < spec->num_pins; i++)
2639
+ reprogram_jack_detect(spec->codec,
2640
+ get_pin(spec, i)->pin_nid,
2641
+ get_pin(spec, i)->dev_id,
2642
+ use_acomp);
2643
+ mutex_unlock(&spec->bind_lock);
2644
+}
2645
+
2646
+/* enable / disable the notifier via master bind / unbind */
2647
+static int generic_acomp_master_bind(struct device *dev,
2648
+ struct drm_audio_component *acomp)
2649
+{
2650
+ generic_acomp_notifier_set(acomp, true);
2651
+ return 0;
2652
+}
2653
+
2654
+static void generic_acomp_master_unbind(struct device *dev,
2655
+ struct drm_audio_component *acomp)
2656
+{
2657
+ generic_acomp_notifier_set(acomp, false);
2658
+}
2659
+
2660
+/* check whether both HD-audio and DRM PCI devices belong to the same bus */
2661
+static int match_bound_vga(struct device *dev, int subtype, void *data)
2662
+{
2663
+ struct hdac_bus *bus = data;
2664
+ struct pci_dev *pci, *master;
2665
+
2666
+ if (!dev_is_pci(dev) || !dev_is_pci(bus->dev))
2667
+ return 0;
2668
+ master = to_pci_dev(bus->dev);
2669
+ pci = to_pci_dev(dev);
2670
+ return master->bus == pci->bus;
2671
+}
2672
+
2673
+/* audio component notifier for AMD/Nvidia HDMI codecs */
2674
+static void generic_acomp_pin_eld_notify(void *audio_ptr, int port, int dev_id)
2675
+{
2676
+ struct hda_codec *codec = audio_ptr;
2677
+ struct hdmi_spec *spec = codec->spec;
2678
+ hda_nid_t pin_nid = spec->port2pin(codec, port);
2679
+
2680
+ if (!pin_nid)
2681
+ return;
2682
+ if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN)
2683
+ return;
2684
+ /* skip notification during system suspend (but not in runtime PM);
2685
+ * the state will be updated at resume
2686
+ */
2687
+ if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND)
2688
+ return;
2689
+
2690
+ check_presence_and_report(codec, pin_nid, dev_id);
2691
+}
2692
+
2693
+/* set up the private drm_audio_ops from the template */
2694
+static void setup_drm_audio_ops(struct hda_codec *codec,
2695
+ const struct drm_audio_component_audio_ops *ops)
2696
+{
2697
+ struct hdmi_spec *spec = codec->spec;
2698
+
2699
+ spec->drm_audio_ops.audio_ptr = codec;
2700
+ /* intel_audio_codec_enable() or intel_audio_codec_disable()
2701
+ * will call pin_eld_notify with using audio_ptr pointer
2702
+ * We need make sure audio_ptr is really setup
2703
+ */
2704
+ wmb();
2705
+ spec->drm_audio_ops.pin2port = ops->pin2port;
2706
+ spec->drm_audio_ops.pin_eld_notify = ops->pin_eld_notify;
2707
+ spec->drm_audio_ops.master_bind = ops->master_bind;
2708
+ spec->drm_audio_ops.master_unbind = ops->master_unbind;
2709
+}
2710
+
2711
+/* initialize the generic HDMI audio component */
2712
+static void generic_acomp_init(struct hda_codec *codec,
2713
+ const struct drm_audio_component_audio_ops *ops,
2714
+ int (*port2pin)(struct hda_codec *, int))
2715
+{
2716
+ struct hdmi_spec *spec = codec->spec;
2717
+
2718
+ if (!enable_acomp) {
2719
+ codec_info(codec, "audio component disabled by module option\n");
2720
+ return;
2721
+ }
2722
+
2723
+ spec->port2pin = port2pin;
2724
+ setup_drm_audio_ops(codec, ops);
2725
+ if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops,
2726
+ match_bound_vga, 0)) {
2727
+ spec->acomp_registered = true;
2728
+ }
2729
+}
2730
+
2731
+/*
24232732 * Intel codec parsers and helpers
24242733 */
24252734
2426
-static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
2427
- hda_nid_t nid)
2428
-{
2429
- struct hdmi_spec *spec = codec->spec;
2430
- hda_nid_t conns[4];
2431
- int nconns;
2432
-
2433
- nconns = snd_hda_get_connections(codec, nid, conns, ARRAY_SIZE(conns));
2434
- if (nconns == spec->num_cvts &&
2435
- !memcmp(conns, spec->cvt_nids, spec->num_cvts * sizeof(hda_nid_t)))
2436
- return;
2437
-
2438
- /* override pins connection list */
2439
- codec_dbg(codec, "hdmi: haswell: override pin connection 0x%x\n", nid);
2440
- snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids);
2441
-}
2442
-
2443
-#define INTEL_VENDOR_NID 0x08
2444
-#define INTEL_GLK_VENDOR_NID 0x0B
2445
-#define INTEL_GET_VENDOR_VERB 0xf81
2446
-#define INTEL_SET_VENDOR_VERB 0x781
2447
-#define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */
2448
-#define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */
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 */
24492739
24502740 static void intel_haswell_enable_all_pins(struct hda_codec *codec,
24512741 bool update_tree)
....@@ -2525,11 +2815,44 @@
25252815
25262816 static int intel_pin2port(void *audio_ptr, int pin_nid)
25272817 {
2528
- int base_nid = intel_base_nid(audio_ptr);
2818
+ struct hda_codec *codec = audio_ptr;
2819
+ struct hdmi_spec *spec = codec->spec;
2820
+ int base_nid, i;
25292821
2530
- if (WARN_ON(pin_nid < base_nid || pin_nid >= base_nid + 3))
2531
- return -1;
2532
- return pin_nid - base_nid + 1; /* intel port is 1-based */
2822
+ if (!spec->port_num) {
2823
+ base_nid = intel_base_nid(codec);
2824
+ if (WARN_ON(pin_nid < base_nid || pin_nid >= base_nid + 3))
2825
+ return -1;
2826
+ return pin_nid - base_nid + 1;
2827
+ }
2828
+
2829
+ /*
2830
+ * looking for the pin number in the mapping table and return
2831
+ * the index which indicate the port number
2832
+ */
2833
+ for (i = 0; i < spec->port_num; i++) {
2834
+ if (pin_nid == spec->port_map[i])
2835
+ return i;
2836
+ }
2837
+
2838
+ codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid);
2839
+ return -1;
2840
+}
2841
+
2842
+static int intel_port2pin(struct hda_codec *codec, int port)
2843
+{
2844
+ struct hdmi_spec *spec = codec->spec;
2845
+
2846
+ if (!spec->port_num) {
2847
+ /* we assume only from port-B to port-D */
2848
+ if (port < 1 || port > 3)
2849
+ return 0;
2850
+ return port + intel_base_nid(codec) - 1;
2851
+ }
2852
+
2853
+ if (port < 0 || port >= spec->port_num)
2854
+ return 0;
2855
+ return spec->port_map[port];
25332856 }
25342857
25352858 static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
....@@ -2538,24 +2861,23 @@
25382861 int pin_nid;
25392862 int dev_id = pipe;
25402863
2541
- /* we assume only from port-B to port-D */
2542
- if (port < 1 || port > 3)
2864
+ pin_nid = intel_port2pin(codec, port);
2865
+ if (!pin_nid)
25432866 return;
2544
-
2545
- pin_nid = port + intel_base_nid(codec) - 1; /* intel port is 1-based */
2546
-
25472867 /* skip notification during system suspend (but not in runtime PM);
25482868 * the state will be updated at resume
25492869 */
2550
- if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0)
2551
- return;
2552
- /* ditto during suspend/resume process itself */
2553
- if (snd_hdac_is_in_pm(&codec->core))
2870
+ if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND)
25542871 return;
25552872
25562873 snd_hdac_i915_set_bclk(&codec->bus->core);
25572874 check_presence_and_report(codec, pin_nid, dev_id);
25582875 }
2876
+
2877
+static const struct drm_audio_component_audio_ops intel_audio_ops = {
2878
+ .pin2port = intel_pin2port,
2879
+ .pin_eld_notify = intel_pin_eld_notify,
2880
+};
25592881
25602882 /* register i915 component pin_eld_notify callback */
25612883 static void register_i915_notifier(struct hda_codec *codec)
....@@ -2563,14 +2885,8 @@
25632885 struct hdmi_spec *spec = codec->spec;
25642886
25652887 spec->use_acomp_notifier = true;
2566
- spec->drm_audio_ops.audio_ptr = codec;
2567
- /* intel_audio_codec_enable() or intel_audio_codec_disable()
2568
- * will call pin_eld_notify with using audio_ptr pointer
2569
- * We need make sure audio_ptr is really setup
2570
- */
2571
- wmb();
2572
- spec->drm_audio_ops.pin2port = intel_pin2port;
2573
- spec->drm_audio_ops.pin_eld_notify = intel_pin_eld_notify;
2888
+ spec->port2pin = intel_port2pin;
2889
+ setup_drm_audio_ops(codec, &intel_audio_ops);
25742890 snd_hdac_acomp_register_notifier(&codec->bus->core,
25752891 &spec->drm_audio_ops);
25762892 /* no need for forcible resume for jack check thanks to notifier */
....@@ -2579,10 +2895,12 @@
25792895
25802896 /* setup_stream ops override for HSW+ */
25812897 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
2582
- hda_nid_t pin_nid, u32 stream_tag, int format)
2898
+ hda_nid_t pin_nid, int dev_id, u32 stream_tag,
2899
+ int format)
25832900 {
25842901 haswell_verify_D0(codec, cvt_nid, pin_nid);
2585
- return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
2902
+ return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id,
2903
+ stream_tag, format);
25862904 }
25872905
25882906 /* pin_cvt_fixup ops override for HSW+ and VLV+ */
....@@ -2643,7 +2961,8 @@
26432961 }
26442962
26452963 /* Intel Haswell and onwards; audio component with eld notifier */
2646
-static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid)
2964
+static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid,
2965
+ const int *port_map, int port_num)
26472966 {
26482967 struct hdmi_spec *spec;
26492968 int err;
....@@ -2655,15 +2974,14 @@
26552974 codec->dp_mst = true;
26562975 spec->dyn_pcm_assign = true;
26572976 spec->vendor_nid = vendor_nid;
2977
+ spec->port_map = port_map;
2978
+ spec->port_num = port_num;
2979
+ spec->intel_hsw_fixup = true;
26582980
26592981 intel_haswell_enable_all_pins(codec, true);
26602982 intel_haswell_fixup_enable_dp12(codec);
26612983
2662
- /* For Haswell/Broadwell, the controller is also in the power well and
2663
- * can cover the codec power request, and so need not set this flag.
2664
- */
2665
- if (!is_haswell(codec) && !is_broadwell(codec))
2666
- codec->core.link_power_control = 1;
2984
+ codec->display_power_control = 1;
26672985
26682986 codec->patch_ops.set_power_state = haswell_set_power_state;
26692987 codec->depop_delay = 0;
....@@ -2672,17 +2990,54 @@
26722990 spec->ops.setup_stream = i915_hsw_setup_stream;
26732991 spec->ops.pin_cvt_fixup = i915_pin_cvt_fixup;
26742992
2993
+ /*
2994
+ * Enable silent stream feature, if it is enabled via
2995
+ * module param or Kconfig option
2996
+ */
2997
+ if (enable_silent_stream)
2998
+ spec->send_silent_stream = true;
2999
+
26753000 return parse_intel_hdmi(codec);
26763001 }
26773002
26783003 static int patch_i915_hsw_hdmi(struct hda_codec *codec)
26793004 {
2680
- return intel_hsw_common_init(codec, INTEL_VENDOR_NID);
3005
+ return intel_hsw_common_init(codec, 0x08, NULL, 0);
26813006 }
26823007
26833008 static int patch_i915_glk_hdmi(struct hda_codec *codec)
26843009 {
2685
- return intel_hsw_common_init(codec, INTEL_GLK_VENDOR_NID);
3010
+ return intel_hsw_common_init(codec, 0x0b, NULL, 0);
3011
+}
3012
+
3013
+static int patch_i915_icl_hdmi(struct hda_codec *codec)
3014
+{
3015
+ /*
3016
+ * pin to port mapping table where the value indicate the pin number and
3017
+ * the index indicate the port number.
3018
+ */
3019
+ static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb};
3020
+
3021
+ return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
3022
+}
3023
+
3024
+static int patch_i915_tgl_hdmi(struct hda_codec *codec)
3025
+{
3026
+ /*
3027
+ * pin to port mapping table where the value indicate the pin number and
3028
+ * the index indicate the port number.
3029
+ */
3030
+ static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
3031
+ int ret;
3032
+
3033
+ ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
3034
+ if (!ret) {
3035
+ struct hdmi_spec *spec = codec->spec;
3036
+
3037
+ spec->dyn_pcm_no_legacy = true;
3038
+ }
3039
+
3040
+ return ret;
26863041 }
26873042
26883043 /* Intel Baytrail and Braswell; with eld notifier */
....@@ -2699,7 +3054,7 @@
26993054 /* For Valleyview/Cherryview, only the display codec is in the display
27003055 * power well and can use link_power ops to request/release the power.
27013056 */
2702
- codec->core.link_power_control = 1;
3057
+ codec->display_power_control = 1;
27033058
27043059 codec->depop_delay = 0;
27053060 codec->auto_runtime_pm = 1;
....@@ -2790,7 +3145,7 @@
27903145 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)
27913146 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE,
27923147 AMP_OUT_UNMUTE);
2793
- snd_hda_jack_detect_enable(codec, pin);
3148
+ snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id);
27943149 return 0;
27953150 }
27963151
....@@ -2969,6 +3324,7 @@
29693324 if (!spec)
29703325 return -ENOMEM;
29713326
3327
+ spec->codec = codec;
29723328 codec->spec = spec;
29733329 hdmi_array_init(spec, 1);
29743330
....@@ -3180,6 +3536,7 @@
31803536 spec->pcm_playback.rates = SUPPORTED_RATES;
31813537 spec->pcm_playback.maxbps = SUPPORTED_MAXBPS;
31823538 spec->pcm_playback.formats = SUPPORTED_FORMATS;
3539
+ spec->nv_dp_workaround = true;
31833540 return 0;
31843541 }
31853542
....@@ -3273,7 +3630,62 @@
32733630 return 0;
32743631 }
32753632
3633
+/* map from pin NID to port; port is 0-based */
3634
+/* for Nvidia: assume widget NID starting from 4, with step 1 (4, 5, 6, ...) */
3635
+static int nvhdmi_pin2port(void *audio_ptr, int pin_nid)
3636
+{
3637
+ return pin_nid - 4;
3638
+}
3639
+
3640
+/* reverse-map from port to pin NID: see above */
3641
+static int nvhdmi_port2pin(struct hda_codec *codec, int port)
3642
+{
3643
+ return port + 4;
3644
+}
3645
+
3646
+static const struct drm_audio_component_audio_ops nvhdmi_audio_ops = {
3647
+ .pin2port = nvhdmi_pin2port,
3648
+ .pin_eld_notify = generic_acomp_pin_eld_notify,
3649
+ .master_bind = generic_acomp_master_bind,
3650
+ .master_unbind = generic_acomp_master_unbind,
3651
+};
3652
+
32763653 static int patch_nvhdmi(struct hda_codec *codec)
3654
+{
3655
+ struct hdmi_spec *spec;
3656
+ int err;
3657
+
3658
+ err = alloc_generic_hdmi(codec);
3659
+ if (err < 0)
3660
+ return err;
3661
+ codec->dp_mst = true;
3662
+
3663
+ spec = codec->spec;
3664
+ spec->dyn_pcm_assign = true;
3665
+
3666
+ err = hdmi_parse_codec(codec);
3667
+ if (err < 0) {
3668
+ generic_spec_free(codec);
3669
+ return err;
3670
+ }
3671
+
3672
+ generic_hdmi_init_per_pins(codec);
3673
+
3674
+ spec->dyn_pin_out = true;
3675
+
3676
+ spec->chmap.ops.chmap_cea_alloc_validate_get_type =
3677
+ nvhdmi_chmap_cea_alloc_validate_get_type;
3678
+ spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate;
3679
+ spec->nv_dp_workaround = true;
3680
+
3681
+ codec->link_down_at_suspend = 1;
3682
+
3683
+ generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin);
3684
+
3685
+ return 0;
3686
+}
3687
+
3688
+static int patch_nvhdmi_legacy(struct hda_codec *codec)
32773689 {
32783690 struct hdmi_spec *spec;
32793691 int err;
....@@ -3288,6 +3700,7 @@
32883700 spec->chmap.ops.chmap_cea_alloc_validate_get_type =
32893701 nvhdmi_chmap_cea_alloc_validate_get_type;
32903702 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate;
3703
+ spec->nv_dp_workaround = true;
32913704
32923705 codec->link_down_at_suspend = 1;
32933706
....@@ -3455,11 +3868,13 @@
34553868 if (err)
34563869 return err;
34573870
3871
+ codec->depop_delay = 10;
34583872 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms;
34593873 spec = codec->spec;
34603874 spec->chmap.ops.chmap_cea_alloc_validate_get_type =
34613875 nvhdmi_chmap_cea_alloc_validate_get_type;
34623876 spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate;
3877
+ spec->nv_dp_workaround = true;
34633878
34643879 return 0;
34653880 }
....@@ -3512,16 +3927,19 @@
35123927 #define ATI_HBR_ENABLE 0x10
35133928
35143929 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid,
3515
- unsigned char *buf, int *eld_size)
3930
+ int dev_id, unsigned char *buf, int *eld_size)
35163931 {
3932
+ WARN_ON(dev_id != 0);
35173933 /* call hda_eld.c ATI/AMD-specific function */
35183934 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size,
35193935 is_amdhdmi_rev3_or_later(codec));
35203936 }
35213937
3522
-static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, int ca,
3938
+static void atihdmi_pin_setup_infoframe(struct hda_codec *codec,
3939
+ hda_nid_t pin_nid, int dev_id, int ca,
35233940 int active_channels, int conn_type)
35243941 {
3942
+ WARN_ON(dev_id != 0);
35253943 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca);
35263944 }
35273945
....@@ -3593,7 +4011,7 @@
35934011 static int atihdmi_pin_set_slot_channel(struct hdac_device *hdac,
35944012 hda_nid_t pin_nid, int hdmi_slot, int stream_channel)
35954013 {
3596
- struct hda_codec *codec = container_of(hdac, struct hda_codec, core);
4014
+ struct hda_codec *codec = hdac_to_hda_codec(hdac);
35974015 int verb;
35984016 int ati_channel_setup = 0;
35994017
....@@ -3629,7 +4047,7 @@
36294047 static int atihdmi_pin_get_slot_channel(struct hdac_device *hdac,
36304048 hda_nid_t pin_nid, int asp_slot)
36314049 {
3632
- struct hda_codec *codec = container_of(hdac, struct hda_codec, core);
4050
+ struct hda_codec *codec = hdac_to_hda_codec(hdac);
36334051 bool was_odd = false;
36344052 int ati_asp_slot = asp_slot;
36354053 int verb;
....@@ -3712,9 +4130,11 @@
37124130 }
37134131
37144132 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
3715
- bool hbr)
4133
+ int dev_id, bool hbr)
37164134 {
37174135 int hbr_ctl, hbr_ctl_new;
4136
+
4137
+ WARN_ON(dev_id != 0);
37184138
37194139 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0);
37204140 if (hbr_ctl >= 0 && (hbr_ctl & ATI_HBR_CAPABLE)) {
....@@ -3741,9 +4161,9 @@
37414161 }
37424162
37434163 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
3744
- hda_nid_t pin_nid, u32 stream_tag, int format)
4164
+ hda_nid_t pin_nid, int dev_id,
4165
+ u32 stream_tag, int format)
37454166 {
3746
-
37474167 if (is_amdhdmi_rev3_or_later(codec)) {
37484168 int ramp_rate = 180; /* default as per AMD spec */
37494169 /* disable ramp-up/down for non-pcm as per AMD spec */
....@@ -3753,7 +4173,8 @@
37534173 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate);
37544174 }
37554175
3756
- return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
4176
+ return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id,
4177
+ stream_tag, format);
37574178 }
37584179
37594180
....@@ -3779,9 +4200,30 @@
37794200 ATI_VERB_SET_MULTICHANNEL_MODE,
37804201 ATI_MULTICHANNEL_MODE_SINGLE);
37814202 }
4203
+ codec->auto_runtime_pm = 1;
37824204
37834205 return 0;
37844206 }
4207
+
4208
+/* map from pin NID to port; port is 0-based */
4209
+/* for AMD: assume widget NID starting from 3, with step 2 (3, 5, 7, ...) */
4210
+static int atihdmi_pin2port(void *audio_ptr, int pin_nid)
4211
+{
4212
+ return pin_nid / 2 - 1;
4213
+}
4214
+
4215
+/* reverse-map from port to pin NID: see above */
4216
+static int atihdmi_port2pin(struct hda_codec *codec, int port)
4217
+{
4218
+ return port * 2 + 3;
4219
+}
4220
+
4221
+static const struct drm_audio_component_audio_ops atihdmi_audio_ops = {
4222
+ .pin2port = atihdmi_pin2port,
4223
+ .pin_eld_notify = generic_acomp_pin_eld_notify,
4224
+ .master_bind = generic_acomp_master_bind,
4225
+ .master_unbind = generic_acomp_master_unbind,
4226
+};
37854227
37864228 static int patch_atihdmi(struct hda_codec *codec)
37874229 {
....@@ -3831,6 +4273,8 @@
38314273 */
38324274 codec->link_down_at_suspend = 1;
38334275
4276
+ generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin);
4277
+
38344278 return 0;
38354279 }
38364280
....@@ -3841,6 +4285,22 @@
38414285 static int patch_via_hdmi(struct hda_codec *codec)
38424286 {
38434287 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID);
4288
+}
4289
+
4290
+static int patch_gf_hdmi(struct hda_codec *codec)
4291
+{
4292
+ int err;
4293
+
4294
+ err = patch_generic_hdmi(codec);
4295
+ if (err)
4296
+ return err;
4297
+
4298
+ /*
4299
+ * Glenfly GPUs have two codecs, stream switches from one codec to
4300
+ * another, need to do actual clean-ups in codec_cleanup_stream
4301
+ */
4302
+ codec->no_sticky_stream = 1;
4303
+ return 0;
38444304 }
38454305
38464306 /*
....@@ -3861,29 +4321,33 @@
38614321 HDA_CODEC_ENTRY(0x10de0005, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
38624322 HDA_CODEC_ENTRY(0x10de0006, "MCP77/78 HDMI", patch_nvhdmi_8ch_7x),
38634323 HDA_CODEC_ENTRY(0x10de0007, "MCP79/7A HDMI", patch_nvhdmi_8ch_7x),
3864
-HDA_CODEC_ENTRY(0x10de0008, "GPU 08 HDMI/DP", patch_nvhdmi),
3865
-HDA_CODEC_ENTRY(0x10de0009, "GPU 09 HDMI/DP", patch_nvhdmi),
3866
-HDA_CODEC_ENTRY(0x10de000a, "GPU 0a HDMI/DP", patch_nvhdmi),
3867
-HDA_CODEC_ENTRY(0x10de000b, "GPU 0b HDMI/DP", patch_nvhdmi),
3868
-HDA_CODEC_ENTRY(0x10de000c, "MCP89 HDMI", patch_nvhdmi),
3869
-HDA_CODEC_ENTRY(0x10de000d, "GPU 0d HDMI/DP", patch_nvhdmi),
3870
-HDA_CODEC_ENTRY(0x10de0010, "GPU 10 HDMI/DP", patch_nvhdmi),
3871
-HDA_CODEC_ENTRY(0x10de0011, "GPU 11 HDMI/DP", patch_nvhdmi),
3872
-HDA_CODEC_ENTRY(0x10de0012, "GPU 12 HDMI/DP", patch_nvhdmi),
3873
-HDA_CODEC_ENTRY(0x10de0013, "GPU 13 HDMI/DP", patch_nvhdmi),
3874
-HDA_CODEC_ENTRY(0x10de0014, "GPU 14 HDMI/DP", patch_nvhdmi),
3875
-HDA_CODEC_ENTRY(0x10de0015, "GPU 15 HDMI/DP", patch_nvhdmi),
3876
-HDA_CODEC_ENTRY(0x10de0016, "GPU 16 HDMI/DP", patch_nvhdmi),
4324
+HDA_CODEC_ENTRY(0x10de0008, "GPU 08 HDMI/DP", patch_nvhdmi_legacy),
4325
+HDA_CODEC_ENTRY(0x10de0009, "GPU 09 HDMI/DP", patch_nvhdmi_legacy),
4326
+HDA_CODEC_ENTRY(0x10de000a, "GPU 0a HDMI/DP", patch_nvhdmi_legacy),
4327
+HDA_CODEC_ENTRY(0x10de000b, "GPU 0b HDMI/DP", patch_nvhdmi_legacy),
4328
+HDA_CODEC_ENTRY(0x10de000c, "MCP89 HDMI", patch_nvhdmi_legacy),
4329
+HDA_CODEC_ENTRY(0x10de000d, "GPU 0d HDMI/DP", patch_nvhdmi_legacy),
4330
+HDA_CODEC_ENTRY(0x10de0010, "GPU 10 HDMI/DP", patch_nvhdmi_legacy),
4331
+HDA_CODEC_ENTRY(0x10de0011, "GPU 11 HDMI/DP", patch_nvhdmi_legacy),
4332
+HDA_CODEC_ENTRY(0x10de0012, "GPU 12 HDMI/DP", patch_nvhdmi_legacy),
4333
+HDA_CODEC_ENTRY(0x10de0013, "GPU 13 HDMI/DP", patch_nvhdmi_legacy),
4334
+HDA_CODEC_ENTRY(0x10de0014, "GPU 14 HDMI/DP", patch_nvhdmi_legacy),
4335
+HDA_CODEC_ENTRY(0x10de0015, "GPU 15 HDMI/DP", patch_nvhdmi_legacy),
4336
+HDA_CODEC_ENTRY(0x10de0016, "GPU 16 HDMI/DP", patch_nvhdmi_legacy),
38774337 /* 17 is known to be absent */
3878
-HDA_CODEC_ENTRY(0x10de0018, "GPU 18 HDMI/DP", patch_nvhdmi),
3879
-HDA_CODEC_ENTRY(0x10de0019, "GPU 19 HDMI/DP", patch_nvhdmi),
3880
-HDA_CODEC_ENTRY(0x10de001a, "GPU 1a HDMI/DP", patch_nvhdmi),
3881
-HDA_CODEC_ENTRY(0x10de001b, "GPU 1b HDMI/DP", patch_nvhdmi),
3882
-HDA_CODEC_ENTRY(0x10de001c, "GPU 1c HDMI/DP", patch_nvhdmi),
4338
+HDA_CODEC_ENTRY(0x10de0018, "GPU 18 HDMI/DP", patch_nvhdmi_legacy),
4339
+HDA_CODEC_ENTRY(0x10de0019, "GPU 19 HDMI/DP", patch_nvhdmi_legacy),
4340
+HDA_CODEC_ENTRY(0x10de001a, "GPU 1a HDMI/DP", patch_nvhdmi_legacy),
4341
+HDA_CODEC_ENTRY(0x10de001b, "GPU 1b HDMI/DP", patch_nvhdmi_legacy),
4342
+HDA_CODEC_ENTRY(0x10de001c, "GPU 1c HDMI/DP", patch_nvhdmi_legacy),
38834343 HDA_CODEC_ENTRY(0x10de0020, "Tegra30 HDMI", patch_tegra_hdmi),
38844344 HDA_CODEC_ENTRY(0x10de0022, "Tegra114 HDMI", patch_tegra_hdmi),
38854345 HDA_CODEC_ENTRY(0x10de0028, "Tegra124 HDMI", patch_tegra_hdmi),
38864346 HDA_CODEC_ENTRY(0x10de0029, "Tegra210 HDMI/DP", patch_tegra_hdmi),
4347
+HDA_CODEC_ENTRY(0x10de002d, "Tegra186 HDMI/DP0", patch_tegra_hdmi),
4348
+HDA_CODEC_ENTRY(0x10de002e, "Tegra186 HDMI/DP1", patch_tegra_hdmi),
4349
+HDA_CODEC_ENTRY(0x10de002f, "Tegra194 HDMI/DP2", patch_tegra_hdmi),
4350
+HDA_CODEC_ENTRY(0x10de0030, "Tegra194 HDMI/DP3", patch_tegra_hdmi),
38874351 HDA_CODEC_ENTRY(0x10de0040, "GPU 40 HDMI/DP", patch_nvhdmi),
38884352 HDA_CODEC_ENTRY(0x10de0041, "GPU 41 HDMI/DP", patch_nvhdmi),
38894353 HDA_CODEC_ENTRY(0x10de0042, "GPU 42 HDMI/DP", patch_nvhdmi),
....@@ -3926,13 +4390,25 @@
39264390 HDA_CODEC_ENTRY(0x10de009e, "GPU 9e HDMI/DP", patch_nvhdmi),
39274391 HDA_CODEC_ENTRY(0x10de009f, "GPU 9f HDMI/DP", patch_nvhdmi),
39284392 HDA_CODEC_ENTRY(0x10de00a0, "GPU a0 HDMI/DP", patch_nvhdmi),
4393
+HDA_CODEC_ENTRY(0x10de00a3, "GPU a3 HDMI/DP", patch_nvhdmi),
4394
+HDA_CODEC_ENTRY(0x10de00a4, "GPU a4 HDMI/DP", patch_nvhdmi),
4395
+HDA_CODEC_ENTRY(0x10de00a5, "GPU a5 HDMI/DP", patch_nvhdmi),
4396
+HDA_CODEC_ENTRY(0x10de00a6, "GPU a6 HDMI/DP", patch_nvhdmi),
4397
+HDA_CODEC_ENTRY(0x10de00a7, "GPU a7 HDMI/DP", patch_nvhdmi),
39294398 HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI", patch_nvhdmi_2ch),
39304399 HDA_CODEC_ENTRY(0x10de8067, "MCP67/68 HDMI", patch_nvhdmi_2ch),
4400
+HDA_CODEC_ENTRY(0x67663d82, "Arise 82 HDMI/DP", patch_gf_hdmi),
4401
+HDA_CODEC_ENTRY(0x67663d83, "Arise 83 HDMI/DP", patch_gf_hdmi),
4402
+HDA_CODEC_ENTRY(0x67663d84, "Arise 84 HDMI/DP", patch_gf_hdmi),
4403
+HDA_CODEC_ENTRY(0x67663d85, "Arise 85 HDMI/DP", patch_gf_hdmi),
4404
+HDA_CODEC_ENTRY(0x67663d86, "Arise 86 HDMI/DP", patch_gf_hdmi),
4405
+HDA_CODEC_ENTRY(0x67663d87, "Arise 87 HDMI/DP", patch_gf_hdmi),
39314406 HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP", patch_via_hdmi),
39324407 HDA_CODEC_ENTRY(0x11069f81, "VX900 HDMI/DP", patch_via_hdmi),
39334408 HDA_CODEC_ENTRY(0x11069f84, "VX11 HDMI/DP", patch_generic_hdmi),
39344409 HDA_CODEC_ENTRY(0x11069f85, "VX11 HDMI/DP", patch_generic_hdmi),
39354410 HDA_CODEC_ENTRY(0x80860054, "IbexPeak HDMI", patch_i915_cpt_hdmi),
4411
+HDA_CODEC_ENTRY(0x80862800, "Geminilake HDMI", patch_i915_glk_hdmi),
39364412 HDA_CODEC_ENTRY(0x80862801, "Bearlake HDMI", patch_generic_hdmi),
39374413 HDA_CODEC_ENTRY(0x80862802, "Cantiga HDMI", patch_generic_hdmi),
39384414 HDA_CODEC_ENTRY(0x80862803, "Eaglelake HDMI", patch_generic_hdmi),
....@@ -3946,7 +4422,15 @@
39464422 HDA_CODEC_ENTRY(0x8086280b, "Kabylake HDMI", patch_i915_hsw_hdmi),
39474423 HDA_CODEC_ENTRY(0x8086280c, "Cannonlake HDMI", patch_i915_glk_hdmi),
39484424 HDA_CODEC_ENTRY(0x8086280d, "Geminilake HDMI", patch_i915_glk_hdmi),
3949
-HDA_CODEC_ENTRY(0x80862800, "Geminilake HDMI", patch_i915_glk_hdmi),
4425
+HDA_CODEC_ENTRY(0x8086280f, "Icelake HDMI", patch_i915_icl_hdmi),
4426
+HDA_CODEC_ENTRY(0x80862812, "Tigerlake HDMI", patch_i915_tgl_hdmi),
4427
+HDA_CODEC_ENTRY(0x80862814, "DG1 HDMI", patch_i915_tgl_hdmi),
4428
+HDA_CODEC_ENTRY(0x80862815, "Alderlake HDMI", patch_i915_tgl_hdmi),
4429
+HDA_CODEC_ENTRY(0x80862816, "Rocketlake HDMI", patch_i915_tgl_hdmi),
4430
+HDA_CODEC_ENTRY(0x80862819, "DG2 HDMI", patch_i915_tgl_hdmi),
4431
+HDA_CODEC_ENTRY(0x8086281a, "Jasperlake HDMI", patch_i915_icl_hdmi),
4432
+HDA_CODEC_ENTRY(0x8086281b, "Elkhartlake HDMI", patch_i915_icl_hdmi),
4433
+HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi),
39504434 HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi),
39514435 HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_i915_byt_hdmi),
39524436 HDA_CODEC_ENTRY(0x80862883, "Braswell HDMI", patch_i915_byt_hdmi),