ifeq ($(strip $(BOARD_USES_GRALLOC1)), true)
LOCAL_SRC_FILES += cros_gralloc/gralloc1/cros_gralloc1_module.cc
+LOCAL_CPPFLAGS += -DUSE_GRALLOC1
else
LOCAL_SRC_FILES += cros_gralloc/gralloc0/gralloc0.cc
endif
struct cros_gralloc_handle *hnd;
resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->use_flags);
- bo = drv_bo_create(drv_, descriptor->width, descriptor->height, resolved_format,
- descriptor->use_flags);
+ if (descriptor->modifier == 0) {
+ bo = drv_bo_create(drv_, descriptor->width, descriptor->height, resolved_format,
+ descriptor->use_flags);
+ } else {
+ bo = drv_bo_create_with_modifiers(drv_, descriptor->width, descriptor->height,
+ resolved_format, &descriptor->modifier, 1);
+ }
if (!bo) {
cros_gralloc_error("Failed to create bo.");
return -ENOMEM;
uint32_t producer_usage;
uint32_t droid_format;
uint32_t drm_format;
+ uint64_t modifier;
uint64_t use_flags;
};
descriptor.height = h;
descriptor.droid_format = format;
descriptor.producer_usage = descriptor.consumer_usage = usage;
+ descriptor.modifier = 0;
descriptor.drm_format = cros_gralloc_convert_format(format);
descriptor.use_flags = gralloc0_convert_usage(usage);
gralloc1_function_pointer_t CrosGralloc1::doGetFunction(int32_t intDescriptor)
{
constexpr auto lastDescriptor = static_cast<int32_t>(GRALLOC1_LAST_FUNCTION);
- if (intDescriptor < 0 || intDescriptor > lastDescriptor) {
- ALOGE("Invalid function descriptor");
+ if (intDescriptor < 0 || ((intDescriptor > lastDescriptor) && ((intDescriptor < 100) || (intDescriptor > GRALLOC1_LAST_CUSTOM)))) {
+ ALOGE("Invalid function descriptor %d", intDescriptor);
return nullptr;
}
lockHook<struct android_flex_layout, &CrosGralloc1::lockFlex>);
case GRALLOC1_FUNCTION_UNLOCK:
return asFP<GRALLOC1_PFN_UNLOCK>(unlockHook);
+ case GRALLOC1_FUNCTION_SET_MODIFIER:
+ return asFP<GRALLOC1_PFN_SET_MODIFIER>(setModifierHook);
case GRALLOC1_FUNCTION_INVALID:
ALOGE("Invalid function descriptor");
return nullptr;
return CROS_GRALLOC_ERROR_NONE;
}
+int32_t CrosGralloc1::setModifier(gralloc1_buffer_descriptor_t descriptorId, uint64_t modifier)
+{
+ auto hnd = (struct cros_gralloc_buffer_descriptor *)descriptorId;
+ hnd->modifier = modifier;
+ return CROS_GRALLOC_ERROR_NONE;
+}
+
int32_t CrosGralloc1::allocate(struct cros_gralloc_buffer_descriptor *descriptor,
buffer_handle_t *outBufferHandle)
{
return error;
}
+ int32_t setModifier(gralloc1_buffer_descriptor_t descriptor, uint64_t modifier);
+ static int32_t setModifierHook(gralloc1_device_t *device,
+ gralloc1_buffer_descriptor_t descriptor, uint64_t modifier)
+ {
+ return getAdapter(device)->setModifier(descriptor, modifier);
+ }
+
// Adapter internals
std::unique_ptr<cros_gralloc_driver> driver;
};
* found in the LICENSE file.
*/
-#ifdef DRV_I915
-
/*
* Android graphics.h defines the formats and leaves 0x100 - 0x1FF
* range available for HAL implementation specific formats.
*/
+
+#ifndef i915_PRIVATE_ANDROID_TYPES_H_
+#define i915_PRIVATE_ANDROID_TYPES_H_
+
+#ifdef USE_GRALLOC1
+#include <hardware/gralloc1.h>
+#endif
+
enum { HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL = 0x100,
HAL_PIXEL_FORMAT_NV12_LINEAR_INTEL = 0x101,
HAL_PIXEL_FORMAT_YCrCb_422_H_INTEL = 0x102,
HAL_PIXEL_FORMAT_YUV420PackedSemiPlanar_Tiled_INTEL = 0x7FA00F00,
};
+#ifdef USE_GRALLOC1
+enum { GRALLOC1_FUNCTION_SET_MODIFIER = 101,
+ GRALLOC1_LAST_CUSTOM = 500 };
+
+typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_MODIFIER)(
+ gralloc1_device_t *device, gralloc1_buffer_descriptor_t descriptor, uint64_t modifier);
+#endif
+
#endif