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
25 * @ops: bus verb operators
29 int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, in snd_hdac_bus_init() argument
32 memset(bus, 0, sizeof(*bus)); in snd_hdac_bus_init()
33 bus->dev = dev; in snd_hdac_bus_init()
35 bus->ops = ops; in snd_hdac_bus_init()
37 bus->ops = &default_ops; in snd_hdac_bus_init()
38 bus->dma_type = SNDRV_DMA_TYPE_DEV; in snd_hdac_bus_init()
39 INIT_LIST_HEAD(&bus->stream_list); in snd_hdac_bus_init()
40 INIT_LIST_HEAD(&bus->codec_list); in snd_hdac_bus_init()
41 INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events); in snd_hdac_bus_init()
42 spin_lock_init(&bus->reg_lock); in snd_hdac_bus_init()
43 mutex_init(&bus->cmd_mutex); in snd_hdac_bus_init()
44 mutex_init(&bus->lock); in snd_hdac_bus_init()
45 INIT_LIST_HEAD(&bus->hlink_list); in snd_hdac_bus_init()
46 bus->irq = -1; in snd_hdac_bus_init()
52 * snd_hdac_bus_exit - clean up a HD-audio bas bus
53 * @bus: the pointer to bus object
55 void snd_hdac_bus_exit(struct hdac_bus *bus) in snd_hdac_bus_exit() argument
57 WARN_ON(!list_empty(&bus->stream_list)); in snd_hdac_bus_exit()
58 WARN_ON(!list_empty(&bus->codec_list)); in snd_hdac_bus_exit()
59 cancel_work_sync(&bus->unsol_work); in snd_hdac_bus_exit()
64 * snd_hdac_bus_exec_verb - execute a HD-audio verb on the given bus
65 * @bus: bus object
71 int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr, in snd_hdac_bus_exec_verb() argument
76 mutex_lock(&bus->cmd_mutex); in snd_hdac_bus_exec_verb()
77 err = snd_hdac_bus_exec_verb_unlocked(bus, addr, cmd, res); in snd_hdac_bus_exec_verb()
78 mutex_unlock(&bus->cmd_mutex); in snd_hdac_bus_exec_verb()
85 * @bus: bus object
91 int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr, in snd_hdac_bus_exec_verb_unlocked() argument
102 else if (bus->sync_write) in snd_hdac_bus_exec_verb_unlocked()
105 trace_hda_send_cmd(bus, cmd); in snd_hdac_bus_exec_verb_unlocked()
106 err = bus->ops->command(bus, cmd); in snd_hdac_bus_exec_verb_unlocked()
110 err = bus->ops->get_response(bus, addr, &tmp); in snd_hdac_bus_exec_verb_unlocked()
115 err = bus->ops->get_response(bus, addr, res); in snd_hdac_bus_exec_verb_unlocked()
116 trace_hda_get_response(bus, addr, *res); in snd_hdac_bus_exec_verb_unlocked()
124 * @bus: the BUS
132 void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex) in snd_hdac_bus_queue_event() argument
136 if (!bus) in snd_hdac_bus_queue_event()
139 trace_hda_unsol_event(bus, res, res_ex); in snd_hdac_bus_queue_event()
140 wp = (bus->unsol_wp + 1) % HDA_UNSOL_QUEUE_SIZE; in snd_hdac_bus_queue_event()
141 bus->unsol_wp = wp; in snd_hdac_bus_queue_event()
144 bus->unsol_queue[wp] = res; in snd_hdac_bus_queue_event()
145 bus->unsol_queue[wp + 1] = res_ex; in snd_hdac_bus_queue_event()
147 schedule_work(&bus->unsol_work); in snd_hdac_bus_queue_event()
156 struct hdac_bus *bus = container_of(work, struct hdac_bus, unsol_work); in snd_hdac_bus_process_unsol_events() local
161 while (bus->unsol_rp != bus->unsol_wp) { in snd_hdac_bus_process_unsol_events()
162 rp = (bus->unsol_rp + 1) % HDA_UNSOL_QUEUE_SIZE; in snd_hdac_bus_process_unsol_events()
163 bus->unsol_rp = rp; in snd_hdac_bus_process_unsol_events()
165 res = bus->unsol_queue[rp]; in snd_hdac_bus_process_unsol_events()
166 caddr = bus->unsol_queue[rp + 1]; in snd_hdac_bus_process_unsol_events()
169 codec = bus->caddr_tbl[caddr & 0x0f]; in snd_hdac_bus_process_unsol_events()
179 * snd_hdac_bus_add_device - Add a codec to bus
180 * @bus: HDA core bus
183 * Adds the given codec to the list in the bus. The caddr_tbl array
187 int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec) in snd_hdac_bus_add_device() argument
189 if (bus->caddr_tbl[codec->addr]) { in snd_hdac_bus_add_device()
190 dev_err(bus->dev, "address 0x%x is already occupied\n", in snd_hdac_bus_add_device()
195 list_add_tail(&codec->list, &bus->codec_list); in snd_hdac_bus_add_device()
196 bus->caddr_tbl[codec->addr] = codec; in snd_hdac_bus_add_device()
197 set_bit(codec->addr, &bus->codec_powered); in snd_hdac_bus_add_device()
198 bus->num_codecs++; in snd_hdac_bus_add_device()
203 * snd_hdac_bus_remove_device - Remove a codec from bus
204 * @bus: HDA core bus
207 void snd_hdac_bus_remove_device(struct hdac_bus *bus, in snd_hdac_bus_remove_device() argument
210 WARN_ON(bus != codec->bus); in snd_hdac_bus_remove_device()
214 bus->caddr_tbl[codec->addr] = NULL; in snd_hdac_bus_remove_device()
215 clear_bit(codec->addr, &bus->codec_powered); in snd_hdac_bus_remove_device()
216 bus->num_codecs--; in snd_hdac_bus_remove_device()
217 flush_work(&bus->unsol_work); in snd_hdac_bus_remove_device()