Skip to content

Commit 019033c

Browse files
bardliaobroonie
authored andcommitted
ASoC: Intel: hdac_hdmi: add Icelake support
Add Icelake device id. Also, Icelake's pin2port mapping table is complicated. So we use a mapping table to do the pin2port mapping. Signed-off-by: Bard liao <bard.liao@intel.com> Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent dcad34f commit 019033c

File tree

1 file changed

+54
-9
lines changed

1 file changed

+54
-9
lines changed

sound/soc/codecs/hdac_hdmi.c

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,16 @@ struct hdac_hdmi_dai_port_map {
121121
struct hdac_hdmi_cvt *cvt;
122122
};
123123

124+
/*
125+
* pin to port mapping table where the value indicate the pin number and
126+
* the index indicate the port number with 1 base.
127+
*/
128+
static const int icl_pin2port_map[] = {0x4, 0x6, 0x8, 0xa, 0xb};
129+
124130
struct hdac_hdmi_drv_data {
125131
unsigned int vendor_nid;
132+
const int *port_map; /* pin to port mapping table */
133+
int port_num;
126134
};
127135

128136
struct hdac_hdmi_priv {
@@ -1329,11 +1337,12 @@ static int hdac_hdmi_add_pin(struct hdac_device *hdev, hda_nid_t nid)
13291337
return 0;
13301338
}
13311339

1332-
#define INTEL_VENDOR_NID 0x08
1333-
#define INTEL_GLK_VENDOR_NID 0x0b
1340+
#define INTEL_VENDOR_NID_0x2 0x02
1341+
#define INTEL_VENDOR_NID_0x8 0x08
1342+
#define INTEL_VENDOR_NID_0xb 0x0b
13341343
#define INTEL_GET_VENDOR_VERB 0xf81
13351344
#define INTEL_SET_VENDOR_VERB 0x781
1336-
#define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */
1345+
#define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */
13371346
#define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */
13381347

13391348
static void hdac_hdmi_skl_enable_all_pins(struct hdac_device *hdev)
@@ -1538,7 +1547,26 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_device *hdev,
15381547

15391548
static int hdac_hdmi_pin2port(void *aptr, int pin)
15401549
{
1541-
return pin - 4; /* map NID 0x05 -> port #1 */
1550+
struct hdac_device *hdev = aptr;
1551+
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1552+
const int *map = hdmi->drv_data->port_map;
1553+
int i;
1554+
1555+
if (!hdmi->drv_data->port_num)
1556+
return pin - 4; /* map NID 0x05 -> port #1 */
1557+
1558+
/*
1559+
* looking for the pin number in the mapping table and return
1560+
* the index which indicate the port number
1561+
*/
1562+
for (i = 0; i < hdmi->drv_data->port_num; i++) {
1563+
if (pin == map[i])
1564+
return i + 1;
1565+
}
1566+
1567+
/* return -1 if pin number exceeds our expectation */
1568+
dev_err(&hdev->dev, "Can't find the port for pin %d\n", pin);
1569+
return -1;
15421570
}
15431571

15441572
static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
@@ -1549,9 +1577,18 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
15491577
struct hdac_hdmi_port *hport = NULL;
15501578
struct snd_soc_component *component = hdmi->component;
15511579
int i;
1552-
1553-
/* Don't know how this mapping is derived */
1554-
hda_nid_t pin_nid = port + 0x04;
1580+
hda_nid_t pin_nid;
1581+
1582+
if (!hdmi->drv_data->port_num) {
1583+
/* for legacy platforms */
1584+
pin_nid = port + 0x04;
1585+
} else if (port < hdmi->drv_data->port_num) {
1586+
/* get pin number from the pin2port mapping table */
1587+
pin_nid = hdmi->drv_data->port_map[port - 1];
1588+
} else {
1589+
dev_err(&hdev->dev, "Can't find the pin for port %d\n", port);
1590+
return;
1591+
}
15551592

15561593
dev_dbg(&hdev->dev, "%s: for pin:%d port=%d\n", __func__,
15571594
pin_nid, pipe);
@@ -1973,12 +2010,18 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdev, int pcm_idx)
19732010
return port->eld.info.spk_alloc;
19742011
}
19752012

2013+
static struct hdac_hdmi_drv_data intel_icl_drv_data = {
2014+
.vendor_nid = INTEL_VENDOR_NID_0x2,
2015+
.port_map = icl_pin2port_map,
2016+
.port_num = ARRAY_SIZE(icl_pin2port_map),
2017+
};
2018+
19762019
static struct hdac_hdmi_drv_data intel_glk_drv_data = {
1977-
.vendor_nid = INTEL_GLK_VENDOR_NID,
2020+
.vendor_nid = INTEL_VENDOR_NID_0xb,
19782021
};
19792022

19802023
static struct hdac_hdmi_drv_data intel_drv_data = {
1981-
.vendor_nid = INTEL_VENDOR_NID,
2024+
.vendor_nid = INTEL_VENDOR_NID_0x8,
19822025
};
19832026

19842027
static int hdac_hdmi_dev_probe(struct hdac_device *hdev)
@@ -2259,6 +2302,8 @@ static const struct hda_device_id hdmi_list[] = {
22592302
&intel_glk_drv_data),
22602303
HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI",
22612304
&intel_glk_drv_data),
2305+
HDA_CODEC_EXT_ENTRY(0x8086280f, 0x100000, "Icelake HDMI",
2306+
&intel_icl_drv_data),
22622307
{}
22632308
};
22642309

0 commit comments

Comments
 (0)