saa7164-cards.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. /*
  2. * Driver for the NXP SAA7164 PCIe bridge
  3. *
  4. * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.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. #include <linux/init.h>
  18. #include <linux/module.h>
  19. #include <linux/pci.h>
  20. #include <linux/delay.h>
  21. #include "saa7164.h"
  22. /* The Bridge API needs to understand register widths (in bytes) for the
  23. * attached I2C devices, so we can simplify the virtual i2c mechansms
  24. * and keep the -i2c.c implementation clean.
  25. */
  26. #define REGLEN_0bit 0
  27. #define REGLEN_8bit 1
  28. #define REGLEN_16bit 2
  29. struct saa7164_board saa7164_boards[] = {
  30. [SAA7164_BOARD_UNKNOWN] = {
  31. /* Bridge will not load any firmware, without knowing
  32. * the rev this would be fatal. */
  33. .name = "Unknown",
  34. },
  35. [SAA7164_BOARD_UNKNOWN_REV2] = {
  36. /* Bridge will load the v2 f/w and dump descriptors */
  37. /* Required during new board bringup */
  38. .name = "Generic Rev2",
  39. .chiprev = SAA7164_CHIP_REV2,
  40. },
  41. [SAA7164_BOARD_UNKNOWN_REV3] = {
  42. /* Bridge will load the v2 f/w and dump descriptors */
  43. /* Required during new board bringup */
  44. .name = "Generic Rev3",
  45. .chiprev = SAA7164_CHIP_REV3,
  46. },
  47. [SAA7164_BOARD_HAUPPAUGE_HVR2200] = {
  48. .name = "Hauppauge WinTV-HVR2200",
  49. .porta = SAA7164_MPEG_DVB,
  50. .portb = SAA7164_MPEG_DVB,
  51. .portc = SAA7164_MPEG_ENCODER,
  52. .portd = SAA7164_MPEG_ENCODER,
  53. .porte = SAA7164_MPEG_VBI,
  54. .portf = SAA7164_MPEG_VBI,
  55. .chiprev = SAA7164_CHIP_REV3,
  56. .unit = {{
  57. .id = 0x1d,
  58. .type = SAA7164_UNIT_EEPROM,
  59. .name = "4K EEPROM",
  60. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  61. .i2c_bus_addr = 0xa0 >> 1,
  62. .i2c_reg_len = REGLEN_8bit,
  63. }, {
  64. .id = 0x04,
  65. .type = SAA7164_UNIT_TUNER,
  66. .name = "TDA18271-1",
  67. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  68. .i2c_bus_addr = 0xc0 >> 1,
  69. .i2c_reg_len = REGLEN_8bit,
  70. }, {
  71. .id = 0x1b,
  72. .type = SAA7164_UNIT_TUNER,
  73. .name = "TDA18271-2",
  74. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  75. .i2c_bus_addr = 0xc0 >> 1,
  76. .i2c_reg_len = REGLEN_8bit,
  77. }, {
  78. .id = 0x1e,
  79. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  80. .name = "TDA10048-1",
  81. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  82. .i2c_bus_addr = 0x10 >> 1,
  83. .i2c_reg_len = REGLEN_8bit,
  84. }, {
  85. .id = 0x1f,
  86. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  87. .name = "TDA10048-2",
  88. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  89. .i2c_bus_addr = 0x12 >> 1,
  90. .i2c_reg_len = REGLEN_8bit,
  91. } },
  92. },
  93. [SAA7164_BOARD_HAUPPAUGE_HVR2200_2] = {
  94. .name = "Hauppauge WinTV-HVR2200",
  95. .porta = SAA7164_MPEG_DVB,
  96. .portb = SAA7164_MPEG_DVB,
  97. .portc = SAA7164_MPEG_ENCODER,
  98. .portd = SAA7164_MPEG_ENCODER,
  99. .porte = SAA7164_MPEG_VBI,
  100. .portf = SAA7164_MPEG_VBI,
  101. .chiprev = SAA7164_CHIP_REV2,
  102. .unit = {{
  103. .id = 0x06,
  104. .type = SAA7164_UNIT_EEPROM,
  105. .name = "4K EEPROM",
  106. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  107. .i2c_bus_addr = 0xa0 >> 1,
  108. .i2c_reg_len = REGLEN_8bit,
  109. }, {
  110. .id = 0x04,
  111. .type = SAA7164_UNIT_TUNER,
  112. .name = "TDA18271-1",
  113. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  114. .i2c_bus_addr = 0xc0 >> 1,
  115. .i2c_reg_len = REGLEN_8bit,
  116. }, {
  117. .id = 0x05,
  118. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  119. .name = "TDA10048-1",
  120. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  121. .i2c_bus_addr = 0x10 >> 1,
  122. .i2c_reg_len = REGLEN_8bit,
  123. }, {
  124. .id = 0x1e,
  125. .type = SAA7164_UNIT_TUNER,
  126. .name = "TDA18271-2",
  127. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  128. .i2c_bus_addr = 0xc0 >> 1,
  129. .i2c_reg_len = REGLEN_8bit,
  130. }, {
  131. .id = 0x1f,
  132. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  133. .name = "TDA10048-2",
  134. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  135. .i2c_bus_addr = 0x12 >> 1,
  136. .i2c_reg_len = REGLEN_8bit,
  137. } },
  138. },
  139. [SAA7164_BOARD_HAUPPAUGE_HVR2200_3] = {
  140. .name = "Hauppauge WinTV-HVR2200",
  141. .porta = SAA7164_MPEG_DVB,
  142. .portb = SAA7164_MPEG_DVB,
  143. .portc = SAA7164_MPEG_ENCODER,
  144. .portd = SAA7164_MPEG_ENCODER,
  145. .porte = SAA7164_MPEG_VBI,
  146. .portf = SAA7164_MPEG_VBI,
  147. .chiprev = SAA7164_CHIP_REV2,
  148. .unit = {{
  149. .id = 0x1d,
  150. .type = SAA7164_UNIT_EEPROM,
  151. .name = "4K EEPROM",
  152. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  153. .i2c_bus_addr = 0xa0 >> 1,
  154. .i2c_reg_len = REGLEN_8bit,
  155. }, {
  156. .id = 0x04,
  157. .type = SAA7164_UNIT_TUNER,
  158. .name = "TDA18271-1",
  159. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  160. .i2c_bus_addr = 0xc0 >> 1,
  161. .i2c_reg_len = REGLEN_8bit,
  162. }, {
  163. .id = 0x05,
  164. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  165. .name = "TDA8290-1",
  166. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  167. .i2c_bus_addr = 0x84 >> 1,
  168. .i2c_reg_len = REGLEN_8bit,
  169. }, {
  170. .id = 0x1b,
  171. .type = SAA7164_UNIT_TUNER,
  172. .name = "TDA18271-2",
  173. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  174. .i2c_bus_addr = 0xc0 >> 1,
  175. .i2c_reg_len = REGLEN_8bit,
  176. }, {
  177. .id = 0x1c,
  178. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  179. .name = "TDA8290-2",
  180. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  181. .i2c_bus_addr = 0x84 >> 1,
  182. .i2c_reg_len = REGLEN_8bit,
  183. }, {
  184. .id = 0x1e,
  185. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  186. .name = "TDA10048-1",
  187. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  188. .i2c_bus_addr = 0x10 >> 1,
  189. .i2c_reg_len = REGLEN_8bit,
  190. }, {
  191. .id = 0x1f,
  192. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  193. .name = "TDA10048-2",
  194. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  195. .i2c_bus_addr = 0x12 >> 1,
  196. .i2c_reg_len = REGLEN_8bit,
  197. } },
  198. },
  199. [SAA7164_BOARD_HAUPPAUGE_HVR2200_4] = {
  200. .name = "Hauppauge WinTV-HVR2200",
  201. .porta = SAA7164_MPEG_DVB,
  202. .portb = SAA7164_MPEG_DVB,
  203. .portc = SAA7164_MPEG_ENCODER,
  204. .portd = SAA7164_MPEG_ENCODER,
  205. .porte = SAA7164_MPEG_VBI,
  206. .portf = SAA7164_MPEG_VBI,
  207. .chiprev = SAA7164_CHIP_REV3,
  208. .unit = {{
  209. .id = 0x1d,
  210. .type = SAA7164_UNIT_EEPROM,
  211. .name = "4K EEPROM",
  212. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  213. .i2c_bus_addr = 0xa0 >> 1,
  214. .i2c_reg_len = REGLEN_8bit,
  215. }, {
  216. .id = 0x04,
  217. .type = SAA7164_UNIT_TUNER,
  218. .name = "TDA18271-1",
  219. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  220. .i2c_bus_addr = 0xc0 >> 1,
  221. .i2c_reg_len = REGLEN_8bit,
  222. }, {
  223. .id = 0x05,
  224. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  225. .name = "TDA8290-1",
  226. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  227. .i2c_bus_addr = 0x84 >> 1,
  228. .i2c_reg_len = REGLEN_8bit,
  229. }, {
  230. .id = 0x1b,
  231. .type = SAA7164_UNIT_TUNER,
  232. .name = "TDA18271-2",
  233. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  234. .i2c_bus_addr = 0xc0 >> 1,
  235. .i2c_reg_len = REGLEN_8bit,
  236. }, {
  237. .id = 0x1c,
  238. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  239. .name = "TDA8290-2",
  240. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  241. .i2c_bus_addr = 0x84 >> 1,
  242. .i2c_reg_len = REGLEN_8bit,
  243. }, {
  244. .id = 0x1e,
  245. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  246. .name = "TDA10048-1",
  247. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  248. .i2c_bus_addr = 0x10 >> 1,
  249. .i2c_reg_len = REGLEN_8bit,
  250. }, {
  251. .id = 0x1f,
  252. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  253. .name = "TDA10048-2",
  254. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  255. .i2c_bus_addr = 0x12 >> 1,
  256. .i2c_reg_len = REGLEN_8bit,
  257. } },
  258. },
  259. [SAA7164_BOARD_HAUPPAUGE_HVR2250] = {
  260. .name = "Hauppauge WinTV-HVR2250",
  261. .porta = SAA7164_MPEG_DVB,
  262. .portb = SAA7164_MPEG_DVB,
  263. .portc = SAA7164_MPEG_ENCODER,
  264. .portd = SAA7164_MPEG_ENCODER,
  265. .porte = SAA7164_MPEG_VBI,
  266. .portf = SAA7164_MPEG_VBI,
  267. .chiprev = SAA7164_CHIP_REV3,
  268. .unit = {{
  269. .id = 0x22,
  270. .type = SAA7164_UNIT_EEPROM,
  271. .name = "4K EEPROM",
  272. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  273. .i2c_bus_addr = 0xa0 >> 1,
  274. .i2c_reg_len = REGLEN_8bit,
  275. }, {
  276. .id = 0x04,
  277. .type = SAA7164_UNIT_TUNER,
  278. .name = "TDA18271-1",
  279. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  280. .i2c_bus_addr = 0xc0 >> 1,
  281. .i2c_reg_len = REGLEN_8bit,
  282. }, {
  283. .id = 0x07,
  284. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  285. .name = "CX24228/S5H1411-1 (TOP)",
  286. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  287. .i2c_bus_addr = 0x32 >> 1,
  288. .i2c_reg_len = REGLEN_8bit,
  289. }, {
  290. .id = 0x08,
  291. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  292. .name = "CX24228/S5H1411-1 (QAM)",
  293. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  294. .i2c_bus_addr = 0x34 >> 1,
  295. .i2c_reg_len = REGLEN_8bit,
  296. }, {
  297. .id = 0x1e,
  298. .type = SAA7164_UNIT_TUNER,
  299. .name = "TDA18271-2",
  300. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  301. .i2c_bus_addr = 0xc0 >> 1,
  302. .i2c_reg_len = REGLEN_8bit,
  303. }, {
  304. .id = 0x20,
  305. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  306. .name = "CX24228/S5H1411-2 (TOP)",
  307. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  308. .i2c_bus_addr = 0x32 >> 1,
  309. .i2c_reg_len = REGLEN_8bit,
  310. }, {
  311. .id = 0x23,
  312. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  313. .name = "CX24228/S5H1411-2 (QAM)",
  314. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  315. .i2c_bus_addr = 0x34 >> 1,
  316. .i2c_reg_len = REGLEN_8bit,
  317. } },
  318. },
  319. [SAA7164_BOARD_HAUPPAUGE_HVR2250_2] = {
  320. .name = "Hauppauge WinTV-HVR2250",
  321. .porta = SAA7164_MPEG_DVB,
  322. .portb = SAA7164_MPEG_DVB,
  323. .portc = SAA7164_MPEG_ENCODER,
  324. .portd = SAA7164_MPEG_ENCODER,
  325. .porte = SAA7164_MPEG_VBI,
  326. .portf = SAA7164_MPEG_VBI,
  327. .chiprev = SAA7164_CHIP_REV3,
  328. .unit = {{
  329. .id = 0x28,
  330. .type = SAA7164_UNIT_EEPROM,
  331. .name = "4K EEPROM",
  332. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  333. .i2c_bus_addr = 0xa0 >> 1,
  334. .i2c_reg_len = REGLEN_8bit,
  335. }, {
  336. .id = 0x04,
  337. .type = SAA7164_UNIT_TUNER,
  338. .name = "TDA18271-1",
  339. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  340. .i2c_bus_addr = 0xc0 >> 1,
  341. .i2c_reg_len = REGLEN_8bit,
  342. }, {
  343. .id = 0x07,
  344. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  345. .name = "CX24228/S5H1411-1 (TOP)",
  346. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  347. .i2c_bus_addr = 0x32 >> 1,
  348. .i2c_reg_len = REGLEN_8bit,
  349. }, {
  350. .id = 0x08,
  351. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  352. .name = "CX24228/S5H1411-1 (QAM)",
  353. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  354. .i2c_bus_addr = 0x34 >> 1,
  355. .i2c_reg_len = REGLEN_8bit,
  356. }, {
  357. .id = 0x24,
  358. .type = SAA7164_UNIT_TUNER,
  359. .name = "TDA18271-2",
  360. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  361. .i2c_bus_addr = 0xc0 >> 1,
  362. .i2c_reg_len = REGLEN_8bit,
  363. }, {
  364. .id = 0x26,
  365. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  366. .name = "CX24228/S5H1411-2 (TOP)",
  367. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  368. .i2c_bus_addr = 0x32 >> 1,
  369. .i2c_reg_len = REGLEN_8bit,
  370. }, {
  371. .id = 0x29,
  372. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  373. .name = "CX24228/S5H1411-2 (QAM)",
  374. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  375. .i2c_bus_addr = 0x34 >> 1,
  376. .i2c_reg_len = REGLEN_8bit,
  377. } },
  378. },
  379. [SAA7164_BOARD_HAUPPAUGE_HVR2250_3] = {
  380. .name = "Hauppauge WinTV-HVR2250",
  381. .porta = SAA7164_MPEG_DVB,
  382. .portb = SAA7164_MPEG_DVB,
  383. .portc = SAA7164_MPEG_ENCODER,
  384. .portd = SAA7164_MPEG_ENCODER,
  385. .porte = SAA7164_MPEG_VBI,
  386. .portf = SAA7164_MPEG_VBI,
  387. .chiprev = SAA7164_CHIP_REV3,
  388. .unit = {{
  389. .id = 0x26,
  390. .type = SAA7164_UNIT_EEPROM,
  391. .name = "4K EEPROM",
  392. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  393. .i2c_bus_addr = 0xa0 >> 1,
  394. .i2c_reg_len = REGLEN_8bit,
  395. }, {
  396. .id = 0x04,
  397. .type = SAA7164_UNIT_TUNER,
  398. .name = "TDA18271-1",
  399. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  400. .i2c_bus_addr = 0xc0 >> 1,
  401. .i2c_reg_len = REGLEN_8bit,
  402. }, {
  403. .id = 0x07,
  404. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  405. .name = "CX24228/S5H1411-1 (TOP)",
  406. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  407. .i2c_bus_addr = 0x32 >> 1,
  408. .i2c_reg_len = REGLEN_8bit,
  409. }, {
  410. .id = 0x08,
  411. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  412. .name = "CX24228/S5H1411-1 (QAM)",
  413. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  414. .i2c_bus_addr = 0x34 >> 1,
  415. .i2c_reg_len = REGLEN_8bit,
  416. }, {
  417. .id = 0x22,
  418. .type = SAA7164_UNIT_TUNER,
  419. .name = "TDA18271-2",
  420. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  421. .i2c_bus_addr = 0xc0 >> 1,
  422. .i2c_reg_len = REGLEN_8bit,
  423. }, {
  424. .id = 0x24,
  425. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  426. .name = "CX24228/S5H1411-2 (TOP)",
  427. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  428. .i2c_bus_addr = 0x32 >> 1,
  429. .i2c_reg_len = REGLEN_8bit,
  430. }, {
  431. .id = 0x27,
  432. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  433. .name = "CX24228/S5H1411-2 (QAM)",
  434. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  435. .i2c_bus_addr = 0x34 >> 1,
  436. .i2c_reg_len = REGLEN_8bit,
  437. } },
  438. },
  439. [SAA7164_BOARD_HAUPPAUGE_HVR2200_5] = {
  440. .name = "Hauppauge WinTV-HVR2200",
  441. .porta = SAA7164_MPEG_DVB,
  442. .portb = SAA7164_MPEG_DVB,
  443. .chiprev = SAA7164_CHIP_REV3,
  444. .unit = {{
  445. .id = 0x23,
  446. .type = SAA7164_UNIT_EEPROM,
  447. .name = "4K EEPROM",
  448. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  449. .i2c_bus_addr = 0xa0 >> 1,
  450. .i2c_reg_len = REGLEN_8bit,
  451. }, {
  452. .id = 0x04,
  453. .type = SAA7164_UNIT_TUNER,
  454. .name = "TDA18271-1",
  455. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  456. .i2c_bus_addr = 0xc0 >> 1,
  457. .i2c_reg_len = REGLEN_8bit,
  458. }, {
  459. .id = 0x05,
  460. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  461. .name = "TDA8290-1",
  462. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  463. .i2c_bus_addr = 0x84 >> 1,
  464. .i2c_reg_len = REGLEN_8bit,
  465. }, {
  466. .id = 0x21,
  467. .type = SAA7164_UNIT_TUNER,
  468. .name = "TDA18271-2",
  469. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  470. .i2c_bus_addr = 0xc0 >> 1,
  471. .i2c_reg_len = REGLEN_8bit,
  472. }, {
  473. .id = 0x22,
  474. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  475. .name = "TDA8290-2",
  476. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  477. .i2c_bus_addr = 0x84 >> 1,
  478. .i2c_reg_len = REGLEN_8bit,
  479. }, {
  480. .id = 0x24,
  481. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  482. .name = "TDA10048-1",
  483. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  484. .i2c_bus_addr = 0x10 >> 1,
  485. .i2c_reg_len = REGLEN_8bit,
  486. }, {
  487. .id = 0x25,
  488. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  489. .name = "TDA10048-2",
  490. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  491. .i2c_bus_addr = 0x12 >> 1,
  492. .i2c_reg_len = REGLEN_8bit,
  493. } },
  494. },
  495. [SAA7164_BOARD_HAUPPAUGE_HVR2255proto] = {
  496. .name = "Hauppauge WinTV-HVR2255(proto)",
  497. .porta = SAA7164_MPEG_DVB,
  498. .portb = SAA7164_MPEG_DVB,
  499. .portc = SAA7164_MPEG_ENCODER,
  500. .portd = SAA7164_MPEG_ENCODER,
  501. .porte = SAA7164_MPEG_VBI,
  502. .portf = SAA7164_MPEG_VBI,
  503. .chiprev = SAA7164_CHIP_REV3,
  504. .unit = {{
  505. .id = 0x27,
  506. .type = SAA7164_UNIT_EEPROM,
  507. .name = "4K EEPROM",
  508. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  509. .i2c_bus_addr = 0xa0 >> 1,
  510. .i2c_reg_len = REGLEN_8bit,
  511. }, {
  512. .id = 0x04,
  513. .type = SAA7164_UNIT_TUNER,
  514. .name = "SI2157-1",
  515. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  516. .i2c_bus_addr = 0xc0 >> 1,
  517. .i2c_reg_len = REGLEN_0bit,
  518. }, {
  519. .id = 0x06,
  520. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  521. .name = "LGDT3306",
  522. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  523. .i2c_bus_addr = 0xb2 >> 1,
  524. .i2c_reg_len = REGLEN_8bit,
  525. }, {
  526. .id = 0x24,
  527. .type = SAA7164_UNIT_TUNER,
  528. .name = "SI2157-2",
  529. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  530. .i2c_bus_addr = 0xc0 >> 1,
  531. .i2c_reg_len = REGLEN_0bit,
  532. }, {
  533. .id = 0x26,
  534. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  535. .name = "LGDT3306-2",
  536. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  537. .i2c_bus_addr = 0x1c >> 1,
  538. .i2c_reg_len = REGLEN_8bit,
  539. } },
  540. },
  541. [SAA7164_BOARD_HAUPPAUGE_HVR2255] = {
  542. .name = "Hauppauge WinTV-HVR2255",
  543. .porta = SAA7164_MPEG_DVB,
  544. .portb = SAA7164_MPEG_DVB,
  545. .portc = SAA7164_MPEG_ENCODER,
  546. .portd = SAA7164_MPEG_ENCODER,
  547. .porte = SAA7164_MPEG_VBI,
  548. .portf = SAA7164_MPEG_VBI,
  549. .chiprev = SAA7164_CHIP_REV3,
  550. .unit = {{
  551. .id = 0x28,
  552. .type = SAA7164_UNIT_EEPROM,
  553. .name = "4K EEPROM",
  554. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  555. .i2c_bus_addr = 0xa0 >> 1,
  556. .i2c_reg_len = REGLEN_8bit,
  557. }, {
  558. .id = 0x04,
  559. .type = SAA7164_UNIT_TUNER,
  560. .name = "SI2157-1",
  561. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  562. .i2c_bus_addr = 0xc0 >> 1,
  563. .i2c_reg_len = REGLEN_0bit,
  564. }, {
  565. .id = 0x06,
  566. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  567. .name = "LGDT3306-1",
  568. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  569. .i2c_bus_addr = 0xb2 >> 1,
  570. .i2c_reg_len = REGLEN_8bit,
  571. }, {
  572. .id = 0x25,
  573. .type = SAA7164_UNIT_TUNER,
  574. .name = "SI2157-2",
  575. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  576. .i2c_bus_addr = 0xc0 >> 1,
  577. .i2c_reg_len = REGLEN_0bit,
  578. }, {
  579. .id = 0x27,
  580. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  581. .name = "LGDT3306-2",
  582. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  583. .i2c_bus_addr = 0x1c >> 1,
  584. .i2c_reg_len = REGLEN_8bit,
  585. } },
  586. },
  587. [SAA7164_BOARD_HAUPPAUGE_HVR2205] = {
  588. .name = "Hauppauge WinTV-HVR2205",
  589. .porta = SAA7164_MPEG_DVB,
  590. .portb = SAA7164_MPEG_DVB,
  591. .portc = SAA7164_MPEG_ENCODER,
  592. .portd = SAA7164_MPEG_ENCODER,
  593. .porte = SAA7164_MPEG_VBI,
  594. .portf = SAA7164_MPEG_VBI,
  595. .chiprev = SAA7164_CHIP_REV3,
  596. .unit = {{
  597. .id = 0x28,
  598. .type = SAA7164_UNIT_EEPROM,
  599. .name = "4K EEPROM",
  600. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  601. .i2c_bus_addr = 0xa0 >> 1,
  602. .i2c_reg_len = REGLEN_8bit,
  603. }, {
  604. .id = 0x04,
  605. .type = SAA7164_UNIT_TUNER,
  606. .name = "SI2157-1",
  607. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  608. .i2c_bus_addr = 0xc0 >> 1,
  609. .i2c_reg_len = REGLEN_0bit,
  610. }, {
  611. .id = 0x06,
  612. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  613. .name = "SI2168-1",
  614. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  615. .i2c_bus_addr = 0xc8 >> 1,
  616. .i2c_reg_len = REGLEN_0bit,
  617. }, {
  618. .id = 0x25,
  619. .type = SAA7164_UNIT_TUNER,
  620. .name = "SI2157-2",
  621. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  622. .i2c_bus_addr = 0xc0 >> 1,
  623. .i2c_reg_len = REGLEN_0bit,
  624. }, {
  625. .id = 0x27,
  626. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  627. .name = "SI2168-2",
  628. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  629. .i2c_bus_addr = 0xcc >> 1,
  630. .i2c_reg_len = REGLEN_0bit,
  631. } },
  632. },
  633. };
  634. const unsigned int saa7164_bcount = ARRAY_SIZE(saa7164_boards);
  635. /* ------------------------------------------------------------------ */
  636. /* PCI subsystem IDs */
  637. struct saa7164_subid saa7164_subids[] = {
  638. {
  639. .subvendor = 0x0070,
  640. .subdevice = 0x8880,
  641. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  642. }, {
  643. .subvendor = 0x0070,
  644. .subdevice = 0x8810,
  645. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  646. }, {
  647. .subvendor = 0x0070,
  648. .subdevice = 0x8980,
  649. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200,
  650. }, {
  651. .subvendor = 0x0070,
  652. .subdevice = 0x8900,
  653. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_2,
  654. }, {
  655. .subvendor = 0x0070,
  656. .subdevice = 0x8901,
  657. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_3,
  658. }, {
  659. .subvendor = 0x0070,
  660. .subdevice = 0x88A1,
  661. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_3,
  662. }, {
  663. .subvendor = 0x0070,
  664. .subdevice = 0x8891,
  665. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  666. }, {
  667. .subvendor = 0x0070,
  668. .subdevice = 0x8851,
  669. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  670. }, {
  671. .subvendor = 0x0070,
  672. .subdevice = 0x8940,
  673. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_4,
  674. }, {
  675. .subvendor = 0x0070,
  676. .subdevice = 0x8953,
  677. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_5,
  678. }, {
  679. .subvendor = 0x0070,
  680. .subdevice = 0xf111,
  681. .card = SAA7164_BOARD_HAUPPAUGE_HVR2255,
  682. /* Prototype card left here for documenation purposes.
  683. .card = SAA7164_BOARD_HAUPPAUGE_HVR2255proto,
  684. */
  685. }, {
  686. .subvendor = 0x0070,
  687. .subdevice = 0xf123,
  688. .card = SAA7164_BOARD_HAUPPAUGE_HVR2205,
  689. }, {
  690. .subvendor = 0x0070,
  691. .subdevice = 0xf120,
  692. .card = SAA7164_BOARD_HAUPPAUGE_HVR2205,
  693. },
  694. };
  695. const unsigned int saa7164_idcount = ARRAY_SIZE(saa7164_subids);
  696. void saa7164_card_list(struct saa7164_dev *dev)
  697. {
  698. int i;
  699. if (0 == dev->pci->subsystem_vendor &&
  700. 0 == dev->pci->subsystem_device) {
  701. printk(KERN_ERR
  702. "%s: Board has no valid PCIe Subsystem ID and can't\n"
  703. "%s: be autodetected. Pass card=<n> insmod option to\n"
  704. "%s: workaround that. Send complaints to the vendor\n"
  705. "%s: of the TV card. Best regards,\n"
  706. "%s: -- tux\n",
  707. dev->name, dev->name, dev->name, dev->name, dev->name);
  708. } else {
  709. printk(KERN_ERR
  710. "%s: Your board isn't known (yet) to the driver.\n"
  711. "%s: Try to pick one of the existing card configs via\n"
  712. "%s: card=<n> insmod option. Updating to the latest\n"
  713. "%s: version might help as well.\n",
  714. dev->name, dev->name, dev->name, dev->name);
  715. }
  716. printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod option:\n",
  717. dev->name);
  718. for (i = 0; i < saa7164_bcount; i++)
  719. printk(KERN_ERR "%s: card=%d -> %s\n",
  720. dev->name, i, saa7164_boards[i].name);
  721. }
  722. /* TODO: clean this define up into the -cards.c structs */
  723. #define PCIEBRIDGE_UNITID 2
  724. void saa7164_gpio_setup(struct saa7164_dev *dev)
  725. {
  726. switch (dev->board) {
  727. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  728. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  729. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  730. case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
  731. case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
  732. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  733. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  734. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  735. case SAA7164_BOARD_HAUPPAUGE_HVR2255proto:
  736. case SAA7164_BOARD_HAUPPAUGE_HVR2255:
  737. case SAA7164_BOARD_HAUPPAUGE_HVR2205:
  738. /*
  739. HVR2200 / HVR2250
  740. GPIO 2: s5h1411 / tda10048-1 demod reset
  741. GPIO 3: s5h1411 / tda10048-2 demod reset
  742. GPIO 7: IRBlaster Zilog reset
  743. */
  744. /* HVR2255
  745. * GPIO 2: lgdg3306-1 demod reset
  746. * GPIO 3: lgdt3306-2 demod reset
  747. */
  748. /* HVR2205
  749. * GPIO 2: si2168-1 demod reset
  750. * GPIO 3: si2168-2 demod reset
  751. */
  752. /* Reset parts by going in and out of reset */
  753. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  754. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  755. msleep(20);
  756. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  757. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  758. break;
  759. }
  760. }
  761. static void hauppauge_eeprom(struct saa7164_dev *dev, u8 *eeprom_data)
  762. {
  763. struct tveeprom tv;
  764. tveeprom_hauppauge_analog(&tv, eeprom_data);
  765. /* Make sure we support the board model */
  766. switch (tv.model) {
  767. case 88001:
  768. /* Development board - Limit circulation */
  769. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  770. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  771. case 88021:
  772. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  773. * ATSC/QAM (TDA18271/S5H1411) and basic analog, MCE CIR, FM */
  774. break;
  775. case 88041:
  776. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  777. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  778. break;
  779. case 88061:
  780. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  781. * ATSC/QAM (TDA18271/S5H1411) and basic analog, FM */
  782. break;
  783. case 89519:
  784. case 89609:
  785. /* WinTV-HVR2200 (PCIe, Retail, full-height)
  786. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  787. break;
  788. case 89619:
  789. /* WinTV-HVR2200 (PCIe, Retail, half-height)
  790. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  791. break;
  792. case 151009:
  793. /* First production board rev B2I6 */
  794. /* WinTV-HVR2205 (PCIe, Retail, full-height bracket)
  795. * DVB-T/T2/C (SI2157/SI2168) and basic analog, FM */
  796. break;
  797. case 151609:
  798. /* First production board rev B2I6 */
  799. /* WinTV-HVR2205 (PCIe, Retail, half-height bracket)
  800. * DVB-T/T2/C (SI2157/SI2168) and basic analog, FM */
  801. break;
  802. case 151061:
  803. /* First production board rev B1I6 */
  804. /* WinTV-HVR2255 (PCIe, Retail, full-height bracket)
  805. * ATSC/QAM (SI2157/LGDT3306) and basic analog, FM */
  806. break;
  807. default:
  808. printk(KERN_ERR "%s: Warning: Unknown Hauppauge model #%d\n",
  809. dev->name, tv.model);
  810. break;
  811. }
  812. printk(KERN_INFO "%s: Hauppauge eeprom: model=%d\n", dev->name,
  813. tv.model);
  814. }
  815. void saa7164_card_setup(struct saa7164_dev *dev)
  816. {
  817. static u8 eeprom[256];
  818. if (dev->i2c_bus[0].i2c_rc == 0) {
  819. if (saa7164_api_read_eeprom(dev, &eeprom[0],
  820. sizeof(eeprom)) < 0)
  821. return;
  822. }
  823. switch (dev->board) {
  824. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  825. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  826. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  827. case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
  828. case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
  829. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  830. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  831. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  832. case SAA7164_BOARD_HAUPPAUGE_HVR2255proto:
  833. case SAA7164_BOARD_HAUPPAUGE_HVR2255:
  834. case SAA7164_BOARD_HAUPPAUGE_HVR2205:
  835. hauppauge_eeprom(dev, &eeprom[0]);
  836. break;
  837. }
  838. }
  839. /* With most other drivers, the kernel expects to communicate with subdrivers
  840. * through i2c. This bridge does not allow that, it does not expose any direct
  841. * access to I2C. Instead we have to communicate through the device f/w for
  842. * register access to 'processing units'. Each unit has a unique
  843. * id, regardless of how the physical implementation occurs across
  844. * the three physical i2c busses. The being said if we want leverge of
  845. * the existing kernel drivers for tuners and demods we have to 'speak i2c',
  846. * to this bridge implements 3 virtual i2c buses. This is a helper function
  847. * for those.
  848. *
  849. * Description: Translate the kernels notion of an i2c address and bus into
  850. * the appropriate unitid.
  851. */
  852. int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr)
  853. {
  854. /* For a given bus and i2c device address, return the saa7164 unique
  855. * unitid. < 0 on error */
  856. struct saa7164_dev *dev = bus->dev;
  857. struct saa7164_unit *unit;
  858. int i;
  859. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  860. unit = &saa7164_boards[dev->board].unit[i];
  861. if (unit->type == SAA7164_UNIT_UNDEFINED)
  862. continue;
  863. if ((bus->nr == unit->i2c_bus_nr) &&
  864. (addr == unit->i2c_bus_addr))
  865. return unit->id;
  866. }
  867. return -1;
  868. }
  869. /* The 7164 API needs to know the i2c register length in advance.
  870. * this is a helper function. Based on a specific chip addr and bus return the
  871. * reg length.
  872. */
  873. int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr)
  874. {
  875. /* For a given bus and i2c device address, return the
  876. * saa7164 registry address width. < 0 on error
  877. */
  878. struct saa7164_dev *dev = bus->dev;
  879. struct saa7164_unit *unit;
  880. int i;
  881. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  882. unit = &saa7164_boards[dev->board].unit[i];
  883. if (unit->type == SAA7164_UNIT_UNDEFINED)
  884. continue;
  885. if ((bus->nr == unit->i2c_bus_nr) &&
  886. (addr == unit->i2c_bus_addr))
  887. return unit->i2c_reg_len;
  888. }
  889. return -1;
  890. }
  891. /* TODO: implement a 'findeeprom' functio like the above and fix any other
  892. * eeprom related todo's in -api.c.
  893. */
  894. /* Translate a unitid into a x readable device name, for display purposes. */
  895. char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid)
  896. {
  897. char *undefed = "UNDEFINED";
  898. char *bridge = "BRIDGE";
  899. struct saa7164_unit *unit;
  900. int i;
  901. if (unitid == 0)
  902. return bridge;
  903. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  904. unit = &saa7164_boards[dev->board].unit[i];
  905. if (unit->type == SAA7164_UNIT_UNDEFINED)
  906. continue;
  907. if (unitid == unit->id)
  908. return unit->name;
  909. }
  910. return undefed;
  911. }