diff options
author | Andy Walls <awalls@radix.net> | 2008-06-21 07:36:31 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:10:43 -0400 |
commit | 3b6fe58f0f18880200969e813d0181d1bdab0966 (patch) | |
tree | e059efc521b5eeb2b0f022f7c7e56d3a8f3b7a86 /drivers/media/video/cx18/cx18-controls.c | |
parent | 1a05221bc45ccb1b5c583a87dc3639bfc10c4f10 (diff) |
V4L/DVB (8082): cx18: convert to video_ioctl2()
cx18: convert driver to use video_ioctl2(). Pushed down ioctl debug
messages and priority checks as well. Still left serialization lock in
place for now. #if 0'ed out sliced vbi ioctl code for now.
Patch heavily based on similar changes made to ivtv by Hans Verkuil.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx18/cx18-controls.c')
-rw-r--r-- | drivers/media/video/cx18/cx18-controls.c | 195 |
1 files changed, 97 insertions, 98 deletions
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c index 87cf41021665..6eae75f4ee7c 100644 --- a/drivers/media/video/cx18/cx18-controls.c +++ b/drivers/media/video/cx18/cx18-controls.c | |||
@@ -51,8 +51,9 @@ static const u32 *ctrl_classes[] = { | |||
51 | NULL | 51 | NULL |
52 | }; | 52 | }; |
53 | 53 | ||
54 | static int cx18_queryctrl(struct cx18 *cx, struct v4l2_queryctrl *qctrl) | 54 | int cx18_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl) |
55 | { | 55 | { |
56 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | ||
56 | const char *name; | 57 | const char *name; |
57 | 58 | ||
58 | CX18_DEBUG_IOCTL("VIDIOC_QUERYCTRL(%08x)\n", qctrl->id); | 59 | CX18_DEBUG_IOCTL("VIDIOC_QUERYCTRL(%08x)\n", qctrl->id); |
@@ -91,19 +92,28 @@ static int cx18_queryctrl(struct cx18 *cx, struct v4l2_queryctrl *qctrl) | |||
91 | return 0; | 92 | return 0; |
92 | } | 93 | } |
93 | 94 | ||
94 | static int cx18_querymenu(struct cx18 *cx, struct v4l2_querymenu *qmenu) | 95 | int cx18_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qmenu) |
95 | { | 96 | { |
97 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | ||
96 | struct v4l2_queryctrl qctrl; | 98 | struct v4l2_queryctrl qctrl; |
97 | 99 | ||
100 | CX18_DEBUG_IOCTL("VIDIOC_QUERYMENU\n"); | ||
98 | qctrl.id = qmenu->id; | 101 | qctrl.id = qmenu->id; |
99 | cx18_queryctrl(cx, &qctrl); | 102 | cx18_queryctrl(file, fh, &qctrl); |
100 | return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id)); | 103 | return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id)); |
101 | } | 104 | } |
102 | 105 | ||
103 | static int cx18_s_ctrl(struct cx18 *cx, struct v4l2_control *vctrl) | 106 | int cx18_s_ctrl(struct file *file, void *fh, struct v4l2_control *vctrl) |
104 | { | 107 | { |
108 | struct cx18_open_id *id = fh; | ||
109 | struct cx18 *cx = id->cx; | ||
110 | int ret; | ||
105 | s32 v = vctrl->value; | 111 | s32 v = vctrl->value; |
106 | 112 | ||
113 | ret = v4l2_prio_check(&cx->prio, &id->prio); | ||
114 | if (ret) | ||
115 | return ret; | ||
116 | |||
107 | CX18_DEBUG_IOCTL("VIDIOC_S_CTRL(%08x, %x)\n", vctrl->id, v); | 117 | CX18_DEBUG_IOCTL("VIDIOC_S_CTRL(%08x, %x)\n", vctrl->id, v); |
108 | 118 | ||
109 | switch (vctrl->id) { | 119 | switch (vctrl->id) { |
@@ -129,8 +139,10 @@ static int cx18_s_ctrl(struct cx18 *cx, struct v4l2_control *vctrl) | |||
129 | return 0; | 139 | return 0; |
130 | } | 140 | } |
131 | 141 | ||
132 | static int cx18_g_ctrl(struct cx18 *cx, struct v4l2_control *vctrl) | 142 | int cx18_g_ctrl(struct file *file, void *fh, struct v4l2_control *vctrl) |
133 | { | 143 | { |
144 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | ||
145 | |||
134 | CX18_DEBUG_IOCTL("VIDIOC_G_CTRL(%08x)\n", vctrl->id); | 146 | CX18_DEBUG_IOCTL("VIDIOC_G_CTRL(%08x)\n", vctrl->id); |
135 | 147 | ||
136 | switch (vctrl->id) { | 148 | switch (vctrl->id) { |
@@ -194,113 +206,100 @@ static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt fmt | |||
194 | return 0; | 206 | return 0; |
195 | } | 207 | } |
196 | 208 | ||
197 | int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg) | 209 | int cx18_g_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c) |
198 | { | 210 | { |
211 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; | ||
199 | struct v4l2_control ctrl; | 212 | struct v4l2_control ctrl; |
200 | 213 | ||
201 | switch (cmd) { | 214 | if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { |
202 | case VIDIOC_QUERYMENU: | 215 | int i; |
203 | CX18_DEBUG_IOCTL("VIDIOC_QUERYMENU\n"); | 216 | int err = 0; |
204 | return cx18_querymenu(cx, arg); | 217 | |
205 | 218 | for (i = 0; i < c->count; i++) { | |
206 | case VIDIOC_QUERYCTRL: | 219 | ctrl.id = c->controls[i].id; |
207 | return cx18_queryctrl(cx, arg); | 220 | ctrl.value = c->controls[i].value; |
208 | 221 | err = cx18_g_ctrl(file, fh, &ctrl); | |
209 | case VIDIOC_S_CTRL: | 222 | c->controls[i].value = ctrl.value; |
210 | return cx18_s_ctrl(cx, arg); | 223 | if (err) { |
211 | 224 | c->error_idx = i; | |
212 | case VIDIOC_G_CTRL: | 225 | break; |
213 | return cx18_g_ctrl(cx, arg); | ||
214 | |||
215 | case VIDIOC_S_EXT_CTRLS: | ||
216 | { | ||
217 | struct v4l2_ext_controls *c = arg; | ||
218 | |||
219 | if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { | ||
220 | int i; | ||
221 | int err = 0; | ||
222 | |||
223 | for (i = 0; i < c->count; i++) { | ||
224 | ctrl.id = c->controls[i].id; | ||
225 | ctrl.value = c->controls[i].value; | ||
226 | err = cx18_s_ctrl(cx, &ctrl); | ||
227 | c->controls[i].value = ctrl.value; | ||
228 | if (err) { | ||
229 | c->error_idx = i; | ||
230 | break; | ||
231 | } | ||
232 | } | 226 | } |
233 | return err; | ||
234 | } | 227 | } |
235 | CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); | 228 | return err; |
236 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { | 229 | } |
237 | struct cx2341x_mpeg_params p = cx->params; | 230 | CX18_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n"); |
238 | int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->ana_capturing), arg, cmd); | 231 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) |
232 | return cx2341x_ext_ctrls(&cx->params, 0, c, VIDIOC_G_EXT_CTRLS); | ||
233 | return -EINVAL; | ||
234 | } | ||
239 | 235 | ||
240 | if (err) | 236 | int cx18_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c) |
241 | return err; | 237 | { |
238 | struct cx18_open_id *id = fh; | ||
239 | struct cx18 *cx = id->cx; | ||
240 | int ret; | ||
241 | struct v4l2_control ctrl; | ||
242 | 242 | ||
243 | if (p.video_encoding != cx->params.video_encoding) { | 243 | ret = v4l2_prio_check(&cx->prio, &id->prio); |
244 | int is_mpeg1 = p.video_encoding == | 244 | if (ret) |
245 | V4L2_MPEG_VIDEO_ENCODING_MPEG_1; | 245 | return ret; |
246 | struct v4l2_format fmt; | ||
247 | 246 | ||
248 | /* fix videodecoder resolution */ | 247 | if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { |
249 | fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 248 | int i; |
250 | fmt.fmt.pix.width = cx->params.width / (is_mpeg1 ? 2 : 1); | 249 | int err = 0; |
251 | fmt.fmt.pix.height = cx->params.height; | 250 | |
252 | cx18_av_cmd(cx, VIDIOC_S_FMT, &fmt); | 251 | for (i = 0; i < c->count; i++) { |
252 | ctrl.id = c->controls[i].id; | ||
253 | ctrl.value = c->controls[i].value; | ||
254 | err = cx18_s_ctrl(file, fh, &ctrl); | ||
255 | c->controls[i].value = ctrl.value; | ||
256 | if (err) { | ||
257 | c->error_idx = i; | ||
258 | break; | ||
253 | } | 259 | } |
254 | err = cx2341x_update(cx, cx18_api_func, &cx->params, &p); | ||
255 | if (!err && cx->params.stream_vbi_fmt != p.stream_vbi_fmt) | ||
256 | err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt); | ||
257 | cx->params = p; | ||
258 | cx->dualwatch_stereo_mode = p.audio_properties & 0x0300; | ||
259 | cx18_audio_set_audio_clock_freq(cx, p.audio_properties & 0x03); | ||
260 | return err; | ||
261 | } | 260 | } |
262 | return -EINVAL; | 261 | return err; |
263 | } | 262 | } |
263 | CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); | ||
264 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { | ||
265 | struct cx2341x_mpeg_params p = cx->params; | ||
266 | int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->ana_capturing), | ||
267 | c, VIDIOC_S_EXT_CTRLS); | ||
264 | 268 | ||
265 | case VIDIOC_G_EXT_CTRLS: | 269 | if (err) |
266 | { | ||
267 | struct v4l2_ext_controls *c = arg; | ||
268 | |||
269 | if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { | ||
270 | int i; | ||
271 | int err = 0; | ||
272 | |||
273 | for (i = 0; i < c->count; i++) { | ||
274 | ctrl.id = c->controls[i].id; | ||
275 | ctrl.value = c->controls[i].value; | ||
276 | err = cx18_g_ctrl(cx, &ctrl); | ||
277 | c->controls[i].value = ctrl.value; | ||
278 | if (err) { | ||
279 | c->error_idx = i; | ||
280 | break; | ||
281 | } | ||
282 | } | ||
283 | return err; | 270 | return err; |
284 | } | ||
285 | CX18_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n"); | ||
286 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) | ||
287 | return cx2341x_ext_ctrls(&cx->params, 0, arg, cmd); | ||
288 | return -EINVAL; | ||
289 | } | ||
290 | 271 | ||
291 | case VIDIOC_TRY_EXT_CTRLS: | 272 | if (p.video_encoding != cx->params.video_encoding) { |
292 | { | 273 | int is_mpeg1 = p.video_encoding == |
293 | struct v4l2_ext_controls *c = arg; | 274 | V4L2_MPEG_VIDEO_ENCODING_MPEG_1; |
294 | 275 | struct v4l2_format fmt; | |
295 | CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); | 276 | |
296 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) | 277 | /* fix videodecoder resolution */ |
297 | return cx2341x_ext_ctrls(&cx->params, | 278 | fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
298 | atomic_read(&cx->ana_capturing), arg, cmd); | 279 | fmt.fmt.pix.width = cx->params.width |
299 | return -EINVAL; | 280 | / (is_mpeg1 ? 2 : 1); |
281 | fmt.fmt.pix.height = cx->params.height; | ||
282 | cx18_av_cmd(cx, VIDIOC_S_FMT, &fmt); | ||
283 | } | ||
284 | err = cx2341x_update(cx, cx18_api_func, &cx->params, &p); | ||
285 | if (!err && cx->params.stream_vbi_fmt != p.stream_vbi_fmt) | ||
286 | err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt); | ||
287 | cx->params = p; | ||
288 | cx->dualwatch_stereo_mode = p.audio_properties & 0x0300; | ||
289 | cx18_audio_set_audio_clock_freq(cx, p.audio_properties & 0x03); | ||
290 | return err; | ||
300 | } | 291 | } |
292 | return -EINVAL; | ||
293 | } | ||
301 | 294 | ||
302 | default: | 295 | int cx18_try_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c) |
303 | return -EINVAL; | 296 | { |
304 | } | 297 | struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; |
305 | return 0; | 298 | |
299 | CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); | ||
300 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) | ||
301 | return cx2341x_ext_ctrls(&cx->params, | ||
302 | atomic_read(&cx->ana_capturing), | ||
303 | c, VIDIOC_TRY_EXT_CTRLS); | ||
304 | return -EINVAL; | ||
306 | } | 305 | } |