#include "drv_priv.h"
#include "helpers.h"
+#include "i915_private.h"
#include "util.h"
static uint32_t subsample_stride(uint32_t stride, uint32_t format, size_t plane)
return 32;
}
- fprintf(stderr, "drv: UNKNOWN FORMAT %d\n", format);
- return 0;
+ return i915_private_bpp_from_format(format, plane);
}
uint32_t drv_bo_get_stride_in_pixels(struct bo *bo)
vertical_subsampling = (plane == 0) ? 1 : 2;
break;
default:
- vertical_subsampling = 1;
+ i915_private_vertical_subsampling_from_format(&vertical_subsampling, format, plane);
}
return stride * DIV_ROUND_UP(height, vertical_subsampling);
bo->handles[plane].u32 = prime_handle.handle;
}
+ ATOMIC_LOCK(&bo->drv->driver_lock);
for (plane = 0; plane < bo->num_planes; plane++) {
- pthread_mutex_lock(&bo->drv->driver_lock);
drv_increment_reference_count(bo->drv, bo, plane);
- pthread_mutex_unlock(&bo->drv->driver_lock);
}
+ ATOMIC_UNLOCK(&bo->drv->driver_lock);
return 0;
}
free(items);
return 0;
}
+
+/*
+ * Pick the best modifier from modifiers, according to the ordering
+ * given by modifier_order.
+ */
+uint64_t drv_pick_modifier(const uint64_t *modifiers, uint32_t count,
+ const uint64_t *modifier_order, uint32_t order_count)
+{
+ uint32_t i, j;
+
+ for (i = 0; i < order_count; i++) {
+ for (j = 0; j < count; j++) {
+ if (modifiers[j] == modifier_order[i]) {
+ return modifiers[j];
+ }
+ }
+ }
+
+ return DRM_FORMAT_MOD_LINEAR;
+}