* [PATCH v4 0/2] drm: Add properties to control YCbCr to RGB conversion
@ 2017-05-18 19:52 Jyri Sarha
2017-05-18 19:52 ` [PATCH v4 1/2] drm: Add const to name field declaration in struct drm_prop_enum_list Jyri Sarha
2017-05-18 19:52 ` [PATCH v4 2/2] drm: Add optinal COLOR_ENCODING and COLOR_RANGE properties to drm_plane Jyri Sarha
0 siblings, 2 replies; 3+ messages in thread
From: Jyri Sarha @ 2017-05-18 19:52 UTC (permalink / raw)
To: dri-devel; +Cc: Liviu.Dudau, Jyri Sarha, tomi.valkeinen, laurent.pinchart
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(-)
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v4 1/2] drm: Add const to name field declaration in struct drm_prop_enum_list
2017-05-18 19:52 [PATCH v4 0/2] drm: Add properties to control YCbCr to RGB conversion Jyri Sarha
@ 2017-05-18 19:52 ` Jyri Sarha
2017-05-18 19:52 ` [PATCH v4 2/2] drm: Add optinal COLOR_ENCODING and COLOR_RANGE properties to drm_plane Jyri Sarha
1 sibling, 0 replies; 3+ messages in thread
From: Jyri Sarha @ 2017-05-18 19:52 UTC (permalink / raw)
To: dri-devel; +Cc: Liviu.Dudau, Jyri Sarha, tomi.valkeinen, laurent.pinchart
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.
Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
include/drm/drm_property.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h
index 13e8c17..619868dc 100644
--- a/include/drm/drm_property.h
+++ b/include/drm/drm_property.h
@@ -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)
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v4 2/2] drm: Add optinal COLOR_ENCODING and COLOR_RANGE properties to drm_plane
2017-05-18 19:52 [PATCH v4 0/2] drm: Add properties to control YCbCr to RGB conversion Jyri Sarha
2017-05-18 19:52 ` [PATCH v4 1/2] drm: Add const to name field declaration in struct drm_prop_enum_list Jyri Sarha
@ 2017-05-18 19:52 ` Jyri Sarha
1 sibling, 0 replies; 3+ messages in thread
From: Jyri Sarha @ 2017-05-18 19:52 UTC (permalink / raw)
To: dri-devel; +Cc: Liviu.Dudau, Jyri Sarha, tomi.valkeinen, laurent.pinchart
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.
Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
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(+)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 4033384..f341dda 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -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 {
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index 533f3a3..1a89d1a 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -85,6 +85,19 @@
* drm_mode_crtc_set_gamma_size(). Drivers which support both should use
* drm_atomic_helper_legacy_gamma_set() to alias the legacy gamma ramp with the
* "GAMMA_LUT" property above.
+ *
+ * Support for different non RGB color encodings is controlled through
+ * &drm_plane specific COLOR_ENCODING and COLOR_RANGE properties:
+ *
+ * "COLOR_ENCODING"
+ * Optional plane enum property to support different non RGB
+ * color encodings. The driver can provide a subset of standard
+ * enum values supported by the DRM plane.
+ *
+ * "COLOR_RANGE"
+ * Optional plane enum property to support different non RGB
+ * color parameter ranges. The driver can provide a subset of
+ * standard enum values supported by the DRM plane.
*/
/**
@@ -333,3 +346,82 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev,
drm_modeset_unlock(&crtc->mutex);
return ret;
}
+
+static const char * const color_encoding_name[] = {
+ [DRM_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
+ [DRM_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
+ [DRM_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
+};
+
+static const char * const color_range_name[] = {
+ [DRM_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
+ [DRM_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
+};
+
+/**
+ * drm_plane_create_color_properties - color encoding related plane properties
+ * @supported_encodings: bitfield indicating supported color encodings
+ * @supported_ranges: bitfileld indicating supported color ranges
+ * @default_encoding: default color encoding
+ * @default_range: default color range
+ *
+ * Create and attach plane specific COLOR_ENCODING and COLOR_RANGE
+ * properties to to the drm_plane object. The supported encodings and
+ * ranges should be provided in supported_encodings and
+ * supported_ranges bitmasks. Each bit set in the bitmask indicates
+ * the its number as enum value being supported.
+ */
+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)
+{
+ struct drm_device *dev = plane->dev;
+ struct drm_property *prop;
+ struct drm_prop_enum_list enum_list[max(DRM_COLOR_ENCODING_MAX,
+ DRM_COLOR_RANGE_MAX)];
+ int i, len;
+
+ len = 0;
+ for (i = 0; i < DRM_COLOR_ENCODING_MAX; i++) {
+ if ((supported_encodings & BIT(i)) == 0)
+ continue;
+
+ enum_list[len].type = i;
+ enum_list[len].name = color_encoding_name[i];
+ len++;
+ }
+
+ prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
+ "COLOR_ENCODING",
+ enum_list, len);
+ if (!prop)
+ return -ENOMEM;
+ plane->color_encoding_property = prop;
+ drm_object_attach_property(&plane->base, prop, default_encoding);
+ if (plane->state)
+ plane->state->color_encoding = default_encoding;
+
+ len = 0;
+ for (i = 0; i < DRM_COLOR_RANGE_MAX; i++) {
+ if ((supported_ranges & BIT(i)) == 0)
+ continue;
+
+ enum_list[len].type = i;
+ enum_list[len].name = color_range_name[i];
+ len++;
+ }
+
+ prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
+ "COLOR_RANGE",
+ enum_list, len);
+ if (!prop)
+ return -ENOMEM;
+ plane->color_range_property = prop;
+ drm_object_attach_property(&plane->base, prop, default_range);
+ if (plane->state)
+ plane->state->color_range = default_range;
+
+ return 0;
+}
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 03a59cb..b3b6d30 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -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
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 9ab3e70..f4de5f9 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -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)
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-18 19:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-18 19:52 [PATCH v4 0/2] drm: Add properties to control YCbCr to RGB conversion Jyri Sarha
2017-05-18 19:52 ` [PATCH v4 1/2] drm: Add const to name field declaration in struct drm_prop_enum_list Jyri Sarha
2017-05-18 19:52 ` [PATCH v4 2/2] drm: Add optinal COLOR_ENCODING and COLOR_RANGE properties to drm_plane Jyri Sarha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).