From patchwork Tue Aug 2 05:56:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9260641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 788A060865 for ; Wed, 3 Aug 2016 01:32:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AD1228534 for ; Wed, 3 Aug 2016 01:32:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D9D02853D; Wed, 3 Aug 2016 01:32:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EF5D28534 for ; Wed, 3 Aug 2016 01:32:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D8CB6E6D2; Wed, 3 Aug 2016 01:31:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from relmlie1.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 3D7716E181 for ; Tue, 2 Aug 2016 05:56:08 +0000 (UTC) Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 02 Aug 2016 14:56:07 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 972B64C1A0; Tue, 2 Aug 2016 14:56:07 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 7819B1806F; Tue, 2 Aug 2016 14:56:07 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 705951800A; Tue, 2 Aug 2016 14:56:07 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id QAS30414; Tue, 2 Aug 2016 14:56:07 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'208";a="216466681" Received: from mail-sg2apc01lp0247.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.247]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 02 Aug 2016 14:56:05 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=x2Z3JzpR2R6RprnS4gTZE3tEQyKtccIByN3NyaFhL4I=; b=Z1pO761nJnIo2SWTKTLatkB0nTKCYPRurwkz4Cyh07Pu9brbJojT8BJj0WvaiyLKU+6mhFbJwWalUb7bqMr89PL9eXeLMqevJ1UfYRJg6eJeril5PaUmoZ0BmwB60oFxZCMGl48NTJVynl1emu7T7tLoCViLpY7oCdFxJ7voxQc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by PS1PR0601MB1452.apcprd06.prod.outlook.com (10.165.210.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Tue, 2 Aug 2016 05:56:00 +0000 Message-ID: <87ziovhgbs.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 2/2 v2] drm: bridge: add DesignWare HDMI I2S audio support User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") To: Mark Brown , David Airlie , Russell King In-Reply-To: <8737mniv03.wl%kuninori.morimoto.gx@renesas.com> References: <8737mniv03.wl%kuninori.morimoto.gx@renesas.com> Date: Tue, 2 Aug 2016 05:56:00 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR06CA0017.apcprd06.prod.outlook.com (10.164.91.27) To PS1PR0601MB1452.apcprd06.prod.outlook.com (10.165.210.156) X-MS-Office365-Filtering-Correlation-Id: dba7843a-a40a-432b-e111-08d3ba99aea9 X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1452; 2:Lepu1d9He7lZ7OexkiFv0LeHjfx21ZSFXOdPJH+vMyOmTuXd9gsoX9dtsLgrNxIVK5rWUMSbGuuUXuwfhz1/Pci5rhrKT2P7LG4MgmQiJdFXMlGg131Z2GndNemW4RH0hxx/7a0yWFahm8QwC+npohv1SoAM3CNho7Rcg2rDhhw4lh3XTfa+6ZeJ/Eu9BYoR; 3:FSlXMsSEeXltgANSWSzQF2EFNkUOXnb+E5EGGxYMs1ayQTO+Ikm1IrBWf4YVTzCVELn2DTR3iBEeFIXRtoJSSm3SOYBgEUHJwPbD5QkkZnbDaTpXawx6fVl9QNg+1DE7; 25:UZ9PA6uITMuht+Fh3hLiTC46RlV2ZhAHSHF39Ue/gskvuuWbkizP5mfK4oTEoLjjU9GH986VvRpqVn85XQdvhITVvoqZJf4CknMwEu5bCkfwFtSQdo/stTydsPo6yEOnO8/4sLqeu8m8LTKuF8t5SQ/JoHuXAdfGOOWDTarRKLzx+Lb8clLmWXnzIjcFc8Y+SWtwcnRrf2IVd5IWD2wLRpozr7ajWOwoIUC0TUTLW0oVWVM+22xNSgy8zg5a8r59qMK1us64Q2feGNiJEgH+Q3tu/2cA0xsZAi586jRKy1WgChPXW18k2U/iYoIUauXJV65T6UV0UWypTzHluJJ38TnM8Uiswpz5Ue7AilVAOE7//MnTi8LgN/ZjycFS5IjhIAyDYcxTpkPbRtEijP/H0Lo1eO4dXNFbCVct3peUkRI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:PS1PR0601MB1452; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1452; 31:LoA0yDnemoMXUPOKkmTQdub44ow0Vk1FeMliesCfMtoXqGhItONw1BZvKNlC3a4NPweDWk9cAiZQUqW1jehPb7/FhRJA8IEQc8bCPknoW5woKSOeLhNrnlPzhPkMRTv2tK88TU+uQPVeff01nEMJu45atsMbnWbxaHmztDNPrdfKVvoIN5QKrShggsTroFB9mzJJgrubM+e7nh61A32xgKYI2rqGH0JqGWGZp5N5oNo=; 20:W+MwLb1FEtTzHsJIb6kK8TMR2z0TCw8oCWlshyzGikI1XflcYSkAF7mrBEMC8/kvCVHUhBMW44amL95AunHT4qiB0CBRUY+APTToV56gRupDdi+57xPzLdp5BumVGisiteFJhptcZQW2s5AOGHH0AYboHu/+iqRzsTWrs3PA+AuNjRkDiX52XxkMkJXgFAreGIdCDMWw1+Ui/pSNIiD0szrCj0pqVejqIXukIhkoCRGgx+vvdUlG7wsDjLaVrOTXlzQ3zvRM66ciYUr92VU6UL6+mWXFpxQdKik7ybtbf9CuV8o2lpzEKvz6zwaHvekixFU7ZJuNfH0JdlfEvZVZKIiq5gbERG0dtTvi5GS0GeasFV98HSWBEmkNOQ+6qSVWFOY7qTqQw1mgygv/4dnF1JasFk2EkjwqcDUwRqnRBy1tRqVpmN7YfRTDJ51rfTBWxxQZmSe/KaDyacOmhilqqevLFg15RBT0q0Gz7PZBGhhZrFnjz0o4m3MIs/BJCkOs X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:PS1PR0601MB1452; BCL:0; PCL:0; RULEID:; SRVR:PS1PR0601MB1452; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1452; 4:18lK7gtEGRc/eqrzFY1DcW9u8JFsbq0Znu1uj9rgPKvrtW2aOr++OTDDUfkCdoB77xK4Fw60kTvOHH5MHSBMTBtLlExQt7YKjnURynHNvra6SS/3n4VVTtfdZ2KM97R+QQuE0a1h7LmSnzXaykT1N2Ww10+cErG0UAYcQ8ZTVf+aMDiNw5XH97czCLjfHGc30onucKzFrsx3asN1UH+EesYZKiwCF8jKiaLIUw66YbQBrLON9F1VHQ9Y8OYZjXe3nM+DfLB8LfE3/p6LAdoyJ4QxYCYdHIjBIl/l0/z/CDxOBkYPkcmCSKrQGp5q0NXiP4cm4sDggd5WWnicEJdB+QGJEKLsznOWbO9cjbJh+y2Ats+qbkWGntkXPfD/0c0wAeuYfAtr6O5BhDDF3EC1Zg== X-Forefront-PRVS: 0022134A87 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(83506001)(8676002)(81156014)(81166006)(50466002)(47776003)(305945005)(229853001)(46406003)(7736002)(7846002)(189998001)(4001350100001)(5001770100001)(97736004)(66066001)(8666005)(68736007)(2906002)(42186005)(92566002)(586003)(50986999)(76176999)(106356001)(53416004)(101416001)(4326007)(86362001)(575784001)(2950100001)(54356999)(6116002)(3846002)(77096005)(33646002)(105586002)(7416002)(69596002)(19580405001)(19580395003)(23726003)(36756003)(7059030)(2004002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR0601MB1452; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; PS1PR0601MB1452; 23:B6jjMDP3R+qu/Xev/N17sV/XQT22/0GrMGHZwlO?= =?us-ascii?Q?c87K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afnvTwdw6Jk=; 7:fsJBILOuCqi/ak5FNH/lLrULp80ki3w4XG7cL7LOkzUE1hyDIg21WIUwJJprsVt8WE18OUhTDu7Qb8bxlEXqMWjfMPBFEE5ZhT6NfSVm5FuwX+tHfQ3OUBNJFV1bCaswTcRienxGCWsibnLyq2w5G4oVdc8FoB5WNXp3dGGJfHjaHKYdMuYPTEdI6+V44VrTX8G3jxWy1k6fyGo7ig0BECe2rE8mtbgNnzbIsxVVjolELlOhp9vnPqBCVopHdHdW SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1452; 20:YI+96pOtnwz5+4k9Zx10yq8aYkGEMEjGWUoQDewrVuuLnD5Zz/QHEhUNca/TE0dJrLOhM7Ob+U1iJdyUK9n2A/3nd4/lO+VNeb3pkiLu7hOgN0N1lGWFUycvzjqi6rx63mVAgSHgIB4cclx9OpBGA7mmsFY91ZuljWvmdm8GVos= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2016 05:56:00.4876 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR0601MB1452 X-Mailman-Approved-At: Wed, 03 Aug 2016 01:30:22 +0000 Cc: Fabio Estevam , Linux-ALSA , Daniel Vetter , Koji Matsuoka , dri-devel@lists.freedesktop.org, Liam Girdwood , linux-renesas-soc@vger.kernel.org, Simon , Thierry Reding , linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current dw-hdmi is supporting sound via AHB bus, but it has I2S audio feature too. This patch adds I2S audio support to dw-hdmi. This HDMI I2S is supported by using ALSA SoC common HDMI encoder driver. Signed-off-by: Kuninori Morimoto --- v1 -> v2 - tidyup return value of snd_dw_hdmi_probe() drivers/gpu/drm/bridge/Kconfig | 8 ++ drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/dw-hdmi-audio.h | 7 ++ drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c | 130 +++++++++++++++++++++++++++++ drivers/gpu/drm/bridge/dw-hdmi.c | 22 ++++- drivers/gpu/drm/bridge/dw-hdmi.h | 21 +++++ 6 files changed, 187 insertions(+), 2 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 8f7423f..8e2a22d 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -32,6 +32,14 @@ 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 + select SND_SOC_HDMI_CODEC + help + Support the I2S Audio interface which is part of the Synopsis + Designware HDMI block. + config DRM_NXP_PTN3460 tristate "NXP PTN3460 DP/LVDS bridge" depends on OF diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index 96b13b3..1af92ad 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -3,6 +3,7 @@ ccflags-y := -Iinclude/drm obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.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 obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/ diff --git a/drivers/gpu/drm/bridge/dw-hdmi-audio.h b/drivers/gpu/drm/bridge/dw-hdmi-audio.h index 91f631b..fd1f745 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi-audio.h +++ b/drivers/gpu/drm/bridge/dw-hdmi-audio.h @@ -11,4 +11,11 @@ struct dw_hdmi_audio_data { u8 *eld; }; +struct dw_hdmi_i2s_audio_data { + struct dw_hdmi *hdmi; + + void (*write)(struct dw_hdmi *hdmi, u8 val, int offset); + u8 (*read)(struct dw_hdmi *hdmi, int offset); +}; + #endif 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 0000000..7dd2091 --- /dev/null +++ b/drivers/gpu/drm/bridge/dw-hdmi-i2s-audio.c @@ -0,0 +1,130 @@ +/* + * dw-hdmi-i2s-audio.c + * + * Copyright (c) 2016 Kuninori Morimoto + * + * 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. + */ +#include + +#include + +#include "dw-hdmi.h" +#include "dw-hdmi-audio.h" + +#define DRIVER_NAME "dw-hdmi-i2s-audio" + +static inline void hdmi_write(struct dw_hdmi_i2s_audio_data *audio, + u8 val, int offset) +{ + struct dw_hdmi *hdmi = audio->hdmi; + + audio->write(hdmi, val, offset); +} + +static inline u8 hdmi_read(struct dw_hdmi_i2s_audio_data *audio, int offset) +{ + struct dw_hdmi *hdmi = audio->hdmi; + + return audio->read(hdmi, offset); +} + +static int dw_hdmi_i2s_hw_params(struct device *dev, void *data, + struct hdmi_codec_daifmt *fmt, + struct hdmi_codec_params *hparms) +{ + struct dw_hdmi_i2s_audio_data *audio = data; + struct dw_hdmi *hdmi = audio->hdmi; + u8 conf0 = 0; + u8 conf1 = 0; + u8 inputclkfs = 0; + + /* it cares I2S only */ + if ((fmt->fmt != HDMI_I2S) || + (fmt->bit_clk_master | fmt->frame_clk_master)) { + dev_err(dev, "unsupported format/settings\n"); + return -EINVAL; + } + + inputclkfs = HDMI_AUD_INPUTCLKFS_64FS; + conf0 = HDMI_AUD_CONF0_I2S_ALL_ENABLE; + + switch (hparms->sample_width) { + case 16: + conf1 = HDMI_AUD_CONF1_WIDTH_16; + break; + case 24: + case 32: + conf1 = HDMI_AUD_CONF1_WIDTH_24; + break; + } + + dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate); + + hdmi_write(audio, inputclkfs, HDMI_AUD_INPUTCLKFS); + hdmi_write(audio, conf0, HDMI_AUD_CONF0); + hdmi_write(audio, conf1, HDMI_AUD_CONF1); + + dw_hdmi_audio_enable(hdmi); + + return 0; +} + +static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data) +{ + struct dw_hdmi_i2s_audio_data *audio = data; + struct dw_hdmi *hdmi = audio->hdmi; + + dw_hdmi_audio_disable(hdmi); + + hdmi_write(audio, HDMI_AUD_CONF0_SW_RESET, HDMI_AUD_CONF0); +} + +static struct hdmi_codec_ops dw_hdmi_i2s_ops = { + .hw_params = dw_hdmi_i2s_hw_params, + .audio_shutdown = dw_hdmi_i2s_audio_shutdown, +}; + +static int snd_dw_hdmi_probe(struct platform_device *pdev) +{ + struct dw_hdmi_i2s_audio_data *audio = pdev->dev.platform_data; + struct platform_device_info pdevinfo; + struct hdmi_codec_pdata pdata; + struct platform_device *platform; + + + pdata.ops = &dw_hdmi_i2s_ops; + pdata.i2s = 1; + pdata.max_i2s_channels = 6; + pdata.data = audio; + + memset(&pdevinfo, 0, sizeof(pdevinfo)); + pdevinfo.parent = pdev->dev.parent; + pdevinfo.id = PLATFORM_DEVID_AUTO; + pdevinfo.name = HDMI_CODEC_DRV_NAME; + pdevinfo.data = &pdata; + pdevinfo.size_data = sizeof(pdata); + pdevinfo.dma_mask = DMA_BIT_MASK(32); + + platform = platform_device_register_full(&pdevinfo); + if (IS_ERR_OR_NULL(platform)) + return PTR_ERR(platform); + + return 0; +} + +static struct platform_driver snd_dw_hdmi_driver = { + .probe = snd_dw_hdmi_probe, + .driver = { + .name = DRIVER_NAME, + .owner = THIS_MODULE, + }, +}; +module_platform_driver(snd_dw_hdmi_driver); + +MODULE_AUTHOR("Kuninori Morimoto "); +MODULE_DESCRIPTION("Synopsis Designware HDMI I2S ALSA SoC interface"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRIVER_NAME); diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index 55e73e8..e9ba59e 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -2013,10 +2013,11 @@ int dw_hdmi_bind(struct device *dev, struct device *master, struct device_node *np = dev->of_node; struct platform_device_info pdevinfo; struct device_node *ddc_node; - struct dw_hdmi_audio_data audio; struct dw_hdmi *hdmi; int ret; u32 val = 1; + u8 config0; + u8 config1; hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); if (!hdmi) @@ -2185,7 +2186,12 @@ int dw_hdmi_bind(struct device *dev, struct device *master, pdevinfo.parent = dev; pdevinfo.id = PLATFORM_DEVID_AUTO; - if (hdmi_readb(hdmi, HDMI_CONFIG1_ID) & HDMI_CONFIG1_AHB) { + config0 = hdmi_readb(hdmi, HDMI_CONFIG0_ID); + config1 = hdmi_readb(hdmi, HDMI_CONFIG1_ID); + + if (config1 & HDMI_CONFIG1_AHB) { + struct dw_hdmi_audio_data audio; + audio.phys = iores->start; audio.base = hdmi->regs; audio.irq = irq; @@ -2197,6 +2203,18 @@ int dw_hdmi_bind(struct device *dev, struct device *master, pdevinfo.size_data = sizeof(audio); pdevinfo.dma_mask = DMA_BIT_MASK(32); hdmi->audio = platform_device_register_full(&pdevinfo); + } else if (config0 & HDMI_CONFIG0_I2S) { + struct dw_hdmi_i2s_audio_data audio; + + audio.hdmi = hdmi; + audio.write = hdmi_writeb; + audio.read = hdmi_readb; + + pdevinfo.name = "dw-hdmi-i2s-audio"; + pdevinfo.data = &audio; + pdevinfo.size_data = sizeof(audio); + pdevinfo.dma_mask = DMA_BIT_MASK(32); + hdmi->audio = platform_device_register_full(&pdevinfo); } /* Unmute I2CM interrupts and reset HDMI DDC I2C master controller */ diff --git a/drivers/gpu/drm/bridge/dw-hdmi.h b/drivers/gpu/drm/bridge/dw-hdmi.h index fc9a560..c8bdbf2 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.h +++ b/drivers/gpu/drm/bridge/dw-hdmi.h @@ -545,6 +545,10 @@ #define HDMI_I2CM_FS_SCL_LCNT_0_ADDR 0x7E12 enum { + +/* CONFIG0_ID field values */ + HDMI_CONFIG0_I2S = 0x10, + /* CONFIG1_ID field values */ HDMI_CONFIG1_AHB = 0x01, @@ -887,6 +891,17 @@ enum { HDMI_PHY_I2CM_CTLINT_ADDR_ARBITRATION_POL = 0x08, HDMI_PHY_I2CM_CTLINT_ADDR_ARBITRATION_MASK = 0x04, +/* AUD_CONF0 field values */ + HDMI_AUD_CONF0_SW_RESET = 0x80, + HDMI_AUD_CONF0_I2S_ALL_ENABLE = 0x2F, + +/* AUD_CONF1 field values */ + HDMI_AUD_CONF1_MODE_I2S = 0x00, + HDMI_AUD_CONF1_MODE_RIGHT_J = 0x02, + HDMI_AUD_CONF1_MODE_LEFT_J = 0x04, + HDMI_AUD_CONF1_WIDTH_16 = 0x10, + HDMI_AUD_CONF1_WIDTH_24 = 0x18, + /* AUD_CTS3 field values */ HDMI_AUD_CTS3_N_SHIFT_OFFSET = 5, HDMI_AUD_CTS3_N_SHIFT_MASK = 0xe0, @@ -901,6 +916,12 @@ enum { HDMI_AUD_CTS3_CTS_MANUAL = 0x10, HDMI_AUD_CTS3_AUDCTS19_16_MASK = 0x0f, +/* HDMI_AUD_INPUTCLKFS field values */ + HDMI_AUD_INPUTCLKFS_128FS = 0, + HDMI_AUD_INPUTCLKFS_256FS = 1, + HDMI_AUD_INPUTCLKFS_512FS = 2, + HDMI_AUD_INPUTCLKFS_64FS = 4, + /* AHB_DMA_CONF0 field values */ HDMI_AHB_DMA_CONF0_SW_FIFO_RST_OFFSET = 7, HDMI_AHB_DMA_CONF0_SW_FIFO_RST_MASK = 0x80,