Lines Matching +full:off +full:- +full:codec

1 // SPDX-License-Identifier: GPL-2.0-only
3 * hdac-ext-controller.c - HD-audio extended controller functions.
5 * Copyright (C) 2014-2015 Intel Corp
18 * processing pipe helpers - these helpers are useful for dealing with HDA
23 * snd_hdac_ext_bus_ppcap_enable - enable/disable processing pipe capability
25 * @enable: flag to turn on/off the capability
30 if (!bus->ppcap) { in snd_hdac_ext_bus_ppcap_enable()
31 dev_err(bus->dev, "Address of PP capability is NULL"); in snd_hdac_ext_bus_ppcap_enable()
36 snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, in snd_hdac_ext_bus_ppcap_enable()
39 snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, in snd_hdac_ext_bus_ppcap_enable()
45 * snd_hdac_ext_bus_ppcap_int_enable - ppcap interrupt enable/disable
52 if (!bus->ppcap) { in snd_hdac_ext_bus_ppcap_int_enable()
53 dev_err(bus->dev, "Address of PP capability is NULL\n"); in snd_hdac_ext_bus_ppcap_int_enable()
58 snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, in snd_hdac_ext_bus_ppcap_int_enable()
61 snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, in snd_hdac_ext_bus_ppcap_int_enable()
67 * Multilink helpers - these helpers are useful for dealing with HDA
72 * snd_hdac_ext_bus_get_ml_capabilities - get multilink capability
85 link_count = readl(bus->mlcap + AZX_REG_ML_MLCD) + 1; in snd_hdac_ext_bus_get_ml_capabilities()
87 dev_dbg(bus->dev, "In %s Link count: %d\n", __func__, link_count); in snd_hdac_ext_bus_get_ml_capabilities()
92 return -ENOMEM; in snd_hdac_ext_bus_get_ml_capabilities()
93 hlink->index = idx; in snd_hdac_ext_bus_get_ml_capabilities()
94 hlink->bus = bus; in snd_hdac_ext_bus_get_ml_capabilities()
95 hlink->ml_addr = bus->mlcap + AZX_ML_BASE + in snd_hdac_ext_bus_get_ml_capabilities()
97 hlink->lcaps = readl(hlink->ml_addr + AZX_REG_ML_LCAP); in snd_hdac_ext_bus_get_ml_capabilities()
98 hlink->lsdiid = readw(hlink->ml_addr + AZX_REG_ML_LSDIID); in snd_hdac_ext_bus_get_ml_capabilities()
101 hlink->ref_count = 1; in snd_hdac_ext_bus_get_ml_capabilities()
103 list_add_tail(&hlink->list, &bus->hlink_list); in snd_hdac_ext_bus_get_ml_capabilities()
111 * snd_hdac_link_free_all- free hdac extended link objects
120 while (!list_empty(&bus->hlink_list)) { in snd_hdac_link_free_all()
121 l = list_first_entry(&bus->hlink_list, struct hdac_ext_link, list); in snd_hdac_link_free_all()
122 list_del(&l->list); in snd_hdac_link_free_all()
129 * snd_hdac_ext_bus_link_at - get link at specified address
131 * @addr: codec device address
140 list_for_each_entry(hlink, &bus->hlink_list, list) in snd_hdac_ext_bus_link_at()
142 if (hlink->lsdiid & (0x1 << addr)) in snd_hdac_ext_bus_link_at()
149 * snd_hdac_ext_bus_get_link - get link based on codec name
151 * @codec_name: codec name
160 if (bus->idx != bus_idx) in snd_hdac_ext_bus_get_link()
179 val = readl(link->ml_addr + AZX_REG_ML_LCTL); in check_hdac_link_power_active()
188 } while (--timeout); in check_hdac_link_power_active()
190 return -EIO; in check_hdac_link_power_active()
194 * snd_hdac_ext_bus_link_power_up -power up hda link
195 * @link: HD-audio extended link
199 snd_hdac_updatel(link->ml_addr, AZX_REG_ML_LCTL, in snd_hdac_ext_bus_link_power_up()
207 * snd_hdac_ext_bus_link_power_down -power down hda link
208 * @link: HD-audio extended link
212 snd_hdac_updatel(link->ml_addr, AZX_REG_ML_LCTL, AZX_ML_LCTL_SPA, 0); in snd_hdac_ext_bus_link_power_down()
219 * snd_hdac_ext_bus_link_power_up_all -power up all hda link
227 list_for_each_entry(hlink, &bus->hlink_list, list) { in snd_hdac_ext_bus_link_power_up_all()
228 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, in snd_hdac_ext_bus_link_power_up_all()
240 * snd_hdac_ext_bus_link_power_down_all -power down all hda link
248 list_for_each_entry(hlink, &bus->hlink_list, list) { in snd_hdac_ext_bus_link_power_down_all()
249 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, in snd_hdac_ext_bus_link_power_down_all()
266 mutex_lock(&bus->lock); in snd_hdac_ext_bus_link_get()
272 if (++link->ref_count == 1) { in snd_hdac_ext_bus_link_get()
273 if (!bus->cmd_dma_state) { in snd_hdac_ext_bus_link_get()
275 bus->cmd_dma_state = true; in snd_hdac_ext_bus_link_get()
283 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, in snd_hdac_ext_bus_link_get()
286 * wait for 521usec for codec to report status in snd_hdac_ext_bus_link_get()
287 * HDA spec section 4.3 - Codec Discovery in snd_hdac_ext_bus_link_get()
291 dev_dbg(bus->dev, "codec_mask = 0x%lx\n", codec_mask); in snd_hdac_ext_bus_link_get()
293 if (!bus->codec_mask) in snd_hdac_ext_bus_link_get()
294 bus->codec_mask = codec_mask; in snd_hdac_ext_bus_link_get()
297 mutex_unlock(&bus->lock); in snd_hdac_ext_bus_link_get()
309 mutex_lock(&bus->lock); in snd_hdac_ext_bus_link_put()
315 if (--link->ref_count == 0) { in snd_hdac_ext_bus_link_put()
319 * now check if all links are off, if so turn off in snd_hdac_ext_bus_link_put()
322 list_for_each_entry(hlink, &bus->hlink_list, list) { in snd_hdac_ext_bus_link_put()
323 if (hlink->ref_count) { in snd_hdac_ext_bus_link_put()
331 bus->cmd_dma_state = false; in snd_hdac_ext_bus_link_put()
335 mutex_unlock(&bus->lock); in snd_hdac_ext_bus_link_put()
340 static void hdac_ext_codec_link_up(struct hdac_device *codec) in hdac_ext_codec_link_up() argument
342 const char *devname = dev_name(&codec->dev); in hdac_ext_codec_link_up()
344 snd_hdac_ext_bus_get_link(codec->bus, devname); in hdac_ext_codec_link_up()
347 snd_hdac_ext_bus_link_get(codec->bus, hlink); in hdac_ext_codec_link_up()
350 static void hdac_ext_codec_link_down(struct hdac_device *codec) in hdac_ext_codec_link_down() argument
352 const char *devname = dev_name(&codec->dev); in hdac_ext_codec_link_down()
354 snd_hdac_ext_bus_get_link(codec->bus, devname); in hdac_ext_codec_link_down()
357 snd_hdac_ext_bus_link_put(codec->bus, hlink); in hdac_ext_codec_link_down()
360 void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable) in snd_hdac_ext_bus_link_power() argument
362 struct hdac_bus *bus = codec->bus; in snd_hdac_ext_bus_link_power()
363 bool oldstate = test_bit(codec->addr, &bus->codec_powered); in snd_hdac_ext_bus_link_power()
368 snd_hdac_bus_link_power(codec, enable); in snd_hdac_ext_bus_link_power()
371 hdac_ext_codec_link_up(codec); in snd_hdac_ext_bus_link_power()
373 hdac_ext_codec_link_down(codec); in snd_hdac_ext_bus_link_power()