164b386ea16112564e0b93473e2c347125effb6b2Richard Nauber/*
264b386ea16112564e0b93473e2c347125effb6b2Richard Nauber *  HID driver for Elecom BM084 (bluetooth mouse).
364b386ea16112564e0b93473e2c347125effb6b2Richard Nauber *  Removes a non-existing horizontal wheel from
464b386ea16112564e0b93473e2c347125effb6b2Richard Nauber *  the HID descriptor.
564b386ea16112564e0b93473e2c347125effb6b2Richard Nauber *  (This module is based on "hid-ortek".)
664b386ea16112564e0b93473e2c347125effb6b2Richard Nauber *
764b386ea16112564e0b93473e2c347125effb6b2Richard Nauber *  Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com>
864b386ea16112564e0b93473e2c347125effb6b2Richard Nauber */
964b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
1064b386ea16112564e0b93473e2c347125effb6b2Richard Nauber/*
1164b386ea16112564e0b93473e2c347125effb6b2Richard Nauber * This program is free software; you can redistribute it and/or modify it
1264b386ea16112564e0b93473e2c347125effb6b2Richard Nauber * under the terms of the GNU General Public License as published by the Free
1364b386ea16112564e0b93473e2c347125effb6b2Richard Nauber * Software Foundation; either version 2 of the License, or (at your option)
1464b386ea16112564e0b93473e2c347125effb6b2Richard Nauber * any later version.
1564b386ea16112564e0b93473e2c347125effb6b2Richard Nauber */
1664b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
1764b386ea16112564e0b93473e2c347125effb6b2Richard Nauber#include <linux/device.h>
1864b386ea16112564e0b93473e2c347125effb6b2Richard Nauber#include <linux/hid.h>
1964b386ea16112564e0b93473e2c347125effb6b2Richard Nauber#include <linux/module.h>
2064b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
2164b386ea16112564e0b93473e2c347125effb6b2Richard Nauber#include "hid-ids.h"
2264b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
2373e4008ddddc84d5f2499c17012b340a0dae153eNikolai Kondrashovstatic __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2473e4008ddddc84d5f2499c17012b340a0dae153eNikolai Kondrashov		unsigned int *rsize)
2564b386ea16112564e0b93473e2c347125effb6b2Richard Nauber{
2673e4008ddddc84d5f2499c17012b340a0dae153eNikolai Kondrashov	if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) {
274291ee305e9bb0699504a66f0e2b7aefcf0512a5Joe Perches		hid_info(hdev, "Fixing up Elecom BM084 report descriptor\n");
2864b386ea16112564e0b93473e2c347125effb6b2Richard Nauber		rdesc[47] = 0x00;
2964b386ea16112564e0b93473e2c347125effb6b2Richard Nauber	}
3073e4008ddddc84d5f2499c17012b340a0dae153eNikolai Kondrashov    return rdesc;
3164b386ea16112564e0b93473e2c347125effb6b2Richard Nauber}
3264b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
3364b386ea16112564e0b93473e2c347125effb6b2Richard Nauberstatic const struct hid_device_id elecom_devices[] = {
3464b386ea16112564e0b93473e2c347125effb6b2Richard Nauber	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084)},
3564b386ea16112564e0b93473e2c347125effb6b2Richard Nauber	{ }
3664b386ea16112564e0b93473e2c347125effb6b2Richard Nauber};
3764b386ea16112564e0b93473e2c347125effb6b2Richard NauberMODULE_DEVICE_TABLE(hid, elecom_devices);
3864b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
3964b386ea16112564e0b93473e2c347125effb6b2Richard Nauberstatic struct hid_driver elecom_driver = {
4064b386ea16112564e0b93473e2c347125effb6b2Richard Nauber	.name = "elecom",
4164b386ea16112564e0b93473e2c347125effb6b2Richard Nauber	.id_table = elecom_devices,
4264b386ea16112564e0b93473e2c347125effb6b2Richard Nauber	.report_fixup = elecom_report_fixup
4364b386ea16112564e0b93473e2c347125effb6b2Richard Nauber};
4464b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
4564b386ea16112564e0b93473e2c347125effb6b2Richard Nauberstatic int __init elecom_init(void)
4664b386ea16112564e0b93473e2c347125effb6b2Richard Nauber{
4764b386ea16112564e0b93473e2c347125effb6b2Richard Nauber	return hid_register_driver(&elecom_driver);
4864b386ea16112564e0b93473e2c347125effb6b2Richard Nauber}
4964b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
5064b386ea16112564e0b93473e2c347125effb6b2Richard Nauberstatic void __exit elecom_exit(void)
5164b386ea16112564e0b93473e2c347125effb6b2Richard Nauber{
5264b386ea16112564e0b93473e2c347125effb6b2Richard Nauber	hid_unregister_driver(&elecom_driver);
5364b386ea16112564e0b93473e2c347125effb6b2Richard Nauber}
5464b386ea16112564e0b93473e2c347125effb6b2Richard Nauber
5564b386ea16112564e0b93473e2c347125effb6b2Richard Naubermodule_init(elecom_init);
5664b386ea16112564e0b93473e2c347125effb6b2Richard Naubermodule_exit(elecom_exit);
5764b386ea16112564e0b93473e2c347125effb6b2Richard NauberMODULE_LICENSE("GPL");
58