18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  HID driver for various devices which are apparently based on the same chipset
48c2ecf20Sopenharmony_ci *  from certain vendor which produces chips that contain wrong LogicalMaximum
58c2ecf20Sopenharmony_ci *  value in their HID report descriptor. Currently supported devices are:
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *    Ortek PKB-1700
88c2ecf20Sopenharmony_ci *    Ortek WKB-2000
98c2ecf20Sopenharmony_ci *    iHome IMAC-A210S
108c2ecf20Sopenharmony_ci *    Skycable wireless presenter
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *  Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com>
138c2ecf20Sopenharmony_ci *  Copyright (c) 2011 Jiri Kosina
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/*
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include <linux/device.h>
208c2ecf20Sopenharmony_ci#include <linux/hid.h>
218c2ecf20Sopenharmony_ci#include <linux/module.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include "hid-ids.h"
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistatic __u8 *ortek_report_fixup(struct hid_device *hdev, __u8 *rdesc,
268c2ecf20Sopenharmony_ci		unsigned int *rsize)
278c2ecf20Sopenharmony_ci{
288c2ecf20Sopenharmony_ci	if (*rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x01) {
298c2ecf20Sopenharmony_ci		hid_info(hdev, "Fixing up logical maximum in report descriptor (Ortek)\n");
308c2ecf20Sopenharmony_ci		rdesc[55] = 0x92;
318c2ecf20Sopenharmony_ci	} else if (*rsize >= 54 && rdesc[52] == 0x25 && rdesc[53] == 0x01) {
328c2ecf20Sopenharmony_ci		hid_info(hdev, "Fixing up logical maximum in report descriptor (Skycable)\n");
338c2ecf20Sopenharmony_ci		rdesc[53] = 0x65;
348c2ecf20Sopenharmony_ci	}
358c2ecf20Sopenharmony_ci	return rdesc;
368c2ecf20Sopenharmony_ci}
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistatic const struct hid_device_id ortek_devices[] = {
398c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) },
408c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
418c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_IHOME_IMAC_A210S) },
428c2ecf20Sopenharmony_ci	{ HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
438c2ecf20Sopenharmony_ci	{ }
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(hid, ortek_devices);
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistatic struct hid_driver ortek_driver = {
488c2ecf20Sopenharmony_ci	.name = "ortek",
498c2ecf20Sopenharmony_ci	.id_table = ortek_devices,
508c2ecf20Sopenharmony_ci	.report_fixup = ortek_report_fixup
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_cimodule_hid_driver(ortek_driver);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
55