#ifndef _DRM_AUTH_H_1#define _DRM_AUTH_H_23/*4* Internal Header for the Direct Rendering Manager5*6* Copyright 2016 Intel Corporation7*8* Author: Daniel Vetter <[email protected]>9*10* Permission is hereby granted, free of charge, to any person obtaining a11* copy of this software and associated documentation files (the "Software"),12* to deal in the Software without restriction, including without limitation13* the rights to use, copy, modify, merge, publish, distribute, sublicense,14* and/or sell copies of the Software, and to permit persons to whom the15* Software is furnished to do so, subject to the following conditions:16*17* The above copyright notice and this permission notice (including the next18* paragraph) shall be included in all copies or substantial portions of the19* Software.20*21* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR22* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,23* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL24* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR25* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,26* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR27* OTHER DEALINGS IN THE SOFTWARE.28*/2930#include <linux/idr.h>31#include <linux/kref.h>32#include <linux/wait.h>3334struct drm_file;3536/**37* struct drm_master - drm master structure38*39* @refcount: Refcount for this master object.40* @dev: Link back to the DRM device41* @driver_priv: Pointer to driver-private information.42*43* Note that master structures are only relevant for the legacy/primary device44* nodes, hence there can only be one per device, not one per drm_minor.45*/46struct drm_master {47struct kref refcount;48struct drm_device *dev;49/**50* @unique: Unique identifier: e.g. busid. Protected by51* &drm_device.master_mutex.52*/53char *unique;54/**55* @unique_len: Length of unique field. Protected by56* &drm_device.master_mutex.57*/58int unique_len;59/**60* @magic_map: Map of used authentication tokens. Protected by61* &drm_device.master_mutex.62*/63struct idr magic_map;64void *driver_priv;6566/**67* @lessor:68*69* Lease grantor, only set if this &struct drm_master represents a70* lessee holding a lease of objects from @lessor. Full owners of the71* device have this set to NULL.72*73* The lessor does not change once it's set in drm_lease_create(), and74* each lessee holds a reference to its lessor that it releases upon75* being destroyed in drm_lease_destroy().76*77* See also the :ref:`section on display resource leasing78* <drm_leasing>`.79*/80struct drm_master *lessor;8182/**83* @lessee_id:84*85* ID for lessees. Owners (i.e. @lessor is NULL) always have ID 0.86* Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.87*/88int lessee_id;8990/**91* @lessee_list:92*93* List entry of lessees of @lessor, where they are linked to @lessees.94* Not used for owners. Protected by &drm_device.mode_config's95* &drm_mode_config.idr_mutex.96*/97struct list_head lessee_list;9899/**100* @lessees:101*102* List of drm_masters leasing from this one. Protected by103* &drm_device.mode_config's &drm_mode_config.idr_mutex.104*105* This list is empty if no leases have been granted, or if all lessees106* have been destroyed. Since lessors are referenced by all their107* lessees, this master cannot be destroyed unless the list is empty.108*/109struct list_head lessees;110111/**112* @leases:113*114* Objects leased to this drm_master. Protected by115* &drm_device.mode_config's &drm_mode_config.idr_mutex.116*117* Objects are leased all together in drm_lease_create(), and are118* removed all together when the lease is revoked.119*/120struct idr leases;121122/**123* @lessee_idr:124*125* All lessees under this owner (only used where @lessor is NULL).126* Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.127*/128struct idr lessee_idr;129};130131struct drm_master *drm_master_get(struct drm_master *master);132struct drm_master *drm_file_get_master(struct drm_file *file_priv);133void drm_master_put(struct drm_master **master);134bool drm_is_current_master(struct drm_file *fpriv);135136struct drm_master *drm_master_create(struct drm_device *dev);137138#endif139140141