Re: [PATCH 9/9] drm: bridge/dw_hdmi-i2s-audio: add audio driver
Hi Russell, 在 2015/8/10 23:48, Russell King - ARM Linux 写道: On Sat, Aug 08, 2015 at 05:10:47PM +0100, Russell King wrote: From: Yakir Yang Add ALSA based HDMI I2S audio driver for dw_hdmi. Sound card driver could connect to this codec through the codec dai name "dw-hdmi-i2s-audio". [Fixed IRQ name, MODULE_DESCRIPTION, MODULE_ALIAS in dw-hdmi-i2s-audio.c, and platform device name in dw-hdmi.c --rmk] Signed-off-by: Yakir Yang Signed-off-by: Russell King I'm dropping this patch after all as it no longer builds against modern kernels due to the reference to the removed snd_soc_jack_new(). Its replacement is at card level, and I don't think it's a simple case of replacing it here. Hmm... I would rather to fix it in my side, and then I could rebase on your series, is it okay ? - Yakir +static int snd_dw_hdmi_audio_probe(struct snd_soc_codec *codec) +{ + struct snd_dw_hdmi *dw = snd_soc_codec_get_drvdata(codec); + int ret; + + ret = snd_soc_jack_new(codec, "dw Jack", SND_JACK_LINEOUT, + >jack); ... +static const struct snd_soc_codec_driver dw_hdmi_audio = { + .probe = snd_dw_hdmi_audio_probe, + .dapm_widgets = snd_dw_hdmi_audio_widgets, + .num_dapm_widgets = ARRAY_SIZE(snd_dw_hdmi_audio_widgets), + .dapm_routes = snd_dw_hdmi_audio_routes, + .num_dapm_routes = ARRAY_SIZE(snd_dw_hdmi_audio_routes), +}; + +static int dw_hdmi_audio_probe(struct platform_device *pdev) +{ + struct dw_hdmi_audio_data *data = pdev->dev.platform_data; + struct snd_dw_hdmi *dw; + int ret; + + dw = devm_kzalloc(>dev, sizeof(*dw), GFP_KERNEL); + if (!dw) + return -ENOMEM; + + dw->data = *data; + dw->dev = >dev; + dw->is_jack_ready = false; + platform_set_drvdata(pdev, dw); + + ret = request_irq(dw->data.irq, snd_dw_hdmi_irq, IRQF_SHARED, + DRIVER_NAME, dw); + if (ret) { + dev_err(>dev, "request irq failed (%d)\n", ret); + return -EINVAL; + } + + ret = snd_soc_register_codec(>dev, _hdmi_audio, +_hdmi_audio_dai, 1); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 9/9] drm: bridge/dw_hdmi-i2s-audio: add audio driver
On Sat, Aug 08, 2015 at 05:10:47PM +0100, Russell King wrote: > From: Yakir Yang > > Add ALSA based HDMI I2S audio driver for dw_hdmi. Sound card > driver could connect to this codec through the codec dai name > "dw-hdmi-i2s-audio". > > [Fixed IRQ name, MODULE_DESCRIPTION, MODULE_ALIAS in > dw-hdmi-i2s-audio.c, and platform device name in dw-hdmi.c --rmk] > > Signed-off-by: Yakir Yang > Signed-off-by: Russell King I'm dropping this patch after all as it no longer builds against modern kernels due to the reference to the removed snd_soc_jack_new(). Its replacement is at card level, and I don't think it's a simple case of replacing it here. > +static int snd_dw_hdmi_audio_probe(struct snd_soc_codec *codec) > +{ > + struct snd_dw_hdmi *dw = snd_soc_codec_get_drvdata(codec); > + int ret; > + > + ret = snd_soc_jack_new(codec, "dw Jack", SND_JACK_LINEOUT, > +>jack); ... > +static const struct snd_soc_codec_driver dw_hdmi_audio = { > + .probe = snd_dw_hdmi_audio_probe, > + .dapm_widgets = snd_dw_hdmi_audio_widgets, > + .num_dapm_widgets = ARRAY_SIZE(snd_dw_hdmi_audio_widgets), > + .dapm_routes = snd_dw_hdmi_audio_routes, > + .num_dapm_routes = ARRAY_SIZE(snd_dw_hdmi_audio_routes), > +}; > + > +static int dw_hdmi_audio_probe(struct platform_device *pdev) > +{ > + struct dw_hdmi_audio_data *data = pdev->dev.platform_data; > + struct snd_dw_hdmi *dw; > + int ret; > + > + dw = devm_kzalloc(>dev, sizeof(*dw), GFP_KERNEL); > + if (!dw) > + return -ENOMEM; > + > + dw->data = *data; > + dw->dev = >dev; > + dw->is_jack_ready = false; > + platform_set_drvdata(pdev, dw); > + > + ret = request_irq(dw->data.irq, snd_dw_hdmi_irq, IRQF_SHARED, > + DRIVER_NAME, dw); > + if (ret) { > + dev_err(>dev, "request irq failed (%d)\n", ret); > + return -EINVAL; > + } > + > + ret = snd_soc_register_codec(>dev, _hdmi_audio, > + _hdmi_audio_dai, 1); -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 9/9] drm: bridge/dw_hdmi-i2s-audio: add audio driver
On Sat, Aug 08, 2015 at 05:10:47PM +0100, Russell King wrote: From: Yakir Yang y...@rock-chips.com Add ALSA based HDMI I2S audio driver for dw_hdmi. Sound card driver could connect to this codec through the codec dai name dw-hdmi-i2s-audio. [Fixed IRQ name, MODULE_DESCRIPTION, MODULE_ALIAS in dw-hdmi-i2s-audio.c, and platform device name in dw-hdmi.c --rmk] Signed-off-by: Yakir Yang y...@rock-chips.com Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk I'm dropping this patch after all as it no longer builds against modern kernels due to the reference to the removed snd_soc_jack_new(). Its replacement is at card level, and I don't think it's a simple case of replacing it here. +static int snd_dw_hdmi_audio_probe(struct snd_soc_codec *codec) +{ + struct snd_dw_hdmi *dw = snd_soc_codec_get_drvdata(codec); + int ret; + + ret = snd_soc_jack_new(codec, dw Jack, SND_JACK_LINEOUT, +dw-jack); ... +static const struct snd_soc_codec_driver dw_hdmi_audio = { + .probe = snd_dw_hdmi_audio_probe, + .dapm_widgets = snd_dw_hdmi_audio_widgets, + .num_dapm_widgets = ARRAY_SIZE(snd_dw_hdmi_audio_widgets), + .dapm_routes = snd_dw_hdmi_audio_routes, + .num_dapm_routes = ARRAY_SIZE(snd_dw_hdmi_audio_routes), +}; + +static int dw_hdmi_audio_probe(struct platform_device *pdev) +{ + struct dw_hdmi_audio_data *data = pdev-dev.platform_data; + struct snd_dw_hdmi *dw; + int ret; + + dw = devm_kzalloc(pdev-dev, sizeof(*dw), GFP_KERNEL); + if (!dw) + return -ENOMEM; + + dw-data = *data; + dw-dev = pdev-dev; + dw-is_jack_ready = false; + platform_set_drvdata(pdev, dw); + + ret = request_irq(dw-data.irq, snd_dw_hdmi_irq, IRQF_SHARED, + DRIVER_NAME, dw); + if (ret) { + dev_err(pdev-dev, request irq failed (%d)\n, ret); + return -EINVAL; + } + + ret = snd_soc_register_codec(pdev-dev, dw_hdmi_audio, + dw_hdmi_audio_dai, 1); -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 9/9] drm: bridge/dw_hdmi-i2s-audio: add audio driver
Hi Russell, 在 2015/8/10 23:48, Russell King - ARM Linux 写道: On Sat, Aug 08, 2015 at 05:10:47PM +0100, Russell King wrote: From: Yakir Yang y...@rock-chips.com Add ALSA based HDMI I2S audio driver for dw_hdmi. Sound card driver could connect to this codec through the codec dai name dw-hdmi-i2s-audio. [Fixed IRQ name, MODULE_DESCRIPTION, MODULE_ALIAS in dw-hdmi-i2s-audio.c, and platform device name in dw-hdmi.c --rmk] Signed-off-by: Yakir Yang y...@rock-chips.com Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk I'm dropping this patch after all as it no longer builds against modern kernels due to the reference to the removed snd_soc_jack_new(). Its replacement is at card level, and I don't think it's a simple case of replacing it here. Hmm... I would rather to fix it in my side, and then I could rebase on your series, is it okay ? - Yakir +static int snd_dw_hdmi_audio_probe(struct snd_soc_codec *codec) +{ + struct snd_dw_hdmi *dw = snd_soc_codec_get_drvdata(codec); + int ret; + + ret = snd_soc_jack_new(codec, dw Jack, SND_JACK_LINEOUT, + dw-jack); ... +static const struct snd_soc_codec_driver dw_hdmi_audio = { + .probe = snd_dw_hdmi_audio_probe, + .dapm_widgets = snd_dw_hdmi_audio_widgets, + .num_dapm_widgets = ARRAY_SIZE(snd_dw_hdmi_audio_widgets), + .dapm_routes = snd_dw_hdmi_audio_routes, + .num_dapm_routes = ARRAY_SIZE(snd_dw_hdmi_audio_routes), +}; + +static int dw_hdmi_audio_probe(struct platform_device *pdev) +{ + struct dw_hdmi_audio_data *data = pdev-dev.platform_data; + struct snd_dw_hdmi *dw; + int ret; + + dw = devm_kzalloc(pdev-dev, sizeof(*dw), GFP_KERNEL); + if (!dw) + return -ENOMEM; + + dw-data = *data; + dw-dev = pdev-dev; + dw-is_jack_ready = false; + platform_set_drvdata(pdev, dw); + + ret = request_irq(dw-data.irq, snd_dw_hdmi_irq, IRQF_SHARED, + DRIVER_NAME, dw); + if (ret) { + dev_err(pdev-dev, request irq failed (%d)\n, ret); + return -EINVAL; + } + + ret = snd_soc_register_codec(pdev-dev, dw_hdmi_audio, +dw_hdmi_audio_dai, 1); -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 9/9] drm: bridge/dw_hdmi-i2s-audio: add audio driver
From: Yakir Yang To: linux-rockc...@lists.infradead.org,alsa-de...@alsa-project.org,dri-de...@lists.freedesktop.org,linux-kernel@vger.kernel.org,linux-arm-ker...@lists.infradead.org Add ALSA based HDMI I2S audio driver for dw_hdmi. Sound card driver could connect to this codec through the codec dai name "dw-hdmi-i2s-audio". [Fixed IRQ name, MODULE_DESCRIPTION, MODULE_ALIAS in dw-hdmi-i2s-audio.c, and platform device name in dw-hdmi.c --rmk] Signed-off-by: Yakir Yang Signed-off-by: Russell King --- drivers/gpu/drm/bridge/Kconfig | 9 + drivers/gpu/drm/bridge/Makefile| 1 + drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c | 398 + drivers/gpu/drm/bridge/dw_hdmi.c | 24 +- drivers/gpu/drm/bridge/dw_hdmi.h | 3 + 5 files changed, 426 insertions(+), 9 deletions(-) create mode 100644 drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 204861bfb867..59e3f24c4918 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -14,6 +14,15 @@ config DRM_DW_HDMI_AHB_AUDIO Designware HDMI block. This is used in conjunction with the i.MX6 HDMI driver. +config DRM_DW_HDMI_I2S_AUDIO + tristate "Synopsis Designware I2S Audio interface" + depends on DRM_DW_HDMI && SND + select SND_PCM + help + Support the I2S Audio interface which is part of the Synopsis + Designware HDMI block. This is used in conjunction with the + RK3288 HDMI driver. + config DRM_PTN3460 tristate "PTN3460 DP/LVDS bridge" depends on DRM diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index eb80dbbb8365..65a12390844a 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_PS8622) += ps8622.o obj-$(CONFIG_DRM_PTN3460) += ptn3460.o obj-$(CONFIG_DRM_DW_HDMI) += dw_hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw_hdmi-ahb-audio.o +obj-$(CONFIG_DRM_DW_HDMI_I2S_AUDIO) += dw_hdmi-i2s-audio.o diff --git a/drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c b/drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c new file mode 100644 index ..62d3d33642d0 --- /dev/null +++ b/drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c @@ -0,0 +1,398 @@ +/* + * DesignWare HDMI audio driver + * + * 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. + * + * Written and tested against the Designware HDMI Tx found in RK3288. + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "dw_hdmi-audio.h" + +#define DRIVER_NAME "dw-hdmi-i2s-audio" + +enum { + AUDIO_CONF1_DATWIDTH_MSK = 0x1F, + AUDIO_CONF1_DATAMODE_MSK = 0xE0, + AUDIO_DAIFMT_IIS = 0x0, + AUDIO_DAIFMT_RIGHT_J = 0x20, + AUDIO_DAIFMT_LEFT_J = 0x40, + AUDIO_DAIFMT_BURST_1 = 0x60, + AUDIO_DAIFMT_BURST_2 = 0x80, + AUDIO_CONF0_INTERFACE_MSK = BIT(5), + AUDIO_INPUTTYPE_IIS = 0x20, + AUDIO_INPUTTYPE_SPDIF = 0x00, + AUDIO_CONF0_I2SINEN_MSK = 0x0F, + AUDIO_CHANNELNUM_2 = 0x01, + AUDIO_CHANNELNUM_4 = 0x03, + AUDIO_CHANNELNUM_6 = 0x07, + AUDIO_CHANNELNUM_8 = 0x0F, + HDMI_PHY_HPD = BIT(1), + HDMI_PHY_STAT0 = 0x3004, + HDMI_AUD_CONF0 = 0x3100, + HDMI_AUD_CONF1 = 0x3101, + HDMI_AUD_INPUTCLKFS = 0x3206, +}; + +struct dw_audio_fmt { + int input_type; + int chan_num; + int sample_rate; + int word_length; + int dai_fmt; +}; + +struct snd_dw_hdmi { + struct device *dev; + struct dw_hdmi_audio_data data; + + bool is_jack_ready; + struct snd_soc_jack jack; + + bool is_playback_status; + struct dw_audio_fmt fmt; +}; + +static void hdmi_writel(struct snd_dw_hdmi *dw, u8 val, int offset) +{ + writel(val, dw->data.base + (offset << 2)); +} + +static u8 hdmi_readl(struct snd_dw_hdmi *dw, int offset) +{ + return readl(dw->data.base + (offset << 2)); +} + +static void hdmi_modl(struct snd_dw_hdmi *dw, u8 data, + u8 mask, unsigned reg) +{ + u8 val = hdmi_readl(dw, reg) & ~mask; + + val |= data & mask; + hdmi_writel(dw, val, reg); +} + +int snd_dw_hdmi_jack_detect(struct snd_dw_hdmi *dw) +{ + u8 jack_status; + + if (!dw->is_jack_ready) + return -EINVAL; + + jack_status = !!(hdmi_readl(dw, HDMI_PHY_STAT0) & HDMI_PHY_HPD) ? + SND_JACK_LINEOUT : 0; + + snd_soc_jack_report(>jack, jack_status, SND_JACK_LINEOUT); + + return 0; +} + +static irqreturn_t snd_dw_hdmi_irq(int irq, void *dev_id) +{ + struct snd_dw_hdmi *dw = dev_id; + + snd_dw_hdmi_jack_detect(dw); + +
[PATCH 9/9] drm: bridge/dw_hdmi-i2s-audio: add audio driver
From: Yakir Yang y...@rock-chips.com To: linux-rockc...@lists.infradead.org,alsa-de...@alsa-project.org,dri-de...@lists.freedesktop.org,linux-kernel@vger.kernel.org,linux-arm-ker...@lists.infradead.org Add ALSA based HDMI I2S audio driver for dw_hdmi. Sound card driver could connect to this codec through the codec dai name dw-hdmi-i2s-audio. [Fixed IRQ name, MODULE_DESCRIPTION, MODULE_ALIAS in dw-hdmi-i2s-audio.c, and platform device name in dw-hdmi.c --rmk] Signed-off-by: Yakir Yang y...@rock-chips.com Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk --- drivers/gpu/drm/bridge/Kconfig | 9 + drivers/gpu/drm/bridge/Makefile| 1 + drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c | 398 + drivers/gpu/drm/bridge/dw_hdmi.c | 24 +- drivers/gpu/drm/bridge/dw_hdmi.h | 3 + 5 files changed, 426 insertions(+), 9 deletions(-) create mode 100644 drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 204861bfb867..59e3f24c4918 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -14,6 +14,15 @@ config DRM_DW_HDMI_AHB_AUDIO Designware HDMI block. This is used in conjunction with the i.MX6 HDMI driver. +config DRM_DW_HDMI_I2S_AUDIO + tristate Synopsis Designware I2S Audio interface + depends on DRM_DW_HDMI SND + select SND_PCM + help + Support the I2S Audio interface which is part of the Synopsis + Designware HDMI block. This is used in conjunction with the + RK3288 HDMI driver. + config DRM_PTN3460 tristate PTN3460 DP/LVDS bridge depends on DRM diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index eb80dbbb8365..65a12390844a 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_PS8622) += ps8622.o obj-$(CONFIG_DRM_PTN3460) += ptn3460.o obj-$(CONFIG_DRM_DW_HDMI) += dw_hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw_hdmi-ahb-audio.o +obj-$(CONFIG_DRM_DW_HDMI_I2S_AUDIO) += dw_hdmi-i2s-audio.o diff --git a/drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c b/drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c new file mode 100644 index ..62d3d33642d0 --- /dev/null +++ b/drivers/gpu/drm/bridge/dw_hdmi-i2s-audio.c @@ -0,0 +1,398 @@ +/* + * DesignWare HDMI audio driver + * + * 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. + * + * Written and tested against the Designware HDMI Tx found in RK3288. + */ +#include linux/io.h +#include linux/init.h +#include linux/kernel.h +#include linux/module.h +#include linux/device.h +#include linux/moduleparam.h + +#include sound/pcm.h +#include sound/soc.h +#include sound/core.h +#include sound/jack.h +#include sound/initval.h +#include sound/pcm_params.h +#include drm/bridge/dw_hdmi.h + +#include dw_hdmi-audio.h + +#define DRIVER_NAME dw-hdmi-i2s-audio + +enum { + AUDIO_CONF1_DATWIDTH_MSK = 0x1F, + AUDIO_CONF1_DATAMODE_MSK = 0xE0, + AUDIO_DAIFMT_IIS = 0x0, + AUDIO_DAIFMT_RIGHT_J = 0x20, + AUDIO_DAIFMT_LEFT_J = 0x40, + AUDIO_DAIFMT_BURST_1 = 0x60, + AUDIO_DAIFMT_BURST_2 = 0x80, + AUDIO_CONF0_INTERFACE_MSK = BIT(5), + AUDIO_INPUTTYPE_IIS = 0x20, + AUDIO_INPUTTYPE_SPDIF = 0x00, + AUDIO_CONF0_I2SINEN_MSK = 0x0F, + AUDIO_CHANNELNUM_2 = 0x01, + AUDIO_CHANNELNUM_4 = 0x03, + AUDIO_CHANNELNUM_6 = 0x07, + AUDIO_CHANNELNUM_8 = 0x0F, + HDMI_PHY_HPD = BIT(1), + HDMI_PHY_STAT0 = 0x3004, + HDMI_AUD_CONF0 = 0x3100, + HDMI_AUD_CONF1 = 0x3101, + HDMI_AUD_INPUTCLKFS = 0x3206, +}; + +struct dw_audio_fmt { + int input_type; + int chan_num; + int sample_rate; + int word_length; + int dai_fmt; +}; + +struct snd_dw_hdmi { + struct device *dev; + struct dw_hdmi_audio_data data; + + bool is_jack_ready; + struct snd_soc_jack jack; + + bool is_playback_status; + struct dw_audio_fmt fmt; +}; + +static void hdmi_writel(struct snd_dw_hdmi *dw, u8 val, int offset) +{ + writel(val, dw-data.base + (offset 2)); +} + +static u8 hdmi_readl(struct snd_dw_hdmi *dw, int offset) +{ + return readl(dw-data.base + (offset 2)); +} + +static void hdmi_modl(struct snd_dw_hdmi *dw, u8 data, + u8 mask, unsigned reg) +{ + u8 val = hdmi_readl(dw, reg) ~mask; + + val |= data mask; + hdmi_writel(dw, val, reg); +} + +int snd_dw_hdmi_jack_detect(struct snd_dw_hdmi *dw) +{ + u8 jack_status; + + if (!dw-is_jack_ready) + return -EINVAL; + + jack_status = !!(hdmi_readl(dw, HDMI_PHY_STAT0) HDMI_PHY_HPD) ? + SND_JACK_LINEOUT : 0; + +