Home | History | Annotate | Line # | Download | only in drm
drm_lease.c revision 1.4
      1 /*	$NetBSD: drm_lease.c,v 1.4 2021/12/19 10:46: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.4 2021/12/19 10:46:09 riastradh Exp $");
     34 
     35 #include <sys/types.h>
     36 #include <sys/errno.h>
     37 #include <sys/systm.h>
     38 
     39 #include <linux/mutex.h>
     40 
     41 #include <drm/drm_auth.h>
     42 #include <drm/drm_device.h>
     43 #include <drm/drm_file.h>
     44 #include <drm/drm_lease.h>
     45 
     46 /*
     47  * drm_lease_owner(master)
     48  *
     49  *	Return the root of the lease tree, following parent pointers up
     50  *	from master.
     51  */
     52 struct drm_master *
     53 drm_lease_owner(struct drm_master *master)
     54 {
     55 	struct drm_master *lessor;
     56 
     57 	while ((lessor = master->lessor) != NULL)
     58 		master = lessor;
     59 
     60 	return master;
     61 }
     62 
     63 /*
     64  * drm_lease_held(file, id)
     65  *
     66  *	XXX
     67  */
     68 bool
     69 drm_lease_held(struct drm_file *file, int id)
     70 {
     71 	struct drm_master *master;
     72 	bool held;
     73 
     74 	if (file == NULL || (master = file->master) == NULL)
     75 		return true;
     76 
     77 	mutex_lock(&master->dev->mode_config.idr_mutex);
     78 	held = _drm_lease_held(file, id);
     79 	mutex_unlock(&master->dev->mode_config.idr_mutex);
     80 
     81 	return held;
     82 }
     83 
     84 /*
     85  * _drm_lease_held(file, id)
     86  *
     87  *	Same as drm_lease_held but caller must hold file's root
     88  *	master's dev->mode_config.idr_mutex.
     89  */
     90 bool
     91 _drm_lease_held(struct drm_file *file, int id)
     92 {
     93 	panic("%s: not yet implemented", __func__);
     94 }
     95 
     96 /*
     97  * drm_lease_revoke(master)
     98  *
     99  *	XXX
    100  */
    101 void
    102 drm_lease_revoke(struct drm_master *master)
    103 {
    104 	panic("%s: not yet implemented", __func__);
    105 }
    106 
    107 /*
    108  * drm_lease_filter_crtcs(file, crtcs)
    109  *
    110  *	XXX
    111  */
    112 uint32_t
    113 drm_lease_filter_crtcs(struct drm_file *file, uint32_t crtcs)
    114 {
    115 	panic("%s: not yet implemented", __func__);
    116 }
    117 
    118 /*
    119  * drm_mode_create_lease_ioctl(dev, data, file)
    120  *
    121  *	DRM_IOCTL_MODE_CREATE_LEASE(struct drm_mode_create_lease) ioctl
    122  *	implementation.
    123  */
    124 int
    125 drm_mode_create_lease_ioctl(struct drm_device *dev, void *data,
    126     struct drm_file *file)
    127 {
    128 	struct drm_mode_create_lease *args __unused = data;
    129 
    130 	/* XXX not yet implemented */
    131 	return -ENODEV;
    132 }
    133 
    134 /*
    135  * drm_mode_get_lease_ioctl(dev, data, file)
    136  *
    137  *	DRM_IOCTL_MODE_GET_LEASE(struct drm_mode_get_lease) ioctl
    138  *	implementation.
    139  */
    140 int
    141 drm_mode_get_lease_ioctl(struct drm_device *dev, void *data,
    142     struct drm_file *file)
    143 {
    144 	struct drm_mode_get_lease *args __unused = data;
    145 
    146 	/* XXX not yet implemented */
    147 	return -ENODEV;
    148 }
    149 
    150 /*
    151  * drm_mode_list_lessees_ioctl(dev, data, file)
    152  *
    153  *	DRM_IOCTL_MODE_LIST_LESSEES(struct drm_mode_list_lessees) ioctl
    154  *	implementation.
    155  */
    156 int
    157 drm_mode_list_lessees_ioctl(struct drm_device *dev, void *data,
    158     struct drm_file *file)
    159 {
    160 	struct drm_mode_list_lessees *args __unused = data;
    161 
    162 	/* XXX not yet implemented */
    163 	return -ENODEV;
    164 }
    165 
    166 /*
    167  * drm_mode_revoke_lease_ioctl(dev, data, file)
    168  *
    169  *	DRM_IOCTL_MODE_REVOKE_LEASE(struct drm_mode_revoke_lease) ioctl
    170  *	implementation.
    171  */
    172 int
    173 drm_mode_revoke_lease_ioctl(struct drm_device *dev, void *data,
    174     struct drm_file *file)
    175 {
    176 	struct drm_mode_revoke_lease *args __unused = data;
    177 
    178 	/* XXX not yet implemented */
    179 	return -ENODEV;
    180 }
    181 
    182 /*
    183  * drm_lease_destroy(master)
    184  *
    185  *	Notify lessees that master is being destroyed.
    186  */
    187 void
    188 drm_lease_destroy(struct drm_master *master)
    189 {
    190 }
    191