Lines Matching full:go
80 static void get_resolution(struct go7007 *go, int *width, int *height) in get_resolution() argument
82 switch (go->standard) { in get_resolution()
93 *width = go->board_info->sensor_width; in get_resolution()
94 *height = go->board_info->sensor_height; in get_resolution()
99 static void set_formatting(struct go7007 *go) in set_formatting() argument
101 if (go->format == V4L2_PIX_FMT_MJPEG) { in set_formatting()
102 go->pali = 0; in set_formatting()
103 go->aspect_ratio = GO7007_RATIO_1_1; in set_formatting()
104 go->gop_size = 0; in set_formatting()
105 go->ipb = 0; in set_formatting()
106 go->closed_gop = 0; in set_formatting()
107 go->repeat_seqhead = 0; in set_formatting()
108 go->seq_header_enable = 0; in set_formatting()
109 go->gop_header_enable = 0; in set_formatting()
110 go->dvd_mode = 0; in set_formatting()
114 switch (go->format) { in set_formatting()
116 go->pali = 0; in set_formatting()
120 go->pali = 0x48; in set_formatting()
144 go->pali = 0xf5; in set_formatting()
147 go->gop_size = v4l2_ctrl_g_ctrl(go->mpeg_video_gop_size); in set_formatting()
148 go->closed_gop = v4l2_ctrl_g_ctrl(go->mpeg_video_gop_closure); in set_formatting()
149 go->ipb = v4l2_ctrl_g_ctrl(go->mpeg_video_b_frames) != 0; in set_formatting()
150 go->bitrate = v4l2_ctrl_g_ctrl(go->mpeg_video_bitrate); in set_formatting()
151 go->repeat_seqhead = v4l2_ctrl_g_ctrl(go->mpeg_video_rep_seqheader); in set_formatting()
152 go->gop_header_enable = 1; in set_formatting()
153 go->dvd_mode = 0; in set_formatting()
154 if (go->format == V4L2_PIX_FMT_MPEG2) in set_formatting()
155 go->dvd_mode = in set_formatting()
156 go->bitrate == 9800000 && in set_formatting()
157 go->gop_size == 15 && in set_formatting()
158 go->ipb == 0 && in set_formatting()
159 go->repeat_seqhead == 1 && in set_formatting()
160 go->closed_gop; in set_formatting()
162 switch (v4l2_ctrl_g_ctrl(go->mpeg_video_aspect_ratio)) { in set_formatting()
165 go->aspect_ratio = GO7007_RATIO_1_1; in set_formatting()
168 go->aspect_ratio = GO7007_RATIO_4_3; in set_formatting()
171 go->aspect_ratio = GO7007_RATIO_16_9; in set_formatting()
176 static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try) in set_capture_size() argument
184 get_resolution(go, &sensor_width, &sensor_height); in set_capture_size()
189 } else if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) { in set_capture_size()
238 go->format = fmt->fmt.pix.pixelformat; in set_capture_size()
239 go->width = width; in set_capture_size()
240 go->height = height; in set_capture_size()
241 go->encoder_h_offset = go->board_info->sensor_h_offset; in set_capture_size()
242 go->encoder_v_offset = go->board_info->sensor_v_offset; in set_capture_size()
244 if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) { in set_capture_size()
252 go->encoder_h_halve = 0; in set_capture_size()
253 go->encoder_v_halve = 0; in set_capture_size()
254 go->encoder_subsample = 0; in set_capture_size()
255 call_all(&go->v4l2_dev, pad, set_fmt, NULL, &format); in set_capture_size()
258 go->encoder_h_halve = 1; in set_capture_size()
259 go->encoder_v_halve = 1; in set_capture_size()
260 go->encoder_subsample = 1; in set_capture_size()
262 go->encoder_h_halve = 1; in set_capture_size()
263 go->encoder_v_halve = 1; in set_capture_size()
264 go->encoder_subsample = 0; in set_capture_size()
266 go->encoder_h_halve = 0; in set_capture_size()
267 go->encoder_v_halve = 0; in set_capture_size()
268 go->encoder_subsample = 0; in set_capture_size()
277 struct go7007 *go = video_drvdata(file); in vidioc_querycap() local
280 strscpy(cap->card, go->name, sizeof(cap->card)); in vidioc_querycap()
281 strscpy(cap->bus_info, go->bus_info, sizeof(cap->bus_info)); in vidioc_querycap()
310 struct go7007 *go = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
313 fmt->fmt.pix.width = go->width; in vidioc_g_fmt_vid_cap()
314 fmt->fmt.pix.height = go->height; in vidioc_g_fmt_vid_cap()
315 fmt->fmt.pix.pixelformat = go->format; in vidioc_g_fmt_vid_cap()
327 struct go7007 *go = video_drvdata(file); in vidioc_try_fmt_vid_cap() local
329 return set_capture_size(go, fmt, 1); in vidioc_try_fmt_vid_cap()
335 struct go7007 *go = video_drvdata(file); in vidioc_s_fmt_vid_cap() local
337 if (vb2_is_busy(&go->vidq)) in vidioc_s_fmt_vid_cap()
340 return set_capture_size(go, fmt, 0); in vidioc_s_fmt_vid_cap()
359 struct go7007 *go = vb2_get_drv_priv(vq); in go7007_buf_queue() local
365 spin_lock_irqsave(&go->spinlock, flags); in go7007_buf_queue()
366 list_add_tail(&go7007_vb->list, &go->vidq_active); in go7007_buf_queue()
367 spin_unlock_irqrestore(&go->spinlock, flags); in go7007_buf_queue()
385 struct go7007 *go = vb2_get_drv_priv(vq); in go7007_buf_finish() local
389 u32 frame_type_flag = get_frame_type_flag(go7007_vb, go->format); in go7007_buf_finish()
399 struct go7007 *go = vb2_get_drv_priv(q); in go7007_start_streaming() local
402 set_formatting(go); in go7007_start_streaming()
403 mutex_lock(&go->hw_lock); in go7007_start_streaming()
404 go->next_seq = 0; in go7007_start_streaming()
405 go->active_buf = NULL; in go7007_start_streaming()
406 go->modet_event_status = 0; in go7007_start_streaming()
407 if (go7007_start_encoder(go) < 0) in go7007_start_streaming()
411 mutex_unlock(&go->hw_lock); in go7007_start_streaming()
414 call_all(&go->v4l2_dev, video, s_stream, 1); in go7007_start_streaming()
415 v4l2_ctrl_grab(go->mpeg_video_gop_size, true); in go7007_start_streaming()
416 v4l2_ctrl_grab(go->mpeg_video_gop_closure, true); in go7007_start_streaming()
417 v4l2_ctrl_grab(go->mpeg_video_bitrate, true); in go7007_start_streaming()
418 v4l2_ctrl_grab(go->mpeg_video_aspect_ratio, true); in go7007_start_streaming()
420 if (go->board_id == GO7007_BOARDID_ADS_USBAV_709) in go7007_start_streaming()
421 go7007_write_addr(go, 0x3c82, 0x0005); in go7007_start_streaming()
427 struct go7007 *go = vb2_get_drv_priv(q); in go7007_stop_streaming() local
430 go7007_stream_stop(go); in go7007_stop_streaming()
431 mutex_lock(&go->hw_lock); in go7007_stop_streaming()
432 go7007_reset_encoder(go); in go7007_stop_streaming()
433 mutex_unlock(&go->hw_lock); in go7007_stop_streaming()
434 call_all(&go->v4l2_dev, video, s_stream, 0); in go7007_stop_streaming()
436 spin_lock_irqsave(&go->spinlock, flags); in go7007_stop_streaming()
437 INIT_LIST_HEAD(&go->vidq_active); in go7007_stop_streaming()
438 spin_unlock_irqrestore(&go->spinlock, flags); in go7007_stop_streaming()
439 v4l2_ctrl_grab(go->mpeg_video_gop_size, false); in go7007_stop_streaming()
440 v4l2_ctrl_grab(go->mpeg_video_gop_closure, false); in go7007_stop_streaming()
441 v4l2_ctrl_grab(go->mpeg_video_bitrate, false); in go7007_stop_streaming()
442 v4l2_ctrl_grab(go->mpeg_video_aspect_ratio, false); in go7007_stop_streaming()
444 if (go->board_id == GO7007_BOARDID_ADS_USBAV_709) in go7007_stop_streaming()
445 go7007_write_addr(go, 0x3c82, 0x000d); in go7007_stop_streaming()
462 struct go7007 *go = video_drvdata(filp); in vidioc_g_parm() local
464 .numerator = 1001 * go->fps_scale, in vidioc_g_parm()
465 .denominator = go->sensor_framerate, in vidioc_g_parm()
481 struct go7007 *go = video_drvdata(filp); in vidioc_s_parm() local
487 n = go->sensor_framerate * in vidioc_s_parm()
491 go->fps_scale = (n + d/2) / d; in vidioc_s_parm()
493 go->fps_scale = 1; in vidioc_s_parm()
511 struct go7007 *go = video_drvdata(filp); in vidioc_enum_framesizes() local
520 get_resolution(go, &width, &height); in vidioc_enum_framesizes()
530 struct go7007 *go = video_drvdata(filp); in vidioc_enum_frameintervals() local
540 if (!(go->board_info->sensor_flags & GO7007_SENSOR_SCALING)) { in vidioc_enum_frameintervals()
541 get_resolution(go, &width, &height); in vidioc_enum_frameintervals()
551 fival->discrete.denominator = go->sensor_framerate; in vidioc_enum_frameintervals()
557 struct go7007 *go = video_drvdata(file); in vidioc_g_std() local
559 *std = go->std; in vidioc_g_std()
563 static int go7007_s_std(struct go7007 *go) in go7007_s_std() argument
565 if (go->std & V4L2_STD_625_50) { in go7007_s_std()
566 go->standard = GO7007_STD_PAL; in go7007_s_std()
567 go->sensor_framerate = 25025; in go7007_s_std()
569 go->standard = GO7007_STD_NTSC; in go7007_s_std()
570 go->sensor_framerate = 30000; in go7007_s_std()
573 call_all(&go->v4l2_dev, video, s_std, go->std); in go7007_s_std()
574 set_capture_size(go, NULL, 0); in go7007_s_std()
580 struct go7007 *go = video_drvdata(file); in vidioc_s_std() local
582 if (vb2_is_busy(&go->vidq)) in vidioc_s_std()
585 go->std = std; in vidioc_s_std()
587 return go7007_s_std(go); in vidioc_s_std()
592 struct go7007 *go = video_drvdata(file); in vidioc_querystd() local
594 return call_all(&go->v4l2_dev, video, querystd, std); in vidioc_querystd()
600 struct go7007 *go = video_drvdata(file); in vidioc_enum_input() local
602 if (inp->index >= go->board_info->num_inputs) in vidioc_enum_input()
605 strscpy(inp->name, go->board_info->inputs[inp->index].name, in vidioc_enum_input()
609 if ((go->board_info->flags & GO7007_BOARD_HAS_TUNER) && in vidioc_enum_input()
615 if (go->board_info->num_aud_inputs) in vidioc_enum_input()
616 inp->audioset = (1 << go->board_info->num_aud_inputs) - 1; in vidioc_enum_input()
620 if (go->board_info->sensor_flags & GO7007_SENSOR_TV) in vidioc_enum_input()
631 struct go7007 *go = video_drvdata(file); in vidioc_g_input() local
633 *input = go->input; in vidioc_g_input()
640 struct go7007 *go = video_drvdata(file); in vidioc_enumaudio() local
642 if (a->index >= go->board_info->num_aud_inputs) in vidioc_enumaudio()
644 strscpy(a->name, go->board_info->aud_inputs[a->index].name, in vidioc_enumaudio()
652 struct go7007 *go = video_drvdata(file); in vidioc_g_audio() local
654 a->index = go->aud_input; in vidioc_g_audio()
655 strscpy(a->name, go->board_info->aud_inputs[go->aud_input].name, in vidioc_g_audio()
664 struct go7007 *go = video_drvdata(file); in vidioc_s_audio() local
666 if (a->index >= go->board_info->num_aud_inputs) in vidioc_s_audio()
668 go->aud_input = a->index; in vidioc_s_audio()
669 v4l2_subdev_call(go->sd_audio, audio, s_routing, in vidioc_s_audio()
670 go->board_info->aud_inputs[go->aud_input].audio_input, 0, 0); in vidioc_s_audio()
674 static void go7007_s_input(struct go7007 *go) in go7007_s_input() argument
676 unsigned int input = go->input; in go7007_s_input()
678 v4l2_subdev_call(go->sd_video, video, s_routing, in go7007_s_input()
679 go->board_info->inputs[input].video_input, 0, in go7007_s_input()
680 go->board_info->video_config); in go7007_s_input()
681 if (go->board_info->num_aud_inputs) { in go7007_s_input()
682 int aud_input = go->board_info->inputs[input].audio_index; in go7007_s_input()
684 v4l2_subdev_call(go->sd_audio, audio, s_routing, in go7007_s_input()
685 go->board_info->aud_inputs[aud_input].audio_input, 0, 0); in go7007_s_input()
686 go->aud_input = aud_input; in go7007_s_input()
692 struct go7007 *go = video_drvdata(file); in vidioc_s_input() local
694 if (input >= go->board_info->num_inputs) in vidioc_s_input()
696 if (vb2_is_busy(&go->vidq)) in vidioc_s_input()
699 go->input = input; in vidioc_s_input()
700 go7007_s_input(go); in vidioc_s_input()
708 struct go7007 *go = video_drvdata(file); in vidioc_g_tuner() local
714 return call_all(&go->v4l2_dev, tuner, g_tuner, t); in vidioc_g_tuner()
720 struct go7007 *go = video_drvdata(file); in vidioc_s_tuner() local
725 return call_all(&go->v4l2_dev, tuner, s_tuner, t); in vidioc_s_tuner()
731 struct go7007 *go = video_drvdata(file); in vidioc_g_frequency() local
736 return call_all(&go->v4l2_dev, tuner, g_frequency, f); in vidioc_g_frequency()
742 struct go7007 *go = video_drvdata(file); in vidioc_s_frequency() local
747 return call_all(&go->v4l2_dev, tuner, s_frequency, f); in vidioc_s_frequency()
752 struct go7007 *go = video_drvdata(file); in vidioc_log_status() local
755 return call_all(&go->v4l2_dev, core, log_status); in vidioc_log_status()
775 struct go7007 *go = in go7007_s_ctrl() local
782 go->modet[0].pixel_threshold = ctrl->val; in go7007_s_ctrl()
785 go->modet[0].motion_threshold = ctrl->val; in go7007_s_ctrl()
788 go->modet[0].mb_threshold = ctrl->val; in go7007_s_ctrl()
791 go->modet[1].pixel_threshold = ctrl->val; in go7007_s_ctrl()
794 go->modet[1].motion_threshold = ctrl->val; in go7007_s_ctrl()
797 go->modet[1].mb_threshold = ctrl->val; in go7007_s_ctrl()
800 go->modet[2].pixel_threshold = ctrl->val; in go7007_s_ctrl()
803 go->modet[2].motion_threshold = ctrl->val; in go7007_s_ctrl()
806 go->modet[2].mb_threshold = ctrl->val; in go7007_s_ctrl()
809 go->modet[3].pixel_threshold = ctrl->val; in go7007_s_ctrl()
812 go->modet[3].motion_threshold = ctrl->val; in go7007_s_ctrl()
815 go->modet[3].mb_threshold = ctrl->val; in go7007_s_ctrl()
818 mt = go->modet_map; in go7007_s_ctrl()
819 for (y = 0; y < go->height / 16; y++, mt += go->width / 16) in go7007_s_ctrl()
820 memcpy(mt, ctrl->p_new.p_u8 + y * (720 / 16), go->width / 16); in go7007_s_ctrl()
1012 int go7007_v4l2_ctrl_init(struct go7007 *go) in go7007_v4l2_ctrl_init() argument
1014 struct v4l2_ctrl_handler *hdl = &go->hdl; in go7007_v4l2_ctrl_init()
1018 go->mpeg_video_gop_size = v4l2_ctrl_new_std(hdl, NULL, in go7007_v4l2_ctrl_init()
1020 go->mpeg_video_gop_closure = v4l2_ctrl_new_std(hdl, NULL, in go7007_v4l2_ctrl_init()
1022 go->mpeg_video_bitrate = v4l2_ctrl_new_std(hdl, NULL, in go7007_v4l2_ctrl_init()
1025 go->mpeg_video_b_frames = v4l2_ctrl_new_std(hdl, NULL, in go7007_v4l2_ctrl_init()
1027 go->mpeg_video_rep_seqheader = v4l2_ctrl_new_std(hdl, NULL, in go7007_v4l2_ctrl_init()
1030 go->mpeg_video_aspect_ratio = v4l2_ctrl_new_std_menu(hdl, NULL, in go7007_v4l2_ctrl_init()
1055 go->modet_mode = v4l2_ctrl_new_std_menu(hdl, NULL, in go7007_v4l2_ctrl_init()
1063 v4l2_err(&go->v4l2_dev, "Could not register controls\n"); in go7007_v4l2_ctrl_init()
1066 go->v4l2_dev.ctrl_handler = hdl; in go7007_v4l2_ctrl_init()
1070 int go7007_v4l2_init(struct go7007 *go) in go7007_v4l2_init() argument
1072 struct video_device *vdev = &go->vdev; in go7007_v4l2_init()
1075 mutex_init(&go->serialize_lock); in go7007_v4l2_init()
1076 mutex_init(&go->queue_lock); in go7007_v4l2_init()
1078 INIT_LIST_HEAD(&go->vidq_active); in go7007_v4l2_init()
1079 go->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in go7007_v4l2_init()
1080 go->vidq.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; in go7007_v4l2_init()
1081 go->vidq.ops = &go7007_video_qops; in go7007_v4l2_init()
1082 go->vidq.mem_ops = &vb2_vmalloc_memops; in go7007_v4l2_init()
1083 go->vidq.drv_priv = go; in go7007_v4l2_init()
1084 go->vidq.buf_struct_size = sizeof(struct go7007_buffer); in go7007_v4l2_init()
1085 go->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in go7007_v4l2_init()
1086 go->vidq.lock = &go->queue_lock; in go7007_v4l2_init()
1087 rv = vb2_queue_init(&go->vidq); in go7007_v4l2_init()
1091 vdev->lock = &go->serialize_lock; in go7007_v4l2_init()
1092 vdev->queue = &go->vidq; in go7007_v4l2_init()
1095 if (go->board_info->num_aud_inputs) in go7007_v4l2_init()
1097 if (go->board_info->flags & GO7007_BOARD_HAS_TUNER) in go7007_v4l2_init()
1099 video_set_drvdata(vdev, go); in go7007_v4l2_init()
1100 vdev->v4l2_dev = &go->v4l2_dev; in go7007_v4l2_init()
1101 if (!v4l2_device_has_op(&go->v4l2_dev, 0, video, querystd)) in go7007_v4l2_init()
1103 if (!(go->board_info->flags & GO7007_BOARD_HAS_TUNER)) { in go7007_v4l2_init()
1114 call_all(&go->v4l2_dev, tuner, s_frequency, &f); in go7007_v4l2_init()
1116 if (!(go->board_info->sensor_flags & GO7007_SENSOR_TV)) { in go7007_v4l2_init()
1121 if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) in go7007_v4l2_init()
1123 if (go->board_info->num_aud_inputs == 0) { in go7007_v4l2_init()
1129 if (go->board_info->sensor_flags & GO7007_SENSOR_SAA7115) in go7007_v4l2_init()
1130 v4l2_subdev_call(go->sd_video, video, s_crystal_freq, in go7007_v4l2_init()
1134 go7007_s_input(go); in go7007_v4l2_init()
1135 if (go->board_info->sensor_flags & GO7007_SENSOR_TV) in go7007_v4l2_init()
1136 go7007_s_std(go); in go7007_v4l2_init()
1140 dev_info(go->dev, "registered device %s [v4l2]\n", in go7007_v4l2_init()
1146 void go7007_v4l2_remove(struct go7007 *go) in go7007_v4l2_remove() argument
1148 v4l2_ctrl_handler_free(&go->hdl); in go7007_v4l2_remove()