sde_edid_parser.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. #if defined(CONFIG_SECDP)
  85. int audio_channel_info;
  86. #endif
  87. };
  88. /**
  89. * sde_edid_init() - init edid structure.
  90. * @edid_ctrl: Handle to the edid_ctrl structure.
  91. * Return: handle to sde_edid_ctrl for the client.
  92. */
  93. struct sde_edid_ctrl *sde_edid_init(void);
  94. /**
  95. * sde_edid_deinit() - deinit edid structure.
  96. * @edid_ctrl: Handle to the edid_ctrl structure.
  97. *
  98. * Return: void.
  99. */
  100. void sde_edid_deinit(void **edid_ctrl);
  101. /**
  102. * sde_get_edid() - get edid info.
  103. * @connector: Handle to the drm_connector.
  104. * @adapter: handle to i2c adapter for DDC read
  105. * @edid_ctrl: Handle to the edid_ctrl structure.
  106. *
  107. * Return: void.
  108. */
  109. void sde_get_edid(struct drm_connector *connector,
  110. struct i2c_adapter *adapter,
  111. void **edid_ctrl);
  112. /**
  113. * sde_parse_edid() - parses edid info.
  114. * @edid_ctrl: Handle to the edid_ctrl structure.
  115. *
  116. * Return: void.
  117. */
  118. void sde_parse_edid(void *edid_ctrl);
  119. /**
  120. * sde_free_edid() - free edid structure.
  121. * @edid_ctrl: Handle to the edid_ctrl structure.
  122. *
  123. * Return: void.
  124. */
  125. void sde_free_edid(void **edid_ctrl);
  126. /**
  127. * sde_detect_hdmi_monitor() - detect HDMI mode.
  128. * @edid_ctrl: Handle to the edid_ctrl structure.
  129. *
  130. * Return: error code.
  131. */
  132. bool sde_detect_hdmi_monitor(void *edid_ctrl);
  133. /**
  134. * sde_get_edid_checksum() - return the checksum of last block of EDID.
  135. * @input: Handle to the edid_ctrl structure.
  136. *
  137. * Return: checksum of the last EDID block.
  138. */
  139. u8 sde_get_edid_checksum(void *input);
  140. /**
  141. * _sde_edid_update_modes() - populate EDID modes.
  142. * @edid_ctrl: Handle to the edid_ctrl structure.
  143. *
  144. * Return: error code.
  145. */
  146. int _sde_edid_update_modes(struct drm_connector *connector,
  147. void *edid_ctrl);
  148. #endif /* _SDE_EDID_PARSER_H_ */