aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2016-07-15 15:48:01 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-07-19 04:29:47 -0400
commit34a67dd7f33f3476bc9978c3d353703d3821f6c2 (patch)
treeac7380f82623eea13e8d104a500ea346d5af4882
parent9a6bc03cd63479a40757865e5ff2e510fc2dcdb9 (diff)
drm: Extract&Document drm_irq.h
The drm_irq docs want one function from drmP.h, but that one is a serious mess. Extract it, and while at it improve the docs a bit. There's a bit a header loop issue since core data structures like drm_device and drm_driver aren't in their own headers yet, which means the drm_irq.h include in drmP.h needs to be in just the right spot :( Also noticed that drm_vblank_crtc->last_wait is entirely unused, remove it. v2: git add drm_irq.h ... Acked-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
-rw-r--r--Documentation/gpu/drm-kms.rst4
-rw-r--r--drivers/gpu/drm/drm_irq.c1
-rw-r--r--include/drm/drmP.h83
-rw-r--r--include/drm/drm_irq.h183
4 files changed, 188 insertions, 83 deletions
diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
index 675221f0a64b..8dfa4b214b96 100644
--- a/Documentation/gpu/drm-kms.rst
+++ b/Documentation/gpu/drm-kms.rst
@@ -649,5 +649,5 @@ Vertical Blanking and Interrupt Handling Functions Reference
649.. kernel-doc:: drivers/gpu/drm/drm_irq.c 649.. kernel-doc:: drivers/gpu/drm/drm_irq.c
650 :export: 650 :export:
651 651
652.. kernel-doc:: include/drm/drmP.h 652.. kernel-doc:: include/drm/drm_irq.h
653 :functions: drm_crtc_vblank_waitqueue 653 :internal:
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 35c86acede38..77f357b2c386 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1695,7 +1695,6 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
1695 1695
1696 DRM_DEBUG("waiting on vblank count %d, crtc %u\n", 1696 DRM_DEBUG("waiting on vblank count %d, crtc %u\n",
1697 vblwait->request.sequence, pipe); 1697 vblwait->request.sequence, pipe);
1698 vblank->last_wait = vblwait->request.sequence;
1699 DRM_WAIT_ON(ret, vblank->queue, 3 * HZ, 1698 DRM_WAIT_ON(ret, vblank->queue, 3 * HZ,
1700 (((drm_vblank_count(dev, pipe) - 1699 (((drm_vblank_count(dev, pipe) -
1701 vblwait->request.sequence) <= (1 << 23)) || 1700 vblwait->request.sequence) <= (1 << 23)) ||
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c2fe2cffb809..d3778652e462 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -52,7 +52,6 @@
52#include <linux/poll.h> 52#include <linux/poll.h>
53#include <linux/ratelimit.h> 53#include <linux/ratelimit.h>
54#include <linux/sched.h> 54#include <linux/sched.h>
55#include <linux/seqlock.h>
56#include <linux/slab.h> 55#include <linux/slab.h>
57#include <linux/types.h> 56#include <linux/types.h>
58#include <linux/vmalloc.h> 57#include <linux/vmalloc.h>
@@ -87,6 +86,7 @@ struct drm_device_dma;
87struct drm_dma_handle; 86struct drm_dma_handle;
88struct drm_gem_object; 87struct drm_gem_object;
89struct drm_master; 88struct drm_master;
89struct drm_vblank_crtc;
90 90
91struct device_node; 91struct device_node;
92struct videomode; 92struct videomode;
@@ -684,35 +684,6 @@ struct drm_minor {
684 struct mutex debugfs_lock; /* Protects debugfs_list. */ 684 struct mutex debugfs_lock; /* Protects debugfs_list. */
685}; 685};
686 686
687
688struct drm_pending_vblank_event {
689 struct drm_pending_event base;
690 unsigned int pipe;
691 struct drm_event_vblank event;
692};
693
694struct drm_vblank_crtc {
695 struct drm_device *dev; /* pointer to the drm_device */
696 wait_queue_head_t queue; /**< VBLANK wait queue */
697 struct timer_list disable_timer; /* delayed disable timer */
698
699 seqlock_t seqlock; /* protects vblank count and time */
700
701 u32 count; /* vblank counter */
702 struct timeval time; /* vblank timestamp */
703
704 atomic_t refcount; /* number of users of vblank interruptsper crtc */
705 u32 last; /* protected by dev->vbl_lock, used */
706 /* for wraparound handling */
707 u32 last_wait; /* Last vblank seqno waited per CRTC */
708 unsigned int inmodeset; /* Display driver is setting mode */
709 unsigned int pipe; /* crtc index */
710 int framedur_ns; /* frame/field duration in ns */
711 int linedur_ns; /* line duration in ns */
712 bool enabled; /* so we don't call enable more than
713 once per disable */
714};
715
716/** 687/**
717 * DRM device structure. This structure represent a complete card that 688 * DRM device structure. This structure represent a complete card that
718 * may contain multiple heads. 689 * may contain multiple heads.
@@ -847,6 +818,8 @@ struct drm_device {
847 int switch_power_state; 818 int switch_power_state;
848}; 819};
849 820
821#include <drm/drm_irq.h>
822
850#define DRM_SWITCH_POWER_ON 0 823#define DRM_SWITCH_POWER_ON 0
851#define DRM_SWITCH_POWER_OFF 1 824#define DRM_SWITCH_POWER_OFF 1
852#define DRM_SWITCH_POWER_CHANGING 2 825#define DRM_SWITCH_POWER_CHANGING 2
@@ -933,56 +906,6 @@ void drm_clflush_virt_range(void *addr, unsigned long length);
933 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. 906 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
934 */ 907 */
935 908
936 /* IRQ support (drm_irq.h) */
937extern int drm_irq_install(struct drm_device *dev, int irq);
938extern int drm_irq_uninstall(struct drm_device *dev);
939
940extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
941extern int drm_wait_vblank(struct drm_device *dev, void *data,
942 struct drm_file *filp);
943extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
944extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
945extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
946 struct timeval *vblanktime);
947extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
948 struct drm_pending_vblank_event *e);
949extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
950 struct drm_pending_vblank_event *e);
951extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe);
952extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
953extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
954extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
955extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe);
956extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
957extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe);
958extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe);
959extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
960extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
961extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
962extern void drm_vblank_cleanup(struct drm_device *dev);
963extern u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
964extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
965
966extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
967 unsigned int pipe, int *max_error,
968 struct timeval *vblank_time,
969 unsigned flags,
970 const struct drm_display_mode *mode);
971extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
972 const struct drm_display_mode *mode);
973
974/**
975 * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
976 * @crtc: which CRTC's vblank waitqueue to retrieve
977 *
978 * This function returns a pointer to the vblank waitqueue for the CRTC.
979 * Drivers can use this to implement vblank waits using wait_event() & co.
980 */
981static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc)
982{
983 return &crtc->dev->vblank[drm_crtc_index(crtc)].queue;
984}
985
986/* Modesetting support */ 909/* Modesetting support */
987extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe); 910extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe);
988extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe); 911extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h
new file mode 100644
index 000000000000..2401b14d301f
--- /dev/null
+++ b/include/drm/drm_irq.h
@@ -0,0 +1,183 @@
1/*
2 * Copyright 2016 Intel Corp.
3 *
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:
10 *
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.
14 *
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.
22 */
23
24#ifndef _DRM_IRQ_H_
25#define _DRM_IRQ_H_
26
27#include <linux/seqlock.h>
28
29/**
30 * struct drm_pending_vblank_event - pending vblank event tracking
31 */
32struct drm_pending_vblank_event {
33 /**
34 * @base: Base structure for tracking pending DRM events.
35 */
36 struct drm_pending_event base;
37 /**
38 * @pipe: drm_crtc_index() of the &drm_crtc this event is for.
39 */
40 unsigned int pipe;
41 /**
42 * @event: Actual event which will be sent to userspace.
43 */
44 struct drm_event_vblank event;
45};
46
47/**
48 * struct drm_vblank_crtc - vblank tracking for a CRTC
49 *
50 * This structure tracks the vblank state for one CRTC.
51 *
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.
56 */
57struct drm_vblank_crtc {
58 /**
59 * @dev: Pointer to the &drm_device.
60 */
61 struct drm_device *dev;
62 /**
63 * @queue: Wait queue for vblank waiters.
64 */
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 * max_vblank_count value in the &drm_device structure.
71 */
72 struct timer_list disable_timer;
73
74 /**
75 * @seqlock: Protect vblank count and time.
76 */
77 seqlock_t seqlock; /* protects vblank count and time */
78
79 /**
80 * @count: Current software vblank counter.
81 */
82 u32 count;
83 /**
84 * @time: Vblank timestamp corresponding to @count.
85 */
86 struct timeval time;
87
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.
92 */
93 atomic_t refcount; /* number of users of vblank interruptsper crtc */
94 /**
95 * @last: Protected by dev->vbl_lock, used for wraparound handling.
96 */
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.
105 */
106 unsigned int inmodeset; /* Display driver is setting mode */
107 /**
108 * @pipe: drm_crtc_index() of the &drm_crtc corresponding to this
109 * structure.
110 */
111 unsigned int pipe;
112 /**
113 * @framedur_ns: Frame/Field duration in ns, used by
114 * drm_calc_vbltimestamp_from_scanoutpos() and computed by
115 * drm_calc_timestamping_constants().
116 */
117 int framedur_ns;
118 /**
119 * @linedur_ns: Line duration in ns, used by
120 * drm_calc_vbltimestamp_from_scanoutpos() and computed by
121 * drm_calc_timestamping_constants().
122 */
123 int linedur_ns;
124 /**
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.
129 */
130 bool enabled;
131};
132
133extern int drm_irq_install(struct drm_device *dev, int irq);
134extern int drm_irq_uninstall(struct drm_device *dev);
135
136extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
137extern int drm_wait_vblank(struct drm_device *dev, void *data,
138 struct drm_file *filp);
139extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
140extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
141extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
142 struct timeval *vblanktime);
143extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
144 struct drm_pending_vblank_event *e);
145extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
146 struct drm_pending_vblank_event *e);
147extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe);
148extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
149extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
150extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
151extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe);
152extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
153extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe);
154extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe);
155extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
156extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
157extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
158extern void drm_vblank_cleanup(struct drm_device *dev);
159extern u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
160extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
161
162extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
163 unsigned int pipe, int *max_error,
164 struct timeval *vblank_time,
165 unsigned flags,
166 const struct drm_display_mode *mode);
167extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
168 const struct drm_display_mode *mode);
169
170/**
171 * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
172 * @crtc: which CRTC's vblank waitqueue to retrieve
173 *
174 * This function returns a pointer to the vblank waitqueue for the CRTC.
175 * Drivers can use this to implement vblank waits using wait_event() and related
176 * functions.
177 */
178static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc)
179{
180 return &crtc->dev->vblank[drm_crtc_index(crtc)].queue;
181}
182
183#endif