From: MingLiang Dong Date: Tue, 14 Aug 2018 12:11:23 +0000 (+0800) Subject: hdr: optimize hdrv2 hdr2sdr effect X-Git-Tag: khadas-vims-v0.9.6-release~1374 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b1842bec43100fbab4d657f57b13efc02b8c0a5f;p=platform%2Fkernel%2Flinux-amlogic.git hdr: optimize hdrv2 hdr2sdr effect PD#171788: hdr: optimize hdrv2 hdr2sdr effect 1. oetf blend with oogain 2. set oagin with max(RGB) 3. fix sdr2hlg osd too dark Change-Id: Ib40de7dfa5727cec62573c43dfa38a931b177aed Signed-off-by: MingLiang Dong --- diff --git a/drivers/amlogic/media/enhancement/amvecm/amcsc.c b/drivers/amlogic/media/enhancement/amvecm/amcsc.c index 6d79c18..73575bb 100644 --- a/drivers/amlogic/media/enhancement/amvecm/amcsc.c +++ b/drivers/amlogic/media/enhancement/amvecm/amcsc.c @@ -264,7 +264,7 @@ struct hdr_osd_reg_s hdr_osd_reg = { -1 /* shadow mode */ }; -#define HDR_VERSION "----gxl_20180830---g12a_20180614-----\n" +#define HDR_VERSION "----gxl_20180516---g12a_20180814-----\n" static struct vframe_s *dbg_vf; static struct master_display_info_s dbg_hdr_send; diff --git a/drivers/amlogic/media/enhancement/amvecm/set_hdr2_v0.c b/drivers/amlogic/media/enhancement/amvecm/set_hdr2_v0.c index f5b847b..06eb4e3 100644 --- a/drivers/amlogic/media/enhancement/amvecm/set_hdr2_v0.c +++ b/drivers/amlogic/media/enhancement/amvecm/set_hdr2_v0.c @@ -67,24 +67,27 @@ int cgain_lut2[65] = { 0x146e, 0x1482 }; +static int num_eo_y_lut_hdr = 143; int eo_y_lut_hdr[143] = { - 61440, 66560, 94208, 110592, 121984, 132160, 138816, 146432, 151264, - 156096, 161440, 165568, 168768, 172224, 175952, 179968, 182240, 200680, - 215102, 226400, 235271, 244625, 250984, 258029, 264312, 269323, 275208, - 280295, 284260, 288817, 294028, 297434, 300794, 304586, 308851, 312465, - 315139, 318120, 321437, 325119, 328439, 330693, 333181, 335922, 338938, - 342251, 344974, 346965, 349143, 351524, 354124, 356960, 360050, 361931, - 363762, 365751, 367912, 370258, 372802, 375559, 377689, 379306, 381056, - 382948, 384994, 387204, 389591, 392167, 394081, 395581, 397197, 398940, - 400818, 402840, 405018, 407363, 409743, 411100, 412561, 414132, 415820, - 417636, 419588, 421685, 423939, 426172, 427472, 428869, 430370, 431980, - 433710, 435567, 437561, 439701, 441999, 443416, 444740, 446160, 447685, - 449321, 451078, 452962, 454986, 457157, 459120, 460370, 461713, 463154, - 464701, 466363, 468146, 470061, 472118, 474326, 475917, 477191, 478560, - 480031, 481611, 483309, 485135, 487098, 489208, 491477, 492719, 494032, - 495444, 496965, 498601, 500363, 502261, 504304, 506506, 508391, 509670, - 511049, 512536, 514140, 515870, 517739, 519756, 521934, 524287 + 132288, 136832, 165440, 181832, 193440, 202088, 210400, 216476, 221882, + 227920, 231986, 235648, 239639, 243964, 247193, 249698, 252377, 271330, + 285261, 297148, 306377, 314682, 321922, 329204, 334486, 340750, 346085, + 350369, 355325, 360734, 363991, 367697, 371896, 376636, 379400, 382389, + 385731, 389458, 393410, 395711, 398260, 401078, 404188, 407615, 410492, + 412562, 414834, 417322, 420045, 423021, 426127, 427900, 429831, 431934, + 434222, 436709, 439410, 442342, 443945, 445668, 447230, 448187, 449224, + 450344, 451555, 452864, 454277, 455803, 457449, 458988, 459945, 460977, + 462089, 463286, 464576, 465964, 467458, 469066, 470795, 472655, 474655, + 475971, 477126, 478368, 479702, 481136, 482676, 484330, 486107, 488015, + 490063, 491891, 493071, 494339, 495699, 497159, 498727, 500409, 502262, + 504308, 506503, 508381, 509646, 511003, 512460, 512934, 513098, 513279, + 513477, 513691, 513923, 514172, 514438, 514720, 515017, 515328, 515650, + 515981, 516320, 516662, 517006, 517349, 517689, 518022, 518347, 518662, + 518968, 519263, 519549, 519827, 520097, 520363, 520625, 520888, 521155, + 521431, 521727, 522054, 522431, 522871, 523371, 523881, 524287 }; +module_param_array(eo_y_lut_hdr, int, &num_eo_y_lut_hdr, 0664); +MODULE_PARM_DESC(eo_y_lut_hdr, "\n eo_y_lut_hdr\n"); int eo_y_lut_hlg[143] = { 0, 169296, 202068, 221184, 234837, 246442, 253952, 262485, 267605, @@ -106,22 +109,22 @@ int eo_y_lut_hlg[143] = { }; int eo_y_lut_sdr[143] = { - 0, 131072, 169072, 192440, 208748, 220974, 231863, 240311, 248196, - 254344, 261528, 265967, 270660, 275934, 280168, 283414, 286977, 311340, - 327680, 339286, 349357, 359062, 365682, 372745, 378914, 383660, 389051, - 394162, 397536, 401264, 405358, 409712, 412138, 414760, 417582, 420609, - 423845, 426638, 428471, 430413, 432468, 434636, 436919, 439320, 441839, - 443423, 444804, 446246, 447751, 449320, 450952, 452649, 454412, 456240, - 458136, 459425, 460441, 461491, 462575, 463695, 464851, 466041, 467268, - 468532, 469832, 471168, 472542, 473954, 475269, 476013, 476776, 477558, - 478359, 479181, 480022, 480882, 481763, 482664, 483585, 484526, 485488, - 486471, 487474, 488499, 489544, 490610, 491609, 492163, 492728, 493304, - 493891, 494489, 495097, 495717, 496348, 496990, 497643, 498307, 498983, - 499670, 500369, 501079, 501800, 502533, 503278, 504034, 504802, 505582, - 506373, 507177, 507948, 508362, 508781, 509207, 509639, 510077, 510521, - 510971, 511427, 511890, 512359, 512834, 513315, 513802, 514296, 514796, - 515303, 515815, 516335, 516860, 517392, 517931, 518476, 519027, 519586, - 520150, 520721, 521299, 521883, 522474, 523072, 523676, 524287 + 0, 163808, 199044, 219568, 234610, 247036, 255751, 264272, 270593, + 277939, 282430, 287163, 292441, 296593, 299792, 303278, 307054, 328697, + 344063, 354448, 364052, 372123, 379268, 384835, 391196, 395793, 399793, + 404214, 409063, 411973, 414834, 417919, 421229, 424767, 427260, 429261, + 431380, 433618, 435975, 438453, 441054, 443072, 444496, 445981, 447530, + 449142, 450817, 452556, 454360, 456229, 458163, 459457, 460489, 461555, + 462654, 463787, 464953, 466153, 467387, 468655, 469957, 471294, 472665, + 474071, 475324, 476062, 476817, 477590, 478381, 479190, 480016, 480861, + 481723, 482603, 483502, 484418, 485353, 486306, 487278, 488267, 489276, + 490302, 491348, 491966, 492507, 493057, 493618, 494187, 494766, 495354, + 495952, 496559, 497176, 497803, 498439, 499084, 499740, 500405, 501079, + 501764, 502458, 503161, 503875, 504598, 505332, 506075, 506828, 507590, + 508133, 508525, 508921, 509322, 509728, 510140, 510556, 510977, 511404, + 511835, 512272, 512713, 513160, 513611, 514068, 514530, 514997, 515469, + 515946, 516429, 516916, 517409, 517907, 518410, 518918, 519432, 519950, + 520474, 521003, 521537, 522077, 522622, 523172, 523727, 524287 }; int oe_y_lut_hdr[149] = {0, 3, 5, 8, 12, 19, 28, 41, 60, 67, 74, 80, 85, @@ -152,6 +155,7 @@ int oe_y_lut_hlg[149] = {0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 6, 6, 7, 8, 9, 4072, 4095 }; +static int num_oe_y_lut_sdr = 149; int oe_y_lut_sdr[149] = {0, 1, 1, 2, 2, 3, 5, 7, 9, 10, 11, 12, 12, 13, 15, 16, 16, 18, 20, 21, 22, 24, 26, 28, 30, 33, 35, 38, 40, 44, 47, 50, 53, 59, 63, 67, 71, 78, 85, 90, 95, 105, 113, 121, 127, 134, 140, @@ -164,6 +168,8 @@ int oe_y_lut_sdr[149] = {0, 1, 1, 2, 2, 3, 5, 7, 9, 10, 11, 12, 12, 13, 2624, 2721, 2814, 2902, 2987, 3068, 3147, 3222, 3296, 3367, 3436, 3503, 3569, 3633, 3695, 3756, 3816, 3874, 3931, 3987, 4042, 4095 }; +module_param_array(oe_y_lut_sdr, int, &num_oe_y_lut_sdr, 0664); +MODULE_PARM_DESC(oe_y_lut_sdr, "\n eo_y_lut_hdr\n"); int oo_y_lut_hdr_hlg[149] = { 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, 4095, @@ -183,20 +189,18 @@ int oo_y_lut_hdr_hlg[149] = { static int num_hdr_sdr_lut = 149; int oo_y_lut_hdr_sdr[149] = { - 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, - 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, - 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3260, 3260, - 3260, 3260, 3260, 3260, 3260, 3259, 3259, 3259, 3259, 3258, 3258, - 3257, 3257, 3256, 3256, 3255, 3255, 3254, 3254, 3253, 3252, 3251, - 3251, 3250, 3249, 3248, 3247, 3246, 3244, 3242, 3240, 3238, 3236, - 3235, 3233, 3231, 3227, 3223, 3220, 3216, 3212, 3208, 3205, 3201, - 3194, 3186, 3179, 3172, 3164, 3157, 3150, 3143, 3128, 3114, 3100, - 3086, 3072, 3058, 3044, 3030, 3003, 2976, 2950, 2924, 2898, 2873, - 2848, 2823, 2774, 2727, 2680, 2635, 2591, 2549, 2507, 2466, 2388, - 2314, 2243, 2176, 2112, 2051, 1993, 1938, 1835, 1742, 1658, 1581, - 1511, 1447, 1388, 1334, 1240, 1159, 1090, 1029, 977, 930, 889, - 852, 818, 787, 759, 733, 708, 685, 664, 644, 624, 606, 589, 572, - 556, 541, 526, 512 + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255 }; module_param_array(oo_y_lut_hdr_sdr, int, &num_hdr_sdr_lut, 0664); MODULE_PARM_DESC(oo_y_lut_hdr_sdr, "\n num_hdr_sdr_lut\n"); @@ -216,18 +220,19 @@ int oo_y_lut_hlg_hdr[149] = { }; int oo_y_lut_sdr_hdr[149] = { - 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, - 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, - 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, - 643, 643, 643, 643, 643, 643, 643, 643, 644, 644, 644, 644, 644, - 644, 644, 644, 645, 645, 645, 645, 645, 646, 646, 646, 647, 647, - 647, 648, 648, 649, 649, 650, 651, 652, 652, 653, 654, 655, 656, - 658, 659, 661, 662, 664, 665, 667, 670, 673, 676, 679, 682, 685, - 688, 691, 698, 704, 710, 717, 723, 729, 736, 742, 755, 768, 782, - 795, 809, 822, 836, 850, 878, 906, 934, 963, 992, 1022, 1052, - 1081, 1142, 1203, 1264, 1326, 1387, 1449, 1510, 1571, 1691, 1808, - 1923, 2036, 2145, 2252, 2357, 2460, 2562, 2662, 2761, 2860, 2959, - 3057, 3156, 3256, 3356, 3457, 3559, 3663, 3768, 3875, 3984, 4095 + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, + 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 130, 130, + 130, 131, 131, 131, 132, 132, 133, 133, 134, 135, 136, 136, + 137, 138, 139, 140, 141, 143, 145, 147, 148, 150, 152, 154, + 157, 161, 164, 168, 172, 175, 179, 183, 190, 197, 205, 213, + 220, 228, 235, 243, 258, 273, 288, 303, 318, 332, 346, 360, + 374, 387, 400, 412, 423, 434, 444, 452, 461, 468, 475, 481, + 488, 495, 502, 510 }; int oo_y_lut_hlg_sdr[149] = { @@ -634,8 +639,12 @@ MODULE_PARM_DESC(hdr2_debug, "\n hdr2_debug\n"); /*int ncl_2020_709[9] = {*/ /*3401, -1204, -149, -255, 2320, -17, -37, -206, 2291};*/ /* dci-p3->709rgb*/ +/*int ncl_2020_709[9] = {*/ + /*2543, -459, -36, -88, 2133, 3, -41, -161, 2250};*/ + +/* special primary->709rgb*/ int ncl_2020_709[9] = { - 2543, -459, -36, -88, 2133, 3, -41, -161, 2250}; + 2684, -489, -147, -201, 2266, -17, -29, -171, 2248}; /*int cl_2020_709[9] =*/ /*{-1775, 3867, -44, 3422, -1154, -220 ,-304, 43, 2309}; */ @@ -1117,8 +1126,8 @@ void set_hdr_matrix( for (i = 0; i < 3; i++) { adpscl_enable[i] = 0; if (hdr_mtx_param->p_sel & HDR_SDR) - adpscl_alpha[i] = out_luma * - (1 << adp_scal_shift) / in_luma; + adpscl_alpha[i] = + (1 << adp_scal_shift); else if (hdr_mtx_param->p_sel & SDR_HDR) adpscl_alpha[i] = in_luma * (1 << adp_scal_shift) / out_luma; @@ -1132,17 +1141,29 @@ void set_hdr_matrix( } else if (hdr_mtx_param->p_sel & HLG_HDR) adpscl_alpha[i] = 1 * (1 << adp_scal_shift) / in_luma; - adpscl_shift[i] = adp_scal_shift; - adpscl_ys_coef[i] = - hdr_mtx_param->mtx_ogain[i] << 1; + else if (hdr_mtx_param->p_sel & SDR_HLG) + adpscl_alpha[i] = 10 * in_luma * + (1 << adp_scal_shift) / out_luma; + + if (hdr_mtx_param->p_sel & HDR_SDR) { + if (i == 0) + adpscl_shift[i] = adp_scal_shift; + else + adpscl_shift[i] = adp_scal_shift - 2; + } else + adpscl_shift[i] = adp_scal_shift; + + if (hdr_mtx_param->mtx_ogain) + adpscl_ys_coef[i] = + 1 << adp_scal_shift; adpscl_beta_s[i] = 0; - adpscl_beta[i] = FLTZERO; + adpscl_beta[i] = 0; } /*gamut mode: 1->gamut before ootf*/ /*2->gamut after ootf*/ /*other->disable gamut*/ - VSYNC_WR_MPEG_REG_BITS(hdr_ctrl, 1, 6, 2); + VSYNC_WR_MPEG_REG_BITS(hdr_ctrl, 2, 6, 2); VSYNC_WR_MPEG_REG(GMUT_CTRL, gmut_shift); VSYNC_WR_MPEG_REG(GMUT_COEF0, @@ -1163,7 +1184,8 @@ void set_hdr_matrix( VSYNC_WR_MPEG_REG(CGAIN_COEF0, c_gain_lim_coef[1] << 16 | c_gain_lim_coef[0]); - VSYNC_WR_MPEG_REG(CGAIN_COEF1, c_gain_lim_coef[2]); + VSYNC_WR_MPEG_REG(CGAIN_COEF1, c_gain_lim_coef[2] | + 0x400 << 16); VSYNC_WR_MPEG_REG(ADPS_CTRL, adpscl_enable[2] << 6 | adpscl_enable[1] << 5 | @@ -1632,7 +1654,7 @@ void hdr_func(enum hdr_module_sel module_sel, hdr_mtx_param.mtx_gamut[i] = ncl_709_2020[i]; } hdr_mtx_param.mtx_on = MTX_ON; - hdr_mtx_param.p_sel = SDR_HDR; + hdr_mtx_param.p_sel = SDR_HLG; } set_hdr_matrix(module_sel, HDR_IN_MTX, &hdr_mtx_param);