All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tarang Raval <tarang.raval@siliconsignals.io>
Cc: Xiaolei Wang <xiaolei.wang@windriver.com>,
	"sakari.ailus@linux.intel.com" <sakari.ailus@linux.intel.com>,
	"dave.stevenson@raspberrypi.com" <dave.stevenson@raspberrypi.com>,
	"jacopo@jmondi.org" <jacopo@jmondi.org>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"prabhakar.mahadev-lad.rj@bp.renesas.com"
	<prabhakar.mahadev-lad.rj@bp.renesas.com>,
	"hverkuil+cisco@kernel.org" <hverkuil+cisco@kernel.org>,
	"johannes.goede@oss.qualcomm.com"
	<johannes.goede@oss.qualcomm.com>,
	"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
	"jai.luthra@ideasonboard.com" <jai.luthra@ideasonboard.com>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] media: i2c: ov5647: Convert to CCI register access helpers
Date: Mon, 29 Dec 2025 15:01:16 +0200	[thread overview]
Message-ID: <20251229130116.GC6598@pendragon.ideasonboard.com> (raw)
In-Reply-To: <PN3P287MB18291169FABF1E8A01AA88B88BBFA@PN3P287MB1829.INDP287.PROD.OUTLOOK.COM>

On Mon, Dec 29, 2025 at 12:37:41PM +0000, Tarang Raval wrote:
> > Use the new common CCI register access helpers to replace the private
> > register access helpers in the ov5647 driver. This simplifies the driver
> > by reducing the amount of code.
> > 
> > Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> > ---
> >  drivers/media/i2c/Kconfig  |   1 +
> >  drivers/media/i2c/ov5647.c | 997 +++++++++++++++++--------------------
> >  2 files changed, 453 insertions(+), 545 deletions(-)
> > 
> > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> > index 4b4db8c4f496..cce63349e71e 100644
> > --- a/drivers/media/i2c/Kconfig
> > +++ b/drivers/media/i2c/Kconfig
> > @@ -529,6 +529,7 @@ config VIDEO_OV5645
> > 
> >  config VIDEO_OV5647
> >         tristate "OmniVision OV5647 sensor support"
> > +       select V4L2_CCI_I2C
> >         help
> >           This is a Video4Linux2 sensor driver for the OmniVision
> >           OV5647 camera.
> > diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
> > index e193fef4fced..fd69f1616794 100644
> > --- a/drivers/media/i2c/ov5647.c
> > +++ b/drivers/media/i2c/ov5647.c
> > @@ -22,6 +22,7 @@
> >  #include <linux/pm_runtime.h>
> >  #include <linux/slab.h>
> >  #include <linux/videodev2.h>
> > +#include <media/v4l2-cci.h>
> >  #include <media/v4l2-ctrls.h>
> >  #include <media/v4l2-device.h>
> >  #include <media/v4l2-event.h>
> > @@ -41,24 +42,19 @@
> >  #define MIPI_CTRL00_BUS_IDLE                   BIT(2)
> >  #define MIPI_CTRL00_CLOCK_LANE_DISABLE         BIT(0)
> > 
> > -#define OV5647_SW_STANDBY              0x0100
> > -#define OV5647_SW_RESET                        0x0103
> > -#define OV5647_REG_CHIPID_H            0x300a
> > -#define OV5647_REG_CHIPID_L            0x300b
> > -#define OV5640_REG_PAD_OUT             0x300d
> > -#define OV5647_REG_EXP_HI              0x3500
> > -#define OV5647_REG_EXP_MID             0x3501
> > -#define OV5647_REG_EXP_LO              0x3502
> > -#define OV5647_REG_AEC_AGC             0x3503
> > -#define OV5647_REG_GAIN_HI             0x350a
> > -#define OV5647_REG_GAIN_LO             0x350b
> > -#define OV5647_REG_VTS_HI              0x380e
> > -#define OV5647_REG_VTS_LO              0x380f
> > -#define OV5647_REG_FRAME_OFF_NUMBER    0x4202
> > -#define OV5647_REG_MIPI_CTRL00         0x4800
> > -#define OV5647_REG_MIPI_CTRL14         0x4814
> > -#define OV5647_REG_AWB                 0x5001
> > -#define OV5647_REG_ISPCTRL3D           0x503d
> > +#define OV5647_SW_STANDBY              CCI_REG8(0x0100)
> > +#define OV5647_SW_RESET                        CCI_REG8(0x0103)
> > +#define OV5647_REG_CHIPID              CCI_REG16(0x300a)
> > +#define OV5640_REG_PAD_OUT             CCI_REG8(0x300d)
> > +#define OV5647_REG_EXPOSURE            CCI_REG24(0x3500)
> > +#define OV5647_REG_AEC_AGC             CCI_REG8(0x3503)
> > +#define OV5647_REG_GAIN                        CCI_REG16(0x350b)
> 
> It should be 0x350a, not 0x350b.
> 
> > +#define OV5647_REG_VTS                 CCI_REG16(0x380e)
> > +#define OV5647_REG_FRAME_OFF_NUMBER    CCI_REG8(0x4202)
> > +#define OV5647_REG_MIPI_CTRL00         CCI_REG8(0x4800)
> > +#define OV5647_REG_MIPI_CTRL14         CCI_REG8(0x4814)
> > +#define OV5647_REG_AWB                 CCI_REG8(0x5001)
> > +#define OV5647_REG_ISPCTRL3D           CCI_REG8(0x503d)
> > 
> >  #define REG_TERM 0xfffe
> >  #define VAL_TERM 0xfe
> > @@ -81,23 +77,19 @@
> >  #define OV5647_EXPOSURE_DEFAULT                1000
> >  #define OV5647_EXPOSURE_MAX            65535
>  
> ...
> 
> > @@ -1435,6 +1335,13 @@ static int ov5647_probe(struct i2c_client *client)
> >         if (ret < 0)
> >                 goto ctrl_handler_free;
> > 
> > +       sensor->regmap = devm_cci_regmap_init_i2c(client, 16);
> > +       if (IS_ERR(sensor->regmap)) {
> > +               ret = PTR_ERR(sensor->regmap);
> > +               dev_err(dev, "failed to initialize CCI: %d\n", ret);
> 
> Use return dev_err_probe();

dev_err_probe() is fine, but goto entity_cleanup is needed.

> > +               goto entity_cleanup;
> > +       }
> > +
> >         ret = ov5647_power_on(dev);
> >         if (ret)
> >                 goto entity_cleanup;

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2025-12-29 13:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-29  2:30 [PATCH v2 0/3] media: i2c: ov5647: Modernize driver with CCI and new stream APIs Xiaolei Wang
2025-12-29  2:30 ` [PATCH v2 1/3] media: i2c: ov5647: Convert to CCI register access helpers Xiaolei Wang
2025-12-29 12:37   ` Tarang Raval
2025-12-29 13:01     ` Laurent Pinchart [this message]
2025-12-29 13:26       ` Tarang Raval
2025-12-31  2:57       ` xiaolei wang
2025-12-29 13:26   ` johannes.goede
2025-12-29 14:52   ` Tarang Raval
2025-12-29  2:30 ` [PATCH v2 2/3] media: i2c: ov5647: Switch to using the sub-device state lock Xiaolei Wang
2025-12-29 18:55   ` Sakari Ailus
2025-12-31  2:58     ` xiaolei wang
2025-12-29  2:30 ` [PATCH v2 3/3] media: i2c: ov5647: switch to {enable,disable}_streams Xiaolei Wang
2025-12-29 13:43   ` Laurent Pinchart
2025-12-31  3:02     ` xiaolei wang

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=20251229130116.GC6598@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo@jmondi.org \
    --cc=jai.luthra@ideasonboard.com \
    --cc=johannes.goede@oss.qualcomm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tarang.raval@siliconsignals.io \
    --cc=xiaolei.wang@windriver.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.