}
}
+int cros_gralloc_driver::get_fd() const {
+ return drv_get_fd(drv_);
+}
+
int32_t cros_gralloc_driver::init()
{
/*
if (asprintf(&node, str, DRM_DIR_NAME, j) < 0)
continue;
- fd = open(node, O_RDWR, 0);
+ fd = open(node, O_RDWR | O_CLOEXEC, 0);
free(node);
if (fd < 0)
return -ENODEV;
}
+int cros_gralloc_driver::init_master()
+{
+ int fd = open(DRM_DIR_NAME "/card0", O_RDWR, 0);
+ if (fd >= 0) {
+ drv_ = drv_create(fd);
+ if (drv_)
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
bool cros_gralloc_driver::is_supported(const struct cros_gralloc_buffer_descriptor *descriptor)
{
struct combination *combo;
uint64_t mod;
size_t num_planes;
uint32_t resolved_format;
+ uint32_t bytes_per_pixel;
+ uint64_t use_flags;
struct bo *bo;
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);
+ use_flags = descriptor->use_flags;
+ /*
+ * TODO(b/79682290): ARC++ assumes NV12 is always linear and doesn't
+ * send modifiers across Wayland protocol, so we or in the
+ * BO_USE_LINEAR flag here. We need to fix ARC++ to allocate and work
+ * with tiled buffers.
+ */
+ if (resolved_format == DRM_FORMAT_NV12)
+ use_flags |= BO_USE_LINEAR;
+
+ bo = drv_bo_create(drv_, descriptor->width, descriptor->height, resolved_format, use_flags);
if (!bo) {
drv_log("Failed to create bo.\n");
return -ENOMEM;
hnd->format = drv_bo_get_format(bo);
hnd->use_flags[0] = static_cast<uint32_t>(descriptor->use_flags >> 32);
hnd->use_flags[1] = static_cast<uint32_t>(descriptor->use_flags);
- hnd->pixel_stride = drv_bo_get_stride_in_pixels(bo);
+ bytes_per_pixel = drv_bytes_per_pixel_from_format(hnd->format, 0);
+ hnd->pixel_stride = DIV_ROUND_UP(hnd->strides[0], bytes_per_pixel);
hnd->magic = cros_gralloc_magic;
hnd->droid_format = descriptor->droid_format;
hnd->usage = descriptor->producer_usage;