From patchwork Tue Feb 3 15:17:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 5769601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 26A8CBF6C3 for ; Tue, 3 Feb 2015 15:21:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 526B720251 for ; Tue, 3 Feb 2015 15:21:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57E242022D for ; Tue, 3 Feb 2015 15:21:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YIfFe-00029K-K0; Tue, 03 Feb 2015 15:18:54 +0000 Received: from regular1.263xmail.com ([211.150.99.140]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YIfFb-0001kX-2B; Tue, 03 Feb 2015 15:18:52 +0000 Received: from ykk?rock-chips.com (unknown [192.168.167.172]) by regular1.263xmail.com (Postfix) with SMTP id 8056F4AA0; Tue, 3 Feb 2015 23:18:24 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 24B2E450; Tue, 3 Feb 2015 23:17:55 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-FST-TO: airlied@linux.ie X-SENDER-IP: 192.253.240.203 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: <4733bdca90ea61499056b96b7658ebc5> X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [192.253.240.203]) by smtp.263.net (Postfix) whith ESMTP id 2020559KOY; Tue, 03 Feb 2015 23:18:20 +0800 (CST) From: Yakir Yang To: David Airlie , Russell King , Philipp Zabel Subject: [PATCH v3 12/15] drm: bridge/dw_hdmi: creat dw-hdmi-audio platform device Date: Tue, 3 Feb 2015 10:17:41 -0500 Message-Id: <1422976661-30447-1-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1422975418-13302-1-git-send-email-ykk@rock-chips.com> References: <1422975418-13302-1-git-send-email-ykk@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150203_071851_592066_11EBEBA9 X-CRM114-Status: UNSURE ( 8.31 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.7 (+) Cc: Mark Rutland , alsa-devel@alsa-project.org, Heiko Stuebner , djkurtz@chromium.org, dianders@chromium.org, Yakir Yang , mmind00@googlemail.com, Pawel Moll , linux-rockchip@lists.infradead.org, Sean Cross , devicetree@vger.kernel.org, Arnd Bergmann , Ian Campbell , Jyri Sarha , Ben Zhang , Rob Herring , dri-devel@lists.freedesktop.org, marcheu@chromium.org, linux-arm-kernel@lists.infradead.org, Mark Yao , Fabio Estevam , linux-kernel@vger.kernel.org, Rob Clark , Daniel Vetter , Kumar Gala , Shawn Guo X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_BLACK autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP creat dw-hdmi-audio device dynamically in probe function, and transfer some interfaces to dw-hdmi-audio driver for setting hdmi audio format & control hdmi audio clock. Signed-off-by: Yakir Yang --- Changes in v3: - Remove audio_config & get_connect_status callback functions and add write/read/mod register callback functions Changes in v2: - Update the audio control interfaces drivers/gpu/drm/bridge/dw_hdmi.c | 29 +++++++++++++++++++++++++++++ include/drm/bridge/dw_hdmi.h | 15 +++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c index 92fc12d..9734532 100644 --- a/drivers/gpu/drm/bridge/dw_hdmi.c +++ b/drivers/gpu/drm/bridge/dw_hdmi.c @@ -124,6 +124,8 @@ struct dw_hdmi { struct drm_encoder *encoder; struct drm_bridge *bridge; + struct platform_device *audio_pdev; + enum dw_hdmi_devtype dev_type; struct device *dev; struct clk *isfr_clk; @@ -499,6 +501,12 @@ static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi) hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock); } +static void hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int sample_rate) +{ + hdmi->sample_rate = sample_rate; + hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock); +} + /* * this submodule is responsible for the video data synchronization. * for example, for RGB 4:4:4 input, the data map is defined as @@ -1787,6 +1795,8 @@ int dw_hdmi_bind(struct device *dev, struct device *master, struct resource *iores, int irq, const struct dw_hdmi_plat_data *plat_data) { + struct platform_device_info pdevinfo; + struct dw_hdmi_audio_data audio; struct drm_device *drm = data; struct device_node *np = dev->of_node; struct device_node *ddc_node; @@ -1906,6 +1916,25 @@ int dw_hdmi_bind(struct device *dev, struct device *master, dev_set_drvdata(dev, hdmi); + memset(&pdevinfo, 0, sizeof(pdevinfo)); + pdevinfo.parent = dev; + pdevinfo.id = PLATFORM_DEVID_NONE; + + audio.irq = irq; + audio.dw = hdmi; + audio.mod = hdmi_modb; + audio.read = hdmi_readb; + audio.write = hdmi_writeb; + audio.enable = hdmi_audio_enable; + audio.disable = hdmi_audio_disable; + audio.set_sample_rate = hdmi_set_sample_rate; + + pdevinfo.name = "dw-hdmi-audio"; + pdevinfo.data = &audio; + pdevinfo.size_data = sizeof(audio); + pdevinfo.dma_mask = DMA_BIT_MASK(32); + hdmi->audio_pdev = platform_device_register_full(&pdevinfo); + return 0; err_iahb: diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index e8cfe1c..23ca491 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -12,6 +12,8 @@ #include +struct dw_hdmi; + enum { DW_HDMI_RES_8, DW_HDMI_RES_10, @@ -44,6 +46,19 @@ struct dw_hdmi_sym_term { u16 term; /*transmission termination value*/ }; +struct dw_hdmi_audio_data { + int irq; + struct dw_hdmi *dw; + + u8 (*read)(struct dw_hdmi *hdmi, int offset); + void (*write)(struct dw_hdmi *hdmi, u8 val, int offset); + void (*mod)(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg); + + void (*enable)(struct dw_hdmi *hdmi); + void (*disable)(struct dw_hdmi *hdmi); + void (*set_sample_rate)(struct dw_hdmi *hdmi, unsigned int rate); +}; + struct dw_hdmi_plat_data { enum dw_hdmi_devtype dev_type; const struct dw_hdmi_mpll_config *mpll_cfg;