New feature: Framebuffer processors
Subsystems (4)
cover New feature: Framebuffer processors
Dear all,
This is the initial proposal for extending DRM API with generic support for hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal I named such hardware modules a framebuffer processors.
Embedded SoCs are known to have a number of hardware blocks, which perform such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to target window size.
Till now there was no generic, hardware independent API for performing such operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.
However, the need for commmon API has been already mentioned on the mailing list. Here are some example threads:
1. "RFC: hardware accelerated bitblt using dma engine"
http://www.spinics.net/lists/dri-devel/msg114250.html
2. "[PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem"
https://lists.freedesktop.org/archives/dri-devel/2015-November/094115.html
https://lists.freedesktop.org/archives/dri-devel/2015-November/094533.html
The proposed API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.
The proposed API consists of the 3 new ioctls:
- DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
- DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
- DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.
The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example blending).
Please note that this API is intended to be used for simple memory-to-memory image processing hardware not the full-blown GPU blitters, which usually have more features. Typically blitters provides much more operations beside simple pixel copying and operate best if its command queue is controlled from respective dedicated code in userspace.
The patchset consist of 4 parts:
1. generic code for DRM core for handling fbproc objects and ioctls
2. example, quick conversion of Exynos Rotator driver to fbproc API
3. libdrm extensions for handling fbproc objects
4. simple example of userspace code for performing 180 degree rotation of the framebuffer
Patches were tested on Exynos 4412-based Odroid U3 board, on top of Linux v4.8-rc1 kernel.
TODO:
1. agree on the API shape
2. add more documentation, especially to the kernel docs
3. add more userspace examples
Best regards
Marek Szyprowski
Samsung R&D Institute Poland
Marek Szyprowski (2):
drm: add support for framebuffer processor objects drm/exynos: register rotator as fbproc instead of custom ipp framework
drivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++------ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 - include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 15 files changed, 1263 insertions(+), 183 deletions(-) create mode 100644 drivers/gpu/drm/drm_fbproc.c delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
Signature · 1 line
1.9.1
RFC 1/2 drm: add support for framebuffer processors
This patch extends DRM API with generic support for hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are: rotation, scaling, colour space conversion or mix of them. I named such hardware modules a framebuffer processors.
The new API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.
The API consists of the 3 new ioctls:
- DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
- DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
- DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.
The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example blending).
--- drivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 11 files changed, 1069 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/drm_fbproc.c
drivers/gpu/drm/Makefile +2 -1
@@ -12,7 +12,8 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ drm_info.o drm_debugfs.o drm_encoder_slave.o \ drm_trace_points.o drm_global.o drm_prime.o \ drm_rect.o drm_vma_manager.o drm_flip_work.o \ - drm_modeset_lock.o drm_atomic.o drm_bridge.o + drm_modeset_lock.o drm_atomic.o drm_bridge.o \ + drm_fbproc.o drm-$(CONFIG_COMPAT) += drm_ioc32.o drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
drivers/gpu/drm/drm_atomic.c +5 -0
@@ -1059,6 +1059,11 @@ int drm_atomic_get_property(struct drm_mode_object *obj, plane->state, property, val);break ; } +case DRM_MODE_OBJECT_FBPROC : { +struct drm_fbproc *fbproc =obj_to_fbproc (obj); + ret =drm_fbproc_get_property (fbproc, property, val); +break ; + }default : ret = -EINVAL ;break ;
drivers/gpu/drm/drm_crtc.c +6 -0
@@ -1540,6 +1540,7 @@ void drm_modeset_unregister_all(struct drm_device *dev)static int drm_mode_create_standard_properties (struct drm_device *dev) {struct drm_property *prop; +int ret;/* * Standard properties (apply to all connectors)
@@ -1689,6 +1690,10 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)return -ENOMEM ; dev->mode_config.gamma_lut_size_property = prop; + ret =drm_fbproc_create_properties (dev); +if (ret) +return ret; +return 0 ; }
@@ -5692,6 +5697,7 @@ void drm_mode_config_init(struct drm_device *dev)INIT_LIST_HEAD (&dev->mode_config.property_list);INIT_LIST_HEAD (&dev->mode_config.property_blob_list);INIT_LIST_HEAD (&dev->mode_config.plane_list); +INIT_LIST_HEAD (&dev->mode_config.fbproc_list);idr_init (&dev->mode_config.crtc_idr);idr_init (&dev->mode_config.tile_idr);ida_init (&dev->mode_config.connector_ida);
drivers/gpu/drm/drm_crtc_internal.h +12 -0
@@ -132,3 +132,15 @@ void drm_modeset_unregister_all(struct drm_device *dev);/* drm_blend.c */ int drm_atomic_helper_normalize_zpos (struct drm_device *dev,struct drm_atomic_state *state); + +/* drm_fbproc.c */ +int drm_fbproc_create_properties (struct drm_device *dev); +int drm_fbproc_get_property (struct drm_fbproc *fbproc, +struct drm_property *property,uint64_t *val); + +int drm_mode_getfbproc_res (struct drm_device *dev,void *data, +struct drm_file *file_priv); +int drm_mode_getfbproc (struct drm_device *dev,void *data, +struct drm_file *file_priv); +int drm_mode_fbproc_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv);
drivers/gpu/drm/drm_fbproc.c new file +754 -0
754 lines not on this page · raw message
drivers/gpu/drm/drm_ioctl.c +3 -0
@@ -621,6 +621,9 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_ATOMIC , drm_mode_atomic_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_CREATEPROPBLOB , drm_mode_createblob_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_DESTROYPROPBLOB , drm_mode_destroyblob_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETFBPROCRESOURCES , drm_mode_getfbproc_res,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETFBPROC , drm_mode_getfbproc,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_FBPROC, drm_mode_fbproc_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED), };#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
include/drm/drmP.h +10 -0
@@ -114,6 +114,9 @@ struct dma_buf_attachment;* VBL: used for verbose debug message in the vblank code * This is the category used by the DRM_DEBUG_VBL() macro. * +* FBPROC: used for verbose debug message in the fbproc code +* This is the category used by the DRM_DEBUG_FBPROC() macro. +* * Enabling verbose debug messages is done through the drm.debug parameter, * each category being enabled by a bit. *
@@ -133,6 +136,7 @@ struct dma_buf_attachment;#define DRM_UT_PRIME 0x08#define DRM_UT_ATOMIC 0x10#define DRM_UT_VBL 0x20 +#define DRM_UT_FBPROC 0x40 extern __printf(2, 3) void drm_ut_debug_printk(const char *function_name,
@@ -158,6 +162,7 @@ void drm_err(const char *format, ...);#define DRIVER_RENDER 0x8000#define DRIVER_ATOMIC 0x10000#define DRIVER_KMS_LEGACY_CONTEXT 0x20000 +#define DRIVER_FBPROC 0x40000/***********************************************************************/ /** \name Macros to make printk easier */
@@ -231,6 +236,11 @@ void drm_err(const char *format, ...);if (unlikely (drm_debug &DRM_UT_VBL )) \ drm_ut_debug_printk(__func__, fmt, ##args); \ }while (0 ) +#define DRM_DEBUG_FBPROC(fmt, args...) \ +do { \ +if (unlikely (drm_debug &DRM_UT_FBPROC )) \ + drm_ut_debug_printk(__func__, fmt, ##args); \ + }while (0 )/*@}*/
include/drm/drm_crtc.h +211 -0
268 lines not on this page · raw message
include/drm/drm_irq.h +14 -0
@@ -29,6 +29,20 @@/** * struct drm_pending_vblank_event - pending vblank event tracking */ +struct drm_pending_fbproc_event { +/** +* @base: Base structure for tracking pending DRM events. +*/ +struct drm_pending_event base; +/** +* @event: Actual event which will be sent to userspace. +*/ +struct drm_event_fbproc event; +}; + +/** +* struct drm_pending_vblank_event - pending vblank event tracking +*/ struct drm_pending_vblank_event {/** * @base: Base structure for tracking pending DRM events.
include/uapi/drm/drm.h +13 -0
@@ -812,6 +812,9 @@ extern "C" {#define DRM_IOCTL_MODE_ATOMIC DRM_IOWR(0xBC, struct drm_mode_atomic)#define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob)#define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob) +#define DRM_IOCTL_MODE_GETFBPROCRESOURCES DRM_IOWR(0xBF, struct drm_mode_get_fbproc_res) +#define DRM_IOCTL_MODE_GETFBPROC DRM_IOWR(0xC0, struct drm_mode_get_fbproc) +#define DRM_IOCTL_MODE_FBPROC DRM_IOWR(0xC1, struct drm_mode_fbproc)/** * Device specific ioctls should only be in their respective headers
@@ -843,6 +846,7 @@ struct drm_event {#define DRM_EVENT_VBLANK 0x01#define DRM_EVENT_FLIP_COMPLETE 0x02 +#define DRM_EVENT_FBPROC_COMPLETE 0x03struct drm_event_vblank {struct drm_event base;
@@ -853,6 +857,15 @@ struct drm_event_vblank {__u32 reserved; }; +struct drm_event_fbproc { +struct drm_event base; +__u64 user_data; +__u32 tv_sec; +__u32 tv_usec; +__u32 sequence; +__u32 reserved; +}; +/* typedef area */ #ifndef __KERNEL__typedef struct drm_clip_rect drm_clip_rect_t ;
include/uapi/drm/drm_mode.h +39 -0
@@ -326,6 +326,21 @@ struct drm_mode_connector_set_property {__u32 connector_id; }; +struct drm_mode_get_fbproc_res { +__u64 fbproc_id_ptr; +__u32 count_fbprocs; +}; + +struct drm_mode_get_fbproc { +__u32 fbproc_id; +__u32 capabilities; + +__u32 src_format_count; +__u32 dst_format_count; +__u64 src_format_type_ptr; +__u64 dst_format_type_ptr; +}; +#define DRM_MODE_OBJECT_CRTC 0xcccccccc#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
@@ -334,6 +349,7 @@ struct drm_mode_connector_set_property {#define DRM_MODE_OBJECT_FB 0xfbfbfbfb#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee +#define DRM_MODE_OBJECT_FBPROC 0x88888888#define DRM_MODE_OBJECT_ANY 0struct drm_mode_obj_get_properties {
@@ -627,6 +643,29 @@ struct drm_mode_destroy_blob {__u32 blob_id; }; +#define DRM_FBPROC_CAP_CROP 0x01 +#define DRM_FBPROC_CAP_ROTATE 0x02 +#define DRM_FBPROC_CAP_SCALE 0x04 +#define DRM_FBPROC_CAP_CONVERT 0x08 +#define DRM_FBPROC_CAP_FB_MODIFIERS 0x1000 + +#define DRM_MODE_FBPROC_EVENT 0x01 +#define DRM_MODE_FBPROC_TEST_ONLY 0x02 +#define DRM_MODE_FBPROC_NONBLOCK 0x04 + +#define DRM_MODE_FBPROC_FLAGS (DRM_MODE_FBPROC_EVENT |\ + DRM_MODE_FBPROC_TEST_ONLY | DRM_MODE_FBPROC_NONBLOCK) + +struct drm_mode_fbproc { +__u32 fbproc_id; +__u32 flags; +__u32 count_props; +__u64 props_ptr; +__u64 prop_values_ptr; +__u64 reserved; +__u64 user_data; +}; +#if defined(__cplusplus) }#endif
Signature · 1 line
1.9.1
RFC 2/2 drm/exynos: register rotator as fbproc instead of custom ipp framework
In reply to Marek SzyprowskiThis is a quick conversion of Exynos DRM rotator driver from Exynos IPP framework to generic DRM FBProc API to demonstrate how to use it from the driver side.
Not-for-merge-yet: the code of the driver must be cleaned up first, because its internals still depends on Exynos IPP structures.
--- drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++++++++++------------- drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 -- 4 files changed, 194 insertions(+), 182 deletions(-) delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
drivers/gpu/drm/exynos/Kconfig +0 -1
@@ -109,7 +109,6 @@ config DRM_EXYNOS_FIMC config DRM_EXYNOS_ROTATOR bool "Rotator" - depends on DRM_EXYNOS_IPP help Choose this option if you want to use Exynos Rotator for DRM.
drivers/gpu/drm/exynos/exynos_drm_drv.c +2 -1
@@ -395,7 +395,7 @@ static const struct file_operations exynos_drm_driver_fops = {static struct drm_driver exynos_drm_driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_PRIME - |DRIVER_ATOMIC |DRIVER_RENDER , + |DRIVER_ATOMIC |DRIVER_RENDER |DRIVER_FBPROC , .load = exynos_drm_load, .unload = exynos_drm_unload, .open = exynos_drm_open,
@@ -532,6 +532,7 @@ static struct exynos_drm_driver_info exynos_drm_drivers[] = {DRV_PTR (fimc_driver,CONFIG_DRM_EXYNOS_FIMC ), }, {DRV_PTR (rotator_driver,CONFIG_DRM_EXYNOS_ROTATOR ), +DRM_COMPONENT_DRIVER }, { DRV_PTR(gsc_driver, CONFIG_DRM_EXYNOS_GSC), }, {
drivers/gpu/drm/exynos/exynos_drm_rotator.c +192 -161
441 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_rotator.h deleted +0 -19
@@ -1,19 +0,0 @@ -/* -* Copyright (c) 2012 Samsung Electronics Co., Ltd. -* -* Authors: -* YoungJun Cho <[email protected]> -* Eunchul Kim <[email protected]> -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at your -* option) any later version. -*/ - -#ifndef _EXYNOS_DRM_ROTATOR_H_ -#define _EXYNOS_DRM_ROTATOR_H_ - -/* TODO */ - -#endif
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 1/1 add support for framebuffer processor (fbproc) objects
In reply to Marek SzyprowskiThis patch extends DRM API with generic support for hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are: rotation, scaling, colour space conversion or mix of them. I named such hardware modules a framebuffer processors.
The new API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.
The API consists of the 3 new ioctls:
- DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
- DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
- DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.
The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example blending).
--- include/drm/drm.h | 13 ++ include/drm/drm_mode.h | 39 ++++++ xf86drmMode.c | 345 +++++++++++++++++++++++++++++++++++++++++++++++++ xf86drmMode.h | 37 ++++++ 4 files changed, 434 insertions(+)
include/drm/drm.h +13 -0
@@ -794,6 +794,9 @@ struct drm_prime_handle {#define DRM_IOCTL_MODE_ATOMIC DRM_IOWR(0xBC, struct drm_mode_atomic)#define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob)#define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob) +#define DRM_IOCTL_MODE_GETFBPROCRESOURCES DRM_IOWR(0xBF, struct drm_mode_get_fbproc_res) +#define DRM_IOCTL_MODE_GETFBPROC DRM_IOWR(0xC0, struct drm_mode_get_fbproc) +#define DRM_IOCTL_MODE_FBPROC DRM_IOWR(0xC1, struct drm_mode_fbproc)/** * Device specific ioctls should only be in their respective headers
@@ -825,6 +828,7 @@ struct drm_event {#define DRM_EVENT_VBLANK 0x01#define DRM_EVENT_FLIP_COMPLETE 0x02 +#define DRM_EVENT_FBPROC_COMPLETE 0x03struct drm_event_vblank {struct drm_event base;
@@ -835,6 +839,15 @@ struct drm_event_vblank {__u32 reserved; }; +struct drm_event_fbproc { +struct drm_event base; +__u64 user_data; +__u32 tv_sec; +__u32 tv_usec; +__u32 sequence; +__u32 reserved; +}; +/* typedef area */ typedef struct drm_clip_rect drm_clip_rect_t ;typedef struct drm_drawable_info drm_drawable_info_t ;
include/drm/drm_mode.h +39 -0
@@ -320,6 +320,21 @@ struct drm_mode_connector_set_property {__u32 connector_id; }; +struct drm_mode_get_fbproc_res { +__u64 fbproc_id_ptr; +__u32 count_fbprocs; +}; + +struct drm_mode_get_fbproc { +__u32 fbproc_id; +__u32 capabilities; + +__u32 src_format_count; +__u32 dst_format_count; +__u64 src_format_type_ptr; +__u64 dst_format_type_ptr; +}; +#define DRM_MODE_OBJECT_CRTC 0xcccccccc#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
@@ -328,6 +343,7 @@ struct drm_mode_connector_set_property {#define DRM_MODE_OBJECT_FB 0xfbfbfbfb#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee +#define DRM_MODE_OBJECT_FBPROC 0x88888888#define DRM_MODE_OBJECT_ANY 0struct drm_mode_obj_get_properties {
@@ -621,4 +637,27 @@ struct drm_mode_destroy_blob { __u32 blob_id; }; +#define DRM_FBPROC_CAP_CROP 0x01 +#define DRM_FBPROC_CAP_ROTATE 0x02 +#define DRM_FBPROC_CAP_SCALE 0x04 +#define DRM_FBPROC_CAP_CONVERT 0x08 +#define DRM_FBPROC_CAP_FB_MODIFIERS 0x1000 + +#define DRM_MODE_FBPROC_EVENT 0x01 +#define DRM_MODE_FBPROC_TEST_ONLY 0x02 +#define DRM_MODE_FBPROC_NONBLOCK 0x04 + +#define DRM_MODE_FBPROC_FLAGS (DRM_MODE_FBPROC_EVENT |\ + DRM_MODE_FBPROC_TEST_ONLY | DRM_MODE_FBPROC_NONBLOCK) + +struct drm_mode_fbproc { +__u32 fbproc_id; +__u32 flags; +__u32 count_props; +__u64 props_ptr; +__u64 prop_values_ptr; +__u64 reserved; +__u64 user_data; +}; +#endif
xf86drmMode.c +345 -0
354 lines not on this page · raw message
xf86drmMode.h +37 -0
@@ -335,6 +335,20 @@ typedef struct _drmModePlaneRes {uint32_t *planes; } drmModePlaneRes, *drmModePlaneResPtr; +typedef struct _drmModeFBProcRes { +uint32_t count_fbprocs; +uint32_t *fbprocs; +}drmModeFBProcRes , *drmModeFBProcResPtr ; + +typedef struct _drmModeFBProc { +uint32_t fbproc_id; +uint32_t capabilities; +uint32_t src_format_count; +uint32_t dst_format_count; +uint32_t *src_formats; +uint32_t *dst_formats; +}drmModeFBProc , *drmModeFBProcPtr ; +extern void drmModeFreeModeInfo (drmModeModeInfoPtr ptr );extern void drmModeFreeResources (drmModeResPtr ptr );extern void drmModeFreeFB (drmModeFBPtr ptr );
@@ -343,6 +357,8 @@ extern void drmModeFreeConnector( drmModeConnectorPtr ptr );extern void drmModeFreeEncoder (drmModeEncoderPtr ptr );extern void drmModeFreePlane (drmModePlanePtr ptr );extern void drmModeFreePlaneResources (drmModePlaneResPtr ptr); +extern void drmModeFreeFBProcResources (drmModeFBProcResPtr ptr); +extern void drmModeFreeFBProc (drmModeFBProcPtr ptr);/** * Retrives all of the resources associated with a card.
@@ -483,6 +499,9 @@ extern void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr);extern int drmModeObjectSetProperty (int fd,uint32_t object_id,uint32_t object_type,uint32_t property_id,uint64_t value); +extern drmModeFBProcPtr drmModeGetFBProc (int fd,uint32_t fbproc_id); +extern drmModeFBProcResPtr drmModeGetFBProcResources (int fd); +typedef struct _drmModeAtomicReq drmModeAtomicReq , *drmModeAtomicReqPtr ;
@@ -507,6 +526,24 @@ extern int drmModeCreatePropertyBlob(int fd, const void *data, size_t size, uint32_t *id);extern int drmModeDestroyPropertyBlob (int fd,uint32_t id); +typedef struct _drmModeFBProcReq drmModeFBProcReq , *drmModeFBProcReqPtr ; + +extern drmModeFBProcReqPtr drmModeFBProcReqAlloc (void ); +extern drmModeFBProcReqPtr drmModeFBProcReqDuplicate (drmModeFBProcReqPtr req); +extern int drmModeFBProcReqMerge (drmModeFBProcReqPtr base, +drmModeFBProcReqPtr augment); +extern void drmModeFBProcReqFree (drmModeFBProcReqPtr req); +extern int drmModeFBProcReqGetCursor (drmModeFBProcReqPtr req); +extern void drmModeFBProcReqSetCursor (drmModeFBProcReqPtr req,int cursor); +extern int drmModeFBProcReqAddProperty (drmModeFBProcReqPtr req, +uint32_t property_id, +uint64_t value); +extern int drmModeFBProcReqCommit (int fd, +uint32_t fbproc_id, +drmModeFBProcReqPtr req, +uint32_t flags, +void *user_data); +#if defined(__cplusplus) }
Signature · 1 line
1.9.1
RFC 1/1 example code for testing fbproc drivers
In reply to Marek SzyprowskiThis is simple example how DRM FBProc API can be used from userspace. The code allocates 2 dumb framebuffers, fill first with test pattern and then performs 180 degree rotation of the image data.
TODO: add code to release all allocated resources
--- rotate.c | 336 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 336 insertions(+) create mode 100644 rotate.c
rotate.c new file +336 -0
@@ -0,0 +1,336 @@ +/* +* Copyright (C) 2016 Samsung Electronics Co.Ltd +* Authors: Marek Szyprowski <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/select.h> +#include <sys/mman.h> +#include <fcntl.h> +#include <unistd.h> +#include <string.h> +#include <signal.h> +#include <time.h> +#include <errno.h> + +#include <xf86drm.h> +#include <xf86drmMode.h> +#include <drm_fourcc.h> + +/* missing rotation property bits */ +#define DRM_ROTATE_0 0x01 +#define DRM_ROTATE_90 0x02 +#define DRM_ROTATE_180 0x04 +#define DRM_ROTATE_270 0x08 +#define DRM_REFLECT_X 0x10 +#define DRM_REFLECT_Y 0x20 + +struct bo +{ +int fd; +void *ptr; +size_t size; +size_t offset; +size_t pitch; +int width; +int height; +unsigned handle; +unsigned fb_id; +}; + +struct bo *bo_create_dumb (int fd,unsigned int width,unsigned int height, +unsigned int bpp) +{ +struct drm_mode_create_dumb arg; +struct bo *bo; +int ret; + + bo =calloc (1 ,sizeof (*bo)); +if (bo ==NULL ) { +fprintf (stderr,"failed to allocate buffer object\n" ); +return NULL ; + } + +memset (&arg,0 ,sizeof (arg)); + arg.bpp = bpp; + arg.width = width; + arg.height = height; + + ret =drmIoctl (fd,DRM_IOCTL_MODE_CREATE_DUMB , &arg); +if (ret) { +fprintf (stderr,"failed to create dumb buffer: %s\n" , +strerror (errno)); +free (bo); +return NULL ; + } + + bo->fd = fd; + bo->handle = arg.handle; + bo->size = arg.size; + bo->pitch = arg.pitch; + bo->width = width; + bo->height = height; + +return bo; +} + +int bo_map (struct bo *bo) +{ +struct drm_mode_map_dumb arg; +void *map; +int ret; + +memset (&arg,0 ,sizeof (arg)); + arg.handle = bo->handle; + + ret =drmIoctl (bo->fd,DRM_IOCTL_MODE_MAP_DUMB , &arg); +if (ret) +return ret; + + map =mmap (0 , bo->size,PROT_READ |PROT_WRITE ,MAP_SHARED , + bo->fd, arg.offset); +if (map ==MAP_FAILED ) +return -EINVAL ; + + bo->ptr = map; + +return 0 ; +} + +void bo_unmap (struct bo *bo) +{ +if (!bo->ptr) +return ; + +munmap (bo->ptr, bo->size); + bo->ptr =NULL ; +} + +void bo_destroy (struct bo *bo) +{ +struct drm_mode_destroy_dumb arg; +int ret; + +memset (&arg,0 ,sizeof (arg)); + arg.handle = bo->handle; + + ret =drmIoctl (bo->fd,DRM_IOCTL_MODE_DESTROY_DUMB , &arg); +if (ret) +fprintf (stderr,"failed to destroy dumb buffer: %s\n" , +strerror (errno)); + +free (bo); +} + +int bo_add_fb (struct bo *bo,uint32_t format,uint32_t flags) +{ +int ret; +uint32_t handles[4 ] = {bo->handle}; +uint32_t pitches[4 ] = {bo->pitch}; +uint32_t offsets[4 ] = {}; + + + ret =drmModeAddFB2 (bo->fd, bo->width, bo->height, + format, handles, pitches, offsets, + &bo->fb_id, flags); +if (ret) { +printf ("failed to create fb ret=%d\n" , ret); +return ret; + } +return 0 ; +} + +struct bo *bo_create_dumb_fb_xrgb (int fd,unsigned int width,unsigned int height) +{ +struct bo *bo; + + bo =bo_create_dumb (fd, width, height,32 ); +bo_map (bo); +bo_add_fb (bo,DRM_FORMAT_XRGB8888 ,0 ); + +return bo; +} + +uint32_t get_prop_id (int fd,drmModeObjectPropertiesPtr props,const char *name) +{ +drmModePropertyPtr p; +uint32_t i, prop_id =0 ;/* Property ID should always be > 0 */ + +for (i =0 ; !prop_id && i < props->count_props; i++) { + p =drmModeGetProperty (fd, props->props[i]); +if (!strcmp (p->name, name)) + prop_id = p->prop_id; +drmModeFreeProperty (p); + } +if (!prop_id) +printf ("Could not find %s property\n" , name); +return prop_id; +} + + +int process_fb (int fd,int rotation,int src_fb_id,int sx,int sy,int sw,int sh, +int dst_fb_id,int dx,int dy,int dw,int dh) +{ +drmModeObjectPropertiesPtr props; +drmModeFBProcResPtr res; +drmModeFBProcPtr fbproc; +drmModeFBProcReqPtr req; +uint32_t id, pid; +int i, ret; + + res =drmModeGetFBProcResources (fd); +if (!res) { +printf ("failed to get fbproc resources\n" ); +return 0 ; + } + +if (res->count_fbprocs ==0 ) { +printf ("no fbproc object found\n" ); +return 0 ; + } + + id = res->fbprocs[0 ]; +drmModeFreeFBProcResources (res); + + fbproc =drmModeGetFBProc (fd, id); + +if (!(fbproc->capabilities &DRM_FBPROC_CAP_ROTATE )) { +printf ("fbproc has no rotation capability\n" ); +return 0 ; + } + + req =drmModeFBProcReqAlloc (); +if (!req) { +printf ("Failed to allocate the request\n" ); +return 0 ; + } + +drmModeFBProcReqSetCursor (req,0 ); + + props =drmModeObjectGetProperties (fd, id,DRM_MODE_OBJECT_FBPROC ); + + pid =get_prop_id (fd, props,"SRC_FB_ID" ); +if (drmModeFBProcReqAddProperty (req, pid, src_fb_id) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"SRC_X" ); +if (drmModeFBProcReqAddProperty (req, pid, sx <<16 ) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"SRC_Y" ); +if (drmModeFBProcReqAddProperty (req, pid, sy <<16 ) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"SRC_W" ); +if (drmModeFBProcReqAddProperty (req, pid, sw <<16 ) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"SRC_H" ); +if (drmModeFBProcReqAddProperty (req, pid, sh <<16 ) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"DST_FB_ID" ); +if (drmModeFBProcReqAddProperty (req, pid, dst_fb_id) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"DST_X" ); +if (drmModeFBProcReqAddProperty (req, pid, dx <<16 ) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"DST_Y" ); +if (drmModeFBProcReqAddProperty (req, pid, dy <<16 ) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"DST_W" ); +if (drmModeFBProcReqAddProperty (req, pid, dw <<16 ) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"DST_H" ); +if (drmModeFBProcReqAddProperty (req, pid, dh <<16 ) <0 ) +return 0 ; + + pid =get_prop_id (fd, props,"rotation" ); +if (drmModeFBProcReqAddProperty (req, pid, rotation) <0 ) +return 0 ; + +drmModeFreeObjectProperties (props); + + ret =drmModeFBProcReqCommit (fd, id, req,0 ,NULL ); +if (ret) { +printf ("failed to commit fbproc request: %d\n" , ret); +return 0 ; + } + +drmModeFBProcReqFree (req); + +return 1 ; +} + +int main (int argc,char *argv[]) +{ +struct bo *buf1, *buf2; +int fd; +int ret; +int width =640 ; +int height =480 ; +int val =1 , x, y; + + fd =open ("/dev/dri/card0" ,O_RDWR ); +drmSetClientCap (fd,DRM_CLIENT_CAP_ATOMIC ,1 ); + + buf1 =bo_create_dumb_fb_xrgb (fd, width, height); + buf2 =bo_create_dumb_fb_xrgb (fd, width, height); + +/* draw test pattern to buffer1 */ +for (y =0 ; y < height; y++) { +uint32_t *p = buf1->ptr + buf1->pitch * y; + +for (x =0 ; x < width; x++) + *p++ = val++ &0xffffff ; + } + + ret =process_fb (fd,DRM_ROTATE_180 , buf1->fb_id,0 ,0 , width, height, + buf2->fb_id,0 ,0 , width, height); + +if (ret =1 ) { +printf ("Buffer processed, checking processed buffer... " ); + +for (y =0 ; y < height; y++) { +uint32_t *p1 = buf1->ptr + buf1->pitch * y; +uint32_t *p2 = buf2->ptr + buf1->pitch * (height - y -1 ); + +for (x =0 ; x < width; x++) +if (*(p1 + x) != *(p2 + width - x -1 )) { +printf ("failed at (%d,%d) %06x != %06x.\n" , + x, y, *(p1 + x), + *(p2 + width - x -1 )); +return ; + } + } +printf ("okay.\n" ); + } + +return 0 ; +}
Signature · 1 line
1.9.1
Am 22.08.2016 um 11:44 schrieb Marek Szyprowski:
Quoted 15 lines
Dear all,
This is the initial proposal for extending DRM API with generic support for hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal I named such hardware modules a framebuffer processors.Embedded SoCs are known to have a number of hardware blocks, which perform such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to target window size.
Quoted 5 lines
Till now there was no generic, hardware independent API for performing such operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.
Well there are good reasons why we don't have hardware independent command submission.
We already tried approaches like this and they didn't worked very well and are generally a pain to get right.
So my feeling goes into the direction of a NAK, especially since you didn't explained in this mail why there is need for a common API.
Regards,
Christian.
Quoted 78 lines
However, the need for commmon API has been already mentioned on the mailing list. Here are some example threads:
1. "RFC: hardware accelerated bitblt using dma engine"
http://www.spinics.net/lists/dri-devel/msg114250.html
2. "[PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem"
https://lists.freedesktop.org/archives/dri-devel/2015-November/094115.html
https://lists.freedesktop.org/archives/dri-devel/2015-November/094533.htmlThe proposed API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.The proposed API consists of the 3 new ioctls:
-DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
-DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
-DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example blending).
Please note that this API is intended to be used for simple memory-to-memory image processing hardware not the full-blown GPU blitters, which usually have more features. Typically blitters provides much more operations beside simple pixel copying and operate best if its command queue is controlled from respective dedicated code in userspace.
The patchset consist of 4 parts:
1. generic code for DRM core for handling fbproc objects and ioctls
2. example, quick conversion of Exynos Rotator driver to fbproc API
3. libdrm extensions for handling fbproc objects
4. simple example of userspace code for performing 180 degree rotation of the framebufferPatches were tested on Exynos 4412-based Odroid U3 board, on top of Linux v4.8-rc1 kernel.
TODO:
1. agree on the API shape
2. add more documentation, especially to the kernel docs
3. add more userspace examplesBest regards
Marek Szyprowski
Samsung R&D Institute PolandMarek Szyprowski (2):
drm: add support for framebuffer processor objects drm/exynos: register rotator as fbproc instead of custom ipp frameworkdrivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++------ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 - include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 15 files changed, 1263 insertions(+), 183 deletions(-)
Quoted 3 lines
create mode 100644
drivers/gpu/drm/drm_fbproc.cdelete mode 100644drivers/gpu/drm/exynos/exynos_drm_rotator.h
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 22 lines · Christian König
Am 22.08.2016 um 11:44 schrieb Marek Szyprowski:
Quoted 15 lines
Dear all,
This is the initial proposal for extending DRM API with generic support for hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal I named such hardware modules a framebuffer processors.Embedded SoCs are known to have a number of hardware blocks, which perform such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to target window size.
Quoted 5 lines
Till now there was no generic, hardware independent API for performing such operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.
Quoted 8 lines
Well there are good reasons why we don't have hardware independent command submission.
We already tried approaches like this and they didn't worked very well and are generally a pain to get right.
So my feeling goes into the direction of a NAK, especially since you didn't explained in this mail why there is need for a common API.
We've had an earlier RFC thread, and I made it clear there already that this will face a steep uphill battle. I don't really see any explanation here why this is not an exact copy of the ideas we've shown to not work 10+ years ago, hence I concur on this NACK.
Make this a driver private thing, operating on gem objects (and yes that means you get to reinvent the metdata, which is imo a good thing since it avoids encumbering kms with this blitter use-case). And then that interface proves indeed useful for multiple blitter IP blocks we can use it for that in generic fashion. And if it shows up in different display/render/gpu blocks we can reuse the driver using dma-buf/prime sharing. So there's really downside, except that your ioctl won't be blessed as official in any way, which imo is a Good Thing.
Or this all turns out as a mistake (which I expect it to be) and we can quitely burry it again since it's just a little driver.
Trying to push this will lead to 1+ years of frustration and most likely still not succeed.
-Daniel
Quoted 90 lines
Regards,
Christian.Quoted 78 lines
However, the need for commmon API has been already mentioned on the mailing list. Here are some example threads:
1. "RFC: hardware accelerated bitblt using dma engine"
http://www.spinics.net/lists/dri-devel/msg114250.html
2. "[PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem"
https://lists.freedesktop.org/archives/dri-devel/2015-November/094115.html
https://lists.freedesktop.org/archives/dri-devel/2015-November/094533.htmlThe proposed API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.The proposed API consists of the 3 new ioctls:
-DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
-DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
-DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example blending).
Please note that this API is intended to be used for simple memory-to-memory image processing hardware not the full-blown GPU blitters, which usually have more features. Typically blitters provides much more operations beside simple pixel copying and operate best if its command queue is controlled from respective dedicated code in userspace.
The patchset consist of 4 parts:
1. generic code for DRM core for handling fbproc objects and ioctls
2. example, quick conversion of Exynos Rotator driver to fbproc API
3. libdrm extensions for handling fbproc objects
4. simple example of userspace code for performing 180 degree rotation of the framebufferPatches were tested on Exynos 4412-based Odroid U3 board, on top of Linux v4.8-rc1 kernel.
TODO:
1. agree on the API shape
2. add more documentation, especially to the kernel docs
3. add more userspace examplesBest regards
Marek Szyprowski
Samsung R&D Institute PolandMarek Szyprowski (2):
drm: add support for framebuffer processor objects drm/exynos: register rotator as fbproc instead of custom ipp frameworkdrivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++------ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 - include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 15 files changed, 1263 insertions(+), 183 deletions(-)Quoted 3 lines
create mode 100644
drivers/gpu/drm/drm_fbproc.cdelete mode 100644drivers/gpu/drm/exynos/exynos_drm_rotator.h_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 29 lines · Christian König
Am 22.08.2016 um 11:44 schrieb Marek Szyprowski:
Quoted 19 lines
Dear all,
This is the initial proposal for extending DRM API with generic support for
hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal
I named such hardware modules a framebuffer processors.Embedded SoCs are known to have a number of hardware blocks, which perform such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to
target window size.Quoted 7 lines
Till now there was no generic, hardware independent API for performing such
operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not
really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.
Quoted 8 lines
Well there are good reasons why we don't have hardware independent command submission.
We already tried approaches like this and they didn't worked very well and are generally a pain to get right.
So my feeling goes into the direction of a NAK, especially since you didn't explained in this mail why there is need for a common API.
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
But either way, if userspace needs/wants a generic 2d blitter API, it is probably best to start out with defining a common userspace level API. That gets you a lot more flexibility to throw it away and start again once you realize you've painted yourself into a corner. And it is something that could be implemented on top of real gpu's in addition to things that look more like a mem2mem crtc.
Given the length of time kernel uapi must be supported, vs how fast hw evolves, I'm leaning towards NAK as well.
BR,
-R
Quoted 94 lines
Regards,
Christian.Quoted 86 lines
However, the need for commmon API has been already mentioned on the mailing
list. Here are some example threads:
1. "RFC: hardware accelerated bitblt using dma engine"
http://www.spinics.net/lists/dri-devel/msg114250.html
2. "[PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem"
https://lists.freedesktop.org/archives/dri-devel/2015-November/094115.html
https://lists.freedesktop.org/archives/dri-devel/2015-November/094533.htmlThe proposed API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.The proposed API consists of the 3 new ioctls:
-DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
-DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
-DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example
blending).Please note that this API is intended to be used for simple memory-to-memory
image processing hardware not the full-blown GPU blitters, which usually have more features. Typically blitters provides much more operations beside
simple pixel copying and operate best if its command queue is controlled from
respective dedicated code in userspace.The patchset consist of 4 parts:
1. generic code for DRM core for handling fbproc objects and ioctls
2. example, quick conversion of Exynos Rotator driver to fbproc API
3. libdrm extensions for handling fbproc objects
4. simple example of userspace code for performing 180 degree rotation of the
framebufferPatches were tested on Exynos 4412-based Odroid U3 board, on top of Linux v4.8-rc1 kernel.
TODO:
1. agree on the API shape
2. add more documentation, especially to the kernel docs
3. add more userspace examplesBest regards
Marek Szyprowski
Samsung R&D Institute PolandMarek Szyprowski (2):
drm: add support for framebuffer processor objects drm/exynos: register rotator as fbproc instead of custom ipp frameworkdrivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++------ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 - include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 15 files changed, 1263 insertions(+), 183 deletions(-)Quoted 3 lines
create mode 100644
drivers/gpu/drm/drm_fbproc.cdelete mode 100644drivers/gpu/drm/exynos/exynos_drm_rotator.h
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
In STM SoC we have hardware block doing scaling/colorspace conversion, we have decide to use v4l2 mem2mem API for it:
https://linuxtv.org/downloads/v4l-dvb-apis/selection-api.html
the code is here:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/media/platform/sti/bdisp?id=refs/tags/v4.8-rc3
Regards,
Benjamin
2016-08-22 17:23 GMT+02:00 Rob Clark <[email protected]>:
Quoted 160 lines
Quoted 29 lines · Christian König
Am 22.08.2016 um 11:44 schrieb Marek Szyprowski:
Quoted 19 lines
Dear all,
This is the initial proposal for extending DRM API with generic support for
hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal
I named such hardware modules a framebuffer processors.Embedded SoCs are known to have a number of hardware blocks, which perform such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to
target window size.Quoted 7 lines
Till now there was no generic, hardware independent API for performing such
operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not
really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.Quoted 8 lines
Well there are good reasons why we don't have hardware independent command submission.
We already tried approaches like this and they didn't worked very well and are generally a pain to get right.
So my feeling goes into the direction of a NAK, especially since you didn't explained in this mail why there is need for a common API.
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
But either way, if userspace needs/wants a generic 2d blitter API, it is probably best to start out with defining a common userspace level API. That gets you a lot more flexibility to throw it away and start again once you realize you've painted yourself into a corner. And it is something that could be implemented on top of real gpu's in addition to things that look more like a mem2mem crtc.
Given the length of time kernel uapi must be supported, vs how fast hw evolves, I'm leaning towards NAK as well.
BR,
-RQuoted 94 lines
Regards,
Christian.Quoted 86 lines
However, the need for commmon API has been already mentioned on the mailing
list. Here are some example threads:
1. "RFC: hardware accelerated bitblt using dma engine"
http://www.spinics.net/lists/dri-devel/msg114250.html
2. "[PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem"
https://lists.freedesktop.org/archives/dri-devel/2015-November/094115.html
https://lists.freedesktop.org/archives/dri-devel/2015-November/094533.htmlThe proposed API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.The proposed API consists of the 3 new ioctls:
-DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
-DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
-DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example
blending).Please note that this API is intended to be used for simple memory-to-memory
image processing hardware not the full-blown GPU blitters, which usually have more features. Typically blitters provides much more operations beside
simple pixel copying and operate best if its command queue is controlled from
respective dedicated code in userspace.The patchset consist of 4 parts:
1. generic code for DRM core for handling fbproc objects and ioctls
2. example, quick conversion of Exynos Rotator driver to fbproc API
3. libdrm extensions for handling fbproc objects
4. simple example of userspace code for performing 180 degree rotation of the
framebufferPatches were tested on Exynos 4412-based Odroid U3 board, on top of Linux v4.8-rc1 kernel.
TODO:
1. agree on the API shape
2. add more documentation, especially to the kernel docs
3. add more userspace examplesBest regards
Marek Szyprowski
Samsung R&D Institute PolandMarek Szyprowski (2):
drm: add support for framebuffer processor objects drm/exynos: register rotator as fbproc instead of custom ipp frameworkdrivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++------ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 - include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 15 files changed, 1263 insertions(+), 183 deletions(-)Quoted 3 lines
create mode 100644
drivers/gpu/drm/drm_fbproc.cdelete mode 100644drivers/gpu/drm/exynos/exynos_drm_rotator.hQuoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Benjamin Gaignard Graphic Study Group Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Hi,
Quoted 3 lines · Rob Clark
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
Regardless of whether or not we want it, we already _have_ it, in the form of V4L2 M2M. There are already a few IP blocks working on that, I believe. If V4L2 <-> KMS interop is painful, well, we need to fix that anyway ...
Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Inki Dae
maintainerHi,
2016년 08월 23일 18:41에 Daniel Stone 이(가) 쓴 글:
Quoted 11 lines
Hi,
Quoted 3 lines · Rob Clark
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
Regardless of whether or not we want it, we already _have_ it, in the form of V4L2 M2M. There are already a few IP blocks working on that, I believe. If V4L2 <-> KMS interop is painful, well, we need to fix that anyway ...
So we are trying this. We had expereneced using V4L2 and DRM together on Linux Platform makes it too complicated, and also integrated DRM with M2M such as 2D and Post processor makes it simplified.
So We have been trying to move existing V4L2 based drivers into DRM excepting HW Video Codec - called it MFC - and Camera sensor and relevant things.
I think now V4L2 and DRM frameworks may make many engineers confusing because there are the same devices which can be controlled by V4L2 and DRM frameworks - maybe we would need more efforts like Laurent did with Live source[1] in the future.
Anyway, sad to say, it seems other maintainers leave NAK for this patch series because this trying had failed already long time ago - they had learned such thing didn't work well. So seems we have to keep this in only Exynos DRM.
[1] https://lwn.net/Articles/640290/
Thanks,
Inki Dae
Quoted 10 lines
Cheers,
Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 15 lines · Inki Dae
Hi,
2016년 08월 23일 18:41에 Daniel Stone 이(가) 쓴 글:
Quoted 11 lines
Hi,
Quoted 3 lines · Rob Clark
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
Regardless of whether or not we want it, we already _have_ it, in the form of V4L2 M2M. There are already a few IP blocks working on that, I believe. If V4L2 <-> KMS interop is painful, well, we need to fix that anyway ...
Quoted 9 lines
So we are trying this. We had expereneced using V4L2 and DRM together on Linux Platform makes it too complicated, and also integrated DRM with M2M such as 2D and Post processor makes it simplified. So We have been trying to move existing V4L2 based drivers into DRM excepting HW Video Codec - called it MFC - and Camera sensor and relevant things. I think now V4L2 and DRM frameworks may make many engineers confusing because there are the same devices which can be controlled by V4L2 and DRM frameworks - maybe we would need more efforts like Laurent did with Live source[1] in the future.
Can you pls explain in more detail where working with both v4l and drm drivers and making them cooperate using dma-bufs poses problems? We should definitely fix that.
-Daniel
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
Inki Dae
maintainer2016년 08월 24일 20:57에 Daniel Vetter 이(가) 쓴 글:
Quoted 26 lines · Inki Dae
Quoted 15 lines
Hi,
2016년 08월 23일 18:41에 Daniel Stone 이(가) 쓴 글:
Quoted 11 lines
Hi,
Quoted 3 lines · Rob Clark
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
Regardless of whether or not we want it, we already _have_ it, in the form of V4L2 M2M. There are already a few IP blocks working on that, I believe. If V4L2 <-> KMS interop is painful, well, we need to fix that anyway ...
Quoted 9 lines
So we are trying this. We had expereneced using V4L2 and DRM together on Linux Platform makes it too complicated, and also integrated DRM with M2M such as 2D and Post processor makes it simplified. So We have been trying to move existing V4L2 based drivers into DRM excepting HW Video Codec - called it MFC - and Camera sensor and relevant things. I think now V4L2 and DRM frameworks may make many engineers confusing because there are the same devices which can be controlled by V4L2 and DRM frameworks - maybe we would need more efforts like Laurent did with Live source[1] in the future.
Quoted 3 lines
Can you pls explain in more detail where working with both v4l and drm drivers and making them cooperate using dma-bufs poses problems? We should definitely fix that.
I think it would be most Linux Platforms - Android, Chrome and Tizen - which would use OpenMAX/GStreammer for Multimedia and X or Wayland/SurfaceFlinger for Display.
Thanks,
Inki Dae
Quoted 2 lines
-Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 29 lines · Inki Dae
2016년 08월 24일 20:57에 Daniel Vetter 이(가) 쓴 글:
Quoted 26 lines · Inki Dae
Quoted 24 lines
Hi,
2016년 08월 23일 18:41에 Daniel Stone 이(가) 쓴 글:
Quoted 11 lines
Hi,
Quoted 3 lines · Rob Clark
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
Regardless of whether or not we want it, we already _have_ it, in the form of V4L2 M2M. There are already a few IP blocks working on that, I believe. If V4L2 <-> KMS interop is painful, well, we need to fix that anyway ...
So we are trying this. We had expereneced using V4L2 and DRM together on Linux Platform makes it too complicated, and also integrated DRM with M2M such as 2D and Post processor makes it simplified. So We have been trying to move existing V4L2 based drivers into DRM excepting HW Video Codec - called it MFC - and Camera sensor and relevant things. I think now V4L2 and DRM frameworks may make many engineers confusing because there are the same devices which can be controlled by V4L2 and DRM frameworks - maybe we would need more efforts like Laurent did with Live source[1] in the future.
Quoted 7 lines
Quoted 3 lines
Can you pls explain in more detail where working with both v4l and drm drivers and making them cooperate using dma-bufs poses problems? We should definitely fix that.
I think it would be most Linux Platforms - Android, Chrome and Tizen - which would use OpenMAX/GStreammer for Multimedia and X or Wayland/SurfaceFlinger for Display.
Yes, that's the use case. Where is the problem in making this happen? v4l can import dma-bufs, drm can export them, and there's plenty devices shipping (afaik) that make use of exact this pipeline. Can you pls explain what problem you've hit trying to make this work on exynos? -Daniel
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
Inki Dae
maintainer2016년 08월 25일 17:42에 Daniel Vetter 이(가) 쓴 글:
Quoted 34 lines · Inki Dae
Quoted 33 lines
2016년 08월 24일 20:57에 Daniel Vetter 이(가) 쓴 글:
Quoted 29 lines · Inki Dae
Quoted 15 lines
Hi,
2016년 08월 23일 18:41에 Daniel Stone 이(가) 쓴 글:
Quoted 11 lines
Hi,
Quoted 3 lines · Rob Clark
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
Regardless of whether or not we want it, we already _have_ it, in the form of V4L2 M2M. There are already a few IP blocks working on that, I believe. If V4L2 <-> KMS interop is painful, well, we need to fix that anyway ...
Quoted 9 lines
So we are trying this. We had expereneced using V4L2 and DRM together on Linux Platform makes it too complicated, and also integrated DRM with M2M such as 2D and Post processor makes it simplified. So We have been trying to move existing V4L2 based drivers into DRM excepting HW Video Codec - called it MFC - and Camera sensor and relevant things. I think now V4L2 and DRM frameworks may make many engineers confusing because there are the same devices which can be controlled by V4L2 and DRM frameworks - maybe we would need more efforts like Laurent did with Live source[1] in the future.
Can you pls explain in more detail where working with both v4l and drm drivers and making them cooperate using dma-bufs poses problems? We should definitely fix that.
Quoted 8 lines
Quoted 3 lines
I think it would be most Linux Platforms - Android, Chrome and Tizen - which would use OpenMAX/GStreammer for Multimedia and X or Wayland/SurfaceFlinger for Display.
Yes, that's the use case. Where is the problem in making this happen? v4l can import dma-bufs, drm can export them, and there's plenty devices shipping (afaik) that make use of exact this pipeline. Can you pls explain what problem you've hit trying to make this work on exynos?
No problem but just make it complicated as I mentioned above - the stream operations - S_FMT, REQBUF, QUARYBUF, QBUF, STREAM ON and DQBUF of V4L2 would never be simple as DRM.
Do you think M2M device should be controlled by V4L2 interfaces? and even 2D accelerator? As long as I know, The Graphics card on Desktop has all devices such as 2D/3D GPU, HW Video codec and Display controller, and these devices are controlled by DRM interfaces. So we - ARM Exynos - are trying to move these things to DRM world and also trying to implement more convenient interfaces like Marek did.
Thanks,
Inki Dae
Quoted 2 lines
-Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 46 lines · Inki Dae
2016년 08월 25일 17:42에 Daniel Vetter 이(가) 쓴 글:
Quoted 34 lines · Inki Dae
Quoted 33 lines
2016년 08월 24일 20:57에 Daniel Vetter 이(가) 쓴 글:
Quoted 29 lines · Inki Dae
Quoted 15 lines
Hi,
2016년 08월 23일 18:41에 Daniel Stone 이(가) 쓴 글:
Quoted 11 lines
Hi,
Quoted 3 lines · Rob Clark
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
Regardless of whether or not we want it, we already _have_ it, in the form of V4L2 M2M. There are already a few IP blocks working on that, I believe. If V4L2 <-> KMS interop is painful, well, we need to fix that anyway ...
Quoted 9 lines
So we are trying this. We had expereneced using V4L2 and DRM together on Linux Platform makes it too complicated, and also integrated DRM with M2M such as 2D and Post processor makes it simplified. So We have been trying to move existing V4L2 based drivers into DRM excepting HW Video Codec - called it MFC - and Camera sensor and relevant things. I think now V4L2 and DRM frameworks may make many engineers confusing because there are the same devices which can be controlled by V4L2 and DRM frameworks - maybe we would need more efforts like Laurent did with Live source[1] in the future.
Can you pls explain in more detail where working with both v4l and drm drivers and making them cooperate using dma-bufs poses problems? We should definitely fix that.
Quoted 8 lines
Quoted 3 lines
I think it would be most Linux Platforms - Android, Chrome and Tizen - which would use OpenMAX/GStreammer for Multimedia and X or Wayland/SurfaceFlinger for Display.
Yes, that's the use case. Where is the problem in making this happen? v4l can import dma-bufs, drm can export them, and there's plenty devices shipping (afaik) that make use of exact this pipeline. Can you pls explain what problem you've hit trying to make this work on exynos?
Quoted 9 lines
No problem but just make it complicated as I mentioned above - the stream operations -
S_FMT, REQBUF, QUARYBUF, QBUF, STREAM ON and DQBUF of V4L2 would never be simple as DRM. Do you think M2M device should be controlled by V4L2 interfaces? and even 2D accelerator? As long as I know, The Graphics card on Desktop has all devices such as 2D/3D GPU, HW Video codec and Display controller, and these devices are controlled by DRM interfaces. So we - ARM Exynos - are trying to move these things to DRM world and also trying to implement more convenient interfaces like Marek did.
This is a misconception, there's nothing in the drm world requiring that everything is under the same drm device. All the work we've done over the past years (dma-buf, reservations, fence, prime, changes in X.org and wayland) are _all_ to make it possible to have a gfx device consisting of multiple drm/v4l/whatever else nodes. Especially for a SoC moving back to fake-integrating stuff really isn't a good idea I think.
And wrt drm being simpler than v4l - I don't think drm is any simpler, at elast if you look at some of the more feature-full render drivers. -Daniel
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
Inki Dae
maintainer2016년 08월 25일 21:14에 Daniel Vetter 이(가) 쓴 글:
Quoted 57 lines · Inki Dae
Quoted 46 lines
2016년 08월 25일 17:42에 Daniel Vetter 이(가) 쓴 글:
Quoted 34 lines · Inki Dae
Quoted 33 lines
2016년 08월 24일 20:57에 Daniel Vetter 이(가) 쓴 글:
Quoted 29 lines · Inki Dae
Quoted 15 lines
Hi,
2016년 08월 23일 18:41에 Daniel Stone 이(가) 쓴 글:
Quoted 11 lines
Hi,
Quoted 3 lines · Rob Clark
I guess a lot comes down to 'how long before hw designers bolt a CP to the thing'.. at that point, I think you especially don't want a per-blit kernel interface.
Regardless of whether or not we want it, we already _have_ it, in the form of V4L2 M2M. There are already a few IP blocks working on that, I believe. If V4L2 <-> KMS interop is painful, well, we need to fix that anyway ...
Quoted 9 lines
So we are trying this. We had expereneced using V4L2 and DRM together on Linux Platform makes it too complicated, and also integrated DRM with M2M such as 2D and Post processor makes it simplified. So We have been trying to move existing V4L2 based drivers into DRM excepting HW Video Codec - called it MFC - and Camera sensor and relevant things. I think now V4L2 and DRM frameworks may make many engineers confusing because there are the same devices which can be controlled by V4L2 and DRM frameworks - maybe we would need more efforts like Laurent did with Live source[1] in the future.
Can you pls explain in more detail where working with both v4l and drm drivers and making them cooperate using dma-bufs poses problems? We should definitely fix that.
Quoted 8 lines
Quoted 3 lines
I think it would be most Linux Platforms - Android, Chrome and Tizen - which would use OpenMAX/GStreammer for Multimedia and X or Wayland/SurfaceFlinger for Display.
Yes, that's the use case. Where is the problem in making this happen? v4l can import dma-bufs, drm can export them, and there's plenty devices shipping (afaik) that make use of exact this pipeline. Can you pls explain what problem you've hit trying to make this work on exynos?
Quoted 9 lines
No problem but just make it complicated as I mentioned above - the stream operations -
S_FMT, REQBUF, QUARYBUF, QBUF, STREAM ON and DQBUF of V4L2 would never be simple as DRM. Do you think M2M device should be controlled by V4L2 interfaces? and even 2D accelerator? As long as I know, The Graphics card on Desktop has all devices such as 2D/3D GPU, HW Video codec and Display controller, and these devices are controlled by DRM interfaces. So we - ARM Exynos - are trying to move these things to DRM world and also trying to implement more convenient interfaces like Marek did.
Quoted 6 lines
This is a misconception, there's nothing in the drm world requiring that everything is under the same drm device. All the work we've done over the past years (dma-buf, reservations, fence, prime, changes in X.org and wayland) are _all_ to make it possible to have a gfx device consisting of multiple drm/v4l/whatever else nodes. Especially for a SoC moving back to fake-integrating stuff really isn't a good idea I think.
Yes, not all devices. As I mentioned already - excepting HW Video codec and Camera device, we have changed a post processor driver to DRM instead of V4L2 and now we are trying to standard the post processsor interfaces. I know that the Display controllers of several SoC include Post processing function which makes image to be scaled up, down or rotated and pixel format of the image to be converted to other pixel format, and these device are controlled by DRM.
Do you think these post processor devices should be controlled by V4L2?
Thanks,
Inki Dae
Quoted 5 lines
And wrt drm being simpler than v4l - I don't think drm is any simpler, at elast if you look at some of the more feature-full render drivers. -Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hey Marek,
I had a quick look at the series and I really like the new approach.
I was wondering about the following though. If I understand this correctly I can only perform m2m operations on buffers which are registered as framebuffers. Is this possible to weaken that requirements such that arbitrary GEM objects can be used as input and output?
Anyway, great work!
With best wishes,
Tobias
Quoted 101 lines · Marek Szyprowski
Dear all,
This is the initial proposal for extending DRM API with generic support for hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal I named such hardware modules a framebuffer processors.Embedded SoCs are known to have a number of hardware blocks, which perform such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to target window size.
Till now there was no generic, hardware independent API for performing such operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.
However, the need for commmon API has been already mentioned on the mailing list. Here are some example threads:
1. "RFC: hardware accelerated bitblt using dma engine"
http://www.spinics.net/lists/dri-devel/msg114250.html
2. "[PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem"
https://lists.freedesktop.org/archives/dri-devel/2015-November/094115.html
https://lists.freedesktop.org/archives/dri-devel/2015-November/094533.htmlThe proposed API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.The proposed API consists of the 3 new ioctls:
-DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
-DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
-DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example blending).
Please note that this API is intended to be used for simple memory-to-memory image processing hardware not the full-blown GPU blitters, which usually have more features. Typically blitters provides much more operations beside simple pixel copying and operate best if its command queue is controlled from respective dedicated code in userspace.
The patchset consist of 4 parts:
1. generic code for DRM core for handling fbproc objects and ioctls
2. example, quick conversion of Exynos Rotator driver to fbproc API
3. libdrm extensions for handling fbproc objects
4. simple example of userspace code for performing 180 degree rotation of the framebufferPatches were tested on Exynos 4412-based Odroid U3 board, on top of Linux v4.8-rc1 kernel.
TODO:
1. agree on the API shape
2. add more documentation, especially to the kernel docs
3. add more userspace examplesBest regards
Marek Szyprowski
Samsung R&D Institute PolandMarek Szyprowski (2):
drm: add support for framebuffer processor objects drm/exynos: register rotator as fbproc instead of custom ipp frameworkdrivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++------ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 - include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 15 files changed, 1263 insertions(+), 183 deletions(-) create mode 100644 drivers/gpu/drm/drm_fbproc.c delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
Dear Tobias
Quoted 8 lines · Tobias Jakobi
Hey Marek,
I had a quick look at the series and I really like the new approach.
I was wondering about the following though. If I understand this correctly I can only perform m2m operations on buffers which are registered as framebuffers. Is this possible to weaken that requirements such that arbitrary GEM objects can be used as input and output?
Thanks for you comment.
I'm open for discussion if the API should be based on framebuffers or GEM objects.
Initially I thought that GEM objects would be enough, but later I noticed that in such case user would need to provide at least width, height, stride, start offset and pixel format - all parameters that are already used to create framebuffer object. Operating on GEM buffers will also make support for images composed from multiple buffers (like separate GEM objects for luma/chroma parts in case of planar formats) a bit harder. Same about already introduced API for fb-modifiers. I just don't want to duplicate all of it in fbproc API.
Operating on framebuffer objects also helps to reduce errors in userspace. One can already queue the result of processing to the display hardware and this way avoid common issues related to debugging why the processed image is not displayed correctly due to incorrectly defined pitch/fourcc/start offset/etc. This is however not really a strong advantage of framebuffers.
Quoted 111 lines
Anyway, great work!
With best wishes,
TobiasQuoted 101 lines · Marek Szyprowski
Dear all,
This is the initial proposal for extending DRM API with generic support for hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal I named such hardware modules a framebuffer processors.Embedded SoCs are known to have a number of hardware blocks, which perform such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to target window size.
Till now there was no generic, hardware independent API for performing such operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.
However, the need for commmon API has been already mentioned on the mailing list. Here are some example threads:
1. "RFC: hardware accelerated bitblt using dma engine"
http://www.spinics.net/lists/dri-devel/msg114250.html
2. "[PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem"
https://lists.freedesktop.org/archives/dri-devel/2015-November/094115.html
https://lists.freedesktop.org/archives/dri-devel/2015-November/094533.htmlThe proposed API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects have a set of standard DRM properties, which describes the operation to be performed by respective hardware module. In typical case those properties are a source fb id and rectangle (x, y, width, height) and destination fb id and rectangle. Optionally a rotation property can be also specified if supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.The proposed API consists of the 3 new ioctls:
-DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
-DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
-DRM_IOCTL_MODE_FBPROC: to perform operation described by given property set.The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example blending).
Please note that this API is intended to be used for simple memory-to-memory image processing hardware not the full-blown GPU blitters, which usually have more features. Typically blitters provides much more operations beside simple pixel copying and operate best if its command queue is controlled from respective dedicated code in userspace.
The patchset consist of 4 parts:
1. generic code for DRM core for handling fbproc objects and ioctls
2. example, quick conversion of Exynos Rotator driver to fbproc API
3. libdrm extensions for handling fbproc objects
4. simple example of userspace code for performing 180 degree rotation of the framebufferPatches were tested on Exynos 4412-based Odroid U3 board, on top of Linux v4.8-rc1 kernel.
TODO:
1. agree on the API shape
2. add more documentation, especially to the kernel docs
3. add more userspace examplesBest regards
Marek Szyprowski
Samsung R&D Institute PolandMarek Szyprowski (2):
drm: add support for framebuffer processor objects drm/exynos: register rotator as fbproc instead of custom ipp frameworkdrivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++------ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 - include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 15 files changed, 1263 insertions(+), 183 deletions(-)create mode 100644
drivers/gpu/drm/drm_fbproc.cdelete mode 100644drivers/gpu/drm/exynos/exynos_drm_rotator.h
Best regards
Signature · 7 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hello Marek,
Quoted 18 lines · Marek Szyprowski
Dear Tobias
Quoted 8 lines · Tobias Jakobi
Hey Marek,
I had a quick look at the series and I really like the new approach.
I was wondering about the following though. If I understand this correctly I can only perform m2m operations on buffers which are registered as framebuffers. Is this possible to weaken that requirements such that arbitrary GEM objects can be used as input and output?
Thanks for you comment.
I'm open for discussion if the API should be based on framebuffers or GEM objects.
Quoted 8 lines
Initially I thought that GEM objects would be enough, but later I noticed that in such case user would need to provide at least width, height, stride, start offset and pixel format - all parameters that are already used to create framebuffer object. Operating on GEM buffers will also make support for images composed from multiple buffers (like separate GEM objects for luma/chroma parts in case of planar formats) a bit harder. Same about already introduced API for fb-modifiers. I just don't want to duplicate all of it in fbproc API.
yes, that makes perfectly sense. Passing the buffer parameters (geometry, pixel format, etc.) each time is probably not a good (and efficient) idea.
I'm still wondering if there can't arise a situation where I simply can't register a buffer as framebuffer.
I'm specifically looking at internal_framebuffer_create() and the driver specific fb_create(). Now internal_framebuffer_create() itself only does some minimal checking, but e.g. it does check against certain minimum/maximum geometry parameters. How do we know that these parameters match the ones for the block that performs the m2m operations?
I could image that a block could perform scaling operations on buffers with a much larger geometry than the core allows to bind as framebuffers. So if I have such a buffer with large geometry I might want to scale it down, so that I can display it. But that's not possible since I can't even bind the src as fb.
Does that make sense?
With best wishes,
Tobias
Quoted 146 lines
Operating on framebuffer objects also helps to reduce errors in userspace. One can already queue the result of processing to the display hardware and this way avoid common issues related to debugging why the processed image is not displayed correctly due to incorrectly defined pitch/fourcc/start offset/etc. This is however not really a strong advantage of framebuffers.
Quoted 137 lines
Anyway, great work!
With best wishes,
TobiasQuoted 127 lines · Marek Szyprowski
Dear all,
This is the initial proposal for extending DRM API with generic support for
hardware modules, which can be used for processing image data from the one
memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal
I named such hardware modules a framebuffer processors.Embedded SoCs are known to have a number of hardware blocks, which perform
such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to
target window size.Till now there was no generic, hardware independent API for performing such
operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not
really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.However, the need for commmon API has been already mentioned on the mailing
list. Here are some example threads:
1. "RFC: hardware accelerated bitblt using dma engine"
http://www.spinics.net/lists/dri-devel/msg114250.html
2. "[PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem"
https://lists.freedesktop.org/archives/dri-devel/2015-November/094115.htmlhttps://lists.freedesktop.org/archives/dri-devel/2015-November/094533.html
The proposed API is heavily inspired by atomic KMS approach - it is also based on DRM objects and their properties. A new DRM object is introduced:
framebuffer processor (called fbproc for convenience). Such fbproc objects
have a set of standard DRM properties, which describes the operation to be
performed by respective hardware module. In typical case those properties
are a source fb id and rectangle (x, y, width, height) and destination fb
id and rectangle. Optionally a rotation property can be also specified if
supported by the given hardware. To perform an operation on image data, userspace provides a set of properties and their values for given fbproc object in a similar way as object and properties are provided for performing atomic page flip / mode setting.The proposed API consists of the 3 new ioctls:
-DRM_IOCTL_MODE_GETFBPROCRESOURCES: to enumerate all available fbproc objects,
-DRM_IOCTL_MODE_GETFBPROC: to query capabilities of given fbproc object,
-DRM_IOCTL_MODE_FBPROC: to perform operation described by given property
set.The proposed API is extensible. Drivers can attach their own, custom properties to add support for more advanced picture processing (for example
blending).Please note that this API is intended to be used for simple memory-to-memory
image processing hardware not the full-blown GPU blitters, which usually have more features. Typically blitters provides much more operations beside
simple pixel copying and operate best if its command queue is controlled from
respective dedicated code in userspace.The patchset consist of 4 parts:
1. generic code for DRM core for handling fbproc objects and ioctls
2. example, quick conversion of Exynos Rotator driver to fbproc API
3. libdrm extensions for handling fbproc objects
4. simple example of userspace code for performing 180 degree rotation of the
framebufferPatches were tested on Exynos 4412-based Odroid U3 board, on top of Linux v4.8-rc1 kernel.
TODO:
1. agree on the API shape
2. add more documentation, especially to the kernel docs
3. add more userspace examplesBest regards
Marek Szyprowski
Samsung R&D Institute PolandMarek Szyprowski (2):
drm: add support for framebuffer processor objects drm/exynos: register rotator as fbproc instead of custom ipp
frameworkdrivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_atomic.c | 5 + drivers/gpu/drm/drm_crtc.c | 6 + drivers/gpu/drm/drm_crtc_internal.h | 12 + drivers/gpu/drm/drm_fbproc.c | 754 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 3 + drivers/gpu/drm/exynos/Kconfig | 1 - drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 353 +++++++------ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 19 - include/drm/drmP.h | 10 + include/drm/drm_crtc.h | 211 ++++++++ include/drm/drm_irq.h | 14 + include/uapi/drm/drm.h | 13 + include/uapi/drm/drm_mode.h | 39 ++ 15 files changed, 1263 insertions(+), 183 deletions(-)create mode 100644
drivers/gpu/drm/drm_fbproc.cdelete mode 100644drivers/gpu/drm/exynos/exynos_drm_rotator.h
Quoted 1 line
Best regards
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerQuoted 15 lines · Marek Szyprowski
Dear all,
This is the initial proposal for extending DRM API with generic support for hardware modules, which can be used for processing image data from the one memory buffer to another. Typical memory-to-memory operations are:
rotation, scaling, colour space conversion or mix of them. In this proposal I named such hardware modules a framebuffer processors.Embedded SoCs are known to have a number of hardware blocks, which perform such operations. They can be used in paralel to the main GPU module to offload CPU from processing grapics or video data. One of example use of such modules is implementing video overlay, which usually requires color space conversion from NV12 (or similar) to RGB32 color space and scaling to target window size.
Quoted 5 lines
Till now there was no generic, hardware independent API for performing such operations. Exynos DRM driver has its own custom extension called IPP (Image Post Processing), but frankly speaking, it is over-engineered and not really used in open-source. I didn't indentify similar API in other DRM drivers, besides those which expose complete support for the whole GPU.
So I'm with the others in that it's a road we've travelled and learned from, generic accel API don't work very well long term.
What will happen is the next generation exynos will have a command queue for it's dma engine or whatever and someone will shoehorn that into this API because this API exists, even if it isn't suitable.
What are the requirements for having this API, what userspace feature is driving it, compositors?, toolkit rendering?
Dave.