Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: mediatek: add pcm_pointer callback for mt8186

add pcm_pointer callback for mt8186 to support read
host position from DSP

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220921120239.31934-1-chunxu.li@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Chunxu Li and committed by
Mark Brown
a921986f 843e10b3

+33
+33
sound/soc/sof/mediatek/mt8186/mt8186.c
··· 470 470 return 0; 471 471 } 472 472 473 + static snd_pcm_uframes_t mt8186_pcm_pointer(struct snd_sof_dev *sdev, 474 + struct snd_pcm_substream *substream) 475 + { 476 + int ret; 477 + snd_pcm_uframes_t pos; 478 + struct snd_sof_pcm *spcm; 479 + struct sof_ipc_stream_posn posn; 480 + struct snd_sof_pcm_stream *stream; 481 + struct snd_soc_component *scomp = sdev->component; 482 + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 483 + 484 + spcm = snd_sof_find_spcm_dai(scomp, rtd); 485 + if (!spcm) { 486 + dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n", 487 + rtd->dai_link->id); 488 + return 0; 489 + } 490 + 491 + stream = &spcm->stream[substream->stream]; 492 + ret = snd_sof_ipc_msg_data(sdev, stream->substream, &posn, sizeof(posn)); 493 + if (ret < 0) { 494 + dev_warn(sdev->dev, "failed to read stream position: %d\n", ret); 495 + return 0; 496 + } 497 + 498 + memcpy(&stream->posn, &posn, sizeof(posn)); 499 + pos = spcm->stream[substream->stream].posn.host_posn; 500 + pos = bytes_to_frames(substream->runtime, pos); 501 + 502 + return pos; 503 + } 504 + 473 505 static struct snd_soc_dai_driver mt8186_dai[] = { 474 506 { 475 507 .name = "SOF_DL1", ··· 569 537 /* stream callbacks */ 570 538 .pcm_open = sof_stream_pcm_open, 571 539 .pcm_hw_params = mt8186_pcm_hw_params, 540 + .pcm_pointer = mt8186_pcm_pointer, 572 541 .pcm_close = sof_stream_pcm_close, 573 542 574 543 /* firmware loading */