Lines Matching refs:dev

57 void vfc_lock_device(struct vfc_dev *dev)  in vfc_lock_device()  argument
59 down(&dev->device_lock_sem); in vfc_lock_device()
62 void vfc_unlock_device(struct vfc_dev *dev) in vfc_unlock_device() argument
64 up(&dev->device_lock_sem); in vfc_unlock_device()
68 void vfc_captstat_reset(struct vfc_dev *dev) in vfc_captstat_reset() argument
70 dev->control_reg |= VFC_CONTROL_CAPTRESET; in vfc_captstat_reset()
71 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_captstat_reset()
72 dev->control_reg &= ~VFC_CONTROL_CAPTRESET; in vfc_captstat_reset()
73 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_captstat_reset()
74 dev->control_reg |= VFC_CONTROL_CAPTRESET; in vfc_captstat_reset()
75 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_captstat_reset()
78 void vfc_memptr_reset(struct vfc_dev *dev) in vfc_memptr_reset() argument
80 dev->control_reg |= VFC_CONTROL_MEMPTR; in vfc_memptr_reset()
81 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_memptr_reset()
82 dev->control_reg &= ~VFC_CONTROL_MEMPTR; in vfc_memptr_reset()
83 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_memptr_reset()
84 dev->control_reg |= VFC_CONTROL_MEMPTR; in vfc_memptr_reset()
85 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_memptr_reset()
88 int vfc_csr_init(struct vfc_dev *dev) in vfc_csr_init() argument
90 dev->control_reg = 0x80000000; in vfc_csr_init()
91 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_csr_init()
93 dev->control_reg &= ~0x80000000; in vfc_csr_init()
94 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_csr_init()
96 sbus_writel(0x0f000000, &dev->regs->i2c_magic2); in vfc_csr_init()
98 vfc_memptr_reset(dev); in vfc_csr_init()
100 dev->control_reg &= ~VFC_CONTROL_DIAGMODE; in vfc_csr_init()
101 dev->control_reg &= ~VFC_CONTROL_CAPTURE; in vfc_csr_init()
102 dev->control_reg |= 0x40000000; in vfc_csr_init()
103 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_csr_init()
105 vfc_captstat_reset(dev); in vfc_csr_init()
110 int vfc_saa9051_init(struct vfc_dev *dev) in vfc_saa9051_init() argument
115 dev->saa9051_state_array[i] = saa9051_init_array[i]; in vfc_saa9051_init()
117 vfc_i2c_sendbuf(dev,VFC_SAA9051_ADDR, in vfc_saa9051_init()
118 dev->saa9051_state_array, VFC_SAA9051_NR); in vfc_saa9051_init()
122 int init_vfc_hw(struct vfc_dev *dev) in init_vfc_hw() argument
124 vfc_lock_device(dev); in init_vfc_hw()
125 vfc_csr_init(dev); in init_vfc_hw()
127 vfc_pcf8584_init(dev); in init_vfc_hw()
128 vfc_init_i2c_bus(dev); /* hopefully this doesn't undo the magic in init_vfc_hw()
130 vfc_saa9051_init(dev); in init_vfc_hw()
131 vfc_unlock_device(dev); in init_vfc_hw()
135 int init_vfc_devstruct(struct vfc_dev *dev, int instance) in init_vfc_devstruct() argument
137 dev->instance=instance; in init_vfc_devstruct()
138 init_MUTEX(&dev->device_lock_sem); in init_vfc_devstruct()
139 dev->control_reg=0; in init_vfc_devstruct()
140 init_waitqueue_head(&dev->poll_wait); in init_vfc_devstruct()
141 dev->busy=0; in init_vfc_devstruct()
145 int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev, int instance) in init_vfc_device() argument
149 if(dev == NULL) { in init_vfc_device()
154 dev->regs = NULL; in init_vfc_device()
155 dev->regs = (volatile struct vfc_regs *) in init_vfc_device()
158 dev->which_io = sdev->reg_addrs[0].which_io; in init_vfc_device()
159 dev->phys_regs = (struct vfc_regs *) sdev->reg_addrs[0].phys_addr; in init_vfc_device()
160 if (dev->regs == NULL) in init_vfc_device()
164 instance,(unsigned long)sdev->reg_addrs[0].phys_addr,(unsigned long)dev->regs); in init_vfc_device()
166 if (init_vfc_devstruct(dev, instance)) in init_vfc_device()
168 if (init_vfc_hw(dev)) in init_vfc_device()
172 dev->de = devfs_register (devfs_handle, devname, DEVFS_FL_DEFAULT, in init_vfc_device()
189 struct vfc_dev *dev; in vfc_open() local
192 dev = vfc_get_dev_ptr(MINOR(inode->i_rdev)); in vfc_open()
193 if (dev == NULL) { in vfc_open()
197 if (dev->busy) { in vfc_open()
202 dev->busy = 1; in vfc_open()
205 vfc_lock_device(dev); in vfc_open()
207 vfc_csr_init(dev); in vfc_open()
208 vfc_pcf8584_init(dev); in vfc_open()
209 vfc_init_i2c_bus(dev); in vfc_open()
210 vfc_saa9051_init(dev); in vfc_open()
211 vfc_memptr_reset(dev); in vfc_open()
212 vfc_captstat_reset(dev); in vfc_open()
214 vfc_unlock_device(dev); in vfc_open()
220 struct vfc_dev *dev; in vfc_release() local
223 dev = vfc_get_dev_ptr(MINOR(inode->i_rdev)); in vfc_release()
224 if (!dev || !dev->busy) { in vfc_release()
228 dev->busy = 0; in vfc_release()
233 static int vfc_debug(struct vfc_dev *dev, int cmd, unsigned long arg) in vfc_debug() argument
257 vfc_lock_device(dev); in vfc_debug()
259 vfc_i2c_sendbuf(dev,inout.addr & 0xff, in vfc_debug()
266 vfc_unlock_device(dev); in vfc_debug()
278 vfc_lock_device(dev); in vfc_debug()
280 vfc_i2c_recvbuf(dev,inout.addr & 0xff in vfc_debug()
282 vfc_unlock_device(dev); in vfc_debug()
301 int vfc_capture_start(struct vfc_dev *dev) in vfc_capture_start() argument
303 vfc_captstat_reset(dev); in vfc_capture_start()
304 dev->control_reg = sbus_readl(&dev->regs->control); in vfc_capture_start()
305 if((dev->control_reg & VFC_STATUS_CAPTURE)) { in vfc_capture_start()
307 dev->instance); in vfc_capture_start()
311 vfc_lock_device(dev); in vfc_capture_start()
312 dev->control_reg &= ~VFC_CONTROL_CAPTURE; in vfc_capture_start()
313 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_capture_start()
314 dev->control_reg |= VFC_CONTROL_CAPTURE; in vfc_capture_start()
315 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_capture_start()
316 dev->control_reg &= ~VFC_CONTROL_CAPTURE; in vfc_capture_start()
317 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_capture_start()
318 vfc_unlock_device(dev); in vfc_capture_start()
323 int vfc_capture_poll(struct vfc_dev *dev) in vfc_capture_poll() argument
328 if (dev->regs->control & VFC_STATUS_CAPTURE) in vfc_capture_poll()
330 vfc_i2c_delay_no_busy(dev, 100); in vfc_capture_poll()
334 dev->instance); in vfc_capture_poll()
343 struct vfc_dev *dev, unsigned long arg) in vfc_set_control_ioctl() argument
351 dev->instance,setcmd)); in vfc_set_control_ioctl()
355 vfc_lock_device(dev); in vfc_set_control_ioctl()
356 vfc_memptr_reset(dev); in vfc_set_control_ioctl()
357 vfc_unlock_device(dev); in vfc_set_control_ioctl()
361 vfc_capture_start(dev); in vfc_set_control_ioctl()
362 vfc_capture_poll(dev); in vfc_set_control_ioctl()
366 vfc_lock_device(dev); in vfc_set_control_ioctl()
367 dev->control_reg |= VFC_CONTROL_DIAGMODE; in vfc_set_control_ioctl()
368 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_set_control_ioctl()
369 vfc_unlock_device(dev); in vfc_set_control_ioctl()
376 vfc_lock_device(dev); in vfc_set_control_ioctl()
377 dev->control_reg &= ~VFC_CONTROL_DIAGMODE; in vfc_set_control_ioctl()
378 sbus_writel(dev->control_reg, &dev->regs->control); in vfc_set_control_ioctl()
379 vfc_unlock_device(dev); in vfc_set_control_ioctl()
383 vfc_capture_start(dev); in vfc_set_control_ioctl()
387 vfc_capture_poll(dev); in vfc_set_control_ioctl()
400 struct vfc_dev *dev, unsigned long arg) in vfc_port_change_ioctl() argument
408 dev->instance)); in vfc_port_change_ioctl()
413 dev->instance, cmd)); in vfc_port_change_ioctl()
418 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_START) = 0x72; in vfc_port_change_ioctl()
419 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_STOP) = 0x52; in vfc_port_change_ioctl()
420 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_START) = 0x36; in vfc_port_change_ioctl()
421 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_STOP) = 0x18; in vfc_port_change_ioctl()
422 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) = VFC_SAA9051_BP2; in vfc_port_change_ioctl()
423 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) = VFC_SAA9051_CT | VFC_SAA9051_SS3; in vfc_port_change_ioctl()
424 VFC_SAA9051_SA(dev,VFC_SAA9051_SECAM_DELAY) = 0x3e; in vfc_port_change_ioctl()
427 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_START) = 0x3a; in vfc_port_change_ioctl()
428 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_STOP) = 0x17; in vfc_port_change_ioctl()
429 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_START) = 0xfa; in vfc_port_change_ioctl()
430 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_STOP) = 0xde; in vfc_port_change_ioctl()
431 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) = in vfc_port_change_ioctl()
433 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) = VFC_SAA9051_YC; in vfc_port_change_ioctl()
434 VFC_SAA9051_SA(dev,VFC_SAA9051_SECAM_DELAY) = 0; in vfc_port_change_ioctl()
435 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) &= in vfc_port_change_ioctl()
446 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) |= in vfc_port_change_ioctl()
450 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) &= in vfc_port_change_ioctl()
452 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) |= VFC_SAA9051_SS0; in vfc_port_change_ioctl()
461 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) &= ~(VFC_SAA9051_SS2); in vfc_port_change_ioctl()
462 ret=vfc_update_saa9051(dev); in vfc_port_change_ioctl()
464 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) |= (VFC_SAA9051_SS2); in vfc_port_change_ioctl()
465 ret=vfc_update_saa9051(dev); in vfc_port_change_ioctl()
470 struct vfc_dev *dev, unsigned long arg) in vfc_set_video_ioctl() argument
478 dev->instance)); in vfc_set_video_ioctl()
483 dev->instance, cmd)); in vfc_set_video_ioctl()
486 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~VFC_SAA9051_ALT; in vfc_set_video_ioctl()
487 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) |= VFC_SAA9051_YPN | in vfc_set_video_ioctl()
489 ret = vfc_update_saa9051(dev); in vfc_set_video_ioctl()
492 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~(VFC_SAA9051_YPN | in vfc_set_video_ioctl()
496 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) |= VFC_SAA9051_ALT; in vfc_set_video_ioctl()
497 ret = vfc_update_saa9051(dev); in vfc_set_video_ioctl()
501 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) |= VFC_SAA9051_CO; in vfc_set_video_ioctl()
502 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) &= in vfc_set_video_ioctl()
504 ret = vfc_update_saa9051(dev); in vfc_set_video_ioctl()
507 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~(VFC_SAA9051_CO); in vfc_set_video_ioctl()
508 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) |= in vfc_set_video_ioctl()
510 ret = vfc_update_saa9051(dev); in vfc_set_video_ioctl()
521 struct vfc_dev *dev, unsigned long arg) in vfc_get_video_ioctl() argument
527 if(vfc_i2c_recvbuf(dev, VFC_SAA9051_ADDR, buf, 1)) { in vfc_get_video_ioctl()
529 dev->instance); in vfc_get_video_ioctl()
547 "buf[0]=%x\n", dev->instance, status, buf[0])); in vfc_get_video_ioctl()
552 dev->instance)); in vfc_get_video_ioctl()
563 struct vfc_dev *dev; in vfc_ioctl() local
565 dev = vfc_get_dev_ptr(MINOR(inode->i_rdev)); in vfc_ioctl()
566 if(dev == NULL) in vfc_ioctl()
572 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCGCTRL)\n", dev->instance)); in vfc_ioctl()
574 tmp = sbus_readl(&dev->regs->control); in vfc_ioctl()
582 ret = vfc_set_control_ioctl(inode, file, dev, arg); in vfc_ioctl()
585 ret = vfc_get_video_ioctl(inode, file, dev, arg); in vfc_ioctl()
588 ret = vfc_set_video_ioctl(inode, file, dev, arg); in vfc_ioctl()
591 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCHUE)\n", dev->instance)); in vfc_ioctl()
594 "to IOCTL(VFCHUE)", dev->instance)); in vfc_ioctl()
597 VFC_SAA9051_SA(dev,VFC_SAA9051_HUE) = tmp; in vfc_ioctl()
598 vfc_update_saa9051(dev); in vfc_ioctl()
603 ret = vfc_port_change_ioctl(inode, file, dev, arg); in vfc_ioctl()
607 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCRDINFO)\n", dev->instance)); in vfc_ioctl()
622 struct vfc_dev *dev; in vfc_mmap() local
624 dev = vfc_get_dev_ptr(MINOR(inode->i_rdev)); in vfc_mmap()
625 if(dev == NULL) in vfc_mmap()
634 map_offset = (unsigned int) (long)dev->phys_regs; in vfc_mmap()
636 vma->vm_page_prot, dev->which_io); in vfc_mmap()
722 static void deinit_vfc_device(struct vfc_dev *dev) in deinit_vfc_device() argument
724 if(dev == NULL) in deinit_vfc_device()
726 devfs_unregister (dev->de); in deinit_vfc_device()
727 sbus_iounmap((unsigned long)dev->regs, sizeof(struct vfc_regs)); in deinit_vfc_device()
728 kfree(dev); in deinit_vfc_device()