Lines Matching +full:2 +full:- +full:8

1 // SPDX-License-Identifier: MIT
36 * drm_dsc_dp_pps_header_init() - Initializes the PPS Header
50 pps_header->HB1 = DP_SDP_PPS;
51 pps_header->HB2 = DP_SDP_PPS_HEADER_PAYLOAD_BYTES_MINUS_1;
56 * drm_dsc_dp_rc_buffer_size - get rc buffer size in bytes
58 * @rc_buffer_size: number of blocks - 1, according to DPCD offset 63h
83 * drm_dsc_pps_payload_pack() - Populates the DSC PPS
111 pps_payload->dsc_version =
112 dsc_cfg->dsc_version_minor |
113 dsc_cfg->dsc_version_major << DSC_PPS_VERSION_MAJOR_SHIFT;
115 /* PPS 1, 2 is 0 */
118 pps_payload->pps_3 =
119 dsc_cfg->line_buf_depth |
120 dsc_cfg->bits_per_component << DSC_PPS_BPC_SHIFT;
123 pps_payload->pps_4 =
124 ((dsc_cfg->bits_per_pixel & DSC_PPS_BPP_HIGH_MASK) >>
126 dsc_cfg->vbr_enable << DSC_PPS_VBR_EN_SHIFT |
127 dsc_cfg->simple_422 << DSC_PPS_SIMPLE422_SHIFT |
128 dsc_cfg->convert_rgb << DSC_PPS_CONVERT_RGB_SHIFT |
129 dsc_cfg->block_pred_enable << DSC_PPS_BLOCK_PRED_EN_SHIFT;
132 pps_payload->bits_per_pixel_low =
133 (dsc_cfg->bits_per_pixel & DSC_PPS_LSB_MASK);
137 * for data spanning 2 bytes. Use a macro cpu_to_be16() to convert
143 pps_payload->pic_height = cpu_to_be16(dsc_cfg->pic_height);
145 /* PPS 8, 9 */
146 pps_payload->pic_width = cpu_to_be16(dsc_cfg->pic_width);
149 pps_payload->slice_height = cpu_to_be16(dsc_cfg->slice_height);
152 pps_payload->slice_width = cpu_to_be16(dsc_cfg->slice_width);
155 pps_payload->chunk_size = cpu_to_be16(dsc_cfg->slice_chunk_size);
158 pps_payload->initial_xmit_delay_high =
159 ((dsc_cfg->initial_xmit_delay &
164 pps_payload->initial_xmit_delay_low =
165 (dsc_cfg->initial_xmit_delay & DSC_PPS_LSB_MASK);
168 pps_payload->initial_dec_delay =
169 cpu_to_be16(dsc_cfg->initial_dec_delay);
174 pps_payload->initial_scale_value =
175 dsc_cfg->initial_scale_value;
178 pps_payload->scale_increment_interval =
179 cpu_to_be16(dsc_cfg->scale_increment_interval);
182 pps_payload->scale_decrement_interval_high =
183 ((dsc_cfg->scale_decrement_interval &
188 pps_payload->scale_decrement_interval_low =
189 (dsc_cfg->scale_decrement_interval & DSC_PPS_LSB_MASK);
194 pps_payload->first_line_bpg_offset =
195 dsc_cfg->first_line_bpg_offset;
198 pps_payload->nfl_bpg_offset =
199 cpu_to_be16(dsc_cfg->nfl_bpg_offset);
202 pps_payload->slice_bpg_offset =
203 cpu_to_be16(dsc_cfg->slice_bpg_offset);
206 pps_payload->initial_offset =
207 cpu_to_be16(dsc_cfg->initial_offset);
210 pps_payload->final_offset = cpu_to_be16(dsc_cfg->final_offset);
213 pps_payload->flatness_min_qp = dsc_cfg->flatness_min_qp;
216 pps_payload->flatness_max_qp = dsc_cfg->flatness_max_qp;
219 pps_payload->rc_model_size = cpu_to_be16(dsc_cfg->rc_model_size);
222 pps_payload->rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST;
225 pps_payload->rc_quant_incr_limit0 =
226 dsc_cfg->rc_quant_incr_limit0;
229 pps_payload->rc_quant_incr_limit1 =
230 dsc_cfg->rc_quant_incr_limit1;
233 pps_payload->rc_tgt_offset = DSC_RC_TGT_OFFSET_LO_CONST |
236 /* PPS 44 - 57 */
237 for (i = 0; i < DSC_NUM_BUF_RANGES - 1; i++)
238 pps_payload->rc_buf_thresh[i] =
239 dsc_cfg->rc_buf_thresh[i];
241 /* PPS 58 - 87 */
247 pps_payload->rc_range_parameters[i] =
248 cpu_to_be16((dsc_cfg->rc_range_params[i].range_min_qp <<
250 (dsc_cfg->rc_range_params[i].range_max_qp <<
252 (dsc_cfg->rc_range_params[i].range_bpg_offset));
256 pps_payload->native_422_420 = dsc_cfg->native_422 |
257 dsc_cfg->native_420 << DSC_PPS_NATIVE_420_SHIFT;
260 pps_payload->second_line_bpg_offset =
261 dsc_cfg->second_line_bpg_offset;
264 pps_payload->nsl_bpg_offset =
265 cpu_to_be16(dsc_cfg->nsl_bpg_offset);
268 pps_payload->second_line_offset_adj =
269 cpu_to_be16(dsc_cfg->second_line_offset_adj);
271 /* PPS 94 - 127 are O */
276 * drm_dsc_set_const_params() - Set DSC parameters considered typically
284 if (!vdsc_cfg->rc_model_size)
285 vdsc_cfg->rc_model_size = DSC_RC_MODEL_SIZE_CONST;
286 vdsc_cfg->rc_edge_factor = DSC_RC_EDGE_FACTOR_CONST;
287 vdsc_cfg->rc_tgt_offset_high = DSC_RC_TGT_OFFSET_HI_CONST;
288 vdsc_cfg->rc_tgt_offset_low = DSC_RC_TGT_OFFSET_LO_CONST;
290 if (vdsc_cfg->bits_per_component <= 10)
291 vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
293 vdsc_cfg->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC;
304 * drm_dsc_set_rc_buf_thresh() - Set thresholds for the RC model
314 DSC_NUM_BUF_RANGES - 1);
316 ARRAY_SIZE(vdsc_cfg->rc_buf_thresh));
319 vdsc_cfg->rc_buf_thresh[i] = drm_dsc_rc_buf_thresh[i] >> 6;
325 if (vdsc_cfg->bits_per_pixel == 6 << 4) {
326 vdsc_cfg->rc_buf_thresh[12] = 7936 >> 6;
327 vdsc_cfg->rc_buf_thresh[13] = 8000 >> 6;
355 * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
359 .bpp = DSC_BPP(6), .bpc = 8,
361 { 0, 2, 0 }, { 1, 4, -2 }, { 3, 6, -2 }, { 4, 6, -4 },
362 { 5, 7, -6 }, { 5, 7, -6 }, { 6, 7, -6 }, { 6, 8, -8 },
363 { 7, 9, -8 }, { 8, 10, -10 }, { 9, 11, -10 }, { 10, 12, -12 },
364 { 10, 13, -12 }, { 12, 14, -12 }, { 15, 15, -12 }
369 .bpp = DSC_BPP(8), .bpc = 8,
371 { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
372 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
373 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 }, { 5, 12, -12 },
374 { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
379 .bpp = DSC_BPP(8), .bpc = 10,
382 * DSC model/pre-SCR-cfg has 8 for range_max_qp[0], however
383 * VESA DSC 1.1 Table E-5 sets it to 4.
385 { 0, 4, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
386 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
387 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 },
388 { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
393 .bpp = DSC_BPP(8), .bpc = 12,
395 { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
396 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
397 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 },
398 { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 },
399 { 21, 23, -12 }
404 .bpp = DSC_BPP(10), .bpc = 8,
406 { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
407 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
408 { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 11, -10 },
409 { 5, 12, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
416 { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
417 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
418 { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 15, -10 },
419 { 9, 16, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
426 { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
427 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
428 { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
429 { 13, 19, -10 }, { 13, 20, -12 }, { 15, 21, -12 },
430 { 21, 23, -12 }
435 .bpp = DSC_BPP(12), .bpc = 8,
437 { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
438 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
439 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 11, -10 },
440 { 5, 12, -12 }, { 5, 13, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
447 { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
448 { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
449 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 15, -10 }, { 9, 16, -12 },
450 { 9, 17, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
457 { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
458 { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
459 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 19, -10 },
460 { 13, 20, -12 }, { 13, 21, -12 }, { 15, 21, -12 },
461 { 21, 23, -12 }
466 .bpp = DSC_BPP(15), .bpc = 8,
468 { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
469 { 1, 2, 2 }, { 1, 3, 0 }, { 1, 4, -2 }, { 2, 4, -4 },
470 { 3, 4, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 5, 7, -10 },
471 { 5, 8, -12 }, { 7, 13, -12 }, { 13, 15, -12 }
478 { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
479 { 5, 6, 2 }, { 5, 7, 0 }, { 5, 8, -2 }, { 6, 8, -4 },
480 { 7, 8, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 9, 11, -10 },
481 { 9, 12, -12 }, { 11, 17, -12 }, { 17, 19, -12 }
488 { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
489 { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
490 { 11, 12, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
491 { 13, 15, -10 }, { 13, 16, -12 }, { 15, 21, -12 },
492 { 21, 23, -12 }
500 * Selected Rate Control Related Parameter Recommended Values from DSC v1.2, v1.2a, v1.2b and
503 * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
507 .bpp = DSC_BPP(6), .bpc = 8,
509 { 0, 4, 0 }, { 1, 6, -2 }, { 3, 8, -2 }, { 4, 8, -4 },
510 { 5, 9, -6 }, { 5, 9, -6 }, { 6, 9, -6 }, { 6, 10, -8 },
511 { 7, 11, -8 }, { 8, 12, -10 }, { 9, 12, -10 }, { 10, 12, -12 },
512 { 10, 12, -12 }, { 11, 12, -12 }, { 13, 14, -12 }
519 { 0, 8, 0 }, { 3, 10, -2 }, { 7, 12, -2 }, { 8, 12, -4 },
520 { 9, 13, -6 }, { 9, 13, -6 }, { 10, 13, -6 }, { 10, 14, -8 },
521 { 11, 15, -8 }, { 12, 16, -10 }, { 13, 16, -10 },
522 { 14, 16, -12 }, { 14, 16, -12 }, { 15, 16, -12 },
523 { 17, 18, -12 }
530 { 0, 12, 0 }, { 5, 14, -2 }, { 11, 16, -2 }, { 12, 16, -4 },
531 { 13, 17, -6 }, { 13, 17, -6 }, { 14, 17, -6 }, { 14, 18, -8 },
532 { 15, 19, -8 }, { 16, 20, -10 }, { 17, 20, -10 },
533 { 18, 20, -12 }, { 18, 20, -12 }, { 19, 20, -12 },
534 { 21, 22, -12 }
541 { 0, 16, 0 }, { 7, 18, -2 }, { 15, 20, -2 }, { 16, 20, -4 },
542 { 17, 21, -6 }, { 17, 21, -6 }, { 18, 21, -6 }, { 18, 22, -8 },
543 { 19, 23, -8 }, { 20, 24, -10 }, { 21, 24, -10 },
544 { 22, 24, -12 }, { 22, 24, -12 }, { 23, 24, -12 },
545 { 25, 26, -12 }
552 { 0, 20, 0 }, { 9, 22, -2 }, { 19, 24, -2 }, { 20, 24, -4 },
553 { 21, 25, -6 }, { 21, 25, -6 }, { 22, 25, -6 }, { 22, 26, -8 },
554 { 23, 27, -8 }, { 24, 28, -10 }, { 25, 28, -10 },
555 { 26, 28, -12 }, { 26, 28, -12 }, { 27, 28, -12 },
556 { 29, 30, -12 }
561 .bpp = DSC_BPP(8), .bpc = 8,
563 { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
564 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
565 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
566 { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
571 .bpp = DSC_BPP(8), .bpc = 10,
573 { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
574 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
575 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
576 { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
581 .bpp = DSC_BPP(8), .bpc = 12,
583 { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
584 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
585 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
586 { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
587 { 20, 21, -12 }
592 .bpp = DSC_BPP(8), .bpc = 14,
594 { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
595 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
596 { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
597 { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
598 { 24, 25, -12 }
603 .bpp = DSC_BPP(8), .bpc = 16,
605 { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
606 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
607 { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
608 { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
609 { 28, 29, -12 }
614 .bpp = DSC_BPP(10), .bpc = 8,
616 { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
617 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
618 { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
619 { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
626 { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
627 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
628 { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
629 { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
636 { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
637 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
638 { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
639 { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
640 { 19, 20, -12 }
647 { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
648 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
649 { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
650 { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
651 { 23, 24, -12 }
658 { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
659 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
660 { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
661 { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
662 { 27, 28, -12 }
667 .bpp = DSC_BPP(12), .bpc = 8,
669 { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
670 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
671 { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
672 { 5, 9, -12 }, { 7, 10, -12 }, { 10, 11, -12 }
679 { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
680 { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
681 { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
682 { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
689 { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
690 { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
691 { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
692 { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
693 { 18, 19, -12 }
700 { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
701 { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
702 { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
703 { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
704 { 22, 23, -12 }
711 { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
712 { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
713 { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
714 { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
715 { 26, 27, -12 }
720 .bpp = DSC_BPP(15), .bpc = 8,
722 { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
723 { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
724 { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
725 { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
732 { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
733 { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
734 { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
735 { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
742 { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
743 { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
744 { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
745 { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
746 { 16, 17, -12 }
753 { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
754 { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
755 { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
756 { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
757 { 20, 21, -12 }
764 { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
765 { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
766 { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
767 { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
768 { 24, 25, -12 }
776 * Selected Rate Control Related Parameter Recommended Values for 4:2:2 from
777 * DSC v1.2, v1.2a, v1.2b
779 * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
783 .bpp = DSC_BPP(6), .bpc = 8,
785 { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
786 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
787 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
788 { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
795 { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
796 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
797 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
798 { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
805 { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
806 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
807 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
808 { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
809 { 20, 21, -12 }
816 { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
817 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
818 { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
819 { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
820 { 24, 25, -12 }
827 { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
828 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
829 { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
830 { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
831 { 28, 29, -12 }
836 .bpp = DSC_BPP(7), .bpc = 8,
838 { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
839 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
840 { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
841 { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
848 { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
849 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
850 { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
851 { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
858 { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
859 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
860 { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
861 { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
862 { 19, 20, -12 }
869 { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
870 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
871 { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
872 { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
873 { 23, 24, -12 }
880 { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
881 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
882 { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
883 { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
884 { 27, 28, -12 }
889 .bpp = DSC_BPP(8), .bpc = 8,
891 { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
892 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
893 { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
894 { 5, 9, -12 }, { 7, 10, -12 }, { 10, 11, -12 }
899 .bpp = DSC_BPP(8), .bpc = 10,
901 { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
902 { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
903 { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
904 { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
909 .bpp = DSC_BPP(8), .bpc = 12,
911 { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
912 { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
913 { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
914 { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
915 { 18, 19, -12 }
920 .bpp = DSC_BPP(8), .bpc = 14,
922 { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
923 { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
924 { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
925 { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
926 { 22, 23, -12 }
931 .bpp = DSC_BPP(8), .bpc = 16,
933 { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
934 { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
935 { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
936 { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
937 { 26, 27, -12 }
942 .bpp = DSC_BPP(10), .bpc = 8,
944 { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
945 { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
946 { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
947 { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
954 { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
955 { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
956 { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
957 { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
964 { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
965 { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
966 { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
967 { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
968 { 16, 17, -12 }
975 { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
976 { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
977 { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
978 { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
979 { 20, 21, -12 }
986 { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
987 { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
988 { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
989 { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
990 { 24, 25, -12 }
998 * Selected Rate Control Related Parameter Recommended Values for 4:2:2 from
999 * DSC v1.2, v1.2a, v1.2b
1001 * Cross-checked against C Model releases: DSC_model_20161212 and 20210623
1005 .bpp = DSC_BPP(4), .bpc = 8,
1007 { 0, 4, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
1008 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1009 { 3, 9, -8 }, { 3, 10, -10 }, { 5, 10, -10 }, { 5, 11, -12 },
1010 { 5, 11, -12 }, { 9, 12, -12 }, { 12, 13, -12 }
1017 { 0, 8, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 5, 10, -2 },
1018 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1019 { 7, 13, -8 }, { 7, 14, -10 }, { 9, 14, -10 }, { 9, 15, -12 },
1020 { 9, 15, -12 }, { 13, 16, -12 }, { 16, 17, -12 }
1027 { 0, 12, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 9, 14, -2 },
1028 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1029 { 11, 17, -8 }, { 11, 18, -10 }, { 13, 18, -10 },
1030 { 13, 19, -12 }, { 13, 19, -12 }, { 17, 20, -12 },
1031 { 20, 21, -12 }
1038 { 0, 12, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 12, 17, -2 },
1039 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1040 { 15, 21, -8 }, { 15, 22, -10 }, { 17, 22, -10 },
1041 { 17, 23, -12 }, { 17, 23, -12 }, { 21, 24, -12 },
1042 { 24, 25, -12 }
1049 { 0, 12, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 15, 20, -2 },
1050 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1051 { 19, 25, -8 }, { 19, 26, -10 }, { 21, 26, -10 },
1052 { 21, 27, -12 }, { 21, 27, -12 }, { 25, 28, -12 },
1053 { 28, 29, -12 }
1058 .bpp = DSC_BPP(5), .bpc = 8,
1060 { 0, 3, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 2, 6, -2 },
1061 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1062 { 3, 9, -8 }, { 3, 9, -10 }, { 5, 10, -10 }, { 5, 10, -10 },
1063 { 5, 11, -12 }, { 7, 11, -12 }, { 11, 12, -12 }
1070 { 0, 7, 2 }, { 4, 8, 0 }, { 5, 9, 0 }, { 6, 10, -2 },
1071 { 7, 11, -4 }, { 7, 11, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1072 { 7, 13, -8 }, { 7, 13, -10 }, { 9, 14, -10 }, { 9, 14, -10 },
1073 { 9, 15, -12 }, { 11, 15, -12 }, { 15, 16, -12 }
1080 { 0, 11, 2 }, { 4, 12, 0 }, { 9, 13, 0 }, { 10, 14, -2 },
1081 { 11, 15, -4 }, { 11, 15, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1082 { 11, 17, -8 }, { 11, 17, -10 }, { 13, 18, -10 },
1083 { 13, 18, -10 }, { 13, 19, -12 }, { 15, 19, -12 },
1084 { 19, 20, -12 }
1091 { 0, 11, 2 }, { 5, 13, 0 }, { 11, 15, 0 }, { 13, 18, -2 },
1092 { 15, 19, -4 }, { 15, 19, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1093 { 15, 21, -8 }, { 15, 21, -10 }, { 17, 22, -10 },
1094 { 17, 22, -10 }, { 17, 23, -12 }, { 19, 23, -12 },
1095 { 23, 24, -12 }
1102 { 0, 11, 2 }, { 6, 14, 0 }, { 13, 17, 0 }, { 16, 20, -2 },
1103 { 19, 23, -4 }, { 19, 23, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1104 { 19, 25, -8 }, { 19, 25, -10 }, { 21, 26, -10 },
1105 { 21, 26, -10 }, { 21, 27, -12 }, { 23, 27, -12 },
1106 { 27, 28, -12 }
1111 .bpp = DSC_BPP(6), .bpc = 8,
1113 { 0, 2, 2 }, { 0, 4, 0 }, { 1, 5, 0 }, { 1, 6, -2 },
1114 { 3, 7, -4 }, { 3, 7, -6 }, { 3, 7, -8 }, { 3, 8, -8 },
1115 { 3, 8, -8 }, { 3, 9, -10 }, { 5, 9, -10 }, { 5, 9, -12 },
1116 { 5, 9, -12 }, { 7, 10, -12 }, { 10, 12, -12 }
1123 { 0, 2, 2 }, { 2, 5, 0 }, { 3, 7, 0 }, { 4, 8, -2 },
1124 { 6, 9, -4 }, { 7, 10, -6 }, { 7, 11, -8 }, { 7, 12, -8 },
1125 { 7, 12, -8 }, { 7, 13, -10 }, { 9, 13, -10 }, { 9, 13, -12 },
1126 { 9, 13, -12 }, { 11, 14, -12 }, { 14, 15, -12 }
1133 { 0, 6, 2 }, { 4, 9, 0 }, { 7, 11, 0 }, { 8, 12, -2 },
1134 { 10, 13, -4 }, { 11, 14, -6 }, { 11, 15, -8 }, { 11, 16, -8 },
1135 { 11, 16, -8 }, { 11, 17, -10 }, { 13, 17, -10 },
1136 { 13, 17, -12 }, { 13, 17, -12 }, { 15, 18, -12 },
1137 { 18, 19, -12 }
1144 { 0, 6, 2 }, { 7, 10, 0 }, { 9, 13, 0 }, { 11, 16, -2 },
1145 { 14, 17, -4 }, { 15, 18, -6 }, { 15, 19, -8 }, { 15, 20, -8 },
1146 { 15, 20, -8 }, { 15, 21, -10 }, { 17, 21, -10 },
1147 { 17, 21, -12 }, { 17, 21, -12 }, { 19, 22, -12 },
1148 { 22, 23, -12 }
1155 { 0, 6, 2 }, { 6, 11, 0 }, { 11, 15, 0 }, { 14, 18, -2 },
1156 { 18, 21, -4 }, { 19, 22, -6 }, { 19, 23, -8 }, { 19, 24, -8 },
1157 { 19, 24, -8 }, { 19, 25, -10 }, { 21, 25, -10 },
1158 { 21, 25, -12 }, { 21, 25, -12 }, { 23, 26, -12 },
1159 { 26, 27, -12 }
1164 .bpp = DSC_BPP(8), .bpc = 8,
1166 { 0, 0, 10 }, { 0, 1, 8 }, { 0, 1, 6 }, { 0, 2, 4 },
1167 { 1, 2, 2 }, { 1, 3, 0 }, { 1, 3, -2 }, { 2, 4, -4 },
1168 { 2, 5, -6 }, { 3, 5, -8 }, { 4, 6, -10 }, { 4, 7, -10 },
1169 { 5, 7, -12 }, { 7, 8, -12 }, { 8, 9, -12 }
1174 .bpp = DSC_BPP(8), .bpc = 10,
1176 { 0, 2, 10 }, { 2, 5, 8 }, { 3, 5, 6 }, { 4, 6, 4 },
1177 { 5, 6, 2 }, { 5, 7, 0 }, { 5, 7, -2 }, { 6, 8, -4 },
1178 { 6, 9, -6 }, { 7, 9, -8 }, { 8, 10, -10 }, { 8, 11, -10 },
1179 { 9, 11, -12 }, { 11, 12, -12 }, { 12, 13, -12 }
1184 .bpp = DSC_BPP(8), .bpc = 12,
1186 { 0, 4, 10 }, { 2, 7, 8 }, { 4, 9, 6 }, { 6, 11, 4 },
1187 { 9, 11, 2 }, { 9, 11, 0 }, { 9, 12, -2 }, { 10, 12, -4 },
1188 { 11, 13, -6 }, { 11, 13, -8 }, { 12, 14, -10 },
1189 { 13, 15, -10 }, { 13, 15, -12 }, { 15, 16, -12 },
1190 { 16, 17, -12 }
1195 .bpp = DSC_BPP(8), .bpc = 14,
1197 { 0, 4, 10 }, { 3, 8, 8 }, { 6, 11, 6 }, { 9, 14, 4 },
1198 { 13, 15, 2 }, { 13, 15, 0 }, { 13, 16, -2 }, { 14, 16, -4 },
1199 { 15, 17, -6 }, { 15, 17, -8 }, { 16, 18, -10 },
1200 { 17, 19, -10 }, { 17, 19, -12 }, { 19, 20, -12 },
1201 { 20, 21, -12 }
1206 .bpp = DSC_BPP(8), .bpc = 16,
1208 { 0, 4, 10 }, { 4, 9, 8 }, { 8, 13, 6 }, { 12, 17, 4 },
1209 { 17, 19, 2 }, { 17, 20, 0 }, { 17, 20, -2 }, { 18, 20, -4 },
1210 { 19, 21, -6 }, { 19, 21, -8 }, { 20, 22, -10 },
1211 { 21, 23, -10 }, { 21, 23, -12 }, { 23, 24, -12 },
1212 { 24, 25, -12 }
1234 * drm_dsc_setup_rc_params() - Set parameters and limits for RC model in
1242 * Return: 0 or -error code in case of an error
1250 if (WARN_ON_ONCE(!vdsc_cfg->bits_per_pixel ||
1251 !vdsc_cfg->bits_per_component))
1252 return -EINVAL;
1268 return -EINVAL;
1272 vdsc_cfg->bits_per_pixel,
1273 vdsc_cfg->bits_per_component);
1275 return -EINVAL;
1277 vdsc_cfg->first_line_bpg_offset = rc_params->first_line_bpg_offset;
1278 vdsc_cfg->initial_xmit_delay = rc_params->initial_xmit_delay;
1279 vdsc_cfg->initial_offset = rc_params->initial_offset;
1280 vdsc_cfg->flatness_min_qp = rc_params->flatness_min_qp;
1281 vdsc_cfg->flatness_max_qp = rc_params->flatness_max_qp;
1282 vdsc_cfg->rc_quant_incr_limit0 = rc_params->rc_quant_incr_limit0;
1283 vdsc_cfg->rc_quant_incr_limit1 = rc_params->rc_quant_incr_limit1;
1286 vdsc_cfg->rc_range_params[i].range_min_qp =
1287 rc_params->rc_range_params[i].range_min_qp;
1288 vdsc_cfg->rc_range_params[i].range_max_qp =
1289 rc_params->rc_range_params[i].range_max_qp;
1291 * Range BPG Offset uses 2's complement and is only a 6 bits. So
1294 vdsc_cfg->rc_range_params[i].range_bpg_offset =
1295 rc_params->rc_range_params[i].range_bpg_offset &
1304 * drm_dsc_compute_rc_parameters() - Write rate control
1323 if (vdsc_cfg->native_420 || vdsc_cfg->native_422) {
1325 groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width / 2,
1329 vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width / 2 *
1330 vdsc_cfg->bits_per_pixel,
1331 (8 * 16));
1334 groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width,
1338 vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width *
1339 vdsc_cfg->bits_per_pixel,
1340 (8 * 16));
1343 if (vdsc_cfg->convert_rgb)
1344 num_extra_mux_bits = 3 * (vdsc_cfg->mux_word_size +
1345 (4 * vdsc_cfg->bits_per_component + 4)
1346 - 2);
1347 else if (vdsc_cfg->native_422)
1348 num_extra_mux_bits = 4 * vdsc_cfg->mux_word_size +
1349 (4 * vdsc_cfg->bits_per_component + 4) +
1350 3 * (4 * vdsc_cfg->bits_per_component) - 2;
1352 num_extra_mux_bits = 3 * vdsc_cfg->mux_word_size +
1353 (4 * vdsc_cfg->bits_per_component + 4) +
1354 2 * (4 * vdsc_cfg->bits_per_component) - 2;
1356 slice_bits = 8 * vdsc_cfg->slice_chunk_size * vdsc_cfg->slice_height;
1359 ((slice_bits - num_extra_mux_bits) % vdsc_cfg->mux_word_size))
1360 num_extra_mux_bits--;
1362 if (groups_per_line < vdsc_cfg->initial_scale_value - 8)
1363 vdsc_cfg->initial_scale_value = groups_per_line + 8;
1366 if (vdsc_cfg->initial_scale_value > 8)
1367 vdsc_cfg->scale_decrement_interval = groups_per_line /
1368 (vdsc_cfg->initial_scale_value - 8);
1370 vdsc_cfg->scale_decrement_interval = DSC_SCALE_DECREMENT_INTERVAL_MAX;
1372 vdsc_cfg->final_offset = vdsc_cfg->rc_model_size -
1373 (vdsc_cfg->initial_xmit_delay *
1374 vdsc_cfg->bits_per_pixel + 8) / 16 + num_extra_mux_bits;
1376 if (vdsc_cfg->final_offset >= vdsc_cfg->rc_model_size) {
1378 return -ERANGE;
1381 final_scale = (vdsc_cfg->rc_model_size * 8) /
1382 (vdsc_cfg->rc_model_size - vdsc_cfg->final_offset);
1383 if (vdsc_cfg->slice_height > 1)
1386 * hence we multiply by 2^11 for preserving the
1389 vdsc_cfg->nfl_bpg_offset = DIV_ROUND_UP((vdsc_cfg->first_line_bpg_offset << 11),
1390 (vdsc_cfg->slice_height - 1));
1392 vdsc_cfg->nfl_bpg_offset = 0;
1395 groups_total = groups_per_line * vdsc_cfg->slice_height;
1398 vdsc_cfg->slice_bpg_offset = DIV_ROUND_UP(((vdsc_cfg->rc_model_size -
1399 vdsc_cfg->initial_offset +
1406 * finaloffset/((NflBpgOffset + SliceBpgOffset)*8(finalscale - 1.125))
1408 * we need divide by 2^11 from pstDscCfg values
1410 vdsc_cfg->scale_increment_interval =
1411 (vdsc_cfg->final_offset * (1 << 11)) /
1412 ((vdsc_cfg->nfl_bpg_offset +
1413 vdsc_cfg->slice_bpg_offset) *
1414 (final_scale - 9));
1420 vdsc_cfg->scale_increment_interval = 0;
1428 rbs_min = vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset +
1429 DIV_ROUND_UP(vdsc_cfg->initial_xmit_delay *
1430 vdsc_cfg->bits_per_pixel, 16) +
1431 groups_per_line * vdsc_cfg->first_line_bpg_offset;
1433 hrd_delay = DIV_ROUND_UP((rbs_min * 16), vdsc_cfg->bits_per_pixel);
1434 vdsc_cfg->rc_bits = (hrd_delay * vdsc_cfg->bits_per_pixel) / 16;
1435 vdsc_cfg->initial_dec_delay = hrd_delay - vdsc_cfg->initial_xmit_delay;
1442 * drm_dsc_get_bpp_int() - Get integer bits per pixel value for the given DRM DSC config
1449 WARN_ON_ONCE(vdsc_cfg->bits_per_pixel & 0xf);
1450 return vdsc_cfg->bits_per_pixel >> 4;
1455 * drm_dsc_initial_scale_value() - Calculate the initial scale value for the given DSC config
1462 return 8 * dsc->rc_model_size / (dsc->rc_model_size - dsc->initial_offset);
1467 * drm_dsc_flatness_det_thresh() - Calculate the flatness_det_thresh for the given DSC config
1474 return 2 << (dsc->bits_per_component - 8);
1482 "dsc-cfg: version: %d.%d, picture: w=%d, h=%d, slice: count=%d, w=%d, h=%d, size=%d\n",
1483 cfg->dsc_version_major, cfg->dsc_version_minor,
1484 cfg->pic_width, cfg->pic_height,
1485 cfg->slice_count, cfg->slice_width, cfg->slice_height, cfg->slice_chunk_size);
1487 "dsc-cfg: mode: block-pred=%s, vbr=%s, rgb=%s, simple-422=%s, native-422=%s, native-420=%s\n",
1488 str_yes_no(cfg->block_pred_enable), str_yes_no(cfg->vbr_enable),
1489 str_yes_no(cfg->convert_rgb),
1490 str_yes_no(cfg->simple_422), str_yes_no(cfg->native_422), str_yes_no(cfg->native_420));
1492 "dsc-cfg: color-depth: uncompressed-bpc=%d, compressed-bpp=" FXP_Q4_FMT " line-buf-bpp=%d\n",
1493 cfg->bits_per_component, FXP_Q4_ARGS(cfg->bits_per_pixel), cfg->line_buf_depth);
1495 "dsc-cfg: rc-model: size=%d, bits=%d, mux-word-size: %d, initial-delays: xmit=%d, dec=%d\n",
1496 cfg->rc_model_size, cfg->rc_bits, cfg->mux_word_size,
1497 cfg->initial_xmit_delay, cfg->initial_dec_delay);
1499 "dsc-cfg: offsets: initial=%d, final=%d, slice-bpg=%d\n",
1500 cfg->initial_offset, cfg->final_offset, cfg->slice_bpg_offset);
1502 "dsc-cfg: line-bpg-offsets: first=%d, non-first=%d, second=%d, non-second=%d, second-adj=%d\n",
1503 cfg->first_line_bpg_offset, cfg->nfl_bpg_offset,
1504 cfg->second_line_bpg_offset, cfg->nsl_bpg_offset, cfg->second_line_offset_adj);
1506 "dsc-cfg: rc-tgt-offsets: low=%d, high=%d, rc-edge-factor: %d, rc-quant-incr-limits: [0]=%d, [1]=%d\n",
1507 cfg->rc_tgt_offset_low, cfg->rc_tgt_offset_high,
1508 cfg->rc_edge_factor, cfg->rc_quant_incr_limit0, cfg->rc_quant_incr_limit1);
1510 "dsc-cfg: initial-scale: %d, scale-intervals: increment=%d, decrement=%d\n",
1511 cfg->initial_scale_value, cfg->scale_increment_interval, cfg->scale_decrement_interval);
1513 "dsc-cfg: flatness: min-qp=%d, max-qp=%d\n",
1514 cfg->flatness_min_qp, cfg->flatness_max_qp);
1520 const u16 *bt = cfg->rc_buf_thresh;
1521 const struct drm_dsc_rc_range_parameters *rp = cfg->rc_range_params;
1523 BUILD_BUG_ON(ARRAY_SIZE(cfg->rc_buf_thresh) != 14);
1524 BUILD_BUG_ON(ARRAY_SIZE(cfg->rc_range_params) != 15);
1527 "dsc-cfg: rc-level: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14\n");
1529 "dsc-cfg: rc-buf-thresh: %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n",
1530 bt[0], bt[1], bt[2], bt[3], bt[4], bt[5], bt[6], bt[7],
1531 bt[8], bt[9], bt[10], bt[11], bt[12], bt[13]);
1533 "dsc-cfg: rc-min-qp: %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n",
1534 rp[0].range_min_qp, rp[1].range_min_qp, rp[2].range_min_qp, rp[3].range_min_qp,
1536 rp[8].range_min_qp, rp[9].range_min_qp, rp[10].range_min_qp, rp[11].range_min_qp,
1539 "dsc-cfg: rc-max-qp: %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n",
1540 rp[0].range_max_qp, rp[1].range_max_qp, rp[2].range_max_qp, rp[3].range_max_qp,
1542 rp[8].range_max_qp, rp[9].range_max_qp, rp[10].range_max_qp, rp[11].range_max_qp,
1545 "dsc-cfg: rc-bpg-offset: %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n",
1546 rp[0].range_bpg_offset, rp[1].range_bpg_offset, rp[2].range_bpg_offset, rp[3].range_bpg_offset,
1548 rp[8].range_bpg_offset, rp[9].range_bpg_offset, rp[10].range_bpg_offset, rp[11].range_bpg_offset,
1553 * drm_dsc_dump_config - Dump the provided DSC configuration