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

Commit f9465174 authored by Ravi Kumar Alamanda's avatar Ravi Kumar Alamanda Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: qdsp6: Add support for audio post processing effects



Add interface to support configuring equlaizer, bass boost,
virtualizer and reverb effects in DSP for tunnel mode of
playback.

Change-Id: Ie1512e340315302691327b6379a0935170dc57a7
Signed-off-by: default avatarSubhash Chandra Bose Naripeddy <snariped@codeaurora.org>
Signed-off-by: default avatarRavi Kumar Alamanda <ralama@codeaurora.org>
parent 88a06b81
Loading
Loading
Loading
Loading
+200 −0
Original line number Diff line number Diff line
@@ -6309,6 +6309,206 @@ struct asm_eq_params {
#define VOICE_CMD_GET_PARAM				0x0001133E
#define VOICE_EVT_GET_PARAM_ACK				0x00011008


/** ID of the Bass Boost module.
    This module supports the following parameter IDs:
    - #AUDPROC_PARAM_ID_BASS_BOOST_ENABLE
    - #AUDPROC_PARAM_ID_BASS_BOOST_MODE
    - #AUDPROC_PARAM_ID_BASS_BOOST_STRENGTH
*/
#define AUDPROC_MODULE_ID_BASS_BOOST                             0x000108A1
/** ID of the Bass Boost enable parameter used by
    AUDPROC_MODULE_ID_BASS_BOOST.
*/
#define AUDPROC_PARAM_ID_BASS_BOOST_ENABLE                       0x000108A2
/** ID of the Bass Boost mode parameter used by
    AUDPROC_MODULE_ID_BASS_BOOST.
*/
#define AUDPROC_PARAM_ID_BASS_BOOST_MODE                         0x000108A3
/** ID of the Bass Boost strength parameter used by
    AUDPROC_MODULE_ID_BASS_BOOST.
*/
#define AUDPROC_PARAM_ID_BASS_BOOST_STRENGTH                     0x000108A4

/** ID of the Virtualizer module. This module supports the
    following parameter IDs:
    - #AUDPROC_PARAM_ID_VIRTUALIZER_ENABLE
    - #AUDPROC_PARAM_ID_VIRTUALIZER_STRENGTH
    - #AUDPROC_PARAM_ID_VIRTUALIZER_OUT_TYPE
    - #AUDPROC_PARAM_ID_VIRTUALIZER_GAIN_ADJUST
*/
#define AUDPROC_MODULE_ID_VIRTUALIZER                            0x000108A5
/** ID of the Virtualizer enable parameter used by
    AUDPROC_MODULE_ID_VIRTUALIZER.
*/
#define AUDPROC_PARAM_ID_VIRTUALIZER_ENABLE                      0x000108A6
/** ID of the Virtualizer strength parameter used by
    AUDPROC_MODULE_ID_VIRTUALIZER.
*/
#define AUDPROC_PARAM_ID_VIRTUALIZER_STRENGTH                    0x000108A7
/** ID of the Virtualizer out type parameter used by
    AUDPROC_MODULE_ID_VIRTUALIZER.
*/
#define AUDPROC_PARAM_ID_VIRTUALIZER_OUT_TYPE                    0x000108A8
/** ID of the Virtualizer out type parameter used by
    AUDPROC_MODULE_ID_VIRTUALIZER.
*/
#define AUDPROC_PARAM_ID_VIRTUALIZER_GAIN_ADJUST                 0x000108A9

/** ID of the Reverb module. This module supports the following
    parameter IDs:
    - #AUDPROC_PARAM_ID_REVERB_ENABLE
    - #AUDPROC_PARAM_ID_REVERB_MODE
    - #AUDPROC_PARAM_ID_REVERB_PRESET
    - #AUDPROC_PARAM_ID_REVERB_WET_MIX
    - #AUDPROC_PARAM_ID_REVERB_GAIN_ADJUST
    - #AUDPROC_PARAM_ID_REVERB_ROOM_LEVEL
    - #AUDPROC_PARAM_ID_REVERB_ROOM_HF_LEVEL
    - #AUDPROC_PARAM_ID_REVERB_DECAY_TIME
    - #AUDPROC_PARAM_ID_REVERB_DECAY_HF_RATIO
    - #AUDPROC_PARAM_ID_REVERB_REFLECTIONS_LEVEL
    - #AUDPROC_PARAM_ID_REVERB_REFLECTIONS_DELAY
    - #AUDPROC_PARAM_ID_REVERB_LEVEL
    - #AUDPROC_PARAM_ID_REVERB_DELAY
    - #AUDPROC_PARAM_ID_REVERB_DIFFUSION
    - #AUDPROC_PARAM_ID_REVERB_DENSITY
*/
#define AUDPROC_MODULE_ID_REVERB                          0x000108AA
/** ID of the Reverb enable parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_ENABLE                    0x000108AB
/** ID of the Reverb mode parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_MODE                      0x000108AC
/** ID of the Reverb preset parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_PRESET                    0x000108AD
/** ID of the Reverb wet mix parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_WET_MIX                   0x000108AE
/** ID of the Reverb gain adjust parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_GAIN_ADJUST               0x000108AF
/** ID of the Reverb room level parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_ROOM_LEVEL                0x000108B0
/** ID of the Reverb room hf level parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_ROOM_HF_LEVEL             0x000108B1
/** ID of the Reverb decay time parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_DECAY_TIME                0x000108B2
/** ID of the Reverb decay hf ratio parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_DECAY_HF_RATIO            0x000108B3
/** ID of the Reverb reflections level parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_REFLECTIONS_LEVEL         0x000108B4
/** ID of the Reverb reflections delay parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_REFLECTIONS_DELAY         0x000108B5
/** ID of the Reverb level parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_LEVEL                      0x000108B6
/** ID of the Reverb delay parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_DELAY                      0x000108B7
/** ID of the Reverb diffusion parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_DIFFUSION                  0x000108B8
/** ID of the Reverb density parameter used by
    AUDPROC_MODULE_ID_REVERB.
*/
#define AUDPROC_PARAM_ID_REVERB_DENSITY                    0x000108B9

/** ID of the Popless Equalizer module. This module supports the
    following parameter IDs:
    - #AUDPROC_PARAM_ID_EQ_ENABLE
    - #AUDPROC_PARAM_ID_EQ_CONFIG
    - #AUDPROC_PARAM_ID_EQ_NUM_BANDS
    - #AUDPROC_PARAM_ID_EQ_BAND_LEVELS
    - #AUDPROC_PARAM_ID_EQ_BAND_LEVEL_RANGE
    - #AUDPROC_PARAM_ID_EQ_BAND_FREQS
    - #AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ_RANGE
    - #AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ
    - #AUDPROC_PARAM_ID_EQ_BAND_INDEX
    - #AUDPROC_PARAM_ID_EQ_PRESET_ID
    - #AUDPROC_PARAM_ID_EQ_NUM_PRESETS
    - #AUDPROC_PARAM_ID_EQ_GET_PRESET_NAME
*/
#define AUDPROC_MODULE_ID_POPLESS_EQUALIZER                    0x000108BA
/** ID of the Popless Equalizer enable parameter used by
    AUDPROC_MODULE_ID_POPLESS_EQUALIZER.
*/
#define AUDPROC_PARAM_ID_EQ_ENABLE                             0x000108BB
/** ID of the Popless Equalizer config parameter used by
    AUDPROC_MODULE_ID_POPLESS_EQUALIZER.
*/
#define AUDPROC_PARAM_ID_EQ_CONFIG                             0x000108BC
/** ID of the Popless Equalizer number of bands parameter used
    by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is
    used for get param only.
*/
#define AUDPROC_PARAM_ID_EQ_NUM_BANDS                          0x000108BD
/** ID of the Popless Equalizer band levels parameter used by
    AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is
    used for get param only.
*/
#define AUDPROC_PARAM_ID_EQ_BAND_LEVELS                        0x000108BE
/** ID of the Popless Equalizer band level range parameter used
    by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is
    used for get param only.
*/
#define AUDPROC_PARAM_ID_EQ_BAND_LEVEL_RANGE                   0x000108BF
/** ID of the Popless Equalizer band frequencies parameter used
    by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is
    used for get param only.
*/
#define AUDPROC_PARAM_ID_EQ_BAND_FREQS                         0x000108C0
/** ID of the Popless Equalizer single band frequency range
    parameter used by AUDPROC_MODULE_ID_POPLESS_EQUALIZER.
    This param ID is used for get param only.
*/
#define AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ_RANGE             0x000108C1
/** ID of the Popless Equalizer single band frequency parameter
    used by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID
    is used for set param only.
*/
#define AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ                   0x000108C2
/** ID of the Popless Equalizer band index parameter used by
    AUDPROC_MODULE_ID_POPLESS_EQUALIZER.
*/
#define AUDPROC_PARAM_ID_EQ_BAND_INDEX                         0x000108C3
/** ID of the Popless Equalizer preset id parameter used by
    AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is used
    for get param only.
*/
#define AUDPROC_PARAM_ID_EQ_PRESET_ID                          0x000108C4
/** ID of the Popless Equalizer number of presets parameter used
    by AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is used
    for get param only.
*/
#define AUDPROC_PARAM_ID_EQ_NUM_PRESETS                        0x000108C5
/** ID of the Popless Equalizer preset name parameter used by
    AUDPROC_MODULE_ID_POPLESS_EQUALIZER. This param ID is used
    for get param only.
*/
#define AUDPROC_PARAM_ID_EQ_PRESET_NAME                        0x000108C6

/* Set Q6 topologies */
#define ASM_CMD_ADD_TOPOLOGIES				0x00010DBE
#define ADM_CMD_ADD_TOPOLOGIES				0x00010335
+3 −0
Original line number Diff line number Diff line
@@ -377,6 +377,9 @@ int q6asm_set_mute(struct audio_client *ac, int muteflag);

int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);

int q6asm_send_audio_effects_params(struct audio_client *ac, char *params,
				    uint32_t params_length);

/* Client can set the IO mode to either AIO/SIO mode */
int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);

+52 −0
Original line number Diff line number Diff line
@@ -3990,6 +3990,58 @@ fail_cmd:
	return -EINVAL;
}

int q6asm_send_audio_effects_params(struct audio_client *ac, char *params,
				    uint32_t params_length)
{
	char *asm_params = NULL;
	struct apr_hdr hdr;
	struct asm_stream_cmd_set_pp_params_v2 payload_params;
	int sz, rc;

	pr_debug("%s\n", __func__);
	if (!ac || ac->apr == NULL || params == NULL) {
		pr_err("APR handle NULL or params NULL\n");
		return -EINVAL;
	}
	sz = sizeof(struct apr_hdr) +
	     sizeof(struct asm_stream_cmd_set_pp_params_v2) +
	     params_length;
	asm_params = kzalloc(sz, GFP_KERNEL);
	if (!asm_params) {
		pr_err("%s, adm params memory alloc failed", __func__);
		return -ENOMEM;
	}
	q6asm_add_hdr_async(ac, &hdr, (sizeof(struct apr_hdr) +
			    sizeof(struct asm_stream_cmd_set_pp_params_v2) +
			    params_length), TRUE);
	hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
	payload_params.data_payload_addr_lsw = 0;
	payload_params.data_payload_addr_msw = 0;
	payload_params.mem_map_handle = 0;
	payload_params.data_payload_size = params_length;
	memcpy(((u8 *)asm_params), &hdr, sizeof(struct apr_hdr));
	memcpy(((u8 *)asm_params + sizeof(struct apr_hdr)), &payload_params,
		sizeof(struct asm_stream_cmd_set_pp_params_v2));
	memcpy(((u8 *)asm_params + sizeof(struct apr_hdr) +
		 sizeof(struct asm_stream_cmd_set_pp_params_v2)),
		params, params_length);
	rc = apr_send_pkt(ac->apr, (uint32_t *) asm_params);
	if (rc < 0) {
		pr_err("%s: audio effects set-params send failed\n", __func__);
		goto fail_send_param;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) == 0), 1*HZ);
	if (!rc) {
		pr_err("%s: timeout, audio effects set-params\n", __func__);
		goto fail_send_param;
	}
	rc = 0;
fail_send_param:
	kfree(asm_params);
	return rc;
}

static int __q6asm_cmd(struct audio_client *ac, int cmd, uint32_t stream_id)
{
	struct apr_hdr hdr;