mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-01 02:21:16 +00:00
ASoc: msm: Add check for compressed capture format
- Only AMRWB format is supported in compress capture path, use default codec.id(SND_AUDIOCODEC_AMRWB) if request codec id is invalid. - Use fixed band mode and dtx mode since these are the only supported parameters for AMRWB format Change-Id: I45a48952a5833c3e85588b515d38d311064cd7fb Signed-off-by: Mingming Yin <mingming@codeaurora.org> Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
This commit is contained in:
parent
f28186f65e
commit
b3ca15c1fd
5 changed files with 110 additions and 9 deletions
|
@ -324,6 +324,17 @@ static struct snd_soc_dai_driver msm_fe_dais[] = {
|
|||
.rate_min = 8000,
|
||||
.rate_max = 192000,
|
||||
},
|
||||
.capture = {
|
||||
.stream_name = "MultiMedia8 Capture",
|
||||
.aif_name = "MM_UL8",
|
||||
.rates = (SNDRV_PCM_RATE_8000_48000|
|
||||
SNDRV_PCM_RATE_KNOT),
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
||||
.channels_min = 1,
|
||||
.channels_max = 8,
|
||||
.rate_min = 8000,
|
||||
.rate_max = 48000,
|
||||
},
|
||||
.ops = &msm_fe_Multimedia_dai_ops,
|
||||
.name = "MultiMedia8",
|
||||
.probe = fe_dai_probe,
|
||||
|
|
|
@ -2154,10 +2154,10 @@ static struct snd_soc_dai_link msm8974_common_dai_links[] = {
|
|||
.be_id = MSM_FRONTEND_DAI_MULTIMEDIA7,
|
||||
},
|
||||
{
|
||||
.name = "MSM8974 Compr4",
|
||||
.stream_name = "COMPR4",
|
||||
.name = "MSM8974 Compr8",
|
||||
.stream_name = "COMPR8",
|
||||
.cpu_dai_name = "MultiMedia8",
|
||||
.platform_name = "msm-compress-dsp",
|
||||
.platform_name = "msm-compr-dsp",
|
||||
.dynamic = 1,
|
||||
.trigger = {SND_SOC_DPCM_TRIGGER_POST,
|
||||
SND_SOC_DPCM_TRIGGER_POST},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
snd-soc-qdsp6v2-objs += msm-dai-q6-v2.o msm-pcm-q6-v2.o msm-pcm-routing-v2.o \
|
||||
msm-compress-q6-v2.o msm-multi-ch-pcm-q6-v2.o \
|
||||
msm-pcm-lpa-v2.o msm-pcm-afe-v2.o msm-pcm-voip-v2.o \
|
||||
msm-compress-q6-v2.o msm-compr-q6-v2.o \
|
||||
msm-multi-ch-pcm-q6-v2.o msm-pcm-lpa-v2.o \
|
||||
msm-pcm-afe-v2.o msm-pcm-voip-v2.o \
|
||||
msm-pcm-voice-v2.o msm-dai-q6-hdmi-v2.o \
|
||||
msm-lsm-client.o msm-pcm-host-voice-v2.o \
|
||||
msm-audio-effects-q6-v2.o
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
#define COMPRESSED_LR_VOL_MAX_STEPS 0x20002000
|
||||
|
||||
#define MAX_AC3_PARAM_SIZE (18*2*sizeof(int))
|
||||
#define AMR_WB_BAND_MODE 8
|
||||
#define AMR_WB_DTX_MODE 0
|
||||
|
||||
|
||||
const DECLARE_TLV_DB_LINEAR(compr_rx_vol_gain, 0,
|
||||
COMPRESSED_LR_VOL_MAX_STEPS);
|
||||
|
@ -108,12 +111,30 @@ static unsigned int supported_sample_rates[] = {
|
|||
8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
|
||||
};
|
||||
|
||||
/* Add supported codecs for compress capture path */
|
||||
static uint32_t supported_compr_capture_codecs[] = {
|
||||
SND_AUDIOCODEC_AMRWB
|
||||
};
|
||||
|
||||
static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
|
||||
.count = ARRAY_SIZE(supported_sample_rates),
|
||||
.list = supported_sample_rates,
|
||||
.mask = 0,
|
||||
};
|
||||
|
||||
static bool msm_compr_capture_codecs(uint32_t req_codec)
|
||||
{
|
||||
int i;
|
||||
pr_debug("%s req_codec:%d\n", __func__, req_codec);
|
||||
if (req_codec == 0)
|
||||
return false;
|
||||
for (i = 0; i < ARRAY_SIZE(supported_compr_capture_codecs); i++) {
|
||||
if (req_codec == supported_compr_capture_codecs[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void compr_event_handler(uint32_t opcode,
|
||||
uint32_t token, uint32_t *payload, void *priv)
|
||||
{
|
||||
|
@ -428,6 +449,13 @@ static int msm_compr_capture_prepare(struct snd_pcm_substream *substream)
|
|||
prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
|
||||
prtd->pcm_irq_pos = 0;
|
||||
|
||||
if (!msm_compr_capture_codecs(codec->id)) {
|
||||
/*
|
||||
* request codec invalid or not supported,
|
||||
* use default compress format
|
||||
*/
|
||||
codec->id = SND_AUDIOCODEC_AMRWB;
|
||||
}
|
||||
/* rate and channels are sent to audio driver */
|
||||
prtd->samp_rate = runtime->rate;
|
||||
prtd->channel_mode = runtime->channels;
|
||||
|
@ -441,8 +469,13 @@ static int msm_compr_capture_prepare(struct snd_pcm_substream *substream)
|
|||
pr_debug("SND_AUDIOCODEC_AMRWB\n");
|
||||
ret = q6asm_enc_cfg_blk_amrwb(prtd->audio_client,
|
||||
MAX_NUM_FRAMES_PER_BUFFER,
|
||||
codec->options.generic.reserved[0] /*bitrate 0-8*/,
|
||||
codec->options.generic.reserved[1] /*dtx mode 0/1*/);
|
||||
/*
|
||||
* use fixed band mode and dtx mode
|
||||
* band mode - 23.85 kbps
|
||||
*/
|
||||
AMR_WB_BAND_MODE,
|
||||
/* dtx mode - disable */
|
||||
AMR_WB_DTX_MODE);
|
||||
if (ret < 0)
|
||||
pr_err("%s: CMD Format block" \
|
||||
"failed: %d\n", __func__, ret);
|
||||
|
@ -500,6 +533,15 @@ static int msm_compr_trigger(struct snd_pcm_substream *substream, int cmd)
|
|||
prtd->pcm_irq_pos = 0;
|
||||
|
||||
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
|
||||
if (!msm_compr_capture_codecs(
|
||||
compr->info.codec_param.codec.id)) {
|
||||
/*
|
||||
* request codec invalid or not supported,
|
||||
* use default compress format
|
||||
*/
|
||||
compr->info.codec_param.codec.id =
|
||||
SND_AUDIOCODEC_AMRWB;
|
||||
}
|
||||
switch (compr->info.codec_param.codec.id) {
|
||||
case SND_AUDIOCODEC_AMRWB:
|
||||
break;
|
||||
|
@ -815,8 +857,10 @@ static int msm_compr_hw_params(struct snd_pcm_substream *substream,
|
|||
prtd->audio_client->perf_mode,
|
||||
prtd->session_id,
|
||||
substream->stream);
|
||||
/* the number of channels are required to call volume api
|
||||
accoridngly. So, get channels from hw params */
|
||||
/*
|
||||
* the number of channels are required to call volume api
|
||||
* accoridngly. So, get channels from hw params
|
||||
*/
|
||||
if ((params_channels(params) > 0) &&
|
||||
(params_periods(params) <= runtime->hw.channels_max))
|
||||
prtd->channel_mode = params_channels(params);
|
||||
|
@ -830,6 +874,15 @@ static int msm_compr_hw_params(struct snd_pcm_substream *substream,
|
|||
pr_err("%s: Send SoftVolume Param failed ret=%d\n",
|
||||
__func__, ret);
|
||||
} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
|
||||
if (!msm_compr_capture_codecs(
|
||||
compr->info.codec_param.codec.id)) {
|
||||
/*
|
||||
* request codec invalid or not supported,
|
||||
* use default compress format
|
||||
*/
|
||||
compr->info.codec_param.codec.id =
|
||||
SND_AUDIOCODEC_AMRWB;
|
||||
}
|
||||
switch (compr->info.codec_param.codec.id) {
|
||||
case SND_AUDIOCODEC_AMRWB:
|
||||
pr_debug("q6asm_open_read(FORMAT_AMRWB)\n");
|
||||
|
|
|
@ -2105,6 +2105,31 @@ static const struct snd_kcontrol_new mmul5_mixer_controls[] = {
|
|||
msm_routing_put_audio_mixer),
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new mmul8_mixer_controls[] = {
|
||||
SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX,
|
||||
MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
|
||||
msm_routing_put_audio_mixer),
|
||||
SOC_SINGLE_EXT("PRI_MI2S_TX", MSM_BACKEND_DAI_PRI_MI2S_TX,
|
||||
MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
|
||||
msm_routing_put_audio_mixer),
|
||||
SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX,
|
||||
MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
|
||||
msm_routing_put_audio_mixer),
|
||||
SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX,
|
||||
MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
|
||||
msm_routing_put_audio_mixer),
|
||||
SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX,
|
||||
MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
|
||||
msm_routing_put_audio_mixer),
|
||||
SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX,
|
||||
MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
|
||||
msm_routing_put_audio_mixer),
|
||||
SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX,
|
||||
MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,
|
||||
msm_routing_put_audio_mixer),
|
||||
};
|
||||
|
||||
|
||||
static const struct snd_kcontrol_new pri_rx_voice_mixer_controls[] = {
|
||||
SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_PRI_I2S_RX,
|
||||
MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer,
|
||||
|
@ -3221,6 +3246,7 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
|
|||
SND_SOC_DAPM_AIF_OUT("MM_UL2", "MultiMedia2 Capture", 0, 0, 0, 0),
|
||||
SND_SOC_DAPM_AIF_OUT("MM_UL4", "MultiMedia4 Capture", 0, 0, 0, 0),
|
||||
SND_SOC_DAPM_AIF_OUT("MM_UL5", "MultiMedia5 Capture", 0, 0, 0, 0),
|
||||
SND_SOC_DAPM_AIF_OUT("MM_UL8", "MultiMedia8 Capture", 0, 0, 0, 0),
|
||||
SND_SOC_DAPM_AIF_OUT("MM_UL9", "MultiMedia9 Capture", 0, 0, 0, 0),
|
||||
SND_SOC_DAPM_AIF_IN("CS-VOICE_DL1", "CS-VOICE Playback", 0, 0, 0, 0),
|
||||
SND_SOC_DAPM_AIF_OUT("CS-VOICE_UL1", "CS-VOICE Capture", 0, 0, 0, 0),
|
||||
|
@ -3400,6 +3426,8 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
|
|||
mmul4_mixer_controls, ARRAY_SIZE(mmul4_mixer_controls)),
|
||||
SND_SOC_DAPM_MIXER("MultiMedia5 Mixer", SND_SOC_NOPM, 0, 0,
|
||||
mmul5_mixer_controls, ARRAY_SIZE(mmul5_mixer_controls)),
|
||||
SND_SOC_DAPM_MIXER("MultiMedia8 Mixer", SND_SOC_NOPM, 0, 0,
|
||||
mmul8_mixer_controls, ARRAY_SIZE(mmul8_mixer_controls)),
|
||||
SND_SOC_DAPM_MIXER("AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
|
||||
auxpcm_rx_mixer_controls, ARRAY_SIZE(auxpcm_rx_mixer_controls)),
|
||||
SND_SOC_DAPM_MIXER("SEC_AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
|
||||
|
@ -3594,12 +3622,16 @@ static const struct snd_soc_dapm_route intercon[] = {
|
|||
|
||||
{"MultiMedia1 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"},
|
||||
{"MultiMedia4 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"},
|
||||
{"MultiMedia8 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"},
|
||||
{"MultiMedia1 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"},
|
||||
{"MultiMedia4 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"},
|
||||
{"MultiMedia8 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"},
|
||||
{"MultiMedia1 Mixer", "SLIM_4_TX", "SLIMBUS_4_TX"},
|
||||
{"MultiMedia1 Mixer", "SLIM_6_TX", "SLIMBUS_6_TX"},
|
||||
{"MultiMedia4 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
|
||||
{"MultiMedia8 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
|
||||
{"MultiMedia4 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
|
||||
{"MultiMedia8 Mixer", "PRI_MI2S_TX", "PRI_MI2S_TX"},
|
||||
{"MultiMedia5 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"},
|
||||
{"MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
|
||||
{"MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
|
||||
|
@ -3696,18 +3728,22 @@ static const struct snd_soc_dapm_route intercon[] = {
|
|||
{"MultiMedia1 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
|
||||
{"MultiMedia4 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
|
||||
{"MultiMedia5 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
|
||||
{"MultiMedia8 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"},
|
||||
{"MultiMedia1 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
|
||||
{"MultiMedia4 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
|
||||
{"MultiMedia5 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
|
||||
{"MultiMedia8 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
|
||||
|
||||
{"MultiMedia1 Mixer", "AFE_PCM_TX", "PCM_TX"},
|
||||
{"MultiMedia4 Mixer", "AFE_PCM_TX", "PCM_TX"},
|
||||
{"MultiMedia5 Mixer", "AFE_PCM_TX", "PCM_TX"},
|
||||
{"MultiMedia8 Mixer", "AFE_PCM_TX", "PCM_TX"},
|
||||
{"MM_UL1", NULL, "MultiMedia1 Mixer"},
|
||||
{"MultiMedia2 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"},
|
||||
{"MM_UL2", NULL, "MultiMedia2 Mixer"},
|
||||
{"MM_UL4", NULL, "MultiMedia4 Mixer"},
|
||||
{"MM_UL5", NULL, "MultiMedia5 Mixer"},
|
||||
{"MM_UL8", NULL, "MultiMedia8 Mixer"},
|
||||
|
||||
{"AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"},
|
||||
{"AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"},
|
||||
|
|
Loading…
Reference in a new issue