dc_dsc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef DC_DSC_H_
  2. #define DC_DSC_H_
  3. /*
  4. * Copyright 2019 Advanced Micro Devices, Inc.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Author: AMD
  25. */
  26. /* put it here temporarily until linux has the new addresses official defined */
  27. /* DP Extended DSC Capabilities */
  28. #define DP_DSC_BRANCH_OVERALL_THROUGHPUT_0 0x0a0 /* DP 1.4a SCR */
  29. #define DP_DSC_BRANCH_OVERALL_THROUGHPUT_1 0x0a1
  30. #define DP_DSC_BRANCH_MAX_LINE_WIDTH 0x0a2
  31. #include "dc_types.h"
  32. struct dc_dsc_bw_range {
  33. uint32_t min_kbps; /* Bandwidth if min_target_bpp_x16 is used */
  34. uint32_t min_target_bpp_x16;
  35. uint32_t max_kbps; /* Bandwidth if max_target_bpp_x16 is used */
  36. uint32_t max_target_bpp_x16;
  37. uint32_t stream_kbps; /* Uncompressed stream bandwidth */
  38. };
  39. struct display_stream_compressor {
  40. const struct dsc_funcs *funcs;
  41. struct dc_context *ctx;
  42. int inst;
  43. };
  44. struct dc_dsc_policy {
  45. bool use_min_slices_h;
  46. int max_slices_h; // Maximum available if 0
  47. int min_slice_height; // Must not be less than 8
  48. uint32_t max_target_bpp;
  49. uint32_t min_target_bpp;
  50. bool enable_dsc_when_not_needed;
  51. };
  52. struct dc_dsc_config_options {
  53. uint32_t dsc_min_slice_height_override;
  54. uint32_t max_target_bpp_limit_override_x16;
  55. uint32_t slice_height_granularity;
  56. uint32_t dsc_force_odm_hslice_override;
  57. bool force_dsc_when_not_needed;
  58. };
  59. bool dc_dsc_parse_dsc_dpcd(const struct dc *dc,
  60. const uint8_t *dpcd_dsc_basic_data,
  61. const uint8_t *dpcd_dsc_ext_data,
  62. struct dsc_dec_dpcd_caps *dsc_sink_caps);
  63. bool dc_dsc_compute_bandwidth_range(
  64. const struct display_stream_compressor *dsc,
  65. uint32_t dsc_min_slice_height_override,
  66. uint32_t min_bpp_x16,
  67. uint32_t max_bpp_x16,
  68. const struct dsc_dec_dpcd_caps *dsc_sink_caps,
  69. const struct dc_crtc_timing *timing,
  70. const enum dc_link_encoding_format link_encoding,
  71. struct dc_dsc_bw_range *range);
  72. bool dc_dsc_compute_config(
  73. const struct display_stream_compressor *dsc,
  74. const struct dsc_dec_dpcd_caps *dsc_sink_caps,
  75. const struct dc_dsc_config_options *options,
  76. uint32_t target_bandwidth_kbps,
  77. const struct dc_crtc_timing *timing,
  78. const enum dc_link_encoding_format link_encoding,
  79. struct dc_dsc_config *dsc_cfg);
  80. uint32_t dc_dsc_stream_bandwidth_in_kbps(const struct dc_crtc_timing *timing,
  81. uint32_t bpp_x16, uint32_t num_slices_h, bool is_dp);
  82. uint32_t dc_dsc_stream_bandwidth_overhead_in_kbps(
  83. const struct dc_crtc_timing *timing,
  84. const int num_slices_h,
  85. const bool is_dp);
  86. /* TODO - Hardware/specs limitation should be owned by dc dsc and returned to DM,
  87. * and DM can choose to OVERRIDE the limitation on CASE BY CASE basis.
  88. * Hardware/specs limitation should not be writable by DM.
  89. * It should be decoupled from DM specific policy and named differently.
  90. */
  91. void dc_dsc_get_policy_for_timing(const struct dc_crtc_timing *timing,
  92. uint32_t max_target_bpp_limit_override_x16,
  93. struct dc_dsc_policy *policy,
  94. const enum dc_link_encoding_format link_encoding);
  95. void dc_dsc_policy_set_max_target_bpp_limit(uint32_t limit);
  96. void dc_dsc_policy_set_enable_dsc_when_not_needed(bool enable);
  97. void dc_dsc_policy_set_disable_dsc_stream_overhead(bool disable);
  98. void dc_dsc_get_default_config_option(const struct dc *dc, struct dc_dsc_config_options *options);
  99. #endif