bttv-if.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. if (!bttvs[card])
  39. return NULL;
  40. return bttvs[card]->c.pci;
  41. }
  42. int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data)
  43. {
  44. struct bttv *btv;
  45. if (card >= bttv_num) {
  46. return -EINVAL;
  47. }
  48. btv = bttvs[card];
  49. if (!btv)
  50. return -ENODEV;
  51. gpio_inout(mask,data);
  52. if (bttv_gpio)
  53. bttv_gpio_tracking(btv,"extern enable");
  54. return 0;
  55. }
  56. int bttv_read_gpio(unsigned int card, unsigned long *data)
  57. {
  58. struct bttv *btv;
  59. if (card >= bttv_num) {
  60. return -EINVAL;
  61. }
  62. btv = bttvs[card];
  63. if (!btv)
  64. return -ENODEV;
  65. if(btv->shutdown) {
  66. return -ENODEV;
  67. }
  68. /* prior setting BT848_GPIO_REG_INP is (probably) not needed
  69. because we set direct input on init */
  70. *data = gpio_read();
  71. return 0;
  72. }
  73. int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data)
  74. {
  75. struct bttv *btv;
  76. if (card >= bttv_num) {
  77. return -EINVAL;
  78. }
  79. btv = bttvs[card];
  80. if (!btv)
  81. return -ENODEV;
  82. /* prior setting BT848_GPIO_REG_INP is (probably) not needed
  83. because direct input is set on init */
  84. gpio_bits(mask,data);
  85. if (bttv_gpio)
  86. bttv_gpio_tracking(btv,"extern write");
  87. return 0;
  88. }