From patchwork Tue Feb 7 09:16:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 93538 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2145019obz; Tue, 7 Feb 2017 01:19:47 -0800 (PST) X-Received: by 10.98.192.72 with SMTP id x69mr18771336pff.129.1486459187072; Tue, 07 Feb 2017 01:19:47 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id c15si3499597plk.123.2017.02.07.01.19.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 01:19:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA03B6E629; Tue, 7 Feb 2017 09:19:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 708076E629 for ; Tue, 7 Feb 2017 09:19:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 106E7200ED; Tue, 7 Feb 2017 09:19:44 +0000 (UTC) Received: from localhost.localdomain (li411-102.members.linode.com [106.187.91.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CFB42202FE; Tue, 7 Feb 2017 09:19:27 +0000 (UTC) From: Shawn Guo To: Daniel Vetter Subject: [PATCH v3 12/23] drm: imx: remove struct imx_drm_crtc and imx_drm_crtc_helper_funcs Date: Tue, 7 Feb 2017 17:16:24 +0800 Message-Id: <1486458995-31018-13-git-send-email-shawnguo@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486458995-31018-1-git-send-email-shawnguo@kernel.org> References: <1486458995-31018-1-git-send-email-shawnguo@kernel.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham 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 Cc: Neil Armstrong , Liviu Dudau , Laurent Pinchart , Daniel Vetter , Marek Vasut , Alexey Brodkin , Russell King , Xinliang Liu , Tomi Valkeinen , Mali DP Maintainers , Ben Skeggs , Jyri Sarha , dri-devel@lists.freedesktop.org, Maxime Ripard X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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" From: Shawn Guo With the vblank hooks in struct drm_crtc_funcs, we do not need to maintain the CRTC specific vblank callbacks with struct imx_drm_crtc_helper_funcs any more. By moving the stuff that we currently do in imx_drm_add_crtc(), like of_node setting and drm_crtc_helper_add()/drm_crtc_init_with_planes() invoking, we can kill things like struct imx_drm_crtc, imx_drm_crtc_helper_funcs and related functions completely. Functions ipu_enable_vblank() and ipu_disable_vblank() are moved around without changes, only for saving the forward declarations. Signed-off-by: Shawn Guo Cc: Philipp Zabel Acked-by: Philipp Zabel --- drivers/gpu/drm/imx/imx-drm-core.c | 101 ------------------------------------- drivers/gpu/drm/imx/imx-drm.h | 13 ----- drivers/gpu/drm/imx/ipuv3-crtc.c | 58 ++++++++------------- 3 files changed, 22 insertions(+), 150 deletions(-) diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index 4badbb66d69e..65bd8b8a2494 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -40,17 +40,11 @@ struct imx_drm_component { struct imx_drm_device { struct drm_device *drm; - struct imx_drm_crtc *crtc[MAX_CRTC]; unsigned int pipes; struct drm_fbdev_cma *fbhelper; struct drm_atomic_state *state; }; -struct imx_drm_crtc { - struct drm_crtc *crtc; - struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; -}; - #if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) static int legacyfb_depth = 16; module_param(legacyfb_depth, int, 0444); @@ -63,38 +57,6 @@ static void imx_drm_driver_lastclose(struct drm_device *drm) drm_fbdev_cma_restore_mode(imxdrm->fbhelper); } -static int imx_drm_enable_vblank(struct drm_device *drm, unsigned int pipe) -{ - struct imx_drm_device *imxdrm = drm->dev_private; - struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe]; - int ret; - - if (!imx_drm_crtc) - return -EINVAL; - - if (!imx_drm_crtc->imx_drm_helper_funcs.enable_vblank) - return -ENOSYS; - - ret = imx_drm_crtc->imx_drm_helper_funcs.enable_vblank( - imx_drm_crtc->crtc); - - return ret; -} - -static void imx_drm_disable_vblank(struct drm_device *drm, unsigned int pipe) -{ - struct imx_drm_device *imxdrm = drm->dev_private; - struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe]; - - if (!imx_drm_crtc) - return; - - if (!imx_drm_crtc->imx_drm_helper_funcs.disable_vblank) - return; - - imx_drm_crtc->imx_drm_helper_funcs.disable_vblank(imx_drm_crtc->crtc); -} - static const struct file_operations imx_drm_driver_fops = { .owner = THIS_MODULE, .open = drm_open, @@ -180,67 +142,6 @@ static void imx_drm_atomic_commit_tail(struct drm_atomic_state *state) .atomic_commit_tail = imx_drm_atomic_commit_tail, }; -/* - * imx_drm_add_crtc - add a new crtc - */ -int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, - struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane, - const struct imx_drm_crtc_helper_funcs *imx_drm_helper_funcs, - struct device_node *port) -{ - struct imx_drm_device *imxdrm = drm->dev_private; - struct imx_drm_crtc *imx_drm_crtc; - - /* - * The vblank arrays are dimensioned by MAX_CRTC - we can't - * pass IDs greater than this to those functions. - */ - if (imxdrm->pipes >= MAX_CRTC) - return -EINVAL; - - if (imxdrm->drm->open_count) - return -EBUSY; - - imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL); - if (!imx_drm_crtc) - return -ENOMEM; - - imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs; - imx_drm_crtc->crtc = crtc; - - crtc->port = port; - - imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc; - - *new_crtc = imx_drm_crtc; - - drm_crtc_helper_add(crtc, - imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs); - - drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL, - imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs, NULL); - - return 0; -} -EXPORT_SYMBOL_GPL(imx_drm_add_crtc); - -/* - * imx_drm_remove_crtc - remove a crtc - */ -int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc) -{ - struct imx_drm_device *imxdrm = imx_drm_crtc->crtc->dev->dev_private; - unsigned int pipe = drm_crtc_index(imx_drm_crtc->crtc); - - drm_crtc_cleanup(imx_drm_crtc->crtc); - - imxdrm->crtc[pipe] = NULL; - - kfree(imx_drm_crtc); - - return 0; -} -EXPORT_SYMBOL_GPL(imx_drm_remove_crtc); int imx_drm_encoder_parse_of(struct drm_device *drm, struct drm_encoder *encoder, struct device_node *np) @@ -288,8 +189,6 @@ int imx_drm_encoder_parse_of(struct drm_device *drm, .gem_prime_vmap = drm_gem_cma_prime_vmap, .gem_prime_vunmap = drm_gem_cma_prime_vunmap, .gem_prime_mmap = drm_gem_cma_prime_mmap, - .enable_vblank = imx_drm_enable_vblank, - .disable_vblank = imx_drm_disable_vblank, .ioctls = imx_drm_ioctls, .num_ioctls = ARRAY_SIZE(imx_drm_ioctls), .fops = &imx_drm_driver_fops, diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h index 5a91cb16c8fa..cc003334505d 100644 --- a/drivers/gpu/drm/imx/imx-drm.h +++ b/drivers/gpu/drm/imx/imx-drm.h @@ -25,19 +25,6 @@ static inline struct imx_crtc_state *to_imx_crtc_state(struct drm_crtc_state *s) { return container_of(s, struct imx_crtc_state, base); } - -struct imx_drm_crtc_helper_funcs { - int (*enable_vblank)(struct drm_crtc *crtc); - void (*disable_vblank)(struct drm_crtc *crtc); - const struct drm_crtc_helper_funcs *crtc_helper_funcs; - const struct drm_crtc_funcs *crtc_funcs; -}; - -int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, - struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane, - const struct imx_drm_crtc_helper_funcs *imx_helper_funcs, - struct device_node *port); -int imx_drm_remove_crtc(struct imx_drm_crtc *); int imx_drm_init_drm(struct platform_device *pdev, int preferred_bpp); int imx_drm_exit_drm(void); diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c index 6be515a9fb69..a3f2843b78cd 100644 --- a/drivers/gpu/drm/imx/ipuv3-crtc.c +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c @@ -129,18 +129,31 @@ static void imx_drm_crtc_destroy_state(struct drm_crtc *crtc, kfree(to_imx_crtc_state(state)); } -static void imx_drm_crtc_destroy(struct drm_crtc *crtc) +static int ipu_enable_vblank(struct drm_crtc *crtc) +{ + struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); + + enable_irq(ipu_crtc->irq); + + return 0; +} + +static void ipu_disable_vblank(struct drm_crtc *crtc) { - imx_drm_remove_crtc(to_ipu_crtc(crtc)->imx_crtc); + struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); + + disable_irq_nosync(ipu_crtc->irq); } static const struct drm_crtc_funcs ipu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, - .destroy = imx_drm_crtc_destroy, + .destroy = drm_crtc_cleanup, .page_flip = drm_atomic_helper_page_flip, .reset = imx_drm_crtc_reset, .atomic_duplicate_state = imx_drm_crtc_duplicate_state, .atomic_destroy_state = imx_drm_crtc_destroy_state, + .enable_vblank = ipu_enable_vblank, + .disable_vblank = ipu_disable_vblank, }; static irqreturn_t ipu_irq_handler(int irq, void *dev_id) @@ -261,29 +274,6 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc) .enable = ipu_crtc_enable, }; -static int ipu_enable_vblank(struct drm_crtc *crtc) -{ - struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); - - enable_irq(ipu_crtc->irq); - - return 0; -} - -static void ipu_disable_vblank(struct drm_crtc *crtc) -{ - struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); - - disable_irq_nosync(ipu_crtc->irq); -} - -static const struct imx_drm_crtc_helper_funcs ipu_crtc_helper_funcs = { - .enable_vblank = ipu_enable_vblank, - .disable_vblank = ipu_disable_vblank, - .crtc_funcs = &ipu_crtc_funcs, - .crtc_helper_funcs = &ipu_helper_funcs, -}; - static void ipu_put_resources(struct ipu_crtc *ipu_crtc) { if (!IS_ERR_OR_NULL(ipu_crtc->dc)) @@ -321,6 +311,7 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, struct ipu_client_platformdata *pdata, struct drm_device *drm) { struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); + struct drm_crtc *crtc = &ipu_crtc->base; int dp = -EINVAL; int ret; @@ -340,19 +331,16 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, goto err_put_resources; } - ret = imx_drm_add_crtc(drm, &ipu_crtc->base, &ipu_crtc->imx_crtc, - &ipu_crtc->plane[0]->base, &ipu_crtc_helper_funcs, - pdata->of_node); - if (ret) { - dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret); - goto err_put_resources; - } + crtc->port = pdata->of_node; + drm_crtc_helper_add(crtc, &ipu_helper_funcs); + drm_crtc_init_with_planes(drm, crtc, &ipu_crtc->plane[0]->base, NULL, + &ipu_crtc_funcs, NULL); ret = ipu_plane_get_resources(ipu_crtc->plane[0]); if (ret) { dev_err(ipu_crtc->dev, "getting plane 0 resources failed with %d.\n", ret); - goto err_remove_crtc; + goto err_put_resources; } /* If this crtc is using the DP, add an overlay plane */ @@ -390,8 +378,6 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, ipu_plane_put_resources(ipu_crtc->plane[1]); err_put_plane0_res: ipu_plane_put_resources(ipu_crtc->plane[0]); -err_remove_crtc: - imx_drm_remove_crtc(ipu_crtc->imx_crtc); err_put_resources: ipu_put_resources(ipu_crtc);