[Mesa-dev] [PATCH 2/2] gbm: Add flags to enable creation of rotated scanout buffers (v3)
Vivek Kasireddy
vivek.kasireddy at intel.com
Thu Nov 5 19:08:23 PST 2015
For certain platforms that support rotated scanout buffers, currently,
there is no way to create them with the GBM DRI interface. These flags
will instruct the DRI driver to create the buffer by setting
additional requirements such as tiling mode.
v2: Reserve a bit per angle. (Ville and Michel)
v3:
- Combine all GBM_BO_USE_SCANOUT_ROTATION_* flags into
GBM_BO_USE_SCANOUT_ANY macro (Michel)
- Pull the code that updates dri_use based on the rotation flag
into a separate function.
Cc: Michel Danzer <michel at daenzer.net>
Cc: Ville Syrjala <ville.syrjala at linux.intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
---
src/gbm/backends/dri/gbm_dri.c | 26 ++++++++++++++++++++------
src/gbm/main/gbm.h | 11 +++++++++++
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 57cdeac..741e509 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -124,6 +124,20 @@ image_get_buffers(__DRIdrawable *driDrawable,
}
static void
+gbm_to_dri_flag(uint32_t usage,
+ unsigned *dri_use)
+{
+ if (usage & GBM_BO_USE_SCANOUT)
+ *dri_use |= __DRI_IMAGE_USE_SCANOUT;
+ if (usage & GBM_BO_USE_SCANOUT_ROTATION_90)
+ *dri_use |= __DRI_IMAGE_USE_SCANOUT_ROTATION_90;
+ if (usage & GBM_BO_USE_SCANOUT_ROTATION_180)
+ *dri_use |= __DRI_IMAGE_USE_SCANOUT_ROTATION_180;
+ if (usage & GBM_BO_USE_SCANOUT_ROTATION_270)
+ *dri_use |= __DRI_IMAGE_USE_SCANOUT_ROTATION_270;
+}
+
+static void
swrast_get_drawable_info(__DRIdrawable *driDrawable,
int *x,
int *y,
@@ -539,7 +553,7 @@ gbm_dri_is_format_supported(struct gbm_device *gbm,
break;
case GBM_BO_FORMAT_ARGB8888:
case GBM_FORMAT_ARGB8888:
- if (usage & GBM_BO_USE_SCANOUT)
+ if (usage & GBM_BO_USE_SCANOUT_ANY)
return 0;
break;
default:
@@ -746,8 +760,8 @@ gbm_dri_bo_import(struct gbm_device *gbm,
bo->image = image;
- if (usage & GBM_BO_USE_SCANOUT)
- dri_use |= __DRI_IMAGE_USE_SCANOUT;
+ if (usage & GBM_BO_USE_SCANOUT_ANY)
+ gbm_to_dri_flag(usage, &dri_use);
if (usage & GBM_BO_USE_CURSOR)
dri_use |= __DRI_IMAGE_USE_CURSOR;
if (dri->image->base.version >= 2 &&
@@ -786,7 +800,7 @@ create_dumb(struct gbm_device *gbm,
is_cursor = (usage & GBM_BO_USE_CURSOR) != 0 &&
format == GBM_FORMAT_ARGB8888;
- is_scanout = (usage & GBM_BO_USE_SCANOUT) != 0 &&
+ is_scanout = (usage & GBM_BO_USE_SCANOUT_ANY) != 0 &&
format == GBM_FORMAT_XRGB8888;
if (!is_cursor && !is_scanout) {
errno = EINVAL;
@@ -878,8 +892,8 @@ gbm_dri_bo_create(struct gbm_device *gbm,
goto failed;
}
- if (usage & GBM_BO_USE_SCANOUT)
- dri_use |= __DRI_IMAGE_USE_SCANOUT;
+ if (usage & GBM_BO_USE_SCANOUT_ANY)
+ gbm_to_dri_flag(usage, &dri_use);
if (usage & GBM_BO_USE_CURSOR)
dri_use |= __DRI_IMAGE_USE_CURSOR;
if (usage & GBM_BO_USE_LINEAR)
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index 8db2153..4bda089 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -214,6 +214,13 @@ enum gbm_bo_flags {
* Buffer is linear, i.e. not tiled.
*/
GBM_BO_USE_LINEAR = (1 << 4),
+ /**
+ * Buffer would be rotated and some platforms have additional tiling
+ * requirements for rotated scanout buffers.
+ */
+ GBM_BO_USE_SCANOUT_ROTATION_90 = (1 << 5),
+ GBM_BO_USE_SCANOUT_ROTATION_180 = (1 << 6),
+ GBM_BO_USE_SCANOUT_ROTATION_270 = (1 << 7),
};
int
@@ -240,6 +247,10 @@ gbm_bo_create(struct gbm_device *gbm,
#define GBM_BO_IMPORT_WL_BUFFER 0x5501
#define GBM_BO_IMPORT_EGL_IMAGE 0x5502
#define GBM_BO_IMPORT_FD 0x5503
+#define GBM_BO_USE_SCANOUT_ANY (GBM_BO_USE_SCANOUT | \
+ GBM_BO_USE_SCANOUT_ROTATION_90 | \
+ GBM_BO_USE_SCANOUT_ROTATION_180 | \
+ GBM_BO_USE_SCANOUT_ROTATION_170)
struct gbm_import_fd_data {
int fd;
--
2.4.3
More information about the mesa-dev
mailing list