]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/drm/drm_property.h
drm: Extract drm_property.[hc]
[mirror_ubuntu-bionic-kernel.git] / include / drm / drm_property.h
CommitLineData
59e71ee7
DV
1/*
2 * Copyright (c) 2016 Intel Corporation
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef __DRM_PROPERTY_H__
24#define __DRM_PROPERTY_H__
25
26#include <linux/list.h>
27#include <linux/ctype.h>
28#include <drm/drm_mode_object.h>
29
30struct drm_property_blob {
31 struct drm_mode_object base;
32 struct drm_device *dev;
33 struct list_head head_global;
34 struct list_head head_file;
35 size_t length;
36 unsigned char data[];
37};
38
39struct drm_property_enum {
40 uint64_t value;
41 struct list_head head;
42 char name[DRM_PROP_NAME_LEN];
43};
44
45struct drm_property {
46 struct list_head head;
47 struct drm_mode_object base;
48 uint32_t flags;
49 char name[DRM_PROP_NAME_LEN];
50 uint32_t num_values;
51 uint64_t *values;
52 struct drm_device *dev;
53
54 struct list_head enum_list;
55};
56
57struct drm_prop_enum_list {
58 int type;
59 char *name;
60};
61
62#define obj_to_property(x) container_of(x, struct drm_property, base)
63
64static inline bool drm_property_type_is(struct drm_property *property,
65 uint32_t type)
66{
67 /* instanceof for props.. handles extended type vs original types: */
68 if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
69 return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type;
70 return property->flags & type;
71}
72
73struct drm_property *drm_property_create(struct drm_device *dev, int flags,
74 const char *name, int num_values);
75struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
76 const char *name,
77 const struct drm_prop_enum_list *props,
78 int num_values);
79struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
80 int flags, const char *name,
81 const struct drm_prop_enum_list *props,
82 int num_props,
83 uint64_t supported_bits);
84struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
85 const char *name,
86 uint64_t min, uint64_t max);
87struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
88 int flags, const char *name,
89 int64_t min, int64_t max);
90struct drm_property *drm_property_create_object(struct drm_device *dev,
91 int flags, const char *name, uint32_t type);
92struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags,
93 const char *name);
94int drm_property_add_enum(struct drm_property *property, int index,
95 uint64_t value, const char *name);
96void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
97
98struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
99 size_t length,
100 const void *data);
101struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev,
102 uint32_t id);
103int drm_property_replace_global_blob(struct drm_device *dev,
104 struct drm_property_blob **replace,
105 size_t length,
106 const void *data,
107 struct drm_mode_object *obj_holds_id,
108 struct drm_property *prop_holds_id);
109struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob);
110void drm_property_unreference_blob(struct drm_property_blob *blob);
111
112static inline struct drm_property *drm_property_find(struct drm_device *dev,
113 uint32_t id)
114{
115 struct drm_mode_object *mo;
116 mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY);
117 return mo ? obj_to_property(mo) : NULL;
118}
119
120#endif