1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright © 2011 Intel Corporation
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the "Software"),
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to deal in the Software without restriction, including without limitation
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and/or sell copies of the Software, and to permit persons to whom the
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Software is furnished to do so, subject to the following conditions:
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the next
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * paragraph) shall be included in all copies or substantial portions of the
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Software.
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * DEALINGS IN THE SOFTWARE.
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Authors:
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *    Benjamin Franzke <benjaminfranzke@googlemail.com>
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef _GBM_DRI_INTERNAL_H_
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _GBM_DRI_INTERNAL_H_
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gbmint.h"
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "common.h"
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "common_drm.h"
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include <GL/gl.h> /* dri_interface needs GL types */
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "GL/internal/dri_interface.h"
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gbm_dri_surface;
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gbm_dri_device {
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct gbm_drm_device base;
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *driver;
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIscreen *screen;
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIcoreExtension   *core;
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIdri2Extension   *dri2;
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIimageExtension  *image;
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRI2flushExtension *flush;
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIdri2LoaderExtension *loader;
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   const __DRIconfig   **driver_configs;
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   const __DRIextension *extensions[4];
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIimage *(*lookup_image)(__DRIscreen *screen, void *image, void *data);
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *lookup_user_data;
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIbuffer *(*get_buffers)(__DRIdrawable * driDrawable,
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               int *width, int *height,
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               unsigned int *attachments, int count,
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               int *out_count, void *data);
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void (*flush_front_buffer)(__DRIdrawable * driDrawable, void *data);
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIbuffer *(*get_buffers_with_format)(__DRIdrawable * driDrawable,
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     int *width, int *height,
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     unsigned int *attachments, int count,
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org			     int *out_count, void *data);
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gbm_dri_bo {
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct gbm_drm_bo base;
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   __DRIimage *image;
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /* Only used for cursors */
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint32_t handle, size;
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *map;
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gbm_dri_surface {
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct gbm_surface base;
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *dri_private;
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic inline struct gbm_dri_device *
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orggbm_dri_device(struct gbm_device *gbm)
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return (struct gbm_dri_device *) gbm;
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic inline struct gbm_dri_bo *
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orggbm_dri_bo(struct gbm_bo *bo)
95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return (struct gbm_dri_bo *) bo;
97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic inline struct gbm_dri_surface *
100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orggbm_dri_surface(struct gbm_surface *surface)
101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return (struct gbm_dri_surface *) surface;
103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgchar *
106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdri_fd_get_driver_name(int fd);
107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
109