2 * Copyright © 2018 Broadcom
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 #include <sys/ioctl.h>
26 #include "drm-uapi/v3d_drm.h"
27 #include "drm-shim/drm_shim.h"
29 #include "v3d_simulator_wrapper.h"
31 bool drm_shim_driver_prefers_first_render_node
= false;
33 static struct v3d_device_info devinfo
;
34 struct v3d_shim_device v3d
= {
38 struct v3d_bo
*v3d_bo_lookup(struct shim_fd
*shim_fd
, int handle
)
40 return v3d_bo(drm_shim_bo_lookup(shim_fd
, handle
));
44 v3d_ioctl_wait_bo(int fd
, unsigned long request
, void *arg
)
46 /* No need to wait on anything yet, given that we submit
53 v3d_ioctl_mmap_bo(int fd
, unsigned long request
, void *arg
)
55 struct shim_fd
*shim_fd
= drm_shim_fd_lookup(fd
);
56 struct drm_v3d_mmap_bo
*map
= arg
;
57 struct shim_bo
*bo
= drm_shim_bo_lookup(shim_fd
, map
->handle
);
59 map
->offset
= drm_shim_bo_get_mmap_offset(shim_fd
, bo
);
67 v3d_ioctl_get_bo_offset(int fd
, unsigned long request
, void *arg
)
69 struct shim_fd
*shim_fd
= drm_shim_fd_lookup(fd
);
70 struct drm_v3d_get_bo_offset
*get
= arg
;
71 struct v3d_bo
*bo
= v3d_bo_lookup(shim_fd
, get
->handle
);
73 get
->offset
= bo
->offset
;
75 drm_shim_bo_put(&bo
->base
);
81 drm_shim_driver_init(void)
83 shim_device
.bus_type
= DRM_BUS_PLATFORM
;
84 shim_device
.driver_name
= "v3d";
86 drm_shim_override_file("OF_FULLNAME=/rdb/v3d\n"
88 "OF_COMPATIBLE_0=brcm,7278-v3d\n",
89 "/sys/dev/char/%d:%d/device/uevent",
90 DRM_MAJOR
, render_node_minor
);
92 v3d
.hw
= v3d_hw_auto_new(NULL
);
93 v3d
.devinfo
->ver
= v3d_hw_get_version(v3d
.hw
);
95 if (v3d
.devinfo
->ver
>= 42)
96 v3d42_drm_shim_driver_init();
97 else if (v3d
.devinfo
->ver
>= 41)
98 v3d41_drm_shim_driver_init();
100 v3d33_drm_shim_driver_init();