nouveau: Factor out common winsys bits into libnouveaudrm.a
[mesa.git] / src / gallium / winsys / drm / nouveau / common / nouveau_screen.c
1 #include <util/u_memory.h>
2 #include "nouveau_dri.h"
3 #include "nouveau_local.h"
4 #include "nouveau_screen.h"
5
6 int
7 nouveau_screen_init(struct nouveau_dri *nv_dri, int dev_fd,
8 struct nouveau_screen *nv_screen)
9 {
10 int ret;
11
12 ret = nouveau_device_open_existing(&nv_screen->device, 0,
13 dev_fd, 0);
14 if (ret) {
15 NOUVEAU_ERR("Failed opening nouveau device: %d\n", ret);
16 return 1;
17 }
18
19 nv_screen->front_offset = nv_dri->front_offset;
20 nv_screen->front_pitch = nv_dri->front_pitch * (nv_dri->bpp / 8);
21 nv_screen->front_cpp = nv_dri->bpp / 8;
22 nv_screen->front_height = nv_dri->height;
23
24 return 0;
25 }
26
27 void
28 nouveau_screen_cleanup(struct nouveau_screen *nv_screen)
29 {
30 nouveau_device_close(&nv_screen->device);
31 }