mbox series

[0/6] media: imx: imx7-media-csi: Destage driver

Message ID 20220907200424.32136-1-laurent.pinchart@ideasonboard.com
Headers show
Series media: imx: imx7-media-csi: Destage driver | expand

Message

Laurent Pinchart Sept. 7, 2022, 8:04 p.m. UTC
Hello,

This patch series is the last step of the imx7-media-csi driver
destaging journey. Patch 1/6 starts by decoupling the imx7-media-csi and
imx8mq-mipi-csi2 drivers in Kconfig, and patch 2/6 performs the
destaging. Patches 3/6 to 6/6 then handle the low-hanging fruits of the
staging imx cleanup by dropping features that were only used by the
imx7-media-csi driver.

The patches apply on top of [1].

https://lore.kernel.org/linux-media/20220907191547.19255-1-laurent.pinchart@ideasonboard.com

Laurent Pinchart (6):
  media: imx: Decouple imx8mq-mipi-csi2 from imx7-media-csi
  media: imx: Unstage the imx7-media-csi driver
  staging: media: imx: Drop imx_media_subdev_bound()
  staging: media: imx: Drop IMX_MEDIA_GRP_ID_CSI
  staging: media: imx: Drop unused helper functions
  staging: media: imx: Make imx_media_of_add_csi() static

 MAINTAINERS                                   |  2 +-
 drivers/media/platform/nxp/Kconfig            | 13 ++++
 drivers/media/platform/nxp/Makefile           |  1 +
 .../platform/nxp}/imx7-media-csi.c            | 24 +++++++
 drivers/staging/media/imx/Kconfig             | 17 +++--
 drivers/staging/media/imx/Makefile            |  3 +-
 drivers/staging/media/imx/TODO                | 29 --------
 .../staging/media/imx/imx-media-dev-common.c  | 14 ----
 drivers/staging/media/imx/imx-media-of.c      |  5 +-
 drivers/staging/media/imx/imx-media-utils.c   | 68 -------------------
 drivers/staging/media/imx/imx-media.h         | 13 ----
 11 files changed, 52 insertions(+), 137 deletions(-)
 rename drivers/{staging/media/imx => media/platform/nxp}/imx7-media-csi.c (97%)

Comments

Paul Elder Sept. 8, 2022, 3:58 a.m. UTC | #1
On Wed, Sep 07, 2022 at 11:04:19PM +0300, Laurent Pinchart wrote:
> The imx8mq-mipi-csi2 driver targets SoCs that also run the
> imx7-media-csi driver, but they are distinct. Decouple them in Kconfig
> to prepare for destaging of the imx7-media-csi driver.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  drivers/staging/media/imx/Kconfig  | 10 ++++++++++
>  drivers/staging/media/imx/Makefile |  2 +-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/imx/Kconfig b/drivers/staging/media/imx/Kconfig
> index 0bacac302d7e..bfb849701489 100644
> --- a/drivers/staging/media/imx/Kconfig
> +++ b/drivers/staging/media/imx/Kconfig
> @@ -32,3 +32,13 @@ config VIDEO_IMX7_CSI
>  	  i.MX6UL/L, i.MX7 or i.MX8M.
>  endmenu
>  endif
> +
> +config VIDEO_IMX8MQ_MIPI_CSI2
> +	tristate "NXP i.MX8MQ MIPI CSI-2 receiver"
> +	depends on ARCH_MXC || COMPILE_TEST
> +	depends on VIDEO_DEV
> +	select MEDIA_CONTROLLER
> +	select V4L2_FWNODE
> +	select VIDEO_V4L2_SUBDEV_API
> +	help
> +	  V4L2 driver for the MIPI CSI-2 receiver found in the i.MX8MQ SoC.
> diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile
> index d82be898145b..cef9f30eb401 100644
> --- a/drivers/staging/media/imx/Makefile
> +++ b/drivers/staging/media/imx/Makefile
> @@ -15,4 +15,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-media-csi.o
>  obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
>  
>  obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
> -obj-$(CONFIG_VIDEO_IMX7_CSI) += imx8mq-mipi-csi2.o
> +obj-$(CONFIG_VIDEO_IMX8MQ_MIPI_CSI2) += imx8mq-mipi-csi2.o
Paul Elder Sept. 8, 2022, 4:08 a.m. UTC | #2
On Wed, Sep 07, 2022 at 11:04:21PM +0300, Laurent Pinchart wrote:
> The imx_media_subdev_bound() function is a no-op, and the async notifier
> .bound() operation is optional. Drop it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  drivers/staging/media/imx/imx-media-dev-common.c | 13 -------------
>  1 file changed, 13 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c
> index e6d6ed3b1161..8f7ced3a9cca 100644
> --- a/drivers/staging/media/imx/imx-media-dev-common.c
> +++ b/drivers/staging/media/imx/imx-media-dev-common.c
> @@ -19,18 +19,6 @@ static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n)
>  	return container_of(n, struct imx_media_dev, notifier);
>  }
>  
> -/* async subdev bound notifier */
> -static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
> -				  struct v4l2_subdev *sd,
> -				  struct v4l2_async_subdev *asd)
> -{
> -	struct imx_media_dev *imxmd = notifier2dev(notifier);
> -
> -	dev_dbg(imxmd->md.dev, "subdev %s bound\n", sd->name);
> -
> -	return 0;
> -}
> -
>  /*
>   * Create the missing media links from the CSI-2 receiver.
>   * Called after all async subdevs have bound.
> @@ -337,7 +325,6 @@ static void imx_media_notify(struct v4l2_subdev *sd, unsigned int notification,
>  }
>  
>  static const struct v4l2_async_notifier_operations imx_media_notifier_ops = {
> -	.bound = imx_media_subdev_bound,
>  	.complete = imx_media_probe_complete,
>  };
>
Paul Elder Sept. 8, 2022, 4:12 a.m. UTC | #3
On Wed, Sep 07, 2022 at 11:04:23PM +0300, Laurent Pinchart wrote:
> The imx_media_find_subdev_by_fwnode(),
> imx_media_find_subdev_by_devname(), imx_media_pipeline_csi2_channel()
> and imx_media_pipeline_video_device() helper functions are not used.
> Drop them.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  drivers/staging/media/imx/imx-media-utils.c | 68 ---------------------
>  drivers/staging/media/imx/imx-media.h       | 10 ---
>  2 files changed, 78 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
> index 294c808b2ebe..07770b47e19b 100644
> --- a/drivers/staging/media/imx/imx-media-utils.c
> +++ b/drivers/staging/media/imx/imx-media-utils.c
> @@ -626,36 +626,6 @@ void imx_media_grp_id_to_sd_name(char *sd_name, int sz, u32 grp_id, int ipu_id)
>  }
>  EXPORT_SYMBOL_GPL(imx_media_grp_id_to_sd_name);
>  
> -struct v4l2_subdev *
> -imx_media_find_subdev_by_fwnode(struct imx_media_dev *imxmd,
> -				struct fwnode_handle *fwnode)
> -{
> -	struct v4l2_subdev *sd;
> -
> -	list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
> -		if (sd->fwnode == fwnode)
> -			return sd;
> -	}
> -
> -	return NULL;
> -}
> -EXPORT_SYMBOL_GPL(imx_media_find_subdev_by_fwnode);
> -
> -struct v4l2_subdev *
> -imx_media_find_subdev_by_devname(struct imx_media_dev *imxmd,
> -				 const char *devname)
> -{
> -	struct v4l2_subdev *sd;
> -
> -	list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
> -		if (!strcmp(devname, dev_name(sd->dev)))
> -			return sd;
> -	}
> -
> -	return NULL;
> -}
> -EXPORT_SYMBOL_GPL(imx_media_find_subdev_by_devname);
> -
>  /*
>   * Adds a video device to the master video device list. This is called
>   * when a video device is registered.
> @@ -756,25 +726,6 @@ find_pipeline_entity(struct media_entity *start, u32 grp_id,
>  	return pad ? pad->entity : NULL;
>  }
>  
> -/*
> - * Find the upstream mipi-csi2 virtual channel reached from the given
> - * start entity in the current pipeline.
> - * Must be called with mdev->graph_mutex held.
> - */
> -int imx_media_pipeline_csi2_channel(struct media_entity *start_entity)
> -{
> -	struct media_pad *pad;
> -	int ret = -EPIPE;
> -
> -	pad = imx_media_pipeline_pad(start_entity, IMX_MEDIA_GRP_ID_CSI2,
> -				     0, true);
> -	if (pad)
> -		ret = pad->index - 1;
> -
> -	return ret;
> -}
> -EXPORT_SYMBOL_GPL(imx_media_pipeline_csi2_channel);
> -
>  /*
>   * Find a subdev reached upstream from the given start entity in
>   * the current pipeline.
> @@ -794,25 +745,6 @@ imx_media_pipeline_subdev(struct media_entity *start_entity, u32 grp_id,
>  }
>  EXPORT_SYMBOL_GPL(imx_media_pipeline_subdev);
>  
> -/*
> - * Find a subdev reached upstream from the given start entity in
> - * the current pipeline.
> - * Must be called with mdev->graph_mutex held.
> - */
> -struct video_device *
> -imx_media_pipeline_video_device(struct media_entity *start_entity,
> -				enum v4l2_buf_type buftype, bool upstream)
> -{
> -	struct media_entity *me;
> -
> -	me = find_pipeline_entity(start_entity, 0, buftype, upstream);
> -	if (!me)
> -		return ERR_PTR(-ENODEV);
> -
> -	return media_entity_to_video_device(me);
> -}
> -EXPORT_SYMBOL_GPL(imx_media_pipeline_video_device);
> -
>  /*
>   * Find a fwnode endpoint that maps to the given subdevice's pad.
>   * If there are multiple endpoints that map to the pad, only the
> diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h
> index 5e794f291da6..5a1436dbb12d 100644
> --- a/drivers/staging/media/imx/imx-media.h
> +++ b/drivers/staging/media/imx/imx-media.h
> @@ -201,24 +201,14 @@ int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
>  				  const struct imx_media_pixfmt *cc);
>  void imx_media_grp_id_to_sd_name(char *sd_name, int sz,
>  				 u32 grp_id, int ipu_id);
> -struct v4l2_subdev *
> -imx_media_find_subdev_by_fwnode(struct imx_media_dev *imxmd,
> -				struct fwnode_handle *fwnode);
> -struct v4l2_subdev *
> -imx_media_find_subdev_by_devname(struct imx_media_dev *imxmd,
> -				 const char *devname);
>  void imx_media_add_video_device(struct imx_media_dev *imxmd,
>  				struct imx_media_video_dev *vdev);
> -int imx_media_pipeline_csi2_channel(struct media_entity *start_entity);
>  struct media_pad *
>  imx_media_pipeline_pad(struct media_entity *start_entity, u32 grp_id,
>  		       enum v4l2_buf_type buftype, bool upstream);
>  struct v4l2_subdev *
>  imx_media_pipeline_subdev(struct media_entity *start_entity, u32 grp_id,
>  			  bool upstream);
> -struct video_device *
> -imx_media_pipeline_video_device(struct media_entity *start_entity,
> -				enum v4l2_buf_type buftype, bool upstream);
>  struct fwnode_handle *imx_media_get_pad_fwnode(struct media_pad *pad);
>  
>  struct imx_media_dma_buf {
Laurent Pinchart Sept. 9, 2022, 6:22 p.m. UTC | #4
Hi Martin,

It seems I forgot to CC you on this patch, sorry about that. Could you
give it a look ? I'd like to send a pull request for the series next
week.

On Wed, Sep 07, 2022 at 11:04:19PM +0300, Laurent Pinchart wrote:
> The imx8mq-mipi-csi2 driver targets SoCs that also run the
> imx7-media-csi driver, but they are distinct. Decouple them in Kconfig
> to prepare for destaging of the imx7-media-csi driver.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/staging/media/imx/Kconfig  | 10 ++++++++++
>  drivers/staging/media/imx/Makefile |  2 +-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/imx/Kconfig b/drivers/staging/media/imx/Kconfig
> index 0bacac302d7e..bfb849701489 100644
> --- a/drivers/staging/media/imx/Kconfig
> +++ b/drivers/staging/media/imx/Kconfig
> @@ -32,3 +32,13 @@ config VIDEO_IMX7_CSI
>  	  i.MX6UL/L, i.MX7 or i.MX8M.
>  endmenu
>  endif
> +
> +config VIDEO_IMX8MQ_MIPI_CSI2
> +	tristate "NXP i.MX8MQ MIPI CSI-2 receiver"
> +	depends on ARCH_MXC || COMPILE_TEST
> +	depends on VIDEO_DEV
> +	select MEDIA_CONTROLLER
> +	select V4L2_FWNODE
> +	select VIDEO_V4L2_SUBDEV_API
> +	help
> +	  V4L2 driver for the MIPI CSI-2 receiver found in the i.MX8MQ SoC.
> diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile
> index d82be898145b..cef9f30eb401 100644
> --- a/drivers/staging/media/imx/Makefile
> +++ b/drivers/staging/media/imx/Makefile
> @@ -15,4 +15,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-media-csi.o
>  obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
>  
>  obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
> -obj-$(CONFIG_VIDEO_IMX7_CSI) += imx8mq-mipi-csi2.o
> +obj-$(CONFIG_VIDEO_IMX8MQ_MIPI_CSI2) += imx8mq-mipi-csi2.o
Laurent Pinchart Sept. 13, 2022, 3:26 p.m. UTC | #5
Hi Martin,

On Tue, Sep 13, 2022 at 05:10:12PM +0200, Martin Kepplinger wrote:
> Am Freitag, dem 09.09.2022 um 21:22 +0300 schrieb Laurent Pinchart:
> > Hi Martin,
> > 
> > It seems I forgot to CC you on this patch, sorry about that. Could you
> > give it a look ? I'd like to send a pull request for the series next week.
> 
> hi Laurent,
> 
> this change should be ok. thanks for the config-change warning. I'm
> very much looking forward to seeing some of these drivers moved to
> drivers/media.
> 
> Depeding on how that goes I'll follow with the imx8mq-mipi-csi2 driver
> (if you don't want to do it).

I don't have plans to address that driver, so I'll be happy to let you
handle it :-)

> thanks again,
>                           martin
> 
> > On Wed, Sep 07, 2022 at 11:04:19PM +0300, Laurent Pinchart wrote:
> > > The imx8mq-mipi-csi2 driver targets SoCs that also run the
> > > imx7-media-csi driver, but they are distinct. Decouple them in
> > > Kconfig
> > > to prepare for destaging of the imx7-media-csi driver.
> > > 
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > ---
> > >  drivers/staging/media/imx/Kconfig  | 10 ++++++++++
> > >  drivers/staging/media/imx/Makefile |  2 +-
> > >  2 files changed, 11 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/staging/media/imx/Kconfig
> > > b/drivers/staging/media/imx/Kconfig
> > > index 0bacac302d7e..bfb849701489 100644
> > > --- a/drivers/staging/media/imx/Kconfig
> > > +++ b/drivers/staging/media/imx/Kconfig
> > > @@ -32,3 +32,13 @@ config VIDEO_IMX7_CSI
> > >           i.MX6UL/L, i.MX7 or i.MX8M.
> > >  endmenu
> > >  endif
> > > +
> > > +config VIDEO_IMX8MQ_MIPI_CSI2
> > > +       tristate "NXP i.MX8MQ MIPI CSI-2 receiver"
> > > +       depends on ARCH_MXC || COMPILE_TEST
> > > +       depends on VIDEO_DEV
> > > +       select MEDIA_CONTROLLER
> > > +       select V4L2_FWNODE
> > > +       select VIDEO_V4L2_SUBDEV_API
> > > +       help
> > > +         V4L2 driver for the MIPI CSI-2 receiver found in the
> > > i.MX8MQ SoC.
> > > diff --git a/drivers/staging/media/imx/Makefile
> > > b/drivers/staging/media/imx/Makefile
> > > index d82be898145b..cef9f30eb401 100644
> > > --- a/drivers/staging/media/imx/Makefile
> > > +++ b/drivers/staging/media/imx/Makefile
> > > @@ -15,4 +15,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-media-csi.o
> > >  obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
> > >  
> > >  obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o
> > > -obj-$(CONFIG_VIDEO_IMX7_CSI) += imx8mq-mipi-csi2.o
> > > +obj-$(CONFIG_VIDEO_IMX8MQ_MIPI_CSI2) += imx8mq-mipi-csi2.o