input-polldev.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef _INPUT_POLLDEV_H
  3. #define _INPUT_POLLDEV_H
  4. /*
  5. * Copyright (c) 2007 Dmitry Torokhov
  6. */
  7. #include <linux/input.h>
  8. #include <linux/workqueue.h>
  9. /**
  10. * struct input_polled_dev - simple polled input device
  11. * @private: private driver data.
  12. * @open: driver-supplied method that prepares device for polling
  13. * (enabled the device and maybe flushes device state).
  14. * @close: driver-supplied method that is called when device is no
  15. * longer being polled. Used to put device into low power mode.
  16. * @poll: driver-supplied method that polls the device and posts
  17. * input events (mandatory).
  18. * @poll_interval: specifies how often the poll() method should be called.
  19. * Defaults to 500 msec unless overridden when registering the device.
  20. * @poll_interval_max: specifies upper bound for the poll interval.
  21. * Defaults to the initial value of @poll_interval.
  22. * @poll_interval_min: specifies lower bound for the poll interval.
  23. * Defaults to 0.
  24. * @input: input device structure associated with the polled device.
  25. * Must be properly initialized by the driver (id, name, phys, bits).
  26. *
  27. * Polled input device provides a skeleton for supporting simple input
  28. * devices that do not raise interrupts but have to be periodically
  29. * scanned or polled to detect changes in their state.
  30. */
  31. struct input_polled_dev {
  32. void *private;
  33. void (*open)(struct input_polled_dev *dev);
  34. void (*close)(struct input_polled_dev *dev);
  35. void (*poll)(struct input_polled_dev *dev);
  36. unsigned int poll_interval; /* msec */
  37. unsigned int poll_interval_max; /* msec */
  38. unsigned int poll_interval_min; /* msec */
  39. struct input_dev *input;
  40. /* private: */
  41. struct delayed_work work;
  42. bool devres_managed;
  43. };
  44. struct input_polled_dev *input_allocate_polled_device(void);
  45. struct input_polled_dev *devm_input_allocate_polled_device(struct device *dev);
  46. void input_free_polled_device(struct input_polled_dev *dev);
  47. int input_register_polled_device(struct input_polled_dev *dev);
  48. void input_unregister_polled_device(struct input_polled_dev *dev);
  49. #endif