From patchwork Wed Aug 3 02:09:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9262449 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 E29DE60754 for ; Thu, 4 Aug 2016 00:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D397827FA2 for ; Thu, 4 Aug 2016 00:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C83262807E; Thu, 4 Aug 2016 00:36:53 +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 E952427FA2 for ; Thu, 4 Aug 2016 00:36:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EB3D6E917; Thu, 4 Aug 2016 00:36:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from relmlie2.idc.renesas.com (relmlor3.renesas.com [210.160.252.173]) by gabe.freedesktop.org (Postfix) with ESMTP id 280766E70E for ; Wed, 3 Aug 2016 02:09:46 +0000 (UTC) Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 03 Aug 2016 11:09:45 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 141684E419; Wed, 3 Aug 2016 11:09:45 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 042558002F; Wed, 3 Aug 2016 11:09:44 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id DECA88002E; Wed, 3 Aug 2016 11:09:44 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id MAN27415; Wed, 3 Aug 2016 11:09:44 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'208";a="217060013" Received: from mail-pu1apc01lp0018.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.18]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 03 Aug 2016 11:09:43 +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=OagZgCUd4JTASbarTzv0pmA1pRoEWfqIG+D5N7wyY/w=; b=Ih5GKQ8kSzdDqIG1NyVD9pNGsZQfJYCg0ZnYCMJF2+Gx5bvBiRIh6etAx8sbOo7teheG8VAiATNjawrFUGMCWjrcYB8lncpVWqlYR+Tj8k+iRqGTtt5eGnu34/EuC1G5La9lDvJt28KHktd73SL/rDIrb653vNrItNnEpEhuI08= 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 HK2PR0601MB1444.apcprd06.prod.outlook.com (10.165.182.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Wed, 3 Aug 2016 02:09:39 +0000 Message-ID: <8760ri8val.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Archit Taneja , Mark Brown In-Reply-To: <878twe8ven.wl%kuninori.morimoto.gx@renesas.com> References: <878twe8ven.wl%kuninori.morimoto.gx@renesas.com> Subject: [PATCH 2/2 v2][resend] 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") Date: Wed, 3 Aug 2016 02:09:39 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR0201CA0020.apcprd02.prod.outlook.com (10.164.90.158) To HK2PR0601MB1444.apcprd06.prod.outlook.com (10.165.182.150) X-MS-Office365-Filtering-Correlation-Id: cd608b91-61a4-4775-204c-08d3bb433a98 X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1444; 2:GsiMITq8Eiujsxt3xLfXYKZXhEM9w8y5VknJTKebUjPbbp5rsTn0X6EdYlvn8otpjGiy/ZuilSE+E8Aa2FAQZHaWh38HEnSdOqFGvJJDwF4WtfhMcTSSaS30oAyoz5UsyvEh2TN3puwBEdbdbGFUfdUVlyyhcmxDu092InbTs4/vMhy4aSaBrQ8gGkM4rFth; 3:iE2/e2aWc88mSkhZa/GoAhZSpQPNfyDVz1YxnzlOv8jPuyP1y6eEkdW53vtbgP2N2H6QlRCl+i2nNC3GGvbrzpNhGvQpkzAea+CuESiASvRPiTFV+EDbdBU5BLIEs875; 25:gKXD+QZYktR6+zfiYdmcwbmkfXnCKG+pGceyBQfrdsu5oPpZg0QqELrd95dGz/C1f4K81zYeAs7nmOIM8FwTdy4xH6VYK+3OC41a2nntIa96dj/RbthXf40qt8ftVANx9p8x9PsHqlf8bT4Phbik4rTVBkgAVl1J5z7eWNNU1L66vqWCG6LsnG7aPZ102iRk8mw1oZ1x/y0veMvFK9mGFjauJ8TEK0seuixlPqB385C44JkWOsxQXer17WnKAF1xppi+pO/TaqBX+WY/g5j01GEPM9JHdkVHiG5r/qtwUathOKdeTxF1qzGewHYYlWgmq9BY9yeNhjRv8FnaU6ScZchNK7VxgLXt4eyw+yZRlQNfFwRjAWV+anJWJvIf8+N06m5KOPbyFyyimFFoaJuqmuNl2EE6qthNCvBFKYFOfv0= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HK2PR0601MB1444; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1444; 31:VvMsWyjzlKWuXMBCGZRKoJmD3sVjkCJopw0IjJiwcrXb21vT1Xt75iV0xDdXF7WizYn2wBHIA1F2cno37Gcb1R9EqN+5hP8ZcxWBP0Vs+IdfOQq9QY/cd9jILQL0JAycKMcJZNUmysZTMgx3yYqQhW6E+Bt98jIeVut1e5pb0yOh0KvlkVkt3IHTaNht0OG2ywjyDBwtAzRU5z+9ltH3gYX1uMZ+BkFS5+HXYBfT4Xg=; 20:blD/iHIkZ53wDDtnz16uaPS8A5xs7vyFoYDRldFLtrcR9tOklkkVLtlcrYtahxmBLfuzmmzQEmYcKU9LN7wGcTBQWDsae2Ei3nV5dCSqedO9vDkH+qADFprarLa7YjxNUeHVXajOrsU55ssNMcS802on9Lncc6Gd2hdEU2wDcMxYO9+xFro8er5ndd0iDm4ot9ttDIIVwJJN09FigHksGsnhTltfHZqbqO+6DZHLeRFeVpyULrqU6CwrAn++ylVb2rHdnDMsHATrAvwEFz0Ed3vBGF6r8HYSe+T4oppi/HEoNWD88IdE3wLHPgW4tZRH8SCYeaAbAHfLitRiLbX2P8LXojkl59g+q/68fuypB8GMOt6NiQkgkZbdjT+LzxRDlN+tnT3TeEYFgSrWgJYX9dHpSXdO+eDFUABFOMZr7b3jOePwmn8TKKNM+kM0Im39RaPrv8JLWHv0z+bA8Nf30Is2NbewvbOnb9EypaqP1/dP12kZnFqHGT6ZcNd0FV9h X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:HK2PR0601MB1444; BCL:0; PCL:0; RULEID:; SRVR:HK2PR0601MB1444; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1444; 4:ekEPDrJa6SNMu3UUga/hMhumw66h6tNjtRi+sYzKT+5zk/DBCOXV4IQxMic5BgS9Isk/dCs/KU30EH3JUREQW2rThGSoFrUyo8a83u41Ksu63lgECZOsmTGA86C/HHtKJYRCTmxp27hDa4cFqDRJYO469BUDIRjMDnavogZ5ziO0Eq5yb2V/4ZC22/VF5FCjT8yEOLkNIxaCocu4ckVczzTahjpLQBUFsvEy7wVAw6W2zwdJoQ00PDd9ur+hYsCwk7lW9BrIk3bCsd4i8QzWqkgixTCDAsBiwR4lUz/N8kBru3Xqh6d9XF2wwzlIKDqZ0WhgxpYzeCIHwyo8puqMv063UHbA2gTLeauXmb9S/FlQLMEtVnlQYjWNg3iMaZ8brBP2k+t9KcyOo0k90tSabQ== X-Forefront-PRVS: 00235A1EEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(50986999)(86362001)(47776003)(69596002)(23726003)(81156014)(189998001)(97736004)(68736007)(6116002)(5001770100001)(101416001)(575784001)(83506001)(54356999)(92566002)(53416004)(42186005)(76176999)(8676002)(77096005)(3846002)(4001350100001)(4326007)(586003)(105586002)(19580395003)(66066001)(46406003)(305945005)(106356001)(33646002)(2950100001)(7736002)(36756003)(2906002)(81166006)(7846002)(19580405001)(8666005)(50466002)(229853001)(7416002)(7059030)(2004002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR0601MB1444; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR0601MB1444; 23:VnXqrOqa/XG1pE0qjA1adYNoNgO8ipNQfjGCHzD?= =?us-ascii?Q?tFxiW0MFQaWdXdh9jfaylZ1x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 7:/5XQaWD2qGCerYBM+LinSlu1U8cpO2TiMqTJKFElvbEIjPOs5+mnWQG6t3hrftizvvH+50WDkb3O25TgZzWJBJMfKP/zp8R7dbo+TFCqUoEyI6kuP+Lk6elUvoiWElqJ9aHWMQ1EIHAcVxk9K2hrOm/2eJpTJV6Df0kYT+k9Y1xBMlCMe5bIO/huOZ+C3vNQDSM3pCHPJ89PrGhph9KiLdQpAW4V1cxwVVPZA2nJB6VSIWsx1EHtKll1uAzDO8kc SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1444; 20:2ko9QwGGQiTLagkJYgheXowVtSsxBzaWCbJFzNHncjGQjIYazpE6023/96peWHKYgQA1FGT0SYOtjkEOY4r+knWJ5MI6B2OeJsdH8kUFNk0EFQlxYN5e/WdgF/nGBJHGTuAKUXyIDQ8i+WjPoPQcY8jl747mL2vFPT227CRazfs= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2016 02:09:39.9665 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1444 X-Mailman-Approved-At: Thu, 04 Aug 2016 00:35:48 +0000 Cc: Fabio Estevam , Linux-ALSA , Daniel Vetter , Koji Matsuoka , dri-devel@lists.freedesktop.org, Liam Girdwood , linux-renesas-soc@vger.kernel.org, Simon , Russell King , 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. Tested-by: Jose Abreu 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,