1 #include "pipe/p_context.h"
2 #include "util/u_memory.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;
21 int nouveau_check_dri_drm_ddx(dri_version_t
*dri
, dri_version_t
*drm
, dri_version_t
*ddx
)
23 static const dri_version_t ddx_expected
= {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL
};
24 static const dri_version_t dri_expected
= {4, 0, 0};
25 static const dri_version_t drm_expected
= {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL
};
31 if (dri
->major
!= dri_expected
.major
|| dri
->minor
< dri_expected
.minor
)
33 NOUVEAU_ERR("Unexpected DRI version.\n");
36 if (drm
->major
!= drm_expected
.major
|| drm
->minor
< drm_expected
.minor
)
38 NOUVEAU_ERR("Unexpected DRM version.\n");
41 if (ddx
->major
!= ddx_expected
.major
|| ddx
->minor
< ddx_expected
.minor
)
43 NOUVEAU_ERR("Unexpected DDX version.\n");
51 nouveau_screen_create(dri_screen_t
*dri_screen
, dri_framebuffer_t
*dri_framebuf
)
53 struct nouveau_dri
*nv_dri
= dri_framebuf
->private;
54 struct nouveau_screen
*nv_screen
;
57 if (nouveau_check_dri_drm_ddx(&dri_screen
->dri
, &dri_screen
->drm
, &dri_screen
->ddx
))
60 nv_screen
= CALLOC_STRUCT(nouveau_screen
);
63 nv_screen
->dri_screen
= dri_screen
;
64 dri_screen
->private = (void*)nv_screen
;
67 driParseOptionInfo(&nv_screen->option_cache,
68 __driConfigOptions, __driNConfigOptions);
71 if ((ret
= nouveau_device_open_existing(&nv_screen
->device
, 0,
72 dri_screen
->fd
, 0))) {
73 NOUVEAU_ERR("Failed opening nouveau device: %d.\n", ret
);
77 nv_screen
->front_offset
= nv_dri
->front_offset
;
78 nv_screen
->front_pitch
= nv_dri
->front_pitch
* (nv_dri
->bpp
/ 8);
79 nv_screen
->front_cpp
= nv_dri
->bpp
/ 8;
80 nv_screen
->front_height
= nv_dri
->height
;
86 nouveau_screen_destroy(dri_screen_t
*dri_screen
)
88 struct nouveau_screen
*nv_screen
= dri_screen
->private;