Re: [alsa-devel][PATCH] ASoC: fsl: add imx-wm8960 machine driver
On Thu, Jun 11, 2015 at 08:51:07AM -0700, Nicolin Chen wrote: On Thu, Jun 11, 2015 at 07:10:00PM +0800, Zidan Wang wrote: This imx-wm8960 device-tree-only machine driver works with sai driver and have below feature. * support codec master and slave mode * support headphone jack detect * support headphone and micphone jack event * support asrc-sai-wm8960 mode Signed-off-by: Zidan Wang zidan.w...@freescale.com Above all, could you merge this into fsl-asoc-card? It'd be nicer to have jack detection over there. And we can put PLL settings to the codec driver as Mark suggested. I want to modify imx-wm8960 and upstream it because our release is using it now. After upstreaming imx-wm8960, i will try to merge it to fsl-asoc-card. I knew your intention. That's why I suggested you to merge it directly to fsl-asoc-card instead of making a duplicated copy of that. Remember that getting code upstream should be a chance for us to improve thing. If you find painstaking to handle it in parallel, you can focus on the improvements of the WM8960 driver while I would help you on the dai- link part. How about this? Nicolin The new imx7 release have two new codec wm8958 and wm8960. So we have two machine driver imx-wm8960 and imx-wm8958 which should be upstreamed. I am appreciate that you can help me merge the imx-wm8960 to fsl-asoc-card. And i will focus on wm8960 and wm8958 driver. And i will try to merge imx-wm8958 to fsl-asoc-card. Best Regards, Zidan Wang ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [alsa-devel][PATCH] ASoC: fsl: add imx-wm8960 machine driver
On Wed, Jun 10, 2015 at 11:36:21AM -0700, Nicolin Chen wrote: On Wed, Jun 10, 2015 at 04:26:27PM +0800, Zidan Wang wrote: This imx-wm8960 device-tree-only machine driver works with sai driver and have below feature. * support codec master and slave mode * support headphone jack detect * support headphone and micphone jack event * support asrc-sai-wm8960 mode Signed-off-by: Zidan Wang zidan.w...@freescale.com Above all, could you merge this into fsl-asoc-card? It'd be nicer to have jack detection over there. And we can put PLL settings to the codec driver as Mark suggested. Hi Nicolin, I want to modify imx-wm8960 and upstream it because our release is using it now. After upstreaming imx-wm8960, i will try to merge it to fsl-asoc-card. Best Regards, Zidan Wang Thanks Nicolin ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [alsa-devel][PATCH] ASoC: fsl: add imx-wm8960 machine driver
On Thu, Jun 11, 2015 at 07:10:00PM +0800, Zidan Wang wrote: This imx-wm8960 device-tree-only machine driver works with sai driver and have below feature. * support codec master and slave mode * support headphone jack detect * support headphone and micphone jack event * support asrc-sai-wm8960 mode Signed-off-by: Zidan Wang zidan.w...@freescale.com Above all, could you merge this into fsl-asoc-card? It'd be nicer to have jack detection over there. And we can put PLL settings to the codec driver as Mark suggested. I want to modify imx-wm8960 and upstream it because our release is using it now. After upstreaming imx-wm8960, i will try to merge it to fsl-asoc-card. I knew your intention. That's why I suggested you to merge it directly to fsl-asoc-card instead of making a duplicated copy of that. Remember that getting code upstream should be a chance for us to improve thing. If you find painstaking to handle it in parallel, you can focus on the improvements of the WM8960 driver while I would help you on the dai- link part. How about this? Nicolin ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[alsa-devel][PATCH] ASoC: fsl: add imx-wm8960 machine driver
This imx-wm8960 device-tree-only machine driver works with sai driver and have below feature. * support codec master and slave mode * support headphone jack detect * support headphone and micphone jack event * support asrc-sai-wm8960 mode Signed-off-by: Zidan Wang zidan.w...@freescale.com --- .../devicetree/bindings/sound/imx-audio-wm8960.txt | 68 ++ sound/soc/fsl/Kconfig | 13 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/imx-wm8960.c | 711 + 4 files changed, 794 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-wm8960.txt create mode 100644 sound/soc/fsl/imx-wm8960.c diff --git a/Documentation/devicetree/bindings/sound/imx-audio-wm8960.txt b/Documentation/devicetree/bindings/sound/imx-audio-wm8960.txt new file mode 100644 index 000..300d027 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/imx-audio-wm8960.txt @@ -0,0 +1,68 @@ +Freescale i.MX audio complex with WM8960 codec + +Required properties: + + - compatible : fsl,imx-audio-wm8960 + + - model : The user-visible name of this sound complex + + - audio-codec: The phandle of the WM8960 audio codec + + - hp-det : ADCLRC/GPIO1, LINPUT3/JD2 and RINPUT3/JD3 pins can + be selected as headphone jack detect inputs to + automatically disable the speaker output and enable + the headphone output. + hp-det = hp-det-pin hp-det-polarity; + hp-det-pin = 1: ADCLRC/GPIO1 used as detect pin + hp-det-pin = 2: LINPUT3/JD2 used as detect pin + hp-det-pin = 3: RINPUT3/JD3 used as detect pin + hp-det-polarity = 0: hp detect high for headphone + hp-det-polarity = 1: hp detect high for speaker + + - codec-master : If codec-master present, codec works as master. + Otherwise, codec works as slave. + + - audio-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. Valid names could be power supplies, WM8962 + pins, and the jacks on the board: + + Power supplies: + * MICB + + Board connectors: + * Hp MIC + * Main MIC + * Headset Jack + * Ext Spk + +Example: + +sound { + compatible = fsl,imx6ul-evk-wm8960, + fsl,imx-audio-wm8960; + model = wm8960-audio; + cpu-dai = sai2; + audio-codec = codec; + asrc-controller = asrc; + codec-master; + hp-det = 3 0; + audio-routing = + Headset Jack, HP_L, + Headset Jack, HP_R, + Ext Spk, SPK_LP, + Ext Spk, SPK_LN, + Ext Spk, SPK_RP, + Ext Spk, SPK_RN, + LINPUT2, Hp MIC, + LINPUT3, Hp MIC, + RINPUT1, Main MIC, + RINPUT2, Main MIC, + Hp MIC, MICB, + Main MIC, MICB, + CPU-Playback, ASRC-Playback, + Playback, CPU-Playback, + ASRC-Capture, CPU-Capture, + CPU-Capture, Capture; +}; diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 19c302b..0d9aa56 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -229,6 +229,19 @@ config SND_SOC_EUKREA_TLV320 Enable I2S based access to the TLV320AIC23B codec attached to the SSI interface +config SND_SOC_IMX_WM8960 + tristate SoC Audio support for i.MX boards with wm8960 + depends on OF I2C + select SND_SOC_WM8960 + select SND_SOC_IMX_PCM_DMA + select SND_SOC_FSL_SAI + select SND_SOC_FSL_UTILS + select SND_KCTL_JACK + help +SoC Audio support for i.MX boards with WM8960 +Say Y if you want to add support for SoC audio on an i.MX board with +a wm8960 codec. + config SND_SOC_IMX_WM8962 tristate SoC Audio support for i.MX boards with wm8962 depends on OF I2C INPUT diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index d28dc25..84a9a10 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -54,6 +54,7 @@ snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o snd-soc-wm1133-ev1-objs := wm1133-ev1.o snd-soc-imx-es8328-objs := imx-es8328.o
Re: [alsa-devel][PATCH] ASoC: fsl: add imx-wm8960 machine driver
On Wed, Jun 10, 2015 at 04:26:27PM +0800, Zidan Wang wrote: + - hp-det : ADCLRC/GPIO1, LINPUT3/JD2 and RINPUT3/JD3 pins can + be selected as headphone jack detect inputs to + automatically disable the speaker output and enable + the headphone output. + hp-det = hp-det-pin hp-det-polarity; + hp-det-pin = 1: ADCLRC/GPIO1 used as detect pin + hp-det-pin = 2: LINPUT3/JD2 used as detect pin + hp-det-pin = 3: RINPUT3/JD3 used as detect pin + hp-det-polarity = 0: hp detect high for headphone + hp-det-polarity = 1: hp detect high for speaker This looks like something that should be in the DT binding for the CODEC, not the machine driver. +static int hp_set_status_check(void *data) +{ Why is this in the driver? + hp_status = gpio_get_value(priv-hp_set_gpio) ? 1 : 0; gpio_get_value() already returns a boolean. + if (hp_status != priv-hp_active_low) { + snprintf(buf, 32, STATE=%d, 2); + snd_soc_dapm_disable_pin(priv-codec-dapm, Ext Spk); + snd_soc_dapm_disable_pin(priv-codec-dapm, Main MIC); + ret = imx_hp_set_gpio.report; The generic jack code already has support for disabling and enabling pins, though disabling the speaker looks like a policy decision which probably doesn't belong here. + /* + * As the hp MIC only connect the input for left channel, we + * need to route it for right channel. + */ + snd_soc_update_bits(priv-codec, WM8960_ADDCTL1, 32, 12); This looks like routing which we'd expect userspace to be doing. + snd_kctl_jack_report(priv-snd_card, priv-headset_kctl, 1); Use the ASoC level helpers. + envp[0] = NAME=headset; + envp[1] = buf; + envp[2] = NULL; + kobject_uevent_env(pdev-dev.kobj, KOBJ_CHANGE, envp); + kfree(buf); Let the core deal with notifying userspace - it looks like you want to implement extcon integration there. + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); + if (ret) { + dev_err(dev, failed to set cpu dai fmt: %d\n, ret); + return ret; + } + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, fmt); + if (ret) { + dev_err(dev, failed to set codec dai fmt: %d\n, ret); + return ret; + } Initialise these in the dai_link structure. + for (i = 0; i ARRAY_SIZE(sysclk_divs); ++i) { + if (sysclk_divs[i] == -1) + continue; + sysclk /= sysclk_divs[i]; + for (j = 0; j ARRAY_SIZE(dac_divs); ++j) { + if (sysclk == sample_rate * dac_divs[j]) { + for (k = 0; k ARRAY_SIZE(bclk_divs); ++k) + if (sysclk == bclk * bclk_divs[k] / 10) + break; + if (k != ARRAY_SIZE(bclk_divs)) + break; + } + } + if (j != ARRAY_SIZE(dac_divs)) + break; + } + if (i != ARRAY_SIZE(sysclk_divs)) { + /* Set codec sysclk */ + snd_soc_dai_set_sysclk(codec_dai, +WM8960_SYSCLK_MCLK, sysclk, 0); + snd_soc_dai_set_clkdiv(codec_dai, WM8960_SYSCLKDIV, i 1); + return 0; + } Better, upgrade the CODEC driver to do this. + /* codec mclk should be enabled early to avoid jack detect error */ + ret = clk_prepare_enable(data-codec_clk); + if (ret) { + dev_err(card-dev, Failed to enable MCLK: %d\n, ret); + return ret; + } Similarly integrating clock API support into the CODEC is better - it makes all the DT stuff work a lot more smoothly and avoids things having to get duplicated. signature.asc Description: Digital signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [alsa-devel][PATCH] ASoC: fsl: add imx-wm8960 machine driver
On Wed, Jun 10, 2015 at 04:26:27PM +0800, Zidan Wang wrote: This imx-wm8960 device-tree-only machine driver works with sai driver and have below feature. * support codec master and slave mode * support headphone jack detect * support headphone and micphone jack event * support asrc-sai-wm8960 mode Signed-off-by: Zidan Wang zidan.w...@freescale.com Above all, could you merge this into fsl-asoc-card? It'd be nicer to have jack detection over there. And we can put PLL settings to the codec driver as Mark suggested. Thanks Nicolin --- .../devicetree/bindings/sound/imx-audio-wm8960.txt | 68 ++ sound/soc/fsl/Kconfig | 13 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/imx-wm8960.c | 711 + 4 files changed, 794 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-wm8960.txt create mode 100644 sound/soc/fsl/imx-wm8960.c diff --git a/Documentation/devicetree/bindings/sound/imx-audio-wm8960.txt b/Documentation/devicetree/bindings/sound/imx-audio-wm8960.txt new file mode 100644 index 000..300d027 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/imx-audio-wm8960.txt @@ -0,0 +1,68 @@ +Freescale i.MX audio complex with WM8960 codec + +Required properties: + + - compatible : fsl,imx-audio-wm8960 + + - model: The user-visible name of this sound complex + + - audio-codec : The phandle of the WM8960 audio codec + + - hp-det : ADCLRC/GPIO1, LINPUT3/JD2 and RINPUT3/JD3 pins can + be selected as headphone jack detect inputs to + automatically disable the speaker output and enable + the headphone output. + hp-det = hp-det-pin hp-det-polarity; + hp-det-pin = 1: ADCLRC/GPIO1 used as detect pin + hp-det-pin = 2: LINPUT3/JD2 used as detect pin + hp-det-pin = 3: RINPUT3/JD3 used as detect pin + hp-det-polarity = 0: hp detect high for headphone + hp-det-polarity = 1: hp detect high for speaker + + - codec-master : If codec-master present, codec works as master. + Otherwise, codec works as slave. + + - audio-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. Valid names could be power supplies, WM8962 + pins, and the jacks on the board: + + Power supplies: +* MICB + + Board connectors: +* Hp MIC +* Main MIC +* Headset Jack +* Ext Spk + +Example: + +sound { + compatible = fsl,imx6ul-evk-wm8960, +fsl,imx-audio-wm8960; + model = wm8960-audio; + cpu-dai = sai2; + audio-codec = codec; + asrc-controller = asrc; + codec-master; + hp-det = 3 0; + audio-routing = + Headset Jack, HP_L, + Headset Jack, HP_R, + Ext Spk, SPK_LP, + Ext Spk, SPK_LN, + Ext Spk, SPK_RP, + Ext Spk, SPK_RN, + LINPUT2, Hp MIC, + LINPUT3, Hp MIC, + RINPUT1, Main MIC, + RINPUT2, Main MIC, + Hp MIC, MICB, + Main MIC, MICB, + CPU-Playback, ASRC-Playback, + Playback, CPU-Playback, + ASRC-Capture, CPU-Capture, + CPU-Capture, Capture; +}; diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 19c302b..0d9aa56 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -229,6 +229,19 @@ config SND_SOC_EUKREA_TLV320 Enable I2S based access to the TLV320AIC23B codec attached to the SSI interface +config SND_SOC_IMX_WM8960 + tristate SoC Audio support for i.MX boards with wm8960 + depends on OF I2C + select SND_SOC_WM8960 + select SND_SOC_IMX_PCM_DMA + select SND_SOC_FSL_SAI + select SND_SOC_FSL_UTILS + select SND_KCTL_JACK + help + SoC Audio support for i.MX boards with WM8960 + Say Y if you want to add support for SoC audio on an i.MX board with + a wm8960 codec. + config SND_SOC_IMX_WM8962 tristate SoC Audio support for i.MX boards with wm8962 depends on OF I2C INPUT diff --git a/sound/soc/fsl/Makefile