radeon_glamor.h revision de2362d3
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 RADEON_GLAMOR_H
28#define RADEON_GLAMOR_H
29
30#include "xf86xv.h"
31#ifdef USE_GLAMOR
32
33#include "radeon_surface.h"
34
35Bool radeon_glamor_pre_init(ScrnInfoPtr scrn);
36Bool radeon_glamor_init(ScreenPtr screen);
37Bool radeon_glamor_create_screen_resources(ScreenPtr screen);
38void radeon_glamor_free_screen(int scrnIndex, int flags);
39
40void radeon_glamor_flush(ScrnInfoPtr pScrn);
41
42Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap);
43void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst);
44
45Bool radeon_glamor_pixmap_is_offscreen(PixmapPtr pixmap);
46
47XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt);
48
49struct radeon_pixmap {
50	struct radeon_surface surface;
51	struct radeon_bo *bo;
52
53	uint32_t tiling_flags;
54	int stride;
55};
56
57#if HAS_DEVPRIVATEKEYREC
58extern DevPrivateKeyRec glamor_pixmap_index;
59#else
60extern int glamor_pixmap_index;
61#endif
62
63static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap)
64{
65#if HAS_DEVPRIVATEKEYREC
66	return dixGetPrivate(&pixmap->devPrivates, &glamor_pixmap_index);
67#else
68	return dixLookupPrivate(&pixmap->devPrivates, &glamor_pixmap_index);
69#endif
70}
71
72static inline void radeon_set_pixmap_private(PixmapPtr pixmap, struct radeon_pixmap *priv)
73{
74	dixSetPrivate(&pixmap->devPrivates, &glamor_pixmap_index, priv);
75}
76
77#else
78
79static inline Bool radeon_glamor_pre_init(ScrnInfoPtr scrn) { return FALSE; }
80static inline Bool radeon_glamor_init(ScreenPtr screen) { return FALSE; }
81static inline Bool radeon_glamor_create_screen_resources(ScreenPtr screen) { return FALSE; }
82static inline void radeon_glamor_free_screen(int scrnIndex, int flags) { }
83
84static inline void radeon_glamor_flush(ScrnInfoPtr pScrn) { }
85
86static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap) { return TRUE; }
87
88static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {}
89
90static inline Bool radeon_glamor_pixmap_is_offscreen(PixmapPtr pixmap) { return FALSE; }
91
92static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) { return NULL; }
93
94static inline XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt) { return NULL; }
95#endif
96
97#endif /* RADEON_GLAMOR_H */
98