umt-010.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* DVB USB framework compliant Linux driver for the HanfTek UMT-010 USB2.0
  2. * DVB-T receiver.
  3. *
  4. * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation, version 2.
  9. *
  10. * see Documentation/dvb/README.dvb-usb for more information
  11. */
  12. #include "dibusb.h"
  13. #include "mt352.h"
  14. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  15. static int umt_mt352_demod_init(struct dvb_frontend *fe)
  16. {
  17. static u8 mt352_clock_config[] = { 0x89, 0xb8, 0x2d };
  18. static u8 mt352_reset[] = { 0x50, 0x80 };
  19. static u8 mt352_mclk_ratio[] = { 0x8b, 0x00 };
  20. static u8 mt352_adc_ctl_1_cfg[] = { 0x8E, 0x40 };
  21. static u8 mt352_agc_cfg[] = { 0x67, 0x10, 0xa0 };
  22. static u8 mt352_sec_agc_cfg1[] = { 0x6a, 0xff };
  23. static u8 mt352_sec_agc_cfg2[] = { 0x6d, 0xff };
  24. static u8 mt352_sec_agc_cfg3[] = { 0x70, 0x40 };
  25. static u8 mt352_sec_agc_cfg4[] = { 0x7b, 0x03 };
  26. static u8 mt352_sec_agc_cfg5[] = { 0x7d, 0x0f };
  27. static u8 mt352_acq_ctl[] = { 0x53, 0x50 };
  28. static u8 mt352_input_freq_1[] = { 0x56, 0x31, 0x06 };
  29. mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
  30. udelay(2000);
  31. mt352_write(fe, mt352_reset, sizeof(mt352_reset));
  32. mt352_write(fe, mt352_mclk_ratio, sizeof(mt352_mclk_ratio));
  33. mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
  34. mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
  35. mt352_write(fe, mt352_sec_agc_cfg1, sizeof(mt352_sec_agc_cfg1));
  36. mt352_write(fe, mt352_sec_agc_cfg2, sizeof(mt352_sec_agc_cfg2));
  37. mt352_write(fe, mt352_sec_agc_cfg3, sizeof(mt352_sec_agc_cfg3));
  38. mt352_write(fe, mt352_sec_agc_cfg4, sizeof(mt352_sec_agc_cfg4));
  39. mt352_write(fe, mt352_sec_agc_cfg5, sizeof(mt352_sec_agc_cfg5));
  40. mt352_write(fe, mt352_acq_ctl, sizeof(mt352_acq_ctl));
  41. mt352_write(fe, mt352_input_freq_1, sizeof(mt352_input_freq_1));
  42. return 0;
  43. }
  44. static int umt_mt352_frontend_attach(struct dvb_usb_adapter *adap)
  45. {
  46. struct mt352_config umt_config;
  47. memset(&umt_config,0,sizeof(struct mt352_config));
  48. umt_config.demod_init = umt_mt352_demod_init;
  49. umt_config.demod_address = 0xf;
  50. adap->fe = dvb_attach(mt352_attach, &umt_config, &adap->dev->i2c_adap);
  51. return 0;
  52. }
  53. static int umt_tuner_attach (struct dvb_usb_adapter *adap)
  54. {
  55. dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_TUA6034);
  56. return 0;
  57. }
  58. /* USB Driver stuff */
  59. static struct dvb_usb_device_properties umt_properties;
  60. static int umt_probe(struct usb_interface *intf,
  61. const struct usb_device_id *id)
  62. {
  63. if (0 == dvb_usb_device_init(intf, &umt_properties,
  64. THIS_MODULE, NULL, adapter_nr))
  65. return 0;
  66. return -EINVAL;
  67. }
  68. /* do not change the order of the ID table */
  69. static struct usb_device_id umt_table [] = {
  70. /* 00 */ { USB_DEVICE(USB_VID_HANFTEK, USB_PID_HANFTEK_UMT_010_COLD) },
  71. /* 01 */ { USB_DEVICE(USB_VID_HANFTEK, USB_PID_HANFTEK_UMT_010_WARM) },
  72. { } /* Terminating entry */
  73. };
  74. MODULE_DEVICE_TABLE (usb, umt_table);
  75. static struct dvb_usb_device_properties umt_properties = {
  76. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  77. .usb_ctrl = CYPRESS_FX2,
  78. .firmware = "dvb-usb-umt-010-02.fw",
  79. .num_adapters = 1,
  80. .adapter = {
  81. {
  82. .streaming_ctrl = dibusb2_0_streaming_ctrl,
  83. .frontend_attach = umt_mt352_frontend_attach,
  84. .tuner_attach = umt_tuner_attach,
  85. /* parameter for the MPEG2-data transfer */
  86. .stream = {
  87. .type = USB_BULK,
  88. .count = MAX_NO_URBS_FOR_DATA_STREAM,
  89. .endpoint = 0x06,
  90. .u = {
  91. .bulk = {
  92. .buffersize = 512,
  93. }
  94. }
  95. },
  96. .size_of_priv = sizeof(struct dibusb_state),
  97. }
  98. },
  99. .power_ctrl = dibusb_power_ctrl,
  100. .i2c_algo = &dibusb_i2c_algo,
  101. .generic_bulk_ctrl_endpoint = 0x01,
  102. .num_device_descs = 1,
  103. .devices = {
  104. { "Hanftek UMT-010 DVB-T USB2.0",
  105. { &umt_table[0], NULL },
  106. { &umt_table[1], NULL },
  107. },
  108. }
  109. };
  110. static struct usb_driver umt_driver = {
  111. .name = "dvb_usb_umt_010",
  112. .probe = umt_probe,
  113. .disconnect = dvb_usb_device_exit,
  114. .id_table = umt_table,
  115. };
  116. /* module stuff */
  117. static int __init umt_module_init(void)
  118. {
  119. int result;
  120. if ((result = usb_register(&umt_driver))) {
  121. err("usb_register failed. Error number %d",result);
  122. return result;
  123. }
  124. return 0;
  125. }
  126. static void __exit umt_module_exit(void)
  127. {
  128. /* deregister this driver from the USB subsystem */
  129. usb_deregister(&umt_driver);
  130. }
  131. module_init (umt_module_init);
  132. module_exit (umt_module_exit);
  133. MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
  134. MODULE_DESCRIPTION("Driver for HanfTek UMT 010 USB2.0 DVB-T device");
  135. MODULE_VERSION("1.0");
  136. MODULE_LICENSE("GPL");