summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/drivers/media/common/Kconfig6
-rw-r--r--linux/drivers/media/common/saa7146.h7
-rw-r--r--linux/drivers/media/common/saa7146_core.c34
-rw-r--r--linux/drivers/media/common/saa7146_i2c.c74
-rw-r--r--linux/drivers/media/dvb/av7110/Kconfig1
-rw-r--r--linux/drivers/media/dvb/av7110/av7110.c4
-rw-r--r--linux/drivers/media/video/mxb.c43
7 files changed, 56 insertions, 113 deletions
diff --git a/linux/drivers/media/common/Kconfig b/linux/drivers/media/common/Kconfig
index 9061b1af1..17cb90bc3 100644
--- a/linux/drivers/media/common/Kconfig
+++ b/linux/drivers/media/common/Kconfig
@@ -1,8 +1,8 @@
config VIDEO_SAA7146
tristate
- default y if DVB_AV7110=y
- default m if DVB_AV7110=m
- depends on VIDEO_DEV && PCI && I2C
+ default y if DVB_AV7110=y || VIDEO_MXB=y
+ default m if DVB_AV7110=m || VIDEO_MXB=m
+ depends on VIDEO_DEV && PCI
config VIDEO_VIDEOBUF
tristate
diff --git a/linux/drivers/media/common/saa7146.h b/linux/drivers/media/common/saa7146.h
index 5c6455c6d..282be0531 100644
--- a/linux/drivers/media/common/saa7146.h
+++ b/linux/drivers/media/common/saa7146.h
@@ -14,7 +14,6 @@ from flaws in video-buf.c => Gerd Knorr */
#include <linux/interrupt.h> /* for IMMEDIATE_BH */
#include <linux/kmod.h> /* for kernel module loader */
#include <linux/i2c.h> /* for i2c subsystem */
-#include <linux/i2c-id.h>
#include <asm/io.h> /* for accessing devices */
#include <linux/stringify.h>
@@ -40,7 +39,7 @@ from flaws in video-buf.c => Gerd Knorr */
extern unsigned int saa7146_debug;
//#define DEBUG_PROLOG printk("(0x%08x) %s: %s(): ",(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,IER))),__stringify(KBUILD_MODNAME),__FUNCTION__)
-#define DEBUG_PROLOG printk("%d: %s: %s(): ",saa7146_debug,__stringify(KBUILD_MODNAME),__FUNCTION__)
+#define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_MODNAME),__FUNCTION__)
#define DEB_S(x) if (0!=(saa7146_debug&0x01)) { DEBUG_PROLOG; printk x; } /* simple debug messages */
#define DEB_D(x) if (0!=(saa7146_debug&0x02)) { DEBUG_PROLOG; printk x; } /* more detailed debug messages */
@@ -101,7 +100,6 @@ struct saa7146_extension
int num_stds;
int (*std_callback)(struct saa7146_dev*, struct saa7146_standard *);
- int use_kernel_i2c;
int (*vbi)(struct saa7146_dev*); // want vbi
struct saa7146_extension_ioctls *ioctls;
@@ -237,7 +235,6 @@ struct saa7146_dev
void* ext_priv; /* pointer for extension private use (most likely some private data) */
/* i2c-stuff */
- struct i2c_adapter *i2c_adapter;
u32 i2c_bitrate;
u32* i2c_mem; /* pointer to i2c memory */
@@ -287,7 +284,7 @@ struct saa7146_use_ops {
};
/* from saa7146_i2c.c */
-int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev);
+int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate);
int saa7146_i2c_transfer(struct saa7146_dev *saa, const struct i2c_msg msgs[], int num, int retries);
/* from saa7146_hlp.c */
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c
index 28a84fc25..a92511cdd 100644
--- a/linux/drivers/media/common/saa7146_core.c
+++ b/linux/drivers/media/common/saa7146_core.c
@@ -557,18 +557,8 @@ void try_attach_extension_and_device(struct saa7146_dev *dev, struct saa7146_ext
return;
}
- if( 0 != ext->use_kernel_i2c ) {
- /* register new i2c-bus */
- if(i2c_add_adapter(dev->i2c_adapter) < 0) {
- DEB_S(("cannot register i2c-device. skipping.\n"));
- return;
- }
- }
-
if( 0 != ext->probe(dev, dev->pci->subsystem_vendor, dev->pci->subsystem_device) ) {
DEB_D(("ext->probe() failed for %p. skipping device.\n",dev));
- if( 0 != ext->use_kernel_i2c )
- i2c_del_adapter(dev->i2c_adapter);
return;
}
@@ -576,8 +566,6 @@ void try_attach_extension_and_device(struct saa7146_dev *dev, struct saa7146_ext
if( 0 != ext->attach(dev) ) {
DEB_D(("ext->attach() failed for %p. skipping device.\n",dev));
- if( 0 != ext->use_kernel_i2c )
- i2c_del_adapter(dev->i2c_adapter);
dev->ext = NULL;
return;
}
@@ -596,8 +584,6 @@ void try_attach_extension_and_device(struct saa7146_dev *dev, struct saa7146_ext
it looks - you cannot access the device.
we simply call the 'release' function. */
ext->detach(dev);
- if( 0 != ext->use_kernel_i2c )
- i2c_del_adapter(dev->i2c_adapter);
dev->ext = NULL;
return;
}
@@ -693,9 +679,6 @@ int saa7146_unregister_extension(struct saa7146_extension* ext)
DEB_D(("ext->detach() failed. ignoring.\n"));
}
- if( 0 != ext->use_kernel_i2c )
- i2c_del_adapter(dev->i2c_adapter);
-
video_unregister_device(&dev->video_dev);
if( 0 != BOARD_CAN_DO_VBI(dev)) {
video_unregister_device(&dev->vbi_dev);
@@ -813,19 +796,11 @@ static int config_a_device(struct pci_dev *pci)
goto kmalloc_error_3;
memset(dev->clipping, 0x0, SAA7146_CLIPPING_MEM);
- dev->i2c_adapter = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
- if ( NULL == dev->i2c_adapter )
- goto kmalloc_error_4;
- memset(dev->i2c_adapter, 0x0, sizeof(struct i2c_adapter));
-
dev->i2c_mem = (u32*)kmalloc(SAA7146_I2C_MEM, GFP_KERNEL);
if( NULL == dev->i2c_mem )
- goto kmalloc_error_5;
+ goto kmalloc_error_4;
memset(dev->i2c_mem, 0x00, SAA7146_I2C_MEM);
- /* i2c-adapter preparations */
- saa7146_i2c_adapter_prepare(dev);
-
/* enable i2c-port pins, video-port-pins */
saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
@@ -855,8 +830,6 @@ static int config_a_device(struct pci_dev *pci)
return try_match_device_to_extension(dev);
-kmalloc_error_5:
- kfree( dev->i2c_adapter );
kmalloc_error_4:
kfree( dev->clipping );
kmalloc_error_3:
@@ -890,7 +863,6 @@ static void unconfig_a_device(struct saa7146_dev* dev)
kfree(dev->rps1 );
kfree(dev->clipping);
kfree(dev->i2c_mem);
- kfree(dev->i2c_adapter);
iounmap(dev->mem);
release_mem_region(pci_resource_start(dev->pci,0), pci_resource_len(dev->pci,0));
@@ -931,7 +903,7 @@ struct pci_device_id saa7146_pci_tbl[] __devinitdata = {
{ 0,},
};
-static MODULE_DEVICE_TABLE(pci, saa7146_pci_tbl);
+MODULE_DEVICE_TABLE(pci, saa7146_pci_tbl);
static
struct pci_driver saa7146_driver = {
@@ -977,6 +949,8 @@ EXPORT_SYMBOL_GPL(saa7146_pgtable_alloc);
EXPORT_SYMBOL_GPL(saa7146_pgtable_free);
EXPORT_SYMBOL_GPL(saa7146_pgtable_build_single);
EXPORT_SYMBOL_GPL(saa7146_i2c_transfer);
+EXPORT_SYMBOL_GPL(saa7146_i2c_adapter_prepare);
+EXPORT_SYMBOL_GPL(saa7146_debug);
MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
MODULE_DESCRIPTION("video4linux driver for saa7146-based video hardware");
diff --git a/linux/drivers/media/common/saa7146_i2c.c b/linux/drivers/media/common/saa7146_i2c.c
index fb876b03b..ed5f23930 100644
--- a/linux/drivers/media/common/saa7146_i2c.c
+++ b/linux/drivers/media/common/saa7146_i2c.c
@@ -362,75 +362,35 @@ int saa7146_i2c_xfer(struct i2c_adapter* adapter, struct i2c_msg msg[], int num)
return saa7146_i2c_transfer(dev, msg, num, adapter->retries);
}
-/* these are just for completeness */
-static
-int saa7146_i2c_reg(struct i2c_client *client)
-{
- return 0;
-}
-
-static
-int saa7146_i2c_unreg(struct i2c_client *client)
-{
- return 0;
-}
-
-/* fixme
-void saa7146_i2c_inc_use(struct i2c_adapter *adap)
-{
-#ifdef MODULE
- MOD_INC_USE_COUNT;
-#endif
-}
-
-void saa7146_i2c_dec_use(struct i2c_adapter *adap)
-{
-#ifdef MODULE
- MOD_DEC_USE_COUNT;
-#endif
-}
-*/
/*****************************************************************************/
/* i2c-adapter helper functions */
+#include <linux/i2c-id.h>
/* exported algorithm data */
static
struct i2c_algorithm saa7146_algo = {
- "saa7146 i2c algorithm",
- I2C_ALGO_SAA7146,
- saa7146_i2c_xfer,
- NULL,
- NULL, /* slave_xmit */
- NULL, /* slave_recv */
- NULL, /* ioctl */
- saa7146_i2c_func, /* functionality */
+ .name = "saa7146 i2c algorithm",
+ .id = I2C_ALGO_SAA7146,
+ .master_xfer = saa7146_i2c_xfer,
+ .functionality = saa7146_i2c_func,
};
-int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev)
+int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate)
{
- /* fixme: this should be adjusted by the extension */
- dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_480;
-
+ dev->i2c_bitrate = bitrate;
saa7146_i2c_reset(dev);
- memset(dev->i2c_adapter,0,sizeof(struct i2c_adapter));
- strcpy(dev->i2c_adapter->name, dev->name);
-
- dev->i2c_adapter->data = dev;
- dev->i2c_adapter->algo = &saa7146_algo;
- dev->i2c_adapter->algo_data = NULL;
- dev->i2c_adapter->id = I2C_ALGO_SAA7146;
-
-/* fixme
- dev->i2c_adapter->inc_use = saa7146_i2c_inc_use;
- dev->i2c_adapter->dec_use = saa7146_i2c_dec_use;
-*/
- dev->i2c_adapter->client_register = saa7146_i2c_reg;
- dev->i2c_adapter->client_unregister = saa7146_i2c_unreg;
-
- dev->i2c_adapter->timeout = SAA7146_I2C_TIMEOUT;
- dev->i2c_adapter->retries = SAA7146_I2C_RETRIES;
+ if( NULL != i2c_adapter ) {
+ memset(i2c_adapter,0,sizeof(struct i2c_adapter));
+ strcpy(i2c_adapter->name, dev->name);
+ i2c_adapter->data = dev;
+ i2c_adapter->algo = &saa7146_algo;
+ i2c_adapter->algo_data = NULL;
+ i2c_adapter->id = I2C_ALGO_SAA7146;
+ i2c_adapter->timeout = SAA7146_I2C_TIMEOUT;
+ i2c_adapter->retries = SAA7146_I2C_RETRIES;
+ }
return 0;
}
diff --git a/linux/drivers/media/dvb/av7110/Kconfig b/linux/drivers/media/dvb/av7110/Kconfig
index 6b7e6961d..93270f079 100644
--- a/linux/drivers/media/dvb/av7110/Kconfig
+++ b/linux/drivers/media/dvb/av7110/Kconfig
@@ -23,4 +23,3 @@ config DVB_AV7110_OSD
its menus, so say Y if you want to use this software.
All other people say N.
-
diff --git a/linux/drivers/media/dvb/av7110/av7110.c b/linux/drivers/media/dvb/av7110/av7110.c
index e9126e36c..6fcc7fec7 100644
--- a/linux/drivers/media/dvb/av7110/av7110.c
+++ b/linux/drivers/media/dvb/av7110/av7110.c
@@ -4364,6 +4364,9 @@ int av7110_attach (struct saa7146_dev* dev)
dvb_register_adapter(&adap, av7110->card_type->name);
av7110->dvb_adapter = adap;
+ /* fixme: speed ok? */
+ saa7146_i2c_adapter_prepare(dev, NULL, SAA7146_I2C_BUS_BIT_RATE_480);
+
av7110->i2c_bus = dvb_register_i2c_bus (master_xfer, dev, av7110->dvb_adapter, 0);
if (!av7110->i2c_bus) {
dvb_unregister_adapter (av7110->dvb_adapter);
@@ -4640,7 +4643,6 @@ struct saa7146_extension av7110_extension = {
.num_stds = sizeof(standard)/sizeof(struct saa7146_standard),
.std_callback = NULL,
- .use_kernel_i2c = 0,
.vbi = NULL,
.ioctls = &ioctls[0],
diff --git a/linux/drivers/media/video/mxb.c b/linux/drivers/media/video/mxb.c
index c9688cf9c..572faa133 100644
--- a/linux/drivers/media/video/mxb.c
+++ b/linux/drivers/media/video/mxb.c
@@ -129,6 +129,8 @@ static struct saa7146_extension_ioctls ioctls[] = {
struct mxb
{
+ struct i2c_adapter i2c_adapter;
+
struct i2c_client* saa7111a;
struct i2c_client* tda9840;
struct i2c_client* tea6415c;
@@ -167,26 +169,34 @@ static int mxb_probe(struct saa7146_dev* dev, unsigned int subvendor, unsigned i
}
memset(mxb, 0x0, sizeof(struct mxb));
+ saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
+ if(i2c_add_adapter(&mxb->i2c_adapter) < 0) {
+ DEB_S(("cannot register i2c-device. skipping.\n"));
+ kfree(mxb);
+ return -EFAULT;
+ }
+
/* loop through all i2c-devices on the bus and look who is there */
- for(i = 0; i < dev->i2c_adapter->client_count; i++) {
- if( I2C_TEA6420_1 == dev->i2c_adapter->clients[i]->addr )
- mxb->tea6420_1 = dev->i2c_adapter->clients[i];
- if( I2C_TEA6420_2 == dev->i2c_adapter->clients[i]->addr )
- mxb->tea6420_2 = dev->i2c_adapter->clients[i];
- if( I2C_TEA6415C_2 == dev->i2c_adapter->clients[i]->addr )
- mxb->tea6415c = dev->i2c_adapter->clients[i];
- if( I2C_TDA9840 == dev->i2c_adapter->clients[i]->addr )
- mxb->tda9840 = dev->i2c_adapter->clients[i];
- if( I2C_SAA7111A == dev->i2c_adapter->clients[i]->addr )
- mxb->saa7111a = dev->i2c_adapter->clients[i];
- if( 0x60 == dev->i2c_adapter->clients[i]->addr )
- mxb->tuner = dev->i2c_adapter->clients[i];
+ for(i = 0; i < mxb->i2c_adapter.client_count; i++) {
+ if( I2C_TEA6420_1 == mxb->i2c_adapter.clients[i]->addr )
+ mxb->tea6420_1 = mxb->i2c_adapter.clients[i];
+ if( I2C_TEA6420_2 == mxb->i2c_adapter.clients[i]->addr )
+ mxb->tea6420_2 = mxb->i2c_adapter.clients[i];
+ if( I2C_TEA6415C_2 == mxb->i2c_adapter.clients[i]->addr )
+ mxb->tea6415c = mxb->i2c_adapter.clients[i];
+ if( I2C_TDA9840 == mxb->i2c_adapter.clients[i]->addr )
+ mxb->tda9840 = mxb->i2c_adapter.clients[i];
+ if( I2C_SAA7111A == mxb->i2c_adapter.clients[i]->addr )
+ mxb->saa7111a = mxb->i2c_adapter.clients[i];
+ if( 0x60 == mxb->i2c_adapter.clients[i]->addr )
+ mxb->tuner = mxb->i2c_adapter.clients[i];
}
/* check if all devices are present */
if( 0 == mxb->tea6420_1 || 0 == mxb->tea6420_2 || 0 == mxb->tea6415c
|| 0 == mxb->tda9840 || 0 == mxb->saa7111a || 0 == mxb->tuner ) {
DEB_D(("this saa7146 is not on an mxb.\n"));
+ i2c_del_adapter(&mxb->i2c_adapter);
kfree(mxb);
return -ENODEV;
}
@@ -352,14 +362,14 @@ static int mxb_init_done(struct saa7146_dev* dev)
msg.len = saa7740_init[0].length;
msg.buf = &saa7740_init[0].data[0];
- if( 1 == (err = i2c_transfer(dev->i2c_adapter, &msg, 1))) {
+ if( 1 == (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) {
for(i = 1;;i++) {
msg.len = saa7740_init[i].length;
if( -1 == msg.len ) {
break;
}
msg.buf = &saa7740_init[i].data[0];
- if( 1 != (err = i2c_transfer(dev->i2c_adapter, &msg, 1))) {
+ if( 1 != (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) {
DEB_D(("failed to initialize 'sound arena module'.\n"));
goto err;
}
@@ -427,6 +437,8 @@ static int mxb_detach(struct saa7146_dev* dev)
i2c_dec_use_client(mxb->tuner);
mxb_num--;
+
+ i2c_del_adapter(&mxb->i2c_adapter);
kfree(mxb);
return 0;
@@ -955,7 +967,6 @@ struct saa7146_extension extension = {
.num_stds = sizeof(standard)/sizeof(struct saa7146_standard),
.std_callback = &std_callback,
- .use_kernel_i2c = 1,
.vbi = mxb_vbi_bypass,
.ioctls = &ioctls[0],