This commit was generated by cvs2svn to compensate for changes in r517,
[linux-2.6.git] / drivers / media / video / bttv-if.c
1 /*
2     $Id: bttv-if.c,v 1.3 2004/10/13 10:39:00 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         if (card >= bttv_num) {
54                 return -1;
55         }
56         *type   = bttvs[card].c.type;
57         *cardid = bttvs[card].cardid;
58         return 0;
59 }
60
61 struct pci_dev* bttv_get_pcidev(unsigned int card)
62 {
63         if (card >= bttv_num)
64                 return NULL;
65         return bttvs[card].c.pci;
66 }
67
68 int bttv_get_id(unsigned int card)
69 {
70         printk("bttv_get_id is obsolete, use bttv_get_cardinfo instead\n");
71         if (card >= bttv_num) {
72                 return -1;
73         }
74         return bttvs[card].c.type;
75 }
76
77
78 int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data)
79 {
80         struct bttv *btv;
81
82         if (card >= bttv_num) {
83                 return -EINVAL;
84         }
85
86         btv = &bttvs[card];
87         gpio_inout(mask,data);
88         if (bttv_gpio)
89                 bttv_gpio_tracking(btv,"extern enable");
90         return 0;
91 }
92
93 int bttv_read_gpio(unsigned int card, unsigned long *data)
94 {
95         struct bttv *btv;
96
97         if (card >= bttv_num) {
98                 return -EINVAL;
99         }
100
101         btv = &bttvs[card];
102
103         if(btv->shutdown) {
104                 return -ENODEV;
105         }
106
107 /* prior setting BT848_GPIO_REG_INP is (probably) not needed
108    because we set direct input on init */
109         *data = gpio_read();
110         return 0;
111 }
112
113 int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data)
114 {
115         struct bttv *btv;
116
117         if (card >= bttv_num) {
118                 return -EINVAL;
119         }
120
121         btv = &bttvs[card];
122
123 /* prior setting BT848_GPIO_REG_INP is (probably) not needed
124    because direct input is set on init */
125         gpio_bits(mask,data);
126         if (bttv_gpio)
127                 bttv_gpio_tracking(btv,"extern write");
128         return 0;
129 }
130
131 wait_queue_head_t* bttv_get_gpio_queue(unsigned int card)
132 {
133         struct bttv *btv;
134
135         if (card >= bttv_num) {
136                 return NULL;
137         }
138
139         btv = &bttvs[card];
140         if (bttvs[card].shutdown) {
141                 return NULL;
142         }
143         return &btv->gpioq;
144 }
145
146 /*
147  * Local variables:
148  * c-basic-offset: 8
149  * End:
150  */