summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/dvb-core
diff options
context:
space:
mode:
authorHolger Waechtler <devnull@localhost>2002-12-20 14:52:47 +0000
committerHolger Waechtler <devnull@localhost>2002-12-20 14:52:47 +0000
commit8d8e07ac4e9d94bb8a9b26e3180bcb4fa3b82074 (patch)
tree0314908eed408456b94fb06a01513ca0d32119e1 /linux/drivers/media/dvb/dvb-core
parente62b273dd417c051d1624d6854414d6054e6a131 (diff)
downloadmediapointer-dvb-s2-8d8e07ac4e9d94bb8a9b26e3180bcb4fa3b82074.tar.gz
mediapointer-dvb-s2-8d8e07ac4e9d94bb8a9b26e3180bcb4fa3b82074.tar.bz2
- fix the not-checked-return value at start_feed() bug
- code review + simplification - use const pointers in section and ts callbacks
Diffstat (limited to 'linux/drivers/media/dvb/dvb-core')
-rw-r--r--linux/drivers/media/dvb/dvb-core/demux.h8
-rw-r--r--linux/drivers/media/dvb/dvb-core/dmxdev.c681
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_demux.c1278
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_demux.h11
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_filter.c4
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_filter.h2
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_net.c10
7 files changed, 1015 insertions, 979 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/demux.h b/linux/drivers/media/dvb/dvb-core/demux.h
index 2c37d415f..1042bdab1 100644
--- a/linux/drivers/media/dvb/dvb-core/demux.h
+++ b/linux/drivers/media/dvb/dvb-core/demux.h
@@ -170,16 +170,16 @@ typedef struct dmx_section_feed_s dmx_section_feed_t;
/* Callback functions */
/*--------------------------------------------------------------------------*/
-typedef int (*dmx_ts_cb) ( __u8 * buffer1,
+typedef int (*dmx_ts_cb) ( const u8 * buffer1,
size_t buffer1_length,
- __u8 * buffer2,
+ const u8 * buffer2,
size_t buffer2_length,
dmx_ts_feed_t* source,
dmx_success_t success);
-typedef int (*dmx_section_cb) ( __u8 * buffer1,
+typedef int (*dmx_section_cb) ( const u8 * buffer1,
size_t buffer1_len,
- __u8 * buffer2,
+ const u8 * buffer2,
size_t buffer2_len,
dmx_section_filter_t * source,
dmx_success_t success);
diff --git a/linux/drivers/media/dvb/dvb-core/dmxdev.c b/linux/drivers/media/dvb/dvb-core/dmxdev.c
index 13e8beab3..280a76f6d 100644
--- a/linux/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/linux/drivers/media/dvb/dvb-core/dmxdev.c
@@ -2,8 +2,8 @@
* dmxdev.c - DVB demultiplexer device
*
* Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
- * & Marcus Metzler <marcus@convergence.de>
- for convergence integrated media GmbH
+ * & Marcus Metzler <marcus@convergence.de>
+ for convergence integrated media GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -44,70 +44,70 @@ static int debug = 0;
inline dmxdev_filter_t *
dvb_dmxdev_file_to_filter(struct file *file)
{
- return (dmxdev_filter_t *) file->private_data;
+ return (dmxdev_filter_t *) file->private_data;
}
inline dmxdev_dvr_t *
dvb_dmxdev_file_to_dvr(dmxdev_t *dmxdev, struct file *file)
{
- return (dmxdev_dvr_t *) file->private_data;
+ return (dmxdev_dvr_t *) file->private_data;
}
static inline void
dvb_dmxdev_buffer_init(dmxdev_buffer_t *buffer)
{
- buffer->data=0;
- buffer->size=8192;
- buffer->pread=0;
- buffer->pwrite=0;
- buffer->error=0;
- init_waitqueue_head(&buffer->queue);
+ buffer->data=0;
+ buffer->size=8192;
+ buffer->pread=0;
+ buffer->pwrite=0;
+ buffer->error=0;
+ init_waitqueue_head(&buffer->queue);
}
-static inline int
-dvb_dmxdev_buffer_write(dmxdev_buffer_t *buf, uint8_t *src, int len)
+static inline
+int dvb_dmxdev_buffer_write(dmxdev_buffer_t *buf, const u8 *src, int len)
{
- int split;
- int free;
- int todo;
+ int split;
+ int free;
+ int todo;
if (!len)
- return 0;
+ return 0;
if (!buf->data)
- return 0;
+ return 0;
- free=buf->pread-buf->pwrite;
- split=0;
- if (free<=0) {
- free+=buf->size;
- split=buf->size-buf->pwrite;
- }
- if (len>=free) {
+ free=buf->pread-buf->pwrite;
+ split=0;
+ if (free<=0) {
+ free+=buf->size;
+ split=buf->size-buf->pwrite;
+ }
+ if (len>=free) {
dprintk("dmxdev: buffer overflow\n");
- return -1;
+ return -1;
+ }
+ if (split>=len)
+ split=0;
+ todo=len;
+ if (split) {
+ memcpy(buf->data + buf->pwrite, src, split);
+ todo-=split;
+ buf->pwrite=0;
}
- if (split>=len)
- split=0;
- todo=len;
- if (split) {
- memcpy(buf->data + buf->pwrite, src, split);
- todo-=split;
- buf->pwrite=0;
- }
- memcpy(buf->data + buf->pwrite, src+split, todo);
- buf->pwrite=(buf->pwrite+todo)%buf->size;
- return len;
+ memcpy(buf->data + buf->pwrite, src+split, todo);
+ buf->pwrite=(buf->pwrite+todo)%buf->size;
+ return len;
}
static ssize_t
dvb_dmxdev_buffer_read(dmxdev_buffer_t *src, int non_blocking,
- char *buf, size_t count, loff_t *ppos)
+ char *buf, size_t count, loff_t *ppos)
{
- unsigned long todo=count;
- int split, avail, error;
+ unsigned long todo=count;
+ int split, avail, error;
if (!src->data)
- return 0;
+ return 0;
if ((error=src->error)) {
src->pwrite=src->pread;
@@ -116,61 +116,61 @@ dvb_dmxdev_buffer_read(dmxdev_buffer_t *src, int non_blocking,
}
if (non_blocking && (src->pwrite==src->pread))
- return -EWOULDBLOCK;
+ return -EWOULDBLOCK;
- while (todo>0) {
- if (non_blocking && (src->pwrite==src->pread))
- return (count-todo) ? (count-todo) : -EWOULDBLOCK;
+ while (todo>0) {
+ if (non_blocking && (src->pwrite==src->pread))
+ return (count-todo) ? (count-todo) : -EWOULDBLOCK;
- if (wait_event_interruptible(src->queue,
+ if (wait_event_interruptible(src->queue,
(src->pread!=src->pwrite) ||
(src->error))<0)
- return count-todo;
+ return count-todo;
if ((error=src->error)) {
src->pwrite=src->pread;
- src->error=0;
+ src->error=0;
return error;
}
- split=src->size;
- avail=src->pwrite - src->pread;
- if (avail<0) {
- avail+=src->size;
- split=src->size - src->pread;
- }
- if (avail>todo)
- avail=todo;
- if (split<avail) {
- if (copy_to_user(buf, src->data+src->pread, split))
- return -EFAULT;
- buf+=split;
- src->pread=0;
- todo-=split;
- avail-=split;
- }
- if (avail) {
- if (copy_to_user(buf, src->data+src->pread, avail))
- return -EFAULT;
- src->pread = (src->pread + avail) % src->size;
- todo-=avail;
- buf+=avail;
- }
- }
- return count;
+ split=src->size;
+ avail=src->pwrite - src->pread;
+ if (avail<0) {
+ avail+=src->size;
+ split=src->size - src->pread;
+ }
+ if (avail>todo)
+ avail=todo;
+ if (split<avail) {
+ if (copy_to_user(buf, src->data+src->pread, split))
+ return -EFAULT;
+ buf+=split;
+ src->pread=0;
+ todo-=split;
+ avail-=split;
+ }
+ if (avail) {
+ if (copy_to_user(buf, src->data+src->pread, avail))
+ return -EFAULT;
+ src->pread = (src->pread + avail) % src->size;
+ todo-=avail;
+ buf+=avail;
+ }
+ }
+ return count;
}
static dmx_frontend_t *
get_fe(dmx_demux_t *demux, int type)
{
- struct list_head *head, *pos;
+ struct list_head *head, *pos;
- head=demux->get_frontends(demux);
+ head=demux->get_frontends(demux);
if (!head)
- return 0;
+ return 0;
list_for_each(pos, head)
- if (DMX_FE_ENTRY(pos)->source==type)
- return DMX_FE_ENTRY(pos);
+ if (DMX_FE_ENTRY(pos)->source==type)
+ return DMX_FE_ENTRY(pos);
return 0;
}
@@ -178,8 +178,8 @@ get_fe(dmx_demux_t *demux, int type)
static inline void
dvb_dmxdev_dvr_state_set(dmxdev_dvr_t *dmxdevdvr, int state)
{
- spin_lock_irq(&dmxdevdvr->dev->lock);
- dmxdevdvr->state=state;
+ spin_lock_irq(&dmxdevdvr->dev->lock);
+ dmxdevdvr->state=state;
spin_unlock_irq(&dmxdevdvr->dev->lock);
}
@@ -187,17 +187,17 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
- dmx_frontend_t *front;
+ dmx_frontend_t *front;
- dprintk ("function : %s\n", __FUNCTION__);
+ dprintk ("function : %s\n", __FUNCTION__);
- if (down_interruptible (&dmxdev->mutex))
+ if (down_interruptible (&dmxdev->mutex))
return -ERESTARTSYS;
if ((file->f_flags&O_ACCMODE)==O_RDWR) {
- if (!(dmxdev->capabilities&DMXDEV_CAP_DUPLEX)) {
+ if (!(dmxdev->capabilities&DMXDEV_CAP_DUPLEX)) {
up(&dmxdev->mutex);
- return -EOPNOTSUPP;
+ return -EOPNOTSUPP;
}
}
@@ -207,12 +207,12 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
dmxdev->dvr_buffer.data=vmalloc(DVR_BUFFER_SIZE);
if (!dmxdev->dvr_buffer.data) {
up(&dmxdev->mutex);
- return -ENOMEM;
+ return -ENOMEM;
}
}
if ((file->f_flags&O_ACCMODE)==O_WRONLY) {
- dmxdev->dvr_orig_fe=dmxdev->demux->frontend;
+ dmxdev->dvr_orig_fe=dmxdev->demux->frontend;
if (!dmxdev->demux->write) {
up(&dmxdev->mutex);
@@ -223,13 +223,13 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
if (!front) {
up(&dmxdev->mutex);
- return -EINVAL;
+ return -EINVAL;
}
dmxdev->demux->disconnect_frontend(dmxdev->demux);
dmxdev->demux->connect_frontend(dmxdev->demux, front);
}
- up(&dmxdev->mutex);
- return 0;
+ up(&dmxdev->mutex);
+ return 0;
}
static int dvb_dvr_release(struct inode *inode, struct file *file)
@@ -237,25 +237,25 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
- if (down_interruptible (&dmxdev->mutex))
+ if (down_interruptible (&dmxdev->mutex))
return -ERESTARTSYS;
if ((file->f_flags&O_ACCMODE)==O_WRONLY) {
- dmxdev->demux->disconnect_frontend(dmxdev->demux);
+ dmxdev->demux->disconnect_frontend(dmxdev->demux);
dmxdev->demux->connect_frontend(dmxdev->demux,
dmxdev->dvr_orig_fe);
}
if ((file->f_flags&O_ACCMODE)==O_RDONLY) {
if (dmxdev->dvr_buffer.data) {
- void *mem=dmxdev->dvr_buffer.data;
+ void *mem=dmxdev->dvr_buffer.data;
mb();
spin_lock_irq(&dmxdev->lock);
dmxdev->dvr_buffer.data=0;
spin_unlock_irq(&dmxdev->lock);
- vfree(mem);
+ vfree(mem);
}
}
- up(&dmxdev->mutex);
+ up(&dmxdev->mutex);
return 0;
}
@@ -266,14 +266,14 @@ dvb_dvr_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
int ret;
- if (!dmxdev->demux->write)
- return -EOPNOTSUPP;
+ if (!dmxdev->demux->write)
+ return -EOPNOTSUPP;
if ((file->f_flags&O_ACCMODE)!=O_WRONLY)
- return -EINVAL;
- if (down_interruptible (&dmxdev->mutex))
+ return -EINVAL;
+ if (down_interruptible (&dmxdev->mutex))
return -ERESTARTSYS;
- ret=dmxdev->demux->write(dmxdev->demux, buf, count);
- up(&dmxdev->mutex);
+ ret=dmxdev->demux->write(dmxdev->demux, buf, count);
+ up(&dmxdev->mutex);
return ret;
}
@@ -284,19 +284,19 @@ dvb_dvr_read(struct file *file, char *buf, size_t count, loff_t *ppos)
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
int ret;
- //down(&dmxdev->mutex);
- ret= dvb_dmxdev_buffer_read(&dmxdev->dvr_buffer,
+ //down(&dmxdev->mutex);
+ ret= dvb_dmxdev_buffer_read(&dmxdev->dvr_buffer,
file->f_flags&O_NONBLOCK,
buf, count, ppos);
- //up(&dmxdev->mutex);
+ //up(&dmxdev->mutex);
return ret;
}
static inline void
dvb_dmxdev_filter_state_set(dmxdev_filter_t *dmxdevfilter, int state)
{
- spin_lock_irq(&dmxdevfilter->dev->lock);
- dmxdevfilter->state=state;
+ spin_lock_irq(&dmxdevfilter->dev->lock);
+ dmxdevfilter->state=state;
spin_unlock_irq(&dmxdevfilter->dev->lock);
}
@@ -307,25 +307,25 @@ dvb_dmxdev_set_buffer_size(dmxdev_filter_t *dmxdevfilter, unsigned long size)
void *mem;
if (buf->size==size)
- return 0;
- if (dmxdevfilter->state>=DMXDEV_STATE_GO)
- return -EBUSY;
+ return 0;
+ if (dmxdevfilter->state>=DMXDEV_STATE_GO)
+ return -EBUSY;
spin_lock_irq(&dmxdevfilter->dev->lock);
mem=buf->data;
buf->data=0;
buf->size=size;
buf->pwrite=buf->pread=0;
spin_unlock_irq(&dmxdevfilter->dev->lock);
- if (mem)
+ if (mem)
vfree(mem);
- if (buf->size) {
- mem=vmalloc(dmxdevfilter->buffer.size);
+ if (buf->size) {
+ mem=vmalloc(dmxdevfilter->buffer.size);
if (!mem)
- return -ENOMEM;
- spin_lock_irq(&dmxdevfilter->dev->lock);
- buf->data=mem;
- spin_unlock_irq(&dmxdevfilter->dev->lock);
+ return -ENOMEM;
+ spin_lock_irq(&dmxdevfilter->dev->lock);
+ buf->data=mem;
+ spin_unlock_irq(&dmxdevfilter->dev->lock);
}
return 0;
}
@@ -333,23 +333,23 @@ dvb_dmxdev_set_buffer_size(dmxdev_filter_t *dmxdevfilter, unsigned long size)
static void
dvb_dmxdev_filter_timeout(unsigned long data)
{
- dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *)data;
+ dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *)data;
dmxdevfilter->buffer.error=-ETIMEDOUT;
- spin_lock_irq(&dmxdevfilter->dev->lock);
+ spin_lock_irq(&dmxdevfilter->dev->lock);
dmxdevfilter->state=DMXDEV_STATE_TIMEDOUT;
- spin_unlock_irq(&dmxdevfilter->dev->lock);
+ spin_unlock_irq(&dmxdevfilter->dev->lock);
wake_up(&dmxdevfilter->buffer.queue);
}
static void
dvb_dmxdev_filter_timer(dmxdev_filter_t *dmxdevfilter)
{
- struct dmx_sct_filter_params *para=&dmxdevfilter->params.sec;
+ struct dmx_sct_filter_params *para=&dmxdevfilter->params.sec;
del_timer(&dmxdevfilter->timer);
if (para->timeout) {
- dmxdevfilter->timer.function=dvb_dmxdev_filter_timeout;
+ dmxdevfilter->timer.function=dvb_dmxdev_filter_timeout;
dmxdevfilter->timer.data=(unsigned long) dmxdevfilter;
dmxdevfilter->timer.expires=jiffies+1+(HZ/2+HZ*para->timeout)/1000;
add_timer(&dmxdevfilter->timer);
@@ -357,53 +357,51 @@ dvb_dmxdev_filter_timer(dmxdev_filter_t *dmxdevfilter)
}
static int
-dvb_dmxdev_section_callback(u8 *buffer1, size_t buffer1_len,
- u8 *buffer2, size_t buffer2_len,
- dmx_section_filter_t *filter,
- dmx_success_t success)
+dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
+ const u8 *buffer2, size_t buffer2_len,
+ dmx_section_filter_t *filter, dmx_success_t success)
{
- dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *) filter->priv;
- int ret;
-
+ dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *) filter->priv;
+ int ret;
+
if (dmxdevfilter->buffer.error) {
wake_up(&dmxdevfilter->buffer.queue);
- return 0;
+ return 0;
}
spin_lock(&dmxdevfilter->dev->lock);
if (dmxdevfilter->state!=DMXDEV_STATE_GO) {
spin_unlock(&dmxdevfilter->dev->lock);
- return 0;
+ return 0;
}
del_timer(&dmxdevfilter->timer);
dprintk("dmxdev: section callback %02x %02x %02x %02x %02x %02x\n",
buffer1[0], buffer1[1],
buffer1[2], buffer1[3],
buffer1[4], buffer1[5]);
- ret=dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1, buffer1_len);
- if (ret==buffer1_len) {
- ret=dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer2, buffer2_len);
+ ret=dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1, buffer1_len);
+ if (ret==buffer1_len) {
+ ret=dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer2, buffer2_len);
}
- if (ret<0) {
- dmxdevfilter->buffer.pwrite=dmxdevfilter->buffer.pread;
- dmxdevfilter->buffer.error=-EOVERFLOW;
+ if (ret<0) {
+ dmxdevfilter->buffer.pwrite=dmxdevfilter->buffer.pread;
+ dmxdevfilter->buffer.error=-EOVERFLOW;
}
if (dmxdevfilter->params.sec.flags&DMX_ONESHOT)
- dmxdevfilter->state=DMXDEV_STATE_DONE;
+ dmxdevfilter->state=DMXDEV_STATE_DONE;
spin_unlock(&dmxdevfilter->dev->lock);
wake_up(&dmxdevfilter->buffer.queue);
return 0;
}
static int
-dvb_dmxdev_ts_callback(u8 *buffer1, size_t buffer1_len,
- u8 *buffer2, size_t buffer2_len,
- dmx_ts_feed_t *feed,
- dmx_success_t success)
+dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
+ const u8 *buffer2, size_t buffer2_len,
+ dmx_ts_feed_t *feed, dmx_success_t success)
{
- dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *) feed->priv;
+ dmxdev_filter_t *dmxdevfilter=(dmxdev_filter_t *) feed->priv;
dmxdev_buffer_t *buffer;
- int ret;
-
+ int ret;
+
spin_lock(&dmxdevfilter->dev->lock);
if (dmxdevfilter->params.pes.output==DMX_OUT_DECODER) {
spin_unlock(&dmxdevfilter->dev->lock);
@@ -411,20 +409,20 @@ dvb_dmxdev_ts_callback(u8 *buffer1, size_t buffer1_len,
}
if (dmxdevfilter->params.pes.output==DMX_OUT_TAP)
- buffer=&dmxdevfilter->buffer;
+ buffer=&dmxdevfilter->buffer;
else
- buffer=&dmxdevfilter->dev->dvr_buffer;
+ buffer=&dmxdevfilter->dev->dvr_buffer;
if (buffer->error) {
spin_unlock(&dmxdevfilter->dev->lock);
wake_up(&buffer->queue);
- return 0;
+ return 0;
}
- ret=dvb_dmxdev_buffer_write(buffer, buffer1, buffer1_len);
- if (ret==buffer1_len)
- ret=dvb_dmxdev_buffer_write(buffer, buffer2, buffer2_len);
- if (ret<0) {
- buffer->pwrite=buffer->pread;
- buffer->error=-EOVERFLOW;
+ ret=dvb_dmxdev_buffer_write(buffer, buffer1, buffer1_len);
+ if (ret==buffer1_len)
+ ret=dvb_dmxdev_buffer_write(buffer, buffer2, buffer2_len);
+ if (ret<0) {
+ buffer->pwrite=buffer->pread;
+ buffer->error=-EOVERFLOW;
}
spin_unlock(&dmxdevfilter->dev->lock);
wake_up(&buffer->queue);
@@ -441,49 +439,50 @@ dvb_dmxdev_feed_stop(dmxdev_filter_t *dmxdevfilter)
switch (dmxdevfilter->type) {
case DMXDEV_TYPE_SEC:
- del_timer(&dmxdevfilter->timer);
- dmxdevfilter->feed.sec->stop_filtering(dmxdevfilter->feed.sec);
+ del_timer(&dmxdevfilter->timer);
+ dmxdevfilter->feed.sec->stop_filtering(dmxdevfilter->feed.sec);
break;
case DMXDEV_TYPE_PES:
- dmxdevfilter->feed.ts->stop_filtering(dmxdevfilter->feed.ts);
+ dmxdevfilter->feed.ts->stop_filtering(dmxdevfilter->feed.ts);
break;
default:
- return -EINVAL;
+ return -EINVAL;
}
- return 0;
+ return 0;
}
/* start feed associated with the specified filter */
-static int
-dvb_dmxdev_feed_start(dmxdev_filter_t *dmxdevfilter)
+static
+int dvb_dmxdev_feed_start(dmxdev_filter_t *filter)
{
- dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_GO);
+ dvb_dmxdev_filter_state_set (filter, DMXDEV_STATE_GO);
- switch (dmxdevfilter->type) {
+ switch (filter->type) {
case DMXDEV_TYPE_SEC:
- dmxdevfilter->feed.sec->start_filtering(dmxdevfilter->feed.sec);
+ return filter->feed.sec->start_filtering(filter->feed.sec);
break;
case DMXDEV_TYPE_PES:
- dmxdevfilter->feed.ts->start_filtering(dmxdevfilter->feed.ts);
+ return filter->feed.ts->start_filtering(filter->feed.ts);
break;
default:
- return -EINVAL;
+ return -EINVAL;
}
- return 0;
+
+ return 0;
}
/* restart section feed if it has filters left associated with it,
otherwise release the feed */
-static int
-dvb_dmxdev_feed_restart(dmxdev_filter_t *dmxdevfilter)
+static
+int dvb_dmxdev_feed_restart(dmxdev_filter_t *filter)
{
int i;
- dmxdev_t *dmxdev=dmxdevfilter->dev;
- uint16_t pid=dmxdevfilter->params.sec.pid;
+ dmxdev_t *dmxdev = filter->dev;
+ uint16_t pid = filter->params.sec.pid;
for (i=0; i<dmxdev->filternum; i++)
if (dmxdev->filter[i].state>=DMXDEV_STATE_GO &&
@@ -493,36 +492,34 @@ dvb_dmxdev_feed_restart(dmxdev_filter_t *dmxdevfilter)
return 0;
}
- dmxdevfilter->dev->demux->
- release_section_feed(dmxdev->demux,
- dmxdevfilter->feed.sec);
+ filter->dev->demux->release_section_feed(dmxdev->demux, filter->feed.sec);
- return 0;
+ return 0;
}
static int
dvb_dmxdev_filter_stop(dmxdev_filter_t *dmxdevfilter)
{
- if (dmxdevfilter->state<DMXDEV_STATE_GO)
- return 0;
+ if (dmxdevfilter->state<DMXDEV_STATE_GO)
+ return 0;
switch (dmxdevfilter->type) {
case DMXDEV_TYPE_SEC:
- if (!dmxdevfilter->feed.sec)
- break;
- dvb_dmxdev_feed_stop(dmxdevfilter);
- if (dmxdevfilter->filter.sec)
- dmxdevfilter->feed.sec->
+ if (!dmxdevfilter->feed.sec)
+ break;
+ dvb_dmxdev_feed_stop(dmxdevfilter);
+ if (dmxdevfilter->filter.sec)
+ dmxdevfilter->feed.sec->
release_filter(dmxdevfilter->feed.sec,
dmxdevfilter->filter.sec);
- dvb_dmxdev_feed_restart(dmxdevfilter);
+ dvb_dmxdev_feed_restart(dmxdevfilter);
dmxdevfilter->feed.sec=0;
break;
case DMXDEV_TYPE_PES:
- if (!dmxdevfilter->feed.ts)
- break;
- dvb_dmxdev_feed_stop(dmxdevfilter);
- dmxdevfilter->dev->demux->
+ if (!dmxdevfilter->feed.ts)
+ break;
+ dvb_dmxdev_feed_stop(dmxdevfilter);
+ dmxdevfilter->dev->demux->
release_ts_feed(dmxdevfilter->dev->demux,
dmxdevfilter->feed.ts);
dmxdevfilter->feed.ts=0;
@@ -530,10 +527,10 @@ dvb_dmxdev_filter_stop(dmxdev_filter_t *dmxdevfilter)
default:
if (dmxdevfilter->state==DMXDEV_STATE_ALLOCATED)
return 0;
- return -EINVAL;
+ return -EINVAL;
}
dmxdevfilter->buffer.pwrite=dmxdevfilter->buffer.pread=0;
- return 0;
+ return 0;
}
static inline int
@@ -545,58 +542,59 @@ dvb_dmxdev_filter_reset(dmxdev_filter_t *dmxdevfilter)
dmxdevfilter->type=DMXDEV_TYPE_NONE;
dmxdevfilter->pid=0xffff;
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
- return 0;
+ return 0;
}
static int
-dvb_dmxdev_filter_start(dmxdev_filter_t *dmxdevfilter)
+dvb_dmxdev_filter_start(dmxdev_filter_t *filter)
{
- dmxdev_t *dmxdev=dmxdevfilter->dev;
+ dmxdev_t *dmxdev = filter->dev;
void *mem;
int ret, i;
- if (dmxdevfilter->state<DMXDEV_STATE_SET)
- return -EINVAL;
+ if (filter->state < DMXDEV_STATE_SET)
+ return -EINVAL;
- if (dmxdevfilter->state>=DMXDEV_STATE_GO)
- dvb_dmxdev_filter_stop(dmxdevfilter);
-
- if (!(mem = dmxdevfilter->buffer.data)) {
- mem=vmalloc(dmxdevfilter->buffer.size);
- spin_lock_irq(&dmxdevfilter->dev->lock);
- dmxdevfilter->buffer.data=mem;
- spin_unlock_irq(&dmxdevfilter->dev->lock);
- if (!dmxdevfilter->buffer.data)
- return -ENOMEM;
+ if (filter->state >= DMXDEV_STATE_GO)
+ dvb_dmxdev_filter_stop(filter);
+
+ if (!(mem = filter->buffer.data)) {
+ mem = vmalloc(filter->buffer.size);
+ spin_lock_irq(&filter->dev->lock);
+ filter->buffer.data=mem;
+ spin_unlock_irq(&filter->dev->lock);
+ if (!filter->buffer.data)
+ return -ENOMEM;
}
- dmxdevfilter->buffer.pwrite=dmxdevfilter->buffer.pread=0;
+ filter->buffer.pwrite = filter->buffer.pread = 0;
- switch (dmxdevfilter->type) {
+ switch (filter->type) {
case DMXDEV_TYPE_SEC:
{
- struct dmx_sct_filter_params *para=&dmxdevfilter->params.sec;
- dmx_section_filter_t **secfilter=&dmxdevfilter->filter.sec;
- dmx_section_feed_t **secfeed=&dmxdevfilter->feed.sec;
+ struct dmx_sct_filter_params *para=&filter->params.sec;
+ dmx_section_filter_t **secfilter=&filter->filter.sec;
+ dmx_section_feed_t **secfeed=&filter->feed.sec;
*secfilter=0;
*secfeed=0;
/* find active filter/feed with same PID */
- for (i=0; i<dmxdev->filternum; i++)
- if (dmxdev->filter[i].state>=DMXDEV_STATE_GO &&
- dmxdev->filter[i].pid==para->pid) {
- if (dmxdev->filter[i].type!=DMXDEV_TYPE_SEC)
+ for (i=0; i<dmxdev->filternum; i++) {
+ if (dmxdev->filter[i].state >= DMXDEV_STATE_GO &&
+ dmxdev->filter[i].pid == para->pid) {
+ if (dmxdev->filter[i].type != DMXDEV_TYPE_SEC)
return -EBUSY;
- *secfeed=dmxdev->filter[i].feed.sec;
+ *secfeed = dmxdev->filter[i].feed.sec;
break;
}
+ }
/* if no feed found, try to allocate new one */
if (!*secfeed) {
ret=dmxdev->demux->allocate_section_feed(dmxdev->demux,
secfeed,
- dvb_dmxdev_section_callback);
+ dvb_dmxdev_section_callback);
if (ret<0) {
printk ("DVB (%s): could not alloc feed\n",
__FUNCTION__);
@@ -609,22 +607,23 @@ dvb_dmxdev_filter_start(dmxdev_filter_t *dmxdevfilter)
if (ret<0) {
printk ("DVB (%s): could not set feed\n",
__FUNCTION__);
- dvb_dmxdev_feed_restart(dmxdevfilter);
+ dvb_dmxdev_feed_restart(filter);
return ret;
}
+ } else {
+ dvb_dmxdev_feed_stop(filter);
}
- else
- dvb_dmxdev_feed_stop(dmxdevfilter);
ret=(*secfeed)->allocate_filter(*secfeed, secfilter);
- if (ret<0) {
- dvb_dmxdev_feed_restart(dmxdevfilter);
- dmxdevfilter->feed.sec->start_filtering(*secfeed);
+
+ if (ret < 0) {
+ dvb_dmxdev_feed_restart(filter);
+ filter->feed.sec->start_filtering(*secfeed);
dprintk ("could not get filter\n");
return ret;
}
- (*secfilter)->priv=(void *) dmxdevfilter;
+ (*secfilter)->priv = filter;
memcpy(&((*secfilter)->filter_value[3]),
&(para->filter.filter[1]), DMX_FILTER_SIZE-1);
@@ -639,23 +638,28 @@ dvb_dmxdev_filter_start(dmxdev_filter_t *dmxdevfilter)
(*secfilter)->filter_mask[1]=0;
(*secfilter)->filter_mask[2]=0;
- dmxdevfilter->todo=0;
- dmxdevfilter->feed.sec->start_filtering(dmxdevfilter->feed.sec);
- dvb_dmxdev_filter_timer(dmxdevfilter);
+ filter->todo = 0;
+
+ ret = filter->feed.sec->start_filtering (filter->feed.sec);
+
+ if (ret < 0)
+ return ret;
+
+ dvb_dmxdev_filter_timer(filter);
break;
}
case DMXDEV_TYPE_PES:
{
struct timespec timeout = { 0 };
- struct dmx_pes_filter_params *para=&dmxdevfilter->params.pes;
+ struct dmx_pes_filter_params *para = &filter->params.pes;
dmx_output_t otype;
int ret;
int ts_type;
dmx_ts_pes_t ts_pes;
- dmx_ts_feed_t **tsfeed=&dmxdevfilter->feed.ts;
+ dmx_ts_feed_t **tsfeed = &filter->feed.ts;
- dmxdevfilter->feed.ts=0;
+ filter->feed.ts = 0;
otype=para->output;
ts_pes=(dmx_ts_pes_t) para->pes_type;
@@ -665,11 +669,11 @@ dvb_dmxdev_filter_start(dmxdev_filter_t *dmxdevfilter)
else
ts_type=0;
- if (otype==DMX_OUT_TS_TAP)
- ts_type|=TS_PACKET;
+ if (otype == DMX_OUT_TS_TAP)
+ ts_type |= TS_PACKET;
- if (otype==DMX_OUT_TAP)
- ts_type|=TS_PAYLOAD_ONLY|TS_PACKET;
+ if (otype == DMX_OUT_TAP)
+ ts_type |= TS_PAYLOAD_ONLY|TS_PACKET;
ret=dmxdev->demux->allocate_ts_feed(dmxdev->demux,
tsfeed,
@@ -677,64 +681,73 @@ dvb_dmxdev_filter_start(dmxdev_filter_t *dmxdevfilter)
if (ret<0)
return ret;
- (*tsfeed)->priv=(void *) dmxdevfilter;
- ret=(*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes, 188, 32768, 0, timeout);
- if (ret<0) {
+ (*tsfeed)->priv = (void *) filter;
+
+ ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes,
+ 188, 32768, 0, timeout);
+
+ if (ret < 0) {
dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed);
return ret;
}
- dmxdevfilter->feed.ts->start_filtering(dmxdevfilter->feed.ts);
+
+ ret = filter->feed.ts->start_filtering(filter->feed.ts);
+
+ if (ret < 0)
+ return ret;
+
break;
}
default:
- return -EINVAL;
+ return -EINVAL;
}
- dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_GO);
- return 0;
+
+ dvb_dmxdev_filter_state_set(filter, DMXDEV_STATE_GO);
+ return 0;
}
static int dvb_demux_open(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
- int i;
- dmxdev_filter_t *dmxdevfilter;
+ int i;
+ dmxdev_filter_t *dmxdevfilter;
if (!dmxdev->filter)
- return -EINVAL;
+ return -EINVAL;
if (down_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
for (i=0; i<dmxdev->filternum; i++)
- if (dmxdev->filter[i].state==DMXDEV_STATE_FREE)
- break;
+ if (dmxdev->filter[i].state==DMXDEV_STATE_FREE)
+ break;
if (i==dmxdev->filternum) {
- up(&dmxdev->mutex);
- return -EMFILE;
+ up(&dmxdev->mutex);
+ return -EMFILE;
}
dmxdevfilter=&dmxdev->filter[i];
sema_init(&dmxdevfilter->mutex, 1);
- dmxdevfilter->dvbdev=dmxdev->dvbdev;
+ dmxdevfilter->dvbdev=dmxdev->dvbdev;
file->private_data=dmxdevfilter;
dvb_dmxdev_buffer_init(&dmxdevfilter->buffer);
- dmxdevfilter->type=DMXDEV_TYPE_NONE;
+ dmxdevfilter->type=DMXDEV_TYPE_NONE;
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
dmxdevfilter->feed.ts=0;
init_timer(&dmxdevfilter->timer);
- up(&dmxdev->mutex);
- return 0;
+ up(&dmxdev->mutex);
+ return 0;
}
static
int dvb_dmxdev_filter_free(dmxdev_t *dmxdev, dmxdev_filter_t *dmxdevfilter)
{
- if (down_interruptible(&dmxdev->mutex))
+ if (down_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
if (down_interruptible(&dmxdevfilter->mutex)) {
@@ -742,15 +755,15 @@ int dvb_dmxdev_filter_free(dmxdev_t *dmxdev, dmxdev_filter_t *dmxdevfilter)
return -ERESTARTSYS;
}
- dvb_dmxdev_filter_stop(dmxdevfilter);
+ dvb_dmxdev_filter_stop(dmxdevfilter);
dvb_dmxdev_filter_reset(dmxdevfilter);
-
- if (dmxdevfilter->buffer.data) {
- void *mem=dmxdevfilter->buffer.data;
+
+ if (dmxdevfilter->buffer.data) {
+ void *mem=dmxdevfilter->buffer.data;
- spin_lock_irq(&dmxdev->lock);
+ spin_lock_irq(&dmxdev->lock);
dmxdevfilter->buffer.data=0;
- spin_unlock_irq(&dmxdev->lock);
+ spin_unlock_irq(&dmxdev->lock);
vfree(mem);
}
@@ -758,7 +771,7 @@ int dvb_dmxdev_filter_free(dmxdev_t *dmxdev, dmxdev_filter_t *dmxdevfilter)
wake_up(&dmxdevfilter->buffer.queue);
up(&dmxdevfilter->mutex);
up(&dmxdev->mutex);
- return 0;
+ return 0;
}
static inline void
@@ -773,83 +786,83 @@ invert_mode(dmx_filter_t *filter)
static int
dvb_dmxdev_filter_set(dmxdev_t *dmxdev,
- dmxdev_filter_t *dmxdevfilter,
+ dmxdev_filter_t *dmxdevfilter,
struct dmx_sct_filter_params *params)
{
- dprintk ("function : %s\n", __FUNCTION__);
+ dprintk ("function : %s\n", __FUNCTION__);
dvb_dmxdev_filter_stop(dmxdevfilter);
-
- dmxdevfilter->type=DMXDEV_TYPE_SEC;
- dmxdevfilter->pid=params->pid;
+
+ dmxdevfilter->type=DMXDEV_TYPE_SEC;
+ dmxdevfilter->pid=params->pid;
memcpy(&dmxdevfilter->params.sec,
params, sizeof(struct dmx_sct_filter_params));
invert_mode(&dmxdevfilter->params.sec.filter);
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
- if (params->flags&DMX_IMMEDIATE_START)
- return dvb_dmxdev_filter_start(dmxdevfilter);
+ if (params->flags&DMX_IMMEDIATE_START)
+ return dvb_dmxdev_filter_start(dmxdevfilter);
- return 0;
+ return 0;
}
static int
dvb_dmxdev_pes_filter_set(dmxdev_t *dmxdev,
- dmxdev_filter_t *dmxdevfilter,
- struct dmx_pes_filter_params *params)
+ dmxdev_filter_t *dmxdevfilter,
+ struct dmx_pes_filter_params *params)
{
dvb_dmxdev_filter_stop(dmxdevfilter);
if (params->pes_type>DMX_PES_OTHER || params->pes_type<0)
- return -EINVAL;
+ return -EINVAL;
- dmxdevfilter->type=DMXDEV_TYPE_PES;
- dmxdevfilter->pid=params->pid;
+ dmxdevfilter->type=DMXDEV_TYPE_PES;
+ dmxdevfilter->pid=params->pid;
memcpy(&dmxdevfilter->params, params, sizeof(struct dmx_pes_filter_params));
dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
- if (params->flags&DMX_IMMEDIATE_START)
- return dvb_dmxdev_filter_start(dmxdevfilter);
+ if (params->flags&DMX_IMMEDIATE_START)
+ return dvb_dmxdev_filter_start(dmxdevfilter);
- return 0;
+ return 0;
}
static ssize_t
dvb_dmxdev_read_sec(dmxdev_filter_t *dfil, struct file *file,
char *buf, size_t count, loff_t *ppos)
{
- int result, hcount;
+ int result, hcount;
int done=0;
if (dfil->todo<=0) {
- hcount=3+dfil->todo;
- if (hcount>count)
- hcount=count;
+ hcount=3+dfil->todo;
+ if (hcount>count)
+ hcount=count;
result=dvb_dmxdev_buffer_read(&dfil->buffer, file->f_flags&O_NONBLOCK,
buf, hcount, ppos);
if (result<0) {
dfil->todo=0;
- return result;
+ return result;
}
if (copy_from_user(dfil->secheader-dfil->todo, buf, result))
- return -EFAULT;
+ return -EFAULT;
buf+=result;
done=result;
count-=result;
dfil->todo-=result;
if (dfil->todo>-3)
- return done;
+ return done;
dfil->todo=((dfil->secheader[1]<<8)|dfil->secheader[2])&0xfff;
if (!count)
- return done;
+ return done;
}
if (count>dfil->todo)
- count=dfil->todo;
- result=dvb_dmxdev_buffer_read(&dfil->buffer, file->f_flags&O_NONBLOCK,
+ count=dfil->todo;
+ result=dvb_dmxdev_buffer_read(&dfil->buffer, file->f_flags&O_NONBLOCK,
buf, count, ppos);
if (result<0)
- return result;
+ return result;
dfil->todo-=result;
return (result+done);
}
@@ -858,16 +871,16 @@ dvb_dmxdev_read_sec(dmxdev_filter_t *dfil, struct file *file,
ssize_t
dvb_demux_read(struct file *file, char *buf, size_t count, loff_t *ppos)
{
- dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
+ dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
int ret=0;
if (down_interruptible(&dmxdevfilter->mutex))
return -ERESTARTSYS;
if (dmxdevfilter->type==DMXDEV_TYPE_SEC)
- ret=dvb_dmxdev_read_sec(dmxdevfilter, file, buf, count, ppos);
+ ret=dvb_dmxdev_read_sec(dmxdevfilter, file, buf, count, ppos);
else
- ret=dvb_dmxdev_buffer_read(&dmxdevfilter->buffer,
+ ret=dvb_dmxdev_buffer_read(&dmxdevfilter->buffer,
file->f_flags&O_NONBLOCK,
buf, count, ppos);
@@ -879,12 +892,12 @@ dvb_demux_read(struct file *file, char *buf, size_t count, loff_t *ppos)
static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *parg)
{
- dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
+ dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
dmxdev_t *dmxdev=dmxdevfilter->dev;
- unsigned long arg=(unsigned long) parg;
+ unsigned long arg=(unsigned long) parg;
int ret=0;
- if (down_interruptible (&dmxdev->mutex))
+ if (down_interruptible (&dmxdev->mutex))
return -ERESTARTSYS;
switch (cmd) {
@@ -893,10 +906,10 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
up(&dmxdev->mutex);
return -ERESTARTSYS;
}
- if (dmxdevfilter->state<DMXDEV_STATE_SET)
- ret=-EINVAL;
+ if (dmxdevfilter->state<DMXDEV_STATE_SET)
+ ret = -EINVAL;
else
- ret=dvb_dmxdev_filter_start(dmxdevfilter);
+ ret = dvb_dmxdev_filter_start(dmxdevfilter);
up(&dmxdevfilter->mutex);
break;
@@ -914,7 +927,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
up(&dmxdev->mutex);
return -ERESTARTSYS;
}
- ret=dvb_dmxdev_filter_set(dmxdev, dmxdevfilter,
+ ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter,
(struct dmx_sct_filter_params *)parg);
up(&dmxdevfilter->mutex);
break;
@@ -934,25 +947,25 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
up(&dmxdev->mutex);
return -ERESTARTSYS;
}
- ret=dvb_dmxdev_set_buffer_size(dmxdevfilter, arg);
+ ret=dvb_dmxdev_set_buffer_size(dmxdevfilter, arg);
up(&dmxdevfilter->mutex);
break;
-
- case DMX_GET_EVENT:
- break;
+
+ case DMX_GET_EVENT:
+ break;
- case DMX_GET_PES_PIDS:
+ case DMX_GET_PES_PIDS:
if (!dmxdev->demux->get_pes_pids) {
- ret=-EINVAL;
+ ret=-EINVAL;
break;
}
dmxdev->demux->get_pes_pids(dmxdev->demux, (uint16_t *)parg);
- break;
+ break;
default:
- ret=-EINVAL;
+ ret=-EINVAL;
}
- up(&dmxdev->mutex);
+ up(&dmxdev->mutex);
return ret;
}
@@ -965,40 +978,40 @@ static int dvb_demux_ioctl(struct inode *inode, struct file *file,
static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
{
- dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
+ dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
if (!dmxdevfilter)
- return -EINVAL;
+ return -EINVAL;
if (dmxdevfilter->state==DMXDEV_STATE_FREE)
- return 0;
+ return 0;
if (dmxdevfilter->buffer.error)
- return (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
+ return (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
if (dmxdevfilter->buffer.pread!=dmxdevfilter->buffer.pwrite)
- return (POLLIN | POLLRDNORM | POLLPRI);
+ return (POLLIN | POLLRDNORM | POLLPRI);
if (dmxdevfilter->state!=DMXDEV_STATE_GO)
- return 0;
+ return 0;
poll_wait(file, &dmxdevfilter->buffer.queue, wait);
-
+
if (dmxdevfilter->state==DMXDEV_STATE_FREE)
- return 0;
+ return 0;
if (dmxdevfilter->buffer.error)
- return (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
+ return (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
if (dmxdevfilter->buffer.pread!=dmxdevfilter->buffer.pwrite)
- return (POLLIN | POLLRDNORM | POLLPRI);
+ return (POLLIN | POLLRDNORM | POLLPRI);
return 0;
}
static int dvb_demux_release(struct inode *inode, struct file *file)
{
- dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
+ dmxdev_filter_t *dmxdevfilter=dvb_dmxdev_file_to_filter(file);
dmxdev_t *dmxdev=dmxdevfilter->dev;
return dvb_dmxdev_filter_free(dmxdev, dmxdevfilter);
@@ -1028,19 +1041,19 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
int ret=0;
- if (down_interruptible (&dmxdev->mutex))
+ if (down_interruptible (&dmxdev->mutex))
return -ERESTARTSYS;
switch (cmd) {
case DMX_SET_BUFFER_SIZE:
// FIXME: implement
- ret=0;
+ ret=0;
break;
default:
- ret=-EINVAL;
+ ret=-EINVAL;
}
- up(&dmxdev->mutex);
+ up(&dmxdev->mutex);
return ret;
}
@@ -1056,9 +1069,9 @@ static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
dmxdev_t *dmxdev=(dmxdev_t *) dvbdev->priv;
- dprintk ("function : %s\n", __FUNCTION__);
+ dprintk ("function : %s\n", __FUNCTION__);
- if ((file->f_flags&O_ACCMODE)==O_RDONLY) {
+ if ((file->f_flags&O_ACCMODE)==O_RDONLY) {
if (dmxdev->dvr_buffer.error)
return (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
@@ -1075,7 +1088,7 @@ static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
return 0;
} else
- return (POLLOUT | POLLWRNORM | POLLPRI);
+ return (POLLOUT | POLLWRNORM | POLLPRI);
}
static struct file_operations dvb_dvr_fops = {
@@ -1098,31 +1111,31 @@ static struct dvb_device dvbdev_dvr = {
int
dvb_dmxdev_init(dmxdev_t *dmxdev, struct dvb_adapter *dvb_adapter)
{
- int i;
+ int i;
if (dmxdev->demux->open(dmxdev->demux)<0)
return -EUSERS;
dmxdev->filter=vmalloc(dmxdev->filternum*sizeof(dmxdev_filter_t));
if (!dmxdev->filter)
- return -ENOMEM;
+ return -ENOMEM;
dmxdev->dvr=vmalloc(dmxdev->filternum*sizeof(dmxdev_dvr_t));
if (!dmxdev->dvr) {
vfree(dmxdev->filter);
dmxdev->filter=0;
- return -ENOMEM;
+ return -ENOMEM;
}
- sema_init(&dmxdev->mutex, 1);
+ sema_init(&dmxdev->mutex, 1);
spin_lock_init(&dmxdev->lock);
for (i=0; i<dmxdev->filternum; i++) {
- dmxdev->filter[i].dev=dmxdev;
- dmxdev->filter[i].buffer.data=0;
- dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE);
- dmxdev->dvr[i].dev=dmxdev;
- dmxdev->dvr[i].buffer.data=0;
- dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE);
- dvb_dmxdev_dvr_state_set(&dmxdev->dvr[i], DMXDEV_STATE_FREE);
+ dmxdev->filter[i].dev=dmxdev;
+ dmxdev->filter[i].buffer.data=0;
+ dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE);
+ dmxdev->dvr[i].dev=dmxdev;
+ dmxdev->dvr[i].buffer.data=0;
+ dvb_dmxdev_filter_state_set(&dmxdev->filter[i], DMXDEV_STATE_FREE);
+ dvb_dmxdev_dvr_state_set(&dmxdev->dvr[i], DMXDEV_STATE_FREE);
}
dvb_register_device(dvb_adapter, &dmxdev->dvbdev, &dvbdev_demux, dmxdev, DVB_DEVICE_DEMUX);
dvb_register_device(dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr, dmxdev, DVB_DEVICE_DVR);
@@ -1138,14 +1151,14 @@ dvb_dmxdev_release(dmxdev_t *dmxdev)
dvb_unregister_device(dmxdev->dvbdev);
dvb_unregister_device(dmxdev->dvr_dvbdev);
if (dmxdev->filter) {
- vfree(dmxdev->filter);
+ vfree(dmxdev->filter);
dmxdev->filter=0;
}
if (dmxdev->dvr) {
- vfree(dmxdev->dvr);
+ vfree(dmxdev->dvr);
dmxdev->dvr=0;
}
- dmxdev->demux->close(dmxdev->demux);
+ dmxdev->demux->close(dmxdev->demux);
MOD_DEC_USE_COUNT;
}
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_demux.c b/linux/drivers/media/dvb/dvb-core/dvb_demux.c
index 73f8be699..3f5a46226 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -2,8 +2,8 @@
* dvb_demux.c - DVB kernel demux API
*
* Copyright (C) 2000-2001 Ralph Metzler <ralph@convergence.de>
- * & Marcus Metzler <marcus@convergence.de>
- * for convergence integrated media GmbH
+ * & Marcus Metzler <marcus@convergence.de>
+ * for convergence integrated media GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -35,20 +35,23 @@
LIST_HEAD(dmx_muxs);
+
int dmx_register_demux(dmx_demux_t *demux)
{
- struct list_head *pos, *head=&dmx_muxs;
+ struct list_head *pos;
if (!(demux->id && demux->vendor && demux->model))
- return -EINVAL;
- list_for_each(pos, head)
- {
- if (!strcmp(DMX_DIR_ENTRY(pos)->id, demux->id))
- return -EEXIST;
+ return -EINVAL;
+
+ list_for_each(pos, &dmx_muxs) {
+ if (!strcmp(DMX_DIR_ENTRY(pos)->id, demux->id))
+ return -EEXIST;
}
- demux->users=0;
- list_add(&(demux->reg_list), head);
+
+ demux->users = 0;
+ list_add(&demux->reg_list, &dmx_muxs);
MOD_INC_USE_COUNT;
+
return 0;
}
@@ -56,25 +59,24 @@ int dmx_unregister_demux(dmx_demux_t* demux)
{
struct list_head *pos, *n, *head=&dmx_muxs;
- list_for_each_safe (pos, n, head)
- {
- if (DMX_DIR_ENTRY(pos)==demux)
- {
- if (demux->users>0)
- return -EINVAL;
- list_del(pos);
- MOD_DEC_USE_COUNT;
+ list_for_each_safe (pos, n, head) {
+ if (DMX_DIR_ENTRY(pos) == demux) {
+ if (demux->users>0)
+ return -EINVAL;
+ list_del(pos);
+ MOD_DEC_USE_COUNT;
return 0;
}
}
+
return -ENODEV;
}
struct list_head *dmx_get_demuxes(void)
{
- if (list_empty(&dmx_muxs))
- return NULL;
+ if (list_empty(&dmx_muxs))
+ return NULL;
return &dmx_muxs;
}
@@ -83,58 +85,60 @@ struct list_head *dmx_get_demuxes(void)
* static inlined helper functions
******************************************************************************/
-static inline u16
-section_length(const u8 *buf)
+
+static inline
+u16 section_length(const u8 *buf)
{
- return 3+((buf[1]&0x0f)<<8)+buf[2];
+ return 3+((buf[1]&0x0f)<<8)+buf[2];
}
-static inline u16
-ts_pid(const u8 *buf)
+
+static inline
+u16 ts_pid(const u8 *buf)
{
- return ((buf[1]&0x1f)<<8)+buf[2];
+ return ((buf[1]&0x1f)<<8)+buf[2];
}
-static inline int
-payload(const u8 *tsp)
+
+static inline
+int payload(const u8 *tsp)
{
- if (!(tsp[3]&0x10)) // no payload?
- return 0;
- if (tsp[3]&0x20) { // adaptation field?
+ if (!(tsp[3]&0x10)) // no payload?
+ return 0;
+ if (tsp[3]&0x20) { // adaptation field?
if (tsp[4]>183) // corrupted data?
return 0;
else
return 184-1-tsp[4];
}
- return 184;
+ return 184;
}
+
void dvb_set_crc32(u8 *data, int length)
{
- u32 crc;
+ u32 crc;
- crc = crc32_le(~0, data, length);
+ crc = crc32_le(~0, data, length);
data[length] = (crc >> 24) & 0xff;
- data[length+1] = (crc >> 16) & 0xff;
- data[length+2] = (crc >> 8) & 0xff;
- data[length+3] = (crc) & 0xff;
+ data[length+1] = (crc >> 16) & 0xff;
+ data[length+2] = (crc >> 8) & 0xff;
+ data[length+3] = (crc) & 0xff;
}
static
-u32 dvb_dmx_crc32 (struct dvb_demux_feed *dvbdmxfeed,
- const u8 *src, size_t len)
+u32 dvb_dmx_crc32 (struct dvb_demux_feed *f, const u8 *src, size_t len)
{
- return (dvbdmxfeed->feed.sec.crc_val = crc32_le (dvbdmxfeed->feed.sec.crc_val, src, len));
+ return (f->feed.sec.crc_val = crc32_le (f->feed.sec.crc_val, src, len));
}
static
-void dvb_dmx_memcopy (struct dvb_demux_feed *dvbdmxfeed, u8 *dst,
- const u8 *src, size_t len)
+void dvb_dmx_memcopy (struct dvb_demux_feed *f, u8 *d, const u8 *s, size_t len)
{
- memcpy (dst, src, len);
+ memcpy (d, s, len);
}
@@ -142,82 +146,86 @@ void dvb_dmx_memcopy (struct dvb_demux_feed *dvbdmxfeed, u8 *dst,
* Software filter functions
******************************************************************************/
-static inline int
-dvb_dmx_swfilter_payload(struct dvb_demux_feed *dvbdmxfeed, const u8 *buf)
+static inline
+int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u8 *buf)
{
- int p, count;
+ int count = payload(buf);
+ int p;
//int ccok;
//u8 cc;
- if (!(count=payload(buf)))
- return -1;
- p=188-count;
- /*
+ if (count == 0)
+ return -1;
+
+ p = 188-count;
+
+ /*
cc=buf[3]&0x0f;
- ccok=((dvbdmxfeed->cc+1)&0x0f)==cc ? 1 : 0;
- dvbdmxfeed->cc=cc;
- if (!ccok)
- printk("missed packet!\n");
- */
- if (buf[1]&0x40) // PUSI ?
- dvbdmxfeed->peslen=0xfffa;
- dvbdmxfeed->peslen+=count;
-
- return dvbdmxfeed->cb.ts((u8 *)&buf[p], count, 0, 0,
- &dvbdmxfeed->feed.ts, DMX_OK);
+ ccok=((dvbdmxfeed->cc+1)&0x0f)==cc ? 1 : 0;
+ dvbdmxfeed->cc=cc;
+ if (!ccok)
+ printk("missed packet!\n");
+ */
+
+ if (buf[1] & 0x40) // PUSI ?
+ feed->peslen = 0xfffa;
+
+ feed->peslen += count;
+
+ return feed->cb.ts (&buf[p], count, 0, 0, &feed->feed.ts, DMX_OK);
}
-static int
-dvb_dmx_swfilter_sectionfilter(struct dvb_demux_feed *dvbdmxfeed,
- struct dvb_demux_filter *f)
+static
+int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed,
+ struct dvb_demux_filter *f)
{
- dmx_section_filter_t *filter=&f->filter;
- int i;
- u8 xor, neq=0;
+ u8 neq = 0;
+ int i;
+
+ for (i=0; i<DVB_DEMUX_MASK_MAX; i++) {
+ u8 xor = f->filter.filter_value[i] ^ feed->feed.sec.secbuf[i];
- for (i=0; i<DVB_DEMUX_MASK_MAX; i++) {
- xor=filter->filter_value[i]^dvbdmxfeed->feed.sec.secbuf[i];
- if (f->maskandmode[i]&xor)
+ if (f->maskandmode[i] & xor)
return 0;
- neq|=f->maskandnotmode[i]&xor;
+
+ neq |= f->maskandnotmode[i] & xor;
}
if (f->doneq & !neq)
return 0;
- return dvbdmxfeed->cb.sec(dvbdmxfeed->feed.sec.secbuf,
- dvbdmxfeed->feed.sec.seclen,
- 0, 0, filter, DMX_OK);
+ return feed->cb.sec (feed->feed.sec.secbuf, feed->feed.sec.seclen,
+ 0, 0, &f->filter, DMX_OK);
}
-static inline int
-dvb_dmx_swfilter_section_feed(struct dvb_demux_feed *dvbdmxfeed)
+
+static inline
+int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed)
{
- struct dvb_demux *demux = dvbdmxfeed->demux;
- dmx_section_feed_t *sec = &dvbdmxfeed->feed.sec;
- u8 *buf = sec->secbuf;
- struct dvb_demux_filter *f;
+ struct dvb_demux *demux = feed->demux;
+ struct dvb_demux_filter *f = feed->filter;
+ dmx_section_feed_t *sec = &feed->feed.sec;
+ u8 *buf = sec->secbuf;
- if (sec->secbufp != sec->seclen)
- return -1;
+ if (sec->secbufp != sec->seclen)
+ return -1;
if (!sec->is_filtering)
- return 0;
+ return 0;
- if (!(f = dvbdmxfeed->filter))
- return 0;
+ if (!f)
+ return 0;
- if (sec->check_crc &&
- demux->check_crc32(dvbdmxfeed, sec->secbuf, sec->seclen))
+ if (sec->check_crc && demux->check_crc32(feed, sec->secbuf, sec->seclen))
return -1;
do {
- if (dvb_dmx_swfilter_sectionfilter(dvbdmxfeed, f)<0)
- return -1;
+ if (dvb_dmx_swfilter_sectionfilter(feed, f) < 0)
+ return -1;
} while ((f = f->next) && sec->is_filtering);
- sec->secbufp = sec->seclen = 0;
+ sec->secbufp = sec->seclen = 0;
memset(buf, 0, DVB_DEMUX_MASK_MAX);
@@ -230,60 +238,60 @@ int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf)
{
struct dvb_demux *demux = feed->demux;
dmx_section_feed_t *sec = &feed->feed.sec;
- int p, count;
- int ccok, rest;
+ int p, count;
+ int ccok, rest;
u8 cc;
- if (!(count = payload(buf)))
- return -1;
+ if (!(count = payload(buf)))
+ return -1;
p = 188-count;
- cc = buf[3]&0x0f;
- ccok = ((feed->cc+1)&0x0f)==cc ? 1 : 0;
- feed->cc = cc;
+ cc = buf[3] & 0x0f;
+ ccok = ((feed->cc+1) & 0x0f) == cc ? 1 : 0;
+ feed->cc = cc;
- if (buf[1] & 0x40) { // PUSI set
- // offset to start of first section is in buf[p]
+ if (buf[1] & 0x40) { // PUSI set
+ // offset to start of first section is in buf[p]
if (p+buf[p]>187) // trash if it points beyond packet
return -1;
if (buf[p] && ccok) { // rest of previous section?
- // did we have enough data in last packet to calc length?
+ // did we have enough data in last packet to calc length?
int tmp = 3 - sec->secbufp;
if (tmp > 0 && tmp != 3) {
if (p + tmp >= 187)
return -1;
- demux->memcopy (feed, sec->secbuf+sec->secbufp,
+ demux->memcopy (feed, sec->secbuf+sec->secbufp,
buf+p+1, tmp);
sec->seclen = section_length(sec->secbuf);
if (sec->seclen > 4096)
return -1;
- }
+ }
- rest = sec->seclen - sec->secbufp;
+ rest = sec->seclen - sec->secbufp;
- if (rest == buf[p] && sec->seclen) {
+ if (rest == buf[p] && sec->seclen) {
demux->memcopy (feed, sec->secbuf + sec->secbufp,
- buf+p+1, buf[p]);
- sec->secbufp += buf[p];
- dvb_dmx_swfilter_section_feed(feed);
- }
- }
+ buf+p+1, buf[p]);
+ sec->secbufp += buf[p];
+ dvb_dmx_swfilter_section_feed(feed);
+ }
+ }
- p += buf[p] + 1; // skip rest of last section
- count = 188 - p;
+ p += buf[p] + 1; // skip rest of last section
+ count = 188 - p;
while (count) {
sec->crc_val = ~0;
- if ((count>2) && // enough data to determine sec length?
- ((sec->seclen = section_length(buf+p)) <= count)) {
+ if ((count>2) && // enough data to determine sec length?
+ ((sec->seclen = section_length(buf+p)) <= count)) {
if (sec->seclen>4096)
return -1;
@@ -291,21 +299,21 @@ int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf)
sec->seclen);
sec->secbufp = sec->seclen;
- p += sec->seclen;
- count = 188 - p;
+ p += sec->seclen;
+ count = 188 - p;
dvb_dmx_swfilter_section_feed(feed);
- // filling bytes until packet end?
- if (count && buf[p]==0xff)
- count=0;
+ // filling bytes until packet end?
+ if (count && buf[p]==0xff)
+ count=0;
} else { // section continues to following TS packet
- demux->memcopy(feed, sec->secbuf, buf+p, count);
- sec->secbufp+=count;
- count=0;
- }
- }
+ demux->memcopy(feed, sec->secbuf, buf+p, count);
+ sec->secbufp+=count;
+ count=0;
+ }
+ }
return 0;
}
@@ -318,7 +326,7 @@ int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf)
return -1;
// did we have enough data in last packet to calc section length?
- if (sec->secbufp<3) {
+ if (sec->secbufp < 3) {
int tmp = 3 - sec->secbufp;
if (tmp>count)
@@ -348,374 +356,386 @@ int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf)
sec->secbufp += count;
}
- return 0;
+ return 0;
}
-static inline void
-dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *dvbdmxfeed, const u8 *buf)
+static inline
+void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, const u8 *buf)
{
- switch(dvbdmxfeed->type) {
- case DMX_TYPE_TS:
- if (!dvbdmxfeed->feed.ts.is_filtering)
- break;
- if (dvbdmxfeed->ts_type & TS_PACKET) {
- if (dvbdmxfeed->ts_type & TS_PAYLOAD_ONLY)
- dvb_dmx_swfilter_payload(dvbdmxfeed, buf);
- else
- dvbdmxfeed->cb.ts((u8 *)buf, 188, 0, 0,
- &dvbdmxfeed->feed.ts, DMX_OK);
- }
- if (dvbdmxfeed->ts_type & TS_DECODER)
- if (dvbdmxfeed->demux->write_to_decoder)
- dvbdmxfeed->demux->
- write_to_decoder(dvbdmxfeed, (u8 *)buf, 188);
- break;
-
- case DMX_TYPE_SEC:
- if (!dvbdmxfeed->feed.sec.is_filtering)
- break;
- if (dvb_dmx_swfilter_section_packet(dvbdmxfeed, buf)<0)
- dvbdmxfeed->feed.sec.seclen=dvbdmxfeed->feed.sec.secbufp=0;
- break;
-
- default:
- break;
- }
+ switch(feed->type) {
+ case DMX_TYPE_TS:
+ if (!feed->feed.ts.is_filtering)
+ break;
+ if (feed->ts_type & TS_PACKET) {
+ if (feed->ts_type & TS_PAYLOAD_ONLY)
+ dvb_dmx_swfilter_payload(feed, buf);
+ else
+ feed->cb.ts(buf, 188, 0, 0, &feed->feed.ts, DMX_OK);
+ }
+ if (feed->ts_type & TS_DECODER)
+ if (feed->demux->write_to_decoder)
+ feed->demux->write_to_decoder(feed, buf, 188);
+ break;
+
+ case DMX_TYPE_SEC:
+ if (!feed->feed.sec.is_filtering)
+ break;
+ if (dvb_dmx_swfilter_section_packet(feed, buf) < 0)
+ feed->feed.sec.seclen = feed->feed.sec.secbufp=0;
+ break;
+
+ default:
+ break;
+ }
}
-void
-dvb_dmx_swfilter_packet(struct dvb_demux *dvbdmx, const u8 *buf)
+
+void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
{
- struct dvb_demux_feed *dvbdmxfeed;
+ struct dvb_demux_feed *feed = demux->pid2feed[ts_pid(buf)];
- if (!(dvbdmxfeed=dvbdmx->pid2feed[ts_pid(buf)]))
- return;
+ if (!feed)
+ return;
- dvb_dmx_swfilter_packet_type(dvbdmxfeed, buf);
+ dvb_dmx_swfilter_packet_type (feed, buf);
}
-void
-dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, int count)
+
+void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, int count)
{
- struct dvb_demux_feed *dvbdmxfeed;
-
- spin_lock(&dvbdmx->lock);
- if ((dvbdmxfeed=dvbdmx->pid2feed[0x2000]))
- dvbdmxfeed->cb.ts((u8 *)buf, count*188, 0, 0,
- &dvbdmxfeed->feed.ts, DMX_OK);
- while (count) {
- dvb_dmx_swfilter_packet(dvbdmx, buf);
+ struct dvb_demux_feed *feed;
+
+ spin_lock(&demux->lock);
+
+ if ((feed = demux->pid2feed[0x2000]))
+ feed->cb.ts(buf, count*188, 0, 0, &feed->feed.ts, DMX_OK);
+
+ while (count) {
+ dvb_dmx_swfilter_packet(demux, buf);
count--;
- buf+=188;
+ buf += 188;
}
- spin_unlock(&dvbdmx->lock);
+
+ spin_unlock(&demux->lock);
}
-static inline void
-dvb_dmx_swfilter(struct dvb_demux *dvbdmx, const u8 *buf, size_t count)
+
+static inline
+void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
{
- int p=0,i, j;
-
- if ((i=dvbdmx->tsbufp)) {
- if (count<(j=188-i)) {
- memcpy(&dvbdmx->tsbuf[i], buf, count);
- dvbdmx->tsbufp+=count;
- return;
- }
- memcpy(&dvbdmx->tsbuf[i], buf, j);
- dvb_dmx_swfilter_packet(dvbdmx, dvbdmx->tsbuf);
- dvbdmx->tsbufp=0;
- p+=j;
- }
-
- while (p<count) {
- if (buf[p]==0x47) {
- if (count-p>=188) {
- dvb_dmx_swfilter_packet(dvbdmx, buf+p);
- p+=188;
- } else {
- i=count-p;
- memcpy(dvbdmx->tsbuf, buf+p, i);
- dvbdmx->tsbufp=i;
+ int p = 0,i, j;
+
+ if ((i = demux->tsbufp)) {
+ if (count < (j=188-i)) {
+ memcpy(&demux->tsbuf[i], buf, count);
+ demux->tsbufp += count;
+ return;
+ }
+ memcpy(&demux->tsbuf[i], buf, j);
+ dvb_dmx_swfilter_packet(demux, demux->tsbuf);
+ demux->tsbufp = 0;
+ p += j;
+ }
+
+ while (p < count) {
+ if (buf[p] == 0x47) {
+ if (count-p >= 188) {
+ dvb_dmx_swfilter_packet(demux, buf+p);
+ p += 188;
+ } else {
+ i = count-p;
+ memcpy(demux->tsbuf, buf+p, i);
+ demux->tsbufp=i;
return;
- }
- } else
- p++;
- }
+ }
+ } else
+ p++;
+ }
}
-/******************************************************************************
- ******************************************************************************
- * DVB DEMUX API LEVEL FUNCTIONS
- ******************************************************************************
- ******************************************************************************/
-
-static struct dvb_demux_filter *
-dvb_dmx_filter_alloc(struct dvb_demux *dvbdmx)
+static
+struct dvb_demux_filter* dvb_dmx_filter_alloc(struct dvb_demux *demux)
{
- int i;
-
- for (i=0; i<dvbdmx->filternum; i++)
- if (dvbdmx->filter[i].state==DMX_STATE_FREE)
- break;
- if (i==dvbdmx->filternum)
- return 0;
- dvbdmx->filter[i].state=DMX_STATE_ALLOCATED;
- return &dvbdmx->filter[i];
+ int i;
+
+ for (i=0; i<demux->filternum; i++)
+ if (demux->filter[i].state == DMX_STATE_FREE)
+ break;
+
+ if (i == demux->filternum)
+ return NULL;
+
+ demux->filter[i].state = DMX_STATE_ALLOCATED;
+
+ return &demux->filter[i];
}
-static struct dvb_demux_feed *
-dvb_dmx_feed_alloc(struct dvb_demux *dvbdmx)
+static
+struct dvb_demux_feed* dvb_dmx_feed_alloc(struct dvb_demux *demux)
{
- int i;
-
- for (i=0; i<dvbdmx->feednum; i++)
- if (dvbdmx->feed[i].state==DMX_STATE_FREE)
- break;
- if (i==dvbdmx->feednum)
- return 0;
- dvbdmx->feed[i].state=DMX_STATE_ALLOCATED;
- return &dvbdmx->feed[i];
-}
+ int i;
+ for (i=0; i<demux->feednum; i++)
+ if (demux->feed[i].state == DMX_STATE_FREE)
+ break;
-/******************************************************************************
- * dmx_ts_feed API calls
- ******************************************************************************/
+ if (i == demux->feednum)
+ return NULL;
-static int
-dmx_pid_set(u16 pid, struct dvb_demux_feed *dvbdmxfeed)
+ demux->feed[i].state = DMX_STATE_ALLOCATED;
+
+ return &demux->feed[i];
+}
+
+
+static
+int dmx_pid_set (u16 pid, struct dvb_demux_feed *feed)
{
- struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
- struct dvb_demux_feed **pid2feed=dvbdmx->pid2feed;
-
- if (pid>DMX_MAX_PID)
- return -EINVAL;
- if (dvbdmxfeed->pid!=0xffff) {
- if (dvbdmxfeed->pid<=DMX_MAX_PID)
- pid2feed[dvbdmxfeed->pid]=0;
- dvbdmxfeed->pid=0xffff;
- }
- if (pid2feed[pid]) {
- return -EBUSY;
+ struct dvb_demux *demux = feed->demux;
+ struct dvb_demux_feed **pid2feed = demux->pid2feed;
+
+ if (pid > DMX_MAX_PID)
+ return -EINVAL;
+
+ if (feed->pid != 0xffff) {
+ if (feed->pid <= DMX_MAX_PID)
+ pid2feed[feed->pid] = 0;
+ feed->pid = 0xffff;
}
- pid2feed[pid]=dvbdmxfeed;
- dvbdmxfeed->pid=pid;
+
+ if (pid2feed[pid])
+ return -EBUSY;
+
+ pid2feed[pid] = feed;
+ feed->pid = pid;
+
return 0;
}
-static int
-dmx_ts_feed_set(struct dmx_ts_feed_s* feed,
- u16 pid,
- int ts_type,
- dmx_ts_pes_t pes_type,
- size_t callback_length,
- size_t circular_buffer_size,
- int descramble,
- struct timespec timeout
- )
+static
+int dmx_ts_feed_set (struct dmx_ts_feed_s* ts_feed, u16 pid, int ts_type,
+ dmx_ts_pes_t pes_type, size_t callback_length,
+ size_t circular_buffer_size, int descramble,
+ struct timespec timeout)
{
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
+ struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
+ struct dvb_demux *demux = feed->demux;
int ret;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&demux->mutex))
return -ERESTARTSYS;
if (ts_type & TS_DECODER) {
- if (pes_type >= DMX_TS_PES_OTHER) {
- up(&dvbdmx->mutex);
- return -EINVAL;
+ if (pes_type >= DMX_TS_PES_OTHER) {
+ up(&demux->mutex);
+ return -EINVAL;
}
- if (dvbdmx->pesfilter[pes_type] &&
- (dvbdmx->pesfilter[pes_type]!=dvbdmxfeed)) {
- up(&dvbdmx->mutex);
- return -EINVAL;
+
+ if (demux->pesfilter[pes_type] &&
+ demux->pesfilter[pes_type] != feed) {
+ up(&demux->mutex);
+ return -EINVAL;
}
+
if ((pes_type != DMX_TS_PES_PCR0) &&
(pes_type != DMX_TS_PES_PCR1) &&
(pes_type != DMX_TS_PES_PCR2) &&
(pes_type != DMX_TS_PES_PCR3)) {
- if ((ret=dmx_pid_set(pid, dvbdmxfeed))<0) {
- up(&dvbdmx->mutex);
+ if ((ret = dmx_pid_set(pid, feed))<0) {
+ up(&demux->mutex);
return ret;
}
} else
- dvbdmxfeed->pid=pid;
+ feed->pid = pid;
- dvbdmx->pesfilter[pes_type]=dvbdmxfeed;
- dvbdmx->pids[pes_type]=dvbdmxfeed->pid;
- } else
- if ((ret=dmx_pid_set(pid, dvbdmxfeed))<0) {
- up(&dvbdmx->mutex);
+ demux->pesfilter[pes_type] = feed;
+ demux->pids[pes_type] = feed->pid;
+ } else {
+ if ((ret = dmx_pid_set(pid, feed))<0) {
+ up(&demux->mutex);
return ret;
}
+ }
- dvbdmxfeed->buffer_size=circular_buffer_size;
- dvbdmxfeed->descramble=descramble;
- dvbdmxfeed->timeout=timeout;
- dvbdmxfeed->cb_length=callback_length;
- dvbdmxfeed->ts_type=ts_type;
- dvbdmxfeed->pes_type=pes_type;
+ feed->buffer_size = circular_buffer_size;
+ feed->descramble = descramble;
+ feed->timeout = timeout;
+ feed->cb_length = callback_length;
+ feed->ts_type = ts_type;
+ feed->pes_type = pes_type;
- if (dvbdmxfeed->descramble) {
- up(&dvbdmx->mutex);
- return -ENOSYS;
+ if (feed->descramble) {
+ up(&demux->mutex);
+ return -ENOSYS;
}
- if (dvbdmxfeed->buffer_size) {
+ if (feed->buffer_size) {
#ifdef NOBUFS
- dvbdmxfeed->buffer=0;
+ feed->buffer=0;
#else
- dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size);
- if (!dvbdmxfeed->buffer) {
- up(&dvbdmx->mutex);
+ feed->buffer = vmalloc(feed->buffer_size);
+ if (!feed->buffer) {
+ up(&demux->mutex);
return -ENOMEM;
}
#endif
- }
- dvbdmxfeed->state=DMX_STATE_READY;
- up(&dvbdmx->mutex);
- return 0;
+ }
+
+ feed->state = DMX_STATE_READY;
+ up(&demux->mutex);
+
+ return 0;
}
-static int
-dmx_ts_feed_start_filtering(struct dmx_ts_feed_s* feed)
+
+static
+int dmx_ts_feed_start_filtering(struct dmx_ts_feed_s* ts_feed)
{
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
+ struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
+ struct dvb_demux *demux = feed->demux;
int ret;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&demux->mutex))
return -ERESTARTSYS;
- if (dvbdmxfeed->state!=DMX_STATE_READY ||
- dvbdmxfeed->type!=DMX_TYPE_TS) {
- up(&dvbdmx->mutex);
- return -EINVAL;
+ if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) {
+ up(&demux->mutex);
+ return -EINVAL;
}
- if (!dvbdmx->start_feed) {
- up(&dvbdmx->mutex);
- return -1;
+
+ if (!demux->start_feed) {
+ up(&demux->mutex);
+ return -ENODEV;
}
- ret=dvbdmx->start_feed(dvbdmxfeed);
- if (ret<0) {
- up(&dvbdmx->mutex);
+
+ if ((ret = demux->start_feed(feed)) < 0) {
+ up(&demux->mutex);
return ret;
}
- spin_lock_irq(&dvbdmx->lock);
- feed->is_filtering=1;
- dvbdmxfeed->state=DMX_STATE_GO;
- spin_unlock_irq(&dvbdmx->lock);
- up(&dvbdmx->mutex);
+
+ spin_lock_irq(&demux->lock);
+ ts_feed->is_filtering = 1;
+ feed->state = DMX_STATE_GO;
+ spin_unlock_irq(&demux->lock);
+ up(&demux->mutex);
+
return 0;
}
-static int
-dmx_ts_feed_stop_filtering(struct dmx_ts_feed_s* feed)
+static
+int dmx_ts_feed_stop_filtering(struct dmx_ts_feed_s* ts_feed)
{
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
+ struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
+ struct dvb_demux *demux = feed->demux;
int ret;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&demux->mutex))
return -ERESTARTSYS;
- if (dvbdmxfeed->state<DMX_STATE_GO) {
- up(&dvbdmx->mutex);
- return -EINVAL;
+ if (feed->state<DMX_STATE_GO) {
+ up(&demux->mutex);
+ return -EINVAL;
}
- if (!dvbdmx->stop_feed) {
- up(&dvbdmx->mutex);
- return -1;
+
+ if (!demux->stop_feed) {
+ up(&demux->mutex);
+ return -ENODEV;
}
- ret=dvbdmx->stop_feed(dvbdmxfeed);
- spin_lock_irq(&dvbdmx->lock);
- feed->is_filtering=0;
- dvbdmxfeed->state=DMX_STATE_ALLOCATED;
- spin_unlock_irq(&dvbdmx->lock);
- up(&dvbdmx->mutex);
- return ret;
+ ret = demux->stop_feed(feed);
+
+ spin_lock_irq(&demux->lock);
+ ts_feed->is_filtering = 0;
+ feed->state = DMX_STATE_ALLOCATED;
+ spin_unlock_irq(&demux->lock);
+ up(&demux->mutex);
+
+ return ret;
}
-static int dvbdmx_allocate_ts_feed(dmx_demux_t *demux,
- dmx_ts_feed_t **feed,
- dmx_ts_cb callback)
+static
+int dvbdmx_allocate_ts_feed (dmx_demux_t *dmx, dmx_ts_feed_t **ts_feed,
+ dmx_ts_cb callback)
{
- struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
- struct dvb_demux_feed *dvbdmxfeed;
+ struct dvb_demux *demux = (struct dvb_demux *) dmx;
+ struct dvb_demux_feed *feed;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&demux->mutex))
return -ERESTARTSYS;
- if (!(dvbdmxfeed=dvb_dmx_feed_alloc(dvbdmx))) {
- up(&dvbdmx->mutex);
- return -EBUSY;
+ if (!(feed = dvb_dmx_feed_alloc(demux))) {
+ up(&demux->mutex);
+ return -EBUSY;
}
- dvbdmxfeed->type=DMX_TYPE_TS;
- dvbdmxfeed->cb.ts=callback;
- dvbdmxfeed->demux=dvbdmx;
- dvbdmxfeed->pid=0xffff;
- dvbdmxfeed->peslen=0xfffa;
- dvbdmxfeed->buffer=0;
-
- (*feed)=&dvbdmxfeed->feed.ts;
- (*feed)->is_filtering=0;
- (*feed)->parent=demux;
- (*feed)->priv=0;
- (*feed)->set=dmx_ts_feed_set;
- (*feed)->start_filtering=dmx_ts_feed_start_filtering;
- (*feed)->stop_filtering=dmx_ts_feed_stop_filtering;
-
-
- if (!(dvbdmxfeed->filter=dvb_dmx_filter_alloc(dvbdmx))) {
- dvbdmxfeed->state=DMX_STATE_FREE;
- up(&dvbdmx->mutex);
- return -EBUSY;
- }
-
- dvbdmxfeed->filter->type=DMX_TYPE_TS;
- dvbdmxfeed->filter->feed=dvbdmxfeed;
- dvbdmxfeed->filter->state=DMX_STATE_READY;
-
- up(&dvbdmx->mutex);
- return 0;
+
+ feed->type = DMX_TYPE_TS;
+ feed->cb.ts = callback;
+ feed->demux = demux;
+ feed->pid = 0xffff;
+ feed->peslen = 0xfffa;
+ feed->buffer = 0;
+
+ (*ts_feed) = &feed->feed.ts;
+ (*ts_feed)->is_filtering = 0;
+ (*ts_feed)->parent = dmx;
+ (*ts_feed)->priv = 0;
+ (*ts_feed)->set = dmx_ts_feed_set;
+ (*ts_feed)->start_filtering = dmx_ts_feed_start_filtering;
+ (*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering;
+
+
+ if (!(feed->filter = dvb_dmx_filter_alloc(demux))) {
+ feed->state = DMX_STATE_FREE;
+ up(&demux->mutex);
+ return -EBUSY;
+ }
+
+ feed->filter->type = DMX_TYPE_TS;
+ feed->filter->feed = feed;
+ feed->filter->state = DMX_STATE_READY;
+
+ up(&demux->mutex);
+
+ return 0;
}
-static int dvbdmx_release_ts_feed(dmx_demux_t *demux, dmx_ts_feed_t *feed)
+static
+int dvbdmx_release_ts_feed(dmx_demux_t *dmx, dmx_ts_feed_t *ts_feed)
{
- struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
+ struct dvb_demux *demux = (struct dvb_demux *) dmx;
+ struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&demux->mutex))
return -ERESTARTSYS;
- if (dvbdmxfeed->state==DMX_STATE_FREE) {
- up(&dvbdmx->mutex);
- return -EINVAL;
+ if (feed->state == DMX_STATE_FREE) {
+ up(&demux->mutex);
+ return -EINVAL;
}
+
#ifndef NOBUFS
- if (dvbdmxfeed->buffer) {
- vfree(dvbdmxfeed->buffer);
- dvbdmxfeed->buffer=0;
- }
+ if (feed->buffer) {
+ vfree(feed->buffer);
+ feed->buffer=0;
+ }
#endif
- dvbdmxfeed->state=DMX_STATE_FREE;
- dvbdmxfeed->filter->state=DMX_STATE_FREE;
- if (dvbdmxfeed->pid<=DMX_MAX_PID) {
- dvbdmxfeed->demux->pid2feed[dvbdmxfeed->pid]=0;
- dvbdmxfeed->pid=0xffff;
- }
+
+ feed->state = DMX_STATE_FREE;
+ feed->filter->state = DMX_STATE_FREE;
+
+ if (feed->pid <= DMX_MAX_PID) {
+ feed->demux->pid2feed[feed->pid]=0;
+ feed->pid=0xffff;
+ }
- if (dvbdmxfeed->ts_type & TS_DECODER)
- dvbdmx->pesfilter[dvbdmxfeed->pes_type] = NULL;
+ if (feed->ts_type & TS_DECODER)
+ demux->pesfilter[feed->pes_type] = NULL;
- up(&dvbdmx->mutex);
- return 0;
+ up(&demux->mutex);
+ return 0;
}
@@ -725,92 +745,92 @@ static int dvbdmx_release_ts_feed(dmx_demux_t *demux, dmx_ts_feed_t *feed)
static int
dmx_section_feed_allocate_filter(struct dmx_section_feed_s* feed,
- dmx_section_filter_t** filter)
+ dmx_section_filter_t** filter)
{
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdemux=dvbdmxfeed->demux;
- struct dvb_demux_filter *dvbdmxfilter;
+ struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
+ struct dvb_demux *dvbdemux=dvbdmxfeed->demux;
+ struct dvb_demux_filter *dvbdmxfilter;
if (down_interruptible (&dvbdemux->mutex))
return -ERESTARTSYS;
- dvbdmxfilter=dvb_dmx_filter_alloc(dvbdemux);
- if (!dvbdmxfilter) {
+ dvbdmxfilter=dvb_dmx_filter_alloc(dvbdemux);
+ if (!dvbdmxfilter) {
up(&dvbdemux->mutex);
- return -ENOSPC;
+ return -ENOSPC;
}
spin_lock_irq(&dvbdemux->lock);
- *filter=&dvbdmxfilter->filter;
- (*filter)->parent=feed;
- (*filter)->priv=0;
- dvbdmxfilter->feed=dvbdmxfeed;
- dvbdmxfilter->type=DMX_TYPE_SEC;
- dvbdmxfilter->state=DMX_STATE_READY;
-
- dvbdmxfilter->next=dvbdmxfeed->filter;
- dvbdmxfeed->filter=dvbdmxfilter;
+ *filter=&dvbdmxfilter->filter;
+ (*filter)->parent=feed;
+ (*filter)->priv=0;
+ dvbdmxfilter->feed=dvbdmxfeed;
+ dvbdmxfilter->type=DMX_TYPE_SEC;
+ dvbdmxfilter->state=DMX_STATE_READY;
+
+ dvbdmxfilter->next=dvbdmxfeed->filter;
+ dvbdmxfeed->filter=dvbdmxfilter;
spin_unlock_irq(&dvbdemux->lock);
- up(&dvbdemux->mutex);
- return 0;
+ up(&dvbdemux->mutex);
+ return 0;
}
static int
dmx_section_feed_set(struct dmx_section_feed_s* feed,
- u16 pid, size_t circular_buffer_size,
- int descramble, int check_crc)
+ u16 pid, size_t circular_buffer_size,
+ int descramble, int check_crc)
{
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
+ struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
+ struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
- if (pid>0x1fff)
- return -EINVAL;
+ if (pid>0x1fff)
+ return -EINVAL;
if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS;
- if (dvbdmxfeed->pid!=0xffff) {
- dvbdmx->pid2feed[dvbdmxfeed->pid]=0;
- dvbdmxfeed->pid=0xffff;
- }
- if (dvbdmx->pid2feed[pid]) {
+ if (dvbdmxfeed->pid!=0xffff) {
+ dvbdmx->pid2feed[dvbdmxfeed->pid]=0;
+ dvbdmxfeed->pid=0xffff;
+ }
+ if (dvbdmx->pid2feed[pid]) {
up(&dvbdmx->mutex);
return -EBUSY;
}
- dvbdmx->pid2feed[pid]=dvbdmxfeed;
- dvbdmxfeed->pid=pid;
+ dvbdmx->pid2feed[pid]=dvbdmxfeed;
+ dvbdmxfeed->pid=pid;
- dvbdmxfeed->buffer_size=circular_buffer_size;
- dvbdmxfeed->descramble=descramble;
- if (dvbdmxfeed->descramble) {
+ dvbdmxfeed->buffer_size=circular_buffer_size;
+ dvbdmxfeed->descramble=descramble;
+ if (dvbdmxfeed->descramble) {
up(&dvbdmx->mutex);
- return -ENOSYS;
+ return -ENOSYS;
}
- dvbdmxfeed->feed.sec.check_crc=check_crc;
+ dvbdmxfeed->feed.sec.check_crc=check_crc;
#ifdef NOBUFS
- dvbdmxfeed->buffer=0;
+ dvbdmxfeed->buffer=0;
#else
- dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size);
- if (!dvbdmxfeed->buffer) {
+ dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size);
+ if (!dvbdmxfeed->buffer) {
up(&dvbdmx->mutex);
return -ENOMEM;
}
#endif
- dvbdmxfeed->state=DMX_STATE_READY;
- up(&dvbdmx->mutex);
- return 0;
+ dvbdmxfeed->state=DMX_STATE_READY;
+ up(&dvbdmx->mutex);
+ return 0;
}
static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
{
int i;
- dmx_section_filter_t *sf;
+ dmx_section_filter_t *sf;
struct dvb_demux_filter *f;
u8 mask, mode, doneq;
if (!(f=dvbdmxfeed->filter))
- return;
- do {
+ return;
+ do {
sf=&f->filter;
doneq=0;
for (i=0; i<DVB_DEMUX_MASK_MAX; i++) {
@@ -827,159 +847,161 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
static int
dmx_section_feed_start_filtering(dmx_section_feed_t *feed)
{
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
+ struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
+ struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
int ret;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS;
- if (feed->is_filtering) {
+ if (feed->is_filtering) {
up(&dvbdmx->mutex);
return -EBUSY;
}
- if (!dvbdmxfeed->filter) {
+ if (!dvbdmxfeed->filter) {
up(&dvbdmx->mutex);
- return -EINVAL;
+ return -EINVAL;
}
- dvbdmxfeed->feed.sec.secbufp=0;
- dvbdmxfeed->feed.sec.seclen=0;
-
- if (!dvbdmx->start_feed) {
+ dvbdmxfeed->feed.sec.secbufp=0;
+ dvbdmxfeed->feed.sec.seclen=0;
+
+ if (!dvbdmx->start_feed) {
up(&dvbdmx->mutex);
- return -1;
+ return -ENODEV;
}
+
prepare_secfilters(dvbdmxfeed);
- ret=dvbdmx->start_feed(dvbdmxfeed);
- if (ret<0) {
+
+ if ((ret = dvbdmx->start_feed(dvbdmxfeed)) < 0) {
up(&dvbdmx->mutex);
return ret;
}
+
spin_lock_irq(&dvbdmx->lock);
- feed->is_filtering=1;
- dvbdmxfeed->state=DMX_STATE_GO;
+ feed->is_filtering=1;
+ dvbdmxfeed->state=DMX_STATE_GO;
spin_unlock_irq(&dvbdmx->lock);
- up(&dvbdmx->mutex);
+ up(&dvbdmx->mutex);
return 0;
}
static int
dmx_section_feed_stop_filtering(struct dmx_section_feed_s* feed)
{
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
- int ret;
+ struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
+ struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
+ int ret;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS;
- if (!dvbdmx->stop_feed) {
+ if (!dvbdmx->stop_feed) {
up(&dvbdmx->mutex);
- return -1;
+ return -ENODEV;
}
ret=dvbdmx->stop_feed(dvbdmxfeed);
spin_lock_irq(&dvbdmx->lock);
- dvbdmxfeed->state=DMX_STATE_READY;
- feed->is_filtering=0;
+ dvbdmxfeed->state=DMX_STATE_READY;
+ feed->is_filtering=0;
spin_unlock_irq(&dvbdmx->lock);
- up(&dvbdmx->mutex);
+ up(&dvbdmx->mutex);
return ret;
}
static int
dmx_section_feed_release_filter(dmx_section_feed_t *feed,
- dmx_section_filter_t* filter)
+ dmx_section_filter_t* filter)
{
- struct dvb_demux_filter *dvbdmxfilter=(struct dvb_demux_filter *) filter, *f;
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
+ struct dvb_demux_filter *dvbdmxfilter=(struct dvb_demux_filter *) filter, *f;
+ struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
+ struct dvb_demux *dvbdmx=dvbdmxfeed->demux;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS;
- if (dvbdmxfilter->feed!=dvbdmxfeed) {
+ if (dvbdmxfilter->feed!=dvbdmxfeed) {
up(&dvbdmx->mutex);
- return -EINVAL;
+ return -EINVAL;
}
- if (feed->is_filtering)
- feed->stop_filtering(feed);
+ if (feed->is_filtering)
+ feed->stop_filtering(feed);
spin_lock_irq(&dvbdmx->lock);
- f=dvbdmxfeed->filter;
- if (f==dvbdmxfilter)
- dvbdmxfeed->filter=dvbdmxfilter->next;
- else {
- while(f->next!=dvbdmxfilter)
- f=f->next;
- f->next=f->next->next;
- }
- dvbdmxfilter->state=DMX_STATE_FREE;
+ f=dvbdmxfeed->filter;
+ if (f==dvbdmxfilter)
+ dvbdmxfeed->filter=dvbdmxfilter->next;
+ else {
+ while(f->next!=dvbdmxfilter)
+ f=f->next;
+ f->next=f->next->next;
+ }
+ dvbdmxfilter->state=DMX_STATE_FREE;
spin_unlock_irq(&dvbdmx->lock);
- up(&dvbdmx->mutex);
- return 0;
+ up(&dvbdmx->mutex);
+ return 0;
}
static int dvbdmx_allocate_section_feed(dmx_demux_t *demux,
- dmx_section_feed_t **feed,
- dmx_section_cb callback)
+ dmx_section_feed_t **feed,
+ dmx_section_cb callback)
{
- struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
- struct dvb_demux_feed *dvbdmxfeed;
+ struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
+ struct dvb_demux_feed *dvbdmxfeed;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS;
- if (!(dvbdmxfeed=dvb_dmx_feed_alloc(dvbdmx))) {
+ if (!(dvbdmxfeed=dvb_dmx_feed_alloc(dvbdmx))) {
up(&dvbdmx->mutex);
- return -EBUSY;
+ return -EBUSY;
}
- dvbdmxfeed->type=DMX_TYPE_SEC;
- dvbdmxfeed->cb.sec=callback;
- dvbdmxfeed->demux=dvbdmx;
- dvbdmxfeed->pid=0xffff;
- dvbdmxfeed->feed.sec.secbufp=0;
- dvbdmxfeed->filter=0;
- dvbdmxfeed->buffer=0;
-
- (*feed)=&dvbdmxfeed->feed.sec;
- (*feed)->is_filtering=0;
- (*feed)->parent=demux;
- (*feed)->priv=0;
- (*feed)->set=dmx_section_feed_set;
- (*feed)->allocate_filter=dmx_section_feed_allocate_filter;
- (*feed)->release_filter=dmx_section_feed_release_filter;
- (*feed)->start_filtering=dmx_section_feed_start_filtering;
- (*feed)->stop_filtering=dmx_section_feed_stop_filtering;
-
- up(&dvbdmx->mutex);
- return 0;
+ dvbdmxfeed->type=DMX_TYPE_SEC;
+ dvbdmxfeed->cb.sec=callback;
+ dvbdmxfeed->demux=dvbdmx;
+ dvbdmxfeed->pid=0xffff;
+ dvbdmxfeed->feed.sec.secbufp=0;
+ dvbdmxfeed->filter=0;
+ dvbdmxfeed->buffer=0;
+
+ (*feed)=&dvbdmxfeed->feed.sec;
+ (*feed)->is_filtering=0;
+ (*feed)->parent=demux;
+ (*feed)->priv=0;
+ (*feed)->set=dmx_section_feed_set;
+ (*feed)->allocate_filter=dmx_section_feed_allocate_filter;
+ (*feed)->release_filter=dmx_section_feed_release_filter;
+ (*feed)->start_filtering=dmx_section_feed_start_filtering;
+ (*feed)->stop_filtering=dmx_section_feed_stop_filtering;
+
+ up(&dvbdmx->mutex);
+ return 0;
}
static int dvbdmx_release_section_feed(dmx_demux_t *demux,
- dmx_section_feed_t *feed)
+ dmx_section_feed_t *feed)
{
- struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
- struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
+ struct dvb_demux_feed *dvbdmxfeed=(struct dvb_demux_feed *) feed;
+ struct dvb_demux *dvbdmx=(struct dvb_demux *) demux;
- if (down_interruptible (&dvbdmx->mutex))
+ if (down_interruptible (&dvbdmx->mutex))
return -ERESTARTSYS;
- if (dvbdmxfeed->state==DMX_STATE_FREE) {
+ if (dvbdmxfeed->state==DMX_STATE_FREE) {
up(&dvbdmx->mutex);
- return -EINVAL;
+ return -EINVAL;
}
#ifndef NOBUFS
- if (dvbdmxfeed->buffer) {
- vfree(dvbdmxfeed->buffer);
- dvbdmxfeed->buffer=0;
- }
+ if (dvbdmxfeed->buffer) {
+ vfree(dvbdmxfeed->buffer);
+ dvbdmxfeed->buffer=0;
+ }
#endif
- dvbdmxfeed->state=DMX_STATE_FREE;
- dvbdmxfeed->demux->pid2feed[dvbdmxfeed->pid]=0;
- if (dvbdmxfeed->pid!=0xffff)
- dvbdmxfeed->demux->pid2feed[dvbdmxfeed->pid]=0;
- up(&dvbdmx->mutex);
- return 0;
+ dvbdmxfeed->state=DMX_STATE_FREE;
+ dvbdmxfeed->demux->pid2feed[dvbdmxfeed->pid]=0;
+ if (dvbdmxfeed->pid!=0xffff)
+ dvbdmxfeed->demux->pid2feed[dvbdmxfeed->pid]=0;
+ up(&dvbdmx->mutex);
+ return 0;
}
@@ -989,72 +1011,72 @@ static int dvbdmx_release_section_feed(dmx_demux_t *demux,
static int dvbdmx_open(dmx_demux_t *demux)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- if (dvbdemux->users>=MAX_DVB_DEMUX_USERS)
- return -EUSERS;
- dvbdemux->users++;
- return 0;
+ if (dvbdemux->users>=MAX_DVB_DEMUX_USERS)
+ return -EUSERS;
+ dvbdemux->users++;
+ return 0;
}
static int dvbdmx_close(struct dmx_demux_s *demux)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- if (dvbdemux->users==0)
- return -ENODEV;
- dvbdemux->users--;
- //FIXME: release any unneeded resources if users==0
- return 0;
+ if (dvbdemux->users==0)
+ return -ENODEV;
+ dvbdemux->users--;
+ //FIXME: release any unneeded resources if users==0
+ return 0;
}
static int dvbdmx_write(dmx_demux_t *demux, const char *buf, size_t count)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- if ((!demux->frontend) ||
- (demux->frontend->source!=DMX_MEMORY_FE))
- return -EINVAL;
+ if ((!demux->frontend) ||
+ (demux->frontend->source!=DMX_MEMORY_FE))
+ return -EINVAL;
- if (down_interruptible (&dvbdemux->mutex))
+ if (down_interruptible (&dvbdemux->mutex))
return -ERESTARTSYS;
- dvb_dmx_swfilter(dvbdemux, buf, count);
- up(&dvbdemux->mutex);
- return count;
+ dvb_dmx_swfilter(dvbdemux, buf, count);
+ up(&dvbdemux->mutex);
+ return count;
}
static int dvbdmx_add_frontend(dmx_demux_t *demux,
- dmx_frontend_t *frontend)
+ dmx_frontend_t *frontend)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- struct list_head *pos, *head=&dvbdemux->frontend_list;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct list_head *pos, *head=&dvbdemux->frontend_list;
if (!(frontend->id && frontend->vendor && frontend->model))
- return -EINVAL;
+ return -EINVAL;
list_for_each(pos, head)
{
- if (!strcmp(DMX_FE_ENTRY(pos)->id, frontend->id))
- return -EEXIST;
+ if (!strcmp(DMX_FE_ENTRY(pos)->id, frontend->id))
+ return -EEXIST;
}
list_add(&(frontend->connectivity_list), head);
- return 0;
+ return 0;
}
static int
dvbdmx_remove_frontend(dmx_demux_t *demux,
- dmx_frontend_t *frontend)
+ dmx_frontend_t *frontend)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- struct list_head *pos, *n, *head=&dvbdemux->frontend_list;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct list_head *pos, *n, *head=&dvbdemux->frontend_list;
list_for_each_safe (pos, n, head)
{
- if (DMX_FE_ENTRY(pos)==frontend)
- {
- list_del(pos);
+ if (DMX_FE_ENTRY(pos)==frontend)
+ {
+ list_del(pos);
return 0;
}
}
@@ -1064,81 +1086,81 @@ dvbdmx_remove_frontend(dmx_demux_t *demux,
static struct list_head *
dvbdmx_get_frontends(dmx_demux_t *demux)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- if (list_empty(&dvbdemux->frontend_list))
- return NULL;
- return &dvbdemux->frontend_list;
+ if (list_empty(&dvbdemux->frontend_list))
+ return NULL;
+ return &dvbdemux->frontend_list;
}
static int dvbdmx_connect_frontend(dmx_demux_t *demux,
- dmx_frontend_t *frontend)
+ dmx_frontend_t *frontend)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- if (demux->frontend)
- return -EINVAL;
-
- if (down_interruptible (&dvbdemux->mutex))
+ if (demux->frontend)
+ return -EINVAL;
+
+ if (down_interruptible (&dvbdemux->mutex))
return -ERESTARTSYS;
- demux->frontend=frontend;
- up(&dvbdemux->mutex);
- return 0;
+ demux->frontend=frontend;
+ up(&dvbdemux->mutex);
+ return 0;
}
static int dvbdmx_disconnect_frontend(dmx_demux_t *demux)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- if (down_interruptible (&dvbdemux->mutex))
+ if (down_interruptible (&dvbdemux->mutex))
return -ERESTARTSYS;
- demux->frontend=NULL;
- up(&dvbdemux->mutex);
- return 0;
+ demux->frontend=NULL;
+ up(&dvbdemux->mutex);
+ return 0;
}
static int dvbdmx_get_pes_pids(dmx_demux_t *demux, u16 *pids)
{
- struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
+ struct dvb_demux *dvbdemux=(struct dvb_demux *) demux;
- memcpy(pids, dvbdemux->pids, 5*sizeof(u16));
- return 0;
+ memcpy(pids, dvbdemux->pids, 5*sizeof(u16));
+ return 0;
}
int
dvb_dmx_init(struct dvb_demux *dvbdemux)
{
- int i;
- dmx_demux_t *dmx=&dvbdemux->dmx;
+ int i;
+ dmx_demux_t *dmx=&dvbdemux->dmx;
- dvbdemux->users=0;
+ dvbdemux->users=0;
dvbdemux->filter=vmalloc(dvbdemux->filternum*sizeof(struct dvb_demux_filter));
if (!dvbdemux->filter)
- return -ENOMEM;
+ return -ENOMEM;
dvbdemux->feed=vmalloc(dvbdemux->feednum*sizeof(struct dvb_demux_feed));
if (!dvbdemux->feed) {
- vfree(dvbdemux->filter);
- return -ENOMEM;
+ vfree(dvbdemux->filter);
+ return -ENOMEM;
}
- for (i=0; i<dvbdemux->filternum; i++) {
- dvbdemux->filter[i].state=DMX_STATE_FREE;
- dvbdemux->filter[i].index=i;
- }
- for (i=0; i<dvbdemux->feednum; i++)
- dvbdemux->feed[i].state=DMX_STATE_FREE;
- dvbdemux->frontend_list.next=
- dvbdemux->frontend_list.prev=
- &dvbdemux->frontend_list;
- for (i=0; i<DMX_TS_PES_OTHER; i++) {
- dvbdemux->pesfilter[i]=NULL;
- dvbdemux->pids[i]=0xffff;
+ for (i=0; i<dvbdemux->filternum; i++) {
+ dvbdemux->filter[i].state=DMX_STATE_FREE;
+ dvbdemux->filter[i].index=i;
}
- dvbdemux->playing=dvbdemux->recording=0;
- memset(dvbdemux->pid2feed, 0, (DMX_MAX_PID+1)*sizeof(struct dvb_demux_feed *));
- dvbdemux->tsbufp=0;
+ for (i=0; i<dvbdemux->feednum; i++)
+ dvbdemux->feed[i].state=DMX_STATE_FREE;
+ dvbdemux->frontend_list.next=
+ dvbdemux->frontend_list.prev=
+ &dvbdemux->frontend_list;
+ for (i=0; i<DMX_TS_PES_OTHER; i++) {
+ dvbdemux->pesfilter[i]=NULL;
+ dvbdemux->pids[i]=0xffff;
+ }
+ dvbdemux->playing=dvbdemux->recording=0;
+ memset(dvbdemux->pid2feed, 0, (DMX_MAX_PID+1)*sizeof(struct dvb_demux_feed *));
+ dvbdemux->tsbufp=0;
if (!dvbdemux->check_crc32)
dvbdemux->check_crc32 = dvb_dmx_crc32;
@@ -1146,47 +1168,47 @@ dvb_dmx_init(struct dvb_demux *dvbdemux)
if (!dvbdemux->memcopy)
dvbdemux->memcopy = dvb_dmx_memcopy;
- dmx->frontend=0;
- dmx->reg_list.next=dmx->reg_list.prev=&dmx->reg_list;
- dmx->priv=(void *) dvbdemux;
- //dmx->users=0; // reset in dmx_register_demux()
- dmx->open=dvbdmx_open;
- dmx->close=dvbdmx_close;
- dmx->write=dvbdmx_write;
- dmx->allocate_ts_feed=dvbdmx_allocate_ts_feed;
- dmx->release_ts_feed=dvbdmx_release_ts_feed;
- dmx->allocate_section_feed=dvbdmx_allocate_section_feed;
- dmx->release_section_feed=dvbdmx_release_section_feed;
-
- dmx->descramble_mac_address=NULL;
- dmx->descramble_section_payload=NULL;
-
- dmx->add_frontend=dvbdmx_add_frontend;
- dmx->remove_frontend=dvbdmx_remove_frontend;
- dmx->get_frontends=dvbdmx_get_frontends;
- dmx->connect_frontend=dvbdmx_connect_frontend;
- dmx->disconnect_frontend=dvbdmx_disconnect_frontend;
- dmx->get_pes_pids=dvbdmx_get_pes_pids;
- sema_init(&dvbdemux->mutex, 1);
+ dmx->frontend=0;
+ dmx->reg_list.next=dmx->reg_list.prev=&dmx->reg_list;
+ dmx->priv=(void *) dvbdemux;
+ //dmx->users=0; // reset in dmx_register_demux()
+ dmx->open=dvbdmx_open;
+ dmx->close=dvbdmx_close;
+ dmx->write=dvbdmx_write;
+ dmx->allocate_ts_feed=dvbdmx_allocate_ts_feed;
+ dmx->release_ts_feed=dvbdmx_release_ts_feed;
+ dmx->allocate_section_feed=dvbdmx_allocate_section_feed;
+ dmx->release_section_feed=dvbdmx_release_section_feed;
+
+ dmx->descramble_mac_address=NULL;
+ dmx->descramble_section_payload=NULL;
+
+ dmx->add_frontend=dvbdmx_add_frontend;
+ dmx->remove_frontend=dvbdmx_remove_frontend;
+ dmx->get_frontends=dvbdmx_get_frontends;
+ dmx->connect_frontend=dvbdmx_connect_frontend;
+ dmx->disconnect_frontend=dvbdmx_disconnect_frontend;
+ dmx->get_pes_pids=dvbdmx_get_pes_pids;
+ sema_init(&dvbdemux->mutex, 1);
spin_lock_init(&dvbdemux->lock);
- if (dmx_register_demux(dmx)<0)
- return -1;
+ if (dmx_register_demux(dmx)<0)
+ return -1;
- return 0;
+ return 0;
}
int
dvb_dmx_release(struct dvb_demux *dvbdemux)
{
- dmx_demux_t *dmx=&dvbdemux->dmx;
+ dmx_demux_t *dmx=&dvbdemux->dmx;
- dmx_unregister_demux(dmx);
+ dmx_unregister_demux(dmx);
if (dvbdemux->filter)
- vfree(dvbdemux->filter);
+ vfree(dvbdemux->filter);
if (dvbdemux->feed)
- vfree(dvbdemux->feed);
- return 0;
+ vfree(dvbdemux->feed);
+ return 0;
}
#if 0
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_demux.h b/linux/drivers/media/dvb/dvb-core/dvb_demux.h
index 7aa93503e..896703f79 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_demux.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_demux.h
@@ -96,12 +96,13 @@ struct dvb_demux {
void *priv;
int filternum;
int feednum;
- int (*start_feed) (struct dvb_demux_feed *);
- int (*stop_feed) (struct dvb_demux_feed *);
- int (*write_to_decoder) (struct dvb_demux_feed *, u8 *buf, size_t len);
- u32 (*check_crc32) (struct dvb_demux_feed *,
+ int (*start_feed) (struct dvb_demux_feed *feed);
+ int (*stop_feed) (struct dvb_demux_feed *feed);
+ int (*write_to_decoder) (struct dvb_demux_feed *feed,
+ const u8 *buf, size_t len);
+ u32 (*check_crc32) (struct dvb_demux_feed *feed,
const u8 *buf, size_t len);
- void (*memcopy) (struct dvb_demux_feed *, u8 *dst,
+ void (*memcopy) (struct dvb_demux_feed *feed, u8 *dst,
const u8 *src, size_t len);
int users;
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_filter.c b/linux/drivers/media/dvb/dvb-core/dvb_filter.c
index c25b91b08..a51b76ecb 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_filter.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_filter.c
@@ -718,7 +718,7 @@ void dvb_filter_ipack_flush(ipack *p)
}
static
-void write_ipack(ipack *p, u8 *data, int count)
+void write_ipack(ipack *p, const u8 *data, int count)
{
u8 headr[3] = { 0x00, 0x00, 0x01} ;
@@ -741,7 +741,7 @@ void write_ipack(ipack *p, u8 *data, int count)
}
-int dvb_filter_instant_repack(u8 *buf, int count, ipack *p)
+int dvb_filter_instant_repack (const u8 *buf, int count, ipack *p)
{
int l;
int c=0;
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_filter.h b/linux/drivers/media/dvb/dvb-core/dvb_filter.h
index 4f3a0852c..19091406d 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_filter.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_filter.h
@@ -225,7 +225,7 @@ typedef struct audio_i{
void dvb_filter_ipack_reset(ipack *p);
-int dvb_filter_instant_repack(u8 *buf, int count, ipack *p);
+int dvb_filter_instant_repack(const u8 *buf, int count, ipack *p);
void dvb_filter_ipack_init(ipack *p, int size,
void (*func)(u8 *buf, int size, void *priv));
void dvb_filter_ipack_free(ipack * p);
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c
index ec5e95a23..d3dd7806d 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c
@@ -73,7 +73,7 @@ unsigned short my_eth_type_trans(struct sk_buff *skb, struct net_device *dev)
}
static void
-dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
+dvb_net_sec(struct net_device *dev, const u8 *pkt, int pkt_len)
{
u8 *eth;
struct sk_buff *skb;
@@ -111,8 +111,8 @@ dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
}
static int
-dvb_net_callback(u8 *buffer1, size_t buffer1_len,
- u8 *buffer2, size_t buffer2_len,
+dvb_net_callback(const u8 *buffer1, size_t buffer1_len,
+ const u8 *buffer2, size_t buffer2_len,
dmx_section_filter_t *filter,
dmx_success_t success)
{
@@ -185,8 +185,8 @@ dvb_net_feed_start(struct net_device *dev)
priv->secfeed=0;
priv->secfilter=0;
- ret=demux->allocate_section_feed(demux, &priv->secfeed,
- dvb_net_callback);
+ ret = demux->allocate_section_feed (demux, &priv->secfeed,
+ dvb_net_callback);
if (ret<0) {
printk("%s: could not get section feed\n", dev->name);
return ret;