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> 172a64b147SThomas Zimmermann #include <drm/drm_print.h> 182a64b147SThomas Zimmermann 192a64b147SThomas Zimmermann /** 202a64b147SThomas Zimmermann * DOC: dsc helpers 212a64b147SThomas Zimmermann * 222a64b147SThomas Zimmermann * VESA specification for DP 1.4 adds a new feature called Display Stream 232a64b147SThomas Zimmermann * Compression (DSC) used to compress the pixel bits before sending it on 242a64b147SThomas Zimmermann * DP/eDP/MIPI DSI interface. DSC is required to be enabled so that the existing 252a64b147SThomas Zimmermann * display interfaces can support high resolutions at higher frames rates uisng 262a64b147SThomas Zimmermann * the maximum available link capacity of these interfaces. 272a64b147SThomas Zimmermann * 282a64b147SThomas Zimmermann * These functions contain some common logic and helpers to deal with VESA 292a64b147SThomas Zimmermann * Display Stream Compression standard required for DSC on Display Port/eDP or 302a64b147SThomas Zimmermann * MIPI display interfaces. 312a64b147SThomas Zimmermann */ 322a64b147SThomas Zimmermann 332a64b147SThomas Zimmermann /** 342a64b147SThomas Zimmermann * drm_dsc_dp_pps_header_init() - Initializes the PPS Header 352a64b147SThomas Zimmermann * for DisplayPort as per the DP 1.4 spec. 362a64b147SThomas Zimmermann * @pps_header: Secondary data packet header for DSC Picture 372a64b147SThomas Zimmermann * Parameter Set as defined in &struct dp_sdp_header 382a64b147SThomas Zimmermann * 392a64b147SThomas Zimmermann * DP 1.4 spec defines the secondary data packet for sending the 402a64b147SThomas Zimmermann * picture parameter infoframes from the source to the sink. 412a64b147SThomas Zimmermann * This function populates the SDP header defined in 422a64b147SThomas Zimmermann * &struct dp_sdp_header. 432a64b147SThomas Zimmermann */ 442a64b147SThomas Zimmermann void drm_dsc_dp_pps_header_init(struct dp_sdp_header *pps_header) 452a64b147SThomas Zimmermann { 462a64b147SThomas Zimmermann memset(pps_header, 0, sizeof(*pps_header)); 472a64b147SThomas Zimmermann 482a64b147SThomas Zimmermann pps_header->HB1 = DP_SDP_PPS; 492a64b147SThomas Zimmermann pps_header->HB2 = DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1; 502a64b147SThomas Zimmermann } 512a64b147SThomas Zimmermann EXPORT_SYMBOL(drm_dsc_dp_pps_header_init); 522a64b147SThomas Zimmermann 532a64b147SThomas Zimmermann /** 542a64b147SThomas Zimmermann * drm_dsc_dp_rc_buffer_size - get rc buffer size in bytes 552a64b147SThomas Zimmermann * @rc_buffer_block_size: block size code, according to DPCD offset 62h 562a64b147SThomas Zimmermann * @rc_buffer_size: number of blocks - 1, according to DPCD offset 63h 572a64b147SThomas Zimmermann * 582a64b147SThomas Zimmermann * return: 592a64b147SThomas Zimmermann * buffer size in bytes, or 0 on invalid input 602a64b147SThomas Zimmermann */ 612a64b147SThomas Zimmermann int drm_dsc_dp_rc_buffer_size(u8 rc_buffer_block_size, u8 rc_buffer_size) 622a64b147SThomas Zimmermann { 632a64b147SThomas Zimmermann int size = 1024 * (rc_buffer_size + 1); 642a64b147SThomas Zimmermann 652a64b147SThomas Zimmermann switch (rc_buffer_block_size) { 662a64b147SThomas Zimmermann case DP_DSC_RC_BUF_BLK_SIZE_1: 672a64b147SThomas Zimmermann return 1 * size; 682a64b147SThomas Zimmermann case DP_DSC_RC_BUF_BLK_SIZE_4: 692a64b147SThomas Zimmermann return 4 * size; 702a64b147SThomas Zimmermann case DP_DSC_RC_BUF_BLK_SIZE_16: 712a64b147SThomas Zimmermann return 16 * size; 722a64b147SThomas Zimmermann case DP_DSC_RC_BUF_BLK_SIZE_64: 732a64b147SThomas Zimmermann return 64 * size; 742a64b147SThomas Zimmermann default: 752a64b147SThomas Zimmermann return 0; 762a64b147SThomas Zimmermann } 772a64b147SThomas Zimmermann } 782a64b147SThomas Zimmermann EXPORT_SYMBOL(drm_dsc_dp_rc_buffer_size); 792a64b147SThomas Zimmermann 802a64b147SThomas Zimmermann /** 812a64b147SThomas Zimmermann * drm_dsc_pps_payload_pack() - Populates the DSC PPS 822a64b147SThomas Zimmermann * 832a64b147SThomas Zimmermann * @pps_payload: 842a64b147SThomas Zimmermann * Bitwise struct for DSC Picture Parameter Set. This is defined 852a64b147SThomas Zimmermann * by &struct drm_dsc_picture_parameter_set 862a64b147SThomas Zimmermann * @dsc_cfg: 872a64b147SThomas Zimmermann * DSC Configuration data filled by driver as defined by 882a64b147SThomas Zimmermann * &struct drm_dsc_config 892a64b147SThomas Zimmermann * 902a64b147SThomas Zimmermann * DSC source device sends a picture parameter set (PPS) containing the 912a64b147SThomas Zimmermann * information required by the sink to decode the compressed frame. Driver 922a64b147SThomas Zimmermann * populates the DSC PPS struct using the DSC configuration parameters in 932a64b147SThomas Zimmermann * the order expected by the DSC Display Sink device. For the DSC, the sink 942a64b147SThomas Zimmermann * device expects the PPS payload in big endian format for fields 952a64b147SThomas Zimmermann * that span more than 1 byte. 962a64b147SThomas Zimmermann */ 972a64b147SThomas Zimmermann void drm_dsc_pps_payload_pack(struct drm_dsc_picture_parameter_set *pps_payload, 982a64b147SThomas Zimmermann const struct drm_dsc_config *dsc_cfg) 992a64b147SThomas Zimmermann { 1002a64b147SThomas Zimmermann int i; 1012a64b147SThomas Zimmermann 1022a64b147SThomas Zimmermann /* Protect against someone accidentally changing struct size */ 1032a64b147SThomas Zimmermann BUILD_BUG_ON(sizeof(*pps_payload) != 1042a64b147SThomas Zimmermann DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1 + 1); 1052a64b147SThomas Zimmermann 1062a64b147SThomas Zimmermann memset(pps_payload, 0, sizeof(*pps_payload)); 1072a64b147SThomas Zimmermann 1082a64b147SThomas Zimmermann /* PPS 0 */ 1092a64b147SThomas Zimmermann pps_payload->dsc_version = 1102a64b147SThomas Zimmermann dsc_cfg->dsc_version_minor | 1112a64b147SThomas Zimmermann dsc_cfg->dsc_version_major << DSC_PPS_VERSION_MAJOR_SHIFT; 1122a64b147SThomas Zimmermann 1132a64b147SThomas Zimmermann /* PPS 1, 2 is 0 */ 1142a64b147SThomas Zimmermann 1152a64b147SThomas Zimmermann /* PPS 3 */ 1162a64b147SThomas Zimmermann pps_payload->pps_3 = 1172a64b147SThomas Zimmermann dsc_cfg->line_buf_depth | 1182a64b147SThomas Zimmermann dsc_cfg->bits_per_component << DSC_PPS_BPC_SHIFT; 1192a64b147SThomas Zimmermann 1202a64b147SThomas Zimmermann /* PPS 4 */ 1212a64b147SThomas Zimmermann pps_payload->pps_4 = 1222a64b147SThomas Zimmermann ((dsc_cfg->bits_per_pixel & DSC_PPS_BPP_HIGH_MASK) >> 1232a64b147SThomas Zimmermann DSC_PPS_MSB_SHIFT) | 1242a64b147SThomas Zimmermann dsc_cfg->vbr_enable << DSC_PPS_VBR_EN_SHIFT | 1252a64b147SThomas Zimmermann dsc_cfg->simple_422 << DSC_PPS_SIMPLE422_SHIFT | 1262a64b147SThomas Zimmermann dsc_cfg->convert_rgb << DSC_PPS_CONVERT_RGB_SHIFT | 1272a64b147SThomas Zimmermann dsc_cfg->block_pred_enable << DSC_PPS_BLOCK_PRED_EN_SHIFT; 1282a64b147SThomas Zimmermann 1292a64b147SThomas Zimmermann /* PPS 5 */ 1302a64b147SThomas Zimmermann pps_payload->bits_per_pixel_low = 1312a64b147SThomas Zimmermann (dsc_cfg->bits_per_pixel & DSC_PPS_LSB_MASK); 1322a64b147SThomas Zimmermann 1332a64b147SThomas Zimmermann /* 1342a64b147SThomas Zimmermann * The DSC panel expects the PPS packet to have big endian format 1352a64b147SThomas Zimmermann * for data spanning 2 bytes. Use a macro cpu_to_be16() to convert 1362a64b147SThomas Zimmermann * to big endian format. If format is little endian, it will swap 1372a64b147SThomas Zimmermann * bytes to convert to Big endian else keep it unchanged. 1382a64b147SThomas Zimmermann */ 1392a64b147SThomas Zimmermann 1402a64b147SThomas Zimmermann /* PPS 6, 7 */ 1412a64b147SThomas Zimmermann pps_payload->pic_height = cpu_to_be16(dsc_cfg->pic_height); 1422a64b147SThomas Zimmermann 1432a64b147SThomas Zimmermann /* PPS 8, 9 */ 1442a64b147SThomas Zimmermann pps_payload->pic_width = cpu_to_be16(dsc_cfg->pic_width); 1452a64b147SThomas Zimmermann 1462a64b147SThomas Zimmermann /* PPS 10, 11 */ 1472a64b147SThomas Zimmermann pps_payload->slice_height = cpu_to_be16(dsc_cfg->slice_height); 1482a64b147SThomas Zimmermann 1492a64b147SThomas Zimmermann /* PPS 12, 13 */ 1502a64b147SThomas Zimmermann pps_payload->slice_width = cpu_to_be16(dsc_cfg->slice_width); 1512a64b147SThomas Zimmermann 1522a64b147SThomas Zimmermann /* PPS 14, 15 */ 1532a64b147SThomas Zimmermann pps_payload->chunk_size = cpu_to_be16(dsc_cfg->slice_chunk_size); 1542a64b147SThomas Zimmermann 1552a64b147SThomas Zimmermann /* PPS 16 */ 1562a64b147SThomas Zimmermann pps_payload->initial_xmit_delay_high = 1572a64b147SThomas Zimmermann ((dsc_cfg->initial_xmit_delay & 1582a64b147SThomas Zimmermann DSC_PPS_INIT_XMIT_DELAY_HIGH_MASK) >> 1592a64b147SThomas Zimmermann DSC_PPS_MSB_SHIFT); 1602a64b147SThomas Zimmermann 1612a64b147SThomas Zimmermann /* PPS 17 */ 1622a64b147SThomas Zimmermann pps_payload->initial_xmit_delay_low = 1632a64b147SThomas Zimmermann (dsc_cfg->initial_xmit_delay & DSC_PPS_LSB_MASK); 1642a64b147SThomas Zimmermann 1652a64b147SThomas Zimmermann /* PPS 18, 19 */ 1662a64b147SThomas Zimmermann pps_payload->initial_dec_delay = 1672a64b147SThomas Zimmermann cpu_to_be16(dsc_cfg->initial_dec_delay); 1682a64b147SThomas Zimmermann 1692a64b147SThomas Zimmermann /* PPS 20 is 0 */ 1702a64b147SThomas Zimmermann 1712a64b147SThomas Zimmermann /* PPS 21 */ 1722a64b147SThomas Zimmermann pps_payload->initial_scale_value = 1732a64b147SThomas Zimmermann dsc_cfg->initial_scale_value; 1742a64b147SThomas Zimmermann 1752a64b147SThomas Zimmermann /* PPS 22, 23 */ 1762a64b147SThomas Zimmermann pps_payload->scale_increment_interval = 1772a64b147SThomas Zimmermann cpu_to_be16(dsc_cfg->scale_increment_interval); 1782a64b147SThomas Zimmermann 1792a64b147SThomas Zimmermann /* PPS 24 */ 1802a64b147SThomas Zimmermann pps_payload->scale_decrement_interval_high = 1812a64b147SThomas Zimmermann ((dsc_cfg->scale_decrement_interval & 1822a64b147SThomas Zimmermann DSC_PPS_SCALE_DEC_INT_HIGH_MASK) >> 1832a64b147SThomas Zimmermann DSC_PPS_MSB_SHIFT); 1842a64b147SThomas Zimmermann 1852a64b147SThomas Zimmermann /* PPS 25 */ 1862a64b147SThomas Zimmermann pps_payload->scale_decrement_interval_low = 1872a64b147SThomas Zimmermann (dsc_cfg->scale_decrement_interval & DSC_PPS_LSB_MASK); 1882a64b147SThomas Zimmermann 1892a64b147SThomas Zimmermann /* PPS 26[7:0], PPS 27[7:5] RESERVED */ 1902a64b147SThomas Zimmermann 1912a64b147SThomas Zimmermann /* PPS 27 */ 1922a64b147SThomas Zimmermann pps_payload->first_line_bpg_offset = 1932a64b147SThomas Zimmermann dsc_cfg->first_line_bpg_offset; 1942a64b147SThomas Zimmermann 1952a64b147SThomas Zimmermann /* PPS 28, 29 */ 1962a64b147SThomas Zimmermann pps_payload->nfl_bpg_offset = 1972a64b147SThomas Zimmermann cpu_to_be16(dsc_cfg->nfl_bpg_offset); 1982a64b147SThomas Zimmermann 1992a64b147SThomas Zimmermann /* PPS 30, 31 */ 2002a64b147SThomas Zimmermann pps_payload->slice_bpg_offset = 2012a64b147SThomas Zimmermann cpu_to_be16(dsc_cfg->slice_bpg_offset); 2022a64b147SThomas Zimmermann 2032a64b147SThomas Zimmermann /* PPS 32, 33 */ 2042a64b147SThomas Zimmermann pps_payload->initial_offset = 2052a64b147SThomas Zimmermann cpu_to_be16(dsc_cfg->initial_offset); 2062a64b147SThomas Zimmermann 2072a64b147SThomas Zimmermann /* PPS 34, 35 */ 2082a64b147SThomas Zimmermann pps_payload->final_offset = cpu_to_be16(dsc_cfg->final_offset); 2092a64b147SThomas Zimmermann 2102a64b147SThomas Zimmermann /* PPS 36 */ 2112a64b147SThomas Zimmermann pps_payload->flatness_min_qp = dsc_cfg->flatness_min_qp; 2122a64b147SThomas Zimmermann 2132a64b147SThomas Zimmermann /* PPS 37 */ 2142a64b147SThomas Zimmermann pps_payload->flatness_max_qp = dsc_cfg->flatness_max_qp; 2152a64b147SThomas Zimmermann 2162a64b147SThomas Zimmermann /* PPS 38, 39 */ 2172a64b147SThomas Zimmermann pps_payload->rc_model_size = cpu_to_be16(dsc_cfg->rc_model_size); 2182a64b147SThomas Zimmermann 2192a64b147SThomas Zimmermann /* PPS 40 */ 2202a64b147SThomas Zimmermann pps_payload->rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST; 2212a64b147SThomas Zimmermann 2222a64b147SThomas Zimmermann /* PPS 41 */ 2232a64b147SThomas Zimmermann pps_payload->rc_quant_incr_limit0 = 2242a64b147SThomas Zimmermann dsc_cfg->rc_quant_incr_limit0; 2252a64b147SThomas Zimmermann 2262a64b147SThomas Zimmermann /* PPS 42 */ 2272a64b147SThomas Zimmermann pps_payload->rc_quant_incr_limit1 = 2282a64b147SThomas Zimmermann dsc_cfg->rc_quant_incr_limit1; 2292a64b147SThomas Zimmermann 2302a64b147SThomas Zimmermann /* PPS 43 */ 2312a64b147SThomas Zimmermann pps_payload->rc_tgt_offset = DSC_RC_TGT_OFFSET_LO_CONST | 2322a64b147SThomas Zimmermann DSC_RC_TGT_OFFSET_HI_CONST << DSC_PPS_RC_TGT_OFFSET_HI_SHIFT; 2332a64b147SThomas Zimmermann 2342a64b147SThomas Zimmermann /* PPS 44 - 57 */ 2352a64b147SThomas Zimmermann for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++) 2362a64b147SThomas Zimmermann pps_payload->rc_buf_thresh[i] = 2372a64b147SThomas Zimmermann dsc_cfg->rc_buf_thresh[i]; 2382a64b147SThomas Zimmermann 2392a64b147SThomas Zimmermann /* PPS 58 - 87 */ 2402a64b147SThomas Zimmermann /* 2412a64b147SThomas Zimmermann * For DSC sink programming the RC Range parameter fields 2422a64b147SThomas Zimmermann * are as follows: Min_qp[15:11], max_qp[10:6], offset[5:0] 2432a64b147SThomas Zimmermann */ 2442a64b147SThomas Zimmermann for (i = 0; i < DSC_NUM_BUF_RANGES; i++) { 2452a64b147SThomas Zimmermann pps_payload->rc_range_parameters[i] = 2462a64b147SThomas Zimmermann cpu_to_be16((dsc_cfg->rc_range_params[i].range_min_qp << 2472a64b147SThomas Zimmermann DSC_PPS_RC_RANGE_MINQP_SHIFT) | 2482a64b147SThomas Zimmermann (dsc_cfg->rc_range_params[i].range_max_qp << 2492a64b147SThomas Zimmermann DSC_PPS_RC_RANGE_MAXQP_SHIFT) | 2502a64b147SThomas Zimmermann (dsc_cfg->rc_range_params[i].range_bpg_offset)); 2512a64b147SThomas Zimmermann } 2522a64b147SThomas Zimmermann 2532a64b147SThomas Zimmermann /* PPS 88 */ 2542a64b147SThomas Zimmermann pps_payload->native_422_420 = dsc_cfg->native_422 | 2552a64b147SThomas Zimmermann dsc_cfg->native_420 << DSC_PPS_NATIVE_420_SHIFT; 2562a64b147SThomas Zimmermann 2572a64b147SThomas Zimmermann /* PPS 89 */ 2582a64b147SThomas Zimmermann pps_payload->second_line_bpg_offset = 2592a64b147SThomas Zimmermann dsc_cfg->second_line_bpg_offset; 2602a64b147SThomas Zimmermann 2612a64b147SThomas Zimmermann /* PPS 90, 91 */ 2622a64b147SThomas Zimmermann pps_payload->nsl_bpg_offset = 2632a64b147SThomas Zimmermann cpu_to_be16(dsc_cfg->nsl_bpg_offset); 2642a64b147SThomas Zimmermann 2652a64b147SThomas Zimmermann /* PPS 92, 93 */ 2662a64b147SThomas Zimmermann pps_payload->second_line_offset_adj = 2672a64b147SThomas Zimmermann cpu_to_be16(dsc_cfg->second_line_offset_adj); 2682a64b147SThomas Zimmermann 2692a64b147SThomas Zimmermann /* PPS 94 - 127 are O */ 2702a64b147SThomas Zimmermann } 2712a64b147SThomas Zimmermann EXPORT_SYMBOL(drm_dsc_pps_payload_pack); 2722a64b147SThomas Zimmermann 27316921921SDmitry Baryshkov /* From DSC_v1.11 spec, rc_parameter_Set syntax element typically constant */ 27416921921SDmitry Baryshkov static const u16 drm_dsc_rc_buf_thresh[] = { 27516921921SDmitry Baryshkov 896, 1792, 2688, 3584, 4480, 5376, 6272, 6720, 7168, 7616, 27616921921SDmitry Baryshkov 7744, 7872, 8000, 8064 27716921921SDmitry Baryshkov }; 27816921921SDmitry Baryshkov 27916921921SDmitry Baryshkov /** 28016921921SDmitry Baryshkov * drm_dsc_set_rc_buf_thresh() - Set thresholds for the RC model 28116921921SDmitry Baryshkov * in accordance with the DSC 1.2 specification. 28216921921SDmitry Baryshkov * 28316921921SDmitry Baryshkov * @vdsc_cfg: DSC Configuration data partially filled by driver 28416921921SDmitry Baryshkov */ 28516921921SDmitry Baryshkov void drm_dsc_set_rc_buf_thresh(struct drm_dsc_config *vdsc_cfg) 28616921921SDmitry Baryshkov { 28716921921SDmitry Baryshkov int i; 28816921921SDmitry Baryshkov 28916921921SDmitry Baryshkov BUILD_BUG_ON(ARRAY_SIZE(drm_dsc_rc_buf_thresh) != 29016921921SDmitry Baryshkov DSC_NUM_BUF_RANGES - 1); 29116921921SDmitry Baryshkov BUILD_BUG_ON(ARRAY_SIZE(drm_dsc_rc_buf_thresh) != 29216921921SDmitry Baryshkov ARRAY_SIZE(vdsc_cfg->rc_buf_thresh)); 29316921921SDmitry Baryshkov 29416921921SDmitry Baryshkov for (i = 0; i < ARRAY_SIZE(drm_dsc_rc_buf_thresh); i++) 29516921921SDmitry Baryshkov vdsc_cfg->rc_buf_thresh[i] = drm_dsc_rc_buf_thresh[i] >> 6; 29616921921SDmitry Baryshkov 29716921921SDmitry Baryshkov /* 29816921921SDmitry Baryshkov * For 6bpp, RC Buffer threshold 12 and 13 need a different value 29916921921SDmitry Baryshkov * as per C Model 30016921921SDmitry Baryshkov */ 30116921921SDmitry Baryshkov if (vdsc_cfg->bits_per_pixel == 6 << 4) { 30216921921SDmitry Baryshkov vdsc_cfg->rc_buf_thresh[12] = 7936 >> 6; 30316921921SDmitry Baryshkov vdsc_cfg->rc_buf_thresh[13] = 8000 >> 6; 30416921921SDmitry Baryshkov } 30516921921SDmitry Baryshkov } 30616921921SDmitry Baryshkov EXPORT_SYMBOL(drm_dsc_set_rc_buf_thresh); 30716921921SDmitry Baryshkov 3082b470e55SDmitry Baryshkov struct rc_parameters { 3092b470e55SDmitry Baryshkov u16 initial_xmit_delay; 3102b470e55SDmitry Baryshkov u8 first_line_bpg_offset; 3112b470e55SDmitry Baryshkov u16 initial_offset; 3122b470e55SDmitry Baryshkov u8 flatness_min_qp; 3132b470e55SDmitry Baryshkov u8 flatness_max_qp; 3142b470e55SDmitry Baryshkov u8 rc_quant_incr_limit0; 3152b470e55SDmitry Baryshkov u8 rc_quant_incr_limit1; 3162b470e55SDmitry Baryshkov struct drm_dsc_rc_range_parameters rc_range_params[DSC_NUM_BUF_RANGES]; 3172b470e55SDmitry Baryshkov }; 3182b470e55SDmitry Baryshkov 31974fe874cSDmitry Baryshkov struct rc_parameters_data { 32074fe874cSDmitry Baryshkov u8 bpp; 32174fe874cSDmitry Baryshkov u8 bpc; 32274fe874cSDmitry Baryshkov struct rc_parameters params; 32374fe874cSDmitry Baryshkov }; 32474fe874cSDmitry Baryshkov 32574fe874cSDmitry Baryshkov #define DSC_BPP(bpp) ((bpp) << 4) 32674fe874cSDmitry Baryshkov 3272b470e55SDmitry Baryshkov /* 328e3290f88SDmitry Baryshkov * Rate Control Related Parameter Recommended Values from DSC_v1.1 spec prior 329e3290f88SDmitry Baryshkov * to DSC 1.1 fractional bpp underflow SCR (DSC_v1.1_E1.pdf) 330e3290f88SDmitry Baryshkov * 331e3290f88SDmitry Baryshkov * Cross-checked against C Model releases: DSC_model_20161212 and 20210623 3322b470e55SDmitry Baryshkov */ 333e3290f88SDmitry Baryshkov static const struct rc_parameters_data rc_parameters_pre_scr[] = { 334e3290f88SDmitry Baryshkov { 3353b292112SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 8, 3363b292112SDmitry Baryshkov { 683, 15, 6144, 3, 13, 11, 11, { 3373b292112SDmitry Baryshkov { 0, 2, 0 }, { 1, 4, -2 }, { 3, 6, -2 }, { 4, 6, -4 }, 3383b292112SDmitry Baryshkov { 5, 7, -6 }, { 5, 7, -6 }, { 6, 7, -6 }, { 6, 8, -8 }, 3393b292112SDmitry Baryshkov { 7, 9, -8 }, { 8, 10, -10 }, { 9, 11, -10 }, { 10, 12, -12 }, 3403b292112SDmitry Baryshkov { 10, 13, -12 }, { 12, 14, -12 }, { 15, 15, -12 } 3413b292112SDmitry Baryshkov } 3423b292112SDmitry Baryshkov } 3433b292112SDmitry Baryshkov }, 3443b292112SDmitry Baryshkov { 345e3290f88SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 8, 346e3290f88SDmitry Baryshkov { 512, 12, 6144, 3, 12, 11, 11, { 347e3290f88SDmitry Baryshkov { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 348e3290f88SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 349e3290f88SDmitry Baryshkov { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 }, { 5, 12, -12 }, 350e3290f88SDmitry Baryshkov { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 } 351e3290f88SDmitry Baryshkov } 352e3290f88SDmitry Baryshkov } 353e3290f88SDmitry Baryshkov }, 354e3290f88SDmitry Baryshkov { 355e3290f88SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 10, 356e3290f88SDmitry Baryshkov { 512, 12, 6144, 7, 16, 15, 15, { 357e3290f88SDmitry Baryshkov /* 358e3290f88SDmitry Baryshkov * DSC model/pre-SCR-cfg has 8 for range_max_qp[0], however 359e3290f88SDmitry Baryshkov * VESA DSC 1.1 Table E-5 sets it to 4. 360e3290f88SDmitry Baryshkov */ 361e3290f88SDmitry Baryshkov { 0, 4, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 }, 362e3290f88SDmitry Baryshkov { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 363e3290f88SDmitry Baryshkov { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 }, 364e3290f88SDmitry Baryshkov { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 } 365e3290f88SDmitry Baryshkov } 366e3290f88SDmitry Baryshkov } 367e3290f88SDmitry Baryshkov }, 368e3290f88SDmitry Baryshkov { 369e3290f88SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 12, 370e3290f88SDmitry Baryshkov { 512, 12, 6144, 11, 20, 19, 19, { 371e3290f88SDmitry Baryshkov { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 }, 372e3290f88SDmitry Baryshkov { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 373e3290f88SDmitry Baryshkov { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 }, 374e3290f88SDmitry Baryshkov { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 }, 375e3290f88SDmitry Baryshkov { 21, 23, -12 } 376e3290f88SDmitry Baryshkov } 377e3290f88SDmitry Baryshkov } 378e3290f88SDmitry Baryshkov }, 379e3290f88SDmitry Baryshkov { 3803b292112SDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 8, 3813b292112SDmitry Baryshkov { 410, 12, 5632, 3, 12, 11, 11, { 3823b292112SDmitry Baryshkov { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 }, 3833b292112SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 3843b292112SDmitry Baryshkov { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 11, -10 }, 3853b292112SDmitry Baryshkov { 5, 12, -12 }, { 7, 13, -12 }, { 13, 15, -12 } 3863b292112SDmitry Baryshkov } 3873b292112SDmitry Baryshkov } 3883b292112SDmitry Baryshkov }, 3893b292112SDmitry Baryshkov { 3903b292112SDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 10, 3913b292112SDmitry Baryshkov { 410, 12, 5632, 7, 16, 15, 15, { 3923b292112SDmitry Baryshkov { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 }, 3933b292112SDmitry Baryshkov { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 3943b292112SDmitry Baryshkov { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 15, -10 }, 3953b292112SDmitry Baryshkov { 9, 16, -12 }, { 11, 17, -12 }, { 17, 19, -12 } 3963b292112SDmitry Baryshkov } 3973b292112SDmitry Baryshkov } 3983b292112SDmitry Baryshkov }, 3993b292112SDmitry Baryshkov { 4003b292112SDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 12, 4013b292112SDmitry Baryshkov { 410, 12, 5632, 11, 20, 19, 19, { 4023b292112SDmitry Baryshkov { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 }, 4033b292112SDmitry Baryshkov { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 4043b292112SDmitry Baryshkov { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 }, 4053b292112SDmitry Baryshkov { 13, 19, -10 }, { 13, 20, -12 }, { 15, 21, -12 }, 4063b292112SDmitry Baryshkov { 21, 23, -12 } 4073b292112SDmitry Baryshkov } 4083b292112SDmitry Baryshkov } 4093b292112SDmitry Baryshkov }, 4103b292112SDmitry Baryshkov { 411e3290f88SDmitry Baryshkov .bpp = DSC_BPP(12), .bpc = 8, 412e3290f88SDmitry Baryshkov { 341, 15, 2048, 3, 12, 11, 11, { 413e3290f88SDmitry Baryshkov { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 414e3290f88SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 415e3290f88SDmitry Baryshkov { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 }, 416e3290f88SDmitry Baryshkov { 5, 12, -12 }, { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 } 417e3290f88SDmitry Baryshkov } 418e3290f88SDmitry Baryshkov } 419e3290f88SDmitry Baryshkov }, 420e3290f88SDmitry Baryshkov { 421e3290f88SDmitry Baryshkov .bpp = DSC_BPP(12), .bpc = 10, 422e3290f88SDmitry Baryshkov { 341, 15, 2048, 7, 16, 15, 15, { 423e3290f88SDmitry Baryshkov { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 }, 424e3290f88SDmitry Baryshkov { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 425e3290f88SDmitry Baryshkov { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 }, 426e3290f88SDmitry Baryshkov { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 } 427e3290f88SDmitry Baryshkov } 428e3290f88SDmitry Baryshkov } 429e3290f88SDmitry Baryshkov }, 430e3290f88SDmitry Baryshkov { 431e3290f88SDmitry Baryshkov .bpp = DSC_BPP(12), .bpc = 12, 432e3290f88SDmitry Baryshkov { 341, 15, 2048, 11, 20, 19, 19, { 433e3290f88SDmitry Baryshkov { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 }, 434e3290f88SDmitry Baryshkov { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 435e3290f88SDmitry Baryshkov { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 }, 436e3290f88SDmitry Baryshkov { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 }, 437e3290f88SDmitry Baryshkov { 21, 23, -12 } 438e3290f88SDmitry Baryshkov } 439e3290f88SDmitry Baryshkov } 440e3290f88SDmitry Baryshkov }, 4413b292112SDmitry Baryshkov { 4423b292112SDmitry Baryshkov .bpp = DSC_BPP(15), .bpc = 8, 4433b292112SDmitry Baryshkov { 273, 15, 2048, 3, 12, 11, 11, { 4443b292112SDmitry Baryshkov { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 }, 4453b292112SDmitry Baryshkov { 1, 2, 2 }, { 1, 3, 0 }, { 1, 4, -2 }, { 2, 4, -4 }, 4463b292112SDmitry Baryshkov { 3, 4, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 5, 7, -10 }, 4473b292112SDmitry Baryshkov { 5, 8, -12 }, { 7, 13, -12 }, { 13, 15, -12 } 4483b292112SDmitry Baryshkov } 4493b292112SDmitry Baryshkov } 4503b292112SDmitry Baryshkov }, 4513b292112SDmitry Baryshkov { 4523b292112SDmitry Baryshkov .bpp = DSC_BPP(15), .bpc = 10, 4533b292112SDmitry Baryshkov { 273, 15, 2048, 7, 16, 15, 15, { 4543b292112SDmitry Baryshkov { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 }, 4553b292112SDmitry Baryshkov { 5, 6, 2 }, { 5, 7, 0 }, { 5, 8, -2 }, { 6, 8, -4 }, 4563b292112SDmitry Baryshkov { 7, 8, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 9, 11, -10 }, 4573b292112SDmitry Baryshkov { 9, 12, -12 }, { 11, 17, -12 }, { 17, 19, -12 } 4583b292112SDmitry Baryshkov } 4593b292112SDmitry Baryshkov } 4603b292112SDmitry Baryshkov }, 4613b292112SDmitry Baryshkov { 4623b292112SDmitry Baryshkov .bpp = DSC_BPP(15), .bpc = 12, 4633b292112SDmitry Baryshkov { 273, 15, 2048, 11, 20, 19, 19, { 4643b292112SDmitry Baryshkov { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 }, 4653b292112SDmitry Baryshkov { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 }, 4663b292112SDmitry Baryshkov { 11, 12, -6 }, { 11, 13, -8 }, { 12, 14, -10 }, 4673b292112SDmitry Baryshkov { 13, 15, -10 }, { 13, 16, -12 }, { 15, 21, -12 }, 4683b292112SDmitry Baryshkov { 21, 23, -12 } 4693b292112SDmitry Baryshkov } 4703b292112SDmitry Baryshkov } 4713b292112SDmitry Baryshkov }, 472e3290f88SDmitry Baryshkov { /* sentinel */ } 473e3290f88SDmitry Baryshkov }; 474e3290f88SDmitry Baryshkov 475e3290f88SDmitry Baryshkov /* 476e3290f88SDmitry Baryshkov * Selected Rate Control Related Parameter Recommended Values from DSC v1.2, v1.2a, v1.2b and 477e3290f88SDmitry Baryshkov * DSC_v1.1_E1 specs. 478e3290f88SDmitry Baryshkov * 479e3290f88SDmitry Baryshkov * Cross-checked against C Model releases: DSC_model_20161212 and 20210623 480e3290f88SDmitry Baryshkov */ 481e3290f88SDmitry Baryshkov static const struct rc_parameters_data rc_parameters_1_2_444[] = { 4822b470e55SDmitry Baryshkov { 48374fe874cSDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 8, 4842b470e55SDmitry Baryshkov { 768, 15, 6144, 3, 13, 11, 11, { 4852b470e55SDmitry Baryshkov { 0, 4, 0 }, { 1, 6, -2 }, { 3, 8, -2 }, { 4, 8, -4 }, 4862b470e55SDmitry Baryshkov { 5, 9, -6 }, { 5, 9, -6 }, { 6, 9, -6 }, { 6, 10, -8 }, 4872b470e55SDmitry Baryshkov { 7, 11, -8 }, { 8, 12, -10 }, { 9, 12, -10 }, { 10, 12, -12 }, 4882b470e55SDmitry Baryshkov { 10, 12, -12 }, { 11, 12, -12 }, { 13, 14, -12 } 4892b470e55SDmitry Baryshkov } 49074fe874cSDmitry Baryshkov } 4912b470e55SDmitry Baryshkov }, 49274fe874cSDmitry Baryshkov { 49374fe874cSDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 10, 4942b470e55SDmitry Baryshkov { 768, 15, 6144, 7, 17, 15, 15, { 4952b470e55SDmitry Baryshkov { 0, 8, 0 }, { 3, 10, -2 }, { 7, 12, -2 }, { 8, 12, -4 }, 4962b470e55SDmitry Baryshkov { 9, 13, -6 }, { 9, 13, -6 }, { 10, 13, -6 }, { 10, 14, -8 }, 4972b470e55SDmitry Baryshkov { 11, 15, -8 }, { 12, 16, -10 }, { 13, 16, -10 }, 4982b470e55SDmitry Baryshkov { 14, 16, -12 }, { 14, 16, -12 }, { 15, 16, -12 }, 4992b470e55SDmitry Baryshkov { 17, 18, -12 } 5002b470e55SDmitry Baryshkov } 50174fe874cSDmitry Baryshkov } 5022b470e55SDmitry Baryshkov }, 50374fe874cSDmitry Baryshkov { 50474fe874cSDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 12, 5052b470e55SDmitry Baryshkov { 768, 15, 6144, 11, 21, 19, 19, { 5062b470e55SDmitry Baryshkov { 0, 12, 0 }, { 5, 14, -2 }, { 11, 16, -2 }, { 12, 16, -4 }, 5072b470e55SDmitry Baryshkov { 13, 17, -6 }, { 13, 17, -6 }, { 14, 17, -6 }, { 14, 18, -8 }, 5082b470e55SDmitry Baryshkov { 15, 19, -8 }, { 16, 20, -10 }, { 17, 20, -10 }, 5092b470e55SDmitry Baryshkov { 18, 20, -12 }, { 18, 20, -12 }, { 19, 20, -12 }, 5102b470e55SDmitry Baryshkov { 21, 22, -12 } 5112b470e55SDmitry Baryshkov } 51274fe874cSDmitry Baryshkov } 5132b470e55SDmitry Baryshkov }, 51474fe874cSDmitry Baryshkov { 51574fe874cSDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 14, 5162b470e55SDmitry Baryshkov { 768, 15, 6144, 15, 25, 23, 23, { 5172b470e55SDmitry Baryshkov { 0, 16, 0 }, { 7, 18, -2 }, { 15, 20, -2 }, { 16, 20, -4 }, 5182b470e55SDmitry Baryshkov { 17, 21, -6 }, { 17, 21, -6 }, { 18, 21, -6 }, { 18, 22, -8 }, 5192b470e55SDmitry Baryshkov { 19, 23, -8 }, { 20, 24, -10 }, { 21, 24, -10 }, 5202b470e55SDmitry Baryshkov { 22, 24, -12 }, { 22, 24, -12 }, { 23, 24, -12 }, 5212b470e55SDmitry Baryshkov { 25, 26, -12 } 5222b470e55SDmitry Baryshkov } 52374fe874cSDmitry Baryshkov } 5242b470e55SDmitry Baryshkov }, 52574fe874cSDmitry Baryshkov { 52674fe874cSDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 16, 5272b470e55SDmitry Baryshkov { 768, 15, 6144, 19, 29, 27, 27, { 5282b470e55SDmitry Baryshkov { 0, 20, 0 }, { 9, 22, -2 }, { 19, 24, -2 }, { 20, 24, -4 }, 5292b470e55SDmitry Baryshkov { 21, 25, -6 }, { 21, 25, -6 }, { 22, 25, -6 }, { 22, 26, -8 }, 5302b470e55SDmitry Baryshkov { 23, 27, -8 }, { 24, 28, -10 }, { 25, 28, -10 }, 5312b470e55SDmitry Baryshkov { 26, 28, -12 }, { 26, 28, -12 }, { 27, 28, -12 }, 5322b470e55SDmitry Baryshkov { 29, 30, -12 } 5332b470e55SDmitry Baryshkov } 53474fe874cSDmitry Baryshkov } 5352b470e55SDmitry Baryshkov }, 5362b470e55SDmitry Baryshkov { 53774fe874cSDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 8, 5382b470e55SDmitry Baryshkov { 512, 12, 6144, 3, 12, 11, 11, { 5392b470e55SDmitry Baryshkov { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 5402b470e55SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 541e3290f88SDmitry Baryshkov { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 }, 542e3290f88SDmitry Baryshkov { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 } 5432b470e55SDmitry Baryshkov } 54474fe874cSDmitry Baryshkov } 5452b470e55SDmitry Baryshkov }, 54674fe874cSDmitry Baryshkov { 54774fe874cSDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 10, 5482b470e55SDmitry Baryshkov { 512, 12, 6144, 7, 16, 15, 15, { 549e3290f88SDmitry Baryshkov { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 }, 5502b470e55SDmitry Baryshkov { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 551e3290f88SDmitry Baryshkov { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 }, 552e3290f88SDmitry Baryshkov { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 } 5532b470e55SDmitry Baryshkov } 55474fe874cSDmitry Baryshkov } 5552b470e55SDmitry Baryshkov }, 55674fe874cSDmitry Baryshkov { 55774fe874cSDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 12, 5582b470e55SDmitry Baryshkov { 512, 12, 6144, 11, 20, 19, 19, { 5592b470e55SDmitry Baryshkov { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 }, 5602b470e55SDmitry Baryshkov { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 561e3290f88SDmitry Baryshkov { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 }, 562e3290f88SDmitry Baryshkov { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 }, 563e3290f88SDmitry Baryshkov { 20, 21, -12 } 5642b470e55SDmitry Baryshkov } 56574fe874cSDmitry Baryshkov } 5662b470e55SDmitry Baryshkov }, 56774fe874cSDmitry Baryshkov { 56874fe874cSDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 14, 5692b470e55SDmitry Baryshkov { 512, 12, 6144, 15, 24, 23, 23, { 5702b470e55SDmitry Baryshkov { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 }, 5712b470e55SDmitry Baryshkov { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 5722b470e55SDmitry Baryshkov { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 }, 5732b470e55SDmitry Baryshkov { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 }, 5742b470e55SDmitry Baryshkov { 24, 25, -12 } 5752b470e55SDmitry Baryshkov } 57674fe874cSDmitry Baryshkov } 5772b470e55SDmitry Baryshkov }, 57874fe874cSDmitry Baryshkov { 57974fe874cSDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 16, 5802b470e55SDmitry Baryshkov { 512, 12, 6144, 19, 28, 27, 27, { 5812b470e55SDmitry Baryshkov { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 }, 5822b470e55SDmitry Baryshkov { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 5832b470e55SDmitry Baryshkov { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 }, 5842b470e55SDmitry Baryshkov { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 }, 5852b470e55SDmitry Baryshkov { 28, 29, -12 } 5862b470e55SDmitry Baryshkov } 58774fe874cSDmitry Baryshkov } 5882b470e55SDmitry Baryshkov }, 5892b470e55SDmitry Baryshkov { 59074fe874cSDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 8, 5912b470e55SDmitry Baryshkov { 410, 15, 5632, 3, 12, 11, 11, { 5922b470e55SDmitry Baryshkov { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 }, 5932b470e55SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 5942b470e55SDmitry Baryshkov { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 }, 5952b470e55SDmitry Baryshkov { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 } 5962b470e55SDmitry Baryshkov } 59774fe874cSDmitry Baryshkov } 5982b470e55SDmitry Baryshkov }, 59974fe874cSDmitry Baryshkov { 60074fe874cSDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 10, 6012b470e55SDmitry Baryshkov { 410, 15, 5632, 7, 16, 15, 15, { 6022b470e55SDmitry Baryshkov { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 }, 6032b470e55SDmitry Baryshkov { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 6042b470e55SDmitry Baryshkov { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 }, 6052b470e55SDmitry Baryshkov { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 } 6062b470e55SDmitry Baryshkov } 60774fe874cSDmitry Baryshkov } 6082b470e55SDmitry Baryshkov }, 60974fe874cSDmitry Baryshkov { 61074fe874cSDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 12, 6112b470e55SDmitry Baryshkov { 410, 15, 5632, 11, 20, 19, 19, { 6122b470e55SDmitry Baryshkov { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 }, 6132b470e55SDmitry Baryshkov { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 6142b470e55SDmitry Baryshkov { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 }, 6152b470e55SDmitry Baryshkov { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 }, 6162b470e55SDmitry Baryshkov { 19, 20, -12 } 6172b470e55SDmitry Baryshkov } 61874fe874cSDmitry Baryshkov } 6192b470e55SDmitry Baryshkov }, 62074fe874cSDmitry Baryshkov { 62174fe874cSDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 14, 6222b470e55SDmitry Baryshkov { 410, 15, 5632, 15, 24, 23, 23, { 6232b470e55SDmitry Baryshkov { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 }, 6242b470e55SDmitry Baryshkov { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 6252b470e55SDmitry Baryshkov { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 }, 6262b470e55SDmitry Baryshkov { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 }, 6272b470e55SDmitry Baryshkov { 23, 24, -12 } 6282b470e55SDmitry Baryshkov } 62974fe874cSDmitry Baryshkov } 6302b470e55SDmitry Baryshkov }, 63174fe874cSDmitry Baryshkov { 63274fe874cSDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 16, 6332b470e55SDmitry Baryshkov { 410, 15, 5632, 19, 28, 27, 27, { 6342b470e55SDmitry Baryshkov { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 }, 6352b470e55SDmitry Baryshkov { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 6362b470e55SDmitry Baryshkov { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 }, 6372b470e55SDmitry Baryshkov { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 }, 6382b470e55SDmitry Baryshkov { 27, 28, -12 } 6392b470e55SDmitry Baryshkov } 64074fe874cSDmitry Baryshkov } 6412b470e55SDmitry Baryshkov }, 6422b470e55SDmitry Baryshkov { 64374fe874cSDmitry Baryshkov .bpp = DSC_BPP(12), .bpc = 8, 6442b470e55SDmitry Baryshkov { 341, 15, 2048, 3, 12, 11, 11, { 6452b470e55SDmitry Baryshkov { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 6462b470e55SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 647e3290f88SDmitry Baryshkov { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 }, 648e3290f88SDmitry Baryshkov { 5, 9, -12 }, { 7, 10, -12 }, { 10, 11, -12 } 6492b470e55SDmitry Baryshkov } 65074fe874cSDmitry Baryshkov } 6512b470e55SDmitry Baryshkov }, 65274fe874cSDmitry Baryshkov { 65374fe874cSDmitry Baryshkov .bpp = DSC_BPP(12), .bpc = 10, 6542b470e55SDmitry Baryshkov { 341, 15, 2048, 7, 16, 15, 15, { 6552b470e55SDmitry Baryshkov { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 }, 6562b470e55SDmitry Baryshkov { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 657e3290f88SDmitry Baryshkov { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 }, 658e3290f88SDmitry Baryshkov { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 } 6592b470e55SDmitry Baryshkov } 66074fe874cSDmitry Baryshkov } 6612b470e55SDmitry Baryshkov }, 66274fe874cSDmitry Baryshkov { 66374fe874cSDmitry Baryshkov .bpp = DSC_BPP(12), .bpc = 12, 6642b470e55SDmitry Baryshkov { 341, 15, 2048, 11, 20, 19, 19, { 6652b470e55SDmitry Baryshkov { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 }, 6662b470e55SDmitry Baryshkov { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 667e3290f88SDmitry Baryshkov { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 }, 668e3290f88SDmitry Baryshkov { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 }, 669e3290f88SDmitry Baryshkov { 18, 19, -12 } 6702b470e55SDmitry Baryshkov } 67174fe874cSDmitry Baryshkov } 6722b470e55SDmitry Baryshkov }, 67374fe874cSDmitry Baryshkov { 67474fe874cSDmitry Baryshkov .bpp = DSC_BPP(12), .bpc = 14, 6752b470e55SDmitry Baryshkov { 341, 15, 2048, 15, 24, 23, 23, { 6762b470e55SDmitry Baryshkov { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 }, 6772b470e55SDmitry Baryshkov { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 6782b470e55SDmitry Baryshkov { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 }, 6792b470e55SDmitry Baryshkov { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 }, 6802b470e55SDmitry Baryshkov { 22, 23, -12 } 6812b470e55SDmitry Baryshkov } 68274fe874cSDmitry Baryshkov } 6832b470e55SDmitry Baryshkov }, 68474fe874cSDmitry Baryshkov { 68574fe874cSDmitry Baryshkov .bpp = DSC_BPP(12), .bpc = 16, 6862b470e55SDmitry Baryshkov { 341, 15, 2048, 19, 28, 27, 27, { 6872b470e55SDmitry Baryshkov { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 }, 6882b470e55SDmitry Baryshkov { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 6892b470e55SDmitry Baryshkov { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 }, 6902b470e55SDmitry Baryshkov { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 }, 6912b470e55SDmitry Baryshkov { 26, 27, -12 } 6922b470e55SDmitry Baryshkov } 69374fe874cSDmitry Baryshkov } 6942b470e55SDmitry Baryshkov }, 6952b470e55SDmitry Baryshkov { 69674fe874cSDmitry Baryshkov .bpp = DSC_BPP(15), .bpc = 8, 6972b470e55SDmitry Baryshkov { 273, 15, 2048, 3, 12, 11, 11, { 6982b470e55SDmitry Baryshkov { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 }, 6992b470e55SDmitry Baryshkov { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 }, 7002b470e55SDmitry Baryshkov { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 }, 7012b470e55SDmitry Baryshkov { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 } 7022b470e55SDmitry Baryshkov } 70374fe874cSDmitry Baryshkov } 7042b470e55SDmitry Baryshkov }, 70574fe874cSDmitry Baryshkov { 70674fe874cSDmitry Baryshkov .bpp = DSC_BPP(15), .bpc = 10, 7072b470e55SDmitry Baryshkov { 273, 15, 2048, 7, 16, 15, 15, { 7082b470e55SDmitry Baryshkov { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 }, 7092b470e55SDmitry Baryshkov { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 }, 7102b470e55SDmitry Baryshkov { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 }, 7112b470e55SDmitry Baryshkov { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 } 7122b470e55SDmitry Baryshkov } 71374fe874cSDmitry Baryshkov } 7142b470e55SDmitry Baryshkov }, 71574fe874cSDmitry Baryshkov { 71674fe874cSDmitry Baryshkov .bpp = DSC_BPP(15), .bpc = 12, 7172b470e55SDmitry Baryshkov { 273, 15, 2048, 11, 20, 19, 19, { 7182b470e55SDmitry Baryshkov { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 }, 7192b470e55SDmitry Baryshkov { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 }, 7202b470e55SDmitry Baryshkov { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 }, 7212b470e55SDmitry Baryshkov { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 }, 7222b470e55SDmitry Baryshkov { 16, 17, -12 } 7232b470e55SDmitry Baryshkov } 72474fe874cSDmitry Baryshkov } 7252b470e55SDmitry Baryshkov }, 72674fe874cSDmitry Baryshkov { 72774fe874cSDmitry Baryshkov .bpp = DSC_BPP(15), .bpc = 14, 7282b470e55SDmitry Baryshkov { 273, 15, 2048, 15, 24, 23, 23, { 7292b470e55SDmitry Baryshkov { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 }, 7302b470e55SDmitry Baryshkov { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 }, 7312b470e55SDmitry Baryshkov { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 }, 7322b470e55SDmitry Baryshkov { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 }, 7332b470e55SDmitry Baryshkov { 20, 21, -12 } 7342b470e55SDmitry Baryshkov } 73574fe874cSDmitry Baryshkov } 7362b470e55SDmitry Baryshkov }, 73774fe874cSDmitry Baryshkov { 73874fe874cSDmitry Baryshkov .bpp = DSC_BPP(15), .bpc = 16, 7392b470e55SDmitry Baryshkov { 273, 15, 2048, 19, 28, 27, 27, { 7402b470e55SDmitry Baryshkov { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 }, 7412b470e55SDmitry Baryshkov { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 }, 7422b470e55SDmitry Baryshkov { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 }, 7432b470e55SDmitry Baryshkov { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 }, 7442b470e55SDmitry Baryshkov { 24, 25, -12 } 7452b470e55SDmitry Baryshkov } 7462b470e55SDmitry Baryshkov } 74774fe874cSDmitry Baryshkov }, 74874fe874cSDmitry Baryshkov { /* sentinel */ } 7492b470e55SDmitry Baryshkov }; 7502b470e55SDmitry Baryshkov 751*d54fbea3SDmitry Baryshkov /* 752*d54fbea3SDmitry Baryshkov * Selected Rate Control Related Parameter Recommended Values for 4:2:2 from 753*d54fbea3SDmitry Baryshkov * DSC v1.2, v1.2a, v1.2b 754*d54fbea3SDmitry Baryshkov * 755*d54fbea3SDmitry Baryshkov * Cross-checked against C Model releases: DSC_model_20161212 and 20210623 756*d54fbea3SDmitry Baryshkov */ 757*d54fbea3SDmitry Baryshkov static const struct rc_parameters_data rc_parameters_1_2_422[] = { 758*d54fbea3SDmitry Baryshkov { 759*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 8, 760*d54fbea3SDmitry Baryshkov { 512, 15, 6144, 3, 12, 11, 11, { 761*d54fbea3SDmitry Baryshkov { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 762*d54fbea3SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 763*d54fbea3SDmitry Baryshkov { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 }, 764*d54fbea3SDmitry Baryshkov { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 } 765*d54fbea3SDmitry Baryshkov } 766*d54fbea3SDmitry Baryshkov } 767*d54fbea3SDmitry Baryshkov }, 768*d54fbea3SDmitry Baryshkov { 769*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 10, 770*d54fbea3SDmitry Baryshkov { 512, 15, 6144, 7, 16, 15, 15, { 771*d54fbea3SDmitry Baryshkov { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 }, 772*d54fbea3SDmitry Baryshkov { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 773*d54fbea3SDmitry Baryshkov { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 }, 774*d54fbea3SDmitry Baryshkov { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 } 775*d54fbea3SDmitry Baryshkov } 776*d54fbea3SDmitry Baryshkov } 777*d54fbea3SDmitry Baryshkov }, 778*d54fbea3SDmitry Baryshkov { 779*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 12, 780*d54fbea3SDmitry Baryshkov { 512, 15, 6144, 11, 20, 19, 19, { 781*d54fbea3SDmitry Baryshkov { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 }, 782*d54fbea3SDmitry Baryshkov { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 783*d54fbea3SDmitry Baryshkov { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 }, 784*d54fbea3SDmitry Baryshkov { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 }, 785*d54fbea3SDmitry Baryshkov { 20, 21, -12 } 786*d54fbea3SDmitry Baryshkov } 787*d54fbea3SDmitry Baryshkov } 788*d54fbea3SDmitry Baryshkov }, 789*d54fbea3SDmitry Baryshkov { 790*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 14, 791*d54fbea3SDmitry Baryshkov { 512, 15, 6144, 15, 24, 23, 23, { 792*d54fbea3SDmitry Baryshkov { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 }, 793*d54fbea3SDmitry Baryshkov { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 794*d54fbea3SDmitry Baryshkov { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 }, 795*d54fbea3SDmitry Baryshkov { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 }, 796*d54fbea3SDmitry Baryshkov { 24, 25, -12 } 797*d54fbea3SDmitry Baryshkov } 798*d54fbea3SDmitry Baryshkov } 799*d54fbea3SDmitry Baryshkov }, 800*d54fbea3SDmitry Baryshkov { 801*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 16, 802*d54fbea3SDmitry Baryshkov { 512, 15, 6144, 19, 28, 27, 27, { 803*d54fbea3SDmitry Baryshkov { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 }, 804*d54fbea3SDmitry Baryshkov { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 805*d54fbea3SDmitry Baryshkov { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 }, 806*d54fbea3SDmitry Baryshkov { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 }, 807*d54fbea3SDmitry Baryshkov { 28, 29, -12 } 808*d54fbea3SDmitry Baryshkov } 809*d54fbea3SDmitry Baryshkov } 810*d54fbea3SDmitry Baryshkov }, 811*d54fbea3SDmitry Baryshkov { 812*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(7), .bpc = 8, 813*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 3, 12, 11, 11, { 814*d54fbea3SDmitry Baryshkov { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 }, 815*d54fbea3SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 816*d54fbea3SDmitry Baryshkov { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 }, 817*d54fbea3SDmitry Baryshkov { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 } 818*d54fbea3SDmitry Baryshkov } 819*d54fbea3SDmitry Baryshkov } 820*d54fbea3SDmitry Baryshkov }, 821*d54fbea3SDmitry Baryshkov { 822*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(7), .bpc = 10, 823*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 7, 16, 15, 15, { 824*d54fbea3SDmitry Baryshkov { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 }, 825*d54fbea3SDmitry Baryshkov { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 826*d54fbea3SDmitry Baryshkov { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 }, 827*d54fbea3SDmitry Baryshkov { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 } 828*d54fbea3SDmitry Baryshkov } 829*d54fbea3SDmitry Baryshkov } 830*d54fbea3SDmitry Baryshkov }, 831*d54fbea3SDmitry Baryshkov { 832*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(7), .bpc = 12, 833*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 11, 20, 19, 19, { 834*d54fbea3SDmitry Baryshkov { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 }, 835*d54fbea3SDmitry Baryshkov { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 836*d54fbea3SDmitry Baryshkov { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 }, 837*d54fbea3SDmitry Baryshkov { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 }, 838*d54fbea3SDmitry Baryshkov { 19, 20, -12 } 839*d54fbea3SDmitry Baryshkov } 840*d54fbea3SDmitry Baryshkov } 841*d54fbea3SDmitry Baryshkov }, 842*d54fbea3SDmitry Baryshkov { 843*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(7), .bpc = 14, 844*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 15, 24, 23, 23, { 845*d54fbea3SDmitry Baryshkov { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 }, 846*d54fbea3SDmitry Baryshkov { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 847*d54fbea3SDmitry Baryshkov { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 }, 848*d54fbea3SDmitry Baryshkov { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 }, 849*d54fbea3SDmitry Baryshkov { 23, 24, -12 } 850*d54fbea3SDmitry Baryshkov } 851*d54fbea3SDmitry Baryshkov } 852*d54fbea3SDmitry Baryshkov }, 853*d54fbea3SDmitry Baryshkov { 854*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(7), .bpc = 16, 855*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 19, 28, 27, 27, { 856*d54fbea3SDmitry Baryshkov { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 }, 857*d54fbea3SDmitry Baryshkov { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 858*d54fbea3SDmitry Baryshkov { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 }, 859*d54fbea3SDmitry Baryshkov { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 }, 860*d54fbea3SDmitry Baryshkov { 27, 28, -12 } 861*d54fbea3SDmitry Baryshkov } 862*d54fbea3SDmitry Baryshkov } 863*d54fbea3SDmitry Baryshkov }, 864*d54fbea3SDmitry Baryshkov { 865*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 8, 866*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 3, 12, 11, 11, { 867*d54fbea3SDmitry Baryshkov { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 868*d54fbea3SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 869*d54fbea3SDmitry Baryshkov { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 }, 870*d54fbea3SDmitry Baryshkov { 5, 9, -12 }, { 7, 10, -12 }, { 10, 11, -12 } 871*d54fbea3SDmitry Baryshkov } 872*d54fbea3SDmitry Baryshkov } 873*d54fbea3SDmitry Baryshkov }, 874*d54fbea3SDmitry Baryshkov { 875*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 10, 876*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 7, 16, 15, 15, { 877*d54fbea3SDmitry Baryshkov { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 }, 878*d54fbea3SDmitry Baryshkov { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 879*d54fbea3SDmitry Baryshkov { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 }, 880*d54fbea3SDmitry Baryshkov { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 } 881*d54fbea3SDmitry Baryshkov } 882*d54fbea3SDmitry Baryshkov } 883*d54fbea3SDmitry Baryshkov }, 884*d54fbea3SDmitry Baryshkov { 885*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 12, 886*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 11, 20, 19, 19, { 887*d54fbea3SDmitry Baryshkov { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 }, 888*d54fbea3SDmitry Baryshkov { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 889*d54fbea3SDmitry Baryshkov { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 }, 890*d54fbea3SDmitry Baryshkov { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 }, 891*d54fbea3SDmitry Baryshkov { 18, 19, -12 } 892*d54fbea3SDmitry Baryshkov } 893*d54fbea3SDmitry Baryshkov } 894*d54fbea3SDmitry Baryshkov }, 895*d54fbea3SDmitry Baryshkov { 896*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 14, 897*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 15, 24, 23, 23, { 898*d54fbea3SDmitry Baryshkov { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 }, 899*d54fbea3SDmitry Baryshkov { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 900*d54fbea3SDmitry Baryshkov { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 }, 901*d54fbea3SDmitry Baryshkov { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 }, 902*d54fbea3SDmitry Baryshkov { 22, 23, -12 } 903*d54fbea3SDmitry Baryshkov } 904*d54fbea3SDmitry Baryshkov } 905*d54fbea3SDmitry Baryshkov }, 906*d54fbea3SDmitry Baryshkov { 907*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 16, 908*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 19, 28, 27, 27, { 909*d54fbea3SDmitry Baryshkov { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 }, 910*d54fbea3SDmitry Baryshkov { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 911*d54fbea3SDmitry Baryshkov { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 }, 912*d54fbea3SDmitry Baryshkov { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 }, 913*d54fbea3SDmitry Baryshkov { 26, 27, -12 } 914*d54fbea3SDmitry Baryshkov } 915*d54fbea3SDmitry Baryshkov } 916*d54fbea3SDmitry Baryshkov }, 917*d54fbea3SDmitry Baryshkov { 918*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 8, 919*d54fbea3SDmitry Baryshkov { 273, 15, 2048, 3, 12, 11, 11, { 920*d54fbea3SDmitry Baryshkov { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 }, 921*d54fbea3SDmitry Baryshkov { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 }, 922*d54fbea3SDmitry Baryshkov { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 }, 923*d54fbea3SDmitry Baryshkov { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 } 924*d54fbea3SDmitry Baryshkov } 925*d54fbea3SDmitry Baryshkov } 926*d54fbea3SDmitry Baryshkov }, 927*d54fbea3SDmitry Baryshkov { 928*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 10, 929*d54fbea3SDmitry Baryshkov { 273, 15, 2048, 7, 16, 15, 15, { 930*d54fbea3SDmitry Baryshkov { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 }, 931*d54fbea3SDmitry Baryshkov { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 }, 932*d54fbea3SDmitry Baryshkov { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 }, 933*d54fbea3SDmitry Baryshkov { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 } 934*d54fbea3SDmitry Baryshkov } 935*d54fbea3SDmitry Baryshkov } 936*d54fbea3SDmitry Baryshkov }, 937*d54fbea3SDmitry Baryshkov { 938*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 12, 939*d54fbea3SDmitry Baryshkov { 273, 15, 2048, 11, 20, 19, 19, { 940*d54fbea3SDmitry Baryshkov { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 }, 941*d54fbea3SDmitry Baryshkov { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 }, 942*d54fbea3SDmitry Baryshkov { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 }, 943*d54fbea3SDmitry Baryshkov { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 }, 944*d54fbea3SDmitry Baryshkov { 16, 17, -12 } 945*d54fbea3SDmitry Baryshkov } 946*d54fbea3SDmitry Baryshkov } 947*d54fbea3SDmitry Baryshkov }, 948*d54fbea3SDmitry Baryshkov { 949*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 14, 950*d54fbea3SDmitry Baryshkov { 273, 15, 2048, 15, 24, 23, 23, { 951*d54fbea3SDmitry Baryshkov { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 }, 952*d54fbea3SDmitry Baryshkov { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 }, 953*d54fbea3SDmitry Baryshkov { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 }, 954*d54fbea3SDmitry Baryshkov { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 }, 955*d54fbea3SDmitry Baryshkov { 20, 21, -12 } 956*d54fbea3SDmitry Baryshkov } 957*d54fbea3SDmitry Baryshkov } 958*d54fbea3SDmitry Baryshkov }, 959*d54fbea3SDmitry Baryshkov { 960*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(10), .bpc = 16, 961*d54fbea3SDmitry Baryshkov { 273, 15, 2048, 19, 28, 27, 27, { 962*d54fbea3SDmitry Baryshkov { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 }, 963*d54fbea3SDmitry Baryshkov { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 }, 964*d54fbea3SDmitry Baryshkov { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 }, 965*d54fbea3SDmitry Baryshkov { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 }, 966*d54fbea3SDmitry Baryshkov { 24, 25, -12 } 967*d54fbea3SDmitry Baryshkov } 968*d54fbea3SDmitry Baryshkov } 969*d54fbea3SDmitry Baryshkov }, 970*d54fbea3SDmitry Baryshkov { /* sentinel */ } 971*d54fbea3SDmitry Baryshkov }; 972*d54fbea3SDmitry Baryshkov 973*d54fbea3SDmitry Baryshkov /* 974*d54fbea3SDmitry Baryshkov * Selected Rate Control Related Parameter Recommended Values for 4:2:2 from 975*d54fbea3SDmitry Baryshkov * DSC v1.2, v1.2a, v1.2b 976*d54fbea3SDmitry Baryshkov * 977*d54fbea3SDmitry Baryshkov * Cross-checked against C Model releases: DSC_model_20161212 and 20210623 978*d54fbea3SDmitry Baryshkov */ 979*d54fbea3SDmitry Baryshkov static const struct rc_parameters_data rc_parameters_1_2_420[] = { 980*d54fbea3SDmitry Baryshkov { 981*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(4), .bpc = 8, 982*d54fbea3SDmitry Baryshkov { 512, 12, 6144, 3, 12, 11, 11, { 983*d54fbea3SDmitry Baryshkov { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 984*d54fbea3SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 985*d54fbea3SDmitry Baryshkov { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 }, 986*d54fbea3SDmitry Baryshkov { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 } 987*d54fbea3SDmitry Baryshkov } 988*d54fbea3SDmitry Baryshkov } 989*d54fbea3SDmitry Baryshkov }, 990*d54fbea3SDmitry Baryshkov { 991*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(4), .bpc = 10, 992*d54fbea3SDmitry Baryshkov { 512, 12, 6144, 7, 16, 15, 15, { 993*d54fbea3SDmitry Baryshkov { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 }, 994*d54fbea3SDmitry Baryshkov { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 995*d54fbea3SDmitry Baryshkov { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 }, 996*d54fbea3SDmitry Baryshkov { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 } 997*d54fbea3SDmitry Baryshkov } 998*d54fbea3SDmitry Baryshkov } 999*d54fbea3SDmitry Baryshkov }, 1000*d54fbea3SDmitry Baryshkov { 1001*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(4), .bpc = 12, 1002*d54fbea3SDmitry Baryshkov { 512, 12, 6144, 11, 20, 19, 19, { 1003*d54fbea3SDmitry Baryshkov { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 }, 1004*d54fbea3SDmitry Baryshkov { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 1005*d54fbea3SDmitry Baryshkov { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 }, 1006*d54fbea3SDmitry Baryshkov { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 }, 1007*d54fbea3SDmitry Baryshkov { 20, 21, -12 } 1008*d54fbea3SDmitry Baryshkov } 1009*d54fbea3SDmitry Baryshkov } 1010*d54fbea3SDmitry Baryshkov }, 1011*d54fbea3SDmitry Baryshkov { 1012*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(4), .bpc = 14, 1013*d54fbea3SDmitry Baryshkov { 512, 12, 6144, 15, 24, 23, 23, { 1014*d54fbea3SDmitry Baryshkov { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 }, 1015*d54fbea3SDmitry Baryshkov { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 1016*d54fbea3SDmitry Baryshkov { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 }, 1017*d54fbea3SDmitry Baryshkov { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 }, 1018*d54fbea3SDmitry Baryshkov { 24, 25, -12 } 1019*d54fbea3SDmitry Baryshkov } 1020*d54fbea3SDmitry Baryshkov } 1021*d54fbea3SDmitry Baryshkov }, 1022*d54fbea3SDmitry Baryshkov { 1023*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(4), .bpc = 16, 1024*d54fbea3SDmitry Baryshkov { 512, 12, 6144, 19, 28, 27, 27, { 1025*d54fbea3SDmitry Baryshkov { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 }, 1026*d54fbea3SDmitry Baryshkov { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 1027*d54fbea3SDmitry Baryshkov { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 }, 1028*d54fbea3SDmitry Baryshkov { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 }, 1029*d54fbea3SDmitry Baryshkov { 28, 29, -12 } 1030*d54fbea3SDmitry Baryshkov } 1031*d54fbea3SDmitry Baryshkov } 1032*d54fbea3SDmitry Baryshkov }, 1033*d54fbea3SDmitry Baryshkov { 1034*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(5), .bpc = 8, 1035*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 3, 12, 11, 11, { 1036*d54fbea3SDmitry Baryshkov { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 }, 1037*d54fbea3SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 1038*d54fbea3SDmitry Baryshkov { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 }, 1039*d54fbea3SDmitry Baryshkov { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 } 1040*d54fbea3SDmitry Baryshkov } 1041*d54fbea3SDmitry Baryshkov } 1042*d54fbea3SDmitry Baryshkov }, 1043*d54fbea3SDmitry Baryshkov { 1044*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(5), .bpc = 10, 1045*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 7, 16, 15, 15, { 1046*d54fbea3SDmitry Baryshkov { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 }, 1047*d54fbea3SDmitry Baryshkov { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 1048*d54fbea3SDmitry Baryshkov { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 }, 1049*d54fbea3SDmitry Baryshkov { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 } 1050*d54fbea3SDmitry Baryshkov } 1051*d54fbea3SDmitry Baryshkov } 1052*d54fbea3SDmitry Baryshkov }, 1053*d54fbea3SDmitry Baryshkov { 1054*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(5), .bpc = 12, 1055*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 11, 20, 19, 19, { 1056*d54fbea3SDmitry Baryshkov { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 }, 1057*d54fbea3SDmitry Baryshkov { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 1058*d54fbea3SDmitry Baryshkov { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 }, 1059*d54fbea3SDmitry Baryshkov { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 }, 1060*d54fbea3SDmitry Baryshkov { 19, 20, -12 } 1061*d54fbea3SDmitry Baryshkov } 1062*d54fbea3SDmitry Baryshkov } 1063*d54fbea3SDmitry Baryshkov }, 1064*d54fbea3SDmitry Baryshkov { 1065*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(5), .bpc = 14, 1066*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 15, 24, 23, 23, { 1067*d54fbea3SDmitry Baryshkov { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 }, 1068*d54fbea3SDmitry Baryshkov { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 1069*d54fbea3SDmitry Baryshkov { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 }, 1070*d54fbea3SDmitry Baryshkov { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 }, 1071*d54fbea3SDmitry Baryshkov { 23, 24, -12 } 1072*d54fbea3SDmitry Baryshkov } 1073*d54fbea3SDmitry Baryshkov } 1074*d54fbea3SDmitry Baryshkov }, 1075*d54fbea3SDmitry Baryshkov { 1076*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(5), .bpc = 16, 1077*d54fbea3SDmitry Baryshkov { 410, 15, 5632, 19, 28, 27, 27, { 1078*d54fbea3SDmitry Baryshkov { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 }, 1079*d54fbea3SDmitry Baryshkov { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 1080*d54fbea3SDmitry Baryshkov { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 }, 1081*d54fbea3SDmitry Baryshkov { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 }, 1082*d54fbea3SDmitry Baryshkov { 27, 28, -12 } 1083*d54fbea3SDmitry Baryshkov } 1084*d54fbea3SDmitry Baryshkov } 1085*d54fbea3SDmitry Baryshkov }, 1086*d54fbea3SDmitry Baryshkov { 1087*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 8, 1088*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 3, 12, 11, 11, { 1089*d54fbea3SDmitry Baryshkov { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 }, 1090*d54fbea3SDmitry Baryshkov { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 }, 1091*d54fbea3SDmitry Baryshkov { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 }, 1092*d54fbea3SDmitry Baryshkov { 5, 9, -12 }, { 7, 10, -12 }, { 10, 12, -12 } 1093*d54fbea3SDmitry Baryshkov } 1094*d54fbea3SDmitry Baryshkov } 1095*d54fbea3SDmitry Baryshkov }, 1096*d54fbea3SDmitry Baryshkov { 1097*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 10, 1098*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 7, 16, 15, 15, { 1099*d54fbea3SDmitry Baryshkov { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 }, 1100*d54fbea3SDmitry Baryshkov { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 }, 1101*d54fbea3SDmitry Baryshkov { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 }, 1102*d54fbea3SDmitry Baryshkov { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 } 1103*d54fbea3SDmitry Baryshkov } 1104*d54fbea3SDmitry Baryshkov } 1105*d54fbea3SDmitry Baryshkov }, 1106*d54fbea3SDmitry Baryshkov { 1107*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 12, 1108*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 11, 20, 19, 19, { 1109*d54fbea3SDmitry Baryshkov { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 }, 1110*d54fbea3SDmitry Baryshkov { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 }, 1111*d54fbea3SDmitry Baryshkov { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 }, 1112*d54fbea3SDmitry Baryshkov { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 }, 1113*d54fbea3SDmitry Baryshkov { 18, 19, -12 } 1114*d54fbea3SDmitry Baryshkov } 1115*d54fbea3SDmitry Baryshkov } 1116*d54fbea3SDmitry Baryshkov }, 1117*d54fbea3SDmitry Baryshkov { 1118*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 14, 1119*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 15, 24, 23, 23, { 1120*d54fbea3SDmitry Baryshkov { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 }, 1121*d54fbea3SDmitry Baryshkov { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 }, 1122*d54fbea3SDmitry Baryshkov { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 }, 1123*d54fbea3SDmitry Baryshkov { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 }, 1124*d54fbea3SDmitry Baryshkov { 22, 23, -12 } 1125*d54fbea3SDmitry Baryshkov } 1126*d54fbea3SDmitry Baryshkov } 1127*d54fbea3SDmitry Baryshkov }, 1128*d54fbea3SDmitry Baryshkov { 1129*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(6), .bpc = 16, 1130*d54fbea3SDmitry Baryshkov { 341, 15, 2048, 19, 28, 27, 27, { 1131*d54fbea3SDmitry Baryshkov { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 }, 1132*d54fbea3SDmitry Baryshkov { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 }, 1133*d54fbea3SDmitry Baryshkov { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 }, 1134*d54fbea3SDmitry Baryshkov { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 }, 1135*d54fbea3SDmitry Baryshkov { 26, 27, -12 } 1136*d54fbea3SDmitry Baryshkov } 1137*d54fbea3SDmitry Baryshkov } 1138*d54fbea3SDmitry Baryshkov }, 1139*d54fbea3SDmitry Baryshkov { 1140*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 8, 1141*d54fbea3SDmitry Baryshkov { 256, 15, 2048, 3, 12, 11, 11, { 1142*d54fbea3SDmitry Baryshkov { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 }, 1143*d54fbea3SDmitry Baryshkov { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 }, 1144*d54fbea3SDmitry Baryshkov { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 }, 1145*d54fbea3SDmitry Baryshkov { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 } 1146*d54fbea3SDmitry Baryshkov } 1147*d54fbea3SDmitry Baryshkov } 1148*d54fbea3SDmitry Baryshkov }, 1149*d54fbea3SDmitry Baryshkov { 1150*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 10, 1151*d54fbea3SDmitry Baryshkov { 256, 15, 2048, 7, 16, 15, 15, { 1152*d54fbea3SDmitry Baryshkov { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 }, 1153*d54fbea3SDmitry Baryshkov { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 }, 1154*d54fbea3SDmitry Baryshkov { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 }, 1155*d54fbea3SDmitry Baryshkov { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 } 1156*d54fbea3SDmitry Baryshkov } 1157*d54fbea3SDmitry Baryshkov } 1158*d54fbea3SDmitry Baryshkov }, 1159*d54fbea3SDmitry Baryshkov { 1160*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 12, 1161*d54fbea3SDmitry Baryshkov { 256, 15, 2048, 11, 20, 19, 19, { 1162*d54fbea3SDmitry Baryshkov { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 }, 1163*d54fbea3SDmitry Baryshkov { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 }, 1164*d54fbea3SDmitry Baryshkov { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 }, 1165*d54fbea3SDmitry Baryshkov { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 }, 1166*d54fbea3SDmitry Baryshkov { 16, 17, -12 } 1167*d54fbea3SDmitry Baryshkov } 1168*d54fbea3SDmitry Baryshkov } 1169*d54fbea3SDmitry Baryshkov }, 1170*d54fbea3SDmitry Baryshkov { 1171*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 14, 1172*d54fbea3SDmitry Baryshkov { 256, 15, 2048, 15, 24, 23, 23, { 1173*d54fbea3SDmitry Baryshkov { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 }, 1174*d54fbea3SDmitry Baryshkov { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 }, 1175*d54fbea3SDmitry Baryshkov { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 }, 1176*d54fbea3SDmitry Baryshkov { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 }, 1177*d54fbea3SDmitry Baryshkov { 20, 21, -12 } 1178*d54fbea3SDmitry Baryshkov } 1179*d54fbea3SDmitry Baryshkov } 1180*d54fbea3SDmitry Baryshkov }, 1181*d54fbea3SDmitry Baryshkov { 1182*d54fbea3SDmitry Baryshkov .bpp = DSC_BPP(8), .bpc = 16, 1183*d54fbea3SDmitry Baryshkov { 256, 15, 2048, 19, 28, 27, 27, { 1184*d54fbea3SDmitry Baryshkov { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 }, 1185*d54fbea3SDmitry Baryshkov { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 }, 1186*d54fbea3SDmitry Baryshkov { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 }, 1187*d54fbea3SDmitry Baryshkov { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 }, 1188*d54fbea3SDmitry Baryshkov { 24, 25, -12 } 1189*d54fbea3SDmitry Baryshkov } 1190*d54fbea3SDmitry Baryshkov } 1191*d54fbea3SDmitry Baryshkov }, 1192*d54fbea3SDmitry Baryshkov { /* sentinel */ } 1193*d54fbea3SDmitry Baryshkov }; 1194*d54fbea3SDmitry Baryshkov 1195e3290f88SDmitry Baryshkov static const struct rc_parameters *get_rc_params(const struct rc_parameters_data *rc_parameters, 1196e3290f88SDmitry Baryshkov u16 dsc_bpp, 11972b470e55SDmitry Baryshkov u8 bits_per_component) 11982b470e55SDmitry Baryshkov { 119974fe874cSDmitry Baryshkov int i; 12002b470e55SDmitry Baryshkov 120174fe874cSDmitry Baryshkov for (i = 0; rc_parameters[i].bpp; i++) 120274fe874cSDmitry Baryshkov if (rc_parameters[i].bpp == dsc_bpp && 120374fe874cSDmitry Baryshkov rc_parameters[i].bpc == bits_per_component) 120474fe874cSDmitry Baryshkov return &rc_parameters[i].params; 120574fe874cSDmitry Baryshkov 12062b470e55SDmitry Baryshkov return NULL; 12072b470e55SDmitry Baryshkov } 12082b470e55SDmitry Baryshkov 12092b470e55SDmitry Baryshkov /** 12102b470e55SDmitry Baryshkov * drm_dsc_setup_rc_params() - Set parameters and limits for RC model in 12112b470e55SDmitry Baryshkov * accordance with the DSC 1.1 or 1.2 specification and DSC C Model 12122b470e55SDmitry Baryshkov * Required bits_per_pixel and bits_per_component to be set before calling this 12132b470e55SDmitry Baryshkov * function. 12142b470e55SDmitry Baryshkov * 12152b470e55SDmitry Baryshkov * @vdsc_cfg: DSC Configuration data partially filled by driver 1216e3290f88SDmitry Baryshkov * @type: operating mode and standard to follow 12172b470e55SDmitry Baryshkov * 12182b470e55SDmitry Baryshkov * Return: 0 or -error code in case of an error 12192b470e55SDmitry Baryshkov */ 1220e3290f88SDmitry Baryshkov int drm_dsc_setup_rc_params(struct drm_dsc_config *vdsc_cfg, enum drm_dsc_params_type type) 12212b470e55SDmitry Baryshkov { 1222e3290f88SDmitry Baryshkov const struct rc_parameters_data *data; 12232b470e55SDmitry Baryshkov const struct rc_parameters *rc_params; 12242b470e55SDmitry Baryshkov int i; 12252b470e55SDmitry Baryshkov 12262b470e55SDmitry Baryshkov if (WARN_ON_ONCE(!vdsc_cfg->bits_per_pixel || 12272b470e55SDmitry Baryshkov !vdsc_cfg->bits_per_component)) 12282b470e55SDmitry Baryshkov return -EINVAL; 12292b470e55SDmitry Baryshkov 1230e3290f88SDmitry Baryshkov switch (type) { 1231e3290f88SDmitry Baryshkov case DRM_DSC_1_2_444: 1232e3290f88SDmitry Baryshkov data = rc_parameters_1_2_444; 1233e3290f88SDmitry Baryshkov break; 1234e3290f88SDmitry Baryshkov case DRM_DSC_1_1_PRE_SCR: 1235e3290f88SDmitry Baryshkov data = rc_parameters_pre_scr; 1236e3290f88SDmitry Baryshkov break; 1237*d54fbea3SDmitry Baryshkov case DRM_DSC_1_2_422: 1238*d54fbea3SDmitry Baryshkov data = rc_parameters_1_2_422; 1239*d54fbea3SDmitry Baryshkov break; 1240*d54fbea3SDmitry Baryshkov case DRM_DSC_1_2_420: 1241*d54fbea3SDmitry Baryshkov data = rc_parameters_1_2_420; 1242*d54fbea3SDmitry Baryshkov break; 1243e3290f88SDmitry Baryshkov default: 1244e3290f88SDmitry Baryshkov return -EINVAL; 1245e3290f88SDmitry Baryshkov } 1246e3290f88SDmitry Baryshkov 1247e3290f88SDmitry Baryshkov rc_params = get_rc_params(data, 1248e3290f88SDmitry Baryshkov vdsc_cfg->bits_per_pixel, 12492b470e55SDmitry Baryshkov vdsc_cfg->bits_per_component); 12502b470e55SDmitry Baryshkov if (!rc_params) 12512b470e55SDmitry Baryshkov return -EINVAL; 12522b470e55SDmitry Baryshkov 12532b470e55SDmitry Baryshkov vdsc_cfg->first_line_bpg_offset = rc_params->first_line_bpg_offset; 12542b470e55SDmitry Baryshkov vdsc_cfg->initial_xmit_delay = rc_params->initial_xmit_delay; 12552b470e55SDmitry Baryshkov vdsc_cfg->initial_offset = rc_params->initial_offset; 12562b470e55SDmitry Baryshkov vdsc_cfg->flatness_min_qp = rc_params->flatness_min_qp; 12572b470e55SDmitry Baryshkov vdsc_cfg->flatness_max_qp = rc_params->flatness_max_qp; 12582b470e55SDmitry Baryshkov vdsc_cfg->rc_quant_incr_limit0 = rc_params->rc_quant_incr_limit0; 12592b470e55SDmitry Baryshkov vdsc_cfg->rc_quant_incr_limit1 = rc_params->rc_quant_incr_limit1; 12602b470e55SDmitry Baryshkov 12612b470e55SDmitry Baryshkov for (i = 0; i < DSC_NUM_BUF_RANGES; i++) { 12622b470e55SDmitry Baryshkov vdsc_cfg->rc_range_params[i].range_min_qp = 12632b470e55SDmitry Baryshkov rc_params->rc_range_params[i].range_min_qp; 12642b470e55SDmitry Baryshkov vdsc_cfg->rc_range_params[i].range_max_qp = 12652b470e55SDmitry Baryshkov rc_params->rc_range_params[i].range_max_qp; 12662b470e55SDmitry Baryshkov /* 12672b470e55SDmitry Baryshkov * Range BPG Offset uses 2's complement and is only a 6 bits. So 12682b470e55SDmitry Baryshkov * mask it to get only 6 bits. 12692b470e55SDmitry Baryshkov */ 12702b470e55SDmitry Baryshkov vdsc_cfg->rc_range_params[i].range_bpg_offset = 12712b470e55SDmitry Baryshkov rc_params->rc_range_params[i].range_bpg_offset & 12722b470e55SDmitry Baryshkov DSC_RANGE_BPG_OFFSET_MASK; 12732b470e55SDmitry Baryshkov } 12742b470e55SDmitry Baryshkov 12752b470e55SDmitry Baryshkov return 0; 12762b470e55SDmitry Baryshkov } 12772b470e55SDmitry Baryshkov EXPORT_SYMBOL(drm_dsc_setup_rc_params); 12782b470e55SDmitry Baryshkov 12792a64b147SThomas Zimmermann /** 12802a64b147SThomas Zimmermann * drm_dsc_compute_rc_parameters() - Write rate control 12812a64b147SThomas Zimmermann * parameters to the dsc configuration defined in 12822a64b147SThomas Zimmermann * &struct drm_dsc_config in accordance with the DSC 1.2 12832a64b147SThomas Zimmermann * specification. Some configuration fields must be present 12842a64b147SThomas Zimmermann * beforehand. 12852a64b147SThomas Zimmermann * 12862a64b147SThomas Zimmermann * @vdsc_cfg: 12872a64b147SThomas Zimmermann * DSC Configuration data partially filled by driver 12882a64b147SThomas Zimmermann */ 12892a64b147SThomas Zimmermann int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg) 12902a64b147SThomas Zimmermann { 12912a64b147SThomas Zimmermann unsigned long groups_per_line = 0; 12922a64b147SThomas Zimmermann unsigned long groups_total = 0; 12932a64b147SThomas Zimmermann unsigned long num_extra_mux_bits = 0; 12942a64b147SThomas Zimmermann unsigned long slice_bits = 0; 12952a64b147SThomas Zimmermann unsigned long hrd_delay = 0; 12962a64b147SThomas Zimmermann unsigned long final_scale = 0; 12972a64b147SThomas Zimmermann unsigned long rbs_min = 0; 12982a64b147SThomas Zimmermann 12992a64b147SThomas Zimmermann if (vdsc_cfg->native_420 || vdsc_cfg->native_422) { 13002a64b147SThomas Zimmermann /* Number of groups used to code each line of a slice */ 13012a64b147SThomas Zimmermann groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width / 2, 13022a64b147SThomas Zimmermann DSC_RC_PIXELS_PER_GROUP); 13032a64b147SThomas Zimmermann 13042a64b147SThomas Zimmermann /* chunksize in Bytes */ 13052a64b147SThomas Zimmermann vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width / 2 * 13062a64b147SThomas Zimmermann vdsc_cfg->bits_per_pixel, 13072a64b147SThomas Zimmermann (8 * 16)); 13082a64b147SThomas Zimmermann } else { 13092a64b147SThomas Zimmermann /* Number of groups used to code each line of a slice */ 13102a64b147SThomas Zimmermann groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width, 13112a64b147SThomas Zimmermann DSC_RC_PIXELS_PER_GROUP); 13122a64b147SThomas Zimmermann 13132a64b147SThomas Zimmermann /* chunksize in Bytes */ 13142a64b147SThomas Zimmermann vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width * 13152a64b147SThomas Zimmermann vdsc_cfg->bits_per_pixel, 13162a64b147SThomas Zimmermann (8 * 16)); 13172a64b147SThomas Zimmermann } 13182a64b147SThomas Zimmermann 13192a64b147SThomas Zimmermann if (vdsc_cfg->convert_rgb) 13202a64b147SThomas Zimmermann num_extra_mux_bits = 3 * (vdsc_cfg->mux_word_size + 13212a64b147SThomas Zimmermann (4 * vdsc_cfg->bits_per_component + 4) 13222a64b147SThomas Zimmermann - 2); 13232a64b147SThomas Zimmermann else if (vdsc_cfg->native_422) 13242a64b147SThomas Zimmermann num_extra_mux_bits = 4 * vdsc_cfg->mux_word_size + 13252a64b147SThomas Zimmermann (4 * vdsc_cfg->bits_per_component + 4) + 13262a64b147SThomas Zimmermann 3 * (4 * vdsc_cfg->bits_per_component) - 2; 13272a64b147SThomas Zimmermann else 13282a64b147SThomas Zimmermann num_extra_mux_bits = 3 * vdsc_cfg->mux_word_size + 13292a64b147SThomas Zimmermann (4 * vdsc_cfg->bits_per_component + 4) + 13302a64b147SThomas Zimmermann 2 * (4 * vdsc_cfg->bits_per_component) - 2; 13312a64b147SThomas Zimmermann /* Number of bits in one Slice */ 13322a64b147SThomas Zimmermann slice_bits = 8 * vdsc_cfg->slice_chunk_size * vdsc_cfg->slice_height; 13332a64b147SThomas Zimmermann 13342a64b147SThomas Zimmermann while ((num_extra_mux_bits > 0) && 13352a64b147SThomas Zimmermann ((slice_bits - num_extra_mux_bits) % vdsc_cfg->mux_word_size)) 13362a64b147SThomas Zimmermann num_extra_mux_bits--; 13372a64b147SThomas Zimmermann 13382a64b147SThomas Zimmermann if (groups_per_line < vdsc_cfg->initial_scale_value - 8) 13392a64b147SThomas Zimmermann vdsc_cfg->initial_scale_value = groups_per_line + 8; 13402a64b147SThomas Zimmermann 13412a64b147SThomas Zimmermann /* scale_decrement_interval calculation according to DSC spec 1.11 */ 13422a64b147SThomas Zimmermann if (vdsc_cfg->initial_scale_value > 8) 13432a64b147SThomas Zimmermann vdsc_cfg->scale_decrement_interval = groups_per_line / 13442a64b147SThomas Zimmermann (vdsc_cfg->initial_scale_value - 8); 13452a64b147SThomas Zimmermann else 13462a64b147SThomas Zimmermann vdsc_cfg->scale_decrement_interval = DSC_SCALE_DECREMENT_INTERVAL_MAX; 13472a64b147SThomas Zimmermann 13482a64b147SThomas Zimmermann vdsc_cfg->final_offset = vdsc_cfg->rc_model_size - 13492a64b147SThomas Zimmermann (vdsc_cfg->initial_xmit_delay * 13502a64b147SThomas Zimmermann vdsc_cfg->bits_per_pixel + 8) / 16 + num_extra_mux_bits; 13512a64b147SThomas Zimmermann 13522a64b147SThomas Zimmermann if (vdsc_cfg->final_offset >= vdsc_cfg->rc_model_size) { 13532a64b147SThomas Zimmermann DRM_DEBUG_KMS("FinalOfs < RcModelSze for this InitialXmitDelay\n"); 13542a64b147SThomas Zimmermann return -ERANGE; 13552a64b147SThomas Zimmermann } 13562a64b147SThomas Zimmermann 13572a64b147SThomas Zimmermann final_scale = (vdsc_cfg->rc_model_size * 8) / 13582a64b147SThomas Zimmermann (vdsc_cfg->rc_model_size - vdsc_cfg->final_offset); 13592a64b147SThomas Zimmermann if (vdsc_cfg->slice_height > 1) 13602a64b147SThomas Zimmermann /* 13612a64b147SThomas Zimmermann * NflBpgOffset is 16 bit value with 11 fractional bits 13622a64b147SThomas Zimmermann * hence we multiply by 2^11 for preserving the 13632a64b147SThomas Zimmermann * fractional part 13642a64b147SThomas Zimmermann */ 13652a64b147SThomas Zimmermann vdsc_cfg->nfl_bpg_offset = DIV_ROUND_UP((vdsc_cfg->first_line_bpg_offset << 11), 13662a64b147SThomas Zimmermann (vdsc_cfg->slice_height - 1)); 13672a64b147SThomas Zimmermann else 13682a64b147SThomas Zimmermann vdsc_cfg->nfl_bpg_offset = 0; 13692a64b147SThomas Zimmermann 13702a64b147SThomas Zimmermann /* Number of groups used to code the entire slice */ 13712a64b147SThomas Zimmermann groups_total = groups_per_line * vdsc_cfg->slice_height; 13722a64b147SThomas Zimmermann 13732a64b147SThomas Zimmermann /* slice_bpg_offset is 16 bit value with 11 fractional bits */ 13742a64b147SThomas Zimmermann vdsc_cfg->slice_bpg_offset = DIV_ROUND_UP(((vdsc_cfg->rc_model_size - 13752a64b147SThomas Zimmermann vdsc_cfg->initial_offset + 13762a64b147SThomas Zimmermann num_extra_mux_bits) << 11), 13772a64b147SThomas Zimmermann groups_total); 13782a64b147SThomas Zimmermann 13792a64b147SThomas Zimmermann if (final_scale > 9) { 13802a64b147SThomas Zimmermann /* 13812a64b147SThomas Zimmermann * ScaleIncrementInterval = 13822a64b147SThomas Zimmermann * finaloffset/((NflBpgOffset + SliceBpgOffset)*8(finalscale - 1.125)) 13832a64b147SThomas Zimmermann * as (NflBpgOffset + SliceBpgOffset) has 11 bit fractional value, 13842a64b147SThomas Zimmermann * we need divide by 2^11 from pstDscCfg values 13852a64b147SThomas Zimmermann */ 13862a64b147SThomas Zimmermann vdsc_cfg->scale_increment_interval = 13872a64b147SThomas Zimmermann (vdsc_cfg->final_offset * (1 << 11)) / 13882a64b147SThomas Zimmermann ((vdsc_cfg->nfl_bpg_offset + 13892a64b147SThomas Zimmermann vdsc_cfg->slice_bpg_offset) * 13902a64b147SThomas Zimmermann (final_scale - 9)); 13912a64b147SThomas Zimmermann } else { 13922a64b147SThomas Zimmermann /* 13932a64b147SThomas Zimmermann * If finalScaleValue is less than or equal to 9, a value of 0 should 13942a64b147SThomas Zimmermann * be used to disable the scale increment at the end of the slice 13952a64b147SThomas Zimmermann */ 13962a64b147SThomas Zimmermann vdsc_cfg->scale_increment_interval = 0; 13972a64b147SThomas Zimmermann } 13982a64b147SThomas Zimmermann 13992a64b147SThomas Zimmermann /* 14002a64b147SThomas Zimmermann * DSC spec mentions that bits_per_pixel specifies the target 14012a64b147SThomas Zimmermann * bits/pixel (bpp) rate that is used by the encoder, 14022a64b147SThomas Zimmermann * in steps of 1/16 of a bit per pixel 14032a64b147SThomas Zimmermann */ 14042a64b147SThomas Zimmermann rbs_min = vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset + 14052a64b147SThomas Zimmermann DIV_ROUND_UP(vdsc_cfg->initial_xmit_delay * 14062a64b147SThomas Zimmermann vdsc_cfg->bits_per_pixel, 16) + 14072a64b147SThomas Zimmermann groups_per_line * vdsc_cfg->first_line_bpg_offset; 14082a64b147SThomas Zimmermann 14092a64b147SThomas Zimmermann hrd_delay = DIV_ROUND_UP((rbs_min * 16), vdsc_cfg->bits_per_pixel); 14102a64b147SThomas Zimmermann vdsc_cfg->rc_bits = (hrd_delay * vdsc_cfg->bits_per_pixel) / 16; 14112a64b147SThomas Zimmermann vdsc_cfg->initial_dec_delay = hrd_delay - vdsc_cfg->initial_xmit_delay; 14122a64b147SThomas Zimmermann 14132a64b147SThomas Zimmermann return 0; 14142a64b147SThomas Zimmermann } 14152a64b147SThomas Zimmermann EXPORT_SYMBOL(drm_dsc_compute_rc_parameters); 1416