gallium: Remove dri1_api.h and winsys support for DRI1
[mesa.git] / src / gallium / winsys / nouveau / drm / nouveau_drm_api.c
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"
6
7 #include "nouveau_drm_api.h"
8
9 #include "nouveau_drmif.h"
10 #include "nouveau_channel.h"
11 #include "nouveau_bo.h"
12
13 #include "nouveau/nouveau_winsys.h"
14 #include "nouveau/nouveau_screen.h"
15
16 static void
17 nouveau_drm_destroy_winsys(struct pipe_winsys *s)
18 {
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);
22 FREE(nv_winsys);
23 }
24
25 static struct pipe_screen *
26 nouveau_drm_create_screen(struct drm_api *api, int fd,
27 struct drm_create_screen_arg *arg)
28 {
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 *);
34 int ret;
35
36 ret = nouveau_device_open_existing(&dev, 0, fd, 0);
37 if (ret)
38 return NULL;
39
40 switch (dev->chipset & 0xf0) {
41 case 0x30:
42 case 0x40:
43 case 0x60:
44 init = nvfx_screen_create;
45 break;
46 case 0x50:
47 case 0x80:
48 case 0x90:
49 case 0xa0:
50 init = nv50_screen_create;
51 break;
52 default:
53 debug_printf("%s: unknown chipset nv%02x\n", __func__,
54 dev->chipset);
55 return NULL;
56 }
57
58 nvws = CALLOC_STRUCT(nouveau_winsys);
59 if (!nvws) {
60 nouveau_device_close(&dev);
61 return NULL;
62 }
63 ws = &nvws->base;
64 ws->destroy = nouveau_drm_destroy_winsys;
65
66 nvws->pscreen = init(ws, dev);
67 if (!nvws->pscreen) {
68 ws->destroy(ws);
69 return NULL;
70 }
71
72 return nvws->pscreen;
73 }
74
75 static struct drm_api nouveau_drm_api_hooks = {
76 .name = "nouveau",
77 .driver_name = "nouveau",
78 .create_screen = nouveau_drm_create_screen,
79 .destroy = NULL,
80 };
81
82 struct drm_api *
83 drm_api_create() {
84 return &nouveau_drm_api_hooks;
85 }
86