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