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

Documentation/amdgpu_dm: Add DM color correction documentation

AMDGPU DM maps DRM color management properties (degamma, ctm and gamma)
to DC color correction entities. Part of this mapping is already
documented as code comments and can be converted as kernel docs.

v2:
- rebase to amd-staging-drm-next
- fix typos (Tales)
- undo kernel-docs inside functions (Tales)

Signed-off-by: Melissa Wen <mwen@igalia.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Tales Aparecida <tales.aparecida@gmail.com>
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Melissa Wen and committed by
Alex Deucher
cdeec9a1 db910f10

+90 -28
+9
Documentation/gpu/amdgpu/display/display-manager.rst
··· 40 40 41 41 .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 42 42 :functions: amdgpu_dm_atomic_check amdgpu_dm_atomic_commit_tail 43 + 44 + Color Management Properties 45 + =========================== 46 + 47 + .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c 48 + :doc: overview 49 + 50 + .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c 51 + :internal:
+81 -28
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
··· 29 29 #include "modules/color/color_gamma.h" 30 30 #include "basics/conversion.h" 31 31 32 - /* 32 + /** 33 + * DOC: overview 34 + * 33 35 * The DC interface to HW gives us the following color management blocks 34 36 * per pipe (surface): 35 37 * ··· 73 71 74 72 #define MAX_DRM_LUT_VALUE 0xFFFF 75 73 76 - /* 77 - * Initialize the color module. 74 + /** 75 + * amdgpu_dm_init_color_mod - Initialize the color module. 78 76 * 79 77 * We're not using the full color module, only certain components. 80 78 * Only call setup functions for components that we need. ··· 84 82 setup_x_points_distribution(); 85 83 } 86 84 87 - /* Extracts the DRM lut and lut size from a blob. */ 85 + /** 86 + * __extract_blob_lut - Extracts the DRM lut and lut size from a blob. 87 + * @blob: DRM color mgmt property blob 88 + * @size: lut size 89 + * 90 + * Returns: 91 + * DRM LUT or NULL 92 + */ 88 93 static const struct drm_color_lut * 89 94 __extract_blob_lut(const struct drm_property_blob *blob, uint32_t *size) 90 95 { ··· 99 90 return blob ? (struct drm_color_lut *)blob->data : NULL; 100 91 } 101 92 102 - /* 103 - * Return true if the given lut is a linear mapping of values, i.e. it acts 104 - * like a bypass LUT. 93 + /** 94 + * __is_lut_linear - check if the given lut is a linear mapping of values 95 + * @lut: given lut to check values 96 + * @size: lut size 105 97 * 106 98 * It is considered linear if the lut represents: 107 - * f(a) = (0xFF00/MAX_COLOR_LUT_ENTRIES-1)a; for integer a in 108 - * [0, MAX_COLOR_LUT_ENTRIES) 99 + * f(a) = (0xFF00/MAX_COLOR_LUT_ENTRIES-1)a; for integer a in [0, 100 + * MAX_COLOR_LUT_ENTRIES) 101 + * 102 + * Returns: 103 + * True if the given lut is a linear mapping of values, i.e. it acts like a 104 + * bypass LUT. Otherwise, false. 109 105 */ 110 106 static bool __is_lut_linear(const struct drm_color_lut *lut, uint32_t size) 111 107 { ··· 133 119 return true; 134 120 } 135 121 136 - /* 137 - * Convert the drm_color_lut to dc_gamma. The conversion depends on the size 138 - * of the lut - whether or not it's legacy. 122 + /** 123 + * __drm_lut_to_dc_gamma - convert the drm_color_lut to dc_gamma. 124 + * @lut: DRM lookup table for color conversion 125 + * @gamma: DC gamma to set entries 126 + * @is_legacy: legacy or atomic gamma 127 + * 128 + * The conversion depends on the size of the lut - whether or not it's legacy. 139 129 */ 140 130 static void __drm_lut_to_dc_gamma(const struct drm_color_lut *lut, 141 131 struct dc_gamma *gamma, bool is_legacy) ··· 172 154 } 173 155 } 174 156 175 - /* 176 - * Converts a DRM CTM to a DC CSC float matrix. 157 + /** 158 + * __drm_ctm_to_dc_matrix - converts a DRM CTM to a DC CSC float matrix 159 + * @ctm: DRM color transformation matrix 160 + * @matrix: DC CSC float matrix 161 + * 177 162 * The matrix needs to be a 3x4 (12 entry) matrix. 178 163 */ 179 164 static void __drm_ctm_to_dc_matrix(const struct drm_color_ctm *ctm, ··· 210 189 } 211 190 } 212 191 213 - /* Calculates the legacy transfer function - only for sRGB input space. */ 192 + /** 193 + * __set_legacy_tf - Calculates the legacy transfer function 194 + * @func: transfer function 195 + * @lut: lookup table that defines the color space 196 + * @lut_size: size of respective lut 197 + * @has_rom: if ROM can be used for hardcoded curve 198 + * 199 + * Only for sRGB input space 200 + * 201 + * Returns: 202 + * 0 in case of success, -ENOMEM if fails 203 + */ 214 204 static int __set_legacy_tf(struct dc_transfer_func *func, 215 205 const struct drm_color_lut *lut, uint32_t lut_size, 216 206 bool has_rom) ··· 250 218 return res ? 0 : -ENOMEM; 251 219 } 252 220 253 - /* Calculates the output transfer function based on expected input space. */ 221 + /** 222 + * __set_output_tf - calculates the output transfer function based on expected input space. 223 + * @func: transfer function 224 + * @lut: lookup table that defines the color space 225 + * @lut_size: size of respective lut 226 + * @has_rom: if ROM can be used for hardcoded curve 227 + * 228 + * Returns: 229 + * 0 in case of success. -ENOMEM if fails. 230 + */ 254 231 static int __set_output_tf(struct dc_transfer_func *func, 255 232 const struct drm_color_lut *lut, uint32_t lut_size, 256 233 bool has_rom) ··· 303 262 return res ? 0 : -ENOMEM; 304 263 } 305 264 306 - /* Caculates the input transfer function based on expected input space. */ 265 + /** 266 + * __set_input_tf - calculates the input transfer function based on expected 267 + * input space. 268 + * @func: transfer function 269 + * @lut: lookup table that defines the color space 270 + * @lut_size: size of respective lut. 271 + * 272 + * Returns: 273 + * 0 in case of success. -ENOMEM if fails. 274 + */ 307 275 static int __set_input_tf(struct dc_transfer_func *func, 308 276 const struct drm_color_lut *lut, uint32_t lut_size) 309 277 { ··· 335 285 } 336 286 337 287 /** 338 - * amdgpu_dm_verify_lut_sizes 288 + * amdgpu_dm_verify_lut_sizes - verifies if DRM luts match the hw supported sizes 339 289 * @crtc_state: the DRM CRTC state 340 290 * 341 - * Verifies that the Degamma and Gamma LUTs attached to the |crtc_state| are of 342 - * the expected size. 291 + * Verifies that the Degamma and Gamma LUTs attached to the &crtc_state 292 + * are of the expected size. 343 293 * 344 - * Returns 0 on success. 294 + * Returns: 295 + * 0 on success. -EINVAL if any lut sizes are invalid. 345 296 */ 346 297 int amdgpu_dm_verify_lut_sizes(const struct drm_crtc_state *crtc_state) 347 298 { ··· 378 327 * of the HW blocks as long as the CRTC CTM always comes before the 379 328 * CRTC RGM and after the CRTC DGM. 380 329 * 381 - * The CRTC RGM block will be placed in the RGM LUT block if it is non-linear. 382 - * The CRTC DGM block will be placed in the DGM LUT block if it is non-linear. 383 - * The CRTC CTM will be placed in the gamut remap block if it is non-linear. 330 + * - The CRTC RGM block will be placed in the RGM LUT block if it is non-linear. 331 + * - The CRTC DGM block will be placed in the DGM LUT block if it is non-linear. 332 + * - The CRTC CTM will be placed in the gamut remap block if it is non-linear. 384 333 * 385 334 * The RGM block is typically more fully featured and accurate across 386 335 * all ASICs - DCE can't support a custom non-linear CRTC DGM. ··· 389 338 * management at once we have to either restrict the usage of CRTC properties 390 339 * or blend adjustments together. 391 340 * 392 - * Returns 0 on success. 341 + * Returns: 342 + * 0 on success. Error code if setup fails. 393 343 */ 394 344 int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc) 395 345 { ··· 445 393 if (r) 446 394 return r; 447 395 } else if (has_regamma) { 448 - /* CRTC RGM goes into RGM LUT. */ 396 + /* If atomic regamma, CRTC RGM goes into RGM LUT. */ 449 397 stream->out_transfer_func->type = TF_TYPE_DISTRIBUTED_POINTS; 450 398 stream->out_transfer_func->tf = TRANSFER_FUNCTION_LINEAR; 451 399 ··· 502 450 * 503 451 * Update the underlying dc_stream_state's input transfer function (ITF) in 504 452 * preparation for hardware commit. The transfer function used depends on 505 - * the prepartion done on the stream for color management. 453 + * the preparation done on the stream for color management. 506 454 * 507 - * Returns 0 on success. 455 + * Returns: 456 + * 0 on success. -ENOMEM if mem allocation fails. 508 457 */ 509 458 int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc, 510 459 struct dc_plane_state *dc_plane_state)