Lines Matching +full:- +full:10

1 // SPDX-License-Identifier: MIT
34 * drm_dsc_dp_pps_header_init() - Initializes the PPS Header
48 pps_header->HB1 = DP_SDP_PPS; in drm_dsc_dp_pps_header_init()
49 pps_header->HB2 = DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1; in drm_dsc_dp_pps_header_init()
54 * drm_dsc_dp_rc_buffer_size - get rc buffer size in bytes
56 * @rc_buffer_size: number of blocks - 1, according to DPCD offset 63h
81 * drm_dsc_pps_payload_pack() - Populates the DSC PPS
109 pps_payload->dsc_version = in drm_dsc_pps_payload_pack()
110 dsc_cfg->dsc_version_minor | in drm_dsc_pps_payload_pack()
111 dsc_cfg->dsc_version_major << DSC_PPS_VERSION_MAJOR_SHIFT; in drm_dsc_pps_payload_pack()
116 pps_payload->pps_3 = in drm_dsc_pps_payload_pack()
117 dsc_cfg->line_buf_depth | in drm_dsc_pps_payload_pack()
118 dsc_cfg->bits_per_component << DSC_PPS_BPC_SHIFT; in drm_dsc_pps_payload_pack()
121 pps_payload->pps_4 = in drm_dsc_pps_payload_pack()
122 ((dsc_cfg->bits_per_pixel & DSC_PPS_BPP_HIGH_MASK) >> in drm_dsc_pps_payload_pack()
124 dsc_cfg->vbr_enable << DSC_PPS_VBR_EN_SHIFT | in drm_dsc_pps_payload_pack()
125 dsc_cfg->simple_422 << DSC_PPS_SIMPLE422_SHIFT | in drm_dsc_pps_payload_pack()
126 dsc_cfg->convert_rgb << DSC_PPS_CONVERT_RGB_SHIFT | in drm_dsc_pps_payload_pack()
127 dsc_cfg->block_pred_enable << DSC_PPS_BLOCK_PRED_EN_SHIFT; in drm_dsc_pps_payload_pack()
130 pps_payload->bits_per_pixel_low = in drm_dsc_pps_payload_pack()
131 (dsc_cfg->bits_per_pixel & DSC_PPS_LSB_MASK); in drm_dsc_pps_payload_pack()
141 pps_payload->pic_height = cpu_to_be16(dsc_cfg->pic_height); in drm_dsc_pps_payload_pack()
144 pps_payload->pic_width = cpu_to_be16(dsc_cfg->pic_width); in drm_dsc_pps_payload_pack()
146 /* PPS 10, 11 */ in drm_dsc_pps_payload_pack()
147 pps_payload->slice_height = cpu_to_be16(dsc_cfg->slice_height); in drm_dsc_pps_payload_pack()
150 pps_payload->slice_width = cpu_to_be16(dsc_cfg->slice_width); in drm_dsc_pps_payload_pack()
153 pps_payload->chunk_size = cpu_to_be16(dsc_cfg->slice_chunk_size); in drm_dsc_pps_payload_pack()
156 pps_payload->initial_xmit_delay_high = in drm_dsc_pps_payload_pack()
157 ((dsc_cfg->initial_xmit_delay & in drm_dsc_pps_payload_pack()
162 pps_payload->initial_xmit_delay_low = in drm_dsc_pps_payload_pack()
163 (dsc_cfg->initial_xmit_delay & DSC_PPS_LSB_MASK); in drm_dsc_pps_payload_pack()
166 pps_payload->initial_dec_delay = in drm_dsc_pps_payload_pack()
167 cpu_to_be16(dsc_cfg->initial_dec_delay); in drm_dsc_pps_payload_pack()
172 pps_payload->initial_scale_value = in drm_dsc_pps_payload_pack()
173 dsc_cfg->initial_scale_value; in drm_dsc_pps_payload_pack()
176 pps_payload->scale_increment_interval = in drm_dsc_pps_payload_pack()
177 cpu_to_be16(dsc_cfg->scale_increment_interval); in drm_dsc_pps_payload_pack()
180 pps_payload->scale_decrement_interval_high = in drm_dsc_pps_payload_pack()
181 ((dsc_cfg->scale_decrement_interval & in drm_dsc_pps_payload_pack()
186 pps_payload->scale_decrement_interval_low = in drm_dsc_pps_payload_pack()
187 (dsc_cfg->scale_decrement_interval & DSC_PPS_LSB_MASK); in drm_dsc_pps_payload_pack()
192 pps_payload->first_line_bpg_offset = in drm_dsc_pps_payload_pack()
193 dsc_cfg->first_line_bpg_offset; in drm_dsc_pps_payload_pack()
196 pps_payload->nfl_bpg_offset = in drm_dsc_pps_payload_pack()
197 cpu_to_be16(dsc_cfg->nfl_bpg_offset); in drm_dsc_pps_payload_pack()
200 pps_payload->slice_bpg_offset = in drm_dsc_pps_payload_pack()
201 cpu_to_be16(dsc_cfg->slice_bpg_offset); in drm_dsc_pps_payload_pack()
204 pps_payload->initial_offset = in drm_dsc_pps_payload_pack()
205 cpu_to_be16(dsc_cfg->initial_offset); in drm_dsc_pps_payload_pack()
208 pps_payload->final_offset = cpu_to_be16(dsc_cfg->final_offset); in drm_dsc_pps_payload_pack()
211 pps_payload->flatness_min_qp = dsc_cfg->flatness_min_qp; in drm_dsc_pps_payload_pack()
214 pps_payload->flatness_max_qp = dsc_cfg->flatness_max_qp; in drm_dsc_pps_payload_pack()
217 pps_payload->rc_model_size = cpu_to_be16(dsc_cfg->rc_model_size); in drm_dsc_pps_payload_pack()
220 pps_payload->rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST; in drm_dsc_pps_payload_pack()
223 pps_payload->rc_quant_incr_limit0 = in drm_dsc_pps_payload_pack()
224 dsc_cfg->rc_quant_incr_limit0; in drm_dsc_pps_payload_pack()
227 pps_payload->rc_quant_incr_limit1 = in drm_dsc_pps_payload_pack()
228 dsc_cfg->rc_quant_incr_limit1; in drm_dsc_pps_payload_pack()
231 pps_payload->rc_tgt_offset = DSC_RC_TGT_OFFSET_LO_CONST | in drm_dsc_pps_payload_pack()
234 /* PPS 44 - 57 */ in drm_dsc_pps_payload_pack()
235 for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++) in drm_dsc_pps_payload_pack()
236 pps_payload->rc_buf_thresh[i] = in drm_dsc_pps_payload_pack()
237 dsc_cfg->rc_buf_thresh[i]; in drm_dsc_pps_payload_pack()
239 /* PPS 58 - 87 */ in drm_dsc_pps_payload_pack()
242 * are as follows: Min_qp[15:11], max_qp[10:6], offset[5:0] in drm_dsc_pps_payload_pack()
245 pps_payload->rc_range_parameters[i] = in drm_dsc_pps_payload_pack()
246 cpu_to_be16((dsc_cfg->rc_range_params[i].range_min_qp << in drm_dsc_pps_payload_pack()
248 (dsc_cfg->rc_range_params[i].range_max_qp << in drm_dsc_pps_payload_pack()
250 (dsc_cfg->rc_range_params[i].range_bpg_offset)); in drm_dsc_pps_payload_pack()
254 pps_payload->native_422_420 = dsc_cfg->native_422 | in drm_dsc_pps_payload_pack()
255 dsc_cfg->native_420 << DSC_PPS_NATIVE_420_SHIFT; in drm_dsc_pps_payload_pack()
258 pps_payload->second_line_bpg_offset = in drm_dsc_pps_payload_pack()
259 dsc_cfg->second_line_bpg_offset; in drm_dsc_pps_payload_pack()
262 pps_payload->nsl_bpg_offset = in drm_dsc_pps_payload_pack()
263 cpu_to_be16(dsc_cfg->nsl_bpg_offset); in drm_dsc_pps_payload_pack()
266 pps_payload->second_line_offset_adj = in drm_dsc_pps_payload_pack()
267 cpu_to_be16(dsc_cfg->second_line_offset_adj); in drm_dsc_pps_payload_pack()
269 /* PPS 94 - 127 are O */ in drm_dsc_pps_payload_pack()
274 * drm_dsc_set_const_params() - Set DSC parameters considered typically
282 if (!vdsc_cfg->rc_model_size) in drm_dsc_set_const_params()
283 vdsc_cfg->rc_model_size = DSC_RC_MODEL_SIZE_CONST; in drm_dsc_set_const_params()
284 vdsc_cfg->rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST; in drm_dsc_set_const_params()
285 vdsc_cfg->rc_tgt_offset_high = DSC_RC_TGT_OFFSET_HI_CONST; in drm_dsc_set_const_params()
286 vdsc_cfg->rc_tgt_offset_low = DSC_RC_TGT_OFFSET_LO_CONST; in drm_dsc_set_const_params()
288 if (vdsc_cfg->bits_per_component <= 10) in drm_dsc_set_const_params()
289 vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC; in drm_dsc_set_const_params()
291 vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC; in drm_dsc_set_const_params()
302 * drm_dsc_set_rc_buf_thresh() - Set thresholds for the RC model
312 DSC_NUM_BUF_RANGES - 1); in drm_dsc_set_rc_buf_thresh()
314 ARRAY_SIZE(vdsc_cfg->rc_buf_thresh)); in drm_dsc_set_rc_buf_thresh()
317 vdsc_cfg->rc_buf_thresh[i] = drm_dsc_rc_buf_thresh[i] >> 6; in drm_dsc_set_rc_buf_thresh()
323 if (vdsc_cfg->bits_per_pixel == 6 << 4) { in drm_dsc_set_rc_buf_thresh()
324 vdsc_cfg->rc_buf_thresh[12] = 7936 >> 6; in drm_dsc_set_rc_buf_thresh()
325 vdsc_cfg->rc_buf_thresh[13] = 8000 >> 6; in drm_dsc_set_rc_buf_thresh()
353 * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
359 { 0, 2, 0 }, { 1, 4, -2 }, { 3, 6, -2 }, { 4, 6, -4 },
360 { 5, 7, -6 }, { 5, 7, -6 }, { 6, 7, -6 }, { 6, 8, -8 },
361 { 7, 9, -8 }, { 8, 10, -10 }, { 9, 11, -10 }, { 10, 12, -12 },
362 { 10, 13, -12 }, { 12, 14, -12 }, { 15, 15, -12 }
369 { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
370 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
371 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 }, { 5, 12, -12 },
372 { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
377 .bpp = DSC_BPP(8), .bpc = 10,
380 * DSC model/pre-SCR-cfg has 8 for range_max_qp[0], however
381 * VESA DSC 1.1 Table E-5 sets it to 4.
383 { 0, 4, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
384 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
385 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 },
386 { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
393 { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
394 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
395 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 },
396 { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 },
397 { 21, 23, -12 }
402 .bpp = DSC_BPP(10), .bpc = 8,
404 { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
405 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
406 { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 11, -10 },
407 { 5, 12, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
412 .bpp = DSC_BPP(10), .bpc = 10,
414 { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
415 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
416 { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 15, -10 },
417 { 9, 16, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
422 .bpp = DSC_BPP(10), .bpc = 12,
424 { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
425 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
426 { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
427 { 13, 19, -10 }, { 13, 20, -12 }, { 15, 21, -12 },
428 { 21, 23, -12 }
435 { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
436 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
437 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 },
438 { 5, 12, -12 }, { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
443 .bpp = DSC_BPP(12), .bpc = 10,
445 { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
446 { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
447 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 },
448 { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
455 { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
456 { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
457 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 },
458 { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 },
459 { 21, 23, -12 }
466 { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
467 { 1, 2, 2 }, { 1, 3, 0 }, { 1, 4, -2 }, { 2, 4, -4 },
468 { 3, 4, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 5, 7, -10 },
469 { 5, 8, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
474 .bpp = DSC_BPP(15), .bpc = 10,
476 { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
477 { 5, 6, 2 }, { 5, 7, 0 }, { 5, 8, -2 }, { 6, 8, -4 },
478 { 7, 8, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 9, 11, -10 },
479 { 9, 12, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
486 { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
487 { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
488 { 11, 12, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
489 { 13, 15, -10 }, { 13, 16, -12 }, { 15, 21, -12 },
490 { 21, 23, -12 }
501 * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
507 { 0, 4, 0 }, { 1, 6, -2 }, { 3, 8, -2 }, { 4, 8, -4 },
508 { 5, 9, -6 }, { 5, 9, -6 }, { 6, 9, -6 }, { 6, 10, -8 },
509 { 7, 11, -8 }, { 8, 12, -10 }, { 9, 12, -10 }, { 10, 12, -12 },
510 { 10, 12, -12 }, { 11, 12, -12 }, { 13, 14, -12 }
515 .bpp = DSC_BPP(6), .bpc = 10,
517 { 0, 8, 0 }, { 3, 10, -2 }, { 7, 12, -2 }, { 8, 12, -4 },
518 { 9, 13, -6 }, { 9, 13, -6 }, { 10, 13, -6 }, { 10, 14, -8 },
519 { 11, 15, -8 }, { 12, 16, -10 }, { 13, 16, -10 },
520 { 14, 16, -12 }, { 14, 16, -12 }, { 15, 16, -12 },
521 { 17, 18, -12 }
528 { 0, 12, 0 }, { 5, 14, -2 }, { 11, 16, -2 }, { 12, 16, -4 },
529 { 13, 17, -6 }, { 13, 17, -6 }, { 14, 17, -6 }, { 14, 18, -8 },
530 { 15, 19, -8 }, { 16, 20, -10 }, { 17, 20, -10 },
531 { 18, 20, -12 }, { 18, 20, -12 }, { 19, 20, -12 },
532 { 21, 22, -12 }
539 { 0, 16, 0 }, { 7, 18, -2 }, { 15, 20, -2 }, { 16, 20, -4 },
540 { 17, 21, -6 }, { 17, 21, -6 }, { 18, 21, -6 }, { 18, 22, -8 },
541 { 19, 23, -8 }, { 20, 24, -10 }, { 21, 24, -10 },
542 { 22, 24, -12 }, { 22, 24, -12 }, { 23, 24, -12 },
543 { 25, 26, -12 }
550 { 0, 20, 0 }, { 9, 22, -2 }, { 19, 24, -2 }, { 20, 24, -4 },
551 { 21, 25, -6 }, { 21, 25, -6 }, { 22, 25, -6 }, { 22, 26, -8 },
552 { 23, 27, -8 }, { 24, 28, -10 }, { 25, 28, -10 },
553 { 26, 28, -12 }, { 26, 28, -12 }, { 27, 28, -12 },
554 { 29, 30, -12 }
561 { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
562 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
563 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
564 { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
569 .bpp = DSC_BPP(8), .bpc = 10,
571 { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
572 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
573 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
574 { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
581 { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
582 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
583 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
584 { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
585 { 20, 21, -12 }
592 { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
593 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
594 { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
595 { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
596 { 24, 25, -12 }
603 { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
604 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
605 { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
606 { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
607 { 28, 29, -12 }
612 .bpp = DSC_BPP(10), .bpc = 8,
614 { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
615 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
616 { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
617 { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
622 .bpp = DSC_BPP(10), .bpc = 10,
624 { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
625 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
626 { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
627 { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
632 .bpp = DSC_BPP(10), .bpc = 12,
634 { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
635 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
636 { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
637 { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
638 { 19, 20, -12 }
643 .bpp = DSC_BPP(10), .bpc = 14,
645 { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
646 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
647 { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
648 { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
649 { 23, 24, -12 }
654 .bpp = DSC_BPP(10), .bpc = 16,
656 { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
657 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
658 { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
659 { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
660 { 27, 28, -12 }
667 { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
668 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
669 { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
670 { 5, 9, -12 }, { 7, 10, -12 }, { 10, 11, -12 }
675 .bpp = DSC_BPP(12), .bpc = 10,
677 { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
678 { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
679 { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
680 { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
687 { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
688 { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
689 { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
690 { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
691 { 18, 19, -12 }
698 { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
699 { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
700 { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
701 { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
702 { 22, 23, -12 }
709 { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
710 { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
711 { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
712 { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
713 { 26, 27, -12 }
720 { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
721 { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
722 { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
723 { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
728 .bpp = DSC_BPP(15), .bpc = 10,
730 { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
731 { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
732 { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
733 { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
740 { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
741 { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
742 { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
743 { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
744 { 16, 17, -12 }
751 { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
752 { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
753 { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
754 { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
755 { 20, 21, -12 }
762 { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
763 { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
764 { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
765 { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
766 { 24, 25, -12 }
777 * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
783 { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
784 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
785 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
786 { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
791 .bpp = DSC_BPP(6), .bpc = 10,
793 { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
794 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
795 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
796 { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
803 { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
804 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
805 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
806 { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
807 { 20, 21, -12 }
814 { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
815 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
816 { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
817 { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
818 { 24, 25, -12 }
825 { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
826 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
827 { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
828 { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
829 { 28, 29, -12 }
836 { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
837 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
838 { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
839 { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
844 .bpp = DSC_BPP(7), .bpc = 10,
846 { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
847 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
848 { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
849 { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
856 { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
857 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
858 { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
859 { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
860 { 19, 20, -12 }
867 { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
868 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
869 { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
870 { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
871 { 23, 24, -12 }
878 { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
879 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
880 { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
881 { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
882 { 27, 28, -12 }
889 { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
890 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
891 { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
892 { 5, 9, -12 }, { 7, 10, -12 }, { 10, 11, -12 }
897 .bpp = DSC_BPP(8), .bpc = 10,
899 { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
900 { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
901 { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
902 { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
909 { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
910 { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
911 { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
912 { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
913 { 18, 19, -12 }
920 { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
921 { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
922 { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
923 { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
924 { 22, 23, -12 }
931 { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
932 { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
933 { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
934 { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
935 { 26, 27, -12 }
940 .bpp = DSC_BPP(10), .bpc = 8,
942 { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
943 { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
944 { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
945 { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
950 .bpp = DSC_BPP(10), .bpc = 10,
952 { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
953 { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
954 { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
955 { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
960 .bpp = DSC_BPP(10), .bpc = 12,
962 { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
963 { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
964 { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
965 { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
966 { 16, 17, -12 }
971 .bpp = DSC_BPP(10), .bpc = 14,
973 { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
974 { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
975 { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
976 { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
977 { 20, 21, -12 }
982 .bpp = DSC_BPP(10), .bpc = 16,
984 { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
985 { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
986 { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
987 { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
988 { 24, 25, -12 }
999 * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
1005 { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
1006 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1007 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
1008 { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
1013 .bpp = DSC_BPP(4), .bpc = 10,
1015 { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
1016 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1017 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
1018 { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
1025 { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
1026 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1027 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
1028 { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
1029 { 20, 21, -12 }
1036 { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
1037 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1038 { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
1039 { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
1040 { 24, 25, -12 }
1047 { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
1048 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1049 { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
1050 { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
1051 { 28, 29, -12 }
1058 { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
1059 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1060 { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
1061 { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
1066 .bpp = DSC_BPP(5), .bpc = 10,
1068 { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
1069 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1070 { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
1071 { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
1078 { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
1079 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1080 { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
1081 { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
1082 { 19, 20, -12 }
1089 { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
1090 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1091 { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
1092 { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
1093 { 23, 24, -12 }
1100 { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
1101 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1102 { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
1103 { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
1104 { 27, 28, -12 }
1111 { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
1112 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1113 { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
1114 { 5, 9, -12 }, { 7, 10, -12 }, { 10, 12, -12 }
1119 .bpp = DSC_BPP(6), .bpc = 10,
1121 { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
1122 { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1123 { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
1124 { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
1131 { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
1132 { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1133 { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
1134 { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
1135 { 18, 19, -12 }
1142 { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
1143 { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1144 { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
1145 { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
1146 { 22, 23, -12 }
1153 { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
1154 { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1155 { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
1156 { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
1157 { 26, 27, -12 }
1164 { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
1165 { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
1166 { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
1167 { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
1172 .bpp = DSC_BPP(8), .bpc = 10,
1174 { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
1175 { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
1176 { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
1177 { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
1184 { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
1185 { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
1186 { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
1187 { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
1188 { 16, 17, -12 }
1195 { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
1196 { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
1197 { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
1198 { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
1199 { 20, 21, -12 }
1206 { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
1207 { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
1208 { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
1209 { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
1210 { 24, 25, -12 }
1232 * drm_dsc_setup_rc_params() - Set parameters and limits for RC model in
1240 * Return: 0 or -error code in case of an error
1248 if (WARN_ON_ONCE(!vdsc_cfg->bits_per_pixel || in drm_dsc_setup_rc_params()
1249 !vdsc_cfg->bits_per_component)) in drm_dsc_setup_rc_params()
1250 return -EINVAL; in drm_dsc_setup_rc_params()
1266 return -EINVAL; in drm_dsc_setup_rc_params()
1270 vdsc_cfg->bits_per_pixel, in drm_dsc_setup_rc_params()
1271 vdsc_cfg->bits_per_component); in drm_dsc_setup_rc_params()
1273 return -EINVAL; in drm_dsc_setup_rc_params()
1275 vdsc_cfg->first_line_bpg_offset = rc_params->first_line_bpg_offset; in drm_dsc_setup_rc_params()
1276 vdsc_cfg->initial_xmit_delay = rc_params->initial_xmit_delay; in drm_dsc_setup_rc_params()
1277 vdsc_cfg->initial_offset = rc_params->initial_offset; in drm_dsc_setup_rc_params()
1278 vdsc_cfg->flatness_min_qp = rc_params->flatness_min_qp; in drm_dsc_setup_rc_params()
1279 vdsc_cfg->flatness_max_qp = rc_params->flatness_max_qp; in drm_dsc_setup_rc_params()
1280 vdsc_cfg->rc_quant_incr_limit0 = rc_params->rc_quant_incr_limit0; in drm_dsc_setup_rc_params()
1281 vdsc_cfg->rc_quant_incr_limit1 = rc_params->rc_quant_incr_limit1; in drm_dsc_setup_rc_params()
1284 vdsc_cfg->rc_range_params[i].range_min_qp = in drm_dsc_setup_rc_params()
1285 rc_params->rc_range_params[i].range_min_qp; in drm_dsc_setup_rc_params()
1286 vdsc_cfg->rc_range_params[i].range_max_qp = in drm_dsc_setup_rc_params()
1287 rc_params->rc_range_params[i].range_max_qp; in drm_dsc_setup_rc_params()
1292 vdsc_cfg->rc_range_params[i].range_bpg_offset = in drm_dsc_setup_rc_params()
1293 rc_params->rc_range_params[i].range_bpg_offset & in drm_dsc_setup_rc_params()
1302 * drm_dsc_compute_rc_parameters() - Write rate control
1321 if (vdsc_cfg->native_420 || vdsc_cfg->native_422) { in drm_dsc_compute_rc_parameters()
1323 groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width / 2, in drm_dsc_compute_rc_parameters()
1327 vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width / 2 * in drm_dsc_compute_rc_parameters()
1328 vdsc_cfg->bits_per_pixel, in drm_dsc_compute_rc_parameters()
1332 groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width, in drm_dsc_compute_rc_parameters()
1336 vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width * in drm_dsc_compute_rc_parameters()
1337 vdsc_cfg->bits_per_pixel, in drm_dsc_compute_rc_parameters()
1341 if (vdsc_cfg->convert_rgb) in drm_dsc_compute_rc_parameters()
1342 num_extra_mux_bits = 3 * (vdsc_cfg->mux_word_size + in drm_dsc_compute_rc_parameters()
1343 (4 * vdsc_cfg->bits_per_component + 4) in drm_dsc_compute_rc_parameters()
1344 - 2); in drm_dsc_compute_rc_parameters()
1345 else if (vdsc_cfg->native_422) in drm_dsc_compute_rc_parameters()
1346 num_extra_mux_bits = 4 * vdsc_cfg->mux_word_size + in drm_dsc_compute_rc_parameters()
1347 (4 * vdsc_cfg->bits_per_component + 4) + in drm_dsc_compute_rc_parameters()
1348 3 * (4 * vdsc_cfg->bits_per_component) - 2; in drm_dsc_compute_rc_parameters()
1350 num_extra_mux_bits = 3 * vdsc_cfg->mux_word_size + in drm_dsc_compute_rc_parameters()
1351 (4 * vdsc_cfg->bits_per_component + 4) + in drm_dsc_compute_rc_parameters()
1352 2 * (4 * vdsc_cfg->bits_per_component) - 2; in drm_dsc_compute_rc_parameters()
1354 slice_bits = 8 * vdsc_cfg->slice_chunk_size * vdsc_cfg->slice_height; in drm_dsc_compute_rc_parameters()
1357 ((slice_bits - num_extra_mux_bits) % vdsc_cfg->mux_word_size)) in drm_dsc_compute_rc_parameters()
1358 num_extra_mux_bits--; in drm_dsc_compute_rc_parameters()
1360 if (groups_per_line < vdsc_cfg->initial_scale_value - 8) in drm_dsc_compute_rc_parameters()
1361 vdsc_cfg->initial_scale_value = groups_per_line + 8; in drm_dsc_compute_rc_parameters()
1364 if (vdsc_cfg->initial_scale_value > 8) in drm_dsc_compute_rc_parameters()
1365 vdsc_cfg->scale_decrement_interval = groups_per_line / in drm_dsc_compute_rc_parameters()
1366 (vdsc_cfg->initial_scale_value - 8); in drm_dsc_compute_rc_parameters()
1368 vdsc_cfg->scale_decrement_interval = DSC_SCALE_DECREMENT_INTERVAL_MAX; in drm_dsc_compute_rc_parameters()
1370 vdsc_cfg->final_offset = vdsc_cfg->rc_model_size - in drm_dsc_compute_rc_parameters()
1371 (vdsc_cfg->initial_xmit_delay * in drm_dsc_compute_rc_parameters()
1372 vdsc_cfg->bits_per_pixel + 8) / 16 + num_extra_mux_bits; in drm_dsc_compute_rc_parameters()
1374 if (vdsc_cfg->final_offset >= vdsc_cfg->rc_model_size) { in drm_dsc_compute_rc_parameters()
1376 return -ERANGE; in drm_dsc_compute_rc_parameters()
1379 final_scale = (vdsc_cfg->rc_model_size * 8) / in drm_dsc_compute_rc_parameters()
1380 (vdsc_cfg->rc_model_size - vdsc_cfg->final_offset); in drm_dsc_compute_rc_parameters()
1381 if (vdsc_cfg->slice_height > 1) in drm_dsc_compute_rc_parameters()
1387 vdsc_cfg->nfl_bpg_offset = DIV_ROUND_UP((vdsc_cfg->first_line_bpg_offset << 11), in drm_dsc_compute_rc_parameters()
1388 (vdsc_cfg->slice_height - 1)); in drm_dsc_compute_rc_parameters()
1390 vdsc_cfg->nfl_bpg_offset = 0; in drm_dsc_compute_rc_parameters()
1393 groups_total = groups_per_line * vdsc_cfg->slice_height; in drm_dsc_compute_rc_parameters()
1396 vdsc_cfg->slice_bpg_offset = DIV_ROUND_UP(((vdsc_cfg->rc_model_size - in drm_dsc_compute_rc_parameters()
1397 vdsc_cfg->initial_offset + in drm_dsc_compute_rc_parameters()
1404 * finaloffset/((NflBpgOffset + SliceBpgOffset)*8(finalscale - 1.125)) in drm_dsc_compute_rc_parameters()
1408 vdsc_cfg->scale_increment_interval = in drm_dsc_compute_rc_parameters()
1409 (vdsc_cfg->final_offset * (1 << 11)) / in drm_dsc_compute_rc_parameters()
1410 ((vdsc_cfg->nfl_bpg_offset + in drm_dsc_compute_rc_parameters()
1411 vdsc_cfg->slice_bpg_offset) * in drm_dsc_compute_rc_parameters()
1412 (final_scale - 9)); in drm_dsc_compute_rc_parameters()
1418 vdsc_cfg->scale_increment_interval = 0; in drm_dsc_compute_rc_parameters()
1426 rbs_min = vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset + in drm_dsc_compute_rc_parameters()
1427 DIV_ROUND_UP(vdsc_cfg->initial_xmit_delay * in drm_dsc_compute_rc_parameters()
1428 vdsc_cfg->bits_per_pixel, 16) + in drm_dsc_compute_rc_parameters()
1429 groups_per_line * vdsc_cfg->first_line_bpg_offset; in drm_dsc_compute_rc_parameters()
1431 hrd_delay = DIV_ROUND_UP((rbs_min * 16), vdsc_cfg->bits_per_pixel); in drm_dsc_compute_rc_parameters()
1432 vdsc_cfg->rc_bits = (hrd_delay * vdsc_cfg->bits_per_pixel) / 16; in drm_dsc_compute_rc_parameters()
1433 vdsc_cfg->initial_dec_delay = hrd_delay - vdsc_cfg->initial_xmit_delay; in drm_dsc_compute_rc_parameters()
1440 * drm_dsc_get_bpp_int() - Get integer bits per pixel value for the given DRM DSC config
1447 WARN_ON_ONCE(vdsc_cfg->bits_per_pixel & 0xf); in drm_dsc_get_bpp_int()
1448 return vdsc_cfg->bits_per_pixel >> 4; in drm_dsc_get_bpp_int()
1453 * drm_dsc_initial_scale_value() - Calculate the initial scale value for the given DSC config
1460 return 8 * dsc->rc_model_size / (dsc->rc_model_size - dsc->initial_offset); in drm_dsc_initial_scale_value()
1465 * drm_dsc_flatness_det_thresh() - Calculate the flatness_det_thresh for the given DSC config
1472 return 2 << (dsc->bits_per_component - 8); in drm_dsc_flatness_det_thresh()