mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 06:55:13 +08:00
media: i2c: alvium: store frame interval in subdev state
Use the newly added storage for frame interval in the subdev state to simplify the driver. 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:
parent
d0d487582f
commit
d95d9c2c93
@ -1641,25 +1641,6 @@ static int alvium_hw_init(struct alvium_dev *alvium)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------- Subdev Operations --------------- */
|
/* --------------- Subdev Operations --------------- */
|
||||||
|
|
||||||
static int alvium_g_frame_interval(struct v4l2_subdev *sd,
|
|
||||||
struct v4l2_subdev_state *sd_state,
|
|
||||||
struct v4l2_subdev_frame_interval *fi)
|
|
||||||
{
|
|
||||||
struct alvium_dev *alvium = sd_to_alvium(sd);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
|
|
||||||
* subdev active state API.
|
|
||||||
*/
|
|
||||||
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
fi->interval = alvium->frame_interval;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int alvium_s_frame_interval(struct v4l2_subdev *sd,
|
static int alvium_s_frame_interval(struct v4l2_subdev *sd,
|
||||||
struct v4l2_subdev_state *sd_state,
|
struct v4l2_subdev_state *sd_state,
|
||||||
struct v4l2_subdev_frame_interval *fi)
|
struct v4l2_subdev_frame_interval *fi)
|
||||||
@ -1667,15 +1648,9 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd,
|
|||||||
struct alvium_dev *alvium = sd_to_alvium(sd);
|
struct alvium_dev *alvium = sd_to_alvium(sd);
|
||||||
struct device *dev = &alvium->i2c_client->dev;
|
struct device *dev = &alvium->i2c_client->dev;
|
||||||
u64 req_fr, dft_fr, min_fr, max_fr;
|
u64 req_fr, dft_fr, min_fr, max_fr;
|
||||||
|
struct v4l2_fract *interval;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
|
|
||||||
* subdev active state API.
|
|
||||||
*/
|
|
||||||
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (alvium->streaming)
|
if (alvium->streaming)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
@ -1699,8 +1674,13 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd,
|
|||||||
if (req_fr >= max_fr && req_fr <= min_fr)
|
if (req_fr >= max_fr && req_fr <= min_fr)
|
||||||
req_fr = dft_fr;
|
req_fr = dft_fr;
|
||||||
|
|
||||||
alvium->frame_interval.numerator = fi->interval.numerator;
|
interval = v4l2_subdev_state_get_interval(sd_state, 0);
|
||||||
alvium->frame_interval.denominator = fi->interval.denominator;
|
|
||||||
|
interval->numerator = fi->interval.numerator;
|
||||||
|
interval->denominator = fi->interval.denominator;
|
||||||
|
|
||||||
|
if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return alvium_set_frame_rate(alvium, req_fr);
|
return alvium_set_frame_rate(alvium, req_fr);
|
||||||
}
|
}
|
||||||
@ -1850,6 +1830,7 @@ static int alvium_init_state(struct v4l2_subdev *sd,
|
|||||||
{
|
{
|
||||||
struct alvium_dev *alvium = sd_to_alvium(sd);
|
struct alvium_dev *alvium = sd_to_alvium(sd);
|
||||||
struct alvium_mode *mode = &alvium->mode;
|
struct alvium_mode *mode = &alvium->mode;
|
||||||
|
struct v4l2_fract *interval;
|
||||||
struct v4l2_subdev_format sd_fmt = {
|
struct v4l2_subdev_format sd_fmt = {
|
||||||
.which = V4L2_SUBDEV_FORMAT_TRY,
|
.which = V4L2_SUBDEV_FORMAT_TRY,
|
||||||
.format = alvium_csi2_default_fmt,
|
.format = alvium_csi2_default_fmt,
|
||||||
@ -1867,6 +1848,11 @@ static int alvium_init_state(struct v4l2_subdev *sd,
|
|||||||
*v4l2_subdev_state_get_crop(state, 0) = sd_crop.rect;
|
*v4l2_subdev_state_get_crop(state, 0) = sd_crop.rect;
|
||||||
*v4l2_subdev_state_get_format(state, 0) = sd_fmt.format;
|
*v4l2_subdev_state_get_format(state, 0) = sd_fmt.format;
|
||||||
|
|
||||||
|
/* Setup initial frame interval*/
|
||||||
|
interval = v4l2_subdev_state_get_interval(state, 0);
|
||||||
|
interval->numerator = 1;
|
||||||
|
interval->denominator = ALVIUM_DEFAULT_FR_HZ;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2236,7 +2222,7 @@ static const struct v4l2_subdev_pad_ops alvium_pad_ops = {
|
|||||||
.set_fmt = alvium_set_fmt,
|
.set_fmt = alvium_set_fmt,
|
||||||
.get_selection = alvium_get_selection,
|
.get_selection = alvium_get_selection,
|
||||||
.set_selection = alvium_set_selection,
|
.set_selection = alvium_set_selection,
|
||||||
.get_frame_interval = alvium_g_frame_interval,
|
.get_frame_interval = v4l2_subdev_get_frame_interval,
|
||||||
.set_frame_interval = alvium_s_frame_interval,
|
.set_frame_interval = alvium_s_frame_interval,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2257,10 +2243,6 @@ static int alvium_subdev_init(struct alvium_dev *alvium)
|
|||||||
struct v4l2_subdev *sd = &alvium->sd;
|
struct v4l2_subdev *sd = &alvium->sd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Setup initial frame interval*/
|
|
||||||
alvium->frame_interval.numerator = 1;
|
|
||||||
alvium->frame_interval.denominator = ALVIUM_DEFAULT_FR_HZ;
|
|
||||||
|
|
||||||
/* Setup the initial mode */
|
/* Setup the initial mode */
|
||||||
alvium->mode.fmt = alvium_csi2_default_fmt;
|
alvium->mode.fmt = alvium_csi2_default_fmt;
|
||||||
alvium->mode.width = alvium_csi2_default_fmt.width;
|
alvium->mode.width = alvium_csi2_default_fmt.width;
|
||||||
|
@ -442,7 +442,6 @@ struct alvium_dev {
|
|||||||
s32 inc_sharp;
|
s32 inc_sharp;
|
||||||
|
|
||||||
struct alvium_mode mode;
|
struct alvium_mode mode;
|
||||||
struct v4l2_fract frame_interval;
|
|
||||||
|
|
||||||
u8 h_sup_csi_lanes;
|
u8 h_sup_csi_lanes;
|
||||||
u64 link_freq;
|
u64 link_freq;
|
||||||
|
Loading…
Reference in New Issue
Block a user