blk-mq: really fix plug list flushing for nomerge queues
[linux-2.6-block.git] / include / drm / drm_crtc.h
index e0170bf80bb030356e85489d568bed959749320a..d1559cd04e3de85849eee8df7189f4ce2e09cad4 100644 (file)
@@ -45,20 +45,12 @@ struct drm_clip_rect;
 struct device_node;
 struct fence;
 
-#define DRM_MODE_OBJECT_CRTC 0xcccccccc
-#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
-#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
-#define DRM_MODE_OBJECT_MODE 0xdededede
-#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
-#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
-#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
-#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
-#define DRM_MODE_OBJECT_ANY 0
-
 struct drm_mode_object {
        uint32_t id;
        uint32_t type;
        struct drm_object_properties *properties;
+       struct kref refcount;
+       void (*free_cb)(struct kref *kref);
 };
 
 #define DRM_OBJECT_MAX_PROPERTY 24
@@ -126,6 +118,14 @@ enum subpixel_order {
 #define DRM_COLOR_FORMAT_RGB444                (1<<0)
 #define DRM_COLOR_FORMAT_YCRCB444      (1<<1)
 #define DRM_COLOR_FORMAT_YCRCB422      (1<<2)
+
+#define DRM_BUS_FLAG_DE_LOW            (1<<0)
+#define DRM_BUS_FLAG_DE_HIGH           (1<<1)
+/* drive data on pos. edge */
+#define DRM_BUS_FLAG_PIXDATA_POSEDGE   (1<<2)
+/* drive data on neg. edge */
+#define DRM_BUS_FLAG_PIXDATA_NEGEDGE   (1<<3)
+
 /*
  * Describes a given display (e.g. CRT or flat panel) and its limitations.
  */
@@ -147,6 +147,7 @@ struct drm_display_info {
 
        const u32 *bus_formats;
        unsigned int num_bus_formats;
+       u32 bus_flags;
 
        /* Mask of supported hdmi deep color modes */
        u8 edid_hdmi_dc_modes;
@@ -233,8 +234,8 @@ struct drm_framebuffer {
         * should be deferred.  In cases like this, the driver would like to
         * hold a ref to the fb even though it has already been removed from
         * userspace perspective.
+        * The refcount is stored inside the mode object.
         */
-       struct kref refcount;
        /*
         * Place on the dev->mode_config.fb_list, access protected by
         * dev->mode_config.fb_lock.
@@ -258,7 +259,6 @@ struct drm_framebuffer {
 struct drm_property_blob {
        struct drm_mode_object base;
        struct drm_device *dev;
-       struct kref refcount;
        struct list_head head_global;
        struct list_head head_file;
        size_t length;
@@ -1895,7 +1895,7 @@ struct drm_mode_config_funcs {
         * drm_atomic_helper_commit(), or one of the exported sub-functions of
         * it.
         *
-        * Asynchronous commits (as indicated with the async parameter) must
+        * Nonblocking commits (as indicated with the nonblock parameter) must
         * do any preparatory work which might result in an unsuccessful commit
         * in the context of this callback. The only exceptions are hardware
         * errors resulting in -EIO. But even in that case the driver must
@@ -1908,7 +1908,7 @@ struct drm_mode_config_funcs {
         * The driver must wait for any pending rendering to the new
         * framebuffers to complete before executing the flip. It should also
         * wait for any pending rendering from other drivers if the underlying
-        * buffer is a shared dma-buf. Asynchronous commits must not wait for
+        * buffer is a shared dma-buf. Nonblocking commits must not wait for
         * rendering in the context of this callback.
         *
         * An application can request to be notified when the atomic commit has
@@ -1939,7 +1939,7 @@ struct drm_mode_config_funcs {
         *
         * 0 on success or one of the below negative error codes:
         *
-        *  - -EBUSY, if an asynchronous updated is requested and there is
+        *  - -EBUSY, if a nonblocking updated is requested and there is
         *    an earlier updated pending. Drivers are allowed to support a queue
         *    of outstanding updates, but currently no driver supports that.
         *    Note that drivers must wait for preceding updates to complete if a
@@ -1969,7 +1969,7 @@ struct drm_mode_config_funcs {
         */
        int (*atomic_commit)(struct drm_device *dev,
                             struct drm_atomic_state *state,
-                            bool async);
+                            bool nonblock);
 
        /**
         * @atomic_state_alloc:
@@ -2259,8 +2259,9 @@ static inline unsigned drm_connector_index(struct drm_connector *connector)
        return connector->connector_id;
 }
 
-/* helper to unplug all connectors from sysfs for device */
-extern void drm_connector_unplug_all(struct drm_device *dev);
+/* helpers to {un}register all connectors from sysfs for device */
+extern int drm_connector_register_all(struct drm_device *dev);
+extern void drm_connector_unregister_all(struct drm_device *dev);
 
 extern int drm_bridge_add(struct drm_bridge *bridge);
 extern void drm_bridge_remove(struct drm_bridge *bridge);
@@ -2386,8 +2387,6 @@ extern int drm_framebuffer_init(struct drm_device *dev,
                                const struct drm_framebuffer_funcs *funcs);
 extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
                                                      uint32_t id);
-extern void drm_framebuffer_unreference(struct drm_framebuffer *fb);
-extern void drm_framebuffer_reference(struct drm_framebuffer *fb);
 extern void drm_framebuffer_remove(struct drm_framebuffer *fb);
 extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
 extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb);
@@ -2445,6 +2444,8 @@ extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
                                         int gamma_size);
 extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
                uint32_t id, uint32_t type);
+void drm_mode_object_reference(struct drm_mode_object *obj);
+void drm_mode_object_unreference(struct drm_mode_object *obj);
 
 /* IOCTLs */
 extern int drm_mode_getresources(struct drm_device *dev,
@@ -2510,6 +2511,8 @@ extern int drm_edid_header_is_valid(const u8 *raw_edid);
 extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
                                 bool *edid_corrupt);
 extern bool drm_edid_is_valid(struct edid *edid);
+extern void drm_edid_get_monitor_name(struct edid *edid, char *name,
+                                     int buflen);
 
 extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
                                                         char topology[8]);
@@ -2577,7 +2580,15 @@ static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
        return mo ? obj_to_encoder(mo) : NULL;
 }
 
-static inline struct drm_connector *drm_connector_find(struct drm_device *dev,
+/**
+ * drm_connector_lookup - lookup connector object
+ * @dev: DRM device
+ * @id: connector object id
+ *
+ * This function looks up the connector object specified by id
+ * add takes a reference to it.
+ */
+static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
                uint32_t id)
 {
        struct drm_mode_object *mo;
@@ -2600,14 +2611,73 @@ static inline struct drm_property *drm_property_find(struct drm_device *dev,
 static inline uint32_t drm_color_lut_extract(uint32_t user_input,
                                             uint32_t bit_precision)
 {
-       uint32_t val = user_input + (1 << (16 - bit_precision - 1));
+       uint32_t val = user_input;
        uint32_t max = 0xffff >> (16 - bit_precision);
 
-       val >>= 16 - bit_precision;
+       /* Round only if we're not using full precision. */
+       if (bit_precision < 16) {
+               val += 1UL << (16 - bit_precision - 1);
+               val >>= 16 - bit_precision;
+       }
 
        return clamp_val(val, 0, max);
 }
 
+/**
+ * drm_framebuffer_reference - incr the fb refcnt
+ * @fb: framebuffer
+ *
+ * This functions increments the fb's refcount.
+ */
+static inline void drm_framebuffer_reference(struct drm_framebuffer *fb)
+{
+       drm_mode_object_reference(&fb->base);
+}
+
+/**
+ * drm_framebuffer_unreference - unref a framebuffer
+ * @fb: framebuffer to unref
+ *
+ * This functions decrements the fb's refcount and frees it if it drops to zero.
+ */
+static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb)
+{
+       drm_mode_object_unreference(&fb->base);
+}
+
+/**
+ * drm_framebuffer_read_refcount - read the framebuffer reference count.
+ * @fb: framebuffer
+ *
+ * This functions returns the framebuffer's reference count.
+ */
+static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb)
+{
+       return atomic_read(&fb->base.refcount.refcount);
+}
+
+/**
+ * drm_connector_reference - incr the connector refcnt
+ * @connector: connector
+ *
+ * This function increments the connector's refcount.
+ */
+static inline void drm_connector_reference(struct drm_connector *connector)
+{
+       drm_mode_object_reference(&connector->base);
+}
+
+/**
+ * drm_connector_unreference - unref a connector
+ * @connector: connector to unref
+ *
+ * This function decrements the connector's refcount and frees it if it drops to zero.
+ */
+static inline void drm_connector_unreference(struct drm_connector *connector)
+{
+       drm_mode_object_unreference(&connector->base);
+}
+
 /* Plane list iterator for legacy (overlay only) planes. */
 #define drm_for_each_legacy_plane(plane, dev) \
        list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \