xref: /linux/drivers/gpu/drm/display/drm_dsc_helper.c (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
12a64b147SThomas Zimmermann // SPDX-License-Identifier: MIT
22a64b147SThomas Zimmermann /*
32a64b147SThomas Zimmermann  * Copyright © 2018 Intel Corp
42a64b147SThomas Zimmermann  *
52a64b147SThomas Zimmermann  * Author:
62a64b147SThomas Zimmermann  * Manasi Navare <manasi.d.navare@intel.com>
72a64b147SThomas Zimmermann  */
82a64b147SThomas Zimmermann 
92a64b147SThomas Zimmermann #include <linux/kernel.h>
102a64b147SThomas Zimmermann #include <linux/module.h>
112a64b147SThomas Zimmermann #include <linux/init.h>
122a64b147SThomas Zimmermann #include <linux/errno.h>
132a64b147SThomas Zimmermann #include <linux/byteorder/generic.h>
142a64b147SThomas Zimmermann 
152a64b147SThomas Zimmermann #include <drm/display/drm_dp_helper.h>
162a64b147SThomas Zimmermann #include <drm/display/drm_dsc_helper.h>
17*74c3f5daSImre Deak #include <drm/drm_fixed.h>
182a64b147SThomas Zimmermann #include <drm/drm_print.h>
192a64b147SThomas Zimmermann 
202a64b147SThomas Zimmermann /**
212a64b147SThomas Zimmermann  * DOC: dsc helpers
222a64b147SThomas Zimmermann  *
232a64b147SThomas Zimmermann  * VESA specification for DP 1.4 adds a new feature called Display Stream
242a64b147SThomas Zimmermann  * Compression (DSC) used to compress the pixel bits before sending it on
252a64b147SThomas Zimmermann  * DP/eDP/MIPI DSI interface. DSC is required to be enabled so that the existing
262a64b147SThomas Zimmermann  * display interfaces can support high resolutions at higher frames rates uisng
272a64b147SThomas Zimmermann  * the maximum available link capacity of these interfaces.
282a64b147SThomas Zimmermann  *
292a64b147SThomas Zimmermann  * These functions contain some common logic and helpers to deal with VESA
302a64b147SThomas Zimmermann  * Display Stream Compression standard required for DSC on Display Port/eDP or
312a64b147SThomas Zimmermann  * MIPI display interfaces.
322a64b147SThomas Zimmermann  */
332a64b147SThomas Zimmermann 
342a64b147SThomas Zimmermann /**
352a64b147SThomas Zimmermann  * drm_dsc_dp_pps_header_init() - Initializes the PPS Header
362a64b147SThomas Zimmermann  * for DisplayPort as per the DP 1.4 spec.
372a64b147SThomas Zimmermann  * @pps_header: Secondary data packet header for DSC Picture
382a64b147SThomas Zimmermann  *              Parameter Set as defined in &struct dp_sdp_header
392a64b147SThomas Zimmermann  *
402a64b147SThomas Zimmermann  * DP 1.4 spec defines the secondary data packet for sending the
412a64b147SThomas Zimmermann  * picture parameter infoframes from the source to the sink.
422a64b147SThomas Zimmermann  * This function populates the SDP header defined in
432a64b147SThomas Zimmermann  * &struct dp_sdp_header.
442a64b147SThomas Zimmermann  */
drm_dsc_dp_pps_header_init(struct dp_sdp_header * pps_header)452a64b147SThomas Zimmermann void drm_dsc_dp_pps_header_init(struct dp_sdp_header *pps_header)
462a64b147SThomas Zimmermann {
472a64b147SThomas Zimmermann 	memset(pps_header, 0, sizeof(*pps_header));
482a64b147SThomas Zimmermann 
492a64b147SThomas Zimmermann 	pps_header->HB1 = DP_SDP_PPS;
502a64b147SThomas Zimmermann 	pps_header->HB2 = DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1;
512a64b147SThomas Zimmermann }
522a64b147SThomas Zimmermann EXPORT_SYMBOL(drm_dsc_dp_pps_header_init);
532a64b147SThomas Zimmermann 
542a64b147SThomas Zimmermann /**
552a64b147SThomas Zimmermann  * drm_dsc_dp_rc_buffer_size - get rc buffer size in bytes
562a64b147SThomas Zimmermann  * @rc_buffer_block_size: block size code, according to DPCD offset 62h
572a64b147SThomas Zimmermann  * @rc_buffer_size: number of blocks - 1, according to DPCD offset 63h
582a64b147SThomas Zimmermann  *
592a64b147SThomas Zimmermann  * return:
602a64b147SThomas Zimmermann  * buffer size in bytes, or 0 on invalid input
612a64b147SThomas Zimmermann  */
drm_dsc_dp_rc_buffer_size(u8 rc_buffer_block_size,u8 rc_buffer_size)622a64b147SThomas Zimmermann int drm_dsc_dp_rc_buffer_size(u8 rc_buffer_block_size, u8 rc_buffer_size)
632a64b147SThomas Zimmermann {
642a64b147SThomas Zimmermann 	int size = 1024 * (rc_buffer_size + 1);
652a64b147SThomas Zimmermann 
662a64b147SThomas Zimmermann 	switch (rc_buffer_block_size) {
672a64b147SThomas Zimmermann 	case DP_DSC_RC_BUF_BLK_SIZE_1:
682a64b147SThomas Zimmermann 		return 1 * size;
692a64b147SThomas Zimmermann 	case DP_DSC_RC_BUF_BLK_SIZE_4:
702a64b147SThomas Zimmermann 		return 4 * size;
712a64b147SThomas Zimmermann 	case DP_DSC_RC_BUF_BLK_SIZE_16:
722a64b147SThomas Zimmermann 		return 16 * size;
732a64b147SThomas Zimmermann 	case DP_DSC_RC_BUF_BLK_SIZE_64:
742a64b147SThomas Zimmermann 		return 64 * size;
752a64b147SThomas Zimmermann 	default:
762a64b147SThomas Zimmermann 		return 0;
772a64b147SThomas Zimmermann 	}
782a64b147SThomas Zimmermann }
792a64b147SThomas Zimmermann EXPORT_SYMBOL(drm_dsc_dp_rc_buffer_size);
802a64b147SThomas Zimmermann 
812a64b147SThomas Zimmermann /**
822a64b147SThomas Zimmermann  * drm_dsc_pps_payload_pack() - Populates the DSC PPS
832a64b147SThomas Zimmermann  *
842a64b147SThomas Zimmermann  * @pps_payload:
852a64b147SThomas Zimmermann  * Bitwise struct for DSC Picture Parameter Set. This is defined
862a64b147SThomas Zimmermann  * by &struct drm_dsc_picture_parameter_set
872a64b147SThomas Zimmermann  * @dsc_cfg:
882a64b147SThomas Zimmermann  * DSC Configuration data filled by driver as defined by
892a64b147SThomas Zimmermann  * &struct drm_dsc_config
902a64b147SThomas Zimmermann  *
912a64b147SThomas Zimmermann  * DSC source device sends a picture parameter set (PPS) containing the
922a64b147SThomas Zimmermann  * information required by the sink to decode the compressed frame. Driver
932a64b147SThomas Zimmermann  * populates the DSC PPS struct using the DSC configuration parameters in
942a64b147SThomas Zimmermann  * the order expected by the DSC Display Sink device. For the DSC, the sink
952a64b147SThomas Zimmermann  * device expects the PPS payload in big endian format for fields
962a64b147SThomas Zimmermann  * that span more than 1 byte.
972a64b147SThomas Zimmermann  */
drm_dsc_pps_payload_pack(struct drm_dsc_picture_parameter_set * pps_payload,const struct drm_dsc_config * dsc_cfg)982a64b147SThomas Zimmermann void drm_dsc_pps_payload_pack(struct drm_dsc_picture_parameter_set *pps_payload,
992a64b147SThomas Zimmermann 				const struct drm_dsc_config *dsc_cfg)
1002a64b147SThomas Zimmermann {
1012a64b147SThomas Zimmermann 	int i;
1022a64b147SThomas Zimmermann 
1032a64b147SThomas Zimmermann 	/* Protect against someone accidentally changing struct size */
1042a64b147SThomas Zimmermann 	BUILD_BUG_ON(sizeof(*pps_payload) !=
1052a64b147SThomas Zimmermann 		     DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1 + 1);
1062a64b147SThomas Zimmermann 
1072a64b147SThomas Zimmermann 	memset(pps_payload, 0, sizeof(*pps_payload));
1082a64b147SThomas Zimmermann 
1092a64b147SThomas Zimmermann 	/* PPS 0 */
1102a64b147SThomas Zimmermann 	pps_payload->dsc_version =
1112a64b147SThomas Zimmermann 		dsc_cfg->dsc_version_minor |
1122a64b147SThomas Zimmermann 		dsc_cfg->dsc_version_major << DSC_PPS_VERSION_MAJOR_SHIFT;
1132a64b147SThomas Zimmermann 
1142a64b147SThomas Zimmermann 	/* PPS 1, 2 is 0 */
1152a64b147SThomas Zimmermann 
1162a64b147SThomas Zimmermann 	/* PPS 3 */
1172a64b147SThomas Zimmermann 	pps_payload->pps_3 =
1182a64b147SThomas Zimmermann 		dsc_cfg->line_buf_depth |
1192a64b147SThomas Zimmermann 		dsc_cfg->bits_per_component << DSC_PPS_BPC_SHIFT;
1202a64b147SThomas Zimmermann 
1212a64b147SThomas Zimmermann 	/* PPS 4 */
1222a64b147SThomas Zimmermann 	pps_payload->pps_4 =
1232a64b147SThomas Zimmermann 		((dsc_cfg->bits_per_pixel & DSC_PPS_BPP_HIGH_MASK) >>
1242a64b147SThomas Zimmermann 		 DSC_PPS_MSB_SHIFT) |
1252a64b147SThomas Zimmermann 		dsc_cfg->vbr_enable << DSC_PPS_VBR_EN_SHIFT |
1262a64b147SThomas Zimmermann 		dsc_cfg->simple_422 << DSC_PPS_SIMPLE422_SHIFT |
1272a64b147SThomas Zimmermann 		dsc_cfg->convert_rgb << DSC_PPS_CONVERT_RGB_SHIFT |
1282a64b147SThomas Zimmermann 		dsc_cfg->block_pred_enable << DSC_PPS_BLOCK_PRED_EN_SHIFT;
1292a64b147SThomas Zimmermann 
1302a64b147SThomas Zimmermann 	/* PPS 5 */
1312a64b147SThomas Zimmermann 	pps_payload->bits_per_pixel_low =
1322a64b147SThomas Zimmermann 		(dsc_cfg->bits_per_pixel & DSC_PPS_LSB_MASK);
1332a64b147SThomas Zimmermann 
1342a64b147SThomas Zimmermann 	/*
1352a64b147SThomas Zimmermann 	 * The DSC panel expects the PPS packet to have big endian format
1362a64b147SThomas Zimmermann 	 * for data spanning 2 bytes. Use a macro cpu_to_be16() to convert
1372a64b147SThomas Zimmermann 	 * to big endian format. If format is little endian, it will swap
1382a64b147SThomas Zimmermann 	 * bytes to convert to Big endian else keep it unchanged.
1392a64b147SThomas Zimmermann 	 */
1402a64b147SThomas Zimmermann 
1412a64b147SThomas Zimmermann 	/* PPS 6, 7 */
1422a64b147SThomas Zimmermann 	pps_payload->pic_height = cpu_to_be16(dsc_cfg->pic_height);
1432a64b147SThomas Zimmermann 
1442a64b147SThomas Zimmermann 	/* PPS 8, 9 */
1452a64b147SThomas Zimmermann 	pps_payload->pic_width = cpu_to_be16(dsc_cfg->pic_width);
1462a64b147SThomas Zimmermann 
1472a64b147SThomas Zimmermann 	/* PPS 10, 11 */
1482a64b147SThomas Zimmermann 	pps_payload->slice_height = cpu_to_be16(dsc_cfg->slice_height);
1492a64b147SThomas Zimmermann 
1502a64b147SThomas Zimmermann 	/* PPS 12, 13 */
1512a64b147SThomas Zimmermann 	pps_payload->slice_width = cpu_to_be16(dsc_cfg->slice_width);
1522a64b147SThomas Zimmermann 
1532a64b147SThomas Zimmermann 	/* PPS 14, 15 */
1542a64b147SThomas Zimmermann 	pps_payload->chunk_size = cpu_to_be16(dsc_cfg->slice_chunk_size);
1552a64b147SThomas Zimmermann 
1562a64b147SThomas Zimmermann 	/* PPS 16 */
1572a64b147SThomas Zimmermann 	pps_payload->initial_xmit_delay_high =
1582a64b147SThomas Zimmermann 		((dsc_cfg->initial_xmit_delay &
1592a64b147SThomas Zimmermann 		  DSC_PPS_INIT_XMIT_DELAY_HIGH_MASK) >>
1602a64b147SThomas Zimmermann 		 DSC_PPS_MSB_SHIFT);
1612a64b147SThomas Zimmermann 
1622a64b147SThomas Zimmermann 	/* PPS 17 */
1632a64b147SThomas Zimmermann 	pps_payload->initial_xmit_delay_low =
1642a64b147SThomas Zimmermann 		(dsc_cfg->initial_xmit_delay & DSC_PPS_LSB_MASK);
1652a64b147SThomas Zimmermann 
1662a64b147SThomas Zimmermann 	/* PPS 18, 19 */
1672a64b147SThomas Zimmermann 	pps_payload->initial_dec_delay =
1682a64b147SThomas Zimmermann 		cpu_to_be16(dsc_cfg->initial_dec_delay);
1692a64b147SThomas Zimmermann 
1702a64b147SThomas Zimmermann 	/* PPS 20 is 0 */
1712a64b147SThomas Zimmermann 
1722a64b147SThomas Zimmermann 	/* PPS 21 */
1732a64b147SThomas Zimmermann 	pps_payload->initial_scale_value =
1742a64b147SThomas Zimmermann 		dsc_cfg->initial_scale_value;
1752a64b147SThomas Zimmermann 
1762a64b147SThomas Zimmermann 	/* PPS 22, 23 */
1772a64b147SThomas Zimmermann 	pps_payload->scale_increment_interval =
1782a64b147SThomas Zimmermann 		cpu_to_be16(dsc_cfg->scale_increment_interval);
1792a64b147SThomas Zimmermann 
1802a64b147SThomas Zimmermann 	/* PPS 24 */
1812a64b147SThomas Zimmermann 	pps_payload->scale_decrement_interval_high =
1822a64b147SThomas Zimmermann 		((dsc_cfg->scale_decrement_interval &
1832a64b147SThomas Zimmermann 		  DSC_PPS_SCALE_DEC_INT_HIGH_MASK) >>
1842a64b147SThomas Zimmermann 		 DSC_PPS_MSB_SHIFT);
1852a64b147SThomas Zimmermann 
1862a64b147SThomas Zimmermann 	/* PPS 25 */
1872a64b147SThomas Zimmermann 	pps_payload->scale_decrement_interval_low =
1882a64b147SThomas Zimmermann 		(dsc_cfg->scale_decrement_interval & DSC_PPS_LSB_MASK);
1892a64b147SThomas Zimmermann 
1902a64b147SThomas Zimmermann 	/* PPS 26[7:0], PPS 27[7:5] RESERVED */
1912a64b147SThomas Zimmermann 
1922a64b147SThomas Zimmermann 	/* PPS 27 */
1932a64b147SThomas Zimmermann 	pps_payload->first_line_bpg_offset =
1942a64b147SThomas Zimmermann 		dsc_cfg->first_line_bpg_offset;
1952a64b147SThomas Zimmermann 
1962a64b147SThomas Zimmermann 	/* PPS 28, 29 */
1972a64b147SThomas Zimmermann 	pps_payload->nfl_bpg_offset =
1982a64b147SThomas Zimmermann 		cpu_to_be16(dsc_cfg->nfl_bpg_offset);
1992a64b147SThomas Zimmermann 
2002a64b147SThomas Zimmermann 	/* PPS 30, 31 */
2012a64b147SThomas Zimmermann 	pps_payload->slice_bpg_offset =
2022a64b147SThomas Zimmermann 		cpu_to_be16(dsc_cfg->slice_bpg_offset);
2032a64b147SThomas Zimmermann 
2042a64b147SThomas Zimmermann 	/* PPS 32, 33 */
2052a64b147SThomas Zimmermann 	pps_payload->initial_offset =
2062a64b147SThomas Zimmermann 		cpu_to_be16(dsc_cfg->initial_offset);
2072a64b147SThomas Zimmermann 
2082a64b147SThomas Zimmermann 	/* PPS 34, 35 */
2092a64b147SThomas Zimmermann 	pps_payload->final_offset = cpu_to_be16(dsc_cfg->final_offset);
2102a64b147SThomas Zimmermann 
2112a64b147SThomas Zimmermann 	/* PPS 36 */
2122a64b147SThomas Zimmermann 	pps_payload->flatness_min_qp = dsc_cfg->flatness_min_qp;
2132a64b147SThomas Zimmermann 
2142a64b147SThomas Zimmermann 	/* PPS 37 */
2152a64b147SThomas Zimmermann 	pps_payload->flatness_max_qp = dsc_cfg->flatness_max_qp;
2162a64b147SThomas Zimmermann 
2172a64b147SThomas Zimmermann 	/* PPS 38, 39 */
2182a64b147SThomas Zimmermann 	pps_payload->rc_model_size = cpu_to_be16(dsc_cfg->rc_model_size);
2192a64b147SThomas Zimmermann 
2202a64b147SThomas Zimmermann 	/* PPS 40 */
2212a64b147SThomas Zimmermann 	pps_payload->rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST;
2222a64b147SThomas Zimmermann 
2232a64b147SThomas Zimmermann 	/* PPS 41 */
2242a64b147SThomas Zimmermann 	pps_payload->rc_quant_incr_limit0 =
2252a64b147SThomas Zimmermann 		dsc_cfg->rc_quant_incr_limit0;
2262a64b147SThomas Zimmermann 
2272a64b147SThomas Zimmermann 	/* PPS 42 */
2282a64b147SThomas Zimmermann 	pps_payload->rc_quant_incr_limit1 =
2292a64b147SThomas Zimmermann 		dsc_cfg->rc_quant_incr_limit1;
2302a64b147SThomas Zimmermann 
2312a64b147SThomas Zimmermann 	/* PPS 43 */
2322a64b147SThomas Zimmermann 	pps_payload->rc_tgt_offset = DSC_RC_TGT_OFFSET_LO_CONST |
2332a64b147SThomas Zimmermann 		DSC_RC_TGT_OFFSET_HI_CONST << DSC_PPS_RC_TGT_OFFSET_HI_SHIFT;
2342a64b147SThomas Zimmermann 
2352a64b147SThomas Zimmermann 	/* PPS 44 - 57 */
2362a64b147SThomas Zimmermann 	for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++)
2372a64b147SThomas Zimmermann 		pps_payload->rc_buf_thresh[i] =
2382a64b147SThomas Zimmermann 			dsc_cfg->rc_buf_thresh[i];
2392a64b147SThomas Zimmermann 
2402a64b147SThomas Zimmermann 	/* PPS 58 - 87 */
2412a64b147SThomas Zimmermann 	/*
2422a64b147SThomas Zimmermann 	 * For DSC sink programming the RC Range parameter fields
2432a64b147SThomas Zimmermann 	 * are as follows: Min_qp[15:11], max_qp[10:6], offset[5:0]
2442a64b147SThomas Zimmermann 	 */
2452a64b147SThomas Zimmermann 	for (i = 0; i < DSC_NUM_BUF_RANGES; i++) {
2462a64b147SThomas Zimmermann 		pps_payload->rc_range_parameters[i] =
2472a64b147SThomas Zimmermann 			cpu_to_be16((dsc_cfg->rc_range_params[i].range_min_qp <<
2482a64b147SThomas Zimmermann 				     DSC_PPS_RC_RANGE_MINQP_SHIFT) |
2492a64b147SThomas Zimmermann 				    (dsc_cfg->rc_range_params[i].range_max_qp <<
2502a64b147SThomas Zimmermann 				     DSC_PPS_RC_RANGE_MAXQP_SHIFT) |
2512a64b147SThomas Zimmermann 				    (dsc_cfg->rc_range_params[i].range_bpg_offset));
2522a64b147SThomas Zimmermann 	}
2532a64b147SThomas Zimmermann 
2542a64b147SThomas Zimmermann 	/* PPS 88 */
2552a64b147SThomas Zimmermann 	pps_payload->native_422_420 = dsc_cfg->native_422 |
2562a64b147SThomas Zimmermann 		dsc_cfg->native_420 << DSC_PPS_NATIVE_420_SHIFT;
2572a64b147SThomas Zimmermann 
2582a64b147SThomas Zimmermann 	/* PPS 89 */
2592a64b147SThomas Zimmermann 	pps_payload->second_line_bpg_offset =
2602a64b147SThomas Zimmermann 		dsc_cfg->second_line_bpg_offset;
2612a64b147SThomas Zimmermann 
2622a64b147SThomas Zimmermann 	/* PPS 90, 91 */
2632a64b147SThomas Zimmermann 	pps_payload->nsl_bpg_offset =
2642a64b147SThomas Zimmermann 		cpu_to_be16(dsc_cfg->nsl_bpg_offset);
2652a64b147SThomas Zimmermann 
2662a64b147SThomas Zimmermann 	/* PPS 92, 93 */
2672a64b147SThomas Zimmermann 	pps_payload->second_line_offset_adj =
2682a64b147SThomas Zimmermann 		cpu_to_be16(dsc_cfg->second_line_offset_adj);
2692a64b147SThomas Zimmermann 
2702a64b147SThomas Zimmermann 	/* PPS 94 - 127 are O */
2712a64b147SThomas Zimmermann }
2722a64b147SThomas Zimmermann EXPORT_SYMBOL(drm_dsc_pps_payload_pack);
2732a64b147SThomas Zimmermann 
274e871a70dSDmitry Baryshkov /**
275e871a70dSDmitry Baryshkov  * drm_dsc_set_const_params() - Set DSC parameters considered typically
276e871a70dSDmitry Baryshkov  * constant across operation modes
277e871a70dSDmitry Baryshkov  *
278e871a70dSDmitry Baryshkov  * @vdsc_cfg:
279e871a70dSDmitry Baryshkov  * DSC Configuration data partially filled by driver
280e871a70dSDmitry Baryshkov  */
drm_dsc_set_const_params(struct drm_dsc_config * vdsc_cfg)281e871a70dSDmitry Baryshkov void drm_dsc_set_const_params(struct drm_dsc_config *vdsc_cfg)
282e871a70dSDmitry Baryshkov {
283e871a70dSDmitry Baryshkov 	if (!vdsc_cfg->rc_model_size)
284e871a70dSDmitry Baryshkov 		vdsc_cfg->rc_model_size = DSC_RC_MODEL_SIZE_CONST;
285e871a70dSDmitry Baryshkov 	vdsc_cfg->rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST;
286e871a70dSDmitry Baryshkov 	vdsc_cfg->rc_tgt_offset_high = DSC_RC_TGT_OFFSET_HI_CONST;
287e871a70dSDmitry Baryshkov 	vdsc_cfg->rc_tgt_offset_low = DSC_RC_TGT_OFFSET_LO_CONST;
288e871a70dSDmitry Baryshkov 
289e871a70dSDmitry Baryshkov 	if (vdsc_cfg->bits_per_component <= 10)
290e871a70dSDmitry Baryshkov 		vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
291e871a70dSDmitry Baryshkov 	else
292e871a70dSDmitry Baryshkov 		vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC;
293e871a70dSDmitry Baryshkov }
294e871a70dSDmitry Baryshkov EXPORT_SYMBOL(drm_dsc_set_const_params);
295e871a70dSDmitry Baryshkov 
29616921921SDmitry Baryshkov /* From DSC_v1.11 spec, rc_parameter_Set syntax element typically constant */
29716921921SDmitry Baryshkov static const u16 drm_dsc_rc_buf_thresh[] = {
29816921921SDmitry Baryshkov 	896, 1792, 2688, 3584, 4480, 5376, 6272, 6720, 7168, 7616,
29916921921SDmitry Baryshkov 	7744, 7872, 8000, 8064
30016921921SDmitry Baryshkov };
30116921921SDmitry Baryshkov 
30216921921SDmitry Baryshkov /**
30316921921SDmitry Baryshkov  * drm_dsc_set_rc_buf_thresh() - Set thresholds for the RC model
30416921921SDmitry Baryshkov  * in accordance with the DSC 1.2 specification.
30516921921SDmitry Baryshkov  *
30616921921SDmitry Baryshkov  * @vdsc_cfg: DSC Configuration data partially filled by driver
30716921921SDmitry Baryshkov  */
drm_dsc_set_rc_buf_thresh(struct drm_dsc_config * vdsc_cfg)30816921921SDmitry Baryshkov void drm_dsc_set_rc_buf_thresh(struct drm_dsc_config *vdsc_cfg)
30916921921SDmitry Baryshkov {
31016921921SDmitry Baryshkov 	int i;
31116921921SDmitry Baryshkov 
31216921921SDmitry Baryshkov 	BUILD_BUG_ON(ARRAY_SIZE(drm_dsc_rc_buf_thresh) !=
31316921921SDmitry Baryshkov 		     DSC_NUM_BUF_RANGES - 1);
31416921921SDmitry Baryshkov 	BUILD_BUG_ON(ARRAY_SIZE(drm_dsc_rc_buf_thresh) !=
31516921921SDmitry Baryshkov 		     ARRAY_SIZE(vdsc_cfg->rc_buf_thresh));
31616921921SDmitry Baryshkov 
31716921921SDmitry Baryshkov 	for (i = 0; i < ARRAY_SIZE(drm_dsc_rc_buf_thresh); i++)
31816921921SDmitry Baryshkov 		vdsc_cfg->rc_buf_thresh[i] = drm_dsc_rc_buf_thresh[i] >> 6;
31916921921SDmitry Baryshkov 
32016921921SDmitry Baryshkov 	/*
32116921921SDmitry Baryshkov 	 * For 6bpp, RC Buffer threshold 12 and 13 need a different value
32216921921SDmitry Baryshkov 	 * as per C Model
32316921921SDmitry Baryshkov 	 */
32416921921SDmitry Baryshkov 	if (vdsc_cfg->bits_per_pixel == 6 << 4) {
32516921921SDmitry Baryshkov 		vdsc_cfg->rc_buf_thresh[12] = 7936 >> 6;
32616921921SDmitry Baryshkov 		vdsc_cfg->rc_buf_thresh[13] = 8000 >> 6;
32716921921SDmitry Baryshkov 	}
32816921921SDmitry Baryshkov }
32916921921SDmitry Baryshkov EXPORT_SYMBOL(drm_dsc_set_rc_buf_thresh);
33016921921SDmitry Baryshkov 
3312b470e55SDmitry Baryshkov struct rc_parameters {
3322b470e55SDmitry Baryshkov 	u16 initial_xmit_delay;
3332b470e55SDmitry Baryshkov 	u8 first_line_bpg_offset;
3342b470e55SDmitry Baryshkov 	u16 initial_offset;
3352b470e55SDmitry Baryshkov 	u8 flatness_min_qp;
3362b470e55SDmitry Baryshkov 	u8 flatness_max_qp;
3372b470e55SDmitry Baryshkov 	u8 rc_quant_incr_limit0;
3382b470e55SDmitry Baryshkov 	u8 rc_quant_incr_limit1;
3392b470e55SDmitry Baryshkov 	struct drm_dsc_rc_range_parameters rc_range_params[DSC_NUM_BUF_RANGES];
3402b470e55SDmitry Baryshkov };
3412b470e55SDmitry Baryshkov 
34274fe874cSDmitry Baryshkov struct rc_parameters_data {
34374fe874cSDmitry Baryshkov 	u8 bpp;
34474fe874cSDmitry Baryshkov 	u8 bpc;
34574fe874cSDmitry Baryshkov 	struct rc_parameters params;
34674fe874cSDmitry Baryshkov };
34774fe874cSDmitry Baryshkov 
34874fe874cSDmitry Baryshkov #define DSC_BPP(bpp)	((bpp) << 4)
34974fe874cSDmitry Baryshkov 
3502b470e55SDmitry Baryshkov /*
351e3290f88SDmitry Baryshkov  * Rate Control Related Parameter Recommended Values from DSC_v1.1 spec prior
352e3290f88SDmitry Baryshkov  * to DSC 1.1 fractional bpp underflow SCR (DSC_v1.1_E1.pdf)
353e3290f88SDmitry Baryshkov  *
354e3290f88SDmitry Baryshkov  * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
3552b470e55SDmitry Baryshkov  */
356e3290f88SDmitry Baryshkov static const struct rc_parameters_data rc_parameters_pre_scr[] = {
357e3290f88SDmitry Baryshkov 	{
3583b292112SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 8,
3593b292112SDmitry Baryshkov 		{ 683, 15, 6144, 3, 13, 11, 11, {
3603b292112SDmitry Baryshkov 			{ 0, 2, 0 }, { 1, 4, -2 }, { 3, 6, -2 }, { 4, 6, -4 },
3613b292112SDmitry Baryshkov 			{ 5, 7, -6 }, { 5, 7, -6 }, { 6, 7, -6 }, { 6, 8, -8 },
3623b292112SDmitry Baryshkov 			{ 7, 9, -8 }, { 8, 10, -10 }, { 9, 11, -10 }, { 10, 12, -12 },
3633b292112SDmitry Baryshkov 			{ 10, 13, -12 }, { 12, 14, -12 }, { 15, 15, -12 }
3643b292112SDmitry Baryshkov 			}
3653b292112SDmitry Baryshkov 		}
3663b292112SDmitry Baryshkov 	},
3673b292112SDmitry Baryshkov 	{
368e3290f88SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 8,
369e3290f88SDmitry Baryshkov 		{ 512, 12, 6144, 3, 12, 11, 11, {
370e3290f88SDmitry Baryshkov 			{ 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
371e3290f88SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
372e3290f88SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 }, { 5, 12, -12 },
373e3290f88SDmitry Baryshkov 			{ 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
374e3290f88SDmitry Baryshkov 			}
375e3290f88SDmitry Baryshkov 		}
376e3290f88SDmitry Baryshkov 	},
377e3290f88SDmitry Baryshkov 	{
378e3290f88SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 10,
379e3290f88SDmitry Baryshkov 		{ 512, 12, 6144, 7, 16, 15, 15, {
380e3290f88SDmitry Baryshkov 			/*
381e3290f88SDmitry Baryshkov 			 * DSC model/pre-SCR-cfg has 8 for range_max_qp[0], however
382e3290f88SDmitry Baryshkov 			 * VESA DSC 1.1 Table E-5 sets it to 4.
383e3290f88SDmitry Baryshkov 			 */
384e3290f88SDmitry Baryshkov 			{ 0, 4, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
385e3290f88SDmitry Baryshkov 			{ 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
386e3290f88SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 },
387e3290f88SDmitry Baryshkov 			{ 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
388e3290f88SDmitry Baryshkov 			}
389e3290f88SDmitry Baryshkov 		}
390e3290f88SDmitry Baryshkov 	},
391e3290f88SDmitry Baryshkov 	{
392e3290f88SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 12,
393e3290f88SDmitry Baryshkov 		{ 512, 12, 6144, 11, 20, 19, 19, {
394e3290f88SDmitry Baryshkov 			{ 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
395e3290f88SDmitry Baryshkov 			{ 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
396e3290f88SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 },
397e3290f88SDmitry Baryshkov 			{ 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 },
398e3290f88SDmitry Baryshkov 			{ 21, 23, -12 }
399e3290f88SDmitry Baryshkov 			}
400e3290f88SDmitry Baryshkov 		}
401e3290f88SDmitry Baryshkov 	},
402e3290f88SDmitry Baryshkov 	{
4033b292112SDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 8,
4043b292112SDmitry Baryshkov 		{ 410, 12, 5632, 3, 12, 11, 11, {
4053b292112SDmitry Baryshkov 			{ 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
4063b292112SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
4073b292112SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 11, -10 },
4083b292112SDmitry Baryshkov 			{ 5, 12, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
4093b292112SDmitry Baryshkov 			}
4103b292112SDmitry Baryshkov 		}
4113b292112SDmitry Baryshkov 	},
4123b292112SDmitry Baryshkov 	{
4133b292112SDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 10,
4143b292112SDmitry Baryshkov 		{ 410, 12, 5632, 7, 16, 15, 15, {
4153b292112SDmitry Baryshkov 			{ 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
4163b292112SDmitry Baryshkov 			{ 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
4173b292112SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 15, -10 },
4183b292112SDmitry Baryshkov 			{ 9, 16, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
4193b292112SDmitry Baryshkov 			}
4203b292112SDmitry Baryshkov 		}
4213b292112SDmitry Baryshkov 	},
4223b292112SDmitry Baryshkov 	{
4233b292112SDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 12,
4243b292112SDmitry Baryshkov 		{ 410, 12, 5632, 11, 20, 19, 19, {
4253b292112SDmitry Baryshkov 			{ 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
4263b292112SDmitry Baryshkov 			{ 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
4273b292112SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
4283b292112SDmitry Baryshkov 			{ 13, 19, -10 }, { 13, 20, -12 }, { 15, 21, -12 },
4293b292112SDmitry Baryshkov 			{ 21, 23, -12 }
4303b292112SDmitry Baryshkov 			}
4313b292112SDmitry Baryshkov 		}
4323b292112SDmitry Baryshkov 	},
4333b292112SDmitry Baryshkov 	{
434e3290f88SDmitry Baryshkov 		.bpp = DSC_BPP(12), .bpc = 8,
435e3290f88SDmitry Baryshkov 		{ 341, 15, 2048, 3, 12, 11, 11, {
436e3290f88SDmitry Baryshkov 			{ 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
437e3290f88SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
438e3290f88SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 },
439e3290f88SDmitry Baryshkov 			{ 5, 12, -12 }, { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
440e3290f88SDmitry Baryshkov 			}
441e3290f88SDmitry Baryshkov 		}
442e3290f88SDmitry Baryshkov 	},
443e3290f88SDmitry Baryshkov 	{
444e3290f88SDmitry Baryshkov 		.bpp = DSC_BPP(12), .bpc = 10,
445e3290f88SDmitry Baryshkov 		{ 341, 15, 2048, 7, 16, 15, 15, {
446e3290f88SDmitry Baryshkov 			{ 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
447e3290f88SDmitry Baryshkov 			{ 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
448e3290f88SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 },
449e3290f88SDmitry Baryshkov 			{ 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
450e3290f88SDmitry Baryshkov 			}
451e3290f88SDmitry Baryshkov 		}
452e3290f88SDmitry Baryshkov 	},
453e3290f88SDmitry Baryshkov 	{
454e3290f88SDmitry Baryshkov 		.bpp = DSC_BPP(12), .bpc = 12,
455e3290f88SDmitry Baryshkov 		{ 341, 15, 2048, 11, 20, 19, 19, {
456e3290f88SDmitry Baryshkov 			{ 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
457e3290f88SDmitry Baryshkov 			{ 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
458e3290f88SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 },
459e3290f88SDmitry Baryshkov 			{ 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 },
460e3290f88SDmitry Baryshkov 			{ 21, 23, -12 }
461e3290f88SDmitry Baryshkov 			}
462e3290f88SDmitry Baryshkov 		}
463e3290f88SDmitry Baryshkov 	},
4643b292112SDmitry Baryshkov 	{
4653b292112SDmitry Baryshkov 		.bpp = DSC_BPP(15), .bpc = 8,
4663b292112SDmitry Baryshkov 		{ 273, 15, 2048, 3, 12, 11, 11, {
4673b292112SDmitry Baryshkov 			{ 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
4683b292112SDmitry Baryshkov 			{ 1, 2, 2 }, { 1, 3, 0 }, { 1, 4, -2 }, { 2, 4, -4 },
4693b292112SDmitry Baryshkov 			{ 3, 4, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 5, 7, -10 },
4703b292112SDmitry Baryshkov 			{ 5, 8, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
4713b292112SDmitry Baryshkov 			}
4723b292112SDmitry Baryshkov 		}
4733b292112SDmitry Baryshkov 	},
4743b292112SDmitry Baryshkov 	{
4753b292112SDmitry Baryshkov 		.bpp = DSC_BPP(15), .bpc = 10,
4763b292112SDmitry Baryshkov 		{ 273, 15, 2048, 7, 16, 15, 15, {
4773b292112SDmitry Baryshkov 			{ 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
4783b292112SDmitry Baryshkov 			{ 5, 6, 2 }, { 5, 7, 0 }, { 5, 8, -2 }, { 6, 8, -4 },
4793b292112SDmitry Baryshkov 			{ 7, 8, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 9, 11, -10 },
4803b292112SDmitry Baryshkov 			{ 9, 12, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
4813b292112SDmitry Baryshkov 			}
4823b292112SDmitry Baryshkov 		}
4833b292112SDmitry Baryshkov 	},
4843b292112SDmitry Baryshkov 	{
4853b292112SDmitry Baryshkov 		.bpp = DSC_BPP(15), .bpc = 12,
4863b292112SDmitry Baryshkov 		{ 273, 15, 2048, 11, 20, 19, 19, {
4873b292112SDmitry Baryshkov 			{ 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
4883b292112SDmitry Baryshkov 			{ 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
4893b292112SDmitry Baryshkov 			{ 11, 12, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
4903b292112SDmitry Baryshkov 			{ 13, 15, -10 }, { 13, 16, -12 }, { 15, 21, -12 },
4913b292112SDmitry Baryshkov 			{ 21, 23, -12 }
4923b292112SDmitry Baryshkov 			}
4933b292112SDmitry Baryshkov 		}
4943b292112SDmitry Baryshkov 	},
495e3290f88SDmitry Baryshkov 	{ /* sentinel */ }
496e3290f88SDmitry Baryshkov };
497e3290f88SDmitry Baryshkov 
498e3290f88SDmitry Baryshkov /*
499e3290f88SDmitry Baryshkov  * Selected Rate Control Related Parameter Recommended Values from DSC v1.2, v1.2a, v1.2b and
500e3290f88SDmitry Baryshkov  * DSC_v1.1_E1 specs.
501e3290f88SDmitry Baryshkov  *
502e3290f88SDmitry Baryshkov  * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
503e3290f88SDmitry Baryshkov  */
504e3290f88SDmitry Baryshkov static const struct rc_parameters_data rc_parameters_1_2_444[] = {
5052b470e55SDmitry Baryshkov 	{
50674fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 8,
5072b470e55SDmitry Baryshkov 		{ 768, 15, 6144, 3, 13, 11, 11, {
5082b470e55SDmitry Baryshkov 			{ 0, 4, 0 }, { 1, 6, -2 }, { 3, 8, -2 }, { 4, 8, -4 },
5092b470e55SDmitry Baryshkov 			{ 5, 9, -6 }, { 5, 9, -6 }, { 6, 9, -6 }, { 6, 10, -8 },
5102b470e55SDmitry Baryshkov 			{ 7, 11, -8 }, { 8, 12, -10 }, { 9, 12, -10 }, { 10, 12, -12 },
5112b470e55SDmitry Baryshkov 			{ 10, 12, -12 }, { 11, 12, -12 }, { 13, 14, -12 }
5122b470e55SDmitry Baryshkov 			}
51374fe874cSDmitry Baryshkov 		}
5142b470e55SDmitry Baryshkov 	},
51574fe874cSDmitry Baryshkov 	{
51674fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 10,
5172b470e55SDmitry Baryshkov 		{ 768, 15, 6144, 7, 17, 15, 15, {
5182b470e55SDmitry Baryshkov 			{ 0, 8, 0 }, { 3, 10, -2 }, { 7, 12, -2 }, { 8, 12, -4 },
5192b470e55SDmitry Baryshkov 			{ 9, 13, -6 }, { 9, 13, -6 }, { 10, 13, -6 }, { 10, 14, -8 },
5202b470e55SDmitry Baryshkov 			{ 11, 15, -8 }, { 12, 16, -10 }, { 13, 16, -10 },
5212b470e55SDmitry Baryshkov 			{ 14, 16, -12 }, { 14, 16, -12 }, { 15, 16, -12 },
5222b470e55SDmitry Baryshkov 			{ 17, 18, -12 }
5232b470e55SDmitry Baryshkov 			}
52474fe874cSDmitry Baryshkov 		}
5252b470e55SDmitry Baryshkov 	},
52674fe874cSDmitry Baryshkov 	{
52774fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 12,
5282b470e55SDmitry Baryshkov 		{ 768, 15, 6144, 11, 21, 19, 19, {
5292b470e55SDmitry Baryshkov 			{ 0, 12, 0 }, { 5, 14, -2 }, { 11, 16, -2 }, { 12, 16, -4 },
5302b470e55SDmitry Baryshkov 			{ 13, 17, -6 }, { 13, 17, -6 }, { 14, 17, -6 }, { 14, 18, -8 },
5312b470e55SDmitry Baryshkov 			{ 15, 19, -8 }, { 16, 20, -10 }, { 17, 20, -10 },
5322b470e55SDmitry Baryshkov 			{ 18, 20, -12 }, { 18, 20, -12 }, { 19, 20, -12 },
5332b470e55SDmitry Baryshkov 			{ 21, 22, -12 }
5342b470e55SDmitry Baryshkov 			}
53574fe874cSDmitry Baryshkov 		}
5362b470e55SDmitry Baryshkov 	},
53774fe874cSDmitry Baryshkov 	{
53874fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 14,
5392b470e55SDmitry Baryshkov 		{ 768, 15, 6144, 15, 25, 23, 23, {
5402b470e55SDmitry Baryshkov 			{ 0, 16, 0 }, { 7, 18, -2 }, { 15, 20, -2 }, { 16, 20, -4 },
5412b470e55SDmitry Baryshkov 			{ 17, 21, -6 }, { 17, 21, -6 }, { 18, 21, -6 }, { 18, 22, -8 },
5422b470e55SDmitry Baryshkov 			{ 19, 23, -8 }, { 20, 24, -10 }, { 21, 24, -10 },
5432b470e55SDmitry Baryshkov 			{ 22, 24, -12 }, { 22, 24, -12 }, { 23, 24, -12 },
5442b470e55SDmitry Baryshkov 			{ 25, 26, -12 }
5452b470e55SDmitry Baryshkov 			}
54674fe874cSDmitry Baryshkov 		}
5472b470e55SDmitry Baryshkov 	},
54874fe874cSDmitry Baryshkov 	{
54974fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 16,
5502b470e55SDmitry Baryshkov 		{ 768, 15, 6144, 19, 29, 27, 27, {
5512b470e55SDmitry Baryshkov 			{ 0, 20, 0 }, { 9, 22, -2 }, { 19, 24, -2 }, { 20, 24, -4 },
5522b470e55SDmitry Baryshkov 			{ 21, 25, -6 }, { 21, 25, -6 }, { 22, 25, -6 }, { 22, 26, -8 },
5532b470e55SDmitry Baryshkov 			{ 23, 27, -8 }, { 24, 28, -10 }, { 25, 28, -10 },
5542b470e55SDmitry Baryshkov 			{ 26, 28, -12 }, { 26, 28, -12 }, { 27, 28, -12 },
5552b470e55SDmitry Baryshkov 			{ 29, 30, -12 }
5562b470e55SDmitry Baryshkov 			}
55774fe874cSDmitry Baryshkov 		}
5582b470e55SDmitry Baryshkov 	},
5592b470e55SDmitry Baryshkov 	{
56074fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 8,
5612b470e55SDmitry Baryshkov 		{ 512, 12, 6144, 3, 12, 11, 11, {
5622b470e55SDmitry Baryshkov 			{ 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
5632b470e55SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
564e3290f88SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
565e3290f88SDmitry Baryshkov 			{ 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
5662b470e55SDmitry Baryshkov 			}
56774fe874cSDmitry Baryshkov 		}
5682b470e55SDmitry Baryshkov 	},
56974fe874cSDmitry Baryshkov 	{
57074fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 10,
5712b470e55SDmitry Baryshkov 		{ 512, 12, 6144, 7, 16, 15, 15, {
572e3290f88SDmitry Baryshkov 			{ 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
5732b470e55SDmitry Baryshkov 			{ 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
574e3290f88SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
575e3290f88SDmitry Baryshkov 			{ 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
5762b470e55SDmitry Baryshkov 			}
57774fe874cSDmitry Baryshkov 		}
5782b470e55SDmitry Baryshkov 	},
57974fe874cSDmitry Baryshkov 	{
58074fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 12,
5812b470e55SDmitry Baryshkov 		{ 512, 12, 6144, 11, 20, 19, 19, {
5822b470e55SDmitry Baryshkov 			{ 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
5832b470e55SDmitry Baryshkov 			{ 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
584e3290f88SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
585e3290f88SDmitry Baryshkov 			{ 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
586e3290f88SDmitry Baryshkov 			{ 20, 21, -12 }
5872b470e55SDmitry Baryshkov 			}
58874fe874cSDmitry Baryshkov 		}
5892b470e55SDmitry Baryshkov 	},
59074fe874cSDmitry Baryshkov 	{
59174fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 14,
5922b470e55SDmitry Baryshkov 		{ 512, 12, 6144, 15, 24, 23, 23, {
5932b470e55SDmitry Baryshkov 			{ 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
5942b470e55SDmitry Baryshkov 			{ 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
5952b470e55SDmitry Baryshkov 			{ 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
5962b470e55SDmitry Baryshkov 			{ 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
5972b470e55SDmitry Baryshkov 			{ 24, 25, -12 }
5982b470e55SDmitry Baryshkov 			}
59974fe874cSDmitry Baryshkov 		}
6002b470e55SDmitry Baryshkov 	},
60174fe874cSDmitry Baryshkov 	{
60274fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 16,
6032b470e55SDmitry Baryshkov 		{ 512, 12, 6144, 19, 28, 27, 27, {
6042b470e55SDmitry Baryshkov 			{ 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
6052b470e55SDmitry Baryshkov 			{ 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
6062b470e55SDmitry Baryshkov 			{ 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
6072b470e55SDmitry Baryshkov 			{ 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
6082b470e55SDmitry Baryshkov 			{ 28, 29, -12 }
6092b470e55SDmitry Baryshkov 			}
61074fe874cSDmitry Baryshkov 		}
6112b470e55SDmitry Baryshkov 	},
6122b470e55SDmitry Baryshkov 	{
61374fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 8,
6142b470e55SDmitry Baryshkov 		{ 410, 15, 5632, 3, 12, 11, 11, {
6152b470e55SDmitry Baryshkov 			{ 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
6162b470e55SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
6172b470e55SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
6182b470e55SDmitry Baryshkov 			{ 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
6192b470e55SDmitry Baryshkov 			}
62074fe874cSDmitry Baryshkov 		}
6212b470e55SDmitry Baryshkov 	},
62274fe874cSDmitry Baryshkov 	{
62374fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 10,
6242b470e55SDmitry Baryshkov 		{ 410, 15, 5632, 7, 16, 15, 15, {
6252b470e55SDmitry Baryshkov 			{ 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
6262b470e55SDmitry Baryshkov 			{ 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
6272b470e55SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
6282b470e55SDmitry Baryshkov 			{ 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
6292b470e55SDmitry Baryshkov 			}
63074fe874cSDmitry Baryshkov 		}
6312b470e55SDmitry Baryshkov 	},
63274fe874cSDmitry Baryshkov 	{
63374fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 12,
6342b470e55SDmitry Baryshkov 		{ 410, 15, 5632, 11, 20, 19, 19, {
6352b470e55SDmitry Baryshkov 			{ 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
6362b470e55SDmitry Baryshkov 			{ 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
6372b470e55SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
6382b470e55SDmitry Baryshkov 			{ 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
6392b470e55SDmitry Baryshkov 			{ 19, 20, -12 }
6402b470e55SDmitry Baryshkov 			}
64174fe874cSDmitry Baryshkov 		}
6422b470e55SDmitry Baryshkov 	},
64374fe874cSDmitry Baryshkov 	{
64474fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 14,
6452b470e55SDmitry Baryshkov 		{ 410, 15, 5632, 15, 24, 23, 23, {
6462b470e55SDmitry Baryshkov 			{ 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
6472b470e55SDmitry Baryshkov 			{ 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
6482b470e55SDmitry Baryshkov 			{ 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
6492b470e55SDmitry Baryshkov 			{ 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
6502b470e55SDmitry Baryshkov 			{ 23, 24, -12 }
6512b470e55SDmitry Baryshkov 			}
65274fe874cSDmitry Baryshkov 		}
6532b470e55SDmitry Baryshkov 	},
65474fe874cSDmitry Baryshkov 	{
65574fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 16,
6562b470e55SDmitry Baryshkov 		{ 410, 15, 5632, 19, 28, 27, 27, {
6572b470e55SDmitry Baryshkov 			{ 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
6582b470e55SDmitry Baryshkov 			{ 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
6592b470e55SDmitry Baryshkov 			{ 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
6602b470e55SDmitry Baryshkov 			{ 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
6612b470e55SDmitry Baryshkov 			{ 27, 28, -12 }
6622b470e55SDmitry Baryshkov 			}
66374fe874cSDmitry Baryshkov 		}
6642b470e55SDmitry Baryshkov 	},
6652b470e55SDmitry Baryshkov 	{
66674fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(12), .bpc = 8,
6672b470e55SDmitry Baryshkov 		{ 341, 15, 2048, 3, 12, 11, 11, {
6682b470e55SDmitry Baryshkov 			{ 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
6692b470e55SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
670e3290f88SDmitry Baryshkov 			{ 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
671e3290f88SDmitry Baryshkov 			{ 5, 9, -12 }, { 7, 10, -12 }, { 10, 11, -12 }
6722b470e55SDmitry Baryshkov 			}
67374fe874cSDmitry Baryshkov 		}
6742b470e55SDmitry Baryshkov 	},
67574fe874cSDmitry Baryshkov 	{
67674fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(12), .bpc = 10,
6772b470e55SDmitry Baryshkov 		{ 341, 15, 2048, 7, 16, 15, 15, {
6782b470e55SDmitry Baryshkov 			{ 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
6792b470e55SDmitry Baryshkov 			{ 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
680e3290f88SDmitry Baryshkov 			{ 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
681e3290f88SDmitry Baryshkov 			{ 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
6822b470e55SDmitry Baryshkov 			}
68374fe874cSDmitry Baryshkov 		}
6842b470e55SDmitry Baryshkov 	},
68574fe874cSDmitry Baryshkov 	{
68674fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(12), .bpc = 12,
6872b470e55SDmitry Baryshkov 		{ 341, 15, 2048, 11, 20, 19, 19, {
6882b470e55SDmitry Baryshkov 			{ 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
6892b470e55SDmitry Baryshkov 			{ 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
690e3290f88SDmitry Baryshkov 			{ 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
691e3290f88SDmitry Baryshkov 			{ 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
692e3290f88SDmitry Baryshkov 			{ 18, 19, -12 }
6932b470e55SDmitry Baryshkov 			}
69474fe874cSDmitry Baryshkov 		}
6952b470e55SDmitry Baryshkov 	},
69674fe874cSDmitry Baryshkov 	{
69774fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(12), .bpc = 14,
6982b470e55SDmitry Baryshkov 		{ 341, 15, 2048, 15, 24, 23, 23, {
6992b470e55SDmitry Baryshkov 			{ 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
7002b470e55SDmitry Baryshkov 			{ 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
7012b470e55SDmitry Baryshkov 			{ 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
7022b470e55SDmitry Baryshkov 			{ 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
7032b470e55SDmitry Baryshkov 			{ 22, 23, -12 }
7042b470e55SDmitry Baryshkov 			}
70574fe874cSDmitry Baryshkov 		}
7062b470e55SDmitry Baryshkov 	},
70774fe874cSDmitry Baryshkov 	{
70874fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(12), .bpc = 16,
7092b470e55SDmitry Baryshkov 		{ 341, 15, 2048, 19, 28, 27, 27, {
7102b470e55SDmitry Baryshkov 			{ 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
7112b470e55SDmitry Baryshkov 			{ 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
7122b470e55SDmitry Baryshkov 			{ 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
7132b470e55SDmitry Baryshkov 			{ 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
7142b470e55SDmitry Baryshkov 			{ 26, 27, -12 }
7152b470e55SDmitry Baryshkov 			}
71674fe874cSDmitry Baryshkov 		}
7172b470e55SDmitry Baryshkov 	},
7182b470e55SDmitry Baryshkov 	{
71974fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(15), .bpc = 8,
7202b470e55SDmitry Baryshkov 		{ 273, 15, 2048, 3, 12, 11, 11, {
7212b470e55SDmitry Baryshkov 			{ 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
7222b470e55SDmitry Baryshkov 			{ 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
7232b470e55SDmitry Baryshkov 			{ 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
7242b470e55SDmitry Baryshkov 			{ 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
7252b470e55SDmitry Baryshkov 			}
72674fe874cSDmitry Baryshkov 		}
7272b470e55SDmitry Baryshkov 	},
72874fe874cSDmitry Baryshkov 	{
72974fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(15), .bpc = 10,
7302b470e55SDmitry Baryshkov 		{ 273, 15, 2048, 7, 16, 15, 15, {
7312b470e55SDmitry Baryshkov 			{ 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
7322b470e55SDmitry Baryshkov 			{ 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
7332b470e55SDmitry Baryshkov 			{ 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
7342b470e55SDmitry Baryshkov 			{ 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
7352b470e55SDmitry Baryshkov 			}
73674fe874cSDmitry Baryshkov 		}
7372b470e55SDmitry Baryshkov 	},
73874fe874cSDmitry Baryshkov 	{
73974fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(15), .bpc = 12,
7402b470e55SDmitry Baryshkov 		{ 273, 15, 2048, 11, 20, 19, 19, {
7412b470e55SDmitry Baryshkov 			{ 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
7422b470e55SDmitry Baryshkov 			{ 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
7432b470e55SDmitry Baryshkov 			{ 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
7442b470e55SDmitry Baryshkov 			{ 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
7452b470e55SDmitry Baryshkov 			{ 16, 17, -12 }
7462b470e55SDmitry Baryshkov 			}
74774fe874cSDmitry Baryshkov 		}
7482b470e55SDmitry Baryshkov 	},
74974fe874cSDmitry Baryshkov 	{
75074fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(15), .bpc = 14,
7512b470e55SDmitry Baryshkov 		{ 273, 15, 2048, 15, 24, 23, 23, {
7522b470e55SDmitry Baryshkov 			{ 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
7532b470e55SDmitry Baryshkov 			{ 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
7542b470e55SDmitry Baryshkov 			{ 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
7552b470e55SDmitry Baryshkov 			{ 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
7562b470e55SDmitry Baryshkov 			{ 20, 21, -12 }
7572b470e55SDmitry Baryshkov 			}
75874fe874cSDmitry Baryshkov 		}
7592b470e55SDmitry Baryshkov 	},
76074fe874cSDmitry Baryshkov 	{
76174fe874cSDmitry Baryshkov 		.bpp = DSC_BPP(15), .bpc = 16,
7622b470e55SDmitry Baryshkov 		{ 273, 15, 2048, 19, 28, 27, 27, {
7632b470e55SDmitry Baryshkov 			{ 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
7642b470e55SDmitry Baryshkov 			{ 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
7652b470e55SDmitry Baryshkov 			{ 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
7662b470e55SDmitry Baryshkov 			{ 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
7672b470e55SDmitry Baryshkov 			{ 24, 25, -12 }
7682b470e55SDmitry Baryshkov 			}
7692b470e55SDmitry Baryshkov 		}
77074fe874cSDmitry Baryshkov 	},
77174fe874cSDmitry Baryshkov 	{ /* sentinel */ }
7722b470e55SDmitry Baryshkov };
7732b470e55SDmitry Baryshkov 
774d54fbea3SDmitry Baryshkov /*
775d54fbea3SDmitry Baryshkov  * Selected Rate Control Related Parameter Recommended Values for 4:2:2 from
776d54fbea3SDmitry Baryshkov  * DSC v1.2, v1.2a, v1.2b
777d54fbea3SDmitry Baryshkov  *
778d54fbea3SDmitry Baryshkov  * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
779d54fbea3SDmitry Baryshkov  */
780d54fbea3SDmitry Baryshkov static const struct rc_parameters_data rc_parameters_1_2_422[] = {
781d54fbea3SDmitry Baryshkov 	{
782d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 8,
783d54fbea3SDmitry Baryshkov 		{ 512, 15, 6144, 3, 12, 11, 11, {
784d54fbea3SDmitry Baryshkov 			{ 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
785d54fbea3SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
786d54fbea3SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
787d54fbea3SDmitry Baryshkov 			{ 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
788d54fbea3SDmitry Baryshkov 			}
789d54fbea3SDmitry Baryshkov 		}
790d54fbea3SDmitry Baryshkov 	},
791d54fbea3SDmitry Baryshkov 	{
792d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 10,
793d54fbea3SDmitry Baryshkov 		{ 512, 15, 6144, 7, 16, 15, 15, {
794d54fbea3SDmitry Baryshkov 			{ 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
795d54fbea3SDmitry Baryshkov 			{ 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
796d54fbea3SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
797d54fbea3SDmitry Baryshkov 			{ 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
798d54fbea3SDmitry Baryshkov 			}
799d54fbea3SDmitry Baryshkov 		}
800d54fbea3SDmitry Baryshkov 	},
801d54fbea3SDmitry Baryshkov 	{
802d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 12,
803d54fbea3SDmitry Baryshkov 		{ 512, 15, 6144, 11, 20, 19, 19, {
804d54fbea3SDmitry Baryshkov 			{ 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
805d54fbea3SDmitry Baryshkov 			{ 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
806d54fbea3SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
807d54fbea3SDmitry Baryshkov 			{ 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
808d54fbea3SDmitry Baryshkov 			{ 20, 21, -12 }
809d54fbea3SDmitry Baryshkov 			}
810d54fbea3SDmitry Baryshkov 		}
811d54fbea3SDmitry Baryshkov 	},
812d54fbea3SDmitry Baryshkov 	{
813d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 14,
814d54fbea3SDmitry Baryshkov 		{ 512, 15, 6144, 15, 24, 23, 23, {
815d54fbea3SDmitry Baryshkov 			{ 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
816d54fbea3SDmitry Baryshkov 			{ 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
817d54fbea3SDmitry Baryshkov 			{ 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
818d54fbea3SDmitry Baryshkov 			{ 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
819d54fbea3SDmitry Baryshkov 			{ 24, 25, -12 }
820d54fbea3SDmitry Baryshkov 			}
821d54fbea3SDmitry Baryshkov 		}
822d54fbea3SDmitry Baryshkov 	},
823d54fbea3SDmitry Baryshkov 	{
824d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 16,
825d54fbea3SDmitry Baryshkov 		{ 512, 15, 6144, 19, 28, 27, 27, {
826d54fbea3SDmitry Baryshkov 			{ 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
827d54fbea3SDmitry Baryshkov 			{ 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
828d54fbea3SDmitry Baryshkov 			{ 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
829d54fbea3SDmitry Baryshkov 			{ 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
830d54fbea3SDmitry Baryshkov 			{ 28, 29, -12 }
831d54fbea3SDmitry Baryshkov 			}
832d54fbea3SDmitry Baryshkov 		}
833d54fbea3SDmitry Baryshkov 	},
834d54fbea3SDmitry Baryshkov 	{
835d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(7), .bpc = 8,
836d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 3, 12, 11, 11, {
837d54fbea3SDmitry Baryshkov 			{ 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
838d54fbea3SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
839d54fbea3SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
840d54fbea3SDmitry Baryshkov 			{ 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
841d54fbea3SDmitry Baryshkov 			}
842d54fbea3SDmitry Baryshkov 		}
843d54fbea3SDmitry Baryshkov 	},
844d54fbea3SDmitry Baryshkov 	{
845d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(7), .bpc = 10,
846d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 7, 16, 15, 15, {
847d54fbea3SDmitry Baryshkov 			{ 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
848d54fbea3SDmitry Baryshkov 			{ 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
849d54fbea3SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
850d54fbea3SDmitry Baryshkov 			{ 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
851d54fbea3SDmitry Baryshkov 			}
852d54fbea3SDmitry Baryshkov 		}
853d54fbea3SDmitry Baryshkov 	},
854d54fbea3SDmitry Baryshkov 	{
855d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(7), .bpc = 12,
856d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 11, 20, 19, 19, {
857d54fbea3SDmitry Baryshkov 			{ 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
858d54fbea3SDmitry Baryshkov 			{ 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
859d54fbea3SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
860d54fbea3SDmitry Baryshkov 			{ 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
861d54fbea3SDmitry Baryshkov 			{ 19, 20, -12 }
862d54fbea3SDmitry Baryshkov 			}
863d54fbea3SDmitry Baryshkov 		}
864d54fbea3SDmitry Baryshkov 	},
865d54fbea3SDmitry Baryshkov 	{
866d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(7), .bpc = 14,
867d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 15, 24, 23, 23, {
868d54fbea3SDmitry Baryshkov 			{ 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
869d54fbea3SDmitry Baryshkov 			{ 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
870d54fbea3SDmitry Baryshkov 			{ 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
871d54fbea3SDmitry Baryshkov 			{ 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
872d54fbea3SDmitry Baryshkov 			{ 23, 24, -12 }
873d54fbea3SDmitry Baryshkov 			}
874d54fbea3SDmitry Baryshkov 		}
875d54fbea3SDmitry Baryshkov 	},
876d54fbea3SDmitry Baryshkov 	{
877d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(7), .bpc = 16,
878d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 19, 28, 27, 27, {
879d54fbea3SDmitry Baryshkov 			{ 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
880d54fbea3SDmitry Baryshkov 			{ 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
881d54fbea3SDmitry Baryshkov 			{ 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
882d54fbea3SDmitry Baryshkov 			{ 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
883d54fbea3SDmitry Baryshkov 			{ 27, 28, -12 }
884d54fbea3SDmitry Baryshkov 			}
885d54fbea3SDmitry Baryshkov 		}
886d54fbea3SDmitry Baryshkov 	},
887d54fbea3SDmitry Baryshkov 	{
888d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 8,
889d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 3, 12, 11, 11, {
890d54fbea3SDmitry Baryshkov 			{ 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
891d54fbea3SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
892d54fbea3SDmitry Baryshkov 			{ 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
893d54fbea3SDmitry Baryshkov 			{ 5, 9, -12 }, { 7, 10, -12 }, { 10, 11, -12 }
894d54fbea3SDmitry Baryshkov 			}
895d54fbea3SDmitry Baryshkov 		}
896d54fbea3SDmitry Baryshkov 	},
897d54fbea3SDmitry Baryshkov 	{
898d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 10,
899d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 7, 16, 15, 15, {
900d54fbea3SDmitry Baryshkov 			{ 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
901d54fbea3SDmitry Baryshkov 			{ 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
902d54fbea3SDmitry Baryshkov 			{ 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
903d54fbea3SDmitry Baryshkov 			{ 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
904d54fbea3SDmitry Baryshkov 			}
905d54fbea3SDmitry Baryshkov 		}
906d54fbea3SDmitry Baryshkov 	},
907d54fbea3SDmitry Baryshkov 	{
908d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 12,
909d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 11, 20, 19, 19, {
910d54fbea3SDmitry Baryshkov 			{ 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
911d54fbea3SDmitry Baryshkov 			{ 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
912d54fbea3SDmitry Baryshkov 			{ 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
913d54fbea3SDmitry Baryshkov 			{ 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
914d54fbea3SDmitry Baryshkov 			{ 18, 19, -12 }
915d54fbea3SDmitry Baryshkov 			}
916d54fbea3SDmitry Baryshkov 		}
917d54fbea3SDmitry Baryshkov 	},
918d54fbea3SDmitry Baryshkov 	{
919d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 14,
920d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 15, 24, 23, 23, {
921d54fbea3SDmitry Baryshkov 			{ 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
922d54fbea3SDmitry Baryshkov 			{ 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
923d54fbea3SDmitry Baryshkov 			{ 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
924d54fbea3SDmitry Baryshkov 			{ 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
925d54fbea3SDmitry Baryshkov 			{ 22, 23, -12 }
926d54fbea3SDmitry Baryshkov 			}
927d54fbea3SDmitry Baryshkov 		}
928d54fbea3SDmitry Baryshkov 	},
929d54fbea3SDmitry Baryshkov 	{
930d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 16,
931d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 19, 28, 27, 27, {
932d54fbea3SDmitry Baryshkov 			{ 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
933d54fbea3SDmitry Baryshkov 			{ 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
934d54fbea3SDmitry Baryshkov 			{ 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
935d54fbea3SDmitry Baryshkov 			{ 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
936d54fbea3SDmitry Baryshkov 			{ 26, 27, -12 }
937d54fbea3SDmitry Baryshkov 			}
938d54fbea3SDmitry Baryshkov 		}
939d54fbea3SDmitry Baryshkov 	},
940d54fbea3SDmitry Baryshkov 	{
941d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 8,
942d54fbea3SDmitry Baryshkov 		{ 273, 15, 2048, 3, 12, 11, 11, {
943d54fbea3SDmitry Baryshkov 			{ 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
944d54fbea3SDmitry Baryshkov 			{ 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
945d54fbea3SDmitry Baryshkov 			{ 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
946d54fbea3SDmitry Baryshkov 			{ 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
947d54fbea3SDmitry Baryshkov 			}
948d54fbea3SDmitry Baryshkov 		}
949d54fbea3SDmitry Baryshkov 	},
950d54fbea3SDmitry Baryshkov 	{
951d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 10,
952d54fbea3SDmitry Baryshkov 		{ 273, 15, 2048, 7, 16, 15, 15, {
953d54fbea3SDmitry Baryshkov 			{ 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
954d54fbea3SDmitry Baryshkov 			{ 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
955d54fbea3SDmitry Baryshkov 			{ 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
956d54fbea3SDmitry Baryshkov 			{ 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
957d54fbea3SDmitry Baryshkov 			}
958d54fbea3SDmitry Baryshkov 		}
959d54fbea3SDmitry Baryshkov 	},
960d54fbea3SDmitry Baryshkov 	{
961d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 12,
962d54fbea3SDmitry Baryshkov 		{ 273, 15, 2048, 11, 20, 19, 19, {
963d54fbea3SDmitry Baryshkov 			{ 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
964d54fbea3SDmitry Baryshkov 			{ 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
965d54fbea3SDmitry Baryshkov 			{ 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
966d54fbea3SDmitry Baryshkov 			{ 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
967d54fbea3SDmitry Baryshkov 			{ 16, 17, -12 }
968d54fbea3SDmitry Baryshkov 			}
969d54fbea3SDmitry Baryshkov 		}
970d54fbea3SDmitry Baryshkov 	},
971d54fbea3SDmitry Baryshkov 	{
972d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 14,
973d54fbea3SDmitry Baryshkov 		{ 273, 15, 2048, 15, 24, 23, 23, {
974d54fbea3SDmitry Baryshkov 			{ 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
975d54fbea3SDmitry Baryshkov 			{ 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
976d54fbea3SDmitry Baryshkov 			{ 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
977d54fbea3SDmitry Baryshkov 			{ 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
978d54fbea3SDmitry Baryshkov 			{ 20, 21, -12 }
979d54fbea3SDmitry Baryshkov 			}
980d54fbea3SDmitry Baryshkov 		}
981d54fbea3SDmitry Baryshkov 	},
982d54fbea3SDmitry Baryshkov 	{
983d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(10), .bpc = 16,
984d54fbea3SDmitry Baryshkov 		{ 273, 15, 2048, 19, 28, 27, 27, {
985d54fbea3SDmitry Baryshkov 			{ 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
986d54fbea3SDmitry Baryshkov 			{ 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
987d54fbea3SDmitry Baryshkov 			{ 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
988d54fbea3SDmitry Baryshkov 			{ 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
989d54fbea3SDmitry Baryshkov 			{ 24, 25, -12 }
990d54fbea3SDmitry Baryshkov 			}
991d54fbea3SDmitry Baryshkov 		}
992d54fbea3SDmitry Baryshkov 	},
993d54fbea3SDmitry Baryshkov 	{ /* sentinel */ }
994d54fbea3SDmitry Baryshkov };
995d54fbea3SDmitry Baryshkov 
996d54fbea3SDmitry Baryshkov /*
997d54fbea3SDmitry Baryshkov  * Selected Rate Control Related Parameter Recommended Values for 4:2:2 from
998d54fbea3SDmitry Baryshkov  * DSC v1.2, v1.2a, v1.2b
999d54fbea3SDmitry Baryshkov  *
1000d54fbea3SDmitry Baryshkov  * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
1001d54fbea3SDmitry Baryshkov  */
1002d54fbea3SDmitry Baryshkov static const struct rc_parameters_data rc_parameters_1_2_420[] = {
1003d54fbea3SDmitry Baryshkov 	{
1004d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(4), .bpc = 8,
1005d54fbea3SDmitry Baryshkov 		{ 512, 12, 6144, 3, 12, 11, 11, {
1006d54fbea3SDmitry Baryshkov 			{ 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
1007d54fbea3SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1008d54fbea3SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
1009d54fbea3SDmitry Baryshkov 			{ 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
1010d54fbea3SDmitry Baryshkov 			}
1011d54fbea3SDmitry Baryshkov 		}
1012d54fbea3SDmitry Baryshkov 	},
1013d54fbea3SDmitry Baryshkov 	{
1014d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(4), .bpc = 10,
1015d54fbea3SDmitry Baryshkov 		{ 512, 12, 6144, 7, 16, 15, 15, {
1016d54fbea3SDmitry Baryshkov 			{ 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
1017d54fbea3SDmitry Baryshkov 			{ 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1018d54fbea3SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
1019d54fbea3SDmitry Baryshkov 			{ 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
1020d54fbea3SDmitry Baryshkov 			}
1021d54fbea3SDmitry Baryshkov 		}
1022d54fbea3SDmitry Baryshkov 	},
1023d54fbea3SDmitry Baryshkov 	{
1024d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(4), .bpc = 12,
1025d54fbea3SDmitry Baryshkov 		{ 512, 12, 6144, 11, 20, 19, 19, {
1026d54fbea3SDmitry Baryshkov 			{ 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
1027d54fbea3SDmitry Baryshkov 			{ 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1028d54fbea3SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
1029d54fbea3SDmitry Baryshkov 			{ 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
1030d54fbea3SDmitry Baryshkov 			{ 20, 21, -12 }
1031d54fbea3SDmitry Baryshkov 			}
1032d54fbea3SDmitry Baryshkov 		}
1033d54fbea3SDmitry Baryshkov 	},
1034d54fbea3SDmitry Baryshkov 	{
1035d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(4), .bpc = 14,
1036d54fbea3SDmitry Baryshkov 		{ 512, 12, 6144, 15, 24, 23, 23, {
1037d54fbea3SDmitry Baryshkov 			{ 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
1038d54fbea3SDmitry Baryshkov 			{ 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1039d54fbea3SDmitry Baryshkov 			{ 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
1040d54fbea3SDmitry Baryshkov 			{ 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
1041d54fbea3SDmitry Baryshkov 			{ 24, 25, -12 }
1042d54fbea3SDmitry Baryshkov 			}
1043d54fbea3SDmitry Baryshkov 		}
1044d54fbea3SDmitry Baryshkov 	},
1045d54fbea3SDmitry Baryshkov 	{
1046d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(4), .bpc = 16,
1047d54fbea3SDmitry Baryshkov 		{ 512, 12, 6144, 19, 28, 27, 27, {
1048d54fbea3SDmitry Baryshkov 			{ 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
1049d54fbea3SDmitry Baryshkov 			{ 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1050d54fbea3SDmitry Baryshkov 			{ 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
1051d54fbea3SDmitry Baryshkov 			{ 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
1052d54fbea3SDmitry Baryshkov 			{ 28, 29, -12 }
1053d54fbea3SDmitry Baryshkov 			}
1054d54fbea3SDmitry Baryshkov 		}
1055d54fbea3SDmitry Baryshkov 	},
1056d54fbea3SDmitry Baryshkov 	{
1057d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(5), .bpc = 8,
1058d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 3, 12, 11, 11, {
1059d54fbea3SDmitry Baryshkov 			{ 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
1060d54fbea3SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1061d54fbea3SDmitry Baryshkov 			{ 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
1062d54fbea3SDmitry Baryshkov 			{ 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
1063d54fbea3SDmitry Baryshkov 			}
1064d54fbea3SDmitry Baryshkov 		}
1065d54fbea3SDmitry Baryshkov 	},
1066d54fbea3SDmitry Baryshkov 	{
1067d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(5), .bpc = 10,
1068d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 7, 16, 15, 15, {
1069d54fbea3SDmitry Baryshkov 			{ 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
1070d54fbea3SDmitry Baryshkov 			{ 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1071d54fbea3SDmitry Baryshkov 			{ 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
1072d54fbea3SDmitry Baryshkov 			{ 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
1073d54fbea3SDmitry Baryshkov 			}
1074d54fbea3SDmitry Baryshkov 		}
1075d54fbea3SDmitry Baryshkov 	},
1076d54fbea3SDmitry Baryshkov 	{
1077d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(5), .bpc = 12,
1078d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 11, 20, 19, 19, {
1079d54fbea3SDmitry Baryshkov 			{ 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
1080d54fbea3SDmitry Baryshkov 			{ 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1081d54fbea3SDmitry Baryshkov 			{ 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
1082d54fbea3SDmitry Baryshkov 			{ 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
1083d54fbea3SDmitry Baryshkov 			{ 19, 20, -12 }
1084d54fbea3SDmitry Baryshkov 			}
1085d54fbea3SDmitry Baryshkov 		}
1086d54fbea3SDmitry Baryshkov 	},
1087d54fbea3SDmitry Baryshkov 	{
1088d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(5), .bpc = 14,
1089d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 15, 24, 23, 23, {
1090d54fbea3SDmitry Baryshkov 			{ 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
1091d54fbea3SDmitry Baryshkov 			{ 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1092d54fbea3SDmitry Baryshkov 			{ 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
1093d54fbea3SDmitry Baryshkov 			{ 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
1094d54fbea3SDmitry Baryshkov 			{ 23, 24, -12 }
1095d54fbea3SDmitry Baryshkov 			}
1096d54fbea3SDmitry Baryshkov 		}
1097d54fbea3SDmitry Baryshkov 	},
1098d54fbea3SDmitry Baryshkov 	{
1099d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(5), .bpc = 16,
1100d54fbea3SDmitry Baryshkov 		{ 410, 15, 5632, 19, 28, 27, 27, {
1101d54fbea3SDmitry Baryshkov 			{ 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
1102d54fbea3SDmitry Baryshkov 			{ 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1103d54fbea3SDmitry Baryshkov 			{ 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
1104d54fbea3SDmitry Baryshkov 			{ 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
1105d54fbea3SDmitry Baryshkov 			{ 27, 28, -12 }
1106d54fbea3SDmitry Baryshkov 			}
1107d54fbea3SDmitry Baryshkov 		}
1108d54fbea3SDmitry Baryshkov 	},
1109d54fbea3SDmitry Baryshkov 	{
1110d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 8,
1111d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 3, 12, 11, 11, {
1112d54fbea3SDmitry Baryshkov 			{ 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
1113d54fbea3SDmitry Baryshkov 			{ 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1114d54fbea3SDmitry Baryshkov 			{ 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
1115d54fbea3SDmitry Baryshkov 			{ 5, 9, -12 }, { 7, 10, -12 }, { 10, 12, -12 }
1116d54fbea3SDmitry Baryshkov 			}
1117d54fbea3SDmitry Baryshkov 		}
1118d54fbea3SDmitry Baryshkov 	},
1119d54fbea3SDmitry Baryshkov 	{
1120d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 10,
1121d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 7, 16, 15, 15, {
1122d54fbea3SDmitry Baryshkov 			{ 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
1123d54fbea3SDmitry Baryshkov 			{ 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1124d54fbea3SDmitry Baryshkov 			{ 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
1125d54fbea3SDmitry Baryshkov 			{ 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
1126d54fbea3SDmitry Baryshkov 			}
1127d54fbea3SDmitry Baryshkov 		}
1128d54fbea3SDmitry Baryshkov 	},
1129d54fbea3SDmitry Baryshkov 	{
1130d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 12,
1131d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 11, 20, 19, 19, {
1132d54fbea3SDmitry Baryshkov 			{ 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
1133d54fbea3SDmitry Baryshkov 			{ 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1134d54fbea3SDmitry Baryshkov 			{ 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
1135d54fbea3SDmitry Baryshkov 			{ 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
1136d54fbea3SDmitry Baryshkov 			{ 18, 19, -12 }
1137d54fbea3SDmitry Baryshkov 			}
1138d54fbea3SDmitry Baryshkov 		}
1139d54fbea3SDmitry Baryshkov 	},
1140d54fbea3SDmitry Baryshkov 	{
1141d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 14,
1142d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 15, 24, 23, 23, {
1143d54fbea3SDmitry Baryshkov 			{ 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
1144d54fbea3SDmitry Baryshkov 			{ 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1145d54fbea3SDmitry Baryshkov 			{ 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
1146d54fbea3SDmitry Baryshkov 			{ 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
1147d54fbea3SDmitry Baryshkov 			{ 22, 23, -12 }
1148d54fbea3SDmitry Baryshkov 			}
1149d54fbea3SDmitry Baryshkov 		}
1150d54fbea3SDmitry Baryshkov 	},
1151d54fbea3SDmitry Baryshkov 	{
1152d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(6), .bpc = 16,
1153d54fbea3SDmitry Baryshkov 		{ 341, 15, 2048, 19, 28, 27, 27, {
1154d54fbea3SDmitry Baryshkov 			{ 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
1155d54fbea3SDmitry Baryshkov 			{ 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1156d54fbea3SDmitry Baryshkov 			{ 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
1157d54fbea3SDmitry Baryshkov 			{ 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
1158d54fbea3SDmitry Baryshkov 			{ 26, 27, -12 }
1159d54fbea3SDmitry Baryshkov 			}
1160d54fbea3SDmitry Baryshkov 		}
1161d54fbea3SDmitry Baryshkov 	},
1162d54fbea3SDmitry Baryshkov 	{
1163d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 8,
1164d54fbea3SDmitry Baryshkov 		{ 256, 15, 2048, 3, 12, 11, 11, {
1165d54fbea3SDmitry Baryshkov 			{ 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
1166d54fbea3SDmitry Baryshkov 			{ 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
1167d54fbea3SDmitry Baryshkov 			{ 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
1168d54fbea3SDmitry Baryshkov 			{ 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
1169d54fbea3SDmitry Baryshkov 			}
1170d54fbea3SDmitry Baryshkov 		}
1171d54fbea3SDmitry Baryshkov 	},
1172d54fbea3SDmitry Baryshkov 	{
1173d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 10,
1174d54fbea3SDmitry Baryshkov 		{ 256, 15, 2048, 7, 16, 15, 15, {
1175d54fbea3SDmitry Baryshkov 			{ 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
1176d54fbea3SDmitry Baryshkov 			{ 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
1177d54fbea3SDmitry Baryshkov 			{ 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
1178d54fbea3SDmitry Baryshkov 			{ 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
1179d54fbea3SDmitry Baryshkov 			}
1180d54fbea3SDmitry Baryshkov 		}
1181d54fbea3SDmitry Baryshkov 	},
1182d54fbea3SDmitry Baryshkov 	{
1183d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 12,
1184d54fbea3SDmitry Baryshkov 		{ 256, 15, 2048, 11, 20, 19, 19, {
1185d54fbea3SDmitry Baryshkov 			{ 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
1186d54fbea3SDmitry Baryshkov 			{ 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
1187d54fbea3SDmitry Baryshkov 			{ 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
1188d54fbea3SDmitry Baryshkov 			{ 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
1189d54fbea3SDmitry Baryshkov 			{ 16, 17, -12 }
1190d54fbea3SDmitry Baryshkov 			}
1191d54fbea3SDmitry Baryshkov 		}
1192d54fbea3SDmitry Baryshkov 	},
1193d54fbea3SDmitry Baryshkov 	{
1194d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 14,
1195d54fbea3SDmitry Baryshkov 		{ 256, 15, 2048, 15, 24, 23, 23, {
1196d54fbea3SDmitry Baryshkov 			{ 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
1197d54fbea3SDmitry Baryshkov 			{ 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
1198d54fbea3SDmitry Baryshkov 			{ 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
1199d54fbea3SDmitry Baryshkov 			{ 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
1200d54fbea3SDmitry Baryshkov 			{ 20, 21, -12 }
1201d54fbea3SDmitry Baryshkov 			}
1202d54fbea3SDmitry Baryshkov 		}
1203d54fbea3SDmitry Baryshkov 	},
1204d54fbea3SDmitry Baryshkov 	{
1205d54fbea3SDmitry Baryshkov 		.bpp = DSC_BPP(8), .bpc = 16,
1206d54fbea3SDmitry Baryshkov 		{ 256, 15, 2048, 19, 28, 27, 27, {
1207d54fbea3SDmitry Baryshkov 			{ 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
1208d54fbea3SDmitry Baryshkov 			{ 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
1209d54fbea3SDmitry Baryshkov 			{ 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
1210d54fbea3SDmitry Baryshkov 			{ 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
1211d54fbea3SDmitry Baryshkov 			{ 24, 25, -12 }
1212d54fbea3SDmitry Baryshkov 			}
1213d54fbea3SDmitry Baryshkov 		}
1214d54fbea3SDmitry Baryshkov 	},
1215d54fbea3SDmitry Baryshkov 	{ /* sentinel */ }
1216d54fbea3SDmitry Baryshkov };
1217d54fbea3SDmitry Baryshkov 
get_rc_params(const struct rc_parameters_data * rc_parameters,u16 dsc_bpp,u8 bits_per_component)1218e3290f88SDmitry Baryshkov static const struct rc_parameters *get_rc_params(const struct rc_parameters_data *rc_parameters,
1219e3290f88SDmitry Baryshkov 						 u16 dsc_bpp,
12202b470e55SDmitry Baryshkov 						 u8 bits_per_component)
12212b470e55SDmitry Baryshkov {
122274fe874cSDmitry Baryshkov 	int i;
12232b470e55SDmitry Baryshkov 
122474fe874cSDmitry Baryshkov 	for (i = 0; rc_parameters[i].bpp; i++)
122574fe874cSDmitry Baryshkov 		if (rc_parameters[i].bpp == dsc_bpp &&
122674fe874cSDmitry Baryshkov 		    rc_parameters[i].bpc == bits_per_component)
122774fe874cSDmitry Baryshkov 			return &rc_parameters[i].params;
122874fe874cSDmitry Baryshkov 
12292b470e55SDmitry Baryshkov 	return NULL;
12302b470e55SDmitry Baryshkov }
12312b470e55SDmitry Baryshkov 
12322b470e55SDmitry Baryshkov /**
12332b470e55SDmitry Baryshkov  * drm_dsc_setup_rc_params() - Set parameters and limits for RC model in
12342b470e55SDmitry Baryshkov  * accordance with the DSC 1.1 or 1.2 specification and DSC C Model
12352b470e55SDmitry Baryshkov  * Required bits_per_pixel and bits_per_component to be set before calling this
12362b470e55SDmitry Baryshkov  * function.
12372b470e55SDmitry Baryshkov  *
12382b470e55SDmitry Baryshkov  * @vdsc_cfg: DSC Configuration data partially filled by driver
1239e3290f88SDmitry Baryshkov  * @type: operating mode and standard to follow
12402b470e55SDmitry Baryshkov  *
12412b470e55SDmitry Baryshkov  * Return: 0 or -error code in case of an error
12422b470e55SDmitry Baryshkov  */
drm_dsc_setup_rc_params(struct drm_dsc_config * vdsc_cfg,enum drm_dsc_params_type type)1243e3290f88SDmitry Baryshkov int drm_dsc_setup_rc_params(struct drm_dsc_config *vdsc_cfg, enum drm_dsc_params_type type)
12442b470e55SDmitry Baryshkov {
1245e3290f88SDmitry Baryshkov 	const struct rc_parameters_data *data;
12462b470e55SDmitry Baryshkov 	const struct rc_parameters *rc_params;
12472b470e55SDmitry Baryshkov 	int i;
12482b470e55SDmitry Baryshkov 
12492b470e55SDmitry Baryshkov 	if (WARN_ON_ONCE(!vdsc_cfg->bits_per_pixel ||
12502b470e55SDmitry Baryshkov 			 !vdsc_cfg->bits_per_component))
12512b470e55SDmitry Baryshkov 		return -EINVAL;
12522b470e55SDmitry Baryshkov 
1253e3290f88SDmitry Baryshkov 	switch (type) {
1254e3290f88SDmitry Baryshkov 	case DRM_DSC_1_2_444:
1255e3290f88SDmitry Baryshkov 		data = rc_parameters_1_2_444;
1256e3290f88SDmitry Baryshkov 		break;
1257e3290f88SDmitry Baryshkov 	case DRM_DSC_1_1_PRE_SCR:
1258e3290f88SDmitry Baryshkov 		data = rc_parameters_pre_scr;
1259e3290f88SDmitry Baryshkov 		break;
1260d54fbea3SDmitry Baryshkov 	case DRM_DSC_1_2_422:
1261d54fbea3SDmitry Baryshkov 		data = rc_parameters_1_2_422;
1262d54fbea3SDmitry Baryshkov 		break;
1263d54fbea3SDmitry Baryshkov 	case DRM_DSC_1_2_420:
1264d54fbea3SDmitry Baryshkov 		data = rc_parameters_1_2_420;
1265d54fbea3SDmitry Baryshkov 		break;
1266e3290f88SDmitry Baryshkov 	default:
1267e3290f88SDmitry Baryshkov 		return -EINVAL;
1268e3290f88SDmitry Baryshkov 	}
1269e3290f88SDmitry Baryshkov 
1270e3290f88SDmitry Baryshkov 	rc_params = get_rc_params(data,
1271e3290f88SDmitry Baryshkov 				  vdsc_cfg->bits_per_pixel,
12722b470e55SDmitry Baryshkov 				  vdsc_cfg->bits_per_component);
12732b470e55SDmitry Baryshkov 	if (!rc_params)
12742b470e55SDmitry Baryshkov 		return -EINVAL;
12752b470e55SDmitry Baryshkov 
12762b470e55SDmitry Baryshkov 	vdsc_cfg->first_line_bpg_offset = rc_params->first_line_bpg_offset;
12772b470e55SDmitry Baryshkov 	vdsc_cfg->initial_xmit_delay = rc_params->initial_xmit_delay;
12782b470e55SDmitry Baryshkov 	vdsc_cfg->initial_offset = rc_params->initial_offset;
12792b470e55SDmitry Baryshkov 	vdsc_cfg->flatness_min_qp = rc_params->flatness_min_qp;
12802b470e55SDmitry Baryshkov 	vdsc_cfg->flatness_max_qp = rc_params->flatness_max_qp;
12812b470e55SDmitry Baryshkov 	vdsc_cfg->rc_quant_incr_limit0 = rc_params->rc_quant_incr_limit0;
12822b470e55SDmitry Baryshkov 	vdsc_cfg->rc_quant_incr_limit1 = rc_params->rc_quant_incr_limit1;
12832b470e55SDmitry Baryshkov 
12842b470e55SDmitry Baryshkov 	for (i = 0; i < DSC_NUM_BUF_RANGES; i++) {
12852b470e55SDmitry Baryshkov 		vdsc_cfg->rc_range_params[i].range_min_qp =
12862b470e55SDmitry Baryshkov 			rc_params->rc_range_params[i].range_min_qp;
12872b470e55SDmitry Baryshkov 		vdsc_cfg->rc_range_params[i].range_max_qp =
12882b470e55SDmitry Baryshkov 			rc_params->rc_range_params[i].range_max_qp;
12892b470e55SDmitry Baryshkov 		/*
12902b470e55SDmitry Baryshkov 		 * Range BPG Offset uses 2's complement and is only a 6 bits. So
12912b470e55SDmitry Baryshkov 		 * mask it to get only 6 bits.
12922b470e55SDmitry Baryshkov 		 */
12932b470e55SDmitry Baryshkov 		vdsc_cfg->rc_range_params[i].range_bpg_offset =
12942b470e55SDmitry Baryshkov 			rc_params->rc_range_params[i].range_bpg_offset &
12952b470e55SDmitry Baryshkov 			DSC_RANGE_BPG_OFFSET_MASK;
12962b470e55SDmitry Baryshkov 	}
12972b470e55SDmitry Baryshkov 
12982b470e55SDmitry Baryshkov 	return 0;
12992b470e55SDmitry Baryshkov }
13002b470e55SDmitry Baryshkov EXPORT_SYMBOL(drm_dsc_setup_rc_params);
13012b470e55SDmitry Baryshkov 
13022a64b147SThomas Zimmermann /**
13032a64b147SThomas Zimmermann  * drm_dsc_compute_rc_parameters() - Write rate control
13042a64b147SThomas Zimmermann  * parameters to the dsc configuration defined in
13052a64b147SThomas Zimmermann  * &struct drm_dsc_config in accordance with the DSC 1.2
13062a64b147SThomas Zimmermann  * specification. Some configuration fields must be present
13072a64b147SThomas Zimmermann  * beforehand.
13082a64b147SThomas Zimmermann  *
13092a64b147SThomas Zimmermann  * @vdsc_cfg:
13102a64b147SThomas Zimmermann  * DSC Configuration data partially filled by driver
13112a64b147SThomas Zimmermann  */
drm_dsc_compute_rc_parameters(struct drm_dsc_config * vdsc_cfg)13122a64b147SThomas Zimmermann int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg)
13132a64b147SThomas Zimmermann {
13142a64b147SThomas Zimmermann 	unsigned long groups_per_line = 0;
13152a64b147SThomas Zimmermann 	unsigned long groups_total = 0;
13162a64b147SThomas Zimmermann 	unsigned long num_extra_mux_bits = 0;
13172a64b147SThomas Zimmermann 	unsigned long slice_bits = 0;
13182a64b147SThomas Zimmermann 	unsigned long hrd_delay = 0;
13192a64b147SThomas Zimmermann 	unsigned long final_scale = 0;
13202a64b147SThomas Zimmermann 	unsigned long rbs_min = 0;
13212a64b147SThomas Zimmermann 
13222a64b147SThomas Zimmermann 	if (vdsc_cfg->native_420 || vdsc_cfg->native_422) {
13232a64b147SThomas Zimmermann 		/* Number of groups used to code each line of a slice */
13242a64b147SThomas Zimmermann 		groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width / 2,
13252a64b147SThomas Zimmermann 					       DSC_RC_PIXELS_PER_GROUP);
13262a64b147SThomas Zimmermann 
13272a64b147SThomas Zimmermann 		/* chunksize in Bytes */
13282a64b147SThomas Zimmermann 		vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width / 2 *
13292a64b147SThomas Zimmermann 							  vdsc_cfg->bits_per_pixel,
13302a64b147SThomas Zimmermann 							  (8 * 16));
13312a64b147SThomas Zimmermann 	} else {
13322a64b147SThomas Zimmermann 		/* Number of groups used to code each line of a slice */
13332a64b147SThomas Zimmermann 		groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width,
13342a64b147SThomas Zimmermann 					       DSC_RC_PIXELS_PER_GROUP);
13352a64b147SThomas Zimmermann 
13362a64b147SThomas Zimmermann 		/* chunksize in Bytes */
13372a64b147SThomas Zimmermann 		vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width *
13382a64b147SThomas Zimmermann 							  vdsc_cfg->bits_per_pixel,
13392a64b147SThomas Zimmermann 							  (8 * 16));
13402a64b147SThomas Zimmermann 	}
13412a64b147SThomas Zimmermann 
13422a64b147SThomas Zimmermann 	if (vdsc_cfg->convert_rgb)
13432a64b147SThomas Zimmermann 		num_extra_mux_bits = 3 * (vdsc_cfg->mux_word_size +
13442a64b147SThomas Zimmermann 					  (4 * vdsc_cfg->bits_per_component + 4)
13452a64b147SThomas Zimmermann 					  - 2);
13462a64b147SThomas Zimmermann 	else if (vdsc_cfg->native_422)
13472a64b147SThomas Zimmermann 		num_extra_mux_bits = 4 * vdsc_cfg->mux_word_size +
13482a64b147SThomas Zimmermann 			(4 * vdsc_cfg->bits_per_component + 4) +
13492a64b147SThomas Zimmermann 			3 * (4 * vdsc_cfg->bits_per_component) - 2;
13502a64b147SThomas Zimmermann 	else
13512a64b147SThomas Zimmermann 		num_extra_mux_bits = 3 * vdsc_cfg->mux_word_size +
13522a64b147SThomas Zimmermann 			(4 * vdsc_cfg->bits_per_component + 4) +
13532a64b147SThomas Zimmermann 			2 * (4 * vdsc_cfg->bits_per_component) - 2;
13542a64b147SThomas Zimmermann 	/* Number of bits in one Slice */
13552a64b147SThomas Zimmermann 	slice_bits = 8 * vdsc_cfg->slice_chunk_size * vdsc_cfg->slice_height;
13562a64b147SThomas Zimmermann 
13572a64b147SThomas Zimmermann 	while ((num_extra_mux_bits > 0) &&
13582a64b147SThomas Zimmermann 	       ((slice_bits - num_extra_mux_bits) % vdsc_cfg->mux_word_size))
13592a64b147SThomas Zimmermann 		num_extra_mux_bits--;
13602a64b147SThomas Zimmermann 
13612a64b147SThomas Zimmermann 	if (groups_per_line < vdsc_cfg->initial_scale_value - 8)
13622a64b147SThomas Zimmermann 		vdsc_cfg->initial_scale_value = groups_per_line + 8;
13632a64b147SThomas Zimmermann 
13642a64b147SThomas Zimmermann 	/* scale_decrement_interval calculation according to DSC spec 1.11 */
13652a64b147SThomas Zimmermann 	if (vdsc_cfg->initial_scale_value > 8)
13662a64b147SThomas Zimmermann 		vdsc_cfg->scale_decrement_interval = groups_per_line /
13672a64b147SThomas Zimmermann 			(vdsc_cfg->initial_scale_value - 8);
13682a64b147SThomas Zimmermann 	else
13692a64b147SThomas Zimmermann 		vdsc_cfg->scale_decrement_interval = DSC_SCALE_DECREMENT_INTERVAL_MAX;
13702a64b147SThomas Zimmermann 
13712a64b147SThomas Zimmermann 	vdsc_cfg->final_offset = vdsc_cfg->rc_model_size -
13722a64b147SThomas Zimmermann 		(vdsc_cfg->initial_xmit_delay *
13732a64b147SThomas Zimmermann 		 vdsc_cfg->bits_per_pixel + 8) / 16 + num_extra_mux_bits;
13742a64b147SThomas Zimmermann 
13752a64b147SThomas Zimmermann 	if (vdsc_cfg->final_offset >= vdsc_cfg->rc_model_size) {
13762a64b147SThomas Zimmermann 		DRM_DEBUG_KMS("FinalOfs < RcModelSze for this InitialXmitDelay\n");
13772a64b147SThomas Zimmermann 		return -ERANGE;
13782a64b147SThomas Zimmermann 	}
13792a64b147SThomas Zimmermann 
13802a64b147SThomas Zimmermann 	final_scale = (vdsc_cfg->rc_model_size * 8) /
13812a64b147SThomas Zimmermann 		(vdsc_cfg->rc_model_size - vdsc_cfg->final_offset);
13822a64b147SThomas Zimmermann 	if (vdsc_cfg->slice_height > 1)
13832a64b147SThomas Zimmermann 		/*
13842a64b147SThomas Zimmermann 		 * NflBpgOffset is 16 bit value with 11 fractional bits
13852a64b147SThomas Zimmermann 		 * hence we multiply by 2^11 for preserving the
13862a64b147SThomas Zimmermann 		 * fractional part
13872a64b147SThomas Zimmermann 		 */
13882a64b147SThomas Zimmermann 		vdsc_cfg->nfl_bpg_offset = DIV_ROUND_UP((vdsc_cfg->first_line_bpg_offset << 11),
13892a64b147SThomas Zimmermann 							(vdsc_cfg->slice_height - 1));
13902a64b147SThomas Zimmermann 	else
13912a64b147SThomas Zimmermann 		vdsc_cfg->nfl_bpg_offset = 0;
13922a64b147SThomas Zimmermann 
13932a64b147SThomas Zimmermann 	/* Number of groups used to code the entire slice */
13942a64b147SThomas Zimmermann 	groups_total = groups_per_line * vdsc_cfg->slice_height;
13952a64b147SThomas Zimmermann 
13962a64b147SThomas Zimmermann 	/* slice_bpg_offset is 16 bit value with 11 fractional bits */
13972a64b147SThomas Zimmermann 	vdsc_cfg->slice_bpg_offset = DIV_ROUND_UP(((vdsc_cfg->rc_model_size -
13982a64b147SThomas Zimmermann 						    vdsc_cfg->initial_offset +
13992a64b147SThomas Zimmermann 						    num_extra_mux_bits) << 11),
14002a64b147SThomas Zimmermann 						  groups_total);
14012a64b147SThomas Zimmermann 
14022a64b147SThomas Zimmermann 	if (final_scale > 9) {
14032a64b147SThomas Zimmermann 		/*
14042a64b147SThomas Zimmermann 		 * ScaleIncrementInterval =
14052a64b147SThomas Zimmermann 		 * finaloffset/((NflBpgOffset + SliceBpgOffset)*8(finalscale - 1.125))
14062a64b147SThomas Zimmermann 		 * as (NflBpgOffset + SliceBpgOffset) has 11 bit fractional value,
14072a64b147SThomas Zimmermann 		 * we need divide by 2^11 from pstDscCfg values
14082a64b147SThomas Zimmermann 		 */
14092a64b147SThomas Zimmermann 		vdsc_cfg->scale_increment_interval =
14102a64b147SThomas Zimmermann 				(vdsc_cfg->final_offset * (1 << 11)) /
14112a64b147SThomas Zimmermann 				((vdsc_cfg->nfl_bpg_offset +
14122a64b147SThomas Zimmermann 				vdsc_cfg->slice_bpg_offset) *
14132a64b147SThomas Zimmermann 				(final_scale - 9));
14142a64b147SThomas Zimmermann 	} else {
14152a64b147SThomas Zimmermann 		/*
14162a64b147SThomas Zimmermann 		 * If finalScaleValue is less than or equal to 9, a value of 0 should
14172a64b147SThomas Zimmermann 		 * be used to disable the scale increment at the end of the slice
14182a64b147SThomas Zimmermann 		 */
14192a64b147SThomas Zimmermann 		vdsc_cfg->scale_increment_interval = 0;
14202a64b147SThomas Zimmermann 	}
14212a64b147SThomas Zimmermann 
14222a64b147SThomas Zimmermann 	/*
14232a64b147SThomas Zimmermann 	 * DSC spec mentions that bits_per_pixel specifies the target
14242a64b147SThomas Zimmermann 	 * bits/pixel (bpp) rate that is used by the encoder,
14252a64b147SThomas Zimmermann 	 * in steps of 1/16 of a bit per pixel
14262a64b147SThomas Zimmermann 	 */
14272a64b147SThomas Zimmermann 	rbs_min = vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset +
14282a64b147SThomas Zimmermann 		DIV_ROUND_UP(vdsc_cfg->initial_xmit_delay *
14292a64b147SThomas Zimmermann 			     vdsc_cfg->bits_per_pixel, 16) +
14302a64b147SThomas Zimmermann 		groups_per_line * vdsc_cfg->first_line_bpg_offset;
14312a64b147SThomas Zimmermann 
14322a64b147SThomas Zimmermann 	hrd_delay = DIV_ROUND_UP((rbs_min * 16), vdsc_cfg->bits_per_pixel);
14332a64b147SThomas Zimmermann 	vdsc_cfg->rc_bits = (hrd_delay * vdsc_cfg->bits_per_pixel) / 16;
14342a64b147SThomas Zimmermann 	vdsc_cfg->initial_dec_delay = hrd_delay - vdsc_cfg->initial_xmit_delay;
14352a64b147SThomas Zimmermann 
14362a64b147SThomas Zimmermann 	return 0;
14372a64b147SThomas Zimmermann }
14382a64b147SThomas Zimmermann EXPORT_SYMBOL(drm_dsc_compute_rc_parameters);
14397df1ed6dSJessica Zhang 
14407df1ed6dSJessica Zhang /**
144168858328SJessica Zhang  * drm_dsc_get_bpp_int() - Get integer bits per pixel value for the given DRM DSC config
144268858328SJessica Zhang  * @vdsc_cfg: Pointer to DRM DSC config struct
144368858328SJessica Zhang  *
144468858328SJessica Zhang  * Return: Integer BPP value
144568858328SJessica Zhang  */
drm_dsc_get_bpp_int(const struct drm_dsc_config * vdsc_cfg)144668858328SJessica Zhang u32 drm_dsc_get_bpp_int(const struct drm_dsc_config *vdsc_cfg)
144768858328SJessica Zhang {
144868858328SJessica Zhang 	WARN_ON_ONCE(vdsc_cfg->bits_per_pixel & 0xf);
144968858328SJessica Zhang 	return vdsc_cfg->bits_per_pixel >> 4;
145068858328SJessica Zhang }
145168858328SJessica Zhang EXPORT_SYMBOL(drm_dsc_get_bpp_int);
145268858328SJessica Zhang 
145368858328SJessica Zhang /**
14547df1ed6dSJessica Zhang  * drm_dsc_initial_scale_value() - Calculate the initial scale value for the given DSC config
14557df1ed6dSJessica Zhang  * @dsc: Pointer to DRM DSC config struct
14567df1ed6dSJessica Zhang  *
14577df1ed6dSJessica Zhang  * Return: Calculated initial scale value
14587df1ed6dSJessica Zhang  */
drm_dsc_initial_scale_value(const struct drm_dsc_config * dsc)14597df1ed6dSJessica Zhang u8 drm_dsc_initial_scale_value(const struct drm_dsc_config *dsc)
14607df1ed6dSJessica Zhang {
14617df1ed6dSJessica Zhang 	return 8 * dsc->rc_model_size / (dsc->rc_model_size - dsc->initial_offset);
14627df1ed6dSJessica Zhang }
14637df1ed6dSJessica Zhang EXPORT_SYMBOL(drm_dsc_initial_scale_value);
14647df1ed6dSJessica Zhang 
14657df1ed6dSJessica Zhang /**
14667df1ed6dSJessica Zhang  * drm_dsc_flatness_det_thresh() - Calculate the flatness_det_thresh for the given DSC config
14677df1ed6dSJessica Zhang  * @dsc: Pointer to DRM DSC config struct
14687df1ed6dSJessica Zhang  *
14697df1ed6dSJessica Zhang  * Return: Calculated flatness det thresh value
14707df1ed6dSJessica Zhang  */
drm_dsc_flatness_det_thresh(const struct drm_dsc_config * dsc)14717df1ed6dSJessica Zhang u32 drm_dsc_flatness_det_thresh(const struct drm_dsc_config *dsc)
14727df1ed6dSJessica Zhang {
14737df1ed6dSJessica Zhang 	return 2 << (dsc->bits_per_component - 8);
14747df1ed6dSJessica Zhang }
14757df1ed6dSJessica Zhang EXPORT_SYMBOL(drm_dsc_flatness_det_thresh);
1476*74c3f5daSImre Deak 
drm_dsc_dump_config_main_params(struct drm_printer * p,int indent,const struct drm_dsc_config * cfg)1477*74c3f5daSImre Deak static void drm_dsc_dump_config_main_params(struct drm_printer *p, int indent,
1478*74c3f5daSImre Deak 					    const struct drm_dsc_config *cfg)
1479*74c3f5daSImre Deak {
1480*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1481*74c3f5daSImre Deak 			  "dsc-cfg: version: %d.%d, picture: w=%d, h=%d, slice: count=%d, w=%d, h=%d, size=%d\n",
1482*74c3f5daSImre Deak 			  cfg->dsc_version_major, cfg->dsc_version_minor,
1483*74c3f5daSImre Deak 			  cfg->pic_width, cfg->pic_height,
1484*74c3f5daSImre Deak 			  cfg->slice_count, cfg->slice_width, cfg->slice_height, cfg->slice_chunk_size);
1485*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1486*74c3f5daSImre Deak 			  "dsc-cfg: mode: block-pred=%s, vbr=%s, rgb=%s, simple-422=%s, native-422=%s, native-420=%s\n",
1487*74c3f5daSImre Deak 			  str_yes_no(cfg->block_pred_enable), str_yes_no(cfg->vbr_enable),
1488*74c3f5daSImre Deak 			  str_yes_no(cfg->convert_rgb),
1489*74c3f5daSImre Deak 			  str_yes_no(cfg->simple_422), str_yes_no(cfg->native_422), str_yes_no(cfg->native_420));
1490*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1491*74c3f5daSImre Deak 			  "dsc-cfg: color-depth: uncompressed-bpc=%d, compressed-bpp=" FXP_Q4_FMT " line-buf-bpp=%d\n",
1492*74c3f5daSImre Deak 			  cfg->bits_per_component, FXP_Q4_ARGS(cfg->bits_per_pixel), cfg->line_buf_depth);
1493*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1494*74c3f5daSImre Deak 			  "dsc-cfg: rc-model: size=%d, bits=%d, mux-word-size: %d, initial-delays: xmit=%d, dec=%d\n",
1495*74c3f5daSImre Deak 			  cfg->rc_model_size, cfg->rc_bits, cfg->mux_word_size,
1496*74c3f5daSImre Deak 			  cfg->initial_xmit_delay, cfg->initial_dec_delay);
1497*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1498*74c3f5daSImre Deak 			  "dsc-cfg: offsets: initial=%d, final=%d, slice-bpg=%d\n",
1499*74c3f5daSImre Deak 			  cfg->initial_offset, cfg->final_offset, cfg->slice_bpg_offset);
1500*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1501*74c3f5daSImre Deak 			  "dsc-cfg: line-bpg-offsets: first=%d, non-first=%d, second=%d, non-second=%d, second-adj=%d\n",
1502*74c3f5daSImre Deak 			  cfg->first_line_bpg_offset, cfg->nfl_bpg_offset,
1503*74c3f5daSImre Deak 			  cfg->second_line_bpg_offset, cfg->nsl_bpg_offset, cfg->second_line_offset_adj);
1504*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1505*74c3f5daSImre Deak 			  "dsc-cfg: rc-tgt-offsets: low=%d, high=%d, rc-edge-factor: %d, rc-quant-incr-limits: [0]=%d, [1]=%d\n",
1506*74c3f5daSImre Deak 			  cfg->rc_tgt_offset_low, cfg->rc_tgt_offset_high,
1507*74c3f5daSImre Deak 			  cfg->rc_edge_factor, cfg->rc_quant_incr_limit0, cfg->rc_quant_incr_limit1);
1508*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1509*74c3f5daSImre Deak 			  "dsc-cfg: initial-scale: %d, scale-intervals: increment=%d, decrement=%d\n",
1510*74c3f5daSImre Deak 			  cfg->initial_scale_value, cfg->scale_increment_interval, cfg->scale_decrement_interval);
1511*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1512*74c3f5daSImre Deak 			  "dsc-cfg: flatness: min-qp=%d, max-qp=%d\n",
1513*74c3f5daSImre Deak 			  cfg->flatness_min_qp, cfg->flatness_max_qp);
1514*74c3f5daSImre Deak }
1515*74c3f5daSImre Deak 
drm_dsc_dump_config_rc_params(struct drm_printer * p,int indent,const struct drm_dsc_config * cfg)1516*74c3f5daSImre Deak static void drm_dsc_dump_config_rc_params(struct drm_printer *p, int indent,
1517*74c3f5daSImre Deak 					  const struct drm_dsc_config *cfg)
1518*74c3f5daSImre Deak {
1519*74c3f5daSImre Deak 	const u16 *bt = cfg->rc_buf_thresh;
1520*74c3f5daSImre Deak 	const struct drm_dsc_rc_range_parameters *rp = cfg->rc_range_params;
1521*74c3f5daSImre Deak 
1522*74c3f5daSImre Deak 	BUILD_BUG_ON(ARRAY_SIZE(cfg->rc_buf_thresh) != 14);
1523*74c3f5daSImre Deak 	BUILD_BUG_ON(ARRAY_SIZE(cfg->rc_range_params) != 15);
1524*74c3f5daSImre Deak 
1525*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1526*74c3f5daSImre Deak 			  "dsc-cfg: rc-level:         0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14\n");
1527*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1528*74c3f5daSImre Deak 			  "dsc-cfg: rc-buf-thresh:  %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n",
1529*74c3f5daSImre Deak 			  bt[0], bt[1], bt[2],  bt[3],  bt[4],  bt[5], bt[6], bt[7],
1530*74c3f5daSImre Deak 			  bt[8], bt[9], bt[10], bt[11], bt[12], bt[13]);
1531*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1532*74c3f5daSImre Deak 			  "dsc-cfg: rc-min-qp:      %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n",
1533*74c3f5daSImre Deak 			  rp[0].range_min_qp,  rp[1].range_min_qp,  rp[2].range_min_qp,  rp[3].range_min_qp,
1534*74c3f5daSImre Deak 			  rp[4].range_min_qp,  rp[5].range_min_qp,  rp[6].range_min_qp,  rp[7].range_min_qp,
1535*74c3f5daSImre Deak 			  rp[8].range_min_qp,  rp[9].range_min_qp,  rp[10].range_min_qp, rp[11].range_min_qp,
1536*74c3f5daSImre Deak 			  rp[12].range_min_qp, rp[13].range_min_qp, rp[14].range_min_qp);
1537*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1538*74c3f5daSImre Deak 			  "dsc-cfg: rc-max-qp:      %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n",
1539*74c3f5daSImre Deak 			  rp[0].range_max_qp,  rp[1].range_max_qp,  rp[2].range_max_qp,  rp[3].range_max_qp,
1540*74c3f5daSImre Deak 			  rp[4].range_max_qp,  rp[5].range_max_qp,  rp[6].range_max_qp,  rp[7].range_max_qp,
1541*74c3f5daSImre Deak 			  rp[8].range_max_qp,  rp[9].range_max_qp,  rp[10].range_max_qp, rp[11].range_max_qp,
1542*74c3f5daSImre Deak 			  rp[12].range_max_qp, rp[13].range_max_qp, rp[14].range_max_qp);
1543*74c3f5daSImre Deak 	drm_printf_indent(p, indent,
1544*74c3f5daSImre Deak 			  "dsc-cfg: rc-bpg-offset:  %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n",
1545*74c3f5daSImre Deak 			  rp[0].range_bpg_offset,  rp[1].range_bpg_offset,  rp[2].range_bpg_offset,  rp[3].range_bpg_offset,
1546*74c3f5daSImre Deak 			  rp[4].range_bpg_offset,  rp[5].range_bpg_offset,  rp[6].range_bpg_offset,  rp[7].range_bpg_offset,
1547*74c3f5daSImre Deak 			  rp[8].range_bpg_offset,  rp[9].range_bpg_offset,  rp[10].range_bpg_offset, rp[11].range_bpg_offset,
1548*74c3f5daSImre Deak 			  rp[12].range_bpg_offset, rp[13].range_bpg_offset, rp[14].range_bpg_offset);
1549*74c3f5daSImre Deak }
1550*74c3f5daSImre Deak 
1551*74c3f5daSImre Deak /**
1552*74c3f5daSImre Deak  * drm_dsc_dump_config - Dump the provided DSC configuration
1553*74c3f5daSImre Deak  * @p: The printer used for output
1554*74c3f5daSImre Deak  * @indent: Tab indentation level (max 5)
1555*74c3f5daSImre Deak  * @cfg: DSC configuration to print
1556*74c3f5daSImre Deak  *
1557*74c3f5daSImre Deak  * Print the provided DSC configuration in @cfg.
1558*74c3f5daSImre Deak  */
drm_dsc_dump_config(struct drm_printer * p,int indent,const struct drm_dsc_config * cfg)1559*74c3f5daSImre Deak void drm_dsc_dump_config(struct drm_printer *p, int indent,
1560*74c3f5daSImre Deak 			 const struct drm_dsc_config *cfg)
1561*74c3f5daSImre Deak {
1562*74c3f5daSImre Deak 	drm_dsc_dump_config_main_params(p, indent, cfg);
1563*74c3f5daSImre Deak 	drm_dsc_dump_config_rc_params(p, indent, cfg);
1564*74c3f5daSImre Deak }
1565*74c3f5daSImre Deak EXPORT_SYMBOL(drm_dsc_dump_config);
1566