1 #include "pipe/p_context.h"
2 #include "pipe/p_util.h"
3 #include "nouveau_context.h"
4 #include "nouveau_drm.h"
5 #include "nouveau_dri.h"
6 #include "nouveau_local.h"
7 #include "nouveau_screen.h"
8 #include "nouveau_swapbuffers.h"
10 #if NOUVEAU_DRM_HEADER_PATCHLEVEL != 11
11 #error nouveau_drm.h version does not match expected version
15 PUBLIC const char __driConfigOptions[] =
18 static const GLuint __driNConfigOptions = 0;
22 nouveau_screen_create(dri_screen_t
*dri_screen
, dri_framebuffer_t
*dri_framebuf
)
24 /* XXX: Someone forgot to bump this? */
25 static const dri_version_t ddx_expected
= {0, 0, 10 /*NOUVEAU_DRM_HEADER_PATCHLEVEL*/};
26 static const dri_version_t dri_expected
= {4, 1, 0};
27 static const dri_version_t drm_expected
= {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL
};
29 struct nouveau_dri
*nv_dri
= dri_framebuf
->private;
30 struct nouveau_screen
*nv_screen
;
33 if (!driCompareVersions(&ddx_expected
, &dri_screen
->ddx
))
35 NOUVEAU_ERR("Unexpected DDX version.\n");
39 if (!driCompareVersions(&drm_expected
, &dri_screen
->drm
))
41 NOUVEAU_ERR("Unexpected DRM version.\n");
45 if (!driCompareVersions(&dri_expected
, &dri_screen
->dri
))
47 NOUVEAU_ERR("Unexpected DRI version.\n");
51 if (dri_framebuf
->private_size
!= sizeof(struct nouveau_dri
)) {
52 NOUVEAU_ERR("DRI struct mismatch between DDX/DRI.\n");
56 nv_screen
= CALLOC_STRUCT(nouveau_screen
);
59 nv_screen
->dri_screen
= dri_screen
;
60 dri_screen
->private = (void*)nv_screen
;
63 driParseOptionInfo(&nv_screen->option_cache,
64 __driConfigOptions, __driNConfigOptions);
67 if ((ret
= nouveau_device_open_existing(&nv_screen
->device
, 0,
68 dri_screen
->fd
, 0))) {
69 NOUVEAU_ERR("Failed opening nouveau device: %d.\n", ret
);
73 nv_screen
->front_offset
= nv_dri
->front_offset
;
74 nv_screen
->front_pitch
= nv_dri
->front_pitch
* (nv_dri
->bpp
/ 8);
75 nv_screen
->front_cpp
= nv_dri
->bpp
/ 8;
76 nv_screen
->front_height
= nv_dri
->height
;
82 nouveau_screen_destroy(dri_screen_t
*dri_screen
)
84 struct nouveau_screen
*nv_screen
= dri_screen
->private;