Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright (c) 2016 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Permission to use, copy, modify, distribute, and sell this software and its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * documentation for any purpose is hereby granted without fee, provided that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * the above copyright notice appear in all copies and that both that copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * notice and this permission notice appear in supporting documentation, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * that the name of the copyright holders not be used in advertising or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * publicity pertaining to distribution of the software without specific,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * written prior permission.  The copyright holders make no representations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * about the suitability of this software for any purpose.  It is provided "as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * is" without express or implied warranty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * OF THIS SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #ifndef __DRM_MODESET_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define __DRM_MODESET_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <drm/drm_lease.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct drm_object_properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) struct drm_property;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) struct drm_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) struct drm_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * struct drm_mode_object - base structure for modeset objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * @id: userspace visible identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * @type: type of the object, one of DRM_MODE_OBJECT\_\*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * @properties: properties attached to this object, including values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * @refcount: reference count for objects which with dynamic lifetime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * @free_cb: free function callback, only set for objects with dynamic lifetime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * Base structure for modeset objects visible to userspace. Objects can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * looked up using drm_mode_object_find(). Besides basic uapi interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * properties like @id and @type it provides two services:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * - It tracks attached properties and their values. This is used by &drm_crtc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  *   &drm_plane and &drm_connector. Properties are attached by calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *   drm_object_attach_property() before the object is visible to userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * - For objects with dynamic lifetimes (as indicated by a non-NULL @free_cb) it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  *   provides reference counting through drm_mode_object_get() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *   drm_mode_object_put(). This is used by &drm_framebuffer, &drm_connector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  *   and &drm_property_blob. These objects provide specialized reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *   counting wrappers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) struct drm_mode_object {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	uint32_t id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	uint32_t type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct drm_object_properties *properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct kref refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	void (*free_cb)(struct kref *kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define DRM_OBJECT_MAX_PROPERTY 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * struct drm_object_properties - property tracking for &drm_mode_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct drm_object_properties {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	 * @count: number of valid properties, must be less than or equal to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	 * DRM_OBJECT_MAX_PROPERTY.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	 * @properties: Array of pointers to &drm_property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	 * NOTE: if we ever start dynamically destroying properties (ie.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	 * not at drm_mode_config_cleanup() time), then we'd have to do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	 * a better job of detaching property from mode objects to avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 * dangling property pointers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	 * @values: Array to store the property values, matching @properties. Do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 * not read/write values directly, but use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 * drm_object_property_get_value() and drm_object_property_set_value().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 * Note that atomic drivers do not store mutable properties in this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	 * array, but only the decoded values in the corresponding state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	 * structure. The decoding is done using the &drm_crtc.atomic_get_property and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	 * &drm_crtc.atomic_set_property hooks for &struct drm_crtc. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	 * &struct drm_plane the hooks are &drm_plane_funcs.atomic_get_property and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	 * &drm_plane_funcs.atomic_set_property. And for &struct drm_connector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	 * the hooks are &drm_connector_funcs.atomic_get_property and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 * &drm_connector_funcs.atomic_set_property .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 * Hence atomic drivers should not use drm_object_property_set_value()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 * and drm_object_property_get_value() on mutable objects, i.e. those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	 * without the DRM_MODE_PROP_IMMUTABLE flag set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /* Avoid boilerplate.  I'm tired of typing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define DRM_ENUM_NAME_FN(fnname, list)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	const char *fnname(int val)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	{							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		int i;						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		for (i = 0; i < ARRAY_SIZE(list); i++) {	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			if (list[i].type == val)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 				return list[i].name;		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		}						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		return "(unknown)";				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 					     struct drm_file *file_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 					     uint32_t id, uint32_t type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) void drm_mode_object_get(struct drm_mode_object *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) void drm_mode_object_put(struct drm_mode_object *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int drm_object_property_set_value(struct drm_mode_object *obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 				  struct drm_property *property,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 				  uint64_t val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int drm_object_property_get_value(struct drm_mode_object *obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 				  struct drm_property *property,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 				  uint64_t *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) void drm_object_attach_property(struct drm_mode_object *obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 				struct drm_property *property,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 				uint64_t init_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) bool drm_mode_object_lease_required(uint32_t type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #endif