2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
/*
|
|
|
|
buffer queues.
|
|
|
|
Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
|
|
|
|
Copyright (C) 2004 Chris Kennedy <c@groovy.org>
|
|
|
|
Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ivtv-driver.h"
|
|
|
|
#include "ivtv-queue.h"
|
|
|
|
|
|
|
|
int ivtv_buf_copy_from_user(struct ivtv_stream *s, struct ivtv_buffer *buf, const char __user *src, int copybytes)
|
|
|
|
{
|
|
|
|
if (s->buf_size - buf->bytesused < copybytes)
|
|
|
|
copybytes = s->buf_size - buf->bytesused;
|
|
|
|
if (copy_from_user(buf->buf + buf->bytesused, src, copybytes)) {
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
buf->bytesused += copybytes;
|
|
|
|
return copybytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ivtv_buf_swap(struct ivtv_buffer *buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < buf->bytesused; i += 4)
|
|
|
|
swab32s((u32 *)(buf->buf + i));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ivtv_queue_init(struct ivtv_queue *q)
|
|
|
|
{
|
|
|
|
INIT_LIST_HEAD(&q->list);
|
|
|
|
q->buffers = 0;
|
|
|
|
q->length = 0;
|
|
|
|
q->bytesused = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_queue *q)
|
|
|
|
{
|
2008-04-23 01:46:03 +08:00
|
|
|
unsigned long flags;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
|
|
|
/* clear the buffer if it is going to be enqueued to the free queue */
|
|
|
|
if (q == &s->q_free) {
|
|
|
|
buf->bytesused = 0;
|
|
|
|
buf->readpos = 0;
|
|
|
|
buf->b_flags = 0;
|
2007-07-28 23:07:12 +08:00
|
|
|
buf->dma_xfer_cnt = 0;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
}
|
|
|
|
spin_lock_irqsave(&s->qlock, flags);
|
|
|
|
list_add_tail(&buf->list, &q->list);
|
|
|
|
q->buffers++;
|
|
|
|
q->length += s->buf_size;
|
|
|
|
q->bytesused += buf->bytesused - buf->readpos;
|
|
|
|
spin_unlock_irqrestore(&s->qlock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ivtv_buffer *ivtv_dequeue(struct ivtv_stream *s, struct ivtv_queue *q)
|
|
|
|
{
|
|
|
|
struct ivtv_buffer *buf = NULL;
|
2008-04-23 01:46:03 +08:00
|
|
|
unsigned long flags;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
|
|
|
spin_lock_irqsave(&s->qlock, flags);
|
|
|
|
if (!list_empty(&q->list)) {
|
|
|
|
buf = list_entry(q->list.next, struct ivtv_buffer, list);
|
|
|
|
list_del_init(q->list.next);
|
|
|
|
q->buffers--;
|
|
|
|
q->length -= s->buf_size;
|
|
|
|
q->bytesused -= buf->bytesused - buf->readpos;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&s->qlock, flags);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ivtv_queue_move_buf(struct ivtv_stream *s, struct ivtv_queue *from,
|
2007-07-28 23:07:12 +08:00
|
|
|
struct ivtv_queue *to, int clear)
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
{
|
|
|
|
struct ivtv_buffer *buf = list_entry(from->list.next, struct ivtv_buffer, list);
|
|
|
|
|
|
|
|
list_move_tail(from->list.next, &to->list);
|
|
|
|
from->buffers--;
|
|
|
|
from->length -= s->buf_size;
|
|
|
|
from->bytesused -= buf->bytesused - buf->readpos;
|
|
|
|
/* special handling for q_free */
|
|
|
|
if (clear)
|
2007-07-28 23:07:12 +08:00
|
|
|
buf->bytesused = buf->readpos = buf->b_flags = buf->dma_xfer_cnt = 0;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
to->buffers++;
|
|
|
|
to->length += s->buf_size;
|
|
|
|
to->bytesused += buf->bytesused - buf->readpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move 'needed_bytes' worth of buffers from queue 'from' into queue 'to'.
|
|
|
|
If 'needed_bytes' == 0, then move all buffers from 'from' into 'to'.
|
|
|
|
If 'steal' != NULL, then buffers may also taken from that queue if
|
2007-07-28 23:07:12 +08:00
|
|
|
needed, but only if 'from' is the free queue.
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
|
|
|
The buffer is automatically cleared if it goes to the free queue. It is
|
|
|
|
also cleared if buffers need to be taken from the 'steal' queue and
|
|
|
|
the 'from' queue is the free queue.
|
|
|
|
|
|
|
|
When 'from' is q_free, then needed_bytes is compared to the total
|
|
|
|
available buffer length, otherwise needed_bytes is compared to the
|
|
|
|
bytesused value. For the 'steal' queue the total available buffer
|
|
|
|
length is always used.
|
|
|
|
|
|
|
|
-ENOMEM is returned if the buffers could not be obtained, 0 if all
|
|
|
|
buffers where obtained from the 'from' list and if non-zero then
|
|
|
|
the number of stolen buffers is returned. */
|
|
|
|
int ivtv_queue_move(struct ivtv_stream *s, struct ivtv_queue *from, struct ivtv_queue *steal,
|
|
|
|
struct ivtv_queue *to, int needed_bytes)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int rc = 0;
|
|
|
|
int from_free = from == &s->q_free;
|
|
|
|
int to_free = to == &s->q_free;
|
2007-07-28 23:07:12 +08:00
|
|
|
int bytes_available, bytes_steal;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
|
|
|
spin_lock_irqsave(&s->qlock, flags);
|
|
|
|
if (needed_bytes == 0) {
|
|
|
|
from_free = 1;
|
|
|
|
needed_bytes = from->length;
|
|
|
|
}
|
|
|
|
|
|
|
|
bytes_available = from_free ? from->length : from->bytesused;
|
2007-07-28 23:07:12 +08:00
|
|
|
bytes_steal = (from_free && steal) ? steal->length : 0;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
2007-07-28 23:07:12 +08:00
|
|
|
if (bytes_available + bytes_steal < needed_bytes) {
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
spin_unlock_irqrestore(&s->qlock, flags);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2016-02-23 00:27:20 +08:00
|
|
|
while (steal && bytes_available < needed_bytes) {
|
2007-07-28 23:07:12 +08:00
|
|
|
struct ivtv_buffer *buf = list_entry(steal->list.prev, struct ivtv_buffer, list);
|
|
|
|
u16 dma_xfer_cnt = buf->dma_xfer_cnt;
|
|
|
|
|
|
|
|
/* move buffers from the tail of the 'steal' queue to the tail of the
|
|
|
|
'from' queue. Always copy all the buffers with the same dma_xfer_cnt
|
|
|
|
value, this ensures that you do not end up with partial frame data
|
|
|
|
if one frame is stored in multiple buffers. */
|
|
|
|
while (dma_xfer_cnt == buf->dma_xfer_cnt) {
|
|
|
|
list_move_tail(steal->list.prev, &from->list);
|
|
|
|
rc++;
|
|
|
|
steal->buffers--;
|
|
|
|
steal->length -= s->buf_size;
|
|
|
|
steal->bytesused -= buf->bytesused - buf->readpos;
|
|
|
|
buf->bytesused = buf->readpos = buf->b_flags = buf->dma_xfer_cnt = 0;
|
|
|
|
from->buffers++;
|
|
|
|
from->length += s->buf_size;
|
|
|
|
bytes_available += s->buf_size;
|
|
|
|
if (list_empty(&steal->list))
|
|
|
|
break;
|
|
|
|
buf = list_entry(steal->list.prev, struct ivtv_buffer, list);
|
|
|
|
}
|
|
|
|
}
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
if (from_free) {
|
|
|
|
u32 old_length = to->length;
|
|
|
|
|
|
|
|
while (to->length - old_length < needed_bytes) {
|
2007-07-28 23:07:12 +08:00
|
|
|
ivtv_queue_move_buf(s, from, to, 1);
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
u32 old_bytesused = to->bytesused;
|
|
|
|
|
|
|
|
while (to->bytesused - old_bytesused < needed_bytes) {
|
2007-07-28 23:07:12 +08:00
|
|
|
ivtv_queue_move_buf(s, from, to, to_free);
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&s->qlock, flags);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ivtv_flush_queues(struct ivtv_stream *s)
|
|
|
|
{
|
|
|
|
ivtv_queue_move(s, &s->q_io, NULL, &s->q_free, 0);
|
|
|
|
ivtv_queue_move(s, &s->q_full, NULL, &s->q_free, 0);
|
|
|
|
ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0);
|
|
|
|
ivtv_queue_move(s, &s->q_predma, NULL, &s->q_free, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ivtv_stream_alloc(struct ivtv_stream *s)
|
|
|
|
{
|
|
|
|
struct ivtv *itv = s->itv;
|
2008-05-21 11:31:41 +08:00
|
|
|
int SGsize = sizeof(struct ivtv_sg_host_element) * s->buffers;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (s->buffers == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
IVTV_DEBUG_INFO("Allocate %s%s stream: %d x %d buffers (%dkB total)\n",
|
|
|
|
s->dma != PCI_DMA_NONE ? "DMA " : "",
|
|
|
|
s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024);
|
|
|
|
|
2008-05-01 21:31:12 +08:00
|
|
|
s->sg_pending = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN);
|
2007-07-29 06:45:50 +08:00
|
|
|
if (s->sg_pending == NULL) {
|
|
|
|
IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name);
|
|
|
|
return -ENOMEM;
|
2007-05-20 01:07:16 +08:00
|
|
|
}
|
2007-07-29 06:45:50 +08:00
|
|
|
s->sg_pending_size = 0;
|
2007-05-20 01:07:16 +08:00
|
|
|
|
2008-05-01 21:31:12 +08:00
|
|
|
s->sg_processing = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN);
|
2007-07-29 06:45:50 +08:00
|
|
|
if (s->sg_processing == NULL) {
|
|
|
|
IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name);
|
|
|
|
kfree(s->sg_pending);
|
|
|
|
s->sg_pending = NULL;
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
s->sg_processing_size = 0;
|
|
|
|
|
2008-05-01 21:31:12 +08:00
|
|
|
s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element),
|
|
|
|
GFP_KERNEL|__GFP_NOWARN);
|
2007-07-29 06:45:50 +08:00
|
|
|
if (s->sg_dma == NULL) {
|
|
|
|
IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name);
|
|
|
|
kfree(s->sg_pending);
|
|
|
|
s->sg_pending = NULL;
|
|
|
|
kfree(s->sg_processing);
|
|
|
|
s->sg_processing = NULL;
|
2007-05-20 01:07:16 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
if (ivtv_might_use_dma(s)) {
|
2009-06-05 18:56:18 +08:00
|
|
|
s->sg_handle = pci_map_single(itv->pdev, s->sg_dma,
|
|
|
|
sizeof(struct ivtv_sg_element), PCI_DMA_TODEVICE);
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
ivtv_stream_sync_for_cpu(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate stream buffers. Initially all buffers are in q_free. */
|
|
|
|
for (i = 0; i < s->buffers; i++) {
|
2008-05-01 21:31:12 +08:00
|
|
|
struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer),
|
|
|
|
GFP_KERNEL|__GFP_NOWARN);
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
|
|
|
if (buf == NULL)
|
|
|
|
break;
|
2008-05-01 21:31:12 +08:00
|
|
|
buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL|__GFP_NOWARN);
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
if (buf->buf == NULL) {
|
|
|
|
kfree(buf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
INIT_LIST_HEAD(&buf->list);
|
2007-05-20 01:07:16 +08:00
|
|
|
if (ivtv_might_use_dma(s)) {
|
2009-02-07 18:02:27 +08:00
|
|
|
buf->dma_handle = pci_map_single(s->itv->pdev,
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
buf->buf, s->buf_size + 256, s->dma);
|
|
|
|
ivtv_buf_sync_for_cpu(s, buf);
|
|
|
|
}
|
|
|
|
ivtv_enqueue(s, buf, &s->q_free);
|
|
|
|
}
|
|
|
|
if (i == s->buffers)
|
|
|
|
return 0;
|
|
|
|
IVTV_ERR("Couldn't allocate buffers for %s stream\n", s->name);
|
|
|
|
ivtv_stream_free(s);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ivtv_stream_free(struct ivtv_stream *s)
|
|
|
|
{
|
|
|
|
struct ivtv_buffer *buf;
|
|
|
|
|
|
|
|
/* move all buffers to q_free */
|
|
|
|
ivtv_flush_queues(s);
|
|
|
|
|
|
|
|
/* empty q_free */
|
|
|
|
while ((buf = ivtv_dequeue(s, &s->q_free))) {
|
2007-05-20 01:07:16 +08:00
|
|
|
if (ivtv_might_use_dma(s))
|
2009-02-07 18:02:27 +08:00
|
|
|
pci_unmap_single(s->itv->pdev, buf->dma_handle,
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
s->buf_size + 256, s->dma);
|
|
|
|
kfree(buf->buf);
|
|
|
|
kfree(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free SG Array/Lists */
|
2007-07-29 06:45:50 +08:00
|
|
|
if (s->sg_dma != NULL) {
|
|
|
|
if (s->sg_handle != IVTV_DMA_UNMAPPED) {
|
2009-02-07 18:02:27 +08:00
|
|
|
pci_unmap_single(s->itv->pdev, s->sg_handle,
|
2007-07-29 06:45:50 +08:00
|
|
|
sizeof(struct ivtv_sg_element), PCI_DMA_TODEVICE);
|
|
|
|
s->sg_handle = IVTV_DMA_UNMAPPED;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
}
|
2007-07-29 06:45:50 +08:00
|
|
|
kfree(s->sg_pending);
|
|
|
|
kfree(s->sg_processing);
|
|
|
|
kfree(s->sg_dma);
|
|
|
|
s->sg_pending = NULL;
|
|
|
|
s->sg_processing = NULL;
|
|
|
|
s->sg_dma = NULL;
|
|
|
|
s->sg_pending_size = 0;
|
|
|
|
s->sg_processing_size = 0;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
}
|
|
|
|
}
|