sde_edid_parser.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_EDID_PARSER_H_
  6. #define _SDE_EDID_PARSER_H_
  7. #include <linux/types.h>
  8. #include <linux/bitops.h>
  9. #include <linux/debugfs.h>
  10. #include <linux/of_device.h>
  11. #include <linux/i2c.h>
  12. #include <drm/drmP.h>
  13. #include <drm/drm_crtc.h>
  14. #include <drm/drm_edid.h>
  15. #define MAX_NUMBER_ADB 5
  16. #define MAX_AUDIO_DATA_BLOCK_SIZE 30
  17. #define MAX_SPKR_ALLOC_DATA_BLOCK_SIZE 3
  18. #define EDID_VENDOR_ID_SIZE 4
  19. #define SDE_CEA_EXT 0x02
  20. #define SDE_EXTENDED_TAG 0x07
  21. #define SDE_DRM_MODE_FLAG_FMT_MASK (0x3 << 20)
  22. #define VSVDB_HDR10_PLUS_IEEE_CODE 0x90848b
  23. #define VSVDB_HDR10_PLUS_APP_VER_MASK 0x3
  24. /*Enum storing luminance types for HDR blocks in EDID*/
  25. enum luminance_value {
  26. NO_LUMINANCE_DATA = 3,
  27. MAXIMUM_LUMINANCE = 4,
  28. FRAME_AVERAGE_LUMINANCE = 5,
  29. MINIMUM_LUMINANCE = 6
  30. };
  31. enum extended_data_block_types {
  32. VIDEO_CAPABILITY_DATA_BLOCK = 0x0,
  33. VENDOR_SPECIFIC_VIDEO_DATA_BLOCK = 0x01,
  34. HDMI_VIDEO_DATA_BLOCK = 0x04,
  35. COLORIMETRY_EXTENDED_DATA_BLOCK = 0x5,
  36. HDR_STATIC_METADATA_DATA_BLOCK = 0x06,
  37. Y420_VIDEO_DATA_BLOCK = 0x0E,
  38. VIDEO_FORMAT_PREFERENCE_DATA_BLOCK = 0x0D,
  39. Y420_CAPABILITY_MAP_DATA_BLOCK = 0x0F,
  40. VENDOR_SPECIFIC_AUDIO_DATA_BLOCK = 0x11,
  41. INFOFRAME_DATA_BLOCK = 0x20,
  42. };
  43. #ifdef SDE_EDID_DEBUG_ENABLE
  44. #define SDE_EDID_DEBUG(fmt, args...) SDE_ERROR(fmt, ##args)
  45. #else
  46. #define SDE_EDID_DEBUG(fmt, args...) SDE_DEBUG(fmt, ##args)
  47. #endif
  48. /*
  49. * struct hdmi_edid_hdr_data - HDR Static Metadata
  50. * @eotf: Electro-Optical Transfer Function
  51. * @metadata_type_one: Static Metadata Type 1 support
  52. * @max_luminance: Desired Content Maximum Luminance
  53. * @avg_luminance: Desired Content Frame-average Luminance
  54. * @min_luminance: Desired Content Minimum Luminance
  55. */
  56. struct sde_edid_hdr_data {
  57. u32 eotf;
  58. bool metadata_type_one;
  59. u32 max_luminance;
  60. u32 avg_luminance;
  61. u32 min_luminance;
  62. };
  63. struct sde_edid_sink_caps {
  64. u32 max_pclk_in_hz;
  65. bool scdc_present;
  66. bool scramble_support; /* scramble support for less than 340Mcsc */
  67. bool read_req_support;
  68. bool osd_disparity;
  69. bool dual_view_support;
  70. bool ind_view_support;
  71. };
  72. struct sde_edid_ctrl {
  73. struct edid *edid;
  74. u8 pt_scan_info;
  75. u8 it_scan_info;
  76. u8 ce_scan_info;
  77. u8 audio_data_block[MAX_NUMBER_ADB * MAX_AUDIO_DATA_BLOCK_SIZE];
  78. int adb_size;
  79. u8 spkr_alloc_data_block[MAX_SPKR_ALLOC_DATA_BLOCK_SIZE];
  80. int sadb_size;
  81. bool hdr_supported;
  82. char vendor_id[EDID_VENDOR_ID_SIZE];
  83. struct sde_edid_sink_caps sink_caps;
  84. struct sde_edid_hdr_data hdr_data;
  85. };
  86. /**
  87. * sde_edid_init() - init edid structure.
  88. * @edid_ctrl: Handle to the edid_ctrl structure.
  89. * Return: handle to sde_edid_ctrl for the client.
  90. */
  91. struct sde_edid_ctrl *sde_edid_init(void);
  92. /**
  93. * sde_edid_deinit() - deinit edid structure.
  94. * @edid_ctrl: Handle to the edid_ctrl structure.
  95. *
  96. * Return: void.
  97. */
  98. void sde_edid_deinit(void **edid_ctrl);
  99. /**
  100. * sde_get_edid() - get edid info.
  101. * @connector: Handle to the drm_connector.
  102. * @adapter: handle to i2c adapter for DDC read
  103. * @edid_ctrl: Handle to the edid_ctrl structure.
  104. *
  105. * Return: void.
  106. */
  107. void sde_get_edid(struct drm_connector *connector,
  108. struct i2c_adapter *adapter,
  109. void **edid_ctrl);
  110. /**
  111. * sde_parse_edid() - parses edid info.
  112. * @edid_ctrl: Handle to the edid_ctrl structure.
  113. *
  114. * Return: void.
  115. */
  116. void sde_parse_edid(void *edid_ctrl);
  117. /**
  118. * sde_free_edid() - free edid structure.
  119. * @edid_ctrl: Handle to the edid_ctrl structure.
  120. *
  121. * Return: void.
  122. */
  123. void sde_free_edid(void **edid_ctrl);
  124. /**
  125. * sde_detect_hdmi_monitor() - detect HDMI mode.
  126. * @edid_ctrl: Handle to the edid_ctrl structure.
  127. *
  128. * Return: error code.
  129. */
  130. bool sde_detect_hdmi_monitor(void *edid_ctrl);
  131. /**
  132. * sde_get_edid_checksum() - return the checksum of last block of EDID.
  133. * @input: Handle to the edid_ctrl structure.
  134. *
  135. * Return: checksum of the last EDID block.
  136. */
  137. u8 sde_get_edid_checksum(void *input);
  138. /**
  139. * _sde_edid_update_modes() - populate EDID modes.
  140. * @edid_ctrl: Handle to the edid_ctrl structure.
  141. *
  142. * Return: error code.
  143. */
  144. int _sde_edid_update_modes(struct drm_connector *connector,
  145. void *edid_ctrl);
  146. #endif /* _SDE_EDID_PARSER_H_ */