Commit 39099d09 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] omap3isp: Move *_init_entities() functions to the init/cleanup section

Group all init/cleanup functions together to make the code more
readable.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 63b4ca23
...@@ -2152,6 +2152,37 @@ static const struct media_entity_operations ccdc_media_ops = { ...@@ -2152,6 +2152,37 @@ static const struct media_entity_operations ccdc_media_ops = {
.link_setup = ccdc_link_setup, .link_setup = ccdc_link_setup,
}; };
void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device *ccdc)
{
v4l2_device_unregister_subdev(&ccdc->subdev);
omap3isp_video_unregister(&ccdc->video_out);
}
int omap3isp_ccdc_register_entities(struct isp_ccdc_device *ccdc,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video node. */
ret = v4l2_device_register_subdev(vdev, &ccdc->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&ccdc->video_out, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_ccdc_unregister_entities(ccdc);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP CCDC initialisation and cleanup
*/
/* /*
* ccdc_init_entities - Initialize V4L2 subdev and media entity * ccdc_init_entities - Initialize V4L2 subdev and media entity
* @ccdc: ISP CCDC module * @ccdc: ISP CCDC module
...@@ -2204,37 +2235,6 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) ...@@ -2204,37 +2235,6 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc)
return 0; return 0;
} }
void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device *ccdc)
{
v4l2_device_unregister_subdev(&ccdc->subdev);
omap3isp_video_unregister(&ccdc->video_out);
}
int omap3isp_ccdc_register_entities(struct isp_ccdc_device *ccdc,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video node. */
ret = v4l2_device_register_subdev(vdev, &ccdc->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&ccdc->video_out, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_ccdc_unregister_entities(ccdc);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP CCDC initialisation and cleanup
*/
/* /*
* omap3isp_ccdc_init - CCDC module initialization. * omap3isp_ccdc_init - CCDC module initialization.
* @dev: Device pointer specific to the OMAP3 ISP. * @dev: Device pointer specific to the OMAP3 ISP.
......
...@@ -1031,6 +1031,48 @@ static const struct media_entity_operations ccp2_media_ops = { ...@@ -1031,6 +1031,48 @@ static const struct media_entity_operations ccp2_media_ops = {
.link_setup = ccp2_link_setup, .link_setup = ccp2_link_setup,
}; };
/*
* omap3isp_ccp2_unregister_entities - Unregister media entities: subdev
* @ccp2: Pointer to ISP CCP2 device
*/
void omap3isp_ccp2_unregister_entities(struct isp_ccp2_device *ccp2)
{
v4l2_device_unregister_subdev(&ccp2->subdev);
omap3isp_video_unregister(&ccp2->video_in);
}
/*
* omap3isp_ccp2_register_entities - Register the subdev media entity
* @ccp2: Pointer to ISP CCP2 device
* @vdev: Pointer to v4l device
* return negative error code or zero on success
*/
int omap3isp_ccp2_register_entities(struct isp_ccp2_device *ccp2,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video nodes. */
ret = v4l2_device_register_subdev(vdev, &ccp2->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&ccp2->video_in, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_ccp2_unregister_entities(ccp2);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP ccp2 initialisation and cleanup
*/
/* /*
* ccp2_init_entities - Initialize ccp2 subdev and media entity. * ccp2_init_entities - Initialize ccp2 subdev and media entity.
* @ccp2: Pointer to ISP CCP2 device * @ccp2: Pointer to ISP CCP2 device
...@@ -1094,62 +1136,6 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) ...@@ -1094,62 +1136,6 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2)
return 0; return 0;
} }
/*
* omap3isp_ccp2_unregister_entities - Unregister media entities: subdev
* @ccp2: Pointer to ISP CCP2 device
*/
void omap3isp_ccp2_unregister_entities(struct isp_ccp2_device *ccp2)
{
v4l2_device_unregister_subdev(&ccp2->subdev);
omap3isp_video_unregister(&ccp2->video_in);
}
/*
* omap3isp_ccp2_register_entities - Register the subdev media entity
* @ccp2: Pointer to ISP CCP2 device
* @vdev: Pointer to v4l device
* return negative error code or zero on success
*/
int omap3isp_ccp2_register_entities(struct isp_ccp2_device *ccp2,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video nodes. */
ret = v4l2_device_register_subdev(vdev, &ccp2->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&ccp2->video_in, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_ccp2_unregister_entities(ccp2);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP ccp2 initialisation and cleanup
*/
/*
* omap3isp_ccp2_cleanup - CCP2 un-initialization
* @isp : Pointer to ISP device
*/
void omap3isp_ccp2_cleanup(struct isp_device *isp)
{
struct isp_ccp2_device *ccp2 = &isp->isp_ccp2;
omap3isp_video_cleanup(&ccp2->video_in);
media_entity_cleanup(&ccp2->subdev.entity);
regulator_put(ccp2->vdds_csib);
}
/* /*
* omap3isp_ccp2_init - CCP2 initialization. * omap3isp_ccp2_init - CCP2 initialization.
* @isp : Pointer to ISP device * @isp : Pointer to ISP device
...@@ -1195,3 +1181,17 @@ int omap3isp_ccp2_init(struct isp_device *isp) ...@@ -1195,3 +1181,17 @@ int omap3isp_ccp2_init(struct isp_device *isp)
return ret; return ret;
} }
/*
* omap3isp_ccp2_cleanup - CCP2 un-initialization
* @isp : Pointer to ISP device
*/
void omap3isp_ccp2_cleanup(struct isp_device *isp)
{
struct isp_ccp2_device *ccp2 = &isp->isp_ccp2;
omap3isp_video_cleanup(&ccp2->video_in);
media_entity_cleanup(&ccp2->subdev.entity);
regulator_put(ccp2->vdds_csib);
}
...@@ -1187,6 +1187,37 @@ static const struct media_entity_operations csi2_media_ops = { ...@@ -1187,6 +1187,37 @@ static const struct media_entity_operations csi2_media_ops = {
.link_setup = csi2_link_setup, .link_setup = csi2_link_setup,
}; };
void omap3isp_csi2_unregister_entities(struct isp_csi2_device *csi2)
{
v4l2_device_unregister_subdev(&csi2->subdev);
omap3isp_video_unregister(&csi2->video_out);
}
int omap3isp_csi2_register_entities(struct isp_csi2_device *csi2,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video nodes. */
ret = v4l2_device_register_subdev(vdev, &csi2->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&csi2->video_out, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_csi2_unregister_entities(csi2);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP CSI2 initialisation and cleanup
*/
/* /*
* csi2_init_entities - Initialize subdev and media entity. * csi2_init_entities - Initialize subdev and media entity.
* @csi2: Pointer to csi2 structure. * @csi2: Pointer to csi2 structure.
...@@ -1239,48 +1270,6 @@ static int csi2_init_entities(struct isp_csi2_device *csi2) ...@@ -1239,48 +1270,6 @@ static int csi2_init_entities(struct isp_csi2_device *csi2)
return 0; return 0;
} }
void omap3isp_csi2_unregister_entities(struct isp_csi2_device *csi2)
{
v4l2_device_unregister_subdev(&csi2->subdev);
omap3isp_video_unregister(&csi2->video_out);
}
int omap3isp_csi2_register_entities(struct isp_csi2_device *csi2,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video nodes. */
ret = v4l2_device_register_subdev(vdev, &csi2->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&csi2->video_out, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_csi2_unregister_entities(csi2);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP CSI2 initialisation and cleanup
*/
/*
* omap3isp_csi2_cleanup - Routine for module driver cleanup
*/
void omap3isp_csi2_cleanup(struct isp_device *isp)
{
struct isp_csi2_device *csi2a = &isp->isp_csi2a;
omap3isp_video_cleanup(&csi2a->video_out);
media_entity_cleanup(&csi2a->subdev.entity);
}
/* /*
* omap3isp_csi2_init - Routine for module driver init * omap3isp_csi2_init - Routine for module driver init
*/ */
...@@ -1317,3 +1306,14 @@ int omap3isp_csi2_init(struct isp_device *isp) ...@@ -1317,3 +1306,14 @@ int omap3isp_csi2_init(struct isp_device *isp)
omap3isp_csi2_cleanup(isp); omap3isp_csi2_cleanup(isp);
return ret; return ret;
} }
/*
* omap3isp_csi2_cleanup - Routine for module driver cleanup
*/
void omap3isp_csi2_cleanup(struct isp_device *isp)
{
struct isp_csi2_device *csi2a = &isp->isp_csi2a;
omap3isp_video_cleanup(&csi2a->video_out);
media_entity_cleanup(&csi2a->subdev.entity);
}
...@@ -1966,8 +1966,44 @@ static const struct media_entity_operations preview_media_ops = { ...@@ -1966,8 +1966,44 @@ static const struct media_entity_operations preview_media_ops = {
.link_setup = preview_link_setup, .link_setup = preview_link_setup,
}; };
void omap3isp_preview_unregister_entities(struct isp_prev_device *prev)
{
v4l2_device_unregister_subdev(&prev->subdev);
omap3isp_video_unregister(&prev->video_in);
omap3isp_video_unregister(&prev->video_out);
}
int omap3isp_preview_register_entities(struct isp_prev_device *prev,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video nodes. */
ret = v4l2_device_register_subdev(vdev, &prev->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&prev->video_in, vdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&prev->video_out, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_preview_unregister_entities(prev);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP previewer initialisation and cleanup
*/
/* /*
* review_init_entities - Initialize subdev and media entity. * preview_init_entities - Initialize subdev and media entity.
* @prev : Pointer to preview structure * @prev : Pointer to preview structure
* return -ENOMEM or zero on success * return -ENOMEM or zero on success
*/ */
...@@ -2044,52 +2080,6 @@ static int preview_init_entities(struct isp_prev_device *prev) ...@@ -2044,52 +2080,6 @@ static int preview_init_entities(struct isp_prev_device *prev)
return 0; return 0;
} }
void omap3isp_preview_unregister_entities(struct isp_prev_device *prev)
{
v4l2_device_unregister_subdev(&prev->subdev);
omap3isp_video_unregister(&prev->video_in);
omap3isp_video_unregister(&prev->video_out);
}
int omap3isp_preview_register_entities(struct isp_prev_device *prev,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video nodes. */
ret = v4l2_device_register_subdev(vdev, &prev->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&prev->video_in, vdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&prev->video_out, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_preview_unregister_entities(prev);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP previewer initialisation and cleanup
*/
void omap3isp_preview_cleanup(struct isp_device *isp)
{
struct isp_prev_device *prev = &isp->isp_prev;
v4l2_ctrl_handler_free(&prev->ctrls);
omap3isp_video_cleanup(&prev->video_in);
omap3isp_video_cleanup(&prev->video_out);
media_entity_cleanup(&prev->subdev.entity);
}
/* /*
* isp_preview_init - Previewer initialization. * isp_preview_init - Previewer initialization.
* @dev : Pointer to ISP device * @dev : Pointer to ISP device
...@@ -2114,3 +2104,13 @@ int omap3isp_preview_init(struct isp_device *isp) ...@@ -2114,3 +2104,13 @@ int omap3isp_preview_init(struct isp_device *isp)
return ret; return ret;
} }
void omap3isp_preview_cleanup(struct isp_device *isp)
{
struct isp_prev_device *prev = &isp->isp_prev;
v4l2_ctrl_handler_free(&prev->ctrls);
omap3isp_video_cleanup(&prev->video_in);
omap3isp_video_cleanup(&prev->video_out);
media_entity_cleanup(&prev->subdev.entity);
}
...@@ -1608,6 +1608,42 @@ static const struct media_entity_operations resizer_media_ops = { ...@@ -1608,6 +1608,42 @@ static const struct media_entity_operations resizer_media_ops = {
.link_setup = resizer_link_setup, .link_setup = resizer_link_setup,
}; };
void omap3isp_resizer_unregister_entities(struct isp_res_device *res)
{
v4l2_device_unregister_subdev(&res->subdev);
omap3isp_video_unregister(&res->video_in);
omap3isp_video_unregister(&res->video_out);
}
int omap3isp_resizer_register_entities(struct isp_res_device *res,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video nodes. */
ret = v4l2_device_register_subdev(vdev, &res->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&res->video_in, vdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&res->video_out, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_resizer_unregister_entities(res);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP resizer initialization and cleanup
*/
/* /*
* resizer_init_entities - Initialize resizer subdev and media entity. * resizer_init_entities - Initialize resizer subdev and media entity.
* @res : Pointer to resizer device structure * @res : Pointer to resizer device structure
...@@ -1672,51 +1708,6 @@ static int resizer_init_entities(struct isp_res_device *res) ...@@ -1672,51 +1708,6 @@ static int resizer_init_entities(struct isp_res_device *res)
return 0; return 0;
} }
void omap3isp_resizer_unregister_entities(struct isp_res_device *res)
{
v4l2_device_unregister_subdev(&res->subdev);
omap3isp_video_unregister(&res->video_in);
omap3isp_video_unregister(&res->video_out);
}
int omap3isp_resizer_register_entities(struct isp_res_device *res,
struct v4l2_device *vdev)
{
int ret;
/* Register the subdev and video nodes. */
ret = v4l2_device_register_subdev(vdev, &res->subdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&res->video_in, vdev);
if (ret < 0)
goto error;
ret = omap3isp_video_register(&res->video_out, vdev);
if (ret < 0)
goto error;
return 0;
error:
omap3isp_resizer_unregister_entities(res);
return ret;
}
/* -----------------------------------------------------------------------------
* ISP resizer initialization and cleanup
*/
void omap3isp_resizer_cleanup(struct isp_device *isp)
{
struct isp_res_device *res = &isp->isp_res;
omap3isp_video_cleanup(&res->video_in);
omap3isp_video_cleanup(&res->video_out);
media_entity_cleanup(&res->subdev.entity);
}
/* /*
* isp_resizer_init - Resizer initialization. * isp_resizer_init - Resizer initialization.
* @isp : Pointer to ISP device * @isp : Pointer to ISP device
...@@ -1739,3 +1730,12 @@ int omap3isp_resizer_init(struct isp_device *isp) ...@@ -1739,3 +1730,12 @@ int omap3isp_resizer_init(struct isp_device *isp)
return ret; return ret;
} }
void omap3isp_resizer_cleanup(struct isp_device *isp)
{
struct isp_res_device *res = &isp->isp_res;
omap3isp_video_cleanup(&res->video_in);
omap3isp_video_cleanup(&res->video_out);
media_entity_cleanup(&res->subdev.entity);
}
...@@ -1023,24 +1023,6 @@ void omap3isp_stat_dma_isr(struct ispstat *stat) ...@@ -1023,24 +1023,6 @@ void omap3isp_stat_dma_isr(struct ispstat *stat)
__stat_isr(stat, 1); __stat_isr(stat, 1);
} }
static int isp_stat_init_entities(struct ispstat *stat, const char *name,
const struct v4l2_subdev_ops *sd_ops)
{
struct v4l2_subdev *subdev = &stat->subdev;
struct media_entity *me = &subdev->entity;
v4l2_subdev_init(subdev, sd_ops);
snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "OMAP3 ISP %s", name);
subdev->grp_id = 1 << 16; /* group ID for isp subdevs */
subdev->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
v4l2_set_subdevdata(subdev, stat);
stat->pad.flags = MEDIA_PAD_FL_SINK;
me->ops = NULL;
return media_entity_init(me, 1, &stat->pad, 0);
}
int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
struct v4l2_fh *fh, struct v4l2_fh *fh,
struct v4l2_event_subscription *sub) struct v4l2_event_subscription *sub)
...@@ -1071,6 +1053,24 @@ int omap3isp_stat_register_entities(struct ispstat *stat, ...@@ -1071,6 +1053,24 @@ int omap3isp_stat_register_entities(struct ispstat *stat,
return v4l2_device_register_subdev(vdev, &stat->subdev); return v4l2_device_register_subdev(vdev, &stat->subdev);
} }
static int isp_stat_init_entities(struct ispstat *stat, const char *name,
const struct v4l2_subdev_ops *sd_ops)
{
struct v4l2_subdev *subdev = &stat->subdev;
struct media_entity *me = &subdev->entity;
v4l2_subdev_init(subdev, sd_ops);
snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "OMAP3 ISP %s", name);
subdev->grp_id = 1 << 16; /* group ID for isp subdevs */
subdev->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
v4l2_set_subdevdata(subdev, stat);
stat->pad.flags = MEDIA_PAD_FL_SINK;
me->ops = NULL;
return media_entity_init(me, 1, &stat->pad, 0);
}
int omap3isp_stat_init(struct ispstat *stat, const char *name, int omap3isp_stat_init(struct ispstat *stat, const char *name,
const struct v4l2_subdev_ops *sd_ops) const struct v4l2_subdev_ops *sd_ops)
{ {
......
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