1848b8605Smrg/* 2848b8605Smrg * Copyright © 2011 Intel Corporation 3848b8605Smrg * 4848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5848b8605Smrg * copy of this software and associated documentation files (the "Software"), 6848b8605Smrg * to deal in the Software without restriction, including without limitation 7848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the 9848b8605Smrg * Software is furnished to do so, subject to the following conditions: 10848b8605Smrg * 11848b8605Smrg * The above copyright notice and this permission notice (including the next 12848b8605Smrg * paragraph) shall be included in all copies or substantial portions of the 13848b8605Smrg * Software. 14848b8605Smrg * 15848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16848b8605Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18848b8605Smrg * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19848b8605Smrg * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20848b8605Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21848b8605Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22848b8605Smrg * DEALINGS IN THE SOFTWARE. 23848b8605Smrg * 24848b8605Smrg * Authors: 25848b8605Smrg * Benjamin Franzke <benjaminfranzke@googlemail.com> 26848b8605Smrg */ 27848b8605Smrg 28848b8605Smrg#ifndef INTERNAL_H_ 29848b8605Smrg#define INTERNAL_H_ 30848b8605Smrg 31848b8605Smrg#include "gbm.h" 32848b8605Smrg#include <sys/stat.h> 33848b8605Smrg 34848b8605Smrg/* GCC visibility */ 35b8e80941Smrg#if defined(__GNUC__) 36848b8605Smrg#define GBM_EXPORT __attribute__ ((visibility("default"))) 37848b8605Smrg#else 38848b8605Smrg#define GBM_EXPORT 39848b8605Smrg#endif 40848b8605Smrg 41848b8605Smrg/** 42848b8605Smrg * \file gbmint.h 43848b8605Smrg * \brief Internal implementation details of gbm 44848b8605Smrg */ 45848b8605Smrg 46848b8605Smrg/** 47848b8605Smrg * The device used for the memory allocation. 48848b8605Smrg * 49848b8605Smrg * The members of this structure should be not accessed directly 50848b8605Smrg */ 51848b8605Smrgstruct gbm_device { 52848b8605Smrg /* Hack to make a gbm_device detectable by its first element. */ 53848b8605Smrg struct gbm_device *(*dummy)(int); 54848b8605Smrg 55848b8605Smrg int fd; 56848b8605Smrg const char *name; 57848b8605Smrg unsigned int refcount; 58848b8605Smrg struct stat stat; 59848b8605Smrg 60848b8605Smrg void (*destroy)(struct gbm_device *gbm); 61848b8605Smrg int (*is_format_supported)(struct gbm_device *gbm, 62848b8605Smrg uint32_t format, 63848b8605Smrg uint32_t usage); 64b8e80941Smrg int (*get_format_modifier_plane_count)(struct gbm_device *device, 65b8e80941Smrg uint32_t format, 66b8e80941Smrg uint64_t modifier); 67848b8605Smrg 68848b8605Smrg struct gbm_bo *(*bo_create)(struct gbm_device *gbm, 69848b8605Smrg uint32_t width, uint32_t height, 70848b8605Smrg uint32_t format, 71b8e80941Smrg uint32_t usage, 72b8e80941Smrg const uint64_t *modifiers, 73b8e80941Smrg const unsigned int count); 74848b8605Smrg struct gbm_bo *(*bo_import)(struct gbm_device *gbm, uint32_t type, 75848b8605Smrg void *buffer, uint32_t usage); 76b8e80941Smrg void *(*bo_map)(struct gbm_bo *bo, 77b8e80941Smrg uint32_t x, uint32_t y, 78b8e80941Smrg uint32_t width, uint32_t height, 79b8e80941Smrg uint32_t flags, uint32_t *stride, 80b8e80941Smrg void **map_data); 81b8e80941Smrg void (*bo_unmap)(struct gbm_bo *bo, void *map_data); 82848b8605Smrg int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data); 83848b8605Smrg int (*bo_get_fd)(struct gbm_bo *bo); 84b8e80941Smrg int (*bo_get_planes)(struct gbm_bo *bo); 85b8e80941Smrg union gbm_bo_handle (*bo_get_handle)(struct gbm_bo *bo, int plane); 86b8e80941Smrg uint32_t (*bo_get_stride)(struct gbm_bo *bo, int plane); 87b8e80941Smrg uint32_t (*bo_get_offset)(struct gbm_bo *bo, int plane); 88b8e80941Smrg uint64_t (*bo_get_modifier)(struct gbm_bo *bo); 89848b8605Smrg void (*bo_destroy)(struct gbm_bo *bo); 90848b8605Smrg 91848b8605Smrg struct gbm_surface *(*surface_create)(struct gbm_device *gbm, 92848b8605Smrg uint32_t width, uint32_t height, 93b8e80941Smrg uint32_t format, uint32_t flags, 94b8e80941Smrg const uint64_t *modifiers, 95b8e80941Smrg const unsigned count); 96848b8605Smrg struct gbm_bo *(*surface_lock_front_buffer)(struct gbm_surface *surface); 97848b8605Smrg void (*surface_release_buffer)(struct gbm_surface *surface, 98848b8605Smrg struct gbm_bo *bo); 99848b8605Smrg int (*surface_has_free_buffers)(struct gbm_surface *surface); 100848b8605Smrg void (*surface_destroy)(struct gbm_surface *surface); 101848b8605Smrg}; 102848b8605Smrg 103848b8605Smrg/** 104848b8605Smrg * The allocated buffer object. 105848b8605Smrg * 106848b8605Smrg * The members in this structure should not be accessed directly. 107848b8605Smrg */ 108848b8605Smrgstruct gbm_bo { 109848b8605Smrg struct gbm_device *gbm; 110848b8605Smrg uint32_t width; 111848b8605Smrg uint32_t height; 112848b8605Smrg uint32_t stride; 113848b8605Smrg uint32_t format; 114848b8605Smrg union gbm_bo_handle handle; 115848b8605Smrg void *user_data; 116848b8605Smrg void (*destroy_user_data)(struct gbm_bo *, void *); 117848b8605Smrg}; 118848b8605Smrg 119848b8605Smrgstruct gbm_surface { 120848b8605Smrg struct gbm_device *gbm; 121848b8605Smrg uint32_t width; 122848b8605Smrg uint32_t height; 123848b8605Smrg uint32_t format; 124848b8605Smrg uint32_t flags; 125b8e80941Smrg struct { 126b8e80941Smrg uint64_t *modifiers; 127b8e80941Smrg unsigned count; 128b8e80941Smrg }; 129848b8605Smrg}; 130848b8605Smrg 131848b8605Smrgstruct gbm_backend { 132848b8605Smrg const char *backend_name; 133848b8605Smrg struct gbm_device *(*create_device)(int fd); 134848b8605Smrg}; 135848b8605Smrg 136b8e80941Smrguint32_t 137b8e80941Smrggbm_format_canonicalize(uint32_t gbm_format); 138848b8605Smrg 139848b8605Smrg#endif 140