| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 |  * descriptions + helper functions for simple dvb plls. | 
 | 3 |  * | 
 | 4 |  * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] | 
 | 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 |  *  GNU General Public License for more details. | 
 | 15 |  * | 
 | 16 |  *  You should have received a copy of the GNU General Public License | 
 | 17 |  *  along with this program; if not, write to the Free Software | 
 | 18 |  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
 | 19 |  */ | 
 | 20 |  | 
 | 21 | #include <linux/module.h> | 
 | 22 | #include <linux/dvb/frontend.h> | 
 | 23 | #include <asm/types.h> | 
 | 24 |  | 
 | 25 | #include "dvb-pll.h" | 
 | 26 |  | 
| Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame^] | 27 | struct dvb_pll_priv { | 
 | 28 | 	/* pll number */ | 
 | 29 | 	int nr; | 
 | 30 |  | 
 | 31 | 	/* i2c details */ | 
 | 32 | 	int pll_i2c_address; | 
 | 33 | 	struct i2c_adapter *i2c; | 
 | 34 |  | 
 | 35 | 	/* the PLL descriptor */ | 
 | 36 | 	struct dvb_pll_desc *pll_desc; | 
 | 37 |  | 
 | 38 | 	/* cached frequency/bandwidth */ | 
 | 39 | 	u32 frequency; | 
 | 40 | 	u32 bandwidth; | 
 | 41 | }; | 
 | 42 |  | 
 | 43 | #define DVB_PLL_MAX 16 | 
 | 44 |  | 
 | 45 | static unsigned int dvb_pll_devcount; | 
 | 46 |  | 
 | 47 | static int debug = 0; | 
 | 48 | module_param(debug, int, 0644); | 
 | 49 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 
 | 50 |  | 
 | 51 | static unsigned int input[DVB_PLL_MAX] = { [ 0 ... (DVB_PLL_MAX-1) ] = 0 }; | 
 | 52 | module_param_array(input, int, NULL, 0644); | 
 | 53 | MODULE_PARM_DESC(input,"specify rf input choice, 0 for autoselect (default)"); | 
 | 54 |  | 
 | 55 | /* ----------------------------------------------------------- */ | 
 | 56 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 57 | struct dvb_pll_desc { | 
 | 58 | 	char *name; | 
 | 59 | 	u32  min; | 
 | 60 | 	u32  max; | 
 | 61 | 	u32  iffreq; | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 62 | 	void (*set)(struct dvb_frontend *fe, u8 *buf, | 
 | 63 | 		    const struct dvb_frontend_parameters *params); | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 64 | 	u8   *initdata; | 
 | 65 | 	u8   *sleepdata; | 
 | 66 | 	int  count; | 
 | 67 | 	struct { | 
 | 68 | 		u32 limit; | 
 | 69 | 		u32 stepsize; | 
 | 70 | 		u8  config; | 
 | 71 | 		u8  cb; | 
 | 72 | 	} entries[12]; | 
 | 73 | }; | 
 | 74 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | /* ----------------------------------------------------------- */ | 
 | 76 | /* descriptions                                                */ | 
 | 77 |  | 
| Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame] | 78 | /* Set AGC TOP value to 103 dBuV: | 
 | 79 | 	0x80 = Control Byte | 
 | 80 | 	0x40 = 250 uA charge pump (irrelevant) | 
 | 81 | 	0x18 = Aux Byte to follow | 
 | 82 | 	0x06 = 64.5 kHz divider (irrelevant) | 
 | 83 | 	0x01 = Disable Vt (aka sleep) | 
 | 84 |  | 
 | 85 | 	0x00 = AGC Time constant 2s Iagc = 300 nA (vs 0x80 = 9 nA) | 
 | 86 | 	0x50 = AGC Take over point = 103 dBuV */ | 
 | 87 | static u8 tua603x_agc103[] = { 2, 0x80|0x40|0x18|0x06|0x01, 0x00|0x50 }; | 
 | 88 |  | 
| Trent Piepho | b7754d7 | 2007-05-08 18:05:16 -0300 | [diff] [blame] | 89 | /*	0x04 = 166.67 kHz divider | 
 | 90 |  | 
 | 91 | 	0x80 = AGC Time constant 50ms Iagc = 9 uA | 
 | 92 | 	0x20 = AGC Take over point = 112 dBuV */ | 
 | 93 | static u8 tua603x_agc112[] = { 2, 0x80|0x40|0x18|0x04|0x01, 0x80|0x20 }; | 
 | 94 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 95 | static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | 	.name  = "Thomson dtt7579", | 
 | 97 | 	.min   = 177000000, | 
 | 98 | 	.max   = 858000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 99 | 	.iffreq= 36166667, | 
| Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 100 | 	.sleepdata = (u8[]){ 2, 0xb4, 0x03 }, | 
 | 101 | 	.count = 4, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 103 | 		{  443250000, 166667, 0xb4, 0x02 }, | 
 | 104 | 		{  542000000, 166667, 0xb4, 0x08 }, | 
 | 105 | 		{  771000000, 166667, 0xbc, 0x08 }, | 
 | 106 | 		{  999999999, 166667, 0xf4, 0x08 }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | 	}, | 
 | 108 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 110 | static struct dvb_pll_desc dvb_pll_thomson_dtt7610 = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | 	.name  = "Thomson dtt7610", | 
 | 112 | 	.min   =  44000000, | 
 | 113 | 	.max   = 958000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 114 | 	.iffreq= 44000000, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | 	.count = 3, | 
 | 116 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 117 | 		{ 157250000, 62500, 0x8e, 0x39 }, | 
 | 118 | 		{ 454000000, 62500, 0x8e, 0x3a }, | 
 | 119 | 		{ 999999999, 62500, 0x8e, 0x3c }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | 	}, | 
 | 121 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 |  | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 123 | static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf, | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 124 | 			       const struct dvb_frontend_parameters *params) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | { | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 126 | 	if (BANDWIDTH_7_MHZ == params->u.ofdm.bandwidth) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | 		buf[3] |= 0x10; | 
 | 128 | } | 
 | 129 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 130 | static struct dvb_pll_desc dvb_pll_thomson_dtt759x = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | 	.name  = "Thomson dtt759x", | 
 | 132 | 	.min   = 177000000, | 
 | 133 | 	.max   = 896000000, | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 134 | 	.set   = thomson_dtt759x_bw, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 135 | 	.iffreq= 36166667, | 
| Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 136 | 	.sleepdata = (u8[]){ 2, 0x84, 0x03 }, | 
 | 137 | 	.count = 5, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 139 | 		{  264000000, 166667, 0xb4, 0x02 }, | 
 | 140 | 		{  470000000, 166667, 0xbc, 0x02 }, | 
 | 141 | 		{  735000000, 166667, 0xbc, 0x08 }, | 
 | 142 | 		{  835000000, 166667, 0xf4, 0x08 }, | 
 | 143 | 		{  999999999, 166667, 0xfc, 0x08 }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | 	}, | 
 | 145 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 147 | static struct dvb_pll_desc dvb_pll_lg_z201 = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | 	.name  = "LG z201", | 
 | 149 | 	.min   = 174000000, | 
 | 150 | 	.max   = 862000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 151 | 	.iffreq= 36166667, | 
| Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 152 | 	.sleepdata = (u8[]){ 2, 0xbc, 0x03 }, | 
 | 153 | 	.count = 5, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 155 | 		{  157500000, 166667, 0xbc, 0x01 }, | 
 | 156 | 		{  443250000, 166667, 0xbc, 0x02 }, | 
 | 157 | 		{  542000000, 166667, 0xbc, 0x04 }, | 
 | 158 | 		{  830000000, 166667, 0xf4, 0x04 }, | 
 | 159 | 		{  999999999, 166667, 0xfc, 0x04 }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | 	}, | 
 | 161 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 163 | static struct dvb_pll_desc dvb_pll_microtune_4042 = { | 
| Mac Michaels | d8667cb | 2005-07-07 17:58:29 -0700 | [diff] [blame] | 164 | 	.name  = "Microtune 4042 FI5", | 
 | 165 | 	.min   =  57000000, | 
 | 166 | 	.max   = 858000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 167 | 	.iffreq= 44000000, | 
| Mac Michaels | d8667cb | 2005-07-07 17:58:29 -0700 | [diff] [blame] | 168 | 	.count = 3, | 
 | 169 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 170 | 		{ 162000000, 62500, 0x8e, 0xa1 }, | 
 | 171 | 		{ 457000000, 62500, 0x8e, 0x91 }, | 
 | 172 | 		{ 999999999, 62500, 0x8e, 0x31 }, | 
| Mac Michaels | d8667cb | 2005-07-07 17:58:29 -0700 | [diff] [blame] | 173 | 	}, | 
 | 174 | }; | 
| Mac Michaels | d8667cb | 2005-07-07 17:58:29 -0700 | [diff] [blame] | 175 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 176 | static struct dvb_pll_desc dvb_pll_thomson_dtt761x = { | 
| Michael Krufky | 83ac8722 | 2006-01-09 15:25:29 -0200 | [diff] [blame] | 177 | 	/* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */ | 
 | 178 | 	.name  = "Thomson dtt761x", | 
 | 179 | 	.min   =  57000000, | 
 | 180 | 	.max   = 863000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 181 | 	.iffreq= 44000000, | 
| Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 182 | 	.count = 3, | 
| Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame] | 183 | 	.initdata = tua603x_agc103, | 
| Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 184 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 185 | 		{ 147000000, 62500, 0x8e, 0x39 }, | 
 | 186 | 		{ 417000000, 62500, 0x8e, 0x3a }, | 
 | 187 | 		{ 999999999, 62500, 0x8e, 0x3c }, | 
| Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 188 | 	}, | 
 | 189 | }; | 
| Michael Krufky | 0d723c0 | 2005-07-07 17:58:42 -0700 | [diff] [blame] | 190 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 191 | static struct dvb_pll_desc dvb_pll_unknown_1 = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | 	.name  = "unknown 1", /* used by dntv live dvb-t */ | 
 | 193 | 	.min   = 174000000, | 
 | 194 | 	.max   = 862000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 195 | 	.iffreq= 36166667, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | 	.count = 9, | 
 | 197 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 198 | 		{  150000000, 166667, 0xb4, 0x01 }, | 
 | 199 | 		{  173000000, 166667, 0xbc, 0x01 }, | 
 | 200 | 		{  250000000, 166667, 0xb4, 0x02 }, | 
 | 201 | 		{  400000000, 166667, 0xbc, 0x02 }, | 
 | 202 | 		{  420000000, 166667, 0xf4, 0x02 }, | 
 | 203 | 		{  470000000, 166667, 0xfc, 0x02 }, | 
 | 204 | 		{  600000000, 166667, 0xbc, 0x08 }, | 
 | 205 | 		{  730000000, 166667, 0xf4, 0x08 }, | 
 | 206 | 		{  999999999, 166667, 0xfc, 0x08 }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | 	}, | 
 | 208 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 |  | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 210 | /* Infineon TUA6010XS | 
 | 211 |  * used in Thomson Cable Tuner | 
 | 212 |  */ | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 213 | static struct dvb_pll_desc dvb_pll_tua6010xs = { | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 214 | 	.name  = "Infineon TUA6010XS", | 
 | 215 | 	.min   =  44250000, | 
 | 216 | 	.max   = 858000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 217 | 	.iffreq= 36125000, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 218 | 	.count = 3, | 
 | 219 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 220 | 		{  115750000, 62500, 0x8e, 0x03 }, | 
 | 221 | 		{  403250000, 62500, 0x8e, 0x06 }, | 
 | 222 | 		{  999999999, 62500, 0x8e, 0x85 }, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 223 | 	}, | 
 | 224 | }; | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 225 |  | 
 | 226 | /* Panasonic env57h1xd5 (some Philips PLL ?) */ | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 227 | static struct dvb_pll_desc dvb_pll_env57h1xd5 = { | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 228 | 	.name  = "Panasonic ENV57H1XD5", | 
 | 229 | 	.min   =  44250000, | 
 | 230 | 	.max   = 858000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 231 | 	.iffreq= 36125000, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 232 | 	.count = 4, | 
 | 233 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 234 | 		{  153000000, 166667, 0xc2, 0x41 }, | 
 | 235 | 		{  470000000, 166667, 0xc2, 0x42 }, | 
 | 236 | 		{  526000000, 166667, 0xc2, 0x84 }, | 
 | 237 | 		{  999999999, 166667, 0xc2, 0xa4 }, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 238 | 	}, | 
 | 239 | }; | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 240 |  | 
 | 241 | /* Philips TDA6650/TDA6651 | 
 | 242 |  * used in Panasonic ENV77H11D5 | 
 | 243 |  */ | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 244 | static void tda665x_bw(struct dvb_frontend *fe, u8 *buf, | 
 | 245 | 		       const struct dvb_frontend_parameters *params) | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 246 | { | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 247 | 	if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 248 | 		buf[3] |= 0x08; | 
 | 249 | } | 
 | 250 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 251 | static struct dvb_pll_desc dvb_pll_tda665x = { | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 252 | 	.name  = "Philips TDA6650/TDA6651", | 
 | 253 | 	.min   =  44250000, | 
 | 254 | 	.max   = 858000000, | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 255 | 	.set   = tda665x_bw, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 256 | 	.iffreq= 36166667, | 
| Michael Krufky | fbfee86 | 2007-05-09 15:58:17 -0300 | [diff] [blame] | 257 | 	.initdata = (u8[]){ 4, 0x0b, 0xf5, 0x85, 0xab }, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 258 | 	.count = 12, | 
 | 259 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 260 | 		{   93834000, 166667, 0xca, 0x61 /* 011 0 0 0  01 */ }, | 
 | 261 | 		{  123834000, 166667, 0xca, 0xa1 /* 101 0 0 0  01 */ }, | 
 | 262 | 		{  161000000, 166667, 0xca, 0xa1 /* 101 0 0 0  01 */ }, | 
 | 263 | 		{  163834000, 166667, 0xca, 0xc2 /* 110 0 0 0  10 */ }, | 
 | 264 | 		{  253834000, 166667, 0xca, 0x62 /* 011 0 0 0  10 */ }, | 
 | 265 | 		{  383834000, 166667, 0xca, 0xa2 /* 101 0 0 0  10 */ }, | 
 | 266 | 		{  443834000, 166667, 0xca, 0xc2 /* 110 0 0 0  10 */ }, | 
 | 267 | 		{  444000000, 166667, 0xca, 0xc4 /* 110 0 0 1  00 */ }, | 
 | 268 | 		{  583834000, 166667, 0xca, 0x64 /* 011 0 0 1  00 */ }, | 
 | 269 | 		{  793834000, 166667, 0xca, 0xa4 /* 101 0 0 1  00 */ }, | 
 | 270 | 		{  444834000, 166667, 0xca, 0xc4 /* 110 0 0 1  00 */ }, | 
 | 271 | 		{  861000000, 166667, 0xca, 0xe4 /* 111 0 0 1  00 */ }, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 272 | 	} | 
 | 273 | }; | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 274 |  | 
 | 275 | /* Infineon TUA6034 | 
 | 276 |  * used in LG TDTP E102P | 
 | 277 |  */ | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 278 | static void tua6034_bw(struct dvb_frontend *fe, u8 *buf, | 
 | 279 | 		       const struct dvb_frontend_parameters *params) | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 280 | { | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 281 | 	if (BANDWIDTH_7_MHZ != params->u.ofdm.bandwidth) | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 282 | 		buf[3] |= 0x08; | 
 | 283 | } | 
 | 284 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 285 | static struct dvb_pll_desc dvb_pll_tua6034 = { | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 286 | 	.name  = "Infineon TUA6034", | 
 | 287 | 	.min   =  44250000, | 
 | 288 | 	.max   = 858000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 289 | 	.iffreq= 36166667, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 290 | 	.count = 3, | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 291 | 	.set   = tua6034_bw, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 292 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 293 | 		{  174500000, 62500, 0xce, 0x01 }, | 
 | 294 | 		{  230000000, 62500, 0xce, 0x02 }, | 
 | 295 | 		{  999999999, 62500, 0xce, 0x04 }, | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 296 | 	}, | 
 | 297 | }; | 
| Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 298 |  | 
| Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 299 | /* Infineon TUA6034 | 
| Michael Krufky | d9e12f2 | 2006-04-22 16:15:11 -0300 | [diff] [blame] | 300 |  * used in LG TDVS-H061F, LG TDVS-H062F and LG TDVS-H064F | 
| Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 301 |  */ | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 302 | static struct dvb_pll_desc dvb_pll_lg_tdvs_h06xf = { | 
| Michael Krufky | d9e12f2 | 2006-04-22 16:15:11 -0300 | [diff] [blame] | 303 | 	.name  = "LG TDVS-H06xF", | 
| Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 304 | 	.min   =  54000000, | 
 | 305 | 	.max   = 863000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 306 | 	.iffreq= 44000000, | 
| Trent Piepho | 6bdcc6e | 2007-04-27 12:31:30 -0300 | [diff] [blame] | 307 | 	.initdata = tua603x_agc103, | 
| Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 308 | 	.count = 3, | 
 | 309 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 310 | 		{  165000000, 62500, 0xce, 0x01 }, | 
 | 311 | 		{  450000000, 62500, 0xce, 0x02 }, | 
 | 312 | 		{  999999999, 62500, 0xce, 0x04 }, | 
| Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 313 | 	}, | 
 | 314 | }; | 
| Michael Krufky | 1963c90 | 2005-08-08 09:22:43 -0700 | [diff] [blame] | 315 |  | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 316 | /* Philips FMD1216ME | 
 | 317 |  * used in Medion Hybrid PCMCIA card and USB Box | 
 | 318 |  */ | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 319 | static void fmd1216me_bw(struct dvb_frontend *fe, u8 *buf, | 
 | 320 | 			 const struct dvb_frontend_parameters *params) | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 321 | { | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 322 | 	if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && | 
 | 323 | 	    params->frequency >= 158870000) | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 324 | 		buf[3] |= 0x08; | 
 | 325 | } | 
 | 326 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 327 | static struct dvb_pll_desc dvb_pll_fmd1216me = { | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 328 | 	.name = "Philips FMD1216ME", | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 329 | 	.min = 50870000, | 
 | 330 | 	.max = 858000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 331 | 	.iffreq= 36125000, | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 332 | 	.set   = fmd1216me_bw, | 
| Trent Piepho | b7754d7 | 2007-05-08 18:05:16 -0300 | [diff] [blame] | 333 | 	.initdata = tua603x_agc112, | 
 | 334 | 	.sleepdata = (u8[]){ 4, 0x9c, 0x60, 0x85, 0x54 }, | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 335 | 	.count = 7, | 
 | 336 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 337 | 		{ 143870000, 166667, 0xbc, 0x41 }, | 
 | 338 | 		{ 158870000, 166667, 0xf4, 0x41 }, | 
 | 339 | 		{ 329870000, 166667, 0xbc, 0x42 }, | 
 | 340 | 		{ 441870000, 166667, 0xf4, 0x42 }, | 
 | 341 | 		{ 625870000, 166667, 0xbc, 0x44 }, | 
 | 342 | 		{ 803870000, 166667, 0xf4, 0x44 }, | 
 | 343 | 		{ 999999999, 166667, 0xfc, 0x44 }, | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 344 | 	} | 
 | 345 | }; | 
| Patrick Boettcher | 49dc82f | 2005-07-07 17:58:09 -0700 | [diff] [blame] | 346 |  | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 347 | /* ALPS TDED4 | 
 | 348 |  * used in Nebula-Cards and USB boxes | 
 | 349 |  */ | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 350 | static void tded4_bw(struct dvb_frontend *fe, u8 *buf, | 
 | 351 | 		     const struct dvb_frontend_parameters *params) | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 352 | { | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 353 | 	if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 354 | 		buf[3] |= 0x04; | 
 | 355 | } | 
 | 356 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 357 | static struct dvb_pll_desc dvb_pll_tded4 = { | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 358 | 	.name = "ALPS TDED4", | 
 | 359 | 	.min = 47000000, | 
 | 360 | 	.max = 863000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 361 | 	.iffreq= 36166667, | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 362 | 	.set   = tded4_bw, | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 363 | 	.count = 4, | 
 | 364 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 365 | 		{ 153000000, 166667, 0x85, 0x01 }, | 
 | 366 | 		{ 470000000, 166667, 0x85, 0x02 }, | 
 | 367 | 		{ 823000000, 166667, 0x85, 0x08 }, | 
 | 368 | 		{ 999999999, 166667, 0x85, 0x88 }, | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 369 | 	} | 
 | 370 | }; | 
| Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 371 |  | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 372 | /* ALPS TDHU2 | 
 | 373 |  * used in AverTVHD MCE A180 | 
 | 374 |  */ | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 375 | static struct dvb_pll_desc dvb_pll_tdhu2 = { | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 376 | 	.name = "ALPS TDHU2", | 
 | 377 | 	.min = 54000000, | 
 | 378 | 	.max = 864000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 379 | 	.iffreq= 44000000, | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 380 | 	.count = 4, | 
 | 381 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 382 | 		{ 162000000, 62500, 0x85, 0x01 }, | 
 | 383 | 		{ 426000000, 62500, 0x85, 0x02 }, | 
 | 384 | 		{ 782000000, 62500, 0x85, 0x08 }, | 
 | 385 | 		{ 999999999, 62500, 0x85, 0x88 }, | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 386 | 	} | 
 | 387 | }; | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 388 |  | 
 | 389 | /* Philips TUV1236D | 
 | 390 |  * used in ATI HDTV Wonder | 
 | 391 |  */ | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 392 | static void tuv1236d_rf(struct dvb_frontend *fe, u8 *buf, | 
 | 393 | 			const struct dvb_frontend_parameters *params) | 
| Michael Krufky | 4abe9f9 | 2007-05-05 12:15:57 -0300 | [diff] [blame] | 394 | { | 
| Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame^] | 395 | 	struct dvb_pll_priv *priv = fe->tuner_priv; | 
 | 396 | 	unsigned int new_rf = input[priv->nr]; | 
 | 397 |  | 
 | 398 | 	if ((new_rf == 0) || (new_rf > 2)) { | 
 | 399 | 		switch (params->u.vsb.modulation) { | 
 | 400 | 			case QAM_64: | 
 | 401 | 			case QAM_256: | 
 | 402 | 				new_rf = 1; | 
 | 403 | 				break; | 
 | 404 | 			case VSB_8: | 
 | 405 | 			default: | 
 | 406 | 				new_rf = 2; | 
 | 407 | 		} | 
 | 408 | 	} | 
 | 409 |  | 
 | 410 | 	switch (new_rf) { | 
 | 411 | 		case 1: | 
| Michael Krufky | 4abe9f9 | 2007-05-05 12:15:57 -0300 | [diff] [blame] | 412 | 			buf[3] |= 0x08; | 
 | 413 | 			break; | 
| Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame^] | 414 | 		case 2: | 
| Michael Krufky | 4abe9f9 | 2007-05-05 12:15:57 -0300 | [diff] [blame] | 415 | 			buf[3] &= ~0x08; | 
| Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame^] | 416 | 			break; | 
 | 417 | 		default: | 
 | 418 | 			printk(KERN_WARNING | 
 | 419 | 			       "%s: unhandled rf input selection: %d", | 
 | 420 | 			       __FUNCTION__, new_rf); | 
| Michael Krufky | 4abe9f9 | 2007-05-05 12:15:57 -0300 | [diff] [blame] | 421 | 	} | 
 | 422 | } | 
 | 423 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 424 | static struct dvb_pll_desc dvb_pll_tuv1236d = { | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 425 | 	.name  = "Philips TUV1236D", | 
| Kirk Lapray | 04a4592 | 2005-11-08 21:35:46 -0800 | [diff] [blame] | 426 | 	.min   =  54000000, | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 427 | 	.max   = 864000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 428 | 	.iffreq= 44000000, | 
| Michael Krufky | 4abe9f9 | 2007-05-05 12:15:57 -0300 | [diff] [blame] | 429 | 	.set   = tuv1236d_rf, | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 430 | 	.count = 3, | 
 | 431 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 432 | 		{ 157250000, 62500, 0xc6, 0x41 }, | 
 | 433 | 		{ 454000000, 62500, 0xc6, 0x42 }, | 
 | 434 | 		{ 999999999, 62500, 0xc6, 0x44 }, | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 435 | 	}, | 
 | 436 | }; | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 437 |  | 
| Michael Krufky | d76a617 | 2006-01-23 17:11:06 -0200 | [diff] [blame] | 438 | /* Samsung TBMV30111IN / TBMV30712IN1 | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 439 |  * used in Air2PC ATSC - 2nd generation (nxt2002) | 
 | 440 |  */ | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 441 | static struct dvb_pll_desc dvb_pll_samsung_tbmv = { | 
| Michael Krufky | 28f3d4b | 2006-01-23 17:11:07 -0200 | [diff] [blame] | 442 | 	.name = "Samsung TBMV30111IN / TBMV30712IN1", | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 443 | 	.min = 54000000, | 
 | 444 | 	.max = 860000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 445 | 	.iffreq= 44000000, | 
| Michael Krufky | 17c37ef | 2006-01-15 19:04:04 -0200 | [diff] [blame] | 446 | 	.count = 6, | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 447 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 448 | 		{ 172000000, 166667, 0xb4, 0x01 }, | 
 | 449 | 		{ 214000000, 166667, 0xb4, 0x02 }, | 
 | 450 | 		{ 467000000, 166667, 0xbc, 0x02 }, | 
 | 451 | 		{ 721000000, 166667, 0xbc, 0x08 }, | 
 | 452 | 		{ 841000000, 166667, 0xf4, 0x08 }, | 
 | 453 | 		{ 999999999, 166667, 0xfc, 0x02 }, | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 454 | 	} | 
 | 455 | }; | 
| Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 456 |  | 
| Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 457 | /* | 
 | 458 |  * Philips SD1878 Tuner. | 
 | 459 |  */ | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 460 | static struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = { | 
| Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 461 | 	.name  = "Philips SD1878", | 
 | 462 | 	.min   =  950000, | 
 | 463 | 	.max   = 2150000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 464 | 	.iffreq= 249, /* zero-IF, offset 249 is to round up */ | 
| Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 465 | 	.count = 4, | 
 | 466 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 467 | 		{ 1250000, 500, 0xc4, 0x00}, | 
 | 468 | 		{ 1550000, 500, 0xc4, 0x40}, | 
 | 469 | 		{ 2050000, 500, 0xc4, 0x80}, | 
 | 470 | 		{ 2150000, 500, 0xc4, 0xc0}, | 
| Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 471 | 	}, | 
 | 472 | }; | 
| Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 473 |  | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 474 | /* | 
 | 475 |  * Philips TD1316 Tuner. | 
 | 476 |  */ | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 477 | static void td1316_bw(struct dvb_frontend *fe, u8 *buf, | 
 | 478 | 		      const struct dvb_frontend_parameters *params) | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 479 | { | 
 | 480 | 	u8 band; | 
 | 481 |  | 
 | 482 | 	/* determine band */ | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 483 | 	if (params->frequency < 161000000) | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 484 | 		band = 1; | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 485 | 	else if (params->frequency < 444000000) | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 486 | 		band = 2; | 
 | 487 | 	else | 
 | 488 | 		band = 4; | 
 | 489 |  | 
 | 490 | 	buf[3] |= band; | 
 | 491 |  | 
 | 492 | 	/* setup PLL filter */ | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 493 | 	if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 494 | 		buf[3] |= 1 << 3; | 
 | 495 | } | 
 | 496 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 497 | static struct dvb_pll_desc dvb_pll_philips_td1316 = { | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 498 | 	.name  = "Philips TD1316", | 
 | 499 | 	.min   =  87000000, | 
 | 500 | 	.max   = 895000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 501 | 	.iffreq= 36166667, | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 502 | 	.set   = td1316_bw, | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 503 | 	.count = 9, | 
 | 504 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 505 | 		{  93834000, 166667, 0xca, 0x60}, | 
 | 506 | 		{ 123834000, 166667, 0xca, 0xa0}, | 
 | 507 | 		{ 163834000, 166667, 0xca, 0xc0}, | 
 | 508 | 		{ 253834000, 166667, 0xca, 0x60}, | 
 | 509 | 		{ 383834000, 166667, 0xca, 0xa0}, | 
 | 510 | 		{ 443834000, 166667, 0xca, 0xc0}, | 
 | 511 | 		{ 583834000, 166667, 0xca, 0x60}, | 
 | 512 | 		{ 793834000, 166667, 0xca, 0xa0}, | 
 | 513 | 		{ 858834000, 166667, 0xca, 0xe0}, | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 514 | 	}, | 
 | 515 | }; | 
| Jose Alberto Reguero | a78d0bf | 2006-02-07 06:25:14 -0200 | [diff] [blame] | 516 |  | 
| Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 517 | /* FE6600 used on DViCO Hybrid */ | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 518 | static struct dvb_pll_desc dvb_pll_thomson_fe6600 = { | 
| Michael Krufky | 91ae329 | 2006-03-01 00:04:42 -0300 | [diff] [blame] | 519 | 	.name = "Thomson FE6600", | 
| Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 520 | 	.min =  44250000, | 
 | 521 | 	.max = 858000000, | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 522 | 	.iffreq= 36125000, | 
| Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 523 | 	.count = 4, | 
 | 524 | 	.entries = { | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 525 | 		{ 250000000, 166667, 0xb4, 0x12 }, | 
 | 526 | 		{ 455000000, 166667, 0xfe, 0x11 }, | 
 | 527 | 		{ 775500000, 166667, 0xbc, 0x18 }, | 
 | 528 | 		{ 999999999, 166667, 0xf4, 0x18 }, | 
| Chris Pascoe | 780dfef | 2006-02-28 08:34:59 -0300 | [diff] [blame] | 529 | 	} | 
 | 530 | }; | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 531 |  | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 532 | static void opera1_bw(struct dvb_frontend *fe, u8 *buf, | 
 | 533 | 		      const struct dvb_frontend_parameters *params) | 
| Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 534 | { | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 535 | 	if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | 
| Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 536 | 		buf[2] |= 0x08; | 
 | 537 | } | 
 | 538 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 539 | static struct dvb_pll_desc dvb_pll_opera1 = { | 
| Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 540 | 	.name  = "Opera Tuner", | 
 | 541 | 	.min   =  900000, | 
 | 542 | 	.max   = 2250000, | 
 | 543 | 	.iffreq= 0, | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 544 | 	.set   = opera1_bw, | 
| Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 545 | 	.count = 8, | 
 | 546 | 	.entries = { | 
 | 547 | 		{ 1064000, 500, 0xe5, 0xc6 }, | 
 | 548 | 		{ 1169000, 500, 0xe5, 0xe6 }, | 
 | 549 | 		{ 1299000, 500, 0xe5, 0x24 }, | 
 | 550 | 		{ 1444000, 500, 0xe5, 0x44 }, | 
 | 551 | 		{ 1606000, 500, 0xe5, 0x64 }, | 
 | 552 | 		{ 1777000, 500, 0xe5, 0x84 }, | 
 | 553 | 		{ 1941000, 500, 0xe5, 0xa4 }, | 
 | 554 | 		{ 2250000, 500, 0xe5, 0xc4 }, | 
 | 555 | 	} | 
 | 556 | }; | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 557 |  | 
| Michael Krufky | f1b2439 | 2006-10-13 22:18:01 -0300 | [diff] [blame] | 558 | /* Philips FCV1236D | 
 | 559 |  */ | 
| Adrian Bunk | 0a0f2c8 | 2007-07-29 12:40:48 -0300 | [diff] [blame] | 560 | static struct dvb_pll_desc dvb_pll_fcv1236d = { | 
| Michael Krufky | f1b2439 | 2006-10-13 22:18:01 -0300 | [diff] [blame] | 561 | /* Bit_0: RF Input select | 
 | 562 |  * Bit_1: 0=digital, 1=analog | 
 | 563 |  */ | 
 | 564 | 	.name  = "Philips FCV1236D", | 
 | 565 | 	.min   =  53000000, | 
 | 566 | 	.max   = 803000000, | 
 | 567 | 	.iffreq= 44000000, | 
 | 568 | 	.count = 3, | 
 | 569 | 	.entries = { | 
 | 570 | 		{ 159000000, 62500, 0x8e, 0xa0 }, | 
 | 571 | 		{ 453000000, 62500, 0x8e, 0x90 }, | 
 | 572 | 		{ 999999999, 62500, 0x8e, 0x30 }, | 
 | 573 | 	}, | 
 | 574 | }; | 
 | 575 |  | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 576 | /* ----------------------------------------------------------- */ | 
 | 577 |  | 
 | 578 | static struct dvb_pll_desc *pll_list[] = { | 
 | 579 | 	[DVB_PLL_UNDEFINED]              = NULL, | 
 | 580 | 	[DVB_PLL_THOMSON_DTT7579]        = &dvb_pll_thomson_dtt7579, | 
 | 581 | 	[DVB_PLL_THOMSON_DTT759X]        = &dvb_pll_thomson_dtt759x, | 
 | 582 | 	[DVB_PLL_THOMSON_DTT7610]        = &dvb_pll_thomson_dtt7610, | 
 | 583 | 	[DVB_PLL_LG_Z201]                = &dvb_pll_lg_z201, | 
 | 584 | 	[DVB_PLL_MICROTUNE_4042]         = &dvb_pll_microtune_4042, | 
 | 585 | 	[DVB_PLL_THOMSON_DTT761X]        = &dvb_pll_thomson_dtt761x, | 
 | 586 | 	[DVB_PLL_UNKNOWN_1]              = &dvb_pll_unknown_1, | 
 | 587 | 	[DVB_PLL_TUA6010XS]              = &dvb_pll_tua6010xs, | 
 | 588 | 	[DVB_PLL_ENV57H1XD5]             = &dvb_pll_env57h1xd5, | 
 | 589 | 	[DVB_PLL_TUA6034]                = &dvb_pll_tua6034, | 
 | 590 | 	[DVB_PLL_LG_TDVS_H06XF]          = &dvb_pll_lg_tdvs_h06xf, | 
 | 591 | 	[DVB_PLL_TDA665X]                = &dvb_pll_tda665x, | 
 | 592 | 	[DVB_PLL_FMD1216ME]              = &dvb_pll_fmd1216me, | 
 | 593 | 	[DVB_PLL_TDED4]                  = &dvb_pll_tded4, | 
 | 594 | 	[DVB_PLL_TUV1236D]               = &dvb_pll_tuv1236d, | 
 | 595 | 	[DVB_PLL_TDHU2]                  = &dvb_pll_tdhu2, | 
 | 596 | 	[DVB_PLL_SAMSUNG_TBMV]           = &dvb_pll_samsung_tbmv, | 
 | 597 | 	[DVB_PLL_PHILIPS_SD1878_TDA8261] = &dvb_pll_philips_sd1878_tda8261, | 
 | 598 | 	[DVB_PLL_PHILIPS_TD1316]         = &dvb_pll_philips_td1316, | 
 | 599 | 	[DVB_PLL_THOMSON_FE6600]         = &dvb_pll_thomson_fe6600, | 
 | 600 | 	[DVB_PLL_OPERA1]                 = &dvb_pll_opera1, | 
| Michael Krufky | f1b2439 | 2006-10-13 22:18:01 -0300 | [diff] [blame] | 601 | 	[DVB_PLL_FCV1236D]               = &dvb_pll_fcv1236d, | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 602 | }; | 
 | 603 |  | 
 | 604 | /* ----------------------------------------------------------- */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | /* code                                                        */ | 
 | 606 |  | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 607 | static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf, | 
| Trent Piepho | 4ce1567 | 2007-06-02 16:30:46 -0300 | [diff] [blame] | 608 | 			     const struct dvb_frontend_parameters *params) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | { | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 610 | 	struct dvb_pll_priv *priv = fe->tuner_priv; | 
 | 611 | 	struct dvb_pll_desc *desc = priv->pll_desc; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | 	u32 div; | 
 | 613 | 	int i; | 
 | 614 |  | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 615 | 	if (params->frequency != 0 && (params->frequency < desc->min || | 
 | 616 | 				       params->frequency > desc->max)) | 
 | 617 | 		return -EINVAL; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 |  | 
 | 619 | 	for (i = 0; i < desc->count; i++) { | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 620 | 		if (params->frequency > desc->entries[i].limit) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | 			continue; | 
 | 622 | 		break; | 
 | 623 | 	} | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 624 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | 	if (debug) | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 626 | 		printk("pll: %s: freq=%d | i=%d/%d\n", desc->name, | 
 | 627 | 		       params->frequency, i, desc->count); | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 628 | 	if (i == desc->count) | 
 | 629 | 		return -EINVAL; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 |  | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 631 | 	div = (params->frequency + desc->iffreq + | 
 | 632 | 	       desc->entries[i].stepsize/2) / desc->entries[i].stepsize; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | 	buf[0] = div >> 8; | 
 | 634 | 	buf[1] = div & 0xff; | 
| Michael Krufky | ab66b22 | 2006-01-23 17:11:11 -0200 | [diff] [blame] | 635 | 	buf[2] = desc->entries[i].config; | 
 | 636 | 	buf[3] = desc->entries[i].cb; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 |  | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 638 | 	if (desc->set) | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 639 | 		desc->set(fe, buf, params); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 |  | 
 | 641 | 	if (debug) | 
 | 642 | 		printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", | 
 | 643 | 		       desc->name, div, buf[0], buf[1], buf[2], buf[3]); | 
 | 644 |  | 
| Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 645 | 	// calculate the frequency we set it to | 
| Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 646 | 	return (div * desc->entries[i].stepsize) - desc->iffreq; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 |  | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 649 | static int dvb_pll_release(struct dvb_frontend *fe) | 
 | 650 | { | 
| Michael Krufky | 2213918 | 2006-11-19 19:49:11 -0300 | [diff] [blame] | 651 | 	kfree(fe->tuner_priv); | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 652 | 	fe->tuner_priv = NULL; | 
 | 653 | 	return 0; | 
 | 654 | } | 
 | 655 |  | 
 | 656 | static int dvb_pll_sleep(struct dvb_frontend *fe) | 
 | 657 | { | 
 | 658 | 	struct dvb_pll_priv *priv = fe->tuner_priv; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 659 |  | 
| Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 660 | 	if (priv->i2c == NULL) | 
 | 661 | 		return -EINVAL; | 
 | 662 |  | 
| Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 663 | 	if (priv->pll_desc->sleepdata) { | 
 | 664 | 		struct i2c_msg msg = { .flags = 0, | 
 | 665 | 			.addr = priv->pll_i2c_address, | 
 | 666 | 			.buf = priv->pll_desc->sleepdata + 1, | 
 | 667 | 			.len = priv->pll_desc->sleepdata[0] }; | 
 | 668 |  | 
 | 669 | 		int result; | 
 | 670 |  | 
 | 671 | 		if (fe->ops.i2c_gate_ctrl) | 
 | 672 | 			fe->ops.i2c_gate_ctrl(fe, 1); | 
 | 673 | 		if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { | 
 | 674 | 			return result; | 
 | 675 | 		} | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 676 | 		return 0; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 677 | 	} | 
| Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 678 | 	/* Shouldn't be called when initdata is NULL, maybe BUG()? */ | 
 | 679 | 	return -EINVAL; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 680 | } | 
 | 681 |  | 
| Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 682 | static int dvb_pll_set_params(struct dvb_frontend *fe, | 
 | 683 | 			      struct dvb_frontend_parameters *params) | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 684 | { | 
 | 685 | 	struct dvb_pll_priv *priv = fe->tuner_priv; | 
 | 686 | 	u8 buf[4]; | 
 | 687 | 	struct i2c_msg msg = | 
| Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 688 | 		{ .addr = priv->pll_i2c_address, .flags = 0, | 
 | 689 | 		  .buf = buf, .len = sizeof(buf) }; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 690 | 	int result; | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 691 | 	u32 frequency = 0; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 692 |  | 
 | 693 | 	if (priv->i2c == NULL) | 
 | 694 | 		return -EINVAL; | 
 | 695 |  | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 696 | 	if ((result = dvb_pll_configure(fe, buf, params)) < 0) | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 697 | 		return result; | 
| Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 698 | 	else | 
 | 699 | 		frequency = result; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 700 |  | 
| Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 701 | 	if (fe->ops.i2c_gate_ctrl) | 
 | 702 | 		fe->ops.i2c_gate_ctrl(fe, 1); | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 703 | 	if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { | 
 | 704 | 		return result; | 
 | 705 | 	} | 
 | 706 |  | 
| Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 707 | 	priv->frequency = frequency; | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 708 | 	priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 709 |  | 
 | 710 | 	return 0; | 
 | 711 | } | 
 | 712 |  | 
| Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 713 | static int dvb_pll_calc_regs(struct dvb_frontend *fe, | 
 | 714 | 			     struct dvb_frontend_parameters *params, | 
 | 715 | 			     u8 *buf, int buf_len) | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 716 | { | 
 | 717 | 	struct dvb_pll_priv *priv = fe->tuner_priv; | 
 | 718 | 	int result; | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 719 | 	u32 frequency = 0; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 720 |  | 
 | 721 | 	if (buf_len < 5) | 
 | 722 | 		return -EINVAL; | 
 | 723 |  | 
| Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 724 | 	if ((result = dvb_pll_configure(fe, buf+1, params)) < 0) | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 725 | 		return result; | 
| Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 726 | 	else | 
 | 727 | 		frequency = result; | 
 | 728 |  | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 729 | 	buf[0] = priv->pll_i2c_address; | 
 | 730 |  | 
| Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 731 | 	priv->frequency = frequency; | 
| Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 732 | 	priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 733 |  | 
 | 734 | 	return 5; | 
 | 735 | } | 
 | 736 |  | 
 | 737 | static int dvb_pll_get_frequency(struct dvb_frontend *fe, u32 *frequency) | 
 | 738 | { | 
 | 739 | 	struct dvb_pll_priv *priv = fe->tuner_priv; | 
 | 740 | 	*frequency = priv->frequency; | 
 | 741 | 	return 0; | 
 | 742 | } | 
 | 743 |  | 
 | 744 | static int dvb_pll_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | 
 | 745 | { | 
 | 746 | 	struct dvb_pll_priv *priv = fe->tuner_priv; | 
 | 747 | 	*bandwidth = priv->bandwidth; | 
 | 748 | 	return 0; | 
 | 749 | } | 
 | 750 |  | 
| Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame] | 751 | static int dvb_pll_init(struct dvb_frontend *fe) | 
 | 752 | { | 
 | 753 | 	struct dvb_pll_priv *priv = fe->tuner_priv; | 
 | 754 |  | 
 | 755 | 	if (priv->i2c == NULL) | 
 | 756 | 		return -EINVAL; | 
 | 757 |  | 
 | 758 | 	if (priv->pll_desc->initdata) { | 
 | 759 | 		struct i2c_msg msg = { .flags = 0, | 
 | 760 | 			.addr = priv->pll_i2c_address, | 
 | 761 | 			.buf = priv->pll_desc->initdata + 1, | 
 | 762 | 			.len = priv->pll_desc->initdata[0] }; | 
 | 763 |  | 
 | 764 | 		int result; | 
 | 765 | 		if (fe->ops.i2c_gate_ctrl) | 
 | 766 | 			fe->ops.i2c_gate_ctrl(fe, 1); | 
 | 767 | 		if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { | 
 | 768 | 			return result; | 
 | 769 | 		} | 
 | 770 | 		return 0; | 
 | 771 | 	} | 
 | 772 | 	/* Shouldn't be called when initdata is NULL, maybe BUG()? */ | 
 | 773 | 	return -EINVAL; | 
 | 774 | } | 
 | 775 |  | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 776 | static struct dvb_tuner_ops dvb_pll_tuner_ops = { | 
 | 777 | 	.release = dvb_pll_release, | 
 | 778 | 	.sleep = dvb_pll_sleep, | 
| Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 779 | 	.init = dvb_pll_init, | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 780 | 	.set_params = dvb_pll_set_params, | 
| Andrew de Quincey | bd4956b | 2006-04-18 21:38:49 -0300 | [diff] [blame] | 781 | 	.calc_regs = dvb_pll_calc_regs, | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 782 | 	.get_frequency = dvb_pll_get_frequency, | 
 | 783 | 	.get_bandwidth = dvb_pll_get_bandwidth, | 
 | 784 | }; | 
 | 785 |  | 
| Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 786 | struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, | 
 | 787 | 				    struct i2c_adapter *i2c, | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 788 | 				    unsigned int pll_desc_id) | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 789 | { | 
| Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 790 | 	u8 b1 [] = { 0 }; | 
| Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 791 | 	struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, | 
 | 792 | 			       .buf = b1, .len = 1 }; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 793 | 	struct dvb_pll_priv *priv = NULL; | 
| Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 794 | 	int ret; | 
| Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 795 | 	struct dvb_pll_desc *desc; | 
 | 796 |  | 
 | 797 | 	BUG_ON(pll_desc_id < 1 || pll_desc_id >= ARRAY_SIZE(pll_list)); | 
 | 798 |  | 
 | 799 | 	desc = pll_list[pll_desc_id]; | 
| Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 800 |  | 
| Andrew de Quincey | 55c05b6 | 2006-07-16 19:41:41 -0300 | [diff] [blame] | 801 | 	if (i2c != NULL) { | 
 | 802 | 		if (fe->ops.i2c_gate_ctrl) | 
 | 803 | 			fe->ops.i2c_gate_ctrl(fe, 1); | 
| Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 804 |  | 
| Andrew de Quincey | 95faba2 | 2006-07-18 16:37:13 -0300 | [diff] [blame] | 805 | 		ret = i2c_transfer (i2c, &msg, 1); | 
 | 806 | 		if (ret != 1) | 
| Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 807 | 			return NULL; | 
| Andrew de Quincey | 55c05b6 | 2006-07-16 19:41:41 -0300 | [diff] [blame] | 808 | 		if (fe->ops.i2c_gate_ctrl) | 
 | 809 | 			     fe->ops.i2c_gate_ctrl(fe, 0); | 
 | 810 | 	} | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 811 |  | 
 | 812 | 	priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL); | 
 | 813 | 	if (priv == NULL) | 
| Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 814 | 		return NULL; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 815 |  | 
 | 816 | 	priv->pll_i2c_address = pll_addr; | 
 | 817 | 	priv->i2c = i2c; | 
 | 818 | 	priv->pll_desc = desc; | 
| Michael Krufky | a27e5e7 | 2007-09-07 18:11:15 -0300 | [diff] [blame] | 819 | 	priv->nr = dvb_pll_devcount++; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 820 |  | 
| Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 821 | 	memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops, | 
 | 822 | 	       sizeof(struct dvb_tuner_ops)); | 
 | 823 |  | 
| Trent Piepho | 982dd1b | 2007-04-27 12:31:27 -0300 | [diff] [blame] | 824 | 	strncpy(fe->ops.tuner_ops.info.name, desc->name, | 
 | 825 | 		sizeof(fe->ops.tuner_ops.info.name)); | 
| Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 826 | 	fe->ops.tuner_ops.info.frequency_min = desc->min; | 
| Trent Piepho | 0d84a62 | 2007-08-17 18:36:44 -0300 | [diff] [blame] | 827 | 	fe->ops.tuner_ops.info.frequency_max = desc->max; | 
| Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 828 | 	if (!desc->initdata) | 
 | 829 | 		fe->ops.tuner_ops.init = NULL; | 
 | 830 | 	if (!desc->sleepdata) | 
 | 831 | 		fe->ops.tuner_ops.sleep = NULL; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 832 |  | 
 | 833 | 	fe->tuner_priv = priv; | 
| Michael Krufky | a27e5e7 | 2007-09-07 18:11:15 -0300 | [diff] [blame] | 834 |  | 
 | 835 | 	if (debug) { | 
 | 836 | 		printk("dvb-pll[%d]", priv->nr); | 
 | 837 | 		if (i2c != NULL) | 
 | 838 | 			printk(" %d-%04x", i2c_adapter_id(i2c), pll_addr); | 
 | 839 | 		printk(": id# %d (%s) attached\n", pll_desc_id, desc->name); | 
 | 840 | 	} | 
 | 841 |  | 
| Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 842 | 	return fe; | 
| Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 843 | } | 
 | 844 | EXPORT_SYMBOL(dvb_pll_attach); | 
 | 845 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | MODULE_DESCRIPTION("dvb pll library"); | 
 | 847 | MODULE_AUTHOR("Gerd Knorr"); | 
 | 848 | MODULE_LICENSE("GPL"); |