Add support for es8388 and hdmi audio on the rock2
Subsystems (4)
v4 cover Add support for es8388 and hdmi audio on the rock2
This set of patches adds a machine driver for rk3288-based boards that have the built-in HDMI audio and a generic analog output. It also adds slave mode to the es8328 driver that currently only supported the master mode. Then, it adds the required DT definitions to link rockchip-i2s to the es8388 analog output and to hdmi audio.
This work is based on the initial work that was done by Sjoerd Simons <[email protected]> with some improvements, changes and more commits.
Changes in v4:
- Add support for multi codecs in the asoc machine driver, so the driver matches the hw architecture (analog and hdmi audio are connected on the same i2s line)
- Renamed the driver to rk3288-hdmi-analog.c and changed its documentation
- Add built-in support for hdmi audio in this driver
- Add support for the property 'rockchip,routing'
Changes in v3:
- Cosmetic changes in rockchip_es8388.c
- Added missing email to MODULE_AUTHOR in rockchip_es8388.c
Changes in v2:
- Fixed wrong use of the data structure i2c_device_id
- Fixed wrong dependencies for SND_SOC_ROCKCHIP_ES8388
Romain Perier (4):
ASoC: es8328-i2c: Add compatible for ES8388
ASoC: es8328: Add support for slave mode
ASoC: rockchip: Add machine driver for RK3288 boards that use
analog/HDMI
arm: dts: Add support for ES8388 to the Radxa Rock 2
Documentation/devicetree/bindings/sound/es8328.txt | 2 +- .../bindings/sound/rockchip,rk3288-hdmi-analog.txt | 36 +++ arch/arm/boot/dts/rk3288-rock2-square.dts | 39 +++ sound/soc/codecs/es8328-i2c.c | 2 + sound/soc/codecs/es8328.c | 28 +- sound/soc/rockchip/Kconfig | 10 + sound/soc/rockchip/Makefile | 2 + sound/soc/rockchip/rk3288_hdmi_analog.c | 299 +++++++++++++++++++++ 8 files changed, 411 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt create mode 100644 sound/soc/rockchip/rk3288_hdmi_analog.c
Signature · 1 line
2.9.3
PATCH v4 1/4 ASoC: es8328-i2c: Add compatible for ES8388
This commit adds a compatible string for everest,es8388. This is an audio codec that is compatible with es8328.
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- Fixed wrong use of the i2c_device_id data structure
Documentation/devicetree/bindings/sound/es8328.txt | 2 +- sound/soc/codecs/es8328-i2c.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/es8328.txt +1 -1
@@ -4,7 +4,7 @@ This device supports both I2C and SPI. Required properties: - - compatible : "everest,es8328" + - compatible : Should be "everest,es8328" or "everest,es8388" - DVDD-supply : Regulator providing digital core supply voltage 1.8 - 3.6V - AVDD-supply : Regulator providing analog supply voltage 3.3V - PVDD-supply : Regulator providing digital IO supply voltage 1.8 - 3.6V
sound/soc/codecs/es8328-i2c.c +2 -0
@@ -20,12 +20,14 @@static const struct i2c_device_id es8328_id[] = { {"es8328" ,0 }, + {"es8388" ,0 }, { } };MODULE_DEVICE_TABLE (i2c, es8328_id);static const struct of_device_id es8328_of_match[] = { { .compatible ="everest,es8328" , }, + { .compatible ="everest,es8388" , }, { } };MODULE_DEVICE_TABLE (of, es8328_of_match);
Signature · 1 line
2.9.3
PATCH v4 2/4 ASoC: es8328: Add support for slave mode
In reply to Romain PerierCurrently, the function that changes the DAI format only supports master mode. Trying to use a slave mode exits the function with -EINVAL and leave the codec misconfigured. This commits adds support for enabling the slave mode.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
sound/soc/codecs/es8328.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
sound/soc/codecs/es8328.c +22 -6
@@ -588,10 +588,18 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai,struct snd_soc_codec *codec = codec_dai->codec;u8 dac_mode =0 ;u8 adc_mode =0 ; +bool master; -/* set master/slave audio interface */ -if ((fmt &SND_SOC_DAIFMT_MASTER_MASK ) !=SND_SOC_DAIFMT_CBM_CFM ) -return -EINVAL ; +switch (fmt &SND_SOC_DAIFMT_MASTER_MASK ) { +case SND_SOC_DAIFMT_CBM_CFM : + master = true; +break ; +case SND_SOC_DAIFMT_CBS_CFS : + master = false; +break ; +default : +return -EINVAL ; + }/* interface format */ switch (fmt &SND_SOC_DAIFMT_FORMAT_MASK ) {
@@ -620,9 +628,17 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai,snd_soc_update_bits (codec,ES8328_ADCCONTROL4 ,ES8328_ADCCONTROL4_ADCFORMAT_MASK , adc_mode); -/* Master serial port mode, with BCLK generated automatically */ -snd_soc_update_bits (codec,ES8328_MASTERMODE , -ES8328_MASTERMODE_MSC ,ES8328_MASTERMODE_MSC ); +if (master) { +/* Master serial port mode, with BCLK generated automatically */ +snd_soc_update_bits (codec,ES8328_MASTERMODE , +ES8328_MASTERMODE_MSC , +ES8328_MASTERMODE_MSC ); + }else { +/* Slave serial port mode */ +snd_soc_update_bits (codec,ES8328_MASTERMODE , +ES8328_MASTERMODE_MSC , +0 ); + }return 0 ; }
Signature · 1 line
2.9.3
A message that is not in the archive (sent off-list or not yet received): 20170123104149.2508-3-romain.perier-ZGY8ohtN/[email protected]
Re: [PATCH v4 2/4] ASoC: es8328: Add support for slave mode
sound/soc/codecs/es8328.c static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, · line 602
Quoted 10 lines · Romain Perier
sound/soc/codecs/es8328.c +10
-0+switch (fmt &SND_SOC_DAIFMT_MASTER_MASK ) { +case SND_SOC_DAIFMT_CBM_CFM : + master = true; +break ; +case SND_SOC_DAIFMT_CBS_CFS : + master = false; +break ; +default : +return -EINVAL ; + }
Please use the normal kernel coding style. People read in part by pattern matching so this is important to ease review and coding style problems are a big warning sign that the code also has problems with other, more substantial, understanding of how the kernel is expected to work.
Quoted 4 lines
sound/soc/codecs/es8328.c +1
-3-/* Master serial port mode, with BCLK generated automatically */ -snd_soc_update_bits (codec,ES8328_MASTERMODE , -ES8328_MASTERMODE_MSC ,ES8328_MASTERMODE_MSC ); +if (master) {
sound/soc/codecs/es8328.c static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, · line 641
Quoted 10 lines
sound/soc/codecs/es8328.c +10
-0+/* Master serial port mode, with BCLK generated automatically */ +snd_soc_update_bits (codec,ES8328_MASTERMODE , +ES8328_MASTERMODE_MSC , +ES8328_MASTERMODE_MSC ); + }else { +/* Slave serial port mode */ +snd_soc_update_bits (codec,ES8328_MASTERMODE , +ES8328_MASTERMODE_MSC , +0 ); + }
Why not just directly do this in the switch statement? This appears to be the only place where we change behaviour so setting a variable at the top of the function then using it at the bottom doesn't seem to add anything.
PATCH v4 3/4 ASoC: rockchip: Add machine driver for RK3288 boards that use analog/HDMI
In reply to Romain PerierThe driver is used for Rockchip rk3288-based boards using a configurable analog output (can be an headphone) and the built-in HDMI audio output that is part of the RK3288 SoCs and use the Alsa HDMI codec driver. For some rk3288-based boards the analog output and the hdmi audio are plugged on the same i2s line, so we have to do the same in the driver by using a DAI link CPU to multicodecs. This configuration can be found for example on the Radxa Rock2 or the Firefly-RK3288.
This commit is based on the initial work that was done by Sjoerd Simons <[email protected]> with some improvements.
---
Changes in v4:
- Added support for multi codecs in the asoc machine driver, so the driver matches the hw architecture (analog and hdmi audio are connected on the same i2s line)
- Renamed the driver to rk3288-hdmi-analog.c
- Changed some variables names due to this renaming
- Changed the documentation
- Added built-in support for hdmi audio in this driver
- Added support for the property 'rockchip,routing'
Changes in v3:
- Cosmetic changes
- Added missing email to MODULE_AUTHOR
Changes in v2:
- Fixed wrong dependencies for SND_SOC_ROCKCHIP_ES8388, SND_SOC_ROCKCHIP_I2S was selected with unmet direct dependencies
.../bindings/sound/rockchip,rk3288-hdmi-analog.txt | 36 +++ sound/soc/rockchip/Kconfig | 10 + sound/soc/rockchip/Makefile | 2 + sound/soc/rockchip/rk3288_hdmi_analog.c | 299 +++++++++++++++++++++ 4 files changed, 347 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt create mode 100644 sound/soc/rockchip/rk3288_hdmi_analog.c
Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt new file +36 -0
@@ -0,0 +1,36 @@ +ROCKCHIP RK3288 with HDMI and analog audio + +Required properties: +- compatible: "rockchip,rk3288-hdmi-analog" +- rockchip,model: The user-visible name of this sound complex +- rockchip,i2s-controller: The phandle of the Rockchip I2S controller that's + connected to the CODEC +- rockchip,audio-codec: The phandle of the analog audio codec. +- rockchip,routing: A list of the connections between audio components. + Each entry is a pair of strings, the first being the + connection's sink, the second being the connection's + source. For this driver the first string should always be + "Analog". + +Optionnal properties: +- rockchip,hp-en-gpios = The phandle of the GPIO that power up/down the + headphone (when the analog output is an headphone). +- rockchip,hp-det-gpios = The phandle of the GPIO that detects the headphone + (when the analog output is an headphone). +- pinctrl-names, pinctrl-0: Please refer to pinctrl-bindings.txt + +Example: + +sound { + compatible = "rockchip,rockchip-audio-es8388"; + rockchip,model = "Analog audio output"; + rockchip,i2s-controller = <&i2s>; + rockchip,audio-codec = <&es8388>; + rockchip,routing = "Analog", "LOUT2", + "Analog", "ROUT2"; + rockchip,hp-en-gpios = <&gpio8 0 GPIO_ACTIVE_HIGH>; + rockchip,hp-det-gpios = <&gpio7 7 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&headphone>; +}; +
sound/soc/rockchip/Kconfig +10 -0
@@ -42,6 +42,16 @@ config SND_SOC_ROCKCHIP_RT5645 Say Y or M here if you want to add support for SoC audio on Rockchip boards using the RT5645/RT5650 codec, such as Veyron. +config SND_SOC_RK3288_HDMI_ANALOG + tristate "ASoC support multiple codecs for Rockchip RK3288 boards" + depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP + select SND_SOC_ROCKCHIP_I2S + select SND_SOC_ES8328_I2C + select SND_SOC_HDMI_CODEC + help + Say Y or M here if you want to add support for SoC audio on Rockchip + RK3288 boards using an analog output and the built-in HDMI audio. + config SND_SOC_RK3399_GRU_SOUND tristate "ASoC support multiple codecs for Rockchip RK3399 GRU boards" depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP && SPI
sound/soc/rockchip/Makefile +2 -0
@@ -7,8 +7,10 @@ obj-$(CONFIG_SND_SOC_ROCKCHIP_SPDIF) += snd-soc-rockchip-spdif.o snd-soc-rockchip-max98090-objs := rockchip_max98090.o snd-soc-rockchip-rt5645-objs := rockchip_rt5645.o +snd-soc-rk3288-hdmi-analog-objs := rk3288_hdmi_analog.o snd-soc-rk3399-gru-sound-objs := rk3399_gru_sound.o obj-$(CONFIG_SND_SOC_ROCKCHIP_MAX98090) += snd-soc-rockchip-max98090.o obj-$(CONFIG_SND_SOC_ROCKCHIP_RT5645) += snd-soc-rockchip-rt5645.o +obj-$(CONFIG_SND_SOC_RK3288_HDMI_ANALOG) += snd-soc-rk3288-hdmi-analog.o obj-$(CONFIG_SND_SOC_RK3399_GRU_SOUND) += snd-soc-rk3399-gru-sound.o
sound/soc/rockchip/rk3288_hdmi_analog.c new file +299 -0
299 lines not on this page · raw message
Signature · 1 line
2.9.3
A message that is not in the archive (sent off-list or not yet received): 20170123104149.2508-4-romain.perier-ZGY8ohtN/[email protected]
kbuild test robot
build bot[PATCH] ASoC: rockchip: fix platform_no_drv_owner.cocci warnings
sound/soc/rockchip/rk3288_hdmi_analog.c:288:3-8: No need to set .owner here. The core will do it.
sound/soc/rockchip/rk3288_hdmi_analog.c:288:3-8: No need to set .owner here. The core will do it.
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
---
rk3288_hdmi_analog.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/rockchip/rk3288_hdmi_analog.c +0 -1
@@ -285,7 +285,6 @@ static struct platform_driver rockchip_s .probe = snd_rk_mc_probe, .driver = { .name = DRV_NAME, - .owner = THIS_MODULE, .pm = &snd_soc_pm_ops, .of_match_table = rockchip_sound_of_match, },
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
kbuild test robot
build botRe: [alsa-devel] [PATCH v4 3/4] ASoC: rockchip: Add machine driver for RK3288 boards that use analog/HDMI
In reply to a message not in the archivecoccinelle warnings: (new ones prefixed by >>)
Hi Romain,
[auto build test WARNING on rockchip/for-next]
[also build test WARNING on v4.10-rc5 next-20170123]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Romain-Perier/Add-support-for-es8388-and-hdmi-audio-on-the-rock2/20170123-220028 base: https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
coccinelle warnings: (new ones prefixed by >>)
>> sound/soc/rockchip/rk3288_hdmi_analog.c:288:3-8: No need to set .owner here. The core will do it.
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 3/4] ASoC: rockchip: Add machine driver for RK3288 boards that use analog/HDMI
In reply to a message not in the archiveOn Mon, Jan 23, 2017 at 11:41:48AM +0100, Romain Perier wrote:
This looks mostly fine but:
sound/soc/rockchip/rk3288_hdmi_analog.c line 200
Quoted 4 lines
sound/soc/rockchip/rk3288_hdmi_analog.c new file +4
-0+ machine->gpio_hp_det =of_get_named_gpio (np, +"rockchip,hp-det-gpios" ,0 ); +if (machine->gpio_hp_det == -EPROBE_DEFER ) +return -EPROBE_DEFER ;
Rather than explicitly checking for probe defer here it's better to check for the error code that indicates there's nothing to find (-ENODEV IIRC but I might be misremembering for GPIO). That way if there's some actual error like running out of memory allocating some structure that's required then we'll not just silently ignore it.
PATCH v4 4/4 arm: dts: Add support for ES8388 to the Radxa Rock 2
In reply to Romain PerierThis commit adds the DT definition of the es8388 i2c device found at address 0x10. It also adds the definition for connecting the Rockchip I2S to the es8388 analog output.
This commit is based on the initial work that was done by Sjoerd Simons <[email protected]> with some improvements.
---
Changes in v4:
- Updated to the new DT binding
- Added the property 'rockchip,routing'
- Renamed the node sound_es8388 to sound_i2s
Changes in v3: None
Changes in v2: None
arch/arm/boot/dts/rk3288-rock2-square.dts | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
arch/arm/boot/dts/rk3288-rock2-square.dts +39 -0
@@ -86,6 +86,19 @@ #sound-dai-cells = <0>; }; + sound_i2s { + compatible = "rockchip,rk3288-hdmi-analog"; + rockchip,model = "I2S"; + rockchip,i2s-controller = <&i2s>; + rockchip,audio-codec = <&es8388>; + rockchip,routing = "Analog", "LOUT2", + "Analog", "ROUT2"; + rockchip,hp-en-gpios = <&gpio8 0 GPIO_ACTIVE_HIGH>; + rockchip,hp-det-gpios = <&gpio7 7 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&headphone>; + }; + sdio_pwrseq: sdio-pwrseq { compatible = "mmc-pwrseq-simple"; clocks = <&hym8563>;
@@ -173,10 +186,29 @@ }; }; +&i2c2 { + status = "okay"; + + es8388: es8388@10 { + compatible = "everest,es8388", "everest,es8328"; + reg = <0x10>; + AVDD-supply = <&vcca_codec>; + DVDD-supply = <&vcca_codec>; + HPVDD-supply = <&vcca_codec>; + PVDD-supply = <&vcca_codec>; + clocks = <&cru SCLK_I2S0_OUT>; + clock-names = "i2s_clk_out"; + }; +}; + &i2c5 { status = "okay"; }; +&i2s { + status = "okay"; +}; + &pinctrl { ir { ir_int: ir-int {
@@ -190,6 +222,13 @@ }; }; + sound { + headphone: headphone { + rockchip,pins = <8 0 RK_FUNC_GPIO &pcfg_pull_up>, + <7 7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + usb { host_vbus_drv: host-vbus-drv { rockchip,pins = <0 14 RK_FUNC_GPIO &pcfg_pull_none>;
Signature · 1 line
2.9.3
A message that is not in the archive (sent off-list or not yet received): 20170123104149.2508-1-romain.perier-ZGY8ohtN/[email protected]
Quoted 8 lines · Romain Perier
Changes in v4:
- Add support for multi codecs in the asoc machine driver, so the driver matches the hw architecture (analog and hdmi audio are connected on the same i2s line)
- Renamed the driver tork3288-hdmi-analog.cand changed its documentation
- Add built-in support for hdmi audio in this driver
- Add support for the property 'rockchip,routing'
This is the first version that has been sumbitted upstream.
A message that is not in the archive (sent off-list or not yet received): 20170123175451.hwvuum4ismutrbsf-GFdadSzt00ze9xe1eoZjHA@public.gmane.org
Hi,
Quoted 11 lines · Mark Brown
Quoted 8 lines · Romain Perier
Changes in v4:
- Add support for multi codecs in the asoc machine driver, so the driver matches the hw architecture (analog and hdmi audio are connected on the same i2s line)
- Renamed the driver tork3288-hdmi-analog.cand changed its documentation
- Add built-in support for hdmi audio in this driver
- Add support for the property 'rockchip,routing'This is the first version that has been sumbitted upstream.
No this is the 4th, I have just re-worded the title :
-
http://mailman.alsa-project.org/pipermail/alsa-devel/2017-January/116702.html
Not sure that you was in Cc: for the previous ones (whoops?)
Romain
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 3f39ed38-309f-2e79-bd00-21ff367c83b5-ZGY8ohtN/[email protected]
Quoted 9 lines · Romain Perier
Quoted 1 line · Mark Brown
This is the first version that has been sumbitted upstream.
No this is the 4th, I have just re-worded the title :
http://mailman.alsa-project.org/pipermail/alsa-devel/2017-January/116702.html
Not sure that you was in Cc: for the previous ones (whoops?)
I wasn't, that's my point.