Message ID | 20200611161651.264633-9-jacopo+renesas@jmondi.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | v4l2-subdev: Introduce [g|s]et_mbus_format pad op | expand |
Hi Jacopo, On 11/06/2020 17:16, Jacopo Mondi wrote: > Implement the newly introduced get_mbus_config operation to report the > number of currently used data lanes on the MIPI CSI-2 interface. > > Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org> > --- > drivers/media/i2c/adv748x/adv748x-csi2.c | 31 ++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c > index 2091cda50935..99bb63d05eef 100644 > --- a/drivers/media/i2c/adv748x/adv748x-csi2.c > +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c > @@ -214,9 +214,40 @@ static int adv748x_csi2_set_format(struct v4l2_subdev *sd, > return ret; > } > > +static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad, > + struct v4l2_mbus_config *config) > +{ > + struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); > + > + if (pad != ADV748X_CSI2_SOURCE) > + return -EINVAL; > + > + config->type = V4L2_MBUS_CSI2_DPHY; > + switch (tx->active_lanes) { > + case 1: > + config->flags = V4L2_MBUS_CSI2_1_LANE; > + break; > + > + case 2: > + config->flags = V4L2_MBUS_CSI2_2_LANE; > + break; > + > + case 3: > + config->flags = V4L2_MBUS_CSI2_3_LANE; > + break; > + > + case 4: > + config->flags = V4L2_MBUS_CSI2_4_LANE; > + break; > + } > + > + return 0; > +} > + > static const struct v4l2_subdev_pad_ops adv748x_csi2_pad_ops = { > .get_fmt = adv748x_csi2_get_format, > .set_fmt = adv748x_csi2_set_format, > + .get_mbus_config = adv748x_csi2_get_mbus_config, > }; > > /* ----------------------------------------------------------------------------- >
diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c index 2091cda50935..99bb63d05eef 100644 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c @@ -214,9 +214,40 @@ static int adv748x_csi2_set_format(struct v4l2_subdev *sd, return ret; } +static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_mbus_config *config) +{ + struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); + + if (pad != ADV748X_CSI2_SOURCE) + return -EINVAL; + + config->type = V4L2_MBUS_CSI2_DPHY; + switch (tx->active_lanes) { + case 1: + config->flags = V4L2_MBUS_CSI2_1_LANE; + break; + + case 2: + config->flags = V4L2_MBUS_CSI2_2_LANE; + break; + + case 3: + config->flags = V4L2_MBUS_CSI2_3_LANE; + break; + + case 4: + config->flags = V4L2_MBUS_CSI2_4_LANE; + break; + } + + return 0; +} + static const struct v4l2_subdev_pad_ops adv748x_csi2_pad_ops = { .get_fmt = adv748x_csi2_get_format, .set_fmt = adv748x_csi2_set_format, + .get_mbus_config = adv748x_csi2_get_mbus_config, }; /* -----------------------------------------------------------------------------