1 /*
2 * Copyright 2014 Broadcom
3 * Copyright 2018 Alyssa Rosenzweig
4 * SPDX-License-Identifier: MIT
5 */
6
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10
11 #include "util/format/u_format.h"
12 #include "util/os_file.h"
13 #include "util/u_math.h"
14 #include "util/u_memory.h"
15 #include "util/u_screen.h"
16
17 #include "asahi/agx_public.h"
18 #include "drm-uapi/drm.h"
19 #include "renderonly/renderonly.h"
20 #include "asahi_drm_public.h"
21
22 static struct pipe_screen *
asahi_screen_create(int fd,const struct pipe_screen_config * config,struct renderonly * ro)23 asahi_screen_create(int fd, const struct pipe_screen_config *config,
24 struct renderonly *ro)
25 {
26 return agx_screen_create(fd, ro, config);
27 }
28
29 struct pipe_screen *
asahi_drm_screen_create(int fd,const struct pipe_screen_config * config)30 asahi_drm_screen_create(int fd, const struct pipe_screen_config *config)
31 {
32 return u_pipe_screen_lookup_or_create(os_dupfd_cloexec(fd), config, NULL,
33 asahi_screen_create);
34 }
35
36 struct pipe_screen *
asahi_drm_screen_create_renderonly(int fd,struct renderonly * ro,const struct pipe_screen_config * config)37 asahi_drm_screen_create_renderonly(int fd, struct renderonly *ro,
38 const struct pipe_screen_config *config)
39 {
40 return u_pipe_screen_lookup_or_create(os_dupfd_cloexec(fd), config, ro,
41 asahi_screen_create);
42 }
43