Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Modified in order to keep it compatible both with new and old videotext IOCTLs by |
| 3 | * Michael Geng <linux@MichaelGeng.de> |
| 4 | * |
| 5 | * Cleaned up to use existing videodev interface and allow the idea |
| 6 | * of multiple teletext decoders on the video4linux iface. Changed i2c |
| 7 | * to cover addressing clashes on device busses. It's also rebuilt so |
| 8 | * you can add arbitary multiple teletext devices to Linux video4linux |
| 9 | * now (well 32 anyway). |
| 10 | * |
| 11 | * Alan Cox <Alan.Cox@linux.org> |
| 12 | * |
| 13 | * The original driver was heavily modified to match the i2c interface |
| 14 | * It was truncated to use the WinTV boards, too. |
| 15 | * |
| 16 | * Copyright (c) 1998 Richard Guenther <richard.guenther@student.uni-tuebingen.de> |
| 17 | * |
| 18 | * $Id: saa5249.c,v 1.1 1998/03/30 22:23:23 alan Exp $ |
| 19 | * |
| 20 | * Derived From |
| 21 | * |
| 22 | * vtx.c: |
| 23 | * This is a loadable character-device-driver for videotext-interfaces |
| 24 | * (aka teletext). Please check the Makefile/README for a list of supported |
| 25 | * interfaces. |
| 26 | * |
| 27 | * Copyright (c) 1994-97 Martin Buck <martin-2.buck@student.uni-ulm.de> |
| 28 | * |
| 29 | * |
| 30 | * This program is free software; you can redistribute it and/or modify |
| 31 | * it under the terms of the GNU General Public License as published by |
| 32 | * the Free Software Foundation; either version 2 of the License, or |
| 33 | * (at your option) any later version. |
| 34 | * |
| 35 | * This program is distributed in the hope that it will be useful, |
| 36 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 37 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 38 | * GNU General Public License for more details. |
| 39 | * |
| 40 | * You should have received a copy of the GNU General Public License |
| 41 | * along with this program; if not, write to the Free Software |
| 42 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 43 | * USA. |
| 44 | */ |
| 45 | |
| 46 | #include <linux/module.h> |
| 47 | #include <linux/kernel.h> |
| 48 | #include <linux/sched.h> |
| 49 | #include <linux/mm.h> |
| 50 | #include <linux/errno.h> |
| 51 | #include <linux/delay.h> |
| 52 | #include <linux/ioport.h> |
| 53 | #include <linux/slab.h> |
| 54 | #include <linux/init.h> |
| 55 | #include <stdarg.h> |
| 56 | #include <linux/i2c.h> |
| 57 | #include <linux/videotext.h> |
| 58 | #include <linux/videodev.h> |
Mauro Carvalho Chehab | 5e87efa | 2006-06-05 10:26:32 -0300 | [diff] [blame] | 59 | #include <media/v4l2-common.h> |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 60 | #include <linux/mutex.h> |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | #include <asm/io.h> |
| 64 | #include <asm/uaccess.h> |
| 65 | |
| 66 | #define VTX_VER_MAJ 1 |
| 67 | #define VTX_VER_MIN 8 |
| 68 | |
| 69 | |
| 70 | |
| 71 | #define NUM_DAUS 4 |
| 72 | #define NUM_BUFS 8 |
| 73 | #define IF_NAME "SAA5249" |
| 74 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 75 | static const int disp_modes[8][3] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
| 77 | { 0x46, 0x03, 0x03 }, /* DISPOFF */ |
| 78 | { 0x46, 0xcc, 0xcc }, /* DISPNORM */ |
| 79 | { 0x44, 0x0f, 0x0f }, /* DISPTRANS */ |
| 80 | { 0x46, 0xcc, 0x46 }, /* DISPINS */ |
| 81 | { 0x44, 0x03, 0x03 }, /* DISPOFF, interlaced */ |
| 82 | { 0x44, 0xcc, 0xcc }, /* DISPNORM, interlaced */ |
| 83 | { 0x44, 0x0f, 0x0f }, /* DISPTRANS, interlaced */ |
| 84 | { 0x44, 0xcc, 0x46 } /* DISPINS, interlaced */ |
| 85 | }; |
| 86 | |
| 87 | |
| 88 | |
Mauro Carvalho Chehab | 09df5cb | 2007-07-17 16:25:38 -0300 | [diff] [blame] | 89 | #define PAGE_WAIT msecs_to_jiffies(300) /* Time between requesting page and */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | /* checking status bits */ |
Mauro Carvalho Chehab | 09df5cb | 2007-07-17 16:25:38 -0300 | [diff] [blame] | 91 | #define PGBUF_EXPIRE msecs_to_jiffies(15000) /* Time to wait before retransmitting */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | /* page regardless of infobits */ |
| 93 | typedef struct { |
| 94 | u8 pgbuf[VTX_VIRTUALSIZE]; /* Page-buffer */ |
| 95 | u8 laststat[10]; /* Last value of infobits for DAU */ |
| 96 | u8 sregs[7]; /* Page-request registers */ |
| 97 | unsigned long expire; /* Time when page will be expired */ |
| 98 | unsigned clrfound : 1; /* VTXIOCCLRFOUND has been called */ |
| 99 | unsigned stopped : 1; /* VTXIOCSTOPDAU has been called */ |
| 100 | } vdau_t; |
| 101 | |
| 102 | struct saa5249_device |
| 103 | { |
| 104 | vdau_t vdau[NUM_DAUS]; /* Data for virtual DAUs (the 5249 only has one */ |
| 105 | /* real DAU, so we have to simulate some more) */ |
| 106 | int vtx_use_count; |
| 107 | int is_searching[NUM_DAUS]; |
| 108 | int disp_mode; |
| 109 | int virtual_mode; |
| 110 | struct i2c_client *client; |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 111 | struct mutex lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | |
| 115 | #define CCTWR 34 /* I²C write/read-address of vtx-chip */ |
| 116 | #define CCTRD 35 |
| 117 | #define NOACK_REPEAT 10 /* Retry access this many times on failure */ |
Mauro Carvalho Chehab | 09df5cb | 2007-07-17 16:25:38 -0300 | [diff] [blame] | 118 | #define CLEAR_DELAY msecs_to_jiffies(50) /* Time required to clear a page */ |
| 119 | #define READY_TIMEOUT msecs_to_jiffies(30) /* Time to wait for ready signal of I2C-bus interface */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | #define INIT_DELAY 500 /* Time in usec to wait at initialization of CEA interface */ |
| 121 | #define START_DELAY 10 /* Time in usec to wait before starting write-cycle (CEA) */ |
| 122 | |
| 123 | #define VTX_DEV_MINOR 0 |
| 124 | |
| 125 | /* General defines and debugging support */ |
| 126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | #define RESCHED do { cond_resched(); } while(0) |
| 128 | |
| 129 | static struct video_device saa_template; /* Declared near bottom */ |
| 130 | |
| 131 | /* Addresses to scan */ |
| 132 | static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END}; |
Hans Verkuil | f87086e | 2008-07-18 00:50:58 -0300 | [diff] [blame] | 133 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | I2C_CLIENT_INSMOD; |
| 135 | |
| 136 | static struct i2c_client client_template; |
| 137 | |
| 138 | static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind) |
| 139 | { |
| 140 | int pgbuf; |
| 141 | int err; |
| 142 | struct i2c_client *client; |
| 143 | struct video_device *vd; |
| 144 | struct saa5249_device *t; |
| 145 | |
| 146 | printk(KERN_INFO "saa5249: teletext chip found.\n"); |
| 147 | client=kmalloc(sizeof(*client), GFP_KERNEL); |
| 148 | if(client==NULL) |
| 149 | return -ENOMEM; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 150 | client_template.adapter = adap; |
| 151 | client_template.addr = addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | memcpy(client, &client_template, sizeof(*client)); |
Panagiotis Issaris | 7408187 | 2006-01-11 19:40:56 -0200 | [diff] [blame] | 153 | t = kzalloc(sizeof(*t), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | if(t==NULL) |
| 155 | { |
| 156 | kfree(client); |
| 157 | return -ENOMEM; |
| 158 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 160 | mutex_init(&t->lock); |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 161 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | /* |
| 163 | * Now create a video4linux device |
| 164 | */ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 165 | |
Panagiotis Issaris | 7408187 | 2006-01-11 19:40:56 -0200 | [diff] [blame] | 166 | vd = kmalloc(sizeof(struct video_device), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | if(vd==NULL) |
| 168 | { |
| 169 | kfree(t); |
| 170 | kfree(client); |
| 171 | return -ENOMEM; |
| 172 | } |
| 173 | i2c_set_clientdata(client, vd); |
| 174 | memcpy(vd, &saa_template, sizeof(*vd)); |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 175 | |
| 176 | for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | { |
| 178 | memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); |
| 179 | memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); |
| 180 | memset(t->vdau[pgbuf].laststat, 0, sizeof(t->vdau[0].laststat)); |
| 181 | t->vdau[pgbuf].expire = 0; |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 182 | t->vdau[pgbuf].clrfound = true; |
| 183 | t->vdau[pgbuf].stopped = true; |
| 184 | t->is_searching[pgbuf] = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | } |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 186 | vd->priv=t; |
| 187 | |
| 188 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | /* |
| 190 | * Register it |
| 191 | */ |
| 192 | |
| 193 | if((err=video_register_device(vd, VFL_TYPE_VTX,-1))<0) |
| 194 | { |
| 195 | kfree(t); |
| 196 | kfree(vd); |
| 197 | kfree(client); |
| 198 | return err; |
| 199 | } |
| 200 | t->client = client; |
| 201 | i2c_attach_client(client); |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | /* |
| 206 | * We do most of the hard work when we become a device on the i2c. |
| 207 | */ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 208 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | static int saa5249_probe(struct i2c_adapter *adap) |
| 210 | { |
| 211 | if (adap->class & I2C_CLASS_TV_ANALOG) |
| 212 | return i2c_probe(adap, &addr_data, saa5249_attach); |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | static int saa5249_detach(struct i2c_client *client) |
| 217 | { |
| 218 | struct video_device *vd = i2c_get_clientdata(client); |
| 219 | i2c_detach_client(client); |
| 220 | video_unregister_device(vd); |
| 221 | kfree(vd->priv); |
| 222 | kfree(vd); |
| 223 | kfree(client); |
| 224 | return 0; |
| 225 | } |
| 226 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | /* new I2C driver support */ |
| 228 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 229 | static struct i2c_driver i2c_driver_videotext = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | { |
Laurent Riffard | 604f28e | 2005-11-26 20:43:39 +0100 | [diff] [blame] | 231 | .driver = { |
Laurent Riffard | 604f28e | 2005-11-26 20:43:39 +0100 | [diff] [blame] | 232 | .name = IF_NAME, /* name */ |
| 233 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | .attach_adapter = saa5249_probe, |
| 236 | .detach_client = saa5249_detach, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | }; |
| 238 | |
| 239 | static struct i2c_client client_template = { |
| 240 | .driver = &i2c_driver_videotext, |
| 241 | .name = "(unset)", |
| 242 | }; |
| 243 | |
| 244 | /* |
| 245 | * Wait the given number of jiffies (10ms). This calls the scheduler, so the actual |
| 246 | * delay may be longer. |
| 247 | */ |
| 248 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 249 | static void jdelay(unsigned long delay) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
| 251 | sigset_t oldblocked = current->blocked; |
| 252 | |
| 253 | spin_lock_irq(¤t->sighand->siglock); |
| 254 | sigfillset(¤t->blocked); |
| 255 | recalc_sigpending(); |
| 256 | spin_unlock_irq(¤t->sighand->siglock); |
| 257 | msleep_interruptible(jiffies_to_msecs(delay)); |
| 258 | |
| 259 | spin_lock_irq(¤t->sighand->siglock); |
| 260 | current->blocked = oldblocked; |
| 261 | recalc_sigpending(); |
| 262 | spin_unlock_irq(¤t->sighand->siglock); |
| 263 | } |
| 264 | |
| 265 | |
| 266 | /* |
| 267 | * I2C interfaces |
| 268 | */ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 269 | |
| 270 | static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | { |
| 272 | char buf[64]; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | buf[0] = reg; |
| 275 | memcpy(buf+1, data, count); |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 276 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | if(i2c_master_send(t->client, buf, count+1)==count+1) |
| 278 | return 0; |
| 279 | return -1; |
| 280 | } |
| 281 | |
| 282 | static int i2c_senddata(struct saa5249_device *t, ...) |
| 283 | { |
| 284 | unsigned char buf[64]; |
| 285 | int v; |
Richard Knutsson | b730a81 | 2007-11-27 06:59:37 -0300 | [diff] [blame] | 286 | int ct = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | va_list argp; |
| 288 | va_start(argp,t); |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 289 | |
Richard Knutsson | b730a81 | 2007-11-27 06:59:37 -0300 | [diff] [blame] | 290 | while ((v = va_arg(argp, int)) != -1) |
| 291 | buf[ct++] = v; |
| 292 | |
| 293 | va_end(argp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | return i2c_sendbuf(t, buf[0], ct-1, buf+1); |
| 295 | } |
| 296 | |
Marcin Garski | db95517 | 2007-10-19 23:22:11 +0200 | [diff] [blame] | 297 | /* Get count number of bytes from I²C-device at address adr, store them in buf. Start & stop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | * handshaking is done by this routine, ack will be sent after the last byte to inhibit further |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 299 | * sending of data. If uaccess is 'true', data is written to user-space with put_user. |
Marcin Garski | db95517 | 2007-10-19 23:22:11 +0200 | [diff] [blame] | 300 | * Returns -1 if I²C-device didn't send acknowledge, 0 otherwise |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | */ |
| 302 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 303 | static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | { |
| 305 | if(i2c_master_recv(t->client, buf, count)!=count) |
| 306 | return -1; |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | |
| 311 | /* |
| 312 | * Standard character-device-driver functions |
| 313 | */ |
| 314 | |
| 315 | static int do_saa5249_ioctl(struct inode *inode, struct file *file, |
| 316 | unsigned int cmd, void *arg) |
| 317 | { |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 318 | static int virtual_mode = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | struct video_device *vd = video_devdata(file); |
| 320 | struct saa5249_device *t=vd->priv; |
| 321 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 322 | switch(cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | { |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 324 | case VTXIOCGETINFO: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { |
| 326 | vtx_info_t *info = arg; |
| 327 | info->version_major = VTX_VER_MAJ; |
| 328 | info->version_minor = VTX_VER_MIN; |
| 329 | info->numpages = NUM_DAUS; |
| 330 | /*info->cct_type = CCT_TYPE;*/ |
| 331 | return 0; |
| 332 | } |
| 333 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 334 | case VTXIOCCLRPAGE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | { |
| 336 | vtx_pagereq_t *req = arg; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 337 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) |
| 339 | return -EINVAL; |
| 340 | memset(t->vdau[req->pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 341 | t->vdau[req->pgbuf].clrfound = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | return 0; |
| 343 | } |
| 344 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 345 | case VTXIOCCLRFOUND: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | { |
| 347 | vtx_pagereq_t *req = arg; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 348 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) |
| 350 | return -EINVAL; |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 351 | t->vdau[req->pgbuf].clrfound = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | return 0; |
| 353 | } |
| 354 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 355 | case VTXIOCPAGEREQ: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | { |
| 357 | vtx_pagereq_t *req = arg; |
| 358 | if (!(req->pagemask & PGMASK_PAGE)) |
| 359 | req->page = 0; |
| 360 | if (!(req->pagemask & PGMASK_HOUR)) |
| 361 | req->hour = 0; |
| 362 | if (!(req->pagemask & PGMASK_MINUTE)) |
| 363 | req->minute = 0; |
| 364 | if (req->page < 0 || req->page > 0x8ff) /* 7FF ?? */ |
| 365 | return -EINVAL; |
| 366 | req->page &= 0x7ff; |
| 367 | if (req->hour < 0 || req->hour > 0x3f || req->minute < 0 || req->minute > 0x7f || |
| 368 | req->pagemask < 0 || req->pagemask >= PGMASK_MAX || req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) |
| 369 | return -EINVAL; |
| 370 | t->vdau[req->pgbuf].sregs[0] = (req->pagemask & PG_HUND ? 0x10 : 0) | (req->page / 0x100); |
| 371 | t->vdau[req->pgbuf].sregs[1] = (req->pagemask & PG_TEN ? 0x10 : 0) | ((req->page / 0x10) & 0xf); |
| 372 | t->vdau[req->pgbuf].sregs[2] = (req->pagemask & PG_UNIT ? 0x10 : 0) | (req->page & 0xf); |
| 373 | t->vdau[req->pgbuf].sregs[3] = (req->pagemask & HR_TEN ? 0x10 : 0) | (req->hour / 0x10); |
| 374 | t->vdau[req->pgbuf].sregs[4] = (req->pagemask & HR_UNIT ? 0x10 : 0) | (req->hour & 0xf); |
| 375 | t->vdau[req->pgbuf].sregs[5] = (req->pagemask & MIN_TEN ? 0x10 : 0) | (req->minute / 0x10); |
| 376 | t->vdau[req->pgbuf].sregs[6] = (req->pagemask & MIN_UNIT ? 0x10 : 0) | (req->minute & 0xf); |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 377 | t->vdau[req->pgbuf].stopped = false; |
| 378 | t->vdau[req->pgbuf].clrfound = true; |
| 379 | t->is_searching[req->pgbuf] = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | return 0; |
| 381 | } |
| 382 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 383 | case VTXIOCGETSTAT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | { |
| 385 | vtx_pagereq_t *req = arg; |
| 386 | u8 infobits[10]; |
| 387 | vtx_pageinfo_t info; |
| 388 | int a; |
| 389 | |
| 390 | if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) |
| 391 | return -EINVAL; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 392 | if (!t->vdau[req->pgbuf].stopped) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | { |
| 394 | if (i2c_senddata(t, 2, 0, -1) || |
| 395 | i2c_sendbuf(t, 3, sizeof(t->vdau[0].sregs), t->vdau[req->pgbuf].sregs) || |
| 396 | i2c_senddata(t, 8, 0, 25, 0, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', -1) || |
| 397 | i2c_senddata(t, 2, 0, t->vdau[req->pgbuf].sregs[0] | 8, -1) || |
| 398 | i2c_senddata(t, 8, 0, 25, 0, -1)) |
| 399 | return -EIO; |
| 400 | jdelay(PAGE_WAIT); |
| 401 | if (i2c_getdata(t, 10, infobits)) |
| 402 | return -EIO; |
| 403 | |
| 404 | if (!(infobits[8] & 0x10) && !(infobits[7] & 0xf0) && /* check FOUND-bit */ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 405 | (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | time_after_eq(jiffies, t->vdau[req->pgbuf].expire))) |
| 407 | { /* check if new page arrived */ |
| 408 | if (i2c_senddata(t, 8, 0, 0, 0, -1) || |
| 409 | i2c_getdata(t, VTX_PAGESIZE, t->vdau[req->pgbuf].pgbuf)) |
| 410 | return -EIO; |
| 411 | t->vdau[req->pgbuf].expire = jiffies + PGBUF_EXPIRE; |
| 412 | memset(t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE, ' ', VTX_VIRTUALSIZE - VTX_PAGESIZE); |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 413 | if (t->virtual_mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | { |
| 415 | /* Packet X/24 */ |
| 416 | if (i2c_senddata(t, 8, 0, 0x20, 0, -1) || |
| 417 | i2c_getdata(t, 40, t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE + 20 * 40)) |
| 418 | return -EIO; |
| 419 | /* Packet X/27/0 */ |
| 420 | if (i2c_senddata(t, 8, 0, 0x21, 0, -1) || |
| 421 | i2c_getdata(t, 40, t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE + 16 * 40)) |
| 422 | return -EIO; |
| 423 | /* Packet 8/30/0...8/30/15 |
| 424 | * FIXME: AFAIK, the 5249 does hamming-decoding for some bytes in packet 8/30, |
| 425 | * so we should undo this here. |
| 426 | */ |
| 427 | if (i2c_senddata(t, 8, 0, 0x22, 0, -1) || |
| 428 | i2c_getdata(t, 40, t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE + 23 * 40)) |
| 429 | return -EIO; |
| 430 | } |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 431 | t->vdau[req->pgbuf].clrfound = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | memcpy(t->vdau[req->pgbuf].laststat, infobits, sizeof(infobits)); |
| 433 | } |
| 434 | else |
| 435 | { |
| 436 | memcpy(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)); |
| 437 | } |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | memcpy(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)); |
| 442 | } |
| 443 | |
| 444 | info.pagenum = ((infobits[8] << 8) & 0x700) | ((infobits[1] << 4) & 0xf0) | (infobits[0] & 0x0f); |
| 445 | if (info.pagenum < 0x100) |
| 446 | info.pagenum += 0x800; |
| 447 | info.hour = ((infobits[5] << 4) & 0x30) | (infobits[4] & 0x0f); |
| 448 | info.minute = ((infobits[3] << 4) & 0x70) | (infobits[2] & 0x0f); |
| 449 | info.charset = ((infobits[7] >> 1) & 7); |
| 450 | info.delete = !!(infobits[3] & 8); |
| 451 | info.headline = !!(infobits[5] & 4); |
| 452 | info.subtitle = !!(infobits[5] & 8); |
| 453 | info.supp_header = !!(infobits[6] & 1); |
| 454 | info.update = !!(infobits[6] & 2); |
| 455 | info.inter_seq = !!(infobits[6] & 4); |
| 456 | info.dis_disp = !!(infobits[6] & 8); |
| 457 | info.serial = !!(infobits[7] & 1); |
| 458 | info.notfound = !!(infobits[8] & 0x10); |
| 459 | info.pblf = !!(infobits[9] & 0x20); |
| 460 | info.hamming = 0; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 461 | for (a = 0; a <= 7; a++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | { |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 463 | if (infobits[a] & 0xf0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | { |
| 465 | info.hamming = 1; |
| 466 | break; |
| 467 | } |
| 468 | } |
| 469 | if (t->vdau[req->pgbuf].clrfound) |
| 470 | info.notfound = 1; |
| 471 | if(copy_to_user(req->buffer, &info, sizeof(vtx_pageinfo_t))) |
| 472 | return -EFAULT; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 473 | if (!info.hamming && !info.notfound) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | { |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 475 | t->is_searching[req->pgbuf] = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | } |
| 477 | return 0; |
| 478 | } |
| 479 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 480 | case VTXIOCGETPAGE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | { |
| 482 | vtx_pagereq_t *req = arg; |
| 483 | int start, end; |
| 484 | |
| 485 | if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS || req->start < 0 || |
| 486 | req->start > req->end || req->end >= (virtual_mode ? VTX_VIRTUALSIZE : VTX_PAGESIZE)) |
| 487 | return -EINVAL; |
| 488 | if(copy_to_user(req->buffer, &t->vdau[req->pgbuf].pgbuf[req->start], req->end - req->start + 1)) |
| 489 | return -EFAULT; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 490 | |
| 491 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | * Always read the time directly from SAA5249 |
| 493 | */ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 494 | |
| 495 | if (req->start <= 39 && req->end >= 32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | { |
| 497 | int len; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 498 | char buf[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | start = max(req->start, 32); |
| 500 | end = min(req->end, 39); |
| 501 | len=end-start+1; |
| 502 | if (i2c_senddata(t, 8, 0, 0, start, -1) || |
| 503 | i2c_getdata(t, len, buf)) |
| 504 | return -EIO; |
| 505 | if(copy_to_user(req->buffer+start-req->start, buf, len)) |
| 506 | return -EFAULT; |
| 507 | } |
| 508 | /* Insert the current header if DAU is still searching for a page */ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 509 | if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | { |
| 511 | char buf[32]; |
| 512 | int len; |
| 513 | start = max(req->start, 7); |
| 514 | end = min(req->end, 31); |
| 515 | len=end-start+1; |
| 516 | if (i2c_senddata(t, 8, 0, 0, start, -1) || |
| 517 | i2c_getdata(t, len, buf)) |
| 518 | return -EIO; |
| 519 | if(copy_to_user(req->buffer+start-req->start, buf, len)) |
| 520 | return -EFAULT; |
| 521 | } |
| 522 | return 0; |
| 523 | } |
| 524 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 525 | case VTXIOCSTOPDAU: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | { |
| 527 | vtx_pagereq_t *req = arg; |
| 528 | |
| 529 | if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) |
| 530 | return -EINVAL; |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 531 | t->vdau[req->pgbuf].stopped = true; |
| 532 | t->is_searching[req->pgbuf] = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | return 0; |
| 534 | } |
| 535 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 536 | case VTXIOCPUTPAGE: |
| 537 | case VTXIOCSETDISP: |
| 538 | case VTXIOCPUTSTAT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | return 0; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 540 | |
| 541 | case VTXIOCCLRCACHE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | { |
| 543 | if (i2c_senddata(t, 0, NUM_DAUS, 0, 8, -1) || i2c_senddata(t, 11, |
| 544 | ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', |
| 545 | ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', -1)) |
| 546 | return -EIO; |
| 547 | if (i2c_senddata(t, 3, 0x20, -1)) |
| 548 | return -EIO; |
| 549 | jdelay(10 * CLEAR_DELAY); /* I have no idea how long we have to wait here */ |
| 550 | return 0; |
| 551 | } |
| 552 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 553 | case VTXIOCSETVIRT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | { |
| 555 | /* The SAA5249 has virtual-row reception turned on always */ |
| 556 | t->virtual_mode = (int)(long)arg; |
| 557 | return 0; |
| 558 | } |
| 559 | } |
| 560 | return -EINVAL; |
| 561 | } |
| 562 | |
| 563 | /* |
| 564 | * Translates old vtx IOCTLs to new ones |
| 565 | * |
| 566 | * This keeps new kernel versions compatible with old userspace programs. |
| 567 | */ |
| 568 | static inline unsigned int vtx_fix_command(unsigned int cmd) |
| 569 | { |
| 570 | switch (cmd) { |
| 571 | case VTXIOCGETINFO_OLD: |
| 572 | cmd = VTXIOCGETINFO; |
| 573 | break; |
| 574 | case VTXIOCCLRPAGE_OLD: |
| 575 | cmd = VTXIOCCLRPAGE; |
| 576 | break; |
| 577 | case VTXIOCCLRFOUND_OLD: |
| 578 | cmd = VTXIOCCLRFOUND; |
| 579 | break; |
| 580 | case VTXIOCPAGEREQ_OLD: |
| 581 | cmd = VTXIOCPAGEREQ; |
| 582 | break; |
| 583 | case VTXIOCGETSTAT_OLD: |
| 584 | cmd = VTXIOCGETSTAT; |
| 585 | break; |
| 586 | case VTXIOCGETPAGE_OLD: |
| 587 | cmd = VTXIOCGETPAGE; |
| 588 | break; |
| 589 | case VTXIOCSTOPDAU_OLD: |
| 590 | cmd = VTXIOCSTOPDAU; |
| 591 | break; |
| 592 | case VTXIOCPUTPAGE_OLD: |
| 593 | cmd = VTXIOCPUTPAGE; |
| 594 | break; |
| 595 | case VTXIOCSETDISP_OLD: |
| 596 | cmd = VTXIOCSETDISP; |
| 597 | break; |
| 598 | case VTXIOCPUTSTAT_OLD: |
| 599 | cmd = VTXIOCPUTSTAT; |
| 600 | break; |
| 601 | case VTXIOCCLRCACHE_OLD: |
| 602 | cmd = VTXIOCCLRCACHE; |
| 603 | break; |
| 604 | case VTXIOCSETVIRT_OLD: |
| 605 | cmd = VTXIOCSETVIRT; |
| 606 | break; |
| 607 | } |
| 608 | return cmd; |
| 609 | } |
| 610 | |
| 611 | /* |
| 612 | * Handle the locking |
| 613 | */ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 614 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | static int saa5249_ioctl(struct inode *inode, struct file *file, |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 616 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | { |
| 618 | struct video_device *vd = video_devdata(file); |
| 619 | struct saa5249_device *t=vd->priv; |
| 620 | int err; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 621 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | cmd = vtx_fix_command(cmd); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 623 | mutex_lock(&t->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 625 | mutex_unlock(&t->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | return err; |
| 627 | } |
| 628 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 629 | static int saa5249_open(struct inode *inode, struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | { |
| 631 | struct video_device *vd = video_devdata(file); |
| 632 | struct saa5249_device *t=vd->priv; |
| 633 | int err,pgbuf; |
| 634 | |
| 635 | err = video_exclusive_open(inode,file); |
| 636 | if (err < 0) |
| 637 | return err; |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 638 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | if (t->client==NULL) { |
| 640 | err = -ENODEV; |
| 641 | goto fail; |
| 642 | } |
| 643 | |
| 644 | if (i2c_senddata(t, 0, 0, -1) || /* Select R11 */ |
| 645 | /* Turn off parity checks (we do this ourselves) */ |
| 646 | i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) || |
| 647 | /* Display TV-picture, no virtual rows */ |
| 648 | i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */ |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 649 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | { |
| 651 | err = -EIO; |
| 652 | goto fail; |
| 653 | } |
| 654 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 655 | for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | { |
| 657 | memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); |
| 658 | memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); |
| 659 | memset(t->vdau[pgbuf].laststat, 0, sizeof(t->vdau[0].laststat)); |
| 660 | t->vdau[pgbuf].expire = 0; |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 661 | t->vdau[pgbuf].clrfound = true; |
| 662 | t->vdau[pgbuf].stopped = true; |
| 663 | t->is_searching[pgbuf] = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | } |
Richard Knutsson | e8be02a | 2007-02-06 21:52:04 -0300 | [diff] [blame] | 665 | t->virtual_mode = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | return 0; |
| 667 | |
| 668 | fail: |
| 669 | video_exclusive_release(inode,file); |
| 670 | return err; |
| 671 | } |
| 672 | |
| 673 | |
| 674 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 675 | static int saa5249_release(struct inode *inode, struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | { |
| 677 | struct video_device *vd = video_devdata(file); |
| 678 | struct saa5249_device *t=vd->priv; |
| 679 | i2c_senddata(t, 1, 0x20, -1); /* Turn off CCT */ |
| 680 | i2c_senddata(t, 5, 3, 3, -1); /* Turn off TV-display */ |
| 681 | video_exclusive_release(inode,file); |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | static int __init init_saa_5249 (void) |
| 686 | { |
| 687 | printk(KERN_INFO "SAA5249 driver (" IF_NAME " interface) for VideoText version %d.%d\n", |
| 688 | VTX_VER_MAJ, VTX_VER_MIN); |
| 689 | return i2c_add_driver(&i2c_driver_videotext); |
| 690 | } |
| 691 | |
Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 692 | static void __exit cleanup_saa_5249 (void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | { |
| 694 | i2c_del_driver(&i2c_driver_videotext); |
| 695 | } |
| 696 | |
| 697 | module_init(init_saa_5249); |
| 698 | module_exit(cleanup_saa_5249); |
| 699 | |
Arjan van de Ven | fa027c2 | 2007-02-12 00:55:33 -0800 | [diff] [blame] | 700 | static const struct file_operations saa_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | .owner = THIS_MODULE, |
| 702 | .open = saa5249_open, |
| 703 | .release = saa5249_release, |
| 704 | .ioctl = saa5249_ioctl, |
Douglas Schilling Landgraf | 078ff79 | 2008-04-22 14:46:11 -0300 | [diff] [blame] | 705 | #ifdef CONFIG_COMPAT |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 706 | .compat_ioctl = v4l_compat_ioctl32, |
Douglas Schilling Landgraf | 078ff79 | 2008-04-22 14:46:11 -0300 | [diff] [blame] | 707 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | .llseek = no_llseek, |
| 709 | }; |
| 710 | |
| 711 | static struct video_device saa_template = |
| 712 | { |
| 713 | .owner = THIS_MODULE, |
| 714 | .name = IF_NAME, |
| 715 | .type = VID_TYPE_TELETEXT, /*| VID_TYPE_TUNER ?? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | .fops = &saa_fops, |
| 717 | }; |
| 718 | |
| 719 | MODULE_LICENSE("GPL"); |