mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
ASoC: SOF: Copy compress parameters into extended data
Allocate memory at the end of sof_ipc_stream_params to store snd_compr_params in order to be sent them to SOF firmware. This will help firmware correctly configure codecs parameters. Notice, that we use 2 bytes from the reserved pool in order to store the extended data length. This is compatible with older FWs where there was no extended data. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20220712141531.14599-3-daniel.baluta@oss.nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
d5770daef6
commit
3f70c360d4
|
@ -86,9 +86,11 @@ struct sof_ipc_stream_params {
|
||||||
uint32_t host_period_bytes;
|
uint32_t host_period_bytes;
|
||||||
uint16_t no_stream_position; /**< 1 means don't send stream position */
|
uint16_t no_stream_position; /**< 1 means don't send stream position */
|
||||||
uint8_t cont_update_posn; /**< 1 means continuous update stream position */
|
uint8_t cont_update_posn; /**< 1 means continuous update stream position */
|
||||||
|
uint8_t reserved0;
|
||||||
uint8_t reserved[5];
|
int16_t ext_data_length; /**< 0, means no extended data */
|
||||||
|
uint8_t reserved[2];
|
||||||
uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */
|
uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */
|
||||||
|
uint8_t ext_data[]; /**< extended data */
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
/* PCM params info - SOF_IPC_STREAM_PCM_PARAMS */
|
/* PCM params info - SOF_IPC_STREAM_PCM_PARAMS */
|
||||||
|
|
|
@ -170,6 +170,7 @@ static int sof_compr_set_params(struct snd_soc_component *component,
|
||||||
struct snd_compr_tstamp *tstamp;
|
struct snd_compr_tstamp *tstamp;
|
||||||
struct sof_ipc_pcm_params *pcm;
|
struct sof_ipc_pcm_params *pcm;
|
||||||
struct snd_sof_pcm *spcm;
|
struct snd_sof_pcm *spcm;
|
||||||
|
size_t ext_data_size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
tstamp = crtd->private_data;
|
tstamp = crtd->private_data;
|
||||||
|
@ -179,7 +180,12 @@ static int sof_compr_set_params(struct snd_soc_component *component,
|
||||||
if (!spcm)
|
if (!spcm)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
|
ext_data_size = sizeof(params->codec);
|
||||||
|
|
||||||
|
if (sizeof(*pcm) + ext_data_size > sdev->ipc->max_payload_size)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
pcm = kzalloc(sizeof(*pcm) + ext_data_size, GFP_KERNEL);
|
||||||
if (!pcm)
|
if (!pcm)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -194,11 +200,11 @@ static int sof_compr_set_params(struct snd_soc_component *component,
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
pcm->params.buffer.pages = PFN_UP(crtd->dma_bytes);
|
pcm->params.buffer.pages = PFN_UP(crtd->dma_bytes);
|
||||||
pcm->hdr.size = sizeof(*pcm);
|
pcm->hdr.size = sizeof(*pcm) + ext_data_size;
|
||||||
pcm->hdr.cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_PARAMS;
|
pcm->hdr.cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_PARAMS;
|
||||||
|
|
||||||
pcm->comp_id = spcm->stream[cstream->direction].comp_id;
|
pcm->comp_id = spcm->stream[cstream->direction].comp_id;
|
||||||
pcm->params.hdr.size = sizeof(pcm->params);
|
pcm->params.hdr.size = sizeof(pcm->params) + ext_data_size;
|
||||||
pcm->params.buffer.phy_addr = spcm->stream[cstream->direction].page_table.addr;
|
pcm->params.buffer.phy_addr = spcm->stream[cstream->direction].page_table.addr;
|
||||||
pcm->params.buffer.size = crtd->dma_bytes;
|
pcm->params.buffer.size = crtd->dma_bytes;
|
||||||
pcm->params.direction = cstream->direction;
|
pcm->params.direction = cstream->direction;
|
||||||
|
@ -209,8 +215,11 @@ static int sof_compr_set_params(struct snd_soc_component *component,
|
||||||
pcm->params.sample_container_bytes =
|
pcm->params.sample_container_bytes =
|
||||||
snd_pcm_format_physical_width(SNDRV_PCM_FORMAT_S32) >> 3;
|
snd_pcm_format_physical_width(SNDRV_PCM_FORMAT_S32) >> 3;
|
||||||
pcm->params.host_period_bytes = params->buffer.fragment_size;
|
pcm->params.host_period_bytes = params->buffer.fragment_size;
|
||||||
|
pcm->params.ext_data_length = ext_data_size;
|
||||||
|
|
||||||
ret = sof_ipc_tx_message(sdev->ipc, pcm, sizeof(*pcm),
|
memcpy((u8 *)pcm->params.ext_data, ¶ms->codec, ext_data_size);
|
||||||
|
|
||||||
|
ret = sof_ipc_tx_message(sdev->ipc, pcm, sizeof(*pcm) + ext_data_size,
|
||||||
&ipc_params_reply, sizeof(ipc_params_reply));
|
&ipc_params_reply, sizeof(ipc_params_reply));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(component->dev, "error ipc failed\n");
|
dev_err(component->dev, "error ipc failed\n");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user