drm_lease.c revision 1.1 1 /* $NetBSD: drm_lease.c,v 1.1 2021/12/19 00:26:09 riastradh Exp $ */
2
3 /*-
4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: drm_lease.c,v 1.1 2021/12/19 00:26:09 riastradh Exp $");
34
35 #include <drm/drm_lease.h>
36
37 /*
38 * drm_lease_owner(master)
39 *
40 * Return the root of the lease tree, following parent pointers up
41 * from master.
42 */
43 struct drm_master *
44 drm_lease_owner(struct drm_master *master)
45 {
46 struct drm_master *lessor;
47
48 while ((lessor = master->lessor) != NULL)
49 master = lessor;
50
51 return master;
52 }
53
54 /*
55 * drm_lease_held(file, id)
56 *
57 * XXX
58 */
59 bool
60 drm_lease_held(struct drm_file *file, int id)
61 {
62 struct drm_master *master;
63 bool held;
64
65 if (file == NULL || (master = file->master) == NULL)
66 return true;
67
68 mutex_lock(&master->dev->mode_config.idr_mutex);
69 held = _drm_lease_held(file, id);
70 mutex_unlock(&master->dev->mode_config.idr_mutex);
71
72 return held;
73 }
74
75 /*
76 * _drm_lease_held(file, id)
77 *
78 * Same as drm_lease_held but caller must hold file's root
79 * master's dev->mode_config.idr_mutex.
80 */
81 bool
82 _drm_lease_held(struct drm_file *file, int id)
83 {
84 panic("%s: not yet implemented", __func__);
85 }
86
87 /*
88 * drm_lease_revoke(master)
89 *
90 * XXX
91 */
92 void
93 drm_lease_revoke(struct drm_master *master)
94 {
95 panic("%s: not yet implemented", __func__);
96 }
97
98 /*
99 * drm_lease_filter_crtcs(file, crtcs)
100 *
101 * XXX
102 */
103 uint32_t
104 drm_lease_filter_crtcs(struct drm_file *file, uint32_t crtcs)
105 {
106 panic("%s: not yet implemented", __func__);
107 }
108
109 /*
110 * drm_mode_create_lease_ioctl(dev, data, file)
111 *
112 * DRM_IOCTL_MODE_CREATE_LEASE(struct drm_mode_create_lease) ioctl
113 * implementation.
114 */
115 int
116 drm_mode_create_lease_ioctl(struct drm_device *dev, void *data,
117 struct drm_file *file)
118 {
119 struct drm_mode_create_lease *args __unused = data;
120
121 /* XXX not yet implemented */
122 return -ENODEV;
123 }
124
125 /*
126 * drm_mode_get_lease_ioctl(dev, data, file)
127 *
128 * DRM_IOCTL_MODE_GET_LEASE(struct drm_mode_get_lease) ioctl
129 * implementation.
130 */
131 int
132 drm_mode_get_lease_ioctl(struct drm_device *dev, void *data,
133 struct drm_file *file)
134 {
135 struct drm_mode_get_lease *args __unused = data;
136
137 /* XXX not yet implemented */
138 return -ENODEV;
139 }
140
141 /*
142 * drm_mode_list_leases_ioctl(dev, data, file)
143 *
144 * DRM_IOCTL_MODE_LIST_LEASES(struct drm_mode_list_leases) ioctl
145 * implementation.
146 */
147 int
148 drm_mode_list_leases_ioctl(struct drm_device *dev, void *data,
149 struct drm_file *file)
150 {
151 struct drm_mode_list_leases *args __unused = data;
152
153 /* XXX not yet implemented */
154 return -ENODEV;
155 }
156
157 /*
158 * drm_mode_revoke_lease_ioctl(dev, data, file)
159 *
160 * DRM_IOCTL_MODE_REVOKE_LEASE(struct drm_mode_revoke_lease) ioctl
161 * implementation.
162 */
163 int
164 drm_mode_revoke_lease_ioctl(struct drm_device *dev, void *data,
165 struct drm_file *file)
166 {
167 struct drm_mode_revoke_lease *args __unused = data;
168
169 /* XXX not yet implemented */
170 return -ENODEV;
171 }
172