]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: vimc: Initialize subdev active state
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 24 Apr 2024 23:57:38 +0000 (02:57 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 26 Jun 2024 14:39:34 +0000 (16:39 +0200)
Finalize subdev initialization for all subdevs that provide a
.init_state() operation. This creates an active state for all those
subdevs, which subsequent patches will use to simplify the
implementation of individual vimc entities.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/test-drivers/vimc/vimc-common.c
drivers/media/test-drivers/vimc/vimc-debayer.c
drivers/media/test-drivers/vimc/vimc-lens.c
drivers/media/test-drivers/vimc/vimc-scaler.c
drivers/media/test-drivers/vimc/vimc-sensor.c

index 3da2271215c679dfb52e9a8bc896a33e03b36bed..4f4fcb26e2368e7296e801c4f2ae7627276f7561 100644 (file)
@@ -8,6 +8,8 @@
 #include <linux/init.h>
 #include <linux/module.h>
 
+#include <media/v4l2-ctrls.h>
+
 #include "vimc-common.h"
 
 /*
@@ -385,17 +387,36 @@ int vimc_ent_sd_register(struct vimc_ent_device *ved,
        if (ret)
                return ret;
 
+       /*
+        * Finalize the subdev initialization if it supports active states. Use
+        * the control handler lock as the state lock if available.
+        */
+       if (int_ops && int_ops->init_state) {
+               if (sd->ctrl_handler)
+                       sd->state_lock = sd->ctrl_handler->lock;
+
+               ret = v4l2_subdev_init_finalize(sd);
+               if (ret) {
+                       dev_err(v4l2_dev->dev,
+                               "%s: subdev initialization failed (err=%d)\n",
+                               name, ret);
+                       goto err_clean_m_ent;
+               }
+       }
+
        /* Register the subdev with the v4l2 and the media framework */
        ret = v4l2_device_register_subdev(v4l2_dev, sd);
        if (ret) {
                dev_err(v4l2_dev->dev,
                        "%s: subdev register failed (err=%d)\n",
                        name, ret);
-               goto err_clean_m_ent;
+               goto err_clean_sd;
        }
 
        return 0;
 
+err_clean_sd:
+       v4l2_subdev_cleanup(sd);
 err_clean_m_ent:
        media_entity_cleanup(&sd->entity);
        return ret;
index d4ca57b3672d1d11377322cc1f928c0561f37fec..9f8a31fb0695ba548104d87ab7f305da0e729bb0 100644 (file)
@@ -540,6 +540,7 @@ static void vimc_debayer_release(struct vimc_ent_device *ved)
                container_of(ved, struct vimc_debayer_device, ved);
 
        v4l2_ctrl_handler_free(&vdebayer->hdl);
+       v4l2_subdev_cleanup(&vdebayer->sd);
        media_entity_cleanup(vdebayer->ved.ent);
        kfree(vdebayer);
 }
index 42c58a3e3f1bc4ead490135d8cd670e63d21a665..96399057a2b51b73823208ed5a9798a565a5129d 100644 (file)
@@ -92,6 +92,7 @@ static void vimc_lens_release(struct vimc_ent_device *ved)
                container_of(ved, struct vimc_lens_device, ved);
 
        v4l2_ctrl_handler_free(&vlens->hdl);
+       v4l2_subdev_cleanup(&vlens->sd);
        media_entity_cleanup(vlens->ved.ent);
        kfree(vlens);
 }
index 4f9c44a663e1b9b4c3939630e3f5c7239c2d0020..f8639f5b4d0c9e1126a4559b9eac6e424bb62047 100644 (file)
@@ -398,6 +398,7 @@ static void vimc_scaler_release(struct vimc_ent_device *ved)
        struct vimc_scaler_device *vscaler =
                container_of(ved, struct vimc_scaler_device, ved);
 
+       v4l2_subdev_cleanup(&vscaler->sd);
        media_entity_cleanup(vscaler->ved.ent);
        kfree(vscaler);
 }
index 5c31d9435cdd71edd730382f4973bb9490b3179a..9eb24c4791bf9c272e6cb050eff051b35cec1396 100644 (file)
@@ -340,6 +340,7 @@ static void vimc_sensor_release(struct vimc_ent_device *ved)
 
        v4l2_ctrl_handler_free(&vsensor->hdl);
        tpg_free(&vsensor->tpg);
+       v4l2_subdev_cleanup(&vsensor->sd);
        media_entity_cleanup(vsensor->ved.ent);
        kfree(vsensor);
 }