Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1 | /* DVB USB compliant linux driver for MSI Mega Sky 580 DVB-T USB2.0 receiver |
| 2 | * |
| 3 | * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License as published by the Free |
| 7 | * Software Foundation, version 2. |
| 8 | * |
| 9 | * see Documentation/dvb/README.dvb-usb for more information |
| 10 | */ |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 11 | |
Michael Krufky | 2aef7d0 | 2006-09-23 20:00:42 -0300 | [diff] [blame] | 12 | #include "m920x.h" |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 13 | |
| 14 | #include "mt352.h" |
| 15 | #include "mt352_priv.h" |
Michael Krufky | 017cf01 | 2006-09-23 20:40:20 -0300 | [diff] [blame] | 16 | #include "qt1010.h" |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 17 | #include "tda1004x.h" |
| 18 | #include "tda827x.h" |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 19 | |
| 20 | /* debug */ |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 21 | static int dvb_usb_m920x_debug; |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 22 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 23 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
| 24 | |
| 25 | static struct dvb_usb_rc_key megasky_rc_keys [] = { |
| 26 | { 0x0, 0x12, KEY_POWER }, |
| 27 | { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */ |
| 28 | { 0x0, 0x02, KEY_CHANNELUP }, |
| 29 | { 0x0, 0x05, KEY_CHANNELDOWN }, |
| 30 | { 0x0, 0x03, KEY_VOLUMEUP }, |
| 31 | { 0x0, 0x06, KEY_VOLUMEDOWN }, |
| 32 | { 0x0, 0x04, KEY_MUTE }, |
| 33 | { 0x0, 0x07, KEY_OK }, /* TS */ |
| 34 | { 0x0, 0x08, KEY_STOP }, |
| 35 | { 0x0, 0x09, KEY_MENU }, /* swap */ |
| 36 | { 0x0, 0x0a, KEY_REWIND }, |
| 37 | { 0x0, 0x1b, KEY_PAUSE }, |
| 38 | { 0x0, 0x1f, KEY_FASTFORWARD }, |
| 39 | { 0x0, 0x0c, KEY_RECORD }, |
| 40 | { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */ |
| 41 | { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */ |
| 42 | }; |
| 43 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 44 | static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = { |
| 45 | { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */ |
| 46 | { 0x0, 0x02, KEY_CAMERA }, /* snapshot */ |
| 47 | { 0x0, 0x03, KEY_MUTE }, |
| 48 | { 0x0, 0x04, KEY_REWIND }, |
| 49 | { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */ |
| 50 | { 0x0, 0x06, KEY_FASTFORWARD }, |
| 51 | { 0x0, 0x07, KEY_RECORD }, |
| 52 | { 0x0, 0x08, KEY_STOP }, |
| 53 | { 0x0, 0x09, KEY_TIME }, /* Timeshift */ |
| 54 | { 0x0, 0x0c, KEY_COFFEE }, /* Recall */ |
| 55 | { 0x0, 0x0e, KEY_CHANNELUP }, |
| 56 | { 0x0, 0x12, KEY_POWER }, |
| 57 | { 0x0, 0x15, KEY_MENU }, /* source */ |
| 58 | { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */ |
| 59 | { 0x0, 0x1a, KEY_CHANNELDOWN }, |
| 60 | { 0x0, 0x1b, KEY_VOLUMEDOWN }, |
| 61 | { 0x0, 0x1e, KEY_VOLUMEUP }, |
| 62 | }; |
| 63 | |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 64 | static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\ |
| 65 | u16 index, void *data, int size) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 66 | { |
| 67 | int ret; |
| 68 | |
| 69 | ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
| 70 | request, USB_TYPE_VENDOR | USB_DIR_IN, |
| 71 | value, index, data, size, 2000); |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 72 | if (ret < 0) { |
| 73 | printk(KERN_INFO "m920x_read = error: %d\n", ret); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 74 | return ret; |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 75 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 76 | |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 77 | if (ret != size) { |
| 78 | deb_rc("m920x_read = no data\n"); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 79 | return -EIO; |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 80 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 85 | static inline int m9206_write(struct usb_device *udev, u8 request, |
| 86 | u16 value, u16 index) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 87 | { |
| 88 | int ret; |
| 89 | |
| 90 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
| 91 | request, USB_TYPE_VENDOR | USB_DIR_OUT, |
| 92 | value, index, NULL, 0, 2000); |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 93 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 94 | return ret; |
| 95 | } |
| 96 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 97 | static int m9206_init(struct dvb_usb_device *d, struct m9206_inits *rc_seq) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 98 | { |
| 99 | int ret = 0; |
| 100 | |
| 101 | /* Remote controller init. */ |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 102 | if (d->props.rc_query) { |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 103 | deb_rc("Initialising remote control\n"); |
| 104 | while (rc_seq->address) { |
| 105 | if ((ret = m9206_write(d->udev, M9206_CORE, rc_seq->data, rc_seq->address)) != 0) { |
| 106 | deb_rc("Initialising remote control failed\n"); |
| 107 | return ret; |
| 108 | } |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 109 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 110 | rc_seq++; |
| 111 | } |
| 112 | |
| 113 | deb_rc("Initialising remote control success\n"); |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 114 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 115 | |
| 116 | return ret; |
| 117 | } |
| 118 | |
| 119 | static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
| 120 | { |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 121 | struct m9206_state *m = d->priv; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 122 | int i, ret = 0; |
| 123 | u8 rc_state[2]; |
| 124 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 125 | if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 126 | goto unlock; |
| 127 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 128 | if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 129 | goto unlock; |
| 130 | |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 131 | for (i = 0; i < d->props.rc_key_map_size; i++) |
| 132 | if (d->props.rc_key_map[i].data == rc_state[1]) { |
| 133 | *event = d->props.rc_key_map[i].event; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 134 | |
| 135 | switch(rc_state[0]) { |
| 136 | case 0x80: |
| 137 | *state = REMOTE_NO_KEY_PRESSED; |
| 138 | goto unlock; |
| 139 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 140 | case 0x88: /* framing error or "invalid code" */ |
| 141 | case 0x99: |
| 142 | case 0xc0: |
| 143 | case 0xd8: |
| 144 | *state = REMOTE_NO_KEY_PRESSED; |
| 145 | m->rep_count = 0; |
| 146 | goto unlock; |
| 147 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 148 | case 0x93: |
| 149 | case 0x92: |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 150 | m->rep_count = 0; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 151 | *state = REMOTE_KEY_PRESSED; |
| 152 | goto unlock; |
| 153 | |
| 154 | case 0x91: |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 155 | /* prevent immediate auto-repeat */ |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 156 | if (++m->rep_count > 2) |
| 157 | *state = REMOTE_KEY_REPEAT; |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 158 | else |
| 159 | *state = REMOTE_NO_KEY_PRESSED; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 160 | goto unlock; |
| 161 | |
| 162 | default: |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 163 | deb_rc("Unexpected rc state %02x\n", rc_state[0]); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 164 | *state = REMOTE_NO_KEY_PRESSED; |
| 165 | goto unlock; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | if (rc_state[1] != 0) |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 170 | deb_rc("Unknown rc key %02x\n", rc_state[1]); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 171 | |
| 172 | *state = REMOTE_NO_KEY_PRESSED; |
| 173 | |
| 174 | unlock: |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 175 | |
| 176 | return ret; |
| 177 | } |
| 178 | |
| 179 | /* I2C */ |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 180 | static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 181 | int num) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 182 | { |
| 183 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 184 | int i, j; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 185 | int ret = 0; |
| 186 | |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 187 | if (!num) |
| 188 | return -EINVAL; |
| 189 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 190 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 191 | return -EAGAIN; |
| 192 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 193 | for (i = 0; i < num; i++) { |
Trent Piepho | 57f8dcf | 2007-03-12 12:13:12 -0300 | [diff] [blame] | 194 | if (msg[i].flags & (I2C_M_NO_RD_ACK|I2C_M_IGNORE_NAK|I2C_M_TEN) || |
| 195 | msg[i].len == 0) { |
| 196 | /* For a 0 byte message, I think sending the address to index 0x80|0x40 |
| 197 | * would be the correct thing to do. However, zero byte messages are |
| 198 | * only used for probing, and since we don't know how to get the slave's |
| 199 | * ack, we can't probe. */ |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 200 | ret = -ENOTSUPP; |
| 201 | goto unlock; |
| 202 | } |
| 203 | /* Send START & address/RW bit */ |
| 204 | if (!(msg[i].flags & I2C_M_NOSTART)) { |
Trent Piepho | 57f8dcf | 2007-03-12 12:13:12 -0300 | [diff] [blame] | 205 | if ((ret = m9206_write(d->udev, M9206_I2C, (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0), 0x80)) != 0) |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 206 | goto unlock; |
| 207 | /* Should check for ack here, if we knew how. */ |
| 208 | } |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 209 | if (msg[i].flags & I2C_M_RD) { |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 210 | for (j = 0; j < msg[i].len; j++) { |
| 211 | /* Last byte of transaction? Send STOP, otherwise send ACK. */ |
| 212 | int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x01; |
| 213 | if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x20|stop, &msg[i].buf[j], 1)) != 0) |
| 214 | goto unlock; |
Aapo Tahkola | 84ad757 | 2007-01-21 15:57:20 -0300 | [diff] [blame] | 215 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 216 | } else { |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 217 | for (j = 0; j < msg[i].len; j++) { |
| 218 | /* Last byte of transaction? Then send STOP. */ |
| 219 | int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x00; |
| 220 | if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0) |
| 221 | goto unlock; |
| 222 | /* Should check for ack here too. */ |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 223 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 224 | } |
| 225 | } |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 226 | ret = num; |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 227 | |
| 228 | unlock: |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 229 | mutex_unlock(&d->i2c_mutex); |
| 230 | |
| 231 | return ret; |
| 232 | } |
| 233 | |
| 234 | static u32 m9206_i2c_func(struct i2c_adapter *adapter) |
| 235 | { |
| 236 | return I2C_FUNC_I2C; |
| 237 | } |
| 238 | |
| 239 | static struct i2c_algorithm m9206_i2c_algo = { |
| 240 | .master_xfer = m9206_i2c_xfer, |
| 241 | .functionality = m9206_i2c_func, |
| 242 | }; |
| 243 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 244 | |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 245 | static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, |
| 246 | int pid) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 247 | { |
| 248 | int ret = 0; |
| 249 | |
| 250 | if (pid >= 0x8000) |
| 251 | return -EINVAL; |
| 252 | |
| 253 | pid |= 0x8000; |
| 254 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 255 | if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 256 | return ret; |
| 257 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 258 | if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0) |
| 259 | return ret; |
| 260 | |
| 261 | return ret; |
| 262 | } |
| 263 | |
| 264 | static int m9206_update_filters(struct dvb_usb_adapter *adap) |
| 265 | { |
| 266 | struct m9206_state *m = adap->dev->priv; |
| 267 | int enabled = m->filtering_enabled; |
| 268 | int i, ret = 0, filter = 0; |
| 269 | |
| 270 | for (i = 0; i < M9206_MAX_FILTERS; i++) |
| 271 | if (m->filters[i] == 8192) |
| 272 | enabled = 0; |
| 273 | |
| 274 | /* Disable all filters */ |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 275 | if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 276 | return ret; |
| 277 | |
| 278 | for (i = 0; i < M9206_MAX_FILTERS; i++) |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 279 | if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 280 | return ret; |
| 281 | |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 282 | if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 283 | return ret; |
| 284 | |
| 285 | /* Set */ |
| 286 | if (enabled) { |
| 287 | for (i = 0; i < M9206_MAX_FILTERS; i++) { |
| 288 | if (m->filters[i] == 0) |
| 289 | continue; |
| 290 | |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 291 | if ((ret = m9206_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 292 | return ret; |
| 293 | |
| 294 | filter++; |
| 295 | } |
| 296 | } |
| 297 | |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 298 | if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 299 | return ret; |
| 300 | |
| 301 | return ret; |
| 302 | } |
| 303 | |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 304 | static int m9206_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 305 | { |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 306 | struct m9206_state *m = adap->dev->priv; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 307 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 308 | m->filtering_enabled = onoff ? 1 : 0; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 309 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 310 | return m9206_update_filters(adap); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 311 | } |
| 312 | |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 313 | static int m9206_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, |
| 314 | int onoff) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 315 | { |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 316 | struct m9206_state *m = adap->dev->priv; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 317 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 318 | m->filters[index] = onoff ? pid : 0; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 319 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 320 | return m9206_update_filters(adap); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 321 | } |
| 322 | |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 323 | static int m9206_firmware_download(struct usb_device *udev, |
| 324 | const struct firmware *fw) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 325 | { |
| 326 | u16 value, index, size; |
| 327 | u8 read[4], *buff; |
| 328 | int i, pass, ret = 0; |
| 329 | |
| 330 | buff = kmalloc(65536, GFP_KERNEL); |
| 331 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 332 | if ((ret = m9206_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 333 | goto done; |
| 334 | deb_rc("%x %x %x %x\n", read[0], read[1], read[2], read[3]); |
| 335 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 336 | if ((ret = m9206_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 337 | goto done; |
| 338 | deb_rc("%x\n", read[0]); |
| 339 | |
| 340 | for (pass = 0; pass < 2; pass++) { |
| 341 | for (i = 0; i + (sizeof(u16) * 3) < fw->size;) { |
| 342 | value = le16_to_cpu(*(u16 *)(fw->data + i)); |
| 343 | i += sizeof(u16); |
| 344 | |
| 345 | index = le16_to_cpu(*(u16 *)(fw->data + i)); |
| 346 | i += sizeof(u16); |
| 347 | |
| 348 | size = le16_to_cpu(*(u16 *)(fw->data + i)); |
| 349 | i += sizeof(u16); |
| 350 | |
| 351 | if (pass == 1) { |
| 352 | /* Will stall if using fw->data ... */ |
| 353 | memcpy(buff, fw->data + i, size); |
| 354 | |
| 355 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0), |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 356 | M9206_FW, |
| 357 | USB_TYPE_VENDOR | USB_DIR_OUT, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 358 | value, index, buff, size, 20); |
| 359 | if (ret != size) { |
| 360 | deb_rc("error while uploading fw!\n"); |
| 361 | ret = -EIO; |
| 362 | goto done; |
| 363 | } |
| 364 | msleep(3); |
| 365 | } |
| 366 | i += size; |
| 367 | } |
| 368 | if (i != fw->size) { |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 369 | deb_rc("bad firmware file!\n"); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 370 | ret = -EINVAL; |
| 371 | goto done; |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | msleep(36); |
| 376 | |
| 377 | /* m9206 will disconnect itself from the bus after this. */ |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 378 | (void) m9206_write(udev, M9206_CORE, 0x01, M9206_FW_GO); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 379 | deb_rc("firmware uploaded!\n"); |
| 380 | |
| 381 | done: |
| 382 | kfree(buff); |
| 383 | |
| 384 | return ret; |
| 385 | } |
| 386 | |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 387 | /* Callbacks for DVB USB */ |
Aapo Tahkola | 7d1d4e6 | 2007-03-15 13:01:46 -0300 | [diff] [blame] | 388 | static int m920x_identify_state(struct usb_device *udev, |
| 389 | struct dvb_usb_device_properties *props, |
| 390 | struct dvb_usb_device_description **desc, |
| 391 | int *cold) |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 392 | { |
| 393 | struct usb_host_interface *alt; |
| 394 | |
| 395 | alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1); |
| 396 | *cold = (alt == NULL) ? 1 : 0; |
| 397 | |
| 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | static int megasky_mt352_demod_init(struct dvb_frontend *fe) |
| 402 | { |
| 403 | u8 config[] = { CONFIG, 0x3d }; |
| 404 | u8 clock[] = { CLOCK_CTL, 0x30 }; |
| 405 | u8 reset[] = { RESET, 0x80 }; |
| 406 | u8 adc_ctl[] = { ADC_CTL_1, 0x40 }; |
| 407 | u8 agc[] = { AGC_TARGET, 0x1c, 0x20 }; |
| 408 | u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 }; |
| 409 | u8 unk1[] = { 0x93, 0x1a }; |
| 410 | u8 unk2[] = { 0xb5, 0x7a }; |
| 411 | |
| 412 | mt352_write(fe, config, ARRAY_SIZE(config)); |
| 413 | mt352_write(fe, clock, ARRAY_SIZE(clock)); |
| 414 | mt352_write(fe, reset, ARRAY_SIZE(reset)); |
| 415 | mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl)); |
| 416 | mt352_write(fe, agc, ARRAY_SIZE(agc)); |
| 417 | mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc)); |
| 418 | mt352_write(fe, unk1, ARRAY_SIZE(unk1)); |
| 419 | mt352_write(fe, unk2, ARRAY_SIZE(unk2)); |
| 420 | |
| 421 | deb_rc("Demod init!\n"); |
| 422 | |
| 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | static struct mt352_config megasky_mt352_config = { |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 427 | .demod_address = 0x0f, |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 428 | .no_tuner = 1, |
| 429 | .demod_init = megasky_mt352_demod_init, |
| 430 | }; |
| 431 | |
| 432 | static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap) |
| 433 | { |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 434 | deb_rc("megasky_frontend_attach!\n"); |
| 435 | |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 436 | if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL) |
| 437 | return -EIO; |
| 438 | |
| 439 | return 0; |
| 440 | } |
| 441 | |
Antti Palosaari | cbdc80e | 2007-01-21 15:56:10 -0300 | [diff] [blame] | 442 | static struct qt1010_config megasky_qt1010_config = { |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 443 | .i2c_address = 0x62 |
Antti Palosaari | cbdc80e | 2007-01-21 15:56:10 -0300 | [diff] [blame] | 444 | }; |
| 445 | |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 446 | static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap) |
Antti Palosaari | cbdc80e | 2007-01-21 15:56:10 -0300 | [diff] [blame] | 447 | { |
Aapo Tahkola | 84ad757 | 2007-01-21 15:57:20 -0300 | [diff] [blame] | 448 | if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, |
| 449 | &megasky_qt1010_config) == NULL) |
| 450 | return -ENODEV; |
| 451 | |
| 452 | return 0; |
Antti Palosaari | cbdc80e | 2007-01-21 15:56:10 -0300 | [diff] [blame] | 453 | } |
| 454 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 455 | static struct m9206_inits megasky_rc_init [] = { |
| 456 | { M9206_RC_INIT2, 0xa8 }, |
| 457 | { M9206_RC_INIT1, 0x51 }, |
| 458 | { } /* terminating entry */ |
| 459 | }; |
| 460 | |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 461 | static struct tda1004x_config digivox_tda10046_config = { |
| 462 | .demod_address = 0x08, |
| 463 | .invert = 0, |
| 464 | .invert_oclk = 0, |
| 465 | .ts_mode = TDA10046_TS_SERIAL, |
| 466 | .xtal_freq = TDA10046_XTAL_16M, |
| 467 | .if_freq = TDA10046_FREQ_045, |
| 468 | .agc_config = TDA10046_AGC_TDA827X, |
| 469 | .gpio_config = TDA10046_GPTRI, |
| 470 | .request_firmware = NULL, |
| 471 | }; |
| 472 | |
| 473 | static int digivox_tda10046_frontend_attach(struct dvb_usb_adapter *adap) |
| 474 | { |
| 475 | deb_rc("digivox_tda10046_frontend_attach!\n"); |
| 476 | |
| 477 | if ((adap->fe = dvb_attach(tda10046_attach, &digivox_tda10046_config, |
| 478 | &adap->dev->i2c_adap)) == NULL) |
| 479 | return -EIO; |
| 480 | |
| 481 | return 0; |
| 482 | } |
| 483 | |
| 484 | static int digivox_tda8275_tuner_attach(struct dvb_usb_adapter *adap) |
| 485 | { |
| 486 | if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, |
| 487 | NULL) == NULL) |
| 488 | return -ENODEV; |
| 489 | return 0; |
| 490 | } |
| 491 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 492 | /* LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A |
| 493 | * TDA10046 #0 is located at i2c address 0x08 |
| 494 | * TDA10046 #1 is located at i2c address 0x0b |
| 495 | * TDA8275A #0 is located at i2c address 0x60 |
| 496 | * TDA8275A #1 is located at i2c address 0x61 |
| 497 | */ |
| 498 | |
| 499 | static struct tda1004x_config tvwalkertwin_0_tda10046_config = { |
| 500 | .demod_address = 0x08, |
| 501 | .invert = 0, |
| 502 | .invert_oclk = 0, |
| 503 | .ts_mode = TDA10046_TS_SERIAL, |
| 504 | .xtal_freq = TDA10046_XTAL_16M, |
| 505 | .if_freq = TDA10046_FREQ_045, |
| 506 | .agc_config = TDA10046_AGC_TDA827X, |
| 507 | .gpio_config = TDA10046_GPTRI, |
| 508 | .request_firmware = NULL, /* uses firmware EEPROM */ |
| 509 | }; |
| 510 | |
| 511 | static struct tda1004x_config tvwalkertwin_1_tda10046_config = { |
| 512 | .demod_address = 0x0b, |
| 513 | .invert = 0, |
| 514 | .invert_oclk = 0, |
| 515 | .ts_mode = TDA10046_TS_SERIAL, |
| 516 | .xtal_freq = TDA10046_XTAL_16M, |
| 517 | .if_freq = TDA10046_FREQ_045, |
| 518 | .agc_config = TDA10046_AGC_TDA827X, |
| 519 | .gpio_config = TDA10046_GPTRI, |
| 520 | .request_firmware = NULL, /* uses firmware EEPROM */ |
| 521 | }; |
| 522 | |
| 523 | static int tvwalkertwin_0_tda10046_frontend_attach(struct dvb_usb_adapter *adap) |
| 524 | { |
| 525 | deb_rc("tvwalkertwin_0_tda10046_frontend_attach!\n"); |
| 526 | |
| 527 | if ((adap->fe = dvb_attach(tda10046_attach, &tvwalkertwin_0_tda10046_config, &adap->dev->i2c_adap)) == NULL) |
| 528 | return -EIO; |
| 529 | |
| 530 | deb_rc("Attached demod 0 at address %02x\n", tvwalkertwin_0_tda10046_config.demod_address); |
| 531 | |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | static int tvwalkertwin_1_tda10046_frontend_attach(struct dvb_usb_adapter *adap) |
| 536 | { |
| 537 | deb_rc("tvwalkertwin_1_tda10046_frontend_attach!\n"); |
| 538 | |
| 539 | if ((adap->fe = dvb_attach(tda10046_attach, &tvwalkertwin_1_tda10046_config, &adap->dev->i2c_adap)) == NULL) |
| 540 | return -EIO; |
| 541 | |
| 542 | deb_rc("Attached demod 1 at address %02x\n", tvwalkertwin_1_tda10046_config.demod_address); |
| 543 | |
| 544 | return 0; |
| 545 | } |
| 546 | |
| 547 | static int tvwalkertwin_0_tda8275_tuner_attach(struct dvb_usb_adapter *adap) |
| 548 | { |
| 549 | int address = 0x60; |
| 550 | |
| 551 | deb_rc("tvwalkertwin_0_tda8275_tuner_attach!\n"); |
| 552 | |
| 553 | if (dvb_attach(tda827x_attach, adap->fe, address, &adap->dev->i2c_adap, |
| 554 | NULL) == NULL) |
| 555 | return -ENODEV; |
| 556 | |
| 557 | deb_rc("Attached tuner 0 at address %02x\n", address); |
| 558 | |
| 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | static int tvwalkertwin_1_tda8275_tuner_attach(struct dvb_usb_adapter *adap) |
| 563 | { |
| 564 | int address = 0x61; |
| 565 | |
| 566 | deb_rc("tvwalkertwin_1_tda8275_tuner_attach!\n"); |
| 567 | |
| 568 | if (dvb_attach(tda827x_attach, adap->fe, address, &adap->dev->i2c_adap, |
| 569 | NULL) == NULL) |
| 570 | return -ENODEV; |
| 571 | |
| 572 | deb_rc("Attached tuner 1 at address %02x\n", address); |
| 573 | |
| 574 | return 0; |
| 575 | } |
| 576 | |
| 577 | static struct m9206_inits tvwalkertwin_rc_init [] = { |
| 578 | { M9206_RC_INIT2, 0x00 }, |
| 579 | { M9206_RC_INIT1, 0xef }, |
| 580 | { 0xff28, 0x00 }, |
| 581 | { 0xff23, 0x00 }, |
| 582 | { 0xff21, 0x30 }, |
| 583 | { } /* terminating entry */ |
| 584 | }; |
| 585 | |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 586 | /* DVB USB Driver stuff */ |
| 587 | static struct dvb_usb_device_properties megasky_properties; |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 588 | static struct dvb_usb_device_properties digivox_mini_ii_properties; |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 589 | static struct dvb_usb_device_properties tvwalkertwin_properties; |
| 590 | static struct m9206_inits megasky_rc_init []; |
| 591 | static struct m9206_inits tvwalkertwin_rc_init []; |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 592 | |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 593 | static int m920x_probe(struct usb_interface *intf, |
| 594 | const struct usb_device_id *id) |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 595 | { |
| 596 | struct dvb_usb_device *d; |
| 597 | struct usb_host_interface *alt; |
| 598 | int ret; |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 599 | struct m9206_inits *rc_init_seq = NULL; |
| 600 | int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber; |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 601 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 602 | deb_rc("Probing for m920x device at interface %d\n", bInterfaceNumber); |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 603 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 604 | if (bInterfaceNumber == 0) { |
| 605 | /* Single-tuner device, or first interface on |
| 606 | * multi-tuner device |
| 607 | */ |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 608 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 609 | if ((ret = dvb_usb_device_init(intf, &megasky_properties, |
| 610 | THIS_MODULE, &d)) == 0) { |
| 611 | rc_init_seq = megasky_rc_init; |
| 612 | goto found; |
| 613 | } |
| 614 | |
| 615 | if ((ret = dvb_usb_device_init(intf, |
| 616 | &digivox_mini_ii_properties, THIS_MODULE, &d)) == 0) { |
| 617 | /* No remote control, so no rc_init_seq */ |
| 618 | goto found; |
| 619 | } |
| 620 | |
| 621 | /* This configures both tuners on the TV Walker Twin */ |
| 622 | if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties, |
| 623 | THIS_MODULE, &d)) == 0) { |
| 624 | rc_init_seq = tvwalkertwin_rc_init; |
| 625 | goto found; |
| 626 | } |
| 627 | |
| 628 | return ret; |
| 629 | } else { |
| 630 | /* Another interface on a multi-tuner device */ |
| 631 | |
| 632 | /* The LifeView TV Walker Twin gets here, but struct |
| 633 | * tvwalkertwin_properties already configured both |
| 634 | * tuners, so there is nothing for us to do here |
| 635 | */ |
| 636 | |
| 637 | return -ENODEV; |
| 638 | } |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 639 | |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 640 | found: |
| 641 | alt = usb_altnum_to_altsetting(intf, 1); |
| 642 | if (alt == NULL) { |
| 643 | deb_rc("No alt found!\n"); |
| 644 | return -ENODEV; |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 645 | } |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 646 | |
| 647 | ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, |
| 648 | alt->desc.bAlternateSetting); |
| 649 | if (ret < 0) |
| 650 | return ret; |
| 651 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 652 | if ((ret = m9206_init(d, rc_init_seq)) != 0) |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 653 | return ret; |
| 654 | |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 655 | return ret; |
| 656 | } |
| 657 | |
| 658 | static struct usb_device_id m920x_table [] = { |
| 659 | { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 660 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, |
| 661 | USB_PID_MSI_DIGI_VOX_MINI_II) }, |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 662 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, |
| 663 | USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) }, |
| 664 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, |
| 665 | USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) }, |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 666 | { } /* Terminating entry */ |
| 667 | }; |
| 668 | MODULE_DEVICE_TABLE (usb, m920x_table); |
| 669 | |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 670 | static struct dvb_usb_device_properties megasky_properties = { |
Michael Krufky | 758117c | 2007-01-23 15:34:10 -0300 | [diff] [blame] | 671 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
Michael Krufky | 1f61f3b | 2006-10-07 15:03:04 -0300 | [diff] [blame] | 672 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 673 | .usb_ctrl = DEVICE_SPECIFIC, |
| 674 | .firmware = "dvb-usb-megasky-02.fw", |
| 675 | .download_firmware = m9206_firmware_download, |
| 676 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 677 | .rc_interval = 100, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 678 | .rc_key_map = megasky_rc_keys, |
| 679 | .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys), |
| 680 | .rc_query = m9206_rc_query, |
| 681 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 682 | .size_of_priv = sizeof(struct m9206_state), |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 683 | |
Aapo Tahkola | 7d1d4e6 | 2007-03-15 13:01:46 -0300 | [diff] [blame] | 684 | .identify_state = m920x_identify_state, |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 685 | .num_adapters = 1, |
| 686 | .adapter = {{ |
Michael Krufky | 758117c | 2007-01-23 15:34:10 -0300 | [diff] [blame] | 687 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 688 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 689 | |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 690 | .pid_filter_count = 8, |
| 691 | .pid_filter = m9206_pid_filter, |
| 692 | .pid_filter_ctrl = m9206_pid_filter_ctrl, |
| 693 | |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 694 | .frontend_attach = megasky_mt352_frontend_attach, |
| 695 | .tuner_attach = megasky_qt1010_tuner_attach, |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 696 | |
| 697 | .stream = { |
| 698 | .type = USB_BULK, |
| 699 | .count = 8, |
| 700 | .endpoint = 0x81, |
| 701 | .u = { |
| 702 | .bulk = { |
| 703 | .buffersize = 512, |
| 704 | } |
| 705 | } |
| 706 | }, |
| 707 | }}, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 708 | .i2c_algo = &m9206_i2c_algo, |
| 709 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 710 | .num_device_descs = 1, |
| 711 | .devices = { |
| 712 | { "MSI Mega Sky 580 DVB-T USB2.0", |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 713 | { &m920x_table[0], NULL }, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 714 | { NULL }, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 715 | } |
| 716 | } |
| 717 | }; |
| 718 | |
| 719 | static struct dvb_usb_device_properties digivox_mini_ii_properties = { |
| 720 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 721 | |
| 722 | .usb_ctrl = DEVICE_SPECIFIC, |
| 723 | .firmware = "dvb-usb-digivox-02.fw", |
| 724 | .download_firmware = m9206_firmware_download, |
| 725 | |
| 726 | .size_of_priv = sizeof(struct m9206_state), |
| 727 | |
| 728 | .identify_state = m920x_identify_state, |
| 729 | .num_adapters = 1, |
| 730 | .adapter = {{ |
| 731 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 732 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 733 | |
| 734 | .pid_filter_count = 8, |
| 735 | .pid_filter = m9206_pid_filter, |
| 736 | .pid_filter_ctrl = m9206_pid_filter_ctrl, |
| 737 | |
| 738 | .frontend_attach = digivox_tda10046_frontend_attach, |
| 739 | .tuner_attach = digivox_tda8275_tuner_attach, |
| 740 | |
| 741 | .stream = { |
| 742 | .type = USB_BULK, |
| 743 | .count = 8, |
| 744 | .endpoint = 0x81, |
| 745 | .u = { |
| 746 | .bulk = { |
| 747 | .buffersize = 0x4000, |
| 748 | } |
| 749 | } |
| 750 | }, |
| 751 | }}, |
| 752 | .i2c_algo = &m9206_i2c_algo, |
| 753 | |
| 754 | .num_device_descs = 1, |
| 755 | .devices = { |
| 756 | { "MSI DIGI VOX mini II DVB-T USB2.0", |
| 757 | { &m920x_table[1], NULL }, |
| 758 | { NULL }, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 759 | }, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 760 | } |
| 761 | }; |
| 762 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 763 | /* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net> */ |
| 764 | |
| 765 | static struct dvb_usb_device_properties tvwalkertwin_properties = { |
| 766 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 767 | |
| 768 | .usb_ctrl = DEVICE_SPECIFIC, |
| 769 | .firmware = "dvb-usb-tvwalkert.fw", |
| 770 | .download_firmware = m9206_firmware_download, |
| 771 | |
| 772 | .rc_interval = 100, |
| 773 | .rc_key_map = tvwalkertwin_rc_keys, |
| 774 | .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys), |
| 775 | .rc_query = m9206_rc_query, |
| 776 | |
| 777 | .size_of_priv = sizeof(struct m9206_state), |
| 778 | |
| 779 | .identify_state = m920x_identify_state, |
| 780 | .num_adapters = 2, |
| 781 | .adapter = { |
| 782 | { |
| 783 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 784 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 785 | |
| 786 | .pid_filter_count = 8, |
| 787 | .pid_filter = m9206_pid_filter, |
| 788 | .pid_filter_ctrl = m9206_pid_filter_ctrl, |
| 789 | |
| 790 | .frontend_attach = tvwalkertwin_0_tda10046_frontend_attach, |
| 791 | .tuner_attach = tvwalkertwin_0_tda8275_tuner_attach, |
| 792 | |
| 793 | .stream = { |
| 794 | .type = USB_BULK, |
| 795 | .count = 8, |
| 796 | .endpoint = 0x81, |
| 797 | .u = { |
| 798 | .bulk = { |
| 799 | .buffersize = 512, |
| 800 | } |
| 801 | } |
| 802 | }, |
| 803 | }, |
| 804 | { |
| 805 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 806 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 807 | |
| 808 | .pid_filter_count = 8, |
| 809 | .pid_filter = m9206_pid_filter, |
| 810 | .pid_filter_ctrl = m9206_pid_filter_ctrl, |
| 811 | |
| 812 | .frontend_attach = tvwalkertwin_1_tda10046_frontend_attach, |
| 813 | .tuner_attach = tvwalkertwin_1_tda8275_tuner_attach, |
| 814 | |
| 815 | .stream = { |
| 816 | .type = USB_BULK, |
| 817 | .count = 8, |
| 818 | .endpoint = 0x82, |
| 819 | .u = { |
| 820 | .bulk = { |
| 821 | .buffersize = 512, |
| 822 | } |
| 823 | } |
| 824 | }, |
| 825 | } |
| 826 | }, |
| 827 | .i2c_algo = &m9206_i2c_algo, |
| 828 | |
| 829 | .num_device_descs = 1, |
| 830 | .devices = { |
| 831 | { .name = "LifeView TV Walker Twin DVB-T USB2.0", |
| 832 | .cold_ids = { &m920x_table[2], NULL }, |
| 833 | .warm_ids = { &m920x_table[3], NULL }, |
| 834 | }, |
| 835 | } |
| 836 | }; |
| 837 | |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 838 | static struct usb_driver m920x_driver = { |
| 839 | .name = "dvb_usb_m920x", |
Michael Krufky | 2a2bfa7 | 2006-09-23 20:13:12 -0300 | [diff] [blame] | 840 | .probe = m920x_probe, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 841 | .disconnect = dvb_usb_device_exit, |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 842 | .id_table = m920x_table, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 843 | }; |
| 844 | |
| 845 | /* module stuff */ |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 846 | static int __init m920x_module_init(void) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 847 | { |
| 848 | int ret; |
| 849 | |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 850 | if ((ret = usb_register(&m920x_driver))) { |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 851 | err("usb_register failed. Error number %d", ret); |
| 852 | return ret; |
| 853 | } |
| 854 | |
| 855 | return 0; |
| 856 | } |
| 857 | |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 858 | static void __exit m920x_module_exit(void) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 859 | { |
| 860 | /* deregister this driver from the USB subsystem */ |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 861 | usb_deregister(&m920x_driver); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 862 | } |
| 863 | |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 864 | module_init (m920x_module_init); |
| 865 | module_exit (m920x_module_exit); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 866 | |
| 867 | MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>"); |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame^] | 868 | MODULE_DESCRIPTION("DVB Driver for ULI M920x"); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 869 | MODULE_VERSION("0.1"); |
| 870 | MODULE_LICENSE("GPL"); |