Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 1 | /* |
Laurent Pinchart | 3dd5ee0 | 2009-12-09 08:38:52 -0300 | [diff] [blame] | 2 | * V4L2 sub-device |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 3 | * |
Laurent Pinchart | 3dd5ee0 | 2009-12-09 08:38:52 -0300 | [diff] [blame] | 4 | * Copyright (C) 2010 Nokia Corporation |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 5 | * |
Laurent Pinchart | 3dd5ee0 | 2009-12-09 08:38:52 -0300 | [diff] [blame] | 6 | * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com> |
| 7 | * Sakari Ailus <sakari.ailus@iki.fi> |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 8 | * |
Laurent Pinchart | 3dd5ee0 | 2009-12-09 08:38:52 -0300 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 12 | * |
Laurent Pinchart | 3dd5ee0 | 2009-12-09 08:38:52 -0300 | [diff] [blame] | 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 17 | * |
Laurent Pinchart | 3dd5ee0 | 2009-12-09 08:38:52 -0300 | [diff] [blame] | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 21 | */ |
| 22 | |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 23 | #include <linux/ioctl.h> |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 24 | #include <linux/slab.h> |
| 25 | #include <linux/types.h> |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 26 | #include <linux/videodev2.h> |
| 27 | |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 28 | #include <media/v4l2-ctrls.h> |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 29 | #include <media/v4l2-device.h> |
| 30 | #include <media/v4l2-ioctl.h> |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 31 | #include <media/v4l2-fh.h> |
| 32 | #include <media/v4l2-event.h> |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 33 | |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 34 | static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd) |
| 35 | { |
| 36 | #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) |
| 37 | /* Allocate try format and crop in the same memory block */ |
| 38 | fh->try_fmt = kzalloc((sizeof(*fh->try_fmt) + sizeof(*fh->try_crop)) |
| 39 | * sd->entity.num_pads, GFP_KERNEL); |
| 40 | if (fh->try_fmt == NULL) |
| 41 | return -ENOMEM; |
| 42 | |
| 43 | fh->try_crop = (struct v4l2_rect *) |
| 44 | (fh->try_fmt + sd->entity.num_pads); |
| 45 | #endif |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | static void subdev_fh_free(struct v4l2_subdev_fh *fh) |
| 50 | { |
| 51 | #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) |
| 52 | kfree(fh->try_fmt); |
| 53 | fh->try_fmt = NULL; |
| 54 | fh->try_crop = NULL; |
| 55 | #endif |
| 56 | } |
| 57 | |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 58 | static int subdev_open(struct file *file) |
| 59 | { |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 60 | struct video_device *vdev = video_devdata(file); |
| 61 | struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 62 | struct v4l2_subdev_fh *subdev_fh; |
Laurent Pinchart | 61f5db5 | 2009-12-09 08:40:08 -0300 | [diff] [blame] | 63 | #if defined(CONFIG_MEDIA_CONTROLLER) |
Laurent Pinchart | f0beea8 | 2010-08-01 19:05:09 -0300 | [diff] [blame] | 64 | struct media_entity *entity = NULL; |
Laurent Pinchart | 61f5db5 | 2009-12-09 08:40:08 -0300 | [diff] [blame] | 65 | #endif |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 66 | int ret; |
| 67 | |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 68 | subdev_fh = kzalloc(sizeof(*subdev_fh), GFP_KERNEL); |
| 69 | if (subdev_fh == NULL) |
| 70 | return -ENOMEM; |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 71 | |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 72 | ret = subdev_fh_init(subdev_fh, sd); |
| 73 | if (ret) { |
| 74 | kfree(subdev_fh); |
| 75 | return ret; |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 76 | } |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 77 | |
| 78 | ret = v4l2_fh_init(&subdev_fh->vfh, vdev); |
| 79 | if (ret) |
| 80 | goto err; |
| 81 | |
| 82 | if (sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS) { |
| 83 | ret = v4l2_event_init(&subdev_fh->vfh); |
| 84 | if (ret) |
| 85 | goto err; |
| 86 | |
| 87 | ret = v4l2_event_alloc(&subdev_fh->vfh, sd->nevents); |
| 88 | if (ret) |
| 89 | goto err; |
| 90 | } |
| 91 | |
| 92 | v4l2_fh_add(&subdev_fh->vfh); |
| 93 | file->private_data = &subdev_fh->vfh; |
Laurent Pinchart | 61f5db5 | 2009-12-09 08:40:08 -0300 | [diff] [blame] | 94 | #if defined(CONFIG_MEDIA_CONTROLLER) |
| 95 | if (sd->v4l2_dev->mdev) { |
| 96 | entity = media_entity_get(&sd->entity); |
| 97 | if (!entity) { |
| 98 | ret = -EBUSY; |
| 99 | goto err; |
| 100 | } |
| 101 | } |
| 102 | #endif |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 103 | |
Laurent Pinchart | f0beea8 | 2010-08-01 19:05:09 -0300 | [diff] [blame] | 104 | if (sd->internal_ops && sd->internal_ops->open) { |
| 105 | ret = sd->internal_ops->open(sd, subdev_fh); |
| 106 | if (ret < 0) |
| 107 | goto err; |
| 108 | } |
| 109 | |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 110 | return 0; |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 111 | |
| 112 | err: |
Laurent Pinchart | f0beea8 | 2010-08-01 19:05:09 -0300 | [diff] [blame] | 113 | #if defined(CONFIG_MEDIA_CONTROLLER) |
| 114 | if (entity) |
| 115 | media_entity_put(entity); |
| 116 | #endif |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 117 | v4l2_fh_del(&subdev_fh->vfh); |
| 118 | v4l2_fh_exit(&subdev_fh->vfh); |
| 119 | subdev_fh_free(subdev_fh); |
| 120 | kfree(subdev_fh); |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 121 | |
| 122 | return ret; |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | static int subdev_close(struct file *file) |
| 126 | { |
Laurent Pinchart | 61f5db5 | 2009-12-09 08:40:08 -0300 | [diff] [blame] | 127 | struct video_device *vdev = video_devdata(file); |
| 128 | struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 129 | struct v4l2_fh *vfh = file->private_data; |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 130 | struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh); |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 131 | |
Laurent Pinchart | f0beea8 | 2010-08-01 19:05:09 -0300 | [diff] [blame] | 132 | if (sd->internal_ops && sd->internal_ops->close) |
| 133 | sd->internal_ops->close(sd, subdev_fh); |
Laurent Pinchart | 61f5db5 | 2009-12-09 08:40:08 -0300 | [diff] [blame] | 134 | #if defined(CONFIG_MEDIA_CONTROLLER) |
| 135 | if (sd->v4l2_dev->mdev) |
| 136 | media_entity_put(&sd->entity); |
| 137 | #endif |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 138 | v4l2_fh_del(vfh); |
| 139 | v4l2_fh_exit(vfh); |
| 140 | subdev_fh_free(subdev_fh); |
| 141 | kfree(subdev_fh); |
| 142 | file->private_data = NULL; |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 143 | |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) |
| 148 | { |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 149 | struct video_device *vdev = video_devdata(file); |
| 150 | struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 151 | struct v4l2_fh *vfh = file->private_data; |
Laurent Pinchart | 333c8b9 | 2010-03-15 20:26:04 -0300 | [diff] [blame] | 152 | #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) |
| 153 | struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh); |
| 154 | #endif |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 155 | |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 156 | switch (cmd) { |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 157 | case VIDIOC_QUERYCTRL: |
Hans Verkuil | 0b84834 | 2011-05-02 08:09:25 -0300 | [diff] [blame^] | 158 | return v4l2_queryctrl(sd->ctrl_handler, arg); |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 159 | |
| 160 | case VIDIOC_QUERYMENU: |
Hans Verkuil | 0b84834 | 2011-05-02 08:09:25 -0300 | [diff] [blame^] | 161 | return v4l2_querymenu(sd->ctrl_handler, arg); |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 162 | |
| 163 | case VIDIOC_G_CTRL: |
Hans Verkuil | 0b84834 | 2011-05-02 08:09:25 -0300 | [diff] [blame^] | 164 | return v4l2_g_ctrl(sd->ctrl_handler, arg); |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 165 | |
| 166 | case VIDIOC_S_CTRL: |
Hans Verkuil | 0b84834 | 2011-05-02 08:09:25 -0300 | [diff] [blame^] | 167 | return v4l2_s_ctrl(sd->ctrl_handler, arg); |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 168 | |
| 169 | case VIDIOC_G_EXT_CTRLS: |
Hans Verkuil | 0b84834 | 2011-05-02 08:09:25 -0300 | [diff] [blame^] | 170 | return v4l2_g_ext_ctrls(sd->ctrl_handler, arg); |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 171 | |
| 172 | case VIDIOC_S_EXT_CTRLS: |
Hans Verkuil | 0b84834 | 2011-05-02 08:09:25 -0300 | [diff] [blame^] | 173 | return v4l2_s_ext_ctrls(sd->ctrl_handler, arg); |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 174 | |
| 175 | case VIDIOC_TRY_EXT_CTRLS: |
Hans Verkuil | 0b84834 | 2011-05-02 08:09:25 -0300 | [diff] [blame^] | 176 | return v4l2_try_ext_ctrls(sd->ctrl_handler, arg); |
Laurent Pinchart | ea8aa43 | 2009-12-09 08:39:54 -0300 | [diff] [blame] | 177 | |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 178 | case VIDIOC_DQEVENT: |
| 179 | if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) |
| 180 | return -ENOIOCTLCMD; |
| 181 | |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 182 | return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK); |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 183 | |
| 184 | case VIDIOC_SUBSCRIBE_EVENT: |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 185 | return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg); |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 186 | |
| 187 | case VIDIOC_UNSUBSCRIBE_EVENT: |
Stanimir Varbanov | 7cd5a16 | 2010-05-21 06:04:24 -0300 | [diff] [blame] | 188 | return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg); |
Laurent Pinchart | 333c8b9 | 2010-03-15 20:26:04 -0300 | [diff] [blame] | 189 | #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) |
| 190 | case VIDIOC_SUBDEV_G_FMT: { |
| 191 | struct v4l2_subdev_format *format = arg; |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 192 | |
Laurent Pinchart | 333c8b9 | 2010-03-15 20:26:04 -0300 | [diff] [blame] | 193 | if (format->which != V4L2_SUBDEV_FORMAT_TRY && |
| 194 | format->which != V4L2_SUBDEV_FORMAT_ACTIVE) |
| 195 | return -EINVAL; |
| 196 | |
| 197 | if (format->pad >= sd->entity.num_pads) |
| 198 | return -EINVAL; |
| 199 | |
| 200 | return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh, format); |
| 201 | } |
| 202 | |
| 203 | case VIDIOC_SUBDEV_S_FMT: { |
| 204 | struct v4l2_subdev_format *format = arg; |
| 205 | |
| 206 | if (format->which != V4L2_SUBDEV_FORMAT_TRY && |
| 207 | format->which != V4L2_SUBDEV_FORMAT_ACTIVE) |
| 208 | return -EINVAL; |
| 209 | |
| 210 | if (format->pad >= sd->entity.num_pads) |
| 211 | return -EINVAL; |
| 212 | |
| 213 | return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh, format); |
| 214 | } |
| 215 | |
Antti Koskipaa | f6a5cb1 | 2010-06-23 05:03:42 -0300 | [diff] [blame] | 216 | case VIDIOC_SUBDEV_G_CROP: { |
| 217 | struct v4l2_subdev_crop *crop = arg; |
| 218 | |
| 219 | if (crop->which != V4L2_SUBDEV_FORMAT_TRY && |
| 220 | crop->which != V4L2_SUBDEV_FORMAT_ACTIVE) |
| 221 | return -EINVAL; |
| 222 | |
| 223 | if (crop->pad >= sd->entity.num_pads) |
| 224 | return -EINVAL; |
| 225 | |
| 226 | return v4l2_subdev_call(sd, pad, get_crop, subdev_fh, crop); |
| 227 | } |
| 228 | |
| 229 | case VIDIOC_SUBDEV_S_CROP: { |
| 230 | struct v4l2_subdev_crop *crop = arg; |
| 231 | |
| 232 | if (crop->which != V4L2_SUBDEV_FORMAT_TRY && |
| 233 | crop->which != V4L2_SUBDEV_FORMAT_ACTIVE) |
| 234 | return -EINVAL; |
| 235 | |
| 236 | if (crop->pad >= sd->entity.num_pads) |
| 237 | return -EINVAL; |
| 238 | |
| 239 | return v4l2_subdev_call(sd, pad, set_crop, subdev_fh, crop); |
| 240 | } |
| 241 | |
Laurent Pinchart | 333c8b9 | 2010-03-15 20:26:04 -0300 | [diff] [blame] | 242 | case VIDIOC_SUBDEV_ENUM_MBUS_CODE: { |
| 243 | struct v4l2_subdev_mbus_code_enum *code = arg; |
| 244 | |
| 245 | if (code->pad >= sd->entity.num_pads) |
| 246 | return -EINVAL; |
| 247 | |
| 248 | return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh, |
| 249 | code); |
| 250 | } |
| 251 | |
| 252 | case VIDIOC_SUBDEV_ENUM_FRAME_SIZE: { |
| 253 | struct v4l2_subdev_frame_size_enum *fse = arg; |
| 254 | |
| 255 | if (fse->pad >= sd->entity.num_pads) |
| 256 | return -EINVAL; |
| 257 | |
| 258 | return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh, |
| 259 | fse); |
| 260 | } |
Laurent Pinchart | 35c3017 | 2010-05-05 11:38:35 -0300 | [diff] [blame] | 261 | |
| 262 | case VIDIOC_SUBDEV_G_FRAME_INTERVAL: |
| 263 | return v4l2_subdev_call(sd, video, g_frame_interval, arg); |
| 264 | |
| 265 | case VIDIOC_SUBDEV_S_FRAME_INTERVAL: |
| 266 | return v4l2_subdev_call(sd, video, s_frame_interval, arg); |
| 267 | |
| 268 | case VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL: { |
| 269 | struct v4l2_subdev_frame_interval_enum *fie = arg; |
| 270 | |
| 271 | if (fie->pad >= sd->entity.num_pads) |
| 272 | return -EINVAL; |
| 273 | |
| 274 | return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh, |
| 275 | fie); |
| 276 | } |
Laurent Pinchart | 333c8b9 | 2010-03-15 20:26:04 -0300 | [diff] [blame] | 277 | #endif |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 278 | default: |
Laurent Pinchart | c30b46e | 2010-02-26 12:23:10 -0300 | [diff] [blame] | 279 | return v4l2_subdev_call(sd, core, ioctl, cmd, arg); |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | static long subdev_ioctl(struct file *file, unsigned int cmd, |
| 286 | unsigned long arg) |
| 287 | { |
| 288 | return video_usercopy(file, cmd, arg, subdev_do_ioctl); |
| 289 | } |
| 290 | |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 291 | static unsigned int subdev_poll(struct file *file, poll_table *wait) |
| 292 | { |
| 293 | struct video_device *vdev = video_devdata(file); |
| 294 | struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); |
| 295 | struct v4l2_fh *fh = file->private_data; |
| 296 | |
| 297 | if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) |
| 298 | return POLLERR; |
| 299 | |
| 300 | poll_wait(file, &fh->events->wait, wait); |
| 301 | |
| 302 | if (v4l2_event_pending(fh)) |
| 303 | return POLLPRI; |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 308 | const struct v4l2_file_operations v4l2_subdev_fops = { |
| 309 | .owner = THIS_MODULE, |
| 310 | .open = subdev_open, |
| 311 | .unlocked_ioctl = subdev_ioctl, |
| 312 | .release = subdev_close, |
Sakari Ailus | 02adb1c | 2010-03-03 12:49:38 -0300 | [diff] [blame] | 313 | .poll = subdev_poll, |
Laurent Pinchart | 2096a5d | 2009-12-09 08:38:49 -0300 | [diff] [blame] | 314 | }; |
Laurent Pinchart | 3dd5ee0 | 2009-12-09 08:38:52 -0300 | [diff] [blame] | 315 | |
| 316 | void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) |
| 317 | { |
| 318 | INIT_LIST_HEAD(&sd->list); |
| 319 | BUG_ON(!ops); |
| 320 | sd->ops = ops; |
| 321 | sd->v4l2_dev = NULL; |
| 322 | sd->flags = 0; |
| 323 | sd->name[0] = '\0'; |
| 324 | sd->grp_id = 0; |
| 325 | sd->dev_priv = NULL; |
| 326 | sd->host_priv = NULL; |
Laurent Pinchart | 61f5db5 | 2009-12-09 08:40:08 -0300 | [diff] [blame] | 327 | #if defined(CONFIG_MEDIA_CONTROLLER) |
| 328 | sd->entity.name = sd->name; |
| 329 | sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; |
| 330 | #endif |
Laurent Pinchart | 3dd5ee0 | 2009-12-09 08:38:52 -0300 | [diff] [blame] | 331 | } |
| 332 | EXPORT_SYMBOL(v4l2_subdev_init); |