dsp: add CELT encoder support

Add CELT encoder support to enable audio broadcast over split a2dp.

Change-Id: If0d927913c5e525ff1cebf857323ab70be2122a1
Signed-off-by: Preetam Singh Ranawat <apranawat@codeaurora.org>
This commit is contained in:
Preetam Singh Ranawat 2017-09-04 11:42:26 +05:30 committed by Gerrit - the friendly Code Review server
parent 8f7ccc2e6f
commit 5402849018
3 changed files with 64 additions and 5 deletions

View file

@ -49,6 +49,7 @@ enum {
ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
};
enum {
@ -2146,7 +2147,12 @@ static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
case ENC_FMT_APTX_HD:
memcpy(ucontrol->value.bytes.data + format_size,
&dai_data->enc_config.data,
sizeof(struct asm_aac_enc_cfg_v2_t));
sizeof(struct asm_custom_enc_cfg_t));
break;
case ENC_FMT_CELT:
memcpy(ucontrol->value.bytes.data + format_size,
&dai_data->enc_config.data,
sizeof(struct asm_celt_enc_cfg_t));
break;
default:
pr_debug("%s: unknown format = %d\n",
@ -2190,7 +2196,12 @@ static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
case ENC_FMT_APTX_HD:
memcpy(&dai_data->enc_config.data,
ucontrol->value.bytes.data + format_size,
sizeof(struct asm_custom_enc_cfg_aptx_t));
sizeof(struct asm_custom_enc_cfg_t));
break;
case ENC_FMT_CELT:
memcpy(&dai_data->enc_config.data,
ucontrol->value.bytes.data + format_size,
sizeof(struct asm_celt_enc_cfg_t));
break;
default:
pr_debug("%s: Ignore enc config for unknown format = %d\n",

View file

@ -2824,7 +2824,8 @@ static int q6afe_send_enc_config(u16 port_id,
pr_debug("%s:update DSP for enc format = %d\n", __func__, format);
if (format != ASM_MEDIA_FMT_SBC && format != ASM_MEDIA_FMT_AAC_V2 &&
format != ASM_MEDIA_FMT_APTX && format != ASM_MEDIA_FMT_APTX_HD) {
format != ASM_MEDIA_FMT_APTX && format != ASM_MEDIA_FMT_APTX_HD &&
format != ASM_MEDIA_FMT_CELT) {
pr_err("%s:Unsuppported format Ignore AFE config\n", __func__);
return 0;
}

View file

@ -3252,7 +3252,7 @@ struct asm_aac_enc_cfg_v2_t {
#define PCM_CHANNEL_R 2
#define PCM_CHANNEL_C 3
struct asm_custom_enc_cfg_aptx_t {
struct asm_custom_enc_cfg_t {
uint32_t sample_rate;
/* Mono or stereo */
uint16_t num_channels;
@ -3263,6 +3263,52 @@ struct asm_custom_enc_cfg_aptx_t {
uint8_t channel_mapping[8];
uint32_t custom_size;
} __packed;
#define ASM_MEDIA_FMT_CELT 0x00013221
struct asm_celt_specific_enc_cfg_t {
/*
* Bit rate used for encoding.
* This is used to calculate the upper threshold
* for bytes per frame if vbr_flag is 1.
* Or else, this will be used as a regular constant
* bit rate for encoder output.
* @Range : 32000 to 1536000
* @Default: 128
*/
uint32_t bit_rate;
/*
* Frame size used for encoding.
* @Range : 64, 128, 256, 512
* @Default: 256
*/
uint16_t frame_size;
/*
* complexity of algorithm.
* @Range : 0-10
* @Default: 3
*/
uint16_t complexity;
/*
* Switch variable for prediction feature.
* Used to choose between the level of interframe
* predictions allowed while encoding.
* @Range:
* 0: Independent Frames.
* 1: Short Term interframe prediction allowed.
* 2: Long term prediction allowed.
* @Default: 2
*/
uint16_t prediction_mode;
/*
* Variable Bit Rate flag.
* @Default: 0
*/
uint16_t vbr_flag;
} __packed;
struct asm_celt_enc_cfg_t {
struct asm_custom_enc_cfg_t custom_config;
struct asm_celt_specific_enc_cfg_t celt_specific_config;
} __packed;
struct afe_enc_fmt_id_param_t {
/*
@ -3331,7 +3377,8 @@ struct afe_port_media_type_t {
union afe_enc_config_data {
struct asm_sbc_enc_cfg_t sbc_config;
struct asm_aac_enc_cfg_v2_t aac_config;
struct asm_custom_enc_cfg_aptx_t aptx_config;
struct asm_custom_enc_cfg_t custom_config;
struct asm_celt_enc_cfg_t celt_config;
};
struct afe_enc_config {