Print this page
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
loader: pxe receive cleanup
9475 libefi: Do not return only if ReceiveFilter
installboot: should support efi system partition
8931 boot1.efi: scan all display modes rather than
loader: spinconsole updates
loader: gfx experiment to try GOP Blt() function.
sha1 build test
loader: add sha1 hash calculation
common/sha1: update for loader build
loader: biosdisk rework
uts: 32-bit kernel FB needs mapping in low memory
uts: add diag-device
uts: boot console mirror with diag-device
uts: enable very early console on ttya
kmdb: add diag-device as input/output device
uts: test VGA memory exclusion from mapping
uts: clear boot mapping and protect boot pages test
uts: add dboot map debug printf
uts: need to release FB pages in release_bootstrap()
uts: add screenmap ioctl
uts: update sys/queue.h
loader: add illumos uts/common to include path
loader: tem/gfx font cleanup
loader: vbe checks
uts: gfx_private set KD_TEXT when KD_RESETTEXT is
uts: gfx 8-bit update
loader: gfx 8-bit fix
loader: always set media size from partition.
uts: MB2 support for 32-bit kernel
loader: x86 should have tem 80x25
uts: x86 should have tem 80x25
uts: font update
loader: font update
uts: tem attributes
loader: tem.c comment added
uts: use font module
loader: add font module
loader: build rules for new font setup
uts: gfx_private update for new font structure
uts: early boot update for new font structure
uts: font update
uts: font build rules update for new fonts
uts: tem update to new font structure
loader: module.c needs to include tem_impl.h
uts: gfx_private 8x16 font rework
uts: make font_lookup public
loader: font rework
uts: font rework
9259 libefi: efi_alloc_and_read should check for PMBR
uts: tem utf-8 support
loader: implement tem utf-8 support
loader: tem should be able to display UTF-8
7784 uts: console input should support utf-8
7796 uts: ldterm default to utf-8
uts: do not reset serial console
uts: set up colors even if tem is not console
uts: add type for early boot properties
uts: gfx_private experiment with drm and vga
uts: gfx_private should use setmode drm callback.
uts: identify FB types and set up gfx_private based
loader: replace gop and vesa with framebuffer
uts: boot needs simple tem to support mdb
uts: boot_keyboard should emit esc sequences for
uts: gfx_private FB showuld be written by line
kmdb: set terminal window size
uts: gfx_private needs to keep track of early boot FB
pnglite: move pnglite to usr/src/common
loader: gfx_fb
ficl-sys: add gfx primitives
loader: add illumos.png logo
ficl: add fb-putimage
loader: add png support
loader: add alpha blending for gfx_fb
loader: use term-drawrect for menu frame
ficl: add simple gfx words
uts: provide fb_info via fbgattr dev_specific array.
uts: gfx_private add alpha blending
uts: update sys/ascii.h
uts: tem OSC support (incomplete)
uts: implement env module support and use data from
uts: tem get colors from early boot data
loader: use crc32 from libstand (libz)
loader: optimize for size
loader: pass tem info to the environment
loader: import tem for loader console
loader: UEFI loader needs to set ISADIR based on
loader: need UEFI32 support
8918 loader.efi: add vesa edid support
uts: tem_safe_pix_clear_prom_output() should only
uts: tem_safe_pix_clear_entire_screen() should use
uts: tem_safe_check_first_time() should query cursor
uts: tem implement cls callback & visual_io v4
uts: gfx_vgatext use block cursor for vgatext
uts: gfx_private implement cls callback & visual_io
uts: gfx_private bitmap framebuffer implementation
uts: early start frame buffer console support
uts: font functions should check the input char
uts: font rendering should support 16/24/32bit depths
uts: use smallest font as fallback default.
uts: update terminal dimensions based on selected
7834 uts: vgatext should use gfx_private
uts: add spacing property to 8859-1.bdf
terminfo: add underline for sun-color
terminfo: sun-color has 16 colors
uts: add font load callback type
loader: do not repeat int13 calls with error 0x20 and
8905 loader: add skein/edonr support
8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
loader: pxe receive cleanup
9475 libefi: Do not return only if ReceiveFilter
installboot: should support efi system partition
8931 boot1.efi: scan all display modes rather than
loader: spinconsole updates
loader: gfx experiment to try GOP Blt() function.
sha1 build test
loader: add sha1 hash calculation
common/sha1: update for loader build
loader: biosdisk rework
uts: 32-bit kernel FB needs mapping in low memory
uts: add diag-device
uts: boot console mirror with diag-device
uts: enable very early console on ttya
kmdb: add diag-device as input/output device
uts: test VGA memory exclusion from mapping
uts: clear boot mapping and protect boot pages test
uts: add dboot map debug printf
uts: need to release FB pages in release_bootstrap()
uts: add screenmap ioctl
uts: update sys/queue.h
loader: add illumos uts/common to include path
loader: tem/gfx font cleanup
loader: vbe checks
uts: gfx_private set KD_TEXT when KD_RESETTEXT is
uts: gfx 8-bit update
loader: gfx 8-bit fix
loader: always set media size from partition.
uts: MB2 support for 32-bit kernel
loader: x86 should have tem 80x25
uts: x86 should have tem 80x25
uts: font update
loader: font update
uts: tem attributes
loader: tem.c comment added
uts: use font module
loader: add font module
loader: build rules for new font setup
uts: gfx_private update for new font structure
uts: early boot update for new font structure
uts: font update
uts: font build rules update for new fonts
uts: tem update to new font structure
loader: module.c needs to include tem_impl.h
uts: gfx_private 8x16 font rework
uts: make font_lookup public
loader: font rework
uts: font rework
libefi: efi_alloc_and_read should check for PMBR
uts: tem utf-8 support
loader: implement tem utf-8 support
loader: tem should be able to display UTF-8
7784 uts: console input should support utf-8
7796 uts: ldterm default to utf-8
uts: do not reset serial console
uts: set up colors even if tem is not console
uts: add type for early boot properties
uts: gfx_private experiment with drm and vga
uts: gfx_private should use setmode drm callback.
uts: identify FB types and set up gfx_private based
loader: replace gop and vesa with framebuffer
uts: boot needs simple tem to support mdb
uts: boot_keyboard should emit esc sequences for
uts: gfx_private FB showuld be written by line
kmdb: set terminal window size
uts: gfx_private needs to keep track of early boot FB
pnglite: move pnglite to usr/src/common
loader: gfx_fb
ficl-sys: add gfx primitives
loader: add illumos.png logo
ficl: add fb-putimage
loader: add png support
loader: add alpha blending for gfx_fb
loader: use term-drawrect for menu frame
ficl: add simple gfx words
uts: provide fb_info via fbgattr dev_specific array.
uts: gfx_private add alpha blending
uts: update sys/ascii.h
uts: tem OSC support (incomplete)
uts: implement env module support and use data from
uts: tem get colors from early boot data
loader: use crc32 from libstand (libz)
loader: optimize for size
loader: pass tem info to the environment
loader: import tem for loader console
loader: UEFI loader needs to set ISADIR based on
loader: need UEFI32 support
8918 loader.efi: add vesa edid support
uts: tem_safe_pix_clear_prom_output() should only
uts: tem_safe_pix_clear_entire_screen() should use
uts: tem_safe_check_first_time() should query cursor
uts: tem implement cls callback & visual_io v4
uts: gfx_vgatext use block cursor for vgatext
uts: gfx_private implement cls callback & visual_io
uts: gfx_private bitmap framebuffer implementation
uts: early start frame buffer console support
uts: font functions should check the input char
uts: font rendering should support 16/24/32bit depths
uts: use smallest font as fallback default.
uts: update terminal dimensions based on selected
7834 uts: vgatext should use gfx_private
uts: add spacing property to 8859-1.bdf
terminfo: add underline for sun-color
terminfo: sun-color has 16 colors
uts: add font load callback type
loader: do not repeat int13 calls with error 0x20 and
8905 loader: add skein/edonr support
8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/io/drm/drm_irq.c
+++ new/usr/src/uts/common/io/drm/drm_irq.c
1 1 /*
2 2 * drm_irq.c -- IRQ IOCTL and function support
3 3 * Created: Fri Oct 18 2003 by anholt@FreeBSD.org
4 4 */
5 5 /*
6 6 * Copyright 2003 Eric Anholt
7 7 * Copyright (c) 2009, Intel Corporation.
8 8 * All Rights Reserved.
9 9 *
10 10 * Permission is hereby granted, free of charge, to any person obtaining a
11 11 * copy of this software and associated documentation files (the "Software"),
12 12 * to deal in the Software without restriction, including without limitation
13 13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 14 * and/or sell copies of the Software, and to permit persons to whom the
15 15 * Software is furnished to do so, subject to the following conditions:
16 16 *
17 17 * The above copyright notice and this permission notice (including the next
18 18 * paragraph) shall be included in all copies or substantial portions of the
19 19 * Software.
20 20 *
21 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 24 * ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
25 25 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 27 *
28 28 * Authors:
29 29 * Eric Anholt <anholt@FreeBSD.org>
30 30 *
31 31 */
32 32
33 33 /*
34 34 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
35 35 * Use is subject to license terms.
36 36 */
37 37
38 38 #include "drmP.h"
39 39 #include "drm.h"
40 40 #include "drm_io32.h"
41 41
42 42 /*ARGSUSED*/
43 43 int
44 44 drm_irq_by_busid(DRM_IOCTL_ARGS)
45 45 {
46 46 DRM_DEVICE;
47 47 drm_irq_busid_t irq;
48 48
49 49 DRM_COPYFROM_WITH_RETURN(&irq, (void *)data, sizeof (irq));
50 50
51 51 if ((irq.busnum >> 8) != dev->pci_domain ||
52 52 (irq.busnum & 0xff) != dev->pci_bus ||
53 53 irq.devnum != dev->pci_slot ||
54 54 irq.funcnum != dev->pci_func)
55 55 return (EINVAL);
56 56
57 57 irq.irq = dev->irq;
58 58
59 59 DRM_DEBUG("%d:%d:%d => IRQ %d\n",
60 60 irq.busnum, irq.devnum, irq.funcnum, irq.irq);
61 61
62 62 DRM_COPYTO_WITH_RETURN((void *)data, &irq, sizeof (irq));
63 63
64 64 return (0);
65 65 }
66 66
67 67
68 68 static irqreturn_t
69 69 drm_irq_handler_wrap(DRM_IRQ_ARGS)
70 70 {
71 71 drm_device_t *dev = (void *)arg;
72 72 int ret;
73 73
74 74 mutex_enter(&dev->irq_lock);
75 75 ret = dev->driver->irq_handler(arg);
76 76 mutex_exit(&dev->irq_lock);
77 77
78 78 return (ret);
79 79 }
80 80
81 81 static void vblank_disable_fn(void *arg)
82 82 {
83 83 struct drm_device *dev = (struct drm_device *)arg;
84 84 int i;
85 85
86 86 if (!dev->vblank_disable_allowed)
87 87 return;
88 88
89 89 for (i = 0; i < dev->num_crtcs; i++) {
90 90 if (atomic_read(&dev->vblank_refcount[i]) == 0 &&
91 91 atomic_read(&dev->vblank_enabled[i]) == 1) {
92 92 dev->last_vblank[i] =
93 93 dev->driver->get_vblank_counter(dev, i);
94 94 dev->driver->disable_vblank(dev, i);
95 95 atomic_set(&dev->vblank_enabled[i], 0);
96 96 DRM_DEBUG("disable vblank");
97 97 }
98 98 }
99 99 }
100 100
101 101 void
102 102 drm_vblank_cleanup(struct drm_device *dev)
103 103 {
104 104
105 105 /* Bail if the driver didn't call drm_vblank_init() */
106 106 if (dev->num_crtcs == 0)
107 107 return;
108 108
109 109 vblank_disable_fn((void *)dev);
110 110
111 111 drm_free(dev->vbl_queues, sizeof (wait_queue_head_t) * dev->num_crtcs,
112 112 DRM_MEM_DRIVER);
113 113 drm_free(dev->vbl_sigs, sizeof (struct drm_vbl_sig) * dev->num_crtcs,
114 114 DRM_MEM_DRIVER);
115 115 drm_free(dev->_vblank_count, sizeof (atomic_t) *
116 116 dev->num_crtcs, DRM_MEM_DRIVER);
117 117 drm_free(dev->vblank_refcount, sizeof (atomic_t) *
118 118 dev->num_crtcs, DRM_MEM_DRIVER);
119 119 drm_free(dev->vblank_enabled, sizeof (int) *
120 120 dev->num_crtcs, DRM_MEM_DRIVER);
121 121 drm_free(dev->last_vblank, sizeof (u32) * dev->num_crtcs,
122 122 DRM_MEM_DRIVER);
123 123 drm_free(dev->vblank_inmodeset, sizeof (*dev->vblank_inmodeset) *
124 124 dev->num_crtcs, DRM_MEM_DRIVER);
125 125 dev->num_crtcs = 0;
126 126 }
127 127
128 128 int
129 129 drm_vblank_init(struct drm_device *dev, int num_crtcs)
130 130 {
131 131 int i, ret = ENOMEM;
132 132
133 133 atomic_set(&dev->vbl_signal_pending, 0);
134 134 dev->num_crtcs = num_crtcs;
135 135
136 136
137 137 dev->vbl_queues = drm_alloc(sizeof (wait_queue_head_t) * num_crtcs,
138 138 DRM_MEM_DRIVER);
139 139 if (!dev->vbl_queues)
140 140 goto err;
141 141
142 142 dev->vbl_sigs = drm_alloc(sizeof (struct drm_vbl_sig) * num_crtcs,
143 143 DRM_MEM_DRIVER);
144 144 if (!dev->vbl_sigs)
145 145 goto err;
146 146
147 147 dev->_vblank_count = drm_alloc(sizeof (atomic_t) * num_crtcs,
148 148 DRM_MEM_DRIVER);
149 149 if (!dev->_vblank_count)
150 150 goto err;
151 151
152 152 dev->vblank_refcount = drm_alloc(sizeof (atomic_t) * num_crtcs,
153 153 DRM_MEM_DRIVER);
154 154 if (!dev->vblank_refcount)
155 155 goto err;
156 156
157 157 dev->vblank_enabled = drm_alloc(num_crtcs * sizeof (int),
158 158 DRM_MEM_DRIVER);
159 159 if (!dev->vblank_enabled)
160 160 goto err;
161 161
162 162 dev->last_vblank = drm_alloc(num_crtcs * sizeof (u32), DRM_MEM_DRIVER);
163 163 if (!dev->last_vblank)
164 164 goto err;
165 165
166 166 dev->vblank_inmodeset = drm_alloc(num_crtcs * sizeof (int),
167 167 DRM_MEM_DRIVER);
168 168 if (!dev->vblank_inmodeset)
169 169 goto err;
170 170
171 171 /* Zero per-crtc vblank stuff */
172 172 for (i = 0; i < num_crtcs; i++) {
173 173 DRM_INIT_WAITQUEUE(&dev->vbl_queues[i], DRM_INTR_PRI(dev));
174 174 TAILQ_INIT(&dev->vbl_sigs[i]);
175 175 atomic_set(&dev->_vblank_count[i], 0);
176 176 atomic_set(&dev->vblank_refcount[i], 0);
177 177 }
178 178
179 179 dev->vblank_disable_allowed = 1;
180 180 return (0);
181 181
182 182 err:
183 183 DRM_ERROR("drm_vblank_init: alloc error");
184 184 drm_vblank_cleanup(dev);
|
↓ open down ↓ |
184 lines elided |
↑ open up ↑ |
185 185 return (ret);
186 186 }
187 187
188 188 /*ARGSUSED*/
189 189 static int
190 190 drm_install_irq_handle(drm_device_t *dev)
191 191 {
192 192 dev_info_t *dip = dev->dip;
193 193
194 194 if (dip == NULL) {
195 - DRM_ERROR("drm_install_irq_handle: cannot get vgatext's dip");
195 + DRM_ERROR("drm_install_irq_handle: cannot get gfxp_fb's dip");
196 196 return (DDI_FAILURE);
197 197 }
198 198
199 199 if (ddi_intr_hilevel(dip, 0) != 0) {
200 200 DRM_ERROR("drm_install_irq_handle: "
201 201 "high-level interrupts are not supported");
202 202 return (DDI_FAILURE);
203 203 }
204 204
205 205 if (ddi_get_iblock_cookie(dip, (uint_t)0,
206 206 &dev->intr_block) != DDI_SUCCESS) {
207 207 DRM_ERROR("drm_install_irq_handle: cannot get iblock cookie");
208 208 return (DDI_FAILURE);
209 209 }
210 210
211 211 /* setup the interrupt handler */
212 212 if (ddi_add_intr(dip, 0, &dev->intr_block,
213 213 (ddi_idevice_cookie_t *)NULL, drm_irq_handler_wrap,
214 214 (caddr_t)dev) != DDI_SUCCESS) {
215 215 DRM_ERROR("drm_install_irq_handle: ddi_add_intr failed");
216 216 return (DDI_FAILURE);
217 217 }
218 218
219 219 return (DDI_SUCCESS);
220 220 }
221 221
222 222 /*ARGSUSED*/
223 223 int
224 224 drm_irq_install(drm_device_t *dev)
225 225 {
226 226 int ret;
227 227
228 228 if (dev->dev_private == NULL) {
229 229 DRM_ERROR("drm_irq_install: dev_private is NULL");
230 230 return (EINVAL);
231 231 }
232 232
233 233 if (dev->irq_enabled) {
234 234 DRM_ERROR("drm_irq_install: irq already enabled");
235 235 return (EBUSY);
236 236 }
237 237
238 238 DRM_DEBUG("drm_irq_install irq=%d\n", dev->irq);
239 239
240 240 /* before installing handler */
241 241 ret = dev->driver->irq_preinstall(dev);
242 242 if (ret)
243 243 return (EINVAL);
244 244
245 245 /* install handler */
246 246 ret = drm_install_irq_handle(dev);
247 247 if (ret != DDI_SUCCESS) {
248 248 DRM_ERROR("drm_irq_install: drm_install_irq_handle failed");
249 249 return (ret);
250 250 }
251 251
252 252 /* after installing handler */
253 253 dev->driver->irq_postinstall(dev);
254 254
255 255 dev->irq_enabled = 1;
256 256 dev->context_flag = 0;
257 257
258 258 return (0);
259 259 }
260 260
261 261 static void
262 262 drm_uninstall_irq_handle(drm_device_t *dev)
263 263 {
264 264 ASSERT(dev->dip);
265 265 ddi_remove_intr(dev->dip, 0, dev->intr_block);
266 266 }
267 267
268 268
269 269 /*ARGSUSED*/
270 270 int
271 271 drm_irq_uninstall(drm_device_t *dev)
272 272 {
273 273 int i;
274 274 if (!dev->irq_enabled) {
275 275 return (EINVAL);
276 276 }
277 277 dev->irq_enabled = 0;
278 278
279 279 /*
280 280 * Wake up any waiters so they don't hang.
281 281 */
282 282 DRM_SPINLOCK(&dev->vbl_lock);
283 283 for (i = 0; i < dev->num_crtcs; i++) {
284 284 DRM_WAKEUP(&dev->vbl_queues[i]);
285 285 dev->vblank_enabled[i] = 0;
286 286 }
287 287 DRM_SPINUNLOCK(&dev->vbl_lock);
288 288
289 289 dev->driver->irq_uninstall(dev);
290 290 drm_uninstall_irq_handle(dev);
291 291 dev->locked_tasklet_func = NULL;
292 292
293 293 return (DDI_SUCCESS);
294 294 }
295 295
296 296 /*ARGSUSED*/
297 297 int
298 298 drm_control(DRM_IOCTL_ARGS)
299 299 {
300 300 DRM_DEVICE;
301 301 drm_control_t ctl;
302 302 int err;
303 303
304 304 DRM_COPYFROM_WITH_RETURN(&ctl, (void *)data, sizeof (ctl));
305 305
306 306 switch (ctl.func) {
307 307 case DRM_INST_HANDLER:
308 308 /*
309 309 * Handle drivers whose DRM used to require IRQ setup but the
310 310 * no longer does.
311 311 */
312 312 return (drm_irq_install(dev));
313 313 case DRM_UNINST_HANDLER:
314 314 err = drm_irq_uninstall(dev);
315 315 return (err);
316 316 default:
317 317 return (EINVAL);
318 318 }
319 319 }
320 320
321 321 u32
322 322 drm_vblank_count(struct drm_device *dev, int crtc)
323 323 {
324 324 return (atomic_read(&dev->_vblank_count[crtc]));
325 325 }
326 326
327 327 static void drm_update_vblank_count(struct drm_device *dev, int crtc)
328 328 {
329 329 u32 cur_vblank, diff;
330 330 /*
331 331 * Interrupts were disabled prior to this call, so deal with counter
332 332 * wrap if needed.
333 333 * NOTE! It's possible we lost a full dev->max_vblank_count events
334 334 * here if the register is small or we had vblank interrupts off for
335 335 * a long time.
336 336 */
337 337 cur_vblank = dev->driver->get_vblank_counter(dev, crtc);
338 338 diff = cur_vblank - dev->last_vblank[crtc];
339 339 if (cur_vblank < dev->last_vblank[crtc]) {
340 340 diff += dev->max_vblank_count;
341 341 DRM_DEBUG("last_vblank[%d]=0x%x, cur_vblank=0x%x => diff=0x%x\n",
342 342 crtc, dev->last_vblank[crtc], cur_vblank, diff);
343 343 }
344 344
345 345 atomic_add(diff, &dev->_vblank_count[crtc]);
346 346 }
347 347
348 348 static timeout_id_t timer_id = NULL;
349 349
350 350 int
351 351 drm_vblank_get(struct drm_device *dev, int crtc)
352 352 {
353 353 int ret = 0;
354 354
355 355 DRM_SPINLOCK(&dev->vbl_lock);
356 356
357 357 if (timer_id != NULL) {
358 358 (void) untimeout(timer_id);
359 359 timer_id = NULL;
360 360 }
361 361
362 362 /* Going from 0->1 means we have to enable interrupts again */
363 363 atomic_add(1, &dev->vblank_refcount[crtc]);
364 364 if (dev->vblank_refcount[crtc] == 1 &&
365 365 atomic_read(&dev->vblank_enabled[crtc]) == 0) {
366 366 ret = dev->driver->enable_vblank(dev, crtc);
367 367 if (ret)
368 368 atomic_dec(&dev->vblank_refcount[crtc]);
369 369 else {
370 370 atomic_set(&dev->vblank_enabled[crtc], 1);
371 371 drm_update_vblank_count(dev, crtc);
372 372 }
373 373 }
374 374 DRM_SPINUNLOCK(&dev->vbl_lock);
375 375
376 376 return (ret);
377 377 }
378 378
379 379 void
380 380 drm_vblank_put(struct drm_device *dev, int crtc)
381 381 {
382 382 DRM_SPINLOCK(&dev->vbl_lock);
383 383 /* Last user schedules interrupt disable */
384 384 atomic_dec(&dev->vblank_refcount[crtc]);
385 385
386 386 if (dev->vblank_refcount[crtc] == 0)
387 387 timer_id = timeout(vblank_disable_fn, (void *) dev, 5*DRM_HZ);
388 388
389 389 DRM_SPINUNLOCK(&dev->vbl_lock);
390 390 }
391 391
392 392 /*
393 393 * drm_modeset_ctl - handle vblank event counter changes across mode switch
394 394 * @DRM_IOCTL_ARGS: standard ioctl arguments
395 395 *
396 396 * Applications should call the %_DRM_PRE_MODESET and %_DRM_POST_MODESET
397 397 * ioctls around modesetting so that any lost vblank events are accounted for.
398 398 *
399 399 * Generally the counter will reset across mode sets. If interrupts are
400 400 * enabled around this call, we don't have to do anything since the counter
401 401 * will have already been incremented.
402 402 */
403 403 /*ARGSUSED*/
404 404 int
405 405 drm_modeset_ctl(DRM_IOCTL_ARGS)
406 406 {
407 407 DRM_DEVICE;
408 408 struct drm_modeset_ctl modeset;
409 409 int crtc, ret = 0;
410 410
411 411 /* If drm_vblank_init() hasn't been called yet, just no-op */
412 412 if (!dev->num_crtcs)
413 413 goto out;
414 414
415 415 DRM_COPYFROM_WITH_RETURN(&modeset, (void *)data,
416 416 sizeof (modeset));
417 417
418 418 crtc = modeset.crtc;
419 419 if (crtc >= dev->num_crtcs) {
420 420 ret = -EINVAL;
421 421 goto out;
422 422 }
423 423
424 424 /*
425 425 * To avoid all the problems that might happen if interrupts
426 426 * were enabled/disabled around or between these calls, we just
427 427 * have the kernel take a reference on the CRTC (just once though
428 428 * to avoid corrupting the count if multiple, mismatch calls occur),
429 429 * so that interrupts remain enabled in the interim.
430 430 */
431 431 switch (modeset.cmd) {
432 432 case _DRM_PRE_MODESET:
433 433 if (!dev->vblank_inmodeset[crtc]) {
434 434 dev->vblank_inmodeset[crtc] = 1;
435 435 ret = drm_vblank_get(dev, crtc);
436 436 }
437 437 break;
438 438 case _DRM_POST_MODESET:
439 439 if (dev->vblank_inmodeset[crtc]) {
440 440 DRM_SPINLOCK(&dev->vbl_lock);
441 441 dev->vblank_disable_allowed = 1;
442 442 dev->vblank_inmodeset[crtc] = 0;
443 443 DRM_SPINUNLOCK(&dev->vbl_lock);
444 444 drm_vblank_put(dev, crtc);
445 445 }
446 446 break;
447 447 default:
448 448 ret = -EINVAL;
449 449 break;
450 450 }
451 451
452 452 out:
453 453 return (ret);
454 454 }
455 455
456 456 /*ARGSUSED*/
457 457 int
458 458 drm_wait_vblank(DRM_IOCTL_ARGS)
459 459 {
460 460 DRM_DEVICE;
461 461 drm_wait_vblank_t vblwait;
462 462 int ret, flags, crtc;
463 463 unsigned int sequence;
464 464
465 465 if (!dev->irq_enabled) {
466 466 DRM_ERROR("wait vblank, EINVAL");
467 467 return (EINVAL);
468 468 }
469 469 #ifdef _MULTI_DATAMODEL
470 470 if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) {
471 471 drm_wait_vblank_32_t vblwait32;
472 472 DRM_COPYFROM_WITH_RETURN(&vblwait32, (void *)data,
473 473 sizeof (vblwait32));
474 474 vblwait.request.type = vblwait32.request.type;
475 475 vblwait.request.sequence = vblwait32.request.sequence;
476 476 vblwait.request.signal = vblwait32.request.signal;
477 477 } else {
478 478 #endif
479 479 DRM_COPYFROM_WITH_RETURN(&vblwait, (void *)data,
480 480 sizeof (vblwait));
481 481 #ifdef _MULTI_DATAMODEL
482 482 }
483 483 #endif
484 484
485 485 if (vblwait.request.type &
486 486 ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) {
487 487 DRM_ERROR("drm_wait_vblank: wrong request type 0x%x",
488 488 vblwait.request.type);
489 489 return (EINVAL);
490 490 }
491 491
492 492 flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK;
493 493 crtc = flags & _DRM_VBLANK_SECONDARY ? 1 : 0;
494 494 if (crtc >= dev->num_crtcs) {
495 495 DRM_ERROR("wait vblank operation not support");
496 496 return (ENOTSUP);
497 497 }
498 498 ret = drm_vblank_get(dev, crtc);
499 499 if (ret) {
500 500 DRM_ERROR("can't get drm vblank %d", ret);
501 501 return (ret);
502 502 }
503 503 sequence = drm_vblank_count(dev, crtc);
504 504
505 505 switch (vblwait.request.type & _DRM_VBLANK_TYPES_MASK) {
506 506 case _DRM_VBLANK_RELATIVE:
507 507 vblwait.request.sequence += sequence;
508 508 vblwait.request.type &= ~_DRM_VBLANK_RELATIVE;
509 509 /*FALLTHROUGH*/
510 510 case _DRM_VBLANK_ABSOLUTE:
511 511 break;
512 512 default:
513 513 DRM_DEBUG("wait vblank return EINVAL");
514 514 return (EINVAL);
515 515 }
516 516
517 517 if ((flags & _DRM_VBLANK_NEXTONMISS) &&
518 518 (sequence - vblwait.request.sequence) <= (1<<23)) {
519 519 vblwait.request.sequence = sequence + 1;
520 520 }
521 521
522 522 if (flags & _DRM_VBLANK_SIGNAL) {
523 523 /*
524 524 * Don't block process, send signal when vblank interrupt
525 525 */
526 526 DRM_ERROR("NOT SUPPORT YET, SHOULD BE ADDED");
527 527 cmn_err(CE_WARN, "NOT SUPPORT YET, SHOULD BE ADDED");
528 528 ret = EINVAL;
529 529 goto done;
530 530 } else {
531 531 /* block until vblank interupt */
532 532 /* shared code returns -errno */
533 533 DRM_WAIT_ON(ret, &dev->vbl_queues[crtc], 3 * DRM_HZ,
534 534 (((drm_vblank_count(dev, crtc)
535 535 - vblwait.request.sequence) <= (1 << 23)) ||
536 536 !dev->irq_enabled));
537 537 if (ret != EINTR) {
538 538 struct timeval now;
539 539 (void) uniqtime(&now);
540 540 vblwait.reply.tval_sec = now.tv_sec;
541 541 vblwait.reply.tval_usec = now.tv_usec;
542 542 vblwait.reply.sequence = drm_vblank_count(dev, crtc);
543 543 }
544 544 }
545 545
546 546 done:
547 547 #ifdef _MULTI_DATAMODEL
548 548 if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) {
549 549 drm_wait_vblank_32_t vblwait32;
550 550 vblwait32.reply.type = vblwait.reply.type;
551 551 vblwait32.reply.sequence = vblwait.reply.sequence;
552 552 vblwait32.reply.tval_sec = (int32_t)vblwait.reply.tval_sec;
553 553 vblwait32.reply.tval_usec = (int32_t)vblwait.reply.tval_usec;
554 554 DRM_COPYTO_WITH_RETURN((void *)data, &vblwait32,
555 555 sizeof (vblwait32));
556 556 } else {
557 557 #endif
558 558 DRM_COPYTO_WITH_RETURN((void *)data, &vblwait,
559 559 sizeof (vblwait));
560 560 #ifdef _MULTI_DATAMODEL
561 561 }
562 562 #endif
563 563
564 564 drm_vblank_put(dev, crtc);
565 565 return (ret);
566 566 }
567 567
568 568
569 569 /*ARGSUSED*/
570 570 void
571 571 drm_vbl_send_signals(drm_device_t *dev)
572 572 {
573 573 DRM_DEBUG("drm_vbl_send_signals");
574 574 }
575 575
576 576 void
577 577 drm_handle_vblank(struct drm_device *dev, int crtc)
578 578 {
579 579 atomic_inc(&dev->_vblank_count[crtc]);
580 580 DRM_WAKEUP(&dev->vbl_queues[crtc]);
581 581 }
|
↓ open down ↓ |
376 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX