From: Hao Yao <hao.yao@intel.com>
To: Hans de Goede <hdegoede@redhat.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Arec Kao <arec.kao@intel.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>
Cc: <linux-media@vger.kernel.org>, Bingbu Cao <bingbu.cao@intel.com>
Subject: Re: [PATCH v2 1/2] media: i2c: ov13b10: Fix h_blank calculation
Date: Tue, 11 Mar 2025 22:20:36 +0800 [thread overview]
Message-ID: <8580b975-42f1-440f-9f27-aa1c2229a530@intel.com> (raw)
In-Reply-To: <70b8c4d4-09c4-4818-ab59-0ea8867157db@redhat.com>
Hi Hans,
On 2025/3/11 18:20, Hans de Goede wrote:
> Hi Hao,
>
> On 11-Mar-25 9:46 AM, Hao Yao wrote:
>> Pixel per line (PPL) is calculated as pixel_rate / (VTS * FPS), which
>> is not decided by MIPI CSI-2 link frequency. PPL can vary while link
>> frequency keeps the same. If PPL is wrong, the h_blank = PPL - width
>> is also wrong then FPS control is inaccurate.
>>
>> This patch fix h_blank by:
>> 1. Move PPL from link_freq_config to ov13b10_mode
>> 2. Add PPL value for different modes
>> 3. Use PPL from mode to calculate h_blank
>>
>> Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
>> Signed-off-by: Hao Yao <hao.yao@intel.com>
>> ---
>> drivers/media/i2c/ov13b10.c | 36 ++++++++++++++++++------------------
>> 1 file changed, 18 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/media/i2c/ov13b10.c b/drivers/media/i2c/ov13b10.c
>> index 73c844aa5697..2e83fc23f321 100644
>> --- a/drivers/media/i2c/ov13b10.c
>> +++ b/drivers/media/i2c/ov13b10.c
>> @@ -34,9 +34,6 @@
>> #define OV13B10_VTS_120FPS 0x0320
>> #define OV13B10_VTS_MAX 0x7fff
>>
>> -/* HBLANK control - read only */
>> -#define OV13B10_PPL_560MHZ 4704
>> -
>> /* Exposure control */
>> #define OV13B10_REG_EXPOSURE 0x3500
>> #define OV13B10_EXPOSURE_MIN 4
>> @@ -95,7 +92,7 @@ struct ov13b10_reg_list {
>>
>> /* Link frequency config */
>> struct ov13b10_link_freq_config {
>> - u32 pixels_per_line;
>> + u64 link_freq;
>>
>> /* registers for this link frequency */
>> struct ov13b10_reg_list reg_list;
>> @@ -114,6 +111,10 @@ struct ov13b10_mode {
>>
>> /* Index of Link frequency config to be used */
>> u32 link_freq_index;
>> +
>> + /* Pixels per line in current mode */
>> + u32 ppl;
>> +
>> /* Default register values */
>> struct ov13b10_reg_list reg_list;
>> };
>> @@ -549,7 +550,7 @@ static const s64 link_freq_menu_items[] = {
>> static const struct ov13b10_link_freq_config
>> link_freq_configs[] = {
>> {
>> - .pixels_per_line = OV13B10_PPL_560MHZ,
>> + .link_freq = OV13B10_LINK_FREQ_560MHZ,
>> .reg_list = {
>> .num_of_regs = ARRAY_SIZE(mipi_data_rate_1120mbps),
>> .regs = mipi_data_rate_1120mbps,
>> @@ -564,6 +565,7 @@ static const struct ov13b10_mode supported_modes[] = {
>> .height = 3120,
>> .vts_def = OV13B10_VTS_30FPS,
>> .vts_min = OV13B10_VTS_30FPS,
>> + .ppl = 4704,
>> .reg_list = {
>> .num_of_regs = ARRAY_SIZE(mode_4208x3120_regs),
>> .regs = mode_4208x3120_regs,
>> @@ -575,6 +577,7 @@ static const struct ov13b10_mode supported_modes[] = {
>> .height = 3120,
>> .vts_def = OV13B10_VTS_30FPS,
>> .vts_min = OV13B10_VTS_30FPS,
>> + .ppl = 4704,
>> .reg_list = {
>> .num_of_regs = ARRAY_SIZE(mode_4160x3120_regs),
>> .regs = mode_4160x3120_regs,
>> @@ -586,6 +589,7 @@ static const struct ov13b10_mode supported_modes[] = {
>> .height = 2340,
>> .vts_def = OV13B10_VTS_30FPS,
>> .vts_min = OV13B10_VTS_30FPS,
>> + .ppl = 4704,
>> .reg_list = {
>> .num_of_regs = ARRAY_SIZE(mode_4160x2340_regs),
>> .regs = mode_4160x2340_regs,
>> @@ -597,6 +601,7 @@ static const struct ov13b10_mode supported_modes[] = {
>> .height = 1560,
>> .vts_def = OV13B10_VTS_60FPS,
>> .vts_min = OV13B10_VTS_60FPS,
>> + .ppl = 4704,
>> .reg_list = {
>> .num_of_regs = ARRAY_SIZE(mode_2104x1560_regs),
>> .regs = mode_2104x1560_regs,
>> @@ -608,6 +613,7 @@ static const struct ov13b10_mode supported_modes[] = {
>> .height = 1170,
>> .vts_def = OV13B10_VTS_60FPS,
>> .vts_min = OV13B10_VTS_60FPS,
>> + .ppl = 4704,
>> .reg_list = {
>> .num_of_regs = ARRAY_SIZE(mode_2080x1170_regs),
>> .regs = mode_2080x1170_regs,
>> @@ -620,6 +626,7 @@ static const struct ov13b10_mode supported_modes[] = {
>> .vts_def = OV13B10_VTS_120FPS,
>> .vts_min = OV13B10_VTS_120FPS,
>> .link_freq_index = OV13B10_LINK_FREQ_INDEX_0,
>> + .ppl = 4664,
>> .reg_list = {
>> .num_of_regs = ARRAY_SIZE(mode_1364x768_120fps_regs),
>> .regs = mode_1364x768_120fps_regs,
>> @@ -1062,19 +1069,13 @@ ov13b10_set_pad_format(struct v4l2_subdev *sd,
>> __v4l2_ctrl_s_ctrl_int64(ov13b->pixel_rate, pixel_rate);
>>
>> /* Update limits and set FPS to default */
>> - vblank_def = ov13b->cur_mode->vts_def -
>> - ov13b->cur_mode->height;
>> - vblank_min = ov13b->cur_mode->vts_min -
>> - ov13b->cur_mode->height;
>> + vblank_def = mode->vts_def - mode->height;
>> + vblank_min = mode->vts_min - mode->height;
>> __v4l2_ctrl_modify_range(ov13b->vblank, vblank_min,
>> - OV13B10_VTS_MAX
>> - - ov13b->cur_mode->height,
>> - 1,
>> - vblank_def);
>> + OV13B10_VTS_MAX - mode->height,
>> + 1, vblank_def);
>> __v4l2_ctrl_s_ctrl(ov13b->vblank, vblank_def);
>> - h_blank =
>> - link_freq_configs[mode->link_freq_index].pixels_per_line
>> - - ov13b->cur_mode->width;
>> + h_blank = mode->ppl - mode->width;
>> __v4l2_ctrl_modify_range(ov13b->hblank, h_blank,
>> h_blank, 1, h_blank);
>> }
>
> You are doing a bunch of unrelated search 'ov13b->cur_mode->' replace
> with 'mode->' here e.g. for vblank_def and vblank_min. While this is
> a good change to have which increases readability, this is unrelated
> to the hblank changes, so please split this out into a new patch 1/3
> as preparation for the further changes in the series.
>
> Mixing those changes into this patch makes it hard for reviewers to
> see which changes you are actually making wrt h_blank handling.
>
> Regards,
>
> Hans
>
Sorry for that - let me fix it in next version. This patchset was mainly
for the 2 lane setting of ov13b, and the style change is not necessary.
Best Regards,
Hao Yao
>
>> @@ -1328,8 +1329,7 @@ static int ov13b10_init_controls(struct ov13b10 *ov13b)
>> OV13B10_VTS_MAX - mode->height, 1,
>> vblank_def);
>>
>> - hblank = link_freq_configs[mode->link_freq_index].pixels_per_line -
>> - mode->width;
>> + hblank = mode->ppl - mode->width;
>> ov13b->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov13b10_ctrl_ops,
>> V4L2_CID_HBLANK,
>> hblank, hblank, 1, hblank);
>
next prev parent reply other threads:[~2025-03-11 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 8:46 [PATCH v2 1/2] media: i2c: ov13b10: Fix h_blank calculation Hao Yao
2025-03-11 8:46 ` [PATCH v2 2/2] media: i2c: ov13b10: Support 2 lane mode Hao Yao
2025-03-11 10:20 ` [PATCH v2 1/2] media: i2c: ov13b10: Fix h_blank calculation Hans de Goede
2025-03-11 14:20 ` Hao Yao [this message]
2025-03-11 10:20 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8580b975-42f1-440f-9f27-aa1c2229a530@intel.com \
--to=hao.yao@intel.com \
--cc=arec.kao@intel.com \
--cc=bingbu.cao@intel.com \
--cc=hdegoede@redhat.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.