diff options
author | Tomasz Figa <[email protected]> | 2016-08-02 19:46:26 +0900 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2016-08-24 14:39:23 +0100 |
commit | e71b78ebf9a405f2831826de2cb2d4ebb8658262 (patch) | |
tree | 6c10b9ff1530324117e5cde5f2205917fd47e4f7 /src/gallium/winsys | |
parent | 0aa6a818ef60e01f304987fe07ac1370d68d38b1 (diff) |
gallium/winsys/kms: Fully initialize kms_sw_dt at prime import time (v2)
Currently kms_sw_displaytarget_add_from_prime() allocates the struct and
fills in only some of the fields, resulting in a half-baked struct that
needs to be further completed by the caller. To make this a bit more
consistent, pass width, height and stride to this function and fill in
everything there, so that caller can take the returned struct as is.
v2: Split from one big patch into four fixing one thing at a time.
Signed-off-by: Tomasz Figa <[email protected]>
CC: <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c index 0585fcce207..65dbf70785c 100644 --- a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c +++ b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c @@ -211,7 +211,9 @@ kms_sw_displaytarget_map(struct sw_winsys *ws, } static struct kms_sw_displaytarget * -kms_sw_displaytarget_add_from_prime(struct kms_sw_winsys *kms_sw, int fd) +kms_sw_displaytarget_add_from_prime(struct kms_sw_winsys *kms_sw, int fd, + unsigned width, unsigned height, + unsigned stride) { uint32_t handle = -1; struct kms_sw_displaytarget * kms_sw_dt; @@ -229,6 +231,9 @@ kms_sw_displaytarget_add_from_prime(struct kms_sw_winsys *kms_sw, int fd) kms_sw_dt->ref_count = 1; kms_sw_dt->handle = handle; kms_sw_dt->size = lseek(fd, 0, SEEK_END); + kms_sw_dt->width = width; + kms_sw_dt->height = height; + kms_sw_dt->stride = stride; if (kms_sw_dt->size == (off_t)-1) { FREE(kms_sw_dt); @@ -274,13 +279,12 @@ kms_sw_displaytarget_from_handle(struct sw_winsys *ws, switch(whandle->type) { case DRM_API_HANDLE_TYPE_FD: - kms_sw_dt = kms_sw_displaytarget_add_from_prime(kms_sw, whandle->handle); - if (kms_sw_dt) { - kms_sw_dt->width = templ->width0; - kms_sw_dt->height = templ->height0; - kms_sw_dt->stride = whandle->stride; + kms_sw_dt = kms_sw_displaytarget_add_from_prime(kms_sw, whandle->handle, + templ->width0, + templ->height0, + whandle->stride); + if (kms_sw_dt) *stride = kms_sw_dt->stride; - } return (struct sw_displaytarget *)kms_sw_dt; case DRM_API_HANDLE_TYPE_KMS: LIST_FOR_EACH_ENTRY(kms_sw_dt, &kms_sw->bo_list, link) { |