From patchwork Sun Mar 5 16:00:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9604909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 30FAF60234 for ; Mon, 6 Mar 2017 00:11:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2319B272F9 for ; Mon, 6 Mar 2017 00:11:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17C9927D45; Mon, 6 Mar 2017 00:11:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AFD2C272F9 for ; Mon, 6 Mar 2017 00:11:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C0C06E399; Mon, 6 Mar 2017 00:08:41 +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 4E0206E2CB for ; Sun, 5 Mar 2017 16:00:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E0312034F; Sun, 5 Mar 2017 16:00:15 +0000 (UTC) Received: from CookieMonster.cookiemonster.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4B7020361; Sun, 5 Mar 2017 16:00:12 +0000 (UTC) From: Kieran Bingham To: laurent.pinchart@ideasonboard.com Subject: [PATCH v3 2/3] v4l: vsp1: Extend VSP1 module API to allow DRM callbacks Date: Sun, 5 Mar 2017 16:00:03 +0000 Message-Id: <200127cf978c8d8904e43ab2b28a225e8a786f6e.1488729419.git-series.kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: ClamAV using ClamSMTP X-Mailman-Approved-At: Mon, 06 Mar 2017 00:08:29 +0000 Cc: linux-renesas-soc@vger.kernel.org, Kieran Bingham , dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org 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" X-Virus-Scanned: ClamAV using ClamSMTP To be able to perform page flips in DRM without flicker we need to be able to notify the rcar-du module when the VSP has completed its processing. We must not have bidirectional dependencies on the two components to maintain support for loadable modules, thus we extend the API to allow a callback to be registered within the VSP DRM interface. Signed-off-by: Kieran Bingham --- drivers/media/platform/vsp1/vsp1_drm.c | 17 +++++++++++++++++ drivers/media/platform/vsp1/vsp1_drm.h | 11 +++++++++++ include/media/vsp1.h | 13 +++++++++++++ 3 files changed, 41 insertions(+) diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c index 4ee437c7ff0c..d93bf7d3a39e 100644 --- a/drivers/media/platform/vsp1/vsp1_drm.c +++ b/drivers/media/platform/vsp1/vsp1_drm.c @@ -37,6 +37,14 @@ void vsp1_drm_display_start(struct vsp1_device *vsp1) vsp1_dlm_irq_display_start(vsp1->drm->pipe.output->dlm); } +static void vsp1_du_pipeline_frame_end(struct vsp1_pipeline *pipe) +{ + struct vsp1_drm *drm = to_vsp1_drm(pipe); + + if (drm->du_complete) + drm->du_complete(drm->du_private); +} + /* ----------------------------------------------------------------------------- * DU Driver API */ @@ -96,6 +104,7 @@ int vsp1_du_setup_lif(struct device *dev, const struct vsp1_du_lif_config *cfg) } pipe->num_inputs = 0; + vsp1->drm->du_complete = NULL; vsp1_dlm_reset(pipe->output->dlm); vsp1_device_put(vsp1); @@ -200,6 +209,13 @@ int vsp1_du_setup_lif(struct device *dev, const struct vsp1_du_lif_config *cfg) if (ret < 0) return ret; + /* + * Register a callback to allow us to notify the DRM framework of frame + * completion events. + */ + vsp1->drm->du_complete = cfg->callback; + vsp1->drm->du_private = cfg->callback_data; + ret = media_pipeline_start(&pipe->output->entity.subdev.entity, &pipe->pipe); if (ret < 0) { @@ -607,6 +623,7 @@ int vsp1_drm_init(struct vsp1_device *vsp1) pipe->lif = &vsp1->lif->entity; pipe->output = vsp1->wpf[0]; pipe->output->pipe = pipe; + pipe->frame_end = vsp1_du_pipeline_frame_end; return 0; } diff --git a/drivers/media/platform/vsp1/vsp1_drm.h b/drivers/media/platform/vsp1/vsp1_drm.h index c8d2f88fc483..3de2095cb0ce 100644 --- a/drivers/media/platform/vsp1/vsp1_drm.h +++ b/drivers/media/platform/vsp1/vsp1_drm.h @@ -23,6 +23,8 @@ * @num_inputs: number of active pipeline inputs at the beginning of an update * @inputs: source crop rectangle, destination compose rectangle and z-order * position for every input + * @du_complete: frame completion callback for the DU driver (optional) + * @du_private: data to be passed to the du_complete callback */ struct vsp1_drm { struct vsp1_pipeline pipe; @@ -33,8 +35,17 @@ struct vsp1_drm { struct v4l2_rect compose; unsigned int zpos; } inputs[VSP1_MAX_RPF]; + + /* Frame syncronisation */ + void (*du_complete)(void *); + void *du_private; }; +static inline struct vsp1_drm *to_vsp1_drm(struct vsp1_pipeline *pipe) +{ + return container_of(pipe, struct vsp1_drm, pipe); +} + int vsp1_drm_init(struct vsp1_device *vsp1); void vsp1_drm_cleanup(struct vsp1_device *vsp1); int vsp1_drm_create_links(struct vsp1_device *vsp1); diff --git a/include/media/vsp1.h b/include/media/vsp1.h index bfc701f04f3f..d59d0adf560d 100644 --- a/include/media/vsp1.h +++ b/include/media/vsp1.h @@ -20,9 +20,22 @@ struct device; int vsp1_du_init(struct device *dev); +/** + * struct vsp1_du_lif_config - VSP LIF configuration + * @width: output frame width + * @height: output frame height + * @callback: frame completion callback function (optional) + * @callback_data: data to be passed to the frame completion callback + * + * When the optional callback is provided to the VSP1, the VSP1 must guarantee + * that one completion callback is performed after every vsp1_du_atomic_flush() + */ struct vsp1_du_lif_config { unsigned int width; unsigned int height; + + void (*callback)(void *); + void *callback_data; }; int vsp1_du_setup_lif(struct device *dev, const struct vsp1_du_lif_config *cfg);