MLK-24444-1: ASoC: fsl_dsp: Support PCM format for compress sound card
For PCM format the supported format is mono/stereo, S16_LE/S32_LE, and 8KHz-192kHz frequency. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>5.4-rM2-2.2.x-imx-squashed
parent
edfae0f3a6
commit
e17ee871b9
|
@ -44,7 +44,8 @@
|
|||
#define CODEC_DRM_DEC 6
|
||||
#define CODEC_SBC_DEC 7
|
||||
#define CODEC_SBC_ENC 8
|
||||
#define CODEC_DEMO_DEC 9
|
||||
#define CODEC_PCM_DEC 9
|
||||
#define CODEC_DEMO_DEC 10
|
||||
|
||||
#define RENDER_ESAI 0x10
|
||||
#define RENDER_SAI 0x11
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "fsl_dsp_platform.h"
|
||||
#include "fsl_dsp_xaf_api.h"
|
||||
|
||||
#define NUM_CODEC 2
|
||||
#define NUM_CODEC 3
|
||||
#define MIN_FRAGMENT 1
|
||||
#define MAX_FRAGMENT 1
|
||||
#define MIN_FRAGMENT_SIZE (4 * 1024)
|
||||
|
@ -137,6 +137,9 @@ static int dsp_platform_compr_set_params(struct snd_compr_stream *cstream,
|
|||
int ret;
|
||||
|
||||
switch (params->codec.id) {
|
||||
case SND_AUDIOCODEC_PCM:
|
||||
drv->codec_type = CODEC_PCM_DEC;
|
||||
break;
|
||||
case SND_AUDIOCODEC_MP3:
|
||||
drv->codec_type = CODEC_MP3_DEC;
|
||||
break;
|
||||
|
@ -210,6 +213,21 @@ static int dsp_platform_compr_set_params(struct snd_compr_stream *cstream,
|
|||
drv->client->consume_bytes = 0;
|
||||
drv->client->offset = 0;
|
||||
|
||||
if (drv->codec_type == CODEC_PCM_DEC) {
|
||||
s_param.id = XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH;
|
||||
if (params->codec.format == SNDRV_PCM_FORMAT_S32_LE)
|
||||
s_param.mixData.value = 32;
|
||||
else
|
||||
s_param.mixData.value = 16;
|
||||
ret = xaf_comp_set_config(drv->client, &drv->component[0], 1, &s_param);
|
||||
if (ret) {
|
||||
dev_err(component->dev,
|
||||
"set param[cmd:0x%x|val:0x%x] error, err = %d\n",
|
||||
s_param.id, s_param.mixData.value, ret);
|
||||
goto err_comp1_create;
|
||||
}
|
||||
}
|
||||
|
||||
s_param.id = XA_RENDERER_CONFIG_PARAM_SAMPLE_RATE;
|
||||
s_param.mixData.value = params->codec.sample_rate;
|
||||
ret = xaf_comp_set_config(drv->client, &drv->component[1], 1, &s_param);
|
||||
|
@ -512,10 +530,32 @@ static int dsp_platform_compr_get_caps(struct snd_compr_stream *cstream,
|
|||
caps->max_fragments = MAX_FRAGMENT;
|
||||
caps->codecs[0] = SND_AUDIOCODEC_MP3;
|
||||
caps->codecs[1] = SND_AUDIOCODEC_AAC;
|
||||
caps->codecs[2] = SND_AUDIOCODEC_PCM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_compr_codec_caps caps_pcm = {
|
||||
.num_descriptors = 1,
|
||||
.descriptor[0].max_ch = 2,
|
||||
.descriptor[0].sample_rates[0] = 192000,
|
||||
.descriptor[0].sample_rates[1] = 176400,
|
||||
.descriptor[0].sample_rates[2] = 96000,
|
||||
.descriptor[0].sample_rates[3] = 88200,
|
||||
.descriptor[0].sample_rates[4] = 48000,
|
||||
.descriptor[0].sample_rates[5] = 44100,
|
||||
.descriptor[0].sample_rates[6] = 32000,
|
||||
.descriptor[0].sample_rates[7] = 16000,
|
||||
.descriptor[0].sample_rates[8] = 8000,
|
||||
.descriptor[0].num_sample_rates = 9,
|
||||
.descriptor[0].bit_rate[0] = 320,
|
||||
.descriptor[0].bit_rate[1] = 192,
|
||||
.descriptor[0].num_bitrates = 2,
|
||||
.descriptor[0].profiles = SND_AUDIOPROFILE_PCM,
|
||||
.descriptor[0].modes = 0,
|
||||
.descriptor[0].formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
|
||||
};
|
||||
|
||||
static struct snd_compr_codec_caps caps_mp3 = {
|
||||
.num_descriptors = 1,
|
||||
.descriptor[0].max_ch = 2,
|
||||
|
@ -559,6 +599,8 @@ static int dsp_platform_compr_get_codec_caps(struct snd_compr_stream *cstream,
|
|||
*codec = caps_mp3;
|
||||
else if (codec->codec == SND_AUDIOCODEC_AAC)
|
||||
*codec = caps_aac;
|
||||
else if (codec->codec == SND_AUDIOCODEC_PCM)
|
||||
*codec = caps_pcm;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
@ -180,6 +180,7 @@ int xaf_comp_create(struct xf_client *client, struct xf_proxy *proxy,
|
|||
struct xf_buffer *buf;
|
||||
int ret = 0, size;
|
||||
bool loadlib = true;
|
||||
bool request_inbuf = true;
|
||||
|
||||
memset((void *)p_comp, 0, sizeof(struct xaf_comp));
|
||||
|
||||
|
@ -190,9 +191,14 @@ int xaf_comp_create(struct xf_client *client, struct xf_proxy *proxy,
|
|||
|
||||
p_comp->comp_type = comp_type;
|
||||
|
||||
if (comp_type == RENDER_ESAI || comp_type == RENDER_SAI)
|
||||
/* No need to load library for PCM */
|
||||
if (comp_type == RENDER_ESAI || comp_type == RENDER_SAI || comp_type == CODEC_PCM_DEC)
|
||||
loadlib = false;
|
||||
|
||||
/* Need to allocate in buffer for PCM */
|
||||
if (comp_type == RENDER_ESAI || comp_type == RENDER_SAI)
|
||||
request_inbuf = false;
|
||||
|
||||
if (loadlib) {
|
||||
p_comp->codec_lib.filename = lib_path;
|
||||
p_comp->codec_wrap_lib.filename = lib_wrap_path;
|
||||
|
@ -200,6 +206,9 @@ int xaf_comp_create(struct xf_client *client, struct xf_proxy *proxy,
|
|||
}
|
||||
|
||||
switch (comp_type) {
|
||||
case CODEC_PCM_DEC:
|
||||
p_comp->dec_id = "audio-decoder/pcm";
|
||||
break;
|
||||
case CODEC_MP3_DEC:
|
||||
p_comp->dec_id = "audio-decoder/mp3";
|
||||
strcat(lib_path, "lib_dsp_mp3_dec.so");
|
||||
|
@ -245,7 +254,9 @@ int xaf_comp_create(struct xf_client *client, struct xf_proxy *proxy,
|
|||
dev_err(dsp_priv->dev, "load codec lib error\n");
|
||||
goto err_codec_load;
|
||||
}
|
||||
}
|
||||
|
||||
if (request_inbuf) {
|
||||
/* ...allocate input buffer */
|
||||
if (dsp_priv->dsp_is_lpa)
|
||||
size = INBUF_SIZE_LPA;
|
||||
|
|
|
@ -161,4 +161,16 @@ enum xa_config_param_renderer {
|
|||
XA_RENDERER_CONFIG_PARAM_NUM = 7,
|
||||
};
|
||||
|
||||
/* pcm codec configuration parameters */
|
||||
enum xa_config_param_pcm {
|
||||
XA_PCM_CONFIG_PARAM_SAMPLE_RATE = 0, /* not supported */
|
||||
XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH = 1,
|
||||
XA_PCM_CONFIG_PARAM_IN_CHANNELS = 2, /* not supported */
|
||||
XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH = 3, /* not supported */
|
||||
XA_PCM_CONFIG_PARAM_OUT_CHANNELS = 4, /* not supported */
|
||||
XA_PCM_CONFIG_PARAM_CHANROUTING = 5, /* not supported */
|
||||
XA_PCM_CONFIG_PARAM_FUNC_PRINT = 13, /* not supported */
|
||||
XA_PCM_CONFIG_PARAM_NUM = 14, /* not supported */
|
||||
};
|
||||
|
||||
#endif /* FSL_DSP_XAF_API_H */
|
||||
|
|
Loading…
Reference in New Issue