From patchwork Wed Mar 19 07:34:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 3850221 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 A88429F369 for ; Wed, 19 Mar 2014 07:35:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2B0C20386 for ; Wed, 19 Mar 2014 07:35:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B1F3B20381 for ; Wed, 19 Mar 2014 07:35:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C7B28A6ED; Wed, 19 Mar 2014 00:35:08 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by gabe.freedesktop.org (Postfix) with ESMTP id 7228A8A6ED for ; Wed, 19 Mar 2014 00:35:06 -0700 (PDT) Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2O004K4AEBZA70@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 19 Mar 2014 16:34:59 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.116]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id F0.36.10364.0A849235; Wed, 19 Mar 2014 16:34:56 +0900 (KST) X-AuditID: cbfee690-b7f266d00000287c-78-532948a0a3c1 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B3.C1.28157.F9849235; Wed, 19 Mar 2014 16:34:55 +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 <0N2O00CX3AE7B9B0@mmp2.samsung.com>; Wed, 19 Mar 2014 16:34:55 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH] drm: improve various bridge devices support Date: Wed, 19 Mar 2014 16:34:55 +0900 Message-id: <1395214495-13218-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGLMWRmVeSWpSXmKPExsWyRsSkRHeBh2awwamzXBZXvr5ns5h0fwKL A5PH/e7jTB59W1YxBjBFcdmkpOZklqUW6dslcGU8Pt7FUvDwBGPFhztcDYxvFzF2MXJwSAiY SFw7X9HFyAlkiklcuLeerYuRi0NIYCmjROeMHnaYmtMnHSHi0xklNh/4zwzhdDNJ9Px8zQTS zSagKjFxxX02EFtEQFni78RVjCA2M5B9sX8pM4gtLOAgcW5WL1g9C1D9u62zwOK8Ai4Sfce2 sUEsU5CYM8kGZL6EwAk2iRNvNzJD1AtIfJt8iAWiRlZi0wFmiKMlJQ6uuMEygVFwASPDKkbR 1ILkguKk9CITveLE3OLSvHS95PzcTYzAMDv979mEHYz3DlgfYkwGGjeRWUo0OR8Ypnkl8YbG ZkYWpiamxkbmlmakCSuJ86o9SgoSEkhPLEnNTk0tSC2KLyrNSS0+xMjEwSnVwMizkafkziuR X5ssForfsAz7cG/+Kd1DYU/0dr2ccvtp9qR4hce7vZa9S/hWJlulOlt/+qky7i7hda+/RFyZ cDbi6N3FsbXvD17qWy1Q9F3jRe4K2YCb9inL5NUU2NvZw1WvCGlOf83BZveDp3ZRzXZTuf+h As9Xyk8usPhQsu3eo6uCK2Qrn21RYinOSDTUYi4qTgQAQmIxWkkCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCIsWRmVeSWpSXmKPExsVy+t9jQd35HprBBov+21hc+fqezWLS/Qks Dkwe97uPM3n0bVnFGMAU1cBok5GamJJapJCal5yfkpmXbqvkHRzvHG9qZmCoa2hpYa6kkJeY m2qr5OIToOuWmQO0QEmhLDGnFCgUkFhcrKRvh2lCaIibrgVMY4Sub0gQXI+RARpIWMOY8fh4 F0vBwxOMFR/ucDUwvl3E2MXIwSEhYCJx+qRjFyMnkCkmceHeerYuRi4OIYHpjBKbD/xnhnC6 mSR6fr5mAqliE1CVmLjiPhuILSKgLPF34ipGEJsZyL7Yv5QZxBYWcJA4N6sXrJ4FqP7d1llg cV4BF4m+Y9vYIBYrSMyZZDOBkXsBI8MqRtHUguSC4qT0XCO94sTc4tK8dL3k/NxNjOAwfia9 g3FVg8UhRgEORiUe3gNRGsFCrIllxZW5hxglOJiVRHiF7wKFeFMSK6tSi/Lji0pzUosPMSYD LZ/ILCWanA+MsbySeENjEzMjSyNzQwsjY3PShJXEeQ+2WgcKCaQnlqRmp6YWpBbBbGHi4JRq YIw7uGmTatEfw+37vxuU3997O+K/wSu3u+o8e7dm7VV9Un7sO8+O6gUzz1T43pGzcVbfKM00 Oe1zbGCy4HyFGR7hLBzcUq/uLd5iy5Syb5FULs+FC7c3eFtYcm3MtpKQmWv2KijWolnoW5TZ 2TQt1tSdxgFro9Xusr2x28XjtvThnuxP0zXW/1ZiKc5INNRiLipOBAB44QFYpwIAAA== 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 [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 | 107 ++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 82 -------------------------- 12 files changed, 254 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..e7bb1fc --- /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 panel 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