drm: Add reference counting to blob properties
[firefly-linux-kernel-4.4.55.git] / include / drm / drm_crtc.h
index 920e21a8f3fd7979483fd5febcd9c4df364d616a..5626191f3af0ddbea2bce691b2778c4ea64e9feb 100644 (file)
@@ -53,7 +53,6 @@ struct fence;
 #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
 #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
 #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
-#define DRM_MODE_OBJECT_BRIDGE 0xbdbdbdbd
 #define DRM_MODE_OBJECT_ANY 0
 
 struct drm_mode_object {
@@ -202,6 +201,7 @@ struct drm_framebuffer {
        const struct drm_framebuffer_funcs *funcs;
        unsigned int pitches[4];
        unsigned int offsets[4];
+       uint64_t modifier[4];
        unsigned int width;
        unsigned int height;
        /* depth can be 15 or 16 */
@@ -216,6 +216,8 @@ struct drm_framebuffer {
 
 struct drm_property_blob {
        struct drm_mode_object base;
+       struct drm_device *dev;
+       struct kref refcount;
        struct list_head head;
        size_t length;
        unsigned char data[];
@@ -466,7 +468,7 @@ struct drm_crtc {
        int framedur_ns, linedur_ns, pixeldur_ns;
 
        /* if you are using the helper */
-       void *helper_private;
+       const void *helper_private;
 
        struct drm_object_properties properties;
 
@@ -596,7 +598,7 @@ struct drm_encoder {
        struct drm_crtc *crtc;
        struct drm_bridge *bridge;
        const struct drm_encoder_funcs *funcs;
-       void *helper_private;
+       const void *helper_private;
 };
 
 /* should we poll this connector for connects and disconnects */
@@ -700,7 +702,7 @@ struct drm_connector {
        /* requested DPMS state */
        int dpms;
 
-       void *helper_private;
+       const void *helper_private;
 
        /* forced on connector */
        struct drm_cmdline_mode cmdline_mode;
@@ -829,6 +831,7 @@ enum drm_plane_type {
  * @possible_crtcs: pipes this plane can be bound to
  * @format_types: array of formats supported by this plane
  * @format_count: number of formats supported
+ * @format_default: driver hasn't supplied supported formats for the plane
  * @crtc: currently bound CRTC
  * @fb: currently bound fb
  * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
@@ -849,6 +852,7 @@ struct drm_plane {
        uint32_t possible_crtcs;
        uint32_t *format_types;
        uint32_t format_count;
+       bool format_default;
 
        struct drm_crtc *crtc;
        struct drm_framebuffer *fb;
@@ -861,7 +865,7 @@ struct drm_plane {
 
        enum drm_plane_type type;
 
-       void *helper_private;
+       const void *helper_private;
 
        struct drm_plane_state *state;
 };
@@ -912,7 +916,7 @@ struct drm_bridge {
 };
 
 /**
- * struct struct drm_atomic_state - the global state object for atomic updates
+ * struct drm_atomic_state - the global state object for atomic updates
  * @dev: parent DRM device
  * @allow_modeset: allow full modeset
  * @legacy_cursor_update: hint to enforce legacy cursor ioctl semantics
@@ -972,7 +976,7 @@ struct drm_mode_set {
  * struct drm_mode_config_funcs - basic driver provided mode setting functions
  * @fb_create: create a new framebuffer object
  * @output_poll_changed: function to handle output configuration changes
- * @atomic_check: check whether a give atomic state update is possible
+ * @atomic_check: check whether a given atomic state update is possible
  * @atomic_commit: commit an atomic state update previously verified with
  *     atomic_check()
  *
@@ -1046,6 +1050,7 @@ struct drm_mode_group {
  * @poll_running: track polling status for this device
  * @output_poll_work: delayed work for polling in process context
  * @property_blob_list: list of all the blob property objects
+ * @blob_lock: mutex for blob property allocation and management
  * @*_property: core property tracking
  * @preferred_depth: preferred RBG pixel depth, used by fb helpers
  * @prefer_shadow: hint to userspace to prefer shadow-fb rendering
@@ -1101,6 +1106,8 @@ struct drm_mode_config {
        bool delayed_event;
        struct delayed_work output_poll_work;
 
+       struct mutex blob_lock;
+
        /* pointers to standard properties */
        struct list_head property_blob_list;
        struct drm_property *edid_property;
@@ -1155,6 +1162,9 @@ struct drm_mode_config {
        /* whether async page flip is supported or not */
        bool async_page_flip;
 
+       /* whether the driver supports fb modifiers */
+       bool allow_fb_modifiers;
+
        /* cursor size */
        uint32_t cursor_width, cursor_height;
 };
@@ -1259,6 +1269,8 @@ extern int drm_plane_init(struct drm_device *dev,
 extern void drm_plane_cleanup(struct drm_plane *plane);
 extern unsigned int drm_plane_index(struct drm_plane *plane);
 extern void drm_plane_force_disable(struct drm_plane *plane);
+extern int drm_plane_check_pixel_format(const struct drm_plane *plane,
+                                       u32 format);
 extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode,
                                   int *hdisplay, int *vdisplay);
 extern int drm_crtc_check_viewport(const struct drm_crtc *crtc,
@@ -1355,6 +1367,13 @@ 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);
+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);
@@ -1518,14 +1537,6 @@ static inline struct drm_property *drm_property_find(struct drm_device *dev,
        return mo ? obj_to_property(mo) : NULL;
 }
 
-static inline struct drm_property_blob *
-drm_property_blob_find(struct drm_device *dev, uint32_t id)
-{
-       struct drm_mode_object *mo;
-       mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_BLOB);
-       return mo ? obj_to_blob(mo) : NULL;
-}
-
 /* Plane list iterator for legacy (overlay only) planes. */
 #define drm_for_each_legacy_plane(plane, planelist) \
        list_for_each_entry(plane, planelist, head) \