Merge "ASOC: wcd934x: Fix finding of correct AMIC"
diff --git a/asoc/codecs/aqt1000/aqt1000-core.c b/asoc/codecs/aqt1000/aqt1000-core.c
index f6fee20..e6313c1 100644
--- a/asoc/codecs/aqt1000/aqt1000-core.c
+++ b/asoc/codecs/aqt1000/aqt1000-core.c
@@ -13,6 +13,8 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
#include <linux/slab.h>
#include <linux/ratelimit.h>
#include <linux/mfd/core.h>
@@ -21,6 +23,9 @@
#include <linux/debugfs.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+#include <linux/pm_runtime.h>
#include <sound/soc.h>
#include "../msm-cdc-pinctrl.h"
#include "../msm-cdc-supply.h"
@@ -93,8 +98,22 @@
regmap_update_bits(aqt->regmap, AQT1000_CLK_SYS_MCLK2_I2S_HS_CLK_PRG,
0x01, 0x01);
+ regmap_update_bits(aqt->regmap, AQT1000_CHIP_CFG0_CLK_CFG_MCLK,
+ 0x04, 0x00);
+
+ /* Add 100usec delay as per HW requirement */
+ usleep_range(100, 110);
+ regmap_update_bits(aqt->regmap, AQT1000_CDC_CLK_RST_CTRL_MCLK_CONTROL,
+ 0x01, 0x01);
+ regmap_update_bits(aqt->regmap, AQT1000_CDC_CLK_RST_CTRL_FS_CNT_CONTROL,
+ 0x01, 0x01);
+ regmap_update_bits(aqt->regmap, AQT1000_CHIP_CFG0_CLK_CTL_CDC_DIG,
+ 0x01, 0x01);
+
/* Codec digital reset */
regmap_update_bits(aqt->regmap, AQT1000_CHIP_CFG0_RST_CTL, 0x01, 0x01);
+ /* Add 100usec delay as per HW requirement */
+ usleep_range(100, 110);
return 0;
}
@@ -378,6 +397,13 @@
goto err_parse_dt_prop;
}
+ pdata->irq_gpio = of_get_named_gpio(dev->of_node,
+ "qcom,gpio-connect", 0);
+ if (!gpio_is_valid(pdata->irq_gpio)) {
+ dev_err(dev, "%s: TLMM connect gpio not found\n", __func__);
+ goto err_parse_dt_prop;
+ }
+
return pdata;
err_parse_dt_prop:
@@ -457,6 +483,7 @@
aqt1000->dev = &client->dev;
aqt1000->dev_up = true;
aqt1000->mclk_rate = pdata->mclk_rate;
+ aqt1000->irq = client->irq;
aqt1000->num_of_supplies = pdata->num_supplies;
ret = msm_cdc_init_supplies(aqt1000->dev, &aqt1000->supplies,
@@ -496,6 +523,9 @@
goto err_supplies;
}
+ pm_runtime_set_active(aqt1000->dev);
+ pm_runtime_enable(aqt1000->dev);
+
ret = aqt_register_codec(&client->dev);
if (ret) {
dev_err(aqt1000->dev, "%s: Codec registration failed\n",
@@ -506,6 +536,7 @@
return ret;
err_cdc_register:
+ pm_runtime_disable(aqt1000->dev);
aqt1000_device_exit(aqt1000);
err_supplies:
msm_cdc_release_supplies(aqt1000->dev, aqt1000->supplies,
@@ -527,6 +558,7 @@
aqt = dev_get_drvdata(&client->dev);
+ pm_runtime_disable(aqt->dev);
msm_cdc_release_supplies(aqt->dev, aqt->supplies,
pdata->regulator,
pdata->num_supplies);
@@ -535,6 +567,22 @@
return 0;
}
+#ifdef CONFIG_PM
+static int aqt1000_runtime_resume(struct device *dev)
+{
+ dev_dbg(dev, "%s system resume\n", __func__);
+
+ return 0;
+}
+
+static int aqt1000_runtime_suspend(struct device *dev)
+{
+ dev_dbg(dev, "%s system suspend\n", __func__);
+
+ return 0;
+}
+#endif
+
#ifdef CONFIG_PM_SLEEP
static int aqt1000_i2c_resume(struct device *dev)
{
@@ -556,8 +604,10 @@
MODULE_DEVICE_TABLE(i2c, aqt1000_id_table);
static const struct dev_pm_ops aqt1000_i2c_pm_ops = {
- .suspend = aqt1000_i2c_suspend,
- .resume = aqt1000_i2c_resume,
+ SET_RUNTIME_PM_OPS(aqt1000_runtime_suspend,
+ aqt1000_runtime_resume, NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(aqt1000_i2c_suspend,
+ aqt1000_i2c_resume)
};
static const struct of_device_id aqt_match_table[] = {
diff --git a/asoc/codecs/aqt1000/aqt1000-irq.c b/asoc/codecs/aqt1000/aqt1000-irq.c
index 0c13353..321b490 100644
--- a/asoc/codecs/aqt1000/aqt1000-irq.c
+++ b/asoc/codecs/aqt1000/aqt1000-irq.c
@@ -77,7 +77,8 @@
if (irq < 0)
return irq;
- return request_threaded_irq(irq, NULL, handler, IRQF_ONESHOT,
+ return request_threaded_irq(irq, NULL, handler,
+ IRQF_ONESHOT | IRQF_TRIGGER_RISING,
name, data);
}
EXPORT_SYMBOL(aqt_request_irq);
@@ -160,6 +161,8 @@
.irq_enable = aqt_irq_enable,
};
+static struct lock_class_key aqt_irq_lock_class;
+
static int aqt_irq_map(struct irq_domain *irqd, unsigned int virq,
irq_hw_number_t hw)
{
@@ -167,6 +170,7 @@
irq_set_chip_data(virq, data);
irq_set_chip_and_handler(virq, &aqt_irq_chip, handle_simple_irq);
+ irq_set_lockdep_class(virq, &aqt_irq_lock_class);
irq_set_nested_thread(virq, 1);
irq_set_noprobe(virq);
@@ -196,12 +200,6 @@
return -EINVAL;
}
- if (!aqt->irq) {
- dev_dbg(aqt->dev, "%s: No interrupt specified\n", __func__);
- aqt->irq_base = 0;
- return 0;
- }
-
pdata = dev_get_platdata(aqt->dev);
if (!pdata) {
dev_err(aqt->dev, "%s: Invalid platform data\n", __func__);
@@ -214,13 +212,7 @@
flags = pdata->irq_flags;
if (pdata->irq_gpio) {
- if (gpio_to_irq(pdata->irq_gpio) != aqt->irq) {
- dev_warn(aqt->dev, "%s: IRQ %d is not GPIO %d (%d)\n",
- __func__, aqt->irq, pdata->irq_gpio,
- gpio_to_irq(pdata->irq_gpio));
- aqt->irq = gpio_to_irq(pdata->irq_gpio);
- }
-
+ aqt->irq = gpio_to_irq(pdata->irq_gpio);
ret = devm_gpio_request_one(aqt->dev, pdata->irq_gpio,
GPIOF_IN, "AQT IRQ");
if (ret) {
@@ -229,10 +221,6 @@
pdata->irq_gpio = 0;
return ret;
}
- } else {
- dev_dbg(aqt->dev, "%s: irq_gpio is %d\n",
- __func__, pdata->irq_gpio);
- return 0;
}
irq_data = irq_get_irq_data(aqt->irq);
@@ -242,6 +230,7 @@
return -EINVAL;
}
+ aqt->num_irq_regs = aqt_regmap_irq_chip.num_regs;
for (i = 0; i < aqt->num_irq_regs; i++) {
regmap_write(aqt->regmap,
(AQT1000_INTR_CTRL_INT_TYPE_2 + i), 0);
diff --git a/asoc/codecs/aqt1000/aqt1000-routing.h b/asoc/codecs/aqt1000/aqt1000-routing.h
index 9dc74a4..7ae3276 100644
--- a/asoc/codecs/aqt1000/aqt1000-routing.h
+++ b/asoc/codecs/aqt1000/aqt1000-routing.h
@@ -85,30 +85,30 @@
{"AQT ANC0 FB MUX", "ANC_IN_HPHL", "AQT RX INT1 MIX2"},
{"AQT ANC1 FB MUX", "ANC_IN_HPHR", "AQT RX INT2 MIX2"},
- {"AQT I2S_L RX", "AIF1_PB", "AQT AIF1 PB"},
- {"AQT I2S_R RX", "AIF1_PB", "AQT AIF1 PB"},
+ {"AQT I2S_L RX", NULL, "AQT AIF1 PB"},
+ {"AQT I2S_R RX", NULL, "AQT AIF1 PB"},
- {"AQT RX INT1_1 MUX", "I2S_L", "AQT I2S_L RX"},
- {"AQT RX INT1_1 MUX", "I2S_R", "AQT I2S_R RX"},
+ {"AQT RX INT1_1 MUX", "I2S0_L", "AQT I2S_L RX"},
+ {"AQT RX INT1_1 MUX", "I2S0_R", "AQT I2S_R RX"},
{"AQT RX INT1_1 MUX", "DEC_L", "AQT ADC0 MUX"},
{"AQT RX INT1_1 MUX", "DEC_R", "AQT ADC1 MUX"},
{"AQT RX INT1_1 MUX", "DEC_V", "AQT ADC2 MUX"},
- {"AQT RX INT2_1 MUX", "I2S_L", "AQT I2S_L RX"},
- {"AQT RX INT2_1 MUX", "I2S_R", "AQT I2S_R RX"},
+ {"AQT RX INT2_1 MUX", "I2S0_L", "AQT I2S_L RX"},
+ {"AQT RX INT2_1 MUX", "I2S0_R", "AQT I2S_R RX"},
{"AQT RX INT2_1 MUX", "DEC_L", "AQT ADC0 MUX"},
{"AQT RX INT2_1 MUX", "DEC_R", "AQT ADC1 MUX"},
{"AQT RX INT2_1 MUX", "DEC_V", "AQT ADC2 MUX"},
- {"AQT RX INT1_2 MUX", "I2S_L", "AQT I2S_L RX"},
- {"AQT RX INT1_2 MUX", "I2S_R", "AQT I2S_R RX"},
+ {"AQT RX INT1_2 MUX", "I2S0_L", "AQT I2S_L RX"},
+ {"AQT RX INT1_2 MUX", "I2S0_R", "AQT I2S_R RX"},
{"AQT RX INT1_2 MUX", "DEC_L", "AQT ADC0 MUX"},
{"AQT RX INT1_2 MUX", "DEC_R", "AQT ADC1 MUX"},
{"AQT RX INT1_2 MUX", "DEC_V", "AQT ADC2 MUX"},
{"AQT RX INT1_2 MUX", "IIR0", "AQT IIR0"},
- {"AQT RX INT2_2 MUX", "I2S_L", "AQT I2S_L RX"},
- {"AQT RX INT2_2 MUX", "I2S_R", "AQT I2S_R RX"},
+ {"AQT RX INT2_2 MUX", "I2S0_L", "AQT I2S_L RX"},
+ {"AQT RX INT2_2 MUX", "I2S0_R", "AQT I2S_R RX"},
{"AQT RX INT2_2 MUX", "DEC_L", "AQT ADC0 MUX"},
{"AQT RX INT2_2 MUX", "DEC_R", "AQT ADC1 MUX"},
{"AQT RX INT2_2 MUX", "DEC_V", "AQT ADC2 MUX"},
@@ -137,6 +137,8 @@
{"AQT RX INT1 DEM MUX", "CLSH_DSM_OUT", "AQT RX INT1 MIX2"},
{"AQT RX INT1 DAC", NULL, "AQT RX INT1 DEM MUX"},
{"AQT RX INT1 DAC", NULL, "AQT RX_BIAS"},
+ {"AQT RX_BIAS", NULL, "AQT MCLK"},
+ {"AQT MIC BIAS1", NULL, "AQT MCLK"},
{"AQT HPHL PA", NULL, "AQT RX INT1 DAC"},
{"AQT HPHL", NULL, "AQT HPHL PA"},
@@ -152,10 +154,12 @@
{"AQT ANC HPHR PA", NULL, "AQT RX INT2 DAC"},
{"AQT ANC HPHR", NULL, "AQT ANC HPHR PA"},
- {"AQT IIR0", NULL, "AQT TX_PATH2"},
+ {"AQT IIR0", NULL, "AQT ADC2 MUX"},
{"AQT SRC0", NULL, "AQT IIR0"},
- {"AQT RX INT1 MIX2", "SRC0", "AQT SRC0"},
- {"AQT RX INT2 MIX2", "SRC0", "AQT SRC0"},
+ {"AQT RX ST MUX", "SRC0", "AQT SRC0"},
+
+ {"AQT RX INT1 MIX2", NULL, "AQT RX ST MUX"},
+ {"AQT RX INT2 MIX2", NULL, "AQT RX ST MUX"},
/* Native clk main path routing */
{"AQT RX INT1_1 NATIVE MUX", "ON", "AQT RX INT1_1 MUX"},
diff --git a/asoc/codecs/aqt1000/aqt1000.c b/asoc/codecs/aqt1000/aqt1000.c
index 21baae7..8463d82 100644
--- a/asoc/codecs/aqt1000/aqt1000.c
+++ b/asoc/codecs/aqt1000/aqt1000.c
@@ -2542,6 +2542,26 @@
AQT_DAPM_ENUM(int1_1_native, SND_SOC_NOPM, 0, native_mux_text);
AQT_DAPM_ENUM(int2_1_native, SND_SOC_NOPM, 0, native_mux_text);
+static int aqt_mclk_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+ int ret = 0;
+
+ dev_dbg(codec->dev, "%s: event = %d\n", __func__, event);
+
+ switch (event) {
+ case SND_SOC_DAPM_PRE_PMU:
+ ret = aqt_cdc_mclk_enable(codec, true);
+ break;
+ case SND_SOC_DAPM_POST_PMD:
+ ret = aqt_cdc_mclk_enable(codec, false);
+ break;
+ }
+
+ return ret;
+}
+
static int aif_cap_mixer_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -2561,8 +2581,17 @@
aif_cap_mixer_get, aif_cap_mixer_put),
};
+static const char * const rx_inp_st_mux_text[] = {
+ "ZERO", "SRC0",
+};
+AQT_DAPM_ENUM(rx_inp_st, AQT1000_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4,
+ rx_inp_st_mux_text);
+
static const struct snd_soc_dapm_widget aqt_dapm_widgets[] = {
+ SND_SOC_DAPM_SUPPLY("AQT MCLK", SND_SOC_NOPM, 0, 0, aqt_mclk_event,
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
+
SND_SOC_DAPM_AIF_OUT_E("AQT AIF1 CAP", "AQT AIF1 Capture", 0,
SND_SOC_NOPM, AIF1_CAP, 0, aqt_codec_enable_i2s_tx,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
@@ -2720,6 +2749,10 @@
AQT_DAPM_MUX("AQT RX INT1_1 NATIVE MUX", 0, int1_1_native),
AQT_DAPM_MUX("AQT RX INT2_1 NATIVE MUX", 0, int2_1_native),
+
+ SND_SOC_DAPM_MUX("AQT RX ST MUX",
+ AQT1000_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 0,
+ &rx_inp_st_mux),
};
static int aqt_startup(struct snd_pcm_substream *substream,
@@ -3230,14 +3263,10 @@
EXPORT_SYMBOL(aqt_codec_info_create_codec_entry);
static const struct aqt_reg_mask_val aqt_codec_reg_init[] = {
- {AQT1000_CHIP_CFG0_CLK_CFG_MCLK, 0x04, 0x00},
{AQT1000_CHIP_CFG0_EFUSE_CTL, 0x01, 0x01},
};
static const struct aqt_reg_mask_val aqt_codec_reg_update[] = {
- {AQT1000_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x01, 0x01},
- {AQT1000_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x01, 0x01},
- {AQT1000_CHIP_CFG0_CLK_CTL_CDC_DIG, 0x01, 0x01},
{AQT1000_LDOH_MODE, 0x1F, 0x0B},
{AQT1000_MICB1_TEST_CTL_2, 0x07, 0x01},
{AQT1000_MICB1_MISC_MICB1_INM_RES_BIAS, 0x03, 0x02},
diff --git a/asoc/codecs/wcd9360/wcd9360-dsp-cntl.c b/asoc/codecs/wcd9360/wcd9360-dsp-cntl.c
index 5a67aa6..4b46032 100644
--- a/asoc/codecs/wcd9360/wcd9360-dsp-cntl.c
+++ b/asoc/codecs/wcd9360/wcd9360-dsp-cntl.c
@@ -1078,7 +1078,7 @@
return -EINVAL;
}
- cntl = pahu_get_wcd_dsp_cntl(dev);
+ cntl = (struct wcd_dsp_cntl *) pahu_get_wcd_dsp_cntl(dev);
if (!cntl) {
dev_err(dev, "%s: Failed to get cntl reference\n",
__func__);
@@ -1165,7 +1165,7 @@
return;
}
- cntl = pahu_get_wcd_dsp_cntl(dev);
+ cntl = (struct wcd_dsp_cntl *) pahu_get_wcd_dsp_cntl(dev);
if (!cntl) {
dev_err(dev, "%s: Failed to get cntl reference\n",
__func__);
diff --git a/asoc/codecs/wcd9360/wcd9360.c b/asoc/codecs/wcd9360/wcd9360.c
index d195152..5b8da20 100644
--- a/asoc/codecs/wcd9360/wcd9360.c
+++ b/asoc/codecs/wcd9360/wcd9360.c
@@ -154,6 +154,21 @@
#define WCD9360_DIG_CORE_COLLAPSE_TIMER_MS (5 * 1000)
enum {
+ INTERP_EAR = 0,
+ /* Headset and Lineout are not avalible in pahu */
+ INTERP_HPHL_NA,
+ INTERP_HPHR_NA,
+ INTERP_LO1_NA,
+ INTERP_LO2_NA,
+ INTERP_LO3_NA,
+ INTERP_LO4_NA,
+ INTERP_SPKR1,
+ INTERP_SPKR2,
+ INTERP_AUX,
+ INTERP_MAX,
+};
+
+enum {
POWER_COLLAPSE,
POWER_RESUME,
};
@@ -7904,7 +7919,7 @@
*
* This API gets the reference to codec's struct wcd_dsp_cntl
*/
-struct wcd_dsp_cntl *pahu_get_wcd_dsp_cntl(struct device *dev)
+void *pahu_get_wcd_dsp_cntl(struct device *dev)
{
struct platform_device *pdev;
struct pahu_priv *pahu;
diff --git a/asoc/codecs/wcd9360/wcd9360.h b/asoc/codecs/wcd9360/wcd9360.h
index 21f4e73..2c70a68 100644
--- a/asoc/codecs/wcd9360/wcd9360.h
+++ b/asoc/codecs/wcd9360/wcd9360.h
@@ -14,7 +14,6 @@
#define __WCD9360_H__
#include <dsp/apr_audio-v2.h>
-#include "wcd9360-dsp-cntl.h"
#include "../wcd9xxx-slimslave.h"
#include "../wcd9xxx-common-v2.h"
@@ -75,21 +74,6 @@
WCD9360_TX_MAX,
};
-enum {
- INTERP_EAR = 0,
- /* Headset and Lineout are not avalible in pahu */
- INTERP_HPHL_NA,
- INTERP_HPHR_NA,
- INTERP_LO1_NA,
- INTERP_LO2_NA,
- INTERP_LO3_NA,
- INTERP_LO4_NA,
- INTERP_SPKR1,
- INTERP_SPKR2,
- INTERP_AUX,
- INTERP_MAX,
-};
-
/*
* Selects compander and smart boost settings
* for a given speaker mode
@@ -149,7 +133,7 @@
extern int pahu_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable);
extern int pahu_set_spkr_mode(struct snd_soc_codec *codec, int mode);
extern int pahu_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
-extern struct wcd_dsp_cntl *pahu_get_wcd_dsp_cntl(struct device *dev);
+extern void *pahu_get_wcd_dsp_cntl(struct device *dev);
extern int wcd9360_get_micb_vout_ctl_val(u32 micb_mv);
extern int pahu_codec_info_create_codec_entry(
struct snd_info_entry *codec_root,
diff --git a/asoc/msm-audio-effects-q6-v2.c b/asoc/msm-audio-effects-q6-v2.c
index 5bab856..8b2ca31 100644
--- a/asoc/msm-audio-effects-q6-v2.c
+++ b/asoc/msm-audio-effects-q6-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, 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
@@ -16,6 +16,7 @@
#include <dsp/apr_audio-v2.h>
#include <dsp/q6asm-v2.h>
#include <dsp/msm-audio-effects-q6-v2.h>
+#include <dsp/q6common.h>
#define MAX_ENABLE_CMD_SIZE 32
@@ -67,44 +68,36 @@
struct msm_nt_eff_all_config *effects,
bool flag)
{
- uint32_t updt_params[MAX_ENABLE_CMD_SIZE] = {0};
- uint32_t params_length;
+ u32 flag_param = flag ? 1 : 0;
+ struct param_hdr_v3 param_hdr;
int rc = 0;
pr_debug("%s\n", __func__);
- if (!ac) {
- pr_err("%s: cannot set audio effects\n", __func__);
- return -EINVAL;
- }
- params_length = 0;
- updt_params[0] = AUDPROC_MODULE_ID_VIRTUALIZER;
- updt_params[1] = AUDPROC_PARAM_ID_ENABLE;
- updt_params[2] = VIRTUALIZER_ENABLE_PARAM_SZ;
- updt_params[3] = flag;
- params_length += COMMAND_PAYLOAD_SZ + VIRTUALIZER_ENABLE_PARAM_SZ;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_VIRTUALIZER;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_ENABLE;
+ param_hdr.param_size = VIRTUALIZER_ENABLE_PARAM_SZ;
if (effects->virtualizer.enable_flag)
- q6asm_send_audio_effects_params(ac, (char *)&updt_params[0],
- params_length);
- memset(updt_params, 0, MAX_ENABLE_CMD_SIZE);
- params_length = 0;
- updt_params[0] = AUDPROC_MODULE_ID_BASS_BOOST;
- updt_params[1] = AUDPROC_PARAM_ID_ENABLE;
- updt_params[2] = BASS_BOOST_ENABLE_PARAM_SZ;
- updt_params[3] = flag;
- params_length += COMMAND_PAYLOAD_SZ + BASS_BOOST_ENABLE_PARAM_SZ;
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_hdr,
+ (u8 *) &flag_param);
+
+ param_hdr.module_id = AUDPROC_MODULE_ID_BASS_BOOST;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_ENABLE;
+ param_hdr.param_size = BASS_BOOST_ENABLE_PARAM_SZ;
if (effects->bass_boost.enable_flag)
- q6asm_send_audio_effects_params(ac, (char *)&updt_params[0],
- params_length);
- memset(updt_params, 0, MAX_ENABLE_CMD_SIZE);
- params_length = 0;
- updt_params[0] = AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
- updt_params[1] = AUDPROC_PARAM_ID_ENABLE;
- updt_params[2] = EQ_ENABLE_PARAM_SZ;
- updt_params[3] = flag;
- params_length += COMMAND_PAYLOAD_SZ + EQ_ENABLE_PARAM_SZ;
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_hdr,
+ (u8 *) &flag_param);
+
+ param_hdr.module_id = AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_ENABLE;
+ param_hdr.param_size = EQ_ENABLE_PARAM_SZ;
if (effects->equalizer.enable_flag)
- q6asm_send_audio_effects_params(ac, (char *)&updt_params[0],
- params_length);
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_hdr,
+ (u8 *) &flag_param);
+
return rc;
}
@@ -124,24 +117,32 @@
{
long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
char *params = NULL;
+ u8 *updt_params;
int rc = 0;
int devices = GET_NEXT(values, param_max_offset, rc);
int num_commands = GET_NEXT(values, param_max_offset, rc);
- int *updt_params, i, prev_enable_flag;
- uint32_t params_length = (MAX_INBAND_PARAM_SZ);
+ int i, prev_enable_flag;
+ uint32_t max_params_length = 0;
+ uint32_t params_length = 0;
+ struct param_hdr_v3 param_hdr;
+ u8 *param_data = NULL;
+ u32 packed_data_size = 0;
pr_debug("%s\n", __func__);
if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
pr_err("%s: cannot set audio effects\n", __func__);
return -EINVAL;
}
- params = kzalloc(params_length, GFP_KERNEL);
- if (!params)
+ params = kzalloc(MAX_INBAND_PARAM_SZ, 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;
+ updt_params = (u8 *) params;
+ /* Set MID and IID once at top and only update param specific fields*/
+ param_hdr.module_id = AUDPROC_MODULE_ID_VIRTUALIZER;
+ param_hdr.instance_id = INSTANCE_ID_0;
for (i = 0; i < num_commands; i++) {
uint32_t command_id =
GET_NEXT(values, param_max_offset, rc);
@@ -163,23 +164,19 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s:VIRT ENABLE prev:%d, new:%d\n", __func__,
prev_enable_flag, virtualizer->enable_flag);
- if (prev_enable_flag != virtualizer->enable_flag) {
- params_length += COMMAND_PAYLOAD_SZ +
- VIRTUALIZER_ENABLE_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "VIRT ENABLE", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_VIRTUALIZER;
- *updt_params++ =
+ if (prev_enable_flag == virtualizer->enable_flag)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ VIRTUALIZER_ENABLE_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "VIRT ENABLE", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
AUDPROC_PARAM_ID_VIRTUALIZER_ENABLE;
- *updt_params++ =
- VIRTUALIZER_ENABLE_PARAM_SZ;
- *updt_params++ =
- virtualizer->enable_flag;
- }
+ param_hdr.param_size = VIRTUALIZER_ENABLE_PARAM_SZ;
+ param_data = (u8 *) &virtualizer->enable_flag;
break;
case VIRTUALIZER_STRENGTH:
if (length != 1 || index_offset != 0) {
@@ -191,23 +188,19 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: VIRT STRENGTH val: %d\n",
__func__, virtualizer->strength);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- VIRTUALIZER_STRENGTH_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "VIRT STRENGTH", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_VIRTUALIZER;
- *updt_params++ =
- AUDPROC_PARAM_ID_VIRTUALIZER_STRENGTH;
- *updt_params++ =
- VIRTUALIZER_STRENGTH_PARAM_SZ;
- *updt_params++ =
- virtualizer->strength;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ VIRTUALIZER_STRENGTH_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "VIRT STRENGTH", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
+ AUDPROC_PARAM_ID_VIRTUALIZER_STRENGTH;
+ param_hdr.param_size = VIRTUALIZER_STRENGTH_PARAM_SZ;
+ param_data = (u8 *) &virtualizer->strength;
break;
case VIRTUALIZER_OUT_TYPE:
if (length != 1 || index_offset != 0) {
@@ -219,23 +212,19 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: VIRT OUT_TYPE val:%d\n",
__func__, virtualizer->out_type);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- VIRTUALIZER_OUT_TYPE_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "VIRT OUT_TYPE", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_VIRTUALIZER;
- *updt_params++ =
- AUDPROC_PARAM_ID_VIRTUALIZER_OUT_TYPE;
- *updt_params++ =
- VIRTUALIZER_OUT_TYPE_PARAM_SZ;
- *updt_params++ =
- virtualizer->out_type;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ VIRTUALIZER_OUT_TYPE_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "VIRT OUT_TYPE", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
+ AUDPROC_PARAM_ID_VIRTUALIZER_OUT_TYPE;
+ param_hdr.param_size = VIRTUALIZER_OUT_TYPE_PARAM_SZ;
+ param_data = (u8 *) &virtualizer->out_type;
break;
case VIRTUALIZER_GAIN_ADJUST:
if (length != 1 || index_offset != 0) {
@@ -247,32 +236,40 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: VIRT GAIN_ADJUST val:%d\n",
__func__, virtualizer->gain_adjust);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- VIRTUALIZER_GAIN_ADJUST_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "VIRT GAIN_ADJUST", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_VIRTUALIZER;
- *updt_params++ =
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ VIRTUALIZER_GAIN_ADJUST_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "VIRT GAIN_ADJUST", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
AUDPROC_PARAM_ID_VIRTUALIZER_GAIN_ADJUST;
- *updt_params++ =
- VIRTUALIZER_GAIN_ADJUST_PARAM_SZ;
- *updt_params++ =
- virtualizer->gain_adjust;
- }
+ param_hdr.param_size = VIRTUALIZER_GAIN_ADJUST_PARAM_SZ;
+ param_data = (u8 *) &virtualizer->gain_adjust;
break;
default:
pr_err("%s: Invalid command to set config\n", __func__);
- break;
+ continue;
}
+ if (rc)
+ goto invalid_config;
+
+ rc = q6common_pack_pp_params(updt_params, ¶m_hdr,
+ param_data, &packed_data_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, rc);
+ goto invalid_config;
+ }
+
+ updt_params += packed_data_size;
+ params_length += packed_data_size;
}
if (params_length && (rc == 0))
- q6asm_send_audio_effects_params(ac, params,
- params_length);
+ q6asm_set_pp_params(ac, NULL, params, params_length);
else
pr_debug("%s: did not send pp params\n", __func__);
invalid_config:
@@ -297,24 +294,33 @@
{
long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
char *params = NULL;
+ u8 *updt_params;
int rc = 0;
int devices = GET_NEXT(values, param_max_offset, rc);
int num_commands = GET_NEXT(values, param_max_offset, rc);
- int *updt_params, i, prev_enable_flag;
- uint32_t params_length = (MAX_INBAND_PARAM_SZ);
+ int i, prev_enable_flag;
+ uint32_t max_params_length = 0;
+ uint32_t params_length = 0;
+ struct param_hdr_v3 param_hdr;
+ u8 *param_data = NULL;
+ u32 packed_data_size = 0;
pr_debug("%s\n", __func__);
if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
pr_err("%s: cannot set audio effects\n", __func__);
return -EINVAL;
}
- params = kzalloc(params_length, GFP_KERNEL);
- if (!params)
+ params = kzalloc(MAX_INBAND_PARAM_SZ, 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;
+ updt_params = (u8 *) params;
+ /* Set MID and IID once at top and only update param specific fields*/
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_REVERB;
+ param_hdr.instance_id = INSTANCE_ID_0;
for (i = 0; i < num_commands; i++) {
uint32_t command_id =
GET_NEXT(values, param_max_offset, rc);
@@ -336,23 +342,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s:REVERB_ENABLE prev:%d,new:%d\n", __func__,
prev_enable_flag, reverb->enable_flag);
- if (prev_enable_flag != reverb->enable_flag) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_ENABLE_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_ENABLE", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_ENABLE;
- *updt_params++ =
- REVERB_ENABLE_PARAM_SZ;
- *updt_params++ =
- reverb->enable_flag;
- }
+ if (prev_enable_flag == reverb->enable_flag)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_ENABLE_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_ENABLE", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_ENABLE;
+ param_hdr.param_size = REVERB_ENABLE_PARAM_SZ;
+ param_data = (u8 *) &reverb->enable_flag;
break;
case REVERB_MODE:
if (length != 1 || index_offset != 0) {
@@ -364,23 +365,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_MODE val:%d\n",
__func__, reverb->mode);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_MODE_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_MODE", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_MODE;
- *updt_params++ =
- REVERB_MODE_PARAM_SZ;
- *updt_params++ =
- reverb->mode;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_MODE_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_MODE", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_MODE;
+ param_hdr.param_size = REVERB_MODE_PARAM_SZ;
+ param_data = (u8 *) &reverb->mode;
break;
case REVERB_PRESET:
if (length != 1 || index_offset != 0) {
@@ -392,23 +388,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_PRESET val:%d\n",
__func__, reverb->preset);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_PRESET_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_PRESET", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_PRESET;
- *updt_params++ =
- REVERB_PRESET_PARAM_SZ;
- *updt_params++ =
- reverb->preset;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_PRESET_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_PRESET", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_PRESET;
+ param_hdr.param_size = REVERB_PRESET_PARAM_SZ;
+ param_data = (u8 *) &reverb->preset;
break;
case REVERB_WET_MIX:
if (length != 1 || index_offset != 0) {
@@ -420,23 +411,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_WET_MIX val:%d\n",
__func__, reverb->wet_mix);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_WET_MIX_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_WET_MIX", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_WET_MIX;
- *updt_params++ =
- REVERB_WET_MIX_PARAM_SZ;
- *updt_params++ =
- reverb->wet_mix;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_WET_MIX_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_WET_MIX", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_WET_MIX;
+ param_hdr.param_size = REVERB_WET_MIX_PARAM_SZ;
+ param_data = (u8 *) &reverb->wet_mix;
break;
case REVERB_GAIN_ADJUST:
if (length != 1 || index_offset != 0) {
@@ -448,23 +434,19 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_GAIN_ADJUST val:%d\n",
__func__, reverb->gain_adjust);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_GAIN_ADJUST_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_GAIN_ADJUST", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_GAIN_ADJUST;
- *updt_params++ =
- REVERB_GAIN_ADJUST_PARAM_SZ;
- *updt_params++ =
- reverb->gain_adjust;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_GAIN_ADJUST_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_GAIN_ADJUST", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
+ AUDPROC_PARAM_ID_REVERB_GAIN_ADJUST;
+ param_hdr.param_size = REVERB_GAIN_ADJUST_PARAM_SZ;
+ param_data = (u8 *) &reverb->gain_adjust;
break;
case REVERB_ROOM_LEVEL:
if (length != 1 || index_offset != 0) {
@@ -476,23 +458,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_ROOM_LEVEL val:%d\n",
__func__, reverb->room_level);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_ROOM_LEVEL_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_ROOM_LEVEL", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_ROOM_LEVEL;
- *updt_params++ =
- REVERB_ROOM_LEVEL_PARAM_SZ;
- *updt_params++ =
- reverb->room_level;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_ROOM_LEVEL_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_ROOM_LEVEL", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_ROOM_LEVEL;
+ param_hdr.param_size = REVERB_ROOM_LEVEL_PARAM_SZ;
+ param_data = (u8 *) &reverb->room_level;
break;
case REVERB_ROOM_HF_LEVEL:
if (length != 1 || index_offset != 0) {
@@ -504,23 +481,19 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_ROOM_HF_LEVEL val%d\n",
__func__, reverb->room_hf_level);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_ROOM_HF_LEVEL_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_ROOM_HF_LEVEL", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_ROOM_HF_LEVEL;
- *updt_params++ =
- REVERB_ROOM_HF_LEVEL_PARAM_SZ;
- *updt_params++ =
- reverb->room_hf_level;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_ROOM_HF_LEVEL_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_ROOM_HF_LEVEL", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
+ AUDPROC_PARAM_ID_REVERB_ROOM_HF_LEVEL;
+ param_hdr.param_size = REVERB_ROOM_HF_LEVEL_PARAM_SZ;
+ param_data = (u8 *) &reverb->room_hf_level;
break;
case REVERB_DECAY_TIME:
if (length != 1 || index_offset != 0) {
@@ -532,23 +505,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_DECAY_TIME val:%d\n",
__func__, reverb->decay_time);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_DECAY_TIME_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_DECAY_TIME", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_DECAY_TIME;
- *updt_params++ =
- REVERB_DECAY_TIME_PARAM_SZ;
- *updt_params++ =
- reverb->decay_time;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_DECAY_TIME_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_DECAY_TIME", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_DECAY_TIME;
+ param_hdr.param_size = REVERB_DECAY_TIME_PARAM_SZ;
+ param_data = (u8 *) &reverb->decay_time;
break;
case REVERB_DECAY_HF_RATIO:
if (length != 1 || index_offset != 0) {
@@ -560,23 +528,19 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_DECAY_HF_RATIO val%d\n",
__func__, reverb->decay_hf_ratio);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_DECAY_HF_RATIO_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_DECAY_HF_RATIO", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_DECAY_HF_RATIO;
- *updt_params++ =
- REVERB_DECAY_HF_RATIO_PARAM_SZ;
- *updt_params++ =
- reverb->decay_hf_ratio;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_DECAY_HF_RATIO_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_DECAY_HF_RATIO", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
+ AUDPROC_PARAM_ID_REVERB_DECAY_HF_RATIO;
+ param_hdr.param_size = REVERB_DECAY_HF_RATIO_PARAM_SZ;
+ param_data = (u8 *) &reverb->decay_hf_ratio;
break;
case REVERB_REFLECTIONS_LEVEL:
if (length != 1 || index_offset != 0) {
@@ -588,23 +552,20 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_REFLECTIONS_LEVEL val:%d\n",
__func__, reverb->reflections_level);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_REFLECTIONS_LEVEL_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_REFLECTIONS_LEVEL", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_REFLECTIONS_LEVEL_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_REFLECTIONS_LEVEL", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
AUDPROC_PARAM_ID_REVERB_REFLECTIONS_LEVEL;
- *updt_params++ =
+ param_hdr.param_size =
REVERB_REFLECTIONS_LEVEL_PARAM_SZ;
- *updt_params++ =
- reverb->reflections_level;
- }
+ param_data = (u8 *) &reverb->reflections_level;
break;
case REVERB_REFLECTIONS_DELAY:
if (length != 1 || index_offset != 0) {
@@ -616,23 +577,20 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_REFLECTIONS_DELAY val:%d\n",
__func__, reverb->reflections_delay);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_REFLECTIONS_DELAY_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_REFLECTIONS_DELAY", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_REFLECTIONS_DELAY_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_REFLECTIONS_DELAY", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
AUDPROC_PARAM_ID_REVERB_REFLECTIONS_DELAY;
- *updt_params++ =
+ param_hdr.param_size =
REVERB_REFLECTIONS_DELAY_PARAM_SZ;
- *updt_params++ =
- reverb->reflections_delay;
- }
+ param_data = (u8 *) &reverb->reflections_delay;
break;
case REVERB_LEVEL:
if (length != 1 || index_offset != 0) {
@@ -644,23 +602,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_LEVEL val:%d\n",
__func__, reverb->level);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_LEVEL_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_LEVEL", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_LEVEL;
- *updt_params++ =
- REVERB_LEVEL_PARAM_SZ;
- *updt_params++ =
- reverb->level;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_LEVEL_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_LEVEL", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_LEVEL;
+ param_hdr.param_size = REVERB_LEVEL_PARAM_SZ;
+ param_data = (u8 *) &reverb->level;
break;
case REVERB_DELAY:
if (length != 1 || index_offset != 0) {
@@ -672,23 +625,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s:REVERB_DELAY val:%d\n",
__func__, reverb->delay);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_DELAY_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_DELAY", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_DELAY;
- *updt_params++ =
- REVERB_DELAY_PARAM_SZ;
- *updt_params++ =
- reverb->delay;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_DELAY_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_DELAY", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_DELAY;
+ param_hdr.param_size = REVERB_DELAY_PARAM_SZ;
+ param_data = (u8 *) &reverb->delay;
break;
case REVERB_DIFFUSION:
if (length != 1 || index_offset != 0) {
@@ -700,23 +648,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_DIFFUSION val:%d\n",
__func__, reverb->diffusion);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_DIFFUSION_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_DIFFUSION", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_DIFFUSION;
- *updt_params++ =
- REVERB_DIFFUSION_PARAM_SZ;
- *updt_params++ =
- reverb->diffusion;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_DIFFUSION_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_DIFFUSION", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_DIFFUSION;
+ param_hdr.param_size = REVERB_DIFFUSION_PARAM_SZ;
+ param_data = (u8 *) &reverb->diffusion;
break;
case REVERB_DENSITY:
if (length != 1 || index_offset != 0) {
@@ -728,32 +671,39 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: REVERB_DENSITY val:%d\n",
__func__, reverb->density);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- REVERB_DENSITY_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "REVERB_DENSITY", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_REVERB;
- *updt_params++ =
- AUDPROC_PARAM_ID_REVERB_DENSITY;
- *updt_params++ =
- REVERB_DENSITY_PARAM_SZ;
- *updt_params++ =
- reverb->density;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ REVERB_DENSITY_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "REVERB_DENSITY", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_REVERB_DENSITY;
+ param_hdr.param_size = REVERB_DENSITY_PARAM_SZ;
+ param_data = (u8 *) &reverb->density;
break;
default:
pr_err("%s: Invalid command to set config\n", __func__);
- break;
+ continue;
}
+ if (rc)
+ goto invalid_config;
+
+ rc = q6common_pack_pp_params(updt_params, ¶m_hdr,
+ param_data, &packed_data_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, rc);
+ goto invalid_config;
+ }
+
+ updt_params += packed_data_size;
+ params_length += packed_data_size;
}
if (params_length && (rc == 0))
- q6asm_send_audio_effects_params(ac, params,
- params_length);
+ q6asm_set_pp_params(ac, NULL, params, params_length);
else
pr_debug("%s: did not send pp params\n", __func__);
invalid_config:
@@ -778,24 +728,33 @@
{
long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
char *params = NULL;
+ u8 *updt_params;
int rc = 0;
int devices = GET_NEXT(values, param_max_offset, rc);
int num_commands = GET_NEXT(values, param_max_offset, rc);
- int *updt_params, i, prev_enable_flag;
- uint32_t params_length = (MAX_INBAND_PARAM_SZ);
+ int i, prev_enable_flag;
+ uint32_t max_params_length = 0;
+ uint32_t params_length = 0;
+ struct param_hdr_v3 param_hdr;
+ u8 *param_data = NULL;
+ u32 packed_data_size = 0;
pr_debug("%s\n", __func__);
if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
pr_err("%s: cannot set audio effects\n", __func__);
return -EINVAL;
}
- params = kzalloc(params_length, GFP_KERNEL);
- if (!params)
+ params = kzalloc(MAX_INBAND_PARAM_SZ, 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;
+ updt_params = (u8 *) params;
+ /* Set MID and IID once at top and only update param specific fields*/
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_BASS_BOOST;
+ param_hdr.instance_id = INSTANCE_ID_0;
for (i = 0; i < num_commands; i++) {
uint32_t command_id =
GET_NEXT(values, param_max_offset, rc);
@@ -818,23 +777,18 @@
pr_debug("%s: BASS_BOOST_ENABLE prev:%d new:%d\n",
__func__, prev_enable_flag,
bass_boost->enable_flag);
- if (prev_enable_flag != bass_boost->enable_flag) {
- params_length += COMMAND_PAYLOAD_SZ +
- BASS_BOOST_ENABLE_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "BASS_BOOST_ENABLE", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_BASS_BOOST;
- *updt_params++ =
- AUDPROC_PARAM_ID_BASS_BOOST_ENABLE;
- *updt_params++ =
- BASS_BOOST_ENABLE_PARAM_SZ;
- *updt_params++ =
- bass_boost->enable_flag;
- }
+ if (prev_enable_flag == bass_boost->enable_flag)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ BASS_BOOST_ENABLE_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "BASS_BOOST_ENABLE", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_BASS_BOOST_ENABLE;
+ param_hdr.param_size = BASS_BOOST_ENABLE_PARAM_SZ;
+ param_data = (u8 *) &bass_boost->enable_flag;
break;
case BASS_BOOST_MODE:
if (length != 1 || index_offset != 0) {
@@ -846,23 +800,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: BASS_BOOST_MODE val:%d\n",
__func__, bass_boost->mode);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- BASS_BOOST_MODE_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "BASS_BOOST_MODE", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_BASS_BOOST;
- *updt_params++ =
- AUDPROC_PARAM_ID_BASS_BOOST_MODE;
- *updt_params++ =
- BASS_BOOST_MODE_PARAM_SZ;
- *updt_params++ =
- bass_boost->mode;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ BASS_BOOST_MODE_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "BASS_BOOST_MODE", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_BASS_BOOST_MODE;
+ param_hdr.param_size = BASS_BOOST_MODE_PARAM_SZ;
+ param_data = (u8 *) &bass_boost->mode;
break;
case BASS_BOOST_STRENGTH:
if (length != 1 || index_offset != 0) {
@@ -874,32 +823,40 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: BASS_BOOST_STRENGTH val:%d\n",
__func__, bass_boost->strength);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- BASS_BOOST_STRENGTH_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "BASS_BOOST_STRENGTH", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_BASS_BOOST;
- *updt_params++ =
- AUDPROC_PARAM_ID_BASS_BOOST_STRENGTH;
- *updt_params++ =
- BASS_BOOST_STRENGTH_PARAM_SZ;
- *updt_params++ =
- bass_boost->strength;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ BASS_BOOST_STRENGTH_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "BASS_BOOST_STRENGTH", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
+ AUDPROC_PARAM_ID_BASS_BOOST_STRENGTH;
+ param_hdr.param_size = BASS_BOOST_STRENGTH_PARAM_SZ;
+ param_data = (u8 *) &bass_boost->strength;
break;
default:
pr_err("%s: Invalid command to set config\n", __func__);
- break;
+ continue;
}
+ if (rc)
+ goto invalid_config;
+
+ rc = q6common_pack_pp_params(updt_params, ¶m_hdr,
+ param_data, &packed_data_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, rc);
+ goto invalid_config;
+ }
+
+ updt_params += packed_data_size;
+ params_length += packed_data_size;
}
if (params_length && (rc == 0))
- q6asm_send_audio_effects_params(ac, params,
- params_length);
+ q6asm_set_pp_params(ac, NULL, params, params_length);
else
pr_debug("%s: did not send pp params\n", __func__);
invalid_config:
@@ -924,24 +881,33 @@
{
long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
char *params = NULL;
+ u8 *updt_params;
int rc = 0;
int devices = GET_NEXT(values, param_max_offset, rc);
int num_commands = GET_NEXT(values, param_max_offset, rc);
- int *updt_params, i, j, prev_enable_flag;
- uint32_t params_length = (MAX_INBAND_PARAM_SZ);
+ int i, prev_enable_flag;
+ uint32_t max_params_length = 0;
+ uint32_t params_length = 0;
+ struct param_hdr_v3 param_hdr;
+ u8 *param_data = NULL;
+ u32 packed_data_size = 0;
pr_debug("%s\n", __func__);
if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
pr_err("%s: cannot set audio effects\n", __func__);
return -EINVAL;
}
- params = kzalloc(params_length, GFP_KERNEL);
- if (!params)
+ params = kzalloc(MAX_INBAND_PARAM_SZ, 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;
+ updt_params = (u8 *) params;
+ /* Set MID and IID once at top and only update param specific fields*/
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_PBE;
+ param_hdr.instance_id = INSTANCE_ID_0;
for (i = 0; i < num_commands; i++) {
uint32_t command_id =
GET_NEXT(values, param_max_offset, rc);
@@ -962,23 +928,18 @@
prev_enable_flag = pbe->enable_flag;
pbe->enable_flag =
GET_NEXT(values, param_max_offset, rc);
- if (prev_enable_flag != pbe->enable_flag) {
- params_length += COMMAND_PAYLOAD_SZ +
- PBE_ENABLE_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "PBE_ENABLE", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_PBE;
- *updt_params++ =
- AUDPROC_PARAM_ID_PBE_ENABLE;
- *updt_params++ =
- PBE_ENABLE_PARAM_SZ;
- *updt_params++ =
- pbe->enable_flag;
- }
+ if (prev_enable_flag == pbe->enable_flag)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ PBE_ENABLE_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "PBE_ENABLE", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_PBE_ENABLE;
+ param_hdr.param_size = PBE_ENABLE_PARAM_SZ;
+ param_data = (u8 *) &pbe->enable_flag;
break;
case PBE_CONFIG:
pr_debug("%s: PBE_PARAM length %u\n", __func__, length);
@@ -989,37 +950,38 @@
rc = -EINVAL;
goto invalid_config;
}
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ + length;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "PBE_PARAM", rc);
- if (rc != 0)
- goto invalid_config;
- *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++ =
- GET_NEXT(
- values,
- param_max_offset,
- rc);
- }
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length =
+ params_length + COMMAND_IID_PAYLOAD_SZ + length;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "PBE_PARAM", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_PBE_PARAM_CONFIG;
+ param_hdr.param_size = length;
+ param_data = (u8 *) values;
break;
default:
pr_err("%s: Invalid command to set config\n", __func__);
- break;
+ continue;
}
+ if (rc)
+ goto invalid_config;
+
+ rc = q6common_pack_pp_params(updt_params, ¶m_hdr,
+ param_data, &packed_data_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, rc);
+ goto invalid_config;
+ }
+
+ updt_params += packed_data_size;
+ params_length += packed_data_size;
}
if (params_length && (rc == 0))
- q6asm_send_audio_effects_params(ac, params,
- params_length);
+ q6asm_set_pp_params(ac, NULL, params, params_length);
invalid_config:
kfree(params);
return rc;
@@ -1042,24 +1004,36 @@
{
long *param_max_offset = values + MAX_PP_PARAMS_SZ - 1;
char *params = NULL;
+ u8 *updt_params = NULL;
int rc = 0;
int devices = GET_NEXT(values, param_max_offset, rc);
int num_commands = GET_NEXT(values, param_max_offset, rc);
- int *updt_params, i, prev_enable_flag;
- uint32_t params_length = (MAX_INBAND_PARAM_SZ);
+ int i, prev_enable_flag;
+ uint32_t max_params_length = 0;
+ uint32_t params_length = 0;
+ struct param_hdr_v3 param_hdr;
+ u8 *param_data = NULL;
+ u32 packed_data_size = 0;
+ u8 *eq_config_data = NULL;
+ u32 *updt_config_data = NULL;
+ int config_param_length;
pr_debug("%s\n", __func__);
if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
pr_err("%s: cannot set audio effects\n", __func__);
return -EINVAL;
}
- params = kzalloc(params_length, GFP_KERNEL);
- if (!params)
+ params = kzalloc(MAX_INBAND_PARAM_SZ, 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;
+ updt_params = (u8 *) params;
+ /* Set MID and IID once at top and only update param specific fields*/
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
+ param_hdr.instance_id = INSTANCE_ID_0;
for (i = 0; i < num_commands; i++) {
uint32_t command_id =
GET_NEXT(values, param_max_offset, rc);
@@ -1084,23 +1058,18 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: EQ_ENABLE prev:%d new:%d\n", __func__,
prev_enable_flag, eq->enable_flag);
- if (prev_enable_flag != eq->enable_flag) {
- params_length += COMMAND_PAYLOAD_SZ +
- EQ_ENABLE_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "EQ_ENABLE", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
- *updt_params++ =
- AUDPROC_PARAM_ID_EQ_ENABLE;
- *updt_params++ =
- EQ_ENABLE_PARAM_SZ;
- *updt_params++ =
- eq->enable_flag;
- }
+ if (prev_enable_flag == eq->enable_flag)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ EQ_ENABLE_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "EQ_ENABLE", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_EQ_ENABLE;
+ param_hdr.param_size = EQ_ENABLE_PARAM_SZ;
+ param_data = (u8 *) &eq->enable_flag;
break;
case EQ_CONFIG:
if (length < EQ_CONFIG_PARAM_LEN || index_offset != 0) {
@@ -1149,43 +1118,50 @@
eq->per_band_cfg[idx].quality_factor =
GET_NEXT(values, param_max_offset, rc);
}
- if (command_config_state == CONFIG_SET) {
- int config_param_length = EQ_CONFIG_PARAM_SZ +
- (EQ_CONFIG_PER_BAND_PARAM_SZ*
- eq->config.num_bands);
- params_length += COMMAND_PAYLOAD_SZ +
- config_param_length;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "EQ_CONFIG", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
- *updt_params++ =
- AUDPROC_PARAM_ID_EQ_CONFIG;
- *updt_params++ =
- config_param_length;
- *updt_params++ =
- eq->config.eq_pregain;
- *updt_params++ =
- eq->config.preset_id;
- *updt_params++ =
- eq->config.num_bands;
- for (idx = 0; idx < MAX_EQ_BANDS; idx++) {
- if (eq->per_band_cfg[idx].band_idx < 0)
- continue;
- *updt_params++ =
+ if (command_config_state != CONFIG_SET)
+ break;
+ config_param_length = EQ_CONFIG_PARAM_SZ +
+ (EQ_CONFIG_PER_BAND_PARAM_SZ *
+ eq->config.num_bands);
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ config_param_length;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "EQ_CONFIG", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_EQ_CONFIG;
+ param_hdr.param_size = config_param_length;
+
+ if (!eq_config_data)
+ eq_config_data = kzalloc(config_param_length,
+ GFP_KERNEL);
+ else
+ memset(eq_config_data, 0, config_param_length);
+ if (!eq_config_data) {
+ pr_err("%s, EQ_CONFIG:memory alloc failed\n",
+ __func__);
+ rc = -ENOMEM;
+ goto invalid_config;
+ }
+ param_data = eq_config_data;
+ updt_config_data = (u32 *) eq_config_data;
+ *updt_config_data++ = eq->config.eq_pregain;
+ *updt_config_data++ = eq->config.preset_id;
+ *updt_config_data++ = eq->config.num_bands;
+ for (idx = 0; idx < MAX_EQ_BANDS; idx++) {
+ if (eq->per_band_cfg[idx].band_idx < 0)
+ continue;
+ *updt_config_data++ =
eq->per_band_cfg[idx].filter_type;
- *updt_params++ =
+ *updt_config_data++ =
eq->per_band_cfg[idx].freq_millihertz;
- *updt_params++ =
+ *updt_config_data++ =
eq->per_band_cfg[idx].gain_millibels;
- *updt_params++ =
+ *updt_config_data++ =
eq->per_band_cfg[idx].quality_factor;
- *updt_params++ =
+ *updt_config_data++ =
eq->per_band_cfg[idx].band_idx;
- }
}
break;
case EQ_BAND_INDEX:
@@ -1203,23 +1179,18 @@
eq->band_index = idx;
pr_debug("%s: EQ_BAND_INDEX val:%d\n",
__func__, eq->band_index);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- EQ_BAND_INDEX_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "EQ_BAND_INDEX", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
- *updt_params++ =
- AUDPROC_PARAM_ID_EQ_BAND_INDEX;
- *updt_params++ =
- EQ_BAND_INDEX_PARAM_SZ;
- *updt_params++ =
- eq->band_index;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ EQ_BAND_INDEX_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "EQ_BAND_INDEX", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id = AUDPROC_PARAM_ID_EQ_BAND_INDEX;
+ param_hdr.param_size = EQ_BAND_INDEX_PARAM_SZ;
+ param_data = (u8 *) &eq->band_index;
break;
case EQ_SINGLE_BAND_FREQ:
if (length != 1 || index_offset != 0) {
@@ -1235,36 +1206,45 @@
GET_NEXT(values, param_max_offset, rc);
pr_debug("%s: EQ_SINGLE_BAND_FREQ idx:%d, val:%d\n",
__func__, eq->band_index, eq->freq_millihertz);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- EQ_SINGLE_BAND_FREQ_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "EQ_SINGLE_BAND_FREQ", rc);
- if (rc != 0)
- goto invalid_config;
- *updt_params++ =
- AUDPROC_MODULE_ID_POPLESS_EQUALIZER;
- *updt_params++ =
- AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ;
- *updt_params++ =
- EQ_SINGLE_BAND_FREQ_PARAM_SZ;
- *updt_params++ =
- eq->freq_millihertz;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ EQ_SINGLE_BAND_FREQ_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "EQ_SINGLE_BAND_FREQ", rc);
+ if (rc != 0)
+ break;
+ param_hdr.param_id =
+ AUDPROC_PARAM_ID_EQ_SINGLE_BAND_FREQ;
+ param_hdr.param_size = EQ_SINGLE_BAND_FREQ_PARAM_SZ;
+ param_data = (u8 *) &eq->freq_millihertz;
break;
default:
pr_err("%s: Invalid command to set config\n", __func__);
- break;
+ continue;
}
+ if (rc)
+ goto invalid_config;
+
+ rc = q6common_pack_pp_params(updt_params, ¶m_hdr,
+ param_data, &packed_data_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, rc);
+ goto invalid_config;
+ }
+
+ updt_params += packed_data_size;
+ params_length += packed_data_size;
}
if (params_length && (rc == 0))
- q6asm_send_audio_effects_params(ac, params,
- params_length);
+ q6asm_set_pp_params(ac, NULL, params, params_length);
else
pr_debug("%s: did not send pp params\n", __func__);
invalid_config:
kfree(params);
+ kfree(eq_config_data);
return rc;
}
EXPORT_SYMBOL(msm_audio_effects_popless_eq_handler);
@@ -1277,8 +1257,13 @@
int devices;
int num_commands;
char *params = NULL;
- int *updt_params, i;
- uint32_t params_length = (MAX_INBAND_PARAM_SZ);
+ u8 *updt_params;
+ int i;
+ uint32_t vol_gain_2ch = 0;
+ uint32_t max_params_length = 0;
+ uint32_t params_length = 0;
+ struct param_hdr_v3 param_hdr;
+ u32 packed_data_size = 0;
long *param_max_offset;
int rc = 0;
@@ -1295,12 +1280,15 @@
pr_err("%s: cannot set audio effects\n", __func__);
return -EINVAL;
}
- params = kzalloc(params_length, GFP_KERNEL);
- if (!params)
+ params = kzalloc(MAX_INBAND_PARAM_SZ, GFP_KERNEL);
+ if (!params) {
+ pr_err("%s, params memory alloc failed\n", __func__);
return -ENOMEM;
-
- updt_params = (int *)params;
- params_length = 0;
+ }
+ updt_params = (u8 *) params;
+ /* Set MID and IID once at top and only update param specific fields*/
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ q6asm_set_soft_volume_module_instance_ids(instance, ¶m_hdr);
for (i = 0; i < num_commands; i++) {
uint32_t command_id =
GET_NEXT(values, param_max_offset, rc);
@@ -1322,43 +1310,15 @@
vol->right_gain =
GET_NEXT(values, param_max_offset, rc);
vol->master_gain = 0x2000;
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
- params_length += COMMAND_PAYLOAD_SZ +
- SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "VOLUME/VOLUME2_GAIN_2CH",
- rc);
- if (rc != 0)
- goto invalid_config;
- if (instance == SOFT_VOLUME_INSTANCE_2)
- *updt_params++ =
- ASM_MODULE_ID_VOL_CTRL2;
- else
- *updt_params++ =
- ASM_MODULE_ID_VOL_CTRL;
- *updt_params++ =
- ASM_PARAM_ID_VOL_CTRL_LR_CHANNEL_GAIN;
- *updt_params++ =
- SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
- *updt_params++ =
- (vol->left_gain << 16) |
- vol->right_gain;
- if (instance == SOFT_VOLUME_INSTANCE_2)
- *updt_params++ =
- ASM_MODULE_ID_VOL_CTRL2;
- else
- *updt_params++ =
- ASM_MODULE_ID_VOL_CTRL;
- *updt_params++ =
- ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN;
- *updt_params++ =
- SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
- *updt_params++ =
- vol->master_gain;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ SOFT_VOLUME_GAIN_2CH_PARAM_SZ +
+ COMMAND_IID_PAYLOAD_SZ +
+ SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "VOLUME/VOLUME2_GAIN_2CH", rc);
break;
case SOFT_VOLUME_GAIN_MASTER:
case SOFT_VOLUME2_GAIN_MASTER:
@@ -1371,53 +1331,57 @@
vol->right_gain = 0x2000;
vol->master_gain =
GET_NEXT(values, param_max_offset, rc);
- if (command_config_state == CONFIG_SET) {
- params_length += COMMAND_PAYLOAD_SZ +
- SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
- params_length += COMMAND_PAYLOAD_SZ +
- SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
- CHECK_PARAM_LEN(params_length,
- MAX_INBAND_PARAM_SZ,
- "VOLUME/VOLUME2_GAIN_MASTER",
- rc);
- if (rc != 0)
- goto invalid_config;
- if (instance == SOFT_VOLUME_INSTANCE_2)
- *updt_params++ =
- ASM_MODULE_ID_VOL_CTRL2;
- else
- *updt_params++ =
- ASM_MODULE_ID_VOL_CTRL;
- *updt_params++ =
- ASM_PARAM_ID_VOL_CTRL_LR_CHANNEL_GAIN;
- *updt_params++ =
- SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
- *updt_params++ =
- (vol->left_gain << 16) |
- vol->right_gain;
- if (instance == SOFT_VOLUME_INSTANCE_2)
- *updt_params++ =
- ASM_MODULE_ID_VOL_CTRL2;
- else
- *updt_params++ =
- ASM_MODULE_ID_VOL_CTRL;
- *updt_params++ =
- ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN;
- *updt_params++ =
- SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
- *updt_params++ =
- vol->master_gain;
- }
+ if (command_config_state != CONFIG_SET)
+ break;
+ max_params_length = params_length +
+ COMMAND_IID_PAYLOAD_SZ +
+ SOFT_VOLUME_GAIN_2CH_PARAM_SZ +
+ COMMAND_IID_PAYLOAD_SZ +
+ SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
+ CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
+ "VOLUME/VOLUME2_GAIN_MASTER", rc);
break;
default:
pr_err("%s: Invalid command id: %d to set config\n",
__func__, command_id);
- break;
+ continue;
}
+ if (rc)
+ continue;
+
+ /* Set Volume Control for Left/Right */
+ param_hdr.param_id = ASM_PARAM_ID_VOL_CTRL_LR_CHANNEL_GAIN;
+ param_hdr.param_size = SOFT_VOLUME_GAIN_2CH_PARAM_SZ;
+ vol_gain_2ch = (vol->left_gain << 16) | vol->right_gain;
+ rc = q6common_pack_pp_params(updt_params, ¶m_hdr,
+ (u8 *) &vol_gain_2ch,
+ &packed_data_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, rc);
+ goto invalid_config;
+ }
+
+ updt_params += packed_data_size;
+ params_length += packed_data_size;
+
+ /* Set Master Volume Control */
+ param_hdr.param_id = ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN;
+ param_hdr.param_size = SOFT_VOLUME_GAIN_MASTER_PARAM_SZ;
+ rc = q6common_pack_pp_params(updt_params, ¶m_hdr,
+ (u8 *) &vol->master_gain,
+ &packed_data_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, rc);
+ goto invalid_config;
+ }
+
+ updt_params += packed_data_size;
+ params_length += packed_data_size;
}
if (params_length && (rc == 0))
- q6asm_send_audio_effects_params(ac, params,
- params_length);
+ q6asm_set_pp_params(ac, NULL, params, params_length);
invalid_config:
kfree(params);
return rc;
diff --git a/asoc/msm-cpe-lsm.c b/asoc/msm-cpe-lsm.c
index 2dc32f6..4094c1e 100644
--- a/asoc/msm-cpe-lsm.c
+++ b/asoc/msm-cpe-lsm.c
@@ -478,18 +478,21 @@
lab_d->pcm_buf = pcm_buf;
dma_alloc = bufsz * bufcnt;
pcm_buf->mem = NULL;
- pcm_buf->mem = dma_alloc_coherent(dma_data->sdev->dev.parent,
- dma_alloc,
- &(pcm_buf->phys),
- GFP_KERNEL);
+ pcm_buf->mem = kzalloc(dma_alloc, GFP_DMA);
if (!pcm_buf->mem) {
- dev_err(rtd->dev,
- "%s:DMA alloc failed size = %x\n",
- __func__, dma_alloc);
rc = -ENOMEM;
goto fail;
}
+ pcm_buf->phys = dma_map_single(dma_data->sdev->dev.parent,
+ pcm_buf->mem, dma_alloc, DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(dma_data->sdev->dev.parent, pcm_buf->phys)) {
+ dev_err(rtd->dev, "%s Error mapping DMA buffers\n", __func__);
+ pcm_buf->phys = (phys_addr_t)NULL;
+ rc = -EFAULT;
+ goto fail;
+ }
+
count = 0;
while (count < bufcnt) {
pcm_buf[count].mem = pcm_buf[0].mem + (count * bufsz);
@@ -504,13 +507,10 @@
return 0;
fail:
- if (pcm_buf) {
- if (pcm_buf->mem)
- dma_free_coherent(dma_data->sdev->dev.parent, dma_alloc,
- pcm_buf->mem, pcm_buf->phys);
- kfree(pcm_buf);
- lab_d->pcm_buf = NULL;
- }
+ if (pcm_buf && pcm_buf->mem)
+ kfree(pcm_buf->mem);
+ kfree(pcm_buf);
+ lab_d->pcm_buf = NULL;
exit:
return rc;
}
@@ -544,8 +544,12 @@
pcm_buf = lab_d->pcm_buf;
dma_alloc = bufsz * bufcnt;
if (dma_data && pcm_buf)
- dma_free_coherent(dma_data->sdev->dev.parent, dma_alloc,
- pcm_buf->mem, pcm_buf->phys);
+ if (pcm_buf->phys)
+ dma_unmap_single(dma_data->sdev->dev.parent,
+ pcm_buf->phys, dma_alloc, DMA_BIDIRECTIONAL);
+ if (pcm_buf)
+ kfree(pcm_buf->mem);
+
kfree(pcm_buf);
lab_d->pcm_buf = NULL;
return rc;
@@ -633,7 +637,7 @@
memset(lab_d->pcm_buf[0].mem, 0, lab_d->pcm_size);
rc = slim_port_xfer(dma_data->sdev, dma_data->ph,
- lab_d->pcm_buf[0].phys,
+ lab_d->pcm_buf[0].mem,
hw_params->buf_sz, &lab_d->comp);
if (rc) {
dev_err(rtd->dev,
@@ -643,7 +647,7 @@
}
rc = slim_port_xfer(dma_data->sdev, dma_data->ph,
- lab_d->pcm_buf[1].phys,
+ lab_d->pcm_buf[1].mem,
hw_params->buf_sz, &lab_d->comp);
if (rc) {
dev_err(rtd->dev,
@@ -678,7 +682,7 @@
lab_d->thread_status != MSM_LSM_LAB_THREAD_ERROR) {
rc = slim_port_xfer(dma_data->sdev, dma_data->ph,
- next_buf->phys,
+ next_buf->mem,
hw_params->buf_sz, &lab_d->comp);
if (rc) {
dev_err(rtd->dev,
diff --git a/asoc/msm-ds2-dap-config.c b/asoc/msm-ds2-dap-config.c
index 645ecf5..ad7a3c6 100644
--- a/asoc/msm-ds2-dap-config.c
+++ b/asoc/msm-ds2-dap-config.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2018, 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
@@ -17,6 +17,7 @@
#include <sound/control.h>
#include <dsp/q6adm-v2.h>
#include <dsp/q6core.h>
+#include <dsp/q6common.h>
#include "msm-ds2-dap-config.h"
#include "msm-pcm-routing-v2.h"
@@ -196,18 +197,23 @@
int32_t *update_params_value = NULL;
uint32_t params_length = SOFT_VOLUME_PARAM_SIZE * sizeof(uint32_t);
uint32_t param_payload_len = PARAM_PAYLOAD_SIZE * sizeof(uint32_t);
+ struct param_hdr_v3 param_hdr;
int rc = 0;
update_params_value = kzalloc(params_length + param_payload_len,
GFP_KERNEL);
- if (!update_params_value)
+ if (!update_params_value) {
+ pr_err("%s: params memory alloc failed\n", __func__);
goto end;
+ }
- rc = adm_get_params(port_id, copp_idx,
- AUDPROC_MODULE_ID_VOL_CTRL,
- AUDPROC_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS,
- params_length + param_payload_len,
- (char *) update_params_value);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_VOL_CTRL;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS;
+ param_hdr.param_size = params_length + param_payload_len;
+ rc = adm_get_pp_params(port_id, copp_idx, ADM_CLIENT_ID_DEFAULT, NULL,
+ ¶m_hdr, (char *) update_params_value);
if (rc == 0) {
pr_debug("%s: params_value [0x%x, 0x%x, 0x%x]\n",
__func__, update_params_value[0],
@@ -227,12 +233,13 @@
static int msm_ds2_dap_set_vspe_vdhe(int dev_map_idx,
bool is_custom_stereo_enabled)
{
- int32_t *update_params_value = NULL;
- int32_t *param_val = NULL;
- int idx, i, j, rc = 0, cdev;
- uint32_t params_length = (TOTAL_LENGTH_DOLBY_PARAM +
- 2 * DOLBY_PARAM_PAYLOAD_SIZE) *
- sizeof(uint32_t);
+ u8 *packed_param_data = NULL;
+ u8 *param_data = NULL;
+ struct param_hdr_v3 param_hdr;
+ u32 packed_param_size = 0;
+ u32 param_size = 0;
+ int cdev;
+ int rc = 0;
if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
@@ -260,74 +267,95 @@
goto end;
}
- update_params_value = kzalloc(params_length, GFP_KERNEL);
- if (!update_params_value) {
- rc = -ENOMEM;
+ /* Allocate the max space needed */
+ packed_param_size = (TOTAL_LENGTH_DOLBY_PARAM * sizeof(uint32_t)) +
+ (2 * sizeof(union param_hdrs));
+ packed_param_data = kzalloc(packed_param_size, GFP_KERNEL);
+ if (!packed_param_data)
+ return -ENOMEM;
+
+ packed_param_size = 0;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
+ /* Set common values */
+ cdev = dev_map[dev_map_idx].cache_dev;
+ param_hdr.module_id = DOLBY_BUNDLE_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+
+ /* Pack VDHE header + data */
+ param_hdr.param_id = DOLBY_PARAM_ID_VDHE;
+ param_size = DOLBY_PARAM_VDHE_LENGTH * sizeof(uint32_t);
+ param_hdr.param_size = param_size;
+
+ if (is_custom_stereo_enabled)
+ param_data = NULL;
+ else
+ param_data = (u8 *) &ds2_dap_params[cdev]
+ .params_val[DOLBY_PARAM_VDHE_OFFSET];
+
+ rc = q6common_pack_pp_params(packed_param_data, ¶m_hdr, param_data,
+ ¶m_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params for dolby vdhe, error %d\n",
+ __func__, rc);
goto end;
}
- params_length = 0;
- param_val = update_params_value;
- cdev = dev_map[dev_map_idx].cache_dev;
- /* for VDHE and VSPE DAP params at index 0 and 1 in table */
- for (i = 0; i < 2; i++) {
- *update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
- *update_params_value++ = ds2_dap_params_id[i];
- *update_params_value++ = ds2_dap_params_length[i] *
- sizeof(uint32_t);
- idx = ds2_dap_params_offset[i];
- for (j = 0; j < ds2_dap_params_length[i]; j++) {
- if (is_custom_stereo_enabled)
- *update_params_value++ = 0;
- else
- *update_params_value++ =
- ds2_dap_params[cdev].params_val[idx+j];
- }
- params_length += (DOLBY_PARAM_PAYLOAD_SIZE +
- ds2_dap_params_length[i]) *
- sizeof(uint32_t);
- }
+ packed_param_size += param_size;
- pr_debug("%s: valid param length: %d\n", __func__, params_length);
- if (params_length) {
- rc = adm_dolby_dap_send_params(dev_map[dev_map_idx].port_id,
- dev_map[dev_map_idx].copp_idx,
- (char *)param_val,
- params_length);
- if (rc) {
- pr_err("%s: send vdhe/vspe params failed with rc=%d\n",
- __func__, rc);
- rc = -EINVAL;
- goto end;
- }
+ /* Pack VSPE header + data */
+ param_hdr.param_id = DOLBY_PARAM_ID_VSPE;
+ param_size = DOLBY_PARAM_VSPE_LENGTH * sizeof(uint32_t);
+ param_hdr.param_size = param_size;
+
+ if (is_custom_stereo_enabled)
+ param_data = NULL;
+ else
+ param_data = (u8 *) &ds2_dap_params[cdev]
+ .params_val[DOLBY_PARAM_VSPE_OFFSET];
+
+ rc = q6common_pack_pp_params(packed_param_data + packed_param_size,
+ ¶m_hdr, param_data, ¶m_size);
+ if (rc) {
+ pr_err("%s: Failed to pack params for dolby vspe, error %d\n",
+ __func__, rc);
+ goto end;
+ }
+ packed_param_size += param_size;
+
+ rc = adm_set_pp_params(dev_map[dev_map_idx].port_id,
+ dev_map[dev_map_idx].copp_idx, NULL,
+ packed_param_data, packed_param_size);
+ if (rc) {
+ pr_err("%s: send vdhe/vspe params failed with rc=%d\n",
+ __func__, rc);
+ rc = -EINVAL;
+ goto end;
}
end:
- kfree(param_val);
+ kfree(packed_param_data);
return rc;
}
int qti_set_custom_stereo_on(int port_id, int copp_idx,
bool is_custom_stereo_on)
{
-
+ struct custom_stereo_param custom_stereo;
+ struct param_hdr_v3 param_hdr;
uint16_t op_FL_ip_FL_weight;
uint16_t op_FL_ip_FR_weight;
uint16_t op_FR_ip_FL_weight;
uint16_t op_FR_ip_FR_weight;
-
- int32_t *update_params_value32 = NULL, rc = 0;
- int32_t *param_val = NULL;
- int16_t *update_params_value16 = 0;
- uint32_t params_length_bytes = CUSTOM_STEREO_PAYLOAD_SIZE *
- sizeof(uint32_t);
- uint32_t avail_length = params_length_bytes;
+ int rc = 0;
if ((port_id != SLIMBUS_0_RX) &&
(port_id != RT_PROXY_PORT_001_RX)) {
pr_debug("%s:No Custom stereo for port:0x%x\n",
__func__, port_id);
- goto skip_send_cmd;
+ return 0;
}
+ memset(&custom_stereo, 0, sizeof(custom_stereo));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
pr_debug("%s: port 0x%x, copp_idx %d, is_custom_stereo_on %d\n",
__func__, port_id, copp_idx, is_custom_stereo_on);
if (is_custom_stereo_on) {
@@ -346,76 +374,50 @@
op_FR_ip_FR_weight = Q14_GAIN_UNITY;
}
- update_params_value32 = kzalloc(params_length_bytes, GFP_KERNEL);
- if (!update_params_value32) {
- rc = -ENOMEM;
- goto skip_send_cmd;
- }
- param_val = update_params_value32;
- if (avail_length < 2 * sizeof(uint32_t))
- goto skip_send_cmd;
- *update_params_value32++ = MTMX_MODULE_ID_DEFAULT_CHMIXER;
- *update_params_value32++ = DEFAULT_CHMIXER_PARAM_ID_COEFF;
- avail_length = avail_length - (2 * sizeof(uint32_t));
+ param_hdr.module_id = MTMX_MODULE_ID_DEFAULT_CHMIXER;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = DEFAULT_CHMIXER_PARAM_ID_COEFF;
+ param_hdr.param_size = sizeof(struct custom_stereo_param);
- update_params_value16 = (int16_t *)update_params_value32;
- if (avail_length < 10 * sizeof(uint16_t))
- goto skip_send_cmd;
- *update_params_value16++ = CUSTOM_STEREO_CMD_PARAM_SIZE;
- /* for alignment only*/
- *update_params_value16++ = 0;
/* index is 32-bit param in little endian*/
- *update_params_value16++ = CUSTOM_STEREO_INDEX_PARAM;
- *update_params_value16++ = 0;
+ custom_stereo.index = CUSTOM_STEREO_INDEX_PARAM;
+ custom_stereo.reserved = 0;
/* for stereo mixing num out ch*/
- *update_params_value16++ = CUSTOM_STEREO_NUM_OUT_CH;
+ custom_stereo.num_out_ch = CUSTOM_STEREO_NUM_OUT_CH;
/* for stereo mixing num in ch*/
- *update_params_value16++ = CUSTOM_STEREO_NUM_IN_CH;
+ custom_stereo.num_in_ch = CUSTOM_STEREO_NUM_IN_CH;
/* Out ch map FL/FR*/
- *update_params_value16++ = PCM_CHANNEL_FL;
- *update_params_value16++ = PCM_CHANNEL_FR;
+ custom_stereo.out_fl = PCM_CHANNEL_FL;
+ custom_stereo.out_fr = PCM_CHANNEL_FR;
/* In ch map FL/FR*/
- *update_params_value16++ = PCM_CHANNEL_FL;
- *update_params_value16++ = PCM_CHANNEL_FR;
- avail_length = avail_length - (10 * sizeof(uint16_t));
+ custom_stereo.in_fl = PCM_CHANNEL_FL;
+ custom_stereo.in_fr = PCM_CHANNEL_FR;
+
/* weighting coefficients as name suggests,
* mixing will be done according to these coefficients
*/
- if (avail_length < 4 * sizeof(uint16_t))
- goto skip_send_cmd;
- *update_params_value16++ = op_FL_ip_FL_weight;
- *update_params_value16++ = op_FL_ip_FR_weight;
- *update_params_value16++ = op_FR_ip_FL_weight;
- *update_params_value16++ = op_FR_ip_FR_weight;
- avail_length = avail_length - (4 * sizeof(uint16_t));
- if (params_length_bytes != 0) {
- rc = adm_dolby_dap_send_params(port_id, copp_idx,
- (char *)param_val,
- params_length_bytes);
- if (rc) {
- pr_err("%s: send params failed rc=%d\n", __func__, rc);
- rc = -EINVAL;
- goto skip_send_cmd;
- }
+ custom_stereo.op_FL_ip_FL_weight = op_FL_ip_FL_weight;
+ custom_stereo.op_FL_ip_FR_weight = op_FL_ip_FR_weight;
+ custom_stereo.op_FR_ip_FL_weight = op_FR_ip_FL_weight;
+ custom_stereo.op_FR_ip_FR_weight = op_FR_ip_FR_weight;
+ rc = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (u8 *) &custom_stereo);
+ if (rc) {
+ pr_err("%s: send params failed rc=%d\n", __func__, rc);
+ return -EINVAL;
}
- kfree(param_val);
+
return 0;
-skip_send_cmd:
- pr_err("%s: insufficient memory, send cmd failed\n",
- __func__);
- kfree(param_val);
- return rc;
}
static int dap_set_custom_stereo_onoff(int dev_map_idx,
bool is_custom_stereo_enabled)
{
+ uint32_t enable = is_custom_stereo_enabled ? 1 : 0;
+ struct param_hdr_v3 param_hdr;
+ int rc = 0;
- int32_t *update_params_value = NULL, rc = 0;
- int32_t *param_val = NULL;
- uint32_t params_length_bytes = (TOTAL_LENGTH_DOLBY_PARAM +
- DOLBY_PARAM_PAYLOAD_SIZE) * sizeof(uint32_t);
if ((dev_map[dev_map_idx].port_id != SLIMBUS_0_RX) &&
(dev_map[dev_map_idx].port_id != RT_PROXY_PORT_001_RX)) {
pr_debug("%s:No Custom stereo for port:0x%x\n",
@@ -429,41 +431,25 @@
goto end;
}
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
/* DAP custom stereo */
msm_ds2_dap_set_vspe_vdhe(dev_map_idx,
is_custom_stereo_enabled);
- update_params_value = kzalloc(params_length_bytes, GFP_KERNEL);
- if (!update_params_value) {
- pr_err("%s: params memory alloc failed\n", __func__);
- rc = -ENOMEM;
- goto end;
- }
- params_length_bytes = 0;
- param_val = update_params_value;
- *update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
- *update_params_value++ = DOLBY_ENABLE_CUSTOM_STEREO;
- *update_params_value++ = sizeof(uint32_t);
- if (is_custom_stereo_enabled)
- *update_params_value++ = 1;
- else
- *update_params_value++ = 0;
- params_length_bytes += (DOLBY_PARAM_PAYLOAD_SIZE + 1) *
- sizeof(uint32_t);
- pr_debug("%s: valid param length: %d\n", __func__, params_length_bytes);
- if (params_length_bytes) {
- rc = adm_dolby_dap_send_params(dev_map[dev_map_idx].port_id,
- dev_map[dev_map_idx].copp_idx,
- (char *)param_val,
- params_length_bytes);
- if (rc) {
- pr_err("%s: custom stereo param failed with rc=%d\n",
- __func__, rc);
- rc = -EINVAL;
- goto end;
- }
+ param_hdr.module_id = DOLBY_BUNDLE_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = DOLBY_ENABLE_CUSTOM_STEREO;
+ param_hdr.param_size = sizeof(enable);
+
+ rc = adm_pack_and_set_one_pp_param(dev_map[dev_map_idx].port_id,
+ dev_map[dev_map_idx].copp_idx,
+ param_hdr, (u8 *) &enable);
+ if (rc) {
+ pr_err("%s: set custom stereo enable failed with rc=%d\n",
+ __func__, rc);
+ rc = -EINVAL;
}
end:
- kfree(param_val);
return rc;
}
@@ -652,8 +638,11 @@
{
int rc = 0, i = 0, port_id, copp_idx;
/* Account for 32 bit integer allocation */
- int32_t param_sz = (ADM_GET_TOPO_MODULE_LIST_LENGTH / sizeof(uint32_t));
+ int32_t param_sz =
+ (ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH / sizeof(uint32_t));
int32_t *update_param_val = NULL;
+ struct module_instance_info mod_inst_info;
+ int mod_inst_info_sz = 0;
if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
@@ -661,10 +650,12 @@
goto end;
}
+ memset(&mod_inst_info, 0, sizeof(mod_inst_info));
port_id = dev_map[dev_map_idx].port_id;
copp_idx = dev_map[dev_map_idx].copp_idx;
pr_debug("%s: port_id 0x%x copp_idx %d\n", __func__, port_id, copp_idx);
- update_param_val = kzalloc(ADM_GET_TOPO_MODULE_LIST_LENGTH, GFP_KERNEL);
+ update_param_val =
+ kzalloc(ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH, GFP_KERNEL);
if (!update_param_val) {
pr_err("%s, param memory alloc failed\n", __func__);
rc = -ENOMEM;
@@ -673,9 +664,10 @@
if (!ds2_dap_params_states.dap_bypass) {
/* get modules from dsp */
- rc = adm_get_pp_topo_module_list(port_id, copp_idx,
- ADM_GET_TOPO_MODULE_LIST_LENGTH,
- (char *)update_param_val);
+ rc = adm_get_pp_topo_module_list_v2(
+ port_id, copp_idx,
+ ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH,
+ update_param_val);
if (rc < 0) {
pr_err("%s:topo list port %d, err %d,copp_idx %d\n",
__func__, port_id, copp_idx, rc);
@@ -689,11 +681,15 @@
rc = -EINVAL;
goto end;
}
+
+ mod_inst_info_sz = sizeof(struct module_instance_info) /
+ sizeof(uint32_t);
/* Turn off modules */
- for (i = 1; i < update_param_val[0]; i++) {
+ for (i = 1; i < update_param_val[0] * mod_inst_info_sz;
+ i += mod_inst_info_sz) {
if (!msm_ds2_dap_can_enable_module(
- update_param_val[i]) ||
- (update_param_val[i] == DS2_MODULE_ID)) {
+ update_param_val[i]) ||
+ (update_param_val[i] == DS2_MODULE_ID)) {
pr_debug("%s: Do not enable/disable %d\n",
__func__, update_param_val[i]);
continue;
@@ -701,15 +697,21 @@
pr_debug("%s: param disable %d\n",
__func__, update_param_val[i]);
- adm_param_enable(port_id, copp_idx, update_param_val[i],
- MODULE_DISABLE);
+ memcpy(&mod_inst_info, &update_param_val[i],
+ sizeof(mod_inst_info));
+ adm_param_enable_v2(port_id, copp_idx,
+ mod_inst_info,
+ MODULE_DISABLE);
}
} else {
msm_ds2_dap_send_cal_data(dev_map_idx);
}
- adm_param_enable(port_id, copp_idx, DS2_MODULE_ID,
- !ds2_dap_params_states.dap_bypass);
+
+ mod_inst_info.module_id = DS2_MODULE_ID;
+ mod_inst_info.instance_id = INSTANCE_ID_0;
+ adm_param_enable_v2(port_id, copp_idx, mod_inst_info,
+ !ds2_dap_params_states.dap_bypass);
end:
kfree(update_param_val);
return rc;
@@ -885,17 +887,22 @@
{
int rc = 0, i = 0, j = 0;
/*Account for 32 bit integer allocation */
- int32_t param_sz = (ADM_GET_TOPO_MODULE_LIST_LENGTH / sizeof(uint32_t));
+ int32_t param_sz =
+ (ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH / sizeof(uint32_t));
int32_t *mod_list = NULL;
int port_id = 0, copp_idx = -1;
bool cs_onoff = ds2_dap_params_states.custom_stereo_onoff;
int ramp_wait = DOLBY_SOFT_VOLUME_PERIOD;
+ struct module_instance_info mod_inst_info;
+ int mod_inst_info_sz = 0;
pr_debug("%s: bypass type %d bypass %d custom stereo %d\n", __func__,
ds2_dap_params_states.dap_bypass_type,
ds2_dap_params_states.dap_bypass,
ds2_dap_params_states.custom_stereo_onoff);
- mod_list = kzalloc(ADM_GET_TOPO_MODULE_LIST_LENGTH, GFP_KERNEL);
+ memset(&mod_inst_info, 0, sizeof(mod_inst_info));
+ mod_list =
+ kzalloc(ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH, GFP_KERNEL);
if (!mod_list) {
pr_err("%s: param memory alloc failed\n", __func__);
rc = -ENOMEM;
@@ -922,9 +929,10 @@
}
/* getmodules from dsp */
- rc = adm_get_pp_topo_module_list(port_id, copp_idx,
- ADM_GET_TOPO_MODULE_LIST_LENGTH,
- (char *)mod_list);
+ rc = adm_get_pp_topo_module_list_v2(
+ port_id, copp_idx,
+ ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH,
+ mod_list);
if (rc < 0) {
pr_err("%s:adm get topo list port %d",
__func__, port_id);
@@ -976,8 +984,11 @@
/* if dap bypass is set */
if (ds2_dap_params_states.dap_bypass) {
/* Turn off dap module */
- adm_param_enable(port_id, copp_idx,
- DS2_MODULE_ID, MODULE_DISABLE);
+ mod_inst_info.module_id = DS2_MODULE_ID;
+ mod_inst_info.instance_id = INSTANCE_ID_0;
+ adm_param_enable_v2(port_id, copp_idx,
+ mod_inst_info,
+ MODULE_DISABLE);
/*
* If custom stereo is on at the time of bypass,
* switch off custom stereo on dap and turn on
@@ -1000,8 +1011,13 @@
copp_idx, rc);
}
}
+
+ mod_inst_info_sz =
+ sizeof(struct module_instance_info) /
+ sizeof(uint32_t);
/* Turn on qti modules */
- for (j = 1; j < mod_list[0]; j++) {
+ for (j = 1; j < mod_list[0] * mod_inst_info_sz;
+ j += mod_inst_info_sz) {
if (!msm_ds2_dap_can_enable_module(
mod_list[j]) ||
mod_list[j] ==
@@ -1009,9 +1025,11 @@
continue;
pr_debug("%s: param enable %d\n",
__func__, mod_list[j]);
- adm_param_enable(port_id, copp_idx,
- mod_list[j],
- MODULE_ENABLE);
+ memcpy(&mod_inst_info, &mod_list[j],
+ sizeof(mod_inst_info));
+ adm_param_enable_v2(port_id, copp_idx,
+ mod_inst_info,
+ MODULE_ENABLE);
}
/* Add adm api to resend calibration on port */
@@ -1026,7 +1044,8 @@
}
} else {
/* Turn off qti modules */
- for (j = 1; j < mod_list[0]; j++) {
+ for (j = 1; j < mod_list[0] * mod_inst_info_sz;
+ j += mod_inst_info_sz) {
if (!msm_ds2_dap_can_enable_module(
mod_list[j]) ||
mod_list[j] ==
@@ -1034,15 +1053,20 @@
continue;
pr_debug("%s: param disable %d\n",
__func__, mod_list[j]);
- adm_param_enable(port_id, copp_idx,
- mod_list[j],
- MODULE_DISABLE);
+ memcpy(&mod_inst_info, &mod_list[j],
+ sizeof(mod_inst_info));
+ adm_param_enable_v2(port_id, copp_idx,
+ mod_inst_info,
+ MODULE_DISABLE);
}
/* Enable DAP modules */
pr_debug("%s:DS2 param enable\n", __func__);
- adm_param_enable(port_id, copp_idx,
- DS2_MODULE_ID, MODULE_ENABLE);
+ mod_inst_info.module_id = DS2_MODULE_ID;
+ mod_inst_info.instance_id = INSTANCE_ID_0;
+ adm_param_enable_v2(port_id, copp_idx,
+ mod_inst_info,
+ MODULE_ENABLE);
/*
* If custom stereo is on at the time of dap on,
* switch off custom stereo on qti channel mixer
@@ -1101,19 +1125,19 @@
static int msm_ds2_dap_send_end_point(int dev_map_idx, int endp_idx)
{
- int rc = 0;
- int32_t *update_params_value = NULL, *params_value = NULL;
- uint32_t params_length = (DOLBY_PARAM_INT_ENDP_LENGTH +
- DOLBY_PARAM_PAYLOAD_SIZE) * sizeof(uint32_t);
+ uint32_t offset = 0;
+ struct param_hdr_v3 param_hdr;
int cache_device = 0;
struct ds2_dap_params_s *ds2_ap_params_obj = NULL;
int32_t *modified_param = NULL;
+ int rc = 0;
if (dev_map_idx < 0 || dev_map_idx >= DS2_DEVICES_ALL) {
pr_err("%s: invalid dev map index %d\n", __func__, dev_map_idx);
rc = -EINVAL;
goto end;
}
+ memset(¶m_hdr, 0, sizeof(param_hdr));
cache_device = dev_map[dev_map_idx].cache_dev;
ds2_ap_params_obj = &ds2_dap_params[cache_device];
@@ -1122,12 +1146,6 @@
pr_debug("%s: endp - %pK %pK\n", __func__,
&ds2_dap_params[cache_device], ds2_ap_params_obj);
- params_value = kzalloc(params_length, GFP_KERNEL);
- if (!params_value) {
- rc = -ENOMEM;
- goto end;
- }
-
if (dev_map[dev_map_idx].port_id == DOLBY_INVALID_PORT_ID) {
pr_err("%s: invalid port\n", __func__);
rc = -EINVAL;
@@ -1141,21 +1159,20 @@
goto end;
}
- update_params_value = params_value;
- *update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
- *update_params_value++ = DOLBY_PARAM_ID_INIT_ENDP;
- *update_params_value++ = DOLBY_PARAM_INT_ENDP_LENGTH * sizeof(uint32_t);
- *update_params_value++ = ds2_ap_params_obj->params_val[
- ds2_dap_params_offset[endp_idx]];
+ param_hdr.module_id = DOLBY_BUNDLE_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = DOLBY_PARAM_ID_INIT_ENDP;
+ param_hdr.param_size = sizeof(offset);
+ offset = ds2_ap_params_obj->params_val[ds2_dap_params_offset[endp_idx]];
pr_debug("%s: off %d, length %d\n", __func__,
ds2_dap_params_offset[endp_idx],
ds2_dap_params_length[endp_idx]);
pr_debug("%s: param 0x%x, param val %d\n", __func__,
ds2_dap_params_id[endp_idx], ds2_ap_params_obj->
params_val[ds2_dap_params_offset[endp_idx]]);
- rc = adm_dolby_dap_send_params(dev_map[dev_map_idx].port_id,
- dev_map[dev_map_idx].copp_idx,
- (char *)params_value, params_length);
+ rc = adm_pack_and_set_one_pp_param(dev_map[dev_map_idx].port_id,
+ dev_map[dev_map_idx].copp_idx,
+ param_hdr, (u8 *) &offset);
if (rc) {
pr_err("%s: send dolby params failed rc %d\n", __func__, rc);
rc = -EINVAL;
@@ -1172,19 +1189,17 @@
ds2_ap_params_obj->dap_params_modified[endp_idx] = 0x00010001;
end:
- kfree(params_value);
return rc;
}
static int msm_ds2_dap_send_cached_params(int dev_map_idx,
int commit)
{
- int32_t *update_params_value = NULL, *params_value = NULL;
- uint32_t idx, i, j, ret = 0;
- uint32_t params_length = (TOTAL_LENGTH_DOLBY_PARAM +
- (MAX_DS2_PARAMS - 1) *
- DOLBY_PARAM_PAYLOAD_SIZE) *
- sizeof(uint32_t);
+ uint8_t *packed_params = NULL;
+ uint32_t packed_params_size = 0;
+ uint32_t param_size = 0;
+ struct param_hdr_v3 param_hdr;
+ uint32_t idx, i, ret = 0;
int cache_device = 0;
struct ds2_dap_params_s *ds2_ap_params_obj = NULL;
int32_t *modified_param = NULL;
@@ -1194,6 +1209,7 @@
ret = -EINVAL;
goto end;
}
+ memset(¶m_hdr, 0, sizeof(param_hdr));
cache_device = dev_map[dev_map_idx].cache_dev;
/* Use off profile cache in only for soft bypass */
@@ -1207,12 +1223,16 @@
pr_debug("%s: cached param - %pK %pK, cache_device %d\n", __func__,
&ds2_dap_params[cache_device], ds2_ap_params_obj,
cache_device);
- params_value = kzalloc(params_length, GFP_KERNEL);
- if (!params_value) {
- pr_err("%s: params memory alloc failed\n", __func__);
- ret = -ENOMEM;
- goto end;
- }
+
+ /*
+ * Allocate the max space needed. This is enough space to hold the
+ * header for each param plus the total size of all the params.
+ */
+ packed_params_size = (sizeof(param_hdr) * (MAX_DS2_PARAMS - 1)) +
+ (TOTAL_LENGTH_DOLBY_PARAM * sizeof(uint32_t));
+ packed_params = kzalloc(packed_params_size, GFP_KERNEL);
+ if (!packed_params)
+ return -ENOMEM;
if (dev_map[dev_map_idx].port_id == DOLBY_INVALID_PORT_ID) {
pr_err("%s: invalid port id\n", __func__);
@@ -1227,8 +1247,7 @@
goto end;
}
- update_params_value = params_value;
- params_length = 0;
+ packed_params_size = 0;
for (i = 0; i < (MAX_DS2_PARAMS-1); i++) {
/*get the pointer to the param modified array in the cache*/
modified_param = ds2_ap_params_obj->dap_params_modified;
@@ -1241,28 +1260,33 @@
if (!msm_ds2_dap_check_is_param_modified(modified_param, i,
commit))
continue;
- *update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
- *update_params_value++ = ds2_dap_params_id[i];
- *update_params_value++ = ds2_dap_params_length[i] *
- sizeof(uint32_t);
+
+ param_hdr.module_id = DOLBY_BUNDLE_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = ds2_dap_params_id[i];
+ param_hdr.param_size =
+ ds2_dap_params_length[i] * sizeof(uint32_t);
+
idx = ds2_dap_params_offset[i];
- for (j = 0; j < ds2_dap_params_length[i]; j++) {
- *update_params_value++ =
- ds2_ap_params_obj->params_val[idx+j];
- pr_debug("%s: id 0x%x,val %d\n", __func__,
- ds2_dap_params_id[i],
- ds2_ap_params_obj->params_val[idx+j]);
+ ret = q6common_pack_pp_params(
+ packed_params + packed_params_size, ¶m_hdr,
+ (u8 *) &ds2_ap_params_obj->params_val[idx],
+ ¶m_size);
+ if (ret) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, ret);
+ goto end;
}
- params_length += (DOLBY_PARAM_PAYLOAD_SIZE +
- ds2_dap_params_length[i]) * sizeof(uint32_t);
+
+ packed_params_size += param_size;
}
- pr_debug("%s: valid param length: %d\n", __func__, params_length);
- if (params_length) {
- ret = adm_dolby_dap_send_params(dev_map[dev_map_idx].port_id,
- dev_map[dev_map_idx].copp_idx,
- (char *)params_value,
- params_length);
+ pr_debug("%s: total packed param length: %d\n", __func__,
+ packed_params_size);
+ if (packed_params_size) {
+ ret = adm_set_pp_params(dev_map[dev_map_idx].port_id,
+ dev_map[dev_map_idx].copp_idx, NULL,
+ packed_params, packed_params_size);
if (ret) {
pr_err("%s: send dolby params failed ret %d\n",
__func__, ret);
@@ -1285,7 +1309,7 @@
}
}
end:
- kfree(params_value);
+ kfree(packed_params);
return ret;
}
@@ -1523,11 +1547,12 @@
{
int rc = 0, i, port_id = 0, copp_idx = -1;
struct dolby_param_data *dolby_data = (struct dolby_param_data *)arg;
- int32_t *update_params_value = NULL, *params_value = NULL;
+ int32_t *params_value = NULL;
uint32_t params_length = DOLBY_MAX_LENGTH_INDIVIDUAL_PARAM *
sizeof(uint32_t);
uint32_t param_payload_len =
DOLBY_PARAM_PAYLOAD_SIZE * sizeof(uint32_t);
+ struct param_hdr_v3 param_hdr;
/* Return error on get param in soft or hard bypass */
if (ds2_dap_params_states.dap_bypass == true) {
@@ -1573,17 +1598,15 @@
params_value = kzalloc(params_length + param_payload_len,
GFP_KERNEL);
- if (!params_value) {
- rc = -ENOMEM;
- goto end;
- }
+ if (!params_value)
+ return -ENOMEM;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
if (dolby_data->param_id == DOLBY_PARAM_ID_VER) {
- rc = adm_get_params(port_id, copp_idx,
- DOLBY_BUNDLE_MODULE_ID,
- DOLBY_PARAM_ID_VER,
- params_length + param_payload_len,
- (char *)params_value);
+ param_hdr.module_id = DOLBY_BUNDLE_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = DOLBY_PARAM_ID_VER;
+ param_hdr.param_size = params_length + param_payload_len;
} else {
for (i = 0; i < MAX_DS2_PARAMS; i++)
if (ds2_dap_params_id[i] ==
@@ -1596,25 +1619,25 @@
goto end;
} else {
params_length =
- ds2_dap_params_length[i] * sizeof(uint32_t);
+ ds2_dap_params_length[i] * sizeof(uint32_t);
- rc = adm_get_params(port_id, copp_idx,
- DOLBY_BUNDLE_MODULE_ID,
- ds2_dap_params_id[i],
- params_length +
- param_payload_len,
- (char *)params_value);
+ param_hdr.module_id = DOLBY_BUNDLE_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = ds2_dap_params_id[i];
+ param_hdr.param_size =
+ params_length + param_payload_len;
}
}
+ rc = adm_get_pp_params(port_id, copp_idx, ADM_CLIENT_ID_DEFAULT, NULL,
+ ¶m_hdr, (u8 *) params_value);
if (rc) {
pr_err("%s: get parameters failed rc %d\n", __func__, rc);
rc = -EINVAL;
goto end;
}
- update_params_value = params_value;
- if (copy_to_user((void *)dolby_data->data,
- &update_params_value[DOLBY_PARAM_PAYLOAD_SIZE],
- (dolby_data->length * sizeof(uint32_t)))) {
+ if (copy_to_user((void __user *) dolby_data->data,
+ ¶ms_value[DOLBY_PARAM_PAYLOAD_SIZE],
+ (dolby_data->length * sizeof(uint32_t)))) {
pr_err("%s: error getting param\n", __func__);
rc = -EFAULT;
goto end;
@@ -1633,6 +1656,7 @@
uint32_t offset, length, params_length;
uint32_t param_payload_len =
DOLBY_PARAM_PAYLOAD_SIZE * sizeof(uint32_t);
+ struct param_hdr_v3 param_hdr;
for (i = 0; i < DS2_DEVICES_ALL; i++) {
if ((dev_map[i].active)) {
@@ -1651,6 +1675,7 @@
goto end;
}
+ memset(¶m_hdr, 0, sizeof(param_hdr));
length = ds2_dap_params[cache_dev].params_val[DOLBY_PARAM_VCNB_OFFSET];
if (length > DOLBY_PARAM_VCNB_MAX_LENGTH || length <= 0) {
@@ -1665,6 +1690,7 @@
visualizer_data = kzalloc(params_length, GFP_KERNEL);
if (!visualizer_data) {
+ pr_err("%s: params memory alloc failed\n", __func__);
ret = -ENOMEM;
dolby_data->length = 0;
goto end;
@@ -1682,11 +1708,13 @@
offset = 0;
params_length = length * sizeof(uint32_t);
- ret = adm_get_params(port_id, copp_idx,
- DOLBY_BUNDLE_MODULE_ID,
- DOLBY_PARAM_ID_VCBG,
- params_length + param_payload_len,
- (((char *)(visualizer_data)) + offset));
+ param_hdr.module_id = DOLBY_BUNDLE_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = DOLBY_PARAM_ID_VCBG;
+ param_hdr.param_size = length * sizeof(uint32_t) + param_payload_len;
+ ret = adm_get_pp_params(port_id, copp_idx, ADM_CLIENT_ID_DEFAULT, NULL,
+ ¶m_hdr,
+ (((char *) (visualizer_data)) + offset));
if (ret) {
pr_err("%s: get parameters failed ret %d\n", __func__, ret);
ret = -EINVAL;
@@ -1694,11 +1722,13 @@
goto end;
}
offset = length * sizeof(uint32_t);
- ret = adm_get_params(port_id, copp_idx,
- DOLBY_BUNDLE_MODULE_ID,
- DOLBY_PARAM_ID_VCBE,
- params_length + param_payload_len,
- (((char *)(visualizer_data)) + offset));
+ param_hdr.module_id = DOLBY_BUNDLE_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = DOLBY_PARAM_ID_VCBE;
+ param_hdr.param_size = length * sizeof(uint32_t) + param_payload_len;
+ ret = adm_get_pp_params(port_id, copp_idx, ADM_CLIENT_ID_DEFAULT, NULL,
+ ¶m_hdr,
+ (((char *) (visualizer_data)) + offset));
if (ret) {
pr_err("%s: get parameters failed ret %d\n", __func__, ret);
ret = -EINVAL;
diff --git a/asoc/msm-ds2-dap-config.h b/asoc/msm-ds2-dap-config.h
index c90bd8f..4d6b5eb 100644
--- a/asoc/msm-ds2-dap-config.h
+++ b/asoc/msm-ds2-dap-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014, 2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, 2017-2018 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
* only version 2 as published by the Free Software Foundation.
@@ -33,7 +33,6 @@
compat_uptr_t license_key;
};
-
#define SNDRV_DEVDEP_DAP_IOCTL_SET_PARAM32\
_IOWR('U', 0x10, struct dolby_param_data32)
#define SNDRV_DEVDEP_DAP_IOCTL_GET_PARAM32\
@@ -63,6 +62,34 @@
DAP_CMD_SET_BYPASS_TYPE = 5,
};
+struct custom_stereo_param {
+ /* Index is 32-bit param in little endian */
+ u16 index;
+ u16 reserved;
+
+ /* For stereo mixing, the number of out channels */
+ u16 num_out_ch;
+ /* For stereo mixing, the number of in channels */
+ u16 num_in_ch;
+
+ /* Out channel map FL/FR*/
+ u16 out_fl;
+ u16 out_fr;
+
+ /* In channel map FL/FR*/
+ u16 in_fl;
+ u16 in_fr;
+
+ /*
+ * Weighting coefficients. Mixing will be done according to
+ * these coefficients.
+ */
+ u16 op_FL_ip_FL_weight;
+ u16 op_FL_ip_FR_weight;
+ u16 op_FR_ip_FL_weight;
+ u16 op_FR_ip_FR_weight;
+};
+
#define DOLBY_PARAM_INT_ENDP_LENGTH 1
#define DOLBY_PARAM_INT_ENDP_OFFSET (DOLBY_PARAM_PSTG_OFFSET + \
DOLBY_PARAM_PSTG_LENGTH)
diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c
index 2b6a69f..5e82550 100644
--- a/asoc/msm-pcm-routing-v2.c
+++ b/asoc/msm-pcm-routing-v2.c
@@ -11517,10 +11517,11 @@
int ret = 0;
unsigned long copp;
struct msm_pcm_routing_bdai_data *bedai;
- char *param_data = NULL;
- uint32_t *update_param_data = NULL;
- uint32_t param_size = sizeof(uint32_t) +
- sizeof(struct adm_param_data_v5);
+ u8 *packed_params = NULL;
+ struct param_hdr_v3 param_hdr;
+ u32 packed_param_size = (sizeof(struct param_hdr_v3) +
+ sizeof(uint32_t));
+
int dir = ucontrol->value.integer.value[0] ? SESSION_TYPE_TX :
SESSION_TYPE_RX;
int app_type = ucontrol->value.integer.value[1];
@@ -11535,15 +11536,17 @@
__func__, app_type, module_id,
instance_id, param_id, param_value);
- param_data = kzalloc(param_size, GFP_KERNEL);
- if (!param_data)
+ packed_params = kzalloc(packed_param_size, GFP_KERNEL);
+ if (!packed_params)
return -ENOMEM;
- update_param_data = (uint32_t *)param_data;
- *update_param_data++ = module_id;
- *update_param_data++ = param_id;
- *update_param_data++ = sizeof(uint32_t);
- *update_param_data++ = param_value;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = module_id;
+ param_hdr.instance_id = instance_id;
+ param_hdr.param_id = param_id;
+ param_hdr.param_size = sizeof(uint32_t);
+
+ packed_param_size = 0;
mutex_lock(&routing_lock);
for (be_id = 0; be_id < MSM_BACKEND_DAI_MAX; be_id++) {
@@ -11571,10 +11574,20 @@
if (!test_bit(copp_idx, &copp))
continue;
- ret = adm_send_params_v5(bedai->port_id,
- copp_idx,
- param_data,
- param_size);
+ ret = q6common_pack_pp_params(packed_params,
+ ¶m_hdr,
+ (u8 *) ¶m_value,
+ &packed_param_size);
+ if (ret) {
+ pr_err("%s: Failed to pack params, error %d\n",
+ __func__, ret);
+ goto done;
+ }
+
+ ret = adm_set_pp_params(bedai->port_id,
+ copp_idx, NULL,
+ packed_params,
+ packed_param_size);
if (ret) {
pr_err("%s: Setting param failed with err=%d\n",
__func__, ret);
@@ -11586,7 +11599,7 @@
}
done:
mutex_unlock(&routing_lock);
- kfree(param_data);
+ kfree(packed_params);
return ret;
}
@@ -11662,22 +11675,24 @@
int be_idx = 0;
char *param_value;
int *update_param_value;
- uint32_t param_length = sizeof(uint32_t);
- uint32_t param_payload_len = RMS_PAYLOAD_LEN * sizeof(uint32_t);
+ uint32_t param_size = (RMS_PAYLOAD_LEN + 1) * sizeof(uint32_t);
+ struct param_hdr_v3 param_hdr;
- param_value = kzalloc(param_length + param_payload_len, GFP_KERNEL);
+ param_value = kzalloc(param_size, GFP_KERNEL);
if (!param_value)
return -ENOMEM;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++)
if (msm_bedais[be_idx].port_id == SLIMBUS_0_TX)
break;
if ((be_idx < MSM_BACKEND_DAI_MAX) && msm_bedais[be_idx].active) {
- rc = adm_get_params(SLIMBUS_0_TX, 0,
- RMS_MODULEID_APPI_PASSTHRU,
- RMS_PARAM_FIRST_SAMPLE,
- param_length + param_payload_len,
- param_value);
+ param_hdr.module_id = RMS_MODULEID_APPI_PASSTHRU;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = RMS_PARAM_FIRST_SAMPLE;
+ param_hdr.param_size = param_size;
+ rc = adm_get_pp_params(SLIMBUS_0_TX, 0, ADM_CLIENT_ID_DEFAULT,
+ NULL, ¶m_hdr, (u8 *) param_value);
if (rc) {
pr_err("%s: get parameters failed:%d\n", __func__, rc);
kfree(param_value);
diff --git a/asoc/msm-qti-pp-config.c b/asoc/msm-qti-pp-config.c
index 00a29d7..f210745 100644
--- a/asoc/msm-qti-pp-config.c
+++ b/asoc/msm-qti-pp-config.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2018, 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
@@ -21,6 +21,7 @@
#include <dsp/q6asm-v2.h>
#include <dsp/q6afe-v2.h>
#include <dsp/q6audio-v2.h>
+#include <dsp/q6common.h>
#include "msm-qti-pp-config.h"
#include "msm-pcm-routing-v2.h"
@@ -263,6 +264,11 @@
update_params_value32 = (int *)params_value;
if (avail_length < 2 * sizeof(uint32_t))
goto skip_send_cmd;
+
+ /*
+ * This module is internal to ADSP and cannot be configured with
+ * an instance id
+ */
*update_params_value32++ = MTMX_MODULE_ID_DEFAULT_CHMIXER;
*update_params_value32++ = DEFAULT_CHMIXER_PARAM_ID_COEFF;
avail_length = avail_length - (2 * sizeof(uint32_t));
@@ -329,14 +335,13 @@
int be_idx = 0, copp_idx;
char *param_value;
int *update_param_value;
- uint32_t param_length = sizeof(uint32_t);
- uint32_t param_payload_len = RMS_PAYLOAD_LEN * sizeof(uint32_t);
+ uint32_t param_size = (RMS_PAYLOAD_LEN + 1) * sizeof(uint32_t);
struct msm_pcm_routing_bdai_data msm_bedai;
+ struct param_hdr_v3 param_hdr;
- param_value = kzalloc(param_length + param_payload_len, GFP_KERNEL);
+ param_value = kzalloc(param_size, GFP_KERNEL);
if (!param_value)
return -ENOMEM;
-
msm_pcm_routing_acquire_lock();
for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
@@ -356,11 +361,13 @@
rc = -EINVAL;
goto get_rms_value_err;
}
- rc = adm_get_params(SLIMBUS_0_TX, copp_idx,
- RMS_MODULEID_APPI_PASSTHRU,
- RMS_PARAM_FIRST_SAMPLE,
- param_length + param_payload_len,
- param_value);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = RMS_MODULEID_APPI_PASSTHRU;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = RMS_PARAM_FIRST_SAMPLE;
+ param_hdr.param_size = param_size;
+ rc = adm_get_pp_params(SLIMBUS_0_TX, copp_idx, ADM_CLIENT_ID_DEFAULT,
+ NULL, ¶m_hdr, param_value);
if (rc) {
pr_err("%s: get parameters failed rc=%d\n", __func__, rc);
rc = -EINVAL;
@@ -692,64 +699,83 @@
static int msm_qti_pp_asphere_send_params(int port_id, int copp_idx, bool force)
{
- char *params_value = NULL;
- uint32_t *update_params_value = NULL;
- uint32_t param_size = sizeof(uint32_t) +
- sizeof(struct adm_param_data_v5);
- int params_length = 0, param_count = 0, ret = 0;
+ u8 *packed_params = NULL;
+ u32 packed_params_size = 0;
+ u32 param_size = 0;
+ struct param_hdr_v3 param_hdr;
bool set_enable = force ||
(asphere_state.enabled != asphere_state.enabled_prev);
bool set_strength = asphere_state.enabled == 1 && (set_enable ||
(asphere_state.strength != asphere_state.strength_prev));
+ int param_count = 0;
+ int ret = 0;
if (set_enable)
param_count++;
if (set_strength)
param_count++;
- params_length = param_count * param_size;
+
+ if (param_count == 0) {
+ pr_debug("%s: Nothing to send, exiting\n", __func__);
+ return 0;
+ }
pr_debug("%s: port_id %d, copp_id %d, forced %d, param_count %d\n",
- __func__, port_id, copp_idx, force, param_count);
+ __func__, port_id, copp_idx, force, param_count);
pr_debug("%s: enable prev:%u cur:%u, strength prev:%u cur:%u\n",
__func__, asphere_state.enabled_prev, asphere_state.enabled,
asphere_state.strength_prev, asphere_state.strength);
- if (params_length > 0)
- params_value = kzalloc(params_length, GFP_KERNEL);
- if (!params_value) {
- pr_err("%s, params memory alloc failed\n", __func__);
+ packed_params_size =
+ param_count * (sizeof(struct param_hdr_v3) + sizeof(uint32_t));
+ packed_params = kzalloc(packed_params_size, GFP_KERNEL);
+ if (!packed_params)
return -ENOMEM;
- }
- update_params_value = (uint32_t *)params_value;
- params_length = 0;
+
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ packed_params_size = 0;
+ param_hdr.module_id = AUDPROC_MODULE_ID_AUDIOSPHERE;
+ param_hdr.instance_id = INSTANCE_ID_0;
if (set_strength) {
/* add strength command */
- *update_params_value++ = AUDPROC_MODULE_ID_AUDIOSPHERE;
- *update_params_value++ = AUDPROC_PARAM_ID_AUDIOSPHERE_STRENGTH;
- *update_params_value++ = sizeof(uint32_t);
- *update_params_value++ = asphere_state.strength;
- params_length += param_size;
+ param_hdr.param_id = AUDPROC_PARAM_ID_AUDIOSPHERE_STRENGTH;
+ param_hdr.param_size = sizeof(asphere_state.strength);
+ ret = q6common_pack_pp_params(packed_params +
+ packed_params_size,
+ ¶m_hdr,
+ (u8 *) &asphere_state.strength,
+ ¶m_size);
+ if (ret) {
+ pr_err("%s: Failed to pack params for audio sphere"
+ " strength, error %d\n", __func__, ret);
+ goto done;
+ }
+ packed_params_size += param_size;
}
if (set_enable) {
/* add enable command */
- *update_params_value++ = AUDPROC_MODULE_ID_AUDIOSPHERE;
- *update_params_value++ = AUDPROC_PARAM_ID_AUDIOSPHERE_ENABLE;
- *update_params_value++ = sizeof(uint32_t);
- *update_params_value++ = asphere_state.enabled;
- params_length += param_size;
- }
- pr_debug("%s, param length: %d\n", __func__, params_length);
- if (params_length) {
- ret = adm_send_params_v5(port_id, copp_idx,
- params_value, params_length);
+ param_hdr.param_id = AUDPROC_PARAM_ID_AUDIOSPHERE_ENABLE;
+ param_hdr.param_size = sizeof(asphere_state.enabled);
+ q6common_pack_pp_params(packed_params + packed_params_size,
+ ¶m_hdr,
+ (u8 *) &asphere_state.enabled,
+ ¶m_size);
if (ret) {
- pr_err("%s: setting param failed with err=%d\n",
- __func__, ret);
- kfree(params_value);
- return -EINVAL;
+ pr_err("%s: Failed to pack params for audio sphere"
+ " enable, error %d\n", __func__, ret);
+ goto done;
}
+ packed_params_size += param_size;
}
- kfree(params_value);
+
+ pr_debug("%s: packed data size: %d\n", __func__, packed_params_size);
+ ret = adm_set_pp_params(port_id, copp_idx, NULL, packed_params,
+ packed_params_size);
+ if (ret)
+ pr_err("%s: set param failed with err=%d\n", __func__, ret);
+
+done:
+ kfree(packed_params);
return 0;
}
diff --git a/asoc/sdm855.c b/asoc/sdm855.c
index 5944a89..2690ed5 100644
--- a/asoc/sdm855.c
+++ b/asoc/sdm855.c
@@ -33,6 +33,8 @@
#include "device_event.h"
#include "msm-pcm-routing-v2.h"
#include "codecs/msm-cdc-pinctrl.h"
+#include "codecs/wcd934x/wcd934x.h"
+#include "codecs/wcd934x/wcd934x-mbhc.h"
#include "codecs/wcd9360/wcd9360.h"
#include "codecs/wsa881x.h"
#include "codecs/wcd-mbhc-v2.h"
@@ -68,6 +70,7 @@
#define ADSP_STATE_READY_TIMEOUT_MS 3000
#define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
+#define MSM_HIFI_ON 1
enum {
SLIM_RX_0 = 0,
@@ -160,6 +163,8 @@
struct snd_info_entry *codec_root;
struct msm_pinctrl_info pinctrl_info;
struct device_node *us_euro_gpio_p; /* used by pinctrl API */
+ struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
+ struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
};
struct msm_asoc_wcd93xx_codec {
@@ -499,15 +504,18 @@
static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
+static SOC_ENUM_SINGLE_EXT_DECL(hifi_function, hifi_text);
static struct platform_device *spdev;
+static int msm_hifi_control;
static bool is_initial_boot;
static bool codec_reg_done;
static struct snd_soc_aux_dev *msm_aux_dev;
static struct snd_soc_codec_conf *msm_codec_conf;
static struct msm_asoc_wcd93xx_codec msm_codec_fn;
+static void *def_wcd_mbhc_cal(void);
static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
int enable, bool dapm);
static int msm_wsa881x_init(struct snd_soc_component *component);
@@ -544,6 +552,13 @@
{"MIC BIAS4", NULL, "MCLK TX"},
};
+static struct snd_soc_dapm_route wcd_audio_paths_tavil[] = {
+ {"MIC BIAS1", NULL, "MCLK TX"},
+ {"MIC BIAS2", NULL, "MCLK TX"},
+ {"MIC BIAS3", NULL, "MCLK TX"},
+ {"MIC BIAS4", NULL, "MCLK TX"},
+};
+
static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
{
AFE_API_VERSION_I2S_CONFIG,
@@ -2619,6 +2634,57 @@
return 0;
}
+
+static int msm_hifi_ctrl(struct snd_soc_codec *codec)
+{
+ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
+ struct snd_soc_card *card = codec->component.card;
+ struct msm_asoc_mach_data *pdata =
+ snd_soc_card_get_drvdata(card);
+
+ dev_dbg(codec->dev, "%s: msm_hifi_control = %d\n", __func__,
+ msm_hifi_control);
+
+ if (!pdata || !pdata->hph_en1_gpio_p) {
+ dev_err(codec->dev, "%s: hph_en1_gpio is invalid\n", __func__);
+ return -EINVAL;
+ }
+ if (msm_hifi_control == MSM_HIFI_ON) {
+ msm_cdc_pinctrl_select_active_state(pdata->hph_en1_gpio_p);
+ /* 5msec delay needed as per HW requirement */
+ usleep_range(5000, 5010);
+ } else {
+ msm_cdc_pinctrl_select_sleep_state(pdata->hph_en1_gpio_p);
+ }
+ snd_soc_dapm_sync(dapm);
+
+ return 0;
+}
+
+static int msm_hifi_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ pr_debug("%s: msm_hifi_control = %d\n",
+ __func__, msm_hifi_control);
+ ucontrol->value.integer.value[0] = msm_hifi_control;
+
+ return 0;
+}
+
+static int msm_hifi_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+
+ dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
+ __func__, ucontrol->value.integer.value[0]);
+
+ msm_hifi_control = ucontrol->value.integer.value[0];
+ msm_hifi_ctrl(codec);
+
+ return 0;
+}
+
static const struct snd_kcontrol_new msm_snd_controls[] = {
SOC_ENUM_EXT("SLIM_0_RX Channels", slim_0_rx_chs,
slim_rx_ch_get, slim_rx_ch_put),
@@ -2888,6 +2954,8 @@
msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
+ SOC_ENUM_EXT("HiFi Function", hifi_function, msm_hifi_get,
+ msm_hifi_put),
};
@@ -2898,6 +2966,8 @@
if (!strcmp(dev_name(codec->dev), "pahu_codec")) {
ret = pahu_cdc_mclk_enable(codec, enable);
+ } else if (!strcmp(dev_name(codec->dev), "tavil_codec")) {
+ ret = tavil_cdc_mclk_enable(codec, enable);
} else {
dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
__func__);
@@ -2913,6 +2983,8 @@
if (!strcmp(dev_name(codec->dev), "pahu_codec")) {
ret = pahu_cdc_mclk_tx_enable(codec, enable);
+ } else if (!strcmp(dev_name(codec->dev), "tavil_codec")) {
+ ret = tavil_cdc_mclk_tx_enable(codec, enable);
} else {
dev_err(codec->dev, "%s: unknown codec to enable TX ext clk\n",
__func__);
@@ -2954,6 +3026,40 @@
return 0;
}
+static int msm_hifi_ctrl_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *k, int event)
+{
+ struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+ struct snd_soc_card *card = codec->component.card;
+ struct msm_asoc_mach_data *pdata =
+ snd_soc_card_get_drvdata(card);
+
+ dev_dbg(codec->dev, "%s: msm_hifi_control = %d\n",
+ __func__, msm_hifi_control);
+
+ if (!pdata || !pdata->hph_en0_gpio_p) {
+ dev_err(codec->dev, "%s: hph_en0_gpio is invalid\n", __func__);
+ return -EINVAL;
+ }
+
+ if (msm_hifi_control != MSM_HIFI_ON) {
+ dev_dbg(codec->dev, "%s: HiFi mixer control is not set\n",
+ __func__);
+ return 0;
+ }
+
+ switch (event) {
+ case SND_SOC_DAPM_POST_PMU:
+ msm_cdc_pinctrl_select_active_state(pdata->hph_en0_gpio_p);
+ break;
+ case SND_SOC_DAPM_PRE_PMD:
+ msm_cdc_pinctrl_select_sleep_state(pdata->hph_en0_gpio_p);
+ break;
+ }
+
+ return 0;
+}
+
static const struct snd_soc_dapm_widget msm_dapm_widgets[] = {
SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
@@ -2976,6 +3082,33 @@
SND_SOC_DAPM_MIC("Digital Mic7", NULL),
};
+static const struct snd_soc_dapm_widget msm_dapm_widgets_tavil[] = {
+
+ SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
+ msm_mclk_event,
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
+
+ SND_SOC_DAPM_SUPPLY("MCLK TX", SND_SOC_NOPM, 0, 0,
+ msm_mclk_tx_event,
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
+
+ SND_SOC_DAPM_SPK("Lineout_1 amp", NULL),
+ SND_SOC_DAPM_SPK("Lineout_2 amp", NULL),
+ SND_SOC_DAPM_SPK("hifi amp", msm_hifi_ctrl_event),
+ SND_SOC_DAPM_MIC("Handset Mic", NULL),
+ SND_SOC_DAPM_MIC("Headset Mic", NULL),
+ SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
+ SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
+ SND_SOC_DAPM_MIC("Analog Mic5", NULL),
+
+ SND_SOC_DAPM_MIC("Digital Mic0", NULL),
+ SND_SOC_DAPM_MIC("Digital Mic1", NULL),
+ SND_SOC_DAPM_MIC("Digital Mic2", NULL),
+ SND_SOC_DAPM_MIC("Digital Mic3", NULL),
+ SND_SOC_DAPM_MIC("Digital Mic4", NULL),
+ SND_SOC_DAPM_MIC("Digital Mic5", NULL),
+};
+
static inline int param_is_mask(int p)
{
return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
@@ -3697,11 +3830,17 @@
return ret;
}
- snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
+ if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
+ snd_soc_dapm_new_controls(dapm, msm_dapm_widgets_tavil,
+ ARRAY_SIZE(msm_dapm_widgets_tavil));
+ snd_soc_dapm_add_routes(dapm, wcd_audio_paths_tavil,
+ ARRAY_SIZE(wcd_audio_paths_tavil));
+ } else {
+ snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
ARRAY_SIZE(msm_dapm_widgets));
-
- snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
- ARRAY_SIZE(wcd_audio_paths));
+ snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
+ ARRAY_SIZE(wcd_audio_paths));
+ }
snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
@@ -3711,8 +3850,6 @@
snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
snd_soc_dapm_ignore_suspend(dapm, "MADINPUT");
snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_INPUT");
snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT1");
@@ -3724,12 +3861,31 @@
snd_soc_dapm_ignore_suspend(dapm, "AIF4 VI");
snd_soc_dapm_ignore_suspend(dapm, "VIINPUT");
+ if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
+ snd_soc_dapm_ignore_suspend(dapm, "ANCRight Headset Mic");
+ snd_soc_dapm_ignore_suspend(dapm, "ANCLeft Headset Mic");
+ snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
+ snd_soc_dapm_ignore_suspend(dapm, "Analog Mic6");
+ snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
+ snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
+ snd_soc_dapm_ignore_suspend(dapm, "HPHL");
+ snd_soc_dapm_ignore_suspend(dapm, "HPHR");
+ snd_soc_dapm_ignore_suspend(dapm, "ANC HPHL");
+ snd_soc_dapm_ignore_suspend(dapm, "ANC HPHR");
+ } else {
+ snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
+ snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
+ }
+
snd_soc_dapm_sync(dapm);
snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
- msm_codec_fn.get_afe_config_fn = pahu_get_afe_config;
+ if (!strcmp(dev_name(codec_dai->dev), "tavil_codec"))
+ msm_codec_fn.get_afe_config_fn = tavil_get_afe_config;
+ else
+ msm_codec_fn.get_afe_config_fn = pahu_get_afe_config;
ret = msm_adsp_power_up_config(codec, rtd->card->snd_card);
if (ret) {
@@ -3754,29 +3910,56 @@
*/
pr_debug("%s: Number of aux devices: %d\n",
__func__, rtd->card->num_aux_devs);
- if (rtd->card->num_aux_devs &&
- !list_empty(&rtd->card->component_dev_list)) {
- aux_comp = list_first_entry(&rtd->card->component_dev_list,
- struct snd_soc_component, card_aux_list);
- if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
- !strcmp(aux_comp->name, WSA8810_NAME_2)) {
- pahu_set_spkr_mode(rtd->codec, WCD9360_SPKR_MODE_1);
- pahu_set_spkr_gain_offset(rtd->codec,
- WCD9360_RX_GAIN_OFFSET_M1P5_DB);
+ if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
+ if (rtd->card->num_aux_devs &&
+ !list_empty(&rtd->card->component_dev_list)) {
+ aux_comp = list_first_entry(
+ &rtd->card->component_dev_list,
+ struct snd_soc_component,
+ card_aux_list);
+ if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
+ !strcmp(aux_comp->name, WSA8810_NAME_2)) {
+ tavil_set_spkr_mode(rtd->codec,
+ WCD934X_SPKR_MODE_1);
+ tavil_set_spkr_gain_offset(rtd->codec,
+ WCD934X_RX_GAIN_OFFSET_M1P5_DB);
+ }
}
+ card = rtd->card->snd_card;
+ entry = snd_info_create_subdir(card->module, "codecs",
+ card->proc_root);
+ if (!entry) {
+ pr_debug("%s: Cannot create codecs module entry\n",
+ __func__);
+ pdata->codec_root = NULL;
+ goto done;
+ }
+ pdata->codec_root = entry;
+ tavil_codec_info_create_codec_entry(pdata->codec_root, codec);
+ } else {
+ if (rtd->card->num_aux_devs &&
+ !list_empty(&rtd->card->component_dev_list)) {
+ aux_comp = list_first_entry(&rtd->card->component_dev_list,
+ struct snd_soc_component, card_aux_list);
+ if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
+ !strcmp(aux_comp->name, WSA8810_NAME_2)) {
+ pahu_set_spkr_mode(rtd->codec, WCD9360_SPKR_MODE_1);
+ pahu_set_spkr_gain_offset(rtd->codec,
+ WCD9360_RX_GAIN_OFFSET_M1P5_DB);
+ }
+ }
+ card = rtd->card->snd_card;
+ entry = snd_info_create_subdir(card->module, "codecs",
+ card->proc_root);
+ if (!entry) {
+ pr_debug("%s: Cannot create codecs module entry\n",
+ __func__);
+ pdata->codec_root = NULL;
+ goto done;
+ }
+ pdata->codec_root = entry;
+ pahu_codec_info_create_codec_entry(pdata->codec_root, codec);
}
- card = rtd->card->snd_card;
- entry = snd_info_create_subdir(card->module, "codecs",
- card->proc_root);
- if (!entry) {
- pr_debug("%s: Cannot create codecs module entry\n",
- __func__);
- pdata->codec_root = NULL;
- goto done;
- }
- pdata->codec_root = entry;
- pahu_codec_info_create_codec_entry(pdata->codec_root, codec);
-
done:
codec_reg_done = true;
return 0;
@@ -3795,6 +3978,40 @@
tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
}
+static void *def_wcd_mbhc_cal(void)
+{
+ void *wcd_mbhc_cal;
+ struct wcd_mbhc_btn_detect_cfg *btn_cfg;
+ u16 *btn_high;
+
+ wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
+ WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
+ if (!wcd_mbhc_cal)
+ return NULL;
+
+#define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->X) = (Y))
+ S(v_hs_max, 1600);
+#undef S
+#define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->X) = (Y))
+ S(num_btn, WCD_MBHC_DEF_BUTTONS);
+#undef S
+
+ btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
+ btn_high = ((void *)&btn_cfg->_v_btn_low) +
+ (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
+
+ btn_high[0] = 75;
+ btn_high[1] = 150;
+ btn_high[2] = 237;
+ btn_high[3] = 500;
+ btn_high[4] = 500;
+ btn_high[5] = 500;
+ btn_high[6] = 500;
+ btn_high[7] = 500;
+
+ return wcd_mbhc_cal;
+}
+
static int msm_snd_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
@@ -5199,6 +5416,47 @@
},
};
+static struct snd_soc_dai_link msm_tavil_fe_dai_links[] = {
+ {
+ .name = LPASS_BE_SLIMBUS_4_TX,
+ .stream_name = "Slimbus4 Capture",
+ .cpu_dai_name = "msm-dai-q6-dev.16393",
+ .platform_name = "msm-pcm-hostless",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_vifeedback",
+ .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
+ .ignore_suspend = 1,
+ },
+ /* Ultrasound RX DAI Link */
+ {
+ .name = "SLIMBUS_2 Hostless Playback",
+ .stream_name = "SLIMBUS_2 Hostless Playback",
+ .cpu_dai_name = "msm-dai-q6-dev.16388",
+ .platform_name = "msm-pcm-hostless",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_rx2",
+ .ignore_suspend = 1,
+ .ignore_pmdown_time = 1,
+ .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
+ .ops = &msm_slimbus_2_be_ops,
+ },
+ /* Ultrasound TX DAI Link */
+ {
+ .name = "SLIMBUS_2 Hostless Capture",
+ .stream_name = "SLIMBUS_2 Hostless Capture",
+ .cpu_dai_name = "msm-dai-q6-dev.16389",
+ .platform_name = "msm-pcm-hostless",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_tx2",
+ .ignore_suspend = 1,
+ .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
+ .ops = &msm_slimbus_2_be_ops,
+ },
+};
+
static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
{
.name = MSM_DAILINK_NAME(ASM Loopback),
@@ -5655,6 +5913,193 @@
},
};
+static struct snd_soc_dai_link msm_tavil_be_dai_links[] = {
+ {
+ .name = LPASS_BE_SLIMBUS_0_RX,
+ .stream_name = "Slimbus Playback",
+ .cpu_dai_name = "msm-dai-q6-dev.16384",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_rx1",
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
+ .init = &msm_audrx_init,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ /* this dainlink has playback support */
+ .ignore_pmdown_time = 1,
+ .ignore_suspend = 1,
+ .ops = &msm_be_ops,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_0_TX,
+ .stream_name = "Slimbus Capture",
+ .cpu_dai_name = "msm-dai-q6-dev.16385",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_tx1",
+ .no_pcm = 1,
+ .dpcm_capture = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ignore_suspend = 1,
+ .ops = &msm_be_ops,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_1_RX,
+ .stream_name = "Slimbus1 Playback",
+ .cpu_dai_name = "msm-dai-q6-dev.16386",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_rx1",
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ /* dai link has playback support */
+ .ignore_pmdown_time = 1,
+ .ignore_suspend = 1,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_1_TX,
+ .stream_name = "Slimbus1 Capture",
+ .cpu_dai_name = "msm-dai-q6-dev.16387",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_tx3",
+ .no_pcm = 1,
+ .dpcm_capture = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ .ignore_suspend = 1,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_2_RX,
+ .stream_name = "Slimbus2 Playback",
+ .cpu_dai_name = "msm-dai-q6-dev.16388",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_rx2",
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ .ignore_pmdown_time = 1,
+ .ignore_suspend = 1,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_3_RX,
+ .stream_name = "Slimbus3 Playback",
+ .cpu_dai_name = "msm-dai-q6-dev.16390",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_rx1",
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ /* dai link has playback support */
+ .ignore_pmdown_time = 1,
+ .ignore_suspend = 1,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_3_TX,
+ .stream_name = "Slimbus3 Capture",
+ .cpu_dai_name = "msm-dai-q6-dev.16391",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_tx1",
+ .no_pcm = 1,
+ .dpcm_capture = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ .ignore_suspend = 1,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_4_RX,
+ .stream_name = "Slimbus4 Playback",
+ .cpu_dai_name = "msm-dai-q6-dev.16392",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_rx1",
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ /* dai link has playback support */
+ .ignore_pmdown_time = 1,
+ .ignore_suspend = 1,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_5_RX,
+ .stream_name = "Slimbus5 Playback",
+ .cpu_dai_name = "msm-dai-q6-dev.16394",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_rx3",
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ /* dai link has playback support */
+ .ignore_pmdown_time = 1,
+ .ignore_suspend = 1,
+ },
+ /* MAD BE */
+ {
+ .name = LPASS_BE_SLIMBUS_5_TX,
+ .stream_name = "Slimbus5 Capture",
+ .cpu_dai_name = "msm-dai-q6-dev.16395",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_mad1",
+ .no_pcm = 1,
+ .dpcm_capture = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ .ignore_suspend = 1,
+ },
+ {
+ .name = LPASS_BE_SLIMBUS_6_RX,
+ .stream_name = "Slimbus6 Playback",
+ .cpu_dai_name = "msm-dai-q6-dev.16396",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_rx4",
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ /* dai link has playback support */
+ .ignore_pmdown_time = 1,
+ .ignore_suspend = 1,
+ },
+ /* Slimbus VI Recording */
+ {
+ .name = LPASS_BE_SLIMBUS_TX_VI,
+ .stream_name = "Slimbus4 Capture",
+ .cpu_dai_name = "msm-dai-q6-dev.16393",
+ .platform_name = "msm-pcm-routing",
+ .codec_name = "tavil_codec",
+ .codec_dai_name = "tavil_vifeedback",
+ .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
+ .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .ops = &msm_be_ops,
+ .ignore_suspend = 1,
+ .no_pcm = 1,
+ .dpcm_capture = 1,
+ },
+};
+
static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
{
.name = LPASS_BE_SLIMBUS_7_RX,
@@ -6027,10 +6472,63 @@
ARRAY_SIZE(msm_mi2s_be_dai_links) +
ARRAY_SIZE(msm_auxpcm_be_dai_links)];
+static struct snd_soc_dai_link msm_tavil_dai_links[
+ ARRAY_SIZE(msm_common_dai_links) +
+ ARRAY_SIZE(msm_tavil_fe_dai_links) +
+ ARRAY_SIZE(msm_common_misc_fe_dai_links) +
+ ARRAY_SIZE(msm_common_be_dai_links) +
+ ARRAY_SIZE(msm_tavil_be_dai_links) +
+ ARRAY_SIZE(msm_wcn_be_dai_links) +
+ ARRAY_SIZE(ext_disp_be_dai_link) +
+ ARRAY_SIZE(msm_mi2s_be_dai_links) +
+ ARRAY_SIZE(msm_auxpcm_be_dai_links)];
+
+static int msm_snd_card_tavil_late_probe(struct snd_soc_card *card)
+{
+ const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
+ struct snd_soc_pcm_runtime *rtd;
+ int ret = 0;
+ void *mbhc_calibration;
+
+ rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
+ if (!rtd) {
+ dev_err(card->dev,
+ "%s: snd_soc_get_pcm_runtime for %s failed!\n",
+ __func__, be_dl_name);
+ ret = -EINVAL;
+ goto err_pcm_runtime;
+ }
+
+ mbhc_calibration = def_wcd_mbhc_cal();
+ if (!mbhc_calibration) {
+ ret = -ENOMEM;
+ goto err_mbhc_cal;
+ }
+ wcd_mbhc_cfg.calibration = mbhc_calibration;
+ ret = tavil_mbhc_hs_detect(rtd->codec, &wcd_mbhc_cfg);
+ if (ret) {
+ dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
+ __func__, ret);
+ goto err_hs_detect;
+ }
+ return 0;
+
+err_hs_detect:
+ kfree(mbhc_calibration);
+err_mbhc_cal:
+err_pcm_runtime:
+ return ret;
+}
+
struct snd_soc_card snd_soc_card_pahu_msm = {
.name = "sdm855-pahu-snd-card",
};
+struct snd_soc_card snd_soc_card_tavil_msm = {
+ .name = "sdm855-tavil-snd-card",
+ .late_probe = msm_snd_card_tavil_late_probe,
+};
+
static int msm_populate_dai_link_component_of_node(
struct snd_soc_card *card)
{
@@ -6239,6 +6737,8 @@
static const struct of_device_id sdm855_asoc_machine_of_match[] = {
{ .compatible = "qcom,sdm855-asoc-snd-pahu",
.data = "pahu_codec"},
+ { .compatible = "qcom,sdm855-asoc-snd-tavil",
+ .data = "tavil_codec"},
{ .compatible = "qcom,sdm855-asoc-snd-stub",
.data = "stub_codec"},
{},
@@ -6316,6 +6816,62 @@
}
dailink = msm_pahu_snd_card_dai_links;
+ } else if (!strcmp(match->data, "tavil_codec")) {
+ card = &snd_soc_card_tavil_msm;
+ len_1 = ARRAY_SIZE(msm_common_dai_links);
+ len_2 = len_1 + ARRAY_SIZE(msm_tavil_fe_dai_links);
+ len_3 = len_2 + ARRAY_SIZE(msm_common_misc_fe_dai_links);
+ len_4 = len_3 + ARRAY_SIZE(msm_common_be_dai_links);
+ total_links = len_4 + ARRAY_SIZE(msm_tavil_be_dai_links);
+ memcpy(msm_tavil_dai_links,
+ msm_common_dai_links,
+ sizeof(msm_common_dai_links));
+ memcpy(msm_tavil_dai_links + len_1,
+ msm_tavil_fe_dai_links,
+ sizeof(msm_tavil_fe_dai_links));
+ memcpy(msm_tavil_dai_links + len_2,
+ msm_common_misc_fe_dai_links,
+ sizeof(msm_common_misc_fe_dai_links));
+ memcpy(msm_tavil_dai_links + len_3,
+ msm_common_be_dai_links,
+ sizeof(msm_common_be_dai_links));
+ memcpy(msm_tavil_dai_links + len_4,
+ msm_tavil_be_dai_links,
+ sizeof(msm_tavil_be_dai_links));
+
+ if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
+ dev_dbg(dev, "%s(): WCN BTFM support present\n",
+ __func__);
+ memcpy(msm_tavil_dai_links + total_links,
+ msm_wcn_be_dai_links,
+ sizeof(msm_wcn_be_dai_links));
+ total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
+ }
+
+ if (of_property_read_bool(dev->of_node,
+ "qcom,ext-disp-audio-rx")) {
+ dev_dbg(dev, "%s(): ext disp audio support present\n",
+ __func__);
+ memcpy(msm_tavil_dai_links + total_links,
+ ext_disp_be_dai_link,
+ sizeof(ext_disp_be_dai_link));
+ total_links += ARRAY_SIZE(ext_disp_be_dai_link);
+ }
+ if (of_property_read_bool(dev->of_node,
+ "qcom,mi2s-audio-intf")) {
+ memcpy(msm_tavil_dai_links + total_links,
+ msm_mi2s_be_dai_links,
+ sizeof(msm_mi2s_be_dai_links));
+ total_links += ARRAY_SIZE(msm_mi2s_be_dai_links);
+ }
+ if (of_property_read_bool(dev->of_node,
+ "qcom,auxpcm-audio-intf")) {
+ memcpy(msm_tavil_dai_links + total_links,
+ msm_auxpcm_be_dai_links,
+ sizeof(msm_auxpcm_be_dai_links));
+ total_links += ARRAY_SIZE(msm_auxpcm_be_dai_links);
+ }
+ dailink = msm_tavil_dai_links;
} else if (!strcmp(match->data, "stub_codec")) {
card = &snd_soc_card_stub_msm;
len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
@@ -6678,6 +7234,28 @@
dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
spdev = pdev;
+ ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+ if (ret) {
+ dev_dbg(&pdev->dev, "%s: failed to add child nodes, ret=%d\n",
+ __func__, ret);
+ } else {
+ pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
+ "qcom,hph-en1-gpio", 0);
+ if (!pdata->hph_en1_gpio_p) {
+ dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
+ "qcom,hph-en1-gpio",
+ pdev->dev.of_node->full_name);
+ }
+
+ pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
+ "qcom,hph-en0-gpio", 0);
+ if (!pdata->hph_en0_gpio_p) {
+ dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
+ "qcom,hph-en0-gpio",
+ pdev->dev.of_node->full_name);
+ }
+ }
+
ret = of_property_read_string(pdev->dev.of_node,
"qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
if (ret) {
diff --git a/dsp/q6adm.c b/dsp/q6adm.c
index f8aef94..f0b7121 100644
--- a/dsp/q6adm.c
+++ b/dsp/q6adm.c
@@ -24,6 +24,7 @@
#include <dsp/q6audio-v2.h>
#include <dsp/q6afe-v2.h>
#include <dsp/audio_cal_utils.h>
+#include <dsp/q6common.h>
#include <ipc/apr.h>
#include "adsp_err.h"
@@ -32,8 +33,8 @@
#define RESET_COPP_ID 99
#define INVALID_COPP_ID 0xFF
/* Used for inband payload copy, max size is 4k */
-/* 2 is to account for module & param ID in payload */
-#define ADM_GET_PARAMETER_LENGTH (4096 - APR_HDR_SIZE - 2 * sizeof(uint32_t))
+/* 3 is to account for module, instance & param ID in payload */
+#define ADM_GET_PARAMETER_LENGTH (4096 - APR_HDR_SIZE - 3 * sizeof(uint32_t))
#define ULL_SUPPORTED_BITS_PER_SAMPLE 16
#define ULL_SUPPORTED_SAMPLE_RATE 48000
@@ -124,8 +125,8 @@
};
static int adm_get_parameters[MAX_COPPS_PER_PORT * ADM_GET_PARAMETER_LENGTH];
-static int adm_module_topo_list[
- MAX_COPPS_PER_PORT * ADM_GET_TOPO_MODULE_LIST_LENGTH];
+static int adm_module_topo_list[MAX_COPPS_PER_PORT *
+ ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH];
static struct mutex dts_srs_lock;
void msm_dts_srs_acquire_lock(void)
@@ -316,266 +317,109 @@
int srs_trumedia_open(int port_id, int copp_idx, __s32 srs_tech_id,
void *srs_params)
{
- struct adm_cmd_set_pp_params_inband_v5 *adm_params = NULL;
- struct adm_cmd_set_pp_params_v5 *adm_params_ = NULL;
- __s32 sz = 0, param_id, module_id = SRS_TRUMEDIA_MODULE_ID, outband = 0;
- int ret = 0, port_idx;
+ struct param_hdr_v3 param_hdr;
+ struct mem_mapping_hdr mem_hdr;
+ u32 total_param_size = 0;
+ bool outband = false;
+ int port_idx;
+ int ret = 0;
pr_debug("SRS - %s", __func__);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ memset(&mem_hdr, 0, sizeof(mem_hdr));
port_id = afe_convert_virtual_to_portid(port_id);
port_idx = adm_validate_and_get_port_index(port_id);
if (port_idx < 0) {
pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
return -EINVAL;
}
+
+ param_hdr.module_id = SRS_TRUMEDIA_MODULE_ID;
+ param_hdr.instance_id = INSTANCE_ID_0;
+
switch (srs_tech_id) {
case SRS_ID_GLOBAL: {
- struct srs_trumedia_params_GLOBAL *glb_params = NULL;
-
- sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
+ param_hdr.param_id = SRS_TRUMEDIA_PARAMS;
+ param_hdr.param_size =
sizeof(struct srs_trumedia_params_GLOBAL);
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed\n",
- __func__);
- return -ENOMEM;
- }
- adm_params->payload_size =
- sizeof(struct srs_trumedia_params_GLOBAL) +
- sizeof(struct adm_param_data_v5);
- param_id = SRS_TRUMEDIA_PARAMS;
- adm_params->params.param_size =
- sizeof(struct srs_trumedia_params_GLOBAL);
- glb_params = (struct srs_trumedia_params_GLOBAL *)
- ((u8 *)adm_params +
- sizeof(struct adm_cmd_set_pp_params_inband_v5));
- memcpy(glb_params, srs_params,
- sizeof(struct srs_trumedia_params_GLOBAL));
break;
}
case SRS_ID_WOWHD: {
- struct srs_trumedia_params_WOWHD *whd_params = NULL;
-
- sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
- sizeof(struct srs_trumedia_params_WOWHD);
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed\n",
- __func__);
- return -ENOMEM;
- }
- adm_params->payload_size =
- sizeof(struct srs_trumedia_params_WOWHD) +
- sizeof(struct adm_param_data_v5);
- param_id = SRS_TRUMEDIA_PARAMS_WOWHD;
- adm_params->params.param_size =
- sizeof(struct srs_trumedia_params_WOWHD);
- whd_params = (struct srs_trumedia_params_WOWHD *)
- ((u8 *)adm_params +
- sizeof(struct adm_cmd_set_pp_params_inband_v5));
- memcpy(whd_params, srs_params,
- sizeof(struct srs_trumedia_params_WOWHD));
+ param_hdr.param_id = SRS_TRUMEDIA_PARAMS_WOWHD;
+ param_hdr.param_size = sizeof(struct srs_trumedia_params_WOWHD);
break;
}
case SRS_ID_CSHP: {
- struct srs_trumedia_params_CSHP *chp_params = NULL;
-
- sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
- sizeof(struct srs_trumedia_params_CSHP);
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed\n",
- __func__);
- return -ENOMEM;
- }
- adm_params->payload_size =
- sizeof(struct srs_trumedia_params_CSHP) +
- sizeof(struct adm_param_data_v5);
- param_id = SRS_TRUMEDIA_PARAMS_CSHP;
- adm_params->params.param_size =
- sizeof(struct srs_trumedia_params_CSHP);
- chp_params = (struct srs_trumedia_params_CSHP *)
- ((u8 *)adm_params +
- sizeof(struct adm_cmd_set_pp_params_inband_v5));
- memcpy(chp_params, srs_params,
- sizeof(struct srs_trumedia_params_CSHP));
+ param_hdr.param_id = SRS_TRUMEDIA_PARAMS_CSHP;
+ param_hdr.param_size = sizeof(struct srs_trumedia_params_CSHP);
break;
}
case SRS_ID_HPF: {
- struct srs_trumedia_params_HPF *hpf_params = NULL;
-
- sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
- sizeof(struct srs_trumedia_params_HPF);
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed\n",
- __func__);
- return -ENOMEM;
- }
- adm_params->payload_size =
- sizeof(struct srs_trumedia_params_HPF) +
- sizeof(struct adm_param_data_v5);
- param_id = SRS_TRUMEDIA_PARAMS_HPF;
- adm_params->params.param_size =
- sizeof(struct srs_trumedia_params_HPF);
- hpf_params = (struct srs_trumedia_params_HPF *)
- ((u8 *)adm_params +
- sizeof(struct adm_cmd_set_pp_params_inband_v5));
- memcpy(hpf_params, srs_params,
- sizeof(struct srs_trumedia_params_HPF));
+ param_hdr.param_id = SRS_TRUMEDIA_PARAMS_HPF;
+ param_hdr.param_size = sizeof(struct srs_trumedia_params_HPF);
break;
}
case SRS_ID_AEQ: {
- int *update_params_ptr = (int *)this_adm.outband_memmap.kvaddr;
+ u8 *update_params_ptr = (u8 *) this_adm.outband_memmap.kvaddr;
- outband = 1;
- adm_params = kzalloc(sizeof(struct adm_cmd_set_pp_params_v5),
- GFP_KERNEL);
- adm_params_ = (struct adm_cmd_set_pp_params_v5 *)adm_params;
- if (!adm_params_) {
- pr_err("%s, adm params memory alloc failed\n",
- __func__);
- return -ENOMEM;
- }
+ outband = true;
- sz = sizeof(struct srs_trumedia_params_AEQ);
if (update_params_ptr == NULL) {
pr_err("ADM_SRS_TRUMEDIA - %s: null memmap for AEQ params\n",
__func__);
ret = -EINVAL;
goto fail_cmd;
}
- param_id = SRS_TRUMEDIA_PARAMS_AEQ;
- *update_params_ptr++ = module_id;
- *update_params_ptr++ = param_id;
- *update_params_ptr++ = sz;
- memcpy(update_params_ptr, srs_params, sz);
- adm_params_->payload_size = sz + 12;
+ param_hdr.param_id = SRS_TRUMEDIA_PARAMS_AEQ;
+ param_hdr.param_size = sizeof(struct srs_trumedia_params_AEQ);
+ ret = q6common_pack_pp_params(update_params_ptr, ¶m_hdr,
+ srs_params, &total_param_size);
+ if (ret) {
+ pr_err("%s: Failed to pack param header and data, error %d\n",
+ __func__, ret);
+ goto fail_cmd;
+ }
break;
}
case SRS_ID_HL: {
- struct srs_trumedia_params_HL *hl_params = NULL;
-
- sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
- sizeof(struct srs_trumedia_params_HL);
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed\n",
- __func__);
- return -ENOMEM;
- }
- adm_params->payload_size =
- sizeof(struct srs_trumedia_params_HL) +
- sizeof(struct adm_param_data_v5);
- param_id = SRS_TRUMEDIA_PARAMS_HL;
- adm_params->params.param_size =
- sizeof(struct srs_trumedia_params_HL);
- hl_params = (struct srs_trumedia_params_HL *)
- ((u8 *)adm_params +
- sizeof(struct adm_cmd_set_pp_params_inband_v5));
- memcpy(hl_params, srs_params,
- sizeof(struct srs_trumedia_params_HL));
+ param_hdr.param_id = SRS_TRUMEDIA_PARAMS_HL;
+ param_hdr.param_size = sizeof(struct srs_trumedia_params_HL);
break;
}
case SRS_ID_GEQ: {
- struct srs_trumedia_params_GEQ *geq_params = NULL;
-
- sz = sizeof(struct adm_cmd_set_pp_params_inband_v5) +
- sizeof(struct srs_trumedia_params_GEQ);
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed\n",
- __func__);
- return -ENOMEM;
- }
- adm_params->payload_size =
- sizeof(struct srs_trumedia_params_GEQ) +
- sizeof(struct adm_param_data_v5);
- param_id = SRS_TRUMEDIA_PARAMS_GEQ;
- adm_params->params.param_size =
- sizeof(struct srs_trumedia_params_GEQ);
- geq_params = (struct srs_trumedia_params_GEQ *)
- ((u8 *)adm_params +
- sizeof(struct adm_cmd_set_pp_params_inband_v5));
- memcpy(geq_params, srs_params,
- sizeof(struct srs_trumedia_params_GEQ));
- pr_debug("SRS - %s: GEQ params prepared\n", __func__);
+ param_hdr.param_id = SRS_TRUMEDIA_PARAMS_GEQ;
+ param_hdr.param_size = sizeof(struct srs_trumedia_params_GEQ);
break;
}
default:
goto fail_cmd;
}
- adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- adm_params->hdr.src_svc = APR_SVC_ADM;
- adm_params->hdr.src_domain = APR_DOMAIN_APPS;
- adm_params->hdr.src_port = port_id;
- adm_params->hdr.dest_svc = APR_SVC_ADM;
- adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
- adm_params->hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- adm_params->hdr.token = port_idx << 16 | copp_idx;
- adm_params->hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
if (outband && this_adm.outband_memmap.paddr) {
- adm_params->hdr.pkt_size =
- sizeof(struct adm_cmd_set_pp_params_v5);
- adm_params->payload_addr_lsw = lower_32_bits(
- this_adm.outband_memmap.paddr);
- adm_params->payload_addr_msw = msm_audio_populate_upper_32_bits(
- this_adm.outband_memmap.paddr);
- adm_params->mem_map_handle = atomic_read(&this_adm.
- mem_map_handles[ADM_SRS_TRUMEDIA]);
- } else {
- adm_params->hdr.pkt_size = sz;
- adm_params->payload_addr_lsw = 0;
- adm_params->payload_addr_msw = 0;
- adm_params->mem_map_handle = 0;
+ mem_hdr.data_payload_addr_lsw =
+ lower_32_bits(this_adm.outband_memmap.paddr);
+ mem_hdr.data_payload_addr_msw =
+ msm_audio_populate_upper_32_bits(
+ this_adm.outband_memmap.paddr);
+ mem_hdr.mem_map_handle = atomic_read(
+ &this_adm.mem_map_handles[ADM_SRS_TRUMEDIA]);
- adm_params->params.module_id = module_id;
- adm_params->params.param_id = param_id;
- adm_params->params.reserved = 0;
+ ret = adm_set_pp_params(port_id, copp_idx, &mem_hdr, NULL,
+ total_param_size);
+ } else {
+ ret = adm_pack_and_set_one_pp_param(port_id, copp_idx,
+ param_hdr,
+ (u8 *) srs_params);
}
- pr_debug("SRS - %s: Command was sent now check Q6 - port id = %d, size %d, module id %x, param id %x.\n",
- __func__, adm_params->hdr.dest_port,
- adm_params->payload_size, module_id, param_id);
-
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- ret = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
- if (ret < 0) {
+ if (ret < 0)
pr_err("SRS - %s: ADM enable for port %d failed\n", __func__,
port_id);
- ret = -EINVAL;
- goto fail_cmd;
- }
- /* Wait for the callback with copp id */
- ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: SRS set params timed out port = %d\n",
- __func__, port_id);
- ret = -EINVAL;
- goto fail_cmd;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto fail_cmd;
- }
fail_cmd:
- kfree(adm_params);
return ret;
}
EXPORT_SYMBOL(srs_trumedia_open);
@@ -636,7 +480,7 @@
int channel_index)
{
struct adm_cmd_set_pspd_mtmx_strtr_params_v5 *adm_params = NULL;
- struct adm_param_data_v5 data_v5;
+ struct param_hdr_v3 data_v5;
int ret = 0, port_idx, sz = 0, param_size = 0;
u16 *adm_pspd_params;
u16 *ptr;
@@ -668,8 +512,8 @@
roundup(param_size, 4);
sz = sizeof(struct adm_cmd_set_pspd_mtmx_strtr_params_v5) +
- sizeof(struct default_chmixer_param_id_coeff) +
- sizeof(struct adm_param_data_v5) + param_size;
+ sizeof(struct default_chmixer_param_id_coeff) +
+ sizeof(struct param_hdr_v3) + param_size;
pr_debug("%s: sz = %d\n", __func__, sz);
adm_params = kzalloc(sz, GFP_KERNEL);
if (!adm_params)
@@ -687,13 +531,17 @@
&this_adm.copp.id[port_idx][copp_idx]);
adm_params->reserved = 0;
+ /*
+ * This module is internal to ADSP and cannot be configured with
+ * an instance id
+ */
data_v5.module_id = MTMX_MODULE_ID_DEFAULT_CHMIXER;
data_v5.param_id = DEFAULT_CHMIXER_PARAM_ID_COEFF;
data_v5.reserved = 0;
data_v5.param_size = param_size;
adm_params->payload_size =
- sizeof(struct default_chmixer_param_id_coeff) +
- sizeof(struct adm_param_data_v5) + data_v5.param_size;
+ sizeof(struct default_chmixer_param_id_coeff) +
+ sizeof(struct param_hdr_v3) + data_v5.param_size;
adm_pspd_params = (u16 *)((u8 *)adm_params +
sizeof(struct adm_cmd_set_pspd_mtmx_strtr_params_v5));
memcpy(adm_pspd_params, &data_v5, sizeof(data_v5));
@@ -941,335 +789,269 @@
}
EXPORT_SYMBOL(adm_set_stereo_to_custom_stereo);
-/**
- * adm_dolby_dap_send_params -
- * command to send dolby dap params
- *
- * @port_id: Port ID number
- * @copp_idx: copp index of ADM copp
- * @params: params pointer
- * @param_length: length of params
- *
- * Returns 0 on success or error on failure
+/*
+ * With pre-packed data, only the opcode differes from V5 and V6.
+ * Use q6common_pack_pp_params to pack the data correctly.
*/
-int adm_dolby_dap_send_params(int port_id, int copp_idx, char *params,
- uint32_t params_length)
+int adm_set_pp_params(int port_id, int copp_idx,
+ struct mem_mapping_hdr *mem_hdr, u8 *param_data,
+ u32 param_size)
{
- struct adm_cmd_set_pp_params_v5 *adm_params = NULL;
- int sz, rc = 0;
- int port_idx;
-
- pr_debug("%s:\n", __func__);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
- return -EINVAL;
- }
-
- sz = sizeof(struct adm_cmd_set_pp_params_v5) + params_length;
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed", __func__);
- return -ENOMEM;
- }
-
- memcpy(((u8 *)adm_params + sizeof(struct adm_cmd_set_pp_params_v5)),
- params, params_length);
- adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- adm_params->hdr.pkt_size = sz;
- adm_params->hdr.src_svc = APR_SVC_ADM;
- adm_params->hdr.src_domain = APR_DOMAIN_APPS;
- adm_params->hdr.src_port = port_id;
- adm_params->hdr.dest_svc = APR_SVC_ADM;
- adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
- adm_params->hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- adm_params->hdr.token = port_idx << 16 | copp_idx;
- adm_params->hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- adm_params->payload_addr_lsw = 0;
- adm_params->payload_addr_msw = 0;
- adm_params->mem_map_handle = 0;
- adm_params->payload_size = params_length;
-
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
- if (rc < 0) {
- pr_err("%s: Set params failed port = 0x%x rc %d\n",
- __func__, port_id, rc);
- rc = -EINVAL;
- goto dolby_dap_send_param_return;
- }
- /* Wait for the callback */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: Set params timed out port = 0x%x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto dolby_dap_send_param_return;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto dolby_dap_send_param_return;
- }
- rc = 0;
-dolby_dap_send_param_return:
- kfree(adm_params);
- return rc;
-}
-EXPORT_SYMBOL(adm_dolby_dap_send_params);
-
-/**
- * adm_get_params_v5 -
- * command to retrieve ADM params for given module
- *
- * @port_id: Port ID number
- * @copp_idx: copp index of ADM copp
- * @params: params pointer
- * @param_length: length of params
- *
- * Returns 0 on success or error on failure
- */
-int adm_send_params_v5(int port_id, int copp_idx, char *params,
- uint32_t params_length)
-{
- struct adm_cmd_set_pp_params_v5 *adm_params = NULL;
- int rc = 0;
- int sz, port_idx;
-
- pr_debug("%s:\n", __func__);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
- return -EINVAL;
- }
-
- sz = sizeof(struct adm_cmd_set_pp_params_v5) + params_length;
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed", __func__);
- return -ENOMEM;
- }
-
- memcpy(((u8 *)adm_params + sizeof(struct adm_cmd_set_pp_params_v5)),
- params, params_length);
- adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- adm_params->hdr.pkt_size = sz;
- adm_params->hdr.src_svc = APR_SVC_ADM;
- adm_params->hdr.src_domain = APR_DOMAIN_APPS;
- adm_params->hdr.src_port = port_id;
- adm_params->hdr.dest_svc = APR_SVC_ADM;
- adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
- adm_params->hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- adm_params->hdr.token = port_idx << 16 | copp_idx;
- adm_params->hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- adm_params->payload_addr_lsw = 0;
- adm_params->payload_addr_msw = 0;
- adm_params->mem_map_handle = 0;
- adm_params->payload_size = params_length;
-
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
- if (rc < 0) {
- pr_err("%s: Set params failed port = 0x%x rc %d\n",
- __func__, port_id, rc);
- rc = -EINVAL;
- goto send_param_return;
- }
- /* Wait for the callback */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: Set params timed out port = 0x%x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto send_param_return;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto send_param_return;
- }
- rc = 0;
-send_param_return:
- kfree(adm_params);
- return rc;
-}
-EXPORT_SYMBOL(adm_send_params_v5);
-
-int adm_get_params_v2(int port_id, int copp_idx, uint32_t module_id,
- uint32_t param_id, uint32_t params_length,
- char *params, uint32_t client_id)
-{
- struct adm_cmd_get_pp_params_v5 *adm_params = NULL;
- int rc = 0, i = 0;
- int port_idx, idx;
- int *params_data = (int *)params;
- uint64_t sz = 0;
+ struct adm_cmd_set_pp_params *adm_set_params = NULL;
+ int size = 0;
+ int port_idx = 0;
+ atomic_t *copp_stat = NULL;
+ int ret = 0;
port_id = afe_convert_virtual_to_portid(port_id);
port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
+ if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
+ pr_err("%s: Invalid port_idx 0x%x\n", __func__, port_idx);
+ return -EINVAL;
+ } else if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
+ pr_err("%s: Invalid copp_idx 0x%x\n", __func__, copp_idx);
return -EINVAL;
}
- sz = (uint64_t)sizeof(struct adm_cmd_get_pp_params_v5) +
- (uint64_t)params_length;
- /*
- * Check if the value of "sz" (which is ultimately assigned to
- * "hdr.pkt_size") crosses U16_MAX.
- */
- if (sz > U16_MAX) {
- pr_err("%s: Invalid params_length\n", __func__);
- return -EINVAL;
- }
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s: adm params memory alloc failed", __func__);
+ /* Only add params_size in inband case */
+ size = sizeof(struct adm_cmd_set_pp_params);
+ if (param_data != NULL)
+ size += param_size;
+ adm_set_params = kzalloc(size, GFP_KERNEL);
+ if (!adm_set_params)
return -ENOMEM;
- }
- memcpy(((u8 *)adm_params + sizeof(struct adm_cmd_get_pp_params_v5)),
- params, params_length);
- adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- adm_params->hdr.pkt_size = sz;
- adm_params->hdr.src_svc = APR_SVC_ADM;
- adm_params->hdr.src_domain = APR_DOMAIN_APPS;
- adm_params->hdr.src_port = port_id;
- adm_params->hdr.dest_svc = APR_SVC_ADM;
- adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
- adm_params->hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- adm_params->hdr.token = port_idx << 16 | client_id << 8 | copp_idx;
- adm_params->hdr.opcode = ADM_CMD_GET_PP_PARAMS_V5;
- adm_params->data_payload_addr_lsw = 0;
- adm_params->data_payload_addr_msw = 0;
- adm_params->mem_map_handle = 0;
- adm_params->module_id = module_id;
- adm_params->param_id = param_id;
- adm_params->param_max_size = params_length;
- adm_params->reserved = 0;
+ adm_set_params->apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ adm_set_params->apr_hdr.pkt_size = size;
+ adm_set_params->apr_hdr.src_svc = APR_SVC_ADM;
+ adm_set_params->apr_hdr.src_domain = APR_DOMAIN_APPS;
+ adm_set_params->apr_hdr.src_port = port_id;
+ adm_set_params->apr_hdr.dest_svc = APR_SVC_ADM;
+ adm_set_params->apr_hdr.dest_domain = APR_DOMAIN_ADSP;
+ adm_set_params->apr_hdr.dest_port =
+ atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
+ adm_set_params->apr_hdr.token = port_idx << 16 | copp_idx;
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
- if (rc < 0) {
- pr_err("%s: Failed to Get Params on port_id 0x%x %d\n",
- __func__, port_id, rc);
- rc = -EINVAL;
- goto adm_get_param_return;
- }
- /* Wait for the callback with copp id */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: get params timed out port_id = 0x%x\n", __func__,
- port_id);
- rc = -EINVAL;
- goto adm_get_param_return;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto adm_get_param_return;
- }
- idx = ADM_GET_PARAMETER_LENGTH * copp_idx;
+ if (q6common_is_instance_id_supported())
+ adm_set_params->apr_hdr.opcode = ADM_CMD_SET_PP_PARAMS_V6;
+ else
+ adm_set_params->apr_hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- if (adm_get_parameters[idx] < 0) {
- pr_err("%s: Size is invalid %d\n", __func__,
- adm_get_parameters[idx]);
- rc = -EINVAL;
- goto adm_get_param_return;
- }
- if ((params_data) &&
- (ARRAY_SIZE(adm_get_parameters) >
- idx) &&
- (ARRAY_SIZE(adm_get_parameters) >=
- 1+adm_get_parameters[idx]+idx) &&
- (params_length/sizeof(uint32_t) >=
- adm_get_parameters[idx])) {
- for (i = 0; i < adm_get_parameters[idx]; i++)
- params_data[i] = adm_get_parameters[1+i+idx];
+ adm_set_params->payload_size = param_size;
+ if (mem_hdr != NULL) {
+ /* Out of Band Case */
+ adm_set_params->mem_hdr = *mem_hdr;
+ } else if (param_data != NULL) {
+ /*
+ * In band case. Parameter data must be pre-packed with its
+ * header before calling this function. Use
+ * q6common_pack_pp_params to pack parameter data and header
+ * correctly.
+ */
+ memcpy(&adm_set_params->param_data, param_data, param_size);
} else {
- pr_err("%s: Get param data not copied! get_param array size %zd, index %d, params array size %zd, index %d\n",
- __func__, ARRAY_SIZE(adm_get_parameters),
- (1+adm_get_parameters[idx]+idx),
- params_length/sizeof(int),
- adm_get_parameters[idx]);
+ pr_err("%s: Received NULL pointers for both memory header and param data\n",
+ __func__);
+ ret = -EINVAL;
+ goto done;
}
- rc = 0;
-adm_get_param_return:
- kfree(adm_params);
- return rc;
+ copp_stat = &this_adm.copp.stat[port_idx][copp_idx];
+ atomic_set(copp_stat, -1);
+ ret = apr_send_pkt(this_adm.apr, (uint32_t *) adm_set_params);
+ if (ret < 0) {
+ pr_err("%s: Set params APR send failed port = 0x%x ret %d\n",
+ __func__, port_id, ret);
+ goto done;
+ }
+ ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
+ atomic_read(copp_stat) >= 0,
+ msecs_to_jiffies(TIMEOUT_MS));
+ if (!ret) {
+ pr_err("%s: Set params timed out port = 0x%x\n", __func__,
+ port_id);
+ ret = -ETIMEDOUT;
+ goto done;
+ }
+ if (atomic_read(copp_stat) > 0) {
+ pr_err("%s: DSP returned error[%s]\n", __func__,
+ adsp_err_get_err_str(atomic_read(copp_stat)));
+ ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat));
+ goto done;
+ }
+
+ ret = 0;
+done:
+ kfree(adm_set_params);
+ return ret;
}
+EXPORT_SYMBOL(adm_set_pp_params);
-/**
- * adm_get_params -
- * command to retrieve ADM params for given module
- *
- * @port_id: Port ID number
- * @copp_idx: copp index of ADM copp
- * @module_id: module ID
- * @param_id: Param index
- * @param_length: length of params
- * @params: params pointer
- *
- * Returns 0 on success or error on failure
- */
-int adm_get_params(int port_id, int copp_idx, uint32_t module_id,
- uint32_t param_id, uint32_t params_length, char *params)
+int adm_pack_and_set_one_pp_param(int port_id, int copp_idx,
+ struct param_hdr_v3 param_hdr, u8 *param_data)
{
- return adm_get_params_v2(port_id, copp_idx, module_id, param_id,
- params_length, params, 0);
+ u8 *packed_data = NULL;
+ u32 total_size = 0;
+ int ret = 0;
+
+ total_size = sizeof(union param_hdrs) + param_hdr.param_size;
+ packed_data = kzalloc(total_size, GFP_KERNEL);
+ if (!packed_data)
+ return -ENOMEM;
+
+ ret = q6common_pack_pp_params(packed_data, ¶m_hdr, param_data,
+ &total_size);
+ if (ret) {
+ pr_err("%s: Failed to pack parameter data, error %d\n",
+ __func__, ret);
+ goto done;
+ }
+
+ ret = adm_set_pp_params(port_id, copp_idx, NULL, packed_data,
+ total_size);
+ if (ret)
+ pr_err("%s: Failed to set parameter data, error %d\n", __func__,
+ ret);
+done:
+ kfree(packed_data);
+ return ret;
}
-EXPORT_SYMBOL(adm_get_params);
+EXPORT_SYMBOL(adm_pack_and_set_one_pp_param);
-/**
- * adm_get_pp_topo_module_list -
- * command to update PP top module list
- *
- * @port_id: Port ID number
- * @copp_idx: copp index of ADM copp
- * @param_length: length of params
- * @params: pointer with PP top module params
- *
- * Returns 0 on success or error on failure
+/*
+ * Only one parameter can be requested at a time. Therefore, packing and sending
+ * the request can be handled locally.
*/
-int adm_get_pp_topo_module_list(int port_id, int copp_idx, int32_t param_length,
- char *params)
+int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id,
+ struct mem_mapping_hdr *mem_hdr,
+ struct param_hdr_v3 *param_hdr, u8 *returned_param_data)
{
- struct adm_cmd_get_pp_topo_module_list_t *adm_pp_module_list = NULL;
- int sz, rc = 0, i = 0;
- int port_idx, idx;
- int32_t *params_data = (int32_t *)params;
+ struct adm_cmd_get_pp_params adm_get_params;
+ int total_size = 0;
+ int get_param_array_sz = ARRAY_SIZE(adm_get_parameters);
+ int returned_param_size = 0;
+ int returned_param_size_in_bytes = 0;
+ int port_idx = 0;
+ int idx = 0;
+ atomic_t *copp_stat = NULL;
+ int ret = 0;
+
+ if (param_hdr == NULL) {
+ pr_err("%s: Received NULL pointer for parameter header\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ port_id = afe_convert_virtual_to_portid(port_id);
+ port_idx = adm_validate_and_get_port_index(port_id);
+ if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
+ pr_err("%s: Invalid port_idx 0x%x\n", __func__, port_idx);
+ return -EINVAL;
+ }
+ if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
+ pr_err("%s: Invalid copp_idx 0x%x\n", __func__, copp_idx);
+ return -EINVAL;
+ }
+
+ memset(&adm_get_params, 0, sizeof(adm_get_params));
+
+ if (mem_hdr != NULL)
+ adm_get_params.mem_hdr = *mem_hdr;
+
+ q6common_pack_pp_params((u8 *) &adm_get_params.param_hdr, param_hdr,
+ NULL, &total_size);
+
+ /* Pack APR header after filling body so total_size has correct value */
+ adm_get_params.apr_hdr.pkt_size = total_size;
+ adm_get_params.apr_hdr.src_svc = APR_SVC_ADM;
+ adm_get_params.apr_hdr.src_domain = APR_DOMAIN_APPS;
+ adm_get_params.apr_hdr.src_port = port_id;
+ adm_get_params.apr_hdr.dest_svc = APR_SVC_ADM;
+ adm_get_params.apr_hdr.dest_domain = APR_DOMAIN_ADSP;
+ adm_get_params.apr_hdr.dest_port =
+ atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
+ adm_get_params.apr_hdr.token =
+ port_idx << 16 | client_id << 8 | copp_idx;
+
+ if (q6common_is_instance_id_supported())
+ adm_get_params.apr_hdr.opcode = ADM_CMD_GET_PP_PARAMS_V6;
+ else
+ adm_get_params.apr_hdr.opcode = ADM_CMD_GET_PP_PARAMS_V5;
+
+ copp_stat = &this_adm.copp.stat[port_idx][copp_idx];
+ atomic_set(copp_stat, -1);
+ ret = apr_send_pkt(this_adm.apr, (uint32_t *) &adm_get_params);
+ if (ret) {
+ pr_err("%s: Get params APR send failed port = 0x%x ret %d\n",
+ __func__, port_id, ret);
+ ret = -EINVAL;
+ goto done;
+ }
+ ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
+ atomic_read(copp_stat) >= 0,
+ msecs_to_jiffies(TIMEOUT_MS));
+ if (!ret) {
+ pr_err("%s: Get params timed out port = 0x%x\n", __func__,
+ port_id);
+ ret = -ETIMEDOUT;
+ goto done;
+ }
+ if (atomic_read(copp_stat) > 0) {
+ pr_err("%s: DSP returned error[%s]\n", __func__,
+ adsp_err_get_err_str(atomic_read(copp_stat)));
+ ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat));
+ goto done;
+ }
+
+ ret = 0;
+
+ /* Copy data to caller if sent in band */
+ if (!returned_param_data) {
+ pr_debug("%s: Received NULL pointer for param destination, not copying payload\n",
+ __func__);
+ return 0;
+ }
+
+ idx = ADM_GET_PARAMETER_LENGTH * copp_idx;
+ returned_param_size = adm_get_parameters[idx];
+ if (returned_param_size < 0 ||
+ returned_param_size + idx + 1 > get_param_array_sz) {
+ pr_err("%s: Invalid parameter size %d\n", __func__,
+ returned_param_size);
+ return -EINVAL;
+ }
+
+ returned_param_size_in_bytes = returned_param_size * sizeof(uint32_t);
+ if (param_hdr->param_size < returned_param_size_in_bytes) {
+ pr_err("%s: Provided buffer is not big enough, provided buffer size(%d) size needed(%d)\n",
+ __func__, param_hdr->param_size,
+ returned_param_size_in_bytes);
+ return -EINVAL;
+ }
+
+ memcpy(returned_param_data, &adm_get_parameters[idx + 1],
+ returned_param_size_in_bytes);
+done:
+ return ret;
+}
+EXPORT_SYMBOL(adm_get_pp_params);
+
+int adm_get_pp_topo_module_list_v2(int port_id, int copp_idx,
+ int32_t param_length,
+ int32_t *returned_params)
+{
+ struct adm_cmd_get_pp_topo_module_list adm_get_module_list;
+ bool iid_supported = q6common_is_instance_id_supported();
int *topo_list;
+ int num_modules = 0;
+ int list_size = 0;
+ int port_idx, idx;
+ int i = 0;
+ atomic_t *copp_stat = NULL;
+ int ret = 0;
pr_debug("%s : port_id %x", __func__, port_id);
port_id = afe_convert_virtual_to_portid(port_id);
@@ -1284,81 +1066,96 @@
return -EINVAL;
}
- sz = sizeof(struct adm_cmd_get_pp_topo_module_list_t) + param_length;
- adm_pp_module_list = kzalloc(sz, GFP_KERNEL);
- if (!adm_pp_module_list) {
- pr_err("%s, adm params memory alloc failed", __func__);
- return -ENOMEM;
+ memset(&adm_get_module_list, 0, sizeof(adm_get_module_list));
+
+ adm_get_module_list.apr_hdr.pkt_size = sizeof(adm_get_module_list);
+ adm_get_module_list.apr_hdr.src_svc = APR_SVC_ADM;
+ adm_get_module_list.apr_hdr.src_domain = APR_DOMAIN_APPS;
+ adm_get_module_list.apr_hdr.src_port = port_id;
+ adm_get_module_list.apr_hdr.dest_svc = APR_SVC_ADM;
+ adm_get_module_list.apr_hdr.dest_domain = APR_DOMAIN_ADSP;
+ adm_get_module_list.apr_hdr.dest_port =
+ atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
+ adm_get_module_list.apr_hdr.token = port_idx << 16 | copp_idx;
+ /*
+ * Out of band functionality is not currently utilized.
+ * Assume in band.
+ */
+ if (iid_supported) {
+ adm_get_module_list.apr_hdr.opcode =
+ ADM_CMD_GET_PP_TOPO_MODULE_LIST_V2;
+ adm_get_module_list.param_max_size = param_length;
+ } else {
+ adm_get_module_list.apr_hdr.opcode =
+ ADM_CMD_GET_PP_TOPO_MODULE_LIST;
+
+ if (param_length > U16_MAX) {
+ pr_err("%s: Invalid param length for V1 %d\n", __func__,
+ param_length);
+ return -EINVAL;
+ }
+ adm_get_module_list.param_max_size = param_length << 16;
}
- memcpy(((u8 *)adm_pp_module_list +
- sizeof(struct adm_cmd_get_pp_topo_module_list_t)),
- params, param_length);
- adm_pp_module_list->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- adm_pp_module_list->hdr.pkt_size = sz;
- adm_pp_module_list->hdr.src_svc = APR_SVC_ADM;
- adm_pp_module_list->hdr.src_domain = APR_DOMAIN_APPS;
- adm_pp_module_list->hdr.src_port = port_id;
- adm_pp_module_list->hdr.dest_svc = APR_SVC_ADM;
- adm_pp_module_list->hdr.dest_domain = APR_DOMAIN_ADSP;
- adm_pp_module_list->hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- adm_pp_module_list->hdr.token = port_idx << 16 | copp_idx;
- adm_pp_module_list->hdr.opcode = ADM_CMD_GET_PP_TOPO_MODULE_LIST;
- adm_pp_module_list->param_max_size = param_length;
- /* Payload address and mmap handle set to zero by kzalloc */
+ copp_stat = &this_adm.copp.stat[port_idx][copp_idx];
+ atomic_set(copp_stat, -1);
+ ret = apr_send_pkt(this_adm.apr, (uint32_t *) &adm_get_module_list);
+ if (ret) {
+ pr_err("%s: APR send pkt failed for port_id: 0x%x failed ret %d\n",
+ __func__, port_id, ret);
+ ret = -EINVAL;
+ goto done;
+ }
+ ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
+ atomic_read(copp_stat) >= 0,
+ msecs_to_jiffies(TIMEOUT_MS));
+ if (!ret) {
+ pr_err("%s: Timeout for port_id: 0x%x\n", __func__, port_id);
+ ret = -ETIMEDOUT;
+ goto done;
+ }
+ if (atomic_read(copp_stat) > 0) {
+ pr_err("%s: DSP returned error[%s]\n", __func__,
+ adsp_err_get_err_str(atomic_read(copp_stat)));
+ ret = adsp_err_get_lnx_err_code(atomic_read(copp_stat));
+ goto done;
+ }
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
+ ret = 0;
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_pp_module_list);
- if (rc < 0) {
- pr_err("%s: Failed to Get Params on port %d\n", __func__,
- port_id);
- rc = -EINVAL;
- goto adm_pp_module_list_l;
+ if (returned_params) {
+ /*
+ * When processing ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST IID is
+ * added since it is not present. Therefore, there is no need to
+ * do anything different if IID is not supported here as it is
+ * already taken care of.
+ */
+ idx = ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH * copp_idx;
+ num_modules = adm_module_topo_list[idx];
+ if (num_modules < 0 || num_modules > MAX_MODULES_IN_TOPO) {
+ pr_err("%s: Invalid number of modules returned %d\n",
+ __func__, num_modules);
+ return -EINVAL;
+ }
+
+ list_size = num_modules * sizeof(struct module_instance_info);
+ if (param_length < list_size) {
+ pr_err("%s: Provided buffer not big enough to hold module-instance list, provided size %d, needed size %d\n",
+ __func__, param_length, list_size);
+ return -EINVAL;
+ }
+
+ topo_list = (int32_t *) (&adm_module_topo_list[idx]);
+ memcpy(returned_params, topo_list, list_size);
+ for (i = 1; i <= num_modules; i += 2) {
+ pr_debug("module = 0x%x instance = 0x%x\n",
+ returned_params[i], returned_params[i + 1]);
+ }
}
- /* Wait for the callback with copp id */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: get params timed out port = %d\n", __func__,
- port_id);
- rc = -EINVAL;
- goto adm_pp_module_list_l;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto adm_pp_module_list_l;
- }
- if (params_data) {
- idx = ADM_GET_TOPO_MODULE_LIST_LENGTH * copp_idx;
- topo_list = (int *)(adm_module_topo_list + idx);
- if (param_length <= ADM_GET_TOPO_MODULE_LIST_LENGTH &&
- idx <
- (MAX_COPPS_PER_PORT * ADM_GET_TOPO_MODULE_LIST_LENGTH))
- memcpy(params_data, topo_list, param_length);
- else
- pr_debug("%s: i/p size:%d > MAX param size:%d\n",
- __func__, param_length,
- (int)ADM_GET_TOPO_MODULE_LIST_LENGTH);
- for (i = 1; i <= params_data[0]; i++)
- pr_debug("module = 0x%x\n", params_data[i]);
- }
- rc = 0;
-adm_pp_module_list_l:
- kfree(adm_pp_module_list);
- pr_debug("%s : rc = %d ", __func__, rc);
- return rc;
+done:
+ return ret;
}
-EXPORT_SYMBOL(adm_get_pp_topo_module_list);
+EXPORT_SYMBOL(adm_get_pp_topo_module_list_v2);
static void adm_callback_debug_print(struct apr_client_data *data)
{
@@ -1440,6 +1237,114 @@
}
EXPORT_SYMBOL(adm_get_multi_ch_map);
+static int adm_process_get_param_response(u32 opcode, u32 idx, u32 *payload,
+ u32 payload_size)
+{
+ struct adm_cmd_rsp_get_pp_params_v5 *v5_rsp = NULL;
+ struct adm_cmd_rsp_get_pp_params_v6 *v6_rsp = NULL;
+ u32 *param_data = NULL;
+ int data_size = 0;
+ int struct_size = 0;
+
+ if (payload == NULL) {
+ pr_err("%s: Payload is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ switch (opcode) {
+ case ADM_CMDRSP_GET_PP_PARAMS_V5:
+ struct_size = sizeof(struct adm_cmd_rsp_get_pp_params_v5);
+ v5_rsp = (struct adm_cmd_rsp_get_pp_params_v5 *) payload;
+ data_size = v5_rsp->param_hdr.param_size;
+ param_data = v5_rsp->param_data;
+ break;
+ case ADM_CMDRSP_GET_PP_PARAMS_V6:
+ struct_size = sizeof(struct adm_cmd_rsp_get_pp_params_v6);
+ v6_rsp = (struct adm_cmd_rsp_get_pp_params_v6 *) payload;
+ data_size = v6_rsp->param_hdr.param_size;
+ param_data = v6_rsp->param_data;
+ break;
+ default:
+ pr_err("%s: Invalid opcode %d\n", __func__, opcode);
+ return -EINVAL;
+ }
+
+ /*
+ * Just store the returned parameter data, not the header. The calling
+ * function is expected to know what it asked for. Therefore, there is
+ * no difference between V5 and V6.
+ */
+ if ((payload_size >= struct_size + data_size) &&
+ (ARRAY_SIZE(adm_get_parameters) > idx) &&
+ (ARRAY_SIZE(adm_get_parameters) >= idx + 1 + data_size)) {
+ /*
+ * data_size is expressed in number of bytes, store in number of
+ * ints
+ */
+ adm_get_parameters[idx] =
+ data_size / sizeof(*adm_get_parameters);
+ pr_debug("%s: GET_PP PARAM: received parameter length: 0x%x\n",
+ __func__, adm_get_parameters[idx]);
+ /* store params after param_size */
+ memcpy(&adm_get_parameters[idx + 1], param_data, data_size);
+ return 0;
+ }
+
+ pr_err("%s: Invalid parameter combination, payload_size %d, idx %d\n",
+ __func__, payload_size, idx);
+ return -EINVAL;
+}
+
+static int adm_process_get_topo_list_response(u32 opcode, int copp_idx,
+ u32 num_modules, u32 *payload,
+ u32 payload_size)
+{
+ u32 *fill_list = NULL;
+ int idx = 0;
+ int i = 0;
+ int j = 0;
+
+ if (payload == NULL) {
+ pr_err("%s: Payload is NULL\n", __func__);
+ return -EINVAL;
+ } else if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
+ pr_err("%s: Invalid COPP index %d\n", __func__, copp_idx);
+ return -EINVAL;
+ }
+
+ idx = ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH * copp_idx;
+ fill_list = adm_module_topo_list + idx;
+ *fill_list++ = num_modules;
+ for (i = 0; i < num_modules; i++) {
+ if (j > payload_size / sizeof(u32)) {
+ pr_err("%s: Invalid number of modules specified %d\n",
+ __func__, num_modules);
+ return -EINVAL;
+ }
+
+ /* store module ID */
+ *fill_list++ = payload[j];
+ j++;
+
+ switch (opcode) {
+ case ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST_V2:
+ /* store instance ID */
+ *fill_list++ = payload[j];
+ j++;
+ break;
+ case ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST:
+ /* Insert IID 0 when repacking */
+ *fill_list++ = INSTANCE_ID_0;
+ break;
+ default:
+ pr_err("%s: Invalid opcode %d\n", __func__, opcode);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
static void adm_reset_data(void)
{
int i, j;
@@ -1501,7 +1406,9 @@
static int32_t adm_callback(struct apr_client_data *data, void *priv)
{
uint32_t *payload;
- int i, port_idx, copp_idx, idx, client_id;
+ int port_idx, copp_idx, idx, client_id;
+ int num_modules;
+ int ret;
if (data == NULL) {
pr_err("%s: data parameter is null\n", __func__);
@@ -1548,8 +1455,9 @@
}
switch (payload[0]) {
case ADM_CMD_SET_PP_PARAMS_V5:
- pr_debug("%s: ADM_CMD_SET_PP_PARAMS_V5\n",
- __func__);
+ case ADM_CMD_SET_PP_PARAMS_V6:
+ pr_debug("%s: ADM_CMD_SET_PP_PARAMS\n",
+ __func__);
if (client_id == ADM_CLIENT_ID_SOURCE_TRACKING)
this_adm.sourceTrackingData.
apr_cmd_status = payload[1];
@@ -1605,8 +1513,9 @@
}
break;
case ADM_CMD_GET_PP_PARAMS_V5:
- pr_debug("%s: ADM_CMD_GET_PP_PARAMS_V5\n",
- __func__);
+ case ADM_CMD_GET_PP_PARAMS_V6:
+ pr_debug("%s: ADM_CMD_GET_PP_PARAMS\n",
+ __func__);
/* Should only come here if there is an APR */
/* error or malformed APR packet. Otherwise */
/* response will be returned as */
@@ -1643,11 +1552,12 @@
&this_adm.copp.wait[port_idx][copp_idx]);
break;
case ADM_CMD_GET_PP_TOPO_MODULE_LIST:
+ case ADM_CMD_GET_PP_TOPO_MODULE_LIST_V2:
pr_debug("%s:ADM_CMD_GET_PP_TOPO_MODULE_LIST\n",
__func__);
if (payload[1] != 0)
- pr_err("%s: ADM get topo list error = %d,\n",
- __func__, payload[1]);
+ pr_err("%s: ADM get topo list error = %d\n",
+ __func__, payload[1]);
break;
default:
pr_err("%s: Unknown Cmd: 0x%x\n", __func__,
@@ -1682,80 +1592,60 @@
}
break;
case ADM_CMDRSP_GET_PP_PARAMS_V5:
- pr_debug("%s: ADM_CMDRSP_GET_PP_PARAMS_V5\n", __func__);
- if (payload[0] != 0)
- pr_err("%s: ADM_CMDRSP_GET_PP_PARAMS_V5 returned error = 0x%x\n",
- __func__, payload[0]);
+ case ADM_CMDRSP_GET_PP_PARAMS_V6:
+ pr_debug("%s: ADM_CMDRSP_GET_PP_PARAMS\n", __func__);
if (client_id == ADM_CLIENT_ID_SOURCE_TRACKING)
this_adm.sourceTrackingData.apr_cmd_status =
- payload[0];
+ payload[0];
else if (rtac_make_adm_callback(payload,
- data->payload_size))
+ data->payload_size))
break;
idx = ADM_GET_PARAMETER_LENGTH * copp_idx;
- if ((payload[0] == 0) && (data->payload_size >
- (4 * sizeof(*payload))) &&
- (data->payload_size - 4 >=
- payload[3]) &&
- (ARRAY_SIZE(adm_get_parameters) >
- idx) &&
- (ARRAY_SIZE(adm_get_parameters)-idx-1 >=
- payload[3])) {
- adm_get_parameters[idx] = payload[3] /
- sizeof(uint32_t);
- /*
- * payload[3] is param_size which is
- * expressed in number of bytes
- */
- pr_debug("%s: GET_PP PARAM:received parameter length: 0x%x\n",
- __func__, adm_get_parameters[idx]);
- /* storing param size then params */
- for (i = 0; i < payload[3] /
- sizeof(uint32_t); i++)
- adm_get_parameters[idx+1+i] =
- payload[4+i];
- } else if (payload[0] == 0) {
+ if (payload[0] == 0 && data->payload_size > 0) {
+ pr_debug("%s: Received parameter data in band\n",
+ __func__);
+ ret = adm_process_get_param_response(
+ data->opcode, idx, payload,
+ data->payload_size);
+ if (ret)
+ pr_err("%s: Failed to process get param response, error %d\n",
+ __func__, ret);
+ } else if (payload[0] == 0 && data->payload_size == 0) {
adm_get_parameters[idx] = -1;
- pr_err("%s: Out of band case, setting size to %d\n",
+ pr_debug("%s: Out of band case, setting size to %d\n",
__func__, adm_get_parameters[idx]);
} else {
adm_get_parameters[idx] = -1;
- pr_err("%s: GET_PP_PARAMS failed, setting size to %d\n",
- __func__, adm_get_parameters[idx]);
+ pr_err("%s: ADM_CMDRSP_GET_PP_PARAMS returned error 0x%x\n",
+ __func__, payload[0]);
}
- atomic_set(&this_adm.copp.stat
- [port_idx][copp_idx], payload[0]);
+ atomic_set(&this_adm.copp.stat[port_idx][copp_idx],
+ payload[0]);
wake_up(&this_adm.copp.wait[port_idx][copp_idx]);
break;
case ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST:
+ case ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST_V2:
pr_debug("%s: ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST\n",
__func__);
- if (payload[0] != 0) {
- pr_err("%s: ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST",
- __func__);
- pr_err(":err = 0x%x\n", payload[0]);
- } else if (payload[1] >
- ((ADM_GET_TOPO_MODULE_LIST_LENGTH /
- sizeof(uint32_t)) - 1)) {
- pr_err("%s: ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST",
- __func__);
- pr_err(":size = %d\n", payload[1]);
+ num_modules = payload[1];
+ pr_debug("%s: Num modules %d\n", __func__, num_modules);
+ if (payload[0]) {
+ pr_err("%s: ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST, error = %d\n",
+ __func__, payload[0]);
+ } else if (num_modules > MAX_MODULES_IN_TOPO) {
+ pr_err("%s: ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST invalid num modules received, num modules = %d\n",
+ __func__, num_modules);
} else {
- idx = ADM_GET_TOPO_MODULE_LIST_LENGTH *
- copp_idx;
- pr_debug("%s:Num modules payload[1] %d\n",
- __func__, payload[1]);
- adm_module_topo_list[idx] = payload[1];
- for (i = 1; i <= payload[1]; i++) {
- adm_module_topo_list[idx+i] =
- payload[1+i];
- pr_debug("%s:payload[%d] = %x\n",
- __func__, (i+1), payload[1+i]);
- }
+ ret = adm_process_get_topo_list_response(
+ data->opcode, copp_idx, num_modules,
+ payload, data->payload_size);
+ if (ret)
+ pr_err("%s: Failed to process get topo modules list response, error %d\n",
+ __func__, ret);
}
- atomic_set(&this_adm.copp.stat
- [port_idx][copp_idx], payload[0]);
+ atomic_set(&this_adm.copp.stat[port_idx][copp_idx],
+ payload[0]);
wake_up(&this_adm.copp.wait[port_idx][copp_idx]);
break;
case ADM_CMDRSP_SHARED_MEM_MAP_REGIONS:
@@ -2036,21 +1926,16 @@
}
static int send_adm_cal_block(int port_id, int copp_idx,
- struct cal_block_data *cal_block, int perf_mode,
- int app_type, int acdb_id, int sample_rate)
+ struct cal_block_data *cal_block, int perf_mode)
{
- s32 result = 0;
- struct adm_cmd_set_pp_params_v5 adm_params;
- int port_idx;
+ struct mem_mapping_hdr mem_hdr;
+ int payload_size = 0;
+ int port_idx = 0;
+ int topology = 0;
+ int result = 0;
- pr_debug("%s: Port id 0x%x sample_rate %d ,\n", __func__,
- port_id, sample_rate);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
- return -EINVAL;
- }
+ pr_debug("%s: Port id 0x%x,\n", __func__, port_id);
+
if (!cal_block) {
pr_debug("%s: No ADM cal to send for port_id = 0x%x!\n",
__func__, port_id);
@@ -2058,75 +1943,39 @@
goto done;
}
if (cal_block->cal_data.size <= 0) {
- pr_debug("%s: No ADM cal send for port_id = 0x%x!\n",
- __func__, port_id);
+ pr_debug("%s: No ADM cal sent for port_id = 0x%x!\n", __func__,
+ port_id);
result = -EINVAL;
goto done;
}
+ memset(&mem_hdr, 0, sizeof(mem_hdr));
+ port_id = afe_convert_virtual_to_portid(port_id);
+ port_idx = adm_validate_and_get_port_index(port_id);
+ if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
+ pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
+ return -EINVAL;
+ } else if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
+ pr_err("%s: Invalid copp_idx 0x%x\n", __func__, copp_idx);
+ return -EINVAL;
+ }
+
+ topology = atomic_read(&this_adm.copp.topology[port_idx][copp_idx]);
if (perf_mode == LEGACY_PCM_MODE &&
- ((atomic_read(&this_adm.copp.topology[port_idx][copp_idx])) ==
- DS2_ADM_COPP_TOPOLOGY_ID)) {
+ topology == DS2_ADM_COPP_TOPOLOGY_ID) {
pr_err("%s: perf_mode %d, topology 0x%x\n", __func__, perf_mode,
- atomic_read(
- &this_adm.copp.topology[port_idx][copp_idx]));
+ topology);
goto done;
}
- adm_params.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(20), APR_PKT_VER);
- adm_params.hdr.pkt_size = sizeof(adm_params);
- adm_params.hdr.src_svc = APR_SVC_ADM;
- adm_params.hdr.src_domain = APR_DOMAIN_APPS;
- adm_params.hdr.src_port = port_id;
- adm_params.hdr.dest_svc = APR_SVC_ADM;
- adm_params.hdr.dest_domain = APR_DOMAIN_ADSP;
+ mem_hdr.data_payload_addr_lsw =
+ lower_32_bits(cal_block->cal_data.paddr);
+ mem_hdr.data_payload_addr_msw =
+ msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
+ mem_hdr.mem_map_handle = cal_block->map_data.q6map_handle;
+ payload_size = cal_block->cal_data.size;
- adm_params.hdr.token = port_idx << 16 | copp_idx;
- adm_params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- adm_params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- adm_params.payload_addr_lsw = lower_32_bits(cal_block->cal_data.paddr);
- adm_params.payload_addr_msw = msm_audio_populate_upper_32_bits(
- cal_block->cal_data.paddr);
- adm_params.mem_map_handle = cal_block->map_data.q6map_handle;
- adm_params.payload_size = cal_block->cal_data.size;
-
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- pr_debug("%s: Sending SET_PARAMS payload = 0x%pK, size = %d\n",
- __func__, &cal_block->cal_data.paddr,
- adm_params.payload_size);
- result = apr_send_pkt(this_adm.apr, (uint32_t *)&adm_params);
- if (result < 0) {
- pr_err("%s: Set params failed port 0x%x result %d\n",
- __func__, port_id, result);
- pr_debug("%s: Set params failed port = 0x%x payload = 0x%pK result %d\n",
- __func__, port_id, &cal_block->cal_data.paddr, result);
- result = -EINVAL;
- goto done;
- }
- /* Wait for the callback */
- result = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!result) {
- pr_err("%s: Set params timed out port = 0x%x\n",
- __func__, port_id);
- pr_debug("%s: Set params timed out port = 0x%x, payload = 0x%pK\n",
- __func__, port_id, &cal_block->cal_data.paddr);
- result = -EINVAL;
- goto done;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- result = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto done;
- }
+ adm_set_pp_params(port_id, copp_idx, &mem_hdr, NULL, payload_size);
done:
return result;
@@ -2255,8 +2104,7 @@
__func__, cal_index);
goto done;
}
- ret = send_adm_cal_block(port_id, copp_idx, cal_block, perf_mode,
- app_type, acdb_id, sample_rate);
+ ret = send_adm_cal_block(port_id, copp_idx, cal_block, perf_mode);
if (ret < 0)
pr_debug("%s: No cal sent for cal_index %d, port_id = 0x%x! ret %d sample_rate %d\n",
__func__, cal_index, port_id, ret, sample_rate);
@@ -2808,10 +2656,10 @@
*/
void adm_copp_mfc_cfg(int port_id, int copp_idx, int dst_sample_rate)
{
- struct audproc_mfc_output_media_fmt mfc_cfg;
+ struct audproc_mfc_param_media_fmt mfc_cfg;
struct adm_cmd_device_open_v5 open;
+ struct param_hdr_v3 param_hdr;
int port_idx;
- int sz = 0;
int rc = 0;
int i = 0;
@@ -2828,32 +2676,15 @@
goto fail_cmd;
}
- sz = sizeof(struct audproc_mfc_output_media_fmt);
+ memset(&mfc_cfg, 0, sizeof(mfc_cfg));
+ memset(&open, 0, sizeof(open));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
- mfc_cfg.params.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- mfc_cfg.params.hdr.pkt_size = sz;
- mfc_cfg.params.hdr.src_svc = APR_SVC_ADM;
- mfc_cfg.params.hdr.src_domain = APR_DOMAIN_APPS;
- mfc_cfg.params.hdr.src_port = port_id;
- mfc_cfg.params.hdr.dest_svc = APR_SVC_ADM;
- mfc_cfg.params.hdr.dest_domain = APR_DOMAIN_ADSP;
- mfc_cfg.params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- mfc_cfg.params.hdr.token = port_idx << 16 | copp_idx;
- mfc_cfg.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- mfc_cfg.params.payload_addr_lsw = 0;
- mfc_cfg.params.payload_addr_msw = 0;
- mfc_cfg.params.mem_map_handle = 0;
- mfc_cfg.params.payload_size = sizeof(mfc_cfg) -
- sizeof(mfc_cfg.params);
- mfc_cfg.data.module_id = AUDPROC_MODULE_ID_MFC;
- mfc_cfg.data.param_id =
- AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT;
- mfc_cfg.data.param_size = mfc_cfg.params.payload_size -
- sizeof(mfc_cfg.data);
- mfc_cfg.data.reserved = 0;
+ param_hdr.module_id = AUDPROC_MODULE_ID_MFC;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT;
+ param_hdr.param_size = sizeof(mfc_cfg);
+
mfc_cfg.sampling_rate = dst_sample_rate;
mfc_cfg.bits_per_sample =
atomic_read(&this_adm.copp.bit_width[port_idx][copp_idx]);
@@ -2879,31 +2710,12 @@
mfc_cfg.bits_per_sample, mfc_cfg.num_channels,
mfc_cfg.sampling_rate);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)&mfc_cfg);
+ rc = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &mfc_cfg);
+ if (rc)
+ pr_err("%s: Failed to set media format configuration data, err %d\n",
+ __func__, rc);
- if (rc < 0) {
- pr_err("%s: port_id: for[0x%x] failed %d\n",
- __func__, port_id, rc);
- goto fail_cmd;
- }
- /* Wait for the callback with copp id */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: mfc_cfg Set params timed out for port_id: for [0x%x]\n",
- __func__, port_id);
- goto fail_cmd;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- goto fail_cmd;
- }
- rc = 0;
fail_cmd:
return;
}
@@ -3727,79 +3539,25 @@
int adm_set_volume(int port_id, int copp_idx, int volume)
{
struct audproc_volume_ctrl_master_gain audproc_vol;
- int sz = 0;
+ struct param_hdr_v3 param_hdr;
int rc = 0;
- int port_idx;
pr_debug("%s: port_id %d, volume %d\n", __func__, port_id, volume);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- }
- if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
- pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
- return -EINVAL;
- }
+ memset(&audproc_vol, 0, sizeof(audproc_vol));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_VOL_CTRL;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_VOL_CTRL_MASTER_GAIN;
+ param_hdr.param_size = sizeof(audproc_vol);
- sz = sizeof(struct audproc_volume_ctrl_master_gain);
- audproc_vol.params.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- audproc_vol.params.hdr.pkt_size = sz;
- audproc_vol.params.hdr.src_svc = APR_SVC_ADM;
- audproc_vol.params.hdr.src_domain = APR_DOMAIN_APPS;
- audproc_vol.params.hdr.src_port = port_id;
- audproc_vol.params.hdr.dest_svc = APR_SVC_ADM;
- audproc_vol.params.hdr.dest_domain = APR_DOMAIN_ADSP;
- audproc_vol.params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- audproc_vol.params.hdr.token = port_idx << 16 | copp_idx;
- audproc_vol.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- audproc_vol.params.payload_addr_lsw = 0;
- audproc_vol.params.payload_addr_msw = 0;
- audproc_vol.params.mem_map_handle = 0;
- audproc_vol.params.payload_size = sizeof(audproc_vol) -
- sizeof(audproc_vol.params);
- audproc_vol.data.module_id = AUDPROC_MODULE_ID_VOL_CTRL;
- audproc_vol.data.param_id = AUDPROC_PARAM_ID_VOL_CTRL_MASTER_GAIN;
- audproc_vol.data.param_size = audproc_vol.params.payload_size -
- sizeof(audproc_vol.data);
- audproc_vol.data.reserved = 0;
audproc_vol.master_gain = volume;
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)&audproc_vol);
- if (rc < 0) {
- pr_err("%s: Set params failed port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- }
- /* Wait for the callback */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: Vol cntrl Set params timed out port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
+ rc = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &audproc_vol);
+ if (rc)
+ pr_err("%s: Failed to set volume, err %d\n", __func__, rc);
+
return rc;
}
EXPORT_SYMBOL(adm_set_volume);
@@ -3818,53 +3576,20 @@
struct audproc_softvolume_params *softvol_param)
{
struct audproc_soft_step_volume_params audproc_softvol;
- int sz = 0;
+ struct param_hdr_v3 param_hdr;
int rc = 0;
- int port_idx;
pr_debug("%s: period %d step %d curve %d\n", __func__,
softvol_param->period, softvol_param->step,
softvol_param->rampingcurve);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- }
+ memset(&audproc_softvol, 0, sizeof(audproc_softvol));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_VOL_CTRL;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS;
+ param_hdr.param_size = sizeof(audproc_softvol);
- if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
- pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
- return -EINVAL;
- }
-
- sz = sizeof(struct audproc_soft_step_volume_params);
-
- audproc_softvol.params.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- audproc_softvol.params.hdr.pkt_size = sz;
- audproc_softvol.params.hdr.src_svc = APR_SVC_ADM;
- audproc_softvol.params.hdr.src_domain = APR_DOMAIN_APPS;
- audproc_softvol.params.hdr.src_port = port_id;
- audproc_softvol.params.hdr.dest_svc = APR_SVC_ADM;
- audproc_softvol.params.hdr.dest_domain = APR_DOMAIN_ADSP;
- audproc_softvol.params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- audproc_softvol.params.hdr.token = port_idx << 16 | copp_idx;
- audproc_softvol.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- audproc_softvol.params.payload_addr_lsw = 0;
- audproc_softvol.params.payload_addr_msw = 0;
- audproc_softvol.params.mem_map_handle = 0;
- audproc_softvol.params.payload_size = sizeof(audproc_softvol) -
- sizeof(audproc_softvol.params);
- audproc_softvol.data.module_id = AUDPROC_MODULE_ID_VOL_CTRL;
- audproc_softvol.data.param_id =
- AUDPROC_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS;
- audproc_softvol.data.param_size = audproc_softvol.params.payload_size -
- sizeof(audproc_softvol.data);
- audproc_softvol.data.reserved = 0;
audproc_softvol.period = softvol_param->period;
audproc_softvol.step = softvol_param->step;
audproc_softvol.ramping_curve = softvol_param->rampingcurve;
@@ -3873,36 +3598,11 @@
audproc_softvol.period, audproc_softvol.step,
audproc_softvol.ramping_curve);
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)&audproc_softvol);
- if (rc < 0) {
- pr_err("%s: Set params failed port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- }
- /* Wait for the callback */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: Soft volume Set params timed out port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
+ rc = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &audproc_softvol);
+ if (rc)
+ pr_err("%s: Failed to set soft volume, err %d\n", __func__, rc);
+
return rc;
}
EXPORT_SYMBOL(adm_set_softvolume);
@@ -3919,79 +3619,27 @@
*/
int adm_set_mic_gain(int port_id, int copp_idx, int volume)
{
- struct adm_set_mic_gain_params mic_gain_params;
+ struct admx_mic_gain mic_gain_params;
+ struct param_hdr_v3 param_hdr;
int rc = 0;
- int sz, port_idx;
- pr_debug("%s:\n", __func__);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
- return -EINVAL;
- }
+ pr_debug("%s: Setting mic gain to %d at port_id 0x%x\n", __func__,
+ volume, port_id);
- sz = sizeof(struct adm_set_mic_gain_params);
+ memset(&mic_gain_params, 0, sizeof(mic_gain_params));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = ADM_MODULE_IDX_MIC_GAIN_CTRL;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = ADM_PARAM_IDX_MIC_GAIN;
+ param_hdr.param_size = sizeof(mic_gain_params);
- mic_gain_params.params.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- mic_gain_params.params.hdr.pkt_size = sz;
- mic_gain_params.params.hdr.src_svc = APR_SVC_ADM;
- mic_gain_params.params.hdr.src_domain = APR_DOMAIN_APPS;
- mic_gain_params.params.hdr.src_port = port_id;
- mic_gain_params.params.hdr.dest_svc = APR_SVC_ADM;
- mic_gain_params.params.hdr.dest_domain = APR_DOMAIN_ADSP;
- mic_gain_params.params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- mic_gain_params.params.hdr.token = port_idx << 16 | copp_idx;
- mic_gain_params.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- mic_gain_params.params.payload_addr_lsw = 0;
- mic_gain_params.params.payload_addr_msw = 0;
- mic_gain_params.params.mem_map_handle = 0;
- mic_gain_params.params.payload_size =
- sizeof(struct adm_param_data_v5) +
- sizeof(struct admx_mic_gain);
- mic_gain_params.data.module_id = ADM_MODULE_IDX_MIC_GAIN_CTRL;
- mic_gain_params.data.param_id = ADM_PARAM_IDX_MIC_GAIN;
- mic_gain_params.data.param_size =
- sizeof(struct admx_mic_gain);
- mic_gain_params.data.reserved = 0;
- mic_gain_params.mic_gain_data.tx_mic_gain = volume;
- mic_gain_params.mic_gain_data.reserved = 0;
- pr_debug("%s: Mic Gain set to %d at port_id 0x%x\n",
- __func__, volume, port_id);
+ mic_gain_params.tx_mic_gain = volume;
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)&mic_gain_params);
- if (rc < 0) {
- pr_err("%s: Set params failed port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- }
- /* Wait for the callback */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: Mic Gain Set params timed out port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
+ rc = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &mic_gain_params);
+ if (rc)
+ pr_err("%s: Failed to set mic gain, err %d\n", __func__, rc);
+
return rc;
}
EXPORT_SYMBOL(adm_set_mic_gain);
@@ -4009,88 +3657,29 @@
int adm_send_set_multichannel_ec_primary_mic_ch(int port_id, int copp_idx,
int primary_mic_ch)
{
- struct adm_set_sec_primary_ch_params sec_primary_ch_params;
+ struct admx_sec_primary_mic_ch sec_primary_ch_params;
+ struct param_hdr_v3 param_hdr;
int rc = 0;
- int sz, port_idx;
pr_debug("%s port_id 0x%x, copp_idx 0x%x, primary_mic_ch %d\n",
__func__, port_id, copp_idx, primary_mic_ch);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id);
- return -EINVAL;
- }
- if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
- pr_err("%s: Invalid copp_idx 0x%x\n", __func__, copp_idx);
- return -EINVAL;
- }
+ memset(&sec_primary_ch_params, 0, sizeof(sec_primary_ch_params));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_VOICE_TX_SECNS;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_IDX_SEC_PRIMARY_MIC_CH;
+ param_hdr.param_size = sizeof(sec_primary_ch_params);
- sz = sizeof(struct adm_set_sec_primary_ch_params);
+ sec_primary_ch_params.version = 0;
+ sec_primary_ch_params.sec_primary_mic_ch = primary_mic_ch;
- sec_primary_ch_params.params.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- sec_primary_ch_params.params.hdr.pkt_size = sz;
- sec_primary_ch_params.params.hdr.src_svc = APR_SVC_ADM;
- sec_primary_ch_params.params.hdr.src_domain = APR_DOMAIN_APPS;
- sec_primary_ch_params.params.hdr.src_port = port_id;
- sec_primary_ch_params.params.hdr.dest_svc = APR_SVC_ADM;
- sec_primary_ch_params.params.hdr.dest_domain = APR_DOMAIN_ADSP;
- sec_primary_ch_params.params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- sec_primary_ch_params.params.hdr.token = port_idx << 16 | copp_idx;
- sec_primary_ch_params.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- sec_primary_ch_params.params.payload_addr_lsw = 0;
- sec_primary_ch_params.params.payload_addr_msw = 0;
- sec_primary_ch_params.params.mem_map_handle = 0;
- sec_primary_ch_params.params.payload_size =
- sizeof(struct adm_param_data_v5) +
- sizeof(struct admx_sec_primary_mic_ch);
- sec_primary_ch_params.data.module_id =
- AUDPROC_MODULE_ID_VOICE_TX_SECNS;
- sec_primary_ch_params.data.param_id =
- AUDPROC_PARAM_IDX_SEC_PRIMARY_MIC_CH;
- sec_primary_ch_params.data.param_size =
- sizeof(struct admx_sec_primary_mic_ch);
- sec_primary_ch_params.data.reserved = 0;
- sec_primary_ch_params.sec_primary_mic_ch_data.version = 0;
- sec_primary_ch_params.sec_primary_mic_ch_data.reserved = 0;
- sec_primary_ch_params.sec_primary_mic_ch_data.sec_primary_mic_ch =
- primary_mic_ch;
- sec_primary_ch_params.sec_primary_mic_ch_data.reserved1 = 0;
+ rc = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &sec_primary_ch_params);
+ if (rc)
+ pr_err("%s: Failed to set primary mic chanel, err %d\n",
+ __func__, rc);
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)&sec_primary_ch_params);
- if (rc < 0) {
- pr_err("%s: Set params failed port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- }
- /* Wait for the callback */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: Mic Set params timed out port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
return rc;
}
EXPORT_SYMBOL(adm_send_set_multichannel_ec_primary_mic_ch);
@@ -4108,86 +3697,57 @@
*/
int adm_param_enable(int port_id, int copp_idx, int module_id, int enable)
{
- struct audproc_enable_param_t adm_mod_enable;
- int sz = 0;
- int rc = 0;
- int port_idx;
+ struct module_instance_info mod_inst_info;
- pr_debug("%s port_id %d, module_id 0x%x, enable %d\n",
- __func__, port_id, module_id, enable);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- }
+ memset(&mod_inst_info, 0, sizeof(mod_inst_info));
+ mod_inst_info.module_id = module_id;
+ mod_inst_info.instance_id = INSTANCE_ID_0;
- if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
- pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
+ return adm_param_enable_v2(port_id, copp_idx, mod_inst_info, enable);
+}
+
+/**
+ * adm_param_enable_v2 -
+ * command to send params to ADM for given module
+ *
+ * @port_id: Port ID number
+ * @copp_idx: copp index assigned
+ * @mod_inst_info: module and instance ID info
+ * @enable: flag to enable or disable module
+ *
+ * Returns 0 on success or error on failure
+ */
+int adm_param_enable_v2(int port_id, int copp_idx,
+ struct module_instance_info mod_inst_info, int enable)
+{
+ uint32_t enable_param;
+ struct param_hdr_v3 param_hdr;
+ int rc = 0;
+
+ if (enable < 0 || enable > 1) {
+ pr_err("%s: Invalid value for enable %d\n", __func__, enable);
return -EINVAL;
}
- sz = sizeof(struct audproc_enable_param_t);
+ pr_debug("%s port_id %d, module_id 0x%x, instance_id 0x%x, enable %d\n",
+ __func__, port_id, mod_inst_info.module_id,
+ mod_inst_info.instance_id, enable);
- adm_mod_enable.pp_params.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- adm_mod_enable.pp_params.hdr.pkt_size = sz;
- adm_mod_enable.pp_params.hdr.src_svc = APR_SVC_ADM;
- adm_mod_enable.pp_params.hdr.src_domain = APR_DOMAIN_APPS;
- adm_mod_enable.pp_params.hdr.src_port = port_id;
- adm_mod_enable.pp_params.hdr.dest_svc = APR_SVC_ADM;
- adm_mod_enable.pp_params.hdr.dest_domain = APR_DOMAIN_ADSP;
- adm_mod_enable.pp_params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- adm_mod_enable.pp_params.hdr.token = port_idx << 16 | copp_idx;
- adm_mod_enable.pp_params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- adm_mod_enable.pp_params.payload_addr_lsw = 0;
- adm_mod_enable.pp_params.payload_addr_msw = 0;
- adm_mod_enable.pp_params.mem_map_handle = 0;
- adm_mod_enable.pp_params.payload_size = sizeof(adm_mod_enable) -
- sizeof(adm_mod_enable.pp_params) +
- sizeof(adm_mod_enable.pp_params.params);
- adm_mod_enable.pp_params.params.module_id = module_id;
- adm_mod_enable.pp_params.params.param_id = AUDPROC_PARAM_ID_ENABLE;
- adm_mod_enable.pp_params.params.param_size =
- adm_mod_enable.pp_params.payload_size -
- sizeof(adm_mod_enable.pp_params.params);
- adm_mod_enable.pp_params.params.reserved = 0;
- adm_mod_enable.enable = enable;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = mod_inst_info.module_id;
+ param_hdr.instance_id = mod_inst_info.instance_id;
+ param_hdr.param_id = AUDPROC_PARAM_ID_ENABLE;
+ param_hdr.param_size = sizeof(enable_param);
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
+ enable_param = enable;
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)&adm_mod_enable);
- if (rc < 0) {
- pr_err("%s: Set params failed port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- }
- /* Wait for the callback */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: module %x enable %d timed out on port = %#x\n",
- __func__, module_id, enable, port_id);
- rc = -EINVAL;
- goto fail_cmd;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
+ rc = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &enable_param);
+ if (rc)
+ pr_err("%s: Failed to set enable of module(%d) instance(%d) to %d, err %d\n",
+ __func__, mod_inst_info.module_id,
+ mod_inst_info.instance_id, enable, rc);
+
return rc;
}
@@ -4211,26 +3771,11 @@
int cal_type, char *params, int size)
{
- struct adm_cmd_set_pp_params_v5 *adm_params = NULL;
- int sz, rc = 0;
- int port_idx;
+ int rc = 0;
pr_debug("%s:port_id %d, path %d, perf_mode %d, cal_type %d, size %d\n",
__func__, port_id, path, perf_mode, cal_type, size);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
- rc = -EINVAL;
- goto end;
- }
-
- if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
- pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
- return -EINVAL;
- }
-
/* Maps audio_dev_ctrl path definition to ACDB definition */
if (get_cal_path(path) != RX_DEVICE) {
pr_err("%s: acdb_path %d\n", __func__, path);
@@ -4238,64 +3783,9 @@
goto end;
}
- sz = sizeof(struct adm_cmd_set_pp_params_v5) + size;
- adm_params = kzalloc(sz, GFP_KERNEL);
- if (!adm_params) {
- pr_err("%s, adm params memory alloc failed", __func__);
- rc = -ENOMEM;
- goto end;
- }
-
- memcpy(((u8 *)adm_params + sizeof(struct adm_cmd_set_pp_params_v5)),
- params, size);
-
- adm_params->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- adm_params->hdr.pkt_size = sz;
- adm_params->hdr.src_svc = APR_SVC_ADM;
- adm_params->hdr.src_domain = APR_DOMAIN_APPS;
- adm_params->hdr.src_port = port_id;
- adm_params->hdr.dest_svc = APR_SVC_ADM;
- adm_params->hdr.dest_domain = APR_DOMAIN_ADSP;
- adm_params->hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- adm_params->hdr.token = port_idx << 16 | copp_idx;
- adm_params->hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- /* payload address and mmap handle initialized to zero by kzalloc */
- adm_params->payload_size = size;
-
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- rc = apr_send_pkt(this_adm.apr, (uint32_t *)adm_params);
- if (rc < 0) {
- pr_err("%s: Set params failed port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto end;
- }
- /* Wait for the callback */
- rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!rc) {
- pr_err("%s: Set params timed out port = %#x\n",
- __func__, port_id);
- rc = -EINVAL;
- goto end;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto end;
- }
- rc = 0;
+ rc = adm_set_pp_params(port_id, copp_idx, NULL, (u8 *) params, size);
end:
- kfree(adm_params);
return rc;
}
EXPORT_SYMBOL(adm_send_calibration);
@@ -4526,78 +4016,24 @@
*/
int adm_send_compressed_device_mute(int port_id, int copp_idx, bool mute_on)
{
- struct adm_set_compressed_device_mute mute_params;
+ u32 mute_param = mute_on ? 1 : 0;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int port_idx;
pr_debug("%s port_id: 0x%x, copp_idx %d, mute_on: %d\n",
__func__, port_id, copp_idx, mute_on);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
- pr_err("%s: Invalid port_id %#x copp_idx %d\n",
- __func__, port_id, copp_idx);
- ret = -EINVAL;
- goto end;
- }
- mute_params.command.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- mute_params.command.hdr.pkt_size =
- sizeof(struct adm_set_compressed_device_mute);
- mute_params.command.hdr.src_svc = APR_SVC_ADM;
- mute_params.command.hdr.src_domain = APR_DOMAIN_APPS;
- mute_params.command.hdr.src_port = port_id;
- mute_params.command.hdr.dest_svc = APR_SVC_ADM;
- mute_params.command.hdr.dest_domain = APR_DOMAIN_ADSP;
- mute_params.command.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- mute_params.command.hdr.token = port_idx << 16 | copp_idx;
- mute_params.command.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- mute_params.command.payload_addr_lsw = 0;
- mute_params.command.payload_addr_msw = 0;
- mute_params.command.mem_map_handle = 0;
- mute_params.command.payload_size = sizeof(mute_params) -
- sizeof(mute_params.command);
- mute_params.params.module_id = AUDPROC_MODULE_ID_COMPRESSED_MUTE;
- mute_params.params.param_id = AUDPROC_PARAM_ID_COMPRESSED_MUTE;
- mute_params.params.param_size = mute_params.command.payload_size -
- sizeof(mute_params.params);
- mute_params.params.reserved = 0;
- mute_params.mute_on = mute_on;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_COMPRESSED_MUTE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_COMPRESSED_MUTE;
+ param_hdr.param_size = sizeof(mute_param);
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- ret = apr_send_pkt(this_adm.apr, (uint32_t *)&mute_params);
- if (ret < 0) {
- pr_err("%s: device mute for port %d copp %d failed, ret %d\n",
- __func__, port_id, copp_idx, ret);
- ret = -EINVAL;
- goto end;
- }
+ ret = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &mute_param);
+ if (ret)
+ pr_err("%s: Failed to set mute, err %d\n", __func__, ret);
- /* Wait for the callback */
- ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: send device mute for port %d copp %d failed\n",
- __func__, port_id, copp_idx);
- ret = -EINVAL;
- goto end;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto end;
- }
- ret = 0;
-end:
return ret;
}
EXPORT_SYMBOL(adm_send_compressed_device_mute);
@@ -4614,78 +4050,31 @@
*/
int adm_send_compressed_device_latency(int port_id, int copp_idx, int latency)
{
- struct adm_set_compressed_device_latency latency_params;
- int port_idx;
+ u32 latency_param;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
pr_debug("%s port_id: 0x%x, copp_idx %d latency: %d\n", __func__,
port_id, copp_idx, latency);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
- pr_err("%s: Invalid port_id %#x copp_idx %d\n",
- __func__, port_id, copp_idx);
- ret = -EINVAL;
- goto end;
+
+ if (latency < 0) {
+ pr_err("%s: Invalid value for latency %d", __func__, latency);
+ return -EINVAL;
}
- latency_params.command.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- latency_params.command.hdr.pkt_size =
- sizeof(struct adm_set_compressed_device_latency);
- latency_params.command.hdr.src_svc = APR_SVC_ADM;
- latency_params.command.hdr.src_domain = APR_DOMAIN_APPS;
- latency_params.command.hdr.src_port = port_id;
- latency_params.command.hdr.dest_svc = APR_SVC_ADM;
- latency_params.command.hdr.dest_domain = APR_DOMAIN_ADSP;
- latency_params.command.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- latency_params.command.hdr.token = port_idx << 16 | copp_idx;
- latency_params.command.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- latency_params.command.payload_addr_lsw = 0;
- latency_params.command.payload_addr_msw = 0;
- latency_params.command.mem_map_handle = 0;
- latency_params.command.payload_size = sizeof(latency_params) -
- sizeof(latency_params.command);
- latency_params.params.module_id = AUDPROC_MODULE_ID_COMPRESSED_LATENCY;
- latency_params.params.param_id = AUDPROC_PARAM_ID_COMPRESSED_LATENCY;
- latency_params.params.param_size = latency_params.command.payload_size -
- sizeof(latency_params.params);
- latency_params.params.reserved = 0;
- latency_params.latency = latency;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AUDPROC_MODULE_ID_COMPRESSED_LATENCY;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_COMPRESSED_LATENCY;
+ param_hdr.param_size = sizeof(latency_param);
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- ret = apr_send_pkt(this_adm.apr, (uint32_t *)&latency_params);
- if (ret < 0) {
- pr_err("%s: send device latency err %d for port %d copp %d\n",
- __func__, port_id, copp_idx, ret);
- ret = -EINVAL;
- goto end;
- }
+ latency_param = latency;
- /* Wait for the callback */
- ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: send device latency for port %d failed\n", __func__,
- port_id);
- ret = -EINVAL;
- goto end;
- } else if (atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto end;
- }
- ret = 0;
-end:
+ ret = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &latency_param);
+ if (ret)
+ pr_err("%s: Failed to set latency, err %d\n", __func__, ret);
+
return ret;
}
EXPORT_SYMBOL(adm_send_compressed_device_latency);
@@ -4705,9 +4094,10 @@
int adm_swap_speaker_channels(int port_id, int copp_idx,
int sample_rate, bool spk_swap)
{
- struct audproc_mfc_output_media_fmt mfc_cfg;
+ struct audproc_mfc_param_media_fmt mfc_cfg;
+ struct param_hdr_v3 param_hdr;
uint16_t num_channels;
- int port_idx;
+ int port_idx = 0;
int ret = 0;
pr_debug("%s: Enter, port_id %d, copp_idx %d\n",
@@ -4716,50 +4106,27 @@
port_idx = adm_validate_and_get_port_index(port_id);
if (port_idx < 0 || port_idx >= AFE_MAX_PORTS) {
pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
- ret = -EINVAL;
- goto done;
+ return -EINVAL;
+ } else if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
+ pr_err("%s: Invalid copp_idx 0x%x\n", __func__, copp_idx);
+ return -EINVAL;
}
- if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
- pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
- ret = -EINVAL;
- goto done;
- }
-
- num_channels = atomic_read(
- &this_adm.copp.channels[port_idx][copp_idx]);
+ num_channels = atomic_read(&this_adm.copp.channels[port_idx][copp_idx]);
if (num_channels != 2) {
pr_debug("%s: Invalid number of channels: %d\n",
__func__, num_channels);
- ret = -EINVAL;
- goto done;
+ return -EINVAL;
}
memset(&mfc_cfg, 0, sizeof(mfc_cfg));
- mfc_cfg.params.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- mfc_cfg.params.hdr.pkt_size =
- sizeof(mfc_cfg);
- mfc_cfg.params.hdr.src_svc = APR_SVC_ADM;
- mfc_cfg.params.hdr.src_domain = APR_DOMAIN_APPS;
- mfc_cfg.params.hdr.src_port = port_id;
- mfc_cfg.params.hdr.dest_svc = APR_SVC_ADM;
- mfc_cfg.params.hdr.dest_domain = APR_DOMAIN_ADSP;
- mfc_cfg.params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- mfc_cfg.params.hdr.token = port_idx << 16 | copp_idx;
- mfc_cfg.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- mfc_cfg.params.payload_addr_lsw = 0;
- mfc_cfg.params.payload_addr_msw = 0;
- mfc_cfg.params.mem_map_handle = 0;
- mfc_cfg.params.payload_size = sizeof(mfc_cfg) -
- sizeof(mfc_cfg.params);
- mfc_cfg.data.module_id = AUDPROC_MODULE_ID_MFC;
- mfc_cfg.data.param_id = AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT;
- mfc_cfg.data.param_size = mfc_cfg.params.payload_size -
- sizeof(mfc_cfg.data);
- mfc_cfg.data.reserved = 0;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
+ param_hdr.module_id = AUDPROC_MODULE_ID_MFC;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AUDPROC_PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT;
+ param_hdr.param_size = sizeof(mfc_cfg);
+
mfc_cfg.sampling_rate = sample_rate;
mfc_cfg.bits_per_sample =
atomic_read(&this_adm.copp.bit_width[port_idx][copp_idx]);
@@ -4778,45 +4145,16 @@
(uint16_t) PCM_CHANNEL_FR;
}
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- pr_debug("%s: mfc config: port_idx %d copp_idx %d copp SR %d copp BW %d copp chan %d\n",
- __func__, port_idx, copp_idx, mfc_cfg.sampling_rate,
- mfc_cfg.bits_per_sample, mfc_cfg.num_channels);
-
- ret = apr_send_pkt(this_adm.apr, (uint32_t *)&mfc_cfg);
+ ret = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (u8 *) &mfc_cfg);
if (ret < 0) {
- pr_err("%s: port_id: for[0x%x] failed %d\n",
- __func__, port_id, ret);
- goto done;
- }
- /* Wait for the callback with copp id */
- ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: mfc_cfg Set params timed out for port_id: for [0x%x]\n",
- __func__, port_id);
- ret = -ETIMEDOUT;
- goto done;
- }
-
- if (atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx])));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [port_idx][copp_idx]));
- goto done;
+ pr_err("%s: Failed to set swap speaker channels on port[0x%x] failed %d\n",
+ __func__, port_id, ret);
+ return ret;
}
pr_debug("%s: mfc_cfg Set params returned success", __func__);
- ret = 0;
-
-done:
- return ret;
+ return 0;
}
EXPORT_SYMBOL(adm_swap_speaker_channels);
@@ -4833,108 +4171,41 @@
int adm_set_sound_focus(int port_id, int copp_idx,
struct sound_focus_param soundFocusData)
{
- struct adm_set_fluence_soundfocus_param soundfocus_params;
- int sz = 0;
+ struct adm_param_fluence_soundfocus_t soundfocus_params;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int port_idx;
int i;
pr_debug("%s: Enter, port_id %d, copp_idx %d\n",
__func__, port_id, copp_idx);
- port_id = afe_convert_virtual_to_portid(port_id);
- port_idx = adm_validate_and_get_port_index(port_id);
- if (port_idx < 0) {
- pr_err("%s: Invalid port_id %#x\n", __func__, port_id);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = VOICEPROC_MODULE_ID_GENERIC_TX;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = VOICEPROC_PARAM_ID_FLUENCE_SOUNDFOCUS;
+ param_hdr.param_size = sizeof(soundfocus_params);
- ret = -EINVAL;
- goto done;
- }
-
- if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) {
- pr_err("%s: Invalid copp_num: %d\n", __func__, copp_idx);
-
- ret = -EINVAL;
- goto done;
- }
-
- sz = sizeof(struct adm_set_fluence_soundfocus_param);
- soundfocus_params.params.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- soundfocus_params.params.hdr.pkt_size = sz;
- soundfocus_params.params.hdr.src_svc = APR_SVC_ADM;
- soundfocus_params.params.hdr.src_domain = APR_DOMAIN_APPS;
- soundfocus_params.params.hdr.src_port = port_id;
- soundfocus_params.params.hdr.dest_svc = APR_SVC_ADM;
- soundfocus_params.params.hdr.dest_domain = APR_DOMAIN_ADSP;
- soundfocus_params.params.hdr.dest_port =
- atomic_read(&this_adm.copp.id[port_idx][copp_idx]);
- soundfocus_params.params.hdr.token = port_idx << 16 |
- ADM_CLIENT_ID_SOURCE_TRACKING << 8 | copp_idx;
- soundfocus_params.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5;
- soundfocus_params.params.payload_addr_lsw = 0;
- soundfocus_params.params.payload_addr_msw = 0;
- soundfocus_params.params.mem_map_handle = 0;
- soundfocus_params.params.payload_size = sizeof(soundfocus_params) -
- sizeof(soundfocus_params.params);
- soundfocus_params.data.module_id = VOICEPROC_MODULE_ID_GENERIC_TX;
- soundfocus_params.data.param_id = VOICEPROC_PARAM_ID_FLUENCE_SOUNDFOCUS;
- soundfocus_params.data.param_size =
- soundfocus_params.params.payload_size -
- sizeof(soundfocus_params.data);
- soundfocus_params.data.reserved = 0;
-
- memset(&(soundfocus_params.soundfocus_data), 0xFF,
- sizeof(struct adm_param_fluence_soundfocus_t));
+ memset(&(soundfocus_params), 0xFF, sizeof(soundfocus_params));
for (i = 0; i < MAX_SECTORS; i++) {
- soundfocus_params.soundfocus_data.start_angles[i] =
+ soundfocus_params.start_angles[i] =
soundFocusData.start_angle[i];
- soundfocus_params.soundfocus_data.enables[i] =
- soundFocusData.enable[i];
+ soundfocus_params.enables[i] = soundFocusData.enable[i];
pr_debug("%s: start_angle[%d] = %d\n",
__func__, i, soundFocusData.start_angle[i]);
pr_debug("%s: enable[%d] = %d\n",
__func__, i, soundFocusData.enable[i]);
}
- soundfocus_params.soundfocus_data.gain_step =
- soundFocusData.gain_step;
+ soundfocus_params.gain_step = soundFocusData.gain_step;
pr_debug("%s: gain_step = %d\n", __func__, soundFocusData.gain_step);
- soundfocus_params.soundfocus_data.reserved = 0;
+ soundfocus_params.reserved = 0;
- atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1);
- ret = apr_send_pkt(this_adm.apr, (uint32_t *)&soundfocus_params);
- if (ret < 0) {
- pr_err("%s: Set params failed\n", __func__);
+ ret = adm_pack_and_set_one_pp_param(port_id, copp_idx, param_hdr,
+ (uint8_t *) &soundfocus_params);
+ if (ret)
+ pr_err("%s: Failed to set sound focus params, err %d\n",
+ __func__, ret);
- ret = -EINVAL;
- goto done;
- }
- /* Wait for the callback */
- ret = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: Set params timed out\n", __func__);
-
- ret = -EINVAL;
- goto done;
- }
-
- if (this_adm.sourceTrackingData.apr_cmd_status != 0) {
- pr_err("%s - set params returned error [%s]\n",
- __func__, adsp_err_get_err_str(
- this_adm.sourceTrackingData.apr_cmd_status));
-
- ret = adsp_err_get_lnx_err_code(
- this_adm.sourceTrackingData.apr_cmd_status);
- goto done;
- }
-
- ret = 0;
-
-done:
pr_debug("%s: Exit, ret=%d\n", __func__, ret);
return ret;
@@ -4956,28 +4227,29 @@
{
int ret = 0, i;
char *params_value;
- uint32_t param_payload_len = sizeof(struct adm_param_data_v5) +
- sizeof(struct adm_param_fluence_soundfocus_t);
- struct adm_param_fluence_soundfocus_t *soundfocus_params;
+ uint32_t max_param_size = 0;
+ struct adm_param_fluence_soundfocus_t *soundfocus_params = NULL;
+ struct param_hdr_v3 param_hdr;
pr_debug("%s: Enter, port_id %d, copp_idx %d\n",
__func__, port_id, copp_idx);
- params_value = kzalloc(param_payload_len, GFP_KERNEL);
- if (!params_value) {
- ret = -ENOMEM;
- goto done;
- }
- ret = adm_get_params_v2(port_id, copp_idx,
- VOICEPROC_MODULE_ID_GENERIC_TX,
- VOICEPROC_PARAM_ID_FLUENCE_SOUNDFOCUS,
- param_payload_len,
- params_value,
- ADM_CLIENT_ID_SOURCE_TRACKING);
+ max_param_size = sizeof(struct adm_param_fluence_soundfocus_t) +
+ sizeof(union param_hdrs);
+ params_value = kzalloc(max_param_size, GFP_KERNEL);
+ if (!params_value)
+ return -ENOMEM;
+
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = VOICEPROC_MODULE_ID_GENERIC_TX;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = VOICEPROC_PARAM_ID_FLUENCE_SOUNDFOCUS;
+ param_hdr.param_size = max_param_size;
+ ret = adm_get_pp_params(port_id, copp_idx,
+ ADM_CLIENT_ID_SOURCE_TRACKING, NULL, ¶m_hdr,
+ params_value);
if (ret) {
pr_err("%s: get parameters failed ret:%d\n", __func__, ret);
-
- kfree(params_value);
ret = -EINVAL;
goto done;
}
@@ -4986,8 +4258,6 @@
pr_err("%s - get params returned error [%s]\n",
__func__, adsp_err_get_err_str(
this_adm.sourceTrackingData.apr_cmd_status));
-
- kfree(params_value);
ret = adsp_err_get_lnx_err_code(
this_adm.sourceTrackingData.apr_cmd_status);
goto done;
@@ -5007,11 +4277,10 @@
soundFocusData->gain_step = soundfocus_params->gain_step;
pr_debug("%s: gain_step = %d\n", __func__, soundFocusData->gain_step);
- kfree(params_value);
-
done:
pr_debug("%s: Exit, ret = %d\n", __func__, ret);
+ kfree(params_value);
return ret;
}
EXPORT_SYMBOL(adm_get_sound_focus);
@@ -5083,9 +4352,12 @@
int adm_get_source_tracking(int port_id, int copp_idx,
struct source_tracking_param *sourceTrackingData)
{
- struct adm_cmd_get_pp_params_v5 admp;
- int p_idx, ret = 0, i;
- struct adm_param_fluence_sourcetracking_t *source_tracking_params;
+ struct adm_param_fluence_sourcetracking_t *source_tracking_params =
+ NULL;
+ struct mem_mapping_hdr mem_hdr;
+ struct param_hdr_v3 param_hdr;
+ int i = 0;
+ int ret = 0;
pr_debug("%s: Enter, port_id %d, copp_idx %d\n",
__func__, port_id, copp_idx);
@@ -5099,68 +4371,36 @@
}
}
- port_id = afe_convert_virtual_to_portid(port_id);
- p_idx = adm_validate_and_get_port_index(port_id);
- if (p_idx < 0) {
- pr_err("%s - invalid port index %i, port id %i, copp idx %i\n",
- __func__, p_idx, port_id, copp_idx);
-
- ret = -EINVAL;
- goto done;
- }
-
- admp.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- admp.hdr.pkt_size = sizeof(admp);
- admp.hdr.src_svc = APR_SVC_ADM;
- admp.hdr.src_domain = APR_DOMAIN_APPS;
- admp.hdr.src_port = port_id;
- admp.hdr.dest_svc = APR_SVC_ADM;
- admp.hdr.dest_domain = APR_DOMAIN_ADSP;
- admp.hdr.dest_port = atomic_read(&this_adm.copp.id[p_idx][copp_idx]);
- admp.hdr.token = p_idx << 16 | ADM_CLIENT_ID_SOURCE_TRACKING << 8 |
- copp_idx;
- admp.hdr.opcode = ADM_CMD_GET_PP_PARAMS_V5;
- admp.data_payload_addr_lsw =
+ memset(&mem_hdr, 0, sizeof(mem_hdr));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ mem_hdr.data_payload_addr_lsw =
lower_32_bits(this_adm.sourceTrackingData.memmap.paddr);
- admp.data_payload_addr_msw =
- msm_audio_populate_upper_32_bits(
- this_adm.sourceTrackingData.memmap.paddr);
- admp.mem_map_handle = atomic_read(&this_adm.mem_map_handles[
- ADM_MEM_MAP_INDEX_SOURCE_TRACKING]);
- admp.module_id = VOICEPROC_MODULE_ID_GENERIC_TX;
- admp.param_id = VOICEPROC_PARAM_ID_FLUENCE_SOURCETRACKING;
- admp.param_max_size = sizeof(struct adm_param_fluence_sourcetracking_t)
- + sizeof(struct adm_param_data_v5);
- admp.reserved = 0;
+ mem_hdr.data_payload_addr_msw = msm_audio_populate_upper_32_bits(
+ this_adm.sourceTrackingData.memmap.paddr);
+ mem_hdr.mem_map_handle = atomic_read(
+ &this_adm.mem_map_handles[ADM_MEM_MAP_INDEX_SOURCE_TRACKING]);
- atomic_set(&this_adm.copp.stat[p_idx][copp_idx], -1);
+ param_hdr.module_id = VOICEPROC_MODULE_ID_GENERIC_TX;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = VOICEPROC_PARAM_ID_FLUENCE_SOURCETRACKING;
+ /*
+ * This size should be the max size of the calibration data + header.
+ * Use the union size to ensure max size is used.
+ */
+ param_hdr.param_size =
+ sizeof(struct adm_param_fluence_sourcetracking_t) +
+ sizeof(union param_hdrs);
- ret = apr_send_pkt(this_adm.apr, (uint32_t *)&admp);
- if (ret < 0) {
- pr_err("%s - failed to get Source Tracking Params\n",
- __func__);
-
- ret = -EINVAL;
- goto done;
- }
- ret = wait_event_timeout(this_adm.copp.wait[p_idx][copp_idx],
- atomic_read(&this_adm.copp.stat[p_idx][copp_idx]) >= 0,
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s - get params timed out\n", __func__);
-
- ret = -EINVAL;
- goto done;
- } else if (atomic_read(&this_adm.copp.stat
- [p_idx][copp_idx]) > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_adm.copp.stat
- [p_idx][copp_idx])));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_adm.copp.stat
- [p_idx][copp_idx]));
+ /*
+ * Retrieving parameters out of band, so no need to provide a buffer for
+ * the returned parameter data as it will be at the memory location
+ * provided.
+ */
+ ret = adm_get_pp_params(port_id, copp_idx,
+ ADM_CLIENT_ID_SOURCE_TRACKING, &mem_hdr,
+ ¶m_hdr, NULL);
+ if (ret) {
+ pr_err("%s: Failed to get params, error %d\n", __func__, ret);
goto done;
}
@@ -5174,9 +4414,11 @@
goto done;
}
- source_tracking_params = (struct adm_param_fluence_sourcetracking_t *)
- (this_adm.sourceTrackingData.memmap.kvaddr +
- sizeof(struct adm_param_data_v5));
+ /* How do we know what the param data was retrieved with for hdr size */
+ source_tracking_params =
+ (struct adm_param_fluence_sourcetracking_t
+ *) (this_adm.sourceTrackingData.memmap.kvaddr +
+ sizeof(struct param_hdr_v1));
for (i = 0; i < MAX_SECTORS; i++) {
sourceTrackingData->vad[i] = source_tracking_params->vad[i];
pr_debug("%s: vad[%d] = %d\n",
@@ -5212,36 +4454,16 @@
{
int i = 0, j;
- this_adm.apr = NULL;
this_adm.ec_ref_rx = -1;
- this_adm.num_ec_ref_rx_chans = 0;
- this_adm.ec_ref_rx_bit_width = 0;
- this_adm.ec_ref_rx_sampling_rate = 0;
- atomic_set(&this_adm.matrix_map_stat, 0);
init_waitqueue_head(&this_adm.matrix_map_wait);
- atomic_set(&this_adm.adm_stat, 0);
init_waitqueue_head(&this_adm.adm_wait);
for (i = 0; i < AFE_MAX_PORTS; i++) {
for (j = 0; j < MAX_COPPS_PER_PORT; j++) {
atomic_set(&this_adm.copp.id[i][j], RESET_COPP_ID);
- atomic_set(&this_adm.copp.cnt[i][j], 0);
- atomic_set(&this_adm.copp.topology[i][j], 0);
- atomic_set(&this_adm.copp.mode[i][j], 0);
- atomic_set(&this_adm.copp.stat[i][j], 0);
- atomic_set(&this_adm.copp.rate[i][j], 0);
- atomic_set(&this_adm.copp.channels[i][j], 0);
- atomic_set(&this_adm.copp.bit_width[i][j], 0);
- atomic_set(&this_adm.copp.app_type[i][j], 0);
- atomic_set(&this_adm.copp.acdb_id[i][j], 0);
init_waitqueue_head(&this_adm.copp.wait[i][j]);
- atomic_set(&this_adm.copp.adm_delay_stat[i][j], 0);
init_waitqueue_head(
&this_adm.copp.adm_delay_wait[i][j]);
- atomic_set(&this_adm.copp.topology[i][j], 0);
- this_adm.copp.adm_delay[i][j] = 0;
- this_adm.copp.adm_status[i][j] =
- ADM_STATUS_CALIBRATION_REQUIRED;
}
}
@@ -5253,9 +4475,6 @@
this_adm.sourceTrackingData.memmap.kvaddr = NULL;
this_adm.sourceTrackingData.memmap.paddr = 0;
this_adm.sourceTrackingData.apr_cmd_status = -1;
- atomic_set(&this_adm.mem_map_handles[ADM_MEM_MAP_INDEX_SOURCE_TRACKING],
- 0);
- mutex_init(&dts_srs_lock);
return 0;
}
@@ -5264,6 +4483,5 @@
{
if (this_adm.apr)
adm_reset_data();
- mutex_destroy(&dts_srs_lock);
adm_delete_cal_data();
}
diff --git a/dsp/q6afe.c b/dsp/q6afe.c
index d1ef665..9a6b6ad 100644
--- a/dsp/q6afe.c
+++ b/dsp/q6afe.c
@@ -23,6 +23,7 @@
#include <dsp/audio_cal_utils.h>
#include <dsp/q6afe-v2.h>
#include <dsp/q6audio-v2.h>
+#include <dsp/q6common.h>
#include <ipc/apr_tal.h>
#include "adsp_err.h"
@@ -199,100 +200,127 @@
__func__, data->opcode, data->payload_size);
}
-static void av_dev_drift_afe_cb_handler(uint32_t *payload,
+static void av_dev_drift_afe_cb_handler(uint32_t opcode, uint32_t *payload,
uint32_t payload_size)
{
u32 param_id;
- struct afe_av_dev_drift_get_param_resp *resp =
- (struct afe_av_dev_drift_get_param_resp *) payload;
+ size_t expected_size =
+ sizeof(u32) + sizeof(struct afe_param_id_dev_timing_stats);
- if (!(&(resp->pdata))) {
- pr_err("%s: Error: resp pdata is NULL\n", __func__);
+ /* Get param ID depending on command type */
+ param_id = (opcode == AFE_PORT_CMDRSP_GET_PARAM_V3) ? payload[3] :
+ payload[2];
+ if (param_id != AFE_PARAM_ID_DEV_TIMING_STATS) {
+ pr_err("%s: Unrecognized param ID %d\n", __func__, param_id);
return;
}
- param_id = resp->pdata.param_id;
- if (param_id == AFE_PARAM_ID_DEV_TIMING_STATS) {
- if (payload_size < sizeof(this_afe.av_dev_drift_resp)) {
- pr_err("%s: Error: received size %d, resp size %zu\n",
- __func__, payload_size,
- sizeof(this_afe.av_dev_drift_resp));
+ switch (opcode) {
+ case AFE_PORT_CMDRSP_GET_PARAM_V2:
+ expected_size += sizeof(struct param_hdr_v1);
+ if (payload_size < expected_size) {
+ pr_err("%s: Error: received size %d, expected size %zu\n",
+ __func__, payload_size, expected_size);
+ return;
+ }
+ /* Repack response to add IID */
+ this_afe.av_dev_drift_resp.status = payload[0];
+ this_afe.av_dev_drift_resp.pdata.module_id = payload[1];
+ this_afe.av_dev_drift_resp.pdata.instance_id = INSTANCE_ID_0;
+ this_afe.av_dev_drift_resp.pdata.param_id = payload[2];
+ this_afe.av_dev_drift_resp.pdata.param_size = payload[3];
+ memcpy(&this_afe.av_dev_drift_resp.timing_stats, &payload[4],
+ sizeof(struct afe_param_id_dev_timing_stats));
+ break;
+ case AFE_PORT_CMDRSP_GET_PARAM_V3:
+ expected_size += sizeof(struct param_hdr_v3);
+ if (payload_size < expected_size) {
+ pr_err("%s: Error: received size %d, expected size %zu\n",
+ __func__, payload_size, expected_size);
return;
}
memcpy(&this_afe.av_dev_drift_resp, payload,
sizeof(this_afe.av_dev_drift_resp));
- if (!this_afe.av_dev_drift_resp.status) {
- atomic_set(&this_afe.state, 0);
- } else {
- pr_debug("%s: av_dev_drift_resp status: %d", __func__,
- this_afe.av_dev_drift_resp.status);
- atomic_set(&this_afe.state, -1);
- }
+ break;
+ default:
+ pr_err("%s: Unrecognized command %d\n", __func__, opcode);
+ return;
+ }
+
+ if (!this_afe.av_dev_drift_resp.status) {
+ atomic_set(&this_afe.state, 0);
+ } else {
+ pr_debug("%s: av_dev_drift_resp status: %d", __func__,
+ this_afe.av_dev_drift_resp.status);
+ atomic_set(&this_afe.state, -1);
}
}
-static int32_t sp_make_afe_callback(uint32_t *payload, uint32_t payload_size)
+static int32_t sp_make_afe_callback(uint32_t opcode, uint32_t *payload,
+ uint32_t payload_size)
{
- u32 param_id;
- struct afe_spkr_prot_calib_get_resp *resp =
- (struct afe_spkr_prot_calib_get_resp *) payload;
+ struct param_hdr_v3 param_hdr;
+ u32 *data_dest = NULL;
+ u32 *data_start = NULL;
+ size_t expected_size = sizeof(u32);
- if (!(&(resp->pdata))) {
- pr_err("%s: Error: resp pdata is NULL\n", __func__);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
+ /* Set command specific details */
+ switch (opcode) {
+ case AFE_PORT_CMDRSP_GET_PARAM_V2:
+ expected_size += sizeof(struct param_hdr_v1);
+ param_hdr.module_id = payload[1];
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = payload[2];
+ param_hdr.param_size = payload[3];
+ data_start = &payload[4];
+ break;
+ case AFE_PORT_CMDRSP_GET_PARAM_V3:
+ expected_size += sizeof(struct param_hdr_v3);
+ memcpy(¶m_hdr, &payload[1], sizeof(struct param_hdr_v3));
+ data_start = &payload[5];
+ break;
+ default:
+ pr_err("%s: Unrecognized command %d\n", __func__, opcode);
return -EINVAL;
}
- param_id = resp->pdata.param_id;
- if (param_id == AFE_PARAM_ID_CALIB_RES_CFG_V2) {
- if (payload_size < sizeof(this_afe.calib_data)) {
- pr_err("%s: Error: received size %d, calib_data size %zu\n",
- __func__, payload_size,
- sizeof(this_afe.calib_data));
- return -EINVAL;
- }
- memcpy(&this_afe.calib_data, payload,
- sizeof(this_afe.calib_data));
- if (!this_afe.calib_data.status) {
- atomic_set(&this_afe.state, 0);
- } else {
- pr_debug("%s: calib resp status: %d", __func__,
- this_afe.calib_data.status);
- atomic_set(&this_afe.state, -1);
- }
+ switch (param_hdr.param_id) {
+ case AFE_PARAM_ID_CALIB_RES_CFG_V2:
+ expected_size += sizeof(struct asm_calib_res_cfg);
+ data_dest = (u32 *) &this_afe.calib_data;
+ break;
+ case AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS:
+ expected_size += sizeof(struct afe_sp_th_vi_ftm_params);
+ data_dest = (u32 *) &this_afe.th_vi_resp;
+ break;
+ case AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS:
+ expected_size += sizeof(struct afe_sp_ex_vi_ftm_params);
+ data_dest = (u32 *) &this_afe.ex_vi_resp;
+ break;
+ default:
+ pr_err("%s: Unrecognized param ID %d\n", __func__,
+ param_hdr.param_id);
+ return -EINVAL;
}
- if (param_id == AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS) {
- if (payload_size < sizeof(this_afe.th_vi_resp)) {
- pr_err("%s: Error: received size %d, th_vi_resp size %zu\n",
- __func__, payload_size,
- sizeof(this_afe.th_vi_resp));
- return -EINVAL;
- }
- memcpy(&this_afe.th_vi_resp, payload,
- sizeof(this_afe.th_vi_resp));
- if (!this_afe.th_vi_resp.status) {
- atomic_set(&this_afe.state, 0);
- } else {
- pr_debug("%s: th vi resp status: %d", __func__,
- this_afe.th_vi_resp.status);
- atomic_set(&this_afe.state, -1);
- }
+
+ if (payload_size < expected_size) {
+ pr_err("%s: Error: received size %d, expected size %zu for param %d\n",
+ __func__, payload_size, expected_size,
+ param_hdr.param_id);
+ return -EINVAL;
}
- if (param_id == AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS) {
- if (payload_size < sizeof(this_afe.ex_vi_resp)) {
- pr_err("%s: Error: received size %d, ex_vi_resp size %zu\n",
- __func__, payload_size,
- sizeof(this_afe.ex_vi_resp));
- return -EINVAL;
- }
- memcpy(&this_afe.ex_vi_resp, payload,
- sizeof(this_afe.ex_vi_resp));
- if (!this_afe.ex_vi_resp.status) {
- atomic_set(&this_afe.state, 0);
- } else {
- pr_debug("%s: ex vi resp status: %d", __func__,
- this_afe.ex_vi_resp.status);
- atomic_set(&this_afe.state, -1);
- }
+
+ data_dest[0] = payload[0];
+ memcpy(&data_dest[1], ¶m_hdr, sizeof(struct param_hdr_v3));
+ memcpy(&data_dest[5], data_start, param_hdr.param_size);
+
+ if (!data_dest[0]) {
+ atomic_set(&this_afe.state, 0);
+ } else {
+ pr_debug("%s: status: %d", __func__, data_dest[0]);
+ atomic_set(&this_afe.state, -1);
}
return 0;
@@ -350,8 +378,10 @@
return 0;
}
afe_callback_debug_print(data);
- if (data->opcode == AFE_PORT_CMDRSP_GET_PARAM_V2) {
+ if (data->opcode == AFE_PORT_CMDRSP_GET_PARAM_V2 ||
+ data->opcode == AFE_PORT_CMDRSP_GET_PARAM_V3) {
uint32_t *payload = data->payload;
+ uint32_t param_id;
if (!payload || (data->token >= AFE_MAX_PORTS)) {
pr_err("%s: Error: size %d payload %pK token %d\n",
@@ -360,15 +390,18 @@
return -EINVAL;
}
- if (payload[2] == AFE_PARAM_ID_DEV_TIMING_STATS) {
- av_dev_drift_afe_cb_handler(data->payload,
+ param_id = (data->opcode == AFE_PORT_CMDRSP_GET_PARAM_V3) ?
+ payload[3] :
+ payload[2];
+ if (param_id == AFE_PARAM_ID_DEV_TIMING_STATS) {
+ av_dev_drift_afe_cb_handler(data->opcode, data->payload,
data->payload_size);
} else {
if (rtac_make_afe_callback(data->payload,
data->payload_size))
return 0;
- if (sp_make_afe_callback(data->payload,
+ if (sp_make_afe_callback(data->opcode, data->payload,
data->payload_size))
return -EINVAL;
}
@@ -390,8 +423,9 @@
}
switch (payload[0]) {
case AFE_PORT_CMD_SET_PARAM_V2:
+ case AFE_PORT_CMD_SET_PARAM_V3:
if (rtac_make_afe_callback(payload,
- data->payload_size))
+ data->payload_size))
return 0;
case AFE_PORT_CMD_DEVICE_STOP:
case AFE_PORT_CMD_DEVICE_START:
@@ -402,6 +436,7 @@
case AFE_SERVICE_CMD_UNREGISTER_RT_PORT_DRIVER:
case AFE_PORTS_CMD_DTMF_CTL:
case AFE_SVC_CMD_SET_PARAM:
+ case AFE_SVC_CMD_SET_PARAM_V2:
atomic_set(&this_afe.state, 0);
wake_up(&this_afe.wait[data->token]);
break;
@@ -419,6 +454,28 @@
pr_debug("%s: AFE_CMD_ADD_TOPOLOGIES cmd 0x%x\n",
__func__, payload[1]);
break;
+ case AFE_PORT_CMD_GET_PARAM_V2:
+ case AFE_PORT_CMD_GET_PARAM_V3:
+ /*
+ * Should only come here if there is an APR
+ * error or malformed APR packet. Otherwise
+ * response will be returned as
+ * AFE_PORT_CMDRSP_GET_PARAM_V2/3
+ */
+ pr_debug("%s: AFE Get Param opcode 0x%x token 0x%x src %d dest %d\n",
+ __func__, data->opcode, data->token,
+ data->src_port, data->dest_port);
+ if (payload[1] != 0) {
+ pr_err("%s: AFE Get Param failed with error %d\n",
+ __func__, payload[1]);
+ if (rtac_make_afe_callback(
+ payload,
+ data->payload_size))
+ return 0;
+ }
+ atomic_set(&this_afe.state, payload[1]);
+ wake_up(&this_afe.wait[data->token]);
+ break;
default:
pr_err("%s: Unknown cmd 0x%x\n", __func__,
payload[0]);
@@ -796,11 +853,403 @@
return ret;
}
+/* This function shouldn't be called directly. Instead call q6afe_set_params. */
+static int q6afe_set_params_v2(u16 port_id, int index,
+ struct mem_mapping_hdr *mem_hdr,
+ u8 *packed_param_data, u32 packed_data_size)
+{
+ struct afe_port_cmd_set_param_v2 *set_param = NULL;
+ uint32_t size = sizeof(struct afe_port_cmd_set_param_v2);
+ int rc = 0;
+
+ if (packed_param_data != NULL)
+ size += packed_data_size;
+ set_param = kzalloc(size, GFP_KERNEL);
+ if (set_param == NULL)
+ return -ENOMEM;
+
+ set_param->apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ set_param->apr_hdr.pkt_size = size;
+ set_param->apr_hdr.src_port = 0;
+ set_param->apr_hdr.dest_port = 0;
+ set_param->apr_hdr.token = index;
+ set_param->apr_hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
+ set_param->port_id = port_id;
+ if (packed_data_size > U16_MAX) {
+ pr_err("%s: Invalid data size for set params V2 %d\n", __func__,
+ packed_data_size);
+ rc = -EINVAL;
+ goto done;
+ }
+ set_param->payload_size = packed_data_size;
+ if (mem_hdr != NULL) {
+ set_param->mem_hdr = *mem_hdr;
+ } else if (packed_param_data != NULL) {
+ memcpy(&set_param->param_data, packed_param_data,
+ packed_data_size);
+ } else {
+ pr_err("%s: Both memory header and param data are NULL\n",
+ __func__);
+ rc = -EINVAL;
+ goto done;
+ }
+
+ rc = afe_apr_send_pkt(set_param, &this_afe.wait[index]);
+done:
+ kfree(set_param);
+ return rc;
+}
+
+/* This function shouldn't be called directly. Instead call q6afe_set_params. */
+static int q6afe_set_params_v3(u16 port_id, int index,
+ struct mem_mapping_hdr *mem_hdr,
+ u8 *packed_param_data, u32 packed_data_size)
+{
+ struct afe_port_cmd_set_param_v3 *set_param = NULL;
+ uint32_t size = sizeof(struct afe_port_cmd_set_param_v3);
+ int rc = 0;
+
+ if (packed_param_data != NULL)
+ size += packed_data_size;
+ set_param = kzalloc(size, GFP_KERNEL);
+ if (set_param == NULL)
+ return -ENOMEM;
+
+ set_param->apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ set_param->apr_hdr.pkt_size = size;
+ set_param->apr_hdr.src_port = 0;
+ set_param->apr_hdr.dest_port = 0;
+ set_param->apr_hdr.token = index;
+ set_param->apr_hdr.opcode = AFE_PORT_CMD_SET_PARAM_V3;
+ set_param->port_id = port_id;
+ set_param->payload_size = packed_data_size;
+ if (mem_hdr != NULL) {
+ set_param->mem_hdr = *mem_hdr;
+ } else if (packed_param_data != NULL) {
+ memcpy(&set_param->param_data, packed_param_data,
+ packed_data_size);
+ } else {
+ pr_err("%s: Both memory header and param data are NULL\n",
+ __func__);
+ rc = -EINVAL;
+ goto done;
+ }
+
+ rc = afe_apr_send_pkt(set_param, &this_afe.wait[index]);
+done:
+ kfree(set_param);
+ return rc;
+}
+
+static int q6afe_set_params(u16 port_id, int index,
+ struct mem_mapping_hdr *mem_hdr,
+ u8 *packed_param_data, u32 packed_data_size)
+{
+ int ret = 0;
+
+ ret = afe_q6_interface_prepare();
+ if (ret != 0) {
+ pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
+ return ret;
+ }
+
+ port_id = q6audio_get_port_id(port_id);
+ ret = q6audio_validate_port(port_id);
+ if (ret < 0) {
+ pr_err("%s: Not a valid port id = 0x%x ret %d\n", __func__,
+ port_id, ret);
+ return -EINVAL;
+ }
+
+ if (index < 0 || index >= AFE_MAX_PORTS) {
+ pr_err("%s: AFE port index[%d] invalid\n", __func__, index);
+ return -EINVAL;
+ }
+
+ if (q6common_is_instance_id_supported())
+ return q6afe_set_params_v3(port_id, index, mem_hdr,
+ packed_param_data, packed_data_size);
+ else
+ return q6afe_set_params_v2(port_id, index, mem_hdr,
+ packed_param_data, packed_data_size);
+}
+
+static int q6afe_pack_and_set_param_in_band(u16 port_id, int index,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data)
+{
+ u8 *packed_param_data = NULL;
+ int packed_data_size = sizeof(union param_hdrs) + param_hdr.param_size;
+ int ret;
+
+ packed_param_data = kzalloc(packed_data_size, GFP_KERNEL);
+ if (packed_param_data == NULL)
+ return -ENOMEM;
+
+ ret = q6common_pack_pp_params(packed_param_data, ¶m_hdr, param_data,
+ &packed_data_size);
+ if (ret) {
+ pr_err("%s: Failed to pack param header and data, error %d\n",
+ __func__, ret);
+ goto fail_cmd;
+ }
+
+ ret = q6afe_set_params(port_id, index, NULL, packed_param_data,
+ packed_data_size);
+
+fail_cmd:
+ kfree(packed_param_data);
+ return ret;
+}
+
+/* This function shouldn't be called directly. Instead call q6afe_get_param. */
+static int q6afe_get_params_v2(u16 port_id, int index,
+ struct mem_mapping_hdr *mem_hdr,
+ struct param_hdr_v3 *param_hdr)
+{
+ struct afe_port_cmd_get_param_v2 afe_get_param;
+ u32 param_size = param_hdr->param_size;
+
+ memset(&afe_get_param, 0, sizeof(afe_get_param));
+ afe_get_param.apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ afe_get_param.apr_hdr.pkt_size = sizeof(afe_get_param) + param_size;
+ afe_get_param.apr_hdr.src_port = 0;
+ afe_get_param.apr_hdr.dest_port = 0;
+ afe_get_param.apr_hdr.token = index;
+ afe_get_param.apr_hdr.opcode = AFE_PORT_CMD_GET_PARAM_V2;
+ afe_get_param.port_id = port_id;
+ afe_get_param.payload_size = sizeof(struct param_hdr_v1) + param_size;
+ if (mem_hdr != NULL)
+ afe_get_param.mem_hdr = *mem_hdr;
+ /* Set MID and PID in command */
+ afe_get_param.module_id = param_hdr->module_id;
+ afe_get_param.param_id = param_hdr->param_id;
+ /* Set param header in payload */
+ afe_get_param.param_hdr.module_id = param_hdr->module_id;
+ afe_get_param.param_hdr.param_id = param_hdr->param_id;
+ afe_get_param.param_hdr.param_size = param_size;
+
+ return afe_apr_send_pkt(&afe_get_param, &this_afe.wait[index]);
+}
+
+/* This function shouldn't be called directly. Instead call q6afe_get_param. */
+static int q6afe_get_params_v3(u16 port_id, int index,
+ struct mem_mapping_hdr *mem_hdr,
+ struct param_hdr_v3 *param_hdr)
+{
+ struct afe_port_cmd_get_param_v3 afe_get_param;
+
+ memset(&afe_get_param, 0, sizeof(afe_get_param));
+ afe_get_param.apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ afe_get_param.apr_hdr.pkt_size = sizeof(afe_get_param);
+ afe_get_param.apr_hdr.src_port = 0;
+ afe_get_param.apr_hdr.dest_port = 0;
+ afe_get_param.apr_hdr.token = index;
+ afe_get_param.apr_hdr.opcode = AFE_PORT_CMD_GET_PARAM_V3;
+ afe_get_param.port_id = port_id;
+ if (mem_hdr != NULL)
+ afe_get_param.mem_hdr = *mem_hdr;
+ /* Set param header in command, no payload in V3 */
+ afe_get_param.param_hdr = *param_hdr;
+
+ return afe_apr_send_pkt(&afe_get_param, &this_afe.wait[index]);
+}
+
+/*
+ * Calling functions copy param data directly from this_afe. Do not copy data
+ * back to caller here.
+ */
+static int q6afe_get_params(u16 port_id, struct mem_mapping_hdr *mem_hdr,
+ struct param_hdr_v3 *param_hdr)
+{
+ int index;
+ int ret;
+
+ ret = afe_q6_interface_prepare();
+ if (ret != 0) {
+ pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
+ return ret;
+ }
+
+ port_id = q6audio_get_port_id(port_id);
+ ret = q6audio_validate_port(port_id);
+ if (ret < 0) {
+ pr_err("%s: Not a valid port id = 0x%x ret %d\n", __func__,
+ port_id, ret);
+ return -EINVAL;
+ }
+
+ index = q6audio_get_port_index(port_id);
+ if (index < 0 || index >= AFE_MAX_PORTS) {
+ pr_err("%s: AFE port index[%d] invalid\n", __func__, index);
+ return -EINVAL;
+ }
+
+ if (q6common_is_instance_id_supported())
+ return q6afe_get_params_v3(port_id, index, NULL, param_hdr);
+ else
+ return q6afe_get_params_v2(port_id, index, NULL, param_hdr);
+}
+
+/*
+ * This function shouldn't be called directly. Instead call
+ * q6afe_svc_set_params.
+ */
+static int q6afe_svc_set_params_v1(int index, struct mem_mapping_hdr *mem_hdr,
+ u8 *packed_param_data, u32 packed_data_size)
+{
+ struct afe_svc_cmd_set_param_v1 *svc_set_param = NULL;
+ uint32_t size = sizeof(struct afe_svc_cmd_set_param_v1);
+ int rc = 0;
+
+ if (packed_param_data != NULL)
+ size += packed_data_size;
+ svc_set_param = kzalloc(size, GFP_KERNEL);
+ if (svc_set_param == NULL)
+ return -ENOMEM;
+
+ svc_set_param->apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ svc_set_param->apr_hdr.pkt_size = size;
+ svc_set_param->apr_hdr.src_port = 0;
+ svc_set_param->apr_hdr.dest_port = 0;
+ svc_set_param->apr_hdr.token = IDX_GLOBAL_CFG;
+ svc_set_param->apr_hdr.opcode = AFE_SVC_CMD_SET_PARAM;
+ svc_set_param->payload_size = packed_data_size;
+
+ if (mem_hdr != NULL) {
+ /* Out of band case. */
+ svc_set_param->mem_hdr = *mem_hdr;
+ } else if (packed_param_data != NULL) {
+ /* In band case. */
+ memcpy(&svc_set_param->param_data, packed_param_data,
+ packed_data_size);
+ } else {
+ pr_err("%s: Both memory header and param data are NULL\n",
+ __func__);
+ rc = -EINVAL;
+ goto done;
+ }
+
+ rc = afe_apr_send_pkt(svc_set_param, &this_afe.wait[index]);
+done:
+ kfree(svc_set_param);
+ return rc;
+}
+
+/*
+ * This function shouldn't be called directly. Instead call
+ * q6afe_svc_set_params.
+ */
+static int q6afe_svc_set_params_v2(int index, struct mem_mapping_hdr *mem_hdr,
+ u8 *packed_param_data, u32 packed_data_size)
+{
+ struct afe_svc_cmd_set_param_v2 *svc_set_param = NULL;
+ uint16_t size = sizeof(struct afe_svc_cmd_set_param_v2);
+ int rc = 0;
+
+ if (packed_param_data != NULL)
+ size += packed_data_size;
+ svc_set_param = kzalloc(size, GFP_KERNEL);
+ if (svc_set_param == NULL)
+ return -ENOMEM;
+
+ svc_set_param->apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ svc_set_param->apr_hdr.pkt_size = size;
+ svc_set_param->apr_hdr.src_port = 0;
+ svc_set_param->apr_hdr.dest_port = 0;
+ svc_set_param->apr_hdr.token = IDX_GLOBAL_CFG;
+ svc_set_param->apr_hdr.opcode = AFE_SVC_CMD_SET_PARAM_V2;
+ svc_set_param->payload_size = packed_data_size;
+
+ if (mem_hdr != NULL) {
+ /* Out of band case. */
+ svc_set_param->mem_hdr = *mem_hdr;
+ } else if (packed_param_data != NULL) {
+ /* In band case. */
+ memcpy(&svc_set_param->param_data, packed_param_data,
+ packed_data_size);
+ } else {
+ pr_err("%s: Both memory header and param data are NULL\n",
+ __func__);
+ rc = -EINVAL;
+ goto done;
+ }
+
+ rc = afe_apr_send_pkt(svc_set_param, &this_afe.wait[index]);
+done:
+ kfree(svc_set_param);
+ return rc;
+}
+
+static int q6afe_svc_set_params(int index, struct mem_mapping_hdr *mem_hdr,
+ u8 *packed_param_data, u32 packed_data_size)
+{
+ int ret;
+
+ ret = afe_q6_interface_prepare();
+ if (ret != 0) {
+ pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
+ return ret;
+ }
+
+ if (q6common_is_instance_id_supported())
+ return q6afe_svc_set_params_v2(index, mem_hdr,
+ packed_param_data,
+ packed_data_size);
+ else
+ return q6afe_svc_set_params_v1(index, mem_hdr,
+ packed_param_data,
+ packed_data_size);
+}
+
+static int q6afe_svc_pack_and_set_param_in_band(int index,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data)
+{
+ u8 *packed_param_data = NULL;
+ u32 packed_data_size =
+ sizeof(struct param_hdr_v3) + param_hdr.param_size;
+ int ret = 0;
+
+ packed_param_data = kzalloc(packed_data_size, GFP_KERNEL);
+ if (!packed_param_data)
+ return -ENOMEM;
+
+ ret = q6common_pack_pp_params(packed_param_data, ¶m_hdr, param_data,
+ &packed_data_size);
+ if (ret) {
+ pr_err("%s: Failed to pack parameter header and data, error %d\n",
+ __func__, ret);
+ goto done;
+ }
+
+ ret = q6afe_svc_set_params(index, NULL, packed_param_data,
+ packed_data_size);
+
+done:
+ kfree(packed_param_data);
+ return ret;
+}
+
static int afe_send_cal_block(u16 port_id, struct cal_block_data *cal_block)
{
- int result = 0;
- int index = 0;
- struct afe_audioif_config_command_no_payload afe_cal;
+ struct mem_mapping_hdr mem_hdr;
+ int payload_size = 0;
+ int result = 0;
+
+ memset(&mem_hdr, 0, sizeof(mem_hdr));
if (!cal_block) {
pr_debug("%s: No AFE cal to send!\n", __func__);
@@ -813,34 +1262,19 @@
goto done;
}
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- result = -EINVAL;
- goto done;
- }
-
- afe_cal.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- afe_cal.hdr.pkt_size = sizeof(afe_cal);
- afe_cal.hdr.src_port = 0;
- afe_cal.hdr.dest_port = 0;
- afe_cal.hdr.token = index;
- afe_cal.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- afe_cal.param.port_id = port_id;
- afe_cal.param.payload_size = cal_block->cal_data.size;
- afe_cal.param.payload_address_lsw =
+ payload_size = cal_block->cal_data.size;
+ mem_hdr.data_payload_addr_lsw =
lower_32_bits(cal_block->cal_data.paddr);
- afe_cal.param.payload_address_msw =
+ mem_hdr.data_payload_addr_msw =
msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
- afe_cal.param.mem_map_handle = cal_block->map_data.q6map_handle;
+ mem_hdr.mem_map_handle = cal_block->map_data.q6map_handle;
pr_debug("%s: AFE cal sent for device port = 0x%x, cal size = %zd, cal addr = 0x%pK\n",
__func__, port_id,
cal_block->cal_data.size, &cal_block->cal_data.paddr);
- result = afe_apr_send_pkt(&afe_cal, &this_afe.wait[index]);
+ result = q6afe_set_params(port_id, q6audio_get_port_index(port_id),
+ &mem_hdr, NULL, payload_size);
if (result)
pr_err("%s: AFE cal for port 0x%x failed %d\n",
__func__, port_id, result);
@@ -936,9 +1370,10 @@
static int afe_spk_ramp_dn_cfg(int port)
{
+ struct param_hdr_v3 param_info;
int ret = -EINVAL;
- int index = 0;
- struct afe_spkr_prot_config_command config;
+
+ memset(¶m_info, 0, sizeof(param_info));
if (afe_get_port_type(port) != MSM_AFE_PORT_TYPE_RX) {
pr_debug("%s: port doesn't match 0x%x\n", __func__, port);
@@ -950,84 +1385,41 @@
__func__, port, ret, this_afe.vi_rx_port);
return 0;
}
- memset(&config, 0, sizeof(config));
- ret = q6audio_validate_port(port);
- if (ret < 0) {
- pr_err("%s: Invalid port 0x%x ret %d", __func__, port, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
- index = q6audio_get_port_index(port);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- ret = -EINVAL;
- goto fail_cmd;
- }
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
+ param_info.module_id = AFE_MODULE_FB_SPKR_PROT_V2_RX;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = AFE_PARAM_ID_FBSP_PTONE_RAMP_CFG;
+ param_info.param_size = 0;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port);
- config.param.payload_size =
- sizeof(config) - sizeof(config.hdr) - sizeof(config.param)
- - sizeof(config.prot_config);
- config.pdata.module_id = AFE_MODULE_FB_SPKR_PROT_V2_RX;
- config.pdata.param_id = AFE_PARAM_ID_FBSP_PTONE_RAMP_CFG;
- config.pdata.param_size = 0;
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config);
- if (ret < 0) {
- pr_err("%s: port = 0x%x param = 0x%x failed %d\n",
- __func__, port, config.pdata.param_id, ret);
+ ret = q6afe_pack_and_set_param_in_band(port,
+ q6audio_get_port_index(port),
+ param_info, NULL);
+ if (ret) {
+ pr_err("%s: Failed to set speaker ramp duration param, err %d\n",
+ __func__, ret);
goto fail_cmd;
}
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
+
/* dsp needs atleast 15ms to ramp down pilot tone*/
usleep_range(15000, 15010);
ret = 0;
fail_cmd:
- pr_debug("%s: config.pdata.param_id 0x%x status %d\n",
- __func__, config.pdata.param_id, ret);
-return ret;
+ pr_debug("%s: config.pdata.param_id 0x%x status %d\n", __func__,
+ param_info.param_id, ret);
+ return ret;
}
static int afe_spk_prot_prepare(int src_port, int dst_port, int param_id,
- union afe_spkr_prot_config *prot_config)
+ union afe_spkr_prot_config *prot_config)
{
+ struct param_hdr_v3 param_info;
int ret = -EINVAL;
- int index = 0;
- struct afe_spkr_prot_config_command config;
- memset(&config, 0, sizeof(config));
- if (!prot_config) {
- pr_err("%s: Invalid params\n", __func__);
- goto fail_cmd;
- }
+ memset(¶m_info, 0, sizeof(param_info));
+
ret = q6audio_validate_port(src_port);
if (ret < 0) {
- pr_err("%s: Invalid src port 0x%x ret %d",
- __func__, src_port, ret);
+ pr_err("%s: Invalid src port 0x%x ret %d", __func__, src_port,
+ ret);
ret = -EINVAL;
goto fail_cmd;
}
@@ -1038,22 +1430,16 @@
ret = -EINVAL;
goto fail_cmd;
}
- index = q6audio_get_port_index(src_port);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- ret = -EINVAL;
- goto fail_cmd;
- }
+
switch (param_id) {
case AFE_PARAM_ID_FBSP_MODE_RX_CFG:
case AFE_PARAM_ID_SP_RX_LIMITER_TH:
- config.pdata.module_id = AFE_MODULE_FB_SPKR_PROT_V2_RX;
+ param_info.module_id = AFE_MODULE_FB_SPKR_PROT_V2_RX;
break;
case AFE_PARAM_ID_FEEDBACK_PATH_CFG:
this_afe.vi_tx_port = src_port;
this_afe.vi_rx_port = dst_port;
- config.pdata.module_id = AFE_MODULE_FEEDBACK;
+ param_info.module_id = AFE_MODULE_FEEDBACK;
break;
/*
* AFE_PARAM_ID_SPKR_CALIB_VI_PROC_CFG_V2 is same as
@@ -1061,59 +1447,31 @@
*/
case AFE_PARAM_ID_SPKR_CALIB_VI_PROC_CFG_V2:
case AFE_PARAM_ID_SP_V2_TH_VI_FTM_CFG:
- config.pdata.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI;
+ param_info.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI;
break;
case AFE_PARAM_ID_SP_V2_EX_VI_MODE_CFG:
case AFE_PARAM_ID_SP_V2_EX_VI_FTM_CFG:
- config.pdata.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI;
+ param_info.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI;
break;
default:
pr_err("%s: default case 0x%x\n", __func__, param_id);
goto fail_cmd;
}
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = param_id;
+ param_info.param_size = sizeof(union afe_spkr_prot_config);
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(src_port);
- config.param.payload_size = sizeof(config) - sizeof(config.hdr)
- - sizeof(config.param);
- config.pdata.param_id = param_id;
- config.pdata.param_size = sizeof(config.prot_config);
- config.prot_config = *prot_config;
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config);
- if (ret < 0) {
- pr_err("%s: port = 0x%x param = 0x%x failed %d\n",
- __func__, src_port, param_id, ret);
- goto fail_cmd;
- }
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
- ret = 0;
+ ret = q6afe_pack_and_set_param_in_band(src_port,
+ q6audio_get_port_index(src_port),
+ param_info, (u8 *) prot_config);
+ if (ret)
+ pr_err("%s: port = 0x%x param = 0x%x failed %d\n", __func__,
+ src_port, param_id, ret);
+
fail_cmd:
- pr_debug("%s: config.pdata.param_id 0x%x status %d 0x%x\n",
- __func__, config.pdata.param_id, ret, src_port);
+ pr_debug("%s: config.pdata.param_id 0x%x status %d 0x%x\n", __func__,
+ param_info.param_id, ret, src_port);
return ret;
}
@@ -1286,14 +1644,16 @@
static int afe_send_hw_delay(u16 port_id, u32 rate)
{
- struct audio_cal_hw_delay_entry delay_entry;
- struct afe_audioif_config_command config;
- int index = 0;
+ struct audio_cal_hw_delay_entry delay_entry;
+ struct afe_param_id_device_hw_delay_cfg hw_delay;
+ struct param_hdr_v3 param_info;
int ret = -EINVAL;
pr_debug("%s:\n", __func__);
memset(&delay_entry, 0, sizeof(delay_entry));
+ memset(¶m_info, 0, sizeof(param_info));
+
delay_entry.sample_rate = rate;
if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX)
ret = afe_get_cal_hw_delay(TX_DEVICE, &delay_entry);
@@ -1311,42 +1671,21 @@
goto fail_cmd;
}
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- ret = -EINVAL;
- goto fail_cmd;
- }
+ param_info.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = AFE_PARAM_ID_DEVICE_HW_DELAY;
+ param_info.param_size = sizeof(hw_delay);
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
+ hw_delay.delay_in_us = delay_entry.delay_usec;
+ hw_delay.device_hw_delay_minor_version =
+ AFE_API_VERSION_DEVICE_HW_DELAY;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- config.pdata.param_id = AFE_PARAM_ID_DEVICE_HW_DELAY;
- config.pdata.param_size = sizeof(config.port);
-
- config.port.hw_delay.delay_in_us = delay_entry.delay_usec;
- config.port.hw_delay.device_hw_delay_minor_version =
- AFE_API_VERSION_DEVICE_HW_DELAY;
-
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
- if (ret) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_info, (u8 *) &hw_delay);
+ if (ret)
pr_err("%s: AFE hw delay for port 0x%x failed %d\n",
__func__, port_id, ret);
- goto fail_cmd;
- }
fail_cmd:
pr_debug("%s: port_id 0x%x rate %u delay_usec %d status %d\n",
@@ -1446,11 +1785,14 @@
static int afe_send_port_topology_id(u16 port_id)
{
- struct afe_audioif_config_command config;
+ struct afe_param_id_set_topology_cfg topology;
+ struct param_hdr_v3 param_info;
+ u32 topology_id = 0;
int index = 0;
int ret = 0;
- u32 topology_id = 0;
+ memset(&topology, 0, sizeof(topology));
+ memset(¶m_info, 0, sizeof(param_info));
index = q6audio_get_port_index(port_id);
if (index < 0 || index >= AFE_MAX_PORTS) {
pr_err("%s: AFE port index[%d] invalid!\n",
@@ -1470,32 +1812,17 @@
goto done;
}
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
+ param_info.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = AFE_PARAM_ID_SET_TOPOLOGY;
+ param_info.param_size = sizeof(topology);
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- config.pdata.param_id = AFE_PARAM_ID_SET_TOPOLOGY;
- config.pdata.param_size = sizeof(config.port);
- config.port.topology.minor_version = AFE_API_VERSION_TOPOLOGY_V1;
- config.port.topology.topology_id = topology_id;
+ topology.minor_version = AFE_API_VERSION_TOPOLOGY_V1;
+ topology.topology_id = topology_id;
- pr_debug("%s: param PL size=%d iparam_size[%d][%zd %zd %zd %zd] param_id[0x%x]\n",
- __func__, config.param.payload_size, config.pdata.param_size,
- sizeof(config), sizeof(config.param), sizeof(config.port),
- sizeof(struct apr_hdr), config.pdata.param_id);
-
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_info, (u8 *) &topology);
if (ret) {
pr_err("%s: AFE set topology id enable for port 0x%x failed %d\n",
__func__, port_id, ret);
@@ -1657,33 +1984,26 @@
int afe_turn_onoff_hw_mad(u16 mad_type, u16 enable)
{
+ struct afe_param_hw_mad_ctrl mad_enable_param;
+ struct param_hdr_v3 param_info;
int ret;
- struct afe_cmd_hw_mad_ctrl config;
pr_debug("%s: enter\n", __func__);
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = IDX_GLOBAL_CFG;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = SLIMBUS_5_TX;
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_HW_MAD;
- config.pdata.param_id = AFE_PARAM_ID_HW_MAD_CTRL;
- config.pdata.param_size = sizeof(config.payload);
- config.payload.minor_version = 1;
- config.payload.mad_type = mad_type;
- config.payload.mad_enable = enable;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
+ memset(&mad_enable_param, 0, sizeof(mad_enable_param));
+ memset(¶m_info, 0, sizeof(param_info));
+ param_info.module_id = AFE_MODULE_HW_MAD;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = AFE_PARAM_ID_HW_MAD_CTRL;
+ param_info.param_size = sizeof(mad_enable_param);
+
+ mad_enable_param.minor_version = 1;
+ mad_enable_param.mad_type = mad_type;
+ mad_enable_param.mad_enable = enable;
+
+ ret = q6afe_pack_and_set_param_in_band(SLIMBUS_5_TX, IDX_GLOBAL_CFG,
+ param_info,
+ (u8 *) &mad_enable_param);
if (ret)
pr_err("%s: AFE_PARAM_ID_HW_MAD_CTRL failed %d\n", __func__,
ret);
@@ -1693,31 +2013,19 @@
static int afe_send_slimbus_slave_cfg(
struct afe_param_cdc_slimbus_slave_cfg *sb_slave_cfg)
{
+ struct param_hdr_v3 param_hdr;
int ret;
- struct afe_svc_cmd_sb_slave_cfg config;
pr_debug("%s: enter\n", __func__);
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = IDX_GLOBAL_CFG;
- config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_CDC_DEV_CFG;
- config.pdata.param_id = AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG;
- config.pdata.param_size =
- sizeof(struct afe_param_cdc_slimbus_slave_cfg);
- config.sb_slave_cfg = *sb_slave_cfg;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_CDC_DEV_CFG;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG;
+ param_hdr.param_size = sizeof(struct afe_param_cdc_slimbus_slave_cfg);
- ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
+ ret = q6afe_svc_pack_and_set_param_in_band(IDX_GLOBAL_CFG, param_hdr,
+ (u8 *) sb_slave_cfg);
if (ret)
pr_err("%s: AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG failed %d\n",
__func__, ret);
@@ -1729,29 +2037,17 @@
static int afe_send_codec_reg_page_config(
struct afe_param_cdc_reg_page_cfg *cdc_reg_page_cfg)
{
- struct afe_svc_cmd_cdc_reg_page_cfg config;
+ struct param_hdr_v3 param_hdr;
int ret;
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = IDX_GLOBAL_CFG;
- config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_CDC_DEV_CFG;
- config.pdata.param_id = AFE_PARAM_ID_CDC_REG_PAGE_CFG;
- config.pdata.param_size =
- sizeof(struct afe_param_cdc_reg_page_cfg);
- config.cdc_reg_page_cfg = *cdc_reg_page_cfg;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_CDC_DEV_CFG;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CDC_REG_PAGE_CFG;
+ param_hdr.param_size = sizeof(struct afe_param_cdc_reg_page_cfg);
- ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
+ ret = q6afe_svc_pack_and_set_param_in_band(IDX_GLOBAL_CFG, param_hdr,
+ (u8 *) cdc_reg_page_cfg);
if (ret)
pr_err("%s: AFE_PARAM_ID_CDC_REG_PAGE_CFG failed %d\n",
__func__, ret);
@@ -1762,186 +2058,123 @@
static int afe_send_codec_reg_config(
struct afe_param_cdc_reg_cfg_data *cdc_reg_cfg)
{
- int i, j, ret = -EINVAL;
- int pkt_size, payload_size, reg_per_pkt, num_pkts, num_regs;
- struct afe_svc_cmd_cdc_reg_cfg *config;
- struct afe_svc_cmd_set_param *param;
+ u8 *packed_param_data = NULL;
+ u32 packed_data_size = 0;
+ u32 single_param_size = 0;
+ u32 max_data_size = 0;
+ u32 max_single_param = 0;
+ struct param_hdr_v3 param_hdr;
+ int idx = 0;
+ int ret = -EINVAL;
- reg_per_pkt = (APR_MAX_BUF - sizeof(*config)) /
- sizeof(struct afe_param_cdc_reg_cfg_payload);
- if (reg_per_pkt > 0) {
- num_pkts = (cdc_reg_cfg->num_registers / reg_per_pkt) +
- (cdc_reg_cfg->num_registers % reg_per_pkt == 0 ? 0 : 1);
- } else {
- pr_err("%s: Failed to build codec reg config APR packet\n",
- __func__);
- return -EINVAL;
- }
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ max_single_param = sizeof(struct param_hdr_v3) +
+ sizeof(struct afe_param_cdc_reg_cfg);
+ max_data_size = APR_MAX_BUF - sizeof(struct afe_svc_cmd_set_param_v2);
+ packed_param_data = kzalloc(max_data_size, GFP_KERNEL);
+ if (!packed_param_data)
+ return -ENOMEM;
- for (j = 0; j < num_pkts; ++j) {
- /*
- * num_regs is set to reg_per_pkt on each pass through the loop
- * except the last, when it is set to the number of registers
- * remaining from the total
- */
- num_regs = (j < (num_pkts - 1) ? reg_per_pkt :
- cdc_reg_cfg->num_registers - (reg_per_pkt * j));
- payload_size = sizeof(struct afe_param_cdc_reg_cfg_payload) *
- num_regs;
- pkt_size = sizeof(*config) + payload_size;
- pr_debug("%s: pkt_size %d, payload_size %d\n", __func__,
- pkt_size, payload_size);
- config = kzalloc(pkt_size, GFP_KERNEL);
- if (!config)
- return -ENOMEM;
+ /* param_hdr is the same for all params sent, set once at top */
+ param_hdr.module_id = AFE_MODULE_CDC_DEV_CFG;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CDC_REG_CFG;
+ param_hdr.param_size = sizeof(struct afe_param_cdc_reg_cfg);
- config->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- config->hdr.pkt_size = pkt_size;
- config->hdr.src_port = 0;
- config->hdr.dest_port = 0;
- config->hdr.token = IDX_GLOBAL_CFG;
- config->hdr.opcode = AFE_SVC_CMD_SET_PARAM;
+ while (idx < cdc_reg_cfg->num_registers) {
+ memset(packed_param_data, 0, max_data_size);
+ packed_data_size = 0;
+ single_param_size = 0;
- param = &config->param;
- param->payload_size = payload_size;
- param->payload_address_lsw = 0x00;
- param->payload_address_msw = 0x00;
- param->mem_map_handle = 0x00;
-
- for (i = 0; i < num_regs; i++) {
- config->reg_data[i].common.module_id =
- AFE_MODULE_CDC_DEV_CFG;
- config->reg_data[i].common.param_id =
- AFE_PARAM_ID_CDC_REG_CFG;
- config->reg_data[i].common.param_size =
- sizeof(config->reg_data[i].reg_cfg);
- config->reg_data[i].reg_cfg =
- cdc_reg_cfg->reg_data[i + (j * reg_per_pkt)];
+ while (packed_data_size + max_single_param < max_data_size &&
+ idx < cdc_reg_cfg->num_registers) {
+ ret = q6common_pack_pp_params(
+ packed_param_data + packed_data_size,
+ ¶m_hdr, (u8 *) &cdc_reg_cfg->reg_data[idx],
+ &single_param_size);
+ if (ret) {
+ pr_err("%s: Failed to pack parameters with error %d\n",
+ __func__, ret);
+ goto done;
+ }
+ packed_data_size += single_param_size;
+ idx++;
}
- ret = afe_apr_send_pkt(config, &this_afe.wait[IDX_GLOBAL_CFG]);
+ ret = q6afe_svc_set_params(IDX_GLOBAL_CFG, NULL,
+ packed_param_data, packed_data_size);
if (ret) {
pr_err("%s: AFE_PARAM_ID_CDC_REG_CFG failed %d\n",
__func__, ret);
- kfree(config);
break;
}
- kfree(config);
}
-
+done:
+ kfree(packed_param_data);
return ret;
}
static int afe_init_cdc_reg_config(void)
{
+ struct param_hdr_v3 param_hdr;
int ret;
- struct afe_svc_cmd_init_cdc_reg_cfg config;
pr_debug("%s: enter\n", __func__);
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = IDX_GLOBAL_CFG;
- config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_CDC_DEV_CFG;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CDC_REG_CFG_INIT;
- config.param.payload_size = sizeof(struct afe_port_param_data_v2);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
-
- config.init.module_id = AFE_MODULE_CDC_DEV_CFG;
- config.init.param_id = AFE_PARAM_ID_CDC_REG_CFG_INIT;
- config.init.param_size = 0;
-
- ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
- if (ret) {
+ ret = q6afe_svc_pack_and_set_param_in_band(IDX_GLOBAL_CFG, param_hdr,
+ NULL);
+ if (ret)
pr_err("%s: AFE_PARAM_ID_CDC_INIT_REG_CFG failed %d\n",
__func__, ret);
- }
return ret;
}
static int afe_send_slimbus_slave_port_cfg(
- struct afe_param_slimbus_slave_port_cfg *port_config, u16 port_id)
+ struct afe_param_slimbus_slave_port_cfg *slim_slave_config, u16 port_id)
{
- int ret, index;
- struct afe_cmd_hw_mad_slimbus_slave_port_cfg config;
+ struct param_hdr_v3 param_hdr;
+ int ret;
pr_debug("%s: enter, port_id = 0x%x\n", __func__, port_id);
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(port_id);
- if (ret < 0) {
- pr_err("%s: port id = 0x%x ret %d\n", __func__, port_id, ret);
- return -EINVAL;
- }
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_HW_MAD;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.reserved = 0;
+ param_hdr.param_id = AFE_PARAM_ID_SLIMBUS_SLAVE_PORT_CFG;
+ param_hdr.param_size = sizeof(struct afe_param_slimbus_slave_port_cfg);
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = port_id;
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_HW_MAD;
- config.pdata.param_id = AFE_PARAM_ID_SLIMBUS_SLAVE_PORT_CFG;
- config.pdata.param_size = sizeof(*port_config);
- config.sb_port_cfg = *port_config;
-
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
- if (ret) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr,
+ (u8 *) slim_slave_config);
+ if (ret)
pr_err("%s: AFE_PARAM_ID_SLIMBUS_SLAVE_PORT_CFG failed %d\n",
__func__, ret);
- }
+
pr_debug("%s: leave %d\n", __func__, ret);
return ret;
}
static int afe_aanc_port_cfg(void *apr, uint16_t tx_port, uint16_t rx_port)
{
- struct afe_port_cmd_set_aanc_param cfg;
+ struct afe_param_aanc_port_cfg aanc_port_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int index = 0;
pr_debug("%s: tx_port 0x%x, rx_port 0x%x\n",
__func__, tx_port, rx_port);
- ret = afe_q6_interface_prepare();
- if (ret != 0) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return -EINVAL;
- }
+ pr_debug("%s: AANC sample rate tx rate: %d rx rate %d\n", __func__,
+ this_afe.aanc_info.aanc_tx_port_sample_rate,
+ this_afe.aanc_info.aanc_rx_port_sample_rate);
- index = q6audio_get_port_index(tx_port);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(tx_port);
- if (ret < 0) {
- pr_err("%s: port id: 0x%x ret %d\n", __func__, tx_port, ret);
- return -EINVAL;
- }
- pr_debug("%s: AANC sample rate tx rate: %d rx rate %d\n",
- __func__, this_afe.aanc_info.aanc_tx_port_sample_rate,
- this_afe.aanc_info.aanc_rx_port_sample_rate);
+ memset(&aanc_port_cfg, 0, sizeof(aanc_port_cfg));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
/*
* If aanc tx sample rate or rx sample rate is zero, skip aanc
* configuration as AFE resampler will fail for invalid sample
@@ -1952,177 +2185,107 @@
return -EINVAL;
}
- cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- cfg.hdr.pkt_size = sizeof(cfg);
- cfg.hdr.src_port = 0;
- cfg.hdr.dest_port = 0;
- cfg.hdr.token = index;
- cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
+ param_hdr.module_id = AFE_MODULE_AANC;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_AANC_PORT_CONFIG;
+ param_hdr.param_size = sizeof(struct afe_param_aanc_port_cfg);
- cfg.param.port_id = tx_port;
- cfg.param.payload_size = sizeof(struct afe_port_param_data_v2) +
- sizeof(struct afe_param_aanc_port_cfg);
- cfg.param.payload_address_lsw = 0;
- cfg.param.payload_address_msw = 0;
- cfg.param.mem_map_handle = 0;
-
- cfg.pdata.module_id = AFE_MODULE_AANC;
- cfg.pdata.param_id = AFE_PARAM_ID_AANC_PORT_CONFIG;
- cfg.pdata.param_size = sizeof(struct afe_param_aanc_port_cfg);
- cfg.pdata.reserved = 0;
-
- cfg.data.aanc_port_cfg.aanc_port_cfg_minor_version =
+ aanc_port_cfg.aanc_port_cfg_minor_version =
AFE_API_VERSION_AANC_PORT_CONFIG;
- cfg.data.aanc_port_cfg.tx_port_sample_rate =
+ aanc_port_cfg.tx_port_sample_rate =
this_afe.aanc_info.aanc_tx_port_sample_rate;
- cfg.data.aanc_port_cfg.tx_port_channel_map[0] = AANC_TX_VOICE_MIC;
- cfg.data.aanc_port_cfg.tx_port_channel_map[1] = AANC_TX_NOISE_MIC;
- cfg.data.aanc_port_cfg.tx_port_channel_map[2] = AANC_TX_ERROR_MIC;
- cfg.data.aanc_port_cfg.tx_port_channel_map[3] = AANC_TX_MIC_UNUSED;
- cfg.data.aanc_port_cfg.tx_port_channel_map[4] = AANC_TX_MIC_UNUSED;
- cfg.data.aanc_port_cfg.tx_port_channel_map[5] = AANC_TX_MIC_UNUSED;
- cfg.data.aanc_port_cfg.tx_port_channel_map[6] = AANC_TX_MIC_UNUSED;
- cfg.data.aanc_port_cfg.tx_port_channel_map[7] = AANC_TX_MIC_UNUSED;
- cfg.data.aanc_port_cfg.tx_port_num_channels = 3;
- cfg.data.aanc_port_cfg.rx_path_ref_port_id = rx_port;
- cfg.data.aanc_port_cfg.ref_port_sample_rate =
- this_afe.aanc_info.aanc_rx_port_sample_rate;
+ aanc_port_cfg.tx_port_channel_map[0] = AANC_TX_VOICE_MIC;
+ aanc_port_cfg.tx_port_channel_map[1] = AANC_TX_NOISE_MIC;
+ aanc_port_cfg.tx_port_channel_map[2] = AANC_TX_ERROR_MIC;
+ aanc_port_cfg.tx_port_channel_map[3] = AANC_TX_MIC_UNUSED;
+ aanc_port_cfg.tx_port_channel_map[4] = AANC_TX_MIC_UNUSED;
+ aanc_port_cfg.tx_port_channel_map[5] = AANC_TX_MIC_UNUSED;
+ aanc_port_cfg.tx_port_channel_map[6] = AANC_TX_MIC_UNUSED;
+ aanc_port_cfg.tx_port_channel_map[7] = AANC_TX_MIC_UNUSED;
+ aanc_port_cfg.tx_port_num_channels = 3;
+ aanc_port_cfg.rx_path_ref_port_id = rx_port;
+ aanc_port_cfg.ref_port_sample_rate =
+ this_afe.aanc_info.aanc_rx_port_sample_rate;
- ret = afe_apr_send_pkt((uint32_t *) &cfg, &this_afe.wait[index]);
- if (ret) {
+ ret = q6afe_pack_and_set_param_in_band(tx_port,
+ q6audio_get_port_index(tx_port),
+ param_hdr,
+ (u8 *) &aanc_port_cfg);
+ if (ret)
pr_err("%s: AFE AANC port config failed for tx_port 0x%x, rx_port 0x%x ret %d\n",
- __func__, tx_port, rx_port, ret);
- }
+ __func__, tx_port, rx_port, ret);
return ret;
}
static int afe_aanc_mod_enable(void *apr, uint16_t tx_port, uint16_t enable)
{
- struct afe_port_cmd_set_aanc_param cfg;
+ struct afe_mod_enable_param mod_enable;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int index = 0;
- pr_debug("%s: tx_port 0x%x\n",
- __func__, tx_port);
+ pr_debug("%s: tx_port 0x%x\n", __func__, tx_port);
- ret = afe_q6_interface_prepare();
- if (ret != 0) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return -EINVAL;
- }
+ memset(&mod_enable, 0, sizeof(mod_enable));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_AANC;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_ENABLE;
+ param_hdr.param_size = sizeof(struct afe_mod_enable_param);
- index = q6audio_get_port_index(tx_port);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(tx_port);
- if (ret < 0) {
- pr_err("%s: port id: 0x%x ret %d\n", __func__, tx_port, ret);
- return -EINVAL;
- }
+ mod_enable.enable = enable;
+ mod_enable.reserved = 0;
- cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- cfg.hdr.pkt_size = sizeof(cfg);
- cfg.hdr.src_port = 0;
- cfg.hdr.dest_port = 0;
- cfg.hdr.token = index;
- cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-
- cfg.param.port_id = tx_port;
- cfg.param.payload_size = sizeof(struct afe_port_param_data_v2) +
- sizeof(struct afe_mod_enable_param);
- cfg.param.payload_address_lsw = 0;
- cfg.param.payload_address_lsw = 0;
- cfg.param.mem_map_handle = 0;
-
- cfg.pdata.module_id = AFE_MODULE_AANC;
- cfg.pdata.param_id = AFE_PARAM_ID_ENABLE;
- cfg.pdata.param_size = sizeof(struct afe_mod_enable_param);
- cfg.pdata.reserved = 0;
-
- cfg.data.mod_enable.enable = enable;
- cfg.data.mod_enable.reserved = 0;
-
- ret = afe_apr_send_pkt((uint32_t *) &cfg, &this_afe.wait[index]);
- if (ret) {
+ ret = q6afe_pack_and_set_param_in_band(tx_port,
+ q6audio_get_port_index(tx_port),
+ param_hdr, (u8 *) &mod_enable);
+ if (ret)
pr_err("%s: AFE AANC enable failed for tx_port 0x%x ret %d\n",
__func__, tx_port, ret);
- }
return ret;
}
static int afe_send_bank_selection_clip(
struct afe_param_id_clip_bank_sel *param)
{
+ struct param_hdr_v3 param_hdr;
int ret;
- struct afe_svc_cmd_set_clip_bank_selection config;
if (!param) {
pr_err("%s: Invalid params", __func__);
return -EINVAL;
}
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = IDX_GLOBAL_CFG;
- config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_CDC_DEV_CFG;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CLIP_BANK_SEL_CFG;
+ param_hdr.param_size = sizeof(struct afe_param_id_clip_bank_sel);
- config.param.payload_size = sizeof(struct afe_port_param_data_v2) +
- sizeof(struct afe_param_id_clip_bank_sel);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
-
- config.pdata.module_id = AFE_MODULE_CDC_DEV_CFG;
- config.pdata.param_id = AFE_PARAM_ID_CLIP_BANK_SEL_CFG;
- config.pdata.param_size =
- sizeof(struct afe_param_id_clip_bank_sel);
- config.bank_sel = *param;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
- if (ret) {
+ ret = q6afe_svc_pack_and_set_param_in_band(IDX_GLOBAL_CFG, param_hdr,
+ (u8 *) param);
+ if (ret)
pr_err("%s: AFE_PARAM_ID_CLIP_BANK_SEL_CFG failed %d\n",
__func__, ret);
- }
return ret;
}
int afe_send_aanc_version(
struct afe_param_id_cdc_aanc_version *version_cfg)
{
+ struct param_hdr_v3 param_hdr;
int ret;
- struct afe_svc_cmd_cdc_aanc_version config;
pr_debug("%s: enter\n", __func__);
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = IDX_GLOBAL_CFG;
- config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_CDC_DEV_CFG;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CDC_AANC_VERSION;
+ param_hdr.param_size = sizeof(struct afe_param_id_cdc_aanc_version);
- config.param.payload_size = sizeof(struct afe_port_param_data_v2) +
- sizeof(struct afe_param_id_cdc_aanc_version);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
-
- config.pdata.module_id = AFE_MODULE_CDC_DEV_CFG;
- config.pdata.param_id = AFE_PARAM_ID_CDC_AANC_VERSION;
- config.pdata.param_size =
- sizeof(struct afe_param_id_cdc_aanc_version);
- config.version = *version_cfg;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
- if (ret) {
+ ret = q6afe_svc_pack_and_set_param_in_band(IDX_GLOBAL_CFG, param_hdr,
+ (u8 *) version_cfg);
+ if (ret)
pr_err("%s: AFE_PARAM_ID_CDC_AANC_VERSION failed %d\n",
__func__, ret);
- }
return ret;
}
@@ -2261,86 +2424,32 @@
int afe_send_spdif_clk_cfg(struct afe_param_id_spdif_clk_cfg *cfg,
u16 port_id)
{
- struct afe_spdif_clk_config_command clk_cfg;
+ struct afe_param_id_spdif_clk_cfg clk_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int index = 0;
if (!cfg) {
pr_err("%s: Error, no configuration data\n", __func__);
- ret = -EINVAL;
- return ret;
- }
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(port_id);
- if (ret < 0) {
- pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
return -EINVAL;
}
- ret = afe_q6_interface_prepare();
- if (ret) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return ret;
- }
- clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
- clk_cfg.hdr.src_port = 0;
- clk_cfg.hdr.dest_port = 0;
- clk_cfg.hdr.token = index;
+ memset(&clk_cfg, 0, sizeof(clk_cfg));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_SPDIF_CLK_CONFIG;
+ param_hdr.param_size = sizeof(struct afe_param_id_spdif_clk_cfg);
- clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- clk_cfg.param.port_id = q6audio_get_port_id(port_id);
- clk_cfg.param.payload_address_lsw = 0x00;
- clk_cfg.param.payload_address_msw = 0x00;
- clk_cfg.param.mem_map_handle = 0x00;
- clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- clk_cfg.pdata.param_id = AFE_PARAM_ID_SPDIF_CLK_CONFIG;
- clk_cfg.pdata.param_size = sizeof(clk_cfg.clk_cfg);
- clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
- - sizeof(clk_cfg.param);
- clk_cfg.clk_cfg = *cfg;
+ pr_debug("%s: Minor version = 0x%x clk val = %d clk root = 0x%x port id = 0x%x\n",
+ __func__, clk_cfg.clk_cfg_minor_version, clk_cfg.clk_value,
+ clk_cfg.clk_root, q6audio_get_port_id(port_id));
- pr_debug("%s: Minor version = 0x%x clk val = %d\n"
- "clk root = 0x%x\n port id = 0x%x\n",
- __func__, cfg->clk_cfg_minor_version,
- cfg->clk_value, cfg->clk_root,
- q6audio_get_port_id(port_id));
-
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
- if (ret < 0) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &clk_cfg);
+ if (ret < 0)
pr_err("%s: AFE send clock config for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
-
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n",
- __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
-
-fail_cmd:
return ret;
}
@@ -2357,80 +2466,25 @@
int afe_send_spdif_ch_status_cfg(struct afe_param_id_spdif_ch_status_cfg
*ch_status_cfg, u16 port_id)
{
- struct afe_spdif_chstatus_config_command ch_status;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int index = 0;
- if (!ch_status_cfg) {
+ if (!ch_status_cfg)
pr_err("%s: Error, no configuration data\n", __func__);
- ret = -EINVAL;
- return ret;
- }
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(port_id);
- if (ret < 0) {
- pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
- return -EINVAL;
- }
+ return -EINVAL;
- ret = afe_q6_interface_prepare();
- if (ret != 0) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return ret;
- }
- ch_status.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- ch_status.hdr.pkt_size = sizeof(ch_status_cfg);
- ch_status.hdr.src_port = 0;
- ch_status.hdr.dest_port = 0;
- ch_status.hdr.token = index;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_SPDIF_CLK_CONFIG;
+ param_hdr.param_size = sizeof(struct afe_param_id_spdif_ch_status_cfg);
- ch_status.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- ch_status.param.port_id = q6audio_get_port_id(port_id);
- ch_status.param.payload_address_lsw = 0x00;
- ch_status.param.payload_address_msw = 0x00;
- ch_status.param.mem_map_handle = 0x00;
- ch_status.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- ch_status.pdata.param_id = AFE_PARAM_ID_SPDIF_CLK_CONFIG;
- ch_status.pdata.param_size = sizeof(ch_status.ch_status);
- ch_status.param.payload_size = sizeof(ch_status)
- - sizeof(struct apr_hdr) - sizeof(ch_status.param);
- ch_status.ch_status = *ch_status_cfg;
-
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &ch_status);
- if (ret < 0) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) ch_status_cfg);
+ if (ret < 0)
pr_err("%s: AFE send channel status for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
-
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n",
- __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
-
-fail_cmd:
return ret;
}
EXPORT_SYMBOL(afe_send_spdif_ch_status_cfg);
@@ -2509,10 +2563,9 @@
int afe_spdif_port_start(u16 port_id, struct afe_spdif_port_config *spdif_port,
u32 rate)
{
- struct afe_audioif_config_command config;
- int ret = 0;
- int index = 0;
+ struct param_hdr_v3 param_hdr;
uint16_t port_index;
+ int ret = 0;
if (!spdif_port) {
pr_err("%s: Error, no configuration data\n", __func__);
@@ -2522,12 +2575,7 @@
pr_debug("%s: port id: 0x%x\n", __func__, port_id);
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
+ memset(¶m_hdr, 0, sizeof(param_hdr));
ret = q6audio_validate_port(port_id);
if (ret < 0) {
pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
@@ -2537,24 +2585,14 @@
afe_send_cal(port_id);
afe_send_hw_delay(port_id, rate);
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- config.pdata.param_id = AFE_PARAM_ID_SPDIF_CONFIG;
- config.pdata.param_size = sizeof(config.port);
- config.port.spdif = spdif_port->cfg;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_SPDIF_CONFIG;
+ param_hdr.param_size = sizeof(struct afe_spdif_port_config);
+
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) spdif_port);
if (ret) {
pr_err("%s: AFE enable for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
@@ -2587,9 +2625,8 @@
struct afe_param_id_slot_mapping_cfg *slot_mapping_cfg,
u16 port_id)
{
- struct afe_slot_mapping_config_command config;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int index = 0;
if (!slot_mapping_cfg) {
pr_err("%s: Error, no configuration data\n", __func__);
@@ -2598,67 +2635,19 @@
pr_debug("%s: port id: 0x%x\n", __func__, port_id);
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(port_id);
- if (ret < 0) {
- pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
- return -EINVAL;
- }
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_TDM;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG;
+ param_hdr.param_size = sizeof(struct afe_param_id_slot_mapping_cfg);
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
-
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config)
- - sizeof(struct apr_hdr) - sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_TDM;
- config.pdata.param_id = AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG;
- config.pdata.param_size = sizeof(config.slot_mapping);
- config.slot_mapping = *slot_mapping_cfg;
-
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config);
- if (ret < 0) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr,
+ (u8 *) slot_mapping_cfg);
+ if (ret < 0)
pr_err("%s: AFE send slot mapping for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
-
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n",
- __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
-
-fail_cmd:
return ret;
}
@@ -2666,9 +2655,8 @@
struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header_cfg,
u16 port_id)
{
- struct afe_custom_tdm_header_config_command config;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int index = 0;
if (!custom_tdm_header_cfg) {
pr_err("%s: Error, no configuration data\n", __func__);
@@ -2677,67 +2665,20 @@
pr_debug("%s: port id: 0x%x\n", __func__, port_id);
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(port_id);
- if (ret < 0) {
- pr_err("%s: port id: 0x%x ret %d\n", __func__, port_id, ret);
- return -EINVAL;
- }
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_TDM;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CUSTOM_TDM_HEADER_CONFIG;
+ param_hdr.param_size =
+ sizeof(struct afe_param_id_custom_tdm_header_cfg);
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
-
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config)
- - sizeof(struct apr_hdr) - sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_TDM;
- config.pdata.param_id = AFE_PARAM_ID_CUSTOM_TDM_HEADER_CONFIG;
- config.pdata.param_size = sizeof(config.custom_tdm_header);
- config.custom_tdm_header = *custom_tdm_header_cfg;
-
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config);
- if (ret < 0) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr,
+ (u8 *) custom_tdm_header_cfg);
+ if (ret < 0)
pr_err("%s: AFE send custom tdm header for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
-
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n",
- __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
-
-fail_cmd:
return ret;
}
@@ -2755,11 +2696,11 @@
int afe_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port,
u32 rate, u16 num_groups)
{
- struct afe_audioif_config_command config;
- int ret = 0;
+ struct param_hdr_v3 param_hdr;
int index = 0;
uint16_t port_index = 0;
enum afe_mad_type mad_type = MAD_HW_NONE;
+ int ret = 0;
if (!tdm_port) {
pr_err("%s: Error, no configuration data\n", __func__);
@@ -2768,6 +2709,7 @@
pr_debug("%s: port id: 0x%x\n", __func__, port_id);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
index = q6audio_get_port_index(port_id);
if (index < 0 || index >= AFE_MAX_PORTS) {
pr_err("%s: AFE port index[%d] invalid!\n",
@@ -2823,26 +2765,15 @@
}
}
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- config.pdata.param_id = AFE_PARAM_ID_TDM_CONFIG;
- config.pdata.param_size = sizeof(config.port);
- config.port.tdm = tdm_port->tdm;
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_TDM_CONFIG;
+ param_hdr.param_size = sizeof(struct afe_param_id_tdm_cfg);
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr,
+ (u8 *) &tdm_port->tdm);
if (ret) {
pr_err("%s: AFE enable for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
@@ -2913,61 +2844,48 @@
int afe_port_send_usb_dev_param(u16 port_id, union afe_port_config *afe_config)
{
- struct afe_usb_audio_dev_param_command config;
- int ret = 0, index = 0;
+ struct afe_param_id_usb_audio_dev_params usb_dev;
+ struct afe_param_id_usb_audio_dev_lpcm_fmt lpcm_fmt;
+ struct param_hdr_v3 param_hdr;
+ int ret = 0;
if (!afe_config) {
pr_err("%s: Error, no configuration data\n", __func__);
ret = -EINVAL;
goto exit;
}
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid! for port ID 0x%x\n",
- __func__, index, port_id);
- ret = -EINVAL;
- goto exit;
- }
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- config.pdata.param_id = AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS;
- config.pdata.param_size = sizeof(config.usb_dev);
- config.usb_dev.cfg_minor_version =
- AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
- config.usb_dev.dev_token = afe_config->usb_audio.dev_token;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ memset(&usb_dev, 0, sizeof(usb_dev));
+ memset(&lpcm_fmt, 0, sizeof(lpcm_fmt));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+
+ param_hdr.param_id = AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS;
+ param_hdr.param_size = sizeof(usb_dev);
+ usb_dev.cfg_minor_version = AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
+ usb_dev.dev_token = afe_config->usb_audio.dev_token;
+
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &usb_dev);
if (ret) {
pr_err("%s: AFE device param cmd failed %d\n",
__func__, ret);
- ret = -EINVAL;
goto exit;
}
- config.pdata.param_id = AFE_PARAM_ID_USB_AUDIO_DEV_LPCM_FMT;
- config.pdata.param_size = sizeof(config.lpcm_fmt);
- config.lpcm_fmt.cfg_minor_version =
- AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
- config.lpcm_fmt.endian = afe_config->usb_audio.endian;
+ param_hdr.param_id = AFE_PARAM_ID_USB_AUDIO_DEV_LPCM_FMT;
+ param_hdr.param_size = sizeof(lpcm_fmt);
+ lpcm_fmt.cfg_minor_version = AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG;
+ lpcm_fmt.endian = afe_config->usb_audio.endian;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &lpcm_fmt);
if (ret) {
pr_err("%s: AFE device param cmd LPCM_FMT failed %d\n",
__func__, ret);
- ret = -EINVAL;
goto exit;
}
@@ -2981,62 +2899,58 @@
u16 afe_in_channels, u16 afe_in_bit_width,
u32 scrambler_mode)
{
- struct afe_audioif_config_command config;
- int index;
+ u32 enc_fmt;
+ struct afe_enc_cfg_blk_param_t enc_blk_param;
+ struct afe_param_id_aptx_sync_mode sync_mode_param;
+ struct avs_enc_packetizer_id_param_t enc_pkt_id_param;
+ struct avs_enc_set_scrambler_param_t enc_set_scrambler_param;
+ struct afe_port_media_type_t media_type;
+ struct param_hdr_v3 param_hdr;
int ret;
- int payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param) - sizeof(config.port);
pr_debug("%s:update DSP for enc format = %d\n", __func__, format);
+
+ memset(&enc_blk_param, 0, sizeof(enc_blk_param));
+ memset(&sync_mode_param, 0, sizeof(sync_mode_param));
+ memset(&enc_pkt_id_param, 0, sizeof(enc_pkt_id_param));
+ memset(&enc_set_scrambler_param, 0, sizeof(enc_set_scrambler_param));
+ memset(&media_type, 0, sizeof(media_type));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
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_CELT && format != ASM_MEDIA_FMT_LDAC) {
pr_err("%s:Unsuppported format Ignore AFE config\n", __func__);
return 0;
}
- memset(&config, 0, sizeof(config));
- index = q6audio_get_port_index(port_id);
- if (index < 0) {
- pr_err("%s: Invalid index number: %d\n", __func__, index);
- return -EINVAL;
- }
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
+ param_hdr.module_id = AFE_MODULE_ID_ENCODER;
+ param_hdr.instance_id = INSTANCE_ID_0;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = payload_size + sizeof(config.port.enc_fmt);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_ID_ENCODER;
- config.pdata.param_id = AFE_ENCODER_PARAM_ID_ENC_FMT_ID;
- config.pdata.param_size = sizeof(config.port.enc_fmt);
- config.port.enc_fmt.fmt_id = format;
- pr_debug("%s:sending AFE_ENCODER_PARAM_ID_ENC_FMT_ID payload: %d\n",
- __func__, config.param.payload_size);
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ param_hdr.param_id = AFE_ENCODER_PARAM_ID_ENC_FMT_ID;
+ param_hdr.param_size = sizeof(enc_fmt);
+ enc_fmt = format;
+ pr_debug("%s:sending AFE_ENCODER_PARAM_ID_ENC_FMT_ID payload\n",
+ __func__);
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &enc_fmt);
if (ret) {
pr_err("%s:unable to send AFE_ENCODER_PARAM_ID_ENC_FMT_ID",
__func__);
goto exit;
}
- config.param.payload_size = payload_size
- + sizeof(config.port.enc_blk_param);
- pr_debug("%s:send AFE_ENCODER_PARAM_ID_ENC_CFG_BLK to DSP payload:%d\n",
- __func__, config.param.payload_size);
- config.pdata.param_id = AFE_ENCODER_PARAM_ID_ENC_CFG_BLK;
- config.pdata.param_size = sizeof(config.port.enc_blk_param);
- config.port.enc_blk_param.enc_cfg_blk_size =
- sizeof(config.port.enc_blk_param.enc_blk_config);
- config.port.enc_blk_param.enc_blk_config = *cfg;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ pr_debug("%s:send AFE_ENCODER_PARAM_ID_ENC_CFG_BLK to DSP payloadn",
+ __func__);
+ param_hdr.param_id = AFE_ENCODER_PARAM_ID_ENC_CFG_BLK;
+ param_hdr.param_size = sizeof(struct afe_enc_cfg_blk_param_t);
+ enc_blk_param.enc_cfg_blk_size = sizeof(union afe_enc_config_data);
+ enc_blk_param.enc_blk_config = *cfg;
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr,
+ (u8 *) &enc_blk_param);
if (ret) {
pr_err("%s: AFE_ENCODER_PARAM_ID_ENC_CFG_BLK for port 0x%x failed %d\n",
__func__, port_id, ret);
@@ -3044,16 +2958,18 @@
}
if (format == ASM_MEDIA_FMT_APTX) {
- config.param.payload_size =
- payload_size + sizeof(config.port.sync_mode_param);
pr_debug("%s: sending AFE_PARAM_ID_APTX_SYNC_MODE to DSP",
__func__);
- config.pdata.param_id = AFE_PARAM_ID_APTX_SYNC_MODE;
- config.pdata.param_size = sizeof(config.port.sync_mode_param);
- config.port.sync_mode_param.sync_mode =
- config.port.enc_blk_param.enc_blk_config.aptx_config.
+ param_hdr.param_id = AFE_PARAM_ID_APTX_SYNC_MODE;
+ param_hdr.param_size =
+ sizeof(struct afe_param_id_aptx_sync_mode);
+ sync_mode_param.sync_mode =
+ enc_blk_param.enc_blk_config.aptx_config.
aptx_v2_cfg.sync_mode;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr,
+ (u8 *) &sync_mode_param);
if (ret) {
pr_err("%s: AFE_PARAM_ID_APTX_SYNC_MODE for port 0x%x failed %d\n",
__func__, port_id, ret);
@@ -3061,67 +2977,57 @@
}
}
- config.param.payload_size =
- payload_size + sizeof(config.port.enc_pkt_id_param);
- pr_debug("%s:sending AFE_ENCODER_PARAM_ID_PACKETIZER to DSP payload = %d",
- __func__, config.param.payload_size);
- config.pdata.param_id = AFE_ENCODER_PARAM_ID_PACKETIZER_ID;
- config.pdata.param_size = sizeof(config.port.enc_pkt_id_param);
- config.port.enc_pkt_id_param.enc_packetizer_id =
- AFE_MODULE_ID_PACKETIZER_COP;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ pr_debug("%s:sending AFE_ENCODER_PARAM_ID_PACKETIZER to DSP\n",
+ __func__);
+ param_hdr.param_id = AFE_ENCODER_PARAM_ID_PACKETIZER_ID;
+ param_hdr.param_size = sizeof(struct avs_enc_packetizer_id_param_t);
+ enc_pkt_id_param.enc_packetizer_id = AFE_MODULE_ID_PACKETIZER_COP;
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr,
+ (u8 *) &enc_pkt_id_param);
if (ret) {
pr_err("%s: AFE_ENCODER_PARAM_ID_PACKETIZER for port 0x%x failed %d\n",
__func__, port_id, ret);
goto exit;
}
- config.param.payload_size =
- payload_size + sizeof(config.port.enc_set_scrambler_param);
- pr_debug("%s:sending AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING mode= %d to DSP payload = %d\n",
- __func__, scrambler_mode, config.param.payload_size);
- config.pdata.param_id = AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING;
- config.pdata.param_size = sizeof(config.port.enc_set_scrambler_param);
- config.port.enc_set_scrambler_param.enable_scrambler = scrambler_mode;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ pr_debug("%s:sending AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING mode= %d to DSP payload\n",
+ __func__, scrambler_mode);
+ param_hdr.param_id = AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING;
+ param_hdr.param_size = sizeof(struct avs_enc_set_scrambler_param_t);
+ enc_set_scrambler_param.enable_scrambler = scrambler_mode;
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr,
+ (u8 *) &enc_set_scrambler_param);
if (ret) {
pr_err("%s: AFE_ENCODER_PARAM_ID_ENABLE_SCRAMBLING for port 0x%x failed %d\n",
__func__, port_id, ret);
goto exit;
}
- config.param.payload_size =
- payload_size + sizeof(config.port.media_type);
- config.pdata.param_size = sizeof(config.port.media_type);
-
pr_debug("%s:Sending AFE_API_VERSION_PORT_MEDIA_TYPE to DSP", __func__);
- config.pdata.module_id = AFE_MODULE_PORT;
- config.pdata.param_id = AFE_PARAM_ID_PORT_MEDIA_TYPE;
- config.port.media_type.minor_version = AFE_API_VERSION_PORT_MEDIA_TYPE;
- if (format == ASM_MEDIA_FMT_LDAC) {
- config.port.media_type.sample_rate =
- config.port.enc_blk_param.enc_blk_config.ldac_config.
- custom_config.sample_rate;
- } else {
- config.port.media_type.sample_rate =
- afe_config.slim_sch.sample_rate;
- }
-
+ param_hdr.module_id = AFE_MODULE_PORT;
+ param_hdr.param_id = AFE_PARAM_ID_PORT_MEDIA_TYPE;
+ param_hdr.param_size = sizeof(struct afe_port_media_type_t);
+ media_type.minor_version = AFE_API_VERSION_PORT_MEDIA_TYPE;
+ media_type.sample_rate = afe_config.slim_sch.sample_rate;
if (afe_in_bit_width)
- config.port.media_type.bit_width = afe_in_bit_width;
+ media_type.bit_width = afe_in_bit_width;
else
- config.port.media_type.bit_width =
- afe_config.slim_sch.bit_width;
+ media_type.bit_width = afe_config.slim_sch.bit_width;
if (afe_in_channels)
- config.port.media_type.num_channels = afe_in_channels;
+ media_type.num_channels = afe_in_channels;
else
- config.port.media_type.num_channels =
- afe_config.slim_sch.num_channels;
- config.port.media_type.data_format = AFE_PORT_DATA_FORMAT_PCM;
- config.port.media_type.reserved = 0;
+ media_type.num_channels = afe_config.slim_sch.num_channels;
+ media_type.data_format = AFE_PORT_DATA_FORMAT_PCM;
+ media_type.reserved = 0;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &media_type);
if (ret) {
pr_err("%s: AFE_API_VERSION_PORT_MEDIA_TYPE for port 0x%x failed %d\n",
__func__, port_id, ret);
@@ -3137,13 +3043,17 @@
union afe_enc_config_data *cfg, u32 enc_format,
u32 scrambler_mode)
{
- struct afe_audioif_config_command config;
+ union afe_port_config port_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
int cfg_type;
int index = 0;
enum afe_mad_type mad_type;
uint16_t port_index;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ memset(&port_cfg, 0, sizeof(port_cfg));
+
if (!afe_config) {
pr_err("%s: Error, no configuration data\n", __func__);
ret = -EINVAL;
@@ -3264,13 +3174,6 @@
}
}
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
-
switch (port_id) {
case AFE_PORT_ID_PRIMARY_PCM_RX:
case AFE_PORT_ID_PRIMARY_PCM_TX:
@@ -3368,24 +3271,21 @@
ret = -EINVAL;
goto fail_cmd;
}
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- config.pdata.param_id = cfg_type;
- config.pdata.param_size = sizeof(config.port);
- config.port = *afe_config;
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = cfg_type;
+ param_hdr.param_size = sizeof(union afe_port_config);
+
+ port_cfg = *afe_config;
if ((enc_format != ASM_MEDIA_FMT_NONE) &&
(cfg_type == AFE_PARAM_ID_SLIMBUS_CONFIG)) {
- config.port.slim_sch.data_format =
- AFE_SB_DATA_FORMAT_GENERIC_COMPRESSED;
+ port_cfg.slim_sch.data_format =
+ AFE_SB_DATA_FORMAT_GENERIC_COMPRESSED;
}
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &port_cfg);
if (ret) {
pr_err("%s: AFE enable for port 0x%x failed %d\n",
__func__, port_id, ret);
@@ -3778,11 +3678,16 @@
union afe_port_config *afe_config, int rate)
{
struct afe_port_cmd_device_start start;
- struct afe_audioif_config_command config;
+ union afe_port_config port_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
int cfg_type;
int index = 0;
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ memset(&start, 0, sizeof(start));
+ memset(&port_cfg, 0, sizeof(port_cfg));
+
if (!afe_config) {
pr_err("%s: Error, no configuration data\n", __func__);
ret = -EINVAL;
@@ -3837,12 +3742,6 @@
}
mutex_lock(&this_afe.afe_cmd_lock);
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
switch (port_id) {
case PRIMARY_I2S_RX:
case PRIMARY_I2S_TX:
@@ -3906,24 +3805,16 @@
ret = -EINVAL;
goto fail_cmd;
}
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr)
- - sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- config.pdata.param_id = cfg_type;
- config.pdata.param_size = sizeof(config.port);
- config.port = *afe_config;
- pr_debug("%s: param PL size=%d iparam_size[%d][%zd %zd %zd %zd] param_id[0x%x]\n",
- __func__, config.param.payload_size, config.pdata.param_size,
- sizeof(config), sizeof(config.param), sizeof(config.port),
- sizeof(struct apr_hdr), config.pdata.param_id);
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = cfg_type;
+ param_hdr.param_size = sizeof(union afe_port_config);
+ port_cfg = *afe_config;
- ret = afe_apr_send_pkt(&config, &this_afe.wait[index]);
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &port_cfg);
if (ret) {
pr_err("%s: AFE enable for port 0x%x opcode[0x%x]failed %d\n",
__func__, port_id, cfg_type, ret);
@@ -3965,57 +3856,31 @@
*/
int afe_loopback(u16 enable, u16 rx_port, u16 tx_port)
{
- struct afe_loopback_cfg_v1 lb_cmd;
+ struct afe_loopback_cfg_v1 lb_param;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int index = 0;
+
+ memset(&lb_param, 0, sizeof(lb_param));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
if (rx_port == MI2S_RX)
rx_port = AFE_PORT_ID_PRIMARY_MI2S_RX;
if (tx_port == MI2S_TX)
tx_port = AFE_PORT_ID_PRIMARY_MI2S_TX;
- ret = afe_q6_interface_prepare();
- if (ret != 0) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return ret;
- }
+ param_hdr.module_id = AFE_MODULE_LOOPBACK;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_LOOPBACK_CONFIG;
+ param_hdr.param_size = sizeof(struct afe_loopback_cfg_v1);
- index = q6audio_get_port_index(rx_port);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(rx_port);
- if (ret < 0) {
- pr_err("%s: Invalid port 0x%x ret %d", __func__, rx_port, ret);
- return -EINVAL;
- }
+ lb_param.dst_port_id = rx_port;
+ lb_param.routing_mode = LB_MODE_DEFAULT;
+ lb_param.enable = (enable ? 1 : 0);
+ lb_param.loopback_cfg_minor_version = AFE_API_VERSION_LOOPBACK_CONFIG;
- lb_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(20), APR_PKT_VER);
- lb_cmd.hdr.pkt_size = sizeof(lb_cmd);
- lb_cmd.hdr.src_port = 0;
- lb_cmd.hdr.dest_port = 0;
- lb_cmd.hdr.token = index;
- lb_cmd.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- lb_cmd.param.port_id = tx_port;
- lb_cmd.param.payload_size = (sizeof(lb_cmd) - sizeof(struct apr_hdr) -
- sizeof(struct afe_port_cmd_set_param_v2));
- lb_cmd.param.payload_address_lsw = 0x00;
- lb_cmd.param.payload_address_msw = 0x00;
- lb_cmd.param.mem_map_handle = 0x00;
- lb_cmd.pdata.module_id = AFE_MODULE_LOOPBACK;
- lb_cmd.pdata.param_id = AFE_PARAM_ID_LOOPBACK_CONFIG;
- lb_cmd.pdata.param_size = lb_cmd.param.payload_size -
- sizeof(struct afe_port_param_data_v2);
-
- lb_cmd.dst_port_id = rx_port;
- lb_cmd.routing_mode = LB_MODE_DEFAULT;
- lb_cmd.enable = (enable ? 1 : 0);
- lb_cmd.loopback_cfg_minor_version = AFE_API_VERSION_LOOPBACK_CONFIG;
-
- ret = afe_apr_send_pkt(&lb_cmd, &this_afe.wait[index]);
+ ret = q6afe_pack_and_set_param_in_band(tx_port,
+ q6audio_get_port_index(tx_port),
+ param_hdr, (u8 *) &lb_param);
if (ret)
pr_err("%s: AFE loopback failed %d\n", __func__, ret);
return ret;
@@ -4034,8 +3899,11 @@
int afe_loopback_gain(u16 port_id, u16 volume)
{
struct afe_loopback_gain_per_path_param set_param;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- int index = 0;
+
+ memset(&set_param, 0, sizeof(set_param));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
if (this_afe.apr == NULL) {
this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
@@ -4056,18 +3924,6 @@
ret = -EINVAL;
goto fail_cmd;
}
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
- ret = q6audio_validate_port(port_id);
- if (ret < 0) {
- pr_err("%s: Invalid port 0x%x ret %d",
- __func__, port_id, ret);
- return -EINVAL;
- }
/* RX ports numbers are even .TX ports numbers are odd. */
if (port_id % 2 == 0) {
@@ -4079,36 +3935,19 @@
pr_debug("%s: port 0x%x volume %d\n", __func__, port_id, volume);
- set_param.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- set_param.hdr.pkt_size = sizeof(set_param);
- set_param.hdr.src_port = 0;
- set_param.hdr.dest_port = 0;
- set_param.hdr.token = index;
- set_param.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
-
- set_param.param.port_id = port_id;
- set_param.param.payload_size =
- (sizeof(struct afe_loopback_gain_per_path_param) -
- sizeof(struct apr_hdr) - sizeof(struct afe_port_cmd_set_param_v2));
- set_param.param.payload_address_lsw = 0;
- set_param.param.payload_address_msw = 0;
- set_param.param.mem_map_handle = 0;
-
- set_param.pdata.module_id = AFE_MODULE_LOOPBACK;
- set_param.pdata.param_id = AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH;
- set_param.pdata.param_size =
- (set_param.param.payload_size -
- sizeof(struct afe_port_param_data_v2));
+ param_hdr.module_id = AFE_MODULE_LOOPBACK;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH;
+ param_hdr.param_size = sizeof(struct afe_loopback_gain_per_path_param);
set_param.rx_port_id = port_id;
set_param.gain = volume;
- ret = afe_apr_send_pkt(&set_param, &this_afe.wait[index]);
- if (ret) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &set_param);
+ if (ret)
pr_err("%s: AFE param set failed for port 0x%x ret %d\n",
__func__, port_id, ret);
- goto fail_cmd;
- }
fail_cmd:
return ret;
@@ -4237,9 +4076,9 @@
int afe_port_group_set_param(u16 group_id,
union afe_port_group_config *afe_group_config)
{
- int ret;
- struct afe_port_group_create config;
+ struct param_hdr_v3 param_hdr;
int cfg_type;
+ int ret;
if (!afe_group_config) {
pr_err("%s: Error, no configuration data\n", __func__);
@@ -4248,6 +4087,8 @@
pr_debug("%s: group id: 0x%x\n", __func__, group_id);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
ret = afe_q6_interface_prepare();
if (ret != 0) {
pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
@@ -4272,27 +4113,13 @@
return -EINVAL;
}
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = IDX_GLOBAL_CFG;
- config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
+ param_hdr.module_id = AFE_MODULE_GROUP_DEVICE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = cfg_type;
+ param_hdr.param_size = sizeof(union afe_port_group_config);
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_GROUP_DEVICE;
- config.pdata.param_id = cfg_type;
- config.pdata.param_size = sizeof(config.data);
- config.data = *afe_group_config;
-
- ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
+ ret = q6afe_svc_pack_and_set_param_in_band(IDX_GLOBAL_CFG, param_hdr,
+ (u8 *) afe_group_config);
if (ret)
pr_err("%s: AFE_PARAM_ID_GROUP_DEVICE_CFG failed %d\n",
__func__, ret);
@@ -4314,12 +4141,16 @@
union afe_port_group_config *afe_group_config,
u16 enable)
{
+ struct afe_group_device_enable group_enable;
+ struct param_hdr_v3 param_hdr;
int ret;
- struct afe_port_group_create config;
pr_debug("%s: group id: 0x%x enable: %d\n", __func__,
group_id, enable);
+ memset(&group_enable, 0, sizeof(group_enable));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
ret = afe_q6_interface_prepare();
if (ret != 0) {
pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
@@ -4334,28 +4165,15 @@
}
}
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = IDX_GLOBAL_CFG;
- config.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
+ param_hdr.module_id = AFE_MODULE_GROUP_DEVICE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_GROUP_DEVICE_ENABLE;
+ param_hdr.param_size = sizeof(struct afe_group_device_enable);
+ group_enable.group_id = group_id;
+ group_enable.enable = enable;
- config.param.payload_size = sizeof(config) - sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AFE_MODULE_GROUP_DEVICE;
- config.pdata.param_id = AFE_PARAM_ID_GROUP_DEVICE_ENABLE;
- config.pdata.param_size = sizeof(config.data);
- config.data.group_enable.group_id = group_id;
- config.data.group_enable.enable = enable;
-
- ret = afe_apr_send_pkt(&config, &this_afe.wait[IDX_GLOBAL_CFG]);
+ ret = q6afe_svc_pack_and_set_param_in_band(IDX_GLOBAL_CFG, param_hdr,
+ (u8 *) &group_enable);
if (ret)
pr_err("%s: AFE_PARAM_ID_GROUP_DEVICE_ENABLE failed %d\n",
__func__, ret);
@@ -5427,9 +5245,7 @@
static int afe_sidetone_iir(u16 tx_port_id)
{
- struct afe_loopback_iir_cfg_v2 iir_sidetone;
int ret;
- int index = 0;
uint16_t size = 0;
int cal_index = AFE_SIDETONE_IIR_CAL;
int iir_pregain = 0;
@@ -5437,20 +5253,17 @@
int iir_enable;
struct cal_block_data *cal_block;
int mid;
+ struct afe_mod_enable_param enable;
+ struct afe_sidetone_iir_filter_config_params filter_data;
+ struct param_hdr_v3 param_hdr;
+ u8 *packed_param_data = NULL;
+ u32 packed_param_size = 0;
+ u32 single_param_size = 0;
+ struct audio_cal_info_sidetone_iir *st_iir_cal_info = NULL;
- memset(&iir_sidetone, 0, sizeof(iir_sidetone));
- index = q6audio_get_port_index(tx_port_id);
- iir_sidetone.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- iir_sidetone.hdr.pkt_size = sizeof(iir_sidetone);
- iir_sidetone.hdr.src_port = 0;
- iir_sidetone.hdr.dest_port = 0;
- iir_sidetone.hdr.token = index;
- iir_sidetone.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- iir_sidetone.param.port_id = tx_port_id;
- iir_sidetone.param.payload_address_lsw = 0x00;
- iir_sidetone.param.payload_address_msw = 0x00;
- iir_sidetone.param.mem_map_handle = 0x00;
+ memset(&enable, 0, sizeof(enable));
+ memset(&filter_data, 0, sizeof(filter_data));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
if (this_afe.cal_data[cal_index] == NULL) {
pr_err("%s: cal data is NULL\n", __func__);
@@ -5466,14 +5279,13 @@
goto done;
}
- iir_pregain = ((struct audio_cal_info_sidetone_iir *)
- cal_block->cal_info)->pregain;
- iir_enable = ((struct audio_cal_info_sidetone_iir *)
- cal_block->cal_info)->iir_enable;
- iir_num_biquad_stages = ((struct audio_cal_info_sidetone_iir *)
- cal_block->cal_info)->num_biquad_stages;
- mid = ((struct audio_cal_info_sidetone_iir *)
- cal_block->cal_info)->mid;
+ /* Cache data from cal block while inside lock to reduce locked time */
+ st_iir_cal_info =
+ (struct audio_cal_info_sidetone_iir *) cal_block->cal_info;
+ iir_pregain = st_iir_cal_info->pregain;
+ iir_enable = st_iir_cal_info->iir_enable;
+ iir_num_biquad_stages = st_iir_cal_info->num_biquad_stages;
+ mid = st_iir_cal_info->mid;
/*
* calculate the actual size of payload based on no of stages
@@ -5489,80 +5301,102 @@
pr_debug("%s: adding 2 to size:%d\n", __func__, size);
size = size + 2;
}
- memcpy(&iir_sidetone.st_iir_filter_config_data.iir_config,
- &((struct audio_cal_info_sidetone_iir *)
- cal_block->cal_info)->iir_config,
- sizeof(iir_sidetone.st_iir_filter_config_data.iir_config));
+ memcpy(&filter_data.iir_config, &st_iir_cal_info->iir_config, size);
mutex_unlock(&this_afe.cal_data[cal_index]->lock);
- /*
- * Calculate the payload size for setparams command
- */
- iir_sidetone.param.payload_size = (sizeof(iir_sidetone) -
- sizeof(struct apr_hdr) -
- sizeof(struct afe_port_cmd_set_param_v2) -
- (MAX_SIDETONE_IIR_DATA_SIZE - size));
-
- pr_debug("%s: payload size :%d\n", __func__,
- iir_sidetone.param.payload_size);
+ packed_param_size =
+ sizeof(param_hdr) * 2 + sizeof(enable) + sizeof(filter_data);
+ packed_param_data = kzalloc(packed_param_size, GFP_KERNEL);
+ if (!packed_param_data)
+ return -ENOMEM;
+ packed_param_size = 0;
/*
* Set IIR enable params
*/
- iir_sidetone.st_iir_enable_pdata.module_id = mid;
- iir_sidetone.st_iir_enable_pdata.param_id =
- AFE_PARAM_ID_ENABLE;
- iir_sidetone.st_iir_enable_pdata.param_size =
- sizeof(iir_sidetone.st_iir_mode_enable_data);
- iir_sidetone.st_iir_mode_enable_data.enable = iir_enable;
+ param_hdr.module_id = mid;
+ param_hdr.param_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_ENABLE;
+ param_hdr.param_size = sizeof(enable);
+ enable.enable = iir_enable;
+ ret = q6common_pack_pp_params(packed_param_data, ¶m_hdr,
+ (u8 *) &enable, &single_param_size);
+ if (ret) {
+ pr_err("%s: Failed to pack param data, error %d\n", __func__,
+ ret);
+ goto done;
+ }
+ packed_param_size += single_param_size;
/*
* Set IIR filter config params
*/
- iir_sidetone.st_iir_filter_config_pdata.module_id = mid;
- iir_sidetone.st_iir_filter_config_pdata.param_id =
- AFE_PARAM_ID_SIDETONE_IIR_FILTER_CONFIG;
- iir_sidetone.st_iir_filter_config_pdata.param_size =
- sizeof(iir_sidetone.st_iir_filter_config_data.num_biquad_stages)
- +
- sizeof(iir_sidetone.st_iir_filter_config_data.pregain) + size;
- iir_sidetone.st_iir_filter_config_pdata.reserved = 0;
- iir_sidetone.st_iir_filter_config_data.num_biquad_stages =
- iir_num_biquad_stages;
- iir_sidetone.st_iir_filter_config_data.pregain = iir_pregain;
+ param_hdr.module_id = mid;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_SIDETONE_IIR_FILTER_CONFIG;
+ param_hdr.param_size = sizeof(filter_data.num_biquad_stages) +
+ sizeof(filter_data.pregain) + size;
+ filter_data.num_biquad_stages = iir_num_biquad_stages;
+ filter_data.pregain = iir_pregain;
+ ret = q6common_pack_pp_params(packed_param_data + packed_param_size,
+ ¶m_hdr, (u8 *) &filter_data,
+ &single_param_size);
+ if (ret) {
+ pr_err("%s: Failed to pack param data, error %d\n", __func__,
+ ret);
+ goto done;
+ }
+ packed_param_size += single_param_size;
+
pr_debug("%s: tx(0x%x)mid(0x%x)iir_en(%d)stg(%d)gain(0x%x)size(%d)\n",
- __func__, tx_port_id, mid,
- iir_sidetone.st_iir_mode_enable_data.enable,
- iir_sidetone.st_iir_filter_config_data.num_biquad_stages,
- iir_sidetone.st_iir_filter_config_data.pregain,
- iir_sidetone.st_iir_filter_config_pdata.param_size);
- ret = afe_apr_send_pkt(&iir_sidetone, &this_afe.wait[index]);
+ __func__, tx_port_id, mid, enable.enable,
+ filter_data.num_biquad_stages, filter_data.pregain,
+ param_hdr.param_size);
+
+ ret = q6afe_set_params(tx_port_id, q6audio_get_port_index(tx_port_id),
+ NULL, packed_param_data, packed_param_size);
if (ret)
pr_err("%s: AFE sidetone failed for tx_port(0x%x)\n",
__func__, tx_port_id);
done:
+ kfree(packed_param_data);
return ret;
-
}
static int afe_sidetone(u16 tx_port_id, u16 rx_port_id, bool enable)
{
- struct afe_st_loopback_cfg_v1 cmd_sidetone;
int ret;
- int index;
int cal_index = AFE_SIDETONE_CAL;
int sidetone_gain;
int sidetone_enable;
struct cal_block_data *cal_block;
int mid = 0;
+ struct afe_loopback_sidetone_gain gain_data;
+ struct loopback_cfg_data cfg_data;
+ struct param_hdr_v3 param_hdr;
+ u8 *packed_param_data = NULL;
+ u32 packed_param_size = 0;
+ u32 single_param_size = 0;
+ struct audio_cal_info_sidetone *st_cal_info = NULL;
- memset(&cmd_sidetone, 0, sizeof(cmd_sidetone));
if (this_afe.cal_data[cal_index] == NULL) {
pr_err("%s: cal data is NULL\n", __func__);
ret = -EINVAL;
goto done;
}
+
+ memset(&gain_data, 0, sizeof(gain_data));
+ memset(&cfg_data, 0, sizeof(cfg_data));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
+ packed_param_size =
+ sizeof(param_hdr) * 2 + sizeof(gain_data) + sizeof(cfg_data);
+ packed_param_data = kzalloc(packed_param_size, GFP_KERNEL);
+ if (!packed_param_data)
+ return -ENOMEM;
+ packed_param_size = 0;
+
mutex_lock(&this_afe.cal_data[cal_index]->lock);
cal_block = cal_utils_get_only_cal_block(this_afe.cal_data[cal_index]);
if (cal_block == NULL) {
@@ -5571,60 +5405,61 @@
ret = -EINVAL;
goto done;
}
- sidetone_gain = ((struct audio_cal_info_sidetone *)
- cal_block->cal_info)->gain;
- sidetone_enable = ((struct audio_cal_info_sidetone *)
- cal_block->cal_info)->enable;
- mid = ((struct audio_cal_info_sidetone *)
- cal_block->cal_info)->mid;
+
+ /* Cache data from cal block while inside lock to reduce locked time */
+ st_cal_info = (struct audio_cal_info_sidetone *) cal_block->cal_info;
+ sidetone_gain = st_cal_info->gain;
+ sidetone_enable = st_cal_info->enable;
+ mid = st_cal_info->mid;
mutex_unlock(&this_afe.cal_data[cal_index]->lock);
- index = q6audio_get_port_index(tx_port_id);
- cmd_sidetone.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- cmd_sidetone.hdr.pkt_size = sizeof(cmd_sidetone);
- cmd_sidetone.hdr.src_port = 0;
- cmd_sidetone.hdr.dest_port = 0;
- cmd_sidetone.hdr.token = index;
- cmd_sidetone.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- cmd_sidetone.param.port_id = tx_port_id;
- cmd_sidetone.param.payload_size = (sizeof(cmd_sidetone) -
- sizeof(struct apr_hdr) -
- sizeof(struct afe_port_cmd_set_param_v2));
- cmd_sidetone.param.payload_address_lsw = 0x00;
- cmd_sidetone.param.payload_address_msw = 0x00;
- cmd_sidetone.param.mem_map_handle = 0x00;
- cmd_sidetone.gain_pdata.module_id = AFE_MODULE_LOOPBACK;
- cmd_sidetone.gain_pdata.param_id = AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH;
- /*
- * size of actual payload only
- */
- cmd_sidetone.gain_pdata.param_size = sizeof(
- struct afe_loopback_sidetone_gain);
- cmd_sidetone.gain_data.rx_port_id = rx_port_id;
- cmd_sidetone.gain_data.gain = sidetone_gain;
+ /* Set gain data. */
+ param_hdr.module_id = AFE_MODULE_LOOPBACK;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH;
+ param_hdr.param_size = sizeof(struct afe_loopback_sidetone_gain);
+ gain_data.rx_port_id = rx_port_id;
+ gain_data.gain = sidetone_gain;
+ ret = q6common_pack_pp_params(packed_param_data, ¶m_hdr,
+ (u8 *) &gain_data, &single_param_size);
+ if (ret) {
+ pr_err("%s: Failed to pack param data, error %d\n", __func__,
+ ret);
+ goto done;
+ }
+ packed_param_size += single_param_size;
- cmd_sidetone.cfg_pdata.module_id = AFE_MODULE_LOOPBACK;
- cmd_sidetone.cfg_pdata.param_id = AFE_PARAM_ID_LOOPBACK_CONFIG;
- /*
- * size of actual payload only
- */
- cmd_sidetone.cfg_pdata.param_size = sizeof(struct loopback_cfg_data);
- cmd_sidetone.cfg_data.loopback_cfg_minor_version =
- AFE_API_VERSION_LOOPBACK_CONFIG;
- cmd_sidetone.cfg_data.dst_port_id = rx_port_id;
- cmd_sidetone.cfg_data.routing_mode = LB_MODE_SIDETONE;
- cmd_sidetone.cfg_data.enable = enable;
+ /* Set configuration data. */
+ param_hdr.module_id = AFE_MODULE_LOOPBACK;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_LOOPBACK_CONFIG;
+ param_hdr.param_size = sizeof(struct loopback_cfg_data);
+ cfg_data.loopback_cfg_minor_version = AFE_API_VERSION_LOOPBACK_CONFIG;
+ cfg_data.dst_port_id = rx_port_id;
+ cfg_data.routing_mode = LB_MODE_SIDETONE;
+ cfg_data.enable = enable;
+ ret = q6common_pack_pp_params(packed_param_data + packed_param_size,
+ ¶m_hdr, (u8 *) &cfg_data,
+ &single_param_size);
+ if (ret) {
+ pr_err("%s: Failed to pack param data, error %d\n", __func__,
+ ret);
+ goto done;
+ }
+ packed_param_size += single_param_size;
pr_debug("%s rx(0x%x) tx(0x%x) enable(%d) mid(0x%x) gain(%d) sidetone_enable(%d)\n",
__func__, rx_port_id, tx_port_id,
enable, mid, sidetone_gain, sidetone_enable);
- ret = afe_apr_send_pkt(&cmd_sidetone, &this_afe.wait[index]);
+ ret = q6afe_set_params(tx_port_id, q6audio_get_port_index(tx_port_id),
+ NULL, packed_param_data, packed_param_size);
if (ret)
pr_err("%s: AFE sidetone send failed for tx_port:%d rx_port:%d ret:%d\n",
__func__, tx_port_id, rx_port_id, ret);
+
done:
+ kfree(packed_param_data);
return ret;
}
@@ -6035,75 +5870,36 @@
int afe_set_digital_codec_core_clock(u16 port_id,
struct afe_digital_clk_cfg *cfg)
{
- struct afe_lpass_digital_clk_config_command clk_cfg;
- int index = 0;
+ struct afe_digital_clk_cfg clk_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
if (!cfg) {
pr_err("%s: clock cfg is NULL\n", __func__);
- ret = -EINVAL;
- return ret;
+ return -EINVAL;
}
- ret = afe_q6_interface_prepare();
- if (ret != 0) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return ret;
- }
+ memset(&clk_cfg, 0, sizeof(clk_cfg));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
- clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
- clk_cfg.hdr.src_port = 0;
- clk_cfg.hdr.dest_port = 0;
- clk_cfg.hdr.token = index;
-
- clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
/*default rx port is taken to enable the codec digital clock*/
- clk_cfg.param.port_id = q6audio_get_port_id(port_id);
- clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
- - sizeof(clk_cfg.param);
- clk_cfg.param.payload_address_lsw = 0x00;
- clk_cfg.param.payload_address_msw = 0x00;
- clk_cfg.param.mem_map_handle = 0x00;
- clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- clk_cfg.pdata.param_id = AFE_PARAM_ID_INTERNAL_DIGIATL_CDC_CLK_CONFIG;
- clk_cfg.pdata.param_size = sizeof(clk_cfg.clk_cfg);
- clk_cfg.clk_cfg = *cfg;
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_INTERNAL_DIGIATL_CDC_CLK_CONFIG;
+ param_hdr.param_size = sizeof(struct afe_digital_clk_cfg);
+ clk_cfg = *cfg;
pr_debug("%s: Minor version =0x%x clk val = %d\n"
"clk root = 0x%x resrv = 0x%x\n",
- __func__, cfg->i2s_cfg_minor_version,
- cfg->clk_val, cfg->clk_root, cfg->reserved);
+ __func__, cfg->i2s_cfg_minor_version, cfg->clk_val,
+ cfg->clk_root, cfg->reserved);
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
- if (ret < 0) {
- pr_err("%s: AFE enable for port 0x%x ret %d\n",
- __func__, port_id, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
-
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
-
-fail_cmd:
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &clk_cfg);
+ if (ret < 0)
+ pr_err("%s: AFE enable for port 0x%x ret %d\n", __func__,
+ port_id, ret);
return ret;
}
@@ -6117,21 +5913,18 @@
*/
int afe_set_lpass_clock(u16 port_id, struct afe_clk_cfg *cfg)
{
- struct afe_lpass_clk_config_command clk_cfg;
- int index = 0;
+ struct afe_clk_cfg clk_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
if (!cfg) {
pr_err("%s: clock cfg is NULL\n", __func__);
- ret = -EINVAL;
- return ret;
- }
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
return -EINVAL;
}
+
+ memset(&clk_cfg, 0, sizeof(clk_cfg));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
ret = q6audio_is_digital_pcm_interface(port_id);
if (ret < 0) {
pr_err("%s: q6audio_is_digital_pcm_interface fail %d\n",
@@ -6139,31 +5932,12 @@
return -EINVAL;
}
- ret = afe_q6_interface_prepare();
- if (ret != 0) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return ret;
- }
-
mutex_lock(&this_afe.afe_cmd_lock);
- clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
- clk_cfg.hdr.src_port = 0;
- clk_cfg.hdr.dest_port = 0;
- clk_cfg.hdr.token = index;
-
- clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- clk_cfg.param.port_id = q6audio_get_port_id(port_id);
- clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
- - sizeof(clk_cfg.param);
- clk_cfg.param.payload_address_lsw = 0x00;
- clk_cfg.param.payload_address_msw = 0x00;
- clk_cfg.param.mem_map_handle = 0x00;
- clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- clk_cfg.pdata.param_id = AFE_PARAM_ID_LPAIF_CLK_CONFIG;
- clk_cfg.pdata.param_size = sizeof(clk_cfg.clk_cfg);
- clk_cfg.clk_cfg = *cfg;
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_LPAIF_CLK_CONFIG;
+ param_hdr.param_size = sizeof(clk_cfg);
+ clk_cfg = *cfg;
pr_debug("%s: Minor version =0x%x clk val1 = %d\n"
"clk val2 = %d, clk src = 0x%x\n"
@@ -6174,34 +5948,13 @@
cfg->clk_root, cfg->clk_set_mode,
cfg->reserved, q6audio_get_port_id(port_id));
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
- if (ret < 0) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &clk_cfg);
+ if (ret < 0)
pr_err("%s: AFE enable for port 0x%x ret %d\n",
__func__, port_id, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
-
-fail_cmd:
mutex_unlock(&this_afe.afe_cmd_lock);
return ret;
}
@@ -6217,7 +5970,7 @@
*/
int afe_set_lpass_clk_cfg(int index, struct afe_clk_set *cfg)
{
- struct afe_lpass_clk_config_command_v2 clk_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
if (!cfg) {
@@ -6231,6 +5984,8 @@
return -EINVAL;
}
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
ret = afe_q6_interface_prepare();
if (ret != 0) {
pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
@@ -6238,23 +5993,10 @@
}
mutex_lock(&this_afe.afe_cmd_lock);
- clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
- clk_cfg.hdr.src_port = 0;
- clk_cfg.hdr.dest_port = 0;
- clk_cfg.hdr.token = index;
-
- clk_cfg.hdr.opcode = AFE_SVC_CMD_SET_PARAM;
- clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
- - sizeof(clk_cfg.param);
- clk_cfg.param.payload_address_lsw = 0x00;
- clk_cfg.param.payload_address_msw = 0x00;
- clk_cfg.param.mem_map_handle = 0x00;
- clk_cfg.pdata.module_id = AFE_MODULE_CLOCK_SET;
- clk_cfg.pdata.param_id = AFE_PARAM_ID_CLOCK_SET;
- clk_cfg.pdata.param_size = sizeof(clk_cfg.clk_cfg);
- clk_cfg.clk_cfg = *cfg;
+ param_hdr.module_id = AFE_MODULE_CLOCK_SET;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CLOCK_SET;
+ param_hdr.param_size = sizeof(struct afe_clk_set);
pr_debug("%s: Minor version =0x%x clk id = %d\n"
@@ -6264,34 +6006,12 @@
cfg->clk_id, cfg->clk_freq_in_hz, cfg->clk_attri,
cfg->clk_root, cfg->enable);
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
- if (ret < 0) {
+ ret = q6afe_svc_pack_and_set_param_in_band(index, param_hdr,
+ (u8 *) cfg);
+ if (ret < 0)
pr_err("%s: AFE clk cfg failed with ret %d\n",
__func__, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- } else {
- /* set ret to 0 as no timeout happened */
- ret = 0;
- }
- if (atomic_read(&this_afe.status) != 0) {
- pr_err("%s: config cmd failed\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
-
-fail_cmd:
mutex_unlock(&this_afe.afe_cmd_lock);
return ret;
}
@@ -6335,21 +6055,18 @@
int afe_set_lpass_internal_digital_codec_clock(u16 port_id,
struct afe_digital_clk_cfg *cfg)
{
- struct afe_lpass_digital_clk_config_command clk_cfg;
- int index = 0;
+ struct afe_digital_clk_cfg clk_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
if (!cfg) {
pr_err("%s: clock cfg is NULL\n", __func__);
- ret = -EINVAL;
- return ret;
- }
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
return -EINVAL;
}
+
+ memset(&clk_cfg, 0, sizeof(clk_cfg));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
ret = q6audio_is_digital_pcm_interface(port_id);
if (ret < 0) {
pr_err("%s: q6audio_is_digital_pcm_interface fail %d\n",
@@ -6357,30 +6074,11 @@
return -EINVAL;
}
- ret = afe_q6_interface_prepare();
- if (ret != 0) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return ret;
- }
-
- clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
- clk_cfg.hdr.src_port = 0;
- clk_cfg.hdr.dest_port = 0;
- clk_cfg.hdr.token = index;
-
- clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- clk_cfg.param.port_id = q6audio_get_port_id(port_id);
- clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
- - sizeof(clk_cfg.param);
- clk_cfg.param.payload_address_lsw = 0x00;
- clk_cfg.param.payload_address_msw = 0x00;
- clk_cfg.param.mem_map_handle = 0x00;
- clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- clk_cfg.pdata.param_id = AFE_PARAM_ID_INTERNAL_DIGIATL_CDC_CLK_CONFIG;
- clk_cfg.pdata.param_size = sizeof(clk_cfg.clk_cfg);
- clk_cfg.clk_cfg = *cfg;
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_INTERNAL_DIGIATL_CDC_CLK_CONFIG;
+ param_hdr.param_size = sizeof(clk_cfg);
+ clk_cfg = *cfg;
pr_debug("%s: Minor version =0x%x clk val = %d\n"
"clk root = 0x%x resrv = 0x%x port id = 0x%x\n",
@@ -6388,49 +6086,25 @@
cfg->clk_val, cfg->clk_root, cfg->reserved,
q6audio_get_port_id(port_id));
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
- if (ret < 0) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &clk_cfg);
+ if (ret < 0)
pr_err("%s: AFE enable for port 0x0x%x ret %d\n",
__func__, port_id, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
-
-fail_cmd:
return ret;
}
int afe_enable_lpass_core_shared_clock(u16 port_id, u32 enable)
{
- struct afe_lpass_core_shared_clk_config_command clk_cfg;
- int index = 0;
+ struct afe_param_id_lpass_core_shared_clk_cfg clk_cfg;
+ struct param_hdr_v3 param_hdr;
int ret = 0;
- index = q6audio_get_port_index(port_id);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- return -EINVAL;
- }
+ memset(&clk_cfg, 0, sizeof(clk_cfg));
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
ret = q6audio_is_digital_pcm_interface(port_id);
if (ret < 0) {
pr_err("%s: q6audio_is_digital_pcm_interface fail %d\n",
@@ -6438,65 +6112,25 @@
return -EINVAL;
}
- ret = afe_q6_interface_prepare();
- if (ret != 0) {
- pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
- return ret;
- }
-
mutex_lock(&this_afe.afe_cmd_lock);
- clk_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- clk_cfg.hdr.pkt_size = sizeof(clk_cfg);
- clk_cfg.hdr.src_port = 0;
- clk_cfg.hdr.dest_port = 0;
- clk_cfg.hdr.token = index;
-
- clk_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- clk_cfg.param.port_id = q6audio_get_port_id(port_id);
- clk_cfg.param.payload_size = sizeof(clk_cfg) - sizeof(struct apr_hdr)
- - sizeof(clk_cfg.param);
- clk_cfg.param.payload_address_lsw = 0x00;
- clk_cfg.param.payload_address_msw = 0x00;
- clk_cfg.param.mem_map_handle = 0x00;
- clk_cfg.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- clk_cfg.pdata.param_id = AFE_PARAM_ID_LPASS_CORE_SHARED_CLOCK_CONFIG;
- clk_cfg.pdata.param_size = sizeof(clk_cfg.clk_cfg);
- clk_cfg.clk_cfg.lpass_core_shared_clk_cfg_minor_version =
- AFE_API_VERSION_LPASS_CORE_SHARED_CLK_CONFIG;
- clk_cfg.clk_cfg.enable = enable;
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_LPASS_CORE_SHARED_CLOCK_CONFIG;
+ param_hdr.param_size = sizeof(clk_cfg);
+ clk_cfg.lpass_core_shared_clk_cfg_minor_version =
+ AFE_API_VERSION_LPASS_CORE_SHARED_CLK_CONFIG;
+ clk_cfg.enable = enable;
pr_debug("%s: port id = %d, enable = %d\n",
__func__, q6audio_get_port_id(port_id), enable);
- atomic_set(&this_afe.state, 1);
- atomic_set(&this_afe.status, 0);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *) &clk_cfg);
- if (ret < 0) {
+ ret = q6afe_pack_and_set_param_in_band(port_id,
+ q6audio_get_port_index(port_id),
+ param_hdr, (u8 *) &clk_cfg);
+ if (ret < 0)
pr_err("%s: AFE enable for port 0x%x ret %d\n",
__func__, port_id, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
- goto fail_cmd;
- }
-
-fail_cmd:
mutex_unlock(&this_afe.afe_cmd_lock);
return ret;
}
@@ -6519,7 +6153,7 @@
case Q6AFE_LPASS_OSR_CLK_512_kHZ:
break;
default:
- pr_err("%s: deafault freq 0x%x\n",
+ pr_err("%s: default freq 0x%x\n",
__func__, freq);
ret = -EINVAL;
}
@@ -6528,8 +6162,9 @@
int afe_get_sp_th_vi_ftm_data(struct afe_sp_th_vi_get_param *th_vi)
{
+ struct param_hdr_v3 param_hdr;
+ int port = SLIMBUS_4_TX;
int ret = -EINVAL;
- int index = 0, port = SLIMBUS_4_TX;
if (!th_vi) {
pr_err("%s: Invalid params\n", __func__);
@@ -6538,59 +6173,20 @@
if (this_afe.vi_tx_port != -1)
port = this_afe.vi_tx_port;
- ret = q6audio_validate_port(port);
- if (ret < 0) {
- pr_err("%s: invalid port 0x%x ret %d\n", __func__, port, ret);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+
+ param_hdr.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS;
+ param_hdr.param_size = sizeof(struct afe_sp_th_vi_ftm_params);
+
+ ret = q6afe_get_params(port, NULL, ¶m_hdr);
+ if (ret) {
+ pr_err("%s: Failed to get TH VI FTM data\n", __func__);
goto done;
}
- index = q6audio_get_port_index(port);
- if (index < 0) {
- pr_err("%s: invalid port 0x%x, index %d\n",
- __func__, port, index);
- ret = -EINVAL;
- goto done;
- }
- th_vi->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- th_vi->hdr.pkt_size = sizeof(*th_vi);
- th_vi->hdr.src_port = 0;
- th_vi->hdr.dest_port = 0;
- th_vi->hdr.token = index;
- th_vi->hdr.opcode = AFE_PORT_CMD_GET_PARAM_V2;
- th_vi->get_param.mem_map_handle = 0;
- th_vi->get_param.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI;
- th_vi->get_param.param_id = AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS;
- th_vi->get_param.payload_address_lsw = 0;
- th_vi->get_param.payload_address_msw = 0;
- th_vi->get_param.payload_size = sizeof(*th_vi)
- - sizeof(th_vi->get_param) - sizeof(th_vi->hdr);
- th_vi->get_param.port_id = q6audio_get_port_id(port);
- th_vi->pdata.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_TH_VI;
- th_vi->pdata.param_id = AFE_PARAM_ID_SP_V2_TH_VI_FTM_PARAMS;
- th_vi->pdata.param_size = sizeof(th_vi->param);
- atomic_set(&this_afe.status, 0);
- atomic_set(&this_afe.state, 1);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *)th_vi);
- if (ret < 0) {
- pr_err("%s: get param port 0x%x param id[0x%x]failed %d\n",
- __func__, port, th_vi->get_param.param_id, ret);
- goto done;
- }
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto done;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(atomic_read(&this_afe.status));
- goto done;
- }
+
+ th_vi->pdata = param_hdr;
memcpy(&th_vi->param, &this_afe.th_vi_resp.param,
sizeof(this_afe.th_vi_resp.param));
pr_debug("%s: DC resistance %d %d temp %d %d status %d %d\n",
@@ -6607,8 +6203,9 @@
int afe_get_sp_ex_vi_ftm_data(struct afe_sp_ex_vi_get_param *ex_vi)
{
+ struct param_hdr_v3 param_hdr;
+ int port = SLIMBUS_4_TX;
int ret = -EINVAL;
- int index = 0, port = SLIMBUS_4_TX;
if (!ex_vi) {
pr_err("%s: Invalid params\n", __func__);
@@ -6617,61 +6214,21 @@
if (this_afe.vi_tx_port != -1)
port = this_afe.vi_tx_port;
- ret = q6audio_validate_port(port);
- if (ret < 0) {
- pr_err("%s: invalid port 0x%x ret %d\n", __func__, port, ret);
- goto done;
- }
+ memset(¶m_hdr, 0, sizeof(param_hdr));
- index = q6audio_get_port_index(port);
- if (index < 0) {
- pr_err("%s: invalid index %d port 0x%x\n", __func__,
- index, port);
- ret = -EINVAL;
- goto done;
- }
+ param_hdr.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS;
+ param_hdr.param_size = sizeof(struct afe_sp_ex_vi_ftm_params);
- ex_vi->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- ex_vi->hdr.pkt_size = sizeof(*ex_vi);
- ex_vi->hdr.src_port = 0;
- ex_vi->hdr.dest_port = 0;
- ex_vi->hdr.token = index;
- ex_vi->hdr.opcode = AFE_PORT_CMD_GET_PARAM_V2;
- ex_vi->get_param.mem_map_handle = 0;
- ex_vi->get_param.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI;
- ex_vi->get_param.param_id = AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS;
- ex_vi->get_param.payload_address_lsw = 0;
- ex_vi->get_param.payload_address_msw = 0;
- ex_vi->get_param.payload_size = sizeof(*ex_vi)
- - sizeof(ex_vi->get_param) - sizeof(ex_vi->hdr);
- ex_vi->get_param.port_id = q6audio_get_port_id(port);
- ex_vi->pdata.module_id = AFE_MODULE_SPEAKER_PROTECTION_V2_EX_VI;
- ex_vi->pdata.param_id = AFE_PARAM_ID_SP_V2_EX_VI_FTM_PARAMS;
- ex_vi->pdata.param_size = sizeof(ex_vi->param);
- atomic_set(&this_afe.status, 0);
- atomic_set(&this_afe.state, 1);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *)ex_vi);
+ ret = q6afe_get_params(port, NULL, ¶m_hdr);
if (ret < 0) {
pr_err("%s: get param port 0x%x param id[0x%x]failed %d\n",
- __func__, port, ex_vi->get_param.param_id, ret);
+ __func__, port, param_hdr.param_id, ret);
goto done;
}
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto done;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(atomic_read(&this_afe.status));
- goto done;
- }
+
+ ex_vi->pdata = param_hdr;
memcpy(&ex_vi->param, &this_afe.ex_vi_resp.param,
sizeof(this_afe.ex_vi_resp.param));
pr_debug("%s: freq %d %d resistance %d %d qfactor %d %d state %d %d\n",
@@ -6700,80 +6257,29 @@
int afe_get_av_dev_drift(struct afe_param_id_dev_timing_stats *timing_stats,
u16 port)
{
+ struct param_hdr_v3 param_hdr;
int ret = -EINVAL;
- int index = 0;
- struct afe_av_dev_drift_get_param av_dev_drift;
if (!timing_stats) {
pr_err("%s: Invalid params\n", __func__);
goto exit;
}
- ret = q6audio_validate_port(port);
- if (ret < 0) {
- pr_err("%s: invalid port 0x%x ret %d\n", __func__, port, ret);
- ret = -EINVAL;
- goto exit;
- }
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_DEV_TIMING_STATS;
+ param_hdr.param_size = sizeof(struct afe_param_id_dev_timing_stats);
- index = q6audio_get_port_index(port);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: Invalid AFE port index[%d]\n",
- __func__, index);
- ret = -EINVAL;
- goto exit;
- }
-
- memset(&av_dev_drift, 0, sizeof(struct afe_av_dev_drift_get_param));
-
- av_dev_drift.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- av_dev_drift.hdr.pkt_size = sizeof(av_dev_drift);
- av_dev_drift.hdr.src_port = 0;
- av_dev_drift.hdr.dest_port = 0;
- av_dev_drift.hdr.token = index;
- av_dev_drift.hdr.opcode = AFE_PORT_CMD_GET_PARAM_V2;
- av_dev_drift.get_param.mem_map_handle = 0;
- av_dev_drift.get_param.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- av_dev_drift.get_param.param_id = AFE_PARAM_ID_DEV_TIMING_STATS;
- av_dev_drift.get_param.payload_address_lsw = 0;
- av_dev_drift.get_param.payload_address_msw = 0;
- av_dev_drift.get_param.payload_size = sizeof(av_dev_drift)
- - sizeof(av_dev_drift.get_param) - sizeof(av_dev_drift.hdr);
- av_dev_drift.get_param.port_id = q6audio_get_port_id(port);
- av_dev_drift.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
- av_dev_drift.pdata.param_id = AFE_PARAM_ID_DEV_TIMING_STATS;
- av_dev_drift.pdata.param_size = sizeof(av_dev_drift.timing_stats);
- atomic_set(&this_afe.status, 0);
- atomic_set(&this_afe.state, 1);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *)&av_dev_drift);
+ ret = q6afe_get_params(port, NULL, ¶m_hdr);
if (ret < 0) {
pr_err("%s: get param port 0x%x param id[0x%x] failed %d\n",
- __func__, port, av_dev_drift.get_param.param_id, ret);
- goto exit;
- }
-
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto exit;
- }
-
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
+ __func__, port, param_hdr.param_id, ret);
goto exit;
}
memcpy(timing_stats, &this_afe.av_dev_drift_resp.timing_stats,
- sizeof(this_afe.av_dev_drift_resp.timing_stats));
+ param_hdr.param_size);
ret = 0;
exit:
return ret;
@@ -6782,8 +6288,9 @@
int afe_spk_prot_get_calib_data(struct afe_spkr_prot_get_vi_calib *calib_resp)
{
+ struct param_hdr_v3 param_hdr;
+ int port = SLIMBUS_4_TX;
int ret = -EINVAL;
- int index = 0, port = SLIMBUS_4_TX;
if (!calib_resp) {
pr_err("%s: Invalid params\n", __func__);
@@ -6792,60 +6299,16 @@
if (this_afe.vi_tx_port != -1)
port = this_afe.vi_tx_port;
- ret = q6audio_validate_port(port);
- if (ret < 0) {
- pr_err("%s: invalid port 0x%x ret %d\n", __func__, port, ret);
- ret = -EINVAL;
- goto fail_cmd;
- }
- index = q6audio_get_port_index(port);
- if (index < 0 || index >= AFE_MAX_PORTS) {
- pr_err("%s: AFE port index[%d] invalid!\n",
- __func__, index);
- ret = -EINVAL;
- goto fail_cmd;
- }
- calib_resp->hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- calib_resp->hdr.pkt_size = sizeof(*calib_resp);
- calib_resp->hdr.src_port = 0;
- calib_resp->hdr.dest_port = 0;
- calib_resp->hdr.token = index;
- calib_resp->hdr.opcode = AFE_PORT_CMD_GET_PARAM_V2;
- calib_resp->get_param.mem_map_handle = 0;
- calib_resp->get_param.module_id = AFE_MODULE_FB_SPKR_PROT_VI_PROC_V2;
- calib_resp->get_param.param_id = AFE_PARAM_ID_CALIB_RES_CFG_V2;
- calib_resp->get_param.payload_address_lsw = 0;
- calib_resp->get_param.payload_address_msw = 0;
- calib_resp->get_param.payload_size = sizeof(*calib_resp)
- - sizeof(calib_resp->get_param) - sizeof(calib_resp->hdr);
- calib_resp->get_param.port_id = q6audio_get_port_id(port);
- calib_resp->pdata.module_id = AFE_MODULE_FB_SPKR_PROT_VI_PROC_V2;
- calib_resp->pdata.param_id = AFE_PARAM_ID_CALIB_RES_CFG_V2;
- calib_resp->pdata.param_size = sizeof(calib_resp->res_cfg);
- atomic_set(&this_afe.status, 0);
- atomic_set(&this_afe.state, 1);
- ret = apr_send_pkt(this_afe.apr, (uint32_t *)calib_resp);
+ memset(¶m_hdr, 0, sizeof(param_hdr));
+ param_hdr.module_id = AFE_MODULE_FB_SPKR_PROT_VI_PROC_V2;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_id = AFE_PARAM_ID_CALIB_RES_CFG_V2;
+ param_hdr.param_size = sizeof(struct afe_spkr_prot_get_vi_calib);
+
+ ret = q6afe_get_params(port, NULL, ¶m_hdr);
if (ret < 0) {
pr_err("%s: get param port 0x%x param id[0x%x]failed %d\n",
- __func__, port, calib_resp->get_param.param_id, ret);
- goto fail_cmd;
- }
- ret = wait_event_timeout(this_afe.wait[index],
- (atomic_read(&this_afe.state) == 0),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto fail_cmd;
- }
- if (atomic_read(&this_afe.status) > 0) {
- pr_err("%s: config cmd failed [%s]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&this_afe.status)));
- ret = adsp_err_get_lnx_err_code(
- atomic_read(&this_afe.status));
+ __func__, port, param_hdr.param_id, ret);
goto fail_cmd;
}
memcpy(&calib_resp->res_cfg, &this_afe.calib_data.res_cfg,
diff --git a/dsp/q6asm.c b/dsp/q6asm.c
index 4f61fbe..208c7e2 100644
--- a/dsp/q6asm.c
+++ b/dsp/q6asm.c
@@ -39,6 +39,7 @@
#include <dsp/audio_cal_utils.h>
#include <dsp/q6asm-v2.h>
#include <dsp/q6audio-v2.h>
+#include <dsp/q6common.h>
#include "adsp_err.h"
#define TRUE 0x01
@@ -1898,6 +1899,7 @@
if (data->opcode == APR_BASIC_RSP_RESULT) {
switch (payload[0]) {
case ASM_STREAM_CMD_SET_PP_PARAMS_V2:
+ case ASM_STREAM_CMD_SET_PP_PARAMS_V3:
if (rtac_make_asm_callback(ac->session, payload,
data->payload_size))
break;
@@ -1945,9 +1947,12 @@
pr_err("%s: cmd = 0x%x returned error = 0x%x\n",
__func__, payload[0], payload[1]);
if (wakeup_flag) {
- if ((is_adsp_reg_event(payload[0]) >= 0)
- || (payload[0] ==
- ASM_STREAM_CMD_SET_PP_PARAMS_V2))
+ if ((is_adsp_reg_event(payload[0]) >=
+ 0) ||
+ (payload[0] ==
+ ASM_STREAM_CMD_SET_PP_PARAMS_V2) ||
+ (payload[0] ==
+ ASM_STREAM_CMD_SET_PP_PARAMS_V3))
atomic_set(&ac->cmd_state_pp,
payload[1]);
else
@@ -1960,7 +1965,8 @@
return 0;
}
if ((is_adsp_reg_event(payload[0]) >= 0) ||
- (payload[0] == ASM_STREAM_CMD_SET_PP_PARAMS_V2)) {
+ (payload[0] == ASM_STREAM_CMD_SET_PP_PARAMS_V2) ||
+ (payload[0] == ASM_STREAM_CMD_SET_PP_PARAMS_V3)) {
if (atomic_read(&ac->cmd_state_pp) &&
wakeup_flag) {
atomic_set(&ac->cmd_state_pp, 0);
@@ -2005,10 +2011,10 @@
break;
}
case ASM_STREAM_CMD_GET_PP_PARAMS_V2:
- pr_debug("%s: ASM_STREAM_CMD_GET_PP_PARAMS_V2 session %d opcode 0x%x token 0x%x src %d dest %d\n",
- __func__, ac->session,
- data->opcode, data->token,
- data->src_port, data->dest_port);
+ case ASM_STREAM_CMD_GET_PP_PARAMS_V3:
+ pr_debug("%s: ASM_STREAM_CMD_GET_PP_PARAMS session %d opcode 0x%x token 0x%x src %d dest %d\n",
+ __func__, ac->session, data->opcode,
+ data->token, data->src_port, data->dest_port);
/* Should only come here if there is an APR */
/* error or malformed APR packet. Otherwise */
/* response will be returned as */
@@ -2085,13 +2091,13 @@
break;
}
case ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2:
- pr_debug("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 session %d opcode 0x%x token 0x%x src %d dest %d\n",
- __func__, ac->session, data->opcode,
- data->token,
- data->src_port, data->dest_port);
+ case ASM_STREAM_CMDRSP_GET_PP_PARAMS_V3:
+ pr_debug("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS session %d opcode 0x%x token 0x%x src %d dest %d\n",
+ __func__, ac->session, data->opcode, data->token,
+ data->src_port, data->dest_port);
if (payload[0] != 0) {
- pr_err("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 returned error = 0x%x\n",
- __func__, payload[0]);
+ pr_err("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS returned error = 0x%x\n",
+ __func__, payload[0]);
} else if (generic_get_data) {
generic_get_data->valid = 1;
if (generic_get_data->is_inband) {
@@ -2619,6 +2625,174 @@
hdr->pkt_size = pkt_size;
}
+/**
+ * q6asm_set_pp_params
+ * command to set ASM parameter data
+ * send memory mapping header for out of band case
+ * send pre-packed parameter data for in band case
+ *
+ * @ac: audio client handle
+ * @mem_hdr: memory mapping header
+ * @param_data: pre-packed parameter payload
+ * @param_size: size of pre-packed parameter data
+ *
+ * Returns 0 on success or error on failure
+ */
+int q6asm_set_pp_params(struct audio_client *ac,
+ struct mem_mapping_hdr *mem_hdr, u8 *param_data,
+ u32 param_size)
+{
+ struct asm_stream_cmd_set_pp_params *asm_set_param = NULL;
+ int pkt_size = 0;
+ int ret = 0;
+
+ if (ac == NULL) {
+ pr_err("%s: Audio Client is NULL\n", __func__);
+ return -EINVAL;
+ } else if (ac->apr == NULL) {
+ pr_err("%s: APR pointer is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ pkt_size = sizeof(struct asm_stream_cmd_set_pp_params);
+ /* Add param size to packet size when sending in-band only */
+ if (param_data != NULL)
+ pkt_size += param_size;
+ asm_set_param = kzalloc(pkt_size, GFP_KERNEL);
+ if (!asm_set_param)
+ return -ENOMEM;
+
+ q6asm_add_hdr_async(ac, &asm_set_param->apr_hdr, pkt_size, TRUE);
+
+ /* With pre-packed data, only the opcode differs from V2 and V3. */
+ if (q6common_is_instance_id_supported())
+ asm_set_param->apr_hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V3;
+ else
+ asm_set_param->apr_hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
+
+ asm_set_param->payload_size = param_size;
+
+ if (mem_hdr != NULL) {
+ /* Out of band case */
+ asm_set_param->mem_hdr = *mem_hdr;
+ } else if (param_data != NULL) {
+ /*
+ * In band case. Parameter data must be pre-packed with its
+ * header before calling this function. Use
+ * q6common_pack_pp_params to pack parameter data and header
+ * correctly.
+ */
+ memcpy(&asm_set_param->param_data, param_data, param_size);
+ } else {
+ pr_err("%s: Received NULL pointers for both mem header and param data\n",
+ __func__);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ atomic_set(&ac->cmd_state_pp, -1);
+ ret = apr_send_pkt(ac->apr, (uint32_t *)asm_set_param);
+ if (ret < 0) {
+ pr_err("%s: apr send failed rc %d\n", __func__, ret);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ ret = wait_event_timeout(ac->cmd_wait,
+ atomic_read(&ac->cmd_state_pp) >= 0, 5 * HZ);
+ if (!ret) {
+ pr_err("%s: timeout sending apr pkt\n", __func__);
+ ret = -ETIMEDOUT;
+ goto done;
+ }
+
+ if (atomic_read(&ac->cmd_state_pp) > 0) {
+ pr_err("%s: DSP returned error[%s]\n", __func__,
+ adsp_err_get_err_str(atomic_read(&ac->cmd_state_pp)));
+ ret = adsp_err_get_lnx_err_code(atomic_read(&ac->cmd_state_pp));
+ goto done;
+ }
+ ret = 0;
+done:
+ kfree(asm_set_param);
+ return ret;
+}
+EXPORT_SYMBOL(q6asm_set_pp_params);
+
+/**
+ * q6asm_pack_and_set_pp_param_in_band
+ * command to pack and set parameter data for in band case
+ *
+ * @ac: audio client handle
+ * @param_hdr: parameter header
+ * @param_data: parameter data
+ *
+ * Returns 0 on success or error on failure
+ */
+int q6asm_pack_and_set_pp_param_in_band(struct audio_client *ac,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data)
+{
+ u8 *packed_data = NULL;
+ u32 packed_size = sizeof(union param_hdrs) + param_hdr.param_size;
+ int ret = 0;
+
+ if (ac == NULL) {
+ pr_err("%s: Audio Client is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ packed_data = kzalloc(packed_size, GFP_KERNEL);
+ if (packed_data == NULL)
+ return -ENOMEM;
+
+ ret = q6common_pack_pp_params(packed_data, ¶m_hdr, param_data,
+ &packed_size);
+ if (ret) {
+ pr_err("%s: Failed to pack params, error %d\n", __func__, ret);
+ goto done;
+ }
+
+ ret = q6asm_set_pp_params(ac, NULL, packed_data, packed_size);
+done:
+ kfree(packed_data);
+ return ret;
+}
+EXPORT_SYMBOL(q6asm_pack_and_set_pp_param_in_band);
+
+/**
+ * q6asm_set_soft_volume_module_instance_ids
+ * command to set module and instance ids for soft volume
+ *
+ * @instance: soft volume instance
+ * @param_hdr: parameter header
+ *
+ * Returns 0 on success or error on failure
+ */
+int q6asm_set_soft_volume_module_instance_ids(int instance,
+ struct param_hdr_v3 *param_hdr)
+{
+ if (param_hdr == NULL) {
+ pr_err("%s: Param header is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ switch (instance) {
+ case SOFT_VOLUME_INSTANCE_2:
+ param_hdr->module_id = ASM_MODULE_ID_VOL_CTRL2;
+ param_hdr->instance_id = INSTANCE_ID_0;
+ return 0;
+ case SOFT_VOLUME_INSTANCE_1:
+ param_hdr->module_id = ASM_MODULE_ID_VOL_CTRL;
+ param_hdr->instance_id = INSTANCE_ID_0;
+ return 0;
+ default:
+ pr_err("%s: Invalid instance %d\n", __func__, instance);
+ return -EINVAL;
+ }
+}
+EXPORT_SYMBOL(q6asm_set_soft_volume_module_instance_ids);
+
static int __q6asm_open_read(struct audio_client *ac,
uint32_t format, uint16_t bits_per_sample,
uint32_t pcm_format_block_ver,
@@ -7336,67 +7510,28 @@
int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain)
{
struct asm_volume_ctrl_multichannel_gain multi_ch_gain;
- int sz = 0;
+ struct param_hdr_v3 param_info;
int rc = 0;
- if (ac == NULL) {
- pr_err("%s: APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
- if (ac->apr == NULL) {
- pr_err("%s: AC APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
-
+ memset(¶m_info, 0, sizeof(param_info));
memset(&multi_ch_gain, 0, sizeof(multi_ch_gain));
- sz = sizeof(struct asm_volume_ctrl_multichannel_gain);
- q6asm_add_hdr_async(ac, &multi_ch_gain.hdr, sz, TRUE);
- atomic_set(&ac->cmd_state_pp, -1);
- multi_ch_gain.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
- multi_ch_gain.param.data_payload_addr_lsw = 0;
- multi_ch_gain.param.data_payload_addr_msw = 0;
- multi_ch_gain.param.mem_map_handle = 0;
- multi_ch_gain.param.data_payload_size = sizeof(multi_ch_gain) -
- sizeof(multi_ch_gain.hdr) - sizeof(multi_ch_gain.param);
- multi_ch_gain.data.module_id = ASM_MODULE_ID_VOL_CTRL;
- multi_ch_gain.data.param_id = ASM_PARAM_ID_MULTICHANNEL_GAIN;
- multi_ch_gain.data.param_size = multi_ch_gain.param.data_payload_size -
- sizeof(multi_ch_gain.data);
- multi_ch_gain.data.reserved = 0;
+
+ param_info.module_id = ASM_MODULE_ID_VOL_CTRL;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = ASM_PARAM_ID_MULTICHANNEL_GAIN;
+ param_info.param_size = sizeof(multi_ch_gain);
+
multi_ch_gain.gain_data[0].channeltype = PCM_CHANNEL_FL;
multi_ch_gain.gain_data[0].gain = left_gain << 15;
multi_ch_gain.gain_data[1].channeltype = PCM_CHANNEL_FR;
multi_ch_gain.gain_data[1].gain = right_gain << 15;
multi_ch_gain.num_channels = 2;
- rc = apr_send_pkt(ac->apr, (uint32_t *) &multi_ch_gain);
- if (rc < 0) {
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
+ (u8 *) &multi_ch_gain);
+ if (rc < 0)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
- __func__, multi_ch_gain.data.param_id, rc);
- rc = -EINVAL;
- goto fail_cmd;
- }
+ __func__, param_info.param_id, rc);
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
- if (!rc) {
- pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
- multi_ch_gain.data.param_id);
- rc = -ETIMEDOUT;
- goto fail_cmd;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%s] , set-params paramid[0x%x]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&ac->cmd_state_pp)),
- multi_ch_gain.data.param_id);
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&ac->cmd_state_pp));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
return rc;
}
@@ -7412,20 +7547,14 @@
uint32_t *gains, uint8_t *ch_map, bool use_default)
{
struct asm_volume_ctrl_multichannel_gain multich_gain;
- int sz = 0;
+ struct param_hdr_v3 param_info;
int rc = 0;
int i;
u8 default_chmap[VOLUME_CONTROL_MAX_CHANNELS];
if (ac == NULL) {
- pr_err("%s: ac is NULL\n", __func__);
- rc = -EINVAL;
- goto done;
- }
- if (ac->apr == NULL) {
- dev_err(ac->dev, "%s: AC APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto done;
+ pr_err("%s: Audio client is NULL\n", __func__);
+ return -EINVAL;
}
if (gains == NULL) {
dev_err(ac->dev, "%s: gain_list is NULL\n", __func__);
@@ -7444,21 +7573,12 @@
goto done;
}
+ memset(¶m_info, 0, sizeof(param_info));
memset(&multich_gain, 0, sizeof(multich_gain));
- sz = sizeof(struct asm_volume_ctrl_multichannel_gain);
- q6asm_add_hdr_async(ac, &multich_gain.hdr, sz, TRUE);
- atomic_set(&ac->cmd_state_pp, -1);
- multich_gain.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
- multich_gain.param.data_payload_addr_lsw = 0;
- multich_gain.param.data_payload_addr_msw = 0;
- multich_gain.param.mem_map_handle = 0;
- multich_gain.param.data_payload_size = sizeof(multich_gain) -
- sizeof(multich_gain.hdr) - sizeof(multich_gain.param);
- multich_gain.data.module_id = ASM_MODULE_ID_VOL_CTRL;
- multich_gain.data.param_id = ASM_PARAM_ID_MULTICHANNEL_GAIN;
- multich_gain.data.param_size = multich_gain.param.data_payload_size -
- sizeof(multich_gain.data);
- multich_gain.data.reserved = 0;
+ param_info.module_id = ASM_MODULE_ID_VOL_CTRL;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = ASM_PARAM_ID_MULTICHANNEL_GAIN;
+ param_info.param_size = sizeof(multich_gain);
if (use_default) {
rc = q6asm_map_channels(default_chmap, channels, false);
@@ -7477,29 +7597,11 @@
}
multich_gain.num_channels = channels;
- rc = apr_send_pkt(ac->apr, (uint32_t *) &multich_gain);
- if (rc < 0) {
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
+ (u8 *) &multich_gain);
+ if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
- __func__, multich_gain.data.param_id, rc);
- goto done;
- }
-
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
- if (!rc) {
- pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
- multich_gain.data.param_id);
- rc = -EINVAL;
- goto done;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%d] , set-params paramid[0x%x]\n",
- __func__, atomic_read(&ac->cmd_state_pp),
- multich_gain.data.param_id);
- rc = -EINVAL;
- goto done;
- }
- rc = 0;
+ __func__, param_info.param_id, rc);
done:
return rc;
}
@@ -7517,62 +7619,21 @@
int q6asm_set_mute(struct audio_client *ac, int muteflag)
{
struct asm_volume_ctrl_mute_config mute;
- int sz = 0;
+ struct param_hdr_v3 param_info;
int rc = 0;
- if (ac == NULL) {
- pr_err("%s: APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
- if (ac->apr == NULL) {
- pr_err("%s: AC APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
-
- sz = sizeof(struct asm_volume_ctrl_mute_config);
- q6asm_add_hdr_async(ac, &mute.hdr, sz, TRUE);
- atomic_set(&ac->cmd_state_pp, -1);
- mute.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
- mute.param.data_payload_addr_lsw = 0;
- mute.param.data_payload_addr_msw = 0;
- mute.param.mem_map_handle = 0;
- mute.param.data_payload_size = sizeof(mute) -
- sizeof(mute.hdr) - sizeof(mute.param);
- mute.data.module_id = ASM_MODULE_ID_VOL_CTRL;
- mute.data.param_id = ASM_PARAM_ID_VOL_CTRL_MUTE_CONFIG;
- mute.data.param_size = mute.param.data_payload_size - sizeof(mute.data);
- mute.data.reserved = 0;
+ memset(&mute, 0, sizeof(mute));
+ memset(¶m_info, 0, sizeof(param_info));
+ param_info.module_id = ASM_MODULE_ID_VOL_CTRL;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = ASM_PARAM_ID_VOL_CTRL_MUTE_CONFIG;
+ param_info.param_size = sizeof(mute);
mute.mute_flag = muteflag;
- rc = apr_send_pkt(ac->apr, (uint32_t *) &mute);
- if (rc < 0) {
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info, (u8 *) &mute);
+ if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
- __func__, mute.data.param_id, rc);
- rc = -EINVAL;
- goto fail_cmd;
- }
-
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
- if (!rc) {
- pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
- mute.data.param_id);
- rc = -ETIMEDOUT;
- goto fail_cmd;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&ac->cmd_state_pp)),
- mute.data.param_id);
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&ac->cmd_state_pp));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
+ __func__, param_info.param_id, rc);
return rc;
}
EXPORT_SYMBOL(q6asm_set_mute);
@@ -7580,74 +7641,28 @@
static int __q6asm_set_volume(struct audio_client *ac, int volume, int instance)
{
struct asm_volume_ctrl_master_gain vol;
- int sz = 0;
- int rc = 0;
- int module_id;
+ struct param_hdr_v3 param_info;
+ int rc = 0;
- if (ac == NULL) {
- pr_err("%s: APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
- if (ac->apr == NULL) {
- pr_err("%s: AC APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
+ memset(&vol, 0, sizeof(vol));
+ memset(¶m_info, 0, sizeof(param_info));
+
+ rc = q6asm_set_soft_volume_module_instance_ids(instance, ¶m_info);
+ if (rc) {
+ pr_err("%s: Failed to pack soft volume module and instance IDs, error %d\n",
+ __func__, rc);
+ return rc;
}
- switch (instance) {
- case SOFT_VOLUME_INSTANCE_2:
- module_id = ASM_MODULE_ID_VOL_CTRL2;
- break;
- case SOFT_VOLUME_INSTANCE_1:
- default:
- module_id = ASM_MODULE_ID_VOL_CTRL;
- break;
- }
-
- sz = sizeof(struct asm_volume_ctrl_master_gain);
- q6asm_add_hdr_async(ac, &vol.hdr, sz, TRUE);
- atomic_set(&ac->cmd_state_pp, -1);
- vol.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
- vol.param.data_payload_addr_lsw = 0;
- vol.param.data_payload_addr_msw = 0;
- vol.param.mem_map_handle = 0;
- vol.param.data_payload_size = sizeof(vol) -
- sizeof(vol.hdr) - sizeof(vol.param);
- vol.data.module_id = module_id;
- vol.data.param_id = ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN;
- vol.data.param_size = vol.param.data_payload_size - sizeof(vol.data);
- vol.data.reserved = 0;
+ param_info.param_id = ASM_PARAM_ID_VOL_CTRL_MASTER_GAIN;
+ param_info.param_size = sizeof(vol);
vol.master_gain = volume;
- rc = apr_send_pkt(ac->apr, (uint32_t *) &vol);
- if (rc < 0) {
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info, (u8 *) &vol);
+ if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
- __func__, vol.data.param_id, rc);
- rc = -EINVAL;
- goto fail_cmd;
- }
+ __func__, param_info.param_id, rc);
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
- if (!rc) {
- pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
- vol.data.param_id);
- rc = -ETIMEDOUT;
- goto fail_cmd;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&ac->cmd_state_pp)),
- vol.data.param_id);
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&ac->cmd_state_pp));
- goto fail_cmd;
- }
-
- rc = 0;
-fail_cmd:
return rc;
}
@@ -7925,67 +7940,27 @@
struct asm_softpause_params *pause_param)
{
struct asm_soft_pause_params softpause;
- int sz = 0;
+ struct param_hdr_v3 param_info;
int rc = 0;
- if (ac == NULL) {
- pr_err("%s: APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
- if (ac->apr == NULL) {
- pr_err("%s: AC APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
+ memset(&softpause, 0, sizeof(softpause));
+ memset(¶m_info, 0, sizeof(param_info));
+ param_info.module_id = ASM_MODULE_ID_VOL_CTRL;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = ASM_PARAM_ID_SOFT_PAUSE_PARAMETERS;
+ param_info.param_size = sizeof(softpause);
- sz = sizeof(struct asm_soft_pause_params);
- q6asm_add_hdr_async(ac, &softpause.hdr, sz, TRUE);
- atomic_set(&ac->cmd_state_pp, -1);
- softpause.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
-
- softpause.param.data_payload_addr_lsw = 0;
- softpause.param.data_payload_addr_msw = 0;
- softpause.param.mem_map_handle = 0;
- softpause.param.data_payload_size = sizeof(softpause) -
- sizeof(softpause.hdr) - sizeof(softpause.param);
- softpause.data.module_id = ASM_MODULE_ID_VOL_CTRL;
- softpause.data.param_id = ASM_PARAM_ID_SOFT_PAUSE_PARAMETERS;
- softpause.data.param_size = softpause.param.data_payload_size -
- sizeof(softpause.data);
- softpause.data.reserved = 0;
softpause.enable_flag = pause_param->enable;
softpause.period = pause_param->period;
softpause.step = pause_param->step;
softpause.ramping_curve = pause_param->rampingcurve;
- rc = apr_send_pkt(ac->apr, (uint32_t *) &softpause);
- if (rc < 0) {
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
+ (u8 *) &softpause);
+ if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
- __func__, softpause.data.param_id, rc);
- rc = -EINVAL;
- goto fail_cmd;
- }
+ __func__, param_info.param_id, rc);
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
- if (!rc) {
- pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
- softpause.data.param_id);
- rc = -ETIMEDOUT;
- goto fail_cmd;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&ac->cmd_state_pp)),
- softpause.data.param_id);
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&ac->cmd_state_pp));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
return rc;
}
EXPORT_SYMBOL(q6asm_set_softpause);
@@ -7995,76 +7970,32 @@
int instance)
{
struct asm_soft_step_volume_params softvol;
- int sz = 0;
- int rc = 0;
- int module_id;
+ struct param_hdr_v3 param_info;
+ int rc = 0;
- if (ac == NULL) {
- pr_err("%s: APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
- if (ac->apr == NULL) {
- pr_err("%s: AC APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
+ memset(&softvol, 0, sizeof(softvol));
+ memset(¶m_info, 0, sizeof(param_info));
+
+ rc = q6asm_set_soft_volume_module_instance_ids(instance, ¶m_info);
+ if (rc) {
+ pr_err("%s: Failed to pack soft volume module and instance IDs, error %d\n",
+ __func__, rc);
+ return rc;
}
- switch (instance) {
- case SOFT_VOLUME_INSTANCE_2:
- module_id = ASM_MODULE_ID_VOL_CTRL2;
- break;
- case SOFT_VOLUME_INSTANCE_1:
- default:
- module_id = ASM_MODULE_ID_VOL_CTRL;
- break;
- }
+ param_info.param_id = ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS;
+ param_info.param_size = sizeof(softvol);
- sz = sizeof(struct asm_soft_step_volume_params);
- q6asm_add_hdr_async(ac, &softvol.hdr, sz, TRUE);
- atomic_set(&ac->cmd_state_pp, -1);
- softvol.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
- softvol.param.data_payload_addr_lsw = 0;
- softvol.param.data_payload_addr_msw = 0;
- softvol.param.mem_map_handle = 0;
- softvol.param.data_payload_size = sizeof(softvol) -
- sizeof(softvol.hdr) - sizeof(softvol.param);
- softvol.data.module_id = module_id;
- softvol.data.param_id = ASM_PARAM_ID_SOFT_VOL_STEPPING_PARAMETERS;
- softvol.data.param_size = softvol.param.data_payload_size -
- sizeof(softvol.data);
- softvol.data.reserved = 0;
softvol.period = softvol_param->period;
softvol.step = softvol_param->step;
softvol.ramping_curve = softvol_param->rampingcurve;
- rc = apr_send_pkt(ac->apr, (uint32_t *) &softvol);
- if (rc < 0) {
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info,
+ (u8 *) &softvol);
+ if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
- __func__, softvol.data.param_id, rc);
- rc = -EINVAL;
- goto fail_cmd;
- }
+ __func__, param_info.param_id, rc);
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
- if (!rc) {
- pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
- softvol.data.param_id);
- rc = -ETIMEDOUT;
- goto fail_cmd;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&ac->cmd_state_pp)),
- softvol.data.param_id);
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&ac->cmd_state_pp));
- goto fail_cmd;
- }
- rc = 0;
-fail_cmd:
return rc;
}
@@ -8116,40 +8047,27 @@
{
struct asm_eq_params eq;
struct msm_audio_eq_stream_config *eq_params = NULL;
+ struct param_hdr_v3 param_info;
int i = 0;
- int sz = 0;
int rc = 0;
if (ac == NULL) {
- pr_err("%s: APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
+ pr_err("%s: Audio client is NULL\n", __func__);
+ return -EINVAL;
}
- if (ac->apr == NULL) {
- pr_err("%s: AC APR handle NULL\n", __func__);
- rc = -EINVAL;
- goto fail_cmd;
- }
-
if (eq_p == NULL) {
pr_err("%s: [%d]: Invalid Eq param\n", __func__, ac->session);
rc = -EINVAL;
goto fail_cmd;
}
- sz = sizeof(struct asm_eq_params);
- eq_params = (struct msm_audio_eq_stream_config *) eq_p;
- q6asm_add_hdr(ac, &eq.hdr, sz, TRUE);
- atomic_set(&ac->cmd_state_pp, -1);
- eq.hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
- eq.param.data_payload_addr_lsw = 0;
- eq.param.data_payload_addr_msw = 0;
- eq.param.mem_map_handle = 0;
- eq.param.data_payload_size = sizeof(eq) -
- sizeof(eq.hdr) - sizeof(eq.param);
- eq.data.module_id = ASM_MODULE_ID_EQUALIZER;
- eq.data.param_id = ASM_PARAM_ID_EQUALIZER_PARAMETERS;
- eq.data.param_size = eq.param.data_payload_size - sizeof(eq.data);
+ memset(&eq, 0, sizeof(eq));
+ memset(¶m_info, 0, sizeof(param_info));
+ eq_params = (struct msm_audio_eq_stream_config *) eq_p;
+ param_info.module_id = ASM_MODULE_ID_EQUALIZER;
+ param_info.instance_id = INSTANCE_ID_0;
+ param_info.param_id = ASM_PARAM_ID_EQUALIZER_PARAMETERS;
+ param_info.param_size = sizeof(eq);
eq.enable_flag = eq_params->enable;
eq.num_bands = eq_params->num_bands;
@@ -8175,32 +8093,11 @@
pr_debug("%s: q_factor:%d bandnum:%d\n", __func__,
eq_params->eq_bands[i].q_factor, i);
}
- rc = apr_send_pkt(ac->apr, (uint32_t *)&eq);
- if (rc < 0) {
+ rc = q6asm_pack_and_set_pp_param_in_band(ac, param_info, (u8 *) &eq);
+ if (rc)
pr_err("%s: set-params send failed paramid[0x%x] rc %d\n",
- __func__, eq.data.param_id, rc);
- rc = -EINVAL;
- goto fail_cmd;
- }
+ __func__, param_info.param_id, rc);
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 5*HZ);
- if (!rc) {
- pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
- eq.data.param_id);
- rc = -ETIMEDOUT;
- goto fail_cmd;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%s] set-params paramid[0x%x]\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&ac->cmd_state_pp)),
- eq.data.param_id);
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&ac->cmd_state_pp));
- goto fail_cmd;
- }
- rc = 0;
fail_cmd:
return rc;
}
@@ -8797,7 +8694,7 @@
mtmx_params.param_info.param_id =
ASM_SESSION_MTMX_STRTR_PARAM_SESSION_TIME_V3;
mtmx_params.param_info.param_max_size =
- sizeof(struct asm_stream_param_data_v2) +
+ sizeof(struct param_hdr_v1) +
sizeof(struct asm_session_mtmx_strtr_param_session_time_v3_t);
atomic_set(&ac->time_flag, 1);
@@ -8882,89 +8779,6 @@
EXPORT_SYMBOL(q6asm_get_session_time_legacy);
/**
- * q6asm_send_audio_effects_params -
- * command to send audio effects params
- *
- * @ac: Audio client handle
- * @params: audio effects params
- * @params_length: size of params
- *
- * Returns 0 on success or error on failure
- */
-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) {
- pr_err("%s: APR handle NULL\n", __func__);
- return -EINVAL;
- }
- if (ac->apr == NULL) {
- pr_err("%s: AC APR handle NULL\n", __func__);
- return -EINVAL;
- }
- if (params == NULL) {
- pr_err("%s: params NULL\n", __func__);
- 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, asm 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);
- atomic_set(&ac->cmd_state_pp, -1);
- 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__);
- rc = -EINVAL;
- goto fail_send_param;
- }
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 1*HZ);
- if (!rc) {
- pr_err("%s: timeout, audio effects set-params\n", __func__);
- rc = -ETIMEDOUT;
- goto fail_send_param;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%s] set-params\n",
- __func__, adsp_err_get_err_str(
- atomic_read(&ac->cmd_state_pp)));
- rc = adsp_err_get_lnx_err_code(
- atomic_read(&ac->cmd_state_pp));
- goto fail_send_param;
- }
-
- rc = 0;
-fail_send_param:
- kfree(asm_params);
- return rc;
-}
-EXPORT_SYMBOL(q6asm_send_audio_effects_params);
-
-/**
* q6asm_send_mtmx_strtr_window -
* command to send matrix for window params
*
@@ -9006,7 +8820,7 @@
matrix.param.data_payload_addr_msw = 0;
matrix.param.mem_map_handle = 0;
matrix.param.data_payload_size =
- sizeof(struct asm_stream_param_data_v2) +
+ sizeof(struct param_hdr_v1) +
sizeof(struct asm_session_mtmx_strtr_param_window_v2_t);
matrix.param.direction = 0; /* RX */
matrix.data.module_id = ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
@@ -9101,7 +8915,7 @@
matrix.param.data_payload_addr_msw = 0;
matrix.param.mem_map_handle = 0;
matrix.param.data_payload_size =
- sizeof(struct asm_stream_param_data_v2) +
+ sizeof(struct param_hdr_v1) +
sizeof(struct asm_session_mtmx_strtr_param_render_mode_t);
matrix.param.direction = 0; /* RX */
matrix.data.module_id = ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
@@ -9196,7 +9010,7 @@
matrix.param.data_payload_addr_msw = 0;
matrix.param.mem_map_handle = 0;
matrix.param.data_payload_size =
- sizeof(struct asm_stream_param_data_v2) +
+ sizeof(struct param_hdr_v1) +
sizeof(struct asm_session_mtmx_strtr_param_clk_rec_t);
matrix.param.direction = 0; /* RX */
matrix.data.module_id = ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
@@ -9281,7 +9095,7 @@
matrix.param.data_payload_addr_msw = 0;
matrix.param.mem_map_handle = 0;
matrix.param.data_payload_size =
- sizeof(struct asm_stream_param_data_v2) +
+ sizeof(struct param_hdr_v1) +
sizeof(struct asm_session_mtmx_param_adjust_session_time_ctl_t);
matrix.param.direction = 0; /* RX */
matrix.data.module_id = ASM_SESSION_MTMX_STRTR_MODULE_ID_AVSYNC;
@@ -10010,20 +9824,14 @@
int q6asm_send_cal(struct audio_client *ac)
{
struct cal_block_data *cal_block = NULL;
- struct apr_hdr hdr;
- char *asm_params = NULL;
- struct asm_stream_cmd_set_pp_params_v2 payload_params;
- int sz, rc = -EINVAL;
-
+ struct mem_mapping_hdr mem_hdr;
+ u32 payload_size = 0;
+ int rc = -EINVAL;
pr_debug("%s:\n", __func__);
if (!ac) {
- pr_err("%s: APR handle NULL\n", __func__);
- goto done;
- }
- if (ac->apr == NULL) {
- pr_err("%s: AC APR handle NULL\n", __func__);
- goto done;
+ pr_err("%s: Audio client is NULL\n", __func__);
+ return -EINVAL;
}
if (ac->io_mode & NT_MODE) {
pr_debug("%s: called for NT MODE, exiting\n", __func__);
@@ -10038,6 +9846,7 @@
goto done;
}
+ memset(&mem_hdr, 0, sizeof(mem_hdr));
mutex_lock(&cal_data[ASM_AUDSTRM_CAL]->lock);
cal_block = cal_utils_get_only_cal_block(cal_data[ASM_AUDSTRM_CAL]);
if (cal_block == NULL) {
@@ -10060,62 +9869,26 @@
goto unlock;
}
- sz = sizeof(struct apr_hdr) +
- sizeof(struct asm_stream_cmd_set_pp_params_v2);
- asm_params = kzalloc(sz, GFP_KERNEL);
- if (!asm_params) {
- pr_err("%s, asm params memory alloc failed", __func__);
- rc = -ENOMEM;
- goto unlock;
- }
-
- /* asm_stream_cmd_set_pp_params_v2 has no APR header in it */
- q6asm_add_hdr_async(ac, &hdr, (sizeof(struct apr_hdr) +
- sizeof(struct asm_stream_cmd_set_pp_params_v2)), TRUE);
-
- atomic_set(&ac->cmd_state_pp, -1);
- hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS_V2;
- payload_params.data_payload_addr_lsw =
- lower_32_bits(cal_block->cal_data.paddr);
- payload_params.data_payload_addr_msw =
- msm_audio_populate_upper_32_bits(
- cal_block->cal_data.paddr);
- payload_params.mem_map_handle = cal_block->map_data.q6map_handle;
- payload_params.data_payload_size = cal_block->cal_data.size;
- 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));
+ mem_hdr.data_payload_addr_lsw =
+ lower_32_bits(cal_block->cal_data.paddr);
+ mem_hdr.data_payload_addr_msw =
+ msm_audio_populate_upper_32_bits(cal_block->cal_data.paddr);
+ mem_hdr.mem_map_handle = cal_block->map_data.q6map_handle;
+ payload_size = cal_block->cal_data.size;
pr_debug("%s: phyaddr lsw = %x msw = %x, maphdl = %x calsize = %d\n",
- __func__, payload_params.data_payload_addr_lsw,
- payload_params.data_payload_addr_msw,
- payload_params.mem_map_handle,
- payload_params.data_payload_size);
+ __func__, mem_hdr.data_payload_addr_lsw,
+ mem_hdr.data_payload_addr_msw, mem_hdr.mem_map_handle,
+ payload_size);
- rc = apr_send_pkt(ac->apr, (uint32_t *) asm_params);
- if (rc < 0) {
+ rc = q6asm_set_pp_params(ac, &mem_hdr, NULL, payload_size);
+ if (rc) {
pr_err("%s: audio audstrm cal send failed\n", __func__);
- rc = -EINVAL;
- goto free;
- }
- rc = wait_event_timeout(ac->cmd_wait,
- (atomic_read(&ac->cmd_state_pp) >= 0), 5 * HZ);
- if (!rc) {
- pr_err("%s: timeout, audio audstrm cal send\n", __func__);
- rc = -ETIMEDOUT;
- goto free;
- }
- if (atomic_read(&ac->cmd_state_pp) > 0) {
- pr_err("%s: DSP returned error[%d] audio audstrm cal send\n",
- __func__, atomic_read(&ac->cmd_state_pp));
- rc = -EINVAL;
- goto free;
+ goto unlock;
}
rc = 0;
-free:
- kfree(asm_params);
unlock:
mutex_unlock(&cal_data[ASM_AUDSTRM_CAL]->lock);
done:
diff --git a/dsp/q6voice.c b/dsp/q6voice.c
index 801e761..788805e 100644
--- a/dsp/q6voice.c
+++ b/dsp/q6voice.c
@@ -7456,6 +7456,7 @@
data->payload_size);
break;
case VSS_ICOMMON_CMD_GET_PARAM_V2:
+ case VSS_ICOMMON_CMD_GET_PARAM_V3:
pr_debug("%s: VSS_ICOMMON_CMD_GET_PARAM_V2\n",
__func__);
/* Should only come here if there is an APR */
@@ -7589,7 +7590,8 @@
pr_debug("Recd VSS_ISTREAM_EVT_NOT_READY\n");
} else if (data->opcode == VSS_ISTREAM_EVT_READY) {
pr_debug("Recd VSS_ISTREAM_EVT_READY\n");
- } else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM) {
+ } else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM ||
+ VSS_ICOMMON_RSP_GET_PARAM_V3) {
pr_debug("%s: VSS_ICOMMON_RSP_GET_PARAM\n", __func__);
ptr = data->payload;
if (ptr[0] != 0) {
@@ -7747,12 +7749,13 @@
data->payload_size);
break;
default:
- pr_debug("%s: invalid token for command VSS_ICOMMON_CMD_SET_PARAM_V2: %d\n",
+ pr_debug("%s: invalid token for command VSS_ICOMMON_CMD_SET_PARAM: %d\n",
__func__, data->token);
break;
}
break;
case VSS_ICOMMON_CMD_GET_PARAM_V2:
+ case VSS_ICOMMON_CMD_GET_PARAM_V3:
pr_debug("%s: VSS_ICOMMON_CMD_GET_PARAM_V2\n",
__func__);
/* Should only come here if there is an APR */
@@ -7819,7 +7822,8 @@
break;
}
}
- } else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM) {
+ } else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM ||
+ VSS_ICOMMON_RSP_GET_PARAM_V3) {
pr_debug("%s: VSS_ICOMMON_RSP_GET_PARAM\n", __func__);
ptr = data->payload;
if (ptr[0] != 0) {
diff --git a/dsp/rtac.c b/dsp/rtac.c
index 0785f56..d233635 100644
--- a/dsp/rtac.c
+++ b/dsp/rtac.c
@@ -27,6 +27,7 @@
#include <dsp/q6afe-v2.h>
#include <dsp/q6adm-v2.h>
#include <dsp/apr_audio-v2.h>
+#include <dsp/q6common.h>
#include <dsp/q6voice.h>
#include "adsp_err.h"
@@ -103,14 +104,10 @@
uint32_t cmd_size;
uint32_t port_id;
union {
- struct rtac_afe_set {
- struct afe_port_cmd_set_param_v2 cmd;
- struct afe_port_param_data_v2 data;
- } rtac_afe_set;
- struct rtac_afe_get {
- struct afe_port_cmd_get_param_v2 cmd;
- struct afe_port_param_data_v2 data;
- } rtac_afe_get;
+ struct afe_rtac_user_data_set_v2 v2_set;
+ struct afe_rtac_user_data_set_v3 v3_set;
+ struct afe_rtac_user_data_get_v2 v2_get;
+ struct afe_rtac_user_data_get_v3 v3_get;
};
} __packed;
@@ -804,7 +801,9 @@
goto err;
}
- if (opcode == ADM_CMD_SET_PP_PARAMS_V5) {
+ switch (opcode) {
+ case ADM_CMD_SET_PP_PARAMS_V5:
+ case ADM_CMD_SET_PP_PARAMS_V6:
/* set payload size to in-band payload */
/* set data size to actual out of band payload size */
data_size = payload_size - 4 * sizeof(u32);
@@ -822,12 +821,15 @@
buf + 7 * sizeof(u32), data_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
- result = -EINVAL;
+ result = -EFAULT;
goto err;
}
+
/* set payload size in packet */
rtac_adm_buffer[8] = data_size;
- } else {
+ break;
+ case ADM_CMD_GET_PP_PARAMS_V5:
+ case ADM_CMD_GET_PP_PARAMS_V6:
if (payload_size > MAX_PAYLOAD_SIZE) {
pr_err("%s: Invalid payload size = %d\n",
__func__, payload_size);
@@ -841,9 +843,14 @@
buf + 3 * sizeof(u32), payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
- result = -EINVAL;
+ result = -EFAULT;
goto err;
}
+ break;
+ default:
+ pr_err("%s: Invalid opcode %d\n", __func__, opcode);
+ result = -EINVAL;
+ goto err;
}
/* Pack header */
@@ -904,33 +911,39 @@
if (opcode == ADM_CMD_GET_PP_PARAMS_V5) {
bytes_returned = ((u32 *)rtac_cal[ADM_RTAC_CAL].cal_data.
kvaddr)[2] + 3 * sizeof(u32);
-
- if (bytes_returned > rtac_cal[ADM_RTAC_CAL].
- map_data.map_size) {
- pr_err("%s: Invalid data size = %d\n",
- __func__, bytes_returned);
- result = -EINVAL;
- goto err;
- }
-
- if (bytes_returned > user_buf_size) {
- pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
- __func__, user_buf_size, bytes_returned);
- result = -EINVAL;
- goto err;
- }
-
- if (copy_to_user(buf, (void *)
- rtac_cal[ADM_RTAC_CAL].cal_data.kvaddr,
- bytes_returned)) {
- pr_err("%s: Could not copy buffer to user,size = %d\n",
- __func__, bytes_returned);
- result = -EINVAL;
- goto err;
- }
+ } else if (opcode == ADM_CMD_GET_PP_PARAMS_V6) {
+ bytes_returned =
+ ((u32 *) rtac_cal[ADM_RTAC_CAL].cal_data.kvaddr)[3] +
+ 4 * sizeof(u32);
} else {
bytes_returned = data_size;
+ goto unlock;
}
+
+ if (bytes_returned > rtac_cal[ADM_RTAC_CAL].map_data.map_size) {
+ pr_err("%s: Invalid data size = %d\n", __func__,
+ bytes_returned);
+ result = -EINVAL;
+ goto err;
+ }
+
+ if (bytes_returned > user_buf_size) {
+ pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
+ __func__, user_buf_size, bytes_returned);
+ result = -EINVAL;
+ goto err;
+ }
+
+ if (copy_to_user((void __user *) buf,
+ rtac_cal[ADM_RTAC_CAL].cal_data.kvaddr,
+ bytes_returned)) {
+ pr_err("%s: Could not copy buffer to user,size = %d\n",
+ __func__, bytes_returned);
+ result = -EFAULT;
+ goto err;
+ }
+
+unlock:
mutex_unlock(&rtac_adm_apr_mutex);
done:
return bytes_returned;
@@ -1032,7 +1045,9 @@
goto err;
}
- if (opcode == ASM_STREAM_CMD_SET_PP_PARAMS_V2) {
+ switch (opcode) {
+ case ASM_STREAM_CMD_SET_PP_PARAMS_V2:
+ case ASM_STREAM_CMD_SET_PP_PARAMS_V3:
/* set payload size to in-band payload */
/* set data size to actual out of band payload size */
data_size = payload_size - 4 * sizeof(u32);
@@ -1050,13 +1065,14 @@
buf + 7 * sizeof(u32), data_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
- result = -EINVAL;
+ result = -EFAULT;
goto err;
}
/* set payload size in packet */
rtac_asm_buffer[8] = data_size;
-
- } else {
+ break;
+ case ASM_STREAM_CMD_GET_PP_PARAMS_V2:
+ case ASM_STREAM_CMD_GET_PP_PARAMS_V3:
if (payload_size > MAX_PAYLOAD_SIZE) {
pr_err("%s: Invalid payload size = %d\n",
__func__, payload_size);
@@ -1070,9 +1086,15 @@
buf + 3 * sizeof(u32), payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
- result = -EINVAL;
+ result = -EFAULT;
goto err;
}
+
+ break;
+ default:
+ pr_err("%s: Invalid opcode %d\n", __func__, opcode);
+ result = -EINVAL;
+ goto err;
}
/* Pack header */
@@ -1135,33 +1157,39 @@
if (opcode == ASM_STREAM_CMD_GET_PP_PARAMS_V2) {
bytes_returned = ((u32 *)rtac_cal[ASM_RTAC_CAL].cal_data.
kvaddr)[2] + 3 * sizeof(u32);
-
- if (bytes_returned > rtac_cal[ASM_RTAC_CAL].
- map_data.map_size) {
- pr_err("%s: Invalid data size = %d\n",
- __func__, bytes_returned);
- result = -EINVAL;
- goto err;
- }
-
- if (bytes_returned > user_buf_size) {
- pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
- __func__, user_buf_size, bytes_returned);
- result = -EINVAL;
- goto err;
- }
-
- if (copy_to_user(buf, (void *)
- rtac_cal[ASM_RTAC_CAL].cal_data.kvaddr,
- bytes_returned)) {
- pr_err("%s: Could not copy buffer to user,size = %d\n",
- __func__, bytes_returned);
- result = -EINVAL;
- goto err;
- }
+ } else if (opcode == ASM_STREAM_CMD_GET_PP_PARAMS_V3) {
+ bytes_returned =
+ ((u32 *) rtac_cal[ASM_RTAC_CAL].cal_data.kvaddr)[3] +
+ 4 * sizeof(u32);
} else {
bytes_returned = data_size;
+ goto unlock;
}
+
+ if (bytes_returned > rtac_cal[ASM_RTAC_CAL].map_data.map_size) {
+ pr_err("%s: Invalid data size = %d\n", __func__,
+ bytes_returned);
+ result = -EINVAL;
+ goto err;
+ }
+
+ if (bytes_returned > user_buf_size) {
+ pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
+ __func__, user_buf_size, bytes_returned);
+ result = -EINVAL;
+ goto err;
+ }
+
+ if (copy_to_user((void __user *) buf,
+ rtac_cal[ASM_RTAC_CAL].cal_data.kvaddr,
+ bytes_returned)) {
+ pr_err("%s: Could not copy buffer to user,size = %d\n",
+ __func__, bytes_returned);
+ result = -EFAULT;
+ goto err;
+ }
+
+unlock:
mutex_unlock(&rtac_asm_apr_mutex);
done:
return bytes_returned;
@@ -1218,13 +1246,18 @@
return 0;
}
-static int send_rtac_afe_apr(void *buf, uint32_t opcode)
+static int send_rtac_afe_apr(void __user *buf, uint32_t opcode)
{
int32_t result;
uint32_t bytes_returned = 0;
+ uint32_t payload_size = 0;
uint32_t port_index = 0;
+ uint32_t *afe_cmd = NULL;
uint32_t apr_msg_size = 0;
struct rtac_afe_user_data user_afe_buf;
+ struct mem_mapping_hdr *mem_hdr = NULL;
+ struct param_hdr_v1 *get_resp_v2;
+ struct param_hdr_v3 *get_resp_v3;
pr_debug("%s\n", __func__);
@@ -1272,93 +1305,126 @@
result = -EINVAL;
goto err;
}
- if (opcode == AFE_PORT_CMD_SET_PARAM_V2) {
- struct afe_port_cmd_set_param_v2 *afe_set_apr_msg;
- /* set data size to actual out of band payload size */
- if (user_afe_buf.rtac_afe_set.cmd.payload_size >
- rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
- pr_err("%s: Invalid data size = %d\n",
- __func__,
- user_afe_buf.rtac_afe_set.cmd.payload_size);
+ afe_cmd =
+ (u32 *) rtac_afe_buffer + sizeof(struct apr_hdr) / sizeof(u32);
+
+ switch (opcode) {
+ case AFE_PORT_CMD_SET_PARAM_V2:
+ apr_msg_size = sizeof(struct afe_port_cmd_set_param_v2);
+ payload_size = user_afe_buf.v2_set.payload_size;
+ if (payload_size > rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
+ pr_err("%s: Invalid payload size = %d\n", __func__,
+ payload_size);
result = -EINVAL;
goto err;
}
- /* Copy buffer to out-of-band payload */
- if (copy_from_user((void *)
- rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
- buf+offsetof(struct rtac_afe_user_data,
- rtac_afe_set.data),
- user_afe_buf.rtac_afe_set.cmd.payload_size)) {
+ /* Copy the command to the rtac buffer */
+ memcpy(afe_cmd, &user_afe_buf.v2_set,
+ sizeof(user_afe_buf.v2_set));
+
+ /* Copy the param data to the out-of-band location */
+ if (copy_from_user(rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
+ (void __user *) buf +
+ offsetof(struct rtac_afe_user_data,
+ v2_set.param_hdr),
+ payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
+ result = -EFAULT;
+ goto err;
+ }
+ break;
+ case AFE_PORT_CMD_SET_PARAM_V3:
+ apr_msg_size = sizeof(struct afe_port_cmd_set_param_v3);
+ payload_size = user_afe_buf.v3_set.payload_size;
+ if (payload_size > rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
+ pr_err("%s: Invalid payload size = %d\n", __func__,
+ payload_size);
result = -EINVAL;
goto err;
}
- /* Copy AFE APR Message */
- afe_set_apr_msg = (struct afe_port_cmd_set_param_v2 *)
- ((u8 *)rtac_afe_buffer +
- sizeof(struct apr_hdr));
- if (copy_from_user((void *)
- afe_set_apr_msg,
- buf + offsetof(struct rtac_afe_user_data,
- rtac_afe_set.cmd),
- sizeof(struct afe_port_cmd_set_param_v2))) {
+ /* Copy the command to the rtac buffer */
+ memcpy(afe_cmd, &user_afe_buf.v3_set,
+ sizeof(user_afe_buf.v3_set));
+
+ /* Copy the param data to the out-of-band location */
+ if (copy_from_user(rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
+ (void __user *) buf +
+ offsetof(struct rtac_afe_user_data,
+ v3_get.param_hdr),
+ payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
- result = -EINVAL;
+ result = -EFAULT;
goto err;
}
-
- afe_set_apr_msg->payload_address_lsw =
- lower_32_bits(rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
- afe_set_apr_msg->payload_address_msw =
- msm_audio_populate_upper_32_bits(
- rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
- afe_set_apr_msg->mem_map_handle =
- rtac_cal[AFE_RTAC_CAL].map_data.map_handle;
-
- apr_msg_size = sizeof(struct apr_hdr) +
- sizeof(struct afe_port_cmd_set_param_v2);
-
- } else {
- struct afe_port_cmd_get_param_v2 *afe_get_apr_msg;
+ break;
+ case AFE_PORT_CMD_GET_PARAM_V2:
+ apr_msg_size = sizeof(struct afe_port_cmd_get_param_v2);
if (user_afe_buf.cmd_size > MAX_PAYLOAD_SIZE) {
- pr_err("%s: Invalid payload size = %d\n",
- __func__, user_afe_buf.cmd_size);
+ pr_err("%s: Invalid payload size = %d\n", __func__,
+ user_afe_buf.cmd_size);
result = -EINVAL;
goto err;
}
- /* Copy buffer to in-band payload */
- afe_get_apr_msg = (struct afe_port_cmd_get_param_v2 *)
- ((u8 *) rtac_afe_buffer +
- sizeof(struct apr_hdr));
- if (copy_from_user((void *)afe_get_apr_msg,
- buf+offsetof(struct rtac_afe_user_data,
- rtac_afe_get.cmd),
- sizeof(struct afe_port_cmd_get_param_v2))) {
+ /* Copy the command and param data in-band */
+ if (copy_from_user(afe_cmd,
+ (void __user *) buf +
+ offsetof(struct rtac_afe_user_data,
+ v2_get),
+ user_afe_buf.cmd_size)) {
+ pr_err("%s: Could not copy payload from user buffer\n",
+ __func__);
+ result = -EFAULT;
+ goto err;
+ }
+ break;
+ case AFE_PORT_CMD_GET_PARAM_V3:
+ apr_msg_size = sizeof(struct afe_port_cmd_get_param_v3);
+
+ if (user_afe_buf.cmd_size > MAX_PAYLOAD_SIZE) {
+ pr_err("%s: Invalid payload size = %d\n", __func__,
+ user_afe_buf.cmd_size);
+ result = -EINVAL;
+ goto err;
+ }
+
+ /* Copy the command and param data in-band */
+ if (copy_from_user(afe_cmd,
+ (void __user *) buf +
+ offsetof(struct rtac_afe_user_data,
+ v3_get),
+ user_afe_buf.cmd_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
- result = -EINVAL;
+ result = -EFAULT;
goto err;
}
-
- afe_get_apr_msg->payload_address_lsw =
- lower_32_bits(rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
- afe_get_apr_msg->payload_address_msw =
- msm_audio_populate_upper_32_bits(
- rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
- afe_get_apr_msg->mem_map_handle =
- rtac_cal[AFE_RTAC_CAL].map_data.map_handle;
- afe_get_apr_msg->payload_size -= sizeof(struct apr_hdr);
- apr_msg_size = sizeof(struct apr_hdr) +
- sizeof(struct afe_port_cmd_get_param_v2);
+ break;
+ default:
+ pr_err("%s: Invalid opcode %d\n", __func__, opcode);
+ result = -EINVAL;
+ goto err;
}
+ /*
+ * The memory header is in the same location in all commands. Therefore,
+ * it doesn't matter what command the buffer is cast into.
+ */
+ mem_hdr = &((struct afe_port_cmd_set_param_v3 *) rtac_afe_buffer)
+ ->mem_hdr;
+ mem_hdr->data_payload_addr_lsw =
+ lower_32_bits(rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
+ mem_hdr->data_payload_addr_msw = msm_audio_populate_upper_32_bits(
+ rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
+ mem_hdr->mem_map_handle = rtac_cal[AFE_RTAC_CAL].map_data.map_handle;
+
+ /* Fill the APR header at the end so we have the correct message size */
fill_afe_apr_hdr((struct apr_hdr *) rtac_afe_buffer,
port_index, opcode, apr_msg_size);
@@ -1396,41 +1462,44 @@
}
if (opcode == AFE_PORT_CMD_GET_PARAM_V2) {
- struct afe_port_param_data_v2 *get_resp;
-
- get_resp = (struct afe_port_param_data_v2 *)
- rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr;
-
- bytes_returned = get_resp->param_size +
- sizeof(struct afe_port_param_data_v2);
-
- if (bytes_returned > rtac_cal[AFE_RTAC_CAL].
- map_data.map_size) {
- pr_err("%s: Invalid data size = %d\n",
- __func__, bytes_returned);
- result = -EINVAL;
- goto err;
- }
-
- if (bytes_returned > user_afe_buf.buf_size) {
- pr_err("%s: user size = 0x%x, returned size = 0x%x\n",
- __func__, user_afe_buf.buf_size,
- bytes_returned);
- result = -EINVAL;
- goto err;
- }
-
- if (copy_to_user(buf, (void *)
- rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
- bytes_returned)) {
- pr_err("%s: Could not copy buffer to user,size = %d\n",
- __func__, bytes_returned);
- result = -EINVAL;
- goto err;
- }
+ get_resp_v2 = (struct param_hdr_v1 *) rtac_cal[AFE_RTAC_CAL]
+ .cal_data.kvaddr;
+ bytes_returned =
+ get_resp_v2->param_size + sizeof(struct param_hdr_v1);
+ } else if (opcode == AFE_PORT_CMD_GET_PARAM_V3) {
+ get_resp_v3 = (struct param_hdr_v3 *) rtac_cal[AFE_RTAC_CAL]
+ .cal_data.kvaddr;
+ bytes_returned =
+ get_resp_v3->param_size + sizeof(struct param_hdr_v3);
} else {
- bytes_returned = user_afe_buf.rtac_afe_set.cmd.payload_size;
+ bytes_returned = payload_size;
+ goto unlock;
}
+
+ if (bytes_returned > rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
+ pr_err("%s: Invalid data size = %d\n", __func__,
+ bytes_returned);
+ result = -EINVAL;
+ goto err;
+ }
+
+ if (bytes_returned > user_afe_buf.buf_size) {
+ pr_err("%s: user size = 0x%x, returned size = 0x%x\n", __func__,
+ user_afe_buf.buf_size, bytes_returned);
+ result = -EINVAL;
+ goto err;
+ }
+
+ if (copy_to_user((void __user *) buf,
+ rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
+ bytes_returned)) {
+ pr_err("%s: Could not copy buffer to user,size = %d\n",
+ __func__, bytes_returned);
+ result = -EFAULT;
+ goto err;
+ }
+
+unlock:
mutex_unlock(&rtac_afe_apr_mutex);
done:
return bytes_returned;
@@ -1533,7 +1602,9 @@
goto err;
}
- if (opcode == VSS_ICOMMON_CMD_SET_PARAM_V2) {
+ switch (opcode) {
+ case VSS_ICOMMON_CMD_SET_PARAM_V2:
+ case VSS_ICOMMON_CMD_SET_PARAM_V3:
/* set payload size to in-band payload */
/* set data size to actual out of band payload size */
data_size = payload_size - 4 * sizeof(u32);
@@ -1551,12 +1622,16 @@
buf + 7 * sizeof(u32), data_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
- result = -EINVAL;
+ result = -EFAULT;
goto err;
}
/* set payload size in packet */
rtac_voice_buffer[8] = data_size;
- } else {
+ /* set token for set param case */
+ voice_params.token = VOC_RTAC_SET_PARAM_TOKEN;
+ break;
+ case VSS_ICOMMON_CMD_GET_PARAM_V2:
+ case VSS_ICOMMON_CMD_GET_PARAM_V3:
if (payload_size > MAX_PAYLOAD_SIZE) {
pr_err("%s: Invalid payload size = %d\n",
__func__, payload_size);
@@ -1570,9 +1645,16 @@
buf + 3 * sizeof(u32), payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
- result = -EINVAL;
+ result = -EFAULT;
goto err;
}
+ /* set token for get param case */
+ voice_params.token = 0;
+ break;
+ default:
+ pr_err("%s: Invalid opcode %d\n", __func__, opcode);
+ result = -EINVAL;
+ goto err;
}
/* Pack header */
@@ -1586,18 +1668,14 @@
voice_params.dest_svc = 0;
voice_params.dest_domain = APR_DOMAIN_MODEM;
voice_params.dest_port = (u16)dest_port;
- voice_params.token = (opcode == VSS_ICOMMON_CMD_SET_PARAM_V2) ?
- VOC_RTAC_SET_PARAM_TOKEN :
- 0;
voice_params.opcode = opcode;
/* fill for out-of-band */
rtac_voice_buffer[5] = rtac_cal[VOICE_RTAC_CAL].map_data.map_handle;
rtac_voice_buffer[6] =
lower_32_bits(rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
- rtac_voice_buffer[7] =
- msm_audio_populate_upper_32_bits(
- rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
+ rtac_voice_buffer[7] = msm_audio_populate_upper_32_bits(
+ rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
memcpy(rtac_voice_buffer, &voice_params, sizeof(voice_params));
atomic_set(&rtac_voice_apr_data[mode].cmd_state, 1);
@@ -1636,33 +1714,39 @@
if (opcode == VSS_ICOMMON_CMD_GET_PARAM_V2) {
bytes_returned = ((u32 *)rtac_cal[VOICE_RTAC_CAL].cal_data.
kvaddr)[2] + 3 * sizeof(u32);
-
- if (bytes_returned > rtac_cal[VOICE_RTAC_CAL].
- map_data.map_size) {
- pr_err("%s: Invalid data size = %d\n",
- __func__, bytes_returned);
- result = -EINVAL;
- goto err;
- }
-
- if (bytes_returned > user_buf_size) {
- pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
- __func__, user_buf_size, bytes_returned);
- result = -EINVAL;
- goto err;
- }
-
- if (copy_to_user(buf, (void *)
- rtac_cal[VOICE_RTAC_CAL].cal_data.kvaddr,
- bytes_returned)) {
- pr_err("%s: Could not copy buffer to user, size = %d\n",
- __func__, bytes_returned);
- result = -EINVAL;
- goto err;
- }
+ } else if (opcode == VSS_ICOMMON_CMD_GET_PARAM_V3) {
+ bytes_returned =
+ ((u32 *) rtac_cal[VOICE_RTAC_CAL].cal_data.kvaddr)[3] +
+ 4 * sizeof(u32);
} else {
bytes_returned = data_size;
+ goto unlock;
}
+
+ if (bytes_returned > rtac_cal[VOICE_RTAC_CAL].map_data.map_size) {
+ pr_err("%s: Invalid data size = %d\n", __func__,
+ bytes_returned);
+ result = -EINVAL;
+ goto err;
+ }
+
+ if (bytes_returned > user_buf_size) {
+ pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
+ __func__, user_buf_size, bytes_returned);
+ result = -EINVAL;
+ goto err;
+ }
+
+ if (copy_to_user((void __user *) buf,
+ rtac_cal[VOICE_RTAC_CAL].cal_data.kvaddr,
+ bytes_returned)) {
+ pr_err("%s: Could not copy buffer to user, size = %d\n",
+ __func__, bytes_returned);
+ result = -EFAULT;
+ goto err;
+ }
+
+unlock:
mutex_unlock(&rtac_voice_apr_mutex);
done:
return bytes_returned;
@@ -1682,8 +1766,8 @@
static long rtac_ioctl_shared(struct file *f,
unsigned int cmd, void *arg)
{
+ u32 opcode;
int result = 0;
-
if (!arg) {
pr_err("%s: No data sent to driver!\n", __func__);
result = -EFAULT;
@@ -1719,42 +1803,64 @@
}
case AUDIO_GET_RTAC_ADM_CAL:
- result = send_adm_apr((void *)arg, ADM_CMD_GET_PP_PARAMS_V5);
+ opcode = q6common_is_instance_id_supported() ?
+ ADM_CMD_GET_PP_PARAMS_V6 :
+ ADM_CMD_GET_PP_PARAMS_V5;
+ result = send_adm_apr((void *) arg, opcode);
break;
case AUDIO_SET_RTAC_ADM_CAL:
- result = send_adm_apr((void *)arg, ADM_CMD_SET_PP_PARAMS_V5);
+ opcode = q6common_is_instance_id_supported() ?
+ ADM_CMD_SET_PP_PARAMS_V6 :
+ ADM_CMD_SET_PP_PARAMS_V5;
+ result = send_adm_apr((void *) arg, opcode);
break;
case AUDIO_GET_RTAC_ASM_CAL:
- result = send_rtac_asm_apr((void *)arg,
- ASM_STREAM_CMD_GET_PP_PARAMS_V2);
+ opcode = q6common_is_instance_id_supported() ?
+ ASM_STREAM_CMD_GET_PP_PARAMS_V3 :
+ ASM_STREAM_CMD_GET_PP_PARAMS_V2;
+ result = send_rtac_asm_apr((void *) arg, opcode);
break;
case AUDIO_SET_RTAC_ASM_CAL:
- result = send_rtac_asm_apr((void *)arg,
- ASM_STREAM_CMD_SET_PP_PARAMS_V2);
+ opcode = q6common_is_instance_id_supported() ?
+ ASM_STREAM_CMD_SET_PP_PARAMS_V3 :
+ ASM_STREAM_CMD_SET_PP_PARAMS_V2;
+ result = send_rtac_asm_apr((void *) arg, opcode);
break;
case AUDIO_GET_RTAC_CVS_CAL:
- result = send_voice_apr(RTAC_CVS, (void *) arg,
- VSS_ICOMMON_CMD_GET_PARAM_V2);
+ opcode = q6common_is_instance_id_supported() ?
+ VSS_ICOMMON_CMD_GET_PARAM_V3 :
+ VSS_ICOMMON_CMD_GET_PARAM_V2;
+ result = send_voice_apr(RTAC_CVS, (void *) arg, opcode);
break;
case AUDIO_SET_RTAC_CVS_CAL:
- result = send_voice_apr(RTAC_CVS, (void *) arg,
- VSS_ICOMMON_CMD_SET_PARAM_V2);
+ opcode = q6common_is_instance_id_supported() ?
+ VSS_ICOMMON_CMD_SET_PARAM_V3 :
+ VSS_ICOMMON_CMD_SET_PARAM_V2;
+ result = send_voice_apr(RTAC_CVS, (void *) arg, opcode);
break;
case AUDIO_GET_RTAC_CVP_CAL:
- result = send_voice_apr(RTAC_CVP, (void *) arg,
- VSS_ICOMMON_CMD_GET_PARAM_V2);
+ opcode = q6common_is_instance_id_supported() ?
+ VSS_ICOMMON_CMD_GET_PARAM_V3 :
+ VSS_ICOMMON_CMD_GET_PARAM_V2;
+ result = send_voice_apr(RTAC_CVP, (void *) arg, opcode);
break;
case AUDIO_SET_RTAC_CVP_CAL:
- result = send_voice_apr(RTAC_CVP, (void *) arg,
- VSS_ICOMMON_CMD_SET_PARAM_V2);
+ opcode = q6common_is_instance_id_supported() ?
+ VSS_ICOMMON_CMD_SET_PARAM_V3 :
+ VSS_ICOMMON_CMD_SET_PARAM_V2;
+ result = send_voice_apr(RTAC_CVP, (void *) arg, opcode);
break;
case AUDIO_GET_RTAC_AFE_CAL:
- result = send_rtac_afe_apr((void *)arg,
- AFE_PORT_CMD_GET_PARAM_V2);
+ opcode = q6common_is_instance_id_supported() ?
+ AFE_PORT_CMD_GET_PARAM_V3 :
+ AFE_PORT_CMD_GET_PARAM_V2;
+ result = send_rtac_afe_apr((void __user *) arg, opcode);
break;
case AUDIO_SET_RTAC_AFE_CAL:
- result = send_rtac_afe_apr((void *)arg,
- AFE_PORT_CMD_SET_PARAM_V2);
+ opcode = q6common_is_instance_id_supported() ?
+ AFE_PORT_CMD_SET_PARAM_V3 :
+ AFE_PORT_CMD_SET_PARAM_V2;
+ result = send_rtac_afe_apr((void __user *) arg, opcode);
break;
default:
pr_err("%s: Invalid IOCTL, command = %d!\n",
diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h
index 9c7f39d..ae096e6 100644
--- a/include/dsp/apr_audio-v2.h
+++ b/include/dsp/apr_audio-v2.h
@@ -498,55 +498,40 @@
/* Sets one or more parameters to a COPP. */
#define ADM_CMD_SET_PP_PARAMS_V5 0x00010328
+#define ADM_CMD_SET_PP_PARAMS_V6 0x0001035D
-/* Payload of the #ADM_CMD_SET_PP_PARAMS_V5 command.
- * If the data_payload_addr_lsw and data_payload_addr_msw element
- * are NULL, a series of adm_param_datastructures immediately
- * follows, whose total size is data_payload_size bytes.
+/*
+ * Structure of the ADM Set PP Params command. Parameter data must be
+ * pre-packed with correct header for either V2 or V3 when sent in-band.
+ * Use q6core_pack_pp_params to pack the header and data correctly depending on
+ * Instance ID support.
*/
-struct adm_cmd_set_pp_params_v5 {
- struct apr_hdr hdr;
- u32 payload_addr_lsw;
-/* LSW of parameter data payload address. */
- u32 payload_addr_msw;
-/* MSW of parameter data payload address. */
+struct adm_cmd_set_pp_params {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
- u32 mem_map_handle;
-/* Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS
- * command
- *
- * If mem_map_handle is zero implies the message is in
- * the payload
- */
+ /* The memory mapping header to be used when sending out of band */
+ struct mem_mapping_hdr mem_hdr;
- u32 payload_size;
-/* Size in bytes of the variable payload accompanying this
- * message or
- * in shared memory. This is used for parsing the parameter
- * payload.
- */
+ /*
+ * Size in bytes of the variable payload accompanying this
+ * message or
+ * in shared memory. This is used for parsing the parameter
+ * payload.
+ */
+ u32 payload_size;
+
+ /*
+ * Parameter data for in band payload. This should be structured as the
+ * parameter header immediately followed by the parameter data. Multiple
+ * parameters can be set in one command by repeating the header followed
+ * by the data for as many parameters as need to be set.
+ * Use q6core_pack_pp_params to pack the header and data correctly
+ * depending on Instance ID support.
+ */
+ u8 param_data[0];
} __packed;
-/* Payload format for COPP parameter data.
- * Immediately following this structure are param_size bytes
- * of parameter
- * data.
- */
-struct adm_param_data_v5 {
- u32 module_id;
- /* Unique ID of the module. */
- u32 param_id;
- /* Unique ID of the parameter. */
- u16 param_size;
- /* Data size of the param_id/module_id combination.
- * This value is a
- * multiple of 4 bytes.
- */
- u16 reserved;
- /* Reserved for future enhancements.
- * This field must be set to zero.
- */
-} __packed;
#define ASM_STREAM_CMD_REGISTER_PP_EVENTS 0x00013213
#define ASM_STREAM_PP_EVENT 0x00013214
@@ -590,25 +575,6 @@
u16 reserved;
} __packed;
-/* Defined specifically for in-band use, includes params */
-struct adm_cmd_set_pp_params_inband_v5 {
- struct apr_hdr hdr;
- /* LSW of parameter data payload address.*/
- u32 payload_addr_lsw;
- /* MSW of parameter data payload address.*/
- u32 payload_addr_msw;
- /* Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS */
- /* command. If mem_map_handle is zero implies the message is in */
- /* the payload */
- u32 mem_map_handle;
- /* Size in bytes of the variable payload accompanying this */
- /* message or in shared memory. This is used for parsing the */
- /* parameter payload. */
- u32 payload_size;
- /* Parameters passed for in band payload */
- struct adm_param_data_v5 params;
-} __packed;
-
/* Returns the status and COPP ID to an #ADM_CMD_DEVICE_OPEN_V5 command.
*/
#define ADM_CMDRSP_DEVICE_OPEN_V5 0x00010329
@@ -639,43 +605,21 @@
/* This command allows a query of one COPP parameter. */
#define ADM_CMD_GET_PP_PARAMS_V5 0x0001032A
+#define ADM_CMD_GET_PP_PARAMS_V6 0x0001035E
-/* Payload an #ADM_CMD_GET_PP_PARAMS_V5 command. */
-struct adm_cmd_get_pp_params_v5 {
- struct apr_hdr hdr;
- u32 data_payload_addr_lsw;
- /* LSW of parameter data payload address.*/
+/*
+ * Structure of the ADM Get PP Params command. Parameter header must be
+ * packed correctly for either V2 or V3. Use q6core_pack_pp_params to pack the
+ * header correctly depending on Instance ID support.
+ */
+struct adm_cmd_get_pp_params {
+ struct apr_hdr apr_hdr;
- u32 data_payload_addr_msw;
- /* MSW of parameter data payload address.*/
+ /* The memory mapping header to be used when requesting outband */
+ struct mem_mapping_hdr mem_hdr;
- /* If the mem_map_handle is non zero,
- * on ACK, the ParamData payloads begin at
- * the address specified (out-of-band).
- */
-
- u32 mem_map_handle;
- /* Memory map handle returned
- * by ADM_CMD_SHARED_MEM_MAP_REGIONS command.
- * If the mem_map_handle is 0, it implies that
- * the ACK's payload will contain the ParamData (in-band).
- */
-
- u32 module_id;
- /* Unique ID of the module. */
-
- u32 param_id;
- /* Unique ID of the parameter. */
-
- u16 param_max_size;
- /* Maximum data size of the parameter
- *ID/module ID combination. This
- * field is a multiple of 4 bytes.
- */
- u16 reserved;
- /* Reserved for future enhancements.
- * This field must be set to zero.
- */
+ /* Parameter header for in band payload. */
+ union param_hdrs param_hdr;
} __packed;
/* Returns parameter values
@@ -687,15 +631,49 @@
* which returns parameter values in response
* to an #ADM_CMD_GET_PP_PARAMS_V5 command.
* Immediately following this
- * structure is the adm_param_data_v5
+ * structure is the param_hdr_v1
* structure containing the pre/postprocessing
* parameter data. For an in-band
* scenario, the variable payload depends
* on the size of the parameter.
*/
struct adm_cmd_rsp_get_pp_params_v5 {
- u32 status;
/* Status message (error code).*/
+ u32 status;
+
+ /* The header that identifies the subsequent parameter data */
+ struct param_hdr_v1 param_hdr;
+
+ /* The parameter data returned */
+ u32 param_data[0];
+} __packed;
+
+/*
+ * Returns parameter values in response to an #ADM_CMD_GET_PP_PARAMS_V5/6
+ * command.
+ */
+#define ADM_CMDRSP_GET_PP_PARAMS_V6 0x0001035F
+
+/*
+ * Payload of the #ADM_CMDRSP_GET_PP_PARAMS_V6 message,
+ * which returns parameter values in response
+ * to an #ADM_CMD_GET_PP_PARAMS_V6 command.
+ * Immediately following this
+ * structure is the param_hdr_v3
+ * structure containing the pre/postprocessing
+ * parameter data. For an in-band
+ * scenario, the variable payload depends
+ * on the size of the parameter.
+ */
+struct adm_cmd_rsp_get_pp_params_v6 {
+ /* Status message (error code).*/
+ u32 status;
+
+ /* The header that identifies the subsequent parameter data */
+ struct param_hdr_v3 param_hdr;
+
+ /* The parameter data returned */
+ u32 param_data[0];
} __packed;
/* Structure for holding soft stepping volume parameters. */
@@ -728,9 +706,31 @@
#define AUDPROC_CHMIXER_PARAM_ID_COEFF 0x00010342
-struct audproc_mfc_output_media_fmt {
- struct adm_cmd_set_pp_params_v5 params;
- struct adm_param_data_v5 data;
+struct adm_cmd_set_pp_params_v5 {
+ struct apr_hdr hdr;
+ u32 payload_addr_lsw;
+ /* LSW of parameter data payload address.*/
+ u32 payload_addr_msw;
+ /* MSW of parameter data payload address.*/
+
+ u32 mem_map_handle;
+ /*
+ * Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS
+ * command.
+ * If mem_map_handle is zero implies the message is in
+ * the payload
+ */
+
+ u32 payload_size;
+ /*
+ * Size in bytes of the variable payload accompanying this
+ * message or
+ * in shared memory. This is used for parsing the parameter
+ * payload.
+ */
+} __packed;
+
+struct audproc_mfc_param_media_fmt {
uint32_t sampling_rate;
uint16_t bits_per_sample;
uint16_t num_channels;
@@ -738,8 +738,6 @@
} __packed;
struct audproc_volume_ctrl_master_gain {
- struct adm_cmd_set_pp_params_v5 params;
- struct adm_param_data_v5 data;
/* Linear gain in Q13 format. */
uint16_t master_gain;
/* Clients must set this field to zero. */
@@ -747,8 +745,6 @@
} __packed;
struct audproc_soft_step_volume_params {
- struct adm_cmd_set_pp_params_v5 params;
- struct adm_param_data_v5 data;
/*
* Period in milliseconds.
* Supported values: 0 to 15000
@@ -770,7 +766,6 @@
} __packed;
struct audproc_enable_param_t {
- struct adm_cmd_set_pp_params_inband_v5 pp_params;
/*
* Specifies whether the Audio processing module is enabled.
* This parameter is generic/common parameter to configure or
@@ -1533,86 +1528,137 @@
#define AFE_MODULE_LOOPBACK 0x00010205
#define AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH 0x00010206
+/* Used by RTAC */
+struct afe_rtac_user_data_set_v2 {
+ /* Port interface and direction (Rx or Tx) to start. */
+ u16 port_id;
+
+ /* Actual size of the payload in bytes.
+ * This is used for parsing the parameter payload.
+ * Supported values: > 0
+ */
+ u16 payload_size;
+
+ /* The header detailing the memory mapping for out of band. */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The parameter header for the parameter data to set */
+ struct param_hdr_v1 param_hdr;
+
+ /* The parameter data to be filled when sent inband */
+ u32 *param_data;
+} __packed;
+
+struct afe_rtac_user_data_set_v3 {
+ /* Port interface and direction (Rx or Tx) to start. */
+ u16 port_id;
+ /* Reserved for future enhancements. Must be 0. */
+ u16 reserved;
+
+ /* The header detailing the memory mapping for out of band. */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The size of the parameter header and parameter data */
+ u32 payload_size;
+
+ /* The parameter header for the parameter data to set */
+ struct param_hdr_v3 param_hdr;
+
+ /* The parameter data to be filled when sent inband */
+ u32 *param_data;
+} __packed;
+
+struct afe_rtac_user_data_get_v2 {
+ /* Port interface and direction (Rx or Tx) to start. */
+ u16 port_id;
+
+ /* Actual size of the payload in bytes.
+ * This is used for parsing the parameter payload.
+ * Supported values: > 0
+ */
+ u16 payload_size;
+
+ /* The header detailing the memory mapping for out of band. */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The module ID of the parameter to get */
+ u32 module_id;
+
+ /* The parameter ID of the parameter to get */
+ u32 param_id;
+
+ /* The parameter data to be filled when sent inband */
+ struct param_hdr_v1 param_hdr;
+} __packed;
+
+struct afe_rtac_user_data_get_v3 {
+ /* Port interface and direction (Rx or Tx) to start. */
+ u16 port_id;
+ /* Reserved for future enhancements. Must be 0. */
+ u16 reserved;
+
+ /* The header detailing the memory mapping for out of band. */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The parameter data to be filled when sent inband */
+ struct param_hdr_v3 param_hdr;
+} __packed;
+
+#define AFE_PORT_CMD_SET_PARAM_V2 0x000100EF
+struct afe_port_cmd_set_param_v2 {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
+
+ /* Port interface and direction (Rx or Tx) to start. */
+ u16 port_id;
+
+ /*
+ * Actual size of the payload in bytes.
+ * This is used for parsing the parameter payload.
+ * Supported values: > 0
+ */
+ u16 payload_size;
+
+ /* The header detailing the memory mapping for out of band. */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The parameter data to be filled when sent inband */
+ u8 param_data[0];
+} __packed;
+
+#define AFE_PORT_CMD_SET_PARAM_V3 0x000100FA
+struct afe_port_cmd_set_param_v3 {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
+
+ /* Port ID of the AFE port to configure. Port interface and direction
+ * (Rx or Tx) to configure. An even number represents the Rx direction,
+ * and an odd number represents the Tx direction.
+ */
+ u16 port_id;
+
+ /* Reserved. This field must be set to zero. */
+ u16 reserved;
+
+ /* The memory mapping header to be used when sending outband */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The total size of the payload, including param_hdr_v3 */
+ u32 payload_size;
+
+ /*
+ * The parameter data to be filled when sent inband.
+ * Must include param_hdr packed correctly.
+ */
+ u8 param_data[0];
+} __packed;
+
/* Payload of the #AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH parameter,
* which gets/sets loopback gain of a port to an Rx port.
* The Tx port ID of the loopback is part of the set_param command.
*/
-/* Payload of the #AFE_PORT_CMD_SET_PARAM_V2 command's
- * configuration/calibration settings for the AFE port.
- */
-struct afe_port_cmd_set_param_v2 {
- u16 port_id;
-/* Port interface and direction (Rx or Tx) to start. */
-
- u16 payload_size;
-/* Actual size of the payload in bytes.
- * This is used for parsing the parameter payload.
- * Supported values: > 0
- */
-
-u32 payload_address_lsw;
-/* LSW of 64 bit Payload address.
- * Address should be 32-byte,
- * 4kbyte aligned and must be contiguous memory.
- */
-
-u32 payload_address_msw;
-/* MSW of 64 bit Payload address.
- * In case of 32-bit shared memory address,
- * this field must be set to zero.
- * In case of 36-bit shared memory address,
- * bit-4 to bit-31 must be set to zero.
- * Address should be 32-byte, 4kbyte aligned
- * and must be contiguous memory.
- */
-
-u32 mem_map_handle;
-/* Memory map handle returned by
- * AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands.
- * Supported Values:
- * - NULL -- Message. The parameter data is in-band.
- * - Non-NULL -- The parameter data is Out-band.Pointer to
- * the physical address
- * in shared memory of the payload data.
- * An optional field is available if parameter
- * data is in-band:
- * afe_param_data_v2 param_data[...].
- * For detailed payload content, see the
- * afe_port_param_data_v2 structure.
- */
-} __packed;
-
-#define AFE_PORT_CMD_SET_PARAM_V2 0x000100EF
-
-struct afe_port_param_data_v2 {
- u32 module_id;
-/* ID of the module to be configured.
- * Supported values: Valid module ID
- */
-
-u32 param_id;
-/* ID of the parameter corresponding to the supported parameters
- * for the module ID.
- * Supported values: Valid parameter ID
- */
-
-u16 param_size;
-/* Actual size of the data for the
- * module_id/param_id pair. The size is a
- * multiple of four bytes.
- * Supported values: > 0
- */
-
-u16 reserved;
-/* This field must be set to zero.
- */
-} __packed;
-
struct afe_loopback_gain_per_path_param {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
u16 rx_port_id;
/* Rx port of the loopback. */
@@ -1648,9 +1694,6 @@
* which enables/disables one AFE loopback.
*/
struct afe_loopback_cfg_v1 {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
u32 loopback_cfg_minor_version;
/* Minor version used for tracking the version of the RMC module
* configuration interface.
@@ -1712,19 +1755,19 @@
struct afe_st_loopback_cfg_v1 {
struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 gain_pdata;
+ struct mem_mapping_hdr mem_hdr;
+ struct param_hdr_v1 gain_pdata;
struct afe_loopback_sidetone_gain gain_data;
- struct afe_port_param_data_v2 cfg_pdata;
+ struct param_hdr_v1 cfg_pdata;
struct loopback_cfg_data cfg_data;
} __packed;
struct afe_loopback_iir_cfg_v2 {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 st_iir_enable_pdata;
- struct afe_mod_enable_param st_iir_mode_enable_data;
- struct afe_port_param_data_v2 st_iir_filter_config_pdata;
+ struct apr_hdr hdr;
+ struct mem_mapping_hdr param;
+ struct param_hdr_v1 st_iir_enable_pdata;
+ struct afe_mod_enable_param st_iir_mode_enable_data;
+ struct param_hdr_v1 st_iir_filter_config_pdata;
struct afe_sidetone_iir_filter_config_params st_iir_filter_config_data;
} __packed;
#define AFE_MODULE_SPEAKER_PROTECTION 0x00010209
@@ -2177,20 +2220,6 @@
*/
} __packed;
-struct afe_spdif_clk_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_id_spdif_clk_cfg clk_cfg;
-} __packed;
-
-struct afe_spdif_chstatus_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_id_spdif_ch_status_cfg ch_status;
-} __packed;
-
struct afe_spdif_port_config {
struct afe_param_id_spdif_cfg cfg;
struct afe_param_id_spdif_ch_status_cfg ch_status;
@@ -2709,16 +2738,6 @@
u32 endian;
} __packed;
-struct afe_usb_audio_dev_param_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- union {
- struct afe_param_id_usb_audio_dev_params usb_dev;
- struct afe_param_id_usb_audio_dev_lpcm_fmt lpcm_fmt;
- };
-} __packed;
-
/* This param id is used to configure Real Time Proxy interface. */
#define AFE_PARAM_ID_RT_PROXY_CONFIG 0x00010213
@@ -3131,20 +3150,6 @@
*/
} __packed;
-struct afe_slot_mapping_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_id_slot_mapping_cfg slot_mapping;
-} __packed;
-
-struct afe_custom_tdm_header_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_id_custom_tdm_header_cfg custom_tdm_header;
-} __packed;
-
struct afe_tdm_port_config {
struct afe_param_id_tdm_cfg tdm;
struct afe_param_id_slot_mapping_cfg slot_mapping;
@@ -3660,18 +3665,6 @@
struct avs_enc_set_scrambler_param_t enc_set_scrambler_param;
} __packed;
-struct afe_audioif_config_command_no_payload {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
-} __packed;
-
-struct afe_audioif_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- union afe_port_config port;
-} __packed;
-
#define AFE_PORT_CMD_DEVICE_START 0x000100E5
/* Payload of the #AFE_PORT_CMD_DEVICE_START.*/
@@ -3833,13 +3826,8 @@
*/
} __packed;
-#define AFE_PORT_CMD_GET_PARAM_V2 0x000100F0
-
-/* Payload of the #AFE_PORT_CMD_GET_PARAM_V2 command,
- * which queries for one post/preprocessing parameter of a
- * stream.
- */
-struct afe_port_cmd_get_param_v2 {
+/* Used by RTAC */
+struct afe_rtac_get_param_v2 {
u16 port_id;
/* Port interface and direction (Rx or Tx) to start. */
@@ -3885,6 +3873,37 @@
*/
} __packed;
+#define AFE_PORT_CMD_GET_PARAM_V2 0x000100F0
+
+/* Payload of the #AFE_PORT_CMD_GET_PARAM_V2 command,
+ * which queries for one post/preprocessing parameter of a
+ * stream.
+ */
+struct afe_port_cmd_get_param_v2 {
+ struct apr_hdr apr_hdr;
+
+ /* Port interface and direction (Rx or Tx) to start. */
+ u16 port_id;
+
+ /* Maximum data size of the parameter ID/module ID combination.
+ * This is a multiple of four bytes
+ * Supported values: > 0
+ */
+ u16 payload_size;
+
+ /* The memory mapping header to be used when requesting outband */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The module ID of the parameter data requested */
+ u32 module_id;
+
+ /* The parameter ID of the parameter data requested */
+ u32 param_id;
+
+ /* The header information for the parameter data */
+ struct param_hdr_v1 param_hdr;
+} __packed;
+
#define AFE_PORT_CMDRSP_GET_PARAM_V2 0x00010106
/* Payload of the #AFE_PORT_CMDRSP_GET_PARAM_V2 message, which
@@ -3900,6 +3919,41 @@
struct afe_port_cmdrsp_get_param_v2 {
u32 status;
+ struct param_hdr_v1 param_hdr;
+ u8 param_data[0];
+} __packed;
+
+#define AFE_PORT_CMD_GET_PARAM_V3 0x000100FB
+struct afe_port_cmd_get_param_v3 {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
+
+ /* Port ID of the AFE port to configure. Port interface and direction
+ * (Rx or Tx) to configure. An even number represents the Rx direction,
+ * and an odd number represents the Tx direction.
+ */
+ u16 port_id;
+
+ /* Reserved. This field must be set to zero. */
+ u16 reserved;
+
+ /* The memory mapping header to be used when requesting outband */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The header information for the parameter data */
+ struct param_hdr_v3 param_hdr;
+} __packed;
+
+#define AFE_PORT_CMDRSP_GET_PARAM_V3 0x00010108
+struct afe_port_cmdrsp_get_param_v3 {
+ /* The status of the command */
+ uint32_t status;
+
+ /* The header information for the parameter data */
+ struct param_hdr_v3 param_hdr;
+
+ /* The parameter data to be filled when sent inband */
+ u8 param_data[0];
} __packed;
#define AFE_PARAM_ID_LPASS_CORE_SHARED_CLOCK_CONFIG 0x0001028C
@@ -3921,13 +3975,6 @@
*/
} __packed;
-struct afe_lpass_core_shared_clk_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_id_lpass_core_shared_clk_cfg clk_cfg;
-} __packed;
-
/* adsp_afe_service_commands.h */
#define ADSP_MEMORY_MAP_EBI_POOL 0
@@ -6552,59 +6599,33 @@
#define ASM_STREAM_CMD_FLUSH_READBUFS 0x00010C09
#define ASM_STREAM_CMD_SET_PP_PARAMS_V2 0x00010DA1
+#define ASM_STREAM_CMD_SET_PP_PARAMS_V3 0x0001320D
-struct asm_stream_cmd_set_pp_params_v2 {
- u32 data_payload_addr_lsw;
-/* LSW of parameter data payload address. Supported values: any. */
- u32 data_payload_addr_msw;
-/* MSW of Parameter data payload address. Supported values: any.
- * - Must be set to zero for in-band data.
- * - In the case of 32 bit Shared memory address, msw field must be
- * - set to zero.
- * - In the case of 36 bit shared memory address, bit 31 to bit 4 of
- * msw
- *
- * - must be set to zero.
+/*
+ * Structure for the ASM Stream Set PP Params command. Parameter data must be
+ * pre-packed with the correct header for either V2 or V3 when sent in-band.
+ * Use q6core_pack_pp_params to pack the header and data correctly depending on
+ * Instance ID support.
*/
- u32 mem_map_handle;
-/* Supported Values: Any.
- * memory map handle returned by DSP through
- * ASM_CMD_SHARED_MEM_MAP_REGIONS
- * command.
- * if mmhandle is NULL, the ParamData payloads are within the
- * message payload (in-band).
- * If mmhandle is non-NULL, the ParamData payloads begin at the
- * address specified in the address msw and lsw (out-of-band).
- */
+struct asm_stream_cmd_set_pp_params {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
- u32 data_payload_size;
-/* Size in bytes of the variable payload accompanying the
- * message, or in shared memory. This field is used for parsing the
- * parameter payload.
- */
-} __packed;
+ /* The memory mapping header to be used when sending out of band */
+ struct mem_mapping_hdr mem_hdr;
+ /* The total size of the payload, including the parameter header */
+ u32 payload_size;
-struct asm_stream_param_data_v2 {
- u32 module_id;
- /* Unique module ID. */
-
- u32 param_id;
- /* Unique parameter ID. */
-
- u16 param_size;
-/* Data size of the param_id/module_id combination. This is
- * a multiple of 4 bytes.
- */
-
- u16 reserved;
-/* Reserved for future enhancements. This field must be set to
- * zero.
- */
-
+ /* The parameter data to be filled when sent inband. Parameter data
+ * must be pre-packed with parameter header and then copied here. Use
+ * q6core_pack_pp_params to pack the header and param data correctly.
+ */
+ u32 param_data[0];
} __packed;
#define ASM_STREAM_CMD_GET_PP_PARAMS_V2 0x00010DA2
+#define ASM_STREAM_CMD_GET_PP_PARAMS_V3 0x0001320E
struct asm_stream_cmd_get_pp_params_v2 {
u32 data_payload_addr_lsw;
@@ -6782,6 +6803,7 @@
} __packed;
#define ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 0x00010DA4
+#define ASM_STREAM_CMDRSP_GET_PP_PARAMS_V3 0x0001320F
struct asm_stream_cmdrsp_get_pp_params_v2 {
u32 status;
@@ -7557,12 +7579,6 @@
/*< Clients must set this field to zero. */
} __packed;
-struct adm_set_mic_gain_params {
- struct adm_cmd_set_pp_params_v5 params;
- struct adm_param_data_v5 data;
- struct admx_mic_gain mic_gain_data;
-} __packed;
-
/* end_addtogroup audio_pp_param_ids */
/* @ingroup audio_pp_module_ids
@@ -7920,56 +7936,23 @@
#define ADM_CMD_GET_PP_TOPO_MODULE_LIST 0x00010349
#define ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST 0x00010350
+#define ADM_CMD_GET_PP_TOPO_MODULE_LIST_V2 0x00010360
+#define ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST_V2 0x00010361
#define AUDPROC_PARAM_ID_ENABLE 0x00010904
- /*
- * Payload of the ADM_CMD_GET_PP_TOPO_MODULE_LIST command.
- */
-struct adm_cmd_get_pp_topo_module_list_t {
- struct apr_hdr hdr;
- /* Lower 32 bits of the 64-bit parameter data payload address. */
- uint32_t data_payload_addr_lsw;
- /*
- * Upper 32 bits of the 64-bit parameter data payload address.
- *
- *
- * The size of the shared memory, if specified, must be large enough to
- * contain the entire parameter data payload, including the module ID,
- * parameter ID, parameter size, and parameter values.
- */
- uint32_t data_payload_addr_msw;
- /*
- * Unique identifier for an address.
- *
- * This memory map handle is returned by the aDSP through the
- * #ADM_CMD_SHARED_MEM_MAP_REGIONS command.
- *
- * @values
- * - Non-NULL -- On acknowledgment, the parameter data payloads begin at
- * the address specified (out-of-band)
- * - NULL -- The acknowledgment's payload contains the parameter data
- * (in-band) @tablebulletend
- */
- uint32_t mem_map_handle;
+/*
+ * Payload of the ADM_CMD_GET_PP_TOPO_MODULE_LIST command.
+ */
+struct adm_cmd_get_pp_topo_module_list {
+ struct apr_hdr apr_hdr;
+
+ /* The memory mapping header to be used when requesting out of band */
+ struct mem_mapping_hdr mem_hdr;
+
/*
* Maximum data size of the list of modules. This
* field is a multiple of 4 bytes.
*/
- uint16_t param_max_size;
- /* This field must be set to zero. */
- uint16_t reserved;
-} __packed;
-
-/*
- * Payload of the ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST message, which returns
- * module ids in response to an ADM_CMD_GET_PP_TOPO_MODULE_LIST command.
- * Immediately following this structure is the acknowledgment <b>module id
- * data variable payload</b> containing the pre/postprocessing module id
- * values. For an in-band scenario, the variable payload depends on the size
- * of the parameter.
- */
-struct adm_cmd_rsp_get_pp_topo_module_list_t {
- /* Status message (error code). */
- uint32_t status;
+ uint32_t param_max_size;
} __packed;
struct audproc_topology_module_id_info_t {
@@ -8062,9 +8045,6 @@
struct asm_volume_ctrl_master_gain {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
uint16_t master_gain;
/* Linear gain in Q13 format. */
@@ -8074,10 +8054,6 @@
struct asm_volume_ctrl_lr_chan_gain {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
-
uint16_t l_chan_gain;
/*< Linear gain in Q13 format for the left channel. */
@@ -8097,9 +8073,6 @@
struct asm_volume_ctrl_mute_config {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
uint32_t mute_flag;
/*< Specifies whether mute is disabled (0) or enabled (nonzero).*/
@@ -8127,9 +8100,6 @@
* parameters used by the Volume Control module.
*/
struct asm_soft_step_volume_params {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
uint32_t period;
/*< Period in milliseconds.
* Supported values: 0 to 15000
@@ -8159,9 +8129,6 @@
struct asm_soft_pause_params {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
uint32_t enable_flag;
/*< Specifies whether soft pause is disabled (0) or enabled
* (nonzero).
@@ -8251,10 +8218,7 @@
struct asm_volume_ctrl_multichannel_gain {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
- uint32_t num_channels;
+ uint32_t num_channels;
/*
* Number of channels for which gain values are provided. Any
* channels present in the data for which gain is not provided are
@@ -8279,9 +8243,6 @@
struct asm_volume_ctrl_channelype_mute_pair {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
uint8_t channelype;
/*< Channel type for which the mute setting is to be applied.
* Supported values:
@@ -8330,9 +8291,6 @@
struct asm_volume_ctrl_multichannel_mute {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
uint32_t num_channels;
/*< Number of channels for which mute configuration is
* provided. Any channels present in the data for which mute
@@ -8777,9 +8735,6 @@
} __packed;
struct asm_eq_params {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
uint32_t enable_flag;
/*< Specifies whether the equalizer module is disabled (0) or enabled
* (nonzero).
@@ -9206,15 +9161,13 @@
} __packed;
struct afe_sp_th_vi_get_param {
- struct apr_hdr hdr;
- struct afe_port_cmd_get_param_v2 get_param;
- struct afe_port_param_data_v2 pdata;
+ struct param_hdr_v3 pdata;
struct afe_sp_th_vi_ftm_params param;
} __packed;
struct afe_sp_th_vi_get_param_resp {
uint32_t status;
- struct afe_port_param_data_v2 pdata;
+ struct param_hdr_v3 pdata;
struct afe_sp_th_vi_ftm_params param;
} __packed;
@@ -9280,15 +9233,13 @@
} __packed;
struct afe_sp_ex_vi_get_param {
- struct apr_hdr hdr;
- struct afe_port_cmd_get_param_v2 get_param;
- struct afe_port_param_data_v2 pdata;
+ struct param_hdr_v3 pdata;
struct afe_sp_ex_vi_ftm_params param;
} __packed;
struct afe_sp_ex_vi_get_param_resp {
uint32_t status;
- struct afe_port_param_data_v2 pdata;
+ struct param_hdr_v3 pdata;
struct afe_sp_ex_vi_ftm_params param;
} __packed;
@@ -9309,23 +9260,16 @@
struct afe_sp_rx_limiter_th_param limiter_th_cfg;
} __packed;
-struct afe_spkr_prot_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- union afe_spkr_prot_config prot_config;
-} __packed;
-
struct afe_spkr_prot_get_vi_calib {
struct apr_hdr hdr;
- struct afe_port_cmd_get_param_v2 get_param;
- struct afe_port_param_data_v2 pdata;
+ struct mem_mapping_hdr mem_hdr;
+ struct param_hdr_v3 pdata;
struct asm_calib_res_cfg res_cfg;
} __packed;
struct afe_spkr_prot_calib_get_resp {
uint32_t status;
- struct afe_port_param_data_v2 pdata;
+ struct param_hdr_v3 pdata;
struct asm_calib_res_cfg res_cfg;
} __packed;
@@ -9454,16 +9398,6 @@
#define ASM_STREAM_POSTPROC_TOPO_ID_DTS_HPX 0x00010DED
#define ASM_STREAM_POSTPROC_TOPO_ID_HPX_PLUS 0x10015000
#define ASM_STREAM_POSTPROC_TOPO_ID_HPX_MASTER 0x10015001
-struct asm_dts_eagle_param {
- struct apr_hdr hdr;
- struct asm_stream_cmd_set_pp_params_v2 param;
- struct asm_stream_param_data_v2 data;
-} __packed;
-
-struct asm_dts_eagle_param_get {
- struct apr_hdr hdr;
- struct asm_stream_cmd_get_pp_params_v2 param;
-} __packed;
/* Opcode to set BT address and license for aptx decoder */
#define APTX_DECODER_BT_ADDRESS 0x00013201
@@ -9619,6 +9553,7 @@
/* Commands/Params to pass the codec/slimbus data to DSP */
#define AFE_SVC_CMD_SET_PARAM (0x000100f3)
+#define AFE_SVC_CMD_SET_PARAM_V2 (0x000100fc)
#define AFE_MODULE_CDC_DEV_CFG (0x00010234)
#define AFE_PARAM_ID_CDC_SLIMBUS_SLAVE_CFG (0x00010235)
#define AFE_PARAM_ID_CDC_REG_CFG (0x00010236)
@@ -10018,13 +9953,6 @@
#define AFE_MODULE_CLOCK_SET 0x0001028F
#define AFE_PARAM_ID_CLOCK_SET 0x00010290
-struct afe_lpass_clk_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_clk_cfg clk_cfg;
-} __packed;
-
enum afe_lpass_digital_clk_src {
Q6AFE_LPASS_DIGITAL_ROOT_INVALID,
Q6AFE_LPASS_DIGITAL_ROOT_PRI_MI2S_OSR,
@@ -10060,14 +9988,6 @@
u16 reserved;
} __packed;
-
-struct afe_lpass_digital_clk_config_command {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_digital_clk_cfg clk_cfg;
-} __packed;
-
/*
* Opcode for AFE to start DTMF.
*/
@@ -10176,18 +10096,32 @@
struct afe_param_cdc_reg_cfg *reg_data;
} __packed;
-struct afe_svc_cmd_set_param {
+struct afe_svc_cmd_set_param_v1 {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
+
+ /* The total size of the payload, including param_hdr_v3 */
uint32_t payload_size;
- uint32_t payload_address_lsw;
- uint32_t payload_address_msw;
- uint32_t mem_map_handle;
+
+ /* The memory mapping header to be used when sending outband */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The parameter data to be filled when sent inband */
+ u32 param_data[0];
} __packed;
-struct afe_svc_param_data {
- uint32_t module_id;
- uint32_t param_id;
- uint16_t param_size;
- uint16_t reserved;
+struct afe_svc_cmd_set_param_v2 {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
+
+ /* The memory mapping header to be used when sending outband */
+ struct mem_mapping_hdr mem_hdr;
+
+ /* The total size of the payload, including param_hdr_v3 */
+ u32 payload_size;
+
+ /* The parameter data to be filled when sent inband */
+ u32 param_data[0];
} __packed;
struct afe_param_hw_mad_ctrl {
@@ -10196,87 +10130,9 @@
uint16_t mad_enable;
} __packed;
-struct afe_cmd_hw_mad_ctrl {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_hw_mad_ctrl payload;
-} __packed;
-
-struct afe_cmd_hw_mad_slimbus_slave_port_cfg {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_slimbus_slave_port_cfg sb_port_cfg;
-} __packed;
-
-struct afe_cmd_sw_mad_enable {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
-} __packed;
-
-struct afe_param_cdc_reg_cfg_payload {
- struct afe_svc_param_data common;
- struct afe_param_cdc_reg_cfg reg_cfg;
-} __packed;
-
-struct afe_lpass_clk_config_command_v2 {
- struct apr_hdr hdr;
- struct afe_svc_cmd_set_param param;
- struct afe_svc_param_data pdata;
- struct afe_clk_set clk_cfg;
-} __packed;
-
-/*
- * reg_data's size can be up to AFE_MAX_CDC_REGISTERS_TO_CONFIG
- */
-struct afe_svc_cmd_cdc_reg_cfg {
- struct apr_hdr hdr;
- struct afe_svc_cmd_set_param param;
- struct afe_param_cdc_reg_cfg_payload reg_data[0];
-} __packed;
-
-struct afe_svc_cmd_init_cdc_reg_cfg {
- struct apr_hdr hdr;
- struct afe_svc_cmd_set_param param;
- struct afe_port_param_data_v2 init;
-} __packed;
-
-struct afe_svc_cmd_sb_slave_cfg {
- struct apr_hdr hdr;
- struct afe_svc_cmd_set_param param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_cdc_slimbus_slave_cfg sb_slave_cfg;
-} __packed;
-
-struct afe_svc_cmd_cdc_reg_page_cfg {
- struct apr_hdr hdr;
- struct afe_svc_cmd_set_param param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_cdc_reg_page_cfg cdc_reg_page_cfg;
-} __packed;
-
-struct afe_svc_cmd_cdc_aanc_version {
- struct apr_hdr hdr;
- struct afe_svc_cmd_set_param param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_id_cdc_aanc_version version;
-} __packed;
-
-struct afe_port_cmd_set_aanc_param {
- struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
- struct afe_port_param_data_v2 pdata;
- union {
- struct afe_param_aanc_port_cfg aanc_port_cfg;
- struct afe_mod_enable_param mod_enable;
- } __packed data;
-} __packed;
-
struct afe_port_cmd_set_aanc_acdb_table {
struct apr_hdr hdr;
- struct afe_port_cmd_set_param_v2 param;
+ struct mem_mapping_hdr mem_hdr;
} __packed;
/* Dolby DAP topology */
@@ -10299,13 +10155,6 @@
#define Q14_GAIN_ZERO_POINT_FIVE 0x2000
#define Q14_GAIN_UNITY 0x4000
-struct afe_svc_cmd_set_clip_bank_selection {
- struct apr_hdr hdr;
- struct afe_svc_cmd_set_param param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_id_clip_bank_sel bank_sel;
-} __packed;
-
/* Ultrasound supported formats */
#define US_POINT_EPOS_FORMAT_V2 0x0001272D
#define US_RAW_FORMAT_V2 0x0001272C
@@ -10532,13 +10381,6 @@
struct afe_param_id_group_device_tdm_cfg tdm_cfg;
} __packed;
-struct afe_port_group_create {
- struct apr_hdr hdr;
- struct afe_svc_cmd_set_param param;
- struct afe_port_param_data_v2 pdata;
- union afe_port_group_config data;
-} __packed;
-
/* ID of the parameter used by #AFE_MODULE_AUDIO_DEV_INTERFACE to specify
* the timing statistics of the corresponding device interface.
* Client can periodically query for the device time statistics to help adjust
@@ -10628,16 +10470,9 @@
u32 ref_timer_abs_ts_msw;
} __packed;
-struct afe_av_dev_drift_get_param {
- struct apr_hdr hdr;
- struct afe_port_cmd_get_param_v2 get_param;
- struct afe_port_param_data_v2 pdata;
- struct afe_param_id_dev_timing_stats timing_stats;
-} __packed;
-
struct afe_av_dev_drift_get_param_resp {
uint32_t status;
- struct afe_port_param_data_v2 pdata;
+ struct param_hdr_v3 pdata;
struct afe_param_id_dev_timing_stats timing_stats;
} __packed;
@@ -10849,7 +10684,7 @@
struct asm_mtmx_strtr_params {
struct apr_hdr hdr;
struct asm_session_cmd_set_mtmx_strstr_params_v2 param;
- struct asm_stream_param_data_v2 data;
+ struct param_hdr_v1 data;
union asm_session_mtmx_strtr_param_config config;
} __packed;
@@ -10959,7 +10794,7 @@
struct asm_mtmx_strtr_get_params_cmdrsp {
uint32_t err_code;
- struct asm_stream_param_data_v2 param_info;
+ struct param_hdr_v1 param_info;
union asm_session_mtmx_strtr_data_type param_data;
} __packed;
@@ -10979,18 +10814,14 @@
#define AUDPROC_PARAM_ID_COMPRESSED_MUTE 0x00010771
struct adm_set_compressed_device_mute {
- struct adm_cmd_set_pp_params_v5 command;
- struct adm_param_data_v5 params;
- u32 mute_on;
+ u32 mute_on;
} __packed;
#define AUDPROC_MODULE_ID_COMPRESSED_LATENCY 0x0001076E
#define AUDPROC_PARAM_ID_COMPRESSED_LATENCY 0x0001076F
struct adm_set_compressed_device_latency {
- struct adm_cmd_set_pp_params_v5 command;
- struct adm_param_data_v5 params;
- u32 latency;
+ u32 latency;
} __packed;
#define VOICEPROC_MODULE_ID_GENERIC_TX 0x00010EF6
@@ -11020,12 +10851,6 @@
uint16_t reserved;
} __packed;
-struct adm_set_fluence_soundfocus_param {
- struct adm_cmd_set_pp_params_v5 params;
- struct adm_param_data_v5 data;
- struct adm_param_fluence_soundfocus_t soundfocus_data;
-} __packed;
-
struct adm_param_fluence_sourcetracking_t {
uint8_t vad[MAX_SECTORS];
uint16_t doa_speech;
@@ -11055,10 +10880,4 @@
uint16_t reserved1;
} __packed;
-
-struct adm_set_sec_primary_ch_params {
- struct adm_cmd_set_pp_params_v5 params;
- struct adm_param_data_v5 data;
- struct admx_sec_primary_mic_ch sec_primary_mic_ch_data;
-} __packed;
#endif /*_APR_AUDIO_V2_H_ */
diff --git a/include/dsp/q6adm-v2.h b/include/dsp/q6adm-v2.h
index 881943b..bc3fdcf 100644
--- a/include/dsp/q6adm-v2.h
+++ b/include/dsp/q6adm-v2.h
@@ -25,6 +25,8 @@
#define MAX_MODULES_IN_TOPO 16
#define ADM_GET_TOPO_MODULE_LIST_LENGTH\
((MAX_MODULES_IN_TOPO + 1) * sizeof(uint32_t))
+#define ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH \
+ ((MAX_MODULES_IN_TOPO + 1) * 2 * sizeof(uint32_t))
#define AUD_PROC_BLOCK_SIZE 4096
#define AUD_VOL_BLOCK_SIZE 4096
#define AUDIO_RX_CALIBRATION_SIZE (AUD_PROC_BLOCK_SIZE + \
@@ -91,14 +93,20 @@
void adm_copp_mfc_cfg(int port_id, int copp_idx, int dst_sample_rate);
-int adm_get_params(int port_id, int copp_idx, uint32_t module_id,
- uint32_t param_id, uint32_t params_length, char *params);
+int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id,
+ struct mem_mapping_hdr *mem_hdr,
+ struct param_hdr_v3 *param_hdr, u8 *returned_param_data);
int adm_send_params_v5(int port_id, int copp_idx, char *params,
uint32_t params_length);
-int adm_dolby_dap_send_params(int port_id, int copp_idx, char *params,
- uint32_t params_length);
+int adm_set_pp_params(int port_id, int copp_idx,
+ struct mem_mapping_hdr *mem_hdr, u8 *param_data,
+ u32 params_size);
+
+int adm_pack_and_set_one_pp_param(int port_id, int copp_idx,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data);
int adm_open(int port, int path, int rate, int mode, int topology,
int perf_mode, uint16_t bits_per_sample,
@@ -146,6 +154,10 @@
int adm_get_pp_topo_module_list(int port_id, int copp_idx, int32_t param_length,
char *params);
+int adm_get_pp_topo_module_list_v2(int port_id, int copp_idx,
+ int32_t param_length,
+ int32_t *returned_params);
+
int adm_set_volume(int port_id, int copp_idx, int volume);
int adm_set_softvolume(int port_id, int copp_idx,
@@ -158,6 +170,9 @@
int adm_param_enable(int port_id, int copp_idx, int module_id, int enable);
+int adm_param_enable_v2(int port_id, int copp_idx,
+ struct module_instance_info mod_inst_info, int enable);
+
int adm_send_calibration(int port_id, int copp_idx, int path, int perf_mode,
int cal_type, char *params, int size);
diff --git a/include/dsp/q6asm-v2.h b/include/dsp/q6asm-v2.h
index 27b360f..c92cacf 100644
--- a/include/dsp/q6asm-v2.h
+++ b/include/dsp/q6asm-v2.h
@@ -264,6 +264,17 @@
int q6asm_audio_client_buf_free_contiguous(unsigned int dir,
struct audio_client *ac);
+int q6asm_set_pp_params(struct audio_client *ac,
+ struct mem_mapping_hdr *mem_hdr, u8 *param_data,
+ u32 param_size);
+
+int q6asm_pack_and_set_pp_param_in_band(struct audio_client *ac,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data);
+
+int q6asm_set_soft_volume_module_instance_ids(int instance,
+ struct param_hdr_v3 *param_hdr);
+
int q6asm_open_read(struct audio_client *ac, uint32_t format
/*, uint16_t bits_per_sample*/);
@@ -624,9 +635,6 @@
int q6asm_get_session_time_legacy(struct audio_client *ac, uint64_t *tstamp);
-int q6asm_send_audio_effects_params(struct audio_client *ac, char *params,
- uint32_t params_length);
-
int q6asm_send_stream_cmd(struct audio_client *ac,
struct msm_adsp_event_data *data);
diff --git a/include/uapi/sound/audio_effects.h b/include/uapi/sound/audio_effects.h
index 7964c34..f38b212 100644
--- a/include/uapi/sound/audio_effects.h
+++ b/include/uapi/sound/audio_effects.h
@@ -145,8 +145,12 @@
#define PBE_ENABLE_PARAM_LEN 1
#define PBE_CONFIG_PARAM_LEN 28
+/* Command Payload length and size for Non-IID commands */
#define COMMAND_PAYLOAD_LEN 3
#define COMMAND_PAYLOAD_SZ (COMMAND_PAYLOAD_LEN * sizeof(uint32_t))
+/* Command Payload length and size for IID commands */
+#define COMMAND_IID_PAYLOAD_LEN 4
+#define COMMAND_IID_PAYLOAD_SZ (COMMAND_IID_PAYLOAD_LEN * sizeof(uint32_t))
#define MAX_INBAND_PARAM_SZ 4096
#define Q27_UNITY (1 << 27)
#define Q8_UNITY (1 << 8)