162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  HID driver for various devices which are apparently based on the same chipset
462306a36Sopenharmony_ci *  from certain vendor which produces chips that contain wrong LogicalMaximum
562306a36Sopenharmony_ci *  value in their HID report descriptor. Currently supported devices are:
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci *    Ortek PKB-1700
862306a36Sopenharmony_ci *    Ortek WKB-2000
962306a36Sopenharmony_ci *    iHome IMAC-A210S
1062306a36Sopenharmony_ci *    Skycable wireless presenter
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci *  Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com>
1362306a36Sopenharmony_ci *  Copyright (c) 2011 Jiri Kosina
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/*
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#include <linux/device.h>
2062306a36Sopenharmony_ci#include <linux/hid.h>
2162306a36Sopenharmony_ci#include <linux/module.h>
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#include "hid-ids.h"
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_cistatic __u8 *ortek_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2662306a36Sopenharmony_ci		unsigned int *rsize)
2762306a36Sopenharmony_ci{
2862306a36Sopenharmony_ci	if (*rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x01) {
2962306a36Sopenharmony_ci		hid_info(hdev, "Fixing up logical maximum in report descriptor (Ortek)\n");
3062306a36Sopenharmony_ci		rdesc[55] = 0x92;
3162306a36Sopenharmony_ci	} else if (*rsize >= 54 && rdesc[52] == 0x25 && rdesc[53] == 0x01) {
3262306a36Sopenharmony_ci		hid_info(hdev, "Fixing up logical maximum in report descriptor (Skycable)\n");
3362306a36Sopenharmony_ci		rdesc[53] = 0x65;
3462306a36Sopenharmony_ci	}
3562306a36Sopenharmony_ci	return rdesc;
3662306a36Sopenharmony_ci}
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_cistatic const struct hid_device_id ortek_devices[] = {
3962306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) },
4062306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
4162306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_IHOME_IMAC_A210S) },
4262306a36Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
4362306a36Sopenharmony_ci	{ }
4462306a36Sopenharmony_ci};
4562306a36Sopenharmony_ciMODULE_DEVICE_TABLE(hid, ortek_devices);
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_cistatic struct hid_driver ortek_driver = {
4862306a36Sopenharmony_ci	.name = "ortek",
4962306a36Sopenharmony_ci	.id_table = ortek_devices,
5062306a36Sopenharmony_ci	.report_fixup = ortek_report_fixup
5162306a36Sopenharmony_ci};
5262306a36Sopenharmony_cimodule_hid_driver(ortek_driver);
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciMODULE_LICENSE("GPL");
55