From: Chen-Yu Tsai <wens@csie.org>
To: Stefan Mavrodiev <stefan@olimex.com>
Cc: David Airlie <airlied@linux.ie>,
linux-sunxi <linux-sunxi@googlegroups.com>,
open list <linux-kernel@vger.kernel.org>,
Vinod Koul <vkoul@kernel.org>,
"open list:DRM DRIVERS FOR ALLWINNER A10"
<dri-devel@lists.freedesktop.org>,
"open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM"
<dmaengine@vger.kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
"moderated list:ARM/Allwinner sunXi SoC support"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [linux-sunxi] [PATCH 2/2] drm: sun4i: hdmi: Add support for sun4i HDMI encoder audio
Date: Sat, 11 Jan 2020 00:30:53 +0800 [thread overview]
Message-ID: <CAGb2v670FN7-dyjQuL+gyagupm5pr+z1ZWGG8E8YnYJA0aKPEA@mail.gmail.com> (raw)
In-Reply-To: <20200110141140.28527-3-stefan@olimex.com>
On Fri, Jan 10, 2020 at 10:12 PM Stefan Mavrodiev <stefan@olimex.com> wrote:
>
> Add HDMI audio support for the sun4i-hdmi encoder, used on
> the older Allwinner chips - A10, A20, A31.
>
> Most of the code is based on the BSP implementation. In it
> dditional formats are supported (S20_3LE and S24_LE), however
> there where some problems with them and only S16_LE is left.
>
> Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
> ---
> drivers/gpu/drm/sun4i/Kconfig | 1 +
> drivers/gpu/drm/sun4i/Makefile | 1 +
> drivers/gpu/drm/sun4i/sun4i_hdmi.h | 30 ++
> drivers/gpu/drm/sun4i/sun4i_hdmi_audio.c | 375 +++++++++++++++++++++++
> drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 4 +
> 5 files changed, 411 insertions(+)
> create mode 100644 drivers/gpu/drm/sun4i/sun4i_hdmi_audio.c
>
> diff --git a/drivers/gpu/drm/sun4i/Kconfig b/drivers/gpu/drm/sun4i/Kconfig
> index 37e90e42943f..192b732b10cd 100644
> --- a/drivers/gpu/drm/sun4i/Kconfig
> +++ b/drivers/gpu/drm/sun4i/Kconfig
> @@ -19,6 +19,7 @@ if DRM_SUN4I
> config DRM_SUN4I_HDMI
> tristate "Allwinner A10 HDMI Controller Support"
> default DRM_SUN4I
> + select SND_PCM_ELD
> help
> Choose this option if you have an Allwinner SoC with an HDMI
> controller.
> diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile
> index 0d04f2447b01..e2d82b451c36 100644
> --- a/drivers/gpu/drm/sun4i/Makefile
> +++ b/drivers/gpu/drm/sun4i/Makefile
> @@ -5,6 +5,7 @@ sun4i-frontend-y += sun4i_frontend.o
> sun4i-drm-y += sun4i_drv.o
> sun4i-drm-y += sun4i_framebuffer.o
>
> +sun4i-drm-hdmi-y += sun4i_hdmi_audio.o
> sun4i-drm-hdmi-y += sun4i_hdmi_ddc_clk.o
> sun4i-drm-hdmi-y += sun4i_hdmi_enc.o
> sun4i-drm-hdmi-y += sun4i_hdmi_i2c.o
> diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi.h b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
> index 7ad3f06c127e..456964e681b0 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h
> +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
> @@ -42,7 +42,32 @@
> #define SUN4I_HDMI_VID_TIMING_POL_VSYNC BIT(1)
> #define SUN4I_HDMI_VID_TIMING_POL_HSYNC BIT(0)
>
> +#define SUN4I_HDMI_AUDIO_CTRL_REG 0x040
> +#define SUN4I_HDMI_AUDIO_CTRL_ENABLE BIT(31)
> +#define SUN4I_HDMI_AUDIO_CTRL_RESET BIT(30)
> +
> +#define SUN4I_HDMI_AUDIO_FMT_REG 0x048
> +#define SUN4I_HDMI_AUDIO_FMT_SRC BIT(31)
> +#define SUN4I_HDMI_AUDIO_FMT_LAYOUT BIT(3)
> +#define SUN4I_HDMI_AUDIO_FMT_CH_CFG(n) (n - 1)
> +#define SUN4I_HDMI_AUDIO_FMT_CH_CFG_MASK GENMASK(2, 0)
> +
> +#define SUN4I_HDMI_AUDIO_PCM_REG 0x4c
> +#define SUN4I_HDMI_AUDIO_PCM_CH_MAP(n, m) ((m - 1) << (n * 4))
> +#define SUN4I_HDMI_AUDIO_PCM_CH_MAP_MASK(n) (GENMASK(2, 0) << (n * 4))
> +
> +#define SUN4I_HDMI_AUDIO_CTS_REG 0x050
> +#define SUN4I_HDMI_AUDIO_CTS(n) (n & GENMASK(19, 0))
> +
> +#define SUN4I_HDMI_AUDIO_N_REG 0x054
> +#define SUN4I_HDMI_AUDIO_N(n) (n & GENMASK(19, 0))
> +
> +#define SUN4I_HDMI_AUDIO_STAT0_REG 0x58
> +#define SUN4I_HDMI_AUDIO_STAT0_FREQ(n) (n << 24)
> +#define SUN4I_HDMI_AUDIO_STAT0_FREQ_MASK GENMASK(27, 24)
> +
> #define SUN4I_HDMI_AVI_INFOFRAME_REG(n) (0x080 + (n))
> +#define SUN4I_HDMI_AUDIO_INFOFRAME_REG(n) (0x0a0 + (n))
>
> #define SUN4I_HDMI_PAD_CTRL0_REG 0x200
> #define SUN4I_HDMI_PAD_CTRL0_BIASEN BIT(31)
> @@ -283,9 +308,13 @@ struct sun4i_hdmi {
> struct regmap_field *field_ddc_sda_en;
> struct regmap_field *field_ddc_sck_en;
>
> + u8 hdmi_audio_channels;
> +
> struct sun4i_drv *drv;
>
> bool hdmi_monitor;
> + bool hdmi_audio;
> +
> struct cec_adapter *cec_adap;
>
> const struct sun4i_hdmi_variant *variant;
> @@ -294,5 +323,6 @@ struct sun4i_hdmi {
> int sun4i_ddc_create(struct sun4i_hdmi *hdmi, struct clk *clk);
> int sun4i_tmds_create(struct sun4i_hdmi *hdmi);
> int sun4i_hdmi_i2c_create(struct device *dev, struct sun4i_hdmi *hdmi);
> +int sun4i_hdmi_audio_create(struct sun4i_hdmi *hdmi);
>
> #endif /* _SUN4I_HDMI_H_ */
> diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_audio.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_audio.c
> new file mode 100644
> index 000000000000..b6d4199d15ce
> --- /dev/null
> +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_audio.c
> @@ -0,0 +1,375 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2020 Olimex Ltd.
> + * Author: Stefan Mavrodiev <stefan@olimex.com>
> + */
> +#include <linux/dma-mapping.h>
> +#include <linux/dmaengine.h>
> +#include <linux/module.h>
> +#include <linux/of_dma.h>
> +#include <linux/regmap.h>
> +
> +#include <drm/drm_print.h>
> +
> +#include <sound/dmaengine_pcm.h>
> +#include <sound/pcm_drm_eld.h>
> +#include <sound/pcm_params.h>
> +#include <sound/soc.h>
I would drop the ASoC stuff and just do a standard ALSA driver.
You really don't gain anything from using ASoC, since this is
just a really standard PCM DMA interface plus some controls.
There aren't multiple components that need to be strung together.
ChenYu
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2020-01-10 16:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 14:11 [PATCH 0/2] Add support for sun4i HDMI audio Stefan Mavrodiev
2020-01-10 14:11 ` [PATCH 1/2] dmaengine: sun4i: Add support for cyclic requests with dedicated DMA Stefan Mavrodiev
2020-01-10 16:18 ` Maxime Ripard
2020-01-15 12:31 ` Vinod Koul
2020-01-15 17:07 ` Maxime Ripard
2020-01-21 8:35 ` Vinod Koul
2020-01-21 11:37 ` Stefan Mavrodiev
2020-01-21 12:14 ` Vinod Koul
2020-01-10 14:11 ` [PATCH 2/2] drm: sun4i: hdmi: Add support for sun4i HDMI encoder audio Stefan Mavrodiev
2020-01-10 16:26 ` Maxime Ripard
2020-01-14 9:04 ` Stefan Mavrodiev
2020-01-15 8:32 ` Maxime Ripard
2020-01-15 12:23 ` Stefan Mavrodiev
2020-01-10 16:30 ` Chen-Yu Tsai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGb2v670FN7-dyjQuL+gyagupm5pr+z1ZWGG8E8YnYJA0aKPEA@mail.gmail.com \
--to=wens@csie.org \
--cc=airlied@linux.ie \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=stefan@olimex.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).