Lines Matching refs:dev

35 		v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,	\
38 list_size(&dev->free_buff_list), \
39 list_size(&dev->rec_buff_list)); }
77 struct hdpvr_device *dev = buf->dev; in hdpvr_read_bulk_callback() local
81 wake_up_interruptible(&dev->wait_data); in hdpvr_read_bulk_callback()
88 int hdpvr_cancel_queue(struct hdpvr_device *dev) in hdpvr_cancel_queue() argument
92 list_for_each_entry(buf, &dev->rec_buff_list, buff_list) { in hdpvr_cancel_queue()
97 list_splice_init(&dev->rec_buff_list, dev->free_buff_list.prev); in hdpvr_cancel_queue()
113 usb_free_coherent(urb->dev, urb->transfer_buffer_length, in hdpvr_free_queue()
126 int hdpvr_free_buffers(struct hdpvr_device *dev) in hdpvr_free_buffers() argument
128 hdpvr_cancel_queue(dev); in hdpvr_free_buffers()
130 hdpvr_free_queue(&dev->free_buff_list); in hdpvr_free_buffers()
131 hdpvr_free_queue(&dev->rec_buff_list); in hdpvr_free_buffers()
137 int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count) in hdpvr_alloc_buffers() argument
145 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_alloc_buffers()
152 v4l2_err(&dev->v4l2_dev, "cannot allocate buffer\n"); in hdpvr_alloc_buffers()
155 buf->dev = dev; in hdpvr_alloc_buffers()
159 v4l2_err(&dev->v4l2_dev, "cannot allocate urb\n"); in hdpvr_alloc_buffers()
164 mem = usb_alloc_coherent(dev->udev, dev->bulk_in_size, GFP_KERNEL, in hdpvr_alloc_buffers()
167 v4l2_err(&dev->v4l2_dev, in hdpvr_alloc_buffers()
172 usb_fill_bulk_urb(buf->urb, dev->udev, in hdpvr_alloc_buffers()
173 usb_rcvbulkpipe(dev->udev, in hdpvr_alloc_buffers()
174 dev->bulk_in_endpointAddr), in hdpvr_alloc_buffers()
175 mem, dev->bulk_in_size, in hdpvr_alloc_buffers()
180 list_add_tail(&buf->buff_list, &dev->free_buff_list); in hdpvr_alloc_buffers()
188 hdpvr_free_buffers(dev); in hdpvr_alloc_buffers()
192 static int hdpvr_submit_buffers(struct hdpvr_device *dev) in hdpvr_submit_buffers() argument
198 mutex_lock(&dev->io_mutex); in hdpvr_submit_buffers()
200 while (dev->status == STATUS_STREAMING && in hdpvr_submit_buffers()
201 !list_empty(&dev->free_buff_list)) { in hdpvr_submit_buffers()
203 buf = list_entry(dev->free_buff_list.next, struct hdpvr_buffer, in hdpvr_submit_buffers()
206 v4l2_err(&dev->v4l2_dev, in hdpvr_submit_buffers()
217 v4l2_err(&dev->v4l2_dev, in hdpvr_submit_buffers()
225 list_move_tail(&buf->buff_list, &dev->rec_buff_list); in hdpvr_submit_buffers()
229 mutex_unlock(&dev->io_mutex); in hdpvr_submit_buffers()
233 static struct hdpvr_buffer *hdpvr_get_next_buffer(struct hdpvr_device *dev) in hdpvr_get_next_buffer() argument
237 mutex_lock(&dev->io_mutex); in hdpvr_get_next_buffer()
239 if (list_empty(&dev->rec_buff_list)) { in hdpvr_get_next_buffer()
240 mutex_unlock(&dev->io_mutex); in hdpvr_get_next_buffer()
244 buf = list_entry(dev->rec_buff_list.next, struct hdpvr_buffer, in hdpvr_get_next_buffer()
246 mutex_unlock(&dev->io_mutex); in hdpvr_get_next_buffer()
253 struct hdpvr_device *dev = container_of(work, struct hdpvr_device, in hdpvr_transmit_buffers() local
256 while (dev->status == STATUS_STREAMING) { in hdpvr_transmit_buffers()
258 if (hdpvr_submit_buffers(dev)) { in hdpvr_transmit_buffers()
259 v4l2_err(&dev->v4l2_dev, "couldn't submit buffers\n"); in hdpvr_transmit_buffers()
262 if (wait_event_interruptible(dev->wait_buffer, in hdpvr_transmit_buffers()
263 !list_empty(&dev->free_buff_list) || in hdpvr_transmit_buffers()
264 dev->status != STATUS_STREAMING)) in hdpvr_transmit_buffers()
268 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_transmit_buffers()
272 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_transmit_buffers()
274 dev->status = STATUS_ERROR; in hdpvr_transmit_buffers()
278 static int hdpvr_start_streaming(struct hdpvr_device *dev) in hdpvr_start_streaming() argument
283 if (dev->status == STATUS_STREAMING) in hdpvr_start_streaming()
285 if (dev->status != STATUS_IDLE) in hdpvr_start_streaming()
288 ret = get_video_info(dev, &vidinf); in hdpvr_start_streaming()
294 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_start_streaming()
295 "no video signal at input %d\n", dev->options.video_input); in hdpvr_start_streaming()
299 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_start_streaming()
304 ret = usb_control_msg(dev->udev, in hdpvr_start_streaming()
305 usb_sndctrlpipe(dev->udev, 0), in hdpvr_start_streaming()
307 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_start_streaming()
312 ret = hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); in hdpvr_start_streaming()
316 dev->status = STATUS_STREAMING; in hdpvr_start_streaming()
318 INIT_WORK(&dev->worker, hdpvr_transmit_buffers); in hdpvr_start_streaming()
319 queue_work(dev->workqueue, &dev->worker); in hdpvr_start_streaming()
321 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_start_streaming()
329 static int hdpvr_stop_streaming(struct hdpvr_device *dev) in hdpvr_stop_streaming() argument
335 if (dev->status == STATUS_IDLE) in hdpvr_stop_streaming()
337 else if (dev->status != STATUS_STREAMING) in hdpvr_stop_streaming()
340 buf = kmalloc(dev->bulk_in_size, GFP_KERNEL); in hdpvr_stop_streaming()
342 v4l2_err(&dev->v4l2_dev, "failed to allocate temporary buffer " in hdpvr_stop_streaming()
346 dev->status = STATUS_SHUTTING_DOWN; in hdpvr_stop_streaming()
347 hdpvr_config_call(dev, CTRL_STOP_STREAMING_VALUE, 0x00); in hdpvr_stop_streaming()
348 mutex_unlock(&dev->io_mutex); in hdpvr_stop_streaming()
350 wake_up_interruptible(&dev->wait_buffer); in hdpvr_stop_streaming()
353 flush_workqueue(dev->workqueue); in hdpvr_stop_streaming()
355 mutex_lock(&dev->io_mutex); in hdpvr_stop_streaming()
357 hdpvr_cancel_queue(dev); in hdpvr_stop_streaming()
361 !usb_bulk_msg(dev->udev, in hdpvr_stop_streaming()
362 usb_rcvbulkpipe(dev->udev, in hdpvr_stop_streaming()
363 dev->bulk_in_endpointAddr), in hdpvr_stop_streaming()
364 buf, dev->bulk_in_size, &actual_length, in hdpvr_stop_streaming()
366 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_stop_streaming()
370 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_stop_streaming()
374 dev->status = STATUS_IDLE; in hdpvr_stop_streaming()
400 struct hdpvr_device *dev = video_drvdata(file); in hdpvr_release() local
402 mutex_lock(&dev->io_mutex); in hdpvr_release()
403 if (file->private_data == dev->owner) { in hdpvr_release()
404 hdpvr_stop_streaming(dev); in hdpvr_release()
405 dev->owner = NULL; in hdpvr_release()
407 mutex_unlock(&dev->io_mutex); in hdpvr_release()
419 struct hdpvr_device *dev = video_drvdata(file); in hdpvr_read() local
428 mutex_lock(&dev->io_mutex); in hdpvr_read()
429 if (dev->status == STATUS_IDLE) { in hdpvr_read()
430 if (hdpvr_start_streaming(dev)) { in hdpvr_read()
431 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_read()
435 dev->status = STATUS_IDLE; in hdpvr_read()
436 mutex_unlock(&dev->io_mutex); in hdpvr_read()
439 dev->owner = file->private_data; in hdpvr_read()
442 mutex_unlock(&dev->io_mutex); in hdpvr_read()
446 if (wait_event_interruptible(dev->wait_data, in hdpvr_read()
447 hdpvr_get_next_buffer(dev))) in hdpvr_read()
451 buf = hdpvr_get_next_buffer(dev); in hdpvr_read()
456 dev->status != STATUS_DISCONNECTED) { in hdpvr_read()
464 if (wait_event_interruptible(dev->wait_data, in hdpvr_read()
481 v4l2_err(&dev->v4l2_dev, "read: copy_to_user failed\n"); in hdpvr_read()
494 mutex_lock(&dev->io_mutex); in hdpvr_read()
498 list_move_tail(&buf->buff_list, &dev->free_buff_list); in hdpvr_read()
502 mutex_unlock(&dev->io_mutex); in hdpvr_read()
504 wake_up_interruptible(&dev->wait_buffer); in hdpvr_read()
506 buf = hdpvr_get_next_buffer(dev); in hdpvr_read()
519 struct hdpvr_device *dev = video_drvdata(filp); in hdpvr_poll() local
525 mutex_lock(&dev->io_mutex); in hdpvr_poll()
527 if (dev->status == STATUS_IDLE) { in hdpvr_poll()
528 if (hdpvr_start_streaming(dev)) { in hdpvr_poll()
529 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, in hdpvr_poll()
531 dev->status = STATUS_IDLE; in hdpvr_poll()
533 dev->owner = filp->private_data; in hdpvr_poll()
538 mutex_unlock(&dev->io_mutex); in hdpvr_poll()
540 buf = hdpvr_get_next_buffer(dev); in hdpvr_poll()
543 poll_wait(filp, &dev->wait_data, wait); in hdpvr_poll()
544 buf = hdpvr_get_next_buffer(dev); in hdpvr_poll()
570 struct hdpvr_device *dev = video_drvdata(file); in vidioc_querycap() local
574 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); in vidioc_querycap()
584 struct hdpvr_device *dev = video_drvdata(file); in vidioc_s_std() local
588 if (!fh->legacy_mode && dev->options.video_input == HDPVR_COMPONENT) in vidioc_s_std()
590 if (dev->status != STATUS_IDLE) in vidioc_s_std()
594 dev->cur_std = std; in vidioc_s_std()
595 dev->width = 720; in vidioc_s_std()
596 dev->height = std_type ? 576 : 480; in vidioc_s_std()
598 return hdpvr_config_call(dev, CTRL_VIDEO_STD_TYPE, std_type); in vidioc_s_std()
604 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_std() local
607 if (!fh->legacy_mode && dev->options.video_input == HDPVR_COMPONENT) in vidioc_g_std()
609 *std = dev->cur_std; in vidioc_g_std()
615 struct hdpvr_device *dev = video_drvdata(file); in vidioc_querystd() local
621 if (dev->options.video_input == HDPVR_COMPONENT) in vidioc_querystd()
623 ret = get_video_info(dev, &vid_info); in vidioc_querystd()
635 struct hdpvr_device *dev = video_drvdata(file); in vidioc_s_dv_timings() local
640 if (dev->options.video_input) in vidioc_s_dv_timings()
642 if (dev->status != STATUS_IDLE) in vidioc_s_dv_timings()
649 dev->cur_dv_timings = hdpvr_dv_timings[i]; in vidioc_s_dv_timings()
650 dev->width = hdpvr_dv_timings[i].bt.width; in vidioc_s_dv_timings()
651 dev->height = hdpvr_dv_timings[i].bt.height; in vidioc_s_dv_timings()
658 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_dv_timings() local
662 if (dev->options.video_input) in vidioc_g_dv_timings()
664 *timings = dev->cur_dv_timings; in vidioc_g_dv_timings()
671 struct hdpvr_device *dev = video_drvdata(file); in vidioc_query_dv_timings() local
679 if (dev->options.video_input) in vidioc_query_dv_timings()
681 ret = get_video_info(dev, &vid_info); in vidioc_query_dv_timings()
713 struct hdpvr_device *dev = video_drvdata(file); in vidioc_enum_dv_timings() local
718 if (dev->options.video_input) in vidioc_enum_dv_timings()
729 struct hdpvr_device *dev = video_drvdata(file); in vidioc_dv_timings_cap() local
733 if (dev->options.video_input) in vidioc_dv_timings_cap()
777 struct hdpvr_device *dev = video_drvdata(file); in vidioc_s_input() local
783 if (dev->status != STATUS_IDLE) in vidioc_s_input()
786 retval = hdpvr_config_call(dev, CTRL_VIDEO_INPUT_VALUE, index+1); in vidioc_s_input()
788 dev->options.video_input = index; in vidioc_s_input()
811 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_input() local
813 *index = dev->options.video_input; in vidioc_g_input()
844 struct hdpvr_device *dev = video_drvdata(file); in vidioc_s_audio() local
850 if (dev->status != STATUS_IDLE) in vidioc_s_audio()
853 retval = hdpvr_set_audio(dev, audio->index+1, dev->options.audio_codec); in vidioc_s_audio()
855 dev->options.audio_input = audio->index; in vidioc_s_audio()
863 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_audio() local
865 audio->index = dev->options.audio_input; in vidioc_g_audio()
874 struct hdpvr_device *dev = in hdpvr_try_ctrl() local
880 dev->video_bitrate->val >= dev->video_bitrate_peak->val) in hdpvr_try_ctrl()
881 dev->video_bitrate_peak->val = in hdpvr_try_ctrl()
882 dev->video_bitrate->val + 100000; in hdpvr_try_ctrl()
890 struct hdpvr_device *dev = in hdpvr_s_ctrl() local
892 struct hdpvr_options *opt = &dev->options; in hdpvr_s_ctrl()
897 ret = hdpvr_config_call(dev, CTRL_BRIGHTNESS, ctrl->val); in hdpvr_s_ctrl()
900 dev->options.brightness = ctrl->val; in hdpvr_s_ctrl()
903 ret = hdpvr_config_call(dev, CTRL_CONTRAST, ctrl->val); in hdpvr_s_ctrl()
906 dev->options.contrast = ctrl->val; in hdpvr_s_ctrl()
909 ret = hdpvr_config_call(dev, CTRL_SATURATION, ctrl->val); in hdpvr_s_ctrl()
912 dev->options.saturation = ctrl->val; in hdpvr_s_ctrl()
915 ret = hdpvr_config_call(dev, CTRL_HUE, ctrl->val); in hdpvr_s_ctrl()
918 dev->options.hue = ctrl->val; in hdpvr_s_ctrl()
921 ret = hdpvr_config_call(dev, CTRL_SHARPNESS, ctrl->val); in hdpvr_s_ctrl()
924 dev->options.sharpness = ctrl->val; in hdpvr_s_ctrl()
927 if (dev->flags & HDPVR_FLAG_AC3_CAP) { in hdpvr_s_ctrl()
929 return hdpvr_set_audio(dev, opt->audio_input + 1, in hdpvr_s_ctrl()
948 uint peak_bitrate = dev->video_bitrate_peak->val / 100000; in hdpvr_s_ctrl()
949 uint bitrate = dev->video_bitrate->val / 100000; in hdpvr_s_ctrl()
956 hdpvr_config_call(dev, CTRL_BITRATE_MODE_VALUE, in hdpvr_s_ctrl()
958 v4l2_ctrl_activate(dev->video_bitrate_peak, in hdpvr_s_ctrl()
962 if (dev->video_bitrate_peak->is_new || in hdpvr_s_ctrl()
963 dev->video_bitrate->is_new) { in hdpvr_s_ctrl()
966 hdpvr_set_bitrate(dev); in hdpvr_s_ctrl()
994 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
1011 ret = get_video_info(dev, &vid_info); in vidioc_g_fmt_vid_cap()
1019 f->fmt.pix.width = dev->width; in vidioc_g_fmt_vid_cap()
1020 f->fmt.pix.height = dev->height; in vidioc_g_fmt_vid_cap()
1023 f->fmt.pix.sizeimage = dev->bulk_in_size; in vidioc_g_fmt_vid_cap()
1040 struct hdpvr_device *dev = video_drvdata(filp); in vidioc_encoder_cmd() local
1043 mutex_lock(&dev->io_mutex); in vidioc_encoder_cmd()
1048 if (dev->owner && filp->private_data != dev->owner) { in vidioc_encoder_cmd()
1052 if (dev->status == STATUS_STREAMING) in vidioc_encoder_cmd()
1054 res = hdpvr_start_streaming(dev); in vidioc_encoder_cmd()
1056 dev->owner = filp->private_data; in vidioc_encoder_cmd()
1058 dev->status = STATUS_IDLE; in vidioc_encoder_cmd()
1061 if (dev->owner && filp->private_data != dev->owner) { in vidioc_encoder_cmd()
1065 if (dev->status == STATUS_IDLE) in vidioc_encoder_cmd()
1067 res = hdpvr_stop_streaming(dev); in vidioc_encoder_cmd()
1069 dev->owner = NULL; in vidioc_encoder_cmd()
1072 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in vidioc_encoder_cmd()
1078 mutex_unlock(&dev->io_mutex); in vidioc_encoder_cmd()
1124 struct hdpvr_device *dev = video_get_drvdata(vdev); in hdpvr_device_release() local
1126 hdpvr_delete(dev); in hdpvr_device_release()
1127 mutex_lock(&dev->io_mutex); in hdpvr_device_release()
1128 destroy_workqueue(dev->workqueue); in hdpvr_device_release()
1129 mutex_unlock(&dev->io_mutex); in hdpvr_device_release()
1131 v4l2_device_unregister(&dev->v4l2_dev); in hdpvr_device_release()
1132 v4l2_ctrl_handler_free(&dev->hdl); in hdpvr_device_release()
1136 mutex_lock(&dev->i2c_mutex); in hdpvr_device_release()
1137 i2c_del_adapter(&dev->i2c_adapter); in hdpvr_device_release()
1138 mutex_unlock(&dev->i2c_mutex); in hdpvr_device_release()
1141 kfree(dev->usbc_buf); in hdpvr_device_release()
1142 kfree(dev); in hdpvr_device_release()
1157 int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent, in hdpvr_register_videodev() argument
1160 struct v4l2_ctrl_handler *hdl = &dev->hdl; in hdpvr_register_videodev()
1161 bool ac3 = dev->flags & HDPVR_FLAG_AC3_CAP; in hdpvr_register_videodev()
1164 dev->cur_std = V4L2_STD_525_60; in hdpvr_register_videodev()
1165 dev->width = 720; in hdpvr_register_videodev()
1166 dev->height = 480; in hdpvr_register_videodev()
1167 dev->cur_dv_timings = hdpvr_dv_timings[HDPVR_DEF_DV_TIMINGS_IDX]; in hdpvr_register_videodev()
1169 if (dev->fw_ver > 0x15) { in hdpvr_register_videodev()
1200 0x7, ac3 ? dev->options.audio_codec : V4L2_MPEG_AUDIO_ENCODING_AAC); in hdpvr_register_videodev()
1206 dev->video_mode = v4l2_ctrl_new_std_menu(hdl, &hdpvr_ctrl_ops, in hdpvr_register_videodev()
1211 dev->video_bitrate = v4l2_ctrl_new_std(hdl, &hdpvr_ctrl_ops, in hdpvr_register_videodev()
1214 dev->video_bitrate_peak = v4l2_ctrl_new_std(hdl, &hdpvr_ctrl_ops, in hdpvr_register_videodev()
1217 dev->v4l2_dev.ctrl_handler = hdl; in hdpvr_register_videodev()
1220 v4l2_err(&dev->v4l2_dev, "Could not register controls\n"); in hdpvr_register_videodev()
1223 v4l2_ctrl_cluster(3, &dev->video_mode); in hdpvr_register_videodev()
1226 v4l2_err(&dev->v4l2_dev, "Could not setup controls\n"); in hdpvr_register_videodev()
1231 dev->video_dev = hdpvr_video_template; in hdpvr_register_videodev()
1232 strcpy(dev->video_dev.name, "Hauppauge HD PVR"); in hdpvr_register_videodev()
1233 dev->video_dev.v4l2_dev = &dev->v4l2_dev; in hdpvr_register_videodev()
1234 video_set_drvdata(&dev->video_dev, dev); in hdpvr_register_videodev()
1236 res = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, devnum); in hdpvr_register_videodev()
1238 v4l2_err(&dev->v4l2_dev, "video_device registration failed\n"); in hdpvr_register_videodev()