[Mesa-dev] [PATCH 3/3] gbm: Add new flags to enable creation of rotated scanout buffers (v5)

Vivek Kasireddy vivek.kasireddy at intel.com
Fri Nov 20 19:38:04 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)

v4: Added a brief comment to explain the rotation orientation.

v5: Corrected a typo in the comment added in v4.

Cc: Michel Danzer <michel at daenzer.net>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
---
 src/gbm/backends/dri/gbm_dri.c | 10 ++++++++--
 src/gbm/main/gbm.h             | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 88e5c5e..6616d37 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -129,6 +129,12 @@ gbm_to_dri_flag(uint32_t usage,
 {
    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;
    if (usage & GBM_BO_USE_CURSOR)
       *dri_use |= __DRI_IMAGE_USE_CURSOR;
    if (usage & GBM_BO_USE_LINEAR)
@@ -551,7 +557,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:
@@ -796,7 +802,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;
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index 8db2153..e99d96d 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -214,8 +214,23 @@ 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.
+    * And, setting a rotation angle of 90 or 270 would result in the
+    * scanout buffer being rotated in a counter clockwise manner. This
+    * is the expected behavior for ensuring XRandR compliance.
+    */
+   GBM_BO_USE_SCANOUT_ROTATION_90 = (1 << 5),
+   GBM_BO_USE_SCANOUT_ROTATION_180 = (1 << 6),
+   GBM_BO_USE_SCANOUT_ROTATION_270 = (1 << 7),
 };
 
+#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_270)
+
 int
 gbm_device_get_fd(struct gbm_device *gbm);
 
-- 
2.4.3



More information about the mesa-dev mailing list