[Mesa-dev] [PATCH v2 3/4] gallium/winsys/kms: Move display target handle lookup to separate function (v2)

Jordan Justen jordan.l.justen at intel.com
Thu Aug 4 17:37:32 UTC 2016


On 2016-08-02 03:46:27, Tomasz Figa wrote:
> 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.
> 
> Signed-off-by: Tomasz Figa <tfiga at chromium.org>
> CC: <mesa-stable at lists.freedesktop.org>
> ---
>  src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c | 33 ++++++++++++++++-------
>  1 file changed, 24 insertions(+), 9 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 65dbf70..cb02b22 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,6 +211,26 @@ kms_sw_displaytarget_map(struct sw_winsys *ws,
>  }
>  
>  static struct kms_sw_displaytarget *
> +kms_sw_displaytarget_lookup(struct kms_sw_winsys *kms_sw,
> +                            unsigned int kms_handle)

I don't think the 'lookup' name is appropriate, since it has the
ref-count side effect. Instead of 'lookup', how about import, or
find_and_import or something similar?

With that fixed,
Series Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

> +{
> +   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,
>                                      unsigned stride)
> @@ -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_lookup(kms_sw, whandle->handle);
> +      if (kms_sw_dt) {
> +         *stride = kms_sw_dt->stride;
> +         return (struct sw_displaytarget *)kms_sw_dt;
>        }
>        /* fallthrough */
>     default:
> -- 
> 2.8.0.rc3.226.g39d4020
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list