From patchwork Thu Jul 17 20:43:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar X-Patchwork-Id: 4578831 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 C17819F37C for ; Thu, 17 Jul 2014 20:47:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3D0D20160 for ; Thu, 17 Jul 2014 20:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73BC02011E for ; Thu, 17 Jul 2014 20:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753929AbaGQUrL (ORCPT ); Thu, 17 Jul 2014 16:47:11 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:50033 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752881AbaGQUrK (ORCPT ); Thu, 17 Jul 2014 16:47:10 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N8V000EKJ2KQD20@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Fri, 18 Jul 2014 05:47:08 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id A5.05.14704.C4638C35; Fri, 18 Jul 2014 05:47:08 +0900 (KST) X-AuditID: cbfee68f-b7fef6d000003970-c1-53c8364c91d6 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id E9.6C.04943.C4638C35; Fri, 18 Jul 2014 05:47:08 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N8V002BCJ1T7D60@mmp1.samsung.com>; Fri, 18 Jul 2014 05:47:08 +0900 (KST) From: Ajay Kumar To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, robdclark@gmail.com, daniel.vetter@ffwll.ch, thierry.reding@gmail.com, seanpaul@google.com, ajaynumb@gmail.com, jg1.han@samsung.com, joshi@samsung.com, prashanth.g@samsung.com, javier@dowhile0.org, Ajay Kumar Subject: [PATCH V5 07/12] drm/bridge: Add a driver which binds drm_bridge with drm_panel Date: Fri, 18 Jul 2014 02:13:53 +0530 Message-id: <1405629839-12086-8-git-send-email-ajaykumar.rs@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1405629839-12086-1-git-send-email-ajaykumar.rs@samsung.com> References: <1405629839-12086-1-git-send-email-ajaykumar.rs@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRmVeSWpSXmKPExsWyRsSkStfH7ESwwZbXMhYH3h9ksdjwZiGz xcKHd5ktrnx9z2Yx6f4EFotrv2ewWVxeeInV4vuuL+wWM87vY7JYdXgDu8XzhT+YLeYezLX4 uWseiwOvx9/Zrcwee78tYPHYOesuu8eCTaUe97uPM3n0bVnF6PF5k1wAexSXTUpqTmZZapG+ XQJXxtdtz9gKNrlUrH3XwdTA2GbZxcjJISFgIrFvz112CFtM4sK99WxdjFwcQgJLGSWurusD SnCAFS1YnwoRX8QosfXkGiYIZwKTxKzFq1hButkEtCW2Tb/JAmKLCLhJNB2eyQpSxCzQzSSx 795ZsISwQJTE4e9z2UBsFgFViQuLj4I18wp4SKzav50RYpuCxJxJNiBhTgFPiZmdP8BahYBK fu7+zgwyU0LgGr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LEzMLJXEeQ+0WgcKCaQnlqRmp6YWpBbB9DFxcEo1MC6fufpt p3jcq6bHncpsgq9ez/j5zYilfOvuiTwlG//c1tneyGPnvlxxV9+V39cuPbZcdu5mc1qfRumN aywJF2ouL33peTXW1sZvauj3c1kLqirf7svkZ5YKnzjXYEWNr1vZt2eXjzzQn7J8f61CxLfU Gdc9tN2vV1pds83a2KM9a+spztKjeyYqsRRnJBpqMRcVJwIAGdMZO94CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Add a dummy bridge which binds all of the drm_bridge callbacks to corresponding drm_panel callbacks. In theory, this is just a glue layer for the last bridge and the panel attached to it. This driver also implements the required drm_connector ops for the encoder(on which the entire bridge chain is hanging off). Signed-off-by: Ajay Kumar --- drivers/gpu/drm/bridge/Kconfig | 7 ++ drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/panel_binder.c | 193 +++++++++++++++++++++++++++++++++ include/drm/bridge/panel_binder.h | 44 ++++++++ 4 files changed, 245 insertions(+) create mode 100644 drivers/gpu/drm/bridge/panel_binder.c create mode 100644 include/drm/bridge/panel_binder.h diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 884923f..e3fb487 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -3,3 +3,10 @@ config DRM_PTN3460 depends on DRM select DRM_KMS_HELPER ---help--- + +config DRM_PANEL_BINDER + tristate "bridge panel binder" + depends on DRM + select DRM_KMS_HELPER + select DRM_PANEL + ---help--- diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index b4733e1..ba8b5b8 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -1,3 +1,4 @@ ccflags-y := -Iinclude/drm obj-$(CONFIG_DRM_PTN3460) += ptn3460.o +obj-$(CONFIG_DRM_PANEL_BINDER) += panel_binder.o diff --git a/drivers/gpu/drm/bridge/panel_binder.c b/drivers/gpu/drm/bridge/panel_binder.c new file mode 100644 index 0000000..6160ed5 --- /dev/null +++ b/drivers/gpu/drm/bridge/panel_binder.c @@ -0,0 +1,193 @@ +/* + * Copyright (C) 2014 Samsung Electronics Co., Ltd. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +#include + +#include "drmP.h" +#include "drm_crtc.h" +#include "drm_crtc_helper.h" + +#include "bridge/panel_binder.h" + +struct panel_binder { + struct drm_connector connector; + struct i2c_client *client; + struct drm_encoder *encoder; + struct drm_bridge *bridge; + struct drm_panel *panel; +}; + +static void panel_binder_pre_enable(struct drm_bridge *bridge) +{ + struct panel_binder *panel_binder = bridge->driver_private; + + drm_panel_prepare(panel_binder->panel); +} + +static void panel_binder_enable(struct drm_bridge *bridge) +{ + struct panel_binder *panel_binder = bridge->driver_private; + + drm_panel_enable(panel_binder->panel); +} + +static void panel_binder_disable(struct drm_bridge *bridge) +{ + struct panel_binder *panel_binder = bridge->driver_private; + + drm_panel_disable(panel_binder->panel); +} + +static void panel_binder_post_disable(struct drm_bridge *bridge) +{ + struct panel_binder *panel_binder = bridge->driver_private; + + drm_panel_unprepare(panel_binder->panel); +} + +void panel_binder_destroy(struct drm_bridge *bridge) +{ + struct panel_binder *panel_binder = bridge->driver_private; + + drm_panel_detach(panel_binder->panel); + drm_bridge_cleanup(bridge); +} + +struct drm_bridge_funcs panel_binder_funcs = { + .pre_enable = panel_binder_pre_enable, + .enable = panel_binder_enable, + .disable = panel_binder_disable, + .post_disable = panel_binder_post_disable, + .destroy = panel_binder_destroy, +}; + +static int panel_binder_mode_valid(struct drm_connector *connector, + struct drm_display_mode *mode) +{ + return MODE_OK; +} + +static int panel_binder_get_modes(struct drm_connector *connector) +{ + struct panel_binder *panel_binder; + + panel_binder = container_of(connector, struct panel_binder, connector); + + return panel_binder->panel->funcs->get_modes(panel_binder->panel); +} + +static struct drm_encoder *panel_binder_best_encoder(struct drm_connector + *connector) +{ + struct panel_binder *panel_binder; + + panel_binder = container_of(connector, struct panel_binder, connector); + + return panel_binder->encoder; +} + +static const struct drm_connector_helper_funcs + panel_binder_connector_helper_funcs = { + .get_modes = panel_binder_get_modes, + .mode_valid = panel_binder_mode_valid, + .best_encoder = panel_binder_best_encoder, +}; + +static enum drm_connector_status panel_binder_detect(struct drm_connector + *connector, bool force) +{ + return connector_status_connected; +} + +static void panel_binder_connector_destroy(struct drm_connector *connector) +{ + drm_connector_cleanup(connector); +} + +static const struct drm_connector_funcs panel_binder_connector_funcs = { + .dpms = drm_helper_connector_dpms, + .fill_modes = drm_helper_probe_single_connector_modes, + .detect = panel_binder_detect, + .destroy = panel_binder_connector_destroy, +}; + +struct drm_bridge *panel_binder_init(struct drm_device *dev, + struct drm_encoder *encoder, + struct i2c_client *client, + struct device_node *node, + struct drm_panel *panel, + int connector_type, + uint8_t polled) +{ + int ret; + struct drm_bridge *bridge; + struct panel_binder *panel_binder; + + if (IS_ERR_OR_NULL(panel)) { + DRM_ERROR("invalid drm_panel pointer\n"); + return NULL; + } + + bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL); + if (!bridge) { + DRM_ERROR("failed to allocate drm bridge\n"); + return NULL; + } + + panel_binder = devm_kzalloc(dev->dev, sizeof(*panel_binder), + GFP_KERNEL); + if (!panel_binder) { + DRM_ERROR("failed to allocate bridge panel_binder\n"); + return NULL; + } + + panel_binder->client = client; + panel_binder->encoder = encoder; + panel_binder->bridge = bridge; + panel_binder->panel = panel; + + ret = drm_bridge_init(dev, bridge, &panel_binder_funcs); + if (ret) { + DRM_ERROR("failed to initialize bridge with drm\n"); + goto err; + } + + bridge->driver_private = panel_binder; + + drm_panel_attach(panel_binder->panel, &panel_binder->connector); + + if (!encoder->bridge) + /* First entry in the bridge chain */ + encoder->bridge = bridge; + + panel_binder->connector.polled = polled; + ret = drm_connector_init(dev, &panel_binder->connector, + &panel_binder_connector_funcs, connector_type); + if (ret) { + DRM_ERROR("failed to initialize connector with drm\n"); + goto err; + } + drm_connector_helper_add(&panel_binder->connector, + &panel_binder_connector_helper_funcs); + drm_connector_register(&panel_binder->connector); + drm_mode_connector_attach_encoder(&panel_binder->connector, encoder); + + return bridge; + +err: + return NULL; +} +EXPORT_SYMBOL(panel_binder_init); diff --git a/include/drm/bridge/panel_binder.h b/include/drm/bridge/panel_binder.h new file mode 100644 index 0000000..5bed382 --- /dev/null +++ b/include/drm/bridge/panel_binder.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2014 Samsung Electronics Co., Ltd. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _DRM_BRIDGE_PANEL_H_ +#define _DRM_BRIDGE_PANEL_H_ + +struct drm_device; +struct drm_encoder; +struct i2c_client; +struct device_node; +struct drm_panel; + +#if defined(CONFIG_DRM_PANEL_BINDER) || defined(CONFIG_DRM_PANEL_BINDER_MODULE) +struct drm_bridge *panel_binder_init(struct drm_device *dev, + struct drm_encoder *encoder, + struct i2c_client *client, + struct device_node *node, + struct drm_panel *panel, + int connector_type, + uint8_t polled); +#else +static inline struct drm_bridge *panel_binder_init(struct drm_device *dev, + struct drm_encoder *encoder, + struct i2c_client *client, + struct device_node *node, + struct drm_panel *panel, + int connector_type, + uint8_t polled) +{ + return 0; +} +#endif + +#endif