diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-01-18 17:59:11 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:24 -0400 |
commit | b960074fec573fb1b226d9e2686ce51be807cdf1 (patch) | |
tree | da58b7afa37b0ccd1c06948ad6497cb801553335 /drivers/media/video/hexium_gemini.c | |
parent | c9b8b04b267f9a7e472daa06cdf6d4963d503d1f (diff) |
V4L/DVB (10271): saa7146: convert to video_ioctl2.
The conversion to video_ioctl2 is the first phase to converting this driver
to the latest v4l2 framework.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/hexium_gemini.c')
-rw-r--r-- | drivers/media/video/hexium_gemini.c | 292 |
1 files changed, 132 insertions, 160 deletions
diff --git a/drivers/media/video/hexium_gemini.c b/drivers/media/video/hexium_gemini.c index 79393d1772e4..8e1463ee1b64 100644 --- a/drivers/media/video/hexium_gemini.c +++ b/drivers/media/video/hexium_gemini.c | |||
@@ -56,17 +56,6 @@ struct hexium_data | |||
56 | u8 byte; | 56 | u8 byte; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static struct saa7146_extension_ioctls ioctls[] = { | ||
60 | { VIDIOC_G_INPUT, SAA7146_EXCLUSIVE }, | ||
61 | { VIDIOC_S_INPUT, SAA7146_EXCLUSIVE }, | ||
62 | { VIDIOC_QUERYCTRL, SAA7146_BEFORE }, | ||
63 | { VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE }, | ||
64 | { VIDIOC_S_STD, SAA7146_AFTER }, | ||
65 | { VIDIOC_G_CTRL, SAA7146_BEFORE }, | ||
66 | { VIDIOC_S_CTRL, SAA7146_BEFORE }, | ||
67 | { 0, 0 } | ||
68 | }; | ||
69 | |||
70 | #define HEXIUM_CONTROLS 1 | 59 | #define HEXIUM_CONTROLS 1 |
71 | static struct v4l2_queryctrl hexium_controls[] = { | 60 | static struct v4l2_queryctrl hexium_controls[] = { |
72 | { V4L2_CID_PRIVATE_BASE, V4L2_CTRL_TYPE_BOOLEAN, "B/W", 0, 1, 1, 0, 0 }, | 61 | { V4L2_CID_PRIVATE_BASE, V4L2_CTRL_TYPE_BOOLEAN, "B/W", 0, 1, 1, 0, 0 }, |
@@ -231,6 +220,132 @@ static int hexium_set_standard(struct hexium *hexium, struct hexium_data *vdec) | |||
231 | return 0; | 220 | return 0; |
232 | } | 221 | } |
233 | 222 | ||
223 | static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) | ||
224 | { | ||
225 | DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index)); | ||
226 | |||
227 | if (i->index < 0 || i->index >= HEXIUM_INPUTS) | ||
228 | return -EINVAL; | ||
229 | |||
230 | memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input)); | ||
231 | |||
232 | DEB_D(("v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n", i->index)); | ||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) | ||
237 | { | ||
238 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
239 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | ||
240 | |||
241 | *input = hexium->cur_input; | ||
242 | |||
243 | DEB_D(("VIDIOC_G_INPUT: %d\n", *input)); | ||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | ||
248 | { | ||
249 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
250 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | ||
251 | |||
252 | DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); | ||
253 | |||
254 | if (input < 0 || input >= HEXIUM_INPUTS) | ||
255 | return -EINVAL; | ||
256 | |||
257 | hexium->cur_input = input; | ||
258 | hexium_set_input(hexium, input); | ||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | /* the saa7146 provides some controls (brightness, contrast, saturation) | ||
263 | which gets registered *after* this function. because of this we have | ||
264 | to return with a value != 0 even if the function succeded.. */ | ||
265 | static int vidioc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qc) | ||
266 | { | ||
267 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
268 | int i; | ||
269 | |||
270 | for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) { | ||
271 | if (hexium_controls[i].id == qc->id) { | ||
272 | *qc = hexium_controls[i]; | ||
273 | DEB_D(("VIDIOC_QUERYCTRL %d.\n", qc->id)); | ||
274 | return 0; | ||
275 | } | ||
276 | } | ||
277 | return dev->ext_vv_data->core_ops->vidioc_queryctrl(file, fh, qc); | ||
278 | } | ||
279 | |||
280 | static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *vc) | ||
281 | { | ||
282 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
283 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | ||
284 | int i; | ||
285 | |||
286 | for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) { | ||
287 | if (hexium_controls[i].id == vc->id) | ||
288 | break; | ||
289 | } | ||
290 | |||
291 | if (i < 0) | ||
292 | return dev->ext_vv_data->core_ops->vidioc_g_ctrl(file, fh, vc); | ||
293 | |||
294 | if (vc->id == V4L2_CID_PRIVATE_BASE) { | ||
295 | vc->value = hexium->cur_bw; | ||
296 | DEB_D(("VIDIOC_G_CTRL BW:%d.\n", vc->value)); | ||
297 | return 0; | ||
298 | } | ||
299 | return -EINVAL; | ||
300 | } | ||
301 | |||
302 | static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc) | ||
303 | { | ||
304 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
305 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | ||
306 | int i = 0; | ||
307 | |||
308 | for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) { | ||
309 | if (hexium_controls[i].id == vc->id) | ||
310 | break; | ||
311 | } | ||
312 | |||
313 | if (i < 0) | ||
314 | return dev->ext_vv_data->core_ops->vidioc_s_ctrl(file, fh, vc); | ||
315 | |||
316 | if (vc->id == V4L2_CID_PRIVATE_BASE) | ||
317 | hexium->cur_bw = vc->value; | ||
318 | |||
319 | DEB_D(("VIDIOC_S_CTRL BW:%d.\n", hexium->cur_bw)); | ||
320 | |||
321 | if (0 == hexium->cur_bw && V4L2_STD_PAL == hexium->cur_std) { | ||
322 | hexium_set_standard(hexium, hexium_pal); | ||
323 | return 0; | ||
324 | } | ||
325 | if (0 == hexium->cur_bw && V4L2_STD_NTSC == hexium->cur_std) { | ||
326 | hexium_set_standard(hexium, hexium_ntsc); | ||
327 | return 0; | ||
328 | } | ||
329 | if (0 == hexium->cur_bw && V4L2_STD_SECAM == hexium->cur_std) { | ||
330 | hexium_set_standard(hexium, hexium_secam); | ||
331 | return 0; | ||
332 | } | ||
333 | if (1 == hexium->cur_bw && V4L2_STD_PAL == hexium->cur_std) { | ||
334 | hexium_set_standard(hexium, hexium_pal_bw); | ||
335 | return 0; | ||
336 | } | ||
337 | if (1 == hexium->cur_bw && V4L2_STD_NTSC == hexium->cur_std) { | ||
338 | hexium_set_standard(hexium, hexium_ntsc_bw); | ||
339 | return 0; | ||
340 | } | ||
341 | if (1 == hexium->cur_bw && V4L2_STD_SECAM == hexium->cur_std) | ||
342 | /* fixme: is there no bw secam mode? */ | ||
343 | return -EINVAL; | ||
344 | |||
345 | return -EINVAL; | ||
346 | } | ||
347 | |||
348 | |||
234 | static struct saa7146_ext_vv vv_data; | 349 | static struct saa7146_ext_vv vv_data; |
235 | 350 | ||
236 | /* this function only gets called when the probing was successful */ | 351 | /* this function only gets called when the probing was successful */ |
@@ -279,6 +394,12 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d | |||
279 | hexium->cur_input = 0; | 394 | hexium->cur_input = 0; |
280 | 395 | ||
281 | saa7146_vv_init(dev, &vv_data); | 396 | saa7146_vv_init(dev, &vv_data); |
397 | vv_data.ops.vidioc_queryctrl = vidioc_queryctrl; | ||
398 | vv_data.ops.vidioc_g_ctrl = vidioc_g_ctrl; | ||
399 | vv_data.ops.vidioc_s_ctrl = vidioc_s_ctrl; | ||
400 | vv_data.ops.vidioc_enum_input = vidioc_enum_input; | ||
401 | vv_data.ops.vidioc_g_input = vidioc_g_input; | ||
402 | vv_data.ops.vidioc_s_input = vidioc_s_input; | ||
282 | if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium gemini", VFL_TYPE_GRABBER)) { | 403 | if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium gemini", VFL_TYPE_GRABBER)) { |
283 | printk("hexium_gemini: cannot register capture v4l2 device. skipping.\n"); | 404 | printk("hexium_gemini: cannot register capture v4l2 device. skipping.\n"); |
284 | return -1; | 405 | return -1; |
@@ -306,153 +427,6 @@ static int hexium_detach(struct saa7146_dev *dev) | |||
306 | return 0; | 427 | return 0; |
307 | } | 428 | } |
308 | 429 | ||
309 | static long hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | ||
310 | { | ||
311 | struct saa7146_dev *dev = fh->dev; | ||
312 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | ||
313 | /* | ||
314 | struct saa7146_vv *vv = dev->vv_data; | ||
315 | */ | ||
316 | switch (cmd) { | ||
317 | case VIDIOC_ENUMINPUT: | ||
318 | { | ||
319 | struct v4l2_input *i = arg; | ||
320 | DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index)); | ||
321 | |||
322 | if (i->index < 0 || i->index >= HEXIUM_INPUTS) { | ||
323 | return -EINVAL; | ||
324 | } | ||
325 | |||
326 | memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input)); | ||
327 | |||
328 | DEB_D(("v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n", i->index)); | ||
329 | return 0; | ||
330 | } | ||
331 | case VIDIOC_G_INPUT: | ||
332 | { | ||
333 | int *input = (int *) arg; | ||
334 | *input = hexium->cur_input; | ||
335 | |||
336 | DEB_D(("VIDIOC_G_INPUT: %d\n", *input)); | ||
337 | return 0; | ||
338 | } | ||
339 | case VIDIOC_S_INPUT: | ||
340 | { | ||
341 | int input = *(int *) arg; | ||
342 | |||
343 | DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); | ||
344 | |||
345 | if (input < 0 || input >= HEXIUM_INPUTS) { | ||
346 | return -EINVAL; | ||
347 | } | ||
348 | |||
349 | hexium->cur_input = input; | ||
350 | hexium_set_input(hexium, input); | ||
351 | |||
352 | return 0; | ||
353 | } | ||
354 | /* the saa7146 provides some controls (brightness, contrast, saturation) | ||
355 | which gets registered *after* this function. because of this we have | ||
356 | to return with a value != 0 even if the function succeded.. */ | ||
357 | case VIDIOC_QUERYCTRL: | ||
358 | { | ||
359 | struct v4l2_queryctrl *qc = arg; | ||
360 | int i; | ||
361 | |||
362 | for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) { | ||
363 | if (hexium_controls[i].id == qc->id) { | ||
364 | *qc = hexium_controls[i]; | ||
365 | DEB_D(("VIDIOC_QUERYCTRL %d.\n", qc->id)); | ||
366 | return 0; | ||
367 | } | ||
368 | } | ||
369 | return -EAGAIN; | ||
370 | } | ||
371 | case VIDIOC_G_CTRL: | ||
372 | { | ||
373 | struct v4l2_control *vc = arg; | ||
374 | int i; | ||
375 | |||
376 | for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) { | ||
377 | if (hexium_controls[i].id == vc->id) { | ||
378 | break; | ||
379 | } | ||
380 | } | ||
381 | |||
382 | if (i < 0) { | ||
383 | return -EAGAIN; | ||
384 | } | ||
385 | |||
386 | switch (vc->id) { | ||
387 | case V4L2_CID_PRIVATE_BASE:{ | ||
388 | vc->value = hexium->cur_bw; | ||
389 | DEB_D(("VIDIOC_G_CTRL BW:%d.\n", vc->value)); | ||
390 | return 0; | ||
391 | } | ||
392 | } | ||
393 | return -EINVAL; | ||
394 | } | ||
395 | |||
396 | case VIDIOC_S_CTRL: | ||
397 | { | ||
398 | struct v4l2_control *vc = arg; | ||
399 | int i = 0; | ||
400 | |||
401 | for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) { | ||
402 | if (hexium_controls[i].id == vc->id) { | ||
403 | break; | ||
404 | } | ||
405 | } | ||
406 | |||
407 | if (i < 0) { | ||
408 | return -EAGAIN; | ||
409 | } | ||
410 | |||
411 | switch (vc->id) { | ||
412 | case V4L2_CID_PRIVATE_BASE:{ | ||
413 | hexium->cur_bw = vc->value; | ||
414 | break; | ||
415 | } | ||
416 | } | ||
417 | |||
418 | DEB_D(("VIDIOC_S_CTRL BW:%d.\n", hexium->cur_bw)); | ||
419 | |||
420 | if (0 == hexium->cur_bw && V4L2_STD_PAL == hexium->cur_std) { | ||
421 | hexium_set_standard(hexium, hexium_pal); | ||
422 | return 0; | ||
423 | } | ||
424 | if (0 == hexium->cur_bw && V4L2_STD_NTSC == hexium->cur_std) { | ||
425 | hexium_set_standard(hexium, hexium_ntsc); | ||
426 | return 0; | ||
427 | } | ||
428 | if (0 == hexium->cur_bw && V4L2_STD_SECAM == hexium->cur_std) { | ||
429 | hexium_set_standard(hexium, hexium_secam); | ||
430 | return 0; | ||
431 | } | ||
432 | if (1 == hexium->cur_bw && V4L2_STD_PAL == hexium->cur_std) { | ||
433 | hexium_set_standard(hexium, hexium_pal_bw); | ||
434 | return 0; | ||
435 | } | ||
436 | if (1 == hexium->cur_bw && V4L2_STD_NTSC == hexium->cur_std) { | ||
437 | hexium_set_standard(hexium, hexium_ntsc_bw); | ||
438 | return 0; | ||
439 | } | ||
440 | if (1 == hexium->cur_bw && V4L2_STD_SECAM == hexium->cur_std) { | ||
441 | /* fixme: is there no bw secam mode? */ | ||
442 | return -EINVAL; | ||
443 | } | ||
444 | |||
445 | return -EINVAL; | ||
446 | } | ||
447 | default: | ||
448 | /* | ||
449 | DEB_D(("hexium_ioctl() does not handle this ioctl.\n")); | ||
450 | */ | ||
451 | return -ENOIOCTLCMD; | ||
452 | } | ||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *std) | 430 | static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *std) |
457 | { | 431 | { |
458 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | 432 | struct hexium *hexium = (struct hexium *) dev->ext_priv; |
@@ -514,8 +488,6 @@ static struct saa7146_ext_vv vv_data = { | |||
514 | .stds = &hexium_standards[0], | 488 | .stds = &hexium_standards[0], |
515 | .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard), | 489 | .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard), |
516 | .std_callback = &std_callback, | 490 | .std_callback = &std_callback, |
517 | .ioctls = &ioctls[0], | ||
518 | .ioctl = hexium_ioctl, | ||
519 | }; | 491 | }; |
520 | 492 | ||
521 | static struct saa7146_extension hexium_extension = { | 493 | static struct saa7146_extension hexium_extension = { |