Lines Matching full:vc
248 struct s2255_vc vc[MAX_CHANNELS]; member
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) in norm_maxw() argument
411 return (vc->std & V4L2_STD_525_60) ? in norm_maxw()
415 static int norm_maxh(struct s2255_vc *vc) in norm_maxh() argument
417 return (vc->std & V4L2_STD_525_60) ? in norm_maxh()
421 static int norm_minw(struct s2255_vc *vc) in norm_minw() argument
423 return (vc->std & V4L2_STD_525_60) ? in norm_minw()
427 static int norm_minh(struct s2255_vc *vc) in norm_minh() argument
429 return (vc->std & V4L2_STD_525_60) ? in norm_minh()
543 static void s2255_got_frame(struct s2255_vc *vc, int jpgsize) in s2255_got_frame() argument
546 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_got_frame()
549 spin_lock_irqsave(&vc->qlock, flags); in s2255_got_frame()
550 if (list_empty(&vc->buf_list)) { in s2255_got_frame()
552 spin_unlock_irqrestore(&vc->qlock, flags); in s2255_got_frame()
555 buf = list_entry(vc->buf_list.next, in s2255_got_frame()
559 buf->vb.field = vc->field; in s2255_got_frame()
560 buf->vb.sequence = vc->frame_count; in s2255_got_frame()
561 spin_unlock_irqrestore(&vc->qlock, flags); in s2255_got_frame()
563 s2255_fillbuff(vc, buf, jpgsize); in s2255_got_frame()
592 static void s2255_fillbuff(struct s2255_vc *vc, in s2255_fillbuff() argument
599 struct s2255_dev *dev = vc->dev; in s2255_fillbuff()
603 last_frame = vc->last_frame; in s2255_fillbuff()
606 (const char *)vc->buffer.frame[last_frame].lpvbits; in s2255_fillbuff()
607 switch (vc->fmt->fourcc) { in s2255_fillbuff()
611 vbuf, vc->width, in s2255_fillbuff()
612 vc->height, in s2255_fillbuff()
613 vc->fmt->fourcc); in s2255_fillbuff()
616 memcpy(vbuf, tmpbuf, vc->width * vc->height); in s2255_fillbuff()
625 vc->width * vc->height * 2); in s2255_fillbuff()
630 vc->last_frame = -1; in s2255_fillbuff()
648 struct s2255_vc *vc = vb2_get_drv_priv(vq); in queue_setup() local
652 sizes[0] = vc->width * vc->height * (vc->fmt->depth >> 3); in queue_setup()
658 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue); in buffer_prepare() local
661 int w = vc->width; in buffer_prepare()
662 int h = vc->height; in buffer_prepare()
665 dprintk(vc->dev, 4, "%s\n", __func__); in buffer_prepare()
666 if (vc->fmt == NULL) in buffer_prepare()
669 if ((w < norm_minw(vc)) || in buffer_prepare()
670 (w > norm_maxw(vc)) || in buffer_prepare()
671 (h < norm_minh(vc)) || in buffer_prepare()
672 (h > norm_maxh(vc))) { in buffer_prepare()
673 dprintk(vc->dev, 4, "invalid buffer prepare\n"); in buffer_prepare()
676 size = w * h * (vc->fmt->depth >> 3); in buffer_prepare()
678 dprintk(vc->dev, 4, "invalid buffer prepare\n"); in buffer_prepare()
690 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue); in buffer_queue() local
692 dprintk(vc->dev, 1, "%s\n", __func__); in buffer_queue()
693 spin_lock_irqsave(&vc->qlock, flags); in buffer_queue()
694 list_add_tail(&buf->list, &vc->buf_list); in buffer_queue()
695 spin_unlock_irqrestore(&vc->qlock, flags); in buffer_queue()
712 struct s2255_vc *vc = video_drvdata(file); in vidioc_querycap() local
713 struct s2255_dev *dev = vc->dev; in vidioc_querycap()
738 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
739 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_g_fmt_vid_cap()
741 f->fmt.pix.width = vc->width; in vidioc_g_fmt_vid_cap()
742 f->fmt.pix.height = vc->height; in vidioc_g_fmt_vid_cap()
748 f->fmt.pix.pixelformat = vc->fmt->fourcc; in vidioc_g_fmt_vid_cap()
749 f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3); in vidioc_g_fmt_vid_cap()
760 struct s2255_vc *vc = video_drvdata(file); in vidioc_try_fmt_vid_cap() local
761 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_try_fmt_vid_cap()
768 dprintk(vc->dev, 50, "%s NTSC: %d suggested width: %d, height: %d\n", in vidioc_try_fmt_vid_cap()
801 dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__, in vidioc_try_fmt_vid_cap()
809 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_fmt_vid_cap() local
811 struct vb2_queue *q = &vc->vb_vidq; in vidioc_s_fmt_vid_cap()
815 ret = vidioc_try_fmt_vid_cap(file, vc, f); in vidioc_s_fmt_vid_cap()
826 dprintk(vc->dev, 1, "queue busy\n"); in vidioc_s_fmt_vid_cap()
830 mode = vc->mode; in vidioc_s_fmt_vid_cap()
831 vc->fmt = fmt; in vidioc_s_fmt_vid_cap()
832 vc->width = f->fmt.pix.width; in vidioc_s_fmt_vid_cap()
833 vc->height = f->fmt.pix.height; in vidioc_s_fmt_vid_cap()
834 vc->field = f->fmt.pix.field; in vidioc_s_fmt_vid_cap()
835 if (vc->width > norm_minw(vc)) { in vidioc_s_fmt_vid_cap()
836 if (vc->height > norm_minh(vc)) { in vidioc_s_fmt_vid_cap()
837 if (vc->cap_parm.capturemode & in vidioc_s_fmt_vid_cap()
849 switch (vc->fmt->fourcc) { in vidioc_s_fmt_vid_cap()
858 mode.color |= (vc->jpegqual << 8); in vidioc_s_fmt_vid_cap()
871 if ((mode.color & MASK_COLOR) != (vc->mode.color & MASK_COLOR)) in vidioc_s_fmt_vid_cap()
873 else if (mode.scale != vc->mode.scale) in vidioc_s_fmt_vid_cap()
875 else if (mode.format != vc->mode.format) in vidioc_s_fmt_vid_cap()
877 vc->mode = mode; in vidioc_s_fmt_vid_cap()
878 (void) s2255_set_mode(vc, &mode); in vidioc_s_fmt_vid_cap()
979 static int s2255_set_mode(struct s2255_vc *vc, in s2255_set_mode() argument
984 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_set_mode()
989 chn_rev = G_chnmap[vc->idx]; in s2255_set_mode()
990 dprintk(dev, 3, "%s channel: %d\n", __func__, vc->idx); in s2255_set_mode()
996 mode->color |= (vc->jpegqual << 8); in s2255_set_mode()
999 vc->mode = *mode; in s2255_set_mode()
1000 vc->req_image_size = get_transfer_size(mode); in s2255_set_mode()
1001 dprintk(dev, 1, "%s: reqsize %ld\n", __func__, vc->req_image_size); in s2255_set_mode()
1007 buffer[3 + i] = cpu_to_le32(((u32 *)&vc->mode)[i]); in s2255_set_mode()
1008 vc->setmode_ready = 0; in s2255_set_mode()
1014 wait_event_timeout(vc->wait_setmode, in s2255_set_mode()
1015 (vc->setmode_ready != 0), in s2255_set_mode()
1017 if (vc->setmode_ready != 1) { in s2255_set_mode()
1023 vc->mode.restart = 0; in s2255_set_mode()
1024 dprintk(dev, 1, "%s chn %d, result: %d\n", __func__, vc->idx, res); in s2255_set_mode()
1029 static int s2255_cmd_status(struct s2255_vc *vc, u32 *pstatus) in s2255_cmd_status() argument
1033 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_cmd_status()
1037 chn_rev = G_chnmap[vc->idx]; in s2255_cmd_status()
1038 dprintk(dev, 4, "%s chan %d\n", __func__, vc->idx); in s2255_cmd_status()
1044 vc->vidstatus_ready = 0; in s2255_cmd_status()
1046 wait_event_timeout(vc->wait_vidstatus, in s2255_cmd_status()
1047 (vc->vidstatus_ready != 0), in s2255_cmd_status()
1049 if (vc->vidstatus_ready != 1) { in s2255_cmd_status()
1053 *pstatus = vc->vidstatus; in s2255_cmd_status()
1061 struct s2255_vc *vc = vb2_get_drv_priv(vq); in start_streaming() local
1064 vc->last_frame = -1; in start_streaming()
1065 vc->bad_payload = 0; in start_streaming()
1066 vc->cur_frame = 0; in start_streaming()
1067 vc->frame_count = 0; in start_streaming()
1069 vc->buffer.frame[j].ulState = S2255_READ_IDLE; in start_streaming()
1070 vc->buffer.frame[j].cur_size = 0; in start_streaming()
1072 return s2255_start_acquire(vc); in start_streaming()
1078 struct s2255_vc *vc = vb2_get_drv_priv(vq); in stop_streaming() local
1081 (void) s2255_stop_acquire(vc); in stop_streaming()
1082 spin_lock_irqsave(&vc->qlock, flags); in stop_streaming()
1083 list_for_each_entry_safe(buf, node, &vc->buf_list, list) { in stop_streaming()
1086 dprintk(vc->dev, 2, "[%p/%d] done\n", in stop_streaming()
1089 spin_unlock_irqrestore(&vc->qlock, flags); in stop_streaming()
1094 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_std() local
1096 struct vb2_queue *q = &vc->vb_vidq; in vidioc_s_std()
1105 mode = vc->mode; in vidioc_s_std()
1107 dprintk(vc->dev, 4, "%s 60 Hz\n", __func__); in vidioc_s_std()
1113 vc->width = LINE_SZ_4CIFS_NTSC; in vidioc_s_std()
1114 vc->height = NUM_LINES_4CIFS_NTSC * 2; in vidioc_s_std()
1117 dprintk(vc->dev, 4, "%s 50 Hz\n", __func__); in vidioc_s_std()
1122 vc->width = LINE_SZ_4CIFS_PAL; in vidioc_s_std()
1123 vc->height = NUM_LINES_4CIFS_PAL * 2; in vidioc_s_std()
1127 vc->std = i; in vidioc_s_std()
1129 s2255_set_mode(vc, &mode); in vidioc_s_std()
1135 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_std() local
1137 *i = vc->std; in vidioc_g_std()
1151 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_input() local
1152 struct s2255_dev *dev = vc->dev; in vidioc_enum_input()
1162 rc = s2255_cmd_status(vc, &status); in vidioc_enum_input()
1175 strscpy(inp->name, (vc->idx < 2) ? "Composite" : "S-Video", in vidioc_enum_input()
1196 struct s2255_vc *vc = in s2255_s_ctrl() local
1199 mode = vc->mode; in s2255_s_ctrl()
1219 vc->jpegqual = ctrl->val; in s2255_s_ctrl()
1229 s2255_set_mode(vc, &mode); in s2255_s_ctrl()
1236 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_jpegcomp() local
1239 jc->quality = vc->jpegqual; in vidioc_g_jpegcomp()
1240 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality); in vidioc_g_jpegcomp()
1247 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_jpegcomp() local
1251 v4l2_ctrl_s_ctrl(vc->jpegqual_ctrl, jc->quality); in vidioc_s_jpegcomp()
1252 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality); in vidioc_s_jpegcomp()
1260 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_parm() local
1265 sp->parm.capture.capturemode = vc->cap_parm.capturemode; in vidioc_g_parm()
1267 def_num = (vc->mode.format == FORMAT_NTSC) ? 1001 : 1000; in vidioc_g_parm()
1268 def_dem = (vc->mode.format == FORMAT_NTSC) ? 30000 : 25000; in vidioc_g_parm()
1270 switch (vc->mode.fdec) { in vidioc_g_parm()
1285 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d\n", in vidioc_g_parm()
1296 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_parm() local
1302 mode = vc->mode; in vidioc_s_parm()
1304 if ((vc->cap_parm.capturemode != sp->parm.capture.capturemode) in vidioc_s_parm()
1305 && vb2_is_streaming(&vc->vb_vidq)) in vidioc_s_parm()
1326 s2255_set_mode(vc, &mode); in vidioc_s_parm()
1327 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n", in vidioc_s_parm()
1350 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_framesizes() local
1351 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_enum_framesizes()
1368 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_frameintervals() local
1371 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_enum_frameintervals()
1394 dprintk(vc->dev, 4, "%s discrete %d/%d\n", __func__, in vidioc_enum_frameintervals()
1402 struct s2255_vc *vc = video_drvdata(file); in s2255_open() local
1403 struct s2255_dev *dev = vc->dev; in s2255_open()
1473 if (!vc->configured) { in s2255_open()
1475 vc->fmt = &formats[0]; in s2255_open()
1476 s2255_set_mode(vc, &vc->mode); in s2255_open()
1477 vc->configured = 1; in s2255_open()
1547 struct s2255_vc *vc = in s2255_video_device_release() local
1553 v4l2_ctrl_handler_free(&vc->hdl); in s2255_video_device_release()
1587 struct s2255_vc *vc; in s2255_probe_v4l() local
1596 vc = &dev->vc[i]; in s2255_probe_v4l()
1597 INIT_LIST_HEAD(&vc->buf_list); in s2255_probe_v4l()
1599 v4l2_ctrl_handler_init(&vc->hdl, 6); in s2255_probe_v4l()
1600 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1602 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1604 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1606 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1608 vc->jpegqual_ctrl = v4l2_ctrl_new_std(&vc->hdl, in s2255_probe_v4l()
1613 (dev->pid != 0x2257 || vc->idx <= 1)) in s2255_probe_v4l()
1614 v4l2_ctrl_new_custom(&vc->hdl, &color_filter_ctrl, in s2255_probe_v4l()
1616 if (vc->hdl.error) { in s2255_probe_v4l()
1617 ret = vc->hdl.error; in s2255_probe_v4l()
1618 v4l2_ctrl_handler_free(&vc->hdl); in s2255_probe_v4l()
1622 q = &vc->vb_vidq; in s2255_probe_v4l()
1625 q->drv_priv = vc; in s2255_probe_v4l()
1626 q->lock = &vc->vb_lock; in s2255_probe_v4l()
1638 vc->vdev = template; in s2255_probe_v4l()
1639 vc->vdev.queue = q; in s2255_probe_v4l()
1640 vc->vdev.ctrl_handler = &vc->hdl; in s2255_probe_v4l()
1641 vc->vdev.lock = &dev->lock; in s2255_probe_v4l()
1642 vc->vdev.v4l2_dev = &dev->v4l2_dev; in s2255_probe_v4l()
1643 vc->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | in s2255_probe_v4l()
1645 video_set_drvdata(&vc->vdev, vc); in s2255_probe_v4l()
1647 ret = video_register_device(&vc->vdev, in s2255_probe_v4l()
1651 ret = video_register_device(&vc->vdev, in s2255_probe_v4l()
1662 video_device_node_name(&vc->vdev)); in s2255_probe_v4l()
1699 struct s2255_vc *vc; in save_frame() local
1701 vc = &dev->vc[dev->cc]; in save_frame()
1702 idx = vc->cur_frame; in save_frame()
1703 frm = &vc->buffer.frame[idx]; in save_frame()
1727 vc = &dev->vc[dev->cc]; in save_frame()
1729 if (payload > vc->req_image_size) { in save_frame()
1730 vc->bad_payload++; in save_frame()
1734 vc->pkt_size = payload; in save_frame()
1735 vc->jpg_size = le32_to_cpu(pdword[4]); in save_frame()
1746 vc = &dev->vc[cc]; in save_frame()
1751 vc->setmode_ready = 1; in save_frame()
1752 wake_up(&vc->wait_setmode); in save_frame()
1766 vc->vidstatus = le32_to_cpu(pdword[3]); in save_frame()
1767 vc->vidstatus_ready = 1; in save_frame()
1768 wake_up(&vc->wait_vidstatus); in save_frame()
1787 vc = &dev->vc[dev->cc]; in save_frame()
1788 idx = vc->cur_frame; in save_frame()
1789 frm = &vc->buffer.frame[idx]; in save_frame()
1791 if (!vb2_is_streaming(&vc->vb_vidq)) { in save_frame()
1816 size = vc->pkt_size - PREFIX_SIZE; in save_frame()
1819 if ((copy_size + frm->cur_size) < vc->req_image_size) in save_frame()
1828 vc->last_frame = vc->cur_frame; in save_frame()
1829 vc->cur_frame++; in save_frame()
1831 if ((vc->cur_frame == SYS_FRAMES) || in save_frame()
1832 (vc->cur_frame == vc->buffer.dwFrames)) in save_frame()
1833 vc->cur_frame = 0; in save_frame()
1835 if (vb2_is_streaming(&vc->vb_vidq)) in save_frame()
1836 s2255_got_frame(vc, vc->jpg_size); in save_frame()
1837 vc->frame_count++; in save_frame()
1922 static int s2255_create_sys_buffers(struct s2255_vc *vc) in s2255_create_sys_buffers() argument
1926 vc->buffer.dwFrames = SYS_FRAMES; in s2255_create_sys_buffers()
1935 vc->buffer.frame[i].lpvbits = vmalloc(reqsize); in s2255_create_sys_buffers()
1936 vc->buffer.frame[i].size = reqsize; in s2255_create_sys_buffers()
1937 if (vc->buffer.frame[i].lpvbits == NULL) { in s2255_create_sys_buffers()
1939 vc->buffer.dwFrames = i; in s2255_create_sys_buffers()
1946 vc->buffer.frame[i].ulState = 0; in s2255_create_sys_buffers()
1947 vc->buffer.frame[i].cur_size = 0; in s2255_create_sys_buffers()
1950 vc->cur_frame = 0; in s2255_create_sys_buffers()
1951 vc->last_frame = -1; in s2255_create_sys_buffers()
1955 static int s2255_release_sys_buffers(struct s2255_vc *vc) in s2255_release_sys_buffers() argument
1959 vfree(vc->buffer.frame[i].lpvbits); in s2255_release_sys_buffers()
1960 vc->buffer.frame[i].lpvbits = NULL; in s2255_release_sys_buffers()
1994 struct s2255_vc *vc = &dev->vc[j]; in s2255_board_init() local
1995 vc->mode = mode_def; in s2255_board_init()
1997 vc->mode.color |= (1 << 16); in s2255_board_init()
1998 vc->jpegqual = S2255_DEF_JPEG_QUAL; in s2255_board_init()
1999 vc->width = LINE_SZ_4CIFS_NTSC; in s2255_board_init()
2000 vc->height = NUM_LINES_4CIFS_NTSC * 2; in s2255_board_init()
2001 vc->std = V4L2_STD_NTSC_M; in s2255_board_init()
2002 vc->fmt = &formats[0]; in s2255_board_init()
2003 vc->mode.restart = 1; in s2255_board_init()
2004 vc->req_image_size = get_transfer_size(&mode_def); in s2255_board_init()
2005 vc->frame_count = 0; in s2255_board_init()
2007 s2255_create_sys_buffers(vc); in s2255_board_init()
2021 if (vb2_is_streaming(&dev->vc[i].vb_vidq)) in s2255_board_shutdown()
2022 s2255_stop_acquire(&dev->vc[i]); in s2255_board_shutdown()
2026 s2255_release_sys_buffers(&dev->vc[i]); in s2255_board_shutdown()
2112 static int s2255_start_acquire(struct s2255_vc *vc) in s2255_start_acquire() argument
2117 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_start_acquire()
2121 chn_rev = G_chnmap[vc->idx]; in s2255_start_acquire()
2122 vc->last_frame = -1; in s2255_start_acquire()
2123 vc->bad_payload = 0; in s2255_start_acquire()
2124 vc->cur_frame = 0; in s2255_start_acquire()
2126 vc->buffer.frame[j].ulState = 0; in s2255_start_acquire()
2127 vc->buffer.frame[j].cur_size = 0; in s2255_start_acquire()
2138 dprintk(dev, 2, "start acquire exit[%d] %d\n", vc->idx, res); in s2255_start_acquire()
2143 static int s2255_stop_acquire(struct s2255_vc *vc) in s2255_stop_acquire() argument
2147 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_stop_acquire()
2151 chn_rev = G_chnmap[vc->idx]; in s2255_stop_acquire()
2161 dprintk(dev, 4, "%s: chn %d, res %d\n", __func__, vc->idx, res); in s2255_stop_acquire()
2258 struct s2255_vc *vc = &dev->vc[i]; in s2255_probe() local
2259 vc->idx = i; in s2255_probe()
2260 vc->dev = dev; in s2255_probe()
2261 init_waitqueue_head(&vc->wait_setmode); in s2255_probe()
2262 init_waitqueue_head(&vc->wait_vidstatus); in s2255_probe()
2263 spin_lock_init(&vc->qlock); in s2255_probe()
2264 mutex_init(&vc->vb_lock); in s2255_probe()
2350 video_unregister_device(&dev->vc[i].vdev); in s2255_disconnect()
2355 dev->vc[i].setmode_ready = 1; in s2255_disconnect()
2356 wake_up(&dev->vc[i].wait_setmode); in s2255_disconnect()
2357 dev->vc[i].vidstatus_ready = 1; in s2255_disconnect()
2358 wake_up(&dev->vc[i].wait_vidstatus); in s2255_disconnect()