Message ID | 20190820094027.4144-3-ribalda@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/3] media: add V4L2_CID_UNIT_CELL_SIZE control | expand |
On Tue, 2019-08-20 at 11:40 +0200, Ricardo Ribalda Delgado wrote: > According to the product brief, the unit cell size is 1120 nanometers^2. > > https://www.sony-semicon.co.jp/products_en/IS/sensor1/img/products/ProductBrief_IMX214_20150428.pdf > > Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org> > --- > drivers/media/i2c/imx214.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c > index 159a3a604f0e..cc0a013ba7da 100644 > --- a/drivers/media/i2c/imx214.c > +++ b/drivers/media/i2c/imx214.c > @@ -47,6 +47,7 @@ struct imx214 { > struct v4l2_ctrl *pixel_rate; > struct v4l2_ctrl *link_freq; > struct v4l2_ctrl *exposure; > + struct v4l2_ctrl *unit_size; This is never used. Neither are pixel_rate and exposure, it appears. And link_freq is only used locally in imx214_probe to set the read-only flag. > > struct regulator_bulk_data supplies[IMX214_NUM_SUPPLIES]; > > @@ -941,6 +942,26 @@ static int __maybe_unused imx214_resume(struct device *dev) > return ret; > } > > +static void unit_size_init(const struct v4l2_ctrl *ctrl, u32 idx, > + union v4l2_ctrl_ptr ptr) > +{ > + ptr.p_area->width = 1120; > + ptr.p_area->height = 1120; > +} > + > +static const struct v4l2_ctrl_type_ops unit_size_ops = { > + .init = unit_size_init, > +}; > + > +static struct v4l2_ctrl *new_unit_size_ctrl(struct v4l2_ctrl_handler *handler) > +{ > + static struct v4l2_ctrl_config ctrl = { > + .id = V4L2_CID_UNIT_CELL_SIZE, > + .type_ops = &unit_size_ops, > + }; > + > + return v4l2_ctrl_new_custom(handler, &ctrl, NULL); > +} > static int imx214_probe(struct i2c_client *client) > { > struct device *dev = &client->dev; > @@ -1029,6 +1050,8 @@ static int imx214_probe(struct i2c_client *client) > V4L2_CID_EXPOSURE, > 0, 3184, 1, 0x0c70); > > + imx214->unit_size = new_unit_size_ctrl(&imx214->ctrls); > + > ret = imx214->ctrls.error; > if (ret) { > dev_err(&client->dev, "%s control init failed (%d)\n", This seems like a lot of parts to assemble in every sensor driver just to provide a constant area control. Should this be turned into a v4l2_ctrl_new_area helper that takes a const struct v4l2_area as an argument? static const struct v4l2_area unit_cell_size = { .width = 1120, .height = 1120 }; v4l2_ctrl_new_area(&imx214->ctrls, V4L2_CID_UNIT_CELL_SIZE, &unit_cell_size); regards Philipp
Hi Philipp On Thu, Aug 22, 2019 at 11:31 AM Philipp Zabel <p.zabel@pengutronix.de> wrote: > > On Tue, 2019-08-20 at 11:40 +0200, Ricardo Ribalda Delgado wrote: > > According to the product brief, the unit cell size is 1120 nanometers^2. > > > > https://www.sony-semicon.co.jp/products_en/IS/sensor1/img/products/ProductBrief_IMX214_20150428.pdf > > > > Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org> > > --- > > drivers/media/i2c/imx214.c | 23 +++++++++++++++++++++++ > > 1 file changed, 23 insertions(+) > > > > diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c > > index 159a3a604f0e..cc0a013ba7da 100644 > > --- a/drivers/media/i2c/imx214.c > > +++ b/drivers/media/i2c/imx214.c > > @@ -47,6 +47,7 @@ struct imx214 { > > struct v4l2_ctrl *pixel_rate; > > struct v4l2_ctrl *link_freq; > > struct v4l2_ctrl *exposure; > > + struct v4l2_ctrl *unit_size; > > This is never used. > > Neither are pixel_rate and exposure, it appears. And link_freq is only > used locally in imx214_probe to set the read-only flag. > > > > > struct regulator_bulk_data supplies[IMX214_NUM_SUPPLIES]; > > > > @@ -941,6 +942,26 @@ static int __maybe_unused imx214_resume(struct device *dev) > > return ret; > > } > > > > +static void unit_size_init(const struct v4l2_ctrl *ctrl, u32 idx, > > + union v4l2_ctrl_ptr ptr) > > +{ > > + ptr.p_area->width = 1120; > > + ptr.p_area->height = 1120; > > +} > > + > > +static const struct v4l2_ctrl_type_ops unit_size_ops = { > > + .init = unit_size_init, > > +}; > > + > > +static struct v4l2_ctrl *new_unit_size_ctrl(struct v4l2_ctrl_handler *handler) > > +{ > > + static struct v4l2_ctrl_config ctrl = { > > + .id = V4L2_CID_UNIT_CELL_SIZE, > > + .type_ops = &unit_size_ops, > > + }; > > + > > + return v4l2_ctrl_new_custom(handler, &ctrl, NULL); > > +} > > static int imx214_probe(struct i2c_client *client) > > { > > struct device *dev = &client->dev; > > @@ -1029,6 +1050,8 @@ static int imx214_probe(struct i2c_client *client) > > V4L2_CID_EXPOSURE, > > 0, 3184, 1, 0x0c70); > > > > + imx214->unit_size = new_unit_size_ctrl(&imx214->ctrls); > > + > > ret = imx214->ctrls.error; > > if (ret) { > > dev_err(&client->dev, "%s control init failed (%d)\n", > > This seems like a lot of parts to assemble in every sensor driver just > to provide a constant area control. Should this be turned into a > v4l2_ctrl_new_area helper that takes a const struct v4l2_area as an > argument? I agree, I was planning on making a helper afterwards ;). I do not mind adding it to this series. > > static const struct v4l2_area unit_cell_size = { > .width = 1120, > .height = 1120 > }; > > v4l2_ctrl_new_area(&imx214->ctrls, V4L2_CID_UNIT_CELL_SIZE, > &unit_cell_size); > > regards > Philipp
diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 159a3a604f0e..cc0a013ba7da 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -47,6 +47,7 @@ struct imx214 { struct v4l2_ctrl *pixel_rate; struct v4l2_ctrl *link_freq; struct v4l2_ctrl *exposure; + struct v4l2_ctrl *unit_size; struct regulator_bulk_data supplies[IMX214_NUM_SUPPLIES]; @@ -941,6 +942,26 @@ static int __maybe_unused imx214_resume(struct device *dev) return ret; } +static void unit_size_init(const struct v4l2_ctrl *ctrl, u32 idx, + union v4l2_ctrl_ptr ptr) +{ + ptr.p_area->width = 1120; + ptr.p_area->height = 1120; +} + +static const struct v4l2_ctrl_type_ops unit_size_ops = { + .init = unit_size_init, +}; + +static struct v4l2_ctrl *new_unit_size_ctrl(struct v4l2_ctrl_handler *handler) +{ + static struct v4l2_ctrl_config ctrl = { + .id = V4L2_CID_UNIT_CELL_SIZE, + .type_ops = &unit_size_ops, + }; + + return v4l2_ctrl_new_custom(handler, &ctrl, NULL); +} static int imx214_probe(struct i2c_client *client) { struct device *dev = &client->dev; @@ -1029,6 +1050,8 @@ static int imx214_probe(struct i2c_client *client) V4L2_CID_EXPOSURE, 0, 3184, 1, 0x0c70); + imx214->unit_size = new_unit_size_ctrl(&imx214->ctrls); + ret = imx214->ctrls.error; if (ret) { dev_err(&client->dev, "%s control init failed (%d)\n",
According to the product brief, the unit cell size is 1120 nanometers^2. https://www.sony-semicon.co.jp/products_en/IS/sensor1/img/products/ProductBrief_IMX214_20150428.pdf Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org> --- drivers/media/i2c/imx214.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)