cec-pin.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * cec-pin.h - low-level CEC pin control
  4. *
  5. * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
  6. */
  7. #ifndef LINUX_CEC_PIN_H
  8. #define LINUX_CEC_PIN_H
  9. #include <linux/types.h>
  10. #include <media/cec.h>
  11. /**
  12. * struct cec_pin_ops - low-level CEC pin operations
  13. * @read: read the CEC pin. Return true if high, false if low.
  14. * @low: drive the CEC pin low.
  15. * @high: stop driving the CEC pin. The pull-up will drive the pin
  16. * high, unless someone else is driving the pin low.
  17. * @enable_irq: optional, enable the interrupt to detect pin voltage changes.
  18. * @disable_irq: optional, disable the interrupt.
  19. * @free: optional. Free any allocated resources. Called when the
  20. * adapter is deleted.
  21. * @status: optional, log status information.
  22. * @read_hpd: read the HPD pin. Return true if high, false if low or
  23. * an error if negative. If NULL or -ENOTTY is returned,
  24. * then this is not supported.
  25. * @read_5v: read the 5V pin. Return true if high, false if low or
  26. * an error if negative. If NULL or -ENOTTY is returned,
  27. * then this is not supported.
  28. *
  29. * These operations are used by the cec pin framework to manipulate
  30. * the CEC pin.
  31. */
  32. struct cec_pin_ops {
  33. bool (*read)(struct cec_adapter *adap);
  34. void (*low)(struct cec_adapter *adap);
  35. void (*high)(struct cec_adapter *adap);
  36. bool (*enable_irq)(struct cec_adapter *adap);
  37. void (*disable_irq)(struct cec_adapter *adap);
  38. void (*free)(struct cec_adapter *adap);
  39. void (*status)(struct cec_adapter *adap, struct seq_file *file);
  40. int (*read_hpd)(struct cec_adapter *adap);
  41. int (*read_5v)(struct cec_adapter *adap);
  42. };
  43. /**
  44. * cec_pin_changed() - update pin state from interrupt
  45. *
  46. * @adap: pointer to the cec adapter
  47. * @value: when true the pin is high, otherwise it is low
  48. *
  49. * If changes of the CEC voltage are detected via an interrupt, then
  50. * cec_pin_changed is called from the interrupt with the new value.
  51. */
  52. void cec_pin_changed(struct cec_adapter *adap, bool value);
  53. /**
  54. * cec_pin_allocate_adapter() - allocate a pin-based cec adapter
  55. *
  56. * @pin_ops: low-level pin operations
  57. * @priv: will be stored in adap->priv and can be used by the adapter ops.
  58. * Use cec_get_drvdata(adap) to get the priv pointer.
  59. * @name: the name of the CEC adapter. Note: this name will be copied.
  60. * @caps: capabilities of the CEC adapter. This will be ORed with
  61. * CEC_CAP_MONITOR_ALL and CEC_CAP_MONITOR_PIN.
  62. *
  63. * Allocate a cec adapter using the cec pin framework.
  64. *
  65. * Return: a pointer to the cec adapter or an error pointer
  66. */
  67. struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,
  68. void *priv, const char *name, u32 caps);
  69. #endif