mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 00:51:35 +00:00
V4L/DVB (7666): meye: Replace meye_do_ioctl to use video_ioctl2
Convert meye to use video_ioctl2 Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
130ca945d8
commit
6ec6e0ced1
1 changed files with 722 additions and 777 deletions
|
@ -42,15 +42,10 @@
|
||||||
#include <linux/meye.h>
|
#include <linux/meye.h>
|
||||||
|
|
||||||
MODULE_AUTHOR("Stelian Pop <stelian@popies.net>");
|
MODULE_AUTHOR("Stelian Pop <stelian@popies.net>");
|
||||||
MODULE_DESCRIPTION("v4l/v4l2 driver for the MotionEye camera");
|
MODULE_DESCRIPTION("v4l2 driver for the MotionEye camera");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
MODULE_VERSION(MEYE_DRIVER_VERSION);
|
MODULE_VERSION(MEYE_DRIVER_VERSION);
|
||||||
|
|
||||||
/* force usage of V4L1 API */
|
|
||||||
static int forcev4l1; /* = 0 */
|
|
||||||
module_param(forcev4l1, int, 0644);
|
|
||||||
MODULE_PARM_DESC(forcev4l1, "force use of V4L1 instead of V4L2");
|
|
||||||
|
|
||||||
/* number of grab buffers */
|
/* number of grab buffers */
|
||||||
static unsigned int gbuffers = 2;
|
static unsigned int gbuffers = 2;
|
||||||
module_param(gbuffers, int, 0444);
|
module_param(gbuffers, int, 0444);
|
||||||
|
@ -876,172 +871,32 @@ static int meye_release(struct inode *inode, struct file *file)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int meye_do_ioctl(struct inode *inode, struct file *file,
|
static int meyeioc_g_params(struct meye_params *p)
|
||||||
unsigned int cmd, void *arg)
|
|
||||||
{
|
{
|
||||||
switch (cmd) {
|
|
||||||
|
|
||||||
case VIDIOCGCAP: {
|
|
||||||
struct video_capability *b = arg;
|
|
||||||
strcpy(b->name,meye.video_dev->name);
|
|
||||||
b->type = VID_TYPE_CAPTURE;
|
|
||||||
b->channels = 1;
|
|
||||||
b->audios = 0;
|
|
||||||
b->maxwidth = 640;
|
|
||||||
b->maxheight = 480;
|
|
||||||
b->minwidth = 320;
|
|
||||||
b->minheight = 240;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOCGCHAN: {
|
|
||||||
struct video_channel *v = arg;
|
|
||||||
v->flags = 0;
|
|
||||||
v->tuners = 0;
|
|
||||||
v->type = VIDEO_TYPE_CAMERA;
|
|
||||||
if (v->channel != 0)
|
|
||||||
return -EINVAL;
|
|
||||||
strcpy(v->name,"Camera");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOCSCHAN: {
|
|
||||||
struct video_channel *v = arg;
|
|
||||||
if (v->channel != 0)
|
|
||||||
return -EINVAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOCGPICT: {
|
|
||||||
struct video_picture *p = arg;
|
|
||||||
*p = meye.picture;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOCSPICT: {
|
|
||||||
struct video_picture *p = arg;
|
|
||||||
if (p->depth != 16)
|
|
||||||
return -EINVAL;
|
|
||||||
if (p->palette != VIDEO_PALETTE_YUV422 && p->palette != VIDEO_PALETTE_YUYV)
|
|
||||||
return -EINVAL;
|
|
||||||
mutex_lock(&meye.lock);
|
|
||||||
sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERABRIGHTNESS,
|
|
||||||
p->brightness >> 10);
|
|
||||||
sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAHUE,
|
|
||||||
p->hue >> 10);
|
|
||||||
sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERACOLOR,
|
|
||||||
p->colour >> 10);
|
|
||||||
sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERACONTRAST,
|
|
||||||
p->contrast >> 10);
|
|
||||||
meye.picture = *p;
|
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOCSYNC: {
|
|
||||||
int *i = arg;
|
|
||||||
int unused;
|
|
||||||
|
|
||||||
if (*i < 0 || *i >= gbuffers)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
|
||||||
|
|
||||||
switch (meye.grab_buffer[*i].state) {
|
|
||||||
|
|
||||||
case MEYE_BUF_UNUSED:
|
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
return -EINVAL;
|
|
||||||
case MEYE_BUF_USING:
|
|
||||||
if (file->f_flags & O_NONBLOCK) {
|
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
return -EAGAIN;
|
|
||||||
}
|
|
||||||
if (wait_event_interruptible(meye.proc_list,
|
|
||||||
(meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
|
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
return -EINTR;
|
|
||||||
}
|
|
||||||
/* fall through */
|
|
||||||
case MEYE_BUF_DONE:
|
|
||||||
meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
|
|
||||||
kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int));
|
|
||||||
}
|
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOCMCAPTURE: {
|
|
||||||
struct video_mmap *vm = arg;
|
|
||||||
int restart = 0;
|
|
||||||
|
|
||||||
if (vm->frame >= gbuffers || vm->frame < 0)
|
|
||||||
return -EINVAL;
|
|
||||||
if (vm->format != VIDEO_PALETTE_YUV422 && vm->format != VIDEO_PALETTE_YUYV)
|
|
||||||
return -EINVAL;
|
|
||||||
if (vm->height * vm->width * 2 > gbufsize)
|
|
||||||
return -EINVAL;
|
|
||||||
if (!meye.grab_fbuffer)
|
|
||||||
return -EINVAL;
|
|
||||||
if (meye.grab_buffer[vm->frame].state != MEYE_BUF_UNUSED)
|
|
||||||
return -EBUSY;
|
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
|
||||||
if (vm->width == 640 && vm->height == 480) {
|
|
||||||
if (meye.params.subsample) {
|
|
||||||
meye.params.subsample = 0;
|
|
||||||
restart = 1;
|
|
||||||
}
|
|
||||||
} else if (vm->width == 320 && vm->height == 240) {
|
|
||||||
if (!meye.params.subsample) {
|
|
||||||
meye.params.subsample = 1;
|
|
||||||
restart = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (restart || meye.mchip_mode != MCHIP_HIC_MODE_CONT_OUT)
|
|
||||||
mchip_continuous_start();
|
|
||||||
meye.grab_buffer[vm->frame].state = MEYE_BUF_USING;
|
|
||||||
kfifo_put(meye.grabq, (unsigned char *)&vm->frame, sizeof(int));
|
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOCGMBUF: {
|
|
||||||
struct video_mbuf *vm = arg;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
memset(vm, 0 , sizeof(*vm));
|
|
||||||
vm->size = gbufsize * gbuffers;
|
|
||||||
vm->frames = gbuffers;
|
|
||||||
for (i = 0; i < gbuffers; i++)
|
|
||||||
vm->offsets[i] = i * gbufsize;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MEYEIOC_G_PARAMS: {
|
|
||||||
struct meye_params *p = arg;
|
|
||||||
*p = meye.params;
|
*p = meye.params;
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MEYEIOC_S_PARAMS: {
|
static int meyeioc_s_params(struct meye_params *jp)
|
||||||
struct meye_params *jp = arg;
|
{
|
||||||
if (jp->subsample > 1)
|
if (jp->subsample > 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (jp->quality > 10)
|
if (jp->quality > 10)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (jp->sharpness > 63 || jp->agc > 63 || jp->picture > 63)
|
if (jp->sharpness > 63 || jp->agc > 63 || jp->picture > 63)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (jp->framerate > 31)
|
if (jp->framerate > 31)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
|
|
||||||
if (meye.params.subsample != jp->subsample ||
|
if (meye.params.subsample != jp->subsample ||
|
||||||
meye.params.quality != jp->quality)
|
meye.params.quality != jp->quality)
|
||||||
mchip_hic_stop(); /* need restart */
|
mchip_hic_stop(); /* need restart */
|
||||||
|
|
||||||
meye.params = *jp;
|
meye.params = *jp;
|
||||||
sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERASHARPNESS,
|
sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERASHARPNESS,
|
||||||
meye.params.sharpness);
|
meye.params.sharpness);
|
||||||
|
@ -1050,34 +905,41 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE,
|
sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE,
|
||||||
meye.params.picture);
|
meye.params.picture);
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MEYEIOC_QBUF_CAPT: {
|
return 0;
|
||||||
int *nb = arg;
|
}
|
||||||
|
|
||||||
|
static int meyeioc_qbuf_capt(int *nb)
|
||||||
|
{
|
||||||
if (!meye.grab_fbuffer)
|
if (!meye.grab_fbuffer)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (*nb >= gbuffers)
|
if (*nb >= gbuffers)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (*nb < 0) {
|
if (*nb < 0) {
|
||||||
/* stop capture */
|
/* stop capture */
|
||||||
mchip_hic_stop();
|
mchip_hic_stop();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meye.grab_buffer[*nb].state != MEYE_BUF_UNUSED)
|
if (meye.grab_buffer[*nb].state != MEYE_BUF_UNUSED)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
|
|
||||||
if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP)
|
if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP)
|
||||||
mchip_cont_compression_start();
|
mchip_cont_compression_start();
|
||||||
|
|
||||||
meye.grab_buffer[*nb].state = MEYE_BUF_USING;
|
meye.grab_buffer[*nb].state = MEYE_BUF_USING;
|
||||||
kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int));
|
kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int));
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MEYEIOC_SYNC: {
|
return 0;
|
||||||
int *i = arg;
|
}
|
||||||
|
|
||||||
|
static int meyeioc_sync(struct file *file, void *fh, int *i)
|
||||||
|
{
|
||||||
int unused;
|
int unused;
|
||||||
|
|
||||||
if (*i < 0 || *i >= gbuffers)
|
if (*i < 0 || *i >= gbuffers)
|
||||||
|
@ -1106,92 +968,99 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
}
|
}
|
||||||
*i = meye.grab_buffer[*i].size;
|
*i = meye.grab_buffer[*i].size;
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MEYEIOC_STILLCAPT: {
|
|
||||||
|
|
||||||
|
static int meyeioc_stillcapt(void)
|
||||||
|
{
|
||||||
if (!meye.grab_fbuffer)
|
if (!meye.grab_fbuffer)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED)
|
if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
meye.grab_buffer[0].state = MEYE_BUF_USING;
|
meye.grab_buffer[0].state = MEYE_BUF_USING;
|
||||||
mchip_take_picture();
|
mchip_take_picture();
|
||||||
mchip_get_picture(
|
|
||||||
meye.grab_fbuffer,
|
mchip_get_picture(meye.grab_fbuffer,
|
||||||
mchip_hsize() * mchip_vsize() * 2);
|
mchip_hsize() * mchip_vsize() * 2);
|
||||||
|
|
||||||
meye.grab_buffer[0].state = MEYE_BUF_DONE;
|
meye.grab_buffer[0].state = MEYE_BUF_DONE;
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MEYEIOC_STILLJCAPT: {
|
return 0;
|
||||||
int *len = arg;
|
}
|
||||||
|
|
||||||
|
static int meyeioc_stilljcapt(int *len)
|
||||||
|
{
|
||||||
if (!meye.grab_fbuffer)
|
if (!meye.grab_fbuffer)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED)
|
if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
meye.grab_buffer[0].state = MEYE_BUF_USING;
|
meye.grab_buffer[0].state = MEYE_BUF_USING;
|
||||||
*len = -1;
|
*len = -1;
|
||||||
|
|
||||||
while (*len == -1) {
|
while (*len == -1) {
|
||||||
mchip_take_picture();
|
mchip_take_picture();
|
||||||
*len = mchip_compress_frame(meye.grab_fbuffer, gbufsize);
|
*len = mchip_compress_frame(meye.grab_fbuffer, gbufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
meye.grab_buffer[0].state = MEYE_BUF_DONE;
|
meye.grab_buffer[0].state = MEYE_BUF_DONE;
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIDIOC_QUERYCAP: {
|
|
||||||
struct v4l2_capability *cap = arg;
|
|
||||||
|
|
||||||
if (forcev4l1)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
|
static int vidioc_querycap(struct file *file, void *fh,
|
||||||
|
struct v4l2_capability *cap)
|
||||||
|
{
|
||||||
memset(cap, 0, sizeof(*cap));
|
memset(cap, 0, sizeof(*cap));
|
||||||
strcpy(cap->driver, "meye");
|
strcpy(cap->driver, "meye");
|
||||||
strcpy(cap->card, "meye");
|
strcpy(cap->card, "meye");
|
||||||
sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev));
|
sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev));
|
||||||
|
|
||||||
cap->version = (MEYE_DRIVER_MAJORVERSION << 8) +
|
cap->version = (MEYE_DRIVER_MAJORVERSION << 8) +
|
||||||
MEYE_DRIVER_MINORVERSION;
|
MEYE_DRIVER_MINORVERSION;
|
||||||
|
|
||||||
cap->capabilities = V4L2_CAP_VIDEO_CAPTURE |
|
cap->capabilities = V4L2_CAP_VIDEO_CAPTURE |
|
||||||
V4L2_CAP_STREAMING;
|
V4L2_CAP_STREAMING;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_ENUMINPUT: {
|
return 0;
|
||||||
struct v4l2_input *i = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
|
||||||
|
{
|
||||||
if (i->index != 0)
|
if (i->index != 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
memset(i, 0, sizeof(*i));
|
memset(i, 0, sizeof(*i));
|
||||||
i->index = 0;
|
i->index = 0;
|
||||||
strcpy(i->name, "Camera");
|
strcpy(i->name, "Camera");
|
||||||
i->type = V4L2_INPUT_TYPE_CAMERA;
|
i->type = V4L2_INPUT_TYPE_CAMERA;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_G_INPUT: {
|
return 0;
|
||||||
int *i = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_g_input(struct file *file, void *fh, unsigned int *i)
|
||||||
|
{
|
||||||
*i = 0;
|
*i = 0;
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIDIOC_S_INPUT: {
|
static int vidioc_s_input(struct file *file, void *fh, unsigned int i)
|
||||||
int *i = arg;
|
{
|
||||||
|
if (i != 0)
|
||||||
if (*i != 0)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_QUERYCTRL: {
|
return 0;
|
||||||
struct v4l2_queryctrl *c = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_queryctrl(struct file *file, void *fh,
|
||||||
|
struct v4l2_queryctrl *c)
|
||||||
|
{
|
||||||
switch (c->id) {
|
switch (c->id) {
|
||||||
|
|
||||||
case V4L2_CID_BRIGHTNESS:
|
case V4L2_CID_BRIGHTNESS:
|
||||||
|
@ -1284,12 +1153,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_S_CTRL: {
|
return 0;
|
||||||
struct v4l2_control *c = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
|
||||||
|
{
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
switch (c->id) {
|
switch (c->id) {
|
||||||
case V4L2_CID_BRIGHTNESS:
|
case V4L2_CID_BRIGHTNESS:
|
||||||
|
@ -1339,12 +1208,12 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_G_CTRL: {
|
return 0;
|
||||||
struct v4l2_control *c = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *c)
|
||||||
|
{
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
switch (c->id) {
|
switch (c->id) {
|
||||||
case V4L2_CID_BRIGHTNESS:
|
case V4L2_CID_BRIGHTNESS:
|
||||||
|
@ -1380,16 +1249,19 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_ENUM_FMT: {
|
return 0;
|
||||||
struct v4l2_fmtdesc *f = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_enum_fmt_cap(struct file *file, void *fh,
|
||||||
|
struct v4l2_fmtdesc *f)
|
||||||
|
{
|
||||||
if (f->index > 1)
|
if (f->index > 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (f->index == 0) {
|
if (f->index == 0) {
|
||||||
/* standard YUV 422 capture */
|
/* standard YUV 422 capture */
|
||||||
memset(f, 0, sizeof(*f));
|
memset(f, 0, sizeof(*f));
|
||||||
|
@ -1407,21 +1279,26 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
strcpy(f->description, "MJPEG");
|
strcpy(f->description, "MJPEG");
|
||||||
f->pixelformat = V4L2_PIX_FMT_MJPEG;
|
f->pixelformat = V4L2_PIX_FMT_MJPEG;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_TRY_FMT: {
|
return 0;
|
||||||
struct v4l2_format *f = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_try_fmt_cap(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f)
|
||||||
|
{
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
|
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
|
||||||
f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
|
f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (f->fmt.pix.field != V4L2_FIELD_ANY &&
|
if (f->fmt.pix.field != V4L2_FIELD_ANY &&
|
||||||
f->fmt.pix.field != V4L2_FIELD_NONE)
|
f->fmt.pix.field != V4L2_FIELD_NONE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
f->fmt.pix.field = V4L2_FIELD_NONE;
|
f->fmt.pix.field = V4L2_FIELD_NONE;
|
||||||
|
|
||||||
if (f->fmt.pix.width <= 320) {
|
if (f->fmt.pix.width <= 320) {
|
||||||
f->fmt.pix.width = 320;
|
f->fmt.pix.width = 320;
|
||||||
f->fmt.pix.height = 240;
|
f->fmt.pix.height = 240;
|
||||||
|
@ -1429,21 +1306,24 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
f->fmt.pix.width = 640;
|
f->fmt.pix.width = 640;
|
||||||
f->fmt.pix.height = 480;
|
f->fmt.pix.height = 480;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
|
f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
|
||||||
f->fmt.pix.sizeimage = f->fmt.pix.height *
|
f->fmt.pix.sizeimage = f->fmt.pix.height *
|
||||||
f->fmt.pix.bytesperline;
|
f->fmt.pix.bytesperline;
|
||||||
f->fmt.pix.colorspace = 0;
|
f->fmt.pix.colorspace = 0;
|
||||||
f->fmt.pix.priv = 0;
|
f->fmt.pix.priv = 0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_G_FMT: {
|
return 0;
|
||||||
struct v4l2_format *f = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_g_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
|
||||||
|
{
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format));
|
memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format));
|
||||||
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
|
||||||
switch (meye.mchip_mode) {
|
switch (meye.mchip_mode) {
|
||||||
case MCHIP_HIC_MODE_CONT_OUT:
|
case MCHIP_HIC_MODE_CONT_OUT:
|
||||||
default:
|
default:
|
||||||
|
@ -1453,6 +1333,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
|
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
f->fmt.pix.field = V4L2_FIELD_NONE;
|
f->fmt.pix.field = V4L2_FIELD_NONE;
|
||||||
f->fmt.pix.width = mchip_hsize();
|
f->fmt.pix.width = mchip_hsize();
|
||||||
f->fmt.pix.height = mchip_vsize();
|
f->fmt.pix.height = mchip_vsize();
|
||||||
|
@ -1461,22 +1342,26 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
f->fmt.pix.bytesperline;
|
f->fmt.pix.bytesperline;
|
||||||
f->fmt.pix.colorspace = 0;
|
f->fmt.pix.colorspace = 0;
|
||||||
f->fmt.pix.priv = 0;
|
f->fmt.pix.priv = 0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_S_FMT: {
|
return 0;
|
||||||
struct v4l2_format *f = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_s_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
|
||||||
|
{
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
|
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
|
||||||
f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
|
f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (f->fmt.pix.field != V4L2_FIELD_ANY &&
|
if (f->fmt.pix.field != V4L2_FIELD_ANY &&
|
||||||
f->fmt.pix.field != V4L2_FIELD_NONE)
|
f->fmt.pix.field != V4L2_FIELD_NONE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
f->fmt.pix.field = V4L2_FIELD_NONE;
|
f->fmt.pix.field = V4L2_FIELD_NONE;
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
|
|
||||||
if (f->fmt.pix.width <= 320) {
|
if (f->fmt.pix.width <= 320) {
|
||||||
f->fmt.pix.width = 320;
|
f->fmt.pix.width = 320;
|
||||||
f->fmt.pix.height = 240;
|
f->fmt.pix.height = 240;
|
||||||
|
@ -1486,6 +1371,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
f->fmt.pix.height = 480;
|
f->fmt.pix.height = 480;
|
||||||
meye.params.subsample = 0;
|
meye.params.subsample = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (f->fmt.pix.pixelformat) {
|
switch (f->fmt.pix.pixelformat) {
|
||||||
case V4L2_PIX_FMT_YUYV:
|
case V4L2_PIX_FMT_YUYV:
|
||||||
meye.mchip_mode = MCHIP_HIC_MODE_CONT_OUT;
|
meye.mchip_mode = MCHIP_HIC_MODE_CONT_OUT;
|
||||||
|
@ -1494,6 +1380,7 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP;
|
meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
|
f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
|
||||||
f->fmt.pix.sizeimage = f->fmt.pix.height *
|
f->fmt.pix.sizeimage = f->fmt.pix.height *
|
||||||
|
@ -1501,21 +1388,25 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
f->fmt.pix.colorspace = 0;
|
f->fmt.pix.colorspace = 0;
|
||||||
f->fmt.pix.priv = 0;
|
f->fmt.pix.priv = 0;
|
||||||
|
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIDIOC_REQBUFS: {
|
static int vidioc_reqbufs(struct file *file, void *fh,
|
||||||
struct v4l2_requestbuffers *req = arg;
|
struct v4l2_requestbuffers *req)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (req->memory != V4L2_MEMORY_MMAP)
|
if (req->memory != V4L2_MEMORY_MMAP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (meye.grab_fbuffer && req->count == gbuffers) {
|
if (meye.grab_fbuffer && req->count == gbuffers) {
|
||||||
/* already allocated, no modifications */
|
/* already allocated, no modifications */
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
if (meye.grab_fbuffer) {
|
if (meye.grab_fbuffer) {
|
||||||
for (i = 0; i < gbuffers; i++)
|
for (i = 0; i < gbuffers; i++)
|
||||||
|
@ -1526,93 +1417,114 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
rvfree(meye.grab_fbuffer, gbuffers * gbufsize);
|
rvfree(meye.grab_fbuffer, gbuffers * gbufsize);
|
||||||
meye.grab_fbuffer = NULL;
|
meye.grab_fbuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gbuffers = max(2, min((int)req->count, MEYE_MAX_BUFNBRS));
|
gbuffers = max(2, min((int)req->count, MEYE_MAX_BUFNBRS));
|
||||||
req->count = gbuffers;
|
req->count = gbuffers;
|
||||||
meye.grab_fbuffer = rvmalloc(gbuffers * gbufsize);
|
meye.grab_fbuffer = rvmalloc(gbuffers * gbufsize);
|
||||||
|
|
||||||
if (!meye.grab_fbuffer) {
|
if (!meye.grab_fbuffer) {
|
||||||
printk(KERN_ERR "meye: v4l framebuffer allocation"
|
printk(KERN_ERR "meye: v4l framebuffer allocation"
|
||||||
" failed\n");
|
" failed\n");
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < gbuffers; i++)
|
for (i = 0; i < gbuffers; i++)
|
||||||
meye.vma_use_count[i] = 0;
|
meye.vma_use_count[i] = 0;
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_QUERYBUF: {
|
mutex_unlock(&meye.lock);
|
||||||
struct v4l2_buffer *buf = arg;
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
||||||
|
{
|
||||||
int index = buf->index;
|
int index = buf->index;
|
||||||
|
|
||||||
if (index < 0 || index >= gbuffers)
|
if (index < 0 || index >= gbuffers)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
memset(buf, 0, sizeof(*buf));
|
memset(buf, 0, sizeof(*buf));
|
||||||
|
|
||||||
buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
buf->index = index;
|
buf->index = index;
|
||||||
buf->bytesused = meye.grab_buffer[index].size;
|
buf->bytesused = meye.grab_buffer[index].size;
|
||||||
buf->flags = V4L2_BUF_FLAG_MAPPED;
|
buf->flags = V4L2_BUF_FLAG_MAPPED;
|
||||||
|
|
||||||
if (meye.grab_buffer[index].state == MEYE_BUF_USING)
|
if (meye.grab_buffer[index].state == MEYE_BUF_USING)
|
||||||
buf->flags |= V4L2_BUF_FLAG_QUEUED;
|
buf->flags |= V4L2_BUF_FLAG_QUEUED;
|
||||||
|
|
||||||
if (meye.grab_buffer[index].state == MEYE_BUF_DONE)
|
if (meye.grab_buffer[index].state == MEYE_BUF_DONE)
|
||||||
buf->flags |= V4L2_BUF_FLAG_DONE;
|
buf->flags |= V4L2_BUF_FLAG_DONE;
|
||||||
|
|
||||||
buf->field = V4L2_FIELD_NONE;
|
buf->field = V4L2_FIELD_NONE;
|
||||||
buf->timestamp = meye.grab_buffer[index].timestamp;
|
buf->timestamp = meye.grab_buffer[index].timestamp;
|
||||||
buf->sequence = meye.grab_buffer[index].sequence;
|
buf->sequence = meye.grab_buffer[index].sequence;
|
||||||
buf->memory = V4L2_MEMORY_MMAP;
|
buf->memory = V4L2_MEMORY_MMAP;
|
||||||
buf->m.offset = index * gbufsize;
|
buf->m.offset = index * gbufsize;
|
||||||
buf->length = gbufsize;
|
buf->length = gbufsize;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_QBUF: {
|
return 0;
|
||||||
struct v4l2_buffer *buf = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
||||||
|
{
|
||||||
if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (buf->memory != V4L2_MEMORY_MMAP)
|
if (buf->memory != V4L2_MEMORY_MMAP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (buf->index < 0 || buf->index >= gbuffers)
|
if (buf->index < 0 || buf->index >= gbuffers)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED)
|
if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
buf->flags |= V4L2_BUF_FLAG_QUEUED;
|
buf->flags |= V4L2_BUF_FLAG_QUEUED;
|
||||||
buf->flags &= ~V4L2_BUF_FLAG_DONE;
|
buf->flags &= ~V4L2_BUF_FLAG_DONE;
|
||||||
meye.grab_buffer[buf->index].state = MEYE_BUF_USING;
|
meye.grab_buffer[buf->index].state = MEYE_BUF_USING;
|
||||||
kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int));
|
kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int));
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_DQBUF: {
|
return 0;
|
||||||
struct v4l2_buffer *buf = arg;
|
}
|
||||||
|
|
||||||
|
static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
||||||
|
{
|
||||||
int reqnr;
|
int reqnr;
|
||||||
|
|
||||||
if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (buf->memory != V4L2_MEMORY_MMAP)
|
if (buf->memory != V4L2_MEMORY_MMAP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
|
|
||||||
if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) {
|
if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) {
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wait_event_interruptible(meye.proc_list,
|
if (wait_event_interruptible(meye.proc_list,
|
||||||
kfifo_len(meye.doneq) != 0) < 0) {
|
kfifo_len(meye.doneq) != 0) < 0) {
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr,
|
if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr,
|
||||||
sizeof(int))) {
|
sizeof(int))) {
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) {
|
if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) {
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->index = reqnr;
|
buf->index = reqnr;
|
||||||
buf->bytesused = meye.grab_buffer[reqnr].size;
|
buf->bytesused = meye.grab_buffer[reqnr].size;
|
||||||
buf->flags = V4L2_BUF_FLAG_MAPPED;
|
buf->flags = V4L2_BUF_FLAG_MAPPED;
|
||||||
|
@ -1624,11 +1536,14 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
buf->length = gbufsize;
|
buf->length = gbufsize;
|
||||||
meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED;
|
meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED;
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_STREAMON: {
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
|
||||||
|
{
|
||||||
mutex_lock(&meye.lock);
|
mutex_lock(&meye.lock);
|
||||||
|
|
||||||
switch (meye.mchip_mode) {
|
switch (meye.mchip_mode) {
|
||||||
case MCHIP_HIC_MODE_CONT_OUT:
|
case MCHIP_HIC_MODE_CONT_OUT:
|
||||||
mchip_continuous_start();
|
mchip_continuous_start();
|
||||||
|
@ -1640,39 +1555,51 @@ static int meye_do_ioctl(struct inode *inode, struct file *file,
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&meye.lock);
|
mutex_unlock(&meye.lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case VIDIOC_STREAMOFF: {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
mutex_lock(&meye.lock);
|
|
||||||
mchip_hic_stop();
|
|
||||||
kfifo_reset(meye.grabq);
|
|
||||||
kfifo_reset(meye.doneq);
|
|
||||||
for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
|
|
||||||
meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
|
|
||||||
mutex_unlock(&meye.lock);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX what about private snapshot ioctls ?
|
|
||||||
* Do they need to be converted to V4L2 ?
|
|
||||||
*/
|
|
||||||
|
|
||||||
default:
|
|
||||||
return -ENOIOCTLCMD;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int meye_ioctl(struct inode *inode, struct file *file,
|
static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
return video_usercopy(inode, file, cmd, arg, meye_do_ioctl);
|
mutex_lock(&meye.lock);
|
||||||
|
mchip_hic_stop();
|
||||||
|
kfifo_reset(meye.grabq);
|
||||||
|
kfifo_reset(meye.doneq);
|
||||||
|
|
||||||
|
for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
|
||||||
|
meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
|
||||||
|
|
||||||
|
mutex_unlock(&meye.lock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vidioc_default(struct file *file, void *fh, int cmd, void *arg)
|
||||||
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
case MEYEIOC_G_PARAMS:
|
||||||
|
return meyeioc_g_params((struct meye_params *) arg);
|
||||||
|
|
||||||
|
case MEYEIOC_S_PARAMS:
|
||||||
|
return meyeioc_s_params((struct meye_params *) arg);
|
||||||
|
|
||||||
|
case MEYEIOC_QBUF_CAPT:
|
||||||
|
return meyeioc_qbuf_capt((int *) arg);
|
||||||
|
|
||||||
|
case MEYEIOC_SYNC:
|
||||||
|
return meyeioc_sync(file, fh, (int *) arg);
|
||||||
|
|
||||||
|
case MEYEIOC_STILLCAPT:
|
||||||
|
return meyeioc_stillcapt();
|
||||||
|
|
||||||
|
case MEYEIOC_STILLJCAPT:
|
||||||
|
return meyeioc_stilljcapt((int *) arg);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int meye_poll(struct file *file, poll_table *wait)
|
static unsigned int meye_poll(struct file *file, poll_table *wait)
|
||||||
|
@ -1760,7 +1687,7 @@ static const struct file_operations meye_fops = {
|
||||||
.open = meye_open,
|
.open = meye_open,
|
||||||
.release = meye_release,
|
.release = meye_release,
|
||||||
.mmap = meye_mmap,
|
.mmap = meye_mmap,
|
||||||
.ioctl = meye_ioctl,
|
.ioctl = video_ioctl2,
|
||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
.compat_ioctl = v4l_compat_ioctl32,
|
.compat_ioctl = v4l_compat_ioctl32,
|
||||||
#endif
|
#endif
|
||||||
|
@ -1775,6 +1702,24 @@ static struct video_device meye_template = {
|
||||||
.fops = &meye_fops,
|
.fops = &meye_fops,
|
||||||
.release = video_device_release,
|
.release = video_device_release,
|
||||||
.minor = -1,
|
.minor = -1,
|
||||||
|
.vidioc_querycap = vidioc_querycap,
|
||||||
|
.vidioc_enum_input = vidioc_enum_input,
|
||||||
|
.vidioc_g_input = vidioc_g_input,
|
||||||
|
.vidioc_s_input = vidioc_s_input,
|
||||||
|
.vidioc_queryctrl = vidioc_queryctrl,
|
||||||
|
.vidioc_s_ctrl = vidioc_s_ctrl,
|
||||||
|
.vidioc_g_ctrl = vidioc_g_ctrl,
|
||||||
|
.vidioc_enum_fmt_cap = vidioc_enum_fmt_cap,
|
||||||
|
.vidioc_try_fmt_cap = vidioc_try_fmt_cap,
|
||||||
|
.vidioc_g_fmt_cap = vidioc_g_fmt_cap,
|
||||||
|
.vidioc_s_fmt_cap = vidioc_s_fmt_cap,
|
||||||
|
.vidioc_reqbufs = vidioc_reqbufs,
|
||||||
|
.vidioc_querybuf = vidioc_querybuf,
|
||||||
|
.vidioc_qbuf = vidioc_qbuf,
|
||||||
|
.vidioc_dqbuf = vidioc_dqbuf,
|
||||||
|
.vidioc_streamon = vidioc_streamon,
|
||||||
|
.vidioc_streamoff = vidioc_streamoff,
|
||||||
|
.vidioc_default = vidioc_default,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue