2 * Copyright (c) 2007 NVIDIA, Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include <cursorstr.h>
28 #include "nv_include.h"
29 #include "nv50_type.h"
30 #include "nv50_cursor.h"
31 #include "nv50_display.h"
33 #define CURSOR_PTR ((CARD32*)pNv->Cursor->map)
35 void NV50SetCursorPosition(xf86CrtcPtr crtc, int x, int y)
37 NVPtr pNv = NVPTR(crtc->scrn);
38 const int headOff = 0x1000*NV50CrtcGetHead(crtc);
42 pNv->REGS[(0x00647084 + headOff)/4] = y << 16 | x;
43 pNv->REGS[(0x00647080 + headOff)/4] = 0;
46 void NV50LoadCursorARGB(xf86CrtcPtr crtc, CARD32 *src)
48 NVPtr pNv = NVPTR(crtc->scrn);
49 CARD32 *dst = CURSOR_PTR;
51 /* Assume cursor is 64x64 */
52 memcpy(dst, src, 64 * 64 * 4);
55 Bool NV50CursorAcquire(ScrnInfoPtr pScrn)
57 NVPtr pNv = NVPTR(pScrn);
58 xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
61 if(!pNv->HWCursor) return TRUE;
63 /* Initialize the cursor on each head */
64 for(i = 0; i < xf86_config->num_crtc; i++) {
65 const int headOff = 0x10 * NV50CrtcGetHead(xf86_config->crtc[i]);
67 pNv->REGS[(0x00610270+headOff)/4] = 0x2000;
68 while(pNv->REGS[(0x00610270+headOff)/4] & 0x30000);
70 pNv->REGS[(0x00610270+headOff)/4] = 1;
71 while((pNv->REGS[(0x00610270+headOff)/4] & 0x30000) != 0x10000);
77 void NV50CursorRelease(ScrnInfoPtr pScrn)
79 NVPtr pNv = NVPTR(pScrn);
80 xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
83 if(!pNv->HWCursor) return;
85 /* Release the cursor on each head */
86 for(i = 0; i < xf86_config->num_crtc; i++) {
87 const int headOff = 0x10 * NV50CrtcGetHead(xf86_config->crtc[i]);
89 pNv->REGS[(0x00610270+headOff)/4] = 0;
90 while(pNv->REGS[(0x00610270+headOff)/4] & 0x30000);
94 Bool NV50CursorInit(ScreenPtr pScreen)
96 return xf86_cursors_init(pScreen, 64, 64,
97 HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
98 HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 |
99 HARDWARE_CURSOR_ARGB);