1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2021 NVIDIA Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16bf215546Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18bf215546Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19bf215546Sopenharmony_ci * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20bf215546Sopenharmony_ci * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 23bf215546Sopenharmony_ci */ 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci#include "gbm_backend_abi.h" /* Current GBM backend ABI implementation */ 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include <stddef.h> /* offsetof */ 28bf215546Sopenharmony_ci#include <stdio.h> /* printf */ 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci/* 31bf215546Sopenharmony_ci * The following are previous implementations of the structures defined in 32bf215546Sopenharmony_ci * gbm_backend_abi.h, with their ABI version appended. 33bf215546Sopenharmony_ci * 34bf215546Sopenharmony_ci * DO NOT EVER CHANGE EXISTING DEFINITIONS HERE! 35bf215546Sopenharmony_ci * 36bf215546Sopenharmony_ci * Changing them implies breaking the GBM backend ABI. Instead, to extend the 37bf215546Sopenharmony_ci * ABI, in gbm_backend_abi.h: 38bf215546Sopenharmony_ci * 39bf215546Sopenharmony_ci * -Add a new versioned struct 40bf215546Sopenharmony_ci * -Append it to the associated top-level object's struct 41bf215546Sopenharmony_ci * -Increment GBM_BACKEND_ABI_VERSION 42bf215546Sopenharmony_ci * 43bf215546Sopenharmony_ci * Then, here: 44bf215546Sopenharmony_ci * 45bf215546Sopenharmony_ci * -Add a new block of definitions below for the new ABI content 46bf215546Sopenharmony_ci * -Add a new block of checks in main() 47bf215546Sopenharmony_ci */ 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci/* 50bf215546Sopenharmony_ci * From: Simon Ser - "gbm: assume USE_SCANOUT in create_with_modifiers" 51bf215546Sopenharmony_ci * 52bf215546Sopenharmony_ci * Note: ABI 1 is identical to ABI 0, except gbm_device_v0.bo_create can 53bf215546Sopenharmony_ci * provide both modifiers and usage. 54bf215546Sopenharmony_ci */ 55bf215546Sopenharmony_ci#define GBM_BACKEND_ABI_VERSION_abi0 1 56bf215546Sopenharmony_cistruct gbm_device_v0_abi0 { 57bf215546Sopenharmony_ci const struct gbm_backend_desc *backend_desc; 58bf215546Sopenharmony_ci uint32_t backend_version; 59bf215546Sopenharmony_ci int fd; 60bf215546Sopenharmony_ci const char *name; 61bf215546Sopenharmony_ci void (*destroy)(struct gbm_device *gbm); 62bf215546Sopenharmony_ci int (*is_format_supported)(struct gbm_device *gbm, 63bf215546Sopenharmony_ci uint32_t format, 64bf215546Sopenharmony_ci uint32_t usage); 65bf215546Sopenharmony_ci int (*get_format_modifier_plane_count)(struct gbm_device *device, 66bf215546Sopenharmony_ci uint32_t format, 67bf215546Sopenharmony_ci uint64_t modifier); 68bf215546Sopenharmony_ci struct gbm_bo *(*bo_create)(struct gbm_device *gbm, 69bf215546Sopenharmony_ci uint32_t width, uint32_t height, 70bf215546Sopenharmony_ci uint32_t format, 71bf215546Sopenharmony_ci uint32_t usage, 72bf215546Sopenharmony_ci const uint64_t *modifiers, 73bf215546Sopenharmony_ci const unsigned int count); 74bf215546Sopenharmony_ci struct gbm_bo *(*bo_import)(struct gbm_device *gbm, uint32_t type, 75bf215546Sopenharmony_ci void *buffer, uint32_t usage); 76bf215546Sopenharmony_ci void *(*bo_map)(struct gbm_bo *bo, 77bf215546Sopenharmony_ci uint32_t x, uint32_t y, 78bf215546Sopenharmony_ci uint32_t width, uint32_t height, 79bf215546Sopenharmony_ci uint32_t flags, uint32_t *stride, 80bf215546Sopenharmony_ci void **map_data); 81bf215546Sopenharmony_ci void (*bo_unmap)(struct gbm_bo *bo, void *map_data); 82bf215546Sopenharmony_ci int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data); 83bf215546Sopenharmony_ci int (*bo_get_fd)(struct gbm_bo *bo); 84bf215546Sopenharmony_ci int (*bo_get_planes)(struct gbm_bo *bo); 85bf215546Sopenharmony_ci union gbm_bo_handle (*bo_get_handle)(struct gbm_bo *bo, int plane); 86bf215546Sopenharmony_ci int (*bo_get_plane_fd)(struct gbm_bo *bo, int plane); 87bf215546Sopenharmony_ci uint32_t (*bo_get_stride)(struct gbm_bo *bo, int plane); 88bf215546Sopenharmony_ci uint32_t (*bo_get_offset)(struct gbm_bo *bo, int plane); 89bf215546Sopenharmony_ci uint64_t (*bo_get_modifier)(struct gbm_bo *bo); 90bf215546Sopenharmony_ci void (*bo_destroy)(struct gbm_bo *bo); 91bf215546Sopenharmony_ci struct gbm_surface *(*surface_create)(struct gbm_device *gbm, 92bf215546Sopenharmony_ci uint32_t width, uint32_t height, 93bf215546Sopenharmony_ci uint32_t format, uint32_t flags, 94bf215546Sopenharmony_ci const uint64_t *modifiers, 95bf215546Sopenharmony_ci const unsigned count); 96bf215546Sopenharmony_ci struct gbm_bo *(*surface_lock_front_buffer)(struct gbm_surface *surface); 97bf215546Sopenharmony_ci void (*surface_release_buffer)(struct gbm_surface *surface, 98bf215546Sopenharmony_ci struct gbm_bo *bo); 99bf215546Sopenharmony_ci int (*surface_has_free_buffers)(struct gbm_surface *surface); 100bf215546Sopenharmony_ci void (*surface_destroy)(struct gbm_surface *surface); 101bf215546Sopenharmony_ci}; 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_cistruct gbm_device_abi0 { 104bf215546Sopenharmony_ci /* Hack to make a gbm_device detectable by its first element. */ 105bf215546Sopenharmony_ci struct gbm_device *(*dummy)(int); 106bf215546Sopenharmony_ci struct gbm_device_v0_abi0 v0; 107bf215546Sopenharmony_ci}; 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci/** 110bf215546Sopenharmony_ci * GBM buffer object interface corresponding to GBM_BACKEND_ABI_VERSION = 0 111bf215546Sopenharmony_ci * 112bf215546Sopenharmony_ci * DO NOT MODIFY THIS STRUCT. Instead, introduce a gbm_bo_v1, increment 113bf215546Sopenharmony_ci * GBM_BACKEND_ABI_VERSION, and append gbm_bo_v1 to gbm_bo. 114bf215546Sopenharmony_ci */ 115bf215546Sopenharmony_cistruct gbm_bo_v0_abi0 { 116bf215546Sopenharmony_ci uint32_t width; 117bf215546Sopenharmony_ci uint32_t height; 118bf215546Sopenharmony_ci uint32_t stride; 119bf215546Sopenharmony_ci uint32_t format; 120bf215546Sopenharmony_ci union gbm_bo_handle handle; 121bf215546Sopenharmony_ci void *user_data; 122bf215546Sopenharmony_ci void (*destroy_user_data)(struct gbm_bo *, void *); 123bf215546Sopenharmony_ci}; 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_ci/** 126bf215546Sopenharmony_ci * The allocated buffer object. 127bf215546Sopenharmony_ci * 128bf215546Sopenharmony_ci * The members in this structure should not be accessed directly. 129bf215546Sopenharmony_ci * 130bf215546Sopenharmony_ci * To modify this structure, introduce a new gbm_bo_v<N> structure, add it to 131bf215546Sopenharmony_ci * the end of this structure, and increment GBM_BACKEND_ABI_VERSION. 132bf215546Sopenharmony_ci */ 133bf215546Sopenharmony_cistruct gbm_bo_abi0 { 134bf215546Sopenharmony_ci struct gbm_device *gbm; 135bf215546Sopenharmony_ci struct gbm_bo_v0_abi0 v0; 136bf215546Sopenharmony_ci}; 137bf215546Sopenharmony_ci 138bf215546Sopenharmony_ci/** 139bf215546Sopenharmony_ci * GBM surface interface corresponding to GBM_BACKEND_ABI_VERSION = 0 140bf215546Sopenharmony_ci * 141bf215546Sopenharmony_ci * DO NOT MODIFY THIS STRUCT. Instead, introduce a gbm_surface_v1, increment 142bf215546Sopenharmony_ci * GBM_BACKEND_ABI_VERSION, and append gbm_surface_v1 to gbm_surface. 143bf215546Sopenharmony_ci */ 144bf215546Sopenharmony_cistruct gbm_surface_v0_abi0 { 145bf215546Sopenharmony_ci uint32_t width; 146bf215546Sopenharmony_ci uint32_t height; 147bf215546Sopenharmony_ci uint32_t format; 148bf215546Sopenharmony_ci uint32_t flags; 149bf215546Sopenharmony_ci struct { 150bf215546Sopenharmony_ci uint64_t *modifiers; 151bf215546Sopenharmony_ci unsigned count; 152bf215546Sopenharmony_ci }; 153bf215546Sopenharmony_ci}; 154bf215546Sopenharmony_ci 155bf215546Sopenharmony_ci/** 156bf215546Sopenharmony_ci * An allocated GBM surface. 157bf215546Sopenharmony_ci * 158bf215546Sopenharmony_ci * To modify this structure, introduce a new gbm_surface_v<N> structure, add it 159bf215546Sopenharmony_ci * to the end of this structure, and increment GBM_BACKEND_ABI_VERSION. 160bf215546Sopenharmony_ci */ 161bf215546Sopenharmony_cistruct gbm_surface_abi0 { 162bf215546Sopenharmony_ci struct gbm_device *gbm; 163bf215546Sopenharmony_ci struct gbm_surface_v0_abi0 v0; 164bf215546Sopenharmony_ci}; 165bf215546Sopenharmony_ci 166bf215546Sopenharmony_ci/** 167bf215546Sopenharmony_ci * GBM backend interfaces corresponding to GBM_BACKEND_ABI_VERSION = 0 168bf215546Sopenharmony_ci * 169bf215546Sopenharmony_ci * DO NOT MODIFY THIS STRUCT. Instead, introduce a gbm_backend_v1, increment 170bf215546Sopenharmony_ci * GBM_BACKEND_ABI_VERSION, append gbm_backend_v1 to gbm_backend. 171bf215546Sopenharmony_ci */ 172bf215546Sopenharmony_cistruct gbm_backend_v0_abi0 { 173bf215546Sopenharmony_ci /** 174bf215546Sopenharmony_ci * The version of the GBM backend interface supported by this backend. This 175bf215546Sopenharmony_ci * is set by the backend itself, and may be greater or less than the version 176bf215546Sopenharmony_ci * supported by the loader. It is the responsibility of the GBM loader to 177bf215546Sopenharmony_ci * respect this version when accessing fields in this structure. 178bf215546Sopenharmony_ci */ 179bf215546Sopenharmony_ci uint32_t backend_version; 180bf215546Sopenharmony_ci 181bf215546Sopenharmony_ci const char *backend_name; 182bf215546Sopenharmony_ci struct gbm_device *(*create_device)(int fd, uint32_t gbm_backend_version); 183bf215546Sopenharmony_ci}; 184bf215546Sopenharmony_ci 185bf215546Sopenharmony_ci/** 186bf215546Sopenharmony_ci * The interface exposed by an external GBM backend. 187bf215546Sopenharmony_ci * 188bf215546Sopenharmony_ci * To modify this structure, introduce a new gbm_backend_v<N> structure, add it 189bf215546Sopenharmony_ci * to the end of this structure, and increment GBM_BACKEND_ABI_VERSION. 190bf215546Sopenharmony_ci */ 191bf215546Sopenharmony_cistruct gbm_backend_abi0 { 192bf215546Sopenharmony_ci struct gbm_backend_v0_abi0 v0; 193bf215546Sopenharmony_ci}; 194bf215546Sopenharmony_ci 195bf215546Sopenharmony_ci/** 196bf215546Sopenharmony_ci * GBM interfaces exposed to GBM backends at GBM_BACKEND_ABI_VERSION >= 0 197bf215546Sopenharmony_ci * 198bf215546Sopenharmony_ci * DO NOT MODIFY THIS STRUCT. Instead, introduce a gbm_core_v1, increment 199bf215546Sopenharmony_ci * GBM_BACKEND_ABI_VERSION, and append gbm_core_v1 to gbm_backend. 200bf215546Sopenharmony_ci */ 201bf215546Sopenharmony_cistruct gbm_core_v0_abi0 { 202bf215546Sopenharmony_ci /** 203bf215546Sopenharmony_ci * The version of the GBM backend interface supported by the GBM loader. This 204bf215546Sopenharmony_ci * is set by the loader, and may be greater or less than the version 205bf215546Sopenharmony_ci * supported by a given backend. It is the responsibility of the backend to 206bf215546Sopenharmony_ci * respect this version when accessing fields in this structure and other 207bf215546Sopenharmony_ci * structures allocated or modified by the loader. 208bf215546Sopenharmony_ci */ 209bf215546Sopenharmony_ci uint32_t core_version; 210bf215546Sopenharmony_ci 211bf215546Sopenharmony_ci uint32_t (*format_canonicalize)(uint32_t gbm_format); 212bf215546Sopenharmony_ci}; 213bf215546Sopenharmony_ci 214bf215546Sopenharmony_ci/** 215bf215546Sopenharmony_ci * The interface exposed by the GBM core/loader code to GBM backends. 216bf215546Sopenharmony_ci * 217bf215546Sopenharmony_ci * To modify this structure, introduce a new gbm_core_v<N> structure, add it 218bf215546Sopenharmony_ci * to the end of this structure, and increment GBM_BACKEND_ABI_VERSION. 219bf215546Sopenharmony_ci */ 220bf215546Sopenharmony_cistruct gbm_core_abi0 { 221bf215546Sopenharmony_ci struct gbm_core_v0_abi0 v0; 222bf215546Sopenharmony_ci}; 223bf215546Sopenharmony_ci 224bf215546Sopenharmony_citypedef const struct gbm_backend *(*GBM_GET_BACKEND_PROC_PTR_abi0)(const struct gbm_core *gbm_core); 225bf215546Sopenharmony_ci 226bf215546Sopenharmony_ci/* 227bf215546Sopenharmony_ci * Structure/member ABI-checking helper macros 228bf215546Sopenharmony_ci */ 229bf215546Sopenharmony_ci#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member) 230bf215546Sopenharmony_ci 231bf215546Sopenharmony_ci#define CHECK_RENAMED_MEMBER_BASE(type, a_ver, b_ver, a_member, b_member) \ 232bf215546Sopenharmony_ci do { \ 233bf215546Sopenharmony_ci if (offsetof(struct type ## a_ver, a_member) != \ 234bf215546Sopenharmony_ci offsetof(struct type ## b_ver, b_member)) { \ 235bf215546Sopenharmony_ci printf("Backards incompatible change detected!\n " \ 236bf215546Sopenharmony_ci "offsetof(struct " #type #a_ver "::" #a_member ") != " \ 237bf215546Sopenharmony_ci "offsetof(struct " #type #b_ver "::" #b_member ")\n"); \ 238bf215546Sopenharmony_ci return 1; \ 239bf215546Sopenharmony_ci } \ 240bf215546Sopenharmony_ci \ 241bf215546Sopenharmony_ci if (MEMBER_SIZE(struct type ## a_ver, a_member) != \ 242bf215546Sopenharmony_ci MEMBER_SIZE(struct type ## b_ver, b_member)) { \ 243bf215546Sopenharmony_ci printf("Backards incompatible change detected!\n " \ 244bf215546Sopenharmony_ci "MEMBER_SIZE(struct " #type #a_ver "::" #a_member ") != " \ 245bf215546Sopenharmony_ci "MEMBER_SIZE(struct " #type #b_ver "::" #b_member ")\n"); \ 246bf215546Sopenharmony_ci return 1; \ 247bf215546Sopenharmony_ci } \ 248bf215546Sopenharmony_ci } while (0) 249bf215546Sopenharmony_ci 250bf215546Sopenharmony_ci#define CHECK_RENAMED_MEMBER_TYPE(type, a_ver, b_ver, a_member, b_member) \ 251bf215546Sopenharmony_ci do { \ 252bf215546Sopenharmony_ci /* Compile-time type compatibility check */ \ 253bf215546Sopenharmony_ci struct type ## a_ver a; \ 254bf215546Sopenharmony_ci struct type ## b_ver b = {0}; \ 255bf215546Sopenharmony_ci a.a_member = b.b_member; \ 256bf215546Sopenharmony_ci (void)a; \ 257bf215546Sopenharmony_ci } while (0) 258bf215546Sopenharmony_ci 259bf215546Sopenharmony_ci#define CHECK_RENAMED_MEMBER(type, a_ver, b_ver, a_member, b_member) \ 260bf215546Sopenharmony_ci do { \ 261bf215546Sopenharmony_ci CHECK_RENAMED_MEMBER_BASE(type, a_ver, b_ver, a_member, b_member); \ 262bf215546Sopenharmony_ci CHECK_RENAMED_MEMBER_TYPE(type, a_ver, b_ver, a_member, b_member); \ 263bf215546Sopenharmony_ci } while (0) 264bf215546Sopenharmony_ci#define CHECK_RENAMED_MEMBER_NO_TYPE(type, a_ver, b_ver, a_member, b_member) \ 265bf215546Sopenharmony_ci CHECK_RENAMED_MEMBER_BASE(type, a_ver, b_ver, a_member, b_member); 266bf215546Sopenharmony_ci 267bf215546Sopenharmony_ci#define CHECK_MEMBER(type, a_ver, b_ver, member) \ 268bf215546Sopenharmony_ci CHECK_RENAMED_MEMBER(type, a_ver, b_ver, member, member) 269bf215546Sopenharmony_ci#define CHECK_MEMBER_NO_TYPE(type, a_ver, b_ver, member) \ 270bf215546Sopenharmony_ci CHECK_RENAMED_MEMBER_NO_TYPE(type, a_ver, b_ver, member, member) 271bf215546Sopenharmony_ci#define CHECK_MEMBER_CURRENT(type, a_ver, member) \ 272bf215546Sopenharmony_ci CHECK_MEMBER(type, a_ver,, member) 273bf215546Sopenharmony_ci#define CHECK_MEMBER_CURRENT_NO_TYPE(type, a_ver, member) \ 274bf215546Sopenharmony_ci CHECK_MEMBER_NO_TYPE(type, a_ver,, member) 275bf215546Sopenharmony_ci 276bf215546Sopenharmony_ci#define CHECK_SIZE(type, a_ver, b_ver) \ 277bf215546Sopenharmony_ci do { \ 278bf215546Sopenharmony_ci if (sizeof(struct type ## a_ver) > \ 279bf215546Sopenharmony_ci sizeof(struct type ## b_ver)) { \ 280bf215546Sopenharmony_ci printf("Backards incompatible change detected!\n " \ 281bf215546Sopenharmony_ci "sizeof(struct " #type #a_ver ") > " \ 282bf215546Sopenharmony_ci "sizeof(struct " #type #b_ver ")\n"); \ 283bf215546Sopenharmony_ci return 1; \ 284bf215546Sopenharmony_ci } \ 285bf215546Sopenharmony_ci } while (0) 286bf215546Sopenharmony_ci 287bf215546Sopenharmony_ci#define CHECK_SIZE_CURRENT(type, a_ver) \ 288bf215546Sopenharmony_ci do { \ 289bf215546Sopenharmony_ci if (sizeof(struct type ## a_ver) != \ 290bf215546Sopenharmony_ci sizeof(struct type)) { \ 291bf215546Sopenharmony_ci printf("Backards incompatible change detected!\n " \ 292bf215546Sopenharmony_ci "sizeof(struct " #type #a_ver ") != " \ 293bf215546Sopenharmony_ci "sizeof(struct " #type ")\n"); \ 294bf215546Sopenharmony_ci return 1; \ 295bf215546Sopenharmony_ci } \ 296bf215546Sopenharmony_ci } while (0) 297bf215546Sopenharmony_ci 298bf215546Sopenharmony_ci#define CHECK_VERSION(a_ver, b_ver) \ 299bf215546Sopenharmony_ci do { \ 300bf215546Sopenharmony_ci if ((GBM_BACKEND_ABI_VERSION ## a_ver) >= \ 301bf215546Sopenharmony_ci (GBM_BACKEND_ABI_VERSION ## b_ver)) { \ 302bf215546Sopenharmony_ci printf("Backards incompatible change detected!\n " \ 303bf215546Sopenharmony_ci "GBM_BACKEND_ABI_VERSION" #a_ver " >= " \ 304bf215546Sopenharmony_ci "GBM_BACKEND_ABI_VERSION" #b_ver "\n"); \ 305bf215546Sopenharmony_ci return 1; \ 306bf215546Sopenharmony_ci } \ 307bf215546Sopenharmony_ci } while (0) 308bf215546Sopenharmony_ci 309bf215546Sopenharmony_ci#define CHECK_VERSION_CURRENT(a_ver) \ 310bf215546Sopenharmony_ci do { \ 311bf215546Sopenharmony_ci if ((GBM_BACKEND_ABI_VERSION ## a_ver) != \ 312bf215546Sopenharmony_ci (GBM_BACKEND_ABI_VERSION)) { \ 313bf215546Sopenharmony_ci printf("Backards incompatible change detected!\n " \ 314bf215546Sopenharmony_ci "GBM_BACKEND_ABI_VERSION" #a_ver " != " \ 315bf215546Sopenharmony_ci "GBM_BACKEND_ABI_VERSION\n"); \ 316bf215546Sopenharmony_ci return 1; \ 317bf215546Sopenharmony_ci } \ 318bf215546Sopenharmony_ci } while (0) 319bf215546Sopenharmony_ci 320bf215546Sopenharmony_ci#define CHECK_PROC(proc, a_ver, b_ver) \ 321bf215546Sopenharmony_ci do { \ 322bf215546Sopenharmony_ci proc ## a_ver a; \ 323bf215546Sopenharmony_ci proc ## b_ver b = NULL; \ 324bf215546Sopenharmony_ci a = b; \ 325bf215546Sopenharmony_ci (void)a; \ 326bf215546Sopenharmony_ci } while (0) 327bf215546Sopenharmony_ci 328bf215546Sopenharmony_ci#define CHECK_PROC_CURRENT(proc, a_ver) \ 329bf215546Sopenharmony_ci CHECK_PROC(proc, a_ver,) 330bf215546Sopenharmony_ci 331bf215546Sopenharmony_ciint main(int argc, char **argv) 332bf215546Sopenharmony_ci{ 333bf215546Sopenharmony_ci /********************************************/ 334bf215546Sopenharmony_ci /*** Compare Current ABI to ABI version 0 ***/ 335bf215546Sopenharmony_ci /********************************************/ 336bf215546Sopenharmony_ci 337bf215546Sopenharmony_ci /* Check current gbm_device ABI against gbm_device_abi0*/ 338bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device, _abi0, dummy); 339bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT_NO_TYPE(gbm_device, _abi0, v0); 340bf215546Sopenharmony_ci 341bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, backend_desc); 342bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, backend_version); 343bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, fd); 344bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, name); 345bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, destroy); 346bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, is_format_supported); 347bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, get_format_modifier_plane_count); 348bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_create); 349bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_import); 350bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_map); 351bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_unmap); 352bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_write); 353bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_get_fd); 354bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_get_planes); 355bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_get_handle); 356bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_get_plane_fd); 357bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_get_stride); 358bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_get_offset); 359bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_get_modifier); 360bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, bo_destroy); 361bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, surface_create); 362bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, surface_lock_front_buffer); 363bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, surface_release_buffer); 364bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, surface_has_free_buffers); 365bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_device_v0, _abi0, surface_destroy); 366bf215546Sopenharmony_ci 367bf215546Sopenharmony_ci /* Size of ABI-versioned substructures verified by above member checks */ 368bf215546Sopenharmony_ci CHECK_SIZE_CURRENT (gbm_device, _abi0); 369bf215546Sopenharmony_ci 370bf215546Sopenharmony_ci 371bf215546Sopenharmony_ci /* Check current gbm_bo ABI against gbm_bo_abi0*/ 372bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_bo, _abi0, gbm); 373bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT_NO_TYPE(gbm_bo, _abi0, v0); 374bf215546Sopenharmony_ci 375bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_bo_v0, _abi0, width); 376bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_bo_v0, _abi0, height); 377bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_bo_v0, _abi0, stride); 378bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_bo_v0, _abi0, format); 379bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_bo_v0, _abi0, handle); 380bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_bo_v0, _abi0, user_data); 381bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_bo_v0, _abi0, destroy_user_data); 382bf215546Sopenharmony_ci 383bf215546Sopenharmony_ci /* Size of ABI-versioned substructures verified by above member checks */ 384bf215546Sopenharmony_ci CHECK_SIZE_CURRENT (gbm_bo, _abi0); 385bf215546Sopenharmony_ci 386bf215546Sopenharmony_ci 387bf215546Sopenharmony_ci /* Check current gbm_surface ABI against gbm_surface_abi0 */ 388bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_surface, _abi0, gbm); 389bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT_NO_TYPE(gbm_surface, _abi0, v0); 390bf215546Sopenharmony_ci 391bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_surface_v0, _abi0, width); 392bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_surface_v0, _abi0, height); 393bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_surface_v0, _abi0, format); 394bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_surface_v0, _abi0, flags); 395bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_surface_v0, _abi0, modifiers); 396bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_surface_v0, _abi0, count); 397bf215546Sopenharmony_ci 398bf215546Sopenharmony_ci /* Size of ABI-versioned substructures verified by above member checks */ 399bf215546Sopenharmony_ci CHECK_SIZE_CURRENT (gbm_surface, _abi0); 400bf215546Sopenharmony_ci 401bf215546Sopenharmony_ci 402bf215546Sopenharmony_ci /* Check current gbm_backend ABI against gbm_backend_abi0 */ 403bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT_NO_TYPE(gbm_backend, _abi0, v0); 404bf215546Sopenharmony_ci 405bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_backend_v0, _abi0, backend_version); 406bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_backend_v0, _abi0, backend_name); 407bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_backend_v0, _abi0, create_device); 408bf215546Sopenharmony_ci 409bf215546Sopenharmony_ci /* Size of ABI-versioned substructures verified by above member checks */ 410bf215546Sopenharmony_ci CHECK_SIZE_CURRENT (gbm_backend, _abi0); 411bf215546Sopenharmony_ci 412bf215546Sopenharmony_ci 413bf215546Sopenharmony_ci /* Check current gbm_core ABI against gbm_core_abi0 */ 414bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT_NO_TYPE(gbm_core, _abi0, v0); 415bf215546Sopenharmony_ci 416bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_core_v0, _abi0, core_version); 417bf215546Sopenharmony_ci CHECK_MEMBER_CURRENT(gbm_core_v0, _abi0, format_canonicalize); 418bf215546Sopenharmony_ci 419bf215546Sopenharmony_ci /* Size of ABI-versioned substructures verified by above member checks */ 420bf215546Sopenharmony_ci CHECK_SIZE_CURRENT (gbm_core, _abi0); 421bf215546Sopenharmony_ci 422bf215546Sopenharmony_ci 423bf215546Sopenharmony_ci CHECK_PROC_CURRENT (GBM_GET_BACKEND_PROC_PTR, _abi0); 424bf215546Sopenharmony_ci 425bf215546Sopenharmony_ci return 0; 426bf215546Sopenharmony_ci} 427