Thomas Gleixner | 8e8e69d | 2019-05-29 07:17:59 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 2 | /* |
| 3 | * hdac-ext-stream.c - HD-audio extended stream operations. |
| 4 | * |
| 5 | * Copyright (C) 2015 Intel Corp |
| 6 | * Author: Jeeja KP <jeeja.kp@intel.com> |
| 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 8 | * |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 9 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 | */ |
| 11 | |
| 12 | #include <linux/delay.h> |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 13 | #include <linux/slab.h> |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 14 | #include <sound/pcm.h> |
| 15 | #include <sound/hda_register.h> |
| 16 | #include <sound/hdaudio_ext.h> |
| 17 | |
| 18 | /** |
| 19 | * snd_hdac_ext_stream_init - initialize each stream (aka device) |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 20 | * @bus: HD-audio core bus |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 21 | * @hext_stream: HD-audio ext core stream object to initialize |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 22 | * @idx: stream index number |
| 23 | * @direction: stream direction (SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE) |
| 24 | * @tag: the tag id to assign |
| 25 | * |
| 26 | * initialize the stream, if ppcap is enabled then init those and then |
| 27 | * invoke hdac stream initialization routine |
| 28 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 29 | void snd_hdac_ext_stream_init(struct hdac_bus *bus, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 30 | struct hdac_ext_stream *hext_stream, |
| 31 | int idx, int direction, int tag) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 32 | { |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 33 | if (bus->ppcap) { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 34 | hext_stream->pphc_addr = bus->ppcap + AZX_PPHC_BASE + |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 35 | AZX_PPHC_INTERVAL * idx; |
| 36 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 37 | hext_stream->pplc_addr = bus->ppcap + AZX_PPLC_BASE + |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 38 | AZX_PPLC_MULTI * bus->num_streams + |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 39 | AZX_PPLC_INTERVAL * idx; |
| 40 | } |
| 41 | |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 42 | if (bus->spbcap) { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 43 | hext_stream->spib_addr = bus->spbcap + AZX_SPB_BASE + |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 44 | AZX_SPB_INTERVAL * idx + |
| 45 | AZX_SPB_SPIB; |
| 46 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 47 | hext_stream->fifo_addr = bus->spbcap + AZX_SPB_BASE + |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 48 | AZX_SPB_INTERVAL * idx + |
| 49 | AZX_SPB_MAXFIFO; |
| 50 | } |
| 51 | |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 52 | if (bus->drsmcap) |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 53 | hext_stream->dpibr_addr = bus->drsmcap + AZX_DRSM_BASE + |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 54 | AZX_DRSM_INTERVAL * idx; |
| 55 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 56 | hext_stream->decoupled = false; |
| 57 | snd_hdac_stream_init(bus, &hext_stream->hstream, idx, direction, tag); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 58 | } |
| 59 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init); |
| 60 | |
| 61 | /** |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 62 | * snd_hdac_ext_stream_init_all - create and initialize the stream objects |
| 63 | * for an extended hda bus |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 64 | * @bus: HD-audio core bus |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 65 | * @start_idx: start index for streams |
| 66 | * @num_stream: number of streams to initialize |
| 67 | * @dir: direction of streams |
| 68 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 69 | int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 70 | int num_stream, int dir) |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 71 | { |
| 72 | int stream_tag = 0; |
| 73 | int i, tag, idx = start_idx; |
| 74 | |
| 75 | for (i = 0; i < num_stream; i++) { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 76 | struct hdac_ext_stream *hext_stream = |
| 77 | kzalloc(sizeof(*hext_stream), GFP_KERNEL); |
| 78 | if (!hext_stream) |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 79 | return -ENOMEM; |
| 80 | tag = ++stream_tag; |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 81 | snd_hdac_ext_stream_init(bus, hext_stream, idx, dir, tag); |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 82 | idx++; |
| 83 | } |
| 84 | |
| 85 | return 0; |
| 86 | |
| 87 | } |
| 88 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_init_all); |
| 89 | |
| 90 | /** |
| 91 | * snd_hdac_stream_free_all - free hdac extended stream objects |
| 92 | * |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 93 | * @bus: HD-audio core bus |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 94 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 95 | void snd_hdac_stream_free_all(struct hdac_bus *bus) |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 96 | { |
Vinod Koul | 4a6c5e6 | 2016-03-15 16:39:23 +0530 | [diff] [blame] | 97 | struct hdac_stream *s, *_s; |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 98 | struct hdac_ext_stream *hext_stream; |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 99 | |
Vinod Koul | 4a6c5e6 | 2016-03-15 16:39:23 +0530 | [diff] [blame] | 100 | list_for_each_entry_safe(s, _s, &bus->stream_list, list) { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 101 | hext_stream = stream_to_hdac_ext_stream(s); |
| 102 | snd_hdac_ext_stream_decouple(bus, hext_stream, false); |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 103 | list_del(&s->list); |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 104 | kfree(hext_stream); |
Vinod Koul | e7a3484 | 2015-06-17 11:20:16 +0530 | [diff] [blame] | 105 | } |
| 106 | } |
| 107 | EXPORT_SYMBOL_GPL(snd_hdac_stream_free_all); |
| 108 | |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 109 | void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 110 | struct hdac_ext_stream *hext_stream, |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 111 | bool decouple) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 112 | { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 113 | struct hdac_stream *hstream = &hext_stream->hstream; |
Jeeja KP | 09a8bf8 | 2017-01-02 12:44:28 +0530 | [diff] [blame] | 114 | u32 val; |
| 115 | int mask = AZX_PPCTL_PROCEN(hstream->index); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 116 | |
Jeeja KP | 09a8bf8 | 2017-01-02 12:44:28 +0530 | [diff] [blame] | 117 | val = readw(bus->ppcap + AZX_REG_PP_PPCTL) & mask; |
| 118 | |
| 119 | if (decouple && !val) |
| 120 | snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, mask, mask); |
| 121 | else if (!decouple && val) |
| 122 | snd_hdac_updatel(bus->ppcap, AZX_REG_PP_PPCTL, mask, 0); |
| 123 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 124 | hext_stream->decoupled = decouple; |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 125 | } |
| 126 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple_locked); |
| 127 | |
| 128 | /** |
| 129 | * snd_hdac_ext_stream_decouple - decouple the hdac stream |
| 130 | * @bus: HD-audio core bus |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 131 | * @hext_stream: HD-audio ext core stream object to initialize |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 132 | * @decouple: flag to decouple |
| 133 | */ |
| 134 | void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 135 | struct hdac_ext_stream *hext_stream, bool decouple) |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 136 | { |
| 137 | spin_lock_irq(&bus->reg_lock); |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 138 | snd_hdac_ext_stream_decouple_locked(bus, hext_stream, decouple); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 139 | spin_unlock_irq(&bus->reg_lock); |
| 140 | } |
| 141 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple); |
| 142 | |
| 143 | /** |
Pierre-Louis Bossart | 3531ba2 | 2021-03-01 11:46:17 -0600 | [diff] [blame] | 144 | * snd_hdac_ext_link_stream_start - start a stream |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 145 | * @hext_stream: HD-audio ext core stream to start |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 146 | */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 147 | void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hext_stream) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 148 | { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 149 | snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, |
Keyon Jie | f7c50fa | 2018-09-03 10:47:09 +0800 | [diff] [blame] | 150 | AZX_PPLCCTL_RUN, AZX_PPLCCTL_RUN); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 151 | } |
| 152 | EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_start); |
| 153 | |
| 154 | /** |
| 155 | * snd_hdac_ext_link_stream_clear - stop a stream DMA |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 156 | * @hext_stream: HD-audio ext core stream to stop |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 157 | */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 158 | void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hext_stream) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 159 | { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 160 | snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, AZX_PPLCCTL_RUN, 0); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 161 | } |
| 162 | EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_clear); |
| 163 | |
| 164 | /** |
| 165 | * snd_hdac_ext_link_stream_reset - reset a stream |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 166 | * @hext_stream: HD-audio ext core stream to reset |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 167 | */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 168 | void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hext_stream) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 169 | { |
| 170 | unsigned char val; |
| 171 | int timeout; |
| 172 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 173 | snd_hdac_ext_link_stream_clear(hext_stream); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 174 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 175 | snd_hdac_updatel(hext_stream->pplc_addr, AZX_REG_PPLCCTL, |
Keyon Jie | f7c50fa | 2018-09-03 10:47:09 +0800 | [diff] [blame] | 176 | AZX_PPLCCTL_STRST, AZX_PPLCCTL_STRST); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 177 | udelay(3); |
| 178 | timeout = 50; |
| 179 | do { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 180 | val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL) & |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 181 | AZX_PPLCCTL_STRST; |
| 182 | if (val) |
| 183 | break; |
| 184 | udelay(3); |
| 185 | } while (--timeout); |
| 186 | val &= ~AZX_PPLCCTL_STRST; |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 187 | writel(val, hext_stream->pplc_addr + AZX_REG_PPLCCTL); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 188 | udelay(3); |
| 189 | |
| 190 | timeout = 50; |
| 191 | /* waiting for hardware to report that the stream is out of reset */ |
| 192 | do { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 193 | val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL) & AZX_PPLCCTL_STRST; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 194 | if (!val) |
| 195 | break; |
| 196 | udelay(3); |
| 197 | } while (--timeout); |
| 198 | |
| 199 | } |
| 200 | EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_reset); |
| 201 | |
| 202 | /** |
| 203 | * snd_hdac_ext_link_stream_setup - set up the SD for streaming |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 204 | * @hext_stream: HD-audio ext core stream to set up |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 205 | * @fmt: stream format |
| 206 | */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 207 | int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *hext_stream, int fmt) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 208 | { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 209 | struct hdac_stream *hstream = &hext_stream->hstream; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 210 | unsigned int val; |
| 211 | |
| 212 | /* make sure the run bit is zero for SD */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 213 | snd_hdac_ext_link_stream_clear(hext_stream); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 214 | /* program the stream_tag */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 215 | val = readl(hext_stream->pplc_addr + AZX_REG_PPLCCTL); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 216 | val = (val & ~AZX_PPLCCTL_STRM_MASK) | |
| 217 | (hstream->stream_tag << AZX_PPLCCTL_STRM_SHIFT); |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 218 | writel(val, hext_stream->pplc_addr + AZX_REG_PPLCCTL); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 219 | |
| 220 | /* program the stream format */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 221 | writew(fmt, hext_stream->pplc_addr + AZX_REG_PPLCFMT); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 222 | |
| 223 | return 0; |
| 224 | } |
| 225 | EXPORT_SYMBOL_GPL(snd_hdac_ext_link_stream_setup); |
| 226 | |
| 227 | /** |
| 228 | * snd_hdac_ext_link_set_stream_id - maps stream id to link output |
| 229 | * @link: HD-audio ext link to set up |
| 230 | * @stream: stream id |
| 231 | */ |
| 232 | void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 233 | int stream) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 234 | { |
Subhransu S. Prusty | 88b1996 | 2015-10-05 15:09:48 +0100 | [diff] [blame] | 235 | snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 1 << stream); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 236 | } |
| 237 | EXPORT_SYMBOL_GPL(snd_hdac_ext_link_set_stream_id); |
| 238 | |
| 239 | /** |
| 240 | * snd_hdac_ext_link_clear_stream_id - maps stream id to link output |
| 241 | * @link: HD-audio ext link to set up |
| 242 | * @stream: stream id |
| 243 | */ |
| 244 | void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link, |
| 245 | int stream) |
| 246 | { |
Keyon Jie | f7c50fa | 2018-09-03 10:47:09 +0800 | [diff] [blame] | 247 | snd_hdac_updatew(link->ml_addr, AZX_REG_ML_LOSIDV, (1 << stream), 0); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 248 | } |
| 249 | EXPORT_SYMBOL_GPL(snd_hdac_ext_link_clear_stream_id); |
| 250 | |
| 251 | static struct hdac_ext_stream * |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 252 | hdac_ext_link_stream_assign(struct hdac_bus *bus, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 253 | struct snd_pcm_substream *substream) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 254 | { |
| 255 | struct hdac_ext_stream *res = NULL; |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 256 | struct hdac_stream *hstream = NULL; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 257 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 258 | if (!bus->ppcap) { |
| 259 | dev_err(bus->dev, "stream type not supported\n"); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 260 | return NULL; |
| 261 | } |
| 262 | |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 263 | spin_lock_irq(&bus->reg_lock); |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 264 | list_for_each_entry(hstream, &bus->stream_list, list) { |
| 265 | struct hdac_ext_stream *hext_stream = container_of(hstream, |
| 266 | struct hdac_ext_stream, |
| 267 | hstream); |
| 268 | if (hstream->direction != substream->stream) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 269 | continue; |
| 270 | |
| 271 | /* check if decoupled stream and not in use is available */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 272 | if (hext_stream->decoupled && !hext_stream->link_locked) { |
| 273 | res = hext_stream; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 274 | break; |
| 275 | } |
| 276 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 277 | if (!hext_stream->link_locked) { |
| 278 | snd_hdac_ext_stream_decouple_locked(bus, hext_stream, true); |
| 279 | res = hext_stream; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 280 | break; |
| 281 | } |
| 282 | } |
| 283 | if (res) { |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 284 | res->link_locked = 1; |
| 285 | res->link_substream = substream; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 286 | } |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 287 | spin_unlock_irq(&bus->reg_lock); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 288 | return res; |
| 289 | } |
| 290 | |
| 291 | static struct hdac_ext_stream * |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 292 | hdac_ext_host_stream_assign(struct hdac_bus *bus, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 293 | struct snd_pcm_substream *substream) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 294 | { |
| 295 | struct hdac_ext_stream *res = NULL; |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 296 | struct hdac_stream *hstream = NULL; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 297 | |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 298 | if (!bus->ppcap) { |
| 299 | dev_err(bus->dev, "stream type not supported\n"); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 300 | return NULL; |
| 301 | } |
| 302 | |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 303 | spin_lock_irq(&bus->reg_lock); |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 304 | list_for_each_entry(hstream, &bus->stream_list, list) { |
| 305 | struct hdac_ext_stream *hext_stream = container_of(hstream, |
| 306 | struct hdac_ext_stream, |
| 307 | hstream); |
| 308 | if (hstream->direction != substream->stream) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 309 | continue; |
| 310 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 311 | if (!hstream->opened) { |
| 312 | if (!hext_stream->decoupled) |
| 313 | snd_hdac_ext_stream_decouple_locked(bus, hext_stream, true); |
| 314 | res = hext_stream; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 315 | break; |
| 316 | } |
| 317 | } |
| 318 | if (res) { |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 319 | res->hstream.opened = 1; |
| 320 | res->hstream.running = 0; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 321 | res->hstream.substream = substream; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 322 | } |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 323 | spin_unlock_irq(&bus->reg_lock); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 324 | |
| 325 | return res; |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * snd_hdac_ext_stream_assign - assign a stream for the PCM |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 330 | * @bus: HD-audio core bus |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 331 | * @substream: PCM substream to assign |
| 332 | * @type: type of stream (coupled, host or link stream) |
| 333 | * |
| 334 | * This assigns the stream based on the type (coupled/host/link), for the |
| 335 | * given PCM substream, assigns it and returns the stream object |
| 336 | * |
| 337 | * coupled: Looks for an unused stream |
| 338 | * host: Looks for an unused decoupled host stream |
| 339 | * link: Looks for an unused decoupled link stream |
| 340 | * |
| 341 | * If no stream is free, returns NULL. The function tries to keep using |
| 342 | * the same stream object when it's used beforehand. when a stream is |
| 343 | * decoupled, it becomes a host stream and link stream. |
| 344 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 345 | struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 346 | struct snd_pcm_substream *substream, |
| 347 | int type) |
| 348 | { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 349 | struct hdac_ext_stream *hext_stream = NULL; |
| 350 | struct hdac_stream *hstream = NULL; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 351 | |
| 352 | switch (type) { |
| 353 | case HDAC_EXT_STREAM_TYPE_COUPLED: |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 354 | hstream = snd_hdac_stream_assign(bus, substream); |
| 355 | if (hstream) |
| 356 | hext_stream = container_of(hstream, |
| 357 | struct hdac_ext_stream, |
| 358 | hstream); |
| 359 | return hext_stream; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 360 | |
| 361 | case HDAC_EXT_STREAM_TYPE_HOST: |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 362 | return hdac_ext_host_stream_assign(bus, substream); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 363 | |
| 364 | case HDAC_EXT_STREAM_TYPE_LINK: |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 365 | return hdac_ext_link_stream_assign(bus, substream); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 366 | |
| 367 | default: |
| 368 | return NULL; |
| 369 | } |
| 370 | } |
| 371 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_assign); |
| 372 | |
| 373 | /** |
| 374 | * snd_hdac_ext_stream_release - release the assigned stream |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 375 | * @hext_stream: HD-audio ext core stream to release |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 376 | * @type: type of stream (coupled, host or link stream) |
| 377 | * |
| 378 | * Release the stream that has been assigned by snd_hdac_ext_stream_assign(). |
| 379 | */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 380 | void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type) |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 381 | { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 382 | struct hdac_bus *bus = hext_stream->hstream.bus; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 383 | |
| 384 | switch (type) { |
| 385 | case HDAC_EXT_STREAM_TYPE_COUPLED: |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 386 | snd_hdac_stream_release(&hext_stream->hstream); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 387 | break; |
| 388 | |
| 389 | case HDAC_EXT_STREAM_TYPE_HOST: |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 390 | spin_lock_irq(&bus->reg_lock); |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 391 | if (hext_stream->decoupled && !hext_stream->link_locked) |
| 392 | snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); |
Pierre-Louis Bossart | 868ddfc | 2021-09-24 14:24:16 -0500 | [diff] [blame] | 393 | spin_unlock_irq(&bus->reg_lock); |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 394 | snd_hdac_stream_release(&hext_stream->hstream); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 395 | break; |
| 396 | |
| 397 | case HDAC_EXT_STREAM_TYPE_LINK: |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 398 | spin_lock_irq(&bus->reg_lock); |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 399 | if (hext_stream->decoupled && !hext_stream->hstream.opened) |
| 400 | snd_hdac_ext_stream_decouple_locked(bus, hext_stream, false); |
| 401 | hext_stream->link_locked = 0; |
| 402 | hext_stream->link_substream = NULL; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 403 | spin_unlock_irq(&bus->reg_lock); |
| 404 | break; |
| 405 | |
| 406 | default: |
| 407 | dev_dbg(bus->dev, "Invalid type %d\n", type); |
| 408 | } |
| 409 | |
| 410 | } |
| 411 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_release); |
| 412 | |
| 413 | /** |
| 414 | * snd_hdac_ext_stream_spbcap_enable - enable SPIB for a stream |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 415 | * @bus: HD-audio core bus |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 416 | * @enable: flag to enable/disable SPIB |
| 417 | * @index: stream index for which SPIB need to be enabled |
| 418 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 419 | void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *bus, |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 420 | bool enable, int index) |
| 421 | { |
| 422 | u32 mask = 0; |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 423 | |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 424 | if (!bus->spbcap) { |
Colin Ian King | 3617631 | 2016-09-16 17:36:05 +0100 | [diff] [blame] | 425 | dev_err(bus->dev, "Address of SPB capability is NULL\n"); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 426 | return; |
| 427 | } |
| 428 | |
| 429 | mask |= (1 << index); |
| 430 | |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 431 | if (enable) |
Keyon Jie | f7c50fa | 2018-09-03 10:47:09 +0800 | [diff] [blame] | 432 | snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, mask); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 433 | else |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 434 | snd_hdac_updatel(bus->spbcap, AZX_REG_SPB_SPBFCCTL, mask, 0); |
Jeeja KP | df203a4 | 2015-06-11 14:11:49 +0530 | [diff] [blame] | 435 | } |
| 436 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_spbcap_enable); |
| 437 | |
| 438 | /** |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 439 | * snd_hdac_ext_stream_set_spib - sets the spib value of a stream |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 440 | * @bus: HD-audio core bus |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 441 | * @hext_stream: hdac_ext_stream |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 442 | * @value: spib value to set |
| 443 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 444 | int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 445 | struct hdac_ext_stream *hext_stream, u32 value) |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 446 | { |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 447 | |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 448 | if (!bus->spbcap) { |
Colin Ian King | 3617631 | 2016-09-16 17:36:05 +0100 | [diff] [blame] | 449 | dev_err(bus->dev, "Address of SPB capability is NULL\n"); |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 450 | return -EINVAL; |
| 451 | } |
| 452 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 453 | writel(value, hext_stream->spib_addr); |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 454 | |
| 455 | return 0; |
| 456 | } |
| 457 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_spib); |
| 458 | |
| 459 | /** |
Vinod Koul | 54d1d2f | 2015-08-23 11:52:50 +0530 | [diff] [blame] | 460 | * snd_hdac_ext_stream_get_spbmaxfifo - gets the spib value of a stream |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 461 | * @bus: HD-audio core bus |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 462 | * @hext_stream: hdac_ext_stream |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 463 | * |
| 464 | * Return maxfifo for the stream |
| 465 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 466 | int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 467 | struct hdac_ext_stream *hext_stream) |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 468 | { |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 469 | |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 470 | if (!bus->spbcap) { |
Colin Ian King | 3617631 | 2016-09-16 17:36:05 +0100 | [diff] [blame] | 471 | dev_err(bus->dev, "Address of SPB capability is NULL\n"); |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 472 | return -EINVAL; |
| 473 | } |
| 474 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 475 | return readl(hext_stream->fifo_addr); |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 476 | } |
Vinod Koul | 54d1d2f | 2015-08-23 11:52:50 +0530 | [diff] [blame] | 477 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_get_spbmaxfifo); |
Jeeja KP | ee8bc4d | 2015-08-21 21:36:20 +0530 | [diff] [blame] | 478 | |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 479 | /** |
| 480 | * snd_hdac_ext_stream_drsm_enable - enable DMA resume for a stream |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 481 | * @bus: HD-audio core bus |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 482 | * @enable: flag to enable/disable DRSM |
| 483 | * @index: stream index for which DRSM need to be enabled |
| 484 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 485 | void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus, |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 486 | bool enable, int index) |
| 487 | { |
| 488 | u32 mask = 0; |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 489 | |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 490 | if (!bus->drsmcap) { |
Colin Ian King | 3617631 | 2016-09-16 17:36:05 +0100 | [diff] [blame] | 491 | dev_err(bus->dev, "Address of DRSM capability is NULL\n"); |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 492 | return; |
| 493 | } |
| 494 | |
| 495 | mask |= (1 << index); |
| 496 | |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 497 | if (enable) |
Keyon Jie | f7c50fa | 2018-09-03 10:47:09 +0800 | [diff] [blame] | 498 | snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, mask); |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 499 | else |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 500 | snd_hdac_updatel(bus->drsmcap, AZX_REG_DRSM_CTL, mask, 0); |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 501 | } |
| 502 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_drsm_enable); |
| 503 | |
| 504 | /** |
| 505 | * snd_hdac_ext_stream_set_dpibr - sets the dpibr value of a stream |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 506 | * @bus: HD-audio core bus |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 507 | * @hext_stream: hdac_ext_stream |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 508 | * @value: dpib value to set |
| 509 | */ |
Rakesh Ughreja | 76f56fa | 2018-06-01 22:53:50 -0500 | [diff] [blame] | 510 | int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus, |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 511 | struct hdac_ext_stream *hext_stream, u32 value) |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 512 | { |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 513 | |
Vinod Koul | ec8ae57 | 2016-08-04 15:46:01 +0530 | [diff] [blame] | 514 | if (!bus->drsmcap) { |
Colin Ian King | 3617631 | 2016-09-16 17:36:05 +0100 | [diff] [blame] | 515 | dev_err(bus->dev, "Address of DRSM capability is NULL\n"); |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 516 | return -EINVAL; |
| 517 | } |
| 518 | |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 519 | writel(value, hext_stream->dpibr_addr); |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 520 | |
| 521 | return 0; |
| 522 | } |
| 523 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_dpibr); |
| 524 | |
| 525 | /** |
| 526 | * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 527 | * @hext_stream: hdac_ext_stream |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 528 | * @value: lpib value to set |
| 529 | */ |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 530 | int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *hext_stream, u32 value) |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 531 | { |
Pierre-Louis Bossart | 0f7e5ee | 2021-12-16 17:11:28 -0600 | [diff] [blame] | 532 | snd_hdac_stream_writel(&hext_stream->hstream, SD_LPIB, value); |
Jeeja KP | a9c48f7 | 2015-12-18 15:11:59 +0530 | [diff] [blame] | 533 | |
| 534 | return 0; |
| 535 | } |
| 536 | EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_lpib); |