@@ -121,8 +121,16 @@ struct hdac_hdmi_dai_port_map {
121
121
struct hdac_hdmi_cvt * cvt ;
122
122
};
123
123
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
+
124
130
struct hdac_hdmi_drv_data {
125
131
unsigned int vendor_nid ;
132
+ const int * port_map ; /* pin to port mapping table */
133
+ int port_num ;
126
134
};
127
135
128
136
struct hdac_hdmi_priv {
@@ -1329,11 +1337,12 @@ static int hdac_hdmi_add_pin(struct hdac_device *hdev, hda_nid_t nid)
1329
1337
return 0 ;
1330
1338
}
1331
1339
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
1334
1343
#define INTEL_GET_VENDOR_VERB 0xf81
1335
1344
#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 */
1337
1346
#define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */
1338
1347
1339
1348
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,
1538
1547
1539
1548
static int hdac_hdmi_pin2port (void * aptr , int pin )
1540
1549
{
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 ;
1542
1570
}
1543
1571
1544
1572
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)
1549
1577
struct hdac_hdmi_port * hport = NULL ;
1550
1578
struct snd_soc_component * component = hdmi -> component ;
1551
1579
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
+ }
1555
1592
1556
1593
dev_dbg (& hdev -> dev , "%s: for pin:%d port=%d\n" , __func__ ,
1557
1594
pin_nid , pipe );
@@ -1973,12 +2010,18 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdev, int pcm_idx)
1973
2010
return port -> eld .info .spk_alloc ;
1974
2011
}
1975
2012
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
+
1976
2019
static struct hdac_hdmi_drv_data intel_glk_drv_data = {
1977
- .vendor_nid = INTEL_GLK_VENDOR_NID ,
2020
+ .vendor_nid = INTEL_VENDOR_NID_0xb ,
1978
2021
};
1979
2022
1980
2023
static struct hdac_hdmi_drv_data intel_drv_data = {
1981
- .vendor_nid = INTEL_VENDOR_NID ,
2024
+ .vendor_nid = INTEL_VENDOR_NID_0x8 ,
1982
2025
};
1983
2026
1984
2027
static int hdac_hdmi_dev_probe (struct hdac_device * hdev )
@@ -2259,6 +2302,8 @@ static const struct hda_device_id hdmi_list[] = {
2259
2302
& intel_glk_drv_data ),
2260
2303
HDA_CODEC_EXT_ENTRY (0x8086280d , 0x100000 , "Geminilake HDMI" ,
2261
2304
& intel_glk_drv_data ),
2305
+ HDA_CODEC_EXT_ENTRY (0x8086280f , 0x100000 , "Icelake HDMI" ,
2306
+ & intel_icl_drv_data ),
2262
2307
{}
2263
2308
};
2264
2309
0 commit comments