1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
|
/* SPDX-License-Identifier: MIT */
/*
* Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DRM_COLOROP_H__
#define __DRM_COLOROP_H__
#include <drm/drm_mode_object.h>
#include <drm/drm_mode.h>
#include <drm/drm_property.h>
/* DRM colorop flags */
#define DRM_COLOROP_FLAG_ALLOW_BYPASS (1<<0) /* Allow bypass on the drm_colorop */
/**
* enum drm_colorop_curve_1d_type - type of 1D curve
*
* Describes a 1D curve to be applied by the DRM_COLOROP_1D_CURVE colorop.
*/
enum drm_colorop_curve_1d_type {
/**
* @DRM_COLOROP_1D_CURVE_SRGB_EOTF:
*
* enum string "sRGB EOTF"
*
* sRGB piece-wise electro-optical transfer function. Transfer
* characteristics as defined by IEC 61966-2-1 sRGB. Equivalent
* to H.273 TransferCharacteristics code point 13 with
* MatrixCoefficients set to 0.
*/
DRM_COLOROP_1D_CURVE_SRGB_EOTF,
/**
* @DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF:
*
* enum string "sRGB Inverse EOTF"
*
* The inverse of &DRM_COLOROP_1D_CURVE_SRGB_EOTF
*/
DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF,
/**
* @DRM_COLOROP_1D_CURVE_PQ_125_EOTF:
*
* enum string "PQ 125 EOTF"
*
* The PQ transfer function, scaled by 125.0f, so that 10,000
* nits correspond to 125.0f.
*
* Transfer characteristics of the PQ function as defined by
* SMPTE ST 2084 (2014) for 10-, 12-, 14-, and 16-bit systems
* and Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system,
* represented by H.273 TransferCharacteristics code point 16.
*/
DRM_COLOROP_1D_CURVE_PQ_125_EOTF,
/**
* @DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF:
*
* enum string "PQ 125 Inverse EOTF"
*
* The inverse of DRM_COLOROP_1D_CURVE_PQ_125_EOTF.
*/
DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF,
/**
* @DRM_COLOROP_1D_CURVE_BT2020_INV_OETF:
*
* enum string "BT.2020 Inverse OETF"
*
* The inverse of &DRM_COLOROP_1D_CURVE_BT2020_OETF
*/
DRM_COLOROP_1D_CURVE_BT2020_INV_OETF,
/**
* @DRM_COLOROP_1D_CURVE_BT2020_OETF:
*
* enum string "BT.2020 OETF"
*
* The BT.2020/BT.709 transfer function. The BT.709 and BT.2020
* transfer functions are the same, the only difference is that
* BT.2020 is defined with more precision for 10 and 12-bit
* encodings.
*
*
*/
DRM_COLOROP_1D_CURVE_BT2020_OETF,
/**
* @DRM_COLOROP_1D_CURVE_GAMMA22:
*
* enum string "Gamma 2.2"
*
* A gamma 2.2 power function. This applies a power curve with
* gamma value of 2.2 to the input values.
*/
DRM_COLOROP_1D_CURVE_GAMMA22,
/**
* @DRM_COLOROP_1D_CURVE_GAMMA22_INV:
*
* enum string "Gamma 2.2 Inverse"
*
* The inverse of &DRM_COLOROP_1D_CURVE_GAMMA22
*/
DRM_COLOROP_1D_CURVE_GAMMA22_INV,
/**
* @DRM_COLOROP_1D_CURVE_COUNT:
*
* enum value denoting the size of the enum
*/
DRM_COLOROP_1D_CURVE_COUNT
};
/**
* struct drm_colorop_state - mutable colorop state
*/
struct drm_colorop_state {
/** @colorop: backpointer to the colorop */
struct drm_colorop *colorop;
/*
* Color properties
*
* The following fields are not always valid, their usage depends
* on the colorop type. See their associated comment for more
* information.
*/
/**
* @bypass:
*
* When the property BYPASS exists on this colorop, this stores
* the requested bypass state: true if colorop shall be bypassed,
* false if colorop is enabled.
*/
bool bypass;
/**
* @curve_1d_type:
*
* Type of 1D curve.
*/
enum drm_colorop_curve_1d_type curve_1d_type;
/**
* @multiplier:
*
* Multiplier to 'gain' the plane. Format is S31.32 sign-magnitude.
*/
uint64_t multiplier;
/**
* @data:
*
* Data blob for any TYPE that requires such a blob. The
* interpretation of the blob is TYPE-specific.
*
* See the &drm_colorop_type documentation for how blob is laid
* out.
*/
struct drm_property_blob *data;
/** @state: backpointer to global drm_atomic_state */
struct drm_atomic_state *state;
};
/**
* struct drm_colorop - DRM color operation control structure
*
* A colorop represents one color operation. They can be chained via
* the 'next' pointer to build a color pipeline.
*
* Since colorops cannot stand-alone and are used to describe colorop
* operations on a plane they don't have their own locking mechanism but
* are locked and programmed along with their associated &drm_plane.
*
*/
struct drm_colorop {
/** @dev: parent DRM device */
struct drm_device *dev;
/**
* @head:
*
* List of all colorops on @dev, linked from &drm_mode_config.colorop_list.
* Invariant over the lifetime of @dev and therefore does not need
* locking.
*/
struct list_head head;
/**
* @index: Position inside the mode_config.list, can be used as an array
* index. It is invariant over the lifetime of the colorop.
*/
unsigned int index;
/** @base: base mode object */
struct drm_mode_object base;
/**
* @plane:
*
* The plane on which the colorop sits. A drm_colorop is always unique
* to a plane.
*/
struct drm_plane *plane;
/**
* @state:
*
* Current atomic state for this colorop.
*
* This is protected by @mutex. Note that nonblocking atomic commits
* access the current colorop state without taking locks.
*/
struct drm_colorop_state *state;
/*
* Color properties
*
* The following fields are not always valid, their usage depends
* on the colorop type. See their associated comment for more
* information.
*/
/** @properties: property tracking for this colorop */
struct drm_object_properties properties;
/**
* @type:
*
* Read-only
* Type of color operation
*/
enum drm_colorop_type type;
/**
* @next:
*
* Read-only
* Pointer to next drm_colorop in pipeline
*/
struct drm_colorop *next;
/**
* @type_property:
*
* Read-only "TYPE" property for specifying the type of
* this color operation. The type is enum drm_colorop_type.
*/
struct drm_property *type_property;
/**
* @bypass_property:
*
* Boolean property to control enablement of the color
* operation. Only present if DRM_COLOROP_FLAG_ALLOW_BYPASS
* flag is set. When present, setting bypass to "true" shall
* always be supported to allow compositors to quickly fall
* back to alternate methods of color processing. This is
* important since setting color operations can fail due to
* unique HW constraints.
*/
struct drm_property *bypass_property;
/**
* @size:
*
* Number of entries of the custom LUT. This should be read-only.
*/
uint32_t size;
/**
* @lut1d_interpolation:
*
* Read-only
* Interpolation for DRM_COLOROP_1D_LUT
*/
enum drm_colorop_lut1d_interpolation_type lut1d_interpolation;
/**
* @lut3d_interpolation:
*
* Read-only
* Interpolation for DRM_COLOROP_3D_LUT
*/
enum drm_colorop_lut3d_interpolation_type lut3d_interpolation;
/**
* @lut1d_interpolation_property:
*
* Read-only property for DRM_COLOROP_1D_LUT interpolation
*/
struct drm_property *lut1d_interpolation_property;
/**
* @curve_1d_type_property:
*
* Sub-type for DRM_COLOROP_1D_CURVE type.
*/
struct drm_property *curve_1d_type_property;
/**
* @multiplier_property:
*
* Multiplier property for plane gain
*/
struct drm_property *multiplier_property;
/**
* @size_property:
*
* Size property for custom LUT from userspace.
*/
struct drm_property *size_property;
/**
* @lut3d_interpolation_property:
*
* Read-only property for DRM_COLOROP_3D_LUT interpolation
*/
struct drm_property *lut3d_interpolation_property;
/**
* @data_property:
*
* blob property for any TYPE that requires a blob of data,
* such as 1DLUT, CTM, 3DLUT, etc.
*
* The way this blob is interpreted depends on the TYPE of
* this
*/
struct drm_property *data_property;
/**
* @next_property:
*
* Read-only property to next colorop in the pipeline
*/
struct drm_property *next_property;
};
#define obj_to_colorop(x) container_of(x, struct drm_colorop, base)
/**
* drm_colorop_find - look up a Colorop object from its ID
* @dev: DRM device
* @file_priv: drm file to check for lease against.
* @id: &drm_mode_object ID
*
* This can be used to look up a Colorop from its userspace ID. Only used by
* drivers for legacy IOCTLs and interface, nowadays extensions to the KMS
* userspace interface should be done using &drm_property.
*/
static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,
struct drm_file *file_priv,
uint32_t id)
{
struct drm_mode_object *mo;
mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_COLOROP);
return mo ? obj_to_colorop(mo) : NULL;
}
void drm_colorop_pipeline_destroy(struct drm_device *dev);
void drm_colorop_cleanup(struct drm_colorop *colorop);
int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, u64 supported_tfs, uint32_t flags);
int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, uint32_t lut_size,
enum drm_colorop_lut1d_interpolation_type interpolation,
uint32_t flags);
int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, uint32_t flags);
int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, uint32_t flags);
int drm_plane_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane,
uint32_t lut_size,
enum drm_colorop_lut3d_interpolation_type interpolation,
uint32_t flags);
struct drm_colorop_state *
drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);
void drm_colorop_atomic_destroy_state(struct drm_colorop *colorop,
struct drm_colorop_state *state);
/**
* drm_colorop_reset - reset colorop atomic state
* @colorop: drm colorop
*
* Resets the atomic state for @colorop by freeing the state pointer (which might
* be NULL, e.g. at driver load time) and allocating a new empty state object.
*/
void drm_colorop_reset(struct drm_colorop *colorop);
/**
* drm_colorop_index - find the index of a registered colorop
* @colorop: colorop to find index for
*
* Given a registered colorop, return the index of that colorop within a DRM
* device's list of colorops.
*/
static inline unsigned int drm_colorop_index(const struct drm_colorop *colorop)
{
return colorop->index;
}
#define drm_for_each_colorop(colorop, dev) \
list_for_each_entry(colorop, &(dev)->mode_config.colorop_list, head)
/**
* drm_get_colorop_type_name - return a string for colorop type
* @type: colorop type to compute name of
*
* In contrast to the other drm_get_*_name functions this one here returns a
* const pointer and hence is threadsafe.
*/
const char *drm_get_colorop_type_name(enum drm_colorop_type type);
/**
* drm_get_colorop_curve_1d_type_name - return a string for 1D curve type
* @type: 1d curve type to compute name of
*
* In contrast to the other drm_get_*_name functions this one here returns a
* const pointer and hence is threadsafe.
*/
const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type);
const char *
drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_interpolation_type type);
const char *
drm_get_colorop_lut3d_interpolation_name(enum drm_colorop_lut3d_interpolation_type type);
void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next);
#endif /* __DRM_COLOROP_H__ */
|