From patchwork Fri Jan 22 00:57:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8086471 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 690F8BEEED for ; Fri, 22 Jan 2016 00:58:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A15C2042A for ; Fri, 22 Jan 2016 00:58:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AAFFF2041E for ; Fri, 22 Jan 2016 00:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751583AbcAVA6D (ORCPT ); Thu, 21 Jan 2016 19:58:03 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:58729 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751586AbcAVA6D (ORCPT ); Thu, 21 Jan 2016 19:58:03 -0500 Received: from avalon.access.network (nblzone-211-213.nblnetworks.fi [83.145.211.213]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id CDAEA2005A for ; Fri, 22 Jan 2016 01:56:57 +0100 (CET) From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Subject: [PATCH/RFC v2 53/56] v4l: vsp1: Store pipeline pointer in rwpf Date: Fri, 22 Jan 2016 02:57:22 +0200 Message-Id: <1453424245-18782-54-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1453424245-18782-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1453424245-18782-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-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=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 This prepares for the request API support by removing the need to store the pipeline pointer in the media entities. Signed-off-by: Laurent Pinchart --- drivers/media/platform/vsp1/vsp1_drv.c | 4 +--- drivers/media/platform/vsp1/vsp1_pipe.c | 14 +++++++++----- drivers/media/platform/vsp1/vsp1_pipe.h | 8 -------- drivers/media/platform/vsp1/vsp1_rwpf.h | 2 ++ drivers/media/platform/vsp1/vsp1_video.c | 13 +++++++------ 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index e0bcc67e2d07..0232057504d6 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -49,17 +49,15 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data) for (i = 0; i < vsp1->info->wpf_count; ++i) { struct vsp1_rwpf *wpf = vsp1->wpf[i]; - struct vsp1_pipeline *pipe; if (wpf == NULL) continue; - pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); status = vsp1_read(vsp1, VI6_WPF_IRQ_STA(i)); vsp1_write(vsp1, VI6_WPF_IRQ_STA(i), ~status & mask); if (status & VI6_WFP_IRQ_STA_FRE) { - vsp1_pipeline_frame_end(pipe); + vsp1_pipeline_frame_end(wpf->pipe); ret = IRQ_HANDLED; } } diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c index 2310ea34040d..1a9ca1dd9417 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.c +++ b/drivers/media/platform/vsp1/vsp1_pipe.c @@ -171,14 +171,18 @@ void vsp1_pipeline_reset(struct vsp1_pipeline *pipe) bru->inputs[i].rpf = NULL; } - for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) + for (i = 0; i < pipe->num_inputs; ++i) { + pipe->inputs[i]->pipe = NULL; pipe->inputs[i] = NULL; + } + + pipe->output->pipe = NULL; + pipe->output = NULL; INIT_LIST_HEAD(&pipe->entities); pipe->state = VSP1_PIPELINE_STOPPED; pipe->buffers_ready = 0; pipe->num_inputs = 0; - pipe->output = NULL; pipe->bru = NULL; pipe->lif = NULL; pipe->uds = NULL; @@ -343,7 +347,7 @@ void vsp1_pipelines_suspend(struct vsp1_device *vsp1) if (wpf == NULL) continue; - pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); + pipe = wpf->pipe; if (pipe == NULL) continue; @@ -360,7 +364,7 @@ void vsp1_pipelines_suspend(struct vsp1_device *vsp1) if (wpf == NULL) continue; - pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); + pipe = wpf->pipe; if (pipe == NULL) continue; @@ -384,7 +388,7 @@ void vsp1_pipelines_resume(struct vsp1_device *vsp1) if (wpf == NULL) continue; - pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); + pipe = wpf->pipe; if (pipe == NULL) continue; diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h b/drivers/media/platform/vsp1/vsp1_pipe.h index 1100229a1ed2..9fd688bfe638 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.h +++ b/drivers/media/platform/vsp1/vsp1_pipe.h @@ -103,14 +103,6 @@ struct vsp1_pipeline { struct vsp1_dl_list *dl; }; -static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e) -{ - if (likely(e->pipe)) - return container_of(e->pipe, struct vsp1_pipeline, pipe); - else - return NULL; -} - void vsp1_pipeline_reset(struct vsp1_pipeline *pipe); void vsp1_pipeline_init(struct vsp1_pipeline *pipe); diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h index 2637ae1a4719..a88589988b76 100644 --- a/drivers/media/platform/vsp1/vsp1_rwpf.h +++ b/drivers/media/platform/vsp1/vsp1_rwpf.h @@ -25,6 +25,7 @@ struct v4l2_ctrl; struct vsp1_dl_manager; +struct vsp1_pipeline; struct vsp1_rwpf; struct vsp1_video; @@ -36,6 +37,7 @@ struct vsp1_rwpf { struct vsp1_entity entity; struct v4l2_ctrl_handler ctrls; + struct vsp1_pipeline *pipe; struct vsp1_video *video; unsigned int max_width; diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index f3d26757e6e3..5c239b436bde 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -271,10 +271,12 @@ static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe, rwpf = to_rwpf(subdev); pipe->inputs[rwpf->entity.index] = rwpf; rwpf->video->pipe_index = ++pipe->num_inputs; + rwpf->pipe = pipe; } else if (e->type == VSP1_ENTITY_WPF) { rwpf = to_rwpf(subdev); pipe->output = rwpf; rwpf->video->pipe_index = 0; + rwpf->pipe = pipe; } else if (e->type == VSP1_ENTITY_LIF) { pipe->lif = e; } else if (e->type == VSP1_ENTITY_BRU) { @@ -360,7 +362,7 @@ static void vsp1_video_pipeline_cleanup(struct vsp1_pipeline *pipe) static struct vsp1_vb2_buffer * vsp1_video_complete_buffer(struct vsp1_video *video) { - struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); + struct vsp1_pipeline *pipe = video->rwpf->pipe; struct vsp1_vb2_buffer *next = NULL; struct vsp1_vb2_buffer *done; unsigned long flags; @@ -539,7 +541,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb) { struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); - struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); + struct vsp1_pipeline *pipe = video->rwpf->pipe; struct vsp1_vb2_buffer *buf = to_vsp1_vb2_buffer(vbuf); unsigned long flags; bool empty; @@ -606,7 +608,7 @@ static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe) static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) { struct vsp1_video *video = vb2_get_drv_priv(vq); - struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); + struct vsp1_pipeline *pipe = video->rwpf->pipe; unsigned long flags; int ret; @@ -633,7 +635,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) static void vsp1_video_stop_streaming(struct vb2_queue *vq) { struct vsp1_video *video = vb2_get_drv_priv(vq); - struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); + struct vsp1_pipeline *pipe = video->rwpf->pipe; struct vsp1_vb2_buffer *buffer; unsigned long flags; int ret; @@ -778,8 +780,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) * FIXME: This is racy, the ioctl is only protected by the video node * lock. */ - pipe = video->video.entity.pipe - ? to_vsp1_pipeline(&video->video.entity) : &video->pipe; + pipe = video->rwpf->pipe ? video->rwpf->pipe : &video->pipe; ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); if (ret < 0)