Esempio n. 1
0
int mpq_streambuffer_init(
		struct mpq_streambuffer *sbuff,
		enum mpq_streambuffer_mode mode,
		struct mpq_streambuffer_buffer_desc *data_buffers,
		u32 data_buff_num,
		void *packet_buff,
		size_t packet_buff_size)
{
	if ((NULL == sbuff) || (NULL == data_buffers) || (NULL == packet_buff))
		return -EINVAL;

	if (data_buff_num > 1) {
		if (mode != MPQ_STREAMBUFFER_BUFFER_MODE_LINEAR)
			return -EINVAL;
		/* Linear buffer group */
		dvb_ringbuffer_init(
			&sbuff->raw_data,
			data_buffers,
			data_buff_num *
			sizeof(struct mpq_streambuffer_buffer_desc));
	} else if (data_buff_num == 1) {
		if (mode != MPQ_STREAMBUFFER_BUFFER_MODE_RING)
			return -EINVAL;
		/* Single ring-buffer */
		dvb_ringbuffer_init(&sbuff->raw_data,
			data_buffers[0].base, data_buffers[0].size);
	}
	sbuff->mode = mode;
	sbuff->buffers = data_buffers;
	sbuff->pending_buffers_count = 0;
	sbuff->buffers_num = data_buff_num;
	dvb_ringbuffer_init(&sbuff->packet_data, packet_buff, packet_buff_size);

	return 0;
}
Esempio n. 2
0
File: dmxdev.c Progetto: 274914765/C
int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
{
    int i;

    if (dmxdev->demux->open(dmxdev->demux) < 0)
        return -EUSERS;

    dmxdev->filter = vmalloc(dmxdev->filternum * sizeof(struct dmxdev_filter));
    if (!dmxdev->filter)
        return -ENOMEM;

    mutex_init(&dmxdev->mutex);
    spin_lock_init(&dmxdev->lock);
    for (i = 0; i < dmxdev->filternum; i++) {
        dmxdev->filter[i].dev = dmxdev;
        dmxdev->filter[i].buffer.data = NULL;
        dvb_dmxdev_filter_state_set(&dmxdev->filter[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);

    dvb_ringbuffer_init(&dmxdev->dvr_buffer, NULL, 8192);

    return 0;
}
Esempio n. 3
0
static int dvb_demux_open(struct inode *inode, struct file *file)
{
	struct dvb_device *dvbdev = file->private_data;
	struct dmxdev *dmxdev = dvbdev->priv;
	int i;
	struct dmxdev_filter *dmxdevfilter;

	if (!dmxdev->filter)
		return -EINVAL;

	if (mutex_lock_interruptible(&dmxdev->mutex))
		return -ERESTARTSYS;

	for (i = 0; i < dmxdev->filternum; i++)
		if (dmxdev->filter[i].state == DMXDEV_STATE_FREE)
			break;

	if (i == dmxdev->filternum) {
		mutex_unlock(&dmxdev->mutex);
		return -EMFILE;
	}

	dmxdevfilter = &dmxdev->filter[i];
	mutex_init(&dmxdevfilter->mutex);
	file->private_data = dmxdevfilter;

	dvb_ringbuffer_init(&dmxdevfilter->buffer, NULL, 8192);
	dmxdevfilter->type = DMXDEV_TYPE_NONE;
	dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
	dmxdevfilter->feed.ts = NULL;
	init_timer(&dmxdevfilter->timer);

	mutex_unlock(&dmxdev->mutex);
	return 0;
}
Esempio n. 4
0
File: dmxdev.c Progetto: 274914765/C
static int dvb_dvr_open(struct inode *inode, struct file *file)
{
    struct dvb_device *dvbdev = file->private_data;
    struct dmxdev *dmxdev = dvbdev->priv;
    struct dmx_frontend *front;

    dprintk("function : %s\n", __func__);

    if (mutex_lock_interruptible(&dmxdev->mutex))
        return -ERESTARTSYS;

    if (dmxdev->exit) {
        mutex_unlock(&dmxdev->mutex);
        return -ENODEV;
    }

    if ((file->f_flags & O_ACCMODE) == O_RDWR) {
        if (!(dmxdev->capabilities & DMXDEV_CAP_DUPLEX)) {
            mutex_unlock(&dmxdev->mutex);
            return -EOPNOTSUPP;
        }
    }

    if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
        void *mem;
        if (!dvbdev->readers) {
            mutex_unlock(&dmxdev->mutex);
            return -EBUSY;
        }
        mem = vmalloc(DVR_BUFFER_SIZE);
        if (!mem) {
            mutex_unlock(&dmxdev->mutex);
            return -ENOMEM;
        }
        dvb_ringbuffer_init(&dmxdev->dvr_buffer, mem, DVR_BUFFER_SIZE);
        dvbdev->readers--;
    }

    if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
        dmxdev->dvr_orig_fe = dmxdev->demux->frontend;

        if (!dmxdev->demux->write) {
            mutex_unlock(&dmxdev->mutex);
            return -EOPNOTSUPP;
        }

        front = get_fe(dmxdev->demux, DMX_MEMORY_FE);

        if (!front) {
            mutex_unlock(&dmxdev->mutex);
            return -EINVAL;
        }
        dmxdev->demux->disconnect_frontend(dmxdev->demux);
        dmxdev->demux->connect_frontend(dmxdev->demux, front);
    }
    dvbdev->users++;
    mutex_unlock(&dmxdev->mutex);
    return 0;
}
static int ci_ll_init(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf, int size)
{
	struct dvb_ringbuffer *tab[] = { cirbuf, ciwbuf, NULL }, **p;
	void *data;

	for (p = tab; *p; p++) {
		data = vmalloc(size);
		if (!data) {
			while (p-- != tab) {
				vfree(p[0]->data);
				p[0]->data = NULL;
			}
			return -ENOMEM;
		}
		dvb_ringbuffer_init(*p, data, size);
	}
	return 0;
}
Esempio n. 6
0
/*=============================================================================
	Function	: kfront_init
	Description	:
	Input		:
	Output		:
	Return		:
=============================================================================*/
int kfront_init(void)
{
	void *data;
	int rv = -1;
	int i;

	printk("FP driver for abip 55hd\nVersion %d.%02d (c) 2010 Sysifos\n", FP55_MODULE_VERSION / 100, FP55_MODULE_VERSION % 100);
	printk("Built %s %s\n", __DATE__, __TIME__);

	sema_init(&sem, 0);
	sema_init(&sem_lock, 1);

	/*	alloc key buffer	*/
	data = vmalloc(KEY_BUF_SIZE);
	if (!data)
		return -ENOMEM;

	dvb_ringbuffer_init(&ci_rbuffer, data, KEY_BUF_SIZE);

	kfront = vmalloc(sizeof(struct kfront_tag));
	if (!kfront)
		return -ENOMEM;

	/*	open pio	*/
	kfront->clk = stpio_request_pin(PIO_CLOCK_PORT, PIO_CLOCK_BIT, "clock", STPIO_OUT);
	kfront->data = stpio_request_pin(PIO_DATA_PORT, PIO_DATA_BIT, "data", STPIO_BIDIR/*STPIO_OUT*/);
	kfront->stb = stpio_request_pin(PIO_STB_PORT, PIO_STB_BIT, "stb", STPIO_OUT);

	if (!kfront->clk || !kfront->data || !kfront->stb)
	{
		dprintk("%s: kfront->clk=%p, kfront->data=%p kfront->stb=%p open error\n", __func__, kfront->clk, kfront->data, kfront->stb);
		goto error1;
	}

	/*	initialize	*/
	initial();

	/*	start task	*/
	kfront->bQuit = 0;

	kfront->th = kthread_create(kfront_thread, kfront, "kfront");

	if (IS_ERR(kfront->th))
	{
		dprintk("%s: unable to start task\n", __func__);
		goto error2;
	}
	else
	{
		wake_up_process(kfront->th);
	}

	/*	register device	*/
	if (register_chrdev(KFRONT_MAJOR, "kfront0", &kfront_fops))
	{
		dprintk("%s:: Unable to register driver\n", __func__);
		goto error3;
	}

	// input device init
	fp_button_dev = input_allocate_device();
	if (!fp_button_dev)
	{
		printk("FP: ERR: Not enough memory\n");

		rv = -ENOMEM;
		goto error3;
	}


	printk("FP: register key events:");
	set_bit(EV_KEY, fp_button_dev->evbit);
	memset(fp_button_dev->keybit, 0, sizeof(fp_button_dev->keybit));
	for (i = 0; i < FP_KEYS_MAX; i++)
		if (fp_keys[i].key)
		{
			set_bit(fp_keys[i].key, fp_button_dev->keybit);
			printk(" [%s]", fp_keys[i].name);
		}
	printk("\n");

	fp_button_dev->name = "Frontpanel";

	if (input_register_device(fp_button_dev))
	{
		printk("FP: ERR: Failed to register input device\n");

		rv = -ENOMEM;
		goto error3;
	}

	return 0; // all is ok


error3:
	if (kfront->th)
	{
		kfront->bQuit = 1;
		kthread_stop(kfront->th);
	}
error2:
	if (kfront->clk)
		stpio_free_pin(kfront->clk);
	if (kfront->data)
		stpio_free_pin(kfront->data);
	if (kfront->stb)
		stpio_free_pin(kfront->stb);
error1:
	if (kfront)
	{
		vfree(kfront);
		kfront = NULL;
	}
	if (data)
		vfree(data);

	return -1;
}