| .. | .. |
|---|
| 71 | 71 | unsigned int i = 0; |
|---|
| 72 | 72 | |
|---|
| 73 | 73 | REG_SET_2(reg->start_cntl_b, 0, |
|---|
| 74 | | - exp_region_start, params->arr_points[0].custom_float_x, |
|---|
| 74 | + exp_region_start, params->corner_points[0].blue.custom_float_x, |
|---|
| 75 | 75 | exp_resion_start_segment, 0); |
|---|
| 76 | 76 | REG_SET_2(reg->start_cntl_g, 0, |
|---|
| 77 | | - exp_region_start, params->arr_points[0].custom_float_x, |
|---|
| 77 | + exp_region_start, params->corner_points[0].green.custom_float_x, |
|---|
| 78 | 78 | exp_resion_start_segment, 0); |
|---|
| 79 | 79 | REG_SET_2(reg->start_cntl_r, 0, |
|---|
| 80 | | - exp_region_start, params->arr_points[0].custom_float_x, |
|---|
| 80 | + exp_region_start, params->corner_points[0].red.custom_float_x, |
|---|
| 81 | 81 | exp_resion_start_segment, 0); |
|---|
| 82 | 82 | |
|---|
| 83 | 83 | REG_SET(reg->start_slope_cntl_b, 0, |
|---|
| 84 | | - field_region_linear_slope, params->arr_points[0].custom_float_slope); |
|---|
| 84 | + field_region_linear_slope, params->corner_points[0].blue.custom_float_slope); |
|---|
| 85 | 85 | REG_SET(reg->start_slope_cntl_g, 0, |
|---|
| 86 | | - field_region_linear_slope, params->arr_points[0].custom_float_slope); |
|---|
| 86 | + field_region_linear_slope, params->corner_points[0].green.custom_float_slope); |
|---|
| 87 | 87 | REG_SET(reg->start_slope_cntl_r, 0, |
|---|
| 88 | | - field_region_linear_slope, params->arr_points[0].custom_float_slope); |
|---|
| 88 | + field_region_linear_slope, params->corner_points[0].red.custom_float_slope); |
|---|
| 89 | 89 | |
|---|
| 90 | 90 | REG_SET(reg->start_end_cntl1_b, 0, |
|---|
| 91 | | - field_region_end, params->arr_points[1].custom_float_x); |
|---|
| 91 | + field_region_end, params->corner_points[1].blue.custom_float_x); |
|---|
| 92 | 92 | REG_SET_2(reg->start_end_cntl2_b, 0, |
|---|
| 93 | | - field_region_end_slope, params->arr_points[1].custom_float_slope, |
|---|
| 94 | | - field_region_end_base, params->arr_points[1].custom_float_y); |
|---|
| 93 | + field_region_end_slope, params->corner_points[1].blue.custom_float_slope, |
|---|
| 94 | + field_region_end_base, params->corner_points[1].blue.custom_float_y); |
|---|
| 95 | 95 | |
|---|
| 96 | 96 | REG_SET(reg->start_end_cntl1_g, 0, |
|---|
| 97 | | - field_region_end, params->arr_points[1].custom_float_x); |
|---|
| 97 | + field_region_end, params->corner_points[1].green.custom_float_x); |
|---|
| 98 | 98 | REG_SET_2(reg->start_end_cntl2_g, 0, |
|---|
| 99 | | - field_region_end_slope, params->arr_points[1].custom_float_slope, |
|---|
| 100 | | - field_region_end_base, params->arr_points[1].custom_float_y); |
|---|
| 99 | + field_region_end_slope, params->corner_points[1].green.custom_float_slope, |
|---|
| 100 | + field_region_end_base, params->corner_points[1].green.custom_float_y); |
|---|
| 101 | 101 | |
|---|
| 102 | 102 | REG_SET(reg->start_end_cntl1_r, 0, |
|---|
| 103 | | - field_region_end, params->arr_points[1].custom_float_x); |
|---|
| 103 | + field_region_end, params->corner_points[1].red.custom_float_x); |
|---|
| 104 | 104 | REG_SET_2(reg->start_end_cntl2_r, 0, |
|---|
| 105 | | - field_region_end_slope, params->arr_points[1].custom_float_slope, |
|---|
| 106 | | - field_region_end_base, params->arr_points[1].custom_float_y); |
|---|
| 105 | + field_region_end_slope, params->corner_points[1].red.custom_float_slope, |
|---|
| 106 | + field_region_end_base, params->corner_points[1].red.custom_float_y); |
|---|
| 107 | 107 | |
|---|
| 108 | 108 | for (reg_region_cur = reg->region_start; |
|---|
| 109 | 109 | reg_region_cur <= reg->region_end; |
|---|
| .. | .. |
|---|
| 127 | 127 | |
|---|
| 128 | 128 | bool cm_helper_convert_to_custom_float( |
|---|
| 129 | 129 | struct pwl_result_data *rgb_resulted, |
|---|
| 130 | | - struct curve_points *arr_points, |
|---|
| 130 | + struct curve_points3 *corner_points, |
|---|
| 131 | 131 | uint32_t hw_points_num, |
|---|
| 132 | 132 | bool fixpoint) |
|---|
| 133 | 133 | { |
|---|
| .. | .. |
|---|
| 141 | 141 | fmt.mantissa_bits = 12; |
|---|
| 142 | 142 | fmt.sign = false; |
|---|
| 143 | 143 | |
|---|
| 144 | | - if (!convert_to_custom_float_format(arr_points[0].x, &fmt, |
|---|
| 145 | | - &arr_points[0].custom_float_x)) { |
|---|
| 144 | + /* corner_points[0] - beginning base, slope offset for R,G,B |
|---|
| 145 | + * corner_points[1] - end base, slope offset for R,G,B |
|---|
| 146 | + */ |
|---|
| 147 | + if (!convert_to_custom_float_format(corner_points[0].red.x, &fmt, |
|---|
| 148 | + &corner_points[0].red.custom_float_x)) { |
|---|
| 149 | + BREAK_TO_DEBUGGER(); |
|---|
| 150 | + return false; |
|---|
| 151 | + } |
|---|
| 152 | + if (!convert_to_custom_float_format(corner_points[0].green.x, &fmt, |
|---|
| 153 | + &corner_points[0].green.custom_float_x)) { |
|---|
| 154 | + BREAK_TO_DEBUGGER(); |
|---|
| 155 | + return false; |
|---|
| 156 | + } |
|---|
| 157 | + if (!convert_to_custom_float_format(corner_points[0].blue.x, &fmt, |
|---|
| 158 | + &corner_points[0].blue.custom_float_x)) { |
|---|
| 146 | 159 | BREAK_TO_DEBUGGER(); |
|---|
| 147 | 160 | return false; |
|---|
| 148 | 161 | } |
|---|
| 149 | 162 | |
|---|
| 150 | | - if (!convert_to_custom_float_format(arr_points[0].offset, &fmt, |
|---|
| 151 | | - &arr_points[0].custom_float_offset)) { |
|---|
| 163 | + if (!convert_to_custom_float_format(corner_points[0].red.offset, &fmt, |
|---|
| 164 | + &corner_points[0].red.custom_float_offset)) { |
|---|
| 165 | + BREAK_TO_DEBUGGER(); |
|---|
| 166 | + return false; |
|---|
| 167 | + } |
|---|
| 168 | + if (!convert_to_custom_float_format(corner_points[0].green.offset, &fmt, |
|---|
| 169 | + &corner_points[0].green.custom_float_offset)) { |
|---|
| 170 | + BREAK_TO_DEBUGGER(); |
|---|
| 171 | + return false; |
|---|
| 172 | + } |
|---|
| 173 | + if (!convert_to_custom_float_format(corner_points[0].blue.offset, &fmt, |
|---|
| 174 | + &corner_points[0].blue.custom_float_offset)) { |
|---|
| 152 | 175 | BREAK_TO_DEBUGGER(); |
|---|
| 153 | 176 | return false; |
|---|
| 154 | 177 | } |
|---|
| 155 | 178 | |
|---|
| 156 | | - if (!convert_to_custom_float_format(arr_points[0].slope, &fmt, |
|---|
| 157 | | - &arr_points[0].custom_float_slope)) { |
|---|
| 179 | + if (!convert_to_custom_float_format(corner_points[0].red.slope, &fmt, |
|---|
| 180 | + &corner_points[0].red.custom_float_slope)) { |
|---|
| 181 | + BREAK_TO_DEBUGGER(); |
|---|
| 182 | + return false; |
|---|
| 183 | + } |
|---|
| 184 | + if (!convert_to_custom_float_format(corner_points[0].green.slope, &fmt, |
|---|
| 185 | + &corner_points[0].green.custom_float_slope)) { |
|---|
| 186 | + BREAK_TO_DEBUGGER(); |
|---|
| 187 | + return false; |
|---|
| 188 | + } |
|---|
| 189 | + if (!convert_to_custom_float_format(corner_points[0].blue.slope, &fmt, |
|---|
| 190 | + &corner_points[0].blue.custom_float_slope)) { |
|---|
| 158 | 191 | BREAK_TO_DEBUGGER(); |
|---|
| 159 | 192 | return false; |
|---|
| 160 | 193 | } |
|---|
| .. | .. |
|---|
| 162 | 195 | fmt.mantissa_bits = 10; |
|---|
| 163 | 196 | fmt.sign = false; |
|---|
| 164 | 197 | |
|---|
| 165 | | - if (!convert_to_custom_float_format(arr_points[1].x, &fmt, |
|---|
| 166 | | - &arr_points[1].custom_float_x)) { |
|---|
| 198 | + if (!convert_to_custom_float_format(corner_points[1].red.x, &fmt, |
|---|
| 199 | + &corner_points[1].red.custom_float_x)) { |
|---|
| 200 | + BREAK_TO_DEBUGGER(); |
|---|
| 201 | + return false; |
|---|
| 202 | + } |
|---|
| 203 | + if (!convert_to_custom_float_format(corner_points[1].green.x, &fmt, |
|---|
| 204 | + &corner_points[1].green.custom_float_x)) { |
|---|
| 205 | + BREAK_TO_DEBUGGER(); |
|---|
| 206 | + return false; |
|---|
| 207 | + } |
|---|
| 208 | + if (!convert_to_custom_float_format(corner_points[1].blue.x, &fmt, |
|---|
| 209 | + &corner_points[1].blue.custom_float_x)) { |
|---|
| 167 | 210 | BREAK_TO_DEBUGGER(); |
|---|
| 168 | 211 | return false; |
|---|
| 169 | 212 | } |
|---|
| 170 | 213 | |
|---|
| 171 | | - if (fixpoint == true) |
|---|
| 172 | | - arr_points[1].custom_float_y = dc_fixpt_clamp_u0d14(arr_points[1].y); |
|---|
| 173 | | - else if (!convert_to_custom_float_format(arr_points[1].y, &fmt, |
|---|
| 174 | | - &arr_points[1].custom_float_y)) { |
|---|
| 214 | + if (fixpoint == true) { |
|---|
| 215 | + corner_points[1].red.custom_float_y = |
|---|
| 216 | + dc_fixpt_clamp_u0d14(corner_points[1].red.y); |
|---|
| 217 | + corner_points[1].green.custom_float_y = |
|---|
| 218 | + dc_fixpt_clamp_u0d14(corner_points[1].green.y); |
|---|
| 219 | + corner_points[1].blue.custom_float_y = |
|---|
| 220 | + dc_fixpt_clamp_u0d14(corner_points[1].blue.y); |
|---|
| 221 | + } else { |
|---|
| 222 | + if (!convert_to_custom_float_format(corner_points[1].red.y, |
|---|
| 223 | + &fmt, &corner_points[1].red.custom_float_y)) { |
|---|
| 224 | + BREAK_TO_DEBUGGER(); |
|---|
| 225 | + return false; |
|---|
| 226 | + } |
|---|
| 227 | + if (!convert_to_custom_float_format(corner_points[1].green.y, |
|---|
| 228 | + &fmt, &corner_points[1].green.custom_float_y)) { |
|---|
| 229 | + BREAK_TO_DEBUGGER(); |
|---|
| 230 | + return false; |
|---|
| 231 | + } |
|---|
| 232 | + if (!convert_to_custom_float_format(corner_points[1].blue.y, |
|---|
| 233 | + &fmt, &corner_points[1].blue.custom_float_y)) { |
|---|
| 234 | + BREAK_TO_DEBUGGER(); |
|---|
| 235 | + return false; |
|---|
| 236 | + } |
|---|
| 237 | + } |
|---|
| 238 | + |
|---|
| 239 | + if (!convert_to_custom_float_format(corner_points[1].red.slope, &fmt, |
|---|
| 240 | + &corner_points[1].red.custom_float_slope)) { |
|---|
| 175 | 241 | BREAK_TO_DEBUGGER(); |
|---|
| 176 | 242 | return false; |
|---|
| 177 | 243 | } |
|---|
| 178 | | - |
|---|
| 179 | | - if (!convert_to_custom_float_format(arr_points[1].slope, &fmt, |
|---|
| 180 | | - &arr_points[1].custom_float_slope)) { |
|---|
| 244 | + if (!convert_to_custom_float_format(corner_points[1].green.slope, &fmt, |
|---|
| 245 | + &corner_points[1].green.custom_float_slope)) { |
|---|
| 246 | + BREAK_TO_DEBUGGER(); |
|---|
| 247 | + return false; |
|---|
| 248 | + } |
|---|
| 249 | + if (!convert_to_custom_float_format(corner_points[1].blue.slope, &fmt, |
|---|
| 250 | + &corner_points[1].blue.custom_float_slope)) { |
|---|
| 181 | 251 | BREAK_TO_DEBUGGER(); |
|---|
| 182 | 252 | return false; |
|---|
| 183 | 253 | } |
|---|
| .. | .. |
|---|
| 242 | 312 | const struct dc_transfer_func *output_tf, |
|---|
| 243 | 313 | struct pwl_params *lut_params, bool fixpoint) |
|---|
| 244 | 314 | { |
|---|
| 245 | | - struct curve_points *arr_points; |
|---|
| 315 | + struct curve_points3 *corner_points; |
|---|
| 246 | 316 | struct pwl_result_data *rgb_resulted; |
|---|
| 247 | 317 | struct pwl_result_data *rgb; |
|---|
| 248 | 318 | struct pwl_result_data *rgb_plus_1; |
|---|
| 249 | | - struct fixed31_32 y_r; |
|---|
| 250 | | - struct fixed31_32 y_g; |
|---|
| 251 | | - struct fixed31_32 y_b; |
|---|
| 252 | | - struct fixed31_32 y1_min; |
|---|
| 253 | | - struct fixed31_32 y3_max; |
|---|
| 319 | + struct pwl_result_data *rgb_minus_1; |
|---|
| 254 | 320 | |
|---|
| 255 | 321 | int32_t region_start, region_end; |
|---|
| 256 | 322 | int32_t i; |
|---|
| .. | .. |
|---|
| 259 | 325 | if (output_tf == NULL || lut_params == NULL || output_tf->type == TF_TYPE_BYPASS) |
|---|
| 260 | 326 | return false; |
|---|
| 261 | 327 | |
|---|
| 262 | | - PERF_TRACE(); |
|---|
| 263 | | - |
|---|
| 264 | | - arr_points = lut_params->arr_points; |
|---|
| 328 | + corner_points = lut_params->corner_points; |
|---|
| 265 | 329 | rgb_resulted = lut_params->rgb_resulted; |
|---|
| 266 | 330 | hw_points = 0; |
|---|
| 267 | 331 | |
|---|
| 268 | 332 | memset(lut_params, 0, sizeof(struct pwl_params)); |
|---|
| 269 | 333 | memset(seg_distr, 0, sizeof(seg_distr)); |
|---|
| 270 | 334 | |
|---|
| 271 | | - if (output_tf->tf == TRANSFER_FUNCTION_PQ) { |
|---|
| 335 | + if (output_tf->tf == TRANSFER_FUNCTION_PQ || output_tf->tf == TRANSFER_FUNCTION_GAMMA22) { |
|---|
| 272 | 336 | /* 32 segments |
|---|
| 273 | 337 | * segments are from 2^-25 to 2^7 |
|---|
| 274 | 338 | */ |
|---|
| .. | .. |
|---|
| 278 | 342 | region_start = -MAX_LOW_POINT; |
|---|
| 279 | 343 | region_end = NUMBER_REGIONS - MAX_LOW_POINT; |
|---|
| 280 | 344 | } else { |
|---|
| 281 | | - /* 10 segments |
|---|
| 282 | | - * segment is from 2^-10 to 2^0 |
|---|
| 345 | + /* 11 segments |
|---|
| 346 | + * segment is from 2^-10 to 2^1 |
|---|
| 283 | 347 | * There are less than 256 points, for optimization |
|---|
| 284 | 348 | */ |
|---|
| 285 | 349 | seg_distr[0] = 3; |
|---|
| .. | .. |
|---|
| 328 | 392 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; |
|---|
| 329 | 393 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; |
|---|
| 330 | 394 | |
|---|
| 331 | | - arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
|---|
| 395 | + rgb_resulted[hw_points].red = rgb_resulted[hw_points - 1].red; |
|---|
| 396 | + rgb_resulted[hw_points].green = rgb_resulted[hw_points - 1].green; |
|---|
| 397 | + rgb_resulted[hw_points].blue = rgb_resulted[hw_points - 1].blue; |
|---|
| 398 | + |
|---|
| 399 | + // All 3 color channels have same x |
|---|
| 400 | + corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2), |
|---|
| 332 | 401 | dc_fixpt_from_int(region_start)); |
|---|
| 333 | | - arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
|---|
| 402 | + corner_points[0].green.x = corner_points[0].red.x; |
|---|
| 403 | + corner_points[0].blue.x = corner_points[0].red.x; |
|---|
| 404 | + |
|---|
| 405 | + corner_points[1].red.x = dc_fixpt_pow(dc_fixpt_from_int(2), |
|---|
| 334 | 406 | dc_fixpt_from_int(region_end)); |
|---|
| 407 | + corner_points[1].green.x = corner_points[1].red.x; |
|---|
| 408 | + corner_points[1].blue.x = corner_points[1].red.x; |
|---|
| 335 | 409 | |
|---|
| 336 | | - y_r = rgb_resulted[0].red; |
|---|
| 337 | | - y_g = rgb_resulted[0].green; |
|---|
| 338 | | - y_b = rgb_resulted[0].blue; |
|---|
| 410 | + corner_points[0].red.y = rgb_resulted[0].red; |
|---|
| 411 | + corner_points[0].green.y = rgb_resulted[0].green; |
|---|
| 412 | + corner_points[0].blue.y = rgb_resulted[0].blue; |
|---|
| 339 | 413 | |
|---|
| 340 | | - y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b)); |
|---|
| 341 | | - |
|---|
| 342 | | - arr_points[0].y = y1_min; |
|---|
| 343 | | - arr_points[0].slope = dc_fixpt_div(arr_points[0].y, arr_points[0].x); |
|---|
| 344 | | - y_r = rgb_resulted[hw_points - 1].red; |
|---|
| 345 | | - y_g = rgb_resulted[hw_points - 1].green; |
|---|
| 346 | | - y_b = rgb_resulted[hw_points - 1].blue; |
|---|
| 414 | + corner_points[0].red.slope = dc_fixpt_div(corner_points[0].red.y, |
|---|
| 415 | + corner_points[0].red.x); |
|---|
| 416 | + corner_points[0].green.slope = dc_fixpt_div(corner_points[0].green.y, |
|---|
| 417 | + corner_points[0].green.x); |
|---|
| 418 | + corner_points[0].blue.slope = dc_fixpt_div(corner_points[0].blue.y, |
|---|
| 419 | + corner_points[0].blue.x); |
|---|
| 347 | 420 | |
|---|
| 348 | 421 | /* see comment above, m_arrPoints[1].y should be the Y value for the |
|---|
| 349 | 422 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) |
|---|
| 350 | 423 | */ |
|---|
| 351 | | - y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b)); |
|---|
| 352 | | - |
|---|
| 353 | | - arr_points[1].y = y3_max; |
|---|
| 354 | | - |
|---|
| 355 | | - arr_points[1].slope = dc_fixpt_zero; |
|---|
| 424 | + corner_points[1].red.y = rgb_resulted[hw_points - 1].red; |
|---|
| 425 | + corner_points[1].green.y = rgb_resulted[hw_points - 1].green; |
|---|
| 426 | + corner_points[1].blue.y = rgb_resulted[hw_points - 1].blue; |
|---|
| 427 | + corner_points[1].red.slope = dc_fixpt_zero; |
|---|
| 428 | + corner_points[1].green.slope = dc_fixpt_zero; |
|---|
| 429 | + corner_points[1].blue.slope = dc_fixpt_zero; |
|---|
| 356 | 430 | |
|---|
| 357 | 431 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { |
|---|
| 358 | 432 | /* for PQ, we want to have a straight line from last HW X point, |
|---|
| .. | .. |
|---|
| 361 | 435 | const struct fixed31_32 end_value = |
|---|
| 362 | 436 | dc_fixpt_from_int(125); |
|---|
| 363 | 437 | |
|---|
| 364 | | - arr_points[1].slope = dc_fixpt_div( |
|---|
| 365 | | - dc_fixpt_sub(dc_fixpt_one, arr_points[1].y), |
|---|
| 366 | | - dc_fixpt_sub(end_value, arr_points[1].x)); |
|---|
| 438 | + corner_points[1].red.slope = dc_fixpt_div( |
|---|
| 439 | + dc_fixpt_sub(dc_fixpt_one, corner_points[1].red.y), |
|---|
| 440 | + dc_fixpt_sub(end_value, corner_points[1].red.x)); |
|---|
| 441 | + corner_points[1].green.slope = dc_fixpt_div( |
|---|
| 442 | + dc_fixpt_sub(dc_fixpt_one, corner_points[1].green.y), |
|---|
| 443 | + dc_fixpt_sub(end_value, corner_points[1].green.x)); |
|---|
| 444 | + corner_points[1].blue.slope = dc_fixpt_div( |
|---|
| 445 | + dc_fixpt_sub(dc_fixpt_one, corner_points[1].blue.y), |
|---|
| 446 | + dc_fixpt_sub(end_value, corner_points[1].blue.x)); |
|---|
| 367 | 447 | } |
|---|
| 368 | 448 | |
|---|
| 369 | 449 | lut_params->hw_points_num = hw_points; |
|---|
| .. | .. |
|---|
| 384 | 464 | |
|---|
| 385 | 465 | rgb = rgb_resulted; |
|---|
| 386 | 466 | rgb_plus_1 = rgb_resulted + 1; |
|---|
| 467 | + rgb_minus_1 = rgb; |
|---|
| 387 | 468 | |
|---|
| 388 | 469 | i = 1; |
|---|
| 389 | 470 | while (i != hw_points + 1) { |
|---|
| 390 | | - if (dc_fixpt_lt(rgb_plus_1->red, rgb->red)) |
|---|
| 391 | | - rgb_plus_1->red = rgb->red; |
|---|
| 392 | | - if (dc_fixpt_lt(rgb_plus_1->green, rgb->green)) |
|---|
| 393 | | - rgb_plus_1->green = rgb->green; |
|---|
| 394 | | - if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue)) |
|---|
| 395 | | - rgb_plus_1->blue = rgb->blue; |
|---|
| 471 | + |
|---|
| 472 | + if (i >= hw_points - 1) { |
|---|
| 473 | + if (dc_fixpt_lt(rgb_plus_1->red, rgb->red)) |
|---|
| 474 | + rgb_plus_1->red = dc_fixpt_add(rgb->red, rgb_minus_1->delta_red); |
|---|
| 475 | + if (dc_fixpt_lt(rgb_plus_1->green, rgb->green)) |
|---|
| 476 | + rgb_plus_1->green = dc_fixpt_add(rgb->green, rgb_minus_1->delta_green); |
|---|
| 477 | + if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue)) |
|---|
| 478 | + rgb_plus_1->blue = dc_fixpt_add(rgb->blue, rgb_minus_1->delta_blue); |
|---|
| 479 | + } |
|---|
| 396 | 480 | |
|---|
| 397 | 481 | rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); |
|---|
| 398 | 482 | rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); |
|---|
| .. | .. |
|---|
| 408 | 492 | } |
|---|
| 409 | 493 | |
|---|
| 410 | 494 | ++rgb_plus_1; |
|---|
| 495 | + rgb_minus_1 = rgb; |
|---|
| 411 | 496 | ++rgb; |
|---|
| 412 | 497 | ++i; |
|---|
| 413 | 498 | } |
|---|
| 414 | 499 | cm_helper_convert_to_custom_float(rgb_resulted, |
|---|
| 415 | | - lut_params->arr_points, |
|---|
| 500 | + lut_params->corner_points, |
|---|
| 416 | 501 | hw_points, fixpoint); |
|---|
| 417 | 502 | |
|---|
| 418 | 503 | return true; |
|---|
| .. | .. |
|---|
| 425 | 510 | const struct dc_transfer_func *output_tf, |
|---|
| 426 | 511 | struct pwl_params *lut_params) |
|---|
| 427 | 512 | { |
|---|
| 428 | | - struct curve_points *arr_points; |
|---|
| 513 | + struct curve_points3 *corner_points; |
|---|
| 429 | 514 | struct pwl_result_data *rgb_resulted; |
|---|
| 430 | 515 | struct pwl_result_data *rgb; |
|---|
| 431 | 516 | struct pwl_result_data *rgb_plus_1; |
|---|
| 432 | | - struct fixed31_32 y_r; |
|---|
| 433 | | - struct fixed31_32 y_g; |
|---|
| 434 | | - struct fixed31_32 y_b; |
|---|
| 435 | | - struct fixed31_32 y1_min; |
|---|
| 436 | | - struct fixed31_32 y3_max; |
|---|
| 437 | 517 | |
|---|
| 438 | 518 | int32_t region_start, region_end; |
|---|
| 439 | 519 | int32_t i; |
|---|
| .. | .. |
|---|
| 442 | 522 | if (output_tf == NULL || lut_params == NULL || output_tf->type == TF_TYPE_BYPASS) |
|---|
| 443 | 523 | return false; |
|---|
| 444 | 524 | |
|---|
| 445 | | - PERF_TRACE(); |
|---|
| 446 | | - |
|---|
| 447 | | - arr_points = lut_params->arr_points; |
|---|
| 525 | + corner_points = lut_params->corner_points; |
|---|
| 448 | 526 | rgb_resulted = lut_params->rgb_resulted; |
|---|
| 449 | 527 | hw_points = 0; |
|---|
| 450 | 528 | |
|---|
| .. | .. |
|---|
| 490 | 568 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; |
|---|
| 491 | 569 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; |
|---|
| 492 | 570 | |
|---|
| 493 | | - arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
|---|
| 571 | + rgb_resulted[hw_points].red = rgb_resulted[hw_points - 1].red; |
|---|
| 572 | + rgb_resulted[hw_points].green = rgb_resulted[hw_points - 1].green; |
|---|
| 573 | + rgb_resulted[hw_points].blue = rgb_resulted[hw_points - 1].blue; |
|---|
| 574 | + |
|---|
| 575 | + corner_points[0].red.x = dc_fixpt_pow(dc_fixpt_from_int(2), |
|---|
| 494 | 576 | dc_fixpt_from_int(region_start)); |
|---|
| 495 | | - arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2), |
|---|
| 577 | + corner_points[0].green.x = corner_points[0].red.x; |
|---|
| 578 | + corner_points[0].blue.x = corner_points[0].red.x; |
|---|
| 579 | + corner_points[1].red.x = dc_fixpt_pow(dc_fixpt_from_int(2), |
|---|
| 496 | 580 | dc_fixpt_from_int(region_end)); |
|---|
| 581 | + corner_points[1].green.x = corner_points[1].red.x; |
|---|
| 582 | + corner_points[1].blue.x = corner_points[1].red.x; |
|---|
| 497 | 583 | |
|---|
| 498 | | - y_r = rgb_resulted[0].red; |
|---|
| 499 | | - y_g = rgb_resulted[0].green; |
|---|
| 500 | | - y_b = rgb_resulted[0].blue; |
|---|
| 501 | | - |
|---|
| 502 | | - y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b)); |
|---|
| 503 | | - |
|---|
| 504 | | - arr_points[0].y = y1_min; |
|---|
| 505 | | - arr_points[0].slope = dc_fixpt_div(arr_points[0].y, arr_points[0].x); |
|---|
| 506 | | - y_r = rgb_resulted[hw_points - 1].red; |
|---|
| 507 | | - y_g = rgb_resulted[hw_points - 1].green; |
|---|
| 508 | | - y_b = rgb_resulted[hw_points - 1].blue; |
|---|
| 584 | + corner_points[0].red.y = rgb_resulted[0].red; |
|---|
| 585 | + corner_points[0].green.y = rgb_resulted[0].green; |
|---|
| 586 | + corner_points[0].blue.y = rgb_resulted[0].blue; |
|---|
| 509 | 587 | |
|---|
| 510 | 588 | /* see comment above, m_arrPoints[1].y should be the Y value for the |
|---|
| 511 | 589 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) |
|---|
| 512 | 590 | */ |
|---|
| 513 | | - y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b)); |
|---|
| 514 | | - |
|---|
| 515 | | - arr_points[1].y = y3_max; |
|---|
| 516 | | - |
|---|
| 517 | | - arr_points[1].slope = dc_fixpt_zero; |
|---|
| 591 | + corner_points[1].red.y = rgb_resulted[hw_points - 1].red; |
|---|
| 592 | + corner_points[1].green.y = rgb_resulted[hw_points - 1].green; |
|---|
| 593 | + corner_points[1].blue.y = rgb_resulted[hw_points - 1].blue; |
|---|
| 594 | + corner_points[1].red.slope = dc_fixpt_zero; |
|---|
| 595 | + corner_points[1].green.slope = dc_fixpt_zero; |
|---|
| 596 | + corner_points[1].blue.slope = dc_fixpt_zero; |
|---|
| 518 | 597 | |
|---|
| 519 | 598 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { |
|---|
| 520 | 599 | /* for PQ, we want to have a straight line from last HW X point, |
|---|
| .. | .. |
|---|
| 523 | 602 | const struct fixed31_32 end_value = |
|---|
| 524 | 603 | dc_fixpt_from_int(125); |
|---|
| 525 | 604 | |
|---|
| 526 | | - arr_points[1].slope = dc_fixpt_div( |
|---|
| 527 | | - dc_fixpt_sub(dc_fixpt_one, arr_points[1].y), |
|---|
| 528 | | - dc_fixpt_sub(end_value, arr_points[1].x)); |
|---|
| 605 | + corner_points[1].red.slope = dc_fixpt_div( |
|---|
| 606 | + dc_fixpt_sub(dc_fixpt_one, corner_points[1].red.y), |
|---|
| 607 | + dc_fixpt_sub(end_value, corner_points[1].red.x)); |
|---|
| 608 | + corner_points[1].green.slope = dc_fixpt_div( |
|---|
| 609 | + dc_fixpt_sub(dc_fixpt_one, corner_points[1].green.y), |
|---|
| 610 | + dc_fixpt_sub(end_value, corner_points[1].green.x)); |
|---|
| 611 | + corner_points[1].blue.slope = dc_fixpt_div( |
|---|
| 612 | + dc_fixpt_sub(dc_fixpt_one, corner_points[1].blue.y), |
|---|
| 613 | + dc_fixpt_sub(end_value, corner_points[1].blue.x)); |
|---|
| 529 | 614 | } |
|---|
| 530 | 615 | |
|---|
| 531 | 616 | lut_params->hw_points_num = hw_points; |
|---|
| .. | .. |
|---|
| 549 | 634 | |
|---|
| 550 | 635 | i = 1; |
|---|
| 551 | 636 | while (i != hw_points + 1) { |
|---|
| 552 | | - if (dc_fixpt_lt(rgb_plus_1->red, rgb->red)) |
|---|
| 553 | | - rgb_plus_1->red = rgb->red; |
|---|
| 554 | | - if (dc_fixpt_lt(rgb_plus_1->green, rgb->green)) |
|---|
| 555 | | - rgb_plus_1->green = rgb->green; |
|---|
| 556 | | - if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue)) |
|---|
| 557 | | - rgb_plus_1->blue = rgb->blue; |
|---|
| 558 | | - |
|---|
| 559 | 637 | rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red); |
|---|
| 560 | 638 | rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green); |
|---|
| 561 | 639 | rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue); |
|---|
| .. | .. |
|---|
| 565 | 643 | ++i; |
|---|
| 566 | 644 | } |
|---|
| 567 | 645 | cm_helper_convert_to_custom_float(rgb_resulted, |
|---|
| 568 | | - lut_params->arr_points, |
|---|
| 646 | + lut_params->corner_points, |
|---|
| 569 | 647 | hw_points, false); |
|---|
| 570 | 648 | |
|---|
| 571 | 649 | return true; |
|---|