From patchwork Thu Aug 22 21:24:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 821545 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E73B51D1753; Thu, 22 Aug 2024 21:24:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724361893; cv=none; b=IzHMIW1AQ1XH6A2KVvHgqthhYPLwQyjvliR86qpazfMQbO3AwccRADKQHvx01Zn9nnTEL1odxkNBZ3q4buSanlJY03s7eGvulPnHsQfrTwasN9SV1+pw9VzsIJQmJ1ZETnE1a3bHJUvZzZfu+G4GuKjMRG9PwKIXy2CYDaEfglg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724361893; c=relaxed/simple; bh=MLDyfpjT+SmchGmpRWoLhkFRvYsGE89EYC55eOC4Lu4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RB0LSRYpnix2Z7jwyfL7BIgMnqpOKx0xDoD+E0wwYATGu85K8XhC7aEQI6kjQGc1bEABNdrG2v9CJMX28qsWruQHUgiAzcGuo9bjktxA539iRpBo5ohPQAKuKcDXiGwxXqaVzWtkZXQBBYyf7BzX/Alqovbuzd865ILscjARdOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=jZhtJSnF; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jZhtJSnF" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 84BE88A9; Thu, 22 Aug 2024 23:23:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1724361826; bh=MLDyfpjT+SmchGmpRWoLhkFRvYsGE89EYC55eOC4Lu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZhtJSnFxJepfMu9g7M3dchFiuXhEXp9RiZpiDhXgJU70KBNw6/6+d59UITBYHFzI boiGaFIcKnBMUHyj4SC7KRd5fJSwY2yQ+Ahr+ZsKPArGxypV7p3DSwxxbg5C8uFbNv WOsO1gUYfnmByI+l4EYKs9VtVoTDLlkqca0A5Qbw= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Kieran Bingham Subject: [PATCH 1/4] media: vsp1: Build the pipeline after starting it Date: Fri, 23 Aug 2024 00:24:40 +0300 Message-ID: <20240822212445.2037-2-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240822212445.2037-1-laurent.pinchart+renesas@ideasonboard.com> References: <20240822212445.2037-1-laurent.pinchart+renesas@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to use the new media pipeline iterators, the pipeline has to be built after being started. Refactor the code to do so. Switching to the iterators will happen in a separate step. Signed-off-by: Laurent Pinchart --- .../media/platform/renesas/vsp1/vsp1_video.c | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c index fdb46ec0c872..ca2d00c9be35 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_video.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c @@ -520,22 +520,6 @@ static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe, return ret; } - return 0; -} - -static int vsp1_video_pipeline_init(struct vsp1_pipeline *pipe, - struct vsp1_video *video) -{ - int ret; - - vsp1_pipeline_init(pipe); - - pipe->frame_end = vsp1_video_pipeline_frame_end; - - ret = vsp1_video_pipeline_build(pipe, video); - if (ret) - return ret; - vsp1_pipeline_dump(pipe, "video"); return 0; @@ -544,7 +528,6 @@ static int vsp1_video_pipeline_init(struct vsp1_pipeline *pipe, static struct vsp1_pipeline *vsp1_video_pipeline_get(struct vsp1_video *video) { struct vsp1_pipeline *pipe; - int ret; /* * Get a pipeline object for the video node. If a pipeline has already @@ -557,12 +540,9 @@ static struct vsp1_pipeline *vsp1_video_pipeline_get(struct vsp1_video *video) if (!pipe) return ERR_PTR(-ENOMEM); - ret = vsp1_video_pipeline_init(pipe, video); - if (ret < 0) { - vsp1_pipeline_reset(pipe); - kfree(pipe); - return ERR_PTR(ret); - } + vsp1_pipeline_init(pipe); + + pipe->frame_end = vsp1_video_pipeline_frame_end; } else { pipe = video->rwpf->entity.pipe; kref_get(&pipe->kref); @@ -579,12 +559,17 @@ static void vsp1_video_pipeline_release(struct kref *kref) kfree(pipe); } +static void __vsp1_video_pipeline_put(struct vsp1_pipeline *pipe) +{ + kref_put(&pipe->kref, vsp1_video_pipeline_release); +} + static void vsp1_video_pipeline_put(struct vsp1_pipeline *pipe) { struct media_device *mdev = &pipe->output->entity.vsp1->media_dev; mutex_lock(&mdev->graph_mutex); - kref_put(&pipe->kref, vsp1_video_pipeline_release); + __vsp1_video_pipeline_put(pipe); mutex_unlock(&mdev->graph_mutex); } @@ -985,8 +970,23 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) ret = __video_device_pipeline_start(&video->video, &pipe->pipe); if (ret < 0) { + __vsp1_video_pipeline_put(pipe); mutex_unlock(&mdev->graph_mutex); - goto err_pipe; + return ret; + } + + /* + * If the pipeline hasn't been built, do so now. This needs to happen + * after __media_pipeline_start() to use the pipeline iterators. + */ + if (!pipe->output) { + ret = vsp1_video_pipeline_build(pipe, video); + if (ret < 0) { + __media_pipeline_stop(video->video.entity.pads); + __vsp1_video_pipeline_put(pipe); + mutex_unlock(&mdev->graph_mutex); + return ret; + } } mutex_unlock(&mdev->graph_mutex); @@ -997,18 +997,17 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) */ ret = vsp1_video_verify_format(video); if (ret < 0) - goto err_stop; + goto error; /* Start the queue. */ ret = vb2_streamon(&video->queue, type); if (ret < 0) - goto err_stop; + goto error; return 0; -err_stop: +error: video_device_pipeline_stop(&video->video); -err_pipe: vsp1_video_pipeline_put(pipe); return ret; } From patchwork Thu Aug 22 21:24:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 821544 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B67D1D2786; Thu, 22 Aug 2024 21:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724361897; cv=none; b=NZ+IUjsBavKAgaaGSeOwsrb773PXEfUkP90DD2+lD4N6d/ACGToOgE9/bYaNoK+DBXoaYkh4NUSNl1MXT1j6Gvw5VCOCTAd4mXO6smAKVcJQdulEjgrlUg/ncWdNCzaba+YaUn6MevZMw4kgGqqGje7TsQxVA5RKN9ScS0BDAc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724361897; c=relaxed/simple; bh=Fg3t36x269QHlBrOe4bqDhBNl9hAksoC9EJEki1/ZWs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cmSJBJHYhz1AhRAig45Lsy2UPFyIERu6b7ovs9BKnSL4L706AUX15neAMbsyvEFUzCKBCnFXD7Rme8rPOziqQAvkRqOMpapzOEF6qoGFCmL/4vJmEy0V1hwqzVDteYKUHIT/fS9tR+6aKECMSMAp0eA/A2iEyfyHTZDOAKsWhnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=F7tx5Bkw; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="F7tx5Bkw" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8826C8D0; Thu, 22 Aug 2024 23:23:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1724361829; bh=Fg3t36x269QHlBrOe4bqDhBNl9hAksoC9EJEki1/ZWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F7tx5Bkw2cqcC6VarMHQZpvBRmrH47dxm9rXHhD4TJB3jXIjZsYxTv8hge1zUxuI4 J4HJqFWVBn+QrakTlLOrgfkG4Vxp7+5sTjPP1psA5YuocGlo19SFGMnJFOuvrHtw5g VxOQFEkKakzwoYe5ZU2kn5SoJLj0fghr740WsGYc= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Kieran Bingham Subject: [PATCH 3/4] media: vsp1: Switch to the new pipeline iterators Date: Fri, 23 Aug 2024 00:24:42 +0300 Message-ID: <20240822212445.2037-4-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240822212445.2037-1-laurent.pinchart+renesas@ideasonboard.com> References: <20240822212445.2037-1-laurent.pinchart+renesas@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace the soon to be deprecated graph walk API with the more efficient iterator over entities in the media pipeline. Signed-off-by: Laurent Pinchart --- .../media/platform/renesas/vsp1/vsp1_video.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c index f0288968bd55..0c6152f73126 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_video.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c @@ -439,21 +439,16 @@ static int vsp1_video_pipeline_build_branch(struct vsp1_pipeline *pipe, static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe, struct vsp1_video *video) { - struct media_graph graph; - struct media_entity *entity = &video->video.entity; - struct media_device *mdev = entity->graph_obj.mdev; + struct media_pipeline_entity_iter iter; + struct media_entity *entity; struct list_head *cursor; unsigned int i; int ret; - /* Walk the graph to locate the entities and video nodes. */ - ret = media_graph_walk_init(&graph, mdev); - if (ret) - return ret; + /* Iterate over the pipeline to locate the entities and video nodes. */ + media_pipeline_entity_iter_init(&pipe->pipe, &iter); - media_graph_walk_start(&graph, entity); - - while ((entity = media_graph_walk_next(&graph))) { + media_pipeline_for_each_entity(&pipe->pipe, &iter, entity) { struct v4l2_subdev *subdev; struct vsp1_rwpf *rwpf; struct vsp1_entity *e; @@ -501,7 +496,7 @@ static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe, } } - media_graph_walk_cleanup(&graph); + media_pipeline_entity_iter_cleanup(&iter); /* We need one output and at least one input. */ if (pipe->num_inputs == 0 || !pipe->output)