From patchwork Mon Mar 21 09:38:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 8630781 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BD465C0553 for ; Mon, 21 Mar 2016 09:41:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C228B202BE for ; Mon, 21 Mar 2016 09:41:01 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C697A202B8 for ; Mon, 21 Mar 2016 09:41:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ahwKV-0003i7-8L; Mon, 21 Mar 2016 09:40:55 +0000 Received: from lucky1.263xmail.com ([211.157.147.132]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ahwK8-0002RL-5n; Mon, 21 Mar 2016 09:40:33 +0000 Received: from ykk?rock-chips.com (unknown [192.168.167.128]) by lucky1.263xmail.com (Postfix) with SMTP id 8129A61B05; Mon, 21 Mar 2016 17:40:07 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 2C212219D8; Mon, 21 Mar 2016 17:40:02 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-FST-TO: airlied@linux.ie X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: <8d4e2006f09c68b2984b095a0f194631> X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 149738RQEKT; Mon, 21 Mar 2016 17:40:03 +0800 (CST) From: Yakir Yang To: David Airlie , Mark Yao , Heiko Stuebner Subject: [RFC PATCH v1 1/4] drm: rockchip: add a common subdrv interfaces Date: Mon, 21 Mar 2016 17:38:03 +0800 Message-Id: <1458553083-26535-1-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458552518-25527-1-git-send-email-ykk@rock-chips.com> References: <1458552518-25527-1-git-send-email-ykk@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160321_024033_011358_9A356837 X-CRM114-Status: GOOD ( 11.85 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Russell King , Joonyoung Shim , Pawel Moll , Ian Campbell , Yakir Yang , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Rob Herring , Kumar Gala , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RDNS_NONE,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 Introduce a common subdrv register/unregister interfaces, help external driver to hook the drm open/close event. Signed-off-by: Yakir Yang --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 49 +++++++++++++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 15 +++++++++ 2 files changed, 64 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 896da09..4e0feb2 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -36,6 +36,8 @@ #define DRIVER_MAJOR 1 #define DRIVER_MINOR 0 +static LIST_HEAD(rockchip_drm_subdrv_list); + /* * Attach a (component) device to the shared drm dma mapping from master drm * device. This is used by the VOPs to map GEM buffers to a common DMA @@ -251,6 +253,51 @@ static int rockchip_drm_unload(struct drm_device *drm_dev) return 0; } +int rockchip_register_subdrv(struct drm_rockchip_subdrv *subdrv) +{ + if (!subdrv) + return -EINVAL; + + list_add_tail(&subdrv->list, &rockchip_drm_subdrv_list); + + return 0; +} +EXPORT_SYMBOL_GPL(rockchip_register_subdrv); + +int rockchip_unregister_subdrv(struct drm_rockchip_subdrv *subdrv) +{ + if (!subdrv) + return -EINVAL; + + list_del(&subdrv->list); + + return 0; +} +EXPORT_SYMBOL_GPL(rockchip_unregister_subdrv); + +static int rockchip_drm_open(struct drm_device *dev, struct drm_file *file) +{ + struct drm_rockchip_subdrv *subdrv; + int ret = 0; + + list_for_each_entry(subdrv, &rockchip_drm_subdrv_list, list) { + ret = subdrv->open(dev, subdrv->dev, file); + if (ret) + return ret; + } + + return 0; +} + +static void rockchip_drm_preclose(struct drm_device *dev, + struct drm_file *file) +{ + struct drm_rockchip_subdrv *subdrv; + + list_for_each_entry(subdrv, &rockchip_drm_subdrv_list, list) + subdrv->close(dev, subdrv->dev, file); +} + void rockchip_drm_lastclose(struct drm_device *dev) { struct rockchip_drm_private *priv = dev->dev_private; @@ -281,6 +328,8 @@ static struct drm_driver rockchip_drm_driver = { DRIVER_PRIME | DRIVER_ATOMIC, .load = rockchip_drm_load, .unload = rockchip_drm_unload, + .open = rockchip_drm_open, + .preclose = rockchip_drm_preclose, .lastclose = rockchip_drm_lastclose, .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = rockchip_drm_crtc_enable_vblank, diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 3529f69..5ea5fcb 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -42,6 +42,17 @@ struct rockchip_crtc_funcs { void (*wait_for_update)(struct drm_crtc *crtc); }; +struct drm_rockchip_subdrv { + struct list_head list; + struct device *dev; + struct drm_device *drm_dev; + + int (*open)(struct drm_device *drm_dev, struct device *dev, + struct drm_file *file); + void (*close)(struct drm_device *drm_dev, struct device *dev, + struct drm_file *file); +}; + struct rockchip_atomic_commit { struct work_struct work; struct drm_atomic_state *state; @@ -73,4 +84,8 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, struct device *dev); void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, struct device *dev); + +int rockchip_register_subdrv(struct drm_rockchip_subdrv *subdrv); +int rockchip_unregister_subdrv(struct drm_rockchip_subdrv *subdrv); + #endif /* _ROCKCHIP_DRM_DRV_H_ */