linux/drivers/hid/hid-wiimote-core.c
<<
>>
Prefs
   1/*
   2 * HID driver for Nintendo Wiimote devices
   3 * Copyright (c) 2011 David Herrmann
   4 */
   5
   6/*
   7 * This program is free software; you can redistribute it and/or modify it
   8 * under the terms of the GNU General Public License as published by the Free
   9 * Software Foundation; either version 2 of the License, or (at your option)
  10 * any later version.
  11 */
  12
  13#include <linux/completion.h>
  14#include <linux/device.h>
  15#include <linux/hid.h>
  16#include <linux/input.h>
  17#include <linux/leds.h>
  18#include <linux/module.h>
  19#include <linux/mutex.h>
  20#include <linux/power_supply.h>
  21#include <linux/spinlock.h>
  22#include "hid-ids.h"
  23#include "hid-wiimote.h"
  24
  25enum wiiproto_keys {
  26        WIIPROTO_KEY_LEFT,
  27        WIIPROTO_KEY_RIGHT,
  28        WIIPROTO_KEY_UP,
  29        WIIPROTO_KEY_DOWN,
  30        WIIPROTO_KEY_PLUS,
  31        WIIPROTO_KEY_MINUS,
  32        WIIPROTO_KEY_ONE,
  33        WIIPROTO_KEY_TWO,
  34        WIIPROTO_KEY_A,
  35        WIIPROTO_KEY_B,
  36        WIIPROTO_KEY_HOME,
  37        WIIPROTO_KEY_COUNT
  38};
  39
  40static __u16 wiiproto_keymap[] = {
  41        KEY_LEFT,       /* WIIPROTO_KEY_LEFT */
  42        KEY_RIGHT,      /* WIIPROTO_KEY_RIGHT */
  43        KEY_UP,         /* WIIPROTO_KEY_UP */
  44        KEY_DOWN,       /* WIIPROTO_KEY_DOWN */
  45        KEY_NEXT,       /* WIIPROTO_KEY_PLUS */
  46        KEY_PREVIOUS,   /* WIIPROTO_KEY_MINUS */
  47        BTN_1,          /* WIIPROTO_KEY_ONE */
  48        BTN_2,          /* WIIPROTO_KEY_TWO */
  49        BTN_A,          /* WIIPROTO_KEY_A */
  50        BTN_B,          /* WIIPROTO_KEY_B */
  51        BTN_MODE,       /* WIIPROTO_KEY_HOME */
  52};
  53
  54static enum power_supply_property wiimote_battery_props[] = {
  55        POWER_SUPPLY_PROP_CAPACITY,
  56        POWER_SUPPLY_PROP_SCOPE,
  57};
  58
  59static ssize_t wiimote_hid_send(struct hid_device *hdev, __u8 *buffer,
  60                                                                size_t count)
  61{
  62        __u8 *buf;
  63        ssize_t ret;
  64
  65        if (!hdev->hid_output_raw_report)
  66                return -ENODEV;
  67
  68        buf = kmemdup(buffer, count, GFP_KERNEL);
  69        if (!buf)
  70                return -ENOMEM;
  71
  72        ret = hdev->hid_output_raw_report(hdev, buf, count, HID_OUTPUT_REPORT);
  73
  74        kfree(buf);
  75        return ret;
  76}
  77
  78static void wiimote_worker(struct work_struct *work)
  79{
  80        struct wiimote_data *wdata = container_of(work, struct wiimote_data,
  81                                                                        worker);
  82        unsigned long flags;
  83
  84        spin_lock_irqsave(&wdata->qlock, flags);
  85
  86        while (wdata->head != wdata->tail) {
  87                spin_unlock_irqrestore(&wdata->qlock, flags);
  88                wiimote_hid_send(wdata->hdev, wdata->outq[wdata->tail].data,
  89                                                wdata->outq[wdata->tail].size);
  90                spin_lock_irqsave(&wdata->qlock, flags);
  91
  92                wdata->tail = (wdata->tail + 1) % WIIMOTE_BUFSIZE;
  93        }
  94
  95        spin_unlock_irqrestore(&wdata->qlock, flags);
  96}
  97
  98static void wiimote_queue(struct wiimote_data *wdata, const __u8 *buffer,
  99                                                                size_t count)
 100{
 101        unsigned long flags;
 102        __u8 newhead;
 103
 104        if (count > HID_MAX_BUFFER_SIZE) {
 105                hid_warn(wdata->hdev, "Sending too large output report\n");
 106                return;
 107        }
 108
 109        /*
 110         * Copy new request into our output queue and check whether the
 111         * queue is full. If it is full, discard this request.
 112         * If it is empty we need to start a new worker that will
 113         * send out the buffer to the hid device.
 114         * If the queue is not empty, then there must be a worker
 115         * that is currently sending out our buffer and this worker
 116         * will reschedule itself until the queue is empty.
 117         */
 118
 119        spin_lock_irqsave(&wdata->qlock, flags);
 120
 121        memcpy(wdata->outq[wdata->head].data, buffer, count);
 122        wdata->outq[wdata->head].size = count;
 123        newhead = (wdata->head + 1) % WIIMOTE_BUFSIZE;
 124
 125        if (wdata->head == wdata->tail) {
 126                wdata->head = newhead;
 127                schedule_work(&wdata->worker);
 128        } else if (newhead != wdata->tail) {
 129                wdata->head = newhead;
 130        } else {
 131                hid_warn(wdata->hdev, "Output queue is full");
 132        }
 133
 134        spin_unlock_irqrestore(&wdata->qlock, flags);
 135}
 136
 137/*
 138 * This sets the rumble bit on the given output report if rumble is
 139 * currently enabled.
 140 * \cmd1 must point to the second byte in the output report => &cmd[1]
 141 * This must be called on nearly every output report before passing it
 142 * into the output queue!
 143 */
 144static inline void wiiproto_keep_rumble(struct wiimote_data *wdata, __u8 *cmd1)
 145{
 146        if (wdata->state.flags & WIIPROTO_FLAG_RUMBLE)
 147                *cmd1 |= 0x01;
 148}
 149
 150static void wiiproto_req_rumble(struct wiimote_data *wdata, __u8 rumble)
 151{
 152        __u8 cmd[2];
 153
 154        rumble = !!rumble;
 155        if (rumble == !!(wdata->state.flags & WIIPROTO_FLAG_RUMBLE))
 156                return;
 157
 158        if (rumble)
 159                wdata->state.flags |= WIIPROTO_FLAG_RUMBLE;
 160        else
 161                wdata->state.flags &= ~WIIPROTO_FLAG_RUMBLE;
 162
 163        cmd[0] = WIIPROTO_REQ_RUMBLE;
 164        cmd[1] = 0;
 165
 166        wiiproto_keep_rumble(wdata, &cmd[1]);
 167        wiimote_queue(wdata, cmd, sizeof(cmd));
 168}
 169
 170static void wiiproto_req_leds(struct wiimote_data *wdata, int leds)
 171{
 172        __u8 cmd[2];
 173
 174        leds &= WIIPROTO_FLAGS_LEDS;
 175        if ((wdata->state.flags & WIIPROTO_FLAGS_LEDS) == leds)
 176                return;
 177        wdata->state.flags = (wdata->state.flags & ~WIIPROTO_FLAGS_LEDS) | leds;
 178
 179        cmd[0] = WIIPROTO_REQ_LED;
 180        cmd[1] = 0;
 181
 182        if (leds & WIIPROTO_FLAG_LED1)
 183                cmd[1] |= 0x10;
 184        if (leds & WIIPROTO_FLAG_LED2)
 185                cmd[1] |= 0x20;
 186        if (leds & WIIPROTO_FLAG_LED3)
 187                cmd[1] |= 0x40;
 188        if (leds & WIIPROTO_FLAG_LED4)
 189                cmd[1] |= 0x80;
 190
 191        wiiproto_keep_rumble(wdata, &cmd[1]);
 192        wiimote_queue(wdata, cmd, sizeof(cmd));
 193}
 194
 195/*
 196 * Check what peripherals of the wiimote are currently
 197 * active and select a proper DRM that supports all of
 198 * the requested data inputs.
 199 */
 200static __u8 select_drm(struct wiimote_data *wdata)
 201{
 202        __u8 ir = wdata->state.flags & WIIPROTO_FLAGS_IR;
 203        bool ext = wiiext_active(wdata);
 204
 205        if (ir == WIIPROTO_FLAG_IR_BASIC) {
 206                if (wdata->state.flags & WIIPROTO_FLAG_ACCEL)
 207                        return WIIPROTO_REQ_DRM_KAIE;
 208                else
 209                        return WIIPROTO_REQ_DRM_KIE;
 210        } else if (ir == WIIPROTO_FLAG_IR_EXT) {
 211                return WIIPROTO_REQ_DRM_KAI;
 212        } else if (ir == WIIPROTO_FLAG_IR_FULL) {
 213                return WIIPROTO_REQ_DRM_SKAI1;
 214        } else {
 215                if (wdata->state.flags & WIIPROTO_FLAG_ACCEL) {
 216                        if (ext)
 217                                return WIIPROTO_REQ_DRM_KAE;
 218                        else
 219                                return WIIPROTO_REQ_DRM_KA;
 220                } else {
 221                        if (ext)
 222                                return WIIPROTO_REQ_DRM_KE;
 223                        else
 224                                return WIIPROTO_REQ_DRM_K;
 225                }
 226        }
 227}
 228
 229void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
 230{
 231        __u8 cmd[3];
 232
 233        if (drm == WIIPROTO_REQ_NULL)
 234                drm = select_drm(wdata);
 235
 236        cmd[0] = WIIPROTO_REQ_DRM;
 237        cmd[1] = 0;
 238        cmd[2] = drm;
 239
 240        wdata->state.drm = drm;
 241        wiiproto_keep_rumble(wdata, &cmd[1]);
 242        wiimote_queue(wdata, cmd, sizeof(cmd));
 243}
 244
 245static void wiiproto_req_status(struct wiimote_data *wdata)
 246{
 247        __u8 cmd[2];
 248
 249        cmd[0] = WIIPROTO_REQ_SREQ;
 250        cmd[1] = 0;
 251
 252        wiiproto_keep_rumble(wdata, &cmd[1]);
 253        wiimote_queue(wdata, cmd, sizeof(cmd));
 254}
 255
 256static void wiiproto_req_accel(struct wiimote_data *wdata, __u8 accel)
 257{
 258        accel = !!accel;
 259        if (accel == !!(wdata->state.flags & WIIPROTO_FLAG_ACCEL))
 260                return;
 261
 262        if (accel)
 263                wdata->state.flags |= WIIPROTO_FLAG_ACCEL;
 264        else
 265                wdata->state.flags &= ~WIIPROTO_FLAG_ACCEL;
 266
 267        wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL);
 268}
 269
 270static void wiiproto_req_ir1(struct wiimote_data *wdata, __u8 flags)
 271{
 272        __u8 cmd[2];
 273
 274        cmd[0] = WIIPROTO_REQ_IR1;
 275        cmd[1] = flags;
 276
 277        wiiproto_keep_rumble(wdata, &cmd[1]);
 278        wiimote_queue(wdata, cmd, sizeof(cmd));
 279}
 280
 281static void wiiproto_req_ir2(struct wiimote_data *wdata, __u8 flags)
 282{
 283        __u8 cmd[2];
 284
 285        cmd[0] = WIIPROTO_REQ_IR2;
 286        cmd[1] = flags;
 287
 288        wiiproto_keep_rumble(wdata, &cmd[1]);
 289        wiimote_queue(wdata, cmd, sizeof(cmd));
 290}
 291
 292#define wiiproto_req_wreg(wdata, os, buf, sz) \
 293                        wiiproto_req_wmem((wdata), false, (os), (buf), (sz))
 294
 295#define wiiproto_req_weeprom(wdata, os, buf, sz) \
 296                        wiiproto_req_wmem((wdata), true, (os), (buf), (sz))
 297
 298static void wiiproto_req_wmem(struct wiimote_data *wdata, bool eeprom,
 299                                __u32 offset, const __u8 *buf, __u8 size)
 300{
 301        __u8 cmd[22];
 302
 303        if (size > 16 || size == 0) {
 304                hid_warn(wdata->hdev, "Invalid length %d wmem request\n", size);
 305                return;
 306        }
 307
 308        memset(cmd, 0, sizeof(cmd));
 309        cmd[0] = WIIPROTO_REQ_WMEM;
 310        cmd[2] = (offset >> 16) & 0xff;
 311        cmd[3] = (offset >> 8) & 0xff;
 312        cmd[4] = offset & 0xff;
 313        cmd[5] = size;
 314        memcpy(&cmd[6], buf, size);
 315
 316        if (!eeprom)
 317                cmd[1] |= 0x04;
 318
 319        wiiproto_keep_rumble(wdata, &cmd[1]);
 320        wiimote_queue(wdata, cmd, sizeof(cmd));
 321}
 322
 323void wiiproto_req_rmem(struct wiimote_data *wdata, bool eeprom, __u32 offset,
 324                                                                __u16 size)
 325{
 326        __u8 cmd[7];
 327
 328        if (size == 0) {
 329                hid_warn(wdata->hdev, "Invalid length %d rmem request\n", size);
 330                return;
 331        }
 332
 333        cmd[0] = WIIPROTO_REQ_RMEM;
 334        cmd[1] = 0;
 335        cmd[2] = (offset >> 16) & 0xff;
 336        cmd[3] = (offset >> 8) & 0xff;
 337        cmd[4] = offset & 0xff;
 338        cmd[5] = (size >> 8) & 0xff;
 339        cmd[6] = size & 0xff;
 340
 341        if (!eeprom)
 342                cmd[1] |= 0x04;
 343
 344        wiiproto_keep_rumble(wdata, &cmd[1]);
 345        wiimote_queue(wdata, cmd, sizeof(cmd));
 346}
 347
 348/* requries the cmd-mutex to be held */
 349int wiimote_cmd_write(struct wiimote_data *wdata, __u32 offset,
 350                                                const __u8 *wmem, __u8 size)
 351{
 352        unsigned long flags;
 353        int ret;
 354
 355        spin_lock_irqsave(&wdata->state.lock, flags);
 356        wiimote_cmd_set(wdata, WIIPROTO_REQ_WMEM, 0);
 357        wiiproto_req_wreg(wdata, offset, wmem, size);
 358        spin_unlock_irqrestore(&wdata->state.lock, flags);
 359
 360        ret = wiimote_cmd_wait(wdata);
 361        if (!ret && wdata->state.cmd_err)
 362                ret = -EIO;
 363
 364        return ret;
 365}
 366
 367/* requries the cmd-mutex to be held */
 368ssize_t wiimote_cmd_read(struct wiimote_data *wdata, __u32 offset, __u8 *rmem,
 369                                                                __u8 size)
 370{
 371        unsigned long flags;
 372        ssize_t ret;
 373
 374        spin_lock_irqsave(&wdata->state.lock, flags);
 375        wdata->state.cmd_read_size = size;
 376        wdata->state.cmd_read_buf = rmem;
 377        wiimote_cmd_set(wdata, WIIPROTO_REQ_RMEM, offset & 0xffff);
 378        wiiproto_req_rreg(wdata, offset, size);
 379        spin_unlock_irqrestore(&wdata->state.lock, flags);
 380
 381        ret = wiimote_cmd_wait(wdata);
 382
 383        spin_lock_irqsave(&wdata->state.lock, flags);
 384        wdata->state.cmd_read_buf = NULL;
 385        spin_unlock_irqrestore(&wdata->state.lock, flags);
 386
 387        if (!ret) {
 388                if (wdata->state.cmd_read_size == 0)
 389                        ret = -EIO;
 390                else
 391                        ret = wdata->state.cmd_read_size;
 392        }
 393
 394        return ret;
 395}
 396
 397static int wiimote_battery_get_property(struct power_supply *psy,
 398                                                enum power_supply_property psp,
 399                                                union power_supply_propval *val)
 400{
 401        struct wiimote_data *wdata = container_of(psy,
 402                                                struct wiimote_data, battery);
 403        int ret = 0, state;
 404        unsigned long flags;
 405
 406        if (psp == POWER_SUPPLY_PROP_SCOPE) {
 407                val->intval = POWER_SUPPLY_SCOPE_DEVICE;
 408                return 0;
 409        }
 410
 411        ret = wiimote_cmd_acquire(wdata);
 412        if (ret)
 413                return ret;
 414
 415        spin_lock_irqsave(&wdata->state.lock, flags);
 416        wiimote_cmd_set(wdata, WIIPROTO_REQ_SREQ, 0);
 417        wiiproto_req_status(wdata);
 418        spin_unlock_irqrestore(&wdata->state.lock, flags);
 419
 420        ret = wiimote_cmd_wait(wdata);
 421        state = wdata->state.cmd_battery;
 422        wiimote_cmd_release(wdata);
 423
 424        if (ret)
 425                return ret;
 426
 427        switch (psp) {
 428                case POWER_SUPPLY_PROP_CAPACITY:
 429                        val->intval = state * 100 / 255;
 430                        break;
 431                default:
 432                        ret = -EINVAL;
 433                        break;
 434        }
 435
 436        return ret;
 437}
 438
 439static int wiimote_init_ir(struct wiimote_data *wdata, __u16 mode)
 440{
 441        int ret;
 442        unsigned long flags;
 443        __u8 format = 0;
 444        static const __u8 data_enable[] = { 0x01 };
 445        static const __u8 data_sens1[] = { 0x02, 0x00, 0x00, 0x71, 0x01,
 446                                                0x00, 0xaa, 0x00, 0x64 };
 447        static const __u8 data_sens2[] = { 0x63, 0x03 };
 448        static const __u8 data_fin[] = { 0x08 };
 449
 450        spin_lock_irqsave(&wdata->state.lock, flags);
 451
 452        if (mode == (wdata->state.flags & WIIPROTO_FLAGS_IR)) {
 453                spin_unlock_irqrestore(&wdata->state.lock, flags);
 454                return 0;
 455        }
 456
 457        if (mode == 0) {
 458                wdata->state.flags &= ~WIIPROTO_FLAGS_IR;
 459                wiiproto_req_ir1(wdata, 0);
 460                wiiproto_req_ir2(wdata, 0);
 461                wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL);
 462                spin_unlock_irqrestore(&wdata->state.lock, flags);
 463                return 0;
 464        }
 465
 466        spin_unlock_irqrestore(&wdata->state.lock, flags);
 467
 468        ret = wiimote_cmd_acquire(wdata);
 469        if (ret)
 470                return ret;
 471
 472        /* send PIXEL CLOCK ENABLE cmd first */
 473        spin_lock_irqsave(&wdata->state.lock, flags);
 474        wiimote_cmd_set(wdata, WIIPROTO_REQ_IR1, 0);
 475        wiiproto_req_ir1(wdata, 0x06);
 476        spin_unlock_irqrestore(&wdata->state.lock, flags);
 477
 478        ret = wiimote_cmd_wait(wdata);
 479        if (ret)
 480                goto unlock;
 481        if (wdata->state.cmd_err) {
 482                ret = -EIO;
 483                goto unlock;
 484        }
 485
 486        /* enable IR LOGIC */
 487        spin_lock_irqsave(&wdata->state.lock, flags);
 488        wiimote_cmd_set(wdata, WIIPROTO_REQ_IR2, 0);
 489        wiiproto_req_ir2(wdata, 0x06);
 490        spin_unlock_irqrestore(&wdata->state.lock, flags);
 491
 492        ret = wiimote_cmd_wait(wdata);
 493        if (ret)
 494                goto unlock;
 495        if (wdata->state.cmd_err) {
 496                ret = -EIO;
 497                goto unlock;
 498        }
 499
 500        /* enable IR cam but do not make it send data, yet */
 501        ret = wiimote_cmd_write(wdata, 0xb00030, data_enable,
 502                                                        sizeof(data_enable));
 503        if (ret)
 504                goto unlock;
 505
 506        /* write first sensitivity block */
 507        ret = wiimote_cmd_write(wdata, 0xb00000, data_sens1,
 508                                                        sizeof(data_sens1));
 509        if (ret)
 510                goto unlock;
 511
 512        /* write second sensitivity block */
 513        ret = wiimote_cmd_write(wdata, 0xb0001a, data_sens2,
 514                                                        sizeof(data_sens2));
 515        if (ret)
 516                goto unlock;
 517
 518        /* put IR cam into desired state */
 519        switch (mode) {
 520                case WIIPROTO_FLAG_IR_FULL:
 521                        format = 5;
 522                        break;
 523                case WIIPROTO_FLAG_IR_EXT:
 524                        format = 3;
 525                        break;
 526                case WIIPROTO_FLAG_IR_BASIC:
 527                        format = 1;
 528                        break;
 529        }
 530        ret = wiimote_cmd_write(wdata, 0xb00033, &format, sizeof(format));
 531        if (ret)
 532                goto unlock;
 533
 534        /* make IR cam send data */
 535        ret = wiimote_cmd_write(wdata, 0xb00030, data_fin, sizeof(data_fin));
 536        if (ret)
 537                goto unlock;
 538
 539        /* request new DRM mode compatible to IR mode */
 540        spin_lock_irqsave(&wdata->state.lock, flags);
 541        wdata->state.flags &= ~WIIPROTO_FLAGS_IR;
 542        wdata->state.flags |= mode & WIIPROTO_FLAGS_IR;
 543        wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL);
 544        spin_unlock_irqrestore(&wdata->state.lock, flags);
 545
 546unlock:
 547        wiimote_cmd_release(wdata);
 548        return ret;
 549}
 550
 551static enum led_brightness wiimote_leds_get(struct led_classdev *led_dev)
 552{
 553        struct wiimote_data *wdata;
 554        struct device *dev = led_dev->dev->parent;
 555        int i;
 556        unsigned long flags;
 557        bool value = false;
 558
 559        wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev));
 560
 561        for (i = 0; i < 4; ++i) {
 562                if (wdata->leds[i] == led_dev) {
 563                        spin_lock_irqsave(&wdata->state.lock, flags);
 564                        value = wdata->state.flags & WIIPROTO_FLAG_LED(i + 1);
 565                        spin_unlock_irqrestore(&wdata->state.lock, flags);
 566                        break;
 567                }
 568        }
 569
 570        return value ? LED_FULL : LED_OFF;
 571}
 572
 573static void wiimote_leds_set(struct led_classdev *led_dev,
 574                                                enum led_brightness value)
 575{
 576        struct wiimote_data *wdata;
 577        struct device *dev = led_dev->dev->parent;
 578        int i;
 579        unsigned long flags;
 580        __u8 state, flag;
 581
 582        wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev));
 583
 584        for (i = 0; i < 4; ++i) {
 585                if (wdata->leds[i] == led_dev) {
 586                        flag = WIIPROTO_FLAG_LED(i + 1);
 587                        spin_lock_irqsave(&wdata->state.lock, flags);
 588                        state = wdata->state.flags;
 589                        if (value == LED_OFF)
 590                                wiiproto_req_leds(wdata, state & ~flag);
 591                        else
 592                                wiiproto_req_leds(wdata, state | flag);
 593                        spin_unlock_irqrestore(&wdata->state.lock, flags);
 594                        break;
 595                }
 596        }
 597}
 598
 599static int wiimote_ff_play(struct input_dev *dev, void *data,
 600                                                        struct ff_effect *eff)
 601{
 602        struct wiimote_data *wdata = input_get_drvdata(dev);
 603        __u8 value;
 604        unsigned long flags;
 605
 606        /*
 607         * The wiimote supports only a single rumble motor so if any magnitude
 608         * is set to non-zero then we start the rumble motor. If both are set to
 609         * zero, we stop the rumble motor.
 610         */
 611
 612        if (eff->u.rumble.strong_magnitude || eff->u.rumble.weak_magnitude)
 613                value = 1;
 614        else
 615                value = 0;
 616
 617        spin_lock_irqsave(&wdata->state.lock, flags);
 618        wiiproto_req_rumble(wdata, value);
 619        spin_unlock_irqrestore(&wdata->state.lock, flags);
 620
 621        return 0;
 622}
 623
 624static int wiimote_input_open(struct input_dev *dev)
 625{
 626        struct wiimote_data *wdata = input_get_drvdata(dev);
 627
 628        return hid_hw_open(wdata->hdev);
 629}
 630
 631static void wiimote_input_close(struct input_dev *dev)
 632{
 633        struct wiimote_data *wdata = input_get_drvdata(dev);
 634
 635        hid_hw_close(wdata->hdev);
 636}
 637
 638static int wiimote_accel_open(struct input_dev *dev)
 639{
 640        struct wiimote_data *wdata = input_get_drvdata(dev);
 641        int ret;
 642        unsigned long flags;
 643
 644        ret = hid_hw_open(wdata->hdev);
 645        if (ret)
 646                return ret;
 647
 648        spin_lock_irqsave(&wdata->state.lock, flags);
 649        wiiproto_req_accel(wdata, true);
 650        spin_unlock_irqrestore(&wdata->state.lock, flags);
 651
 652        return 0;
 653}
 654
 655static void wiimote_accel_close(struct input_dev *dev)
 656{
 657        struct wiimote_data *wdata = input_get_drvdata(dev);
 658        unsigned long flags;
 659
 660        spin_lock_irqsave(&wdata->state.lock, flags);
 661        wiiproto_req_accel(wdata, false);
 662        spin_unlock_irqrestore(&wdata->state.lock, flags);
 663
 664        hid_hw_close(wdata->hdev);
 665}
 666
 667static int wiimote_ir_open(struct input_dev *dev)
 668{
 669        struct wiimote_data *wdata = input_get_drvdata(dev);
 670        int ret;
 671
 672        ret = hid_hw_open(wdata->hdev);
 673        if (ret)
 674                return ret;
 675
 676        ret = wiimote_init_ir(wdata, WIIPROTO_FLAG_IR_BASIC);
 677        if (ret) {
 678                hid_hw_close(wdata->hdev);
 679                return ret;
 680        }
 681
 682        return 0;
 683}
 684
 685static void wiimote_ir_close(struct input_dev *dev)
 686{
 687        struct wiimote_data *wdata = input_get_drvdata(dev);
 688
 689        wiimote_init_ir(wdata, 0);
 690        hid_hw_close(wdata->hdev);
 691}
 692
 693static void handler_keys(struct wiimote_data *wdata, const __u8 *payload)
 694{
 695        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_LEFT],
 696                                                        !!(payload[0] & 0x01));
 697        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_RIGHT],
 698                                                        !!(payload[0] & 0x02));
 699        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_DOWN],
 700                                                        !!(payload[0] & 0x04));
 701        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_UP],
 702                                                        !!(payload[0] & 0x08));
 703        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_PLUS],
 704                                                        !!(payload[0] & 0x10));
 705        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_TWO],
 706                                                        !!(payload[1] & 0x01));
 707        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_ONE],
 708                                                        !!(payload[1] & 0x02));
 709        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_B],
 710                                                        !!(payload[1] & 0x04));
 711        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_A],
 712                                                        !!(payload[1] & 0x08));
 713        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_MINUS],
 714                                                        !!(payload[1] & 0x10));
 715        input_report_key(wdata->input, wiiproto_keymap[WIIPROTO_KEY_HOME],
 716                                                        !!(payload[1] & 0x80));
 717        input_sync(wdata->input);
 718}
 719
 720static void handler_accel(struct wiimote_data *wdata, const __u8 *payload)
 721{
 722        __u16 x, y, z;
 723
 724        if (!(wdata->state.flags & WIIPROTO_FLAG_ACCEL))
 725                return;
 726
 727        /*
 728         * payload is: BB BB XX YY ZZ
 729         * Accelerometer data is encoded into 3 10bit values. XX, YY and ZZ
 730         * contain the upper 8 bits of each value. The lower 2 bits are
 731         * contained in the buttons data BB BB.
 732         * Bits 6 and 7 of the first buttons byte BB is the lower 2 bits of the
 733         * X accel value. Bit 5 of the second buttons byte is the 2nd bit of Y
 734         * accel value and bit 6 is the second bit of the Z value.
 735         * The first bit of Y and Z values is not available and always set to 0.
 736         * 0x200 is returned on no movement.
 737         */
 738
 739        x = payload[2] << 2;
 740        y = payload[3] << 2;
 741        z = payload[4] << 2;
 742
 743        x |= (payload[0] >> 5) & 0x3;
 744        y |= (payload[1] >> 4) & 0x2;
 745        z |= (payload[1] >> 5) & 0x2;
 746
 747        input_report_abs(wdata->accel, ABS_RX, x - 0x200);
 748        input_report_abs(wdata->accel, ABS_RY, y - 0x200);
 749        input_report_abs(wdata->accel, ABS_RZ, z - 0x200);
 750        input_sync(wdata->accel);
 751}
 752
 753#define ir_to_input0(wdata, ir, packed) __ir_to_input((wdata), (ir), (packed), \
 754                                                        ABS_HAT0X, ABS_HAT0Y)
 755#define ir_to_input1(wdata, ir, packed) __ir_to_input((wdata), (ir), (packed), \
 756                                                        ABS_HAT1X, ABS_HAT1Y)
 757#define ir_to_input2(wdata, ir, packed) __ir_to_input((wdata), (ir), (packed), \
 758                                                        ABS_HAT2X, ABS_HAT2Y)
 759#define ir_to_input3(wdata, ir, packed) __ir_to_input((wdata), (ir), (packed), \
 760                                                        ABS_HAT3X, ABS_HAT3Y)
 761
 762static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir,
 763                                                bool packed, __u8 xid, __u8 yid)
 764{
 765        __u16 x, y;
 766
 767        if (!(wdata->state.flags & WIIPROTO_FLAGS_IR))
 768                return;
 769
 770        /*
 771         * Basic IR data is encoded into 3 bytes. The first two bytes are the
 772         * lower 8 bit of the X/Y data, the 3rd byte contains the upper 2 bits
 773         * of both.
 774         * If data is packed, then the 3rd byte is put first and slightly
 775         * reordered. This allows to interleave packed and non-packed data to
 776         * have two IR sets in 5 bytes instead of 6.
 777         * The resulting 10bit X/Y values are passed to the ABS_HATXY input dev.
 778         */
 779
 780        if (packed) {
 781                x = ir[1] | ((ir[0] & 0x03) << 8);
 782                y = ir[2] | ((ir[0] & 0x0c) << 6);
 783        } else {
 784                x = ir[0] | ((ir[2] & 0x30) << 4);
 785                y = ir[1] | ((ir[2] & 0xc0) << 2);
 786        }
 787
 788        input_report_abs(wdata->ir, xid, x);
 789        input_report_abs(wdata->ir, yid, y);
 790}
 791
 792static void handler_status(struct wiimote_data *wdata, const __u8 *payload)
 793{
 794        handler_keys(wdata, payload);
 795
 796        /* on status reports the drm is reset so we need to resend the drm */
 797        wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL);
 798
 799        wiiext_event(wdata, payload[2] & 0x02);
 800
 801        if (wiimote_cmd_pending(wdata, WIIPROTO_REQ_SREQ, 0)) {
 802                wdata->state.cmd_battery = payload[5];
 803                wiimote_cmd_complete(wdata);
 804        }
 805}
 806
 807static void handler_data(struct wiimote_data *wdata, const __u8 *payload)
 808{
 809        __u16 offset = payload[3] << 8 | payload[4];
 810        __u8 size = (payload[2] >> 4) + 1;
 811        __u8 err = payload[2] & 0x0f;
 812
 813        handler_keys(wdata, payload);
 814
 815        if (wiimote_cmd_pending(wdata, WIIPROTO_REQ_RMEM, offset)) {
 816                if (err)
 817                        size = 0;
 818                else if (size > wdata->state.cmd_read_size)
 819                        size = wdata->state.cmd_read_size;
 820
 821                wdata->state.cmd_read_size = size;
 822                if (wdata->state.cmd_read_buf)
 823                        memcpy(wdata->state.cmd_read_buf, &payload[5], size);
 824                wiimote_cmd_complete(wdata);
 825        }
 826}
 827
 828static void handler_ 826handler_ 826hi1ore.c#L820722        wiif="driver8/hid/hid-wiimote-core.c#8729" 83" class="sref">offset = payloaa> = (payload[2] >> 4) + 1;
 809        __u8 sizepayload[2] >> 4) + 1;
 809        
__u8 payload[2] & 0x0f;
 812
handler_keysn>
payload);
 814
 801        if (wdata.cmd_read_buf)
 payload" class="sref">a> = (
cmd_read_buf, &payload[5], size);
   8     * 0x200 is returned8on no83s/hid/hid-wii}re.c#L817" id="L817" clasWIIPROTO_REQ_RMEM" class="line" name="L801"> 801        if (hi1ore.c37" id="L737" class="lin8" nam83code=wdata" class="srd" class="sref">id_wa"> 826}
ref">state.cmd_read_bufhdev 826}
+code=payloa-wid"Re   i  clor %hhuref"req %hhu\n"="L795"4"> 814
__ir_to_input(struct wdata), ();
wdata);
wdata);
z = 8a hre84e=__u16" class="sref">__u16  827
 828static void handler_ 826handler_ 826
 801        if (payload[2] & 0x0f;
 812
z |= (payload 718}
 812
   8de=wdata" class="sref">w8atainput_syncw8ata
w8ata 827
 828static void handler_ 826handler_ 826 750     8  wdata, co8(payload[2] & 0x0f;
 812
                        __ir_t8_inpu8((code=input_sync" class="sref">input_sync 754          8     85code=handler_keys" class="sref">handler_keys__ir_t8_inpu8((L805" id="L805" class="line" name="Lrm_KrIt_key" class="s" name="Lrm_KrId/hid-wiimote-core.c#L827" id="L827" class="line" name="L827"> 827
 828static void handler_ 826handler_ 826 756          8     8      ef="+code=wdata" class="sref">wdata, co8(ent">   8put" class="sref">__ir_t8_inpu856" id="L786" class="line" na>payload[2] & 0x0f;
 812
 758          8     85/a> * 718}
 812
__ir_t8_inpu86-> 751}
                        memcpy 760          8     86 name="L710"> 710                 ABS_HAT0X,                         memcpyABS_H8T3X *ABS_HAT1X,                         memcpy8iimot86"+code=payload" class="sref"          ABS_HAT2X,                         memcpy *payload[1] &ref">wdata, wdata);
 765        __u16  827
 828static void handler_ 826handler_ 826   8ta->wdata, conmp;  * 812
                        input_sync__u8  827
 828static void handler_ 826handler_ 826__u8 __u8  812
,  751}
                        memcpypayload         ABS_HAT0X,                         memcpy   8hid-wiimote-core.c#L777"8id="L876" id="L786" class="line" nam         ABS_HAT1X,                         memcpywdata->ABS_HAT2X,                         memcpyaccel, ABS_RZ, z<&ref">wdata,  779
 710       
                         781              8 wdata);
 782              8 __u16  827
 828static void handler_ 826handler_ 826ef="driv8"> 784              8  801        if ( 785              8 , payload[2] & 0x0f;
 812
i8[1] | ((payload 718}
 812
                        wdata);
(wdata->i8,  827
 828static void handler_ 826handler_ 826 801        if (wiimote_da8a89"+code=payload" class="sref">payload[2] & 0x0f;
 812
__u8 * 718}
 812
 794        __u8  751}
                        memcpyABS_HAT0X,                         memcpyABS_HAT1X,                         memcpyABS_HAT2X,                         memcpywdata, accel, ABS_RZ, z<&ref">wdata,  799                        wdata, <9 href90ef="+code=input_sync" class="sref">input_sync__u8 wdata-> 827
 828static void handler_ 826handler_ 826__u8 wiimote_cmd_compl9te__u8  812
wdata);
<9     }
 825  9mote_data9 class="sref">wiimote_da9a90re.c#L826" id="L826" class="line" name="Lrm_SKAIa href="+code=AB" name="Lrm_SKAIad/hid-wiimote-core.c#L827" id="L827" class="line" name="L827"> 827
 828static void handler_ 826handler_ 826wdata, __u90de=__u100);
wi9ass="sref9>__u16 offset = >payload[2] & 0x0f;
 812
 810        yid, 9ss="line"9name="L811"> 811    9    *cmd_read_buf)
payload[2] >> 4) + 1;
 809        err = 9a hre9="+code=payload" class="sref"ef="+code=cmd_read_buf" class="sref">cmd_read_buf)
payload[4];
 813         *cmd_read_buf)
payload[4];
handler_keys( 751}
                        memcpyoffset))9{
payload         ABS_HAT0X,                         memcpyerr)
accel, ABS_RZ, z<&ref">wdata, size > wdata);
<9e=size" c9ass="sref">size = wdata->state 827
 828static void handler_ 826handler_ 826wdata-&g9; 801        if ( 829                if (9a hre92"+code=payload" class="sref"a> size 802"> 802                state.handler_keys__u8  812
wiimote_cmd_compl9te 765        cmd_read_buf)
payload[4];
cmd_read_buf)
payload[4];
hi1ore.9#L820722        offset = ="L823" class="linL823"> 80]oad"> 816                if (__u8 81]oad"> 816                if (
 82]oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_buf)
 802                 83]oad" class="sref">payload[2] >> 4) + 1;
 809         * 84]oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_buf)
 809        __u8  718}
 -wiimote-core.c#L781" id="L781" class="line"9ivers/hid9hid-wiimote-core.c#L735"9id="L93e="L765"> 765        ABS_HAT1X,                         memcpy   9     * 0x200 is returned9on no936" id="L786" class="line" nam         ABS_HAT2X,                         memcpyaccel, ABS_RZ, z<&ref">wdata, wdata->yid, 9vers/hid/9id-wiimote-core.c#L741" 9d="L794re.c#L7iimote-core.c#L827" id=mment"ref="drass="line" name="Lmment"ref="drIIPROine" name="L801"> 801        if (z = 9a hre94"+code=payload" class="sref"a> size * 815       data_> class="sref">size 821                __u8 d="L8(void accel,  827
 828static void h"L821"> 821                 821                z |= ( 825  9cent">   9de=wdata" class="sref">w9ata[2] & 0x0f;
 801        if (hi1ore.9de=wdata" class="sref">w9ata.c#L801" id="LTATUS789" id="L789" .c#L801" id="LTATUS828" id-wiimote-core.cef="+code=state" class="sref">6 id-wiimote-core.cfuef">accel, ref="driL826u>[2] & 0x0f;
 hreo}ass="sref">__ir_to_input(struct w9ata.c#L801" id="DATrt_key" class="s.c#L801" id="DATr828" id-wiimote-core.cef="+code=state" class="sref">21 id-wiimote-core.cfuef">accel, ref="drihid/hid-wiimote-corhref="drivers/hio}ass="sref">__ir_to_input(struct  750     9  .c#L801" id="RETURNt_key" class="s.c#L801" id="RETURN828" id-wiimote-core.cef="+code=state" class="sref">4 id-wiimote-core.cfuef">accel, ref="driL826"> 826}
__ir_to_input(struct .c#L801" id="DRM_Kt_key" class="s.c#L801" id="DRM_K828" id-wiimote-core.cef="+code=state" class="sref">2 id-wiimote-core.cfuef">accel, ref="dri[2] & 0x0f;
__ir_to_input(struct .c#L801" id="DRM_Krt_key" class="s.c#L801" id="DRM_Kr828" id-wiimote-core.cef="+code=state" class="sref">5 id-wiimote-core.cfuef">accel, ref="drihrm_Krt_key" class="s" name="Lrm_Krd/hio}ass="sref">__ir_to_input(struct __ir_t9_inpu954+code=payloa{ d-wiimote-core.c#L789" id="L789" lass="oad" class="sref">.c#L801" id="DRM_KEt_key" class="s.c#L801" id="DRM_KE828" id-wiimote-core.cef="+code=state" class="sref">10 id-wiimote-core.cfuef">accel, ref="drihrm_KEt_key" class="s" name="Lrm_KEd/hio}ass="sref">__ir_to_input(struct 
 754          9     955+code=payloa{ d-wiimote-core.c#L789" id="L789" lass="oad" class="sref">.c#L801" id="DRM_KrIt_key" class="s.c#L801" id="DRM_KrI828" id-wiimote-core.cef="+code=state" class="sref">17 id-wiimote-core.cfuef">accel, ref="drihrm_KrIt_key" class="s" name="Lrm_KrId/hio}ass="sref">__ir_to_input(struct __ir_t9_inpu956+code=payloa{ d-wiimote-core.c#L789" id="L789" lass="oad" class="sref">.c#L801" id="DRM_KEEt_key" class="s.c#L801" id="DRM_KEE828" id-wiimote-core.cef="+code=state" class="sref">21 id-wiimote-core.cfuef">accel, ref="drihrm_KEEt_key" class="s" name="Lrm_KEEd/hio}ass="sref">__ir_to_input(struct  756          9     957+code=payloa{ d-wiimote-core.c#L789" id="L789" lass="oad" class="sref">.c#L801" id="DRM_KrEt_key" class="s.c#L801" id="DRM_KAE828" id-wiimote-core.cef="+code=state" class="sref">21 id-wiimote-core.cfuef">accel, ref="drihrm_KrEt_key" class="s" name="Lrm_KAEd/hio}ass="sref">__ir_to_input(struct    9put" class="sref">__ir_t9_inpu956" id="L786" { d-wiimote-core.c#L789" id="L789" lass="oad" class="sref">.c#L801" id="DRM_KIEt_key" class="s.c#L801" id="DRM_KIE828" id-wiimote-core.cef="+code=state" class="sref">21 id-wiimote-core.cfuef">accel, ref="drihrm_KIEt_key" class="s" name="Lrm_KIEd/hio}ass="sref">__ir_to_input(struct hi1ore.9L758"> 758          9     95WIIPROTO_REQ_{ d-wiimote-core.c#L789" id="L789" lass="oad" class="sref">.c#L801" id="DRM_KrIEt_key" class="s.c#L801" id="DRM_KAIE828" id-wiimote-core.cef="+code=state" class="sref">21 id-wiimote-core.cfuef">accel, ref="drihrm_KrIEt_key" class="s" name="Lrm_KAIEd/hio}ass="sref">__ir_to_input(struct __ir_t9_inpu960IIPROTO_REQ_{ d-wiimote-core.c#L789" id="L789" lass="oad" class="sref">.c#L801" id="DRM_Et_key" class="s.c#L801" id="DRM_E828" id-wiimote-core.cef="+code=state" class="sref">21 id-wiimote-core.cfuef">accel, ref="drihrm_Et_key" class="s" name="Lrm_Ed/hio}ass="sref">__ir_to_input(struct  760          9     961IIPROTO_REQ_{ d-wiimote-core.c#L789" id="L789" lass="oad" class="sref">.c#L801" id="DRM_SKAIa href="+code=AB.c#L801" id="DRM_SKAIa828" id-wiimote-core.cef="+code=state" class="sref">21 id-wiimote-core.cfuef">accel, ref="drihrm_SKAIa href="+code=AB" name="Lrm_SKAIad/hio}ass="sref">__ir_to_input(struct ABS_H9T3X *.c#L801" id="DRM_SKAIa href="+code=AB.c#L801" id="DRM_SKAIa828" id-wiimote-core.cef="+code=state" class="sref">21 id-wiimote-core.cfuef">accel, ref="drihrm_SKAIa href="+code=AB" name="Lrm_SKAIad/hio}ass="sref">__ir_to_input(struct 9iimot96"+code=payloa{ d-wiimote-core.c#L789" id="L789" lass="oad0eef="+code=wdata" class="sref">wdata);
<9_iimote-c9ed,  *}"L821"> 821                handler_keys((L805" iinote-core.c#L827" id="L827ref_even> 815       id="L827ref_even>de=ABL7iimote-core.c#L827" ref_devic"+code=state" clref_devic"atic void  815       ref_repor>atic void __ir_to_input(struct __u16  828(__ir_to_input(struct    9ta->wdata, co9mp;  * 827
ref_get"Lrvhid/hid-wiimote-corhef_get"Lrvhid/de=ABS_RZ" class="srhdev 826}
 821                }
 821                 821                 *memcpy[2] & 0x0f;flag>ame="L821"> 821                 718}
falsrass="line" namefalsr/hid"L821"> 821                handler_keys__u8 817" id="L817" clasef="+code=state" class="srefhid/h1)handler_keys" class="sref">handler_keyswdata 821                
 825  9dent">   9hid-wiimote-core.c#L777"9id="L976" id="L786" class="line" naspin_lock_irqsav"+code=state" clapin_lock_irqsav"de=AB3               
f="+code=cmd_read_buf" class="sref">cmd_read_buf)
memcpy[2] & 0x0f;flag>ame=h"L821"> 821                O[2] & 0x0f;
 801        if ( 779
="L786" class="line" nah 826}
               " name=>[2] & 0x0f;
 821                 781              9 ="L786" 817" id="L817" clash 826}
z<&L789" id="L789" lass="oaad" class="sref">rawihid/hid-wiimote-corrawihid/"L81r0f="ef="dr id="L817" clash 826}
z( 801        if ( 782              9 ="L786" ="L786" class="line" nah 826}
zaccel, ABS_HAT2X,                rawihid/hid-wiimote-corrawihid/"L81r1]/hid-wiimote-core.c#L813" id="L813" class="l9>ir[29 | ((="L786" ="L786" class="line" nah nameL789" id="L789" " nameL828"oad" class="sref">wiirass="line" namewiir/hidhid-wiimote-core.c#L813" id="L813" class="l9>ef="driv9"> 784              9 ="L786" ef="+code=wdata" class="sref">wdata);
<9name="L789"> 785              9 , wdata);
<9nhref="dr9[1] | (( 825  9a href="d9ivers/hid/hid-wiimote-co9e.c#L986" id="L786" 817"!class="line" nah nameL789" id="L789" " nameL828")handler_keys" class="sref">handler_keys(="L786" class="line" nahef_wa"> 826}
de=ABS_RZ" class="srhdev 826}
}
tring">"Un" nameL repor> %hhu data %d\n"memcpy__ir_to_input(struct (="L786" ="L786"                                                 e-core.c#L827" a>(i9, yid, 9=ame="L789href="drivers/hid/hid-wi9mote-99/a> *               
f="+code=cmd_read_buf" class="sref">cmd_read_buf)
memcpy[2] & 0x0f;flag>ame=h"L821"> 821                wiimote_da9a99e=__u16" class="sref">__u16 __u9 * 816                if ( 794        wdata);
<9( 765        meLs_destroyass="line" name="L827">meLs_destroyde=ABL7iimote-core.c#L827" id="L827" class="line" name="L827"> 827
handler_keyswdata, co9"p; wdata,  821                 799 7">wdata,  >10">>wdadev 826}
wdadev
 >821"> 821                , 10""sref">yid, 10"2 79910"/a> *O 801        if (wiimote_da10"cl>10"3name="L710">="L786" 817" id="L817" clas
f="+code=cmd_read_buf" class="sref">cmd_read_bufmeLs789" id="L789" meLriver[ id="L817" clasi789" id="L789" lame=]"line" name="L801"> 801        if (10"4name="L710">="L786" ="L786" class="line" nameL789" id="L789" meL828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufmeLs789" id="L789" meLriver[ id="L817" clasi789" id="L789" lame=]"L821"> 821                 794        10"5name="L710">="L786" ="L786" class="line" na
f="+code=cmd_read_buf" class="sref">cmd_read_bufmeLs789" id="L789" meLriver[ id="L817" clasi789" id="L789" lame=]oad" class="sref">NULL+code=state" clNULLame="L821"> 821                10" class="sref">wdatawdadev_unregistdrass="line" namemeL_">wdadev_unregistdrde=ABS_RZ" class="srmeL789" id="L789" meL828"h"L821"> 821                10"ef="drivers/hid/hid-wwwwwwwwwS_RZ" class="srkfre)
 821                10"8f="drivers/hid/hid-wef="+code=wdata" class="sref">wdata);
<10"9 799wdata, 10"WIIPROTO_REQ_ef="+code=wdata" class="sref">wdata);
<101> 799__u16 wdata);
<10>1 799 810        10>"sref">yid, 1012 799 811    10nam>10>2a>((L805" iinote-core.c#L827" id="L827meLs_crea>)
)de=ABL7iimote-core.c#L827" id="L827" class="line" name="L827"> 827
handler_keys3 799err = 10 cl>10>3a href="+code=wdata" class="sref">wdata, co10>4 799 813        10>4name="L710">inote-core.c#L827" i789" id="L789" lame=4""sref">memcpy 815       retame="L821"> 821                L7iimote-core.c#L827" devic"+code=state" cldevic"atic void cmd_read_bufhdev 826}
cmd_read_bufdev 826}
"L821"> 821                10>/a>,  815       data_> class="sref">size       f="+sz828"oad" class="sref">L7ile> 826}
de=ABS_RZ" class="srdev_f="+ 826}
 821                offset))10las>10>7name="L710">L7iimote-core.c#L827" meL_">wdadev 826}
wdadev
 821                err)
}
 821                size > 10>put dev.
size = 10asa> *O 801        if (state10a name="L710">="L786" class="line" nameL789" id="L789" meL828"oad" class="sref">kzallof">accel, wdadev 826}
wdadev) + s="sref">size       f="+sz828"4""sref">memcpy 821                wdata-&g10las>10a2name="L710">="L786" 817"!class="line" nameL789" id="L789" meL828"hline" name="L801"> 801        if (                if (1010a3name="L710">="L786" ="L786" class="line" nare> 815       retame=oad- id="L817" clasENOMEM 815       ENOMEMde=A"L821"> 821                state.="L786" ="L786" goto class="line" naerrass="line" nameerrde=A"L821"> 821                10a5name="L710">="L786" ef="+code=wdata" class="sref">wdata);
<10a6 799wiimote_cmd_compl10"sr>10a class="sref">wdata}
 809        10aef="drivers/hid/hid-w" class="sref">LnprinoL823" class="linLnprinoLde=ABS_RZ" class="srf="+ 826}
memcpy       f="+sz828"4""span826}
tring">"%s:blue:p%d"memcpy}
memcpy 809        cmd_read_buff="+ 826}
 821                ="L786" class="line" nameL789" id="L789" meL828"="sref">cmd_read_bufbrightness789" id="L789" brightnessame=oad">L821"> 821                ="L786" class="line" nameL789" id="L789" meL828"="sref">cmd_read_bufmax_brightness789" id="L789" max_brightnessame=oad1>L821"> 821                ="L786" class="line" nameL789" id="L789" meL828"="sref">cmd_read_bufbrightness_get789" id="L789" brightness_get828"oad" class="sref">
d="L827meLs_get789" id="L789" 
d="L827meLs_getde=A"L821"> 821                10/2name="L710">="L786" class="line" nameL789" id="L789" meL828"="sref">cmd_read_bufbrightness_set789" id="L789" brightness_set828"oad" class="sref">
d="L827meLs_set789" id="L789" 
d="L827meLs_setde=A"L821"> 821                __u16 ="L786" class="line" nare> 815       retame=oadclass="line" nameL_">wdadev_registdrass="line" namemeL_">wdadev_registdrde=ABS_RZ" class="srdev 826}
4""sref">memcpy 821                ="L786" 817" id="L817" clasre> 815       retame=hline" name="L801"> 801        if (10/ class="sref">wdata 821                10/ef="drivers/hid/hid-wwwwwwwwwgoto class="line" naerrass="line" nameerrde=A"L821"> 821                wdata);
<1039 79910/9name="L710">="L786" class="line" na
f="+code=cmd_read_buf" class="sref">cmd_read_bufmeLs789" id="L789" meLriver[ id="L817" clasi789" id="L789" lame=]oad" class="sref">meL789" id="L789" meL828""L821"> 821                10idIIPROTO_REQ_ef="+code=wdata" class="sref">wdata);
<1041 79910i"sref">yid, 1042 79910i2name="L710">ers/hi "> 816                if (z = 10z" >10ie=__u16" class="sref">__u16 10i4nameclass="line" naerrass="line" nameerrde=A:16" class="sref">__u16 10ief">__u8 meLs_destroyass="line" name="L827">meLs_destroyde=ABa href="drivers/hid/hid-wiimote-core.c#L828")> 816                if (10i6name="L710">ers/hi "sref">memcpy 815       retame="L821"> 821                z |= (>10i7a href="+code=wdata" class="sref">wdata);
<1048 799w10de=>10i8=__u16" class="sref">__u16 w10de=>10i9a>((L805" iL7iimote-core.c#L827" id="L827" class="line" name="L827"> 827
crea>)
)de=ABL7iimote-core.c#L827" hef_devic"+code=state" clref_devic"atic void handler_keys 799w10de=>10dea href="+code=wdata" class="sref">wdata, co1051 799 750     10ame>10d name="L710">L7iimote-core.c#L827" id="L827" class="line" name="L827"> 827
 821                inote-core.c#L827" i789" id="L789" lame="L821"> 821                10de=__u16" class="sref">__u16 __ir_t10put>10d/a> *kzallof">accel, memcpy 821                 754          10L75>10def">__u8 817"!class="line" na/hid/hid-wiimote-core.c#L828")handler_keys" class="sref">handler_keys__ir_t10put>10d class="sref">wdata 821                 756          10L75>10d" id="L825" class="line" name="L825"> 825  10d8 799__ir_t10put>10d6" id="L786" class="line" na
f="+code=cmd_read_buf" class="sref">cmd_read_buf href789" id="L789" lhreflassoad" class="sref"> href=allofa7"> evic"+code=state" cl href=allofa7"> evic"de=ABh"L821"> 821                 758          10L75>10d9f">__u8 817"!class="line" na/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf href789" id="L789" lhreflass)handler_keys" class="sref">handler_keys 799__ir_t10put>10puclass="sref">wdata 821                 760          10L76>10p"sref">yid, 1062 799ABS_H10AT3>10p/a> *cmd_read_bufhdev 826}
rdev 826}
 821                10mot>10p"+code=payload" class="sref"ref_set"Lrvhid/hid-wiimote-corhef_set"Lrvhid/de=ABS_RZ" class="srhdev 826}
memcpy 816                if (10pcode=handler_keys" class="sref">handler_keys10pef">__u8 cmd_read_buf href789" id="L789" lhreflass4""sref">memcpy 816                if (cmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_bufope> 826}
828"oad" class="sref">
d="L827 href=ope> 826}
 821                __u16 _>10pL796" class="line" name="L796f="+code=cmd_read_buf" class="sref">cmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_bufclosrass="line" nameclosr828"oad" class="sref">
d="L827 href=closrass="line" name
d="L827 href=closr"L81"L821"> 821                10p6" id="L786" class="line" na
f="+code=cmd_read_buf" class="sref">cmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_bufdev 826}
d-wiimote-core.cparen> 815       paren>828"oad3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufdev 826}
"L821"> 821                10pWIIPROTO_REQ_NULL" class="sr
f="+code=cmd_read_buf" class="sref">cmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cbustyprass="line" namebustypr828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufbu>[2] & 0x0f;bu>ame="L821"> 821                10wiIIPROTO_REQ_NULL" class="sr
f="+code=cmd_read_buf" class="sref">cmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cvendorass="line" namevendor828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufvendorass="line" namevendor828""L821"> 821                __u8cmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cproduc> 815       produc>828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufproduc> 815       produc>828""L821"> 821                cmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cversio> 826}
828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufversio> 826}
828""L821"> 821                cmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_buff="+ 826}
}
 821                handler_keys10wef">__u8  815       "et"bi>de=ABa href="driversEV_KEY 815       EV_KEYlass4""sref">memcpycmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_bufevbi> 815       evbi>828")> 816                if (O}

Let"bi> 815       "et"bi>de=ABa href="driversw"Lmment"keymapass="line" name
d=mment"keymapde=A[ id="L817" clasi789" id="L789" lame=]4""sref">memcpycmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_bufkeybi> 815       keybi>828")> 816                if (10w8=__u16" class="sref">__u16  815       "et"bi>de=ABa href="driversFF_RUMBLE 826}
memcpycmd_read_buf href789" id="L789" lhreflass="sref">cmd_read_bufffbi> 815       ffbi>828")> 816                if (1078f">__u8 817")_memlessde=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf href789" id="L789" lhreflass4""sref">memcpymemcpyff7play828")" 816                if ( 779107 name="L710">="L786" goto class="line" naerr_ href789" id="L789" err_ href828""L821"> 821                 781              10"> >1072=__u16" class="sref">__u16  782              10"> >107"+code=payload" class="sref"ef="+code=cmd_read_buf" class="sref">cmd_read_bufacce"> 718}
 href=allofa7"> evic"+code=state" cl href=allofa7"> evic"de=ABh"L821"> 821                1074f">__u8 817"!class="line" na/hid/hid-wiimote-core.c#L828"="sref">cmd_read_bufacce"> 718}
                if ( 784              10"> >1075name="L710">="L786" goto class="line" naerr_ href789" id="L789" err_ href828""L821"> 821                 785              10"> >107e="L765"> 765        [1] | ((cmd_read_bufacce"> 718}
memcpy 816                if (cmd_read_bufacce"> 718}
cmd_read_bufope> 826}
828"oad" class="sref">
d="L827acce"=ope> 826}
828""L821"> 821                107WIIPROTO_REQ_NULL" class="sr
f="+code=cmd_read_buf" class="sref">cmd_read_bufacce"> 718}
cmd_read_bufclosrass="line" nameclosr828"oad" class="sref">
d="L827acce"=closrass="line" name
d="L827acce"=closr828""L821"> 821                10abIIPROTO_REQ_NULL" class="sr
f="+code=cmd_read_buf" class="sref">cmd_read_bufacce"> 718}
cmd_read_bufdev 826}
d-wiimote-core.cparen> 815       paren>828"oad3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufdev 826}
"L821"> 821                10ade=__u8" class="sref">__u8cmd_read_bufacce"> 718}
cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cbustyprass="line" namebustypr828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufbu>[2] & 0x0f;bu>ame="L821"> 821                10a/a> *cmd_read_bufacce"> 718}
cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cvendorass="line" namevendor828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufvendorass="line" namevendor828""L821"> 821                wiimote_da10 cl>10a"+code=payload" class="sref"ef="+code=cmd_read_buf" class="sref">cmd_read_bufacce"> 718}
cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cproduc> 815       produc>828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufproduc> 815       produc>828""L821"> 821                10a/a> *cmd_read_bufacce"> 718}
cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cversio> 826}
828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufversio> 826}
828""L821"> 821                 794        10aef">__u8 cmd_read_bufacce"> 718}
cmd_read_buff="+ 826}
}
}
tring">" Acce"erometer" 821                 765        10aL796" class="line" name="L79"et"bi> 815       "et"bi>de=ABa href="driversEV_ABS 815       EV_ABSlass4""sref">memcpycmd_read_bufacce"> 718}
cmd_read_bufevbi> 815       evbi>828")> 816                if (10a6" id="L786" class="line" naset"bi> 815       "et"bi>de=ABa href="driversABS_RX 815       ABS_RXlass4""sref">memcpycmd_read_bufacce"> 718}
cmd_read_bufabsbi> 815       absbi>828")> 816                if (wdata, 10aWIIPROTO_REQ_NULL" class="srLet"bi> 815       "et"bi>de=ABa href="driversABS_RY 815       ABS_RYlass4""sref">memcpycmd_read_bufacce"> 718}
cmd_read_bufabsbi> 815       absbi>828")> 816                if ( 799 7">wdata,  >110bIIPROTO_REQ_NULL" class="srLet"bi> 815       "et"bi>de=ABa href="driversABS_RZ 815       ABS_RZlass4""sref">memcpycmd_read_bufacce"> 718}
cmd_read_bufabsbi> 815       absbi>828")> 816                if (, 110de=__u8" class="sref">__u8cmd_read_bufacce"> 718}
memcpy       ABS_RXlass4"-500, 500, 2, 4)> 816                if (110/a> *cmd_read_bufacce"> 718}
memcpy       ABS_RYlass4"-500, 500, 2, 4)> 816                if (wiimote_da11"cl>110"+code=payload" class="sref" href="et"abs_params789" id="L789"  href="et"abs_paramsde=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_bufacce"> 718}
memcpy       ABS_RZlass4"-500, 500, 2, 4)> 816                if (110code=handler_keys" class="sref">handler_keys 794        110ef">__u8 cmd_read_bufirass="line" nameir828"oad" class="sref"> href=allofa7"> evic"+code=state" cl href=allofa7"> evic"de=ABh"L821"> 821                11" class="sref"817"!class="line" na/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf rass="line" nameir828"" 816                if (11"ef="drivers/hid/hid-wgoto class="line" naerr_ rass="line" nameerr_ir828""L821"> 821                1108=__u16" class="sref">__u16 wdata, 110WIIPROTO_REQ_NULL" class="sr href="et"Lrvhid/hid-wiimote-cor href="et"Lrvhid/de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf rass="line" nameir828"4""sref">memcpy 816                if (__>111iIIPROTO_REQ_NULL" class="sr
f="+code=cmd_read_buf" class="sref">cmd_read_buf rass="line" nameir828"="sref">cmd_read_bufope> 826}
828"oad" class="sref">
d="L827 r=ope> 826}
 821                 810        111de=__u8" class="sref">__u8cmd_read_buf rass="line" nameir828"="sref">cmd_read_bufclosrass="line" nameclosr828"oad" class="sref">
d="L827 r=closrass="line" name
d="L827 r=closr828""L821"> 821                 811    11nam>111/a> *cmd_read_buf rass="line" nameir828"="sref">cmd_read_bufdev 826}
d-wiimote-core.cparen> 815       paren>828"oad3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufdev 826}
"L821"> 821                err = 11 cl>111"+code=payload" class="sref"ef="+code=cmd_read_buf" class="sref">cmd_read_buf rass="line" nameir828"="sref">cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cbustyprass="line" namebustypr828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufbu>[2] & 0x0f;bu>ame="L821"> 821                 813        111/a> *cmd_read_buf rass="line" nameir828"="sref">cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cvendorass="line" namevendor828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufvendorass="line" namevendor828""L821"> 821                __u8 cmd_read_bufirass="line" nameir828"="sref">cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cproduc> 815       produc>828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufproduc> 815       produc>828""L821"> 821                11>/a>, cmd_read_bufirass="line" nameir828"="sref">cmd_read_buf&L789" id="L789" lass="d-wiimote-core.cversio> 826}
828"oad" class="sref">
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufversio> 826}
828""L821"> 821                offset))11las>111L796" class="line" name="L796f="+code=cmd_read_buf" class="sref">cmd_read_buf rass="line" nameir828"="sref">cmd_read_buff="+ 826}
}
}
tring">" IR" 821                err)
__u16 size > 111WIIPROTO_REQ_NULL" class="srLet"bi> 815       "et"bi>de=ABa href="driversEV_ABS 815       EV_ABSlass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufevbi> 815       evbi>828")> 816                if (size = 112bIIPROTO_REQ_NULL" class="srLet"bi> 815       "et"bi>de=ABa href="driversABS_HAT0X 815       ABS_HAT0Xlass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufabsbi> 815       absbi>828")> 816                if (state112de=__u8" class="sref">__u8 815       "et"bi>de=ABa href="driversABS_HAT0Y 815       ABS_HAT0Ylass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufabsbi> 815       absbi>828")> 816                if (wdata-&g11las>112/a> * 815       "et"bi>de=ABa href="driversABS_HAT1X 815       ABS_HAT1Xlass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufabsbi> 815       absbi>828")> 816                if ( 815       "et"bi>de=ABa href="driversABS_HAT1Y 815       ABS_HAT1Ylass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufabsbi> 815       absbi>828")> 816                if (state. 815       "et"bi>de=ABa href="driversABS_HAT2X 815       ABS_HAT2Xlass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufabsbi> 815       absbi>828")> 816                if (112ef">__u8  815       "et"bi>de=ABa href="driversABS_HAT2Y 815       ABS_HAT2Ylass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufabsbi> 815       absbi>828")> 816                if (wiimote_cmd_compl11"sr>112/a>,  815       "et"bi>de=ABa href="driversABS_HAT3X 815       ABS_HAT3Xlass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufabsbi> 815       absbi>828")> 816                if ( 815       "et"bi>de=ABa href="driversABS_HAT3Y 815       ABS_HAT3Ylass4""sref">memcpycmd_read_buf rass="line" nameir828"="sref">cmd_read_bufabsbi> 815       absbi>828")> 816                if (1126" id="L786" class="line" na href="et"abs_params789" id="L789"  href="et"abs_paramsde=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf rass="line" nameir828"4""sref">memcpy       ABS_HAT0Xlass4"0, 10a3, 2, 4)> 816                if (cmd_read_buf rass="line" nameir828"4""sref">memcpy       ABS_HAT0Ylass4"0, 767, 2, 4)> 816                if (cmd_read_buf rass="line" nameir828"4""sref">memcpy       ABS_HAT1Xlass4"0, 10a3, 2, 4)> 816                if (__u8cmd_read_buf rass="line" nameir828"4""sref">memcpy       ABS_HAT1Ylass4"0, 767, 2, 4)> 816                if (113/a> *cmd_read_buf rass="line" nameir828"4""sref">memcpy       ABS_HAT2Xlass4"0, 10a3, 2, 4)> 816                if (cmd_read_buf rass="line" nameir828"4""sref">memcpy       ABS_HAT2Ylass4"0, 767, 2, 4)> 816                if (cmd_read_buf rass="line" nameir828"4""sref">memcpy       ABS_HAT3Xlass4"0, 10a3, 2, 4)> 816                if (__u8 cmd_read_buf rass="line" nameir828"4""sref">memcpy       ABS_HAT3Ylass4"0, 767, 2, 4)> 816                if (113e="L765"> 765        
 815       "pin_lock_ini>de=AB3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufqlockcode=cmd_read_bqlock828")> 816                if (               
f="+code=cmd_read_buf" class="sref">cmd_read_bufworkdrass="line" nameworkdrlass4""sref">memcpy 816                if (113put dev.
114bIIPROTO_REQ_NULL" class="srLpin_lock_ini> 815       "pin_lock_ini>de=AB3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufL805+ 826}
 816                if (114de=__u8" class="sref">__u8 826}
de=AB3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufL805+ 826}
 816                if (114/a> * 815       mutex_ini>de=AB3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufL805+ 826}
accel,  816                if (z = 11z" >114"+code=payload" class="sref"ef="+code=cmd_read_buf" class="sref">cmd_read_bufL805+ 826}
 816                if (114code=handler_keys" class="sref">handler_keys11ief">__u8 ers/hi class="line" naef="+code=cmd_read_buf" class> 816                if (114e="L765"> 765        z |= (>11i7a hrf">cmd_read_buferr_ rass="line" nameerr_ir828":16" class="sref">__u16 w11de=>1146" id="L786" class="line" na href=fre)_ evic"+code=state" cl href=fre)_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_bufacce"> 718}
 816                if (w11de=>11i9a>((f">cmd_read_buferr_ href789" id="L789" err_ href828":16" class="sref">__u16 w11de=>115bIIPROTO_REQ_NULL" class="sr href=fre)_ evic"+code=state" cl href=fre)_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf href789" id="L789" lhreflass)> 816                if ( 750     11ame>11d namef">cmd_read_buferr789" id="L789" err828":16" class="sref">__u16  816                if (1153f">__u8 ers/hi class="line" naNULL+code=state" clNULLame="L821"> 821                __ir_t11put>11d/a> *ef="+code=wdata" class="sref">wdata);
<1155 799 754          11L75>11def">_f="+code=wdata" class="sref">wdata);
<1156 799__ir_t11put>11d clasL805" ivoid""sref">memcpydestroyde=ABL7iimote-core.c#L827" id="L827" class="line" name="L827"> 827
                if ( 756          11L75>11d" id=ef="+code=wdata" class="sref">wdata, co11d8 799__ir_t11put>11d6" id="L786" class="line" na
iidebug>deini> 815       
iidebug>deini>de=ABS_RZ" class="sr/hid/hid-wiimote-core.c#L828")> 816                if ( 758          11L75>115WIIPROTO_REQ_NULL" class="sr
iiext>deini> 815       
iiext>deini>de=ABS_RZ" class="sr/hid/hid-wiimote-core.c#L828")> 816                if (__ir_t11put>116iIIPROTO_REQ_NULL" class="sr
"L827">meLs_destroyass="line" name="L827">meLs_destroyde=ABa href="drivers/hid/hid-wiimote-core.c#L828")> 816                if ( 760          11L76>11p"sref">yid, 1162 799ABS_H11AT3>11p/a> *               
f="+code=cmd_read_buf" class="sref">cmd_read_bufbattdryass="line" namebattdry828")> 816                if (11mot>11p"+code=payload" class="sref" href=unregistdr_ evic"+code=state" cl href=unregistdr_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_bufacce"> 718}
 816                if (116/a> *cmd_read_buf rass="line" nameir828""> 816                if (11pef">__u8 cmd_read_buf href789" id="L789" lhreflass)> 816                if (accel,                
f="+code=cmd_read_buf" class="sref">cmd_read_bufworkdrass="line" nameworkdrlass)> 816                if (__u16 _>11pL796" class="line" name="L79  i_hw_stopass="line" name  i_hw_stopde=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_bufhdev 826}
 816                if (1168=__u16" class="sref">__u16 11pWIIPROTO_REQ_NULL" class="srkfre)
 816                if (11wiIIPRef="+code=wdata" class="sref">wdata);
<1171 799yid, 1172 79911w/a> *L805" iinote-core.c#L827" ="L827">  i_probrass="line" name
d="L827  i_probrde=ABL7iimote-core.c#L827" hef_devic"+code=state" clref_devic"atic void yid, 1173 79911w"+code=payloaaaaaaaaaaaaaaaaaaaaaaaaaconst>L7iimote-core.c#L827" ref_devic"_&L789" id="L789" ref_devic"_&Latic void                 if (wdata, co1175 79911wef">__u8 L7iimote-core.c#L827" id="L827" class="line" name="L827"> 827
 821                 821                117" id="L825" class="line" name="L825"> 825  1178 7991176" id="L786" class="line" nahdev 826}
cmd_read_bufquirks789" id="L789" quirks" id=|f=a href="driversHID_QUIRK_NO_INIT_REPORTS 815       HID_QUIRK_NO_INIT_REPORTS828""L821"> 821                 799118iIIPROTO_REQ_NULL" class="sr
f="+code=cmd_read_buf" classoad" class="sref">
d="L827crea>)ass="line" name="L827">crea>)de=ABS_RZ" class="srhdev 826}
 816                if ( 779117 name="L710">817"!class="line" na/hid/hid-wiimote-core.c#L828") ef="+code=wdata" class="sref">wdata, co1182 799 781              11"> >1182+code=payloaaaaaaaaae-core.c#L827" ref_err789" id="L789" ref_errde=ABS_RZ" class="srhdev 826}
}
tring">"Can't allof devic"\n" 816                if ( 782              11"> >118"+code=payloaaaaaaaaaers/hi -S_RZ" class="srENOMEM 826}
 821                1174f">__u8 ef="+code=wdata" class="sref">wdata);
<1185 799 784              11"> >118ef">_f="+code=wdata" class="sref">wdata);
<1186 799 785              11"> >118/a>, r i_parsrass="line" namer i_parsrde=ABS_RZ" class="srhdev 826}
 816                if (117L796" class="817"wdata, co1188 7991176" id="L786" aaaaaaaae-core.c#L827" ref_err789" id="L789" ref_errde=ABS_RZ" class="srhdev 826}
}
tring">"HID parsr failed\n" 816                if (117WIIPROTO_REQ_________goto class="line" naerr789" id="L789" err828"> 816                if (11abIIPROTO_REQ_ef="+code=wdata" class="sref">wdata);
<11a1 799, yid, 1192 79911a/a> *r i_hw_starf789" id="L789" r i_hw_starfde=ABS_RZ" class="srhdev 826}
 816                if (wiimote_da11 cl>11a"+code=payloa817"wdata, co1194 79911a/a> *}
tring">"HW starf failed\n" 816                if ( 794        11aef">__u8 ________goto class="line" naerr789" id="L789" err828"> 816                if (wdata);
<11a7 799119" id="L825" class="line" name="L825"> 825  1198 79911a6" id="L786" class="line" naref789" id="L789" ref828"oad" class="sref"> href=registdr_ evic"+code=state" cl href=registdr_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_bufacce"> 718}
 816                if (wdata, 11aWIIPROTO_REQ_817"wdata, co12"> 799 7">wdata,  >120bIIPROTO_REQ_aaaaaaaae-core.c#L827" ref_err789" id="L789" ref_errde=ABS_RZ" class="srhdev 826}
}
tring">"Cannot registdr  href devic"\n" 816                if (, 120de=__u8" clas________goto class="line" naerr_stopass="line" nameerr_stop828"> 816                if (120/a> *wdata);
<12"3 799wiimote_da12"cl>120"+codf="+code=wdata" class="sref">wdata);
<12"4 799120/a> * href=registdr_ evic"+code=state" cl href=registdr_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf rass="line" nameir828""> 816                if ( 794        120ef">__u8 817"wdata, co12"6 79912" class="sref"aaaaaaaae-core.c#L827" ref_err789" id="L789" ref_errde=ABS_RZ" class="srhdev 826}
}
tring">"Cannot registdr  href devic"\n" 816                if (12"ef="drivers/hid/hid-wgoto class="line" naerr_ rass="line" nameerr_ir828""L821"> 821                1208a> *wdata);
<12"9 799wdata, 120put dev.
__>121iIIPROTO_REQ_NULL" class="srref789" id="L789" ref828"oad" class="sref"> href=registdr_ evic"+code=state" cl href=registdr_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf href789" id="L789" lhreflass)> 816                if ( 810        121 name="L710">817"wdata, co1212 799 811    12nam>1212+code=payloaaaaaaaaae-core.c#L827" ref_err789" id="L789" ref_errde=ABS_RZ" class="srhdev 826}
}
tring">"Cannot registdr  href devic"\n" 816                if (err = 12 cl>121"+code=payloaaaaaaaaagoto class="line" naerr_ href789" id="L789" err_ href828""L821"> 821                 813        1214f">__u8 ef="+code=wdata" class="sref">wdata);
<1215 799_f="+code=wdata" class="sref">wdata);
<1216 799(cmd_read_bufbattdryass="line" namebattdry828"d-wiimote-core.cproperties789" id="L789" propertieslassoad" class="sref">
d="L827battdry_props789" id="L789" 
d="L827battdry_props828""L821"> 821                offset))12las>121L796" class="line" name="L796f="+code=cmd_read_buf" class="sref">cmd_read_bufbattdryass="line" namebattdry828"d-wiimote-core.cnum_properties789" id="L789" num_propertieslassoad" class="sref">ARRAY_SIZE789" id="L789" ARRAY_SIZEde=ABa href="drivers/d="L827battdry_props789" id="L789" 
d="L827battdry_props828")> 816                if (err)
cmd_read_bufbattdryass="line" namebattdry828"d-wiimote-core.cget_propertyass="line" nameget_propertylassoad" class="sref">
d="L827battdry_get_propertyass="line" name
d="L827battdry_get_property828""L821"> 821                size > 121WIIPROTO_REQ_NULL" class="sr6f="+code=cmd_read_buf" class="sref">cmd_read_bufbattdryass="line" namebattdry828"d-wiimote-core.cn="+ 826}
"
d="L827battdry" 821                size = 122bIIPROTO_REQ_NULL" class="sr6f="+code=cmd_read_buf" class="sref">cmd_read_bufbattdryass="line" namebattdry828"d-wiimote-core.ctyprass="line" nametypr828"oad" class="sref">POWER_SUPPLY_TYPE_BATTERY 815       POWER_SUPPLY_TYPE_BATTERY828""L821"> 821                state122de=__u8" class="sref">__u8cmd_read_bufbattdryass="line" namebattdry828"d-wiimote-core.cuse_for_apm 826}
 821                wdata-&g12las>122/a> *L821"> 821                power_supply_registdrass="line" namepower_supply_registdrde=AB3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufhdev 826}
cmd_read_bufdev 826}
,d3               
f="+code=cmd_read_buf" class="sref">cmd_read_bufbattdryass="line" namebattdry828")> 816                if (state.wdata, co1225 799122ef">__u8 ________e-core.c#L827" ref_err789" id="L789" ref_errde=ABS_RZ" class="srhdev 826}
}
tring">"Cannot registdr battdry devic"\n" 816                if (wiimote_cmd_compl12"sr>122 class="sref"aaaaaaaagoto class="line" naerr_battdryass="line" nameerr_battdry828""L821"> 821                wdata);
<1228 7991228=__u16" class="sref">__u16                
f="+code=cmd_read_buf" class="sref">cmd_read_bufbattdryass="line" namebattdry828",d3               hdev 826}
cmd_read_bufdev 826}
)> 816                if (123de=__u8" class="sref">__u8="L827">meLs_crea>)ass="line" name="L827">meLs_crea>)de=ABa href="drivers/hid/hid-wiimote-core.c#L828")> 816                if (123/a> *                if ( 821                handler_keys123ef">__u8 ="Lext>ini> 815       
iiext>ini>de=ABS_RZ" class="sr/hid/hid-wiimote-core.c#L828")> 816                if (123 class="sref"817"                if (123ef="drivers/hid/hid-wgoto class="line" naerr_fre)
 821                __u16 123WIIPROTO_REQ_NULL" class="srref789" id="L789" ref828"oad" class="sref">="Ldebug>ini> 815       
iidebug>ini>de=ABS_RZ" class="sr/hid/hid-wiimote-core.c#L828")> 816                if (124bIIPROTO_REQ_817"                if (124de=__u8" clas________goto class="line" naerr_fre)
 821                124/a> *L821"> 821                z = 12z" >124"+code=payload" class="sref"ref_info789" id="L789" ref_infode=ABS_RZ" class="srhdev 826}
}
tring">"New devic" registdred\n" 816                if (124code=handler_keys" class="sref">handler_keys12ief">__u8 "span826}commen> >/* by default set meL1 aftdr devic" ini>ializatio> */handler_keys124/a>, }
               
f="+code=cmd_read_buf" class="sref">cmd_read_bufL805+ 826}
 816                if (z |= (>124L796" class="line" name="L796iiproto_req>meLs 815       
iiproto_req>meLsde=ABS_RZ" class="sr/hid/hid-wiimote-core.c#L828","" href="driversWIIL801" FLAG_LED1hid-wiimote-corWIIL801" FLAG_LED1828")> 816                if (1246" id="L786" class="line" 21233 799              27_irqde=Ade=cmd_read_buf" class="sref">cmd_read_bufL805+ 826}
 816                if (z |= (12i9a>((f">cmd_read_buferr_2href724/hid/hid-wiimot121> 799__u16 w11de=>125bIIPROTO_REQ_NULL" class2"sr h2ef=fre)_ evic"6}
wdata   11ame>12d namef">cmd_read_buferr729" id25" class="sref">1192 799125/a> * 821                __u8 ers/hi clas2="lin25+code=cmd_read_buf" class="sr827">destroyde=ABL7iimote-core.c#L827" id="L827" core.c#L828")> 816                if (}
 ref828") 816                if (_f="+code=wdata" cla2s="sr2f">wdata);
<1156 799__2r_t11put>12d clasL805" ivoid""sref">2emcpy2//d="Line" nameerr_battdry828""L821"> 821                >12d" id=ef="+code=wdata" cl2ss="s25roto_req>meLs 815       te" cl href=unregistdr_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf href789" id="L789" lhreflass)> 816                if (12d6" id="L786" class="line2 na
i2debug>deini> 815       
iief">cmd_read_buf href789" id="L789" lhreflass)> 816                if (       
iid"> 821                __2   11L75>125WIIPROTO_REQ_NULL" class2"sr
i25" id="L789" err_ href828":16" class="sref">__u16 meLs_destroyass="line" nte" cl href=unregistdr_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_buf href789" id="L789" lhreflass)> 8                if ( 794          11L76>12p"sref">yid, cmd_read_bufbattdryass="line" namebattdry8288                if (       
iid"> 821                __2S_H11AT3>12p/a> *__u16 11mot>12p"+code=payload" class="s2ef" h2ef=unregistdr_ evic"+code=state" cl href=unregistdr_ evic"de=ABa href="drivers/hid/hid-wiimote-core.c#L828"="sref">cmd_read_bufacce"> 718}
 816                if (126/a> *cmd_read_bufacce"> 718}
 816                if (       
iid"> 821                __2Sla12re.>12pef">__u8                 if (accel,                 if (_>12pL796" class="line" name=2L79  26ine" nameerr_ir828":16"              (__216cmd_read_bufacce"> 718}
 8                if ( 794          11L75>12pWIIPROTO_REQ_NULL" class2"srkf2e)
cmd_read_bufacce"> 718}
 816                if (cmd_read_buf href789" id="L789" lhreflass)> 816                if ( 750 2"li11769>127"sref">yid,  816                if (12w/a> *L805" iinote-core.c2L827"27ref789" id="L6}
 ref828") 816                if ();
<1228 79912wcode=ef="+code=wdata" cl2ss="s27handler_keys12wef">__u8 L7iimote-co2e.c#L227" id827destroyass="line" name="L827">dehid/remova>)de=ABa href="drivers/hid/removamote-+code=state" clref_devic"atic void yid, 127" id="L825" class="line"2name=27roto_req>meLsclass="line" name="L827"> 827
 821                <9" id="L789" r i_hw_st    drv1"> 821        w_st    drv1"> mote-core.c#L828"="s6                if (1276" id="L786" class="line2 nahd27}
tring">"New devic" registdred\n" 816128iIIPROTO_REQ_NULL" class2"sr
f2"+code=cmd_read_buf" classoad"827">destroyde=ABL7iimote-core.c#L827" id="L827" core.c#L828")> 816                if (817"!class=2line"2na/hidata);
<1228 799 >1282+code=payloaaaaaaaaae-c2re.c#28   z   11"> >128"+code=payloaaaaaaaaaers2hi -S2RZ" cl827destdevic"_&L789" id="L789" ref_devic"_&Latic void dehid/789" iprops828")> 816     hid/789" ipL789[]9" ata, co1225 7991274f">__u8 ef="+code=w2ata" 2lass="sref">wd{AW 815       HIDBLUETOOTH_DEVIC href="drivers/d HIDBLUETOOTH_DEVIC 827" core.c#L828")> USB_VENDOR_HIDNINTENDOhref="drivers/dUSB_VENDOR_HIDNINTENDO;New ta, co1225 799128ef">_f="+code=wdata" cla2s="sr2827" ref_err789" id="LLLLLLLLLLLLLLLLLcore.c#L828")> USB_DEVIC _HIDNINTENDO_WIIMOT href="drivers/dUSB_DEVIC _HIDNINTENDO_WIIMOT  (, co1225 799128/a>, );
<1228 799127L796" class="817" 7991276" id="L786" aaaaaaaae-c2re.c#2827" rcore.c#L828")> MODULE_DEVIC _TABL href="drivers/dMODULE_DEVIC _TABL }
dehid/789" iprops828")> 816     hid/789" ipL789 href="+code124> 799127WIIPROTO_REQ_________got2 clas28/hid/hid-wiimot121> 799__u16  7 void dehid/721> 7 void dehid/721> 7   <9" ata, co1225 799129"sref">yid, "
d="L827battdry" 821       if (, co1225 79912a/a> *dehid/789" iprops828")> 816     hid/789" ipL789 ta, co1225 799 >12a"+code=payloa817"dehid/probrde=ABL7iimote-core.c#L827" hef_devic ta, co1225 79912a/a> * 81mova>)de=ABa href="removamote9" id="L789" r i_hL827">dehid/remova>)de=ABa href="drivers/hid/removamote ta, co1225 79912aef">__u8 ________got2 clas2="line" naerr7nameready828")> 8aw_evr de)de=ABa href="raw_evr dmote9" id="L789" r i_hL827">dehid/evr de)de=ABa href="L827">dehid/evr dmote ta, co1225 7991296IIPROTO_REQ_ef="+code=w2ata" 2lass="}href="+code124> 799129" id="L825" class="line"2name=2L825"> 825  1198 79912a6" id="L786" class="line2 nare2789" i">  i_probrass="line" name_>de=ABS_RZ" class="s_d-wiimote id="L789" r i_hL827">dede=ABS_RZ" class="sr/h7">dede=A}
, co1225 799 >130bIIPROTO_REQ_aaaaaaaae-c3re.c#3827" ref_err78789" ref828""L821"> 821                130de=__u8" clas________got3 clas30" class="sref">1192 799130/a> *r i_hw_starf789" id="L789" r i_hw_sters/hid/hi21> 7 void dehid/721> 7 void dehid/721> 7   < href="+code124> 799130"+codf="+code=wdata" cla3s="sr30ref789" id="L789" ref828") ef="+code=wdata" class="sref">wref="+code124> 799130/a> * 81/span1)> wiimote 2id 124> 7         if (130ef">__u8 817"wdata);
<1156 799__3ref12"co>13" class="sref"aaaaaaaae-c3re.c#3827" ref_err786}
 ref828") 816                if (13"ef="drivers/hid/hid-wgot3 clas3="lineata);
<1228 799130put dev.
deex=ABS_RZ" class="sL827">deex=A}
, co1225 799131 name="L710">817" 7}
dehid/721> 7 void dehid/721> 7   < href="+code124> 7991312+code=payloaaaaaaaaae-c3re.c#3827" rata);
<1228 799131"+code=payloaaaaaaaaagot3 clas31">wdata);
<12"4 7991314f">__u8 ef="+code=w3ata" 3lass="d_buf" class="smoduldede=ABS_RZ" class="smoduldede=A827" core.c#L828")> 8827">dede=ABS_RZ" class="sr/h7">dede=A}
131ef">_f="+code=wdata" cla3s="sr31f=unr"driveerr_fre)8moduldeex=ABS_RZ" class="smoduldeex=A827" core.c#L828")> 8827">deex=ABS_RZ" class="sL827">deex=A}
13>/a>, ))12las>131L796" class="line" name=3L796f31ine" nameerr_ir828":MODULE_AUTHORhref="drivers/dMODULE_AUTHOR}
dr12"=">1316" id="L786" class="line3 na
f3127" rcore.c#L828")> MODULE_DESCRIPTIONhref="drivers/dMODULE_DESCRIPTION827" core.c#L828")> WIIMOT _NAM href="drivers/dWIIMOT _NAM mote i9;t allof devic"\n" 816ef12"re>131WIIPROTO_REQ_NULL" class3"sr6f3"+code


The original LXR software" inthe ef="+codehttp://sourceforge.net/projects/lxis>LXR aftdue=A826this experidr dal 4 79="sr inef="+codemailto:lxi@EQ_ux.no">lxi@EQ_ux.no26 lxi.EQ_ux.no kindly hohiddr inef="+codehttp://www.redpill-EQ_pro.no">Redpill LQ_pro AS26provya)> of LQ_uxtdeviult"\n and ss="ss ser9" ip sin16<1995.