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