diff --git a/cros_gralloc/aidl/.clang-format b/cros_gralloc/aidl/.clang-format index e5e7076..3031709 100644 --- a/cros_gralloc/aidl/.clang-format +++ b/cros_gralloc/aidl/.clang-format @@ -16,4 +16,4 @@ IndentWidth: 4 ContinuationIndentWidth: 8 PointerAlignment: Left TabWidth: 4 -UseTab: Never \ No newline at end of file +UseTab: Never diff --git a/cros_gralloc/aidl/allocator.xml b/cros_gralloc/aidl/allocator.xml index 4d375b3..74ed382 100644 --- a/cros_gralloc/aidl/allocator.xml +++ b/cros_gralloc/aidl/allocator.xml @@ -7,4 +7,4 @@ default - \ No newline at end of file + diff --git a/cros_gralloc/gralloc0/tests/gralloctest.c b/cros_gralloc/gralloc0/tests/gralloctest.c index 1641b8a..9d8101c 100644 --- a/cros_gralloc/gralloc0/tests/gralloctest.c +++ b/cros_gralloc/gralloc0/tests/gralloctest.c @@ -22,7 +22,7 @@ #include #include -#define ALIGN(A, B) (((A) + (B) - 1) / (B) * (B)) +#define ALIGN(A, B) (((A) + (B)-1) / (B) * (B)) #define ARRAY_SIZE(A) (sizeof(A) / sizeof(*(A))) #define CHECK(cond) \ diff --git a/cros_gralloc/gralloc4/.clang-format b/cros_gralloc/gralloc4/.clang-format index b310cc1..4783e1b 100644 --- a/cros_gralloc/gralloc4/.clang-format +++ b/cros_gralloc/gralloc4/.clang-format @@ -16,4 +16,4 @@ IndentWidth: 4 ContinuationIndentWidth: 8 PointerAlignment: Left TabWidth: 4 -UseTab: Never \ No newline at end of file +UseTab: Never diff --git a/cros_gralloc/mapper_stablec/.clang-format b/cros_gralloc/mapper_stablec/.clang-format index e5e7076..3031709 100644 --- a/cros_gralloc/mapper_stablec/.clang-format +++ b/cros_gralloc/mapper_stablec/.clang-format @@ -16,4 +16,4 @@ IndentWidth: 4 ContinuationIndentWidth: 8 PointerAlignment: Left TabWidth: 4 -UseTab: Never \ No newline at end of file +UseTab: Never diff --git a/i915.c b/i915.c index adfd8c5..d0584f0 100644 --- a/i915.c +++ b/i915.c @@ -559,7 +559,7 @@ static size_t i915_num_planes_from_modifier(struct driver *drv, uint32_t format, 32 - __builtin_clz(x)) \ : 0) -#define roundup_power_of_two(x) ((x) != 0 ? 1ULL << gbm_fls((x) - 1) : 0) +#define roundup_power_of_two(x) ((x) != 0 ? 1ULL << gbm_fls((x)-1) : 0) static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, uint64_t use_flags, const uint64_t *modifiers, uint32_t count) @@ -590,7 +590,7 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig uint64_t cursor_width = 0; uint64_t cursor_height = 0; bool err = drmGetCap(bo->drv->fd, DRM_CAP_CURSOR_WIDTH, &cursor_width) || - drmGetCap(bo->drv->fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height); + drmGetCap(bo->drv->fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height); if (!err && width <= cursor_width && height <= cursor_height) { width = cursor_width; diff --git a/intel_defines.h b/intel_defines.h index 36d1f03..39b260f 100644 --- a/intel_defines.h +++ b/intel_defines.h @@ -7,25 +7,18 @@ #define ARRAY_SIZE(A) (sizeof(A) / sizeof(*(A))) static const uint32_t scanout_render_formats[] = { - DRM_FORMAT_ABGR2101010, - DRM_FORMAT_ABGR8888, - DRM_FORMAT_ARGB2101010, - DRM_FORMAT_ARGB8888, - DRM_FORMAT_RGB565, - DRM_FORMAT_XBGR2101010, - DRM_FORMAT_XBGR8888, - DRM_FORMAT_XRGB2101010, - DRM_FORMAT_XRGB8888, + DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB2101010, + DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565, DRM_FORMAT_XBGR2101010, + DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB2101010, DRM_FORMAT_XRGB8888, }; -static const uint32_t render_formats[] = { DRM_FORMAT_ABGR16161616F, }; +static const uint32_t render_formats[] = { + DRM_FORMAT_ABGR16161616F, +}; static const uint32_t texture_only_formats[] = { - DRM_FORMAT_R8, - DRM_FORMAT_NV12, - DRM_FORMAT_P010, - DRM_FORMAT_YVU420, - DRM_FORMAT_YVU420_ANDROID, + DRM_FORMAT_R8, DRM_FORMAT_NV12, DRM_FORMAT_P010, + DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID, }; static const uint32_t image_storage_formats[] = { @@ -65,17 +58,23 @@ const uint16_t gen12_ids[] = { }; const uint16_t adlp_ids[] = { - 0x46A0, 0x46A1, 0x46A2, 0x46A3, 0x46A6, 0x46A8, 0x46AA, 0x462A, 0x4626, 0x4628, - 0x46B0, 0x46B1, 0x46B2, 0x46B3, 0x46C0, 0x46C1, 0x46C2, 0x46C3, 0x46D0, 0x46D1, - 0x46D2, 0x46D3, 0x46D4, + 0x46A0, 0x46A1, 0x46A2, 0x46A3, 0x46A6, 0x46A8, 0x46AA, 0x462A, + 0x4626, 0x4628, 0x46B0, 0x46B1, 0x46B2, 0x46B3, 0x46C0, 0x46C1, + 0x46C2, 0x46C3, 0x46D0, 0x46D1, 0x46D2, 0x46D3, 0x46D4, }; const uint16_t rplp_ids[] = { 0xA720, 0xA721, 0xA7A0, 0xA7A1, 0xA7A8, 0xA7A9, 0xA7AA, 0xA7AB, 0xA7AC, 0xA7AD, }; -const uint16_t mtl_ids[] = { 0x7D40, 0x7D60, 0x7D45, 0x7D55, 0x7DD5, }; +const uint16_t mtl_ids[] = { + 0x7D40, 0x7D60, 0x7D45, 0x7D55, 0x7DD5, +}; -const uint16_t lnl_ids[] = { 0x6420, 0x64A0, 0x64B0, }; +const uint16_t lnl_ids[] = { + 0x6420, + 0x64A0, + 0x64B0, +}; const uint16_t ptl_ids[] = { 0xB080, 0xB081, 0xB082, 0xB083, 0xB08F, 0xB090, 0xB0A0, 0xB0B0 }; diff --git a/presubmit.sh b/presubmit.sh index 69665f2..8dca103 100755 --- a/presubmit.sh +++ b/presubmit.sh @@ -2,9 +2,10 @@ # Copyright 2017 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -find \ - '(' -name '*.[ch]' -or -name '*.cc' ')' \ - -not -name 'virtgpu_drm.h' -not -name 'i915_drm.h' \ - -not -name 'gbm.h' -not -name 'virgl_hw.h' \ - -not -name 'virgl_protocol.h' \ - -exec clang-format -style=file -i {} + +cros format \ + --exclude 'external/*' \ + --exclude 'gbm.h' \ + --include '*.[ch]' \ + --include '*.cc' \ + --include '*.cpp' \ + . diff --git a/util.h b/util.h index 4e9a06a..b45224a 100644 --- a/util.h +++ b/util.h @@ -10,11 +10,11 @@ #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define ARRAY_SIZE(A) (sizeof(A) / sizeof(*(A))) #define PUBLIC __attribute__((visibility("default"))) -#define ALIGN(A, B) (((A) + (B) - 1) & ~((B) - 1)) +#define ALIGN(A, B) (((A) + (B)-1) & ~((B)-1)) #define IS_ALIGNED(A, B) (ALIGN((A), (B)) == (A)) -#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) #define STRINGIZE_NO_EXPANSION(x) #x #define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x) -#define BITFIELD_BIT(b) (1u<<(b)) +#define BITFIELD_BIT(b) (1u << (b)) #endif diff --git a/virtgpu_virgl.c b/virtgpu_virgl.c index 763bdbc..4030433 100644 --- a/virtgpu_virgl.c +++ b/virtgpu_virgl.c @@ -53,10 +53,9 @@ static const uint32_t texture_source_formats[] = { DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR16161616F }; -static const uint32_t depth_stencil_formats[] = { - DRM_FORMAT_DEPTH16, DRM_FORMAT_DEPTH24, DRM_FORMAT_DEPTH24_STENCIL8, - DRM_FORMAT_DEPTH32, DRM_FORMAT_DEPTH32_STENCIL8 -}; +static const uint32_t depth_stencil_formats[] = { DRM_FORMAT_DEPTH16, DRM_FORMAT_DEPTH24, + DRM_FORMAT_DEPTH24_STENCIL8, DRM_FORMAT_DEPTH32, + DRM_FORMAT_DEPTH32_STENCIL8 }; extern struct virtgpu_param params[]; diff --git a/xe.c b/xe.c index 2a14807..fd8b1f3 100644 --- a/xe.c +++ b/xe.c @@ -19,8 +19,8 @@ #include "drv_priv.h" #include "external/xe_drm.h" -#include "util.h" #include "intel_defines.h" +#include "util.h" struct modifier_support_t { const uint64_t *order; @@ -39,8 +39,8 @@ struct xe_device { uint64_t gtt_size; /** - * Memory vm bind alignment and buffer size requirement - */ + * Memory vm bind alignment and buffer size requirement + */ unsigned mem_alignment; struct modifier_support_t modifier; @@ -135,7 +135,7 @@ static int xe_add_combinations(struct driver *drv) const uint64_t texture_only = BO_USE_TEXTURE_MASK; // HW protected buffers also need to be scanned out. const uint64_t hw_protected = - xe->has_hw_protection ? (BO_USE_PROTECTED | BO_USE_SCANOUT) : 0; + xe->has_hw_protection ? (BO_USE_PROTECTED | BO_USE_SCANOUT) : 0; const uint64_t linear_mask = BO_USE_RENDERSCRIPT | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | @@ -236,7 +236,7 @@ static int xe_add_combinations(struct driver *drv) } static int xe_align_dimensions(struct bo *bo, uint32_t format, uint32_t tiling, uint32_t *stride, - uint32_t *aligned_height) + uint32_t *aligned_height) { uint32_t horizontal_alignment = 0; uint32_t vertical_alignment = 0; @@ -307,19 +307,18 @@ static bool xe_query_config(struct driver *drv, struct xe_device *xe) struct drm_xe_device_query query = { .query = DRM_XE_DEVICE_QUERY_CONFIG, }; - if(drmIoctl(drv->fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)) + if (drmIoctl(drv->fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)) return false; struct drm_xe_query_config *config = calloc(1, query.size); - if(!config) + if (!config) return false; query.data = (uintptr_t)config; - if(drmIoctl(drv->fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)) + if (drmIoctl(drv->fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)) goto data_query_failed; - - if(config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM) + if (config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_VRAM) xe->has_local_mem = true; else xe->has_local_mem = false; @@ -339,7 +338,7 @@ data_query_failed: static bool xe_device_probe(struct driver *drv, struct xe_device *xe) { /* Retrieve the device info by querying KMD through IOCTL - */ + */ struct drm_xe_device_query query = { .extensions = 0, .query = DRM_XE_DEVICE_QUERY_CONFIG, @@ -347,20 +346,21 @@ static bool xe_device_probe(struct driver *drv, struct xe_device *xe) .data = 0, }; - if(drmIoctl(drv->fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)) + if (drmIoctl(drv->fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)) return false; struct drm_xe_query_config *config = calloc(1, query.size); - if(!config) + if (!config) return false; query.data = (uintptr_t)config; - if(drmIoctl(drv->fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)){ + if (drmIoctl(drv->fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)) { free(config); return false; } - xe->device_id = ((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] << 16)>>16) & 0xFFFF; + xe->device_id = + ((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] << 16) >> 16) & 0xFFFF; xe->revision = (config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16) & 0xFFFF; free(config); @@ -375,7 +375,7 @@ static int xe_init(struct driver *drv) if (!xe) return -ENOMEM; - if(!xe_device_probe(drv, xe)){ + if (!xe_device_probe(drv, xe)) { drv_loge("Failed to query device id using DRM_IOCTL_XE_DEVICE_QUERY"); return -EINVAL; } @@ -391,14 +391,14 @@ static int xe_init(struct driver *drv) if (xe->graphics_version >= 12) xe->has_hw_protection = 0; else if (xe->graphics_version < 12) { - drv_loge("Xe driver is not supported on your platform: 0x%x\n",xe->device_id); + drv_loge("Xe driver is not supported on your platform: 0x%x\n", xe->device_id); return -errno; } drv->priv = xe; return xe_add_combinations(drv); -return 0; + return 0; } /* @@ -406,8 +406,7 @@ return 0; * to the largest coded unit (LCU) assuming that it will be used for video. This * is based on gmmlib's GmmIsYUVFormatLCUAligned(). */ -static bool xe_format_needs_LCU_alignment(uint32_t format, size_t plane, - const struct xe_device *xe) +static bool xe_format_needs_LCU_alignment(uint32_t format, size_t plane, const struct xe_device *xe) { switch (format) { case DRM_FORMAT_NV12: @@ -473,7 +472,7 @@ static size_t xe_num_planes_from_modifier(struct driver *drv, uint32_t format, u } static int xe_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, - uint64_t use_flags, const uint64_t *modifiers, uint32_t count) + uint64_t use_flags, const uint64_t *modifiers, uint32_t count) { int ret = 0; uint64_t modifier; @@ -661,10 +660,10 @@ static int xe_bo_create_from_metadata(struct bo *bo) } struct drm_xe_gem_create gem_create = { - .vm_id = 0, /* ensure exportable to PRIME fd */ - .size = bo->meta.total_size, - .flags = flags, - .cpu_caching = cpu_caching, + .vm_id = 0, /* ensure exportable to PRIME fd */ + .size = bo->meta.total_size, + .flags = flags, + .cpu_caching = cpu_caching, }; /* FIXME: let's assume iGPU with SYSMEM is only supported */ @@ -711,8 +710,8 @@ static void *xe_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) /* Get the fake offset back */ ret = drmIoctl(bo->drv->fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &gem_map); if (ret == 0) { - addr = mmap(0, bo->meta.total_size, PROT_READ | PROT_WRITE, - MAP_SHARED, bo->drv->fd, gem_map.offset); + addr = mmap(0, bo->meta.total_size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->drv->fd, + gem_map.offset); } if (addr == MAP_FAILED) {