From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Tomasz Figa <tfiga@chromium.org>
Cc: "Chen, Jason Z" <jason.z.chen@intel.com>,
bingbu.cao@linux.intel.com, linux-media@vger.kernel.org,
andy.yeh@intel.com, qingwu.zhang@intel.com,
senozhatsky@chromium.org
Subject: Re: [PATCH v3] media: ov08x40: Reduce start streaming time
Date: Tue, 23 Jan 2024 10:16:19 +0000 [thread overview]
Message-ID: <Za-R8xeuD5cHCA0K@kekkonen.localdomain> (raw)
In-Reply-To: <CAAFQd5D6y8nKg8axJxZj+yhMD8ZNC=q6w_e2=7qcQo1HFWSFTw@mail.gmail.com>
Hi Tomasz,
On Tue, Jan 23, 2024 at 07:03:49PM +0900, Tomasz Figa wrote:
> On Tue, Jan 23, 2024 at 6:37 PM Chen, Jason Z <jason.z.chen@intel.com> wrote:
> >
> > From: Jason Chen <jason.z.chen@intel.com>
> >
> > Because video duration involves calculating the streaming time, and i2c
> > communication incurs too many XTALK register settings every 4 bytes with
> > i2c START and STOP.
> >
> > So we have opted switch to the i2c burst method.
> > This method involves writing the XTALK registers in the order of
> > the register block.
> >
> > The start streaming time can be reduced from around 400ms to 150ms
> >
> > Signed-off-by: Jason Chen <jason.z.chen@intel.com>
> > ---
> > drivers/media/i2c/ov08x40.c | 1207 ++---------------------------------
> > 1 file changed, 55 insertions(+), 1152 deletions(-)
> >
> > diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
> > index ddcb4b6848b..7b09f405fc5 100644
> > --- a/drivers/media/i2c/ov08x40.c
> > +++ b/drivers/media/i2c/ov08x40.c
> [snip]
> > +static int ov08x40_burst_fill_regs(struct ov08x40 *ov08x, u16 first_reg,
> > + u16 last_reg, u8 val)
> > +{
> > + struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd);
> > + struct i2c_msg msgs;
> > + __be16 reg_addr_be = cpu_to_be16(first_reg);
> > + size_t i, num_regs;
> > + int ret;
> > +
> > + num_regs = last_reg - first_reg + 1;
> > + msgs.addr = client->addr;
> > + msgs.flags = 0;
> > + msgs.len = 2 + num_regs;
> > + msgs.buf = kmalloc(msgs.len, GFP_KERNEL);
> > + if (!msgs.buf)
> > + return -ENOMEM;
> > +
> > + /* Set the register address to the first two bytes of the buffer */
> > + memcpy(msgs.buf, ®_addr_be, 2);
>
> nit: Wouldn't the code be much simpler to follow if rewritten as below?
>
> msgs.buf[0] = first_reg >> 8;
> msgs.buf[1] = first_reg & 0xff;
Or... just put_unaligned_be16()?
>
> > + for (i = 0; i < num_regs; ++i)
> > + msgs.buf[2 + i] = val;
> > +
> > + ret = i2c_transfer(client->adapter, &msgs, 1);
> > +
> > + kfree(msgs.buf);
> > +
> > + if (ret != 1) {
> > + dev_err(&client->dev, "Failed %d regs transferred: %d\n", ret);
> > + return -EIO;
> > + }
> > +
> > + dev_dbg(&client->dev, "I2C burst transfer succeeded\n");
> > +
> > + return 0;
> > +}
> > +
> > /* Write registers up to 4 at a time */
> > static int ov08x40_write_reg(struct ov08x40 *ov08x,
> > u16 reg, u32 len, u32 __val)
> > @@ -2936,6 +1826,19 @@ static int ov08x40_start_streaming(struct ov08x40 *ov08x)
> > return ret;
> > }
> >
> > + /* Use i2c burst to write register on full size registers */
> > + if (ov08x->cur_mode->exposure_shift == 1) {
> > + ret = ov08x40_burst_fill_regs(ov08x, OV08X40_REG_XTALK_FIRST_A,
> > + OV08X40_REG_XTALK_LAST_A, 0x75);
> > + ret = ov08x40_burst_fill_regs(ov08x, OV08X40_REG_XTALK_FIRST_B,
> > + OV08X40_REG_XTALK_LAST_B, 0x75);
> > + }
>
> Hmm, if we only need to set these if exposure_shift is 1, don't we
> need to somehow "unset" them if the mode exposure_shift != 1?
I recall the driver powers the sensor off every time streaming is stopped
(without pm_runtime_put_sync(), so it's not reliable)... that would be nice
to address as well, but outside the scope of this patch.
--
Regards,
Sakari Ailus
next prev parent reply other threads:[~2024-01-23 10:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 9:36 [PATCH v3] media: ov08x40: Reduce start streaming time Chen, Jason Z
2024-01-23 10:03 ` Tomasz Figa
2024-01-23 10:16 ` Sakari Ailus [this message]
2024-01-23 14:48 ` Chen, Jason Z
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=Za-R8xeuD5cHCA0K@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=andy.yeh@intel.com \
--cc=bingbu.cao@linux.intel.com \
--cc=jason.z.chen@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=qingwu.zhang@intel.com \
--cc=senozhatsky@chromium.org \
--cc=tfiga@chromium.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox