From patchwork Mon Oct 17 07:56:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9380959 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 38F656086B for ; Tue, 18 Oct 2016 01:13:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D7CF28F7C for ; Tue, 18 Oct 2016 01:13:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E38D28FF3; Tue, 18 Oct 2016 01:13:43 +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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E94D328F7C for ; Tue, 18 Oct 2016 01:13:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D2526E602; Tue, 18 Oct 2016 01:13:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by gabe.freedesktop.org (Postfix) with ESMTP id 191FE6E2A0 for ; Mon, 17 Oct 2016 08:06:30 +0000 (UTC) Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie3.idc.renesas.com with ESMTP; 17 Oct 2016 17:06:29 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 2EC4352F7D; Mon, 17 Oct 2016 17:06:29 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 2FF9580030; Mon, 17 Oct 2016 17:06:29 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 2ABA68002F; Mon, 17 Oct 2016 17:06:29 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id TAB12727; Mon, 17 Oct 2016 17:06:29 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="223075478" Received: from mail-pu1apc01lp0022.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.22]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 17 Oct 2016 17:06:26 +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=UmKtlZaefYJ3GcK5eUifysl4HT/S9okEAMWWrQCMA1siVljOCwml28rSLV0aKsAEPniCMM1IB2XdN3G2kX0PYw3v+SjZSx+0ChDuwqdPXLgT7fYeEYXFM7EC9AffZ4wvUJ0iYnyfCSnoaEOy5NeXNBbTY80X18ZkCT2UTn3eAM0= 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 KL1PR0601MB1447.apcprd06.prod.outlook.com (10.169.69.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.659.11; Mon, 17 Oct 2016 08:06:23 +0000 Date: Mon, 17 Oct 2016 16:56:54 +0900 Message-ID: <87twcb4ddl.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Archit Taneja , Mark Brown Subject: [PATCH v2][resend v2] drm: bridge: add DesignWare HDMI I2S audio support In-Reply-To: <878twe8ven.wl%kuninori.morimoto.gx@renesas.com> References: <878twe8ven.wl%kuninori.morimoto.gx@renesas.com> User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS2PR01CA0034.jpnprd01.prod.outlook.com (10.164.161.144) To KL1PR0601MB1447.apcprd06.prod.outlook.com (10.169.69.25) X-MS-Office365-Filtering-Correlation-Id: bc7ea7ef-495e-47cb-b119-08d3f6647d4f X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1447; 2:NKM6sFWZSpy1DbSsb5lGWiJfCqU2GEk+8UOpa8gLWZM47Uwg7n6DfPO5O7cfEVrLjOfRk2EuqIGqSa9hbiRko8fBKjKALte1WYh+0aF6eLSiHX93cE5E0A1WfIhexCl8fznzvRFmTsoJCIR5cfGlL2CUunwDFCS+rQZuPFT1Th76EhrhhTmZxkgV7xPxLYLIH0o8kO4ekbFRWsjPnjwo/w==; 3:In4TwxHSZx5DvF2tf9a+PQ8b08pXjV9n8vDhWVgJ4vT09hizI7w5vSHfZZquuvxvbWY338yU3B9pAz/MvTJnnTSG+wKcwa8GW+VrxkNevIvL0Z4Gsg+Rgmk1ww0vqDxMJWhTizniBOMkYB05z1sbSg==; 25:30SXCCD1HpJUroh/sya/AEtf0Jd+LvwMkbVY7OaB0WeZZ17QLunz9X765JO7oWar4u7BZJt9WgxsqF9bAfyanuMac7l0VwgxNR5eTU/p/z/I+xKK6mQ4OItUA8HlwUrFurLNTavbzmfQsr6y1P7o85+15HeQsJcyvW5epD0/2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iHw14KUWXI5UKImU2GTJ8ye5aY5/mvuVERtt2xjHc6h2cR28UutTYG2d7+0NeT8nAUsaVXJ18ttUW+4q X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:KL1PR0601MB1447; BCL:0; PCL:0; RULEID:; SRVR:KL1PR0601MB1447; X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1447; 4:ahNt3UCNh4ls8TCzl+mUe7Tc3zbf3tNkeAYYKT3mw5z8vIhNPYYQ6Z+164+IYGrUJt+vkour4XDpkw0U+9hxqDkA/erJ+UZXaQPIMNaUomwkYpTI3H+XSe8Mba90zjGP8VQ6Dx04SirglX/iWao1hEXQ2Kn0Mn8VmBMAgIgS0oL2vhcKSEPsyvok3pRlLWC3/TwkcYXS6Oq5g7r9xgUAKfgWvRPq+hr8gd+iSqOlYzp5AQv0l2ogIn4jh/fKU44ttXIbb5nfu2myIrIgQKlrYJC8z4GKhRR8oIjbKeHEODMnTxilEgLzv6jIOAjddhKVQKk8QPSn4Dz19xNYbtwLbhn2CAj1p3q7ODBty5gh2QMj2MSwcu/t5IXbC1KOMfUGFbfkswdmKov2h6ri2v00QX9s/wQgymDdXnv0cw/uhDg= X-Forefront-PRVS: 0098BA6C6C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(97736004)(5001770100001)(47776003)(7846002)(86362001)(106356001)(305945005)(8666005)(101416001)(50986999)(76176999)(54356999)(3846002)(92566002)(4001350100001)(586003)(2950100002)(6116002)(7736002)(33646002)(77096005)(19580405001)(19580395003)(23726003)(42186005)(7416002)(53416004)(5660300001)(4326007)(8676002)(189998001)(68736007)(81166006)(81156014)(2906002)(50466002)(6666003)(69596002)(36756003)(105586002)(66066001)(229853001)(46406003)(575784001)(83506001)(7059030)(2004002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1PR0601MB1447; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; KL1PR0601MB1447; 23:gWAk/rWU0cyZ6g7yl8el/D42UL0h/OEvv/eBopW?= =?us-ascii?Q?d0xfMbBsQ2/5G6KvFIQ7I3T7iNIUuOdLC7N/nqOt9ZIDvIXuFSgBiE29/xhX?= =?us-ascii?Q?Ac1ZwqYkjfTuAIzXACPoutxTpunS5KggP7Q69E2kqFx1eYJs5Y098bA8rXro?= =?us-ascii?Q?dL1K1ukJbkZGi8IDkAYqQJTzvDlRPGwMIJs/ci//LixVbVfoZhu3Gw1IMT20?= =?us-ascii?Q?VrHjimIZ6zpQfLyA8f68I0ckur+GqZM08mmi1aDutxWe9vOuasBOh0poqmjb?= =?us-ascii?Q?pQKhd8nulr598R1QHJt9HAiLedcPYAHhIgFj7bVf1y4amwxYFJkplpApxC6Y?= =?us-ascii?Q?MVyrbCl/S83gPYsD040HHxhdcBLnmBKhC+EKA59iDDOPDfswDXjjwZAPQUU/?= =?us-ascii?Q?95d8RvssCCLJgFmk6oMOs2bopsIdYvnLNgUpnAubOuLl8plmQQoFndajgkEs?= =?us-ascii?Q?zVDTj/gs3Bxzts/DsgJpBlAxJYJdwbJvq5NEx6P0YiGa1lApVJHebw8o52if?= =?us-ascii?Q?dColLD8B+beLJUCCpgp+gGZzER9YA5Bp5jHFAhpAaQonv7svCwBMagePDH+v?= =?us-ascii?Q?U1sBV0vrIWzgx1yHu6EAllAzeSWibMKvAFvuF84ZH3RTH5EIaR3DZpg/M0zO?= =?us-ascii?Q?cxkUgznK/dnokdnVmltWnXmB1mJJu7q7Y3sio5igWhkR2b0EwqYHlkrrXR2R?= =?us-ascii?Q?yNtMA/rbsYC3VowGgKJMRDhzAyWmMWyUE2qAyaIvwNOQA1VO3rllCQ5/pYLr?= =?us-ascii?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UcN2Saf787ck7Xz90NLGi33UDUtdCU=; 5:euwlyUs5HWmuL9nuuC5u8N54OaCIisjmP/pDOq5XVlgpdmyqSnRw71/EXh3ujysWgYc2w4q2ltK/PFVAI3jQSAr3hymiwSUtfEXCnyBfnfWGAE/oKShpcrIBmt4EKAS2xZWj0sNYMXwB5XrSoTjl8Q==; 24:05001tqgOYHDe74V5Ck/2eDzXQMVyATyB4aBtIHRbBsB+n36Vwlhpy2391D8v4ytwvyw7+gwPvQhIOOHgyvBFW3CjqsRkITljQiq25w7qkU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1447; 7:G4psXHuKLC6Z5gfIyy4JzgUCYjbLHQBnYHT8TbN+dsWAPMsh63p/8T98Y3LuGKO5W2bLBZQGlj6UIJc6MdjWepnjdAK7faBzYe/j2osE6VifKeqniYStx5ExOhbGe5qcptdB7CkEEkj9+qIhGDfDcCnzyzZfTqQFDavV4Ba9+0oLruGuoKT5vVDPJmwIrdBRm4SPizy5fSFi1tPH/vA/BqWUXAggPTHXm/WVlOytvdLbWxFUfPnhGoOgfm+eaZkQMCODvRLASRGcDmKi3Q+IhJ+N/Zgj4g559ofbCL4+l/OkvsDSsKHnrQ6iIOpD3WgP0rsfg5ytsT5ExWJFmoqqWkETMZQe6sOPgiU9edxy6DI=; 20:FHasYCwLTJMNjhSEAQfK8izc/ry4IMA4cDpEa7i01IIykVh8qNwxObBuY963j2l099ZmZuk88xirgxim8/W3yOWABrobwk05Xq4+n1KA8LDD+LjLmMMDirifA3p2nrNeQ7ph+Z2XBtodeVBnYG5JtCYAa7KZIfUCImNFHzXHALs= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2016 08:06:23.3014 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB1447 X-Mailman-Approved-At: Tue, 18 Oct 2016 01:13:38 +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,