1 /* Copyright 2020-2021 IGEL Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef TEST_DRM_DEVICE_H
17 #define TEST_DRM_DEVICE_H
19 #include <xf86drmMode.h>
21 /* TEST_DRM_DEVICE can be the path to any
22 * file that can be opened.
24 #define TEST_DRM_DEVICE "/dev/null"
28 drmModePlaneRes plane_resources;
30 drmModeConnector *connectors;
31 drmModeEncoder *encoders;
43 extern struct drm_device test_device;
45 bool setup_drm_test_device(int crtcs, int connectors, int encoders, int planes);
46 void setup_test_device_layout(drmModeConnector *connectors,
47 drmModeEncoder *encoders, drmModePlane *planes);
48 void setup_layout_simple_test_device(int connectors, int planes);
49 void reset_drm_test_device(void);
51 drmModeConnectorPtr get_connector(int fd, uint32_t id);
52 drmModeEncoderPtr get_encoder(int fd, uint32_t id);
53 drmModePlanePtr get_plane(int fd, uint32_t id);
54 int create_lease(int fd, const uint32_t *objects, int num_objects, int flags,
57 #define TEST_DEVICE_RESOURCES (&test_device.resources)
58 #define TEST_DEVICE_PLANE_RESOURCES (&test_device.plane_resources)
60 #define CRTC_ID(x) (test_device.resources.crtcs[x])
61 #define CONNECTOR_ID(x) (test_device.resources.connectors[x])
62 #define ENCODER_ID(x) (test_device.resources.encoders[x])
63 #define PLANE_ID(x) (test_device.plane_resources.planes[x])
64 #define LESSEE_ID(x) (test_device.leases.lessee_ids[x])
66 #define CONNECTOR(cid, eid, encs, enc_cnt) \
67 CONNECTOR_FULL(cid, eid, encs, enc_cnt, DRM_MODE_CONNECTOR_Unknown, cid)
69 #define CONNECTOR_FULL(cid, eid, encs, enc_cnt, type, type_id) \
71 .connector_id = cid, .encoder_id = eid, \
72 .count_encoders = enc_cnt, .encoders = encs, \
73 .connector_type = type, .connector_type_id = type_id, \
76 #define ENCODER(eid, crtc, crtc_mask) \
78 .encoder_id = eid, .crtc_id = crtc, \
79 .possible_crtcs = crtc_mask, \
82 #define PLANE(pid, crtc_mask) \
84 .plane_id = pid, .possible_crtcs = crtc_mask, \