aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-gpio.c
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 /drivers/media/video/cx18/cx18-gpio.c
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>
Diffstat (limited to 'drivers/media/video/cx18/cx18-gpio.c')
-rw-r--r--drivers/media/video/cx18/cx18-gpio.c29
1 files changed, 14 insertions, 15 deletions
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;