Skip to content

Commit 6720b38

Browse files
Vinod Koultiwai
authored andcommitted
ALSA: hda - move bus_parse_capabilities to core
HDA capability introduced recently are move to hdac core so that it can be used by legacy driver as well. Also move the capability pointers up to hdac_bus object. Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 29b4817 commit 6720b38

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

include/sound/hdaudio.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ struct hdac_rb {
245245

246246
/*
247247
* HD-audio bus base driver
248+
*
249+
* @ppcap: pp capabilities pointer
250+
* @spbcap: SPIB capabilities pointer
251+
* @mlcap: MultiLink capabilities pointer
252+
* @gtscap: gts capabilities pointer
253+
* @drsmcap: dma resume capabilities pointer
248254
*/
249255
struct hdac_bus {
250256
struct device *dev;
@@ -256,6 +262,12 @@ struct hdac_bus {
256262
void __iomem *remap_addr;
257263
int irq;
258264

265+
void __iomem *ppcap;
266+
void __iomem *spbcap;
267+
void __iomem *mlcap;
268+
void __iomem *gtscap;
269+
void __iomem *drsmcap;
270+
259271
/* codec linked list */
260272
struct list_head codec_list;
261273
unsigned int num_codecs;
@@ -335,6 +347,7 @@ static inline void snd_hdac_codec_link_down(struct hdac_device *codec)
335347
int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val);
336348
int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,
337349
unsigned int *res);
350+
int snd_hdac_bus_parse_capabilities(struct hdac_bus *bus);
338351
int snd_hdac_link_power(struct hdac_device *codec, bool enable);
339352

340353
bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset);

sound/hda/hdac_controller.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,81 @@ int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,
255255
}
256256
EXPORT_SYMBOL_GPL(snd_hdac_bus_get_response);
257257

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+
258333
/*
259334
* Lowlevel interface
260335
*/

0 commit comments

Comments
 (0)