aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx88/cx88-i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/pci/cx88/cx88-i2c.c')
-rw-r--r--drivers/media/pci/cx88/cx88-i2c.c136
1 files changed, 68 insertions, 68 deletions
diff --git a/drivers/media/pci/cx88/cx88-i2c.c b/drivers/media/pci/cx88/cx88-i2c.c
index cf2d69615838..f7692775fb5a 100644
--- a/drivers/media/pci/cx88/cx88-i2c.c
+++ b/drivers/media/pci/cx88/cx88-i2c.c
@@ -1,55 +1,53 @@
/*
+ *
+ * cx88-i2c.c -- all the i2c code is here
+ *
+ * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
+ * & Marcus Metzler (mocm@thp.uni-koeln.de)
+ * (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
+ * (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
+ *
+ * (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
+ * - Multituner support and i2c address binding
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
- cx88-i2c.c -- all the i2c code is here
-
- Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
- & Marcus Metzler (mocm@thp.uni-koeln.de)
- (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
- (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
-
- (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
- - Multituner support and i2c address binding
-
- 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 program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+#include "cx88.h"
-#include <linux/module.h>
#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/module.h>
-#include <asm/io.h>
-
-#include "cx88.h"
#include <media/v4l2-common.h>
static unsigned int i2c_debug;
module_param(i2c_debug, int, 0644);
-MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]");
+MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
static unsigned int i2c_scan;
module_param(i2c_scan, int, 0444);
-MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
+MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time");
static unsigned int i2c_udelay = 5;
module_param(i2c_udelay, int, 0644);
-MODULE_PARM_DESC(i2c_udelay,"i2c delay at insmod time, in usecs "
- "(should be 5 or higher). Lower value means higher bus speed.");
+MODULE_PARM_DESC(i2c_udelay,
+ "i2c delay at insmod time, in usecs (should be 5 or higher). Lower value means higher bus speed.");
-#define dprintk(level,fmt, arg...) if (i2c_debug >= level) \
- printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
+#define dprintk(level, fmt, arg...) do { \
+ if (i2c_debug >= level) \
+ printk(KERN_DEBUG pr_fmt("%s: i2c:" fmt), \
+ __func__, ##arg); \
+} while (0)
/* ----------------------------------------------------------------------- */
@@ -109,26 +107,26 @@ static const struct i2c_algo_bit_data cx8800_i2c_algo_template = {
/* ----------------------------------------------------------------------- */
static const char * const i2c_devs[128] = {
- [ 0x1c >> 1 ] = "lgdt330x",
- [ 0x86 >> 1 ] = "tda9887/cx22702",
- [ 0xa0 >> 1 ] = "eeprom",
- [ 0xc0 >> 1 ] = "tuner (analog)",
- [ 0xc2 >> 1 ] = "tuner (analog/dvb)",
- [ 0xc8 >> 1 ] = "xc5000",
+ [0x1c >> 1] = "lgdt330x",
+ [0x86 >> 1] = "tda9887/cx22702",
+ [0xa0 >> 1] = "eeprom",
+ [0xc0 >> 1] = "tuner (analog)",
+ [0xc2 >> 1] = "tuner (analog/dvb)",
+ [0xc8 >> 1] = "xc5000",
};
static void do_i2c_scan(const char *name, struct i2c_client *c)
{
unsigned char buf;
- int i,rc;
+ int i, rc;
for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) {
c->addr = i;
- rc = i2c_master_recv(c,&buf,0);
+ rc = i2c_master_recv(c, &buf, 0);
if (rc < 0)
continue;
- printk("%s: i2c scan: found device @ 0x%x [%s]\n",
- name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
+ pr_info("i2c scan: found device @ 0x%x [%s]\n",
+ i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
}
}
@@ -136,14 +134,13 @@ static void do_i2c_scan(const char *name, struct i2c_client *c)
int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
{
/* Prevents usage of invalid delay values */
- if (i2c_udelay<5)
- i2c_udelay=5;
+ if (i2c_udelay < 5)
+ i2c_udelay = 5;
core->i2c_algo = cx8800_i2c_algo_template;
-
core->i2c_adap.dev.parent = &pci->dev;
- strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name));
+ strlcpy(core->i2c_adap.name, core->name, sizeof(core->i2c_adap.name));
core->i2c_adap.owner = THIS_MODULE;
core->i2c_algo.udelay = i2c_udelay;
core->i2c_algo.data = core;
@@ -152,32 +149,35 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
core->i2c_client.adapter = &core->i2c_adap;
strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE);
- cx8800_bit_setscl(core,1);
- cx8800_bit_setsda(core,1);
+ cx8800_bit_setscl(core, 1);
+ cx8800_bit_setsda(core, 1);
core->i2c_rc = i2c_bit_add_bus(&core->i2c_adap);
- if (0 == core->i2c_rc) {
- static u8 tuner_data[] =
- { 0x0b, 0xdc, 0x86, 0x52 };
- static struct i2c_msg tuner_msg =
- { .flags = 0, .addr = 0xc2 >> 1, .buf = tuner_data, .len = 4 };
+ if (core->i2c_rc == 0) {
+ static u8 tuner_data[] = {
+ 0x0b, 0xdc, 0x86, 0x52 };
+ static struct i2c_msg tuner_msg = {
+ .flags = 0,
+ .addr = 0xc2 >> 1,
+ .buf = tuner_data,
+ .len = 4
+ };
dprintk(1, "i2c register ok\n");
- switch( core->boardnr ) {
- case CX88_BOARD_HAUPPAUGE_HVR1300:
- case CX88_BOARD_HAUPPAUGE_HVR3000:
- case CX88_BOARD_HAUPPAUGE_HVR4000:
- printk("%s: i2c init: enabling analog demod on HVR1300/3000/4000 tuner\n",
- core->name);
- i2c_transfer(core->i2c_client.adapter, &tuner_msg, 1);
- break;
- default:
- break;
+ switch (core->boardnr) {
+ case CX88_BOARD_HAUPPAUGE_HVR1300:
+ case CX88_BOARD_HAUPPAUGE_HVR3000:
+ case CX88_BOARD_HAUPPAUGE_HVR4000:
+ pr_info("i2c init: enabling analog demod on HVR1300/3000/4000 tuner\n");
+ i2c_transfer(core->i2c_client.adapter, &tuner_msg, 1);
+ break;
+ default:
+ break;
}
if (i2c_scan)
- do_i2c_scan(core->name,&core->i2c_client);
+ do_i2c_scan(core->name, &core->i2c_client);
} else
- printk("%s: i2c register FAILED\n", core->name);
+ pr_err("i2c register FAILED\n");
return core->i2c_rc;
}