Commit 25ac0ce6 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] Remove dead i2c bits from media/video

parent 63ec00ac
...@@ -5,7 +5,6 @@ mainmenu_option next_comment ...@@ -5,7 +5,6 @@ mainmenu_option next_comment
comment 'Video For Linux' comment 'Video For Linux'
bool ' V4L information in proc filesystem' CONFIG_VIDEO_PROC_FS bool ' V4L information in proc filesystem' CONFIG_VIDEO_PROC_FS
dep_tristate ' I2C on parallel port' CONFIG_I2C_PARPORT $CONFIG_PARPORT $CONFIG_I2C
comment 'Video Adapters' comment 'Video Adapters'
if [ "$CONFIG_I2C_ALGOBIT" = "y" -o "$CONFIG_I2C_ALGOBIT" = "m" ]; then if [ "$CONFIG_I2C_ALGOBIT" = "y" -o "$CONFIG_I2C_ALGOBIT" = "m" ]; then
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# All of the (potential) objects that export symbols. # All of the (potential) objects that export symbols.
# This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'. # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'.
export-objs := i2c-old.o videodev.o bttv-if.o cpia.o video-buf.o export-objs := videodev.o bttv-if.o cpia.o video-buf.o
bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \
bttv-risc.o bttv-vbi.o bttv-risc.o bttv-vbi.o
...@@ -13,21 +13,19 @@ zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o ...@@ -13,21 +13,19 @@ zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o
obj-$(CONFIG_VIDEO_DEV) += videodev.o obj-$(CONFIG_VIDEO_DEV) += videodev.o
obj-$(CONFIG_BUS_I2C) += i2c-old.o
obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \ obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \
tda7432.o tda9875.o tuner.o video-buf.o tda7432.o tda9875.o tuner.o video-buf.o
obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o
obj-$(CONFIG_VIDEO_ZR36120) += zoran.o obj-$(CONFIG_VIDEO_ZR36120) += zoran.o
obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o i2c-old.o obj-$(CONFIG_VIDEO_SAA5249) += saa5249.o
obj-$(CONFIG_VIDEO_SAA5249) += saa5249.o i2c-old.o
obj-$(CONFIG_VIDEO_CQCAM) += c-qcam.o obj-$(CONFIG_VIDEO_CQCAM) += c-qcam.o
obj-$(CONFIG_VIDEO_BWQCAM) += bw-qcam.o obj-$(CONFIG_VIDEO_BWQCAM) += bw-qcam.o
obj-$(CONFIG_VIDEO_W9966) += w9966.o obj-$(CONFIG_VIDEO_W9966) += w9966.o
obj-$(CONFIG_VIDEO_ZORAN_BUZ) += saa7111.o saa7185.o obj-$(CONFIG_VIDEO_ZORAN_BUZ) += saa7111.o saa7185.o
obj-$(CONFIG_VIDEO_ZORAN_DC10) += saa7110.o adv7175.o obj-$(CONFIG_VIDEO_ZORAN_DC10) += saa7110.o adv7175.o
obj-$(CONFIG_VIDEO_ZORAN_LML33) += bt819.o bt856.o obj-$(CONFIG_VIDEO_ZORAN_LML33) += bt819.o bt856.o
obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o i2c-old.o obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o
obj-$(CONFIG_VIDEO_PMS) += pms.o obj-$(CONFIG_VIDEO_PMS) += pms.o
obj-$(CONFIG_VIDEO_PLANB) += planb.o obj-$(CONFIG_VIDEO_PLANB) += planb.o
obj-$(CONFIG_VIDEO_VINO) += vino.o obj-$(CONFIG_VIDEO_VINO) += vino.o
......
/*
* Generic i2c interface for linux
*
* (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
*
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/i2c-old.h>
#define REGPRINT(x) if (verbose) (x)
#define I2C_DEBUG(x) if (i2c_debug) (x)
static int scan = 0;
static int verbose = 0;
static int i2c_debug = 0;
#if LINUX_VERSION_CODE >= 0x020117
MODULE_PARM(scan,"i");
MODULE_PARM(verbose,"i");
MODULE_PARM(i2c_debug,"i");
#endif
/* ----------------------------------------------------------------------- */
static struct i2c_bus *busses[I2C_BUS_MAX];
static struct i2c_driver *drivers[I2C_DRIVER_MAX];
static int bus_count = 0, driver_count = 0;
#ifdef CONFIG_VIDEO_BUZ
extern int saa7111_init(void);
extern int saa7185_init(void);
#endif
#ifdef CONFIG_VIDEO_LML33
extern int bt819_init(void);
extern int bt856_init(void);
#endif
int i2c_init(void)
{
printk(KERN_INFO "i2c: initialized%s\n",
scan ? " (i2c bus scan enabled)" : "");
/* anything to do here ? */
#ifdef CONFIG_VIDEO_BUZ
saa7111_init();
saa7185_init();
#endif
#ifdef CONFIG_VIDEO_LML33
bt819_init();
bt856_init();
#endif
return 0;
}
/* ----------------------------------------------------------------------- */
static void i2c_attach_device(struct i2c_bus *bus, struct i2c_driver *driver)
{
struct i2c_device *device;
int i,j,ack=1;
unsigned char addr;
LOCK_FLAGS;
/* probe for device */
LOCK_I2C_BUS(bus);
for (addr = driver->addr_l; addr <= driver->addr_h; addr += 2)
{
i2c_start(bus);
ack = i2c_sendbyte(bus,addr,0);
i2c_stop(bus);
if (!ack)
break;
}
UNLOCK_I2C_BUS(bus);
if (ack)
return;
/* got answer */
for (i = 0; i < I2C_DEVICE_MAX; i++)
if (NULL == driver->devices[i])
break;
if (I2C_DEVICE_MAX == i)
return;
for (j = 0; j < I2C_DEVICE_MAX; j++)
if (NULL == bus->devices[j])
break;
if (I2C_DEVICE_MAX == j)
return;
if (NULL == (device = kmalloc(sizeof(struct i2c_device),GFP_KERNEL)))
return;
device->bus = bus;
device->driver = driver;
device->addr = addr;
/* Attach */
if (driver->attach(device)!=0)
{
kfree(device);
return;
}
driver->devices[i] = device;
driver->devcount++;
bus->devices[j] = device;
bus->devcount++;
if (bus->attach_inform)
bus->attach_inform(bus,driver->id);
REGPRINT(printk("i2c: device attached: %s (addr=0x%02x, bus=%s, driver=%s)\n",device->name,addr,bus->name,driver->name));
}
static void i2c_detach_device(struct i2c_device *device)
{
int i;
if (device->bus->detach_inform)
device->bus->detach_inform(device->bus,device->driver->id);
device->driver->detach(device);
for (i = 0; i < I2C_DEVICE_MAX; i++)
if (device == device->driver->devices[i])
break;
if (I2C_DEVICE_MAX == i)
{
printk(KERN_WARNING "i2c: detach_device #1: device not found: %s\n",
device->name);
return;
}
device->driver->devices[i] = NULL;
device->driver->devcount--;
for (i = 0; i < I2C_DEVICE_MAX; i++)
if (device == device->bus->devices[i])
break;
if (I2C_DEVICE_MAX == i)
{
printk(KERN_WARNING "i2c: detach_device #2: device not found: %s\n",
device->name);
return;
}
device->bus->devices[i] = NULL;
device->bus->devcount--;
REGPRINT(printk("i2c: device detached: %s (addr=0x%02x, bus=%s, driver=%s)\n",device->name,device->addr,device->bus->name,device->driver->name));
kfree(device);
}
/* ----------------------------------------------------------------------- */
int i2c_register_bus(struct i2c_bus *bus)
{
int i,ack;
LOCK_FLAGS;
memset(bus->devices,0,sizeof(bus->devices));
bus->devcount = 0;
for (i = 0; i < I2C_BUS_MAX; i++)
if (NULL == busses[i])
break;
if (I2C_BUS_MAX == i)
return -ENOMEM;
busses[i] = bus;
bus_count++;
REGPRINT(printk("i2c: bus registered: %s\n",bus->name));
MOD_INC_USE_COUNT;
if (scan)
{
/* scan whole i2c bus */
LOCK_I2C_BUS(bus);
for (i = 0; i < 256; i+=2)
{
i2c_start(bus);
ack = i2c_sendbyte(bus,i,0);
i2c_stop(bus);
if (!ack)
{
printk(KERN_INFO "i2c: scanning bus %s: found device at addr=0x%02x\n",
bus->name,i);
}
}
UNLOCK_I2C_BUS(bus);
}
/* probe available drivers */
for (i = 0; i < I2C_DRIVER_MAX; i++)
if (drivers[i])
i2c_attach_device(bus,drivers[i]);
return 0;
}
int i2c_unregister_bus(struct i2c_bus *bus)
{
int i;
/* detach devices */
for (i = 0; i < I2C_DEVICE_MAX; i++)
if (bus->devices[i])
i2c_detach_device(bus->devices[i]);
for (i = 0; i < I2C_BUS_MAX; i++)
if (bus == busses[i])
break;
if (I2C_BUS_MAX == i)
{
printk(KERN_WARNING "i2c: unregister_bus #1: bus not found: %s\n",
bus->name);
return -ENODEV;
}
MOD_DEC_USE_COUNT;
busses[i] = NULL;
bus_count--;
REGPRINT(printk("i2c: bus unregistered: %s\n",bus->name));
return 0;
}
/* ----------------------------------------------------------------------- */
int i2c_register_driver(struct i2c_driver *driver)
{
int i;
memset(driver->devices,0,sizeof(driver->devices));
driver->devcount = 0;
for (i = 0; i < I2C_DRIVER_MAX; i++)
if (NULL == drivers[i])
break;
if (I2C_DRIVER_MAX == i)
return -ENOMEM;
drivers[i] = driver;
driver_count++;
MOD_INC_USE_COUNT;
REGPRINT(printk("i2c: driver registered: %s\n",driver->name));
/* Probe available busses */
for (i = 0; i < I2C_BUS_MAX; i++)
if (busses[i])
i2c_attach_device(busses[i],driver);
return 0;
}
int i2c_unregister_driver(struct i2c_driver *driver)
{
int i;
/* detach devices */
for (i = 0; i < I2C_DEVICE_MAX; i++)
if (driver->devices[i])
i2c_detach_device(driver->devices[i]);
for (i = 0; i < I2C_DRIVER_MAX; i++)
if (driver == drivers[i])
break;
if (I2C_DRIVER_MAX == i)
{
printk(KERN_WARNING "i2c: unregister_driver: driver not found: %s\n",
driver->name);
return -ENODEV;
}
MOD_DEC_USE_COUNT;
drivers[i] = NULL;
driver_count--;
REGPRINT(printk("i2c: driver unregistered: %s\n",driver->name));
return 0;
}
/* ----------------------------------------------------------------------- */
int i2c_control_device(struct i2c_bus *bus, int id,
unsigned int cmd, void *arg)
{
int i;
for (i = 0; i < I2C_DEVICE_MAX; i++)
if (bus->devices[i] && bus->devices[i]->driver->id == id)
break;
if (i == I2C_DEVICE_MAX)
return -ENODEV;
if (NULL == bus->devices[i]->driver->command)
return -ENODEV;
return bus->devices[i]->driver->command(bus->devices[i],cmd,arg);
}
/* ----------------------------------------------------------------------- */
#define I2C_SET(bus,ctrl,data) (bus->i2c_setlines(bus,ctrl,data))
#define I2C_GET(bus) (bus->i2c_getdataline(bus))
void i2c_start(struct i2c_bus *bus)
{
I2C_SET(bus,0,1);
I2C_SET(bus,1,1);
I2C_SET(bus,1,0);
I2C_SET(bus,0,0);
I2C_DEBUG(printk("%s: < ",bus->name));
}
void i2c_stop(struct i2c_bus *bus)
{
I2C_SET(bus,0,0);
I2C_SET(bus,1,0);
I2C_SET(bus,1,1);
I2C_DEBUG(printk(">\n"));
}
void i2c_one(struct i2c_bus *bus)
{
I2C_SET(bus,0,1);
I2C_SET(bus,1,1);
I2C_SET(bus,0,1);
}
void i2c_zero(struct i2c_bus *bus)
{
I2C_SET(bus,0,0);
I2C_SET(bus,1,0);
I2C_SET(bus,0,0);
}
int i2c_ack(struct i2c_bus *bus)
{
int ack;
I2C_SET(bus,0,1);
I2C_SET(bus,1,1);
ack = I2C_GET(bus);
I2C_SET(bus,0,1);
return ack;
}
int i2c_sendbyte(struct i2c_bus *bus,unsigned char data,int wait_for_ack)
{
int i, ack;
I2C_SET(bus,0,0);
for (i=7; i>=0; i--)
(data&(1<<i)) ? i2c_one(bus) : i2c_zero(bus);
if (wait_for_ack)
udelay(wait_for_ack);
ack=i2c_ack(bus);
I2C_DEBUG(printk("%02x%c ",(int)data,ack?'-':'+'));
return ack;
}
unsigned char i2c_readbyte(struct i2c_bus *bus,int last)
{
int i;
unsigned char data=0;
I2C_SET(bus,0,1);
for (i=7; i>=0; i--)
{
I2C_SET(bus,1,1);
if (I2C_GET(bus))
data |= (1<<i);
I2C_SET(bus,0,1);
}
last ? i2c_one(bus) : i2c_zero(bus);
I2C_DEBUG(printk("=%02x%c ",(int)data,last?'-':'+'));
return data;
}
/* ----------------------------------------------------------------------- */
int i2c_read(struct i2c_bus *bus, unsigned char addr)
{
int ret;
if (bus->i2c_read)
return bus->i2c_read(bus, addr);
i2c_start(bus);
i2c_sendbyte(bus,addr,0);
ret = i2c_readbyte(bus,1);
i2c_stop(bus);
return ret;
}
int i2c_write(struct i2c_bus *bus, unsigned char addr,
unsigned char data1, unsigned char data2, int both)
{
int ack;
if (bus->i2c_write)
return bus->i2c_write(bus, addr, data1, data2, both);
i2c_start(bus);
i2c_sendbyte(bus,addr,0);
ack = i2c_sendbyte(bus,data1,0);
if (both)
ack = i2c_sendbyte(bus,data2,0);
i2c_stop(bus);
return ack ? -1 : 0 ;
}
/* ----------------------------------------------------------------------- */
#ifdef MODULE
#if LINUX_VERSION_CODE >= 0x020100
EXPORT_SYMBOL(i2c_register_bus);
EXPORT_SYMBOL(i2c_unregister_bus);
EXPORT_SYMBOL(i2c_register_driver);
EXPORT_SYMBOL(i2c_unregister_driver);
EXPORT_SYMBOL(i2c_control_device);
EXPORT_SYMBOL(i2c_start);
EXPORT_SYMBOL(i2c_stop);
EXPORT_SYMBOL(i2c_one);
EXPORT_SYMBOL(i2c_zero);
EXPORT_SYMBOL(i2c_ack);
EXPORT_SYMBOL(i2c_sendbyte);
EXPORT_SYMBOL(i2c_readbyte);
EXPORT_SYMBOL(i2c_read);
EXPORT_SYMBOL(i2c_write);
#endif
int init_module(void)
{
return i2c_init();
}
void cleanup_module(void)
{
}
#endif
MODULE_LICENSE("GPL");
/*
* I2C driver for parallel port
*
* Author: Phil Blundell <philb@gnu.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* This driver implements a simple I2C protocol by bit-twiddling some
* signals on the parallel port. Since the outputs on the parallel port
* aren't open collector, three lines rather than two are used:
*
* D0 clock out
* D1 data out
* BUSY data in
*/
#include <linux/parport.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/i2c-old.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#define I2C_DELAY 10
static int debug = 0;
struct parport_i2c_bus
{
struct i2c_bus i2c;
struct parport_i2c_bus *next;
};
static struct parport_i2c_bus *bus_list;
static spinlock_t bus_list_lock = SPIN_LOCK_UNLOCKED;
/* software I2C functions */
static void i2c_setlines(struct i2c_bus *bus, int clk, int data)
{
struct parport *p = bus->data;
parport_write_data(p, (clk?1:0) | (data?2:0));
udelay(I2C_DELAY);
}
static int i2c_getdataline(struct i2c_bus *bus)
{
struct parport *p = bus->data;
return (parport_read_status(p) & PARPORT_STATUS_BUSY) ? 0 : 1;
}
static struct i2c_bus parport_i2c_bus_template =
{
"...",
I2C_BUSID_PARPORT,
NULL,
SPIN_LOCK_UNLOCKED,
NULL,
NULL,
i2c_setlines,
i2c_getdataline,
NULL,
NULL,
};
static void i2c_parport_attach(struct parport *port)
{
struct parport_i2c_bus *b = kmalloc(sizeof(struct parport_i2c_bus),
GFP_KERNEL);
if (!b) {
printk(KERN_ERR "i2c_parport: Memory allocation failed. Not attaching.\n");
return;
}
b->i2c = parport_i2c_bus_template;
b->i2c.data = parport_get_port (port);
strncpy(b->i2c.name, port->name, 32);
spin_lock(&bus_list_lock);
b->next = bus_list;
bus_list = b;
spin_unlock(&bus_list_lock);
i2c_register_bus(&b->i2c);
if (debug)
printk(KERN_DEBUG "i2c: attached to %s\n", port->name);
}
static void i2c_parport_detach(struct parport *port)
{
struct parport_i2c_bus *b, *old_b = NULL;
spin_lock(&bus_list_lock);
b = bus_list;
while (b)
{
if (b->i2c.data == port)
{
if (old_b)
old_b->next = b->next;
else
bus_list = b->next;
i2c_unregister_bus(&b->i2c);
kfree(b);
break;
}
old_b = b;
b = b->next;
}
spin_unlock(&bus_list_lock);
if (debug)
printk(KERN_DEBUG "i2c: detached from %s\n", port->name);
}
static struct parport_driver parport_i2c_driver =
{
"i2c",
i2c_parport_attach,
i2c_parport_detach
};
#ifdef MODULE
int init_module(void)
#else
int __init i2c_parport_init(void)
#endif
{
printk("I2C: driver for parallel port v0.1 philb@gnu.org\n");
parport_register_driver(&parport_i2c_driver);
return 0;
}
#ifdef MODULE
MODULE_PARM(debug, "i");
void cleanup_module(void)
{
struct parport_i2c_bus *b = bus_list;
while (b)
{
struct parport_i2c_bus *next = b->next;
i2c_unregister_bus(&b->i2c);
kfree(b);
b = next;
}
parport_unregister_driver(&parport_i2c_driver);
}
#endif
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment