Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 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 | |
| 14 | #include "mt352.h" |
| 15 | |
| 16 | static int umt_mt352_demod_init(struct dvb_frontend *fe) |
| 17 | { |
| 18 | static u8 mt352_clock_config[] = { 0x89, 0xb8, 0x2d }; |
| 19 | static u8 mt352_reset[] = { 0x50, 0x80 }; |
| 20 | static u8 mt352_mclk_ratio[] = { 0x8b, 0x00 }; |
| 21 | static u8 mt352_adc_ctl_1_cfg[] = { 0x8E, 0x40 }; |
| 22 | static u8 mt352_agc_cfg[] = { 0x67, 0x10, 0xa0 }; |
| 23 | |
| 24 | static u8 mt352_sec_agc_cfg1[] = { 0x6a, 0xff }; |
| 25 | static u8 mt352_sec_agc_cfg2[] = { 0x6d, 0xff }; |
| 26 | static u8 mt352_sec_agc_cfg3[] = { 0x70, 0x40 }; |
| 27 | static u8 mt352_sec_agc_cfg4[] = { 0x7b, 0x03 }; |
| 28 | static u8 mt352_sec_agc_cfg5[] = { 0x7d, 0x0f }; |
| 29 | |
| 30 | static u8 mt352_acq_ctl[] = { 0x53, 0x50 }; |
| 31 | static u8 mt352_input_freq_1[] = { 0x56, 0x31, 0x06 }; |
| 32 | |
| 33 | mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); |
| 34 | udelay(2000); |
| 35 | mt352_write(fe, mt352_reset, sizeof(mt352_reset)); |
| 36 | mt352_write(fe, mt352_mclk_ratio, sizeof(mt352_mclk_ratio)); |
| 37 | |
| 38 | mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg)); |
| 39 | mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg)); |
| 40 | |
| 41 | mt352_write(fe, mt352_sec_agc_cfg1, sizeof(mt352_sec_agc_cfg1)); |
| 42 | mt352_write(fe, mt352_sec_agc_cfg2, sizeof(mt352_sec_agc_cfg2)); |
| 43 | mt352_write(fe, mt352_sec_agc_cfg3, sizeof(mt352_sec_agc_cfg3)); |
| 44 | mt352_write(fe, mt352_sec_agc_cfg4, sizeof(mt352_sec_agc_cfg4)); |
| 45 | mt352_write(fe, mt352_sec_agc_cfg5, sizeof(mt352_sec_agc_cfg5)); |
| 46 | |
| 47 | mt352_write(fe, mt352_acq_ctl, sizeof(mt352_acq_ctl)); |
| 48 | mt352_write(fe, mt352_input_freq_1, sizeof(mt352_input_freq_1)); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 53 | static int umt_mt352_frontend_attach(struct dvb_usb_adapter *adap) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 54 | { |
| 55 | struct mt352_config umt_config; |
| 56 | |
| 57 | memset(&umt_config,0,sizeof(struct mt352_config)); |
| 58 | umt_config.demod_init = umt_mt352_demod_init; |
| 59 | umt_config.demod_address = 0xf; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 60 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 61 | adap->fe = dvb_attach(mt352_attach, &umt_config, &adap->dev->i2c_adap); |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 66 | static int umt_tuner_attach (struct dvb_usb_adapter *adap) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 67 | { |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame^] | 68 | dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_TUA6034); |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | /* USB Driver stuff */ |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 73 | static struct dvb_usb_device_properties umt_properties; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 74 | |
| 75 | static int umt_probe(struct usb_interface *intf, |
| 76 | const struct usb_device_id *id) |
| 77 | { |
Patrick Boettcher | 47dc3d6 | 2005-09-09 13:02:47 -0700 | [diff] [blame] | 78 | if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE,NULL) == 0) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 79 | return 0; |
| 80 | return -EINVAL; |
| 81 | } |
| 82 | |
| 83 | /* do not change the order of the ID table */ |
| 84 | static struct usb_device_id umt_table [] = { |
Michael Krufky | 9bc7c04 | 2007-05-09 13:34:54 -0300 | [diff] [blame] | 85 | /* 00 */ { USB_DEVICE(USB_VID_HANFTEK, USB_PID_HANFTEK_UMT_010_COLD) }, |
| 86 | /* 01 */ { USB_DEVICE(USB_VID_HANFTEK, USB_PID_HANFTEK_UMT_010_WARM) }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 87 | { } /* Terminating entry */ |
| 88 | }; |
| 89 | MODULE_DEVICE_TABLE (usb, umt_table); |
| 90 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 91 | static struct dvb_usb_device_properties umt_properties = { |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 92 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 93 | |
| 94 | .usb_ctrl = CYPRESS_FX2, |
| 95 | .firmware = "dvb-usb-umt-010-02.fw", |
| 96 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 97 | .num_adapters = 1, |
| 98 | .adapter = { |
| 99 | { |
Patrick Boettcher | 01451e7 | 2006-10-13 11:34:46 -0300 | [diff] [blame] | 100 | .streaming_ctrl = dibusb2_0_streaming_ctrl, |
| 101 | .frontend_attach = umt_mt352_frontend_attach, |
| 102 | .tuner_attach = umt_tuner_attach, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 103 | |
Patrick Boettcher | 01451e7 | 2006-10-13 11:34:46 -0300 | [diff] [blame] | 104 | /* parameter for the MPEG2-data transfer */ |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 105 | .stream = { |
| 106 | .type = USB_BULK, |
Patrick Boettcher | 01451e7 | 2006-10-13 11:34:46 -0300 | [diff] [blame] | 107 | .count = 20, |
| 108 | .endpoint = 0x06, |
| 109 | .u = { |
| 110 | .bulk = { |
| 111 | .buffersize = 512, |
| 112 | } |
| 113 | } |
| 114 | }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 115 | |
Patrick Boettcher | 4d43e13 | 2006-09-30 06:53:48 -0300 | [diff] [blame] | 116 | .size_of_priv = sizeof(struct dibusb_state), |
| 117 | } |
| 118 | }, |
| 119 | .power_ctrl = dibusb_power_ctrl, |
| 120 | |
| 121 | .i2c_algo = &dibusb_i2c_algo, |
| 122 | |
| 123 | .generic_bulk_ctrl_endpoint = 0x01, |
| 124 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 125 | .num_device_descs = 1, |
| 126 | .devices = { |
| 127 | { "Hanftek UMT-010 DVB-T USB2.0", |
| 128 | { &umt_table[0], NULL }, |
| 129 | { &umt_table[1], NULL }, |
| 130 | }, |
| 131 | } |
| 132 | }; |
| 133 | |
| 134 | static struct usb_driver umt_driver = { |
Patrick Boettcher | 63b5c1c | 2005-07-07 17:58:30 -0700 | [diff] [blame] | 135 | .name = "dvb_usb_umt_010", |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 136 | .probe = umt_probe, |
| 137 | .disconnect = dvb_usb_device_exit, |
| 138 | .id_table = umt_table, |
| 139 | }; |
| 140 | |
| 141 | /* module stuff */ |
| 142 | static int __init umt_module_init(void) |
| 143 | { |
| 144 | int result; |
| 145 | if ((result = usb_register(&umt_driver))) { |
| 146 | err("usb_register failed. Error number %d",result); |
| 147 | return result; |
| 148 | } |
| 149 | |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | static void __exit umt_module_exit(void) |
| 154 | { |
| 155 | /* deregister this driver from the USB subsystem */ |
| 156 | usb_deregister(&umt_driver); |
| 157 | } |
| 158 | |
| 159 | module_init (umt_module_init); |
| 160 | module_exit (umt_module_exit); |
| 161 | |
| 162 | MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); |
| 163 | MODULE_DESCRIPTION("Driver for HanfTek UMT 010 USB2.0 DVB-T device"); |
| 164 | MODULE_VERSION("1.0"); |
| 165 | MODULE_LICENSE("GPL"); |