^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_PROPERTY_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define __DRM_PROPERTY_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <drm/drm_mode_object.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <uapi/drm/drm_mode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * struct drm_property_enum - symbolic values for enumerations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * @value: numeric property value for this enum entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * @head: list of enum values, linked to &drm_property.enum_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * @name: symbolic name for the enum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * For enumeration and bitmask properties this structure stores the symbolic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * decoding for each value. This is used for example for the rotation property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct drm_property_enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) uint64_t value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct list_head head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) char name[DRM_PROP_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * struct drm_property - modeset object property
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * This structure represent a modeset object property. It combines both the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * of the property with the set of permissible values. This means that when a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * driver wants to use a property with the same name on different objects, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * with different value ranges, then it must create property for each one. An
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * example would be rotation of &drm_plane, when e.g. the primary plane cannot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * be rotated. But if both the name and the value range match, then the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * property structure can be instantiated multiple times for the same object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * Userspace must be able to cope with this and cannot assume that the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * symbolic property will have the same modeset object ID on all modeset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * Properties are created by one of the special functions, as explained in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * detail in the @flags structure member.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * To actually expose a property it must be attached to each object using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * drm_object_attach_property(). Currently properties can only be attached to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * &drm_connector, &drm_crtc and &drm_plane.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Properties are also used as the generic metadatatransport for the atomic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * IOCTL. Everything that was set directly in structures in the legacy modeset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * IOCTLs (like the plane source or destination windows, or e.g. the links to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * the CRTC) is exposed as a property with the DRM_MODE_PROP_ATOMIC flag set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct drm_property {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @head: per-device list of properties, for cleanup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct list_head head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * @base: base KMS object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct drm_mode_object base;
^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) * @flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * Property flags and type. A property needs to be one of the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * types:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * DRM_MODE_PROP_RANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * Range properties report their minimum and maximum admissible unsigned values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * The KMS core verifies that values set by application fit in that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * range. The range is unsigned. Range properties are created using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * drm_property_create_range().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * DRM_MODE_PROP_SIGNED_RANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * Range properties report their minimum and maximum admissible unsigned values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * The KMS core verifies that values set by application fit in that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * range. The range is signed. Range properties are created using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * drm_property_create_signed_range().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * DRM_MODE_PROP_ENUM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * Enumerated properties take a numerical value that ranges from 0 to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * the number of enumerated values defined by the property minus one,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * and associate a free-formed string name to each value. Applications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * can retrieve the list of defined value-name pairs and use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * numerical value to get and set property instance values. Enum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * properties are created using drm_property_create_enum().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * DRM_MODE_PROP_BITMASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * Bitmask properties are enumeration properties that additionally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * restrict all enumerated values to the 0..63 range. Bitmask property
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * instance values combine one or more of the enumerated bits defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * by the property. Bitmask properties are created using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * drm_property_create_bitmask().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * DRM_MODE_PROB_OBJECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * Object properties are used to link modeset objects. This is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * extensively in the atomic support to create the display pipeline,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * by linking &drm_framebuffer to &drm_plane, &drm_plane to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * &drm_crtc and &drm_connector to &drm_crtc. An object property can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * only link to a specific type of &drm_mode_object, this limit is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * enforced by the core. Object properties are created using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * drm_property_create_object().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * Object properties work like blob properties, but in a more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * general fashion. They are limited to atomic drivers and must have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * the DRM_MODE_PROP_ATOMIC flag set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * DRM_MODE_PROP_BLOB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * Blob properties store a binary blob without any format restriction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * The binary blobs are created as KMS standalone objects, and blob
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * property instance values store the ID of their associated blob
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * object. Blob properties are created by calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * drm_property_create() with DRM_MODE_PROP_BLOB as the type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * Actual blob objects to contain blob data are created using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * drm_property_create_blob(), or through the corresponding IOCTL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * Besides the built-in limit to only accept blob objects blob
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * properties work exactly like object properties. The only reasons
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * blob properties exist is backwards compatibility with existing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * In addition a property can have any combination of the below flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * DRM_MODE_PROP_ATOMIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * Set for properties which encode atomic modeset state. Such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * properties are not exposed to legacy userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * DRM_MODE_PROP_IMMUTABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * Set for properties whose values cannot be changed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * userspace. The kernel is allowed to update the value of these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * properties. This is generally used to expose probe state to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * userspace, e.g. the EDID, or the connector path property on DP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * MST sinks. Kernel can update the value of an immutable property
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * by calling drm_object_property_set_value().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) uint32_t flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * @name: symbolic name of the properties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) char name[DRM_PROP_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * @num_values: size of the @values array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) uint32_t num_values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * @values:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * Array with limits and values for the property. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * interpretation of these limits is dependent upon the type per @flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) uint64_t *values;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * @dev: DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct drm_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * @enum_list:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * List of &drm_prop_enum_list structures with the symbolic names for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * enum and bitmask values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct list_head enum_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * struct drm_property_blob - Blob data for &drm_property
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * @base: base KMS object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * @dev: DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * @head_global: entry on the global blob list in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * &drm_mode_config.property_blob_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * @head_file: entry on the per-file blob list in &drm_file.blobs list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * @length: size of the blob in bytes, invariant over the lifetime of the object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * @data: actual data, embedded at the end of this structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * Blobs are used to store bigger values than what fits directly into the 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * bits available for a &drm_property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * Blobs are reference counted using drm_property_blob_get() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * drm_property_blob_put(). They are created using drm_property_create_blob().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct drm_property_blob {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct drm_mode_object base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct drm_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct list_head head_global;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct list_head head_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) size_t length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct drm_prop_enum_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) #define obj_to_property(x) container_of(x, struct drm_property, base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * drm_property_type_is - check the type of a property
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * @property: property to check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * @type: property type to compare with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * This is a helper function becauase the uapi encoding of property types is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * a bit special for historical reasons.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static inline bool drm_property_type_is(struct drm_property *property,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) uint32_t type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) /* instanceof for props.. handles extended type vs original types: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return property->flags & type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct drm_property *drm_property_create(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) u32 flags, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) int num_values);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct drm_property *drm_property_create_enum(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) u32 flags, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) const struct drm_prop_enum_list *props,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) int num_values);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) u32 flags, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) const struct drm_prop_enum_list *props,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) int num_props,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) uint64_t supported_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) struct drm_property *drm_property_create_range(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) u32 flags, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) uint64_t min, uint64_t max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) u32 flags, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) int64_t min, int64_t max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct drm_property *drm_property_create_object(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) u32 flags, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) uint32_t type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct drm_property *drm_property_create_bool(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) u32 flags, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) int drm_property_add_enum(struct drm_property *property,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) uint64_t value, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) size_t length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) const void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) uint32_t id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) int drm_property_replace_global_blob(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct drm_property_blob **replace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) size_t length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) const void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct drm_mode_object *obj_holds_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) struct drm_property *prop_holds_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) bool drm_property_replace_blob(struct drm_property_blob **blob,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct drm_property_blob *new_blob);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) struct drm_property_blob *drm_property_blob_get(struct drm_property_blob *blob);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) void drm_property_blob_put(struct drm_property_blob *blob);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * drm_property_find - find property object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * @dev: DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * @file_priv: drm file to check for lease against.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * @id: property object id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) * This function looks up the property object specified by id and returns it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) static inline struct drm_property *drm_property_find(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct drm_file *file_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) uint32_t id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) struct drm_mode_object *mo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_PROPERTY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) return mo ? obj_to_property(mo) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) #endif