aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Anderson <linux-dev@sensoray.com>2014-02-04 16:16:24 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-02-28 12:18:21 -0500
commit5e950faffc74e71be416ea3cf4e68ab3f326535c (patch)
treea588a692b391f679e4bbca7e35bea7c2f7b5312c
parentd86c6a8cc5ce53d539425ae3aa5e93122628ff52 (diff)
[media] s2255drv: refactoring s2255_channel to s2255_vc
Renaming s2255_channel and all instances of channel to vc (video channel). Signed-off-by: Dean Anderson <linux-dev@sensoray.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/usb/s2255/s2255drv.c517
1 files changed, 259 insertions, 258 deletions
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 5f09a5690145..2e24aeecfed7 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -212,7 +212,8 @@ struct s2255_pipeinfo {
212struct s2255_fmt; /*forward declaration */ 212struct s2255_fmt; /*forward declaration */
213struct s2255_dev; 213struct s2255_dev;
214 214
215struct s2255_channel { 215/* 2255 video channel */
216struct s2255_vc {
216 struct s2255_dev *dev; 217 struct s2255_dev *dev;
217 struct video_device vdev; 218 struct video_device vdev;
218 struct v4l2_ctrl_handler hdl; 219 struct v4l2_ctrl_handler hdl;
@@ -254,7 +255,7 @@ struct s2255_channel {
254 255
255 256
256struct s2255_dev { 257struct s2255_dev {
257 struct s2255_channel channel[MAX_CHANNELS]; 258 struct s2255_vc vc[MAX_CHANNELS];
258 struct v4l2_device v4l2_dev; 259 struct v4l2_device v4l2_dev;
259 atomic_t num_channels; 260 atomic_t num_channels;
260 int frames; 261 int frames;
@@ -298,7 +299,7 @@ struct s2255_fh {
298 struct s2255_dev *dev; 299 struct s2255_dev *dev;
299 struct videobuf_queue vb_vidq; 300 struct videobuf_queue vb_vidq;
300 enum v4l2_buf_type type; 301 enum v4l2_buf_type type;
301 struct s2255_channel *channel; 302 struct s2255_vc *vc;
302 int resources; 303 int resources;
303}; 304};
304 305
@@ -351,11 +352,11 @@ static int debug;
351 352
352static int s2255_start_readpipe(struct s2255_dev *dev); 353static int s2255_start_readpipe(struct s2255_dev *dev);
353static void s2255_stop_readpipe(struct s2255_dev *dev); 354static void s2255_stop_readpipe(struct s2255_dev *dev);
354static int s2255_start_acquire(struct s2255_channel *channel); 355static int s2255_start_acquire(struct s2255_vc *vc);
355static int s2255_stop_acquire(struct s2255_channel *channel); 356static int s2255_stop_acquire(struct s2255_vc *vc);
356static void s2255_fillbuff(struct s2255_channel *chn, struct s2255_buffer *buf, 357static void s2255_fillbuff(struct s2255_vc *vc, struct s2255_buffer *buf,
357 int jpgsize); 358 int jpgsize);
358static int s2255_set_mode(struct s2255_channel *chan, struct s2255_mode *mode); 359static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode *mode);
359static int s2255_board_shutdown(struct s2255_dev *dev); 360static int s2255_board_shutdown(struct s2255_dev *dev);
360static void s2255_fwload_start(struct s2255_dev *dev, int reset); 361static void s2255_fwload_start(struct s2255_dev *dev, int reset);
361static void s2255_destroy(struct s2255_dev *dev); 362static void s2255_destroy(struct s2255_dev *dev);
@@ -434,27 +435,27 @@ static const struct s2255_fmt formats[] = {
434 } 435 }
435}; 436};
436 437
437static int norm_maxw(struct s2255_channel *channel) 438static int norm_maxw(struct s2255_vc *vc)
438{ 439{
439 return (channel->std & V4L2_STD_525_60) ? 440 return (vc->std & V4L2_STD_525_60) ?
440 LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL; 441 LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL;
441} 442}
442 443
443static int norm_maxh(struct s2255_channel *channel) 444static int norm_maxh(struct s2255_vc *vc)
444{ 445{
445 return (channel->std & V4L2_STD_525_60) ? 446 return (vc->std & V4L2_STD_525_60) ?
446 (NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2); 447 (NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2);
447} 448}
448 449
449static int norm_minw(struct s2255_channel *channel) 450static int norm_minw(struct s2255_vc *vc)
450{ 451{
451 return (channel->std & V4L2_STD_525_60) ? 452 return (vc->std & V4L2_STD_525_60) ?
452 LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL; 453 LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL;
453} 454}
454 455
455static int norm_minh(struct s2255_channel *channel) 456static int norm_minh(struct s2255_vc *vc)
456{ 457{
457 return (channel->std & V4L2_STD_525_60) ? 458 return (vc->std & V4L2_STD_525_60) ?
458 (NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL); 459 (NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL);
459} 460}
460 461
@@ -567,23 +568,23 @@ static void s2255_fwchunk_complete(struct urb *urb)
567 568
568} 569}
569 570
570static int s2255_got_frame(struct s2255_channel *channel, int jpgsize) 571static int s2255_got_frame(struct s2255_vc *vc, int jpgsize)
571{ 572{
572 struct s2255_buffer *buf; 573 struct s2255_buffer *buf;
573 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 574 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
574 unsigned long flags = 0; 575 unsigned long flags = 0;
575 int rc = 0; 576 int rc = 0;
576 spin_lock_irqsave(&dev->slock, flags); 577 spin_lock_irqsave(&dev->slock, flags);
577 if (list_empty(&channel->buf_list)) { 578 if (list_empty(&vc->buf_list)) {
578 dprintk(dev, 1, "No active queue to serve\n"); 579 dprintk(dev, 1, "No active queue to serve\n");
579 rc = -1; 580 rc = -1;
580 goto unlock; 581 goto unlock;
581 } 582 }
582 buf = list_entry(channel->buf_list.next, 583 buf = list_entry(vc->buf_list.next,
583 struct s2255_buffer, vb.queue); 584 struct s2255_buffer, vb.queue);
584 list_del(&buf->vb.queue); 585 list_del(&buf->vb.queue);
585 v4l2_get_timestamp(&buf->vb.ts); 586 v4l2_get_timestamp(&buf->vb.ts);
586 s2255_fillbuff(channel, buf, jpgsize); 587 s2255_fillbuff(vc, buf, jpgsize);
587 wake_up(&buf->vb.done); 588 wake_up(&buf->vb.done);
588 dprintk(dev, 2, "%s: [buf/i] [%p/%d]\n", __func__, buf, buf->vb.i); 589 dprintk(dev, 2, "%s: [buf/i] [%p/%d]\n", __func__, buf, buf->vb.i);
589unlock: 590unlock:
@@ -614,21 +615,21 @@ static const struct s2255_fmt *format_by_fourcc(int fourcc)
614 * http://v4l.videotechnology.com/ 615 * http://v4l.videotechnology.com/
615 * 616 *
616 */ 617 */
617static void s2255_fillbuff(struct s2255_channel *channel, 618static void s2255_fillbuff(struct s2255_vc *vc,
618 struct s2255_buffer *buf, int jpgsize) 619 struct s2255_buffer *buf, int jpgsize)
619{ 620{
620 int pos = 0; 621 int pos = 0;
621 const char *tmpbuf; 622 const char *tmpbuf;
622 char *vbuf = videobuf_to_vmalloc(&buf->vb); 623 char *vbuf = videobuf_to_vmalloc(&buf->vb);
623 unsigned long last_frame; 624 unsigned long last_frame;
624 struct s2255_dev *dev = channel->dev; 625 struct s2255_dev *dev = vc->dev;
625 626
626 if (!vbuf) 627 if (!vbuf)
627 return; 628 return;
628 last_frame = channel->last_frame; 629 last_frame = vc->last_frame;
629 if (last_frame != -1) { 630 if (last_frame != -1) {
630 tmpbuf = 631 tmpbuf =
631 (const char *)channel->buffer.frame[last_frame].lpvbits; 632 (const char *)vc->buffer.frame[last_frame].lpvbits;
632 switch (buf->fmt->fourcc) { 633 switch (buf->fmt->fourcc) {
633 case V4L2_PIX_FMT_YUYV: 634 case V4L2_PIX_FMT_YUYV:
634 case V4L2_PIX_FMT_UYVY: 635 case V4L2_PIX_FMT_UYVY:
@@ -652,7 +653,7 @@ static void s2255_fillbuff(struct s2255_channel *channel,
652 default: 653 default:
653 pr_info("s2255: unknown format?\n"); 654 pr_info("s2255: unknown format?\n");
654 } 655 }
655 channel->last_frame = -1; 656 vc->last_frame = -1;
656 } else { 657 } else {
657 pr_err("s2255: =======no frame\n"); 658 pr_err("s2255: =======no frame\n");
658 return; 659 return;
@@ -660,7 +661,7 @@ static void s2255_fillbuff(struct s2255_channel *channel,
660 dprintk(dev, 2, "s2255fill at : Buffer 0x%08lx size= %d\n", 661 dprintk(dev, 2, "s2255fill at : Buffer 0x%08lx size= %d\n",
661 (unsigned long)vbuf, pos); 662 (unsigned long)vbuf, pos);
662 /* tell v4l buffer was filled */ 663 /* tell v4l buffer was filled */
663 buf->vb.field_count = channel->frame_count * 2; 664 buf->vb.field_count = vc->frame_count * 2;
664 v4l2_get_timestamp(&buf->vb.ts); 665 v4l2_get_timestamp(&buf->vb.ts);
665 buf->vb.state = VIDEOBUF_DONE; 666 buf->vb.state = VIDEOBUF_DONE;
666} 667}
@@ -674,8 +675,8 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
674 unsigned int *size) 675 unsigned int *size)
675{ 676{
676 struct s2255_fh *fh = vq->priv_data; 677 struct s2255_fh *fh = vq->priv_data;
677 struct s2255_channel *channel = fh->channel; 678 struct s2255_vc *vc = fh->vc;
678 *size = channel->width * channel->height * (channel->fmt->depth >> 3); 679 *size = vc->width * vc->height * (vc->fmt->depth >> 3);
679 680
680 if (0 == *count) 681 if (0 == *count)
681 *count = S2255_DEF_BUFS; 682 *count = S2255_DEF_BUFS;
@@ -696,29 +697,29 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
696 enum v4l2_field field) 697 enum v4l2_field field)
697{ 698{
698 struct s2255_fh *fh = vq->priv_data; 699 struct s2255_fh *fh = vq->priv_data;
699 struct s2255_channel *channel = fh->channel; 700 struct s2255_vc *vc = fh->vc;
700 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); 701 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
701 int rc; 702 int rc;
702 int w = channel->width; 703 int w = vc->width;
703 int h = channel->height; 704 int h = vc->height;
704 dprintk(fh->dev, 4, "%s, field=%d\n", __func__, field); 705 dprintk(fh->dev, 4, "%s, field=%d\n", __func__, field);
705 if (channel->fmt == NULL) 706 if (vc->fmt == NULL)
706 return -EINVAL; 707 return -EINVAL;
707 708
708 if ((w < norm_minw(channel)) || 709 if ((w < norm_minw(vc)) ||
709 (w > norm_maxw(channel)) || 710 (w > norm_maxw(vc)) ||
710 (h < norm_minh(channel)) || 711 (h < norm_minh(vc)) ||
711 (h > norm_maxh(channel))) { 712 (h > norm_maxh(vc))) {
712 dprintk(fh->dev, 4, "invalid buffer prepare\n"); 713 dprintk(fh->dev, 4, "invalid buffer prepare\n");
713 return -EINVAL; 714 return -EINVAL;
714 } 715 }
715 buf->vb.size = w * h * (channel->fmt->depth >> 3); 716 buf->vb.size = w * h * (vc->fmt->depth >> 3);
716 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) { 717 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) {
717 dprintk(fh->dev, 4, "invalid buffer prepare\n"); 718 dprintk(fh->dev, 4, "invalid buffer prepare\n");
718 return -EINVAL; 719 return -EINVAL;
719 } 720 }
720 721
721 buf->fmt = channel->fmt; 722 buf->fmt = vc->fmt;
722 buf->vb.width = w; 723 buf->vb.width = w;
723 buf->vb.height = h; 724 buf->vb.height = h;
724 buf->vb.field = field; 725 buf->vb.field = field;
@@ -740,10 +741,10 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
740{ 741{
741 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); 742 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
742 struct s2255_fh *fh = vq->priv_data; 743 struct s2255_fh *fh = vq->priv_data;
743 struct s2255_channel *channel = fh->channel; 744 struct s2255_vc *vc = fh->vc;
744 dprintk(fh->dev, 1, "%s\n", __func__); 745 dprintk(fh->dev, 1, "%s\n", __func__);
745 buf->vb.state = VIDEOBUF_QUEUED; 746 buf->vb.state = VIDEOBUF_QUEUED;
746 list_add_tail(&buf->vb.queue, &channel->buf_list); 747 list_add_tail(&buf->vb.queue, &vc->buf_list);
747} 748}
748 749
749static void buffer_release(struct videobuf_queue *vq, 750static void buffer_release(struct videobuf_queue *vq,
@@ -751,7 +752,7 @@ static void buffer_release(struct videobuf_queue *vq,
751{ 752{
752 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); 753 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
753 struct s2255_fh *fh = vq->priv_data; 754 struct s2255_fh *fh = vq->priv_data;
754 dprintk(fh->dev, 4, "%s %d\n", __func__, fh->channel->idx); 755 dprintk(fh->dev, 4, "%s %d\n", __func__, fh->vc->idx);
755 free_buffer(vq, buf); 756 free_buffer(vq, buf);
756} 757}
757 758
@@ -765,12 +766,12 @@ static struct videobuf_queue_ops s2255_video_qops = {
765 766
766static int res_get(struct s2255_fh *fh) 767static int res_get(struct s2255_fh *fh)
767{ 768{
768 struct s2255_channel *channel = fh->channel; 769 struct s2255_vc *vc = fh->vc;
769 /* is it free? */ 770 /* is it free? */
770 if (channel->resources) 771 if (vc->resources)
771 return 0; /* no, someone else uses it */ 772 return 0; /* no, someone else uses it */
772 /* it's free, grab it */ 773 /* it's free, grab it */
773 channel->resources = 1; 774 vc->resources = 1;
774 fh->resources = 1; 775 fh->resources = 1;
775 dprintk(fh->dev, 1, "s2255: res: get\n"); 776 dprintk(fh->dev, 1, "s2255: res: get\n");
776 return 1; 777 return 1;
@@ -778,7 +779,7 @@ static int res_get(struct s2255_fh *fh)
778 779
779static int res_locked(struct s2255_fh *fh) 780static int res_locked(struct s2255_fh *fh)
780{ 781{
781 return fh->channel->resources; 782 return fh->vc->resources;
782} 783}
783 784
784static int res_check(struct s2255_fh *fh) 785static int res_check(struct s2255_fh *fh)
@@ -789,8 +790,8 @@ static int res_check(struct s2255_fh *fh)
789 790
790static void res_free(struct s2255_fh *fh) 791static void res_free(struct s2255_fh *fh)
791{ 792{
792 struct s2255_channel *channel = fh->channel; 793 struct s2255_vc *vc = fh->vc;
793 channel->resources = 0; 794 vc->resources = 0;
794 fh->resources = 0; 795 fh->resources = 0;
795} 796}
796 797
@@ -827,18 +828,18 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
827 struct v4l2_format *f) 828 struct v4l2_format *f)
828{ 829{
829 struct s2255_fh *fh = priv; 830 struct s2255_fh *fh = priv;
830 struct s2255_channel *channel = fh->channel; 831 struct s2255_vc *vc = fh->vc;
831 int is_ntsc = channel->std & V4L2_STD_525_60; 832 int is_ntsc = vc->std & V4L2_STD_525_60;
832 833
833 f->fmt.pix.width = channel->width; 834 f->fmt.pix.width = vc->width;
834 f->fmt.pix.height = channel->height; 835 f->fmt.pix.height = vc->height;
835 if (f->fmt.pix.height >= 836 if (f->fmt.pix.height >=
836 (is_ntsc ? NUM_LINES_1CIFS_NTSC : NUM_LINES_1CIFS_PAL) * 2) 837 (is_ntsc ? NUM_LINES_1CIFS_NTSC : NUM_LINES_1CIFS_PAL) * 2)
837 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 838 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
838 else 839 else
839 f->fmt.pix.field = V4L2_FIELD_TOP; 840 f->fmt.pix.field = V4L2_FIELD_TOP;
840 f->fmt.pix.pixelformat = channel->fmt->fourcc; 841 f->fmt.pix.pixelformat = vc->fmt->fourcc;
841 f->fmt.pix.bytesperline = f->fmt.pix.width * (channel->fmt->depth >> 3); 842 f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3);
842 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 843 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
843 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 844 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
844 f->fmt.pix.priv = 0; 845 f->fmt.pix.priv = 0;
@@ -851,8 +852,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
851 const struct s2255_fmt *fmt; 852 const struct s2255_fmt *fmt;
852 enum v4l2_field field; 853 enum v4l2_field field;
853 struct s2255_fh *fh = priv; 854 struct s2255_fh *fh = priv;
854 struct s2255_channel *channel = fh->channel; 855 struct s2255_vc *vc = fh->vc;
855 int is_ntsc = channel->std & V4L2_STD_525_60; 856 int is_ntsc = vc->std & V4L2_STD_525_60;
856 857
857 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 858 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
858 859
@@ -912,7 +913,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
912 struct v4l2_format *f) 913 struct v4l2_format *f)
913{ 914{
914 struct s2255_fh *fh = priv; 915 struct s2255_fh *fh = priv;
915 struct s2255_channel *channel = fh->channel; 916 struct s2255_vc *vc = fh->vc;
916 const struct s2255_fmt *fmt; 917 const struct s2255_fmt *fmt;
917 struct videobuf_queue *q = &fh->vb_vidq; 918 struct videobuf_queue *q = &fh->vb_vidq;
918 struct s2255_mode mode; 919 struct s2255_mode mode;
@@ -941,15 +942,15 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
941 ret = -EBUSY; 942 ret = -EBUSY;
942 goto out_s_fmt; 943 goto out_s_fmt;
943 } 944 }
944 mode = channel->mode; 945 mode = vc->mode;
945 channel->fmt = fmt; 946 vc->fmt = fmt;
946 channel->width = f->fmt.pix.width; 947 vc->width = f->fmt.pix.width;
947 channel->height = f->fmt.pix.height; 948 vc->height = f->fmt.pix.height;
948 fh->vb_vidq.field = f->fmt.pix.field; 949 fh->vb_vidq.field = f->fmt.pix.field;
949 fh->type = f->type; 950 fh->type = f->type;
950 if (channel->width > norm_minw(channel)) { 951 if (vc->width > norm_minw(vc)) {
951 if (channel->height > norm_minh(channel)) { 952 if (vc->height > norm_minh(vc)) {
952 if (channel->cap_parm.capturemode & 953 if (vc->cap_parm.capturemode &
953 V4L2_MODE_HIGHQUALITY) 954 V4L2_MODE_HIGHQUALITY)
954 mode.scale = SCALE_4CIFSI; 955 mode.scale = SCALE_4CIFSI;
955 else 956 else
@@ -961,7 +962,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
961 mode.scale = SCALE_1CIFS; 962 mode.scale = SCALE_1CIFS;
962 } 963 }
963 /* color mode */ 964 /* color mode */
964 switch (channel->fmt->fourcc) { 965 switch (vc->fmt->fourcc) {
965 case V4L2_PIX_FMT_GREY: 966 case V4L2_PIX_FMT_GREY:
966 mode.color &= ~MASK_COLOR; 967 mode.color &= ~MASK_COLOR;
967 mode.color |= COLOR_Y8; 968 mode.color |= COLOR_Y8;
@@ -970,7 +971,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
970 case V4L2_PIX_FMT_MJPEG: 971 case V4L2_PIX_FMT_MJPEG:
971 mode.color &= ~MASK_COLOR; 972 mode.color &= ~MASK_COLOR;
972 mode.color |= COLOR_JPG; 973 mode.color |= COLOR_JPG;
973 mode.color |= (channel->jpegqual << 8); 974 mode.color |= (vc->jpegqual << 8);
974 break; 975 break;
975 case V4L2_PIX_FMT_YUV422P: 976 case V4L2_PIX_FMT_YUV422P:
976 mode.color &= ~MASK_COLOR; 977 mode.color &= ~MASK_COLOR;
@@ -983,14 +984,14 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
983 mode.color |= COLOR_YUVPK; 984 mode.color |= COLOR_YUVPK;
984 break; 985 break;
985 } 986 }
986 if ((mode.color & MASK_COLOR) != (channel->mode.color & MASK_COLOR)) 987 if ((mode.color & MASK_COLOR) != (vc->mode.color & MASK_COLOR))
987 mode.restart = 1; 988 mode.restart = 1;
988 else if (mode.scale != channel->mode.scale) 989 else if (mode.scale != vc->mode.scale)
989 mode.restart = 1; 990 mode.restart = 1;
990 else if (mode.format != channel->mode.format) 991 else if (mode.format != vc->mode.format)
991 mode.restart = 1; 992 mode.restart = 1;
992 channel->mode = mode; 993 vc->mode = mode;
993 (void) s2255_set_mode(channel, &mode); 994 (void) s2255_set_mode(vc, &mode);
994 ret = 0; 995 ret = 0;
995out_s_fmt: 996out_s_fmt:
996 mutex_unlock(&q->vb_lock); 997 mutex_unlock(&q->vb_lock);
@@ -1126,28 +1127,28 @@ static void s2255_print_cfg(struct s2255_dev *sdev, struct s2255_mode *mode)
1126 * When the restart parameter is set, we sleep for ONE frame to allow the 1127 * When the restart parameter is set, we sleep for ONE frame to allow the
1127 * DSP time to get the new frame 1128 * DSP time to get the new frame
1128 */ 1129 */
1129static int s2255_set_mode(struct s2255_channel *channel, 1130static int s2255_set_mode(struct s2255_vc *vc,
1130 struct s2255_mode *mode) 1131 struct s2255_mode *mode)
1131{ 1132{
1132 int res; 1133 int res;
1133 __le32 *buffer; 1134 __le32 *buffer;
1134 unsigned long chn_rev; 1135 unsigned long chn_rev;
1135 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 1136 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
1136 int i; 1137 int i;
1137 1138
1138 chn_rev = G_chnmap[channel->idx]; 1139 chn_rev = G_chnmap[vc->idx];
1139 dprintk(dev, 3, "%s channel: %d\n", __func__, channel->idx); 1140 dprintk(dev, 3, "%s channel: %d\n", __func__, vc->idx);
1140 /* if JPEG, set the quality */ 1141 /* if JPEG, set the quality */
1141 if ((mode->color & MASK_COLOR) == COLOR_JPG) { 1142 if ((mode->color & MASK_COLOR) == COLOR_JPG) {
1142 mode->color &= ~MASK_COLOR; 1143 mode->color &= ~MASK_COLOR;
1143 mode->color |= COLOR_JPG; 1144 mode->color |= COLOR_JPG;
1144 mode->color &= ~MASK_JPG_QUALITY; 1145 mode->color &= ~MASK_JPG_QUALITY;
1145 mode->color |= (channel->jpegqual << 8); 1146 mode->color |= (vc->jpegqual << 8);
1146 } 1147 }
1147 /* save the mode */ 1148 /* save the mode */
1148 channel->mode = *mode; 1149 vc->mode = *mode;
1149 channel->req_image_size = get_transfer_size(mode); 1150 vc->req_image_size = get_transfer_size(mode);
1150 dprintk(dev, 1, "%s: reqsize %ld\n", __func__, channel->req_image_size); 1151 dprintk(dev, 1, "%s: reqsize %ld\n", __func__, vc->req_image_size);
1151 buffer = kzalloc(512, GFP_KERNEL); 1152 buffer = kzalloc(512, GFP_KERNEL);
1152 if (buffer == NULL) { 1153 if (buffer == NULL) {
1153 dev_err(&dev->udev->dev, "out of mem\n"); 1154 dev_err(&dev->udev->dev, "out of mem\n");
@@ -1158,36 +1159,36 @@ static int s2255_set_mode(struct s2255_channel *channel,
1158 buffer[1] = (__le32) cpu_to_le32(chn_rev); 1159 buffer[1] = (__le32) cpu_to_le32(chn_rev);
1159 buffer[2] = CMD_SET_MODE; 1160 buffer[2] = CMD_SET_MODE;
1160 for (i = 0; i < sizeof(struct s2255_mode) / sizeof(u32); i++) 1161 for (i = 0; i < sizeof(struct s2255_mode) / sizeof(u32); i++)
1161 buffer[3 + i] = cpu_to_le32(((u32 *)&channel->mode)[i]); 1162 buffer[3 + i] = cpu_to_le32(((u32 *)&vc->mode)[i]);
1162 channel->setmode_ready = 0; 1163 vc->setmode_ready = 0;
1163 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); 1164 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512);
1164 if (debug) 1165 if (debug)
1165 s2255_print_cfg(dev, mode); 1166 s2255_print_cfg(dev, mode);
1166 kfree(buffer); 1167 kfree(buffer);
1167 /* wait at least 3 frames before continuing */ 1168 /* wait at least 3 frames before continuing */
1168 if (mode->restart) { 1169 if (mode->restart) {
1169 wait_event_timeout(channel->wait_setmode, 1170 wait_event_timeout(vc->wait_setmode,
1170 (channel->setmode_ready != 0), 1171 (vc->setmode_ready != 0),
1171 msecs_to_jiffies(S2255_SETMODE_TIMEOUT)); 1172 msecs_to_jiffies(S2255_SETMODE_TIMEOUT));
1172 if (channel->setmode_ready != 1) { 1173 if (vc->setmode_ready != 1) {
1173 dprintk(dev, 0, "s2255: no set mode response\n"); 1174 dprintk(dev, 0, "s2255: no set mode response\n");
1174 res = -EFAULT; 1175 res = -EFAULT;
1175 } 1176 }
1176 } 1177 }
1177 /* clear the restart flag */ 1178 /* clear the restart flag */
1178 channel->mode.restart = 0; 1179 vc->mode.restart = 0;
1179 dprintk(dev, 1, "%s chn %d, result: %d\n", __func__, channel->idx, res); 1180 dprintk(dev, 1, "%s chn %d, result: %d\n", __func__, vc->idx, res);
1180 return res; 1181 return res;
1181} 1182}
1182 1183
1183static int s2255_cmd_status(struct s2255_channel *channel, u32 *pstatus) 1184static int s2255_cmd_status(struct s2255_vc *vc, u32 *pstatus)
1184{ 1185{
1185 int res; 1186 int res;
1186 __le32 *buffer; 1187 __le32 *buffer;
1187 u32 chn_rev; 1188 u32 chn_rev;
1188 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 1189 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
1189 chn_rev = G_chnmap[channel->idx]; 1190 chn_rev = G_chnmap[vc->idx];
1190 dprintk(dev, 4, "%s chan %d\n", __func__, channel->idx); 1191 dprintk(dev, 4, "%s chan %d\n", __func__, vc->idx);
1191 buffer = kzalloc(512, GFP_KERNEL); 1192 buffer = kzalloc(512, GFP_KERNEL);
1192 if (buffer == NULL) { 1193 if (buffer == NULL) {
1193 dev_err(&dev->udev->dev, "out of mem\n"); 1194 dev_err(&dev->udev->dev, "out of mem\n");
@@ -1198,17 +1199,17 @@ static int s2255_cmd_status(struct s2255_channel *channel, u32 *pstatus)
1198 buffer[1] = (__le32) cpu_to_le32(chn_rev); 1199 buffer[1] = (__le32) cpu_to_le32(chn_rev);
1199 buffer[2] = CMD_STATUS; 1200 buffer[2] = CMD_STATUS;
1200 *pstatus = 0; 1201 *pstatus = 0;
1201 channel->vidstatus_ready = 0; 1202 vc->vidstatus_ready = 0;
1202 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); 1203 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512);
1203 kfree(buffer); 1204 kfree(buffer);
1204 wait_event_timeout(channel->wait_vidstatus, 1205 wait_event_timeout(vc->wait_vidstatus,
1205 (channel->vidstatus_ready != 0), 1206 (vc->vidstatus_ready != 0),
1206 msecs_to_jiffies(S2255_VIDSTATUS_TIMEOUT)); 1207 msecs_to_jiffies(S2255_VIDSTATUS_TIMEOUT));
1207 if (channel->vidstatus_ready != 1) { 1208 if (vc->vidstatus_ready != 1) {
1208 dprintk(dev, 0, "s2255: no vidstatus response\n"); 1209 dprintk(dev, 0, "s2255: no vidstatus response\n");
1209 res = -EFAULT; 1210 res = -EFAULT;
1210 } 1211 }
1211 *pstatus = channel->vidstatus; 1212 *pstatus = vc->vidstatus;
1212 dprintk(dev, 4, "%s, vid status %d\n", __func__, *pstatus); 1213 dprintk(dev, 4, "%s, vid status %d\n", __func__, *pstatus);
1213 return res; 1214 return res;
1214} 1215}
@@ -1218,7 +1219,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1218 int res; 1219 int res;
1219 struct s2255_fh *fh = priv; 1220 struct s2255_fh *fh = priv;
1220 struct s2255_dev *dev = fh->dev; 1221 struct s2255_dev *dev = fh->dev;
1221 struct s2255_channel *channel = fh->channel; 1222 struct s2255_vc *vc = fh->vc;
1222 int j; 1223 int j;
1223 dprintk(dev, 4, "%s\n", __func__); 1224 dprintk(dev, 4, "%s\n", __func__);
1224 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1225 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
@@ -1234,18 +1235,18 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1234 s2255_dev_err(&dev->udev->dev, "stream busy\n"); 1235 s2255_dev_err(&dev->udev->dev, "stream busy\n");
1235 return -EBUSY; 1236 return -EBUSY;
1236 } 1237 }
1237 channel->last_frame = -1; 1238 vc->last_frame = -1;
1238 channel->bad_payload = 0; 1239 vc->bad_payload = 0;
1239 channel->cur_frame = 0; 1240 vc->cur_frame = 0;
1240 channel->frame_count = 0; 1241 vc->frame_count = 0;
1241 for (j = 0; j < SYS_FRAMES; j++) { 1242 for (j = 0; j < SYS_FRAMES; j++) {
1242 channel->buffer.frame[j].ulState = S2255_READ_IDLE; 1243 vc->buffer.frame[j].ulState = S2255_READ_IDLE;
1243 channel->buffer.frame[j].cur_size = 0; 1244 vc->buffer.frame[j].cur_size = 0;
1244 } 1245 }
1245 res = videobuf_streamon(&fh->vb_vidq); 1246 res = videobuf_streamon(&fh->vb_vidq);
1246 if (res == 0) { 1247 if (res == 0) {
1247 s2255_start_acquire(channel); 1248 s2255_start_acquire(vc);
1248 channel->b_acquire = 1; 1249 vc->b_acquire = 1;
1249 } else 1250 } else
1250 res_free(fh); 1251 res_free(fh);
1251 1252
@@ -1255,14 +1256,14 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1255static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) 1256static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
1256{ 1257{
1257 struct s2255_fh *fh = priv; 1258 struct s2255_fh *fh = priv;
1258 dprintk(fh->dev, 4, "%s\n, channel: %d", __func__, fh->channel->idx); 1259 dprintk(fh->dev, 4, "%s\n, channel: %d", __func__, fh->vc->idx);
1259 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1260 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1260 dprintk(fh->dev, 1, "invalid fh type0\n"); 1261 dprintk(fh->dev, 1, "invalid fh type0\n");
1261 return -EINVAL; 1262 return -EINVAL;
1262 } 1263 }
1263 if (i != fh->type) 1264 if (i != fh->type)
1264 return -EINVAL; 1265 return -EINVAL;
1265 s2255_stop_acquire(fh->channel); 1266 s2255_stop_acquire(fh->vc);
1266 videobuf_streamoff(&fh->vb_vidq); 1267 videobuf_streamoff(&fh->vb_vidq);
1267 res_free(fh); 1268 res_free(fh);
1268 return 0; 1269 return 0;
@@ -1273,7 +1274,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i)
1273 struct s2255_fh *fh = priv; 1274 struct s2255_fh *fh = priv;
1274 struct s2255_mode mode; 1275 struct s2255_mode mode;
1275 struct videobuf_queue *q = &fh->vb_vidq; 1276 struct videobuf_queue *q = &fh->vb_vidq;
1276 struct s2255_channel *channel = fh->channel; 1277 struct s2255_vc *vc = fh->vc;
1277 int ret = 0; 1278 int ret = 0;
1278 1279
1279 mutex_lock(&q->vb_lock); 1280 mutex_lock(&q->vb_lock);
@@ -1282,7 +1283,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i)
1282 ret = -EBUSY; 1283 ret = -EBUSY;
1283 goto out_s_std; 1284 goto out_s_std;
1284 } 1285 }
1285 mode = fh->channel->mode; 1286 mode = fh->vc->mode;
1286 if (i & V4L2_STD_525_60) { 1287 if (i & V4L2_STD_525_60) {
1287 dprintk(fh->dev, 4, "%s 60 Hz\n", __func__); 1288 dprintk(fh->dev, 4, "%s 60 Hz\n", __func__);
1288 /* if changing format, reset frame decimation/intervals */ 1289 /* if changing format, reset frame decimation/intervals */
@@ -1290,8 +1291,8 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i)
1290 mode.restart = 1; 1291 mode.restart = 1;
1291 mode.format = FORMAT_NTSC; 1292 mode.format = FORMAT_NTSC;
1292 mode.fdec = FDEC_1; 1293 mode.fdec = FDEC_1;
1293 channel->width = LINE_SZ_4CIFS_NTSC; 1294 vc->width = LINE_SZ_4CIFS_NTSC;
1294 channel->height = NUM_LINES_4CIFS_NTSC * 2; 1295 vc->height = NUM_LINES_4CIFS_NTSC * 2;
1295 } 1296 }
1296 } else if (i & V4L2_STD_625_50) { 1297 } else if (i & V4L2_STD_625_50) {
1297 dprintk(fh->dev, 4, "%s 50 Hz\n", __func__); 1298 dprintk(fh->dev, 4, "%s 50 Hz\n", __func__);
@@ -1299,16 +1300,16 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i)
1299 mode.restart = 1; 1300 mode.restart = 1;
1300 mode.format = FORMAT_PAL; 1301 mode.format = FORMAT_PAL;
1301 mode.fdec = FDEC_1; 1302 mode.fdec = FDEC_1;
1302 channel->width = LINE_SZ_4CIFS_PAL; 1303 vc->width = LINE_SZ_4CIFS_PAL;
1303 channel->height = NUM_LINES_4CIFS_PAL * 2; 1304 vc->height = NUM_LINES_4CIFS_PAL * 2;
1304 } 1305 }
1305 } else { 1306 } else {
1306 ret = -EINVAL; 1307 ret = -EINVAL;
1307 goto out_s_std; 1308 goto out_s_std;
1308 } 1309 }
1309 fh->channel->std = i; 1310 fh->vc->std = i;
1310 if (mode.restart) 1311 if (mode.restart)
1311 s2255_set_mode(fh->channel, &mode); 1312 s2255_set_mode(fh->vc, &mode);
1312out_s_std: 1313out_s_std:
1313 mutex_unlock(&q->vb_lock); 1314 mutex_unlock(&q->vb_lock);
1314 return ret; 1315 return ret;
@@ -1318,7 +1319,7 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *i)
1318{ 1319{
1319 struct s2255_fh *fh = priv; 1320 struct s2255_fh *fh = priv;
1320 1321
1321 *i = fh->channel->std; 1322 *i = fh->vc->std;
1322 return 0; 1323 return 0;
1323} 1324}
1324 1325
@@ -1334,7 +1335,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
1334{ 1335{
1335 struct s2255_fh *fh = priv; 1336 struct s2255_fh *fh = priv;
1336 struct s2255_dev *dev = fh->dev; 1337 struct s2255_dev *dev = fh->dev;
1337 struct s2255_channel *channel = fh->channel; 1338 struct s2255_vc *vc = fh->vc;
1338 u32 status = 0; 1339 u32 status = 0;
1339 if (inp->index != 0) 1340 if (inp->index != 0)
1340 return -EINVAL; 1341 return -EINVAL;
@@ -1343,7 +1344,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
1343 inp->status = 0; 1344 inp->status = 0;
1344 if (dev->dsp_fw_ver >= S2255_MIN_DSP_STATUS) { 1345 if (dev->dsp_fw_ver >= S2255_MIN_DSP_STATUS) {
1345 int rc; 1346 int rc;
1346 rc = s2255_cmd_status(fh->channel, &status); 1347 rc = s2255_cmd_status(fh->vc, &status);
1347 dprintk(dev, 4, "s2255_cmd_status rc: %d status %x\n", 1348 dprintk(dev, 4, "s2255_cmd_status rc: %d status %x\n",
1348 rc, status); 1349 rc, status);
1349 if (rc == 0) 1350 if (rc == 0)
@@ -1356,7 +1357,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
1356 strlcpy(inp->name, "Composite", sizeof(inp->name)); 1357 strlcpy(inp->name, "Composite", sizeof(inp->name));
1357 break; 1358 break;
1358 case 0x2257: 1359 case 0x2257:
1359 strlcpy(inp->name, (channel->idx < 2) ? "Composite" : "S-Video", 1360 strlcpy(inp->name, (vc->idx < 2) ? "Composite" : "S-Video",
1360 sizeof(inp->name)); 1361 sizeof(inp->name));
1361 break; 1362 break;
1362 } 1363 }
@@ -1377,10 +1378,10 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1377 1378
1378static int s2255_s_ctrl(struct v4l2_ctrl *ctrl) 1379static int s2255_s_ctrl(struct v4l2_ctrl *ctrl)
1379{ 1380{
1380 struct s2255_channel *channel = 1381 struct s2255_vc *vc =
1381 container_of(ctrl->handler, struct s2255_channel, hdl); 1382 container_of(ctrl->handler, struct s2255_vc, hdl);
1382 struct s2255_mode mode; 1383 struct s2255_mode mode;
1383 mode = channel->mode; 1384 mode = vc->mode;
1384 /* update the mode to the corresponding value */ 1385 /* update the mode to the corresponding value */
1385 switch (ctrl->id) { 1386 switch (ctrl->id) {
1386 case V4L2_CID_BRIGHTNESS: 1387 case V4L2_CID_BRIGHTNESS:
@@ -1400,7 +1401,7 @@ static int s2255_s_ctrl(struct v4l2_ctrl *ctrl)
1400 mode.color |= !ctrl->val << 16; 1401 mode.color |= !ctrl->val << 16;
1401 break; 1402 break;
1402 case V4L2_CID_JPEG_COMPRESSION_QUALITY: 1403 case V4L2_CID_JPEG_COMPRESSION_QUALITY:
1403 channel->jpegqual = ctrl->val; 1404 vc->jpegqual = ctrl->val;
1404 return 0; 1405 return 0;
1405 default: 1406 default:
1406 return -EINVAL; 1407 return -EINVAL;
@@ -1410,7 +1411,7 @@ static int s2255_s_ctrl(struct v4l2_ctrl *ctrl)
1410 some V4L programs restart stream unnecessarily 1411 some V4L programs restart stream unnecessarily
1411 after a s_crtl. 1412 after a s_crtl.
1412 */ 1413 */
1413 s2255_set_mode(channel, &mode); 1414 s2255_set_mode(vc, &mode);
1414 return 0; 1415 return 0;
1415} 1416}
1416 1417
@@ -1418,10 +1419,10 @@ static int vidioc_g_jpegcomp(struct file *file, void *priv,
1418 struct v4l2_jpegcompression *jc) 1419 struct v4l2_jpegcompression *jc)
1419{ 1420{
1420 struct s2255_fh *fh = priv; 1421 struct s2255_fh *fh = priv;
1421 struct s2255_channel *channel = fh->channel; 1422 struct s2255_vc *vc = fh->vc;
1422 1423
1423 memset(jc, 0, sizeof(*jc)); 1424 memset(jc, 0, sizeof(*jc));
1424 jc->quality = channel->jpegqual; 1425 jc->quality = vc->jpegqual;
1425 dprintk(fh->dev, 2, "%s: quality %d\n", __func__, jc->quality); 1426 dprintk(fh->dev, 2, "%s: quality %d\n", __func__, jc->quality);
1426 return 0; 1427 return 0;
1427} 1428}
@@ -1430,10 +1431,10 @@ static int vidioc_s_jpegcomp(struct file *file, void *priv,
1430 const struct v4l2_jpegcompression *jc) 1431 const struct v4l2_jpegcompression *jc)
1431{ 1432{
1432 struct s2255_fh *fh = priv; 1433 struct s2255_fh *fh = priv;
1433 struct s2255_channel *channel = fh->channel; 1434 struct s2255_vc *vc = fh->vc;
1434 if (jc->quality < 0 || jc->quality > 100) 1435 if (jc->quality < 0 || jc->quality > 100)
1435 return -EINVAL; 1436 return -EINVAL;
1436 v4l2_ctrl_s_ctrl(channel->jpegqual_ctrl, jc->quality); 1437 v4l2_ctrl_s_ctrl(vc->jpegqual_ctrl, jc->quality);
1437 dprintk(fh->dev, 2, "%s: quality %d\n", __func__, jc->quality); 1438 dprintk(fh->dev, 2, "%s: quality %d\n", __func__, jc->quality);
1438 return 0; 1439 return 0;
1439} 1440}
@@ -1443,15 +1444,15 @@ static int vidioc_g_parm(struct file *file, void *priv,
1443{ 1444{
1444 struct s2255_fh *fh = priv; 1445 struct s2255_fh *fh = priv;
1445 __u32 def_num, def_dem; 1446 __u32 def_num, def_dem;
1446 struct s2255_channel *channel = fh->channel; 1447 struct s2255_vc *vc = fh->vc;
1447 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1448 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1448 return -EINVAL; 1449 return -EINVAL;
1449 sp->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; 1450 sp->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
1450 sp->parm.capture.capturemode = channel->cap_parm.capturemode; 1451 sp->parm.capture.capturemode = vc->cap_parm.capturemode;
1451 def_num = (channel->mode.format == FORMAT_NTSC) ? 1001 : 1000; 1452 def_num = (vc->mode.format == FORMAT_NTSC) ? 1001 : 1000;
1452 def_dem = (channel->mode.format == FORMAT_NTSC) ? 30000 : 25000; 1453 def_dem = (vc->mode.format == FORMAT_NTSC) ? 30000 : 25000;
1453 sp->parm.capture.timeperframe.denominator = def_dem; 1454 sp->parm.capture.timeperframe.denominator = def_dem;
1454 switch (channel->mode.fdec) { 1455 switch (vc->mode.fdec) {
1455 default: 1456 default:
1456 case FDEC_1: 1457 case FDEC_1:
1457 sp->parm.capture.timeperframe.numerator = def_num; 1458 sp->parm.capture.timeperframe.numerator = def_num;
@@ -1478,15 +1479,15 @@ static int vidioc_s_parm(struct file *file, void *priv,
1478 struct v4l2_streamparm *sp) 1479 struct v4l2_streamparm *sp)
1479{ 1480{
1480 struct s2255_fh *fh = priv; 1481 struct s2255_fh *fh = priv;
1481 struct s2255_channel *channel = fh->channel; 1482 struct s2255_vc *vc = fh->vc;
1482 struct s2255_mode mode; 1483 struct s2255_mode mode;
1483 int fdec = FDEC_1; 1484 int fdec = FDEC_1;
1484 __u32 def_num, def_dem; 1485 __u32 def_num, def_dem;
1485 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1486 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1486 return -EINVAL; 1487 return -EINVAL;
1487 mode = channel->mode; 1488 mode = vc->mode;
1488 /* high quality capture mode requires a stream restart */ 1489 /* high quality capture mode requires a stream restart */
1489 if (channel->cap_parm.capturemode 1490 if (vc->cap_parm.capturemode
1490 != sp->parm.capture.capturemode && res_locked(fh)) 1491 != sp->parm.capture.capturemode && res_locked(fh))
1491 return -EBUSY; 1492 return -EBUSY;
1492 def_num = (mode.format == FORMAT_NTSC) ? 1001 : 1000; 1493 def_num = (mode.format == FORMAT_NTSC) ? 1001 : 1000;
@@ -1507,7 +1508,7 @@ static int vidioc_s_parm(struct file *file, void *priv,
1507 } 1508 }
1508 mode.fdec = fdec; 1509 mode.fdec = fdec;
1509 sp->parm.capture.timeperframe.denominator = def_dem; 1510 sp->parm.capture.timeperframe.denominator = def_dem;
1510 s2255_set_mode(channel, &mode); 1511 s2255_set_mode(vc, &mode);
1511 dprintk(fh->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n", 1512 dprintk(fh->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n",
1512 __func__, 1513 __func__,
1513 sp->parm.capture.capturemode, 1514 sp->parm.capture.capturemode,
@@ -1532,8 +1533,8 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
1532 struct v4l2_frmsizeenum *fe) 1533 struct v4l2_frmsizeenum *fe)
1533{ 1534{
1534 struct s2255_fh *fh = priv; 1535 struct s2255_fh *fh = priv;
1535 struct s2255_channel *channel = fh->channel; 1536 struct s2255_vc *vc = fh->vc;
1536 int is_ntsc = channel->std & V4L2_STD_525_60; 1537 int is_ntsc = vc->std & V4L2_STD_525_60;
1537 const struct s2255_fmt *fmt; 1538 const struct s2255_fmt *fmt;
1538 1539
1539 if (fe->index >= NUM_SIZE_ENUMS) 1540 if (fe->index >= NUM_SIZE_ENUMS)
@@ -1551,10 +1552,10 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv,
1551 struct v4l2_frmivalenum *fe) 1552 struct v4l2_frmivalenum *fe)
1552{ 1553{
1553 struct s2255_fh *fh = priv; 1554 struct s2255_fh *fh = priv;
1554 struct s2255_channel *channel = fh->channel; 1555 struct s2255_vc *vc = fh->vc;
1555 const struct s2255_fmt *fmt; 1556 const struct s2255_fmt *fmt;
1556 const struct v4l2_frmsize_discrete *sizes; 1557 const struct v4l2_frmsize_discrete *sizes;
1557 int is_ntsc = channel->std & V4L2_STD_525_60; 1558 int is_ntsc = vc->std & V4L2_STD_525_60;
1558#define NUM_FRAME_ENUMS 4 1559#define NUM_FRAME_ENUMS 4
1559 int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5}; 1560 int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5};
1560 int i; 1561 int i;
@@ -1586,7 +1587,7 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv,
1586static int __s2255_open(struct file *file) 1587static int __s2255_open(struct file *file)
1587{ 1588{
1588 struct video_device *vdev = video_devdata(file); 1589 struct video_device *vdev = video_devdata(file);
1589 struct s2255_channel *channel = video_drvdata(file); 1590 struct s2255_vc *vc = video_drvdata(file);
1590 struct s2255_dev *dev = to_s2255_dev(vdev->v4l2_dev); 1591 struct s2255_dev *dev = to_s2255_dev(vdev->v4l2_dev);
1591 struct s2255_fh *fh; 1592 struct s2255_fh *fh;
1592 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1593 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1663,19 +1664,19 @@ static int __s2255_open(struct file *file)
1663 file->private_data = &fh->fh; 1664 file->private_data = &fh->fh;
1664 fh->dev = dev; 1665 fh->dev = dev;
1665 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1666 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1666 fh->channel = channel; 1667 fh->vc = vc;
1667 if (!channel->configured) { 1668 if (!vc->configured) {
1668 /* configure channel to default state */ 1669 /* configure channel to default state */
1669 channel->fmt = &formats[0]; 1670 vc->fmt = &formats[0];
1670 s2255_set_mode(channel, &channel->mode); 1671 s2255_set_mode(vc, &vc->mode);
1671 channel->configured = 1; 1672 vc->configured = 1;
1672 } 1673 }
1673 dprintk(dev, 1, "%s: dev=%s type=%s\n", __func__, 1674 dprintk(dev, 1, "%s: dev=%s type=%s\n", __func__,
1674 video_device_node_name(vdev), v4l2_type_names[type]); 1675 video_device_node_name(vdev), v4l2_type_names[type]);
1675 dprintk(dev, 2, "%s: fh=0x%08lx, dev=0x%08lx\n", __func__, 1676 dprintk(dev, 2, "%s: fh=0x%08lx, dev=0x%08lx\n", __func__,
1676 (unsigned long)fh, (unsigned long)dev); 1677 (unsigned long)fh, (unsigned long)dev);
1677 dprintk(dev, 4, "%s: list_empty active=%d\n", __func__, 1678 dprintk(dev, 4, "%s: list_empty active=%d\n", __func__,
1678 list_empty(&channel->buf_list)); 1679 list_empty(&vc->buf_list));
1679 videobuf_queue_vmalloc_init(&fh->vb_vidq, &s2255_video_qops, 1680 videobuf_queue_vmalloc_init(&fh->vb_vidq, &s2255_video_qops,
1680 NULL, &dev->slock, 1681 NULL, &dev->slock,
1681 fh->type, 1682 fh->type,
@@ -1741,14 +1742,14 @@ static int s2255_release(struct file *file)
1741 struct s2255_fh *fh = file->private_data; 1742 struct s2255_fh *fh = file->private_data;
1742 struct s2255_dev *dev = fh->dev; 1743 struct s2255_dev *dev = fh->dev;
1743 struct video_device *vdev = video_devdata(file); 1744 struct video_device *vdev = video_devdata(file);
1744 struct s2255_channel *channel = fh->channel; 1745 struct s2255_vc *vc = fh->vc;
1745 if (!dev) 1746 if (!dev)
1746 return -ENODEV; 1747 return -ENODEV;
1747 mutex_lock(&dev->lock); 1748 mutex_lock(&dev->lock);
1748 /* turn off stream */ 1749 /* turn off stream */
1749 if (res_check(fh)) { 1750 if (res_check(fh)) {
1750 if (channel->b_acquire) 1751 if (vc->b_acquire)
1751 s2255_stop_acquire(fh->channel); 1752 s2255_stop_acquire(fh->vc);
1752 videobuf_streamoff(&fh->vb_vidq); 1753 videobuf_streamoff(&fh->vb_vidq);
1753 res_free(fh); 1754 res_free(fh);
1754 } 1755 }
@@ -1820,13 +1821,13 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
1820static void s2255_video_device_release(struct video_device *vdev) 1821static void s2255_video_device_release(struct video_device *vdev)
1821{ 1822{
1822 struct s2255_dev *dev = to_s2255_dev(vdev->v4l2_dev); 1823 struct s2255_dev *dev = to_s2255_dev(vdev->v4l2_dev);
1823 struct s2255_channel *channel = 1824 struct s2255_vc *vc =
1824 container_of(vdev, struct s2255_channel, vdev); 1825 container_of(vdev, struct s2255_vc, vdev);
1825 1826
1826 dprintk(dev, 4, "%s, chnls: %d\n", __func__, 1827 dprintk(dev, 4, "%s, chnls: %d\n", __func__,
1827 atomic_read(&dev->num_channels)); 1828 atomic_read(&dev->num_channels));
1828 1829
1829 v4l2_ctrl_handler_free(&channel->hdl); 1830 v4l2_ctrl_handler_free(&vc->hdl);
1830 1831
1831 if (atomic_dec_and_test(&dev->num_channels)) 1832 if (atomic_dec_and_test(&dev->num_channels))
1832 s2255_destroy(dev); 1833 s2255_destroy(dev);
@@ -1860,52 +1861,52 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1860 int ret; 1861 int ret;
1861 int i; 1862 int i;
1862 int cur_nr = video_nr; 1863 int cur_nr = video_nr;
1863 struct s2255_channel *channel; 1864 struct s2255_vc *vc;
1864 ret = v4l2_device_register(&dev->interface->dev, &dev->v4l2_dev); 1865 ret = v4l2_device_register(&dev->interface->dev, &dev->v4l2_dev);
1865 if (ret) 1866 if (ret)
1866 return ret; 1867 return ret;
1867 /* initialize all video 4 linux */ 1868 /* initialize all video 4 linux */
1868 /* register 4 video devices */ 1869 /* register 4 video devices */
1869 for (i = 0; i < MAX_CHANNELS; i++) { 1870 for (i = 0; i < MAX_CHANNELS; i++) {
1870 channel = &dev->channel[i]; 1871 vc = &dev->vc[i];
1871 INIT_LIST_HEAD(&channel->buf_list); 1872 INIT_LIST_HEAD(&vc->buf_list);
1872 1873
1873 v4l2_ctrl_handler_init(&channel->hdl, 6); 1874 v4l2_ctrl_handler_init(&vc->hdl, 6);
1874 v4l2_ctrl_new_std(&channel->hdl, &s2255_ctrl_ops, 1875 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1875 V4L2_CID_BRIGHTNESS, -127, 127, 1, DEF_BRIGHT); 1876 V4L2_CID_BRIGHTNESS, -127, 127, 1, DEF_BRIGHT);
1876 v4l2_ctrl_new_std(&channel->hdl, &s2255_ctrl_ops, 1877 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1877 V4L2_CID_CONTRAST, 0, 255, 1, DEF_CONTRAST); 1878 V4L2_CID_CONTRAST, 0, 255, 1, DEF_CONTRAST);
1878 v4l2_ctrl_new_std(&channel->hdl, &s2255_ctrl_ops, 1879 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1879 V4L2_CID_SATURATION, 0, 255, 1, DEF_SATURATION); 1880 V4L2_CID_SATURATION, 0, 255, 1, DEF_SATURATION);
1880 v4l2_ctrl_new_std(&channel->hdl, &s2255_ctrl_ops, 1881 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1881 V4L2_CID_HUE, 0, 255, 1, DEF_HUE); 1882 V4L2_CID_HUE, 0, 255, 1, DEF_HUE);
1882 channel->jpegqual_ctrl = v4l2_ctrl_new_std(&channel->hdl, 1883 vc->jpegqual_ctrl = v4l2_ctrl_new_std(&vc->hdl,
1883 &s2255_ctrl_ops, 1884 &s2255_ctrl_ops,
1884 V4L2_CID_JPEG_COMPRESSION_QUALITY, 1885 V4L2_CID_JPEG_COMPRESSION_QUALITY,
1885 0, 100, 1, S2255_DEF_JPEG_QUAL); 1886 0, 100, 1, S2255_DEF_JPEG_QUAL);
1886 if (dev->dsp_fw_ver >= S2255_MIN_DSP_COLORFILTER && 1887 if (dev->dsp_fw_ver >= S2255_MIN_DSP_COLORFILTER &&
1887 (dev->pid != 0x2257 || channel->idx <= 1)) 1888 (dev->pid != 0x2257 || vc->idx <= 1))
1888 v4l2_ctrl_new_custom(&channel->hdl, &color_filter_ctrl, 1889 v4l2_ctrl_new_custom(&vc->hdl, &color_filter_ctrl,
1889 NULL); 1890 NULL);
1890 if (channel->hdl.error) { 1891 if (vc->hdl.error) {
1891 ret = channel->hdl.error; 1892 ret = vc->hdl.error;
1892 v4l2_ctrl_handler_free(&channel->hdl); 1893 v4l2_ctrl_handler_free(&vc->hdl);
1893 dev_err(&dev->udev->dev, "couldn't register control\n"); 1894 dev_err(&dev->udev->dev, "couldn't register control\n");
1894 break; 1895 break;
1895 } 1896 }
1896 /* register 4 video devices */ 1897 /* register 4 video devices */
1897 channel->vdev = template; 1898 vc->vdev = template;
1898 channel->vdev.ctrl_handler = &channel->hdl; 1899 vc->vdev.ctrl_handler = &vc->hdl;
1899 channel->vdev.lock = &dev->lock; 1900 vc->vdev.lock = &dev->lock;
1900 channel->vdev.v4l2_dev = &dev->v4l2_dev; 1901 vc->vdev.v4l2_dev = &dev->v4l2_dev;
1901 set_bit(V4L2_FL_USE_FH_PRIO, &channel->vdev.flags); 1902 set_bit(V4L2_FL_USE_FH_PRIO, &vc->vdev.flags);
1902 video_set_drvdata(&channel->vdev, channel); 1903 video_set_drvdata(&vc->vdev, vc);
1903 if (video_nr == -1) 1904 if (video_nr == -1)
1904 ret = video_register_device(&channel->vdev, 1905 ret = video_register_device(&vc->vdev,
1905 VFL_TYPE_GRABBER, 1906 VFL_TYPE_GRABBER,
1906 video_nr); 1907 video_nr);
1907 else 1908 else
1908 ret = video_register_device(&channel->vdev, 1909 ret = video_register_device(&vc->vdev,
1909 VFL_TYPE_GRABBER, 1910 VFL_TYPE_GRABBER,
1910 cur_nr + i); 1911 cur_nr + i);
1911 1912
@@ -1916,7 +1917,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1916 } 1917 }
1917 atomic_inc(&dev->num_channels); 1918 atomic_inc(&dev->num_channels);
1918 v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", 1919 v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n",
1919 video_device_node_name(&channel->vdev)); 1920 video_device_node_name(&vc->vdev));
1920 1921
1921 } 1922 }
1922 pr_info("Sensoray 2255 V4L driver Revision: %s\n", 1923 pr_info("Sensoray 2255 V4L driver Revision: %s\n",
@@ -1953,11 +1954,11 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
1953 s32 idx = -1; 1954 s32 idx = -1;
1954 struct s2255_framei *frm; 1955 struct s2255_framei *frm;
1955 unsigned char *pdata; 1956 unsigned char *pdata;
1956 struct s2255_channel *ch; 1957 struct s2255_vc *vc;
1957 dprintk(dev, 100, "buffer to user\n"); 1958 dprintk(dev, 100, "buffer to user\n");
1958 ch = &dev->channel[dev->cc]; 1959 vc = &dev->vc[dev->cc];
1959 idx = ch->cur_frame; 1960 idx = vc->cur_frame;
1960 frm = &ch->buffer.frame[idx]; 1961 frm = &vc->buffer.frame[idx];
1961 if (frm->ulState == S2255_READ_IDLE) { 1962 if (frm->ulState == S2255_READ_IDLE) {
1962 int jj; 1963 int jj;
1963 unsigned int cc; 1964 unsigned int cc;
@@ -1981,15 +1982,15 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
1981 } 1982 }
1982 /* reverse it */ 1983 /* reverse it */
1983 dev->cc = G_chnmap[cc]; 1984 dev->cc = G_chnmap[cc];
1984 ch = &dev->channel[dev->cc]; 1985 vc = &dev->vc[dev->cc];
1985 payload = le32_to_cpu(pdword[3]); 1986 payload = le32_to_cpu(pdword[3]);
1986 if (payload > ch->req_image_size) { 1987 if (payload > vc->req_image_size) {
1987 ch->bad_payload++; 1988 vc->bad_payload++;
1988 /* discard the bad frame */ 1989 /* discard the bad frame */
1989 return -EINVAL; 1990 return -EINVAL;
1990 } 1991 }
1991 ch->pkt_size = payload; 1992 vc->pkt_size = payload;
1992 ch->jpg_size = le32_to_cpu(pdword[4]); 1993 vc->jpg_size = le32_to_cpu(pdword[4]);
1993 break; 1994 break;
1994 case S2255_MARKER_RESPONSE: 1995 case S2255_MARKER_RESPONSE:
1995 1996
@@ -2000,13 +2001,13 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2000 cc = G_chnmap[le32_to_cpu(pdword[1])]; 2001 cc = G_chnmap[le32_to_cpu(pdword[1])];
2001 if (cc >= MAX_CHANNELS) 2002 if (cc >= MAX_CHANNELS)
2002 break; 2003 break;
2003 ch = &dev->channel[cc]; 2004 vc = &dev->vc[cc];
2004 switch (pdword[2]) { 2005 switch (pdword[2]) {
2005 case S2255_RESPONSE_SETMODE: 2006 case S2255_RESPONSE_SETMODE:
2006 /* check if channel valid */ 2007 /* check if channel valid */
2007 /* set mode ready */ 2008 /* set mode ready */
2008 ch->setmode_ready = 1; 2009 vc->setmode_ready = 1;
2009 wake_up(&ch->wait_setmode); 2010 wake_up(&vc->wait_setmode);
2010 dprintk(dev, 5, "setmode rdy %d\n", cc); 2011 dprintk(dev, 5, "setmode rdy %d\n", cc);
2011 break; 2012 break;
2012 case S2255_RESPONSE_FW: 2013 case S2255_RESPONSE_FW:
@@ -2020,9 +2021,9 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2020 wake_up(&dev->fw_data->wait_fw); 2021 wake_up(&dev->fw_data->wait_fw);
2021 break; 2022 break;
2022 case S2255_RESPONSE_STATUS: 2023 case S2255_RESPONSE_STATUS:
2023 ch->vidstatus = le32_to_cpu(pdword[3]); 2024 vc->vidstatus = le32_to_cpu(pdword[3]);
2024 ch->vidstatus_ready = 1; 2025 vc->vidstatus_ready = 1;
2025 wake_up(&ch->wait_vidstatus); 2026 wake_up(&vc->wait_vidstatus);
2026 dprintk(dev, 5, "vstat %x chan %d\n", 2027 dprintk(dev, 5, "vstat %x chan %d\n",
2027 le32_to_cpu(pdword[3]), cc); 2028 le32_to_cpu(pdword[3]), cc);
2028 break; 2029 break;
@@ -2039,11 +2040,11 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2039 if (!bframe) 2040 if (!bframe)
2040 return -EINVAL; 2041 return -EINVAL;
2041 } 2042 }
2042 ch = &dev->channel[dev->cc]; 2043 vc = &dev->vc[dev->cc];
2043 idx = ch->cur_frame; 2044 idx = vc->cur_frame;
2044 frm = &ch->buffer.frame[idx]; 2045 frm = &vc->buffer.frame[idx];
2045 /* search done. now find out if should be acquiring on this channel */ 2046 /* search done. now find out if should be acquiring on this channel */
2046 if (!ch->b_acquire) { 2047 if (!vc->b_acquire) {
2047 /* we found a frame, but this channel is turned off */ 2048 /* we found a frame, but this channel is turned off */
2048 frm->ulState = S2255_READ_IDLE; 2049 frm->ulState = S2255_READ_IDLE;
2049 return -EINVAL; 2050 return -EINVAL;
@@ -2068,10 +2069,10 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2068 2069
2069 copy_size = (pipe_info->cur_transfer_size - offset); 2070 copy_size = (pipe_info->cur_transfer_size - offset);
2070 2071
2071 size = ch->pkt_size - PREFIX_SIZE; 2072 size = vc->pkt_size - PREFIX_SIZE;
2072 2073
2073 /* sanity check on pdest */ 2074 /* sanity check on pdest */
2074 if ((copy_size + frm->cur_size) < ch->req_image_size) 2075 if ((copy_size + frm->cur_size) < vc->req_image_size)
2075 memcpy(pdest, psrc, copy_size); 2076 memcpy(pdest, psrc, copy_size);
2076 2077
2077 frm->cur_size += copy_size; 2078 frm->cur_size += copy_size;
@@ -2080,16 +2081,16 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2080 if (frm->cur_size >= size) { 2081 if (frm->cur_size >= size) {
2081 dprintk(dev, 2, "******[%d]Buffer[%d]full*******\n", 2082 dprintk(dev, 2, "******[%d]Buffer[%d]full*******\n",
2082 dev->cc, idx); 2083 dev->cc, idx);
2083 ch->last_frame = ch->cur_frame; 2084 vc->last_frame = vc->cur_frame;
2084 ch->cur_frame++; 2085 vc->cur_frame++;
2085 /* end of system frame ring buffer, start at zero */ 2086 /* end of system frame ring buffer, start at zero */
2086 if ((ch->cur_frame == SYS_FRAMES) || 2087 if ((vc->cur_frame == SYS_FRAMES) ||
2087 (ch->cur_frame == ch->buffer.dwFrames)) 2088 (vc->cur_frame == vc->buffer.dwFrames))
2088 ch->cur_frame = 0; 2089 vc->cur_frame = 0;
2089 /* frame ready */ 2090 /* frame ready */
2090 if (ch->b_acquire) 2091 if (vc->b_acquire)
2091 s2255_got_frame(ch, ch->jpg_size); 2092 s2255_got_frame(vc, vc->jpg_size);
2092 ch->frame_count++; 2093 vc->frame_count++;
2093 frm->ulState = S2255_READ_IDLE; 2094 frm->ulState = S2255_READ_IDLE;
2094 frm->cur_size = 0; 2095 frm->cur_size = 0;
2095 2096
@@ -2162,11 +2163,11 @@ static int s2255_get_fx2fw(struct s2255_dev *dev)
2162 * Create the system ring buffer to copy frames into from the 2163 * Create the system ring buffer to copy frames into from the
2163 * usb read pipe. 2164 * usb read pipe.
2164 */ 2165 */
2165static int s2255_create_sys_buffers(struct s2255_channel *channel) 2166static int s2255_create_sys_buffers(struct s2255_vc *vc)
2166{ 2167{
2167 unsigned long i; 2168 unsigned long i;
2168 unsigned long reqsize; 2169 unsigned long reqsize;
2169 channel->buffer.dwFrames = SYS_FRAMES; 2170 vc->buffer.dwFrames = SYS_FRAMES;
2170 /* always allocate maximum size(PAL) for system buffers */ 2171 /* always allocate maximum size(PAL) for system buffers */
2171 reqsize = SYS_FRAMES_MAXSIZE; 2172 reqsize = SYS_FRAMES_MAXSIZE;
2172 2173
@@ -2175,33 +2176,33 @@ static int s2255_create_sys_buffers(struct s2255_channel *channel)
2175 2176
2176 for (i = 0; i < SYS_FRAMES; i++) { 2177 for (i = 0; i < SYS_FRAMES; i++) {
2177 /* allocate the frames */ 2178 /* allocate the frames */
2178 channel->buffer.frame[i].lpvbits = vmalloc(reqsize); 2179 vc->buffer.frame[i].lpvbits = vmalloc(reqsize);
2179 channel->buffer.frame[i].size = reqsize; 2180 vc->buffer.frame[i].size = reqsize;
2180 if (channel->buffer.frame[i].lpvbits == NULL) { 2181 if (vc->buffer.frame[i].lpvbits == NULL) {
2181 pr_info("out of memory. using less frames\n"); 2182 pr_info("out of memory. using less frames\n");
2182 channel->buffer.dwFrames = i; 2183 vc->buffer.dwFrames = i;
2183 break; 2184 break;
2184 } 2185 }
2185 } 2186 }
2186 2187
2187 /* make sure internal states are set */ 2188 /* make sure internal states are set */
2188 for (i = 0; i < SYS_FRAMES; i++) { 2189 for (i = 0; i < SYS_FRAMES; i++) {
2189 channel->buffer.frame[i].ulState = 0; 2190 vc->buffer.frame[i].ulState = 0;
2190 channel->buffer.frame[i].cur_size = 0; 2191 vc->buffer.frame[i].cur_size = 0;
2191 } 2192 }
2192 2193
2193 channel->cur_frame = 0; 2194 vc->cur_frame = 0;
2194 channel->last_frame = -1; 2195 vc->last_frame = -1;
2195 return 0; 2196 return 0;
2196} 2197}
2197 2198
2198static int s2255_release_sys_buffers(struct s2255_channel *channel) 2199static int s2255_release_sys_buffers(struct s2255_vc *vc)
2199{ 2200{
2200 unsigned long i; 2201 unsigned long i;
2201 for (i = 0; i < SYS_FRAMES; i++) { 2202 for (i = 0; i < SYS_FRAMES; i++) {
2202 if (channel->buffer.frame[i].lpvbits) 2203 if (vc->buffer.frame[i].lpvbits)
2203 vfree(channel->buffer.frame[i].lpvbits); 2204 vfree(vc->buffer.frame[i].lpvbits);
2204 channel->buffer.frame[i].lpvbits = NULL; 2205 vc->buffer.frame[i].lpvbits = NULL;
2205 } 2206 }
2206 return 0; 2207 return 0;
2207} 2208}
@@ -2235,21 +2236,21 @@ static int s2255_board_init(struct s2255_dev *dev)
2235 pr_info("s2255: newer USB firmware available\n"); 2236 pr_info("s2255: newer USB firmware available\n");
2236 2237
2237 for (j = 0; j < MAX_CHANNELS; j++) { 2238 for (j = 0; j < MAX_CHANNELS; j++) {
2238 struct s2255_channel *channel = &dev->channel[j]; 2239 struct s2255_vc *vc = &dev->vc[j];
2239 channel->b_acquire = 0; 2240 vc->b_acquire = 0;
2240 channel->mode = mode_def; 2241 vc->mode = mode_def;
2241 if (dev->pid == 0x2257 && j > 1) 2242 if (dev->pid == 0x2257 && j > 1)
2242 channel->mode.color |= (1 << 16); 2243 vc->mode.color |= (1 << 16);
2243 channel->jpegqual = S2255_DEF_JPEG_QUAL; 2244 vc->jpegqual = S2255_DEF_JPEG_QUAL;
2244 channel->width = LINE_SZ_4CIFS_NTSC; 2245 vc->width = LINE_SZ_4CIFS_NTSC;
2245 channel->height = NUM_LINES_4CIFS_NTSC * 2; 2246 vc->height = NUM_LINES_4CIFS_NTSC * 2;
2246 channel->std = V4L2_STD_NTSC_M; 2247 vc->std = V4L2_STD_NTSC_M;
2247 channel->fmt = &formats[0]; 2248 vc->fmt = &formats[0];
2248 channel->mode.restart = 1; 2249 vc->mode.restart = 1;
2249 channel->req_image_size = get_transfer_size(&mode_def); 2250 vc->req_image_size = get_transfer_size(&mode_def);
2250 channel->frame_count = 0; 2251 vc->frame_count = 0;
2251 /* create the system buffers */ 2252 /* create the system buffers */
2252 s2255_create_sys_buffers(channel); 2253 s2255_create_sys_buffers(vc);
2253 } 2254 }
2254 /* start read pipe */ 2255 /* start read pipe */
2255 s2255_start_readpipe(dev); 2256 s2255_start_readpipe(dev);
@@ -2263,12 +2264,12 @@ static int s2255_board_shutdown(struct s2255_dev *dev)
2263 dprintk(dev, 1, "%s: dev: %p", __func__, dev); 2264 dprintk(dev, 1, "%s: dev: %p", __func__, dev);
2264 2265
2265 for (i = 0; i < MAX_CHANNELS; i++) { 2266 for (i = 0; i < MAX_CHANNELS; i++) {
2266 if (dev->channel[i].b_acquire) 2267 if (dev->vc[i].b_acquire)
2267 s2255_stop_acquire(&dev->channel[i]); 2268 s2255_stop_acquire(&dev->vc[i]);
2268 } 2269 }
2269 s2255_stop_readpipe(dev); 2270 s2255_stop_readpipe(dev);
2270 for (i = 0; i < MAX_CHANNELS; i++) 2271 for (i = 0; i < MAX_CHANNELS; i++)
2271 s2255_release_sys_buffers(&dev->channel[i]); 2272 s2255_release_sys_buffers(&dev->vc[i]);
2272 /* release transfer buffer */ 2273 /* release transfer buffer */
2273 kfree(dev->pipe.transfer_buffer); 2274 kfree(dev->pipe.transfer_buffer);
2274 return 0; 2275 return 0;
@@ -2357,26 +2358,26 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
2357} 2358}
2358 2359
2359/* starts acquisition process */ 2360/* starts acquisition process */
2360static int s2255_start_acquire(struct s2255_channel *channel) 2361static int s2255_start_acquire(struct s2255_vc *vc)
2361{ 2362{
2362 unsigned char *buffer; 2363 unsigned char *buffer;
2363 int res; 2364 int res;
2364 unsigned long chn_rev; 2365 unsigned long chn_rev;
2365 int j; 2366 int j;
2366 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 2367 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
2367 chn_rev = G_chnmap[channel->idx]; 2368 chn_rev = G_chnmap[vc->idx];
2368 buffer = kzalloc(512, GFP_KERNEL); 2369 buffer = kzalloc(512, GFP_KERNEL);
2369 if (buffer == NULL) { 2370 if (buffer == NULL) {
2370 dev_err(&dev->udev->dev, "out of mem\n"); 2371 dev_err(&dev->udev->dev, "out of mem\n");
2371 return -ENOMEM; 2372 return -ENOMEM;
2372 } 2373 }
2373 2374
2374 channel->last_frame = -1; 2375 vc->last_frame = -1;
2375 channel->bad_payload = 0; 2376 vc->bad_payload = 0;
2376 channel->cur_frame = 0; 2377 vc->cur_frame = 0;
2377 for (j = 0; j < SYS_FRAMES; j++) { 2378 for (j = 0; j < SYS_FRAMES; j++) {
2378 channel->buffer.frame[j].ulState = 0; 2379 vc->buffer.frame[j].ulState = 0;
2379 channel->buffer.frame[j].cur_size = 0; 2380 vc->buffer.frame[j].cur_size = 0;
2380 } 2381 }
2381 2382
2382 /* send the start command */ 2383 /* send the start command */
@@ -2387,18 +2388,18 @@ static int s2255_start_acquire(struct s2255_channel *channel)
2387 if (res != 0) 2388 if (res != 0)
2388 dev_err(&dev->udev->dev, "CMD_START error\n"); 2389 dev_err(&dev->udev->dev, "CMD_START error\n");
2389 2390
2390 dprintk(dev, 2, "start acquire exit[%d] %d\n", channel->idx, res); 2391 dprintk(dev, 2, "start acquire exit[%d] %d\n", vc->idx, res);
2391 kfree(buffer); 2392 kfree(buffer);
2392 return 0; 2393 return 0;
2393} 2394}
2394 2395
2395static int s2255_stop_acquire(struct s2255_channel *channel) 2396static int s2255_stop_acquire(struct s2255_vc *vc)
2396{ 2397{
2397 unsigned char *buffer; 2398 unsigned char *buffer;
2398 int res; 2399 int res;
2399 unsigned long chn_rev; 2400 unsigned long chn_rev;
2400 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 2401 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
2401 chn_rev = G_chnmap[channel->idx]; 2402 chn_rev = G_chnmap[vc->idx];
2402 buffer = kzalloc(512, GFP_KERNEL); 2403 buffer = kzalloc(512, GFP_KERNEL);
2403 if (buffer == NULL) { 2404 if (buffer == NULL) {
2404 dev_err(&dev->udev->dev, "out of mem\n"); 2405 dev_err(&dev->udev->dev, "out of mem\n");
@@ -2412,8 +2413,8 @@ static int s2255_stop_acquire(struct s2255_channel *channel)
2412 if (res != 0) 2413 if (res != 0)
2413 dev_err(&dev->udev->dev, "CMD_STOP error\n"); 2414 dev_err(&dev->udev->dev, "CMD_STOP error\n");
2414 kfree(buffer); 2415 kfree(buffer);
2415 channel->b_acquire = 0; 2416 vc->b_acquire = 0;
2416 dprintk(dev, 4, "%s: chn %d, res %d\n", __func__, channel->idx, res); 2417 dprintk(dev, 4, "%s: chn %d, res %d\n", __func__, vc->idx, res);
2417 return res; 2418 return res;
2418} 2419}
2419 2420
@@ -2503,11 +2504,11 @@ static int s2255_probe(struct usb_interface *interface,
2503 dev->timer.data = (unsigned long)dev->fw_data; 2504 dev->timer.data = (unsigned long)dev->fw_data;
2504 init_waitqueue_head(&dev->fw_data->wait_fw); 2505 init_waitqueue_head(&dev->fw_data->wait_fw);
2505 for (i = 0; i < MAX_CHANNELS; i++) { 2506 for (i = 0; i < MAX_CHANNELS; i++) {
2506 struct s2255_channel *channel = &dev->channel[i]; 2507 struct s2255_vc *vc = &dev->vc[i];
2507 channel->idx = i; 2508 vc->idx = i;
2508 channel->dev = dev; 2509 vc->dev = dev;
2509 init_waitqueue_head(&channel->wait_setmode); 2510 init_waitqueue_head(&vc->wait_setmode);
2510 init_waitqueue_head(&channel->wait_vidstatus); 2511 init_waitqueue_head(&vc->wait_vidstatus);
2511 } 2512 }
2512 2513
2513 dev->fw_data->fw_urb = usb_alloc_urb(0, GFP_KERNEL); 2514 dev->fw_data->fw_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -2595,15 +2596,15 @@ static void s2255_disconnect(struct usb_interface *interface)
2595 atomic_inc(&dev->num_channels); 2596 atomic_inc(&dev->num_channels);
2596 /* unregister each video device. */ 2597 /* unregister each video device. */
2597 for (i = 0; i < channels; i++) 2598 for (i = 0; i < channels; i++)
2598 video_unregister_device(&dev->channel[i].vdev); 2599 video_unregister_device(&dev->vc[i].vdev);
2599 /* wake up any of our timers */ 2600 /* wake up any of our timers */
2600 atomic_set(&dev->fw_data->fw_state, S2255_FW_DISCONNECTING); 2601 atomic_set(&dev->fw_data->fw_state, S2255_FW_DISCONNECTING);
2601 wake_up(&dev->fw_data->wait_fw); 2602 wake_up(&dev->fw_data->wait_fw);
2602 for (i = 0; i < MAX_CHANNELS; i++) { 2603 for (i = 0; i < MAX_CHANNELS; i++) {
2603 dev->channel[i].setmode_ready = 1; 2604 dev->vc[i].setmode_ready = 1;
2604 wake_up(&dev->channel[i].wait_setmode); 2605 wake_up(&dev->vc[i].wait_setmode);
2605 dev->channel[i].vidstatus_ready = 1; 2606 dev->vc[i].vidstatus_ready = 1;
2606 wake_up(&dev->channel[i].wait_vidstatus); 2607 wake_up(&dev->vc[i].wait_vidstatus);
2607 } 2608 }
2608 if (atomic_dec_and_test(&dev->num_channels)) 2609 if (atomic_dec_and_test(&dev->num_channels))
2609 s2255_destroy(dev); 2610 s2255_destroy(dev);