Lines Matching refs:vc

248 	struct s2255_vc         vc[MAX_CHANNELS];
337 static int s2255_start_acquire(struct s2255_vc *vc);
338 static int s2255_stop_acquire(struct s2255_vc *vc);
339 static void s2255_fillbuff(struct s2255_vc *vc, struct s2255_buffer *buf,
341 static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode *mode);
409 static int norm_maxw(struct s2255_vc *vc)
411 return (vc->std & V4L2_STD_525_60) ?
415 static int norm_maxh(struct s2255_vc *vc)
417 return (vc->std & V4L2_STD_525_60) ?
421 static int norm_minw(struct s2255_vc *vc)
423 return (vc->std & V4L2_STD_525_60) ?
427 static int norm_minh(struct s2255_vc *vc)
429 return (vc->std & V4L2_STD_525_60) ?
543 static void s2255_got_frame(struct s2255_vc *vc, int jpgsize)
546 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
549 spin_lock_irqsave(&vc->qlock, flags);
550 if (list_empty(&vc->buf_list)) {
552 spin_unlock_irqrestore(&vc->qlock, flags);
555 buf = list_entry(vc->buf_list.next,
559 buf->vb.field = vc->field;
560 buf->vb.sequence = vc->frame_count;
561 spin_unlock_irqrestore(&vc->qlock, flags);
563 s2255_fillbuff(vc, buf, jpgsize);
592 static void s2255_fillbuff(struct s2255_vc *vc,
599 struct s2255_dev *dev = vc->dev;
603 last_frame = vc->last_frame;
606 (const char *)vc->buffer.frame[last_frame].lpvbits;
607 switch (vc->fmt->fourcc) {
611 vbuf, vc->width,
612 vc->height,
613 vc->fmt->fourcc);
616 memcpy(vbuf, tmpbuf, vc->width * vc->height);
625 vc->width * vc->height * 2);
630 vc->last_frame = -1;
648 struct s2255_vc *vc = vb2_get_drv_priv(vq);
652 sizes[0] = vc->width * vc->height * (vc->fmt->depth >> 3);
658 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue);
661 int w = vc->width;
662 int h = vc->height;
665 dprintk(vc->dev, 4, "%s\n", __func__);
666 if (vc->fmt == NULL)
669 if ((w < norm_minw(vc)) ||
670 (w > norm_maxw(vc)) ||
671 (h < norm_minh(vc)) ||
672 (h > norm_maxh(vc))) {
673 dprintk(vc->dev, 4, "invalid buffer prepare\n");
676 size = w * h * (vc->fmt->depth >> 3);
678 dprintk(vc->dev, 4, "invalid buffer prepare\n");
690 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue);
692 dprintk(vc->dev, 1, "%s\n", __func__);
693 spin_lock_irqsave(&vc->qlock, flags);
694 list_add_tail(&buf->list, &vc->buf_list);
695 spin_unlock_irqrestore(&vc->qlock, flags);
714 struct s2255_vc *vc = video_drvdata(file);
715 struct s2255_dev *dev = vc->dev;
740 struct s2255_vc *vc = video_drvdata(file);
741 int is_ntsc = vc->std & V4L2_STD_525_60;
743 f->fmt.pix.width = vc->width;
744 f->fmt.pix.height = vc->height;
750 f->fmt.pix.pixelformat = vc->fmt->fourcc;
751 f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3);
762 struct s2255_vc *vc = video_drvdata(file);
763 int is_ntsc = vc->std & V4L2_STD_525_60;
772 dprintk(vc->dev, 50, "%s NTSC: %d suggested width: %d, height: %d\n",
805 dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__,
813 struct s2255_vc *vc = video_drvdata(file);
815 struct vb2_queue *q = &vc->vb_vidq;
819 ret = vidioc_try_fmt_vid_cap(file, vc, f);
830 dprintk(vc->dev, 1, "queue busy\n");
834 mode = vc->mode;
835 vc->fmt = fmt;
836 vc->width = f->fmt.pix.width;
837 vc->height = f->fmt.pix.height;
838 vc->field = f->fmt.pix.field;
839 if (vc->width > norm_minw(vc)) {
840 if (vc->height > norm_minh(vc)) {
841 if (vc->cap_parm.capturemode &
853 switch (vc->fmt->fourcc) {
862 mode.color |= (vc->jpegqual << 8);
875 if ((mode.color & MASK_COLOR) != (vc->mode.color & MASK_COLOR))
877 else if (mode.scale != vc->mode.scale)
879 else if (mode.format != vc->mode.format)
881 vc->mode = mode;
882 (void) s2255_set_mode(vc, &mode);
983 static int s2255_set_mode(struct s2255_vc *vc,
988 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
993 chn_rev = G_chnmap[vc->idx];
994 dprintk(dev, 3, "%s channel: %d\n", __func__, vc->idx);
1000 mode->color |= (vc->jpegqual << 8);
1003 vc->mode = *mode;
1004 vc->req_image_size = get_transfer_size(mode);
1005 dprintk(dev, 1, "%s: reqsize %ld\n", __func__, vc->req_image_size);
1011 buffer[3 + i] = cpu_to_le32(((u32 *)&vc->mode)[i]);
1012 vc->setmode_ready = 0;
1018 wait_event_timeout(vc->wait_setmode,
1019 (vc->setmode_ready != 0),
1021 if (vc->setmode_ready != 1) {
1027 vc->mode.restart = 0;
1028 dprintk(dev, 1, "%s chn %d, result: %d\n", __func__, vc->idx, res);
1033 static int s2255_cmd_status(struct s2255_vc *vc, u32 *pstatus)
1037 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
1041 chn_rev = G_chnmap[vc->idx];
1042 dprintk(dev, 4, "%s chan %d\n", __func__, vc->idx);
1048 vc->vidstatus_ready = 0;
1050 wait_event_timeout(vc->wait_vidstatus,
1051 (vc->vidstatus_ready != 0),
1053 if (vc->vidstatus_ready != 1) {
1057 *pstatus = vc->vidstatus;
1065 struct s2255_vc *vc = vb2_get_drv_priv(vq);
1068 vc->last_frame = -1;
1069 vc->bad_payload = 0;
1070 vc->cur_frame = 0;
1071 vc->frame_count = 0;
1073 vc->buffer.frame[j].ulState = S2255_READ_IDLE;
1074 vc->buffer.frame[j].cur_size = 0;
1076 return s2255_start_acquire(vc);
1082 struct s2255_vc *vc = vb2_get_drv_priv(vq);
1085 (void) s2255_stop_acquire(vc);
1086 spin_lock_irqsave(&vc->qlock, flags);
1087 list_for_each_entry_safe(buf, node, &vc->buf_list, list) {
1090 dprintk(vc->dev, 2, "[%p/%d] done\n",
1093 spin_unlock_irqrestore(&vc->qlock, flags);
1098 struct s2255_vc *vc = video_drvdata(file);
1100 struct vb2_queue *q = &vc->vb_vidq;
1109 mode = vc->mode;
1111 dprintk(vc->dev, 4, "%s 60 Hz\n", __func__);
1117 vc->width = LINE_SZ_4CIFS_NTSC;
1118 vc->height = NUM_LINES_4CIFS_NTSC * 2;
1121 dprintk(vc->dev, 4, "%s 50 Hz\n", __func__);
1126 vc->width = LINE_SZ_4CIFS_PAL;
1127 vc->height = NUM_LINES_4CIFS_PAL * 2;
1131 vc->std = i;
1133 s2255_set_mode(vc, &mode);
1139 struct s2255_vc *vc = video_drvdata(file);
1141 *i = vc->std;
1155 struct s2255_vc *vc = video_drvdata(file);
1156 struct s2255_dev *dev = vc->dev;
1166 rc = s2255_cmd_status(vc, &status);
1179 strscpy(inp->name, (vc->idx < 2) ? "Composite" : "S-Video",
1200 struct s2255_vc *vc =
1203 mode = vc->mode;
1223 vc->jpegqual = ctrl->val;
1233 s2255_set_mode(vc, &mode);
1240 struct s2255_vc *vc = video_drvdata(file);
1243 jc->quality = vc->jpegqual;
1244 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality);
1251 struct s2255_vc *vc = video_drvdata(file);
1255 v4l2_ctrl_s_ctrl(vc->jpegqual_ctrl, jc->quality);
1256 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality);
1264 struct s2255_vc *vc = video_drvdata(file);
1269 sp->parm.capture.capturemode = vc->cap_parm.capturemode;
1271 def_num = (vc->mode.format == FORMAT_NTSC) ? 1001 : 1000;
1272 def_dem = (vc->mode.format == FORMAT_NTSC) ? 30000 : 25000;
1274 switch (vc->mode.fdec) {
1289 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d\n",
1300 struct s2255_vc *vc = video_drvdata(file);
1306 mode = vc->mode;
1308 if ((vc->cap_parm.capturemode != sp->parm.capture.capturemode)
1309 && vb2_is_streaming(&vc->vb_vidq))
1330 s2255_set_mode(vc, &mode);
1331 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n",
1354 struct s2255_vc *vc = video_drvdata(file);
1355 int is_ntsc = vc->std & V4L2_STD_525_60;
1372 struct s2255_vc *vc = video_drvdata(file);
1375 int is_ntsc = vc->std & V4L2_STD_525_60;
1398 dprintk(vc->dev, 4, "%s discrete %d/%d\n", __func__,
1406 struct s2255_vc *vc = video_drvdata(file);
1407 struct s2255_dev *dev = vc->dev;
1477 if (!vc->configured) {
1479 vc->fmt = &formats[0];
1480 s2255_set_mode(vc, &vc->mode);
1481 vc->configured = 1;
1551 struct s2255_vc *vc =
1557 v4l2_ctrl_handler_free(&vc->hdl);
1591 struct s2255_vc *vc;
1600 vc = &dev->vc[i];
1601 INIT_LIST_HEAD(&vc->buf_list);
1603 v4l2_ctrl_handler_init(&vc->hdl, 6);
1604 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1606 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1608 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1610 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1612 vc->jpegqual_ctrl = v4l2_ctrl_new_std(&vc->hdl,
1617 (dev->pid != 0x2257 || vc->idx <= 1))
1618 v4l2_ctrl_new_custom(&vc->hdl, &color_filter_ctrl,
1620 if (vc->hdl.error) {
1621 ret = vc->hdl.error;
1622 v4l2_ctrl_handler_free(&vc->hdl);
1626 q = &vc->vb_vidq;
1629 q->drv_priv = vc;
1630 q->lock = &vc->vb_lock;
1642 vc->vdev = template;
1643 vc->vdev.queue = q;
1644 vc->vdev.ctrl_handler = &vc->hdl;
1645 vc->vdev.lock = &dev->lock;
1646 vc->vdev.v4l2_dev = &dev->v4l2_dev;
1647 vc->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE |
1649 video_set_drvdata(&vc->vdev, vc);
1651 ret = video_register_device(&vc->vdev,
1655 ret = video_register_device(&vc->vdev,
1666 video_device_node_name(&vc->vdev));
1703 struct s2255_vc *vc;
1705 vc = &dev->vc[dev->cc];
1706 idx = vc->cur_frame;
1707 frm = &vc->buffer.frame[idx];
1731 vc = &dev->vc[dev->cc];
1733 if (payload > vc->req_image_size) {
1734 vc->bad_payload++;
1738 vc->pkt_size = payload;
1739 vc->jpg_size = le32_to_cpu(pdword[4]);
1750 vc = &dev->vc[cc];
1755 vc->setmode_ready = 1;
1756 wake_up(&vc->wait_setmode);
1770 vc->vidstatus = le32_to_cpu(pdword[3]);
1771 vc->vidstatus_ready = 1;
1772 wake_up(&vc->wait_vidstatus);
1791 vc = &dev->vc[dev->cc];
1792 idx = vc->cur_frame;
1793 frm = &vc->buffer.frame[idx];
1795 if (!vb2_is_streaming(&vc->vb_vidq)) {
1820 size = vc->pkt_size - PREFIX_SIZE;
1823 if ((copy_size + frm->cur_size) < vc->req_image_size)
1832 vc->last_frame = vc->cur_frame;
1833 vc->cur_frame++;
1835 if ((vc->cur_frame == SYS_FRAMES) ||
1836 (vc->cur_frame == vc->buffer.dwFrames))
1837 vc->cur_frame = 0;
1839 if (vb2_is_streaming(&vc->vb_vidq))
1840 s2255_got_frame(vc, vc->jpg_size);
1841 vc->frame_count++;
1925 static int s2255_create_sys_buffers(struct s2255_vc *vc)
1929 vc->buffer.dwFrames = SYS_FRAMES;
1938 vc->buffer.frame[i].lpvbits = vmalloc(reqsize);
1939 vc->buffer.frame[i].size = reqsize;
1940 if (vc->buffer.frame[i].lpvbits == NULL) {
1942 vc->buffer.dwFrames = i;
1949 vc->buffer.frame[i].ulState = 0;
1950 vc->buffer.frame[i].cur_size = 0;
1953 vc->cur_frame = 0;
1954 vc->last_frame = -1;
1958 static int s2255_release_sys_buffers(struct s2255_vc *vc)
1962 vfree(vc->buffer.frame[i].lpvbits);
1963 vc->buffer.frame[i].lpvbits = NULL;
1997 struct s2255_vc *vc = &dev->vc[j];
1998 vc->mode = mode_def;
2000 vc->mode.color |= (1 << 16);
2001 vc->jpegqual = S2255_DEF_JPEG_QUAL;
2002 vc->width = LINE_SZ_4CIFS_NTSC;
2003 vc->height = NUM_LINES_4CIFS_NTSC * 2;
2004 vc->std = V4L2_STD_NTSC_M;
2005 vc->fmt = &formats[0];
2006 vc->mode.restart = 1;
2007 vc->req_image_size = get_transfer_size(&mode_def);
2008 vc->frame_count = 0;
2010 s2255_create_sys_buffers(vc);
2024 if (vb2_is_streaming(&dev->vc[i].vb_vidq))
2025 s2255_stop_acquire(&dev->vc[i]);
2029 s2255_release_sys_buffers(&dev->vc[i]);
2115 static int s2255_start_acquire(struct s2255_vc *vc)
2120 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
2124 chn_rev = G_chnmap[vc->idx];
2125 vc->last_frame = -1;
2126 vc->bad_payload = 0;
2127 vc->cur_frame = 0;
2129 vc->buffer.frame[j].ulState = 0;
2130 vc->buffer.frame[j].cur_size = 0;
2141 dprintk(dev, 2, "start acquire exit[%d] %d\n", vc->idx, res);
2146 static int s2255_stop_acquire(struct s2255_vc *vc)
2150 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
2154 chn_rev = G_chnmap[vc->idx];
2164 dprintk(dev, 4, "%s: chn %d, res %d\n", __func__, vc->idx, res);
2261 struct s2255_vc *vc = &dev->vc[i];
2262 vc->idx = i;
2263 vc->dev = dev;
2264 init_waitqueue_head(&vc->wait_setmode);
2265 init_waitqueue_head(&vc->wait_vidstatus);
2266 spin_lock_init(&vc->qlock);
2267 mutex_init(&vc->vb_lock);
2353 video_unregister_device(&dev->vc[i].vdev);
2358 dev->vc[i].setmode_ready = 1;
2359 wake_up(&dev->vc[i].wait_setmode);
2360 dev->vc[i].vidstatus_ready = 1;
2361 wake_up(&dev->vc[i].wait_vidstatus);