Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | |
| 3 | bttv-if.c -- old gpio interface to other kernel modules |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 4 | don't use in new code, will go away in 2.7 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 10 | & Marcus Metzler (mocm@thp.uni-koeln.de) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | EXPORT_SYMBOL(bttv_get_pcidev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | EXPORT_SYMBOL(bttv_gpio_enable); |
| 38 | EXPORT_SYMBOL(bttv_read_gpio); |
| 39 | EXPORT_SYMBOL(bttv_write_gpio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | struct pci_dev* bttv_get_pcidev(unsigned int card) |
| 47 | { |
| 48 | if (card >= bttv_num) |
| 49 | return NULL; |
Trent Piepho | 4b10d3b | 2009-01-28 21:32:59 -0300 | [diff] [blame] | 50 | if (!bttvs[card]) |
| 51 | return NULL; |
| 52 | |
| 53 | return bttvs[card]->c.pci; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data) |
| 58 | { |
| 59 | struct bttv *btv; |
| 60 | |
| 61 | if (card >= bttv_num) { |
| 62 | return -EINVAL; |
| 63 | } |
| 64 | |
Trent Piepho | 4b10d3b | 2009-01-28 21:32:59 -0300 | [diff] [blame] | 65 | btv = bttvs[card]; |
| 66 | if (!btv) |
| 67 | return -ENODEV; |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | gpio_inout(mask,data); |
| 70 | if (bttv_gpio) |
| 71 | bttv_gpio_tracking(btv,"extern enable"); |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | int bttv_read_gpio(unsigned int card, unsigned long *data) |
| 76 | { |
| 77 | struct bttv *btv; |
| 78 | |
| 79 | if (card >= bttv_num) { |
| 80 | return -EINVAL; |
| 81 | } |
| 82 | |
Trent Piepho | 4b10d3b | 2009-01-28 21:32:59 -0300 | [diff] [blame] | 83 | btv = bttvs[card]; |
| 84 | if (!btv) |
| 85 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | if(btv->shutdown) { |
| 88 | return -ENODEV; |
| 89 | } |
| 90 | |
| 91 | /* prior setting BT848_GPIO_REG_INP is (probably) not needed |
| 92 | because we set direct input on init */ |
| 93 | *data = gpio_read(); |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data) |
| 98 | { |
| 99 | struct bttv *btv; |
| 100 | |
| 101 | if (card >= bttv_num) { |
| 102 | return -EINVAL; |
| 103 | } |
| 104 | |
Trent Piepho | 4b10d3b | 2009-01-28 21:32:59 -0300 | [diff] [blame] | 105 | btv = bttvs[card]; |
| 106 | if (!btv) |
| 107 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
| 109 | /* prior setting BT848_GPIO_REG_INP is (probably) not needed |
| 110 | because direct input is set on init */ |
| 111 | gpio_bits(mask,data); |
| 112 | if (bttv_gpio) |
| 113 | bttv_gpio_tracking(btv,"extern write"); |
| 114 | return 0; |
| 115 | } |
| 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | /* |
| 118 | * Local variables: |
| 119 | * c-basic-offset: 8 |
| 120 | * End: |
| 121 | */ |