asoc:upgrade aw88261 driver to v 1.9.0.4

version 1.9.0.4;
add speaker spin function;
fix compile errors.

Change-Id: I1ef2a6b32d373cc87ec0615e1ed4b3709e13051e
Signed-off-by: yaozm1 <yaozm1@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2167927
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
yaozm1 authored and Gilberto Gambugge committed 2023-06-01 00:35:13 -03:00
1 parent 18e0cfd652
commit 6e3bdd99d8
6 files changed
+258 -8

No files matched your search

+167 -6
View File
@@ -35,7 +35,7 @@
#include "aw_log.h"
#include "aw_dsp.h"
#define AW882XX_DRIVER_VERSION "v1.9.0.3"
#define AW882XX_DRIVER_VERSION "v1.9.0.4"
#define AW882XX_I2C_NAME "aw882xxacf_smartpa"
#define AW_READ_CHIPID_RETRIES 5 /* 5 times */
@@ -48,11 +48,18 @@ static unsigned int g_algo_tx_en = false;
static unsigned int g_algo_copp_en = false;
#ifdef AW_SPIN_ENABLE
static unsigned int g_spin_value = 0;
static uint32_t g_spin_en = 0;
#endif
#ifdef AW882XX_RUNIN_TEST
static unsigned int g_runin_test;
#endif
#define AW882XX_SPIN_FOR_LOW_LATENCY_ONLY 1
#ifdef AW882XX_SPIN_FOR_LOW_LATENCY_ONLY
static unsigned int g_skt_prof_id = 0;
#endif
static DEFINE_MUTEX(g_aw882xx_lock);
struct aw_container *g_awinic_cfg = NULL;
@@ -1257,12 +1264,21 @@ static int aw882xx_set_spin(struct snd_kcontrol *kcontrol,
aw_dev = aw882xx->aw_pa;
ctrl_value = ucontrol->value.integer.value[0];
#ifdef AW882XX_SPIN_FOR_LOW_LATENCY_ONLY
if (g_skt_prof_id == (AW882XX_SCENE_FASTTRACK_ID+1)) {
#else
if (aw882xx->pstream) {
#endif
ret = aw_dev_set_spin(ctrl_value);
if (ret)
aw_dev_err(aw882xx->dev, "set spin error, ret=%d", ret);
} else {
#ifdef AW882XX_SPIN_FOR_LOW_LATENCY_ONLY
aw_dev_info(aw882xx->dev, "fasttrack stream no start");
#else
aw_dev_info(aw882xx->dev, "stream no start only record");
#endif
}
g_spin_value = ctrl_value;
@@ -1297,6 +1313,127 @@ static int aw882xx_get_spin(struct snd_kcontrol *kcontrol,
aw_dev_dbg(aw882xx->dev, "spin value is %ld", ucontrol->value.integer.value[0]);
return 0;
}
static int aw882xx_get_spin_status(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct aw_device *aw_dev;
aw_snd_soc_codec_t *codec =
aw_componet_codec_ops.kcontrol_codec(kcontrol);
struct aw882xx *aw882xx =
aw_componet_codec_ops.codec_get_drvdata(codec);
struct aw_spin_param spin_param;
int ctrl_value;
int ret = -EINVAL;
aw_dev = aw882xx->aw_pa;
if (aw882xx->pstream) {
ret = aw_dev_get_spin_param(aw_dev, &ctrl_value, &(spin_param.relase_time));
if (ret) {
aw_dev_err(aw882xx->dev, "get spin status failed!, ret = %d", ret);
ctrl_value = 0;
}
ucontrol->value.integer.value[0] = ctrl_value;
} else {
aw_dev_info(aw882xx->dev, "no stream, use record value");
}
aw_dev_dbg(aw882xx->dev, "spin value is %ld", ucontrol->value.integer.value[0]);
return 0;
}
static int aw882xx_set_spin_status(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = -EINVAL;
uint32_t ctrl_value = 0;
struct aw_device *aw_dev;
aw_snd_soc_codec_t *codec =
aw_componet_codec_ops.kcontrol_codec(kcontrol);
struct aw882xx *aw882xx =
aw_componet_codec_ops.codec_get_drvdata(codec);
struct aw_spin_param spin_param;
aw_dev_dbg(aw882xx->dev, "ucontrol->value.integer.value[0]=%ld",
ucontrol->value.integer.value[0]);
aw_dev = aw882xx->aw_pa;
ctrl_value = ucontrol->value.integer.value[0];
if (g_algo_rx_en == true) {
ret = aw_dev_set_spin_param(aw_dev, ctrl_value, spin_param.relase_time);
if (ret)
aw_dev_err(aw882xx->dev, "set spin status error, ret=%d", ret);
g_spin_en = ctrl_value;
} else {
aw_dev_info(aw882xx->dev, "stream no start only record");
}
return 0;
}
static int aw882xx_get_spin_relase_time(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct aw_device *aw_dev;
aw_snd_soc_codec_t *codec =
aw_componet_codec_ops.kcontrol_codec(kcontrol);
struct aw882xx *aw882xx =
aw_componet_codec_ops.codec_get_drvdata(codec);
struct aw_spin_param spin_param;
int ctrl_value;
int ret = -EINVAL;
aw_dev = aw882xx->aw_pa;
if (aw882xx->pstream) {
ret = aw_dev_get_spin_param(aw_dev, &(spin_param.enable), &ctrl_value);
if (ret) {
aw_dev_err(aw882xx->dev, "get spin release time failed!, ret = %d", ret);
ctrl_value = 0;
}
ucontrol->value.integer.value[0] = ctrl_value;
} else {
aw_dev_info(aw882xx->dev, "no stream, use record value");
}
aw_dev_dbg(aw882xx->dev, "spin value is %ld", ucontrol->value.integer.value[0]);
return 0;
}
static int aw882xx_set_spin_relase_time(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
int ret = -EINVAL;
uint32_t ctrl_value = 0;
struct aw_device *aw_dev;
aw_snd_soc_codec_t *codec =
aw_componet_codec_ops.kcontrol_codec(kcontrol);
struct aw882xx *aw882xx =
aw_componet_codec_ops.codec_get_drvdata(codec);
//struct aw_spin_param spin_param;
aw_dev_dbg(aw882xx->dev, "ucontrol->value.integer.value[0]=%ld",
ucontrol->value.integer.value[0]);
aw_dev = aw882xx->aw_pa;
ctrl_value = ucontrol->value.integer.value[0];
//if ((aw882xx->pstream) && (g_spin_en == 1) && (g_algo_rx_en == true)) {
if ( (g_spin_en == 1) && (g_algo_rx_en == true)) {
ret = aw_dev_set_spin_param(aw_dev, g_spin_en , ctrl_value);
if (ret)
aw_dev_err(aw882xx->dev, "set spin release time error, ret=%d", ret);
} else {
aw_dev_info(aw882xx->dev, "set release time failed");
}
return 0;
}
#endif
static int aw882xx_get_fade_in_time(struct snd_kcontrol *kcontrol,
@@ -1569,10 +1706,10 @@ static int aw882xx_update_algo_profile(struct aw882xx *aw882xx)
return 0;
}
aw_dev_info(aw882xx->dev, "algo scene switch. [new] %d,[old] %d",
aw_dev_info(aw882xx->dev, "algo scene switch. [new] %d,[old] %d",
new_skt_prof_id, cur_skt_prof_id);
aw882xx->cur_algo_prof_id = new_skt_prof_id;
aw_dev = aw882xx->aw_pa;
aw882xx->cur_algo_prof_id = new_skt_prof_id;
aw_dev = aw882xx->aw_pa;
/* set new scene pramas to skt */
ret = aw_dev_set_algo_prof(aw_dev, aw882xx->cur_algo_prof_id);
@@ -1580,10 +1717,27 @@ static int aw882xx_update_algo_profile(struct aw882xx *aw882xx)
aw_dev_err(aw882xx->dev, "set algo prof failed");
return -1;
}
aw_dev_info(aw882xx->dev, "algo scene hold, cur scene %d",
aw_dev_info(aw882xx->dev, "algo scene hold, cur scene %d",
new_skt_prof_id);
#ifdef AW882XX_SPIN_FOR_LOW_LATENCY_ONLY
aw_dev_info(aw882xx->dev, "g_skt_prof_id=%d\n",g_skt_prof_id);
if (new_skt_prof_id == (AW882XX_SCENE_FASTTRACK_ID+1)){
ret = aw_dev_set_spin(g_spin_value);
if (ret)
aw_dev_err(aw882xx->dev, "set spin error when switch prof id to %d, ret=%d", ret, new_skt_prof_id);
} else if ((g_skt_prof_id == (AW882XX_SCENE_FASTTRACK_ID+1))
&& (new_skt_prof_id != (AW882XX_SCENE_FASTTRACK_ID+1))){
ret = aw_dev_set_spin(1);
if (ret)
aw_dev_err(aw882xx->dev, "set spin error when switch prof id to %d, ret=%d", ret, new_skt_prof_id);
}
g_skt_prof_id = new_skt_prof_id;
#endif
return 0;
}
@@ -1887,6 +2041,10 @@ static struct snd_kcontrol_new aw882xx_controls[] = {
#ifdef AW_SPIN_ENABLE
SOC_ENUM_EXT("aw882xx_spin_switch", aw882xx_snd_enum[2],
aw882xx_get_spin, aw882xx_set_spin),
SOC_ENUM_EXT("aw882xx_spin_status", aw882xx_snd_enum[1],
aw882xx_get_spin_status, aw882xx_set_spin_status),
SOC_SINGLE_EXT("aw882xx_spin_relase_time", 0, 0, 1000000, 0,
aw882xx_get_spin_relase_time, aw882xx_set_spin_relase_time),
#endif
#ifdef AW882XX_RUNIN_TEST
SOC_ENUM_EXT("aw882xx_runin_test", aw882xx_snd_enum[1],
@@ -3104,3 +3262,6 @@ module_exit(aw882xx_i2c_exit);
MODULE_DESCRIPTION("ASoC AW882XX Smart PA Driver");
MODULE_LICENSE("GPL v2");
+6 -1
View File
@@ -2,6 +2,11 @@
#define _AW882XX_H_
#include <linux/version.h>
#include <linux/kernel.h>
#ifndef AW_SPIN_ENABLE
#define AW_SPIN_ENABLE 1
#endif
#include "aw_device.h"
/*
@@ -201,7 +206,7 @@ struct aw882xx {
int rate;
int pstream;
int cstream;
int aw882xx_ramp_status; /* ramp status */
int aw882xx_ramp_status; /* ramp status */
#ifdef CONFIG_AW882XX_ALGO_BIN_PARAMS
int aw882xx_algo_cali;
int aw882xx_algo_bypass;
+12
View File
@@ -1494,6 +1494,18 @@ int aw_dev_set_algo_params_path(struct aw_device *aw_dev)
return aw_dsp_set_algo_params_path(aw_dev);
}
#ifdef AW_SPIN_ENABLE
int aw_dev_set_spin_param(struct aw_device *aw_dev, uint32_t enable, uint32_t relase_time)
{
return aw_dsp_set_spin_param(aw_dev, enable, relase_time);
}
int aw_dev_get_spin_param(struct aw_device *aw_dev, uint32_t *enable, uint32_t *relase_time)
{
return aw_dsp_get_spin_param(aw_dev, enable, relase_time);
}
#endif
static void aw_device_parse_sound_channel_dt(struct aw_device *aw_dev)
{
int ret;
+4
View File
@@ -289,6 +289,10 @@ int aw_dev_set_algo_params_path(struct aw_device *aw_dev);
int aw_device_probe(struct aw_device *aw_dev);
int aw_device_remove(struct aw_device *aw_dev);
int aw_dev_get_list_head(struct list_head **head);
#ifdef AW_SPIN_ENABLE
int aw_dev_set_spin_param(struct aw_device *aw_dev, uint32_t enable, uint32_t relase_time);
int aw_dev_get_spin_param(struct aw_device *aw_dev, uint32_t* enable, uint32_t* relase_time);
#endif
#endif
+52
View File
@@ -48,6 +48,7 @@ static DEFINE_MUTEX(g_aw_dsp_lock);
#define AW_MSG_ID_REAL_DATA_L (0X10013D21)
#define AW_MSG_ID_REAL_DATA_R (0X10013D22)
#define AW_MSG_ID_SET_BIN_PARAMS (0X10013D30)
#define AW_MSG_ID_SPIN_ENABLE (0x10013D2F)
#define AFE_MSG_ID_MSG_0 (0X10013D2A)
#define AFE_MSG_ID_MSG_1 (0X10013D2B)
@@ -555,6 +556,57 @@ int aw_dsp_read_st(struct aw_device *aw_dev, int32_t *r0, int32_t *te)
return 0;
}
#ifdef AW_SPIN_ENABLE
int aw_dsp_get_spin_param(struct aw_device *aw_dev,
uint32_t *enable, uint32_t *relase_time)
{
int ret;
struct aw_spin_param spin_param;
ret = aw_read_data_from_dsp(AW_MSG_ID_SPIN_ENABLE,
&spin_param,
sizeof(spin_param));
if (ret) {
spin_param.enable = 0;
spin_param.relase_time = 0;
aw_pr_err("yao,read spin params failed ");
return ret;
}
*enable = spin_param.enable;
*relase_time = spin_param.relase_time;
aw_pr_info("yao,get spin params done");
return 0;
}
int aw_dsp_set_spin_param(struct aw_device *aw_dev,
uint32_t enable, uint32_t relase_time)
{
int ret;
struct aw_spin_param spin_param;
if (!enable) {
aw_pr_dbg("yao,need to set the rotation parameters");
return 0;
}
spin_param.enable = enable;
spin_param.relase_time = relase_time;
ret = aw_write_data_to_dsp(AW_MSG_ID_SPIN_ENABLE,
&spin_param,
sizeof(spin_param));
if (ret){
pr_err("yao,222,set spin params failed\n");
return -EINVAL;
}
pr_err("yao,222,set spin params with ret 0");
return 0;
}
#endif
int aw_dsp_read_spin(int *spin_mode)
{
int ret;
+17 -1
View File
@@ -3,6 +3,10 @@
#define AW_QCOM_PLATFORM
#ifndef AW_SPIN_ENABLE
#define AW_SPIN_ENABLE 1
#endif
/*factor form 12bit(4096) to 1000*/
#define AW_DSP_RE_TO_SHOW_RE(re) (((re) * (1000)) >> (12))
#define AW_SHOW_RE_TO_DSP_RE(re) (((re) << 12) / (1000))
@@ -31,6 +35,13 @@ enum {
#define AW_DSP_MSG_HDR_VER (1)
typedef struct aw_msg_hdr aw_dsp_msg_t;
#ifdef AW_SPIN_ENABLE
struct aw_spin_param {
uint32_t enable;
uint32_t relase_time;
};
#endif
int aw_dsp_write_msg(struct aw_device *aw_dev, uint32_t msg_id, char *data_ptr, unsigned int data_size);
int aw_dsp_read_msg(struct aw_device *aw_dev, uint32_t msg_id, char *data_ptr, unsigned int data_size);
int aw_dsp_write_cali_cfg(struct aw_device *aw_dev, char *data, unsigned int data_len);
@@ -61,6 +72,11 @@ int aw_dsp_get_algo_prof(struct aw_device *aw_dev, int *prof_id);
int aw_dsp_set_algo_params_path(struct aw_device *aw_dev);
void aw_device_parse_topo_id_dt(struct aw_device *aw_dev);
void aw_device_parse_port_id_dt(struct aw_device *aw_dev);
#ifdef AW_SPIN_ENABLE
int aw_dsp_set_spin_param(struct aw_device *aw_dev,
uint32_t enable, uint32_t relase_time);
int aw_dsp_get_spin_param(struct aw_device *aw_dev,
uint32_t *enable, uint32_t *relase_time);
#endif
#endif