bttv-if.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. $Id: bttv-if.c,v 1.4 2004/11/17 18:47:47 kraxel Exp $
  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. bttv - Bt848 frame grabber driver
  7. Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
  8. & Marcus Metzler (mocm@thp.uni-koeln.de)
  9. (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include <linux/module.h>
  23. #include <linux/init.h>
  24. #include <linux/delay.h>
  25. #include <asm/io.h>
  26. #include "bttvp.h"
  27. EXPORT_SYMBOL(bttv_get_cardinfo);
  28. EXPORT_SYMBOL(bttv_get_pcidev);
  29. EXPORT_SYMBOL(bttv_get_id);
  30. EXPORT_SYMBOL(bttv_gpio_enable);
  31. EXPORT_SYMBOL(bttv_read_gpio);
  32. EXPORT_SYMBOL(bttv_write_gpio);
  33. EXPORT_SYMBOL(bttv_get_gpio_queue);
  34. EXPORT_SYMBOL(bttv_i2c_call);
  35. /* ----------------------------------------------------------------------- */
  36. /* Exported functions - for other modules which want to access the */
  37. /* gpio ports (IR for example) */
  38. /* see bttv.h for comments */
  39. int bttv_get_cardinfo(unsigned int card, int *type, unsigned *cardid)
  40. {
  41. printk("The bttv_* interface is obsolete and will go away,\n"
  42. "please use the new, sysfs based interface instead.\n");
  43. if (card >= bttv_num) {
  44. return -1;
  45. }
  46. *type = bttvs[card].c.type;
  47. *cardid = bttvs[card].cardid;
  48. return 0;
  49. }
  50. struct pci_dev* bttv_get_pcidev(unsigned int card)
  51. {
  52. if (card >= bttv_num)
  53. return NULL;
  54. return bttvs[card].c.pci;
  55. }
  56. int bttv_get_id(unsigned int card)
  57. {
  58. printk("The bttv_* interface is obsolete and will go away,\n"
  59. "please use the new, sysfs based interface instead.\n");
  60. if (card >= bttv_num) {
  61. return -1;
  62. }
  63. return bttvs[card].c.type;
  64. }
  65. int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data)
  66. {
  67. struct bttv *btv;
  68. if (card >= bttv_num) {
  69. return -EINVAL;
  70. }
  71. btv = &bttvs[card];
  72. gpio_inout(mask,data);
  73. if (bttv_gpio)
  74. bttv_gpio_tracking(btv,"extern enable");
  75. return 0;
  76. }
  77. int bttv_read_gpio(unsigned int card, unsigned long *data)
  78. {
  79. struct bttv *btv;
  80. if (card >= bttv_num) {
  81. return -EINVAL;
  82. }
  83. btv = &bttvs[card];
  84. if(btv->shutdown) {
  85. return -ENODEV;
  86. }
  87. /* prior setting BT848_GPIO_REG_INP is (probably) not needed
  88. because we set direct input on init */
  89. *data = gpio_read();
  90. return 0;
  91. }
  92. int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data)
  93. {
  94. struct bttv *btv;
  95. if (card >= bttv_num) {
  96. return -EINVAL;
  97. }
  98. btv = &bttvs[card];
  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. wait_queue_head_t* bttv_get_gpio_queue(unsigned int card)
  107. {
  108. struct bttv *btv;
  109. if (card >= bttv_num) {
  110. return NULL;
  111. }
  112. btv = &bttvs[card];
  113. if (bttvs[card].shutdown) {
  114. return NULL;
  115. }
  116. return &btv->gpioq;
  117. }
  118. void bttv_i2c_call(unsigned int card, unsigned int cmd, void *arg)
  119. {
  120. if (card >= bttv_num)
  121. return;
  122. bttv_call_i2c_clients(&bttvs[card], cmd, arg);
  123. }
  124. /*
  125. * Local variables:
  126. * c-basic-offset: 8
  127. * End:
  128. */