From: Hans de Goede <hdegoede@redhat.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
Tsuchiya Yuto <kitakar@gmail.com>,
Andy Shevchenko <andy@kernel.org>,
Yury Luneff <yury.lunev@gmail.com>,
Nable <nable.maininbox@googlemail.com>,
andrey.i.trufanov@gmail.com, Fabio Aiuto <fabioaiuto83@gmail.com>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: [PATCH v2 17/17] media: atomisp: gc0310: Power on sensor from set_fmt() callback
Date: Thu, 20 Oct 2022 21:55:33 +0200 [thread overview]
Message-ID: <20221020195533.114049-18-hdegoede@redhat.com> (raw)
In-Reply-To: <20221020195533.114049-1-hdegoede@redhat.com>
Depending on which order userspace makes various v4l2 calls, the sensor
might still be powered down when set_fmt is called.
What should really happen here is delay the writing of the mode-related
registers till streaming is started, but for now use the same quick fix
as the atomisp_ov2680 code and call power_up() from set_fmt() in
combination with keeping track of the power-state to avoid doing the
power-up sequence twice.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/staging/media/atomisp/i2c/atomisp-gc0310.c | 14 ++++++++++++--
drivers/staging/media/atomisp/i2c/gc0310.h | 1 +
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
index 783f1b88ebf2..87a634bf9ff5 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
@@ -786,8 +786,6 @@ static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
return ret;
}
-static int power_down(struct v4l2_subdev *sd);
-
static int power_up(struct v4l2_subdev *sd)
{
struct gc0310_device *dev = to_gc0310_sensor(sd);
@@ -800,6 +798,9 @@ static int power_up(struct v4l2_subdev *sd)
return -ENODEV;
}
+ if (dev->power_on)
+ return 0; /* Already on */
+
/* power control */
ret = power_ctrl(sd, 1);
if (ret)
@@ -820,6 +821,7 @@ static int power_up(struct v4l2_subdev *sd)
msleep(100);
+ dev->power_on = true;
return 0;
fail_gpio:
@@ -844,6 +846,9 @@ static int power_down(struct v4l2_subdev *sd)
return -ENODEV;
}
+ if (!dev->power_on)
+ return 0; /* Already off */
+
/* gpio ctrl */
ret = gpio_ctrl(sd, 0);
if (ret) {
@@ -861,6 +866,7 @@ static int power_down(struct v4l2_subdev *sd)
if (ret)
dev_err(&client->dev, "vprog failed.\n");
+ dev->power_on = false;
return ret;
}
@@ -935,6 +941,9 @@ static int gc0310_set_fmt(struct v4l2_subdev *sd,
return 0;
}
+ /* s_power has not been called yet for std v4l2 clients (camorama) */
+ power_up(sd);
+
dev_dbg(&client->dev, "%s: before gc0310_write_reg_array %s\n",
__func__, dev->res->desc);
ret = startup(sd);
@@ -1073,6 +1082,7 @@ static int gc0310_s_config(struct v4l2_subdev *sd,
* as first power on by board may not fulfill the
* power on sequqence needed by the module
*/
+ dev->power_on = true; /* force power_down() to run */
ret = power_down(sd);
if (ret) {
dev_err(&client->dev, "gc0310 power-off err.\n");
diff --git a/drivers/staging/media/atomisp/i2c/gc0310.h b/drivers/staging/media/atomisp/i2c/gc0310.h
index db643ebc3909..4b9ce681bd93 100644
--- a/drivers/staging/media/atomisp/i2c/gc0310.h
+++ b/drivers/staging/media/atomisp/i2c/gc0310.h
@@ -152,6 +152,7 @@ struct gc0310_device {
int vt_pix_clk_freq_mhz;
struct gc0310_resolution *res;
u8 type;
+ bool power_on;
};
enum gc0310_tok_type {
--
2.37.3
next prev parent reply other threads:[~2022-10-20 19:56 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 19:55 [PATCH v2 00/17] media: atomisp: Convert to videobuf2 Hans de Goede
2022-10-20 19:55 ` [PATCH v2 01/17] media: atomisp: Add hmm_create_from_vmalloc_buf() function Hans de Goede
2022-10-20 19:55 ` [PATCH v2 02/17] media: atomisp: Add ia_css_frame_init_from_info() function Hans de Goede
2022-10-20 19:55 ` [PATCH v2 03/17] media: atomisp: Make atomisp_q_video_buffers_to_css() static Hans de Goede
2022-10-20 19:55 ` [PATCH v2 04/17] media: atomisp: On streamoff wait for buffers owned by the CSS to be given back Hans de Goede
2022-11-14 10:38 ` Andy Shevchenko
2022-11-20 21:55 ` Hans de Goede
2022-10-20 19:55 ` [PATCH v2 05/17] media: atomisp: Remove unused atomisp_buffers_queued[_pipe] functions Hans de Goede
2022-10-20 19:55 ` [PATCH v2 06/17] media: atomisp: Also track buffers in a list when submitted to the ISP Hans de Goede
2022-11-14 11:53 ` Andy Shevchenko
2022-11-20 21:59 ` Hans de Goede
2022-10-20 19:55 ` [PATCH v2 07/17] media: atomisp: Add an index helper variable to atomisp_buf_done() Hans de Goede
2022-10-20 19:55 ` [PATCH v2 08/17] media: atomisp: Use new atomisp_flush_video_pipe() helper in atomisp_streamoff() Hans de Goede
2022-10-20 19:55 ` [PATCH v2 09/17] media: atomisp: Add ia_css_frame_get_info() helper Hans de Goede
2022-11-14 12:00 ` Andy Shevchenko
2022-10-20 19:55 ` [PATCH v2 10/17] media: atomisp: Convert to videobuf2 Hans de Goede
2022-11-14 12:14 ` Andy Shevchenko
2022-11-20 22:11 ` Hans de Goede
2022-10-20 19:55 ` [PATCH v2 11/17] media: atomisp: Make it possible to call atomisp_set_fmt() without a file handle Hans de Goede
2022-10-20 19:55 ` [PATCH v2 12/17] media: atomisp: Fix VIDIOC_REQBUFS failing when VIDIOC_S_FMT has not been called yet Hans de Goede
2022-11-14 12:17 ` Andy Shevchenko
2022-11-20 22:21 ` Hans de Goede
2022-11-14 20:38 ` Mauro Carvalho Chehab
2022-11-20 22:17 ` Hans de Goede
2022-11-20 23:29 ` Mauro Carvalho Chehab
2022-10-20 19:55 ` [PATCH v2 13/17] media: atomisp: Refactor atomisp_adjust_fmt() Hans de Goede
2022-10-20 19:55 ` [PATCH v2 14/17] media: atomisp: Fix atomisp_try_fmt_cap() always returning YUV420 pixelformat Hans de Goede
2022-10-20 19:55 ` [PATCH v2 15/17] media: atomisp: Make atomisp_g_fmt_cap() default to YUV420 Hans de Goede
2022-11-14 12:18 ` Andy Shevchenko
2022-10-20 19:55 ` [PATCH v2 16/17] media: atomisp: Remove __atomisp_get_pipe() helper Hans de Goede
2022-10-20 19:55 ` Hans de Goede [this message]
2022-11-14 12:20 ` [PATCH v2 17/17] media: atomisp: gc0310: Power on sensor from set_fmt() callback Andy Shevchenko
2022-11-20 22:24 ` Hans de Goede
2022-11-14 20:57 ` Mauro Carvalho Chehab
2022-11-14 12:22 ` [PATCH v2 00/17] media: atomisp: Convert to videobuf2 Andy Shevchenko
2022-11-20 22:39 ` 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=20221020195533.114049-18-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andrey.i.trufanov@gmail.com \
--cc=andy@kernel.org \
--cc=fabioaiuto83@gmail.com \
--cc=kitakar@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=nable.maininbox@googlemail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=yury.lunev@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).