Re: [PATCH v8 32/55] [media] media: use macros to check for V4L2 subdev entities

2015-10-11 Thread Sakari Ailus
Hi Mauro,

On Sun, Aug 30, 2015 at 12:06:43AM -0300, Mauro Carvalho Chehab wrote:
> Instead of relying on media subtype, use the new macros to detect
> if an entity is a subdev or an A/V DMA entity.
> 
> Please note that most drivers assume that there's just AV_DMA or
> V4L2 subdevs. This is not true anymore, as we've added MC support
> for DVB, and there are plans to add support for ALSA and FB/DRM
> too.
> 
> Ok, on the current pipelines supported by those drivers, just V4L
> stuff are there, but, assuming that some day a pipeline that also
> works with other subsystems will ever added, it is better to add
> explicit checks for the AV_DMA stuff.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> 
> diff --git a/drivers/media/platform/exynos4-is/common.c 
> b/drivers/media/platform/exynos4-is/common.c
> index 0eb34ecb8ee4..8c9a29e0e294 100644
> --- a/drivers/media/platform/exynos4-is/common.c
> +++ b/drivers/media/platform/exynos4-is/common.c
> @@ -22,8 +22,7 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct 
> media_entity *entity)
>   while (pad->flags & MEDIA_PAD_FL_SINK) {
>   /* source pad */
>   pad = media_entity_remote_pad(pad);
> - if (pad == NULL ||
> - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
>   break;
>  
>   sd = media_entity_to_v4l2_subdev(pad->entity);
> diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
> b/drivers/media/platform/exynos4-is/fimc-capture.c
> index 0627a93b2f3b..e9810fee4c30 100644
> --- a/drivers/media/platform/exynos4-is/fimc-capture.c
> +++ b/drivers/media/platform/exynos4-is/fimc-capture.c
> @@ -1141,8 +1141,7 @@ static int fimc_pipeline_validate(struct fimc_dev *fimc)
>   }
>   }
>  
> - if (src_pad == NULL ||
> - media_entity_type(src_pad->entity) != 
> MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!src_pad || !is_media_entity_v4l2_subdev(src_pad->entity))
>   break;
>  
>   /* Don't call FIMC subdev operation to avoid nested locking */
> @@ -1397,7 +1396,7 @@ static int fimc_link_setup(struct media_entity *entity,
>   struct fimc_vid_cap *vc = &fimc->vid_cap;
>   struct v4l2_subdev *sensor;
>  
> - if (media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!is_media_entity_v4l2_subdev(remote->entity))
>   return -EINVAL;
>  
>   if (WARN_ON(fimc == NULL))
> diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c 
> b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> index 3d9ccbf5f10f..5fbaf5e39903 100644
> --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
> +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> @@ -467,8 +467,7 @@ static int isp_video_pipeline_validate(struct fimc_isp 
> *isp)
>  
>   /* Retrieve format at the source pad */
>   pad = media_entity_remote_pad(pad);
> - if (pad == NULL ||
> - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
>   break;
>  
>   sd = media_entity_to_v4l2_subdev(pad->entity);
> diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
> b/drivers/media/platform/exynos4-is/fimc-lite.c
> index b2607da4ad14..c2327147b360 100644
> --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> @@ -814,8 +814,7 @@ static int fimc_pipeline_validate(struct fimc_lite *fimc)
>   }
>   /* Retrieve format at the source pad */
>   pad = media_entity_remote_pad(pad);
> - if (pad == NULL ||
> - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
>   break;
>  
>   sd = media_entity_to_v4l2_subdev(pad->entity);
> @@ -988,7 +987,6 @@ static int fimc_lite_link_setup(struct media_entity 
> *entity,
>  {
>   struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
>   struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
> - unsigned int remote_ent_type = media_entity_type(remote->entity);
>   int ret = 0;
>  
>   if (WARN_ON(fimc == NULL))
> @@ -1000,7 +998,7 @@ static int fimc_lite_link_setup(struct media_entity 
> *entity,
>  
>   switch (local->index) {
>   case FLITE_SD_PAD_SINK:
> - if (remote_ent_type != MEDIA_ENT_T_V4L2_SUBDEV) {
> + if (!is_media_entity_v4l2_subdev(remote->entity)) {
>   ret = -EINVAL;
>   break;
>   }
> @@ -1018,7 +1016,7 @@ static int fimc_lite_link_setup(struct media_entity 
> *entity,
>   case FLITE_SD_PAD_SOURCE_DMA:
>   if (!(flags & MEDIA_LNK_FL_ENABLED))
>

Re: [PATCH v8 32/55] [media] media: use macros to check for V4L2 subdev entities

2015-10-11 Thread Mauro Carvalho Chehab
Em Mon, 12 Oct 2015 00:07:52 +0300
Sakari Ailus  escreveu:

> Hi Mauro,
> 
> On Sun, Aug 30, 2015 at 12:06:43AM -0300, Mauro Carvalho Chehab wrote:
> > Instead of relying on media subtype, use the new macros to detect
> > if an entity is a subdev or an A/V DMA entity.
> > 
> > Please note that most drivers assume that there's just AV_DMA or
> > V4L2 subdevs. This is not true anymore, as we've added MC support
> > for DVB, and there are plans to add support for ALSA and FB/DRM
> > too.
> > 
> > Ok, on the current pipelines supported by those drivers, just V4L
> > stuff are there, but, assuming that some day a pipeline that also
> > works with other subsystems will ever added, it is better to add
> > explicit checks for the AV_DMA stuff.
> > 
> > Signed-off-by: Mauro Carvalho Chehab 
> > 
> > diff --git a/drivers/media/platform/exynos4-is/common.c 
> > b/drivers/media/platform/exynos4-is/common.c
> > index 0eb34ecb8ee4..8c9a29e0e294 100644
> > --- a/drivers/media/platform/exynos4-is/common.c
> > +++ b/drivers/media/platform/exynos4-is/common.c
> > @@ -22,8 +22,7 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct 
> > media_entity *entity)
> > while (pad->flags & MEDIA_PAD_FL_SINK) {
> > /* source pad */
> > pad = media_entity_remote_pad(pad);
> > -   if (pad == NULL ||
> > -   media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > break;
> >  
> > sd = media_entity_to_v4l2_subdev(pad->entity);
> > diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
> > b/drivers/media/platform/exynos4-is/fimc-capture.c
> > index 0627a93b2f3b..e9810fee4c30 100644
> > --- a/drivers/media/platform/exynos4-is/fimc-capture.c
> > +++ b/drivers/media/platform/exynos4-is/fimc-capture.c
> > @@ -1141,8 +1141,7 @@ static int fimc_pipeline_validate(struct fimc_dev 
> > *fimc)
> > }
> > }
> >  
> > -   if (src_pad == NULL ||
> > -   media_entity_type(src_pad->entity) != 
> > MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!src_pad || !is_media_entity_v4l2_subdev(src_pad->entity))
> > break;
> >  
> > /* Don't call FIMC subdev operation to avoid nested locking */
> > @@ -1397,7 +1396,7 @@ static int fimc_link_setup(struct media_entity 
> > *entity,
> > struct fimc_vid_cap *vc = &fimc->vid_cap;
> > struct v4l2_subdev *sensor;
> >  
> > -   if (media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!is_media_entity_v4l2_subdev(remote->entity))
> > return -EINVAL;
> >  
> > if (WARN_ON(fimc == NULL))
> > diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c 
> > b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > index 3d9ccbf5f10f..5fbaf5e39903 100644
> > --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > @@ -467,8 +467,7 @@ static int isp_video_pipeline_validate(struct fimc_isp 
> > *isp)
> >  
> > /* Retrieve format at the source pad */
> > pad = media_entity_remote_pad(pad);
> > -   if (pad == NULL ||
> > -   media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > break;
> >  
> > sd = media_entity_to_v4l2_subdev(pad->entity);
> > diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
> > b/drivers/media/platform/exynos4-is/fimc-lite.c
> > index b2607da4ad14..c2327147b360 100644
> > --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> > +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> > @@ -814,8 +814,7 @@ static int fimc_pipeline_validate(struct fimc_lite 
> > *fimc)
> > }
> > /* Retrieve format at the source pad */
> > pad = media_entity_remote_pad(pad);
> > -   if (pad == NULL ||
> > -   media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > break;
> >  
> > sd = media_entity_to_v4l2_subdev(pad->entity);
> > @@ -988,7 +987,6 @@ static int fimc_lite_link_setup(struct media_entity 
> > *entity,
> >  {
> > struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
> > struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
> > -   unsigned int remote_ent_type = media_entity_type(remote->entity);
> > int ret = 0;
> >  
> > if (WARN_ON(fimc == NULL))
> > @@ -1000,7 +998,7 @@ static int fimc_lite_link_setup(struct media_entity 
> > *entity,
> >  
> > switch (local->index) {
> > case FLITE_SD_PAD_SINK:
> > -   if (remote_ent_type != MEDIA_ENT_T_V4L2_SUBDEV) {
> > +   if (!is_media_entity_v4l2_subdev(remote->entity)) {
> > ret = -EINVAL;
> > break;
> > }

Re: [PATCH v8 32/55] [media] media: use macros to check for V4L2 subdev entities

2015-10-12 Thread Sakari Ailus
Hi Mauro,

On Sun, Oct 11, 2015 at 09:56:25PM -0300, Mauro Carvalho Chehab wrote:
> Em Mon, 12 Oct 2015 00:07:52 +0300
> Sakari Ailus  escreveu:
> 
> > Hi Mauro,
> > 
> > On Sun, Aug 30, 2015 at 12:06:43AM -0300, Mauro Carvalho Chehab wrote:
> > > Instead of relying on media subtype, use the new macros to detect
> > > if an entity is a subdev or an A/V DMA entity.
> > > 
> > > Please note that most drivers assume that there's just AV_DMA or
> > > V4L2 subdevs. This is not true anymore, as we've added MC support
> > > for DVB, and there are plans to add support for ALSA and FB/DRM
> > > too.
> > > 
> > > Ok, on the current pipelines supported by those drivers, just V4L
> > > stuff are there, but, assuming that some day a pipeline that also
> > > works with other subsystems will ever added, it is better to add
> > > explicit checks for the AV_DMA stuff.
> > > 
> > > Signed-off-by: Mauro Carvalho Chehab 
> > > 
> > > diff --git a/drivers/media/platform/exynos4-is/common.c 
> > > b/drivers/media/platform/exynos4-is/common.c
> > > index 0eb34ecb8ee4..8c9a29e0e294 100644
> > > --- a/drivers/media/platform/exynos4-is/common.c
> > > +++ b/drivers/media/platform/exynos4-is/common.c
> > > @@ -22,8 +22,7 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct 
> > > media_entity *entity)
> > >   while (pad->flags & MEDIA_PAD_FL_SINK) {
> > >   /* source pad */
> > >   pad = media_entity_remote_pad(pad);
> > > - if (pad == NULL ||
> > > - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > > + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > >   break;
> > >  
> > >   sd = media_entity_to_v4l2_subdev(pad->entity);
> > > diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
> > > b/drivers/media/platform/exynos4-is/fimc-capture.c
> > > index 0627a93b2f3b..e9810fee4c30 100644
> > > --- a/drivers/media/platform/exynos4-is/fimc-capture.c
> > > +++ b/drivers/media/platform/exynos4-is/fimc-capture.c
> > > @@ -1141,8 +1141,7 @@ static int fimc_pipeline_validate(struct fimc_dev 
> > > *fimc)
> > >   }
> > >   }
> > >  
> > > - if (src_pad == NULL ||
> > > - media_entity_type(src_pad->entity) != 
> > > MEDIA_ENT_T_V4L2_SUBDEV)
> > > + if (!src_pad || !is_media_entity_v4l2_subdev(src_pad->entity))
> > >   break;
> > >  
> > >   /* Don't call FIMC subdev operation to avoid nested locking */
> > > @@ -1397,7 +1396,7 @@ static int fimc_link_setup(struct media_entity 
> > > *entity,
> > >   struct fimc_vid_cap *vc = &fimc->vid_cap;
> > >   struct v4l2_subdev *sensor;
> > >  
> > > - if (media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > > + if (!is_media_entity_v4l2_subdev(remote->entity))
> > >   return -EINVAL;
> > >  
> > >   if (WARN_ON(fimc == NULL))
> > > diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c 
> > > b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > > index 3d9ccbf5f10f..5fbaf5e39903 100644
> > > --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > > +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > > @@ -467,8 +467,7 @@ static int isp_video_pipeline_validate(struct 
> > > fimc_isp *isp)
> > >  
> > >   /* Retrieve format at the source pad */
> > >   pad = media_entity_remote_pad(pad);
> > > - if (pad == NULL ||
> > > - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > > + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > >   break;
> > >  
> > >   sd = media_entity_to_v4l2_subdev(pad->entity);
> > > diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
> > > b/drivers/media/platform/exynos4-is/fimc-lite.c
> > > index b2607da4ad14..c2327147b360 100644
> > > --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> > > +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> > > @@ -814,8 +814,7 @@ static int fimc_pipeline_validate(struct fimc_lite 
> > > *fimc)
> > >   }
> > >   /* Retrieve format at the source pad */
> > >   pad = media_entity_remote_pad(pad);
> > > - if (pad == NULL ||
> > > - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > > + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > >   break;
> > >  
> > >   sd = media_entity_to_v4l2_subdev(pad->entity);
> > > @@ -988,7 +987,6 @@ static int fimc_lite_link_setup(struct media_entity 
> > > *entity,
> > >  {
> > >   struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
> > >   struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
> > > - unsigned int remote_ent_type = media_entity_type(remote->entity);
> > >   int ret = 0;
> > >  
> > >   if (WARN_ON(fimc == NULL))
> > > @@ -1000,7 +998,7 @@ static int fimc_lite_link_setup(struct media_entity 
> > > *entity,
> > >  
> > >   switch (local->index) {
> > >   case FLITE_SD_PAD_SINK:
> > >

Re: [PATCH v8 32/55] [media] media: use macros to check for V4L2 subdev entities

2015-10-12 Thread Mauro Carvalho Chehab
Em Mon, 12 Oct 2015 18:35:05 +0300
Sakari Ailus  escreveu:

> Hi Mauro,
> 
> On Sun, Oct 11, 2015 at 09:56:25PM -0300, Mauro Carvalho Chehab wrote:
> > Em Mon, 12 Oct 2015 00:07:52 +0300
> > Sakari Ailus  escreveu:
> > 
> > > Hi Mauro,
> > > 
> > > On Sun, Aug 30, 2015 at 12:06:43AM -0300, Mauro Carvalho Chehab wrote:
> > > > Instead of relying on media subtype, use the new macros to detect
> > > > if an entity is a subdev or an A/V DMA entity.
> > > > 
> > > > Please note that most drivers assume that there's just AV_DMA or
> > > > V4L2 subdevs. This is not true anymore, as we've added MC support
> > > > for DVB, and there are plans to add support for ALSA and FB/DRM
> > > > too.
> > > > 
> > > > Ok, on the current pipelines supported by those drivers, just V4L
> > > > stuff are there, but, assuming that some day a pipeline that also
> > > > works with other subsystems will ever added, it is better to add
> > > > explicit checks for the AV_DMA stuff.
> > > > 
> > > > Signed-off-by: Mauro Carvalho Chehab 
> > > > 
> > > > diff --git a/drivers/media/platform/exynos4-is/common.c 
> > > > b/drivers/media/platform/exynos4-is/common.c
> > > > index 0eb34ecb8ee4..8c9a29e0e294 100644
> > > > --- a/drivers/media/platform/exynos4-is/common.c
> > > > +++ b/drivers/media/platform/exynos4-is/common.c
> > > > @@ -22,8 +22,7 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct 
> > > > media_entity *entity)
> > > > while (pad->flags & MEDIA_PAD_FL_SINK) {
> > > > /* source pad */
> > > > pad = media_entity_remote_pad(pad);
> > > > -   if (pad == NULL ||
> > > > -   media_entity_type(pad->entity) != 
> > > > MEDIA_ENT_T_V4L2_SUBDEV)
> > > > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > > > break;
> > > >  
> > > > sd = media_entity_to_v4l2_subdev(pad->entity);
> > > > diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
> > > > b/drivers/media/platform/exynos4-is/fimc-capture.c
> > > > index 0627a93b2f3b..e9810fee4c30 100644
> > > > --- a/drivers/media/platform/exynos4-is/fimc-capture.c
> > > > +++ b/drivers/media/platform/exynos4-is/fimc-capture.c
> > > > @@ -1141,8 +1141,7 @@ static int fimc_pipeline_validate(struct fimc_dev 
> > > > *fimc)
> > > > }
> > > > }
> > > >  
> > > > -   if (src_pad == NULL ||
> > > > -   media_entity_type(src_pad->entity) != 
> > > > MEDIA_ENT_T_V4L2_SUBDEV)
> > > > +   if (!src_pad || 
> > > > !is_media_entity_v4l2_subdev(src_pad->entity))
> > > > break;
> > > >  
> > > > /* Don't call FIMC subdev operation to avoid nested 
> > > > locking */
> > > > @@ -1397,7 +1396,7 @@ static int fimc_link_setup(struct media_entity 
> > > > *entity,
> > > > struct fimc_vid_cap *vc = &fimc->vid_cap;
> > > > struct v4l2_subdev *sensor;
> > > >  
> > > > -   if (media_entity_type(remote->entity) != 
> > > > MEDIA_ENT_T_V4L2_SUBDEV)
> > > > +   if (!is_media_entity_v4l2_subdev(remote->entity))
> > > > return -EINVAL;
> > > >  
> > > > if (WARN_ON(fimc == NULL))
> > > > diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c 
> > > > b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > > > index 3d9ccbf5f10f..5fbaf5e39903 100644
> > > > --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > > > +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > > > @@ -467,8 +467,7 @@ static int isp_video_pipeline_validate(struct 
> > > > fimc_isp *isp)
> > > >  
> > > > /* Retrieve format at the source pad */
> > > > pad = media_entity_remote_pad(pad);
> > > > -   if (pad == NULL ||
> > > > -   media_entity_type(pad->entity) != 
> > > > MEDIA_ENT_T_V4L2_SUBDEV)
> > > > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > > > break;
> > > >  
> > > > sd = media_entity_to_v4l2_subdev(pad->entity);
> > > > diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
> > > > b/drivers/media/platform/exynos4-is/fimc-lite.c
> > > > index b2607da4ad14..c2327147b360 100644
> > > > --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> > > > +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> > > > @@ -814,8 +814,7 @@ static int fimc_pipeline_validate(struct fimc_lite 
> > > > *fimc)
> > > > }
> > > > /* Retrieve format at the source pad */
> > > > pad = media_entity_remote_pad(pad);
> > > > -   if (pad == NULL ||
> > > > -   media_entity_type(pad->entity) != 
> > > > MEDIA_ENT_T_V4L2_SUBDEV)
> > > > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > > > break;
> > > >  
> > > > sd = media_entity_to_v4l2_subdev(pad->entity);
> > > > @@ -9

Re: [PATCH v8 32/55] [media] media: use macros to check for V4L2 subdev entities

2015-12-05 Thread Laurent Pinchart
Hi Mauro,

Thank you for the patch.

On Sunday 30 August 2015 00:06:43 Mauro Carvalho Chehab wrote:
> Instead of relying on media subtype, use the new macros to detect
> if an entity is a subdev or an A/V DMA entity.
> 
> Please note that most drivers assume that there's just AV_DMA or
> V4L2 subdevs. This is not true anymore, as we've added MC support
> for DVB, and there are plans to add support for ALSA and FB/DRM
> too.
> 
> Ok, on the current pipelines supported by those drivers, just V4L
> stuff are there, but, assuming that some day a pipeline that also
> works with other subsystems will ever added, it is better to add
> explicit checks for the AV_DMA stuff.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> 
> diff --git a/drivers/media/platform/exynos4-is/common.c
> b/drivers/media/platform/exynos4-is/common.c index
> 0eb34ecb8ee4..8c9a29e0e294 100644
> --- a/drivers/media/platform/exynos4-is/common.c
> +++ b/drivers/media/platform/exynos4-is/common.c
> @@ -22,8 +22,7 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct
> media_entity *entity) while (pad->flags & MEDIA_PAD_FL_SINK) {
>   /* source pad */
>   pad = media_entity_remote_pad(pad);
> - if (pad == NULL ||
> - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
>   break;
> 
>   sd = media_entity_to_v4l2_subdev(pad->entity);
> diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c
> b/drivers/media/platform/exynos4-is/fimc-capture.c index
> 0627a93b2f3b..e9810fee4c30 100644
> --- a/drivers/media/platform/exynos4-is/fimc-capture.c
> +++ b/drivers/media/platform/exynos4-is/fimc-capture.c
> @@ -1141,8 +1141,7 @@ static int fimc_pipeline_validate(struct fimc_dev
> *fimc) }
>   }
> 
> - if (src_pad == NULL ||
> - media_entity_type(src_pad->entity) != 
> MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!src_pad || !is_media_entity_v4l2_subdev(src_pad->entity))
>   break;
> 
>   /* Don't call FIMC subdev operation to avoid nested locking */
> @@ -1397,7 +1396,7 @@ static int fimc_link_setup(struct media_entity
> *entity, struct fimc_vid_cap *vc = &fimc->vid_cap;
>   struct v4l2_subdev *sensor;
> 
> - if (media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!is_media_entity_v4l2_subdev(remote->entity))
>   return -EINVAL;
> 
>   if (WARN_ON(fimc == NULL))
> diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c
> b/drivers/media/platform/exynos4-is/fimc-isp-video.c index
> 3d9ccbf5f10f..5fbaf5e39903 100644
> --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
> +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> @@ -467,8 +467,7 @@ static int isp_video_pipeline_validate(struct fimc_isp
> *isp)
> 
>   /* Retrieve format at the source pad */
>   pad = media_entity_remote_pad(pad);
> - if (pad == NULL ||
> - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
>   break;
> 
>   sd = media_entity_to_v4l2_subdev(pad->entity);
> diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c
> b/drivers/media/platform/exynos4-is/fimc-lite.c index
> b2607da4ad14..c2327147b360 100644
> --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> @@ -814,8 +814,7 @@ static int fimc_pipeline_validate(struct fimc_lite
> *fimc) }
>   /* Retrieve format at the source pad */
>   pad = media_entity_remote_pad(pad);
> - if (pad == NULL ||
> - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> + if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
>   break;
> 
>   sd = media_entity_to_v4l2_subdev(pad->entity);
> @@ -988,7 +987,6 @@ static int fimc_lite_link_setup(struct media_entity
> *entity, {
>   struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
>   struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
> - unsigned int remote_ent_type = media_entity_type(remote->entity);
>   int ret = 0;
> 
>   if (WARN_ON(fimc == NULL))
> @@ -1000,7 +998,7 @@ static int fimc_lite_link_setup(struct media_entity
> *entity,
> 
>   switch (local->index) {
>   case FLITE_SD_PAD_SINK:
> - if (remote_ent_type != MEDIA_ENT_T_V4L2_SUBDEV) {
> + if (!is_media_entity_v4l2_subdev(remote->entity)) {
>   ret = -EINVAL;
>   break;
>   }
> @@ -1018,7 +1016,7 @@ static int fimc_lite_link_setup(struct media_entity
> *entity, case FLITE_SD_PAD_SOURCE_DMA:
>   if (!(flags & MEDIA_LNK_FL_ENABLED))
>   atomic_set(&fimc->out_path, FIMC_IO_NONE);
> - 

Re: [PATCH v8 32/55] [media] media: use macros to check for V4L2 subdev entities

2015-12-08 Thread Mauro Carvalho Chehab
Em Sun, 06 Dec 2015 04:16:15 +0200
Laurent Pinchart  escreveu:

> Hi Mauro,
> 
> Thank you for the patch.
> 
> On Sunday 30 August 2015 00:06:43 Mauro Carvalho Chehab wrote:
> > Instead of relying on media subtype, use the new macros to detect
> > if an entity is a subdev or an A/V DMA entity.
> > 
> > Please note that most drivers assume that there's just AV_DMA or
> > V4L2 subdevs. This is not true anymore, as we've added MC support
> > for DVB, and there are plans to add support for ALSA and FB/DRM
> > too.
> > 
> > Ok, on the current pipelines supported by those drivers, just V4L
> > stuff are there, but, assuming that some day a pipeline that also
> > works with other subsystems will ever added, it is better to add
> > explicit checks for the AV_DMA stuff.
> > 
> > Signed-off-by: Mauro Carvalho Chehab 
> > 
> > diff --git a/drivers/media/platform/exynos4-is/common.c
> > b/drivers/media/platform/exynos4-is/common.c index
> > 0eb34ecb8ee4..8c9a29e0e294 100644
> > --- a/drivers/media/platform/exynos4-is/common.c
> > +++ b/drivers/media/platform/exynos4-is/common.c
> > @@ -22,8 +22,7 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct
> > media_entity *entity) while (pad->flags & MEDIA_PAD_FL_SINK) {
> > /* source pad */
> > pad = media_entity_remote_pad(pad);
> > -   if (pad == NULL ||
> > -   media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > break;
> > 
> > sd = media_entity_to_v4l2_subdev(pad->entity);
> > diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c
> > b/drivers/media/platform/exynos4-is/fimc-capture.c index
> > 0627a93b2f3b..e9810fee4c30 100644
> > --- a/drivers/media/platform/exynos4-is/fimc-capture.c
> > +++ b/drivers/media/platform/exynos4-is/fimc-capture.c
> > @@ -1141,8 +1141,7 @@ static int fimc_pipeline_validate(struct fimc_dev
> > *fimc) }
> > }
> > 
> > -   if (src_pad == NULL ||
> > -   media_entity_type(src_pad->entity) != 
> > MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!src_pad || !is_media_entity_v4l2_subdev(src_pad->entity))
> > break;
> > 
> > /* Don't call FIMC subdev operation to avoid nested locking */
> > @@ -1397,7 +1396,7 @@ static int fimc_link_setup(struct media_entity
> > *entity, struct fimc_vid_cap *vc = &fimc->vid_cap;
> > struct v4l2_subdev *sensor;
> > 
> > -   if (media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!is_media_entity_v4l2_subdev(remote->entity))
> > return -EINVAL;
> > 
> > if (WARN_ON(fimc == NULL))
> > diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > b/drivers/media/platform/exynos4-is/fimc-isp-video.c index
> > 3d9ccbf5f10f..5fbaf5e39903 100644
> > --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
> > @@ -467,8 +467,7 @@ static int isp_video_pipeline_validate(struct fimc_isp
> > *isp)
> > 
> > /* Retrieve format at the source pad */
> > pad = media_entity_remote_pad(pad);
> > -   if (pad == NULL ||
> > -   media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > break;
> > 
> > sd = media_entity_to_v4l2_subdev(pad->entity);
> > diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c
> > b/drivers/media/platform/exynos4-is/fimc-lite.c index
> > b2607da4ad14..c2327147b360 100644
> > --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> > +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> > @@ -814,8 +814,7 @@ static int fimc_pipeline_validate(struct fimc_lite
> > *fimc) }
> > /* Retrieve format at the source pad */
> > pad = media_entity_remote_pad(pad);
> > -   if (pad == NULL ||
> > -   media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
> > +   if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
> > break;
> > 
> > sd = media_entity_to_v4l2_subdev(pad->entity);
> > @@ -988,7 +987,6 @@ static int fimc_lite_link_setup(struct media_entity
> > *entity, {
> > struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
> > struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
> > -   unsigned int remote_ent_type = media_entity_type(remote->entity);
> > int ret = 0;
> > 
> > if (WARN_ON(fimc == NULL))
> > @@ -1000,7 +998,7 @@ static int fimc_lite_link_setup(struct media_entity
> > *entity,
> > 
> > switch (local->index) {
> > case FLITE_SD_PAD_SINK:
> > -   if (remote_ent_type != MEDIA_ENT_T_V4L2_SUBDEV) {
> > +   if (!is_media_entity_v4l2_subdev(remote->entity)) {
> > ret = -EINVAL;
> > break;
> > }
> > @@ -1018,7 +1016,7 @@ static int fimc_lite_link_set