Merge series "ASoC: rsnd: cleanup ppcheck warning for Renesas sound driver" from...
authorMark Brown <broonie@kernel.org>
Mon, 1 Mar 2021 23:31:55 +0000 (23:31 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 10 Mar 2021 13:08:35 +0000 (13:08 +0000)
Hi Mark, Pierre-Louis

These patches are based on below patch-set which from Pierre-Louis,
and cleanup cppcheck warnings for Rensas sound driver.
[3/5] has Reported-by Pierre-Louis tag.

Subject: [PATCH 0/8] ASoC: sh: remove cppcheck warnings
Date: Fri, 19 Feb 2021 17:16:27 -0600

Kuninori Morimoto (5):
  ASoC: rsnd: cleanup ppcheck warning for ssiu.c
  ASoC: rsnd: cleanup ppcheck warning for ssi.c
  ASoC: rsnd: cleanup ppcheck warning for core.c
  ASoC: rsnd: cleanup ppcheck warning for cmd.c
  ASoC: rsnd: cleanup ppcheck warning for adg.c

 sound/soc/sh/rcar/adg.c  | 15 +++++++-------
 sound/soc/sh/rcar/cmd.c  | 15 +++++++-------
 sound/soc/sh/rcar/core.c | 32 +++++++++++++---------------
 sound/soc/sh/rcar/ssi.c  | 45 ++++++++++++++++++++--------------------
 sound/soc/sh/rcar/ssiu.c | 22 +++++++++++---------
 5 files changed, 64 insertions(+), 65 deletions(-)

--
2.25.1

73 files changed:
include/sound/soc-component.h
include/sound/soc.h
sound/soc/codecs/Kconfig
sound/soc/codecs/Makefile
sound/soc/codecs/lpass-rx-macro.c
sound/soc/codecs/lpass-wsa-macro.c
sound/soc/codecs/rt1011.c
sound/soc/codecs/rt1015.c
sound/soc/codecs/rt1016.c
sound/soc/codecs/rt1305.c
sound/soc/codecs/rt1308-sdw.c
sound/soc/codecs/rt1308.c
sound/soc/codecs/rt1316-sdw.c [new file with mode: 0644]
sound/soc/codecs/rt1316-sdw.h [new file with mode: 0644]
sound/soc/codecs/rt5631.c
sound/soc/codecs/rt5682-sdw.c
sound/soc/codecs/rt700-sdw.c
sound/soc/codecs/rt700.c
sound/soc/codecs/rt711-sdw.c
sound/soc/codecs/rt711.c
sound/soc/codecs/rt715-sdw.c
sound/soc/codecs/rt715.c
sound/soc/codecs/wcd-clsh-v2.h
sound/soc/codecs/wcd9335.c
sound/soc/codecs/wcd934x.c
sound/soc/fsl/fsl_asrc.c
sound/soc/fsl/fsl_dma.c
sound/soc/fsl/fsl_easrc.c
sound/soc/fsl/fsl_esai.c
sound/soc/fsl/fsl_micfil.c
sound/soc/fsl/fsl_sai.c
sound/soc/fsl/fsl_sai.h
sound/soc/fsl/fsl_ssi.c
sound/soc/fsl/fsl_xcvr.c
sound/soc/fsl/imx-hdmi.c
sound/soc/fsl/mpc5200_dma.c
sound/soc/fsl/mpc8610_hpcd.c
sound/soc/fsl/p1022_ds.c
sound/soc/generic/simple-card-utils.c
sound/soc/intel/Makefile
sound/soc/intel/boards/sof_wm8804.c
sound/soc/intel/skylake/Makefile
sound/soc/meson/aiu-acodec-ctrl.c
sound/soc/meson/aiu-codec-ctrl.c
sound/soc/meson/aiu.c
sound/soc/meson/aiu.h
sound/soc/mxs/mxs-saif.c
sound/soc/pxa/mmp-sspa.c
sound/soc/qcom/lpass-cpu.c
sound/soc/qcom/lpass-hdmi.c
sound/soc/qcom/lpass-platform.c
sound/soc/qcom/qdsp6/q6afe-dai.c
sound/soc/qcom/qdsp6/q6afe.c
sound/soc/qcom/qdsp6/q6afe.h
sound/soc/qcom/qdsp6/q6asm.h
sound/soc/samsung/i2s.c
sound/soc/samsung/s3c24xx_simtec.c
sound/soc/samsung/smdk_wm8994.c
sound/soc/samsung/snow.c
sound/soc/sh/dma-sh7760.c
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/ctu.c
sound/soc/sh/rcar/rsnd.h
sound/soc/sh/rcar/ssi.c
sound/soc/sh/siu_pcm.c
sound/soc/soc-component.c
sound/soc/soc-core.c
sound/soc/soc-ops.c
sound/soc/soc-pcm.c
sound/soc/soc-topology.c
sound/soc/sof/intel/hda-dsp.c
sound/soc/sunxi/sun4i-i2s.c
sound/soc/uniphier/aio-cpu.c

index 5b47768..7dc75b3 100644 (file)
@@ -101,7 +101,7 @@ struct snd_soc_component_driver {
 
        /* DT */
        int (*of_xlate_dai_name)(struct snd_soc_component *component,
-                                struct of_phandle_args *args,
+                                const struct of_phandle_args *args,
                                 const char **dai_name);
        int (*of_xlate_dai_id)(struct snd_soc_component *comment,
                               struct device_node *endpoint);
@@ -450,7 +450,7 @@ void snd_soc_component_remove(struct snd_soc_component *component);
 int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
                                      struct device_node *ep);
 int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
-                                       struct of_phandle_args *args,
+                                       const struct of_phandle_args *args,
                                        const char **dai_name);
 int snd_soc_component_compr_open(struct snd_compr_stream *cstream);
 void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
index bd38015..78609ab 100644 (file)
@@ -1219,7 +1219,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
                                     struct device_node **bitclkmaster,
                                     struct device_node **framemaster);
 int snd_soc_get_dai_id(struct device_node *ep);
-int snd_soc_get_dai_name(struct of_phandle_args *args,
+int snd_soc_get_dai_name(const struct of_phandle_args *args,
                         const char **dai_name);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
                            const char **dai_name);
index 1c87b42..0eb9f06 100644 (file)
@@ -182,6 +182,7 @@ config SND_SOC_ALL_CODECS
        imply SND_SOC_RT711_SDW
        imply SND_SOC_RT715_SDW
        imply SND_SOC_RT1308_SDW
+       imply SND_SOC_RT1316_SDW
        imply SND_SOC_SGTL5000
        imply SND_SOC_SI476X
        imply SND_SOC_SIMPLE_AMPLIFIER
@@ -1143,6 +1144,11 @@ config SND_SOC_RT1308_SDW
        depends on I2C && SOUNDWIRE
        select REGMAP_SOUNDWIRE
 
+config SND_SOC_RT1316_SDW
+       tristate "Realtek RT1316 Codec - SDW"
+       depends on SOUNDWIRE
+       select REGMAP_SOUNDWIRE
+
 config SND_SOC_RT5514
        tristate
        depends on I2C
index 81357dc..1585bc1 100644 (file)
@@ -173,6 +173,7 @@ snd-soc-rt1015p-objs := rt1015p.o
 snd-soc-rt1305-objs := rt1305.o
 snd-soc-rt1308-objs := rt1308.o
 snd-soc-rt1308-sdw-objs := rt1308-sdw.o
+snd-soc-rt1316-sdw-objs := rt1316-sdw.o
 snd-soc-rt274-objs := rt274.o
 snd-soc-rt286-objs := rt286.o
 snd-soc-rt298-objs := rt298.o
@@ -487,6 +488,7 @@ obj-$(CONFIG_SND_SOC_RT1015P)       += snd-soc-rt1015p.o
 obj-$(CONFIG_SND_SOC_RT1305)   += snd-soc-rt1305.o
 obj-$(CONFIG_SND_SOC_RT1308)   += snd-soc-rt1308.o
 obj-$(CONFIG_SND_SOC_RT1308_SDW)       += snd-soc-rt1308-sdw.o
+obj-$(CONFIG_SND_SOC_RT1316_SDW)       += snd-soc-rt1316-sdw.o
 obj-$(CONFIG_SND_SOC_RT274)    += snd-soc-rt274.o
 obj-$(CONFIG_SND_SOC_RT286)    += snd-soc-rt286.o
 obj-$(CONFIG_SND_SOC_RT298)    += snd-soc-rt298.o
index 8c04b3b..76909c5 100644 (file)
@@ -2038,7 +2038,7 @@ static int rx_macro_load_compander_coeff(struct snd_soc_component *component,
 {
        u16 comp_coeff_lsb_reg, comp_coeff_msb_reg;
        int i;
-       int hph_pwr_mode = HPH_LOHIFI;
+       int hph_pwr_mode;
 
        if (!rx->comp_enabled[comp])
                return 0;
index 9ca49a1..e37c814 100644 (file)
@@ -944,6 +944,8 @@ static int wsa_macro_set_interpolator_rate(struct snd_soc_dai *dai,
                goto prim_rate;
 
        ret = wsa_macro_set_mix_interpolator_rate(dai, (u8) rate_val, sample_rate);
+       if (ret < 0)
+               return ret;
 prim_rate:
        /* set primary path sample rate */
        for (i = 0; i < ARRAY_SIZE(int_prim_sample_rate_val); i++) {
index 098ecf1..6877be5 100644 (file)
@@ -2151,7 +2151,7 @@ MODULE_DEVICE_TABLE(of, rt1011_of_match);
 #endif
 
 #ifdef CONFIG_ACPI
-static struct acpi_device_id rt1011_acpi_match[] = {
+static const struct acpi_device_id rt1011_acpi_match[] = {
        {"10EC1011", 0,},
        {},
 };
index 844e407..3cd967a 100644 (file)
@@ -1028,7 +1028,7 @@ static void rt1015_remove(struct snd_soc_component *component)
 #define RT1015_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
                        SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
 
-static struct snd_soc_dai_ops rt1015_aif_dai_ops = {
+static const struct snd_soc_dai_ops rt1015_aif_dai_ops = {
        .hw_params = rt1015_hw_params,
        .set_fmt = rt1015_set_dai_fmt,
        .set_tdm_slot = rt1015_set_tdm_slot,
@@ -1121,7 +1121,7 @@ MODULE_DEVICE_TABLE(of, rt1015_of_match);
 #endif
 
 #ifdef CONFIG_ACPI
-static struct acpi_device_id rt1015_acpi_match[] = {
+static const struct acpi_device_id rt1015_acpi_match[] = {
        {"10EC1015", 0,},
        {},
 };
index a23d368..c14a809 100644 (file)
@@ -534,7 +534,7 @@ static void rt1016_remove(struct snd_soc_component *component)
 #define RT1016_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
                        SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
 
-static struct snd_soc_dai_ops rt1016_aif_dai_ops = {
+static const struct snd_soc_dai_ops rt1016_aif_dai_ops = {
        .hw_params = rt1016_hw_params,
        .set_fmt = rt1016_set_dai_fmt,
 };
@@ -623,7 +623,7 @@ MODULE_DEVICE_TABLE(of, rt1016_of_match);
 #endif
 
 #ifdef CONFIG_ACPI
-static struct acpi_device_id rt1016_acpi_match[] = {
+static const struct acpi_device_id rt1016_acpi_match[] = {
        {"10EC1016", 0,},
        {},
 };
index 4e9dfd2..16aa405 100644 (file)
@@ -975,7 +975,7 @@ MODULE_DEVICE_TABLE(of, rt1305_of_match);
 #endif
 
 #ifdef CONFIG_ACPI
-static struct acpi_device_id rt1305_acpi_match[] = {
+static const struct acpi_device_id rt1305_acpi_match[] = {
        {"10EC1305", 0,},
        {"10EC1306", 0,},
        {},
index afd2c3b..1c22699 100644 (file)
@@ -594,7 +594,7 @@ static int rt1308_sdw_pcm_hw_free(struct snd_pcm_substream *substream,
  * slave_ops: callbacks for get_clock_stop_mode, clock_stop and
  * port_prep are not defined for now
  */
-static struct sdw_slave_ops rt1308_slave_ops = {
+static const struct sdw_slave_ops rt1308_slave_ops = {
        .read_prop = rt1308_read_prop,
        .interrupt_callback = rt1308_interrupt_callback,
        .update_status = rt1308_update_status,
index b75931a..76e6584 100644 (file)
@@ -790,7 +790,7 @@ MODULE_DEVICE_TABLE(of, rt1308_of_match);
 #endif
 
 #ifdef CONFIG_ACPI
-static struct acpi_device_id rt1308_acpi_match[] = {
+static const struct acpi_device_id rt1308_acpi_match[] = {
        { "10EC1308", 0, },
        { },
 };
diff --git a/sound/soc/codecs/rt1316-sdw.c b/sound/soc/codecs/rt1316-sdw.c
new file mode 100644 (file)
index 0000000..a6fb34a
--- /dev/null
@@ -0,0 +1,744 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// rt1316-sdw.c -- rt1316 SDCA ALSA SoC amplifier audio driver
+//
+// Copyright(c) 2021 Realtek Semiconductor Corp.
+//
+//
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/pm_runtime.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc-dapm.h>
+#include <sound/initval.h>
+#include "rt1316-sdw.h"
+
+static const struct reg_default rt1316_reg_defaults[] = {
+       { 0x3004, 0x00 },
+       { 0x3005, 0x00 },
+       { 0x3206, 0x00 },
+       { 0xc001, 0x00 },
+       { 0xc002, 0x00 },
+       { 0xc003, 0x00 },
+       { 0xc004, 0x00 },
+       { 0xc005, 0x00 },
+       { 0xc006, 0x00 },
+       { 0xc007, 0x00 },
+       { 0xc008, 0x00 },
+       { 0xc009, 0x00 },
+       { 0xc00a, 0x00 },
+       { 0xc00b, 0x00 },
+       { 0xc00c, 0x00 },
+       { 0xc00d, 0x00 },
+       { 0xc00e, 0x00 },
+       { 0xc00f, 0x00 },
+       { 0xc010, 0xa5 },
+       { 0xc011, 0x00 },
+       { 0xc012, 0xff },
+       { 0xc013, 0xff },
+       { 0xc014, 0x40 },
+       { 0xc015, 0x00 },
+       { 0xc016, 0x00 },
+       { 0xc017, 0x00 },
+       { 0xc605, 0x30 },
+       { 0xc700, 0x0a },
+       { 0xc701, 0xaa },
+       { 0xc702, 0x1a },
+       { 0xc703, 0x0a },
+       { 0xc710, 0x80 },
+       { 0xc711, 0x00 },
+       { 0xc712, 0x3e },
+       { 0xc713, 0x80 },
+       { 0xc714, 0x80 },
+       { 0xc715, 0x06 },
+       { 0xd101, 0x00 },
+       { 0xd102, 0x30 },
+       { 0xd103, 0x00 },
+       { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_UDMPU21, RT1316_SDCA_CTL_UDMPU_CLUSTER, 0), 0x00 },
+       { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_FU21, RT1316_SDCA_CTL_FU_MUTE, CH_L), 0x01 },
+       { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_FU21, RT1316_SDCA_CTL_FU_MUTE, CH_R), 0x01 },
+       { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_XU24, RT1316_SDCA_CTL_BYPASS, 0), 0x01 },
+       { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE23, RT1316_SDCA_CTL_REQ_POWER_STATE, 0), 0x03 },
+       { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE22, RT1316_SDCA_CTL_REQ_POWER_STATE, 0), 0x03 },
+       { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE24, RT1316_SDCA_CTL_REQ_POWER_STATE, 0), 0x03 },
+};
+
+static const struct reg_sequence rt1316_blind_write[] = {
+       { 0xc710, 0x17 },
+       { 0xc711, 0x80 },
+       { 0xc712, 0x26 },
+       { 0xc713, 0x06 },
+       { 0xc714, 0x80 },
+       { 0xc715, 0x06 },
+       { 0xc702, 0x0a },
+       { 0xc703, 0x0a },
+       { 0xc001, 0x45 },
+       { 0xc003, 0x00 },
+       { 0xc004, 0x11 },
+       { 0xc005, 0x00 },
+       { 0xc006, 0x00 },
+       { 0xc106, 0x00 },
+       { 0xc007, 0x11 },
+       { 0xc008, 0x11 },
+       { 0xc009, 0x00 },
+
+       { 0x2f0a, 0x00 },
+       { 0xd101, 0xf0 },
+       { 0xd103, 0x9b },
+       { 0x2f36, 0x8e },
+       { 0x3206, 0x80 },
+       { 0x3211, 0x0b },
+       { 0x3216, 0x06 },
+       { 0xc614, 0x20 },
+       { 0xc615, 0x0a },
+       { 0xc616, 0x02 },
+       { 0xc617, 0x00 },
+       { 0xc60b, 0x10 },
+       { 0xc60e, 0x05 },
+       { 0xc102, 0x00 },
+       { 0xc090, 0xb0 },
+       { 0xc00f, 0x01 },
+       { 0xc09c, 0x7b },
+
+       { 0xc602, 0x07 },
+       { 0xc603, 0x07 },
+       { 0xc0a3, 0x71 },
+       { 0xc00b, 0x30 },
+       { 0xc093, 0x80 },
+       { 0xc09d, 0x80 },
+       { 0xc0b0, 0x77 },
+       { 0xc010, 0xa5 },
+       { 0xc050, 0x83 },
+       { 0x2f55, 0x03 },
+       { 0x3217, 0xb5 },
+       { 0x3202, 0x02 },
+
+       { SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_XU24, RT1316_SDCA_CTL_BYPASS, 0), 0x00 },
+
+       /* for IV sense */
+       { 0x2232, 0x80 },
+       { 0xc0b0, 0x77 },
+       { 0xc011, 0x00 },
+       { 0xc020, 0x00 },
+       { 0xc023, 0x00 },
+       { 0x3101, 0x00 },
+       { 0x3004, 0xa0 },
+       { 0x3005, 0xb1 },
+       { 0xc007, 0x11 },
+       { 0xc008, 0x11 },
+       { 0xc009, 0x00 },
+       { 0xc022, 0xd6 },
+       { 0xc025, 0xd6 },
+
+       { 0xd001, 0x03 },
+       { 0xd002, 0xbf },
+       { 0xd003, 0x03 },
+       { 0xd004, 0xbf },
+};
+
+static bool rt1316_readable_register(struct device *dev, unsigned int reg)
+{
+       switch (reg) {
+       case 0x2f0a:
+       case 0x2f36:
+       case 0x3203 ... 0x320e:
+       case 0xc000 ... 0xc7b4:
+       case 0xcf00 ... 0xcf03:
+       case 0xd101 ... 0xd103:
+       case SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_UDMPU21, RT1316_SDCA_CTL_UDMPU_CLUSTER, 0):
+       case SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_FU21, RT1316_SDCA_CTL_FU_MUTE, CH_L):
+       case SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_FU21, RT1316_SDCA_CTL_FU_MUTE, CH_R):
+       case SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE23, RT1316_SDCA_CTL_REQ_POWER_STATE, 0):
+       case SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE27, RT1316_SDCA_CTL_REQ_POWER_STATE, 0):
+       case SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE22, RT1316_SDCA_CTL_REQ_POWER_STATE, 0):
+       case SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE24, RT1316_SDCA_CTL_REQ_POWER_STATE, 0):
+               return true;
+       default:
+               return false;
+       }
+}
+
+static bool rt1316_volatile_register(struct device *dev, unsigned int reg)
+{
+       switch (reg) {
+       case 0xc000:
+       case 0xc093:
+       case 0xc09d:
+       case 0xc0a3:
+       case 0xc201:
+       case 0xc427 ... 0xc428:
+       case 0xd102:
+               return true;
+       default:
+               return false;
+       }
+}
+
+static const struct regmap_config rt1316_sdw_regmap = {
+       .reg_bits = 32,
+       .val_bits = 8,
+       .readable_reg = rt1316_readable_register,
+       .volatile_reg = rt1316_volatile_register,
+       .max_register = 0x4108ffff,
+       .reg_defaults = rt1316_reg_defaults,
+       .num_reg_defaults = ARRAY_SIZE(rt1316_reg_defaults),
+       .cache_type = REGCACHE_RBTREE,
+       .use_single_read = true,
+       .use_single_write = true,
+};
+
+static int rt1316_read_prop(struct sdw_slave *slave)
+{
+       struct sdw_slave_prop *prop = &slave->prop;
+       int nval;
+       int i, j;
+       u32 bit;
+       unsigned long addr;
+       struct sdw_dpn_prop *dpn;
+
+       prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY;
+       prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY;
+       prop->is_sdca = true;
+
+       prop->paging_support = true;
+
+       /* first we need to allocate memory for set bits in port lists */
+       prop->source_ports = 0x04; /* BITMAP: 00000100 */
+       prop->sink_ports = 0x2; /* BITMAP:  00000010 */
+
+       nval = hweight32(prop->source_ports);
+       prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval,
+               sizeof(*prop->src_dpn_prop), GFP_KERNEL);
+       if (!prop->src_dpn_prop)
+               return -ENOMEM;
+
+       i = 0;
+       dpn = prop->src_dpn_prop;
+       addr = prop->source_ports;
+       for_each_set_bit(bit, &addr, 32) {
+               dpn[i].num = bit;
+               dpn[i].type = SDW_DPN_FULL;
+               dpn[i].simple_ch_prep_sm = true;
+               dpn[i].ch_prep_timeout = 10;
+               i++;
+       }
+
+       /* do this again for sink now */
+       nval = hweight32(prop->sink_ports);
+       prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval,
+               sizeof(*prop->sink_dpn_prop), GFP_KERNEL);
+       if (!prop->sink_dpn_prop)
+               return -ENOMEM;
+
+       j = 0;
+       dpn = prop->sink_dpn_prop;
+       addr = prop->sink_ports;
+       for_each_set_bit(bit, &addr, 32) {
+               dpn[j].num = bit;
+               dpn[j].type = SDW_DPN_FULL;
+               dpn[j].simple_ch_prep_sm = true;
+               dpn[j].ch_prep_timeout = 10;
+               j++;
+       }
+
+       /* set the timeout values */
+       prop->clk_stop_timeout = 20;
+
+       dev_dbg(&slave->dev, "%s\n", __func__);
+
+       return 0;
+}
+
+static int rt1316_io_init(struct device *dev, struct sdw_slave *slave)
+{
+       struct rt1316_sdw_priv *rt1316 = dev_get_drvdata(dev);
+
+       if (rt1316->hw_init)
+               return 0;
+
+       if (rt1316->first_hw_init) {
+               regcache_cache_only(rt1316->regmap, false);
+               regcache_cache_bypass(rt1316->regmap, true);
+       } else {
+               /*
+                * PM runtime is only enabled when a Slave reports as Attached
+                */
+
+               /* set autosuspend parameters */
+               pm_runtime_set_autosuspend_delay(&slave->dev, 3000);
+               pm_runtime_use_autosuspend(&slave->dev);
+
+               /* update count of parent 'active' children */
+               pm_runtime_set_active(&slave->dev);
+
+               /* make sure the device does not suspend immediately */
+               pm_runtime_mark_last_busy(&slave->dev);
+
+               pm_runtime_enable(&slave->dev);
+       }
+
+       pm_runtime_get_noresume(&slave->dev);
+
+       /* sw reset */
+       regmap_write(rt1316->regmap, 0xc000, 0x02);
+
+       /* initial settings - blind write */
+       regmap_multi_reg_write(rt1316->regmap, rt1316_blind_write,
+               ARRAY_SIZE(rt1316_blind_write));
+
+       if (rt1316->first_hw_init) {
+               regcache_cache_bypass(rt1316->regmap, false);
+               regcache_mark_dirty(rt1316->regmap);
+       } else
+               rt1316->first_hw_init = true;
+
+       /* Mark Slave initialization complete */
+       rt1316->hw_init = true;
+
+       pm_runtime_mark_last_busy(&slave->dev);
+       pm_runtime_put_autosuspend(&slave->dev);
+
+       dev_dbg(&slave->dev, "%s hw_init complete\n", __func__);
+       return 0;
+}
+
+static int rt1316_update_status(struct sdw_slave *slave,
+                                       enum sdw_slave_status status)
+{
+       struct  rt1316_sdw_priv *rt1316 = dev_get_drvdata(&slave->dev);
+
+       /* Update the status */
+       rt1316->status = status;
+
+       if (status == SDW_SLAVE_UNATTACHED)
+               rt1316->hw_init = false;
+
+       /*
+        * Perform initialization only if slave status is present and
+        * hw_init flag is false
+        */
+       if (rt1316->hw_init || rt1316->status != SDW_SLAVE_ATTACHED)
+               return 0;
+
+       /* perform I/O transfers required for Slave initialization */
+       return rt1316_io_init(&slave->dev, slave);
+}
+
+static int rt1316_classd_event(struct snd_soc_dapm_widget *w,
+       struct snd_kcontrol *kcontrol, int event)
+{
+       struct snd_soc_component *component =
+               snd_soc_dapm_to_component(w->dapm);
+       struct rt1316_sdw_priv *rt1316 = snd_soc_component_get_drvdata(component);
+       unsigned char ps0 = 0x0, ps3 = 0x3;
+
+       switch (event) {
+       case SND_SOC_DAPM_POST_PMU:
+               regmap_write(rt1316->regmap,
+                       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE23,
+                               RT1316_SDCA_CTL_REQ_POWER_STATE, 0),
+                               ps0);
+               regmap_write(rt1316->regmap,
+                       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE27,
+                               RT1316_SDCA_CTL_REQ_POWER_STATE, 0),
+                               ps0);
+               regmap_write(rt1316->regmap,
+                       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE22,
+                               RT1316_SDCA_CTL_REQ_POWER_STATE, 0),
+                               ps0);
+               break;
+       case SND_SOC_DAPM_PRE_PMD:
+               regmap_write(rt1316->regmap,
+                       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE23,
+                               RT1316_SDCA_CTL_REQ_POWER_STATE, 0),
+                               ps3);
+               regmap_write(rt1316->regmap,
+                       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE27,
+                               RT1316_SDCA_CTL_REQ_POWER_STATE, 0),
+                               ps3);
+               regmap_write(rt1316->regmap,
+                       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE22,
+                               RT1316_SDCA_CTL_REQ_POWER_STATE, 0),
+                               ps3);
+               break;
+
+       default:
+               break;
+       }
+
+       return 0;
+}
+
+static int rt1316_pde24_event(struct snd_soc_dapm_widget *w,
+       struct snd_kcontrol *kcontrol, int event)
+{
+       struct snd_soc_component *component =
+               snd_soc_dapm_to_component(w->dapm);
+       struct rt1316_sdw_priv *rt1316 = snd_soc_component_get_drvdata(component);
+       unsigned char ps0 = 0x0, ps3 = 0x3;
+
+       switch (event) {
+       case SND_SOC_DAPM_POST_PMU:
+               regmap_write(rt1316->regmap,
+                       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE24,
+                               RT1316_SDCA_CTL_REQ_POWER_STATE, 0),
+                               ps0);
+               break;
+       case SND_SOC_DAPM_PRE_PMD:
+               regmap_write(rt1316->regmap,
+                       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_PDE24,
+                               RT1316_SDCA_CTL_REQ_POWER_STATE, 0),
+                               ps3);
+               break;
+       }
+       return 0;
+}
+
+static const char * const rt1316_rx_data_ch_select[] = {
+       "L,R",
+       "L,L",
+       "L,R",
+       "L,L+R",
+       "R,L",
+       "R,R",
+       "R,L+R",
+       "L+R,L",
+       "L+R,R",
+       "L+R,L+R",
+};
+
+static SOC_ENUM_SINGLE_DECL(rt1316_rx_data_ch_enum,
+       SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_UDMPU21, RT1316_SDCA_CTL_UDMPU_CLUSTER, 0), 0,
+       rt1316_rx_data_ch_select);
+
+static const struct snd_kcontrol_new rt1316_snd_controls[] = {
+
+       /* I2S Data Channel Selection */
+       SOC_ENUM("RX Channel Select", rt1316_rx_data_ch_enum),
+
+       /* XU24 Bypass Control */
+       SOC_SINGLE("XU24 Bypass Switch",
+               SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_XU24, RT1316_SDCA_CTL_BYPASS, 0), 0, 1, 0),
+
+       /* Left/Right IV tag */
+       SOC_SINGLE("Left V Tag Select", 0x3004, 0, 7, 0),
+       SOC_SINGLE("Left I Tag Select", 0x3004, 4, 7, 0),
+       SOC_SINGLE("Right V Tag Select", 0x3005, 0, 7, 0),
+       SOC_SINGLE("Right I Tag Select", 0x3005, 4, 7, 0),
+
+       /* IV mixer Control */
+       SOC_DOUBLE("Isense Mixer Switch", 0xc605, 2, 0, 1, 1),
+       SOC_DOUBLE("Vsense Mixer Switch", 0xc605, 3, 1, 1, 1),
+};
+
+static const struct snd_kcontrol_new rt1316_sto_dac =
+       SOC_DAPM_DOUBLE_R("Switch",
+               SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_FU21, RT1316_SDCA_CTL_FU_MUTE, CH_L),
+               SDW_SDCA_CTL(FUNC_NUM_SMART_AMP, RT1316_SDCA_ENT_FU21, RT1316_SDCA_CTL_FU_MUTE, CH_R),
+               0, 1, 1);
+
+static const struct snd_soc_dapm_widget rt1316_dapm_widgets[] = {
+       /* Audio Interface */
+       SND_SOC_DAPM_AIF_IN("DP1RX", "DP1 Playback", 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("DP2TX", "DP2 Capture", 0, SND_SOC_NOPM, 0, 0),
+
+       /* Digital Interface */
+       SND_SOC_DAPM_SWITCH("DAC", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac),
+
+       /* Output Lines */
+       SND_SOC_DAPM_PGA_E("CLASS D", SND_SOC_NOPM, 0, 0, NULL, 0,
+               rt1316_classd_event,
+               SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
+       SND_SOC_DAPM_OUTPUT("SPOL"),
+       SND_SOC_DAPM_OUTPUT("SPOR"),
+
+       SND_SOC_DAPM_SUPPLY("PDE 24", SND_SOC_NOPM, 0, 0,
+               rt1316_pde24_event,
+               SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+       SND_SOC_DAPM_PGA("I Sense", SND_SOC_NOPM, 0, 0, NULL, 0),
+       SND_SOC_DAPM_PGA("V Sense", SND_SOC_NOPM, 0, 0, NULL, 0),
+       SND_SOC_DAPM_SIGGEN("I Gen"),
+       SND_SOC_DAPM_SIGGEN("V Gen"),
+};
+
+static const struct snd_soc_dapm_route rt1316_dapm_routes[] = {
+       { "DAC", "Switch", "DP1RX" },
+       { "CLASS D", NULL, "DAC" },
+       { "SPOL", NULL, "CLASS D" },
+       { "SPOR", NULL, "CLASS D" },
+
+       { "I Sense", NULL, "I Gen" },
+       { "V Sense", NULL, "V Gen" },
+       { "I Sense", NULL, "PDE 24" },
+       { "V Sense", NULL, "PDE 24" },
+       { "DP2TX", NULL, "I Sense" },
+       { "DP2TX", NULL, "V Sense" },
+};
+
+static int rt1316_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
+                               int direction)
+{
+       struct sdw_stream_data *stream;
+
+       if (!sdw_stream)
+               return 0;
+
+       stream = kzalloc(sizeof(*stream), GFP_KERNEL);
+       if (!stream)
+               return -ENOMEM;
+
+       stream->sdw_stream = sdw_stream;
+
+       /* Use tx_mask or rx_mask to configure stream tag and set dma_data */
+       if (direction == SNDRV_PCM_STREAM_PLAYBACK)
+               dai->playback_dma_data = stream;
+       else
+               dai->capture_dma_data = stream;
+
+       return 0;
+}
+
+static void rt1316_sdw_shutdown(struct snd_pcm_substream *substream,
+                               struct snd_soc_dai *dai)
+{
+       struct sdw_stream_data *stream;
+
+       stream = snd_soc_dai_get_dma_data(dai, substream);
+       snd_soc_dai_set_dma_data(dai, substream, NULL);
+       kfree(stream);
+}
+
+static int rt1316_sdw_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
+{
+       struct snd_soc_component *component = dai->component;
+       struct rt1316_sdw_priv *rt1316 =
+               snd_soc_component_get_drvdata(component);
+       struct sdw_stream_config stream_config;
+       struct sdw_port_config port_config;
+       enum sdw_data_direction direction;
+       struct sdw_stream_data *stream;
+       int retval, port, num_channels, ch_mask;
+
+       dev_dbg(dai->dev, "%s %s", __func__, dai->name);
+       stream = snd_soc_dai_get_dma_data(dai, substream);
+
+       if (!stream)
+               return -EINVAL;
+
+       if (!rt1316->sdw_slave)
+               return -EINVAL;
+
+       /* SoundWire specific configuration */
+       /* port 1 for playback */
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               direction = SDW_DATA_DIR_RX;
+               port = 1;
+       } else {
+               direction = SDW_DATA_DIR_TX;
+               port = 2;
+       }
+
+       num_channels = params_channels(params);
+       ch_mask = (1 << num_channels) - 1;
+
+       stream_config.frame_rate = params_rate(params);
+       stream_config.ch_count = num_channels;
+       stream_config.bps = snd_pcm_format_width(params_format(params));
+       stream_config.direction = direction;
+
+       port_config.ch_mask = ch_mask;
+       port_config.num = port;
+
+       retval = sdw_stream_add_slave(rt1316->sdw_slave, &stream_config,
+                               &port_config, 1, stream->sdw_stream);
+       if (retval) {
+               dev_err(dai->dev, "Unable to configure port\n");
+               return retval;
+       }
+
+       return 0;
+}
+
+static int rt1316_sdw_pcm_hw_free(struct snd_pcm_substream *substream,
+                               struct snd_soc_dai *dai)
+{
+       struct snd_soc_component *component = dai->component;
+       struct rt1316_sdw_priv *rt1316 =
+               snd_soc_component_get_drvdata(component);
+       struct sdw_stream_data *stream =
+               snd_soc_dai_get_dma_data(dai, substream);
+
+       if (!rt1316->sdw_slave)
+               return -EINVAL;
+
+       sdw_stream_remove_slave(rt1316->sdw_slave, stream->sdw_stream);
+       return 0;
+}
+
+/*
+ * slave_ops: callbacks for get_clock_stop_mode, clock_stop and
+ * port_prep are not defined for now
+ */
+static struct sdw_slave_ops rt1316_slave_ops = {
+       .read_prop = rt1316_read_prop,
+       .update_status = rt1316_update_status,
+};
+
+static const struct snd_soc_component_driver soc_component_sdw_rt1316 = {
+       .controls = rt1316_snd_controls,
+       .num_controls = ARRAY_SIZE(rt1316_snd_controls),
+       .dapm_widgets = rt1316_dapm_widgets,
+       .num_dapm_widgets = ARRAY_SIZE(rt1316_dapm_widgets),
+       .dapm_routes = rt1316_dapm_routes,
+       .num_dapm_routes = ARRAY_SIZE(rt1316_dapm_routes),
+};
+
+static const struct snd_soc_dai_ops rt1316_aif_dai_ops = {
+       .hw_params = rt1316_sdw_hw_params,
+       .hw_free        = rt1316_sdw_pcm_hw_free,
+       .set_sdw_stream = rt1316_set_sdw_stream,
+       .shutdown       = rt1316_sdw_shutdown,
+};
+
+#define RT1316_STEREO_RATES SNDRV_PCM_RATE_48000
+#define RT1316_FORMATS (SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S16_LE | \
+                       SNDRV_PCM_FMTBIT_S24_LE)
+
+static struct snd_soc_dai_driver rt1316_sdw_dai[] = {
+       {
+               .name = "rt1316-aif",
+               .playback = {
+                       .stream_name = "DP1 Playback",
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = RT1316_STEREO_RATES,
+                       .formats = RT1316_FORMATS,
+               },
+               .capture = {
+                       .stream_name = "DP2 Capture",
+                       .channels_min = 1,
+                       .channels_max = 2,
+                       .rates = RT1316_STEREO_RATES,
+                       .formats = RT1316_FORMATS,
+               },
+               .ops = &rt1316_aif_dai_ops,
+       },
+};
+
+static int rt1316_sdw_init(struct device *dev, struct regmap *regmap,
+                               struct sdw_slave *slave)
+{
+       struct rt1316_sdw_priv *rt1316;
+       int ret;
+
+       rt1316 = devm_kzalloc(dev, sizeof(*rt1316), GFP_KERNEL);
+       if (!rt1316)
+               return -ENOMEM;
+
+       dev_set_drvdata(dev, rt1316);
+       rt1316->sdw_slave = slave;
+       rt1316->regmap = regmap;
+
+       /*
+        * Mark hw_init to false
+        * HW init will be performed when device reports present
+        */
+       rt1316->hw_init = false;
+       rt1316->first_hw_init = false;
+
+       ret =  devm_snd_soc_register_component(dev,
+                               &soc_component_sdw_rt1316,
+                               rt1316_sdw_dai,
+                               ARRAY_SIZE(rt1316_sdw_dai));
+
+       dev_dbg(&slave->dev, "%s\n", __func__);
+
+       return ret;
+}
+
+static int rt1316_sdw_probe(struct sdw_slave *slave,
+                               const struct sdw_device_id *id)
+{
+       struct regmap *regmap;
+
+       /* Regmap Initialization */
+       regmap = devm_regmap_init_sdw(slave, &rt1316_sdw_regmap);
+       if (!regmap)
+               return -EINVAL;
+
+       return rt1316_sdw_init(&slave->dev, regmap, slave);
+}
+
+static const struct sdw_device_id rt1316_id[] = {
+       SDW_SLAVE_ENTRY_EXT(0x025d, 0x1316, 0x3, 0x1, 0),
+       {},
+};
+MODULE_DEVICE_TABLE(sdw, rt1316_id);
+
+static int __maybe_unused rt1316_dev_suspend(struct device *dev)
+{
+       struct rt1316_sdw_priv *rt1316 = dev_get_drvdata(dev);
+
+       if (!rt1316->hw_init)
+               return 0;
+
+       regcache_cache_only(rt1316->regmap, true);
+
+       return 0;
+}
+
+#define RT1316_PROBE_TIMEOUT 5000
+
+static int __maybe_unused rt1316_dev_resume(struct device *dev)
+{
+       struct sdw_slave *slave = dev_to_sdw_dev(dev);
+       struct rt1316_sdw_priv *rt1316 = dev_get_drvdata(dev);
+       unsigned long time;
+
+       if (!rt1316->hw_init)
+               return 0;
+
+       if (!slave->unattach_request)
+               goto regmap_sync;
+
+       time = wait_for_completion_timeout(&slave->initialization_complete,
+                               msecs_to_jiffies(RT1316_PROBE_TIMEOUT));
+       if (!time) {
+               dev_err(&slave->dev, "Initialization not complete, timed out\n");
+               return -ETIMEDOUT;
+       }
+
+regmap_sync:
+       slave->unattach_request = 0;
+       regcache_cache_only(rt1316->regmap, false);
+       regcache_sync(rt1316->regmap);
+
+       return 0;
+}
+
+static const struct dev_pm_ops rt1316_pm = {
+       SET_SYSTEM_SLEEP_PM_OPS(rt1316_dev_suspend, rt1316_dev_resume)
+       SET_RUNTIME_PM_OPS(rt1316_dev_suspend, rt1316_dev_resume, NULL)
+};
+
+static struct sdw_driver rt1316_sdw_driver = {
+       .driver = {
+               .name = "rt1316-sdca",
+               .owner = THIS_MODULE,
+               .pm = &rt1316_pm,
+       },
+       .probe = rt1316_sdw_probe,
+       .ops = &rt1316_slave_ops,
+       .id_table = rt1316_id,
+};
+module_sdw_driver(rt1316_sdw_driver);
+
+MODULE_DESCRIPTION("ASoC RT1316 driver SDCA SDW");
+MODULE_AUTHOR("Shuming Fan <shumingf@realtek.com>");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/rt1316-sdw.h b/sound/soc/codecs/rt1316-sdw.h
new file mode 100644 (file)
index 0000000..cbcdaa8
--- /dev/null
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * rt1316-sdw.h -- RT1316 SDCA ALSA SoC audio driver header
+ *
+ * Copyright(c) 2021 Realtek Semiconductor Corp.
+ */
+
+#ifndef __RT1316_SDW_H__
+#define __RT1316_SDW_H__
+
+#include <linux/regmap.h>
+#include <linux/soundwire/sdw.h>
+#include <linux/soundwire/sdw_type.h>
+#include <linux/soundwire/sdw_registers.h>
+#include <sound/soc.h>
+
+/* RT1316 SDCA Control - function number */
+#define FUNC_NUM_SMART_AMP 0x04
+
+/* RT1316 SDCA entity */
+#define RT1316_SDCA_ENT_PDE23 0x31
+#define RT1316_SDCA_ENT_PDE27 0x32
+#define RT1316_SDCA_ENT_PDE22 0x33
+#define RT1316_SDCA_ENT_PDE24 0x34
+#define RT1316_SDCA_ENT_XU24 0x24
+#define RT1316_SDCA_ENT_FU21 0x03
+#define RT1316_SDCA_ENT_UDMPU21 0x02
+
+/* RT1316 SDCA control */
+#define RT1316_SDCA_CTL_SAMPLE_FREQ_INDEX 0x10
+#define RT1316_SDCA_CTL_REQ_POWER_STATE 0x01
+#define RT1316_SDCA_CTL_BYPASS 0x01
+#define RT1316_SDCA_CTL_FU_MUTE 0x01
+#define RT1316_SDCA_CTL_FU_VOLUME 0x02
+#define RT1316_SDCA_CTL_UDMPU_CLUSTER 0x10
+
+/* RT1316 SDCA channel */
+#define CH_L 0x01
+#define CH_R 0x02
+
+struct rt1316_sdw_priv {
+       struct snd_soc_component *component;
+       struct regmap *regmap;
+       struct sdw_slave *sdw_slave;
+       enum sdw_slave_status status;
+       struct sdw_bus_params params;
+       bool hw_init;
+       bool first_hw_init;
+};
+
+struct sdw_stream_data {
+       struct sdw_stream_runtime *sdw_stream;
+};
+
+#endif /* __RT1316_SDW_H__ */
index 653da3e..afc1305 100644 (file)
@@ -1283,7 +1283,7 @@ static const struct pll_div codec_slave_pll_div[] = {
        {3072000,  12288000,  0x0a90},
 };
 
-static struct coeff_clk_div coeff_div[] = {
+static const struct coeff_clk_div coeff_div[] = {
        /* sysclk is 256fs */
        {2048000,  8000 * 32,  8000, 0x1000},
        {2048000,  8000 * 64,  8000, 0x0000},
index b49f1e1..5e097f7 100644 (file)
@@ -269,7 +269,7 @@ static int rt5682_sdw_hw_free(struct snd_pcm_substream *substream,
        return 0;
 }
 
-static struct snd_soc_dai_ops rt5682_sdw_ops = {
+static const struct snd_soc_dai_ops rt5682_sdw_ops = {
        .hw_params      = rt5682_sdw_hw_params,
        .hw_free        = rt5682_sdw_hw_free,
        .set_sdw_stream = rt5682_set_sdw_stream,
@@ -683,7 +683,7 @@ static int rt5682_interrupt_callback(struct sdw_slave *slave,
        return 0;
 }
 
-static struct sdw_slave_ops rt5682_slave_ops = {
+static const struct sdw_slave_ops rt5682_slave_ops = {
        .read_prop = rt5682_read_prop,
        .interrupt_callback = rt5682_interrupt_callback,
        .update_status = rt5682_update_status,
index 4001612..ff9c081 100644 (file)
@@ -430,7 +430,7 @@ static int rt700_interrupt_callback(struct sdw_slave *slave,
  * slave_ops: callbacks for get_clock_stop_mode, clock_stop and
  * port_prep are not defined for now
  */
-static struct sdw_slave_ops rt700_slave_ops = {
+static const struct sdw_slave_ops rt700_slave_ops = {
        .read_prop = rt700_read_prop,
        .interrupt_callback = rt700_interrupt_callback,
        .update_status = rt700_update_status,
index 66ec395..01af9d9 100644 (file)
@@ -1002,7 +1002,7 @@ static int rt700_pcm_hw_free(struct snd_pcm_substream *substream,
 #define RT700_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
                        SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
 
-static struct snd_soc_dai_ops rt700_ops = {
+static const struct snd_soc_dai_ops rt700_ops = {
        .hw_params      = rt700_pcm_hw_params,
        .hw_free        = rt700_pcm_hw_free,
        .set_sdw_stream = rt700_set_sdw_stream,
index 2beb428..8f5ebe9 100644 (file)
@@ -431,7 +431,7 @@ static int rt711_interrupt_callback(struct sdw_slave *slave,
        return 0;
 }
 
-static struct sdw_slave_ops rt711_slave_ops = {
+static const struct sdw_slave_ops rt711_slave_ops = {
        .read_prop = rt711_read_prop,
        .interrupt_callback = rt711_interrupt_callback,
        .update_status = rt711_update_status,
index 85f7441..202bf6f 100644 (file)
@@ -1048,7 +1048,7 @@ static int rt711_pcm_hw_free(struct snd_pcm_substream *substream,
 #define RT711_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
                        SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
 
-static struct snd_soc_dai_ops rt711_ops = {
+static const struct snd_soc_dai_ops rt711_ops = {
        .hw_params      = rt711_pcm_hw_params,
        .hw_free        = rt711_pcm_hw_free,
        .set_sdw_stream = rt711_set_sdw_stream,
index 71dd3b9..81a1dd7 100644 (file)
@@ -488,7 +488,7 @@ static int rt715_bus_config(struct sdw_slave *slave,
        return 0;
 }
 
-static struct sdw_slave_ops rt715_slave_ops = {
+static const struct sdw_slave_ops rt715_slave_ops = {
        .read_prop = rt715_read_prop,
        .update_status = rt715_update_status,
        .bus_config = rt715_bus_config,
index 9a7d393..f419d00 100644 (file)
@@ -683,7 +683,7 @@ static int rt715_pcm_hw_free(struct snd_pcm_substream *substream,
 #define RT715_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
                        SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
 
-static struct snd_soc_dai_ops rt715_ops = {
+static const struct snd_soc_dai_ops rt715_ops = {
        .hw_params      = rt715_pcm_hw_params,
        .hw_free        = rt715_pcm_hw_free,
        .set_sdw_stream = rt715_set_sdw_stream,
index a902f98..a6d0f2d 100644 (file)
@@ -37,13 +37,13 @@ enum wcd_clsh_mode {
 struct wcd_clsh_ctrl;
 
 extern struct wcd_clsh_ctrl *wcd_clsh_ctrl_alloc(
-                               struct snd_soc_component *component,
+                               struct snd_soc_component *comp,
                                int version);
 extern void wcd_clsh_ctrl_free(struct wcd_clsh_ctrl *ctrl);
 extern int wcd_clsh_ctrl_get_state(struct wcd_clsh_ctrl *ctrl);
 extern int wcd_clsh_ctrl_set_state(struct wcd_clsh_ctrl *ctrl,
-                                  enum wcd_clsh_event event,
-                                  int state,
+                                  enum wcd_clsh_event clsh_event,
+                                  int nstate,
                                   enum wcd_clsh_mode mode);
 
 #endif /* _WCD_CLSH_V2_H_ */
index 9ddfed7..adb325f 100644 (file)
@@ -5213,7 +5213,7 @@ static int wcd9335_slim_status(struct slim_device *sdev,
 
        wcd9335_probe(wcd);
 
-       return ret;
+       return 0;
 }
 
 static const struct slim_device_id wcd9335_slim_id[] = {
index d18ae5e..2c4818d 100644 (file)
@@ -1565,8 +1565,6 @@ static int wcd934x_set_interpolator_rate(struct snd_soc_dai *dai,
                return ret;
        ret = wcd934x_set_mix_interpolator_rate(dai, (u8)rate_val,
                                                sample_rate);
-       if (ret)
-               return ret;
 
        return ret;
 }
index c325c98..63d236e 100644 (file)
@@ -610,7 +610,7 @@ static void fsl_asrc_select_clk(struct fsl_asrc_priv *asrc_priv,
        struct asrc_config *config = pair_priv->config;
        int rate[2], select_clk[2]; /* Array size 2 means IN and OUT */
        int clk_rate, clk_index;
-       int i = 0, j = 0;
+       int i, j;
 
        rate[IN] = in_rate;
        rate[OUT] = out_rate;
index e0c39c5..84bd8a5 100644 (file)
@@ -392,7 +392,6 @@ static int fsl_dma_open(struct snd_soc_component *component,
        dma_addr_t ld_buf_phys;
        u64 temp_link;          /* Pointer to next link descriptor */
        u32 mr;
-       unsigned int channel;
        int ret = 0;
        unsigned int i;
 
@@ -408,8 +407,6 @@ static int fsl_dma_open(struct snd_soc_component *component,
                return ret;
        }
 
-       channel = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
-
        if (dma->assigned) {
                dev_err(dev, "dma channel already assigned\n");
                return -EBUSY;
index 636a702..725a5d3 100644 (file)
@@ -710,7 +710,7 @@ static int fsl_easrc_max_ch_for_slot(struct fsl_asrc_pair *ctx,
                                     struct fsl_easrc_slot *slot)
 {
        struct fsl_easrc_ctx_priv *ctx_priv = ctx->private;
-       int st1_mem_alloc = 0, st2_mem_alloc = 0;
+       int st1_mem_alloc = 0, st2_mem_alloc;
        int pf_mem_alloc = 0;
        int max_channels = 8 - slot->num_channel;
        int channels = 0;
@@ -748,7 +748,7 @@ static int fsl_easrc_config_one_slot(struct fsl_asrc_pair *ctx,
 {
        struct fsl_asrc *easrc = ctx->asrc;
        struct fsl_easrc_ctx_priv *ctx_priv = ctx->private;
-       int st1_chanxexp, st1_mem_alloc = 0, st2_mem_alloc = 0;
+       int st1_chanxexp, st1_mem_alloc = 0, st2_mem_alloc;
        unsigned int reg0, reg1, reg2, reg3;
        unsigned int addr;
 
@@ -1328,7 +1328,7 @@ static int fsl_easrc_stop_context(struct fsl_asrc_pair *ctx)
 {
        struct fsl_asrc *easrc = ctx->asrc;
        int val, i;
-       int size = 0;
+       int size;
        int retry = 200;
 
        regmap_read(easrc->regmap, REG_EASRC_CC(ctx->index), &val);
index 08056fa..41b1544 100644 (file)
@@ -304,7 +304,7 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
 
        if (IS_ERR(clksrc)) {
                dev_err(dai->dev, "no assigned %s clock\n",
-                               clk_id % 2 ? "extal" : "fsys");
+                       (clk_id % 2) ? "extal" : "fsys");
                return PTR_ERR(clksrc);
        }
        clk_rate = clk_get_rate(clksrc);
index 5935af2..2b9edd4 100644 (file)
@@ -423,8 +423,6 @@ static int fsl_micfil_dai_probe(struct snd_soc_dai *cpu_dai)
                return ret;
        }
 
-       snd_soc_dai_set_drvdata(cpu_dai, micfil);
-
        return 0;
 }
 
index 5e65b45..6ef2ce3 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
+#include <linux/pm_qos.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
@@ -727,8 +728,6 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai)
        snd_soc_dai_init_dma_data(cpu_dai, &sai->dma_params_tx,
                                &sai->dma_params_rx);
 
-       snd_soc_dai_set_drvdata(cpu_dai, sai);
-
        return 0;
 }
 
@@ -1177,6 +1176,7 @@ static const struct fsl_sai_soc_data fsl_sai_vf610_data = {
        .fifo_depth = 32,
        .reg_offset = 0,
        .mclk0_is_mclk1 = false,
+       .flags = 0,
 };
 
 static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
@@ -1185,6 +1185,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
        .fifo_depth = 32,
        .reg_offset = 0,
        .mclk0_is_mclk1 = true,
+       .flags = 0,
 };
 
 static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = {
@@ -1193,6 +1194,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = {
        .fifo_depth = 16,
        .reg_offset = 8,
        .mclk0_is_mclk1 = false,
+       .flags = PMQOS_CPU_LATENCY,
 };
 
 static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = {
@@ -1201,6 +1203,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = {
        .fifo_depth = 128,
        .reg_offset = 8,
        .mclk0_is_mclk1 = false,
+       .flags = 0,
 };
 
 static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = {
@@ -1209,6 +1212,7 @@ static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = {
        .fifo_depth = 64,
        .reg_offset = 0,
        .mclk0_is_mclk1 = false,
+       .flags = 0,
 };
 
 static const struct of_device_id fsl_sai_ids[] = {
@@ -1235,6 +1239,9 @@ static int fsl_sai_runtime_suspend(struct device *dev)
 
        clk_disable_unprepare(sai->bus_clk);
 
+       if (sai->soc_data->flags & PMQOS_CPU_LATENCY)
+               cpu_latency_qos_remove_request(&sai->pm_qos_req);
+
        regcache_cache_only(sai->regmap, true);
 
        return 0;
@@ -1264,6 +1271,9 @@ static int fsl_sai_runtime_resume(struct device *dev)
                        goto disable_tx_clk;
        }
 
+       if (sai->soc_data->flags & PMQOS_CPU_LATENCY)
+               cpu_latency_qos_add_request(&sai->pm_qos_req, 0);
+
        regcache_cache_only(sai->regmap, false);
        regcache_mark_dirty(sai->regmap);
        regmap_write(sai->regmap, FSL_SAI_TCSR(ofs), FSL_SAI_CSR_SR);
index ff2619f..bc60030 100644 (file)
 #define FSL_SAI_MAXBURST_TX 6
 #define FSL_SAI_MAXBURST_RX 6
 
+#define PMQOS_CPU_LATENCY   BIT(0)
+
 struct fsl_sai_soc_data {
        bool use_imx_pcm;
        bool use_edma;
        bool mclk0_is_mclk1;
        unsigned int fifo_depth;
        unsigned int reg_offset;
+       unsigned int flags;
 };
 
 /**
@@ -273,6 +276,7 @@ struct fsl_sai {
        struct snd_dmaengine_dai_dma_data dma_params_tx;
        struct fsl_sai_verid verid;
        struct fsl_sai_param param;
+       struct pm_qos_request pm_qos_req;
 };
 
 #define TX 1
index ad8af3f..4e2ce47 100644 (file)
@@ -747,7 +747,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
                sub *= 100000;
                do_div(sub, freq);
 
-               if (sub < savesub && !(i == 0 && psr == 0 && div2 == 0)) {
+               if (sub < savesub && !(i == 0)) {
                        baudrate = tmprate;
                        savesub = sub;
                        pm = i;
@@ -764,8 +764,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
                return -EINVAL;
        }
 
-       stccr = SSI_SxCCR_PM(pm + 1) | (div2 ? SSI_SxCCR_DIV2 : 0) |
-               (psr ? SSI_SxCCR_PSR : 0);
+       stccr = SSI_SxCCR_PM(pm + 1);
        mask = SSI_SxCCR_PM_MASK | SSI_SxCCR_DIV2 | SSI_SxCCR_PSR;
 
        /* STCCR is used for RX in synchronous mode */
index 6dd0a5f..80416e4 100644 (file)
@@ -869,7 +869,6 @@ static int fsl_xcvr_dai_probe(struct snd_soc_dai *dai)
        struct fsl_xcvr *xcvr = snd_soc_dai_get_drvdata(dai);
 
        snd_soc_dai_init_dma_data(dai, &xcvr->dma_prms_tx, &xcvr->dma_prms_rx);
-       snd_soc_dai_set_drvdata(dai, xcvr);
 
        snd_soc_add_dai_controls(dai, &fsl_xcvr_mode_kctl, 1);
        snd_soc_add_dai_controls(dai, &fsl_xcvr_arc_mode_kctl, 1);
@@ -1243,10 +1242,6 @@ static __maybe_unused int fsl_xcvr_runtime_suspend(struct device *dev)
        if (ret < 0)
                dev_err(dev, "Failed to assert M0+ core: %d\n", ret);
 
-       ret = reset_control_assert(xcvr->reset);
-       if (ret < 0)
-               dev_err(dev, "Failed to assert M0+ reset: %d\n", ret);
-
        regcache_cache_only(xcvr->regmap, true);
 
        clk_disable_unprepare(xcvr->spba_clk);
@@ -1262,6 +1257,12 @@ static __maybe_unused int fsl_xcvr_runtime_resume(struct device *dev)
        struct fsl_xcvr *xcvr = dev_get_drvdata(dev);
        int ret;
 
+       ret = reset_control_assert(xcvr->reset);
+       if (ret < 0) {
+               dev_err(dev, "Failed to assert M0+ reset: %d\n", ret);
+               return ret;
+       }
+
        ret = clk_prepare_enable(xcvr->ipg_clk);
        if (ret) {
                dev_err(dev, "failed to start IPG clock.\n");
index dbbb761..1ebcb9a 100644 (file)
 
 /**
  * struct cpu_priv - CPU private data
- * @sysclk_freq: SYSCLK rates for set_sysclk()
- * @sysclk_dir: SYSCLK directions for set_sysclk()
  * @sysclk_id: SYSCLK ids for set_sysclk()
  * @slot_width: Slot width of each frame
  *
  * Note: [1] for tx and [0] for rx
  */
 struct cpu_priv {
-       unsigned long sysclk_freq[2];
-       u32 sysclk_dir[2];
        u32 sysclk_id[2];
        u32 slot_width;
 };
index 2319848..6c65cd8 100644 (file)
@@ -411,7 +411,7 @@ int mpc5200_audio_dma_create(struct platform_device *op)
        psc_dma->dev = &op->dev;
        psc_dma->playback.psc_dma = psc_dma;
        psc_dma->capture.psc_dma = psc_dma;
-       snprintf(psc_dma->name, sizeof psc_dma->name, "PSC%u", psc_dma->id);
+       snprintf(psc_dma->name, sizeof(psc_dma->name), "PSC%d", psc_dma->id);
 
        /* Find the address of the fifo data registers and setup the
         * DMA tasks */
index eccc833..58b9ca3 100644 (file)
@@ -190,7 +190,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
        struct device_node *codec_np = NULL;
        struct mpc8610_hpcd_data *machine_data;
        struct snd_soc_dai_link_component *comp;
-       int ret = -ENODEV;
+       int ret;
        const char *sprop;
        const u32 *iprop;
 
index ac68d22..317c767 100644 (file)
@@ -200,7 +200,7 @@ static int p1022_ds_probe(struct platform_device *pdev)
        struct device_node *codec_np = NULL;
        struct machine_data *mdata;
        struct snd_soc_dai_link_component *comp;
-       int ret = -ENODEV;
+       int ret;
        const char *sprop;
        const u32 *iprop;
 
index ab31045..06c2512 100644 (file)
@@ -254,7 +254,7 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream,
        struct simple_dai_props *dai_props =
                simple_priv_to_props(priv, rtd->num);
        unsigned int mclk, mclk_fs = 0;
-       int ret = 0;
+       int ret;
 
        if (dai_props->mclk_fs)
                mclk_fs = dai_props->mclk_fs;
index 4e0248d..7c50388 100644 (file)
@@ -5,7 +5,7 @@ obj-$(CONFIG_SND_SOC) += common/
 # Platform Support
 obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += atom/
 obj-$(CONFIG_SND_SOC_INTEL_CATPT) += catpt/
-obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += skylake/
+obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE_COMMON) += skylake/
 obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY) += keembay/
 
 # Machine support
index a46ba13..6a181e4 100644 (file)
@@ -124,7 +124,11 @@ static int sof_wm8804_hw_params(struct snd_pcm_substream *substream,
        }
 
        snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div);
-       snd_soc_dai_set_pll(codec_dai, 0, 0, sysclk, mclk_freq);
+       ret = snd_soc_dai_set_pll(codec_dai, 0, 0, sysclk, mclk_freq);
+       if (ret < 0) {
+               dev_err(rtd->card->dev, "Failed to set WM8804 PLL\n");
+               return ret;
+       }
 
        ret = snd_soc_dai_set_sysclk(codec_dai, WM8804_TX_CLKSRC_PLL,
                                     sysclk, SND_SOC_CLOCK_OUT);
index dd39149..1c4649b 100644 (file)
@@ -7,7 +7,7 @@ ifdef CONFIG_DEBUG_FS
   snd-soc-skl-objs += skl-debug.o
 endif
 
-obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
+obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE_COMMON) += snd-soc-skl.o
 
 #Skylake Clock device support
 snd-soc-skl-ssp-clk-objs := skl-ssp-clk.o
index 7078197..27a6d32 100644 (file)
@@ -159,7 +159,7 @@ static const struct snd_kcontrol_new aiu_acodec_ctrl_controls[] = {
 };
 
 static int aiu_acodec_of_xlate_dai_name(struct snd_soc_component *component,
-                                       struct of_phandle_args *args,
+                                       const struct of_phandle_args *args,
                                        const char **dai_name)
 {
        return aiu_of_xlate_dai_name(component, args, dai_name, AIU_ACODEC);
index 4b773d3..c3ea733 100644 (file)
@@ -125,7 +125,7 @@ static const struct snd_soc_dapm_route aiu_hdmi_ctrl_routes[] = {
 };
 
 static int aiu_hdmi_of_xlate_dai_name(struct snd_soc_component *component,
-                                     struct of_phandle_args *args,
+                                     const struct of_phandle_args *args,
                                      const char **dai_name)
 {
        return aiu_of_xlate_dai_name(component, args, dai_name, AIU_HDMI);
index dc35ca7..ba15d57 100644 (file)
@@ -42,7 +42,7 @@ static const struct snd_soc_dapm_route aiu_cpu_dapm_routes[] = {
 };
 
 int aiu_of_xlate_dai_name(struct snd_soc_component *component,
-                         struct of_phandle_args *args,
+                         const struct of_phandle_args *args,
                          const char **dai_name,
                          unsigned int component_id)
 {
@@ -72,7 +72,7 @@ int aiu_of_xlate_dai_name(struct snd_soc_component *component,
 }
 
 static int aiu_cpu_of_xlate_dai_name(struct snd_soc_component *component,
-                                    struct of_phandle_args *args,
+                                    const struct of_phandle_args *args,
                                     const char **dai_name)
 {
        return aiu_of_xlate_dai_name(component, args, dai_name, AIU_CPU);
index 87aa19a..393b6c2 100644 (file)
@@ -45,7 +45,7 @@ struct aiu {
                     SNDRV_PCM_FMTBIT_S24_LE)
 
 int aiu_of_xlate_dai_name(struct snd_soc_component *component,
-                         struct of_phandle_args *args,
+                         const struct of_phandle_args *args,
                          const char **dai_name,
                          unsigned int component_id);
 
index 07f8cf9..6a2d24d 100644 (file)
@@ -642,18 +642,8 @@ static const struct snd_soc_dai_ops mxs_saif_dai_ops = {
        .set_fmt = mxs_saif_set_dai_fmt,
 };
 
-static int mxs_saif_dai_probe(struct snd_soc_dai *dai)
-{
-       struct mxs_saif *saif = dev_get_drvdata(dai->dev);
-
-       snd_soc_dai_set_drvdata(dai, saif);
-
-       return 0;
-}
-
 static struct snd_soc_dai_driver mxs_saif_dai = {
        .name = "mxs-saif",
-       .probe = mxs_saif_dai_probe,
        .playback = {
                .channels_min = 2,
                .channels_max = 2,
index 4803972..7e39210 100644 (file)
@@ -330,7 +330,6 @@ static int mmp_sspa_probe(struct snd_soc_dai *dai)
                                &sspa->playback_dma_data,
                                &sspa->capture_dma_data);
 
-       snd_soc_dai_set_drvdata(dai, sspa);
        return 0;
 }
 
index c642e5f..4762286 100644 (file)
@@ -340,7 +340,7 @@ int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai)
 EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_probe);
 
 static int asoc_qcom_of_xlate_dai_name(struct snd_soc_component *component,
-                                  struct of_phandle_args *args,
+                                  const struct of_phandle_args *args,
                                   const char **dai_name)
 {
        struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
index abfb873..24b1a75 100644 (file)
@@ -183,8 +183,6 @@ static int lpass_hdmi_daiops_hw_params(struct snd_pcm_substream *substream,
                return ret;
 
        ret = regmap_field_write(sstream_ctl->dp_staffing_en, LPASS_SSTREAM_DEFAULT_ENABLE);
-       if (ret)
-               return ret;
 
        return ret;
 }
@@ -200,8 +198,6 @@ static int lpass_hdmi_daiops_prepare(struct snd_pcm_substream *substream,
                return ret;
 
        ret = regmap_field_write(drvdata->meta_ctl->mute, LPASS_MUTE_DISABLE);
-       if (ret)
-               return ret;
 
        return ret;
 }
index 0074b7f..0df9481 100644 (file)
@@ -788,7 +788,7 @@ static int lpass_platform_pcm_new(struct snd_soc_component *component,
 {
        struct snd_pcm *pcm = soc_runtime->pcm;
        struct snd_pcm_substream *psubstream, *csubstream;
-       int ret = -EINVAL;
+       int ret;
        size_t size = lpass_platform_pcm_hardware.buffer_bytes_max;
 
        psubstream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
index 4e1f101..b539af8 100644 (file)
@@ -261,7 +261,7 @@ static int q6tdm_set_tdm_slot(struct snd_soc_dai *dai,
                tdm->nslots_per_frame = slots;
                tdm->slot_width = slot_width;
                /* TDM RX dais ids are even and tx are odd */
-               tdm->slot_mask = (dai->id & 0x1 ? tx_mask : rx_mask) & cap_mask;
+               tdm->slot_mask = ((dai->id & 0x1) ? tx_mask : rx_mask) & cap_mask;
                break;
        default:
                dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
@@ -1315,7 +1315,7 @@ static struct snd_soc_dai_driver q6afe_dais[] = {
 };
 
 static int q6afe_of_xlate_dai_name(struct snd_soc_component *component,
-                                  struct of_phandle_args *args,
+                                  const struct of_phandle_args *args,
                                   const char **dai_name)
 {
        int id = args->args[0];
index cad1cd1..6f700c3 100644 (file)
@@ -845,7 +845,7 @@ static void q6afe_port_free(struct kref *ref)
 
 static struct q6afe_port *q6afe_find_port(struct q6afe *afe, int token)
 {
-       struct q6afe_port *p = NULL;
+       struct q6afe_port *p;
        struct q6afe_port *ret = NULL;
        unsigned long flags;
 
@@ -930,7 +930,7 @@ EXPORT_SYMBOL_GPL(q6afe_get_port_id);
 static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
                            struct q6afe_port *port, uint32_t rsp_opcode)
 {
-       wait_queue_head_t *wait = &port->wait;
+       wait_queue_head_t *wait;
        struct aprv2_ibasic_rsp_result_t *result;
        int ret;
 
@@ -1188,7 +1188,6 @@ int q6afe_port_stop(struct q6afe_port *port)
        int index, pkt_size;
        void *p;
 
-       port_id = port->id;
        index = port->token;
        if (index < 0 || index >= AFE_PORT_MAX) {
                dev_err(afe->dev, "AFE port index[%d] invalid!\n", index);
index 22e1026..41133f8 100644 (file)
@@ -233,7 +233,7 @@ void q6afe_cdc_dma_port_prepare(struct q6afe_port *port,
 int q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id,
                          int clk_src, int clk_root,
                          unsigned int freq, int dir);
-int q6afe_set_lpass_clock(struct device *dev, int clk_id, int clk_src,
+int q6afe_set_lpass_clock(struct device *dev, int clk_id, int attri,
                          int clk_root, unsigned int freq);
 int q6afe_vote_lpass_core_hw(struct device *dev, uint32_t hw_block_id,
                             char *client_name, uint32_t *client_handle);
index 82e584a..394604c 100644 (file)
@@ -97,7 +97,7 @@ struct audio_client *q6asm_audio_client_alloc(struct device *dev,
                                              int session_id, int perf_mode);
 void q6asm_audio_client_free(struct audio_client *ac);
 int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len,
-                     uint32_t msw_ts, uint32_t lsw_ts, uint32_t flags);
+                     uint32_t msw_ts, uint32_t lsw_ts, uint32_t wflags);
 int q6asm_open_write(struct audio_client *ac, uint32_t stream_id,
                     uint32_t format, u32 codec_profile,
                     uint16_t bits_per_sample, bool is_gapless);
@@ -143,10 +143,10 @@ int q6asm_stream_remove_trailing_silence(struct audio_client *ac,
                                         uint32_t trailing_samples);
 int q6asm_cmd(struct audio_client *ac, uint32_t stream_id,  int cmd);
 int q6asm_cmd_nowait(struct audio_client *ac, uint32_t stream_id,  int cmd);
-int q6asm_get_session_id(struct audio_client *ac);
+int q6asm_get_session_id(struct audio_client *c);
 int q6asm_map_memory_regions(unsigned int dir,
                             struct audio_client *ac,
                             phys_addr_t phys,
-                            size_t bufsz, unsigned int bufcnt);
+                            size_t period_sz, unsigned int periods);
 int q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac);
 #endif /* __Q6_ASM_H__ */
index b043183..c632842 100644 (file)
@@ -1156,11 +1156,10 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv,
        static const char *stream_names[] = { "Primary Playback",
                                              "Secondary Playback" };
        struct snd_soc_dai_driver *dai_drv;
-       struct i2s_dai *dai;
        int i;
 
        priv->dai = devm_kcalloc(&priv->pdev->dev, num_dais,
-                                    sizeof(*dai), GFP_KERNEL);
+                                    sizeof(struct i2s_dai), GFP_KERNEL);
        if (!priv->dai)
                return -ENOMEM;
 
index 3cddd11..81a29d1 100644 (file)
@@ -190,6 +190,11 @@ static int simtec_hw_params(struct snd_pcm_substream *substream,
 
                ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
                                             cdclk_scale);
+               if (ret) {
+                       pr_err("%s: failed to set clock div\n",
+                              __func__);
+                       return ret;
+               }
        }
 
        return 0;
index 681b244..39a7a44 100644 (file)
@@ -164,6 +164,7 @@ static int smdk_audio_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev,
                           "Property 'samsung,i2s-controller' missing or invalid\n");
                        ret = -EINVAL;
+                       return ret;
                }
 
                smdk_dai[0].platforms->name = NULL;
index 989af62..6da674e 100644 (file)
@@ -109,10 +109,7 @@ static int snow_late_probe(struct snd_soc_card *card)
        rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
 
        /* In the multi-codec case codec_dais 0 is MAX98095 and 1 is HDMI. */
-       if (rtd->num_codecs > 1)
-               codec_dai = asoc_rtd_to_codec(rtd, 0);
-       else
-               codec_dai = asoc_rtd_to_codec(rtd, 0);
+       codec_dai = asoc_rtd_to_codec(rtd, 0);
 
        /* Set the MCLK rate for the codec */
        return snd_soc_dai_set_sysclk(codec_dai, 0,
index b70068d..121e48f 100644 (file)
@@ -177,7 +177,6 @@ static int camelot_hw_params(struct snd_soc_component *component,
        struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
        struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id];
        int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
-       int ret;
 
        if (recv) {
                cam->rx_period_size = params_period_bytes(hw_params);
index ee1f320..d1612d3 100644 (file)
@@ -216,7 +216,7 @@ int rsnd_mod_init(struct rsnd_priv *priv,
        mod->clk        = clk;
        mod->priv       = priv;
 
-       return ret;
+       return 0;
 }
 
 void rsnd_mod_quit(struct rsnd_mod *mod)
index 7647b3d..20eecd0 100644 (file)
@@ -207,6 +207,8 @@ static int rsnd_ctu_pcm_new(struct rsnd_mod *mod,
                               NULL,
                               &ctu->pass, RSND_MAX_CHANNELS,
                               0xC);
+       if (ret < 0)
+               return ret;
 
        /* ROW0 */
        ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV0",
index 6b51937..1255a85 100644 (file)
@@ -597,15 +597,15 @@ phys_addr_t rsnd_gen_get_phy_addr(struct rsnd_priv *priv, int reg_id);
  *     R-Car ADG
  */
 int rsnd_adg_clk_query(struct rsnd_priv *priv, unsigned int rate);
-int rsnd_adg_ssi_clk_stop(struct rsnd_mod *mod);
-int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate);
+int rsnd_adg_ssi_clk_stop(struct rsnd_mod *ssi_mod);
+int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *ssi_mod, unsigned int rate);
 int rsnd_adg_probe(struct rsnd_priv *priv);
 void rsnd_adg_remove(struct rsnd_priv *priv);
 int rsnd_adg_set_src_timesel_gen2(struct rsnd_mod *src_mod,
                                  struct rsnd_dai_stream *io,
                                  unsigned int in_rate,
                                  unsigned int out_rate);
-int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod,
+int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *cmd_mod,
                                 struct rsnd_dai_stream *io);
 #define rsnd_adg_clk_enable(priv)      rsnd_adg_clk_control(priv, 1)
 #define rsnd_adg_clk_disable(priv)     rsnd_adg_clk_control(priv, 0)
index 49aa81f..d071cec 100644 (file)
@@ -400,7 +400,6 @@ static void rsnd_ssi_config_init(struct rsnd_mod *mod,
         * see
         *      rsnd_ssiu_init_gen2()
         */
-       wsr = ssi->wsr;
        if (is_tdm || is_tdm_split) {
                wsr     |= WS_MODE;
                cr_own  |= CHNL_8;
index 4785886..0a8a3c3 100644 (file)
@@ -217,14 +217,10 @@ static void siu_io_work(struct work_struct *work)
        if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
                dma_addr_t buff;
                size_t count;
-               u8 *virt;
 
                buff = (dma_addr_t)PERIOD_OFFSET(rt->dma_addr,
                                                siu_stream->cur_period,
                                                siu_stream->period_bytes);
-               virt = PERIOD_OFFSET(rt->dma_area,
-                                    siu_stream->cur_period,
-                                    siu_stream->period_bytes);
                count = siu_stream->period_bytes;
 
                /* DMA transfer start */
@@ -363,7 +359,7 @@ static int siu_pcm_prepare(struct snd_soc_component *component,
        struct siu_info *info = siu_i2s_data;
        struct siu_port *port_info = siu_port_info(ss);
        struct device *dev = ss->pcm->card->dev;
-       struct snd_pcm_runtime  *rt = ss->runtime;
+       struct snd_pcm_runtime *rt;
        struct siu_stream *siu_stream;
        snd_pcm_sframes_t xfer_cnt;
 
index 159bf88..8415e9b 100644 (file)
@@ -370,7 +370,7 @@ int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
 }
 
 int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
-                                       struct of_phandle_args *args,
+                                       const struct of_phandle_args *args,
                                        const char **dai_name)
 {
        if (component->driver->of_xlate_dai_name)
index 0cffc95..16ba54e 100644 (file)
@@ -2998,7 +2998,7 @@ int snd_soc_get_dai_id(struct device_node *ep)
 }
 EXPORT_SYMBOL_GPL(snd_soc_get_dai_id);
 
-int snd_soc_get_dai_name(struct of_phandle_args *args,
+int snd_soc_get_dai_name(const struct of_phandle_args *args,
                                const char **dai_name)
 {
        struct snd_soc_component *pos;
index 10f4882..5852724 100644 (file)
@@ -407,7 +407,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
        int min = mc->min;
        unsigned int mask = (1U << (fls(min + max) - 1)) - 1;
        int err = 0;
-       unsigned int val, val_mask, val2 = 0;
+       unsigned int val, val_mask, val2;
 
        val_mask = mask << shift;
        val = (ucontrol->value.integer.value[0] + min) & mask;
index 14d85ca..ba8ffbf 100644 (file)
@@ -1526,23 +1526,40 @@ unwind:
        return err;
 }
 
-static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
-                                struct snd_soc_pcm_stream *stream)
+static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream)
 {
+       struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_pcm_hardware *hw = &runtime->hw;
+       struct snd_soc_dai *dai;
+       int stream = substream->stream;
+       int i;
+
+       soc_pcm_hw_init(hw);
+
+       for_each_rtd_cpu_dais(fe, i, dai) {
+               struct snd_soc_pcm_stream *cpu_stream;
+
+               /*
+                * Skip CPUs which don't support the current stream
+                * type. See soc_pcm_init_runtime_hw() for more details
+                */
+               if (!snd_soc_dai_stream_valid(dai, stream))
+                       continue;
+
+               cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream);
+
+               soc_pcm_hw_update_rate(hw, cpu_stream);
+               soc_pcm_hw_update_chan(hw, cpu_stream);
+               soc_pcm_hw_update_format(hw, cpu_stream);
+       }
 
-       soc_pcm_hw_update_rate(hw, stream);
-       soc_pcm_hw_update_chan(hw, stream);
-       if (runtime->hw.formats)
-               runtime->hw.formats &= stream->formats;
-       else
-               runtime->hw.formats = stream->formats;
 }
 
-static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream,
-                                     struct snd_pcm_runtime *runtime)
+static void dpcm_runtime_setup_be_format(struct snd_pcm_substream *substream)
 {
        struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_pcm_hardware *hw = &runtime->hw;
        struct snd_soc_dpcm *dpcm;
        struct snd_soc_dai *dai;
@@ -1576,10 +1593,10 @@ static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream,
        }
 }
 
-static void dpcm_runtime_merge_chan(struct snd_pcm_substream *substream,
-                                   struct snd_pcm_runtime *runtime)
+static void dpcm_runtime_setup_be_chan(struct snd_pcm_substream *substream)
 {
        struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_pcm_hardware *hw = &runtime->hw;
        struct snd_soc_dpcm *dpcm;
        int stream = substream->stream;
@@ -1624,10 +1641,10 @@ static void dpcm_runtime_merge_chan(struct snd_pcm_substream *substream,
        }
 }
 
-static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream,
-                                   struct snd_pcm_runtime *runtime)
+static void dpcm_runtime_setup_be_rate(struct snd_pcm_substream *substream)
 {
        struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_pcm_hardware *hw = &runtime->hw;
        struct snd_soc_dpcm *dpcm;
        int stream = substream->stream;
@@ -1661,34 +1678,6 @@ static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream,
        }
 }
 
-static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream)
-{
-       struct snd_pcm_runtime *runtime = substream->runtime;
-       struct snd_pcm_hardware *hw = &runtime->hw;
-       struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
-       struct snd_soc_dai *cpu_dai;
-       int i;
-
-       soc_pcm_hw_init(hw);
-
-       for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
-               /*
-                * Skip CPUs which don't support the current stream
-                * type. See soc_pcm_init_runtime_hw() for more details
-                */
-               if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream))
-                       continue;
-
-               dpcm_init_runtime_hw(runtime,
-                       snd_soc_dai_get_pcm_stream(cpu_dai,
-                                                  substream->stream));
-       }
-
-       dpcm_runtime_merge_format(substream, runtime);
-       dpcm_runtime_merge_chan(substream, runtime);
-       dpcm_runtime_merge_rate(substream, runtime);
-}
-
 static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
                               int stream)
 {
@@ -1718,7 +1707,6 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
                        snd_soc_dpcm_get_substream(be, stream);
                struct snd_soc_pcm_runtime *rtd;
                struct snd_soc_dai *dai;
-               int i;
 
                /* A backend may not have the requested substream */
                if (!be_substream)
@@ -1768,7 +1756,11 @@ static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)
 
        fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN;
 
-       dpcm_set_fe_runtime(fe_substream);
+       dpcm_runtime_setup_fe(fe_substream);
+
+       dpcm_runtime_setup_be_format(fe_substream);
+       dpcm_runtime_setup_be_chan(fe_substream);
+       dpcm_runtime_setup_be_rate(fe_substream);
 
        ret = dpcm_apply_symmetry(fe_substream, stream);
        if (ret < 0)
@@ -1908,6 +1900,8 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream)
        /* only hw_params backends that are either sinks or sources
         * to this frontend DAI */
        err = dpcm_be_dai_hw_free(fe, stream);
+       if (err < 0)
+               dev_err(fe->dev, "ASoC: hw_free BE failed %d\n", err);
 
        fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE;
        dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
@@ -2395,7 +2389,6 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
        /* Only start the BE if the FE is ready */
        if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE ||
                fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) {
-               ret = -EINVAL;
                dev_err(fe->dev, "ASoC: FE %s is not ready %d\n",
                        fe->dai_link->name, fe->dpcm[stream].state);
                ret = -EINVAL;
index 1b0cd33..73076d4 100644 (file)
@@ -1673,16 +1673,16 @@ static void set_dai_flags(struct snd_soc_dai_driver *dai_drv,
 {
        if (flag_mask & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_RATES)
                dai_drv->symmetric_rate =
-                       flags & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_RATES ? 1 : 0;
+                       (flags & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_RATES) ? 1 : 0;
 
        if (flag_mask & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS)
                dai_drv->symmetric_channels =
-                       flags & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS ?
+                       (flags & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS) ?
                        1 : 0;
 
        if (flag_mask & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS)
                dai_drv->symmetric_sample_bits =
-                       flags & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS ?
+                       (flags & SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS) ?
                        1 : 0;
 }
 
@@ -1765,22 +1765,22 @@ static void set_link_flags(struct snd_soc_dai_link *link,
 {
        if (flag_mask & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES)
                link->symmetric_rate =
-                       flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES ? 1 : 0;
+                       (flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES) ? 1 : 0;
 
        if (flag_mask & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS)
                link->symmetric_channels =
-                       flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS ?
+                       (flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS) ?
                        1 : 0;
 
        if (flag_mask & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS)
                link->symmetric_sample_bits =
-                       flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS ?
+                       (flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS) ?
                        1 : 0;
 
        if (flag_mask & SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP)
                link->ignore_suspend =
-               flags & SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP ?
-               1 : 0;
+                       (flags & SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP) ?
+                       1 : 0;
 }
 
 /* create the FE DAI link */
index c3b757c..6e24e1c 100644 (file)
@@ -678,7 +678,7 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume)
        if (ret < 0) {
                dev_err(sdev->dev,
                        "error: failed to start controller after resume\n");
-               return ret;
+               goto cleanup;
        }
 
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
@@ -704,6 +704,10 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume)
        hda_dsp_ctrl_ppcap_enable(sdev, true);
        hda_dsp_ctrl_ppcap_int_enable(sdev, true);
 
+cleanup:
+       /* display codec can powered off after controller init */
+       hda_codec_i915_display_power(sdev, false);
+
        return 0;
 }
 
index 78506c3..c57feae 100644 (file)
@@ -1079,8 +1079,6 @@ static int sun4i_i2s_dai_probe(struct snd_soc_dai *dai)
                                  &i2s->playback_dma_data,
                                  &i2s->capture_dma_data);
 
-       snd_soc_dai_set_drvdata(dai, i2s);
-
        return 0;
 }
 
index 25c40c2..cf98141 100644 (file)
@@ -256,17 +256,12 @@ static int uniphier_aio_startup(struct snd_pcm_substream *substream,
 {
        struct uniphier_aio *aio = uniphier_priv(dai);
        struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
-       int ret;
 
        sub->substream = substream;
        sub->pass_through = 0;
        sub->use_mmap = true;
 
-       ret = aio_init(sub);
-       if (ret)
-               return ret;
-
-       return 0;
+       return aio_init(sub);
 }
 
 static void uniphier_aio_shutdown(struct snd_pcm_substream *substream,