/** * snd_hdac_bus_init - initialize a HD-audio bas bus * @bus: the pointer to bus object * @dev: device pointer * @ops: bus verb operators * * Returns 0 if successful, or a negative error code.
*/ int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, conststruct hdac_bus_ops *ops)
{
memset(bus, 0, sizeof(*bus));
bus->dev = dev; if (ops)
bus->ops = ops; else
bus->ops = &default_ops;
bus->dma_type = SNDRV_DMA_TYPE_DEV;
INIT_LIST_HEAD(&bus->stream_list);
INIT_LIST_HEAD(&bus->codec_list);
INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events);
spin_lock_init(&bus->reg_lock);
mutex_init(&bus->cmd_mutex);
mutex_init(&bus->lock);
INIT_LIST_HEAD(&bus->hlink_list);
init_waitqueue_head(&bus->rirb_wq);
bus->irq = -1;
/* * Default value of '8' is as per the HD audio specification (Rev 1.0a). * Following relation is used to derive STRIPE control value. * For sample rate <= 48K: * { ((num_channels * bits_per_sample) / number of SDOs) >= 8 } * For sample rate > 48K: * { ((num_channels * bits_per_sample * rate/48000) / * number of SDOs) >= 8 }
*/
bus->sdo_limit = 8;
return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_bus_init);
/** * snd_hdac_bus_exit - clean up a HD-audio bas bus * @bus: the pointer to bus object
*/ void snd_hdac_bus_exit(struct hdac_bus *bus)
{
WARN_ON(!list_empty(&bus->stream_list));
WARN_ON(!list_empty(&bus->codec_list));
cancel_work_sync(&bus->unsol_work);
}
EXPORT_SYMBOL_GPL(snd_hdac_bus_exit);
/** * snd_hdac_bus_exec_verb - execute a HD-audio verb on the given bus * @bus: bus object * @addr: the HDAC device address * @cmd: HD-audio encoded verb * @res: pointer to store the response, NULL if performing asynchronously * * Returns 0 if successful, or a negative error code.
*/ int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsignedint addr, unsignedint cmd, unsignedint *res)
{ int err;
/** * snd_hdac_bus_exec_verb_unlocked - unlocked version * @bus: bus object * @addr: the HDAC device address * @cmd: HD-audio encoded verb * @res: pointer to store the response, NULL if performing asynchronously * * Returns 0 if successful, or a negative error code.
*/ int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsignedint addr, unsignedint cmd, unsignedint *res)
{ unsignedint tmp; int err;
if (cmd == ~0) return -EINVAL;
if (res)
*res = -1; elseif (bus->sync_write)
res = &tmp; for (;;) {
trace_hda_send_cmd(bus, cmd);
err = bus->ops->command(bus, cmd); if (err != -EAGAIN) break; /* process pending verbs */
err = bus->ops->get_response(bus, addr, &tmp); if (err) break;
} if (!err && res) {
err = bus->ops->get_response(bus, addr, res);
trace_hda_get_response(bus, addr, *res);
} return err;
}
EXPORT_SYMBOL_GPL(snd_hdac_bus_exec_verb_unlocked);
/** * snd_hdac_bus_queue_event - add an unsolicited event to queue * @bus: the BUS * @res: unsolicited event (lower 32bit of RIRB entry) * @res_ex: codec addr and flags (upper 32bit or RIRB entry) * * Adds the given event to the queue. The events are processed in * the workqueue asynchronously. Call this function in the interrupt * hanlder when RIRB receives an unsolicited event.
*/ void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex)
{ unsignedint wp;
spin_lock_irq(&bus->reg_lock); while (bus->unsol_rp != bus->unsol_wp) {
rp = (bus->unsol_rp + 1) % HDA_UNSOL_QUEUE_SIZE;
bus->unsol_rp = rp;
rp <<= 1;
res = bus->unsol_queue[rp];
caddr = bus->unsol_queue[rp + 1]; if (!(caddr & (1 << 4))) /* no unsolicited event? */ continue;
codec = bus->caddr_tbl[caddr & 0x0f]; if (!codec || !codec->registered) continue;
spin_unlock_irq(&bus->reg_lock);
drv = drv_to_hdac_driver(codec->dev.driver); if (drv->unsol_event)
drv->unsol_event(codec, res);
spin_lock_irq(&bus->reg_lock);
}
spin_unlock_irq(&bus->reg_lock);
}
/** * snd_hdac_bus_add_device - Add a codec to bus * @bus: HDA core bus * @codec: HDA core device to add * * Adds the given codec to the list in the bus. The caddr_tbl array * and codec_powered bits are updated, as well. * Returns zero if success, or a negative error code.
*/ int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec)
{ if (bus->caddr_tbl[codec->addr]) {
dev_err(bus->dev, "address 0x%x is already occupied\n",
codec->addr); return -EBUSY;
}
v = readl(aligned_addr);
v &= ~(mask << shift);
v |= val << shift;
writel(v, aligned_addr);
}
EXPORT_SYMBOL_GPL(snd_hdac_aligned_write); #endif/* CONFIG_SND_HDA_ALIGNED_MMIO */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.