• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 
3     bttv-if.c  --  old gpio interface to other kernel modules
4 		   don't use in new code, will go away in 2.7
5 		   have a look at bttv-gpio.c instead.
6 
7     bttv - Bt848 frame grabber driver
8 
9     Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@thp.uni-koeln.de)
10 			   & Marcus Metzler (mocm@thp.uni-koeln.de)
11     (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
12 
13     This program is free software; you can redistribute it and/or modify
14     it under the terms of the GNU General Public License as published by
15     the Free Software Foundation; either version 2 of the License, or
16     (at your option) any later version.
17 
18     This program is distributed in the hope that it will be useful,
19     but WITHOUT ANY WARRANTY; without even the implied warranty of
20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21     GNU General Public License for more details.
22 
23     You should have received a copy of the GNU General Public License
24     along with this program; if not, write to the Free Software
25     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 
27 */
28 
29 #include <linux/module.h>
30 #include <linux/init.h>
31 #include <linux/delay.h>
32 #include <asm/io.h>
33 
34 #include "bttvp.h"
35 
36 EXPORT_SYMBOL(bttv_get_pcidev);
37 EXPORT_SYMBOL(bttv_gpio_enable);
38 EXPORT_SYMBOL(bttv_read_gpio);
39 EXPORT_SYMBOL(bttv_write_gpio);
40 
41 /* ----------------------------------------------------------------------- */
42 /* Exported functions - for other modules which want to access the         */
43 /*                      gpio ports (IR for example)                        */
44 /*                      see bttv.h for comments                            */
45 
bttv_get_pcidev(unsigned int card)46 struct pci_dev* bttv_get_pcidev(unsigned int card)
47 {
48 	if (card >= bttv_num)
49 		return NULL;
50 	return bttvs[card].c.pci;
51 }
52 
53 
bttv_gpio_enable(unsigned int card,unsigned long mask,unsigned long data)54 int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data)
55 {
56 	struct bttv *btv;
57 
58 	if (card >= bttv_num) {
59 		return -EINVAL;
60 	}
61 
62 	btv = &bttvs[card];
63 	gpio_inout(mask,data);
64 	if (bttv_gpio)
65 		bttv_gpio_tracking(btv,"extern enable");
66 	return 0;
67 }
68 
bttv_read_gpio(unsigned int card,unsigned long * data)69 int bttv_read_gpio(unsigned int card, unsigned long *data)
70 {
71 	struct bttv *btv;
72 
73 	if (card >= bttv_num) {
74 		return -EINVAL;
75 	}
76 
77 	btv = &bttvs[card];
78 
79 	if(btv->shutdown) {
80 		return -ENODEV;
81 	}
82 
83 /* prior setting BT848_GPIO_REG_INP is (probably) not needed
84    because we set direct input on init */
85 	*data = gpio_read();
86 	return 0;
87 }
88 
bttv_write_gpio(unsigned int card,unsigned long mask,unsigned long data)89 int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data)
90 {
91 	struct bttv *btv;
92 
93 	if (card >= bttv_num) {
94 		return -EINVAL;
95 	}
96 
97 	btv = &bttvs[card];
98 
99 /* prior setting BT848_GPIO_REG_INP is (probably) not needed
100    because direct input is set on init */
101 	gpio_bits(mask,data);
102 	if (bttv_gpio)
103 		bttv_gpio_tracking(btv,"extern write");
104 	return 0;
105 }
106 
107 /*
108  * Local variables:
109  * c-basic-offset: 8
110  * End:
111  */
112