2009-03-04 01:37:50 +08:00
|
|
|
/*
|
|
|
|
cx231xx_vbi.c - driver for Conexant Cx23100/101/102 USB video capture devices
|
|
|
|
|
|
|
|
Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
|
2009-03-03 17:14:34 +08:00
|
|
|
Based on cx88 driver
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/bitmap.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/mutex.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>
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
#include <media/v4l2-common.h>
|
|
|
|
#include <media/v4l2-ioctl.h>
|
|
|
|
#include <media/msp3400.h>
|
|
|
|
#include <media/tuner.h>
|
|
|
|
|
|
|
|
#include "cx231xx.h"
|
|
|
|
#include "cx231xx-vbi.h"
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
static inline void print_err_status(struct cx231xx *dev, int packet, int status)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
|
|
|
char *errmsg = "Unknown";
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case -ENOENT:
|
|
|
|
errmsg = "unlinked synchronuously";
|
|
|
|
break;
|
|
|
|
case -ECONNRESET:
|
|
|
|
errmsg = "unlinked asynchronuously";
|
|
|
|
break;
|
|
|
|
case -ENOSR:
|
|
|
|
errmsg = "Buffer error (overrun)";
|
|
|
|
break;
|
|
|
|
case -EPIPE:
|
|
|
|
errmsg = "Stalled (device not responding)";
|
|
|
|
break;
|
|
|
|
case -EOVERFLOW:
|
|
|
|
errmsg = "Babble (bad cable?)";
|
|
|
|
break;
|
|
|
|
case -EPROTO:
|
|
|
|
errmsg = "Bit-stuff error (bad cable?)";
|
|
|
|
break;
|
|
|
|
case -EILSEQ:
|
|
|
|
errmsg = "CRC/Timeout (could be anything)";
|
|
|
|
break;
|
|
|
|
case -ETIME:
|
|
|
|
errmsg = "Device does not respond";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (packet < 0) {
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_err("URB status %d [%s].\n", status,
|
2009-03-03 17:14:34 +08:00
|
|
|
errmsg);
|
2009-03-04 01:37:50 +08:00
|
|
|
} else {
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_err("URB packet %d, status %d [%s].\n",
|
2009-03-03 17:14:34 +08:00
|
|
|
packet, status, errmsg);
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Controls the isoc copy of each urb packet
|
|
|
|
*/
|
|
|
|
static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb)
|
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_dmaqueue *dma_q = urb->context;
|
|
|
|
int rc = 1;
|
2009-03-04 01:37:50 +08:00
|
|
|
unsigned char *p_buffer;
|
2009-03-03 17:14:34 +08:00
|
|
|
u32 bytes_parsed = 0, buffer_size = 0;
|
|
|
|
u8 sav_eav = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
if (!dev)
|
|
|
|
return 0;
|
|
|
|
|
2012-01-10 19:48:50 +08:00
|
|
|
if (dev->state & DEV_DISCONNECTED)
|
2009-03-04 01:37:50 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (urb->status < 0) {
|
|
|
|
print_err_status(dev, -1, urb->status);
|
|
|
|
if (urb->status == -ENOENT)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
/* get buffer pointer and length */
|
|
|
|
p_buffer = urb->transfer_buffer;
|
|
|
|
buffer_size = urb->actual_length;
|
|
|
|
|
|
|
|
if (buffer_size > 0) {
|
|
|
|
bytes_parsed = 0;
|
|
|
|
|
|
|
|
if (dma_q->is_partial_line) {
|
2009-03-04 00:31:36 +08:00
|
|
|
/* Handle the case where we were working on a partial
|
|
|
|
line */
|
2009-03-03 17:14:34 +08:00
|
|
|
sav_eav = dma_q->last_sav;
|
|
|
|
} else {
|
2009-03-04 00:31:36 +08:00
|
|
|
/* Check for a SAV/EAV overlapping the
|
|
|
|
buffer boundary */
|
|
|
|
|
|
|
|
sav_eav = cx231xx_find_boundary_SAV_EAV(p_buffer,
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->partial_buf,
|
|
|
|
&bytes_parsed);
|
|
|
|
}
|
|
|
|
|
|
|
|
sav_eav &= 0xF0;
|
2009-03-04 00:31:36 +08:00
|
|
|
/* Get the first line if we have some portion of an SAV/EAV from
|
|
|
|
the last buffer or a partial line */
|
2009-03-03 17:14:34 +08:00
|
|
|
if (sav_eav) {
|
2009-03-04 00:31:36 +08:00
|
|
|
bytes_parsed += cx231xx_get_vbi_line(dev, dma_q,
|
|
|
|
sav_eav, /* SAV/EAV */
|
|
|
|
p_buffer + bytes_parsed, /* p_buffer */
|
|
|
|
buffer_size - bytes_parsed); /* buffer size */
|
2009-03-03 17:14:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now parse data that is completely in this buffer */
|
|
|
|
dma_q->is_partial_line = 0;
|
|
|
|
|
|
|
|
while (bytes_parsed < buffer_size) {
|
|
|
|
u32 bytes_used = 0;
|
|
|
|
|
2009-03-05 04:49:01 +08:00
|
|
|
sav_eav = cx231xx_find_next_SAV_EAV(
|
|
|
|
p_buffer + bytes_parsed, /* p_buffer */
|
|
|
|
buffer_size - bytes_parsed, /* buffer size */
|
|
|
|
&bytes_used); /* bytes used to get SAV/EAV */
|
2009-03-03 17:14:34 +08:00
|
|
|
|
|
|
|
bytes_parsed += bytes_used;
|
|
|
|
|
|
|
|
sav_eav &= 0xF0;
|
|
|
|
if (sav_eav && (bytes_parsed < buffer_size)) {
|
2009-03-04 00:31:36 +08:00
|
|
|
bytes_parsed += cx231xx_get_vbi_line(dev,
|
2009-03-05 04:49:01 +08:00
|
|
|
dma_q, sav_eav, /* SAV/EAV */
|
|
|
|
p_buffer+bytes_parsed, /* p_buffer */
|
|
|
|
buffer_size-bytes_parsed);/*buf size*/
|
2009-03-03 17:14:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-05 04:49:01 +08:00
|
|
|
/* Save the last four bytes of the buffer so we can
|
|
|
|
check the buffer boundary condition next time */
|
2009-03-03 17:14:34 +08:00
|
|
|
memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4);
|
|
|
|
bytes_parsed = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------
|
|
|
|
Vbi buf operations
|
|
|
|
------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static int
|
2009-03-03 17:14:34 +08:00
|
|
|
vbi_buffer_setup(struct videobuf_queue *vq, unsigned int *count,
|
|
|
|
unsigned int *size)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
|
|
|
struct cx231xx_fh *fh = vq->priv_data;
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx *dev = fh->dev;
|
|
|
|
u32 height = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
height = ((dev->norm & V4L2_STD_625_50) ?
|
2009-03-03 17:14:34 +08:00
|
|
|
PAL_VBI_LINES : NTSC_VBI_LINES);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-09 02:45:13 +08:00
|
|
|
*size = (dev->width * height * 2 * 2);
|
2009-03-04 01:37:50 +08:00
|
|
|
if (0 == *count)
|
|
|
|
*count = CX231XX_DEF_VBI_BUF;
|
|
|
|
|
|
|
|
if (*count < CX231XX_MIN_BUF)
|
|
|
|
*count = CX231XX_MIN_BUF;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is called *without* dev->slock held; please keep it that way */
|
|
|
|
static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
|
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_fh *fh = vq->priv_data;
|
|
|
|
struct cx231xx *dev = fh->dev;
|
2009-03-04 01:37:50 +08:00
|
|
|
unsigned long flags = 0;
|
|
|
|
if (in_interrupt())
|
|
|
|
BUG();
|
|
|
|
|
|
|
|
/* We used to wait for the buffer to finish here, but this didn't work
|
|
|
|
because, as we were keeping the state as VIDEOBUF_QUEUED,
|
|
|
|
videobuf_queue_cancel marked it as finished for us.
|
|
|
|
(Also, it could wedge forever if the hardware was misconfigured.)
|
|
|
|
|
|
|
|
This should be safe; by the time we get here, the buffer isn't
|
|
|
|
queued anymore. If we ever start marking the buffers as
|
|
|
|
VIDEOBUF_ACTIVE, it won't be, though.
|
2009-03-03 17:14:34 +08:00
|
|
|
*/
|
2009-03-04 01:37:50 +08:00
|
|
|
spin_lock_irqsave(&dev->vbi_mode.slock, flags);
|
2010-07-07 05:12:25 +08:00
|
|
|
if (dev->vbi_mode.bulk_ctl.buf == buf)
|
|
|
|
dev->vbi_mode.bulk_ctl.buf = NULL;
|
2009-03-04 01:37:50 +08:00
|
|
|
spin_unlock_irqrestore(&dev->vbi_mode.slock, flags);
|
|
|
|
|
|
|
|
videobuf_vmalloc_free(&buf->vb);
|
|
|
|
buf->vb.state = VIDEOBUF_NEEDS_INIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
|
2009-03-03 17:14:34 +08:00
|
|
|
enum v4l2_field field)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_fh *fh = vq->priv_data;
|
|
|
|
struct cx231xx_buffer *buf =
|
|
|
|
container_of(vb, struct cx231xx_buffer, vb);
|
|
|
|
struct cx231xx *dev = fh->dev;
|
|
|
|
int rc = 0, urb_init = 0;
|
|
|
|
u32 height = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
height = ((dev->norm & V4L2_STD_625_50) ?
|
2009-03-03 17:14:34 +08:00
|
|
|
PAL_VBI_LINES : NTSC_VBI_LINES);
|
2010-07-09 02:45:13 +08:00
|
|
|
buf->vb.size = ((dev->width << 1) * height * 2);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
|
2009-03-04 01:37:50 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
buf->vb.width = dev->width;
|
2009-03-04 01:37:50 +08:00
|
|
|
buf->vb.height = height;
|
2009-03-03 17:14:34 +08:00
|
|
|
buf->vb.field = field;
|
|
|
|
buf->vb.field = V4L2_FIELD_SEQ_TB;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
|
|
|
|
rc = videobuf_iolock(vq, &buf->vb, NULL);
|
|
|
|
if (rc < 0)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
if (!dev->vbi_mode.bulk_ctl.num_bufs)
|
2009-03-04 01:37:50 +08:00
|
|
|
urb_init = 1;
|
|
|
|
|
|
|
|
if (urb_init) {
|
|
|
|
rc = cx231xx_init_vbi_isoc(dev, CX231XX_NUM_VBI_PACKETS,
|
2009-03-03 17:14:34 +08:00
|
|
|
CX231XX_NUM_VBI_BUFS,
|
|
|
|
dev->vbi_mode.alt_max_pkt_size[0],
|
|
|
|
cx231xx_isoc_vbi_copy);
|
2009-03-04 01:37:50 +08:00
|
|
|
if (rc < 0)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf->vb.state = VIDEOBUF_PREPARED;
|
|
|
|
return 0;
|
|
|
|
|
2009-03-04 00:31:36 +08:00
|
|
|
fail:
|
2009-03-04 01:37:50 +08:00
|
|
|
free_buffer(vq, buf);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
|
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_buffer *buf =
|
|
|
|
container_of(vb, struct cx231xx_buffer, vb);
|
|
|
|
struct cx231xx_fh *fh = vq->priv_data;
|
|
|
|
struct cx231xx *dev = fh->dev;
|
|
|
|
struct cx231xx_dmaqueue *vidq = &dev->vbi_mode.vidq;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
buf->vb.state = VIDEOBUF_QUEUED;
|
|
|
|
list_add_tail(&buf->vb.queue, &vidq->active);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vbi_buffer_release(struct videobuf_queue *vq,
|
2009-03-03 17:14:34 +08:00
|
|
|
struct videobuf_buffer *vb)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_buffer *buf =
|
|
|
|
container_of(vb, struct cx231xx_buffer, vb);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
free_buffer(vq, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct videobuf_queue_ops cx231xx_vbi_qops = {
|
2009-03-04 00:31:36 +08:00
|
|
|
.buf_setup = vbi_buffer_setup,
|
2009-03-03 17:14:34 +08:00
|
|
|
.buf_prepare = vbi_buffer_prepare,
|
2009-03-04 00:31:36 +08:00
|
|
|
.buf_queue = vbi_buffer_queue,
|
2009-03-03 17:14:34 +08:00
|
|
|
.buf_release = vbi_buffer_release,
|
2009-03-04 01:37:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------
|
|
|
|
URB control
|
|
|
|
------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IRQ callback, called by URB callback
|
|
|
|
*/
|
|
|
|
static void cx231xx_irq_vbi_callback(struct urb *urb)
|
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_dmaqueue *dma_q = urb->context;
|
|
|
|
struct cx231xx_video_mode *vmode =
|
|
|
|
container_of(dma_q, struct cx231xx_video_mode, vidq);
|
|
|
|
struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
switch (urb->status) {
|
|
|
|
case 0: /* success */
|
|
|
|
case -ETIMEDOUT: /* NAK */
|
|
|
|
break;
|
|
|
|
case -ECONNRESET: /* kill */
|
|
|
|
case -ENOENT:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
return;
|
|
|
|
default: /* error */
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_err("urb completition error %d.\n",
|
2009-03-03 17:14:34 +08:00
|
|
|
urb->status);
|
|
|
|
break;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy data from URB */
|
|
|
|
spin_lock(&dev->vbi_mode.slock);
|
2012-05-14 21:14:53 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.bulk_copy(dev, urb);
|
2009-03-04 01:37:50 +08:00
|
|
|
spin_unlock(&dev->vbi_mode.slock);
|
|
|
|
|
|
|
|
/* Reset status */
|
|
|
|
urb->status = 0;
|
|
|
|
|
|
|
|
urb->status = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (urb->status) {
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_err("urb resubmit failed (error=%i)\n",
|
2009-03-03 17:14:34 +08:00
|
|
|
urb->status);
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop and Deallocate URBs
|
|
|
|
*/
|
|
|
|
void cx231xx_uninit_vbi_isoc(struct cx231xx *dev)
|
|
|
|
{
|
|
|
|
struct urb *urb;
|
|
|
|
int i;
|
|
|
|
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_info("called cx231xx_uninit_vbi_isoc\n");
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.nfields = -1;
|
|
|
|
for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) {
|
|
|
|
urb = dev->vbi_mode.bulk_ctl.urb[i];
|
2009-03-04 01:37:50 +08:00
|
|
|
if (urb) {
|
2009-03-03 17:14:34 +08:00
|
|
|
if (!irqs_disabled())
|
|
|
|
usb_kill_urb(urb);
|
|
|
|
else
|
|
|
|
usb_unlink_urb(urb);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
if (dev->vbi_mode.bulk_ctl.transfer_buffer[i]) {
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
kfree(dev->vbi_mode.bulk_ctl.
|
2009-03-03 17:14:34 +08:00
|
|
|
transfer_buffer[i]);
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.transfer_buffer[i] =
|
2009-03-03 17:14:34 +08:00
|
|
|
NULL;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
usb_free_urb(urb);
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.urb[i] = NULL;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.transfer_buffer[i] = NULL;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
kfree(dev->vbi_mode.bulk_ctl.urb);
|
|
|
|
kfree(dev->vbi_mode.bulk_ctl.transfer_buffer);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.urb = NULL;
|
|
|
|
dev->vbi_mode.bulk_ctl.transfer_buffer = NULL;
|
|
|
|
dev->vbi_mode.bulk_ctl.num_bufs = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
cx231xx_capture_start(dev, 0, Vbi);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate URBs and start IRQ
|
|
|
|
*/
|
|
|
|
int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
|
2009-03-03 17:14:34 +08:00
|
|
|
int num_bufs, int max_pkt_size,
|
2010-07-07 05:12:25 +08:00
|
|
|
int (*bulk_copy) (struct cx231xx *dev,
|
2009-03-04 00:31:36 +08:00
|
|
|
struct urb *urb))
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
|
|
|
struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq;
|
|
|
|
int i;
|
|
|
|
int sb_size, pipe;
|
|
|
|
struct urb *urb;
|
|
|
|
int rc;
|
|
|
|
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_info("called cx231xx_vbi_isoc\n");
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
/* De-allocates all pending stuff */
|
|
|
|
cx231xx_uninit_vbi_isoc(dev);
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
/* clear if any halt */
|
|
|
|
usb_clear_halt(dev->udev,
|
|
|
|
usb_rcvbulkpipe(dev->udev,
|
|
|
|
dev->vbi_mode.end_point_addr));
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.bulk_copy = bulk_copy;
|
|
|
|
dev->vbi_mode.bulk_ctl.num_bufs = num_bufs;
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->pos = 0;
|
|
|
|
dma_q->is_partial_line = 0;
|
|
|
|
dma_q->last_sav = 0;
|
|
|
|
dma_q->current_field = -1;
|
|
|
|
dma_q->bytes_left_in_line = dev->width << 1;
|
|
|
|
dma_q->lines_per_field = ((dev->norm & V4L2_STD_625_50) ?
|
|
|
|
PAL_VBI_LINES : NTSC_VBI_LINES);
|
|
|
|
dma_q->lines_completed = 0;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
dma_q->partial_buf[i] = 0;
|
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs,
|
2009-03-04 00:31:36 +08:00
|
|
|
GFP_KERNEL);
|
2010-07-07 05:12:25 +08:00
|
|
|
if (!dev->vbi_mode.bulk_ctl.urb) {
|
2009-03-04 01:37:50 +08:00
|
|
|
cx231xx_errdev("cannot alloc memory for usb buffers\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.transfer_buffer =
|
2009-03-03 17:14:34 +08:00
|
|
|
kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
|
2010-07-07 05:12:25 +08:00
|
|
|
if (!dev->vbi_mode.bulk_ctl.transfer_buffer) {
|
2009-03-04 01:37:50 +08:00
|
|
|
cx231xx_errdev("cannot allocate memory for usbtransfer\n");
|
2010-07-07 05:12:25 +08:00
|
|
|
kfree(dev->vbi_mode.bulk_ctl.urb);
|
2009-03-04 01:37:50 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.max_pkt_size = max_pkt_size;
|
|
|
|
dev->vbi_mode.bulk_ctl.buf = NULL;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
sb_size = max_packets * dev->vbi_mode.bulk_ctl.max_pkt_size;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
/* allocate urbs and transfer buffers */
|
2010-07-07 05:12:25 +08:00
|
|
|
for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) {
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!urb) {
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_err("cannot alloc bulk_ctl.urb %i\n", i);
|
2009-03-04 01:37:50 +08:00
|
|
|
cx231xx_uninit_vbi_isoc(dev);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.urb[i] = urb;
|
2012-06-18 11:15:21 +08:00
|
|
|
urb->transfer_flags = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.transfer_buffer[i] =
|
2009-03-03 17:14:34 +08:00
|
|
|
kzalloc(sb_size, GFP_KERNEL);
|
2010-07-07 05:12:25 +08:00
|
|
|
if (!dev->vbi_mode.bulk_ctl.transfer_buffer[i]) {
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_err("unable to allocate %i bytes for transfer"
|
2009-03-03 17:14:34 +08:00
|
|
|
" buffer %i%s\n", sb_size, i,
|
2009-03-04 00:31:36 +08:00
|
|
|
in_interrupt() ? " while in int" : "");
|
2009-03-04 01:37:50 +08:00
|
|
|
cx231xx_uninit_vbi_isoc(dev);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr);
|
2009-03-03 17:14:34 +08:00
|
|
|
usb_fill_bulk_urb(urb, dev->udev, pipe,
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.transfer_buffer[i],
|
2009-03-03 17:14:34 +08:00
|
|
|
sb_size, cx231xx_irq_vbi_callback, dma_q);
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
init_waitqueue_head(&dma_q->wq);
|
|
|
|
|
|
|
|
/* submit urbs and enables IRQ */
|
2010-07-07 05:12:25 +08:00
|
|
|
for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) {
|
|
|
|
rc = usb_submit_urb(dev->vbi_mode.bulk_ctl.urb[i], GFP_ATOMIC);
|
2009-03-04 01:37:50 +08:00
|
|
|
if (rc) {
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_err("submit of urb %i failed (error=%i)\n", i,
|
2009-03-03 17:14:34 +08:00
|
|
|
rc);
|
2009-03-04 01:37:50 +08:00
|
|
|
cx231xx_uninit_vbi_isoc(dev);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
cx231xx_capture_start(dev, 1, Vbi);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-03-03 17:14:34 +08:00
|
|
|
EXPORT_SYMBOL_GPL(cx231xx_init_vbi_isoc);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-04 00:31:36 +08:00
|
|
|
u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
|
|
|
|
u8 sav_eav, u8 *p_buffer, u32 buffer_size)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
u32 bytes_copied = 0;
|
|
|
|
int current_field = -1;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
switch (sav_eav) {
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
case SAV_VBI_FIELD1:
|
|
|
|
current_field = 1;
|
|
|
|
break;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
case SAV_VBI_FIELD2:
|
|
|
|
current_field = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
if (current_field < 0)
|
|
|
|
return bytes_copied;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->last_sav = sav_eav;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
bytes_copied =
|
|
|
|
cx231xx_copy_vbi_line(dev, dma_q, p_buffer, buffer_size,
|
|
|
|
current_field);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
return bytes_copied;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Announces that a buffer were filled and request the next
|
|
|
|
*/
|
|
|
|
static inline void vbi_buffer_filled(struct cx231xx *dev,
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_dmaqueue *dma_q,
|
|
|
|
struct cx231xx_buffer *buf)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
|
|
|
/* Advice that buffer was filled */
|
2013-02-07 22:07:40 +08:00
|
|
|
/* cx231xx_info("[%p/%d] wakeup\n", buf, buf->vb.i); */
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
buf->vb.state = VIDEOBUF_DONE;
|
|
|
|
buf->vb.field_count++;
|
2012-09-16 02:14:42 +08:00
|
|
|
v4l2_get_timestamp(&buf->vb.ts);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.buf = NULL;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
list_del(&buf->vb.queue);
|
|
|
|
wake_up(&buf->vb.done);
|
|
|
|
}
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
|
2009-03-04 00:31:36 +08:00
|
|
|
u8 *p_line, u32 length, int field_number)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
u32 bytes_to_copy;
|
|
|
|
struct cx231xx_buffer *buf;
|
|
|
|
u32 _line_size = dev->width * 2;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-09 02:45:13 +08:00
|
|
|
if (dma_q->current_field == -1) {
|
|
|
|
/* Just starting up */
|
2009-03-03 17:14:34 +08:00
|
|
|
cx231xx_reset_vbi_buffer(dev, dma_q);
|
2010-07-09 02:45:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dma_q->current_field != field_number)
|
|
|
|
dma_q->lines_completed = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
/* get the buffer pointer */
|
2010-07-07 05:12:25 +08:00
|
|
|
buf = dev->vbi_mode.bulk_ctl.buf;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
/* Remember the field number for next time */
|
|
|
|
dma_q->current_field = field_number;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
bytes_to_copy = dma_q->bytes_left_in_line;
|
|
|
|
if (bytes_to_copy > length)
|
|
|
|
bytes_to_copy = length;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
if (dma_q->lines_completed >= dma_q->lines_per_field) {
|
|
|
|
dma_q->bytes_left_in_line -= bytes_to_copy;
|
|
|
|
dma_q->is_partial_line =
|
|
|
|
(dma_q->bytes_left_in_line == 0) ? 0 : 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->is_partial_line = 1;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
/* If we don't have a buffer, just return the number of bytes we would
|
|
|
|
have copied if we had a buffer. */
|
|
|
|
if (!buf) {
|
|
|
|
dma_q->bytes_left_in_line -= bytes_to_copy;
|
|
|
|
dma_q->is_partial_line =
|
|
|
|
(dma_q->bytes_left_in_line == 0) ? 0 : 1;
|
|
|
|
return bytes_to_copy;
|
|
|
|
}
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
/* copy the data to video buffer */
|
|
|
|
cx231xx_do_vbi_copy(dev, dma_q, p_line, bytes_to_copy);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->pos += bytes_to_copy;
|
|
|
|
dma_q->bytes_left_in_line -= bytes_to_copy;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
if (dma_q->bytes_left_in_line == 0) {
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->bytes_left_in_line = _line_size;
|
|
|
|
dma_q->lines_completed++;
|
|
|
|
dma_q->is_partial_line = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
if (cx231xx_is_vbi_buffer_done(dev, dma_q) && buf) {
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
vbi_buffer_filled(dev, dma_q, buf);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->pos = 0;
|
|
|
|
dma_q->lines_completed = 0;
|
2010-07-09 02:45:13 +08:00
|
|
|
cx231xx_reset_vbi_buffer(dev, dma_q);
|
2009-03-03 17:14:34 +08:00
|
|
|
}
|
|
|
|
}
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
return bytes_to_copy;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* video-buf generic routine to get the next available buffer
|
|
|
|
*/
|
|
|
|
static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q,
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_buffer **buf)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_video_mode *vmode =
|
|
|
|
container_of(dma_q, struct cx231xx_video_mode, vidq);
|
|
|
|
struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode);
|
2009-03-04 01:37:50 +08:00
|
|
|
char *outp;
|
|
|
|
|
|
|
|
if (list_empty(&dma_q->active)) {
|
2013-02-07 22:07:40 +08:00
|
|
|
cx231xx_err("No active queue to serve\n");
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.buf = NULL;
|
2009-03-04 01:37:50 +08:00
|
|
|
*buf = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the next buffer */
|
|
|
|
*buf = list_entry(dma_q->active.next, struct cx231xx_buffer, vb.queue);
|
|
|
|
|
2011-03-31 09:57:33 +08:00
|
|
|
/* Cleans up buffer - Useful for testing for frame/URB loss */
|
2009-03-04 01:37:50 +08:00
|
|
|
outp = videobuf_to_vmalloc(&(*buf)->vb);
|
|
|
|
memset(outp, 0, (*buf)->vb.size);
|
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
dev->vbi_mode.bulk_ctl.buf = *buf;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
void cx231xx_reset_vbi_buffer(struct cx231xx *dev,
|
|
|
|
struct cx231xx_dmaqueue *dma_q)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
struct cx231xx_buffer *buf;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
buf = dev->vbi_mode.bulk_ctl.buf;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
if (buf == NULL) {
|
|
|
|
/* first try to get the buffer */
|
|
|
|
get_next_vbi_buf(dma_q, &buf);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->pos = 0;
|
|
|
|
dma_q->current_field = -1;
|
|
|
|
}
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
dma_q->bytes_left_in_line = dev->width << 1;
|
|
|
|
dma_q->lines_completed = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
|
2009-03-04 00:31:36 +08:00
|
|
|
u8 *p_buffer, u32 bytes_to_copy)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
u8 *p_out_buffer = NULL;
|
|
|
|
u32 current_line_bytes_copied = 0;
|
|
|
|
struct cx231xx_buffer *buf;
|
|
|
|
u32 _line_size = dev->width << 1;
|
|
|
|
void *startwrite;
|
|
|
|
int offset, lencopy;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-07 05:12:25 +08:00
|
|
|
buf = dev->vbi_mode.bulk_ctl.buf;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-04 00:31:36 +08:00
|
|
|
if (buf == NULL)
|
|
|
|
return -EINVAL;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
p_out_buffer = videobuf_to_vmalloc(&buf->vb);
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
if (dma_q->bytes_left_in_line != _line_size) {
|
|
|
|
current_line_bytes_copied =
|
|
|
|
_line_size - dma_q->bytes_left_in_line;
|
|
|
|
}
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-04 00:31:36 +08:00
|
|
|
offset = (dma_q->lines_completed * _line_size) +
|
|
|
|
current_line_bytes_copied;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2010-07-09 02:45:13 +08:00
|
|
|
if (dma_q->current_field == 2) {
|
|
|
|
/* Populate the second half of the frame */
|
|
|
|
offset += (dev->width * 2 * dma_q->lines_per_field);
|
|
|
|
}
|
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
/* prepare destination address */
|
2009-03-04 01:37:50 +08:00
|
|
|
startwrite = p_out_buffer + offset;
|
|
|
|
|
2009-03-04 00:31:36 +08:00
|
|
|
lencopy = dma_q->bytes_left_in_line > bytes_to_copy ?
|
|
|
|
bytes_to_copy : dma_q->bytes_left_in_line;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
memcpy(startwrite, p_buffer, lencopy);
|
2009-03-04 01:37:50 +08:00
|
|
|
|
2009-03-03 17:14:34 +08:00
|
|
|
return 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|
|
|
|
|
2009-03-04 00:31:36 +08:00
|
|
|
u8 cx231xx_is_vbi_buffer_done(struct cx231xx *dev,
|
|
|
|
struct cx231xx_dmaqueue *dma_q)
|
2009-03-04 01:37:50 +08:00
|
|
|
{
|
2009-03-03 17:14:34 +08:00
|
|
|
u32 height = 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
|
|
|
|
height = ((dev->norm & V4L2_STD_625_50) ?
|
2009-03-03 17:14:34 +08:00
|
|
|
PAL_VBI_LINES : NTSC_VBI_LINES);
|
2010-07-09 02:45:13 +08:00
|
|
|
if (dma_q->lines_completed == height && dma_q->current_field == 2)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
2009-03-04 01:37:50 +08:00
|
|
|
}
|