bttv-if.c 2.7 KB

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