Skip to content

Commit

Permalink
ASoC: q6asm: add length to write command token
Browse files Browse the repository at this point in the history
Add length to write command packet token so that we can track exactly
how many bytes are consumed by DSP in the command reply.

This is useful in some use-cases where the end of the file/stream
is not aligned with period size.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20200727093806.17089-5-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Srinivas Kandagatla authored and Mark Brown committed Aug 17, 2020
1 parent e0c078a commit 50d4e21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion sound/soc/qcom/qdsp6/q6asm-dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ static void compress_event_handler(uint32_t opcode, uint32_t token,
struct snd_compr_stream *substream = prtd->cstream;
unsigned long flags;
uint64_t avail;
uint32_t bytes_written;

switch (opcode) {
case ASM_CLIENT_EVENT_CMD_RUN_DONE:
Expand All @@ -526,7 +527,8 @@ static void compress_event_handler(uint32_t opcode, uint32_t token,
case ASM_CLIENT_EVENT_DATA_WRITE_DONE:
spin_lock_irqsave(&prtd->lock, flags);

prtd->copied_total += prtd->pcm_count;
bytes_written = token >> ASM_WRITE_TOKEN_LEN_SHIFT;
prtd->copied_total += bytes_written;
snd_compr_fragment_elapsed(substream);

if (prtd->state != Q6ASM_STREAM_RUNNING) {
Expand Down
7 changes: 4 additions & 3 deletions sound/soc/qcom/qdsp6/q6asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
if (ac->io_mode & ASM_SYNC_IO_MODE) {
phys_addr_t phys;
unsigned long flags;
int token = hdr->token & ASM_WRITE_TOKEN_MASK;

spin_lock_irqsave(&ac->lock, flags);

Expand All @@ -681,12 +682,12 @@ static int32_t q6asm_stream_callback(struct apr_device *adev,
goto done;
}

phys = port->buf[hdr->token].phys;
phys = port->buf[token].phys;

if (lower_32_bits(phys) != result->opcode ||
upper_32_bits(phys) != result->status) {
dev_err(ac->dev, "Expected addr %pa\n",
&port->buf[hdr->token].phys);
&port->buf[token].phys);
spin_unlock_irqrestore(&ac->lock, flags);
ret = -EINVAL;
goto done;
Expand Down Expand Up @@ -1535,7 +1536,7 @@ int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len,
q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id);

ab = &port->buf[port->dsp_buf];
pkt->hdr.token = port->dsp_buf;
pkt->hdr.token = port->dsp_buf | (len << ASM_WRITE_TOKEN_LEN_SHIFT);
pkt->hdr.opcode = ASM_DATA_CMD_WRITE_V2;
write->buf_addr_lsw = lower_32_bits(ab->phys);
write->buf_addr_msw = upper_32_bits(ab->phys);
Expand Down
3 changes: 3 additions & 0 deletions sound/soc/qcom/qdsp6/q6asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#define ASM_CLIENT_EVENT_CMD_RUN_DONE 0x1008
#define ASM_CLIENT_EVENT_DATA_WRITE_DONE 0x1009
#define ASM_CLIENT_EVENT_DATA_READ_DONE 0x100a
#define ASM_WRITE_TOKEN_MASK GENMASK(15, 0)
#define ASM_WRITE_TOKEN_LEN_MASK GENMASK(31, 16)
#define ASM_WRITE_TOKEN_LEN_SHIFT 16

enum {
LEGACY_PCM_MODE = 0,
Expand Down

0 comments on commit 50d4e21

Please sign in to comment.