summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-23 21:58:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-23 21:58:18 -0500
commitef96152e6a36e0510387cb174178b7982c1ae879 (patch)
treef2b881feb97893dd6e73380fe206bbfd5110559e /sound
parentd5500a074741b78b7f778b4ab3415d5ecdcda0a7 (diff)
parent64a577196d66b44e37384bc5c4d78c61f59d5b2a (diff)
Merge tag 'drm-for-v4.11-less-shouty' of git://people.freedesktop.org/~airlied/linux
Pull drm updates from Dave Airlie: "This is the main drm pull request for v4.11. Nothing too major, the tinydrm and mmu-less support should make writing smaller drivers easier for some of the simpler platforms, and there are a bunch of documentation updates. Intel grew displayport MST audio support which is hopefully useful to people, and FBC is on by default for GEN9+ (so people know where to look for regressions). AMDGPU has a lot of fixes that would like new firmware files installed for some GPUs. Other than that it's pretty scattered all over. I may have a follow up pull request as I know BenH has a bunch of AST rework and fixes and I'd like to get those in once they've been tested by AST, and I've got at least one pull request I'm just trying to get the author to fix up. Core: - drm_mm reworked - Connector list locking and iterators - Documentation updates - Format handling rework - MMU-less support for fbdev helpers - drm_crtc_from_index helper - Core CRC API - Remove drm_framebuffer_unregister_private - Debugfs cleanup - EDID/Infoframe fixes - Release callback - Tinydrm support (smaller drivers for simple hw) panel: - Add support for some new simple panels i915: - FBC by default for gen9+ - Shared dpll cleanups and docs - GEN8 powerdomain cleanup - DMC support on GLK - DP MST audio support - HuC loading support - GVT init ordering fixes - GVT IOMMU workaround fix amdgpu/radeon: - Power/clockgating improvements - Preliminary SR-IOV support - TTM buffer priority and eviction fixes - SI DPM quirks removed due to firmware fixes - Powerplay improvements - VCE/UVD powergating fixes - Cleanup SI GFX code to match CI/VI - Support for > 2 displays on 3/5 crtc asics - SI headless fixes nouveau: - Rework securre boot code in prep for GP10x secure boot - Channel recovery improvements - Initial power budget code - MMU rework preperation vmwgfx: - Bunch of fixes and cleanups exynos: - Runtime PM support for MIC driver - Cleanups to use atomic helpers - UHD Support for TM2/TM2E boards - Trigger mode fix for Rinato board etnaviv: - Shader performance fix - Command stream validator fixes - Command buffer suballocator rockchip: - CDN DisplayPort support - IOMMU support for arm64 platform imx-drm: - Fix i.MX5 TV encoder probing - Remove lower fb size limits msm: - Support for HW cursor on MDP5 devices - DSI encoder cleanup - GPU DT bindings cleanup sti: - stih410 cleanups - Create fbdev at binding - HQVDP fixes - Remove stih416 chip functionality - DVI/HDMI mode selection fixes - FPS statistic reporting omapdrm: - IRQ code cleanup dwi-hdmi bridge: - Cleanups and fixes adv-bridge: - Updates for nexus sii8520 bridge: - Add interlace mode support - Rework HDMI and lots of fixes qxl: - probing/teardown cleanups ZTE drm: - HDMI audio via SPDIF interface - Video Layer overlay plane support - Add TV encoder output device atmel-hlcdc: - Rework fbdev creation logic tegra: - OF node fix fsl-dcu: - Minor fixes mali-dp: - Assorted fixes sunxi: - Minor fix" [ This was the "fixed" pull, that still had build warnings due to people not even having build tested the result. I'm not a happy camper I've fixed the things I noticed up in this merge. - Linus ] * tag 'drm-for-v4.11-less-shouty' of git://people.freedesktop.org/~airlied/linux: (1177 commits) lib/Kconfig: make PRIME_NUMBERS not user selectable drm/tinydrm: helpers: Properly fix backlight dependency drm/tinydrm: mipi-dbi: Fix field width specifier warning drm/tinydrm: mipi-dbi: Silence: ‘cmd’ may be used uninitialized drm/sti: fix build warnings in sti_drv.c and sti_vtg.c files drm/amd/powerplay: fix PSI feature on Polars12 drm/amdgpu: refuse to reserve io mem for split VRAM buffers drm/ttm: fix use-after-free races in vm fault handling drm/tinydrm: Add support for Multi-Inno MI0283QT display dt-bindings: Add Multi-Inno MI0283QT binding dt-bindings: display/panel: Add common rotation property of: Add vendor prefix for Multi-Inno drm/tinydrm: Add MIPI DBI support drm/tinydrm: Add helper functions drm: Add DRM support for tiny LCD displays drm/amd/amdgpu: post card if there is real hw resetting performed drm/nouveau/tmr: provide backtrace when a timeout is hit drm/nouveau/pci/g92: Fix rearm drm/nouveau/drm/therm/fan: add a fallback if no fan control is specified in the vbios drm/nouveau/hwmon: expose power_max and power_crit ..
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/hda_codec.c76
-rw-r--r--sound/pci/hda/hda_codec.h3
-rw-r--r--sound/pci/hda/patch_hdmi.c245
3 files changed, 268 insertions, 56 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 9913be8532ab..8fd745cb3f36 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -311,9 +311,15 @@ int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
311} 311}
312EXPORT_SYMBOL_GPL(snd_hda_get_conn_index); 312EXPORT_SYMBOL_GPL(snd_hda_get_conn_index);
313 313
314 314/**
315/* return DEVLIST_LEN parameter of the given widget */ 315 * snd_hda_get_num_devices - get DEVLIST_LEN parameter of the given widget
316static unsigned int get_num_devices(struct hda_codec *codec, hda_nid_t nid) 316 * @codec: the HDA codec
317 * @nid: NID of the pin to parse
318 *
319 * Get the device entry number on the given widget. This is a feature of
320 * DP MST audio. Each pin can have several device entries in it.
321 */
322unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid)
317{ 323{
318 unsigned int wcaps = get_wcaps(codec, nid); 324 unsigned int wcaps = get_wcaps(codec, nid);
319 unsigned int parm; 325 unsigned int parm;
@@ -327,6 +333,7 @@ static unsigned int get_num_devices(struct hda_codec *codec, hda_nid_t nid)
327 parm = 0; 333 parm = 0;
328 return parm & AC_DEV_LIST_LEN_MASK; 334 return parm & AC_DEV_LIST_LEN_MASK;
329} 335}
336EXPORT_SYMBOL_GPL(snd_hda_get_num_devices);
330 337
331/** 338/**
332 * snd_hda_get_devices - copy device list without cache 339 * snd_hda_get_devices - copy device list without cache
@@ -344,7 +351,7 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
344 unsigned int parm; 351 unsigned int parm;
345 int i, dev_len, devices; 352 int i, dev_len, devices;
346 353
347 parm = get_num_devices(codec, nid); 354 parm = snd_hda_get_num_devices(codec, nid);
348 if (!parm) /* not multi-stream capable */ 355 if (!parm) /* not multi-stream capable */
349 return 0; 356 return 0;
350 357
@@ -368,6 +375,63 @@ int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
368 return devices; 375 return devices;
369} 376}
370 377
378/**
379 * snd_hda_get_dev_select - get device entry select on the pin
380 * @codec: the HDA codec
381 * @nid: NID of the pin to get device entry select
382 *
383 * Get the devcie entry select on the pin. Return the device entry
384 * id selected on the pin. Return 0 means the first device entry
385 * is selected or MST is not supported.
386 */
387int snd_hda_get_dev_select(struct hda_codec *codec, hda_nid_t nid)
388{
389 /* not support dp_mst will always return 0, using first dev_entry */
390 if (!codec->dp_mst)
391 return 0;
392
393 return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DEVICE_SEL, 0);
394}
395EXPORT_SYMBOL_GPL(snd_hda_get_dev_select);
396
397/**
398 * snd_hda_set_dev_select - set device entry select on the pin
399 * @codec: the HDA codec
400 * @nid: NID of the pin to set device entry select
401 * @dev_id: device entry id to be set
402 *
403 * Set the device entry select on the pin nid.
404 */
405int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid, int dev_id)
406{
407 int ret, num_devices;
408
409 /* not support dp_mst will always return 0, using first dev_entry */
410 if (!codec->dp_mst)
411 return 0;
412
413 /* AC_PAR_DEVLIST_LEN is 0 based. */
414 num_devices = snd_hda_get_num_devices(codec, nid) + 1;
415 /* If Device List Length is 0 (num_device = 1),
416 * the pin is not multi stream capable.
417 * Do nothing in this case.
418 */
419 if (num_devices == 1)
420 return 0;
421
422 /* Behavior of setting index being equal to or greater than
423 * Device List Length is not predictable
424 */
425 if (num_devices <= dev_id)
426 return -EINVAL;
427
428 ret = snd_hda_codec_write(codec, nid, 0,
429 AC_VERB_SET_DEVICE_SEL, dev_id);
430
431 return ret;
432}
433EXPORT_SYMBOL_GPL(snd_hda_set_dev_select);
434
371/* 435/*
372 * read widget caps for each widget and store in cache 436 * read widget caps for each widget and store in cache
373 */ 437 */
@@ -403,6 +467,10 @@ static int read_pin_defaults(struct hda_codec *codec)
403 pin->nid = nid; 467 pin->nid = nid;
404 pin->cfg = snd_hda_codec_read(codec, nid, 0, 468 pin->cfg = snd_hda_codec_read(codec, nid, 0,
405 AC_VERB_GET_CONFIG_DEFAULT, 0); 469 AC_VERB_GET_CONFIG_DEFAULT, 0);
470 /*
471 * all device entries are the same widget control so far
472 * fixme: if any codec is different, need fix here
473 */
406 pin->ctrl = snd_hda_codec_read(codec, nid, 0, 474 pin->ctrl = snd_hda_codec_read(codec, nid, 0,
407 AC_VERB_GET_PIN_WIDGET_CONTROL, 475 AC_VERB_GET_PIN_WIDGET_CONTROL,
408 0); 476 0);
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 373fcad840ea..f17f25245e52 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -347,8 +347,11 @@ int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int nums,
347 const hda_nid_t *list); 347 const hda_nid_t *list);
348int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux, 348int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
349 hda_nid_t nid, int recursive); 349 hda_nid_t nid, int recursive);
350unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid);
350int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid, 351int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
351 u8 *dev_list, int max_devices); 352 u8 *dev_list, int max_devices);
353int snd_hda_get_dev_select(struct hda_codec *codec, hda_nid_t nid);
354int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid, int dev_id);
352 355
353struct hda_verb { 356struct hda_verb {
354 hda_nid_t nid; 357 hda_nid_t nid;
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 3fc201c3b95a..fd5efa72a68b 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -76,6 +76,7 @@ struct hdmi_spec_per_cvt {
76 76
77struct hdmi_spec_per_pin { 77struct hdmi_spec_per_pin {
78 hda_nid_t pin_nid; 78 hda_nid_t pin_nid;
79 int dev_id;
79 /* pin idx, different device entries on the same pin use the same idx */ 80 /* pin idx, different device entries on the same pin use the same idx */
80 int pin_nid_idx; 81 int pin_nid_idx;
81 int num_mux_nids; 82 int num_mux_nids;
@@ -130,7 +131,23 @@ struct hdmi_spec {
130 struct snd_array cvts; /* struct hdmi_spec_per_cvt */ 131 struct snd_array cvts; /* struct hdmi_spec_per_cvt */
131 hda_nid_t cvt_nids[4]; /* only for haswell fix */ 132 hda_nid_t cvt_nids[4]; /* only for haswell fix */
132 133
134 /*
135 * num_pins is the number of virtual pins
136 * for example, there are 3 pins, and each pin
137 * has 4 device entries, then the num_pins is 12
138 */
133 int num_pins; 139 int num_pins;
140 /*
141 * num_nids is the number of real pins
142 * In the above example, num_nids is 3
143 */
144 int num_nids;
145 /*
146 * dev_num is the number of device entries
147 * on each pin.
148 * In the above example, dev_num is 4
149 */
150 int dev_num;
134 struct snd_array pins; /* struct hdmi_spec_per_pin */ 151 struct snd_array pins; /* struct hdmi_spec_per_pin */
135 struct hdmi_pcm pcm_rec[16]; 152 struct hdmi_pcm pcm_rec[16];
136 struct mutex pcm_lock; 153 struct mutex pcm_lock;
@@ -217,14 +234,26 @@ union audio_infoframe {
217/* obtain hda_pcm object assigned to idx */ 234/* obtain hda_pcm object assigned to idx */
218#define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm) 235#define get_pcm_rec(spec, idx) (get_hdmi_pcm(spec, idx)->pcm)
219 236
220static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid) 237static int pin_id_to_pin_index(struct hda_codec *codec,
238 hda_nid_t pin_nid, int dev_id)
221{ 239{
222 struct hdmi_spec *spec = codec->spec; 240 struct hdmi_spec *spec = codec->spec;
223 int pin_idx; 241 int pin_idx;
242 struct hdmi_spec_per_pin *per_pin;
243
244 /*
245 * (dev_id == -1) means it is NON-MST pin
246 * return the first virtual pin on this port
247 */
248 if (dev_id == -1)
249 dev_id = 0;
224 250
225 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) 251 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
226 if (get_pin(spec, pin_idx)->pin_nid == pin_nid) 252 per_pin = get_pin(spec, pin_idx);
253 if ((per_pin->pin_nid == pin_nid) &&
254 (per_pin->dev_id == dev_id))
227 return pin_idx; 255 return pin_idx;
256 }
228 257
229 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid); 258 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid);
230 return -EINVAL; 259 return -EINVAL;
@@ -724,10 +753,11 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
724 753
725static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll); 754static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
726 755
727static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid) 756static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid,
757 int dev_id)
728{ 758{
729 struct hdmi_spec *spec = codec->spec; 759 struct hdmi_spec *spec = codec->spec;
730 int pin_idx = pin_nid_to_pin_index(codec, nid); 760 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id);
731 761
732 if (pin_idx < 0) 762 if (pin_idx < 0)
733 return; 763 return;
@@ -738,7 +768,8 @@ static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid)
738static void jack_callback(struct hda_codec *codec, 768static void jack_callback(struct hda_codec *codec,
739 struct hda_jack_callback *jack) 769 struct hda_jack_callback *jack)
740{ 770{
741 check_presence_and_report(codec, jack->nid); 771 /* hda_jack don't support DP MST */
772 check_presence_and_report(codec, jack->nid, 0);
742} 773}
743 774
744static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) 775static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
@@ -747,6 +778,12 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
747 struct hda_jack_tbl *jack; 778 struct hda_jack_tbl *jack;
748 int dev_entry = (res & AC_UNSOL_RES_DE) >> AC_UNSOL_RES_DE_SHIFT; 779 int dev_entry = (res & AC_UNSOL_RES_DE) >> AC_UNSOL_RES_DE_SHIFT;
749 780
781 /*
782 * assume DP MST uses dyn_pcm_assign and acomp and
783 * never comes here
784 * if DP MST supports unsol event, below code need
785 * consider dev_entry
786 */
750 jack = snd_hda_jack_tbl_get_from_tag(codec, tag); 787 jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
751 if (!jack) 788 if (!jack)
752 return; 789 return;
@@ -757,7 +794,8 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
757 codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA), 794 codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA),
758 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV)); 795 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV));
759 796
760 check_presence_and_report(codec, jack->nid); 797 /* hda_jack don't support DP MST */
798 check_presence_and_report(codec, jack->nid, 0);
761} 799}
762 800
763static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) 801static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
@@ -970,28 +1008,60 @@ static int intel_cvt_id_to_mux_idx(struct hdmi_spec *spec,
970 * by any other pins. 1008 * by any other pins.
971 */ 1009 */
972static void intel_not_share_assigned_cvt(struct hda_codec *codec, 1010static void intel_not_share_assigned_cvt(struct hda_codec *codec,
973 hda_nid_t pin_nid, int mux_idx) 1011 hda_nid_t pin_nid,
1012 int dev_id, int mux_idx)
974{ 1013{
975 struct hdmi_spec *spec = codec->spec; 1014 struct hdmi_spec *spec = codec->spec;
976 hda_nid_t nid; 1015 hda_nid_t nid;
977 int cvt_idx, curr; 1016 int cvt_idx, curr;
978 struct hdmi_spec_per_cvt *per_cvt; 1017 struct hdmi_spec_per_cvt *per_cvt;
1018 struct hdmi_spec_per_pin *per_pin;
1019 int pin_idx;
1020
1021 /* configure the pins connections */
1022 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1023 int dev_id_saved;
1024 int dev_num;
979 1025
980 /* configure all pins, including "no physical connection" ones */ 1026 per_pin = get_pin(spec, pin_idx);
981 for_each_hda_codec_node(nid, codec) { 1027 /*
982 unsigned int wid_caps = get_wcaps(codec, nid); 1028 * pin not connected to monitor
983 unsigned int wid_type = get_wcaps_type(wid_caps); 1029 * no need to operate on it
1030 */
1031 if (!per_pin->pcm)
1032 continue;
984 1033
985 if (wid_type != AC_WID_PIN) 1034 if ((per_pin->pin_nid == pin_nid) &&
1035 (per_pin->dev_id == dev_id))
986 continue; 1036 continue;
987 1037
988 if (nid == pin_nid) 1038 /*
1039 * if per_pin->dev_id >= dev_num,
1040 * snd_hda_get_dev_select() will fail,
1041 * and the following operation is unpredictable.
1042 * So skip this situation.
1043 */
1044 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1;
1045 if (per_pin->dev_id >= dev_num)
989 continue; 1046 continue;
990 1047
1048 nid = per_pin->pin_nid;
1049
1050 /*
1051 * Calling this function should not impact
1052 * on the device entry selection
1053 * So let's save the dev id for each pin,
1054 * and restore it when return
1055 */
1056 dev_id_saved = snd_hda_get_dev_select(codec, nid);
1057 snd_hda_set_dev_select(codec, nid, per_pin->dev_id);
991 curr = snd_hda_codec_read(codec, nid, 0, 1058 curr = snd_hda_codec_read(codec, nid, 0,
992 AC_VERB_GET_CONNECT_SEL, 0); 1059 AC_VERB_GET_CONNECT_SEL, 0);
993 if (curr != mux_idx) 1060 if (curr != mux_idx) {
1061 snd_hda_set_dev_select(codec, nid, dev_id_saved);
994 continue; 1062 continue;
1063 }
1064
995 1065
996 /* choose an unassigned converter. The conveters in the 1066 /* choose an unassigned converter. The conveters in the
997 * connection list are in the same order as in the codec. 1067 * connection list are in the same order as in the codec.
@@ -1008,12 +1078,13 @@ static void intel_not_share_assigned_cvt(struct hda_codec *codec,
1008 break; 1078 break;
1009 } 1079 }
1010 } 1080 }
1081 snd_hda_set_dev_select(codec, nid, dev_id_saved);
1011 } 1082 }
1012} 1083}
1013 1084
1014/* A wrapper of intel_not_share_asigned_cvt() */ 1085/* A wrapper of intel_not_share_asigned_cvt() */
1015static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, 1086static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec,
1016 hda_nid_t pin_nid, hda_nid_t cvt_nid) 1087 hda_nid_t pin_nid, int dev_id, hda_nid_t cvt_nid)
1017{ 1088{
1018 int mux_idx; 1089 int mux_idx;
1019 struct hdmi_spec *spec = codec->spec; 1090 struct hdmi_spec *spec = codec->spec;
@@ -1025,7 +1096,7 @@ static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec,
1025 */ 1096 */
1026 mux_idx = intel_cvt_id_to_mux_idx(spec, cvt_nid); 1097 mux_idx = intel_cvt_id_to_mux_idx(spec, cvt_nid);
1027 if (mux_idx >= 0) 1098 if (mux_idx >= 0)
1028 intel_not_share_assigned_cvt(codec, pin_nid, mux_idx); 1099 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx);
1029} 1100}
1030 1101
1031/* skeleton caller of pin_cvt_fixup ops */ 1102/* skeleton caller of pin_cvt_fixup ops */
@@ -1140,6 +1211,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
1140 per_pin->cvt_nid = per_cvt->cvt_nid; 1211 per_pin->cvt_nid = per_cvt->cvt_nid;
1141 hinfo->nid = per_cvt->cvt_nid; 1212 hinfo->nid = per_cvt->cvt_nid;
1142 1213
1214 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id);
1143 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, 1215 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
1144 AC_VERB_SET_CONNECT_SEL, 1216 AC_VERB_SET_CONNECT_SEL,
1145 per_pin->mux_idx); 1217 per_pin->mux_idx);
@@ -1198,6 +1270,7 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
1198 return -EINVAL; 1270 return -EINVAL;
1199 } 1271 }
1200 1272
1273 /* all the device entries on the same pin have the same conn list */
1201 per_pin->num_mux_nids = snd_hda_get_connections(codec, pin_nid, 1274 per_pin->num_mux_nids = snd_hda_get_connections(codec, pin_nid,
1202 per_pin->mux_nids, 1275 per_pin->mux_nids,
1203 HDA_MAX_CONNECTIONS); 1276 HDA_MAX_CONNECTIONS);
@@ -1215,13 +1288,13 @@ static int hdmi_find_pcm_slot(struct hdmi_spec *spec,
1215 return per_pin->pin_nid_idx; 1288 return per_pin->pin_nid_idx;
1216 1289
1217 /* have a second try; check the "reserved area" over num_pins */ 1290 /* have a second try; check the "reserved area" over num_pins */
1218 for (i = spec->num_pins; i < spec->pcm_used; i++) { 1291 for (i = spec->num_nids; i < spec->pcm_used; i++) {
1219 if (!test_bit(i, &spec->pcm_bitmap)) 1292 if (!test_bit(i, &spec->pcm_bitmap))
1220 return i; 1293 return i;
1221 } 1294 }
1222 1295
1223 /* the last try; check the empty slots in pins */ 1296 /* the last try; check the empty slots in pins */
1224 for (i = 0; i < spec->num_pins; i++) { 1297 for (i = 0; i < spec->num_nids; i++) {
1225 if (!test_bit(i, &spec->pcm_bitmap)) 1298 if (!test_bit(i, &spec->pcm_bitmap))
1226 return i; 1299 return i;
1227 } 1300 }
@@ -1296,10 +1369,13 @@ static void hdmi_pcm_setup_pin(struct hdmi_spec *spec,
1296 per_pin->cvt_nid = hinfo->nid; 1369 per_pin->cvt_nid = hinfo->nid;
1297 1370
1298 mux_idx = hdmi_get_pin_cvt_mux(spec, per_pin, hinfo->nid); 1371 mux_idx = hdmi_get_pin_cvt_mux(spec, per_pin, hinfo->nid);
1299 if (mux_idx < per_pin->num_mux_nids) 1372 if (mux_idx < per_pin->num_mux_nids) {
1373 snd_hda_set_dev_select(codec, per_pin->pin_nid,
1374 per_pin->dev_id);
1300 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, 1375 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
1301 AC_VERB_SET_CONNECT_SEL, 1376 AC_VERB_SET_CONNECT_SEL,
1302 mux_idx); 1377 mux_idx);
1378 }
1303 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); 1379 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid);
1304 1380
1305 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); 1381 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid);
@@ -1467,6 +1543,11 @@ static struct snd_jack *pin_idx_to_jack(struct hda_codec *codec,
1467 if (per_pin->pcm_idx >= 0 && spec->dyn_pcm_assign) 1543 if (per_pin->pcm_idx >= 0 && spec->dyn_pcm_assign)
1468 jack = spec->pcm_rec[per_pin->pcm_idx].jack; 1544 jack = spec->pcm_rec[per_pin->pcm_idx].jack;
1469 else if (!spec->dyn_pcm_assign) { 1545 else if (!spec->dyn_pcm_assign) {
1546 /*
1547 * jack tbl doesn't support DP MST
1548 * DP MST will use dyn_pcm_assign,
1549 * so DP MST will never come here
1550 */
1470 jack_tbl = snd_hda_jack_tbl_get(codec, per_pin->pin_nid); 1551 jack_tbl = snd_hda_jack_tbl_get(codec, per_pin->pin_nid);
1471 if (jack_tbl) 1552 if (jack_tbl)
1472 jack = jack_tbl->jack; 1553 jack = jack_tbl->jack;
@@ -1485,9 +1566,9 @@ static void sync_eld_via_acomp(struct hda_codec *codec,
1485 1566
1486 mutex_lock(&per_pin->lock); 1567 mutex_lock(&per_pin->lock);
1487 eld->monitor_present = false; 1568 eld->monitor_present = false;
1488 size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, -1, 1569 size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid,
1489 &eld->monitor_present, eld->eld_buffer, 1570 per_pin->dev_id, &eld->monitor_present,
1490 ELD_MAX_SIZE); 1571 eld->eld_buffer, ELD_MAX_SIZE);
1491 if (size > 0) { 1572 if (size > 0) {
1492 size = min(size, ELD_MAX_SIZE); 1573 size = min(size, ELD_MAX_SIZE);
1493 if (snd_hdmi_parse_eld(codec, &eld->info, 1574 if (snd_hdmi_parse_eld(codec, &eld->info,
@@ -1565,38 +1646,81 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
1565 int pin_idx; 1646 int pin_idx;
1566 struct hdmi_spec_per_pin *per_pin; 1647 struct hdmi_spec_per_pin *per_pin;
1567 int err; 1648 int err;
1649 int dev_num, i;
1568 1650
1569 caps = snd_hda_query_pin_caps(codec, pin_nid); 1651 caps = snd_hda_query_pin_caps(codec, pin_nid);
1570 if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP))) 1652 if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP)))
1571 return 0; 1653 return 0;
1572 1654
1655 /*
1656 * For DP MST audio, Configuration Default is the same for
1657 * all device entries on the same pin
1658 */
1573 config = snd_hda_codec_get_pincfg(codec, pin_nid); 1659 config = snd_hda_codec_get_pincfg(codec, pin_nid);
1574 if (get_defcfg_connect(config) == AC_JACK_PORT_NONE) 1660 if (get_defcfg_connect(config) == AC_JACK_PORT_NONE)
1575 return 0; 1661 return 0;
1576 1662
1577 if (is_haswell_plus(codec)) 1663 /*
1578 intel_haswell_fixup_connect_list(codec, pin_nid); 1664 * To simplify the implementation, malloc all
1579 1665 * the virtual pins in the initialization statically
1580 pin_idx = spec->num_pins; 1666 */
1581 per_pin = snd_array_new(&spec->pins); 1667 if (is_haswell_plus(codec)) {
1582 if (!per_pin) 1668 /*
1583 return -ENOMEM; 1669 * On Intel platforms, device entries number is
1584 1670 * changed dynamically. If there is a DP MST
1585 per_pin->pin_nid = pin_nid; 1671 * hub connected, the device entries number is 3.
1586 per_pin->non_pcm = false; 1672 * Otherwise, it is 1.
1587 if (spec->dyn_pcm_assign) 1673 * Here we manually set dev_num to 3, so that
1588 per_pin->pcm_idx = -1; 1674 * we can initialize all the device entries when
1589 else { 1675 * bootup statically.
1590 per_pin->pcm = get_hdmi_pcm(spec, pin_idx); 1676 */
1591 per_pin->pcm_idx = pin_idx; 1677 dev_num = 3;
1678 spec->dev_num = 3;
1679 } else if (spec->dyn_pcm_assign && codec->dp_mst) {
1680 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1;
1681 /*
1682 * spec->dev_num is the maxinum number of device entries
1683 * among all the pins
1684 */
1685 spec->dev_num = (spec->dev_num > dev_num) ?
1686 spec->dev_num : dev_num;
1687 } else {
1688 /*
1689 * If the platform doesn't support DP MST,
1690 * manually set dev_num to 1. This means
1691 * the pin has only one device entry.
1692 */
1693 dev_num = 1;
1694 spec->dev_num = 1;
1592 } 1695 }
1593 per_pin->pin_nid_idx = pin_idx;
1594 1696
1595 err = hdmi_read_pin_conn(codec, pin_idx); 1697 for (i = 0; i < dev_num; i++) {
1596 if (err < 0) 1698 pin_idx = spec->num_pins;
1597 return err; 1699 per_pin = snd_array_new(&spec->pins);
1598 1700
1599 spec->num_pins++; 1701 if (!per_pin)
1702 return -ENOMEM;
1703
1704 if (spec->dyn_pcm_assign) {
1705 per_pin->pcm = NULL;
1706 per_pin->pcm_idx = -1;
1707 } else {
1708 per_pin->pcm = get_hdmi_pcm(spec, pin_idx);
1709 per_pin->pcm_idx = pin_idx;
1710 }
1711 per_pin->pin_nid = pin_nid;
1712 per_pin->pin_nid_idx = spec->num_nids;
1713 per_pin->dev_id = i;
1714 per_pin->non_pcm = false;
1715 snd_hda_set_dev_select(codec, pin_nid, i);
1716 if (is_haswell_plus(codec))
1717 intel_haswell_fixup_connect_list(codec, pin_nid);
1718 err = hdmi_read_pin_conn(codec, pin_idx);
1719 if (err < 0)
1720 return err;
1721 spec->num_pins++;
1722 }
1723 spec->num_nids++;
1600 1724
1601 return 0; 1725 return 0;
1602} 1726}
@@ -1744,7 +1868,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1744 /* Call sync_audio_rate to set the N/CTS/M manually if necessary */ 1868 /* Call sync_audio_rate to set the N/CTS/M manually if necessary */
1745 /* Todo: add DP1.2 MST audio support later */ 1869 /* Todo: add DP1.2 MST audio support later */
1746 if (codec_has_acomp(codec)) 1870 if (codec_has_acomp(codec))
1747 snd_hdac_sync_audio_rate(&codec->core, pin_nid, -1, 1871 snd_hdac_sync_audio_rate(&codec->core, pin_nid, per_pin->dev_id,
1748 runtime->rate); 1872 runtime->rate);
1749 1873
1750 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); 1874 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
@@ -1762,6 +1886,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1762 pinctl | PIN_OUT); 1886 pinctl | PIN_OUT);
1763 } 1887 }
1764 1888
1889 /* snd_hda_set_dev_select() has been called before */
1765 err = spec->ops.setup_stream(codec, cvt_nid, pin_nid, 1890 err = spec->ops.setup_stream(codec, cvt_nid, pin_nid,
1766 stream_tag, format); 1891 stream_tag, format);
1767 mutex_unlock(&spec->pcm_lock); 1892 mutex_unlock(&spec->pcm_lock);
@@ -1897,17 +2022,23 @@ static bool is_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)
1897static int generic_hdmi_build_pcms(struct hda_codec *codec) 2022static int generic_hdmi_build_pcms(struct hda_codec *codec)
1898{ 2023{
1899 struct hdmi_spec *spec = codec->spec; 2024 struct hdmi_spec *spec = codec->spec;
1900 int pin_idx; 2025 int idx;
1901 2026
1902 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { 2027 /*
2028 * for non-mst mode, pcm number is the same as before
2029 * for DP MST mode, pcm number is (nid number + dev_num - 1)
2030 * dev_num is the device entry number in a pin
2031 *
2032 */
2033 for (idx = 0; idx < spec->num_nids + spec->dev_num - 1; idx++) {
1903 struct hda_pcm *info; 2034 struct hda_pcm *info;
1904 struct hda_pcm_stream *pstr; 2035 struct hda_pcm_stream *pstr;
1905 2036
1906 info = snd_hda_codec_pcm_new(codec, "HDMI %d", pin_idx); 2037 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx);
1907 if (!info) 2038 if (!info)
1908 return -ENOMEM; 2039 return -ENOMEM;
1909 2040
1910 spec->pcm_rec[pin_idx].pcm = info; 2041 spec->pcm_rec[idx].pcm = info;
1911 spec->pcm_used++; 2042 spec->pcm_used++;
1912 info->pcm_type = HDA_PCM_TYPE_HDMI; 2043 info->pcm_type = HDA_PCM_TYPE_HDMI;
1913 info->own_chmap = true; 2044 info->own_chmap = true;
@@ -1915,6 +2046,9 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
1915 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; 2046 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
1916 pstr->substreams = 1; 2047 pstr->substreams = 1;
1917 pstr->ops = generic_ops; 2048 pstr->ops = generic_ops;
2049 /* pcm number is less than 16 */
2050 if (spec->pcm_used >= 16)
2051 break;
1918 /* other pstr fields are set in open */ 2052 /* other pstr fields are set in open */
1919 } 2053 }
1920 2054
@@ -2070,7 +2204,9 @@ static int generic_hdmi_init(struct hda_codec *codec)
2070 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { 2204 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
2071 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); 2205 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
2072 hda_nid_t pin_nid = per_pin->pin_nid; 2206 hda_nid_t pin_nid = per_pin->pin_nid;
2207 int dev_id = per_pin->dev_id;
2073 2208
2209 snd_hda_set_dev_select(codec, pin_nid, dev_id);
2074 hdmi_init_pin(codec, pin_nid); 2210 hdmi_init_pin(codec, pin_nid);
2075 if (!codec_has_acomp(codec)) 2211 if (!codec_has_acomp(codec))
2076 snd_hda_jack_detect_enable_callback(codec, pin_nid, 2212 snd_hda_jack_detect_enable_callback(codec, pin_nid,
@@ -2178,6 +2314,7 @@ static int alloc_generic_hdmi(struct hda_codec *codec)
2178 return -ENOMEM; 2314 return -ENOMEM;
2179 2315
2180 spec->ops = generic_standard_hdmi_ops; 2316 spec->ops = generic_standard_hdmi_ops;
2317 spec->dev_num = 1; /* initialize to 1 */
2181 mutex_init(&spec->pcm_lock); 2318 mutex_init(&spec->pcm_lock);
2182 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); 2319 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap);
2183 2320
@@ -2295,6 +2432,7 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
2295{ 2432{
2296 struct hda_codec *codec = audio_ptr; 2433 struct hda_codec *codec = audio_ptr;
2297 int pin_nid; 2434 int pin_nid;
2435 int dev_id = pipe;
2298 2436
2299 /* we assume only from port-B to port-D */ 2437 /* we assume only from port-B to port-D */
2300 if (port < 1 || port > 3) 2438 if (port < 1 || port > 3)
@@ -2321,7 +2459,7 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
2321 return; 2459 return;
2322 2460
2323 snd_hdac_i915_set_bclk(&codec->bus->core); 2461 snd_hdac_i915_set_bclk(&codec->bus->core);
2324 check_presence_and_report(codec, pin_nid); 2462 check_presence_and_report(codec, pin_nid, dev_id);
2325} 2463}
2326 2464
2327/* register i915 component pin_eld_notify callback */ 2465/* register i915 component pin_eld_notify callback */
@@ -2354,11 +2492,13 @@ static void i915_pin_cvt_fixup(struct hda_codec *codec,
2354 hda_nid_t cvt_nid) 2492 hda_nid_t cvt_nid)
2355{ 2493{
2356 if (per_pin) { 2494 if (per_pin) {
2495 snd_hda_set_dev_select(codec, per_pin->pin_nid,
2496 per_pin->dev_id);
2357 intel_verify_pin_cvt_connect(codec, per_pin); 2497 intel_verify_pin_cvt_connect(codec, per_pin);
2358 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, 2498 intel_not_share_assigned_cvt(codec, per_pin->pin_nid,
2359 per_pin->mux_idx); 2499 per_pin->dev_id, per_pin->mux_idx);
2360 } else { 2500 } else {
2361 intel_not_share_assigned_cvt_nid(codec, 0, cvt_nid); 2501 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid);
2362 } 2502 }
2363} 2503}
2364 2504
@@ -2378,6 +2518,8 @@ static int patch_i915_hsw_hdmi(struct hda_codec *codec)
2378 if (err < 0) 2518 if (err < 0)
2379 return err; 2519 return err;
2380 spec = codec->spec; 2520 spec = codec->spec;
2521 codec->dp_mst = true;
2522 spec->dyn_pcm_assign = true;
2381 2523
2382 intel_haswell_enable_all_pins(codec, true); 2524 intel_haswell_enable_all_pins(codec, true);
2383 intel_haswell_fixup_enable_dp12(codec); 2525 intel_haswell_fixup_enable_dp12(codec);
@@ -2389,7 +2531,6 @@ static int patch_i915_hsw_hdmi(struct hda_codec *codec)
2389 codec->core.link_power_control = 1; 2531 codec->core.link_power_control = 1;
2390 2532
2391 codec->patch_ops.set_power_state = haswell_set_power_state; 2533 codec->patch_ops.set_power_state = haswell_set_power_state;
2392 codec->dp_mst = true;
2393 codec->depop_delay = 0; 2534 codec->depop_delay = 0;
2394 codec->auto_runtime_pm = 1; 2535 codec->auto_runtime_pm = 1;
2395 2536