blob: 648d6c8a8e21fdb8196ccbf0739de6e140db6182 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "nouveau_drm_winsys.h"
#include "nouveau_drm_public.h"
#include "nouveau_drmif.h"
#include "nouveau_channel.h"
#include "nouveau_bo.h"
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_screen.h"
static void
nouveau_drm_destroy_winsys(struct pipe_winsys *s)
{
struct nouveau_winsys *nv_winsys = nouveau_winsys(s);
struct nouveau_screen *nv_screen= nouveau_screen(nv_winsys->pscreen);
if (nv_screen)
nouveau_device_close(&nv_screen->device);
FREE(nv_winsys);
}
struct pipe_screen *
nouveau_drm_screen_create(int fd)
{
struct nouveau_winsys *nvws;
struct pipe_winsys *ws;
struct nouveau_device *dev = NULL;
struct pipe_screen *(*init)(struct pipe_winsys *,
struct nouveau_device *);
int ret;
ret = nouveau_device_open_existing(&dev, 0, fd, 0);
if (ret)
return NULL;
switch (dev->chipset & 0xf0) {
case 0x30:
case 0x40:
case 0x60:
init = nvfx_screen_create;
break;
case 0x50:
case 0x80:
case 0x90:
case 0xa0:
init = nv50_screen_create;
break;
case 0xc0:
init = nvc0_screen_create;
break;
default:
debug_printf("%s: unknown chipset nv%02x\n", __func__,
dev->chipset);
return NULL;
}
nvws = CALLOC_STRUCT(nouveau_winsys);
if (!nvws) {
nouveau_device_close(&dev);
return NULL;
}
ws = &nvws->base;
ws->destroy = nouveau_drm_destroy_winsys;
nvws->pscreen = init(ws, dev);
if (!nvws->pscreen) {
ws->destroy(ws);
return NULL;
}
return nvws->pscreen;
}
|