Message ID | 20211017182449.64192-8-jacopo+renesas@jmondi.org (mailing list archive) |
---|---|
State | New |
Delegated to: | Kieran Bingham |
Headers | show |
Series | media: Add multiplexed support to R-Car CSI-2 and GMSL | expand |
Hi Jacopo, Thank you for the patch. On Sun, Oct 17, 2021 at 08:24:43PM +0200, Jacopo Mondi wrote: > Implement the get_frame_desc pad operation to allow retrieving the > stream configuration of the max9286 subdevice. > > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org> > --- > drivers/media/i2c/max9286.c | 53 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > > diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c > index 8bfb88db9976..aca8455d6d56 100644 > --- a/drivers/media/i2c/max9286.c > +++ b/drivers/media/i2c/max9286.c > @@ -878,6 +878,58 @@ static int max9286_set_fmt(struct v4l2_subdev *sd, > return ret; > } > > +static int max9286_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, > + struct v4l2_mbus_frame_desc *fd) > +{ > + struct v4l2_subdev_route *route; > + struct v4l2_subdev_state *state; > + int ret = 0; > + > + if (pad != MAX9286_SRC_PAD) > + return -EINVAL; > + > + state = v4l2_subdev_lock_active_state(sd); > + > + memset(fd, 0, sizeof(*fd)); > + > + /* One stream entry per each connected route. */ s/connected/active/ > + for_each_active_route(&state->routing, route) { > + struct v4l2_mbus_frame_desc_entry *entry = > + &fd->entry[fd->num_entries]; > + struct v4l2_mbus_framefmt *fmt; > + > + fmt = v4l2_state_get_stream_format(state, pad, I would write s/pad/MAX9286_SRC_PAD/. This won't chanege the behaviour, but would be more explicit. > + route->source_stream); > + if (!fmt) { > + ret = -EINVAL; > + goto out; > + } > + > + /* > + * Assume a YUYV format (0x1e DT) and 16 bpp: we only support > + * these formats at the moment. > + */ I'll rebase my pending max9286 series on top of your poc-gpio patches, but in return I'll ask you to rebase this on top of my patches, which add support for other formats :-) > + entry->stream = fd->num_entries++; > + entry->flags = V4L2_MBUS_FRAME_DESC_FL_LEN_MAX; > + entry->length = fmt->width * fmt->height * 16 / 8; > + entry->pixelcode = fmt->code; > + > + /* > + * The source stream id corresponds to the virtual channel a > + * stream is output on. > + */ > + entry->bus.csi2.vc = route->source_stream; > + entry->bus.csi2.dt = 0x1e; > + } > + > + fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; > + > +out: > + v4l2_subdev_unlock_state(state); > + > + return ret; > +} > + > static int max9286_routing_verify(struct max9286_priv *priv, > struct v4l2_subdev_krouting *routing) > { > @@ -1020,6 +1072,7 @@ static const struct v4l2_subdev_pad_ops max9286_pad_ops = { > .enum_mbus_code = max9286_enum_mbus_code, > .get_fmt = v4l2_subdev_get_fmt, > .set_fmt = max9286_set_fmt, > + .get_frame_desc = max9286_get_frame_desc, > .set_routing = max9286_set_routing, > }; >
diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 8bfb88db9976..aca8455d6d56 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -878,6 +878,58 @@ static int max9286_set_fmt(struct v4l2_subdev *sd, return ret; } +static int max9286_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct v4l2_subdev_route *route; + struct v4l2_subdev_state *state; + int ret = 0; + + if (pad != MAX9286_SRC_PAD) + return -EINVAL; + + state = v4l2_subdev_lock_active_state(sd); + + memset(fd, 0, sizeof(*fd)); + + /* One stream entry per each connected route. */ + for_each_active_route(&state->routing, route) { + struct v4l2_mbus_frame_desc_entry *entry = + &fd->entry[fd->num_entries]; + struct v4l2_mbus_framefmt *fmt; + + fmt = v4l2_state_get_stream_format(state, pad, + route->source_stream); + if (!fmt) { + ret = -EINVAL; + goto out; + } + + /* + * Assume a YUYV format (0x1e DT) and 16 bpp: we only support + * these formats at the moment. + */ + entry->stream = fd->num_entries++; + entry->flags = V4L2_MBUS_FRAME_DESC_FL_LEN_MAX; + entry->length = fmt->width * fmt->height * 16 / 8; + entry->pixelcode = fmt->code; + + /* + * The source stream id corresponds to the virtual channel a + * stream is output on. + */ + entry->bus.csi2.vc = route->source_stream; + entry->bus.csi2.dt = 0x1e; + } + + fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; + +out: + v4l2_subdev_unlock_state(state); + + return ret; +} + static int max9286_routing_verify(struct max9286_priv *priv, struct v4l2_subdev_krouting *routing) { @@ -1020,6 +1072,7 @@ static const struct v4l2_subdev_pad_ops max9286_pad_ops = { .enum_mbus_code = max9286_enum_mbus_code, .get_fmt = v4l2_subdev_get_fmt, .set_fmt = max9286_set_fmt, + .get_frame_desc = max9286_get_frame_desc, .set_routing = max9286_set_routing, };
Implement the get_frame_desc pad operation to allow retrieving the stream configuration of the max9286 subdevice. Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org> --- drivers/media/i2c/max9286.c | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)