Lines Matching +full:on +full:- +full:the +full:- +full:go
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2005-2006 Micronas USA Inc.
20 #include <media/v4l2-common.h>
21 #include <media/v4l2-ioctl.h>
22 #include <media/v4l2-subdev.h>
23 #include <media/v4l2-event.h>
24 #include <media/videobuf2-vmalloc.h>
27 #include "go7007-priv.h"
47 u8 *ptr = vb2_plane_vaddr(&vb->vb.vb2_buf, 0); in get_frame_type_flag()
53 switch ((ptr[vb->frame_offset + 4] >> 6) & 0x3) { in get_frame_type_flag()
65 switch ((ptr[vb->frame_offset + 5] >> 3) & 0x7) { in get_frame_type_flag()
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()
123 /* For future reference: this is the list of MPEG4 in set_formatting()
128 * -------------- ---- 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
181 if (fmt != NULL && !valid_pixelformat(fmt->fmt.pix.pixelformat)) in set_capture_size()
182 return -EINVAL; in set_capture_size()
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()
190 if (fmt->fmt.pix.width > sensor_width) in set_capture_size()
192 else if (fmt->fmt.pix.width < 144) in set_capture_size()
195 width = fmt->fmt.pix.width & ~0x0f; in set_capture_size()
197 if (fmt->fmt.pix.height > sensor_height) in set_capture_size()
199 else if (fmt->fmt.pix.height < 96) in set_capture_size()
202 height = fmt->fmt.pix.height & ~0x0f; in set_capture_size()
204 width = fmt->fmt.pix.width; in set_capture_size()
221 u32 pixelformat = fmt->fmt.pix.pixelformat; in set_capture_size()
224 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in set_capture_size()
225 fmt->fmt.pix.width = width; in set_capture_size()
226 fmt->fmt.pix.height = height; in set_capture_size()
227 fmt->fmt.pix.pixelformat = pixelformat; in set_capture_size()
228 fmt->fmt.pix.field = V4L2_FIELD_NONE; in set_capture_size()
229 fmt->fmt.pix.bytesperline = 0; in set_capture_size()
230 fmt->fmt.pix.sizeimage = GO7007_BUF_SIZE; in set_capture_size()
231 fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 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()
250 format.format.width = fmt ? fmt->fmt.pix.width : width; 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
279 strscpy(cap->driver, "go7007", sizeof(cap->driver)); in vidioc_querycap()
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()
288 switch (fmt->index) { in vidioc_enum_fmt_vid_cap()
290 fmt->pixelformat = V4L2_PIX_FMT_MJPEG; in vidioc_enum_fmt_vid_cap()
293 fmt->pixelformat = V4L2_PIX_FMT_MPEG1; in vidioc_enum_fmt_vid_cap()
296 fmt->pixelformat = V4L2_PIX_FMT_MPEG2; in vidioc_enum_fmt_vid_cap()
299 fmt->pixelformat = V4L2_PIX_FMT_MPEG4; in vidioc_enum_fmt_vid_cap()
302 return -EINVAL; in vidioc_enum_fmt_vid_cap()
310 struct go7007 *go = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
312 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in vidioc_g_fmt_vid_cap()
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()
316 fmt->fmt.pix.field = V4L2_FIELD_NONE; in vidioc_g_fmt_vid_cap()
317 fmt->fmt.pix.bytesperline = 0; in vidioc_g_fmt_vid_cap()
318 fmt->fmt.pix.sizeimage = GO7007_BUF_SIZE; in vidioc_g_fmt_vid_cap()
319 fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 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()
338 return -EBUSY; in vidioc_s_fmt_vid_cap()
340 return set_capture_size(go, fmt, 0); in vidioc_s_fmt_vid_cap()
358 struct vb2_queue *vq = vb->vb2_queue; in go7007_buf_queue()
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()
376 go7007_vb->modet_active = 0; in go7007_buf_prepare()
377 go7007_vb->frame_offset = 0; in go7007_buf_prepare()
378 vb->planes[0].bytesused = 0; in go7007_buf_prepare()
384 struct vb2_queue *vq = vb->vb2_queue; in go7007_buf_finish()
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()
391 vbuf->flags &= ~(V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_BFRAME | in go7007_buf_finish()
393 vbuf->flags |= frame_type_flag; in go7007_buf_finish()
394 vbuf->field = V4L2_FIELD_NONE; 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()
408 ret = -EIO; 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()
419 /* Turn on Capture LED */ 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()
443 /* Turn on Capture LED */ 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()
468 if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in vidioc_g_parm()
469 return -EINVAL; in vidioc_g_parm()
471 parm->parm.capture.readbuffers = 2; in vidioc_g_parm()
472 parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; in vidioc_g_parm()
473 parm->parm.capture.timeperframe = timeperframe; in vidioc_g_parm()
481 struct go7007 *go = video_drvdata(filp); in vidioc_s_parm() local
484 if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in vidioc_s_parm()
485 return -EINVAL; in vidioc_s_parm()
487 n = go->sensor_framerate * in vidioc_s_parm()
488 parm->parm.capture.timeperframe.numerator; in vidioc_s_parm()
489 d = 1001 * parm->parm.capture.timeperframe.denominator; 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()
498 /* VIDIOC_ENUMSTD on go7007 were used for enumerating the supported fps and
499 its resolution, when the device is not connected to TV.
500 This is were an API abuse, probably used by the lack of specific IOCTL's to
501 enumerate it, by the time the driver was written.
506 The two functions below implement the newer ioctls
511 struct go7007 *go = video_drvdata(filp); in vidioc_enum_framesizes() local
514 if (fsize->index > 2) in vidioc_enum_framesizes()
515 return -EINVAL; in vidioc_enum_framesizes()
517 if (!valid_pixelformat(fsize->pixel_format)) in vidioc_enum_framesizes()
518 return -EINVAL; in vidioc_enum_framesizes()
520 get_resolution(go, &width, &height); in vidioc_enum_framesizes()
521 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; in vidioc_enum_framesizes()
522 fsize->discrete.width = (width >> fsize->index) & ~0xf; in vidioc_enum_framesizes()
523 fsize->discrete.height = (height >> fsize->index) & ~0xf; in vidioc_enum_framesizes()
530 struct go7007 *go = video_drvdata(filp); in vidioc_enum_frameintervals() local
534 if (fival->index > 4) in vidioc_enum_frameintervals()
535 return -EINVAL; in vidioc_enum_frameintervals()
537 if (!valid_pixelformat(fival->pixel_format)) in vidioc_enum_frameintervals()
538 return -EINVAL; in vidioc_enum_frameintervals()
540 if (!(go->board_info->sensor_flags & GO7007_SENSOR_SCALING)) { in vidioc_enum_frameintervals()
541 get_resolution(go, &width, &height); in vidioc_enum_frameintervals()
543 if (fival->width == ((width >> i) & ~0xf) && in vidioc_enum_frameintervals()
544 fival->height == ((height >> i) & ~0xf)) in vidioc_enum_frameintervals()
547 return -EINVAL; in vidioc_enum_frameintervals()
549 fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; in vidioc_enum_frameintervals()
550 fival->discrete.numerator = 1001 * (fival->index + 1); 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()
583 return -EBUSY; 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()
603 return -EINVAL; in vidioc_enum_input()
605 strscpy(inp->name, go->board_info->inputs[inp->index].name, in vidioc_enum_input()
606 sizeof(inp->name)); in vidioc_enum_input()
608 /* If this board has a tuner, it will be the first input */ in vidioc_enum_input()
609 if ((go->board_info->flags & GO7007_BOARD_HAS_TUNER) && in vidioc_enum_input()
610 inp->index == 0) in vidioc_enum_input()
611 inp->type = V4L2_INPUT_TYPE_TUNER; in vidioc_enum_input()
613 inp->type = V4L2_INPUT_TYPE_CAMERA; 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()
618 inp->audioset = 0; in vidioc_enum_input()
619 inp->tuner = 0; in vidioc_enum_input()
620 if (go->board_info->sensor_flags & GO7007_SENSOR_TV) in vidioc_enum_input()
621 inp->std = video_devdata(file)->tvnorms; in vidioc_enum_input()
623 inp->std = 0; 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()
643 return -EINVAL; in vidioc_enumaudio()
644 strscpy(a->name, go->board_info->aud_inputs[a->index].name, in vidioc_enumaudio()
645 sizeof(a->name)); in vidioc_enumaudio()
646 a->capability = V4L2_AUDCAP_STEREO; 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()
656 sizeof(a->name)); in vidioc_g_audio()
657 a->capability = V4L2_AUDCAP_STEREO; 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()
667 return -EINVAL; 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()
695 return -EINVAL; in vidioc_s_input()
696 if (vb2_is_busy(&go->vidq)) in vidioc_s_input()
697 return -EBUSY; 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
710 if (t->index != 0) in vidioc_g_tuner()
711 return -EINVAL; in vidioc_g_tuner()
713 strscpy(t->name, "Tuner", sizeof(t->name)); in vidioc_g_tuner()
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
722 if (t->index != 0) in vidioc_s_tuner()
723 return -EINVAL; in vidioc_s_tuner()
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
733 if (f->tuner) in vidioc_g_frequency()
734 return -EINVAL; in vidioc_g_frequency()
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
744 if (f->tuner) in vidioc_s_frequency()
745 return -EINVAL; in vidioc_s_frequency()
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()
762 switch (sub->type) { in vidioc_subscribe_event()
775 struct go7007 *go = in go7007_s_ctrl() local
776 container_of(ctrl->handler, struct go7007, hdl); in go7007_s_ctrl()
780 switch (ctrl->id) { in go7007_s_ctrl()
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()
823 return -EINVAL; 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()
1041 ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; in go7007_v4l2_ctrl_init()
1055 go->modet_mode = v4l2_ctrl_new_std_menu(hdl, NULL, in go7007_v4l2_ctrl_init()
1060 if (hdl->error) { in go7007_v4l2_ctrl_init()
1061 int rv = hdl->error; 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()
1093 vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | in go7007_v4l2_init()
1095 if (go->board_info->num_aud_inputs) in go7007_v4l2_init()
1096 vdev->device_caps |= V4L2_CAP_AUDIO; in go7007_v4l2_init()
1097 if (go->board_info->flags & GO7007_BOARD_HAS_TUNER) in go7007_v4l2_init()
1098 vdev->device_caps |= V4L2_CAP_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()
1119 vdev->tvnorms = 0; 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()
1128 /* Setup correct crystal frequency on this board */ 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()
1137 rv = video_register_device(vdev, VFL_TYPE_VIDEO, -1); 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()