dib0700_devices.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* Linux driver for devices based on the DiBcom DiB0700 USB bridge
  2. *
  3. * This program is free software; you can redistribute it and/or modify it
  4. * under the terms of the GNU General Public License as published by the Free
  5. * Software Foundation, version 2.
  6. *
  7. * Copyright (C) 2005-6 DiBcom, SA
  8. */
  9. #include "dib0700.h"
  10. #include "dib3000mc.h"
  11. #include "dib7000m.h"
  12. #include "mt2060.h"
  13. static int force_lna_activation;
  14. module_param(force_lna_activation, int, 0644);
  15. MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
  16. "if applicable for the device (default: 0=automatic/off).");
  17. /* Hauppauge Nova-T 500
  18. * has a LNA on GPIO0 which is enabled by setting 1 */
  19. static struct mt2060_config bristol_mt2060_config[2] = {
  20. {
  21. .i2c_address = 0x60,
  22. .clock_out = 3,
  23. }, {
  24. .i2c_address = 0x61,
  25. }
  26. };
  27. static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
  28. .band_caps = BAND_VHF | BAND_UHF,
  29. .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
  30. .agc1_max = 42598,
  31. .agc1_min = 17694,
  32. .agc2_max = 45875,
  33. .agc2_min = 0,
  34. .agc1_pt1 = 0,
  35. .agc1_pt2 = 59,
  36. .agc1_slope1 = 0,
  37. .agc1_slope2 = 69,
  38. .agc2_pt1 = 0,
  39. .agc2_pt2 = 59,
  40. .agc2_slope1 = 111,
  41. .agc2_slope2 = 28,
  42. };
  43. static struct dib3000mc_config bristol_dib3000mc_config[2] = {
  44. { .agc = &bristol_dib3000p_mt2060_agc_config,
  45. .max_time = 0x196,
  46. .ln_adc_level = 0x1cc7,
  47. .output_mpeg2_in_188_bytes = 1,
  48. },
  49. { .agc = &bristol_dib3000p_mt2060_agc_config,
  50. .max_time = 0x196,
  51. .ln_adc_level = 0x1cc7,
  52. .output_mpeg2_in_188_bytes = 1,
  53. }
  54. };
  55. static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
  56. {
  57. struct dib0700_state *st = adap->dev->priv;
  58. if (adap->id == 0) {
  59. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
  60. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
  61. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
  62. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
  63. if (force_lna_activation)
  64. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
  65. else
  66. dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
  67. if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
  68. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
  69. return -ENODEV;
  70. }
  71. }
  72. st->mt2060_if1[adap->id] = 1220;
  73. return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
  74. (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
  75. }
  76. static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
  77. {
  78. struct dib0700_state *st = adap->dev->priv;
  79. struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
  80. return dvb_attach(mt2060_attach,adap->fe, tun_i2c, &bristol_mt2060_config[adap->id],
  81. st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0;
  82. }
  83. /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
  84. /*
  85. static struct mt2060_config stk7000p_mt2060_config = {
  86. 0x60
  87. };
  88. */
  89. static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
  90. {
  91. /* unless there is no real power management in DVB - we leave the device on GPIO6 */
  92. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
  93. dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
  94. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
  95. dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
  96. // adap->fe = dib7000m_attach(&adap->dev->i2c_adap, &stk7700p_dib7000m_config, 18);
  97. return 0;
  98. }
  99. static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
  100. {
  101. // tun_i2c = dib7000m_get_tuner_i2c_master(adap->fe, 1);
  102. // return mt2060_attach(adap->fe, tun_i2c, &stk3000p_mt2060_config, if1);
  103. return 0;
  104. }
  105. struct usb_device_id dib0700_usb_id_table[] = {
  106. { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
  107. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
  108. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
  109. { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
  110. { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
  111. { } /* Terminating entry */
  112. };
  113. MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
  114. #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
  115. .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
  116. .usb_ctrl = DEVICE_SPECIFIC, \
  117. .firmware = "dvb-usb-dib0700-01.fw", \
  118. .download_firmware = dib0700_download_firmware, \
  119. .no_reconnect = 1, \
  120. .size_of_priv = sizeof(struct dib0700_state), \
  121. .i2c_algo = &dib0700_i2c_algo, \
  122. .identify_state = dib0700_identify_state
  123. #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
  124. .streaming_ctrl = dib0700_streaming_ctrl, \
  125. .stream = { \
  126. .type = USB_BULK, \
  127. .count = 4, \
  128. .endpoint = ep, \
  129. .u = { \
  130. .bulk = { \
  131. .buffersize = 39480, \
  132. } \
  133. } \
  134. }
  135. struct dvb_usb_device_properties dib0700_devices[] = {
  136. {
  137. DIB0700_DEFAULT_DEVICE_PROPERTIES,
  138. .num_adapters = 1,
  139. .adapter = {
  140. {
  141. .frontend_attach = stk7700p_frontend_attach,
  142. .tuner_attach = stk7700p_tuner_attach,
  143. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  144. },
  145. },
  146. .num_device_descs = 3,
  147. .devices = {
  148. { "DiBcom STK7700P reference design",
  149. { &dib0700_usb_id_table[0], NULL },
  150. { NULL },
  151. },
  152. { "Hauppauge Nova-T Stick",
  153. { &dib0700_usb_id_table[3], NULL },
  154. { NULL },
  155. },
  156. { "AVerMedia AVerTV DVB-T Volar",
  157. { &dib0700_usb_id_table[4], NULL },
  158. { NULL },
  159. },
  160. }
  161. }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
  162. .num_adapters = 2,
  163. .adapter = {
  164. {
  165. .frontend_attach = bristol_frontend_attach,
  166. .tuner_attach = bristol_tuner_attach,
  167. DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
  168. }, {
  169. .frontend_attach = bristol_frontend_attach,
  170. .tuner_attach = bristol_tuner_attach,
  171. DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
  172. }
  173. },
  174. .num_device_descs = 1,
  175. .devices = {
  176. { "Hauppauge Nova-T 500 Dual DVB-T",
  177. { &dib0700_usb_id_table[1], &dib0700_usb_id_table[2], NULL },
  178. { NULL },
  179. },
  180. }
  181. }
  182. };
  183. int dib0700_device_count = ARRAY_SIZE(dib0700_devices);