From patchwork Fri Oct 28 01:22:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9401473 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 6FA2F60231 for ; Fri, 28 Oct 2016 08:03:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E4CB2A602 for ; Fri, 28 Oct 2016 08:03:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52E2F2A604; Fri, 28 Oct 2016 08:03:22 +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 4C61E2A602 for ; Fri, 28 Oct 2016 08:03:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A4B86EB50; Fri, 28 Oct 2016 08:03:20 +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 602846E27A for ; Fri, 28 Oct 2016 01:22:28 +0000 (UTC) Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 28 Oct 2016 10:22:27 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 876C943979; Fri, 28 Oct 2016 10:22:26 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 687BF18070; Fri, 28 Oct 2016 10:22:26 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 20FEF1806F; Fri, 28 Oct 2016 10:22:26 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id LAD20854; Fri, 28 Oct 2016 10:22:26 +0900 X-IronPort-AV: E=Sophos;i="5.31,406,1473087600"; d="scan'";a="223592496" Received: from mail-pu1apc01lp0021.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.21]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 28 Oct 2016 10:22:25 +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=0zBO1OCv7jVVMBB9D05z5srQAd7BY3Z/JdNo7H6xYWk=; b=BYq0fV5bS+9yUSgcKKprYrjgs6dHJ8tRMoiz9at9Gi9VbB9vOb+tWWeFT7Dwwyn7kUV/nuI+13DaUv7g1n7LbrIVLYRRNbWb7wLQyUkm8AVBLX5OFiDAZPDH9j9K545qb94mkbnUYYKfNIKf3yViYu+ZcJSbFtOyUxInKTrTuT0= 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.693.12; Fri, 28 Oct 2016 01:22:21 +0000 Message-ID: <87lgx9wa2d.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH][resend] drm: bridge: add DesignWare HDMI I2S audio support User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Archit Taneja , Mark Brown , David Airlie , Russell King , Fabio Estevam , Daniel Vetter , Koji Matsuoka , Thierry Reding MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 28 Oct 2016 01:22:21 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS2PR01CA0085.jpnprd01.prod.outlook.com (10.165.51.173) To PS1PR0601MB1452.apcprd06.prod.outlook.com (10.165.210.156) X-MS-Office365-Filtering-Correlation-Id: 35670f81-3f5a-48a7-0f22-08d3fed0de74 X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1452; 2:6+WcX6r9TJGhdMG+Cl+WXHusVHDYZ2dI+b64k53rqnu2ypKl+33jO+0rhPNjfkYV3EFqr/hYdRpzf33iiszxlRwss+eqoXV+rWwIwqTEAnuI0AS3oar5F8JfTfPEeUFh9BMotoOsLr+djWYoIoq01Y6PiX4JX0WlBT1HVuEWvTXXFKOO7V4cRrP7yaIOMCnu9EzBjDCVq2onr7QOVnWPmQ==; 3:e1oq/YnxtmJXdt5L/3Mp1hTS/xuna3WwxQVnxaqOyPM/r0kcZWUi0qhwlQ191z4fw3owl7ET3Acy/M1RavOAk0kT+oXYR8brKWWpPyUlQjypzE2k79Iix3kSj3luSaxhtxlqhOvHw6k5/gAXZ4N+GA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:PS1PR0601MB1452; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1452; 25:yBAvhlXrYMWg4uVm4UGTlkKqer448zZFI6UyIEIkfYx+8b5pNoG35OCoQxXtDnlL3O1i5ZAd06v0k3Wo5/FeqOeFtqBH+Q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Tz52JoJj7FPs5kd2sT9jzJbuaGI8Vt1/8O300l2dDsXdh9+fOq4+ZM6a+SQselBoofH8r4c2leqIAdyYFXkGEdYnqWd+dyycnzCoj39lVOpipNHru0/RdZJFShATSOVOijdGVKNvG33hfI7O63vCviVB3etLKdaWTNVFIeKGOHgwycxEGr7RB6Flbr/ppQzZaWMI6vZ33PjjQJw6OS1ztFY9C1to9zderaFXooTubYYCiw1VIDsIHFNdlorEICPDSW+d3jzC6lzwtUhdjaXJBtNWC4lRfCWNbkcz9pryv6lo8SJn/ef8eHUDtjmWDkGVm12S+KXmDMoGFi+nNwxy+xijwdJHmR+1wR2O35dSkhVPGxkERTiBpBRSenLZNF1sTRkpxd6awgYkK0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:PS1PR0601MB1452; BCL:0; PCL:0; RULEID:; SRVR:PS1PR0601MB1452; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1452; 4:OfuSAnmO/bf09AOEHH0uwDrn848TSLzojozqD9v1C9pyFP6/yAVEMOi4dmTo7v7nrDKAxXLtTTqDdHspT9y7FtZBS0XN2VjHCleqHsLyK1FbFXNi++s7AvDGQE/wcSoWFj0FNrR/KEhlXKms5FPem+hYDE5QMjNnUOa7Rp8TI8FhTbc7gZKFv1GKZn8JMWdju5H9gwPf0KeMZNyjkbvxW/plFvlEPUr8Fddv6QNt2WhEjZah657HSUJzHh9g99l+7uJIKQdSAfMVz8uxf+K4x/rIOa/EtCQgpf9AUt82DiSc/hBzDpqxtL+uFI57YLwDDz+mAjY5Jmbm4SSclnYgBU8+sYMwztVh9U8OK6pseN6AhPwxEJObKAvO0xYRVoZsqWsJPbwLOWBvl7uwehmcNbuzoo1+Ry8lAewZpU/Myqs= X-Forefront-PRVS: 0109D382B0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(229853001)(33646002)(7416002)(42186005)(53416004)(106356001)(105586002)(7736002)(8666005)(47776003)(83506001)(36756003)(69596002)(66066001)(7846002)(305945005)(586003)(86362001)(19580405001)(19580395003)(575784001)(101416001)(8676002)(68736007)(54356999)(81156014)(81166006)(5660300001)(50986999)(50466002)(5001770100001)(4001350100001)(97736004)(77096005)(23726003)(3846002)(2906002)(92566002)(189998001)(4326007)(6116002)(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:bKsqORhgYerUPWVrzCN3iCRaA/gT+VeEb0iIrZ4?= =?us-ascii?Q?6A3tYkRTYXACQjtbEV6ASYURaPvHNqCs20+wHfjMDxWyR7M1XHnctjb1+upz?= =?us-ascii?Q?gAMjdemj56t3GPF006gApJYgz7Cx0laXZ+8agAVS1HvknZGQFI/TWskNZki4?= =?us-ascii?Q?iwPrmlfrkOOmjN3ACQZbwci3uZuHxgnAjdUMCKOsSAoS4C/y3IrbVaiifNCV?= =?us-ascii?Q?hJYf99RV9Z98OtcIDQ06Or9EVtwZyQ0wFSo3ieKO+tGnZ4OCwrlD5VPvrJ2y?= =?us-ascii?Q?45i7HQIG2cgodPIQUmk2SLAEIya/wI+27MINDd/ffTvWQvpamGk8lYhtkraf?= =?us-ascii?Q?VcHy9siCCBnG1biRgSSC65kj0T+0U4XsFBqRrTcOSTtgGq0aUDqkHV+3PUwB?= =?us-ascii?Q?EGE0chgMN2Qflk9KPBrxZrt0vgO6ja+T4MD7D6ABtwbjwQOW1XTZqWMWT8Gh?= =?us-ascii?Q?Ox9IrbKUBN1D/HxOIETfY8//x/3sRstsrrgSjcTHDsE8Muax3JWVIaCuaKso?= =?us-ascii?Q?Aoh1SSa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PMTgA7NIthgRGbhE87p6vO8V6SXETPAbesZF0PuH9trw= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 01:22:21.7753 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR0601MB1452 X-Mailman-Approved-At: Fri, 28 Oct 2016 08:03:18 +0000 Cc: Linux-ALSA , Liam Girdwood , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Simon 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 --- 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 b590e67..4ed891e 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 efdb07e..720e53e 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_SII902X) += sii902x.o 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 51f45ad..84e7e7c 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -1921,10 +1921,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) @@ -2093,7 +2094,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; @@ -2105,6 +2111,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); } /* Reset HDMI DDC I2C master controller and mute I2CM interrupts */ diff --git a/drivers/gpu/drm/bridge/dw-hdmi.h b/drivers/gpu/drm/bridge/dw-hdmi.h index 6aadc84..0336b91 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, @@ -891,6 +895,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, @@ -905,6 +920,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,