Skip to content

Commit

Permalink
media: vimc: Initialize subdev active state
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
  • Loading branch information
pinchartl authored and Hans Verkuil committed Jun 26, 2024
1 parent 556d821 commit b3f73b2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
23 changes: 22 additions & 1 deletion drivers/media/test-drivers/vimc/vimc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <linux/init.h>
#include <linux/module.h>

#include <media/v4l2-ctrls.h>

#include "vimc-common.h"

/*
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/media/test-drivers/vimc/vimc-debayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/media/test-drivers/vimc/vimc-lens.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/media/test-drivers/vimc/vimc-scaler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/media/test-drivers/vimc/vimc-sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit b3f73b2

Please sign in to comment.