Home | History | Annotate | Line # | Download | only in dc
      1 /*	$NetBSD: dc_dsc.h,v 1.2 2021/12/18 23:45:00 riastradh Exp $	*/
      2 
      3 #ifndef DC_DSC_H_
      4 #define DC_DSC_H_
      5 /*
      6  * Copyright 2019 Advanced Micro Devices, Inc.
      7  *
      8  * Permission is hereby granted, free of charge, to any person obtaining a
      9  * copy of this software and associated documentation files (the "Software"),
     10  * to deal in the Software without restriction, including without limitation
     11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     12  * and/or sell copies of the Software, and to permit persons to whom the
     13  * Software is furnished to do so, subject to the following conditions:
     14  *
     15  * The above copyright notice and this permission notice shall be included in
     16  * all copies or substantial portions of the Software.
     17  *
     18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     21  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     24  * OTHER DEALINGS IN THE SOFTWARE.
     25  *
     26  * Author: AMD
     27  */
     28 
     29 /* put it here temporarily until linux has the new addresses official defined */
     30 /* DP Extended DSC Capabilities */
     31 #define DP_DSC_BRANCH_OVERALL_THROUGHPUT_0  0x0a0   /* DP 1.4a SCR */
     32 #define DP_DSC_BRANCH_OVERALL_THROUGHPUT_1  0x0a1
     33 #define DP_DSC_BRANCH_MAX_LINE_WIDTH        0x0a2
     34 #include "dc_types.h"
     35 
     36 struct dc_dsc_bw_range {
     37 	uint32_t min_kbps; /* Bandwidth if min_target_bpp_x16 is used */
     38 	uint32_t min_target_bpp_x16;
     39 	uint32_t max_kbps; /* Bandwidth if max_target_bpp_x16 is used */
     40 	uint32_t max_target_bpp_x16;
     41 	uint32_t stream_kbps; /* Uncompressed stream bandwidth */
     42 };
     43 
     44 struct display_stream_compressor {
     45 	const struct dsc_funcs *funcs;
     46 	struct dc_context *ctx;
     47 	int inst;
     48 };
     49 
     50 struct dc_dsc_policy {
     51 	bool use_min_slices_h;
     52 	int max_slices_h; // Maximum available if 0
     53 	int min_slice_height; // Must not be less than 8
     54 	uint32_t max_target_bpp;
     55 	uint32_t min_target_bpp;
     56 };
     57 
     58 bool dc_dsc_parse_dsc_dpcd(const struct dc *dc,
     59 		const uint8_t *dpcd_dsc_basic_data,
     60 		const uint8_t *dpcd_dsc_ext_data,
     61 		struct dsc_dec_dpcd_caps *dsc_sink_caps);
     62 
     63 bool dc_dsc_compute_bandwidth_range(
     64 		const struct display_stream_compressor *dsc,
     65 		const uint32_t dsc_min_slice_height_override,
     66 		const uint32_t min_bpp,
     67 		const uint32_t max_bpp,
     68 		const struct dsc_dec_dpcd_caps *dsc_sink_caps,
     69 		const struct dc_crtc_timing *timing,
     70 		struct dc_dsc_bw_range *range);
     71 
     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 uint32_t dsc_min_slice_height_override,
     76 		uint32_t target_bandwidth_kbps,
     77 		const struct dc_crtc_timing *timing,
     78 		struct dc_dsc_config *dsc_cfg);
     79 
     80 void dc_dsc_get_policy_for_timing(const struct dc_crtc_timing *timing,
     81 		struct dc_dsc_policy *policy);
     82 
     83 void dc_dsc_policy_set_max_target_bpp_limit(uint32_t limit);
     84 
     85 #endif
     86