Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 2 | |
| 3 | i2c tv tuner chip device driver |
| 4 | controls the philips tda8290+75 tuner chip combo. |
| 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. |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 19 | |
| 20 | This "tda8290" module was split apart from the original "tuner" module. |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 21 | */ |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/i2c.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <linux/delay.h> |
Michael Krufky | ffbb807 | 2007-08-21 01:14:12 -0300 | [diff] [blame] | 25 | #include <linux/videodev.h> |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 26 | #include "tuner-driver.h" |
| 27 | #include "tuner-i2c.h" |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 28 | #include "tda8290.h" |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 29 | #include "tda827x.h" |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 30 | #include "tda18271.h" |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 31 | |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 32 | static int debug; |
| 33 | module_param(debug, int, 0644); |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 34 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 35 | |
Hans Verkuil | 9dd659d | 2007-11-04 11:03:36 -0300 | [diff] [blame] | 36 | #define PREFIX "tda8290" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | /* ---------------------------------------------------------------------- */ |
| 39 | |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 40 | struct tda8290_priv { |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 41 | struct tuner_i2c_props i2c_props; |
| 42 | |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 43 | unsigned char tda8290_easy_mode; |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 44 | |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 45 | unsigned char tda827x_addr; |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 46 | |
| 47 | unsigned char ver; |
| 48 | #define TDA8290 1 |
| 49 | #define TDA8295 2 |
| 50 | #define TDA8275 4 |
| 51 | #define TDA8275A 8 |
| 52 | #define TDA18271 16 |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 53 | |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 54 | struct tda827x_config cfg; |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 55 | }; |
| 56 | |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 57 | /*---------------------------------------------------------------------*/ |
| 58 | |
Michael Krufky | a72dd30 | 2007-10-24 09:30:17 -0300 | [diff] [blame] | 59 | static int tda8290_i2c_bridge(struct dvb_frontend *fe, int close) |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 60 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 61 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 62 | |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 63 | unsigned char enable[2] = { 0x21, 0xC0 }; |
Hartmut Hackmann | 0157a9c | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 64 | unsigned char disable[2] = { 0x21, 0x00 }; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 65 | unsigned char *msg; |
Michael Krufky | a72dd30 | 2007-10-24 09:30:17 -0300 | [diff] [blame] | 66 | |
| 67 | if (close) { |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 68 | msg = enable; |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 69 | tuner_i2c_xfer_send(&priv->i2c_props, msg, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 70 | /* let the bridge stabilize */ |
| 71 | msleep(20); |
| 72 | } else { |
| 73 | msg = disable; |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 74 | tuner_i2c_xfer_send(&priv->i2c_props, msg, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 75 | } |
Michael Krufky | a72dd30 | 2007-10-24 09:30:17 -0300 | [diff] [blame] | 76 | |
| 77 | return 0; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Michael Krufky | a72dd30 | 2007-10-24 09:30:17 -0300 | [diff] [blame] | 80 | static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 81 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 82 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 83 | |
| 84 | unsigned char enable[2] = { 0x45, 0xc1 }; |
| 85 | unsigned char disable[2] = { 0x46, 0x00 }; |
| 86 | unsigned char buf[3] = { 0x45, 0x01, 0x00 }; |
| 87 | unsigned char *msg; |
Michael Krufky | a72dd30 | 2007-10-24 09:30:17 -0300 | [diff] [blame] | 88 | |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 89 | if (close) { |
| 90 | msg = enable; |
| 91 | tuner_i2c_xfer_send(&priv->i2c_props, msg, 2); |
| 92 | /* let the bridge stabilize */ |
| 93 | msleep(20); |
| 94 | } else { |
| 95 | msg = disable; |
| 96 | tuner_i2c_xfer_send(&priv->i2c_props, msg, 1); |
| 97 | tuner_i2c_xfer_recv(&priv->i2c_props, &msg[1], 1); |
| 98 | |
| 99 | buf[2] = msg[1]; |
| 100 | buf[2] &= ~0x04; |
| 101 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 3); |
| 102 | msleep(5); |
| 103 | |
| 104 | msg[1] |= 0x04; |
| 105 | tuner_i2c_xfer_send(&priv->i2c_props, msg, 2); |
| 106 | } |
Michael Krufky | a72dd30 | 2007-10-24 09:30:17 -0300 | [diff] [blame] | 107 | |
| 108 | return 0; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 109 | } |
| 110 | |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 111 | /*---------------------------------------------------------------------*/ |
| 112 | |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 113 | static void set_audio(struct dvb_frontend *fe, |
| 114 | struct analog_parameters *params) |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 115 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 116 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 117 | char* mode; |
| 118 | |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 119 | if (params->std & V4L2_STD_MN) { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 120 | priv->tda8290_easy_mode = 0x01; |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 121 | mode = "MN"; |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 122 | } else if (params->std & V4L2_STD_B) { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 123 | priv->tda8290_easy_mode = 0x02; |
| 124 | mode = "B"; |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 125 | } else if (params->std & V4L2_STD_GH) { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 126 | priv->tda8290_easy_mode = 0x04; |
| 127 | mode = "GH"; |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 128 | } else if (params->std & V4L2_STD_PAL_I) { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 129 | priv->tda8290_easy_mode = 0x08; |
| 130 | mode = "I"; |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 131 | } else if (params->std & V4L2_STD_DK) { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 132 | priv->tda8290_easy_mode = 0x10; |
| 133 | mode = "DK"; |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 134 | } else if (params->std & V4L2_STD_SECAM_L) { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 135 | priv->tda8290_easy_mode = 0x20; |
| 136 | mode = "L"; |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 137 | } else if (params->std & V4L2_STD_SECAM_LC) { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 138 | priv->tda8290_easy_mode = 0x40; |
| 139 | mode = "LC"; |
| 140 | } else { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 141 | priv->tda8290_easy_mode = 0x10; |
| 142 | mode = "xx"; |
| 143 | } |
| 144 | |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 145 | tuner_dbg("setting tda829x to system %s\n", mode); |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 146 | } |
| 147 | |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 148 | static void tda8290_set_params(struct dvb_frontend *fe, |
| 149 | struct analog_parameters *params) |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 150 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 151 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 152 | |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 153 | unsigned char soft_reset[] = { 0x00, 0x00 }; |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 154 | unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 155 | unsigned char expert_mode[] = { 0x01, 0x80 }; |
Hartmut Hackmann | 0157a9c | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 156 | unsigned char agc_out_on[] = { 0x02, 0x00 }; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 157 | unsigned char gainset_off[] = { 0x28, 0x14 }; |
| 158 | unsigned char if_agc_spd[] = { 0x0f, 0x88 }; |
| 159 | unsigned char adc_head_6[] = { 0x05, 0x04 }; |
| 160 | unsigned char adc_head_9[] = { 0x05, 0x02 }; |
| 161 | unsigned char adc_head_12[] = { 0x05, 0x01 }; |
| 162 | unsigned char pll_bw_nom[] = { 0x0d, 0x47 }; |
| 163 | unsigned char pll_bw_low[] = { 0x0d, 0x27 }; |
| 164 | unsigned char gainset_2[] = { 0x28, 0x64 }; |
| 165 | unsigned char agc_rst_on[] = { 0x0e, 0x0b }; |
| 166 | unsigned char agc_rst_off[] = { 0x0e, 0x09 }; |
| 167 | unsigned char if_agc_set[] = { 0x0f, 0x81 }; |
| 168 | unsigned char addr_adc_sat = 0x1a; |
| 169 | unsigned char addr_agc_stat = 0x1d; |
| 170 | unsigned char addr_pll_stat = 0x1b; |
| 171 | unsigned char adc_sat, agc_stat, |
Nickolay V. Shmyrev | 9a741ec | 2005-11-08 21:37:50 -0800 | [diff] [blame] | 172 | pll_stat; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 173 | int i; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 174 | |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 175 | set_audio(fe, params); |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 176 | |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 177 | if (priv->cfg.config) |
| 178 | tuner_dbg("tda827xa config is 0x%02x\n", *priv->cfg.config); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 179 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); |
| 180 | tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2); |
| 181 | tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 182 | msleep(1); |
| 183 | |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 184 | expert_mode[1] = priv->tda8290_easy_mode + 0x80; |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 185 | tuner_i2c_xfer_send(&priv->i2c_props, expert_mode, 2); |
| 186 | tuner_i2c_xfer_send(&priv->i2c_props, gainset_off, 2); |
| 187 | tuner_i2c_xfer_send(&priv->i2c_props, if_agc_spd, 2); |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 188 | if (priv->tda8290_easy_mode & 0x60) |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 189 | tuner_i2c_xfer_send(&priv->i2c_props, adc_head_9, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 190 | else |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 191 | tuner_i2c_xfer_send(&priv->i2c_props, adc_head_6, 2); |
| 192 | tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 193 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 194 | tda8290_i2c_bridge(fe, 1); |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 195 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 196 | if (fe->ops.tuner_ops.set_analog_params) |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 197 | fe->ops.tuner_ops.set_analog_params(fe, params); |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 198 | |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 199 | for (i = 0; i < 3; i++) { |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 200 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); |
| 201 | tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 202 | if (pll_stat & 0x80) { |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 203 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1); |
| 204 | tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1); |
| 205 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); |
| 206 | tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 207 | tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat); |
| 208 | break; |
| 209 | } else { |
| 210 | tuner_dbg("tda8290 not locked, no signal?\n"); |
| 211 | msleep(100); |
| 212 | } |
| 213 | } |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 214 | /* adjust headroom resp. gain */ |
Hartmut Hackmann | 4ac95af | 2005-11-08 21:38:38 -0800 | [diff] [blame] | 215 | if ((agc_stat > 115) || (!(pll_stat & 0x80) && (adc_sat < 20))) { |
| 216 | tuner_dbg("adjust gain, step 1. Agc: %d, ADC stat: %d, lock: %d\n", |
| 217 | agc_stat, adc_sat, pll_stat & 0x80); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 218 | tuner_i2c_xfer_send(&priv->i2c_props, gainset_2, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 219 | msleep(100); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 220 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); |
| 221 | tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); |
| 222 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); |
| 223 | tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 224 | if ((agc_stat > 115) || !(pll_stat & 0x80)) { |
Hartmut Hackmann | 4ac95af | 2005-11-08 21:38:38 -0800 | [diff] [blame] | 225 | tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", |
| 226 | agc_stat, pll_stat & 0x80); |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 227 | if (priv->cfg.agcf) |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 228 | priv->cfg.agcf(fe); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 229 | msleep(100); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 230 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); |
| 231 | tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); |
| 232 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); |
| 233 | tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 234 | if((agc_stat > 115) || !(pll_stat & 0x80)) { |
| 235 | tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 236 | tuner_i2c_xfer_send(&priv->i2c_props, adc_head_12, 2); |
| 237 | tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_low, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 238 | msleep(100); |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | /* l/ l' deadlock? */ |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 244 | if(priv->tda8290_easy_mode & 0x60) { |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 245 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1); |
| 246 | tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1); |
| 247 | tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); |
| 248 | tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 249 | if ((adc_sat > 20) || !(pll_stat & 0x80)) { |
Hartmut Hackmann | 4ac95af | 2005-11-08 21:38:38 -0800 | [diff] [blame] | 250 | tuner_dbg("trying to resolve SECAM L deadlock\n"); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 251 | tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_on, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 252 | msleep(40); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 253 | tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_off, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 254 | } |
| 255 | } |
| 256 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 257 | tda8290_i2c_bridge(fe, 0); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 258 | tuner_i2c_xfer_send(&priv->i2c_props, if_agc_set, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 259 | } |
| 260 | |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 261 | /*---------------------------------------------------------------------*/ |
| 262 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 263 | static void tda8295_power(struct dvb_frontend *fe, int enable) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 264 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 265 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 266 | unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */ |
| 267 | |
| 268 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); |
| 269 | tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1); |
| 270 | |
| 271 | if (enable) |
| 272 | buf[1] = 0x01; |
| 273 | else |
| 274 | buf[1] = 0x03; |
| 275 | |
| 276 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); |
| 277 | } |
| 278 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 279 | static void tda8295_set_easy_mode(struct dvb_frontend *fe, int enable) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 280 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 281 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 282 | unsigned char buf[] = { 0x01, 0x00 }; |
| 283 | |
| 284 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); |
| 285 | tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1); |
| 286 | |
| 287 | if (enable) |
| 288 | buf[1] = 0x01; /* rising edge sets regs 0x02 - 0x23 */ |
| 289 | else |
| 290 | buf[1] = 0x00; /* reset active bit */ |
| 291 | |
| 292 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); |
| 293 | } |
| 294 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 295 | static void tda8295_set_video_std(struct dvb_frontend *fe) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 296 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 297 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 298 | unsigned char buf[] = { 0x00, priv->tda8290_easy_mode }; |
| 299 | |
| 300 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); |
| 301 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 302 | tda8295_set_easy_mode(fe, 1); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 303 | msleep(20); |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 304 | tda8295_set_easy_mode(fe, 0); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | /*---------------------------------------------------------------------*/ |
| 308 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 309 | static void tda8295_agc1_out(struct dvb_frontend *fe, int enable) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 310 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 311 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 312 | unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */ |
| 313 | |
| 314 | tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); |
| 315 | tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1); |
| 316 | |
| 317 | if (enable) |
| 318 | buf[1] &= ~0x40; |
| 319 | else |
| 320 | buf[1] |= 0x40; |
| 321 | |
| 322 | tuner_i2c_xfer_send(&priv->i2c_props, buf, 2); |
| 323 | } |
| 324 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 325 | static void tda8295_agc2_out(struct dvb_frontend *fe, int enable) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 326 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 327 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 328 | unsigned char set_gpio_cf[] = { 0x44, 0x00 }; |
| 329 | unsigned char set_gpio_val[] = { 0x46, 0x00 }; |
| 330 | |
| 331 | tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_cf[0], 1); |
| 332 | tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_cf[1], 1); |
| 333 | tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_val[0], 1); |
| 334 | tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_val[1], 1); |
| 335 | |
| 336 | set_gpio_cf[1] &= 0xf0; /* clear GPIO_0 bits 3-0 */ |
| 337 | |
| 338 | if (enable) { |
| 339 | set_gpio_cf[1] |= 0x01; /* config GPIO_0 as Open Drain Out */ |
| 340 | set_gpio_val[1] &= 0xfe; /* set GPIO_0 pin low */ |
| 341 | } |
| 342 | tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_cf, 2); |
| 343 | tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_val, 2); |
| 344 | } |
| 345 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 346 | static int tda8295_has_signal(struct dvb_frontend *fe) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 347 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 348 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 349 | |
| 350 | unsigned char hvpll_stat = 0x26; |
| 351 | unsigned char ret; |
| 352 | |
| 353 | tuner_i2c_xfer_send(&priv->i2c_props, &hvpll_stat, 1); |
| 354 | tuner_i2c_xfer_recv(&priv->i2c_props, &ret, 1); |
| 355 | return (ret & 0x01) ? 65535 : 0; |
| 356 | } |
| 357 | |
| 358 | /*---------------------------------------------------------------------*/ |
| 359 | |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 360 | static void tda8295_set_params(struct dvb_frontend *fe, |
| 361 | struct analog_parameters *params) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 362 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 363 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 364 | |
| 365 | unsigned char blanking_mode[] = { 0x1d, 0x00 }; |
| 366 | |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 367 | set_audio(fe, params); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 368 | |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 369 | tuner_dbg("%s: freq = %d\n", __FUNCTION__, params->frequency); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 370 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 371 | tda8295_power(fe, 1); |
| 372 | tda8295_agc1_out(fe, 1); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 373 | |
| 374 | tuner_i2c_xfer_send(&priv->i2c_props, &blanking_mode[0], 1); |
| 375 | tuner_i2c_xfer_recv(&priv->i2c_props, &blanking_mode[1], 1); |
| 376 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 377 | tda8295_set_video_std(fe); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 378 | |
| 379 | blanking_mode[1] = 0x03; |
| 380 | tuner_i2c_xfer_send(&priv->i2c_props, blanking_mode, 2); |
| 381 | msleep(20); |
| 382 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 383 | tda8295_i2c_bridge(fe, 1); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 384 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 385 | if (fe->ops.tuner_ops.set_analog_params) |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 386 | fe->ops.tuner_ops.set_analog_params(fe, params); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 387 | |
| 388 | if (priv->cfg.agcf) |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 389 | priv->cfg.agcf(fe); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 390 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 391 | if (tda8295_has_signal(fe)) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 392 | tuner_dbg("tda8295 is locked\n"); |
| 393 | else |
| 394 | tuner_dbg("tda8295 not locked, no signal?\n"); |
| 395 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 396 | tda8295_i2c_bridge(fe, 0); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | /*---------------------------------------------------------------------*/ |
| 400 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 401 | static int tda8290_has_signal(struct dvb_frontend *fe) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 403 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 404 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | unsigned char i2c_get_afc[1] = { 0x1B }; |
| 406 | unsigned char afc = 0; |
| 407 | |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 408 | tuner_i2c_xfer_send(&priv->i2c_props, i2c_get_afc, ARRAY_SIZE(i2c_get_afc)); |
| 409 | tuner_i2c_xfer_recv(&priv->i2c_props, &afc, 1); |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 410 | return (afc & 0x80)? 65535:0; |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 411 | } |
| 412 | |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 413 | /*---------------------------------------------------------------------*/ |
| 414 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 415 | static void tda8290_standby(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 793cf9e | 2005-09-09 13:03:37 -0700 | [diff] [blame] | 416 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 417 | struct tda8290_priv *priv = fe->analog_demod_priv; |
| 418 | |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 419 | unsigned char cb1[] = { 0x30, 0xD0 }; |
| 420 | unsigned char tda8290_standby[] = { 0x00, 0x02 }; |
Hartmut Hackmann | 0157a9c | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 421 | unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 422 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 423 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 424 | tda8290_i2c_bridge(fe, 1); |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 425 | if (priv->ver & TDA8275A) |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 426 | cb1[1] = 0x90; |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 427 | i2c_transfer(priv->i2c_props.adap, &msg, 1); |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 428 | tda8290_i2c_bridge(fe, 0); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 429 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_agc_tri, 2); |
| 430 | tuner_i2c_xfer_send(&priv->i2c_props, tda8290_standby, 2); |
Mauro Carvalho Chehab | 793cf9e | 2005-09-09 13:03:37 -0700 | [diff] [blame] | 431 | } |
| 432 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 433 | static void tda8295_standby(struct dvb_frontend *fe) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 434 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 435 | tda8295_agc1_out(fe, 0); /* Put AGC in tri-state */ |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 436 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 437 | tda8295_power(fe, 0); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 438 | } |
| 439 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 440 | static void tda8290_init_if(struct dvb_frontend *fe) |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 441 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 442 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 443 | |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 444 | unsigned char set_VS[] = { 0x30, 0x6F }; |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 445 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 446 | unsigned char set_GP01_CF[] = { 0x20, 0x0B }; |
| 447 | |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 448 | if ((priv->cfg.config) && |
| 449 | ((*priv->cfg.config == 1) || (*priv->cfg.config == 2))) |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 450 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2); |
Hartmut Hackmann | 58ef4f9 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 451 | else |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 452 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2); |
| 453 | tuner_i2c_xfer_send(&priv->i2c_props, set_VS, 2); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 454 | } |
| 455 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 456 | static void tda8295_init_if(struct dvb_frontend *fe) |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 457 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 458 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 459 | |
| 460 | static unsigned char set_adc_ctl[] = { 0x33, 0x14 }; |
| 461 | static unsigned char set_adc_ctl2[] = { 0x34, 0x00 }; |
| 462 | static unsigned char set_pll_reg6[] = { 0x3e, 0x63 }; |
| 463 | static unsigned char set_pll_reg0[] = { 0x38, 0x23 }; |
| 464 | static unsigned char set_pll_reg7[] = { 0x3f, 0x01 }; |
| 465 | static unsigned char set_pll_reg10[] = { 0x42, 0x61 }; |
| 466 | static unsigned char set_gpio_reg0[] = { 0x44, 0x0b }; |
| 467 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 468 | tda8295_power(fe, 1); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 469 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 470 | tda8295_set_easy_mode(fe, 0); |
| 471 | tda8295_set_video_std(fe); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 472 | |
| 473 | tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl, 2); |
| 474 | tuner_i2c_xfer_send(&priv->i2c_props, set_adc_ctl2, 2); |
| 475 | tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg6, 2); |
| 476 | tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg0, 2); |
| 477 | tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg7, 2); |
| 478 | tuner_i2c_xfer_send(&priv->i2c_props, set_pll_reg10, 2); |
| 479 | tuner_i2c_xfer_send(&priv->i2c_props, set_gpio_reg0, 2); |
| 480 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 481 | tda8295_agc1_out(fe, 0); |
| 482 | tda8295_agc2_out(fe, 0); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 483 | } |
| 484 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 485 | static void tda8290_init_tuner(struct dvb_frontend *fe) |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 486 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 487 | struct tda8290_priv *priv = fe->analog_demod_priv; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 488 | unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, |
Nickolay V. Shmyrev | 9a741ec | 2005-11-08 21:37:50 -0800 | [diff] [blame] | 489 | 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 490 | unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, |
Nickolay V. Shmyrev | 9a741ec | 2005-11-08 21:37:50 -0800 | [diff] [blame] | 491 | 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b }; |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 492 | struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, |
Ricardo Cerqueira | c2f6f9d | 2005-11-08 21:37:51 -0800 | [diff] [blame] | 493 | .buf=tda8275_init, .len = 14}; |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 494 | if (priv->ver & TDA8275A) |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 495 | msg.buf = tda8275a_init; |
| 496 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 497 | tda8290_i2c_bridge(fe, 1); |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 498 | i2c_transfer(priv->i2c_props.adap, &msg, 1); |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 499 | tda8290_i2c_bridge(fe, 0); |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | /*---------------------------------------------------------------------*/ |
| 503 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 504 | static void tda829x_release(struct dvb_frontend *fe) |
Michael Krufky | 024cf53 | 2007-06-04 15:20:11 -0300 | [diff] [blame] | 505 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 506 | if (fe->ops.tuner_ops.release) |
| 507 | fe->ops.tuner_ops.release(fe); |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 508 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 509 | kfree(fe->analog_demod_priv); |
| 510 | fe->analog_demod_priv = NULL; |
Michael Krufky | 024cf53 | 2007-06-04 15:20:11 -0300 | [diff] [blame] | 511 | } |
| 512 | |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 513 | static int tda829x_find_tuner(struct dvb_frontend *fe) |
| 514 | { |
| 515 | struct tda8290_priv *priv = fe->analog_demod_priv; |
| 516 | struct analog_tuner_ops *ops = fe->ops.analog_demod_ops; |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 517 | int i, ret, tuners_found; |
| 518 | u32 tuner_addrs; |
| 519 | u8 data; |
| 520 | struct i2c_msg msg = { .flags = I2C_M_RD, .buf = &data, .len = 1 }; |
| 521 | |
| 522 | if (NULL == ops) |
| 523 | return -EINVAL; |
| 524 | |
| 525 | ops->i2c_gate_ctrl(fe, 1); |
| 526 | |
| 527 | /* probe for tuner chip */ |
| 528 | tuners_found = 0; |
| 529 | tuner_addrs = 0; |
| 530 | for (i = 0x60; i <= 0x63; i++) { |
| 531 | msg.addr = i; |
| 532 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); |
| 533 | if (ret == 1) { |
| 534 | tuners_found++; |
| 535 | tuner_addrs = (tuner_addrs << 8) + i; |
| 536 | } |
| 537 | } |
| 538 | /* if there is more than one tuner, we expect the right one is |
| 539 | behind the bridge and we choose the highest address that doesn't |
| 540 | give a response now |
| 541 | */ |
| 542 | |
| 543 | ops->i2c_gate_ctrl(fe, 0); |
| 544 | |
| 545 | if (tuners_found > 1) |
| 546 | for (i = 0; i < tuners_found; i++) { |
| 547 | msg.addr = tuner_addrs & 0xff; |
| 548 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); |
| 549 | if (ret == 1) |
| 550 | tuner_addrs = tuner_addrs >> 8; |
| 551 | else |
| 552 | break; |
| 553 | } |
| 554 | |
| 555 | if (tuner_addrs == 0) { |
| 556 | tuner_addrs = 0x60; |
| 557 | tuner_info("could not clearly identify tuner address, " |
| 558 | "defaulting to %x\n", tuner_addrs); |
| 559 | } else { |
| 560 | tuner_addrs = tuner_addrs & 0xff; |
| 561 | tuner_info("setting tuner address to %x\n", tuner_addrs); |
| 562 | } |
| 563 | priv->tda827x_addr = tuner_addrs; |
| 564 | msg.addr = tuner_addrs; |
| 565 | |
| 566 | ops->i2c_gate_ctrl(fe, 1); |
| 567 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); |
| 568 | |
| 569 | if (ret != 1) { |
| 570 | tuner_warn("tuner access failed!\n"); |
| 571 | return -EREMOTEIO; |
| 572 | } |
| 573 | |
| 574 | if (data == 0x83) { |
| 575 | priv->ver |= TDA18271; |
Michael Krufky | 6881647 | 2007-12-08 16:25:41 -0300 | [diff] [blame] | 576 | tda18271_attach(fe, priv->tda827x_addr, |
Michael Krufky | e435f95 | 2007-12-09 22:23:30 -0300 | [diff] [blame^] | 577 | priv->i2c_props.adap, |
| 578 | TDA18271_GATE_ANALOG); |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 579 | } else { |
| 580 | if ((data & 0x3c) == 0) |
| 581 | priv->ver |= TDA8275; |
| 582 | else |
| 583 | priv->ver |= TDA8275A; |
| 584 | |
Michael Krufky | 6881647 | 2007-12-08 16:25:41 -0300 | [diff] [blame] | 585 | tda827x_attach(fe, priv->tda827x_addr, |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 586 | priv->i2c_props.adap, &priv->cfg); |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 587 | } |
Michael Krufky | 6881647 | 2007-12-08 16:25:41 -0300 | [diff] [blame] | 588 | if (fe->ops.tuner_ops.init) |
| 589 | fe->ops.tuner_ops.init(fe); |
Michael Krufky | 63c2548 | 2007-11-23 15:08:11 -0300 | [diff] [blame] | 590 | |
Michael Krufky | 6881647 | 2007-12-08 16:25:41 -0300 | [diff] [blame] | 591 | if (fe->ops.tuner_ops.sleep) |
| 592 | fe->ops.tuner_ops.sleep(fe); |
Michael Krufky | 63c2548 | 2007-11-23 15:08:11 -0300 | [diff] [blame] | 593 | |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 594 | ops->i2c_gate_ctrl(fe, 0); |
| 595 | |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 596 | return 0; |
| 597 | } |
| 598 | |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 599 | static int tda8290_probe(struct tuner_i2c_props *i2c_props) |
| 600 | { |
| 601 | #define TDA8290_ID 0x89 |
| 602 | unsigned char tda8290_id[] = { 0x1f, 0x00 }; |
| 603 | |
| 604 | /* detect tda8290 */ |
| 605 | tuner_i2c_xfer_send(i2c_props, &tda8290_id[0], 1); |
| 606 | tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1); |
| 607 | |
| 608 | if (tda8290_id[1] == TDA8290_ID) { |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 609 | if (debug) |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 610 | printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n", |
| 611 | __FUNCTION__, i2c_adapter_id(i2c_props->adap), |
| 612 | i2c_props->addr); |
| 613 | return 0; |
| 614 | } |
| 615 | |
Michael Krufky | 1f3a4e32 | 2007-11-04 10:51:28 -0300 | [diff] [blame] | 616 | return -ENODEV; |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | static int tda8295_probe(struct tuner_i2c_props *i2c_props) |
| 620 | { |
| 621 | #define TDA8295_ID 0x8a |
| 622 | unsigned char tda8295_id[] = { 0x2f, 0x00 }; |
| 623 | |
| 624 | /* detect tda8295 */ |
| 625 | tuner_i2c_xfer_send(i2c_props, &tda8295_id[0], 1); |
| 626 | tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1); |
| 627 | |
| 628 | if (tda8295_id[1] == TDA8295_ID) { |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 629 | if (debug) |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 630 | printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n", |
| 631 | __FUNCTION__, i2c_adapter_id(i2c_props->adap), |
| 632 | i2c_props->addr); |
| 633 | return 0; |
| 634 | } |
| 635 | |
Michael Krufky | 1f3a4e32 | 2007-11-04 10:51:28 -0300 | [diff] [blame] | 636 | return -ENODEV; |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 637 | } |
| 638 | |
Michael Krufky | 1dde7a4 | 2007-10-21 13:40:56 -0300 | [diff] [blame] | 639 | static struct analog_tuner_ops tda8290_tuner_ops = { |
Michael Krufky | a55db8c | 2007-12-09 13:52:51 -0300 | [diff] [blame] | 640 | .info = { |
| 641 | .name = "TDA8290", |
| 642 | }, |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 643 | .set_params = tda8290_set_params, |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 644 | .has_signal = tda8290_has_signal, |
| 645 | .standby = tda8290_standby, |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 646 | .release = tda829x_release, |
Michael Krufky | a72dd30 | 2007-10-24 09:30:17 -0300 | [diff] [blame] | 647 | .i2c_gate_ctrl = tda8290_i2c_bridge, |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 648 | }; |
| 649 | |
Michael Krufky | 1dde7a4 | 2007-10-21 13:40:56 -0300 | [diff] [blame] | 650 | static struct analog_tuner_ops tda8295_tuner_ops = { |
Michael Krufky | a55db8c | 2007-12-09 13:52:51 -0300 | [diff] [blame] | 651 | .info = { |
| 652 | .name = "TDA8295", |
| 653 | }, |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 654 | .set_params = tda8295_set_params, |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 655 | .has_signal = tda8295_has_signal, |
| 656 | .standby = tda8295_standby, |
| 657 | .release = tda829x_release, |
Michael Krufky | a72dd30 | 2007-10-24 09:30:17 -0300 | [diff] [blame] | 658 | .i2c_gate_ctrl = tda8295_i2c_bridge, |
Michael Krufky | 7fd8b26 | 2007-06-06 16:15:15 -0300 | [diff] [blame] | 659 | }; |
| 660 | |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 661 | struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe, |
| 662 | struct i2c_adapter *i2c_adap, u8 i2c_addr, |
| 663 | struct tda829x_config *cfg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | { |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 665 | struct tda8290_priv *priv = NULL; |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 666 | char *name; |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 667 | |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 668 | priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL); |
| 669 | if (priv == NULL) |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 670 | return NULL; |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 671 | fe->analog_demod_priv = priv; |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 672 | |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 673 | priv->i2c_props.addr = i2c_addr; |
| 674 | priv->i2c_props.adap = i2c_adap; |
| 675 | if (cfg) { |
| 676 | priv->cfg.config = cfg->lna_cfg; |
| 677 | priv->cfg.tuner_callback = cfg->tuner_callback; |
| 678 | } |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 679 | |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 680 | if (tda8290_probe(&priv->i2c_props) == 0) { |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 681 | priv->ver = TDA8290; |
| 682 | fe->ops.analog_demod_ops = &tda8290_tuner_ops; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 683 | } |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 684 | |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 685 | if (tda8295_probe(&priv->i2c_props) == 0) { |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 686 | priv->ver = TDA8295; |
| 687 | fe->ops.analog_demod_ops = &tda8295_tuner_ops; |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 688 | } |
Hartmut Hackmann | de48eeb | 2005-11-08 21:37:48 -0800 | [diff] [blame] | 689 | |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 690 | if (tda829x_find_tuner(fe) < 0) |
Michael Krufky | fa746aee | 2007-12-09 05:16:10 -0300 | [diff] [blame] | 691 | goto fail; |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 692 | |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 693 | switch (priv->ver) { |
| 694 | case TDA8290 | TDA8275: |
| 695 | name = "tda8290+75"; |
| 696 | break; |
| 697 | case TDA8295 | TDA8275: |
| 698 | name = "tda8295+75"; |
| 699 | break; |
| 700 | case TDA8290 | TDA8275A: |
| 701 | name = "tda8290+75a"; |
| 702 | break; |
| 703 | case TDA8295 | TDA8275A: |
| 704 | name = "tda8295+75a"; |
| 705 | break; |
| 706 | case TDA8290 | TDA18271: |
| 707 | name = "tda8290+18271"; |
| 708 | break; |
| 709 | case TDA8295 | TDA18271: |
| 710 | name = "tda8295+18271"; |
| 711 | break; |
| 712 | default: |
| 713 | goto fail; |
| 714 | } |
| 715 | tuner_info("type set to %s\n", name); |
| 716 | |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 717 | if (priv->ver & TDA8290) { |
| 718 | tda8290_init_tuner(fe); |
| 719 | tda8290_init_if(fe); |
| 720 | } else if (priv->ver & TDA8295) |
| 721 | tda8295_init_if(fe); |
Michael Krufky | 746d9732 | 2007-08-25 19:08:45 -0300 | [diff] [blame] | 722 | |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 723 | return fe; |
Michael Krufky | fa746aee | 2007-12-09 05:16:10 -0300 | [diff] [blame] | 724 | |
| 725 | fail: |
| 726 | tda829x_release(fe); |
| 727 | fe->ops.analog_demod_ops = NULL; |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 728 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | } |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 730 | EXPORT_SYMBOL_GPL(tda829x_attach); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 732 | int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr) |
Hartmut Hackmann | 9573603 | 2005-11-08 21:38:00 -0800 | [diff] [blame] | 733 | { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 734 | struct tuner_i2c_props i2c_props = { |
Michael Krufky | ab16605 | 2007-12-09 02:26:48 -0300 | [diff] [blame] | 735 | .adap = i2c_adap, |
| 736 | .addr = i2c_addr, |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 737 | }; |
Michael Krufky | db8a695 | 2007-08-21 01:24:42 -0300 | [diff] [blame] | 738 | |
Hartmut Hackmann | 44fd06f | 2006-02-27 00:09:11 -0300 | [diff] [blame] | 739 | unsigned char soft_reset[] = { 0x00, 0x00 }; |
| 740 | unsigned char easy_mode_b[] = { 0x01, 0x02 }; |
| 741 | unsigned char easy_mode_g[] = { 0x01, 0x04 }; |
| 742 | unsigned char restore_9886[] = { 0x00, 0xd6, 0x30 }; |
Hartmut Hackmann | 9573603 | 2005-11-08 21:38:00 -0800 | [diff] [blame] | 743 | unsigned char addr_dto_lsb = 0x07; |
| 744 | unsigned char data; |
Michael Krufky | a818e1c | 2007-11-04 11:03:22 -0300 | [diff] [blame] | 745 | #define PROBE_BUFFER_SIZE 8 |
| 746 | unsigned char buf[PROBE_BUFFER_SIZE]; |
| 747 | int i; |
| 748 | |
| 749 | /* rule out tda9887, which would return the same byte repeatedly */ |
| 750 | tuner_i2c_xfer_send(&i2c_props, soft_reset, 1); |
| 751 | tuner_i2c_xfer_recv(&i2c_props, buf, PROBE_BUFFER_SIZE); |
| 752 | for (i = 1; i < PROBE_BUFFER_SIZE; i++) { |
Michael Krufky | bbe1e0b | 2007-11-05 09:54:42 -0300 | [diff] [blame] | 753 | if (buf[i] != buf[0]) |
| 754 | break; |
Michael Krufky | a818e1c | 2007-11-04 11:03:22 -0300 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | /* all bytes are equal, not a tda829x - probably a tda9887 */ |
| 758 | if (i == PROBE_BUFFER_SIZE) |
| 759 | return -ENODEV; |
Hartmut Hackmann | 9573603 | 2005-11-08 21:38:00 -0800 | [diff] [blame] | 760 | |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 761 | if ((tda8290_probe(&i2c_props) == 0) || |
| 762 | (tda8295_probe(&i2c_props) == 0)) |
| 763 | return 0; |
| 764 | |
| 765 | /* fall back to old probing method */ |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 766 | tuner_i2c_xfer_send(&i2c_props, easy_mode_b, 2); |
| 767 | tuner_i2c_xfer_send(&i2c_props, soft_reset, 2); |
| 768 | tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1); |
| 769 | tuner_i2c_xfer_recv(&i2c_props, &data, 1); |
Hartmut Hackmann | 9573603 | 2005-11-08 21:38:00 -0800 | [diff] [blame] | 770 | if (data == 0) { |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 771 | tuner_i2c_xfer_send(&i2c_props, easy_mode_g, 2); |
| 772 | tuner_i2c_xfer_send(&i2c_props, soft_reset, 2); |
| 773 | tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1); |
| 774 | tuner_i2c_xfer_recv(&i2c_props, &data, 1); |
Hartmut Hackmann | 9573603 | 2005-11-08 21:38:00 -0800 | [diff] [blame] | 775 | if (data == 0x7b) { |
| 776 | return 0; |
| 777 | } |
| 778 | } |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 779 | tuner_i2c_xfer_send(&i2c_props, restore_9886, 3); |
Michael Krufky | 1f3a4e32 | 2007-11-04 10:51:28 -0300 | [diff] [blame] | 780 | return -ENODEV; |
Hartmut Hackmann | 9573603 | 2005-11-08 21:38:00 -0800 | [diff] [blame] | 781 | } |
Michael Krufky | f1f3284 | 2007-11-03 22:14:54 -0300 | [diff] [blame] | 782 | EXPORT_SYMBOL_GPL(tda829x_probe); |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 783 | |
Michael Krufky | 8c125f2c | 2007-10-27 02:00:57 -0300 | [diff] [blame] | 784 | MODULE_DESCRIPTION("Philips/NXP TDA8290/TDA8295 analog IF demodulator driver"); |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 785 | MODULE_AUTHOR("Gerd Knorr, Hartmut Hackmann, Michael Krufky"); |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 786 | MODULE_LICENSE("GPL"); |
| 787 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | /* |
| 789 | * Overrides for Emacs so that we follow Linus's tabbing style. |
| 790 | * --------------------------------------------------------------------------- |
| 791 | * Local variables: |
| 792 | * c-basic-offset: 8 |
| 793 | * End: |
| 794 | */ |