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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Mauro Carvalho Chehab | 5479a58 | 2016-10-13 15:32:32 -0300 | [diff] [blame] | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 18 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/module.h> |
| 21 | #include <linux/dvb/frontend.h> |
| 22 | #include <asm/types.h> |
| 23 | |
| 24 | #include "dvb-pll.h" |
| 25 | |
Mauro Carvalho Chehab | 5479a58 | 2016-10-13 15:32:32 -0300 | [diff] [blame] | 26 | #define dprintk(fmt, arg...) \ |
| 27 | printk(KERN_DEBUG pr_fmt("%s: " fmt), __func__, ##arg) |
| 28 | |
Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame] | 29 | struct dvb_pll_priv { |
| 30 | /* pll number */ |
| 31 | int nr; |
| 32 | |
| 33 | /* i2c details */ |
| 34 | int pll_i2c_address; |
| 35 | struct i2c_adapter *i2c; |
| 36 | |
| 37 | /* the PLL descriptor */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 38 | const struct dvb_pll_desc *pll_desc; |
Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame] | 39 | |
| 40 | /* cached frequency/bandwidth */ |
| 41 | u32 frequency; |
| 42 | u32 bandwidth; |
| 43 | }; |
| 44 | |
Michael Krufky | ff3e7dd | 2007-09-09 13:00:45 -0300 | [diff] [blame] | 45 | #define DVB_PLL_MAX 64 |
Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame] | 46 | |
| 47 | static unsigned int dvb_pll_devcount; |
| 48 | |
Douglas Schilling Landgraf | ff699e6 | 2008-04-22 14:41:48 -0300 | [diff] [blame] | 49 | static int debug; |
Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame] | 50 | module_param(debug, int, 0644); |
| 51 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 52 | |
Michael Krufky | 704e39b | 2007-09-07 18:27:43 -0300 | [diff] [blame] | 53 | static unsigned int id[DVB_PLL_MAX] = |
| 54 | { [ 0 ... (DVB_PLL_MAX-1) ] = DVB_PLL_UNDEFINED }; |
| 55 | module_param_array(id, int, NULL, 0644); |
| 56 | MODULE_PARM_DESC(id, "force pll id to use (DEBUG ONLY)"); |
| 57 | |
Michael Krufky | 05a4611 | 2007-09-07 18:19:57 -0300 | [diff] [blame] | 58 | /* ----------------------------------------------------------- */ |
| 59 | |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 60 | struct dvb_pll_desc { |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 61 | const char *name; |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 62 | u32 min; |
| 63 | u32 max; |
| 64 | u32 iffreq; |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 65 | void (*set)(struct dvb_frontend *fe, u8 *buf); |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 66 | u8 *initdata; |
Malcolm Priestley | 2b74334 | 2011-02-06 12:29:51 -0300 | [diff] [blame] | 67 | u8 *initdata2; |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 68 | u8 *sleepdata; |
| 69 | int count; |
| 70 | struct { |
| 71 | u32 limit; |
| 72 | u32 stepsize; |
| 73 | u8 config; |
| 74 | u8 cb; |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 75 | } entries[]; |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 76 | }; |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | /* ----------------------------------------------------------- */ |
| 79 | /* descriptions */ |
| 80 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 81 | static const struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | .name = "Thomson dtt7579", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 83 | .min = 177 * MHz, |
| 84 | .max = 858 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 85 | .iffreq= 36166667, |
Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 86 | .sleepdata = (u8[]){ 2, 0xb4, 0x03 }, |
| 87 | .count = 4, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 89 | { 443250000, 166667, 0xb4, 0x02 }, |
| 90 | { 542000000, 166667, 0xb4, 0x08 }, |
| 91 | { 771000000, 166667, 0xbc, 0x08 }, |
| 92 | { 999999999, 166667, 0xf4, 0x08 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | }, |
| 94 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 96 | static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | { |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 98 | u32 bw = fe->dtv_property_cache.bandwidth_hz; |
| 99 | if (bw == 7000000) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | buf[3] |= 0x10; |
| 101 | } |
| 102 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 103 | static const struct dvb_pll_desc dvb_pll_thomson_dtt759x = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | .name = "Thomson dtt759x", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 105 | .min = 177 * MHz, |
| 106 | .max = 896 * MHz, |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 107 | .set = thomson_dtt759x_bw, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 108 | .iffreq= 36166667, |
Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 109 | .sleepdata = (u8[]){ 2, 0x84, 0x03 }, |
| 110 | .count = 5, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 112 | { 264000000, 166667, 0xb4, 0x02 }, |
| 113 | { 470000000, 166667, 0xbc, 0x02 }, |
| 114 | { 735000000, 166667, 0xbc, 0x08 }, |
| 115 | { 835000000, 166667, 0xf4, 0x08 }, |
| 116 | { 999999999, 166667, 0xfc, 0x08 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | }, |
| 118 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Patrice Chotard | 5fb6707 | 2012-07-31 15:31:20 -0300 | [diff] [blame] | 120 | static void thomson_dtt7520x_bw(struct dvb_frontend *fe, u8 *buf) |
| 121 | { |
| 122 | u32 bw = fe->dtv_property_cache.bandwidth_hz; |
| 123 | if (bw == 8000000) |
| 124 | buf[3] ^= 0x10; |
| 125 | } |
| 126 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 127 | static const struct dvb_pll_desc dvb_pll_thomson_dtt7520x = { |
Patrice Chotard | 5fb6707 | 2012-07-31 15:31:20 -0300 | [diff] [blame] | 128 | .name = "Thomson dtt7520x", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 129 | .min = 185 * MHz, |
| 130 | .max = 900 * MHz, |
Patrice Chotard | 5fb6707 | 2012-07-31 15:31:20 -0300 | [diff] [blame] | 131 | .set = thomson_dtt7520x_bw, |
| 132 | .iffreq = 36166667, |
| 133 | .count = 7, |
| 134 | .entries = { |
| 135 | { 305000000, 166667, 0xb4, 0x12 }, |
| 136 | { 405000000, 166667, 0xbc, 0x12 }, |
| 137 | { 445000000, 166667, 0xbc, 0x12 }, |
| 138 | { 465000000, 166667, 0xf4, 0x18 }, |
| 139 | { 735000000, 166667, 0xfc, 0x18 }, |
| 140 | { 835000000, 166667, 0xbc, 0x18 }, |
| 141 | { 999999999, 166667, 0xfc, 0x18 }, |
| 142 | }, |
| 143 | }; |
| 144 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 145 | static const struct dvb_pll_desc dvb_pll_lg_z201 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | .name = "LG z201", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 147 | .min = 174 * MHz, |
| 148 | .max = 862 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 149 | .iffreq= 36166667, |
Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 150 | .sleepdata = (u8[]){ 2, 0xbc, 0x03 }, |
| 151 | .count = 5, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 153 | { 157500000, 166667, 0xbc, 0x01 }, |
| 154 | { 443250000, 166667, 0xbc, 0x02 }, |
| 155 | { 542000000, 166667, 0xbc, 0x04 }, |
| 156 | { 830000000, 166667, 0xf4, 0x04 }, |
| 157 | { 999999999, 166667, 0xfc, 0x04 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | }, |
| 159 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 161 | static const struct dvb_pll_desc dvb_pll_unknown_1 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | .name = "unknown 1", /* used by dntv live dvb-t */ |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 163 | .min = 174 * MHz, |
| 164 | .max = 862 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 165 | .iffreq= 36166667, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | .count = 9, |
| 167 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 168 | { 150000000, 166667, 0xb4, 0x01 }, |
| 169 | { 173000000, 166667, 0xbc, 0x01 }, |
| 170 | { 250000000, 166667, 0xb4, 0x02 }, |
| 171 | { 400000000, 166667, 0xbc, 0x02 }, |
| 172 | { 420000000, 166667, 0xf4, 0x02 }, |
| 173 | { 470000000, 166667, 0xfc, 0x02 }, |
| 174 | { 600000000, 166667, 0xbc, 0x08 }, |
| 175 | { 730000000, 166667, 0xf4, 0x08 }, |
| 176 | { 999999999, 166667, 0xfc, 0x08 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | }, |
| 178 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 180 | /* Infineon TUA6010XS |
| 181 | * used in Thomson Cable Tuner |
| 182 | */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 183 | static const struct dvb_pll_desc dvb_pll_tua6010xs = { |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 184 | .name = "Infineon TUA6010XS", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 185 | .min = 44250 * kHz, |
| 186 | .max = 858 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 187 | .iffreq= 36125000, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 188 | .count = 3, |
| 189 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 190 | { 115750000, 62500, 0x8e, 0x03 }, |
| 191 | { 403250000, 62500, 0x8e, 0x06 }, |
| 192 | { 999999999, 62500, 0x8e, 0x85 }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 193 | }, |
| 194 | }; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 195 | |
| 196 | /* Panasonic env57h1xd5 (some Philips PLL ?) */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 197 | static const struct dvb_pll_desc dvb_pll_env57h1xd5 = { |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 198 | .name = "Panasonic ENV57H1XD5", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 199 | .min = 44250 * kHz, |
| 200 | .max = 858 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 201 | .iffreq= 36125000, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 202 | .count = 4, |
| 203 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 204 | { 153000000, 166667, 0xc2, 0x41 }, |
| 205 | { 470000000, 166667, 0xc2, 0x42 }, |
| 206 | { 526000000, 166667, 0xc2, 0x84 }, |
| 207 | { 999999999, 166667, 0xc2, 0xa4 }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 208 | }, |
| 209 | }; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 210 | |
| 211 | /* Philips TDA6650/TDA6651 |
| 212 | * used in Panasonic ENV77H11D5 |
| 213 | */ |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 214 | static void tda665x_bw(struct dvb_frontend *fe, u8 *buf) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 215 | { |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 216 | u32 bw = fe->dtv_property_cache.bandwidth_hz; |
| 217 | if (bw == 8000000) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 218 | buf[3] |= 0x08; |
| 219 | } |
| 220 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 221 | static const struct dvb_pll_desc dvb_pll_tda665x = { |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 222 | .name = "Philips TDA6650/TDA6651", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 223 | .min = 44250 * kHz, |
| 224 | .max = 858 * MHz, |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 225 | .set = tda665x_bw, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 226 | .iffreq= 36166667, |
Michael Krufky | fbfee86 | 2007-05-09 15:58:17 -0300 | [diff] [blame] | 227 | .initdata = (u8[]){ 4, 0x0b, 0xf5, 0x85, 0xab }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 228 | .count = 12, |
| 229 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 230 | { 93834000, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ }, |
| 231 | { 123834000, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ }, |
| 232 | { 161000000, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ }, |
| 233 | { 163834000, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ }, |
| 234 | { 253834000, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ }, |
| 235 | { 383834000, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ }, |
| 236 | { 443834000, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ }, |
| 237 | { 444000000, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ }, |
| 238 | { 583834000, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ }, |
| 239 | { 793834000, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ }, |
| 240 | { 444834000, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ }, |
| 241 | { 861000000, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 242 | } |
| 243 | }; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 244 | |
| 245 | /* Infineon TUA6034 |
| 246 | * used in LG TDTP E102P |
| 247 | */ |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 248 | static void tua6034_bw(struct dvb_frontend *fe, u8 *buf) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 249 | { |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 250 | u32 bw = fe->dtv_property_cache.bandwidth_hz; |
| 251 | if (bw == 7000000) |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 252 | buf[3] |= 0x08; |
| 253 | } |
| 254 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 255 | static const struct dvb_pll_desc dvb_pll_tua6034 = { |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 256 | .name = "Infineon TUA6034", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 257 | .min = 44250 * kHz, |
| 258 | .max = 858 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 259 | .iffreq= 36166667, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 260 | .count = 3, |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 261 | .set = tua6034_bw, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 262 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 263 | { 174500000, 62500, 0xce, 0x01 }, |
| 264 | { 230000000, 62500, 0xce, 0x02 }, |
| 265 | { 999999999, 62500, 0xce, 0x04 }, |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 266 | }, |
| 267 | }; |
Johannes Stezenbach | 776338e | 2005-06-23 22:02:35 -0700 | [diff] [blame] | 268 | |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 269 | /* ALPS TDED4 |
| 270 | * used in Nebula-Cards and USB boxes |
| 271 | */ |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 272 | static void tded4_bw(struct dvb_frontend *fe, u8 *buf) |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 273 | { |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 274 | u32 bw = fe->dtv_property_cache.bandwidth_hz; |
| 275 | if (bw == 8000000) |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 276 | buf[3] |= 0x04; |
| 277 | } |
| 278 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 279 | static const struct dvb_pll_desc dvb_pll_tded4 = { |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 280 | .name = "ALPS TDED4", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 281 | .min = 47 * MHz, |
| 282 | .max = 863 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 283 | .iffreq= 36166667, |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 284 | .set = tded4_bw, |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 285 | .count = 4, |
| 286 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 287 | { 153000000, 166667, 0x85, 0x01 }, |
| 288 | { 470000000, 166667, 0x85, 0x02 }, |
| 289 | { 823000000, 166667, 0x85, 0x08 }, |
| 290 | { 999999999, 166667, 0x85, 0x88 }, |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 291 | } |
| 292 | }; |
Patrick Boettcher | 0589b8e | 2005-07-07 17:58:12 -0700 | [diff] [blame] | 293 | |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 294 | /* ALPS TDHU2 |
| 295 | * used in AverTVHD MCE A180 |
| 296 | */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 297 | static const struct dvb_pll_desc dvb_pll_tdhu2 = { |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 298 | .name = "ALPS TDHU2", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 299 | .min = 54 * MHz, |
| 300 | .max = 864 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 301 | .iffreq= 44000000, |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 302 | .count = 4, |
| 303 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 304 | { 162000000, 62500, 0x85, 0x01 }, |
| 305 | { 426000000, 62500, 0x85, 0x02 }, |
| 306 | { 782000000, 62500, 0x85, 0x08 }, |
| 307 | { 999999999, 62500, 0x85, 0x88 }, |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 308 | } |
| 309 | }; |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 310 | |
Michael Krufky | d76a617 | 2006-01-23 17:11:06 -0200 | [diff] [blame] | 311 | /* Samsung TBMV30111IN / TBMV30712IN1 |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 312 | * used in Air2PC ATSC - 2nd generation (nxt2002) |
| 313 | */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 314 | static const struct dvb_pll_desc dvb_pll_samsung_tbmv = { |
Michael Krufky | 28f3d4b | 2006-01-23 17:11:07 -0200 | [diff] [blame] | 315 | .name = "Samsung TBMV30111IN / TBMV30712IN1", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 316 | .min = 54 * MHz, |
| 317 | .max = 860 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 318 | .iffreq= 44000000, |
Michael Krufky | 17c37ef | 2006-01-15 19:04:04 -0200 | [diff] [blame] | 319 | .count = 6, |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 320 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 321 | { 172000000, 166667, 0xb4, 0x01 }, |
| 322 | { 214000000, 166667, 0xb4, 0x02 }, |
| 323 | { 467000000, 166667, 0xbc, 0x02 }, |
| 324 | { 721000000, 166667, 0xbc, 0x08 }, |
| 325 | { 841000000, 166667, 0xf4, 0x08 }, |
| 326 | { 999999999, 166667, 0xfc, 0x02 }, |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 327 | } |
| 328 | }; |
Kirk Lapray | 147418c | 2005-11-08 21:35:39 -0800 | [diff] [blame] | 329 | |
Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 330 | /* |
| 331 | * Philips SD1878 Tuner. |
| 332 | */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 333 | static const struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = { |
Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 334 | .name = "Philips SD1878", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 335 | .min = 950 * MHz, |
| 336 | .max = 2150 * MHz, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 337 | .iffreq= 249, /* zero-IF, offset 249 is to round up */ |
Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 338 | .count = 4, |
| 339 | .entries = { |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 340 | { 1250000, 500, 0xc4, 0x00}, |
Manu Abraham | b3332a9 | 2007-07-03 09:58:57 -0300 | [diff] [blame] | 341 | { 1450000, 500, 0xc4, 0x40}, |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 342 | { 2050000, 500, 0xc4, 0x80}, |
| 343 | { 2150000, 500, 0xc4, 0xc0}, |
Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 344 | }, |
| 345 | }; |
Regis Prevot | f8bf134 | 2006-01-11 23:31:53 -0200 | [diff] [blame] | 346 | |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 347 | static void opera1_bw(struct dvb_frontend *fe, u8 *buf) |
Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 348 | { |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 349 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Malcolm Priestley | 2b74334 | 2011-02-06 12:29:51 -0300 | [diff] [blame] | 350 | struct dvb_pll_priv *priv = fe->tuner_priv; |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 351 | u32 b_w = (c->symbol_rate * 27) / 32000; |
Malcolm Priestley | 2b74334 | 2011-02-06 12:29:51 -0300 | [diff] [blame] | 352 | struct i2c_msg msg = { |
| 353 | .addr = priv->pll_i2c_address, |
| 354 | .flags = 0, |
| 355 | .buf = buf, |
| 356 | .len = 4 |
| 357 | }; |
| 358 | int result; |
| 359 | u8 lpf; |
| 360 | |
| 361 | if (fe->ops.i2c_gate_ctrl) |
| 362 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 363 | |
| 364 | result = i2c_transfer(priv->i2c, &msg, 1); |
| 365 | if (result != 1) |
Mauro Carvalho Chehab | 5479a58 | 2016-10-13 15:32:32 -0300 | [diff] [blame] | 366 | pr_err("%s: i2c_transfer failed:%d", |
Malcolm Priestley | 2b74334 | 2011-02-06 12:29:51 -0300 | [diff] [blame] | 367 | __func__, result); |
| 368 | |
| 369 | if (b_w <= 10000) |
| 370 | lpf = 0xc; |
| 371 | else if (b_w <= 12000) |
| 372 | lpf = 0x2; |
| 373 | else if (b_w <= 14000) |
| 374 | lpf = 0xa; |
| 375 | else if (b_w <= 16000) |
| 376 | lpf = 0x6; |
| 377 | else if (b_w <= 18000) |
| 378 | lpf = 0xe; |
| 379 | else if (b_w <= 20000) |
| 380 | lpf = 0x1; |
| 381 | else if (b_w <= 22000) |
| 382 | lpf = 0x9; |
| 383 | else if (b_w <= 24000) |
| 384 | lpf = 0x5; |
| 385 | else if (b_w <= 26000) |
| 386 | lpf = 0xd; |
| 387 | else if (b_w <= 28000) |
| 388 | lpf = 0x3; |
| 389 | else |
| 390 | lpf = 0xb; |
| 391 | buf[2] ^= 0x1c; /* Flip bits 3-5 */ |
| 392 | /* Set lpf */ |
| 393 | buf[2] |= ((lpf >> 2) & 0x3) << 3; |
| 394 | buf[3] |= (lpf & 0x3) << 2; |
| 395 | |
| 396 | return; |
Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 397 | } |
| 398 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 399 | static const struct dvb_pll_desc dvb_pll_opera1 = { |
Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 400 | .name = "Opera Tuner", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 401 | .min = 900 * MHz, |
| 402 | .max = 2250 * MHz, |
Malcolm Priestley | 2b74334 | 2011-02-06 12:29:51 -0300 | [diff] [blame] | 403 | .initdata = (u8[]){ 4, 0x08, 0xe5, 0xe1, 0x00 }, |
| 404 | .initdata2 = (u8[]){ 4, 0x08, 0xe5, 0xe5, 0x00 }, |
Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 405 | .iffreq= 0, |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 406 | .set = opera1_bw, |
Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 407 | .count = 8, |
| 408 | .entries = { |
Malcolm Priestley | 2b74334 | 2011-02-06 12:29:51 -0300 | [diff] [blame] | 409 | { 1064000, 500, 0xf9, 0xc2 }, |
| 410 | { 1169000, 500, 0xf9, 0xe2 }, |
| 411 | { 1299000, 500, 0xf9, 0x20 }, |
| 412 | { 1444000, 500, 0xf9, 0x40 }, |
| 413 | { 1606000, 500, 0xf9, 0x60 }, |
| 414 | { 1777000, 500, 0xf9, 0x80 }, |
| 415 | { 1941000, 500, 0xf9, 0xa0 }, |
| 416 | { 2250000, 500, 0xf9, 0xc0 }, |
Marco Gittler | 941491f | 2007-04-19 11:26:47 -0300 | [diff] [blame] | 417 | } |
| 418 | }; |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 419 | |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 420 | static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf) |
Antti Palosaari | 139dfeb | 2008-05-17 23:02:00 -0300 | [diff] [blame] | 421 | { |
| 422 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 423 | struct i2c_msg msg = { |
| 424 | .addr = priv->pll_i2c_address, |
| 425 | .flags = 0, |
| 426 | .buf = buf, |
| 427 | .len = 4 |
| 428 | }; |
| 429 | int result; |
| 430 | |
| 431 | if (fe->ops.i2c_gate_ctrl) |
| 432 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 433 | |
| 434 | result = i2c_transfer(priv->i2c, &msg, 1); |
| 435 | if (result != 1) |
Mauro Carvalho Chehab | 5479a58 | 2016-10-13 15:32:32 -0300 | [diff] [blame] | 436 | pr_err("%s: i2c_transfer failed:%d", |
Antti Palosaari | 139dfeb | 2008-05-17 23:02:00 -0300 | [diff] [blame] | 437 | __func__, result); |
| 438 | |
| 439 | buf[2] = 0x9e; |
| 440 | buf[3] = 0x90; |
| 441 | |
| 442 | return; |
| 443 | } |
| 444 | |
| 445 | /* unknown pll used in Samsung DTOS403IH102A DVB-C tuner */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 446 | static const struct dvb_pll_desc dvb_pll_samsung_dtos403ih102a = { |
Antti Palosaari | 139dfeb | 2008-05-17 23:02:00 -0300 | [diff] [blame] | 447 | .name = "Samsung DTOS403IH102A", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 448 | .min = 44250 * kHz, |
| 449 | .max = 858 * MHz, |
Antti Palosaari | 139dfeb | 2008-05-17 23:02:00 -0300 | [diff] [blame] | 450 | .iffreq = 36125000, |
| 451 | .count = 8, |
| 452 | .set = samsung_dtos403ih102a_set, |
| 453 | .entries = { |
| 454 | { 135000000, 62500, 0xbe, 0x01 }, |
| 455 | { 177000000, 62500, 0xf6, 0x01 }, |
| 456 | { 370000000, 62500, 0xbe, 0x02 }, |
| 457 | { 450000000, 62500, 0xf6, 0x02 }, |
| 458 | { 466000000, 62500, 0xfe, 0x02 }, |
| 459 | { 538000000, 62500, 0xbe, 0x08 }, |
| 460 | { 826000000, 62500, 0xf6, 0x08 }, |
| 461 | { 999999999, 62500, 0xfe, 0x08 }, |
| 462 | } |
| 463 | }; |
| 464 | |
Trent Piepho | a104ed0 | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 465 | /* Samsung TDTC9251DH0 DVB-T NIM, as used on AirStar 2 */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 466 | static const struct dvb_pll_desc dvb_pll_samsung_tdtc9251dh0 = { |
Trent Piepho | a104ed0 | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 467 | .name = "Samsung TDTC9251DH0", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 468 | .min = 48 * MHz, |
| 469 | .max = 863 * MHz, |
Trent Piepho | a104ed0 | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 470 | .iffreq = 36166667, |
| 471 | .count = 3, |
| 472 | .entries = { |
| 473 | { 157500000, 166667, 0xcc, 0x09 }, |
| 474 | { 443000000, 166667, 0xcc, 0x0a }, |
| 475 | { 863000000, 166667, 0xcc, 0x08 }, |
| 476 | } |
| 477 | }; |
| 478 | |
Trent Piepho | f52c485 | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 479 | /* Samsung TBDU18132 DVB-S NIM with TSA5059 PLL, used in SkyStar2 DVB-S 2.3 */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 480 | static const struct dvb_pll_desc dvb_pll_samsung_tbdu18132 = { |
Trent Piepho | f52c485 | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 481 | .name = "Samsung TBDU18132", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 482 | .min = 950 * MHz, |
| 483 | .max = 2150 * MHz, /* guesses */ |
Trent Piepho | f52c485 | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 484 | .iffreq = 0, |
| 485 | .count = 2, |
| 486 | .entries = { |
| 487 | { 1550000, 125, 0x84, 0x82 }, |
| 488 | { 4095937, 125, 0x84, 0x80 }, |
| 489 | } |
| 490 | /* TSA5059 PLL has a 17 bit divisor rather than the 15 bits supported |
| 491 | * by this driver. The two extra bits are 0x60 in the third byte. 15 |
| 492 | * bits is enough for over 4 GHz, which is enough to cover the range |
| 493 | * of this tuner. We could use the additional divisor bits by adding |
| 494 | * more entries, e.g. |
| 495 | { 0x0ffff * 125 + 125/2, 125, 0x84 | 0x20, }, |
| 496 | { 0x17fff * 125 + 125/2, 125, 0x84 | 0x40, }, |
| 497 | { 0x1ffff * 125 + 125/2, 125, 0x84 | 0x60, }, */ |
| 498 | }; |
| 499 | |
Trent Piepho | 9d5d75a | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 500 | /* Samsung TBMU24112 DVB-S NIM with SL1935 zero-IF tuner */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 501 | static const struct dvb_pll_desc dvb_pll_samsung_tbmu24112 = { |
Trent Piepho | 9d5d75a | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 502 | .name = "Samsung TBMU24112", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 503 | .min = 950 * MHz, |
| 504 | .max = 2150 * MHz, /* guesses */ |
Trent Piepho | 9d5d75a | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 505 | .iffreq = 0, |
| 506 | .count = 2, |
| 507 | .entries = { |
| 508 | { 1500000, 125, 0x84, 0x18 }, |
| 509 | { 9999999, 125, 0x84, 0x08 }, |
| 510 | } |
| 511 | }; |
| 512 | |
Trent Piepho | d799ce5 | 2009-06-11 19:24:00 -0300 | [diff] [blame] | 513 | /* Alps TDEE4 DVB-C NIM, used on Cablestar 2 */ |
| 514 | /* byte 4 : 1 * * AGD R3 R2 R1 R0 |
| 515 | * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1 |
| 516 | * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95 |
| 517 | * Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5 |
| 518 | * 47 - 153 0 * 0 0 0 0 0 1 0x01 |
| 519 | * 153 - 430 0 * 0 0 0 0 1 0 0x02 |
| 520 | * 430 - 822 0 * 0 0 1 0 0 0 0x08 |
| 521 | * 822 - 862 1 * 0 0 1 0 0 0 0x88 */ |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 522 | static const struct dvb_pll_desc dvb_pll_alps_tdee4 = { |
Trent Piepho | d799ce5 | 2009-06-11 19:24:00 -0300 | [diff] [blame] | 523 | .name = "ALPS TDEE4", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 524 | .min = 47 * MHz, |
| 525 | .max = 862 * MHz, |
Trent Piepho | d799ce5 | 2009-06-11 19:24:00 -0300 | [diff] [blame] | 526 | .iffreq = 36125000, |
| 527 | .count = 4, |
| 528 | .entries = { |
| 529 | { 153000000, 62500, 0x95, 0x01 }, |
| 530 | { 430000000, 62500, 0x95, 0x02 }, |
| 531 | { 822000000, 62500, 0x95, 0x08 }, |
| 532 | { 999999999, 62500, 0x95, 0x88 }, |
| 533 | } |
| 534 | }; |
| 535 | |
Akihiro Tsukada | 1745972 | 2018-04-08 13:21:35 -0400 | [diff] [blame] | 536 | /* Infineon TUA6034 ISDB-T, used in Friio */ |
| 537 | /* CP cur. 50uA, AGC takeover: 103dBuV, PORT3 on */ |
| 538 | static const struct dvb_pll_desc dvb_pll_tua6034_friio = { |
| 539 | .name = "Infineon TUA6034 ISDB-T (Friio)", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 540 | .min = 90 * MHz, |
| 541 | .max = 770 * MHz, |
Akihiro Tsukada | 1745972 | 2018-04-08 13:21:35 -0400 | [diff] [blame] | 542 | .iffreq = 57000000, |
| 543 | .initdata = (u8[]){ 4, 0x9a, 0x50, 0xb2, 0x08 }, |
| 544 | .sleepdata = (u8[]){ 4, 0x9a, 0x70, 0xb3, 0x0b }, |
| 545 | .count = 3, |
| 546 | .entries = { |
| 547 | { 170000000, 142857, 0xba, 0x09 }, |
| 548 | { 470000000, 142857, 0xba, 0x0a }, |
| 549 | { 770000000, 142857, 0xb2, 0x08 }, |
| 550 | } |
| 551 | }; |
| 552 | |
Akihiro Tsukada | 648db06 | 2018-04-08 13:39:49 -0400 | [diff] [blame] | 553 | /* Philips TDA6651 ISDB-T, used in Earthsoft PT1 */ |
| 554 | static const struct dvb_pll_desc dvb_pll_tda665x_earth_pt1 = { |
| 555 | .name = "Philips TDA6651 ISDB-T (EarthSoft PT1)", |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 556 | .min = 90 * MHz, |
| 557 | .max = 770 * MHz, |
Akihiro Tsukada | 648db06 | 2018-04-08 13:39:49 -0400 | [diff] [blame] | 558 | .iffreq = 57000000, |
| 559 | .initdata = (u8[]){ 5, 0x0e, 0x7f, 0xc1, 0x80, 0x80 }, |
| 560 | .count = 10, |
| 561 | .entries = { |
| 562 | { 140000000, 142857, 0xc1, 0x81 }, |
| 563 | { 170000000, 142857, 0xc1, 0xa1 }, |
| 564 | { 220000000, 142857, 0xc1, 0x62 }, |
| 565 | { 330000000, 142857, 0xc1, 0xa2 }, |
| 566 | { 402000000, 142857, 0xc1, 0xe2 }, |
| 567 | { 450000000, 142857, 0xc1, 0x64 }, |
| 568 | { 550000000, 142857, 0xc1, 0x84 }, |
| 569 | { 600000000, 142857, 0xc1, 0xa4 }, |
| 570 | { 700000000, 142857, 0xc1, 0xc4 }, |
| 571 | { 770000000, 142857, 0xc1, 0xe4 }, |
| 572 | } |
| 573 | }; |
| 574 | |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 575 | /* ----------------------------------------------------------- */ |
| 576 | |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 577 | static const struct dvb_pll_desc *pll_list[] = { |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 578 | [DVB_PLL_UNDEFINED] = NULL, |
| 579 | [DVB_PLL_THOMSON_DTT7579] = &dvb_pll_thomson_dtt7579, |
| 580 | [DVB_PLL_THOMSON_DTT759X] = &dvb_pll_thomson_dtt759x, |
Patrice Chotard | 5fb6707 | 2012-07-31 15:31:20 -0300 | [diff] [blame] | 581 | [DVB_PLL_THOMSON_DTT7520X] = &dvb_pll_thomson_dtt7520x, |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 582 | [DVB_PLL_LG_Z201] = &dvb_pll_lg_z201, |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 583 | [DVB_PLL_UNKNOWN_1] = &dvb_pll_unknown_1, |
| 584 | [DVB_PLL_TUA6010XS] = &dvb_pll_tua6010xs, |
| 585 | [DVB_PLL_ENV57H1XD5] = &dvb_pll_env57h1xd5, |
| 586 | [DVB_PLL_TUA6034] = &dvb_pll_tua6034, |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 587 | [DVB_PLL_TDA665X] = &dvb_pll_tda665x, |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 588 | [DVB_PLL_TDED4] = &dvb_pll_tded4, |
Trent Piepho | d799ce5 | 2009-06-11 19:24:00 -0300 | [diff] [blame] | 589 | [DVB_PLL_TDEE4] = &dvb_pll_alps_tdee4, |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 590 | [DVB_PLL_TDHU2] = &dvb_pll_tdhu2, |
| 591 | [DVB_PLL_SAMSUNG_TBMV] = &dvb_pll_samsung_tbmv, |
| 592 | [DVB_PLL_PHILIPS_SD1878_TDA8261] = &dvb_pll_philips_sd1878_tda8261, |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 593 | [DVB_PLL_OPERA1] = &dvb_pll_opera1, |
Antti Palosaari | 139dfeb | 2008-05-17 23:02:00 -0300 | [diff] [blame] | 594 | [DVB_PLL_SAMSUNG_DTOS403IH102A] = &dvb_pll_samsung_dtos403ih102a, |
Trent Piepho | a104ed0 | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 595 | [DVB_PLL_SAMSUNG_TDTC9251DH0] = &dvb_pll_samsung_tdtc9251dh0, |
Trent Piepho | f52c485 | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 596 | [DVB_PLL_SAMSUNG_TBDU18132] = &dvb_pll_samsung_tbdu18132, |
Trent Piepho | 9d5d75a | 2009-06-11 19:21:34 -0300 | [diff] [blame] | 597 | [DVB_PLL_SAMSUNG_TBMU24112] = &dvb_pll_samsung_tbmu24112, |
Akihiro Tsukada | 1745972 | 2018-04-08 13:21:35 -0400 | [diff] [blame] | 598 | [DVB_PLL_TUA6034_FRIIO] = &dvb_pll_tua6034_friio, |
Akihiro Tsukada | 648db06 | 2018-04-08 13:39:49 -0400 | [diff] [blame] | 599 | [DVB_PLL_TDA665X_EARTH_PT1] = &dvb_pll_tda665x_earth_pt1, |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 600 | }; |
| 601 | |
| 602 | /* ----------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | /* code */ |
| 604 | |
Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 605 | static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf, |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 606 | const u32 frequency) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | { |
Michael Krufky | 5d7802b | 2007-09-07 18:03:58 -0300 | [diff] [blame] | 608 | struct dvb_pll_priv *priv = fe->tuner_priv; |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 609 | const struct dvb_pll_desc *desc = priv->pll_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | u32 div; |
| 611 | int i; |
| 612 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | for (i = 0; i < desc->count; i++) { |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 614 | if (frequency > desc->entries[i].limit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | continue; |
| 616 | break; |
| 617 | } |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 618 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | if (debug) |
Mauro Carvalho Chehab | 5479a58 | 2016-10-13 15:32:32 -0300 | [diff] [blame] | 620 | dprintk("pll: %s: freq=%d | i=%d/%d\n", desc->name, |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 621 | frequency, i, desc->count); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 622 | if (i == desc->count) |
| 623 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 625 | div = (frequency + desc->iffreq + |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 626 | desc->entries[i].stepsize/2) / desc->entries[i].stepsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | buf[0] = div >> 8; |
| 628 | buf[1] = div & 0xff; |
Michael Krufky | ab66b22 | 2006-01-23 17:11:11 -0200 | [diff] [blame] | 629 | buf[2] = desc->entries[i].config; |
| 630 | buf[3] = desc->entries[i].cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 632 | if (desc->set) |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 633 | desc->set(fe, buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
| 635 | if (debug) |
Mauro Carvalho Chehab | 5479a58 | 2016-10-13 15:32:32 -0300 | [diff] [blame] | 636 | dprintk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | desc->name, div, buf[0], buf[1], buf[2], buf[3]); |
| 638 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 639 | // calculate the frequency we set it to |
Trent Piepho | df78cb0 | 2007-03-19 02:24:04 -0300 | [diff] [blame] | 640 | return (div * desc->entries[i].stepsize) - desc->iffreq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | |
Mauro Carvalho Chehab | f2709c2 | 2016-11-18 20:30:51 -0200 | [diff] [blame] | 643 | static void dvb_pll_release(struct dvb_frontend *fe) |
| 644 | { |
| 645 | kfree(fe->tuner_priv); |
| 646 | fe->tuner_priv = NULL; |
| 647 | } |
| 648 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 649 | static int dvb_pll_sleep(struct dvb_frontend *fe) |
| 650 | { |
| 651 | struct dvb_pll_priv *priv = fe->tuner_priv; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 652 | |
Chris Pascoe | c162dff | 2006-08-08 15:48:08 -0300 | [diff] [blame] | 653 | if (priv->i2c == NULL) |
| 654 | return -EINVAL; |
| 655 | |
Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 656 | if (priv->pll_desc->sleepdata) { |
| 657 | struct i2c_msg msg = { .flags = 0, |
| 658 | .addr = priv->pll_i2c_address, |
| 659 | .buf = priv->pll_desc->sleepdata + 1, |
| 660 | .len = priv->pll_desc->sleepdata[0] }; |
| 661 | |
| 662 | int result; |
| 663 | |
| 664 | if (fe->ops.i2c_gate_ctrl) |
| 665 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 666 | if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { |
| 667 | return result; |
| 668 | } |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 669 | return 0; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 670 | } |
Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 671 | /* Shouldn't be called when initdata is NULL, maybe BUG()? */ |
| 672 | return -EINVAL; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 673 | } |
| 674 | |
Mauro Carvalho Chehab | 14d24d1 | 2011-12-24 12:24:33 -0300 | [diff] [blame] | 675 | static int dvb_pll_set_params(struct dvb_frontend *fe) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 676 | { |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 677 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 678 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 679 | u8 buf[4]; |
| 680 | struct i2c_msg msg = |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 681 | { .addr = priv->pll_i2c_address, .flags = 0, |
| 682 | .buf = buf, .len = sizeof(buf) }; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 683 | int result; |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 684 | u32 frequency = 0; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 685 | |
| 686 | if (priv->i2c == NULL) |
| 687 | return -EINVAL; |
| 688 | |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 689 | result = dvb_pll_configure(fe, buf, c->frequency); |
| 690 | if (result < 0) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 691 | return result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 692 | else |
| 693 | frequency = result; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 694 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 695 | if (fe->ops.i2c_gate_ctrl) |
| 696 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 697 | if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) { |
| 698 | return result; |
| 699 | } |
| 700 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 701 | priv->frequency = frequency; |
Mauro Carvalho Chehab | c6f56e7 | 2011-12-26 20:02:28 -0300 | [diff] [blame] | 702 | priv->bandwidth = c->bandwidth_hz; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 703 | |
| 704 | return 0; |
| 705 | } |
| 706 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 707 | static int dvb_pll_calc_regs(struct dvb_frontend *fe, |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 708 | u8 *buf, int buf_len) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 709 | { |
Mauro Carvalho Chehab | 249fa0b | 2011-12-24 12:03:05 -0300 | [diff] [blame] | 710 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 711 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 712 | int result; |
Michael Krufky | 77d6750 | 2007-05-05 12:05:39 -0300 | [diff] [blame] | 713 | u32 frequency = 0; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 714 | |
| 715 | if (buf_len < 5) |
| 716 | return -EINVAL; |
| 717 | |
Mauro Carvalho Chehab | 249fa0b | 2011-12-24 12:03:05 -0300 | [diff] [blame] | 718 | result = dvb_pll_configure(fe, buf + 1, c->frequency); |
Mauro Carvalho Chehab | 80d8d49 | 2011-12-21 11:16:39 -0300 | [diff] [blame] | 719 | if (result < 0) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 720 | return result; |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 721 | else |
| 722 | frequency = result; |
| 723 | |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 724 | buf[0] = priv->pll_i2c_address; |
| 725 | |
Michael Krufky | 89faeef | 2006-11-20 16:45:29 -0300 | [diff] [blame] | 726 | priv->frequency = frequency; |
Mauro Carvalho Chehab | 249fa0b | 2011-12-24 12:03:05 -0300 | [diff] [blame] | 727 | priv->bandwidth = c->bandwidth_hz; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 728 | |
| 729 | return 5; |
| 730 | } |
| 731 | |
| 732 | static int dvb_pll_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
| 733 | { |
| 734 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 735 | *frequency = priv->frequency; |
| 736 | return 0; |
| 737 | } |
| 738 | |
| 739 | static int dvb_pll_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) |
| 740 | { |
| 741 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 742 | *bandwidth = priv->bandwidth; |
| 743 | return 0; |
| 744 | } |
| 745 | |
Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame] | 746 | static int dvb_pll_init(struct dvb_frontend *fe) |
| 747 | { |
| 748 | struct dvb_pll_priv *priv = fe->tuner_priv; |
| 749 | |
| 750 | if (priv->i2c == NULL) |
| 751 | return -EINVAL; |
| 752 | |
| 753 | if (priv->pll_desc->initdata) { |
| 754 | struct i2c_msg msg = { .flags = 0, |
| 755 | .addr = priv->pll_i2c_address, |
| 756 | .buf = priv->pll_desc->initdata + 1, |
| 757 | .len = priv->pll_desc->initdata[0] }; |
| 758 | |
| 759 | int result; |
| 760 | if (fe->ops.i2c_gate_ctrl) |
| 761 | fe->ops.i2c_gate_ctrl(fe, 1); |
Malcolm Priestley | 2b74334 | 2011-02-06 12:29:51 -0300 | [diff] [blame] | 762 | result = i2c_transfer(priv->i2c, &msg, 1); |
| 763 | if (result != 1) |
Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame] | 764 | return result; |
Malcolm Priestley | 2b74334 | 2011-02-06 12:29:51 -0300 | [diff] [blame] | 765 | if (priv->pll_desc->initdata2) { |
| 766 | msg.buf = priv->pll_desc->initdata2 + 1; |
| 767 | msg.len = priv->pll_desc->initdata2[0]; |
| 768 | if (fe->ops.i2c_gate_ctrl) |
| 769 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 770 | result = i2c_transfer(priv->i2c, &msg, 1); |
| 771 | if (result != 1) |
| 772 | return result; |
Trent Piepho | 26aed92 | 2007-04-27 12:31:29 -0300 | [diff] [blame] | 773 | } |
| 774 | return 0; |
| 775 | } |
| 776 | /* Shouldn't be called when initdata is NULL, maybe BUG()? */ |
| 777 | return -EINVAL; |
| 778 | } |
| 779 | |
Julia Lawall | 14c4bf3 | 2016-09-11 11:44:12 -0300 | [diff] [blame] | 780 | static const struct dvb_tuner_ops dvb_pll_tuner_ops = { |
Mauro Carvalho Chehab | f2709c2 | 2016-11-18 20:30:51 -0200 | [diff] [blame] | 781 | .release = dvb_pll_release, |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 782 | .sleep = dvb_pll_sleep, |
Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 783 | .init = dvb_pll_init, |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 784 | .set_params = dvb_pll_set_params, |
Andrew de Quincey | bd4956b | 2006-04-18 21:38:49 -0300 | [diff] [blame] | 785 | .calc_regs = dvb_pll_calc_regs, |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 786 | .get_frequency = dvb_pll_get_frequency, |
| 787 | .get_bandwidth = dvb_pll_get_bandwidth, |
| 788 | }; |
| 789 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 790 | struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, |
| 791 | struct i2c_adapter *i2c, |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 792 | unsigned int pll_desc_id) |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 793 | { |
Sean Young | b475670 | 2017-09-02 07:42:42 -0400 | [diff] [blame] | 794 | u8 *b1; |
| 795 | struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, .len = 1 }; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 796 | struct dvb_pll_priv *priv = NULL; |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 797 | int ret; |
Joe Perches | 548146f | 2015-07-30 14:08:53 -0300 | [diff] [blame] | 798 | const struct dvb_pll_desc *desc; |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 799 | |
Sean Young | b475670 | 2017-09-02 07:42:42 -0400 | [diff] [blame] | 800 | b1 = kmalloc(1, GFP_KERNEL); |
| 801 | if (!b1) |
| 802 | return NULL; |
| 803 | |
| 804 | b1[0] = 0; |
| 805 | msg.buf = b1; |
| 806 | |
Michael Krufky | 704e39b | 2007-09-07 18:27:43 -0300 | [diff] [blame] | 807 | if ((id[dvb_pll_devcount] > DVB_PLL_UNDEFINED) && |
| 808 | (id[dvb_pll_devcount] < ARRAY_SIZE(pll_list))) |
| 809 | pll_desc_id = id[dvb_pll_devcount]; |
| 810 | |
Michael Krufky | 47a9991 | 2007-06-12 16:10:51 -0300 | [diff] [blame] | 811 | BUG_ON(pll_desc_id < 1 || pll_desc_id >= ARRAY_SIZE(pll_list)); |
| 812 | |
| 813 | desc = pll_list[pll_desc_id]; |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 814 | |
Andrew de Quincey | 55c05b6 | 2006-07-16 19:41:41 -0300 | [diff] [blame] | 815 | if (i2c != NULL) { |
| 816 | if (fe->ops.i2c_gate_ctrl) |
| 817 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 061b623 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 818 | |
Andrew de Quincey | 95faba2 | 2006-07-18 16:37:13 -0300 | [diff] [blame] | 819 | ret = i2c_transfer (i2c, &msg, 1); |
Sean Young | b475670 | 2017-09-02 07:42:42 -0400 | [diff] [blame] | 820 | if (ret != 1) { |
| 821 | kfree(b1); |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 822 | return NULL; |
Sean Young | b475670 | 2017-09-02 07:42:42 -0400 | [diff] [blame] | 823 | } |
Andrew de Quincey | 55c05b6 | 2006-07-16 19:41:41 -0300 | [diff] [blame] | 824 | if (fe->ops.i2c_gate_ctrl) |
| 825 | fe->ops.i2c_gate_ctrl(fe, 0); |
| 826 | } |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 827 | |
| 828 | priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL); |
Sean Young | b475670 | 2017-09-02 07:42:42 -0400 | [diff] [blame] | 829 | if (!priv) { |
| 830 | kfree(b1); |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 831 | return NULL; |
Sean Young | b475670 | 2017-09-02 07:42:42 -0400 | [diff] [blame] | 832 | } |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 833 | |
| 834 | priv->pll_i2c_address = pll_addr; |
| 835 | priv->i2c = i2c; |
| 836 | priv->pll_desc = desc; |
Michael Krufky | a27e5e7 | 2007-09-07 18:11:15 -0300 | [diff] [blame] | 837 | priv->nr = dvb_pll_devcount++; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 838 | |
Michael Krufky | 47ae9ae | 2006-11-20 16:38:42 -0300 | [diff] [blame] | 839 | memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops, |
| 840 | sizeof(struct dvb_tuner_ops)); |
| 841 | |
Mauro Carvalho Chehab | 85709cb | 2018-09-10 08:19:16 -0400 | [diff] [blame] | 842 | strscpy(fe->ops.tuner_ops.info.name, desc->name, |
Trent Piepho | 982dd1b | 2007-04-27 12:31:27 -0300 | [diff] [blame] | 843 | sizeof(fe->ops.tuner_ops.info.name)); |
Mauro Carvalho Chehab | 3d8e450 | 2018-11-20 05:19:36 -0500 | [diff] [blame] | 844 | |
| 845 | fe->ops.tuner_ops.info.frequency_min_hz = desc->min; |
| 846 | fe->ops.tuner_ops.info.frequency_max_hz = desc->max; |
| 847 | |
| 848 | dprintk("%s tuner, frequency range: %u...%u\n", |
| 849 | desc->name, desc->min, desc->max); |
Mauro Carvalho Chehab | a3f90c7 | 2018-07-05 18:59:35 -0400 | [diff] [blame] | 850 | |
Trent Piepho | d519dcf | 2007-03-19 02:24:09 -0300 | [diff] [blame] | 851 | if (!desc->initdata) |
| 852 | fe->ops.tuner_ops.init = NULL; |
| 853 | if (!desc->sleepdata) |
| 854 | fe->ops.tuner_ops.sleep = NULL; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 855 | |
| 856 | fe->tuner_priv = priv; |
Michael Krufky | a27e5e7 | 2007-09-07 18:11:15 -0300 | [diff] [blame] | 857 | |
Michael Krufky | 8528fa4 | 2007-09-09 05:08:30 -0300 | [diff] [blame] | 858 | if ((debug) || (id[priv->nr] == pll_desc_id)) { |
Mauro Carvalho Chehab | 5479a58 | 2016-10-13 15:32:32 -0300 | [diff] [blame] | 859 | dprintk("dvb-pll[%d]", priv->nr); |
Michael Krufky | a27e5e7 | 2007-09-07 18:11:15 -0300 | [diff] [blame] | 860 | if (i2c != NULL) |
Mauro Carvalho Chehab | 5479a58 | 2016-10-13 15:32:32 -0300 | [diff] [blame] | 861 | pr_cont(" %d-%04x", i2c_adapter_id(i2c), pll_addr); |
| 862 | pr_cont(": id# %d (%s) attached, %s\n", pll_desc_id, desc->name, |
Michael Krufky | 704e39b | 2007-09-07 18:27:43 -0300 | [diff] [blame] | 863 | id[priv->nr] == pll_desc_id ? |
| 864 | "insmod option" : "autodetected"); |
Michael Krufky | 4562fbe | 2007-09-09 05:16:34 -0300 | [diff] [blame] | 865 | } |
Michael Krufky | a27e5e7 | 2007-09-07 18:11:15 -0300 | [diff] [blame] | 866 | |
Sean Young | b475670 | 2017-09-02 07:42:42 -0400 | [diff] [blame] | 867 | kfree(b1); |
| 868 | |
Andrew de Quincey | 2bfe031 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 869 | return fe; |
Andrew de Quincey | 272bc4d | 2006-04-18 17:47:12 -0300 | [diff] [blame] | 870 | } |
| 871 | EXPORT_SYMBOL(dvb_pll_attach); |
| 872 | |
Akihiro Tsukada | eaa51fe | 2018-04-08 13:21:34 -0400 | [diff] [blame] | 873 | |
| 874 | static int |
| 875 | dvb_pll_probe(struct i2c_client *client, const struct i2c_device_id *id) |
| 876 | { |
| 877 | struct dvb_pll_config *cfg; |
| 878 | struct dvb_frontend *fe; |
| 879 | unsigned int desc_id; |
| 880 | |
| 881 | cfg = client->dev.platform_data; |
| 882 | fe = cfg->fe; |
| 883 | i2c_set_clientdata(client, fe); |
| 884 | desc_id = (unsigned int) id->driver_data; |
| 885 | |
| 886 | if (!dvb_pll_attach(fe, client->addr, client->adapter, desc_id)) |
| 887 | return -ENOMEM; |
| 888 | |
Akihiro Tsukada | f917fc0 | 2018-06-10 10:49:15 -0400 | [diff] [blame] | 889 | /* |
| 890 | * Unset tuner_ops.release (== dvb_pll_release) |
| 891 | * which has been just set in the above dvb_pll_attach(), |
| 892 | * because if tuner_ops.release was left defined, |
| 893 | * this module would be 'put' twice on exit: |
| 894 | * once by dvb_frontend_detach() and another by dvb_module_release(). |
| 895 | * |
| 896 | * dvb_pll_release is instead executed in the i2c driver's .remove(), |
| 897 | * keeping dvb_pll_attach untouched for legacy (dvb_attach) drivers. |
| 898 | */ |
| 899 | fe->ops.tuner_ops.release = NULL; |
Akihiro Tsukada | eaa51fe | 2018-04-08 13:21:34 -0400 | [diff] [blame] | 900 | dev_info(&client->dev, "DVB Simple Tuner attached.\n"); |
| 901 | return 0; |
| 902 | } |
| 903 | |
| 904 | static int dvb_pll_remove(struct i2c_client *client) |
| 905 | { |
| 906 | struct dvb_frontend *fe; |
| 907 | |
| 908 | fe = i2c_get_clientdata(client); |
| 909 | dvb_pll_release(fe); |
| 910 | return 0; |
| 911 | } |
| 912 | |
| 913 | |
| 914 | static const struct i2c_device_id dvb_pll_id[] = { |
| 915 | {"dtt7579", DVB_PLL_THOMSON_DTT7579}, |
| 916 | {"dtt759x", DVB_PLL_THOMSON_DTT759X}, |
| 917 | {"z201", DVB_PLL_LG_Z201}, |
| 918 | {"unknown_1", DVB_PLL_UNKNOWN_1}, |
| 919 | {"tua6010xs", DVB_PLL_TUA6010XS}, |
| 920 | {"env57h1xd5", DVB_PLL_ENV57H1XD5}, |
| 921 | {"tua6034", DVB_PLL_TUA6034}, |
| 922 | {"tda665x", DVB_PLL_TDA665X}, |
| 923 | {"tded4", DVB_PLL_TDED4}, |
| 924 | {"tdhu2", DVB_PLL_TDHU2}, |
| 925 | {"tbmv", DVB_PLL_SAMSUNG_TBMV}, |
| 926 | {"sd1878_tda8261", DVB_PLL_PHILIPS_SD1878_TDA8261}, |
| 927 | {"opera1", DVB_PLL_OPERA1}, |
| 928 | {"dtos403ih102a", DVB_PLL_SAMSUNG_DTOS403IH102A}, |
| 929 | {"tdtc9251dh0", DVB_PLL_SAMSUNG_TDTC9251DH0}, |
| 930 | {"tbdu18132", DVB_PLL_SAMSUNG_TBDU18132}, |
| 931 | {"tbmu24112", DVB_PLL_SAMSUNG_TBMU24112}, |
| 932 | {"tdee4", DVB_PLL_TDEE4}, |
| 933 | {"dtt7520x", DVB_PLL_THOMSON_DTT7520X}, |
Akihiro Tsukada | 1745972 | 2018-04-08 13:21:35 -0400 | [diff] [blame] | 934 | {"tua6034_friio", DVB_PLL_TUA6034_FRIIO}, |
Akihiro Tsukada | 648db06 | 2018-04-08 13:39:49 -0400 | [diff] [blame] | 935 | {"tda665x_earthpt1", DVB_PLL_TDA665X_EARTH_PT1}, |
Akihiro Tsukada | eaa51fe | 2018-04-08 13:21:34 -0400 | [diff] [blame] | 936 | {} |
| 937 | }; |
| 938 | |
| 939 | |
| 940 | MODULE_DEVICE_TABLE(i2c, dvb_pll_id); |
| 941 | |
| 942 | static struct i2c_driver dvb_pll_driver = { |
| 943 | .driver = { |
| 944 | .name = "dvb_pll", |
| 945 | }, |
| 946 | .probe = dvb_pll_probe, |
| 947 | .remove = dvb_pll_remove, |
| 948 | .id_table = dvb_pll_id, |
| 949 | }; |
| 950 | |
| 951 | module_i2c_driver(dvb_pll_driver); |
| 952 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | MODULE_DESCRIPTION("dvb pll library"); |
| 954 | MODULE_AUTHOR("Gerd Knorr"); |
| 955 | MODULE_LICENSE("GPL"); |