RE: [PATCH v4] media: imx258: Add imx258 camera sensor driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Tomasz,

Agree with your point, if so, we could just change as below with a simple check of streaming flag.
And for Sakari, do you agree with Tomasz's comment?

Kindly review and I would send v5 with the change.

diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
index a7e58bd2..cf1c5ee 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -561,10 +561,13 @@ static int imx258_set_ctrl(struct v4l2_ctrl *ctrl)

        /*
         * Applying V4L2 control value only happens
-        * when power is up for qstreaming
+        * when streaming flag is on
         */
-       if (pm_runtime_get_if_in_use(&client->dev) <= 0)
+       if (imx258->streaming == 0)
                return 0;

        switch (ctrl->id) {
        case V4L2_CID_ANALOGUE_GAIN:
@@ -590,8 +593,6 @@ static int imx258_set_ctrl(struct v4l2_ctrl *ctrl)
                break;
        }

-       pm_runtime_put(&client->dev);
-
        return ret;
 }


Regards, Andy

-----Original Message-----
From: Tomasz Figa [mailto:tfiga@xxxxxxxxxxxx] 
Sent: Friday, January 19, 2018 12:18 PM
To: Yeh, Andy <andy.yeh@xxxxxxxxx>
Cc: Linux Media Mailing List <linux-media@xxxxxxxxxxxxxxx>; Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
Subject: Re: [PATCH v4] media: imx258: Add imx258 camera sensor driver

Hi Andy,

Thanks for the patch. Please see my comments inline.

On Fri, Jan 19, 2018 at 12:37 PM, Andy Yeh <andy.yeh@xxxxxxxxx> wrote:
> Add a V4L2 sub-device driver for the Sony IMX258 image sensor.
> This is a camera sensor using the I2C bus for control and the
> CSI-2 bus for data.
>
> Signed-off-by: Andy Yeh <andy.yeh@xxxxxxxxx>
> ---
> - v2->v3
> -- Update the streaming function to remove SW_STANDBY in the beginning.
> -- Adjust the delay time from 1ms to 12ms before set stream-on register.
> - v3->v4
> -- fix the sd.entity to make code be compiled on the mainline kernel.
> -- " - imx258->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;"
> -- " + imx258->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;"
>
>  MAINTAINERS                |    7 +
>  drivers/media/i2c/Kconfig  |   11 +
>  drivers/media/i2c/Makefile |    1 +
>  drivers/media/i2c/imx258.c | 1148 
> ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 1167 insertions(+)
>  create mode 100644 drivers/media/i2c/imx258.c
[snip]
> +static int imx258_set_ctrl(struct v4l2_ctrl *ctrl) {
> +       struct imx258 *imx258 =
> +               container_of(ctrl->handler, struct imx258, ctrl_handler);
> +       struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd);
> +       s64 max;
> +       int ret = 0;
> +
> +       /* Propagate change of current control to all related controls */
> +       if (ctrl->id == V4L2_CID_VBLANK) {
> +               /* Update max exposure while meeting expected vblanking */
> +               max = imx258->cur_mode->height + ctrl->val - 8;
> +               __v4l2_ctrl_modify_range(imx258->exposure,
> +                                        imx258->exposure->minimum,
> +                                        max, imx258->exposure->step, max);
> +       }
> +
> +       /*
> +        * Applying V4L2 control value only happens
> +        * when power is up for streaming
> +        */
> +       if (pm_runtime_get_if_in_use(&client->dev) <= 0)
> +               return 0;

This won't work if runtime PM is not compiled in or is disabled at runtime, i.e. pm_runtime_get_if_in_use() returns -EINVAL.

But actually, do we need to care about runtime PM here? Could we just return early if we're not streaming? Then the controls would be handled when streaming starts, since we call
__v4l2_ctrl_handler_setup() from _start_streaming().

Best regards,
Tomasz




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux