Commit b3f73b21 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Hans Verkuil

media: vimc: Initialize subdev active state

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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 556d821a
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment