diff options
author | Tommaso Merciai <tomm.merciai@gmail.com> | 2023-12-20 13:40:23 +0100 |
---|---|---|
committer | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2024-02-23 14:33:32 +0100 |
commit | 188d2ff3342bdeea471d0d2f5599ef0fea7de5e2 (patch) | |
tree | e584da9130d586976dc0b107ba3cd948ce9f2695 /drivers/media | |
parent | media: i2c: alvium: store frame interval in subdev state (diff) | |
download | linux-188d2ff3342bdeea471d0d2f5599ef0fea7de5e2.tar.xz linux-188d2ff3342bdeea471d0d2f5599ef0fea7de5e2.zip |
media: i2c: alvium: fix req_fr check in alvium_s_frame_interval()
req_fr check in alvium_s_frame_interval() is incorrect. In particular
req_fr can't be >=max and <= min at the same time. Ensure the requested
frame rate remains within the supported range between min_fr and max_fr by
clamping it.
Also remove the unused dft_fr argument of alvium_get_frame_interval().
Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/i2c/alvium-csi2.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c index 1d85de53b62d..e65702e3f73e 100644 --- a/drivers/media/i2c/alvium-csi2.c +++ b/drivers/media/i2c/alvium-csi2.c @@ -1171,12 +1171,10 @@ static int alvium_set_bayer_pattern(struct alvium_dev *alvium, } static int alvium_get_frame_interval(struct alvium_dev *alvium, - u64 *dft_fr, u64 *min_fr, u64 *max_fr) + u64 *min_fr, u64 *max_fr) { int ret = 0; - alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW, - dft_fr, &ret); alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MIN_R, min_fr, &ret); alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MAX_R, @@ -1647,7 +1645,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, { struct alvium_dev *alvium = sd_to_alvium(sd); struct device *dev = &alvium->i2c_client->dev; - u64 req_fr, dft_fr, min_fr, max_fr; + u64 req_fr, min_fr, max_fr; struct v4l2_fract *interval; int ret; @@ -1657,7 +1655,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, if (fi->interval.denominator == 0) return -EINVAL; - ret = alvium_get_frame_interval(alvium, &dft_fr, &min_fr, &max_fr); + ret = alvium_get_frame_interval(alvium, &min_fr, &max_fr); if (ret) { dev_err(dev, "Fail to get frame interval\n"); return ret; @@ -1670,9 +1668,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) / fi->interval.numerator); - - if (req_fr >= max_fr && req_fr <= min_fr) - req_fr = dft_fr; + req_fr = clamp(req_fr, min_fr, max_fr); interval = v4l2_subdev_state_get_interval(sd_state, 0); |