Skip to content

Commit d1e7dce

Browse files
committed
ASoC: fsl: two fixes for asrc memory to memory
Merge series from Shengjiu Wang <[email protected]>: 1. Fix the suspend failure for memory to peripheral function. 2. Return error value for processing function.
2 parents da8146c + abe01a7 commit d1e7dce

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

sound/soc/fsl/fsl_asrc_m2m.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static int asrc_dmaconfig(struct fsl_asrc_pair *pair,
183183
}
184184

185185
/* main function of converter */
186-
static void asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_compr_task_runtime *task)
186+
static int asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_compr_task_runtime *task)
187187
{
188188
struct fsl_asrc *asrc = pair->asrc;
189189
struct device *dev = &asrc->pdev->dev;
@@ -193,7 +193,7 @@ static void asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_compr_tas
193193
unsigned int out_dma_len;
194194
unsigned int width;
195195
u32 fifo_addr;
196-
int ret;
196+
int ret = 0;
197197

198198
/* set ratio mod */
199199
if (asrc->m2m_set_ratio_mod) {
@@ -215,6 +215,7 @@ static void asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_compr_tas
215215
in_buf_len > ASRC_M2M_BUFFER_SIZE ||
216216
in_buf_len % (width * pair->channels / 8)) {
217217
dev_err(dev, "out buffer size is error: [%d]\n", in_buf_len);
218+
ret = -EINVAL;
218219
goto end;
219220
}
220221

@@ -245,6 +246,7 @@ static void asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_compr_tas
245246
}
246247
} else if (out_dma_len > ASRC_M2M_BUFFER_SIZE) {
247248
dev_err(dev, "cap buffer size error\n");
249+
ret = -EINVAL;
248250
goto end;
249251
}
250252

@@ -263,12 +265,14 @@ static void asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_compr_tas
263265

264266
if (!wait_for_completion_interruptible_timeout(&pair->complete[IN], 10 * HZ)) {
265267
dev_err(dev, "out DMA task timeout\n");
268+
ret = -ETIMEDOUT;
266269
goto end;
267270
}
268271

269272
if (out_dma_len > 0) {
270273
if (!wait_for_completion_interruptible_timeout(&pair->complete[OUT], 10 * HZ)) {
271274
dev_err(dev, "cap DMA task timeout\n");
275+
ret = -ETIMEDOUT;
272276
goto end;
273277
}
274278
}
@@ -278,7 +282,7 @@ static void asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_compr_tas
278282
/* update payload length for capture */
279283
task->output_size = out_dma_len;
280284
end:
281-
return;
285+
return ret;
282286
}
283287

284288
static int fsl_asrc_m2m_comp_open(struct snd_compr_stream *stream)
@@ -525,9 +529,7 @@ static int fsl_asrc_m2m_comp_task_start(struct snd_compr_stream *stream,
525529
struct snd_compr_runtime *runtime = stream->runtime;
526530
struct fsl_asrc_pair *pair = runtime->private_data;
527531

528-
asrc_m2m_device_run(pair, task);
529-
530-
return 0;
532+
return asrc_m2m_device_run(pair, task);
531533
}
532534

533535
static int fsl_asrc_m2m_comp_task_stop(struct snd_compr_stream *stream,
@@ -633,7 +635,7 @@ int fsl_asrc_m2m_suspend(struct fsl_asrc *asrc)
633635

634636
for (i = 0; i < PAIR_CTX_NUM; i++) {
635637
pair = asrc->pair[i];
636-
if (!pair)
638+
if (!pair || !pair->dma_buffer[IN].area || !pair->dma_buffer[OUT].area)
637639
continue;
638640
if (!completion_done(&pair->complete[IN])) {
639641
if (pair->dma_chan[IN])

0 commit comments

Comments
 (0)