/* * HD-audio core bus driver */ #include #include #include #include #include #include "trace.h" static void process_unsol_events(struct work_struct *work); static const struct hdac_bus_ops default_ops = { .command = snd_hdac_bus_send_cmd, .get_response = snd_hdac_bus_get_response, }; /** * snd_hdac_bus_init - initialize a HD-audio bas bus * @bus: the pointer to bus object * @ops: bus verb operators * @io_ops: lowlevel I/O operators * * Returns 0 if successful, or a negative error code. */ int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, const struct hdac_bus_ops *ops, const struct hdac_io_ops *io_ops) { memset(bus, 0, sizeof(*bus)); bus->dev = dev; if (ops) bus->ops = ops; else bus->ops = &default_ops; bus->io_ops = io_ops; INIT_LIST_HEAD(&bus->stream_list); INIT_LIST_HEAD(&bus->codec_list); INIT_WORK(&bus->unsol_work, process_unsol_events); spin_lock_init(&bus->reg_lock); mutex_init(&bus->cmd_mutex); bus->irq = -1; 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 * @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, unsigned int addr, unsigned int cmd, unsigned int *res) { int err; mutex_lock(&bus->cmd_mutex); err = snd_hdac_bus_exec_verb_unlocked(bus, addr, cmd, res); mutex_unlock(&bus->cmd_mutex); return err; } EXPORT_SYMBOL_GPL(snd_hdac_bus_exec_verb); /** * snd_hdac_bus_exec_verb_unlocked - unlocked version * @bus: bus object * @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, unsigned int addr, unsigned int cmd, unsigned int *res) { unsigned int tmp; int err; if (cmd == ~0) return -EINVAL; if (res) *res = -1; else if (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) { unsigned int wp; if (!bus) return; trace_hda_unsol_event(bus, res, res_ex); wp = (bus->unsol_wp + 1) % HDA_UNSOL_QUEUE_SIZE; bus->unsol_wp = wp; wp <<= 1; bus->unsol_queue[wp] = res; bus->unsol_queue[wp + 1] = res_ex; schedule_work(&bus->unsol_work); } EXPORT_SYMBOL_GPL(snd_hdac_bus_queue_event); /* * process queued unsolicited events */ static void process_unsol_events(struct work_struct *work) { struct hdac_bus *bus = container_of(work, struct hdac_bus, unsol_work); struct hdac_device *codec; struct hdac_driver *drv; unsigned int rp, caddr, res; 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->dev.driver) continue; drv = drv_to_hdac_driver(codec->dev.driver); if (drv->unsol_event) drv->unsol_event(codec, res); } } /** * 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; } list_add_tail(&codec->list, &bus->codec_list); bus->caddr_tbl[codec->addr] = codec; set_bit(codec->addr, &bus->codec_powered); bus->num_codecs++; return 0; } EXPORT_SYMBOL_GPL(snd_hdac_bus_add_device); /** * snd_hdac_bus_remove_device - Remove a codec from bus * @bus: HDA core bus * @codec: HDA core device to remove */ void snd_hdac_bus_remove_device(struct hdac_bus *bus, struct hdac_device *codec) { WARN_ON(bus != codec->bus); if (list_empty(&codec->list)) return; list_del_init(&codec->list); bus->caddr_tbl[codec->addr] = NULL; clear_bit(codec->addr, &bus->codec_powered); bus->num_codecs--; } EXPORT_SYMBOL_GPL(snd_hdac_bus_remove_device); 1692e9b62756323c675a44cb1a1f9dbd (patch) treed514a2d8512fc52c15747841e2368f8f99a50787 /sound/soc/codecs/ak4641.c parent3365135d43f861003555c963b309672d053a2228 (diff)parent950eabbd6ddedc1b08350b9169a6a51b130ebaaf (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) GTP fixes from Andreas Schultz (missing genl module alias, clear IP DF on transmit). 2) Netfilter needs to reflect the fwmark when sending resets, from Pau Espin Pedrol. 3) nftable dump OOPS fix from Liping Zhang. 4) Fix erroneous setting of VIRTIO_NET_HDR_F_DATA_VALID on transmit, from Rolf Neugebauer. 5) Fix build error of ipt_CLUSTERIP when procfs is disabled, from Arnd Bergmann. 6) Fix regression in handling of NETIF_F_SG in harmonize_features(), from Eric Dumazet. 7) Fix RTNL deadlock wrt. lwtunnel module loading, from David Ahern. 8) tcp_fastopen_create_child() needs to setup tp->max_window, from Alexey Kodanev. 9) Missing kmemdup() failure check in ipv6 segment routing code, from Eric Dumazet. 10) Don't execute unix_bind() under the bindlock, otherwise we deadlock with splice. From WANG Cong. 11) ip6_tnl_parse_tlv_enc_lim() potentially reallocates the skb buffer, therefore callers must reload cached header pointers into that skb. Fix from Eric Dumazet. 12) Fix various bugs in legacy IRQ fallback handling in alx driver, from Tobias Regnery. 13) Do not allow lwtunnel drivers to be unloaded while they are referenced by active instances, from Robert Shearman. 14) Fix truncated PHY LED trigger names, from Geert Uytterhoeven. 15) Fix a few regressions from virtio_net XDP support, from John Fastabend and Jakub Kicinski. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (102 commits) ISDN: eicon: silence misleading array-bounds warning net: phy: micrel: add support for KSZ8795 gtp: fix cross netns recv on gtp socket gtp: clear DF bit on GTP packet tx gtp: add genl family modules alias tcp: don't annotate mark on control socket from tcp_v6_send_response() ravb: unmap descriptors when freeing rings virtio_net: reject XDP programs using header adjustment virtio_net: use dev_kfree_skb for small buffer XDP receive r8152: check rx after napi is enabled r8152: re-schedule napi for tx r8152: avoid start_xmit to schedule napi when napi is disabled r8152: avoid start_xmit to call napi_schedule during autosuspend net: dsa: Bring back device detaching in dsa_slave_suspend() net: phy: leds: Fix truncated LED trigger names net: phy: leds: Break dependency of phy.h on phy_led_triggers.h net: phy: leds: Clear phy_num_led_triggers on failure to avoid crash net-next: ethernet: mediatek: change the compatible string Documentation: devicetree: change the mediatek ethernet compatible string bnxt_en: Fix RTNL lock usage on bnxt_get_port_module_status(). ...
Diffstat (limited to 'sound/soc/codecs/ak4641.c')