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