Commit graph

996517 commits

Author SHA1 Message Date
Mark Brown
e49bcf4f55
Merge series "Add audio driver base on rpmsg on i.MX platform" from Shengjiu Wang <shengjiu.wang@nxp.com>:
On Asymmetric multiprocessor, there is Cortex-A core and Cortex-M core,
Linux is running on A core, RTOS is running on M core.
The audio hardware device can be controlled by Cortex-M device,
So audio playback/capture can be handled by M core.

Rpmsg is the interface for sending and receiving msg to and from M
core, that we can create a virtual sound on Cortex-A core side.

A core will tell the Cortex-M core sound format/rate/channel,
where is the data buffer, what is the period size, when to start,
when to stop and when suspend or resume happen, each of this behavior
there is defined rpmsg command.

Especially we designed the low power audio case, that is to
allocate a large buffer and fill the data, then Cortex-A core can go
to sleep mode, Cortex-M core continue to play the sound, when the
buffer is consumed, Cortex-M core will trigger the Cortex-A core to
wakeup to fill data.

changes in v5:
- remove unneeded property in binding doc and driver
- update binding doc according to Rob's comments.
- Fix link issue reported by kernel test robot

changes in v4:
- remove the sound card node, merge the property to cpu dai node
  according to Rob's comments.
- sound card device will be registered by cpu dai driver.
- Fix do_div issue reported by kernel test robot

changes in v3:
- add local refcount for clk enablement in hw_params()
- update the document according Rob's comments

changes in v2:
- update codes and comments according to Mark's comments

Shengjiu Wang (6):
  ASoC: soc-component: Add snd_soc_pcm_component_ack
  ASoC: fsl_rpmsg: Add CPU DAI driver for audio base on rpmsg
  ASoC: dt-bindings: fsl_rpmsg: Add binding doc for rpmsg audio device
  ASoC: imx-audio-rpmsg: Add rpmsg_driver for audio channel
  ASoC: imx-pcm-rpmsg: Add platform driver for audio base on rpmsg
  ASoC: imx-rpmsg: Add machine driver for audio base on rpmsg

 .../devicetree/bindings/sound/fsl,rpmsg.yaml  | 108 +++
 include/sound/soc-component.h                 |   3 +
 sound/soc/fsl/Kconfig                         |  30 +
 sound/soc/fsl/Makefile                        |   6 +
 sound/soc/fsl/fsl_rpmsg.c                     | 279 ++++++
 sound/soc/fsl/fsl_rpmsg.h                     |  35 +
 sound/soc/fsl/imx-audio-rpmsg.c               | 140 +++
 sound/soc/fsl/imx-pcm-rpmsg.c                 | 918 ++++++++++++++++++
 sound/soc/fsl/imx-pcm-rpmsg.h                 | 512 ++++++++++
 sound/soc/fsl/imx-rpmsg.c                     | 150 +++
 sound/soc/soc-component.c                     |  14 +
 sound/soc/soc-pcm.c                           |   2 +
 12 files changed, 2197 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
 create mode 100644 sound/soc/fsl/fsl_rpmsg.c
 create mode 100644 sound/soc/fsl/fsl_rpmsg.h
 create mode 100644 sound/soc/fsl/imx-audio-rpmsg.c
 create mode 100644 sound/soc/fsl/imx-pcm-rpmsg.c
 create mode 100644 sound/soc/fsl/imx-pcm-rpmsg.h
 create mode 100644 sound/soc/fsl/imx-rpmsg.c

--
2.27.0
2021-03-25 17:32:00 +00:00
Mark Brown
b9af3fb775
Merge series "ASoC: soc.h: small cleanups" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:
Hi Mark

These are small cleanups for soc.h

Kuninori Morimoto (3):
  ASoC: soc.h: add asoc_link_to_cpu/codec/platform() macro
  ASoC: soc.h: fixup return timing for snd_soc_fixup_dai_links_platform_name()
  ASoC: soc.h: return error if multi platform at snd_soc_fixup_dai_links_platform_name()

 include/sound/soc.h | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

--
2.25.1

Thank you for your help !!

Best regards
---
Kuninori Morimoto
2021-03-25 17:31:59 +00:00
Shengjiu Wang
99067c07e8
ASoC: wm8960: Remove bitclk relax condition in wm8960_configure_sysclk
The call sequence in wm8960_configure_clocking is

   ret = wm8960_configure_sysclk();
   if (ret >= 0)
        goto configure_clock;

   ....

   ret = wm8960_configure_pll();

configure_clock:
   ...

wm8960_configure_sysclk is called before wm8960_configure_pll, as
there is bitclk relax on both functions, so wm8960_configure_sysclk
always return success, then wm8960_configure_pll() never be called.

With this case:
aplay -Dhw:0,0 -d 5 -r 48000 -f S24_LE -c 2 audio48k24b2c.wav
the required bitclk is 48000 * 24 * 2 = 2304000, bitclk got from
wm8960_configure_sysclk is 3072000, but if go to wm8960_configure_pll.
it can get correct bitclk 2304000.

So bitclk relax condition should be removed in wm8960_configure_sysclk,
then wm8960_configure_pll can be called, and there is also bitclk relax
function in wm8960_configure_pll.

Fixes: 3c01b9ee2a ("ASoC: codec: wm8960: Relax bit clock computation")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/1614740862-30196-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:59:00 +00:00
Shengjiu Wang
df8077c6fe
ASoC: bindings: fsl-asoc-card: add compatible string for WM8958 codec
The WM8958 codec is used on i.MX7D val board.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1615986303-27959-2-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:59 +00:00
Shengjiu Wang
efd0b16608
ASoC: fsl-asoc-card: Add support for WM8958 codec
WM8958 codec is used on some i.MX based platform.
So add it support in this generic driver.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1615986303-27959-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:58 +00:00
Ryan Lee
7a0d884986
ASoC: max98373: Added controls for autorestart config
3 new controls are added.
"OVC Autorestart Switch" : controls whether or not the speaker amplifier
automatically re-enables after an overcurrent fault condition.
"THERM Autorestart Switch" : controls whether or not the device
automatically resumes playback when the die temperature recovers from
thermal shutdown.
"CMON Autorestart Switch" : controls whether or not the device
automatically resumes playback when the clock returns after stopping.

Above Auto Restart functions are enabled by default.

Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
Link: https://lore.kernel.org/r/20210325033555.29377-3-ryans.lee@maximintegrated.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:57 +00:00
Jack Yu
9f44673b7a
ASoC: rt1015: Add bclk detection and dc detection
Add bclk detection and dc detection before playback.

Signed-off-by: Jack Yu <jack.yu@realtek.com>
Link: https://lore.kernel.org/r/20210322055053.31797-1-jack.yu@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:56 +00:00
Tian Tao
200d925e23
spi: imx: Use of_device_get_match_data() helper
Use the of_device_get_match_data() helper instead of open coding.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1616385476-53327-1-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:55 +00:00
Kuninori Morimoto
d908b922c7
ASoC: soc.h: return error if multi platform at snd_soc_fixup_dai_links_platform_name()
snd_soc_fixup_dai_links_platform_name() is assuming it is single platform.
return error if multi platforms.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/871rc7aoo9.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:54 +00:00
Kuninori Morimoto
4a50724eb0
ASoC: soc.h: fixup return timing for snd_soc_fixup_dai_links_platform_name()
Current snd_soc_fixup_dai_links_platform_name() creates name first (A),
and checks setup target pointer (B), and set it (C).
We should check target pointer first IMO.
This patch exchange the order to (B) -> (A) -> (C).

	int snd_soc_fixup_dai_links_platform_name(...)
	{
		...
		/* set platform name for each dailink */
		for_each_card_prelinks(card, i, dai_link) {
(A)			name = devm_kstrdup(...);
			if (!name)
				return -ENOMEM;

(B)			if (!dai_link->platforms)
				return -EINVAL;

			/* only single platform is supported for now */
(C)			dai_link->platforms->name = name;
		}

		return 0;
	}

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/8735wnaoon.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:53 +00:00
Kuninori Morimoto
4da40cb995
ASoC: soc.h: add asoc_link_to_cpu/codec/platform() macro
We shouldn't use dai_link->cpus/codecs/platforms directly,
because these are array now to supporting multi CPU/Codec/Platform.
This patch adds asoc_link_to_xxx() macro for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874kh3aopc.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:52 +00:00
Shengjiu Wang
39f8405c3e
ASoC: imx-rpmsg: Add machine driver for audio base on rpmsg
The platform device is not registered by device tree or
cpu dai driver, it is registered by the rpmsg channel,
So add a dedicated machine driver to handle this case.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1615516725-4975-7-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:11 +00:00
Shengjiu Wang
3c00eceb2a
ASoC: imx-pcm-rpmsg: Add platform driver for audio base on rpmsg
Platform driver based on rpmsg is the interface for sending and
receiving rpmsg to and from M core. It will tell the Cortex-M core
sound format/rate/channel, where is the data buffer, where is
the period size, when to start, when to stop and when suspend
or resume happen, each this behavior there is defined rpmsg
command.

Especially we designed the low power audio case, that is to
allocate a large buffer and fill the data, then Cortex-A core can go
to sleep mode, Cortex-M core continue to play the sound, when the
buffer is consumed, Cortex-M core will trigger the Cortex-A core to
wake up.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1615516725-4975-6-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:10 +00:00
Shengjiu Wang
1935050de0
ASoC: imx-audio-rpmsg: Add rpmsg_driver for audio channel
This driver is used to accept the message from rpmsg audio
channel, and if this driver is probed, it will help to register
the platform driver, the platform driver will use this
audio channel to send and receive messages to and from Cortex-M
core.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1615516725-4975-5-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:09 +00:00
Shengjiu Wang
49c6bf6249
ASoC: dt-bindings: fsl_rpmsg: Add binding doc for rpmsg audio device
fsl_rpmsg is a virtual audio device. Mapping to real hardware
devices are SAI, DMA controlled by Cortex M core. What we see from
Linux side is a device which provides audio service by rpmsg channel.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1615516725-4975-4-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:08 +00:00
Shengjiu Wang
b73d9e6225
ASoC: fsl_rpmsg: Add CPU DAI driver for audio base on rpmsg
This is a cpu dai driver for rpmsg audio use case,
which is mainly used for getting the user's configuration
from devicetree and configure the clocks which is used by
Cortex-M core.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1615516725-4975-3-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:07 +00:00
Shengjiu Wang
8bdfc0455e
ASoC: soc-component: Add snd_soc_pcm_component_ack
Add snd_soc_pcm_component_ack back, which can be used to get an
updated buffer pointer in the platform driver.
On Asymmetric multiprocessor, this pointer can be sent to Cortex-M
core for audio processing.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1615516725-4975-2-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25 13:58:06 +00:00
Mark Brown
3f994c2586
Merge series "MFD/extcon/ASoC: Rework arizona codec jack-detect support" from Hans de Goede <hdegoede@redhat.com>:
Hi All,

Here is v4 of my series to rework the arizona codec jack-detect support
to use the snd_soc_jack helpers instead of direct extcon reporting.

As discussed before here is a resend rebased on 5.12-rc2, making sure that
all patches this depends on are in place.

Lee, can you pick-up patches 1-6 through the MFD tree and then send a
pull-req to Mark so that Mark can merge the Asoc parts throught the ASoC
tree ?

Patches 2-6 touch drivers/extcon, these all have an Ack from Chanwoo Choi
for merging these through the MFD tree.

Here is some more generic info on this series from the previous
cover-letter:

This is done by reworking the extcon driver into an arizona-jackdet
library and then modifying the codec drivers to use that directly,
replacing the old separate extcon child-devices and extcon-driver.

This brings the arizona-codec jack-detect handling inline with how
all other ASoC codec driver do this. This was developed and tested on
a Lenovo Yoga Tablet 1051L with a WM5102 codec.

This was also tested by Charles Keepax, one of the Cirrus Codec folks.

Regards,

Hans

Hans de Goede (13):
  mfd: arizona: Drop arizona-extcon cells
  extcon: arizona: Fix some issues when HPDET IRQ fires after the jack
    has been unplugged
  extcon: arizona: Fix various races on driver unbind
  extcon: arizona: Fix flags parameter to the gpiod_get("wlf,micd-pol")
    call
  extcon: arizona: Always use pm_runtime_get_sync() when we need the
    device to be awake
  ASoC/extcon: arizona: Move arizona jack code to
    sound/soc/codecs/arizona-jack.c
  ASoC: arizona-jack: Move jack-detect variables to struct arizona_priv
  ASoC: arizona-jack: Use arizona->dev for runtime-pm
  ASoC: arizona-jack: convert into a helper library for codec drivers
  ASoC: arizona-jack: Use snd_soc_jack to report jack events
  ASoC: arizona-jack: Cleanup logging
  ASoC: arizona: Make the wm5102, wm5110, wm8997 and wm8998 drivers use
    the new jack library
  ASoC: Intel: bytcr_wm5102: Add jack detect support

 MAINTAINERS                                   |   3 +-
 drivers/extcon/Kconfig                        |   8 -
 drivers/extcon/Makefile                       |   1 -
 drivers/mfd/arizona-core.c                    |  20 -
 sound/soc/codecs/Makefile                     |   2 +-
 .../soc/codecs/arizona-jack.c                 | 577 +++++++-----------
 sound/soc/codecs/arizona.h                    |  44 ++
 sound/soc/codecs/wm5102.c                     |  12 +-
 sound/soc/codecs/wm5110.c                     |  12 +-
 sound/soc/codecs/wm8997.c                     |  14 +-
 sound/soc/codecs/wm8998.c                     |   9 +
 sound/soc/intel/boards/bytcr_wm5102.c         |  28 +-
 12 files changed, 325 insertions(+), 405 deletions(-)
 rename drivers/extcon/extcon-arizona.c => sound/soc/codecs/arizona-jack.c (76%)

--
2.30.1
2021-03-24 23:29:33 +00:00
Hans de Goede
ecd77d494e
ASoC: Intel: bytcr_wm5102: Add jack detect support
Add jack detect support by creating a jack and calling
snd_soc_component_set_jack to register the created jack
with the codec.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210307151807.35201-14-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:50:20 +00:00
Hans de Goede
37dbabf14f
ASoC: arizona: Make the wm5102, wm5110, wm8997 and wm8998 drivers use the new jack library
Make all arizona codec drivers for which drivers/mfd/arizona-core.c used
to instantiate a "arizona-extcon" child-device use the new arizona-jack.c
library for jack-detection.

This has been tested on a Lenovo Yoga Tablet 2 1051L with a WM5102 codec.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210307151807.35201-13-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:50:19 +00:00
Hans de Goede
69c58eb61e
ASoC: arizona-jack: Cleanup logging
Cleanup the use of dev_foo functions used for logging:

1. Many of these are unnecessarily split over multiple lines
2. Use dev_err_probe() in cases where we might get a -EPROBE_DEFER
   return value

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210307151807.35201-12-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:50:18 +00:00
Hans de Goede
236b7285e9
ASoC: arizona-jack: Use snd_soc_jack to report jack events
Use the snd_soc_jack code to report jack events, instead of using extcon
for reporting the cable-type + an input_dev for reporting the button
presses.

The snd_soc_jack code will report the cable-type through both input_dev
events and through ALSA controls and the button-presses through input_dev
events.

Note that this means that when the codec drivers are moved over to use
the new arizona-jack.c library code instead of having a separate MFD
extcon cell with the extcon-arizona.c driver, we will no longer report
extcon events to userspace for cable-type changes. This should not be
a problem since "standard" Linux distro userspace does not (and has
never) used the extcon class interface for this. Android does have
support for the extcon class interface, but that was introduced in
the same release as support for input_dev cable-type events, so this
should not be a problem for Android either.

Note this also reduces ARIZONA_MAX_MICD_RANGE from 8 to 6, this is
ok to do since this info is always provided through pdata (or defaults)
and cannot be overridden from devicetree. All in-kernel users of the
pdata (and the fallback defaults) define 6 or less buttons/ranges.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210307151807.35201-11-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:50:17 +00:00
Hans de Goede
ffcc84b9e8
ASoC: arizona-jack: convert into a helper library for codec drivers
Convert the arizona extcon driver into a helper library for direct use
from the arizona codec-drivers, rather then being bound to a separate
MFD cell.

Note the probe (and remove) sequence is split into 2 parts:

1. The arizona_jack_codec_dev_probe() function inits a bunch of
jack-detect specific variables in struct arizona_priv and tries to get
a number of resources where getting them may fail with -EPROBE_DEFER.

2. Then once the machine driver has create a snd_sock_jack through
snd_soc_card_jack_new() it calls snd_soc_component_set_jack() on
the codec component, which will call the new arizona_jack_set_jack(),
which sets up jack-detection and requests the IRQs.

This split is necessary, because the IRQ handlers need access to the
arizona->dapm pointer and the snd_sock_jack which are not available
when the codec-driver's probe function runs.

Note this requires that machine-drivers for codecs which are converted
to use the new helper functions from arizona-jack.c are modified to
create a snd_soc_jack through snd_soc_card_jack_new() and register
this jack with the codec through snd_soc_component_set_jack().

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210307151807.35201-10-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:50:16 +00:00
Hans de Goede
688c8461a4
ASoC: arizona-jack: Use arizona->dev for runtime-pm
Drivers for MFD child-devices such as the arizona codec drivers
and the arizona-extcon driver can choose to either make
runtime_pm_get/_put calls on their own child-device, which will
then be propagated to their parent; or they can make them directly
on their MFD parent-device.

The arizona-extcon code was using runtime_pm_get/_put calls on
its own child-device where as the codec drivers are using
runtime_pm_get/_put calls on their parent.

The arizona-extcon MFD cell/child-device has been removed and this
commit is part of refactoring the arizona-extcon code into a library
to be used directly from the codec drivers.

Specifically this commit moves the code over to make
runtime_pm_get/_put calls on the parent device (on arizona->dev)
bringing the code inline with how the codec drivers do this.

Note this also removes the pm_runtime_enable/_disable calls
as pm_runtime support has already been enabled on the parent-device
by the arizona MFD driver.

This is part of a patch series converting the arizona extcon driver into
a helper library for letting the arizona codec-drivers directly report
jack state through the standard sound/soc/soc-jack.c functions.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210307151807.35201-9-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:50:15 +00:00
Hans de Goede
bcda8cc4b8
ASoC: arizona-jack: Move jack-detect variables to struct arizona_priv
Move all the jack-detect variables from struct arizona_extcon_info to
struct arizona_priv.

This is part of a patch series converting the arizona extcon driver into
a helper library for letting the arizona codec-drivers directly report jack
state through the standard sound/soc/soc-jack.c functions.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210307151807.35201-8-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:50:14 +00:00
Shengjiu Wang
b5cf28f7a8
ASoC: fsl_micfil: Don't use devm_regmap_init_mmio_clk
When there is power domain bind with ipg_clk clock,

The call flow:
devm_regmap_init_mmio_clk
   - clk_prepare()
      - clk_pm_runtime_get()

cause the power domain of clock always be enabled after
regmap_init(). which impact the power consumption.

So use devm_regmap_init_mmio instead of
devm_regmap_init_mmio_clk,but explicitly enable
clock when it is used.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
Link: https://lore.kernel.org/r/1616579928-22428-7-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:49:32 +00:00
Shengjiu Wang
3feaba79d8
ASoC: fsl_audmix: Don't use devm_regmap_init_mmio_clk
When there is power domain bind with ipg clock,

The call flow:
devm_regmap_init_mmio_clk
   - clk_prepare()
       - clk_pm_runtime_get()

cause the power domain of clock always be enabled after
regmap_init(). which impact the power consumption.

So use devm_regmap_init_mmio instead of
devm_regmap_init_mmio_clk,but explicitly enable
clock when it is used.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1616579928-22428-6-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:49:31 +00:00
Shengjiu Wang
069b24f22e
ASoC: fsl_easrc: Don't use devm_regmap_init_mmio_clk
When there is power domain bind with mem clock,

The call flow:
devm_regmap_init_mmio_clk
  - clk_prepare()
      - clk_pm_runtime_get()

cause the power domain of clock always be enabled after
regmap_init(). which impact the power consumption.

So use devm_regmap_init_mmio instead of
devm_regmap_init_mmio_clk,but explicitly enable
clock when it is used.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1616579928-22428-5-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:49:30 +00:00
Shengjiu Wang
cab04ab590
ASoC: fsl_asrc: Don't use devm_regmap_init_mmio_clk
When there is power domain bind with mem clock,

The call flow:
devm_regmap_init_mmio_clk
   - clk_prepare()
       - clk_pm_runtime_get()

cause the power domain of clock always be enabled after
regmap_init(). which impact the power consumption.

So use devm_regmap_init_mmio instead of
devm_regmap_init_mmio_clk,but explicitly enable
clock when it is used.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1616579928-22428-4-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:49:29 +00:00
Shengjiu Wang
c256257246
ASoC: fsl_spdif: Don't use devm_regmap_init_mmio_clk
When there is power domain bind with core clock,

The call flow:
devm_regmap_init_mmio_clk
   - clk_prepare()
       - clk_pm_runtime_get()

cause the power domain of clock always be enabled after
regmap_init(). which impact the power consumption.

So use devm_regmap_init_mmio instead of
devm_regmap_init_mmio_clk,but explicitly enable
clock when it is used.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1616579928-22428-3-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:49:28 +00:00
Shengjiu Wang
203773e393
ASoC: fsl_esai: Don't use devm_regmap_init_mmio_clk
When there is power domain bind with bus clock,

The call flow:
devm_regmap_init_mmio_clk
    - clk_prepare()
       - clk_pm_runtime_get()

cause the power domain of clock always be enabled after
regmap_init(). which impact the power consumption.

So use devm_regmap_init_mmio instead of
devm_regmap_init_mmio_clk,but explicitly enable
clock when it is used.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1616579928-22428-2-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-24 19:49:28 +00:00
Mark Brown
f89c0a87b4 Immutable branch between MFD and Extcon due for the v5.13 merge window
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmBTPZsACgkQUa+KL4f8
 d2Ew4g/8CZnru5gfuR2uMZIReS8Q4RniTKe3IoQNGE+nyZFp8heJm5sJ/tcHzHuX
 RcBbuY9hLhhZRvQ+WrveYiXYdC3tH/8j/5mHj6CLJDwh8ukEf9H/tcNAx1T0Y8by
 C3Y/lY7avAzfTorJQ2g+LRkbuei3mojTpUuEiwgdJEzydbg/GzYVv2edRvdCkW0Y
 6xCg8ufmWBTjrHHoXm4/wtGSJ2L17coieSRSIiQ4KsGf8xM6QAnUEXbwQV3KjlVS
 SbI0gucfjnYYdsYqrPy+yyA8gzA5utP/0Zis4pfDG1Av1dBm6ZfD5n/z+KYyJUoG
 C1GPkqxukZODBitwO6PdCoHpFTsbwfoqz6HD8o+6oFqScdBtU7C8SectMpis0G4/
 j3VrstGL6T0GgzuVmy5EnpPkqyiiJh3Smv5ZS91Rztiy4CTTvLlkrw5+h0GP9aR7
 uUfNmQU65KCG4WscnwuWeImcQzxRAlsiI0QxXFmHhIxZFG8Bq2z11V5rcpYdJXgx
 GbkOml6iq+G1UQu3sKYgLlE2Lg3IlehjytAbpY0Qoj9VE1FeE8STgYQMEwT5TqIB
 Em6T1fkpXp2kho92rmJ+rjcAJp7rKmlSQHO0xgbJwbzZsA5rKvClAn3PZmoZs7HY
 VHmeWjPihoo7qJTx7LVhWEtYptKG31JqCRPFTbVXjeCvClnjcFU=
 =3CZN
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmBaaBIACgkQJNaLcl1U
 h9CaNAgAgM5C0sZW05OQvat+2wpqN2RsTMVZJxdCQb68jU2PQNAj64Q20W17P/Uk
 BO4/Dpbi0RbnUCZ/qOG+teL8Hg+BIE2cA5hTHKfa7KMMGQ8WQfhgPsrWTwnpnkH8
 quBIBX3zRzG9VxiVqY4tbEwrQ87Os9by+OVQ3hb34MXeVRPZ4Z0t5hi3A9JKs9iK
 JGdLLgVZAtBFL8sGJt9eVeZeeDbF0PL0ooEA4elO9C4+ix+bfWKkXLo5tOEW7Onn
 MPvyB+axJ6nmI3+gJSn21Xwxf1OdW2DezHpFQxzbK2dxL/S56uE2UxX8jir3cKFc
 CkNs/e5fAJVNy//5VogQnTilwLqoyg==
 =GG2W
 -----END PGP SIGNATURE-----

Merge tag 'ib-mfd-extcon-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd into asoc-5.13

Immutable branch between MFD and Extcon due for the v5.13 merge window
2021-03-23 22:13:35 +00:00
Kai Vehmanen
dfb81e3b5f
ASoC: SOF: Intel: hda: drop display power on/off in D0i3 flows
Controller needs to ensure display power is enabled only for
HDA controller reset. Drop the display power-up/down calls from
D0i3 entry/exit paths.

This was previously not possible as codec drivers could not resume the
links, and instead controller kept the reference to display power. The
state of display power had be maintained in the D0i3 entry/exit code.
With commit 87fc20e4a0 ("ASoC: SOF: Intel: hda: use hdac_ext
fine-grained link management"), this is no longer needed and the code
can be cleaned up.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Keyon Jie <yang.jie@intel.com>
Link: https://lore.kernel.org/r/20210322143830.3880293-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-23 17:19:01 +00:00
Keyon Jie
bf939446c3
ASoC: intel: sof_rt5682: use the topology mclk
We should use the topology configured mclk if it existed, which can make
sure we are aligned with the FW side about the mclk usage.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@gmail.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210319124950.3853994-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-22 12:32:23 +00:00
Keyon Jie
b951b51e2c
ASoC: SOF: add a helper to get topology configured mclk
Add helper sof_dai_ssp_mclk to get the topology configured MCLK from a
pcm_runtime, return 0 if it is not available, and error if the dai type
is not SSP at the moment.

Export the helper for external use, e.g. from machine drivers.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@gmail.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210319124950.3853994-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-22 12:32:22 +00:00
Shengjiu Wang
2277e7e36b
ASoC: fsl_sai: Don't use devm_regmap_init_mmio_clk
When there is power domain bind with bus clock,

The call flow:
devm_regmap_init_mmio_clk
   - clk_prepare()
      - clk_pm_runtime_get()

cause the power domain of clock always be enabled after
regmap_init(). which impact the power consumption.

So use devm_regmap_init_mmio instead of
devm_regmap_init_mmio_clk, then explicitly enable clock when
using by pm_runtime_get(), if CONFIG_PM=n, then
fsl_sai_runtime_resume will be explicitly called.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Link: https://lore.kernel.org/r/1616141203-13344-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-22 12:32:21 +00:00
Vijendar Mukunda
7e71b48f9e
ASoC: amd: Add support for RT5682 codec in machine driver
Add support for RT5682 codec in machine driver.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://lore.kernel.org/r/1616118056-5506-1-git-send-email-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-22 12:32:20 +00:00
Mark Brown
3722e4ecef
Merge series "ASoC: tidyup error message timing" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:
Hi Mark

Indicating error message when failed case is very useful for debuging.
In many case, it uses below style.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

I know many people have many opinion, but if function() indicates error
message, we can get same and detail information without forgot, and it is better.
This patch-set tidyup to do it.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

Kuninori Morimoto (14):
  ASoC: soc-pcm: indicate error message at soc_pcm_open()
  ASoC: soc-pcm: indicate error message at soc_pcm_hw_params()
  ASoC: soc-pcm: indicate error message at soc_pcm_prepare()
  ASoC: soc-pcm: indicate error message at dpcm_path_get()
  ASoC: soc-pcm: indicate error message at dpcm_be_dai_trigger()
  ASoC: soc-pcm: indicate error message at dpcm_apply_symmetry()
  ASoC: soc-pcm: indicate error message at dpcm_run_update_startup/shutdown()
  ASoC: soc-pcm: indicate error message at dpcm_fe/be_dai_startup()
  ASoC: soc-pcm: indicate error message at dpcm_fe/be_dai_hw_params()
  ASoC: soc-pcm: indicate error message at dpcm_fe/be_dai_prepare()
  ASoC: soc-pcm: don't indicate error message for soc_pcm_hw_free()
  ASoC: soc-pcm: don't indicate error message for dpcm_be_dai_hw_free()
  ASoC: don't indicate error message for snd_soc_[pcm_]dai_xxx()
  ASoC: don't indicate error message for snd_soc_[pcm_]component_xxx()

 include/sound/soc-dpcm.h |   2 +-
 sound/soc/soc-compress.c |   9 +-
 sound/soc/soc-core.c     |  22 +----
 sound/soc/soc-dapm.c     |  24 ++---
 sound/soc/soc-pcm.c      | 197 +++++++++++++++++++--------------------
 5 files changed, 108 insertions(+), 146 deletions(-)

--
2.25.1
2021-03-19 16:31:39 +00:00
Wei Yongjun
e6d8af6687
ASoC: rt1019: make symbol 'rt1019_i2c_driver' static
The sparse tool complains as follows:

sound/soc/codecs/rt1019.c:927:19: warning:
 symbol 'rt1019_i2c_driver' was not declared. Should it be static?

This symbol is not used outside of rt1019.c, so this
commit marks it static.

Fixes: 7ec79d3850 ("ASoC: rt1019: add rt1019 amplifier driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Link: https://lore.kernel.org/r/20210319094102.4185096-1-weiyongjun1@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:24:07 +00:00
Kuninori Morimoto
60adbd8fbf
ASoC: don't indicate error message for snd_soc_[pcm_]component_xxx()
All snd_soc_component_xxx() and snd_soc_pcm_component_xxx() itself
indicate error message if failed.
Its caller doesn't need to indicate duplicated error message.
This patch removes it.

All snd_soc_component_xxx() indicate error message if failed.
Its caller doesn't need to indicate duplicated error message.
This patch removes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878s6puta6.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:24:05 +00:00
Kuninori Morimoto
62462e0182
ASoC: don't indicate error message for snd_soc_[pcm_]dai_xxx()
All snd_soc_dai_xxx() and snd_soc_pcm_dai_xxx() itself
indicate error message if failed.
Its caller doesn't need to indicate duplicated error message.
This patch removes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6r5utaa.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:24:04 +00:00
Kuninori Morimoto
f52366e683
ASoC: soc-pcm: don't indicate error message for dpcm_be_dai_hw_free()
dpcm_be_dai_hw_free() never fail, error message is not needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87blblutaf.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:24:03 +00:00
Kuninori Morimoto
e20c9c4f96
ASoC: soc-pcm: don't indicate error message for soc_pcm_hw_free()
soc_pcm_hw_free() never fail, error message is not needed.
We can't use void function for it, because it is used
part of struct snd_pcm_ops :: hw_free.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87czw1utaj.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:24:02 +00:00
Kuninori Morimoto
273db971cf
ASoC: soc-pcm: indicate error message at dpcm_fe/be_dai_prepare()
Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

This patch follow above style at dpcm_fe/be_dai_prepare()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87eeghutap.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:24:01 +00:00
Kuninori Morimoto
33b6b94f55
ASoC: soc-pcm: indicate error message at dpcm_fe/be_dai_hw_params()
Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

This patch follow above style at dpcm_fe/be_dai_hw_params()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ft0xutat.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:24:00 +00:00
Kuninori Morimoto
06aaeb8742
ASoC: soc-pcm: indicate error message at dpcm_fe/be_dai_startup()
Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

This patch follow above style at dpcm_fe/be_dai_startup().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ldutay.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:23:59 +00:00
Kuninori Morimoto
81c82a9edb
ASoC: soc-pcm: indicate error message at dpcm_run_update_startup/shutdown()
Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

This patch also
do below to dpcm_run_update_startup()
	1) remove duplicated ret = -EINVAL
	2) remove blank line
do below to dpcm_run_update_shutdown()
	1) remove unused ret

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87im5tutb3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:23:58 +00:00
Kuninori Morimoto
bbd2bac8d6
ASoC: soc-pcm: indicate error message at dpcm_apply_symmetry()
Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

This patch follow above style at dpcm_apply_symmetry(...)

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k0q9utb9.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:23:57 +00:00
Kuninori Morimoto
db3aa39c91
ASoC: soc-pcm: indicate error message at dpcm_be_dai_trigger()
Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

Now, dpcm_be_dai_trigger() user uses it like below.

	err = dpcm_be_dai_trigger(...);
	if (err < 0)
		dev_err(..., "ASoC: trigger FE failed %d\n", err);

But we can get more detail information if dpcm_be_dai_trigger() itself
had dev_err(). And above error message is confusable,
failed is *BE*, not *FE*.

This patch indicates error message at dpcm_be_dai_trigger().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87lfaputbe.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:23:56 +00:00
Kuninori Morimoto
d479f00b79
ASoC: soc-pcm: indicate error message at dpcm_path_get()
Indicating error message when failed case is very useful for debuging.
In many case, its style is like below.

	int function(...)
	{
		...
		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		if (ret < 0)
			dev_err(...)
		...
	}

This is not so bad, but in this style *each caller* needs to indicate
duplicate same error message, and some caller is forgetting to do it.
And caller can't indicate detail function() error information.

If function() indicates error message, we can get same and
detail information without forgot.

	int function(...)
	{
		...
		if (ret < 0)
			dev_err(...)

		return ret;
	}

	int caller(...)
	{
		...
		ret = function(...);
		...
	}

Now, many place uses dpcm_path_get() like below

	ret = dpcm_path_get(...);
	if (ret < 0)
		goto error;
(A)	else if (ret == 0)
		dev_dbg(...)

But here, (A) part can be indicated at dpcm_path_get() not caller.
It is simple and readable code.

This patch do it.
Small detail behaviors will be exchanged by this patch.

	1) indicates debug info (= path numbers) if path > 0 case only
	   (It was *always* indicated).
	2) soc_dpcm_fe_runtime_update() is indicating error message
	   for paths < 0 case, but it is already done at dpcm_path_get().
	   Thus just remove it. but dev_dbg() vs dev_warn() is exchanged.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87mtv5utbj.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19 12:23:55 +00:00