Esempio n. 1
0
static int
mp3_ioctl_back(struct inode *inode, struct file *fp, unsigned int command, unsigned long arg)
{
    int ret;

    while(foregroundUseFlag)
    {
        // wait for foreground use flag to get set to 0
        pnx0106_epics_sleep(10);

    }
    // Also, need to check if a foreground task is requesting use of the EPICS
    // If so, need to backup and block and only unblock and restore when
    // it has finished
    if(pnx0106_epics_get_exit_decoder())
    {

        printk("Halting at mp3_ioctl_back\n");
        if((ret = backup_block_restore())<0)
        {
            return ret;
        }

    }

    ret = mp3_ioctl(inode, fp, command, arg);
    return ret;
}
Esempio n. 2
0
static ssize_t mp3_write(struct file *file, const char __user *buf,
			   size_t count, loff_t *pos)
{
	struct mp3 *mp3 = file->private_data;
	struct audio_client *ac;
	struct audio_buffer *ab;
	const char __user *start = buf;
	int xfer;

	if (!mp3->ac)
		mp3_ioctl(file, AUDIO_START, 0);

	ac = mp3->ac;
	if (!ac)
		return -ENODEV;

	while (count > 0) {
		ab = ac->buf + ac->cpu_buf;

		if (ab->used)
			wait_event(ac->wait, (ab->used == 0));

		xfer = count;
		if (xfer > ab->size)
			xfer = ab->size;

		if (copy_from_user(ab->data, buf, xfer))
			return -EFAULT;

		buf += xfer;
		count -= xfer;

		ab->used = xfer;
		q6audio_write(ac, ab);
		ac->cpu_buf ^= 1;
	}

	return buf - start;
}