#include <drm/display/drm_dp_helper.h>
#include <drm/display/drm_dsc_helper.h>
#include "dc_hw_types.h"
#include "dsc.h"
#include "dc.h"
#include "rc_calc.h"
#include "fixed31_32.h"
static uint32_t dsc_policy_max_target_bpp_limit = …;
static bool dsc_policy_enable_dsc_when_not_needed;
static bool dsc_policy_disable_dsc_stream_overhead;
static bool disable_128b_132b_stream_overhead;
#ifndef MAX
#define MAX …
#endif
#ifndef MIN
#define MIN …
#endif
static uint32_t apply_128b_132b_stream_overhead(
const struct dc_crtc_timing *timing, const uint32_t kbps)
{ … }
uint32_t dc_bandwidth_in_kbps_from_timing(
const struct dc_crtc_timing *timing,
const enum dc_link_encoding_format link_encoding)
{ … }
static bool decide_dsc_bandwidth_range(
const uint32_t min_bpp_x16,
const uint32_t max_bpp_x16,
const uint32_t num_slices_h,
const struct dsc_enc_caps *dsc_caps,
const struct dc_crtc_timing *timing,
const enum dc_link_encoding_format link_encoding,
struct dc_dsc_bw_range *range);
static uint32_t compute_bpp_x16_from_target_bandwidth(
const uint32_t bandwidth_in_kbps,
const struct dc_crtc_timing *timing,
const uint32_t num_slices_h,
const uint32_t bpp_increment_div,
const bool is_dp);
static void get_dsc_enc_caps(
const struct display_stream_compressor *dsc,
struct dsc_enc_caps *dsc_enc_caps,
int pixel_clock_100Hz);
static bool intersect_dsc_caps(
const struct dsc_dec_dpcd_caps *dsc_sink_caps,
const struct dsc_enc_caps *dsc_enc_caps,
enum dc_pixel_encoding pixel_encoding,
struct dsc_enc_caps *dsc_common_caps);
static bool setup_dsc_config(
const struct dsc_dec_dpcd_caps *dsc_sink_caps,
const struct dsc_enc_caps *dsc_enc_caps,
int target_bandwidth_kbps,
const struct dc_crtc_timing *timing,
const struct dc_dsc_config_options *options,
const enum dc_link_encoding_format link_encoding,
struct dc_dsc_config *dsc_cfg);
static bool dsc_buff_block_size_from_dpcd(int dpcd_buff_block_size, int *buff_block_size)
{ … }
static bool dsc_line_buff_depth_from_dpcd(int dpcd_line_buff_bit_depth, int *line_buff_bit_depth)
{ … }
static bool dsc_throughput_from_dpcd(int dpcd_throughput, int *throughput)
{ … }
static bool dsc_bpp_increment_div_from_dpcd(uint8_t bpp_increment_dpcd, uint32_t *bpp_increment_div)
{ … }
bool dc_dsc_parse_dsc_dpcd(const struct dc *dc,
const uint8_t *dpcd_dsc_basic_data,
const uint8_t *dpcd_dsc_branch_decoder_caps,
struct dsc_dec_dpcd_caps *dsc_sink_caps)
{ … }
bool dc_dsc_compute_bandwidth_range(
const struct display_stream_compressor *dsc,
uint32_t dsc_min_slice_height_override,
uint32_t min_bpp_x16,
uint32_t max_bpp_x16,
const struct dsc_dec_dpcd_caps *dsc_sink_caps,
const struct dc_crtc_timing *timing,
const enum dc_link_encoding_format link_encoding,
struct dc_dsc_bw_range *range)
{ … }
static void get_dsc_enc_caps(
const struct display_stream_compressor *dsc,
struct dsc_enc_caps *dsc_enc_caps,
int pixel_clock_100Hz)
{ … }
static bool intersect_dsc_caps(
const struct dsc_dec_dpcd_caps *dsc_sink_caps,
const struct dsc_enc_caps *dsc_enc_caps,
enum dc_pixel_encoding pixel_encoding,
struct dsc_enc_caps *dsc_common_caps)
{ … }
static inline uint32_t dsc_div_by_10_round_up(uint32_t value)
{ … }
static uint32_t compute_bpp_x16_from_target_bandwidth(
const uint32_t bandwidth_in_kbps,
const struct dc_crtc_timing *timing,
const uint32_t num_slices_h,
const uint32_t bpp_increment_div,
const bool is_dp)
{ … }
static bool decide_dsc_bandwidth_range(
const uint32_t min_bpp_x16,
const uint32_t max_bpp_x16,
const uint32_t num_slices_h,
const struct dsc_enc_caps *dsc_caps,
const struct dc_crtc_timing *timing,
const enum dc_link_encoding_format link_encoding,
struct dc_dsc_bw_range *range)
{ … }
static bool decide_dsc_target_bpp_x16(
const struct dc_dsc_policy *policy,
const struct dsc_enc_caps *dsc_common_caps,
const int target_bandwidth_kbps,
const struct dc_crtc_timing *timing,
const int num_slices_h,
const enum dc_link_encoding_format link_encoding,
int *target_bpp_x16)
{ … }
#define MIN_AVAILABLE_SLICES_SIZE …
static int get_available_dsc_slices(union dsc_enc_slice_caps slice_caps, int *available_slices)
{ … }
static int get_max_dsc_slices(union dsc_enc_slice_caps slice_caps)
{ … }
static int inc_num_slices(union dsc_enc_slice_caps slice_caps, int num_slices)
{ … }
static int dec_num_slices(union dsc_enc_slice_caps slice_caps, int num_slices)
{ … }
static int fit_num_slices_up(union dsc_enc_slice_caps slice_caps, int num_slices)
{ … }
static bool setup_dsc_config(
const struct dsc_dec_dpcd_caps *dsc_sink_caps,
const struct dsc_enc_caps *dsc_enc_caps,
int target_bandwidth_kbps,
const struct dc_crtc_timing *timing,
const struct dc_dsc_config_options *options,
const enum dc_link_encoding_format link_encoding,
struct dc_dsc_config *dsc_cfg)
{ … }
bool dc_dsc_compute_config(
const struct display_stream_compressor *dsc,
const struct dsc_dec_dpcd_caps *dsc_sink_caps,
const struct dc_dsc_config_options *options,
uint32_t target_bandwidth_kbps,
const struct dc_crtc_timing *timing,
const enum dc_link_encoding_format link_encoding,
struct dc_dsc_config *dsc_cfg)
{ … }
uint32_t dc_dsc_stream_bandwidth_in_kbps(const struct dc_crtc_timing *timing,
uint32_t bpp_x16, uint32_t num_slices_h, bool is_dp)
{ … }
uint32_t dc_dsc_stream_bandwidth_overhead_in_kbps(
const struct dc_crtc_timing *timing,
const int num_slices_h,
const bool is_dp)
{ … }
void dc_dsc_get_policy_for_timing(const struct dc_crtc_timing *timing,
uint32_t max_target_bpp_limit_override_x16,
struct dc_dsc_policy *policy)
{ … }
void dc_dsc_policy_set_max_target_bpp_limit(uint32_t limit)
{ … }
void dc_dsc_policy_set_enable_dsc_when_not_needed(bool enable)
{ … }
void dc_dsc_policy_set_disable_dsc_stream_overhead(bool disable)
{ … }
void dc_set_disable_128b_132b_stream_overhead(bool disable)
{ … }
void dc_dsc_get_default_config_option(const struct dc *dc, struct dc_dsc_config_options *options)
{ … }