gallium/winsys/kms: Move display target handle lookup to separate function

As a preparation to use the lookup in more than once place, move the
code that looks up given KMS/GEM handle to a separate function. This
change should not introduce any functional changes.

v2: Split into separate patch.
    Move lookup code into separate function.

v3 [Emil Velikov]:
    Rename kms_sw_displaytarget_{lookup,find_and_ref} (Jordan)

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com> (v2)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
Tomasz Figa
2016-08-02 19:46:27 +09:00
committed by Emil Velikov
parent e71b78ebf9
commit 0465c72d46

View File

@@ -210,6 +210,26 @@ kms_sw_displaytarget_map(struct sw_winsys *ws,
return kms_sw_dt->mapped;
}
static struct kms_sw_displaytarget *
kms_sw_displaytarget_find_and_ref(struct kms_sw_winsys *kms_sw,
unsigned int kms_handle)
{
struct kms_sw_displaytarget *kms_sw_dt;
LIST_FOR_EACH_ENTRY(kms_sw_dt, &kms_sw->bo_list, link) {
if (kms_sw_dt->handle == kms_handle) {
kms_sw_dt->ref_count++;
DEBUG_PRINT("KMS-DEBUG: imported buffer %u (size %u)\n",
kms_sw_dt->handle, kms_sw_dt->size);
return kms_sw_dt;
}
}
return NULL;
}
static struct kms_sw_displaytarget *
kms_sw_displaytarget_add_from_prime(struct kms_sw_winsys *kms_sw, int fd,
unsigned width, unsigned height,
@@ -287,15 +307,10 @@ kms_sw_displaytarget_from_handle(struct sw_winsys *ws,
*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) {
if (kms_sw_dt->handle == whandle->handle) {
kms_sw_dt->ref_count++;
DEBUG_PRINT("KMS-DEBUG: imported buffer %u (size %u)\n", kms_sw_dt->handle, kms_sw_dt->size);
*stride = kms_sw_dt->stride;
return (struct sw_displaytarget *)kms_sw_dt;
}
kms_sw_dt = kms_sw_displaytarget_find_and_ref(kms_sw, whandle->handle);
if (kms_sw_dt) {
*stride = kms_sw_dt->stride;
return (struct sw_displaytarget *)kms_sw_dt;
}
/* fallthrough */
default: