| .. | .. |
|---|
| 8 | 8 | #include <linux/module.h> |
|---|
| 9 | 9 | #include "rc-core-priv.h" |
|---|
| 10 | 10 | |
|---|
| 11 | | -#define IMON_UNIT 415662 /* ns */ |
|---|
| 11 | +#define IMON_UNIT 416 /* us */ |
|---|
| 12 | 12 | #define IMON_BITS 30 |
|---|
| 13 | 13 | #define IMON_CHKBITS (BIT(30) | BIT(25) | BIT(24) | BIT(22) | \ |
|---|
| 14 | 14 | BIT(21) | BIT(20) | BIT(19) | BIT(18) | \ |
|---|
| .. | .. |
|---|
| 70 | 70 | } |
|---|
| 71 | 71 | |
|---|
| 72 | 72 | if (!imon->stick_keyboard) { |
|---|
| 73 | | - struct lirc_scancode lsc = { |
|---|
| 74 | | - .scancode = imon->bits, |
|---|
| 75 | | - .rc_proto = RC_PROTO_IMON, |
|---|
| 76 | | - }; |
|---|
| 73 | + input_report_rel(dev->input_dev, REL_X, rel_x); |
|---|
| 74 | + input_report_rel(dev->input_dev, REL_Y, rel_y); |
|---|
| 77 | 75 | |
|---|
| 78 | | - ir_lirc_scancode_event(dev, &lsc); |
|---|
| 79 | | - |
|---|
| 80 | | - input_event(imon->idev, EV_MSC, MSC_SCAN, imon->bits); |
|---|
| 81 | | - |
|---|
| 82 | | - input_report_rel(imon->idev, REL_X, rel_x); |
|---|
| 83 | | - input_report_rel(imon->idev, REL_Y, rel_y); |
|---|
| 84 | | - |
|---|
| 85 | | - input_report_key(imon->idev, BTN_LEFT, |
|---|
| 76 | + input_report_key(dev->input_dev, BTN_LEFT, |
|---|
| 86 | 77 | (imon->bits & 0x00010000) != 0); |
|---|
| 87 | | - input_report_key(imon->idev, BTN_RIGHT, |
|---|
| 78 | + input_report_key(dev->input_dev, BTN_RIGHT, |
|---|
| 88 | 79 | (imon->bits & 0x00040000) != 0); |
|---|
| 89 | | - input_sync(imon->idev); |
|---|
| 90 | | - return; |
|---|
| 91 | 80 | } |
|---|
| 92 | 81 | } |
|---|
| 93 | 82 | |
|---|
| .. | .. |
|---|
| 113 | 102 | |
|---|
| 114 | 103 | dev_dbg(&dev->dev, |
|---|
| 115 | 104 | "iMON decode started at state %d bitno %d (%uus %s)\n", |
|---|
| 116 | | - data->state, data->count, TO_US(ev.duration), |
|---|
| 117 | | - TO_STR(ev.pulse)); |
|---|
| 105 | + data->state, data->count, ev.duration, TO_STR(ev.pulse)); |
|---|
| 118 | 106 | |
|---|
| 119 | 107 | /* |
|---|
| 120 | 108 | * Since iMON protocol is a series of bits, if at any point |
|---|
| .. | .. |
|---|
| 127 | 115 | * we're at a new scancode. |
|---|
| 128 | 116 | */ |
|---|
| 129 | 117 | if (data->state == STATE_ERROR) { |
|---|
| 130 | | - if (!ev.pulse && ev.duration > MS_TO_NS(10)) |
|---|
| 118 | + if (!ev.pulse && ev.duration > MS_TO_US(10)) |
|---|
| 131 | 119 | data->state = STATE_INACTIVE; |
|---|
| 132 | 120 | return 0; |
|---|
| 133 | 121 | } |
|---|
| .. | .. |
|---|
| 180 | 168 | err_out: |
|---|
| 181 | 169 | dev_dbg(&dev->dev, |
|---|
| 182 | 170 | "iMON decode failed at state %d bitno %d (%uus %s)\n", |
|---|
| 183 | | - data->state, data->count, TO_US(ev.duration), |
|---|
| 184 | | - TO_STR(ev.pulse)); |
|---|
| 171 | + data->state, data->count, ev.duration, TO_STR(ev.pulse)); |
|---|
| 185 | 172 | |
|---|
| 186 | 173 | data->state = STATE_ERROR; |
|---|
| 187 | 174 | |
|---|
| .. | .. |
|---|
| 243 | 230 | |
|---|
| 244 | 231 | static int ir_imon_register(struct rc_dev *dev) |
|---|
| 245 | 232 | { |
|---|
| 246 | | - struct input_dev *idev; |
|---|
| 247 | 233 | struct imon_dec *imon = &dev->raw->imon; |
|---|
| 248 | | - int ret; |
|---|
| 249 | 234 | |
|---|
| 250 | | - idev = input_allocate_device(); |
|---|
| 251 | | - if (!idev) |
|---|
| 252 | | - return -ENOMEM; |
|---|
| 253 | | - |
|---|
| 254 | | - snprintf(imon->name, sizeof(imon->name), |
|---|
| 255 | | - "iMON PAD Stick (%s)", dev->device_name); |
|---|
| 256 | | - idev->name = imon->name; |
|---|
| 257 | | - idev->phys = dev->input_phys; |
|---|
| 258 | | - |
|---|
| 259 | | - /* Mouse bits */ |
|---|
| 260 | | - set_bit(EV_REL, idev->evbit); |
|---|
| 261 | | - set_bit(EV_KEY, idev->evbit); |
|---|
| 262 | | - set_bit(REL_X, idev->relbit); |
|---|
| 263 | | - set_bit(REL_Y, idev->relbit); |
|---|
| 264 | | - set_bit(BTN_LEFT, idev->keybit); |
|---|
| 265 | | - set_bit(BTN_RIGHT, idev->keybit); |
|---|
| 266 | | - |
|---|
| 267 | | - /* Report scancodes too */ |
|---|
| 268 | | - set_bit(EV_MSC, idev->evbit); |
|---|
| 269 | | - set_bit(MSC_SCAN, idev->mscbit); |
|---|
| 270 | | - |
|---|
| 271 | | - input_set_drvdata(idev, imon); |
|---|
| 272 | | - |
|---|
| 273 | | - ret = input_register_device(idev); |
|---|
| 274 | | - if (ret < 0) { |
|---|
| 275 | | - input_free_device(idev); |
|---|
| 276 | | - return -EIO; |
|---|
| 277 | | - } |
|---|
| 278 | | - |
|---|
| 279 | | - imon->idev = idev; |
|---|
| 280 | 235 | imon->stick_keyboard = false; |
|---|
| 281 | | - |
|---|
| 282 | | - return 0; |
|---|
| 283 | | -} |
|---|
| 284 | | - |
|---|
| 285 | | -static int ir_imon_unregister(struct rc_dev *dev) |
|---|
| 286 | | -{ |
|---|
| 287 | | - struct imon_dec *imon = &dev->raw->imon; |
|---|
| 288 | | - |
|---|
| 289 | | - input_unregister_device(imon->idev); |
|---|
| 290 | | - imon->idev = NULL; |
|---|
| 291 | 236 | |
|---|
| 292 | 237 | return 0; |
|---|
| 293 | 238 | } |
|---|
| .. | .. |
|---|
| 298 | 243 | .encode = ir_imon_encode, |
|---|
| 299 | 244 | .carrier = 38000, |
|---|
| 300 | 245 | .raw_register = ir_imon_register, |
|---|
| 301 | | - .raw_unregister = ir_imon_unregister, |
|---|
| 302 | 246 | .min_timeout = IMON_UNIT * IMON_BITS * 2, |
|---|
| 303 | 247 | }; |
|---|
| 304 | 248 | |
|---|