Linux-2.6.12-rc2
[linux-flexiantxendom0-natty.git] / drivers / media / video / bttv-if.c
1 /*
2     $Id: bttv-if.c,v 1.4 2004/11/17 18:47:47 kraxel Exp $
3
4     bttv-if.c  --  old gpio interface to other kernel modules
5                    don't use in new code, will go away in 2.7
6                    have a look at bttv-gpio.c instead.
7
8     bttv - Bt848 frame grabber driver
9
10     Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@thp.uni-koeln.de)
11                            & Marcus Metzler (mocm@thp.uni-koeln.de)
12     (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
13
14     This program is free software; you can redistribute it and/or modify
15     it under the terms of the GNU General Public License as published by
16     the Free Software Foundation; either version 2 of the License, or
17     (at your option) any later version.
18
19     This program is distributed in the hope that it will be useful,
20     but WITHOUT ANY WARRANTY; without even the implied warranty of
21     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22     GNU General Public License for more details.
23
24     You should have received a copy of the GNU General Public License
25     along with this program; if not, write to the Free Software
26     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 */
29
30 #include <linux/module.h>
31 #include <linux/init.h>
32 #include <linux/delay.h>
33 #include <asm/io.h>
34
35 #include "bttvp.h"
36
37 EXPORT_SYMBOL(bttv_get_cardinfo);
38 EXPORT_SYMBOL(bttv_get_pcidev);
39 EXPORT_SYMBOL(bttv_get_id);
40 EXPORT_SYMBOL(bttv_gpio_enable);
41 EXPORT_SYMBOL(bttv_read_gpio);
42 EXPORT_SYMBOL(bttv_write_gpio);
43 EXPORT_SYMBOL(bttv_get_gpio_queue);
44 EXPORT_SYMBOL(bttv_i2c_call);
45
46 /* ----------------------------------------------------------------------- */
47 /* Exported functions - for other modules which want to access the         */
48 /*                      gpio ports (IR for example)                        */
49 /*                      see bttv.h for comments                            */
50
51 int bttv_get_cardinfo(unsigned int card, int *type, unsigned *cardid)
52 {
53         printk("The bttv_* interface is obsolete and will go away,\n"
54                "please use the new, sysfs based interface instead.\n");
55         if (card >= bttv_num) {
56                 return -1;
57         }
58         *type   = bttvs[card].c.type;
59         *cardid = bttvs[card].cardid;
60         return 0;
61 }
62
63 struct pci_dev* bttv_get_pcidev(unsigned int card)
64 {
65         if (card >= bttv_num)
66                 return NULL;
67         return bttvs[card].c.pci;
68 }
69
70 int bttv_get_id(unsigned int card)
71 {
72         printk("The bttv_* interface is obsolete and will go away,\n"
73                "please use the new, sysfs based interface instead.\n");
74         if (card >= bttv_num) {
75                 return -1;
76         }
77         return bttvs[card].c.type;
78 }
79
80
81 int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data)
82 {
83         struct bttv *btv;
84
85         if (card >= bttv_num) {
86                 return -EINVAL;
87         }
88
89         btv = &bttvs[card];
90         gpio_inout(mask,data);
91         if (bttv_gpio)
92                 bttv_gpio_tracking(btv,"extern enable");
93         return 0;
94 }
95
96 int bttv_read_gpio(unsigned int card, unsigned long *data)
97 {
98         struct bttv *btv;
99
100         if (card >= bttv_num) {
101                 return -EINVAL;
102         }
103
104         btv = &bttvs[card];
105
106         if(btv->shutdown) {
107                 return -ENODEV;
108         }
109
110 /* prior setting BT848_GPIO_REG_INP is (probably) not needed
111    because we set direct input on init */
112         *data = gpio_read();
113         return 0;
114 }
115
116 int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data)
117 {
118         struct bttv *btv;
119
120         if (card >= bttv_num) {
121                 return -EINVAL;
122         }
123
124         btv = &bttvs[card];
125
126 /* prior setting BT848_GPIO_REG_INP is (probably) not needed
127    because direct input is set on init */
128         gpio_bits(mask,data);
129         if (bttv_gpio)
130                 bttv_gpio_tracking(btv,"extern write");
131         return 0;
132 }
133
134 wait_queue_head_t* bttv_get_gpio_queue(unsigned int card)
135 {
136         struct bttv *btv;
137
138         if (card >= bttv_num) {
139                 return NULL;
140         }
141
142         btv = &bttvs[card];
143         if (bttvs[card].shutdown) {
144                 return NULL;
145         }
146         return &btv->gpioq;
147 }
148
149 void bttv_i2c_call(unsigned int card, unsigned int cmd, void *arg)
150 {
151         if (card >= bttv_num)
152                 return;
153         bttv_call_i2c_clients(&bttvs[card], cmd, arg);
154 }
155
156 /*
157  * Local variables:
158  * c-basic-offset: 8
159  * End:
160  */