if (asprintf(&node, str, DRM_DIR_NAME, j) < 0)
continue;
- fd = open(node, O_RDWR, 0);
+ fd = open(node, O_RDWR | O_CLOEXEC);
free(node);
if (fd < 0)
int32_t create_reserved_region(const std::string &buffer_name, uint64_t reserved_region_size)
{
- int32_t reserved_region_fd;
std::string reserved_region_name = buffer_name + " reserved region";
- reserved_region_fd = memfd_create(reserved_region_name.c_str(), FD_CLOEXEC);
+#ifdef __NR_memfd_create
+ int32_t reserved_region_fd = memfd_create(reserved_region_name.c_str(), FD_CLOEXEC);
if (reserved_region_fd == -1) {
drv_log("Failed to create reserved region fd: %s.\n", strerror(errno));
return -errno;
}
return reserved_region_fd;
+#else
+ drv_log("Failed to create reserved region '%s': memfd_create not available.",
+ reserved_region_name.c_str());
+ return -1;
+#endif
}
int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descriptor *descriptor,
num_bytes = ALIGN(num_bytes, sizeof(int));
num_ints = num_bytes - sizeof(native_handle_t) - num_fds;
/*
- * Malloc is used as handles are ultimetly destroyed via free in
+ * Malloc is used as handles are ultimately destroyed via free in
* native_handle_delete().
*/
hnd = static_cast<struct cros_gralloc_handle *>(malloc(num_bytes));
hnd->width = drv_bo_get_width(bo);
hnd->height = drv_bo_get_height(bo);
hnd->format = drv_bo_get_format(bo);
+ hnd->tiling = bo->meta.tiling;
hnd->format_modifier = drv_bo_get_plane_format_modifier(bo, 0);
hnd->use_flags = descriptor->use_flags;
bytes_per_pixel = drv_bytes_per_pixel_from_format(hnd->format, 0);
struct bo *bo;
struct drv_import_fd_data data;
data.format = hnd->format;
+ data.tiling = hnd->tiling;
data.width = hnd->width;
data.height = hnd->height;
for (const auto &pair : handles_) {
function(pair.first);
}
-}
\ No newline at end of file
+}