From patchwork Sat Dec 5 02:12:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 7774401 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@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 89327BEEE1 for ; Sat, 5 Dec 2015 02:14:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A385720551 for ; Sat, 5 Dec 2015 02:14:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E4B8205E8 for ; Sat, 5 Dec 2015 02:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932295AbbLECOD (ORCPT ); Fri, 4 Dec 2015 21:14:03 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:55019 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932288AbbLECNR (ORCPT ); Fri, 4 Dec 2015 21:13:17 -0500 Received: from avalon.bb.dnainternet.fi (85-23-193-79.bb.dnainternet.fi [85.23.193.79]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id EF9D422178; Sat, 5 Dec 2015 03:11:54 +0100 (CET) From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-sh@vger.kernel.org Subject: [PATCH v2 25/32] v4l: vsp1: Make pipeline inputs array index by RPF index Date: Sat, 5 Dec 2015 04:12:59 +0200 Message-Id: <1449281586-25726-26-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1449281586-25726-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1449281586-25726-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 The pipeline inputs array stores pointers to all RPFs contained in the pipeline. It's currently indexed contiguously by adding RPFs in the order they are found during graph walk. This can't easily support dynamic addition and removal of RPFs while streaming, which will be required for combined VSP+DU support. Make the array indexed by RPF index instead and skip NULL elements when iterating over RPFs. Signed-off-by: Laurent Pinchart --- drivers/media/platform/vsp1/vsp1_pipe.c | 6 +++++- drivers/media/platform/vsp1/vsp1_pipe.h | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 16 ++++++++++++---- drivers/media/platform/vsp1/vsp1_wpf.c | 5 ++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c index df11259dcc0a..d41e4ca94a02 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.c +++ b/drivers/media/platform/vsp1/vsp1_pipe.c @@ -140,14 +140,18 @@ const struct vsp1_format_info *vsp1_get_format_info(u32 fourcc) void vsp1_pipeline_reset(struct vsp1_pipeline *pipe) { + unsigned int i; + if (pipe->bru) { struct vsp1_bru *bru = to_bru(&pipe->bru->subdev); - unsigned int i; for (i = 0; i < ARRAY_SIZE(bru->inputs); ++i) bru->inputs[i].rpf = NULL; } + for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) + pipe->inputs[i] = NULL; + INIT_LIST_HEAD(&pipe->entities); pipe->state = VSP1_PIPELINE_STOPPED; pipe->buffers_ready = 0; diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h b/drivers/media/platform/vsp1/vsp1_pipe.h index f9035c739e9a..c4c300561c5c 100644 --- a/drivers/media/platform/vsp1/vsp1_pipe.h +++ b/drivers/media/platform/vsp1/vsp1_pipe.h @@ -66,7 +66,7 @@ enum vsp1_pipeline_state { * @stream_count: number of streaming video nodes * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available * @num_inputs: number of RPFs - * @inputs: array of RPFs in the pipeline + * @inputs: array of RPFs in the pipeline (indexed by RPF index) * @output: WPF at the output of the pipeline * @bru: BRU entity, if present * @lif: LIF entity, if present diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 141e489a8aa9..d3335eb24cce 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -305,8 +305,8 @@ static int vsp1_video_pipeline_validate(struct vsp1_pipeline *pipe, if (e->type == VSP1_ENTITY_RPF) { rwpf = to_rwpf(subdev); - pipe->inputs[pipe->num_inputs++] = rwpf; - rwpf->video->pipe_index = pipe->num_inputs; + pipe->inputs[rwpf->entity.index] = rwpf; + rwpf->video->pipe_index = ++pipe->num_inputs; } else if (e->type == VSP1_ENTITY_WPF) { rwpf = to_rwpf(subdev); pipe->output = rwpf; @@ -329,7 +329,10 @@ static int vsp1_video_pipeline_validate(struct vsp1_pipeline *pipe, /* Follow links downstream for each input and make sure the graph * contains no loop and that all branches end at the output WPF. */ - for (i = 0; i < pipe->num_inputs; ++i) { + for (i = 0; i < video->vsp1->pdata.rpf_count; ++i) { + if (!pipe->inputs[i]) + continue; + ret = vsp1_video_pipeline_validate_branch(pipe, pipe->inputs[i], pipe->output); if (ret < 0) @@ -454,11 +457,16 @@ static void vsp1_video_frame_end(struct vsp1_pipeline *pipe, static void vsp1_video_pipeline_frame_end(struct vsp1_pipeline *pipe) { + struct vsp1_device *vsp1 = pipe->output->entity.vsp1; unsigned int i; /* Complete buffers on all video nodes. */ - for (i = 0; i < pipe->num_inputs; ++i) + for (i = 0; i < vsp1->pdata.rpf_count; ++i) { + if (!pipe->inputs[i]) + continue; + vsp1_video_frame_end(pipe, pipe->inputs[i]); + } if (!pipe->lif) vsp1_video_frame_end(pipe, pipe->output); diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c index 184a7e01aad5..d0edcde721bd 100644 --- a/drivers/media/platform/vsp1/vsp1_wpf.c +++ b/drivers/media/platform/vsp1/vsp1_wpf.c @@ -97,9 +97,12 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable) * inputs as sub-layers and select the virtual RPF as the master * layer. */ - for (i = 0; i < pipe->num_inputs; ++i) { + for (i = 0; i < vsp1->pdata.rpf_count; ++i) { struct vsp1_rwpf *input = pipe->inputs[i]; + if (!input) + continue; + srcrpf |= (!pipe->bru && pipe->num_inputs == 1) ? VI6_WPF_SRCRPF_RPF_ACT_MST(input->entity.index) : VI6_WPF_SRCRPF_RPF_ACT_SUB(input->entity.index);