1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
37 #include "pipe/p_screen.h"
38 #include "pipe/p_context.h"
40 #include "st_winsys.h"
42 #include "radeon_winsys.h"
47 /* XXX: Force init_gallium symbol to be linked */
48 extern void init_gallium(void);
49 void (*force_init_gallium_linkage
)(void) = &init_gallium
;
52 static struct pipe_screen
*
53 radeon_hardpipe_screen_create(void)
57 XWindowAttributes winAttr
;
66 drm_handle_t sAreaOffset
;
69 drm_context_t hHWContext
;
72 dpy
= XOpenDisplay(":0");
74 fprintf(stderr
, "Open Display Failed\n");
78 screen
= DefaultScreen(dpy
);
79 rootWin
= RootWindow(dpy
, screen
);
80 XGetWindowAttributes(dpy
, rootWin
, &winAttr
);
82 ret
= uniDRIQueryDirectRenderingCapable(dpy
, screen
, &isCapable
);
83 if (!ret
|| !isCapable
) {
84 fprintf(stderr
, "No DRI on this display:sceen\n");
88 if (!uniDRIOpenConnection(dpy
, screen
, &sAreaOffset
,
90 fprintf(stderr
, "Could not open DRI connection.\n");
94 if (!uniDRIGetClientDriverName(dpy
, screen
, &ddxDriverMajor
,
95 &ddxDriverMinor
, &ddxDriverPatch
,
97 fprintf(stderr
, "Could not get DRI driver name.\n");
101 if ((drmFD
= drmOpen(NULL
, curBusID
)) < 0) {
102 perror("DRM Device could not be opened");
106 drmGetMagic(drmFD
, &magic
);
107 if (!uniDRIAuthConnection(dpy
, screen
, magic
)) {
108 fprintf(stderr
, "Could not get X server to authenticate us.\n");
112 if (!uniDRICreateContext(dpy
, screen
, winAttr
.visual
,
114 fprintf(stderr
, "Could not create DRI context.\n");
118 /* FIXME: create a radeon pipe_screen from drmFD and hHWContext */
129 const struct st_winsys st_hardpipe_winsys
= {
130 &radeon_hardpipe_screen_create
,