Lines Matching full:bus
3 * HD-audio core bus driver
24 * snd_hdac_bus_init - initialize a HD-audio bas bus
25 * @bus: the pointer to bus object
27 * @ops: bus verb operators
31 int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, in snd_hdac_bus_init() argument
34 memset(bus, 0, sizeof(*bus)); in snd_hdac_bus_init()
35 bus->dev = dev; in snd_hdac_bus_init()
37 bus->ops = ops; in snd_hdac_bus_init()
39 bus->ops = &default_ops; in snd_hdac_bus_init()
40 bus->dma_type = SNDRV_DMA_TYPE_DEV; in snd_hdac_bus_init()
41 INIT_LIST_HEAD(&bus->stream_list); in snd_hdac_bus_init()
42 INIT_LIST_HEAD(&bus->codec_list); in snd_hdac_bus_init()
43 INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events); in snd_hdac_bus_init()
44 spin_lock_init(&bus->reg_lock); in snd_hdac_bus_init()
45 mutex_init(&bus->cmd_mutex); in snd_hdac_bus_init()
46 mutex_init(&bus->lock); in snd_hdac_bus_init()
47 INIT_LIST_HEAD(&bus->hlink_list); in snd_hdac_bus_init()
48 init_waitqueue_head(&bus->rirb_wq); in snd_hdac_bus_init()
49 bus->irq = -1; in snd_hdac_bus_init()
60 bus->sdo_limit = 8; in snd_hdac_bus_init()
67 * snd_hdac_bus_exit - clean up a HD-audio bas bus
68 * @bus: the pointer to bus object
70 void snd_hdac_bus_exit(struct hdac_bus *bus) in snd_hdac_bus_exit() argument
72 WARN_ON(!list_empty(&bus->stream_list)); in snd_hdac_bus_exit()
73 WARN_ON(!list_empty(&bus->codec_list)); in snd_hdac_bus_exit()
74 cancel_work_sync(&bus->unsol_work); in snd_hdac_bus_exit()
79 * snd_hdac_bus_exec_verb - execute a HD-audio verb on the given bus
80 * @bus: bus object
87 int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr, in snd_hdac_bus_exec_verb() argument
92 mutex_lock(&bus->cmd_mutex); in snd_hdac_bus_exec_verb()
93 err = snd_hdac_bus_exec_verb_unlocked(bus, addr, cmd, res); in snd_hdac_bus_exec_verb()
94 mutex_unlock(&bus->cmd_mutex); in snd_hdac_bus_exec_verb()
100 * @bus: bus object
107 int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr, in snd_hdac_bus_exec_verb_unlocked() argument
118 else if (bus->sync_write) in snd_hdac_bus_exec_verb_unlocked()
121 trace_hda_send_cmd(bus, cmd); in snd_hdac_bus_exec_verb_unlocked()
122 err = bus->ops->command(bus, cmd); in snd_hdac_bus_exec_verb_unlocked()
126 err = bus->ops->get_response(bus, addr, &tmp); in snd_hdac_bus_exec_verb_unlocked()
131 err = bus->ops->get_response(bus, addr, res); in snd_hdac_bus_exec_verb_unlocked()
132 trace_hda_get_response(bus, addr, *res); in snd_hdac_bus_exec_verb_unlocked()
140 * @bus: the BUS
148 void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex) in snd_hdac_bus_queue_event() argument
152 if (!bus) in snd_hdac_bus_queue_event()
155 trace_hda_unsol_event(bus, res, res_ex); in snd_hdac_bus_queue_event()
156 wp = (bus->unsol_wp + 1) % HDA_UNSOL_QUEUE_SIZE; in snd_hdac_bus_queue_event()
157 bus->unsol_wp = wp; in snd_hdac_bus_queue_event()
160 bus->unsol_queue[wp] = res; in snd_hdac_bus_queue_event()
161 bus->unsol_queue[wp + 1] = res_ex; in snd_hdac_bus_queue_event()
163 schedule_work(&bus->unsol_work); in snd_hdac_bus_queue_event()
171 struct hdac_bus *bus = container_of(work, struct hdac_bus, unsol_work); in snd_hdac_bus_process_unsol_events() local
176 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
177 while (bus->unsol_rp != bus->unsol_wp) { in snd_hdac_bus_process_unsol_events()
178 rp = (bus->unsol_rp + 1) % HDA_UNSOL_QUEUE_SIZE; in snd_hdac_bus_process_unsol_events()
179 bus->unsol_rp = rp; in snd_hdac_bus_process_unsol_events()
181 res = bus->unsol_queue[rp]; in snd_hdac_bus_process_unsol_events()
182 caddr = bus->unsol_queue[rp + 1]; in snd_hdac_bus_process_unsol_events()
185 codec = bus->caddr_tbl[caddr & 0x0f]; in snd_hdac_bus_process_unsol_events()
188 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
192 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
194 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
198 * snd_hdac_bus_add_device - Add a codec to bus
199 * @bus: HDA core bus
202 * Adds the given codec to the list in the bus. The caddr_tbl array
206 int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec) in snd_hdac_bus_add_device() argument
208 if (bus->caddr_tbl[codec->addr]) { in snd_hdac_bus_add_device()
209 dev_err(bus->dev, "address 0x%x is already occupied\n", in snd_hdac_bus_add_device()
214 list_add_tail(&codec->list, &bus->codec_list); in snd_hdac_bus_add_device()
215 bus->caddr_tbl[codec->addr] = codec; in snd_hdac_bus_add_device()
216 set_bit(codec->addr, &bus->codec_powered); in snd_hdac_bus_add_device()
217 bus->num_codecs++; in snd_hdac_bus_add_device()
222 * snd_hdac_bus_remove_device - Remove a codec from bus
223 * @bus: HDA core bus
226 void snd_hdac_bus_remove_device(struct hdac_bus *bus, in snd_hdac_bus_remove_device() argument
229 WARN_ON(bus != codec->bus); in snd_hdac_bus_remove_device()
233 bus->caddr_tbl[codec->addr] = NULL; in snd_hdac_bus_remove_device()
234 clear_bit(codec->addr, &bus->codec_powered); in snd_hdac_bus_remove_device()
235 bus->num_codecs--; in snd_hdac_bus_remove_device()
236 flush_work(&bus->unsol_work); in snd_hdac_bus_remove_device()
271 struct hdac_bus *bus = codec->bus; in snd_hdac_codec_link_up() local
273 if (bus->ops->link_power) in snd_hdac_codec_link_up()
274 bus->ops->link_power(codec, true); in snd_hdac_codec_link_up()
282 struct hdac_bus *bus = codec->bus; in snd_hdac_codec_link_down() local
284 if (bus->ops->link_power) in snd_hdac_codec_link_down()
285 bus->ops->link_power(codec, false); in snd_hdac_codec_link_down()