media: i2c: alvium: remove the fr field of the alvium_dev structure

The fr (frame rate) field of the alvium_dev structure is
only used to pass result from alvium_set_frame_interval() to
alvium_set_frame_rate() that writes this info into the hw reg.
Replace it with a function parameter.

Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Tommaso Merciai 2023-12-20 13:40:20 +01:00 committed by Hans Verkuil
parent b5c5a02b3d
commit d7f686d8c5
2 changed files with 12 additions and 13 deletions

View File

@ -1185,19 +1185,19 @@ static int alvium_get_frame_interval(struct alvium_dev *alvium,
return ret;
}
static int alvium_set_frame_rate(struct alvium_dev *alvium)
static int alvium_set_frame_rate(struct alvium_dev *alvium, u64 fr)
{
struct device *dev = &alvium->i2c_client->dev;
int ret;
ret = alvium_write_hshake(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW,
alvium->fr);
fr);
if (ret) {
dev_err(dev, "Fail to set frame rate lanes reg\n");
return ret;
}
dev_dbg(dev, "set frame rate: %llu us\n", alvium->fr);
dev_dbg(dev, "set frame rate: %llu us\n", fr);
return 0;
}
@ -1661,10 +1661,11 @@ static int alvium_g_frame_interval(struct v4l2_subdev *sd,
}
static int alvium_set_frame_interval(struct alvium_dev *alvium,
struct v4l2_subdev_frame_interval *fi)
struct v4l2_subdev_frame_interval *fi,
u64 *req_fr)
{
struct device *dev = &alvium->i2c_client->dev;
u64 req_fr, dft_fr, min_fr, max_fr;
u64 dft_fr, min_fr, max_fr;
int ret;
if (fi->interval.denominator == 0)
@ -1681,13 +1682,12 @@ static int alvium_set_frame_interval(struct alvium_dev *alvium,
dev_dbg(dev, "fi->interval.denominator = %d\n",
fi->interval.denominator);
req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) /
*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;
if (*req_fr >= max_fr && *req_fr <= min_fr)
*req_fr = dft_fr;
alvium->fr = req_fr;
alvium->frame_interval.numerator = fi->interval.numerator;
alvium->frame_interval.denominator = fi->interval.denominator;
@ -1699,6 +1699,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_frame_interval *fi)
{
struct alvium_dev *alvium = sd_to_alvium(sd);
u64 req_fr;
int ret;
/*
@ -1711,9 +1712,9 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd,
if (alvium->streaming)
return -EBUSY;
ret = alvium_set_frame_interval(alvium, fi);
ret = alvium_set_frame_interval(alvium, fi, &req_fr);
if (!ret)
ret = alvium_set_frame_rate(alvium);
ret = alvium_set_frame_rate(alvium, req_fr);
return ret;
}
@ -2273,7 +2274,6 @@ static int alvium_subdev_init(struct alvium_dev *alvium)
/* Setup initial frame interval*/
alvium->frame_interval.numerator = 1;
alvium->frame_interval.denominator = ALVIUM_DEFAULT_FR_HZ;
alvium->fr = ALVIUM_DEFAULT_FR_HZ;
/* Setup the initial mode */
alvium->mode.fmt = alvium_csi2_default_fmt;

View File

@ -443,7 +443,6 @@ struct alvium_dev {
struct alvium_mode mode;
struct v4l2_fract frame_interval;
u64 fr;
u8 h_sup_csi_lanes;
u64 link_freq;