media: ov2740: Fix hts value

HTS must be more then width, so the 1080 value clearly is wrong,
this is then corrected with some weird math dividing clocks in
to_pixels_per_line() which results in the hts getting multiplied by 2,
resulting in 2160.

Instead just directly set hts to the correct value of 2160 and
drop to_pixels_per_line().

Signed-off-by: Hans de Goede <hdegoede@redhat.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:
Hans de Goede 2023-12-04 13:39:42 +01:00 committed by Hans Verkuil
parent 41543c7ccc
commit 3735228bbe

View file

@ -312,7 +312,7 @@ static const struct ov2740_mode supported_modes[] = {
{
.width = 1932,
.height = 1092,
.hts = 1080,
.hts = 2160,
.vts_def = OV2740_VTS_DEF,
.vts_min = OV2740_VTS_MIN,
.reg_list = {
@ -363,15 +363,6 @@ static u64 to_pixel_rate(u32 f_index)
return pixel_rate;
}
static u64 to_pixels_per_line(u32 hts, u32 f_index)
{
u64 ppl = hts * to_pixel_rate(f_index);
do_div(ppl, OV2740_SCLK);
return ppl;
}
static int ov2740_read_reg(struct ov2740 *ov2740, u16 reg, u16 len, u32 *val)
{
struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
@ -604,8 +595,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
V4L2_CID_VBLANK, vblank_min,
vblank_max, 1, vblank_default);
h_blank = to_pixels_per_line(cur_mode->hts, cur_mode->link_freq_index);
h_blank -= cur_mode->width;
h_blank = cur_mode->hts - cur_mode->width;
ov2740->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops,
V4L2_CID_HBLANK, h_blank, h_blank, 1,
h_blank);
@ -848,8 +838,7 @@ static int ov2740_set_format(struct v4l2_subdev *sd,
mode->vts_min - mode->height,
OV2740_VTS_MAX - mode->height, 1, vblank_def);
__v4l2_ctrl_s_ctrl(ov2740->vblank, vblank_def);
h_blank = to_pixels_per_line(mode->hts, mode->link_freq_index) -
mode->width;
h_blank = mode->hts - mode->width;
__v4l2_ctrl_modify_range(ov2740->hblank, h_blank, h_blank, 1, h_blank);
return 0;