Skip to content

Commit bbe0f1a

Browse files
dai-zephyr cleanup
Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
1 parent bd0bb70 commit bbe0f1a

2 files changed

Lines changed: 30 additions & 16 deletions

File tree

src/audio/dai-zephyr.c

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,11 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
349349
}
350350
#endif
351351

352+
#ifdef CONFIG_DAI_INTEL_UAOL
352353
if (dd->uaol.feedback_drift)
353354
uaol_dma_buffer_copy_to(dd, bytes);
354355
else
356+
#endif /* CONFIG_DAI_INTEL_UAOL */
355357
ret = dma_buffer_copy_to(dd->local_buffer, dd->dma_buffer,
356358
dd->process, bytes, dd->chmap);
357359
} else {
@@ -436,9 +438,10 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
436438
dd->total_data_processed += bytes;
437439
}
438440

439-
if (dd->uaol.fb_dma_buf && dd->uaol.fb_chan_idx >= 0) {
441+
#ifdef CONFIG_DAI_INTEL_UAOL
442+
if (dd->uaol.fb_chan_idx >= 0)
440443
process_uaol_feedback(dev, dd);
441-
}
444+
#endif /* CONFIG_DAI_INTEL_UAOL */
442445

443446
#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
444447
/* Increment performance counters */
@@ -1193,12 +1196,18 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
11931196
goto out;
11941197
}
11951198

1196-
/* create dsrc output buffer (if needed) */
1197-
if (dd->ipc_config.type == SOF_DAI_INTEL_UAOL && dd->ipc_config.direction == SOF_IPC_STREAM_PLAYBACK) {
1198-
/* dsrc may add 1 extra frame as a result of interpolation, dsrc only works with 32-bit data */
1199+
/* Ideally, this should be moved into setup_uaol_feedback_dma() in uaol.c, but
1200+
* there is no easy access to "params" there to set up the buffer format.
1201+
*/
1202+
#ifdef CONFIG_DAI_INTEL_UAOL
1203+
/* create DSRC output buffer (if needed) */
1204+
if (dd->ipc_config.type == SOF_DAI_INTEL_UAOL &&
1205+
dd->ipc_config.direction == SOF_IPC_STREAM_PLAYBACK) {
1206+
/* resampling might generate 1 extra frame; DSRC only works with 32-bit data */
11991207
size_t dsrc_buf_size = (dev->frames + 1) * dd->ipc_config.gtw_fmt->channels_count * 4;
1200-
dd->uaol.dsrc_buf = buffer_alloc_range(NULL, dsrc_buf_size, dsrc_buf_size, SOF_MEM_FLAG_USER,
1201-
PLATFORM_DCACHE_ALIGN, BUFFER_USAGE_NOT_SHARED);
1208+
dd->uaol.dsrc_buf = buffer_alloc_range(NULL, dsrc_buf_size, dsrc_buf_size,
1209+
SOF_MEM_FLAG_USER, PLATFORM_DCACHE_ALIGN,
1210+
BUFFER_USAGE_NOT_SHARED);
12021211
if (!dd->uaol.dsrc_buf) {
12031212
comp_err(dev, "failed to alloc dsrc buffer");
12041213
goto out;
@@ -1207,6 +1216,7 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
12071216
/* params should be same as local_buffer's */
12081217
buffer_set_params(dd->uaol.dsrc_buf, &params, BUFFER_UPDATE_FORCE);
12091218
}
1219+
#endif /* CONFIG_DAI_INTEL_UAOL */
12101220

12111221
out:
12121222
/*
@@ -1273,8 +1283,10 @@ int dai_common_config_prepare(struct dai_data *dd, struct comp_dev *dev)
12731283
comp_dbg(dev, "new configured dma channel index %d",
12741284
dd->chan_index);
12751285

1276-
/* Does nothing when non-UAOL gateway */
1286+
#ifdef CONFIG_DAI_INTEL_UAOL
1287+
/* Does nothing if feedback DMA is not needed */
12771288
setup_uaol_feedback_dma(dd, dev);
1289+
#endif /* CONFIG_DAI_INTEL_UAOL */
12781290

12791291
return 0;
12801292
}
@@ -1299,8 +1311,10 @@ int dai_common_prepare(struct dai_data *dd, struct comp_dev *dev)
12991311

13001312
/* clear dma buffer to avoid pop noise */
13011313
buffer_zero(dd->dma_buffer);
1314+
#ifdef CONFIG_DAI_INTEL_UAOL
13021315
if (dd->uaol.fb_dma_buf)
13031316
memset(dd->uaol.fb_dma_buf, 0, dd->uaol.fb_dma_buf_size);
1317+
#endif /* CONFIG_DAI_INTEL_UAOL */
13041318

13051319
/* dma reconfig not required if XRUN handling */
13061320
if (dd->xrun) {
@@ -1360,7 +1374,9 @@ void dai_common_reset(struct dai_data *dd, struct comp_dev *dev)
13601374
dd->dma_buffer = NULL;
13611375
}
13621376

1377+
#ifdef CONFIG_DAI_INTEL_UAOL
13631378
uaol_free(dd);
1379+
#endif /* CONFIG_DAI_INTEL_UAOL */
13641380

13651381
dd->wallclock = 0;
13661382
dd->total_data_processed = 0;
@@ -1418,8 +1434,14 @@ static int dai_comp_trigger_internal(struct dai_data *dd, struct comp_dev *dev,
14181434
if (dev->direction == SOF_IPC_STREAM_CAPTURE) {
14191435
buffer_zero(dd->dma_buffer);
14201436
}
1437+
1438+
#ifdef CONFIG_DAI_INTEL_UAOL
1439+
/* It might be beneficial to clear any old obsolete feedback value to prevent
1440+
* it from being used to adjust the rate immediately after resume. A feedback
1441+
* value of 0 will be rejected by the sanity check. */
14211442
if (dd->uaol.fb_dma_buf)
14221443
memset(dd->uaol.fb_dma_buf, 0, dd->uaol.fb_dma_buf_size);
1444+
#endif /* CONFIG_DAI_INTEL_UAOL */
14231445

14241446
/* DMA driver and SOF's view of the DMA buffer's
14251447
* read and write cursors must be the same to

src/include/sof/lib/dai-zephyr.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,8 @@ typedef int (*channel_copy_func)(const struct audio_stream *src, unsigned int sr
115115
struct audio_stream *dst, unsigned int dst_channel,
116116
unsigned int frames);
117117

118-
/* TODO: consider to move this into some UAOL header file? */
119118
#ifdef CONFIG_DAI_INTEL_UAOL
120119
struct uaol_dai_data {
121-
/* Diff between feedback freq read from UAOL endpoint and audio
122-
* format freq. In Hz. From -MAX_UAOL_DRIFT_HZ to MAX_UAOL_DRIFT_HZ.
123-
*/
124120
int feedback_drift;
125121
uint32_t ms_since_last_adjustment;
126122

@@ -290,10 +286,6 @@ uint32_t dai_get_init_delay_ms(struct dai *dai);
290286
*/
291287
int dai_get_stream_id(struct dai *dai, int direction);
292288

293-
#ifdef CONFIG_DAI_INTEL_UAOL
294-
int dai_get_uaol_stream_id(struct dai *dai, int *uaol_link_id, int *uaol_stream_id);
295-
#endif
296-
297289
/**
298290
* \brief Configure DMA channel for DAI
299291
*/

0 commit comments

Comments
 (0)