b7c74f8299bd0151f71df18f6107ae85e43136cb
[mesa.git] / src / gallium / winsys / g3dvl / nouveau / nouveau_screen_vl.c
1 #include "nouveau_screen_vl.h"
2 #include <util/u_memory.h>
3 #include <nouveau_drm.h>
4 #include <common/nouveau_dri.h>
5 #include <common/nouveau_local.h>
6
7 #if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12
8 #error nouveau_drm.h version does not match expected version
9 #endif
10
11 /*
12 PUBLIC const char __driConfigOptions[] =
13 DRI_CONF_BEGIN
14 DRI_CONF_END;
15 static const GLuint __driNConfigOptions = 0;
16 */
17
18 int nouveau_check_dri_drm_ddx(dri_version_t *dri, dri_version_t *drm, dri_version_t *ddx)
19 {
20 static const dri_version_t ddx_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
21 static const dri_version_t dri_expected = {4, 0, 0};
22 static const dri_version_t drm_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
23
24 assert(dri);
25 assert(drm);
26 assert(ddx);
27
28 if (dri->major != dri_expected.major || dri->minor < dri_expected.minor)
29 {
30 NOUVEAU_ERR("Unexpected DRI version.\n");
31 return 1;
32 }
33 if (drm->major != drm_expected.major || drm->minor < drm_expected.minor)
34 {
35 NOUVEAU_ERR("Unexpected DRM version.\n");
36 return 1;
37 }
38 if (ddx->major != ddx_expected.major || ddx->minor < ddx_expected.minor)
39 {
40 NOUVEAU_ERR("Unexpected DDX version.\n");
41 return 1;
42 }
43
44 return 0;
45 }
46
47 int
48 nouveau_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf)
49 {
50 struct nouveau_dri *nv_dri = dri_framebuf->private;
51 struct nouveau_screen_vl *nv_screen;
52
53 assert(dri_screen);
54 assert(dri_framebuf);
55
56 if (nouveau_check_dri_drm_ddx(&dri_screen->dri, &dri_screen->drm, &dri_screen->ddx))
57 return 1;
58
59 nv_screen = CALLOC_STRUCT(nouveau_screen_vl);
60
61 if (!nv_screen)
62 return 1;
63
64 if (nouveau_screen_init(nv_dri, dri_screen->fd, &nv_screen->base))
65 {
66 FREE(nv_screen);
67 return 1;
68 }
69
70 /*
71 driParseOptionInfo(&nv_screen->option_cache,
72 __driConfigOptions, __driNConfigOptions);
73 */
74
75 nv_screen->dri_screen = dri_screen;
76 dri_screen->private = (void*)nv_screen;
77
78 return 0;
79 }
80
81 void
82 nouveau_screen_destroy(dri_screen_t *dri_screen)
83 {
84 struct nouveau_screen_vl *nv_screen = dri_screen->private;
85
86 nouveau_screen_cleanup(&nv_screen->base);
87 FREE(nv_screen);
88 }