xserver/hw/kdrive/ati ati.c, 1.16, 1.17 ati.h, 1.10, 1.11 ati_cursor.c, 1.5, 1.6 ati_reg.h, 1.6, 1.7
Keith Packard <xserver-commit-u7BhqnqprCWvj1b/[email protected]>
| Newsgroups | gmane.comp.freedesktop.xserver.cvs |
|---|---|
| Message-ID | <[email protected]> |
Committed by: keithp Update of /cvs/xserver/xserver/hw/kdrive/ati In directory pdx:/tmp/cvs-serv11126/hw/kdrive/ati Modified Files: ati.c ati.h ati_cursor.c ati_reg.h Log Message: 2004-07-22 Keith Packard <[email protected]> reviewed by: <delete if not using a buddy> * hw/kdrive/ati/ati.c: (ATISetOffscreen), (ATISetPitch), (ATIRandRSetConfig), (ATIPreserve), (ATIRestore), (ATIEnable): * hw/kdrive/ati/ati.h: * hw/kdrive/ati/ati_cursor.c: (RadeonLoadCursor), (ATIUnloadCursor), (ATICursorEnable): * hw/kdrive/ati/ati_reg.h: Correct pitch so that accelerator can run on 1400x1050 screens. Add a few more register sets for cursors. Index: ati.c =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- ati.c 19 Jul 2004 07:53:53 -0000 1.16 +++ ati.c 22 Jul 2004 18:17:59 -0000 1.17 @@ -291,12 +291,37 @@ static void ATISetOffscreen (KdScreenInfo *screen) { -#if defined(USE_DRI) && defined(GLXEXT) ATICardInfo(screen); +#if defined(USE_DRI) && defined(GLXEXT) ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver; int l; #endif - int screen_size = screen->fb[0].byteStride * screen->height; + int screen_size; + char *mmio = atic->reg_base; + + /* check (and adjust) pitch */ + if (mmio) + { + int byteStride = screen->fb[0].byteStride; + int bitStride; + int pixelStride; + int bpp = screen->fb[0].bitsPerPixel; + + /* + * Ensure frame buffer is correctly aligned + */ + if (byteStride & 0x3f) + { + byteStride = (byteStride + 0x3f) & ~0x3f; + bitStride = byteStride * 8; + pixelStride = bitStride / bpp; + + screen->fb[0].byteStride = byteStride; + screen->fb[0].pixelStride = pixelStride; + } + } + + screen_size = screen->fb[0].byteStride * screen->height; screen->off_screen_base = screen_size; @@ -350,6 +375,62 @@ #endif /* USE_DRI && GLXEXT */ } +static void +ATISetPitch (KdScreenInfo *screen) +{ + ATICardInfo(screen); +#if defined(USE_DRI) && defined(GLXEXT) + ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver; + int l; +#endif + char *mmio = atic->reg_base; + + /* check (and adjust) pitch for radeon */ + if (mmio) + { + int byteStride = screen->fb[0].byteStride; + int bitStride; + int pixelStride; + int bpp = screen->fb[0].bitsPerPixel; + CARD32 crtc_pitch; + CARD32 crtc2_pitch; +#if 0 + CARD32 crtc_ext_cntl; + CARD32 dac_cntl; +#endif + bitStride = byteStride * 8; + pixelStride = bitStride / bpp; + + crtc_pitch = (pixelStride >> 3); + crtc_pitch |= crtc_pitch << 16; + crtc2_pitch = (pixelStride >> 3); + crtc2_pitch |= crtc2_pitch << 16; +#if 0 + crtc_ext_cntl = MMIO_IN32 (mmio, ATI_REG_CRTC_EXT_CNTL); + dac_cntl = MMIO_IN32 (mmio, ATI_REG_DAC_CNTL); + /* Turn off the screen */ + MMIO_OUT32 (mmio, ATI_REG_CRTC_EXT_CNTL, + crtc_ext_cntl | + ATI_CRTC_VSYNC_DIS | + ATI_CRTC_HSYNC_DIS | + ATI_CRTC_DISPLAY_DIS); + MMIO_OUT32 (mmio, ATI_REG_DAC_CNTL, + dac_cntl | + ATI_DAC_RANGE_CNTL | + ATI_DAC_BLANKING); +#endif + MMIO_OUT32 (mmio, ATI_REG_CRTC_PITCH, crtc_pitch); + MMIO_OUT32 (mmio, ATI_REG_CRTC2_PITCH, crtc2_pitch); +#if 0 + /* Turn the screen back on */ + MMIO_OUT32 (mmio, ATI_REG_CRTC_EXT_CNTL, + crtc_ext_cntl); + MMIO_OUT32 (mmio, ATI_REG_DAC_CNTL, + dac_cntl); +#endif + } +} + static Bool ATIScreenInit(KdScreenInfo *screen) { @@ -406,6 +487,18 @@ ATIDrawDisable (pScreen); ret = atic->backend_funcs.randrSetConfig(pScreen, randr, rate, pSize); ATISetOffscreen (screen); + ATISetPitch (screen); + /* + * Set frame buffer mapping + */ + (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), + pScreen->width, + pScreen->height, + screen->fb[0].depth, + screen->fb[0].bitsPerPixel, + screen->fb[0].byteStride, + screen->fb[0].frameBuffer); + ATIDrawEnable (pScreen); return ret; } @@ -502,15 +595,25 @@ ATIPreserve(KdCardInfo *card) { ATICardInfo *atic = card->driver; + char *mmio = atic->reg_base; atic->backend_funcs.preserve(card); + if (atic->is_radeon && mmio) + { + atic->crtc_pitch = MMIO_IN32(mmio, ATI_REG_CRTC_PITCH); + atic->crtc2_pitch = MMIO_IN32(mmio, ATI_REG_CRTC2_PITCH); + + } } static void ATIRestore(KdCardInfo *card) { ATICardInfo *atic = card->driver; + char *mmio = atic->reg_base; + MMIO_OUT32(mmio, ATI_REG_CRTC_PITCH, atic->crtc_pitch); + MMIO_OUT32(mmio, ATI_REG_CRTC2_PITCH, atic->crtc2_pitch); ATIUnmapReg(card, atic); atic->backend_funcs.restore(card); @@ -534,13 +637,13 @@ if (!atic->backend_funcs.enable(pScreen)) return FALSE; - ATISetOffscreen (pScreenPriv->screen); - if ((atic->reg_base == NULL) && !ATIMapReg(pScreenPriv->screen->card, atic)) return FALSE; - ATIDPMS(pScreen, KD_DPMS_NORMAL); + ATISetOffscreen (pScreenPriv->screen); + + ATISetPitch (pScreenPriv->screen); return TRUE; } Index: ati.h =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ati.h 19 Jul 2004 07:53:54 -0000 1.10 +++ ati.h 22 Jul 2004 18:17:59 -0000 1.11 @@ -146,6 +146,8 @@ Bool is_r300; Bool is_agp; char *busid; + CARD32 crtc_pitch; + CARD32 crtc2_pitch; #ifdef USE_DRI int drmFd; #endif /* USE_DRI */ Index: ati_cursor.c =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_cursor.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ati_cursor.c 19 Jul 2004 11:42:49 -0000 1.5 +++ ati_cursor.c 22 Jul 2004 18:17:59 -0000 1.6 @@ -256,9 +256,14 @@ h = bits->height; if (h > ATI_CURSOR_HEIGHT) h = ATI_CURSOR_HEIGHT; + + tmp = MMIO_IN32(mmio, 0x7c); + tmp = 0x00010f80; + MMIO_OUT32 (mmio, 0x7c, tmp); tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL); - MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp & ~ATI_CRTC_CUR_EN); + tmp &= ~(ATI_CRTC_CUR_EN | ATI_CRTC_ICON_EN | ATI_CRTC_ARGB_EN); + MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp); /* Stick new image into cursor memory */ ram = (CARD32 *)(pScreenPriv->screen->memory_base + @@ -336,7 +341,7 @@ /* Enable the cursor */ tmp &= ~(ATI_CRTC_ICON_EN); - tmp |= (ATI_CRTC_ARGB_EN); + tmp |= ATI_CRTC_ARGB_EN; tmp |= ATI_CRTC_CUR_EN; MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp); } @@ -349,7 +354,8 @@ CARD8 *mmio = atic->reg_base; CARD32 tmp; - tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL) & ~ATI_CRTC_CUR_EN; + tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL); + tmp &= ~(ATI_CRTC_CUR_EN | ATI_CRTC_ICON_EN | ATI_CRTC_ARGB_EN); MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp); } @@ -471,11 +477,11 @@ if (atic->is_radeon) pCurPriv->area = KdOffscreenAlloc(pScreen, ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4, - 1, TRUE, ATICursorSave, atis); + 128, TRUE, ATICursorSave, atis); else pCurPriv->area = KdOffscreenAlloc(pScreen, ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 2, - 1, TRUE, ATICursorSave, atis); + 32, TRUE, ATICursorSave, atis); } if (pCurPriv->area == NULL) FatalError("Couldn't allocate offscreen memory for cursor.\n"); Index: ati_reg.h =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_reg.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ati_reg.h 26 Jun 2004 04:13:03 -0000 1.6 +++ ati_reg.h 22 Jul 2004 18:17:59 -0000 1.7 @@ -42,17 +42,17 @@ #define ATI_REG_GEN_INT_CNTL 0x0040 #define ATI_REG_GEN_CNTL 0x0050 -# define ATI_CRTC_DBL_SCAN_EN (1 << 0) -# define ATI_CRTC_INTERLACE_EN (1 << 1) -# define ATI_CRTC_CSYNC_EN (1 << 4) -# define ATI_CRTC_PIX_WIDTH_MASK (7 << 8) -# define ATI_CRTC_CUR_EN (1 << 16) -# define ATI_CRTC_CUR_MODE_MASK (7 << 17) -# define ATI_CRTC_ICON_EN (1 << 20) -# define ATI_CRTC_ARGB_EN (2 << 20) -# define ATI_CRTC_EXT_DISP_EN (1 << 24) -# define ATI_CRTC_EN (1 << 25) -# define ATI_CRTC_DISP_REQ_EN_B (1 << 26) +# define ATI_CRTC_DBL_SCAN_EN (1 << 0) /* 0x00000001 */ +# define ATI_CRTC_INTERLACE_EN (1 << 1) /* 0x00000002 */ +# define ATI_CRTC_CSYNC_EN (1 << 4) /* 0x00000010 */ +# define ATI_CRTC_PIX_WIDTH_MASK (7 << 8) /* 0x00000700 */ +# define ATI_CRTC_CUR_EN (1 << 16) /* 0x00010000 */ +# define ATI_CRTC_CUR_MODE_MASK (7 << 17) /* 0x000e0000 */ +# define ATI_CRTC_ICON_EN (1 << 20) /* 0x00100000 */ +# define ATI_CRTC_ARGB_EN (2 << 20) /* 0x00200000 */ +# define ATI_CRTC_EXT_DISP_EN (1 << 24) /* 0x01000000 */ +# define ATI_CRTC_EN (1 << 25) /* 0x02000000 */ +# define ATI_CRTC_DISP_REQ_EN_B (1 << 26) /* 0x04000000 */ #define ATI_REG_CRTC_EXT_CNTL 0x0054 # define ATI_CRTC_EN (1 << 25)