Lines Matching refs:dev

30 		v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,	\
33 list_size(&dev->free_buff_list), \
34 list_size(&dev->rec_buff_list)); }
72 struct hdpvr_device *dev = buf->dev; in hdpvr_read_bulk_callback() local
76 wake_up_interruptible(&dev->wait_data); in hdpvr_read_bulk_callback()
83 int hdpvr_cancel_queue(struct hdpvr_device *dev) in hdpvr_cancel_queue() argument
87 list_for_each_entry(buf, &dev->rec_buff_list, buff_list) { in hdpvr_cancel_queue()
92 list_splice_init(&dev->rec_buff_list, dev->free_buff_list.prev); in hdpvr_cancel_queue()
108 usb_free_coherent(urb->dev, urb->transfer_buffer_length, in hdpvr_free_queue()
121 int hdpvr_free_buffers(struct hdpvr_device *dev) in hdpvr_free_buffers() argument
123 hdpvr_cancel_queue(dev); in hdpvr_free_buffers()
125 hdpvr_free_queue(&dev->free_buff_list); in hdpvr_free_buffers()
126 hdpvr_free_queue(&dev->rec_buff_list); in hdpvr_free_buffers()
132 int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count) in hdpvr_alloc_buffers() argument
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()
157 mem = usb_alloc_coherent(dev->udev, dev->bulk_in_size, GFP_KERNEL, 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()
173 list_add_tail(&buf->buff_list, &dev->free_buff_list); in hdpvr_alloc_buffers()
181 hdpvr_free_buffers(dev); in hdpvr_alloc_buffers()
185 static int hdpvr_submit_buffers(struct hdpvr_device *dev) in hdpvr_submit_buffers() argument
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()
199 v4l2_err(&dev->v4l2_dev, in hdpvr_submit_buffers()
210 v4l2_err(&dev->v4l2_dev, 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()
226 static struct hdpvr_buffer *hdpvr_get_next_buffer(struct hdpvr_device *dev) in hdpvr_get_next_buffer() argument
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()
246 struct hdpvr_device *dev = container_of(work, struct hdpvr_device, in hdpvr_transmit_buffers() local
249 while (dev->status == STATUS_STREAMING) { in hdpvr_transmit_buffers()
251 if (hdpvr_submit_buffers(dev)) { 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()
271 static int hdpvr_start_streaming(struct hdpvr_device *dev) in hdpvr_start_streaming() argument
276 if (dev->status == STATUS_STREAMING) in hdpvr_start_streaming()
278 if (dev->status != STATUS_IDLE) in hdpvr_start_streaming()
281 ret = get_video_info(dev, &vidinf); 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()
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()
305 ret = hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); 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()
321 static int hdpvr_stop_streaming(struct hdpvr_device *dev) in hdpvr_stop_streaming() argument
327 if (dev->status == STATUS_IDLE) in hdpvr_stop_streaming()
329 else if (dev->status != STATUS_STREAMING) 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()
337 hdpvr_config_call(dev, CTRL_STOP_STREAMING_VALUE, 0x00); 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()
347 hdpvr_cancel_queue(dev); 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()
364 dev->status = STATUS_IDLE; in hdpvr_stop_streaming()
390 struct hdpvr_device *dev = video_drvdata(file); in hdpvr_release() local
392 mutex_lock(&dev->io_mutex); in hdpvr_release()
393 if (file->private_data == dev->owner) { in hdpvr_release()
394 hdpvr_stop_streaming(dev); in hdpvr_release()
395 dev->owner = NULL; in hdpvr_release()
397 mutex_unlock(&dev->io_mutex); in hdpvr_release()
409 struct hdpvr_device *dev = video_drvdata(file); in hdpvr_read() local
418 mutex_lock(&dev->io_mutex); in hdpvr_read()
419 if (dev->status == STATUS_IDLE) { in hdpvr_read()
420 if (hdpvr_start_streaming(dev)) { in hdpvr_read()
421 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 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()
436 if (wait_event_interruptible(dev->wait_data, in hdpvr_read()
437 !list_empty_careful(&dev->rec_buff_list))) in hdpvr_read()
441 buf = hdpvr_get_next_buffer(dev); in hdpvr_read()
446 dev->status != STATUS_DISCONNECTED) { in hdpvr_read()
455 err = wait_event_interruptible_timeout(dev->wait_data, in hdpvr_read()
463 v4l2_info(&dev->v4l2_dev, in hdpvr_read()
465 mutex_lock(&dev->io_mutex); in hdpvr_read()
466 hdpvr_stop_streaming(dev); in hdpvr_read()
467 mutex_unlock(&dev->io_mutex); in hdpvr_read()
474 err = hdpvr_start_streaming(dev); in hdpvr_read()
492 v4l2_err(&dev->v4l2_dev, "read: copy_to_user failed\n"); in hdpvr_read()
505 mutex_lock(&dev->io_mutex); 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()
517 buf = hdpvr_get_next_buffer(dev); in hdpvr_read()
530 struct hdpvr_device *dev = video_drvdata(filp); in hdpvr_poll() local
536 mutex_lock(&dev->io_mutex); in hdpvr_poll()
538 if (dev->status == STATUS_IDLE) { in hdpvr_poll()
539 if (hdpvr_start_streaming(dev)) { 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()
551 buf = hdpvr_get_next_buffer(dev); in hdpvr_poll()
554 poll_wait(filp, &dev->wait_data, wait); in hdpvr_poll()
555 buf = hdpvr_get_next_buffer(dev); in hdpvr_poll()
581 struct hdpvr_device *dev = video_drvdata(file); in vidioc_querycap() local
585 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); in vidioc_querycap()
592 struct hdpvr_device *dev = video_drvdata(file); in vidioc_s_std() local
596 if (!fh->legacy_mode && dev->options.video_input == HDPVR_COMPONENT) in vidioc_s_std()
598 if (dev->status != STATUS_IDLE) 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()
606 return hdpvr_config_call(dev, CTRL_VIDEO_STD_TYPE, std_type); in vidioc_s_std()
612 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_std() local
615 if (!fh->legacy_mode && dev->options.video_input == HDPVR_COMPONENT) in vidioc_g_std()
617 *std = dev->cur_std; in vidioc_g_std()
623 struct hdpvr_device *dev = video_drvdata(file); in vidioc_querystd() local
629 if (dev->options.video_input == HDPVR_COMPONENT) in vidioc_querystd()
631 ret = get_video_info(dev, &vid_info); in vidioc_querystd()
643 struct hdpvr_device *dev = video_drvdata(file); in vidioc_s_dv_timings() local
648 if (dev->options.video_input) in vidioc_s_dv_timings()
650 if (dev->status != STATUS_IDLE) 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()
666 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_dv_timings() local
670 if (dev->options.video_input) in vidioc_g_dv_timings()
672 *timings = dev->cur_dv_timings; in vidioc_g_dv_timings()
679 struct hdpvr_device *dev = video_drvdata(file); in vidioc_query_dv_timings() local
687 if (dev->options.video_input) in vidioc_query_dv_timings()
689 ret = get_video_info(dev, &vid_info); in vidioc_query_dv_timings()
721 struct hdpvr_device *dev = video_drvdata(file); in vidioc_enum_dv_timings() local
726 if (dev->options.video_input) in vidioc_enum_dv_timings()
737 struct hdpvr_device *dev = video_drvdata(file); in vidioc_dv_timings_cap() local
741 if (dev->options.video_input) in vidioc_dv_timings_cap()
784 struct hdpvr_device *dev = video_drvdata(file); in vidioc_s_input() local
790 if (dev->status != STATUS_IDLE) in vidioc_s_input()
793 retval = hdpvr_config_call(dev, CTRL_VIDEO_INPUT_VALUE, index+1); in vidioc_s_input()
795 dev->options.video_input = index; in vidioc_s_input()
818 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_input() local
820 *index = dev->options.video_input; in vidioc_g_input()
850 struct hdpvr_device *dev = video_drvdata(file); in vidioc_s_audio() local
856 if (dev->status != STATUS_IDLE) 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()
869 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_audio() local
871 audio->index = dev->options.audio_input; in vidioc_g_audio()
879 struct hdpvr_device *dev = in hdpvr_try_ctrl() local
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()
895 struct hdpvr_device *dev = in hdpvr_s_ctrl() local
897 struct hdpvr_options *opt = &dev->options; 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()
934 return hdpvr_set_audio(dev, opt->audio_input + 1, 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()
961 hdpvr_config_call(dev, CTRL_BITRATE_MODE_VALUE, in hdpvr_s_ctrl()
963 v4l2_ctrl_activate(dev->video_bitrate_peak, 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()
971 hdpvr_set_bitrate(dev); in hdpvr_s_ctrl()
997 struct hdpvr_device *dev = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
1014 ret = get_video_info(dev, &vid_info); 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()
1026 f->fmt.pix.sizeimage = dev->bulk_in_size; in vidioc_g_fmt_vid_cap()
1043 struct hdpvr_device *dev = video_drvdata(filp); in vidioc_encoder_cmd() local
1046 mutex_lock(&dev->io_mutex); in vidioc_encoder_cmd()
1051 if (dev->owner && filp->private_data != dev->owner) { in vidioc_encoder_cmd()
1055 if (dev->status == STATUS_STREAMING) in vidioc_encoder_cmd()
1057 res = hdpvr_start_streaming(dev); 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()
1068 if (dev->status == STATUS_IDLE) in vidioc_encoder_cmd()
1070 res = hdpvr_stop_streaming(dev); 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()
1081 mutex_unlock(&dev->io_mutex); in vidioc_encoder_cmd()
1127 struct hdpvr_device *dev = video_get_drvdata(vdev); in hdpvr_device_release() local
1129 hdpvr_delete(dev); in hdpvr_device_release()
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()
1143 kfree(dev); in hdpvr_device_release()
1160 int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent, in hdpvr_register_videodev() argument
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()
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()
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()