Skip to content

Commit d745f5e

Browse files
committed
ALSA: hda - Add the pin / port mapping on Intel ILK and VLV
Intel IronLake and ValleyView platforms have different HDMI widget pin and digital port mapping from other newer ones. The recent ones (HSW+) have NID 0x05 to 0x07 for port B to port D, while these chips have NID 0x04 to 0x06. For adapting this mapping, pass the codec object instead of the bus object to snd_hdac_sync_audio_rate() and snd_hdac_acomp_get_eld() so that they can check the codec ID and calculate the mapping properly. The changes in the HDMI codec driver side will follow in the later patch. Signed-off-by: Takashi Iwai <[email protected]>
1 parent e85015a commit d745f5e

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

include/sound/hda_i915.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable);
1111
int snd_hdac_display_power(struct hdac_bus *bus, bool enable);
1212
int snd_hdac_get_display_clk(struct hdac_bus *bus);
13-
int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid, int rate);
14-
int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid,
13+
int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid, int rate);
14+
int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid,
1515
bool *audio_enabled, char *buffer, int max_bytes);
1616
int snd_hdac_i915_init(struct hdac_bus *bus);
1717
int snd_hdac_i915_exit(struct hdac_bus *bus);
@@ -29,12 +29,12 @@ static inline int snd_hdac_get_display_clk(struct hdac_bus *bus)
2929
{
3030
return 0;
3131
}
32-
static inline int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid,
33-
int rate)
32+
static inline int snd_hdac_sync_audio_rate(struct hdac_device *codec,
33+
hda_nid_t nid, int rate)
3434
{
3535
return 0;
3636
}
37-
static inline int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid,
37+
static inline int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid,
3838
bool *audio_enabled, char *buffer,
3939
int max_bytes)
4040
{

sound/hda/hdac_i915.c

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,40 @@ int snd_hdac_get_display_clk(struct hdac_bus *bus)
118118
}
119119
EXPORT_SYMBOL_GPL(snd_hdac_get_display_clk);
120120

121-
/* There is a fixed mapping between audio pin node and display port
122-
* on current Intel platforms:
121+
/* There is a fixed mapping between audio pin node and display port.
122+
* on SNB, IVY, HSW, BSW, SKL, BXT, KBL:
123123
* Pin Widget 5 - PORT B (port = 1 in i915 driver)
124124
* Pin Widget 6 - PORT C (port = 2 in i915 driver)
125125
* Pin Widget 7 - PORT D (port = 3 in i915 driver)
126+
*
127+
* on VLV, ILK:
128+
* Pin Widget 4 - PORT B (port = 1 in i915 driver)
129+
* Pin Widget 5 - PORT C (port = 2 in i915 driver)
130+
* Pin Widget 6 - PORT D (port = 3 in i915 driver)
126131
*/
127-
static int pin2port(hda_nid_t pin_nid)
132+
static int pin2port(struct hdac_device *codec, hda_nid_t pin_nid)
128133
{
129-
if (WARN_ON(pin_nid < 5 || pin_nid > 7))
134+
int base_nid;
135+
136+
switch (codec->vendor_id) {
137+
case 0x80860054: /* ILK */
138+
case 0x80862804: /* ILK */
139+
case 0x80862882: /* VLV */
140+
base_nid = 3;
141+
break;
142+
default:
143+
base_nid = 4;
144+
break;
145+
}
146+
147+
if (WARN_ON(pin_nid <= base_nid || pin_nid > base_nid + 3))
130148
return -1;
131-
return pin_nid - 4;
149+
return pin_nid - base_nid;
132150
}
133151

134152
/**
135153
* snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate
136-
* @bus: HDA core bus
154+
* @codec: HDA codec
137155
* @nid: the pin widget NID
138156
* @rate: the sample rate to set
139157
*
@@ -143,14 +161,15 @@ static int pin2port(hda_nid_t pin_nid)
143161
* This function sets N/CTS value based on the given sample rate.
144162
* Returns zero for success, or a negative error code.
145163
*/
146-
int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid, int rate)
164+
int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid, int rate)
147165
{
166+
struct hdac_bus *bus = codec->bus;
148167
struct i915_audio_component *acomp = bus->audio_component;
149168
int port;
150169

151170
if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate)
152171
return -ENODEV;
153-
port = pin2port(nid);
172+
port = pin2port(codec, nid);
154173
if (port < 0)
155174
return -EINVAL;
156175
return acomp->ops->sync_audio_rate(acomp->dev, port, rate);
@@ -159,7 +178,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_sync_audio_rate);
159178

160179
/**
161180
* snd_hdac_acomp_get_eld - Get the audio state and ELD via component
162-
* @bus: HDA core bus
181+
* @codec: HDA codec
163182
* @nid: the pin widget NID
164183
* @audio_enabled: the pointer to store the current audio state
165184
* @buffer: the buffer pointer to store ELD bytes
@@ -177,16 +196,17 @@ EXPORT_SYMBOL_GPL(snd_hdac_sync_audio_rate);
177196
* thus it may be over @max_bytes. If it's over @max_bytes, it implies
178197
* that only a part of ELD bytes have been fetched.
179198
*/
180-
int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid,
199+
int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid,
181200
bool *audio_enabled, char *buffer, int max_bytes)
182201
{
202+
struct hdac_bus *bus = codec->bus;
183203
struct i915_audio_component *acomp = bus->audio_component;
184204
int port;
185205

186206
if (!acomp || !acomp->ops || !acomp->ops->get_eld)
187207
return -ENODEV;
188208

189-
port = pin2port(nid);
209+
port = pin2port(codec, nid);
190210
if (port < 0)
191211
return -EINVAL;
192212
return acomp->ops->get_eld(acomp->dev, port, audio_enabled,
@@ -286,6 +306,9 @@ int snd_hdac_i915_init(struct hdac_bus *bus)
286306
struct i915_audio_component *acomp;
287307
int ret;
288308

309+
if (WARN_ON(hdac_acomp))
310+
return -EBUSY;
311+
289312
acomp = kzalloc(sizeof(*acomp), GFP_KERNEL);
290313
if (!acomp)
291314
return -ENOMEM;

sound/pci/hda/patch_hdmi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ static void sync_eld_via_acomp(struct hda_codec *codec,
14861486

14871487
mutex_lock(&per_pin->lock);
14881488
eld->monitor_present = false;
1489-
size = snd_hdac_acomp_get_eld(&codec->bus->core, per_pin->pin_nid,
1489+
size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid,
14901490
&eld->monitor_present, eld->eld_buffer,
14911491
ELD_MAX_SIZE);
14921492
if (size > 0) {
@@ -1740,7 +1740,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
17401740
/* Call sync_audio_rate to set the N/CTS/M manually if necessary */
17411741
/* Todo: add DP1.2 MST audio support later */
17421742
if (codec_has_acomp(codec))
1743-
snd_hdac_sync_audio_rate(&codec->bus->core, pin_nid, runtime->rate);
1743+
snd_hdac_sync_audio_rate(&codec->core, pin_nid, runtime->rate);
17441744

17451745
non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
17461746
mutex_lock(&per_pin->lock);

0 commit comments

Comments
 (0)