]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
media: atomisp: Turn on sensor power from atomisp_set_fmt()
authorHans de Goede <hdegoede@redhat.com>
Thu, 11 Apr 2024 18:07:55 +0000 (19:07 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 26 Apr 2024 09:46:32 +0000 (10:46 +0100)
ATM the atomisp driver does not call s_power() at all when no s_input
ioctl() is done by the application. This breaks older sensor drivers
which rely on s_power() for power-management.

Some drivers have worked around this, e.g. commit c5fafbadaeae ("media:
atomisp: gc0310: Power on sensor from set_fmt() callback") and
commit b3118a942c82 ("media: atomisp: ov2722: Power on sensor from
set_fmt() callback"), but this really should be fixed in the atomisp
driver itself, so that all old drivers can work.

A logical place to call s_power() would be from atomisp_start_streaming() /
atomisp_stop_streaming(). But some older drivers, e.g. the atomisp-ov2722
driver already write mode related registers on set_fmt() instead of waiting
on stream on. So the s_power(1) needs to happen at the first set_fmt().

Add an atomisp_s_sensor_power(..., 1) call just before calling set_fmt()
for this. If the power was already enabled through e.g. a s_input ioctl
atomisp_s_sensor_power() will skip calling the s_power() v4l2-subdev-op
a second time.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_cmd.c

index 6b8ff9f1ae638d9f869a038e873a3c0b09e9ebf2..83a15a2d358e8e0a2a24b1cebbcf38180d8c9388 100644 (file)
@@ -3760,6 +3760,17 @@ static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp,
        if (!input->camera)
                return -EINVAL;
 
+       /*
+        * Some old sensor drivers already write the registers on set_fmt
+        * instead of on stream on, power on the sensor now (on newer
+        * sensor drivers the s_power op is a no-op).
+        */
+       if (which == V4L2_SUBDEV_FORMAT_ACTIVE) {
+               ret = atomisp_s_sensor_power(isp, isp->asd.input_curr, 1);
+               if (ret)
+                       return ret;
+       }
+
        sd_state = (which == V4L2_SUBDEV_FORMAT_TRY) ? input->try_sd_state :
                                                       input->camera->active_state;
        if (sd_state)