From a46eb523220e242affb9a6bc9bb8efc05f4f7459 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 3 May 2019 12:32:14 -0700 Subject: ASoC: RT5677-SPI: Disable 16Bit SPI Transfers The current algorithm allows 3 types of transfers, 16bit, 32bit and burst. According to Realtek, 16bit transfers have a special restriction in that it is restricted to the memory region of 0x18020000 ~ 0x18021000. This region is the memory location of the I2C registers. The current algorithm does not uphold this restriction and therefore fails to complete writes. Since this has been broken for some time it likely no one is using it. Better to simply disable the 16 bit writes. This will allow users to properly load firmware over SPI without data corruption. Signed-off-by: Curtis Malainey Reviewed-by: Ben Zhang Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/codecs/rt5677-spi.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c index 167a02773a0b..84b6bd8b50e1 100644 --- a/sound/soc/codecs/rt5677-spi.c +++ b/sound/soc/codecs/rt5677-spi.c @@ -58,13 +58,15 @@ static DEFINE_MUTEX(spi_mutex); * RT5677_SPI_READ/WRITE_32: Transfer 4 bytes * RT5677_SPI_READ/WRITE_BURST: Transfer any multiples of 8 bytes * - * For example, reading 260 bytes at 0x60030002 uses the following commands: - * 0x60030002 RT5677_SPI_READ_16 2 bytes + * Note: + * 16 Bit writes and reads are restricted to the address range + * 0x18020000 ~ 0x18021000 + * + * For example, reading 256 bytes at 0x60030004 uses the following commands: * 0x60030004 RT5677_SPI_READ_32 4 bytes * 0x60030008 RT5677_SPI_READ_BURST 240 bytes * 0x600300F8 RT5677_SPI_READ_BURST 8 bytes * 0x60030100 RT5677_SPI_READ_32 4 bytes - * 0x60030104 RT5677_SPI_READ_16 2 bytes * * Input: * @read: true for read commands; false for write commands @@ -79,15 +81,13 @@ static u8 rt5677_spi_select_cmd(bool read, u32 align, u32 remain, u32 *len) { u8 cmd; - if (align == 2 || align == 6 || remain == 2) { - cmd = RT5677_SPI_READ_16; - *len = 2; - } else if (align == 4 || remain <= 6) { + if (align == 4 || remain <= 4) { cmd = RT5677_SPI_READ_32; *len = 4; } else { cmd = RT5677_SPI_READ_BURST; - *len = min_t(u32, remain & ~7, RT5677_SPI_BURST_LEN); + *len = (((remain - 1) >> 3) + 1) << 3; + *len = min_t(u32, *len, RT5677_SPI_BURST_LEN); } return read ? cmd : cmd + 1; } @@ -108,7 +108,7 @@ static void rt5677_spi_reverse(u8 *dst, u32 dstlen, const u8 *src, u32 srclen) } } -/* Read DSP address space using SPI. addr and len have to be 2-byte aligned. */ +/* Read DSP address space using SPI. addr and len have to be 4-byte aligned. */ int rt5677_spi_read(u32 addr, void *rxbuf, size_t len) { u32 offset; @@ -124,7 +124,7 @@ int rt5677_spi_read(u32 addr, void *rxbuf, size_t len) if (!g_spi) return -ENODEV; - if ((addr & 1) || (len & 1)) { + if ((addr & 3) || (len & 3)) { dev_err(&g_spi->dev, "Bad read align 0x%x(%zu)\n", addr, len); return -EACCES; } @@ -159,13 +159,13 @@ int rt5677_spi_read(u32 addr, void *rxbuf, size_t len) } EXPORT_SYMBOL_GPL(rt5677_spi_read); -/* Write DSP address space using SPI. addr has to be 2-byte aligned. - * If len is not 2-byte aligned, an extra byte of zero is written at the end +/* Write DSP address space using SPI. addr has to be 4-byte aligned. + * If len is not 4-byte aligned, then extra zeros are written at the end * as padding. */ int rt5677_spi_write(u32 addr, const void *txbuf, size_t len) { - u32 offset, len_with_pad = len; + u32 offset; int status = 0; struct spi_transfer t; struct spi_message m; @@ -178,22 +178,19 @@ int rt5677_spi_write(u32 addr, const void *txbuf, size_t len) if (!g_spi) return -ENODEV; - if (addr & 1) { + if (addr & 3) { dev_err(&g_spi->dev, "Bad write align 0x%x(%zu)\n", addr, len); return -EACCES; } - if (len & 1) - len_with_pad = len + 1; - memset(&t, 0, sizeof(t)); t.tx_buf = buf; t.speed_hz = RT5677_SPI_FREQ; spi_message_init_with_transfers(&m, &t, 1); - for (offset = 0; offset < len_with_pad;) { + for (offset = 0; offset < len;) { spi_cmd = rt5677_spi_select_cmd(false, (addr + offset) & 7, - len_with_pad - offset, &t.len); + len - offset, &t.len); /* Construct SPI message header */ buf[0] = spi_cmd; -- cgit v1.2.3-59-g8ed1b From ecb2795c08bc825ebd604997e5be440b060c5b18 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Wed, 1 May 2019 15:29:38 +0100 Subject: ASoC: max98090: Fix restore of DAPM Muxes The max98090 driver defines 3 DAPM muxes; one for the right line output (LINMOD Mux), one for the left headphone mixer source (MIXHPLSEL Mux) and one for the right headphone mixer source (MIXHPRSEL Mux). The same bit is used for the mux as well as the DAPM enable, and although the mux can be correctly configured, after playback has completed, the mux will be reset during the disable phase. This is preventing the state of these muxes from being saved and restored correctly on system reboot. Fix this by marking these muxes as SND_SOC_NOPM. Note this has been verified this on the Tegra124 Nyan Big which features the MAX98090 codec. Signed-off-by: Jon Hunter Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/codecs/max98090.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 30c242c38d99..7619ea31ab50 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -1194,14 +1194,14 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { &max98090_right_rcv_mixer_controls[0], ARRAY_SIZE(max98090_right_rcv_mixer_controls)), - SND_SOC_DAPM_MUX("LINMOD Mux", M98090_REG_LOUTR_MIXER, - M98090_LINMOD_SHIFT, 0, &max98090_linmod_mux), + SND_SOC_DAPM_MUX("LINMOD Mux", SND_SOC_NOPM, 0, 0, + &max98090_linmod_mux), - SND_SOC_DAPM_MUX("MIXHPLSEL Mux", M98090_REG_HP_CONTROL, - M98090_MIXHPLSEL_SHIFT, 0, &max98090_mixhplsel_mux), + SND_SOC_DAPM_MUX("MIXHPLSEL Mux", SND_SOC_NOPM, 0, 0, + &max98090_mixhplsel_mux), - SND_SOC_DAPM_MUX("MIXHPRSEL Mux", M98090_REG_HP_CONTROL, - M98090_MIXHPRSEL_SHIFT, 0, &max98090_mixhprsel_mux), + SND_SOC_DAPM_MUX("MIXHPRSEL Mux", SND_SOC_NOPM, 0, 0, + &max98090_mixhprsel_mux), SND_SOC_DAPM_PGA("HP Left Out", M98090_REG_OUTPUT_ENABLE, M98090_HPLEN_SHIFT, 0, NULL, 0), -- cgit v1.2.3-59-g8ed1b From 863137f0bc5eb2a3a65d1d29778ac65642171b17 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Mon, 6 May 2019 14:44:04 +0200 Subject: ASoC: stm32: spdifrx: update pcm hardware constraints - Set period minimum size. Ensure at least 5ms period up to 48kHz/16 bits to prevent underrun/overrun. - Remove MDMA constraints on period maximum size and set period maximum to half the buffer maximum size. Signed-off-by: Olivier Moysan Signed-off-by: Mark Brown --- sound/soc/stm/stm32_spdifrx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index b4c3d983e195..aa83b50efabb 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -845,7 +845,8 @@ static struct snd_soc_dai_driver stm32_spdifrx_dai[] = { static const struct snd_pcm_hardware stm32_spdifrx_pcm_hw = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP, .buffer_bytes_max = 8 * PAGE_SIZE, - .period_bytes_max = 2048, /* MDMA constraint */ + .period_bytes_min = 1024, + .period_bytes_max = 4 * PAGE_SIZE, .periods_min = 2, .periods_max = 8, }; -- cgit v1.2.3-59-g8ed1b From 19e42536b27121bcf6ee841b25054f8bacafd8c7 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Mon, 6 May 2019 14:44:05 +0200 Subject: ASoC: stm32: spdifrx: change trace level on iec control Change trace level to debug to avoid spurious messages. Return quietly when accessing iec958 control, while no S/PDIF signal is available. Signed-off-by: Olivier Moysan Signed-off-by: Mark Brown --- sound/soc/stm/stm32_spdifrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index aa83b50efabb..3d64200edbb5 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -496,7 +496,7 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx) if (wait_for_completion_interruptible_timeout(&spdifrx->cs_completion, msecs_to_jiffies(100)) <= 0) { - dev_err(&spdifrx->pdev->dev, "Failed to get control data\n"); + dev_dbg(&spdifrx->pdev->dev, "Failed to get control data\n"); ret = -EAGAIN; } -- cgit v1.2.3-59-g8ed1b From 4c88519133bdd802fb0df4707b5a8c066af7154d Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 6 May 2019 12:01:40 -0700 Subject: ASoC: sound/soc/sof/: fix kconfig dependency warning Fix kconfig warning for unmet dependency for IOSF_MBI when PCI is not set/enabled. Fixes this warning: WARNING: unmet direct dependencies detected for IOSF_MBI Depends on [n]: PCI [=n] Selected by [y]: - SND_SOC_SOF_ACPI [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && SND_SOC_SOF_TOPLEVEL [=y] && (ACPI [=y] || COMPILE_TEST [=n]) && X86 [=y] Signed-off-by: Randy Dunlap Cc: Liam Girdwood Cc: Mark Brown Cc: alsa-devel@alsa-project.org Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/sof/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index a1a9ffe605dc..b204c65698f9 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -28,7 +28,7 @@ config SND_SOC_SOF_ACPI select SND_SOC_ACPI if ACPI select SND_SOC_SOF_OPTIONS select SND_SOC_SOF_INTEL_ACPI if SND_SOC_SOF_INTEL_TOPLEVEL - select IOSF_MBI if X86 + select IOSF_MBI if X86 && PCI help This adds support for ACPI enumeration. This option is required to enable Intel Haswell/Broadwell/Baytrail/Cherrytrail devices -- cgit v1.2.3-59-g8ed1b From ab0c433f32f86370152bc9cb4900e5fe9a11055c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 6 May 2019 17:02:22 +0200 Subject: ASoC: da7219: Fix a compile warning at CONFIG_COMMON_CLK=n MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A trivial fix for the randconfig build error: sound/soc/codecs/da7219.c:2366:6: warning: unused variable ‘i’ [-Wunused-variable] Fixes: d90ba6c8b53e ("ASoC: da7219: Expose BCLK and WCLK control through CCF") Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/codecs/da7219.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 206d01c6eb7e..43c03e7b2f0e 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -2357,7 +2357,9 @@ err_disable_reg: static void da7219_remove(struct snd_soc_component *component) { struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); +#ifdef CONFIG_COMMON_CLK int i; +#endif da7219_aad_exit(component); -- cgit v1.2.3-59-g8ed1b From c41d384c39f17ffb5326531da2374a1ab5859403 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 6 May 2019 17:02:23 +0200 Subject: ASoC: SOF: Fix a compile warning with CONFIG_PCI=n MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A trivial fix for the randconfig build error: sound/soc/sof/ops.c:20:6: warning: ‘ret’ is used uninitialized in this function [-Wuninitialized] Fixes: d1d95fcb63e3 ("ASoC: SOF: Add DSP HW abstraction operations") Signed-off-by: Takashi Iwai Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/sof/ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sof/ops.c b/sound/soc/sof/ops.c index 80f907740b82..7a27c3b719e7 100644 --- a/sound/soc/sof/ops.c +++ b/sound/soc/sof/ops.c @@ -17,7 +17,7 @@ bool snd_sof_pci_update_bits_unlocked(struct snd_sof_dev *sdev, u32 offset, { struct pci_dev *pci = to_pci_dev(sdev->dev); unsigned int old, new; - u32 ret; + u32 ret = 0; pci_read_config_dword(pci, offset, &ret); old = ret; -- cgit v1.2.3-59-g8ed1b From f153bf49ddf6169544b24ef5ea26fa3eb4996b95 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 6 May 2019 17:02:24 +0200 Subject: ASoC: rockchip: Fix an uninitialized variable compile warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Paper over a trivial case leading to an uninitialized variable compile warning: sound/soc/rockchip/rockchip_pdm.c:179:3: warning: ‘clk_out’ may be used uninitialized in this function [-Wmaybe-uninitialized] Fixes: 624e8e00acaf ("ASoC: rockchip: pdm: fixup pdm fractional div") Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/rockchip/rockchip_pdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rockchip_pdm.c b/sound/soc/rockchip/rockchip_pdm.c index 6c0f242db5ef..b9c1d8ad77c1 100644 --- a/sound/soc/rockchip/rockchip_pdm.c +++ b/sound/soc/rockchip/rockchip_pdm.c @@ -158,7 +158,7 @@ static int rockchip_pdm_hw_params(struct snd_pcm_substream *substream, struct rk_pdm_dev *pdm = to_info(dai); unsigned int val = 0; unsigned int clk_rate, clk_div, samplerate; - unsigned int clk_src, clk_out; + unsigned int clk_src, clk_out = 0; unsigned long m, n; bool change; int ret; -- cgit v1.2.3-59-g8ed1b From 54d198d5019dd98b9bcb9099a389608d7e2cccad Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 7 May 2019 21:39:10 +0200 Subject: ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly This fixes a compile warning below by properly handling the error code from sof_get_ctrl_copy_params(): include/linux/kernel.h:843:43: warning: 'sparams.pl_size' may be used uninitialized in this function [-Wmaybe-uninitialized] sound/soc/sof/ipc.c:639:34: note: 'sparams.pl_size' was declared here The function returns an error before setting sparams.pl_size, so it'd assign an uninitialized value at a later point. Fixes: 53e0c72d98ba ("ASoC: SOF: Add support for IPC IO between DSP and Host") Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/sof/ipc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index ba1bb17a8d1e..f0b9d3c53f6f 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -567,7 +567,7 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev, size_t offset = 0; size_t msg_bytes; size_t pl_size; - int err = 0; + int err; int i; /* allocate max ipc size because we have at least one */ @@ -576,9 +576,13 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev, return -ENOMEM; if (send) - sof_get_ctrl_copy_params(cdata->type, cdata, partdata, sparams); + err = sof_get_ctrl_copy_params(cdata->type, cdata, partdata, + sparams); else - sof_get_ctrl_copy_params(cdata->type, partdata, cdata, sparams); + err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata, + sparams); + if (err < 0) + return err; msg_bytes = sparams->msg_bytes; pl_size = sparams->pl_size; -- cgit v1.2.3-59-g8ed1b From 78989ff8aeaddc183237da558ee07deee35fbbbd Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 7 May 2019 11:32:35 -0500 Subject: ASoC: SOF: xtensa: fix undefined references The SND_SOC_INTEL_COMMON Kconfig was removed months ago from SOF Kconfig files but is still selected instead of the correct SND_SOC_SOF_INTEL_COMMON kconfig which does select xtensa stuff, leading to the following errors. ld: sound/soc/sof/sof-acpi-dev.o:(.rodata+0x120): undefined reference to `sof_xtensa_arch_ops' ld: sound/soc/sof/sof-acpi-dev.o:(.rodata+0x180): undefined reference to `sof_xtensa_arch_ops' ld: sound/soc/sof/sof-acpi-dev.o:(.rodata+0x1e0): undefined reference to `sof_xtensa_arch_ops' Reported-by: kbuild test robot Signed-off-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/sof/intel/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sof/intel/Kconfig b/sound/soc/sof/intel/Kconfig index 32ee0fabab92..603e0db4f012 100644 --- a/sound/soc/sof/intel/Kconfig +++ b/sound/soc/sof/intel/Kconfig @@ -36,7 +36,7 @@ config SND_SOC_SOF_INTEL_HIFI_EP_IPC config SND_SOC_SOF_INTEL_ATOM_HIFI_EP tristate - select SND_SOC_INTEL_COMMON + select SND_SOC_SOF_INTEL_COMMON select SND_SOC_SOF_INTEL_HIFI_EP_IPC help This option is not user-selectable but automagically handled by -- cgit v1.2.3-59-g8ed1b From ce38a75089f70f6380fc63a5478a7659b4eb3f47 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 7 May 2019 11:32:36 -0500 Subject: ASoC: SOF: core: fix undefined nocodec reference The existing code mistakenly uses IS_ENABLED in C code instead of as in conditional compilation, leading to the following error: ld: sound/soc/sof/core.o: in function `sof_machine_check': sound/soc/sof/core.c:279: undefined reference to `sof_nocodec_setup' Fix by using #if !IS_ENABLED() Reported-by: kbuild test robot Signed-off-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/sof/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 39cbd84ff9c8..5ddbfa8f1a28 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -265,11 +265,10 @@ static int sof_machine_check(struct snd_sof_dev *sdev) if (plat_data->machine) return 0; - if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) { - dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); - return -ENODEV; - } - +#if !IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC) + dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); + return -ENODEV; +#else /* fallback to nocodec mode */ dev_warn(sdev->dev, "No ASoC machine driver found - using nocodec\n"); machine = devm_kzalloc(sdev->dev, sizeof(*machine), GFP_KERNEL); @@ -284,6 +283,7 @@ static int sof_machine_check(struct snd_sof_dev *sdev) plat_data->machine = machine; return 0; +#endif } static int sof_probe_continue(struct snd_sof_dev *sdev) -- cgit v1.2.3-59-g8ed1b