@@ -118,22 +118,40 @@ int snd_hdac_get_display_clk(struct hdac_bus *bus)
118
118
}
119
119
EXPORT_SYMBOL_GPL (snd_hdac_get_display_clk );
120
120
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 :
123
123
* Pin Widget 5 - PORT B (port = 1 in i915 driver)
124
124
* Pin Widget 6 - PORT C (port = 2 in i915 driver)
125
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
*/
127
- static int pin2port (hda_nid_t pin_nid )
132
+ static 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
148
return -1 ;
131
- return pin_nid - 4 ;
149
+ return pin_nid - base_nid ;
132
150
}
133
151
134
152
/**
135
153
* snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate
136
- * @bus : HDA core bus
154
+ * @codec : HDA codec
137
155
* @nid: the pin widget NID
138
156
* @rate: the sample rate to set
139
157
*
@@ -143,14 +161,15 @@ static int pin2port(hda_nid_t pin_nid)
143
161
* This function sets N/CTS value based on the given sample rate.
144
162
* Returns zero for success, or a negative error code.
145
163
*/
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 )
147
165
{
166
+ struct hdac_bus * bus = codec -> bus ;
148
167
struct i915_audio_component * acomp = bus -> audio_component ;
149
168
int port ;
150
169
151
170
if (!acomp || !acomp -> ops || !acomp -> ops -> sync_audio_rate )
152
171
return - ENODEV ;
153
- port = pin2port (nid );
172
+ port = pin2port (codec , nid );
154
173
if (port < 0 )
155
174
return - EINVAL ;
156
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
180
* snd_hdac_acomp_get_eld - Get the audio state and ELD via component
162
- * @bus : HDA core bus
181
+ * @codec : HDA codec
163
182
* @nid: the pin widget NID
164
183
* @audio_enabled: the pointer to store the current audio state
165
184
* @buffer: the buffer pointer to store ELD bytes
@@ -177,16 +196,17 @@ EXPORT_SYMBOL_GPL(snd_hdac_sync_audio_rate);
177
196
* thus it may be over @max_bytes. If it's over @max_bytes, it implies
178
197
* that only a part of ELD bytes have been fetched.
179
198
*/
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 ,
181
200
bool * audio_enabled , char * buffer , int max_bytes )
182
201
{
202
+ struct hdac_bus * bus = codec -> bus ;
183
203
struct i915_audio_component * acomp = bus -> audio_component ;
184
204
int port ;
185
205
186
206
if (!acomp || !acomp -> ops || !acomp -> ops -> get_eld )
187
207
return - ENODEV ;
188
208
189
- port = pin2port (nid );
209
+ port = pin2port (codec , nid );
190
210
if (port < 0 )
191
211
return - EINVAL ;
192
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
306
struct i915_audio_component * acomp ;
287
307
int ret ;
288
308
309
+ if (WARN_ON (hdac_acomp ))
310
+ return - EBUSY ;
311
+
289
312
acomp = kzalloc (sizeof (* acomp ), GFP_KERNEL );
290
313
if (!acomp )
291
314
return - ENOMEM ;
0 commit comments