Lines Matching +full:enable +full:- +full:extended +full:- +full:delay

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
12 #include <linux/delay.h>
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
27 void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *bus, bool enable) in snd_hdac_ext_bus_ppcap_enable() argument
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()
35 if (enable) 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
47 * @enable: flag to enable/disable interrupt
49 void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *bus, bool enable) in snd_hdac_ext_bus_ppcap_int_enable() argument
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()
57 if (enable) 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
76 * in hlink_list of extended hdac bus
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_ext_link_free_all- free hdac extended link objects
120 while (!list_empty(&bus->hlink_list)) { in snd_hdac_ext_link_free_all()
121 hlink = list_first_entry(&bus->hlink_list, struct hdac_ext_link, list); in snd_hdac_ext_link_free_all()
122 list_del(&hlink->list); in snd_hdac_ext_link_free_all()
129 * snd_hdac_ext_bus_get_hlink_by_addr - get hlink at specified address
139 list_for_each_entry(hlink, &bus->hlink_list, list) in snd_hdac_ext_bus_get_hlink_by_addr()
140 if (hlink->lsdiid & (0x1 << addr)) in snd_hdac_ext_bus_get_hlink_by_addr()
147 * snd_hdac_ext_bus_get_hlink_by_name - get hlink based on codec name
158 if (bus->idx != bus_idx) in snd_hdac_ext_bus_get_hlink_by_name()
167 static int check_hdac_link_power_active(struct hdac_ext_link *hlink, bool enable) in check_hdac_link_power_active() argument
177 val = readl(hlink->ml_addr + AZX_REG_ML_LCTL); in check_hdac_link_power_active()
178 if (enable) { in check_hdac_link_power_active()
186 } while (--timeout); in check_hdac_link_power_active()
188 return -EIO; in check_hdac_link_power_active()
192 * snd_hdac_ext_bus_link_power_up -power up hda link
193 * @hlink: HD-audio extended link
197 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, in snd_hdac_ext_bus_link_power_up()
205 * snd_hdac_ext_bus_link_power_down -power down hda link
206 * @hlink: HD-audio extended link
210 snd_hdac_updatel(hlink->ml_addr, AZX_REG_ML_LCTL, AZX_ML_LCTL_SPA, 0); in snd_hdac_ext_bus_link_power_down()
217 * snd_hdac_ext_bus_link_power_up_all -power up all hda link
225 list_for_each_entry(hlink, &bus->hlink_list, list) { in snd_hdac_ext_bus_link_power_up_all()
236 * snd_hdac_ext_bus_link_power_down_all -power down all hda link
244 list_for_each_entry(hlink, &bus->hlink_list, list) { in snd_hdac_ext_bus_link_power_down_all()
255 * snd_hdac_ext_bus_link_set_stream_id - maps stream id to link output
256 * @link: HD-audio ext link to set up
262 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 1 << stream); in snd_hdac_ext_bus_link_set_stream_id()
267 * snd_hdac_ext_bus_link_clear_stream_id - maps stream id to link output
268 * @link: HD-audio ext link to set up
274 snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 0); in snd_hdac_ext_bus_link_clear_stream_id()
284 mutex_lock(&bus->lock); in snd_hdac_ext_bus_link_get()
290 if (++hlink->ref_count == 1) { in snd_hdac_ext_bus_link_get()
291 if (!bus->cmd_dma_state) { in snd_hdac_ext_bus_link_get()
293 bus->cmd_dma_state = true; in snd_hdac_ext_bus_link_get()
301 snd_hdac_updatew(hlink->ml_addr, AZX_REG_ML_LOSIDV, in snd_hdac_ext_bus_link_get()
305 * HDA spec section 4.3 - Codec Discovery in snd_hdac_ext_bus_link_get()
309 dev_dbg(bus->dev, "codec_mask = 0x%lx\n", codec_mask); in snd_hdac_ext_bus_link_get()
311 if (!bus->codec_mask) in snd_hdac_ext_bus_link_get()
312 bus->codec_mask = codec_mask; in snd_hdac_ext_bus_link_get()
315 mutex_unlock(&bus->lock); in snd_hdac_ext_bus_link_get()
327 mutex_lock(&bus->lock); in snd_hdac_ext_bus_link_put()
333 if (--hlink->ref_count == 0) { in snd_hdac_ext_bus_link_put()
340 list_for_each_entry(hlink_tmp, &bus->hlink_list, list) { in snd_hdac_ext_bus_link_put()
341 if (hlink_tmp->ref_count) { in snd_hdac_ext_bus_link_put()
349 bus->cmd_dma_state = false; in snd_hdac_ext_bus_link_put()
353 mutex_unlock(&bus->lock); in snd_hdac_ext_bus_link_put()
360 const char *devname = dev_name(&codec->dev); in hdac_ext_codec_link_up()
362 snd_hdac_ext_bus_get_hlink_by_name(codec->bus, devname); in hdac_ext_codec_link_up()
365 snd_hdac_ext_bus_link_get(codec->bus, hlink); in hdac_ext_codec_link_up()
370 const char *devname = dev_name(&codec->dev); in hdac_ext_codec_link_down()
372 snd_hdac_ext_bus_get_hlink_by_name(codec->bus, devname); in hdac_ext_codec_link_down()
375 snd_hdac_ext_bus_link_put(codec->bus, hlink); in hdac_ext_codec_link_down()
378 void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable) in snd_hdac_ext_bus_link_power() argument
380 struct hdac_bus *bus = codec->bus; in snd_hdac_ext_bus_link_power()
381 bool oldstate = test_bit(codec->addr, &bus->codec_powered); in snd_hdac_ext_bus_link_power()
383 if (enable == oldstate) in snd_hdac_ext_bus_link_power()
386 snd_hdac_bus_link_power(codec, enable); in snd_hdac_ext_bus_link_power()
388 if (enable) in snd_hdac_ext_bus_link_power()