Commit 59e71ee7 authored by Daniel Vetter's avatar Daniel Vetter

drm: Extract drm_property.[hc]

This just contains the base property classes and all the code to
handle blobs. I think for any kind of standardized/shared properties
it's better to have separate files - this is fairly big already as-is.

v2: resurrect misplaced hunk (Daniel Stone)

Cc: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20160829082757.17913-7-daniel.vetter@ffwll.ch
parent ec5e3047
...@@ -389,6 +389,15 @@ connector and plane objects by calling the ...@@ -389,6 +389,15 @@ connector and plane objects by calling the
pointer to the target object, a pointer to the previously created pointer to the target object, a pointer to the previously created
property and an initial instance value. property and an initial instance value.
Property Types and Blob Property Support
----------------------------------------
.. kernel-doc:: include/drm/drm_property.h
:internal:
.. kernel-doc:: drivers/gpu/drm/drm_property.c
:export:
Blending and Z-Position properties Blending and Z-Position properties
---------------------------------- ----------------------------------
......
...@@ -14,7 +14,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ ...@@ -14,7 +14,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \
drm_rect.o drm_vma_manager.o drm_flip_work.o \ drm_rect.o drm_vma_manager.o drm_flip_work.o \
drm_modeset_lock.o drm_atomic.o drm_bridge.o \ drm_modeset_lock.o drm_atomic.o drm_bridge.o \
drm_framebuffer.o drm_connector.o drm_blend.o \ drm_framebuffer.o drm_connector.o drm_blend.o \
drm_encoder.o drm_mode_object.o drm_encoder.o drm_mode_object.o drm_property.o
drm-$(CONFIG_COMPAT) += drm_ioc32.o drm-$(CONFIG_COMPAT) += drm_ioc32.o
drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
......
This diff is collapsed.
...@@ -36,11 +36,6 @@ ...@@ -36,11 +36,6 @@
int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj, int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
struct drm_property *property, struct drm_property *property,
uint64_t value); uint64_t value);
bool drm_property_change_valid_get(struct drm_property *property,
uint64_t value,
struct drm_mode_object **ref);
void drm_property_change_valid_put(struct drm_property *property,
struct drm_mode_object *ref);
int drm_plane_check_pixel_format(const struct drm_plane *plane, int drm_plane_check_pixel_format(const struct drm_plane *plane,
u32 format); u32 format);
int drm_crtc_check_viewport(const struct drm_crtc *crtc, int drm_crtc_check_viewport(const struct drm_crtc *crtc,
...@@ -49,8 +44,6 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc, ...@@ -49,8 +44,6 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
const struct drm_framebuffer *fb); const struct drm_framebuffer *fb);
void drm_fb_release(struct drm_file *file_priv); void drm_fb_release(struct drm_file *file_priv);
void drm_property_destroy_user_blobs(struct drm_device *dev,
struct drm_file *file_priv);
/* dumb buffer support IOCTLs */ /* dumb buffer support IOCTLs */
int drm_mode_create_dumb_ioctl(struct drm_device *dev, int drm_mode_create_dumb_ioctl(struct drm_device *dev,
...@@ -77,6 +70,24 @@ int drm_mode_cursor_ioctl(struct drm_device *dev, ...@@ -77,6 +70,24 @@ int drm_mode_cursor_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv); void *data, struct drm_file *file_priv);
int drm_mode_cursor2_ioctl(struct drm_device *dev, int drm_mode_cursor2_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv); void *data, struct drm_file *file_priv);
int drm_mode_gamma_get_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
int drm_mode_gamma_set_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
int drm_mode_page_flip_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
/* drm_property.c */
void drm_property_destroy_user_blobs(struct drm_device *dev,
struct drm_file *file_priv);
bool drm_property_change_valid_get(struct drm_property *property,
uint64_t value,
struct drm_mode_object **ref);
void drm_property_change_valid_put(struct drm_property *property,
struct drm_mode_object *ref);
/* IOCTL */
int drm_mode_getproperty_ioctl(struct drm_device *dev, int drm_mode_getproperty_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv); void *data, struct drm_file *file_priv);
int drm_mode_getblob_ioctl(struct drm_device *dev, int drm_mode_getblob_ioctl(struct drm_device *dev,
...@@ -85,13 +96,6 @@ int drm_mode_createblob_ioctl(struct drm_device *dev, ...@@ -85,13 +96,6 @@ int drm_mode_createblob_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv); void *data, struct drm_file *file_priv);
int drm_mode_destroyblob_ioctl(struct drm_device *dev, int drm_mode_destroyblob_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv); void *data, struct drm_file *file_priv);
int drm_mode_gamma_get_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
int drm_mode_gamma_set_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
int drm_mode_page_flip_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
/* drm_mode_object.c */ /* drm_mode_object.c */
int drm_mode_object_get_reg(struct drm_device *dev, int drm_mode_object_get_reg(struct drm_device *dev,
......
This diff is collapsed.
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <drm/drm_modes.h> #include <drm/drm_modes.h>
#include <drm/drm_connector.h> #include <drm/drm_connector.h>
#include <drm/drm_encoder.h> #include <drm/drm_encoder.h>
#include <drm/drm_property.h>
struct drm_device; struct drm_device;
struct drm_mode_set; struct drm_mode_set;
...@@ -82,33 +83,6 @@ struct drm_tile_group { ...@@ -82,33 +83,6 @@ struct drm_tile_group {
u8 group_data[8]; u8 group_data[8];
}; };
struct drm_property_blob {
struct drm_mode_object base;
struct drm_device *dev;
struct list_head head_global;
struct list_head head_file;
size_t length;
unsigned char data[];
};
struct drm_property_enum {
uint64_t value;
struct list_head head;
char name[DRM_PROP_NAME_LEN];
};
struct drm_property {
struct list_head head;
struct drm_mode_object base;
uint32_t flags;
char name[DRM_PROP_NAME_LEN];
uint32_t num_values;
uint64_t *values;
struct drm_device *dev;
struct list_head enum_list;
};
struct drm_crtc; struct drm_crtc;
struct drm_encoder; struct drm_encoder;
struct drm_pending_vblank_event; struct drm_pending_vblank_event;
...@@ -2026,15 +2000,9 @@ struct drm_mode_config { ...@@ -2026,15 +2000,9 @@ struct drm_mode_config {
#define obj_to_crtc(x) container_of(x, struct drm_crtc, base) #define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
#define obj_to_mode(x) container_of(x, struct drm_display_mode, base) #define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
#define obj_to_property(x) container_of(x, struct drm_property, base)
#define obj_to_blob(x) container_of(x, struct drm_property_blob, base) #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
#define obj_to_plane(x) container_of(x, struct drm_plane, base) #define obj_to_plane(x) container_of(x, struct drm_plane, base)
struct drm_prop_enum_list {
int type;
char *name;
};
extern __printf(6, 7) extern __printf(6, 7)
int drm_crtc_init_with_planes(struct drm_device *dev, int drm_crtc_init_with_planes(struct drm_device *dev,
struct drm_crtc *crtc, struct drm_crtc *crtc,
...@@ -2107,52 +2075,6 @@ extern void drm_mode_config_init(struct drm_device *dev); ...@@ -2107,52 +2075,6 @@ extern void drm_mode_config_init(struct drm_device *dev);
extern void drm_mode_config_reset(struct drm_device *dev); extern void drm_mode_config_reset(struct drm_device *dev);
extern void drm_mode_config_cleanup(struct drm_device *dev); extern void drm_mode_config_cleanup(struct drm_device *dev);
static inline bool drm_property_type_is(struct drm_property *property,
uint32_t type)
{
/* instanceof for props.. handles extended type vs original types: */
if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type;
return property->flags & type;
}
extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
const char *name, int num_values);
extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
const char *name,
const struct drm_prop_enum_list *props,
int num_values);
struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
int flags, const char *name,
const struct drm_prop_enum_list *props,
int num_props,
uint64_t supported_bits);
struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
const char *name,
uint64_t min, uint64_t max);
struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
int flags, const char *name,
int64_t min, int64_t max);
struct drm_property *drm_property_create_object(struct drm_device *dev,
int flags, const char *name, uint32_t type);
struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags,
const char *name);
struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
size_t length,
const void *data);
struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev,
uint32_t id);
int drm_property_replace_global_blob(struct drm_device *dev,
struct drm_property_blob **replace,
size_t length,
const void *data,
struct drm_mode_object *obj_holds_id,
struct drm_property *prop_holds_id);
struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob);
void drm_property_unreference_blob(struct drm_property_blob *blob);
extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
extern int drm_property_add_enum(struct drm_property *property, int index,
uint64_t value, const char *name);
extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
int gamma_size); int gamma_size);
...@@ -2202,14 +2124,6 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, ...@@ -2202,14 +2124,6 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
return mo ? obj_to_crtc(mo) : NULL; return mo ? obj_to_crtc(mo) : NULL;
} }
static inline struct drm_property *drm_property_find(struct drm_device *dev,
uint32_t id)
{
struct drm_mode_object *mo;
mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY);
return mo ? obj_to_property(mo) : NULL;
}
/* /*
* Extract a degamma/gamma LUT value provided by user and round it to the * Extract a degamma/gamma LUT value provided by user and round it to the
* precision supported by the hardware. * precision supported by the hardware.
......
/*
* Copyright (c) 2016 Intel Corporation
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifndef __DRM_PROPERTY_H__
#define __DRM_PROPERTY_H__
#include <linux/list.h>
#include <linux/ctype.h>
#include <drm/drm_mode_object.h>
struct drm_property_blob {
struct drm_mode_object base;
struct drm_device *dev;
struct list_head head_global;
struct list_head head_file;
size_t length;
unsigned char data[];
};
struct drm_property_enum {
uint64_t value;
struct list_head head;
char name[DRM_PROP_NAME_LEN];
};
struct drm_property {
struct list_head head;
struct drm_mode_object base;
uint32_t flags;
char name[DRM_PROP_NAME_LEN];
uint32_t num_values;
uint64_t *values;
struct drm_device *dev;
struct list_head enum_list;
};
struct drm_prop_enum_list {
int type;
char *name;
};
#define obj_to_property(x) container_of(x, struct drm_property, base)
static inline bool drm_property_type_is(struct drm_property *property,
uint32_t type)
{
/* instanceof for props.. handles extended type vs original types: */
if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type;
return property->flags & type;
}
struct drm_property *drm_property_create(struct drm_device *dev, int flags,
const char *name, int num_values);
struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
const char *name,
const struct drm_prop_enum_list *props,
int num_values);
struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
int flags, const char *name,
const struct drm_prop_enum_list *props,
int num_props,
uint64_t supported_bits);
struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
const char *name,
uint64_t min, uint64_t max);
struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
int flags, const char *name,
int64_t min, int64_t max);
struct drm_property *drm_property_create_object(struct drm_device *dev,
int flags, const char *name, uint32_t type);
struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags,
const char *name);
int drm_property_add_enum(struct drm_property *property, int index,
uint64_t value, const char *name);
void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
struct drm_property_blob *drm_property_create_blob(struct drm_device *dev,
size_t length,
const void *data);
struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev,
uint32_t id);
int drm_property_replace_global_blob(struct drm_device *dev,
struct drm_property_blob **replace,
size_t length,
const void *data,
struct drm_mode_object *obj_holds_id,
struct drm_property *prop_holds_id);
struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob);
void drm_property_unreference_blob(struct drm_property_blob *blob);
static inline struct drm_property *drm_property_find(struct drm_device *dev,
uint32_t id)
{
struct drm_mode_object *mo;
mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY);
return mo ? obj_to_property(mo) : NULL;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment