atomisp: remove fixedbds kernel code
[linux/fpc-iii.git] / include / drm / drm_irq.h
blob2fb880462a57926a9e0d992106182e9d0c93e7a8
1 /*
2 * Copyright 2016 Intel Corp.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
24 #ifndef _DRM_IRQ_H_
25 #define _DRM_IRQ_H_
27 #include <linux/seqlock.h>
29 /**
30 * struct drm_pending_vblank_event - pending vblank event tracking
32 struct drm_pending_vblank_event {
33 /**
34 * @base: Base structure for tracking pending DRM events.
36 struct drm_pending_event base;
37 /**
38 * @pipe: drm_crtc_index() of the &drm_crtc this event is for.
40 unsigned int pipe;
41 /**
42 * @event: Actual event which will be sent to userspace.
44 struct drm_event_vblank event;
47 /**
48 * struct drm_vblank_crtc - vblank tracking for a CRTC
50 * This structure tracks the vblank state for one CRTC.
52 * Note that for historical reasons - the vblank handling code is still shared
53 * with legacy/non-kms drivers - this is a free-standing structure not directly
54 * connected to &struct drm_crtc. But all public interface functions are taking
55 * a &struct drm_crtc to hide this implementation detail.
57 struct drm_vblank_crtc {
58 /**
59 * @dev: Pointer to the &drm_device.
61 struct drm_device *dev;
62 /**
63 * @queue: Wait queue for vblank waiters.
65 wait_queue_head_t queue; /**< VBLANK wait queue */
66 /**
67 * @disable_timer: Disable timer for the delayed vblank disabling
68 * hysteresis logic. Vblank disabling is controlled through the
69 * drm_vblank_offdelay module option and the setting of the
70 * &drm_device.max_vblank_count value.
72 struct timer_list disable_timer;
74 /**
75 * @seqlock: Protect vblank count and time.
77 seqlock_t seqlock; /* protects vblank count and time */
79 /**
80 * @count: Current software vblank counter.
82 u32 count;
83 /**
84 * @time: Vblank timestamp corresponding to @count.
86 struct timeval time;
88 /**
89 * @refcount: Number of users/waiters of the vblank interrupt. Only when
90 * this refcount reaches 0 can the hardware interrupt be disabled using
91 * @disable_timer.
93 atomic_t refcount; /* number of users of vblank interruptsper crtc */
94 /**
95 * @last: Protected by &drm_device.vbl_lock, used for wraparound handling.
97 u32 last;
98 /**
99 * @inmodeset: Tracks whether the vblank is disabled due to a modeset.
100 * For legacy driver bit 2 additionally tracks whether an additional
101 * temporary vblank reference has been acquired to paper over the
102 * hardware counter resetting/jumping. KMS drivers should instead just
103 * call drm_crtc_vblank_off() and drm_crtc_vblank_on(), which explicitly
104 * save and restore the vblank count.
106 unsigned int inmodeset; /* Display driver is setting mode */
108 * @pipe: drm_crtc_index() of the &drm_crtc corresponding to this
109 * structure.
111 unsigned int pipe;
113 * @framedur_ns: Frame/Field duration in ns, used by
114 * drm_calc_vbltimestamp_from_scanoutpos() and computed by
115 * drm_calc_timestamping_constants().
117 int framedur_ns;
119 * @linedur_ns: Line duration in ns, used by
120 * drm_calc_vbltimestamp_from_scanoutpos() and computed by
121 * drm_calc_timestamping_constants().
123 int linedur_ns;
125 * @enabled: Tracks the enabling state of the corresponding &drm_crtc to
126 * avoid double-disabling and hence corrupting saved state. Needed by
127 * drivers not using atomic KMS, since those might go through their CRTC
128 * disabling functions multiple times.
130 bool enabled;
133 int drm_irq_install(struct drm_device *dev, int irq);
134 int drm_irq_uninstall(struct drm_device *dev);
136 int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
137 u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
138 u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
139 struct timeval *vblanktime);
140 void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
141 struct drm_pending_vblank_event *e);
142 void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
143 struct drm_pending_vblank_event *e);
144 bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe);
145 bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
146 int drm_crtc_vblank_get(struct drm_crtc *crtc);
147 void drm_crtc_vblank_put(struct drm_crtc *crtc);
148 void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe);
149 void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
150 void drm_crtc_vblank_off(struct drm_crtc *crtc);
151 void drm_crtc_vblank_reset(struct drm_crtc *crtc);
152 void drm_crtc_vblank_on(struct drm_crtc *crtc);
153 void drm_vblank_cleanup(struct drm_device *dev);
154 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
155 u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
157 int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
158 unsigned int pipe, int *max_error,
159 struct timeval *vblank_time,
160 unsigned flags,
161 const struct drm_display_mode *mode);
162 void drm_calc_timestamping_constants(struct drm_crtc *crtc,
163 const struct drm_display_mode *mode);
166 * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
167 * @crtc: which CRTC's vblank waitqueue to retrieve
169 * This function returns a pointer to the vblank waitqueue for the CRTC.
170 * Drivers can use this to implement vblank waits using wait_event() and related
171 * functions.
173 static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc)
175 return &crtc->dev->vblank[drm_crtc_index(crtc)].queue;
178 #endif