2 bt856 - BT856A Digital Video Encoder (Rockwell Part)
4 Copyright (C) 1999 Mike Bernson <mike@mlb.org>
5 Copyright (C) 1998 Dave Perks <dperks@ibm.net>
7 Modifications for LML33/DC10plus unified driver
8 Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
10 This code was modify/ported from the saa7111 driver written
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/delay.h>
31 #include <linux/errno.h>
33 #include <linux/kernel.h>
34 #include <linux/major.h>
35 #include <linux/slab.h>
37 #include <linux/pci.h>
38 #include <linux/signal.h>
40 #include <asm/pgtable.h>
42 #include <linux/sched.h>
43 #include <asm/segment.h>
44 #include <linux/types.h>
45 #include <linux/wrapper.h>
47 #include <linux/videodev.h>
48 #include <linux/version.h>
49 #include <asm/uaccess.h>
51 #include <linux/i2c-old.h>
52 #include <linux/video_encoder.h>
54 #define DEBUG(x) x /* Debug driver */
56 /* ----------------------------------------------------------------------- */
61 unsigned char reg[128];
71 #define I2C_BT856 0x88
75 /* ----------------------------------------------------------------------- */
77 static int bt856_write(struct bt856 *dev, unsigned char subaddr,
82 LOCK_I2C_BUS(dev->bus);
85 i2c_sendbyte(dev->bus, dev->addr, I2C_DELAY);
86 i2c_sendbyte(dev->bus, subaddr, I2C_DELAY);
87 ack = i2c_sendbyte(dev->bus, data, I2C_DELAY);
88 dev->reg[subaddr] = data;
90 UNLOCK_I2C_BUS(dev->bus);
94 static int bt856_setbit(struct bt856 *dev, int subaddr, int bit, int data)
96 return bt856_write(dev, subaddr,(dev->reg[subaddr] & ~(1 << bit)) | (data ? (1 << bit) : 0));
99 /* ----------------------------------------------------------------------- */
101 static int bt856_attach(struct i2c_device *device)
103 struct bt856 *encoder;
105 /* This chip is not on the buz card but at the same address saa7185 */
106 //if (memcmp(device->bus->name, "buz", 3) == 0 || memcmp(device->bus->name, "zr36057", 6) == 0)
110 device->data = encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
112 if (encoder == NULL) {
118 memset(encoder, 0, sizeof(struct bt856));
119 strcpy(device->name, "bt856");
120 encoder->bus = device->bus;
121 encoder->addr = device->addr;
122 encoder->norm = VIDEO_MODE_NTSC;
125 DEBUG(printk(KERN_INFO "%s-bt856: attach\n", encoder->bus->name));
127 bt856_write(encoder, 0xdc, 0x18);
128 bt856_write(encoder, 0xda, 0);
129 bt856_write(encoder, 0xde, 0);
131 bt856_setbit(encoder, 0xdc, 3, 1);
132 //bt856_setbit(encoder, 0xdc, 6, 0);
133 bt856_setbit(encoder, 0xdc, 4, 1);
135 switch (encoder->norm) {
137 case VIDEO_MODE_NTSC:
138 bt856_setbit(encoder, 0xdc, 2, 0);
142 bt856_setbit(encoder, 0xdc, 2, 1);
146 bt856_setbit(encoder, 0xdc, 1, 1);
147 bt856_setbit(encoder, 0xde, 4, 0);
148 bt856_setbit(encoder, 0xde, 3, 1);
153 static int bt856_detach(struct i2c_device *device)
160 static int bt856_command(struct i2c_device *device, unsigned int cmd,
163 struct bt856 *encoder = device->data;
167 case ENCODER_GET_CAPABILITIES:
169 struct video_encoder_capability *cap = arg;
172 (KERN_INFO "%s-bt856: get capabilities\n",
173 encoder->bus->name));
177 | VIDEO_ENCODER_NTSC | VIDEO_ENCODER_CCIR;
183 case ENCODER_SET_NORM:
187 DEBUG(printk(KERN_INFO "%s-bt856: set norm %d\n",
188 encoder->bus->name, *iarg));
192 case VIDEO_MODE_NTSC:
193 bt856_setbit(encoder, 0xdc, 2, 0);
197 bt856_setbit(encoder, 0xdc, 2, 1);
198 bt856_setbit(encoder, 0xda, 0, 0);
199 //bt856_setbit(encoder, 0xda, 0, 1);
206 encoder->norm = *iarg;
210 case ENCODER_SET_INPUT:
214 DEBUG(printk(KERN_INFO "%s-bt856: set input %d\n",
215 encoder->bus->name, *iarg));
217 /* We only have video bus.
218 *iarg = 0: input is from bt819
219 *iarg = 1: input is from ZR36060 */
224 bt856_setbit(encoder, 0xde, 4, 0);
225 bt856_setbit(encoder, 0xde, 3, 1);
226 bt856_setbit(encoder, 0xdc, 3, 1);
227 bt856_setbit(encoder, 0xdc, 6, 0);
230 bt856_setbit(encoder, 0xde, 4, 0);
231 bt856_setbit(encoder, 0xde, 3, 1);
232 bt856_setbit(encoder, 0xdc, 3, 1);
233 bt856_setbit(encoder, 0xdc, 6, 1);
236 bt856_setbit(encoder, 0xdc, 3, 0);
237 bt856_setbit(encoder, 0xde, 4, 1);
246 case ENCODER_SET_OUTPUT:
250 DEBUG(printk(KERN_INFO "%s-bt856: set output %d\n",
251 encoder->bus->name, *iarg));
253 /* not much choice of outputs */
260 case ENCODER_ENABLE_OUTPUT:
264 encoder->enable = !!*iarg;
267 (KERN_INFO "%s-bt856: enable output %d\n",
268 encoder->bus->name, encoder->enable));
279 /* ----------------------------------------------------------------------- */
281 static struct i2c_driver i2c_driver_bt856 = {
283 I2C_DRIVERID_VIDEOENCODER, /* ID */
284 I2C_BT856, I2C_BT856 + 1,
292 static int bt856_init(void)
294 return i2c_register_driver(&i2c_driver_bt856);
297 static void bt856_exit(void)
299 i2c_unregister_driver(&i2c_driver_bt856);
302 module_init(bt856_init);
303 module_exit(bt856_exit);
304 MODULE_LICENSE("GPL");