0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/types.h>
0011 #include <linux/dmi.h>
0012 #include <linux/mod_devicetable.h>
0013
0014 #include "i2c-hid.h"
0015
0016
0017 struct i2c_hid_desc_override {
0018 union {
0019 struct i2c_hid_desc *i2c_hid_desc;
0020 uint8_t *i2c_hid_desc_buffer;
0021 };
0022 uint8_t *hid_report_desc;
0023 unsigned int hid_report_desc_size;
0024 uint8_t *i2c_name;
0025 };
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 static const struct i2c_hid_desc_override sipodev_desc = {
0039 .i2c_hid_desc_buffer = (uint8_t [])
0040 {0x1e, 0x00,
0041 0x00, 0x01,
0042 0xdb, 0x01,
0043 0x21, 0x00,
0044 0x24, 0x00,
0045 0x1b, 0x00,
0046 0x25, 0x00,
0047 0x11, 0x00,
0048 0x22, 0x00,
0049 0x23, 0x00,
0050 0x11, 0x09,
0051 0x88, 0x52,
0052 0x06, 0x00,
0053 0x00, 0x00, 0x00, 0x00
0054 },
0055
0056 .hid_report_desc = (uint8_t [])
0057 {0x05, 0x01,
0058 0x09, 0x02,
0059 0xA1, 0x01,
0060 0x85, 0x01,
0061 0x09, 0x01,
0062 0xA1, 0x00,
0063 0x05, 0x09,
0064 0x19, 0x01,
0065 0x29, 0x02,
0066 0x25, 0x01,
0067 0x75, 0x01,
0068 0x95, 0x02,
0069 0x81, 0x02,
0070 0x95, 0x06,
0071 0x81, 0x01,
0072 0x05, 0x01,
0073 0x09, 0x30,
0074 0x09, 0x31,
0075 0x15, 0x81,
0076 0x25, 0x7F,
0077 0x75, 0x08,
0078 0x95, 0x02,
0079 0x81, 0x06,
0080 0xC0,
0081 0xC0,
0082 0x05, 0x0D,
0083 0x09, 0x05,
0084 0xA1, 0x01,
0085 0x85, 0x04,
0086 0x05, 0x0D,
0087 0x09, 0x22,
0088 0xA1, 0x02,
0089 0x15, 0x00,
0090 0x25, 0x01,
0091 0x09, 0x47,
0092 0x09, 0x42,
0093 0x95, 0x02,
0094 0x75, 0x01,
0095 0x81, 0x02,
0096 0x95, 0x01,
0097 0x75, 0x03,
0098 0x25, 0x05,
0099 0x09, 0x51,
0100 0x81, 0x02,
0101 0x75, 0x01,
0102 0x95, 0x03,
0103 0x81, 0x03,
0104 0x05, 0x01,
0105 0x26, 0x44, 0x0A,
0106 0x75, 0x10,
0107 0x55, 0x0E,
0108 0x65, 0x11,
0109 0x09, 0x30,
0110 0x46, 0x1A, 0x04,
0111 0x95, 0x01,
0112 0x81, 0x02,
0113 0x46, 0xBC, 0x02,
0114 0x26, 0x34, 0x05,
0115 0x09, 0x31,
0116 0x81, 0x02,
0117 0xC0,
0118 0x05, 0x0D,
0119 0x09, 0x22,
0120 0xA1, 0x02,
0121 0x25, 0x01,
0122 0x09, 0x47,
0123 0x09, 0x42,
0124 0x95, 0x02,
0125 0x75, 0x01,
0126 0x81, 0x02,
0127 0x95, 0x01,
0128 0x75, 0x03,
0129 0x25, 0x05,
0130 0x09, 0x51,
0131 0x81, 0x02,
0132 0x75, 0x01,
0133 0x95, 0x03,
0134 0x81, 0x03,
0135 0x05, 0x01,
0136 0x26, 0x44, 0x0A,
0137 0x75, 0x10,
0138 0x09, 0x30,
0139 0x46, 0x1A, 0x04,
0140 0x95, 0x01,
0141 0x81, 0x02,
0142 0x46, 0xBC, 0x02,
0143 0x26, 0x34, 0x05,
0144 0x09, 0x31,
0145 0x81, 0x02,
0146 0xC0,
0147 0x05, 0x0D,
0148 0x09, 0x22,
0149 0xA1, 0x02,
0150 0x25, 0x01,
0151 0x09, 0x47,
0152 0x09, 0x42,
0153 0x95, 0x02,
0154 0x75, 0x01,
0155 0x81, 0x02,
0156 0x95, 0x01,
0157 0x75, 0x03,
0158 0x25, 0x05,
0159 0x09, 0x51,
0160 0x81, 0x02,
0161 0x75, 0x01,
0162 0x95, 0x03,
0163 0x81, 0x03,
0164 0x05, 0x01,
0165 0x26, 0x44, 0x0A,
0166 0x75, 0x10,
0167 0x09, 0x30,
0168 0x46, 0x1A, 0x04,
0169 0x95, 0x01,
0170 0x81, 0x02,
0171 0x46, 0xBC, 0x02,
0172 0x26, 0x34, 0x05,
0173 0x09, 0x31,
0174 0x81, 0x02,
0175 0xC0,
0176 0x05, 0x0D,
0177 0x09, 0x22,
0178 0xA1, 0x02,
0179 0x25, 0x01,
0180 0x09, 0x47,
0181 0x09, 0x42,
0182 0x95, 0x02,
0183 0x75, 0x01,
0184 0x81, 0x02,
0185 0x95, 0x01,
0186 0x75, 0x03,
0187 0x25, 0x05,
0188 0x09, 0x51,
0189 0x81, 0x02,
0190 0x75, 0x01,
0191 0x95, 0x03,
0192 0x81, 0x03,
0193 0x05, 0x01,
0194 0x26, 0x44, 0x0A,
0195 0x75, 0x10,
0196 0x09, 0x30,
0197 0x46, 0x1A, 0x04,
0198 0x95, 0x01,
0199 0x81, 0x02,
0200 0x46, 0xBC, 0x02,
0201 0x26, 0x34, 0x05,
0202 0x09, 0x31,
0203 0x81, 0x02,
0204 0xC0,
0205 0x05, 0x0D,
0206 0x55, 0x0C,
0207 0x66, 0x01, 0x10,
0208 0x47, 0xFF, 0xFF, 0x00, 0x00,
0209 0x27, 0xFF, 0xFF, 0x00, 0x00,
0210 0x75, 0x10,
0211 0x95, 0x01,
0212 0x09, 0x56,
0213 0x81, 0x02,
0214 0x09, 0x54,
0215 0x25, 0x7F,
0216 0x75, 0x08,
0217 0x81, 0x02,
0218 0x05, 0x09,
0219 0x09, 0x01,
0220 0x25, 0x01,
0221 0x75, 0x01,
0222 0x95, 0x01,
0223 0x81, 0x02,
0224 0x95, 0x07,
0225 0x81, 0x03,
0226 0x05, 0x0D,
0227 0x85, 0x02,
0228 0x09, 0x55,
0229 0x09, 0x59,
0230 0x75, 0x04,
0231 0x95, 0x02,
0232 0x25, 0x0F,
0233 0xB1, 0x02,
0234 0x05, 0x0D,
0235 0x85, 0x07,
0236 0x09, 0x60,
0237 0x75, 0x01,
0238 0x95, 0x01,
0239 0x25, 0x01,
0240 0xB1, 0x02,
0241 0x95, 0x07,
0242 0xB1, 0x03,
0243 0x85, 0x06,
0244 0x06, 0x00, 0xFF,
0245 0x09, 0xC5,
0246 0x26, 0xFF, 0x00,
0247 0x75, 0x08,
0248 0x96, 0x00, 0x01,
0249 0xB1, 0x02,
0250 0xC0,
0251 0x06, 0x00, 0xFF,
0252 0x09, 0x01,
0253 0xA1, 0x01,
0254 0x85, 0x0D,
0255 0x26, 0xFF, 0x00,
0256 0x19, 0x01,
0257 0x29, 0x02,
0258 0x75, 0x08,
0259 0x95, 0x02,
0260 0xB1, 0x02,
0261 0xC0,
0262 0x05, 0x0D,
0263 0x09, 0x0E,
0264 0xA1, 0x01,
0265 0x85, 0x03,
0266 0x09, 0x22,
0267 0xA1, 0x02,
0268 0x09, 0x52,
0269 0x25, 0x0A,
0270 0x95, 0x01,
0271 0xB1, 0x02,
0272 0xC0,
0273 0x09, 0x22,
0274 0xA1, 0x00,
0275 0x85, 0x05,
0276 0x09, 0x57,
0277 0x09, 0x58,
0278 0x75, 0x01,
0279 0x95, 0x02,
0280 0x25, 0x01,
0281 0xB1, 0x02,
0282 0x95, 0x06,
0283 0xB1, 0x03,
0284 0xC0,
0285 0xC0
0286 },
0287 .hid_report_desc_size = 475,
0288 .i2c_name = "SYNA3602:00"
0289 };
0290
0291
0292 static const struct dmi_system_id i2c_hid_dmi_desc_override_table[] = {
0293 {
0294 .ident = "Teclast F6 Pro",
0295 .matches = {
0296 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TECLAST"),
0297 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "F6 Pro"),
0298 },
0299 .driver_data = (void *)&sipodev_desc
0300 },
0301 {
0302 .ident = "Teclast F7",
0303 .matches = {
0304 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TECLAST"),
0305 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "F7"),
0306 },
0307 .driver_data = (void *)&sipodev_desc
0308 },
0309 {
0310 .ident = "Trekstor Primebook C13",
0311 .matches = {
0312 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TREKSTOR"),
0313 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Primebook C13"),
0314 },
0315 .driver_data = (void *)&sipodev_desc
0316 },
0317 {
0318 .ident = "Trekstor Primebook C11",
0319 .matches = {
0320 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TREKSTOR"),
0321 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Primebook C11"),
0322 },
0323 .driver_data = (void *)&sipodev_desc
0324 },
0325 {
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337 .ident = "Trekstor Primebook C11B",
0338 .matches = {
0339 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TREKSTOR"),
0340 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Primebook C11B"),
0341 },
0342 .driver_data = (void *)&sipodev_desc
0343 },
0344 {
0345 .ident = "Trekstor SURFBOOK E11B",
0346 .matches = {
0347 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TREKSTOR"),
0348 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SURFBOOK E11B"),
0349 },
0350 .driver_data = (void *)&sipodev_desc
0351 },
0352 {
0353 .ident = "Direkt-Tek DTLAPY116-2",
0354 .matches = {
0355 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Direkt-Tek"),
0356 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "DTLAPY116-2"),
0357 },
0358 .driver_data = (void *)&sipodev_desc
0359 },
0360 {
0361 .ident = "Direkt-Tek DTLAPY133-1",
0362 .matches = {
0363 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Direkt-Tek"),
0364 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "DTLAPY133-1"),
0365 },
0366 .driver_data = (void *)&sipodev_desc
0367 },
0368 {
0369 .ident = "Mediacom Flexbook Edge 11",
0370 .matches = {
0371 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MEDIACOM"),
0372 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "FlexBook edge11 - M-FBE11"),
0373 },
0374 .driver_data = (void *)&sipodev_desc
0375 },
0376 {
0377 .ident = "Mediacom FlexBook edge 13",
0378 .matches = {
0379 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MEDIACOM"),
0380 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "FlexBook_edge13-M-FBE13"),
0381 },
0382 .driver_data = (void *)&sipodev_desc
0383 },
0384 {
0385 .ident = "Odys Winbook 13",
0386 .matches = {
0387 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "AXDIA International GmbH"),
0388 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "WINBOOK 13"),
0389 },
0390 .driver_data = (void *)&sipodev_desc
0391 },
0392 {
0393 .ident = "iBall Aer3",
0394 .matches = {
0395 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "iBall"),
0396 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Aer3"),
0397 },
0398 .driver_data = (void *)&sipodev_desc
0399 },
0400 {
0401 .ident = "Schneider SCL142ALM",
0402 .matches = {
0403 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "SCHNEIDER"),
0404 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SCL142ALM"),
0405 },
0406 .driver_data = (void *)&sipodev_desc
0407 },
0408 {
0409 .ident = "Vero K147",
0410 .matches = {
0411 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "VERO"),
0412 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "K147"),
0413 },
0414 .driver_data = (void *)&sipodev_desc
0415 },
0416 { }
0417 };
0418
0419
0420 struct i2c_hid_desc *i2c_hid_get_dmi_i2c_hid_desc_override(uint8_t *i2c_name)
0421 {
0422 struct i2c_hid_desc_override *override;
0423 const struct dmi_system_id *system_id;
0424
0425 system_id = dmi_first_match(i2c_hid_dmi_desc_override_table);
0426 if (!system_id)
0427 return NULL;
0428
0429 override = system_id->driver_data;
0430 if (strcmp(override->i2c_name, i2c_name))
0431 return NULL;
0432
0433 return override->i2c_hid_desc;
0434 }
0435
0436 char *i2c_hid_get_dmi_hid_report_desc_override(uint8_t *i2c_name,
0437 unsigned int *size)
0438 {
0439 struct i2c_hid_desc_override *override;
0440 const struct dmi_system_id *system_id;
0441
0442 system_id = dmi_first_match(i2c_hid_dmi_desc_override_table);
0443 if (!system_id)
0444 return NULL;
0445
0446 override = system_id->driver_data;
0447 if (strcmp(override->i2c_name, i2c_name))
0448 return NULL;
0449
0450 *size = override->hid_report_desc_size;
0451 return override->hid_report_desc;
0452 }