Lines Matching +full:audio +full:- +full:core
1 // SPDX-License-Identifier: GPL-2.0-only
3 * HD-audio core bus driver
23 * snd_hdac_bus_init - initialize a HD-audio bas bus
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()
51 * Default value of '8' is as per the HD audio specification (Rev 1.0a). 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
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
81 * @cmd: HD-audio encoded verb
91 mutex_lock(&bus->cmd_mutex); in snd_hdac_bus_exec_verb()
93 mutex_unlock(&bus->cmd_mutex); in snd_hdac_bus_exec_verb()
98 * snd_hdac_bus_exec_verb_unlocked - unlocked version
101 * @cmd: HD-audio encoded verb
113 return -EINVAL; in snd_hdac_bus_exec_verb_unlocked()
116 *res = -1; in snd_hdac_bus_exec_verb_unlocked()
117 else if (bus->sync_write) in snd_hdac_bus_exec_verb_unlocked()
121 err = bus->ops->command(bus, cmd); in snd_hdac_bus_exec_verb_unlocked()
122 if (err != -EAGAIN) 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()
138 * snd_hdac_bus_queue_event - add an unsolicited event to queue
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()
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()
185 if (!codec || !codec->dev.driver) in snd_hdac_bus_process_unsol_events()
187 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_process_unsol_events()
188 drv = drv_to_hdac_driver(codec->dev.driver); in snd_hdac_bus_process_unsol_events()
189 if (drv->unsol_event) in snd_hdac_bus_process_unsol_events()
190 drv->unsol_event(codec, res); 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
199 * @codec: HDA core device to add
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()
209 codec->addr); in snd_hdac_bus_add_device()
210 return -EBUSY; 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
223 * @codec: HDA core device to remove
228 WARN_ON(bus != codec->bus); in snd_hdac_bus_remove_device()
229 if (list_empty(&codec->list)) in snd_hdac_bus_remove_device()
231 list_del_init(&codec->list); 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()