Skip to contentSkip to conversation

drm: Add properties to control YCbCr to RGB conversion

PATCH Superseded Jyri Sarha 1 participant 3 messages May 18, 2017

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Jyri Sarha

author
#0 lore raw

v4 cover drm: Add properties to control YCbCr to RGB conversion

Changes since v3 RFC version:
- Add: "drm: Add const to name field declaration in struct drm_prop_enum_list"
- Fix typos found by Eric Engestrom
- Restructure kernel doc
- Add consts to name sting tables
- Loop variables from unsigned to signed int
- Use len variable to index temporary enum_list
- Initialize state variables if present
- Reorder bitmask test
- Remove drm_property_destroy() call from drm_plane_cleanup()
- Do not initialize the first enum to zero
- Remove struct drm_prop_enum_list declaration from drm_color_mgmt.h

The previous version can be found here:
https://lists.freedesktop.org/archives/dri-devel/2017-May/141766.html

Jyri Sarha (2):
drm: Add const to name field declaration in struct drm_prop_enum_list
drm: Add optinal COLOR_ENCODING and COLOR_RANGE properties to
drm_plane

 drivers/gpu/drm/drm_atomic.c     |  8 ++++
 drivers/gpu/drm/drm_color_mgmt.c | 92 ++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_color_mgmt.h     | 19 +++++++++
 include/drm/drm_plane.h          |  8 ++++
 include/drm/drm_property.h       |  2 +-
 5 files changed, 128 insertions(+), 1 deletion(-)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#1 lore raw

PATCH v4 1/2 drm: Add const to name field declaration in struct drm_prop_enum_list

There is no reason why the name field should not be const, but several why it should. The struct should only be used by drm_property_create_enum() and there the name-field from the struct is passed to drm_property_add_enum(), which takes a const char * as a parameter.

---
 include/drm/drm_property.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_property.h +1 -1
index 13e8c17..619868dc 100644
@@ -214,7 +214,7 @@ struct drm_property_blob {
 
 struct drm_prop_enum_list {
 	int type;
-	char *name;
+	const char *name;
 };
 
 #define obj_to_property(x) container_of(x, struct drm_property, base)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#2 lore raw

PATCH v4 2/2 drm: Add optinal COLOR_ENCODING and COLOR_RANGE properties to drm_plane

In reply to Jyri Sarha

Add a standard optional properties to support different non RGB color encodings in DRM planes. COLOR_ENCODING select the supported non RGB color encoding, for instance ITU-R BT.709 YCbCr. COLOR_RANGE selects the value ranges within the selected color encoding. The properties are stored to drm_plane object to allow different set of supported encoding for different planes on the device.

---
 drivers/gpu/drm/drm_atomic.c     |  8 ++++
 drivers/gpu/drm/drm_color_mgmt.c | 92 ++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_color_mgmt.h     | 19 +++++++++
 include/drm/drm_plane.h          |  8 ++++
 4 files changed, 127 insertions(+)
drivers/gpu/drm/drm_atomic.c +8 -0
index 4033384..f341dda 100644
@@ -774,6 +774,10 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
 		state->rotation = val;
 	} else if (property == plane->zpos_property) {
 		state->zpos = val;
+	} else if (property == plane->color_encoding_property) {
+		state->color_encoding = val;
+	} else if (property == plane->color_range_property) {
+		state->color_range = val;
 	} else if (plane->funcs->atomic_set_property) {
 		return plane->funcs->atomic_set_property(plane, state,
 				property, val);
@@ -834,6 +838,10 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
 		*val = state->rotation;
 	} else if (property == plane->zpos_property) {
 		*val = state->zpos;
+	} else if (property == plane->color_encoding_property) {
+		*val = state->color_encoding;
+	} else if (property == plane->color_range_property) {
+		*val = state->color_range;
 	} else if (plane->funcs->atomic_get_property) {
 		return plane->funcs->atomic_get_property(plane, state, property, val);
 	} else {
drivers/gpu/drm/drm_color_mgmt.c +92 -0

101 lines not on this page · raw message

include/drm/drm_color_mgmt.h +19 -0
index 03a59cb..b3b6d30 100644
@@ -26,6 +26,7 @@
 #include <linux/ctype.h>
 
 struct drm_crtc;
+struct drm_plane;
 
 uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision);
 
@@ -37,4 +38,22 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
 int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
 				 int gamma_size);
 
+enum drm_color_encoding {
+	DRM_COLOR_YCBCR_BT601,
+	DRM_COLOR_YCBCR_BT709,
+	DRM_COLOR_YCBCR_BT2020,
+	DRM_COLOR_ENCODING_MAX,
+};
+
+enum drm_color_range {
+	DRM_COLOR_YCBCR_LIMITED_RANGE,
+	DRM_COLOR_YCBCR_FULL_RANGE,
+	DRM_COLOR_RANGE_MAX,
+};
+
+int drm_plane_create_color_properties(struct drm_plane *plane,
+				      u32 supported_encodings,
+				      u32 supported_ranges,
+				      enum drm_color_encoding default_encoding,
+				      enum drm_color_range default_range);
 #endif
include/drm/drm_plane.h +8 -0
index 9ab3e70..f4de5f9 100644
@@ -26,6 +26,7 @@
 #include <linux/list.h>
 #include <linux/ctype.h>
 #include <drm/drm_mode_object.h>
+#include <drm/drm_color_mgmt.h>
 
 struct drm_crtc;
 struct drm_printer;
@@ -112,6 +113,10 @@ struct drm_plane_state {
 	unsigned int zpos;
 	unsigned int normalized_zpos;
 
+	/* Color encoding for non RGB formats */
+	enum drm_color_encoding color_encoding;
+	enum drm_color_range color_range;
+
 	/* Clipped coordinates */
 	struct drm_rect src, dst;
 
@@ -523,6 +528,9 @@ struct drm_plane {
 
 	struct drm_property *zpos_property;
 	struct drm_property *rotation_property;
+
+	struct drm_property *color_encoding_property;
+	struct drm_property *color_range_property;
 };
 
 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel