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; }
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; }
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; }
int vfc_csr_init(struct vfc_dev *dev) { dev->control_reg = 0x80000000; sbus_writel(dev->control_reg, &dev->regs->control); udelay(200); dev->control_reg &= ~0x80000000; sbus_writel(dev->control_reg, &dev->regs->control); udelay(100); sbus_writel(0x0f000000, &dev->regs->i2c_magic2); vfc_memptr_reset(dev); dev->control_reg &= ~VFC_CONTROL_DIAGMODE; dev->control_reg &= ~VFC_CONTROL_CAPTURE; dev->control_reg |= 0x40000000; sbus_writel(dev->control_reg, &dev->regs->control); vfc_captstat_reset(dev); return 0; }