From patchwork Thu Jun 5 19:10:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar X-Patchwork-Id: 4308201 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 BD33A9F163 for ; Thu, 5 Jun 2014 19:12:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A8B8520265 for ; Thu, 5 Jun 2014 19:12:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 767A820274 for ; Thu, 5 Jun 2014 19:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbaFETMo (ORCPT ); Thu, 5 Jun 2014 15:12:44 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:26940 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761AbaFETMn (ORCPT ); Thu, 5 Jun 2014 15:12:43 -0400 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N6P00CIIMP6R830@mailout1.samsung.com> for linux-samsung-soc@vger.kernel.org; Fri, 06 Jun 2014 04:12:42 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id D4.70.16580.921C0935; Fri, 06 Jun 2014 04:12:42 +0900 (KST) X-AuditID: cbfee691-b7f2f6d0000040c4-5c-5390c1297687 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 77.3D.08203.921C0935; Fri, 06 Jun 2014 04:12:41 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N6P00FLRMOSKS30@mmp2.samsung.com>; Fri, 06 Jun 2014 04:12:41 +0900 (KST) From: Ajay Kumar To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, seanpaul@google.com, jg1.han@samsung.com, ajaynumb@gmail.com, robdclark@gmail.com, daniel.vetter@ffwll.ch, thierry.reding@gmail.com, joshi@samsung.com, prashanth.g@samsung.com, Ajay Kumar Subject: [PATCH V3 3/8] drm/bridge: Add a driver which binds drm_bridge with drm_panel Date: Fri, 06 Jun 2014 00:40:47 +0530 Message-id: <1401995452-15798-4-git-send-email-ajaykumar.rs@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1401995452-15798-1-git-send-email-ajaykumar.rs@samsung.com> References: <1401995452-15798-1-git-send-email-ajaykumar.rs@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRmVeSWpSXmKPExsWyRsSkSlfr4IRgg+nTGS0OvD/IYrHhzUJm i4UP7zJbXPn6ns1i0v0JLBaXF15itfi+6wu7xYzz+5gsVh3ewG7xfOEPZou5B3Mtfu6ax+LA 47H32wIWj52z7rJ7LNhU6nG/+ziTR9+WVYwenzfJBbBFcdmkpOZklqUW6dslcGVcWjOPvWCV S8XMWZMZGxh7LLsYOTkkBEwkrj44xQRhi0lcuLeerYuRi0NIYCmjxIJfS5i7GDnAinbfY4WI T2eU6Fr3gwWkQUhgApPEx7OGIDabgLbEtuk3weIiAm4STYdngjUwC3xjlPhz/j4bSEJYIELi 8YEXYNtYBFQl1iw+zQpi8wp4SFzfP4cVYpmCxJxJNiBhTgFPib17p0Ht8pBYNvEc2HESAqfY JRonbmOEmCMg8W3yIRaIXlmJTQe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4uCUamCco/J7v+nbna/jX0ok HZt3q+aW5bXUA49OakhZ14YFKmxznSrk0WebYFunKmxbM+3u0UoXRcMZn1XF95YVJJvlcN5X n3V740Prw97WGTINb1+GFN+/9155wrarqw7cY7zYeOnEn+nnj+bL7BaYtHa9x75u/8k7E7PU Hf8e45LWLzwRP+Oj9JzlSizFGYmGWsxFxYkA0GH7jwEDAAA= 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=-7.5 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 | 196 +++++++++++++++++++++++++++++++++ include/drm/bridge/panel_binder.h | 42 +++++++ 4 files changed, 246 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..c97e3a9 --- /dev/null +++ b/drivers/gpu/drm/bridge/panel_binder.c @@ -0,0 +1,196 @@ +/* + * 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, + 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, +#ifdef CONFIG_DRM_PANEL_EDP + &panel_binder_connector_funcs, DRM_MODE_CONNECTOR_eDP); +#else + &panel_binder_connector_funcs, DRM_MODE_CONNECTOR_LVDS); +#endif + 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_sysfs_connector_add(&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..1ce7288 --- /dev/null +++ b/include/drm/bridge/panel_binder.h @@ -0,0 +1,42 @@ +/* + * 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) +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, + 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, + uint8_t polled) +{ + return 0; +} +#endif + +#endif