Lines Matching refs:vc

261 	struct s2255_vc         vc[MAX_CHANNELS];  member
351 static int s2255_start_acquire(struct s2255_vc *vc);
352 static int s2255_stop_acquire(struct s2255_vc *vc);
353 static void s2255_fillbuff(struct s2255_vc *vc, struct s2255_buffer *buf,
355 static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode *mode);
429 static int norm_maxw(struct s2255_vc *vc) in norm_maxw() argument
431 return (vc->std & V4L2_STD_525_60) ? in norm_maxw()
435 static int norm_maxh(struct s2255_vc *vc) in norm_maxh() argument
437 return (vc->std & V4L2_STD_525_60) ? in norm_maxh()
441 static int norm_minw(struct s2255_vc *vc) in norm_minw() argument
443 return (vc->std & V4L2_STD_525_60) ? in norm_minw()
447 static int norm_minh(struct s2255_vc *vc) in norm_minh() argument
449 return (vc->std & V4L2_STD_525_60) ? in norm_minh()
562 static void s2255_got_frame(struct s2255_vc *vc, int jpgsize) in s2255_got_frame() argument
565 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_got_frame()
568 spin_lock_irqsave(&vc->qlock, flags); in s2255_got_frame()
569 if (list_empty(&vc->buf_list)) { in s2255_got_frame()
571 spin_unlock_irqrestore(&vc->qlock, flags); in s2255_got_frame()
574 buf = list_entry(vc->buf_list.next, in s2255_got_frame()
578 buf->vb.field = vc->field; in s2255_got_frame()
579 buf->vb.sequence = vc->frame_count; in s2255_got_frame()
580 spin_unlock_irqrestore(&vc->qlock, flags); in s2255_got_frame()
582 s2255_fillbuff(vc, buf, jpgsize); in s2255_got_frame()
611 static void s2255_fillbuff(struct s2255_vc *vc, in s2255_fillbuff() argument
618 struct s2255_dev *dev = vc->dev; in s2255_fillbuff()
622 last_frame = vc->last_frame; in s2255_fillbuff()
625 (const char *)vc->buffer.frame[last_frame].lpvbits; in s2255_fillbuff()
626 switch (vc->fmt->fourcc) { in s2255_fillbuff()
630 vbuf, vc->width, in s2255_fillbuff()
631 vc->height, in s2255_fillbuff()
632 vc->fmt->fourcc); in s2255_fillbuff()
635 memcpy(vbuf, tmpbuf, vc->width * vc->height); in s2255_fillbuff()
644 vc->width * vc->height * 2); in s2255_fillbuff()
649 vc->last_frame = -1; in s2255_fillbuff()
667 struct s2255_vc *vc = vb2_get_drv_priv(vq); in queue_setup() local
671 sizes[0] = vc->width * vc->height * (vc->fmt->depth >> 3); in queue_setup()
677 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue); in buffer_prepare() local
680 int w = vc->width; in buffer_prepare()
681 int h = vc->height; in buffer_prepare()
684 dprintk(vc->dev, 4, "%s\n", __func__); in buffer_prepare()
685 if (vc->fmt == NULL) in buffer_prepare()
688 if ((w < norm_minw(vc)) || in buffer_prepare()
689 (w > norm_maxw(vc)) || in buffer_prepare()
690 (h < norm_minh(vc)) || in buffer_prepare()
691 (h > norm_maxh(vc))) { in buffer_prepare()
692 dprintk(vc->dev, 4, "invalid buffer prepare\n"); in buffer_prepare()
695 size = w * h * (vc->fmt->depth >> 3); in buffer_prepare()
697 dprintk(vc->dev, 4, "invalid buffer prepare\n"); in buffer_prepare()
709 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue); in buffer_queue() local
711 dprintk(vc->dev, 1, "%s\n", __func__); in buffer_queue()
712 spin_lock_irqsave(&vc->qlock, flags); in buffer_queue()
713 list_add_tail(&buf->list, &vc->buf_list); in buffer_queue()
714 spin_unlock_irqrestore(&vc->qlock, flags); in buffer_queue()
733 struct s2255_vc *vc = video_drvdata(file); in vidioc_querycap() local
734 struct s2255_dev *dev = vc->dev; in vidioc_querycap()
763 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
764 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_g_fmt_vid_cap()
766 f->fmt.pix.width = vc->width; in vidioc_g_fmt_vid_cap()
767 f->fmt.pix.height = vc->height; in vidioc_g_fmt_vid_cap()
773 f->fmt.pix.pixelformat = vc->fmt->fourcc; in vidioc_g_fmt_vid_cap()
774 f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3); in vidioc_g_fmt_vid_cap()
786 struct s2255_vc *vc = video_drvdata(file); in vidioc_try_fmt_vid_cap() local
787 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_try_fmt_vid_cap()
796 dprintk(vc->dev, 50, "%s NTSC: %d suggested width: %d, height: %d\n", in vidioc_try_fmt_vid_cap()
838 dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__, in vidioc_try_fmt_vid_cap()
846 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_fmt_vid_cap() local
848 struct vb2_queue *q = &vc->vb_vidq; in vidioc_s_fmt_vid_cap()
852 ret = vidioc_try_fmt_vid_cap(file, vc, f); in vidioc_s_fmt_vid_cap()
863 dprintk(vc->dev, 1, "queue busy\n"); in vidioc_s_fmt_vid_cap()
867 mode = vc->mode; in vidioc_s_fmt_vid_cap()
868 vc->fmt = fmt; in vidioc_s_fmt_vid_cap()
869 vc->width = f->fmt.pix.width; in vidioc_s_fmt_vid_cap()
870 vc->height = f->fmt.pix.height; in vidioc_s_fmt_vid_cap()
871 vc->field = f->fmt.pix.field; in vidioc_s_fmt_vid_cap()
872 if (vc->width > norm_minw(vc)) { in vidioc_s_fmt_vid_cap()
873 if (vc->height > norm_minh(vc)) { in vidioc_s_fmt_vid_cap()
874 if (vc->cap_parm.capturemode & in vidioc_s_fmt_vid_cap()
886 switch (vc->fmt->fourcc) { in vidioc_s_fmt_vid_cap()
895 mode.color |= (vc->jpegqual << 8); in vidioc_s_fmt_vid_cap()
908 if ((mode.color & MASK_COLOR) != (vc->mode.color & MASK_COLOR)) in vidioc_s_fmt_vid_cap()
910 else if (mode.scale != vc->mode.scale) in vidioc_s_fmt_vid_cap()
912 else if (mode.format != vc->mode.format) in vidioc_s_fmt_vid_cap()
914 vc->mode = mode; in vidioc_s_fmt_vid_cap()
915 (void) s2255_set_mode(vc, &mode); in vidioc_s_fmt_vid_cap()
1016 static int s2255_set_mode(struct s2255_vc *vc, in s2255_set_mode() argument
1021 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_set_mode()
1026 chn_rev = G_chnmap[vc->idx]; in s2255_set_mode()
1027 dprintk(dev, 3, "%s channel: %d\n", __func__, vc->idx); in s2255_set_mode()
1033 mode->color |= (vc->jpegqual << 8); in s2255_set_mode()
1036 vc->mode = *mode; in s2255_set_mode()
1037 vc->req_image_size = get_transfer_size(mode); in s2255_set_mode()
1038 dprintk(dev, 1, "%s: reqsize %ld\n", __func__, vc->req_image_size); in s2255_set_mode()
1044 buffer[3 + i] = cpu_to_le32(((u32 *)&vc->mode)[i]); in s2255_set_mode()
1045 vc->setmode_ready = 0; in s2255_set_mode()
1051 wait_event_timeout(vc->wait_setmode, in s2255_set_mode()
1052 (vc->setmode_ready != 0), in s2255_set_mode()
1054 if (vc->setmode_ready != 1) { in s2255_set_mode()
1060 vc->mode.restart = 0; in s2255_set_mode()
1061 dprintk(dev, 1, "%s chn %d, result: %d\n", __func__, vc->idx, res); in s2255_set_mode()
1066 static int s2255_cmd_status(struct s2255_vc *vc, u32 *pstatus) in s2255_cmd_status() argument
1070 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_cmd_status()
1074 chn_rev = G_chnmap[vc->idx]; in s2255_cmd_status()
1075 dprintk(dev, 4, "%s chan %d\n", __func__, vc->idx); in s2255_cmd_status()
1081 vc->vidstatus_ready = 0; in s2255_cmd_status()
1083 wait_event_timeout(vc->wait_vidstatus, in s2255_cmd_status()
1084 (vc->vidstatus_ready != 0), in s2255_cmd_status()
1086 if (vc->vidstatus_ready != 1) { in s2255_cmd_status()
1090 *pstatus = vc->vidstatus; in s2255_cmd_status()
1098 struct s2255_vc *vc = vb2_get_drv_priv(vq); in start_streaming() local
1101 vc->last_frame = -1; in start_streaming()
1102 vc->bad_payload = 0; in start_streaming()
1103 vc->cur_frame = 0; in start_streaming()
1104 vc->frame_count = 0; in start_streaming()
1106 vc->buffer.frame[j].ulState = S2255_READ_IDLE; in start_streaming()
1107 vc->buffer.frame[j].cur_size = 0; in start_streaming()
1109 return s2255_start_acquire(vc); in start_streaming()
1115 struct s2255_vc *vc = vb2_get_drv_priv(vq); in stop_streaming() local
1118 (void) s2255_stop_acquire(vc); in stop_streaming()
1119 spin_lock_irqsave(&vc->qlock, flags); in stop_streaming()
1120 list_for_each_entry_safe(buf, node, &vc->buf_list, list) { in stop_streaming()
1123 dprintk(vc->dev, 2, "[%p/%d] done\n", in stop_streaming()
1126 spin_unlock_irqrestore(&vc->qlock, flags); in stop_streaming()
1131 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_std() local
1133 struct vb2_queue *q = &vc->vb_vidq; in vidioc_s_std()
1142 mode = vc->mode; in vidioc_s_std()
1144 dprintk(vc->dev, 4, "%s 60 Hz\n", __func__); in vidioc_s_std()
1150 vc->width = LINE_SZ_4CIFS_NTSC; in vidioc_s_std()
1151 vc->height = NUM_LINES_4CIFS_NTSC * 2; in vidioc_s_std()
1154 dprintk(vc->dev, 4, "%s 50 Hz\n", __func__); in vidioc_s_std()
1159 vc->width = LINE_SZ_4CIFS_PAL; in vidioc_s_std()
1160 vc->height = NUM_LINES_4CIFS_PAL * 2; in vidioc_s_std()
1164 vc->std = i; in vidioc_s_std()
1166 s2255_set_mode(vc, &mode); in vidioc_s_std()
1172 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_std() local
1174 *i = vc->std; in vidioc_g_std()
1188 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_input() local
1189 struct s2255_dev *dev = vc->dev; in vidioc_enum_input()
1199 rc = s2255_cmd_status(vc, &status); in vidioc_enum_input()
1212 strlcpy(inp->name, (vc->idx < 2) ? "Composite" : "S-Video", in vidioc_enum_input()
1233 struct s2255_vc *vc = in s2255_s_ctrl() local
1236 mode = vc->mode; in s2255_s_ctrl()
1256 vc->jpegqual = ctrl->val; in s2255_s_ctrl()
1266 s2255_set_mode(vc, &mode); in s2255_s_ctrl()
1273 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_jpegcomp() local
1276 jc->quality = vc->jpegqual; in vidioc_g_jpegcomp()
1277 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality); in vidioc_g_jpegcomp()
1284 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_jpegcomp() local
1288 v4l2_ctrl_s_ctrl(vc->jpegqual_ctrl, jc->quality); in vidioc_s_jpegcomp()
1289 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality); in vidioc_s_jpegcomp()
1297 struct s2255_vc *vc = video_drvdata(file); in vidioc_g_parm() local
1302 sp->parm.capture.capturemode = vc->cap_parm.capturemode; in vidioc_g_parm()
1304 def_num = (vc->mode.format == FORMAT_NTSC) ? 1001 : 1000; in vidioc_g_parm()
1305 def_dem = (vc->mode.format == FORMAT_NTSC) ? 30000 : 25000; in vidioc_g_parm()
1307 switch (vc->mode.fdec) { in vidioc_g_parm()
1322 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d\n", in vidioc_g_parm()
1333 struct s2255_vc *vc = video_drvdata(file); in vidioc_s_parm() local
1339 mode = vc->mode; in vidioc_s_parm()
1341 if ((vc->cap_parm.capturemode != sp->parm.capture.capturemode) in vidioc_s_parm()
1342 && vb2_is_streaming(&vc->vb_vidq)) in vidioc_s_parm()
1363 s2255_set_mode(vc, &mode); in vidioc_s_parm()
1364 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n", in vidioc_s_parm()
1387 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_framesizes() local
1388 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_enum_framesizes()
1405 struct s2255_vc *vc = video_drvdata(file); in vidioc_enum_frameintervals() local
1408 int is_ntsc = vc->std & V4L2_STD_525_60; in vidioc_enum_frameintervals()
1431 dprintk(vc->dev, 4, "%s discrete %d/%d\n", __func__, in vidioc_enum_frameintervals()
1439 struct s2255_vc *vc = video_drvdata(file); in s2255_open() local
1440 struct s2255_dev *dev = vc->dev; in s2255_open()
1510 if (!vc->configured) { in s2255_open()
1512 vc->fmt = &formats[0]; in s2255_open()
1513 s2255_set_mode(vc, &vc->mode); in s2255_open()
1514 vc->configured = 1; in s2255_open()
1584 struct s2255_vc *vc = in s2255_video_device_release() local
1590 v4l2_ctrl_handler_free(&vc->hdl); in s2255_video_device_release()
1624 struct s2255_vc *vc; in s2255_probe_v4l() local
1633 vc = &dev->vc[i]; in s2255_probe_v4l()
1634 INIT_LIST_HEAD(&vc->buf_list); in s2255_probe_v4l()
1636 v4l2_ctrl_handler_init(&vc->hdl, 6); in s2255_probe_v4l()
1637 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1639 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1641 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1643 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops, in s2255_probe_v4l()
1645 vc->jpegqual_ctrl = v4l2_ctrl_new_std(&vc->hdl, in s2255_probe_v4l()
1650 (dev->pid != 0x2257 || vc->idx <= 1)) in s2255_probe_v4l()
1651 v4l2_ctrl_new_custom(&vc->hdl, &color_filter_ctrl, in s2255_probe_v4l()
1653 if (vc->hdl.error) { in s2255_probe_v4l()
1654 ret = vc->hdl.error; in s2255_probe_v4l()
1655 v4l2_ctrl_handler_free(&vc->hdl); in s2255_probe_v4l()
1659 q = &vc->vb_vidq; in s2255_probe_v4l()
1662 q->drv_priv = vc; in s2255_probe_v4l()
1663 q->lock = &vc->vb_lock; in s2255_probe_v4l()
1675 vc->vdev = template; in s2255_probe_v4l()
1676 vc->vdev.queue = q; in s2255_probe_v4l()
1677 vc->vdev.ctrl_handler = &vc->hdl; in s2255_probe_v4l()
1678 vc->vdev.lock = &dev->lock; in s2255_probe_v4l()
1679 vc->vdev.v4l2_dev = &dev->v4l2_dev; in s2255_probe_v4l()
1680 video_set_drvdata(&vc->vdev, vc); in s2255_probe_v4l()
1682 ret = video_register_device(&vc->vdev, in s2255_probe_v4l()
1686 ret = video_register_device(&vc->vdev, in s2255_probe_v4l()
1697 video_device_node_name(&vc->vdev)); in s2255_probe_v4l()
1734 struct s2255_vc *vc; in save_frame() local
1736 vc = &dev->vc[dev->cc]; in save_frame()
1737 idx = vc->cur_frame; in save_frame()
1738 frm = &vc->buffer.frame[idx]; in save_frame()
1762 vc = &dev->vc[dev->cc]; in save_frame()
1764 if (payload > vc->req_image_size) { in save_frame()
1765 vc->bad_payload++; in save_frame()
1769 vc->pkt_size = payload; in save_frame()
1770 vc->jpg_size = le32_to_cpu(pdword[4]); in save_frame()
1781 vc = &dev->vc[cc]; in save_frame()
1786 vc->setmode_ready = 1; in save_frame()
1787 wake_up(&vc->wait_setmode); in save_frame()
1801 vc->vidstatus = le32_to_cpu(pdword[3]); in save_frame()
1802 vc->vidstatus_ready = 1; in save_frame()
1803 wake_up(&vc->wait_vidstatus); in save_frame()
1820 vc = &dev->vc[dev->cc]; in save_frame()
1821 idx = vc->cur_frame; in save_frame()
1822 frm = &vc->buffer.frame[idx]; in save_frame()
1824 if (!vb2_is_streaming(&vc->vb_vidq)) { in save_frame()
1849 size = vc->pkt_size - PREFIX_SIZE; in save_frame()
1852 if ((copy_size + frm->cur_size) < vc->req_image_size) in save_frame()
1861 vc->last_frame = vc->cur_frame; in save_frame()
1862 vc->cur_frame++; in save_frame()
1864 if ((vc->cur_frame == SYS_FRAMES) || in save_frame()
1865 (vc->cur_frame == vc->buffer.dwFrames)) in save_frame()
1866 vc->cur_frame = 0; in save_frame()
1868 if (vb2_is_streaming(&vc->vb_vidq)) in save_frame()
1869 s2255_got_frame(vc, vc->jpg_size); in save_frame()
1870 vc->frame_count++; in save_frame()
1943 static int s2255_create_sys_buffers(struct s2255_vc *vc) in s2255_create_sys_buffers() argument
1947 vc->buffer.dwFrames = SYS_FRAMES; in s2255_create_sys_buffers()
1956 vc->buffer.frame[i].lpvbits = vmalloc(reqsize); in s2255_create_sys_buffers()
1957 vc->buffer.frame[i].size = reqsize; in s2255_create_sys_buffers()
1958 if (vc->buffer.frame[i].lpvbits == NULL) { in s2255_create_sys_buffers()
1960 vc->buffer.dwFrames = i; in s2255_create_sys_buffers()
1967 vc->buffer.frame[i].ulState = 0; in s2255_create_sys_buffers()
1968 vc->buffer.frame[i].cur_size = 0; in s2255_create_sys_buffers()
1971 vc->cur_frame = 0; in s2255_create_sys_buffers()
1972 vc->last_frame = -1; in s2255_create_sys_buffers()
1976 static int s2255_release_sys_buffers(struct s2255_vc *vc) in s2255_release_sys_buffers() argument
1980 vfree(vc->buffer.frame[i].lpvbits); in s2255_release_sys_buffers()
1981 vc->buffer.frame[i].lpvbits = NULL; in s2255_release_sys_buffers()
2015 struct s2255_vc *vc = &dev->vc[j]; in s2255_board_init() local
2016 vc->mode = mode_def; in s2255_board_init()
2018 vc->mode.color |= (1 << 16); in s2255_board_init()
2019 vc->jpegqual = S2255_DEF_JPEG_QUAL; in s2255_board_init()
2020 vc->width = LINE_SZ_4CIFS_NTSC; in s2255_board_init()
2021 vc->height = NUM_LINES_4CIFS_NTSC * 2; in s2255_board_init()
2022 vc->std = V4L2_STD_NTSC_M; in s2255_board_init()
2023 vc->fmt = &formats[0]; in s2255_board_init()
2024 vc->mode.restart = 1; in s2255_board_init()
2025 vc->req_image_size = get_transfer_size(&mode_def); in s2255_board_init()
2026 vc->frame_count = 0; in s2255_board_init()
2028 s2255_create_sys_buffers(vc); in s2255_board_init()
2042 if (vb2_is_streaming(&dev->vc[i].vb_vidq)) in s2255_board_shutdown()
2043 s2255_stop_acquire(&dev->vc[i]); in s2255_board_shutdown()
2047 s2255_release_sys_buffers(&dev->vc[i]); in s2255_board_shutdown()
2136 static int s2255_start_acquire(struct s2255_vc *vc) in s2255_start_acquire() argument
2141 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_start_acquire()
2145 chn_rev = G_chnmap[vc->idx]; in s2255_start_acquire()
2146 vc->last_frame = -1; in s2255_start_acquire()
2147 vc->bad_payload = 0; in s2255_start_acquire()
2148 vc->cur_frame = 0; in s2255_start_acquire()
2150 vc->buffer.frame[j].ulState = 0; in s2255_start_acquire()
2151 vc->buffer.frame[j].cur_size = 0; in s2255_start_acquire()
2162 dprintk(dev, 2, "start acquire exit[%d] %d\n", vc->idx, res); in s2255_start_acquire()
2167 static int s2255_stop_acquire(struct s2255_vc *vc) in s2255_stop_acquire() argument
2171 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); in s2255_stop_acquire()
2175 chn_rev = G_chnmap[vc->idx]; in s2255_stop_acquire()
2185 dprintk(dev, 4, "%s: chn %d, res %d\n", __func__, vc->idx, res); in s2255_stop_acquire()
2283 struct s2255_vc *vc = &dev->vc[i]; in s2255_probe() local
2284 vc->idx = i; in s2255_probe()
2285 vc->dev = dev; in s2255_probe()
2286 init_waitqueue_head(&vc->wait_setmode); in s2255_probe()
2287 init_waitqueue_head(&vc->wait_vidstatus); in s2255_probe()
2288 spin_lock_init(&vc->qlock); in s2255_probe()
2289 mutex_init(&vc->vb_lock); in s2255_probe()
2377 video_unregister_device(&dev->vc[i].vdev); in s2255_disconnect()
2382 dev->vc[i].setmode_ready = 1; in s2255_disconnect()
2383 wake_up(&dev->vc[i].wait_setmode); in s2255_disconnect()
2384 dev->vc[i].vidstatus_ready = 1; in s2255_disconnect()
2385 wake_up(&dev->vc[i].wait_vidstatus); in s2255_disconnect()