Alsa-devel
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
May 2024
- 67 participants
- 190 discussions
19 Aug '24
This patch series updated the spi-nor, spi core and the AMD-Xilinx GQSPI
driver to add stacked and parallel memories support.
The first nine patches
https://lore.kernel.org/all/20230119185342.2093323-1-amit.kumar-mahapatra@a…
https://lore.kernel.org/all/20230310173217.3429788-2-amit.kumar-mahapatra@a…
https://lore.kernel.org/all/20230310173217.3429788-3-amit.kumar-mahapatra@a…
https://lore.kernel.org/all/20230310173217.3429788-4-amit.kumar-mahapatra@a…
https://lore.kernel.org/all/20230310173217.3429788-5-amit.kumar-mahapatra@a…
https://lore.kernel.org/all/20230310173217.3429788-6-amit.kumar-mahapatra@a…
https://lore.kernel.org/all/20230310173217.3429788-7-amit.kumar-mahapatra@a…
https://lore.kernel.org/all/20230310173217.3429788-8-amit.kumar-mahapatra@a…
https://lore.kernel.org/all/20230310173217.3429788-9-amit.kumar-mahapatra@a…
of the previous series got applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
for-next But the rest of the patches in the series did not get applied as
failure was reported for spi driver with GPIO CS, so send the remaining
patches in the series after rebasing it on top of for-next branch and
fixing the issue.
CS GPIO is not tested on our hardware, but it has been tested by @Stefan
https://lore.kernel.org/all/005001da1efc$619ad5a0$24d080e0$@opensource.cirr…
---
BRANCH: for-next
Changes in v11:
- Rebased patch series on top of latest for-next branch.
- Added a new patch(1/10) to replace spi->chip_select with
spi_get_chipselect() call in tps6594-spi.c.
- Added a new patch(2/10) to replace spi->chip_select with
spi_get_chipseletc() call in cs35l56_hda_spi.c.
- In spi.c initialized unused CS[] to 0xff and spi->cs_index_mask
to 0x01 in all flows.
- Updated spi_dev_check() to compare the CS of old spi device with
the new spi device CS.
- Updated cover letter description to add information regarding GPIO CS
testing and added Stefen's Tested-by tag in 3/10 patch.
Changes in v10:
- Rebased patch series on top of latest for-next branch and fixed
merge conflicts.
Changes in v9:
- Updated 1/8 patch description to add an high-level overview of
parallel(multi-cs) & stacked design.
- Initialized all unused CS to 0xFF.
- Moved CS check from spi_add_device() to __spi_add_device().
- Updated __spi_add_device() to check to make sure that multiple logical CS
don't map to the same physical CS and same physical CS doesn't map to
different logical CS.
- Updated 1/8, 5/8 & 7/8 to support arbitrary number of flash devices
connected in parallel or stacked mode.
- Updated documentation for chip_select.
- Added a new spi-nor structure member nor->num_flash to keep track of the
number of flashes connected.
- Added a new patch in the series 4/8 to move write_enable call just before
spi_mem ops call in SPI-NOR.
- Added comments in SPI core & SPI-NOR.
- Rebased the patch series on top of the latest for-next branch.
Changes in v8:
- Updated __spi_add_device() and spi_set_cs() to fix spi driver failure
with GPIO CS.
- Rebased the patch series on top of latest for-next branch and fixed
merge conflicts.
- Updated cover letter description to add information regarding GPIO CS
testing and request Stefan to provide his Tested-by tag for 1/7 patch.
- Updated 1/7 patch description.
Changes in v7:
- Updated spi_dev_check() to avoid failures for spi driver GPIO CS and
moved the error message from __spi_add_device() to spi_dev_check().
- Resolved code indentation issue in spi_set_cs().
- In spi_set_cs() call spi_delay_exec( ) once if the controller supports
multi cs with both the CS backed by GPIO.
- Updated __spi_validate()to add checks for both the GPIO CS.
- Replaced cs_index_mask bit mask with SPI_CS_CNT_MAX.
- Updated struct spi_controller to represent multi CS capability of the
spi controller through a flag bit SPI_CONTROLLER_MULTI_CS instead of
a boolen structure member "multi_cs_cap".
- Updated 1/7 patch description .
Changes in v6:
- Rebased on top of latest v6.3-rc1 and fixed merge conflicts in
spi-mpc512x-psc.c, sfdp.c, spansion.c files and removed spi-omap-100k.c.
- Updated spi_dev_check( ) to reject new devices if any one of the
chipselect is used by another device.
Changes in v5:
- Rebased the patches on top of v6.3-rc1 and fixed the merge conflicts.
- Fixed compilation warnings in spi-sh-msiof.c with shmobile_defconfig
Changes in v4:
- Fixed build error in spi-pl022.c file - reported by Mark.
- Fixed build error in spi-sn-f-ospi.c file.
- Added Reviewed-by: Serge Semin <fancer.lancer(a)gmail.com> tag.
- Added two more patches to replace spi->chip_select with API calls in
mpc832x_rdb.c & cs35l41_hda_spi.c files.
Changes in v3:
- Rebased the patches on top of
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
- Added a patch to convert spi_nor_otp_region_len(nor) &
spi_nor_otp_n_regions(nor) macros into inline functions
- Added Reviewed-by & Acked-by tags
Changes in v2:
- Rebased the patches on top of v6.2-rc1
- Created separate patch to add get & set APIs for spi->chip_select &
spi->cs_gpiod, and replaced all spi->chip_select and spi->cs_gpiod
references with the API calls.
- Created separate patch to add get & set APIs for nor->params.
---
Amit Kumar Mahapatra (10):
mfd: tps6594: Use set/get APIs to access spi->chip_select
ALSA: hda/cs35l56: Use set/get APIs to access spi->chip_select
spi: Add multi-cs memories support in SPI core
mtd: spi-nor: Convert macros with inline functions
mtd: spi-nor: Add APIs to set/get nor->params
mtd: spi-nor: Move write enable inside specific write & erase APIs
mtd: spi-nor: Add stacked memories support in spi-nor
spi: spi-zynqmp-gqspi: Add stacked memories support in GQSPI driver
mtd: spi-nor: Add parallel memories support in spi-nor
spi: spi-zynqmp-gqspi: Add parallel memories support in GQSPI driver
drivers/mfd/tps6594-spi.c | 2 +-
drivers/mtd/spi-nor/atmel.c | 17 +-
drivers/mtd/spi-nor/core.c | 683 +++++++++++++++++++++++++------
drivers/mtd/spi-nor/core.h | 8 +
drivers/mtd/spi-nor/debugfs.c | 4 +-
drivers/mtd/spi-nor/gigadevice.c | 4 +-
drivers/mtd/spi-nor/issi.c | 11 +-
drivers/mtd/spi-nor/macronix.c | 10 +-
drivers/mtd/spi-nor/micron-st.c | 35 +-
drivers/mtd/spi-nor/otp.c | 48 ++-
drivers/mtd/spi-nor/sfdp.c | 33 +-
drivers/mtd/spi-nor/spansion.c | 57 +--
drivers/mtd/spi-nor/sst.c | 7 +-
drivers/mtd/spi-nor/swp.c | 25 +-
drivers/mtd/spi-nor/winbond.c | 2 +-
drivers/mtd/spi-nor/xilinx.c | 18 +-
drivers/spi/spi-zynqmp-gqspi.c | 58 ++-
drivers/spi/spi.c | 259 ++++++++++--
include/linux/mtd/spi-nor.h | 21 +-
include/linux/spi/spi.h | 51 ++-
sound/pci/hda/cs35l56_hda_spi.c | 2 +-
21 files changed, 1085 insertions(+), 270 deletions(-)
--
2.17.1
10
61
[PATCH v1] ASoc: tas2781: Add Calibration Kcontrols and tas2563 digtial gain for Chromebook
by Shenghao Ding 09 Aug '24
by Shenghao Ding 09 Aug '24
09 Aug '24
Calibrated data will be set to default after loading DSP config params,
which will cause speaker protection work abnormally. Reload calibrated
data after loading DSP config params.
Signed-off-by: Shenghao Ding <shenghao-ding(a)ti.com>
---
v1:
- Changed the copyright year to 2024 in the related files.
- Add CAL_DAT_SZ for calibrated data size.
- Add TAS2563_DVC_LVL for digtial gain kcontrol.
- Add registers for TAS2563 and TAS2781 calibration.
- Add cali_data_restore for regsiter restore after calibration.
- Add is_user_space_calidata to store the flag where the calibrated
from, user space or bin file from driver parsing.
- Add TASDEVICE_RCA_FW_OK to support only register setting bin in the
device.
- Add tas2563_dvc_table for relationship between tas2563 digtial gains
and register values.
- Correct the filename in the header comments of tas2781-comlib.c,
tas2781-lib.c --> tas2781-comlib.c.
- tasdevice_chn_switch for chip switch among multiple chips(tas2563
or tas2781)
- Add loading the calibrated values from user space in
tasdev_load_calibrated_data
- Correct no dsp no work, it can still work in bypass mode.
- Add calibrated register setting for tas2563&tas2781.
- Add mutex into each kcontrol.
- rename tas2781_force_fwload_get, tas2781_force_fwload_put-->
tasdev_force_fwload_get, tasdev_force_fwload_put
- rename tas2781_codec --> tasdev_codec
- define tas2781_snd_control and tas2563_snd_control for volume
- define tas2781_cali_control and tas2563_cali_control for calibration
---
include/sound/tas2781-dsp.h | 1 +
include/sound/tas2781.h | 92 ++-
sound/soc/codecs/tas2781-comlib.c | 35 +-
sound/soc/codecs/tas2781-fmwlib.c | 51 +-
sound/soc/codecs/tas2781-i2c.c | 941 +++++++++++++++++++++++++++++-
5 files changed, 1061 insertions(+), 59 deletions(-)
diff --git a/include/sound/tas2781-dsp.h b/include/sound/tas2781-dsp.h
index 7fba7ea26a4b..74ab6f113029 100644
--- a/include/sound/tas2781-dsp.h
+++ b/include/sound/tas2781-dsp.h
@@ -121,6 +121,7 @@ enum tasdevice_dsp_fw_state {
TASDEVICE_DSP_FW_NONE = 0,
TASDEVICE_DSP_FW_PENDING,
TASDEVICE_DSP_FW_FAIL,
+ TASDEVICE_RCA_FW_OK,
TASDEVICE_DSP_FW_ALL_OK,
};
diff --git a/include/sound/tas2781.h b/include/sound/tas2781.h
index 99ca3e401fd1..2fb3d03d0040 100644
--- a/include/sound/tas2781.h
+++ b/include/sound/tas2781.h
@@ -2,7 +2,7 @@
//
// ALSA SoC Texas Instruments TAS2563/TAS2781 Audio Smart Amplifier
//
-// Copyright (C) 2022 - 2023 Texas Instruments Incorporated
+// Copyright (C) 2022 - 2024 Texas Instruments Incorporated
// https://www.ti.com
//
// The TAS2563/TAS2781 driver implements a flexible and configurable
@@ -23,6 +23,8 @@
#define SMARTAMP_MODULE_NAME "tas2781"
#define TAS2781_GLOBAL_ADDR 0x40
#define TAS2563_GLOBAL_ADDR 0x48
+#define CAL_DAT_SZ 20
+
#define TASDEVICE_RATES (SNDRV_PCM_RATE_44100 |\
SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\
SNDRV_PCM_RATE_88200)
@@ -31,6 +33,11 @@
SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_S32_LE)
+#define TASDEVICE_CMD_SING_W 0x1
+#define TASDEVICE_CMD_BURST 0x2
+#define TASDEVICE_CMD_DELAY 0x3
+#define TASDEVICE_CMD_FIELD_W 0x4
+
/*PAGE Control Register (available in page0 of each book) */
#define TASDEVICE_PAGE_SELECT 0x00
#define TASDEVICE_BOOKCTL_PAGE 0x00
@@ -43,21 +50,73 @@
(page * 128)) + reg)
/*Software Reset */
-#define TAS2781_REG_SWRESET TASDEVICE_REG(0x0, 0X0, 0x01)
-#define TAS2781_REG_SWRESET_RESET BIT(0)
+#define TASDEVICE_REG_SWRESET TASDEVICE_REG(0x00, 0X00, 0x01)
+#define TASDEVICE_REG_SWRESET_RESET BIT(0)
/*I2C Checksum */
-#define TASDEVICE_I2CChecksum TASDEVICE_REG(0x0, 0x0, 0x7E)
+#define TASDEVICE_I2CChecksum TASDEVICE_REG(0x00, 0x00, 0x7E)
+
+/* XM_340 */
+#define TASDEVICE_XM_A1_REG TASDEVICE_REG(0x64, 0x02, 0x4c)
+/* XM_341 */
+#define TASDEVICE_XM_A2_REG TASDEVICE_REG(0x64, 0x02, 0x64)
/* Volume control */
-#define TAS2781_DVC_LVL TASDEVICE_REG(0x0, 0x0, 0x1A)
-#define TAS2781_AMP_LEVEL TASDEVICE_REG(0x0, 0x0, 0x03)
+#define TAS2563_DVC_LVL TASDEVICE_REG(0x00, 0x02, 0x0C)
+#define TAS2781_DVC_LVL TASDEVICE_REG(0x00, 0x00, 0x1A)
+#define TAS2781_AMP_LEVEL TASDEVICE_REG(0x00, 0x00, 0x03)
#define TAS2781_AMP_LEVEL_MASK GENMASK(5, 1)
-#define TASDEVICE_CMD_SING_W 0x1
-#define TASDEVICE_CMD_BURST 0x2
-#define TASDEVICE_CMD_DELAY 0x3
-#define TASDEVICE_CMD_FIELD_W 0x4
+#define TAS2563_PRM_R0_REG TASDEVICE_REG(0x00, 0x0f, 0x34)
+#define TAS2563_PRM_R0_LOW_REG TASDEVICE_REG(0x00, 0x0f, 0x48)
+#define TAS2563_PRM_INVR0_REG TASDEVICE_REG(0x00, 0x0f, 0x40)
+#define TAS2563_PRM_POW_REG TASDEVICE_REG(0x00, 0x0d, 0x3c)
+#define TAS2563_PRM_TLIMIT_REG TASDEVICE_REG(0x00, 0x10, 0x14)
+
+#define TAS2563_RUNTIME_RE_REG_TF TASDEVICE_REG(0x64, 0x02, 0x70)
+#define TAS2563_RUNTIME_RE_REG TASDEVICE_REG(0x64, 0x02, 0x48)
+
+#define TAS2563_PRM_ENFF_REG TASDEVICE_REG(0x00, 0x0d, 0x54)
+#define TAS2563_PRM_DISTCK_REG TASDEVICE_REG(0x00, 0x0d, 0x58)
+#define TAS2563_PRM_TE_SCTHR_REG TASDEVICE_REG(0x00, 0x0f, 0x60)
+#define TAS2563_PRM_PLT_FLAG_REG TASDEVICE_REG(0x00, 0x0d, 0x74)
+#define TAS2563_PRM_SINEGAIN_REG TASDEVICE_REG(0x00, 0x0d, 0x7c)
+/* prm_Int_B0 */
+#define TAS2563_TE_TA1_REG TASDEVICE_REG(0x00, 0x10, 0x0c)
+/* prm_Int_A1 */
+#define TAS2563_TE_TA1_AT_REG TASDEVICE_REG(0x00, 0x10, 0x10)
+/* prm_TE_Beta */
+#define TAS2563_TE_TA2_REG TASDEVICE_REG(0x00, 0x0f, 0x64)
+/* prm_TE_Beta1 */
+#define TAS2563_TE_AT_REG TASDEVICE_REG(0x00, 0x0f, 0x68)
+/* prm_TE_1_Beta1 */
+#define TAS2563_TE_DT_REG TASDEVICE_REG(0x00, 0x0f, 0x70)
+
+#define TAS2781_PRM_R0_REG TASDEVICE_REG(0x00, 0x17, 0x74)
+#define TAS2781_PRM_R0_LOW_REG TASDEVICE_REG(0x00, 0x18, 0x0c)
+#define TAS2781_PRM_INVR0_REG TASDEVICE_REG(0x00, 0x18, 0x14)
+#define TAS2781_PRM_POW_REG TASDEVICE_REG(0x00, 0x13, 0x70)
+#define TAS2781_PRM_TLIMIT_REG TASDEVICE_REG(0x00, 0x18, 0x7c)
+
+#define TAS2781_PRM_INT_MASK_REG TASDEVICE_REG(0x00, 0x00, 0x3b)
+#define TAS2781_PRM_CLK_CFG_REG TASDEVICE_REG(0x00, 0x00, 0x5c)
+#define TAS2781_PRM_RSVD_REG TASDEVICE_REG(0x00, 0x01, 0x19)
+#define TAS2781_PRM_TEST_57_REG TASDEVICE_REG(0x00, 0xfd, 0x39)
+#define TAS2781_PRM_TEST_62_REG TASDEVICE_REG(0x00, 0xfd, 0x3e)
+#define TAS2781_PRM_PVDD_UVLO_REG TASDEVICE_REG(0x00, 0x00, 0x71)
+#define TAS2781_PRM_CHNL_0_REG TASDEVICE_REG(0x00, 0x00, 0x03)
+#define TAS2781_PRM_NG_CFG0_REG TASDEVICE_REG(0x00, 0x00, 0x35)
+#define TAS2781_PRM_IDLE_CH_DET_REG TASDEVICE_REG(0x00, 0x00, 0x66)
+#define TAS2781_PRM_PLT_FLAG_REG TASDEVICE_REG(0x00, 0x14, 0x38)
+#define TAS2781_PRM_SINEGAIN_REG TASDEVICE_REG(0x00, 0x14, 0x40)
+#define TAS2781_PRM_SINEGAIN2_REG TASDEVICE_REG(0x00, 0x14, 0x44)
+
+#define TAS2781_TEST_UNLOCK_REG TASDEVICE_REG(0x00, 0xFD, 0x0D)
+#define TAS2781_TEST_PAGE_UNLOCK 0x0D
+
+#define TAS2781_RUNTIME_LATCH_RE_REG TASDEVICE_REG(0x00, 0x00, 0x49)
+#define TAS2781_RUNTIME_RE_REG_TF TASDEVICE_REG(0x64, 0x62, 0x48)
+#define TAS2781_RUNTIME_RE_REG TASDEVICE_REG(0x64, 0x63, 0x44)
enum audio_device {
TAS2563,
@@ -69,7 +128,15 @@ enum device_catlog_id {
OTHERS
};
+struct bulk_reg_val {
+ int reg;
+ unsigned char val[4];
+ unsigned char val_len;
+ bool is_locked;
+};
+
struct tasdevice {
+ struct bulk_reg_val *cali_data_restore;
struct tasdevice_fw *cali_data_fmw;
unsigned int dev_addr;
unsigned int err_code;
@@ -88,6 +155,8 @@ struct tasdevice_irqinfo {
struct calidata {
unsigned char *data;
unsigned long total_sz;
+ unsigned int *reg_array;
+ unsigned int reg_array_sz;
};
struct tasdevice_priv {
@@ -122,6 +191,7 @@ struct tasdevice_priv {
bool force_fwload_status;
bool playback_started;
bool isacpi;
+ bool is_user_space_calidata;
unsigned int global_addr;
int (*fw_parse_variable_header)(struct tasdevice_priv *tas_priv,
@@ -148,6 +218,8 @@ int tasdevice_init(struct tasdevice_priv *tas_priv);
void tasdevice_remove(struct tasdevice_priv *tas_priv);
int tasdevice_save_calibration(struct tasdevice_priv *tas_priv);
void tasdevice_apply_calibration(struct tasdevice_priv *tas_priv);
+int tasdevice_chn_switch(struct tasdevice_priv *tas_priv,
+ unsigned short chn);
int tasdevice_dev_read(struct tasdevice_priv *tas_priv,
unsigned short chn, unsigned int reg, unsigned int *value);
int tasdevice_dev_write(struct tasdevice_priv *tas_priv,
diff --git a/sound/soc/codecs/tas2781-comlib.c b/sound/soc/codecs/tas2781-comlib.c
index 3aa81514dad7..9d7b56663b6b 100644
--- a/sound/soc/codecs/tas2781-comlib.c
+++ b/sound/soc/codecs/tas2781-comlib.c
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
//
-// tas2781-lib.c -- TAS2781 Common functions for HDA and ASoC Audio drivers
+// tas2781-comlib.c -- TAS2781 Common functions for HDA and ASoC Audio drivers
//
-// Copyright 2023 Texas Instruments, Inc.
+// Copyright 2023 - 2024 Texas Instruments, Inc.
//
// Author: Shenghao Ding <shenghao-ding(a)ti.com>
@@ -89,6 +89,33 @@ static int tasdevice_change_chn_book(struct tasdevice_priv *tas_priv,
return ret;
}
+int tasdevice_chn_switch(struct tasdevice_priv *tas_priv,
+ unsigned short chn)
+{
+ struct i2c_client *client = (struct i2c_client *)tas_priv->client;
+ struct tasdevice *tasdev = &tas_priv->tasdevice[chn];
+ struct regmap *map = tas_priv->regmap;
+ int ret;
+
+ if (client->addr != tasdev->dev_addr) {
+ client->addr = tasdev->dev_addr;
+ /* All devices share the same regmap, clear the page
+ * inside regmap once switching to another device.
+ * Register 0 at any pages and any books inside tas2781
+ * is the same one for page-switching.
+ */
+ ret = regmap_write(map, TASDEVICE_PAGE_SELECT, 0);
+ if (ret < 0) {
+ dev_err(tas_priv->dev, "%s, E=%d\n",
+ __func__, ret);
+ return ret;
+ }
+ return 1;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(tasdevice_chn_switch);
+
int tasdevice_dev_read(struct tasdevice_priv *tas_priv,
unsigned short chn, unsigned int reg, unsigned int *val)
{
@@ -254,8 +281,8 @@ void tas2781_reset(struct tasdevice_priv *tas_dev)
} else {
for (i = 0; i < tas_dev->ndev; i++) {
ret = tasdevice_dev_write(tas_dev, i,
- TAS2781_REG_SWRESET,
- TAS2781_REG_SWRESET_RESET);
+ TASDEVICE_REG_SWRESET,
+ TASDEVICE_REG_SWRESET_RESET);
if (ret < 0)
dev_err(tas_dev->dev,
"dev %d swreset fail, %d\n",
diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-fmwlib.c
index 265a8ca25cbb..19a5133083dc 100644
--- a/sound/soc/codecs/tas2781-fmwlib.c
+++ b/sound/soc/codecs/tas2781-fmwlib.c
@@ -2153,20 +2153,39 @@ static int tasdevice_load_data(struct tasdevice_priv *tas_priv,
static void tasdev_load_calibrated_data(struct tasdevice_priv *priv, int i)
{
+ struct tasdevice_fw *cal_fmw = priv->tasdevice[i].cali_data_fmw;
+ struct calidata *cali_data = &priv->cali_data;
+ unsigned char *data = cali_data->data;
struct tasdevice_calibration *cal;
- struct tasdevice_fw *cal_fmw;
+ int k = i * (CAL_DAT_SZ + 1);
+ int j, rc;
- cal_fmw = priv->tasdevice[i].cali_data_fmw;
+ if (!priv->is_user_space_calidata &&
+ cal_fmw) {
+ cal = cal_fmw->calibrations;
- /* No calibrated data for current devices, playback will go ahead. */
- if (!cal_fmw)
+ if (cal)
+ load_calib_data(priv, &cal->dev_data);
return;
-
- cal = cal_fmw->calibrations;
- if (cal)
+ }
+ if (!priv->is_user_space_calidata)
return;
-
- load_calib_data(priv, &cal->dev_data);
+ /* load calibrated data from user space */
+ if (data[k] != i) {
+ dev_err(priv->dev, "%s: no cal-data for dev %d from usr-spc\n",
+ __func__, i);
+ return;
+ }
+ for (j = 0; j < cali_data->reg_array_sz; j++) {
+ if (data[k] != j)
+ rc = tasdevice_dev_bulk_write(priv, i,
+ cali_data->reg_array[j],
+ &(data[k + 4 * j]), 4);
+ if (rc < 0)
+ dev_err(priv->dev,
+ "chn %d calib %d bulk_wr err = %d\n",
+ i, j, rc);
+ }
}
int tasdevice_select_tuningprm_cfg(void *context, int prm_no,
@@ -2261,9 +2280,10 @@ int tasdevice_select_tuningprm_cfg(void *context, int prm_no,
tas_priv->tasdevice[i].cur_conf = cfg_no;
}
}
- } else
+ } else {
dev_dbg(tas_priv->dev, "%s: Unneeded loading dsp conf %d\n",
__func__, cfg_no);
+ }
status |= cfg_info[rca_conf_no]->active_dev;
@@ -2324,13 +2344,15 @@ void tasdevice_tuning_switch(void *context, int state)
struct tasdevice_fw *tas_fmw = tas_priv->fmw;
int profile_cfg_id = tas_priv->rcabin.profile_cfg_id;
- if (tas_priv->fw_state == TASDEVICE_DSP_FW_FAIL) {
- dev_err(tas_priv->dev, "DSP bin file not loaded\n");
+ /* Only RCA file loaded still can work without speaker protection */
+ if (!(tas_priv->fw_state == TASDEVICE_RCA_FW_OK ||
+ tas_priv->fw_state == TASDEVICE_DSP_FW_ALL_OK)) {
+ dev_err(tas_priv->dev, "No firmware loaded\n");
return;
}
if (state == 0) {
- if (tas_priv->cur_prog < tas_fmw->nr_programs) {
+ if (tas_fmw && tas_priv->cur_prog < tas_fmw->nr_programs) {
/*dsp mode or tuning mode*/
profile_cfg_id = tas_priv->rcabin.profile_cfg_id;
tasdevice_select_tuningprm_cfg(tas_priv,
@@ -2340,9 +2362,10 @@ void tasdevice_tuning_switch(void *context, int state)
tasdevice_select_cfg_blk(tas_priv, profile_cfg_id,
TASDEVICE_BIN_BLK_PRE_POWER_UP);
- } else
+ } else {
tasdevice_select_cfg_blk(tas_priv, profile_cfg_id,
TASDEVICE_BIN_BLK_PRE_SHUTDOWN);
+ }
}
EXPORT_SYMBOL_NS_GPL(tasdevice_tuning_switch,
SND_SOC_TAS2781_FMWLIB);
diff --git a/sound/soc/codecs/tas2781-i2c.c b/sound/soc/codecs/tas2781-i2c.c
index 9350972dfefe..239f3538c558 100644
--- a/sound/soc/codecs/tas2781-i2c.c
+++ b/sound/soc/codecs/tas2781-i2c.c
@@ -13,6 +13,7 @@
// Author: Kevin Lu <kevin-lu(a)ti.com>
//
+#include <asm/unaligned.h>
#include <linux/crc8.h>
#include <linux/firmware.h>
#include <linux/gpio/consumer.h>
@@ -31,6 +32,122 @@
#include <sound/tlv.h>
#include <sound/tas2781-tlv.h>
+static const struct bulk_reg_val tas2563_cali_start_reg[] = {
+ {
+ .reg = TAS2563_PRM_ENFF_REG,
+ .val = { 0x40, 0x00, 0x00, 0x00 },
+ },
+ {
+ .reg = TAS2563_PRM_DISTCK_REG,
+ .val = { 0x40, 0x00, 0x00, 0x00 },
+ },
+ {
+ .reg = TAS2563_PRM_TE_SCTHR_REG,
+ .val = { 0x7f, 0xff, 0xff, 0xff },
+ },
+ {
+ .reg = TAS2563_PRM_PLT_FLAG_REG,
+ .val = { 0x40, 0x00, 0x00, 0x00 },
+ },
+ {
+ .reg = TAS2563_PRM_SINEGAIN_REG,
+ .val = { 0x0a, 0x3d, 0x70, 0xa4 },
+ },
+ {
+ .reg = TAS2563_TE_TA1_REG,
+ .val = { 0x00, 0x36, 0x91, 0x5e },
+ },
+ {
+ .reg = TAS2563_TE_TA1_AT_REG,
+ .val = { 0x00, 0x36, 0x91, 0x5e },
+ },
+ {
+ .reg = TAS2563_TE_TA2_REG,
+ .val = { 0x00, 0x06, 0xd3, 0x72 },
+ },
+ {
+ .reg = TAS2563_TE_AT_REG,
+ .val = { 0x00, 0x36, 0x91, 0x5e },
+ },
+ {
+ .reg = TAS2563_TE_DT_REG,
+ .val = { 0x00, 0x36, 0x91, 0x5e },
+ },
+};
+
+static const struct bulk_reg_val tas2781_cali_start_reg[] = {
+ {
+ .reg = TAS2781_PRM_INT_MASK_REG,
+ .val = { 0xfe },
+ .val_len = 1,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_CLK_CFG_REG,
+ .val = { 0xdd },
+ .val_len = 1,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_RSVD_REG,
+ .val = { 0x20 },
+ .val_len = 1,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_TEST_57_REG,
+ .val = { 0x14 },
+ .val_len = 1,
+ .is_locked = true
+ },
+ {
+ .reg = TAS2781_PRM_TEST_62_REG,
+ .val = { 0x45 },
+ .val_len = 1,
+ .is_locked = true
+ },
+ {
+ .reg = TAS2781_PRM_PVDD_UVLO_REG,
+ .val = { 0x03 },
+ .val_len = 1,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_CHNL_0_REG,
+ .val = { 0xA8 },
+ .val_len = 1,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_NG_CFG0_REG,
+ .val = { 0xb9 },
+ .val_len = 1,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_IDLE_CH_DET_REG,
+ .val = { 0x92 },
+ .val_len = 1,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_PLT_FLAG_REG,
+ .val = { 0x40, 0x00, 0x00, 0x00 },
+ .val_len = 4,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_SINEGAIN_REG,
+ .val_len = 4,
+ .is_locked = false
+ },
+ {
+ .reg = TAS2781_PRM_SINEGAIN2_REG,
+ .val_len = 4,
+ .is_locked = false
+ },
+};
+
static const struct i2c_device_id tasdevice_id[] = {
{ "tas2563", TAS2563 },
{ "tas2781", TAS2781 },
@@ -47,6 +164,22 @@ static const struct of_device_id tasdevice_of_match[] = {
MODULE_DEVICE_TABLE(of, tasdevice_of_match);
#endif
+static const int tas2563_cali_data_reg[] = {
+ TAS2563_PRM_R0_REG,
+ TAS2563_PRM_R0_LOW_REG,
+ TAS2563_PRM_INVR0_REG,
+ TAS2563_PRM_POW_REG,
+ TAS2563_PRM_TLIMIT_REG,
+};
+
+static const int tas2781_cali_data_reg[] = {
+ TAS2781_PRM_R0_REG,
+ TAS2781_PRM_R0_LOW_REG,
+ TAS2781_PRM_INVR0_REG,
+ TAS2781_PRM_POW_REG,
+ TAS2781_PRM_TLIMIT_REG,
+};
+
/**
* tas2781_digital_getvol - get the volum control
* @kcontrol: control pointer
@@ -65,8 +198,13 @@ static int tas2781_digital_getvol(struct snd_kcontrol *kcontrol,
struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;
+ int rc;
+
+ mutex_lock(&tas_priv->codec_lock);
+ rc = tasdevice_digital_getvol(tas_priv, ucontrol, mc);
+ mutex_unlock(&tas_priv->codec_lock);
- return tasdevice_digital_getvol(tas_priv, ucontrol, mc);
+ return rc;
}
static int tas2781_digital_putvol(struct snd_kcontrol *kcontrol,
@@ -76,8 +214,13 @@ static int tas2781_digital_putvol(struct snd_kcontrol *kcontrol,
struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;
+ int rc;
+
+ mutex_lock(&tas_priv->codec_lock);
+ rc = tasdevice_digital_putvol(tas_priv, ucontrol, mc);
+ mutex_unlock(&tas_priv->codec_lock);
- return tasdevice_digital_putvol(tas_priv, ucontrol, mc);
+ return rc;
}
static int tas2781_amp_getvol(struct snd_kcontrol *kcontrol,
@@ -87,8 +230,13 @@ static int tas2781_amp_getvol(struct snd_kcontrol *kcontrol,
struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;
+ int rc;
+
+ mutex_lock(&tas_priv->codec_lock);
+ rc = tasdevice_amp_getvol(tas_priv, ucontrol, mc);
+ mutex_unlock(&tas_priv->codec_lock);
- return tasdevice_amp_getvol(tas_priv, ucontrol, mc);
+ return rc;
}
static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
@@ -99,11 +247,16 @@ static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
snd_soc_component_get_drvdata(codec);
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;
+ int rc;
+
+ mutex_lock(&tas_priv->codec_lock);
+ rc = tasdevice_amp_putvol(tas_priv, ucontrol, mc);
+ mutex_unlock(&tas_priv->codec_lock);
- return tasdevice_amp_putvol(tas_priv, ucontrol, mc);
+ return rc;
}
-static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
+static int tasdev_force_fwload_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component =
@@ -118,7 +271,7 @@ static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
return 0;
}
-static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
+static int tasdev_force_fwload_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component =
@@ -127,18 +280,496 @@ static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
snd_soc_component_get_drvdata(component);
bool change, val = (bool)ucontrol->value.integer.value[0];
+ mutex_lock(&tas_priv->codec_lock);
if (tas_priv->force_fwload_status == val)
change = false;
else {
change = true;
tas_priv->force_fwload_status = val;
}
+ mutex_unlock(&tas_priv->codec_lock);
dev_dbg(tas_priv->dev, "%s : Force FWload %s\n", __func__,
tas_priv->force_fwload_status ? "ON" : "OFF");
return change;
}
+static int tasdev_cali_data_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct soc_bytes_ext *bytes_ext =
+ (struct soc_bytes_ext *) kcontrol->private_value;
+ unsigned char *dst = ucontrol->value.bytes.data;
+ unsigned char *data = tas_priv->cali_data.data;
+
+ mutex_lock(&tas_priv->codec_lock);
+ if (!tas_priv->is_user_space_calidata ||
+ tas_priv->cali_data.total_sz != bytes_ext->max) {
+ goto out;
+ }
+ memcpy(dst, data, bytes_ext->max);
+out:
+ mutex_unlock(&tas_priv->codec_lock);
+ return 0;
+}
+
+static int calib_data_get(struct tasdevice_priv *tas_priv, int reg,
+ unsigned char *dst, int data_len)
+{
+ struct i2c_client *clt = (struct i2c_client *)tas_priv->client;
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ int rc = -1;
+ int i;
+
+ if (data_len != 4)
+ return rc;
+
+ for (i = 0; i < tas_priv->ndev; i++) {
+ if (clt->addr == tasdev[i].dev_addr) {
+ /* First byte is the device index. */
+ dst[0] = i;
+ tasdevice_dev_bulk_read(tas_priv, i, reg, &dst[1],
+ 4);
+ rc = 0;
+ break;
+ }
+ }
+
+ return rc;
+}
+
+static int tas2781_calib_start_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct soc_bytes_ext *bytes_ext =
+ (struct soc_bytes_ext *) kcontrol->private_value;
+ const int sum = ARRAY_SIZE(tas2781_cali_start_reg);
+ unsigned char *dat = ucontrol->value.bytes.data;
+ int rc = 1;
+ int i, j;
+
+ mutex_lock(&tas_priv->codec_lock);
+ if (tas_priv->chip_id != TAS2781 &&
+ bytes_ext->max != 8 * tas_priv->ndev) {
+ rc = -1;
+ goto out;
+ }
+
+ for (i = 0; i < tas_priv->ndev; i++) {
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ struct bulk_reg_val *p = tasdev[i].cali_data_restore;
+ int k = i * 9;
+
+ if (p == NULL)
+ continue;
+
+ for (j = 0; j < sum; j++) {
+ if (p[j].val_len == 1) {
+ if (p[j].is_locked)
+ tasdevice_dev_write(tas_priv, i,
+ TAS2781_TEST_UNLOCK_REG,
+ TAS2781_TEST_PAGE_UNLOCK);
+ tasdevice_dev_read(tas_priv, i, p[j].reg,
+ (int *)&p[j].val[0]);
+ } else
+ tasdevice_dev_bulk_read(tas_priv, i, p[j].reg,
+ p[j].val, 4);
+ }
+
+ for (j = 0; j < sum - 2; j++) {
+ if (p[j].val_len == 1) {
+ if (p[j].is_locked)
+ tasdevice_dev_write(tas_priv, i,
+ TAS2781_TEST_UNLOCK_REG,
+ TAS2781_TEST_PAGE_UNLOCK);
+ tasdevice_dev_write(tas_priv, i, p[j].reg,
+ tas2781_cali_start_reg[j].val[0]);
+ } else
+ tasdevice_dev_bulk_write(tas_priv, i, p[j].reg,
+ (unsigned char *)
+ tas2781_cali_start_reg[j].val, 4);
+ }
+
+ if (dat[k] != i) {
+ dev_err(tas_priv->dev,
+ "%s: no cal-setting for dev %d\n", __func__,
+ i);
+ continue;
+ }
+ tasdevice_dev_bulk_write(tas_priv, i, p[j].reg,
+ &dat[i * 9 + 1], 4);
+ tasdevice_dev_bulk_write(tas_priv, i, p[j + 1].reg,
+ &dat[i * 9 + 5], 4);
+ }
+out:
+ mutex_unlock(&tas_priv->codec_lock);
+ return rc;
+}
+
+static void tas2781_calib_stop_put(struct tasdevice_priv *tas_priv)
+{
+ const int sum = ARRAY_SIZE(tas2781_cali_start_reg);
+ int i, j;
+
+ for (i = 0; i < tas_priv->ndev; i++) {
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ struct bulk_reg_val *p = tasdev[i].cali_data_restore;
+
+ if (p == NULL)
+ continue;
+
+ for (j = 0; j < sum; j++) {
+ if (p[j].val_len == 1) {
+ if (p[j].is_locked)
+ tasdevice_dev_write(tas_priv, i,
+ TAS2781_TEST_UNLOCK_REG,
+ TAS2781_TEST_PAGE_UNLOCK);
+ tasdevice_dev_write(tas_priv, i, p[j].reg,
+ p[j].val[0]);
+ } else
+ tasdevice_dev_bulk_write(tas_priv, i, p[j].reg,
+ p[j].val, 4);
+ }
+ }
+}
+
+static int tas2563_calib_start_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ const int sum = ARRAY_SIZE(tas2563_cali_start_reg);
+ int rc = 1;
+ int i, j;
+
+ mutex_lock(&tas_priv->codec_lock);
+ if (tas_priv->chip_id != TAS2563) {
+ rc = -1;
+ goto out;
+ }
+
+ for (i = 0; i < tas_priv->ndev; i++) {
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ struct bulk_reg_val *p = tasdev[i].cali_data_restore;
+
+ if (p == NULL)
+ continue;
+ for (j = 0; j < sum; j++) {
+ tasdevice_dev_bulk_read(tas_priv, i, p[j].reg,
+ p[j].val, 4);
+ }
+
+ for (j = 0; j < sum; j++) {
+ tasdevice_dev_bulk_write(tas_priv, i, p[j].reg,
+ (unsigned char *)tas2563_cali_start_reg[j].val,
+ 4);
+ }
+ }
+out:
+ mutex_unlock(&tas_priv->codec_lock);
+ return rc;
+}
+
+static void tas2563_calib_stop_put(struct tasdevice_priv *tas_priv)
+{
+ const int sum = ARRAY_SIZE(tas2563_cali_start_reg);
+ int i, j;
+
+ for (i = 0; i < tas_priv->ndev; i++) {
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ struct bulk_reg_val *p = tasdev[i].cali_data_restore;
+
+ if (p == NULL)
+ continue;
+
+ for (j = 0; j < sum; j++) {
+ tasdevice_dev_bulk_write(tas_priv, i, p[j].reg,
+ p[j].val, 4);
+ }
+ }
+}
+
+static int tasdev_calib_stop_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+
+ mutex_lock(&tas_priv->codec_lock);
+ if (tas_priv->chip_id == TAS2563)
+ tas2563_calib_stop_put(tas_priv);
+ else
+ tas2781_calib_stop_put(tas_priv);
+ mutex_unlock(&tas_priv->codec_lock);
+
+ return 1;
+}
+
+static int tasdev_cali_data_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct soc_bytes_ext *bytes_ext =
+ (struct soc_bytes_ext *) kcontrol->private_value;
+ unsigned char *data = tas_priv->cali_data.data;
+ int rc = 1;
+
+ mutex_lock(&tas_priv->codec_lock);
+ if (tas_priv->cali_data.total_sz != bytes_ext->max) {
+ rc = -1;
+ goto out;
+ }
+ tas_priv->is_user_space_calidata = true;
+ memcpy(data, ucontrol->value.bytes.data, bytes_ext->max);
+out:
+ mutex_unlock(&tas_priv->codec_lock);
+ return rc;
+}
+
+static int tas2781_latch_reg_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct i2c_client *clt = (struct i2c_client *)tas_priv->client;
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ unsigned char *dst = ucontrol->value.bytes.data;
+ int i, val, rc = -1;
+
+ mutex_lock(&tas_priv->codec_lock);
+ for (i = 0; i < tas_priv->ndev; i++) {
+ if (clt->addr == tasdev[i].dev_addr) {
+ /* First byte is the device index. */
+ dst[0] = i;
+ tasdevice_dev_read(tas_priv, i,
+ TAS2781_RUNTIME_LATCH_RE_REG, &val);
+ dst[1] = val;
+ rc = 0;
+ break;
+ }
+ }
+ mutex_unlock(&tas_priv->codec_lock);
+ return rc;
+}
+
+static int tasdev_tf_data_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct soc_bytes_ext *bytes_ext =
+ (struct soc_bytes_ext *) kcontrol->private_value;
+ unsigned char *dst = ucontrol->value.bytes.data;
+ unsigned int reg;
+ int rc = -1;
+
+ if (tas_priv->chip_id == TAS2781)
+ reg = TAS2781_RUNTIME_RE_REG_TF;
+ else
+ reg = TAS2563_RUNTIME_RE_REG_TF;
+
+ mutex_lock(&tas_priv->codec_lock);
+ rc = calib_data_get(tas_priv, reg, dst, bytes_ext->max - 1);
+ mutex_unlock(&tas_priv->codec_lock);
+
+ return rc;
+}
+
+static int tasdev_re_data_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct soc_bytes_ext *bytes_ext =
+ (struct soc_bytes_ext *) kcontrol->private_value;
+ unsigned char *dst = ucontrol->value.bytes.data;
+ unsigned int reg;
+ int rc = -1;
+
+ if (tas_priv->chip_id == TAS2781)
+ reg = TAS2781_RUNTIME_RE_REG;
+ else
+ reg = TAS2563_RUNTIME_RE_REG;
+ mutex_lock(&tas_priv->codec_lock);
+ rc = calib_data_get(tas_priv, reg, dst, bytes_ext->max - 1);
+ mutex_unlock(&tas_priv->codec_lock);
+
+ return rc;
+}
+
+static int tasdev_r0_data_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct soc_bytes_ext *bytes_ext =
+ (struct soc_bytes_ext *) kcontrol->private_value;
+ unsigned char *dst = ucontrol->value.bytes.data;
+ unsigned int reg;
+ int rc = -1;
+
+ if (tas_priv->chip_id == TAS2781)
+ reg = TAS2781_PRM_R0_REG;
+ else
+ reg = TAS2563_PRM_R0_REG;
+ mutex_lock(&tas_priv->codec_lock);
+ rc = calib_data_get(tas_priv, reg, dst, bytes_ext->max - 1);
+ mutex_unlock(&tas_priv->codec_lock);
+
+ return rc;
+}
+
+static int tasdev_XMA1_data_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct soc_bytes_ext *bytes_ext =
+ (struct soc_bytes_ext *) kcontrol->private_value;
+ unsigned char *dst = ucontrol->value.bytes.data;
+ unsigned int reg = TASDEVICE_XM_A1_REG;
+ int rc = -1;
+
+ mutex_lock(&tas_priv->codec_lock);
+ rc = calib_data_get(tas_priv, reg, dst, bytes_ext->max - 1);
+ mutex_unlock(&tas_priv->codec_lock);
+
+ return rc;
+}
+
+static int tasdev_XMA2_data_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp);
+ struct soc_bytes_ext *bytes_ext =
+ (struct soc_bytes_ext *) kcontrol->private_value;
+ unsigned char *dst = ucontrol->value.bytes.data;
+ unsigned int reg = TASDEVICE_XM_A2_REG;
+ int rc = -1;
+
+ mutex_lock(&tas_priv->codec_lock);
+ rc = calib_data_get(tas_priv, reg, dst, bytes_ext->max - 1);
+ mutex_unlock(&tas_priv->codec_lock);
+
+ return rc;
+}
+
+static int tasdev_nop_get(
+ struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ return 0;
+}
+
+static int tas2563_digital_gain_get(
+ struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)kcontrol->private_value;
+ struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_dev = snd_soc_component_get_drvdata(codec);
+ unsigned int l = 0, r = mc->max;
+ unsigned int target, ar_mid, mid, ar_l, ar_r;
+ unsigned int reg = mc->reg;
+ unsigned char data[4];
+ int ret;
+
+ mutex_lock(&tas_dev->codec_lock);
+ /* Read the primary device */
+ ret = tasdevice_dev_bulk_read(tas_dev, 0, reg, data, 4);
+ if (ret) {
+ dev_err(tas_dev->dev, "%s, get AMP vol error\n", __func__);
+ goto out;
+ }
+
+ target = get_unaligned_be32(&data[0]);
+
+ while (r > 1 + l) {
+ mid = (l + r) / 2;
+ ar_mid = get_unaligned_be32(tas2563_dvc_table[mid]);
+ if (target < ar_mid)
+ r = mid;
+ else
+ l = mid;
+ }
+
+ ar_l = get_unaligned_be32(tas2563_dvc_table[l]);
+ ar_r = get_unaligned_be32(tas2563_dvc_table[r]);
+
+ ucontrol->value.integer.value[0] =
+ abs(target - ar_l) <= abs(target - ar_r) ? l : r;
+out:
+ mutex_unlock(&tas_dev->codec_lock);
+ return 0;
+}
+
+static int tas2563_digital_gain_put(
+ struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)kcontrol->private_value;
+ struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_dev = snd_soc_component_get_drvdata(codec);
+ unsigned int reg = mc->reg;
+ unsigned int volrd, volwr;
+ int vol = ucontrol->value.integer.value[0];
+ int max = mc->max, i, ret = 1;
+ unsigned char data[4];
+
+ vol = clamp(vol, 0, max);
+ mutex_lock(&tas_dev->codec_lock);
+ /* Read the primary device */
+ ret = tasdevice_dev_bulk_read(tas_dev, 0, reg, data, 4);
+ if (ret) {
+ dev_err(tas_dev->dev, "%s, get AMP vol error\n", __func__);
+ goto out;
+ }
+
+ volrd = get_unaligned_be32(&data[0]);
+ volwr = get_unaligned_be32(tas2563_dvc_table[vol]);
+
+ if (volrd == volwr) {
+ ret = 0;
+ goto out;
+ }
+
+ for (i = 0; i < tas_dev->ndev; i++) {
+ ret = tasdevice_dev_bulk_write(tas_dev, i, reg,
+ (unsigned char *)tas2563_dvc_table[vol], 4);
+ if (ret)
+ dev_err(tas_dev->dev,
+ "%s, set digital vol error in device %d\n",
+ __func__, i);
+ }
+
+out:
+ mutex_unlock(&tas_dev->codec_lock);
+ return ret;
+}
+
+static const struct snd_kcontrol_new tasdevice_snd_controls[] = {
+ SOC_SINGLE_BOOL_EXT("Speaker Force Firmware Load", 0,
+ tasdev_force_fwload_get, tasdev_force_fwload_put),
+};
+
+static const struct snd_kcontrol_new tasdevice_cali_controls[] = {
+ SOC_SINGLE_EXT("Calibration Stop", SND_SOC_NOPM, 0, 1, 0,
+ tasdev_nop_get, tasdev_calib_stop_put),
+ SND_SOC_BYTES_EXT("Amp TF Data", 5, tasdev_tf_data_get, NULL),
+ SND_SOC_BYTES_EXT("Amp RE Data", 5, tasdev_re_data_get, NULL),
+ SND_SOC_BYTES_EXT("Amp R0 Data", 5, tasdev_r0_data_get, NULL),
+ SND_SOC_BYTES_EXT("Amp XMA1 Data", 5, tasdev_XMA1_data_get, NULL),
+ SND_SOC_BYTES_EXT("Amp XMA2 Data", 5, tasdev_XMA2_data_get, NULL),
+};
+
static const struct snd_kcontrol_new tas2781_snd_controls[] = {
SOC_SINGLE_RANGE_EXT_TLV("Speaker Analog Gain", TAS2781_AMP_LEVEL,
1, 0, 20, 0, tas2781_amp_getvol,
@@ -146,8 +777,22 @@ static const struct snd_kcontrol_new tas2781_snd_controls[] = {
SOC_SINGLE_RANGE_EXT_TLV("Speaker Digital Gain", TAS2781_DVC_LVL,
0, 0, 200, 1, tas2781_digital_getvol,
tas2781_digital_putvol, dvc_tlv),
- SOC_SINGLE_BOOL_EXT("Speaker Force Firmware Load", 0,
- tas2781_force_fwload_get, tas2781_force_fwload_put),
+};
+
+static const struct snd_kcontrol_new tas2781_cali_controls[] = {
+ SND_SOC_BYTES_EXT("Amp Latch Data", 2, tas2781_latch_reg_get, NULL),
+};
+
+static const struct snd_kcontrol_new tas2563_snd_controls[] = {
+ SOC_SINGLE_RANGE_EXT_TLV("Speaker Digital Gain", TAS2563_DVC_LVL, 0,
+ 0, ARRAY_SIZE(tas2563_dvc_table) - 1, 0,
+ tas2563_digital_gain_get, tas2563_digital_gain_put,
+ tas2563_dvc_tlv),
+};
+
+static const struct snd_kcontrol_new tas2563_cali_controls[] = {
+ SOC_SINGLE_EXT("Calibration Start", SND_SOC_NOPM, 0, 1, 0,
+ tasdev_nop_get, tas2563_calib_start_put),
};
static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol,
@@ -167,6 +812,31 @@ static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol,
return ret;
}
+static int tasdevice_info_active_id(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
+
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = (int)tas_priv->ndev - 1;
+
+ return 0;
+}
+
+static int tasdevice_info_chip_id(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 1;
+ uinfo->value.integer.min = TAS2563;
+ uinfo->value.integer.max = TAS2781;
+
+ return 0;
+}
+
static int tasdevice_info_programs(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
@@ -223,6 +893,17 @@ static int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol,
return 0;
}
+static int tasdevice_get_chip_id(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
+
+ ucontrol->value.integer.value[0] = tas_priv->chip_id;
+
+ return 0;
+}
+
static int tasdevice_create_control(struct tasdevice_priv *tas_priv)
{
struct snd_kcontrol_new *prof_ctrls;
@@ -316,15 +997,54 @@ static int tasdevice_configuration_put(
return ret;
}
-static int tasdevice_dsp_create_ctrls(
- struct tasdevice_priv *tas_priv)
+static int tasdevice_active_id_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
+ struct i2c_client *clt = (struct i2c_client *)tas_priv->client;
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ int i;
+
+ for (i = 0; i < tas_priv->ndev; i++) {
+ if (clt->addr == tasdev[i].dev_addr) {
+ ucontrol->value.integer.value[0] = i;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static int tasdevice_active_id_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
+ struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
+ int nr_dev = ucontrol->value.integer.value[0];
+ int max = tas_priv->ndev - 1, rc;
+
+ nr_dev = clamp(nr_dev, 0, max);
+
+ mutex_lock(&tas_priv->codec_lock);
+ rc = tasdevice_chn_switch(tas_priv, nr_dev);
+ mutex_unlock(&tas_priv->codec_lock);
+
+ return rc;
+}
+
+static int tasdevice_dsp_create_ctrls(struct tasdevice_priv *tas_priv)
{
+ char *active_dev_name, *cali_name, *chip_id, *conf_name, *prog_name;
+ struct calidata *cali_data = &tas_priv->cali_data;
struct snd_kcontrol_new *dsp_ctrls;
- char *prog_name, *conf_name;
- int nr_controls = 2;
+ struct soc_bytes_ext *ext_cali_data;
+ int nr_controls = 5;
int mix_index = 0;
int ret;
+ if (tas_priv->chip_id == TAS2781)
+ nr_controls++;
/* Alloc kcontrol via devm_kzalloc, which don't manually
* free the kcontrol
*/
@@ -336,11 +1056,20 @@ static int tasdevice_dsp_create_ctrls(
}
/* Create a mixer item for selecting the active profile */
- prog_name = devm_kzalloc(tas_priv->dev,
+ active_dev_name = devm_kzalloc(tas_priv->dev,
+ SNDRV_CTL_ELEM_ID_NAME_MAXLEN, GFP_KERNEL);
+ cali_name = devm_kzalloc(tas_priv->dev, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
+ GFP_KERNEL);
+ chip_id = devm_kzalloc(tas_priv->dev, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
+ GFP_KERNEL);
+ conf_name = devm_kzalloc(tas_priv->dev,
SNDRV_CTL_ELEM_ID_NAME_MAXLEN, GFP_KERNEL);
- conf_name = devm_kzalloc(tas_priv->dev, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
+ prog_name = devm_kzalloc(tas_priv->dev, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
GFP_KERNEL);
- if (!prog_name || !conf_name) {
+ ext_cali_data = devm_kzalloc(tas_priv->dev, sizeof(*ext_cali_data),
+ GFP_KERNEL);
+ if (!active_dev_name || !cali_name || !conf_name || !chip_id ||
+ !ext_cali_data || !prog_name) {
ret = -ENOMEM;
goto out;
}
@@ -363,6 +1092,68 @@ static int tasdevice_dsp_create_ctrls(
dsp_ctrls[mix_index].put = tasdevice_configuration_put;
mix_index++;
+ scnprintf(active_dev_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
+ "Activate Tasdevice Id");
+ dsp_ctrls[mix_index].name = active_dev_name;
+ dsp_ctrls[mix_index].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+ dsp_ctrls[mix_index].info = tasdevice_info_active_id;
+ dsp_ctrls[mix_index].get = tasdevice_active_id_get;
+ dsp_ctrls[mix_index].put = tasdevice_active_id_put;
+ mix_index++;
+
+ scnprintf(chip_id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
+ "Tasdevice Chip Id");
+ dsp_ctrls[mix_index].name = chip_id;
+ dsp_ctrls[mix_index].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+ dsp_ctrls[mix_index].info = tasdevice_info_chip_id;
+ dsp_ctrls[mix_index].get = tasdevice_get_chip_id;
+ mix_index++;
+
+ scnprintf(cali_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
+ "Speaker Calibrated Data");
+ ext_cali_data->max = tas_priv->ndev * CAL_DAT_SZ;
+ tas_priv->cali_data.total_sz = ext_cali_data->max;
+ tas_priv->cali_data.data = devm_kzalloc(tas_priv->dev,
+ ext_cali_data->max, GFP_KERNEL);
+ dsp_ctrls[mix_index].name = cali_name;
+ dsp_ctrls[mix_index].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+ dsp_ctrls[mix_index].info = snd_soc_bytes_info_ext;
+ dsp_ctrls[mix_index].get = tasdev_cali_data_get;
+ dsp_ctrls[mix_index].put = tasdev_cali_data_put;
+ dsp_ctrls[mix_index].private_value = (unsigned long)ext_cali_data;
+ mix_index++;
+
+ cali_data->data = devm_kzalloc(tas_priv->dev, tas_priv->ndev *
+ (cali_data->reg_array_sz * 4 + 1), GFP_KERNEL);
+ if (!cali_data->data)
+ return -ENOMEM;
+
+ if (tas_priv->chip_id == TAS2781) {
+ struct soc_bytes_ext *ext_cali_start;
+ char *cali_start_name;
+
+ cali_start_name = devm_kzalloc(tas_priv->dev,
+ SNDRV_CTL_ELEM_ID_NAME_MAXLEN, GFP_KERNEL);
+ ext_cali_start = devm_kzalloc(tas_priv->dev,
+ sizeof(*ext_cali_start), GFP_KERNEL);
+ if (!cali_start_name || !ext_cali_start) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ scnprintf(cali_start_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
+ "Calibration Start");
+ ext_cali_data->max = tas_priv->ndev * 9;
+ dsp_ctrls[mix_index].name = cali_start_name;
+ dsp_ctrls[mix_index].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+ dsp_ctrls[mix_index].info = snd_soc_bytes_info_ext;
+ dsp_ctrls[mix_index].put = tas2781_calib_start_put;
+ dsp_ctrls[mix_index].get = tasdev_nop_get;
+ dsp_ctrls[mix_index].private_value =
+ (unsigned long)ext_cali_start;
+ mix_index++;
+ }
+
ret = snd_soc_add_component_controls(tas_priv->codec, dsp_ctrls,
nr_controls < mix_index ? nr_controls : mix_index);
@@ -370,6 +1161,54 @@ static int tasdevice_dsp_create_ctrls(
return ret;
}
+static int tasdevice_create_cali_ctrls(struct tasdevice_priv *tas_priv)
+{
+ struct calidata *cali_data = &tas_priv->cali_data;
+ struct snd_kcontrol_new *cali_ctrls;
+ unsigned int num_controls;
+ int rc;
+
+ rc = snd_soc_add_component_controls(tas_priv->codec,
+ tasdevice_cali_controls, ARRAY_SIZE(tasdevice_cali_controls));
+ if (rc < 0) {
+ dev_err(tas_priv->dev, "%s: Add cali control err rc = %d",
+ __func__, rc);
+ return rc;
+ }
+
+ if (tas_priv->chip_id == TAS2781) {
+ cali_ctrls = (struct snd_kcontrol_new *)tas2781_cali_controls;
+ num_controls = ARRAY_SIZE(tas2781_cali_controls);
+ cali_data->reg_array = (unsigned int *)tas2781_cali_data_reg;
+ cali_data->reg_array_sz = ARRAY_SIZE(tas2781_cali_data_reg);
+ } else {
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ int i;
+
+ cali_ctrls = (struct snd_kcontrol_new *)tas2563_cali_controls;
+ num_controls = ARRAY_SIZE(tas2563_cali_controls);
+ cali_data->reg_array = (unsigned int *)tas2563_cali_data_reg;
+ cali_data->reg_array_sz = sizeof(tas2563_cali_data_reg);
+ for (i = 0; i < tas_priv->ndev; i++) {
+ tasdev[i].cali_data_restore =
+ kmemdup(tas2563_cali_start_reg,
+ sizeof(tas2563_cali_start_reg), GFP_KERNEL);
+ if (!tasdev[i].cali_data_restore)
+ return -ENOMEM;
+ }
+ }
+
+ rc = snd_soc_add_component_controls(tas_priv->codec, cali_ctrls,
+ num_controls);
+ if (rc < 0) {
+ dev_err(tas_priv->dev, "%s: Add control err rc = %d",
+ __func__, rc);
+ return rc;
+ }
+
+ return rc;
+}
+
static void tasdevice_fw_ready(const struct firmware *fmw,
void *context)
{
@@ -380,23 +1219,36 @@ static void tasdevice_fw_ready(const struct firmware *fmw,
mutex_lock(&tas_priv->codec_lock);
ret = tasdevice_rca_parser(tas_priv, fmw);
- if (ret)
+ if (ret) {
+ tasdevice_config_info_remove(tas_priv);
goto out;
+ }
tasdevice_create_control(tas_priv);
tasdevice_dsp_remove(tas_priv);
tasdevice_calbin_remove(tas_priv);
- tas_priv->fw_state = TASDEVICE_DSP_FW_PENDING;
+ tas_priv->fw_state = TASDEVICE_RCA_FW_OK;
scnprintf(tas_priv->coef_binaryname, 64, "%s_coef.bin",
tas_priv->dev_name);
+
ret = tasdevice_dsp_parser(tas_priv);
if (ret) {
dev_err(tas_priv->dev, "dspfw load %s error\n",
tas_priv->coef_binaryname);
- tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL;
goto out;
}
- tasdevice_dsp_create_ctrls(tas_priv);
+
+ ret = tasdevice_dsp_create_ctrls(tas_priv);
+ if (ret) {
+ dev_err(tas_priv->dev, "dsp controls error\n");
+ goto out;
+ }
+
+ ret = tasdevice_create_cali_ctrls(tas_priv);
+ if (ret) {
+ dev_err(tas_priv->dev, "cali controls error\n");
+ goto out;
+ }
tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK;
@@ -417,9 +1269,8 @@ static void tasdevice_fw_ready(const struct firmware *fmw,
tasdevice_prmg_load(tas_priv, 0);
tas_priv->cur_prog = 0;
out:
- if (tas_priv->fw_state == TASDEVICE_DSP_FW_FAIL) {
- /*If DSP FW fail, kcontrol won't be created */
- tasdevice_config_info_remove(tas_priv);
+ if (tas_priv->fw_state == TASDEVICE_RCA_FW_OK) {
+ /*If DSP FW fail, DSP kcontrol won't be created */
tasdevice_dsp_remove(tas_priv);
}
mutex_unlock(&tas_priv->codec_lock);
@@ -466,14 +1317,14 @@ static int tasdevice_startup(struct snd_pcm_substream *substream,
{
struct snd_soc_component *codec = dai->component;
struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
- int ret = 0;
- if (tas_priv->fw_state != TASDEVICE_DSP_FW_ALL_OK) {
- dev_err(tas_priv->dev, "DSP bin file not loaded\n");
- ret = -EINVAL;
+ if (!(tas_priv->fw_state == TASDEVICE_DSP_FW_ALL_OK ||
+ tas_priv->fw_state == TASDEVICE_RCA_FW_OK)) {
+ dev_err(tas_priv->dev, "Bin file not loaded\n");
+ return -EINVAL;
}
- return ret;
+ return 0;
}
static int tasdevice_hw_params(struct snd_pcm_substream *substream,
@@ -541,7 +1392,7 @@ static const struct snd_soc_dai_ops tasdevice_dai_ops = {
static struct snd_soc_dai_driver tasdevice_dai_driver[] = {
{
- .name = "tas2781_codec",
+ .name = "tasdev_codec",
.id = 0,
.playback = {
.stream_name = "Playback",
@@ -565,13 +1416,41 @@ static struct snd_soc_dai_driver tasdevice_dai_driver[] = {
static int tasdevice_codec_probe(struct snd_soc_component *codec)
{
struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
+ int rc;
+
+ if (tas_priv->chip_id == TAS2781) {
+ rc = snd_soc_add_component_controls(codec,
+ tas2781_snd_controls,
+ ARRAY_SIZE(tas2781_snd_controls));
+ if (rc < 0) {
+ dev_err(tas_priv->dev, "%s: Add control err rc = %d",
+ __func__, rc);
+ return rc;
+ }
+ } else {
+ rc = snd_soc_add_component_controls(codec,
+ tas2563_snd_controls,
+ ARRAY_SIZE(tas2563_snd_controls));
+ if (rc < 0) {
+ dev_err(tas_priv->dev, "%s: Add control err rc = %d",
+ __func__, rc);
+ return rc;
+ }
+ }
+
+ rc = tascodec_init(tas_priv, codec, THIS_MODULE, tasdevice_fw_ready);
- return tascodec_init(tas_priv, codec, THIS_MODULE, tasdevice_fw_ready);
+ return rc;
}
static void tasdevice_deinit(void *context)
{
struct tasdevice_priv *tas_priv = (struct tasdevice_priv *) context;
+ struct tasdevice *tasdev = tas_priv->tasdevice;
+ int i;
+
+ for (i = 0; i < tas_priv->ndev; i++)
+ kfree(tasdev[i].cali_data_restore);
tasdevice_config_info_remove(tas_priv);
tasdevice_dsp_remove(tas_priv);
@@ -591,8 +1470,8 @@ static const struct snd_soc_component_driver
soc_codec_driver_tasdevice = {
.probe = tasdevice_codec_probe,
.remove = tasdevice_codec_remove,
- .controls = tas2781_snd_controls,
- .num_controls = ARRAY_SIZE(tas2781_snd_controls),
+ .controls = tasdevice_snd_controls,
+ .num_controls = ARRAY_SIZE(tasdevice_snd_controls),
.dapm_widgets = tasdevice_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tasdevice_dapm_widgets),
.dapm_routes = tasdevice_audio_map,
--
2.34.1
5
6
[PATCH 0/3] slimbus: use 'time_left' instead of 'timeout' with wait_for_*() functions
by Wolfram Sang 01 Aug '24
by Wolfram Sang 01 Aug '24
01 Aug '24
There is a confusing pattern in the kernel to use a variable named 'timeout' to
store the result of wait_for_*() functions causing patterns like:
timeout = wait_for_completion_timeout(...)
if (!timeout) return -ETIMEDOUT;
with all kinds of permutations. Use 'time_left' as a variable to make the code
obvious and self explaining.
This is part of a tree-wide series. The rest of the patches can be found here
(some parts may still be WIP):
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/time_left
Because these patches are generated, I audit them before sending. This is why I
will send series step by step. Build bot is happy with these patches, though.
No functional changes intended.
Wolfram Sang (3):
slimbus: messaging: use 'time_left' variable with
wait_for_completion_timeout()
slimbus: qcom-ctrl: use 'time_left' variable with
wait_for_completion_timeout()
slimbus: qcom-ngd-ctrl: use 'time_left' variable with
wait_for_completion_timeout()
drivers/slimbus/messaging.c | 9 +++++----
drivers/slimbus/qcom-ctrl.c | 7 ++++---
drivers/slimbus/qcom-ngd-ctrl.c | 29 ++++++++++++++++-------------
3 files changed, 25 insertions(+), 20 deletions(-)
--
2.43.0
3
6
Hello,
I have an Acer Aspire 4736G laptop.
The soundcard that is shipped in this laptop is intel-hda based as
shown (actually it's a realtek):
cat /proc/asound/cards
0 [Intel ]: HDA-Intel - HDA Intel
HDA Intel at 0x9b300000 irq 46
Basic sound output is correct but few feature are missing:
- internal mic seems to be found but do not works.
- sound output stop working when trying to send it using HDMI output
- heads do not work when plugged neither when forcing pulseaudio to use it.
I have an ubuntu 10.10 which is shipped with alsa 1.0.23.
I have googled around and tried loading the snd-hda-intel with several
parameters () as found in HD-Audio-Models.txt to no avail.
cat /proc/asound/pcm
00-00: ALC888 Analog : ALC888 Analog : playback 1 : capture 1
00-01: ALC888 Digital : ALC888 Digital : playback 1
00-03: NVIDIA HDMI : NVIDIA HDMI : playback 1
Where can I begin to help implement the support for this sound card? I
have very skills in developement in general but am ready to try if it
is not to hard (I supose I can use previous code for similar models)..
I just need a shepherd.
Thanks
4
4
[PATCH 0/2] ASoC: codecs: lpass: add support for v2.6 rx macro
by srinivas.kandagatla@linaro.org 17 Jun '24
by srinivas.kandagatla@linaro.org 17 Jun '24
17 Jun '24
From: Srinivas Kandagatla <srinivas.kandagatla(a)linaro.org>
This patchset adds support to reading codec version and also adds
support for v2.6 codec version in rx macro.
LPASS 2.6 has changes in some of the rx block which are required to get
headset functional correctly.
Tested this on X13s and x1e80100 crd.
Thanks,
Srini
Srinivas Kandagatla (2):
ASoC: codecs: lpass-macro: add helpers to get codec version
ASoC: codec: lpass-rx-macro: add suppor for 2.6 codec version
sound/soc/codecs/lpass-macro-common.c | 14 +
sound/soc/codecs/lpass-macro-common.h | 35 ++
sound/soc/codecs/lpass-rx-macro.c | 565 +++++++++++++++++++-------
sound/soc/codecs/lpass-va-macro.c | 29 ++
4 files changed, 488 insertions(+), 155 deletions(-)
--
2.25.1
3
5
[PATCH v5 0/7] ASoC: codecs: wcd937x: add wcd937x audio codec support
by Mohammad Rafi Shaik 11 Jun '24
by Mohammad Rafi Shaik 11 Jun '24
11 Jun '24
This patchset adds support for Qualcomm WCD9370/WCD9375 codec.
Qualcomm WCD9370/WCD9375 Codec is a standalone Hi-Fi audio codec IC
connected over SoundWire. This device has two SoundWire devices, RX and
TX respectively supporting 3 x ADCs, ClassH, Ear, Aux PA, 2xHPH,
6 DMICs and MBHC.
For codec driver to be functional it would need both tx and rx Soundwire devices
to be up and this is taken care by using device component framework and device-links
are used to ensure proper pm dependencies. Ex tx does not enter suspend
before rx or codec is suspended.
This patchset along with other SoundWire patches on the list
have been tested on QCM6490 IDP device.
Changes since v4:
- Removed volatile/read-only registers from defaults list
- Added wcd939x_volatile_register() with only volatile registers
- Added a wcd939x_readable_register() with read-only and read-write registers, so cache does it's job
- Fixed Spurious events for mixer controls and validated with mixer selftest tool
- Used TLV instead of enum for ear_pa_gain mixer control
- Used enum constraints instead of OneOf in dt-binding patch
- Added vdd-px supply property as non optional in dt-binding patch
- Reworked and done driver cleanup
Changes since v3:
- Fixed dt binding check errors.
- Added constraints on values in v4-0001 binding patch as suggested by Krzysztof
- Change the patch sequence soundwire driver first then codec driver
- Added missing .remove soundwire driver function
- Reworked and done driver cleanup
Changes since v2:
- Used common qcom,wcd93xx-common.yaml. removed duplicate properties.
- Merged bindings patches "v2-0001" and "v2-0003" in single patch for easy review.
- Fixed dt binding check errors.
- Added missing "qcom,wcd9375-codec" in v3-0001 dt binding patch.
- Added constraints on values in v3-0001 binding patch as suggested by Krzysztof
- Fix the typo mistake in v2 cover letter
Changes since v1:
- Split the patch per driver for easier review as suggested by Krzysztof
- Used devm_gpiod_get api to get reset gpio as suggested by Krzysztof
Prasad Kumpatla (7):
ASoC: dt-bindings: document wcd937x Audio Codec
ASoC: codecs: wcd937x-sdw: add SoundWire driver
ASoC: codecs: wcd937x: add wcd937x codec driver
ASoC: codecs: wcd937x: add basic controls
ASoC: codecs: wcd937x: add playback dapm widgets
ASoC: codecs: wcd937x: add capture dapm widgets
ASoC: codecs: wcd937x: add audio routing and Kconfig
.../bindings/sound/qcom,wcd937x-sdw.yaml | 91 +
.../bindings/sound/qcom,wcd937x.yaml | 82 +
sound/soc/codecs/Kconfig | 20 +
sound/soc/codecs/Makefile | 7 +
sound/soc/codecs/wcd937x-sdw.c | 1139 +++++++
sound/soc/codecs/wcd937x.c | 3029 +++++++++++++++++
sound/soc/codecs/wcd937x.h | 653 ++++
7 files changed, 5021 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sound/qcom,wcd937x-sdw.yaml
create mode 100644 Documentation/devicetree/bindings/sound/qcom,wcd937x.yaml
create mode 100644 sound/soc/codecs/wcd937x-sdw.c
create mode 100644 sound/soc/codecs/wcd937x.c
create mode 100644 sound/soc/codecs/wcd937x.h
base-commit: 124cfbcd6d185d4f50be02d5f5afe61578916773
--
2.25.1
3
11
[PATCH 0/3] ACPI/ALSA/soundwire: add acpi_get_local_u64_address() helper
by Pierre-Louis Bossart 11 Jun '24
by Pierre-Louis Bossart 11 Jun '24
11 Jun '24
The acpi_get_local_address() helper assumes a 32-bit ADR is used. If
we want to use this helper for SoundWire/SDCA ASoC codecs, we need an
extension where the native 64-bits are used. This patchset suggests a
new helper, acpi_get_local_address() may be renamed if desired in a
folow-up patch.
The path of least resistance would be to merge this patchset in the
ASoC tree, since I have additional changes for ASoC/SDCA (SoundWire
Device Class) that depend on the new helper.
Pierre-Louis Bossart (3):
ACPI: utils: introduce acpi_get_local_u64_address()
soundwire: slave: simplify code with acpi_get_local_u64_address()
ALSA: hda: intel-sdw-acpi: use acpi_get_local_u64_address()
drivers/acpi/utils.c | 22 ++++++++++++++++------
drivers/soundwire/slave.c | 13 ++++---------
include/linux/acpi.h | 1 +
sound/hda/intel-sdw-acpi.c | 6 +++---
4 files changed, 24 insertions(+), 18 deletions(-)
--
2.43.0
6
11
[RESEND v5 0/7] ASoC: codecs: wcd937x: add wcd937x audio codec support
by Mohammad Rafi Shaik 11 Jun '24
by Mohammad Rafi Shaik 11 Jun '24
11 Jun '24
This patchset adds support for Qualcomm WCD9370/WCD9375 codec.
Qualcomm WCD9370/WCD9375 Codec is a standalone Hi-Fi audio codec IC
connected over SoundWire. This device has two SoundWire devices, RX and
TX respectively supporting 3 x ADCs, ClassH, Ear, Aux PA, 2xHPH,
6 DMICs and MBHC.
For codec driver to be functional it would need both tx and rx Soundwire devices
to be up and this is taken care by using device component framework and device-links
are used to ensure proper pm dependencies. Ex tx does not enter suspend
before rx or codec is suspended.
This patchset along with other SoundWire patches on the list
have been tested on QCM6490 IDP device.
Changes since v4:
- Removed volatile/read-only registers from defaults list
- Added wcd939x_volatile_register() with only volatile registers
- Added a wcd939x_readable_register() with read-only and read-write registers, so cache does it's job
- Fixed Spurious events for mixer controls and validated with mixer selftest tool
- Used TLV instead of enum for ear_pa_gain mixer control
- Used enum constraints instead of OneOf in dt-binding patch
- Added vdd-px supply property as non optional in dt-binding patch
- Reworked and done driver cleanup
Changes since v3:
- Fixed dt binding check errors.
- Added constraints on values in v4-0001 binding patch as suggested by Krzysztof
- Change the patch sequence soundwire driver first then codec driver
- Added missing .remove soundwire driver function
- Reworked and done driver cleanup
Changes since v2:
- Used common qcom,wcd93xx-common.yaml. removed duplicate properties.
- Merged bindings patches "v2-0001" and "v2-0003" in single patch for easy review.
- Fixed dt binding check errors.
- Added missing "qcom,wcd9375-codec" in v3-0001 dt binding patch.
- Added constraints on values in v3-0001 binding patch as suggested by Krzysztof
- Fix the typo mistake in v2 cover letter
Changes since v1:
- Split the patch per driver for easier review as suggested by Krzysztof
- Used devm_gpiod_get api to get reset gpio as suggested by Krzysztof
Prasad Kumpatla (7):
ASoC: dt-bindings: document wcd937x Audio Codec
ASoC: codecs: wcd937x-sdw: add SoundWire driver
ASoC: codecs: wcd937x: add wcd937x codec driver
ASoC: codecs: wcd937x: add basic controls
ASoC: codecs: wcd937x: add playback dapm widgets
ASoC: codecs: wcd937x: add capture dapm widgets
ASoC: codecs: wcd937x: add audio routing and Kconfig
.../bindings/sound/qcom,wcd937x-sdw.yaml | 91 +
.../bindings/sound/qcom,wcd937x.yaml | 82 +
sound/soc/codecs/Kconfig | 20 +
sound/soc/codecs/Makefile | 7 +
sound/soc/codecs/wcd937x-sdw.c | 1139 +++++++
sound/soc/codecs/wcd937x.c | 3029 +++++++++++++++++
sound/soc/codecs/wcd937x.h | 653 ++++
7 files changed, 5021 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sound/qcom,wcd937x-sdw.yaml
create mode 100644 Documentation/devicetree/bindings/sound/qcom,wcd937x.yaml
create mode 100644 sound/soc/codecs/wcd937x-sdw.c
create mode 100644 sound/soc/codecs/wcd937x.c
create mode 100644 sound/soc/codecs/wcd937x.h
base-commit: 3689b0ef08b70e4e03b82ebd37730a03a672853a
--
2.25.1
2
9
11 Jun '24
Requesting to see if we can get some Acked-By tags, and merge on usb-next.
Several Qualcomm based chipsets can support USB audio offloading to a
dedicated audio DSP, which can take over issuing transfers to the USB
host controller. The intention is to reduce the load on the main
processors in the SoC, and allow them to be placed into lower power modes.
There are several parts to this design:
1. Adding ASoC binding layer
2. Create a USB backend for Q6DSP
3. Introduce XHCI interrupter support
4. Create vendor ops for the USB SND driver
USB | ASoC
--------------------------------------------------------------------
| _________________________
| |sm8250 platform card |
| |_________________________|
| | |
| ___V____ ____V____
| |Q6USB | |Q6AFE |
| |"codec" | |"cpu" |
| |________| |_________|
| ^ ^ ^
| | |________|
| ___V____ |
| |SOC-USB | |
________ ________ | | |
|USB SND |<--->|QC offld|<------------>|________| |
|(card.c)| | |<---------- |
|________| |________|___ | | |
^ ^ | | | ____________V_________
| | | | | |APR/GLINK |
__ V_______________V_____ | | | |______________________|
|USB SND (endpoint.c) | | | | ^
|_________________________| | | | |
^ | | | ___________V___________
| | | |->|audio DSP |
___________V_____________ | | |_______________________|
|XHCI HCD |<- |
|_________________________| |
Adding ASoC binding layer:
soc-usb: Intention is to treat a USB port similar to a headphone jack.
The port is always present on the device, but cable/pin status can be
enabled/disabled. Expose mechanisms for USB backend ASoC drivers to
communicate with USB SND.
Create a USB backend for Q6DSP:
q6usb: Basic backend driver that will be responsible for maintaining the
resources needed to initiate a playback stream using the Q6DSP. Will
be the entity that checks to make sure the connected USB audio device
supports the requested PCM format. If it does not, the PCM open call will
fail, and userpsace ALSA can take action accordingly.
Introduce XHCI interrupter support:
XHCI HCD supports multiple interrupters, which allows for events to be routed
to different event rings. This is determined by "Interrupter Target" field
specified in Section "6.4.1.1 Normal TRB" of the XHCI specification.
Events in the offloading case will be routed to an event ring that is assigned
to the audio DSP.
Create vendor ops for the USB SND driver:
qc_audio_offload: This particular driver has several components associated
with it:
- QMI stream request handler
- XHCI interrupter and resource management
- audio DSP memory management
When the audio DSP wants to enable a playback stream, the request is first
received by the ASoC platform sound card. Depending on the selected route,
ASoC will bring up the individual DAIs in the path. The Q6USB backend DAI
will send an AFE port start command (with enabling the USB playback path), and
the audio DSP will handle the request accordingly.
Part of the AFE USB port start handling will have an exchange of control
messages using the QMI protocol. The qc_audio_offload driver will populate the
buffer information:
- Event ring base address
- EP transfer ring base address
and pass it along to the audio DSP. All endpoint management will now be handed
over to the DSP, and the main processor is not involved in transfers.
Overall, implementing this feature will still expose separate sound card and PCM
devices for both the platorm card and USB audio device:
0 [SM8250MTPWCD938]: sm8250 - SM8250-MTP-WCD9380-WSA8810-VA-D
SM8250-MTP-WCD9380-WSA8810-VA-DMIC
1 [Audio ]: USB-Audio - USB Audio
Generic USB Audio at usb-xhci-hcd.1.auto-1.4, high speed
This is to ensure that userspace ALSA entities can decide which route to take
when executing the audio playback. In the above, if card#1 is selected, then
USB audio data will take the legacy path over the USB PCM drivers, etc...
This feature was validated using:
- tinymix: set/enable the multimedia path to route to USB backend
- tinyplay: issue playback on platform card
Changelog
--------------------------------------------
Changes in v22:
- Removed components tag for the ASoC platform card, as the USB SND kcontrol for
notifying userspace of offload capable card achieves similar results.
- Due to the above, had to remove the review-by tag for the RST documentation,
as changes were made to remove the components tag section.
- Took in feedback to make the SOC USB add/remove ports void.
- Fixed an issue w/ the USB SND kcontrol management for devices that have multi
UAC interfaces. (would attempt to create the kcontrol more than once)
- Modified SOC USB card and PCM index select to be based off the num_supported
streams that is specified by the USB BE DAI.
- Modified comments on selecting the latest USB headset for offloading.
Changes in v21:
- Added an offload jack disable path from the ASoC platform driver and SOC USB.
- Refactored some of the existing SOC USB context look up APIs and created some
new helpers to search for the USB context.
- Renamed snd_soc_usb_find_format to snd_soc_usb_find_supported_format
- Removed some XHCI sideband calls that would allow clients to actually enable
the IRQ line associated w/ the secondary interrupter. This is removed because
there are other dependencies that are required for that to happen, which are not
covered as part of this series, and to avoid confusion.
- Due to the above, removed the need to export IMOD setting, and enable/disable
interrupter APIs.
Changes in v20:
- Fixed up some formatting changes pointed out in the usb.rst
- Added SB null check during XHCI sideband unregister in case caller passes
improper argument (xhci_sideband_unregister())
Changes in v19:
- Rebased to usb-next to account for some new changes in dependent drivers.
Changes in v18:
- Rebased to usb-next, which merged in part of the series. Removed these patches.
- Reworked Kconfigs for the ASoC USB related components from QCOM Q6DSP drivers
to keep dependencies in place for SoC USB and USB SND.
- Removed the repurposing of the stop ep sync API into existing XHCI operations.
This will be solely used by the XHCI sideband for now.
Changes in v17:
- Fixed an issue where one patch was squashed into another.
- Re-added some kconfig checks for helpers exposed in USB SND for the soc usb
driver, after running different kconfigs.
Changes in v16:
- Modified some code layer dependencies so that soc usb can be split as a separate
module.
- Split the kcontrols from ASoC QCOM common layer into a separate driver
- Reworked SOC USB kcontrols for controlling card + pcm offload routing and status
so that there are individual controls for card and pcm devices.
- Added a kcontrol remove API in SOC USB to remove the controls on the fly. This
required to add some kcontrol management to SOC USB.
- Removed the disconnect work and workqueue for the QC USB offload as it is not
required, since QMI interface driver ensures events are handled in its own WQ.
Changes in v15:
- Removed some already merged XHCI changes
- Separated SOC USB driver from being always compiled into SOC core. Now
configurable from kconfig.
- Fixed up ASoC kcontrol naming to fit guidelines.
- Removed some unnecessary dummy ifdefs.
- Moved usb snd offload capable kcontrol to be initialized by the platform offloading
driver.
Changes in v14:
- Cleaned up some USB SND related feedback:
- Renamed SNDUSB OFFLD playback available --> USB offload capable card
- Fixed locking while checking if stream is in use
- Replaced some mutex pairs with guard(mutex)
Changes in v13:
- Pulled in secondary/primary interrupter rework from Mathias from:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/drivers…
- Did some cleanup and commit message updates, and tested on current code base.
- Added mutex locking to xhci sideband to help prevent any race conditions, esp. for when accessing shared
references.
- Addresed concerns from Hillf about gfp_flags and locking used in qc_usb_audio_offload.
- Rebased onto usb-next
Changes in v12:
- Updated copyright year to 2024. Happy new years!
- Fixed newline format on mixer offload driver.
Changes in v11:
- Modified QMI format structures to be const
Changes in v10:
- Added new mixer for exposing kcontrol for sound card created by USB SND. This
allows for applications to know which platform sound card has offload support.
Will return the card number.
- Broke down and cleaned up some functions/APIs within qc_audio_offload driver.
- Exported xhci_initialize_ring_info(), and modified XHCI makefile to allow for
the XHCI sideband to exist as a module.
- Reworked the jack registration and moved it to the QCOM platform card driver,
ie sm8250.
- Added an SOC USB API to fetch a standard component tag that can be appended to
the platform sound card. Added this tag to sm8250 if any USB path exists within
the DT node.
- Moved kcontrols that existed in the Q6USB driver, and made it a bit more generic,
so that naming can be standardized across solutions. SOC USB is now responsible
for creation of these kcontrols.
- Added a SOC USB RST document explaining some code flows and implementation details
so that other vendors can utilize the framework.
- Addressed a case where USB device connection events are lost if usb offload driver
(qc_audio_offload) is not probed when everything else has been initialized, ie
USB SND, SOC USB and ASoC sound card. Add a rediscover device call during module
init, to ensure that connection events will be propagated.
- Rebased to usb-next.
Changes in v9:
- Fixed the dt binding check issue with regards to num-hc-interrupters.
Changes in v8:
- Cleaned up snd_soc_usb_find_priv_data() based on Mark's feedback. Removed some of
the duplicate looping code that was present on previous patches. Also renamed the API.
- Integrated Mathias' suggestions on his new sideband changes:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=feat…
- Addressed some of Mathias' fixme tags, such as:
- Resetting transfer ring dequeue/enqueue pointers
- Issuing stop endpoint command during ep removal
- Reset ERDP properly to first segment ring during interrupter removal. (this is currently
just being cleared to 0, but should be pointing to a valid segment if controller is still
running.
Changes in v7:
- Fixed dt check error for q6usb bindings
- Updated q6usb property from qcom,usb-audio-intr-num --> qcom,usb-audio-intr-idx
- Removed separate DWC3 HC interrupters num property, and place limits to XHCI one.
- Modified xhci_ring_to_sgtable() to use assigned IOVA/DMA address to fetch pages, as
it is not ensured event ring allocated is always done in the vmalloc range.
Changes in v6:
- Fixed limits and description on several DT bindings (XHCI and Q6USB)
- Fixed patch subjects to follow other ALSA/ASoC notations.
USB SND
- Addressed devices which expose multiple audio (UAC) interfaces. These devices will
create a single USB sound card with multiple audio streams, and receive multiple
interface probe routines. QC offload was not properly considering cases with multiple
probe calls.
- Renamed offload module name and kconfig to fit within the SND domain.
- Renamed attach/detach endpoint API to keep the hw_params notation.
Changes in v5:
- Removed some unnescessary files that were included
- Fixed some typos mentioned
- Addressed dt-binding issues and added hc-interrupters definition to usb-xhci.yaml
XHCI:
- Moved secondary skip events API to xhci-ring and updated implementation
- Utilized existing XHCI APIs, such as inc_deq and xhci_update_erst_dequeue()
USB SND
- Renamed and reworked the APIs in "sound: usb: Export USB SND APIs for modules" patch to
include suggestions to utilize snd_usb_hw_params/free and to avoid generic naming.
- Added a resume_cb() op for completion sake.
- Addressed some locking concerns with regards to when registering for platform hooks.
- Added routine to disconnect all offloaded devices during module unbind.
ASoC
- Replaced individual PCM parameter arguments in snd_soc_usb_connect() with new
snd_soc_usb_device structure to pass along PCM info.
- Modified snd_jack set report to notify HEADPHONE event, as we do not support record path.
Changes in v4:
- Rebased to xhci/for-usb-next
- Addressed some dt-bindings comments
XHCI:
- Pulled in latest changes from Mathias' feature_interrupters branch:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=feat…
- Fixed commit text and signage for the XHCI sideband/interrupter related changes
- Added some logic to address the FIXME tags mentioned throughout the commits, such
as handling multi segment rings and building the SGT, locking concerns, and ep
cleanup operations.
- Removed some fixme tags for conditions that may not be needed/addressed.
- Repurposed the new endpoint stop sync API to be utilized in other places.
- Fixed potential compile issue if XHCI sideband config is not defined.
ASoC:
- Added sound jack control into the Q6USB driver. Allows for userpsace to know when
an offload capable device is connected.
USB SND:
- Avoided exporting _snd_pcm_hw_param_set based on Takashi's recommendation.
- Split USB QMI packet header definitions into a separate commit. This is used to
properly allow the QMI interface driver to parse and route QMI packets accordingly
- Added a "depends on" entry when enabling QC audio offload to avoid compile time
issues.
Changes in v3:
- Changed prefix from RFC to PATCH
- Rebased entire series to usb-next
- Updated copyright years
XHCI:
- Rebased changes on top of XHCI changes merged into usb-next, and only added
changes that were still under discussion.
- Added change to read in the "num-hc-interrupters" device property.
ASoC:
- qusb6 USB backend
- Incorporated suggestions to fetch iommu information with existing APIs
- Added two new sound kcontrols to fetch offload status and offload device
selection.
- offload status - will return the card and pcm device in use
tinymix -D 0 get 1 --> 1, 0 (offload in progress on card#1 pcm#0)
- device selection - set the card and pcm device to enable offload on. Ex.:
tinymix -D 0 set 1 2 0 --> sets offload on card#2 pcm#0
(this should be the USB card)
USB SND:
- Fixed up some locking related concerns for registering platform ops.
- Moved callbacks under the register_mutex, so that
- Modified APIs to properly pass more information about the USB SND device, so
that the Q6USB backend can build a device list/map, in order to monitor offload
status and device selection.
Changes in v2:
XHCI:
- Replaced XHCI and HCD changes with Mathias' XHCI interrupter changes
in his tree:
https://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git/log/?h=feat…
Adjustments made to Mathias' changes:
- Created xhci-intr.h to export/expose interrupter APIs versus exposing xhci.h.
Moved dependent structures to this file as well. (so clients can parse out
information from "struct xhci_interrupter")
- Added some basic locking when requesting interrupters.
- Fixed up some sanity checks.
- Removed clearing of the ERSTBA during freeing of the interrupter. (pending
issue where SMMU fault occurs if DMA addr returned is 64b - TODO)
- Clean up pending events in the XHCI secondary interrupter. While testing USB
bus suspend, it was seen that on bus resume, the xHCI HC would run into a command
timeout.
- Added offloading APIs to xHCI to fetch transfer and event ring information.
ASoC:
- Modified soc-usb to allow for multiple USB port additions. For this to work,
the USB offload driver has to have a reference to the USB backend by adding
a "usb-soc-be" DT entry to the device saved into XHCI sysdev.
- Created separate dt-bindings for defining USB_RX port.
- Increased APR timeout to accommodate the situation where the AFE port start
command could be delayed due to having to issue a USB bus resume while
handling the QMI stream start command.
USB SND:
- Added a platform ops during usb_audio_suspend(). This allows for the USB
offload driver to halt the audio stream when system enters PM suspend. This
ensures the audio DSP is not issuing transfers on the USB bus.
- Do not override platform ops if they are already populated.
- Introduce a shared status variable between the USB offload and USB SND layers,
to ensure that only one path is active at a time. If the USB bus is occupied,
then userspace is notified that the path is busy.
Mathias Nyman (2):
xhci: add helper to stop endpoint and wait for completion
xhci: sideband: add initial api to register a sideband entity
Wesley Cheng (36):
usb: host: xhci: Repurpose event handler for skipping interrupter
events
usb: xhci: Allow for secondary interrupter to set IMOD
usb: host: xhci-mem: Cleanup pending secondary event ring events
usb: host: xhci-mem: Allow for interrupter clients to choose specific
index
ASoC: Add SOC USB APIs for adding an USB backend
ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port
ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp
ASoC: qdsp6: q6afe: Increase APR timeout
ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6
ALSA: usb-audio: Introduce USB SND platform op callbacks
ALSA: usb-audio: Export USB SND APIs for modules
ALSA: usb-audio: Save UAC sample size information
usb: dwc3: Specify maximum number of XHCI interrupters
usb: host: xhci-plat: Set XHCI max interrupters if property is present
ALSA: usb-audio: qcom: Add USB QMI definitions
ALSA: usb-audio: qcom: Introduce QC USB SND offloading support
ALSA: usb-audio: Check for support for requested audio format
ASoC: usb: Add PCM format check API for USB backend
ASoC: qcom: qdsp6: Ensure PCM format is supported by USB audio device
ALSA: usb-audio: Prevent starting of audio stream if in use
ALSA: usb-audio: Do not allow USB offload path if PCM device is in use
ASoC: dt-bindings: Update example for enabling USB offload on SM8250
ALSA: usb-audio: qcom: Populate PCM and USB chip information
ASoC: qcom: qdsp6: Add support to track available USB PCM devices
ASoC: Introduce SND kcontrols to select sound card and PCM device
ASoC: qcom: qdsp6: Add SOC USB offload select get/put callbacks
ASoC: Introduce SND kcontrols to track USB offloading state
ASoC: qcom: qdsp6: Add PCM ops to track current state
ASoC: usb: Create SOC USB SND jack kcontrol
ASoC: qcom: qdsp6: Add headphone jack for offload connection status
ASoC: usb: Fetch ASoC sound card information
ALSA: usb-audio: Add USB offloading capable kcontrol
ALSA: usb-audio: Allow for rediscovery of connected USB SND devices
ALSA: usb-audio: qcom: Use card and PCM index from QMI request
ASoC: usb: Rediscover USB SND devices on USB port add
ASoC: doc: Add documentation for SOC USB
.../bindings/sound/qcom,sm8250.yaml | 15 +
Documentation/sound/soc/index.rst | 1 +
Documentation/sound/soc/usb.rst | 603 ++++++
drivers/usb/dwc3/core.c | 12 +
drivers/usb/dwc3/core.h | 2 +
drivers/usb/dwc3/host.c | 3 +
drivers/usb/host/Kconfig | 9 +
drivers/usb/host/Makefile | 2 +
drivers/usb/host/xhci-mem.c | 36 +-
drivers/usb/host/xhci-plat.c | 2 +
drivers/usb/host/xhci-ring.c | 50 +-
drivers/usb/host/xhci-sideband.c | 418 ++++
drivers/usb/host/xhci.c | 43 +-
drivers/usb/host/xhci.h | 18 +-
.../sound/qcom,q6dsp-lpass-ports.h | 1 +
include/linux/usb/xhci-sideband.h | 68 +
include/sound/q6usboffload.h | 20 +
include/sound/soc-usb.h | 188 ++
sound/soc/Kconfig | 10 +
sound/soc/Makefile | 2 +
sound/soc/qcom/Kconfig | 15 +
sound/soc/qcom/Makefile | 2 +
sound/soc/qcom/qdsp6/Makefile | 1 +
sound/soc/qcom/qdsp6/q6afe-dai.c | 60 +
sound/soc/qcom/qdsp6/q6afe.c | 193 +-
sound/soc/qcom/qdsp6/q6afe.h | 36 +-
sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c | 23 +
sound/soc/qcom/qdsp6/q6dsp-lpass-ports.h | 1 +
sound/soc/qcom/qdsp6/q6routing.c | 9 +
sound/soc/qcom/qdsp6/q6usb.c | 417 ++++
sound/soc/qcom/sm8250.c | 23 +-
sound/soc/qcom/usb_offload_utils.c | 55 +
sound/soc/qcom/usb_offload_utils.h | 29 +
sound/soc/soc-usb.c | 684 ++++++
sound/usb/Kconfig | 25 +
sound/usb/Makefile | 2 +-
sound/usb/card.c | 109 +
sound/usb/card.h | 15 +
sound/usb/endpoint.c | 1 +
sound/usb/format.c | 1 +
sound/usb/helper.c | 1 +
sound/usb/pcm.c | 104 +-
sound/usb/pcm.h | 11 +
sound/usb/qcom/Makefile | 6 +
sound/usb/qcom/mixer_usb_offload.c | 65 +
sound/usb/qcom/mixer_usb_offload.h | 17 +
sound/usb/qcom/qc_audio_offload.c | 1915 +++++++++++++++++
sound/usb/qcom/usb_audio_qmi_v01.c | 892 ++++++++
sound/usb/qcom/usb_audio_qmi_v01.h | 162 ++
49 files changed, 6327 insertions(+), 50 deletions(-)
create mode 100644 Documentation/sound/soc/usb.rst
create mode 100644 drivers/usb/host/xhci-sideband.c
create mode 100644 include/linux/usb/xhci-sideband.h
create mode 100644 include/sound/q6usboffload.h
create mode 100644 include/sound/soc-usb.h
create mode 100644 sound/soc/qcom/qdsp6/q6usb.c
create mode 100644 sound/soc/qcom/usb_offload_utils.c
create mode 100644 sound/soc/qcom/usb_offload_utils.h
create mode 100644 sound/soc/soc-usb.c
create mode 100644 sound/usb/qcom/Makefile
create mode 100644 sound/usb/qcom/mixer_usb_offload.c
create mode 100644 sound/usb/qcom/mixer_usb_offload.h
create mode 100644 sound/usb/qcom/qc_audio_offload.c
create mode 100644 sound/usb/qcom/usb_audio_qmi_v01.c
create mode 100644 sound/usb/qcom/usb_audio_qmi_v01.h
2
42
08 Jun '24
From: Srinivas Kandagatla <srinivas.kandagatla(a)linaro.org>
This patchset adds support for.
1. parse Display Port module tokens from ASoC topology
2. add support to DP/HDMI Jack events.
3. fixes a typo in function name in sm8250
Verified these patches on X13s along with changes to tplg in
https://git.codelinaro.org/linaro/qcomlt/audioreach-topology/-/tree/topic/x…
and ucm changes from https://github.com/Srinivas-Kandagatla/alsa-ucm-conf/tree/topic/x13s-dp
Thanks,
Srini
Changes since v1:
- Fixed unused variable warning.
- fixed warning 'break;' to avoid fall-through
Srinivas Kandagatla (4):
ASoC: qcom: q6dsp: parse Display port tokens
ASoC: qcom: common: add Display port Jack function
ASoC: qcom: sc8280xp: add Display port Jack
ASoC: qcom: sm8250: fix a typo in function name
sound/soc/qcom/common.c | 29 +++++++++++++++++++++++++++++
sound/soc/qcom/common.h | 3 +++
sound/soc/qcom/qdsp6/topology.c | 26 ++++++++++++++++++++++++++
sound/soc/qcom/sc8280xp.c | 14 ++++++++++++++
sound/soc/qcom/sm8250.c | 4 ++--
5 files changed, 74 insertions(+), 2 deletions(-)
--
2.25.1
5
24