2009-09-01 12:54:54 +08:00
|
|
|
/*
|
|
|
|
em28xx-vbi.c - VBI driver for em28xx
|
|
|
|
|
|
|
|
Copyright (C) 2009 Devin Heitmueller <dheitmueller@kernellabs.com>
|
|
|
|
|
|
|
|
This work was sponsored by EyeMagnet Limited.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2016-10-12 18:32:23 +08:00
|
|
|
#include "em28xx.h"
|
|
|
|
|
2009-09-01 12:54:54 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
2010-12-08 02:50:09 +08:00
|
|
|
#include <linux/hardirq.h>
|
2009-09-01 12:54:54 +08:00
|
|
|
#include <linux/init.h>
|
2016-10-20 18:42:03 +08:00
|
|
|
#include <linux/usb.h>
|
2009-09-01 12:54:54 +08:00
|
|
|
|
2013-12-23 00:27:02 +08:00
|
|
|
#include "em28xx-v4l.h"
|
2009-09-01 12:54:54 +08:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2015-10-28 10:50:37 +08:00
|
|
|
static int vbi_queue_setup(struct vb2_queue *vq,
|
2013-01-05 03:16:24 +08:00
|
|
|
unsigned int *nbuffers, unsigned int *nplanes,
|
2016-04-15 20:15:05 +08:00
|
|
|
unsigned int sizes[], struct device *alloc_devs[])
|
2009-09-01 12:54:54 +08:00
|
|
|
{
|
2013-01-05 03:16:24 +08:00
|
|
|
struct em28xx *dev = vb2_get_drv_priv(vq);
|
2014-03-25 03:33:14 +08:00
|
|
|
struct em28xx_v4l2 *v4l2 = dev->v4l2;
|
2015-10-28 10:50:37 +08:00
|
|
|
unsigned long size = v4l2->vbi_width * v4l2->vbi_height * 2;
|
2009-09-01 12:54:54 +08:00
|
|
|
|
2013-01-05 03:16:24 +08:00
|
|
|
if (*nbuffers < 2)
|
|
|
|
*nbuffers = 2;
|
2015-10-28 10:50:37 +08:00
|
|
|
|
|
|
|
if (*nplanes) {
|
|
|
|
if (sizes[0] < size)
|
|
|
|
return -EINVAL;
|
|
|
|
size = sizes[0];
|
|
|
|
}
|
2009-11-25 10:17:25 +08:00
|
|
|
|
2013-01-05 03:16:24 +08:00
|
|
|
*nplanes = 1;
|
|
|
|
sizes[0] = size;
|
2009-11-25 10:17:25 +08:00
|
|
|
|
2009-09-01 12:54:54 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-05 03:16:24 +08:00
|
|
|
static int vbi_buffer_prepare(struct vb2_buffer *vb)
|
2009-09-01 12:54:54 +08:00
|
|
|
{
|
2014-03-25 03:33:14 +08:00
|
|
|
struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue);
|
|
|
|
struct em28xx_v4l2 *v4l2 = dev->v4l2;
|
2013-01-05 03:16:24 +08:00
|
|
|
unsigned long size;
|
2009-09-01 12:54:54 +08:00
|
|
|
|
2014-03-25 03:33:14 +08:00
|
|
|
size = v4l2->vbi_width * v4l2->vbi_height * 2;
|
2009-09-01 12:54:54 +08:00
|
|
|
|
2013-01-05 03:16:24 +08:00
|
|
|
if (vb2_plane_size(vb, 0) < size) {
|
2016-12-07 23:48:10 +08:00
|
|
|
dev_info(&dev->intf->dev,
|
2016-10-20 18:42:03 +08:00
|
|
|
"%s data will not fit into plane (%lu < %lu)\n",
|
|
|
|
__func__, vb2_plane_size(vb, 0), size);
|
2009-09-01 12:54:54 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
[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
|
|
|
vb2_set_plane_payload(vb, 0, size);
|
2009-09-01 12:54:54 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-05 03:16:24 +08:00
|
|
|
vbi_buffer_queue(struct vb2_buffer *vb)
|
2009-09-01 12:54:54 +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
|
|
|
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
|
2013-01-05 03:16:24 +08:00
|
|
|
struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue);
|
[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 em28xx_buffer *buf =
|
|
|
|
container_of(vbuf, struct em28xx_buffer, vb);
|
2013-01-05 03:16:24 +08:00
|
|
|
struct em28xx_dmaqueue *vbiq = &dev->vbiq;
|
|
|
|
unsigned long flags = 0;
|
|
|
|
|
|
|
|
buf->mem = vb2_plane_vaddr(vb, 0);
|
|
|
|
buf->length = vb2_plane_size(vb, 0);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
|
|
|
list_add_tail(&buf->list, &vbiq->active);
|
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
2009-09-01 12:54:54 +08:00
|
|
|
}
|
|
|
|
|
2017-09-28 01:08:19 +08:00
|
|
|
const struct vb2_ops em28xx_vbi_qops = {
|
2013-01-05 03:16:24 +08:00
|
|
|
.queue_setup = vbi_queue_setup,
|
|
|
|
.buf_prepare = vbi_buffer_prepare,
|
|
|
|
.buf_queue = vbi_buffer_queue,
|
|
|
|
.start_streaming = em28xx_start_analog_streaming,
|
|
|
|
.stop_streaming = em28xx_stop_vbi_streaming,
|
|
|
|
.wait_prepare = vb2_ops_wait_prepare,
|
|
|
|
.wait_finish = vb2_ops_wait_finish,
|
2009-09-01 12:54:54 +08:00
|
|
|
};
|