Add Plane Color Properties
Subsystems (4)
v5 cover Add Plane Color Properties
This is how a typical display color hardware pipeline looks like:
+-------------------------------------------+
| RAM |
| +------+ +---------+ +---------+ |
| | FB 1 | | FB 2 | | FB N | |
| +------+ +---------+ +---------+ |
+-------------------------------------------+
| Plane Color Hardware Block |
+--------------------------------------------+
| +---v-----+ +---v-------+ +---v------+ |
| | Plane A | | Plane B | | Plane N | |
| | DeGamma | | Degamma | | Degamma | |
| +---+-----+ +---+-------+ +---+------+ |
| | | | |
| +---v-----+ +---v-------+ +---v------+ |
| |Plane A | | Plane B | | Plane N | |
| |CSC/CTM | | CSC/CTM | | CSC/CTM | |
| +---+-----+ +----+------+ +----+-----+ |
| | | | |
| +---v-----+ +----v------+ +----v-----+ |
| | Plane A | | Plane B | | Plane N | |
| | Gamma | | Gamma | | Gamma | |
| +---+-----+ +----+------+ +----+-----+ |
| | | | |
+--------------------------------------------+
+------v--------------v---------------v-------|
|| ||
|| Pipe Blender ||
+--------------------+------------------------+
| | |
| +-----------v----------+ |
| | Pipe DeGamma | |
| | | |
| +-----------+----------+ |
| | Pipe Color |
| +-----------v----------+ Hardware |
| | Pipe CSC/CTM | |
| | | |
| +-----------+----------+ |
| | |
| +-----------v----------+ |
| | Pipe Gamma | |
| | | |
| +-----------+----------+ |
| | |
+---------------------------------------------+
| v
Pipe Output
This patch series adds properties for plane color features. It adds properties for degamma used to linearize data, CSC used for gamut conversion, and gamma used to again non-linearize data as per panel supported color space. These can be utilize by user space to convert planes from one format to another, one color space to another etc.
Usersapce can take smart blending decisions and utilize these hardware supported plane color features to get accurate color profile. The same can help in consistent color quality from source to panel taking advantage of advanced color features in hardware.
These patches just add the property interfaces and enable helper functions.
This series adds Intel Gen9 specific plane gamma feature. We can build up and add other platform/hardware specific implementation on top of this series
Note: This is just to get a design feedback whether these interfaces look ok. Based on community feedback on interfaces, we will implement IGT tests to validate plane color features. This is un-tested currently.
Userspace implementation using these properties have been done in drm hwcomposer by "Alexandru-Cosmin Gheorghe [email protected]" from ARM. A merge request has been opened by Alexandru for drm_hwcomposer, implementing the property changes for the same. Please review that as well:
https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/merge_requests/25
v2: Dropped legacy gamma table for plane as suggested by Maarten. Added Gen9/BDW plane gamma feature and rebase on tot.
v3: Added a new drm_color_lut_ext structure to accommodate 32 bit precision entries, pointed to by Brian, Starkey for HDR usecases. Addressed Sean,Paul comments and moved plane color properties to drm_plane instead of mode_config. Added property documentation as suggested by Daniel, Vetter. Fixed a rebase fumble which occurred in v2, pointed by Emil Velikov.
v4: Rebase
v5: Added "Display Color Hardware Pipeline" flow to kernel documentation as suggested by "Ville Syrjala" and "Brian Starkey". Moved the property creation to drm_color_mgmt.c file to consolidate all color operations at one place. Addressed Alexandru's review comments.
Uma Shankar (8):
drm: Add Enhanced Gamma LUT precision structure
drm: Add Plane Degamma properties
drm: Add Plane CTM property
drm: Add Plane Gamma properties
drm: Define helper function for plane color enabling drm/i915: Enable plane color features
drm/i915: Implement Plane Gamma for Bdw and Gen9 platforms drm/i915: Load plane color luts from atomic flip
Documentation/gpu/drm-kms.rst | 99 +++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 32 +++++++ drivers/gpu/drm/drm_atomic_helper.c | 13 +++ drivers/gpu/drm/drm_color_mgmt.c | 140 +++++++++++++++++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 5 ++ drivers/gpu/drm/i915/i915_pci.c | 5 +- drivers/gpu/drm/i915/i915_reg.h | 25 ++++++ drivers/gpu/drm/i915/intel_atomic_plane.c | 4 + drivers/gpu/drm/i915/intel_color.c | 80 +++++++++++++++++ drivers/gpu/drm/i915/intel_device_info.h | 5 ++ drivers/gpu/drm/i915/intel_display.c | 4 + drivers/gpu/drm/i915/intel_drv.h | 10 +++ drivers/gpu/drm/i915/intel_sprite.c | 4 + include/drm/drm_color_mgmt.h | 6 ++ include/drm/drm_plane.h | 61 +++++++++++++ include/uapi/drm/drm_mode.h | 15 ++++ 16 files changed, 504 insertions(+), 4 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v5 1/8 drm: Add Enhanced Gamma LUT precision structure
Existing LUT precision structure is having only 16 bit precision. This is not enough for upcoming enhanced hardwares and advance usecases like HDR processing. Hence added a new structure with 32 bit precision values. Also added the code, for extracting the same from values passed from userspace.
v4: Rebase
v5: Relocated the helper function to drm_color_mgmt.c. Declared the same in a header file (Alexandru Gheorghe)
--- drivers/gpu/drm/drm_color_mgmt.c | 19 +++++++++++++++++++ include/drm/drm_color_mgmt.h | 1 + include/uapi/drm/drm_mode.h | 15 +++++++++++++++ 3 files changed, 35 insertions(+)
drivers/gpu/drm/drm_color_mgmt.c +19 -0
@@ -128,6 +128,25 @@ uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) }EXPORT_SYMBOL (drm_color_lut_extract); +/* +* Added to accommodate enhanced LUT precision. +* Max LUT precision is 32 bits. +*/ +uint32_t drm_color_lut_extract_ext (uint32_t user_input,uint32_t bit_precision) +{ +uint32_t val = user_input; +uint32_t max =0xffffffff >> (32 - bit_precision); + +/* Round only if we're not using full precision. */ +if (bit_precision <32 ) { + val +=1UL << (32 - bit_precision -1 ); + val >>=32 - bit_precision; + } + +return clamp_val (val,0 , max); +} +EXPORT_SYMBOL (drm_color_lut_extract_ext); +/** * drm_crtc_enable_color_mgmt - enable color management properties * @crtc: DRM CRTC
include/drm/drm_color_mgmt.h +1 -0
@@ -29,6 +29,7 @@struct drm_plane ;uint32_t drm_color_lut_extract (uint32_t user_input,uint32_t bit_precision); +uint32_t drm_color_lut_extract_ext (uint32_t user_input,uint32_t bit_precision); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size,
include/uapi/drm/drm_mode.h +15 -0
@@ -629,6 +629,21 @@ struct drm_color_lut {__u16 reserved; }; +/* +* Creating 32 bit palette entries for better data +* precision. This will be required for HDR and +* similar color processing usecases. +*/ +struct drm_color_lut_ext { +/* +* Data is U0.32 fixed point format. +*/ +__u32 red; +__u32 green; +__u32 blue; +__u32 reserved; +}; +#define DRM_MODE_PAGE_FLIP_EVENT 0x01#define DRM_MODE_PAGE_FLIP_ASYNC 0x02#define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [RFC v5 1/8] drm: Add Enhanced Gamma LUT precision structure
Quoted 29 lines · Uma Shankar
Existing LUT precision structure is having only 16 bit precision. This is not enough for upcoming enhanced hardwares and advance usecases like HDR processing. Hence added a new structure with 32 bit precision values. Also added the code, for extracting the same from values passed from userspace.
v4: Rebase
v5: Relocated the helper function to
drm_color_mgmt.c. Declared the same in a header file (Alexandru Gheorghe)Signed-off-by Uma Shankar <[email protected]>Reviewed-by Alexandru Gheorghe <[email protected]>--- drivers/gpu/drm/drm_color_mgmt.c | 19 +++++++++++++++++++ include/drm/drm_color_mgmt.h | 1 + include/uapi/drm/drm_mode.h | 15 +++++++++++++++ 3 files changed, 35 insertions(+)drivers/gpu/drm/drm_color_mgmt.c +2
-0@@ -128,6 +128,25 @@ uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) }EXPORT_SYMBOL (drm_color_lut_extract); +/* +* Added to accommodate enhanced LUT precision.
drivers/gpu/drm/drm_color_mgmt.c uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) · line 142
Quoted 10 lines
drivers/gpu/drm/drm_color_mgmt.c +10
-0+* Max LUT precision is 32 bits. +*/ +uint32_t drm_color_lut_extract_ext (uint32_t user_input,uint32_t bit_precision) +{ +uint32_t val = user_input; +uint32_t max =0xffffffff >> (32 - bit_precision); + +/* Round only if we're not using full precision. */ +if (bit_precision <32 ) { + val +=1UL << (32 - bit_precision -1 );
Does val need to be a 64-bit type to prevent this from overflowing?
Matt
Quoted 55 lines
drivers/gpu/drm/drm_color_mgmt.c +7
-0+ val >>=32 - bit_precision; + } + +return clamp_val (val,0 , max); +} +EXPORT_SYMBOL (drm_color_lut_extract_ext); +/** * drm_crtc_enable_color_mgmt - enable color management properties * @crtc: DRM CRTC include/drm/drm_color_mgmt.h +1
-0@@ -29,6 +29,7 @@struct drm_plane ;uint32_t drm_color_lut_extract (uint32_t user_input,uint32_t bit_precision); +uint32_t drm_color_lut_extract_ext (uint32_t user_input,uint32_t bit_precision); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size,include/uapi/drm/drm_mode.h +15
-0@@ -629,6 +629,21 @@ struct drm_color_lut {__u16 reserved; }; +/* +* Creating 32 bit palette entries for better data +* precision. This will be required for HDR and +* similar color processing usecases. +*/ +struct drm_color_lut_ext { +/* +* Data is U0.32 fixed point format. +*/ +__u32 red; +__u32 green; +__u32 blue; +__u32 reserved; +}; +#define DRM_MODE_PAGE_FLIP_EVENT 0x01#define DRM_MODE_PAGE_FLIP_ASYNC 0x02#define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 9 lines
Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [RFC v5 1/8] drm: Add Enhanced Gamma LUT precision structure
In reply to Uma ShankarQuoted 6 lines · Uma Shankar
Existing LUT precision structure is having only 16 bit precision. This is not enough for upcoming enhanced hardwares and advance usecases like HDR processing. Hence added a new structure with 32 bit precision values. Also added the code, for extracting the same from values passed from userspace.
Quoted 7 lines
v4: Rebase
v5: Relocated the helper function to
drm_color_mgmt.c. Declared the same in a header file (Alexandru Gheorghe)Signed-off-by Uma Shankar <[email protected]>Reviewed-by Alexandru Gheorghe <[email protected]>
Why is this not enough? If it's just about rounding, then I've already made a comment internally how that should be handled, so that we don't have rounding artifacts when upgrading a 16bit entry to e.g. 20 bits.
Creating new uapi is generally really hard, and needs a bunch more thought than this here. If possible it's much better (or at least, much easier, and much less effort) if this can be avoided.
-Daniel
Quoted 81 lines
--- drivers/gpu/drm/drm_color_mgmt.c | 19 +++++++++++++++++++ include/drm/drm_color_mgmt.h | 1 + include/uapi/drm/drm_mode.h | 15 +++++++++++++++ 3 files changed, 35 insertions(+)drivers/gpu/drm/drm_color_mgmt.c +19
-0@@ -128,6 +128,25 @@ uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) }EXPORT_SYMBOL (drm_color_lut_extract); +/* +* Added to accommodate enhanced LUT precision. +* Max LUT precision is 32 bits. +*/ +uint32_t drm_color_lut_extract_ext (uint32_t user_input,uint32_t bit_precision) +{ +uint32_t val = user_input; +uint32_t max =0xffffffff >> (32 - bit_precision); + +/* Round only if we're not using full precision. */ +if (bit_precision <32 ) { + val +=1UL << (32 - bit_precision -1 ); + val >>=32 - bit_precision; + } + +return clamp_val (val,0 , max); +} +EXPORT_SYMBOL (drm_color_lut_extract_ext); +/** * drm_crtc_enable_color_mgmt - enable color management properties * @crtc: DRM CRTC include/drm/drm_color_mgmt.h +1
-0@@ -29,6 +29,7 @@struct drm_plane ;uint32_t drm_color_lut_extract (uint32_t user_input,uint32_t bit_precision); +uint32_t drm_color_lut_extract_ext (uint32_t user_input,uint32_t bit_precision); void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size,include/uapi/drm/drm_mode.h +15
-0@@ -629,6 +629,21 @@ struct drm_color_lut {__u16 reserved; }; +/* +* Creating 32 bit palette entries for better data +* precision. This will be required for HDR and +* similar color processing usecases. +*/ +struct drm_color_lut_ext { +/* +* Data is U0.32 fixed point format. +*/ +__u32 red; +__u32 green; +__u32 blue; +__u32 reserved; +}; +#define DRM_MODE_PAGE_FLIP_EVENT 0x01#define DRM_MODE_PAGE_FLIP_ASYNC 0x02#define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v5 2/8 drm: Add Plane Degamma properties
In reply to Uma ShankarAdd Plane Degamma as a blob property and plane degamma size as a range property.
v2: Rebase
v3: Fixed Sean, Paul's review comments. Moved the property from mode_config to drm_plane. Created a helper function to instantiate these properties and removed from drm_mode_create_standard_properties Added property documentation as suggested by Daniel, Vetter.
v4: Rebase
v5: Added "Display Color Hardware Pipeline" flow to kernel documentation as suggested by "Ville Syrjala" and "Brian Starkey". Moved the property creation to drm_color_mgmt.c file to consolidate all color operations at one place.
--- Documentation/gpu/drm-kms.rst | 90 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 13 ++++++ drivers/gpu/drm/drm_atomic_helper.c | 6 +++ drivers/gpu/drm/drm_color_mgmt.c | 44 ++++++++++++++++-- include/drm/drm_plane.h | 24 ++++++++++ 5 files changed, 174 insertions(+), 3 deletions(-)
Documentation/gpu/drm-kms.rst +90 -0
@@ -551,12 +551,102 @@ Plane Composition Properties Color Management Properties --------------------------- +Below is how a typical hardware pipeline for color +will look like: + +.. kernel-render:: DOT + :alt: Display Color Pipeline + :caption: Display Color Pipeline Overview + + digraph "KMS" { + node [shape=box] + + subgraph cluster_static { + style=dashed + label="Display Color Hardware Blocks" + + node [bgcolor=grey style=filled] + "Plane Degamma A" -> "Plane CSC/CTM A" + "Plane CSC/CTM A" -> "Plane Gamma A" + "Pipe Blender" [color=lightblue,style=filled, width=5.25, height=0.75]; + "Plane Gamma A" -> "Pipe Blender" + "Pipe Blender" -> "Pipe DeGamma" + "Pipe DeGamma" -> "Pipe CSC/CTM" + "Pipe CSC/CTM" -> "Pipe Gamma" + "Pipe Gamma" -> "Pipe Output" + } + + subgraph cluster_static { + style=dashed + + node [shape=box] + "Plane Degamma B" -> "Plane CSC/CTM B" + "Plane CSC/CTM B" -> "Plane Gamma B" + "Plane Gamma B" -> "Pipe Blender" + } + + subgraph cluster_static { + style=dashed + + node [shape=box] + "Plane Degamma C" -> "Plane CSC/CTM C" + "Plane CSC/CTM C" -> "Plane Gamma C" + "Plane Gamma C" -> "Pipe Blender" + } + + subgraph cluster_fb { + style=dashed + label="RAM" + + node [shape=box width=1.7 height=0.2] + + "FB 1" -> "Plane Degamma A" + "FB 2" -> "Plane Degamma B" + "FB 3" -> "Plane Degamma C" + } + } + +In real world usecases, + +1. Plane Degamma can be used to linearize a non linear gamma +encoded framebuffer. This is needed to do any linear math like +color space conversion. For ex, linearize frames encoded in SRGB +or by HDR curve. + +2. Later Plane CTM block can convert the content to some different +colorspace. For ex, SRGB to BT2020 etc. + +3. Plane Gamma block can be used later to re-apply the non-linear +curve. This can also be used to apply Tone Mapping for HDR usecases. + +All the layers or framebuffers need to be converted to same color +space and format before blending. The plane color hardware blocks +can help with this. Once the Data is blended, similar color processing +can be done on blended output using pipe color hardware blocks. + +DRM Properties have been created to define and expose all these +hardware blocks to userspace. A userspace application (compositor +or any color app) can use these interfaces and define policies to +efficiently use the display hardware for such color operations. + +Pipe Color Management Properties +--------------------------------- + .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :doc: overview .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :export: +Plane Color Management Properties +--------------------------------- + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: Plane Color Properties + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: export + Tile Group Property -------------------
drivers/gpu/drm/drm_atomic.c +13 -0
@@ -857,6 +857,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, {struct drm_device *dev = plane->dev;struct drm_mode_config *config = &dev->mode_config; +bool replaced = false; +int ret;if (property == config->prop_fb_id) {struct drm_framebuffer *fb =drm_framebuffer_lookup (dev,NULL , val);
@@ -910,6 +912,13 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, state->color_encoding = val; }else if (property == plane->color_range_property) { state->color_range = val; + }else if (property == plane->degamma_lut_property) { + ret =drm_atomic_replace_property_blob_from_id (dev, + &state->degamma_lut, + val,-1 ,sizeof (struct drm_color_lut ), + &replaced); + state->color_mgmt_changed |= replaced; +return ret; }else if (plane->funcs->atomic_set_property) {return plane->funcs->atomic_set_property (plane, state, property, val);
@@ -980,6 +989,9 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, *val = state->color_encoding; }else if (property == plane->color_range_property) { *val = state->color_range; + }else if (property == plane->degamma_lut_property) { + *val = (state->degamma_lut) ? + state->degamma_lut->base.id :0 ; }else if (plane->funcs->atomic_get_property) {return plane->funcs->atomic_get_property (plane, state, property, val); }else {
@@ -1120,6 +1132,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, drm_get_color_encoding_name(state->color_encoding));drm_printf (p,"\tcolor-range=%s\n" ,drm_get_color_range_name (state->color_range)); +drm_printf (p,"\tcolor_mgmt_changed=%d\n" , state->color_mgmt_changed);if (plane->funcs->atomic_print_state) plane->funcs->atomic_print_state (p, state);
drivers/gpu/drm/drm_atomic_helper.c +6 -0
@@ -3614,6 +3614,10 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane, state->fence =NULL ; state->commit =NULL ; + +if (state->degamma_lut) +drm_property_blob_get (state->degamma_lut); + state->color_mgmt_changed = false; }EXPORT_SYMBOL (__drm_atomic_helper_plane_duplicate_state);
@@ -3658,6 +3662,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)if (state->commit)drm_crtc_commit_put (state->commit); + +drm_property_blob_put (state->degamma_lut); }EXPORT_SYMBOL (__drm_atomic_helper_plane_destroy_state);
drivers/gpu/drm/drm_color_mgmt.c +41 -3
55 lines not on this page · raw message
include/drm/drm_plane.h +24 -0
@@ -182,6 +182,14 @@ struct drm_plane_state {*/ bool visible; +/* @degamma_lut: +* +* Lookup table for converting framebuffer pixel data before apply the +* color conversion matrix @ctm. See drm_plane_enable_color_mgmt(). The +* blob (if not NULL) is an array of &struct drm_color_lut_ext. +*/ +struct drm_property_blob *degamma_lut; +/** * @commit: Tracks the pending commit to prevent use-after-free conditions, * and for async plane updates.
@@ -192,6 +200,8 @@ struct drm_plane_state {/** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; + + u8 color_mgmt_changed : 1; }; static inline struct drm_rect
@@ -692,6 +702,18 @@ struct drm_plane {* See drm_plane_create_color_properties(). */ struct drm_property *color_range_property; + +/** +* @degamma_lut_property: Optional Plane property to set the LUT +* used to convert the framebuffer's colors to linear gamma. +*/ +struct drm_property *degamma_lut_property; + +/** +* @degamma_lut_size_property: Optional Plane property for the +* size of the degamma LUT as supported by the driver (read-only). +*/ +struct drm_property *degamma_lut_size_property; };#define obj_to_plane (x) container_of(x, struct drm_plane, base)
@@ -741,6 +763,8 @@ static inline u32 drm_plane_mask(const struct drm_plane *plane)int drm_mode_plane_set_obj_prop (struct drm_plane *plane,struct drm_property *property,uint64_t value); +int drm_plane_color_create_prop (struct drm_device *dev, +struct drm_plane *plane);/** * drm_plane_find - find a &drm_plane
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFC v5 2/8] drm: Add Plane Degamma properties
Hi,
Quoted 148 lines · Uma Shankar
Add Plane Degamma as a blob property and plane degamma size as a range property.
v2: Rebase
v3: Fixed Sean, Paul's review comments. Moved the property from
mode_configtodrm_plane. Created a helper function to instantiate these properties and removed fromdrm_mode_create_standard_propertiesAdded property documentation as suggested by Daniel, Vetter.v4: Rebase
v5: Added "Display Color Hardware Pipeline" flow to kernel documentation as suggested by "Ville Syrjala" and "Brian Starkey". Moved the property creation to
drm_color_mgmt.cfile to consolidate all color operations at one place.Signed-off-by Uma Shankar <[email protected]>Reviewed-by Alexandru Gheorghe <[email protected]>--- Documentation/gpu/drm-kms.rst | 90 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 13 ++++++ drivers/gpu/drm/drm_atomic_helper.c | 6 +++ drivers/gpu/drm/drm_color_mgmt.c | 44 ++++++++++++++++-- include/drm/drm_plane.h | 24 ++++++++++ 5 files changed, 174 insertions(+), 3 deletions(-)Documentation/gpu/drm-kms.rst +90
-0@@ -551,12 +551,102 @@ Plane Composition Properties Color Management Properties --------------------------- +Below is how a typical hardware pipeline for color +will look like: + +.. kernel-render:: DOT + :alt: Display Color Pipeline + :caption: Display Color Pipeline Overview + + digraph "KMS" { + node [shape=box] + + subgraph cluster_static { + style=dashed + label="Display Color Hardware Blocks" + + node [bgcolor=grey style=filled] + "Plane Degamma A" -> "Plane CSC/CTM A" + "Plane CSC/CTM A" -> "Plane Gamma A" + "Pipe Blender" [color=lightblue,style=filled, width=5.25, height=0.75]; + "Plane Gamma A" -> "Pipe Blender" + "Pipe Blender" -> "Pipe DeGamma" + "Pipe DeGamma" -> "Pipe CSC/CTM" + "Pipe CSC/CTM" -> "Pipe Gamma" + "Pipe Gamma" -> "Pipe Output" + } + + subgraph cluster_static { + style=dashed + + node [shape=box] + "Plane Degamma B" -> "Plane CSC/CTM B" + "Plane CSC/CTM B" -> "Plane Gamma B" + "Plane Gamma B" -> "Pipe Blender" + } + + subgraph cluster_static { + style=dashed + + node [shape=box] + "Plane Degamma C" -> "Plane CSC/CTM C" + "Plane CSC/CTM C" -> "Plane Gamma C" + "Plane Gamma C" -> "Pipe Blender" + } + + subgraph cluster_fb { + style=dashed + label="RAM" + + node [shape=box width=1.7 height=0.2] + + "FB 1" -> "Plane Degamma A" + "FB 2" -> "Plane Degamma B" + "FB 3" -> "Plane Degamma C" + } + } + +In real world usecases, + +1. Plane Degamma can be used to linearize a non linear gamma +encoded framebuffer. This is needed to do any linear math like +color space conversion. For ex, linearize frames encoded in SRGB +or by HDR curve. + +2. Later Plane CTM block can convert the content to some different +colorspace. For ex, SRGB to BT2020 etc. + +3. Plane Gamma block can be used later to re-apply the non-linear +curve. This can also be used to apply Tone Mapping for HDR usecases. + +All the layers or framebuffers need to be converted to same color +space and format before blending. The plane color hardware blocks +can help with this. Once the Data is blended, similar color processing +can be done on blended output using pipe color hardware blocks. + +DRM Properties have been created to define and expose all these +hardware blocks to userspace. A userspace application (compositor +or any color app) can use these interfaces and define policies to +efficiently use the display hardware for such color operations. + +Pipe Color Management Properties +--------------------------------- + .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :doc: overview .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :export: +Plane Color Management Properties +--------------------------------- + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: Plane Color Properties + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: export + Tile Group Property -------------------drivers/gpu/drm/drm_atomic.c +2
-0@@ -857,6 +857,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, {struct drm_device *dev = plane->dev;struct drm_mode_config *config = &dev->mode_config; +bool replaced = false; +int ret;if (property == config->prop_fb_id) {struct drm_framebuffer *fb =drm_framebuffer_lookup (dev,NULL , val);
drivers/gpu/drm/drm_atomic.c static int drm_atomic_plane_set_property(struct drm_plane *plane, · line 918
Quoted 7 lines
drivers/gpu/drm/drm_atomic.c +4
-0@@ -910,6 +912,13 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, state->color_encoding = val; }else if (property == plane->color_range_property) { state->color_range = val; + }else if (property == plane->degamma_lut_property) { + ret = drm_atomic_replace_property_blob_from_id(dev, + &state->degamma_lut, + val, -1, sizeof(struct drm_color_lut),
Sorry I missed this thing the first time, but this should be sizeof drm_color_lut_ext.
Also I think we have the same problem as for crtc properties when doing suspend/resume.
I think color_mgmt_changed should just be set in drm_atomic_helper_check_planes
https://lists.freedesktop.org/archives/dri-devel/2018-September/189265.html
Quoted 167 lines
drivers/gpu/drm/drm_atomic.c +7
-0+ &replaced); + state->color_mgmt_changed |= replaced; +return ret; }else if (plane->funcs->atomic_set_property) {return plane->funcs->atomic_set_property (plane, state, property, val);@@ -980,6 +989,9 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, *val = state->color_encoding; }else if (property == plane->color_range_property) { *val = state->color_range; + }else if (property == plane->degamma_lut_property) { + *val = (state->degamma_lut) ? + state->degamma_lut->base.id :0 ; }else if (plane->funcs->atomic_get_property) {return plane->funcs->atomic_get_property (plane, state, property, val); }else {@@ -1120,6 +1132,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, drm_get_color_encoding_name(state->color_encoding));drm_printf (p,"\tcolor-range=%s\n" ,drm_get_color_range_name (state->color_range)); +drm_printf (p,"\tcolor_mgmt_changed=%d\n" , state->color_mgmt_changed);if (plane->funcs->atomic_print_state) plane->funcs->atomic_print_state (p, state);drivers/gpu/drm/drm_atomic_helper.c +6
-0@@ -3614,6 +3614,10 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane, state->fence =NULL ; state->commit =NULL ; + +if (state->degamma_lut) +drm_property_blob_get (state->degamma_lut); + state->color_mgmt_changed = false; }EXPORT_SYMBOL (__drm_atomic_helper_plane_duplicate_state);@@ -3658,6 +3662,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)if (state->commit)drm_crtc_commit_put (state->commit); + +drm_property_blob_put (state->degamma_lut); }EXPORT_SYMBOL (__drm_atomic_helper_plane_destroy_state);drivers/gpu/drm/drm_color_mgmt.c +41
-3@@ -29,11 +29,11 @@/** * DOC: overview * -* Color management or color space adjustments is supported through a set of 5 -* properties on the &drm_crtc object. They are set up by calling +* Pipe Color management or color space adjustments is supported through a +* set of 5 properties on the &drm_crtc object. They are set up by calling * drm_crtc_enable_color_mgmt(). * -* "DEGAMMA_LUT”: +* "DEGAMMA_LUT * Blob property to set the degamma lookup table (LUT) mapping pixel data * from the framebuffer before it is given to the transformation matrix. * The data is interpreted as an array of &struct drm_color_lut elements. @@ -491,3 +491,41 @@ int drm_plane_create_color_properties(struct drm_plane *plane,return 0 ; }EXPORT_SYMBOL (drm_plane_create_color_properties); + +/** +* DOC: Plane Color Properties +* +* Plane Color management or color space adjustments is supported +* through a set of 5 properties on the &drm_plane object. +* +* degamma_lut_property: +* Blob property which allows a userspace to provide LUT values +* to apply degamma curve using the h/w plane degamma processing +* engine, thereby making the content as linear for further color +* processing. +* +* degamma_lut_size_property: +* Range Property to indicate size of the plane degamma LUT. +*/ +int drm_plane_color_create_prop (struct drm_device *dev, +struct drm_plane *plane) +{ +struct drm_property *prop; + + prop =drm_property_create (dev, +DRM_MODE_PROP_BLOB , +"PLANE_DEGAMMA_LUT" ,0 ); +if (!prop) +return -ENOMEM ; + plane->degamma_lut_property = prop; + + prop =drm_property_create_range (dev, +DRM_MODE_PROP_IMMUTABLE , +"PLANE_DEGAMMA_LUT_SIZE" ,0 ,UINT_MAX ); +if (!prop) +return -ENOMEM ; + plane->degamma_lut_size_property = prop; + +return 0 ; +} +EXPORT_SYMBOL (drm_plane_color_create_prop);include/drm/drm_plane.h +24
-0@@ -182,6 +182,14 @@ struct drm_plane_state {*/ bool visible; +/* @degamma_lut: +* +* Lookup table for converting framebuffer pixel data before apply the +* color conversion matrix @ctm. See drm_plane_enable_color_mgmt(). The +* blob (if not NULL) is an array of &struct drm_color_lut_ext. +*/ +struct drm_property_blob *degamma_lut; +/** * @commit: Tracks the pending commit to prevent use-after-free conditions, * and for async plane updates. @@ -192,6 +200,8 @@ struct drm_plane_state {/** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; + + u8 color_mgmt_changed : 1; }; static inline struct drm_rect@@ -692,6 +702,18 @@ struct drm_plane {* See drm_plane_create_color_properties(). */ struct drm_property *color_range_property; + +/** +* @degamma_lut_property: Optional Plane property to set the LUT +* used to convert the framebuffer's colors to linear gamma. +*/ +struct drm_property *degamma_lut_property; + +/** +* @degamma_lut_size_property: Optional Plane property for the +* size of the degamma LUT as supported by the driver (read-only). +*/ +struct drm_property *degamma_lut_size_property; };#define obj_to_plane (x) container_of(x, struct drm_plane, base)@@ -741,6 +763,8 @@ static inline u32 drm_plane_mask(const struct drm_plane *plane)int drm_mode_plane_set_obj_prop (struct drm_plane *plane,struct drm_property *property,uint64_t value); +int drm_plane_color_create_prop (struct drm_device *dev, +struct drm_plane *plane);/** * drm_plane_find - find a &drm_plane Signature · 1 line
1.9.1
Signature · 6 lines
Cheers, Alex G _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFC v5 2/8] drm: Add Plane Degamma properties
In reply to Uma ShankarQuoted 209 lines · Uma Shankar
Add Plane Degamma as a blob property and plane degamma size as a range property.
v2: Rebase
v3: Fixed Sean, Paul's review comments. Moved the property from
mode_configtodrm_plane. Created a helper function to instantiate these properties and removed fromdrm_mode_create_standard_propertiesAdded property documentation as suggested by Daniel, Vetter.v4: Rebase
v5: Added "Display Color Hardware Pipeline" flow to kernel documentation as suggested by "Ville Syrjala" and "Brian Starkey". Moved the property creation to
drm_color_mgmt.cfile to consolidate all color operations at one place.Signed-off-by Uma Shankar <[email protected]>Reviewed-by Alexandru Gheorghe <[email protected]>--- Documentation/gpu/drm-kms.rst | 90 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 13 ++++++ drivers/gpu/drm/drm_atomic_helper.c | 6 +++ drivers/gpu/drm/drm_color_mgmt.c | 44 ++++++++++++++++-- include/drm/drm_plane.h | 24 ++++++++++ 5 files changed, 174 insertions(+), 3 deletions(-)Documentation/gpu/drm-kms.rst +90
-0@@ -551,12 +551,102 @@ Plane Composition Properties Color Management Properties --------------------------- +Below is how a typical hardware pipeline for color +will look like: + +.. kernel-render:: DOT + :alt: Display Color Pipeline + :caption: Display Color Pipeline Overview + + digraph "KMS" { + node [shape=box] + + subgraph cluster_static { + style=dashed + label="Display Color Hardware Blocks" + + node [bgcolor=grey style=filled] + "Plane Degamma A" -> "Plane CSC/CTM A" + "Plane CSC/CTM A" -> "Plane Gamma A" + "Pipe Blender" [color=lightblue,style=filled, width=5.25, height=0.75]; + "Plane Gamma A" -> "Pipe Blender" + "Pipe Blender" -> "Pipe DeGamma" + "Pipe DeGamma" -> "Pipe CSC/CTM" + "Pipe CSC/CTM" -> "Pipe Gamma" + "Pipe Gamma" -> "Pipe Output" + } + + subgraph cluster_static { + style=dashed + + node [shape=box] + "Plane Degamma B" -> "Plane CSC/CTM B" + "Plane CSC/CTM B" -> "Plane Gamma B" + "Plane Gamma B" -> "Pipe Blender" + } + + subgraph cluster_static { + style=dashed + + node [shape=box] + "Plane Degamma C" -> "Plane CSC/CTM C" + "Plane CSC/CTM C" -> "Plane Gamma C" + "Plane Gamma C" -> "Pipe Blender" + } + + subgraph cluster_fb { + style=dashed + label="RAM" + + node [shape=box width=1.7 height=0.2] + + "FB 1" -> "Plane Degamma A" + "FB 2" -> "Plane Degamma B" + "FB 3" -> "Plane Degamma C" + } + } + +In real world usecases, + +1. Plane Degamma can be used to linearize a non linear gamma +encoded framebuffer. This is needed to do any linear math like +color space conversion. For ex, linearize frames encoded in SRGB +or by HDR curve. + +2. Later Plane CTM block can convert the content to some different +colorspace. For ex, SRGB to BT2020 etc. + +3. Plane Gamma block can be used later to re-apply the non-linear +curve. This can also be used to apply Tone Mapping for HDR usecases. + +All the layers or framebuffers need to be converted to same color +space and format before blending. The plane color hardware blocks +can help with this. Once the Data is blended, similar color processing +can be done on blended output using pipe color hardware blocks. + +DRM Properties have been created to define and expose all these +hardware blocks to userspace. A userspace application (compositor +or any color app) can use these interfaces and define policies to +efficiently use the display hardware for such color operations. + +Pipe Color Management Properties +--------------------------------- + .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :doc: overview .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :export: +Plane Color Management Properties +--------------------------------- + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: Plane Color Properties + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: export + Tile Group Property -------------------drivers/gpu/drm/drm_atomic.c +13
-0@@ -857,6 +857,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, {struct drm_device *dev = plane->dev;struct drm_mode_config *config = &dev->mode_config; +bool replaced = false; +int ret;if (property == config->prop_fb_id) {struct drm_framebuffer *fb =drm_framebuffer_lookup (dev,NULL , val);@@ -910,6 +912,13 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, state->color_encoding = val; }else if (property == plane->color_range_property) { state->color_range = val; + }else if (property == plane->degamma_lut_property) { + ret =drm_atomic_replace_property_blob_from_id (dev, + &state->degamma_lut, + val,-1 ,sizeof (struct drm_color_lut ), + &replaced); + state->color_mgmt_changed |= replaced; +return ret; }else if (plane->funcs->atomic_set_property) {return plane->funcs->atomic_set_property (plane, state, property, val);@@ -980,6 +989,9 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, *val = state->color_encoding; }else if (property == plane->color_range_property) { *val = state->color_range; + }else if (property == plane->degamma_lut_property) { + *val = (state->degamma_lut) ? + state->degamma_lut->base.id :0 ; }else if (plane->funcs->atomic_get_property) {return plane->funcs->atomic_get_property (plane, state, property, val); }else {@@ -1120,6 +1132,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, drm_get_color_encoding_name(state->color_encoding));drm_printf (p,"\tcolor-range=%s\n" ,drm_get_color_range_name (state->color_range)); +drm_printf (p,"\tcolor_mgmt_changed=%d\n" , state->color_mgmt_changed);if (plane->funcs->atomic_print_state) plane->funcs->atomic_print_state (p, state);drivers/gpu/drm/drm_atomic_helper.c +6
-0@@ -3614,6 +3614,10 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane, state->fence =NULL ; state->commit =NULL ; + +if (state->degamma_lut) +drm_property_blob_get (state->degamma_lut); + state->color_mgmt_changed = false; }EXPORT_SYMBOL (__drm_atomic_helper_plane_duplicate_state);@@ -3658,6 +3662,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)if (state->commit)drm_crtc_commit_put (state->commit); + +drm_property_blob_put (state->degamma_lut); }EXPORT_SYMBOL (__drm_atomic_helper_plane_destroy_state);drivers/gpu/drm/drm_color_mgmt.c +0
-0@@ -29,11 +29,11 @@/**
drivers/gpu/drm/drm_color_mgmt.c line 36
Quoted 10 lines
drivers/gpu/drm/drm_color_mgmt.c +3
-3* DOC: overview * -* Color management or color space adjustments is supported through a set of 5 -* properties on the &drm_crtc object. They are set up by calling +* Pipe Color management or color space adjustments is supported through a +* set of 5 properties on the &drm_crtc object. They are set up by calling * drm_crtc_enable_color_mgmt(). * -* "DEGAMMA_LUT”: +* "DEGAMMA_LUT
This change seems unrelated/unwanted.
Quoted 12 lines
drivers/gpu/drm/drm_color_mgmt.c +5
-0* Blob property to set the degamma lookup table (LUT) mapping pixel data * from the framebuffer before it is given to the transformation matrix. * The data is interpreted as an array of &struct drm_color_lut elements. @@ -491,3 +491,41 @@ int drm_plane_create_color_properties(struct drm_plane *plane,return 0 ; }EXPORT_SYMBOL (drm_plane_create_color_properties); + +/** +* DOC: Plane Color Properties +* +* Plane Color management or color space adjustments is supported
drivers/gpu/drm/drm_color_mgmt.c int drm_plane_create_color_properties(struct drm_plane *plane, · line 508
Quoted 10 lines
drivers/gpu/drm/drm_color_mgmt.c +10
-0+* through a set of 5 properties on the &drm_plane object. +* +* degamma_lut_property: +* Blob property which allows a userspace to provide LUT values +* to apply degamma curve using the h/w plane degamma processing +* engine, thereby making the content as linear for further color +* processing. +* +* degamma_lut_size_property: +* Range Property to indicate size of the plane degamma LUT.
Elsewhere we're documenting the string name for the property, which is part of the ABI (e.g., "DEGAMMA_LUT") but here you're documenting the property variable name in the code.
I think there was also discussion at one point of having a more complex LUT interface that deals with things like non-linear ranges and such. If that's still planned, would it be layered on top of these properties, or would it be a completely separate, replacement ABI down the road?
Quoted 8 lines
drivers/gpu/drm/drm_color_mgmt.c +8
-0+*/ +int drm_plane_color_create_prop (struct drm_device *dev, +struct drm_plane *plane) +{ +struct drm_property *prop; + + prop = drm_property_create(dev, + DRM_MODE_PROP_BLOB,
drivers/gpu/drm/drm_color_mgmt.c int drm_plane_create_color_properties(struct drm_plane *plane, · line 526
Quoted 10 lines
drivers/gpu/drm/drm_color_mgmt.c +10
-0+ "PLANE_DEGAMMA_LUT", 0); +if (!prop) +return -ENOMEM ; + plane->degamma_lut_property = prop; + + prop =drm_property_create_range (dev, +DRM_MODE_PROP_IMMUTABLE , +"PLANE_DEGAMMA_LUT_SIZE" ,0 ,UINT_MAX ); +if (!prop) +return -ENOMEM ;
If this fails, should we try to clean up the earlier property? It looks the i915 callsite for this function (in patch #6 of the series) doesn't check the return value, so even if we return -ENOMEM, the driver will continue with some properties created and some not.
Actually, aside from using names "PLANE_FOO" instead of "FOO," is there a reason why we need to create new properties for planes? I think we could still attach the same properties we're already using for CRTC's (dev->mode_config.degamma_lut_property and such) since afaik there isn't anything that prevents us from attaching the same property to different kinds of drm_object's.
Matt
Quoted 68 lines
drivers/gpu/drm/drm_color_mgmt.c +5
-0+ plane->degamma_lut_size_property = prop; + +return 0 ; +} +EXPORT_SYMBOL (drm_plane_color_create_prop);include/drm/drm_plane.h +24
-0@@ -182,6 +182,14 @@ struct drm_plane_state {*/ bool visible; +/* @degamma_lut: +* +* Lookup table for converting framebuffer pixel data before apply the +* color conversion matrix @ctm. See drm_plane_enable_color_mgmt(). The +* blob (if not NULL) is an array of &struct drm_color_lut_ext. +*/ +struct drm_property_blob *degamma_lut; +/** * @commit: Tracks the pending commit to prevent use-after-free conditions, * and for async plane updates. @@ -192,6 +200,8 @@ struct drm_plane_state {/** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; + + u8 color_mgmt_changed : 1; }; static inline struct drm_rect@@ -692,6 +702,18 @@ struct drm_plane {* See drm_plane_create_color_properties(). */ struct drm_property *color_range_property; + +/** +* @degamma_lut_property: Optional Plane property to set the LUT +* used to convert the framebuffer's colors to linear gamma. +*/ +struct drm_property *degamma_lut_property; + +/** +* @degamma_lut_size_property: Optional Plane property for the +* size of the degamma LUT as supported by the driver (read-only). +*/ +struct drm_property *degamma_lut_size_property; };#define obj_to_plane (x) container_of(x, struct drm_plane, base)@@ -741,6 +763,8 @@ static inline u32 drm_plane_mask(const struct drm_plane *plane)int drm_mode_plane_set_obj_prop (struct drm_plane *plane,struct drm_property *property,uint64_t value); +int drm_plane_color_create_prop (struct drm_device *dev, +struct drm_plane *plane);/** * drm_plane_find - find a &drm_plane Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 9 lines
Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFC v5 2/8] drm: Add Plane Degamma properties
Quoted 238 lines
-----Original Message-----
From: Roper, Matthew D
Sent: Wednesday, November 14, 2018 6:39 AM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Syrjala, Ville <[email protected]>; [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [RFC v5 2/8] drm: Add Plane Degamma propertiesQuoted 17 lines · Uma Shankar
Add Plane Degamma as a blob property and plane degamma size as a range property.
v2: Rebase
v3: Fixed Sean, Paul's review comments. Moved the property from
mode_configtodrm_plane. Created a helper function to instantiate these properties and removed fromdrm_mode_create_standard_propertiesAdded property documentation as suggested by Daniel, Vetter.v4: Rebase
v5: Added "Display Color Hardware Pipeline" flow to kernel documentation as suggested by "Ville Syrjala" and "Brian Starkey". Moved the property creation to
drm_color_mgmt.cfile to consolidate all color operations at one place.Quoted 4 lines
Signed-off-by Uma Shankar <[email protected]>Reviewed-by Alexandru Gheorghe <[email protected]>--- Documentation/gpu/drm-kms.rst | 90+++++++++++++++++++++++++++++++++++++
Quoted 116 lines
drivers/gpu/drm/drm_atomic.c | 13 ++++++ drivers/gpu/drm/drm_atomic_helper.c | 6 +++ drivers/gpu/drm/drm_color_mgmt.c | 44 ++++++++++++++++-- include/drm/drm_plane.h | 24 ++++++++++ 5 files changed, 174 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/Documentation/gpu/drm-kms.rstindex f8f5bf1..253d546 100644Documentation/gpu/drm-kms.rst +0
-0@@ -551,12 +551,102 @@ Plane Composition Properties Color ManagementProperties
---------------------------Documentation/gpu/drm-kms.rst +88
-0+Below is how a typical hardware pipeline for color will look like: + +.. kernel-render:: DOT + :alt: Display Color Pipeline + :caption: Display Color Pipeline Overview + + digraph "KMS" { + node [shape=box] + + subgraph cluster_static { + style=dashed + label="Display Color Hardware Blocks" + + node [bgcolor=grey style=filled] + "Plane Degamma A" -> "Plane CSC/CTM A" + "Plane CSC/CTM A" -> "Plane Gamma A" + "Pipe Blender" [color=lightblue,style=filled, width=5.25, height=0.75]; + "Plane Gamma A" -> "Pipe Blender" + "Pipe Blender" -> "Pipe DeGamma" + "Pipe DeGamma" -> "Pipe CSC/CTM" + "Pipe CSC/CTM" -> "Pipe Gamma" + "Pipe Gamma" -> "Pipe Output" + } + + subgraph cluster_static { + style=dashed + + node [shape=box] + "Plane Degamma B" -> "Plane CSC/CTM B" + "Plane CSC/CTM B" -> "Plane Gamma B" + "Plane Gamma B" -> "Pipe Blender" + } + + subgraph cluster_static { + style=dashed + + node [shape=box] + "Plane Degamma C" -> "Plane CSC/CTM C" + "Plane CSC/CTM C" -> "Plane Gamma C" + "Plane Gamma C" -> "Pipe Blender" + } + + subgraph cluster_fb { + style=dashed + label="RAM" + + node [shape=box width=1.7 height=0.2] + + "FB 1" -> "Plane Degamma A" + "FB 2" -> "Plane Degamma B" + "FB 3" -> "Plane Degamma C" + } + } + +In real world usecases, + +1. Plane Degamma can be used to linearize a non linear gamma encoded +framebuffer. This is needed to do any linear math like color space +conversion. For ex, linearize frames encoded in SRGB or by HDR curve. + +2. Later Plane CTM block can convert the content to some different +colorspace. For ex, SRGB to BT2020 etc. + +3. Plane Gamma block can be used later to re-apply the non-linear +curve. This can also be used to apply Tone Mapping for HDR usecases. + +All the layers or framebuffers need to be converted to same color +space and format before blending. The plane color hardware blocks can +help with this. Once the Data is blended, similar color processing +can be done on blended output using pipe color hardware blocks. + +DRM Properties have been created to define and expose all these +hardware blocks to userspace. A userspace application (compositor or +any color app) can use these interfaces and define policies to +efficiently use the display hardware for such color operations. + +Pipe Color Management Properties +--------------------------------- + .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :doc: overview .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :export: +Plane Color Management Properties +--------------------------------- + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: Plane Color Properties + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: export + Tile Group Property -------------------(quoted diff) +0
-0
b/drivers/gpu/drm/drm_atomic.cindex d0478ab..e716614 100644drivers/gpu/drm/drm_atomic.c static int drm_atomic_plane_set_property(struct · line 864
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +2
-0@@ -857,6 +857,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, {struct drm_device *dev = plane->dev;struct drm_mode_config *config = &dev->mode_config; +bool replaced = false; +int ret;if (property == config->prop_fb_id) { struct drm_framebuffer *fb = drm_framebuffer_lookup(dev,NULL,
Quoted 1 line
val); @@ -910,6 +912,13 @@ static int drm_atomic_plane_set_property(struct
drm_plane*plane,drivers/gpu/drm/drm_atomic.c static int drm_atomic_plane_set_property(struct
Quoted 14 lines
drivers/gpu/drm/drm_atomic.c +7
-0state->color_encoding = val; }else if (property == plane->color_range_property) { state->color_range = val; + }else if (property == plane->degamma_lut_property) { + ret =drm_atomic_replace_property_blob_from_id (dev, + &state->degamma_lut, + val,-1 ,sizeof (struct drm_color_lut ), + &replaced); + state->color_mgmt_changed |= replaced; +return ret; }else if (plane->funcs->atomic_set_property) {return plane->funcs->atomic_set_property (plane, state, property, val);@@ -980,6 +989,9 @@ static int drm_atomic_plane_set_property(struct
drm_plane*plane,drivers/gpu/drm/drm_atomic.c static int drm_atomic_plane_set_property(struct drm_plane *plane,
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +3
-0*val = state->color_encoding; }else if (property == plane->color_range_property) { *val = state->color_range; + }else if (property == plane->degamma_lut_property) { + *val = (state->degamma_lut) ? + state->degamma_lut->base.id :0 ; }else if (plane->funcs->atomic_get_property) { return plane->funcs->atomic_get_property(plane, state,property, val);
drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct
Quoted 2 lines
drivers/gpu/drm/drm_atomic.c +0
-0}else {@@ -1120,6 +1132,7 @@ static void drm_atomic_plane_print_state(struct
drm_printer*p,Quoted 49 lines
drivers/gpu/drm/drm_atomic.c +2
-0drm_get_color_encoding_name(state->color_encoding));drm_printf (p,"\tcolor-range=%s\n" ,drm_get_color_range_name (state->color_range)); +drm_printf (p,"\tcolor_mgmt_changed=%d\n" , +state->color_mgmt_changed);if (plane->funcs->atomic_print_state) plane->funcs->atomic_print_state(p, state); diff --git
a/drivers/gpu/drm/drm_atomic_helper.cb/drivers/gpu/drm/drm_atomic_helper.c
index 2c23a48..203137e 100644drivers/gpu/drm/drm_atomic_helper.c +6
-0@@ -3614,6 +3614,10 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane, state->fence = NULL; state->commit =NULL ; + +if (state->degamma_lut) +drm_property_blob_get (state->degamma_lut); + state->color_mgmt_changed = false; }EXPORT_SYMBOL (__drm_atomic_helper_plane_duplicate_state);@@ -3658,6 +3662,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state) if (state->commit) drm_crtc_commit_put(state->commit); + +drm_property_blob_put (state->degamma_lut); }EXPORT_SYMBOL (__drm_atomic_helper_plane_destroy_state);drivers/gpu/drm/drm_color_mgmt.c +0
-1@@ -29,11 +29,11 @@/** * DOC: overview * -* Color management or color space adjustments is supported through a set of 5
- * properties on the&drm_crtcobject. They are set up by calling
+ * Pipe Color management or color space adjustments is supported
+ through a
Quoted 8 lines
Quoted 6 lines
+ * set of 5 properties on the
&drm_crtcobject. They are set up by
+ calling
*drm_crtc_enable_color_mgmt().
*
- * "DEGAMMA_LUT”:
+ * "DEGAMMA_LUTThis change seems unrelated/unwanted.
Updated Color Management to Pipe Color Management here. The last part, DEGAMMA_LUT change can be dropped and kept as is. Will update this.
Quoted 19 lines
drivers/gpu/drm/drm_color_mgmt.c int drm_plane_create_color_properties(struct
Quoted 4 lines
* Blob property to set the degamma lookup table (LUT) mapping pixel data
* from the framebuffer before it is given to the transformation matrix.
* The data is interpreted as an array of &structdrm_color_lutelements.drivers/gpu/drm/drm_color_mgmt.c +0
-0@@ -491,3 +491,41 @@ int drm_plane_create_color_properties(struct
drm_plane*plane,Quoted 14 lines
drivers/gpu/drm/drm_color_mgmt.c +11
-0return 0 ; }EXPORT_SYMBOL (drm_plane_create_color_properties); + +/** +* DOC: Plane Color Properties +* +* Plane Color management or color space adjustments is supported +* through a set of 5 properties on the &drm_plane object. +* +* degamma_lut_property: +* Blob property which allows a userspace to provide LUT values +* to apply degamma curve using the h/w plane degamma processing +* engine, thereby making the content as linear for further color
Quoted 8 lines
drivers/gpu/drm/drm_color_mgmt.c int drm_plane_create_color_properties(struct drm_plane *plane, · line 508
Quoted 4 lines
drivers/gpu/drm/drm_color_mgmt.c +4
-0+* processing. +* +* degamma_lut_size_property: +* Range Property to indicate size of the plane degamma LUT. Elsewhere we're documenting the string name for the property, which is part of the ABI (e.g., "
DEGAMMA_LUT") but here you're documenting the property variable name in the code.
Ok, will change this to be consistent with pipe color property documentation. Thanks..
Quoted 4 lines
I think there was also discussion at one point of having a more complex LUT interface that deals with things like non-linear ranges and such.
If that's still planned, would it be layered on top of these properties, or would it be a completely separate, replacement ABI down the road?
The non-linear and multi-segment part is a bit tricky. We can develop that on top of this property by creating a segment lut property blob which just tells the number of segments and size of each segment. The actual lut values can be passed through the current property. Driver can then use data of both these properties and use it as per respective hardware to program LUT.
If the blob property is not set while plane degamma is set, driver functions in the legacy way and program luts in a linear fashion (basically as per legacy design).
This is just my thought on that one. Better ideas are welcome.
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/drm_color_mgmt.c +15
-0+*/ +int drm_plane_color_create_prop (struct drm_device *dev, +struct drm_plane *plane) +{ +struct drm_property *prop; + + prop =drm_property_create (dev, +DRM_MODE_PROP_BLOB , +"PLANE_DEGAMMA_LUT" ,0 ); +if (!prop) +return -ENOMEM ; + plane->degamma_lut_property = prop; + + prop = drm_property_create_range(dev, + DRM_MODE_PROP_IMMUTABLE,
Quoted 8 lines
drivers/gpu/drm/drm_color_mgmt.c int drm_plane_create_color_properties(struct drm_plane *plane, · line 526
Quoted 3 lines
drivers/gpu/drm/drm_color_mgmt.c +3
-0+ "PLANE_DEGAMMA_LUT_SIZE", 0, UINT_MAX); +if (!prop) +return -ENOMEM ;If this fails, should we try to clean up the earlier property? It looks the i915 callsite for this function (in patch #6 of the series) doesn't check the return value, so even if we return
-ENOMEM, the driver will continue with some properties created and some not.
Sure, I will fix this. Thanks..
Quoted 6 lines
Actually, aside from using names "
PLANE_FOO" instead of "FOO," is there a reason why we need to create new properties for planes? I think we could still attach the same properties we're already using for CRTC's (dev-Quoted 1 line
mode_config.degamma_lut_property and such) since afaik there isn't anything
that prevents us from attaching the same property to different kinds of drm_object's.
This point was discussed when we were planning this. Plane color is little different than pipe color, and comes handy for making pre blending framebuffer conversion. Also, we can extend it to handle multi segment and non-linear LUT's. Hence, we thought to keep it separate from pipe color properties.
Regards,
Uma Shankar
Quoted 70 lines
Matt
Quoted 10 lines
drivers/gpu/drm/drm_color_mgmt.c +5
-0+ plane->degamma_lut_size_property = prop; + +return 0 ; +} +EXPORT_SYMBOL (drm_plane_color_create_prop);include/drm/drm_plane.h index renamed from include/drm/drm_plane.h +0
-016f5b666..7f0d961 100644
include/drm/drm_plane.h struct drm_plane_state { · line 188
Quoted 7 lines
include/drm/drm_plane.h +4
-0@@ -182,6 +182,14 @@ struct drm_plane_state {*/ bool visible; +/* @degamma_lut: +* +* Lookup table for converting framebuffer pixel data before apply the +* color conversion matrix @ctm. See drm_plane_enable_color_mgmt(). The
include/drm/drm_plane.h struct drm_plane_state {
Quoted 6 lines
include/drm/drm_plane.h +4
-0+* blob (if not NULL) is an array of &struct drm_color_lut_ext. +*/ +struct drm_property_blob *degamma_lut; +/** * @commit: Tracks the pending commit to prevent use-after-free conditions,
Quoted 30 lines
include/drm/drm_plane.h +14
-1* and for async plane updates. @@ -192,6 +200,8 @@ struct drm_plane_state {/** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; + + u8 color_mgmt_changed : 1; }; static inline struct drm_rect@@ -692,6 +702,18 @@ struct drm_plane {* See drm_plane_create_color_properties(). */ struct drm_property *color_range_property; + +/** +* @degamma_lut_property: Optional Plane property to set the LUT +* used to convert the framebuffer's colors to linear gamma. +*/ +struct drm_property *degamma_lut_property; + +/** +* @degamma_lut_size_property: Optional Plane property for the +* size of the degamma LUT as supported by the driver (read-only). +*/ +struct drm_property *degamma_lut_size_property; };#define obj_to_plane (x) container_of(x, struct drm_plane, base) @@ -741,6 +763,8 @@ static inline u32 drm_plane_mask(const structQuoted 1 line
drm_plane*plane) int drm_mode_plane_set_obj_prop(structdrm_plane*plane,
Quoted 10 lines
include/drm/drm_plane.h +2
-1struct drm_property *property, uint64_t value); +int drm_plane_color_create_prop (struct drm_device *dev, +struct drm_plane *plane);/** * drm_plane_find - find a &drm_plane -- 1.9.1
Quoted 11 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v5 3/8 drm: Add Plane CTM property
In reply to Uma ShankarAdd a blob property for plane CSC usage.
v2: Rebase
v3: Fixed Sean, Paul's review comments. Moved the property from mode_config to drm_plane. Created a helper function to instantiate these properties and removed from drm_mode_create_standard_properties Added property documentation as suggested by Daniel, Vetter.
v4: Rebase
v5: Moved property creation to drm_color_mgmt.c file to have all color operations consolidated at one place. No logical change.
--- Documentation/gpu/drm-kms.rst | 3 +++ drivers/gpu/drm/drm_atomic.c | 10 ++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 4 ++++ drivers/gpu/drm/drm_color_mgmt.c | 12 ++++++++++++ include/drm/drm_plane.h | 15 +++++++++++++++ 5 files changed, 44 insertions(+)
Documentation/gpu/drm-kms.rst +3 -0
@@ -647,6 +647,9 @@ Plane Color Management Properties .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :doc: export +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: ctm_property + Tile Group Property -------------------
drivers/gpu/drm/drm_atomic.c +10 -0
@@ -919,6 +919,14 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, &replaced); state->color_mgmt_changed |= replaced;return ret; + }else if (property == plane->ctm_property) { + ret =drm_atomic_replace_property_blob_from_id (dev, + &state->ctm, + val, +sizeof (struct drm_color_ctm ),-1 , + &replaced); + state->color_mgmt_changed |= replaced; +return ret; }else if (plane->funcs->atomic_set_property) {return plane->funcs->atomic_set_property (plane, state, property, val);
@@ -992,6 +1000,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, }else if (property == plane->degamma_lut_property) { *val = (state->degamma_lut) ? state->degamma_lut->base.id :0 ; + }else if (property == plane->ctm_property) { + *val = (state->ctm) ? state->ctm->base.id :0 ; }else if (plane->funcs->atomic_get_property) {return plane->funcs->atomic_get_property (plane, state, property, val); }else {
drivers/gpu/drm/drm_atomic_helper.c +4 -0
@@ -3617,6 +3617,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,if (state->degamma_lut)drm_property_blob_get (state->degamma_lut); +if (state->ctm) +drm_property_blob_get (state->ctm); + state->color_mgmt_changed = false; }EXPORT_SYMBOL (__drm_atomic_helper_plane_duplicate_state);
@@ -3664,6 +3667,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)drm_crtc_commit_put (state->commit);drm_property_blob_put (state->degamma_lut); +drm_property_blob_put (state->ctm); }EXPORT_SYMBOL (__drm_atomic_helper_plane_destroy_state);
drivers/gpu/drm/drm_color_mgmt.c +12 -0
@@ -506,6 +506,11 @@ int drm_plane_create_color_properties(struct drm_plane *plane,* * degamma_lut_size_property: * Range Property to indicate size of the plane degamma LUT. +* +* ctm_property: +* Blob property which allows a userspace to provide CTM coefficients +* to do color space conversion or any other enhancement by doing a +* matrix multiplication using the h/w CTM processing engine */ int drm_plane_color_create_prop (struct drm_device *dev,struct drm_plane *plane)
@@ -526,6 +531,13 @@ int drm_plane_color_create_prop(struct drm_device *dev,return -ENOMEM ; plane->degamma_lut_size_property = prop; + prop =drm_property_create (dev, +DRM_MODE_PROP_BLOB , +"PLANE_CTM" ,0 ); +if (!prop) +return -ENOMEM ; + plane->ctm_property = prop; +return 0 ; }EXPORT_SYMBOL (drm_plane_color_create_prop);
include/drm/drm_plane.h +15 -0
@@ -191,6 +191,14 @@ struct drm_plane_state {struct drm_property_blob *degamma_lut;/** +* @ctm: +* +* Color transformation matrix. See drm_plane_enable_color_mgmt(). The +* blob (if not NULL) is a &struct drm_color_ctm. +*/ +struct drm_property_blob *ctm; + +/** * @commit: Tracks the pending commit to prevent use-after-free conditions, * and for async plane updates. *
@@ -714,6 +722,13 @@ struct drm_plane {* size of the degamma LUT as supported by the driver (read-only). */ struct drm_property *degamma_lut_size_property; + +/** +* @plane_ctm_property: Optional Plane property to set the +* matrix used to convert colors after the lookup in the +* degamma LUT. +*/ +struct drm_property *ctm_property; };#define obj_to_plane (x) container_of(x, struct drm_plane, base)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v5 4/8 drm: Add Plane Gamma properties
In reply to Uma ShankarAdd plane gamma as blob property and size as a
range property.
v2: Rebase
v3: Fixed Sean, Paul's review comments. Moved the property from mode_config to drm_plane. Created a helper function to instantiate these properties and removed from drm_mode_create_standard_properties Added property documentation as suggested by Daniel, Vetter.
v4: Rebase
v5: Moved property creation to drm_color_mgmt.c file to have all color operations consolidated at one place. No logical change.
--- Documentation/gpu/drm-kms.rst | 6 ++++++ drivers/gpu/drm/drm_atomic.c | 9 +++++++++ drivers/gpu/drm/drm_atomic_helper.c | 3 +++ drivers/gpu/drm/drm_color_mgmt.c | 23 +++++++++++++++++++++++ include/drm/drm_plane.h | 22 ++++++++++++++++++++++ 5 files changed, 63 insertions(+)
Documentation/gpu/drm-kms.rst +6 -0
@@ -650,6 +650,12 @@ Plane Color Management Properties .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c :doc: ctm_property +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: gamma_lut_property + +.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c + :doc: gamma_lut_size_property + Tile Group Property -------------------
drivers/gpu/drm/drm_atomic.c +9 -0
@@ -927,6 +927,13 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, &replaced); state->color_mgmt_changed |= replaced;return ret; + }else if (property == plane->gamma_lut_property) { + ret =drm_atomic_replace_property_blob_from_id (dev, + &state->gamma_lut, + val,-1 ,sizeof (struct drm_color_lut ), + &replaced); + state->color_mgmt_changed |= replaced; +return ret; }else if (plane->funcs->atomic_set_property) {return plane->funcs->atomic_set_property (plane, state, property, val);
@@ -1002,6 +1009,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, state->degamma_lut->base.id : 0; }else if (property == plane->ctm_property) { *val = (state->ctm) ? state->ctm->base.id :0 ; + }else if (property == plane->gamma_lut_property) { + *val = (state->gamma_lut) ? state->gamma_lut->base.id :0 ; }else if (plane->funcs->atomic_get_property) {return plane->funcs->atomic_get_property (plane, state, property, val); }else {
drivers/gpu/drm/drm_atomic_helper.c +3 -0
@@ -3619,6 +3619,8 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,drm_property_blob_get (state->degamma_lut);if (state->ctm)drm_property_blob_get (state->ctm); +if (state->gamma_lut) +drm_property_blob_put (state->gamma_lut); state->color_mgmt_changed = false; }
@@ -3668,6 +3670,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)drm_property_blob_put (state->degamma_lut);drm_property_blob_put (state->ctm); +drm_property_blob_put (state->gamma_lut); }EXPORT_SYMBOL (__drm_atomic_helper_plane_destroy_state);
drivers/gpu/drm/drm_color_mgmt.c +23 -0
@@ -511,6 +511,15 @@ int drm_plane_create_color_properties(struct drm_plane *plane,* Blob property which allows a userspace to provide CTM coefficients * to do color space conversion or any other enhancement by doing a * matrix multiplication using the h/w CTM processing engine +* +* gamma_lut_property: +* Blob property which allows a userspace to provide LUT values +* to apply gamma/tone-mapping curve using the h/w plane gamma +* processing engine, thereby making the content as non-linear +* or to perform any tone mapping operation for HDR usecases. +* +* gamma_lut_size_property: +* Range Property to indicate size of the plane gamma LUT. */ int drm_plane_color_create_prop (struct drm_device *dev,struct drm_plane *plane)
@@ -538,6 +547,20 @@ int drm_plane_color_create_prop(struct drm_device *dev,return -ENOMEM ; plane->ctm_property = prop; + prop =drm_property_create (dev, +DRM_MODE_PROP_BLOB , +"PLANE_GAMMA_LUT" ,0 ); +if (!prop) +return -ENOMEM ; + plane->gamma_lut_property = prop; + + prop =drm_property_create_range (dev, +DRM_MODE_PROP_IMMUTABLE , +"PLANE_GAMMA_LUT_SIZE" ,0 ,UINT_MAX ); +if (!prop) +return -ENOMEM ; + plane->gamma_lut_size_property = prop; +return 0 ; }EXPORT_SYMBOL (drm_plane_color_create_prop);
include/drm/drm_plane.h +22 -0
@@ -199,6 +199,15 @@ struct drm_plane_state {struct drm_property_blob *ctm;/** +* @gamma_lut: +* +* Lookup table for converting pixel data after the color conversion +* matrix @ctm. See drm_plane_enable_color_mgmt(). The blob (if not +* NULL) is an array of &struct drm_color_lut_ext. +*/ +struct drm_property_blob *gamma_lut; + +/** * @commit: Tracks the pending commit to prevent use-after-free conditions, * and for async plane updates. *
@@ -729,6 +738,19 @@ struct drm_plane {* degamma LUT. */ struct drm_property *ctm_property; + +/** +* @plane_gamma_lut_property: Optional Plane property to set the LUT +* used to convert the colors, after the CTM matrix, to the common +* gamma space chosen for blending. +*/ +struct drm_property *gamma_lut_property; + +/** +* @plane_gamma_lut_size_property: Optional Plane property for the size +* of the gamma LUT as supported by the driver (read-only). +*/ +struct drm_property *gamma_lut_size_property; };#define obj_to_plane (x) container_of(x, struct drm_plane, base)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v5 5/8 drm: Define helper function for plane color enabling
In reply to Uma ShankarDefine helper function to enable Plane color features to attach plane color properties to plane structure.
v2: Rebase
v3: Modiefied the function to use updated property names.
v4: Rebase
v5: Moved helper function to drm_color_mgmt.c file to have all color operations consolidated at one place. No logical change.
--- drivers/gpu/drm/drm_color_mgmt.c | 42 ++++++++++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 5 +++++ 2 files changed, 47 insertions(+)
drivers/gpu/drm/drm_color_mgmt.c +42 -0
@@ -493,6 +493,48 @@ int drm_plane_create_color_properties(struct drm_plane *plane,EXPORT_SYMBOL (drm_plane_create_color_properties);/** +* drm_plane_enable_color_mgmt - enable color management properties +* @plane: DRM Plane +* @plane_degamma_lut_size: the size of the degamma lut (before CSC) +* @plane_has_ctm: whether to attach ctm_property for CSC matrix +* @plane_gamma_lut_size: the size of the gamma lut (after CSC) +* +* This function lets the driver enable the color correction +* properties on a plane. This includes 3 degamma, csc and gamma +* properties that userspace can set and 2 size properties to inform +* the userspace of the lut sizes. Each of the properties are +* optional. The gamma and degamma properties are only attached if +* their size is not 0 and ctm_property is only attached if has_ctm is +* true. +*/ +void drm_plane_enable_color_mgmt (struct drm_plane *plane, +uint plane_degamma_lut_size, +bool plane_has_ctm, +uint plane_gamma_lut_size) +{ +if (plane_degamma_lut_size) { +drm_object_attach_property (&plane->base, + plane->degamma_lut_property,0 ); +drm_object_attach_property (&plane->base, + plane->degamma_lut_size_property, + plane_degamma_lut_size); + } + +if (plane_has_ctm) +drm_object_attach_property (&plane->base, + plane->ctm_property,0 ); + +if (plane_gamma_lut_size) { +drm_object_attach_property (&plane->base, + plane->gamma_lut_property,0 ); +drm_object_attach_property (&plane->base, + plane->gamma_lut_size_property, + plane_gamma_lut_size); + } +} +EXPORT_SYMBOL (drm_plane_enable_color_mgmt); + +/** * DOC: Plane Color Properties * * Plane Color management or color space adjustments is supported
include/drm/drm_color_mgmt.h +5 -0
@@ -69,4 +69,9 @@ int drm_plane_create_color_properties(struct drm_plane *plane,u32 supported_ranges, enum drm_color_encoding default_encoding, enum drm_color_range default_range); + +void drm_plane_enable_color_mgmt (struct drm_plane *plane, +uint plane_degamma_lut_size, +bool plane_has_ctm, +uint plane_gamma_lut_size);#endif
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v5 6/8 drm/i915: Enable plane color features
In reply to Uma ShankarEnable and initialize plane color features.
v2: Rebase and some cleanup
v3: Updated intel_plane_color_init to calldrm_plane_color_create_prop function, which will
in turn create plane color properties.
v4: Rebase
v5: Rebase
--- drivers/gpu/drm/i915/i915_drv.h | 5 +++++ drivers/gpu/drm/i915/intel_color.c | 14 ++++++++++++++ drivers/gpu/drm/i915/intel_device_info.h | 5 +++++ drivers/gpu/drm/i915/intel_drv.h | 9 +++++++++ 4 files changed, 33 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -455,6 +455,11 @@ struct drm_i915_display_funcs {void (*load_csc_matrix)(struct drm_crtc_state *crtc_state);void (*load_luts)(struct drm_crtc_state *crtc_state); +/* Add Plane Color callbacks */ +void (*load_plane_csc_matrix)(const struct drm_plane_state + *plane_state); +void (*load_plane_luts)(const struct drm_plane_state + *plane_state); };#define CSR_VERSION (major, minor) ((major) << 16 | (minor))
drivers/gpu/drm/i915/intel_color.c +14 -0
@@ -642,6 +642,20 @@ int intel_color_check(struct drm_crtc *crtc,return -EINVAL ; } +void intel_plane_color_init (struct drm_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->dev); + +drm_plane_color_create_prop (plane->dev, plane); + +/* Enable color management support when we have degamma & gamma LUTs. */ +if (INTEL_INFO (dev_priv)->plane_color.plane_degamma_lut_size !=0 && +INTEL_INFO (dev_priv)->plane_color.plane_gamma_lut_size !=0 ) +drm_plane_enable_color_mgmt (plane, +INTEL_INFO (dev_priv)->plane_color.plane_degamma_lut_size, + true,INTEL_INFO (dev_priv)->plane_color.plane_gamma_lut_size); +} +void intel_color_init (struct drm_crtc *crtc) {struct drm_i915_private *dev_priv =to_i915 (crtc->dev);
drivers/gpu/drm/i915/intel_device_info.h +5 -0
@@ -182,6 +182,11 @@ struct intel_device_info {u16 degamma_lut_size;u16 gamma_lut_size; } color; + +struct plane_color_luts { +u16 plane_degamma_lut_size; +u16 plane_gamma_lut_size; + } plane_color; };struct intel_driver_caps {
drivers/gpu/drm/i915/intel_drv.h +9 -0
@@ -536,6 +536,14 @@ struct intel_plane_state {*/ int scaler_id; +/* +* Use reduced/limited/broadcast rbg range, compressing from the full +* range fed into the crtcs. +*/ +bool limited_color_range; +/* Gamma mode programmed on the plane */ +uint32_t gamma_mode; +struct drm_intel_sprite_colorkey ckey; };
@@ -2187,6 +2195,7 @@ int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_int intel_color_check (struct drm_crtc *crtc,struct drm_crtc_state *state);void intel_color_set_csc (struct drm_crtc_state *crtc_state);void intel_color_load_luts (struct drm_crtc_state *crtc_state); +void intel_plane_color_init (struct drm_plane *plane);/* intel_lspcon.c */ bool lspcon_init (struct intel_digital_port *intel_dig_port);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
RFC v5 7/8 drm/i915: Implement Plane Gamma for Bdw and Gen9 platforms
In reply to Uma ShankarImplement Plane Gamma feature for BDW and Gen9 platforms.
v2: Used newly added drm_color_lut_ext structure for enhanced precision for Gamma LUT entries.
v3: Rebase
v4: Used extended function for LUT extraction (pointed by Alexandru).
--- drivers/gpu/drm/i915/i915_pci.c | 5 +++- drivers/gpu/drm/i915/i915_reg.h | 25 ++++++++++++++++ drivers/gpu/drm/i915/intel_color.c | 58 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_display.c | 4 +++ drivers/gpu/drm/i915/intel_sprite.c | 4 +++ 5 files changed, 95 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_pci.c +4 -1
@@ -54,7 +54,10 @@ .cursor_offsets = { CURSOR_A_OFFSET, IVB_CURSOR_B_OFFSET, IVB_CURSOR_C_OFFSET }#define BDW_COLORS \ - .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 } + .color = { .degamma_lut_size = 512, .gamma_lut_size = 512 }, \ + .plane_color = { .plane_degamma_lut_size = 0, \ + .plane_gamma_lut_size = 16 } +#define CHV_COLORS \ .color = { .degamma_lut_size = 65, .gamma_lut_size = 257 }#define GLK_COLORS \
drivers/gpu/drm/i915/i915_reg.h +25 -0
@@ -172,6 +172,10 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)#define _PHY3 (phy, ...) _PICK(phy, __VA_ARGS__)#define _MMIO_PHY3 (phy, a, b, c) _MMIO(_PHY3(phy, a, b, c)) +/* Plane Gamma Registers */ +#define _MMIO_PLANE_GAMC (plane, i, a, b) _MMIO(_PIPE(plane, a, b) + (i) * 4) +#define _MMIO_PLANE_GAMC16 (plane, i, a, b) _MMIO(_PIPE(plane, a, b) + (i) * 4) +#define __MASKED_FIELD (mask, value) ((mask) << 16 | (value))#define _MASKED_FIELD (mask, value) ({ \ if (__builtin_constant_p(mask)) \
@@ -9702,6 +9706,27 @@ enum skl_power_gate {#define PRE_CSC_GAMC_INDEX (pipe) _MMIO_PIPE(pipe, _PRE_CSC_GAMC_INDEX_A, _PRE_CSC_GAMC_INDEX_B)#define PRE_CSC_GAMC_DATA (pipe) _MMIO_PIPE(pipe, _PRE_CSC_GAMC_DATA_A, _PRE_CSC_GAMC_DATA_B) +/* Plane Gamma in Gen9+ */ +#define _PLANE_GAMC_1_A 0x701d0 +#define _PLANE_GAMC_1_B 0x711d0 +#define _PLANE_GAMC_2_A 0x702d0 +#define _PLANE_GAMC_2_B 0x712d0 +#define _PLANE_GAMC_1 (pipe) _PIPE(pipe, _PLANE_GAMC_1_A, _PLANE_GAMC_1_B) +#define _PLANE_GAMC_2 (pipe) _PIPE(pipe, _PLANE_GAMC_2_A, _PLANE_GAMC_2_B) +#define PLANE_GAMC (pipe, plane, i) \ + _MMIO_PLANE_GAMC(plane, i, _PLANE_GAMC_1(pipe), _PLANE_GAMC_2(pipe)) + +#define _PLANE_GAMC16_1_A 0x70210 +#define _PLANE_GAMC16_1_B 0x71210 +#define _PLANE_GAMC16_2_A 0x70310 +#define _PLANE_GAMC16_2_B 0x71310 +#define _PLANE_GAMC16_1 (pipe) _PIPE(pipe, _PLANE_GAMC16_1_A, \ + _PLANE_GAMC16_1_B) +#define _PLANE_GAMC16_2 (pipe) _PIPE(pipe, _PLANE_GAMC16_2_A, \ + _PLANE_GAMC16_2_B) +#define PLANE_GAMC16 (pipe, plane, i) _MMIO_PLANE_GAMC16(plane, i, \ + _PLANE_GAMC16_1(pipe), _PLANE_GAMC16_2(pipe)) +/* pipe CSC & degamma/gamma LUTs on CHV */ #define _CGM_PIPE_A_CSC_COEFF01 (VLV_DISPLAY_BASE + 0x67900)#define _CGM_PIPE_A_CSC_COEFF23 (VLV_DISPLAY_BASE + 0x67904)
drivers/gpu/drm/i915/intel_color.c +58 -0
70 lines not on this page · raw message
drivers/gpu/drm/i915/intel_display.c +4 -0
@@ -13810,6 +13810,10 @@ bool skl_plane_has_planar(struct drm_i915_private *dev_priv,DRM_COLOR_YCBCR_BT709 , DRM_COLOR_YCBCR_LIMITED_RANGE); +/* Add Plane Color properties */ +if (IS_BROADWELL (dev_priv) ||INTEL_GEN (dev_priv) >=9 ) +intel_plane_color_init (&primary->base); +drm_plane_helper_add (&primary->base, &intel_plane_helper_funcs);return primary;
drivers/gpu/drm/i915/intel_sprite.c +4 -0
@@ -1651,6 +1651,10 @@ struct intel_plane *DRM_COLOR_YCBCR_BT709 , DRM_COLOR_YCBCR_LIMITED_RANGE); +/* Add Plane Color properties */ +if (IS_BROADWELL (dev_priv) ||INTEL_GEN (dev_priv) >=9 ) +intel_plane_color_init (&intel_plane->base); +drm_plane_helper_add (&intel_plane->base, &intel_plane_helper_funcs);return intel_plane;
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v5 8/8 drm/i915: Load plane color luts from atomic flip
In reply to Uma ShankarLoad plane color luts as part of atomic plane updates. This will be done only if the plane color luts are changed.
v4: Rebase
v5: Rebase
--- drivers/gpu/drm/i915/intel_atomic_plane.c | 4 ++++ drivers/gpu/drm/i915/intel_color.c | 8 ++++++++ drivers/gpu/drm/i915/intel_drv.h | 1 + 3 files changed, 13 insertions(+)
drivers/gpu/drm/i915/intel_atomic_plane.c +4 -0
@@ -226,6 +226,10 @@ static void intel_plane_atomic_update(struct drm_plane *plane,intel_atomic_get_new_plane_state (state, intel_plane);struct drm_crtc *crtc = new_plane_state->base.crtc ?: old_state->crtc; +if (new_plane_state->base.color_mgmt_changed) { +intel_color_load_plane_luts (&new_plane_state->base); + } +if (new_plane_state->base.visible) {const struct intel_crtc_state *new_crtc_state =intel_atomic_get_new_crtc_state (state,to_intel_crtc (crtc));
drivers/gpu/drm/i915/intel_color.c +8 -0
@@ -666,6 +666,14 @@ void intel_color_load_luts(struct drm_crtc_state *crtc_state) dev_priv->display.load_luts (crtc_state); } +void intel_color_load_plane_luts (const struct drm_plane_state *plane_state) +{ +struct drm_device *dev = plane_state->plane->dev; +struct drm_i915_private *dev_priv =to_i915 (dev); + + dev_priv->display.load_plane_luts (plane_state); +} +int intel_color_check (struct drm_crtc *crtc,struct drm_crtc_state *crtc_state) {
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -2196,6 +2196,7 @@ int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_void intel_color_set_csc (struct drm_crtc_state *crtc_state);void intel_color_load_luts (struct drm_crtc_state *crtc_state);void intel_plane_color_init (struct drm_plane *plane); +void intel_color_load_plane_luts (const struct drm_plane_state *plane_state);/* intel_lspcon.c */ bool lspcon_init (struct intel_digital_port *intel_dig_port);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for Add Plane Color Properties (rev5)
In reply to Uma Shankar== Series Details ==
== Series Details ==
Series: Add Plane Color Properties (rev5)
URL : https://patchwork.freedesktop.org/series/30875/
State : failure
== Summary ==
Applying: drm: Add Enhanced Gamma LUT precision structure
Applying: drm: Add Plane Degamma properties
error: sha1 information is lacking or useless (drivers/gpu/drm/drm_color_mgmt.c).
error: could not build fake ancestor
Patch failed at 0002 drm: Add Plane Degamma properties
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 72 lines · Uma Shankar
This is how a typical display color hardware pipeline looks like:
+-------------------------------------------+ | RAM | | +------+ +---------+ +---------+ | | | FB 1 | | FB 2 | | FB N | | | +------+ +---------+ +---------+ | +-------------------------------------------+ | Plane Color Hardware Block | +--------------------------------------------+ | +---v-----+ +---v-------+ +---v------+ | | | Plane A | | Plane B | | Plane N | | | | DeGamma | | Degamma | | Degamma | | | +---+-----+ +---+-------+ +---+------+ | | | | | | | +---v-----+ +---v-------+ +---v------+ | | |Plane A | | Plane B | | Plane N | | | |CSC/CTM | | CSC/CTM | | CSC/CTM | | | +---+-----+ +----+------+ +----+-----+ | | | | | | | +---v-----+ +----v------+ +----v-----+ | | | Plane A | | Plane B | | Plane N | | | | Gamma | | Gamma | | Gamma | | | +---+-----+ +----+------+ +----+-----+ | | | | | | +--------------------------------------------+ +------v--------------v---------------v-------| || || || Pipe Blender || +--------------------+------------------------+ | | | | +-----------v----------+ | | | Pipe DeGamma | | | | | | | +-----------+----------+ | | | Pipe Color | | +-----------v----------+ Hardware | | | Pipe CSC/CTM | | | | | | | +-----------+----------+ | | | | | +-----------v----------+ | | | Pipe Gamma | | | | | | | +-----------+----------+ | | | | +---------------------------------------------+ |v
Pipe OutputThis patch series adds properties for plane color features. It adds properties for degamma used to linearize data, CSC used for gamut conversion, and gamma used to again non-linearize data as per panel supported color space. These can be utilize by user space to convert planes from one format to another, one color space to another etc.
Usersapce can take smart blending decisions and utilize these hardware supported plane color features to get accurate color profile. The same can help in consistent color quality from source to panel taking advantage of advanced color features in hardware.
These patches just add the property interfaces and enable helper functions.
This series adds Intel Gen9 specific plane gamma feature. We can build up and add other platform/hardware specific implementation on top of this series
Note: This is just to get a design feedback whether these interfaces look ok. Based on community feedback on interfaces, we will implement IGT tests to validate plane color features. This is un-tested currently.
Quoted 6 lines
Userspace implementation using these properties have been done in drm hwcomposer by "Alexandru-Cosmin Gheorghe [email protected]" from ARM. A merge request has been opened by Alexandru for
drm_hwcomposer, implementing the property changes for the same. Please review that as well:
https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/merge_requests/25
Just heads-up I just pushed a v2 for that.
Quoted 46 lines
v2: Dropped legacy gamma table for plane as suggested by Maarten. Added Gen9/BDW plane gamma feature and rebase on tot.
v3: Added a new
drm_color_lut_extstructure to accommodate 32 bit precision entries, pointed to by Brian, Starkey for HDR usecases. Addressed Sean,Paul comments and moved plane color properties todrm_planeinstead ofmode_config. Added property documentation as suggested by Daniel, Vetter. Fixed a rebase fumble which occurred in v2, pointed by Emil Velikov.v4: Rebase
v5: Added "Display Color Hardware Pipeline" flow to kernel documentation as suggested by "Ville Syrjala" and "Brian Starkey". Moved the property creation to
drm_color_mgmt.cfile to consolidate all color operations at one place. Addressed Alexandru's review comments.Uma Shankar (8):
drm: Add Enhanced Gamma LUT precision structure
drm: Add Plane Degamma properties
drm: Add Plane CTM property
drm: Add Plane Gamma properties
drm: Define helper function for plane color enabling drm/i915: Enable plane color features
drm/i915: Implement Plane Gamma for Bdw and Gen9 platforms drm/i915: Load plane color luts from atomic flipDocumentation/gpu/drm-kms.rst | 99 +++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 32 +++++++ drivers/gpu/drm/drm_atomic_helper.c | 13 +++ drivers/gpu/drm/drm_color_mgmt.c | 140 +++++++++++++++++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 5 ++ drivers/gpu/drm/i915/i915_pci.c | 5 +- drivers/gpu/drm/i915/i915_reg.h | 25 ++++++ drivers/gpu/drm/i915/intel_atomic_plane.c | 4 + drivers/gpu/drm/i915/intel_color.c | 80 +++++++++++++++++ drivers/gpu/drm/i915/intel_device_info.h | 5 ++ drivers/gpu/drm/i915/intel_display.c | 4 + drivers/gpu/drm/i915/intel_drv.h | 10 +++ drivers/gpu/drm/i915/intel_sprite.c | 4 + include/drm/drm_color_mgmt.h | 6 ++ include/drm/drm_plane.h | 61 +++++++++++++ include/uapi/drm/drm_mode.h | 15 ++++ 16 files changed, 504 insertions(+), 4 deletions(-)Signature · 1 line
1.9.1
Signature · 6 lines
Cheers, Alex G _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hey,
sön 2018-09-16 klockan 13:45 +0530 skrev Uma Shankar:
Quoted 9 lines
This is how a typical display color hardware pipeline looks like:
+-------------------------------------------+ | RAM | | +------+ +---------+ +---------+ | | | FB 1 | | FB 2 | | FB N | | | +------+ +---------+ +---------+ | +-------------------------------------------+ | Plane Color Hardware Block | +--------------------------------------------+
Should be some mention of color conversion (YUV -> RGB) through drm_color_encoding and drm_color_range enums interacting here?
Quoted 29 lines
| +---v-----+ +---v-------+ +---v------+ | | | Plane A | | Plane B | | Plane N | | | | DeGamma | | Degamma | | Degamma | | | +---+-----+ +---+-------+ +---+------+ | | | | | | | +---v-----+ +---v-------+ +---v------+ | | |Plane A | | Plane B | | Plane N | | | |CSC/CTM | | CSC/CTM | | CSC/CTM | | | +---+-----+ +----+------+ +----+-----+ | | | | | | | +---v-----+ +----v------+ +----v-----+ | | | Plane A | | Plane B | | Plane N | | | | Gamma | | Gamma | | Gamma | | | +---+-----+ +----+------+ +----+-----+ | | | | | | +--------------------------------------------+ +------v--------------v---------------v-------| > > || > > Pipe Blender ||+--------------------+------------------------+ > | | > +-----------v----------+ | > | Pipe DeGamma | | > | | | > +-----------+----------+ | > | Pipe Color | > +-----------v----------+ Hardware | > | Pipe CSC/CTM | |
Quoted 8 lines
> | | | > +-----------+----------+ | > | | > +-----------v----------+ | > | Pipe Gamma | | > | | | > +-----------+----------+ | > | |
Likewise, should probably be some mention about setting colorspace on the connector, so the output will knows what format is used?
Perhaps pull it to this series since one can't work really well without the other?
Quoted 83 lines
+---------------------------------------------+ |v
Pipe OutputThis patch series adds properties for plane color features. It adds properties for degamma used to linearize data, CSC used for gamut conversion, and gamma used to again non-linearize data as per panel supported color space. These can be utilize by user space to convert planes from one format to another, one color space to another etc.
Usersapce can take smart blending decisions and utilize these hardware
supported plane color features to get accurate color profile. The same
can help in consistent color quality from source to panel taking advantage of advanced color features in hardware.These patches just add the property interfaces and enable helper functions.
This series adds Intel Gen9 specific plane gamma feature. We can build up and add other platform/hardware specific implementation on top of this series
Note: This is just to get a design feedback whether these interfaces look ok. Based on community feedback on interfaces, we will implement IGT tests to validate plane color features. This is un-tested currently.
Userspace implementation using these properties have been done in drm hwcomposer by "Alexandru-Cosmin Gheorghe Alexandru-Cosmin.Gheorghe@ar m.com"
from ARM. A merge request has been opened by Alexandru fordrm_hwcomposer,
implementing the property changes for the same. Please review that as well:
https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/merge_re
quests/25v2: Dropped legacy gamma table for plane as suggested by Maarten. Added
Gen9/BDW plane gamma feature and rebase on tot.v3: Added a new
drm_color_lut_extstructure to accommodate 32 bit precision
entries, pointed to by Brian, Starkey for HDR usecases. Addressed Sean,Paul
comments and moved plane color properties todrm_planeinstead ofmode_config. Added property documentation as suggested by Daniel, Vetter.
Fixed a rebase fumble which occurred in v2, pointed by Emil Velikov.v4: Rebase
v5: Added "Display Color Hardware Pipeline" flow to kernel documentation as suggested by "Ville Syrjala" and "Brian Starkey". Moved the property creation to
drm_color_mgmt.cfile to consolidate all color operations at one place. Addressed Alexandru's review comments.Uma Shankar (8):
drm: Add Enhanced Gamma LUT precision structure
drm: Add Plane Degamma properties
drm: Add Plane CTM property
drm: Add Plane Gamma properties
drm: Define helper function for plane color enabling drm/i915: Enable plane color features
drm/i915: Implement Plane Gamma for Bdw and Gen9 platforms drm/i915: Load plane color luts from atomic flipDocumentation/gpu/drm-kms.rst | 99 +++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 32 +++++++ drivers/gpu/drm/drm_atomic_helper.c | 13 +++ drivers/gpu/drm/drm_color_mgmt.c | 140 +++++++++++++++++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 5 ++ drivers/gpu/drm/i915/i915_pci.c | 5 +- drivers/gpu/drm/i915/i915_reg.h | 25 ++++++ drivers/gpu/drm/i915/intel_atomic_plane.c | 4 + drivers/gpu/drm/i915/intel_color.c | 80 +++++++++++++++++
Quoted 9 lines
drivers/gpu/drm/i915/intel_device_info.h | 5 ++ drivers/gpu/drm/i915/intel_display.c | 4 + drivers/gpu/drm/i915/intel_drv.h | 10 +++ drivers/gpu/drm/i915/intel_sprite.c | 4 + include/drm/drm_color_mgmt.h | 6 ++ include/drm/drm_plane.h | 61 +++++++++++++ include/uapi/drm/drm_mode.h | 15 ++++ 16 files changed, 504 insertions(+), 4 deletions(-)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 26 lines
-----Original Message-----
From: Lankhorst, Maarten
Sent: Wednesday, September 26, 2018 1:05 PM
To: Shankar, Uma <[email protected]>; [email protected]; [email protected]
Cc: Syrjala, Ville <[email protected]>; alexandru- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sharma, Shashank <[email protected]>
Subject: Re: [RFC v5 0/8] Add Plane Color PropertiesHey,
sön 2018-09-16 klockan 13:45 +0530 skrev Uma Shankar:
Quoted 9 lines
This is how a typical display color hardware pipeline looks like:
+-------------------------------------------+ | RAM | | +------+ +---------+ +---------+ | | | FB 1 | | FB 2 | | FB N | | | +------+ +---------+ +---------+ | +-------------------------------------------+ | Plane Color Hardware Block | +--------------------------------------------+
Quoted 2 lines
Should be some mention of color conversion (YUV -> RGB) through
drm_color_encodinganddrm_color_rangeenums interacting here?
Thanks Maarten for taking it up for review.
Sure, I can add those details as well here.
Quoted 37 lines
Quoted 29 lines
| +---v-----+ +---v-------+ +---v------+ | | | Plane A | | Plane B | | Plane N | | | | DeGamma | | Degamma | | Degamma | | | +---+-----+ +---+-------+ +---+------+ | | | | | | | +---v-----+ +---v-------+ +---v------+ | | |Plane A | | Plane B | | Plane N | | | |CSC/CTM | | CSC/CTM | | CSC/CTM | | | +---+-----+ +----+------+ +----+-----+ | | | | | | | +---v-----+ +----v------+ +----v-----+ | | | Plane A | | Plane B | | Plane N | | | | Gamma | | Gamma | | Gamma | | | +---+-----+ +----+------+ +----+-----+ | | | | | | +--------------------------------------------+ +------v--------------v---------------v-------| > > || > > Pipe Blender ||+--------------------+------------------------+ > | | > +-----------v----------+ | > | Pipe DeGamma | | > | | | > +-----------+----------+ | > | Pipe Color | > +-----------v----------+ Hardware | > | Pipe CSC/CTM | |Quoted 8 lines
> | | | > +-----------+----------+ | > | | > +-----------v----------+ | > | Pipe Gamma | | > | | | > +-----------+----------+ | > | |
Quoted 6 lines
Likewise, should probably be some mention about setting colorspace on the connector, so the output will knows what format is used?
Perhaps pull it to this series since one can't work really well without the other?
Quoted 1 line
I put it here for painting the complete color hardware pipeline. Since this was just for plane color features, kept the colorspace series separate which was mainly for pipe/connector . So even now if user wants to blend various layers using display plane hardware, it can do that.
I can combine them together if you recommend. But I feel though they both are related but they can be enabled/used independently. Will do as you suggest.
Regards,
Uma Shankar
Quoted 83 lines
Quoted 83 lines
+---------------------------------------------+ |v
Pipe OutputThis patch series adds properties for plane color features. It adds properties for degamma used to linearize data, CSC used for gamut conversion, and gamma used to again non-linearize data as per panel supported color space. These can be utilize by user space to convert planes from one format to another, one color space to another etc.
Usersapce can take smart blending decisions and utilize these hardware
supported plane color features to get accurate color profile. The same
can help in consistent color quality from source to panel taking advantage of advanced color features in hardware.These patches just add the property interfaces and enable helper functions.
This series adds Intel Gen9 specific plane gamma feature. We can build up and add other platform/hardware specific implementation on top of this series
Note: This is just to get a design feedback whether these interfaces look ok. Based on community feedback on interfaces, we will implement IGT tests to validate plane color features. This is un-tested currently.
Userspace implementation using these properties have been done in drm hwcomposer by "Alexandru-Cosmin Gheorghe Alexandru-Cosmin.Gheorghe@ar m.com"
from ARM. A merge request has been opened by Alexandru fordrm_hwcomposer,
implementing the property changes for the same. Please review that as well:
https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/merge_re
quests/25v2: Dropped legacy gamma table for plane as suggested by Maarten. Added
Gen9/BDW plane gamma feature and rebase on tot.v3: Added a new
drm_color_lut_extstructure to accommodate 32 bit precision
entries, pointed to by Brian, Starkey for HDR usecases. Addressed Sean,Paul
comments and moved plane color properties todrm_planeinstead ofmode_config. Added property documentation as suggested by Daniel, Vetter.
Fixed a rebase fumble which occurred in v2, pointed by Emil Velikov.v4: Rebase
v5: Added "Display Color Hardware Pipeline" flow to kernel documentation as suggested by "Ville Syrjala" and "Brian Starkey". Moved the property creation to
drm_color_mgmt.cfile to consolidate all color operations at one place. Addressed Alexandru's review comments.Uma Shankar (8):
drm: Add Enhanced Gamma LUT precision structure
drm: Add Plane Degamma properties
drm: Add Plane CTM property
drm: Add Plane Gamma properties
drm: Define helper function for plane color enabling drm/i915: Enable plane color features
drm/i915: Implement Plane Gamma for Bdw and Gen9 platforms drm/i915: Load plane color luts from atomic flipDocumentation/gpu/drm-kms.rst | 99 +++++++++++++++++++++ drivers/gpu/drm/drm_atomic.c | 32 +++++++ drivers/gpu/drm/drm_atomic_helper.c | 13 +++ drivers/gpu/drm/drm_color_mgmt.c | 140 +++++++++++++++++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 5 ++ drivers/gpu/drm/i915/i915_pci.c | 5 +- drivers/gpu/drm/i915/i915_reg.h | 25 ++++++ drivers/gpu/drm/i915/intel_atomic_plane.c | 4 + drivers/gpu/drm/i915/intel_color.c | 80 +++++++++++++++++ drivers/gpu/drm/i915/intel_device_info.h | 5 ++
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_display.c | 4 + drivers/gpu/drm/i915/intel_drv.h | 10 +++ drivers/gpu/drm/i915/intel_sprite.c | 4 + include/drm/drm_color_mgmt.h | 6 ++ include/drm/drm_plane.h | 61 +++++++++++++ include/uapi/drm/drm_mode.h | 15 ++++ 16 files changed, 504 insertions(+), 4 deletions(-)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx