Lines Matching full:bus

3  * HD-audio core bus driver
23 * snd_hdac_bus_init - initialize a HD-audio bas bus
24 * @bus: the pointer to bus object
26 * @ops: bus verb operators
30 int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, in snd_hdac_bus_init() argument
33 memset(bus, 0, sizeof(*bus)); in snd_hdac_bus_init()
34 bus->dev = dev; in snd_hdac_bus_init()
36 bus->ops = ops; in snd_hdac_bus_init()
38 bus->ops = &default_ops; in snd_hdac_bus_init()
39 bus->dma_type = SNDRV_DMA_TYPE_DEV; in snd_hdac_bus_init()
40 INIT_LIST_HEAD(&bus->stream_list); in snd_hdac_bus_init()
41 INIT_LIST_HEAD(&bus->codec_list); in snd_hdac_bus_init()
42 INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events); in snd_hdac_bus_init()
43 spin_lock_init(&bus->reg_lock); in snd_hdac_bus_init()
44 mutex_init(&bus->cmd_mutex); in snd_hdac_bus_init()
45 mutex_init(&bus->lock); in snd_hdac_bus_init()
46 INIT_LIST_HEAD(&bus->hlink_list); in snd_hdac_bus_init()
47 init_waitqueue_head(&bus->rirb_wq); in snd_hdac_bus_init()
48 bus->irq = -1; in snd_hdac_bus_init()
59 bus->sdo_limit = 8; in snd_hdac_bus_init()
66 * snd_hdac_bus_exit - clean up a HD-audio bas bus
67 * @bus: the pointer to bus object
69 void snd_hdac_bus_exit(struct hdac_bus *bus) in snd_hdac_bus_exit() argument
71 WARN_ON(!list_empty(&bus->stream_list)); in snd_hdac_bus_exit()
72 WARN_ON(!list_empty(&bus->codec_list)); in snd_hdac_bus_exit()
73 cancel_work_sync(&bus->unsol_work); in snd_hdac_bus_exit()
78 * snd_hdac_bus_exec_verb - execute a HD-audio verb on the given bus
79 * @bus: bus object
86 int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr, in snd_hdac_bus_exec_verb() argument
91 mutex_lock(&bus->cmd_mutex); in snd_hdac_bus_exec_verb()
92 err = snd_hdac_bus_exec_verb_unlocked(bus, addr, cmd, res); in snd_hdac_bus_exec_verb()
93 mutex_unlock(&bus->cmd_mutex); in snd_hdac_bus_exec_verb()
99 * @bus: bus object
106 int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr, in snd_hdac_bus_exec_verb_unlocked() argument
117 else if (bus->sync_write) in snd_hdac_bus_exec_verb_unlocked()
120 trace_hda_send_cmd(bus, cmd); in snd_hdac_bus_exec_verb_unlocked()
121 err = bus->ops->command(bus, cmd); in snd_hdac_bus_exec_verb_unlocked()
125 err = bus->ops->get_response(bus, addr, &tmp); in snd_hdac_bus_exec_verb_unlocked()
130 err = bus->ops->get_response(bus, addr, res); in snd_hdac_bus_exec_verb_unlocked()
131 trace_hda_get_response(bus, addr, *res); in snd_hdac_bus_exec_verb_unlocked()
139 * @bus: the BUS
147 void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex) in snd_hdac_bus_queue_event() argument
151 if (!bus) in snd_hdac_bus_queue_event()
154 trace_hda_unsol_event(bus, res, res_ex); in snd_hdac_bus_queue_event()
155 wp = (bus->unsol_wp + 1) % HDA_UNSOL_QUEUE_SIZE; in snd_hdac_bus_queue_event()
156 bus->unsol_wp = wp; in snd_hdac_bus_queue_event()
159 bus->unsol_queue[wp] = res; in snd_hdac_bus_queue_event()
160 bus->unsol_queue[wp + 1] = res_ex; in snd_hdac_bus_queue_event()
162 schedule_work(&bus->unsol_work); in snd_hdac_bus_queue_event()
170 struct hdac_bus *bus = container_of(work, struct hdac_bus, unsol_work); in snd_hdac_bus_process_unsol_events() local
175 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
176 while (bus->unsol_rp != bus->unsol_wp) { in snd_hdac_bus_process_unsol_events()
177 rp = (bus->unsol_rp + 1) % HDA_UNSOL_QUEUE_SIZE; in snd_hdac_bus_process_unsol_events()
178 bus->unsol_rp = rp; in snd_hdac_bus_process_unsol_events()
180 res = bus->unsol_queue[rp]; in snd_hdac_bus_process_unsol_events()
181 caddr = bus->unsol_queue[rp + 1]; in snd_hdac_bus_process_unsol_events()
184 codec = bus->caddr_tbl[caddr & 0x0f]; in snd_hdac_bus_process_unsol_events()
187 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
191 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
193 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
197 * snd_hdac_bus_add_device - Add a codec to bus
198 * @bus: HDA core bus
201 * Adds the given codec to the list in the bus. The caddr_tbl array
205 int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec) in snd_hdac_bus_add_device() argument
207 if (bus->caddr_tbl[codec->addr]) { in snd_hdac_bus_add_device()
208 dev_err(bus->dev, "address 0x%x is already occupied\n", in snd_hdac_bus_add_device()
213 list_add_tail(&codec->list, &bus->codec_list); in snd_hdac_bus_add_device()
214 bus->caddr_tbl[codec->addr] = codec; in snd_hdac_bus_add_device()
215 set_bit(codec->addr, &bus->codec_powered); in snd_hdac_bus_add_device()
216 bus->num_codecs++; in snd_hdac_bus_add_device()
221 * snd_hdac_bus_remove_device - Remove a codec from bus
222 * @bus: HDA core bus
225 void snd_hdac_bus_remove_device(struct hdac_bus *bus, in snd_hdac_bus_remove_device() argument
228 WARN_ON(bus != codec->bus); in snd_hdac_bus_remove_device()
232 bus->caddr_tbl[codec->addr] = NULL; in snd_hdac_bus_remove_device()
233 clear_bit(codec->addr, &bus->codec_powered); in snd_hdac_bus_remove_device()
234 bus->num_codecs--; in snd_hdac_bus_remove_device()
235 flush_work(&bus->unsol_work); in snd_hdac_bus_remove_device()