Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19b2677c authored by Dhananjay Kumar's avatar Dhananjay Kumar Committed by Matt Wagantall
Browse files

ASoC: msm: Add support to enable PBE in DSP



Add interface to support configuring pbe effects
in DSP for offload playback.
PBE provides BassBoost support on small devices
like handset speaker.
Handset speakers are too small to produce proper
Bass, hence PBE is introduced, which adds effect
similar to BassBoost but suitable for small devices.

Change-Id: Ic66f3073cb259c8ef593a1ad6aa06d14efbfb058
Signed-off-by: default avatarwjiang <wjiang@codeaurora.org>
Signed-off-by: default avatarDhananjay Kumar <dhakumar@codeaurora.org>
parent 5c8471f9
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
@@ -368,6 +368,15 @@ static long audio_effects_set_pp_param(struct q6audio_effects *effects,
				&(effects->audio_effects.bass_boost),
				(long *)&values[1]);
		break;
	case PBE_MODULE:
		pr_debug("%s: PBE_MODULE\n", __func__);
		if (msm_audio_effects_is_effmodule_supp_in_top(
			effects_module, effects->ac->topology))
			msm_audio_effects_pbe_handler(
				effects->ac,
				&(effects->audio_effects.pbe),
				(long *)&values[1]);
		break;
	case EQ_MODULE:
		pr_debug("%s: EQ_MODULE\n", __func__);
		if (msm_audio_effects_is_effmodule_supp_in_top(
+15 −0
Original line number Diff line number Diff line
@@ -6682,6 +6682,21 @@ struct asm_eq_params {
*/
#define AUDPROC_PARAM_ID_BASS_BOOST_STRENGTH                     0x000108A4

/** ID of the PBE module.
    This module supports the following parameter IDs:
    - #AUDPROC_PARAM_ID_PBE_ENABLE
    - #AUDPROC_PARAM_ID_PBE_PARAM_CONFIG
*/
#define AUDPROC_MODULE_ID_PBE                                    0x00010C2A
/** ID of the Bass Boost enable parameter used by
    AUDPROC_MODULE_ID_BASS_BOOST.
*/
#define AUDPROC_PARAM_ID_PBE_ENABLE                              0x00010C2B
/** ID of the Bass Boost mode parameter used by
    AUDPROC_MODULE_ID_BASS_BOOST.
*/
#define AUDPROC_PARAM_ID_PBE_PARAM_CONFIG                        0x00010C49

/** ID of the Virtualizer module. This module supports the
    following parameter IDs:
    - #AUDPROC_PARAM_ID_VIRTUALIZER_ENABLE
+6 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -30,6 +30,11 @@ int msm_audio_effects_reverb_handler(struct audio_client *ac,
int msm_audio_effects_bass_boost_handler(struct audio_client *ac,
					struct bass_boost_params *bass_boost,
					long *values);

int msm_audio_effects_pbe_handler(struct audio_client *ac,
					struct pbe_params *pbe,
					long *values);

int msm_audio_effects_virtualizer_handler(struct audio_client *ac,
				struct virtualizer_params *virtualizer,
				long *values);
+55 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -150,6 +150,15 @@
#define SOFT_VOLUME2_GAIN_MASTER_PARAM_LEN	\
					SOFT_VOLUME_GAIN_MASTER_PARAM_LEN

#define PBE_CONF_MODULE_ID	0x00010C2A
#define PBE_CONF_PARAM_ID	0x00010C49

#define PBE_MODULE		0x00008000
#define PBE_ENABLE		0x00008001
#define PBE_CONFIG		0x00008002
#define PBE_ENABLE_PARAM_LEN		1
#define PBE_CONFIG_PARAM_LEN		28

#define COMMAND_PAYLOAD_LEN	3
#define COMMAND_PAYLOAD_SZ	(COMMAND_PAYLOAD_LEN * sizeof(uint32_t))
#define MAX_INBAND_PARAM_SZ	4096
@@ -295,6 +304,50 @@ struct eq_params {
	uint32_t freq_millihertz;
};

#define PBE_ENABLE_PARAM_SZ	\
			(PBE_ENABLE_PARAM_LEN*sizeof(uint32_t))
#define PBE_CONFIG_PARAM_SZ	\
			(PBE_CONFIG_PARAM_LEN*sizeof(uint16_t))
struct pbe_config_t {
	int16_t  real_bass_mix;
	int16_t  bass_color_control;
	uint16_t main_chain_delay;
	uint16_t xover_filter_order;
	uint16_t bandpass_filter_order;
	int16_t  drc_delay;
	uint16_t rms_tav;
	int16_t exp_threshold;
	uint16_t exp_slope;
	int16_t comp_threshold;
	uint16_t comp_slope;
	uint16_t makeup_gain;
	uint32_t comp_attack;
	uint32_t comp_release;
	uint32_t exp_attack;
	uint32_t exp_release;
	int16_t limiter_bass_threshold;
	int16_t limiter_high_threshold;
	int16_t limiter_bass_makeup_gain;
	int16_t limiter_high_makeup_gain;
	int16_t limiter_bass_gc;
	int16_t limiter_high_gc;
	int16_t  limiter_delay;
	uint16_t reserved;
	/* place holder for filter coeffs to be followed */
	int32_t p1LowPassCoeffs[5*2];
	int32_t p1HighPassCoeffs[5*2];
	int32_t p1BandPassCoeffs[5*3];
	int32_t p1BassShelfCoeffs[5];
	int32_t p1TrebleShelfCoeffs[5];
} __packed;

struct pbe_params {
	uint32_t device;
	uint32_t enable_flag;
	uint32_t cfg_len;
	struct pbe_config_t config;
};

#define SOFT_VOLUME_ENABLE_PARAM_SZ		\
			(SOFT_VOLUME_ENABLE_PARAM_LEN*sizeof(uint32_t))
#define SOFT_VOLUME_GAIN_MASTER_PARAM_SZ	\
@@ -311,6 +364,7 @@ struct soft_volume_params {

struct msm_nt_eff_all_config {
	struct bass_boost_params bass_boost;
	struct pbe_params pbe;
	struct virtualizer_params virtualizer;
	struct reverb_params reverb;
	struct eq_params equalizer;
+84 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ bool msm_audio_effects_is_effmodule_supp_in_top(int effect_module,
	case VIRTUALIZER_MODULE:
	case REVERB_MODULE:
	case BASS_BOOST_MODULE:
	case PBE_MODULE:
	case EQ_MODULE:
		switch (topology) {
		case ASM_STREAM_POSTPROC_TOPO_ID_SA_PLUS:
@@ -659,6 +660,89 @@ invalid_config:
	return rc;
}

int msm_audio_effects_pbe_handler(struct audio_client *ac,
					struct pbe_params *pbe,
					long *values)
{
	int devices = *values++;
	int num_commands = *values++;
	char *params;
	int *updt_params, i, j, prev_enable_flag;
	uint32_t params_length = (MAX_INBAND_PARAM_SZ);
	int rc = 0;

	pr_debug("%s\n", __func__);
	if (!ac) {
		pr_err("%s: cannot set audio effects\n", __func__);
		return -EINVAL;
	}
	params = kzalloc(params_length, GFP_KERNEL);
	if (!params) {
		pr_err("%s, params memory alloc failed\n", __func__);
		return -ENOMEM;
	}
	pr_debug("%s: device: %d\n", __func__, devices);
	updt_params = (int *)params;
	params_length = 0;
	for (i = 0; i < num_commands; i++) {
		uint32_t command_id = *values++;
		uint32_t command_config_state = *values++;
		uint32_t index_offset = *values++;
		uint32_t length = *values++;
		switch (command_id) {
		case PBE_ENABLE:
			pr_debug("%s: PBE_ENABLE\n", __func__);
			if (length != 1 || index_offset != 0) {
				pr_err("no valid params\n");
				rc = -EINVAL;
				goto invalid_config;
			}
			prev_enable_flag = pbe->enable_flag;
			pbe->enable_flag = *values++;
			if (prev_enable_flag != pbe->enable_flag) {
				*updt_params++ = AUDPROC_MODULE_ID_PBE;
				*updt_params++ =
					AUDPROC_PARAM_ID_PBE_ENABLE;
				*updt_params++ = PBE_ENABLE_PARAM_SZ;
				*updt_params++ = pbe->enable_flag;
				params_length += COMMAND_PAYLOAD_SZ +
					PBE_ENABLE_PARAM_SZ;
			}
			break;
		case PBE_CONFIG:
			pr_debug("%s: PBE_PARAM length %u\n", __func__, length);
			if (length > sizeof(struct pbe_config_t) ||
				length < PBE_CONFIG_PARAM_LEN ||
				index_offset != 0) {
				pr_err("no valid params, len %d\n", length);
				rc = -EINVAL;
				goto invalid_config;
			}
			if (command_config_state == CONFIG_SET) {
				*updt_params++ = AUDPROC_MODULE_ID_PBE;
				*updt_params++ =
					AUDPROC_PARAM_ID_PBE_PARAM_CONFIG;
				*updt_params++ = length;
				for (j = 0; j < length; ) {
					j += sizeof(*updt_params);
					*updt_params++ = *values++;
				}
				params_length += COMMAND_PAYLOAD_SZ + length;
			}
			break;
		default:
			pr_err("%s: Invalid command to set config\n", __func__);
			break;
		}
	}
	if (params_length)
		q6asm_send_audio_effects_params(ac, params,
						params_length);
invalid_config:
	kfree(params);
	return rc;
}

int msm_audio_effects_popless_eq_handler(struct audio_client *ac,
					 struct eq_params *eq,
					 long *values)
Loading