From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: Sergej Sawazki <ce3a@gmx.de>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
lgirdwood@gmail.com, lars@metafoo.de,
patches@opensource.wolfsonmicro.com
Subject: Re: [PATCH v2] ASoC: wm8741: Add differential mono mode support
Date: Mon, 11 May 2015 09:12:25 +0100 [thread overview]
Message-ID: <20150511081225.GC3480@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1430858791-11825-1-git-send-email-ce3a@gmx.de>
On Tue, May 05, 2015 at 10:46:31PM +0200, Sergej Sawazki wrote:
> The WM8741 DAC supports several differential output modes (stereo,
> stereo reversed, mono left, mono right). Add platform data and DT
> bindings to configure it.
>
> Signed-off-by: Sergej Sawazki <ce3a@gmx.de>
> ---
> Documentation/devicetree/bindings/sound/wm8741.txt | 11 +++
> sound/soc/codecs/wm8741.c | 108 ++++++++++++++++++---
> sound/soc/codecs/wm8741.h | 10 ++
> 3 files changed, 117 insertions(+), 12 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/sound/wm8741.txt b/Documentation/devicetree/bindings/sound/wm8741.txt
> index 74bda58..a133154 100644
> --- a/Documentation/devicetree/bindings/sound/wm8741.txt
> +++ b/Documentation/devicetree/bindings/sound/wm8741.txt
> @@ -10,9 +10,20 @@ Required properties:
> - reg : the I2C address of the device for I2C, the chip select
> number for SPI.
>
> +Optional properties:
> +
> + - diff-mode: Differential output mode configuration. Default value for field
> + DIFF in register R8 (MODE_CONTROL_2). If absent, the default is 0, shall be:
> + 0 = stereo
> + 1 = mono left
> + 2 = stereo reversed
> + 3 = mono right
> +
> Example:
>
> codec: wm8741@1a {
> compatible = "wlf,wm8741";
> reg = <0x1a>;
> +
> + diff-mode = <3>;
> };
> diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c
> index 9e71c76..cbf90ab 100644
> --- a/sound/soc/codecs/wm8741.c
> +++ b/sound/soc/codecs/wm8741.c
> @@ -41,6 +41,7 @@ static const char *wm8741_supply_names[WM8741_NUM_SUPPLIES] = {
>
> /* codec private data */
> struct wm8741_priv {
> + struct wm8741_platform_data pdata;
> struct regmap *regmap;
> struct regulator_bulk_data supplies[WM8741_NUM_SUPPLIES];
> unsigned int sysclk;
> @@ -398,7 +399,7 @@ static struct snd_soc_dai_driver wm8741_dai = {
> .name = "wm8741",
> .playback = {
> .stream_name = "Playback",
> - .channels_min = 2, /* Mono modes not yet supported */
> + .channels_min = 2,
> .channels_max = 2,
> .rates = WM8741_RATES,
> .formats = WM8741_FORMATS,
> @@ -416,6 +417,60 @@ static int wm8741_resume(struct snd_soc_codec *codec)
> #define wm8741_resume NULL
> #endif
>
> +static int wm8741_configure(struct snd_soc_codec *codec)
> +{
> + struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
> +
> + /* Configure differential mode */
> + switch (wm8741->pdata.diff_mode) {
> + case WM8741_DIFF_MODE_STEREO:
> + case WM8741_DIFF_MODE_STEREO_REVERSED:
> + case WM8741_DIFF_MODE_MONO_LEFT:
> + case WM8741_DIFF_MODE_MONO_RIGHT:
> + snd_soc_update_bits(codec, WM8741_MODE_CONTROL_2,
> + WM8741_DIFF_MASK,
> + wm8741->pdata.diff_mode << WM8741_DIFF_SHIFT);
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + /* Change some default settings - latch VU */
> + snd_soc_update_bits(codec, WM8741_DACLLSB_ATTENUATION,
> + WM8741_UPDATELL, WM8741_UPDATELL);
> + snd_soc_update_bits(codec, WM8741_DACLMSB_ATTENUATION,
> + WM8741_UPDATELM, WM8741_UPDATELM);
> + snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION,
> + WM8741_UPDATERL, WM8741_UPDATERL);
> + snd_soc_update_bits(codec, WM8741_DACRMSB_ATTENUATION,
> + WM8741_UPDATERM, WM8741_UPDATERM);
> +
> + return 0;
> +}
> +
> +static int wm8741_add_controls(struct snd_soc_codec *codec)
> +{
> + struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec);
> +
> + switch (wm8741->pdata.diff_mode) {
> + case WM8741_DIFF_MODE_STEREO:
> + case WM8741_DIFF_MODE_STEREO_REVERSED:
> + snd_soc_add_codec_controls(codec, wm8741_snd_controls,
> + ARRAY_SIZE(wm8741_snd_controls));
> + break;
> + case WM8741_DIFF_MODE_MONO_LEFT:
> + case WM8741_DIFF_MODE_MONO_RIGHT:
> + /* The machine driver is responsible for mixer controls
> + * if the codec is configured in differential mono mode.
> + */
Would it not be better to add controls but with a channel neutral
name and then the machine driver can use the name_prefix stuff to
stick left and right onto them? Seems a bit odd for the machine
driver to have to know exact register details of the CODEC and
manually add the volume controls?
Thanks,
Charles
next prev parent reply other threads:[~2015-05-11 8:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 20:46 [PATCH v2] ASoC: wm8741: Add differential mono mode support Sergej Sawazki
2015-05-10 10:23 ` Sergej Sawazki
2015-05-11 17:21 ` Mark Brown
2015-05-11 20:27 ` Sergej Sawazki
2015-05-11 8:12 ` Charles Keepax [this message]
2015-05-11 9:12 ` Sergej Sawazki
2015-05-11 11:50 ` Charles Keepax
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150511081225.GC3480@opensource.wolfsonmicro.com \
--to=ckeepax@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ce3a@gmx.de \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=patches@opensource.wolfsonmicro.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox