cx23885-cards.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Driver for the Conexant CX23885 PCIe bridge
  3. *
  4. * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. *
  15. * GNU General Public License for more details.
  16. *
  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/init.h>
  22. #include <linux/module.h>
  23. #include <linux/pci.h>
  24. #include <linux/delay.h>
  25. #include "cx23885.h"
  26. /* ------------------------------------------------------------------ */
  27. /* board config info */
  28. struct cx23885_board cx23885_boards[] = {
  29. [CX23885_BOARD_UNKNOWN] = {
  30. .name = "UNKNOWN/GENERIC",
  31. .input = {{
  32. .type = CX23885_VMUX_COMPOSITE1,
  33. .vmux = 0,
  34. },{
  35. .type = CX23885_VMUX_COMPOSITE2,
  36. .vmux = 1,
  37. },{
  38. .type = CX23885_VMUX_COMPOSITE3,
  39. .vmux = 2,
  40. },{
  41. .type = CX23885_VMUX_COMPOSITE4,
  42. .vmux = 3,
  43. }},
  44. },
  45. [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = {
  46. .name = "Hauppauge WinTV-HVR1800lp",
  47. .portc = CX23885_MPEG_DVB,
  48. .input = {{
  49. .type = CX23885_VMUX_TELEVISION,
  50. .vmux = 0,
  51. .gpio0 = 0xff00,
  52. },{
  53. .type = CX23885_VMUX_DEBUG,
  54. .vmux = 0,
  55. .gpio0 = 0xff01,
  56. },{
  57. .type = CX23885_VMUX_COMPOSITE1,
  58. .vmux = 1,
  59. .gpio0 = 0xff02,
  60. },{
  61. .type = CX23885_VMUX_SVIDEO,
  62. .vmux = 2,
  63. .gpio0 = 0xff02,
  64. }},
  65. },
  66. [CX23885_BOARD_HAUPPAUGE_HVR1800] = {
  67. .name = "Hauppauge WinTV-HVR1800",
  68. .portc = CX23885_MPEG_DVB,
  69. .input = {{
  70. .type = CX23885_VMUX_TELEVISION,
  71. .vmux = 0,
  72. .gpio0 = 0xff00,
  73. },{
  74. .type = CX23885_VMUX_DEBUG,
  75. .vmux = 0,
  76. .gpio0 = 0xff01,
  77. },{
  78. .type = CX23885_VMUX_COMPOSITE1,
  79. .vmux = 1,
  80. .gpio0 = 0xff02,
  81. },{
  82. .type = CX23885_VMUX_SVIDEO,
  83. .vmux = 2,
  84. .gpio0 = 0xff02,
  85. }},
  86. },
  87. [CX23885_BOARD_HAUPPAUGE_HVR1250] = {
  88. .name = "Hauppauge WinTV-HVR1250",
  89. .portc = CX23885_MPEG_DVB,
  90. .input = {{
  91. .type = CX23885_VMUX_TELEVISION,
  92. .vmux = 0,
  93. .gpio0 = 0xff00,
  94. },{
  95. .type = CX23885_VMUX_DEBUG,
  96. .vmux = 0,
  97. .gpio0 = 0xff01,
  98. },{
  99. .type = CX23885_VMUX_COMPOSITE1,
  100. .vmux = 1,
  101. .gpio0 = 0xff02,
  102. },{
  103. .type = CX23885_VMUX_SVIDEO,
  104. .vmux = 2,
  105. .gpio0 = 0xff02,
  106. }},
  107. },
  108. };
  109. const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
  110. /* ------------------------------------------------------------------ */
  111. /* PCI subsystem IDs */
  112. struct cx23885_subid cx23885_subids[] = {
  113. {
  114. .subvendor = 0x0070,
  115. .subdevice = 0x3400,
  116. .card = CX23885_BOARD_UNKNOWN,
  117. },{
  118. .subvendor = 0x0070,
  119. .subdevice = 0x7600,
  120. .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
  121. },{
  122. .subvendor = 0x0070,
  123. .subdevice = 0x7800,
  124. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  125. },{
  126. .subvendor = 0x0070,
  127. .subdevice = 0x7801,
  128. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  129. },{
  130. .subvendor = 0x0070,
  131. .subdevice = 0x7911,
  132. .card = CX23885_BOARD_HAUPPAUGE_HVR1250,
  133. },
  134. };
  135. const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
  136. void cx23885_card_list(struct cx23885_dev *dev)
  137. {
  138. int i;
  139. if (0 == dev->pci->subsystem_vendor &&
  140. 0 == dev->pci->subsystem_device) {
  141. printk("%s: Your board has no valid PCIe Subsystem ID and thus can't\n"
  142. "%s: be autodetected. Please pass card=<n> insmod option to\n"
  143. "%s: workaround that. Redirect complaints to the vendor of\n"
  144. "%s: the TV card. Best regards,\n"
  145. "%s: -- tux\n",
  146. dev->name, dev->name, dev->name, dev->name, dev->name);
  147. } else {
  148. printk("%s: Your board isn't known (yet) to the driver. You can\n"
  149. "%s: try to pick one of the existing card configs via\n"
  150. "%s: card=<n> insmod option. Updating to the latest\n"
  151. "%s: version might help as well.\n",
  152. dev->name, dev->name, dev->name, dev->name);
  153. }
  154. printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
  155. dev->name);
  156. for (i = 0; i < cx23885_bcount; i++)
  157. printk("%s: card=%d -> %s\n",
  158. dev->name, i, cx23885_boards[i].name);
  159. }
  160. static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
  161. {
  162. struct tveeprom tv;
  163. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, eeprom_data);
  164. /* Make sure we support the board model */
  165. switch (tv.model)
  166. {
  167. case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */
  168. case 77001: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */
  169. case 78501: /* WinTV-HVR1800 (PCIe, Retail, IR, Dual channel ATSC and MPEG2 HW Encoder */
  170. case 78521: /* WinTV-HVR1800 (PCIe, Retail, IR, Dual channel ATSC and MPEG2 HW Encoder */
  171. break;
  172. default:
  173. printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model);
  174. break;
  175. }
  176. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
  177. dev->name, tv.model);
  178. }
  179. void cx23885_card_setup(struct cx23885_dev *dev)
  180. {
  181. static u8 eeprom[256];
  182. if (dev->i2c_bus[0].i2c_rc == 0) {
  183. dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
  184. tveeprom_read(&dev->i2c_bus[0].i2c_client,
  185. eeprom, sizeof(eeprom));
  186. }
  187. switch (dev->board) {
  188. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  189. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  190. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  191. if (dev->i2c_bus[0].i2c_rc == 0)
  192. hauppauge_eeprom(dev, eeprom+0x80);
  193. break;
  194. }
  195. }
  196. /* ------------------------------------------------------------------ */
  197. EXPORT_SYMBOL(cx23885_boards);
  198. /*
  199. * Local variables:
  200. * c-basic-offset: 8
  201. * End:
  202. * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off
  203. */