V4L/DVB (8786): v4l2: remove the priv field, use dev_get_drvdata instead
[linux-2.6/mini2440.git] / drivers / media / video / saa5246a.c
blob0178b49da0c18639a0cb7fa0e4d16c547f1810f3
1 /*
2 * Driver for the SAA5246A or SAA5281 Teletext (=Videotext) decoder chips from
3 * Philips.
5 * Only capturing of Teletext pages is tested. The videotext chips also have a
6 * TV output but my hardware doesn't use it. For this reason this driver does
7 * not support changing any TV display settings.
9 * Copyright (C) 2004 Michael Geng <linux@MichaelGeng.de>
11 * Derived from
13 * saa5249 driver
14 * Copyright (C) 1998 Richard Guenther
15 * <richard.guenther@student.uni-tuebingen.de>
17 * with changes by
18 * Alan Cox <Alan.Cox@linux.org>
20 * and
22 * vtx.c
23 * Copyright (C) 1994-97 Martin Buck <martin-2.buck@student.uni-ulm.de>
25 * This program is free software; you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation; either version 2 of the License, or
28 * (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
38 * USA.
41 #include <linux/module.h>
42 #include <linux/kernel.h>
43 #include <linux/mm.h>
44 #include <linux/init.h>
45 #include <linux/i2c.h>
46 #include <linux/videotext.h>
47 #include <linux/smp_lock.h>
48 #include <linux/videodev.h>
49 #include <media/v4l2-common.h>
50 #include <media/v4l2-ioctl.h>
51 #include <linux/mutex.h>
53 #include "saa5246a.h"
55 MODULE_AUTHOR("Michael Geng <linux@MichaelGeng.de>");
56 MODULE_DESCRIPTION("Philips SAA5246A, SAA5281 Teletext decoder driver");
57 MODULE_LICENSE("GPL");
59 struct saa5246a_device
61 u8 pgbuf[NUM_DAUS][VTX_VIRTUALSIZE];
62 int is_searching[NUM_DAUS];
63 struct i2c_client *client;
64 unsigned long in_use;
65 struct mutex lock;
68 static struct video_device saa_template; /* Declared near bottom */
70 /* Addresses to scan */
71 static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END };
73 I2C_CLIENT_INSMOD;
75 static struct i2c_client client_template;
77 static int saa5246a_attach(struct i2c_adapter *adap, int addr, int kind)
79 int pgbuf;
80 int err;
81 struct i2c_client *client;
82 struct video_device *vd;
83 struct saa5246a_device *t;
85 printk(KERN_INFO "saa5246a: teletext chip found.\n");
86 client=kmalloc(sizeof(*client), GFP_KERNEL);
87 if(client==NULL)
88 return -ENOMEM;
89 client_template.adapter = adap;
90 client_template.addr = addr;
91 memcpy(client, &client_template, sizeof(*client));
92 t = kzalloc(sizeof(*t), GFP_KERNEL);
93 if(t==NULL)
95 kfree(client);
96 return -ENOMEM;
98 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
99 mutex_init(&t->lock);
102 * Now create a video4linux device
105 vd = video_device_alloc();
106 if(vd==NULL)
108 kfree(t);
109 kfree(client);
110 return -ENOMEM;
112 i2c_set_clientdata(client, vd);
113 memcpy(vd, &saa_template, sizeof(*vd));
115 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
117 memset(t->pgbuf[pgbuf], ' ', sizeof(t->pgbuf[0]));
118 t->is_searching[pgbuf] = false;
120 video_set_drvdata(vd, t);
124 * Register it
127 if((err=video_register_device(vd, VFL_TYPE_VTX,-1))<0)
129 kfree(t);
130 kfree(client);
131 video_device_release(vd);
132 return err;
134 t->client = client;
135 i2c_attach_client(client);
136 return 0;
140 * We do most of the hard work when we become a device on the i2c.
142 static int saa5246a_probe(struct i2c_adapter *adap)
144 if (adap->class & I2C_CLASS_TV_ANALOG)
145 return i2c_probe(adap, &addr_data, saa5246a_attach);
146 return 0;
149 static int saa5246a_detach(struct i2c_client *client)
151 struct video_device *vd = i2c_get_clientdata(client);
152 i2c_detach_client(client);
153 video_unregister_device(vd);
154 kfree(video_get_drvdata(vd));
155 kfree(client);
156 return 0;
160 * I2C interfaces
163 static struct i2c_driver i2c_driver_videotext =
165 .driver = {
166 .name = IF_NAME, /* name */
168 .id = I2C_DRIVERID_SAA5249, /* in i2c.h */
169 .attach_adapter = saa5246a_probe,
170 .detach_client = saa5246a_detach,
173 static struct i2c_client client_template = {
174 .driver = &i2c_driver_videotext,
175 .name = "(unset)",
178 static int i2c_sendbuf(struct saa5246a_device *t, int reg, int count, u8 *data)
180 char buf[64];
182 buf[0] = reg;
183 memcpy(buf+1, data, count);
185 if(i2c_master_send(t->client, buf, count+1)==count+1)
186 return 0;
187 return -1;
190 static int i2c_senddata(struct saa5246a_device *t, ...)
192 unsigned char buf[64];
193 int v;
194 int ct = 0;
195 va_list argp;
196 va_start(argp, t);
198 while ((v = va_arg(argp, int)) != -1)
199 buf[ct++] = v;
201 va_end(argp);
202 return i2c_sendbuf(t, buf[0], ct-1, buf+1);
205 /* Get count number of bytes from I²C-device at address adr, store them in buf.
206 * Start & stop handshaking is done by this routine, ack will be sent after the
207 * last byte to inhibit further sending of data. If uaccess is 'true', data is
208 * written to user-space with put_user. Returns -1 if I²C-device didn't send
209 * acknowledge, 0 otherwise
211 static int i2c_getdata(struct saa5246a_device *t, int count, u8 *buf)
213 if(i2c_master_recv(t->client, buf, count)!=count)
214 return -1;
215 return 0;
218 /* When a page is found then the not FOUND bit in one of the status registers
219 * of the SAA5264A chip is cleared. Unfortunately this bit is not set
220 * automatically when a new page is requested. Instead this function must be
221 * called after a page has been requested.
223 * Return value: 0 if successful
225 static int saa5246a_clear_found_bit(struct saa5246a_device *t,
226 unsigned char dau_no)
228 unsigned char row_25_column_8;
230 if (i2c_senddata(t, SAA5246A_REGISTER_R8,
232 dau_no |
233 R8_DO_NOT_CLEAR_MEMORY,
235 R9_CURSER_ROW_25,
237 R10_CURSER_COLUMN_8,
239 COMMAND_END) ||
240 i2c_getdata(t, 1, &row_25_column_8))
242 return -EIO;
244 row_25_column_8 |= ROW25_COLUMN8_PAGE_NOT_FOUND;
245 if (i2c_senddata(t, SAA5246A_REGISTER_R8,
247 dau_no |
248 R8_DO_NOT_CLEAR_MEMORY,
250 R9_CURSER_ROW_25,
252 R10_CURSER_COLUMN_8,
254 row_25_column_8,
256 COMMAND_END))
258 return -EIO;
261 return 0;
264 /* Requests one videotext page as described in req. The fields of req are
265 * checked and an error is returned if something is invalid.
267 * Return value: 0 if successful
269 static int saa5246a_request_page(struct saa5246a_device *t,
270 vtx_pagereq_t *req)
272 if (req->pagemask < 0 || req->pagemask >= PGMASK_MAX)
273 return -EINVAL;
274 if (req->pagemask & PGMASK_PAGE)
275 if (req->page < 0 || req->page > PAGE_MAX)
276 return -EINVAL;
277 if (req->pagemask & PGMASK_HOUR)
278 if (req->hour < 0 || req->hour > HOUR_MAX)
279 return -EINVAL;
280 if (req->pagemask & PGMASK_MINUTE)
281 if (req->minute < 0 || req->minute > MINUTE_MAX)
282 return -EINVAL;
283 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
284 return -EINVAL;
286 if (i2c_senddata(t, SAA5246A_REGISTER_R2,
288 R2_IN_R3_SELECT_PAGE_HUNDREDS |
289 req->pgbuf << 4 |
290 R2_BANK_0 |
291 R2_HAMMING_CHECK_OFF,
293 HUNDREDS_OF_PAGE(req->page) |
294 R3_HOLD_PAGE |
295 (req->pagemask & PG_HUND ?
296 R3_PAGE_HUNDREDS_DO_CARE :
297 R3_PAGE_HUNDREDS_DO_NOT_CARE),
299 TENS_OF_PAGE(req->page) |
300 (req->pagemask & PG_TEN ?
301 R3_PAGE_TENS_DO_CARE :
302 R3_PAGE_TENS_DO_NOT_CARE),
304 UNITS_OF_PAGE(req->page) |
305 (req->pagemask & PG_UNIT ?
306 R3_PAGE_UNITS_DO_CARE :
307 R3_PAGE_UNITS_DO_NOT_CARE),
309 TENS_OF_HOUR(req->hour) |
310 (req->pagemask & HR_TEN ?
311 R3_HOURS_TENS_DO_CARE :
312 R3_HOURS_TENS_DO_NOT_CARE),
314 UNITS_OF_HOUR(req->hour) |
315 (req->pagemask & HR_UNIT ?
316 R3_HOURS_UNITS_DO_CARE :
317 R3_HOURS_UNITS_DO_NOT_CARE),
319 TENS_OF_MINUTE(req->minute) |
320 (req->pagemask & MIN_TEN ?
321 R3_MINUTES_TENS_DO_CARE :
322 R3_MINUTES_TENS_DO_NOT_CARE),
324 UNITS_OF_MINUTE(req->minute) |
325 (req->pagemask & MIN_UNIT ?
326 R3_MINUTES_UNITS_DO_CARE :
327 R3_MINUTES_UNITS_DO_NOT_CARE),
329 COMMAND_END) || i2c_senddata(t, SAA5246A_REGISTER_R2,
331 R2_IN_R3_SELECT_PAGE_HUNDREDS |
332 req->pgbuf << 4 |
333 R2_BANK_0 |
334 R2_HAMMING_CHECK_OFF,
336 HUNDREDS_OF_PAGE(req->page) |
337 R3_UPDATE_PAGE |
338 (req->pagemask & PG_HUND ?
339 R3_PAGE_HUNDREDS_DO_CARE :
340 R3_PAGE_HUNDREDS_DO_NOT_CARE),
342 COMMAND_END))
344 return -EIO;
347 t->is_searching[req->pgbuf] = true;
348 return 0;
351 /* This routine decodes the page number from the infobits contained in line 25.
353 * Parameters:
354 * infobits: must be bits 0 to 9 of column 25
356 * Return value: page number coded in hexadecimal, i. e. page 123 is coded 0x123
358 static inline int saa5246a_extract_pagenum_from_infobits(
359 unsigned char infobits[10])
361 int page_hundreds, page_tens, page_units;
363 page_units = infobits[0] & ROW25_COLUMN0_PAGE_UNITS;
364 page_tens = infobits[1] & ROW25_COLUMN1_PAGE_TENS;
365 page_hundreds = infobits[8] & ROW25_COLUMN8_PAGE_HUNDREDS;
367 /* page 0x.. means page 8.. */
368 if (page_hundreds == 0)
369 page_hundreds = 8;
371 return((page_hundreds << 8) | (page_tens << 4) | page_units);
374 /* Decodes the hour from the infobits contained in line 25.
376 * Parameters:
377 * infobits: must be bits 0 to 9 of column 25
379 * Return: hour coded in hexadecimal, i. e. 12h is coded 0x12
381 static inline int saa5246a_extract_hour_from_infobits(
382 unsigned char infobits[10])
384 int hour_tens, hour_units;
386 hour_units = infobits[4] & ROW25_COLUMN4_HOUR_UNITS;
387 hour_tens = infobits[5] & ROW25_COLUMN5_HOUR_TENS;
389 return((hour_tens << 4) | hour_units);
392 /* Decodes the minutes from the infobits contained in line 25.
394 * Parameters:
395 * infobits: must be bits 0 to 9 of column 25
397 * Return: minutes coded in hexadecimal, i. e. 10min is coded 0x10
399 static inline int saa5246a_extract_minutes_from_infobits(
400 unsigned char infobits[10])
402 int minutes_tens, minutes_units;
404 minutes_units = infobits[2] & ROW25_COLUMN2_MINUTES_UNITS;
405 minutes_tens = infobits[3] & ROW25_COLUMN3_MINUTES_TENS;
407 return((minutes_tens << 4) | minutes_units);
410 /* Reads the status bits contained in the first 10 columns of the first line
411 * and extracts the information into info.
413 * Return value: 0 if successful
415 static inline int saa5246a_get_status(struct saa5246a_device *t,
416 vtx_pageinfo_t *info, unsigned char dau_no)
418 unsigned char infobits[10];
419 int column;
421 if (dau_no >= NUM_DAUS)
422 return -EINVAL;
424 if (i2c_senddata(t, SAA5246A_REGISTER_R8,
426 dau_no |
427 R8_DO_NOT_CLEAR_MEMORY,
429 R9_CURSER_ROW_25,
431 R10_CURSER_COLUMN_0,
433 COMMAND_END) ||
434 i2c_getdata(t, 10, infobits))
436 return -EIO;
439 info->pagenum = saa5246a_extract_pagenum_from_infobits(infobits);
440 info->hour = saa5246a_extract_hour_from_infobits(infobits);
441 info->minute = saa5246a_extract_minutes_from_infobits(infobits);
442 info->charset = ((infobits[7] & ROW25_COLUMN7_CHARACTER_SET) >> 1);
443 info->delete = !!(infobits[3] & ROW25_COLUMN3_DELETE_PAGE);
444 info->headline = !!(infobits[5] & ROW25_COLUMN5_INSERT_HEADLINE);
445 info->subtitle = !!(infobits[5] & ROW25_COLUMN5_INSERT_SUBTITLE);
446 info->supp_header = !!(infobits[6] & ROW25_COLUMN6_SUPPRESS_HEADER);
447 info->update = !!(infobits[6] & ROW25_COLUMN6_UPDATE_PAGE);
448 info->inter_seq = !!(infobits[6] & ROW25_COLUMN6_INTERRUPTED_SEQUENCE);
449 info->dis_disp = !!(infobits[6] & ROW25_COLUMN6_SUPPRESS_DISPLAY);
450 info->serial = !!(infobits[7] & ROW25_COLUMN7_SERIAL_MODE);
451 info->notfound = !!(infobits[8] & ROW25_COLUMN8_PAGE_NOT_FOUND);
452 info->pblf = !!(infobits[9] & ROW25_COLUMN9_PAGE_BEING_LOOKED_FOR);
453 info->hamming = 0;
454 for (column = 0; column <= 7; column++) {
455 if (infobits[column] & ROW25_COLUMN0_TO_7_HAMMING_ERROR) {
456 info->hamming = 1;
457 break;
460 if (!info->hamming && !info->notfound)
461 t->is_searching[dau_no] = false;
462 return 0;
465 /* Reads 1 videotext page buffer of the SAA5246A.
467 * req is used both as input and as output. It contains information which part
468 * must be read. The videotext page is copied into req->buffer.
470 * Return value: 0 if successful
472 static inline int saa5246a_get_page(struct saa5246a_device *t,
473 vtx_pagereq_t *req)
475 int start, end, size;
476 char *buf;
477 int err;
479 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS ||
480 req->start < 0 || req->start > req->end || req->end >= VTX_PAGESIZE)
481 return -EINVAL;
483 buf = kmalloc(VTX_PAGESIZE, GFP_KERNEL);
484 if (!buf)
485 return -ENOMEM;
487 /* Read "normal" part of page */
488 err = -EIO;
490 end = min(req->end, VTX_PAGESIZE - 1);
491 if (i2c_senddata(t, SAA5246A_REGISTER_R8,
492 req->pgbuf | R8_DO_NOT_CLEAR_MEMORY,
493 ROW(req->start), COLUMN(req->start), COMMAND_END))
494 goto out;
495 if (i2c_getdata(t, end - req->start + 1, buf))
496 goto out;
497 err = -EFAULT;
498 if (copy_to_user(req->buffer, buf, end - req->start + 1))
499 goto out;
501 /* Always get the time from buffer 4, since this stupid SAA5246A only
502 * updates the currently displayed buffer...
504 if (REQ_CONTAINS_TIME(req)) {
505 start = max(req->start, POS_TIME_START);
506 end = min(req->end, POS_TIME_END);
507 size = end - start + 1;
508 err = -EINVAL;
509 if (size < 0)
510 goto out;
511 err = -EIO;
512 if (i2c_senddata(t, SAA5246A_REGISTER_R8,
513 R8_ACTIVE_CHAPTER_4 | R8_DO_NOT_CLEAR_MEMORY,
514 R9_CURSER_ROW_0, start, COMMAND_END))
515 goto out;
516 if (i2c_getdata(t, size, buf))
517 goto out;
518 err = -EFAULT;
519 if (copy_to_user(req->buffer + start - req->start, buf, size))
520 goto out;
522 /* Insert the header from buffer 4 only, if acquisition circuit is still searching for a page */
523 if (REQ_CONTAINS_HEADER(req) && t->is_searching[req->pgbuf]) {
524 start = max(req->start, POS_HEADER_START);
525 end = min(req->end, POS_HEADER_END);
526 size = end - start + 1;
527 err = -EINVAL;
528 if (size < 0)
529 goto out;
530 err = -EIO;
531 if (i2c_senddata(t, SAA5246A_REGISTER_R8,
532 R8_ACTIVE_CHAPTER_4 | R8_DO_NOT_CLEAR_MEMORY,
533 R9_CURSER_ROW_0, start, COMMAND_END))
534 goto out;
535 if (i2c_getdata(t, end - start + 1, buf))
536 goto out;
537 err = -EFAULT;
538 if (copy_to_user(req->buffer + start - req->start, buf, size))
539 goto out;
541 err = 0;
542 out:
543 kfree(buf);
544 return err;
547 /* Stops the acquisition circuit given in dau_no. The page buffer associated
548 * with this acquisition circuit will no more be updated. The other daus are
549 * not affected.
551 * Return value: 0 if successful
553 static inline int saa5246a_stop_dau(struct saa5246a_device *t,
554 unsigned char dau_no)
556 if (dau_no >= NUM_DAUS)
557 return -EINVAL;
558 if (i2c_senddata(t, SAA5246A_REGISTER_R2,
560 R2_IN_R3_SELECT_PAGE_HUNDREDS |
561 dau_no << 4 |
562 R2_BANK_0 |
563 R2_HAMMING_CHECK_OFF,
565 R3_PAGE_HUNDREDS_0 |
566 R3_HOLD_PAGE |
567 R3_PAGE_HUNDREDS_DO_NOT_CARE,
569 COMMAND_END))
571 return -EIO;
573 t->is_searching[dau_no] = false;
574 return 0;
577 /* Handles ioctls defined in videotext.h
579 * Returns 0 if successful
581 static int do_saa5246a_ioctl(struct inode *inode, struct file *file,
582 unsigned int cmd, void *arg)
584 struct video_device *vd = video_devdata(file);
585 struct saa5246a_device *t = video_get_drvdata(vd);
587 switch(cmd)
589 case VTXIOCGETINFO:
591 vtx_info_t *info = arg;
593 info->version_major = MAJOR_VERSION;
594 info->version_minor = MINOR_VERSION;
595 info->numpages = NUM_DAUS;
596 return 0;
599 case VTXIOCCLRPAGE:
601 vtx_pagereq_t *req = arg;
603 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
604 return -EINVAL;
605 memset(t->pgbuf[req->pgbuf], ' ', sizeof(t->pgbuf[0]));
606 return 0;
609 case VTXIOCCLRFOUND:
611 vtx_pagereq_t *req = arg;
613 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
614 return -EINVAL;
615 return(saa5246a_clear_found_bit(t, req->pgbuf));
618 case VTXIOCPAGEREQ:
620 vtx_pagereq_t *req = arg;
622 return(saa5246a_request_page(t, req));
625 case VTXIOCGETSTAT:
627 vtx_pagereq_t *req = arg;
628 vtx_pageinfo_t info;
629 int rval;
631 if ((rval = saa5246a_get_status(t, &info, req->pgbuf)))
632 return rval;
633 if(copy_to_user(req->buffer, &info,
634 sizeof(vtx_pageinfo_t)))
635 return -EFAULT;
636 return 0;
639 case VTXIOCGETPAGE:
641 vtx_pagereq_t *req = arg;
643 return(saa5246a_get_page(t, req));
646 case VTXIOCSTOPDAU:
648 vtx_pagereq_t *req = arg;
650 return(saa5246a_stop_dau(t, req->pgbuf));
653 case VTXIOCPUTPAGE:
654 case VTXIOCSETDISP:
655 case VTXIOCPUTSTAT:
656 return 0;
658 case VTXIOCCLRCACHE:
660 return 0;
663 case VTXIOCSETVIRT:
665 /* I do not know what "virtual mode" means */
666 return 0;
669 return -EINVAL;
673 * Translates old vtx IOCTLs to new ones
675 * This keeps new kernel versions compatible with old userspace programs.
677 static inline unsigned int vtx_fix_command(unsigned int cmd)
679 switch (cmd) {
680 case VTXIOCGETINFO_OLD:
681 cmd = VTXIOCGETINFO;
682 break;
683 case VTXIOCCLRPAGE_OLD:
684 cmd = VTXIOCCLRPAGE;
685 break;
686 case VTXIOCCLRFOUND_OLD:
687 cmd = VTXIOCCLRFOUND;
688 break;
689 case VTXIOCPAGEREQ_OLD:
690 cmd = VTXIOCPAGEREQ;
691 break;
692 case VTXIOCGETSTAT_OLD:
693 cmd = VTXIOCGETSTAT;
694 break;
695 case VTXIOCGETPAGE_OLD:
696 cmd = VTXIOCGETPAGE;
697 break;
698 case VTXIOCSTOPDAU_OLD:
699 cmd = VTXIOCSTOPDAU;
700 break;
701 case VTXIOCPUTPAGE_OLD:
702 cmd = VTXIOCPUTPAGE;
703 break;
704 case VTXIOCSETDISP_OLD:
705 cmd = VTXIOCSETDISP;
706 break;
707 case VTXIOCPUTSTAT_OLD:
708 cmd = VTXIOCPUTSTAT;
709 break;
710 case VTXIOCCLRCACHE_OLD:
711 cmd = VTXIOCCLRCACHE;
712 break;
713 case VTXIOCSETVIRT_OLD:
714 cmd = VTXIOCSETVIRT;
715 break;
717 return cmd;
721 * Handle the locking
723 static int saa5246a_ioctl(struct inode *inode, struct file *file,
724 unsigned int cmd, unsigned long arg)
726 struct video_device *vd = video_devdata(file);
727 struct saa5246a_device *t = video_get_drvdata(vd);
728 int err;
730 cmd = vtx_fix_command(cmd);
731 mutex_lock(&t->lock);
732 err = video_usercopy(inode, file, cmd, arg, do_saa5246a_ioctl);
733 mutex_unlock(&t->lock);
734 return err;
737 static int saa5246a_open(struct inode *inode, struct file *file)
739 struct video_device *vd = video_devdata(file);
740 struct saa5246a_device *t = video_get_drvdata(vd);
742 if (t->client == NULL)
743 return -ENODEV;
745 if (test_and_set_bit(0, &t->in_use))
746 return -EBUSY;
748 if (i2c_senddata(t, SAA5246A_REGISTER_R0,
749 R0_SELECT_R11 |
750 R0_PLL_TIME_CONSTANT_LONG |
751 R0_ENABLE_nODD_EVEN_OUTPUT |
752 R0_ENABLE_HDR_POLL |
753 R0_DO_NOT_FORCE_nODD_EVEN_LOW_IF_PICTURE_DISPLAYED |
754 R0_NO_FREE_RUN_PLL |
755 R0_NO_AUTOMATIC_FASTEXT_PROMPT,
757 R1_NON_INTERLACED_312_312_LINES |
758 R1_DEW |
759 R1_EXTENDED_PACKET_DISABLE |
760 R1_DAUS_ALL_ON |
761 R1_8_BITS_NO_PARITY |
762 R1_VCS_TO_SCS,
764 COMMAND_END) ||
765 i2c_senddata(t, SAA5246A_REGISTER_R4,
767 /* We do not care much for the TV display but nevertheless we
768 * need the currently displayed page later because only on that
769 * page the time is updated. */
770 R4_DISPLAY_PAGE_4,
772 COMMAND_END))
774 clear_bit(0, &t->in_use);
775 return -EIO;
777 return 0;
780 static int saa5246a_release(struct inode *inode, struct file *file)
782 struct video_device *vd = video_devdata(file);
783 struct saa5246a_device *t = video_get_drvdata(vd);
785 /* Stop all acquisition circuits. */
786 i2c_senddata(t, SAA5246A_REGISTER_R1,
788 R1_INTERLACED_312_AND_HALF_312_AND_HALF_LINES |
789 R1_DEW |
790 R1_EXTENDED_PACKET_DISABLE |
791 R1_DAUS_ALL_OFF |
792 R1_8_BITS_NO_PARITY |
793 R1_VCS_TO_SCS,
795 COMMAND_END);
796 clear_bit(0, &t->in_use);
797 return 0;
800 static int __init init_saa_5246a (void)
802 printk(KERN_INFO
803 "SAA5246A (or compatible) Teletext decoder driver version %d.%d\n",
804 MAJOR_VERSION, MINOR_VERSION);
805 return i2c_add_driver(&i2c_driver_videotext);
808 static void __exit cleanup_saa_5246a (void)
810 i2c_del_driver(&i2c_driver_videotext);
813 module_init(init_saa_5246a);
814 module_exit(cleanup_saa_5246a);
816 static const struct file_operations saa_fops = {
817 .owner = THIS_MODULE,
818 .open = saa5246a_open,
819 .release = saa5246a_release,
820 .ioctl = saa5246a_ioctl,
821 .llseek = no_llseek,
824 static struct video_device saa_template =
826 .name = IF_NAME,
827 .fops = &saa_fops,
828 .release = video_device_release,
829 .minor = -1,