@@ -255,6 +255,81 @@ int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,
255
255
}
256
256
EXPORT_SYMBOL_GPL (snd_hdac_bus_get_response );
257
257
258
+ #define HDAC_MAX_CAPS 10
259
+ /**
260
+ * snd_hdac_bus_parse_capabilities - parse capability structure
261
+ * @bus: the pointer to bus object
262
+ *
263
+ * Returns 0 if successful, or a negative error code.
264
+ */
265
+ int snd_hdac_bus_parse_capabilities (struct hdac_bus * bus )
266
+ {
267
+ unsigned int cur_cap ;
268
+ unsigned int offset ;
269
+ unsigned int counter = 0 ;
270
+
271
+ offset = snd_hdac_chip_readl (bus , LLCH );
272
+
273
+ /* Lets walk the linked capabilities list */
274
+ do {
275
+ cur_cap = _snd_hdac_chip_read (l , bus , offset );
276
+
277
+ dev_dbg (bus -> dev , "Capability version: 0x%x\n" ,
278
+ (cur_cap & AZX_CAP_HDR_VER_MASK ) >> AZX_CAP_HDR_VER_OFF );
279
+
280
+ dev_dbg (bus -> dev , "HDA capability ID: 0x%x\n" ,
281
+ (cur_cap & AZX_CAP_HDR_ID_MASK ) >> AZX_CAP_HDR_ID_OFF );
282
+
283
+ switch ((cur_cap & AZX_CAP_HDR_ID_MASK ) >> AZX_CAP_HDR_ID_OFF ) {
284
+ case AZX_ML_CAP_ID :
285
+ dev_dbg (bus -> dev , "Found ML capability\n" );
286
+ bus -> mlcap = bus -> remap_addr + offset ;
287
+ break ;
288
+
289
+ case AZX_GTS_CAP_ID :
290
+ dev_dbg (bus -> dev , "Found GTS capability offset=%x\n" , offset );
291
+ bus -> gtscap = bus -> remap_addr + offset ;
292
+ break ;
293
+
294
+ case AZX_PP_CAP_ID :
295
+ /* PP capability found, the Audio DSP is present */
296
+ dev_dbg (bus -> dev , "Found PP capability offset=%x\n" , offset );
297
+ bus -> ppcap = bus -> remap_addr + offset ;
298
+ break ;
299
+
300
+ case AZX_SPB_CAP_ID :
301
+ /* SPIB capability found, handler function */
302
+ dev_dbg (bus -> dev , "Found SPB capability\n" );
303
+ bus -> spbcap = bus -> remap_addr + offset ;
304
+ break ;
305
+
306
+ case AZX_DRSM_CAP_ID :
307
+ /* DMA resume capability found, handler function */
308
+ dev_dbg (bus -> dev , "Found DRSM capability\n" );
309
+ bus -> drsmcap = bus -> remap_addr + offset ;
310
+ break ;
311
+
312
+ default :
313
+ dev_dbg (bus -> dev , "Unknown capability %d\n" , cur_cap );
314
+ break ;
315
+ }
316
+
317
+ counter ++ ;
318
+
319
+ if (counter > HDAC_MAX_CAPS ) {
320
+ dev_err (bus -> dev , "We exceeded HDAC capabilities!!!\n" );
321
+ break ;
322
+ }
323
+
324
+ /* read the offset of next capability */
325
+ offset = cur_cap & AZX_CAP_HDR_NXT_PTR_MASK ;
326
+
327
+ } while (offset );
328
+
329
+ return 0 ;
330
+ }
331
+ EXPORT_SYMBOL_GPL (snd_hdac_bus_parse_capabilities );
332
+
258
333
/*
259
334
* Lowlevel interface
260
335
*/
0 commit comments