Lines Matching refs:vc
260 struct s2255_vc vc[MAX_CHANNELS]; member
350 static int s2255_start_acquire(struct s2255_vc *vc);
351 static int s2255_stop_acquire(struct s2255_vc *vc);
352 static void s2255_fillbuff(struct s2255_vc *vc, struct s2255_buffer *buf,
354 static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode *mode);
428 static int norm_maxw(struct s2255_vc *vc) in norm_maxw() argument
430 return (vc->std & V4L2_STD_525_60) ? in norm_maxw()
434 static int norm_maxh(struct s2255_vc *vc) in norm_maxh() argument
436 return (vc->std & V4L2_STD_525_60) ? in norm_maxh()
440 static int norm_minw(struct s2255_vc *vc) in norm_minw() argument
442 return (vc->std & V4L2_STD_525_60) ? in norm_minw()
446 static int norm_minh(struct s2255_vc *vc) in norm_minh() argument
448 return (vc->std & V4L2_STD_525_60) ? in norm_minh()
561 static void s2255_got_frame(struct s2255_vc *vc, int jpgsize) in s2255_got_frame() argument
564 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_got_frame()
567 spin_lock_irqsave(&vc->qlock, flags); in s2255_got_frame()
568 if (list_empty(&vc->buf_list)) { in s2255_got_frame()
570 spin_unlock_irqrestore(&vc->qlock, flags); in s2255_got_frame()
573 buf = list_entry(vc->buf_list.next, in s2255_got_frame()
577 buf->vb.v4l2_buf.field = vc->field; in s2255_got_frame()
578 buf->vb.v4l2_buf.sequence = vc->frame_count; in s2255_got_frame()
579 spin_unlock_irqrestore(&vc->qlock, flags); in s2255_got_frame()
581 s2255_fillbuff(vc, buf, jpgsize); in s2255_got_frame()
610 static void s2255_fillbuff(struct s2255_vc *vc, in s2255_fillbuff() argument
617 struct s2255_dev *dev = vc->dev; in s2255_fillbuff()
621 last_frame = vc->last_frame; in s2255_fillbuff()
624 (const char *)vc->buffer.frame[last_frame].lpvbits; in s2255_fillbuff()
625 switch (vc->fmt->fourcc) { in s2255_fillbuff()
629 vbuf, vc->width, in s2255_fillbuff()
630 vc->height, in s2255_fillbuff()
631 vc->fmt->fourcc); in s2255_fillbuff()
634 memcpy(vbuf, tmpbuf, vc->width * vc->height); in s2255_fillbuff()
643 vc->width * vc->height * 2); in s2255_fillbuff()
648 vc->last_frame = -1; in s2255_fillbuff()
666 struct s2255_vc *vc = vb2_get_drv_priv(vq); in queue_setup() local
670 sizes[0] = vc->width * vc->height * (vc->fmt->depth >> 3); in queue_setup()
676 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue); in buffer_prepare() local
678 int w = vc->width; in buffer_prepare()
679 int h = vc->height; in buffer_prepare()
682 dprintk(vc->dev, 4, "%s\n", __func__); in buffer_prepare()
683 if (vc->fmt == NULL) in buffer_prepare()
686 if ((w < norm_minw(vc)) || in buffer_prepare()
687 (w > norm_maxw(vc)) || in buffer_prepare()
688 (h < norm_minh(vc)) || in buffer_prepare()
689 (h > norm_maxh(vc))) { in buffer_prepare()
690 dprintk(vc->dev, 4, "invalid buffer prepare\n"); in buffer_prepare()
693 size = w * h * (vc->fmt->depth >> 3); in buffer_prepare()
695 dprintk(vc->dev, 4, "invalid buffer prepare\n"); in buffer_prepare()
706 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue); in buffer_queue() local
708 dprintk(vc->dev, 1, "%s\n", __func__); in buffer_queue()
709 spin_lock_irqsave(&vc->qlock, flags); in buffer_queue()
710 list_add_tail(&buf->list, &vc->buf_list); in buffer_queue()
711 spin_unlock_irqrestore(&vc->qlock, flags); in buffer_queue()
730 struct s2255_vc *vc = video_drvdata(file); in vidioc_querycap() local
731 struct s2255_dev *dev = vc->dev; in vidioc_querycap()
760 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
761 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_g_fmt_vid_cap()
763 f->fmt.pix.width = vc->width; in vidioc_g_fmt_vid_cap()
764 f->fmt.pix.height = vc->height; in vidioc_g_fmt_vid_cap()
770 f->fmt.pix.pixelformat = vc->fmt->fourcc; in vidioc_g_fmt_vid_cap()
771 f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3); in vidioc_g_fmt_vid_cap()
783 struct s2255_vc *vc = video_drvdata(file); in vidioc_try_fmt_vid_cap() local
784 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_try_fmt_vid_cap()
793 dprintk(vc->dev, 50, "%s NTSC: %d suggested width: %d, height: %d\n", in vidioc_try_fmt_vid_cap()
835 dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__, in vidioc_try_fmt_vid_cap()
843 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_fmt_vid_cap() local
845 struct vb2_queue *q = &vc->vb_vidq; in vidioc_s_fmt_vid_cap()
849 ret = vidioc_try_fmt_vid_cap(file, vc, f); in vidioc_s_fmt_vid_cap()
860 dprintk(vc->dev, 1, "queue busy\n"); in vidioc_s_fmt_vid_cap()
864 mode = vc->mode; in vidioc_s_fmt_vid_cap()
865 vc->fmt = fmt; in vidioc_s_fmt_vid_cap()
866 vc->width = f->fmt.pix.width; in vidioc_s_fmt_vid_cap()
867 vc->height = f->fmt.pix.height; in vidioc_s_fmt_vid_cap()
868 vc->field = f->fmt.pix.field; in vidioc_s_fmt_vid_cap()
869 if (vc->width > norm_minw(vc)) { in vidioc_s_fmt_vid_cap()
870 if (vc->height > norm_minh(vc)) { in vidioc_s_fmt_vid_cap()
871 if (vc->cap_parm.capturemode & in vidioc_s_fmt_vid_cap()
883 switch (vc->fmt->fourcc) { in vidioc_s_fmt_vid_cap()
892 mode.color |= (vc->jpegqual << 8); in vidioc_s_fmt_vid_cap()
905 if ((mode.color & MASK_COLOR) != (vc->mode.color & MASK_COLOR)) in vidioc_s_fmt_vid_cap()
907 else if (mode.scale != vc->mode.scale) in vidioc_s_fmt_vid_cap()
909 else if (mode.format != vc->mode.format) in vidioc_s_fmt_vid_cap()
911 vc->mode = mode; in vidioc_s_fmt_vid_cap()
912 (void) s2255_set_mode(vc, &mode); in vidioc_s_fmt_vid_cap()
1013 static int s2255_set_mode(struct s2255_vc *vc, in s2255_set_mode() argument
1018 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_set_mode()
1023 chn_rev = G_chnmap[vc->idx]; in s2255_set_mode()
1024 dprintk(dev, 3, "%s channel: %d\n", __func__, vc->idx); in s2255_set_mode()
1030 mode->color |= (vc->jpegqual << 8); in s2255_set_mode()
1033 vc->mode = *mode; in s2255_set_mode()
1034 vc->req_image_size = get_transfer_size(mode); in s2255_set_mode()
1035 dprintk(dev, 1, "%s: reqsize %ld\n", __func__, vc->req_image_size); in s2255_set_mode()
1041 buffer[3 + i] = cpu_to_le32(((u32 *)&vc->mode)[i]); in s2255_set_mode()
1042 vc->setmode_ready = 0; in s2255_set_mode()
1048 wait_event_timeout(vc->wait_setmode, in s2255_set_mode()
1049 (vc->setmode_ready != 0), in s2255_set_mode()
1051 if (vc->setmode_ready != 1) { in s2255_set_mode()
1057 vc->mode.restart = 0; in s2255_set_mode()
1058 dprintk(dev, 1, "%s chn %d, result: %d\n", __func__, vc->idx, res); in s2255_set_mode()
1063 static int s2255_cmd_status(struct s2255_vc *vc, u32 *pstatus) in s2255_cmd_status() argument
1067 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_cmd_status()
1071 chn_rev = G_chnmap[vc->idx]; in s2255_cmd_status()
1072 dprintk(dev, 4, "%s chan %d\n", __func__, vc->idx); in s2255_cmd_status()
1078 vc->vidstatus_ready = 0; in s2255_cmd_status()
1080 wait_event_timeout(vc->wait_vidstatus, in s2255_cmd_status()
1081 (vc->vidstatus_ready != 0), in s2255_cmd_status()
1083 if (vc->vidstatus_ready != 1) { in s2255_cmd_status()
1087 *pstatus = vc->vidstatus; in s2255_cmd_status()
1095 struct s2255_vc *vc = vb2_get_drv_priv(vq); in start_streaming() local
1098 vc->last_frame = -1; in start_streaming()
1099 vc->bad_payload = 0; in start_streaming()
1100 vc->cur_frame = 0; in start_streaming()
1101 vc->frame_count = 0; in start_streaming()
1103 vc->buffer.frame[j].ulState = S2255_READ_IDLE; in start_streaming()
1104 vc->buffer.frame[j].cur_size = 0; in start_streaming()
1106 return s2255_start_acquire(vc); in start_streaming()
1112 struct s2255_vc *vc = vb2_get_drv_priv(vq); in stop_streaming() local
1115 (void) s2255_stop_acquire(vc); in stop_streaming()
1116 spin_lock_irqsave(&vc->qlock, flags); in stop_streaming()
1117 list_for_each_entry_safe(buf, node, &vc->buf_list, list) { in stop_streaming()
1120 dprintk(vc->dev, 2, "[%p/%d] done\n", in stop_streaming()
1123 spin_unlock_irqrestore(&vc->qlock, flags); in stop_streaming()
1128 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_std() local
1130 struct vb2_queue *q = &vc->vb_vidq; in vidioc_s_std()
1139 mode = vc->mode; in vidioc_s_std()
1141 dprintk(vc->dev, 4, "%s 60 Hz\n", __func__); in vidioc_s_std()
1147 vc->width = LINE_SZ_4CIFS_NTSC; in vidioc_s_std()
1148 vc->height = NUM_LINES_4CIFS_NTSC * 2; in vidioc_s_std()
1151 dprintk(vc->dev, 4, "%s 50 Hz\n", __func__); in vidioc_s_std()
1156 vc->width = LINE_SZ_4CIFS_PAL; in vidioc_s_std()
1157 vc->height = NUM_LINES_4CIFS_PAL * 2; in vidioc_s_std()
1161 vc->std = i; in vidioc_s_std()
1163 s2255_set_mode(vc, &mode); in vidioc_s_std()
1169 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_std() local
1171 *i = vc->std; in vidioc_g_std()
1185 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_input() local
1186 struct s2255_dev *dev = vc->dev; in vidioc_enum_input()
1196 rc = s2255_cmd_status(vc, &status); in vidioc_enum_input()
1209 strlcpy(inp->name, (vc->idx < 2) ? "Composite" : "S-Video", in vidioc_enum_input()
1230 struct s2255_vc *vc = in s2255_s_ctrl() local
1233 mode = vc->mode; in s2255_s_ctrl()
1253 vc->jpegqual = ctrl->val; in s2255_s_ctrl()
1263 s2255_set_mode(vc, &mode); in s2255_s_ctrl()
1270 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_jpegcomp() local
1273 jc->quality = vc->jpegqual; in vidioc_g_jpegcomp()
1274 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality); in vidioc_g_jpegcomp()
1281 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_jpegcomp() local
1285 v4l2_ctrl_s_ctrl(vc->jpegqual_ctrl, jc->quality); in vidioc_s_jpegcomp()
1286 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality); in vidioc_s_jpegcomp()
1294 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_parm() local
1299 sp->parm.capture.capturemode = vc->cap_parm.capturemode; in vidioc_g_parm()
1301 def_num = (vc->mode.format == FORMAT_NTSC) ? 1001 : 1000; in vidioc_g_parm()
1302 def_dem = (vc->mode.format == FORMAT_NTSC) ? 30000 : 25000; in vidioc_g_parm()
1304 switch (vc->mode.fdec) { in vidioc_g_parm()
1319 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d\n", in vidioc_g_parm()
1330 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_parm() local
1336 mode = vc->mode; in vidioc_s_parm()
1338 if ((vc->cap_parm.capturemode != sp->parm.capture.capturemode) in vidioc_s_parm()
1339 && vb2_is_streaming(&vc->vb_vidq)) in vidioc_s_parm()
1360 s2255_set_mode(vc, &mode); in vidioc_s_parm()
1361 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n", in vidioc_s_parm()
1384 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_framesizes() local
1385 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_enum_framesizes()
1402 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_frameintervals() local
1405 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_enum_frameintervals()
1428 dprintk(vc->dev, 4, "%s discrete %d/%d\n", __func__, in vidioc_enum_frameintervals()
1436 struct s2255_vc *vc = video_drvdata(file); in s2255_open() local
1437 struct s2255_dev *dev = vc->dev; in s2255_open()
1507 if (!vc->configured) { in s2255_open()
1509 vc->fmt = &formats[0]; in s2255_open()
1510 s2255_set_mode(vc, &vc->mode); in s2255_open()
1511 vc->configured = 1; in s2255_open()
1581 struct s2255_vc *vc = in s2255_video_device_release() local
1587 v4l2_ctrl_handler_free(&vc->hdl); in s2255_video_device_release()
1621 struct s2255_vc *vc; in s2255_probe_v4l() local
1630 vc = &dev->vc[i]; in s2255_probe_v4l()
1631 INIT_LIST_HEAD(&vc->buf_list); in s2255_probe_v4l()
1633 v4l2_ctrl_handler_init(&vc->hdl, 6); in s2255_probe_v4l()
1634 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1636 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1638 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1640 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1642 vc->jpegqual_ctrl = v4l2_ctrl_new_std(&vc->hdl, in s2255_probe_v4l()
1647 (dev->pid != 0x2257 || vc->idx <= 1)) in s2255_probe_v4l()
1648 v4l2_ctrl_new_custom(&vc->hdl, &color_filter_ctrl, in s2255_probe_v4l()
1650 if (vc->hdl.error) { in s2255_probe_v4l()
1651 ret = vc->hdl.error; in s2255_probe_v4l()
1652 v4l2_ctrl_handler_free(&vc->hdl); in s2255_probe_v4l()
1656 q = &vc->vb_vidq; in s2255_probe_v4l()
1659 q->drv_priv = vc; in s2255_probe_v4l()
1660 q->lock = &vc->vb_lock; in s2255_probe_v4l()
1672 vc->vdev = template; in s2255_probe_v4l()
1673 vc->vdev.queue = q; in s2255_probe_v4l()
1674 vc->vdev.ctrl_handler = &vc->hdl; in s2255_probe_v4l()
1675 vc->vdev.lock = &dev->lock; in s2255_probe_v4l()
1676 vc->vdev.v4l2_dev = &dev->v4l2_dev; in s2255_probe_v4l()
1677 video_set_drvdata(&vc->vdev, vc); in s2255_probe_v4l()
1679 ret = video_register_device(&vc->vdev, in s2255_probe_v4l()
1683 ret = video_register_device(&vc->vdev, in s2255_probe_v4l()
1694 video_device_node_name(&vc->vdev)); in s2255_probe_v4l()
1731 struct s2255_vc *vc; in save_frame() local
1733 vc = &dev->vc[dev->cc]; in save_frame()
1734 idx = vc->cur_frame; in save_frame()
1735 frm = &vc->buffer.frame[idx]; in save_frame()
1759 vc = &dev->vc[dev->cc]; in save_frame()
1761 if (payload > vc->req_image_size) { in save_frame()
1762 vc->bad_payload++; in save_frame()
1766 vc->pkt_size = payload; in save_frame()
1767 vc->jpg_size = le32_to_cpu(pdword[4]); in save_frame()
1778 vc = &dev->vc[cc]; in save_frame()
1783 vc->setmode_ready = 1; in save_frame()
1784 wake_up(&vc->wait_setmode); in save_frame()
1798 vc->vidstatus = le32_to_cpu(pdword[3]); in save_frame()
1799 vc->vidstatus_ready = 1; in save_frame()
1800 wake_up(&vc->wait_vidstatus); in save_frame()
1817 vc = &dev->vc[dev->cc]; in save_frame()
1818 idx = vc->cur_frame; in save_frame()
1819 frm = &vc->buffer.frame[idx]; in save_frame()
1821 if (!vb2_is_streaming(&vc->vb_vidq)) { in save_frame()
1846 size = vc->pkt_size - PREFIX_SIZE; in save_frame()
1849 if ((copy_size + frm->cur_size) < vc->req_image_size) in save_frame()
1858 vc->last_frame = vc->cur_frame; in save_frame()
1859 vc->cur_frame++; in save_frame()
1861 if ((vc->cur_frame == SYS_FRAMES) || in save_frame()
1862 (vc->cur_frame == vc->buffer.dwFrames)) in save_frame()
1863 vc->cur_frame = 0; in save_frame()
1865 if (vb2_is_streaming(&vc->vb_vidq)) in save_frame()
1866 s2255_got_frame(vc, vc->jpg_size); in save_frame()
1867 vc->frame_count++; in save_frame()
1940 static int s2255_create_sys_buffers(struct s2255_vc *vc) in s2255_create_sys_buffers() argument
1944 vc->buffer.dwFrames = SYS_FRAMES; in s2255_create_sys_buffers()
1953 vc->buffer.frame[i].lpvbits = vmalloc(reqsize); in s2255_create_sys_buffers()
1954 vc->buffer.frame[i].size = reqsize; in s2255_create_sys_buffers()
1955 if (vc->buffer.frame[i].lpvbits == NULL) { in s2255_create_sys_buffers()
1957 vc->buffer.dwFrames = i; in s2255_create_sys_buffers()
1964 vc->buffer.frame[i].ulState = 0; in s2255_create_sys_buffers()
1965 vc->buffer.frame[i].cur_size = 0; in s2255_create_sys_buffers()
1968 vc->cur_frame = 0; in s2255_create_sys_buffers()
1969 vc->last_frame = -1; in s2255_create_sys_buffers()
1973 static int s2255_release_sys_buffers(struct s2255_vc *vc) in s2255_release_sys_buffers() argument
1977 vfree(vc->buffer.frame[i].lpvbits); in s2255_release_sys_buffers()
1978 vc->buffer.frame[i].lpvbits = NULL; in s2255_release_sys_buffers()
2012 struct s2255_vc *vc = &dev->vc[j]; in s2255_board_init() local
2013 vc->mode = mode_def; in s2255_board_init()
2015 vc->mode.color |= (1 << 16); in s2255_board_init()
2016 vc->jpegqual = S2255_DEF_JPEG_QUAL; in s2255_board_init()
2017 vc->width = LINE_SZ_4CIFS_NTSC; in s2255_board_init()
2018 vc->height = NUM_LINES_4CIFS_NTSC * 2; in s2255_board_init()
2019 vc->std = V4L2_STD_NTSC_M; in s2255_board_init()
2020 vc->fmt = &formats[0]; in s2255_board_init()
2021 vc->mode.restart = 1; in s2255_board_init()
2022 vc->req_image_size = get_transfer_size(&mode_def); in s2255_board_init()
2023 vc->frame_count = 0; in s2255_board_init()
2025 s2255_create_sys_buffers(vc); in s2255_board_init()
2039 if (vb2_is_streaming(&dev->vc[i].vb_vidq)) in s2255_board_shutdown()
2040 s2255_stop_acquire(&dev->vc[i]); in s2255_board_shutdown()
2044 s2255_release_sys_buffers(&dev->vc[i]); in s2255_board_shutdown()
2133 static int s2255_start_acquire(struct s2255_vc *vc) in s2255_start_acquire() argument
2138 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_start_acquire()
2142 chn_rev = G_chnmap[vc->idx]; in s2255_start_acquire()
2143 vc->last_frame = -1; in s2255_start_acquire()
2144 vc->bad_payload = 0; in s2255_start_acquire()
2145 vc->cur_frame = 0; in s2255_start_acquire()
2147 vc->buffer.frame[j].ulState = 0; in s2255_start_acquire()
2148 vc->buffer.frame[j].cur_size = 0; in s2255_start_acquire()
2159 dprintk(dev, 2, "start acquire exit[%d] %d\n", vc->idx, res); in s2255_start_acquire()
2164 static int s2255_stop_acquire(struct s2255_vc *vc) in s2255_stop_acquire() argument
2168 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_stop_acquire()
2172 chn_rev = G_chnmap[vc->idx]; in s2255_stop_acquire()
2182 dprintk(dev, 4, "%s: chn %d, res %d\n", __func__, vc->idx, res); in s2255_stop_acquire()
2280 struct s2255_vc *vc = &dev->vc[i]; in s2255_probe() local
2281 vc->idx = i; in s2255_probe()
2282 vc->dev = dev; in s2255_probe()
2283 init_waitqueue_head(&vc->wait_setmode); in s2255_probe()
2284 init_waitqueue_head(&vc->wait_vidstatus); in s2255_probe()
2285 spin_lock_init(&vc->qlock); in s2255_probe()
2286 mutex_init(&vc->vb_lock); in s2255_probe()
2374 video_unregister_device(&dev->vc[i].vdev); in s2255_disconnect()
2379 dev->vc[i].setmode_ready = 1; in s2255_disconnect()
2380 wake_up(&dev->vc[i].wait_setmode); in s2255_disconnect()
2381 dev->vc[i].vidstatus_ready = 1; in s2255_disconnect()
2382 wake_up(&dev->vc[i].wait_vidstatus); in s2255_disconnect()