From patchwork Fri Jan 30 11:33:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 5754241 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B072A9F302 for ; Sat, 31 Jan 2015 12:18:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 08C002026D for ; Sat, 31 Jan 2015 12:18:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 18EE12026F for ; Sat, 31 Jan 2015 12:17:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D6AA76E21F; Sat, 31 Jan 2015 04:17:55 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.135]) by gabe.freedesktop.org (Postfix) with ESMTP id B2B276E141 for ; Fri, 30 Jan 2015 03:34:14 -0800 (PST) Received: from ykk?rock-chips.com (unknown [192.168.167.172]) by regular1.263xmail.com (Postfix) with SMTP id 7158319837; Fri, 30 Jan 2015 19:34:10 +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 E969345D; Fri, 30 Jan 2015 19:34:05 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-FST-TO: airlied@linux.ie X-SENDER-IP: 121.15.173.1 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: <4a550e763de4c8e6e510d2657cd43d50> X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [121.15.173.1]) by smtp.263.net (Postfix) whith ESMTP id 1835P4QF72; Fri, 30 Jan 2015 19:34:07 +0800 (CST) From: Yakir Yang To: David Airlie , Russell King , Philipp Zabel Subject: [PATCH v2 09/12] drm: bridge/dw_hdmi: creat dw-hdmi-audio platform device Date: Fri, 30 Jan 2015 06:33:15 -0500 Message-Id: <1422617595-25744-1-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1422617031-25098-1-git-send-email-ykk@rock-chips.com> References: <1422617031-25098-1-git-send-email-ykk@rock-chips.com> X-Mailman-Approved-At: Sat, 31 Jan 2015 04:17:55 -0800 Cc: Fabio Estevam , mmind00@googlemail.com, rockchip-discuss@chromium.org, dbehr@chromoum.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, dianders@chromium.org, Yakir Yang , marcheu@chromium.org, Mark Yao 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY 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 v2: - Update the audio control interfaces drivers/gpu/drm/bridge/dw_hdmi.c | 23 +++++++++++++++++++++++ include/drm/bridge/dw_hdmi.h | 13 +++++++++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c index 25c1678..75e3029 100644 --- a/drivers/gpu/drm/bridge/dw_hdmi.c +++ b/drivers/gpu/drm/bridge/dw_hdmi.c @@ -107,6 +107,7 @@ 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; @@ -1703,6 +1704,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; @@ -1824,6 +1827,23 @@ 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.config_audio = hdmi_config_audio; + audio.enable_clk = hdmi_audio_clk_enable; + audio.disable_clk = hdmi_audio_clk_disable; + audio.get_connect_status = hdmi_get_connect_status; + + 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: @@ -1839,6 +1859,9 @@ void dw_hdmi_unbind(struct device *dev, struct device *master, void *data) { struct dw_hdmi *hdmi = dev_get_drvdata(dev); + if (!IS_ERR(hdmi->audio_pdev)) + platform_device_unregister(hdmi->audio_pdev); + /* Disable all interrupts */ hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index aafa447..2f29112 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, @@ -74,6 +76,17 @@ struct hdmi_audio_fmt { enum hdmi_audio_wordlength word_length; }; +struct dw_hdmi_audio_data { + struct dw_hdmi *dw; + + int irq; + bool (*get_connect_status)(struct dw_hdmi *hdmi); + + void (*enable_clk)(struct dw_hdmi *hdmi); + void (*disable_clk)(struct dw_hdmi *hdmi); + void (*config_audio)(struct dw_hdmi *hdmi, struct hdmi_audio_fmt *aud); +}; + struct dw_hdmi_plat_data { enum dw_hdmi_devtype dev_type; const struct dw_hdmi_mpll_config *mpll_cfg;