cec-edid.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * cec-edid - HDMI Consumer Electronics Control & EDID helpers
  3. *
  4. * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
  5. *
  6. * This program is free software; you may redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  11. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  13. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  14. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  15. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. * SOFTWARE.
  18. */
  19. #ifndef _MEDIA_CEC_EDID_H
  20. #define _MEDIA_CEC_EDID_H
  21. #include <linux/types.h>
  22. #define CEC_PHYS_ADDR_INVALID 0xffff
  23. #define cec_phys_addr_exp(pa) \
  24. ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf
  25. /**
  26. * cec_get_edid_phys_addr() - find and return the physical address
  27. *
  28. * @edid: pointer to the EDID data
  29. * @size: size in bytes of the EDID data
  30. * @offset: If not %NULL then the location of the physical address
  31. * bytes in the EDID will be returned here. This is set to 0
  32. * if there is no physical address found.
  33. *
  34. * Return: the physical address or CEC_PHYS_ADDR_INVALID if there is none.
  35. */
  36. u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size,
  37. unsigned int *offset);
  38. /**
  39. * cec_set_edid_phys_addr() - find and set the physical address
  40. *
  41. * @edid: pointer to the EDID data
  42. * @size: size in bytes of the EDID data
  43. * @phys_addr: the new physical address
  44. *
  45. * This function finds the location of the physical address in the EDID
  46. * and fills in the given physical address and updates the checksum
  47. * at the end of the EDID block. It does nothing if the EDID doesn't
  48. * contain a physical address.
  49. */
  50. void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr);
  51. /**
  52. * cec_phys_addr_for_input() - calculate the PA for an input
  53. *
  54. * @phys_addr: the physical address of the parent
  55. * @input: the number of the input port, must be between 1 and 15
  56. *
  57. * This function calculates a new physical address based on the input
  58. * port number. For example:
  59. *
  60. * PA = 0.0.0.0 and input = 2 becomes 2.0.0.0
  61. *
  62. * PA = 3.0.0.0 and input = 1 becomes 3.1.0.0
  63. *
  64. * PA = 3.2.1.0 and input = 5 becomes 3.2.1.5
  65. *
  66. * PA = 3.2.1.3 and input = 5 becomes f.f.f.f since it maxed out the depth.
  67. *
  68. * Return: the new physical address or CEC_PHYS_ADDR_INVALID.
  69. */
  70. u16 cec_phys_addr_for_input(u16 phys_addr, u8 input);
  71. /**
  72. * cec_phys_addr_validate() - validate a physical address from an EDID
  73. *
  74. * @phys_addr: the physical address to validate
  75. * @parent: if not %NULL, then this is filled with the parents PA.
  76. * @port: if not %NULL, then this is filled with the input port.
  77. *
  78. * This validates a physical address as read from an EDID. If the
  79. * PA is invalid (such as 1.0.1.0 since '0' is only allowed at the end),
  80. * then it will return -EINVAL.
  81. *
  82. * The parent PA is passed into %parent and the input port is passed into
  83. * %port. For example:
  84. *
  85. * PA = 0.0.0.0: has parent 0.0.0.0 and input port 0.
  86. *
  87. * PA = 1.0.0.0: has parent 0.0.0.0 and input port 1.
  88. *
  89. * PA = 3.2.0.0: has parent 3.0.0.0 and input port 2.
  90. *
  91. * PA = f.f.f.f: has parent f.f.f.f and input port 0.
  92. *
  93. * Return: 0 if the PA is valid, -EINVAL if not.
  94. */
  95. int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port);
  96. #endif /* _MEDIA_CEC_EDID_H */