Lines Matching +full:sdtv +full:- +full:standards

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Hauppauge HD PVR USB driver - video 4 linux 2 interface
19 #include <linux/v4l2-dv-timings.h>
20 #include <media/v4l2-dev.h>
21 #include <media/v4l2-common.h>
22 #include <media/v4l2-dv-timings.h>
23 #include <media/v4l2-ioctl.h>
24 #include <media/v4l2-event.h>
30 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, \
33 list_size(&dev->free_buff_list), \
34 list_size(&dev->rec_buff_list)); }
71 struct hdpvr_buffer *buf = (struct hdpvr_buffer *)urb->context; in hdpvr_read_bulk_callback()
72 struct hdpvr_device *dev = buf->dev; in hdpvr_read_bulk_callback()
75 buf->status = BUFSTAT_READY; in hdpvr_read_bulk_callback()
76 wake_up_interruptible(&dev->wait_data); in hdpvr_read_bulk_callback()
82 /* function expects dev->io_mutex to be hold by caller */
87 list_for_each_entry(buf, &dev->rec_buff_list, buff_list) { in hdpvr_cancel_queue()
88 usb_kill_urb(buf->urb); in hdpvr_cancel_queue()
89 buf->status = BUFSTAT_AVAILABLE; in hdpvr_cancel_queue()
92 list_splice_init(&dev->rec_buff_list, dev->free_buff_list.prev); in hdpvr_cancel_queue()
104 for (p = q->next; p != q;) { in hdpvr_free_queue()
107 urb = buf->urb; in hdpvr_free_queue()
108 usb_free_coherent(urb->dev, urb->transfer_buffer_length, in hdpvr_free_queue()
109 urb->transfer_buffer, urb->transfer_dma); in hdpvr_free_queue()
111 tmp = p->next; in hdpvr_free_queue()
120 /* function expects dev->io_mutex to be hold by caller */
125 hdpvr_free_queue(&dev->free_buff_list); in hdpvr_free_buffers()
126 hdpvr_free_queue(&dev->rec_buff_list); in hdpvr_free_buffers()
131 /* function expects dev->io_mutex to be hold by caller */
135 int retval = -ENOMEM; in hdpvr_alloc_buffers()
140 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_alloc_buffers()
147 v4l2_err(&dev->v4l2_dev, "cannot allocate buffer\n"); in hdpvr_alloc_buffers()
150 buf->dev = dev; in hdpvr_alloc_buffers()
155 buf->urb = urb; in hdpvr_alloc_buffers()
157 mem = usb_alloc_coherent(dev->udev, dev->bulk_in_size, GFP_KERNEL, in hdpvr_alloc_buffers()
158 &urb->transfer_dma); in hdpvr_alloc_buffers()
160 v4l2_err(&dev->v4l2_dev, in hdpvr_alloc_buffers()
165 usb_fill_bulk_urb(buf->urb, dev->udev, in hdpvr_alloc_buffers()
166 usb_rcvbulkpipe(dev->udev, in hdpvr_alloc_buffers()
167 dev->bulk_in_endpointAddr), in hdpvr_alloc_buffers()
168 mem, dev->bulk_in_size, in hdpvr_alloc_buffers()
171 buf->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in hdpvr_alloc_buffers()
172 buf->status = BUFSTAT_AVAILABLE; in hdpvr_alloc_buffers()
173 list_add_tail(&buf->buff_list, &dev->free_buff_list); in hdpvr_alloc_buffers()
191 mutex_lock(&dev->io_mutex); in hdpvr_submit_buffers()
193 while (dev->status == STATUS_STREAMING && in hdpvr_submit_buffers()
194 !list_empty(&dev->free_buff_list)) { in hdpvr_submit_buffers()
196 buf = list_entry(dev->free_buff_list.next, struct hdpvr_buffer, in hdpvr_submit_buffers()
198 if (buf->status != BUFSTAT_AVAILABLE) { in hdpvr_submit_buffers()
199 v4l2_err(&dev->v4l2_dev, in hdpvr_submit_buffers()
201 ret = -EFAULT; in hdpvr_submit_buffers()
205 urb = buf->urb; in hdpvr_submit_buffers()
206 urb->status = 0; in hdpvr_submit_buffers()
207 urb->actual_length = 0; in hdpvr_submit_buffers()
210 v4l2_err(&dev->v4l2_dev, in hdpvr_submit_buffers()
217 buf->status = BUFSTAT_INPROGRESS; in hdpvr_submit_buffers()
218 list_move_tail(&buf->buff_list, &dev->rec_buff_list); in hdpvr_submit_buffers()
222 mutex_unlock(&dev->io_mutex); in hdpvr_submit_buffers()
230 mutex_lock(&dev->io_mutex); in hdpvr_get_next_buffer()
232 if (list_empty(&dev->rec_buff_list)) { in hdpvr_get_next_buffer()
233 mutex_unlock(&dev->io_mutex); in hdpvr_get_next_buffer()
237 buf = list_entry(dev->rec_buff_list.next, struct hdpvr_buffer, in hdpvr_get_next_buffer()
239 mutex_unlock(&dev->io_mutex); in hdpvr_get_next_buffer()
249 while (dev->status == STATUS_STREAMING) { in hdpvr_transmit_buffers()
252 v4l2_err(&dev->v4l2_dev, "couldn't submit buffers\n"); in hdpvr_transmit_buffers()
255 if (wait_event_interruptible(dev->wait_buffer, in hdpvr_transmit_buffers()
256 !list_empty(&dev->free_buff_list) || in hdpvr_transmit_buffers()
257 dev->status != STATUS_STREAMING)) in hdpvr_transmit_buffers()
261 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_transmit_buffers()
265 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_transmit_buffers()
267 dev->status = STATUS_ERROR; in hdpvr_transmit_buffers()
270 /* function expects dev->io_mutex to be hold by caller */
276 if (dev->status == STATUS_STREAMING) in hdpvr_start_streaming()
278 if (dev->status != STATUS_IDLE) in hdpvr_start_streaming()
279 return -EAGAIN; in hdpvr_start_streaming()
287 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_start_streaming()
288 "no video signal at input %d\n", dev->options.video_input); in hdpvr_start_streaming()
289 return -EAGAIN; in hdpvr_start_streaming()
292 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_start_streaming()
297 ret = usb_control_msg(dev->udev, in hdpvr_start_streaming()
298 usb_sndctrlpipe(dev->udev, 0), in hdpvr_start_streaming()
300 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_start_streaming()
309 dev->status = STATUS_STREAMING; in hdpvr_start_streaming()
311 schedule_work(&dev->worker); in hdpvr_start_streaming()
313 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_start_streaming()
320 /* function expects dev->io_mutex to be hold by caller */
327 if (dev->status == STATUS_IDLE) in hdpvr_stop_streaming()
329 else if (dev->status != STATUS_STREAMING) in hdpvr_stop_streaming()
330 return -EAGAIN; in hdpvr_stop_streaming()
332 buf = kmalloc(dev->bulk_in_size, GFP_KERNEL); in hdpvr_stop_streaming()
334 …v4l2_err(&dev->v4l2_dev, "failed to allocate temporary buffer for emptying the internal device buf… in hdpvr_stop_streaming()
336 dev->status = STATUS_SHUTTING_DOWN; in hdpvr_stop_streaming()
338 mutex_unlock(&dev->io_mutex); in hdpvr_stop_streaming()
340 wake_up_interruptible(&dev->wait_buffer); in hdpvr_stop_streaming()
343 flush_work(&dev->worker); in hdpvr_stop_streaming()
345 mutex_lock(&dev->io_mutex); in hdpvr_stop_streaming()
351 !usb_bulk_msg(dev->udev, in hdpvr_stop_streaming()
352 usb_rcvbulkpipe(dev->udev, in hdpvr_stop_streaming()
353 dev->bulk_in_endpointAddr), in hdpvr_stop_streaming()
354 buf, dev->bulk_in_size, &actual_length, in hdpvr_stop_streaming()
356 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_stop_streaming()
360 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_stop_streaming()
361 "used %d urbs to empty device buffers\n", c-1); in hdpvr_stop_streaming()
364 dev->status = STATUS_IDLE; in hdpvr_stop_streaming()
380 return -ENOMEM; in hdpvr_open()
381 fh->legacy_mode = true; in hdpvr_open()
382 v4l2_fh_init(&fh->fh, video_devdata(file)); in hdpvr_open()
383 v4l2_fh_add(&fh->fh); in hdpvr_open()
384 file->private_data = fh; in hdpvr_open()
392 mutex_lock(&dev->io_mutex); in hdpvr_release()
393 if (file->private_data == dev->owner) { in hdpvr_release()
395 dev->owner = NULL; in hdpvr_release()
397 mutex_unlock(&dev->io_mutex); in hdpvr_release()
416 return -ESPIPE; in hdpvr_read()
418 mutex_lock(&dev->io_mutex); in hdpvr_read()
419 if (dev->status == STATUS_IDLE) { in hdpvr_read()
421 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_read()
423 ret = -EIO; in hdpvr_read()
425 dev->status = STATUS_IDLE; in hdpvr_read()
426 mutex_unlock(&dev->io_mutex); in hdpvr_read()
429 dev->owner = file->private_data; in hdpvr_read()
432 mutex_unlock(&dev->io_mutex); in hdpvr_read()
435 if (!(file->f_flags & O_NONBLOCK)) { in hdpvr_read()
436 if (wait_event_interruptible(dev->wait_data, in hdpvr_read()
437 !list_empty_careful(&dev->rec_buff_list))) in hdpvr_read()
438 return -ERESTARTSYS; in hdpvr_read()
445 if (buf->status != BUFSTAT_READY && in hdpvr_read()
446 dev->status != STATUS_DISCONNECTED) { in hdpvr_read()
449 if (file->f_flags & O_NONBLOCK) { in hdpvr_read()
451 ret = -EAGAIN; in hdpvr_read()
455 err = wait_event_interruptible_timeout(dev->wait_data, in hdpvr_read()
456 buf->status == BUFSTAT_READY, in hdpvr_read()
463 v4l2_info(&dev->v4l2_dev, in hdpvr_read()
465 mutex_lock(&dev->io_mutex); in hdpvr_read()
467 mutex_unlock(&dev->io_mutex); in hdpvr_read()
482 if (buf->status != BUFSTAT_READY) in hdpvr_read()
486 urb = buf->urb; in hdpvr_read()
487 rem = urb->actual_length - buf->pos; in hdpvr_read()
490 if (copy_to_user(buffer, urb->transfer_buffer + buf->pos, in hdpvr_read()
492 v4l2_err(&dev->v4l2_dev, "read: copy_to_user failed\n"); in hdpvr_read()
494 ret = -EFAULT; in hdpvr_read()
498 buf->pos += cnt; in hdpvr_read()
499 count -= cnt; in hdpvr_read()
504 if (buf->pos == urb->actual_length) { in hdpvr_read()
505 mutex_lock(&dev->io_mutex); in hdpvr_read()
506 buf->pos = 0; in hdpvr_read()
507 buf->status = BUFSTAT_AVAILABLE; in hdpvr_read()
509 list_move_tail(&buf->buff_list, &dev->free_buff_list); in hdpvr_read()
513 mutex_unlock(&dev->io_mutex); in hdpvr_read()
515 wake_up_interruptible(&dev->wait_buffer); in hdpvr_read()
522 ret = -EAGAIN; in hdpvr_read()
536 mutex_lock(&dev->io_mutex); in hdpvr_poll()
538 if (dev->status == STATUS_IDLE) { in hdpvr_poll()
540 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_poll()
542 dev->status = STATUS_IDLE; in hdpvr_poll()
544 dev->owner = filp->private_data; in hdpvr_poll()
549 mutex_unlock(&dev->io_mutex); in hdpvr_poll()
553 if (!buf || buf->status != BUFSTAT_READY) { in hdpvr_poll()
554 poll_wait(filp, &dev->wait_data, wait); in hdpvr_poll()
557 if (buf && buf->status == BUFSTAT_READY) in hdpvr_poll()
583 strscpy(cap->driver, "hdpvr", sizeof(cap->driver)); in vidioc_querycap()
584 strscpy(cap->card, "Hauppauge HD PVR", sizeof(cap->card)); in vidioc_querycap()
585 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); in vidioc_querycap()
596 if (!fh->legacy_mode && dev->options.video_input == HDPVR_COMPONENT) in vidioc_s_std()
597 return -ENODATA; in vidioc_s_std()
598 if (dev->status != STATUS_IDLE) in vidioc_s_std()
599 return -EBUSY; in vidioc_s_std()
602 dev->cur_std = std; in vidioc_s_std()
603 dev->width = 720; in vidioc_s_std()
604 dev->height = std_type ? 576 : 480; in vidioc_s_std()
615 if (!fh->legacy_mode && dev->options.video_input == HDPVR_COMPONENT) in vidioc_g_std()
616 return -ENODATA; in vidioc_g_std()
617 *std = dev->cur_std; in vidioc_g_std()
629 if (dev->options.video_input == HDPVR_COMPONENT) in vidioc_querystd()
630 return fh->legacy_mode ? 0 : -ENODATA; in vidioc_querystd()
647 fh->legacy_mode = false; in vidioc_s_dv_timings()
648 if (dev->options.video_input) in vidioc_s_dv_timings()
649 return -ENODATA; in vidioc_s_dv_timings()
650 if (dev->status != STATUS_IDLE) in vidioc_s_dv_timings()
651 return -EBUSY; in vidioc_s_dv_timings()
656 return -EINVAL; in vidioc_s_dv_timings()
657 dev->cur_dv_timings = hdpvr_dv_timings[i]; in vidioc_s_dv_timings()
658 dev->width = hdpvr_dv_timings[i].bt.width; in vidioc_s_dv_timings()
659 dev->height = hdpvr_dv_timings[i].bt.height; in vidioc_s_dv_timings()
669 fh->legacy_mode = false; in vidioc_g_dv_timings()
670 if (dev->options.video_input) in vidioc_g_dv_timings()
671 return -ENODATA; in vidioc_g_dv_timings()
672 *timings = dev->cur_dv_timings; in vidioc_g_dv_timings()
686 fh->legacy_mode = false; in vidioc_query_dv_timings()
687 if (dev->options.video_input) in vidioc_query_dv_timings()
688 return -ENODATA; in vidioc_query_dv_timings()
693 return -ENOLCK; in vidioc_query_dv_timings()
703 fps = (unsigned)bt->pixelclock / (hsize * vsize); in vidioc_query_dv_timings()
704 if (bt->width != vid_info.width || in vidioc_query_dv_timings()
705 bt->height != vid_info.height || in vidioc_query_dv_timings()
706 bt->interlaced != interlaced || in vidioc_query_dv_timings()
713 ret = -ERANGE; in vidioc_query_dv_timings()
724 fh->legacy_mode = false; in vidioc_enum_dv_timings()
725 memset(timings->reserved, 0, sizeof(timings->reserved)); in vidioc_enum_dv_timings()
726 if (dev->options.video_input) in vidioc_enum_dv_timings()
727 return -ENODATA; in vidioc_enum_dv_timings()
728 if (timings->index >= ARRAY_SIZE(hdpvr_dv_timings)) in vidioc_enum_dv_timings()
729 return -EINVAL; in vidioc_enum_dv_timings()
730 timings->timings = hdpvr_dv_timings[timings->index]; in vidioc_enum_dv_timings()
740 fh->legacy_mode = false; in vidioc_dv_timings_cap()
741 if (dev->options.video_input) in vidioc_dv_timings_cap()
742 return -ENODATA; in vidioc_dv_timings_cap()
743 cap->type = V4L2_DV_BT_656_1120; in vidioc_dv_timings_cap()
744 cap->bt.min_width = 720; in vidioc_dv_timings_cap()
745 cap->bt.max_width = 1920; in vidioc_dv_timings_cap()
746 cap->bt.min_height = 480; in vidioc_dv_timings_cap()
747 cap->bt.max_height = 1080; in vidioc_dv_timings_cap()
748 cap->bt.min_pixelclock = 27000000; in vidioc_dv_timings_cap()
749 cap->bt.max_pixelclock = 74250000; in vidioc_dv_timings_cap()
750 cap->bt.standards = V4L2_DV_BT_STD_CEA861; in vidioc_dv_timings_cap()
751 cap->bt.capabilities = V4L2_DV_BT_CAP_INTERLACED | V4L2_DV_BT_CAP_PROGRESSIVE; in vidioc_dv_timings_cap()
757 [HDPVR_SVIDEO] = "S-Video",
765 n = i->index; in vidioc_enum_input()
767 return -EINVAL; in vidioc_enum_input()
769 i->type = V4L2_INPUT_TYPE_CAMERA; in vidioc_enum_input()
771 strscpy(i->name, iname[n], sizeof(i->name)); in vidioc_enum_input()
773 i->audioset = 1<<HDPVR_RCA_FRONT | 1<<HDPVR_RCA_BACK | 1<<HDPVR_SPDIF; in vidioc_enum_input()
775 i->capabilities = n ? V4L2_IN_CAP_STD : V4L2_IN_CAP_DV_TIMINGS; in vidioc_enum_input()
776 i->std = n ? V4L2_STD_ALL : 0; in vidioc_enum_input()
788 return -EINVAL; in vidioc_s_input()
790 if (dev->status != STATUS_IDLE) in vidioc_s_input()
791 return -EBUSY; in vidioc_s_input()
795 dev->options.video_input = index; in vidioc_s_input()
807 dev->video_dev.tvnorms = in vidioc_s_input()
820 *index = dev->options.video_input; in vidioc_g_input()
836 n = audio->index; in vidioc_enumaudio()
838 return -EINVAL; in vidioc_enumaudio()
840 audio->capability = V4L2_AUDCAP_STEREO; in vidioc_enumaudio()
842 strscpy(audio->name, audio_iname[n], sizeof(audio->name)); in vidioc_enumaudio()
853 if (audio->index >= HDPVR_AUDIO_INPUTS) in vidioc_s_audio()
854 return -EINVAL; in vidioc_s_audio()
856 if (dev->status != STATUS_IDLE) in vidioc_s_audio()
857 return -EBUSY; in vidioc_s_audio()
859 retval = hdpvr_set_audio(dev, audio->index+1, dev->options.audio_codec); in vidioc_s_audio()
861 dev->options.audio_input = audio->index; in vidioc_s_audio()
871 audio->index = dev->options.audio_input; in vidioc_g_audio()
872 audio->capability = V4L2_AUDCAP_STEREO; in vidioc_g_audio()
873 strscpy(audio->name, audio_iname[audio->index], sizeof(audio->name)); in vidioc_g_audio()
880 container_of(ctrl->handler, struct hdpvr_device, hdl); in hdpvr_try_ctrl()
882 switch (ctrl->id) { in hdpvr_try_ctrl()
884 if (ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR && in hdpvr_try_ctrl()
885 dev->video_bitrate->val >= dev->video_bitrate_peak->val) in hdpvr_try_ctrl()
886 dev->video_bitrate_peak->val = in hdpvr_try_ctrl()
887 dev->video_bitrate->val + 100000; in hdpvr_try_ctrl()
896 container_of(ctrl->handler, struct hdpvr_device, hdl); in hdpvr_s_ctrl()
897 struct hdpvr_options *opt = &dev->options; in hdpvr_s_ctrl()
898 int ret = -EINVAL; in hdpvr_s_ctrl()
900 switch (ctrl->id) { in hdpvr_s_ctrl()
902 ret = hdpvr_config_call(dev, CTRL_BRIGHTNESS, ctrl->val); in hdpvr_s_ctrl()
905 dev->options.brightness = ctrl->val; in hdpvr_s_ctrl()
908 ret = hdpvr_config_call(dev, CTRL_CONTRAST, ctrl->val); in hdpvr_s_ctrl()
911 dev->options.contrast = ctrl->val; in hdpvr_s_ctrl()
914 ret = hdpvr_config_call(dev, CTRL_SATURATION, ctrl->val); in hdpvr_s_ctrl()
917 dev->options.saturation = ctrl->val; in hdpvr_s_ctrl()
920 ret = hdpvr_config_call(dev, CTRL_HUE, ctrl->val); in hdpvr_s_ctrl()
923 dev->options.hue = ctrl->val; in hdpvr_s_ctrl()
926 ret = hdpvr_config_call(dev, CTRL_SHARPNESS, ctrl->val); in hdpvr_s_ctrl()
929 dev->options.sharpness = ctrl->val; in hdpvr_s_ctrl()
932 if (dev->flags & HDPVR_FLAG_AC3_CAP) { in hdpvr_s_ctrl()
933 opt->audio_codec = ctrl->val; in hdpvr_s_ctrl()
934 return hdpvr_set_audio(dev, opt->audio_input + 1, in hdpvr_s_ctrl()
935 opt->audio_codec); in hdpvr_s_ctrl()
941 /* if (ctrl->value == 0 && !(opt->gop_mode & 0x2)) { */ in hdpvr_s_ctrl()
942 /* opt->gop_mode |= 0x2; */ in hdpvr_s_ctrl()
944 /* opt->gop_mode); */ in hdpvr_s_ctrl()
946 /* if (ctrl->value == 128 && opt->gop_mode & 0x2) { */ in hdpvr_s_ctrl()
947 /* opt->gop_mode &= ~0x2; */ in hdpvr_s_ctrl()
949 /* opt->gop_mode); */ in hdpvr_s_ctrl()
953 uint peak_bitrate = dev->video_bitrate_peak->val / 100000; in hdpvr_s_ctrl()
954 uint bitrate = dev->video_bitrate->val / 100000; in hdpvr_s_ctrl()
956 if (ctrl->is_new) { in hdpvr_s_ctrl()
957 if (ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) in hdpvr_s_ctrl()
958 opt->bitrate_mode = HDPVR_CONSTANT; in hdpvr_s_ctrl()
960 opt->bitrate_mode = HDPVR_VARIABLE_AVERAGE; in hdpvr_s_ctrl()
962 opt->bitrate_mode); in hdpvr_s_ctrl()
963 v4l2_ctrl_activate(dev->video_bitrate_peak, in hdpvr_s_ctrl()
964 ctrl->val != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR); in hdpvr_s_ctrl()
967 if (dev->video_bitrate_peak->is_new || in hdpvr_s_ctrl()
968 dev->video_bitrate->is_new) { in hdpvr_s_ctrl()
969 opt->bitrate = bitrate; in hdpvr_s_ctrl()
970 opt->peak_bitrate = peak_bitrate; in hdpvr_s_ctrl()
986 if (f->index != 0) in vidioc_enum_fmt_vid_cap()
987 return -EINVAL; in vidioc_enum_fmt_vid_cap()
989 f->pixelformat = V4L2_PIX_FMT_MPEG; in vidioc_enum_fmt_vid_cap()
1011 if (fh->legacy_mode) { in vidioc_g_fmt_vid_cap()
1018 return -EFAULT; in vidioc_g_fmt_vid_cap()
1019 f->fmt.pix.width = vid_info.width; in vidioc_g_fmt_vid_cap()
1020 f->fmt.pix.height = vid_info.height; in vidioc_g_fmt_vid_cap()
1022 f->fmt.pix.width = dev->width; in vidioc_g_fmt_vid_cap()
1023 f->fmt.pix.height = dev->height; in vidioc_g_fmt_vid_cap()
1025 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; in vidioc_g_fmt_vid_cap()
1026 f->fmt.pix.sizeimage = dev->bulk_in_size; in vidioc_g_fmt_vid_cap()
1027 f->fmt.pix.bytesperline = 0; in vidioc_g_fmt_vid_cap()
1028 if (f->fmt.pix.width == 720) { in vidioc_g_fmt_vid_cap()
1029 /* SDTV formats */ in vidioc_g_fmt_vid_cap()
1030 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_g_fmt_vid_cap()
1031 f->fmt.pix.field = V4L2_FIELD_INTERLACED; in vidioc_g_fmt_vid_cap()
1034 f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; in vidioc_g_fmt_vid_cap()
1035 f->fmt.pix.field = V4L2_FIELD_NONE; in vidioc_g_fmt_vid_cap()
1046 mutex_lock(&dev->io_mutex); in vidioc_encoder_cmd()
1047 a->flags = 0; in vidioc_encoder_cmd()
1049 switch (a->cmd) { in vidioc_encoder_cmd()
1051 if (dev->owner && filp->private_data != dev->owner) { in vidioc_encoder_cmd()
1052 res = -EBUSY; in vidioc_encoder_cmd()
1055 if (dev->status == STATUS_STREAMING) in vidioc_encoder_cmd()
1059 dev->owner = filp->private_data; in vidioc_encoder_cmd()
1061 dev->status = STATUS_IDLE; in vidioc_encoder_cmd()
1064 if (dev->owner && filp->private_data != dev->owner) { in vidioc_encoder_cmd()
1065 res = -EBUSY; in vidioc_encoder_cmd()
1068 if (dev->status == STATUS_IDLE) in vidioc_encoder_cmd()
1072 dev->owner = NULL; in vidioc_encoder_cmd()
1075 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in vidioc_encoder_cmd()
1076 "Unsupported encoder cmd %d\n", a->cmd); in vidioc_encoder_cmd()
1077 res = -EINVAL; in vidioc_encoder_cmd()
1081 mutex_unlock(&dev->io_mutex); in vidioc_encoder_cmd()
1088 a->flags = 0; in vidioc_try_encoder_cmd()
1089 switch (a->cmd) { in vidioc_try_encoder_cmd()
1094 return -EINVAL; in vidioc_try_encoder_cmd()
1130 flush_work(&dev->worker); in hdpvr_device_release()
1132 v4l2_device_unregister(&dev->v4l2_dev); in hdpvr_device_release()
1133 v4l2_ctrl_handler_free(&dev->hdl); in hdpvr_device_release()
1137 mutex_lock(&dev->i2c_mutex); in hdpvr_device_release()
1138 i2c_del_adapter(&dev->i2c_adapter); in hdpvr_device_release()
1139 mutex_unlock(&dev->i2c_mutex); in hdpvr_device_release()
1142 kfree(dev->usbc_buf); in hdpvr_device_release()
1163 struct v4l2_ctrl_handler *hdl = &dev->hdl; in hdpvr_register_videodev()
1164 bool ac3 = dev->flags & HDPVR_FLAG_AC3_CAP; in hdpvr_register_videodev()
1167 // initialize dev->worker in hdpvr_register_videodev()
1168 INIT_WORK(&dev->worker, hdpvr_transmit_buffers); in hdpvr_register_videodev()
1170 dev->cur_std = V4L2_STD_525_60; in hdpvr_register_videodev()
1171 dev->width = 720; in hdpvr_register_videodev()
1172 dev->height = 480; in hdpvr_register_videodev()
1173 dev->cur_dv_timings = hdpvr_dv_timings[HDPVR_DEF_DV_TIMINGS_IDX]; in hdpvr_register_videodev()
1175 if (dev->fw_ver > 0x15) { in hdpvr_register_videodev()
1206 0x7, ac3 ? dev->options.audio_codec : V4L2_MPEG_AUDIO_ENCODING_AAC); in hdpvr_register_videodev()
1212 dev->video_mode = v4l2_ctrl_new_std_menu(hdl, &hdpvr_ctrl_ops, in hdpvr_register_videodev()
1217 dev->video_bitrate = v4l2_ctrl_new_std(hdl, &hdpvr_ctrl_ops, in hdpvr_register_videodev()
1220 dev->video_bitrate_peak = v4l2_ctrl_new_std(hdl, &hdpvr_ctrl_ops, in hdpvr_register_videodev()
1223 dev->v4l2_dev.ctrl_handler = hdl; in hdpvr_register_videodev()
1224 if (hdl->error) { in hdpvr_register_videodev()
1225 res = hdl->error; in hdpvr_register_videodev()
1226 v4l2_err(&dev->v4l2_dev, "Could not register controls\n"); in hdpvr_register_videodev()
1229 v4l2_ctrl_cluster(3, &dev->video_mode); in hdpvr_register_videodev()
1232 v4l2_err(&dev->v4l2_dev, "Could not setup controls\n"); in hdpvr_register_videodev()
1237 dev->video_dev = hdpvr_video_template; in hdpvr_register_videodev()
1238 strscpy(dev->video_dev.name, "Hauppauge HD PVR", in hdpvr_register_videodev()
1239 sizeof(dev->video_dev.name)); in hdpvr_register_videodev()
1240 dev->video_dev.v4l2_dev = &dev->v4l2_dev; in hdpvr_register_videodev()
1241 video_set_drvdata(&dev->video_dev, dev); in hdpvr_register_videodev()
1243 res = video_register_device(&dev->video_dev, VFL_TYPE_VIDEO, devnum); in hdpvr_register_videodev()
1245 v4l2_err(&dev->v4l2_dev, "video_device registration failed\n"); in hdpvr_register_videodev()