mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/8] Add sun8i A33 audio driver
@ 2017-01-31 10:05 Mylène Josserand
  2017-01-31 10:05 ` [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to include A31 Mylène Josserand
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Mylène Josserand @ 2017-01-31 10:05 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, maxime.ripard, wens,
	perex, tiwai
  Cc: alsa-devel, devicetree, linux-kernel, linux-arm-kernel,
	thomas.petazzoni, mylene.josserand, alexandre.belloni

Hello everyone,

This a V3 of my Allwinner A33 (sun8i) audio codec driver.
Tested on linux-next-20170131 tag.

Changes since V2:
	- Removed patches from v2 already merged:
	commit ebad64d193779 ("ASoC: sun4i-i2s: Increase DMA max burst to 8")
	commit 603a0c8af9cb2 ("clk: sunxi-ng: a33: Add CLK_SET_RATE_PARENT to ac-dig")
	- Removed "reset-names" from sun4i-i2s driver
	- Fixed the build warning from sun8i-codec
	- Fixed some various topics such as subject line
	for dt bindings patch, renamed the simple-card
	and disabled the simple-card.

Changes since V1:
	- Remove the analog codec driver as a better version has been
	committed by Chen-Yu Tsai and is already merged.
	- Remove the audio-card as simple-card can be used
	- The DMA maxburst is set to 8 in the sun4i-i2s instead of
	adding the maxburst of 4 in Sun6i dma engine.
	- Create a new compatible for sun4i-i2s to handle the reset
	line.
	- Fix various problems in sun8i-codec driver according to V1's
	reviews
	- Add the pm_runtime hooks in sun8i-codec driver to prepare/
	unprepare clocks.
	- Update the DTS according to Chen-Yu's analog codec driver.
	- Rename sun8i-codec's clocks to "bus" and "mod"
	- The first "delay" issue from V1 is fixed by using a delay
	when enabling the headphone amplifier to let the amplifier
	being up.

Patches 1 and 2 add a new compatible "allwinner,sun6i-a31-i2s"
to handle the reset line for sun4i-i2s driver. It uses a quirk to
use a version with or without reset lines.

Patch 3 adds the sun8i codec driver which represents the digital part
of the A33 codec. It supports only playback features.

Path 4 fixes the previous issue of a "first time delay" in V1 (see cover
letter). Do not hesitate if you have comments on this patch.

Patches 5 adds the dt-bindings documentation for new audio driver
added in this serie (sun8i-codec).

Patch 6 adds the cpu DAI, codec and audio nodes to sun8i-a33 device tree.

Patches 7 and 8 enable the audio on Parrot and Sinlinx's boards.

The DAI for this A33 codec is the same than for A20: "sun4i-i2s".
Currently, the sun8i-a33 codec driver handles only the playback feature.
The other ones (such as capture) and all other interfaces except
headphone are not supported. I will send a patch to handle the
capture with microphones in next few weeks.

Examples of amixer commands:
	amixer set 'Headphone' 75%
	amixer set 'Headphone' on
	amixer set 'DAC' on
	amixer set 'Right DAC Mixer RSlot 0' on
	amixer set 'Left DAC Mixer LSlot 0' on

It was tested on Parrot and Sinlinx boards.

Let me know if you have any comments on this serie.

Thank you in advance,
Best regards,

Mylène Josserand (8):
  ASoC: sun4i-i2s: Update binding documentation to include A31
  ASoC: sun4i-i2s: Add quirks to handle a31 compatible
  ASoC: Add sun8i digital audio codec
  ASoC: sun8i-codec-analog: Add amplifier event to fix first delay
  ASoC: codecs: Add sun8i-a33 binding documentation
  ARM: dts: sun8i: Add audio codec, dai and card for A33
  ARM: dts: sun8i: parrot: Enable audio nodes
  ARM: dts: sun8i: sinlinx: Enable audio nodes

 .../devicetree/bindings/sound/sun4i-i2s.txt        |   5 +
 .../devicetree/bindings/sound/sun8i-a33-codec.txt  |  75 ++++
 arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts     |  12 +
 arch/arm/boot/dts/sun8i-a33.dtsi                   |  45 ++
 arch/arm/boot/dts/sun8i-r16-parrot.dts             |  12 +
 sound/soc/sunxi/Kconfig                            |  11 +
 sound/soc/sunxi/Makefile                           |   1 +
 sound/soc/sunxi/sun4i-i2s.c                        |  57 ++-
 sound/soc/sunxi/sun8i-codec-analog.c               |  30 +-
 sound/soc/sunxi/sun8i-codec.c                      | 499 +++++++++++++++++++++
 10 files changed, 743 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt
 create mode 100644 sound/soc/sunxi/sun8i-codec.c

-- 
2.11.0

^ permalink raw reply	[flat|nested] 26+ messages in thread
* [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731)
@ 2018-08-29 14:47 Codrin Ciubotariu
  2018-08-30 10:13 ` [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot
  0 siblings, 1 reply; 26+ messages in thread
From: Codrin Ciubotariu @ 2018-08-29 14:47 UTC (permalink / raw)
  To: alsa-devel, devicetree, broonie, robh+dt, alexandre.belloni,
	nicolas.ferre
  Cc: linux-kernel, linux-arm-kernel, florian.meier, cristian.birsan

Add support for the MikroElektronika PROTO audio codec board.

URL to the audio chip:
http://www.mikroe.com/add-on-boards/audio-voice/audio-codec-proto/

Signed-off-by: Florian Meier <florian.meier@koalo.de>
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---
 sound/soc/atmel/Kconfig        |   7 ++
 sound/soc/atmel/Makefile       |   2 +
 sound/soc/atmel/mikroe-proto.c | 189 +++++++++++++++++++++++++++++++++
 3 files changed, 198 insertions(+)
 create mode 100644 sound/soc/atmel/mikroe-proto.c

diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
index 539ef33e670a..fbf4d3e42c18 100644
--- a/sound/soc/atmel/Kconfig
+++ b/sound/soc/atmel/Kconfig
@@ -97,4 +97,11 @@ config SND_ATMEL_SOC_I2S
 	help
 	  Say Y or M if you want to add support for Atmel ASoc driver for boards
 	  using I2S.
+
+config SND_SOC_MIKROE_PROTO
+	tristate "Support for Mikroe-PROTO board"
+	depends on OF
+	select SND_SOC_WM8731
+	help
+	  Say Y or M if you want to add support for Audio Codec Board PROTO (WM8731).
 endif
diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile
index cd87cb4bcff5..9f41bfa0fea3 100644
--- a/sound/soc/atmel/Makefile
+++ b/sound/soc/atmel/Makefile
@@ -17,6 +17,7 @@ snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o
 snd-atmel-soc-classd-objs := atmel-classd.o
 snd-atmel-soc-pdmic-objs := atmel-pdmic.o
 snd-atmel-soc-tse850-pcm5142-objs := tse850-pcm5142.o
+snd-soc-mikroe-proto-objs := mikroe-proto.o
 
 obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
 obj-$(CONFIG_SND_ATMEL_SOC_WM8904) += snd-atmel-soc-wm8904.o
@@ -24,3 +25,4 @@ obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o
 obj-$(CONFIG_SND_ATMEL_SOC_CLASSD) += snd-atmel-soc-classd.o
 obj-$(CONFIG_SND_ATMEL_SOC_PDMIC) += snd-atmel-soc-pdmic.o
 obj-$(CONFIG_SND_ATMEL_SOC_TSE850_PCM5142) += snd-atmel-soc-tse850-pcm5142.o
+obj-$(CONFIG_SND_SOC_MIKROE_PROTO) += snd-soc-mikroe-proto.o
diff --git a/sound/soc/atmel/mikroe-proto.c b/sound/soc/atmel/mikroe-proto.c
new file mode 100644
index 000000000000..9d9dc1c8ac6b
--- /dev/null
+++ b/sound/soc/atmel/mikroe-proto.c
@@ -0,0 +1,189 @@
+/*
+ * ASoC driver for PROTO AudioCODEC (with a WM8731)
+ *
+ * Author:      Florian Meier, <koalo@koalo.de>
+ *	      Copyright 2013
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/jack.h>
+
+#include "../codecs/wm8731.h"
+
+#define XTAL_RATE 12288000	/* This is fixed on this board */
+
+static const unsigned int wm8731_rates_12288000[] = {
+	8000, 32000, 48000, 96000,
+};
+
+static struct snd_pcm_hw_constraint_list wm8731_constraints_12288000 = {
+	.list = wm8731_rates_12288000,
+	.count = ARRAY_SIZE(wm8731_rates_12288000),
+};
+
+static int snd_proto_startup(struct snd_pcm_substream *substream)
+{
+	/* Setup constraints, because there is a 12.288 MHz XTAL on the board */
+	snd_pcm_hw_constraint_list(substream->runtime, 0,
+				   SNDRV_PCM_HW_PARAM_RATE,
+				   &wm8731_constraints_12288000);
+	return 0;
+}
+
+/* machine stream operations */
+static struct snd_soc_ops snd_proto_ops = {
+	.startup = snd_proto_startup,
+};
+
+static int snd_proto_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_codec *codec = rtd->codec;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	/* Set proto sysclk */
+	int ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
+					 XTAL_RATE, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec->dev, "Failed to set WM8731 SYSCLK: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct snd_soc_dapm_widget snd_proto_widget[] = {
+	SND_SOC_DAPM_MIC("Microphone Jack", NULL),
+	SND_SOC_DAPM_HP("Headphone Jack", NULL),
+};
+
+static const struct snd_soc_dapm_route snd_proto_route[] = {
+	/* speaker connected to LHPOUT/RHPOUT */
+	{"Headphone Jack", NULL, "LHPOUT"},
+	{"Headphone Jack", NULL, "RHPOUT"},
+
+	/* mic is connected to Mic Jack, with WM8731 Mic Bias */
+	{"MICIN", NULL, "Mic Bias"},
+	{"Mic Bias", NULL, "Microphone Jack"},
+};
+
+/* audio machine driver */
+static struct snd_soc_card snd_proto = {
+	.name		= "snd_mikroe_proto",
+	.owner		= THIS_MODULE,
+	.dapm_widgets	= snd_proto_widget,
+	.num_dapm_widgets = ARRAY_SIZE(snd_proto_widget),
+	.dapm_routes	= snd_proto_route,
+	.num_dapm_routes = ARRAY_SIZE(snd_proto_route),
+};
+
+static int snd_proto_probe(struct platform_device *pdev)
+{
+	struct snd_soc_dai_link *dai;
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *codec_np, *cpu_np;
+	struct device_node *bitclkmaster = NULL;
+	struct device_node *framemaster = NULL;
+	unsigned int dai_fmt;
+	int ret = 0;
+
+	if (!np) {
+		dev_err(&pdev->dev, "No device node supplied\n");
+		return -EINVAL;
+	}
+
+	snd_proto.dev = &pdev->dev;
+	ret = snd_soc_of_parse_card_name(&snd_proto, "model");
+	if (ret)
+		return ret;
+
+	dai = devm_kzalloc(&pdev->dev, sizeof(*dai), GFP_KERNEL);
+	if (!dai)
+		return -ENOMEM;
+
+	snd_proto.dai_link = dai;
+	snd_proto.num_links = 1;
+
+	dai->name = "WM8731";
+	dai->stream_name = "WM8731 HiFi";
+	dai->codec_dai_name = "wm8731-hifi";
+	dai->init = &snd_proto_init;
+	dai->ops = &snd_proto_ops;
+
+	codec_np = of_parse_phandle(np, "audio-codec", 0);
+	if (!codec_np) {
+		dev_err(&pdev->dev, "audio-codec node missing\n");
+		return -EINVAL;
+	}
+	dai->codec_of_node = codec_np;
+
+	cpu_np = of_parse_phandle(np, "i2s-controller", 0);
+	if (!cpu_np) {
+		dev_err(&pdev->dev, "i2s-controller missing\n");
+		return -EINVAL;
+	}
+	dai->cpu_of_node = cpu_np;
+	dai->platform_of_node = cpu_np;
+
+	dai_fmt = snd_soc_of_parse_daifmt(np, NULL,
+					  &bitclkmaster, &framemaster);
+	if (bitclkmaster != framemaster) {
+		dev_err(&pdev->dev, "Must be the same bitclock and frame master\n");
+		return -EINVAL;
+	}
+	if (bitclkmaster) {
+		dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
+		if (codec_np == bitclkmaster)
+			dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
+		else
+			dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
+	}
+	of_node_put(bitclkmaster);
+	of_node_put(framemaster);
+	dai->dai_fmt = dai_fmt;
+
+	of_node_put(codec_np);
+	of_node_put(cpu_np);
+
+	ret = snd_soc_register_card(&snd_proto);
+	if (ret && ret != -EPROBE_DEFER)
+		dev_err(&pdev->dev,
+			"snd_soc_register_card() failed: %d\n", ret);
+
+	return ret;
+}
+
+static int snd_proto_remove(struct platform_device *pdev)
+{
+	return snd_soc_unregister_card(&snd_proto);
+}
+
+static const struct of_device_id snd_proto_of_match[] = {
+	{ .compatible = "mikroe,mikroe-proto", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, snd_proto_of_match);
+
+static struct platform_driver snd_proto_driver = {
+	.driver = {
+		.name   = "snd-mikroe-proto",
+		.owner  = THIS_MODULE,
+		.of_match_table = snd_proto_of_match,
+	},
+	.probe	  = snd_proto_probe,
+	.remove	 = snd_proto_remove,
+};
+
+module_platform_driver(snd_proto_driver);
+
+MODULE_AUTHOR("Florian Meier");
+MODULE_DESCRIPTION("ASoC Driver for PROTO board (WM8731)");
+MODULE_LICENSE("GPL");
-- 
2.17.1


^ permalink raw reply	[flat|nested] 26+ messages in thread
[parent not found: <201611100033.SRMoP0oO%fengguang.wu@intel.com>]
[parent not found: <201506222357.qkZddKc2%fengguang.wu@intel.com>]
[parent not found: <201412070634.hwbnurjX%fengguang.wu@intel.com>]

end of thread, other threads:[~2018-08-30 10:14 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-31 10:05 [PATCH v3 0/8] Add sun8i A33 audio driver Mylène Josserand
2017-01-31 10:05 ` [PATCH v3 1/8] ASoC: sun4i-i2s: Update binding documentation to include A31 Mylène Josserand
2017-01-31 10:30   ` Maxime Ripard
2017-01-31 21:17   ` Mark Brown
2017-02-01  7:44     ` Mylene Josserand
2017-02-01 11:59       ` Mark Brown
2017-02-01 15:08         ` Mylene Josserand
2017-02-01 17:26   ` Rob Herring
2017-01-31 10:05 ` [PATCH v3 2/8] ASoC: sun4i-i2s: Add quirks to handle a31 compatible Mylène Josserand
2017-01-31 10:31   ` Maxime Ripard
2017-01-31 10:05 ` [PATCH v3 3/8] ASoC: Add sun8i digital audio codec Mylène Josserand
2017-01-31 10:35   ` Maxime Ripard
2017-01-31 11:34   ` kbuild test robot
2017-01-31 11:34   ` [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot
2017-01-31 10:05 ` [PATCH v3 4/8] ASoC: sun8i-codec-analog: Add amplifier event to fix first delay Mylène Josserand
2017-01-31 10:35   ` Maxime Ripard
2017-01-31 10:05 ` [PATCH v3 5/8] ASoC: codecs: Add sun8i-a33 binding documentation Mylène Josserand
2017-01-31 10:36   ` Maxime Ripard
2017-02-01 17:30   ` Rob Herring
2017-01-31 10:05 ` [PATCH v3 6/8] ARM: dts: sun8i: Add audio codec, dai and card for A33 Mylène Josserand
2017-01-31 10:05 ` [PATCH v3 7/8] ARM: dts: sun8i: parrot: Enable audio nodes Mylène Josserand
2017-01-31 10:05 ` [PATCH v3 8/8] ARM: dts: sun8i: sinlinx: " Mylène Josserand
  -- strict thread matches above, loose matches on Subject: below --
2018-08-29 14:47 [PATCH 1/2] ASoC: Add driver for PROTO Audio CODEC (with a WM8731) Codrin Ciubotariu
2018-08-30 10:13 ` [PATCH] ASoC: fix platform_no_drv_owner.cocci warnings kbuild test robot
     [not found] <201611100033.SRMoP0oO%fengguang.wu@intel.com>
2016-11-09 16:58 ` kbuild test robot
     [not found] <201506222357.qkZddKc2%fengguang.wu@intel.com>
2015-06-22 15:36 ` kbuild test robot
     [not found] <201412070634.hwbnurjX%fengguang.wu@intel.com>
2014-12-06 22:06 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®