Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB: arv: convert to V4L2

Converted this old V4L1 driver to V4L2.
I would like to thank Takeo Takahashi who very kindly tested this
driver for me. Much appreciated!

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Tested-by: Takeo Takahashi <takahashi.takeo@renesas.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
b8e56b6f debff5a7

+182 -217
+1 -1
drivers/media/video/Kconfig
··· 807 807 808 808 config VIDEO_M32R_AR 809 809 tristate "AR devices" 810 - depends on M32R && VIDEO_V4L1 810 + depends on M32R && VIDEO_V4L2 811 811 ---help--- 812 812 This is a video4linux driver for the Renesas AR (Artificial Retina) 813 813 camera module.
+181 -216
drivers/media/video/arv.c
··· 27 27 #include <linux/slab.h> 28 28 #include <linux/mm.h> 29 29 #include <linux/sched.h> 30 - #include <linux/videodev.h> 30 + #include <linux/version.h> 31 + #include <linux/videodev2.h> 31 32 #include <media/v4l2-common.h> 33 + #include <media/v4l2-device.h> 32 34 #include <media/v4l2-ioctl.h> 33 35 #include <linux/mutex.h> 34 36 ··· 54 52 */ 55 53 #define USE_INT 0 /* Don't modify */ 56 54 57 - #define VERSION "0.03" 55 + #define VERSION "0.04" 58 56 59 57 #define ar_inl(addr) inl((unsigned long)(addr)) 60 58 #define ar_outl(val, addr) outl((unsigned long)(val), (unsigned long)(addr)) ··· 81 79 82 80 /* bits & bytes per pixel */ 83 81 #define AR_BITS_PER_PIXEL 16 84 - #define AR_BYTES_PER_PIXEL (AR_BITS_PER_PIXEL/8) 82 + #define AR_BYTES_PER_PIXEL (AR_BITS_PER_PIXEL / 8) 85 83 86 84 /* line buffer size */ 87 85 #define AR_LINE_BYTES_VGA (AR_WIDTH_VGA * AR_BYTES_PER_PIXEL) ··· 106 104 #define AR_MODE_INTERLACE 0 107 105 #define AR_MODE_NORMAL 1 108 106 109 - struct ar_device { 110 - struct video_device *vdev; 107 + struct ar { 108 + struct v4l2_device v4l2_dev; 109 + struct video_device vdev; 111 110 unsigned int start_capture; /* duaring capture in INT. mode. */ 112 111 #if USE_INT 113 112 unsigned char *line_buff; /* DMA line buffer */ ··· 119 116 int width, height; 120 117 int frame_bytes, line_bytes; 121 118 wait_queue_head_t wait; 122 - unsigned long in_use; 123 119 struct mutex lock; 124 120 }; 125 121 122 + static struct ar ardev; 123 + 126 124 static int video_nr = -1; /* video device number (first free) */ 127 - static unsigned char yuv[MAX_AR_FRAME_BYTES]; 125 + static unsigned char yuv[MAX_AR_FRAME_BYTES]; 128 126 129 127 /* module parameters */ 130 128 /* default frequency */ ··· 137 133 module_param(vga, int, 0); 138 134 module_param(vga_interlace, int, 0); 139 135 140 - static int ar_initialize(struct video_device *dev); 141 - 142 - static inline void wait_for_vsync(void) 136 + static void wait_for_vsync(void) 143 137 { 144 138 while (ar_inl(ARVCR0) & ARVCR0_VDS) /* wait for VSYNC */ 145 139 cpu_relax(); ··· 145 143 cpu_relax(); 146 144 } 147 145 148 - static inline void wait_acknowledge(void) 146 + static void wait_acknowledge(void) 149 147 { 150 148 int i; 151 149 ··· 158 156 /******************************************************************* 159 157 * I2C functions 160 158 *******************************************************************/ 161 - void iic(int n, unsigned long addr, unsigned long data1, unsigned long data2, 159 + static void iic(int n, unsigned long addr, unsigned long data1, unsigned long data2, 162 160 unsigned long data3) 163 161 { 164 162 int i; ··· 202 200 } 203 201 204 202 205 - void init_iic(void) 203 + static void init_iic(void) 206 204 { 207 205 DEBUG(1, "init_iic:\n"); 208 206 ··· 246 244 ar_outl(0x8000, M32R_DMAEDET_PORTL); /* clear status */ 247 245 } 248 246 249 - static inline void wait_for_vertical_sync(int exp_line) 247 + static void wait_for_vertical_sync(struct ar *ar, int exp_line) 250 248 { 251 249 #if CHECK_LOST 252 250 int tmout = 10000; /* FIXME */ ··· 261 259 break; 262 260 } 263 261 if (tmout < 0) 264 - printk(KERN_ERR "arv: lost %d -> %d\n", exp_line, l); 262 + v4l2_err(&ar->v4l2_dev, "lost %d -> %d\n", exp_line, l); 265 263 #else 266 264 while (ar_inl(ARVHCOUNT) != exp_line) 267 265 cpu_relax(); ··· 270 268 271 269 static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos) 272 270 { 273 - struct video_device *v = video_devdata(file); 274 - struct ar_device *ar = video_get_drvdata(v); 271 + struct ar *ar = video_drvdata(file); 275 272 long ret = ar->frame_bytes; /* return read bytes */ 276 273 unsigned long arvcr1 = 0; 277 274 unsigned long flags; ··· 305 304 ar_outl(ar->line_bytes, M32R_DMA0RBCUT_PORTL); /* reload count (bytes) */ 306 305 307 306 /* 308 - * Okey , kicks AR LSI to invoke an interrupt 307 + * Okay, kick AR LSI to invoke an interrupt 309 308 */ 310 309 ar->start_capture = 0; 311 310 ar_outl(arvcr1 | ARVCR1_HIEN, ARVCR1); ··· 334 333 cpu_relax(); 335 334 if (ar->mode == AR_MODE_INTERLACE && ar->size == AR_SIZE_VGA) { 336 335 for (h = 0; h < ar->height; h++) { 337 - wait_for_vertical_sync(h); 336 + wait_for_vertical_sync(ar, h); 338 337 if (h < (AR_HEIGHT_VGA/2)) 339 338 l = h << 1; 340 339 else ··· 349 348 } 350 349 } else { 351 350 for (h = 0; h < ar->height; h++) { 352 - wait_for_vertical_sync(h); 351 + wait_for_vertical_sync(ar, h); 353 352 ar_outl(virt_to_phys(ar->frame[h]), M32R_DMA0CDA_PORTL); 354 353 enable_dma(); 355 354 while (!(ar_inl(M32R_DMAEDET_PORTL) & 0x8000)) ··· 386 385 } 387 386 } 388 387 if (copy_to_user(buf, yuv, ar->frame_bytes)) { 389 - printk(KERN_ERR "arv: failed while copy_to_user yuv.\n"); 388 + v4l2_err(&ar->v4l2_dev, "failed while copy_to_user yuv.\n"); 390 389 ret = -EFAULT; 391 390 goto out_up; 392 391 } ··· 396 395 return ret; 397 396 } 398 397 399 - static long ar_do_ioctl(struct file *file, unsigned int cmd, void *arg) 398 + static int ar_querycap(struct file *file, void *priv, 399 + struct v4l2_capability *vcap) 400 400 { 401 - struct video_device *dev = video_devdata(file); 402 - struct ar_device *ar = video_get_drvdata(dev); 401 + struct ar *ar = video_drvdata(file); 403 402 404 - DEBUG(1, "ar_ioctl()\n"); 405 - switch (cmd) { 406 - case VIDIOCGCAP: 407 - { 408 - struct video_capability *b = arg; 409 - DEBUG(1, "VIDIOCGCAP:\n"); 410 - strcpy(b->name, ar->vdev->name); 411 - b->type = VID_TYPE_CAPTURE; 412 - b->channels = 0; 413 - b->audios = 0; 414 - b->maxwidth = MAX_AR_WIDTH; 415 - b->maxheight = MAX_AR_HEIGHT; 416 - b->minwidth = MIN_AR_WIDTH; 417 - b->minheight = MIN_AR_HEIGHT; 418 - return 0; 419 - } 420 - case VIDIOCGCHAN: 421 - DEBUG(1, "VIDIOCGCHAN:\n"); 422 - return 0; 423 - case VIDIOCSCHAN: 424 - DEBUG(1, "VIDIOCSCHAN:\n"); 425 - return 0; 426 - case VIDIOCGTUNER: 427 - DEBUG(1, "VIDIOCGTUNER:\n"); 428 - return 0; 429 - case VIDIOCSTUNER: 430 - DEBUG(1, "VIDIOCSTUNER:\n"); 431 - return 0; 432 - case VIDIOCGPICT: 433 - DEBUG(1, "VIDIOCGPICT:\n"); 434 - return 0; 435 - case VIDIOCSPICT: 436 - DEBUG(1, "VIDIOCSPICT:\n"); 437 - return 0; 438 - case VIDIOCCAPTURE: 439 - DEBUG(1, "VIDIOCCAPTURE:\n"); 440 - return -EINVAL; 441 - case VIDIOCGWIN: 442 - { 443 - struct video_window *w = arg; 444 - DEBUG(1, "VIDIOCGWIN:\n"); 445 - memset(w, 0, sizeof(*w)); 446 - w->width = ar->width; 447 - w->height = ar->height; 448 - return 0; 449 - } 450 - case VIDIOCSWIN: 451 - { 452 - struct video_window *w = arg; 453 - DEBUG(1, "VIDIOCSWIN:\n"); 454 - if ((w->width != AR_WIDTH_VGA || w->height != AR_HEIGHT_VGA) && 455 - (w->width != AR_WIDTH_QVGA || w->height != AR_HEIGHT_QVGA)) 456 - return -EINVAL; 457 - 458 - mutex_lock(&ar->lock); 459 - ar->width = w->width; 460 - ar->height = w->height; 461 - if (ar->width == AR_WIDTH_VGA) { 462 - ar->size = AR_SIZE_VGA; 463 - ar->frame_bytes = AR_FRAME_BYTES_VGA; 464 - ar->line_bytes = AR_LINE_BYTES_VGA; 465 - if (vga_interlace) 466 - ar->mode = AR_MODE_INTERLACE; 467 - else 468 - ar->mode = AR_MODE_NORMAL; 469 - } else { 470 - ar->size = AR_SIZE_QVGA; 471 - ar->frame_bytes = AR_FRAME_BYTES_QVGA; 472 - ar->line_bytes = AR_LINE_BYTES_QVGA; 473 - ar->mode = AR_MODE_INTERLACE; 474 - } 475 - mutex_unlock(&ar->lock); 476 - return 0; 477 - } 478 - case VIDIOCGFBUF: 479 - DEBUG(1, "VIDIOCGFBUF:\n"); 480 - return -EINVAL; 481 - case VIDIOCSFBUF: 482 - DEBUG(1, "VIDIOCSFBUF:\n"); 483 - return -EINVAL; 484 - case VIDIOCKEY: 485 - DEBUG(1, "VIDIOCKEY:\n"); 486 - return 0; 487 - case VIDIOCGFREQ: 488 - DEBUG(1, "VIDIOCGFREQ:\n"); 489 - return -EINVAL; 490 - case VIDIOCSFREQ: 491 - DEBUG(1, "VIDIOCSFREQ:\n"); 492 - return -EINVAL; 493 - case VIDIOCGAUDIO: 494 - DEBUG(1, "VIDIOCGAUDIO:\n"); 495 - return -EINVAL; 496 - case VIDIOCSAUDIO: 497 - DEBUG(1, "VIDIOCSAUDIO:\n"); 498 - return -EINVAL; 499 - case VIDIOCSYNC: 500 - DEBUG(1, "VIDIOCSYNC:\n"); 501 - return -EINVAL; 502 - case VIDIOCMCAPTURE: 503 - DEBUG(1, "VIDIOCMCAPTURE:\n"); 504 - return -EINVAL; 505 - case VIDIOCGMBUF: 506 - DEBUG(1, "VIDIOCGMBUF:\n"); 507 - return -EINVAL; 508 - case VIDIOCGUNIT: 509 - DEBUG(1, "VIDIOCGUNIT:\n"); 510 - return -EINVAL; 511 - case VIDIOCGCAPTURE: 512 - DEBUG(1, "VIDIOCGCAPTURE:\n"); 513 - return -EINVAL; 514 - case VIDIOCSCAPTURE: 515 - DEBUG(1, "VIDIOCSCAPTURE:\n"); 516 - return -EINVAL; 517 - case VIDIOCSPLAYMODE: 518 - DEBUG(1, "VIDIOCSPLAYMODE:\n"); 519 - return -EINVAL; 520 - case VIDIOCSWRITEMODE: 521 - DEBUG(1, "VIDIOCSWRITEMODE:\n"); 522 - return -EINVAL; 523 - case VIDIOCGPLAYINFO: 524 - DEBUG(1, "VIDIOCGPLAYINFO:\n"); 525 - return -EINVAL; 526 - case VIDIOCSMICROCODE: 527 - DEBUG(1, "VIDIOCSMICROCODE:\n"); 528 - return -EINVAL; 529 - case VIDIOCGVBIFMT: 530 - DEBUG(1, "VIDIOCGVBIFMT:\n"); 531 - return -EINVAL; 532 - case VIDIOCSVBIFMT: 533 - DEBUG(1, "VIDIOCSVBIFMT:\n"); 534 - return -EINVAL; 535 - default: 536 - DEBUG(1, "Unknown ioctl(0x%08x)\n", cmd); 537 - return -ENOIOCTLCMD; 538 - } 403 + strlcpy(vcap->driver, ar->vdev.name, sizeof(vcap->driver)); 404 + strlcpy(vcap->card, "Colour AR VGA", sizeof(vcap->card)); 405 + strlcpy(vcap->bus_info, "Platform", sizeof(vcap->bus_info)); 406 + vcap->version = KERNEL_VERSION(0, 0, 4); 407 + vcap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; 539 408 return 0; 540 409 } 541 410 542 - static long ar_ioctl(struct file *file, unsigned int cmd, 543 - unsigned long arg) 411 + static int ar_enum_input(struct file *file, void *fh, struct v4l2_input *vin) 544 412 { 545 - return video_usercopy(file, cmd, arg, ar_do_ioctl); 413 + if (vin->index > 0) 414 + return -EINVAL; 415 + strlcpy(vin->name, "Camera", sizeof(vin->name)); 416 + vin->type = V4L2_INPUT_TYPE_CAMERA; 417 + vin->audioset = 0; 418 + vin->tuner = 0; 419 + vin->std = V4L2_STD_ALL; 420 + vin->status = 0; 421 + return 0; 422 + } 423 + 424 + static int ar_g_input(struct file *file, void *fh, unsigned int *inp) 425 + { 426 + *inp = 0; 427 + return 0; 428 + } 429 + 430 + static int ar_s_input(struct file *file, void *fh, unsigned int inp) 431 + { 432 + return inp ? -EINVAL : 0; 433 + } 434 + 435 + static int ar_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt) 436 + { 437 + struct ar *ar = video_drvdata(file); 438 + struct v4l2_pix_format *pix = &fmt->fmt.pix; 439 + 440 + pix->width = ar->width; 441 + pix->height = ar->height; 442 + pix->pixelformat = V4L2_PIX_FMT_YUV422P; 443 + pix->field = (ar->mode == AR_MODE_NORMAL) ? V4L2_FIELD_NONE : V4L2_FIELD_INTERLACED; 444 + pix->bytesperline = ar->width; 445 + pix->sizeimage = 2 * ar->width * ar->height; 446 + /* Just a guess */ 447 + pix->colorspace = V4L2_COLORSPACE_SMPTE170M; 448 + return 0; 449 + } 450 + 451 + static int ar_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt) 452 + { 453 + struct ar *ar = video_drvdata(file); 454 + struct v4l2_pix_format *pix = &fmt->fmt.pix; 455 + 456 + if (pix->height <= AR_HEIGHT_QVGA || pix->width <= AR_WIDTH_QVGA) { 457 + pix->height = AR_HEIGHT_QVGA; 458 + pix->width = AR_WIDTH_QVGA; 459 + pix->field = V4L2_FIELD_INTERLACED; 460 + } else { 461 + pix->height = AR_HEIGHT_VGA; 462 + pix->width = AR_WIDTH_VGA; 463 + pix->field = vga_interlace ? V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE; 464 + } 465 + pix->pixelformat = V4L2_PIX_FMT_YUV422P; 466 + pix->bytesperline = ar->width; 467 + pix->sizeimage = 2 * ar->width * ar->height; 468 + /* Just a guess */ 469 + pix->colorspace = V4L2_COLORSPACE_SMPTE170M; 470 + return 0; 471 + } 472 + 473 + static int ar_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt) 474 + { 475 + struct ar *ar = video_drvdata(file); 476 + struct v4l2_pix_format *pix = &fmt->fmt.pix; 477 + int ret = ar_try_fmt_vid_cap(file, fh, fmt); 478 + 479 + if (ret) 480 + return ret; 481 + mutex_lock(&ar->lock); 482 + ar->width = pix->width; 483 + ar->height = pix->height; 484 + if (ar->width == AR_WIDTH_VGA) { 485 + ar->size = AR_SIZE_VGA; 486 + ar->frame_bytes = AR_FRAME_BYTES_VGA; 487 + ar->line_bytes = AR_LINE_BYTES_VGA; 488 + if (vga_interlace) 489 + ar->mode = AR_MODE_INTERLACE; 490 + else 491 + ar->mode = AR_MODE_NORMAL; 492 + } else { 493 + ar->size = AR_SIZE_QVGA; 494 + ar->frame_bytes = AR_FRAME_BYTES_QVGA; 495 + ar->line_bytes = AR_LINE_BYTES_QVGA; 496 + ar->mode = AR_MODE_INTERLACE; 497 + } 498 + /* Ok we figured out what to use from our wide choice */ 499 + mutex_unlock(&ar->lock); 500 + return 0; 501 + } 502 + 503 + static int ar_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *fmt) 504 + { 505 + static struct v4l2_fmtdesc formats[] = { 506 + { 0, 0, 0, 507 + "YUV 4:2:2 Planar", V4L2_PIX_FMT_YUV422P, 508 + { 0, 0, 0, 0 } 509 + }, 510 + }; 511 + enum v4l2_buf_type type = fmt->type; 512 + 513 + if (fmt->index > 0) 514 + return -EINVAL; 515 + 516 + *fmt = formats[fmt->index]; 517 + fmt->type = type; 518 + return 0; 546 519 } 547 520 548 521 #if USE_INT ··· 525 550 */ 526 551 static void ar_interrupt(int irq, void *dev) 527 552 { 528 - struct ar_device *ar = dev; 553 + struct ar *ar = dev; 529 554 unsigned int line_count; 530 555 unsigned int line_number; 531 556 unsigned int arvcr1; ··· 597 622 * 0 is returned in success. 598 623 * 599 624 */ 600 - static int ar_initialize(struct video_device *dev) 625 + static int ar_initialize(struct ar *ar) 601 626 { 602 - struct ar_device *ar = video_get_drvdata(dev); 603 627 unsigned long cr = 0; 604 628 int i, found = 0; 605 629 ··· 639 665 if (found == 0) 640 666 return -ENODEV; 641 667 642 - printk(KERN_INFO "arv: Initializing "); 668 + v4l2_info(&ar->v4l2_dev, "Initializing "); 643 669 644 670 iic(2, 0x78, 0x11, 0x01, 0x00); /* start */ 645 671 iic(3, 0x78, 0x12, 0x00, 0x06); ··· 703 729 } 704 730 705 731 706 - void ar_release(struct video_device *vfd) 707 - { 708 - struct ar_device *ar = video_get_drvdata(vfd); 709 - mutex_lock(&ar->lock); 710 - video_device_release(vfd); 711 - } 712 - 713 732 /**************************************************************************** 714 733 * 715 734 * Video4Linux Module functions 716 735 * 717 736 ****************************************************************************/ 718 - static struct ar_device ardev; 719 - 720 - static int ar_exclusive_open(struct file *file) 721 - { 722 - return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0; 723 - } 724 - 725 - static int ar_exclusive_release(struct file *file) 726 - { 727 - clear_bit(0, &ardev.in_use); 728 - return 0; 729 - } 730 737 731 738 static const struct v4l2_file_operations ar_fops = { 732 739 .owner = THIS_MODULE, 733 - .open = ar_exclusive_open, 734 - .release = ar_exclusive_release, 735 740 .read = ar_read, 736 - .ioctl = ar_ioctl, 741 + .ioctl = video_ioctl2, 737 742 }; 738 743 739 - static struct video_device ar_template = { 740 - .name = "Colour AR VGA", 741 - .fops = &ar_fops, 742 - .release = ar_release, 744 + static const struct v4l2_ioctl_ops ar_ioctl_ops = { 745 + .vidioc_querycap = ar_querycap, 746 + .vidioc_g_input = ar_g_input, 747 + .vidioc_s_input = ar_s_input, 748 + .vidioc_enum_input = ar_enum_input, 749 + .vidioc_enum_fmt_vid_cap = ar_enum_fmt_vid_cap, 750 + .vidioc_g_fmt_vid_cap = ar_g_fmt_vid_cap, 751 + .vidioc_s_fmt_vid_cap = ar_s_fmt_vid_cap, 752 + .vidioc_try_fmt_vid_cap = ar_try_fmt_vid_cap, 743 753 }; 744 754 745 755 #define ALIGN4(x) ((((int)(x)) & 0x3) == 0) 746 756 747 757 static int __init ar_init(void) 748 758 { 749 - struct ar_device *ar; 759 + struct ar *ar; 760 + struct v4l2_device *v4l2_dev; 750 761 int ret; 751 762 int i; 752 763 753 - DEBUG(1, "ar_init:\n"); 754 - ret = -EIO; 755 - printk(KERN_INFO "arv: Colour AR VGA driver %s\n", VERSION); 756 - 757 764 ar = &ardev; 758 - memset(ar, 0, sizeof(struct ar_device)); 765 + v4l2_dev = &ar->v4l2_dev; 766 + strlcpy(v4l2_dev->name, "arv", sizeof(v4l2_dev->name)); 767 + v4l2_info(v4l2_dev, "Colour AR VGA driver %s\n", VERSION); 768 + 769 + ret = v4l2_device_register(NULL, v4l2_dev); 770 + if (ret < 0) { 771 + v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); 772 + return ret; 773 + } 774 + ret = -EIO; 759 775 760 776 #if USE_INT 761 777 /* allocate a DMA buffer for 1 line. */ 762 778 ar->line_buff = kmalloc(MAX_AR_LINE_BYTES, GFP_KERNEL | GFP_DMA); 763 779 if (ar->line_buff == NULL || !ALIGN4(ar->line_buff)) { 764 - printk(KERN_ERR "arv: buffer allocation failed for DMA.\n"); 780 + v4l2_err(v4l2_dev, "buffer allocation failed for DMA.\n"); 765 781 ret = -ENOMEM; 766 782 goto out_end; 767 783 } ··· 760 796 for (i = 0; i < MAX_AR_HEIGHT; i++) { 761 797 ar->frame[i] = kmalloc(MAX_AR_LINE_BYTES, GFP_KERNEL); 762 798 if (ar->frame[i] == NULL || !ALIGN4(ar->frame[i])) { 763 - printk(KERN_ERR "arv: buffer allocation failed for frame.\n"); 799 + v4l2_err(v4l2_dev, "buffer allocation failed for frame.\n"); 764 800 ret = -ENOMEM; 765 801 goto out_line_buff; 766 802 } 767 803 } 768 804 769 - ar->vdev = video_device_alloc(); 770 - if (!ar->vdev) { 771 - printk(KERN_ERR "arv: video_device_alloc() failed\n"); 772 - return -ENOMEM; 773 - } 774 - memcpy(ar->vdev, &ar_template, sizeof(ar_template)); 775 - video_set_drvdata(ar->vdev, ar); 805 + strlcpy(ar->vdev.name, "Colour AR VGA", sizeof(ar->vdev.name)); 806 + ar->vdev.v4l2_dev = v4l2_dev; 807 + ar->vdev.fops = &ar_fops; 808 + ar->vdev.ioctl_ops = &ar_ioctl_ops; 809 + ar->vdev.release = video_device_release_empty; 810 + video_set_drvdata(&ar->vdev, ar); 776 811 777 812 if (vga) { 778 813 ar->width = AR_WIDTH_VGA; ··· 796 833 797 834 #if USE_INT 798 835 if (request_irq(M32R_IRQ_INT3, ar_interrupt, 0, "arv", ar)) { 799 - printk(KERN_ERR "arv: request_irq(%d) failed.\n", M32R_IRQ_INT3); 836 + v4l2_err("request_irq(%d) failed.\n", M32R_IRQ_INT3); 800 837 ret = -EIO; 801 838 goto out_irq; 802 839 } 803 840 #endif 804 841 805 - if (ar_initialize(ar->vdev) != 0) { 806 - printk(KERN_ERR "arv: M64278 not found.\n"); 842 + if (ar_initialize(ar) != 0) { 843 + v4l2_err(v4l2_dev, "M64278 not found.\n"); 807 844 ret = -ENODEV; 808 845 goto out_dev; 809 846 } ··· 814 851 * device is named "video[0-64]". 815 852 * video_register_device() initializes h/w using ar_initialize(). 816 853 */ 817 - if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) { 854 + if (video_register_device(&ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) { 818 855 /* return -1, -ENFILE(full) or others */ 819 - printk(KERN_ERR "arv: register video (Colour AR) failed.\n"); 856 + v4l2_err(v4l2_dev, "register video (Colour AR) failed.\n"); 820 857 ret = -ENODEV; 821 858 goto out_dev; 822 859 } 823 860 824 - printk(KERN_INFO "%s: Found M64278 VGA (IRQ %d, Freq %dMHz).\n", 825 - video_device_node_name(ar->vdev), M32R_IRQ_INT3, freq); 861 + v4l2_info(v4l2_dev, "%s: Found M64278 VGA (IRQ %d, Freq %dMHz).\n", 862 + video_device_node_name(&ar->vdev), M32R_IRQ_INT3, freq); 826 863 827 864 return 0; 828 865 ··· 841 878 842 879 out_end: 843 880 #endif 881 + v4l2_device_unregister(&ar->v4l2_dev); 844 882 return ret; 845 883 } 846 884 ··· 857 893 858 894 static void __exit ar_cleanup_module(void) 859 895 { 860 - struct ar_device *ar; 896 + struct ar *ar; 861 897 int i; 862 898 863 899 ar = &ardev; 864 - video_unregister_device(ar->vdev); 900 + video_unregister_device(&ar->vdev); 865 901 #if USE_INT 866 902 free_irq(M32R_IRQ_INT3, ar); 867 903 #endif ··· 870 906 #if USE_INT 871 907 kfree(ar->line_buff); 872 908 #endif 909 + v4l2_device_unregister(&ar->v4l2_dev); 873 910 } 874 911 875 912 module_init(ar_init_module);