bttv-if.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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_cardinfo);
  27. EXPORT_SYMBOL(bttv_get_pcidev);
  28. EXPORT_SYMBOL(bttv_get_id);
  29. EXPORT_SYMBOL(bttv_gpio_enable);
  30. EXPORT_SYMBOL(bttv_read_gpio);
  31. EXPORT_SYMBOL(bttv_write_gpio);
  32. EXPORT_SYMBOL(bttv_get_gpio_queue);
  33. EXPORT_SYMBOL(bttv_i2c_call);
  34. /* ----------------------------------------------------------------------- */
  35. /* Exported functions - for other modules which want to access the */
  36. /* gpio ports (IR for example) */
  37. /* see bttv.h for comments */
  38. int bttv_get_cardinfo(unsigned int card, int *type, unsigned *cardid)
  39. {
  40. printk("The bttv_* interface is obsolete and will go away,\n"
  41. "please use the new, sysfs based interface instead.\n");
  42. if (card >= bttv_num) {
  43. return -1;
  44. }
  45. *type = bttvs[card].c.type;
  46. *cardid = bttvs[card].cardid;
  47. return 0;
  48. }
  49. struct pci_dev* bttv_get_pcidev(unsigned int card)
  50. {
  51. if (card >= bttv_num)
  52. return NULL;
  53. return bttvs[card].c.pci;
  54. }
  55. int bttv_get_id(unsigned int card)
  56. {
  57. printk("The bttv_* interface is obsolete and will go away,\n"
  58. "please use the new, sysfs based interface instead.\n");
  59. if (card >= bttv_num) {
  60. return -1;
  61. }
  62. return bttvs[card].c.type;
  63. }
  64. int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data)
  65. {
  66. struct bttv *btv;
  67. if (card >= bttv_num) {
  68. return -EINVAL;
  69. }
  70. btv = &bttvs[card];
  71. gpio_inout(mask,data);
  72. if (bttv_gpio)
  73. bttv_gpio_tracking(btv,"extern enable");
  74. return 0;
  75. }
  76. int bttv_read_gpio(unsigned int card, unsigned long *data)
  77. {
  78. struct bttv *btv;
  79. if (card >= bttv_num) {
  80. return -EINVAL;
  81. }
  82. btv = &bttvs[card];
  83. if(btv->shutdown) {
  84. return -ENODEV;
  85. }
  86. /* prior setting BT848_GPIO_REG_INP is (probably) not needed
  87. because we set direct input on init */
  88. *data = gpio_read();
  89. return 0;
  90. }
  91. int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data)
  92. {
  93. struct bttv *btv;
  94. if (card >= bttv_num) {
  95. return -EINVAL;
  96. }
  97. btv = &bttvs[card];
  98. /* prior setting BT848_GPIO_REG_INP is (probably) not needed
  99. because direct input is set on init */
  100. gpio_bits(mask,data);
  101. if (bttv_gpio)
  102. bttv_gpio_tracking(btv,"extern write");
  103. return 0;
  104. }
  105. wait_queue_head_t* bttv_get_gpio_queue(unsigned int card)
  106. {
  107. struct bttv *btv;
  108. if (card >= bttv_num) {
  109. return NULL;
  110. }
  111. btv = &bttvs[card];
  112. if (bttvs[card].shutdown) {
  113. return NULL;
  114. }
  115. return &btv->gpioq;
  116. }
  117. void bttv_i2c_call(unsigned int card, unsigned int cmd, void *arg)
  118. {
  119. if (card >= bttv_num)
  120. return;
  121. bttv_call_i2c_clients(&bttvs[card], cmd, arg);
  122. }
  123. /*
  124. * Local variables:
  125. * c-basic-offset: 8
  126. * End:
  127. */