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 #include "dlmclient.h"
24 #include <xf86drmMode.h>
26 static void usage(const char *name)
30 "\tlease name: Name of lease to check\n",
34 static void dump_lease_resources(int lease_fd)
36 drmModeObjectListPtr ol = drmModeGetLease(lease_fd);
40 "drmModeGetLease failed. Received fd is not a DRM lease\n");
45 drmModeRes *res = drmModeGetResources(lease_fd);
47 fprintf(stderr, "drmModeGetResources failed\n");
51 for (int i = 0; i < res->count_crtcs; i++)
52 printf("crtc-id: %u\n", res->crtcs[i]);
54 for (int i = 0; i < res->count_connectors; i++)
55 printf("connector-id: %u\n", res->connectors[i]);
57 drmModeFreeResources(res);
59 drmModePlaneRes *plane_res = drmModeGetPlaneResources(lease_fd);
61 fprintf(stderr, "drmModeGetPlaneResources failed\n");
65 for (uint32_t i = 0; i < plane_res->count_planes; i++)
66 printf("plane-id: %u\n", plane_res->planes[i]);
68 drmModeFreePlaneResources(plane_res);
71 int main(int argc, char **argv)
78 struct dlm_lease *lease = dlm_get_lease(argv[1]);
80 fprintf(stderr, "dlm_get_lease: %s\n", strerror(errno));
84 int lease_fd = dlm_lease_fd(lease);
86 fprintf(stderr, "dlm_lease_fd: %s\n", strerror(errno));
87 dlm_release_lease(lease);
91 dump_lease_resources(lease_fd);
92 dlm_release_lease(lease);