Merge "dsp: add incall stereo capture"

This commit is contained in:
qctecmdr 2019-05-07 22:35:09 -07:00 • committed by Gerrit - the friendly Code Review server
commit a76475b412
3 changed files with 103 additions and 8 deletions

View file

@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
*/
#include <linux/init.h>
@ -24,6 +24,9 @@
#define DRV_NAME "msm-pcm-voice-v2"
#define NUM_CHANNELS_MONO 1
#define NUM_CHANNELS_STEREO 2
static struct msm_voice voice_info[VOICE_SESSION_INDEX_MAX];
static struct snd_pcm_hardware msm_pcm_hardware = {
@ -616,6 +619,38 @@ done:
return ret;
}
static int msm_voice_rec_config_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = 0;
int voc_rec_config_channels = ucontrol->value.integer.value[0];
if (voc_rec_config_channels < NUM_CHANNELS_MONO ||
voc_rec_config_channels > NUM_CHANNELS_STEREO) {
pr_err("%s: Invalid channel config (%d)\n", __func__,
voc_rec_config_channels);
ret = -EINVAL;
goto done;
}
voc_set_incall_capture_channel_config(voc_rec_config_channels);
done:
pr_debug("%s: voc_rec_config_channels = %d, ret = %d\n", __func__,
voc_rec_config_channels, ret);
return ret;
}
static int msm_voice_rec_config_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
ucontrol->value.integer.value[0] =
voc_get_incall_capture_channel_config();
pr_debug("%s: rec_config_channels = %ld\n", __func__,
ucontrol->value.integer.value[0]);
return 0;
}
static int msm_voice_cvd_version_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
@ -678,6 +713,12 @@ static struct snd_kcontrol_new msm_voice_controls[] = {
msm_voice_mbd_put),
};
static struct snd_kcontrol_new msm_voice_rec_config_controls[] = {
SOC_SINGLE_MULTI_EXT("Voc Rec Config", SND_SOC_NOPM, 0,
2, 0, 1, msm_voice_rec_config_get,
msm_voice_rec_config_put),
};
static const struct snd_pcm_ops msm_pcm_ops = {
.open = msm_pcm_open,
.hw_params = msm_pcm_hw_params,
@ -703,7 +744,8 @@ static int msm_pcm_voice_probe(struct snd_soc_component *component)
{
snd_soc_add_component_controls(component, msm_voice_controls,
ARRAY_SIZE(msm_voice_controls));
snd_soc_add_component_controls(component, msm_voice_rec_config_controls,
ARRAY_SIZE(msm_voice_rec_config_controls));
return 0;
}

View file

@ -98,7 +98,8 @@ static void voice_unload_topo_modules(void);
static int voice_cvs_stop_playback(struct voice_data *v);
static int voice_cvs_start_playback(struct voice_data *v);
static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode);
static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode,
uint32_t port_id);
static int voice_cvs_stop_record(struct voice_data *v);
static int32_t qdsp_mvm_callback(struct apr_client_data *data, void *priv);
@ -4411,7 +4412,8 @@ static int voice_setup_vocproc(struct voice_data *v)
/* Start in-call recording if this feature is enabled */
if (v->rec_info.rec_enable)
voice_cvs_start_record(v, v->rec_info.rec_mode);
voice_cvs_start_record(v, v->rec_info.rec_mode,
v->rec_info.port_id);
if (v->dtmf_rx_detect_en)
voice_send_dtmf_rx_detection_cmd(v, v->dtmf_rx_detect_en);
@ -5056,7 +5058,8 @@ static int voice_destroy_vocproc(struct voice_data *v)
if (v->rec_info.rec_enable) {
voice_cvs_start_record(
&common.voice[VOC_PATH_PASSIVE],
v->rec_info.rec_mode);
v->rec_info.rec_mode,
v->rec_info.port_id);
common.srvcc_rec_flag = true;
pr_debug("%s: switch recording, srvcc_rec_flag %d\n",
@ -5565,7 +5568,8 @@ static int voice_send_vol_step_cmd(struct voice_data *v)
return 0;
}
static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode)
static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode,
uint32_t port_id)
{
int ret = 0;
void *apr_cvs;
@ -5616,6 +5620,18 @@ static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode)
VSS_IRECORD_TAP_POINT_STREAM_END;
cvs_start_record.rec_mode.tx_tap_point =
VSS_IRECORD_TAP_POINT_STREAM_END;
if (common.rec_channel_count ==
NUM_CHANNELS_STEREO) {
/*
* if channel count is not stereo,
* then default port_id and mode
* (mono) will be used
*/
cvs_start_record.rec_mode.mode =
VSS_IRECORD_MODE_TX_RX_STEREO;
cvs_start_record.rec_mode.port_id =
port_id;
}
} else {
pr_err("%s: Invalid in-call rec_mode %d\n", __func__,
rec_mode);
@ -5774,6 +5790,7 @@ int voc_start_record(uint32_t port_id, uint32_t set, uint32_t session_id)
mutex_lock(&v->lock);
rec_mode = v->rec_info.rec_mode;
v->rec_info.port_id = port_id;
rec_set = set;
if (set) {
if ((v->rec_route_state.ul_flag != 0) &&
@ -5850,7 +5867,8 @@ int voc_start_record(uint32_t port_id, uint32_t set, uint32_t session_id)
if (cvs_handle != 0) {
if (rec_set)
ret = voice_cvs_start_record(v, rec_mode);
ret = voice_cvs_start_record(v, rec_mode,
port_id);
else
ret = voice_cvs_stop_record(v);
}
@ -6148,6 +6166,31 @@ int voc_disable_topology(uint32_t session_id, uint32_t disable)
}
EXPORT_SYMBOL(voc_disable_topology);
/**
* voc_set_incall_capture_channel_config -
* command to set channel count for record
*
* @channel_count: number of channels
*
*/
void voc_set_incall_capture_channel_config(int channel_count)
{
common.rec_channel_count = channel_count;
}
EXPORT_SYMBOL(voc_set_incall_capture_channel_config);
/**
* voc_get_incall_capture_channel_config -
* command to get channel count for record
*
* Returns number of channels configured for record
*/
int voc_get_incall_capture_channel_config(void)
{
return common.rec_channel_count;
}
EXPORT_SYMBOL(voc_get_incall_capture_channel_config);
static int voice_set_packet_exchange_mode_and_config(uint32_t session_id,
uint32_t mode)
{
@ -9907,6 +9950,12 @@ int __init voice_init(void)
/* Initialize Per-Vocoder Calibration flag */
common.is_per_vocoder_cal_enabled = false;
/*
* Initialize in call record channel config
* to mono
*/
common.rec_channel_count = NUM_CHANNELS_MONO;
mutex_init(&common.common_lock);
common.uevent_data = kzalloc(sizeof(*(common.uevent_data)), GFP_KERNEL);

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
*/
#ifndef __QDSP6VOICE_H__
#define __QDSP6VOICE_H__
@ -1768,6 +1768,7 @@ struct incall_rec_info {
uint32_t rec_enable;
uint32_t rec_mode;
uint32_t recording;
uint32_t port_id;
};
struct incall_music_info {
@ -1946,6 +1947,7 @@ struct common_data {
bool sidetone_enable;
bool mic_break_enable;
struct audio_uevent_data *uevent_data;
int32_t rec_channel_count;
};
struct voice_session_itr {
@ -2079,6 +2081,8 @@ int voc_disable_topology(uint32_t session_id, uint32_t disable);
int voc_set_device_config(uint32_t session_id, uint8_t path_dir,
struct media_format_info *finfo);
uint32_t voice_get_topology(uint32_t topology_idx);
void voc_set_incall_capture_channel_config(int channel_count);
int voc_get_incall_capture_channel_config(void);
int voice_set_topology_specific_info(struct voice_data *v,
uint32_t topology_idx);
int voc_set_sound_focus(struct sound_focus_param sound_focus_param);