From patchwork Wed Mar 19 07:58:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 3850241 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 00B53BF540 for ; Wed, 19 Mar 2014 07:58:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 292B9203A9 for ; Wed, 19 Mar 2014 07:58:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D318F2034E for ; Wed, 19 Mar 2014 07:58:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 820318B928; Wed, 19 Mar 2014 00:58:49 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F8DF8B928 for ; Wed, 19 Mar 2014 00:58:46 -0700 (PDT) Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2O0076SBHX9BC0@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 19 Mar 2014 16:58:45 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.113]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 39.7A.14803.53E49235; Wed, 19 Mar 2014 16:58:45 +0900 (KST) X-AuditID: cbfee691-b7efc6d0000039d3-c8-53294e350850 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 43.28.28157.53E49235; Wed, 19 Mar 2014 16:58:45 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.252.75.62]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N2O00FFYBHXNJ20@mmp2.samsung.com>; Wed, 19 Mar 2014 16:58:45 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH v2] drm: improve various bridge devices support Date: Wed, 19 Mar 2014 16:58:44 +0900 Message-id: <1395215924-16897-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1395214495-13218-1-git-send-email-inki.dae@samsung.com> References: <1395214495-13218-1-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsWyRsSkUNfUTzPY4GibmsWVr+/ZLCbdn8Di wORxv/s4k0ffllWMAUxRXDYpqTmZZalF+nYJXBmzZk9nLvh2hrGiY9pVtgbGGcsYuxg5OSQE TCRO7FjBCmGLSVy4t54NxBYSWMoocfehGEzNjhmb2LsYuYDi0xkl5r55xgbhdDNJrNh7B2wS m4CqxMQV98G6RQSUJf5OXAUWZwayL/YvZe5i5OAQFnCWuHOFBcRkASpfc0YGpIJXwEXi+KIZ jCBhCQEFiTmTbEDCnAKuEl+3zoI6x0Xi1okljCBbJQQes0k8//eZCSTBIiAg8W3yIRaIXlmJ TQeYIU6WlDi44gbLBEbhBYwMqxhFUwuSC4qT0otM9YoTc4tL89L1kvNzNzECw/L0v2cTdzDe P2B9iDEZaNxEZinR5HxgWOeVxBsamxlZmJqYGhuZW5qRJqwkzpv+KClISCA9sSQ1OzW1ILUo vqg0J7X4ECMTB6dUA6PTptSfs5eEHLv5MPgjq2TiyXuqPZ5tSr+VjxxtnvPimc+pKT2LXjVt OmG95PymSvbcD+u9+kL+RB+xVv4r4zj3N+fpqJutp5unP82azSQ5W2SGb1pUxaOKqTm+8xIT Jkmz7F4lb/a4O3CFsHHzeYZ9J2KCKo6x5Fmsk9/6cFpurd610Ks1znxKLMUZiYZazEXFiQA3 /HHGYQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRmVeSWpSXmKPExsVy+t9jQV1TP81gg+n9khZXvr5ns5h0fwKL A5PH/e7jTB59W1YxBjBFNTDaZKQmpqQWKaTmJeenZOal2yp5B8c7x5uaGRjqGlpamCsp5CXm ptoqufgE6Lpl5gAtUFIoS8wpBQoFJBYXK+nbYZoQGuKmawHTGKHrGxIE12NkgAYS1jBmzJo9 nbng2xnGio5pV9kaGGcsY+xi5OSQEDCR2DFjEzuELSZx4d56ti5GLg4hgemMEnPfPINyupkk Vuy9A9bBJqAqMXHFfTYQW0RAWeLvxFVgcWYg+2L/UuYuRg4OYQFniTtXWEBMFqDyNWdkQCp4 BVwkji+awQgSlhBQkJgzyQYkzCngKvF16yywgUJAJbdOLGGcwMi7gJFhFaNoakFyQXFSeq6R XnFibnFpXrpecn7uJkZw2D+T3sG4qsHiEKMAB6MSD++BKI1gIdbEsuLK3EOMEhzMSiK8wneB QrwpiZVVqUX58UWlOanFhxiTgW6ayCwlmpwPjMm8knhDYxMzI0sjc0MLI2Nz0oSVxHkPtloH CgmkJ5akZqemFqQWwWxh4uCUamDMsi3mv3Ry76cAQ2fmeb9+hM89cc2Frd4m891TbTvZfSH9 k3/taPLr+qSuH+943ilhP+PCO7+5K8LVmvnEog4GzHso6XWocffeiRsfvONa8i1EwNw5c5Xi 7aqgx6Jf3vwXbXnQ9mYfS5fi2c+K0y3D/Hctf2027+Ps7XFnLR5++fIieLv9/fVLlViKMxIN tZiLihMBPppRcr8CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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 This patch integrates existing drm_panel and drm_bridge frameworks to one integrated framework, drm_hw_block. For this, I had already sent a email to make a discussion[1] about how we could support all bridges, one bridge between crtc and encoder, and another bridge between encoder and panel. Now existing drm_panel could be used only for real panel, and drm_bridge only for lvds bridge devices between encoder and panel. However, some embedded SoC have bridge devices of other type between crtc and encoder, i.e. Image Enhancer chip. So the existing encoder driver couldn't control such bridge commonly using existing drm_bridge because only drm_encoder has drm_bridge. Below shows how encoder driver could control bridge device using existing drm_bridge. display controller ----- bridge1 ----- mipi dsi ----- bridge2 ----- panel | /|\ /|\ |---------------| | controlled by drm_bridge | | | |---------------------------| controlled by drm_panel In the other hands, drm_panel has no any dependency of drm_encoder, and its infrastructure could be used by crtc driver with a little change. So this integrated framework basically uses existing infrastructure of drm_panel, and just adds drm_lvds structure to it for backward compatibility. And then, we could add a new bridge type, i.e. drm_enhancer in the near future. So this patch is just ready for that. As a result, if we add drm_enhancer, crtc driver could control a bridge device between crtc and encoder like below. display controller ----- bridge1 ----- mipi dsi ----- bridge2 ----- panel | /|\ | /|\ /|\ |--------------------| |---------------| | controlled by drm_enhancer controlled by drm_lvds | | | |--------------------------| controlled by drm_panel Changelog v2: - Call enable and disable callback according to bridge type. - Correct module description. [1] http://www.spinics.net/lists/dri-devel/msg55555.html Signed-off-by: Inki Dae --- drivers/gpu/drm/Kconfig | 4 ++ drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_hw_block.c | 104 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_panel.c | 100 -------------------------- drivers/gpu/drm/exynos/Kconfig | 1 + drivers/gpu/drm/panel/Kconfig | 1 + drivers/gpu/drm/panel/panel-simple.c | 37 +++++----- drivers/gpu/drm/tegra/drm.h | 2 +- drivers/gpu/drm/tegra/dsi.c | 10 +-- drivers/gpu/drm/tegra/output.c | 22 +++--- include/drm/drm_hw_block.h | 127 ++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 82 ---------------------- 12 files changed, 274 insertions(+), 218 deletions(-) create mode 100644 drivers/gpu/drm/drm_hw_block.c delete mode 100644 drivers/gpu/drm/drm_panel.c create mode 100644 include/drm/drm_hw_block.h delete mode 100644 include/drm/drm_panel.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 8e7fa4d..020a0f2 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -24,6 +24,10 @@ config DRM_MIPI_DSI bool depends on DRM +config DRM_HW_BLOCK + bool + depends on DRM + config DRM_USB tristate depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 292a79d..a943663 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -18,7 +18,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ drm-$(CONFIG_COMPAT) += drm_ioc32.o drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o drm-$(CONFIG_PCI) += ati_pcigart.o -drm-$(CONFIG_DRM_PANEL) += drm_panel.o +drm-$(CONFIG_DRM_HW_BLOCK) += drm_hw_block.o drm-usb-y := drm_usb.o diff --git a/drivers/gpu/drm/drm_hw_block.c b/drivers/gpu/drm/drm_hw_block.c new file mode 100644 index 0000000..9ba73a8 --- /dev/null +++ b/drivers/gpu/drm/drm_hw_block.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2013, NVIDIA Corporation. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +#include +#include + +static DEFINE_MUTEX(hw_block_lock); +static LIST_HEAD(hw_block_list); + +void drm_hw_block_init(struct drm_hw_block *block) +{ + INIT_LIST_HEAD(&block->list); +} +EXPORT_SYMBOL(drm_hw_block_init); + +int drm_hw_block_add(struct drm_hw_block *block) +{ + mutex_lock(&hw_block_lock); + list_add_tail(&block->list, &hw_block_list); + mutex_unlock(&hw_block_lock); + + return 0; +} +EXPORT_SYMBOL(drm_hw_block_add); + +void drm_hw_block_remove(struct drm_hw_block *block) +{ + mutex_lock(&hw_block_lock); + list_del_init(&block->list); + mutex_unlock(&hw_block_lock); +} +EXPORT_SYMBOL(drm_hw_block_remove); + +int drm_hw_block_attach(struct drm_hw_block *block, + struct drm_connector *connector) +{ + if (block->type == DRM_HW_BLOCK_PANEL) { + if (block->connector) + return -EBUSY; + + block->connector = connector; + } + + block->drm = connector->dev; + + return 0; +} +EXPORT_SYMBOL(drm_hw_block_attach); + +int drm_hw_block_detach(struct drm_hw_block *block) +{ + block->connector = NULL; + block->drm = NULL; + + return 0; +} +EXPORT_SYMBOL(drm_hw_block_detach); + +#ifdef CONFIG_OF +struct drm_hw_block *of_drm_find_hw_block(struct device_node *np) +{ + struct drm_hw_block *block; + + mutex_lock(&hw_block_lock); + + list_for_each_entry(block, &hw_block_list, list) { + if (block->dev->of_node == np) { + mutex_unlock(&hw_block_lock); + return block; + } + } + + mutex_unlock(&hw_block_lock); + return NULL; +} +EXPORT_SYMBOL(of_drm_find_hw_block); +#endif + +MODULE_AUTHOR("Thierry Reding "); +MODULE_DESCRIPTION("DRM hardware block infrastructure"); +MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c deleted file mode 100644 index 2ef988e..0000000 --- a/drivers/gpu/drm/drm_panel.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2013, NVIDIA Corporation. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include - -#include -#include - -static DEFINE_MUTEX(panel_lock); -static LIST_HEAD(panel_list); - -void drm_panel_init(struct drm_panel *panel) -{ - INIT_LIST_HEAD(&panel->list); -} -EXPORT_SYMBOL(drm_panel_init); - -int drm_panel_add(struct drm_panel *panel) -{ - mutex_lock(&panel_lock); - list_add_tail(&panel->list, &panel_list); - mutex_unlock(&panel_lock); - - return 0; -} -EXPORT_SYMBOL(drm_panel_add); - -void drm_panel_remove(struct drm_panel *panel) -{ - mutex_lock(&panel_lock); - list_del_init(&panel->list); - mutex_unlock(&panel_lock); -} -EXPORT_SYMBOL(drm_panel_remove); - -int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector) -{ - if (panel->connector) - return -EBUSY; - - panel->connector = connector; - panel->drm = connector->dev; - - return 0; -} -EXPORT_SYMBOL(drm_panel_attach); - -int drm_panel_detach(struct drm_panel *panel) -{ - panel->connector = NULL; - panel->drm = NULL; - - return 0; -} -EXPORT_SYMBOL(drm_panel_detach); - -#ifdef CONFIG_OF -struct drm_panel *of_drm_find_panel(struct device_node *np) -{ - struct drm_panel *panel; - - mutex_lock(&panel_lock); - - list_for_each_entry(panel, &panel_list, list) { - if (panel->dev->of_node == np) { - mutex_unlock(&panel_lock); - return panel; - } - } - - mutex_unlock(&panel_lock); - return NULL; -} -EXPORT_SYMBOL(of_drm_find_panel); -#endif - -MODULE_AUTHOR("Thierry Reding "); -MODULE_DESCRIPTION("DRM panel infrastructure"); -MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig index f227f54..4dbdd7a 100644 --- a/drivers/gpu/drm/exynos/Kconfig +++ b/drivers/gpu/drm/exynos/Kconfig @@ -8,6 +8,7 @@ config DRM_EXYNOS select FB_CFB_IMAGEBLIT select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE select VIDEOMODE_HELPERS + select DRM_PANEL help Choose this option if you have a Samsung SoC EXYNOS chipset. If M is selected the module will be called exynosdrm. diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index 3e0f13d..db471a0 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -1,6 +1,7 @@ config DRM_PANEL bool depends on DRM + select DRM_HW_BLOCK help Panel registration and lookup framework. diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 3e611af..f304f66 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include struct panel_desc { const struct drm_display_mode *modes; @@ -48,7 +48,7 @@ struct panel_desc { #define GPIO_ACTIVE_LOW (1 << 0) struct panel_simple { - struct drm_panel base; + struct drm_hw_block base; bool enabled; const struct panel_desc *desc; @@ -61,9 +61,9 @@ struct panel_simple { int enable_gpio; }; -static inline struct panel_simple *to_panel_simple(struct drm_panel *panel) +static inline struct panel_simple *to_panel_simple(struct drm_hw_block *block) { - return container_of(panel, struct panel_simple, base); + return container_of(block, struct panel_simple, base); } static int panel_simple_get_fixed_modes(struct panel_simple *panel) @@ -98,9 +98,9 @@ static int panel_simple_get_fixed_modes(struct panel_simple *panel) return num; } -static int panel_simple_disable(struct drm_panel *panel) +static int panel_simple_disable(struct drm_hw_block *block) { - struct panel_simple *p = to_panel_simple(panel); + struct panel_simple *p = to_panel_simple(block); if (!p->enabled) return 0; @@ -123,9 +123,9 @@ static int panel_simple_disable(struct drm_panel *panel) return 0; } -static int panel_simple_enable(struct drm_panel *panel) +static int panel_simple_enable(struct drm_hw_block *block) { - struct panel_simple *p = to_panel_simple(panel); + struct panel_simple *p = to_panel_simple(block); int err; if (p->enabled) @@ -133,7 +133,7 @@ static int panel_simple_enable(struct drm_panel *panel) err = regulator_enable(p->supply); if (err < 0) { - dev_err(panel->dev, "failed to enable supply: %d\n", err); + dev_err(block->dev, "failed to enable supply: %d\n", err); return err; } @@ -154,16 +154,16 @@ static int panel_simple_enable(struct drm_panel *panel) return 0; } -static int panel_simple_get_modes(struct drm_panel *panel) +static int panel_simple_get_modes(struct drm_hw_block *block) { - struct panel_simple *p = to_panel_simple(panel); + struct panel_simple *p = to_panel_simple(block); int num = 0; /* probe EDID if a DDC bus is available */ if (p->ddc) { - struct edid *edid = drm_get_edid(panel->connector, p->ddc); + struct edid *edid = drm_get_edid(block->connector, p->ddc); if (edid) { - num += drm_add_edid_modes(panel->connector, edid); + num += drm_add_edid_modes(block->connector, edid); kfree(edid); } } @@ -246,11 +246,12 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) } } - drm_panel_init(&panel->base); + panel->base.type = DRM_HW_BLOCK_PANEL; + drm_hw_block_init(&panel->base); panel->base.dev = dev; - panel->base.funcs = &panel_simple_funcs; + panel->base.panel_funcs = &panel_simple_funcs; - err = drm_panel_add(&panel->base); + err = drm_hw_block_add(&panel->base); if (err < 0) goto free_ddc; @@ -275,8 +276,8 @@ static int panel_simple_remove(struct device *dev) { struct panel_simple *panel = dev_get_drvdata(dev); - drm_panel_detach(&panel->base); - drm_panel_remove(&panel->base); + drm_hw_block_detach(&panel->base); + drm_hw_block_remove(&panel->base); panel_simple_disable(&panel->base); diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index bf1cac7..a8ec39f 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -194,7 +194,7 @@ struct tegra_output { const struct tegra_output_ops *ops; enum tegra_output_type type; - struct drm_panel *panel; + struct drm_hw_block *block; struct i2c_adapter *ddc; const struct edid *edid; unsigned int hpd_irq; diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c index d452faab..012a1ba 100644 --- a/drivers/gpu/drm/tegra/dsi.c +++ b/drivers/gpu/drm/tegra/dsi.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include