Message ID | 20220301161156.1119557-31-tomi.valkeinen@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series | v4l: routing and streams support | expand |
On Tue, Mar 01, 2022 at 06:11:50PM +0200, Tomi Valkeinen wrote: > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > If the subdev doesn't implement routing support, fallback to pad config > as the storage for pad formats. This allows using the V4L2 subdev active > state API and the v4l2_subdev_get_fmt() helper in subdev drivers that > don't implement routing support. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > drivers/media/v4l2-core/v4l2-subdev.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > index c1cc9b91dba7..7f50871054cd 100644 > --- a/drivers/media/v4l2-core/v4l2-subdev.c > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > @@ -1512,8 +1512,14 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, > { > struct v4l2_mbus_framefmt *fmt; > > - fmt = v4l2_subdev_state_get_stream_format(state, format->pad, > - format->stream); > + if (sd->flags & V4L2_SUBDEV_FL_MULTIPLEXED) > + fmt = v4l2_subdev_state_get_stream_format(state, format->pad, > + format->stream); > + else if (format->pad < sd->entity.num_pads && format->stream == 0) > + fmt = v4l2_subdev_get_try_format(sd, state, format->pad); > + else > + fmt = NULL; You could initialize fmt = NULL and skip the else Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Thanks j > + > if (!fmt) > return -EINVAL; > > -- > 2.25.1 >
On 16/03/2022 13:03, Jacopo Mondi wrote: > On Tue, Mar 01, 2022 at 06:11:50PM +0200, Tomi Valkeinen wrote: >> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com> >> >> If the subdev doesn't implement routing support, fallback to pad config >> as the storage for pad formats. This allows using the V4L2 subdev active >> state API and the v4l2_subdev_get_fmt() helper in subdev drivers that >> don't implement routing support. >> >> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> >> --- >> drivers/media/v4l2-core/v4l2-subdev.c | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c >> index c1cc9b91dba7..7f50871054cd 100644 >> --- a/drivers/media/v4l2-core/v4l2-subdev.c >> +++ b/drivers/media/v4l2-core/v4l2-subdev.c >> @@ -1512,8 +1512,14 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, >> { >> struct v4l2_mbus_framefmt *fmt; >> >> - fmt = v4l2_subdev_state_get_stream_format(state, format->pad, >> - format->stream); >> + if (sd->flags & V4L2_SUBDEV_FL_MULTIPLEXED) >> + fmt = v4l2_subdev_state_get_stream_format(state, format->pad, >> + format->stream); >> + else if (format->pad < sd->entity.num_pads && format->stream == 0) >> + fmt = v4l2_subdev_get_try_format(sd, state, format->pad); >> + else >> + fmt = NULL; > > You could initialize fmt = NULL and skip the else I do like it better this way, I think it's more understandable to have all the three cases listed there. Tomi
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index c1cc9b91dba7..7f50871054cd 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1512,8 +1512,14 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, { struct v4l2_mbus_framefmt *fmt; - fmt = v4l2_subdev_state_get_stream_format(state, format->pad, - format->stream); + if (sd->flags & V4L2_SUBDEV_FL_MULTIPLEXED) + fmt = v4l2_subdev_state_get_stream_format(state, format->pad, + format->stream); + else if (format->pad < sd->entity.num_pads && format->stream == 0) + fmt = v4l2_subdev_get_try_format(sd, state, format->pad); + else + fmt = NULL; + if (!fmt) return -EINVAL;