Import 2.3.9
[davej-history.git] / drivers / char / vino.c
blob1da4b894ed4653913eabd2c7c281e1e7e3bd5175
1 /* $Id: vino.c,v 1.4 1999/02/09 23:59:36 ulfc Exp $
2 * drivers/char/vino.c
4 * (incomplete) Driver for the Vino Video input system found in SGI Indys.
6 * Copyright (C) 1999 Ulf Carlsson (ulfc@bun.falkenberg.se)
8 * This isn't complete yet, please don't expect any video until I've written
9 * some more code.
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/types.h>
15 #include <linux/mm.h>
16 #include <linux/errno.h>
17 #include <linux/videodev.h>
19 #include <asm/addrspace.h>
20 #include <asm/system.h>
22 #include "vino.h"
24 struct vino_device {
25 struct video_device vdev;
27 unsigned long chan;
28 #define VINO_CHAN_A 0
29 #define VINO_CHAN_B 1
31 unsigned long flags;
32 #define VINO_DMA_ACTIVE (1<<0)
35 /* We can actually receive TV and IndyCam input at the same time. Believe it or
36 * not..
38 static struct vino_device vino[2];
40 /* Those registers have to be accessed by either *one* 64 bit write or *one* 64
41 * bit read. We need some asm to fix this. We can't use mips3 as standard
42 * because we just save 32 bits at context switch.
45 static __inline__ unsigned long long vino_reg_read(unsigned long addr)
47 unsigned long long ret __attribute__ ((aligned (64)));
48 unsigned long virt_addr = KSEG1ADDR(addr + VINO_BASE);
49 unsigned long flags;
51 save_and_cli(flags);
52 __asm__ __volatile__(
53 ".set\tmips3\n\t"
54 ".set\tnoat\n\t"
55 "ld\t$1,(%0)\n\t"
56 "sd\t$1,(%1)\n\t"
57 ".set\tat\n\t"
58 ".set\tmips0"
60 :"r" (virt_addr),
61 "r" (&ret)
62 :"$1");
63 restore_flags(flags);
65 return ret;
68 static __inline__ void vino_reg_write(unsigned long long value,
69 unsigned long addr)
71 unsigned long virt_addr = KSEG1ADDR(addr + VINO_BASE);
72 unsigned long flags;
74 /* we might lose the upper parts of the registers which are not saved
75 * if there comes an interrupt in our way, play safe */
77 save_and_cli(flags);
78 __asm__ __volatile__(
79 ".set\tmips3\n\t"
80 ".set\tnoat\n\t"
81 "ld\t$1,(%0)\n\t"
82 "sd\t$1,(%1)\n\t"
83 ".set\tat\n\t"
84 ".set\tmips0"
86 :"r" (&value),
87 "r" (virt_addr)
88 :"$1");
89 restore_flags(flags);
92 static __inline__ void vino_reg_and(unsigned long long value,
93 unsigned long addr)
95 unsigned long virt_addr = KSEG1ADDR(addr + VINO_BASE);
96 unsigned long flags;
98 save_and_cli(flags);
99 __asm__ __volatile__(
100 ".set\tmips3\n\t"
101 ".set\tnoat\n\t"
102 "ld\t$1,(%0)\n\t"
103 "ld\t$2,(%1)\n\t"
104 "and\t$1,$1,$2\n\t"
105 "sd\t$1,(%0)\n\t"
106 ".set\tat\n\t"
107 ".set\tmips0"
109 :"r" (virt_addr),
110 "r" (&value)
111 :"$1","$2");
112 restore_flags(flags);
115 static __inline__ void vino_reg_or(unsigned long long value,
116 unsigned long addr)
118 unsigned long virt_addr = KSEG1ADDR(addr + VINO_BASE);
119 unsigned long flags;
121 save_and_cli(flags);
122 __asm__ __volatile__(
123 ".set\tmips3\n\t"
124 ".set\tnoat\n\t"
125 "ld\t$1,(%0)\n\t"
126 "ld\t$2,(%1)\n\t"
127 "or\t$1,$1,$2\n\t"
128 "sd\t$1,(%0)\n\t"
129 ".set\tat\n\t"
130 ".set\tmips0"
132 :"r" (virt_addr),
133 "r" (&value)
134 :"$1","$2");
135 restore_flags(flags);
138 static int vino_dma_setup(void)
140 return 0;
143 static void vino_dma_stop(void)
148 static int vino_init(void)
150 unsigned long ret;
151 unsigned short rev, id;
152 unsigned long long foo;
153 unsigned long *bar;
155 bar = (unsigned long *) &foo;
157 ret = vino_reg_read(VINO_REVID);
159 rev = (ret & VINO_REVID_REV_MASK);
160 id = (ret & VINO_REVID_ID_MASK) >> 4;
162 printk("Vino: ID:%02hx Rev:%02hx\n", id, rev);
164 foo = vino_reg_read(VINO_A_DESC_DATA0);
165 printk("0x%lx", bar[0]);
166 printk("%lx ", bar[1]);
167 foo = vino_reg_read(VINO_A_DESC_DATA1);
168 printk("0x%lx", bar[0]);
169 printk("%lx ", bar[1]);
170 foo = vino_reg_read(VINO_A_DESC_DATA2);
171 printk("0x%lx", bar[0]);
172 printk("%lx ", bar[1]);
173 foo = vino_reg_read(VINO_A_DESC_DATA3);
174 printk("0x%lx", bar[0]);
175 printk("%lx\n", bar[1]);
176 foo = vino_reg_read(VINO_B_DESC_DATA0);
177 printk("0x%lx", bar[0]);
178 printk("%lx ", bar[1]);
179 foo = vino_reg_read(VINO_B_DESC_DATA1);
180 printk("0x%lx", bar[0]);
181 printk("%lx ", bar[1]);
182 foo = vino_reg_read(VINO_B_DESC_DATA2);
183 printk("0x%lx", bar[0]);
184 printk("%lx ", bar[1]);
185 foo = vino_reg_read(VINO_B_DESC_DATA3);
186 printk("0x%lx", bar[0]);
187 printk("%lx\n", bar[1]);
189 return 0;
192 static void vino_dma_go(struct vino_device *v)
197 /* Reset the vino back to default state */
199 static void vino_setup(struct vino_device *v)
204 static int vino_open(struct video_device *dev, int flags)
206 MOD_INC_USE_COUNT;
207 return 0;
210 static void vino_close(struct video_device *dev)
212 MOD_DEC_USE_COUNT;
215 static int vino_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
217 return 0;
220 static int vino_mmap(struct video_device *dev, const char *adr,
221 unsigned long size)
223 return 0;
226 static struct video_device vino_dev = {
227 "Vino IndyCam/TV",
228 VID_TYPE_CAPTURE,
229 VID_HARDWARE_VINO,
230 vino_open,
231 vino_close,
232 NULL, /* vino_read */
233 NULL, /* vino_write */
234 NULL, /* vino_poll */
235 vino_ioctl,
236 vino_mmap,
237 NULL, /* vino_init */
238 NULL,
243 __initfunc(int init_vino(struct video_device *dev))
245 int err;
247 err = vino_init();
248 if (err)
249 return err;
251 #if 0
252 if (video_register_device(&vinodev, VFL_TYPE_GRABBER) == -1) {
253 return -ENODEV;
255 #endif
257 return 0;
260 #ifdef MODULE
261 int init_module(void)
263 int err;
265 err = vino_init();
266 if (err)
267 return err;
269 return 0;
272 void cleanup_module(void)
275 #endif