1/*
2 * Copyright 2011 VMWare, Inc.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 * Author: Thomas Hellstrom <thellstrom@vmware.com>
26 */
27#ifndef _VMWGFX_SAA_PRIV_H_
28#define _VMWGFX_SAA_PRIV_H_
29
30#define VMWGFX_PIX_MALLOC  (1 << 0)
31#define VMWGFX_PIX_GMR     (1 << 1)
32#define VMWGFX_PIX_SURFACE (1 << 2)
33
34#include <xorg-server.h>
35#include <picturestr.h>
36#include "vmwgfx_saa.h"
37
38struct vmwgfx_saa {
39    struct saa_driver driver;
40    struct vmwgfx_dma_ctx *ctx;
41    struct xa_tracker *xat;
42    struct xa_context *xa_ctx;
43    ScreenPtr pScreen;
44    int drm_fd;
45    struct vmwgfx_saa_pixmap *src_vpix;
46    struct vmwgfx_saa_pixmap *dst_vpix;
47    Bool present_copy;
48    Bool diff_valid;
49    int xdiff;
50    int ydiff;
51    RegionRec present_region;
52    uint32_t src_handle;
53    Bool can_optimize_dma;
54    Bool use_present_opt;
55    Bool only_hw_presents;
56    Bool rendercheck;
57    Bool is_master;
58    Bool known_prime_format;
59    Bool has_screen_targets;
60    void (*present_flush) (ScreenPtr pScreen);
61    struct _WsbmListHead sync_x_list;
62    struct _WsbmListHead pixmaps;
63    struct vmwgfx_composite *vcomp;
64};
65
66static inline struct vmwgfx_saa *
67to_vmwgfx_saa(struct saa_driver *driver) {
68    return (struct vmwgfx_saa *) driver;
69}
70
71/*
72 * In vmwgfx_saa.c
73 */
74
75Bool
76vmwgfx_hw_kill(struct vmwgfx_saa *vsaa,
77	       struct saa_pixmap *spix);
78Bool
79vmwgfx_create_hw(struct vmwgfx_saa *vsaa,
80		 PixmapPtr pixmap,
81		 Bool shared);
82
83
84/*
85 * vmwgfx_xa_surface.c
86 */
87
88enum xa_formats
89vmwgfx_xa_format(enum _PictFormatShort format);
90Bool
91vmwgfx_hw_validate(PixmapPtr pixmap, RegionPtr region);
92Bool
93vmwgfx_hw_dri2_stage(PixmapPtr pixmap, unsigned int depth);
94Bool
95vmwgfx_hw_accel_stage(PixmapPtr pixmap, unsigned int depth,
96		      uint32_t add_flags, uint32_t remove_flags);
97Bool
98vmwgfx_hw_composite_src_stage(PixmapPtr pixmap,
99			      enum _PictFormatShort pict_format);
100Bool
101vmwgfx_hw_composite_dst_stage(PixmapPtr pixmap,
102			      enum _PictFormatShort pict_format);
103Bool
104vmwgfx_hw_commit(PixmapPtr pixmap);
105
106Bool
107vmwgfx_xa_surface_redefine(struct vmwgfx_saa_pixmap *vpix,
108			   struct xa_surface *srf,
109			   int width,
110			   int height,
111			   int depth,
112			   enum xa_surface_type stype,
113			   enum xa_formats rgb_format,
114			   unsigned int new_flags,
115			   int copy_contents);
116
117/*
118 * vmwgfx_xa_composite.c
119 */
120
121struct vmwgfx_composite;
122
123void
124vmwgfx_free_composite(struct vmwgfx_composite *vcomp);
125struct vmwgfx_composite *
126vmwgfx_alloc_composite(void);
127
128Bool
129vmwgfx_xa_update_comp(struct xa_composite *comp,
130		      PixmapPtr src_pix,
131		      PixmapPtr mask_pix,
132		      PixmapPtr dst_pix);
133
134struct xa_composite *
135vmwgfx_xa_setup_comp(struct vmwgfx_composite *vcomp,
136		     int op,
137		     PicturePtr src_pict,
138		     PicturePtr mask_pict,
139		     PicturePtr dst_pict);
140
141
142#endif
143