media: i2c: imx258: Parse and register properties
PATCH 1/1 media: i2c: imx258: Parse and register properties
Analogous to e.g. the imx219. This enables propagating V4L2_CID_CAMERA_SENSOR_ROTATION values so that libcamera can detect the correct rotation from the device tree and propagate it further to e.g. Pipewire.
--- drivers/media/i2c/imx258.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/media/i2c/imx258.c +12 -1
@@ -9,6 +9,7 @@#include <linux/pm_runtime.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> #include <asm/unaligned.h> #define IMX258_REG_VALUE_08BIT 1
@@ -1149,6 +1150,7 @@ static int imx258_init_controls(struct imx258 *imx258) {struct i2c_client *client =v4l2_get_subdevdata (&imx258->sd);struct v4l2_ctrl_handler *ctrl_hdlr; +struct v4l2_fwnode_device_properties props;s64 vblank_def;s64 vblank_min;s64 pixel_rate_min;
@@ -1156,7 +1158,7 @@ static int imx258_init_controls(struct imx258 *imx258)int ret; ctrl_hdlr = &imx258->ctrl_handler; - ret =v4l2_ctrl_handler_init (ctrl_hdlr,8 ); + ret =v4l2_ctrl_handler_init (ctrl_hdlr,10 );if (ret)return ret;
@@ -1232,6 +1234,15 @@ static int imx258_init_controls(struct imx258 *imx258) goto error; } + ret =v4l2_fwnode_device_parse (&client->dev, &props); +if (ret) + goto error; + + ret =v4l2_ctrl_new_fwnode_properties (ctrl_hdlr, &imx258_ctrl_ops, + &props); +if (ret) + goto error; + imx258->sd.ctrl_handler = ctrl_hdlr;return 0 ;
Signature · 1 line
2.39.0
Hi Robert
Quoted 23 lines · Robert Mader
Analogous to e.g. the imx219. This enables propagating
V4L2_CID_CAMERA_SENSOR_ROTATIONvalues so that libcamera can detect the correct rotation from the device tree and propagate it further to e.g. Pipewire.Signed-off-by Robert Mader <[email protected]>--- drivers/media/i2c/imx258.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/media/i2c/imx258.c +1
-0@@ -9,6 +9,7 @@#include <linux/pm_runtime.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> #include <asm/unaligned.h> #define IMX258_REG_VALUE_08BIT 1
drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1153
Quoted 4 lines
drivers/media/i2c/imx258.c +1
-0@@ -1149,6 +1150,7 @@ static int imx258_init_controls(struct imx258 *imx258) {struct i2c_client *client =v4l2_get_subdevdata (&imx258->sd);struct v4l2_ctrl_handler *ctrl_hdlr; +struct v4l2_fwnode_device_properties props;
Might be nicer to move this one line up
drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1161
Quoted 9 lines
drivers/media/i2c/imx258.c +1
-1s64 vblank_def;s64 vblank_min;s64 pixel_rate_min;@@ -1156,7 +1158,7 @@ static int imx258_init_controls(struct imx258 *imx258)int ret; ctrl_hdlr = &imx258->ctrl_handler; - ret =v4l2_ctrl_handler_init (ctrl_hdlr,8 ); + ret =v4l2_ctrl_handler_init (ctrl_hdlr,10 );
I count 9 controls being registered before this patch, not 8. Do I count them right ?
If that's case, as v4l2_ctrl_new_fwnode_properties()
can register up to two controls (V4L2_CID_ROTATION and V4L2_CID_ORIENTATION) I would pre-reserve 11 controls not 10 to avoid relocations.
Quoted 6 lines
drivers/media/i2c/imx258.c +0
-0if (ret)return ret;@@ -1232,6 +1234,15 @@ static int imx258_init_controls(struct imx258 *imx258) goto error; }
drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1245
Quoted 10 lines
drivers/media/i2c/imx258.c +9
-0+ ret =v4l2_fwnode_device_parse (&client->dev, &props); +if (ret) + goto error; + + ret =v4l2_ctrl_new_fwnode_properties (ctrl_hdlr, &imx258_ctrl_ops, + &props); +if (ret) + goto error; +
The rest looks good to me!
Thanks
j
Quoted 6 lines
drivers/media/i2c/imx258.c +0
-1imx258->sd.ctrl_handler = ctrl_hdlr;return 0 ; --2.39.0
Quoted 24 lines · Jacopo Mondi
Hi Robert
Quoted 21 lines · Robert Mader
Analogous to e.g. the imx219. This enables propagating
V4L2_CID_CAMERA_SENSOR_ROTATIONvalues so that libcamera can detect the correct rotation from the device tree and propagate it further to e.g. Pipewire.Signed-off-by Robert Mader <[email protected]>--- drivers/media/i2c/imx258.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/media/i2c/imx258.c +1
-0@@ -9,6 +9,7 @@#include <linux/pm_runtime.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> #include <asm/unaligned.h>
Quoted 7 lines
drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1153
Quoted 6 lines
drivers/media/i2c/imx258.c +1
-0#define IMX258_REG_VALUE_08BIT 1@@ -1149,6 +1150,7 @@ static int imx258_init_controls(struct imx258 *imx258) {struct i2c_client *client =v4l2_get_subdevdata (&imx258->sd);struct v4l2_ctrl_handler *ctrl_hdlr; +struct v4l2_fwnode_device_properties props;Might be nicer to move this one line up
Can you say what's your reasoning? I personally slightly prefer alphabetical order, but no strong opinion :)
Quoted 12 lines
drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1161
Quoted 9 lines
drivers/media/i2c/imx258.c +1
-1s64 vblank_def;s64 vblank_min;s64 pixel_rate_min;@@ -1156,7 +1158,7 @@ static int imx258_init_controls(struct imx258 *imx258)int ret; ctrl_hdlr = &imx258->ctrl_handler; - ret =v4l2_ctrl_handler_init (ctrl_hdlr,8 ); + ret =v4l2_ctrl_handler_init (ctrl_hdlr,10 );I count 9 controls being registered before this patch, not 8. Do I count them right ?
Quoted 4 lines
If that's case, as
v4l2_ctrl_new_fwnode_properties()
can register up to two controls (V4L2_CID_ROTATIONandV4L2_CID_ORIENTATION) I would pre-reserve 11 controls not 10 to avoid relocations.
Indeed, looks like bumping this was forgotten in c6f9d67e2ac625e331f6a7f5715d2f809ff0a922
Quoted 18 lines
Quoted 6 lines
drivers/media/i2c/imx258.c +0
-0if (ret)return ret;@@ -1232,6 +1234,15 @@ static int imx258_init_controls(struct imx258 *imx258) goto error; }drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1245
Quoted 10 lines
drivers/media/i2c/imx258.c +9
-0+ ret =v4l2_fwnode_device_parse (&client->dev, &props); +if (ret) + goto error; + + ret =v4l2_ctrl_new_fwnode_properties (ctrl_hdlr, &imx258_ctrl_ops, + &props); +if (ret) + goto error; +The rest looks good to me!
Quoted 2 lines
Thanks
j
Thanks!
Signature · 6 lines
Robert Mader Consultant Software Developer Collabora Ltd. Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK Registered in England & Wales, no. 5513718
Hi Robert
Quoted 33 lines · Robert Mader
Quoted 24 lines · Jacopo Mondi
Hi Robert
Quoted 21 lines · Robert Mader
Analogous to e.g. the imx219. This enables propagating
V4L2_CID_CAMERA_SENSOR_ROTATIONvalues so that libcamera can detect the correct rotation from the device tree and propagate it further to e.g. Pipewire.Signed-off-by Robert Mader <[email protected]>--- drivers/media/i2c/imx258.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/media/i2c/imx258.c +1
-0@@ -9,6 +9,7 @@#include <linux/pm_runtime.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> #include <asm/unaligned.h> Quoted 7 lines
drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1153
Quoted 6 lines
drivers/media/i2c/imx258.c +1
-0#define IMX258_REG_VALUE_08BIT 1@@ -1149,6 +1150,7 @@ static int imx258_init_controls(struct imx258 *imx258) {struct i2c_client *client =v4l2_get_subdevdata (&imx258->sd);struct v4l2_ctrl_handler *ctrl_hdlr; +struct v4l2_fwnode_device_properties props;Might be nicer to move this one line up
Quoted 3 lines
Can you say what's your reasoning? I personally slightly prefer alphabetical order, but no strong opinion :)
I've often been instructed to try to respect the inverse-xmas-tree order when declaring variables, if possible. I now realize it's a sort of cargo cult, as the rule is not written anywhere, so I can't ask you to comply with what seems to be a personal preference :)
Quoted 3 lines
Quoted 3 lines
drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1156
Quoted 3 lines
drivers/media/i2c/imx258.c +0
-0s64 vblank_def;s64 vblank_min;s64 pixel_rate_min;
And anyway this breaks the rule already, so up to you, really
Quoted 9 lines
Quoted 9 lines
drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1161
Quoted 6 lines
drivers/media/i2c/imx258.c +1
-1@@ -1156,7 +1158,7 @@ static int imx258_init_controls(struct imx258 *imx258)int ret; ctrl_hdlr = &imx258->ctrl_handler; - ret =v4l2_ctrl_handler_init (ctrl_hdlr,8 ); + ret =v4l2_ctrl_handler_init (ctrl_hdlr,10 );I count 9 controls being registered before this patch, not 8. Do I count them right ?
Quoted 8 lines
Quoted 4 lines
If that's case, as
v4l2_ctrl_new_fwnode_properties()
can register up to two controls (V4L2_CID_ROTATIONandV4L2_CID_ORIENTATION) I would pre-reserve 11 controls not 10 to avoid relocations.Indeed, looks like bumping this was forgotten in
c6f9d67e2ac625e331f6a7f5715d2f809ff0a922
Sorry, not your fault but since you're here... You can either make a patch that fixes the existing number of controls first then apply this one on top, or address the issue here, maybe with a small mention in the commit message along the lines of:
While at it, reserve space for 3 additional controls even if v4l2_ctrl_new_fwnode_properties() can only register 2 of them, to fix the existing implementation which reserve space for 8 controls but actually registers 9.
Thanks
j
Quoted 30 lines
Quoted 18 lines
Quoted 6 lines
drivers/media/i2c/imx258.c +0
-0if (ret)return ret;@@ -1232,6 +1234,15 @@ static int imx258_init_controls(struct imx258 *imx258) goto error; }drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1245
Quoted 10 lines
drivers/media/i2c/imx258.c +9
-0+ ret =v4l2_fwnode_device_parse (&client->dev, &props); +if (ret) + goto error; + + ret =v4l2_ctrl_new_fwnode_properties (ctrl_hdlr, &imx258_ctrl_ops, + &props); +if (ret) + goto error; +The rest looks good to me!
Quoted 2 lines
Thanks
jThanks!
--
Robert Mader
Consultant Software DeveloperCollabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK Registered in England & Wales, no. 5513718
Sakari Ailus
maintainerHi Jacopo, Robert,
Quoted 36 lines · Jacopo Mondi
Hi Robert
Quoted 33 lines · Robert Mader
Quoted 31 lines · Jacopo Mondi
Hi Robert
Quoted 23 lines · Robert Mader
Analogous to e.g. the imx219. This enables propagating
V4L2_CID_CAMERA_SENSOR_ROTATIONvalues so that libcamera can detect the correct rotation from the device tree and propagate it further to e.g. Pipewire.Signed-off-by Robert Mader <[email protected]>--- drivers/media/i2c/imx258.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/media/i2c/imx258.c +1
-0@@ -9,6 +9,7 @@#include <linux/pm_runtime.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> #include <asm/unaligned.h> #define IMX258_REG_VALUE_08BIT 1drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1153
Quoted 4 lines
drivers/media/i2c/imx258.c +1
-0@@ -1149,6 +1150,7 @@ static int imx258_init_controls(struct imx258 *imx258) {struct i2c_client *client =v4l2_get_subdevdata (&imx258->sd);struct v4l2_ctrl_handler *ctrl_hdlr; +struct v4l2_fwnode_device_properties props;Might be nicer to move this one line up
Quoted 5 lines
Quoted 3 lines
Can you say what's your reasoning? I personally slightly prefer alphabetical order, but no strong opinion :)
I've often been instructed to try to respect the inverse-xmas-tree
I'd advise the same, unless there are other reasons to arrange the lines differently.
Signature · 3 lines
Kind regards, Sakari Ailus
Sure, makes sense!
Send out v2 now.
Quoted 45 lines · Sakari Ailus
Hi Jacopo, Robert,
Quoted 35 lines · Jacopo Mondi
Hi Robert
Quoted 32 lines · Robert Mader
Quoted 31 lines · Jacopo Mondi
Hi Robert
Quoted 23 lines · Robert Mader
Analogous to e.g. the imx219. This enables propagating
V4L2_CID_CAMERA_SENSOR_ROTATIONvalues so that libcamera can detect the correct rotation from the device tree and propagate it further to e.g. Pipewire.Signed-off-by Robert Mader <[email protected]>--- drivers/media/i2c/imx258.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/media/i2c/imx258.c +1
-0@@ -9,6 +9,7 @@#include <linux/pm_runtime.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> +#include <media/v4l2-fwnode.h> #include <asm/unaligned.h> #define IMX258_REG_VALUE_08BIT 1drivers/media/i2c/imx258.c static int imx258_init_controls(struct imx258 *imx258) · line 1153
Quoted 4 lines
drivers/media/i2c/imx258.c +1
-0@@ -1149,6 +1150,7 @@ static int imx258_init_controls(struct imx258 *imx258) {struct i2c_client *client =v4l2_get_subdevdata (&imx258->sd);struct v4l2_ctrl_handler *ctrl_hdlr; +struct v4l2_fwnode_device_properties props;Might be nicer to move this one line up
Quoted 4 lines
Quoted 3 lines
Can you say what's your reasoning? I personally slightly prefer
alphabetical order, but no strong opinion :)I've often been instructed to try to respect the inverse-xmas-tree
I'd advise the same, unless there are other reasons to arrange the lines differently.