From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE0ACC33CA3 for ; Fri, 10 Jan 2020 16:31:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC8F4206ED for ; Fri, 10 Jan 2020 16:31:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BV/64D5x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC8F4206ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csie.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J9aPelV5Snz9LJwUvLWIdpO4xFvJu53nguA7NUimx8o=; b=BV/64D5xk79nTS 2HlQfhAOz9qVm8OIml+zorDsSf0bi1DpoFP8ystXn+sav48MnWVvBClufXbZgf2J4F979w1f5NjVO x0is+vOhd85IDI/zGAtIvSMcTte6qtsLFz47mxgUyfS262Mi2+ORSA5PhdCDtQna3gcF/CJ3cefHp l5eUEhYARO/3kAPE9XRtfJjSMQtyFqkjMz9SS8AgYHDV3MlFg/kUEIOr3D3F5QxKylmmmgeR+FoKh E8l+QX4P3+UDP0X0ZfXvG0Dnh8dLFNMtDINMkjSGkkZy6UGdumpDJPBhX58YoZyk3NNQVEhlBebR7 YRWN6FwiCOQIR5uMq4yw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipxBq-0002Sp-VG; Fri, 10 Jan 2020 16:31:14 +0000 Received: from mail-ed1-f67.google.com ([209.85.208.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipxBm-0002RF-EP for linux-arm-kernel@lists.infradead.org; Fri, 10 Jan 2020 16:31:12 +0000 Received: by mail-ed1-f67.google.com with SMTP id dc19so2077883edb.10 for ; Fri, 10 Jan 2020 08:31:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BcakXweHEcQflg8HJoYvX703zzGZOe1NoqnogCk40Mc=; b=h429rkg3R9LfMAjgOHAEN7Zkf0Ae9vTvxwuhCpMDm2GzE099iisVIkhOUp2XXstsj2 a8Q4FRWdXLF+TU9k/E3nkfCr9qg5ZwYMcQSzjeWeOeXPYQ7VDw+VdWcgrhl/dt9LxJEv EULmftHMyyEkL6vErzLltUsap6hqWKp4lVmNTBDxtzwf9MzI8omHEjqa6OJE3gvgriI1 TcP/XFJyVOKsZnGITacfIZgfDQ/8mHYfZIcmpDiuzOx0tB/eV2ptadudLJIQhDXQ8DQZ sE8fKeZsopo5BtuLB/jcaxPixaJbL0j1IvejBGmFMDpeD2nXpOje4+vdgy6ufqg+TNc1 dr5Q== X-Gm-Message-State: APjAAAWGJblWrTVDcVaascTV85+0hX8GMa53CIVum5yEmurW9teBT9GB +OMtd3WZ+i/qCcNgTIJPTdxm9RYlxR8= X-Google-Smtp-Source: APXvYqzKkel2aWOViBKZvuvZ/OvI89n8FC3tr4DFHzSYI7bG4f4G9ZoH6yzxwyz+PTehOVSYZRvASw== X-Received: by 2002:a50:ed11:: with SMTP id j17mr4564012eds.38.1578673867679; Fri, 10 Jan 2020 08:31:07 -0800 (PST) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id t19sm54365eju.10.2020.01.10.08.31.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jan 2020 08:31:07 -0800 (PST) Received: by mail-wr1-f41.google.com with SMTP id c9so2385977wrw.8 for ; Fri, 10 Jan 2020 08:31:07 -0800 (PST) X-Received: by 2002:adf:ef4e:: with SMTP id c14mr4522664wrp.142.1578673866678; Fri, 10 Jan 2020 08:31:06 -0800 (PST) MIME-Version: 1.0 References: <20200110141140.28527-1-stefan@olimex.com> <20200110141140.28527-3-stefan@olimex.com> In-Reply-To: <20200110141140.28527-3-stefan@olimex.com> From: Chen-Yu Tsai Date: Sat, 11 Jan 2020 00:30:53 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [linux-sunxi] [PATCH 2/2] drm: sun4i: hdmi: Add support for sun4i HDMI encoder audio To: Stefan Mavrodiev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200110_083110_487759_F395B88A X-CRM114-Status: GOOD ( 20.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-sunxi , open list , Maxime Ripard , Vinod Koul , "open list:DRM DRIVERS FOR ALLWINNER A10" , Daniel Vetter , "open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM" , Dan Williams , "moderated list:ARM/Allwinner sunXi SoC support" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jan 10, 2020 at 10:12 PM Stefan Mavrodiev 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 > --- > 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 > + */ > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include > +#include > +#include > +#include 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel