All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>
To: Pavel Machek <pavel@denx.de>
Cc: "cip-dev@lists.cip-project.org" <cip-dev@lists.cip-project.org>,
	Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
	Biju Das <biju.das.jz@bp.renesas.com>
Subject: Re: [cip-dev] [PATCH 4.19.y-cip 13/40] media: i2c: Add driver for Sony IMX219 sensor
Date: Wed, 10 Mar 2021 09:36:54 +0000	[thread overview]
Message-ID: <OSAPR01MB48672E161C93582BDF81A520AA919@OSAPR01MB4867.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20210309203635.GB7900@amd>

[-- Attachment #1: Type: text/plain, Size: 6070 bytes --]

Hi Pavel,

Thank you for the review.

> -----Original Message-----
> From: Pavel Machek <pavel@denx.de>
> Sent: 09 March 2021 20:37
> To: Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Cc: cip-dev@lists.cip-project.org; Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>; Pavel Machek
> <pavel@denx.de>; Biju Das <biju.das.jz@bp.renesas.com>
> Subject: Re: [PATCH 4.19.y-cip 13/40] media: i2c: Add driver for Sony IMX219 sensor
> 
> Hi!
> 
> > +/* External clock frequency is 24.0M */
> > +#define IMX219_XCLK_FREQ		24000000
> 
> MHz?
> 
> > +/*Frame Length Line*/
> 
> Make this usual comment style.
> 
> > +/*
> > + * Initialisation delay between XCLR low->high and the moment when the sensor
> > + * can start capture (i.e. can leave software stanby) must be not less than:
> > + *   t4 + max(t5, t6 + <time to initialize the sensor register over I2C>)
> > + * where
> > + *   t4 is fixed, and is max 200uS,
> > + *   t5 is fixed, and is 6000uS,
> ...
> > + * 1185 to 5333 uS, and is always less than t5.
> ...
> > + * For this reason this is always safe to wait (t4 + t5) = 6200 uS, then
> 
> I believe this should be "us" or "usec".
> 
> > +	/*
> > +	 * Mutex for serialized access:
> > +	 * Protect sensor module set pad format and start/stop streaming safely.
> > +	 */
> 
> This is not really english.
> 
> > +/* Read registers up to 2 at a time */
> > +static int imx219_read_reg(struct imx219 *imx219, u16 reg, u32 len, u32 *val)
> > +{
> 
> > +	msgs[1].buf = &data_buf[4 - len];
> > +
> > +	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
> > +	if (ret != ARRAY_SIZE(msgs))
> > +		return -EIO;
> > +
> > +	*val = get_unaligned_be32(data_buf);
> 
> That's really interesting piece of code. len is in bytes, but return
> value is in 32 bit values, magic with be32...
> 
> > +static int imx219_write_reg(struct imx219 *imx219, u16 reg, u32 len, u32 val)
> > +{
> > +	struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd);
> > +	u8 buf[6];
> > +
> > +	if (len > 4)
> > +		return -EINVAL;
> > +
> > +	put_unaligned_be16(reg, buf);
> > +	put_unaligned_be32(val << (8 * (4 - len)), buf + 2);
> 
> Wow. When I thought above was interesting.... this is even more so.
> 
> 
> > +static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
> > +{
> ...
> > +	/*
> > +	 * Applying V4L2 control value only happens
> > +	 * when power is up for streaming
> > +	 */
> > +	if (pm_runtime_get_if_in_use(&client->dev) == 0)
> > +		return 0;
> 
> Is this usual for other cameras? Will not it cause problems to
> applications doing autogain?
> 
Above check is to see if the camera is turned ON, so the application doing autogain should be fine.

> > +	switch (ctrl->id) {
> ...
> > +	case V4L2_CID_HFLIP:
> > +	case V4L2_CID_VFLIP:
> > +		ret = imx219_write_reg(imx219, IMX219_REG_ORIENTATION, 1,
> > +				       imx219->hflip->val |
> > +				       imx219->vflip->val << 1);
> > +		break;
> 
> ctrl->val is unused in this case?
> 
Yes, for the H/V flip it depends on the format code set.

> > +		break;
> > +	default:
> > +		dev_info(&client->dev,
> > +			 "ctrl(id:0x%x,val:0x%x) is not handled\n",
> > +			 ctrl->id, ctrl->val);
> > +		ret = -EINVAL;
> > +		break;
> > +	}
> 
> Rate limit this as user can trigger these?
> 
Yes can be triggered.

> > +static int imx219_set_stream(struct v4l2_subdev *sd, int enable)
> > +{
> > +	struct imx219 *imx219 = to_imx219(sd);
> > +	struct i2c_client *client = v4l2_get_subdevdata(sd);
> > +	int ret = 0;
> > +
> > +	mutex_lock(&imx219->mutex);
> > +	if (imx219->streaming == enable) {
> > +		mutex_unlock(&imx219->mutex);
> > +		return 0;
> > +	}
> > +
> > +	if (enable) {
> > +		ret = pm_runtime_get_sync(&client->dev);
> > +		if (ret < 0) {
> > +			pm_runtime_put_noidle(&client->dev);
> > +			goto err_unlock;
> > +		}
> > +
> > +		/*
> > +		 * Apply default & customized values
> > +		 * and then start streaming.
> > +		 */
> > +		ret = imx219_start_streaming(imx219);
> > +		if (ret)
> > +			goto err_rpm_put;
> 
> Is it correct/vital that one error path uses put_noidle() and second
> uses plain put()?
> 
As per my reading https://patchwork.kernel.org/project/linux-omap/patch/20180518173008.73291-2-tony@atomide.com/ its OK.

> > +static int __maybe_unused imx219_resume(struct device *dev)
> > +{
> > +	struct i2c_client *client = to_i2c_client(dev);
> > +	struct v4l2_subdev *sd = i2c_get_clientdata(client);
> > +	struct imx219 *imx219 = to_imx219(sd);
> > +	int ret;
> > +
> > +	if (imx219->streaming) {
> > +		ret = imx219_start_streaming(imx219);
> > +		if (ret)
> > +			goto error;
> > +	}
> > +
> > +	return 0;
> > +
> > +error:
> > +	imx219_stop_streaming(imx219);
> > +	imx219->streaming = 0;
> 
> This error path will leave driver in inconsistent state. hflip/vflip
> controls will be locked and pm_runtime_put() is not executed.
> 
Good catch, this needs fixing in upstream.

> > +static int imx219_check_hwcfg(struct device *dev)
> > +{
> > +	struct v4l2_fwnode_endpoint *ep_cfg;
> > +	struct device_node *ep;
> > +	int ret = -EINVAL;
> > +
> > +	ep = of_graph_get_next_endpoint(dev->of_node, NULL);
> > +	if (!ep) {
> > +		dev_err(dev, "missing endpoint node\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	ep_cfg = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(ep));
> > +	if (IS_ERR(ep_cfg)) {
> > +		dev_err(dev, "could not parse endpoint\n");
> > +		goto error_out;
> > +	}
> ...
> > +error_out:
> > +	v4l2_fwnode_endpoint_free(ep_cfg);
> 
> Is it correct to call endpoint_free on error pointer?
> 
Yes the core handles it.

> > +MODULE_AUTHOR("Dave Stevenson <dave.stevenson@raspberrypi.com");
> 
> Missing ">" at end of address.
> 
Yep needs fixing as well.

Cheers,
Prabhakar

> Best regards,
> 								Pavel
> --
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: Type: text/plain, Size: 428 bytes --]


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#6266): https://lists.cip-project.org/g/cip-dev/message/6266
Mute This Topic: https://lists.cip-project.org/mt/81205356/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/4520388/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-


  reply	other threads:[~2021-03-10  9:37 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 16:36 [cip-dev] [PATCH 4.19.y-cip 00/40] Renesas RZ/G2{E,H,M,N} add VIN, CSI2 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 01/40] media: ov5645: Remove unneeded regulator_set_voltage() Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 02/40] media: device property: Add a function to test is a fwnode is a graph endpoint Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 03/40] media: v4l2-async: Accept endpoints and devices for fwnode matching Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 04/40] media: v4l2-async: Pass notifier pointer to match functions Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 05/40] media: v4l2-async: Log message in case of heterogeneous fwnode match Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 06/40] media: v4l: ctrl: Provide unlocked variant of v4l2_ctrl_grab Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 07/40] media: rcar-vin: fix wrong return value in rvin_set_channel_routing() Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 08/40] media: rcar-csi2: Update V3M and E3 start procedure Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 09/40] media: rcar-vin: Invalidate pipeline if conversion is not possible on input formats Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 10/40] media: rcar-vin: Add support for MEDIA_BUS_FMT_SRGGB8_1X8 format Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 11/40] media: rcar-csi2: " Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 12/40] media: dt-bindings: media: i2c: Add IMX219 CMOS sensor binding Lad Prabhakar
2021-03-09 18:52   ` Pavel Machek
2021-03-10  8:48     ` Lad Prabhakar
2021-03-10  9:38       ` Pavel Machek
2021-03-10 10:24         ` Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 13/40] media: i2c: Add driver for Sony IMX219 sensor Lad Prabhakar
2021-03-09 20:36   ` Pavel Machek
2021-03-10  9:36     ` Lad Prabhakar [this message]
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 14/40] media: i2c: imx219: Fix power sequence Lad Prabhakar
2021-03-09 19:42   ` Pavel Machek
2021-03-10  8:49     ` Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 15/40] media: i2c: imx219: Add support for RAW8 bit bayer format Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 16/40] media: i2c: imx219: Add support for cropped 640x480 resolution Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 17/40] media: i2c: imx219: Implement get_selection Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 18/40] media: i2c: imx219: Fix a bug in imx219_enum_frame_size Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 19/40] media: i2c: imx219: Selection compliance fixes Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 20/40] media: i2c: imx219: take lock in imx219_enum_mbus_code/frame_size Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 21/40] arm64: dts: renesas: r8a774c0-cat874: Add support for AISTARVISION MIPI Adapter V2.1 Lad Prabhakar
2021-03-09 20:39   ` Pavel Machek
2021-03-10  9:37     ` Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 22/40] media: dt-bindings: media: rcar_vin: Add r8a774a1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 23/40] media: rcar-vin: Enable support for r8a774a1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 24/40] media: dt-bindings: media: rcar-csi2: Add r8a774a1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 25/40] media: rcar-csi2: Enable support for r8a774a1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 26/40] arm64: dts: renesas: r8a774a1: Add VIN and CSI-2 nodes Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 27/40] media: dt-bindings: rcar-vin: Add R8A774B1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 28/40] media: rcar-vin: Enable support for R8A774B1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 29/40] media: dt-bindings: rcar-csi2: Add R8A774B1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 30/40] media: rcar-csi2: Enable support for R8A774B1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 31/40] arm64: dts: renesas: r8a774b1: Add VIN and CSI-2 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 32/40] media: dt-bindings: media: renesas,vin: Add R8A774E1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 33/40] media: rcar-vin: Enable support for R8A774E1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 34/40] media: dt-bindings: media: renesas,csi2: Add R8A774E1 support Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 35/40] media: rcar-csi2: Enable support for R8A774E1 Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 36/40] arm64: dts: renesas: r8a774e1: Add VIN and CSI-2 nodes Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 37/40] arm64: dts: renesas: aistarvision-mipi-adapter-2.1: Add parent macro for each sensor Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 38/40] arm64: dts: renesas: Add support for MIPI Adapter V2.1 connected to HiHope RZ/G2H Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 39/40] arm64: dts: renesas: Add support for MIPI Adapter V2.1 connected to HiHope RZ/G2M Lad Prabhakar
2021-03-09 16:36 ` [cip-dev] [PATCH 4.19.y-cip 40/40] arm64: dts: renesas: Add support for MIPI Adapter V2.1 connected to HiHope RZ/G2N Lad Prabhakar
2021-03-09 20:48 ` [cip-dev] [PATCH 4.19.y-cip 00/40] Renesas RZ/G2{E,H,M,N} add VIN, CSI2 support Pavel Machek
2021-03-09 23:13 ` Pavel Machek
2021-03-10  8:07 ` Nobuhiro Iwamatsu
2021-03-10  9:41   ` Lad Prabhakar
2021-03-10 10:58   ` Chris Paterson
     [not found]   ` <166AF609ACF1E617.19014@lists.cip-project.org>
2021-03-22 22:11     ` Chris Paterson
2021-03-23  7:31       ` Nobuhiro Iwamatsu
2021-03-23  7:50         ` Chris Paterson

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=OSAPR01MB48672E161C93582BDF81A520AA919@OSAPR01MB4867.jpnprd01.prod.outlook.com \
    --to=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=pavel@denx.de \
    /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.