示例#1
0
static int vfc_set_control_ioctl(struct inode *inode, struct file *file, 
			  struct vfc_dev *dev, unsigned long arg) 
{
	int setcmd, ret = 0;

	if (copy_from_user(&setcmd,(void *)arg,sizeof(unsigned int)))
		return -EFAULT;

	VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCSCTRL) arg=0x%x\n",
				dev->instance,setcmd));

	switch(setcmd) {
	case MEMPRST:
		vfc_lock_device(dev);
		vfc_memptr_reset(dev);
		vfc_unlock_device(dev);
		ret=0;
		break;
	case CAPTRCMD:
		vfc_capture_start(dev);
		vfc_capture_poll(dev);
		break;
	case DIAGMODE:
		if(capable(CAP_SYS_ADMIN)) {
			vfc_lock_device(dev);
			dev->control_reg |= VFC_CONTROL_DIAGMODE;
			sbus_writel(dev->control_reg, &dev->regs->control);
			vfc_unlock_device(dev);
			ret = 0;
		} else {
			ret = -EPERM; 
		}
		break;
	case NORMMODE:
		vfc_lock_device(dev);
		dev->control_reg &= ~VFC_CONTROL_DIAGMODE;
		sbus_writel(dev->control_reg, &dev->regs->control);
		vfc_unlock_device(dev);
		ret = 0;
		break;
	case CAPTRSTR:
		vfc_capture_start(dev);
		ret = 0;
		break;
	case CAPTRWAIT:
		vfc_capture_poll(dev);
		ret = 0;
		break;
	default:
		ret = -EINVAL;
		break;
	};

	return ret;
}
示例#2
0
static int vfc_open(struct inode *inode, struct file *file) 
{
	struct vfc_dev *dev;

	spin_lock(&vfc_dev_lock);
	dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
	if (dev == NULL) {
		spin_unlock(&vfc_dev_lock);
		return -ENODEV;
	}
	if (dev->busy) {
		spin_unlock(&vfc_dev_lock);
		return -EBUSY;
	}

	dev->busy = 1;
	spin_unlock(&vfc_dev_lock);

	vfc_lock_device(dev);
	
	vfc_csr_init(dev);
	vfc_pcf8584_init(dev);
	vfc_init_i2c_bus(dev);
	vfc_saa9051_init(dev);
	vfc_memptr_reset(dev);
	vfc_captstat_reset(dev);
	
	vfc_unlock_device(dev);
	return 0;
}
示例#3
0
int init_vfc_hw(struct vfc_dev *dev) 
{
	vfc_lock_device(dev);
	vfc_csr_init(dev);

	vfc_pcf8584_init(dev);
	vfc_init_i2c_bus(dev); /* hopefully this doesn't undo the magic
				  sun code above*/
	vfc_saa9051_init(dev);
	vfc_unlock_device(dev);
	return 0; 
}
示例#4
0
static int vfc_open(struct inode *inode, struct file *file) 
{
	struct vfc_dev *dev;
	dev=vfc_get_dev_ptr(MINOR(inode->i_rdev));
	if(!dev) return -ENODEV;
	if(dev->busy) return -EBUSY;
	dev->busy=1;
	MOD_INC_USE_COUNT;
	vfc_lock_device(dev);
	
	vfc_csr_init(dev);
	vfc_pcf8584_init(dev);
	vfc_init_i2c_bus(dev);
	vfc_saa9051_init(dev);
	vfc_memptr_reset(dev);
	vfc_captstat_reset(dev);
	
	vfc_unlock_device(dev);
	return 0;
}
示例#5
0
int vfc_capture_start(struct vfc_dev *dev) 
{
	vfc_captstat_reset(dev);
	dev->control_reg = sbus_readl(&dev->regs->control);
	if((dev->control_reg & VFC_STATUS_CAPTURE)) {
		printk(KERN_ERR "vfc%d: vfc capture status not reset\n",
		       dev->instance);
		return -EIO;
	}

	vfc_lock_device(dev);
	dev->control_reg &= ~VFC_CONTROL_CAPTURE;
	sbus_writel(dev->control_reg, &dev->regs->control);
	dev->control_reg |= VFC_CONTROL_CAPTURE;
	sbus_writel(dev->control_reg, &dev->regs->control);
	dev->control_reg &= ~VFC_CONTROL_CAPTURE;
	sbus_writel(dev->control_reg, &dev->regs->control);
	vfc_unlock_device(dev);

	return 0;
}
示例#6
0
static int vfc_debug(struct vfc_dev *dev, int cmd, unsigned long arg) 
{
	struct vfc_debug_inout inout;
	unsigned char *buffer;

	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;

	switch(cmd) {
	case VFC_I2C_SEND:
		if(copy_from_user(&inout, (void *)arg, sizeof(inout)))
			return -EFAULT;

		buffer = kmalloc(inout.len*sizeof(char), GFP_KERNEL);
		if (buffer == NULL)
			return -ENOMEM;

		if(copy_from_user(buffer, inout.buffer, 
				  inout.len*sizeof(char))) {
			kfree(buffer);
			return -EFAULT;
		}
		

		vfc_lock_device(dev);
		inout.ret=
			vfc_i2c_sendbuf(dev,inout.addr & 0xff,
					inout.buffer,inout.len);

		if (copy_to_user((void *)arg,&inout,sizeof(inout))) {
			kfree(buffer);
			return -EFAULT;
		}
		vfc_unlock_device(dev);

		break;
	case VFC_I2C_RECV:
		if (copy_from_user(&inout, (void *)arg, sizeof(inout)))
			return -EFAULT;

		buffer = kmalloc(inout.len, GFP_KERNEL);
		if (buffer == NULL)
			return -ENOMEM;

		memset(buffer,0,inout.len*sizeof(char));
		vfc_lock_device(dev);
		inout.ret=
			vfc_i2c_recvbuf(dev,inout.addr & 0xff
					,buffer,inout.len);
		vfc_unlock_device(dev);
		
		if (copy_to_user(inout.buffer, buffer, inout.len)) {
			kfree(buffer);
			return -EFAULT;
		}
		if (copy_to_user((void *)arg,&inout,sizeof(inout))) {
			kfree(buffer);
			return -EFAULT;
		}
		kfree(buffer);
		break;
	default:
		return -EINVAL;
	};

	return 0;
}