]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | * | |
d9b01449 | 11 | * Alan Cox <alan@lxorguk.ukuu.org.uk> |
1da177e4 LT |
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 | * | |
1da177e4 LT |
18 | * Derived From |
19 | * | |
20 | * vtx.c: | |
21 | * This is a loadable character-device-driver for videotext-interfaces | |
22 | * (aka teletext). Please check the Makefile/README for a list of supported | |
23 | * interfaces. | |
24 | * | |
25 | * Copyright (c) 1994-97 Martin Buck <martin-2.buck@student.uni-ulm.de> | |
26 | * | |
27 | * | |
28 | * This program is free software; you can redistribute it and/or modify | |
29 | * it under the terms of the GNU General Public License as published by | |
30 | * the Free Software Foundation; either version 2 of the License, or | |
31 | * (at your option) any later version. | |
32 | * | |
33 | * This program is distributed in the hope that it will be useful, | |
34 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
35 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
36 | * GNU General Public License for more details. | |
37 | * | |
38 | * You should have received a copy of the GNU General Public License | |
39 | * along with this program; if not, write to the Free Software | |
40 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
41 | * USA. | |
42 | */ | |
43 | ||
44 | #include <linux/module.h> | |
45 | #include <linux/kernel.h> | |
1da177e4 | 46 | #include <linux/mm.h> |
1da177e4 | 47 | #include <linux/init.h> |
1da177e4 | 48 | #include <linux/i2c.h> |
96af9880 | 49 | #include <linux/mutex.h> |
d4f59de4 | 50 | #include <linux/delay.h> |
1da177e4 | 51 | #include <linux/videotext.h> |
1b8dac15 | 52 | #include <linux/videodev2.h> |
5a0e3ad6 | 53 | #include <linux/slab.h> |
1b8dac15 HV |
54 | #include <media/v4l2-device.h> |
55 | #include <media/v4l2-chip-ident.h> | |
35ea11ff | 56 | #include <media/v4l2-ioctl.h> |
1b8dac15 | 57 | #include <media/v4l2-i2c-drv.h> |
1da177e4 | 58 | |
96af9880 HV |
59 | MODULE_AUTHOR("Michael Geng <linux@MichaelGeng.de>"); |
60 | MODULE_DESCRIPTION("Philips SAA5249 Teletext decoder driver"); | |
61 | MODULE_LICENSE("GPL"); | |
1da177e4 | 62 | |
1b8dac15 | 63 | |
1da177e4 LT |
64 | #define VTX_VER_MAJ 1 |
65 | #define VTX_VER_MIN 8 | |
66 | ||
67 | ||
1da177e4 LT |
68 | #define NUM_DAUS 4 |
69 | #define NUM_BUFS 8 | |
1da177e4 | 70 | |
d56410e0 | 71 | static const int disp_modes[8][3] = |
1da177e4 LT |
72 | { |
73 | { 0x46, 0x03, 0x03 }, /* DISPOFF */ | |
74 | { 0x46, 0xcc, 0xcc }, /* DISPNORM */ | |
75 | { 0x44, 0x0f, 0x0f }, /* DISPTRANS */ | |
76 | { 0x46, 0xcc, 0x46 }, /* DISPINS */ | |
77 | { 0x44, 0x03, 0x03 }, /* DISPOFF, interlaced */ | |
78 | { 0x44, 0xcc, 0xcc }, /* DISPNORM, interlaced */ | |
79 | { 0x44, 0x0f, 0x0f }, /* DISPTRANS, interlaced */ | |
80 | { 0x44, 0xcc, 0x46 } /* DISPINS, interlaced */ | |
81 | }; | |
82 | ||
83 | ||
84 | ||
09df5cbe | 85 | #define PAGE_WAIT msecs_to_jiffies(300) /* Time between requesting page and */ |
1da177e4 | 86 | /* checking status bits */ |
09df5cbe | 87 | #define PGBUF_EXPIRE msecs_to_jiffies(15000) /* Time to wait before retransmitting */ |
1da177e4 LT |
88 | /* page regardless of infobits */ |
89 | typedef struct { | |
90 | u8 pgbuf[VTX_VIRTUALSIZE]; /* Page-buffer */ | |
91 | u8 laststat[10]; /* Last value of infobits for DAU */ | |
92 | u8 sregs[7]; /* Page-request registers */ | |
93 | unsigned long expire; /* Time when page will be expired */ | |
94 | unsigned clrfound : 1; /* VTXIOCCLRFOUND has been called */ | |
95 | unsigned stopped : 1; /* VTXIOCSTOPDAU has been called */ | |
96 | } vdau_t; | |
97 | ||
98 | struct saa5249_device | |
99 | { | |
1b8dac15 HV |
100 | struct v4l2_subdev sd; |
101 | struct video_device *vdev; | |
1da177e4 LT |
102 | vdau_t vdau[NUM_DAUS]; /* Data for virtual DAUs (the 5249 only has one */ |
103 | /* real DAU, so we have to simulate some more) */ | |
104 | int vtx_use_count; | |
105 | int is_searching[NUM_DAUS]; | |
106 | int disp_mode; | |
107 | int virtual_mode; | |
7d43cd53 | 108 | unsigned long in_use; |
3593cab5 | 109 | struct mutex lock; |
1da177e4 LT |
110 | }; |
111 | ||
1b8dac15 HV |
112 | static inline struct saa5249_device *to_dev(struct v4l2_subdev *sd) |
113 | { | |
114 | return container_of(sd, struct saa5249_device, sd); | |
115 | } | |
116 | ||
1da177e4 LT |
117 | |
118 |