Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * i2c tv tuner chip device driver |
| 4 | * core core, i.e. kernel interfaces, registering and so on |
| 5 | */ |
| 6 | |
| 7 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/string.h> |
| 10 | #include <linux/timer.h> |
| 11 | #include <linux/delay.h> |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/slab.h> |
| 14 | #include <linux/poll.h> |
| 15 | #include <linux/i2c.h> |
| 16 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/init.h> |
Hans Verkuil | 75b4c26 | 2009-04-01 03:32:22 -0300 | [diff] [blame] | 18 | #include <linux/videodev2.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <media/tuner.h> |
Michael Krufky | 4adad28 | 2007-08-27 21:59:08 -0300 | [diff] [blame] | 20 | #include <media/tuner-types.h> |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 21 | #include <media/v4l2-device.h> |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 22 | #include <media/v4l2-ioctl.h> |
Michael Krufky | 96c0b7c | 2007-08-27 21:23:08 -0300 | [diff] [blame] | 23 | #include "mt20xx.h" |
Michael Krufky | 910bb3e | 2007-08-27 21:22:20 -0300 | [diff] [blame] | 24 | #include "tda8290.h" |
Michael Krufky | 7ab10bf | 2007-08-27 21:23:40 -0300 | [diff] [blame] | 25 | #include "tea5761.h" |
Michael Krufky | 8d0936e | 2007-08-27 21:24:27 -0300 | [diff] [blame] | 26 | #include "tea5767.h" |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 27 | #include "tuner-xc2028.h" |
Michael Krufky | 4adad28 | 2007-08-27 21:59:08 -0300 | [diff] [blame] | 28 | #include "tuner-simple.h" |
Michael Krufky | 31c9584 | 2007-10-21 20:48:48 -0300 | [diff] [blame] | 29 | #include "tda9887.h" |
Steven Toth | 27c685a | 2008-01-05 16:50:14 -0300 | [diff] [blame] | 30 | #include "xc5000.h" |
Michael Krufky | 9346389 | 2009-09-15 23:04:18 -0300 | [diff] [blame] | 31 | #include "tda18271.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | #define UNSET (-1U) |
| 34 | |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 35 | #define PREFIX (t->i2c->driver->driver.name) |
Michael Krufky | 241020d | 2007-10-30 09:46:10 -0300 | [diff] [blame] | 36 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 37 | /* |
| 38 | * Driver modprobe parameters |
| 39 | */ |
| 40 | |
| 41 | /* insmod options used at init time => read/only */ |
| 42 | static unsigned int addr; |
| 43 | static unsigned int no_autodetect; |
| 44 | static unsigned int show_i2c; |
| 45 | |
| 46 | module_param(addr, int, 0444); |
| 47 | module_param(no_autodetect, int, 0444); |
| 48 | module_param(show_i2c, int, 0444); |
| 49 | |
| 50 | /* insmod options used at runtime => read/write */ |
| 51 | static int tuner_debug; |
| 52 | static unsigned int tv_range[2] = { 44, 958 }; |
| 53 | static unsigned int radio_range[2] = { 65, 108 }; |
| 54 | static char pal[] = "--"; |
| 55 | static char secam[] = "--"; |
| 56 | static char ntsc[] = "-"; |
| 57 | |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 58 | module_param_named(debug, tuner_debug, int, 0644); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 59 | module_param_array(tv_range, int, NULL, 0644); |
| 60 | module_param_array(radio_range, int, NULL, 0644); |
| 61 | module_param_string(pal, pal, sizeof(pal), 0644); |
| 62 | module_param_string(secam, secam, sizeof(secam), 0644); |
| 63 | module_param_string(ntsc, ntsc, sizeof(ntsc), 0644); |
| 64 | |
| 65 | /* |
| 66 | * Static vars |
| 67 | */ |
| 68 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 69 | static LIST_HEAD(tuner_list); |
| 70 | |
| 71 | /* |
| 72 | * Debug macros |
| 73 | */ |
| 74 | |
| 75 | #define tuner_warn(fmt, arg...) do { \ |
| 76 | printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \ |
| 77 | i2c_adapter_id(t->i2c->adapter), \ |
| 78 | t->i2c->addr, ##arg); \ |
| 79 | } while (0) |
| 80 | |
| 81 | #define tuner_info(fmt, arg...) do { \ |
| 82 | printk(KERN_INFO "%s %d-%04x: " fmt, PREFIX, \ |
| 83 | i2c_adapter_id(t->i2c->adapter), \ |
| 84 | t->i2c->addr, ##arg); \ |
| 85 | } while (0) |
| 86 | |
| 87 | #define tuner_err(fmt, arg...) do { \ |
| 88 | printk(KERN_ERR "%s %d-%04x: " fmt, PREFIX, \ |
| 89 | i2c_adapter_id(t->i2c->adapter), \ |
| 90 | t->i2c->addr, ##arg); \ |
| 91 | } while (0) |
| 92 | |
| 93 | #define tuner_dbg(fmt, arg...) do { \ |
| 94 | if (tuner_debug) \ |
| 95 | printk(KERN_DEBUG "%s %d-%04x: " fmt, PREFIX, \ |
| 96 | i2c_adapter_id(t->i2c->adapter), \ |
| 97 | t->i2c->addr, ##arg); \ |
| 98 | } while (0) |
| 99 | |
| 100 | /* |
| 101 | * Internal struct used inside the driver |
| 102 | */ |
| 103 | |
| 104 | struct tuner { |
| 105 | /* device */ |
| 106 | struct dvb_frontend fe; |
| 107 | struct i2c_client *i2c; |
| 108 | struct v4l2_subdev sd; |
| 109 | struct list_head list; |
| 110 | |
| 111 | /* keep track of the current settings */ |
| 112 | v4l2_std_id std; |
| 113 | unsigned int tv_freq; |
| 114 | unsigned int radio_freq; |
| 115 | unsigned int audmode; |
| 116 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 117 | enum v4l2_tuner_type mode; |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 118 | unsigned int mode_mask; /* Combination of allowable modes */ |
| 119 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 120 | bool standby; /* Standby mode */ |
| 121 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 122 | unsigned int type; /* chip type id */ |
| 123 | unsigned int config; |
| 124 | const char *name; |
| 125 | }; |
| 126 | |
| 127 | /* |
| 128 | * tuner attach/detach logic |
| 129 | */ |
| 130 | |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 131 | /** This macro allows us to probe dynamically, avoiding static links */ |
Mauro Carvalho Chehab | ff13817 | 2008-04-29 23:02:33 -0300 | [diff] [blame] | 132 | #ifdef CONFIG_MEDIA_ATTACH |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 133 | #define tuner_symbol_probe(FUNCTION, ARGS...) ({ \ |
| 134 | int __r = -EINVAL; \ |
| 135 | typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ |
| 136 | if (__a) { \ |
| 137 | __r = (int) __a(ARGS); \ |
Andrew Morton | a1355e5 | 2008-04-30 11:40:17 -0300 | [diff] [blame] | 138 | symbol_put(FUNCTION); \ |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 139 | } else { \ |
| 140 | printk(KERN_ERR "TUNER: Unable to find " \ |
| 141 | "symbol "#FUNCTION"()\n"); \ |
| 142 | } \ |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 143 | __r; \ |
| 144 | }) |
| 145 | |
| 146 | static void tuner_detach(struct dvb_frontend *fe) |
| 147 | { |
| 148 | if (fe->ops.tuner_ops.release) { |
| 149 | fe->ops.tuner_ops.release(fe); |
| 150 | symbol_put_addr(fe->ops.tuner_ops.release); |
| 151 | } |
| 152 | if (fe->ops.analog_ops.release) { |
| 153 | fe->ops.analog_ops.release(fe); |
| 154 | symbol_put_addr(fe->ops.analog_ops.release); |
| 155 | } |
| 156 | } |
| 157 | #else |
| 158 | #define tuner_symbol_probe(FUNCTION, ARGS...) ({ \ |
| 159 | FUNCTION(ARGS); \ |
| 160 | }) |
| 161 | |
| 162 | static void tuner_detach(struct dvb_frontend *fe) |
| 163 | { |
| 164 | if (fe->ops.tuner_ops.release) |
| 165 | fe->ops.tuner_ops.release(fe); |
| 166 | if (fe->ops.analog_ops.release) |
| 167 | fe->ops.analog_ops.release(fe); |
| 168 | } |
| 169 | #endif |
| 170 | |
Michael Krufky | f7f427e | 2007-12-16 22:02:26 -0300 | [diff] [blame] | 171 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 172 | static inline struct tuner *to_tuner(struct v4l2_subdev *sd) |
| 173 | { |
| 174 | return container_of(sd, struct tuner, sd); |
| 175 | } |
| 176 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 177 | /* |
| 178 | * struct analog_demod_ops callbacks |
| 179 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 181 | static void fe_set_params(struct dvb_frontend *fe, |
| 182 | struct analog_parameters *params) |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 183 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 184 | struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; |
| 185 | struct tuner *t = fe->analog_demod_priv; |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 186 | |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 187 | if (NULL == fe_tuner_ops->set_analog_params) { |
| 188 | tuner_warn("Tuner frontend module has no way to set freq\n"); |
| 189 | return; |
| 190 | } |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 191 | fe_tuner_ops->set_analog_params(fe, params); |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 192 | } |
| 193 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 194 | static void fe_standby(struct dvb_frontend *fe) |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 195 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 196 | struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 197 | |
| 198 | if (fe_tuner_ops->sleep) |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 199 | fe_tuner_ops->sleep(fe); |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 200 | } |
| 201 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 202 | static int fe_has_signal(struct dvb_frontend *fe) |
Michael Krufky | 1f5ef19 | 2007-08-31 17:38:02 -0300 | [diff] [blame] | 203 | { |
Michael Krufky | 1419683 | 2007-10-14 18:11:53 -0300 | [diff] [blame] | 204 | u16 strength = 0; |
Michael Krufky | 1f5ef19 | 2007-08-31 17:38:02 -0300 | [diff] [blame] | 205 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 206 | if (fe->ops.tuner_ops.get_rf_strength) |
| 207 | fe->ops.tuner_ops.get_rf_strength(fe, &strength); |
Michael Krufky | 1f5ef19 | 2007-08-31 17:38:02 -0300 | [diff] [blame] | 208 | |
| 209 | return strength; |
| 210 | } |
| 211 | |
Michael Krufky | f1c9a28 | 2007-12-16 19:27:23 -0300 | [diff] [blame] | 212 | static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg) |
| 213 | { |
| 214 | struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; |
| 215 | struct tuner *t = fe->analog_demod_priv; |
| 216 | |
| 217 | if (fe_tuner_ops->set_config) |
| 218 | return fe_tuner_ops->set_config(fe, priv_cfg); |
| 219 | |
| 220 | tuner_warn("Tuner frontend module has no way to set config\n"); |
| 221 | |
| 222 | return 0; |
| 223 | } |
| 224 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 225 | static void tuner_status(struct dvb_frontend *fe); |
Michael Krufky | 1dde7a4 | 2007-10-21 13:40:56 -0300 | [diff] [blame] | 226 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 227 | static struct analog_demod_ops tuner_analog_ops = { |
Michael Krufky | c7919d5 | 2007-12-08 17:06:30 -0300 | [diff] [blame] | 228 | .set_params = fe_set_params, |
Michael Krufky | 1dde7a4 | 2007-10-21 13:40:56 -0300 | [diff] [blame] | 229 | .standby = fe_standby, |
Michael Krufky | 1dde7a4 | 2007-10-21 13:40:56 -0300 | [diff] [blame] | 230 | .has_signal = fe_has_signal, |
Michael Krufky | f1c9a28 | 2007-12-16 19:27:23 -0300 | [diff] [blame] | 231 | .set_config = fe_set_config, |
Michael Krufky | 1dde7a4 | 2007-10-21 13:40:56 -0300 | [diff] [blame] | 232 | .tuner_status = tuner_status |
| 233 | }; |
| 234 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 235 | /* |
| 236 | * Functions that are common to both TV and radio |
| 237 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 239 | static void set_tv_freq(struct i2c_client *c, unsigned int freq); |
| 240 | static void set_radio_freq(struct i2c_client *c, unsigned int freq); |
| 241 | static const struct v4l2_subdev_ops tuner_ops; |
Steven Toth | 27c685a | 2008-01-05 16:50:14 -0300 | [diff] [blame] | 242 | |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 243 | static void set_type(struct i2c_client *c, unsigned int type, |
Hartmut Hackmann | de956c1 | 2007-04-27 12:31:12 -0300 | [diff] [blame] | 244 | unsigned int new_mode_mask, unsigned int new_config, |
Michael Krufky | d7cba04 | 2008-09-12 13:31:45 -0300 | [diff] [blame] | 245 | int (*tuner_callback) (void *dev, int component, int cmd, int arg)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | { |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 247 | struct tuner *t = to_tuner(i2c_get_clientdata(c)); |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 248 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; |
Michael Krufky | bc3e5c7 | 2007-12-21 11:18:32 -0300 | [diff] [blame] | 249 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
Mauro Carvalho Chehab | 586b0ca | 2005-06-28 20:45:21 -0700 | [diff] [blame] | 250 | unsigned char buffer[4]; |
Michael Krufky | d6eef49 | 2009-10-24 16:42:16 -0300 | [diff] [blame] | 251 | int tune_now = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 253 | if (type == UNSET || type == TUNER_ABSENT) { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 254 | tuner_dbg("tuner 0x%02x: Tuner type absent\n", c->addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | return; |
| 256 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | t->type = type; |
Michael Krufky | e7ddcd9 | 2009-03-28 15:35:26 -0300 | [diff] [blame] | 259 | /* prevent invalid config values */ |
Roel Kluin | f14a297 | 2009-10-23 07:59:42 -0300 | [diff] [blame] | 260 | t->config = new_config < 256 ? new_config : 0; |
Hartmut Hackmann | cfeb883 | 2007-04-27 12:31:17 -0300 | [diff] [blame] | 261 | if (tuner_callback != NULL) { |
| 262 | tuner_dbg("defining GPIO callback\n"); |
Michael Krufky | d7cba04 | 2008-09-12 13:31:45 -0300 | [diff] [blame] | 263 | t->fe.callback = tuner_callback; |
Hartmut Hackmann | cfeb883 | 2007-04-27 12:31:17 -0300 | [diff] [blame] | 264 | } |
Hartmut Hackmann | 80f90fb | 2007-04-27 12:31:18 -0300 | [diff] [blame] | 265 | |
Michael Krufky | b208319 | 2007-05-29 22:54:06 -0300 | [diff] [blame] | 266 | /* discard private data, in case set_type() was previously called */ |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 267 | tuner_detach(&t->fe); |
| 268 | t->fe.analog_demod_priv = NULL; |
Michael Krufky | be2b85a | 2007-06-04 14:40:27 -0300 | [diff] [blame] | 269 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | switch (t->type) { |
| 271 | case TUNER_MT2032: |
Mauro Carvalho Chehab | 09fee5f | 2008-04-30 15:29:57 -0300 | [diff] [blame] | 272 | if (!dvb_attach(microtune_attach, |
| 273 | &t->fe, t->i2c->adapter, t->i2c->addr)) |
| 274 | goto attach_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | break; |
| 276 | case TUNER_PHILIPS_TDA8290: |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 277 | { |
Mauro Carvalho Chehab | 09fee5f | 2008-04-30 15:29:57 -0300 | [diff] [blame] | 278 | struct tda829x_config cfg = { |
| 279 | .lna_cfg = t->config, |
Mauro Carvalho Chehab | 09fee5f | 2008-04-30 15:29:57 -0300 | [diff] [blame] | 280 | }; |
| 281 | if (!dvb_attach(tda829x_attach, &t->fe, t->i2c->adapter, |
| 282 | t->i2c->addr, &cfg)) |
| 283 | goto attach_failed; |
Michael Krufky | 5bea1cd | 2007-10-22 09:56:38 -0300 | [diff] [blame] | 284 | break; |
| 285 | } |
Mauro Carvalho Chehab | 586b0ca | 2005-06-28 20:45:21 -0700 | [diff] [blame] | 286 | case TUNER_TEA5767: |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 287 | if (!dvb_attach(tea5767_attach, &t->fe, |
| 288 | t->i2c->adapter, t->i2c->addr)) |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 289 | goto attach_failed; |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 290 | t->mode_mask = T_RADIO; |
Mauro Carvalho Chehab | 586b0ca | 2005-06-28 20:45:21 -0700 | [diff] [blame] | 291 | break; |
Mauro Carvalho Chehab | 8573a9e | 2007-04-08 01:09:11 -0300 | [diff] [blame] | 292 | case TUNER_TEA5761: |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 293 | if (!dvb_attach(tea5761_attach, &t->fe, |
| 294 | t->i2c->adapter, t->i2c->addr)) |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 295 | goto attach_failed; |
Mauro Carvalho Chehab | 8573a9e | 2007-04-08 01:09:11 -0300 | [diff] [blame] | 296 | t->mode_mask = T_RADIO; |
| 297 | break; |
Mauro Carvalho Chehab | 586b0ca | 2005-06-28 20:45:21 -0700 | [diff] [blame] | 298 | case TUNER_PHILIPS_FMD1216ME_MK3: |
| 299 | buffer[0] = 0x0b; |
| 300 | buffer[1] = 0xdc; |
| 301 | buffer[2] = 0x9c; |
| 302 | buffer[3] = 0x60; |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 303 | i2c_master_send(c, buffer, 4); |
Mauro Carvalho Chehab | 586b0ca | 2005-06-28 20:45:21 -0700 | [diff] [blame] | 304 | mdelay(1); |
| 305 | buffer[2] = 0x86; |
| 306 | buffer[3] = 0x54; |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 307 | i2c_master_send(c, buffer, 4); |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 308 | if (!dvb_attach(simple_tuner_attach, &t->fe, |
| 309 | t->i2c->adapter, t->i2c->addr, t->type)) |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 310 | goto attach_failed; |
Mauro Carvalho Chehab | 586b0ca | 2005-06-28 20:45:21 -0700 | [diff] [blame] | 311 | break; |
Hartmut Hackmann | 93df341 | 2005-11-08 21:36:31 -0800 | [diff] [blame] | 312 | case TUNER_PHILIPS_TD1316: |
| 313 | buffer[0] = 0x0b; |
| 314 | buffer[1] = 0xdc; |
| 315 | buffer[2] = 0x86; |
| 316 | buffer[3] = 0xa4; |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 317 | i2c_master_send(c, buffer, 4); |
| 318 | if (!dvb_attach(simple_tuner_attach, &t->fe, |
| 319 | t->i2c->adapter, t->i2c->addr, t->type)) |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 320 | goto attach_failed; |
Markus Rechberger | ac272ed | 2006-01-23 17:11:09 -0200 | [diff] [blame] | 321 | break; |
Mauro Carvalho Chehab | 690c544 | 2007-10-29 11:33:18 -0300 | [diff] [blame] | 322 | case TUNER_XC2028: |
| 323 | { |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 324 | struct xc2028_config cfg = { |
| 325 | .i2c_adap = t->i2c->adapter, |
| 326 | .i2c_addr = t->i2c->addr, |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 327 | }; |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 328 | if (!dvb_attach(xc2028_attach, &t->fe, &cfg)) |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 329 | goto attach_failed; |
Michael Krufky | d6eef49 | 2009-10-24 16:42:16 -0300 | [diff] [blame] | 330 | tune_now = 0; |
Mauro Carvalho Chehab | 690c544 | 2007-10-29 11:33:18 -0300 | [diff] [blame] | 331 | break; |
| 332 | } |
Mauro Carvalho Chehab | 1539623 | 2006-06-23 16:13:56 -0300 | [diff] [blame] | 333 | case TUNER_TDA9887: |
Mauro Carvalho Chehab | 09fee5f | 2008-04-30 15:29:57 -0300 | [diff] [blame] | 334 | if (!dvb_attach(tda9887_attach, |
| 335 | &t->fe, t->i2c->adapter, t->i2c->addr)) |
| 336 | goto attach_failed; |
Mauro Carvalho Chehab | 1539623 | 2006-06-23 16:13:56 -0300 | [diff] [blame] | 337 | break; |
Steven Toth | 27c685a | 2008-01-05 16:50:14 -0300 | [diff] [blame] | 338 | case TUNER_XC5000: |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 339 | { |
Mauro Carvalho Chehab | 900f734 | 2011-02-04 12:56:39 -0300 | [diff] [blame] | 340 | struct xc5000_config xc5000_cfg = { |
| 341 | .i2c_address = t->i2c->addr, |
| 342 | /* if_khz will be set at dvb_attach() */ |
| 343 | .if_khz = 0, |
| 344 | }; |
| 345 | |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 346 | if (!dvb_attach(xc5000_attach, |
Michael Krufky | 3065096 | 2008-09-06 14:56:58 -0300 | [diff] [blame] | 347 | &t->fe, t->i2c->adapter, &xc5000_cfg)) |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 348 | goto attach_failed; |
Michael Krufky | d6eef49 | 2009-10-24 16:42:16 -0300 | [diff] [blame] | 349 | tune_now = 0; |
Steven Toth | 27c685a | 2008-01-05 16:50:14 -0300 | [diff] [blame] | 350 | break; |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 351 | } |
Michael Krufky | 9346389 | 2009-09-15 23:04:18 -0300 | [diff] [blame] | 352 | case TUNER_NXP_TDA18271: |
| 353 | { |
| 354 | struct tda18271_config cfg = { |
| 355 | .config = t->config, |
Mauro Carvalho Chehab | e350d44 | 2010-09-26 22:58:28 -0300 | [diff] [blame] | 356 | .small_i2c = TDA18271_03_BYTE_CHUNK_INIT, |
Michael Krufky | 9346389 | 2009-09-15 23:04:18 -0300 | [diff] [blame] | 357 | }; |
| 358 | |
| 359 | if (!dvb_attach(tda18271_attach, &t->fe, t->i2c->addr, |
| 360 | t->i2c->adapter, &cfg)) |
| 361 | goto attach_failed; |
Michael Krufky | d6eef49 | 2009-10-24 16:42:16 -0300 | [diff] [blame] | 362 | tune_now = 0; |
Michael Krufky | 9346389 | 2009-09-15 23:04:18 -0300 | [diff] [blame] | 363 | break; |
| 364 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | default: |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 366 | if (!dvb_attach(simple_tuner_attach, &t->fe, |
| 367 | t->i2c->adapter, t->i2c->addr, t->type)) |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 368 | goto attach_failed; |
| 369 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | break; |
| 371 | } |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 372 | |
Michael Krufky | bc3e5c7 | 2007-12-21 11:18:32 -0300 | [diff] [blame] | 373 | if ((NULL == analog_ops->set_params) && |
Michael Krufky | 1dde7a4 | 2007-10-21 13:40:56 -0300 | [diff] [blame] | 374 | (fe_tuner_ops->set_analog_params)) { |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 375 | |
Michael Krufky | 7271e60 | 2008-05-26 16:08:40 +0200 | [diff] [blame] | 376 | t->name = fe_tuner_ops->info.name; |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 377 | |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 378 | t->fe.analog_demod_priv = t; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 379 | memcpy(analog_ops, &tuner_analog_ops, |
Michael Krufky | bc3e5c7 | 2007-12-21 11:18:32 -0300 | [diff] [blame] | 380 | sizeof(struct analog_demod_ops)); |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 381 | |
Michael Krufky | a55db8c | 2007-12-09 13:52:51 -0300 | [diff] [blame] | 382 | } else { |
Michael Krufky | 7271e60 | 2008-05-26 16:08:40 +0200 | [diff] [blame] | 383 | t->name = analog_ops->info.name; |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 384 | } |
| 385 | |
Michael Krufky | 7271e60 | 2008-05-26 16:08:40 +0200 | [diff] [blame] | 386 | tuner_dbg("type set to %s\n", t->name); |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 387 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 388 | t->mode_mask = new_mode_mask; |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 389 | |
Michael Krufky | d6eef49 | 2009-10-24 16:42:16 -0300 | [diff] [blame] | 390 | /* Some tuners require more initialization setup before use, |
| 391 | such as firmware download or device calibration. |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 392 | trying to set a frequency here will just fail |
| 393 | FIXME: better to move set_freq to the tuner code. This is needed |
| 394 | on analog tuners for PLL to properly work |
| 395 | */ |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 396 | if (tune_now) { |
| 397 | if (V4L2_TUNER_RADIO == t->mode) |
| 398 | set_radio_freq(c, t->radio_freq); |
| 399 | else |
| 400 | set_tv_freq(c, t->tv_freq); |
| 401 | } |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 402 | |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 403 | tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", |
Laurent Riffard | 604f28e | 2005-11-26 20:43:39 +0100 | [diff] [blame] | 404 | c->adapter->name, c->driver->driver.name, c->addr << 1, type, |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 405 | t->mode_mask); |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 406 | return; |
| 407 | |
| 408 | attach_failed: |
| 409 | tuner_dbg("Tuner attach for type = %d failed.\n", t->type); |
| 410 | t->type = TUNER_ABSENT; |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 411 | |
| 412 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | } |
| 414 | |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 415 | /* |
| 416 | * This function apply tuner config to tuner specified |
| 417 | * by tun_setup structure. I addr is unset, then admin status |
| 418 | * and tun addr status is more precise then current status, |
| 419 | * it's applied. Otherwise status and type are applied only to |
| 420 | * tuner with exactly the same addr. |
| 421 | */ |
Mauro Carvalho Chehab | a34ec5f | 2011-02-15 00:55:18 -0300 | [diff] [blame^] | 422 | static int tuner_s_type_addr(struct v4l2_subdev *sd, |
| 423 | struct tuner_setup *tun_setup) |
Mauro Carvalho Chehab | 56fc08c | 2005-06-23 22:05:07 -0700 | [diff] [blame] | 424 | { |
Mauro Carvalho Chehab | a34ec5f | 2011-02-15 00:55:18 -0300 | [diff] [blame^] | 425 | struct tuner *t = to_tuner(sd); |
| 426 | struct i2c_client *c = v4l2_get_subdevdata(sd); |
| 427 | |
| 428 | tuner_dbg("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x, config=0x%02x\n", |
| 429 | tun_setup->type, |
| 430 | tun_setup->addr, |
| 431 | tun_setup->mode_mask, |
| 432 | tun_setup->config); |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 433 | |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 434 | if ((t->type == UNSET && ((tun_setup->addr == ADDR_UNSET) && |
| 435 | (t->mode_mask & tun_setup->mode_mask))) || |
| 436 | (tun_setup->addr == c->addr)) { |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 437 | set_type(c, tun_setup->type, tun_setup->mode_mask, |
| 438 | tun_setup->config, tun_setup->tuner_callback); |
Mauro Carvalho Chehab | b9ef6bb | 2008-04-26 11:29:34 -0300 | [diff] [blame] | 439 | } else |
| 440 | tuner_dbg("set addr discarded for type %i, mask %x. " |
| 441 | "Asked to change tuner at addr 0x%02x, with mask %x\n", |
| 442 | t->type, t->mode_mask, |
| 443 | tun_setup->addr, tun_setup->mode_mask); |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 444 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 445 | return 0; |
| 446 | } |
| 447 | |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 448 | static int tuner_s_config(struct v4l2_subdev *sd, |
| 449 | const struct v4l2_priv_tun_config *cfg) |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 450 | { |
| 451 | struct tuner *t = to_tuner(sd); |
| 452 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
| 453 | |
| 454 | if (t->type != cfg->tuner) |
| 455 | return 0; |
| 456 | |
| 457 | if (analog_ops->set_config) { |
| 458 | analog_ops->set_config(&t->fe, cfg->priv); |
| 459 | return 0; |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 460 | } |
Mauro Carvalho Chehab | 793cf9e | 2005-09-09 13:03:37 -0700 | [diff] [blame] | 461 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 462 | tuner_dbg("Tuner frontend module has no way to set config\n"); |
Mauro Carvalho Chehab | 793cf9e | 2005-09-09 13:03:37 -0700 | [diff] [blame] | 463 | return 0; |
Mauro Carvalho Chehab | 56fc08c | 2005-06-23 22:05:07 -0700 | [diff] [blame] | 464 | } |
Mauro Carvalho Chehab | 56fc08c | 2005-06-23 22:05:07 -0700 | [diff] [blame] | 465 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 466 | /* Search for existing radio and/or TV tuners on the given I2C adapter. |
| 467 | Note that when this function is called from tuner_probe you can be |
| 468 | certain no other devices will be added/deleted at the same time, I2C |
| 469 | core protects against that. */ |
| 470 | static void tuner_lookup(struct i2c_adapter *adap, |
| 471 | struct tuner **radio, struct tuner **tv) |
| 472 | { |
| 473 | struct tuner *pos; |
| 474 | |
| 475 | *radio = NULL; |
| 476 | *tv = NULL; |
| 477 | |
| 478 | list_for_each_entry(pos, &tuner_list, list) { |
| 479 | int mode_mask; |
| 480 | |
| 481 | if (pos->i2c->adapter != adap || |
| 482 | strcmp(pos->i2c->driver->driver.name, "tuner")) |
| 483 | continue; |
| 484 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 485 | mode_mask = pos->mode_mask; |
| 486 | pos->standby = 1; |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 487 | if (*radio == NULL && mode_mask == T_RADIO) |
| 488 | *radio = pos; |
| 489 | /* Note: currently TDA9887 is the only demod-only |
| 490 | device. If other devices appear then we need to |
| 491 | make this test more general. */ |
| 492 | else if (*tv == NULL && pos->type != TUNER_TDA9887 && |
| 493 | (pos->mode_mask & (T_ANALOG_TV | T_DIGITAL_TV))) |
| 494 | *tv = pos; |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | /* During client attach, set_type is called by adapter's attach_inform callback. |
| 499 | set_type must then be completed by tuner_probe. |
| 500 | */ |
| 501 | static int tuner_probe(struct i2c_client *client, |
| 502 | const struct i2c_device_id *id) |
| 503 | { |
| 504 | struct tuner *t; |
| 505 | struct tuner *radio; |
| 506 | struct tuner *tv; |
| 507 | |
| 508 | t = kzalloc(sizeof(struct tuner), GFP_KERNEL); |
| 509 | if (NULL == t) |
| 510 | return -ENOMEM; |
| 511 | v4l2_i2c_subdev_init(&t->sd, client, &tuner_ops); |
| 512 | t->i2c = client; |
| 513 | t->name = "(tuner unset)"; |
| 514 | t->type = UNSET; |
| 515 | t->audmode = V4L2_TUNER_MODE_STEREO; |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 516 | t->standby = 1; |
| 517 | t->radio_freq = 87.5 * 16000; /* Initial freq range */ |
| 518 | t->tv_freq = 400 * 16; /* Sets freq to VHF High - needed for some PLL's to properly start */ |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 519 | |
| 520 | if (show_i2c) { |
| 521 | unsigned char buffer[16]; |
| 522 | int i, rc; |
| 523 | |
| 524 | memset(buffer, 0, sizeof(buffer)); |
| 525 | rc = i2c_master_recv(client, buffer, sizeof(buffer)); |
| 526 | tuner_info("I2C RECV = "); |
| 527 | for (i = 0; i < rc; i++) |
| 528 | printk(KERN_CONT "%02x ", buffer[i]); |
| 529 | printk("\n"); |
| 530 | } |
| 531 | |
| 532 | /* autodetection code based on the i2c addr */ |
| 533 | if (!no_autodetect) { |
| 534 | switch (client->addr) { |
| 535 | case 0x10: |
| 536 | if (tuner_symbol_probe(tea5761_autodetection, |
| 537 | t->i2c->adapter, |
| 538 | t->i2c->addr) >= 0) { |
| 539 | t->type = TUNER_TEA5761; |
| 540 | t->mode_mask = T_RADIO; |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 541 | tuner_lookup(t->i2c->adapter, &radio, &tv); |
| 542 | if (tv) |
| 543 | tv->mode_mask &= ~T_RADIO; |
| 544 | |
| 545 | goto register_client; |
| 546 | } |
| 547 | kfree(t); |
| 548 | return -ENODEV; |
| 549 | case 0x42: |
| 550 | case 0x43: |
| 551 | case 0x4a: |
| 552 | case 0x4b: |
| 553 | /* If chip is not tda8290, don't register. |
| 554 | since it can be tda9887*/ |
| 555 | if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter, |
| 556 | t->i2c->addr) >= 0) { |
| 557 | tuner_dbg("tda829x detected\n"); |
| 558 | } else { |
| 559 | /* Default is being tda9887 */ |
| 560 | t->type = TUNER_TDA9887; |
| 561 | t->mode_mask = T_RADIO | T_ANALOG_TV | |
| 562 | T_DIGITAL_TV; |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 563 | goto register_client; |
| 564 | } |
| 565 | break; |
| 566 | case 0x60: |
| 567 | if (tuner_symbol_probe(tea5767_autodetection, |
| 568 | t->i2c->adapter, t->i2c->addr) |
| 569 | >= 0) { |
| 570 | t->type = TUNER_TEA5767; |
| 571 | t->mode_mask = T_RADIO; |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 572 | /* Sets freq to FM range */ |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 573 | tuner_lookup(t->i2c->adapter, &radio, &tv); |
| 574 | if (tv) |
| 575 | tv->mode_mask &= ~T_RADIO; |
| 576 | |
| 577 | goto register_client; |
| 578 | } |
| 579 | break; |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | /* Initializes only the first TV tuner on this adapter. Why only the |
| 584 | first? Because there are some devices (notably the ones with TI |
| 585 | tuners) that have more than one i2c address for the *same* device. |
| 586 | Experience shows that, except for just one case, the first |
| 587 | address is the right one. The exception is a Russian tuner |
| 588 | (ACORP_Y878F). So, the desired behavior is just to enable the |
| 589 | first found TV tuner. */ |
| 590 | tuner_lookup(t->i2c->adapter, &radio, &tv); |
| 591 | if (tv == NULL) { |
| 592 | t->mode_mask = T_ANALOG_TV | T_DIGITAL_TV; |
| 593 | if (radio == NULL) |
| 594 | t->mode_mask |= T_RADIO; |
| 595 | tuner_dbg("Setting mode_mask to 0x%02x\n", t->mode_mask); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | /* Should be just before return */ |
| 599 | register_client: |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 600 | /* Sets a default mode */ |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 601 | if (t->mode_mask & T_ANALOG_TV) |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 602 | t->mode = V4L2_TUNER_ANALOG_TV; |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 603 | else if (t->mode_mask & T_RADIO) |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 604 | t->mode = V4L2_TUNER_RADIO; |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 605 | else |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 606 | t->mode = V4L2_TUNER_DIGITAL_TV; |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 607 | set_type(client, t->type, t->mode_mask, t->config, t->fe.callback); |
| 608 | list_add_tail(&t->list, &tuner_list); |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 609 | |
| 610 | tuner_info("Tuner %d found with type(s)%s%s%s.\n", |
| 611 | t->type, |
| 612 | t->mode_mask & T_RADIO ? " radio" : "", |
| 613 | t->mode_mask & T_ANALOG_TV ? " TV" : "", |
| 614 | t->mode_mask & T_ANALOG_TV ? " DTV" : ""); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | static int tuner_remove(struct i2c_client *client) |
| 619 | { |
| 620 | struct tuner *t = to_tuner(i2c_get_clientdata(client)); |
| 621 | |
| 622 | v4l2_device_unregister_subdev(&t->sd); |
| 623 | tuner_detach(&t->fe); |
| 624 | t->fe.analog_demod_priv = NULL; |
| 625 | |
| 626 | list_del(&t->list); |
| 627 | kfree(t); |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | /* |
| 632 | * Functions that are specific for TV mode |
| 633 | */ |
| 634 | |
| 635 | /* Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz */ |
| 636 | static void set_tv_freq(struct i2c_client *c, unsigned int freq) |
| 637 | { |
| 638 | struct tuner *t = to_tuner(i2c_get_clientdata(c)); |
| 639 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
| 640 | |
| 641 | struct analog_parameters params = { |
| 642 | .mode = t->mode, |
| 643 | .audmode = t->audmode, |
| 644 | .std = t->std |
| 645 | }; |
| 646 | |
| 647 | if (t->type == UNSET) { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 648 | tuner_warn("tuner type not set\n"); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 649 | return; |
| 650 | } |
| 651 | if (NULL == analog_ops->set_params) { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 652 | tuner_warn("Tuner has no way to set tv freq\n"); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 653 | return; |
| 654 | } |
| 655 | if (freq < tv_range[0] * 16 || freq > tv_range[1] * 16) { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 656 | tuner_dbg("TV freq (%d.%02d) out of range (%d-%d)\n", |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 657 | freq / 16, freq % 16 * 100 / 16, tv_range[0], |
| 658 | tv_range[1]); |
| 659 | /* V4L2 spec: if the freq is not possible then the closest |
| 660 | possible value should be selected */ |
| 661 | if (freq < tv_range[0] * 16) |
| 662 | freq = tv_range[0] * 16; |
| 663 | else |
| 664 | freq = tv_range[1] * 16; |
| 665 | } |
| 666 | params.frequency = freq; |
| 667 | tuner_dbg("tv freq set to %d.%02d\n", |
| 668 | freq / 16, freq % 16 * 100 / 16); |
| 669 | t->tv_freq = freq; |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 670 | t->standby = false; |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 671 | |
| 672 | analog_ops->set_params(&t->fe, ¶ms); |
| 673 | } |
| 674 | |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 675 | /* get more precise norm info from insmod option */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | static int tuner_fixup_std(struct tuner *t) |
| 677 | { |
| 678 | if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | switch (pal[0]) { |
Hans Verkuil | e71ced1 | 2006-12-11 15:51:43 -0300 | [diff] [blame] | 680 | case '6': |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 681 | tuner_dbg("insmod fixup: PAL => PAL-60\n"); |
Hans Verkuil | e71ced1 | 2006-12-11 15:51:43 -0300 | [diff] [blame] | 682 | t->std = V4L2_STD_PAL_60; |
| 683 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | case 'b': |
| 685 | case 'B': |
| 686 | case 'g': |
| 687 | case 'G': |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 688 | tuner_dbg("insmod fixup: PAL => PAL-BG\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | t->std = V4L2_STD_PAL_BG; |
| 690 | break; |
| 691 | case 'i': |
| 692 | case 'I': |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 693 | tuner_dbg("insmod fixup: PAL => PAL-I\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | t->std = V4L2_STD_PAL_I; |
| 695 | break; |
| 696 | case 'd': |
| 697 | case 'D': |
| 698 | case 'k': |
| 699 | case 'K': |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 700 | tuner_dbg("insmod fixup: PAL => PAL-DK\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | t->std = V4L2_STD_PAL_DK; |
| 702 | break; |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 703 | case 'M': |
| 704 | case 'm': |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 705 | tuner_dbg("insmod fixup: PAL => PAL-M\n"); |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 706 | t->std = V4L2_STD_PAL_M; |
| 707 | break; |
| 708 | case 'N': |
| 709 | case 'n': |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 710 | if (pal[1] == 'c' || pal[1] == 'C') { |
| 711 | tuner_dbg("insmod fixup: PAL => PAL-Nc\n"); |
| 712 | t->std = V4L2_STD_PAL_Nc; |
| 713 | } else { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 714 | tuner_dbg("insmod fixup: PAL => PAL-N\n"); |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 715 | t->std = V4L2_STD_PAL_N; |
| 716 | } |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 717 | break; |
Mauro Carvalho Chehab | 21d4df3 | 2005-09-09 13:03:59 -0700 | [diff] [blame] | 718 | case '-': |
| 719 | /* default parameter, do nothing */ |
| 720 | break; |
| 721 | default: |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 722 | tuner_warn("pal= argument not recognised\n"); |
Mauro Carvalho Chehab | 21d4df3 | 2005-09-09 13:03:59 -0700 | [diff] [blame] | 723 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | } |
| 725 | } |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 726 | if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { |
| 727 | switch (secam[0]) { |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 728 | case 'b': |
| 729 | case 'B': |
| 730 | case 'g': |
| 731 | case 'G': |
| 732 | case 'h': |
| 733 | case 'H': |
| 734 | tuner_dbg("insmod fixup: SECAM => SECAM-BGH\n"); |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 735 | t->std = V4L2_STD_SECAM_B | |
| 736 | V4L2_STD_SECAM_G | |
| 737 | V4L2_STD_SECAM_H; |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 738 | break; |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 739 | case 'd': |
| 740 | case 'D': |
| 741 | case 'k': |
| 742 | case 'K': |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 743 | tuner_dbg("insmod fixup: SECAM => SECAM-DK\n"); |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 744 | t->std = V4L2_STD_SECAM_DK; |
| 745 | break; |
| 746 | case 'l': |
| 747 | case 'L': |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 748 | if ((secam[1] == 'C') || (secam[1] == 'c')) { |
| 749 | tuner_dbg("insmod fixup: SECAM => SECAM-L'\n"); |
Mauro Carvalho Chehab | 800d3c6 | 2005-11-13 16:07:48 -0800 | [diff] [blame] | 750 | t->std = V4L2_STD_SECAM_LC; |
| 751 | } else { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 752 | tuner_dbg("insmod fixup: SECAM => SECAM-L\n"); |
Mauro Carvalho Chehab | 800d3c6 | 2005-11-13 16:07:48 -0800 | [diff] [blame] | 753 | t->std = V4L2_STD_SECAM_L; |
| 754 | } |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 755 | break; |
Mauro Carvalho Chehab | 21d4df3 | 2005-09-09 13:03:59 -0700 | [diff] [blame] | 756 | case '-': |
| 757 | /* default parameter, do nothing */ |
| 758 | break; |
| 759 | default: |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 760 | tuner_warn("secam= argument not recognised\n"); |
Mauro Carvalho Chehab | 21d4df3 | 2005-09-09 13:03:59 -0700 | [diff] [blame] | 761 | break; |
Mauro Carvalho Chehab | f7ce3cc | 2005-07-12 13:58:55 -0700 | [diff] [blame] | 762 | } |
| 763 | } |
| 764 | |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 765 | if ((t->std & V4L2_STD_NTSC) == V4L2_STD_NTSC) { |
| 766 | switch (ntsc[0]) { |
| 767 | case 'm': |
| 768 | case 'M': |
| 769 | tuner_dbg("insmod fixup: NTSC => NTSC-M\n"); |
| 770 | t->std = V4L2_STD_NTSC_M; |
| 771 | break; |
| 772 | case 'j': |
| 773 | case 'J': |
| 774 | tuner_dbg("insmod fixup: NTSC => NTSC_M_JP\n"); |
| 775 | t->std = V4L2_STD_NTSC_M_JP; |
| 776 | break; |
Hans Verkuil | d97a11e | 2006-02-07 06:48:40 -0200 | [diff] [blame] | 777 | case 'k': |
| 778 | case 'K': |
| 779 | tuner_dbg("insmod fixup: NTSC => NTSC_M_KR\n"); |
| 780 | t->std = V4L2_STD_NTSC_M_KR; |
| 781 | break; |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 782 | case '-': |
| 783 | /* default parameter, do nothing */ |
| 784 | break; |
| 785 | default: |
| 786 | tuner_info("ntsc= argument not recognised\n"); |
| 787 | break; |
| 788 | } |
| 789 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | return 0; |
| 791 | } |
| 792 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 793 | /* |
| 794 | * Functions that are specific for Radio mode |
| 795 | */ |
| 796 | |
| 797 | static void set_radio_freq(struct i2c_client *c, unsigned int freq) |
| 798 | { |
| 799 | struct tuner *t = to_tuner(i2c_get_clientdata(c)); |
| 800 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
| 801 | |
| 802 | struct analog_parameters params = { |
| 803 | .mode = t->mode, |
| 804 | .audmode = t->audmode, |
| 805 | .std = t->std |
| 806 | }; |
| 807 | |
| 808 | if (t->type == UNSET) { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 809 | tuner_warn("tuner type not set\n"); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 810 | return; |
| 811 | } |
| 812 | if (NULL == analog_ops->set_params) { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 813 | tuner_warn("tuner has no way to set radio frequency\n"); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 814 | return; |
| 815 | } |
| 816 | if (freq < radio_range[0] * 16000 || freq > radio_range[1] * 16000) { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 817 | tuner_dbg("radio freq (%d.%02d) out of range (%d-%d)\n", |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 818 | freq / 16000, freq % 16000 * 100 / 16000, |
| 819 | radio_range[0], radio_range[1]); |
| 820 | /* V4L2 spec: if the freq is not possible then the closest |
| 821 | possible value should be selected */ |
| 822 | if (freq < radio_range[0] * 16000) |
| 823 | freq = radio_range[0] * 16000; |
| 824 | else |
| 825 | freq = radio_range[1] * 16000; |
| 826 | } |
| 827 | params.frequency = freq; |
| 828 | tuner_dbg("radio freq set to %d.%02d\n", |
| 829 | freq / 16000, freq % 16000 * 100 / 16000); |
| 830 | t->radio_freq = freq; |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 831 | t->standby = false; |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 832 | |
| 833 | analog_ops->set_params(&t->fe, ¶ms); |
| 834 | } |
| 835 | |
Mauro Carvalho Chehab | e2d25a2 | 2011-02-04 10:09:07 -0300 | [diff] [blame] | 836 | /** |
| 837 | * check_mode - Verify if tuner supports the requested mode |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 838 | * @t: a pointer to the module's internal struct_tuner |
Mauro Carvalho Chehab | e2d25a2 | 2011-02-04 10:09:07 -0300 | [diff] [blame] | 839 | * |
| 840 | * This function checks if the tuner is capable of tuning analog TV, |
| 841 | * digital TV or radio, depending on what the caller wants. If the |
| 842 | * tuner can't support that mode, it returns -EINVAL. Otherwise, it |
| 843 | * returns 0. |
| 844 | * This function is needed for boards that have a separate tuner for |
| 845 | * radio (like devices with tea5767). |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 846 | */ |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 847 | static inline int check_mode(struct tuner *t, enum v4l2_tuner_type mode) |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 848 | { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 849 | if ((1 << mode & t->mode_mask) == 0) |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 850 | return -EINVAL; |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 851 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 852 | return 0; |
| 853 | } |
| 854 | |
Mauro Carvalho Chehab | e2d25a2 | 2011-02-04 10:09:07 -0300 | [diff] [blame] | 855 | /** |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 856 | * set_mode_freq - Switch tuner to other mode. |
| 857 | * @client: struct i2c_client pointer |
| 858 | * @t: a pointer to the module's internal struct_tuner |
| 859 | * @mode: enum v4l2_type (radio or TV) |
| 860 | * @freq: frequency to set (0 means to use the previous one) |
Mauro Carvalho Chehab | e2d25a2 | 2011-02-04 10:09:07 -0300 | [diff] [blame] | 861 | * |
| 862 | * If tuner doesn't support the needed mode (radio or TV), prints a |
| 863 | * debug message and returns -EINVAL, changing internal state to T_STANDBY. |
| 864 | * Otherwise, changes the state and sets frequency to the last value, if |
| 865 | * the tuner can sleep or if it supports both Radio and TV. |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 866 | */ |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 867 | static int set_mode_freq(struct i2c_client *client, struct tuner *t, |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 868 | enum v4l2_tuner_type mode, unsigned int freq) |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 869 | { |
| 870 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
| 871 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 872 | if (mode != t->mode) { |
| 873 | if (check_mode(t, mode) == -EINVAL) { |
| 874 | tuner_dbg("Tuner doesn't support mode %d. " |
| 875 | "Putting tuner to sleep\n", mode); |
| 876 | t->standby = true; |
| 877 | if (analog_ops->standby) |
| 878 | analog_ops->standby(&t->fe); |
| 879 | return -EINVAL; |
| 880 | } |
| 881 | t->mode = mode; |
| 882 | tuner_dbg("Changing to mode %d\n", mode); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 883 | } |
Mauro Carvalho Chehab | e2d25a2 | 2011-02-04 10:09:07 -0300 | [diff] [blame] | 884 | if (t->mode == V4L2_TUNER_RADIO) { |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 885 | if (freq) |
| 886 | t->radio_freq = freq; |
| 887 | set_radio_freq(client, t->radio_freq); |
Mauro Carvalho Chehab | e2d25a2 | 2011-02-04 10:09:07 -0300 | [diff] [blame] | 888 | } else { |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 889 | if (freq) |
| 890 | t->tv_freq = freq; |
| 891 | set_tv_freq(client, t->tv_freq); |
Mauro Carvalho Chehab | e2d25a2 | 2011-02-04 10:09:07 -0300 | [diff] [blame] | 892 | } |
| 893 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 894 | return 0; |
| 895 | } |
| 896 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 897 | /** |
| 898 | * tuner_status - Dumps the current tuner status at dmesg |
| 899 | * @fe: pointer to struct dvb_frontend |
| 900 | * |
| 901 | * This callback is used only for driver debug purposes, answering to |
| 902 | * VIDIOC_LOG_STATUS. No changes should happen on this call. |
| 903 | */ |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 904 | static void tuner_status(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 905 | { |
Michael Krufky | 4e9154b | 2007-10-21 19:39:50 -0300 | [diff] [blame] | 906 | struct tuner *t = fe->analog_demod_priv; |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 907 | unsigned long freq, freq_fraction; |
Michael Krufky | a07c877 | 2008-04-29 03:54:19 -0300 | [diff] [blame] | 908 | struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; |
| 909 | struct analog_demod_ops *analog_ops = &fe->ops.analog_ops; |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 910 | const char *p; |
| 911 | |
| 912 | switch (t->mode) { |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 913 | case V4L2_TUNER_RADIO: |
| 914 | p = "radio"; |
| 915 | break; |
| 916 | case V4L2_TUNER_DIGITAL_TV: |
| 917 | p = "digital TV"; |
| 918 | break; |
| 919 | case V4L2_TUNER_ANALOG_TV: |
| 920 | default: |
| 921 | p = "analog TV"; |
| 922 | break; |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 923 | } |
| 924 | if (t->mode == V4L2_TUNER_RADIO) { |
Hans Verkuil | 27487d4 | 2006-01-15 15:04:52 -0200 | [diff] [blame] | 925 | freq = t->radio_freq / 16000; |
| 926 | freq_fraction = (t->radio_freq % 16000) * 100 / 16000; |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 927 | } else { |
Hans Verkuil | 27487d4 | 2006-01-15 15:04:52 -0200 | [diff] [blame] | 928 | freq = t->tv_freq / 16; |
| 929 | freq_fraction = (t->tv_freq % 16) * 100 / 16; |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 930 | } |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 931 | tuner_info("Tuner mode: %s%s\n", p, |
| 932 | t->standby ? " on standby mode" : ""); |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 933 | tuner_info("Frequency: %lu.%02lu MHz\n", freq, freq_fraction); |
Mauro Carvalho Chehab | 4ae5c2e | 2006-03-25 15:53:38 -0300 | [diff] [blame] | 934 | tuner_info("Standard: 0x%08lx\n", (unsigned long)t->std); |
Hans Verkuil | 8a4b275 | 2006-01-23 17:11:09 -0200 | [diff] [blame] | 935 | if (t->mode != V4L2_TUNER_RADIO) |
Mauro Carvalho Chehab | 7d275bf | 2011-02-04 11:28:00 -0300 | [diff] [blame] | 936 | return; |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 937 | if (fe_tuner_ops->get_status) { |
| 938 | u32 tuner_status; |
| 939 | |
| 940 | fe_tuner_ops->get_status(&t->fe, &tuner_status); |
| 941 | if (tuner_status & TUNER_STATUS_LOCKED) |
| 942 | tuner_info("Tuner is locked.\n"); |
| 943 | if (tuner_status & TUNER_STATUS_STEREO) |
| 944 | tuner_info("Stereo: yes\n"); |
| 945 | } |
Michael Krufky | bc3e5c7 | 2007-12-21 11:18:32 -0300 | [diff] [blame] | 946 | if (analog_ops->has_signal) |
| 947 | tuner_info("Signal strength: %d\n", |
| 948 | analog_ops->has_signal(fe)); |
Mauro Carvalho Chehab | 7e57819 | 2006-01-09 15:25:27 -0200 | [diff] [blame] | 949 | } |
Hans Verkuil | 8a4b275 | 2006-01-23 17:11:09 -0200 | [diff] [blame] | 950 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 951 | /** |
| 952 | * tuner_s_power - controls the power state of the tuner |
| 953 | * @sd: pointer to struct v4l2_subdev |
| 954 | * @on: a zero value puts the tuner to sleep |
| 955 | */ |
Laurent Pinchart | 622b828 | 2009-10-05 10:48:17 -0300 | [diff] [blame] | 956 | static int tuner_s_power(struct v4l2_subdev *sd, int on) |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 957 | { |
| 958 | struct tuner *t = to_tuner(sd); |
Michael Krufky | bc3e5c7 | 2007-12-21 11:18:32 -0300 | [diff] [blame] | 959 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 961 | /* FIXME: Why this function don't wake the tuner if on != 0 ? */ |
Laurent Pinchart | 622b828 | 2009-10-05 10:48:17 -0300 | [diff] [blame] | 962 | if (on) |
| 963 | return 0; |
| 964 | |
Mauro Carvalho Chehab | 16a5e53 | 2008-12-20 07:17:10 -0300 | [diff] [blame] | 965 | tuner_dbg("Putting tuner to sleep\n"); |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 966 | t->standby = true; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 967 | if (analog_ops->standby) |
| 968 | analog_ops->standby(&t->fe); |
| 969 | return 0; |
| 970 | } |
| 971 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 972 | /* ---------------------------------------------------------------------- */ |
| 973 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 974 | static int tuner_s_radio(struct v4l2_subdev *sd) |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 975 | { |
| 976 | struct tuner *t = to_tuner(sd); |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 977 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Mauro Carvalho Chehab | 7f17112 | 2007-10-18 19:56:47 -0300 | [diff] [blame] | 978 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 979 | if (set_mode_freq(client, t, V4L2_TUNER_RADIO, 0) == -EINVAL) |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 980 | return 0; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 981 | return 0; |
| 982 | } |
Mauro Carvalho Chehab | 56fc08c | 2005-06-23 22:05:07 -0700 | [diff] [blame] | 983 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 984 | /* --- v4l ioctls --- */ |
| 985 | /* take care: bttv does userspace copying, we'll get a |
| 986 | kernel pointer here... */ |
| 987 | static int tuner_s_std(struct v4l2_subdev *sd, v4l2_std_id std) |
| 988 | { |
| 989 | struct tuner *t = to_tuner(sd); |
| 990 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 992 | if (set_mode_freq(client, t, V4L2_TUNER_ANALOG_TV, 0) == -EINVAL) |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 993 | return 0; |
Mauro Carvalho Chehab | 586b0ca | 2005-06-28 20:45:21 -0700 | [diff] [blame] | 994 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 995 | t->std = std; |
| 996 | tuner_fixup_std(t); |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 997 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 998 | return 0; |
| 999 | } |
Mauro Carvalho Chehab | 586b0ca | 2005-06-28 20:45:21 -0700 | [diff] [blame] | 1000 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1001 | static int tuner_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) |
| 1002 | { |
| 1003 | struct tuner *t = to_tuner(sd); |
| 1004 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
Michael Krufky | e18f944 | 2007-08-21 01:25:48 -0300 | [diff] [blame] | 1005 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1006 | if (set_mode_freq(client, t, f->type, f->frequency) == -EINVAL) |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1007 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1012 | static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) |
| 1013 | { |
| 1014 | struct tuner *t = to_tuner(sd); |
| 1015 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; |
| 1016 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1017 | if (check_mode(t, f->type) == -EINVAL) |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1018 | return 0; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1019 | f->type = t->mode; |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1020 | if (fe_tuner_ops->get_frequency && !t->standby) { |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1021 | u32 abs_freq; |
| 1022 | |
| 1023 | fe_tuner_ops->get_frequency(&t->fe, &abs_freq); |
| 1024 | f->frequency = (V4L2_TUNER_RADIO == t->mode) ? |
Julia Lawall | 75b697f | 2009-08-01 16:48:41 -0300 | [diff] [blame] | 1025 | DIV_ROUND_CLOSEST(abs_freq * 2, 125) : |
| 1026 | DIV_ROUND_CLOSEST(abs_freq, 62500); |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1027 | } else { |
| 1028 | f->frequency = (V4L2_TUNER_RADIO == t->mode) ? |
| 1029 | t->radio_freq : t->tv_freq; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1030 | } |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1031 | return 0; |
| 1032 | } |
| 1033 | |
| 1034 | static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) |
| 1035 | { |
| 1036 | struct tuner *t = to_tuner(sd); |
| 1037 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
| 1038 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; |
| 1039 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1040 | if (check_mode(t, vt->type) == -EINVAL) |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1041 | return 0; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1042 | vt->type = t->mode; |
| 1043 | if (analog_ops->get_afc) |
| 1044 | vt->afc = analog_ops->get_afc(&t->fe); |
| 1045 | if (t->mode == V4L2_TUNER_ANALOG_TV) |
| 1046 | vt->capability |= V4L2_TUNER_CAP_NORM; |
| 1047 | if (t->mode != V4L2_TUNER_RADIO) { |
| 1048 | vt->rangelow = tv_range[0] * 16; |
| 1049 | vt->rangehigh = tv_range[1] * 16; |
| 1050 | return 0; |
| 1051 | } |
| 1052 | |
| 1053 | /* radio mode */ |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1054 | vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1055 | if (fe_tuner_ops->get_status) { |
| 1056 | u32 tuner_status; |
| 1057 | |
| 1058 | fe_tuner_ops->get_status(&t->fe, &tuner_status); |
| 1059 | vt->rxsubchans = |
| 1060 | (tuner_status & TUNER_STATUS_STEREO) ? |
| 1061 | V4L2_TUNER_SUB_STEREO : |
| 1062 | V4L2_TUNER_SUB_MONO; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1063 | } |
| 1064 | if (analog_ops->has_signal) |
| 1065 | vt->signal = analog_ops->has_signal(&t->fe); |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1066 | vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1067 | vt->audmode = t->audmode; |
| 1068 | vt->rangelow = radio_range[0] * 16000; |
| 1069 | vt->rangehigh = radio_range[1] * 16000; |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1070 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1071 | return 0; |
| 1072 | } |
| 1073 | |
| 1074 | static int tuner_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) |
| 1075 | { |
| 1076 | struct tuner *t = to_tuner(sd); |
| 1077 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
| 1078 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1079 | if (set_mode_freq(client, t, vt->type, 0) == -EINVAL) |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1080 | return 0; |
| 1081 | |
Mauro Carvalho Chehab | cbde689 | 2011-02-04 10:42:09 -0300 | [diff] [blame] | 1082 | if (t->mode == V4L2_TUNER_RADIO) |
| 1083 | t->audmode = vt->audmode; |
| 1084 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1085 | return 0; |
| 1086 | } |
| 1087 | |
| 1088 | static int tuner_log_status(struct v4l2_subdev *sd) |
| 1089 | { |
| 1090 | struct tuner *t = to_tuner(sd); |
| 1091 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
| 1092 | |
| 1093 | if (analog_ops->tuner_status) |
| 1094 | analog_ops->tuner_status(&t->fe); |
| 1095 | return 0; |
| 1096 | } |
| 1097 | |
Jean Delvare | 21b48a7 | 2007-03-12 19:20:15 -0300 | [diff] [blame] | 1098 | static int tuner_suspend(struct i2c_client *c, pm_message_t state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | { |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1100 | struct tuner *t = to_tuner(i2c_get_clientdata(c)); |
Mauro Carvalho Chehab | e2f63d9 | 2011-02-04 11:15:21 -0300 | [diff] [blame] | 1101 | struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | |
Hans Verkuil | 9dd659d | 2007-11-04 11:03:36 -0300 | [diff] [blame] | 1103 | tuner_dbg("suspend\n"); |
Mauro Carvalho Chehab | e2f63d9 | 2011-02-04 11:15:21 -0300 | [diff] [blame] | 1104 | |
| 1105 | if (!t->standby && analog_ops->standby) |
| 1106 | analog_ops->standby(&t->fe); |
| 1107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | return 0; |
| 1109 | } |
| 1110 | |
Jean Delvare | 21b48a7 | 2007-03-12 19:20:15 -0300 | [diff] [blame] | 1111 | static int tuner_resume(struct i2c_client *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | { |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1113 | struct tuner *t = to_tuner(i2c_get_clientdata(c)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
Hans Verkuil | 9dd659d | 2007-11-04 11:03:36 -0300 | [diff] [blame] | 1115 | tuner_dbg("resume\n"); |
Mauro Carvalho Chehab | e2f63d9 | 2011-02-04 11:15:21 -0300 | [diff] [blame] | 1116 | |
| 1117 | if (!t->standby) |
| 1118 | set_mode_freq(c, t, t->type, 0); |
| 1119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | return 0; |
| 1121 | } |
| 1122 | |
Hans Verkuil | 75b4c26 | 2009-04-01 03:32:22 -0300 | [diff] [blame] | 1123 | static int tuner_command(struct i2c_client *client, unsigned cmd, void *arg) |
| 1124 | { |
| 1125 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
| 1126 | |
| 1127 | /* TUNER_SET_CONFIG is still called by tuner-simple.c, so we have |
| 1128 | to handle it here. |
| 1129 | There must be a better way of doing this... */ |
| 1130 | switch (cmd) { |
| 1131 | case TUNER_SET_CONFIG: |
| 1132 | return tuner_s_config(sd, arg); |
| 1133 | } |
| 1134 | return -ENOIOCTLCMD; |
| 1135 | } |
| 1136 | |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1137 | /* ----------------------------------------------------------------------- */ |
| 1138 | |
| 1139 | static const struct v4l2_subdev_core_ops tuner_core_ops = { |
| 1140 | .log_status = tuner_log_status, |
Hans Verkuil | f41737e | 2009-04-01 03:52:39 -0300 | [diff] [blame] | 1141 | .s_std = tuner_s_std, |
Laurent Pinchart | 622b828 | 2009-10-05 10:48:17 -0300 | [diff] [blame] | 1142 | .s_power = tuner_s_power, |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1143 | }; |
| 1144 | |
| 1145 | static const struct v4l2_subdev_tuner_ops tuner_tuner_ops = { |
Hans Verkuil | e8a4a9e | 2008-11-24 18:21:40 -0300 | [diff] [blame] | 1146 | .s_radio = tuner_s_radio, |
| 1147 | .g_tuner = tuner_g_tuner, |
| 1148 | .s_tuner = tuner_s_tuner, |
| 1149 | .s_frequency = tuner_s_frequency, |
| 1150 | .g_frequency = tuner_g_frequency, |
| 1151 | .s_type_addr = tuner_s_type_addr, |
| 1152 | .s_config = tuner_s_config, |
| 1153 | }; |
| 1154 | |
| 1155 | static const struct v4l2_subdev_ops tuner_ops = { |
| 1156 | .core = &tuner_core_ops, |
| 1157 | .tuner = &tuner_tuner_ops, |
| 1158 | }; |
| 1159 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | /* ----------------------------------------------------------------------- */ |
| 1161 | |
Jean Delvare | af29486 | 2008-05-18 20:49:40 +0200 | [diff] [blame] | 1162 | /* This driver supports many devices and the idea is to let the driver |
| 1163 | detect which device is present. So rather than listing all supported |
| 1164 | devices here, we pretend to support a single, fake device type. */ |
| 1165 | static const struct i2c_device_id tuner_id[] = { |
| 1166 | { "tuner", }, /* autodetect */ |
| 1167 | { } |
| 1168 | }; |
| 1169 | MODULE_DEVICE_TABLE(i2c, tuner_id); |
| 1170 | |
Hans Verkuil | 02a2098 | 2010-09-15 15:36:23 -0300 | [diff] [blame] | 1171 | static struct i2c_driver tuner_driver = { |
| 1172 | .driver = { |
| 1173 | .owner = THIS_MODULE, |
| 1174 | .name = "tuner", |
| 1175 | }, |
| 1176 | .probe = tuner_probe, |
| 1177 | .remove = tuner_remove, |
| 1178 | .command = tuner_command, |
| 1179 | .suspend = tuner_suspend, |
| 1180 | .resume = tuner_resume, |
| 1181 | .id_table = tuner_id, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | }; |
| 1183 | |
Hans Verkuil | 02a2098 | 2010-09-15 15:36:23 -0300 | [diff] [blame] | 1184 | static __init int init_tuner(void) |
| 1185 | { |
| 1186 | return i2c_add_driver(&tuner_driver); |
| 1187 | } |
| 1188 | |
| 1189 | static __exit void exit_tuner(void) |
| 1190 | { |
| 1191 | i2c_del_driver(&tuner_driver); |
| 1192 | } |
| 1193 | |
| 1194 | module_init(init_tuner); |
| 1195 | module_exit(exit_tuner); |
| 1196 | |
Mauro Carvalho Chehab | 9f3f71e | 2011-02-03 23:32:07 -0300 | [diff] [blame] | 1197 | MODULE_DESCRIPTION("device driver for various TV and TV+FM radio tuners"); |
| 1198 | MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer"); |
| 1199 | MODULE_LICENSE("GPL"); |