diff options
Diffstat (limited to 'extras/recipes-kernel/linux/linux-omap/media/0024-v4l-Create-v4l2-subdev-file-handle-structure.patch')
-rw-r--r-- | extras/recipes-kernel/linux/linux-omap/media/0024-v4l-Create-v4l2-subdev-file-handle-structure.patch | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/extras/recipes-kernel/linux/linux-omap/media/0024-v4l-Create-v4l2-subdev-file-handle-structure.patch b/extras/recipes-kernel/linux/linux-omap/media/0024-v4l-Create-v4l2-subdev-file-handle-structure.patch new file mode 100644 index 00000000..726af5d0 --- /dev/null +++ b/extras/recipes-kernel/linux/linux-omap/media/0024-v4l-Create-v4l2-subdev-file-handle-structure.patch | |||
@@ -0,0 +1,243 @@ | |||
1 | From 47f7677adda05f6d85a35047c4aac940c46a123c Mon Sep 17 00:00:00 2001 | ||
2 | From: Stanimir Varbanov <svarbanov@mm-sol.com> | ||
3 | Date: Fri, 21 May 2010 12:04:24 +0300 | ||
4 | Subject: [PATCH 24/43] v4l: Create v4l2 subdev file handle structure | ||
5 | |||
6 | Used for storing subdev information per file handle and hold V4L2 file | ||
7 | handle. | ||
8 | |||
9 | Signed-off-by: Stanimir Varbanov <svarbanov@mm-sol.com> | ||
10 | Signed-off-by: Antti Koskipaa <antti.koskipaa@nokia.com> | ||
11 | Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
12 | --- | ||
13 | drivers/media/Kconfig | 9 ++++ | ||
14 | drivers/media/video/v4l2-subdev.c | 85 +++++++++++++++++++++++++------------ | ||
15 | include/media/v4l2-subdev.h | 29 +++++++++++++ | ||
16 | 3 files changed, 96 insertions(+), 27 deletions(-) | ||
17 | |||
18 | diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig | ||
19 | index 6b946e6..eaf4734 100644 | ||
20 | --- a/drivers/media/Kconfig | ||
21 | +++ b/drivers/media/Kconfig | ||
22 | @@ -82,6 +82,15 @@ config VIDEO_V4L1_COMPAT | ||
23 | |||
24 | If you are unsure as to whether this is required, answer Y. | ||
25 | |||
26 | +config VIDEO_V4L2_SUBDEV_API | ||
27 | + bool "V4L2 sub-device userspace API (EXPERIMENTAL)" | ||
28 | + depends on VIDEO_DEV && MEDIA_CONTROLLER && EXPERIMENTAL | ||
29 | + ---help--- | ||
30 | + Enables the V4L2 sub-device pad-level userspace API used to configure | ||
31 | + video format, size and frame rate between hardware blocks. | ||
32 | + | ||
33 | + This API is mostly used by camera interfaces in embedded platforms. | ||
34 | + | ||
35 | # | ||
36 | # DVB Core | ||
37 | # | ||
38 | diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c | ||
39 | index a49856a..15449fc 100644 | ||
40 | --- a/drivers/media/video/v4l2-subdev.c | ||
41 | +++ b/drivers/media/video/v4l2-subdev.c | ||
42 | @@ -31,39 +31,69 @@ | ||
43 | #include <media/v4l2-fh.h> | ||
44 | #include <media/v4l2-event.h> | ||
45 | |||
46 | +static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd) | ||
47 | +{ | ||
48 | +#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) | ||
49 | + /* Allocate try format and crop in the same memory block */ | ||
50 | + fh->try_fmt = kzalloc((sizeof(*fh->try_fmt) + sizeof(*fh->try_crop)) | ||
51 | + * sd->entity.num_pads, GFP_KERNEL); | ||
52 | + if (fh->try_fmt == NULL) | ||
53 | + return -ENOMEM; | ||
54 | + | ||
55 | + fh->try_crop = (struct v4l2_rect *) | ||
56 | + (fh->try_fmt + sd->entity.num_pads); | ||
57 | +#endif | ||
58 | + return 0; | ||
59 | +} | ||
60 | + | ||
61 | +static void subdev_fh_free(struct v4l2_subdev_fh *fh) | ||
62 | +{ | ||
63 | +#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) | ||
64 | + kfree(fh->try_fmt); | ||
65 | + fh->try_fmt = NULL; | ||
66 | + fh->try_crop = NULL; | ||
67 | +#endif | ||
68 | +} | ||
69 | + | ||
70 | static int subdev_open(struct file *file) | ||
71 | { | ||
72 | struct video_device *vdev = video_devdata(file); | ||
73 | struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); | ||
74 | + struct v4l2_subdev_fh *subdev_fh; | ||
75 | #if defined(CONFIG_MEDIA_CONTROLLER) | ||
76 | struct media_entity *entity; | ||
77 | #endif | ||
78 | - struct v4l2_fh *vfh = NULL; | ||
79 | int ret; | ||
80 | |||
81 | if (!sd->initialized) | ||
82 | return -EAGAIN; | ||
83 | |||
84 | - if (sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS) { | ||
85 | - vfh = kzalloc(sizeof(*vfh), GFP_KERNEL); | ||
86 | - if (vfh == NULL) | ||
87 | - return -ENOMEM; | ||
88 | + subdev_fh = kzalloc(sizeof(*subdev_fh), GFP_KERNEL); | ||
89 | + if (subdev_fh == NULL) | ||
90 | + return -ENOMEM; | ||
91 | |||
92 | - ret = v4l2_fh_init(vfh, vdev); | ||
93 | - if (ret) | ||
94 | - goto err; | ||
95 | + ret = subdev_fh_init(subdev_fh, sd); | ||
96 | + if (ret) { | ||
97 | + kfree(subdev_fh); | ||
98 | + return ret; | ||
99 | + } | ||
100 | + | ||
101 | + ret = v4l2_fh_init(&subdev_fh->vfh, vdev); | ||
102 | + if (ret) | ||
103 | + goto err; | ||
104 | |||
105 | - ret = v4l2_event_init(vfh); | ||
106 | + if (sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS) { | ||
107 | + ret = v4l2_event_init(&subdev_fh->vfh); | ||
108 | if (ret) | ||
109 | goto err; | ||
110 | |||
111 | - ret = v4l2_event_alloc(vfh, sd->nevents); | ||
112 | + ret = v4l2_event_alloc(&subdev_fh->vfh, sd->nevents); | ||
113 | if (ret) | ||
114 | goto err; | ||
115 | - | ||
116 | - v4l2_fh_add(vfh); | ||
117 | - file->private_data = vfh; | ||
118 | } | ||
119 | + | ||
120 | + v4l2_fh_add(&subdev_fh->vfh); | ||
121 | + file->private_data = &subdev_fh->vfh; | ||
122 | #if defined(CONFIG_MEDIA_CONTROLLER) | ||
123 | if (sd->v4l2_dev->mdev) { | ||
124 | entity = media_entity_get(&sd->entity); | ||
125 | @@ -73,14 +103,14 @@ static int subdev_open(struct file *file) | ||
126 | } | ||
127 | } | ||
128 | #endif | ||
129 | + | ||
130 | return 0; | ||
131 | |||
132 | err: | ||
133 | - if (vfh != NULL) { | ||
134 | - v4l2_fh_del(vfh); | ||
135 | - v4l2_fh_exit(vfh); | ||
136 | - kfree(vfh); | ||
137 | - } | ||
138 | + v4l2_fh_del(&subdev_fh->vfh); | ||
139 | + v4l2_fh_exit(&subdev_fh->vfh); | ||
140 | + subdev_fh_free(subdev_fh); | ||
141 | + kfree(subdev_fh); | ||
142 | |||
143 | return ret; | ||
144 | } | ||
145 | @@ -92,16 +122,17 @@ static int subdev_close(struct file *file) | ||
146 | struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); | ||
147 | #endif | ||
148 | struct v4l2_fh *vfh = file->private_data; | ||
149 | + struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh); | ||
150 | |||
151 | #if defined(CONFIG_MEDIA_CONTROLLER) | ||
152 | if (sd->v4l2_dev->mdev) | ||
153 | media_entity_put(&sd->entity); | ||
154 | #endif | ||
155 | - if (vfh != NULL) { | ||
156 | - v4l2_fh_del(vfh); | ||
157 | - v4l2_fh_exit(vfh); | ||
158 | - kfree(vfh); | ||
159 | - } | ||
160 | + v4l2_fh_del(vfh); | ||
161 | + v4l2_fh_exit(vfh); | ||
162 | + subdev_fh_free(subdev_fh); | ||
163 | + kfree(subdev_fh); | ||
164 | + file->private_data = NULL; | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | @@ -110,7 +141,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) | ||
169 | { | ||
170 | struct video_device *vdev = video_devdata(file); | ||
171 | struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); | ||
172 | - struct v4l2_fh *fh = file->private_data; | ||
173 | + struct v4l2_fh *vfh = file->private_data; | ||
174 | |||
175 | switch (cmd) { | ||
176 | case VIDIOC_QUERYCTRL: | ||
177 | @@ -138,13 +169,13 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) | ||
178 | if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) | ||
179 | return -ENOIOCTLCMD; | ||
180 | |||
181 | - return v4l2_event_dequeue(fh, arg, file->f_flags & O_NONBLOCK); | ||
182 | + return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK); | ||
183 | |||
184 | case VIDIOC_SUBSCRIBE_EVENT: | ||
185 | - return v4l2_subdev_call(sd, core, subscribe_event, fh, arg); | ||
186 | + return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg); | ||
187 | |||
188 | case VIDIOC_UNSUBSCRIBE_EVENT: | ||
189 | - return v4l2_subdev_call(sd, core, unsubscribe_event, fh, arg); | ||
190 | + return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg); | ||
191 | |||
192 | default: | ||
193 | return -ENOIOCTLCMD; | ||
194 | diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h | ||
195 | index 7d55b0c..f8704ff 100644 | ||
196 | --- a/include/media/v4l2-subdev.h | ||
197 | +++ b/include/media/v4l2-subdev.h | ||
198 | @@ -24,6 +24,7 @@ | ||
199 | #include <media/media-entity.h> | ||
200 | #include <media/v4l2-common.h> | ||
201 | #include <media/v4l2-dev.h> | ||
202 | +#include <media/v4l2-fh.h> | ||
203 | #include <media/v4l2-mediabus.h> | ||
204 | |||
205 | /* generic v4l2_device notify callback notification values */ | ||
206 | @@ -467,6 +468,34 @@ struct v4l2_subdev { | ||
207 | #define vdev_to_v4l2_subdev(vdev) \ | ||
208 | container_of(vdev, struct v4l2_subdev, devnode) | ||
209 | |||
210 | +/* | ||
211 | + * Used for storing subdev information per file handle | ||
212 | + */ | ||
213 | +struct v4l2_subdev_fh { | ||
214 | + struct v4l2_fh vfh; | ||
215 | +#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) | ||
216 | + struct v4l2_mbus_framefmt *try_fmt; | ||
217 | + struct v4l2_rect *try_crop; | ||
218 | +#endif | ||
219 | +}; | ||
220 | + | ||
221 | +#define to_v4l2_subdev_fh(fh) \ | ||
222 | + container_of(fh, struct v4l2_subdev_fh, vfh) | ||
223 | + | ||
224 | +#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) | ||
225 | +static inline struct v4l2_mbus_framefmt * | ||
226 | +v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad) | ||
227 | +{ | ||
228 | + return &fh->try_fmt[pad]; | ||
229 | +} | ||
230 | + | ||
231 | +static inline struct v4l2_rect * | ||
232 | +v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh, unsigned int pad) | ||
233 | +{ | ||
234 | + return &fh->try_crop[pad]; | ||
235 | +} | ||
236 | +#endif | ||
237 | + | ||
238 | extern const struct v4l2_file_operations v4l2_subdev_fops; | ||
239 | |||
240 | static inline void v4l2_set_subdevdata(struct v4l2_subdev *sd, void *p) | ||
241 | -- | ||
242 | 1.6.6.1 | ||
243 | |||