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