From patchwork Mon Dec 15 02:11:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 5499011 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D5F229F30B for ; Tue, 16 Dec 2014 01:08:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04182209D3 for ; Tue, 16 Dec 2014 01:08:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 76DA4209C7 for ; Tue, 16 Dec 2014 01:08:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 65DBD6E0B5; Mon, 15 Dec 2014 17:08:30 -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 754406E12E for ; Sun, 14 Dec 2014 18:25:06 -0800 (PST) Received: from ykk?rock-chips.com (unknown [192.168.167.153]) by regular1.263xmail.com (Postfix) with SMTP id 1B0CF18179; Mon, 15 Dec 2014 10:12:03 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 8C866248CB; Mon, 15 Dec 2014 10:11:57 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-SENDER-IP: 104.167.231.7 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [104.167.231.7]) by smtp.263.net (Postfix) whith SMTP id 63664RTMG3; Mon, 15 Dec 2014 10:12:00 +0800 (CST) From: Yakir Yang To: Yakir Yang Subject: [PATCH 1/6] drm: bridge/dw_hdmi: add hdmi audio config interfaces Date: Mon, 15 Dec 2014 10:11:29 +0800 Message-Id: <1418609494-15820-2-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1418609494-15820-1-git-send-email-ykk@rock-chips.com> References: <1418609494-15820-1-git-send-email-ykk@rock-chips.com> X-Mailman-Approved-At: Mon, 15 Dec 2014 17:08:29 -0800 Cc: Fabio Estevam , Oder Chiou , Brian Austin , Zubair.Kakakhel@imgtec.com, Greg Kroah-Hartman , Xu Jianqun , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Max Filippov , Bard Liao , Russell King , =?UTF-8?q?St=C3=A9phane=20Marchesin?= , Dylan Reid , Sonny Rao , Heiko Stuebner 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 in probe function, and support some interfaces to dw-hdmi-audio driver for setting hdmi audio format. Signed-off-by: Yakir Yang --- drivers/gpu/drm/bridge/dw_hdmi.c | 28 ++++++++++++++++++++++++++++ include/drm/bridge/dw_hdmi.h | 12 ++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c index 01c95a8..9ba96de 100644 --- a/drivers/gpu/drm/bridge/dw_hdmi.c +++ b/drivers/gpu/drm/bridge/dw_hdmi.c @@ -106,6 +106,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; @@ -369,6 +370,11 @@ 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 @@ -1558,6 +1564,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; @@ -1679,6 +1687,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.mod = hdmi_modb; + audio.read = hdmi_readb; + audio.write = hdmi_writeb; + 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: @@ -1694,6 +1719,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 5a4f490..82750f6 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -19,6 +19,18 @@ enum { DW_HDMI_RES_MAX, }; +struct dw_hdmi; + +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 (*set_sample_rate)(struct dw_hdmi *hdmi, unsigned int rate); +}; + enum dw_hdmi_devtype { IMX6Q_HDMI, IMX6DL_HDMI,