Lines Matching refs:v4l2

39 #include <media/v4l2-common.h>
40 #include <media/v4l2-ioctl.h>
41 #include <media/v4l2-event.h>
75 MODULE_DESCRIPTION(DRIVER_DESC " - v4l2 interface");
138 struct em28xx_v4l2 *v4l2 = dev->v4l2;
141 return v4l2->sensor_xres;
151 struct em28xx_v4l2 *v4l2 = dev->v4l2;
154 return v4l2->sensor_yres;
159 return (v4l2->norm & V4L2_STD_625_50) ? 576 : 480;
187 struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev;
216 struct em28xx_v4l2 *v4l2 = dev->v4l2;
218 fmt = v4l2->format->reg;
234 ret = em28xx_write_reg(dev, EM28XX_R10_VINMODE, v4l2->vinmode);
238 vinctrl = v4l2->vinctl;
243 v4l2->vbi_width / 4);
244 em28xx_write_reg(dev, EM28XX_R37_VBI_HEIGHT, v4l2->vbi_height);
245 if (v4l2->norm & V4L2_STD_525_60) {
248 } else if (v4l2->norm & V4L2_STD_625_50) {
325 struct em28xx_v4l2 *v4l2 = dev->v4l2;
330 v4l2->vbi_width = 720;
331 if (v4l2->norm & V4L2_STD_525_60)
332 v4l2->vbi_height = 12;
334 v4l2->vbi_height = 18;
354 return em28xx_scaler_set(dev, v4l2->hscale, v4l2->vscale);
360 struct em28xx_v4l2 *v4l2 = dev->v4l2;
364 unsigned int min_pkt_size = v4l2->width * 2 + 4;
384 if (v4l2->width * 2 * v4l2->height > 720 * 240 * 2)
442 buf->vb.sequence = dev->v4l2->field_count++;
443 if (dev->v4l2->progressive)
460 struct em28xx_v4l2 *v4l2 = dev->v4l2;
463 int bytesperline = v4l2->width << 1;
471 if (v4l2->progressive || buf->top_field)
479 if (v4l2->progressive)
503 if (v4l2->progressive)
549 offset += dev->v4l2->vbi_width * dev->v4l2->vbi_height;
625 struct em28xx_v4l2 *v4l2 = dev->v4l2;
627 if (v4l2->progressive || v4l2->top_field) { /* Brand new frame */
633 buf->top_field = v4l2->top_field;
647 struct em28xx_v4l2 *v4l2 = dev->v4l2;
671 v4l2->capture_type = 0;
672 v4l2->vbi_read = 0;
674 v4l2->top_field = !(data_pkt[2] & 1);
679 v4l2->capture_type = 2;
681 v4l2->top_field = !(data_pkt[2] & 1);
691 if (v4l2->capture_type == 0) {
694 v4l2->capture_type = 1;
697 if (v4l2->capture_type == 1) {
698 int vbi_size = v4l2->vbi_width * v4l2->vbi_height;
699 int vbi_data_len = ((v4l2->vbi_read + data_len) > vbi_size) ?
700 (vbi_size - v4l2->vbi_read) : data_len;
705 v4l2->vbi_read += vbi_data_len;
709 v4l2->capture_type = 2;
715 if (v4l2->capture_type == 2) {
718 v4l2->capture_type = 3;
721 if (v4l2->capture_type == 3 && buf && data_len > 0)
734 struct em28xx_v4l2 *v4l2 = dev->v4l2;
745 v4l2->top_field = !(data_pkt[1] &
909 struct em28xx_v4l2 *v4l2 = dev->v4l2;
914 if (!mdev || !v4l2->decoder)
924 list_for_each_entry(link, &v4l2->decoder->links, list) {
925 if (link->sink->entity == v4l2->decoder) {
943 if (sink == v4l2->decoder)
974 struct em28xx_v4l2 *v4l2 = dev->v4l2;
978 v4l2->video_pad.flags = MEDIA_PAD_FL_SINK;
979 ret = media_entity_pads_init(&v4l2->vdev.entity, 1, &v4l2->video_pad);
985 v4l2->vbi_pad.flags = MEDIA_PAD_FL_SINK;
986 ret = media_entity_pads_init(&v4l2->vbi_dev.entity, 1,
987 &v4l2->vbi_pad);
1043 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1045 (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3;
1062 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1067 size = (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3;
1082 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1089 dev->v4l2->field_count = 0;
1099 if (v4l2->streaming_users == 0) {
1111 v4l2->capture_type = -1;
1129 f.frequency = v4l2->frequency;
1135 v4l2_device_call_all(&v4l2->v4l2_dev,
1139 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 1);
1142 v4l2->streaming_users++;
1150 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1158 if (v4l2->streaming_users-- == 1) {
1160 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 0);
1185 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1193 if (v4l2->streaming_users-- == 1) {
1195 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 0);
1250 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1253 q = &v4l2->vb_vidq;
1267 q = &v4l2->vb_vbiq;
1284 * v4l2 interface
1289 struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev;
1344 struct em28xx_v4l2 *v4l2 =
1346 struct em28xx *dev = v4l2->dev;
1426 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1428 f->fmt.pix.width = v4l2->width;
1429 f->fmt.pix.height = v4l2->height;
1430 f->fmt.pix.pixelformat = v4l2->format->fourcc;
1431 f->fmt.pix.bytesperline = (v4l2->width * v4l2->format->depth + 7) >> 3;
1432 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * v4l2->height;
1436 if (v4l2->progressive)
1439 f->fmt.pix.field = v4l2->interlaced_fieldmode ?
1459 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1508 if (v4l2->progressive)
1511 f->fmt.pix.field = v4l2->interlaced_fieldmode ?
1521 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1527 v4l2->format = fmt;
1528 v4l2->width = width;
1529 v4l2->height = height;
1532 size_to_scale(dev, v4l2->width, v4l2->height,
1533 &v4l2->hscale, &v4l2->vscale);
1544 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1546 if (vb2_is_busy(&v4l2->vb_vidq))
1559 *norm = dev->v4l2->norm;
1568 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, video, querystd, norm);
1576 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1579 if (norm == v4l2->norm)
1582 if (v4l2->streaming_users > 0)
1585 v4l2->norm = norm;
1593 v4l2->width = f.fmt.pix.width;
1594 v4l2->height = f.fmt.pix.height;
1595 size_to_scale(dev, v4l2->width, v4l2->height,
1596 &v4l2->hscale, &v4l2->vscale);
1599 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_std, v4l2->norm);
1609 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1619 rc = v4l2_device_call_until_err(&v4l2->v4l2_dev, 0,
1624 v4l2_video_std_frame_period(v4l2->norm,
1651 rc = v4l2_device_call_until_err(&dev->v4l2->v4l2_dev, 0,
1678 i->std = dev->v4l2->vdev.tvnorms;
1842 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, g_tuner, t);
1854 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, s_tuner, t);
1862 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1867 f->frequency = v4l2->frequency;
1876 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1881 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, s_frequency, f);
1882 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, g_frequency, &new_freq);
1883 v4l2->frequency = new_freq.frequency;
1900 dev->v4l2->v4l2_dev.name, sizeof(chip->name));
1980 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1993 if (video_is_registered(&v4l2->vbi_dev))
1995 if (video_is_registered(&v4l2->radio_dev))
2059 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2061 format->fmt.vbi.samples_per_line = v4l2->vbi_width;
2066 format->fmt.vbi.count[0] = v4l2->vbi_height;
2067 format->fmt.vbi.count[1] = v4l2->vbi_height;
2071 if (v4l2->norm & V4L2_STD_525_60) {
2075 } else if (v4l2->norm & V4L2_STD_625_50) {
2098 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, g_tuner, t);
2111 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, s_tuner, t);
2125 struct em28xx_v4l2 *v4l2 = container_of(ref, struct em28xx_v4l2, ref);
2127 v4l2->dev->v4l2 = NULL;
2128 kfree(v4l2);
2139 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2158 v4l2->users);
2172 if (v4l2->users == 0) {
2187 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, s_radio);
2191 kref_get(&v4l2->ref);
2192 v4l2->users++;
2201 * unregisters the v4l2,i2c and usb devices
2206 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2214 /* This device does not support the v4l2 extension */
2218 if (!v4l2)
2225 v4l2_device_disconnect(&v4l2->v4l2_dev);
2231 if (video_is_registered(&v4l2->radio_dev)) {
2233 video_device_node_name(&v4l2->radio_dev));
2234 video_unregister_device(&v4l2->radio_dev);
2236 if (video_is_registered(&v4l2->vbi_dev)) {
2238 video_device_node_name(&v4l2->vbi_dev));
2239 video_unregister_device(&v4l2->vbi_dev);
2241 if (video_is_registered(&v4l2->vdev)) {
2243 video_device_node_name(&v4l2->vdev));
2244 video_unregister_device(&v4l2->vdev);
2247 v4l2_ctrl_handler_free(&v4l2->ctrl_handler);
2248 v4l2_device_unregister(&v4l2->v4l2_dev);
2250 kref_put(&v4l2->ref, em28xx_free_v4l2);
2287 * stops streaming and deallocates all resources allocated by the v4l2
2293 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2297 em28xx_videodbg("users=%d\n", v4l2->users);
2302 if (v4l2->users == 1) {
2308 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, standby);
2325 v4l2->users--;
2326 kref_put(&v4l2->ref, em28xx_free_v4l2);
2448 vfd->v4l2_dev = &dev->v4l2->v4l2_dev;
2461 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2462 struct v4l2_device *v4l2_dev = &v4l2->v4l2_dev;
2516 v4l2->frequency = f.frequency;
2526 struct em28xx_v4l2 *v4l2;
2534 /* This device does not support the v4l2 extension */
2542 v4l2 = kzalloc(sizeof(*v4l2), GFP_KERNEL);
2543 if (!v4l2) {
2547 kref_init(&v4l2->ref);
2548 v4l2->dev = dev;
2549 dev->v4l2 = v4l2;
2552 v4l2->v4l2_dev.mdev = dev->media_dev;
2554 ret = v4l2_device_register(&dev->intf->dev, &v4l2->v4l2_dev);
2561 hdl = &v4l2->ctrl_handler;
2563 v4l2->v4l2_dev.ctrl_handler = hdl;
2566 v4l2->progressive = true;
2571 v4l2->vinmode = EM28XX_VINMODE_YUV422_CbYCrY;
2572 v4l2->vinctl = EM28XX_VINCTRL_INTERLACED |
2578 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2583 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2588 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2593 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2604 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2610 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2619 sd = v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2627 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2688 v4l2->norm = V4L2_STD_PAL;
2689 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_std, v4l2->norm);
2690 v4l2->interlaced_fieldmode = EM28XX_INTERLACED_DEFAULT;
2693 v4l2->format = &format[0];
2759 em28xx_vdev_init(dev, &v4l2->vdev, &em28xx_video_template, "video");
2760 mutex_init(&v4l2->vb_queue_lock);
2761 mutex_init(&v4l2->vb_vbi_queue_lock);
2762 v4l2->vdev.queue = &v4l2->vb_vidq;
2763 v4l2->vdev.queue->lock = &v4l2->vb_queue_lock;
2764 v4l2->vdev.device_caps = V4L2_CAP_READWRITE | V4L2_CAP_VIDEO_CAPTURE |
2767 v4l2->vdev.device_caps |= V4L2_CAP_AUDIO;
2769 v4l2->vdev.device_caps |= V4L2_CAP_TUNER;
2774 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_QUERYSTD);
2775 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_G_STD);
2776 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_STD);
2778 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_PARM);
2781 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_G_TUNER);
2782 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_TUNER);
2783 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_G_FREQUENCY);
2784 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_FREQUENCY);
2787 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_G_AUDIO);
2788 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_AUDIO);
2791 /* register v4l2 video video_device */
2792 ret = video_register_device(&v4l2->vdev, VFL_TYPE_VIDEO,
2802 em28xx_vdev_init(dev, &v4l2->vbi_dev, &em28xx_video_template,
2805 v4l2->vbi_dev.queue = &v4l2->vb_vbiq;
2806 v4l2->vbi_dev.queue->lock = &v4l2->vb_vbi_queue_lock;
2807 v4l2->vbi_dev.device_caps = V4L2_CAP_STREAMING |
2810 v4l2->vbi_dev.device_caps |= V4L2_CAP_TUNER;
2813 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_S_PARM);
2815 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_G_TUNER);
2816 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_S_TUNER);
2817 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_G_FREQUENCY);
2818 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_S_FREQUENCY);
2821 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_G_AUDIO);
2822 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_S_AUDIO);
2825 /* register v4l2 vbi video_device */
2826 ret = video_register_device(&v4l2->vbi_dev, VFL_TYPE_VBI,
2836 em28xx_vdev_init(dev, &v4l2->radio_dev, &em28xx_radio_template,
2838 v4l2->radio_dev.device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER;
2839 ret = video_register_device(&v4l2->radio_dev, VFL_TYPE_RADIO,
2848 video_device_node_name(&v4l2->radio_dev));
2866 video_device_node_name(&v4l2->vdev));
2868 if (video_is_registered(&v4l2->vbi_dev))
2871 video_device_node_name(&v4l2->vbi_dev));
2874 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, standby);
2888 if (video_is_registered(&v4l2->radio_dev)) {
2891 video_device_node_name(&v4l2->radio_dev));
2892 video_unregister_device(&v4l2->radio_dev);
2894 if (video_is_registered(&v4l2->vbi_dev)) {
2897 video_device_node_name(&v4l2->vbi_dev));
2898 video_unregister_device(&v4l2->vbi_dev);
2900 if (video_is_registered(&v4l2->vdev)) {
2903 video_device_node_name(&v4l2->vdev));
2904 video_unregister_device(&v4l2->vdev);
2907 v4l2_ctrl_handler_free(&v4l2->ctrl_handler);
2908 v4l2_device_unregister(&v4l2->v4l2_dev);
2910 dev->v4l2 = NULL;
2911 kref_put(&v4l2->ref, em28xx_free_v4l2);
2918 .name = "Em28xx v4l2 Extension",