cec-pin.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. Returns > 0 if high, 0 if low, or an error
  14. * if negative.
  15. * @low: drive the CEC pin low.
  16. * @high: stop driving the CEC pin. The pull-up will drive the pin
  17. * high, unless someone else is driving the pin low.
  18. * @enable_irq: optional, enable the interrupt to detect pin voltage changes.
  19. * @disable_irq: optional, disable the interrupt.
  20. * @free: optional. Free any allocated resources. Called when the
  21. * adapter is deleted.
  22. * @status: optional, log status information.
  23. * @read_hpd: optional. Read the HPD pin. Returns > 0 if high, 0 if low or
  24. * an error if negative.
  25. * @read_5v: optional. Read the 5V pin. Returns > 0 if high, 0 if low or
  26. * an error if negative.
  27. * @received: optional. High-level CEC message callback. Allows the driver
  28. * to process CEC messages.
  29. *
  30. * These operations (except for the @received op) are used by the
  31. * cec pin framework to manipulate the CEC pin.
  32. */
  33. struct cec_pin_ops {
  34. int (*read)(struct cec_adapter *adap);
  35. void (*low)(struct cec_adapter *adap);
  36. void (*high)(struct cec_adapter *adap);
  37. bool (*enable_irq)(struct cec_adapter *adap);
  38. void (*disable_irq)(struct cec_adapter *adap);
  39. void (*free)(struct cec_adapter *adap);
  40. void (*status)(struct cec_adapter *adap, struct seq_file *file);
  41. int (*read_hpd)(struct cec_adapter *adap);
  42. int (*read_5v)(struct cec_adapter *adap);
  43. /* High-level CEC message callback */
  44. int (*received)(struct cec_adapter *adap, struct cec_msg *msg);
  45. };
  46. /**
  47. * cec_pin_changed() - update pin state from interrupt
  48. *
  49. * @adap: pointer to the cec adapter
  50. * @value: when true the pin is high, otherwise it is low
  51. *
  52. * If changes of the CEC voltage are detected via an interrupt, then
  53. * cec_pin_changed is called from the interrupt with the new value.
  54. */
  55. void cec_pin_changed(struct cec_adapter *adap, bool value);
  56. /**
  57. * cec_pin_allocate_adapter() - allocate a pin-based cec adapter
  58. *
  59. * @pin_ops: low-level pin operations
  60. * @priv: will be stored in adap->priv and can be used by the adapter ops.
  61. * Use cec_get_drvdata(adap) to get the priv pointer.
  62. * @name: the name of the CEC adapter. Note: this name will be copied.
  63. * @caps: capabilities of the CEC adapter. This will be ORed with
  64. * CEC_CAP_MONITOR_ALL and CEC_CAP_MONITOR_PIN.
  65. *
  66. * Allocate a cec adapter using the cec pin framework.
  67. *
  68. * Return: a pointer to the cec adapter or an error pointer
  69. */
  70. struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,
  71. void *priv, const char *name, u32 caps);
  72. #endif