cec-notifier.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * cec-notifier.h - notify CEC drivers of physical address changes
  3. *
  4. * Copyright 2016 Russell King <rmk+kernel@arm.linux.org.uk>
  5. * Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
  6. *
  7. * This program is free software; you may redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  12. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  15. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  16. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. * SOFTWARE.
  19. */
  20. #ifndef LINUX_CEC_NOTIFIER_H
  21. #define LINUX_CEC_NOTIFIER_H
  22. #include <linux/types.h>
  23. #include <media/cec.h>
  24. struct device;
  25. struct edid;
  26. struct cec_adapter;
  27. struct cec_notifier;
  28. #ifdef CONFIG_MEDIA_CEC_NOTIFIER
  29. /**
  30. * cec_notifier_get - find or create a new cec_notifier for the given device.
  31. * @dev: device that sends the events.
  32. *
  33. * If a notifier for device @dev already exists, then increase the refcount
  34. * and return that notifier.
  35. *
  36. * If it doesn't exist, then allocate a new notifier struct and return a
  37. * pointer to that new struct.
  38. *
  39. * Return NULL if the memory could not be allocated.
  40. */
  41. struct cec_notifier *cec_notifier_get(struct device *dev);
  42. /**
  43. * cec_notifier_put - decrease refcount and delete when the refcount reaches 0.
  44. * @n: notifier
  45. */
  46. void cec_notifier_put(struct cec_notifier *n);
  47. /**
  48. * cec_notifier_set_phys_addr - set a new physical address.
  49. * @n: the CEC notifier
  50. * @pa: the CEC physical address
  51. *
  52. * Set a new CEC physical address.
  53. */
  54. void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa);
  55. /**
  56. * cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID.
  57. * @n: the CEC notifier
  58. * @edid: the struct edid pointer
  59. *
  60. * Parses the EDID to obtain the new CEC physical address and set it.
  61. */
  62. void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,
  63. const struct edid *edid);
  64. /**
  65. * cec_notifier_register - register a callback with the notifier
  66. * @n: the CEC notifier
  67. * @adap: the CEC adapter, passed as argument to the callback function
  68. * @callback: the callback function
  69. */
  70. void cec_notifier_register(struct cec_notifier *n,
  71. struct cec_adapter *adap,
  72. void (*callback)(struct cec_adapter *adap, u16 pa));
  73. /**
  74. * cec_notifier_unregister - unregister the callback from the notifier.
  75. * @n: the CEC notifier
  76. */
  77. void cec_notifier_unregister(struct cec_notifier *n);
  78. #else
  79. static inline struct cec_notifier *cec_notifier_get(struct device *dev)
  80. {
  81. /* A non-NULL pointer is expected on success */
  82. return (struct cec_notifier *)0xdeadfeed;
  83. }
  84. static inline void cec_notifier_put(struct cec_notifier *n)
  85. {
  86. }
  87. static inline void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa)
  88. {
  89. }
  90. static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,
  91. const struct edid *edid)
  92. {
  93. }
  94. #endif
  95. #endif