media: i2c: alvium: Fix controls for WB/AWB
Subsystems (3)
Martin Hecht
maintainerPATCH 1/1 media: i2c: alvium: Fix controls for WB/AWB
With that patch the controls for red-balance and blue-balance were created only if the particular camera supports that. Otherwise the pointers on the control variable are initialized with NULL to prevent side effects for clustering with AWB control.
--- drivers/media/i2c/alvium-csi2.c | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/media/i2c/alvium-csi2.c +22 -15
@@ -2108,26 +2108,33 @@ static int alvium_ctrl_init(struct alvium_dev *alvium) 0, 0, &alvium->link_freq); ctrls->link_freq->flags |=V4L2_CTRL_FLAG_READ_ONLY ; +if (alvium->avail_ft.whiteb) { + ctrls->blue_balance =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_BLUE_BALANCE , + alvium->min_bbalance, + alvium->max_bbalance, + alvium->inc_bbalance, + alvium->dft_bbalance); + ctrls->red_balance =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_RED_BALANCE , + alvium->min_rbalance, + alvium->max_rbalance, + alvium->inc_rbalance, + alvium->dft_rbalance); + }else { +/* set to NULL for v4l2_ctrl_auto_cluster if not existing */ + ctrls->blue_balance =NULL ; + ctrls->red_balance =NULL ; + } +/* Auto/manual white balance */ if (alvium->avail_ft.auto_whiteb) { ctrls->auto_wb =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_AUTO_WHITE_BALANCE ,0 ,1 ,1 ,1 ); -v4l2_ctrl_auto_cluster (3 , &ctrls->auto_wb,0 , false); - } - - ctrls->blue_balance =v4l2_ctrl_new_std (hdl, ops, -V4L2_CID_BLUE_BALANCE , - alvium->min_bbalance, - alvium->max_bbalance, - alvium->inc_bbalance, - alvium->dft_bbalance); - ctrls->red_balance =v4l2_ctrl_new_std (hdl, ops, -V4L2_CID_RED_BALANCE , - alvium->min_rbalance, - alvium->max_rbalance, - alvium->inc_rbalance, - alvium->dft_rbalance); + +v4l2_ctrl_auto_cluster (3 , &ctrls->auto_wb,0 , true); + }/* Auto/manual exposure */ if (alvium->avail_ft.auto_exp) {
Signature · 1 line
2.43.0
Hi Martin,
Thanks for the patch.
Quoted 16 lines · Martin Hecht
With that patch the controls for red-balance and blue-balance were created only if the particular camera supports that. Otherwise the pointers on the control variable are initialized with NULL to prevent side effects for clustering with AWB control.
Fixes 0a7af872915e ("media: i2c: Add support for alvium camera")Signed-off-by Martin Hecht <[email protected]>--- drivers/media/i2c/alvium-csi2.c | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-)drivers/media/i2c/alvium-csi2.c +0
-0
drivers/media/i2c/alvium-csi2.c static int alvium_ctrl_init(struct alvium_dev *alvium) · line 2109
Quoted 2 lines
drivers/media/i2c/alvium-csi2.c +0
-0@@ -2108,26 +2108,33 @@ static int alvium_ctrl_init(struct alvium_dev *alvium) 0, 0, &alvium->link_freq); ctrls->link_freq->flags |=V4L2_CTRL_FLAG_READ_ONLY ;
This is a problem. Can you move setting the flags after checking the handler's error status? The functions adding controls may fail and this is simply a missing error check.
Can you submit a fix, with a Fixes: tag and this patch should be rebased on the fix, please?
Quoted 8 lines
drivers/media/i2c/alvium-csi2.c +7
-0+if (alvium->avail_ft.whiteb) { + ctrls->blue_balance =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_BLUE_BALANCE , + alvium->min_bbalance, + alvium->max_bbalance, + alvium->inc_bbalance, + alvium->dft_bbalance);
drivers/media/i2c/alvium-csi2.c static int alvium_ctrl_init(struct alvium_dev *alvium) · line 2127
Quoted 10 lines
drivers/media/i2c/alvium-csi2.c +10
-0+ ctrls->red_balance =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_RED_BALANCE , + alvium->min_rbalance, + alvium->max_rbalance, + alvium->inc_rbalance, + alvium->dft_rbalance); + }else { +/* set to NULL for v4l2_ctrl_auto_cluster if not existing */ + ctrls->blue_balance =NULL ; + ctrls->red_balance =NULL ;
Aren't the two NULL already before this?
Quoted 28 lines
drivers/media/i2c/alvium-csi2.c +5
-15+ } +/* Auto/manual white balance */ if (alvium->avail_ft.auto_whiteb) { ctrls->auto_wb =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_AUTO_WHITE_BALANCE ,0 ,1 ,1 ,1 ); -v4l2_ctrl_auto_cluster (3 , &ctrls->auto_wb,0 , false); - } - - ctrls->blue_balance =v4l2_ctrl_new_std (hdl, ops, -V4L2_CID_BLUE_BALANCE , - alvium->min_bbalance, - alvium->max_bbalance, - alvium->inc_bbalance, - alvium->dft_bbalance); - ctrls->red_balance =v4l2_ctrl_new_std (hdl, ops, -V4L2_CID_RED_BALANCE , - alvium->min_rbalance, - alvium->max_rbalance, - alvium->inc_rbalance, - alvium->dft_rbalance); + +v4l2_ctrl_auto_cluster (3 , &ctrls->auto_wb,0 , true); + }/* Auto/manual exposure */ if (alvium->avail_ft.auto_exp) {
Signature · 3 lines
Kind regards, Sakari Ailus
Martin Hecht
maintainerHi Sakari,
thank you for the comments.
Quoted 28 lines · Sakari Ailus
Hi Martin,
Thanks for the patch.
Quoted 16 lines · Martin Hecht
With that patch the controls for red-balance and blue-balance were created only if the particular camera supports that. Otherwise the pointers on the control variable are initialized with NULL to prevent side effects for clustering with AWB control.
Fixes 0a7af872915e ("media: i2c: Add support for alvium camera")Signed-off-by Martin Hecht <[email protected]>--- drivers/media/i2c/alvium-csi2.c | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-)drivers/media/i2c/alvium-csi2.c +0
-0drivers/media/i2c/alvium-csi2.c static int alvium_ctrl_init(struct alvium_dev *alvium) · line 2109
Quoted 2 lines
drivers/media/i2c/alvium-csi2.c +0
-0@@ -2108,26 +2108,33 @@ static int alvium_ctrl_init(struct alvium_dev *alvium) 0, 0, &alvium->link_freq); ctrls->link_freq->flags |=V4L2_CTRL_FLAG_READ_ONLY ;This is a problem. Can you move setting the flags after checking the handler's error status? The functions adding controls may fail and this is simply a missing error check.
Quoted 2 lines
Can you submit a fix, with a Fixes: tag and this patch should be rebased on the fix, please?
I'm preparing a separate fix for that issue. It's the same situation also for some other controls like pixel_rate and link_frequency but not only. Can I combine that into one patch for fix only that in alvium_ctrl_init?
Quoted 13 lines
Quoted 13 lines
drivers/media/i2c/alvium-csi2.c +11
-0+if (alvium->avail_ft.whiteb) { + ctrls->blue_balance =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_BLUE_BALANCE , + alvium->min_bbalance, + alvium->max_bbalance, + alvium->inc_bbalance, + alvium->dft_bbalance); + ctrls->red_balance = v4l2_ctrl_new_std(hdl, ops, + V4L2_CID_RED_BALANCE, + alvium->min_rbalance, + alvium->max_rbalance,
Quoted 8 lines
drivers/media/i2c/alvium-csi2.c static int alvium_ctrl_init(struct alvium_dev *alvium) · line 2127
Quoted 6 lines
drivers/media/i2c/alvium-csi2.c +6
-0+ alvium->inc_rbalance, + alvium->dft_rbalance); + }else { +/* set to NULL for v4l2_ctrl_auto_cluster if not existing */ + ctrls->blue_balance =NULL ; + ctrls->red_balance =NULL ;Aren't the two NULL already before this?
You are right. It's zeroed before because __GFP_ZERO in devm_kzalloc. Will remove that redundant code.
Quoted 27 lines
Quoted 27 lines
drivers/media/i2c/alvium-csi2.c +5
-15+ } +/* Auto/manual white balance */ if (alvium->avail_ft.auto_whiteb) { ctrls->auto_wb =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_AUTO_WHITE_BALANCE ,0 ,1 ,1 ,1 ); -v4l2_ctrl_auto_cluster (3 , &ctrls->auto_wb,0 , false); - } - - ctrls->blue_balance =v4l2_ctrl_new_std (hdl, ops, -V4L2_CID_BLUE_BALANCE , - alvium->min_bbalance, - alvium->max_bbalance, - alvium->inc_bbalance, - alvium->dft_bbalance); - ctrls->red_balance =v4l2_ctrl_new_std (hdl, ops, -V4L2_CID_RED_BALANCE , - alvium->min_rbalance, - alvium->max_rbalance, - alvium->inc_rbalance, - alvium->dft_rbalance); + +v4l2_ctrl_auto_cluster (3 , &ctrls->auto_wb,0 , true); + }
Quoted 3 lines
drivers/media/i2c/alvium-csi2.c static int alvium_ctrl_init(struct alvium_dev *alvium) · line 2140
Quoted 2 lines
drivers/media/i2c/alvium-csi2.c +0
-0/* Auto/manual exposure */ if (alvium->avail_ft.auto_exp) {
BR Martin
Hi Martin,
Quoted 33 lines · Martin Hecht
Hi Sakari,
thank you for the comments.
Quoted 28 lines · Sakari Ailus
Hi Martin,
Thanks for the patch.
Quoted 16 lines · Martin Hecht
With that patch the controls for red-balance and blue-balance were created only if the particular camera supports that. Otherwise the pointers on the control variable are initialized with NULL to prevent side effects for clustering with AWB control.
Fixes 0a7af872915e ("media: i2c: Add support for alvium camera")Signed-off-by Martin Hecht <[email protected]>--- drivers/media/i2c/alvium-csi2.c | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-)drivers/media/i2c/alvium-csi2.c +0
-0drivers/media/i2c/alvium-csi2.c static int alvium_ctrl_init(struct alvium_dev *alvium) · line 2109
Quoted 2 lines
drivers/media/i2c/alvium-csi2.c +0
-0@@ -2108,26 +2108,33 @@ static int alvium_ctrl_init(struct alvium_dev *alvium) 0, 0, &alvium->link_freq); ctrls->link_freq->flags |=V4L2_CTRL_FLAG_READ_ONLY ;This is a problem. Can you move setting the flags after checking the handler's error status? The functions adding controls may fail and this is simply a missing error check.
Quoted 6 lines
Quoted 2 lines
Can you submit a fix, with a Fixes: tag and this patch should be rebased on the fix, please?
I'm preparing a separate fix for that issue. It's the same situation also for some other controls like
pixel_rateandlink_frequencybut not only. Can I combine that into one patch for fix only that inalvium_ctrl_init?
Please do.
Signature · 3 lines
Regards, Sakari Ailus
Martin Hecht
maintainerHi,
that patch has been superseded by patch [email protected] what addresses more critical issues.
Martin
Quoted 45 lines · Sakari Ailus
Hi Martin,
Quoted 33 lines · Martin Hecht
Hi Sakari,
thank you for the comments.
Quoted 28 lines · Sakari Ailus
Hi Martin,
Thanks for the patch.
Quoted 16 lines · Martin Hecht
With that patch the controls for red-balance and blue-balance were created only if the particular camera supports that. Otherwise the pointers on the control variable are initialized with NULL to prevent side effects for clustering with AWB control.
Fixes 0a7af872915e ("media: i2c: Add support for alvium camera")Signed-off-by Martin Hecht <[email protected]>--- drivers/media/i2c/alvium-csi2.c | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-)drivers/media/i2c/alvium-csi2.c +0
-0drivers/media/i2c/alvium-csi2.c static int alvium_ctrl_init(struct alvium_dev *alvium) · line 2109
Quoted 2 lines
drivers/media/i2c/alvium-csi2.c +0
-0@@ -2108,26 +2108,33 @@ static int alvium_ctrl_init(struct alvium_dev *alvium) 0, 0, &alvium->link_freq); ctrls->link_freq->flags |=V4L2_CTRL_FLAG_READ_ONLY ;This is a problem. Can you move setting the flags after checking the handler's error status? The functions adding controls may fail and this is simply a missing error check.
Quoted 6 lines
Quoted 2 lines
Can you submit a fix, with a Fixes: tag and this patch should be rebased on the fix, please?
I'm preparing a separate fix for that issue. It's the same situation also for some other controls like
pixel_rateandlink_frequencybut not only. Can I combine that into one patch for fix only that inalvium_ctrl_init?Please do.