You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
3.0KB

  1. /*-
  2. * Copyright (c) 2018-2019 Marc Priggemeyer <marc.priggemeyer@gmail.com>
  3. * Copyright (c) 2019 Vladimir Kondratyev <wulf@FreeBSD.org>
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. * SUCH DAMAGE.
  25. */
  26. #ifndef _IICHIDVAR_H_
  27. #define _IICHIDVAR_H_
  28. #define I2C_HID_REPORT_TYPE_INPUT 0x1
  29. #define I2C_HID_REPORT_TYPE_OUTPUT 0x2
  30. #define I2C_HID_REPORT_TYPE_FEATURE 0x3
  31. /* 7.2 */
  32. enum {
  33. I2C_HID_CMD_DESCR = 0x0,
  34. I2C_HID_CMD_RESET = 0x1,
  35. I2C_HID_CMD_GET_REPORT = 0x2,
  36. I2C_HID_CMD_SET_REPORT = 0x3,
  37. I2C_HID_CMD_GET_IDLE = 0x4,
  38. I2C_HID_CMD_SET_IDLE = 0x5,
  39. I2C_HID_CMD_GET_PROTO = 0x6,
  40. I2C_HID_CMD_SET_PROTO = 0x7,
  41. I2C_HID_CMD_SET_POWER = 0x8,
  42. };
  43. #define I2C_HID_POWER_ON 0x0
  44. #define I2C_HID_POWER_OFF 0x1
  45. /*
  46. * Since interrupt resource acquisition is not always possible (in case of GPIO
  47. * interrupts) iichid now supports a sampling_mode.
  48. * Set dev.iichid.<unit>.sampling_rate_fast to a value greater then 0
  49. * to activate sampling. A value of 0 is possible but will not reset the
  50. * callout and, thereby, disable further report requests. Do not set the
  51. * sampling_rate_fast value too high as it may result in periodical lags of
  52. * cursor motion.
  53. */
  54. #define IICHID_SAMPLING_RATE_FAST 60
  55. #define IICHID_SAMPLING_RATE_SLOW 5
  56. #define IICHID_SAMPLING_HYSTERESIS 1
  57. /* 5.1.1 - HID Descriptor Format */
  58. struct i2c_hid_desc {
  59. uint16_t wHIDDescLength;
  60. uint16_t bcdVersion;
  61. uint16_t wReportDescLength;
  62. uint16_t wReportDescRegister;
  63. uint16_t wInputRegister;
  64. uint16_t wMaxInputLength;
  65. uint16_t wOutputRegister;
  66. uint16_t wMaxOutputLength;
  67. uint16_t wCommandRegister;
  68. uint16_t wDataRegister;
  69. uint16_t wVendorID;
  70. uint16_t wProductID;
  71. uint16_t wVersionID;
  72. uint32_t reserved;
  73. } __packed;
  74. #endif /* _IICHIDVAR_H_ */