Messages in this thread | | | Subject | Re: [PATCH v2 9/9] ASoC: q6asm-dai: add support to copy callback | From | Pierre-Louis Bossart <> | Date | Tue, 21 Jul 2020 14:54:41 -0500 |
| |
> +static int q6asm_compr_copy(struct snd_soc_component *component, > + struct snd_compr_stream *stream, char __user *buf, > + size_t count) > { > struct snd_compr_runtime *runtime = stream->runtime; > struct q6asm_dai_rtd *prtd = runtime->private_data; > unsigned long flags; > + u32 wflags = 0; > + int avail, bytes_in_flight = 0; > + void *dstn; > + size_t copy; > + u32 app_pointer; > + u32 bytes_received; > + > + bytes_received = prtd->bytes_received; > + > + /**
/*
> + * Make sure that next track data pointer is aligned at 32 bit boundary > + * This is a Mandatory requirement from DSP data buffers alignment > + */ > + if (prtd->next_track) > + bytes_received = ALIGN(prtd->bytes_received, prtd->pcm_count); > + > + app_pointer = bytes_received/prtd->pcm_size; > + app_pointer = bytes_received - (app_pointer * prtd->pcm_size); > + dstn = prtd->dma_buffer.area + app_pointer; > + > + if (count < prtd->pcm_size - app_pointer) { > + if (copy_from_user(dstn, buf, count)) > + return -EFAULT; > + } else { > + copy = prtd->pcm_size - app_pointer; > + if (copy_from_user(dstn, buf, copy)) > + return -EFAULT; > + if (copy_from_user(prtd->dma_buffer.area, buf + copy, > + count - copy)) > + return -EFAULT; > + }
| |