This is almost just a resend of the previous version, but I had forgotten the EXPORT_SYMBOL(drm_plane_create_color_properties) so bumped the version up. Just wanted to be sure the latest public version actually working.
Changes since v4 version: - Add EXPORT_SYMBOL(drm_plane_create_color_properties); - Rebase on top of the latest drm-next
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 | 93 ++++++++++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 19 ++++++++ include/drm/drm_plane.h | 8 ++++ include/drm/drm_property.h | 2 +- 5 files changed, 129 insertions(+), 1 deletion(-)
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)
On Tue, May 30, 2017 at 07:29:55PM +0300, Jyri Sarha wrote:
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
Thanks for the patch. I've pushed this to drm-misc-next.
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
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 | 93 ++++++++++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 19 ++++++++ include/drm/drm_plane.h | 8 ++++ 4 files changed, 128 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index e163701..3c91775 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -786,6 +786,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); @@ -846,6 +850,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 3eda500..0fb23e5 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -88,6 +88,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. */
/** @@ -336,3 +349,83 @@ 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; +} +EXPORT_SYMBOL(drm_plane_create_color_properties); 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)
Hi Jyri,
[auto build test WARNING on drm/drm-next] [also build test WARNING on next-20170530] [cannot apply to v4.12-rc3] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Jyri-Sarha/drm-Add-const-to-name-fi... base: git://people.freedesktop.org/~airlied/linux.git drm-next reproduce: make htmldocs
All warnings (new ones prefixed by >>):
WARNING: convert(1) not found, for SVG to PDF conversion install ImageMagick (https://www.imagemagick.org) arch/x86/include/asm/uaccess_32.h:1: warning: no structured comments found include/linux/init.h:1: warning: no structured comments found include/linux/mod_devicetable.h:686: warning: Excess struct/union/enum/typedef member 'ver_major' description in 'fsl_mc_device_id' include/linux/mod_devicetable.h:686: warning: Excess struct/union/enum/typedef member 'ver_minor' description in 'fsl_mc_device_id' kernel/sched/core.c:2088: warning: No description found for parameter 'rf' kernel/sched/core.c:2088: warning: Excess function parameter 'cookie' description in 'try_to_wake_up_local' include/linux/kthread.h:26: warning: Excess function parameter '...' description in 'kthread_create' kernel/sys.c:1: warning: no structured comments found include/linux/device.h:969: warning: No description found for parameter 'dma_ops' drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found include/linux/iio/iio.h:597: warning: No description found for parameter 'trig_readonly' include/linux/iio/trigger.h:151: warning: No description found for parameter 'indio_dev' include/linux/iio/trigger.h:151: warning: No description found for parameter 'trig' include/linux/device.h:970: warning: No description found for parameter 'dma_ops' include/linux/usb/gadget.h:230: warning: No description found for parameter 'claimed' include/linux/usb/gadget.h:230: warning: No description found for parameter 'enabled' include/linux/usb/gadget.h:408: warning: No description found for parameter 'quirk_altset_not_supp' include/linux/usb/gadget.h:408: warning: No description found for parameter 'quirk_stall_not_supp' include/linux/usb/gadget.h:408: warning: No description found for parameter 'quirk_zlp_not_supp' include/drm/drm_drv.h:507: warning: No description found for parameter 'set_busid' include/drm/drm_drv.h:507: warning: No description found for parameter 'irq_handler' include/drm/drm_drv.h:507: warning: No description found for parameter 'irq_preinstall' include/drm/drm_drv.h:507: warning: No description found for parameter 'irq_postinstall' include/drm/drm_drv.h:507: warning: No description found for parameter 'irq_uninstall' include/drm/drm_drv.h:507: warning: No description found for parameter 'debugfs_init' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_open_object' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_close_object' include/drm/drm_drv.h:507: warning: No description found for parameter 'prime_handle_to_fd' include/drm/drm_drv.h:507: warning: No description found for parameter 'prime_fd_to_handle' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_export' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_import' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_pin' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_unpin' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_res_obj' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_get_sg_table' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_import_sg_table' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_vmap' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_vunmap' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_prime_mmap' include/drm/drm_drv.h:507: warning: No description found for parameter 'gem_vm_ops' include/drm/drm_drv.h:507: warning: No description found for parameter 'major' include/drm/drm_drv.h:507: warning: No description found for parameter 'minor' include/drm/drm_drv.h:507: warning: No description found for parameter 'patchlevel' include/drm/drm_drv.h:507: warning: No description found for parameter 'name' include/drm/drm_drv.h:507: warning: No description found for parameter 'desc' include/drm/drm_drv.h:507: warning: No description found for parameter 'date' include/drm/drm_drv.h:507: warning: No description found for parameter 'driver_features' include/drm/drm_drv.h:507: warning: No description found for parameter 'ioctls' include/drm/drm_drv.h:507: warning: No description found for parameter 'num_ioctls' include/drm/drm_drv.h:507: warning: No description found for parameter 'fops'
include/drm/drm_plane.h:133: warning: No description found for parameter 'color_encoding' include/drm/drm_plane.h:133: warning: No description found for parameter 'color_range' include/drm/drm_plane.h:535: warning: No description found for parameter 'color_encoding_property' include/drm/drm_plane.h:535: warning: No description found for parameter 'color_range_property' drivers/gpu/drm/drm_color_mgmt.c:382: warning: No description found for parameter 'plane'
include/drm/drm_color_mgmt.h:1: warning: no structured comments found drivers/gpu/drm/drm_color_mgmt.c:383: warning: No description found for parameter 'plane' Documentation/core-api/assoc_array.rst:13: WARNING: Enumerated list ends without a blank line; unexpected unindent. Documentation/doc-guide/sphinx.rst:126: ERROR: Unknown target name: "sphinx c domain". kernel/sched/fair.c:7650: WARNING: Inline emphasis start-string without end-string. kernel/time/timer.c:1200: ERROR: Unexpected indentation. kernel/time/timer.c:1202: ERROR: Unexpected indentation. kernel/time/timer.c:1203: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/wait.h:122: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/wait.h:125: ERROR: Unexpected indentation. include/linux/wait.h:127: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/time/hrtimer.c:990: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/signal.c:322: WARNING: Inline literal start-string without end-string. include/linux/iio/iio.h:219: ERROR: Unexpected indentation. include/linux/iio/iio.h:220: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/iio/iio.h:226: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/iio/industrialio-core.c:638: ERROR: Unknown target name: "iio_val". drivers/iio/industrialio-core.c:645: ERROR: Unknown target name: "iio_val". drivers/message/fusion/mptbase.c:5051: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/tty/serial/serial_core.c:1898: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/pci/pci.c:3457: ERROR: Unexpected indentation. include/linux/regulator/driver.h:271: ERROR: Unknown target name: "regulator_regmap_x_voltage". include/linux/spi/spi.h:370: ERROR: Unexpected indentation. drivers/gpu/drm/drm_scdc_helper.c:203: ERROR: Unexpected indentation. drivers/gpu/drm/drm_scdc_helper.c:204: WARNING: Block quote ends without a blank line; unexpected unindent. drivers/gpu/drm/drm_ioctl.c:690: WARNING: Definition list ends without a blank line; unexpected unindent. Documentation/gpu/todo.rst:111: ERROR: Unknown target name: "drm_fb". sound/soc/soc-core.c:2670: ERROR: Unknown target name: "snd_soc_daifmt". sound/core/jack.c:312: ERROR: Unknown target name: "snd_jack_btn". Documentation/userspace-api/unshare.rst:108: WARNING: Inline emphasis start-string without end-string. Documentation/usb/typec.rst:: WARNING: document isn't included in any toctree Documentation/usb/usb3-debug-port.rst:: WARNING: document isn't included in any toctree Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 164: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "~/.fonts.conf", line 193: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 43: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 56: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 69: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 109: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 122: Having multiple values in <test> isn't supported and may not work as expected Fontconfig warning: "/home/kbuild/.config/fontconfig/fonts.conf", line 133: Having multiple values in <test> isn't supported and may not work as expected
vim +/color_encoding +133 include/drm/drm_plane.h
07f83387 Jyri Sarha 2017-05-30 117 enum drm_color_encoding color_encoding; 07f83387 Jyri Sarha 2017-05-30 118 enum drm_color_range color_range; 07f83387 Jyri Sarha 2017-05-30 119 43968d7b Daniel Vetter 2016-09-21 120 /* Clipped coordinates */ 43968d7b Daniel Vetter 2016-09-21 121 struct drm_rect src, dst; 43968d7b Daniel Vetter 2016-09-21 122 3835b46e Gustavo Padovan 2016-11-07 123 /** 3835b46e Gustavo Padovan 2016-11-07 124 * @visible: 3835b46e Gustavo Padovan 2016-11-07 125 * 3835b46e Gustavo Padovan 2016-11-07 126 * Visibility of the plane. This can be false even if fb!=NULL and 3835b46e Gustavo Padovan 2016-11-07 127 * crtc!=NULL, due to clipping. 43968d7b Daniel Vetter 2016-09-21 128 */ 43968d7b Daniel Vetter 2016-09-21 129 bool visible; 43968d7b Daniel Vetter 2016-09-21 130 43968d7b Daniel Vetter 2016-09-21 131 struct drm_atomic_state *state; 43968d7b Daniel Vetter 2016-09-21 132 }; 43968d7b Daniel Vetter 2016-09-21 @133 1638d30c Rob Clark 2016-11-05 134 static inline struct drm_rect 1638d30c Rob Clark 2016-11-05 135 drm_plane_state_src(const struct drm_plane_state *state) 1638d30c Rob Clark 2016-11-05 136 { 1638d30c Rob Clark 2016-11-05 137 struct drm_rect src = { 1638d30c Rob Clark 2016-11-05 138 .x1 = state->src_x, 1638d30c Rob Clark 2016-11-05 139 .y1 = state->src_y, 1638d30c Rob Clark 2016-11-05 140 .x2 = state->src_x + state->src_w, 1638d30c Rob Clark 2016-11-05 141 .y2 = state->src_y + state->src_h,
:::::: The code at line 133 was first introduced by commit :::::: 43968d7b806d7a7e021261294c583a216fddf0e5 drm: Extract drm_plane.[hc]
:::::: TO: Daniel Vetter daniel.vetter@ffwll.ch :::::: CC: Sean Paul seanpaul@chromium.org
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
On Tue, May 30, 2017 at 07:29:56PM +0300, Jyri Sarha wrote:
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 | 93 ++++++++++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 19 ++++++++ include/drm/drm_plane.h | 8 ++++ 4 files changed, 128 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index e163701..3c91775 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -786,6 +786,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) {
} else if (plane->funcs->atomic_set_property) { return plane->funcs->atomic_set_property(plane, state, property, val);state->color_range = val;
@@ -846,6 +850,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) {
} else if (plane->funcs->atomic_get_property) { return plane->funcs->atomic_get_property(plane, state, property, val); } else {*val = state->color_range;
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 3eda500..0fb23e5 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -88,6 +88,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.
/** @@ -336,3 +349,83 @@ 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,
^^^^^^^^^^^^^^^^^^^^ Apart from these "atomic only" flags I think this looks pretty good.
I've just posted a patch series hooking this up to i915, and I also tossed in some userspace code for the intel ddx to actually make use of this stuff. Seems to work OK, or at least greens change their shade when I toggle the COLOR_ENCODING property ;)
So with s/DRM_MODE_PROP_ATOMIC/0/ this is Reviewed-by: Ville Syrjälä ville.syrjala@linux.intel.com
"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;
+} +EXPORT_SYMBOL(drm_plane_create_color_properties); 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@lists.freedesktop.org