Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 1 | /* tuner-xc2028 |
| 2 | * |
| 3 | * Copyright (c) 2007 Mauro Carvalho Chehab (mchehab@infradead.org) |
Mauro Carvalho Chehab | 983d214 | 2007-10-29 23:44:18 -0300 | [diff] [blame] | 4 | * |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 5 | * Copyright (c) 2007 Michel Ludwig (michel.ludwig@gmail.com) |
| 6 | * - frontend interface |
Mauro Carvalho Chehab | 983d214 | 2007-10-29 23:44:18 -0300 | [diff] [blame] | 7 | * |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 8 | * This code is placed under the terms of the GNU General Public License v2 |
| 9 | */ |
| 10 | |
| 11 | #include <linux/i2c.h> |
| 12 | #include <asm/div64.h> |
| 13 | #include <linux/firmware.h> |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 14 | #include <linux/videodev2.h> |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 15 | #include <linux/delay.h> |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 16 | #include <media/tuner.h> |
Mauro Carvalho Chehab | 3b20532 | 2007-09-27 18:27:03 -0300 | [diff] [blame] | 17 | #include <linux/mutex.h> |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 18 | #include "tuner-i2c.h" |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 19 | #include "tuner-xc2028.h" |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 20 | #include "tuner-xc2028-types.h" |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 21 | |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 22 | #include <linux/dvb/frontend.h> |
| 23 | #include "dvb_frontend.h" |
| 24 | |
Mauro Carvalho Chehab | ef8c188 | 2007-11-16 16:28:21 -0300 | [diff] [blame] | 25 | |
Hans Verkuil | 9dd659d | 2007-11-04 11:03:36 -0300 | [diff] [blame] | 26 | #define PREFIX "xc2028" |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 27 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 28 | static int debug; |
| 29 | module_param(debug, int, 0644); |
| 30 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 31 | |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 32 | static char audio_std[8]; |
| 33 | module_param_string(audio_std, audio_std, sizeof(audio_std), 0); |
| 34 | MODULE_PARM_DESC(audio_std, |
| 35 | "Audio standard. XC3028 audio decoder explicitly " |
| 36 | "needs to know what audio\n" |
| 37 | "standard is needed for some video standards with audio A2 or NICAM.\n" |
| 38 | "The valid values are:\n" |
| 39 | "A2\n" |
| 40 | "A2/A\n" |
| 41 | "A2/B\n" |
| 42 | "NICAM\n" |
| 43 | "NICAM/A\n" |
| 44 | "NICAM/B\n"); |
| 45 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 46 | static LIST_HEAD(xc2028_list); |
Chris Pascoe | aa501be | 2007-11-19 04:45:38 -0300 | [diff] [blame] | 47 | static DEFINE_MUTEX(xc2028_list_mutex); |
| 48 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 49 | /* struct for storing firmware table */ |
| 50 | struct firmware_description { |
| 51 | unsigned int type; |
| 52 | v4l2_std_id id; |
| 53 | unsigned char *ptr; |
| 54 | unsigned int size; |
| 55 | }; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 56 | |
| 57 | struct xc2028_data { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 58 | struct list_head xc2028_list; |
| 59 | struct tuner_i2c_props i2c_props; |
| 60 | int (*tuner_callback) (void *dev, |
| 61 | int command, int arg); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 62 | void *video_dev; |
| 63 | int count; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 64 | __u32 frequency; |
| 65 | |
| 66 | struct firmware_description *firm; |
| 67 | int firm_size; |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 68 | __u16 firm_version; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 69 | |
| 70 | struct xc2028_ctrl ctrl; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 71 | |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 72 | v4l2_std_id firm_type; /* video stds supported |
| 73 | by current firmware */ |
| 74 | fe_bandwidth_t bandwidth; /* Firmware bandwidth: |
| 75 | 6M, 7M or 8M */ |
| 76 | int need_load_generic; /* The generic firmware |
| 77 | were loaded? */ |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 78 | |
| 79 | int max_len; /* Max firmware chunk */ |
| 80 | |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 81 | enum tuner_mode mode; |
| 82 | struct i2c_client *i2c_client; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 83 | |
| 84 | struct mutex lock; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 85 | }; |
| 86 | |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 87 | #define i2c_send(priv, buf, size) ({ \ |
| 88 | int _rc; \ |
| 89 | _rc = tuner_i2c_xfer_send(&priv->i2c_props, buf, size); \ |
| 90 | if (size != _rc) \ |
| 91 | tuner_info("i2c output error: rc = %d (should be %d)\n",\ |
| 92 | _rc, (int)size); \ |
| 93 | _rc; \ |
| 94 | }) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 95 | |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 96 | #define i2c_rcv(priv, buf, size) ({ \ |
| 97 | int _rc; \ |
| 98 | _rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size); \ |
| 99 | if (size != _rc) \ |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 100 | tuner_err("i2c input error: rc = %d (should be %d)\n", \ |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 101 | _rc, (int)size); \ |
| 102 | _rc; \ |
| 103 | }) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 104 | |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 105 | #define i2c_send_recv(priv, obuf, osize, ibuf, isize) ({ \ |
| 106 | int _rc; \ |
| 107 | _rc = tuner_i2c_xfer_send_recv(&priv->i2c_props, obuf, osize, \ |
| 108 | ibuf, isize); \ |
| 109 | if (isize != _rc) \ |
| 110 | tuner_err("i2c input error: rc = %d (should be %d)\n", \ |
| 111 | _rc, (int)isize); \ |
| 112 | _rc; \ |
| 113 | }) |
| 114 | |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 115 | #define send_seq(priv, data...) ({ \ |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 116 | static u8 _val[] = data; \ |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 117 | int _rc; \ |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 118 | if (sizeof(_val) != \ |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 119 | (_rc = tuner_i2c_xfer_send(&priv->i2c_props, \ |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 120 | _val, sizeof(_val)))) { \ |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 121 | tuner_err("Error on line %d: %d\n", __LINE__, _rc); \ |
| 122 | } else \ |
| 123 | msleep(10); \ |
| 124 | _rc; \ |
| 125 | }) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 126 | |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 127 | static unsigned int xc2028_get_reg(struct xc2028_data *priv, u16 reg, u16 *val) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 128 | { |
Mauro Carvalho Chehab | b873e1a | 2007-11-05 08:41:50 -0300 | [diff] [blame] | 129 | unsigned char buf[2]; |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 130 | unsigned char ibuf[2]; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 131 | |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 132 | tuner_dbg("%s %04x called\n", __FUNCTION__, reg); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 133 | |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 134 | buf[0] = reg >> 8; |
Mauro Carvalho Chehab | 80b5220 | 2007-11-05 09:07:13 -0300 | [diff] [blame] | 135 | buf[1] = (unsigned char) reg; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 136 | |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 137 | if (i2c_send_recv(priv, buf, 2, ibuf, 2) != 2) |
| 138 | return -EIO; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 139 | |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 140 | *val = (ibuf[1]) | (ibuf[0] << 8); |
| 141 | return 0; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 142 | } |
| 143 | |
Mauro Carvalho Chehab | 43efe70 | 2007-11-14 19:30:28 -0300 | [diff] [blame] | 144 | void dump_firm_type(unsigned int type) |
| 145 | { |
| 146 | if (type & BASE) |
| 147 | printk("BASE "); |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 148 | if (type & INIT1) |
| 149 | printk("INIT1 "); |
Mauro Carvalho Chehab | 43efe70 | 2007-11-14 19:30:28 -0300 | [diff] [blame] | 150 | if (type & F8MHZ) |
| 151 | printk("F8MHZ "); |
| 152 | if (type & MTS) |
| 153 | printk("MTS "); |
| 154 | if (type & D2620) |
| 155 | printk("D2620 "); |
| 156 | if (type & D2633) |
| 157 | printk("D2633 "); |
| 158 | if (type & DTV6) |
| 159 | printk("DTV6 "); |
| 160 | if (type & QAM) |
| 161 | printk("QAM "); |
| 162 | if (type & DTV7) |
| 163 | printk("DTV7 "); |
| 164 | if (type & DTV78) |
| 165 | printk("DTV78 "); |
| 166 | if (type & DTV8) |
| 167 | printk("DTV8 "); |
| 168 | if (type & FM) |
| 169 | printk("FM "); |
| 170 | if (type & INPUT1) |
| 171 | printk("INPUT1 "); |
| 172 | if (type & LCD) |
| 173 | printk("LCD "); |
| 174 | if (type & NOGD) |
| 175 | printk("NOGD "); |
| 176 | if (type & MONO) |
| 177 | printk("MONO "); |
| 178 | if (type & ATSC) |
| 179 | printk("ATSC "); |
| 180 | if (type & IF) |
| 181 | printk("IF "); |
| 182 | if (type & LG60) |
| 183 | printk("LG60 "); |
| 184 | if (type & ATI638) |
| 185 | printk("ATI638 "); |
| 186 | if (type & OREN538) |
| 187 | printk("OREN538 "); |
| 188 | if (type & OREN36) |
| 189 | printk("OREN36 "); |
| 190 | if (type & TOYOTA388) |
| 191 | printk("TOYOTA388 "); |
| 192 | if (type & TOYOTA794) |
| 193 | printk("TOYOTA794 "); |
| 194 | if (type & DIBCOM52) |
| 195 | printk("DIBCOM52 "); |
| 196 | if (type & ZARLINK456) |
| 197 | printk("ZARLINK456 "); |
| 198 | if (type & CHINA) |
| 199 | printk("CHINA "); |
| 200 | if (type & F6MHZ) |
| 201 | printk("F6MHZ "); |
| 202 | if (type & INPUT2) |
| 203 | printk("INPUT2 "); |
| 204 | if (type & SCODE) |
| 205 | printk("SCODE "); |
| 206 | } |
| 207 | |
Mauro Carvalho Chehab | ef8c188 | 2007-11-16 16:28:21 -0300 | [diff] [blame] | 208 | static v4l2_std_id parse_audio_std_option(void) |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 209 | { |
Chris Pascoe | e155d90 | 2007-11-19 04:16:47 -0300 | [diff] [blame] | 210 | if (strcasecmp(audio_std, "A2") == 0) |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 211 | return V4L2_STD_A2; |
Chris Pascoe | e155d90 | 2007-11-19 04:16:47 -0300 | [diff] [blame] | 212 | if (strcasecmp(audio_std, "A2/A") == 0) |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 213 | return V4L2_STD_A2_A; |
Chris Pascoe | e155d90 | 2007-11-19 04:16:47 -0300 | [diff] [blame] | 214 | if (strcasecmp(audio_std, "A2/B") == 0) |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 215 | return V4L2_STD_A2_B; |
Chris Pascoe | e155d90 | 2007-11-19 04:16:47 -0300 | [diff] [blame] | 216 | if (strcasecmp(audio_std, "NICAM") == 0) |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 217 | return V4L2_STD_NICAM; |
Chris Pascoe | e155d90 | 2007-11-19 04:16:47 -0300 | [diff] [blame] | 218 | if (strcasecmp(audio_std, "NICAM/A") == 0) |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 219 | return V4L2_STD_NICAM_A; |
Chris Pascoe | e155d90 | 2007-11-19 04:16:47 -0300 | [diff] [blame] | 220 | if (strcasecmp(audio_std, "NICAM/B") == 0) |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 221 | return V4L2_STD_NICAM_B; |
| 222 | |
| 223 | return 0; |
| 224 | } |
| 225 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 226 | static void free_firmware(struct xc2028_data *priv) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 227 | { |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 228 | int i; |
| 229 | |
| 230 | if (!priv->firm) |
| 231 | return; |
| 232 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 233 | for (i = 0; i < priv->firm_size; i++) |
| 234 | kfree(priv->firm[i].ptr); |
| 235 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 236 | kfree(priv->firm); |
| 237 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 238 | priv->firm = NULL; |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 239 | priv->firm_size = 0; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 240 | priv->need_load_generic = 1; |
| 241 | } |
| 242 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 243 | static int load_all_firmwares(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 244 | { |
| 245 | struct xc2028_data *priv = fe->tuner_priv; |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 246 | const struct firmware *fw = NULL; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 247 | unsigned char *p, *endp; |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 248 | int rc = 0; |
| 249 | int n, n_array; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 250 | char name[33]; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 251 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 252 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 253 | |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 254 | tuner_dbg("Reading firmware %s\n", priv->ctrl.fname); |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 255 | rc = request_firmware(&fw, priv->ctrl.fname, |
| 256 | &priv->i2c_props.adap->dev); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 257 | if (rc < 0) { |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 258 | if (rc == -ENOENT) |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 259 | tuner_err("Error: firmware %s not found.\n", |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 260 | priv->ctrl.fname); |
Mauro Carvalho Chehab | 2e4160c | 2007-07-18 13:33:23 -0300 | [diff] [blame] | 261 | else |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 262 | tuner_err("Error %d while requesting firmware %s \n", |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 263 | rc, priv->ctrl.fname); |
Mauro Carvalho Chehab | 2e4160c | 2007-07-18 13:33:23 -0300 | [diff] [blame] | 264 | |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 265 | return rc; |
| 266 | } |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 267 | p = fw->data; |
| 268 | endp = p + fw->size; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 269 | |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 270 | if (fw->size < sizeof(name) - 1 + 2 + 2) { |
| 271 | tuner_err("Error: firmware file %s has invalid size!\n", |
| 272 | priv->ctrl.fname); |
| 273 | goto corrupt; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 274 | } |
| 275 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 276 | memcpy(name, p, sizeof(name) - 1); |
| 277 | name[sizeof(name) - 1] = 0; |
| 278 | p += sizeof(name) - 1; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 279 | |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 280 | priv->firm_version = le16_to_cpu(*(__u16 *) p); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 281 | p += 2; |
| 282 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 283 | n_array = le16_to_cpu(*(__u16 *) p); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 284 | p += 2; |
| 285 | |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 286 | tuner_info("Loading %d firmware images from %s, type: %s, ver %d.%d\n", |
| 287 | n_array, priv->ctrl.fname, name, |
| 288 | priv->firm_version >> 8, priv->firm_version & 0xff); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 289 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 290 | priv->firm = kzalloc(sizeof(*priv->firm) * n_array, GFP_KERNEL); |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 291 | if (priv->firm == NULL) { |
| 292 | tuner_err("Not enough memory to load firmware file.\n"); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 293 | rc = -ENOMEM; |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 294 | goto err; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 295 | } |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 296 | priv->firm_size = n_array; |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 297 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 298 | n = -1; |
| 299 | while (p < endp) { |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 300 | __u32 type, size; |
| 301 | v4l2_std_id id; |
| 302 | |
| 303 | n++; |
| 304 | if (n >= n_array) { |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 305 | tuner_err("More firmware images in file than " |
| 306 | "were expected!\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 307 | goto corrupt; |
| 308 | } |
| 309 | |
| 310 | /* Checks if there's enough bytes to read */ |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 311 | if (p + sizeof(type) + sizeof(id) + sizeof(size) > endp) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 312 | tuner_err("Firmware header is incomplete!\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 313 | goto corrupt; |
| 314 | } |
| 315 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 316 | type = le32_to_cpu(*(__u32 *) p); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 317 | p += sizeof(type); |
| 318 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 319 | id = le64_to_cpu(*(v4l2_std_id *) p); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 320 | p += sizeof(id); |
| 321 | |
Michel Ludwig | 2fc580f | 2007-11-16 07:19:35 -0300 | [diff] [blame] | 322 | size = le32_to_cpu(*(__u32 *) p); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 323 | p += sizeof(size); |
| 324 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 325 | if ((!size) || (size + p > endp)) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 326 | tuner_err("Firmware type "); |
Mauro Carvalho Chehab | 43efe70 | 2007-11-14 19:30:28 -0300 | [diff] [blame] | 327 | dump_firm_type(type); |
Mauro Carvalho Chehab | ef8c188 | 2007-11-16 16:28:21 -0300 | [diff] [blame] | 328 | printk("(%x), id %llx is corrupted " |
| 329 | "(size=%d, expected %d)\n", |
Chris Pascoe | 91240dd | 2007-11-19 04:38:53 -0300 | [diff] [blame] | 330 | type, (unsigned long long)id, |
Mauro Carvalho Chehab | ef8c188 | 2007-11-16 16:28:21 -0300 | [diff] [blame] | 331 | (unsigned)(endp - p), size); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 332 | goto corrupt; |
| 333 | } |
| 334 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 335 | priv->firm[n].ptr = kzalloc(size, GFP_KERNEL); |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 336 | if (priv->firm[n].ptr == NULL) { |
| 337 | tuner_err("Not enough memory to load firmware file.\n"); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 338 | rc = -ENOMEM; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 339 | goto err; |
| 340 | } |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 341 | tuner_dbg("Reading firmware type "); |
| 342 | if (debug) { |
| 343 | dump_firm_type(type); |
| 344 | printk("(%x), id %llx, size=%d.\n", |
| 345 | type, (unsigned long long)id, size); |
| 346 | } |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 347 | |
| 348 | memcpy(priv->firm[n].ptr, p, size); |
| 349 | priv->firm[n].type = type; |
| 350 | priv->firm[n].id = id; |
| 351 | priv->firm[n].size = size; |
| 352 | |
| 353 | p += size; |
| 354 | } |
| 355 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 356 | if (n + 1 != priv->firm_size) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 357 | tuner_err("Firmware file is incomplete!\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 358 | goto corrupt; |
| 359 | } |
| 360 | |
| 361 | goto done; |
| 362 | |
| 363 | corrupt: |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 364 | rc = -EINVAL; |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 365 | tuner_err("Error: firmware file is corrupted!\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 366 | |
| 367 | err: |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 368 | tuner_info("Releasing partially loaded firmware file.\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 369 | free_firmware(priv); |
| 370 | |
| 371 | done: |
| 372 | release_firmware(fw); |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 373 | if (rc == 0) |
| 374 | tuner_dbg("Firmware files loaded.\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 375 | |
| 376 | return rc; |
| 377 | } |
| 378 | |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 379 | static int seek_firmware(struct dvb_frontend *fe, unsigned int type, |
| 380 | v4l2_std_id *id) |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 381 | { |
| 382 | struct xc2028_data *priv = fe->tuner_priv; |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 383 | int i; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 384 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 385 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 386 | |
| 387 | if (!priv->firm) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 388 | tuner_err("Error! firmware not loaded\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 389 | return -EINVAL; |
| 390 | } |
| 391 | |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 392 | if (((type & ~SCODE) == 0) && (*id == 0)) |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 393 | *id = V4L2_STD_PAL; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 394 | |
| 395 | /* Seek for exact match */ |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 396 | for (i = 0; i < priv->firm_size; i++) { |
| 397 | if ((type == priv->firm[i].type) && (*id == priv->firm[i].id)) |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 398 | goto found; |
| 399 | } |
| 400 | |
| 401 | /* Seek for generic video standard match */ |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 402 | for (i = 0; i < priv->firm_size; i++) { |
| 403 | if ((type == priv->firm[i].type) && (*id & priv->firm[i].id)) |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 404 | goto found; |
| 405 | } |
| 406 | |
| 407 | /*FIXME: Would make sense to seek for type "hint" match ? */ |
| 408 | |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 409 | i = -EINVAL; |
| 410 | goto ret; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 411 | |
| 412 | found: |
| 413 | *id = priv->firm[i].id; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 414 | |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 415 | ret: |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 416 | tuner_dbg("%s firmware for type=", (i < 0)? "Can't find": "Found"); |
| 417 | if (debug) { |
| 418 | dump_firm_type(type); |
Chris Pascoe | 91240dd | 2007-11-19 04:38:53 -0300 | [diff] [blame] | 419 | printk("(%x), id %016llx.\n", type, (unsigned long long)*id); |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 420 | } |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 421 | return i; |
| 422 | } |
| 423 | |
| 424 | static int load_firmware(struct dvb_frontend *fe, unsigned int type, |
| 425 | v4l2_std_id *id) |
| 426 | { |
| 427 | struct xc2028_data *priv = fe->tuner_priv; |
| 428 | int pos, rc; |
| 429 | unsigned char *p, *endp, buf[priv->max_len]; |
| 430 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 431 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 432 | |
| 433 | pos = seek_firmware(fe, type, id); |
| 434 | if (pos < 0) |
| 435 | return pos; |
| 436 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 437 | tuner_info("Loading firmware for type="); |
| 438 | dump_firm_type(type); |
Chris Pascoe | 91240dd | 2007-11-19 04:38:53 -0300 | [diff] [blame] | 439 | printk("(%x), id %016llx.\n", type, (unsigned long long)*id); |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 440 | |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 441 | p = priv->firm[pos].ptr; |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 442 | endp = p + priv->firm[pos].size; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 443 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 444 | while (p < endp) { |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 445 | __u16 size; |
| 446 | |
| 447 | /* Checks if there's enough bytes to read */ |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 448 | if (p + sizeof(size) > endp) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 449 | tuner_err("Firmware chunk size is wrong\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 450 | return -EINVAL; |
| 451 | } |
| 452 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 453 | size = le16_to_cpu(*(__u16 *) p); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 454 | p += sizeof(size); |
| 455 | |
| 456 | if (size == 0xffff) |
| 457 | return 0; |
| 458 | |
| 459 | if (!size) { |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 460 | /* Special callback command received */ |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 461 | rc = priv->tuner_callback(priv->video_dev, |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 462 | XC2028_TUNER_RESET, 0); |
| 463 | if (rc < 0) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 464 | tuner_err("Error at RESET code %d\n", |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 465 | (*p) & 0x7f); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 466 | return -EINVAL; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 467 | } |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 468 | continue; |
| 469 | } |
Michel Ludwig | 5403bba | 2007-11-16 07:49:49 -0300 | [diff] [blame] | 470 | if (size >= 0xff00) { |
| 471 | switch (size) { |
| 472 | case 0xff00: |
| 473 | rc = priv->tuner_callback(priv->video_dev, |
| 474 | XC2028_RESET_CLK, 0); |
| 475 | if (rc < 0) { |
| 476 | tuner_err("Error at RESET code %d\n", |
| 477 | (*p) & 0x7f); |
| 478 | return -EINVAL; |
| 479 | } |
Chris Pascoe | b32f9fb | 2007-11-19 04:53:50 -0300 | [diff] [blame] | 480 | break; |
Michel Ludwig | 5403bba | 2007-11-16 07:49:49 -0300 | [diff] [blame] | 481 | default: |
| 482 | tuner_info("Invalid RESET code %d\n", |
| 483 | size & 0x7f); |
| 484 | return -EINVAL; |
| 485 | |
| 486 | } |
Mauro Carvalho Chehab | 2d4c0ac | 2007-11-16 09:43:19 -0300 | [diff] [blame] | 487 | continue; |
Michel Ludwig | 5403bba | 2007-11-16 07:49:49 -0300 | [diff] [blame] | 488 | } |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 489 | |
| 490 | /* Checks for a sleep command */ |
| 491 | if (size & 0x8000) { |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 492 | msleep(size & 0x7fff); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 493 | continue; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 494 | } |
| 495 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 496 | if ((size + p > endp)) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 497 | tuner_err("missing bytes: need %d, have %d\n", |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 498 | size, (int)(endp - p)); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 499 | return -EINVAL; |
| 500 | } |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 501 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 502 | buf[0] = *p; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 503 | p++; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 504 | size--; |
| 505 | |
| 506 | /* Sends message chunks */ |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 507 | while (size > 0) { |
| 508 | int len = (size < priv->max_len - 1) ? |
| 509 | size : priv->max_len - 1; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 510 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 511 | memcpy(buf + 1, p, len); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 512 | |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 513 | rc = i2c_send(priv, buf, len + 1); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 514 | if (rc < 0) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 515 | tuner_err("%d returned from send\n", rc); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 516 | return -EINVAL; |
| 517 | } |
| 518 | |
| 519 | p += len; |
| 520 | size -= len; |
| 521 | } |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 522 | } |
Mauro Carvalho Chehab | 43efe70 | 2007-11-14 19:30:28 -0300 | [diff] [blame] | 523 | return 0; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 524 | } |
| 525 | |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 526 | static int load_scode(struct dvb_frontend *fe, unsigned int type, |
| 527 | v4l2_std_id *id, int scode) |
| 528 | { |
| 529 | struct xc2028_data *priv = fe->tuner_priv; |
| 530 | int pos, rc; |
| 531 | unsigned char *p; |
| 532 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 533 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 534 | |
| 535 | pos = seek_firmware(fe, type, id); |
| 536 | if (pos < 0) |
| 537 | return pos; |
| 538 | |
| 539 | p = priv->firm[pos].ptr; |
| 540 | |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 541 | if ((priv->firm[pos].size != 12 * 16) || (scode >= 16)) |
| 542 | return -EINVAL; |
| 543 | |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 544 | if (priv->firm_version < 0x0202) |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 545 | rc = send_seq(priv, {0x20, 0x00, 0x00, 0x00}); |
| 546 | else |
| 547 | rc = send_seq(priv, {0xa0, 0x00, 0x00, 0x00}); |
| 548 | if (rc < 0) |
| 549 | return -EIO; |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 550 | |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 551 | rc = i2c_send(priv, p + 12 * scode, 12); |
| 552 | if (rc < 0) |
| 553 | return -EIO; |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 554 | |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 555 | rc = send_seq(priv, {0x00, 0x8c}); |
| 556 | if (rc < 0) |
| 557 | return -EIO; |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 558 | |
| 559 | return 0; |
| 560 | } |
| 561 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 562 | static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode, |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 563 | v4l2_std_id std, fe_bandwidth_t bandwidth) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 564 | { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 565 | struct xc2028_data *priv = fe->tuner_priv; |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 566 | int rc; |
| 567 | u16 version, hwmodel; |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 568 | v4l2_std_id std0 = 0; |
| 569 | unsigned int type0 = 0, type = 0; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 570 | int change_digital_bandwidth; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 571 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 572 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 573 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 574 | if (!priv->firm) { |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 575 | if (!priv->ctrl.fname) { |
| 576 | tuner_info("xc2028/3028 firmware name not set!\n"); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 577 | return -EINVAL; |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 578 | } |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 579 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 580 | rc = load_all_firmwares(fe); |
| 581 | if (rc < 0) |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 582 | return rc; |
| 583 | } |
| 584 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 585 | tuner_dbg("I am in mode %u and I should switch to mode %i\n", |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 586 | priv->mode, new_mode); |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 587 | |
| 588 | /* first of all, determine whether we have switched the mode */ |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 589 | if (new_mode != priv->mode) { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 590 | priv->mode = new_mode; |
| 591 | priv->need_load_generic = 1; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 592 | } |
| 593 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 594 | change_digital_bandwidth = (priv->mode == T_DIGITAL_TV |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 595 | && bandwidth != priv->bandwidth) ? 1 : 0; |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 596 | tuner_dbg("old bandwidth %u, new bandwidth %u\n", priv->bandwidth, |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 597 | bandwidth); |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 598 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 599 | if (priv->need_load_generic) { |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 600 | /* Reset is needed before loading firmware */ |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 601 | rc = priv->tuner_callback(priv->video_dev, |
| 602 | XC2028_TUNER_RESET, 0); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 603 | if (rc < 0) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 604 | return rc; |
| 605 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 606 | type0 = BASE; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 607 | |
| 608 | if (priv->ctrl.type == XC2028_FIRM_MTS) |
| 609 | type0 |= MTS; |
| 610 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 611 | if (priv->bandwidth == 8) |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 612 | type0 |= F8MHZ; |
| 613 | |
| 614 | /* FIXME: How to load FM and FM|INPUT1 firmwares? */ |
| 615 | |
| 616 | rc = load_firmware(fe, type0, &std0); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 617 | if (rc < 0) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 618 | tuner_err("Error %d while loading generic firmware\n", |
| 619 | rc); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 620 | return rc; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 621 | } |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 622 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 623 | priv->need_load_generic = 0; |
| 624 | priv->firm_type = 0; |
| 625 | if (priv->mode == T_DIGITAL_TV) |
| 626 | change_digital_bandwidth = 1; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 627 | } |
| 628 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 629 | tuner_dbg("I should change bandwidth %u\n", change_digital_bandwidth); |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 630 | |
| 631 | if (change_digital_bandwidth) { |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 632 | |
| 633 | /*FIXME: Should allow selecting between D2620 and D2633 */ |
| 634 | type |= D2620; |
| 635 | |
| 636 | /* FIXME: When should select a DTV78 firmware? |
| 637 | */ |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 638 | switch (bandwidth) { |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 639 | case BANDWIDTH_8_MHZ: |
| 640 | type |= DTV8; |
| 641 | break; |
| 642 | case BANDWIDTH_7_MHZ: |
| 643 | type |= DTV7; |
| 644 | break; |
| 645 | case BANDWIDTH_6_MHZ: |
| 646 | /* FIXME: Should allow select also ATSC */ |
Mauro Carvalho Chehab | 43efe70 | 2007-11-14 19:30:28 -0300 | [diff] [blame] | 647 | type |= DTV6 | QAM; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 648 | break; |
| 649 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 650 | default: |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 651 | tuner_err("error: bandwidth not supported.\n"); |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 652 | }; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 653 | priv->bandwidth = bandwidth; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 654 | } |
| 655 | |
Michel Ludwig | 5403bba | 2007-11-16 07:49:49 -0300 | [diff] [blame] | 656 | if (!change_digital_bandwidth && priv->mode == T_DIGITAL_TV) |
| 657 | return 0; |
| 658 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 659 | /* Load INIT1, if needed */ |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 660 | tuner_dbg("Load init1 firmware, if exists\n"); |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 661 | type0 = BASE | INIT1; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 662 | if (priv->ctrl.type == XC2028_FIRM_MTS) |
| 663 | type0 |= MTS; |
| 664 | |
| 665 | /* FIXME: Should handle errors - if INIT1 found */ |
| 666 | rc = load_firmware(fe, type0, &std0); |
| 667 | |
| 668 | /* FIXME: Should add support for FM radio |
| 669 | */ |
| 670 | |
| 671 | if (priv->ctrl.type == XC2028_FIRM_MTS) |
| 672 | type |= MTS; |
| 673 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 674 | if (priv->firm_type & std) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 675 | tuner_dbg("Std-specific firmware already loaded.\n"); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 676 | return 0; |
Mauro Carvalho Chehab | 2e4160c | 2007-07-18 13:33:23 -0300 | [diff] [blame] | 677 | } |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 678 | |
Mauro Carvalho Chehab | a82200f | 2007-11-15 11:58:00 -0300 | [diff] [blame] | 679 | /* Add audio hack to std mask */ |
| 680 | std |= parse_audio_std_option(); |
| 681 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 682 | rc = load_firmware(fe, type, &std); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 683 | if (rc < 0) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 684 | return rc; |
| 685 | |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 686 | /* Load SCODE firmware, if exists */ |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 687 | tuner_dbg("Trying to load scode 0\n"); |
Mauro Carvalho Chehab | f380e1d | 2007-11-15 08:43:53 -0300 | [diff] [blame] | 688 | type |= SCODE; |
| 689 | |
| 690 | rc = load_scode(fe, type, &std, 0); |
Mauro Carvalho Chehab | 43efe70 | 2007-11-14 19:30:28 -0300 | [diff] [blame] | 691 | |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 692 | xc2028_get_reg(priv, 0x0004, &version); |
| 693 | xc2028_get_reg(priv, 0x0008, &hwmodel); |
Mauro Carvalho Chehab | 80b5220 | 2007-11-05 09:07:13 -0300 | [diff] [blame] | 694 | |
| 695 | tuner_info("Device is Xceive %d version %d.%d, " |
| 696 | "firmware version %d.%d\n", |
| 697 | hwmodel, (version & 0xf000) >> 12, (version & 0xf00) >> 8, |
| 698 | (version & 0xf0) >> 4, version & 0xf); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 699 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 700 | priv->firm_type = std; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 701 | |
| 702 | return 0; |
| 703 | } |
| 704 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 705 | static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 706 | { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 707 | struct xc2028_data *priv = fe->tuner_priv; |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 708 | u16 frq_lock, signal = 0; |
| 709 | int rc; |
Mauro Carvalho Chehab | 3b20532 | 2007-09-27 18:27:03 -0300 | [diff] [blame] | 710 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 711 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 712 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 713 | mutex_lock(&priv->lock); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 714 | |
Mauro Carvalho Chehab | 80b5220 | 2007-11-05 09:07:13 -0300 | [diff] [blame] | 715 | /* Sync Lock Indicator */ |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 716 | rc = xc2028_get_reg(priv, 0x0002, &frq_lock); |
| 717 | if (rc < 0 || frq_lock == 0) |
Mauro Carvalho Chehab | 3b20532 | 2007-09-27 18:27:03 -0300 | [diff] [blame] | 718 | goto ret; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 719 | |
| 720 | /* Frequency is locked. Return signal quality */ |
| 721 | |
Mauro Carvalho Chehab | 80b5220 | 2007-11-05 09:07:13 -0300 | [diff] [blame] | 722 | /* Get SNR of the video signal */ |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 723 | rc = xc2028_get_reg(priv, 0x0040, &signal); |
| 724 | if (rc < 0) |
| 725 | signal = -frq_lock; |
Mauro Carvalho Chehab | 3b20532 | 2007-09-27 18:27:03 -0300 | [diff] [blame] | 726 | |
| 727 | ret: |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 728 | mutex_unlock(&priv->lock); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 729 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 730 | *strength = signal; |
| 731 | |
Chris Pascoe | 7d58d11 | 2007-11-19 04:31:58 -0300 | [diff] [blame] | 732 | return rc; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | #define DIV 15625 |
| 736 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 737 | static int generic_set_tv_freq(struct dvb_frontend *fe, u32 freq /* in Hz */ , |
| 738 | enum tuner_mode new_mode, |
| 739 | v4l2_std_id std, fe_bandwidth_t bandwidth) |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 740 | { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 741 | struct xc2028_data *priv = fe->tuner_priv; |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 742 | int rc = -EINVAL; |
Chris Pascoe | 2ce4b3a | 2007-11-19 06:20:17 -0300 | [diff] [blame^] | 743 | unsigned char buf[4]; |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 744 | u32 div, offset = 0; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 745 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 746 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 747 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 748 | mutex_lock(&priv->lock); |
| 749 | |
Mauro Carvalho Chehab | d4e7668 | 2007-07-18 23:14:25 -0300 | [diff] [blame] | 750 | /* HACK: It seems that specific firmware need to be reloaded |
| 751 | when freq is changed */ |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 752 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 753 | priv->firm_type = 0; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 754 | |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 755 | /* Reset GPIO 1 */ |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 756 | rc = priv->tuner_callback(priv->video_dev, XC2028_TUNER_RESET, 0); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 757 | if (rc < 0) |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 758 | goto ret; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 759 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 760 | msleep(10); |
Chris Pascoe | 2ce4b3a | 2007-11-19 06:20:17 -0300 | [diff] [blame^] | 761 | tuner_dbg("should set frequency %d kHz\n", freq / 1000); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 762 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 763 | if (check_firmware(fe, new_mode, std, bandwidth) < 0) |
Mauro Carvalho Chehab | 3b20532 | 2007-09-27 18:27:03 -0300 | [diff] [blame] | 764 | goto ret; |
Mauro Carvalho Chehab | 2e4160c | 2007-07-18 13:33:23 -0300 | [diff] [blame] | 765 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 766 | if (new_mode == T_DIGITAL_TV) |
Mauro Carvalho Chehab | d4e7668 | 2007-07-18 23:14:25 -0300 | [diff] [blame] | 767 | offset = 2750000; |
Mauro Carvalho Chehab | 2e4160c | 2007-07-18 13:33:23 -0300 | [diff] [blame] | 768 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 769 | div = (freq - offset + DIV / 2) / DIV; |
Mauro Carvalho Chehab | 2e4160c | 2007-07-18 13:33:23 -0300 | [diff] [blame] | 770 | |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 771 | /* CMD= Set frequency */ |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 772 | if (priv->firm_version < 0x0202) |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 773 | rc = send_seq(priv, {0x00, 0x02, 0x00, 0x00}); |
| 774 | else |
| 775 | rc = send_seq(priv, {0x80, 0x02, 0x00, 0x00}); |
| 776 | if (rc < 0) |
| 777 | goto ret; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 778 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 779 | rc = priv->tuner_callback(priv->video_dev, XC2028_RESET_CLK, 1); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 780 | if (rc < 0) |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 781 | goto ret; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 782 | |
| 783 | msleep(10); |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 784 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 785 | buf[0] = 0xff & (div >> 24); |
| 786 | buf[1] = 0xff & (div >> 16); |
| 787 | buf[2] = 0xff & (div >> 8); |
| 788 | buf[3] = 0xff & (div); |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 789 | |
Chris Pascoe | 47cc5b7 | 2007-11-19 04:14:23 -0300 | [diff] [blame] | 790 | rc = i2c_send(priv, buf, sizeof(buf)); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 791 | if (rc < 0) |
Mauro Carvalho Chehab | 3b20532 | 2007-09-27 18:27:03 -0300 | [diff] [blame] | 792 | goto ret; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 793 | msleep(100); |
| 794 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 795 | priv->frequency = freq; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 796 | |
Chris Pascoe | 2ce4b3a | 2007-11-19 06:20:17 -0300 | [diff] [blame^] | 797 | tuner_dbg("divisor= %02x %02x %02x %02x (freq=%d.%03d)\n", |
| 798 | buf[0], buf[1], buf[2], buf[3], |
| 799 | freq / 1000000, (freq % 1000000) / 1000); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 800 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 801 | rc = 0; |
Mauro Carvalho Chehab | 3b20532 | 2007-09-27 18:27:03 -0300 | [diff] [blame] | 802 | |
| 803 | ret: |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 804 | mutex_unlock(&priv->lock); |
| 805 | |
| 806 | return rc; |
Mauro Carvalho Chehab | 6cb4587 | 2007-10-02 11:57:03 -0300 | [diff] [blame] | 807 | } |
| 808 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 809 | static int xc2028_set_tv_freq(struct dvb_frontend *fe, |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 810 | struct analog_parameters *p) |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 811 | { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 812 | struct xc2028_data *priv = fe->tuner_priv; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 813 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 814 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 815 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 816 | return generic_set_tv_freq(fe, 62500l * p->frequency, T_ANALOG_TV, |
| 817 | p->std, BANDWIDTH_8_MHZ /* NOT USED */); |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 818 | } |
| 819 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 820 | static int xc2028_set_params(struct dvb_frontend *fe, |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 821 | struct dvb_frontend_parameters *p) |
| 822 | { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 823 | struct xc2028_data *priv = fe->tuner_priv; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 824 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 825 | tuner_dbg("%s called\n", __FUNCTION__); |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 826 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 827 | /* FIXME: Only OFDM implemented */ |
| 828 | if (fe->ops.info.type != FE_OFDM) { |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 829 | tuner_err("DTV type not implemented.\n"); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 830 | return -EINVAL; |
| 831 | } |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 832 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 833 | return generic_set_tv_freq(fe, p->frequency, T_DIGITAL_TV, |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 834 | 0 /* NOT USED */, |
| 835 | p->u.ofdm.bandwidth); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 836 | |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 837 | } |
| 838 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 839 | static int xc2028_dvb_release(struct dvb_frontend *fe) |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 840 | { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 841 | struct xc2028_data *priv = fe->tuner_priv; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 842 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 843 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 844 | |
Chris Pascoe | aa501be | 2007-11-19 04:45:38 -0300 | [diff] [blame] | 845 | mutex_lock(&xc2028_list_mutex); |
| 846 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 847 | priv->count--; |
| 848 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 849 | if (!priv->count) { |
Mauro Carvalho Chehab | 1808a69 | 2007-10-29 17:38:59 -0300 | [diff] [blame] | 850 | list_del(&priv->xc2028_list); |
| 851 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 852 | kfree(priv->ctrl.fname); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 853 | |
| 854 | free_firmware(priv); |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 855 | kfree(priv); |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 856 | fe->tuner_priv = NULL; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 857 | } |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 858 | |
Chris Pascoe | aa501be | 2007-11-19 04:45:38 -0300 | [diff] [blame] | 859 | mutex_unlock(&xc2028_list_mutex); |
| 860 | |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 861 | return 0; |
| 862 | } |
| 863 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 864 | static int xc2028_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 865 | { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 866 | struct xc2028_data *priv = fe->tuner_priv; |
| 867 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 868 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 869 | |
| 870 | *frequency = priv->frequency; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 871 | |
| 872 | return 0; |
| 873 | } |
| 874 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 875 | static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg) |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 876 | { |
| 877 | struct xc2028_data *priv = fe->tuner_priv; |
| 878 | struct xc2028_ctrl *p = priv_cfg; |
| 879 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 880 | tuner_dbg("%s called\n", __FUNCTION__); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 881 | |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 882 | mutex_lock(&priv->lock); |
| 883 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 884 | priv->ctrl.type = p->type; |
| 885 | |
| 886 | if (p->fname) { |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 887 | kfree(priv->ctrl.fname); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 888 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 889 | priv->ctrl.fname = kmalloc(strlen(p->fname) + 1, GFP_KERNEL); |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 890 | if (priv->ctrl.fname == NULL) { |
| 891 | mutex_unlock(&priv->lock); |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 892 | return -ENOMEM; |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 893 | } |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 894 | |
| 895 | free_firmware(priv); |
| 896 | strcpy(priv->ctrl.fname, p->fname); |
| 897 | } |
| 898 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 899 | if (p->max_len > 0) |
Mauro Carvalho Chehab | 352fae1 | 2007-11-01 16:56:26 -0300 | [diff] [blame] | 900 | priv->max_len = p->max_len; |
| 901 | |
Chris Pascoe | 06fd82d | 2007-11-19 06:06:08 -0300 | [diff] [blame] | 902 | mutex_unlock(&priv->lock); |
| 903 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 904 | return 0; |
| 905 | } |
| 906 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 907 | static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = { |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 908 | .info = { |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 909 | .name = "Xceive XC3028", |
| 910 | .frequency_min = 42000000, |
| 911 | .frequency_max = 864000000, |
| 912 | .frequency_step = 50000, |
| 913 | }, |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 914 | |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 915 | .set_config = xc2028_set_config, |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 916 | .set_analog_params = xc2028_set_tv_freq, |
| 917 | .release = xc2028_dvb_release, |
| 918 | .get_frequency = xc2028_get_frequency, |
| 919 | .get_rf_strength = xc2028_signal, |
| 920 | .set_params = xc2028_set_params, |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 921 | |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 922 | }; |
| 923 | |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 924 | void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg) |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 925 | { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 926 | struct xc2028_data *priv; |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 927 | void *video_dev; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 928 | |
Mauro Carvalho Chehab | 83fb340 | 2007-11-15 09:44:30 -0300 | [diff] [blame] | 929 | if (debug) |
Chris Pascoe | 3157ece | 2007-11-19 04:34:29 -0300 | [diff] [blame] | 930 | printk(KERN_DEBUG PREFIX ": Xcv2028/3028 init called!\n"); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 931 | |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 932 | if (NULL == cfg->video_dev) |
| 933 | return NULL; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 934 | |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 935 | if (!fe) { |
Chris Pascoe | 3157ece | 2007-11-19 04:34:29 -0300 | [diff] [blame] | 936 | printk(KERN_ERR PREFIX ": No frontend!\n"); |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 937 | return NULL; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 938 | } |
| 939 | |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 940 | video_dev = cfg->video_dev; |
| 941 | |
Chris Pascoe | aa501be | 2007-11-19 04:45:38 -0300 | [diff] [blame] | 942 | mutex_lock(&xc2028_list_mutex); |
| 943 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 944 | list_for_each_entry(priv, &xc2028_list, xc2028_list) { |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 945 | if (priv->video_dev == cfg->video_dev) { |
| 946 | video_dev = NULL; |
| 947 | break; |
| 948 | } |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 949 | } |
| 950 | |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 951 | if (video_dev) { |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 952 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
Chris Pascoe | aa501be | 2007-11-19 04:45:38 -0300 | [diff] [blame] | 953 | if (priv == NULL) { |
| 954 | mutex_unlock(&xc2028_list_mutex); |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 955 | return NULL; |
Chris Pascoe | aa501be | 2007-11-19 04:45:38 -0300 | [diff] [blame] | 956 | } |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 957 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 958 | priv->bandwidth = BANDWIDTH_6_MHZ; |
| 959 | priv->need_load_generic = 1; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 960 | priv->mode = T_UNINITIALIZED; |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 961 | priv->i2c_props.addr = cfg->i2c_addr; |
| 962 | priv->i2c_props.adap = cfg->i2c_adap; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 963 | priv->video_dev = video_dev; |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 964 | priv->tuner_callback = cfg->callback; |
Mauro Carvalho Chehab | de3fe21 | 2007-10-24 09:22:08 -0300 | [diff] [blame] | 965 | priv->max_len = 13; |
| 966 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 967 | mutex_init(&priv->lock); |
| 968 | |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 969 | list_add_tail(&priv->xc2028_list, &xc2028_list); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 970 | } |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 971 | |
| 972 | fe->tuner_priv = priv; |
Mauro Carvalho Chehab | 1808a69 | 2007-10-29 17:38:59 -0300 | [diff] [blame] | 973 | priv->count++; |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 974 | |
| 975 | memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops, |
Mauro Carvalho Chehab | ab0b9fc | 2007-11-01 17:47:42 -0300 | [diff] [blame] | 976 | sizeof(xc2028_dvb_tuner_ops)); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 977 | |
| 978 | tuner_info("type set to %s\n", "XCeive xc2028/xc3028 tuner"); |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 979 | |
Chris Pascoe | aa501be | 2007-11-19 04:45:38 -0300 | [diff] [blame] | 980 | mutex_unlock(&xc2028_list_mutex); |
| 981 | |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 982 | return fe; |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 983 | } |
Michel Ludwig | a37b4c9 | 2007-11-16 07:46:14 -0300 | [diff] [blame] | 984 | |
Michel Ludwig | 701672e | 2007-07-18 10:29:10 -0300 | [diff] [blame] | 985 | EXPORT_SYMBOL(xc2028_attach); |
| 986 | |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 987 | MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver"); |
Mauro Carvalho Chehab | 983d214 | 2007-10-29 23:44:18 -0300 | [diff] [blame] | 988 | MODULE_AUTHOR("Michel Ludwig <michel.ludwig@gmail.com>"); |
Mauro Carvalho Chehab | 215b95b | 2007-10-23 15:24:06 -0300 | [diff] [blame] | 989 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
| 990 | MODULE_LICENSE("GPL"); |