gbmint.h revision 848b8605
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 */
35848b8605Smrg#if defined(__GNUC__) && __GNUC__ >= 4
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);
64848b8605Smrg
65848b8605Smrg   struct gbm_bo *(*bo_create)(struct gbm_device *gbm,
66848b8605Smrg                               uint32_t width, uint32_t height,
67848b8605Smrg                               uint32_t format,
68848b8605Smrg                               uint32_t usage);
69848b8605Smrg   struct gbm_bo *(*bo_import)(struct gbm_device *gbm, uint32_t type,
70848b8605Smrg                               void *buffer, uint32_t usage);
71848b8605Smrg   int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);
72848b8605Smrg   int (*bo_get_fd)(struct gbm_bo *bo);
73848b8605Smrg   void (*bo_destroy)(struct gbm_bo *bo);
74848b8605Smrg
75848b8605Smrg   struct gbm_surface *(*surface_create)(struct gbm_device *gbm,
76848b8605Smrg                                         uint32_t width, uint32_t height,
77848b8605Smrg                                         uint32_t format, uint32_t flags);
78848b8605Smrg   struct gbm_bo *(*surface_lock_front_buffer)(struct gbm_surface *surface);
79848b8605Smrg   void (*surface_release_buffer)(struct gbm_surface *surface,
80848b8605Smrg                                  struct gbm_bo *bo);
81848b8605Smrg   int (*surface_has_free_buffers)(struct gbm_surface *surface);
82848b8605Smrg   void (*surface_destroy)(struct gbm_surface *surface);
83848b8605Smrg};
84848b8605Smrg
85848b8605Smrg/**
86848b8605Smrg * The allocated buffer object.
87848b8605Smrg *
88848b8605Smrg * The members in this structure should not be accessed directly.
89848b8605Smrg */
90848b8605Smrgstruct gbm_bo {
91848b8605Smrg   struct gbm_device *gbm;
92848b8605Smrg   uint32_t width;
93848b8605Smrg   uint32_t height;
94848b8605Smrg   uint32_t stride;
95848b8605Smrg   uint32_t format;
96848b8605Smrg   union gbm_bo_handle  handle;
97848b8605Smrg   void *user_data;
98848b8605Smrg   void (*destroy_user_data)(struct gbm_bo *, void *);
99848b8605Smrg};
100848b8605Smrg
101848b8605Smrgstruct gbm_surface {
102848b8605Smrg   struct gbm_device *gbm;
103848b8605Smrg   uint32_t width;
104848b8605Smrg   uint32_t height;
105848b8605Smrg   uint32_t format;
106848b8605Smrg   uint32_t flags;
107848b8605Smrg};
108848b8605Smrg
109848b8605Smrgstruct gbm_backend {
110848b8605Smrg   const char *backend_name;
111848b8605Smrg   struct gbm_device *(*create_device)(int fd);
112848b8605Smrg};
113848b8605Smrg
114848b8605Smrgstruct gbm_device *
115848b8605Smrg_gbm_mesa_get_device(int fd);
116848b8605Smrg
117848b8605Smrg#endif
118