summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/dri/dri_screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/dri/dri_screen.c')
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.c87
1 files changed, 74 insertions, 13 deletions
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index ab33003..418bb90 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -40,7 +40,9 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "pipe/p_inlines.h"
+#include "pipe/p_format.h"
#include "state_tracker/drm_api.h"
+#include "state_tracker/dri1_api.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_cb_fbo.h"
@@ -57,7 +59,6 @@ PUBLIC const char __driConfigOptions[] =
const uint __driNConfigOptions = 3;
-
static const __DRIextension *dri_screen_extensions[] = {
&driReadDrawableExtension,
&driCopySubBufferExtension.base,
@@ -67,6 +68,8 @@ static const __DRIextension *dri_screen_extensions[] = {
NULL
};
+struct dri1_api *__dri1_api_hooks = NULL;
+
static const __DRIconfig **
dri_fill_in_modes(__DRIscreenPrivate *psp,
unsigned pixel_bits, unsigned depth_bits,
@@ -139,7 +142,7 @@ dri_fill_in_modes(__DRIscreenPrivate *psp,
/**
* Get information about previous buffer swaps.
*/
-int
+static int
dri_get_swap_info(__DRIdrawablePrivate * dPriv,
__DRIswapInfo * sInfo)
{
@@ -151,13 +154,69 @@ dri_get_swap_info(__DRIdrawablePrivate * dPriv,
return 0;
}
+static INLINE void
+dri_copy_version(struct dri1_api_version *dst,
+ const struct __DRIversionRec *src)
+{
+ dst->major = src->major;
+ dst->minor = src->minor;
+ dst->patch_level = src->patch;
+}
-/**
- * NULL stub for old dri loaders
- */
-const __DRIconfig **
+static const __DRIconfig **
dri_init_screen(__DRIscreenPrivate *sPriv)
{
+ struct dri_screen *screen;
+ const __DRIconfig **configs;
+ struct dri1_create_screen_arg arg;
+
+ dri_init_extensions(NULL);
+
+ screen = CALLOC_STRUCT(dri_screen);
+ if (!screen)
+ return NULL;
+
+ screen->sPriv = sPriv;
+ screen->fd = sPriv->fd;
+ screen->drmLock = (drmLock *) &sPriv->pSAREA->lock;
+
+ sPriv->private = (void *) screen;
+ sPriv->extensions = dri_screen_extensions;
+
+ arg.base.mode = DRM_CREATE_DRI1;
+ arg.lf = &dri1_lf;
+ arg.ddx_info = sPriv->pDevPriv;
+ arg.ddx_info_size = sPriv->devPrivSize;
+ arg.sarea = sPriv->pSAREA;
+ dri_copy_version(&arg.ddx_version, &sPriv->ddx_version);
+ dri_copy_version(&arg.dri_version, &sPriv->dri_version);
+ dri_copy_version(&arg.drm_version, &sPriv->drm_version);
+ arg.api = NULL;
+
+ screen->pipe_screen = drm_api_hooks.create_screen
+ (screen->fd, &arg.base);
+
+ if (!screen->pipe_screen || !arg.api) {
+ debug_printf("%s: failed to create dri1 screen\n", __FUNCTION__);
+ goto out_no_screen;
+ }
+
+ __dri1_api_hooks = arg.api;
+
+ screen->pipe_screen->flush_frontbuffer = dri1_flush_frontbuffer;
+ driParseOptionInfo(&screen->optionCache,
+ __driConfigOptions,
+ __driNConfigOptions);
+
+ configs = dri_fill_in_modes(sPriv, sPriv->fbBPP, 24, 8, 1);
+ if (!configs)
+ goto out_no_configs;
+
+ return configs;
+ out_no_configs:
+ screen->pipe_screen->destroy(screen->pipe_screen);
+ out_no_screen:
+ FREE(screen);
return NULL;
}
@@ -167,10 +226,11 @@ dri_init_screen(__DRIscreenPrivate *sPriv)
*
* Returns the __GLcontextModes supported by this driver.
*/
-const __DRIconfig **
+static const __DRIconfig **
dri_init_screen2(__DRIscreenPrivate *sPriv)
{
struct dri_screen *screen;
+ struct drm_create_screen_arg arg;
/* Set up dispatch table to cope with all known extensions */
dri_init_extensions(NULL);
@@ -183,9 +243,9 @@ dri_init_screen2(__DRIscreenPrivate *sPriv)
screen->fd = sPriv->fd;
sPriv->private = (void *) screen;
sPriv->extensions = dri_screen_extensions;
+ arg.mode = DRM_CREATE_NORMAL;
-
- screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL);
+ screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, &arg);
if (!screen->pipe_screen) {
debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
goto fail;
@@ -208,7 +268,7 @@ fail:
}
-void
+static void
dri_destroy_screen(__DRIscreenPrivate * sPriv)
{
struct dri_screen *screen = dri_screen(sPriv);
@@ -220,19 +280,20 @@ dri_destroy_screen(__DRIscreenPrivate * sPriv)
PUBLIC const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = dri_init_screen, /* not supported but exported */
+ .InitScreen = dri_init_screen,
.DestroyScreen = dri_destroy_screen,
.CreateContext = dri_create_context,
.DestroyContext = dri_destroy_context,
.CreateBuffer = dri_create_buffer,
.DestroyBuffer = dri_destroy_buffer,
- .SwapBuffers = dri_swap_buffers, /* not supported but exported */
+ .SwapBuffers = dri_swap_buffers,
.MakeCurrent = dri_make_current,
.UnbindContext = dri_unbind_context,
.GetSwapInfo = dri_get_swap_info,
.GetDrawableMSC = driDrawableGetMSC32,
.WaitForMSC = driWaitForMSC32,
- .CopySubBuffer = dri_copy_sub_buffer, /* not supported but exported */
+ .CopySubBuffer = dri_copy_sub_buffer,
+ .InitScreen = dri_init_screen,
.InitScreen2 = dri_init_screen2,
};