ASoC: ak4118: Add support for AK4118 S/PDIF transceiver
Subsystems (3)
PATCH v2 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
---
v2:
- request threaded_irq in driver probe
- change fs_enum from VALUE_SINGLE to VALUE_ENUM_SINGLE
sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/ak4118.c | 438 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 446 insertions(+) create mode 100644 sound/soc/codecs/ak4118.c
sound/soc/codecs/Kconfig +6 -0
@@ -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
@@ -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 +438 -0
438 lines not on this page · raw message
Signature · 1 line
2.19.1
PATCH v2 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
@@ -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 · 6 lines
2.19.1 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Rob Herring
maintainerRe: [PATCH v2 2/2] ASoC: dt-bindings: add bindings for AK4118 transceiver
Quoted 14 lines · Clément Péron
Document the bindings for AK4118 S/PDIF transceiver
Signed-off-by Clément Péron <[email protected]>--- .../devicetree/bindings/sound/ak4118.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/ak4118.txtDocumentation/devicetree/bindings/sound/ak4118.txt new file +0
-0
Documentation/devicetree/bindings/sound/ak4118.txt line 10
Quoted 10 lines
Documentation/devicetree/bindings/sound/ak4118.txt new file +10
-0@@ -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
This should use 'interrupts' instead.
Documentation/devicetree/bindings/sound/ak4118.txt line 15
Quoted 5 lines
Documentation/devicetree/bindings/sound/ak4118.txt new file +5
-0+ +Example: + +&i2c { + ak4118: ak4118@13 {
spdif@13 ? Node names should be based on the class of device, but there's not really one defined for this.
Quoted 10 lines
Documentation/devicetree/bindings/sound/ak4118.txt new file +7
-0+ #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
Re: [PATCH v2 2/2] ASoC: dt-bindings: add bindings for AK4118 transceiver
Hi Rob,
Quoted 20 lines · Rob Herring
Quoted 18 lines · Clément Péron
Document the bindings for AK4118 S/PDIF transceiver
Signed-off-by Clément Péron <[email protected]>--- .../devicetree/bindings/sound/ak4118.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/ak4118.txtDocumentation/devicetree/bindings/sound/ak4118.txt new file +4
-0@@ -0,0 +1,22 @@ +AK4118 S/PDIF transceiver + +This device supports I2C mode. +
Quoted 8 lines
Documentation/devicetree/bindings/sound/ak4118.txt line 10
Quoted 6 lines
Documentation/devicetree/bindings/sound/ak4118.txt new file +6
-0+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 pinThis should use 'interrupts' instead.
Yes, this will also simplify the driver.
Quoted 9 lines
Documentation/devicetree/bindings/sound/ak4118.txt line 15
Quoted 6 lines
Documentation/devicetree/bindings/sound/ak4118.txt new file +5
-0+ +Example: + +&i2c { + ak4118: ak4118@13 {spdif@13 ? Node names should be based on the class of device, but there's not really one defined for this.
Ok I will use spdif.
Thanks for the comments,
Clement
Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/sound/ak4118.txt new file +7
-1+ #sound-dai-cells = <0>; + compatible = "asahi-kasei,ak4118"; + reg = <0x13>; + reset-gpios = <&gpio 0 GPIO_ACTIVE_LOW> + irq-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + }; +}; --2.19.1
Quoted 8 lines · Clément Péron
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.
I'm curious, from what it seems, there is no checking that the input sample rate actually matches the configured sample rate? It's perfectly understandable for a driver which has 'minimal support', but it's something a user must be aware of; for instance if someone does
arecord -r 48000 output.wav
when the input data actually has a rate of 44100 Hz then the file will be written with a header specifying 44100 Hz but the data will actually be 48000 Hz.
It's not an objection on my part, just an observation. I don't know how ALSA could enforce this in any way; ideally (barring automatic sample rate conversion) one would want an error message that the sample rate specified when opening the stream does not match the sample rate of the S/PDIF input data.
/Ricard
Signature · 3 lines
Ricard Wolf Wanderlof ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30
Hi Ricard,
Quoted 24 lines · Ricard Wanderlof
Quoted 8 lines · Clément Péron
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.
I'm curious, from what it seems, there is no checking that the input sample rate actually matches the configured sample rate? It's perfectly understandable for a driver which has 'minimal support', but it's something a user must be aware of; for instance if someone does
arecord -r 48000 output.wav
when the input data actually has a rate of 44100 Hz then the file will be written with a header specifying 44100 Hz but the data will actually be 48000 Hz.
Quoted 5 lines
It's not an objection on my part, just an observation. I don't know how ALSA could enforce this in any way; ideally (barring automatic sample rate conversion) one would want an error message that the sample rate specified when opening the stream does not match the sample rate of the S/PDIF input data.
I'm quite new with linux audio driver but adding in ak4118_hw_params a check like if params_rate(params) == ak4118_rate should do the job no ?
Regards,
Clement
Quoted 6 lines
/Ricard
--Ricard Wolf Wanderlof ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30
Quoted 18 lines · Clément Péron
Quoted 18 lines
Quoted 6 lines
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.
I'm curious, from what it seems, there is no checking that the input sample rate actually matches the configured sample rate? It's perfectly understandable for a driver which has 'minimal support', but it's something a user must be aware of; for instance if someone does
arecord -r 48000 output.wav
when the input data actually has a rate of 44100 Hz then the file will be written with a header specifying 44100 Hz but the data will actually be 48000 Hz.
Quoted 8 lines
Quoted 5 lines
It's not an objection on my part, just an observation. I don't know how ALSA could enforce this in any way; ideally (barring automatic sample rate conversion) one would want an error message that the sample rate specified when opening the stream does not match the sample rate of the S/PDIF input data.
I'm quite new with linux audio driver but adding in
ak4118_hw_paramsa check like ifparams_rate(params)==ak4118_rateshould do the job no
It will if the SPDIF stream is already running when the driver is started up, but if for some reason the sample rate changes or the SPDIF source is not transmitting anything when the stream is started it won't work to do it hw_params. A changing sample rate might be an unusual usecase, but one could imagine having an SPDIF source which is silent (e.g. not even plugged in) when the stream is set up.
Like I said, it might not be a problem in many applications. And I'm not really sure how to solve it. Perhaps someone else knows. ALSA likes to be in control of parameters such as the sample rate, but it can't with an external device controlling the sample rate of the SPDIF receiver.
/Ricard
Signature · 3 lines
Ricard Wolf Wanderlof ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30