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