|
22 | 22 | #include <sof/lib/notifier.h> |
23 | 23 | #include <sof/lib/uuid.h> |
24 | 24 | #include <sof/list.h> |
| 25 | +#include <rtos/spinlock.h> |
25 | 26 | #include <rtos/string.h> |
26 | 27 | #include <sof/ut.h> |
27 | 28 | #include <sof/trace/trace.h> |
@@ -164,36 +165,55 @@ int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config, |
164 | 165 | /* called from ipc/ipc3/dai.c */ |
165 | 166 | int dai_get_handshake(struct dai *dai, int direction, int stream_id) |
166 | 167 | { |
167 | | - const struct dai_properties *props = dai_get_properties(dai->dev, direction, stream_id); |
| 168 | + k_spinlock_key_t key = k_spin_lock(&dai->lock); |
| 169 | + const struct dai_properties *props = dai_get_properties(dai->dev, direction, |
| 170 | + stream_id); |
| 171 | + int hs_id = props->dma_hs_id; |
168 | 172 |
|
169 | | - return props->dma_hs_id; |
| 173 | + k_spin_unlock(&dai->lock, key); |
| 174 | + |
| 175 | + return hs_id; |
170 | 176 | } |
171 | 177 |
|
172 | 178 | /* called from ipc/ipc3/dai.c and ipc/ipc4/dai.c */ |
173 | 179 | int dai_get_fifo_depth(struct dai *dai, int direction) |
174 | 180 | { |
175 | 181 | const struct dai_properties *props; |
| 182 | + k_spinlock_key_t key; |
| 183 | + int fifo_depth; |
176 | 184 |
|
177 | 185 | if (!dai) |
178 | 186 | return 0; |
179 | 187 |
|
| 188 | + key = k_spin_lock(&dai->lock); |
180 | 189 | props = dai_get_properties(dai->dev, direction, 0); |
| 190 | + fifo_depth = props->fifo_depth; |
| 191 | + k_spin_unlock(&dai->lock, key); |
181 | 192 |
|
182 | | - return props->fifo_depth; |
| 193 | + return fifo_depth; |
183 | 194 | } |
184 | 195 |
|
185 | 196 | int dai_get_stream_id(struct dai *dai, int direction) |
186 | 197 | { |
| 198 | + k_spinlock_key_t key = k_spin_lock(&dai->lock); |
187 | 199 | const struct dai_properties *props = dai_get_properties(dai->dev, direction, 0); |
| 200 | + int stream_id = props->stream_id; |
| 201 | + |
| 202 | + k_spin_unlock(&dai->lock, key); |
188 | 203 |
|
189 | | - return props->stream_id; |
| 204 | + return stream_id; |
190 | 205 | } |
191 | 206 |
|
192 | 207 | static int dai_get_fifo(struct dai *dai, int direction, int stream_id) |
193 | 208 | { |
194 | | - const struct dai_properties *props = dai_get_properties(dai->dev, direction, stream_id); |
| 209 | + k_spinlock_key_t key = k_spin_lock(&dai->lock); |
| 210 | + const struct dai_properties *props = dai_get_properties(dai->dev, direction, |
| 211 | + stream_id); |
| 212 | + int fifo_address = props->fifo_address; |
195 | 213 |
|
196 | | - return props->fifo_address; |
| 214 | + k_spin_unlock(&dai->lock, key); |
| 215 | + |
| 216 | + return fifo_address; |
197 | 217 | } |
198 | 218 |
|
199 | 219 | /* this is called by DMA driver every time descriptor has completed */ |
@@ -312,6 +332,8 @@ static struct comp_dev *dai_new(const struct comp_driver *drv, |
312 | 332 | goto error; |
313 | 333 | } |
314 | 334 |
|
| 335 | + k_spinlock_init(&dd->dai->lock); |
| 336 | + |
315 | 337 | dma_sg_init(&dd->config.elem_array); |
316 | 338 | dd->xrun = 0; |
317 | 339 | dd->chan = NULL; |
@@ -1374,13 +1396,18 @@ static int dai_ts_stop_op(struct comp_dev *dev) |
1374 | 1396 | uint32_t dai_get_init_delay_ms(struct dai *dai) |
1375 | 1397 | { |
1376 | 1398 | const struct dai_properties *props; |
| 1399 | + k_spinlock_key_t key; |
| 1400 | + uint32_t init_delay; |
1377 | 1401 |
|
1378 | 1402 | if (!dai) |
1379 | 1403 | return 0; |
1380 | 1404 |
|
| 1405 | + key = k_spin_lock(&dai->lock); |
1381 | 1406 | props = dai_get_properties(dai->dev, 0, 0); |
| 1407 | + init_delay = props->reg_init_delay; |
| 1408 | + k_spin_unlock(&dai->lock, key); |
1382 | 1409 |
|
1383 | | - return props->reg_init_delay; |
| 1410 | + return init_delay; |
1384 | 1411 | } |
1385 | 1412 |
|
1386 | 1413 | static uint64_t dai_get_processed_data(struct comp_dev *dev, uint32_t stream_no, bool input) |
|
0 commit comments