sde_edid_parser.h 3.8 KB

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