~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/drivers/media/video/saa5249.c

Version: ~ [ 2.2.5 ] ~ [ 2.4.1 ] ~ [ 2.4.9 ] ~ [ 2.6.17.10 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.