Commit a095be4b authored by Andrea Odetti's avatar Andrea Odetti Committed by Mauro Carvalho Chehab

V4L/DVB (7659): dvb-core: Implement DMX_SET_BUFFER_SIZE for dvr

Implementation of DMX_SET_BUFFER_SIZE for dvr.
Synchronization of the code of DMX_SET_BUFFER_SIZE for demux and dvr.
Signed-off-by: default avatarAndrea Odetti <mariofutire@gmail.com>
Signed-off-by: default avatarOliver Endriss <o.endriss@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 48c01a9c
...@@ -259,6 +259,39 @@ static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count, ...@@ -259,6 +259,39 @@ static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count,
return ret; return ret;
} }
static int dvb_dvr_set_buffer_size(struct dmxdev *dmxdev,
unsigned long size)
{
struct dvb_ringbuffer *buf = &dmxdev->dvr_buffer;
void *newmem;
void *oldmem;
dprintk("function : %s\n", __func__);
if (buf->size == size)
return 0;
if (!size)
return -EINVAL;
newmem = vmalloc(size);
if (!newmem)
return -ENOMEM;
oldmem = buf->data;
spin_lock_irq(&dmxdev->lock);
buf->data = newmem;
buf->size = size;
/* reset and not flush in case the buffer shrinks */
dvb_ringbuffer_reset(buf);
spin_unlock_irq(&dmxdev->lock);
vfree(oldmem);
return 0;
}
static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter
*dmxdevfilter, int state) *dmxdevfilter, int state)
{ {
...@@ -271,30 +304,32 @@ static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter, ...@@ -271,30 +304,32 @@ static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter,
unsigned long size) unsigned long size)
{ {
struct dvb_ringbuffer *buf = &dmxdevfilter->buffer; struct dvb_ringbuffer *buf = &dmxdevfilter->buffer;
void *mem; void *newmem;
void *oldmem;
if (buf->size == size) if (buf->size == size)
return 0; return 0;
if (!size)
return -EINVAL;
if (dmxdevfilter->state >= DMXDEV_STATE_GO) if (dmxdevfilter->state >= DMXDEV_STATE_GO)
return -EBUSY; return -EBUSY;
newmem = vmalloc(size);
if (!newmem)
return -ENOMEM;
oldmem = buf->data;
spin_lock_irq(&dmxdevfilter->dev->lock); spin_lock_irq(&dmxdevfilter->dev->lock);
mem = buf->data; buf->data = newmem;
buf->data = NULL;
buf->size = size; buf->size = size;
/* reset and not flush in case the buffer shrinks */ /* reset and not flush in case the buffer shrinks */
dvb_ringbuffer_reset(buf); dvb_ringbuffer_reset(buf);
spin_unlock_irq(&dmxdevfilter->dev->lock); spin_unlock_irq(&dmxdevfilter->dev->lock);
vfree(mem);
if (buf->size) { vfree(oldmem);
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 0; return 0;
} }
...@@ -1011,6 +1046,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, ...@@ -1011,6 +1046,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
{ {
struct dvb_device *dvbdev = file->private_data; struct dvb_device *dvbdev = file->private_data;
struct dmxdev *dmxdev = dvbdev->priv; struct dmxdev *dmxdev = dvbdev->priv;
unsigned long arg = (unsigned long)parg;
int ret; int ret;
if (mutex_lock_interruptible(&dmxdev->mutex)) if (mutex_lock_interruptible(&dmxdev->mutex))
...@@ -1018,8 +1054,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, ...@@ -1018,8 +1054,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
switch (cmd) { switch (cmd) {
case DMX_SET_BUFFER_SIZE: case DMX_SET_BUFFER_SIZE:
// FIXME: implement ret = dvb_dvr_set_buffer_size(dmxdev, arg);
ret = 0;
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment