diff mbox series

[16/21] media: i2c: imx258: Set pixel_rate range to the same as the value

Message ID 20230530173000.3060865-17-dave.stevenson@raspberrypi.com (mailing list archive)
State New, archived
Headers show
Series imx258 improvements series | expand

Commit Message

Dave Stevenson May 30, 2023, 5:29 p.m. UTC
With a read only control there is limited point in advertising
a minimum and maximum for the control, so change to set the
value, min, and max all to the selected pixel rate.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/media/i2c/imx258.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

Comments

Jacopo Mondi June 2, 2023, 1:44 p.m. UTC | #1
On Tue, May 30, 2023 at 06:29:55PM +0100, Dave Stevenson wrote:
> With a read only control there is limited point in advertising
> a minimum and maximum for the control, so change to set the
> value, min, and max all to the selected pixel rate.
>
> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> ---
>  drivers/media/i2c/imx258.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
> index 7d6528f9ca4d..b9b650d40365 100644
> --- a/drivers/media/i2c/imx258.c
> +++ b/drivers/media/i2c/imx258.c
> @@ -1002,7 +1002,8 @@ static int imx258_set_pad_format(struct v4l2_subdev *sd,
>
>  		link_freq = imx258->link_freq_menu_items[mode->link_freq_index];
>  		pixel_rate = link_freq_to_pixel_rate(link_freq, imx258->nlanes);
> -		__v4l2_ctrl_s_ctrl_int64(imx258->pixel_rate, pixel_rate);
> +		__v4l2_ctrl_modify_range(imx258->pixel_rate, pixel_rate,
> +					 pixel_rate, 1, pixel_rate);
>  		/* Update limits and set FPS to default */
>  		vblank_def = imx258->cur_mode->vts_def -
>  			     imx258->cur_mode->height;
> @@ -1328,8 +1329,7 @@ static int imx258_init_controls(struct imx258 *imx258)
>  	struct v4l2_ctrl *vflip, *hflip;
>  	s64 vblank_def;
>  	s64 vblank_min;
> -	s64 pixel_rate_min;
> -	s64 pixel_rate_max;
> +	s64 pixel_rate;
>  	int ret;
>
>  	ctrl_hdlr = &imx258->ctrl_handler;
> @@ -1360,17 +1360,13 @@ static int imx258_init_controls(struct imx258 *imx258)
>  	if (vflip)
>  		vflip->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>
> -	pixel_rate_max =
> -		link_freq_to_pixel_rate(imx258->link_freq_menu_items[0],
> -					imx258->nlanes);
> -	pixel_rate_min =
> -		link_freq_to_pixel_rate(imx258->link_freq_menu_items[1],
> -					imx258->nlanes);
> +	pixel_rate = link_freq_to_pixel_rate(imx258->link_freq_menu_items[0],
> +					     imx258->nlanes);
>  	/* By default, PIXEL_RATE is read only */
>  	imx258->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx258_ctrl_ops,
>  				V4L2_CID_PIXEL_RATE,
> -				pixel_rate_min, pixel_rate_max,
> -				1, pixel_rate_max);
> +				pixel_rate, pixel_rate,
> +				1, pixel_rate);

seems legit!
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

>
>

Is there a double blank line here ? Could you take the occasion and
drop it ?

>  	vblank_def = imx258->cur_mode->vts_def - imx258->cur_mode->height;
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
index 7d6528f9ca4d..b9b650d40365 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -1002,7 +1002,8 @@  static int imx258_set_pad_format(struct v4l2_subdev *sd,
 
 		link_freq = imx258->link_freq_menu_items[mode->link_freq_index];
 		pixel_rate = link_freq_to_pixel_rate(link_freq, imx258->nlanes);
-		__v4l2_ctrl_s_ctrl_int64(imx258->pixel_rate, pixel_rate);
+		__v4l2_ctrl_modify_range(imx258->pixel_rate, pixel_rate,
+					 pixel_rate, 1, pixel_rate);
 		/* Update limits and set FPS to default */
 		vblank_def = imx258->cur_mode->vts_def -
 			     imx258->cur_mode->height;
@@ -1328,8 +1329,7 @@  static int imx258_init_controls(struct imx258 *imx258)
 	struct v4l2_ctrl *vflip, *hflip;
 	s64 vblank_def;
 	s64 vblank_min;
-	s64 pixel_rate_min;
-	s64 pixel_rate_max;
+	s64 pixel_rate;
 	int ret;
 
 	ctrl_hdlr = &imx258->ctrl_handler;
@@ -1360,17 +1360,13 @@  static int imx258_init_controls(struct imx258 *imx258)
 	if (vflip)
 		vflip->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
-	pixel_rate_max =
-		link_freq_to_pixel_rate(imx258->link_freq_menu_items[0],
-					imx258->nlanes);
-	pixel_rate_min =
-		link_freq_to_pixel_rate(imx258->link_freq_menu_items[1],
-					imx258->nlanes);
+	pixel_rate = link_freq_to_pixel_rate(imx258->link_freq_menu_items[0],
+					     imx258->nlanes);
 	/* By default, PIXEL_RATE is read only */
 	imx258->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx258_ctrl_ops,
 				V4L2_CID_PIXEL_RATE,
-				pixel_rate_min, pixel_rate_max,
-				1, pixel_rate_max);
+				pixel_rate, pixel_rate,
+				1, pixel_rate);
 
 
 	vblank_def = imx258->cur_mode->vts_def - imx258->cur_mode->height;