aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-05-25 13:34:36 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-06-05 05:35:46 -0400
commitba60bc673ce7d019ae6684cebbb33e5239346664 (patch)
tree2068da6e3586dcb55184a0dfbd599032b2fff9f5
parent8f9935732930e705cab1936a03418ce01aee979a (diff)
V4L/DVB (7934): cx18: move gpio_dir/val statics to the cx18 struct.
The gpio_dir/val statics cannot be global, they are card-specific. Thanks to Andy Walls for pointing this out. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/cx18/cx18-driver.h4
-rw-r--r--drivers/media/video/cx18/cx18-gpio.c29
2 files changed, 18 insertions, 15 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index 9c6a53477a1b..b943aeac2764 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -424,6 +424,10 @@ struct cx18 {
424 struct mutex i2c_bus_lock[2]; 424 struct mutex i2c_bus_lock[2];
425 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX]; 425 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
426 426
427 /* gpio */
428 u32 gpio_dir;
429 u32 gpio_val;
430
427 /* v4l2 and User settings */ 431 /* v4l2 and User settings */
428 432
429 /* codec settings */ 433 /* codec settings */
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c
index 1e0d32b992f9..2f324b8467cb 100644
--- a/drivers/media/video/cx18/cx18-gpio.c
+++ b/drivers/media/video/cx18/cx18-gpio.c
@@ -35,9 +35,6 @@
35#define CX18_REG_GPIO_OUT2 0xc78104 35#define CX18_REG_GPIO_OUT2 0xc78104
36#define CX18_REG_GPIO_DIR2 0xc7810c 36#define CX18_REG_GPIO_DIR2 0xc7810c
37 37
38static u32 gpio_dir;
39static u32 gpio_val;
40
41/* 38/*
42 * HVR-1600 GPIO pins, courtesy of Hauppauge: 39 * HVR-1600 GPIO pins, courtesy of Hauppauge:
43 * 40 *
@@ -49,25 +46,28 @@ static u32 gpio_val;
49 46
50static void gpio_write(struct cx18 *cx) 47static void gpio_write(struct cx18 *cx)
51{ 48{
52 write_reg((gpio_dir & 0xffff) << 16, CX18_REG_GPIO_DIR1); 49 u32 dir = cx->gpio_dir;
53 write_reg(((gpio_dir & 0xffff) << 16) | (gpio_val & 0xffff), 50 u32 val = cx->gpio_val;
51
52 write_reg((dir & 0xffff) << 16, CX18_REG_GPIO_DIR1);
53 write_reg(((dir & 0xffff) << 16) | (val & 0xffff),
54 CX18_REG_GPIO_OUT1); 54 CX18_REG_GPIO_OUT1);
55 write_reg(gpio_dir & 0xffff0000, CX18_REG_GPIO_DIR2); 55 write_reg(dir & 0xffff0000, CX18_REG_GPIO_DIR2);
56 write_reg((gpio_dir & 0xffff0000) | ((gpio_val & 0xffff0000) >> 16), 56 write_reg((dir & 0xffff0000) | ((val & 0xffff0000) >> 16),
57 CX18_REG_GPIO_OUT2); 57 CX18_REG_GPIO_OUT2);
58} 58}
59 59
60void cx18_gpio_init(struct cx18 *cx) 60void cx18_gpio_init(struct cx18 *cx)
61{ 61{
62 gpio_dir = cx->card->gpio_init.direction; 62 cx->gpio_dir = cx->card->gpio_init.direction;
63 gpio_val = cx->card->gpio_init.initial_value; 63 cx->gpio_val = cx->card->gpio_init.initial_value;
64 64
65 if (cx->card->xceive_pin) { 65 if (cx->card->xceive_pin) {
66 gpio_dir |= 1 << cx->card->xceive_pin; 66 cx->gpio_dir |= 1 << cx->card->xceive_pin;
67 gpio_val |= 1 << cx->card->xceive_pin; 67 cx->gpio_val |= 1 << cx->card->xceive_pin;
68 } 68 }
69 69
70 if (gpio_dir == 0) 70 if (cx->gpio_dir == 0)
71 return; 71 return;
72 72
73 CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n", 73 CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n",
@@ -88,13 +88,12 @@ int cx18_reset_tuner_gpio(void *dev, int cmd, int value)
88 return 0; 88 return 0;
89 CX18_DEBUG_INFO("Resetting tuner\n"); 89 CX18_DEBUG_INFO("Resetting tuner\n");
90 90
91 gpio_dir |= 1 << cx->card->xceive_pin; 91 cx->gpio_val &= ~(1 << cx->card->xceive_pin);
92 gpio_val &= ~(1 << cx->card->xceive_pin);
93 92
94 gpio_write(cx); 93 gpio_write(cx);
95 schedule_timeout_interruptible(msecs_to_jiffies(1)); 94 schedule_timeout_interruptible(msecs_to_jiffies(1));
96 95
97 gpio_val |= 1 << cx->card->xceive_pin; 96 cx->gpio_val |= 1 << cx->card->xceive_pin;
98 gpio_write(cx); 97 gpio_write(cx);
99 schedule_timeout_interruptible(msecs_to_jiffies(1)); 98 schedule_timeout_interruptible(msecs_to_jiffies(1));
100 return 0; 99 return 0;