![]() |
|
|||
0001 /* 0002 * Copyright (c) 2016 Intel Corporation 0003 * 0004 * Permission to use, copy, modify, distribute, and sell this software and its 0005 * documentation for any purpose is hereby granted without fee, provided that 0006 * the above copyright notice appear in all copies and that both that copyright 0007 * notice and this permission notice appear in supporting documentation, and 0008 * that the name of the copyright holders not be used in advertising or 0009 * publicity pertaining to distribution of the software without specific, 0010 * written prior permission. The copyright holders make no representations 0011 * about the suitability of this software for any purpose. It is provided "as 0012 * is" without express or implied warranty. 0013 * 0014 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 0015 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 0016 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 0017 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 0018 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 0019 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 0020 * OF THIS SOFTWARE. 0021 */ 0022 0023 #ifndef __DRM_PROPERTY_H__ 0024 #define __DRM_PROPERTY_H__ 0025 0026 #include <linux/list.h> 0027 #include <linux/ctype.h> 0028 #include <drm/drm_mode_object.h> 0029 0030 #include <uapi/drm/drm_mode.h> 0031 0032 /** 0033 * struct drm_property_enum - symbolic values for enumerations 0034 * @head: list of enum values, linked to &drm_property.enum_list 0035 * @name: symbolic name for the enum 0036 * 0037 * For enumeration and bitmask properties this structure stores the symbolic 0038 * decoding for each value. This is used for example for the rotation property. 0039 */ 0040 struct drm_property_enum { 0041 /** 0042 * @value: numeric property value for this enum entry 0043 * 0044 * If the property has the type &DRM_MODE_PROP_BITMASK, @value stores a 0045 * bitshift, not a bitmask. In other words, the enum entry is enabled 0046 * if the bit number @value is set in the property's value. This enum 0047 * entry has the bitmask ``1 << value``. 0048 */ 0049 uint64_t value; 0050 struct list_head head; 0051 char name[DRM_PROP_NAME_LEN]; 0052 }; 0053 0054 /** 0055 * struct drm_property - modeset object property 0056 * 0057 * This structure represent a modeset object property. It combines both the name 0058 * of the property with the set of permissible values. This means that when a 0059 * driver wants to use a property with the same name on different objects, but 0060 * with different value ranges, then it must create property for each one. An 0061 * example would be rotation of &drm_plane, when e.g. the primary plane cannot 0062 * be rotated. But if both the name and the value range match, then the same 0063 * property structure can be instantiated multiple times for the same object. 0064 * Userspace must be able to cope with this and cannot assume that the same 0065 * symbolic property will have the same modeset object ID on all modeset 0066 * objects. 0067 * 0068 * Properties are created by one of the special functions, as explained in 0069 * detail in the @flags structure member. 0070 * 0071 * To actually expose a property it must be attached to each object using 0072 * drm_object_attach_property(). Currently properties can only be attached to 0073 * &drm_connector, &drm_crtc and &drm_plane. 0074 * 0075 * Properties are also used as the generic metadatatransport for the atomic 0076 * IOCTL. Everything that was set directly in structures in the legacy modeset 0077 * IOCTLs (like the plane source or destination windows, or e.g. the links to 0078 * the CRTC) is exposed as a property with the DRM_MODE_PROP_ATOMIC flag set. 0079 */ 0080 struct drm_property { 0081 /** 0082 * @head: per-device list of properties, for cleanup. 0083 */ 0084 struct list_head head; 0085 0086 /** 0087 * @base: base KMS object 0088 */ 0089 struct drm_mode_object base; 0090 0091 /** 0092 * @flags: 0093 * 0094 * Property flags and type. A property needs to be one of the following 0095 * types: 0096 * 0097 * DRM_MODE_PROP_RANGE 0098 * Range properties report their minimum and maximum admissible unsigned values. 0099 * The KMS core verifies that values set by application fit in that 0100 * range. The range is unsigned. Range properties are created using 0101 * drm_property_create_range(). 0102 * 0103 * DRM_MODE_PROP_SIGNED_RANGE 0104 * Range properties report their minimum and maximum admissible unsigned values. 0105 * The KMS core verifies that values set by application fit in that 0106 * range. The range is signed. Range properties are created using 0107 * drm_property_create_signed_range(). 0108 * 0109 * DRM_MODE_PROP_ENUM 0110 * Enumerated properties take a numerical value that ranges from 0 to 0111 * the number of enumerated values defined by the property minus one, 0112 * and associate a free-formed string name to each value. Applications 0113 * can retrieve the list of defined value-name pairs and use the 0114 * numerical value to get and set property instance values. Enum 0115 * properties are created using drm_property_create_enum(). 0116 * 0117 * DRM_MODE_PROP_BITMASK 0118 * Bitmask properties are enumeration properties that additionally 0119 * restrict all enumerated values to the 0..63 range. Bitmask property 0120 * instance values combine one or more of the enumerated bits defined 0121 * by the property. Bitmask properties are created using 0122 * drm_property_create_bitmask(). 0123 * 0124 * DRM_MODE_PROP_OBJECT 0125 * Object properties are used to link modeset objects. This is used 0126 * extensively in the atomic support to create the display pipeline, 0127 * by linking &drm_framebuffer to &drm_plane, &drm_plane to 0128 * &drm_crtc and &drm_connector to &drm_crtc. An object property can 0129 * only link to a specific type of &drm_mode_object, this limit is 0130 * enforced by the core. Object properties are created using 0131 * drm_property_create_object(). 0132 * 0133 * Object properties work like blob properties, but in a more 0134 * general fashion. They are limited to atomic drivers and must have 0135 * the DRM_MODE_PROP_ATOMIC flag set. 0136 * 0137 * DRM_MODE_PROP_BLOB 0138 * Blob properties store a binary blob without any format restriction. 0139 * The binary blobs are created as KMS standalone objects, and blob 0140 * property instance values store the ID of their associated blob 0141 * object. Blob properties are created by calling 0142 * drm_property_create() with DRM_MODE_PROP_BLOB as the type. 0143 * 0144 * Actual blob objects to contain blob data are created using 0145 * drm_property_create_blob(), or through the corresponding IOCTL. 0146 * 0147 * Besides the built-in limit to only accept blob objects blob 0148 * properties work exactly like object properties. The only reasons 0149 * blob properties exist is backwards compatibility with existing 0150 * userspace. 0151 * 0152 * In addition a property can have any combination of the below flags: 0153 * 0154 * DRM_MODE_PROP_ATOMIC 0155 * Set for properties which encode atomic modeset state. Such 0156 * properties are not exposed to legacy userspace. 0157 * 0158 * DRM_MODE_PROP_IMMUTABLE 0159 * Set for properties whose values cannot be changed by 0160 * userspace. The kernel is allowed to update the value of these 0161 * properties. This is generally used to expose probe state to 0162 * userspace, e.g. the EDID, or the connector path property on DP 0163 * MST sinks. Kernel can update the value of an immutable property 0164 * by calling drm_object_property_set_value(). 0165 */ 0166 uint32_t flags; 0167 0168 /** 0169 * @name: symbolic name of the properties 0170 */ 0171 char name[DRM_PROP_NAME_LEN]; 0172 0173 /** 0174 * @num_values: size of the @values array. 0175 */ 0176 uint32_t num_values; 0177 0178 /** 0179 * @values: 0180 * 0181 * Array with limits and values for the property. The 0182 * interpretation of these limits is dependent upon the type per @flags. 0183 */ 0184 uint64_t *values; 0185 0186 /** 0187 * @dev: DRM device 0188 */ 0189 struct drm_device *dev; 0190 0191 /** 0192 * @enum_list: 0193 * 0194 * List of &drm_prop_enum_list structures with the symbolic names for 0195 * enum and bitmask values. 0196 */ 0197 struct list_head enum_list; 0198 }; 0199 0200 /** 0201 * struct drm_property_blob - Blob data for &drm_property 0202 * @base: base KMS object 0203 * @dev: DRM device 0204 * @head_global: entry on the global blob list in 0205 * &drm_mode_config.property_blob_list. 0206 * @head_file: entry on the per-file blob list in &drm_file.blobs list. 0207 * @length: size of the blob in bytes, invariant over the lifetime of the object 0208 * @data: actual data, embedded at the end of this structure 0209 * 0210 * Blobs are used to store bigger values than what fits directly into the 64 0211 * bits available for a &drm_property. 0212 * 0213 * Blobs are reference counted using drm_property_blob_get() and 0214 * drm_property_blob_put(). They are created using drm_property_create_blob(). 0215 */ 0216 struct drm_property_blob { 0217 struct drm_mode_object base; 0218 struct drm_device *dev; 0219 struct list_head head_global; 0220 struct list_head head_file; 0221 size_t length; 0222 void *data; 0223 }; 0224 0225 struct drm_prop_enum_list { 0226 int type; 0227 const char *name; 0228 }; 0229 0230 #define obj_to_property(x) container_of(x, struct drm_property, base) 0231 #define obj_to_blob(x) container_of(x, struct drm_property_blob, base) 0232 0233 /** 0234 * drm_property_type_is - check the type of a property 0235 * @property: property to check 0236 * @type: property type to compare with 0237 * 0238 * This is a helper function becauase the uapi encoding of property types is 0239 * a bit special for historical reasons. 0240 */ 0241 static inline bool drm_property_type_is(struct drm_property *property, 0242 uint32_t type) 0243 { 0244 /* instanceof for props.. handles extended type vs original types: */ 0245 if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) 0246 return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type; 0247 return property->flags & type; 0248 } 0249 0250 struct drm_property *drm_property_create(struct drm_device *dev, 0251 u32 flags, const char *name, 0252 int num_values); 0253 struct drm_property *drm_property_create_enum(struct drm_device *dev, 0254 u32 flags, const char *name, 0255 const struct drm_prop_enum_list *props, 0256 int num_values); 0257 struct drm_property *drm_property_create_bitmask(struct drm_device *dev, 0258 u32 flags, const char *name, 0259 const struct drm_prop_enum_list *props, 0260 int num_props, 0261 uint64_t supported_bits); 0262 struct drm_property *drm_property_create_range(struct drm_device *dev, 0263 u32 flags, const char *name, 0264 uint64_t min, uint64_t max); 0265 struct drm_property *drm_property_create_signed_range(struct drm_device *dev, 0266 u32 flags, const char *name, 0267 int64_t min, int64_t max); 0268 struct drm_property *drm_property_create_object(struct drm_device *dev, 0269 u32 flags, const char *name, 0270 uint32_t type); 0271 struct drm_property *drm_property_create_bool(struct drm_device *dev, 0272 u32 flags, const char *name); 0273 int drm_property_add_enum(struct drm_property *property, 0274 uint64_t value, const char *name); 0275 void drm_property_destroy(struct drm_device *dev, struct drm_property *property); 0276 0277 struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, 0278 size_t length, 0279 const void *data); 0280 struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev, 0281 uint32_t id); 0282 int drm_property_replace_global_blob(struct drm_device *dev, 0283 struct drm_property_blob **replace, 0284 size_t length, 0285 const void *data, 0286 struct drm_mode_object *obj_holds_id, 0287 struct drm_property *prop_holds_id); 0288 bool drm_property_replace_blob(struct drm_property_blob **blob, 0289 struct drm_property_blob *new_blob); 0290 struct drm_property_blob *drm_property_blob_get(struct drm_property_blob *blob); 0291 void drm_property_blob_put(struct drm_property_blob *blob); 0292 0293 /** 0294 * drm_property_find - find property object 0295 * @dev: DRM device 0296 * @file_priv: drm file to check for lease against. 0297 * @id: property object id 0298 * 0299 * This function looks up the property object specified by id and returns it. 0300 */ 0301 static inline struct drm_property *drm_property_find(struct drm_device *dev, 0302 struct drm_file *file_priv, 0303 uint32_t id) 0304 { 0305 struct drm_mode_object *mo; 0306 mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_PROPERTY); 0307 return mo ? obj_to_property(mo) : NULL; 0308 } 0309 0310 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |