All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-media@vger.kernel.org,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	niklas.soderlund+renesas@ragnatech.se,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Pratyush Yadav <p.yadav@ti.com>,
	Kishon Vijay Abraham <kishon@ti.com>,
	satish.nagireddy@getcruise.com, Tomasz Figa <tfiga@chromium.org>
Subject: Re: [PATCH v12 05/30] media: mc: entity: Add media_entity_pipeline() to access the media pipeline
Date: Sat, 30 Jul 2022 11:21:08 +0000	[thread overview]
Message-ID: <YuUUJCzM2HC7Tz++@paasikivi.fi.intel.com> (raw)
In-Reply-To: <20220727103639.581567-6-tomi.valkeinen@ideasonboard.com>

Moi,

On Wed, Jul 27, 2022 at 01:36:14PM +0300, Tomi Valkeinen wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Replace direct access to the pipe field in drivers with a new helper
> function. This will allow easier refactoring of media pipeline handling
> in the MC core behind the scenes without affecting drivers.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  drivers/media/mc/mc-entity.c                   |  6 ++++++
>  .../platform/renesas/rcar-vin/rcar-core.c      |  5 ++---
>  .../media/platform/renesas/rcar-vin/rcar-dma.c |  2 +-
>  drivers/media/platform/ti/omap3isp/isp.c       |  4 +---
>  drivers/media/platform/ti/omap3isp/ispvideo.c  |  3 +--
>  drivers/media/platform/ti/omap3isp/ispvideo.h  | 11 +++++++++--
>  drivers/media/platform/xilinx/xilinx-dma.c     |  3 +--
>  drivers/media/platform/xilinx/xilinx-dma.h     |  7 ++++++-
>  drivers/staging/media/imx/imx-media-utils.c    |  2 +-
>  drivers/staging/media/omap4iss/iss.c           |  4 +---
>  drivers/staging/media/omap4iss/iss_video.c     |  3 +--
>  drivers/staging/media/omap4iss/iss_video.h     | 11 +++++++++--
>  include/media/media-entity.h                   | 18 ++++++++++++++++++
>  13 files changed, 57 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> index 9f4a1c98dc43..50872d953cf9 100644
> --- a/drivers/media/mc/mc-entity.c
> +++ b/drivers/media/mc/mc-entity.c
> @@ -923,6 +923,12 @@ int media_entity_get_fwnode_pad(struct media_entity *entity,
>  }
>  EXPORT_SYMBOL_GPL(media_entity_get_fwnode_pad);
>  
> +struct media_pipeline *media_entity_pipeline(struct media_entity *entity)
> +{
> +	return entity->pipe;

I'd make this an inline function. Or do you plan to add more code later?

> +}
> +EXPORT_SYMBOL_GPL(media_entity_pipeline);
> +
>  static void media_interface_init(struct media_device *mdev,
>  				 struct media_interface *intf,
>  				 u32 gobj_type,
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> index 49bdcfba010b..7b12af3ed8fb 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> @@ -786,9 +786,8 @@ static int rvin_csi2_link_notify(struct media_link *link, u32 flags,
>  		return 0;
>  
>  	/*
> -	 * Don't allow link changes if any entity in the graph is
> -	 * streaming, modifying the CHSEL register fields can disrupt
> -	 * running streams.
> +	 * Don't allow link changes if any stream in the graph is active as
> +	 * modifying the CHSEL register fields can disrupt running streams.
>  	 */
>  	media_device_for_each_entity(entity, &group->mdev)
>  		if (media_entity_is_streaming(entity))
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> index 6644b498929d..924907b71263 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> @@ -1281,7 +1281,7 @@ static int rvin_set_stream(struct rvin_dev *vin, int on)
>  	 */
>  	mdev = vin->vdev.entity.graph_obj.mdev;
>  	mutex_lock(&mdev->graph_mutex);
> -	pipe = sd->entity.pipe ? sd->entity.pipe : &vin->vdev.pipe;
> +	pipe = media_entity_pipeline(&sd->entity) ? : &vin->vdev.pipe;
>  	ret = __media_pipeline_start(&vin->vdev.entity, pipe);
>  	mutex_unlock(&mdev->graph_mutex);
>  	if (ret)
> diff --git a/drivers/media/platform/ti/omap3isp/isp.c b/drivers/media/platform/ti/omap3isp/isp.c
> index 4c937f3f323e..2b5310b07bc3 100644
> --- a/drivers/media/platform/ti/omap3isp/isp.c
> +++ b/drivers/media/platform/ti/omap3isp/isp.c
> @@ -937,10 +937,8 @@ static int isp_pipeline_is_last(struct media_entity *me)
>  	struct isp_pipeline *pipe;
>  	struct media_pad *pad;
>  
> -	if (!me->pipe)
> -		return 0;
>  	pipe = to_isp_pipeline(me);
> -	if (pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED)
> +	if (!pipe || pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED)
>  		return 0;
>  	pad = media_entity_remote_pad(&pipe->output->pad);
>  	return pad->entity == me;
> diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.c
> index 8811d6dd4ee7..44b0d55ee5d8 100644
> --- a/drivers/media/platform/ti/omap3isp/ispvideo.c
> +++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
> @@ -1093,8 +1093,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
>  	/* Start streaming on the pipeline. No link touching an entity in the
>  	 * pipeline can be activated or deactivated once streaming is started.
>  	 */
> -	pipe = video->video.entity.pipe
> -	     ? to_isp_pipeline(&video->video.entity) : &video->pipe;
> +	pipe = to_isp_pipeline(&video->video.entity) ? : &video->pipe;
>  
>  	ret = media_entity_enum_init(&pipe->ent_enum, &video->isp->media_dev);
>  	if (ret)
> diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.h b/drivers/media/platform/ti/omap3isp/ispvideo.h
> index a0908670c0cf..1d23df576e6b 100644
> --- a/drivers/media/platform/ti/omap3isp/ispvideo.h
> +++ b/drivers/media/platform/ti/omap3isp/ispvideo.h
> @@ -99,8 +99,15 @@ struct isp_pipeline {
>  	unsigned int external_width;
>  };
>  
> -#define to_isp_pipeline(__e) \
> -	container_of((__e)->pipe, struct isp_pipeline, pipe)
> +static inline struct isp_pipeline *to_isp_pipeline(struct media_entity *entity)
> +{
> +	struct media_pipeline *pipe = media_entity_pipeline(entity);
> +
> +	if (!pipe)
> +		return NULL;
> +
> +	return container_of(pipe, struct isp_pipeline, pipe);
> +}
>  
>  static inline int isp_pipeline_ready(struct isp_pipeline *pipe)
>  {
> diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
> index 338c3661d809..72eff5ef626b 100644
> --- a/drivers/media/platform/xilinx/xilinx-dma.c
> +++ b/drivers/media/platform/xilinx/xilinx-dma.c
> @@ -402,8 +402,7 @@ static int xvip_dma_start_streaming(struct vb2_queue *vq, unsigned int count)
>  	 * Use the pipeline object embedded in the first DMA object that starts
>  	 * streaming.
>  	 */
> -	pipe = dma->video.entity.pipe
> -	     ? to_xvip_pipeline(&dma->video.entity) : &dma->pipe;
> +	pipe = to_xvip_pipeline(&dma->video.entity) ? : &dma->pipe;
>  
>  	ret = media_pipeline_start(&dma->video.entity, &pipe->pipe);
>  	if (ret < 0)
> diff --git a/drivers/media/platform/xilinx/xilinx-dma.h b/drivers/media/platform/xilinx/xilinx-dma.h
> index 2378bdae57ae..3ea10f6b0bb9 100644
> --- a/drivers/media/platform/xilinx/xilinx-dma.h
> +++ b/drivers/media/platform/xilinx/xilinx-dma.h
> @@ -47,7 +47,12 @@ struct xvip_pipeline {
>  
>  static inline struct xvip_pipeline *to_xvip_pipeline(struct media_entity *e)
>  {
> -	return container_of(e->pipe, struct xvip_pipeline, pipe);
> +	struct media_pipeline *pipe = media_entity_pipeline(e);
> +
> +	if (!pipe)
> +		return NULL;
> +
> +	return container_of(pipe, struct xvip_pipeline, pipe);
>  }
>  
>  /**
> diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
> index 94bc866ca28c..5d9c6fc6f2e0 100644
> --- a/drivers/staging/media/imx/imx-media-utils.c
> +++ b/drivers/staging/media/imx/imx-media-utils.c
> @@ -871,7 +871,7 @@ int imx_media_pipeline_set_stream(struct imx_media_dev *imxmd,
>  			__media_pipeline_stop(entity);
>  	} else {
>  		v4l2_subdev_call(sd, video, s_stream, 0);
> -		if (entity->pipe)
> +		if (media_entity_pipeline(entity))
>  			__media_pipeline_stop(entity);
>  	}
>  
> diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
> index 68588e9dab0b..77760d913b49 100644
> --- a/drivers/staging/media/omap4iss/iss.c
> +++ b/drivers/staging/media/omap4iss/iss.c
> @@ -548,10 +548,8 @@ static int iss_pipeline_is_last(struct media_entity *me)
>  	struct iss_pipeline *pipe;
>  	struct media_pad *pad;
>  
> -	if (!me->pipe)
> -		return 0;
>  	pipe = to_iss_pipeline(me);
> -	if (pipe->stream_state == ISS_PIPELINE_STREAM_STOPPED)
> +	if (!pipe || pipe->stream_state == ISS_PIPELINE_STREAM_STOPPED)
>  		return 0;
>  	pad = media_entity_remote_pad(&pipe->output->pad);
>  	return pad->entity == me;
> diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
> index d0da083deed5..67d63a400fa2 100644
> --- a/drivers/staging/media/omap4iss/iss_video.c
> +++ b/drivers/staging/media/omap4iss/iss_video.c
> @@ -870,8 +870,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
>  	 * Start streaming on the pipeline. No link touching an entity in the
>  	 * pipeline can be activated or deactivated once streaming is started.
>  	 */
> -	pipe = entity->pipe
> -	     ? to_iss_pipeline(entity) : &video->pipe;
> +	pipe = to_iss_pipeline(&video->video.entity) ? : &video->pipe;

s/&video->video\.//

>  	pipe->external = NULL;
>  	pipe->external_rate = 0;
>  	pipe->external_bpp = 0;
> diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h
> index 526281bf0051..ca2d5edb6261 100644
> --- a/drivers/staging/media/omap4iss/iss_video.h
> +++ b/drivers/staging/media/omap4iss/iss_video.h
> @@ -90,8 +90,15 @@ struct iss_pipeline {
>  	int external_bpp;
>  };
>  
> -#define to_iss_pipeline(__e) \
> -	container_of((__e)->pipe, struct iss_pipeline, pipe)
> +static inline struct iss_pipeline *to_iss_pipeline(struct media_entity *entity)
> +{
> +	struct media_pipeline *pipe = media_entity_pipeline(entity);
> +
> +	if (!pipe)
> +		return NULL;
> +
> +	return container_of(pipe, struct iss_pipeline, pipe);
> +}
>  
>  static inline int iss_pipeline_ready(struct iss_pipeline *pipe)
>  {
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index 4e4fec60bf97..96f5fcda1985 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -883,6 +883,24 @@ static inline bool media_entity_is_streaming(const struct media_entity *entity)
>  	return entity->pipe;
>  }
>  
> +/**
> + * media_entity_pipeline - Get the media pipeline an entity is part of
> + * @entity: The entity
> + *
> + * This function returns the media pipeline that an entity has been associated
> + * with when constructing the pipeline with media_pipeline_start(). The pointer
> + * remains valid until media_pipeline_stop() is called.
> + *
> + * In general, entities can be part of multiple pipelines, when carrying
> + * multiple streams (either on different pads, or on the same pad using
> + * multiplexed streams). This function is ill-defined in that case. It
> + * currently returns the pipeline associated with the first pad of the entity.
> + *
> + * Return: The media_pipeline the entity is part of, or NULL if the entity is
> + * not part of any pipeline.
> + */
> +struct media_pipeline *media_entity_pipeline(struct media_entity *entity);
> +
>  /**
>   * media_entity_get_fwnode_pad - Get pad number from fwnode
>   *

-- 
Terveisin,

Sakari Ailus

  reply	other threads:[~2022-07-30 11:21 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 10:36 [PATCH v12 00/30] v4l: routing and streams support Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 01/30] media: Documentation: mc: add definitions for stream and pipeline Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 02/30] media: mc: entity: Add iterator helper for entity pads Tomi Valkeinen
2022-07-30 11:11   ` Sakari Ailus
2022-08-01  5:58     ` Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 03/30] media: mc: entity: Merge media_entity_enum_init and __media_entity_enum_init Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 04/30] media: mc: entity: Move media_entity_get_fwnode_pad() out of graph walk section Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 05/30] media: mc: entity: Add media_entity_pipeline() to access the media pipeline Tomi Valkeinen
2022-07-30 11:21   ` Sakari Ailus [this message]
2022-08-01  6:01     ` Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 06/30] media: mc: entity: Add has_route entity operation and media_entity_has_route() helper Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 07/30] media: mc: entity: Rename streaming_count -> start_count Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 08/30] media: mc: entity: add media_pipeline_alloc_start & media_pipeline_stop_free Tomi Valkeinen
2022-07-29  8:30   ` [EXT] " Satish Nagireddy
2022-07-29  8:40     ` Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 09/30] media: mc: entity: Rewrite media_pipeline_start() to support routes Tomi Valkeinen
2022-07-29  8:45   ` [EXT] " Satish Nagireddy
2022-07-29  8:53     ` Tomi Valkeinen
2022-07-29  9:19       ` [EXT] " Satish Nagireddy
2022-07-29 10:27         ` Tomi Valkeinen
2022-07-29 17:00           ` [EXT] " Satish Nagireddy
2022-07-29 17:07             ` Tomi Valkeinen
2022-07-29 18:20               ` [EXT] " Satish Nagireddy
2022-07-30 11:56               ` Sakari Ailus
2022-08-01  9:33                 ` Tomi Valkeinen
2022-08-01 11:06                   ` Sakari Ailus
2022-07-27 10:36 ` [PATCH v12 10/30] media: add V4L2_SUBDEV_FL_STREAMS Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 11/30] media: add V4L2_SUBDEV_CAP_MPLEXED Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 12/30] media: Documentation: Add GS_ROUTING documentation Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 13/30] media: subdev: Add [GS]_ROUTING subdev ioctls and operations Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 14/30] media: subdev: add v4l2_subdev_has_route() Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 15/30] media: subdev: add v4l2_subdev_set_routing helper() Tomi Valkeinen
2022-08-01  6:59   ` Sakari Ailus
2022-08-01  7:38     ` Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 16/30] media: Documentation: add multiplexed streams documentation Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 17/30] media: subdev: add stream based configuration Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 18/30] media: subdev: use streams in v4l2_subdev_link_validate() Tomi Valkeinen
2022-07-29  9:12   ` [EXT] " Satish Nagireddy
2022-07-29 11:00     ` Tomi Valkeinen
2022-07-29 17:33       ` [EXT] " Satish Nagireddy
2022-07-27 10:36 ` [PATCH v12 19/30] media: subdev: add "opposite" stream helper funcs Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 20/30] media: subdev: add streams to v4l2_subdev_get_fmt() helper function Tomi Valkeinen
2022-07-29  9:16   ` [EXT] " Satish Nagireddy
2022-07-29 10:30     ` Tomi Valkeinen
2022-07-29 17:01       ` [EXT] " Satish Nagireddy
2022-07-27 10:36 ` [PATCH v12 21/30] media: subdev: add v4l2_subdev_set_routing_with_fmt() helper Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 22/30] media: subdev: add v4l2_subdev_routing_validate() helper Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 23/30] media: subdev: Add for_each_active_route() macro Tomi Valkeinen
2022-08-01  8:40   ` Tomi Valkeinen
2022-08-01 11:09     ` Sakari Ailus
2022-07-27 10:36 ` [PATCH v12 24/30] media: subdev: use for_each_active_route() in v4l2_subdev_init_stream_configs() Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 25/30] media: subdev: use for_each_active_route() in v4l2_link_validate_get_streams() Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 26/30] media: v4l2-subdev: Add v4l2_subdev_state_xlate_streams() helper Tomi Valkeinen
2022-08-01 12:37   ` Sakari Ailus
2022-08-01 14:25     ` Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 27/30] media: v4l2-subdev: Add subdev .(enable|disable)_streams() operations Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 28/30] media: v4l2-subdev: Add v4l2_subdev_s_stream_helper() function Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 29/30] media: Add stream to frame descriptor Tomi Valkeinen
2022-07-27 10:36 ` [PATCH v12 30/30] media: subdev: increase V4L2_FRAME_DESC_ENTRY_MAX to 8 Tomi Valkeinen
2022-07-27 10:42 ` [PATCH v12 00/30] v4l: routing and streams support Tomi Valkeinen
2022-07-31 20:47 ` Sakari Ailus
2022-08-01  6:28   ` Tomi Valkeinen
     [not found] ` <MW4PR02MB737849AF15E8004B2CB39C3BB09C9@MW4PR02MB7378.namprd02.prod.outlook.com>
2022-08-03 11:37   ` Tomi Valkeinen
     [not found]     ` <MW4PR02MB73781CDA5C792C28390BAF29B09E9@MW4PR02MB7378.namprd02.prod.outlook.com>
2022-08-08  6:45       ` Tomi Valkeinen
2022-08-19  2:31         ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YuUUJCzM2HC7Tz++@paasikivi.fi.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kishon@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=p.yadav@ti.com \
    --cc=satish.nagireddy@getcruise.com \
    --cc=tfiga@chromium.org \
    --cc=tomi.valkeinen@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.