Merge tag 'acpi-4.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[cascardo/linux.git] / include / drm / drm_crtc.h
index 8d06cab..0aa2925 100644 (file)
@@ -46,6 +46,7 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_plane.h>
 #include <drm/drm_blend.h>
+#include <drm/drm_color_mgmt.h>
 
 struct drm_device;
 struct drm_mode_set;
@@ -108,8 +109,6 @@ struct drm_plane_helper_funcs;
  * @ctm: Transformation matrix
  * @gamma_lut: Lookup table for converting pixel data after the
  *     conversion matrix
- * @event: optional pointer to a DRM event to signal upon completion of the
- *     state update
  * @state: backpointer to global drm_atomic_state
  *
  * Note that the distinction between @enable and @active is rather subtile:
@@ -158,6 +157,46 @@ struct drm_crtc_state {
        struct drm_property_blob *ctm;
        struct drm_property_blob *gamma_lut;
 
+       /**
+        * @event:
+        *
+        * Optional pointer to a DRM event to signal upon completion of the
+        * state update. The driver must send out the event when the atomic
+        * commit operation completes. There are two cases:
+        *
+        *  - The event is for a CRTC which is being disabled through this
+        *    atomic commit. In that case the event can be send out any time
+        *    after the hardware has stopped scanning out the current
+        *    framebuffers. It should contain the timestamp and counter for the
+        *    last vblank before the display pipeline was shut off.
+        *
+        *  - For a CRTC which is enabled at the end of the commit (even when it
+        *    undergoes an full modeset) the vblank timestamp and counter must
+        *    be for the vblank right before the first frame that scans out the
+        *    new set of buffers. Again the event can only be sent out after the
+        *    hardware has stopped scanning out the old buffers.
+        *
+        *  - Events for disabled CRTCs are not allowed, and drivers can ignore
+        *    that case.
+        *
+        * This can be handled by the drm_crtc_send_vblank_event() function,
+        * which the driver should call on the provided event upon completion of
+        * the atomic commit. Note that if the driver supports vblank signalling
+        * and timestamping the vblank counters and timestamps must agree with
+        * the ones returned from page flip events. With the current vblank
+        * helper infrastructure this can be achieved by holding a vblank
+        * reference while the page flip is pending, acquired through
+        * drm_crtc_vblank_get() and released with drm_crtc_vblank_put().
+        * Drivers are free to implement their own vblank counter and timestamp
+        * tracking though, e.g. if they have accurate timestamp registers in
+        * hardware.
+        *
+        * For hardware which supports some means to synchronize vblank
+        * interrupt delivery with committing display state there's also
+        * drm_crtc_arm_vblank_event(). See the documentation of that function
+        * for a detailed discussion of the constraints it needs to be used
+        * safely.
+        */
        struct drm_pending_vblank_event *event;
 
        struct drm_atomic_state *state;
@@ -834,17 +873,9 @@ struct drm_mode_config_funcs {
         * CRTC index supplied in &drm_event to userspace.
         *
         * The drm core will supply a struct &drm_event in the event
-        * member of each CRTC's &drm_crtc_state structure. This can be handled by the
-        * drm_crtc_send_vblank_event() function, which the driver should call on
-        * the provided event upon completion of the atomic commit. Note that if
-        * the driver supports vblank signalling and timestamping the vblank
-        * counters and timestamps must agree with the ones returned from page
-        * flip events. With the current vblank helper infrastructure this can
-        * be achieved by holding a vblank reference while the page flip is
-        * pending, acquired through drm_crtc_vblank_get() and released with
-        * drm_crtc_vblank_put(). Drivers are free to implement their own vblank
-        * counter and timestamp tracking though, e.g. if they have accurate
-        * timestamp registers in hardware.
+        * member of each CRTC's &drm_crtc_state structure. See the
+        * documentation for &drm_crtc_state for more details about the precise
+        * semantics of this event.
         *
         * NOTE:
         *
@@ -1311,7 +1342,7 @@ extern void drm_crtc_cleanup(struct drm_crtc *crtc);
  * Given a registered CRTC, return the index of that CRTC within a DRM
  * device's list of CRTCs.
  */
-static inline unsigned int drm_crtc_index(struct drm_crtc *crtc)
+static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc)
 {
        return crtc->index;
 }
@@ -1337,9 +1368,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_cleanup(struct drm_device *dev);
 
-extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
-                                        int gamma_size);
-
 extern int drm_mode_set_config_internal(struct drm_mode_set *set);
 
 extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
@@ -1349,11 +1377,6 @@ extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
 extern void drm_mode_put_tile_group(struct drm_device *dev,
                                   struct drm_tile_group *tg);
 
-extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
-                                      uint degamma_lut_size,
-                                      bool has_ctm,
-                                      uint gamma_lut_size);
-
 /* Helpers */
 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
        uint32_t id)
@@ -1363,25 +1386,6 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
        return mo ? obj_to_crtc(mo) : NULL;
 }
 
-/*
- * Extract a degamma/gamma LUT value provided by user and round it to the
- * precision supported by the hardware.
- */
-static inline uint32_t drm_color_lut_extract(uint32_t user_input,
-                                            uint32_t bit_precision)
-{
-       uint32_t val = user_input;
-       uint32_t max = 0xffff >> (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);
-}
-
 #define drm_for_each_crtc(crtc, dev) \
        list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head)