Skip to contentSkip to conversation

ASoC: ak4118: Add support for AK4118 S/PDIF transceiver

PATCH Superseded Clément Péron 2 participants 6 messages Nov 8, 2018 – Nov 15, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: ak4118: Add support for AK4118 S/PDIF transceiver

From: Adrien Charruel <[email protected]>

The AK4118A is a digital audio transceiver supporting 8 input channels at 192kHz and with 24bits resolution.
It converts the S/PDIF signal to I2S format and is configurable over I2C.

This driver introduce a minimal support of the AK4118, like selecting the input channel, reading input frequency and detecting some errors.

Datasheet is available here:
https://www.akm.com/akm/en/file/datasheet/AK4118AEQ.pdf

---
 sound/soc/codecs/Kconfig  |   6 +
 sound/soc/codecs/Makefile |   2 +
 sound/soc/codecs/ak4118.c | 449 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 457 insertions(+)
 create mode 100644 sound/soc/codecs/ak4118.c
sound/soc/codecs/Kconfig +6 -0
index 9cc4f1848c9b..62bdb7e333b8 100644
@@ -35,6 +35,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_ADAU7002
 	select SND_SOC_ADS117X
 	select SND_SOC_AK4104 if SPI_MASTER
+	select SND_SOC_AK4118 if I2C
 	select SND_SOC_AK4458 if I2C
 	select SND_SOC_AK4535 if I2C
 	select SND_SOC_AK4554
@@ -392,6 +393,11 @@ config SND_SOC_AK4104
 	tristate "AKM AK4104 CODEC"
 	depends on SPI_MASTER
 
+config SND_SOC_AK4118
+	tristate "AKM AK4118 CODEC"
+	depends on I2C
+	select REGMAP_I2C
+
 config SND_SOC_AK4458
 	tristate "AKM AK4458 CODEC"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index 8ffab8c8dbfa..66f55d185620 100644
@@ -27,6 +27,7 @@ snd-soc-adav801-objs := adav801.o
 snd-soc-adav803-objs := adav803.o
 snd-soc-ads117x-objs := ads117x.o
 snd-soc-ak4104-objs := ak4104.o
+snd-soc-ak4118-objs := ak4118.o
 snd-soc-ak4458-objs := ak4458.o
 snd-soc-ak4535-objs := ak4535.o
 snd-soc-ak4554-objs := ak4554.o
@@ -290,6 +291,7 @@ obj-$(CONFIG_SND_SOC_ADAV801)  += snd-soc-adav801.o
 obj-$(CONFIG_SND_SOC_ADAV803)  += snd-soc-adav803.o
 obj-$(CONFIG_SND_SOC_ADS117X)	+= snd-soc-ads117x.o
 obj-$(CONFIG_SND_SOC_AK4104)	+= snd-soc-ak4104.o
+obj-$(CONFIG_SND_SOC_AK4118)	+= snd-soc-ak4118.o
 obj-$(CONFIG_SND_SOC_AK4458)	+= snd-soc-ak4458.o
 obj-$(CONFIG_SND_SOC_AK4535)	+= snd-soc-ak4535.o
 obj-$(CONFIG_SND_SOC_AK4554)	+= snd-soc-ak4554.o
sound/soc/codecs/ak4118.c new file +449 -0

449 lines not on this page · raw message

Signature · 1 line
2.19.1
#1 lore raw

PATCH 2/2 ASoC: dt-bindings: add bindings for AK4118 transceiver

Document the bindings for AK4118 S/PDIF transceiver

---
 .../devicetree/bindings/sound/ak4118.txt      | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/ak4118.txt
Documentation/devicetree/bindings/sound/ak4118.txt new file +22 -0
new file mode 100644
index 000000000000..6e11a2f7404c
@@ -0,0 +1,22 @@
+AK4118 S/PDIF transceiver
+
+This device supports I2C mode.
+
+Required properties:
+
+- compatible : "asahi-kasei,ak4118"
+- reg : The I2C address of the device for I2C
+- reset-gpios: A GPIO specifier for the reset pin
+- irq-gpios: A GPIO specifier for the IRQ pin
+
+Example:
+
+&i2c {
+	ak4118: ak4118@13 {
+		#sound-dai-cells = <0>;
+		compatible = "asahi-kasei,ak4118";
+		reg = <0x13>;
+		reset-gpios = <&gpio 0 GPIO_ACTIVE_LOW>
+		irq-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
+	};
+};
Signature · 1 line
2.19.1
maintainer
#2 lore raw
In reply to Clément Péron

On Thu, Nov 08, 2018 at 01:49:33PM +0100, Clément Péron wrote:

This looks mostly good, a few small things below but nothing too major:

sound/soc/codecs/ak4118.c line 4

Quoted 7 lines
sound/soc/codecs/ak4118.c new file +4 -0
@@ -0,0 +1,449 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ak4118.c  --  Asahi Kasei ALSA Soc Audio driver
+ *

Please make the entire comment a C++ one so this looks more intentional.

sound/soc/codecs/ak4118.c line 109

Quoted 3 lines
sound/soc/codecs/ak4118.c new file +3 -0
+static const char * const ak4118_iec958_fs_texts[] = {
+	"44100",
+	"Reserved",

If you use a _VALUE_ENUM_SINGLE you can hide the reserved/invalid values from userspace which is easier to use.

sound/soc/codecs/ak4118.c line 341

Quoted 7 lines
sound/soc/codecs/ak4118.c new file +7 -0
+	ret = request_threaded_irq(gpiod_to_irq(ak4118->irq), NULL,
+				   ak4118_irq_handler, IRQF_TRIGGER_RISING |
+				   IRQF_ONESHOT, "ak4118-irq", ak4118);
+	if (ret < 0) {
+		dev_err(component->dev, "Fail to request_irq: %d\n", ret);
+		return ret;
+	}

You should request resources in the device level probe, there's no point in requesting and releasing the interrupt like this.

#3 lore raw

Hi Mark,

Quoted 5 lines · Mark Brown

On Thu, Nov 08, 2018 at 01:49:33PM +0100, Clément Péron wrote:

This looks mostly good, a few small things below but nothing too major:

Quoted 9 lines

sound/soc/codecs/ak4118.c line 4

Quoted 7 lines
sound/soc/codecs/ak4118.c new file +4 -0
@@ -0,0 +1,449 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ak4118.c  --  Asahi Kasei ALSA Soc Audio driver
+ *

Please make the entire comment a C++ one so this looks more intentional.

I check from other files and also this article says :
"For normal C source files, the string will be a comment using the "//" syntax; header files, instead, use traditional (/* */) comments for reasons related to tooling"
https://lwn.net/Articles/739183/

Quoted 7 lines

sound/soc/codecs/ak4118.c line 109

Quoted 4 lines
sound/soc/codecs/ak4118.c new file +3 -0
+static const char * const ak4118_iec958_fs_texts[] = {
+     "44100",
+     "Reserved",

If you use a _VALUE_ENUM_SINGLE you can hide the reserved/invalid values from userspace which is easier to use.

Ok will change to SOC_VALUE_ENUM_SINGLE_DECL

Quoted 11 lines

sound/soc/codecs/ak4118.c line 341

Quoted 8 lines
sound/soc/codecs/ak4118.c new file +7 -0
+     ret = request_threaded_irq(gpiod_to_irq(ak4118->irq), NULL,
+                                ak4118_irq_handler, IRQF_TRIGGER_RISING |
+                                IRQF_ONESHOT, "ak4118-irq", ak4118);
+     if (ret < 0) {
+             dev_err(component->dev, "Fail to request_irq: %d\n", ret);
+             return ret;
+     }

You should request resources in the device level probe, there's no point in requesting and releasing the interrupt like this.

Ok, will change to devm_request_threaded_irq and remove the irq_free

Thanks for the review,
Regards,
Clément

maintainer
#4 lore raw
Quoted 10 lines · Clément Péron
Quoted 8 lines · Mark Brown

sound/soc/codecs/ak4118.c line 4

Quoted 4 lines · Clément Péron
sound/soc/codecs/ak4118.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ak4118.c  --  Asahi Kasei ALSA Soc Audio driver
+ *

Please make the entire comment a C++ one so this looks more intentional.

Quoted 5 lines

I check from other files and also this article says :
"For normal C source files, the string will be a comment using the "//" syntax; header files, instead, use traditional (/* */) comments for reasons related to tooling"
https://lwn.net/Articles/739183/

Right, and what I said was that you should make the entire comment a C++ one which means that the magic line will be C++ as required.

#5 lore raw

Hi Mark,

Quoted 12 lines · Mark Brown
Quoted 9 lines · Clément Péron
Quoted 8 lines · Mark Brown

sound/soc/codecs/ak4118.c line 4

Quoted 4 lines · Clément Péron
sound/soc/codecs/ak4118.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ak4118.c  --  Asahi Kasei ALSA Soc Audio driver
+ *

Please make the entire comment a C++ one so this looks more intentional.

Quoted 8 lines
Quoted 5 lines

I check from other files and also this article says :
"For normal C source files, the string will be a comment using the "//" syntax; header files, instead, use traditional (/* */) comments for reasons related to tooling"
https://lwn.net/Articles/739183/

Right, and what I said was that you should make the entire comment a C++ one which means that the magic line will be C++ as required.

Yes, sorry I was confused between C++ and C99,
Regards,
Clement