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 |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 6 | * under the terms of the GNU General Public License as published by the |
| 7 | * Free Software Foundation, version 2. |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 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" |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 19 | |
| 20 | #include <media/tuner.h> |
| 21 | #include "tuner-simple.h" |
Al Viro | fa9c13a | 2008-05-21 00:32:41 -0300 | [diff] [blame] | 22 | #include <asm/unaligned.h> |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 23 | |
| 24 | /* debug */ |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 25 | static int dvb_usb_m920x_debug; |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 26 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 27 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
| 28 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 29 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 30 | |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 31 | static int m920x_set_filter(struct dvb_usb_device *d, int type, int idx, int pid); |
| 32 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 33 | static inline int m920x_read(struct usb_device *udev, u8 request, u16 value, |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 34 | u16 index, void *data, int size) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 35 | { |
| 36 | int ret; |
| 37 | |
| 38 | ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
| 39 | request, USB_TYPE_VENDOR | USB_DIR_IN, |
| 40 | value, index, data, size, 2000); |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 41 | if (ret < 0) { |
| 42 | printk(KERN_INFO "m920x_read = error: %d\n", ret); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 43 | return ret; |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 44 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 45 | |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 46 | if (ret != size) { |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 47 | deb("m920x_read = no data\n"); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 48 | return -EIO; |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 49 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 54 | static inline int m920x_write(struct usb_device *udev, u8 request, |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 55 | u16 value, u16 index) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 56 | { |
| 57 | int ret; |
| 58 | |
| 59 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
| 60 | request, USB_TYPE_VENDOR | USB_DIR_OUT, |
| 61 | value, index, NULL, 0, 2000); |
Pierre Willenbrock | 59069e5 | 2007-03-15 13:24:29 -0300 | [diff] [blame] | 62 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 63 | return ret; |
| 64 | } |
| 65 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 66 | static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 67 | { |
Aapo Tahkola | 3847b22 | 2007-05-08 18:21:47 -0300 | [diff] [blame] | 68 | int ret = 0, i, epi, flags = 0; |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 69 | int adap_enabled[M9206_MAX_ADAPTERS] = { 0 }; |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 70 | |
| 71 | /* Remote controller init. */ |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 72 | if (d->props.rc_query) { |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 73 | deb("Initialising remote control\n"); |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 74 | while (rc_seq->address) { |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 75 | if ((ret = m920x_write(d->udev, M9206_CORE, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 76 | rc_seq->data, |
| 77 | rc_seq->address)) != 0) { |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 78 | deb("Initialising remote control failed\n"); |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 79 | return ret; |
| 80 | } |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 81 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 82 | rc_seq++; |
| 83 | } |
| 84 | |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 85 | deb("Initialising remote control success\n"); |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 86 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 87 | |
Aapo Tahkola | 3847b22 | 2007-05-08 18:21:47 -0300 | [diff] [blame] | 88 | for (i = 0; i < d->props.num_adapters; i++) |
| 89 | flags |= d->adapter[i].props.caps; |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 90 | |
Aapo Tahkola | 3847b22 | 2007-05-08 18:21:47 -0300 | [diff] [blame] | 91 | /* Some devices(Dposh) might crash if we attempt touch at all. */ |
| 92 | if (flags & DVB_USB_ADAP_HAS_PID_FILTER) { |
| 93 | for (i = 0; i < d->props.num_adapters; i++) { |
| 94 | epi = d->adapter[i].props.stream.endpoint - 0x81; |
| 95 | |
| 96 | if (epi < 0 || epi >= M9206_MAX_ADAPTERS) { |
| 97 | printk(KERN_INFO "m920x: Unexpected adapter endpoint!\n"); |
| 98 | return -EINVAL; |
| 99 | } |
| 100 | |
| 101 | adap_enabled[epi] = 1; |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 102 | } |
| 103 | |
Aapo Tahkola | 3847b22 | 2007-05-08 18:21:47 -0300 | [diff] [blame] | 104 | for (i = 0; i < M9206_MAX_ADAPTERS; i++) { |
| 105 | if (adap_enabled[i]) |
| 106 | continue; |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 107 | |
Aapo Tahkola | 3847b22 | 2007-05-08 18:21:47 -0300 | [diff] [blame] | 108 | if ((ret = m920x_set_filter(d, 0x81 + i, 0, 0x0)) != 0) |
| 109 | return ret; |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 110 | |
Aapo Tahkola | 3847b22 | 2007-05-08 18:21:47 -0300 | [diff] [blame] | 111 | if ((ret = m920x_set_filter(d, 0x81 + i, 0, 0x02f5)) != 0) |
| 112 | return ret; |
| 113 | } |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 114 | } |
| 115 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 116 | return ret; |
| 117 | } |
| 118 | |
Aapo Tahkola | 55bbe5e | 2007-05-08 12:56:54 -0300 | [diff] [blame] | 119 | static int m920x_init_ep(struct usb_interface *intf) |
| 120 | { |
| 121 | struct usb_device *udev = interface_to_usbdev(intf); |
| 122 | struct usb_host_interface *alt; |
| 123 | |
| 124 | if ((alt = usb_altnum_to_altsetting(intf, 1)) == NULL) { |
| 125 | deb("No alt found!\n"); |
| 126 | return -ENODEV; |
| 127 | } |
| 128 | |
| 129 | return usb_set_interface(udev, alt->desc.bInterfaceNumber, |
| 130 | alt->desc.bAlternateSetting); |
| 131 | } |
| 132 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 133 | static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 134 | { |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 135 | struct m920x_state *m = d->priv; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 136 | int i, ret = 0; |
| 137 | u8 rc_state[2]; |
| 138 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 139 | if ((ret = m920x_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] | 140 | goto unlock; |
| 141 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 142 | if ((ret = m920x_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] | 143 | goto unlock; |
| 144 | |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 145 | for (i = 0; i < d->props.rc_key_map_size; i++) |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 146 | if (rc5_data(&d->props.rc_key_map[i]) == rc_state[1]) { |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 147 | *event = d->props.rc_key_map[i].event; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 148 | |
| 149 | switch(rc_state[0]) { |
| 150 | case 0x80: |
| 151 | *state = REMOTE_NO_KEY_PRESSED; |
| 152 | goto unlock; |
| 153 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 154 | case 0x88: /* framing error or "invalid code" */ |
| 155 | case 0x99: |
| 156 | case 0xc0: |
| 157 | case 0xd8: |
| 158 | *state = REMOTE_NO_KEY_PRESSED; |
| 159 | m->rep_count = 0; |
| 160 | goto unlock; |
| 161 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 162 | case 0x93: |
| 163 | case 0x92: |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 164 | case 0x83: /* pinnacle PCTV310e */ |
| 165 | case 0x82: |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 166 | m->rep_count = 0; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 167 | *state = REMOTE_KEY_PRESSED; |
| 168 | goto unlock; |
| 169 | |
| 170 | case 0x91: |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 171 | case 0x81: /* pinnacle PCTV310e */ |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 172 | /* prevent immediate auto-repeat */ |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 173 | if (++m->rep_count > 2) |
| 174 | *state = REMOTE_KEY_REPEAT; |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 175 | else |
| 176 | *state = REMOTE_NO_KEY_PRESSED; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 177 | goto unlock; |
| 178 | |
| 179 | default: |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 180 | deb("Unexpected rc state %02x\n", rc_state[0]); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 181 | *state = REMOTE_NO_KEY_PRESSED; |
| 182 | goto unlock; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | if (rc_state[1] != 0) |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 187 | deb("Unknown rc key %02x\n", rc_state[1]); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 188 | |
| 189 | *state = REMOTE_NO_KEY_PRESSED; |
| 190 | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 191 | unlock: |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 192 | |
| 193 | return ret; |
| 194 | } |
| 195 | |
| 196 | /* I2C */ |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 197 | static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 198 | { |
| 199 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 200 | int i, j; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 201 | int ret = 0; |
| 202 | |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 203 | if (!num) |
| 204 | return -EINVAL; |
| 205 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 206 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 207 | return -EAGAIN; |
| 208 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 209 | for (i = 0; i < num; i++) { |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 210 | if (msg[i].flags & (I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK | I2C_M_TEN) || msg[i].len == 0) { |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 211 | /* For a 0 byte message, I think sending the address |
| 212 | * to index 0x80|0x40 would be the correct thing to |
| 213 | * do. However, zero byte messages are only used for |
| 214 | * probing, and since we don't know how to get the |
| 215 | * slave's ack, we can't probe. */ |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 216 | ret = -ENOTSUPP; |
| 217 | goto unlock; |
| 218 | } |
| 219 | /* Send START & address/RW bit */ |
| 220 | if (!(msg[i].flags & I2C_M_NOSTART)) { |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 221 | if ((ret = m920x_write(d->udev, M9206_I2C, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 222 | (msg[i].addr << 1) | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 223 | (msg[i].flags & I2C_M_RD ? 0x01 : 0), 0x80)) != 0) |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 224 | goto unlock; |
| 225 | /* Should check for ack here, if we knew how. */ |
| 226 | } |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 227 | if (msg[i].flags & I2C_M_RD) { |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 228 | for (j = 0; j < msg[i].len; j++) { |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 229 | /* Last byte of transaction? |
| 230 | * Send STOP, otherwise send ACK. */ |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 231 | int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x01; |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 232 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 233 | if ((ret = m920x_read(d->udev, M9206_I2C, 0x0, |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 234 | 0x20 | stop, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 235 | &msg[i].buf[j], 1)) != 0) |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 236 | goto unlock; |
Aapo Tahkola | 84ad757 | 2007-01-21 15:57:20 -0300 | [diff] [blame] | 237 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 238 | } else { |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 239 | for (j = 0; j < msg[i].len; j++) { |
| 240 | /* Last byte of transaction? Then send STOP. */ |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 241 | int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x00; |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 242 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 243 | if ((ret = m920x_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0) |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 244 | goto unlock; |
| 245 | /* Should check for ack here too. */ |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 246 | } |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 247 | } |
| 248 | } |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 249 | ret = num; |
Trent Piepho | d40860f | 2007-03-05 23:55:00 -0300 | [diff] [blame] | 250 | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 251 | unlock: |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 252 | mutex_unlock(&d->i2c_mutex); |
| 253 | |
| 254 | return ret; |
| 255 | } |
| 256 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 257 | static u32 m920x_i2c_func(struct i2c_adapter *adapter) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 258 | { |
| 259 | return I2C_FUNC_I2C; |
| 260 | } |
| 261 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 262 | static struct i2c_algorithm m920x_i2c_algo = { |
| 263 | .master_xfer = m920x_i2c_xfer, |
| 264 | .functionality = m920x_i2c_func, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 265 | }; |
| 266 | |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 267 | /* pid filter */ |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 268 | static int m920x_set_filter(struct dvb_usb_device *d, int type, int idx, int pid) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 269 | { |
| 270 | int ret = 0; |
| 271 | |
| 272 | if (pid >= 0x8000) |
| 273 | return -EINVAL; |
| 274 | |
| 275 | pid |= 0x8000; |
| 276 | |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 277 | if ((ret = m920x_write(d->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 278 | return ret; |
| 279 | |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 280 | if ((ret = m920x_write(d->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 281 | return ret; |
| 282 | |
| 283 | return ret; |
| 284 | } |
| 285 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 286 | static int m920x_update_filters(struct dvb_usb_adapter *adap) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 287 | { |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 288 | struct m920x_state *m = adap->dev->priv; |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 289 | int enabled = m->filtering_enabled[adap->id]; |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 290 | int i, ret = 0, filter = 0; |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 291 | int ep = adap->props.stream.endpoint; |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 292 | |
| 293 | for (i = 0; i < M9206_MAX_FILTERS; i++) |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 294 | if (m->filters[adap->id][i] == 8192) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 295 | enabled = 0; |
| 296 | |
| 297 | /* Disable all filters */ |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 298 | if ((ret = m920x_set_filter(adap->dev, ep, 1, enabled)) != 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 299 | return ret; |
| 300 | |
| 301 | for (i = 0; i < M9206_MAX_FILTERS; i++) |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 302 | if ((ret = m920x_set_filter(adap->dev, ep, i + 2, 0)) != 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 303 | return ret; |
| 304 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 305 | /* Set */ |
| 306 | if (enabled) { |
| 307 | for (i = 0; i < M9206_MAX_FILTERS; i++) { |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 308 | if (m->filters[adap->id][i] == 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 309 | continue; |
| 310 | |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 311 | if ((ret = m920x_set_filter(adap->dev, ep, filter + 2, m->filters[adap->id][i])) != 0) |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 312 | return ret; |
| 313 | |
| 314 | filter++; |
| 315 | } |
| 316 | } |
| 317 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 318 | return ret; |
| 319 | } |
| 320 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 321 | static int m920x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 322 | { |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 323 | struct m920x_state *m = adap->dev->priv; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 324 | |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 325 | m->filtering_enabled[adap->id] = onoff ? 1 : 0; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 326 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 327 | return m920x_update_filters(adap); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 328 | } |
| 329 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 330 | static int m920x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 331 | { |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 332 | struct m920x_state *m = adap->dev->priv; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 333 | |
Aapo Tahkola | 47f8df0 | 2007-05-08 12:03:55 -0300 | [diff] [blame] | 334 | m->filters[adap->id][index] = onoff ? pid : 0; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 335 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 336 | return m920x_update_filters(adap); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 337 | } |
| 338 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 339 | static int m920x_firmware_download(struct usb_device *udev, const struct firmware *fw) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 340 | { |
| 341 | u16 value, index, size; |
| 342 | u8 read[4], *buff; |
| 343 | int i, pass, ret = 0; |
| 344 | |
| 345 | buff = kmalloc(65536, GFP_KERNEL); |
Roel Kluin | 1601fb1 | 2009-09-18 20:09:52 -0300 | [diff] [blame] | 346 | if (buff == NULL) |
| 347 | return -ENOMEM; |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 348 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 349 | if ((ret = m920x_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 350 | goto done; |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 351 | deb("%x %x %x %x\n", read[0], read[1], read[2], read[3]); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 352 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 353 | if ((ret = m920x_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 354 | goto done; |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 355 | deb("%x\n", read[0]); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 356 | |
| 357 | for (pass = 0; pass < 2; pass++) { |
| 358 | for (i = 0; i + (sizeof(u16) * 3) < fw->size;) { |
Al Viro | fa9c13a | 2008-05-21 00:32:41 -0300 | [diff] [blame] | 359 | value = get_unaligned_le16(fw->data + i); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 360 | i += sizeof(u16); |
| 361 | |
Al Viro | fa9c13a | 2008-05-21 00:32:41 -0300 | [diff] [blame] | 362 | index = get_unaligned_le16(fw->data + i); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 363 | i += sizeof(u16); |
| 364 | |
Al Viro | fa9c13a | 2008-05-21 00:32:41 -0300 | [diff] [blame] | 365 | size = get_unaligned_le16(fw->data + i); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 366 | i += sizeof(u16); |
| 367 | |
| 368 | if (pass == 1) { |
| 369 | /* Will stall if using fw->data ... */ |
| 370 | memcpy(buff, fw->data + i, size); |
| 371 | |
| 372 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0), |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 373 | M9206_FW, |
| 374 | USB_TYPE_VENDOR | USB_DIR_OUT, |
| 375 | value, index, buff, size, 20); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 376 | if (ret != size) { |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 377 | deb("error while uploading fw!\n"); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 378 | ret = -EIO; |
| 379 | goto done; |
| 380 | } |
| 381 | msleep(3); |
| 382 | } |
| 383 | i += size; |
| 384 | } |
| 385 | if (i != fw->size) { |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 386 | deb("bad firmware file!\n"); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 387 | ret = -EINVAL; |
| 388 | goto done; |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | msleep(36); |
| 393 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 394 | /* m920x will disconnect itself from the bus after this. */ |
| 395 | (void) m920x_write(udev, M9206_CORE, 0x01, M9206_FW_GO); |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 396 | deb("firmware uploaded!\n"); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 397 | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 398 | done: |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 399 | kfree(buff); |
| 400 | |
| 401 | return ret; |
| 402 | } |
| 403 | |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 404 | /* Callbacks for DVB USB */ |
Aapo Tahkola | 7d1d4e6 | 2007-03-15 13:01:46 -0300 | [diff] [blame] | 405 | static int m920x_identify_state(struct usb_device *udev, |
| 406 | struct dvb_usb_device_properties *props, |
| 407 | struct dvb_usb_device_description **desc, |
| 408 | int *cold) |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 409 | { |
| 410 | struct usb_host_interface *alt; |
| 411 | |
| 412 | alt = usb_altnum_to_altsetting(usb_ifnum_to_if(udev, 0), 1); |
| 413 | *cold = (alt == NULL) ? 1 : 0; |
| 414 | |
| 415 | return 0; |
| 416 | } |
| 417 | |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 418 | /* demod configurations */ |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 419 | static int m920x_mt352_demod_init(struct dvb_frontend *fe) |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 420 | { |
Aapo Tahkola | d577ee0 | 2007-05-08 18:33:52 -0300 | [diff] [blame] | 421 | int ret; |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 422 | u8 config[] = { CONFIG, 0x3d }; |
| 423 | u8 clock[] = { CLOCK_CTL, 0x30 }; |
| 424 | u8 reset[] = { RESET, 0x80 }; |
| 425 | u8 adc_ctl[] = { ADC_CTL_1, 0x40 }; |
| 426 | u8 agc[] = { AGC_TARGET, 0x1c, 0x20 }; |
| 427 | u8 sec_agc[] = { 0x69, 0x00, 0xff, 0xff, 0x40, 0xff, 0x00, 0x40, 0x40 }; |
| 428 | u8 unk1[] = { 0x93, 0x1a }; |
| 429 | u8 unk2[] = { 0xb5, 0x7a }; |
| 430 | |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 431 | deb("Demod init!\n"); |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 432 | |
Aapo Tahkola | d577ee0 | 2007-05-08 18:33:52 -0300 | [diff] [blame] | 433 | if ((ret = mt352_write(fe, config, ARRAY_SIZE(config))) != 0) |
| 434 | return ret; |
| 435 | if ((ret = mt352_write(fe, clock, ARRAY_SIZE(clock))) != 0) |
| 436 | return ret; |
| 437 | if ((ret = mt352_write(fe, reset, ARRAY_SIZE(reset))) != 0) |
| 438 | return ret; |
| 439 | if ((ret = mt352_write(fe, adc_ctl, ARRAY_SIZE(adc_ctl))) != 0) |
| 440 | return ret; |
| 441 | if ((ret = mt352_write(fe, agc, ARRAY_SIZE(agc))) != 0) |
| 442 | return ret; |
| 443 | if ((ret = mt352_write(fe, sec_agc, ARRAY_SIZE(sec_agc))) != 0) |
| 444 | return ret; |
| 445 | if ((ret = mt352_write(fe, unk1, ARRAY_SIZE(unk1))) != 0) |
| 446 | return ret; |
| 447 | if ((ret = mt352_write(fe, unk2, ARRAY_SIZE(unk2))) != 0) |
| 448 | return ret; |
| 449 | |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 450 | return 0; |
| 451 | } |
| 452 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 453 | static struct mt352_config m920x_mt352_config = { |
Aapo Tahkola | 2624701 | 2007-03-05 18:23:19 -0300 | [diff] [blame] | 454 | .demod_address = 0x0f, |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 455 | .no_tuner = 1, |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 456 | .demod_init = m920x_mt352_demod_init, |
Michael Krufky | e16c1f5 | 2007-01-23 15:00:42 -0300 | [diff] [blame] | 457 | }; |
| 458 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 459 | static struct tda1004x_config m920x_tda10046_08_config = { |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 460 | .demod_address = 0x08, |
| 461 | .invert = 0, |
| 462 | .invert_oclk = 0, |
| 463 | .ts_mode = TDA10046_TS_SERIAL, |
| 464 | .xtal_freq = TDA10046_XTAL_16M, |
| 465 | .if_freq = TDA10046_FREQ_045, |
| 466 | .agc_config = TDA10046_AGC_TDA827X, |
| 467 | .gpio_config = TDA10046_GPTRI, |
| 468 | .request_firmware = NULL, |
| 469 | }; |
| 470 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 471 | static struct tda1004x_config m920x_tda10046_0b_config = { |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 472 | .demod_address = 0x0b, |
| 473 | .invert = 0, |
| 474 | .invert_oclk = 0, |
| 475 | .ts_mode = TDA10046_TS_SERIAL, |
| 476 | .xtal_freq = TDA10046_XTAL_16M, |
| 477 | .if_freq = TDA10046_FREQ_045, |
| 478 | .agc_config = TDA10046_AGC_TDA827X, |
| 479 | .gpio_config = TDA10046_GPTRI, |
| 480 | .request_firmware = NULL, /* uses firmware EEPROM */ |
| 481 | }; |
| 482 | |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 483 | /* tuner configurations */ |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 484 | static struct qt1010_config m920x_qt1010_config = { |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 485 | .i2c_address = 0x62 |
| 486 | }; |
| 487 | |
| 488 | /* Callbacks for DVB USB */ |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 489 | static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 490 | { |
Harvey Harrison | 708bebd | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 491 | deb("%s\n",__func__); |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 492 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 493 | if ((adap->fe = dvb_attach(mt352_attach, |
| 494 | &m920x_mt352_config, |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 495 | &adap->dev->i2c_adap)) == NULL) |
| 496 | return -EIO; |
| 497 | |
| 498 | return 0; |
| 499 | } |
| 500 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 501 | static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap) |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 502 | { |
Harvey Harrison | 708bebd | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 503 | deb("%s\n",__func__); |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 504 | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 505 | if ((adap->fe = dvb_attach(tda10046_attach, |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 506 | &m920x_tda10046_08_config, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 507 | &adap->dev->i2c_adap)) == NULL) |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 508 | return -EIO; |
| 509 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 510 | return 0; |
| 511 | } |
| 512 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 513 | static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap) |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 514 | { |
Harvey Harrison | 708bebd | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 515 | deb("%s\n",__func__); |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 516 | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 517 | if ((adap->fe = dvb_attach(tda10046_attach, |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 518 | &m920x_tda10046_0b_config, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 519 | &adap->dev->i2c_adap)) == NULL) |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 520 | return -EIO; |
| 521 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 522 | return 0; |
| 523 | } |
| 524 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 525 | static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap) |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 526 | { |
Harvey Harrison | 708bebd | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 527 | deb("%s\n",__func__); |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 528 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 529 | if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL) |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 530 | return -ENODEV; |
| 531 | |
| 532 | return 0; |
| 533 | } |
| 534 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 535 | static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap) |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 536 | { |
Harvey Harrison | 708bebd | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 537 | deb("%s\n",__func__); |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 538 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 539 | if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL) |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 540 | return -ENODEV; |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 541 | |
| 542 | return 0; |
| 543 | } |
| 544 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 545 | static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap) |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 546 | { |
Harvey Harrison | 708bebd | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 547 | deb("%s\n",__func__); |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 548 | |
Aapo Tahkola | 9ad4eef | 2007-04-20 13:34:25 -0300 | [diff] [blame] | 549 | if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL) |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 550 | return -ENODEV; |
| 551 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 552 | return 0; |
| 553 | } |
| 554 | |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 555 | static int m920x_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) |
| 556 | { |
| 557 | dvb_attach(simple_tuner_attach, adap->fe, |
| 558 | &adap->dev->i2c_adap, 0x61, |
| 559 | TUNER_PHILIPS_FMD1216ME_MK3); |
| 560 | return 0; |
| 561 | } |
| 562 | |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 563 | /* device-specific initialization */ |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 564 | static struct m920x_inits megasky_rc_init [] = { |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 565 | { M9206_RC_INIT2, 0xa8 }, |
| 566 | { M9206_RC_INIT1, 0x51 }, |
| 567 | { } /* terminating entry */ |
| 568 | }; |
| 569 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 570 | static struct m920x_inits tvwalkertwin_rc_init [] = { |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 571 | { M9206_RC_INIT2, 0x00 }, |
| 572 | { M9206_RC_INIT1, 0xef }, |
| 573 | { 0xff28, 0x00 }, |
| 574 | { 0xff23, 0x00 }, |
| 575 | { 0xff21, 0x30 }, |
| 576 | { } /* terminating entry */ |
| 577 | }; |
| 578 | |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 579 | static struct m920x_inits pinnacle310e_init[] = { |
| 580 | /* without these the tuner don't work */ |
| 581 | { 0xff20, 0x9b }, |
| 582 | { 0xff22, 0x70 }, |
| 583 | |
| 584 | /* rc settings */ |
| 585 | { 0xff50, 0x80 }, |
| 586 | { M9206_RC_INIT1, 0x00 }, |
| 587 | { M9206_RC_INIT2, 0xff }, |
| 588 | { } /* terminating entry */ |
| 589 | }; |
| 590 | |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 591 | /* ir keymaps */ |
Mauro Carvalho Chehab | e27e971 | 2010-04-01 21:35:32 -0300 | [diff] [blame] | 592 | static struct dvb_usb_rc_key ir_codes_megasky_table [] = { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 593 | { 0x0012, KEY_POWER }, |
| 594 | { 0x001e, KEY_CYCLEWINDOWS }, /* min/max */ |
| 595 | { 0x0002, KEY_CHANNELUP }, |
| 596 | { 0x0005, KEY_CHANNELDOWN }, |
| 597 | { 0x0003, KEY_VOLUMEUP }, |
| 598 | { 0x0006, KEY_VOLUMEDOWN }, |
| 599 | { 0x0004, KEY_MUTE }, |
| 600 | { 0x0007, KEY_OK }, /* TS */ |
| 601 | { 0x0008, KEY_STOP }, |
| 602 | { 0x0009, KEY_MENU }, /* swap */ |
| 603 | { 0x000a, KEY_REWIND }, |
| 604 | { 0x001b, KEY_PAUSE }, |
| 605 | { 0x001f, KEY_FASTFORWARD }, |
| 606 | { 0x000c, KEY_RECORD }, |
| 607 | { 0x000d, KEY_CAMERA }, /* screenshot */ |
| 608 | { 0x000e, KEY_COFFEE }, /* "MTS" */ |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 609 | }; |
| 610 | |
Mauro Carvalho Chehab | e27e971 | 2010-04-01 21:35:32 -0300 | [diff] [blame] | 611 | static struct dvb_usb_rc_key ir_codes_tvwalkertwin_table [] = { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 612 | { 0x0001, KEY_ZOOM }, /* Full Screen */ |
| 613 | { 0x0002, KEY_CAMERA }, /* snapshot */ |
| 614 | { 0x0003, KEY_MUTE }, |
| 615 | { 0x0004, KEY_REWIND }, |
| 616 | { 0x0005, KEY_PLAYPAUSE }, /* Play/Pause */ |
| 617 | { 0x0006, KEY_FASTFORWARD }, |
| 618 | { 0x0007, KEY_RECORD }, |
| 619 | { 0x0008, KEY_STOP }, |
| 620 | { 0x0009, KEY_TIME }, /* Timeshift */ |
| 621 | { 0x000c, KEY_COFFEE }, /* Recall */ |
| 622 | { 0x000e, KEY_CHANNELUP }, |
| 623 | { 0x0012, KEY_POWER }, |
| 624 | { 0x0015, KEY_MENU }, /* source */ |
| 625 | { 0x0018, KEY_CYCLEWINDOWS }, /* TWIN PIP */ |
| 626 | { 0x001a, KEY_CHANNELDOWN }, |
| 627 | { 0x001b, KEY_VOLUMEDOWN }, |
| 628 | { 0x001e, KEY_VOLUMEUP }, |
Michael Krufky | 5afb707 | 2007-03-26 16:35:29 -0300 | [diff] [blame] | 629 | }; |
| 630 | |
Mauro Carvalho Chehab | e27e971 | 2010-04-01 21:35:32 -0300 | [diff] [blame] | 631 | static struct dvb_usb_rc_key ir_codes_pinnacle310e_table[] = { |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 632 | { 0x16, KEY_POWER }, |
| 633 | { 0x17, KEY_FAVORITES }, |
| 634 | { 0x0f, KEY_TEXT }, |
| 635 | { 0x48, KEY_MEDIA }, /* preview */ |
| 636 | { 0x1c, KEY_EPG }, |
| 637 | { 0x04, KEY_LIST }, /* record list */ |
| 638 | { 0x03, KEY_1 }, |
| 639 | { 0x01, KEY_2 }, |
| 640 | { 0x06, KEY_3 }, |
| 641 | { 0x09, KEY_4 }, |
| 642 | { 0x1d, KEY_5 }, |
| 643 | { 0x1f, KEY_6 }, |
| 644 | { 0x0d, KEY_7 }, |
| 645 | { 0x19, KEY_8 }, |
| 646 | { 0x1b, KEY_9 }, |
| 647 | { 0x15, KEY_0 }, |
| 648 | { 0x0c, KEY_CANCEL }, |
| 649 | { 0x4a, KEY_CLEAR }, |
| 650 | { 0x13, KEY_BACK }, |
| 651 | { 0x00, KEY_TAB }, |
| 652 | { 0x4b, KEY_UP }, |
| 653 | { 0x4e, KEY_LEFT }, |
| 654 | { 0x52, KEY_RIGHT }, |
| 655 | { 0x51, KEY_DOWN }, |
| 656 | { 0x4f, KEY_ENTER }, /* could also be KEY_OK */ |
| 657 | { 0x1e, KEY_VOLUMEUP }, |
| 658 | { 0x0a, KEY_VOLUMEDOWN }, |
| 659 | { 0x05, KEY_CHANNELUP }, |
| 660 | { 0x02, KEY_CHANNELDOWN }, |
| 661 | { 0x11, KEY_RECORD }, |
| 662 | { 0x14, KEY_PLAY }, |
| 663 | { 0x4c, KEY_PAUSE }, |
| 664 | { 0x1a, KEY_STOP }, |
| 665 | { 0x40, KEY_REWIND }, |
| 666 | { 0x12, KEY_FASTFORWARD }, |
| 667 | { 0x41, KEY_PREVIOUSSONG }, /* Replay */ |
| 668 | { 0x42, KEY_NEXTSONG }, /* Skip */ |
| 669 | { 0x54, KEY_CAMERA }, /* Capture */ |
| 670 | /* { 0x50, KEY_SAP }, */ /* Sap */ |
| 671 | { 0x47, KEY_CYCLEWINDOWS }, /* Pip */ |
| 672 | { 0x4d, KEY_SCREEN }, /* FullScreen */ |
| 673 | { 0x08, KEY_SUBTITLE }, |
| 674 | { 0x0e, KEY_MUTE }, |
| 675 | /* { 0x49, KEY_LR }, */ /* L/R */ |
| 676 | { 0x07, KEY_SLEEP }, /* Hibernate */ |
| 677 | { 0x08, KEY_MEDIA }, /* A/V */ |
| 678 | { 0x0e, KEY_MENU }, /* Recall */ |
| 679 | { 0x45, KEY_ZOOMIN }, |
| 680 | { 0x46, KEY_ZOOMOUT }, |
| 681 | { 0x18, KEY_TV }, /* Red */ |
| 682 | { 0x53, KEY_VCR }, /* Green */ |
| 683 | { 0x5e, KEY_SAT }, /* Yellow */ |
| 684 | { 0x5f, KEY_PLAYER }, /* Blue */ |
| 685 | }; |
| 686 | |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 687 | /* DVB USB Driver stuff */ |
| 688 | static struct dvb_usb_device_properties megasky_properties; |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 689 | static struct dvb_usb_device_properties digivox_mini_ii_properties; |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 690 | static struct dvb_usb_device_properties tvwalkertwin_properties; |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 691 | static struct dvb_usb_device_properties dposh_properties; |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 692 | static struct dvb_usb_device_properties pinnacle_pctv310e_properties; |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 693 | |
Michael Krufky | fa94805 | 2007-01-21 15:57:48 -0300 | [diff] [blame] | 694 | static int m920x_probe(struct usb_interface *intf, |
| 695 | const struct usb_device_id *id) |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 696 | { |
Aapo Tahkola | 55bbe5e | 2007-05-08 12:56:54 -0300 | [diff] [blame] | 697 | struct dvb_usb_device *d = NULL; |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 698 | int ret; |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 699 | struct m920x_inits *rc_init_seq = NULL; |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 700 | int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber; |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 701 | |
Aapo Tahkola | bf2b4f6 | 2007-03-26 16:59:16 -0300 | [diff] [blame] | 702 | deb("Probing for m920x device at interface %d\n", bInterfaceNumber); |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 703 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 704 | if (bInterfaceNumber == 0) { |
| 705 | /* Single-tuner device, or first interface on |
| 706 | * multi-tuner device |
| 707 | */ |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 708 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 709 | ret = dvb_usb_device_init(intf, &megasky_properties, |
| 710 | THIS_MODULE, &d, adapter_nr); |
| 711 | if (ret == 0) { |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 712 | rc_init_seq = megasky_rc_init; |
| 713 | goto found; |
| 714 | } |
| 715 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 716 | ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, |
| 717 | THIS_MODULE, &d, adapter_nr); |
| 718 | if (ret == 0) { |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 719 | /* No remote control, so no rc_init_seq */ |
| 720 | goto found; |
| 721 | } |
| 722 | |
| 723 | /* This configures both tuners on the TV Walker Twin */ |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 724 | ret = dvb_usb_device_init(intf, &tvwalkertwin_properties, |
| 725 | THIS_MODULE, &d, adapter_nr); |
| 726 | if (ret == 0) { |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 727 | rc_init_seq = tvwalkertwin_rc_init; |
| 728 | goto found; |
| 729 | } |
| 730 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 731 | ret = dvb_usb_device_init(intf, &dposh_properties, |
| 732 | THIS_MODULE, &d, adapter_nr); |
| 733 | if (ret == 0) { |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 734 | /* Remote controller not supported yet. */ |
| 735 | goto found; |
| 736 | } |
| 737 | |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 738 | ret = dvb_usb_device_init(intf, &pinnacle_pctv310e_properties, |
| 739 | THIS_MODULE, &d, adapter_nr); |
| 740 | if (ret == 0) { |
| 741 | rc_init_seq = pinnacle310e_init; |
| 742 | goto found; |
| 743 | } |
| 744 | |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 745 | return ret; |
| 746 | } else { |
| 747 | /* Another interface on a multi-tuner device */ |
| 748 | |
| 749 | /* The LifeView TV Walker Twin gets here, but struct |
| 750 | * tvwalkertwin_properties already configured both |
| 751 | * tuners, so there is nothing for us to do here |
| 752 | */ |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 753 | } |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 754 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 755 | found: |
Aapo Tahkola | 55bbe5e | 2007-05-08 12:56:54 -0300 | [diff] [blame] | 756 | if ((ret = m920x_init_ep(intf)) < 0) |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 757 | return ret; |
| 758 | |
Aapo Tahkola | 55bbe5e | 2007-05-08 12:56:54 -0300 | [diff] [blame] | 759 | if (d && (ret = m920x_init(d, rc_init_seq)) != 0) |
Aapo Tahkola | 480ac76 | 2007-03-05 18:54:27 -0300 | [diff] [blame] | 760 | return ret; |
| 761 | |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 762 | return ret; |
| 763 | } |
| 764 | |
| 765 | static struct usb_device_id m920x_table [] = { |
| 766 | { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 767 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, |
| 768 | USB_PID_MSI_DIGI_VOX_MINI_II) }, |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 769 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, |
| 770 | USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) }, |
| 771 | { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, |
| 772 | USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) }, |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 773 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) }, |
| 774 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) }, |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 775 | { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_PINNACLE_PCTV310E) }, |
Michael Krufky | 26f48ea | 2006-09-28 01:46:49 -0300 | [diff] [blame] | 776 | { } /* Terminating entry */ |
| 777 | }; |
| 778 | MODULE_DEVICE_TABLE (usb, m920x_table); |
| 779 | |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 780 | static struct dvb_usb_device_properties megasky_properties = { |
Michael Krufky | 758117c | 2007-01-23 15:34:10 -0300 | [diff] [blame] | 781 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
Michael Krufky | 1f61f3b | 2006-10-07 15:03:04 -0300 | [diff] [blame] | 782 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 783 | .usb_ctrl = DEVICE_SPECIFIC, |
| 784 | .firmware = "dvb-usb-megasky-02.fw", |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 785 | .download_firmware = m920x_firmware_download, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 786 | |
Aapo Tahkola | e2adbecf7 | 2006-09-28 00:47:51 -0300 | [diff] [blame] | 787 | .rc_interval = 100, |
Mauro Carvalho Chehab | e27e971 | 2010-04-01 21:35:32 -0300 | [diff] [blame] | 788 | .rc_key_map = ir_codes_megasky_table, |
| 789 | .rc_key_map_size = ARRAY_SIZE(ir_codes_megasky_table), |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 790 | .rc_query = m920x_rc_query, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 791 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 792 | .size_of_priv = sizeof(struct m920x_state), |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 793 | |
Aapo Tahkola | 7d1d4e6 | 2007-03-15 13:01:46 -0300 | [diff] [blame] | 794 | .identify_state = m920x_identify_state, |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 795 | .num_adapters = 1, |
| 796 | .adapter = {{ |
Michael Krufky | 758117c | 2007-01-23 15:34:10 -0300 | [diff] [blame] | 797 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 798 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 799 | |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 800 | .pid_filter_count = 8, |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 801 | .pid_filter = m920x_pid_filter, |
| 802 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 803 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 804 | .frontend_attach = m920x_mt352_frontend_attach, |
| 805 | .tuner_attach = m920x_qt1010_tuner_attach, |
Michael Krufky | 01cb34d | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 806 | |
| 807 | .stream = { |
| 808 | .type = USB_BULK, |
| 809 | .count = 8, |
| 810 | .endpoint = 0x81, |
| 811 | .u = { |
| 812 | .bulk = { |
| 813 | .buffersize = 512, |
| 814 | } |
| 815 | } |
| 816 | }, |
| 817 | }}, |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 818 | .i2c_algo = &m920x_i2c_algo, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 819 | |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 820 | .num_device_descs = 1, |
| 821 | .devices = { |
| 822 | { "MSI Mega Sky 580 DVB-T USB2.0", |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 823 | { &m920x_table[0], NULL }, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 824 | { NULL }, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 825 | } |
| 826 | } |
| 827 | }; |
| 828 | |
| 829 | static struct dvb_usb_device_properties digivox_mini_ii_properties = { |
| 830 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 831 | |
| 832 | .usb_ctrl = DEVICE_SPECIFIC, |
| 833 | .firmware = "dvb-usb-digivox-02.fw", |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 834 | .download_firmware = m920x_firmware_download, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 835 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 836 | .size_of_priv = sizeof(struct m920x_state), |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 837 | |
| 838 | .identify_state = m920x_identify_state, |
| 839 | .num_adapters = 1, |
| 840 | .adapter = {{ |
| 841 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 842 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 843 | |
| 844 | .pid_filter_count = 8, |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 845 | .pid_filter = m920x_pid_filter, |
| 846 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 847 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 848 | .frontend_attach = m920x_tda10046_08_frontend_attach, |
| 849 | .tuner_attach = m920x_tda8275_60_tuner_attach, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 850 | |
| 851 | .stream = { |
| 852 | .type = USB_BULK, |
| 853 | .count = 8, |
| 854 | .endpoint = 0x81, |
| 855 | .u = { |
| 856 | .bulk = { |
| 857 | .buffersize = 0x4000, |
| 858 | } |
| 859 | } |
| 860 | }, |
| 861 | }}, |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 862 | .i2c_algo = &m920x_i2c_algo, |
Pierre Willenbrock | d4ca23b | 2007-03-18 19:54:07 -0300 | [diff] [blame] | 863 | |
| 864 | .num_device_descs = 1, |
| 865 | .devices = { |
| 866 | { "MSI DIGI VOX mini II DVB-T USB2.0", |
| 867 | { &m920x_table[1], NULL }, |
| 868 | { NULL }, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 869 | }, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 870 | } |
| 871 | }; |
| 872 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 873 | /* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net> |
| 874 | * |
| 875 | * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A |
| 876 | * TDA10046 #0 is located at i2c address 0x08 |
Aapo Tahkola | 3ab3b69 | 2007-05-08 18:23:38 -0300 | [diff] [blame] | 877 | * TDA10046 #1 is located at i2c address 0x0b |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 878 | * TDA8275A #0 is located at i2c address 0x60 |
Aapo Tahkola | 3ab3b69 | 2007-05-08 18:23:38 -0300 | [diff] [blame] | 879 | * TDA8275A #1 is located at i2c address 0x61 |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 880 | */ |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 881 | static struct dvb_usb_device_properties tvwalkertwin_properties = { |
| 882 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 883 | |
| 884 | .usb_ctrl = DEVICE_SPECIFIC, |
| 885 | .firmware = "dvb-usb-tvwalkert.fw", |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 886 | .download_firmware = m920x_firmware_download, |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 887 | |
| 888 | .rc_interval = 100, |
Mauro Carvalho Chehab | e27e971 | 2010-04-01 21:35:32 -0300 | [diff] [blame] | 889 | .rc_key_map = ir_codes_tvwalkertwin_table, |
| 890 | .rc_key_map_size = ARRAY_SIZE(ir_codes_tvwalkertwin_table), |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 891 | .rc_query = m920x_rc_query, |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 892 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 893 | .size_of_priv = sizeof(struct m920x_state), |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 894 | |
| 895 | .identify_state = m920x_identify_state, |
Aapo Tahkola | 3ab3b69 | 2007-05-08 18:23:38 -0300 | [diff] [blame] | 896 | .num_adapters = 2, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 897 | .adapter = {{ |
| 898 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 899 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 900 | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 901 | .pid_filter_count = 8, |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 902 | .pid_filter = m920x_pid_filter, |
| 903 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 904 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 905 | .frontend_attach = m920x_tda10046_08_frontend_attach, |
| 906 | .tuner_attach = m920x_tda8275_60_tuner_attach, |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 907 | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 908 | .stream = { |
| 909 | .type = USB_BULK, |
| 910 | .count = 8, |
| 911 | .endpoint = 0x81, |
| 912 | .u = { |
| 913 | .bulk = { |
| 914 | .buffersize = 512, |
| 915 | } |
| 916 | } |
| 917 | }},{ |
| 918 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 919 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 920 | |
| 921 | .pid_filter_count = 8, |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 922 | .pid_filter = m920x_pid_filter, |
| 923 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 924 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 925 | .frontend_attach = m920x_tda10046_0b_frontend_attach, |
| 926 | .tuner_attach = m920x_tda8275_61_tuner_attach, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 927 | |
| 928 | .stream = { |
| 929 | .type = USB_BULK, |
| 930 | .count = 8, |
| 931 | .endpoint = 0x82, |
| 932 | .u = { |
| 933 | .bulk = { |
| 934 | .buffersize = 512, |
| 935 | } |
| 936 | } |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 937 | }, |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 938 | }}, |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 939 | .i2c_algo = &m920x_i2c_algo, |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 940 | |
| 941 | .num_device_descs = 1, |
| 942 | .devices = { |
| 943 | { .name = "LifeView TV Walker Twin DVB-T USB2.0", |
| 944 | .cold_ids = { &m920x_table[2], NULL }, |
| 945 | .warm_ids = { &m920x_table[3], NULL }, |
| 946 | }, |
| 947 | } |
| 948 | }; |
| 949 | |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 950 | static struct dvb_usb_device_properties dposh_properties = { |
| 951 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 952 | |
| 953 | .usb_ctrl = DEVICE_SPECIFIC, |
| 954 | .firmware = "dvb-usb-dposh-01.fw", |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 955 | .download_firmware = m920x_firmware_download, |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 956 | |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 957 | .size_of_priv = sizeof(struct m920x_state), |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 958 | |
| 959 | .identify_state = m920x_identify_state, |
| 960 | .num_adapters = 1, |
| 961 | .adapter = {{ |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 962 | /* Hardware pid filters don't work with this device/firmware */ |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 963 | |
Michael Krufky | e7b419b | 2007-03-26 16:39:20 -0300 | [diff] [blame] | 964 | .frontend_attach = m920x_mt352_frontend_attach, |
| 965 | .tuner_attach = m920x_qt1010_tuner_attach, |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 966 | |
Michael Krufky | d3911ea | 2007-03-22 19:03:37 -0300 | [diff] [blame] | 967 | .stream = { |
| 968 | .type = USB_BULK, |
| 969 | .count = 8, |
| 970 | .endpoint = 0x81, |
| 971 | .u = { |
| 972 | .bulk = { |
| 973 | .buffersize = 512, |
| 974 | } |
| 975 | } |
| 976 | }, |
| 977 | }}, |
Aapo Tahkola | 4fd74a7 | 2007-03-26 17:05:59 -0300 | [diff] [blame] | 978 | .i2c_algo = &m920x_i2c_algo, |
Aapo Tahkola | f8e0bd5 | 2007-03-22 17:37:58 -0300 | [diff] [blame] | 979 | |
| 980 | .num_device_descs = 1, |
| 981 | .devices = { |
| 982 | { .name = "Dposh DVB-T USB2.0", |
| 983 | .cold_ids = { &m920x_table[4], NULL }, |
| 984 | .warm_ids = { &m920x_table[5], NULL }, |
| 985 | }, |
| 986 | } |
| 987 | }; |
| 988 | |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 989 | static struct dvb_usb_device_properties pinnacle_pctv310e_properties = { |
| 990 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 991 | |
| 992 | .usb_ctrl = DEVICE_SPECIFIC, |
| 993 | .download_firmware = NULL, |
| 994 | |
| 995 | .rc_interval = 100, |
Mauro Carvalho Chehab | e27e971 | 2010-04-01 21:35:32 -0300 | [diff] [blame] | 996 | .rc_key_map = ir_codes_pinnacle310e_table, |
| 997 | .rc_key_map_size = ARRAY_SIZE(ir_codes_pinnacle310e_table), |
Massimo Del Fedele | 3d36f5c | 2009-10-24 13:12:37 -0300 | [diff] [blame] | 998 | .rc_query = m920x_rc_query, |
| 999 | |
| 1000 | .size_of_priv = sizeof(struct m920x_state), |
| 1001 | |
| 1002 | .identify_state = m920x_identify_state, |
| 1003 | .num_adapters = 1, |
| 1004 | .adapter = {{ |
| 1005 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | |
| 1006 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, |
| 1007 | |
| 1008 | .pid_filter_count = 8, |
| 1009 | .pid_filter = m920x_pid_filter, |
| 1010 | .pid_filter_ctrl = m920x_pid_filter_ctrl, |
| 1011 | |
| 1012 | .frontend_attach = m920x_mt352_frontend_attach, |
| 1013 | .tuner_attach = m920x_fmd1216me_tuner_attach, |
| 1014 | |
| 1015 | .stream = { |
| 1016 | .type = USB_ISOC, |
| 1017 | .count = 5, |
| 1018 | .endpoint = 0x84, |
| 1019 | .u = { |
| 1020 | .isoc = { |
| 1021 | .framesperurb = 128, |
| 1022 | .framesize = 564, |
| 1023 | .interval = 1, |
| 1024 | } |
| 1025 | } |
| 1026 | }, |
| 1027 | } }, |
| 1028 | .i2c_algo = &m920x_i2c_algo, |
| 1029 | |
| 1030 | .num_device_descs = 1, |
| 1031 | .devices = { |
| 1032 | { "Pinnacle PCTV 310e", |
| 1033 | { &m920x_table[6], NULL }, |
| 1034 | { NULL }, |
| 1035 | } |
| 1036 | } |
| 1037 | }; |
| 1038 | |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 1039 | static struct usb_driver m920x_driver = { |
| 1040 | .name = "dvb_usb_m920x", |
Michael Krufky | 2a2bfa7 | 2006-09-23 20:13:12 -0300 | [diff] [blame] | 1041 | .probe = m920x_probe, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1042 | .disconnect = dvb_usb_device_exit, |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 1043 | .id_table = m920x_table, |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1044 | }; |
| 1045 | |
| 1046 | /* module stuff */ |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 1047 | static int __init m920x_module_init(void) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1048 | { |
| 1049 | int ret; |
| 1050 | |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 1051 | if ((ret = usb_register(&m920x_driver))) { |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1052 | err("usb_register failed. Error number %d", ret); |
| 1053 | return ret; |
| 1054 | } |
| 1055 | |
| 1056 | return 0; |
| 1057 | } |
| 1058 | |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 1059 | static void __exit m920x_module_exit(void) |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1060 | { |
| 1061 | /* deregister this driver from the USB subsystem */ |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 1062 | usb_deregister(&m920x_driver); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1063 | } |
| 1064 | |
Michael Krufky | baa2ed0 | 2006-09-23 20:01:29 -0300 | [diff] [blame] | 1065 | module_init (m920x_module_init); |
| 1066 | module_exit (m920x_module_exit); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1067 | |
| 1068 | MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>"); |
Nick Andrew | aa50ec2 | 2007-03-22 17:09:35 -0300 | [diff] [blame] | 1069 | MODULE_DESCRIPTION("DVB Driver for ULI M920x"); |
Aapo Tahkola | 5fecd9f | 2006-09-23 20:00:41 -0300 | [diff] [blame] | 1070 | MODULE_VERSION("0.1"); |
| 1071 | MODULE_LICENSE("GPL"); |
Michael Krufky | ce9c275 | 2007-03-22 17:18:26 -0300 | [diff] [blame] | 1072 | |
| 1073 | /* |
| 1074 | * Local variables: |
| 1075 | * c-basic-offset: 8 |
| 1076 | */ |