Re: [RFC 2/3] v4l: vsp1: allow entities to have multiple source pads
Hi Laurent, On 02/11/16 23:59, Laurent Pinchart wrote: > Hi Kieran, > > Thank you for the patch. > > On Thursday 27 Oct 2016 15:01:24 Kieran Bingham wrote: >> The upcoming writeback feature of the VSP1 WPF, allows the active output >> of the DU to be written back to memory. On Generation 3 hardware, the DU >> is fed by the LIF, which is in turn fed by the WPF. >> >> It is the WPF which will perform memory writeback functionality, and >> this brings in a second output of the entity. Configured in this mode, >> the WPF will output to both the LIF, and to a memory (V4L2 video) >> device. >> >> Support this feature by extending vsp1_entity_init() to specify the >> number of source and sink pads. > > Do we need this, can't we just connect the single WPF source pad to both the > LIF and WPF output (video node) entities ? Yes, we can. Looks like I was over-engineering this - for not any particular/good reason - so I've dropped this patch and reworked the writeback to connect to the existing source pad. -- Regards Kieran > >> Signed-off-by: Kieran Bingham >> --- >> drivers/media/platform/vsp1/vsp1_bru.c| 2 +- >> drivers/media/platform/vsp1/vsp1_clu.c| 2 +- >> drivers/media/platform/vsp1/vsp1_entity.c | 15 --- >> drivers/media/platform/vsp1/vsp1_entity.h | 3 ++- >> drivers/media/platform/vsp1/vsp1_histo.c | 2 +- >> drivers/media/platform/vsp1/vsp1_hsit.c | 2 +- >> drivers/media/platform/vsp1/vsp1_lif.c| 2 +- >> drivers/media/platform/vsp1/vsp1_lut.c| 2 +- >> drivers/media/platform/vsp1/vsp1_rpf.c| 2 +- >> drivers/media/platform/vsp1/vsp1_sru.c| 2 +- >> drivers/media/platform/vsp1/vsp1_uds.c| 2 +- >> drivers/media/platform/vsp1/vsp1_wpf.c| 2 +- >> 12 files changed, 20 insertions(+), 18 deletions(-) >> >> diff --git a/drivers/media/platform/vsp1/vsp1_bru.c >> b/drivers/media/platform/vsp1/vsp1_bru.c index ee8355c28f94..796bcc77eb44 >> 100644 >> --- a/drivers/media/platform/vsp1/vsp1_bru.c >> +++ b/drivers/media/platform/vsp1/vsp1_bru.c >> @@ -411,7 +411,7 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device >> *vsp1) bru->entity.type = VSP1_ENTITY_BRU; >> >> ret = vsp1_entity_init(vsp1, &bru->entity, "bru", >> - vsp1->info->num_bru_inputs + 1, &bru_ops, >> + vsp1->info->num_bru_inputs, 1, &bru_ops, >> MEDIA_ENT_F_PROC_VIDEO_COMPOSER); >> if (ret < 0) >> return ERR_PTR(ret); >> diff --git a/drivers/media/platform/vsp1/vsp1_clu.c >> b/drivers/media/platform/vsp1/vsp1_clu.c index f2fb26e5ab4e..b38692b1f0dd >> 100644 >> --- a/drivers/media/platform/vsp1/vsp1_clu.c >> +++ b/drivers/media/platform/vsp1/vsp1_clu.c >> @@ -283,7 +283,7 @@ struct vsp1_clu *vsp1_clu_create(struct vsp1_device >> *vsp1) clu->entity.ops = &clu_entity_ops; >> clu->entity.type = VSP1_ENTITY_CLU; >> >> -ret = vsp1_entity_init(vsp1, &clu->entity, "clu", 2, &clu_ops, >> +ret = vsp1_entity_init(vsp1, &clu->entity, "clu", 1, 1, &clu_ops, >> MEDIA_ENT_F_PROC_VIDEO_LUT); >> if (ret < 0) >> return ERR_PTR(ret); >> diff --git a/drivers/media/platform/vsp1/vsp1_entity.c >> b/drivers/media/platform/vsp1/vsp1_entity.c index >> 5263387f7ec7..72c99de6e3a4 100644 >> --- a/drivers/media/platform/vsp1/vsp1_entity.c >> +++ b/drivers/media/platform/vsp1/vsp1_entity.c >> @@ -472,11 +472,13 @@ static const struct vsp1_route vsp1_routes[] = { >> }; >> >> int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, >> - const char *name, unsigned int num_pads, >> + const char *name, unsigned int num_sink_pads, >> + unsigned int num_source_pads, >> const struct v4l2_subdev_ops *ops, u32 function) >> { >> struct v4l2_subdev *subdev; >> unsigned int i; >> +unsigned int num_pads = num_sink_pads + num_source_pads; >> int ret; >> >> for (i = 0; i < ARRAY_SIZE(vsp1_routes); ++i) { >> @@ -501,18 +503,17 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct >> vsp1_entity *entity, if (entity->pads == NULL) >> return -ENOMEM; >> >> -for (i = 0; i < num_pads - 1; ++i) >> +for (i = 0; i < num_sink_pads; ++i) >> entity->pads[i].flags = MEDIA_PAD_FL_SINK; >> >> -entity->sources = devm_kcalloc(vsp1->dev, max(num_pads - 1, 1U), >> +for (; i < num_pads; ++i) >> +entity->pads[i].flags = MEDIA_PAD_FL_SOURCE; >> + >> +entity->sources = devm_kcalloc(vsp1->dev, num_source_pads, >> sizeof(*entity->sources), GFP_KERNEL); >> if (entity->sources == NULL) >> return -ENOMEM; >> >> -/* Single-pad entities only have a sink. */ >> -entity->pads[num_pads - 1].flags = num_pads > 1 ? MEDIA_PAD_FL_SOURCE >> - : MEDIA_PAD_FL_SINK; >> - >> /* Initialize the media entity. */ >> ret = media_entity
Re: [RFC 2/3] v4l: vsp1: allow entities to have multiple source pads
Hi Kieran, Thank you for the patch. On Thursday 27 Oct 2016 15:01:24 Kieran Bingham wrote: > The upcoming writeback feature of the VSP1 WPF, allows the active output > of the DU to be written back to memory. On Generation 3 hardware, the DU > is fed by the LIF, which is in turn fed by the WPF. > > It is the WPF which will perform memory writeback functionality, and > this brings in a second output of the entity. Configured in this mode, > the WPF will output to both the LIF, and to a memory (V4L2 video) > device. > > Support this feature by extending vsp1_entity_init() to specify the > number of source and sink pads. Do we need this, can't we just connect the single WPF source pad to both the LIF and WPF output (video node) entities ? > Signed-off-by: Kieran Bingham > --- > drivers/media/platform/vsp1/vsp1_bru.c| 2 +- > drivers/media/platform/vsp1/vsp1_clu.c| 2 +- > drivers/media/platform/vsp1/vsp1_entity.c | 15 --- > drivers/media/platform/vsp1/vsp1_entity.h | 3 ++- > drivers/media/platform/vsp1/vsp1_histo.c | 2 +- > drivers/media/platform/vsp1/vsp1_hsit.c | 2 +- > drivers/media/platform/vsp1/vsp1_lif.c| 2 +- > drivers/media/platform/vsp1/vsp1_lut.c| 2 +- > drivers/media/platform/vsp1/vsp1_rpf.c| 2 +- > drivers/media/platform/vsp1/vsp1_sru.c| 2 +- > drivers/media/platform/vsp1/vsp1_uds.c| 2 +- > drivers/media/platform/vsp1/vsp1_wpf.c| 2 +- > 12 files changed, 20 insertions(+), 18 deletions(-) > > diff --git a/drivers/media/platform/vsp1/vsp1_bru.c > b/drivers/media/platform/vsp1/vsp1_bru.c index ee8355c28f94..796bcc77eb44 > 100644 > --- a/drivers/media/platform/vsp1/vsp1_bru.c > +++ b/drivers/media/platform/vsp1/vsp1_bru.c > @@ -411,7 +411,7 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device > *vsp1) bru->entity.type = VSP1_ENTITY_BRU; > > ret = vsp1_entity_init(vsp1, &bru->entity, "bru", > -vsp1->info->num_bru_inputs + 1, &bru_ops, > +vsp1->info->num_bru_inputs, 1, &bru_ops, > MEDIA_ENT_F_PROC_VIDEO_COMPOSER); > if (ret < 0) > return ERR_PTR(ret); > diff --git a/drivers/media/platform/vsp1/vsp1_clu.c > b/drivers/media/platform/vsp1/vsp1_clu.c index f2fb26e5ab4e..b38692b1f0dd > 100644 > --- a/drivers/media/platform/vsp1/vsp1_clu.c > +++ b/drivers/media/platform/vsp1/vsp1_clu.c > @@ -283,7 +283,7 @@ struct vsp1_clu *vsp1_clu_create(struct vsp1_device > *vsp1) clu->entity.ops = &clu_entity_ops; > clu->entity.type = VSP1_ENTITY_CLU; > > - ret = vsp1_entity_init(vsp1, &clu->entity, "clu", 2, &clu_ops, > + ret = vsp1_entity_init(vsp1, &clu->entity, "clu", 1, 1, &clu_ops, > MEDIA_ENT_F_PROC_VIDEO_LUT); > if (ret < 0) > return ERR_PTR(ret); > diff --git a/drivers/media/platform/vsp1/vsp1_entity.c > b/drivers/media/platform/vsp1/vsp1_entity.c index > 5263387f7ec7..72c99de6e3a4 100644 > --- a/drivers/media/platform/vsp1/vsp1_entity.c > +++ b/drivers/media/platform/vsp1/vsp1_entity.c > @@ -472,11 +472,13 @@ static const struct vsp1_route vsp1_routes[] = { > }; > > int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, > - const char *name, unsigned int num_pads, > + const char *name, unsigned int num_sink_pads, > + unsigned int num_source_pads, >const struct v4l2_subdev_ops *ops, u32 function) > { > struct v4l2_subdev *subdev; > unsigned int i; > + unsigned int num_pads = num_sink_pads + num_source_pads; > int ret; > > for (i = 0; i < ARRAY_SIZE(vsp1_routes); ++i) { > @@ -501,18 +503,17 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct > vsp1_entity *entity, if (entity->pads == NULL) > return -ENOMEM; > > - for (i = 0; i < num_pads - 1; ++i) > + for (i = 0; i < num_sink_pads; ++i) > entity->pads[i].flags = MEDIA_PAD_FL_SINK; > > - entity->sources = devm_kcalloc(vsp1->dev, max(num_pads - 1, 1U), > + for (; i < num_pads; ++i) > + entity->pads[i].flags = MEDIA_PAD_FL_SOURCE; > + > + entity->sources = devm_kcalloc(vsp1->dev, num_source_pads, > sizeof(*entity->sources), GFP_KERNEL); > if (entity->sources == NULL) > return -ENOMEM; > > - /* Single-pad entities only have a sink. */ > - entity->pads[num_pads - 1].flags = num_pads > 1 ? MEDIA_PAD_FL_SOURCE > - : MEDIA_PAD_FL_SINK; > - > /* Initialize the media entity. */ > ret = media_entity_pads_init(&entity->subdev.entity, num_pads, >entity->pads); > diff --git a/drivers/media/platform/vsp1/vsp1_entity.h > b/drivers/media/platform/vsp1/vsp1_entity.h index > c169a060b6d2..c709c29eb994 100644 > --- a/drivers/media/platform/vsp1/vsp1_entity.h > +++ b/drivers/media/platform/vsp1/vsp1
[RFC 2/3] v4l: vsp1: allow entities to have multiple source pads
The upcoming writeback feature of the VSP1 WPF, allows the active output of the DU to be written back to memory. On Generation 3 hardware, the DU is fed by the LIF, which is in turn fed by the WPF. It is the WPF which will perform memory writeback functionality, and this brings in a second output of the entity. Configured in this mode, the WPF will output to both the LIF, and to a memory (V4L2 video) device. Support this feature by extending vsp1_entity_init() to specify the number of source and sink pads. Signed-off-by: Kieran Bingham --- drivers/media/platform/vsp1/vsp1_bru.c| 2 +- drivers/media/platform/vsp1/vsp1_clu.c| 2 +- drivers/media/platform/vsp1/vsp1_entity.c | 15 --- drivers/media/platform/vsp1/vsp1_entity.h | 3 ++- drivers/media/platform/vsp1/vsp1_histo.c | 2 +- drivers/media/platform/vsp1/vsp1_hsit.c | 2 +- drivers/media/platform/vsp1/vsp1_lif.c| 2 +- drivers/media/platform/vsp1/vsp1_lut.c| 2 +- drivers/media/platform/vsp1/vsp1_rpf.c| 2 +- drivers/media/platform/vsp1/vsp1_sru.c| 2 +- drivers/media/platform/vsp1/vsp1_uds.c| 2 +- drivers/media/platform/vsp1/vsp1_wpf.c| 2 +- 12 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_bru.c b/drivers/media/platform/vsp1/vsp1_bru.c index ee8355c28f94..796bcc77eb44 100644 --- a/drivers/media/platform/vsp1/vsp1_bru.c +++ b/drivers/media/platform/vsp1/vsp1_bru.c @@ -411,7 +411,7 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1) bru->entity.type = VSP1_ENTITY_BRU; ret = vsp1_entity_init(vsp1, &bru->entity, "bru", - vsp1->info->num_bru_inputs + 1, &bru_ops, + vsp1->info->num_bru_inputs, 1, &bru_ops, MEDIA_ENT_F_PROC_VIDEO_COMPOSER); if (ret < 0) return ERR_PTR(ret); diff --git a/drivers/media/platform/vsp1/vsp1_clu.c b/drivers/media/platform/vsp1/vsp1_clu.c index f2fb26e5ab4e..b38692b1f0dd 100644 --- a/drivers/media/platform/vsp1/vsp1_clu.c +++ b/drivers/media/platform/vsp1/vsp1_clu.c @@ -283,7 +283,7 @@ struct vsp1_clu *vsp1_clu_create(struct vsp1_device *vsp1) clu->entity.ops = &clu_entity_ops; clu->entity.type = VSP1_ENTITY_CLU; - ret = vsp1_entity_init(vsp1, &clu->entity, "clu", 2, &clu_ops, + ret = vsp1_entity_init(vsp1, &clu->entity, "clu", 1, 1, &clu_ops, MEDIA_ENT_F_PROC_VIDEO_LUT); if (ret < 0) return ERR_PTR(ret); diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c index 5263387f7ec7..72c99de6e3a4 100644 --- a/drivers/media/platform/vsp1/vsp1_entity.c +++ b/drivers/media/platform/vsp1/vsp1_entity.c @@ -472,11 +472,13 @@ static const struct vsp1_route vsp1_routes[] = { }; int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, -const char *name, unsigned int num_pads, +const char *name, unsigned int num_sink_pads, +unsigned int num_source_pads, const struct v4l2_subdev_ops *ops, u32 function) { struct v4l2_subdev *subdev; unsigned int i; + unsigned int num_pads = num_sink_pads + num_source_pads; int ret; for (i = 0; i < ARRAY_SIZE(vsp1_routes); ++i) { @@ -501,18 +503,17 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, if (entity->pads == NULL) return -ENOMEM; - for (i = 0; i < num_pads - 1; ++i) + for (i = 0; i < num_sink_pads; ++i) entity->pads[i].flags = MEDIA_PAD_FL_SINK; - entity->sources = devm_kcalloc(vsp1->dev, max(num_pads - 1, 1U), + for (; i < num_pads; ++i) + entity->pads[i].flags = MEDIA_PAD_FL_SOURCE; + + entity->sources = devm_kcalloc(vsp1->dev, num_source_pads, sizeof(*entity->sources), GFP_KERNEL); if (entity->sources == NULL) return -ENOMEM; - /* Single-pad entities only have a sink. */ - entity->pads[num_pads - 1].flags = num_pads > 1 ? MEDIA_PAD_FL_SOURCE -: MEDIA_PAD_FL_SINK; - /* Initialize the media entity. */ ret = media_entity_pads_init(&entity->subdev.entity, num_pads, entity->pads); diff --git a/drivers/media/platform/vsp1/vsp1_entity.h b/drivers/media/platform/vsp1/vsp1_entity.h index c169a060b6d2..c709c29eb994 100644 --- a/drivers/media/platform/vsp1/vsp1_entity.h +++ b/drivers/media/platform/vsp1/vsp1_entity.h @@ -120,7 +120,8 @@ static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev) } int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, -const char *name, unsigned int num_pads, +const char *name, unsigned int num_sink