aboutsummaryrefslogtreecommitdiffstats
path: root/sound/hda
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2016-03-21 09:41:58 -0400
committerTakashi Iwai <tiwai@suse.de>2016-03-28 03:38:40 -0400
commitd745f5e7b8b2961f68b0b9093a0f914a8a83c2ae (patch)
tree0ce841aa86a1f3360a8e298124b7b60cd3779c98 /sound/hda
parente85015a3797f2665cc6f0339e6407adc00ac4245 (diff)
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 <tiwai@suse.de>
Diffstat (limited to 'sound/hda')
-rw-r--r--sound/hda/hdac_i915.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c
index fb96aead8257..750a4ea49fa9 100644
--- a/sound/hda/hdac_i915.c
+++ b/sound/hda/hdac_i915.c
@@ -118,22 +118,40 @@ int snd_hdac_get_display_clk(struct hdac_bus *bus)
118} 118}
119EXPORT_SYMBOL_GPL(snd_hdac_get_display_clk); 119EXPORT_SYMBOL_GPL(snd_hdac_get_display_clk);
120 120
121/* There is a fixed mapping between audio pin node and display port 121/* There is a fixed mapping between audio pin node and display port.
122 * on current Intel platforms: 122 * on SNB, IVY, HSW, BSW, SKL, BXT, KBL:
123 * Pin Widget 5 - PORT B (port = 1 in i915 driver) 123 * Pin Widget 5 - PORT B (port = 1 in i915 driver)
124 * Pin Widget 6 - PORT C (port = 2 in i915 driver) 124 * Pin Widget 6 - PORT C (port = 2 in i915 driver)
125 * Pin Widget 7 - PORT D (port = 3 in i915 driver) 125 * 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)
126 */ 131 */
127static int pin2port(hda_nid_t pin_nid) 132static int pin2port(struct hdac_device *codec, hda_nid_t pin_nid)
128{ 133{
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))
130 return -1; 148 return -1;
131 return pin_nid - 4; 149 return pin_nid - base_nid;
132} 150}
133 151
134/** 152/**
135 * snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate 153 * snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate
136 * @bus: HDA core bus 154 * @codec: HDA codec
137 * @nid: the pin widget NID 155 * @nid: the pin widget NID
138 * @rate: the sample rate to set 156 * @rate: the sample rate to set
139 * 157 *
@@ -143,14 +161,15 @@ static int pin2port(hda_nid_t pin_nid)
143 * This function sets N/CTS value based on the given sample rate. 161 * This function sets N/CTS value based on the given sample rate.
144 * Returns zero for success, or a negative error code. 162 * Returns zero for success, or a negative error code.
145 */ 163 */
146int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid, int rate) 164int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid, int rate)
147{ 165{
166 struct hdac_bus *bus = codec->bus;
148 struct i915_audio_component *acomp = bus->audio_component; 167 struct i915_audio_component *acomp = bus->audio_component;
149 int port; 168 int port;
150 169
151 if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate) 170 if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate)
152 return -ENODEV; 171 return -ENODEV;
153 port = pin2port(nid); 172 port = pin2port(codec, nid);
154 if (port < 0) 173 if (port < 0)
155 return -EINVAL; 174 return -EINVAL;
156 return acomp->ops->sync_audio_rate(acomp->dev, port, rate); 175 return acomp->ops->sync_audio_rate(acomp->dev, port, rate);
@@ -159,7 +178,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_sync_audio_rate);
159 178
160/** 179/**
161 * snd_hdac_acomp_get_eld - Get the audio state and ELD via component 180 * snd_hdac_acomp_get_eld - Get the audio state and ELD via component
162 * @bus: HDA core bus 181 * @codec: HDA codec
163 * @nid: the pin widget NID 182 * @nid: the pin widget NID
164 * @audio_enabled: the pointer to store the current audio state 183 * @audio_enabled: the pointer to store the current audio state
165 * @buffer: the buffer pointer to store ELD bytes 184 * @buffer: the buffer pointer to store ELD bytes
@@ -177,16 +196,17 @@ EXPORT_SYMBOL_GPL(snd_hdac_sync_audio_rate);
177 * thus it may be over @max_bytes. If it's over @max_bytes, it implies 196 * thus it may be over @max_bytes. If it's over @max_bytes, it implies
178 * that only a part of ELD bytes have been fetched. 197 * that only a part of ELD bytes have been fetched.
179 */ 198 */
180int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid, 199int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid,
181 bool *audio_enabled, char *buffer, int max_bytes) 200 bool *audio_enabled, char *buffer, int max_bytes)
182{ 201{
202 struct hdac_bus *bus = codec->bus;
183 struct i915_audio_component *acomp = bus->audio_component; 203 struct i915_audio_component *acomp = bus->audio_component;
184 int port; 204 int port;
185 205
186 if (!acomp || !acomp->ops || !acomp->ops->get_eld) 206 if (!acomp || !acomp->ops || !acomp->ops->get_eld)
187 return -ENODEV; 207 return -ENODEV;
188 208
189 port = pin2port(nid); 209 port = pin2port(codec, nid);
190 if (port < 0) 210 if (port < 0)
191 return -EINVAL; 211 return -EINVAL;
192 return acomp->ops->get_eld(acomp->dev, port, audio_enabled, 212 return acomp->ops->get_eld(acomp->dev, port, audio_enabled,
@@ -286,6 +306,9 @@ int snd_hdac_i915_init(struct hdac_bus *bus)
286 struct i915_audio_component *acomp; 306 struct i915_audio_component *acomp;
287 int ret; 307 int ret;
288 308
309 if (WARN_ON(hdac_acomp))
310 return -EBUSY;
311
289 acomp = kzalloc(sizeof(*acomp), GFP_KERNEL); 312 acomp = kzalloc(sizeof(*acomp), GFP_KERNEL);
290 if (!acomp) 313 if (!acomp)
291 return -ENOMEM; 314 return -ENOMEM;