diff options
Diffstat (limited to 'drivers/media/video/omap3isp/ispstat.c')
-rw-r--r-- | drivers/media/video/omap3isp/ispstat.c | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/drivers/media/video/omap3isp/ispstat.c b/drivers/media/video/omap3isp/ispstat.c index 732905552261..68d539456c55 100644 --- a/drivers/media/video/omap3isp/ispstat.c +++ b/drivers/media/video/omap3isp/ispstat.c | |||
@@ -1023,24 +1023,6 @@ void omap3isp_stat_dma_isr(struct ispstat *stat) | |||
1023 | __stat_isr(stat, 1); | 1023 | __stat_isr(stat, 1); |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | static int isp_stat_init_entities(struct ispstat *stat, const char *name, | ||
1027 | const struct v4l2_subdev_ops *sd_ops) | ||
1028 | { | ||
1029 | struct v4l2_subdev *subdev = &stat->subdev; | ||
1030 | struct media_entity *me = &subdev->entity; | ||
1031 | |||
1032 | v4l2_subdev_init(subdev, sd_ops); | ||
1033 | snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "OMAP3 ISP %s", name); | ||
1034 | subdev->grp_id = 1 << 16; /* group ID for isp subdevs */ | ||
1035 | subdev->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE; | ||
1036 | v4l2_set_subdevdata(subdev, stat); | ||
1037 | |||
1038 | stat->pad.flags = MEDIA_PAD_FL_SINK; | ||
1039 | me->ops = NULL; | ||
1040 | |||
1041 | return media_entity_init(me, 1, &stat->pad, 0); | ||
1042 | } | ||
1043 | |||
1044 | int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, | 1026 | int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, |
1045 | struct v4l2_fh *fh, | 1027 | struct v4l2_fh *fh, |
1046 | struct v4l2_event_subscription *sub) | 1028 | struct v4l2_event_subscription *sub) |
@@ -1062,7 +1044,6 @@ int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev, | |||
1062 | 1044 | ||
1063 | void omap3isp_stat_unregister_entities(struct ispstat *stat) | 1045 | void omap3isp_stat_unregister_entities(struct ispstat *stat) |
1064 | { | 1046 | { |
1065 | media_entity_cleanup(&stat->subdev.entity); | ||
1066 | v4l2_device_unregister_subdev(&stat->subdev); | 1047 | v4l2_device_unregister_subdev(&stat->subdev); |
1067 | } | 1048 | } |
1068 | 1049 | ||
@@ -1072,21 +1053,50 @@ int omap3isp_stat_register_entities(struct ispstat *stat, | |||
1072 | return v4l2_device_register_subdev(vdev, &stat->subdev); | 1053 | return v4l2_device_register_subdev(vdev, &stat->subdev); |
1073 | } | 1054 | } |
1074 | 1055 | ||
1056 | static int isp_stat_init_entities(struct ispstat *stat, const char *name, | ||
1057 | const struct v4l2_subdev_ops *sd_ops) | ||
1058 | { | ||
1059 | struct v4l2_subdev *subdev = &stat->subdev; | ||
1060 | struct media_entity *me = &subdev->entity; | ||
1061 | |||
1062 | v4l2_subdev_init(subdev, sd_ops); | ||
1063 | snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "OMAP3 ISP %s", name); | ||
1064 | subdev->grp_id = 1 << 16; /* group ID for isp subdevs */ | ||
1065 | subdev->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE; | ||
1066 | v4l2_set_subdevdata(subdev, stat); | ||
1067 | |||
1068 | stat->pad.flags = MEDIA_PAD_FL_SINK; | ||
1069 | me->ops = NULL; | ||
1070 | |||
1071 | return media_entity_init(me, 1, &stat->pad, 0); | ||
1072 | } | ||
1073 | |||
1075 | int omap3isp_stat_init(struct ispstat *stat, const char *name, | 1074 | int omap3isp_stat_init(struct ispstat *stat, const char *name, |
1076 | const struct v4l2_subdev_ops *sd_ops) | 1075 | const struct v4l2_subdev_ops *sd_ops) |
1077 | { | 1076 | { |
1077 | int ret; | ||
1078 | |||
1078 | stat->buf = kcalloc(STAT_MAX_BUFS, sizeof(*stat->buf), GFP_KERNEL); | 1079 | stat->buf = kcalloc(STAT_MAX_BUFS, sizeof(*stat->buf), GFP_KERNEL); |
1079 | if (!stat->buf) | 1080 | if (!stat->buf) |
1080 | return -ENOMEM; | 1081 | return -ENOMEM; |
1082 | |||
1081 | isp_stat_buf_clear(stat); | 1083 | isp_stat_buf_clear(stat); |
1082 | mutex_init(&stat->ioctl_lock); | 1084 | mutex_init(&stat->ioctl_lock); |
1083 | atomic_set(&stat->buf_err, 0); | 1085 | atomic_set(&stat->buf_err, 0); |
1084 | 1086 | ||
1085 | return isp_stat_init_entities(stat, name, sd_ops); | 1087 | ret = isp_stat_init_entities(stat, name, sd_ops); |
1088 | if (ret < 0) { | ||
1089 | mutex_destroy(&stat->ioctl_lock); | ||
1090 | kfree(stat->buf); | ||
1091 | } | ||
1092 | |||
1093 | return ret; | ||
1086 | } | 1094 | } |
1087 | 1095 | ||
1088 | void omap3isp_stat_free(struct ispstat *stat) | 1096 | void omap3isp_stat_cleanup(struct ispstat *stat) |
1089 | { | 1097 | { |
1098 | media_entity_cleanup(&stat->subdev.entity); | ||
1099 | mutex_destroy(&stat->ioctl_lock); | ||
1090 | isp_stat_bufs_free(stat); | 1100 | isp_stat_bufs_free(stat); |
1091 | kfree(stat->buf); | 1101 | kfree(stat->buf); |
1092 | } | 1102 | } |