1 #include "pipe/p_context.h"
2 #include "pipe/p_state.h"
3 #include "util/u_format.h"
4 #include "util/u_memory.h"
5 #include "util/u_inlines.h"
7 #include "nouveau_drm_api.h"
9 #include "nouveau_drmif.h"
10 #include "nouveau_channel.h"
11 #include "nouveau_bo.h"
13 #include "nouveau/nouveau_winsys.h"
14 #include "nouveau/nouveau_screen.h"
17 nouveau_drm_destroy_winsys(struct pipe_winsys
*s
)
19 struct nouveau_winsys
*nv_winsys
= nouveau_winsys(s
);
20 struct nouveau_screen
*nv_screen
= nouveau_screen(nv_winsys
->pscreen
);
21 nouveau_device_close(&nv_screen
->device
);
25 static struct pipe_screen
*
26 nouveau_drm_create_screen(struct drm_api
*api
, int fd
,
27 struct drm_create_screen_arg
*arg
)
29 struct nouveau_winsys
*nvws
;
30 struct pipe_winsys
*ws
;
31 struct nouveau_device
*dev
= NULL
;
32 struct pipe_screen
*(*init
)(struct pipe_winsys
*,
33 struct nouveau_device
*);
36 ret
= nouveau_device_open_existing(&dev
, 0, fd
, 0);
40 switch (dev
->chipset
& 0xf0) {
44 init
= nvfx_screen_create
;
50 init
= nv50_screen_create
;
53 debug_printf("%s: unknown chipset nv%02x\n", __func__
,
58 nvws
= CALLOC_STRUCT(nouveau_winsys
);
60 nouveau_device_close(&dev
);
64 ws
->destroy
= nouveau_drm_destroy_winsys
;
66 nvws
->pscreen
= init(ws
, dev
);
75 static struct drm_api nouveau_drm_api_hooks
= {
77 .driver_name
= "nouveau",
78 .create_screen
= nouveau_drm_create_screen
,
84 return &nouveau_drm_api_hooks
;