Lines Matching refs:v4l2
29 #include <media/v4l2-common.h>
30 #include <media/v4l2-ioctl.h>
31 #include <media/v4l2-event.h>
65 MODULE_DESCRIPTION(DRIVER_DESC " - v4l2 interface");
128 struct em28xx_v4l2 *v4l2 = dev->v4l2;
131 return v4l2->sensor_xres;
141 struct em28xx_v4l2 *v4l2 = dev->v4l2;
144 return v4l2->sensor_yres;
149 return (v4l2->norm & V4L2_STD_625_50) ? 576 : 480;
177 struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev;
206 struct em28xx_v4l2 *v4l2 = dev->v4l2;
208 fmt = v4l2->format->reg;
224 ret = em28xx_write_reg(dev, EM28XX_R10_VINMODE, v4l2->vinmode);
228 vinctrl = v4l2->vinctl;
233 v4l2->vbi_width / 4);
234 em28xx_write_reg(dev, EM28XX_R37_VBI_HEIGHT, v4l2->vbi_height);
235 if (v4l2->norm & V4L2_STD_525_60) {
238 } else if (v4l2->norm & V4L2_STD_625_50) {
315 struct em28xx_v4l2 *v4l2 = dev->v4l2;
320 v4l2->vbi_width = 720;
321 if (v4l2->norm & V4L2_STD_525_60)
322 v4l2->vbi_height = 12;
324 v4l2->vbi_height = 18;
344 return em28xx_scaler_set(dev, v4l2->hscale, v4l2->vscale);
350 struct em28xx_v4l2 *v4l2 = dev->v4l2;
354 unsigned int min_pkt_size = v4l2->width * 2 + 4;
374 if (v4l2->width * 2 * v4l2->height > 720 * 240 * 2)
432 buf->vb.sequence = dev->v4l2->field_count++;
433 if (dev->v4l2->progressive)
450 struct em28xx_v4l2 *v4l2 = dev->v4l2;
453 int bytesperline = v4l2->width << 1;
461 if (v4l2->progressive || buf->top_field)
469 if (v4l2->progressive)
493 if (v4l2->progressive)
539 offset += dev->v4l2->vbi_width * dev->v4l2->vbi_height;
615 struct em28xx_v4l2 *v4l2 = dev->v4l2;
617 if (v4l2->progressive || v4l2->top_field) { /* Brand new frame */
623 buf->top_field = v4l2->top_field;
637 struct em28xx_v4l2 *v4l2 = dev->v4l2;
661 v4l2->capture_type = 0;
662 v4l2->vbi_read = 0;
664 v4l2->top_field = !(data_pkt[2] & 1);
669 v4l2->capture_type = 2;
671 v4l2->top_field = !(data_pkt[2] & 1);
681 if (v4l2->capture_type == 0) {
684 v4l2->capture_type = 1;
687 if (v4l2->capture_type == 1) {
688 int vbi_size = v4l2->vbi_width * v4l2->vbi_height;
689 int vbi_data_len = ((v4l2->vbi_read + data_len) > vbi_size) ?
690 (vbi_size - v4l2->vbi_read) : data_len;
695 v4l2->vbi_read += vbi_data_len;
699 v4l2->capture_type = 2;
705 if (v4l2->capture_type == 2) {
708 v4l2->capture_type = 3;
711 if (v4l2->capture_type == 3 && buf && data_len > 0)
724 struct em28xx_v4l2 *v4l2 = dev->v4l2;
735 v4l2->top_field = !(data_pkt[1] &
899 struct em28xx_v4l2 *v4l2 = dev->v4l2;
904 if (!mdev || !v4l2->decoder)
914 list_for_each_entry(link, &v4l2->decoder->links, list) {
915 if (link->sink->entity == v4l2->decoder) {
933 if (sink == v4l2->decoder)
964 struct em28xx_v4l2 *v4l2 = dev->v4l2;
968 v4l2->video_pad.flags = MEDIA_PAD_FL_SINK;
969 ret = media_entity_pads_init(&v4l2->vdev.entity, 1, &v4l2->video_pad);
975 v4l2->vbi_pad.flags = MEDIA_PAD_FL_SINK;
976 ret = media_entity_pads_init(&v4l2->vbi_dev.entity, 1,
977 &v4l2->vbi_pad);
1033 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1035 (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3;
1052 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1057 size = (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3;
1072 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1079 dev->v4l2->field_count = 0;
1089 if (v4l2->streaming_users == 0) {
1101 v4l2->capture_type = -1;
1119 f.frequency = v4l2->frequency;
1125 v4l2_device_call_all(&v4l2->v4l2_dev,
1129 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 1);
1132 v4l2->streaming_users++;
1140 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1148 if (v4l2->streaming_users-- == 1) {
1150 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 0);
1175 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1183 if (v4l2->streaming_users-- == 1) {
1185 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 0);
1240 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1243 q = &v4l2->vb_vidq;
1257 q = &v4l2->vb_vbiq;
1274 * v4l2 interface
1279 struct v4l2_device *v4l2_dev = &dev->v4l2->v4l2_dev;
1334 struct em28xx_v4l2 *v4l2 =
1336 struct em28xx *dev = v4l2->dev;
1416 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1418 f->fmt.pix.width = v4l2->width;
1419 f->fmt.pix.height = v4l2->height;
1420 f->fmt.pix.pixelformat = v4l2->format->fourcc;
1421 f->fmt.pix.bytesperline = (v4l2->width * v4l2->format->depth + 7) >> 3;
1422 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * v4l2->height;
1426 if (v4l2->progressive)
1429 f->fmt.pix.field = v4l2->interlaced_fieldmode ?
1449 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1498 if (v4l2->progressive)
1501 f->fmt.pix.field = v4l2->interlaced_fieldmode ?
1511 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1517 v4l2->format = fmt;
1518 v4l2->width = width;
1519 v4l2->height = height;
1522 size_to_scale(dev, v4l2->width, v4l2->height,
1523 &v4l2->hscale, &v4l2->vscale);
1534 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1536 if (vb2_is_busy(&v4l2->vb_vidq))
1549 *norm = dev->v4l2->norm;
1558 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, video, querystd, norm);
1566 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1569 if (norm == v4l2->norm)
1572 if (v4l2->streaming_users > 0)
1575 v4l2->norm = norm;
1583 v4l2->width = f.fmt.pix.width;
1584 v4l2->height = f.fmt.pix.height;
1585 size_to_scale(dev, v4l2->width, v4l2->height,
1586 &v4l2->hscale, &v4l2->vscale);
1589 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_std, v4l2->norm);
1599 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1609 rc = v4l2_device_call_until_err(&v4l2->v4l2_dev, 0,
1614 v4l2_video_std_frame_period(v4l2->norm,
1641 rc = v4l2_device_call_until_err(&dev->v4l2->v4l2_dev, 0,
1668 i->std = dev->v4l2->vdev.tvnorms;
1832 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, g_tuner, t);
1844 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, s_tuner, t);
1852 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1857 f->frequency = v4l2->frequency;
1866 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1871 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, s_frequency, f);
1872 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, g_frequency, &new_freq);
1873 v4l2->frequency = new_freq.frequency;
1890 dev->v4l2->v4l2_dev.name, sizeof(chip->name));
1970 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1983 if (video_is_registered(&v4l2->vbi_dev))
1985 if (video_is_registered(&v4l2->radio_dev))
2049 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2051 format->fmt.vbi.samples_per_line = v4l2->vbi_width;
2056 format->fmt.vbi.count[0] = v4l2->vbi_height;
2057 format->fmt.vbi.count[1] = v4l2->vbi_height;
2061 if (v4l2->norm & V4L2_STD_525_60) {
2065 } else if (v4l2->norm & V4L2_STD_625_50) {
2088 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, g_tuner, t);
2101 v4l2_device_call_all(&dev->v4l2->v4l2_dev, 0, tuner, s_tuner, t);
2115 struct em28xx_v4l2 *v4l2 = container_of(ref, struct em28xx_v4l2, ref);
2117 v4l2->dev->v4l2 = NULL;
2118 kfree(v4l2);
2129 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2148 v4l2->users);
2162 if (v4l2->users == 0) {
2177 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, s_radio);
2181 kref_get(&v4l2->ref);
2182 v4l2->users++;
2191 * unregisters the v4l2,i2c and usb devices
2196 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2204 /* This device does not support the v4l2 extension */
2208 if (!v4l2)
2215 v4l2_device_disconnect(&v4l2->v4l2_dev);
2221 if (video_is_registered(&v4l2->radio_dev)) {
2223 video_device_node_name(&v4l2->radio_dev));
2224 video_unregister_device(&v4l2->radio_dev);
2226 if (video_is_registered(&v4l2->vbi_dev)) {
2228 video_device_node_name(&v4l2->vbi_dev));
2229 video_unregister_device(&v4l2->vbi_dev);
2231 if (video_is_registered(&v4l2->vdev)) {
2233 video_device_node_name(&v4l2->vdev));
2234 video_unregister_device(&v4l2->vdev);
2237 v4l2_ctrl_handler_free(&v4l2->ctrl_handler);
2238 v4l2_device_unregister(&v4l2->v4l2_dev);
2240 kref_put(&v4l2->ref, em28xx_free_v4l2);
2277 * stops streaming and deallocates all resources allocated by the v4l2
2283 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2287 em28xx_videodbg("users=%d\n", v4l2->users);
2292 if (v4l2->users == 1) {
2298 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, standby);
2315 v4l2->users--;
2316 kref_put(&v4l2->ref, em28xx_free_v4l2);
2438 vfd->v4l2_dev = &dev->v4l2->v4l2_dev;
2451 struct em28xx_v4l2 *v4l2 = dev->v4l2;
2452 struct v4l2_device *v4l2_dev = &v4l2->v4l2_dev;
2506 v4l2->frequency = f.frequency;
2516 struct em28xx_v4l2 *v4l2;
2524 /* This device does not support the v4l2 extension */
2532 v4l2 = kzalloc(sizeof(*v4l2), GFP_KERNEL);
2533 if (!v4l2) {
2537 kref_init(&v4l2->ref);
2538 v4l2->dev = dev;
2539 dev->v4l2 = v4l2;
2542 v4l2->v4l2_dev.mdev = dev->media_dev;
2544 ret = v4l2_device_register(&dev->intf->dev, &v4l2->v4l2_dev);
2551 hdl = &v4l2->ctrl_handler;
2553 v4l2->v4l2_dev.ctrl_handler = hdl;
2556 v4l2->progressive = true;
2561 v4l2->vinmode = EM28XX_VINMODE_YUV422_CbYCrY;
2562 v4l2->vinctl = EM28XX_VINCTRL_INTERLACED |
2568 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2573 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2578 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2583 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2594 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2600 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2609 sd = v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2617 v4l2_i2c_new_subdev(&v4l2->v4l2_dev,
2678 v4l2->norm = V4L2_STD_PAL;
2679 v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_std, v4l2->norm);
2680 v4l2->interlaced_fieldmode = EM28XX_INTERLACED_DEFAULT;
2683 v4l2->format = &format[0];
2749 em28xx_vdev_init(dev, &v4l2->vdev, &em28xx_video_template, "video");
2750 mutex_init(&v4l2->vb_queue_lock);
2751 mutex_init(&v4l2->vb_vbi_queue_lock);
2752 v4l2->vdev.queue = &v4l2->vb_vidq;
2753 v4l2->vdev.queue->lock = &v4l2->vb_queue_lock;
2754 v4l2->vdev.device_caps = V4L2_CAP_READWRITE | V4L2_CAP_VIDEO_CAPTURE |
2757 v4l2->vdev.device_caps |= V4L2_CAP_AUDIO;
2759 v4l2->vdev.device_caps |= V4L2_CAP_TUNER;
2764 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_QUERYSTD);
2765 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_G_STD);
2766 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_STD);
2768 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_PARM);
2771 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_G_TUNER);
2772 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_TUNER);
2773 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_G_FREQUENCY);
2774 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_FREQUENCY);
2777 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_G_AUDIO);
2778 v4l2_disable_ioctl(&v4l2->vdev, VIDIOC_S_AUDIO);
2781 /* register v4l2 video video_device */
2782 ret = video_register_device(&v4l2->vdev, VFL_TYPE_VIDEO,
2792 em28xx_vdev_init(dev, &v4l2->vbi_dev, &em28xx_video_template,
2795 v4l2->vbi_dev.queue = &v4l2->vb_vbiq;
2796 v4l2->vbi_dev.queue->lock = &v4l2->vb_vbi_queue_lock;
2797 v4l2->vbi_dev.device_caps = V4L2_CAP_STREAMING |
2800 v4l2->vbi_dev.device_caps |= V4L2_CAP_TUNER;
2803 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_S_PARM);
2805 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_G_TUNER);
2806 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_S_TUNER);
2807 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_G_FREQUENCY);
2808 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_S_FREQUENCY);
2811 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_G_AUDIO);
2812 v4l2_disable_ioctl(&v4l2->vbi_dev, VIDIOC_S_AUDIO);
2815 /* register v4l2 vbi video_device */
2816 ret = video_register_device(&v4l2->vbi_dev, VFL_TYPE_VBI,
2826 em28xx_vdev_init(dev, &v4l2->radio_dev, &em28xx_radio_template,
2828 v4l2->radio_dev.device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER;
2829 ret = video_register_device(&v4l2->radio_dev, VFL_TYPE_RADIO,
2838 video_device_node_name(&v4l2->radio_dev));
2856 video_device_node_name(&v4l2->vdev));
2858 if (video_is_registered(&v4l2->vbi_dev))
2861 video_device_node_name(&v4l2->vbi_dev));
2864 v4l2_device_call_all(&v4l2->v4l2_dev, 0, tuner, standby);
2878 if (video_is_registered(&v4l2->radio_dev)) {
2881 video_device_node_name(&v4l2->radio_dev));
2882 video_unregister_device(&v4l2->radio_dev);
2884 if (video_is_registered(&v4l2->vbi_dev)) {
2887 video_device_node_name(&v4l2->vbi_dev));
2888 video_unregister_device(&v4l2->vbi_dev);
2890 if (video_is_registered(&v4l2->vdev)) {
2893 video_device_node_name(&v4l2->vdev));
2894 video_unregister_device(&v4l2->vdev);
2897 v4l2_ctrl_handler_free(&v4l2->ctrl_handler);
2898 v4l2_device_unregister(&v4l2->v4l2_dev);
2900 dev->v4l2 = NULL;
2901 kref_put(&v4l2->ref, em28xx_free_v4l2);
2908 .name = "Em28xx v4l2 Extension",