2008-02-16 08:53:09 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2005-2006 Micronas USA Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License (Version 2) as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/spinlock.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2008-02-16 08:53:09 +08:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/pagemap.h>
|
2013-03-09 22:08:41 +08:00
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/uaccess.h>
|
2008-09-30 10:36:24 +08:00
|
|
|
#include <linux/videodev2.h>
|
2008-02-16 08:53:09 +08:00
|
|
|
#include <media/v4l2-common.h>
|
|
|
|
#include <media/v4l2-ioctl.h>
|
2009-11-17 02:16:00 +08:00
|
|
|
#include <media/v4l2-subdev.h>
|
2013-03-09 22:08:41 +08:00
|
|
|
#include <media/v4l2-event.h>
|
2013-03-11 17:52:27 +08:00
|
|
|
#include <media/videobuf2-vmalloc.h>
|
2015-11-10 22:01:44 +08:00
|
|
|
#include <media/i2c/saa7115.h>
|
2008-02-16 08:53:09 +08:00
|
|
|
|
|
|
|
#include "go7007-priv.h"
|
|
|
|
|
2009-11-17 02:16:00 +08:00
|
|
|
#define call_all(dev, o, f, args...) \
|
|
|
|
v4l2_device_call_until_err(dev, 0, o, f, ##args)
|
|
|
|
|
2013-03-11 16:58:55 +08:00
|
|
|
static bool valid_pixelformat(u32 pixelformat)
|
|
|
|
{
|
|
|
|
switch (pixelformat) {
|
|
|
|
case V4L2_PIX_FMT_MJPEG:
|
|
|
|
case V4L2_PIX_FMT_MPEG1:
|
|
|
|
case V4L2_PIX_FMT_MPEG2:
|
|
|
|
case V4L2_PIX_FMT_MPEG4:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
static u32 get_frame_type_flag(struct go7007_buffer *vb, int format)
|
2008-02-16 08:53:09 +08:00
|
|
|
{
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
u8 *ptr = vb2_plane_vaddr(&vb->vb.vb2_buf, 0);
|
2008-02-16 08:53:09 +08:00
|
|
|
|
|
|
|
switch (format) {
|
2013-03-11 16:58:55 +08:00
|
|
|
case V4L2_PIX_FMT_MJPEG:
|
2008-02-16 08:53:09 +08:00
|
|
|
return V4L2_BUF_FLAG_KEYFRAME;
|
2013-03-11 16:58:55 +08:00
|
|
|
case V4L2_PIX_FMT_MPEG4:
|
2013-03-11 17:52:27 +08:00
|
|
|
switch ((ptr[vb->frame_offset + 4] >> 6) & 0x3) {
|
2008-02-16 08:53:09 +08:00
|
|
|
case 0:
|
|
|
|
return V4L2_BUF_FLAG_KEYFRAME;
|
|
|
|
case 1:
|
|
|
|
return V4L2_BUF_FLAG_PFRAME;
|
|
|
|
case 2:
|
|
|
|
return V4L2_BUF_FLAG_BFRAME;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-11 16:58:55 +08:00
|
|
|
case V4L2_PIX_FMT_MPEG1:
|
|
|
|
case V4L2_PIX_FMT_MPEG2:
|
2013-03-11 17:52:27 +08:00
|
|
|
switch ((ptr[vb->frame_offset + 5] >> 3) & 0x7) {
|
2008-02-16 08:53:09 +08:00
|
|
|
case 1:
|
|
|
|
return V4L2_BUF_FLAG_KEYFRAME;
|
|
|
|
case 2:
|
|
|
|
return V4L2_BUF_FLAG_PFRAME;
|
|
|
|
case 3:
|
|
|
|
return V4L2_BUF_FLAG_BFRAME;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
static void get_resolution(struct go7007 *go, int *width, int *height)
|
2008-02-16 08:53:09 +08:00
|
|
|
{
|
|
|
|
switch (go->standard) {
|
|
|
|
case GO7007_STD_NTSC:
|
2013-03-11 16:50:21 +08:00
|
|
|
*width = 720;
|
|
|
|
*height = 480;
|
2008-02-16 08:53:09 +08:00
|
|
|
break;
|
|
|
|
case GO7007_STD_PAL:
|
2013-03-11 16:50:21 +08:00
|
|
|
*width = 720;
|
|
|
|
*height = 576;
|
2008-02-16 08:53:09 +08:00
|
|
|
break;
|
|
|
|
case GO7007_STD_OTHER:
|
2013-03-11 16:50:21 +08:00
|
|
|
default:
|
|
|
|
*width = go->board_info->sensor_width;
|
|
|
|
*height = go->board_info->sensor_height;
|
2008-02-16 08:53:09 +08:00
|
|
|
break;
|
|
|
|
}
|
2013-03-11 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
2013-03-11 16:58:55 +08:00
|
|
|
static void set_formatting(struct go7007 *go)
|
|
|
|
{
|
|
|
|
if (go->format == V4L2_PIX_FMT_MJPEG) {
|
|
|
|
go->pali = 0;
|
|
|
|
go->aspect_ratio = GO7007_RATIO_1_1;
|
|
|
|
go->gop_size = 0;
|
|
|
|
go->ipb = 0;
|
|
|
|
go->closed_gop = 0;
|
|
|
|
go->repeat_seqhead = 0;
|
|
|
|
go->seq_header_enable = 0;
|
|
|
|
go->gop_header_enable = 0;
|
|
|
|
go->dvd_mode = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (go->format) {
|
|
|
|
case V4L2_PIX_FMT_MPEG1:
|
|
|
|
go->pali = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case V4L2_PIX_FMT_MPEG2:
|
|
|
|
go->pali = 0x48;
|
|
|
|
break;
|
|
|
|
case V4L2_PIX_FMT_MPEG4:
|
|
|
|
/* For future reference: this is the list of MPEG4
|
|
|
|
* profiles that are available, although they are
|
|
|
|
* untested:
|
|
|
|
*
|
|
|
|
* Profile pali
|
|
|
|
* -------------- ----
|
|
|
|
* PROFILE_S_L0 0x08
|
|
|
|
* PROFILE_S_L1 0x01
|
|
|
|
* PROFILE_S_L2 0x02
|
|
|
|
* PROFILE_S_L3 0x03
|
|
|
|
* PROFILE_ARTS_L1 0x91
|
|
|
|
* PROFILE_ARTS_L2 0x92
|
|
|
|
* PROFILE_ARTS_L3 0x93
|
|
|
|
* PROFILE_ARTS_L4 0x94
|
|
|
|
* PROFILE_AS_L0 0xf0
|
|
|
|
* PROFILE_AS_L1 0xf1
|
|
|
|
* PROFILE_AS_L2 0xf2
|
|
|
|
* PROFILE_AS_L3 0xf3
|
|
|
|
* PROFILE_AS_L4 0xf4
|
|
|
|
* PROFILE_AS_L5 0xf5
|
|
|
|
*/
|
|
|
|
go->pali = 0xf5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
go->gop_size = v4l2_ctrl_g_ctrl(go->mpeg_video_gop_size);
|
|
|
|
go->closed_gop = v4l2_ctrl_g_ctrl(go->mpeg_video_gop_closure);
|
2013-03-17 18:16:37 +08:00
|
|
|
go->ipb = v4l2_ctrl_g_ctrl(go->mpeg_video_b_frames) != 0;
|
2013-03-11 16:58:55 +08:00
|
|
|
go->bitrate = v4l2_ctrl_g_ctrl(go->mpeg_video_bitrate);
|
2013-03-17 21:47:02 +08:00
|
|
|
go->repeat_seqhead = v4l2_ctrl_g_ctrl(go->mpeg_video_rep_seqheader);
|
2013-03-11 16:58:55 +08:00
|
|
|
go->gop_header_enable = 1;
|
|
|
|
go->dvd_mode = 0;
|
|
|
|
if (go->format == V4L2_PIX_FMT_MPEG2)
|
|
|
|
go->dvd_mode =
|
|
|
|
go->bitrate == 9800000 &&
|
|
|
|
go->gop_size == 15 &&
|
2013-03-17 18:16:37 +08:00
|
|
|
go->ipb == 0 &&
|
2013-03-17 21:47:02 +08:00
|
|
|
go->repeat_seqhead == 1 &&
|
2013-03-11 16:58:55 +08:00
|
|
|
go->closed_gop;
|
|
|
|
|
|
|
|
switch (v4l2_ctrl_g_ctrl(go->mpeg_video_aspect_ratio)) {
|
|
|
|
default:
|
|
|
|
case V4L2_MPEG_VIDEO_ASPECT_1x1:
|
|
|
|
go->aspect_ratio = GO7007_RATIO_1_1;
|
|
|
|
break;
|
|
|
|
case V4L2_MPEG_VIDEO_ASPECT_4x3:
|
|
|
|
go->aspect_ratio = GO7007_RATIO_4_3;
|
|
|
|
break;
|
|
|
|
case V4L2_MPEG_VIDEO_ASPECT_16x9:
|
|
|
|
go->aspect_ratio = GO7007_RATIO_16_9;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try)
|
|
|
|
{
|
|
|
|
int sensor_height = 0, sensor_width = 0;
|
2014-06-10 18:39:04 +08:00
|
|
|
int width, height;
|
2013-03-11 16:50:21 +08:00
|
|
|
|
2013-03-11 16:58:55 +08:00
|
|
|
if (fmt != NULL && !valid_pixelformat(fmt->fmt.pix.pixelformat))
|
2013-03-11 16:50:21 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
get_resolution(go, &sensor_width, &sensor_height);
|
2008-02-16 08:53:09 +08:00
|
|
|
|
|
|
|
if (fmt == NULL) {
|
|
|
|
width = sensor_width;
|
|
|
|
height = sensor_height;
|
|
|
|
} else if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) {
|
|
|
|
if (fmt->fmt.pix.width > sensor_width)
|
|
|
|
width = sensor_width;
|
|
|
|
else if (fmt->fmt.pix.width < 144)
|
|
|
|
width = 144;
|
|
|
|
else
|
|
|
|
width = fmt->fmt.pix.width & ~0x0f;
|
|
|
|
|
|
|
|
if (fmt->fmt.pix.height > sensor_height)
|
|
|
|
height = sensor_height;
|
|
|
|
else if (fmt->fmt.pix.height < 96)
|
|
|
|
height = 96;
|
|
|
|
else
|
|
|
|
height = fmt->fmt.pix.height & ~0x0f;
|
|
|
|
} else {
|
2013-03-11 16:50:21 +08:00
|
|
|
width = fmt->fmt.pix.width;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
if (width <= sensor_width / 4) {
|
2008-02-16 08:53:09 +08:00
|
|
|
width = sensor_width / 4;
|
|
|
|
height = sensor_height / 4;
|
2013-03-11 16:50:21 +08:00
|
|
|
} else if (width <= sensor_width / 2) {
|
2008-02-16 08:53:09 +08:00
|
|
|
width = sensor_width / 2;
|
|
|
|
height = sensor_height / 2;
|
|
|
|
} else {
|
|
|
|
width = sensor_width;
|
|
|
|
height = sensor_height;
|
|
|
|
}
|
|
|
|
width &= ~0xf;
|
|
|
|
height &= ~0xf;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fmt != NULL) {
|
|
|
|
u32 pixelformat = fmt->fmt.pix.pixelformat;
|
|
|
|
|
|
|
|
memset(fmt, 0, sizeof(*fmt));
|
|
|
|
fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
fmt->fmt.pix.width = width;
|
|
|
|
fmt->fmt.pix.height = height;
|
|
|
|
fmt->fmt.pix.pixelformat = pixelformat;
|
|
|
|
fmt->fmt.pix.field = V4L2_FIELD_NONE;
|
|
|
|
fmt->fmt.pix.bytesperline = 0;
|
|
|
|
fmt->fmt.pix.sizeimage = GO7007_BUF_SIZE;
|
2013-03-11 16:50:21 +08:00
|
|
|
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
|
2008-02-16 08:53:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (try)
|
|
|
|
return 0;
|
|
|
|
|
2013-03-11 16:58:55 +08:00
|
|
|
if (fmt)
|
|
|
|
go->format = fmt->fmt.pix.pixelformat;
|
2008-02-16 08:53:09 +08:00
|
|
|
go->width = width;
|
|
|
|
go->height = height;
|
|
|
|
go->encoder_h_offset = go->board_info->sensor_h_offset;
|
|
|
|
go->encoder_v_offset = go->board_info->sensor_v_offset;
|
|
|
|
|
|
|
|
if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING) {
|
2015-04-09 15:05:59 +08:00
|
|
|
struct v4l2_subdev_format format = {
|
|
|
|
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
|
|
|
|
};
|
2009-11-17 02:16:00 +08:00
|
|
|
|
2015-04-09 15:05:59 +08:00
|
|
|
format.format.code = MEDIA_BUS_FMT_FIXED;
|
|
|
|
format.format.width = fmt ? fmt->fmt.pix.width : width;
|
|
|
|
format.format.height = height;
|
2013-03-11 16:50:21 +08:00
|
|
|
go->encoder_h_halve = 0;
|
|
|
|
go->encoder_v_halve = 0;
|
|
|
|
go->encoder_subsample = 0;
|
2015-04-09 15:05:59 +08:00
|
|
|
call_all(&go->v4l2_dev, pad, set_fmt, NULL, &format);
|
2008-02-16 08:53:09 +08:00
|
|
|
} else {
|
|
|
|
if (width <= sensor_width / 4) {
|
|
|
|
go->encoder_h_halve = 1;
|
|
|
|
go->encoder_v_halve = 1;
|
|
|
|
go->encoder_subsample = 1;
|
|
|
|
} else if (width <= sensor_width / 2) {
|
|
|
|
go->encoder_h_halve = 1;
|
|
|
|
go->encoder_v_halve = 1;
|
|
|
|
go->encoder_subsample = 0;
|
|
|
|
} else {
|
|
|
|
go->encoder_h_halve = 0;
|
|
|
|
go->encoder_v_halve = 0;
|
|
|
|
go->encoder_subsample = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
static int vidioc_querycap(struct file *file, void *priv,
|
|
|
|
struct v4l2_capability *cap)
|
2008-02-16 08:53:09 +08:00
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
strlcpy(cap->driver, "go7007", sizeof(cap->driver));
|
|
|
|
strlcpy(cap->card, go->name, sizeof(cap->card));
|
2013-03-09 20:38:03 +08:00
|
|
|
strlcpy(cap->bus_info, go->bus_info, sizeof(cap->bus_info));
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
|
|
|
|
V4L2_CAP_STREAMING;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-10 00:19:08 +08:00
|
|
|
if (go->board_info->num_aud_inputs)
|
|
|
|
cap->device_caps |= V4L2_CAP_AUDIO;
|
2008-11-12 08:54:30 +08:00
|
|
|
if (go->board_info->flags & GO7007_BOARD_HAS_TUNER)
|
2013-03-09 20:38:03 +08:00
|
|
|
cap->device_caps |= V4L2_CAP_TUNER;
|
|
|
|
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
|
2008-11-12 08:54:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_fmtdesc *fmt)
|
|
|
|
{
|
|
|
|
char *desc = NULL;
|
2008-10-31 03:56:33 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
switch (fmt->index) {
|
|
|
|
case 0:
|
|
|
|
fmt->pixelformat = V4L2_PIX_FMT_MJPEG;
|
2013-03-11 16:58:55 +08:00
|
|
|
desc = "Motion JPEG";
|
2008-11-12 08:54:30 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-03-11 16:58:55 +08:00
|
|
|
fmt->pixelformat = V4L2_PIX_FMT_MPEG1;
|
|
|
|
desc = "MPEG-1 ES";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
fmt->pixelformat = V4L2_PIX_FMT_MPEG2;
|
|
|
|
desc = "MPEG-2 ES";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
fmt->pixelformat = V4L2_PIX_FMT_MPEG4;
|
|
|
|
desc = "MPEG-4 ES";
|
2008-11-12 08:54:30 +08:00
|
|
|
break;
|
|
|
|
default:
|
2008-02-16 08:53:09 +08:00
|
|
|
return -EINVAL;
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
fmt->flags = V4L2_FMT_FLAG_COMPRESSED;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
strncpy(fmt->description, desc, sizeof(fmt->description));
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
|
|
|
fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
fmt->fmt.pix.width = go->width;
|
|
|
|
fmt->fmt.pix.height = go->height;
|
2013-03-11 16:58:55 +08:00
|
|
|
fmt->fmt.pix.pixelformat = go->format;
|
2008-11-12 08:54:30 +08:00
|
|
|
fmt->fmt.pix.field = V4L2_FIELD_NONE;
|
|
|
|
fmt->fmt.pix.bytesperline = 0;
|
|
|
|
fmt->fmt.pix.sizeimage = GO7007_BUF_SIZE;
|
|
|
|
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
|
|
|
return set_capture_size(go, fmt, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *fmt)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
if (vb2_is_busy(&go->vidq))
|
2008-11-12 08:54:30 +08:00
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
return set_capture_size(go, fmt, 0);
|
|
|
|
}
|
|
|
|
|
2014-03-16 01:10:16 +08:00
|
|
|
static int go7007_queue_setup(struct vb2_queue *q,
|
2013-03-11 17:52:27 +08:00
|
|
|
unsigned int *num_buffers, unsigned int *num_planes,
|
2016-04-15 20:15:05 +08:00
|
|
|
unsigned int sizes[], struct device *alloc_devs[])
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 17:52:27 +08:00
|
|
|
sizes[0] = GO7007_BUF_SIZE;
|
|
|
|
*num_planes = 1;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
if (*num_buffers < 2)
|
|
|
|
*num_buffers = 2;
|
2008-11-12 08:54:30 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
static void go7007_buf_queue(struct vb2_buffer *vb)
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 17:52:27 +08:00
|
|
|
struct vb2_queue *vq = vb->vb2_queue;
|
|
|
|
struct go7007 *go = vb2_get_drv_priv(vq);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
|
2013-03-11 17:52:27 +08:00
|
|
|
struct go7007_buffer *go7007_vb =
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
container_of(vbuf, struct go7007_buffer, vb);
|
2008-11-12 08:54:30 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&go->spinlock, flags);
|
2013-03-11 17:52:27 +08:00
|
|
|
list_add_tail(&go7007_vb->list, &go->vidq_active);
|
2008-11-12 08:54:30 +08:00
|
|
|
spin_unlock_irqrestore(&go->spinlock, flags);
|
2013-03-11 17:52:27 +08:00
|
|
|
}
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
static int go7007_buf_prepare(struct vb2_buffer *vb)
|
|
|
|
{
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
|
2013-03-11 17:52:27 +08:00
|
|
|
struct go7007_buffer *go7007_vb =
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
container_of(vbuf, struct go7007_buffer, vb);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
go7007_vb->modet_active = 0;
|
|
|
|
go7007_vb->frame_offset = 0;
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vb->planes[0].bytesused = 0;
|
2013-03-11 17:52:27 +08:00
|
|
|
return 0;
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
2014-03-04 18:27:13 +08:00
|
|
|
static void go7007_buf_finish(struct vb2_buffer *vb)
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 17:52:27 +08:00
|
|
|
struct vb2_queue *vq = vb->vb2_queue;
|
|
|
|
struct go7007 *go = vb2_get_drv_priv(vq);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
|
2013-03-11 17:52:27 +08:00
|
|
|
struct go7007_buffer *go7007_vb =
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
container_of(vbuf, struct go7007_buffer, vb);
|
2013-03-11 17:52:27 +08:00
|
|
|
u32 frame_type_flag = get_frame_type_flag(go7007_vb, go->format);
|
|
|
|
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vbuf->flags &= ~(V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_BFRAME |
|
2013-03-11 17:52:27 +08:00
|
|
|
V4L2_BUF_FLAG_PFRAME);
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vbuf->flags |= frame_type_flag;
|
|
|
|
vbuf->field = V4L2_FIELD_NONE;
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
static int go7007_start_streaming(struct vb2_queue *q, unsigned int count)
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 17:52:27 +08:00
|
|
|
struct go7007 *go = vb2_get_drv_priv(q);
|
|
|
|
int ret;
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
set_formatting(go);
|
2009-09-15 22:07:59 +08:00
|
|
|
mutex_lock(&go->hw_lock);
|
2013-03-11 17:52:27 +08:00
|
|
|
go->next_seq = 0;
|
|
|
|
go->active_buf = NULL;
|
2014-06-10 18:39:04 +08:00
|
|
|
go->modet_event_status = 0;
|
2013-03-11 17:52:27 +08:00
|
|
|
q->streaming = 1;
|
|
|
|
if (go7007_start_encoder(go) < 0)
|
|
|
|
ret = -EIO;
|
|
|
|
else
|
|
|
|
ret = 0;
|
2009-09-15 22:07:59 +08:00
|
|
|
mutex_unlock(&go->hw_lock);
|
2013-03-11 17:52:27 +08:00
|
|
|
if (ret) {
|
|
|
|
q->streaming = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
2013-01-16 20:00:51 +08:00
|
|
|
call_all(&go->v4l2_dev, video, s_stream, 1);
|
2013-03-11 16:58:55 +08:00
|
|
|
v4l2_ctrl_grab(go->mpeg_video_gop_size, true);
|
|
|
|
v4l2_ctrl_grab(go->mpeg_video_gop_closure, true);
|
|
|
|
v4l2_ctrl_grab(go->mpeg_video_bitrate, true);
|
|
|
|
v4l2_ctrl_grab(go->mpeg_video_aspect_ratio, true);
|
2013-03-17 21:15:03 +08:00
|
|
|
/* Turn on Capture LED */
|
|
|
|
if (go->board_id == GO7007_BOARDID_ADS_USBAV_709)
|
|
|
|
go7007_write_addr(go, 0x3c82, 0x0005);
|
2013-03-11 17:52:27 +08:00
|
|
|
return ret;
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
2014-04-17 13:47:21 +08:00
|
|
|
static void go7007_stop_streaming(struct vb2_queue *q)
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 17:52:27 +08:00
|
|
|
struct go7007 *go = vb2_get_drv_priv(q);
|
|
|
|
unsigned long flags;
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
q->streaming = 0;
|
|
|
|
go7007_stream_stop(go);
|
|
|
|
mutex_lock(&go->hw_lock);
|
|
|
|
go7007_reset_encoder(go);
|
|
|
|
mutex_unlock(&go->hw_lock);
|
2013-01-16 20:00:51 +08:00
|
|
|
call_all(&go->v4l2_dev, video, s_stream, 0);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
spin_lock_irqsave(&go->spinlock, flags);
|
|
|
|
INIT_LIST_HEAD(&go->vidq_active);
|
|
|
|
spin_unlock_irqrestore(&go->spinlock, flags);
|
|
|
|
v4l2_ctrl_grab(go->mpeg_video_gop_size, false);
|
|
|
|
v4l2_ctrl_grab(go->mpeg_video_gop_closure, false);
|
|
|
|
v4l2_ctrl_grab(go->mpeg_video_bitrate, false);
|
|
|
|
v4l2_ctrl_grab(go->mpeg_video_aspect_ratio, false);
|
2013-03-17 21:15:03 +08:00
|
|
|
/* Turn on Capture LED */
|
|
|
|
if (go->board_id == GO7007_BOARDID_ADS_USBAV_709)
|
|
|
|
go7007_write_addr(go, 0x3c82, 0x000d);
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
2016-09-09 07:59:01 +08:00
|
|
|
static const struct vb2_ops go7007_video_qops = {
|
2013-03-11 17:52:27 +08:00
|
|
|
.queue_setup = go7007_queue_setup,
|
|
|
|
.buf_queue = go7007_buf_queue,
|
|
|
|
.buf_prepare = go7007_buf_prepare,
|
|
|
|
.buf_finish = go7007_buf_finish,
|
|
|
|
.start_streaming = go7007_start_streaming,
|
|
|
|
.stop_streaming = go7007_stop_streaming,
|
|
|
|
.wait_prepare = vb2_ops_wait_prepare,
|
|
|
|
.wait_finish = vb2_ops_wait_finish,
|
|
|
|
};
|
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
static int vidioc_g_parm(struct file *filp, void *priv,
|
|
|
|
struct v4l2_streamparm *parm)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(filp);
|
2008-11-12 08:54:30 +08:00
|
|
|
struct v4l2_fract timeperframe = {
|
|
|
|
.numerator = 1001 * go->fps_scale,
|
|
|
|
.denominator = go->sensor_framerate,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
parm->parm.capture.readbuffers = 2;
|
|
|
|
parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
|
2008-11-12 08:54:30 +08:00
|
|
|
parm->parm.capture.timeperframe = timeperframe;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_s_parm(struct file *filp, void *priv,
|
|
|
|
struct v4l2_streamparm *parm)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(filp);
|
2008-11-12 08:54:30 +08:00
|
|
|
unsigned int n, d;
|
|
|
|
|
|
|
|
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
n = go->sensor_framerate *
|
|
|
|
parm->parm.capture.timeperframe.numerator;
|
|
|
|
d = 1001 * parm->parm.capture.timeperframe.denominator;
|
|
|
|
if (n != 0 && d != 0 && n > d)
|
|
|
|
go->fps_scale = (n + d/2) / d;
|
|
|
|
else
|
|
|
|
go->fps_scale = 1;
|
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
return vidioc_g_parm(filp, priv, parm);
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
2012-03-05 22:49:26 +08:00
|
|
|
/* VIDIOC_ENUMSTD on go7007 were used for enumerating the supported fps and
|
2008-11-12 08:54:30 +08:00
|
|
|
its resolution, when the device is not connected to TV.
|
2012-03-05 22:49:26 +08:00
|
|
|
This is were an API abuse, probably used by the lack of specific IOCTL's to
|
|
|
|
enumerate it, by the time the driver was written.
|
2008-11-12 08:54:30 +08:00
|
|
|
|
|
|
|
However, since kernel 2.6.19, two new ioctls (VIDIOC_ENUM_FRAMEINTERVALS
|
|
|
|
and VIDIOC_ENUM_FRAMESIZES) were added for this purpose.
|
|
|
|
|
2012-03-05 22:49:26 +08:00
|
|
|
The two functions below implement the newer ioctls
|
2008-11-12 08:54:30 +08:00
|
|
|
*/
|
|
|
|
static int vidioc_enum_framesizes(struct file *filp, void *priv,
|
|
|
|
struct v4l2_frmsizeenum *fsize)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(filp);
|
2013-03-11 16:50:21 +08:00
|
|
|
int width, height;
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
if (fsize->index > 2)
|
2008-11-12 08:54:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2013-03-11 16:58:55 +08:00
|
|
|
if (!valid_pixelformat(fsize->pixel_format))
|
2008-11-12 08:54:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
get_resolution(go, &width, &height);
|
2008-11-12 08:54:30 +08:00
|
|
|
fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
|
2013-03-11 16:50:21 +08:00
|
|
|
fsize->discrete.width = (width >> fsize->index) & ~0xf;
|
|
|
|
fsize->discrete.height = (height >> fsize->index) & ~0xf;
|
2008-11-12 08:54:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_enum_frameintervals(struct file *filp, void *priv,
|
|
|
|
struct v4l2_frmivalenum *fival)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(filp);
|
2013-03-11 16:50:21 +08:00
|
|
|
int width, height;
|
|
|
|
int i;
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
if (fival->index > 4)
|
2008-11-12 08:54:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2013-03-11 16:58:55 +08:00
|
|
|
if (!valid_pixelformat(fival->pixel_format))
|
2008-11-12 08:54:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
if (!(go->board_info->sensor_flags & GO7007_SENSOR_SCALING)) {
|
|
|
|
get_resolution(go, &width, &height);
|
|
|
|
for (i = 0; i <= 2; i++)
|
|
|
|
if (fival->width == ((width >> i) & ~0xf) &&
|
|
|
|
fival->height == ((height >> i) & ~0xf))
|
|
|
|
break;
|
|
|
|
if (i > 2)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2008-11-12 08:54:30 +08:00
|
|
|
fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
|
2013-03-11 16:50:21 +08:00
|
|
|
fival->discrete.numerator = 1001 * (fival->index + 1);
|
|
|
|
fival->discrete.denominator = go->sensor_framerate;
|
2008-11-12 08:54:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-19 08:59:29 +08:00
|
|
|
static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *std)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2009-09-19 08:59:29 +08:00
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
*std = go->std;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int go7007_s_std(struct go7007 *go)
|
|
|
|
{
|
2013-03-12 05:58:21 +08:00
|
|
|
if (go->std & V4L2_STD_625_50) {
|
2013-03-11 16:50:21 +08:00
|
|
|
go->standard = GO7007_STD_PAL;
|
|
|
|
go->sensor_framerate = 25025;
|
2013-03-12 05:58:21 +08:00
|
|
|
} else {
|
|
|
|
go->standard = GO7007_STD_NTSC;
|
|
|
|
go->sensor_framerate = 30000;
|
2009-09-19 08:59:29 +08:00
|
|
|
}
|
|
|
|
|
2014-04-29 03:53:01 +08:00
|
|
|
call_all(&go->v4l2_dev, video, s_std, go->std);
|
2013-03-11 16:50:21 +08:00
|
|
|
set_capture_size(go, NULL, 0);
|
2009-09-19 08:59:29 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-15 17:10:40 +08:00
|
|
|
static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id std)
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 16:50:21 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
if (vb2_is_busy(&go->vidq))
|
2008-11-12 08:54:30 +08:00
|
|
|
return -EBUSY;
|
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
go->std = std;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
return go7007_s_std(go);
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
2008-10-31 03:56:33 +08:00
|
|
|
|
2009-09-19 08:59:29 +08:00
|
|
|
static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *std)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
return call_all(&go->v4l2_dev, video, querystd, std);
|
2009-09-19 08:59:29 +08:00
|
|
|
}
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
static int vidioc_enum_input(struct file *file, void *priv,
|
|
|
|
struct v4l2_input *inp)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
if (inp->index >= go->board_info->num_inputs)
|
|
|
|
return -EINVAL;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2018-05-14 20:37:17 +08:00
|
|
|
strlcpy(inp->name, go->board_info->inputs[inp->index].name,
|
2008-11-12 08:54:30 +08:00
|
|
|
sizeof(inp->name));
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-09 20:25:47 +08:00
|
|
|
/* If this board has a tuner, it will be the first input */
|
2008-11-12 08:54:30 +08:00
|
|
|
if ((go->board_info->flags & GO7007_BOARD_HAS_TUNER) &&
|
2013-03-09 20:25:47 +08:00
|
|
|
inp->index == 0)
|
2008-11-12 08:54:30 +08:00
|
|
|
inp->type = V4L2_INPUT_TYPE_TUNER;
|
|
|
|
else
|
|
|
|
inp->type = V4L2_INPUT_TYPE_CAMERA;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-10 00:19:08 +08:00
|
|
|
if (go->board_info->num_aud_inputs)
|
|
|
|
inp->audioset = (1 << go->board_info->num_aud_inputs) - 1;
|
|
|
|
else
|
|
|
|
inp->audioset = 0;
|
2008-11-12 08:54:30 +08:00
|
|
|
inp->tuner = 0;
|
|
|
|
if (go->board_info->sensor_flags & GO7007_SENSOR_TV)
|
2013-03-11 16:50:21 +08:00
|
|
|
inp->std = video_devdata(file)->tvnorms;
|
2008-11-12 08:54:30 +08:00
|
|
|
else
|
|
|
|
inp->std = 0;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-02-16 08:53:09 +08:00
|
|
|
|
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
static int vidioc_g_input(struct file *file, void *priv, unsigned int *input)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
*input = go->input;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-10 00:19:08 +08:00
|
|
|
static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a)
|
|
|
|
{
|
|
|
|
struct go7007 *go = video_drvdata(file);
|
|
|
|
|
|
|
|
if (a->index >= go->board_info->num_aud_inputs)
|
|
|
|
return -EINVAL;
|
2014-03-16 01:10:16 +08:00
|
|
|
strlcpy(a->name, go->board_info->aud_inputs[a->index].name,
|
|
|
|
sizeof(a->name));
|
2013-03-10 00:19:08 +08:00
|
|
|
a->capability = V4L2_AUDCAP_STEREO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a)
|
|
|
|
{
|
|
|
|
struct go7007 *go = video_drvdata(file);
|
|
|
|
|
|
|
|
a->index = go->aud_input;
|
2014-03-16 01:10:16 +08:00
|
|
|
strlcpy(a->name, go->board_info->aud_inputs[go->aud_input].name,
|
|
|
|
sizeof(a->name));
|
2013-03-10 00:19:08 +08:00
|
|
|
a->capability = V4L2_AUDCAP_STEREO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-16 01:10:16 +08:00
|
|
|
static int vidioc_s_audio(struct file *file, void *fh,
|
|
|
|
const struct v4l2_audio *a)
|
2013-03-10 00:19:08 +08:00
|
|
|
{
|
|
|
|
struct go7007 *go = video_drvdata(file);
|
|
|
|
|
|
|
|
if (a->index >= go->board_info->num_aud_inputs)
|
|
|
|
return -EINVAL;
|
|
|
|
go->aud_input = a->index;
|
|
|
|
v4l2_subdev_call(go->sd_audio, audio, s_routing,
|
2014-03-16 01:10:16 +08:00
|
|
|
go->board_info->aud_inputs[go->aud_input].audio_input, 0, 0);
|
2013-03-10 00:19:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
static void go7007_s_input(struct go7007 *go)
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 16:50:21 +08:00
|
|
|
unsigned int input = go->input;
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2013-03-09 20:25:47 +08:00
|
|
|
v4l2_subdev_call(go->sd_video, video, s_routing,
|
|
|
|
go->board_info->inputs[input].video_input, 0,
|
|
|
|
go->board_info->video_config);
|
|
|
|
if (go->board_info->num_aud_inputs) {
|
|
|
|
int aud_input = go->board_info->inputs[input].audio_index;
|
|
|
|
|
|
|
|
v4l2_subdev_call(go->sd_audio, audio, s_routing,
|
|
|
|
go->board_info->aud_inputs[aud_input].audio_input, 0, 0);
|
|
|
|
go->aud_input = aud_input;
|
|
|
|
}
|
2013-03-11 16:50:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_s_input(struct file *file, void *priv, unsigned int input)
|
|
|
|
{
|
|
|
|
struct go7007 *go = video_drvdata(file);
|
|
|
|
|
|
|
|
if (input >= go->board_info->num_inputs)
|
|
|
|
return -EINVAL;
|
2013-03-11 17:52:27 +08:00
|
|
|
if (vb2_is_busy(&go->vidq))
|
2013-03-11 16:50:21 +08:00
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
go->input = input;
|
|
|
|
go7007_s_input(go);
|
|
|
|
|
2013-03-09 20:25:47 +08:00
|
|
|
return 0;
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_g_tuner(struct file *file, void *priv,
|
|
|
|
struct v4l2_tuner *t)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
|
|
|
if (t->index != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2013-03-10 00:14:32 +08:00
|
|
|
strlcpy(t->name, "Tuner", sizeof(t->name));
|
2009-11-17 02:16:00 +08:00
|
|
|
return call_all(&go->v4l2_dev, tuner, g_tuner, t);
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_s_tuner(struct file *file, void *priv,
|
2013-03-15 17:10:06 +08:00
|
|
|
const struct v4l2_tuner *t)
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
|
|
|
if (t->index != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-11-17 02:16:00 +08:00
|
|
|
return call_all(&go->v4l2_dev, tuner, s_tuner, t);
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_g_frequency(struct file *file, void *priv,
|
|
|
|
struct v4l2_frequency *f)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
if (f->tuner)
|
2008-11-12 08:54:30 +08:00
|
|
|
return -EINVAL;
|
2009-11-17 02:16:00 +08:00
|
|
|
|
|
|
|
return call_all(&go->v4l2_dev, tuner, g_frequency, f);
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_s_frequency(struct file *file, void *priv,
|
2013-03-19 15:09:26 +08:00
|
|
|
const struct v4l2_frequency *f)
|
2008-11-12 08:54:30 +08:00
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2008-11-12 08:54:30 +08:00
|
|
|
|
2013-03-11 16:50:21 +08:00
|
|
|
if (f->tuner)
|
2008-11-12 08:54:30 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-11-17 02:16:00 +08:00
|
|
|
return call_all(&go->v4l2_dev, tuner, s_frequency, f);
|
2008-11-12 08:54:30 +08:00
|
|
|
}
|
|
|
|
|
2013-03-09 22:25:09 +08:00
|
|
|
static int vidioc_log_status(struct file *file, void *priv)
|
|
|
|
{
|
2013-03-11 17:18:20 +08:00
|
|
|
struct go7007 *go = video_drvdata(file);
|
2013-03-09 22:25:09 +08:00
|
|
|
|
|
|
|
v4l2_ctrl_log_status(file, priv);
|
|
|
|
return call_all(&go->v4l2_dev, core, log_status);
|
|
|
|
}
|
|
|
|
|
2014-06-10 18:39:04 +08:00
|
|
|
static int vidioc_subscribe_event(struct v4l2_fh *fh,
|
|
|
|
const struct v4l2_event_subscription *sub)
|
|
|
|
{
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2014-06-10 18:39:04 +08:00
|
|
|
switch (sub->type) {
|
|
|
|
case V4L2_EVENT_MOTION_DET:
|
|
|
|
/* Allow for up to 30 events (1 second for NTSC) to be
|
|
|
|
* stored. */
|
|
|
|
return v4l2_event_subscribe(fh, sub, 30, NULL);
|
2017-02-16 01:55:33 +08:00
|
|
|
default:
|
|
|
|
return v4l2_ctrl_subscribe_event(fh, sub);
|
2008-02-16 08:53:09 +08:00
|
|
|
}
|
2014-06-10 18:39:04 +08:00
|
|
|
}
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2014-06-10 18:39:04 +08:00
|
|
|
|
|
|
|
static int go7007_s_ctrl(struct v4l2_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
struct go7007 *go =
|
|
|
|
container_of(ctrl->handler, struct go7007, hdl);
|
|
|
|
unsigned y;
|
|
|
|
u8 *mt;
|
|
|
|
|
|
|
|
switch (ctrl->id) {
|
|
|
|
case V4L2_CID_PIXEL_THRESHOLD0:
|
|
|
|
go->modet[0].pixel_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_MOTION_THRESHOLD0:
|
|
|
|
go->modet[0].motion_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_MB_THRESHOLD0:
|
|
|
|
go->modet[0].mb_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PIXEL_THRESHOLD1:
|
|
|
|
go->modet[1].pixel_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_MOTION_THRESHOLD1:
|
|
|
|
go->modet[1].motion_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_MB_THRESHOLD1:
|
|
|
|
go->modet[1].mb_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PIXEL_THRESHOLD2:
|
|
|
|
go->modet[2].pixel_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_MOTION_THRESHOLD2:
|
|
|
|
go->modet[2].motion_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_MB_THRESHOLD2:
|
|
|
|
go->modet[2].mb_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PIXEL_THRESHOLD3:
|
|
|
|
go->modet[3].pixel_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_MOTION_THRESHOLD3:
|
|
|
|
go->modet[3].motion_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_MB_THRESHOLD3:
|
|
|
|
go->modet[3].mb_threshold = ctrl->val;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_DETECT_MD_REGION_GRID:
|
|
|
|
mt = go->modet_map;
|
|
|
|
for (y = 0; y < go->height / 16; y++, mt += go->width / 16)
|
|
|
|
memcpy(mt, ctrl->p_new.p_u8 + y * (720 / 16), go->width / 16);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
2008-02-16 08:53:09 +08:00
|
|
|
}
|
2014-06-10 18:39:04 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-02-16 08:53:09 +08:00
|
|
|
|
2017-06-29 14:55:23 +08:00
|
|
|
static const struct v4l2_file_operations go7007_fops = {
|
2008-02-16 08:53:09 +08:00
|
|
|
.owner = THIS_MODULE,
|
2013-03-11 17:18:20 +08:00
|
|
|
.open = v4l2_fh_open,
|
2013-03-11 17:52:27 +08:00
|
|
|
.release = vb2_fop_release,
|
|
|
|
.unlocked_ioctl = video_ioctl2,
|
|
|
|
.read = vb2_fop_read,
|
|
|
|
.mmap = vb2_fop_mmap,
|
|
|
|
.poll = vb2_fop_poll,
|
2008-02-16 08:53:09 +08:00
|
|
|
};
|
|
|
|
|
2008-11-12 08:54:30 +08:00
|
|
|
static const struct v4l2_ioctl_ops video_ioctl_ops = {
|
|
|
|
.vidioc_querycap = vidioc_querycap,
|
|
|
|
.vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
|
|
|
|
.vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
|
|
|
|
.vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,
|
|
|
|
.vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
|
2013-03-11 17:52:27 +08:00
|
|
|
.vidioc_reqbufs = vb2_ioctl_reqbufs,
|
|
|
|
.vidioc_querybuf = vb2_ioctl_querybuf,
|
|
|
|
.vidioc_qbuf = vb2_ioctl_qbuf,
|
|
|
|
.vidioc_dqbuf = vb2_ioctl_dqbuf,
|
2009-09-19 08:59:29 +08:00
|
|
|
.vidioc_g_std = vidioc_g_std,
|
2008-11-12 08:54:30 +08:00
|
|
|
.vidioc_s_std = vidioc_s_std,
|
2009-09-19 08:59:29 +08:00
|
|
|
.vidioc_querystd = vidioc_querystd,
|
2008-11-12 08:54:30 +08:00
|
|
|
.vidioc_enum_input = vidioc_enum_input,
|
|
|
|
.vidioc_g_input = vidioc_g_input,
|
|
|
|
.vidioc_s_input = vidioc_s_input,
|
2013-03-10 00:19:08 +08:00
|
|
|
.vidioc_enumaudio = vidioc_enumaudio,
|
|
|
|
.vidioc_g_audio = vidioc_g_audio,
|
|
|
|
.vidioc_s_audio = vidioc_s_audio,
|
2013-03-11 17:52:27 +08:00
|
|
|
.vidioc_streamon = vb2_ioctl_streamon,
|
|
|
|
.vidioc_streamoff = vb2_ioctl_streamoff,
|
2008-11-12 08:54:30 +08:00
|
|
|
.vidioc_g_tuner = vidioc_g_tuner,
|
|
|
|
.vidioc_s_tuner = vidioc_s_tuner,
|
|
|
|
.vidioc_g_frequency = vidioc_g_frequency,
|
|
|
|
.vidioc_s_frequency = vidioc_s_frequency,
|
|
|
|
.vidioc_g_parm = vidioc_g_parm,
|
|
|
|
.vidioc_s_parm = vidioc_s_parm,
|
|
|
|
.vidioc_enum_framesizes = vidioc_enum_framesizes,
|
|
|
|
.vidioc_enum_frameintervals = vidioc_enum_frameintervals,
|
2013-03-09 22:25:09 +08:00
|
|
|
.vidioc_log_status = vidioc_log_status,
|
2014-06-10 18:39:04 +08:00
|
|
|
.vidioc_subscribe_event = vidioc_subscribe_event,
|
2013-03-09 22:08:41 +08:00
|
|
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
2008-11-12 08:54:30 +08:00
|
|
|
};
|
|
|
|
|
2017-08-26 21:11:30 +08:00
|
|
|
static const struct video_device go7007_template = {
|
2008-02-16 08:53:09 +08:00
|
|
|
.name = "go7007",
|
|
|
|
.fops = &go7007_fops,
|
2013-03-11 17:34:22 +08:00
|
|
|
.release = video_device_release_empty,
|
2008-11-12 08:54:30 +08:00
|
|
|
.ioctl_ops = &video_ioctl_ops,
|
|
|
|
.tvnorms = V4L2_STD_ALL,
|
2008-02-16 08:53:09 +08:00
|
|
|
};
|
|
|
|
|
2014-06-10 18:39:04 +08:00
|
|
|
static const struct v4l2_ctrl_ops go7007_ctrl_ops = {
|
|
|
|
.s_ctrl = go7007_s_ctrl,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_pixel_threshold0_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PIXEL_THRESHOLD0,
|
|
|
|
.name = "Pixel Threshold Region 0",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 20,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_motion_threshold0_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MOTION_THRESHOLD0,
|
|
|
|
.name = "Motion Threshold Region 0",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 80,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_mb_threshold0_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MB_THRESHOLD0,
|
|
|
|
.name = "MB Threshold Region 0",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 200,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_pixel_threshold1_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PIXEL_THRESHOLD1,
|
|
|
|
.name = "Pixel Threshold Region 1",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 20,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_motion_threshold1_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MOTION_THRESHOLD1,
|
|
|
|
.name = "Motion Threshold Region 1",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 80,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_mb_threshold1_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MB_THRESHOLD1,
|
|
|
|
.name = "MB Threshold Region 1",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 200,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_pixel_threshold2_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PIXEL_THRESHOLD2,
|
|
|
|
.name = "Pixel Threshold Region 2",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 20,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_motion_threshold2_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MOTION_THRESHOLD2,
|
|
|
|
.name = "Motion Threshold Region 2",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 80,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_mb_threshold2_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MB_THRESHOLD2,
|
|
|
|
.name = "MB Threshold Region 2",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 200,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_pixel_threshold3_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PIXEL_THRESHOLD3,
|
|
|
|
.name = "Pixel Threshold Region 3",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 20,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_motion_threshold3_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MOTION_THRESHOLD3,
|
|
|
|
.name = "Motion Threshold Region 3",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 80,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_mb_threshold3_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MB_THRESHOLD3,
|
|
|
|
.name = "MB Threshold Region 3",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.def = 200,
|
|
|
|
.max = 32767,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config go7007_mb_regions_ctrl = {
|
|
|
|
.ops = &go7007_ctrl_ops,
|
|
|
|
.id = V4L2_CID_DETECT_MD_REGION_GRID,
|
|
|
|
.dims = { 576 / 16, 720 / 16 },
|
|
|
|
.max = 3,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
2013-03-11 16:19:59 +08:00
|
|
|
int go7007_v4l2_ctrl_init(struct go7007 *go)
|
|
|
|
{
|
|
|
|
struct v4l2_ctrl_handler *hdl = &go->hdl;
|
|
|
|
struct v4l2_ctrl *ctrl;
|
|
|
|
|
2014-06-10 18:39:04 +08:00
|
|
|
v4l2_ctrl_handler_init(hdl, 22);
|
2013-03-11 16:58:55 +08:00
|
|
|
go->mpeg_video_gop_size = v4l2_ctrl_new_std(hdl, NULL,
|
2013-03-11 16:19:59 +08:00
|
|
|
V4L2_CID_MPEG_VIDEO_GOP_SIZE, 0, 34, 1, 15);
|
2013-03-11 16:58:55 +08:00
|
|
|
go->mpeg_video_gop_closure = v4l2_ctrl_new_std(hdl, NULL,
|
|
|
|
V4L2_CID_MPEG_VIDEO_GOP_CLOSURE, 0, 1, 1, 1);
|
|
|
|
go->mpeg_video_bitrate = v4l2_ctrl_new_std(hdl, NULL,
|
2013-03-11 16:19:59 +08:00
|
|
|
V4L2_CID_MPEG_VIDEO_BITRATE,
|
2013-03-11 16:58:55 +08:00
|
|
|
64000, 10000000, 1, 9800000);
|
2013-03-17 18:16:37 +08:00
|
|
|
go->mpeg_video_b_frames = v4l2_ctrl_new_std(hdl, NULL,
|
|
|
|
V4L2_CID_MPEG_VIDEO_B_FRAMES, 0, 2, 2, 0);
|
2013-03-17 21:47:02 +08:00
|
|
|
go->mpeg_video_rep_seqheader = v4l2_ctrl_new_std(hdl, NULL,
|
|
|
|
V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER, 0, 1, 1, 1);
|
2013-03-17 18:16:37 +08:00
|
|
|
|
2013-03-11 16:58:55 +08:00
|
|
|
go->mpeg_video_aspect_ratio = v4l2_ctrl_new_std_menu(hdl, NULL,
|
|
|
|
V4L2_CID_MPEG_VIDEO_ASPECT,
|
|
|
|
V4L2_MPEG_VIDEO_ASPECT_16x9, 0,
|
|
|
|
V4L2_MPEG_VIDEO_ASPECT_1x1);
|
|
|
|
ctrl = v4l2_ctrl_new_std(hdl, NULL,
|
2013-03-11 16:19:59 +08:00
|
|
|
V4L2_CID_JPEG_ACTIVE_MARKER, 0,
|
2014-03-16 01:10:16 +08:00
|
|
|
V4L2_JPEG_ACTIVE_MARKER_DQT |
|
|
|
|
V4L2_JPEG_ACTIVE_MARKER_DHT, 0,
|
|
|
|
V4L2_JPEG_ACTIVE_MARKER_DQT |
|
|
|
|
V4L2_JPEG_ACTIVE_MARKER_DHT);
|
2013-03-11 16:19:59 +08:00
|
|
|
if (ctrl)
|
|
|
|
ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
2014-06-10 18:39:04 +08:00
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_pixel_threshold0_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_motion_threshold0_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_mb_threshold0_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_pixel_threshold1_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_motion_threshold1_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_mb_threshold1_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_pixel_threshold2_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_motion_threshold2_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_mb_threshold2_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_pixel_threshold3_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_motion_threshold3_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_mb_threshold3_ctrl, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &go7007_mb_regions_ctrl, NULL);
|
|
|
|
go->modet_mode = v4l2_ctrl_new_std_menu(hdl, NULL,
|
|
|
|
V4L2_CID_DETECT_MD_MODE,
|
|
|
|
V4L2_DETECT_MD_MODE_REGION_GRID,
|
|
|
|
1 << V4L2_DETECT_MD_MODE_THRESHOLD_GRID,
|
|
|
|
V4L2_DETECT_MD_MODE_DISABLED);
|
2013-03-11 16:19:59 +08:00
|
|
|
if (hdl->error) {
|
|
|
|
int rv = hdl->error;
|
|
|
|
|
|
|
|
v4l2_err(&go->v4l2_dev, "Could not register controls\n");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
go->v4l2_dev.ctrl_handler = hdl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-16 08:53:09 +08:00
|
|
|
int go7007_v4l2_init(struct go7007 *go)
|
|
|
|
{
|
2013-03-11 17:34:22 +08:00
|
|
|
struct video_device *vdev = &go->vdev;
|
2008-02-16 08:53:09 +08:00
|
|
|
int rv;
|
|
|
|
|
2013-03-11 17:52:27 +08:00
|
|
|
mutex_init(&go->serialize_lock);
|
|
|
|
mutex_init(&go->queue_lock);
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&go->vidq_active);
|
|
|
|
go->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
go->vidq.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
|
|
|
|
go->vidq.ops = &go7007_video_qops;
|
|
|
|
go->vidq.mem_ops = &vb2_vmalloc_memops;
|
|
|
|
go->vidq.drv_priv = go;
|
|
|
|
go->vidq.buf_struct_size = sizeof(struct go7007_buffer);
|
2014-02-26 06:12:19 +08:00
|
|
|
go->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
|
2013-03-11 17:52:27 +08:00
|
|
|
go->vidq.lock = &go->queue_lock;
|
|
|
|
rv = vb2_queue_init(&go->vidq);
|
|
|
|
if (rv)
|
|
|
|
return rv;
|
2013-03-11 17:34:22 +08:00
|
|
|
*vdev = go7007_template;
|
|
|
|
vdev->lock = &go->serialize_lock;
|
|
|
|
vdev->queue = &go->vidq;
|
|
|
|
video_set_drvdata(vdev, go);
|
|
|
|
vdev->v4l2_dev = &go->v4l2_dev;
|
2016-04-04 04:44:16 +08:00
|
|
|
if (!v4l2_device_has_op(&go->v4l2_dev, 0, video, querystd))
|
2013-03-11 17:34:22 +08:00
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_QUERYSTD);
|
2013-03-11 16:50:21 +08:00
|
|
|
if (!(go->board_info->flags & GO7007_BOARD_HAS_TUNER)) {
|
2013-03-11 17:34:22 +08:00
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_S_FREQUENCY);
|
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_G_FREQUENCY);
|
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_S_TUNER);
|
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_G_TUNER);
|
2013-03-11 16:50:21 +08:00
|
|
|
} else {
|
|
|
|
struct v4l2_frequency f = {
|
|
|
|
.type = V4L2_TUNER_ANALOG_TV,
|
|
|
|
.frequency = 980,
|
|
|
|
};
|
|
|
|
|
|
|
|
call_all(&go->v4l2_dev, tuner, s_frequency, &f);
|
|
|
|
}
|
|
|
|
if (!(go->board_info->sensor_flags & GO7007_SENSOR_TV)) {
|
2013-03-11 17:34:22 +08:00
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_G_STD);
|
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_S_STD);
|
|
|
|
vdev->tvnorms = 0;
|
2008-02-16 08:53:09 +08:00
|
|
|
}
|
2013-03-11 16:50:21 +08:00
|
|
|
if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING)
|
2013-03-11 17:34:22 +08:00
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_ENUM_FRAMESIZES);
|
2013-03-10 00:19:08 +08:00
|
|
|
if (go->board_info->num_aud_inputs == 0) {
|
2013-03-11 17:34:22 +08:00
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_G_AUDIO);
|
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_S_AUDIO);
|
|
|
|
v4l2_disable_ioctl(vdev, VIDIOC_ENUMAUDIO);
|
2013-03-10 00:19:08 +08:00
|
|
|
}
|
2013-03-11 17:12:10 +08:00
|
|
|
/* Setup correct crystal frequency on this board */
|
|
|
|
if (go->board_info->sensor_flags & GO7007_SENSOR_SAA7115)
|
|
|
|
v4l2_subdev_call(go->sd_video, video, s_crystal_freq,
|
|
|
|
SAA7115_FREQ_24_576_MHZ,
|
|
|
|
SAA7115_FREQ_FL_APLL | SAA7115_FREQ_FL_UCGC |
|
|
|
|
SAA7115_FREQ_FL_DOUBLE_ASCLK);
|
2013-03-11 16:50:21 +08:00
|
|
|
go7007_s_input(go);
|
|
|
|
if (go->board_info->sensor_flags & GO7007_SENSOR_TV)
|
|
|
|
go7007_s_std(go);
|
2013-03-11 17:34:22 +08:00
|
|
|
rv = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
|
|
|
|
if (rv < 0)
|
2013-03-11 16:50:21 +08:00
|
|
|
return rv;
|
2012-11-06 19:34:20 +08:00
|
|
|
dev_info(go->dev, "registered device %s [v4l2]\n",
|
2013-03-11 17:34:22 +08:00
|
|
|
video_device_node_name(vdev));
|
2008-02-16 08:53:09 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void go7007_v4l2_remove(struct go7007 *go)
|
|
|
|
{
|
2013-03-11 16:19:59 +08:00
|
|
|
v4l2_ctrl_handler_free(&go->hdl);
|
2008-02-16 08:53:09 +08:00
|
|
|
}
|