]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/drm/drm_drv.h
drm: introduce sync objects (v4)
[karo-tx-linux.git] / include / drm / drm_drv.h
index 53b98321df9b2d6497b5d84afaef0d2b9d91c0e0..d855f9ae41a80e4c77b396e7210609cbee91798e 100644 (file)
@@ -53,6 +53,7 @@ struct drm_mode_create_dumb;
 #define DRIVER_RENDER                  0x8000
 #define DRIVER_ATOMIC                  0x10000
 #define DRIVER_KMS_LEGACY_CONTEXT      0x20000
+#define DRIVER_SYNCOBJ                  0x40000
 
 /**
  * struct drm_driver - DRM driver structure
@@ -103,23 +104,6 @@ struct drm_driver {
         */
        int (*open) (struct drm_device *, struct drm_file *);
 
-       /**
-        * @preclose:
-        *
-        * One of the driver callbacks when a new &struct drm_file is closed.
-        * Useful for tearing down driver-private data structures allocated in
-        * @open like buffer allocators, execution contexts or similar things.
-        *
-        * Since the display/modeset side of DRM can only be owned by exactly
-        * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
-        * there should never be a need to tear down any modeset related
-        * resources in this callback. Doing so would be a driver design bug.
-        *
-        * FIXME: It is not really clear why there's both @preclose and
-        * @postclose. Without a really good reason, use @postclose only.
-        */
-       void (*preclose) (struct drm_device *, struct drm_file *file_priv);
-
        /**
         * @postclose:
         *
@@ -131,9 +115,6 @@ struct drm_driver {
         * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
         * there should never be a need to tear down any modeset related
         * resources in this callback. Doing so would be a driver design bug.
-        *
-        * FIXME: It is not really clear why there's both @preclose and
-        * @postclose. Without a really good reason, use @postclose only.
         */
        void (*postclose) (struct drm_device *, struct drm_file *);
 
@@ -150,7 +131,7 @@ struct drm_driver {
         * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
         * infrastructure.
         *
-        * This is called after @preclose and @postclose have been called.
+        * This is called after @postclose hook has been called.
         *
         * NOTE:
         *
@@ -261,8 +242,10 @@ struct drm_driver {
         *     DRM device.
         * pipe:
         *     Id of the crtc to query.
-        * flags:
-        *     Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
+        * in_vblank_irq:
+        *     True when called from drm_crtc_handle_vblank().  Some drivers
+        *     need to apply some workarounds for gpu-specific vblank irq quirks
+        *     if flag is set.
         * vpos:
         *     Target location for current vertical scanout position.
         * hpos:
@@ -283,22 +266,19 @@ struct drm_driver {
         *
         * Returns:
         *
-        * Flags, or'ed together as follows:
+        * True on success, false if a reliable scanout position counter could
+        * not be read out.
         *
-        * DRM_SCANOUTPOS_VALID:
-        *     Query successful.
-        * DRM_SCANOUTPOS_INVBL:
-        *     Inside vblank.
-        * DRM_SCANOUTPOS_ACCURATE: Returned position is accurate. A lack of
-        *     this flag means that returned position may be offset by a
-        *     constant but unknown small number of scanlines wrt. real scanout
-        *     position.
+        * FIXME:
         *
+        * Since this is a helper to implement @get_vblank_timestamp, we should
+        * move it to &struct drm_crtc_helper_funcs, like all the other
+        * helper-internal hooks.
         */
-       int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
-                                    unsigned int flags, int *vpos, int *hpos,
-                                    ktime_t *stime, ktime_t *etime,
-                                    const struct drm_display_mode *mode);
+       bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
+                                     bool in_vblank_irq, int *vpos, int *hpos,
+                                     ktime_t *stime, ktime_t *etime,
+                                     const struct drm_display_mode *mode);
 
        /**
         * @get_vblank_timestamp:
@@ -328,28 +308,60 @@ struct drm_driver {
         *     Returns true upper bound on error for timestamp.
         * vblank_time:
         *     Target location for returned vblank timestamp.
-        * flags:
-        *     0 = Defaults, no special treatment needed.
-        *     DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
-        *     irq handler. Some drivers need to apply some workarounds
-        *     for gpu-specific vblank irq quirks if flag is set.
+        * in_vblank_irq:
+        *     True when called from drm_crtc_handle_vblank().  Some drivers
+        *     need to apply some workarounds for gpu-specific vblank irq quirks
+        *     if flag is set.
         *
         * Returns:
         *
-        * Zero if timestamping isn't supported in current display mode or a
-        * negative number on failure. A positive status code on success,
-        * which describes how the vblank_time timestamp was computed.
+        * True on success, false on failure, which means the core should
+        * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
+        *
+        * FIXME:
+        *
+        * We should move this hook to &struct drm_crtc_funcs like all the other
+        * vblank hooks.
         */
-       int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
+       bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
                                     int *max_error,
                                     struct timeval *vblank_time,
-                                    unsigned flags);
-
-       /* these have to be filled in */
+                                    bool in_vblank_irq);
 
+       /**
+        * @irq_handler:
+        *
+        * Interrupt handler called when using drm_irq_install(). Not used by
+        * drivers which implement their own interrupt handling.
+        */
        irqreturn_t(*irq_handler) (int irq, void *arg);
+
+       /**
+        * @irq_preinstall:
+        *
+        * Optional callback used by drm_irq_install() which is called before
+        * the interrupt handler is registered. This should be used to clear out
+        * any pending interrupts (from e.g. firmware based drives) and reset
+        * the interrupt handling registers.
+        */
        void (*irq_preinstall) (struct drm_device *dev);
+
+       /**
+        * @irq_postinstall:
+        *
+        * Optional callback used by drm_irq_install() which is called after
+        * the interrupt handler is registered. This should be used to enable
+        * interrupt generation in the hardware.
+        */
        int (*irq_postinstall) (struct drm_device *dev);
+
+       /**
+        * @irq_uninstall:
+        *
+        * Optional callback used by drm_irq_uninstall() which is called before
+        * the interrupt handler is unregistered. This should be used to disable
+        * interrupt generation in the hardware.
+        */
        void (*irq_uninstall) (struct drm_device *dev);
 
        /**
@@ -516,6 +528,7 @@ struct drm_driver {
        /* List of devices hanging off this driver with stealth attach. */
        struct list_head legacy_dev_list;
        int (*firstopen) (struct drm_device *);
+       void (*preclose) (struct drm_device *, struct drm_file *file_priv);
        int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
        int (*dma_quiescent) (struct drm_device *);
        int (*context_dtor) (struct drm_device *dev, int context);