Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/dsc: Enable YCbCr420 for VDSC

Implementation of VDSC for YCbCr420.
Add QP tables for 8,10,12 BPC from rc_tables.h in intel_qp_tables.c
(Derived from C-Model, which is given along with DSC1.2a Spec from Vesa)
intel_lookup_range_min/max_qp functons need to take into account the
output format. Based on that appropriate qp table need to be chosen.
Other rc_parameters need to be set where currently values for 444 format
is hardcoded in calculate_rc_parameters( ).
vdsc_cfg struct needs to be filled with output format information, where
these are hardcoded for 444 format.
Bspec: 49259

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
Reviewed-by: Vandita Kulkarni <Vandita.kulkarni@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230309062855.393087-5-suraj.kandpal@intel.com

authored by

Suraj Kandpal and committed by
Uma Shankar
dd4d6791 ac754358

+180 -15
+176 -11
drivers/gpu/drm/i915/display/intel_qp_tables.c
··· 17 17 /* from BPP 6 to 36 in steps of 0.5 */ 18 18 #define RC_RANGE_QP444_12BPC_MAX_NUM_BPP 61 19 19 20 + /* from BPP 6 to 24 in steps of 0.5 */ 21 + #define RC_RANGE_QP420_8BPC_MAX_NUM_BPP 17 22 + 23 + /* from BPP 6 to 30 in steps of 0.5 */ 24 + #define RC_RANGE_QP420_10BPC_MAX_NUM_BPP 23 25 + 26 + /* from BPP 6 to 36 in steps of 0.5 */ 27 + #define RC_RANGE_QP420_12BPC_MAX_NUM_BPP 29 28 + 20 29 /* 21 30 * These qp tables are as per the C model 22 31 * and it has the rows pointing to bpps which increment ··· 292 283 11, 11, 10, 10, 10, 10, 10, 9, 9, 8, 8, 8, 8, 8, 7, 7, 6, 6, 6, 6, 5, 5, 4 } 293 284 }; 294 285 295 - #define PARAM_TABLE(_minmax, _bpc, _row, _col) do { \ 296 - if (bpc == (_bpc)) \ 297 - return rc_range_##_minmax##qp444_##_bpc##bpc[_row][_col]; \ 286 + static const u8 rc_range_minqp420_8bpc[DSC_NUM_BUF_RANGES][RC_RANGE_QP420_8BPC_MAX_NUM_BPP] = { 287 + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 288 + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 289 + { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 290 + { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 291 + { 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, 292 + { 3, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, 293 + { 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, 294 + { 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 0 }, 295 + { 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 0 }, 296 + { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1 }, 297 + { 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 1, 1 }, 298 + { 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1 }, 299 + { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 3, 3, 2, 1 }, 300 + { 9, 8, 8, 7, 7, 7, 7, 7, 7, 6, 5, 5, 4, 3, 3, 3, 2 }, 301 + { 13, 12, 12, 11, 10, 10, 9, 8, 8, 7, 6, 6, 5, 5, 4, 4, 3 } 302 + }; 303 + 304 + static const u8 rc_range_maxqp420_8bpc[DSC_NUM_BUF_RANGES][RC_RANGE_QP420_8BPC_MAX_NUM_BPP] = { 305 + { 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 306 + { 4, 4, 4, 4, 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0 }, 307 + { 5, 5, 5, 5, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, 308 + { 6, 6, 6, 6, 6, 5, 4, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0 }, 309 + { 7, 7, 7, 7, 7, 5, 4, 3, 2, 2, 2, 2, 2, 1, 1, 1, 0 }, 310 + { 7, 7, 7, 7, 7, 6, 5, 4, 3, 3, 3, 2, 2, 2, 1, 1, 0 }, 311 + { 7, 7, 7, 7, 7, 6, 5, 4, 3, 3, 3, 3, 2, 2, 2, 1, 1 }, 312 + { 8, 8, 8, 8, 8, 7, 6, 5, 4, 4, 4, 3, 3, 2, 2, 2, 1 }, 313 + { 9, 9, 9, 8, 8, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1 }, 314 + { 10, 10, 9, 9, 9, 8, 7, 6, 5, 5, 5, 4, 4, 3, 3, 2, 2 }, 315 + { 10, 10, 10, 9, 9, 8, 8, 7, 6, 6, 5, 5, 4, 4, 3, 2, 2 }, 316 + { 11, 11, 10, 10, 9, 9, 8, 7, 7, 6, 6, 5, 5, 4, 3, 3, 2 }, 317 + { 11, 11, 11, 10, 9, 9, 9, 8, 7, 7, 6, 5, 5, 4, 4, 3, 2 }, 318 + { 13, 12, 12, 11, 10, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 4, 3 }, 319 + { 14, 13, 13, 12, 11, 11, 10, 9, 9, 8, 7, 7, 6, 6, 5, 5, 4 } 320 + }; 321 + 322 + static const u8 rc_range_minqp420_10bpc[DSC_NUM_BUF_RANGES][RC_RANGE_QP420_10BPC_MAX_NUM_BPP] = { 323 + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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2, 2 }, 338 + { 17, 16, 16, 15, 14, 14, 13, 12, 12, 11, 10, 10, 10, 9, 8, 8, 7, 6, 6, 5, 339 + 5, 4, 4 } 340 + }; 341 + 342 + static const u8 rc_range_maxqp420_10bpc[DSC_NUM_BUF_RANGES][RC_RANGE_QP420_10BPC_MAX_NUM_BPP] = { 343 + { 8, 8, 7, 6, 4, 4, 3, 3, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 344 + { 8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 3, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, 345 + { 9, 9, 9, 8, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0 }, 346 + { 10, 10, 10, 9, 9, 8, 7, 6, 5, 4, 4, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 0, 347 + 0 }, 348 + { 11, 11, 11, 10, 10, 8, 7, 6, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 349 + 0 }, 350 + { 11, 11, 11, 10, 10, 9, 8, 7, 6, 6, 6, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 1, 351 + 1 }, 352 + { 11, 11, 11, 11, 11, 10, 9, 8, 7, 7, 7, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 353 + 1 }, 354 + { 12, 12, 12, 12, 12, 11, 10, 9, 8, 8, 8, 7, 6, 5, 5, 4, 3, 3, 3, 2, 2, 355 + 2, 1 }, 356 + { 13, 13, 13, 12, 12, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 5, 4, 4, 3, 3, 3, 357 + 2, 2 }, 358 + { 14, 14, 13, 13, 13, 12, 11, 10, 9, 9, 9, 8, 8, 7, 7, 6, 5, 4, 4, 3, 3, 359 + 2, 2 }, 360 + { 14, 14, 14, 13, 13, 12, 12, 11, 10, 10, 9, 9, 8, 8, 7, 6, 5, 5, 4, 4, 361 + 3, 3, 2 }, 362 + { 15, 15, 14, 14, 13, 13, 12, 11, 11, 10, 10, 9, 9, 8, 7, 7, 6, 5, 5, 4, 363 + 4, 3, 2 }, 364 + { 15, 15, 15, 14, 13, 13, 13, 12, 11, 11, 10, 9, 9, 8, 8, 7, 6, 5, 5, 4, 365 + 4, 3, 2 }, 366 + { 17, 16, 16, 15, 14, 14, 13, 12, 12, 11, 10, 10, 9, 8, 8, 7, 6, 6, 5, 4, 367 + 4, 3, 3 }, 368 + { 18, 17, 17, 16, 15, 15, 14, 13, 13, 12, 11, 11, 11, 10, 9, 9, 8, 7, 7, 369 + 6, 6, 5, 5 } 370 + }; 371 + 372 + static const u8 rc_range_minqp420_12bpc[DSC_NUM_BUF_RANGES][RC_RANGE_QP420_12BPC_MAX_NUM_BPP] = { 373 + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 374 + 0, 0, 0, 0, 0 }, 375 + { 4, 4, 4, 4, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 376 + 0, 0, 0, 0, 0 }, 377 + { 9, 8, 8, 7, 7, 6, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 0, 0, 0, 0, 0, 0, 378 + 0, 0, 0, 0, 0 }, 379 + { 10, 9, 9, 8, 8, 8, 7, 7, 6, 6, 6, 5, 5, 4, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 380 + 0, 0, 0, 0, 0 }, 381 + { 11, 10, 10, 10, 10, 9, 9, 8, 7, 6, 6, 6, 6, 5, 5, 4, 3, 3, 3, 2, 2, 1, 382 + 0, 0, 0, 0, 0, 0, 0 }, 383 + { 11, 11, 11, 11, 11, 10, 10, 9, 9, 9, 9, 8, 7, 6, 5, 5, 4, 4, 3, 3, 3, 2, 384 + 1, 1, 0, 0, 0, 0, 0 }, 385 + { 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 9, 8, 8, 7, 6, 5, 5, 5, 5, 4, 3, 3, 386 + 2, 1, 1, 1, 1, 1, 0 }, 387 + { 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 9, 8, 8, 8, 7, 6, 6, 5, 4, 4, 388 + 3, 2, 2, 1, 1, 1, 1, 1 }, 389 + { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 5, 390 + 5, 4, 4, 2, 2, 1, 1, 1, 1 }, 391 + { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 392 + 5, 4, 4, 3, 2, 2, 1, 1, 1 }, 393 + { 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 394 + 6, 5, 4, 3, 3, 2, 2, 1, 1 }, 395 + { 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 11, 10, 10, 9, 8, 8, 396 + 7, 7, 6, 5, 4, 3, 3, 2, 2, 1 }, 397 + { 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 11, 11, 10, 9, 8, 8, 398 + 7, 7, 6, 5, 4, 4, 3, 2, 2, 1 }, 399 + { 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 13, 13, 12, 11, 11, 10, 9, 9, 8, 400 + 8, 7, 6, 6, 5, 4, 4, 3, 3, 2 }, 401 + { 21, 20, 20, 19, 18, 18, 17, 16, 16, 15, 14, 14, 14, 13, 12, 12, 11, 10, 402 + 10, 10, 9, 8, 8, 7, 6, 6, 5, 5, 4 } 403 + }; 404 + 405 + static const u8 rc_range_maxqp420_12bpc[DSC_NUM_BUF_RANGES][RC_RANGE_QP420_12BPC_MAX_NUM_BPP] = { 406 + { 11, 10, 9, 8, 6, 6, 5, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 407 + 0, 0, 0, 0, 0, 0 }, 408 + { 12, 11, 11, 10, 9, 8, 7, 7, 6, 6, 5, 5, 4, 3, 3, 2, 1, 1, 1, 1, 1, 1, 409 + 1, 0, 0, 0, 0, 0, 0 }, 410 + { 13, 12, 12, 11, 11, 10, 9, 8, 7, 6, 6, 6, 5, 5, 4, 3, 3, 2, 1, 1, 1, 1, 411 + 1, 0, 0, 0, 0, 0, 0 }, 412 + { 14, 13, 13, 12, 12, 11, 10, 9, 8, 7, 7, 6, 6, 5, 5, 4, 3, 3, 2, 2, 2, 1, 413 + 1, 1, 0, 0, 0, 0, 0 }, 414 + { 15, 14, 14, 13, 13, 11, 10, 9, 8, 7, 7, 7, 7, 6, 6, 5, 4, 4, 4, 3, 3, 2, 415 + 1, 1, 1, 0, 0, 0, 0 }, 416 + { 15, 15, 15, 14, 14, 13, 12, 11, 10, 10, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 417 + 4, 3, 2, 2, 1, 1, 0, 0, 0 }, 418 + { 15, 15, 15, 15, 15, 14, 13, 12, 11, 11, 11, 10, 9, 8, 7, 6, 6, 6, 6, 5, 419 + 4, 4, 3, 2, 2, 2, 1, 1, 0 }, 420 + { 16, 16, 16, 16, 16, 15, 14, 13, 12, 12, 12, 11, 10, 9, 9, 8, 7, 7, 6, 5, 421 + 5, 4, 3, 3, 2, 2, 2, 1, 1 }, 422 + { 17, 17, 17, 16, 16, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 9, 8, 8, 7, 423 + 6, 6, 5, 5, 3, 3, 2, 2, 1, 1 }, 424 + { 18, 18, 17, 17, 17, 16, 15, 14, 13, 13, 13, 12, 12, 11, 11, 10, 9, 8, 8, 425 + 7, 6, 5, 5, 4, 3, 3, 2, 2, 1 }, 426 + { 18, 18, 18, 17, 17, 16, 16, 15, 14, 14, 13, 13, 12, 12, 11, 10, 9, 9, 8, 427 + 8, 7, 6, 5, 4, 4, 3, 3, 2, 2 }, 428 + { 19, 19, 18, 18, 17, 17, 16, 15, 15, 14, 14, 13, 13, 12, 11, 11, 10, 9, 429 + 9, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2 }, 430 + { 19, 19, 19, 18, 17, 17, 17, 16, 15, 15, 14, 13, 13, 12, 12, 11, 10, 9, 431 + 9, 8, 8, 7, 6, 5, 5, 4, 3, 3, 2 }, 432 + { 21, 20, 20, 19, 18, 18, 17, 16, 16, 15, 14, 14, 13, 12, 12, 11, 10, 10, 433 + 9, 9, 8, 7, 7, 6, 5, 5, 4, 4, 3 }, 434 + { 22, 21, 21, 20, 19, 19, 18, 17, 17, 16, 15, 15, 15, 14, 13, 13, 12, 11, 435 + 11, 11, 10, 9, 9, 8, 7, 7, 6, 6, 5 } 436 + }; 437 + 438 + #define PARAM_TABLE(_minmax, _bpc, _row, _col, _is_420) do { \ 439 + if (bpc == (_bpc)) { \ 440 + if (_is_420) \ 441 + return rc_range_##_minmax##qp420_##_bpc##bpc[_row][_col]; \ 442 + else \ 443 + return rc_range_##_minmax##qp444_##_bpc##bpc[_row][_col]; \ 444 + } \ 298 445 } while (0) 299 446 300 - u8 intel_lookup_range_min_qp(int bpc, int buf_i, int bpp_i) 447 + u8 intel_lookup_range_min_qp(int bpc, int buf_i, int bpp_i, bool is_420) 301 448 { 302 - PARAM_TABLE(min, 8, buf_i, bpp_i); 303 - PARAM_TABLE(min, 10, buf_i, bpp_i); 304 - PARAM_TABLE(min, 12, buf_i, bpp_i); 449 + PARAM_TABLE(min, 8, buf_i, bpp_i, is_420); 450 + PARAM_TABLE(min, 10, buf_i, bpp_i, is_420); 451 + PARAM_TABLE(min, 12, buf_i, bpp_i, is_420); 305 452 306 453 MISSING_CASE(bpc); 307 454 return 0; 308 455 } 309 456 310 - u8 intel_lookup_range_max_qp(int bpc, int buf_i, int bpp_i) 457 + u8 intel_lookup_range_max_qp(int bpc, int buf_i, int bpp_i, bool is_420) 311 458 { 312 - PARAM_TABLE(max, 8, buf_i, bpp_i); 313 - PARAM_TABLE(max, 10, buf_i, bpp_i); 314 - PARAM_TABLE(max, 12, buf_i, bpp_i); 459 + PARAM_TABLE(max, 8, buf_i, bpp_i, is_420); 460 + PARAM_TABLE(max, 10, buf_i, bpp_i, is_420); 461 + PARAM_TABLE(max, 12, buf_i, bpp_i, is_420); 315 462 316 463 MISSING_CASE(bpc); 317 464 return 0;
+2 -2
drivers/gpu/drm/i915/display/intel_qp_tables.h
··· 8 8 9 9 #include <linux/types.h> 10 10 11 - u8 intel_lookup_range_min_qp(int bpc, int buf_i, int bpp_i); 12 - u8 intel_lookup_range_max_qp(int bpc, int buf_i, int bpp_i); 11 + u8 intel_lookup_range_min_qp(int bpc, int buf_i, int bpp_i, bool is_420); 12 + u8 intel_lookup_range_max_qp(int bpc, int buf_i, int bpp_i, bool is_420); 13 13 14 14 #endif
+2 -2
drivers/gpu/drm/i915/display/intel_vdsc.c
··· 423 423 for (buf_i = 0; buf_i < DSC_NUM_BUF_RANGES; buf_i++) { 424 424 /* Read range_minqp and range_max_qp from qp tables */ 425 425 rc->rc_range_params[buf_i].range_min_qp = 426 - intel_lookup_range_min_qp(bpc, buf_i, bpp_i); 426 + intel_lookup_range_min_qp(bpc, buf_i, bpp_i, vdsc_cfg->native_420); 427 427 rc->rc_range_params[buf_i].range_max_qp = 428 - intel_lookup_range_max_qp(bpc, buf_i, bpp_i); 428 + intel_lookup_range_max_qp(bpc, buf_i, bpp_i, vdsc_cfg->native_420); 429 429 430 430 /* Calculate range_bgp_offset */ 431 431 if (bpp <= 6) {