amdgpu_glamor.h revision 90f2b693
1/*
2 * Copyright © 2011 Intel Corporation.
3 *             2012 Advanced Micro Devices, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use, copy,
9 * modify, merge, publish, distribute, sublicense, and/or sell copies
10 * of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including
14 * the next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
26
27#ifndef AMDGPU_GLAMOR_H
28#define AMDGPU_GLAMOR_H
29
30#include "xf86xv.h"
31
32#ifdef USE_GLAMOR
33
34#define GLAMOR_FOR_XORG  1
35#include <glamor.h>
36
37#define AMDGPU_CREATE_PIXMAP_SHARED(usage) \
38	((usage) == AMDGPU_CREATE_PIXMAP_DRI2 || \
39	 (usage) == CREATE_PIXMAP_USAGE_SHARED)
40
41#ifndef GLAMOR_NO_DRI3
42#define GLAMOR_NO_DRI3 0
43#define glamor_fd_from_pixmap glamor_dri3_fd_from_pixmap
44#define glamor_pixmap_from_fd glamor_egl_dri3_pixmap_from_fd
45#endif
46
47#ifndef GLAMOR_INVERTED_Y_AXIS
48#define GLAMOR_INVERTED_Y_AXIS 0
49#endif
50#ifndef GLAMOR_USE_SCREEN
51#define GLAMOR_USE_SCREEN 0
52#endif
53#ifndef GLAMOR_USE_PICTURE_SCREEN
54#define GLAMOR_USE_PICTURE_SCREEN 0
55#endif
56
57struct amdgpu_pixmap;
58
59Bool amdgpu_glamor_pre_init(ScrnInfoPtr scrn);
60Bool amdgpu_glamor_init(ScreenPtr screen);
61void amdgpu_glamor_fini(ScreenPtr screen);
62void amdgpu_glamor_screen_init(ScreenPtr screen);
63Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen);
64void amdgpu_glamor_free_screen(int scrnIndex, int flags);
65
66void amdgpu_glamor_flush(ScrnInfoPtr pScrn);
67void amdgpu_glamor_finish(ScrnInfoPtr pScrn);
68
69Bool
70amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_buffer *bo);
71void amdgpu_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst);
72PixmapPtr amdgpu_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap);
73
74XF86VideoAdaptorPtr amdgpu_glamor_xv_init(ScreenPtr pScreen, int num_adapt);
75
76#else /* !USE_GLAMOR */
77
78static inline Bool amdgpu_glamor_pre_init(ScrnInfoPtr scrn) { return FALSE; }
79static inline Bool amdgpu_glamor_init(ScreenPtr screen) { return FALSE; }
80static inline void amdgpu_glamor_fini(ScreenPtr screen) { }
81static inline Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen) { return FALSE; }
82
83static inline Bool amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_buffer *bo) { return TRUE; }
84
85static inline void amdgpu_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {}
86static inline PixmapPtr amdgpu_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap) { return pixmap; }
87
88static inline XF86VideoAdaptorPtr amdgpu_glamor_xv_init(ScreenPtr pScreen, int num_adapt) { return NULL; }
89
90static inline void amdgpu_glamor_flush(ScrnInfoPtr pScrn) { }
91static inline void amdgpu_glamor_finish(ScrnInfoPtr pScrn) { }
92
93#endif /* USE_GLAMOR */
94
95#endif /* AMDGPU_GLAMOR_H */
96