sde_edid_parser.h 4.1 KB

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