diff options
author | Ben Widawsky <[email protected]> | 2016-10-26 16:02:23 -0700 |
---|---|---|
committer | Ben Widawsky <[email protected]> | 2017-03-09 15:35:44 -0800 |
commit | 2ee34bd5dcf30f202c9f37e3d986640f71b8a210 (patch) | |
tree | 03be27dd1feb00d44578acbd5e37fc7d00ea43fe /src/gbm/main | |
parent | 7f6209e46f8de409f182931e0ca23bb64f1a8e39 (diff) |
gbm: Export a per plane getter for offset
Unlike stride, there was no previous offset getter, so it can be right
on the first try.
v2: Return EINVAL when plane is greater than total planes to make it
match the similar APIs.
Avoid leak after fromPlanar (Daniel)
Make sure when getting offsets we consider dumb images (Daniel)
v3: Use Jason's recommendation for handling the non-planar case.
v4: Return int64_t so we can get real errors
v5: Add an assertion for dumb BOs (Jason)
Signed-off-by: Ben Widawsky <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Acked-by: Daniel Stone <[email protected]>
Diffstat (limited to 'src/gbm/main')
-rw-r--r-- | src/gbm/main/gbm.c | 15 | ||||
-rw-r--r-- | src/gbm/main/gbm.h | 3 | ||||
-rw-r--r-- | src/gbm/main/gbmint.h | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c index 0a9f0bef7ee..afcca63da3a 100644 --- a/src/gbm/main/gbm.c +++ b/src/gbm/main/gbm.c @@ -194,6 +194,21 @@ gbm_bo_get_format(struct gbm_bo *bo) return bo->format; } +/** Get the offset for the data of the specified plane + * + * Extra planes, and even the first plane, may have an offset from the start of + * the buffer object. This function will provide the offset for the given plane + * to be used in various KMS APIs. + * + * \param bo The buffer object + * \return The offset + */ +GBM_EXPORT int64_t +gbm_bo_get_offset(struct gbm_bo *bo, int plane) +{ + return bo->gbm->bo_get_offset(bo, plane); +} + /** Get the gbm device used to create the buffer object * * \param bo The buffer object diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h index 1719c5312a5..e3e5d34d976 100644 --- a/src/gbm/main/gbm.h +++ b/src/gbm/main/gbm.h @@ -309,6 +309,9 @@ gbm_bo_get_stride_for_plane(struct gbm_bo *bo, int plane); uint32_t gbm_bo_get_format(struct gbm_bo *bo); +int64_t +gbm_bo_get_offset(struct gbm_bo *bo, int plane); + struct gbm_device * gbm_bo_get_device(struct gbm_bo *bo); diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h index 26d18bab6bf..a6541d91c55 100644 --- a/src/gbm/main/gbmint.h +++ b/src/gbm/main/gbmint.h @@ -79,6 +79,7 @@ struct gbm_device { int (*bo_get_planes)(struct gbm_bo *bo); union gbm_bo_handle (*bo_get_handle)(struct gbm_bo *bo, int plane); uint32_t (*bo_get_stride)(struct gbm_bo *bo, int plane); + int64_t (*bo_get_offset)(struct gbm_bo *bo, int plane); void (*bo_destroy)(struct gbm_bo *bo); struct gbm_surface *(*surface_create)(struct gbm_device *gbm, |