summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-03-11 16:21:58 -0600
committerJordan Crouse <jordan.crouse@amd.com>2008-03-14 14:16:42 -0600
commit1fd63467e3fa71f289f80dba013046d0065ff3f3 (patch)
tree7fb9b02c9c387818ece447b82ad2d183d423cd15
parentec8edd1393f482ca42b401463f0f09580aa263a0 (diff)
Massive coding style fixup - move to X coding style,
remove trailing whitespace, zap unused files and remove blocks of ifdefed out code.
-rw-r--r--src/cim_dev.h8
-rw-r--r--src/cimarron.c4
-rw-r--r--src/durango.c60
-rw-r--r--src/geode.h330
-rw-r--r--src/geode_common.c140
-rw-r--r--src/geode_driver.c6
-rw-r--r--src/geode_msr.c87
-rw-r--r--src/geode_pcirename.h5
-rw-r--r--src/gx_accel.c1085
-rw-r--r--src/gx_cursor.c150
-rw-r--r--src/gx_driver.c2106
-rw-r--r--src/gx_randr.c8
-rw-r--r--src/gx_regacc.c122
-rw-r--r--src/gx_rotate.c34
-rw-r--r--src/gx_shadow.c426
-rw-r--r--src/gx_vga.c232
-rw-r--r--src/gx_video.c969
-rw-r--r--src/lx_cursor.c132
-rw-r--r--src/lx_driver.c954
-rw-r--r--src/lx_exa.c1097
-rw-r--r--src/lx_randr.c7
-rw-r--r--src/lx_regacc.c8
-rw-r--r--src/lx_rotate.c337
-rw-r--r--src/lx_vga.c1
-rw-r--r--src/lx_video.c1431
-rw-r--r--src/panel.c12
-rw-r--r--src/z4l.c1184
27 files changed, 5274 insertions, 5661 deletions
diff --git a/src/cim_dev.h b/src/cim_dev.h
index 85eac1e..f491eaf 100644
--- a/src/cim_dev.h
+++ b/src/cim_dev.h
@@ -32,10 +32,10 @@
#define CIMDEV_MINOR_DEV 156
/* Block flags */
-#define CIM_F_FREE 0x01 /* This block is marked as free */
-#define CIM_F_CMDBUF 0x02 /* GP command buffer flag */
-#define CIM_F_PRIVATE 0x04 /* This block is reserved only for its owner */
-#define CIM_F_PUBLIC 0x08 /* This block can be used by the world */
+#define CIM_F_FREE 0x01 /* This block is marked as free */
+#define CIM_F_CMDBUF 0x02 /* GP command buffer flag */
+#define CIM_F_PRIVATE 0x04 /* This block is reserved only for its owner */
+#define CIM_F_PUBLIC 0x08 /* This block can be used by the world */
typedef struct
{
diff --git a/src/cimarron.c b/src/cimarron.c
index 65df4d2..b6986fe 100644
--- a/src/cimarron.c
+++ b/src/cimarron.c
@@ -178,8 +178,8 @@ unsigned char *cim_vg_ptr = (unsigned char *)0;
* to share the MSR code with the GX code */
#ifdef CIMARRON_MSR_HOOKS
-void (*cim_rdmsr)(unsigned long, unsigned long *, unsigned long *);
-void (*cim_wrmsr)(unsigned long, unsigned long, unsigned long);
+void (*cim_rdmsr) (unsigned long, unsigned long *, unsigned long *);
+void (*cim_wrmsr) (unsigned long, unsigned long, unsigned long);
#endif
/*----------------------------------------------------------------------*/
diff --git a/src/durango.c b/src/durango.c
index a41d172..6861acc 100644
--- a/src/durango.c
+++ b/src/durango.c
@@ -37,20 +37,19 @@
#include <unistd.h>
#include <errno.h>
#include <compiler.h>
-#include <os.h> /* ErrorF() */
+#include <os.h> /* ErrorF() */
/* Compiler options */
-
#define GFX_DISPLAY_GU1 0 /* 1st generation display controller */
#define GFX_DISPLAY_GU2 1 /* 2nd generation display controller */
-#define GFX_INIT_DYNAMIC 0 /* runtime selection */
-#define GFX_INIT_GU1 0 /* SC1200/GX1 */
-#define GFX_INIT_GU2 1 /* GX */
+#define GFX_INIT_DYNAMIC 0 /* runtime selection */
+#define GFX_INIT_GU1 0 /* SC1200/GX1 */
+#define GFX_INIT_GU2 1 /* GX */
-#define GFX_MSR_DYNAMIC 0 /* runtime selection */
-#define GFX_MSR_REDCLOUD 1 /* GX */
+#define GFX_MSR_DYNAMIC 0 /* runtime selection */
+#define GFX_MSR_REDCLOUD 1 /* GX */
#define GFX_2DACCEL_DYNAMIC 0 /* runtime selection */
#define GFX_2DACCEL_GU1 0 /* 1st generation 2D accelerator */
@@ -81,7 +80,7 @@
#define FB4MB 1 /* Set to use 4Mb vid ram for Pyramid */
#define GFX_NO_IO_IN_WAIT_MACROS 1 /* Set to remove I/O accesses in GP
- bit testing */
+ * bit testing */
#define GFX_READ_ROUTINES 1
#include "gfx_rtns.h"
@@ -156,7 +155,6 @@ gfx_outd(unsigned short port, unsigned long data)
: "=a" (*(low)), "=d" (*(high)) \
: "c" (msr | adr))
-
#define vsa_msr_write(msr,adr,high,low) \
{ int d0, d1, d2, d3, d4; \
__asm__ __volatile__( \
@@ -180,37 +178,39 @@ gfx_outd(unsigned short port, unsigned long data)
extern int GeodeWriteMSR(unsigned long, unsigned long, unsigned long);
extern int GeodeReadMSR(unsigned long, unsigned long *, unsigned long *);
-void gfx_msr_asm_write(unsigned short reg, unsigned long addr,
-unsigned long *hi, unsigned long *lo)
+void
+gfx_msr_asm_write(unsigned short reg, unsigned long addr,
+ unsigned long *hi, unsigned long *lo)
{
- static int msr_method = 0;
+ static int msr_method = 0;
- if (msr_method == 0) {
- if (!GeodeWriteMSR(addr | reg, *lo, *hi))
- return;
+ if (msr_method == 0) {
+ if (!GeodeWriteMSR(addr | reg, *lo, *hi))
+ return;
- msr_method = 1;
- }
+ msr_method = 1;
+ }
- /* This is the fallback VSA method - not preferred */
- vsa_msr_write(reg, addr, hi, lo);
+ /* This is the fallback VSA method - not preferred */
+ vsa_msr_write(reg, addr, hi, lo);
}
-void gfx_msr_asm_read(unsigned short reg, unsigned long addr,
-unsigned long *hi, unsigned long *lo)
+void
+gfx_msr_asm_read(unsigned short reg, unsigned long addr,
+ unsigned long *hi, unsigned long *lo)
{
- static int msr_method = 0;
+ static int msr_method = 0;
- if (msr_method == 0) {
- if (!GeodeReadMSR(addr | reg, lo, hi))
- return;
+ if (msr_method == 0) {
+ if (!GeodeReadMSR(addr | reg, lo, hi))
+ return;
- ErrorF("Unable to read the MSR - reverting to the VSA method.\n");
- msr_method = 1;
- }
+ ErrorF("Unable to read the MSR - reverting to the VSA method.\n");
+ msr_method = 1;
+ }
- /* This is the fallback VSA method - not preferred */
- vsa_msr_read(reg, addr, hi, lo);
+ /* This is the fallback VSA method - not preferred */
+ vsa_msr_read(reg, addr, hi, lo);
}
#include "gfx_init.c"
diff --git a/src/geode.h b/src/geode.h
index b9e6956..970bdc8 100644
--- a/src/geode.h
+++ b/src/geode.h
@@ -1,29 +1,28 @@
/*
* (c) 2006 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Neither the name of the Advanced Micro Devices, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- */
-
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Neither the name of the Advanced Micro Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ */
#ifndef _AMD_GEODE_H_
#define _AMD_GEODE_H_
@@ -76,7 +75,7 @@
#ifdef HAVE_GX
#define GX_FILL_RECT_SUPPORT 1
#define GX_BRES_LINE_SUPPORT 1
-#define GX_DASH_LINE_SUPPORT 0 /* does not do dashed lines */
+#define GX_DASH_LINE_SUPPORT 0 /* does not do dashed lines */
#define GX_MONO_8X8_PAT_SUPPORT 1
#define GX_CLREXP_8X8_PAT_SUPPORT 1
#define GX_SCR2SCREXP_SUPPORT 1
@@ -240,130 +239,130 @@ VESARec;
typedef struct _geodeRec
{
- /* Common */
-
- int Output; /* Bitmask indicating the valid output options */
-
- Bool HWCursor;
- Bool NoAccel;
- Bool useVGA;
- Bool VGAActive; /* Flag indicating if LX VGA is active */
- Bool Compression;
- Bool useEXA;
-
- int rotation;
- int displayWidth;
- Bool starting;
- Bool tryCompression;
- Bool tryHWCursor;
- unsigned int shadowSize;
- unsigned int shadowOffset;
-
- ExaOffscreenArea *shadowArea;
-
- DisplayModePtr curMode;
- VG_COMPRESSION_DATA CBData;
-
- unsigned long CursorStartOffset;
- unsigned int CursorSize;
- xf86CursorInfoPtr CursorInfo;
- int CursorXHot;
- int CursorYHot;
-
- /* Geometry information */
- unsigned int maxWidth; /* Maximum possible width of the screen */
- unsigned int maxHeight; /* Maximum possible height of the screen */
-
- int Pitch; /* display FB pitch */
-
- int displayPitch; /* The pitch ofthe visible area */
- int displayOffset; /* The offset of the visible area */
- int displaySize; /* The size of the visibile area */
-
- int PanelX;
- int PanelY;
-
- /* Framebuffer memory */
-
- unsigned long FBLinearAddr;
- unsigned char *FBBase;
- unsigned int FBAvail;
- unsigned int FBOffset;
- unsigned int FBSize;
-
- /* Video information */
- int video_x;
- int video_y;
- short video_w;
- short video_h;
- short video_srcw;
- short video_srch;
- short video_dstw;
- short video_dsth;
- int video_id;
- int video_offset;
- ScrnInfoPtr video_scrnptr;
- BOOL OverlayON;
- int videoKey;
-
- /* EXA structures */
-
- ExaDriverPtr pExa;
- unsigned int exaBfrOffset;
- unsigned int exaBfrSz;
-
- /* XAA structures */
- unsigned char **AccelImageWriteBuffers;
- int NoOfImgBuffers;
- unsigned char **AccelColorExpandBuffers;
- int NoOfColorExpandLines;
- XAAInfoRecPtr AccelInfoRec;
-
- /* Other structures */
-
- EntityInfoPtr pEnt;
- ScreenBlockHandlerProcPtr BlockHandler; /* needed for video */
- XF86VideoAdaptorPtr adaptor;
-
- /* State save structures */
-
- gfx_vga_struct FBgfxVgaRegs;
- TVTIMING FBtvtiming;
- GFX_DISPLAYTIMING FBgfxdisplaytiming;
- CIM_DISPLAYTIMING FBcimdisplaytiming;
-
- unsigned int FBTVActive;
- unsigned int FBSupport;
- unsigned long FBDisplayOffset;
- unsigned long PrevDisplayOffset;
-
- VESARec *vesa;
-
- int FBCompressionEnable;
- VG_COMPRESSION_DATA FBCBData;
- VG_CURSOR_DATA FBCursor;
- unsigned long FBCompressionOffset;
- unsigned short FBCompressionPitch;
- unsigned short FBCompressionSize;
-
- /* Save the Cursor offset of the FB */
- unsigned long FBCursorOffset;
- unsigned char FBBIOSMode;
-
- /* Hooks */
-
- void (*WritePixmap) (ScrnInfoPtr pScrni, int x, int y, int w, int h,
- unsigned char *src, int srcwidth, int rop,
- unsigned int planemask, int trans, int bpp, int depth);
-
- void (*PointerMoved) (int index, int x, int y);
- CloseScreenProcPtr CloseScreen;
- Bool (*CreateScreenResources)(ScreenPtr);
-
- /* LX only */
-
- unsigned long CmdBfrOffset;
- unsigned long CmdBfrSize;
+ /* Common */
+
+ int Output; /* Bitmask indicating the valid output options */
+
+ Bool HWCursor;
+ Bool NoAccel;
+ Bool useVGA;
+ Bool VGAActive; /* Flag indicating if LX VGA is active */
+ Bool Compression;
+ Bool useEXA;
+
+ int rotation;
+ int displayWidth;
+ Bool starting;
+ Bool tryCompression;
+ Bool tryHWCursor;
+ unsigned int shadowSize;
+ unsigned int shadowOffset;
+
+ ExaOffscreenArea *shadowArea;
+
+ DisplayModePtr curMode;
+ VG_COMPRESSION_DATA CBData;
+
+ unsigned long CursorStartOffset;
+ unsigned int CursorSize;
+ xf86CursorInfoPtr CursorInfo;
+ int CursorXHot;
+ int CursorYHot;
+
+ /* Geometry information */
+ unsigned int maxWidth; /* Maximum possible width of the screen */
+ unsigned int maxHeight; /* Maximum possible height of the screen */
+
+ int Pitch; /* display FB pitch */
+
+ int displayPitch; /* The pitch ofthe visible area */
+ int displayOffset; /* The offset of the visible area */
+ int displaySize; /* The size of the visibile area */
+
+ int PanelX;
+ int PanelY;
+
+ /* Framebuffer memory */
+
+ unsigned long FBLinearAddr;
+ unsigned char *FBBase;
+ unsigned int FBAvail;
+ unsigned int FBOffset;
+ unsigned int FBSize;
+
+ /* Video information */
+ int video_x;
+ int video_y;
+ short video_w;
+ short video_h;
+ short video_srcw;
+ short video_srch;
+ short video_dstw;
+ short video_dsth;
+ int video_id;
+ int video_offset;
+ ScrnInfoPtr video_scrnptr;
+ BOOL OverlayON;
+ int videoKey;
+
+ /* EXA structures */
+
+ ExaDriverPtr pExa;
+ unsigned int exaBfrOffset;
+ unsigned int exaBfrSz;
+
+ /* XAA structures */
+ unsigned char **AccelImageWriteBuffers;
+ int NoOfImgBuffers;
+ unsigned char **AccelColorExpandBuffers;
+ int NoOfColorExpandLines;
+ XAAInfoRecPtr AccelInfoRec;
+
+ /* Other structures */
+
+ EntityInfoPtr pEnt;
+ ScreenBlockHandlerProcPtr BlockHandler; /* needed for video */
+ XF86VideoAdaptorPtr adaptor;
+
+ /* State save structures */
+
+ gfx_vga_struct FBgfxVgaRegs;
+ TVTIMING FBtvtiming;
+ GFX_DISPLAYTIMING FBgfxdisplaytiming;
+ CIM_DISPLAYTIMING FBcimdisplaytiming;
+
+ unsigned int FBTVActive;
+ unsigned int FBSupport;
+ unsigned long FBDisplayOffset;
+ unsigned long PrevDisplayOffset;
+
+ VESARec *vesa;
+
+ int FBCompressionEnable;
+ VG_COMPRESSION_DATA FBCBData;
+ VG_CURSOR_DATA FBCursor;
+ unsigned long FBCompressionOffset;
+ unsigned short FBCompressionPitch;
+ unsigned short FBCompressionSize;
+
+ /* Save the Cursor offset of the FB */
+ unsigned long FBCursorOffset;
+ unsigned char FBBIOSMode;
+
+ /* Hooks */
+
+ void (*WritePixmap) (ScrnInfoPtr pScrni, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int rop,
+ unsigned int planemask, int trans, int bpp, int depth);
+
+ void (*PointerMoved) (int index, int x, int y);
+ CloseScreenProcPtr CloseScreen;
+ Bool(*CreateScreenResources) (ScreenPtr);
+
+ /* LX only */
+
+ unsigned long CmdBfrOffset;
+ unsigned long CmdBfrSize;
#ifdef HAVE_TVSUPPORT
Bool TVSupport;
@@ -383,20 +382,20 @@ typedef struct _geodeRec
int TVOx, TVOy, TVOw, TVOh;
Bool TV_Overscan_On;
#endif
-
- /* To be killed! */
-
- int FBVGAActive;
- unsigned int cpySrcOffset;
- int cpySrcPitch, cpySrcBpp;
- int cpyDx, cpyDy;
- unsigned int cmpSrcOffset;
- int cmpSrcPitch, cmpSrcBpp;
- unsigned int cmpSrcFmt, cmpDstFmt;
- int cmpOp;
-
- Bool Panel;
-
+
+ /* To be killed! */
+
+ int FBVGAActive;
+ unsigned int cpySrcOffset;
+ int cpySrcPitch, cpySrcBpp;
+ int cpyDx, cpyDy;
+ unsigned int cmpSrcOffset;
+ int cmpSrcPitch, cmpSrcBpp;
+ unsigned int cmpSrcFmt, cmpDstFmt;
+ int cmpOp;
+
+ Bool Panel;
+
}
GeodeRec, *GeodePtr;
@@ -464,7 +463,7 @@ extern int DCONDPMSSet(ScrnInfoPtr pScrni, int mode, int flags);
/* amd_common.c */
void geode_memory_to_screen_blt(unsigned long, unsigned long,
- unsigned long, unsigned long, long, long, int);
+ unsigned long, unsigned long, long, long, int);
int GeodeGetRefreshRate(DisplayModePtr);
void GeodeCopyGreyscale(unsigned char *, unsigned char *, int, int, int, int);
int GeodeGetSizeFromFB(unsigned int *);
@@ -473,8 +472,7 @@ int GeodeGetSizeFromFB(unsigned int *);
int
GeodeQueryImageAttributes(ScrnInfoPtr, int id, unsigned short *w,
- unsigned short *h, int *pitches, int *offsets);
-
+ unsigned short *h, int *pitches, int *offsets);
Bool RegionsEqual(RegionPtr A, RegionPtr B);
diff --git a/src/geode_common.c b/src/geode_common.c
index 083b2f6..2e02af1 100644
--- a/src/geode_common.c
+++ b/src/geode_common.c
@@ -30,7 +30,7 @@
#include "config.h"
#endif
-#include <string.h> /* memcmp() */
+#include <string.h> /* memcmp() */
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -47,8 +47,6 @@
: "0" (n), "1" (s), "2" (d) \
: "memory")
-
-
#define move1(d,s,n) \
__asm__ __volatile__( \
" rep; movsl\n" \
@@ -74,7 +72,6 @@
: "0" (n), "1" (s), "2" (d) \
: "memory")
-
void
geode_memory_to_screen_blt(unsigned long src, unsigned long dst,
unsigned long sp, unsigned long dp, long w, long h, int bpp)
@@ -85,33 +82,33 @@ geode_memory_to_screen_blt(unsigned long src, unsigned long dst,
switch (n & 3) {
case 0:
- while (--h >= 0) {
- move0(dst, src, m);
- src += sp;
- dst += dp;
- }
- break;
+ while (--h >= 0) {
+ move0(dst, src, m);
+ src += sp;
+ dst += dp;
+ }
+ break;
case 1:
- while (--h >= 0) {
- move1(dst, src, m);
- src += sp;
- dst += dp;
- }
- break;
+ while (--h >= 0) {
+ move1(dst, src, m);
+ src += sp;
+ dst += dp;
+ }
+ break;
case 2:
- while (--h >= 0) {
- move2(dst, src, m);
- src += sp;
- dst += dp;
- }
- break;
+ while (--h >= 0) {
+ move2(dst, src, m);
+ src += sp;
+ dst += dp;
+ }
+ break;
case 3:
- while (--h >= 0) {
- move3(dst, src, m);
- src += sp;
- dst += dp;
- }
- break;
+ while (--h >= 0) {
+ move3(dst, src, m);
+ src += sp;
+ dst += dp;
+ }
+ break;
}
}
@@ -130,73 +127,74 @@ GeodeGetRefreshRate(DisplayModePtr pMode)
/* This is used by both GX and LX. It could be accelerated for LX, probably, but
that would involve a two pass blt, the first to copy the data, and the second
- to copy the grey (using a pattern). That seems like a bit of work for a
+ to copy the grey (using a pattern). That seems like a bit of work for a
very underused format - so we'll just use the slow version.
*/
void
GeodeCopyGreyscale(unsigned char *src, unsigned char *dst,
- int dstPitch, int srcPitch, int h, int w)
+ int dstPitch, int srcPitch, int h, int w)
{
- int i;
- unsigned char *src2 = src;
- unsigned char *dst2 = dst;
- unsigned char *dst3;
- unsigned char *src3;
-
- dstPitch <<= 1;
-
- while (h--) {
- dst3 = dst2;
- src3 = src2;
- for (i = 0; i < w; i++) {
- *dst3++ = *src3++; /* Copy Y data */
- *dst3++ = 0x80; /* Fill UV with 0x80 - greyscale */
- }
-
- src3 = src2;
- for (i = 0; i < w; i++) {
- *dst3++ = *src3++; /* Copy Y data */
- *dst3++ = 0x80; /* Fill UV with 0x80 - greyscale */
+ int i;
+ unsigned char *src2 = src;
+ unsigned char *dst2 = dst;
+ unsigned char *dst3;
+ unsigned char *src3;
+
+ dstPitch <<= 1;
+
+ while (h--) {
+ dst3 = dst2;
+ src3 = src2;
+ for (i = 0; i < w; i++) {
+ *dst3++ = *src3++; /* Copy Y data */
+ *dst3++ = 0x80; /* Fill UV with 0x80 - greyscale */
+ }
+
+ src3 = src2;
+ for (i = 0; i < w; i++) {
+ *dst3++ = *src3++; /* Copy Y data */
+ *dst3++ = 0x80; /* Fill UV with 0x80 - greyscale */
+ }
+
+ dst2 += dstPitch;
+ src2 += srcPitch;
}
-
- dst2 += dstPitch;
- src2 += srcPitch;
- }
}
#if defined(linux)
#include <linux/fb.h>
-int GeodeGetSizeFromFB(unsigned int *size)
+int
+GeodeGetSizeFromFB(unsigned int *size)
{
- struct fb_fix_screeninfo fix;
- int ret;
- int fd = open("/dev/fb0", O_RDONLY);
+ struct fb_fix_screeninfo fix;
+ int ret;
+ int fd = open("/dev/fb0", O_RDONLY);
- if (fd == -1)
- return -1;
+ if (fd == -1)
+ return -1;
- ret = ioctl(fd, FBIOGET_FSCREENINFO, &fix);
- close(fd);
+ ret = ioctl(fd, FBIOGET_FSCREENINFO, &fix);
+ close(fd);
- if (!ret) {
- if (!memcmp(fix.id, "Geode", 5)) {
- *size = fix.smem_len;
- return 0;
- }
+ if (!ret) {
+ if (!memcmp(fix.id, "Geode", 5)) {
+ *size = fix.smem_len;
+ return 0;
}
+ }
- return -1;
+ return -1;
}
#else
-int GeodeGetSizeFromFB(unsigned int *size)
+int
+GeodeGetSizeFromFB(unsigned int *size)
{
- return -1;
+ return -1;
}
#endif
-
diff --git a/src/geode_driver.c b/src/geode_driver.c
index 303f865..adf0ee1 100644
--- a/src/geode_driver.c
+++ b/src/geode_driver.c
@@ -99,9 +99,9 @@ static Bool AmdProbe(DriverPtr, int);
#ifdef XSERVER_LIBPCIACCESS
static const struct pci_id_match amdDeviceMatch[] = {
{PCI_VENDOR_ID_NS, PCI_CHIP_REDCLOUD, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0,
- 0},
+ 0},
{PCI_VENDOR_ID_AMD, PCI_CHIP_GEODELX, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0,
- 0},
+ 0},
{0, 0, 0}
};
#endif /* XSERVER_LIBPCIACCESS */
@@ -502,7 +502,7 @@ AmdPciProbe(DriverPtr driver,
* Parameters.
* drv :a pointer to the geode driver
* flags :flags may passed to check the config and probe detect
- *
+ *
* Returns :TRUE on success and FALSE on failure.
*
* Comments :This should ne minimal probe and it should under no
diff --git a/src/geode_msr.c b/src/geode_msr.c
index 12b9f73..0d31192 100644
--- a/src/geode_msr.c
+++ b/src/geode_msr.c
@@ -6,60 +6,63 @@
#include <sys/errno.h>
#include "os.h"
-static int _msr_open(void)
+static int
+_msr_open(void)
{
- static int msrfd = 0;
+ static int msrfd = 0;
- if (msrfd == 0) {
- msrfd = open("/dev/cpu/0/msr", O_RDWR);
- if (msrfd == -1)
- ErrorF("Unable to open /dev/cpu/0/msr: %d\n", errno);
- }
+ if (msrfd == 0) {
+ msrfd = open("/dev/cpu/0/msr", O_RDWR);
+ if (msrfd == -1)
+ ErrorF("Unable to open /dev/cpu/0/msr: %d\n", errno);
+ }
- return msrfd;
+ return msrfd;
}
-int GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
+int
+GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
{
- unsigned int data[2];
- int fd = _msr_open();
- int ret;
-
- if (fd == -1)
- return -1;
-
- ret = lseek64(fd, (off64_t) addr, SEEK_SET);
-
- if (ret == -1)
- return -1;
-
- ret = read(fd, (void *) data, sizeof(data));
-
- if (ret != 8)
- return -1;
-
- *hi = data[1];
- *lo = data[0];
-
- return 0;
+ unsigned int data[2];
+ int fd = _msr_open();
+ int ret;
+
+ if (fd == -1)
+ return -1;
+
+ ret = lseek64(fd, (off64_t) addr, SEEK_SET);
+
+ if (ret == -1)
+ return -1;
+
+ ret = read(fd, (void *)data, sizeof(data));
+
+ if (ret != 8)
+ return -1;
+
+ *hi = data[1];
+ *lo = data[0];
+
+ return 0;
}
-int GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
+int
+GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
{
- unsigned int data[2];
- int fd = _msr_open();
+ unsigned int data[2];
+ int fd = _msr_open();
- if (fd == -1)
- return - 1;
+ if (fd == -1)
+ return -1;
- if (lseek64(fd, (off64_t) addr, SEEK_SET) == -1)
- return -1;
+ if (lseek64(fd, (off64_t) addr, SEEK_SET) == -1)
+ return -1;
- data[0] = lo;
- data[1] = hi;
+ data[0] = lo;
+ data[1] = hi;
- if (write(fd, (void *) data, 8) != 8)
- return -1;
+ if (write(fd, (void *)data, 8) != 8)
+ return -1;
- return 0;
+ return 0;
}
diff --git a/src/geode_pcirename.h b/src/geode_pcirename.h
index f0f5cf8..145cc01 100644
--- a/src/geode_pcirename.h
+++ b/src/geode_pcirename.h
@@ -29,9 +29,10 @@
#ifndef CIRPCIRENAME_H
#define CIRPCIRENAME_H
-enum region_type {
+enum region_type
+{
REGION_MEM,
- REGION_IO
+ REGION_IO
};
#ifndef XSERVER_LIBPCIACCESS
diff --git a/src/gx_accel.c b/src/gx_accel.c
index 5461455..35ca64e 100644
--- a/src/gx_accel.c
+++ b/src/gx_accel.c
@@ -24,7 +24,7 @@
* */
/*
- * File Contents: This file is consists of main Xfree acceleration supported
+ * File Contents: This file is consists of main Xfree acceleration supported
* routines like solid fill used here.
*
* Project: Geode Xfree Frame buffer device driver.
@@ -165,15 +165,16 @@ static const int PDfn_SM[16] = {
};
#ifdef OPT_ACCEL
-static inline CARD32 amd_gx_BppToRasterMode(int bpp)
+static inline CARD32
+amd_gx_BppToRasterMode(int bpp)
{
switch (bpp) {
case 16:
- return MGP_RM_BPPFMT_565;
+ return MGP_RM_BPPFMT_565;
case 32:
- return MGP_RM_BPPFMT_8888;
+ return MGP_RM_BPPFMT_8888;
case 8:
- return MGP_RM_BPPFMT_332;
+ return MGP_RM_BPPFMT_332;
default:
return 0;
}
@@ -232,16 +233,16 @@ GXSetupForSolidFill(ScrnInfoPtr pScrni,
gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
#else
{
- unsigned int ROP =
- BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- BLT_MODE = ((ROP ^ (ROP >> 2)) & 0x33) == 0 ? MGP_BM_SRC_MONO : 0;
- if (((ROP ^ (ROP >> 1)) & 0x55) != 0)
- BLT_MODE |= MGP_BM_DST_REQ;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_RASTER_MODE, ROP);
- WRITE_GP32(MGP_PAT_COLOR_0, planemask);
- WRITE_GP32(MGP_SRC_COLOR_FG, color);
- WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
+ unsigned int ROP =
+ BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
+ BLT_MODE = ((ROP ^ (ROP >> 2)) & 0x33) == 0 ? MGP_BM_SRC_MONO : 0;
+ if (((ROP ^ (ROP >> 1)) & 0x55) != 0)
+ BLT_MODE |= MGP_BM_DST_REQ;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_RASTER_MODE, ROP);
+ WRITE_GP32(MGP_PAT_COLOR_0, planemask);
+ WRITE_GP32(MGP_SRC_COLOR_FG, color);
+ WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
}
#endif
}
@@ -262,7 +263,7 @@ GXSetupForSolidFill(ScrnInfoPtr pScrni,
* Returns :none
*
* Sample application uses:
- * - Window backgrounds.
+ * - Window backgrounds.
* - pull down highlighting.
* - x11perf: rectangle tests (-rect500).
* - x11perf: fill trapezoid tests (-trap100).
@@ -276,13 +277,13 @@ GXSubsequentSolidFillRect(ScrnInfoPtr pScrni, int x, int y, int w, int h)
gfx_pattern_fill(x, y, w, h);
#else
{
- unsigned int offset = CALC_FBOFFSET(x, y);
- unsigned int size = (w << 16) | h;
-
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_DST_OFFSET, offset);
- WRITE_GP32(MGP_WID_HEIGHT, size);
- WRITE_GP32(MGP_BLT_MODE, BLT_MODE);
+ unsigned int offset = CALC_FBOFFSET(x, y);
+ unsigned int size = (w << 16) | h;
+
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_DST_OFFSET, offset);
+ WRITE_GP32(MGP_WID_HEIGHT, size);
+ WRITE_GP32(MGP_BLT_MODE, BLT_MODE);
}
#endif
}
@@ -296,7 +297,7 @@ GXSubsequentSolidFillRect(ScrnInfoPtr pScrni, int x, int y, int w, int h)
* Description :8x8 color pattern data is 64 pixels of full color data
* stored linearly in offscreen video memory. These patterns
* are useful as a substitute for 8x8 mono patterns when tiling,
- * doing opaque stipples, or regular stipples.
+ * doing opaque stipples, or regular stipples.
*
* Arg Type Comment
* pScrni ScrnInfoPtr pointer to Screeen info
@@ -307,7 +308,7 @@ GXSubsequentSolidFillRect(ScrnInfoPtr pScrni, int x, int y, int w, int h)
* trans_color int -1 (copy) or transparent color (not enabled)
* trans color only supported on source channel
* or in monochrome pattern channel
- *
+ *
* Returns :none.
*
*---------------------------------------------------------------------------*/
@@ -325,13 +326,13 @@ GXSetupForColor8x8PatternFill(ScrnInfoPtr pScrni, int patx, int paty, int rop,
/* gfx_set_solid_pattern is needed to clear src/pat transparency */
gfx_set_solid_pattern(0);
gfx_set_raster_operation(planemask == ~0U ? PDfn[rop] :
- (gfx_set_solid_source(planemask), PDfn_SM[rop]));
+ (gfx_set_solid_source(planemask), PDfn_SM[rop]));
gfx2_set_source_stride(pGeode->Pitch);
gfx2_set_destination_stride(pGeode->Pitch);
if (trans_color == -1)
- gfx2_set_source_transparency(0, 0);
+ gfx2_set_source_transparency(0, 0);
else
- gfx2_set_source_transparency(trans_color, ~0);
+ gfx2_set_source_transparency(trans_color, ~0);
}
/*----------------------------------------------------------------------------
@@ -347,7 +348,7 @@ GXSetupForColor8x8PatternFill(ScrnInfoPtr pScrni, int patx, int paty, int rop,
* y int destination y offset
* w int fill area width (pixels)
* h int fill area height (pixels)
- *
+ *
* Returns :none
*
* Sample application uses:
@@ -359,7 +360,7 @@ static void
GXSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrni, int patx, int paty,
int x, int y, int w, int h)
{
- //ErrorF(
+ //ErrorF(
// "GXSubsequentColor8x8PatternFillRect() patxy %d,%d at %d,%d %dsx%d\n",
// patx, paty, x, y, w, h);
gfx2_set_pattern_origin(patx, paty);
@@ -377,7 +378,7 @@ GXSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrni, int patx, int paty,
* with ones indicating the foreground color and zeros
* indicating the background color. These patterns are
* useful when tiling, doing opaque stipples, or regular
- * stipples.
+ * stipples.
*
* Arg Type Comment
* pScrni ScrnInfoPtr pointer to Screeen info
@@ -387,7 +388,7 @@ GXSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrni, int patx, int paty,
* bg int -1 (transparent) or background color
* rop int unmapped raster operation
* planemask uint -1 (copy) or pattern data
- *
+ *
* Returns :none.
*
* Comments :none.
@@ -397,31 +398,31 @@ static void
GXSetupForMono8x8PatternFill(ScrnInfoPtr pScrni, int patx, int paty,
int fg, int bg, int rop, uint planemask)
{
- //ErrorF(
- //"GXSetupForMono8x8PatternFill() pat %#x,%#x fg %#x bg %#x %#x %#x\n",
- //patx, paty, fg, bg, rop, planemask);
+ //ErrorF(
+ //"GXSetupForMono8x8PatternFill() pat %#x,%#x fg %#x bg %#x %#x %#x\n",
+ //patx, paty, fg, bg, rop, planemask);
rop &= 0x0F;
#ifndef OPT_ACCEL
gfx_set_mono_pattern(bg, fg, patx, paty, bg == -1 ? 1 : 0);
gfx_set_raster_operation(planemask == ~0U ? PDfn[rop] :
- (gfx_set_solid_source(planemask), PDfn_SM[rop]));
+ (gfx_set_solid_source(planemask), PDfn_SM[rop]));
#else
{
- unsigned int ROP = BPP |
- (bg ==
- -1 ? MGP_RM_PAT_MONO | MGP_RM_PAT_TRANS : MGP_RM_PAT_MONO) |
- (planemask == ~0U ? PDfn[rop] : PDfn_SM[rop]);
- BLT_MODE = ((ROP ^ (ROP >> 2)) & 0x33) == 0 ? MGP_BM_SRC_MONO : 0;
- if (((ROP ^ (ROP >> 1)) & 0x55) != 0)
- BLT_MODE |= MGP_BM_DST_REQ;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_RASTER_MODE, ROP);
- WRITE_GP32(MGP_SRC_COLOR_FG, planemask);
- WRITE_GP32(MGP_PAT_COLOR_0, bg);
- WRITE_GP32(MGP_PAT_COLOR_1, fg);
- WRITE_GP32(MGP_PAT_DATA_0, patx);
- WRITE_GP32(MGP_PAT_DATA_1, paty);
- WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
+ unsigned int ROP = BPP |
+ (bg ==
+ -1 ? MGP_RM_PAT_MONO | MGP_RM_PAT_TRANS : MGP_RM_PAT_MONO) |
+ (planemask == ~0U ? PDfn[rop] : PDfn_SM[rop]);
+ BLT_MODE = ((ROP ^ (ROP >> 2)) & 0x33) == 0 ? MGP_BM_SRC_MONO : 0;
+ if (((ROP ^ (ROP >> 1)) & 0x55) != 0)
+ BLT_MODE |= MGP_BM_DST_REQ;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_RASTER_MODE, ROP);
+ WRITE_GP32(MGP_SRC_COLOR_FG, planemask);
+ WRITE_GP32(MGP_PAT_COLOR_0, bg);
+ WRITE_GP32(MGP_PAT_COLOR_1, fg);
+ WRITE_GP32(MGP_PAT_DATA_0, patx);
+ WRITE_GP32(MGP_PAT_DATA_1, paty);
+ WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
}
#endif
}
@@ -452,19 +453,19 @@ GXSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrni, int patx, int paty,
int x, int y, int w, int h)
{
DEBUGMSG(1, (0, X_INFO, "%s() pat %#x,%#x at %d,%d %dx%d\n",
- __func__, patx, paty, x, y, w, h));
+ __func__, patx, paty, x, y, w, h));
#ifndef OPT_ACCEL
gfx_pattern_fill(x, y, w, h);
#else
{
- unsigned int offset =
- CALC_FBOFFSET(x, y) | ((x & 7) << 26) | ((y & 7) << 29);
- unsigned int size = (w << 16) | h;
-
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_DST_OFFSET, offset);
- WRITE_GP32(MGP_WID_HEIGHT, size);
- WRITE_GP32(MGP_BLT_MODE, BLT_MODE);
+ unsigned int offset =
+ CALC_FBOFFSET(x, y) | ((x & 7) << 26) | ((y & 7) << 29);
+ unsigned int size = (w << 16) | h;
+
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_DST_OFFSET, offset);
+ WRITE_GP32(MGP_WID_HEIGHT, size);
+ WRITE_GP32(MGP_BLT_MODE, BLT_MODE);
}
#endif
}
@@ -494,37 +495,37 @@ GXSetupForScreenToScreenCopy(ScrnInfoPtr pScrni, int xdir, int ydir, int rop,
uint planemask, int trans_color)
{
DEBUGMSG(1, (0, X_INFO, "%s() xd%d yd%d rop %#x %#x %#x\n",
- __func__, xdir, ydir, rop, planemask, trans_color));
+ __func__, xdir, ydir, rop, planemask, trans_color));
rop &= 0x0F;
#ifndef OPT_ACCEL
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- gfx_set_solid_pattern(planemask);
- /* transparency is a parameter to set_rop, but set...pattern clears
- * transparency */
- if (trans_color == -1)
- gfx2_set_source_transparency(0, 0);
- else
- gfx2_set_source_transparency(trans_color, ~0);
- gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- gfx2_set_source_stride(pGeode->Pitch);
- gfx2_set_destination_stride(pGeode->Pitch);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ gfx_set_solid_pattern(planemask);
+ /* transparency is a parameter to set_rop, but set...pattern clears
+ * transparency */
+ if (trans_color == -1)
+ gfx2_set_source_transparency(0, 0);
+ else
+ gfx2_set_source_transparency(trans_color, ~0);
+ gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
+ gfx2_set_source_stride(pGeode->Pitch);
+ gfx2_set_destination_stride(pGeode->Pitch);
}
#else
{
- unsigned int ROP =
- BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- if (trans_color != -1)
- ROP |= MGP_RM_SRC_TRANS;
- BLT_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ?
- MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_RASTER_MODE, ROP);
- WRITE_GP32(MGP_PAT_COLOR_0, planemask);
- WRITE_GP32(MGP_SRC_COLOR_FG, trans_color);
- WRITE_GP32(MGP_SRC_COLOR_BG, ~0);
- WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
+ unsigned int ROP =
+ BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
+ if (trans_color != -1)
+ ROP |= MGP_RM_SRC_TRANS;
+ BLT_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ?
+ MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_RASTER_MODE, ROP);
+ WRITE_GP32(MGP_PAT_COLOR_0, planemask);
+ WRITE_GP32(MGP_SRC_COLOR_FG, trans_color);
+ WRITE_GP32(MGP_SRC_COLOR_BG, ~0);
+ WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
}
#endif
}
@@ -542,7 +543,7 @@ GXSetupForScreenToScreenCopy(ScrnInfoPtr pScrni, int xdir, int ydir, int rop,
* y2 int destination y offset
* w int copy area width (pixels)
* h int copy area height (pixels)
- *
+ *
* Returns :none
*
* Sample application uses (non-transparent):
@@ -555,45 +556,45 @@ GXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrni,
int x1, int y1, int x2, int y2, int w, int h)
{
DEBUGMSG(1, (0, X_INFO, "%s() from %d,%d to %d,%d %dx%d\n",
- __func__, x1, y1, x2, y2, w, h));
+ __func__, x1, y1, x2, y2, w, h));
#ifndef OPT_ACCEL
{
- int flags = 0;
-
- if (x2 > x1)
- flags |= 1;
- if (y2 > y1)
- flags |= 2;
- gfx2_screen_to_screen_blt(CALC_FBOFFSET(x1, y1), CALC_FBOFFSET(x2,
- y2), w, h, flags);
+ int flags = 0;
+
+ if (x2 > x1)
+ flags |= 1;
+ if (y2 > y1)
+ flags |= 2;
+ gfx2_screen_to_screen_blt(CALC_FBOFFSET(x1, y1), CALC_FBOFFSET(x2,
+ y2), w, h, flags);
}
#else
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- unsigned int src = CALC_FBOFFSET(x1, y1);
- unsigned int dst = CALC_FBOFFSET(x2, y2);
- unsigned int size = (w << 16) | h;
- unsigned int blt_mode = BLT_MODE;
-
- if (x2 > x1) {
- int n = (w << gu2_xshift) - 1;
-
- src += n;
- dst += n;
- blt_mode |= MGP_BM_NEG_XDIR;
- }
- if (y2 > y1) {
- int n = (h - 1) * pGeode->Pitch;
-
- src += n;
- dst += n;
- blt_mode |= MGP_BM_NEG_YDIR;
- }
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_SRC_OFFSET, src);
- WRITE_GP32(MGP_DST_OFFSET, dst);
- WRITE_GP32(MGP_WID_HEIGHT, size);
- WRITE_GP16(MGP_BLT_MODE, blt_mode);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ unsigned int src = CALC_FBOFFSET(x1, y1);
+ unsigned int dst = CALC_FBOFFSET(x2, y2);
+ unsigned int size = (w << 16) | h;
+ unsigned int blt_mode = BLT_MODE;
+
+ if (x2 > x1) {
+ int n = (w << gu2_xshift) - 1;
+
+ src += n;
+ dst += n;
+ blt_mode |= MGP_BM_NEG_XDIR;
+ }
+ if (y2 > y1) {
+ int n = (h - 1) * pGeode->Pitch;
+
+ src += n;
+ dst += n;
+ blt_mode |= MGP_BM_NEG_YDIR;
+ }
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_SRC_OFFSET, src);
+ WRITE_GP32(MGP_DST_OFFSET, dst);
+ WRITE_GP32(MGP_WID_HEIGHT, size);
+ WRITE_GP16(MGP_BLT_MODE, blt_mode);
}
#endif
}
@@ -618,9 +619,9 @@ GXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrni,
*
* Returns :none
*
- * x11perf -putimage10
- * x11perf -putimage100
- * x11perf -putimage500
+ * x11perf -putimage10
+ * x11perf -putimage100
+ * x11perf -putimage500
*----------------------------------------------------------------------------
*/
static void
@@ -630,15 +631,15 @@ GXSetupForScanlineImageWrite(ScrnInfoPtr pScrni, int rop, uint planemask,
GeodeRec *pGeode = GEODEPTR(pScrni);
DEBUGMSG(1, (0, X_INFO, "%s() rop %#x %#x %#x %d %d\n",
- __func__, rop, planemask, trans_color, bpp, depth));
+ __func__, rop, planemask, trans_color, bpp, depth));
rop &= 0x0F;
/* transparency is a parameter to set_rop, but set...pattern clears
* transparency */
gfx_set_solid_pattern(planemask);
if (trans_color == -1)
- gfx2_set_source_transparency(0, 0);
+ gfx2_set_source_transparency(0, 0);
else
- gfx2_set_source_transparency(trans_color, ~0);
+ gfx2_set_source_transparency(trans_color, ~0);
gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
gfx2_set_source_stride(pGeode->Pitch);
gfx2_set_destination_stride(pGeode->Pitch);
@@ -656,7 +657,7 @@ GXSetupForScanlineImageWrite(ScrnInfoPtr pScrni, int rop, uint planemask,
* w int copy area width (pixels)
* h int copy area height (pixels)
* skipleft int x margin (pixels) to skip (not enabled)
- *
+ *
* Returns :none
*---------------------------------------------------------------------------*/
static void
@@ -664,7 +665,7 @@ GXSubsequentScanlineImageWriteRect(ScrnInfoPtr pScrni,
int x, int y, int w, int h, int skipleft)
{
DEBUGMSG(1, (0, X_INFO, "%s() rop %d,%d %dx%d %d\n",
- __func__, x, y, w, h, skipleft));
+ __func__, x, y, w, h, skipleft));
giwr.x = x;
giwr.y = y;
giwr.w = w;
@@ -707,10 +708,10 @@ GXSubsequentImageWriteScanline(ScrnInfoPtr pScrni, int bufno)
#if !GX_USE_OFFSCRN_MEM
offset = pGeode->AccelImageWriteBuffers[bufno] - pGeode->FBBase;
gfx2_screen_to_screen_blt(offset, CALC_FBOFFSET(giwr.x, giwr.y), giwr.w,
- 1, 0);
+ 1, 0);
#else /* if !GX_USE_OFFSCRN_MEM */
gfx2_color_bitmap_to_screen_blt(0, 0, CALC_FBOFFSET(giwr.x, giwr.y),
- giwr.w, 1, pGeode->AccelImageWriteBuffers[bufno], pGeode->Pitch);
+ giwr.w, 1, pGeode->AccelImageWriteBuffers[bufno], pGeode->Pitch);
#endif /* if !GX_USE_OFFSCRN_MEM */
++giwr.y;
#else /* if GX_ONE_LINE_AT_A_TIME */
@@ -719,18 +720,17 @@ GXSubsequentImageWriteScanline(ScrnInfoPtr pScrni, int bufno)
DEBUGMSG(1, (0, X_INFO, "%s() %d\n", __func__, bufno));
if ((blt_height = pGeode->NoOfImgBuffers) > giwr.h)
- blt_height = giwr.h;
+ blt_height = giwr.h;
if (++bufno < blt_height)
- return;
+ return;
#if !GX_USE_OFFSCRN_MEM
offset = pGeode->AccelImageWriteBuffers[0] - pGeode->FBBase;
gfx2_screen_to_screen_blt(offset, CALC_FBOFFSET(giwr.x, giwr.y), giwr.w,
- blt_height, 0);
+ blt_height, 0);
GXAccelSync(pScrni);
#else /* if !GX_USE_OFFSCRN_MEM */
gfx2_color_bitmap_to_screen_blt(0, 0, CALC_FBOFFSET(giwr.x, giwr.y),
- giwr.w, blt_height, pGeode->AccelImageWriteBuffers[0],
- pGeode->Pitch);
+ giwr.w, blt_height, pGeode->AccelImageWriteBuffers[0], pGeode->Pitch);
#endif /* if !GX_USE_OFFSCRN_MEM */
giwr.h -= blt_height;
giwr.y += blt_height;
@@ -746,7 +746,7 @@ GXSubsequentImageWriteScanline(ScrnInfoPtr pScrni, int bufno)
* ColorExpandScanline routines provide an interface for
* doing expansion blits from source patterns stored in
* system memory.
- *
+ *
* Arg Type Comment
* pScrni ScrnInfoPtr pointer to Screeen info
* fg int foreground color
@@ -765,7 +765,7 @@ GXSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrni,
ulong srcpitch;
DEBUGMSG(1, (0, X_INFO, "%s() fg %#x bg %#x rop %#x %#x\n",
- __func__, fg, bg, rop, planemask));
+ __func__, fg, bg, rop, planemask));
rop &= 0x0F;
srcpitch = ((pGeode->Pitch + 31) >> 5) << 2;
#ifndef OPT_ACCEL
@@ -776,20 +776,20 @@ GXSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrni,
gfx2_set_destination_stride(pGeode->Pitch);
#else
{
- unsigned int stride = (srcpitch << 16) | pGeode->Pitch;
- unsigned int ROP =
- BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- if (bg == -1)
- ROP |= MGP_RM_SRC_TRANS;
- BLT_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ?
- MGP_BM_SRC_MONO | MGP_BM_SRC_FB | MGP_BM_DST_REQ :
- MGP_BM_SRC_MONO | MGP_BM_SRC_FB;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_RASTER_MODE, ROP);
- WRITE_GP32(MGP_PAT_COLOR_0, planemask);
- WRITE_GP32(MGP_SRC_COLOR_BG, bg);
- WRITE_GP32(MGP_SRC_COLOR_FG, fg);
- WRITE_GP32(MGP_STRIDE, stride);
+ unsigned int stride = (srcpitch << 16) | pGeode->Pitch;
+ unsigned int ROP =
+ BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
+ if (bg == -1)
+ ROP |= MGP_RM_SRC_TRANS;
+ BLT_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ?
+ MGP_BM_SRC_MONO | MGP_BM_SRC_FB | MGP_BM_DST_REQ :
+ MGP_BM_SRC_MONO | MGP_BM_SRC_FB;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_RASTER_MODE, ROP);
+ WRITE_GP32(MGP_PAT_COLOR_0, planemask);
+ WRITE_GP32(MGP_SRC_COLOR_BG, bg);
+ WRITE_GP32(MGP_SRC_COLOR_FG, fg);
+ WRITE_GP32(MGP_STRIDE, stride);
}
#endif
}
@@ -806,7 +806,7 @@ GXSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrni,
* y int destination y offset
* w int fill area width (pixels)
* h int fill area height (pixels)
- *
+ *
* Returns :none
*
*---------------------------------------------------------------------------*/
@@ -815,7 +815,7 @@ GXSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrni,
int x, int y, int w, int h, int skipleft)
{
DEBUGMSG(1, (0, X_INFO, "%s() %d,%d %dx%d %d\n",
- __func__, x, y, w, h, skipleft));
+ __func__, x, y, w, h, skipleft));
gc2s.x = x;
gc2s.y = y;
gc2s.w = w;
@@ -823,16 +823,16 @@ GXSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrni,
#ifdef OPT_ACCEL
{
#if GX_ONE_LINE_AT_A_TIME
- unsigned int size = (gc2s.w << 16) | 1;
+ unsigned int size = (gc2s.w << 16) | 1;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_WID_HEIGHT, size);
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_WID_HEIGHT, size);
#else
- GeodeRec *pGeode = GEODEPTR(pScrni);
- unsigned int src =
- pGeode->AccelColorExpandBuffers[0] - pGeode->FBBase;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_SRC_OFFSET, src);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ unsigned int src =
+ pGeode->AccelColorExpandBuffers[0] - pGeode->FBBase;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_SRC_OFFSET, src);
#endif
}
#endif
@@ -859,57 +859,57 @@ GXSubsequentColorExpandScanline(ScrnInfoPtr pScrni, int bufno)
#ifndef OPT_ACCEL
{
#if GX_ONE_LINE_AT_A_TIME
- ulong offset =
- pGeode->AccelColorExpandBuffers[bufno] - pGeode->FBBase;
- gfx2_mono_expand_blt(offset, 0, 0, CALC_FBOFFSET(gc2s.x, gc2s.y),
- gc2s.w, 1, 0);
- ++gc2s.y;
+ ulong offset =
+ pGeode->AccelColorExpandBuffers[bufno] - pGeode->FBBase;
+ gfx2_mono_expand_blt(offset, 0, 0, CALC_FBOFFSET(gc2s.x, gc2s.y),
+ gc2s.w, 1, 0);
+ ++gc2s.y;
#else /* if GX_ONE_LINE_AT_A_TIME */
- ulong srcpitch;
- int blt_height;
-
- if ((blt_height = pGeode->NoOfImgBuffers) > gc2s.h)
- blt_height = gc2s.h;
- if (++bufno < blt_height)
- return;
-
- /* convert from bits to dwords */
- srcpitch = ((pGeode->Pitch + 31) >> 5) << 2;
- gfx2_mono_bitmap_to_screen_blt(0, 0, CALC_FBOFFSET(gc2s.x, gc2s.y),
- gc2s.w, blt_height, pGeode->AccelColorExpandBuffers[0], srcpitch);
- gc2s.h -= blt_height;
- gc2s.y += blt_height;
+ ulong srcpitch;
+ int blt_height;
+
+ if ((blt_height = pGeode->NoOfImgBuffers) > gc2s.h)
+ blt_height = gc2s.h;
+ if (++bufno < blt_height)
+ return;
+
+ /* convert from bits to dwords */
+ srcpitch = ((pGeode->Pitch + 31) >> 5) << 2;
+ gfx2_mono_bitmap_to_screen_blt(0, 0, CALC_FBOFFSET(gc2s.x, gc2s.y),
+ gc2s.w, blt_height, pGeode->AccelColorExpandBuffers[0], srcpitch);
+ gc2s.h -= blt_height;
+ gc2s.y += blt_height;
#endif /* if GX_ONE_LINE_AT_A_TIME */
}
#else /* ifndef OPT_ACCEL */
{
#if GX_ONE_LINE_AT_A_TIME
- unsigned int src =
- pGeode->AccelColorExpandBuffers[bufno] - pGeode->FBBase;
- unsigned int dst = CALC_FBOFFSET(gc2s.x, gc2s.y);
-
- ++gc2s.y;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_SRC_OFFSET, src);
- WRITE_GP32(MGP_DST_OFFSET, dst);
- WRITE_GP16(MGP_BLT_MODE, BLT_MODE);
+ unsigned int src =
+ pGeode->AccelColorExpandBuffers[bufno] - pGeode->FBBase;
+ unsigned int dst = CALC_FBOFFSET(gc2s.x, gc2s.y);
+
+ ++gc2s.y;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_SRC_OFFSET, src);
+ WRITE_GP32(MGP_DST_OFFSET, dst);
+ WRITE_GP16(MGP_BLT_MODE, BLT_MODE);
#else /* if GX_ONE_LINE_AT_A_TIME */
- unsigned int dst, size;
- int blt_height;
-
- GU2_WAIT_BUSY;
- if ((blt_height = pGeode->NoOfImgBuffers) > gc2s.h)
- blt_height = gc2s.h;
- if (++bufno < blt_height)
- return;
- dst = CALC_FBOFFSET(gc2s.x, gc2s.y);
- size = (gc2s.w << 16) | blt_height;
- gc2s.h -= blt_height;
- gc2s.y += blt_height;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_DST_OFFSET, dst);
- WRITE_GP32(MGP_WID_HEIGHT, size);
- WRITE_GP16(MGP_BLT_MODE, BLT_MODE);
+ unsigned int dst, size;
+ int blt_height;
+
+ GU2_WAIT_BUSY;
+ if ((blt_height = pGeode->NoOfImgBuffers) > gc2s.h)
+ blt_height = gc2s.h;
+ if (++bufno < blt_height)
+ return;
+ dst = CALC_FBOFFSET(gc2s.x, gc2s.y);
+ size = (gc2s.w << 16) | blt_height;
+ gc2s.h -= blt_height;
+ gc2s.y += blt_height;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_DST_OFFSET, dst);
+ WRITE_GP32(MGP_WID_HEIGHT, size);
+ WRITE_GP16(MGP_BLT_MODE, BLT_MODE);
#endif /* if GX_ONE_LINE_AT_A_TIME */
}
#endif /* ifndef OPT_ACCEL */
@@ -924,7 +924,7 @@ GXSubsequentColorExpandScanline(ScrnInfoPtr pScrni, int bufno)
* ColorExpandScanline routines provide an interface for
* doing expansion blits from source patterns stored in
* video memory.
- *
+ *
* Arg Type Comment
* pScrni ScrnInfoPtr pointer to Screeen info
* fg int foreground color
@@ -940,33 +940,33 @@ GXSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrni, int fg, int bg,
int rop, uint planemask)
{
DEBUGMSG(1, (0, X_INFO, "%s() fg %#x bg %#x rop %#x %#x\n",
- __func__, fg, bg, rop, planemask));
+ __func__, fg, bg, rop, planemask));
rop &= 0x0F;
#ifndef OPT_ACCEL
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- gfx_set_solid_pattern(planemask);
- gfx_set_mono_source(bg, fg, bg == -1 ? 1 : 0);
- gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- gfx2_set_source_stride(pGeode->Pitch);
- gfx2_set_destination_stride(pGeode->Pitch);
+ gfx_set_solid_pattern(planemask);
+ gfx_set_mono_source(bg, fg, bg == -1 ? 1 : 0);
+ gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
+ gfx2_set_source_stride(pGeode->Pitch);
+ gfx2_set_destination_stride(pGeode->Pitch);
}
#else
{
- unsigned int ROP =
- BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- if (bg == -1)
- ROP |= MGP_RM_SRC_TRANS;
- BLT_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ?
- MGP_BM_SRC_MONO | MGP_BM_SRC_FB | MGP_BM_DST_REQ :
- MGP_BM_SRC_MONO | MGP_BM_SRC_FB;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_RASTER_MODE, ROP);
- WRITE_GP32(MGP_PAT_COLOR_0, planemask);
- WRITE_GP32(MGP_SRC_COLOR_BG, bg);
- WRITE_GP32(MGP_SRC_COLOR_FG, fg);
- WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
+ unsigned int ROP =
+ BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
+ if (bg == -1)
+ ROP |= MGP_RM_SRC_TRANS;
+ BLT_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ?
+ MGP_BM_SRC_MONO | MGP_BM_SRC_FB | MGP_BM_DST_REQ :
+ MGP_BM_SRC_MONO | MGP_BM_SRC_FB;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_RASTER_MODE, ROP);
+ WRITE_GP32(MGP_PAT_COLOR_0, planemask);
+ WRITE_GP32(MGP_SRC_COLOR_BG, bg);
+ WRITE_GP32(MGP_SRC_COLOR_FG, fg);
+ WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
}
#endif
}
@@ -984,7 +984,7 @@ GXSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrni, int fg, int bg,
* w int fill area width (pixels)
* h int fill area height (pixels)
* offset int initial x offset
- *
+ *
* Returns :none
*
*---------------------------------------------------------------------------*/
@@ -993,22 +993,22 @@ GXSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrni,
int x, int y, int w, int h, int srcx, int srcy, int offset)
{
DEBUGMSG(1, (0, X_INFO, "%s() %d,%d %dx%d %d,%d %d\n",
- __func__, x, y, w, h, srcx, srcy, offset));
+ __func__, x, y, w, h, srcx, srcy, offset));
#ifndef OPT_ACCEL
gfx2_mono_expand_blt(CALC_FBOFFSET(srcx, srcy), offset, 0,
- CALC_FBOFFSET(x, y), w, h, 0);
+ CALC_FBOFFSET(x, y), w, h, 0);
#else
{
- unsigned int src = (CALC_FBOFFSET(srcx,
- srcy) + (offset >> 3)) | ((offset & 7) << 26);
- unsigned int dst = CALC_FBOFFSET(x, y);
- unsigned int size = (w << 16) | h;
-
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_SRC_OFFSET, src);
- WRITE_GP32(MGP_DST_OFFSET, dst);
- WRITE_GP32(MGP_WID_HEIGHT, size);
- WRITE_GP16(MGP_BLT_MODE, BLT_MODE);
+ unsigned int src = (CALC_FBOFFSET(srcx,
+ srcy) + (offset >> 3)) | ((offset & 7) << 26);
+ unsigned int dst = CALC_FBOFFSET(x, y);
+ unsigned int size = (w << 16) | h;
+
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_SRC_OFFSET, src);
+ WRITE_GP32(MGP_DST_OFFSET, dst);
+ WRITE_GP32(MGP_WID_HEIGHT, size);
+ WRITE_GP16(MGP_BLT_MODE, BLT_MODE);
}
#endif
}
@@ -1049,31 +1049,31 @@ static unsigned short vmode[] = {
* color int foreground fill color
* rop int unmapped raster op
* planemask uint -1 (fill) or pattern data (not enabled)
- *
+ *
* Returns :none
*---------------------------------------------------------------------------*/
static void
GXSetupForSolidLine(ScrnInfoPtr pScrni, int color, int rop, uint planemask)
{
DEBUGMSG(1, (0, X_INFO, "%s() %#x %#x %#x\n",
- __func__, color, rop, planemask));
+ __func__, color, rop, planemask));
rop &= 0x0F;
#ifndef OPT_ACCEL
gfx_set_solid_pattern(color);
gfx_set_raster_operation(planemask == ~0U ? PDfn[rop] :
- (gfx_set_solid_source(planemask), PDfn_SM[rop]));
+ (gfx_set_solid_source(planemask), PDfn_SM[rop]));
#else
{
- unsigned int ROP =
- BPP | (planemask == ~0U ? PDfn[rop] : PDfn_SM[rop]);
- BLT_MODE = ((ROP ^ (ROP >> 2)) & 0x33) == 0 ? MGP_BM_SRC_MONO : 0;
- VEC_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ? ((BLT_MODE |=
- MGP_BM_DST_REQ), MGP_VM_DST_REQ) : 0;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_RASTER_MODE, ROP);
- WRITE_GP32(MGP_PAT_COLOR_0, color);
- WRITE_GP32(MGP_SRC_COLOR_FG, planemask);
- WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
+ unsigned int ROP =
+ BPP | (planemask == ~0U ? PDfn[rop] : PDfn_SM[rop]);
+ BLT_MODE = ((ROP ^ (ROP >> 2)) & 0x33) == 0 ? MGP_BM_SRC_MONO : 0;
+ VEC_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ? ((BLT_MODE |=
+ MGP_BM_DST_REQ), MGP_VM_DST_REQ) : 0;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_RASTER_MODE, ROP);
+ WRITE_GP32(MGP_PAT_COLOR_0, color);
+ WRITE_GP32(MGP_SRC_COLOR_FG, planemask);
+ WRITE_GP32(MGP_STRIDE, ACCEL_STRIDE);
}
#endif
}
@@ -1108,9 +1108,9 @@ GXSubsequentSolidBresenhamLine(ScrnInfoPtr pScrni, int x1, int y1,
long axial, diagn;
DEBUGMSG(1, (0, X_INFO, "%s() %d,%d %d %d, %d %d, %d\n",
- __func__, x1, y1, absmaj, absmin, err, len, octant));
+ __func__, x1, y1, absmaj, absmin, err, len, octant));
if (len <= 0)
- return;
+ return;
axial = absmin;
err += axial;
diagn = absmin - absmaj;
@@ -1118,16 +1118,16 @@ GXSubsequentSolidBresenhamLine(ScrnInfoPtr pScrni, int x1, int y1,
gfx_bresenham_line(x1, y1, len, err, axial, diagn, vmode[octant]);
#else
{
- unsigned int offset = CALC_FBOFFSET(x1, y1);
- unsigned int vec_err = (axial << 16) | (unsigned short)diagn;
- unsigned int vec_len = (len << 16) | (unsigned short)err;
- unsigned int vec_mode = VEC_MODE | vmode[octant];
-
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_DST_OFFSET, offset);
- WRITE_GP32(MGP_VEC_ERR, vec_err);
- WRITE_GP32(MGP_VEC_LEN, vec_len);
- WRITE_GP32(MGP_VECTOR_MODE, vec_mode);
+ unsigned int offset = CALC_FBOFFSET(x1, y1);
+ unsigned int vec_err = (axial << 16) | (unsigned short)diagn;
+ unsigned int vec_len = (len << 16) | (unsigned short)err;
+ unsigned int vec_mode = VEC_MODE | vmode[octant];
+
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_DST_OFFSET, offset);
+ WRITE_GP32(MGP_VEC_ERR, vec_err);
+ WRITE_GP32(MGP_VEC_LEN, vec_len);
+ WRITE_GP32(MGP_VECTOR_MODE, vec_mode);
}
#endif
}
@@ -1155,30 +1155,30 @@ GXSubsequentSolidTwoPointLine(ScrnInfoPtr pScrni, int x0, int y0,
long axial, diagn, err, len;
DEBUGMSG(1, (0, X_INFO, "%s() %d,%d %d,%d, %#x\n",
- __func__, x0, y0, x1, y1, flags));
+ __func__, x0, y0, x1, y1, flags));
if ((dx = x1 - x0) < 0)
- dx = -dx;
+ dx = -dx;
if ((dy = y1 - y0) < 0)
- dy = -dy;
+ dy = -dy;
if (dy >= dx) {
- dmaj = dy;
- dmin = dx;
- octant = YMAJOR;
+ dmaj = dy;
+ dmin = dx;
+ octant = YMAJOR;
} else {
- dmaj = dx;
- dmin = dy;
- octant = 0;
+ dmaj = dx;
+ dmin = dy;
+ octant = 0;
}
len = dmaj;
if ((flags & OMIT_LAST) == 0)
- ++len;
+ ++len;
if (len <= 0)
- return;
+ return;
if (x1 < x0)
- octant |= XDECREASING;
+ octant |= XDECREASING;
if (y1 < y0)
- octant |= YDECREASING;
+ octant |= YDECREASING;
axial = dmin << 1;
bias = miGetZeroLineBias(pScrni->pScreen);
@@ -1189,16 +1189,16 @@ GXSubsequentSolidTwoPointLine(ScrnInfoPtr pScrni, int x0, int y0,
gfx_bresenham_line(x0, y0, len, err, axial, diagn, vmode[octant]);
#else
{
- unsigned int offset = CALC_FBOFFSET(x0, y0);
- unsigned int vec_err = (axial << 16) | (unsigned short)diagn;
- unsigned int vec_len = (len << 16) | (unsigned short)err;
- unsigned int vec_mode = VEC_MODE | vmode[octant];
-
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_DST_OFFSET, offset);
- WRITE_GP32(MGP_VEC_ERR, vec_err);
- WRITE_GP32(MGP_VEC_LEN, vec_len);
- WRITE_GP32(MGP_VECTOR_MODE, vec_mode);
+ unsigned int offset = CALC_FBOFFSET(x0, y0);
+ unsigned int vec_err = (axial << 16) | (unsigned short)diagn;
+ unsigned int vec_len = (len << 16) | (unsigned short)err;
+ unsigned int vec_mode = VEC_MODE | vmode[octant];
+
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_DST_OFFSET, offset);
+ WRITE_GP32(MGP_VEC_ERR, vec_err);
+ WRITE_GP32(MGP_VEC_LEN, vec_len);
+ WRITE_GP32(MGP_VECTOR_MODE, vec_mode);
}
#endif
}
@@ -1225,22 +1225,21 @@ static void
GXSubsequentSolidHorVertLine(ScrnInfoPtr pScrni,
int x, int y, int len, int dir)
{
- DEBUGMSG(1, (0, X_INFO, "%s() %d,%d %d %d\n",
- __func__, x, y, len, dir));
+ DEBUGMSG(1, (0, X_INFO, "%s() %d,%d %d %d\n", __func__, x, y, len, dir));
#ifndef OPT_ACCEL
if (dir == DEGREES_0)
- gfx_pattern_fill(x, y, len, 1);
+ gfx_pattern_fill(x, y, len, 1);
else
- gfx_pattern_fill(x, y, 1, len);
+ gfx_pattern_fill(x, y, 1, len);
#else
{
- unsigned int offset = CALC_FBOFFSET(x, y);
- unsigned int size =
- dir == DEGREES_0 ? (len << 16) | 1 : (1 << 16) | len;
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_DST_OFFSET, offset);
- WRITE_GP32(MGP_WID_HEIGHT, size);
- WRITE_GP32(MGP_BLT_MODE, BLT_MODE);
+ unsigned int offset = CALC_FBOFFSET(x, y);
+ unsigned int size =
+ dir == DEGREES_0 ? (len << 16) | 1 : (1 << 16) | len;
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_DST_OFFSET, offset);
+ WRITE_GP32(MGP_WID_HEIGHT, size);
+ WRITE_GP32(MGP_BLT_MODE, BLT_MODE);
}
#endif
}
@@ -1262,7 +1261,7 @@ GXSubsequentSolidHorVertLine(ScrnInfoPtr pScrni,
* planemask uint -1 (fill) or pattern data (not enabled)
* length int pattern length (bits)
* pattern uchar* dash pattern mask
- *
+ *
* Returns :none
*---------------------------------------------------------------------------*/
static void
@@ -1274,16 +1273,16 @@ GXSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
CARD32 pat8x8[2];
if (length <= 0)
- return;
+ return;
i = l = m = 0;
while (i < 2) {
- m |= pat >> l;
- l += length;
- if ((n = l - 32) >= 0) {
- pat8x8[i++] = m;
- m = pat << (length - n);
- l = n;
- }
+ m |= pat >> l;
+ l += length;
+ if ((n = l - 32) >= 0) {
+ pat8x8[i++] = m;
+ m = pat << (length - n);
+ l = n;
+ }
}
gdln.pat[0] = pat8x8[0];
gdln.pat[1] = pat8x8[1];
@@ -1293,7 +1292,7 @@ GXSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
rop &= 0x0F;
gfx_set_solid_pattern(0);
gfx_set_raster_operation(planemask == ~0U ? PDfn[rop] :
- (gfx_set_solid_source(planemask), PDfn_SM[rop]));
+ (gfx_set_solid_source(planemask), PDfn_SM[rop]));
}
/*---------------------------------------------------------------------------
@@ -1312,11 +1311,11 @@ GXSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
* len: Specifies the length of the vector interms of pixels.
* octant: not used in this function,may be added for standard
* interface.
- *
+ *
* Returns: none
*
* Comments: none
- *
+ *
* Sample application uses:
* - Window outlines on window move.
* - x11perf: line segments (-line500).
@@ -1333,22 +1332,22 @@ GXSubsequentDashedBresenhamLine(ScrnInfoPtr pScrni,
int trans = (gdln.bg == -1);
unsigned long pat8x8[2];
- //ErrorF("BLine %d, %d, %d, %d, %d, %d, %d\n" x1, y1, absmaj, absmin,
+ //ErrorF("BLine %d, %d, %d, %d, %d, %d, %d\n" x1, y1, absmaj, absmin,
//err, len, octant);
i = phase >= 32 ? (phase -= 32, 1) : 0;
n = 32 - phase;
pat8x8[0] =
- ((gdln.pat[i] >> phase) & ((1UL << n) - 1)) | (gdln.pat[1 - i] << n);
+ ((gdln.pat[i] >> phase) & ((1UL << n) - 1)) | (gdln.pat[1 - i] << n);
pat8x8[1] =
- ((gdln.pat[1 - i] >> phase) & ((1UL << n) - 1)) | (gdln.pat[i] << n);
+ ((gdln.pat[1 - i] >> phase) & ((1UL << n) - 1)) | (gdln.pat[i] << n);
axial = absmin;
err += axial;
diagn = absmin - absmaj;
gfx_set_mono_pattern(gdln.bg, gdln.fg, pat8x8[0], pat8x8[1], trans);
gfx2_set_pattern_origin(x1, y1);
gfx2_bresenham_line(CALC_FBOFFSET(x1, y1), len, err, axial, diagn,
- vmode[octant]);
+ vmode[octant]);
}
/*---------------------------------------------------------------------------
@@ -1376,37 +1375,37 @@ GXSubsequentDashedTwoPointLine(ScrnInfoPtr pScrni, int x0, int y0,
long axial, diagn, err, len, pat8x8[2];
//ErrorF("GXSubsequentDashedTwoPointLine() %d,%d %d,%d, %#x %d\n",
- // x0, y0, x1, y1, flags, phase);
+ // x0, y0, x1, y1, flags, phase);
i = phase >= 32 ? (phase -= 32, 1) : 0;
n = 32 - phase;
pat8x8[0] =
- ((gdln.pat[i] >> phase) & ((1UL << n) - 1)) | (gdln.pat[1 - i] << n);
+ ((gdln.pat[i] >> phase) & ((1UL << n) - 1)) | (gdln.pat[1 - i] << n);
pat8x8[1] =
- ((gdln.pat[1 - i] >> phase) & ((1UL << n) - 1)) | (gdln.pat[i] << n);
+ ((gdln.pat[1 - i] >> phase) & ((1UL << n) - 1)) | (gdln.pat[i] << n);
if ((dx = x1 - x0) < 0)
- dx = -dx;
+ dx = -dx;
if ((dy = y1 - y0) < 0)
- dy = -dy;
+ dy = -dy;
if (dy >= dx) {
- dmaj = dy;
- dmin = dx;
- octant = YMAJOR;
+ dmaj = dy;
+ dmin = dx;
+ octant = YMAJOR;
} else {
- dmaj = dx;
- dmin = dy;
- octant = 0;
+ dmaj = dx;
+ dmin = dy;
+ octant = 0;
}
len = dmaj;
if ((flags & OMIT_LAST) == 0)
- ++len;
+ ++len;
if (len <= 0)
- return;
+ return;
if (x1 < x0)
- octant |= XDECREASING;
+ octant |= XDECREASING;
if (y1 < y0)
- octant |= YDECREASING;
+ octant |= YDECREASING;
axial = dmin << 1;
bias = miGetZeroLineBias(pScrni->pScreen);
@@ -1415,7 +1414,7 @@ GXSubsequentDashedTwoPointLine(ScrnInfoPtr pScrni, int x0, int y0,
gfx2_set_pattern_origin(x0, y0);
gfx2_bresenham_line(CALC_FBOFFSET(x0, y0), len, err, axial, diagn,
- vmode[octant]);
+ vmode[octant]);
}
#endif /* GX_DASH_LINE_SUPPORT */
@@ -1432,27 +1431,27 @@ GXWritePixmap(ScrnInfoPtr pScrni, int x, int y, int w, int h,
// x, y, w, h, src, srcwidth, rop, planemask, trans, bpp, depth);
if (bpp == pScrni->bitsPerPixel) {
- rop &= 0x0F;
- if (rop == GXcopy && trans == -1) {
- gfx_wait_until_idle();
- geode_memory_to_screen_blt((unsigned long)src,
- (unsigned long)FBADDR(x, y), srcwidth, pGeode->Pitch, w,
- h, bpp);
- } else {
- gfx_set_solid_pattern(planemask);
- gfx_set_raster_operation(planemask ==
- ~0U ? SDfn[rop] : SDfn_PM[rop]);
- if (trans != -1)
- gfx_color_bitmap_to_screen_xblt(0, 0, x, y, w, h, src,
- srcwidth, trans);
- else
- gfx_color_bitmap_to_screen_blt(0, 0, x, y, w, h, src,
- srcwidth);
- SET_SYNC_FLAG(pGeode->AccelInfoRec);
- }
+ rop &= 0x0F;
+ if (rop == GXcopy && trans == -1) {
+ gfx_wait_until_idle();
+ geode_memory_to_screen_blt((unsigned long)src,
+ (unsigned long)FBADDR(x, y), srcwidth, pGeode->Pitch, w,
+ h, bpp);
+ } else {
+ gfx_set_solid_pattern(planemask);
+ gfx_set_raster_operation(planemask ==
+ ~0U ? SDfn[rop] : SDfn_PM[rop]);
+ if (trans != -1)
+ gfx_color_bitmap_to_screen_xblt(0, 0, x, y, w, h, src,
+ srcwidth, trans);
+ else
+ gfx_color_bitmap_to_screen_blt(0, 0, x, y, w, h, src,
+ srcwidth);
+ SET_SYNC_FLAG(pGeode->AccelInfoRec);
+ }
} else
- pGeode->WritePixmap(pScrni, x, y, w, h, src, srcwidth, rop, planemask,
- trans, bpp, depth);
+ pGeode->WritePixmap(pScrni, x, y, w, h, src, srcwidth, rop, planemask,
+ trans, bpp, depth);
}
#endif /* if GX_WRITE_PIXMAP_SUPPORT */
@@ -1480,7 +1479,7 @@ amd_gx_exa_UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h,
dst += y * dst_pitch + x * (bpp >> 3);
GU2_WAIT_BUSY;
geode_memory_to_screen_blt((unsigned long)src, (unsigned long)dst,
- src_pitch, dst_pitch, w, h, bpp);
+ src_pitch, dst_pitch, w, h, bpp);
return TRUE;
}
@@ -1495,7 +1494,7 @@ amd_gx_exa_DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,
src += (y * src_pitch) + (x * (bpp >> 3));
GU2_WAIT_BUSY;
geode_memory_to_screen_blt((unsigned long)src, (unsigned long)dst,
- src_pitch, dst_pitch, w, h, bpp);
+ src_pitch, dst_pitch, w, h, bpp);
return TRUE;
}
@@ -1505,17 +1504,16 @@ static Bool
amd_gx_exa_PrepareSolid(PixmapPtr pxMap, int alu, Pixel planemask, Pixel fg)
{
int dstPitch = exaGetPixmapPitch(pxMap);
- unsigned int ROP =
- amd_gx_BppToRasterMode(pxMap->drawable.bitsPerPixel)
+ unsigned int ROP = amd_gx_BppToRasterMode(pxMap->drawable.bitsPerPixel)
| (planemask == ~0U ? SDfn[alu] : SDfn_PM[alu]);
// FIXME: this should go away -- workaround for the blockparty icon corruption
//if (pxMap->drawable.bitsPerPixel == 32)
- // return FALSE;
+ // return FALSE;
BLT_MODE = ((ROP ^ (ROP >> 2)) & 0x33) == 0 ? MGP_BM_SRC_MONO : 0;
if (((ROP ^ (ROP >> 1)) & 0x55) != 0)
- BLT_MODE |= MGP_BM_DST_REQ;
+ BLT_MODE |= MGP_BM_DST_REQ;
//ErrorF("amd_gx_exa_PrepareSolid(%#x,%#x,%#x - ROP=%x,BLT_MODE=%x)\n", alu, planemask, fg, ROP, BLT_MODE);
GU2_WAIT_PENDING;
WRITE_GP32(MGP_RASTER_MODE, ROP);
@@ -1568,7 +1566,7 @@ amd_gx_exa_PrepareCopy(PixmapPtr pxSrc, PixmapPtr pxDst, int dx, int dy,
(planemask == ~0U ? SDfn[alu] : SDfn_PM[alu]);
BLT_MODE = ((ROP ^ (ROP >> 1)) & 0x55) != 0 ?
- MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
+ MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
GU2_WAIT_PENDING;
WRITE_GP32(MGP_RASTER_MODE, ROP);
WRITE_GP32(MGP_PAT_COLOR_0, planemask);
@@ -1586,10 +1584,10 @@ amd_gx_exa_Copy(PixmapPtr pxDst, int srcX, int srcY, int dstX, int dstY,
int dstBpp = (pxDst->drawable.bitsPerPixel + 7) / 8;
int dstPitch = exaGetPixmapPitch(pxDst);
unsigned int srcOffset =
- pGeode->cpySrcOffset + (pGeode->cpySrcPitch * srcY) +
- (pGeode->cpySrcBpp * srcX);
+ pGeode->cpySrcOffset + (pGeode->cpySrcPitch * srcY) +
+ (pGeode->cpySrcBpp * srcX);
unsigned int dstOffset =
- exaGetPixmapOffset(pxDst) + (dstPitch * dstY) + (dstBpp * dstX);
+ exaGetPixmapOffset(pxDst) + (dstPitch * dstY) + (dstBpp * dstX);
unsigned int size = (w << 16) | h;
unsigned int blt_mode = BLT_MODE;
@@ -1597,14 +1595,14 @@ amd_gx_exa_Copy(PixmapPtr pxDst, int srcX, int srcY, int dstX, int dstY,
// dstX, dstY, w, h);
if (pGeode->cpyDx < 0) {
- srcOffset += w * pGeode->cpySrcBpp - 1;
- dstOffset += w * dstBpp - 1;
- blt_mode |= MGP_BM_NEG_XDIR;
+ srcOffset += w * pGeode->cpySrcBpp - 1;
+ dstOffset += w * dstBpp - 1;
+ blt_mode |= MGP_BM_NEG_XDIR;
}
if (pGeode->cpyDy < 0) {
- srcOffset += (h - 1) * pGeode->cpySrcPitch;
- dstOffset += (h - 1) * dstPitch;
- blt_mode |= MGP_BM_NEG_YDIR;
+ srcOffset += (h - 1) * pGeode->cpySrcPitch;
+ dstOffset += (h - 1) * dstPitch;
+ blt_mode |= MGP_BM_NEG_YDIR;
}
GU2_WAIT_PENDING;
WRITE_GP32(MGP_SRC_OFFSET, srcOffset);
@@ -1635,27 +1633,27 @@ amd_gx_exa_Copy(PixmapPtr pxDst, int srcX, int srcY, int dstX, int dstY,
#define a_1 MGP_RM_SELECT_ALPHA_1
#define MGP_RM_ALPHA_TO_ARGB (MGP_RM_ALPHA_TO_ALPHA | MGP_RM_ALPHA_TO_RGB)
-#define gxPictOpMAX PictOpAdd /* highest accelerated op */
+#define gxPictOpMAX PictOpAdd /* highest accelerated op */
unsigned int amd_gx_exa_alpha_ops[] =
/* A B OP AS const = 0 */
{
- (SRC_DST | Aa_B0 | a_C), 0, /* clear (src*0) */
- (SRC_DST | Aa_B0 | a_1), 0, /* src (src*1) */
- (DST_SRC | Aa_B0 | a_1), 0, /* dst (dst*1) */
+ (SRC_DST | Aa_B0 | a_C), 0, /* clear (src*0) */
+ (SRC_DST | Aa_B0 | a_1), 0, /* src (src*1) */
+ (DST_SRC | Aa_B0 | a_1), 0, /* dst (dst*1) */
(SRC_DST | A1_B1a | a_A), 0, /* src-over (src*1 + dst(1-A)) */
(DST_SRC | A1_B1a | a_A), 0, /* dst-over (dst*1 + src(1-B)) */
- (SRC_DST | Aa_B0 | a_B), 0, /* src-in (src*B) */
- (DST_SRC | Aa_B0 | a_B), 0, /* dst-in (dst*A) */
+ (SRC_DST | Aa_B0 | a_B), 0, /* src-in (src*B) */
+ (DST_SRC | Aa_B0 | a_B), 0, /* dst-in (dst*A) */
(DST_SRC | A0_B1a | a_A), 0, /* src-out (src*(1-B)) */
(SRC_DST | A0_B1a | a_A), 0, /* dst-out (dst*(1-A)) */
/* pass1 (SRC=dst DST=scr=src), pass2 (SRC=src, DST=dst) */
- (DST_SRC | Aa_B0 | a_B), /* srcatop (src*B) */
- (SRC_DST | A0_B1a | a_A), /* + (dst(1-A)) */
- (SRC_DST | Aa_B0 | a_B), /* dstatop (dst*A) */
- (DST_SRC | A0_B1a | a_A), /* + (src(1-B) */
- (SRC_DST | A0_B1a | a_A), /* xor (src*(1-B) */
- (SRC_DST | A0_B1a | a_A), /* + (dst(1-A) */
+ (DST_SRC | Aa_B0 | a_B), /* srcatop (src*B) */
+ (SRC_DST | A0_B1a | a_A), /* + (dst(1-A)) */
+ (SRC_DST | Aa_B0 | a_B), /* dstatop (dst*A) */
+ (DST_SRC | A0_B1a | a_A), /* + (src(1-B) */
+ (SRC_DST | A0_B1a | a_A), /* xor (src*(1-B) */
+ (SRC_DST | A0_B1a | a_A), /* + (dst(1-A) */
(SRC_DST | A1_B1a | a_C), 0, /* add (src*1 + dst*1) */
};
@@ -1684,13 +1682,13 @@ amd_gx_exa_check_format(PicturePtr p)
amd_gx_exa_fmt_t *fp = &amd_gx_exa_fmts[0];
for (i = sizeof(amd_gx_exa_fmts) / sizeof(amd_gx_exa_fmts[0]); --i >= 0;
- ++fp) {
- if (fp->bpp < bpp)
- return NULL;
- if (fp->bpp != bpp)
- continue;
- if (fp->exa_fmt == p->format)
- break;
+ ++fp) {
+ if (fp->bpp < bpp)
+ return NULL;
+ if (fp->bpp != bpp)
+ continue;
+ if (fp->exa_fmt == p->format)
+ break;
}
return i < 0 ? NULL : fp;
}
@@ -1704,19 +1702,19 @@ amd_gx_exa_CheckComposite(int op, PicturePtr pSrc, PicturePtr pMsk,
GeodeRec *pGeode = GEODEPTR_FROM_PICTURE(pDst);
if (op > gxPictOpMAX)
- return FALSE;
+ return FALSE;
if (pMsk)
- return FALSE;
+ return FALSE;
if (usesPasses(op) && pGeode->exaBfrSz == 0)
- return FALSE;
+ return FALSE;
if (pSrc->filter != PictFilterNearest &&
- pSrc->filter != PictFilterFast &&
- pSrc->filter != PictFilterGood && pSrc->filter != PictFilterBest)
- return FALSE;
+ pSrc->filter != PictFilterFast &&
+ pSrc->filter != PictFilterGood && pSrc->filter != PictFilterBest)
+ return FALSE;
if (pSrc->repeat)
- return FALSE;
+ return FALSE;
if (pSrc->transform)
- return FALSE;
+ return FALSE;
return TRUE;
}
@@ -1730,27 +1728,27 @@ amd_gx_exa_PrepareComposite(int op, PicturePtr pSrc, PicturePtr pMsk,
amd_gx_exa_fmt_t *sfp, *dfp;
//ErrorF("amd_gx_exa_PrepareComposite()\n");
-
+
if ((sfp = amd_gx_exa_check_format(pSrc)) == NULL)
- return FALSE;
+ return FALSE;
if (sfp->alpha_bits == 0 && usesSrcAlpha(op))
- return FALSE;
+ return FALSE;
if ((dfp = amd_gx_exa_check_format(pDst)) == NULL)
- return FALSE;
+ return FALSE;
if (dfp->alpha_bits == 0 && usesDstAlpha(op))
- return FALSE;
+ return FALSE;
if (sfp->gx_fmt != dfp->gx_fmt)
- return FALSE;
+ return FALSE;
srcPitch = exaGetPixmapPitch(pxSrc);
if (usesPasses(op) && srcPitch > pGeode->exaBfrSz)
- return FALSE;
+ return FALSE;
pGeode->cmpSrcPitch = srcPitch;
pGeode->cmpOp = op;
pGeode->cmpSrcOffset = exaGetPixmapOffset(pxSrc);
pGeode->cmpSrcBpp = (pxSrc->drawable.bitsPerPixel + 7) / 8;
pGeode->cmpSrcFmt = sfp->gx_fmt;
pGeode->cmpDstFmt = dfp->gx_fmt | (dfp->alpha_bits == 0 ?
- MGP_RM_ALPHA_TO_RGB : MGP_RM_ALPHA_TO_ARGB);
+ MGP_RM_ALPHA_TO_RGB : MGP_RM_ALPHA_TO_ARGB);
return TRUE;
}
@@ -1769,16 +1767,16 @@ amd_gx_exa_Composite(PixmapPtr pxDst, int srcX, int srcY, int maskX,
op = pGeode->cmpOp;
if (usesPasses(op)) {
- int cacheLineSz = 32;
- int cachelines =
- (width * pGeode->cmpSrcBpp + cacheLineSz - 1) / cacheLineSz;
- scratchPitch = cachelines * cacheLineSz;
- if (scratchPitch > pGeode->cmpSrcPitch)
- scratchPitch = pGeode->cmpSrcPitch;
- max_lines = pGeode->exaBfrSz / scratchPitch;
+ int cacheLineSz = 32;
+ int cachelines =
+ (width * pGeode->cmpSrcBpp + cacheLineSz - 1) / cacheLineSz;
+ scratchPitch = cachelines * cacheLineSz;
+ if (scratchPitch > pGeode->cmpSrcPitch)
+ scratchPitch = pGeode->cmpSrcPitch;
+ max_lines = pGeode->exaBfrSz / scratchPitch;
} else {
- scratchPitch = 0;
- max_lines = height;
+ scratchPitch = 0;
+ max_lines = height;
}
dstBpp = (pxDst->drawable.bitsPerPixel + 7) / 8;
@@ -1790,80 +1788,80 @@ amd_gx_exa_Composite(PixmapPtr pxDst, int srcX, int srcY, int maskX,
current_line = pass = 0;
while (current_line < height) {
- if (usesPasses(op)) {
- lines = height - current_line;
- if (lines > max_lines)
- lines = max_lines;
- switch (pass) {
- case 0: /* copy src to scratch */
- srcPch = srcPitch;
- srcOfs = srcOffset + current_line * srcPch;
- dstPch = scratchPitch;
- dstOfs = pGeode->exaBfrOffset;
- rop = pGeode->cmpSrcFmt | MGP_RM_ALPHA_TO_ARGB;
- rop |= amd_gx_exa_alpha_ops[PictOpSrc * 2];
- blt_mode = usesChanB0(PictOpSrc) ?
- MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
- ++pass;
- break;
- case 1: /* pass1 */
- srcPch = dstPitch;
- srcOfs = dstOffset + current_line * srcPch;
- dstPch = scratchPitch;
- dstOfs = pGeode->exaBfrOffset;
- rop = pGeode->cmpSrcFmt | MGP_RM_ALPHA_TO_ARGB;
- rop |= amd_gx_exa_alpha_ops[op * 2];
- blt_mode = usesChanB1(op) ?
- MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
- ++pass;
- break;
- case 2: /* pass2 */
- srcPch = srcPitch;
- srcOfs = srcOffset + current_line * srcPch;
- dstPch = dstPitch;
- dstOfs = dstOffset + current_line * dstPch;
- rop = pGeode->cmpSrcFmt | MGP_RM_ALPHA_TO_ARGB;
- rop |= amd_gx_exa_alpha_ops[op * 2 + 1];
- blt_mode = usesChanB2(op) ?
- MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
- ++pass;
- break;
- case 3: /* add */
- srcPch = scratchPitch;
- srcOfs = pGeode->exaBfrOffset;
- dstPch = dstPitch;
- dstOfs = dstOffset + current_line * dstPch;
- rop = pGeode->cmpDstFmt;
- rop |= amd_gx_exa_alpha_ops[PictOpAdd * 2];
- blt_mode = usesChanB0(PictOpAdd) ?
- MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
- current_line += lines;
- pass = 0;
- break;
- }
- strides = (srcPch << 16) | dstPch;
- } else { /* not multi pass */
- srcOfs = srcOffset;
- dstOfs = dstOffset;
- current_line = lines = height;
- strides = (srcPitch << 16) | dstPitch;
- rop = pGeode->cmpDstFmt | amd_gx_exa_alpha_ops[op * 2];
- blt_mode = usesChanB0(op) ?
- MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
- }
- sizes = (width << 16) | lines;
- if (srcOfs < dstOfs) {
- srcOfs += (lines - 1) * srcPitch + width * srcBpp - 1;
- dstOfs += (lines - 1) * dstPitch + width * dstBpp - 1;
- blt_mode |= MGP_BM_NEG_XDIR | MGP_BM_NEG_YDIR;
- }
- GU2_WAIT_PENDING;
- WRITE_GP32(MGP_RASTER_MODE, rop);
- WRITE_GP32(MGP_SRC_OFFSET, srcOfs);
- WRITE_GP32(MGP_DST_OFFSET, dstOfs);
- WRITE_GP32(MGP_WID_HEIGHT, sizes);
- WRITE_GP32(MGP_STRIDE, strides);
- WRITE_GP16(MGP_BLT_MODE, blt_mode);
+ if (usesPasses(op)) {
+ lines = height - current_line;
+ if (lines > max_lines)
+ lines = max_lines;
+ switch (pass) {
+ case 0: /* copy src to scratch */
+ srcPch = srcPitch;
+ srcOfs = srcOffset + current_line * srcPch;
+ dstPch = scratchPitch;
+ dstOfs = pGeode->exaBfrOffset;
+ rop = pGeode->cmpSrcFmt | MGP_RM_ALPHA_TO_ARGB;
+ rop |= amd_gx_exa_alpha_ops[PictOpSrc * 2];
+ blt_mode = usesChanB0(PictOpSrc) ?
+ MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
+ ++pass;
+ break;
+ case 1: /* pass1 */
+ srcPch = dstPitch;
+ srcOfs = dstOffset + current_line * srcPch;
+ dstPch = scratchPitch;
+ dstOfs = pGeode->exaBfrOffset;
+ rop = pGeode->cmpSrcFmt | MGP_RM_ALPHA_TO_ARGB;
+ rop |= amd_gx_exa_alpha_ops[op * 2];
+ blt_mode = usesChanB1(op) ?
+ MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
+ ++pass;
+ break;
+ case 2: /* pass2 */
+ srcPch = srcPitch;
+ srcOfs = srcOffset + current_line * srcPch;
+ dstPch = dstPitch;
+ dstOfs = dstOffset + current_line * dstPch;
+ rop = pGeode->cmpSrcFmt | MGP_RM_ALPHA_TO_ARGB;
+ rop |= amd_gx_exa_alpha_ops[op * 2 + 1];
+ blt_mode = usesChanB2(op) ?
+ MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
+ ++pass;
+ break;
+ case 3: /* add */
+ srcPch = scratchPitch;
+ srcOfs = pGeode->exaBfrOffset;
+ dstPch = dstPitch;
+ dstOfs = dstOffset + current_line * dstPch;
+ rop = pGeode->cmpDstFmt;
+ rop |= amd_gx_exa_alpha_ops[PictOpAdd * 2];
+ blt_mode = usesChanB0(PictOpAdd) ?
+ MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
+ current_line += lines;
+ pass = 0;
+ break;
+ }
+ strides = (srcPch << 16) | dstPch;
+ } else { /* not multi pass */
+ srcOfs = srcOffset;
+ dstOfs = dstOffset;
+ current_line = lines = height;
+ strides = (srcPitch << 16) | dstPitch;
+ rop = pGeode->cmpDstFmt | amd_gx_exa_alpha_ops[op * 2];
+ blt_mode = usesChanB0(op) ?
+ MGP_BM_SRC_FB | MGP_BM_DST_REQ : MGP_BM_SRC_FB;
+ }
+ sizes = (width << 16) | lines;
+ if (srcOfs < dstOfs) {
+ srcOfs += (lines - 1) * srcPitch + width * srcBpp - 1;
+ dstOfs += (lines - 1) * dstPitch + width * dstBpp - 1;
+ blt_mode |= MGP_BM_NEG_XDIR | MGP_BM_NEG_YDIR;
+ }
+ GU2_WAIT_PENDING;
+ WRITE_GP32(MGP_RASTER_MODE, rop);
+ WRITE_GP32(MGP_SRC_OFFSET, srcOfs);
+ WRITE_GP32(MGP_DST_OFFSET, dstOfs);
+ WRITE_GP32(MGP_WID_HEIGHT, sizes);
+ WRITE_GP32(MGP_STRIDE, strides);
+ WRITE_GP16(MGP_BLT_MODE, blt_mode);
}
}
#endif /* #if XF86EXA */
@@ -1901,20 +1899,19 @@ GXAccelInit(ScreenPtr pScrn)
switch (pGeode->Pitch) {
case 1024:
- gu2_yshift = 10;
- break;
+ gu2_yshift = 10;
+ break;
case 2048:
- gu2_yshift = 11;
- break;
+ gu2_yshift = 11;
+ break;
case 4096:
- gu2_yshift = 12;
- break;
+ gu2_yshift = 12;
+ break;
default:
- gu2_yshift = 13;
- break;
+ gu2_yshift = 13;
+ break;
}
-
#ifdef OPT_ACCEL
ACCEL_STRIDE = (pGeode->Pitch << 16) | pGeode->Pitch;
BPP = amd_gx_BppToRasterMode(pScrni->bitsPerPixel);
@@ -1925,40 +1922,40 @@ GXAccelInit(ScreenPtr pScrn)
pExa->exa_major = EXA_VERSION_MAJOR;
pExa->exa_minor = EXA_VERSION_MINOR;
- /* Sync */
- pExa->WaitMarker = amd_gx_exa_WaitMarker;
- /* UploadToScreen */
- pExa->UploadToScreen = amd_gx_exa_UploadToScreen;
- pExa->DownloadFromScreen = amd_gx_exa_DownloadFromScreen;
-
- /* Solid fill */
- pExa->PrepareSolid = amd_gx_exa_PrepareSolid;
- pExa->Solid = amd_gx_exa_Solid;
- pExa->DoneSolid = amd_gx_exa_Done;
-
- /* Copy */
- pExa->PrepareCopy = amd_gx_exa_PrepareCopy;
- pExa->Copy = amd_gx_exa_Copy;
- pExa->DoneCopy = amd_gx_exa_Done;
-
- /* Composite */
- pExa->CheckComposite = amd_gx_exa_CheckComposite;
- pExa->PrepareComposite = amd_gx_exa_PrepareComposite;
- pExa->Composite = amd_gx_exa_Composite;
- pExa->DoneComposite = amd_gx_exa_Done;
-
- return exaDriverInit(pScrn, pGeode->pExa);
+ /* Sync */
+ pExa->WaitMarker = amd_gx_exa_WaitMarker;
+ /* UploadToScreen */
+ pExa->UploadToScreen = amd_gx_exa_UploadToScreen;
+ pExa->DownloadFromScreen = amd_gx_exa_DownloadFromScreen;
+
+ /* Solid fill */
+ pExa->PrepareSolid = amd_gx_exa_PrepareSolid;
+ pExa->Solid = amd_gx_exa_Solid;
+ pExa->DoneSolid = amd_gx_exa_Done;
+
+ /* Copy */
+ pExa->PrepareCopy = amd_gx_exa_PrepareCopy;
+ pExa->Copy = amd_gx_exa_Copy;
+ pExa->DoneCopy = amd_gx_exa_Done;
+
+ /* Composite */
+ pExa->CheckComposite = amd_gx_exa_CheckComposite;
+ pExa->PrepareComposite = amd_gx_exa_PrepareComposite;
+ pExa->Composite = amd_gx_exa_Composite;
+ pExa->DoneComposite = amd_gx_exa_Done;
+
+ return exaDriverInit(pScrn, pGeode->pExa);
}
#endif
/* Getting the pointer for acceleration Inforecord */
pGeode->AccelInfoRec = localRecPtr = XAACreateInfoRec();
if (!pGeode->AccelInfoRec)
- return FALSE;
+ return FALSE;
/* SET ACCELERATION FLAGS */
localRecPtr->Flags =
- PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER;
+ PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER;
/* HOOK SYNCRONIZARION ROUTINE */
localRecPtr->Sync = GXAccelSync;
@@ -1976,7 +1973,7 @@ GXAccelInit(ScreenPtr pScrn)
HOOK(SubsequentMono8x8PatternFillRect);
/* BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD | NO_TRANSPARENCY | */
localRecPtr->Mono8x8PatternFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST |
- HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN;
+ HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN;
#endif
#if GX_CLREXP_8X8_PAT_SUPPORT
@@ -1985,8 +1982,8 @@ GXAccelInit(ScreenPtr pScrn)
HOOK(SubsequentColor8x8PatternFillRect);
/* BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD | NO_TRANSPARENCY | */
localRecPtr->Color8x8PatternFillFlags =
- BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD |
- HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_PROGRAMMED_ORIGIN;
+ BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD |
+ HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_PROGRAMMED_ORIGIN;
#endif
#if GX_SCR2SCRCPY_SUPPORT
@@ -1996,7 +1993,7 @@ GXAccelInit(ScreenPtr pScrn)
HOOK(SetupForScreenToScreenCopy);
HOOK(SubsequentScreenToScreenCopy);
localRecPtr->ScreenToScreenCopyFlags =
- BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD;
+ BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD;
#endif
#if GX_BRES_LINE_SUPPORT
@@ -2016,8 +2013,8 @@ GXAccelInit(ScreenPtr pScrn)
HOOK(SubsequentDashedTwoPointLine);
localRecPtr->DashedBresenhamLineErrorTermBits = 15;
localRecPtr->DashPatternMaxLength = 64;
- localRecPtr->DashedLineFlags = NO_PLANEMASK | /* TRANSPARENCY_ONLY | */
- LINE_PATTERN_POWER_OF_2_ONLY | LINE_PATTERN_MSBFIRST_MSBJUSTIFIED;
+ localRecPtr->DashedLineFlags = NO_PLANEMASK | /* TRANSPARENCY_ONLY | */
+ LINE_PATTERN_POWER_OF_2_ONLY | LINE_PATTERN_MSBFIRST_MSBJUSTIFIED;
#endif
#if GX_SCR2SCREXP_SUPPORT
@@ -2025,37 +2022,37 @@ GXAccelInit(ScreenPtr pScrn)
HOOK(SetupForScreenToScreenColorExpandFill);
HOOK(SubsequentScreenToScreenColorExpandFill);
localRecPtr->ScreenToScreenColorExpandFillFlags =
- BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD | NO_TRANSPARENCY;
+ BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD | NO_TRANSPARENCY;
#endif
if (pGeode->AccelImageWriteBuffers) {
#if GX_SCANLINE_SUPPORT
- localRecPtr->ScanlineImageWriteBuffers =
- pGeode->AccelImageWriteBuffers;
- localRecPtr->NumScanlineImageWriteBuffers = pGeode->NoOfImgBuffers;
- HOOK(SetupForScanlineImageWrite);
- HOOK(SubsequentScanlineImageWriteRect);
- HOOK(SubsequentImageWriteScanline);
- localRecPtr->ScanlineImageWriteFlags = NO_PLANEMASK | NO_GXCOPY |
- BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD;
+ localRecPtr->ScanlineImageWriteBuffers =
+ pGeode->AccelImageWriteBuffers;
+ localRecPtr->NumScanlineImageWriteBuffers = pGeode->NoOfImgBuffers;
+ HOOK(SetupForScanlineImageWrite);
+ HOOK(SubsequentScanlineImageWriteRect);
+ HOOK(SubsequentImageWriteScanline);
+ localRecPtr->ScanlineImageWriteFlags = NO_PLANEMASK | NO_GXCOPY |
+ BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD;
#endif
} else {
- localRecPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES;
+ localRecPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES;
}
if (pGeode->AccelColorExpandBuffers) {
#if GX_CPU2SCREXP_SUPPORT
- /* Color expansion */
- localRecPtr->ScanlineColorExpandBuffers =
- pGeode->AccelColorExpandBuffers;
- localRecPtr->NumScanlineColorExpandBuffers =
- pGeode->NoOfColorExpandLines;
- HOOK(SetupForScanlineCPUToScreenColorExpandFill);
- HOOK(SubsequentScanlineCPUToScreenColorExpandFill);
- HOOK(SubsequentColorExpandScanline);
- localRecPtr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK |
- BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD;
+ /* Color expansion */
+ localRecPtr->ScanlineColorExpandBuffers =
+ pGeode->AccelColorExpandBuffers;
+ localRecPtr->NumScanlineColorExpandBuffers =
+ pGeode->NoOfColorExpandLines;
+ HOOK(SetupForScanlineCPUToScreenColorExpandFill);
+ HOOK(SubsequentScanlineCPUToScreenColorExpandFill);
+ HOOK(SubsequentColorExpandScanline);
+ localRecPtr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK |
+ BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD;
#endif
}
#if GX_WRITE_PIXMAP_SUPPORT
diff --git a/src/gx_cursor.c b/src/gx_cursor.c
index bec7fde..9221dfa 100644
--- a/src/gx_cursor.c
+++ b/src/gx_cursor.c
@@ -24,9 +24,9 @@
* */
/*
- * File Contents: Xfree cursor implementation routines for geode HWcursor
+ * File Contents: Xfree cursor implementation routines for geode HWcursor
* init.setting cursor color,image etc. are done here.
- *
+ *
* Project: Geode Xfree Frame buffer device driver.
* */
@@ -72,15 +72,15 @@ GXHWCursorInit(ScreenPtr pScrn)
infoPtr = xf86CreateCursorInfoRec();
if (!infoPtr)
- return FALSE;
+ return FALSE;
/* the geode structure is intiallized with the cursor infoRec */
pGeode->CursorInfo = infoPtr;
infoPtr->MaxWidth = 32;
infoPtr->MaxHeight = 32;
/* seeting up the cursor flags */
infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
- HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
- HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
+ HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
/* cursor info ptr is intiallized with the values obtained from
* * durnago calls
*/
@@ -102,7 +102,7 @@ GXHWCursorInit(ScreenPtr pScrn)
* pScrn: Screeen pointer structure.
* bg: Specifies the color value of cursor background color.
* fg: Specifies the color value of cursor foreground color.
- *
+ *
* Returns: none.
*
* Comments: The integer color value passed by this function is
@@ -125,7 +125,7 @@ GXSetCursorColors(ScrnInfoPtr pScrni, int bg, int fg)
* pScrn: Screeen pointer structure.
* x: Specifies the x-cordinates of the cursor.
* y: Specifies the y co-ordinate of the cursor.
- *
+ *
* Returns: none.
*
*----------------------------------------------------------------------------
@@ -143,27 +143,29 @@ GXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y)
savex = x + pScrni->frameX0;
savey = y + pScrni->frameY0;
- switch(pGeode->rotation) {
+ switch (pGeode->rotation) {
default:
- ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__, pGeode->rotation);
+ ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__,
+ pGeode->rotation);
case RR_Rotate_0:
- newX = savex; newY = savey;
- break;
-
+ newX = savex;
+ newY = savey;
+ break;
+
case RR_Rotate_90:
- newX = savey;
- newY = pScrni->pScreen->width - savex;
- break;
-
+ newX = savey;
+ newY = pScrni->pScreen->width - savex;
+ break;
+
case RR_Rotate_180:
- newX = pScrni->pScreen->width - savex;
- newY = pScrni->pScreen->height - savey;
- break;
-
+ newX = pScrni->pScreen->width - savex;
+ newY = pScrni->pScreen->height - savey;
+ break;
+
case RR_Rotate_270:
- newX = pScrni->pScreen->height - savey;
- newY = savex;
- break;
+ newX = pScrni->pScreen->height - savey;
+ newY = savex;
+ break;
}
newX += pScrni->frameX0;
@@ -172,25 +174,25 @@ GXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y)
//ErrorF("Turned (%d,%d) into (%d,%d)\n", x,y,newX, newY);
if (newX < -31)
- newX = -31;
+ newX = -31;
if (newY < -31)
- newY = -31;
+ newY = -31;
gfx_set_cursor_position(pGeode->CursorStartOffset, newX + 31, newY + 31,
- 31, 31);
+ 31, 31);
gfx_set_cursor_enable(1);
if ((pGeode->OverlayON) && (pGeode->Panel)) {
- pGeode->PrevDisplayOffset = gfx_get_display_offset();
- if (pGeode->PrevDisplayOffset != panOffset) {
- GXSetVideoPosition(pGeode->video_x, pGeode->video_y,
- pGeode->video_w, pGeode->video_h,
- pGeode->video_srcw, pGeode->video_srch,
- pGeode->video_dstw, pGeode->video_dsth,
- pGeode->video_id, pGeode->video_offset,
- pGeode->video_scrnptr);
- panOffset = pGeode->PrevDisplayOffset;
- }
+ pGeode->PrevDisplayOffset = gfx_get_display_offset();
+ if (pGeode->PrevDisplayOffset != panOffset) {
+ GXSetVideoPosition(pGeode->video_x, pGeode->video_y,
+ pGeode->video_w, pGeode->video_h,
+ pGeode->video_srcw, pGeode->video_srch,
+ pGeode->video_dstw, pGeode->video_dsth,
+ pGeode->video_id, pGeode->video_offset,
+ pGeode->video_scrnptr);
+ panOffset = pGeode->PrevDisplayOffset;
+ }
}
}
@@ -203,7 +205,7 @@ GXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y)
* Parameters:
* pScrn: Screeen pointer structure.
* src: Specifies cursor data.
- *
+ *
* Returns: none
*
*----------------------------------------------------------------------------
@@ -219,55 +221,55 @@ GXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src)
unsigned char *mskp = &src[128];
if (src != NULL) {
- mskb = rowb = 0;
- for (y = 32; --y >= 0;)
- andMask[y] = xorMask[y] = 0;
- for (y = 0; y < 32; ++y) {
- for (x = 0; x < 32; ++x) {
- if ((i = x & 7) == 0) {
- rowb = (*rowp & *mskp);
- mskb = ~(*mskp);
- ++rowp;
- ++mskp;
- }
+ mskb = rowb = 0;
+ for (y = 32; --y >= 0;)
+ andMask[y] = xorMask[y] = 0;
+ for (y = 0; y < 32; ++y) {
+ for (x = 0; x < 32; ++x) {
+ if ((i = x & 7) == 0) {
+ rowb = (*rowp & *mskp);
+ mskb = ~(*mskp);
+ ++rowp;
+ ++mskp;
+ }
- switch(pGeode->rotation) {
+ switch (pGeode->rotation) {
default:
- ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__,
- pGeode->rotation);
+ ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__,
+ pGeode->rotation);
case RR_Rotate_0:
- newX = x;
- newY = y;
- break;
+ newX = x;
+ newY = y;
+ break;
case RR_Rotate_90:
- newX = y;
- newY = 31 - x;
- break;
+ newX = y;
+ newY = 31 - x;
+ break;
case RR_Rotate_180:
- newX = 31 - x;
- newY = 31 - y;
- break;
+ newX = 31 - x;
+ newY = 31 - y;
+ break;
case RR_Rotate_270:
- newX = 31 - y;
- newY = x;
- break;
+ newX = 31 - y;
+ newY = x;
+ break;
}
- i = 7 - i;
- n = 31 - newX;
- andMask[newY] |= (((mskb >> i) & 1) << n);
- xorMask[newY] |= (((rowb >> i) & 1) << n);
- }
- }
+ i = 7 - i;
+ n = 31 - newX;
+ andMask[newY] |= (((mskb >> i) & 1) << n);
+ xorMask[newY] |= (((rowb >> i) & 1) << n);
+ }
+ }
} else {
- for (y = 32; --y >= 0;) {
- andMask[y] = ~0;
- xorMask[y] = 0;
- }
+ for (y = 32; --y >= 0;) {
+ andMask[y] = ~0;
+ xorMask[y] = 0;
+ }
}
gfx_set_cursor_shape32(pGeode->CursorStartOffset, &andMask[0],
- &xorMask[0]);
+ &xorMask[0]);
}
/*----------------------------------------------------------------------------
diff --git a/src/gx_driver.c b/src/gx_driver.c
index 1a8eff4..8f0106d 100644
--- a/src/gx_driver.c
+++ b/src/gx_driver.c
@@ -83,309 +83,303 @@ unsigned char *XpressROMPtr;
static inline void
gx_enable_dac_power(void)
{
- gfx_write_vid32(RCDF_VID_MISC,
- gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH);
+ gfx_write_vid32(RCDF_VID_MISC,
+ gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH);
}
static inline void
gx_disable_dac_power(void)
{
- gfx_write_vid32(RCDF_VID_MISC,
- RCDF_DAC_POWER_DOWN | RCDF_ANALOG_POWER_DOWN |
- (gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH));
+ gfx_write_vid32(RCDF_VID_MISC,
+ RCDF_DAC_POWER_DOWN | RCDF_ANALOG_POWER_DOWN |
+ (gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH));
}
-
-
-
static void
GXInitEXAMemory(ScrnInfoPtr pScrni, unsigned int *offset, unsigned int *avail)
{
- GeodePtr pGeode = GEODEPTR(pScrni);
+ GeodePtr pGeode = GEODEPTR(pScrni);
- if (pGeode->exaBfrSz > 0 && pGeode->exaBfrSz <= *avail) {
- pGeode->exaBfrOffset = *offset;
- *offset += pGeode->exaBfrOffset;
- *avail -= pGeode->exaBfrOffset;
- }
+ if (pGeode->exaBfrSz > 0 && pGeode->exaBfrSz <= *avail) {
+ pGeode->exaBfrOffset = *offset;
+ *offset += pGeode->exaBfrOffset;
+ *avail -= pGeode->exaBfrOffset;
+ }
}
static void
GXInitXAAMemory(ScrnInfoPtr pScrni, unsigned int *offset, unsigned int *avail)
{
- GeodePtr pGeode = GEODEPTR(pScrni);
- unsigned int size, i, pitch;
-
- /* XXX - FIXME - What if we are out of room? Then what? */
- /* For now, we NULL them all out. */
-
- if (pGeode->NoOfImgBuffers > 0) {
- size = pGeode->displayPitch * pGeode->NoOfImgBuffers;
- if (size <= *avail) {
- for (i = 0; i < pGeode->NoOfImgBuffers; i++) {
- pGeode->AccelImageWriteBuffers[i] = pGeode->FBBase + *offset;
- *offset += pGeode->displayPitch;
- *avail -= pGeode->displayPitch;
- }
- } else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for image write buffers.\n");
+ GeodePtr pGeode = GEODEPTR(pScrni);
+ unsigned int size, i, pitch;
+
+ /* XXX - FIXME - What if we are out of room? Then what? */
+ /* For now, we NULL them all out. */
+
+ if (pGeode->NoOfImgBuffers > 0) {
+ size = pGeode->displayPitch * pGeode->NoOfImgBuffers;
+ if (size <= *avail) {
+ for (i = 0; i < pGeode->NoOfImgBuffers; i++) {
+ pGeode->AccelImageWriteBuffers[i] = pGeode->FBBase + *offset;
+ *offset += pGeode->displayPitch;
+ *avail -= pGeode->displayPitch;
+ }
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for image write buffers.\n");
- for (i = 0; i < pGeode->NoOfImgBuffers; i++)
- pGeode->AccelImageWriteBuffers[i] = NULL;
+ for (i = 0; i < pGeode->NoOfImgBuffers; i++)
+ pGeode->AccelImageWriteBuffers[i] = NULL;
+ }
}
- }
-
- if (pGeode->NoOfColorExpandLines > 0) {
- pitch = ((pGeode->displayPitch + 31) >> 5) << 2;
- size = pitch * pGeode->NoOfColorExpandLines;
-
- if (size <= *avail) {
- for (i = 0; i < pGeode->NoOfColorExpandLines; i++) {
- pGeode->AccelColorExpandBuffers[i] = pGeode->FBBase + *offset;
- *offset += pitch;
- *avail -= pitch;
- }
- } else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for color expansion buffers.\n");
- for (i = 0; i < pGeode->NoOfImgBuffers; i++)
- pGeode->AccelColorExpandBuffers[i] = NULL;
+ if (pGeode->NoOfColorExpandLines > 0) {
+ pitch = ((pGeode->displayPitch + 31) >> 5) << 2;
+ size = pitch * pGeode->NoOfColorExpandLines;
+
+ if (size <= *avail) {
+ for (i = 0; i < pGeode->NoOfColorExpandLines; i++) {
+ pGeode->AccelColorExpandBuffers[i] = pGeode->FBBase + *offset;
+ *offset += pitch;
+ *avail -= pitch;
+ }
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for color expansion buffers.\n");
+
+ for (i = 0; i < pGeode->NoOfImgBuffers; i++)
+ pGeode->AccelColorExpandBuffers[i] = NULL;
+ }
}
- }
}
static Bool
GXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate)
{
- GeodePtr pGeode = GEODEPTR(pScrni);
+ GeodePtr pGeode = GEODEPTR(pScrni);
- unsigned int fboffset, fbavail;
- unsigned int size;
- unsigned int bytpp = (pScrni->bitsPerPixel + 7) / 8;
- BOOL ret = TRUE;
+ unsigned int fboffset, fbavail;
+ unsigned int size;
+ unsigned int bytpp = (pScrni->bitsPerPixel + 7) / 8;
+ BOOL ret = TRUE;
- if (pGeode->tryCompression)
- pGeode->displayPitch =
- GeodeCalculatePitchBytes(pScrni->virtualX, pScrni->bitsPerPixel);
- else
- pGeode->displayPitch =
- ((pScrni->virtualX + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
+ if (pGeode->tryCompression)
+ pGeode->displayPitch =
+ GeodeCalculatePitchBytes(pScrni->virtualX, pScrni->bitsPerPixel);
+ else
+ pGeode->displayPitch =
+ ((pScrni->virtualX + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
- pGeode->Pitch = pGeode->displayPitch;
- pGeode->displayWidth = pGeode->displayPitch / bytpp;
- pScrni->displayWidth = pGeode->displayWidth;
+ pGeode->Pitch = pGeode->displayPitch;
+ pGeode->displayWidth = pGeode->displayPitch / bytpp;
+ pScrni->displayWidth = pGeode->displayWidth;
- fbavail = pGeode->FBAvail - 0x4000;
+ fbavail = pGeode->FBAvail - 0x4000;
- pGeode->displayOffset = fboffset = 0;
- pGeode->displaySize = pScrni->virtualY * pGeode->displayPitch;
+ pGeode->displayOffset = fboffset = 0;
+ pGeode->displaySize = pScrni->virtualY * pGeode->displayPitch;
- fbavail -= pGeode->displaySize;
- fboffset += pGeode->displaySize;
+ fbavail -= pGeode->displaySize;
+ fboffset += pGeode->displaySize;
- if (pGeode->tryCompression) {
- size = pScrni->virtualY * GX_CB_PITCH;
+ if (pGeode->tryCompression) {
+ size = pScrni->virtualY * GX_CB_PITCH;
- if (size <= fbavail) {
- pGeode->CBData.compression_offset = fboffset;
+ if (size <= fbavail) {
+ pGeode->CBData.compression_offset = fboffset;
- fboffset += size;
- fbavail -= size;
+ fboffset += size;
+ fbavail -= size;
- pGeode->Compression = TRUE;
- } else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for compression\n");
- pGeode->Compression = FALSE;
+ pGeode->Compression = TRUE;
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for compression\n");
+ pGeode->Compression = FALSE;
+ }
}
- }
- if (pGeode->tryHWCursor) {
- pGeode->CursorSize = 1024;
+ if (pGeode->tryHWCursor) {
+ pGeode->CursorSize = 1024;
- if (pGeode->CursorSize <= fbavail) {
- pGeode->CursorStartOffset = fboffset;
- fboffset += pGeode->CursorSize;
- fbavail -= pGeode->CursorSize;
- pGeode->HWCursor = TRUE;
- } else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for the hardware cursor\n");
- pGeode->HWCursor = FALSE;
+ if (pGeode->CursorSize <= fbavail) {
+ pGeode->CursorStartOffset = fboffset;
+ fboffset += pGeode->CursorSize;
+ fbavail -= pGeode->CursorSize;
+ pGeode->HWCursor = TRUE;
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for the hardware cursor\n");
+ pGeode->HWCursor = FALSE;
+ }
}
- }
- if (!pGeode->NoAccel) {
- if (pGeode->useEXA)
- GXInitEXAMemory(pScrni, &fboffset, &fbavail);
- else
- GXInitXAAMemory(pScrni, &fboffset, &fbavail);
- }
+ if (!pGeode->NoAccel) {
+ if (pGeode->useEXA)
+ GXInitEXAMemory(pScrni, &fboffset, &fbavail);
+ else
+ GXInitXAAMemory(pScrni, &fboffset, &fbavail);
+ }
- pGeode->shadowSize = 0;
+ pGeode->shadowSize = 0;
- if (rotate != RR_Rotate_0) {
- if (rotate & (RR_Rotate_90 | RR_Rotate_270))
- size = pGeode->displayPitch * pScrni->virtualX;
- else
- size = pGeode->displayPitch * pScrni->virtualY;
+ if (rotate != RR_Rotate_0) {
+ if (rotate & (RR_Rotate_90 | RR_Rotate_270))
+ size = pGeode->displayPitch * pScrni->virtualX;
+ else
+ size = pGeode->displayPitch * pScrni->virtualY;
- if (size <= fbavail) {
- pGeode->shadowOffset = fboffset;
- pGeode->shadowSize = size;
+ if (size <= fbavail) {
+ pGeode->shadowOffset = fboffset;
+ pGeode->shadowSize = size;
- fboffset += size;
- fbavail -= size;
- } else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for the shadow framebuffer\n");
- ret = FALSE;
+ fboffset += size;
+ fbavail -= size;
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for the shadow framebuffer\n");
+ ret = FALSE;
+ }
}
- }
- /* XAA always exists - we can't remove it on demand like we can with EXA.
- So we assume the worse, and only give XAA enough offspace room to
- account for any eventuality that RandR might throw at us. */
+ /* XAA always exists - we can't remove it on demand like we can with EXA.
+ * So we assume the worse, and only give XAA enough offspace room to
+ * account for any eventuality that RandR might throw at us. */
- if (!pGeode->NoAccel) {
+ if (!pGeode->NoAccel) {
- if (pGeode->useEXA && pGeode->pExa) {
- ExaDriverPtr pExa = pGeode->pExa;
+ if (pGeode->useEXA && pGeode->pExa) {
+ ExaDriverPtr pExa = pGeode->pExa;
- pExa->offScreenBase = fboffset;
- pExa->memorySize = fboffset + fbavail;
- }
+ pExa->offScreenBase = fboffset;
+ pExa->memorySize = fboffset + fbavail;
+ }
- if (!pGeode->useEXA) {
+ if (!pGeode->useEXA) {
- if (!xf86FBManagerRunning(pScrn)) {
+ if (!xf86FBManagerRunning(pScrn)) {
- unsigned int offset = fboffset;
- unsigned int avail = fbavail;
- RegionRec OffscreenRegion;
- BoxRec AvailBox;
+ unsigned int offset = fboffset;
+ unsigned int avail = fbavail;
+ RegionRec OffscreenRegion;
+ BoxRec AvailBox;
- /* Assume the shadow FB exists even if it doesnt */
+ /* Assume the shadow FB exists even if it doesnt */
- if (pGeode->shadowSize == 0) {
- size = (pScrn->width * bytpp) * pScrni->virtualX;
- offset += size;
- avail -= size;
- }
+ if (pGeode->shadowSize == 0) {
+ size = (pScrn->width * bytpp) * pScrni->virtualX;
+ offset += size;
+ avail -= size;
+ }
- AvailBox.x1 = 0;
- AvailBox.y1 =
- (offset + pGeode->displayPitch -
- 1) / pGeode->displayPitch;
+ AvailBox.x1 = 0;
+ AvailBox.y1 =
+ (offset + pGeode->displayPitch -
+ 1) / pGeode->displayPitch;
- AvailBox.x2 = pGeode->displayWidth;
- AvailBox.y2 = (offset + avail) / pGeode->displayPitch;
+ AvailBox.x2 = pGeode->displayWidth;
+ AvailBox.y2 = (offset + avail) / pGeode->displayPitch;
- if (AvailBox.y1 < AvailBox.y2) {
- REGION_INIT(pScrn, &OffscreenRegion, &AvailBox, 2);
+ if (AvailBox.y1 < AvailBox.y2) {
+ REGION_INIT(pScrn, &OffscreenRegion, &AvailBox, 2);
- if (!xf86InitFBManagerRegion(pScrn, &OffscreenRegion))
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Memory manager initialization failed.\n");
+ if (!xf86InitFBManagerRegion(pScrn, &OffscreenRegion))
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Memory manager initialization failed.\n");
- REGION_UNINIT(pScrn, &OffscreenRegion);
- } else
- xf86DrvMsg(pScrni->scrnIndex, X_INFO,
- "Cache disabled - no offscreen memory available.\n");
- } else
- xf86DrvMsg(pScrni->scrnIndex, X_INFO,
+ REGION_UNINIT(pScrn, &OffscreenRegion);
+ } else
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO,
+ "Cache disabled - no offscreen memory available.\n");
+ } else
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO,
"XAA offscreen memory has already been allocated.\n");
+ }
}
- }
- return ret;
+ return ret;
}
static Bool
GXSaveScreen(ScreenPtr pScrn, int mode)
{
- ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
- GeodePtr pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
+ GeodePtr pGeode = GEODEPTR(pScrni);
- if (pGeode->useVGA && !pScrni->vtSema)
- return vgaHWSaveScreen(pScrn, mode);
+ if (pGeode->useVGA && !pScrni->vtSema)
+ return vgaHWSaveScreen(pScrn, mode);
- return TRUE;
+ return TRUE;
}
-
-
/* Common function - used by the LX too */
#ifdef XSERVER_LIBPCIACCESS
-static inline void * map_pci_mem(ScrnInfoPtr pScrni, int vram,
- struct pci_device *dev,
- int bar, int size)
+static inline void *
+map_pci_mem(ScrnInfoPtr pScrni, int vram,
+ struct pci_device *dev, int bar, int size)
{
- void *ptr;
- void** result = (void**)&ptr;
- int map_size = size ? size : dev->regions[bar].size;
-
- int err = pci_device_map_range(dev,
- dev->regions[bar].base_addr,
- map_size,
- PCI_DEV_MAP_FLAG_WRITABLE |
- (vram ? PCI_DEV_MAP_FLAG_WRITE_COMBINE : 0),
- result);
-
- if (err)
- return NULL;
- return ptr;
+ void *ptr;
+ void **result = (void **)&ptr;
+ int map_size = size ? size : dev->regions[bar].size;
+
+ int err = pci_device_map_range(dev,
+ dev->regions[bar].base_addr,
+ map_size,
+ PCI_DEV_MAP_FLAG_WRITABLE |
+ (vram ? PCI_DEV_MAP_FLAG_WRITE_COMBINE : 0),
+ result);
+
+ if (err)
+ return NULL;
+ return ptr;
}
#endif
-
extern unsigned long gfx_gx2_scratch_base;
static Bool
GXMapMem(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int index = pScrni->scrnIndex;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int index = pScrni->scrnIndex;
- pciVideoPtr pci = xf86GetPciInfoForEntity(pGeode->pEnt->index);
+ pciVideoPtr pci = xf86GetPciInfoForEntity(pGeode->pEnt->index);
#ifndef XSERVER_LIBPCIACCESS
- gfx_virt_regptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
- pci->memBase[2], pci->size[2]);
+ gfx_virt_regptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
+ pci->memBase[2], pci->size[2]);
- gfx_virt_gpptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
- pci->memBase[1], pci->size[1]);
+ gfx_virt_gpptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
+ pci->memBase[1], pci->size[1]);
- gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
- pci->memBase[3], pci->size[3]);
+ gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
+ pci->memBase[3], pci->size[3]);
- gfx_virt_fbptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_FRAMEBUFFER,
- pci->memBase[0], pGeode->FBAvail);
+ gfx_virt_fbptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_FRAMEBUFFER,
+ pci->memBase[0], pGeode->FBAvail);
#else
- gfx_virt_regptr = map_pci_mem(pScrni, 0, pci, 2, 0);
- gfx_virt_gpptr = map_pci_mem(pScrni, 0, pci, 1, 0);
- gfx_virt_vidptr = map_pci_mem(pScrni, 0, pci, 3, 0);
- gfx_virt_fbptr = map_pci_mem(pScrni, 1, pci, 0, pGeode->FBAvail);
+ gfx_virt_regptr = map_pci_mem(pScrni, 0, pci, 2, 0);
+ gfx_virt_gpptr = map_pci_mem(pScrni, 0, pci, 1, 0);
+ gfx_virt_vidptr = map_pci_mem(pScrni, 0, pci, 3, 0);
+ gfx_virt_fbptr = map_pci_mem(pScrni, 1, pci, 0, pGeode->FBAvail);
#endif
- gfx_gx2_scratch_base = pGeode->FBAvail - 0x4000;
+ gfx_gx2_scratch_base = pGeode->FBAvail - 0x4000;
- XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
+ XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
- pGeode->FBBase = gfx_virt_fbptr;
+ pGeode->FBBase = gfx_virt_fbptr;
- if ((!gfx_virt_regptr) || (!gfx_virt_gpptr) ||
- (!gfx_virt_vidptr) || (!gfx_virt_fbptr))
- return FALSE;
+ if ((!gfx_virt_regptr) || (!gfx_virt_gpptr) ||
+ (!gfx_virt_vidptr) || (!gfx_virt_fbptr))
+ return FALSE;
- if (!pGeode->NoAccel && pGeode->useEXA)
- pGeode->pExa->memoryBase = pGeode->FBBase;
+ if (!pGeode->NoAccel && pGeode->useEXA)
+ pGeode->pExa->memoryBase = pGeode->FBBase;
- xf86DrvMsg(index, X_INFO, "Found Geode %x %p\n",
- pGeode->FBAvail, pGeode->FBBase);
+ xf86DrvMsg(index, X_INFO, "Found Geode %x %p\n",
+ pGeode->FBAvail, pGeode->FBBase);
- return TRUE;
+ return TRUE;
}
/* Check to see if VGA exists - we map the space and look for a
@@ -393,397 +387,402 @@ GXMapMem(ScrnInfoPtr pScrni)
*/
static Bool
-GXCheckVGA(ScrnInfoPtr pScrni) {
+GXCheckVGA(ScrnInfoPtr pScrni)
+{
- unsigned char *ptr;
- const char *vgasig = "IBM VGA Compatible";
- int ret;
+ unsigned char *ptr;
+ const char *vgasig = "IBM VGA Compatible";
+ int ret;
- ptr = xf86MapVidMem(pScrni->scrnIndex, VIDMEM_FRAMEBUFFER, 0xC001E, strlen(vgasig));
+ ptr =
+ xf86MapVidMem(pScrni->scrnIndex, VIDMEM_FRAMEBUFFER, 0xC001E,
+ strlen(vgasig));
- if (ptr == NULL)
- return FALSE;
+ if (ptr == NULL)
+ return FALSE;
- ret = memcmp(ptr, vgasig, strlen(vgasig));
- xf86UnMapVidMem(pScrni->scrnIndex, (pointer) ptr, strlen(vgasig));
+ ret = memcmp(ptr, vgasig, strlen(vgasig));
+ xf86UnMapVidMem(pScrni->scrnIndex, (pointer) ptr, strlen(vgasig));
- return ret ? FALSE : TRUE;
+ return ret ? FALSE : TRUE;
}
static Bool
GXPreInit(ScrnInfoPtr pScrni, int flags)
{
- GeodePtr pGeode;
- ClockRangePtr GeodeClockRange;
- OptionInfoRec *GeodeOptions = &GX_GeodeOptions[0];
- int ret;
- QQ_WORD msrValue;
- EntityInfoPtr pEnt;
- rgb defaultWeight = { 0, 0, 0 };
- int modecnt;
- char *s, *panelgeo;
- Bool useVGA;
-
- if (pScrni->numEntities != 1)
+ GeodePtr pGeode;
+ ClockRangePtr GeodeClockRange;
+ OptionInfoRec *GeodeOptions = &GX_GeodeOptions[0];
+ int ret;
+ QQ_WORD msrValue;
+ EntityInfoPtr pEnt;
+ rgb defaultWeight = { 0, 0, 0 };
+ int modecnt;
+ char *s, *panelgeo;
+ Bool useVGA;
+
+ if (pScrni->numEntities != 1)
return FALSE;
- pEnt = xf86GetEntityInfo(pScrni->entityList[0]);
- if (pEnt->resources)
+ pEnt = xf86GetEntityInfo(pScrni->entityList[0]);
+ if (pEnt->resources)
return FALSE;
- pGeode = pScrni->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1);
+ pGeode = pScrni->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1);
- if (pGeode == NULL)
- return FALSE;
+ if (pGeode == NULL)
+ return FALSE;
- useVGA = GXCheckVGA(pScrni);
+ useVGA = GXCheckVGA(pScrni);
- if (flags & PROBE_DETECT) {
+ if (flags & PROBE_DETECT) {
if (useVGA)
- GeodeProbeDDC(pScrni, pEnt->index);
+ GeodeProbeDDC(pScrni, pEnt->index);
return TRUE;
- }
+ }
- /* Probe for VGA */
- pGeode->useVGA = useVGA;
- pGeode->pEnt = pEnt;
+ /* Probe for VGA */
+ pGeode->useVGA = useVGA;
+ pGeode->pEnt = pEnt;
- if (pGeode->useVGA) {
- if (!xf86LoadSubModule(pScrni, "vgahw") || !vgaHWGetHWRec(pScrni))
- pGeode->useVGA = FALSE;
+ if (pGeode->useVGA) {
+ if (!xf86LoadSubModule(pScrni, "vgahw") || !vgaHWGetHWRec(pScrni))
+ pGeode->useVGA = FALSE;
#if INT10_SUPPORT
pGeode->vesa = xcalloc(sizeof(VESARec), 1);
#endif
- }
-
- gfx_msr_init();
+ }
- ret = gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue);
+ gfx_msr_init();
- if (!ret) {
- pGeode->Output =
- ((msrValue.low & RCDF_CONFIG_FMT_MASK) ==
- RCDF_CONFIG_FMT_FP) ? OUTPUT_PANEL : OUTPUT_CRT;
- }
+ ret = gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue);
- /* Fill in the monitor information */
- pScrni->monitor = pScrni->confScreen->monitor;
+ if (!ret) {
+ pGeode->Output =
+ ((msrValue.low & RCDF_CONFIG_FMT_MASK) ==
+ RCDF_CONFIG_FMT_FP) ? OUTPUT_PANEL : OUTPUT_CRT;
+ }
- if (!xf86SetDepthBpp(pScrni, 16, 16, 16, Support24bppFb | Support32bppFb))
- return FALSE;
+ /* Fill in the monitor information */
+ pScrni->monitor = pScrni->confScreen->monitor;
- switch (pScrni->depth) {
- case 8:
- pScrni->rgbBits = 8;
- case 16:
- case 24:
- case 32:
- break;
- default:
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "The driver does not support %d as a depth.\n", pScrni->depth);
- return FALSE;
- }
+ if (!xf86SetDepthBpp(pScrni, 16, 16, 16, Support24bppFb | Support32bppFb))
+ return FALSE;
- xf86PrintDepthBpp(pScrni);
+ switch (pScrni->depth) {
+ case 8:
+ pScrni->rgbBits = 8;
+ case 16:
+ case 24:
+ case 32:
+ break;
+ default:
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "The driver does not support %d as a depth.\n", pScrni->depth);
+ return FALSE;
+ }
- if (!xf86SetWeight(pScrni, defaultWeight, defaultWeight))
- return FALSE;
+ xf86PrintDepthBpp(pScrni);
- if (!xf86SetDefaultVisual(pScrni, -1))
- return FALSE;
+ if (!xf86SetWeight(pScrni, defaultWeight, defaultWeight))
+ return FALSE;
- /*
- * If the driver can do gamma correction, it should call xf86SetGamma()
- * here.
- */
- {
- Gamma zeros = { 0.0, 0.0, 0.0 };
+ if (!xf86SetDefaultVisual(pScrni, -1))
+ return FALSE;
- if (!xf86SetGamma(pScrni, zeros)) {
- return FALSE;
- }
- }
+ /*
+ * If the driver can do gamma correction, it should call xf86SetGamma()
+ * here.
+ */
+ {
+ Gamma zeros = { 0.0, 0.0, 0.0 };
- pScrni->progClock = TRUE;
- xf86CollectOptions(pScrni, NULL);
- xf86ProcessOptions(pScrni->scrnIndex, pScrni->options, GeodeOptions);
+ if (!xf86SetGamma(pScrni, zeros)) {
+ return FALSE;
+ }
+ }
- /* Set up our various options that may get reversed as we go on */
+ pScrni->progClock = TRUE;
+ xf86CollectOptions(pScrni, NULL);
+ xf86ProcessOptions(pScrni->scrnIndex, pScrni->options, GeodeOptions);
- pGeode->FBVGAActive = FALSE;
- pGeode->tryHWCursor = TRUE;
- pGeode->tryCompression = TRUE;
+ /* Set up our various options that may get reversed as we go on */
- pGeode->NoAccel = FALSE;
- pGeode->useEXA = TRUE;
+ pGeode->FBVGAActive = FALSE;
+ pGeode->tryHWCursor = TRUE;
+ pGeode->tryCompression = TRUE;
- pGeode->Panel = (pGeode->Output & OUTPUT_PANEL) ? TRUE : FALSE;
+ pGeode->NoAccel = FALSE;
+ pGeode->useEXA = TRUE;
- pGeode->NoOfImgBuffers = DEFAULT_IMG_LINE_BUFS;
- pGeode->NoOfColorExpandLines = DEFAULT_CLR_LINE_BUFS;
- pGeode->exaBfrSz = DEFAULT_EXA_SCRATCH_BFRSZ;
+ pGeode->Panel = (pGeode->Output & OUTPUT_PANEL) ? TRUE : FALSE;
- xf86GetOptValBool(GeodeOptions, GX_OPTION_HW_CURSOR,
- &pGeode->tryHWCursor);
+ pGeode->NoOfImgBuffers = DEFAULT_IMG_LINE_BUFS;
+ pGeode->NoOfColorExpandLines = DEFAULT_CLR_LINE_BUFS;
+ pGeode->exaBfrSz = DEFAULT_EXA_SCRATCH_BFRSZ;
- if (!xf86GetOptValInteger(GeodeOptions, GX_OPTION_FBSIZE,
- (int *)&(pGeode->FBAvail)))
- pGeode->FBAvail = 0;
+ xf86GetOptValBool(GeodeOptions, GX_OPTION_HW_CURSOR,
+ &pGeode->tryHWCursor);
- /* For compatability - allow SWCursor too */
+ if (!xf86GetOptValInteger(GeodeOptions, GX_OPTION_FBSIZE,
+ (int *)&(pGeode->FBAvail)))
+ pGeode->FBAvail = 0;
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_SW_CURSOR, FALSE))
- pGeode->tryHWCursor = FALSE;
+ /* For compatability - allow SWCursor too */
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOCOMPRESSION, FALSE))
- pGeode->tryCompression = FALSE;
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_SW_CURSOR, FALSE))
+ pGeode->tryHWCursor = FALSE;
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOACCEL, FALSE))
- pGeode->NoAccel = TRUE;
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOCOMPRESSION, FALSE))
+ pGeode->tryCompression = FALSE;
- pGeode->rotation = RR_Rotate_0;
-
- if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ROTATE))) {
-
- if (!xf86NameCmp(s, "LEFT"))
- pGeode->rotation = RR_Rotate_90;
- else if (!xf86NameCmp(s, "INVERT"))
- pGeode->rotation = RR_Rotate_180;
- else if (!xf86NameCmp(s, "CCW"))
- pGeode->rotation = RR_Rotate_270;
- else
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Invalid rotation %s.\n", s);
- }
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOACCEL, FALSE))
+ pGeode->NoAccel = TRUE;
+>>>>>>> patched
- xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_IMG_BUFS,
- &(pGeode->NoOfImgBuffers));
+ pGeode->rotation = RR_Rotate_0;
- if (pGeode->NoOfImgBuffers <= 0)
- pGeode->NoOfImgBuffers = 0;
+ if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ROTATE))) {
- xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS,
- &(pGeode->NoOfColorExpandLines));
+ if (!xf86NameCmp(s, "LEFT"))
+ pGeode->rotation = RR_Rotate_90;
+ else if (!xf86NameCmp(s, "INVERT"))
+ pGeode->rotation = RR_Rotate_180;
+ else if (!xf86NameCmp(s, "CCW"))
+ pGeode->rotation = RR_Rotate_270;
+ else
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Invalid rotation %s.\n", s);
+ }
- if (pGeode->NoOfColorExpandLines <= 0)
- pGeode->NoOfColorExpandLines = 0;
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_IMG_BUFS,
+ &(pGeode->NoOfImgBuffers));
- xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS,
- (int *)&(pGeode->exaBfrSz));
+ if (pGeode->NoOfImgBuffers <= 0)
+ pGeode->NoOfImgBuffers = 0;
- if (pGeode->exaBfrSz <= 0)
- pGeode->exaBfrSz = 0;
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS,
+ &(pGeode->NoOfColorExpandLines));
- if (pGeode->Panel == TRUE) {
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOPANEL, FALSE))
- pGeode->Panel = FALSE;
- }
+ if (pGeode->NoOfColorExpandLines <= 0)
+ pGeode->NoOfColorExpandLines = 0;
- panelgeo = xf86GetOptValString(GeodeOptions, GX_OPTION_PANEL_GEOMETRY);
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS,
+ (int *)&(pGeode->exaBfrSz));
- if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ACCEL_METHOD))) {
- if (!xf86NameCmp(s, "XAA"))
- pGeode->useEXA = FALSE;
- else if (xf86NameCmp(s, "EXA"))
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Unknown accleration method %s. Defaulting to EXA.\n", s);
- }
+ if (pGeode->exaBfrSz <= 0)
+ pGeode->exaBfrSz = 0;
- xf86DrvMsg(pScrni->scrnIndex, X_INFO,
- "Using %s acceleration architecture\n",
- pGeode->useEXA ? "EXA" : "XAA");
+ if (pGeode->Panel == TRUE) {
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOPANEL, FALSE))
+ pGeode->Panel = FALSE;
+ }
- /* Set up the panel */
+ panelgeo = xf86GetOptValString(GeodeOptions, GX_OPTION_PANEL_GEOMETRY);
- if (pGeode->Panel) {
- if (panelgeo != NULL) {
- if (GeodeGetFPGeometry(panelgeo, &pGeode->PanelX, &pGeode->PanelY))
- pGeode->Panel = FALSE;
+ if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ACCEL_METHOD))) {
+ if (!xf86NameCmp(s, "XAA"))
+ pGeode->useEXA = FALSE;
+ else if (xf86NameCmp(s, "EXA"))
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Unknown accleration method %s. Defaulting to EXA.\n", s);
}
+
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO,
+ "Using %s acceleration architecture\n",
+ pGeode->useEXA ? "EXA" : "XAA");
+
+ /* Set up the panel */
+
+ if (pGeode->Panel) {
+ if (panelgeo != NULL) {
+ if (GeodeGetFPGeometry(panelgeo, &pGeode->PanelX,
+ &pGeode->PanelY))
+ pGeode->Panel = FALSE;
+ }
#ifdef PNL_SUP
- else {
- int b, f;
+ else {
+ int b, f;
- /* The bitdepth and refresh isn't used anywhere else in the driver */
+ /* The bitdepth and refresh isn't used anywhere else in the driver */
- if ((pGeode->Panel = Pnl_IsPanelEnabledInBIOS()))
- Pnl_GetPanelInfoFromBIOS(&pGeode->PanelX, &pGeode->PanelY, &b,
- &f);
- }
+ if ((pGeode->Panel = Pnl_IsPanelEnabledInBIOS()))
+ Pnl_GetPanelInfoFromBIOS(&pGeode->PanelX, &pGeode->PanelY, &b,
+ &f);
+ }
#endif
- }
+ }
- /* Set up the VGA */
+ /* Set up the VGA */
- if (pGeode->useVGA) {
+ if (pGeode->useVGA) {
#if INT10_SUPPORT
- VESARec *pVesa;
+ VESARec *pVesa;
- if (!xf86LoadSubModule(pScrni, "int10"))
- return FALSE;
- xf86LoaderReqSymLists(amdInt10Symbols, NULL);
+ if (!xf86LoadSubModule(pScrni, "int10"))
+ return FALSE;
+ xf86LoaderReqSymLists(amdInt10Symbols, NULL);
- pVesa = pGeode->vesa;
+ pVesa = pGeode->vesa;
- if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Unable to initialize 1NT10 support\n");
- pGeode->useVGA = FALSE;
- }
+ if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Unable to initialize 1NT10 support\n");
+ pGeode->useVGA = FALSE;
+ }
#endif
- }
+ }
- /* First try to get the framebuffer size from the framebuffer,
- * and if that fails, revert all the way back to the legacy
- * method
- */
+ /* First try to get the framebuffer size from the framebuffer,
+ * and if that fails, revert all the way back to the legacy
+ * method
+ */
- if (pGeode->FBAvail == 0) {
- if (GeodeGetSizeFromFB(&pGeode->FBAvail))
- pGeode->FBAvail = gfx_get_frame_buffer_size();
- }
+ if (pGeode->FBAvail == 0) {
+ if (GeodeGetSizeFromFB(&pGeode->FBAvail))
+ pGeode->FBAvail = gfx_get_frame_buffer_size();
+ }
- if (pScrni->memPhysBase == 0)
- pScrni->memPhysBase = gfx_get_frame_buffer_base();
+ if (pScrni->memPhysBase == 0)
+ pScrni->memPhysBase = gfx_get_frame_buffer_base();
- pScrni->fbOffset = 0;
+ pScrni->fbOffset = 0;
- if (pGeode->pEnt->device->videoRam == 0)
- pScrni->videoRam = pGeode->FBAvail / 1024;
- else
- pScrni->videoRam = pGeode->pEnt->device->videoRam;
+ if (pGeode->pEnt->device->videoRam == 0)
+ pScrni->videoRam = pGeode->FBAvail / 1024;
+ else
+ pScrni->videoRam = pGeode->pEnt->device->videoRam;
- pGeode->maxWidth = GX_MAX_WIDTH;
- pGeode->maxHeight = GX_MAX_HEIGHT;
+ pGeode->maxWidth = GX_MAX_WIDTH;
+ pGeode->maxHeight = GX_MAX_HEIGHT;
- GeodeClockRange = (ClockRangePtr) xnfcalloc(sizeof(ClockRange), 1);
- GeodeClockRange->next = NULL;
- GeodeClockRange->minClock = 25175;
- GeodeClockRange->maxClock = 229500;
- GeodeClockRange->clockIndex = -1;
- GeodeClockRange->interlaceAllowed = TRUE;
- GeodeClockRange->doubleScanAllowed = FALSE;
+ GeodeClockRange = (ClockRangePtr) xnfcalloc(sizeof(ClockRange), 1);
+ GeodeClockRange->next = NULL;
+ GeodeClockRange->minClock = 25175;
+ GeodeClockRange->maxClock = 229500;
+ GeodeClockRange->clockIndex = -1;
+ GeodeClockRange->interlaceAllowed = TRUE;
+ GeodeClockRange->doubleScanAllowed = FALSE;
- if (pGeode->useVGA)
- pScrni->monitor->DDC = GeodeDoDDC(pScrni, pGeode->pEnt->index);
- else
- pScrni->monitor->DDC = NULL;
+ if (pGeode->useVGA)
+ pScrni->monitor->DDC = GeodeDoDDC(pScrni, pGeode->pEnt->index);
+ else
+ pScrni->monitor->DDC = NULL;
- /* I'm still not 100% sure this uses the right values */
+ /* I'm still not 100% sure this uses the right values */
- modecnt = xf86ValidateModes(pScrni,
- pScrni->monitor->Modes,
- pScrni->display->modes,
- GeodeClockRange,
- NULL, GX_MIN_PITCH, GX_MAX_PITCH,
- 32, GX_MIN_HEIGHT, GX_MAX_HEIGHT,
- pScrni->display->virtualX,
- pScrni->display->virtualY, pGeode->FBAvail, LOOKUP_BEST_REFRESH);
+ modecnt = xf86ValidateModes(pScrni,
+ pScrni->monitor->Modes,
+ pScrni->display->modes,
+ GeodeClockRange,
+ NULL, GX_MIN_PITCH, GX_MAX_PITCH,
+ 32, GX_MIN_HEIGHT, GX_MAX_HEIGHT,
+ pScrni->display->virtualX,
+ pScrni->display->virtualY, pGeode->FBAvail, LOOKUP_BEST_REFRESH);
- if (modecnt <= 0) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
- return FALSE;
- }
+ if (modecnt <= 0) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
+ return FALSE;
+ }
- xf86PruneDriverModes(pScrni);
+ xf86PruneDriverModes(pScrni);
- if (pScrni->modes == NULL) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
- return FALSE;
- }
+ if (pScrni->modes == NULL) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
+ return FALSE;
+ }
- xf86SetCrtcForModes(pScrni, 0);
- pScrni->currentMode = pScrni->modes;
+ xf86SetCrtcForModes(pScrni, 0);
+ pScrni->currentMode = pScrni->modes;
- xf86PrintModes(pScrni);
- xf86SetDpi(pScrni, 0, 0);
+ xf86PrintModes(pScrni);
+ xf86SetDpi(pScrni, 0, 0);
- /* Load the modules we'll need */
+ /* Load the modules we'll need */
- if (xf86LoadSubModule(pScrni, "fb") == NULL) {
- return FALSE;
- }
+ if (xf86LoadSubModule(pScrni, "fb") == NULL) {
+ return FALSE;
+ }
- xf86LoaderReqSymLists(amdFbSymbols, NULL);
+ xf86LoaderReqSymLists(amdFbSymbols, NULL);
- if (pGeode->NoAccel == FALSE) {
- const char *module = (pGeode->useEXA) ? "exa" : "xaa";
- const char **symbols = (pGeode->useEXA) ?
- &amdExaSymbols[0] : &amdXaaSymbols[0];
+ if (pGeode->NoAccel == FALSE) {
+ const char *module = (pGeode->useEXA) ? "exa" : "xaa";
+ const char **symbols = (pGeode->useEXA) ?
+ &amdExaSymbols[0] : &amdXaaSymbols[0];
- if (!xf86LoadSubModule(pScrni, module)) {
- return FALSE;
+ if (!xf86LoadSubModule(pScrni, module)) {
+ return FALSE;
+ }
+
+ xf86LoaderReqSymLists(symbols, NULL);
}
- xf86LoaderReqSymLists(symbols, NULL);
- }
+ if (pGeode->tryHWCursor == TRUE) {
+ if (!xf86LoadSubModule(pScrni, "ramdac")) {
+ return FALSE;
+ }
- if (pGeode->tryHWCursor == TRUE) {
- if (!xf86LoadSubModule(pScrni, "ramdac")) {
- return FALSE;
+ xf86LoaderReqSymLists(amdRamdacSymbols, NULL);
}
- xf86LoaderReqSymLists(amdRamdacSymbols, NULL);
- }
-
- if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Couldn't register the resources.\n");
- return FALSE;
- }
+ if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Couldn't register the resources.\n");
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
static void
GXRestore(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (pGeode->useVGA && pGeode->FBVGAActive) {
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
+ if (pGeode->useVGA && pGeode->FBVGAActive) {
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- vgaHWProtect(pScrni, TRUE);
- vgaHWRestore(pScrni, &pvgaHW->SavedReg, VGA_SR_ALL);
- vgaHWProtect(pScrni, FALSE);
- }
+ vgaHWProtect(pScrni, TRUE);
+ vgaHWRestore(pScrni, &pvgaHW->SavedReg, VGA_SR_ALL);
+ vgaHWProtect(pScrni, FALSE);
+ }
}
static Bool
GXUnmapMem(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- /* unmap all the memory map's */
+ /* unmap all the memory map's */
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_regptr, GX_CPU_REG_SIZE);
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_gpptr, GX_GP_REG_SIZE);
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_vidptr, GX_VID_REG_SIZE);
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_fbptr, pGeode->FBAvail);
- return TRUE;
+ xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_regptr, GX_CPU_REG_SIZE);
+ xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_gpptr, GX_GP_REG_SIZE);
+ xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_vidptr, GX_VID_REG_SIZE);
+ xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_fbptr, pGeode->FBAvail);
+ return TRUE;
}
static void
GXSetDvLineSize(unsigned int pitch)
{
- unsigned long temp, dv_size = MDC_DV_LINE_SIZE_1024;
-
- if (pitch > 1024) {
- dv_size = MDC_DV_LINE_SIZE_2048;
- }
- if (pitch > 2048) {
- dv_size = MDC_DV_LINE_SIZE_4096;
- }
- if (pitch > 4096) {
- dv_size = MDC_DV_LINE_SIZE_8192;
- }
-
- /* WRITE DIRTY/VALID CONTROL WITH LINE LENGTH */
-
- temp = READ_REG32(MDC_DV_CTL);
- WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size);
+ unsigned long temp, dv_size = MDC_DV_LINE_SIZE_1024;
+
+ if (pitch > 1024) {
+ dv_size = MDC_DV_LINE_SIZE_2048;
+ }
+ if (pitch > 2048) {
+ dv_size = MDC_DV_LINE_SIZE_4096;
+ }
+ if (pitch > 4096) {
+ dv_size = MDC_DV_LINE_SIZE_8192;
+ }
+
+ /* WRITE DIRTY/VALID CONTROL WITH LINE LENGTH */
+
+ temp = READ_REG32(MDC_DV_CTL);
+ WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size);
}
/* XXX - this is nothing like the original function - not sure exactly what the purpose is for this quite yet */
@@ -791,690 +790,690 @@ GXSetDvLineSize(unsigned int pitch)
static void
GXAdjustFrame(int scrnIndex, int x, int y, int flags)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- unsigned long offset;
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ unsigned long offset;
- offset =
- pGeode->FBOffset + y * pGeode->Pitch +
- x * (pScrni->bitsPerPixel >> 3);
+ offset =
+ pGeode->FBOffset + y * pGeode->Pitch +
+ x * (pScrni->bitsPerPixel >> 3);
- gfx_set_display_offset(offset);
+ gfx_set_display_offset(offset);
}
static Bool
GXSetVideoMode(ScrnInfoPtr pScrni, DisplayModePtr pMode)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int flags = 0;
- int custom = 0;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int flags = 0;
+ int custom = 0;
- pScrni->vtSema = TRUE;
+ pScrni->vtSema = TRUE;
- gx_disable_dac_power();
+ gx_disable_dac_power();
- if (pMode->Flags & V_NHSYNC)
- flags |= 1;
- if (pMode->Flags & V_NVSYNC)
- flags |= 2;
+ if (pMode->Flags & V_NHSYNC)
+ flags |= 1;
+ if (pMode->Flags & V_NVSYNC)
+ flags |= 2;
- /* Check to see if we should use custom or built-in timings */
+ /* Check to see if we should use custom or built-in timings */
- if (pGeode->Panel)
+ if (pGeode->Panel)
custom = (pMode->type & M_T_USERDEF);
- else
+ else
custom = !(pMode->type & (M_T_BUILTIN | M_T_DEFAULT));
- /* If we're not doing a custom mode, then just set the fixed timings,
- * otherwise, do the whole shooting match */
+ /* If we're not doing a custom mode, then just set the fixed timings,
+ * otherwise, do the whole shooting match */
- if (!custom) {
- GFX(set_fixed_timings(pGeode->PanelX, pGeode->PanelY,
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel));
- } else {
- if (pGeode->Panel)
- GFX(set_panel_present(pGeode->PanelX, pGeode->PanelY,
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel));
-
- GFX(set_display_timings(pScrni->bitsPerPixel, flags,
- pMode->CrtcHDisplay, pMode->CrtcHBlankStart,
- pMode->CrtcHSyncStart, pMode->CrtcHSyncEnd,
- pMode->CrtcHBlankEnd, pMode->CrtcHTotal,
- pMode->CrtcVDisplay, pMode->CrtcVBlankStart,
- pMode->CrtcVSyncStart, pMode->CrtcVSyncEnd,
- pMode->CrtcVBlankEnd, pMode->CrtcVTotal,
- (int)((pMode->SynthClock / 1000.0) * 0x10000)));
- }
-
- GFX(set_crt_enable(CRT_ENABLE));
- GFX(set_display_pitch(pGeode->displayPitch));
- GFX(set_display_offset(0L));
- GFX(wait_vertical_blank());
-
- if (pGeode->Compression) {
- GXSetDvLineSize(pGeode->Pitch);
-
- gfx_set_compression_offset(pGeode->CBData.compression_offset);
- gfx_set_compression_pitch(GX_CB_PITCH);
- gfx_set_compression_size(GX_CB_SIZE);
-
- gfx_set_compression_enable(1);
- }
-
- if (pGeode->HWCursor && !(pMode->Flags & V_DBLSCAN)) {
- GXLoadCursorImage(pScrni, NULL);
- GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0));
- GXShowCursor(pScrni);
- } else {
- GFX(set_cursor_enable(0));
- pGeode->HWCursor = FALSE;
- }
-
- GXAdjustFrame(pScrni->scrnIndex, pScrni->frameX0, pScrni->frameY0, 0);
- gx_enable_dac_power();
-
- return TRUE;
+ if (!custom) {
+ GFX(set_fixed_timings(pGeode->PanelX, pGeode->PanelY,
+ pMode->CrtcHDisplay, pMode->CrtcVDisplay,
+ pScrni->bitsPerPixel));
+ } else {
+ if (pGeode->Panel)
+ GFX(set_panel_present(pGeode->PanelX, pGeode->PanelY,
+ pMode->CrtcHDisplay, pMode->CrtcVDisplay,
+ pScrni->bitsPerPixel));
+
+ GFX(set_display_timings(pScrni->bitsPerPixel, flags,
+ pMode->CrtcHDisplay, pMode->CrtcHBlankStart,
+ pMode->CrtcHSyncStart, pMode->CrtcHSyncEnd,
+ pMode->CrtcHBlankEnd, pMode->CrtcHTotal,
+ pMode->CrtcVDisplay, pMode->CrtcVBlankStart,
+ pMode->CrtcVSyncStart, pMode->CrtcVSyncEnd,
+ pMode->CrtcVBlankEnd, pMode->CrtcVTotal,
+ (int)((pMode->SynthClock / 1000.0) * 0x10000)));
+ }
+
+ GFX(set_crt_enable(CRT_ENABLE));
+ GFX(set_display_pitch(pGeode->displayPitch));
+ GFX(set_display_offset(0L));
+ GFX(wait_vertical_blank());
+
+ if (pGeode->Compression) {
+ GXSetDvLineSize(pGeode->Pitch);
+
+ gfx_set_compression_offset(pGeode->CBData.compression_offset);
+ gfx_set_compression_pitch(GX_CB_PITCH);
+ gfx_set_compression_size(GX_CB_SIZE);
+
+ gfx_set_compression_enable(1);
+ }
+
+ if (pGeode->HWCursor && !(pMode->Flags & V_DBLSCAN)) {
+ GXLoadCursorImage(pScrni, NULL);
+ GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0));
+ GXShowCursor(pScrni);
+ } else {
+ GFX(set_cursor_enable(0));
+ pGeode->HWCursor = FALSE;
+ }
+
+ GXAdjustFrame(pScrni->scrnIndex, pScrni->frameX0, pScrni->frameY0, 0);
+ gx_enable_dac_power();
+
+ return TRUE;
}
static Bool
GXSwitchMode(int index, DisplayModePtr pMode, int flags)
{
- ScrnInfoPtr pScrni = xf86Screens[index];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int ret = TRUE;
- int rotate;
+ ScrnInfoPtr pScrni = xf86Screens[index];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int ret = TRUE;
+ int rotate;
- /* Syn the engine and shutdown the DAC momentarily */
+ /* Syn the engine and shutdown the DAC momentarily */
- gfx_wait_until_idle();
+ gfx_wait_until_idle();
- /* Set up the memory for the new mode */
- rotate = GXGetRotation(pScrni->pScreen);
- ret = GXAllocateMemory(pScrni->pScreen, pScrni, rotate);
+ /* Set up the memory for the new mode */
+ rotate = GXGetRotation(pScrni->pScreen);
+ ret = GXAllocateMemory(pScrni->pScreen, pScrni, rotate);
- if (ret) {
- if (pGeode->curMode != pMode)
- ret = GXSetVideoMode(pScrni, pMode);
- }
+ if (ret) {
+ if (pGeode->curMode != pMode)
+ ret = GXSetVideoMode(pScrni, pMode);
+ }
- if (ret)
- ret = GXRotate(pScrni, pMode);
+ if (ret)
+ ret = GXRotate(pScrni, pMode);
- /* Go back the way it was */
+ /* Go back the way it was */
- if (ret == FALSE) {
- if (!GXSetVideoMode(pScrni, pGeode->curMode))
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Could not restore the previous mode\n");
- } else
- pGeode->curMode = pMode;
+ if (ret == FALSE) {
+ if (!GXSetVideoMode(pScrni, pGeode->curMode))
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Could not restore the previous mode\n");
+ } else
+ pGeode->curMode = pMode;
- return ret;
+ return ret;
}
static void
GXLeaveGraphics(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- gfx_wait_until_idle();
-
- /* Restore VG registers */
- gfx_set_display_timings(pGeode->FBgfxdisplaytiming.wBpp,
- pGeode->FBgfxdisplaytiming.wPolarity,
- pGeode->FBgfxdisplaytiming.wHActive,
- pGeode->FBgfxdisplaytiming.wHBlankStart,
- pGeode->FBgfxdisplaytiming.wHSyncStart,
- pGeode->FBgfxdisplaytiming.wHSyncEnd,
- pGeode->FBgfxdisplaytiming.wHBlankEnd,
- pGeode->FBgfxdisplaytiming.wHTotal,
- pGeode->FBgfxdisplaytiming.wVActive,
- pGeode->FBgfxdisplaytiming.wVBlankStart,
- pGeode->FBgfxdisplaytiming.wVSyncStart,
- pGeode->FBgfxdisplaytiming.wVSyncEnd,
- pGeode->FBgfxdisplaytiming.wVBlankEnd,
- pGeode->FBgfxdisplaytiming.wVTotal,
- pGeode->FBgfxdisplaytiming.dwDotClock);
-
- gfx_set_compression_enable(0);
-
- /* Restore the previous Compression state */
- if (pGeode->FBCompressionEnable) {
- gfx_set_compression_offset(pGeode->FBCompressionOffset);
- gfx_set_compression_pitch(pGeode->FBCompressionPitch);
- gfx_set_compression_size(pGeode->FBCompressionSize);
- gfx_set_compression_enable(1);
- }
-
- gfx_set_display_pitch(pGeode->FBgfxdisplaytiming.wPitch);
-
- gfx_set_display_offset(pGeode->FBDisplayOffset);
-
- /* Restore Cursor */
- gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0);
-
- if (pGeode->useVGA) {
- pGeode->vesa->pInt->num = 0x10;
- pGeode->vesa->pInt->ax = 0x0 | pGeode->FBBIOSMode;
- pGeode->vesa->pInt->bx = 0;
- xf86ExecX86int10(pGeode->vesa->pInt);
- gfx_delay_milliseconds(3);
- }
-
- GXRestore(pScrni);
-
- gx_enable_dac_power();
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ gfx_wait_until_idle();
+
+ /* Restore VG registers */
+ gfx_set_display_timings(pGeode->FBgfxdisplaytiming.wBpp,
+ pGeode->FBgfxdisplaytiming.wPolarity,
+ pGeode->FBgfxdisplaytiming.wHActive,
+ pGeode->FBgfxdisplaytiming.wHBlankStart,
+ pGeode->FBgfxdisplaytiming.wHSyncStart,
+ pGeode->FBgfxdisplaytiming.wHSyncEnd,
+ pGeode->FBgfxdisplaytiming.wHBlankEnd,
+ pGeode->FBgfxdisplaytiming.wHTotal,
+ pGeode->FBgfxdisplaytiming.wVActive,
+ pGeode->FBgfxdisplaytiming.wVBlankStart,
+ pGeode->FBgfxdisplaytiming.wVSyncStart,
+ pGeode->FBgfxdisplaytiming.wVSyncEnd,
+ pGeode->FBgfxdisplaytiming.wVBlankEnd,
+ pGeode->FBgfxdisplaytiming.wVTotal,
+ pGeode->FBgfxdisplaytiming.dwDotClock);
+
+ gfx_set_compression_enable(0);
+
+ /* Restore the previous Compression state */
+ if (pGeode->FBCompressionEnable) {
+ gfx_set_compression_offset(pGeode->FBCompressionOffset);
+ gfx_set_compression_pitch(pGeode->FBCompressionPitch);
+ gfx_set_compression_size(pGeode->FBCompressionSize);
+ gfx_set_compression_enable(1);
+ }
+
+ gfx_set_display_pitch(pGeode->FBgfxdisplaytiming.wPitch);
+
+ gfx_set_display_offset(pGeode->FBDisplayOffset);
+
+ /* Restore Cursor */
+ gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0);
+
+ if (pGeode->useVGA) {
+ pGeode->vesa->pInt->num = 0x10;
+ pGeode->vesa->pInt->ax = 0x0 | pGeode->FBBIOSMode;
+ pGeode->vesa->pInt->bx = 0;
+ xf86ExecX86int10(pGeode->vesa->pInt);
+ gfx_delay_milliseconds(3);
+ }
+
+ GXRestore(pScrni);
+
+ gx_enable_dac_power();
}
static Bool
GXCloseScreen(int scrnIndex, ScreenPtr pScrn)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ if (pScrni->vtSema)
+ GXLeaveGraphics(pScrni);
- if (pScrni->vtSema)
- GXLeaveGraphics(pScrni);
+ if (pGeode->AccelInfoRec)
+ XAADestroyInfoRec(pGeode->AccelInfoRec);
- if (pGeode->AccelInfoRec)
- XAADestroyInfoRec(pGeode->AccelInfoRec);
+ if (pGeode->AccelImageWriteBuffers) {
+ xfree(pGeode->AccelImageWriteBuffers[0]);
+ xfree(pGeode->AccelImageWriteBuffers);
+ pGeode->AccelImageWriteBuffers = NULL;
+ }
- if (pGeode->AccelImageWriteBuffers) {
- xfree(pGeode->AccelImageWriteBuffers[0]);
- xfree(pGeode->AccelImageWriteBuffers);
- pGeode->AccelImageWriteBuffers = NULL;
- }
+ if (pGeode->AccelColorExpandBuffers) {
+ xfree(pGeode->AccelColorExpandBuffers);
+ pGeode->AccelColorExpandBuffers = NULL;
+ }
- if (pGeode->AccelColorExpandBuffers) {
- xfree(pGeode->AccelColorExpandBuffers);
- pGeode->AccelColorExpandBuffers = NULL;
- }
+ if (pGeode->pExa) {
+ exaDriverFini(pScrn);
+ xfree(pGeode->pExa);
+ pGeode->pExa = NULL;
+ }
- if (pGeode->pExa) {
- exaDriverFini(pScrn);
- xfree(pGeode->pExa);
- pGeode->pExa = NULL;
- }
+ pScrni->vtSema = FALSE;
- pScrni->vtSema = FALSE;
+ GXUnmapMem(pScrni);
- GXUnmapMem(pScrni);
+ pScrni->PointerMoved = pGeode->PointerMoved;
+ pScrn->CloseScreen = pGeode->CloseScreen;
-
- pScrni->PointerMoved = pGeode->PointerMoved;
- pScrn->CloseScreen = pGeode->CloseScreen;
-
- if (pScrn->CloseScreen)
- return (*pScrn->CloseScreen)(scrnIndex, pScrn);
+ if (pScrn->CloseScreen)
+ return (*pScrn->CloseScreen) (scrnIndex, pScrn);
- return TRUE;
+ return TRUE;
}
static Bool
GXEnterGraphics(ScreenPtr pScrn, ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (!GXMapMem(pScrni))
- return FALSE;
+ if (!GXMapMem(pScrni))
+ return FALSE;
- if (pGeode->useVGA)
+ if (pGeode->useVGA)
pGeode->FBVGAActive = gu2_get_vga_active();
- gfx_wait_until_idle();
-
- /* Save off the current state (should this be somewhere else)? */
-
- pGeode->FBgfxdisplaytiming.dwDotClock = gfx_get_clock_frequency();
- pGeode->FBgfxdisplaytiming.wPitch = gfx_get_display_pitch();
- pGeode->FBgfxdisplaytiming.wBpp = gfx_get_display_bpp();
- pGeode->FBgfxdisplaytiming.wHTotal = gfx_get_htotal();
- pGeode->FBgfxdisplaytiming.wHActive = gfx_get_hactive();
- pGeode->FBgfxdisplaytiming.wHSyncStart = gfx_get_hsync_start();
- pGeode->FBgfxdisplaytiming.wHSyncEnd = gfx_get_hsync_end();
- pGeode->FBgfxdisplaytiming.wHBlankStart = gfx_get_hblank_start();
- pGeode->FBgfxdisplaytiming.wHBlankEnd = gfx_get_hblank_end();
- pGeode->FBgfxdisplaytiming.wVTotal = gfx_get_vtotal();
- pGeode->FBgfxdisplaytiming.wVActive = gfx_get_vactive();
- pGeode->FBgfxdisplaytiming.wVSyncStart = gfx_get_vsync_start();
- pGeode->FBgfxdisplaytiming.wVSyncEnd = gfx_get_vsync_end();
- pGeode->FBgfxdisplaytiming.wVBlankStart = gfx_get_vblank_start();
- pGeode->FBgfxdisplaytiming.wVBlankEnd = gfx_get_vblank_end();
- pGeode->FBgfxdisplaytiming.wPolarity = gfx_get_sync_polarities();
-
- pGeode->FBDisplayOffset = gfx_get_display_offset();
-
- if (pGeode->useVGA) {
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- pGeode->FBBIOSMode = pvgaHW->readCrtc(pvgaHW, 0x040);
- }
-
- pGeode->FBCompressionEnable = gfx_get_compression_enable();
- pGeode->FBCompressionOffset = gfx_get_compression_offset();
- pGeode->FBCompressionPitch = gfx_get_compression_pitch();
- pGeode->FBCompressionSize = gfx_get_compression_size();
+ gfx_wait_until_idle();
+
+ /* Save off the current state (should this be somewhere else)? */
+
+ pGeode->FBgfxdisplaytiming.dwDotClock = gfx_get_clock_frequency();
+ pGeode->FBgfxdisplaytiming.wPitch = gfx_get_display_pitch();
+ pGeode->FBgfxdisplaytiming.wBpp = gfx_get_display_bpp();
+ pGeode->FBgfxdisplaytiming.wHTotal = gfx_get_htotal();
+ pGeode->FBgfxdisplaytiming.wHActive = gfx_get_hactive();
+ pGeode->FBgfxdisplaytiming.wHSyncStart = gfx_get_hsync_start();
+ pGeode->FBgfxdisplaytiming.wHSyncEnd = gfx_get_hsync_end();
+ pGeode->FBgfxdisplaytiming.wHBlankStart = gfx_get_hblank_start();
+ pGeode->FBgfxdisplaytiming.wHBlankEnd = gfx_get_hblank_end();
+ pGeode->FBgfxdisplaytiming.wVTotal = gfx_get_vtotal();
+ pGeode->FBgfxdisplaytiming.wVActive = gfx_get_vactive();
+ pGeode->FBgfxdisplaytiming.wVSyncStart = gfx_get_vsync_start();
+ pGeode->FBgfxdisplaytiming.wVSyncEnd = gfx_get_vsync_end();
+ pGeode->FBgfxdisplaytiming.wVBlankStart = gfx_get_vblank_start();
+ pGeode->FBgfxdisplaytiming.wVBlankEnd = gfx_get_vblank_end();
+ pGeode->FBgfxdisplaytiming.wPolarity = gfx_get_sync_polarities();
+
+ pGeode->FBDisplayOffset = gfx_get_display_offset();
+
+ if (pGeode->useVGA) {
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
+
+ pGeode->FBBIOSMode = pvgaHW->readCrtc(pvgaHW, 0x040);
+ }
+
+ pGeode->FBCompressionEnable = gfx_get_compression_enable();
+ pGeode->FBCompressionOffset = gfx_get_compression_offset();
+ pGeode->FBCompressionPitch = gfx_get_compression_pitch();
+ pGeode->FBCompressionSize = gfx_get_compression_size();
#ifdef PNL_SUP
- Pnl_SavePanelState();
+ Pnl_SavePanelState();
#endif
- /* Turn off the VGA */
+ /* Turn off the VGA */
- if (pGeode->useVGA && pGeode->FBVGAActive) {
- unsigned short sequencer;
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
+ if (pGeode->useVGA && pGeode->FBVGAActive) {
+ unsigned short sequencer;
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- /* Map VGA aperture */
- if (!vgaHWMapMem(pScrni))
- return FALSE;
+ /* Map VGA aperture */
+ if (!vgaHWMapMem(pScrni))
+ return FALSE;
- /* Unlock VGA registers */
- vgaHWUnlock(pvgaHW);
+ /* Unlock VGA registers */
+ vgaHWUnlock(pvgaHW);
- /* Save the current state and setup the current mode */
- vgaHWSave(pScrni, &VGAHWPTR(pScrni)->SavedReg, VGA_SR_ALL);
+ /* Save the current state and setup the current mode */
+ vgaHWSave(pScrni, &VGAHWPTR(pScrni)->SavedReg, VGA_SR_ALL);
- /* DISABLE VGA SEQUENCER */
- /* This allows the VGA state machine to terminate. We must delay */
- /* such that there are no pending MBUS requests. */
+ /* DISABLE VGA SEQUENCER */
+ /* This allows the VGA state machine to terminate. We must delay */
+ /* such that there are no pending MBUS requests. */
- gfx_outb(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_CLK_MODE);
- sequencer = gfx_inb(MDC_SEQUENCER_DATA);
- sequencer |= MDC_CLK_MODE_SCREEN_OFF;
- gfx_outb(MDC_SEQUENCER_DATA, sequencer);
+ gfx_outb(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_CLK_MODE);
+ sequencer = gfx_inb(MDC_SEQUENCER_DATA);
+ sequencer |= MDC_CLK_MODE_SCREEN_OFF;
+ gfx_outb(MDC_SEQUENCER_DATA, sequencer);
- gfx_delay_milliseconds(1);
+ gfx_delay_milliseconds(1);
- /* BLANK THE VGA DISPLAY */
- gfx_outw(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_RESET);
- sequencer = gfx_inb(MDC_SEQUENCER_DATA);
- sequencer &= ~MDC_RESET_VGA_DISP_ENABLE;
- gfx_outb(MDC_SEQUENCER_DATA, sequencer);
+ /* BLANK THE VGA DISPLAY */
+ gfx_outw(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_RESET);
+ sequencer = gfx_inb(MDC_SEQUENCER_DATA);
+ sequencer &= ~MDC_RESET_VGA_DISP_ENABLE;
+ gfx_outb(MDC_SEQUENCER_DATA, sequencer);
- gfx_delay_milliseconds(1);
- }
+ gfx_delay_milliseconds(1);
+ }
- /* Set up the memory */
- /* XXX - FIXME - when we alow inital rotation, it should be here */
- GXAllocateMemory(pScrn, pScrni, pGeode->rotation);
+ /* Set up the memory */
+ /* XXX - FIXME - when we alow inital rotation, it should be here */
+ GXAllocateMemory(pScrn, pScrni, pGeode->rotation);
- /* Clear the framebuffer */
- memset(pGeode->FBBase + pGeode->displayOffset, 0, pGeode->displaySize);
+ /* Clear the framebuffer */
+ memset(pGeode->FBBase + pGeode->displayOffset, 0, pGeode->displaySize);
- /* Set up the video mode */
- GXSetVideoMode(pScrni, pScrni->currentMode);
- pGeode->curMode = pScrni->currentMode;
+ /* Set up the video mode */
+ GXSetVideoMode(pScrni, pScrni->currentMode);
+ pGeode->curMode = pScrni->currentMode;
- return TRUE;
+ return TRUE;
}
static void
GXLoadPalette(ScrnInfoPtr pScrni,
- int numColors, int *indizes, LOCO * colors, VisualPtr pVisual)
+ int numColors, int *indizes, LOCO * colors, VisualPtr pVisual)
{
- int i, index, color;
+ int i, index, color;
- for (i = 0; i < numColors; i++) {
- index = indizes[i] & 0xFF;
- color = (((unsigned long)(colors[index].red & 0xFF)) << 16) |
- (((unsigned long)(colors[index].green & 0xFF)) << 8) |
- ((unsigned long)(colors[index].blue & 0xFF));
+ for (i = 0; i < numColors; i++) {
+ index = indizes[i] & 0xFF;
+ color = (((unsigned long)(colors[index].red & 0xFF)) << 16) |
+ (((unsigned long)(colors[index].green & 0xFF)) << 8) |
+ ((unsigned long)(colors[index].blue & 0xFF));
- GFX(set_display_palette_entry(index, color));
- }
+ GFX(set_display_palette_entry(index, color));
+ }
}
#ifdef DPMSExtension
static void
GXPanelPower(int enable)
{
- unsigned long power = READ_VID32(RCDF_POWER_MANAGEMENT);
+ unsigned long power = READ_VID32(RCDF_POWER_MANAGEMENT);
- if (enable != 0)
- power |= RCDF_PM_PANEL_POWER_ON;
- else
- power &= ~RCDF_PM_PANEL_POWER_ON;
+ if (enable != 0)
+ power |= RCDF_PM_PANEL_POWER_ON;
+ else
+ power &= ~RCDF_PM_PANEL_POWER_ON;
- WRITE_VID32(RCDF_POWER_MANAGEMENT, power);
+ WRITE_VID32(RCDF_POWER_MANAGEMENT, power);
}
static void
GXDPMSSet(ScrnInfoPtr pScrni, int mode, int flags)
{
- GeodeRec *pGeode;
+ GeodeRec *pGeode;
- pGeode = GEODEPTR(pScrni);
+ pGeode = GEODEPTR(pScrni);
- if (!pScrni->vtSema)
- return;
+ if (!pScrni->vtSema)
+ return;
- switch (mode) {
- case DPMSModeOn:
- /* Screen: On; HSync: On; VSync: On */
- GFX(set_crt_enable(CRT_ENABLE));
+ switch (mode) {
+ case DPMSModeOn:
+ /* Screen: On; HSync: On; VSync: On */
+ GFX(set_crt_enable(CRT_ENABLE));
#if defined(PNL_SUP)
- if (pGeode->Panel) {
- Pnl_PowerUp();
- GXPanelPower(1);
- }
+ if (pGeode->Panel) {
+ Pnl_PowerUp();
+ GXPanelPower(1);
+ }
#endif
- break;
+ break;
- case DPMSModeStandby:
- /* Screen: Off; HSync: Off; VSync: On */
- GFX(set_crt_enable(CRT_STANDBY));
+ case DPMSModeStandby:
+ /* Screen: Off; HSync: Off; VSync: On */
+ GFX(set_crt_enable(CRT_STANDBY));
#if defined(PNL_SUP)
- if (pGeode->Panel) {
- Pnl_PowerDown();
- GXPanelPower(0);
- }
+ if (pGeode->Panel) {
+ Pnl_PowerDown();
+ GXPanelPower(0);
+ }
#endif
- break;
+ break;
- case DPMSModeSuspend:
- /* Screen: Off; HSync: On; VSync: Off */
- GFX(set_crt_enable(CRT_SUSPEND));
+ case DPMSModeSuspend:
+ /* Screen: Off; HSync: On; VSync: Off */
+ GFX(set_crt_enable(CRT_SUSPEND));
#if defined(PNL_SUP)
- if (pGeode->Panel) {
- Pnl_PowerDown();
- GXPanelPower(0);
- }
+ if (pGeode->Panel) {
+ Pnl_PowerDown();
+ GXPanelPower(0);
+ }
#endif
- break;
+ break;
- case DPMSModeOff:
- /* Screen: Off; HSync: Off; VSync: Off */
- GFX(set_crt_enable(CRT_DISABLE));
+ case DPMSModeOff:
+ /* Screen: Off; HSync: Off; VSync: Off */
+ GFX(set_crt_enable(CRT_DISABLE));
#if defined(PNL_SUP)
- if (pGeode->Panel) {
- Pnl_PowerDown();
- GXPanelPower(0);
- }
+ if (pGeode->Panel) {
+ Pnl_PowerDown();
+ GXPanelPower(0);
+ }
#endif
- break;
- }
+ break;
+ }
}
#endif
static Bool
GXCreateScreenResources(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- pScreen->CreateScreenResources = pGeode->CreateScreenResources;
- if (!(*pScreen->CreateScreenResources) (pScreen))
- return FALSE;
+ pScreen->CreateScreenResources = pGeode->CreateScreenResources;
+ if (!(*pScreen->CreateScreenResources) (pScreen))
+ return FALSE;
- if (xf86LoaderCheckSymbol("GXRandRSetConfig")
- && pGeode->rotation != RR_Rotate_0) {
- Rotation(*GXRandRSetConfig) (ScreenPtr pScreen, Rotation rr, int rate,
- RRScreenSizePtr pSize) = NULL;
+ if (xf86LoaderCheckSymbol("GXRandRSetConfig")
+ && pGeode->rotation != RR_Rotate_0) {
+ Rotation(*GXRandRSetConfig) (ScreenPtr pScreen, Rotation rr, int rate,
+ RRScreenSizePtr pSize) = NULL;
- RRScreenSize p;
- Rotation requestedRotation = pGeode->rotation;
+ RRScreenSize p;
+ Rotation requestedRotation = pGeode->rotation;
- pGeode->rotation = RR_Rotate_0;
+ pGeode->rotation = RR_Rotate_0;
- /* Just setup enough for an initial rotate */
+ /* Just setup enough for an initial rotate */
- p.width = pScreen->width;
- p.height = pScreen->height;
- p.mmWidth = pScreen->mmWidth;
- p.mmHeight = pScreen->mmHeight;
+ p.width = pScreen->width;
+ p.height = pScreen->height;
+ p.mmWidth = pScreen->mmWidth;
+ p.mmHeight = pScreen->mmHeight;
- GXRandRSetConfig = LoaderSymbol("GXRandRSetConfig");
- if (GXRandRSetConfig) {
- pGeode->starting = TRUE;
- (*GXRandRSetConfig) (pScreen, requestedRotation, 0, &p);
- pGeode->starting = FALSE;
+ GXRandRSetConfig = LoaderSymbol("GXRandRSetConfig");
+ if (GXRandRSetConfig) {
+ pGeode->starting = TRUE;
+ (*GXRandRSetConfig) (pScreen, requestedRotation, 0, &p);
+ pGeode->starting = FALSE;
+ }
}
- }
- return TRUE;
+ return TRUE;
}
static Bool
GXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- XF86ModReqInfo shadowReq;
- int maj, min, ret, rotate;
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ XF86ModReqInfo shadowReq;
+ int maj, min, ret, rotate;
- pGeode->starting = TRUE;
+ pGeode->starting = TRUE;
- /* If we are using VGA then go ahead and map the memory */
+ /* If we are using VGA then go ahead and map the memory */
- if (pGeode->useVGA) {
+ if (pGeode->useVGA) {
- if (!vgaHWMapMem(pScrni))
- return FALSE;
+ if (!vgaHWMapMem(pScrni))
+ return FALSE;
- vgaHWGetIOBase(VGAHWPTR(pScrni));
- }
-
- if (!pGeode->NoAccel) {
+ vgaHWGetIOBase(VGAHWPTR(pScrni));
+ }
- if (pGeode->useEXA) {
+ if (!pGeode->NoAccel) {
- if (!(pGeode->pExa = xnfcalloc(sizeof(ExaDriverRec), 1))) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Couldn't allocate the EXA structure.\n");
- pGeode->NoAccel = TRUE;
- } else {
- ExaDriverPtr pExa = pGeode->pExa;
+ if (pGeode->useEXA) {
- /* THis is set in GXAllocMem */
- pExa->memoryBase = 0;
+ if (!(pGeode->pExa = xnfcalloc(sizeof(ExaDriverRec), 1))) {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Couldn't allocate the EXA structure.\n");
+ pGeode->NoAccel = TRUE;
+ } else {
+ ExaDriverPtr pExa = pGeode->pExa;
- /* This is set in GXAllocateMemory */
- pExa->memorySize = 0;
+ /* THis is set in GXAllocMem */
+ pExa->memoryBase = 0;
- pExa->pixmapOffsetAlign = 32;
- pExa->pixmapPitchAlign = 32;
- pExa->flags = EXA_OFFSCREEN_PIXMAPS;
- pExa->maxX = pGeode->maxWidth - 1;
- pExa->maxY = pGeode->maxHeight - 1;
- }
- } else {
- pGeode->AccelImageWriteBuffers =
- xcalloc(sizeof(pGeode->AccelImageWriteBuffers[0]),
+ /* This is set in GXAllocateMemory */
+ pExa->memorySize = 0;
+
+ pExa->pixmapOffsetAlign = 32;
+ pExa->pixmapPitchAlign = 32;
+ pExa->flags = EXA_OFFSCREEN_PIXMAPS;
+ pExa->maxX = pGeode->maxWidth - 1;
+ pExa->maxY = pGeode->maxHeight - 1;
+ }
+ } else {
+ pGeode->AccelImageWriteBuffers =
+ xcalloc(sizeof(pGeode->AccelImageWriteBuffers[0]),
pGeode->NoOfImgBuffers);
- pGeode->AccelColorExpandBuffers =
- xcalloc(sizeof(pGeode->AccelColorExpandBuffers[0]),
+ pGeode->AccelColorExpandBuffers =
+ xcalloc(sizeof(pGeode->AccelColorExpandBuffers[0]),
pGeode->NoOfColorExpandLines);
+ }
}
- }
- /* XXX FIXME - Take down any of the structures on failure? */
+ /* XXX FIXME - Take down any of the structures on failure? */
- if (!GXEnterGraphics(pScrn, pScrni))
- return FALSE;
+ if (!GXEnterGraphics(pScrn, pScrni))
+ return FALSE;
- miClearVisualTypes();
+ miClearVisualTypes();
- /* XXX Again - take down anything? */
+ /* XXX Again - take down anything? */
- if (pScrni->bitsPerPixel > 8) {
- if (!miSetVisualTypes(pScrni->depth,
- TrueColorMask, pScrni->rgbBits, pScrni->defaultVisual)) {
- return FALSE;
- }
- } else {
- if (!miSetVisualTypes(pScrni->depth,
- miGetDefaultVisualMask(pScrni->depth),
- pScrni->rgbBits, pScrni->defaultVisual)) {
- return FALSE;
+ if (pScrni->bitsPerPixel > 8) {
+ if (!miSetVisualTypes(pScrni->depth,
+ TrueColorMask, pScrni->rgbBits, pScrni->defaultVisual)) {
+ return FALSE;
+ }
+ } else {
+ if (!miSetVisualTypes(pScrni->depth,
+ miGetDefaultVisualMask(pScrni->depth),
+ pScrni->rgbBits, pScrni->defaultVisual)) {
+ return FALSE;
+ }
}
- }
- miSetPixmapDepths();
+ miSetPixmapDepths();
- /* Point at the visible area to start */
+ /* Point at the visible area to start */
- ret = fbScreenInit(pScrn, pGeode->FBBase + pGeode->displayOffset,
- pScrni->virtualX, pScrni->virtualY,
- pScrni->xDpi, pScrni->yDpi, pGeode->displayWidth,
- pScrni->bitsPerPixel);
+ ret = fbScreenInit(pScrn, pGeode->FBBase + pGeode->displayOffset,
+ pScrni->virtualX, pScrni->virtualY,
+ pScrni->xDpi, pScrni->yDpi, pGeode->displayWidth,
+ pScrni->bitsPerPixel);
- if (!ret)
- return FALSE;
+ if (!ret)
+ return FALSE;
- xf86SetBlackWhitePixels(pScrn);
+ xf86SetBlackWhitePixels(pScrn);
- /* Set up the color ordering */
+ /* Set up the color ordering */
- if (pScrni->bitsPerPixel > 8) {
- VisualPtr visual = pScrn->visuals + pScrn->numVisuals;
+ if (pScrni->bitsPerPixel > 8) {
+ VisualPtr visual = pScrn->visuals + pScrn->numVisuals;
- while (--visual >= pScrn->visuals) {
- if ((visual->class | DynamicClass) == DirectColor) {
- visual->offsetRed = pScrni->offset.red;
- visual->offsetGreen = pScrni->offset.green;
- visual->offsetBlue = pScrni->offset.blue;
- visual->redMask = pScrni->mask.red;
- visual->greenMask = pScrni->mask.green;
- visual->blueMask = pScrni->mask.blue;
- }
+ while (--visual >= pScrn->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = pScrni->offset.red;
+ visual->offsetGreen = pScrni->offset.green;
+ visual->offsetBlue = pScrni->offset.blue;
+ visual->redMask = pScrni->mask.red;
+ visual->greenMask = pScrni->mask.green;
+ visual->blueMask = pScrni->mask.blue;
+ }
+ }
}
- }
- /* Must follow the color ordering */
- fbPictureInit(pScrn, 0, 0);
+ /* Must follow the color ordering */
+ fbPictureInit(pScrn, 0, 0);
- if (!pGeode->NoAccel)
- GXAccelInit(pScrn);
+ if (!pGeode->NoAccel)
+ GXAccelInit(pScrn);
- miInitializeBackingStore(pScrn);
- xf86SetBackingStore(pScrn);
+ miInitializeBackingStore(pScrn);
+ xf86SetBackingStore(pScrn);
- /* Set up the soft cursor */
- miDCInitialize(pScrn, xf86GetPointerScreenFuncs());
+ /* Set up the soft cursor */
+ miDCInitialize(pScrn, xf86GetPointerScreenFuncs());
- /* Set up the HW cursor - must follow the soft cursor init */
+ /* Set up the HW cursor - must follow the soft cursor init */
- if (pGeode->tryHWCursor) {
- if (!GXHWCursorInit(pScrn))
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Hardware cursor initialization failed.\n");
- }
+ if (pGeode->tryHWCursor) {
+ if (!GXHWCursorInit(pScrn))
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Hardware cursor initialization failed.\n");
+ }
- /* Set up the color map */
+ /* Set up the color map */
- if (!miCreateDefColormap(pScrn))
- return FALSE;
+ if (!miCreateDefColormap(pScrn))
+ return FALSE;
- if (pScrni->bitsPerPixel == 8) {
- /* Must follow initialization of the default colormap */
+ if (pScrni->bitsPerPixel == 8) {
+ /* Must follow initialization of the default colormap */
- if (!xf86HandleColormaps(pScrn, 256, 8,
- GXLoadPalette, NULL,
- CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) {
- return FALSE;
+ if (!xf86HandleColormaps(pScrn, 256, 8,
+ GXLoadPalette, NULL,
+ CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) {
+ return FALSE;
+ }
}
- }
#ifdef DPMSExtension
- xf86DPMSInit(pScrn, GXDPMSSet, 0);
+ xf86DPMSInit(pScrn, GXDPMSSet, 0);
#endif
- GXInitVideo(pScrn);
+ GXInitVideo(pScrn);
- /* Set up RandR */
+ /* Set up RandR */
- xf86DisableRandR(); /* We provide our own RandR goodness */
+ xf86DisableRandR(); /* We provide our own RandR goodness */
- /* Try to set up the shadow FB for rotation */
+ /* Try to set up the shadow FB for rotation */
- memset(&shadowReq, 0, sizeof(shadowReq));
- shadowReq.majorversion = 1;
- shadowReq.minorversion = 1;
+ memset(&shadowReq, 0, sizeof(shadowReq));
+ shadowReq.majorversion = 1;
+ shadowReq.minorversion = 1;
- if (LoadSubModule(pScrni->module, "shadow",
- NULL, NULL, NULL, &shadowReq, &maj, &min)) {
+ if (LoadSubModule(pScrni->module, "shadow",
+ NULL, NULL, NULL, &shadowReq, &maj, &min)) {
- rotate = RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270;
- shadowSetup(pScrn);
- } else {
- LoaderErrorMsg(NULL, "shadow", maj, min);
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Error loading shadow - rotation not available.\n");
-
- if (pGeode->rotation != RR_Rotate_0)
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Reverting back to normal rotation.\n");
-
- rotate = pGeode->rotation = RR_Rotate_0;
- }
-
- GXRandRInit(pScrn, rotate);
+ rotate = RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270;
+ shadowSetup(pScrn);
+ } else {
+ LoaderErrorMsg(NULL, "shadow", maj, min);
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Error loading shadow - rotation not available.\n");
- pGeode->PointerMoved = pScrni->PointerMoved;
- pScrni->PointerMoved = GeodePointerMoved;
+ if (pGeode->rotation != RR_Rotate_0)
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Reverting back to normal rotation.\n");
- pGeode->CreateScreenResources = pScrn->CreateScreenResources;
- pScrn->CreateScreenResources = GXCreateScreenResources;
+ rotate = pGeode->rotation = RR_Rotate_0;
+ }
+
+ GXRandRInit(pScrn, rotate);
+
+ pGeode->PointerMoved = pScrni->PointerMoved;
+ pScrni->PointerMoved = GeodePointerMoved;
- pGeode->CloseScreen = pScrn->CloseScreen;
- pScrn->CloseScreen = GXCloseScreen;
- pScrn->SaveScreen = GXSaveScreen;
+ pGeode->CreateScreenResources = pScrn->CreateScreenResources;
+ pScrn->CreateScreenResources = GXCreateScreenResources;
- if (serverGeneration == 1)
- xf86ShowUnusedOptions(pScrni->scrnIndex, pScrni->options);
+ pGeode->CloseScreen = pScrn->CloseScreen;
+ pScrn->CloseScreen = GXCloseScreen;
+ pScrn->SaveScreen = GXSaveScreen;
- pGeode->starting = FALSE;
+ if (serverGeneration == 1)
+ xf86ShowUnusedOptions(pScrni->scrnIndex, pScrni->options);
- return TRUE;
+ pGeode->starting = FALSE;
+
+ return TRUE;
}
static int
GXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int p, ret;
- int custom = 0;
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int p, ret;
+ int custom = 0;
- if (pGeode->Panel)
+ if (pGeode->Panel)
custom = (pMode->type & M_T_USERDEF);
- else
+ else
custom = (pMode->type & (M_T_BUILTIN | M_T_DEFAULT));
- /* Use the durango lookup for !custom modes */
+ /* Use the durango lookup for !custom modes */
- if (!custom) {
- if (pGeode->Panel) {
- if (pMode->CrtcHDisplay > pGeode->PanelX ||
- pMode->CrtcVDisplay > pGeode->PanelY ||
- gfx_is_panel_mode_supported(pGeode->PanelX, pGeode->PanelY,
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel) < 0) {
-
- return MODE_BAD;
- }
- }
+ if (!custom) {
+ if (pGeode->Panel) {
+ if (pMode->CrtcHDisplay > pGeode->PanelX ||
+ pMode->CrtcVDisplay > pGeode->PanelY ||
+ gfx_is_panel_mode_supported(pGeode->PanelX, pGeode->PanelY,
+ pMode->CrtcHDisplay, pMode->CrtcVDisplay,
+ pScrni->bitsPerPixel) < 0) {
- ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay,
- pMode->CrtcVDisplay,
- pScrni->bitsPerPixel,
- GeodeGetRefreshRate(pMode));
- if (ret < 0)
- return MODE_BAD;
- }
+ return MODE_BAD;
+ }
+ }
+
+ ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay,
+ pMode->CrtcVDisplay,
+ pScrni->bitsPerPixel, GeodeGetRefreshRate(pMode));
+ if (ret < 0)
+ return MODE_BAD;
+ }
- if (pMode->Flags & V_INTERLACE)
- return MODE_NO_INTERLACE;
+ if (pMode->Flags & V_INTERLACE)
+ return MODE_NO_INTERLACE;
- if (pGeode->tryCompression)
- p = GeodeCalculatePitchBytes(pMode->CrtcHDisplay, pScrni->bitsPerPixel);
- else
- p = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
+ if (pGeode->tryCompression)
+ p = GeodeCalculatePitchBytes(pMode->CrtcHDisplay,
+ pScrni->bitsPerPixel);
+ else
+ p = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
- if (p * pMode->CrtcVDisplay > pGeode->FBAvail)
- return MODE_MEM;
+ if (p * pMode->CrtcVDisplay > pGeode->FBAvail)
+ return MODE_MEM;
- return MODE_OK;
+ return MODE_OK;
}
/* XXX - Way more to do here */
@@ -1482,155 +1481,152 @@ GXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags)
static Bool
GXEnterVT(int scrnIndex, int flags)
{
- return GXEnterGraphics(NULL, xf86Screens[scrnIndex]);
+ return GXEnterGraphics(NULL, xf86Screens[scrnIndex]);
}
static void
GXLeaveVT(int scrnIndex, int flags)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- pGeode->PrevDisplayOffset = gfx_get_display_offset();
- GXLeaveGraphics(xf86Screens[scrnIndex]);
+ pGeode->PrevDisplayOffset = gfx_get_display_offset();
+ GXLeaveGraphics(xf86Screens[scrnIndex]);
}
void
GXSetupChipsetFPtr(ScrnInfoPtr pScrn)
{
- pScrn->PreInit = GXPreInit;
- pScrn->ScreenInit = GXScreenInit;
- pScrn->SwitchMode = GXSwitchMode;
- pScrn->AdjustFrame = GXAdjustFrame;
- pScrn->EnterVT = GXEnterVT;
- pScrn->LeaveVT = GXLeaveVT;
- pScrn->FreeScreen = GeodeFreeScreen;
- pScrn->ValidMode = GXValidMode;
+ pScrn->PreInit = GXPreInit;
+ pScrn->ScreenInit = GXScreenInit;
+ pScrn->SwitchMode = GXSwitchMode;
+ pScrn->AdjustFrame = GXAdjustFrame;
+ pScrn->EnterVT = GXEnterVT;
+ pScrn->LeaveVT = GXLeaveVT;
+ pScrn->FreeScreen = GeodeFreeScreen;
+ pScrn->ValidMode = GXValidMode;
}
/* ====== Common functions ======
* These are all the common functions that we use for both GX and LX - They live here
* because most of them came along for the GX first, and then were adapted to the LX.
* We could move these to a common function, but there is no hurry
- * ============================== */
-
+ * ============================== */
void
GeodePointerMoved(int index, int x, int y)
{
- ScrnInfoPtr pScrni = xf86Screens[index];
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- int newX = x, newY = y;
-
- switch (pGeode->rotation) {
- case RR_Rotate_0:
- break;
- case RR_Rotate_90:
- newX = y;
- newY = pScrni->pScreen->width - x - 1;
- break;
- case RR_Rotate_180:
- newX = pScrni->pScreen->width - x - 1;
- newY = pScrni->pScreen->height - y - 1;
- break;
- case RR_Rotate_270:
- newX = pScrni->pScreen->height - y - 1;
- newY = x;
- break;
- }
-
- (*pGeode->PointerMoved)(index, newX, newY);
+ ScrnInfoPtr pScrni = xf86Screens[index];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ int newX = x, newY = y;
+
+ switch (pGeode->rotation) {
+ case RR_Rotate_0:
+ break;
+ case RR_Rotate_90:
+ newX = y;
+ newY = pScrni->pScreen->width - x - 1;
+ break;
+ case RR_Rotate_180:
+ newX = pScrni->pScreen->width - x - 1;
+ newY = pScrni->pScreen->height - y - 1;
+ break;
+ case RR_Rotate_270:
+ newX = pScrni->pScreen->height - y - 1;
+ newY = x;
+ break;
+ }
+
+ (*pGeode->PointerMoved) (index, newX, newY);
}
void
GeodeProbeDDC(ScrnInfoPtr pScrni, int index)
{
- vbeInfoPtr pVbe;
+ vbeInfoPtr pVbe;
- if (xf86LoadSubModule(pScrni, "vbe")) {
- pVbe = VBEInit(NULL, index);
- ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
- vbeFree(pVbe);
- }
+ if (xf86LoadSubModule(pScrni, "vbe")) {
+ pVbe = VBEInit(NULL, index);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+ vbeFree(pVbe);
+ }
}
xf86MonPtr
GeodeDoDDC(ScrnInfoPtr pScrni, int index)
{
- vbeInfoPtr pVbe;
- xf86MonPtr info = NULL;
-
- if (xf86LoadSubModule(pScrni, "vbe") &&
- (pVbe = VBEInit(NULL, index))) {
- xf86LoaderReqSymLists(amdVbeSymbols, NULL);
- info = vbeDoEDID(pVbe, NULL);
- xf86PrintEDID(info);
- xf86SetDDCproperties(pScrni, info);
- vbeFree(pVbe);
- } else
- xf86DrvMsg(pScrni->scrnIndex, X_INFO,
- "We cannot do DDC without VBE.\n");
+ vbeInfoPtr pVbe;
+ xf86MonPtr info = NULL;
+
+ if (xf86LoadSubModule(pScrni, "vbe") && (pVbe = VBEInit(NULL, index))) {
+ xf86LoaderReqSymLists(amdVbeSymbols, NULL);
+ info = vbeDoEDID(pVbe, NULL);
+ xf86PrintEDID(info);
+ xf86SetDDCproperties(pScrni, info);
+ vbeFree(pVbe);
+ } else
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO,
+ "We cannot do DDC without VBE.\n");
- return info;
+ return info;
}
int
GeodeGetFPGeometry(const char *str, int *width, int *height)
{
- int ret = sscanf(str, "%dx%d", width, height);
+ int ret = sscanf(str, "%dx%d", width, height);
- return (ret == 2) ? 0 : 1;
+ return (ret == 2) ? 0 : 1;
}
static void
GeodeFreeRec(ScrnInfoPtr pScrni)
{
- if (pScrni->driverPrivate != NULL) {
- xfree(pScrni->driverPrivate);
- pScrni->driverPrivate = NULL;
- }
+ if (pScrni->driverPrivate != NULL) {
+ xfree(pScrni->driverPrivate);
+ pScrni->driverPrivate = NULL;
+ }
}
void
GeodeFreeScreen(int scrnIndex, int flags)
{
- GeodeRec *pGeode = GEODEPTR(xf86Screens[scrnIndex]);
+ GeodeRec *pGeode = GEODEPTR(xf86Screens[scrnIndex]);
- if (pGeode == NULL)
- return;
+ if (pGeode == NULL)
+ return;
- if (pGeode->useVGA) {
- if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
- vgaHWFreeHWRec(xf86Screens[scrnIndex]);
- }
+ if (pGeode->useVGA) {
+ if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
+ vgaHWFreeHWRec(xf86Screens[scrnIndex]);
+ }
- GeodeFreeRec(xf86Screens[scrnIndex]);
+ GeodeFreeRec(xf86Screens[scrnIndex]);
}
int
GeodeCalculatePitchBytes(unsigned int width, unsigned int bpp)
{
- int delta = width * (bpp >> 3);
+ int delta = width * (bpp >> 3);
- /* Less then 640 has doubling enabled */
+ /* Less then 640 has doubling enabled */
- if (width < 640)
- delta <<= 1;
+ if (width < 640)
+ delta <<= 1;
- /* Calculate the pitch (compression rquires a power of 2) */
+ /* Calculate the pitch (compression rquires a power of 2) */
- if (delta > 4096)
- delta = 8192;
- else if (delta > 2048)
- delta = 4096;
- else if (delta > 1024)
- delta = 2048;
- else
- delta = 1024;
+ if (delta > 4096)
+ delta = 8192;
+ else if (delta > 2048)
+ delta = 4096;
+ else if (delta > 1024)
+ delta = 2048;
+ else
+ delta = 1024;
- return delta;
+ return delta;
}
-
diff --git a/src/gx_randr.c b/src/gx_randr.c
index 9ab446f..98a86f7 100644
--- a/src/gx_randr.c
+++ b/src/gx_randr.c
@@ -2,7 +2,7 @@
* Copyright (C) 2002 Keith Packard, member of The XFree86 Project, Inc.
* Copyright (c) 2006 Advanced Micro Devices, Inc.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
@@ -60,14 +60,15 @@ typedef struct _GXRandRInfo
#if AMD_OLDPRIV
static int GXRandRIndex;
+
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[GXRandRIndex].ptr)
#else
static DevPrivateKey GXRandRKey;
+
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
dixLookupPrivate(&(p)->devPrivates, GXRandRKey));
-
#endif
static int
@@ -208,7 +209,7 @@ GXRandRSetMode(ScreenPtr pScreen,
* Get the new Screen pixmap ptr as SwitchMode might have called
* ModifyPixmapHeader and xf86EnableDisableFBAccess will put it back...
* Unfortunately.
-
+
*/
pspix = (*pScreen->GetScreenPixmap) (pScreen);
@@ -314,7 +315,6 @@ GXRandRInit(ScreenPtr pScreen, int rotation)
if (GXRandRGeneration != serverGeneration) {
GXRandRGeneration = serverGeneration;
}
-
#if AMD_OLDPRIV
GXRandRIndex = AllocateScreenPrivateIndex();
#else
diff --git a/src/gx_regacc.c b/src/gx_regacc.c
index cd1b429..3156726 100644
--- a/src/gx_regacc.c
+++ b/src/gx_regacc.c
@@ -24,16 +24,16 @@
* */
/*
- * This is the main file used to add Durango graphics support to a software
+ * This is the main file used to add Durango graphics support to a software
* project. The main reason to have a single file include the other files
* is that it centralizes the location of the compiler options. This file
* should be tuned for a specific implementation, and then modified as needed
* for new Durango releases. The releases.txt file indicates any updates to
- * this main file, such as a new definition for a new hardware platform.
+ * this main file, such as a new definition for a new hardware platform.
*
* In other words, this file should be copied from the Durango source files
- * once when a software project starts, and then maintained as necessary.
- * It should not be recopied with new versions of Durango unless the
+ * once when a software project starts, and then maintained as necessary.
+ * It should not be recopied with new versions of Durango unless the
* developer is willing to tune the file again for the specific project.
* */
@@ -171,15 +171,15 @@ gfx_mono_bitmap_to_screen_blt_swp(unsigned short srcx, unsigned short srcy,
offset = (unsigned long)srcy *pitch + ((unsigned long)srcx >> 3);
dstoffset = (unsigned long)dsty *gu2_pitch +
- (((unsigned long)dstx) << gu2_xshift);
+ (((unsigned long)dstx) << gu2_xshift);
/* CHECK IF PATTERN ORIGINS NEED TO BE SET */
if (GFXpatternFlags) {
- /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */
+ /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */
- dstoffset |= ((unsigned long)(dstx & 7)) << 26;
- dstoffset |= ((unsigned long)(dsty & 7)) << 29;
+ dstoffset |= ((unsigned long)(dstx & 7)) << 26;
+ dstoffset |= ((unsigned long)(dsty & 7)) << 29;
}
bytes = ((srcx & 7) + width + 7) >> 3;
@@ -200,7 +200,7 @@ gfx_mono_bitmap_to_screen_blt_swp(unsigned short srcx, unsigned short srcy,
WRITE_GP32(MGP_WID_HEIGHT, size);
WRITE_GP32(MGP_STRIDE, gu2_pitch);
WRITE_GP16(MGP_BLT_MODE,
- gu2_blt_mode | MGP_BM_SRC_HOST | MGP_BM_SRC_MONO);
+ gu2_blt_mode | MGP_BM_SRC_HOST | MGP_BM_SRC_MONO);
/* WAIT FOR BLT TO BE LATCHED */
@@ -209,34 +209,34 @@ gfx_mono_bitmap_to_screen_blt_swp(unsigned short srcx, unsigned short srcy,
/* WRITE ALL OF THE DATA TO THE HOST SOURCE REGISTER */
while (height--) {
- temp_offset = offset;
+ temp_offset = offset;
- /* WRITE ALL FULL FIFO LINES */
+ /* WRITE ALL FULL FIFO LINES */
- for (i = 0; i < fifo_lines; i++) {
- GU2_WAIT_HALF_EMPTY;
- WRITE_GPREG_STRING32_SWP(MGP_HST_SOURCE, 8, j, data, temp_offset,
- temp1);
- temp_offset += 32;
- }
+ for (i = 0; i < fifo_lines; i++) {
+ GU2_WAIT_HALF_EMPTY;
+ WRITE_GPREG_STRING32_SWP(MGP_HST_SOURCE, 8, j, data, temp_offset,
+ temp1);
+ temp_offset += 32;
+ }
- /* WRITE ALL FULL DWORDS */
+ /* WRITE ALL FULL DWORDS */
- GU2_WAIT_HALF_EMPTY;
- if (dwords_extra) {
- WRITE_GPREG_STRING32_SWP(MGP_HST_SOURCE, dwords_extra, i, data,
- temp_offset, temp1);
- temp_offset += (dwords_extra << 2);
- }
+ GU2_WAIT_HALF_EMPTY;
+ if (dwords_extra) {
+ WRITE_GPREG_STRING32_SWP(MGP_HST_SOURCE, dwords_extra, i, data,
+ temp_offset, temp1);
+ temp_offset += (dwords_extra << 2);
+ }
- /* WRITE REMAINING BYTES */
+ /* WRITE REMAINING BYTES */
- shift = 0;
- if (bytes_extra)
- WRITE_GPREG_STRING8(MGP_HST_SOURCE, bytes_extra, shift, i, data,
- temp_offset, temp1, temp2);
+ shift = 0;
+ if (bytes_extra)
+ WRITE_GPREG_STRING8(MGP_HST_SOURCE, bytes_extra, shift, i, data,
+ temp_offset, temp1, temp2);
- offset += pitch;
+ offset += pitch;
}
}
@@ -260,37 +260,37 @@ GetVideoMemSize(void)
/* Calculate total memory size for GXm. */
for (i = 0; i < 2; i++) {
- if (((mcBankCfg >> dimmShift) & 0x7) != 0x7) {
- switch ((mcBankCfg >> (dimmShift + 4)) & 0x7) {
- case 0:
- totalMem += 0x400000;
- break;
- case 1:
- totalMem += 0x800000;
- break;
- case 2:
- totalMem += 0x1000000;
- break;
- case 3:
- totalMem += 0x2000000;
- break;
- case 4:
- totalMem += 0x4000000;
- break;
- case 5:
- totalMem += 0x8000000;
- break;
- case 6:
- totalMem += 0x10000000;
- break;
- case 7:
- totalMem += 0x20000000;
- break;
- default:
- break;
- }
- }
- dimmShift += 16;
+ if (((mcBankCfg >> dimmShift) & 0x7) != 0x7) {
+ switch ((mcBankCfg >> (dimmShift + 4)) & 0x7) {
+ case 0:
+ totalMem += 0x400000;
+ break;
+ case 1:
+ totalMem += 0x800000;
+ break;
+ case 2:
+ totalMem += 0x1000000;
+ break;
+ case 3:
+ totalMem += 0x2000000;
+ break;
+ case 4:
+ totalMem += 0x4000000;
+ break;
+ case 5:
+ totalMem += 0x8000000;
+ break;
+ case 6:
+ totalMem += 0x10000000;
+ break;
+ case 7:
+ totalMem += 0x20000000;
+ break;
+ default:
+ break;
+ }
+ }
+ dimmShift += 16;
}
/* Calculate graphics memory base address */
diff --git a/src/gx_rotate.c b/src/gx_rotate.c
index b689da2..e473a34 100644
--- a/src/gx_rotate.c
+++ b/src/gx_rotate.c
@@ -1,5 +1,5 @@
/* Copyrightg (c) 2006 Advanced Micro Devices, Inc.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
@@ -157,31 +157,31 @@ GXRotate(ScrnInfoPtr pScrni, DisplayModePtr mode)
/* Don't use XAA pixmap cache or offscreen pixmaps when rotated */
if (pGeode->AccelInfoRec) {
- if (pGeode->rotation == RR_Rotate_0) {
- pGeode->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE;
- pGeode->AccelInfoRec->UsingPixmapCache = TRUE;
- pGeode->AccelInfoRec->maxOffPixWidth = 0;
- pGeode->AccelInfoRec->maxOffPixHeight = 0;
- }
- else {
- pGeode->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER;
- pGeode->AccelInfoRec->UsingPixmapCache = FALSE;
- pGeode->AccelInfoRec->maxOffPixWidth = 1;
- pGeode->AccelInfoRec->maxOffPixHeight = 1;
- }
+ if (pGeode->rotation == RR_Rotate_0) {
+ pGeode->AccelInfoRec->Flags =
+ LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE;
+ pGeode->AccelInfoRec->UsingPixmapCache = TRUE;
+ pGeode->AccelInfoRec->maxOffPixWidth = 0;
+ pGeode->AccelInfoRec->maxOffPixHeight = 0;
+ } else {
+ pGeode->AccelInfoRec->Flags = LINEAR_FRAMEBUFFER;
+ pGeode->AccelInfoRec->UsingPixmapCache = FALSE;
+ pGeode->AccelInfoRec->maxOffPixWidth = 1;
+ pGeode->AccelInfoRec->maxOffPixHeight = 1;
+ }
}
return TRUE;
-error:
+ error:
/* Restore the old rotation */
pScrni->displayWidth = curdw;
if (curr & (RR_Rotate_0 | RR_Rotate_180)) {
- pScrni->pScreen->width = pScrni->virtualX;
- pScrni->pScreen->height = pScrni->virtualY;
+ pScrni->pScreen->width = pScrni->virtualX;
+ pScrni->pScreen->height = pScrni->virtualY;
} else {
- pScrni->pScreen->width = pScrni->virtualY;
+ pScrni->pScreen->width = pScrni->virtualY;
pScrni->pScreen->height = pScrni->virtualX;
}
diff --git a/src/gx_shadow.c b/src/gx_shadow.c
deleted file mode 100644
index 436a46a..0000000
--- a/src/gx_shadow.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/* Copyright (c) 2003-2005 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Neither the name of the Advanced Micro Devices, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- * */
-
-/*
- * File Contents: Direct graphics display routines are implemented and
- * graphics rendering are all done in memory.
- *
- * Project: Geode Xfree Frame buffer device driver.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "xf86Resources.h"
-#include "xf86PciInfo.h"
-#include "xf86Pci.h"
-#include "geode.h"
-#include "shadowfb.h"
-#include "servermd.h"
-
-#define CLIP(sip,bp,u1,v1,u2,v2) \
- u1 = bp->x1; v1 = bp->y1; \
- u2 = bp->x2; v2 = bp->y2; \
- if ( u1 < 0 ) \
- u1 = 0; \
- if ( v1 < 0 ) \
- v1 = 0; \
- if ( u1 > sip->virtualX ) \
- u1 = sip->virtualX; \
- if ( v1 > sip->virtualY ) \
- v1 = sip->virtualY; \
- if ( u2 < 0 ) \
- u2 = 0; \
- if ( v2 < 0 ) \
- v2 = 0; \
- if ( u2 > sip->virtualX ) \
- u2 = sip->virtualX; \
- if ( v2 > sip->virtualY ) \
- v2 = sip->virtualY;
-
-void GXAccelSync(ScrnInfoPtr pScrni);
-
-void
-GXRotation0(int x, int y, int w, int h, int *newX, int *newY)
-{
- *newX = x;
- *newY = y;
-}
-
-void
-GXRotation1(int x, int y, int w, int h, int *newX, int *newY)
-{
- *newX = (h - 1) - y;
- *newY = x;
-}
-
-void
-GXRotation2(int x, int y, int w, int h, int *newX, int *newY)
-{
- *newX = (w - 1) - x;
- *newY = (h - 1) - y;
-}
-
-void
-GXRotation3(int x, int y, int w, int h, int *newX, int *newY)
-{
- *newY = (w - 1) - x;
- *newX = y;
-}
-
-void
-GXRBltXlat0(int x, int y, int w, int h, int *newX, int *newY)
-{
- *newX = x;
- *newY = y;
-}
-
-void
-GXRBltXlat1(int x, int y, int w, int h, int *newX, int *newY)
-{
- *newX = x - (h - 1);
- *newY = y;
-}
-
-void
-GXRBltXlat2(int x, int y, int w, int h, int *newX, int *newY)
-{
- *newX = x - (w - 1);
- *newY = y - (h - 1);
-}
-
-void
-GXRBltXlat3(int x, int y, int w, int h, int *newX, int *newY)
-{
- *newX = x;
- *newY = y - (w - 1);
-}
-
-/*----------------------------------------------------------------------------
- * GXPointerMoved.
- *
- * Description :This function moves one screen memory from one area to other.
- *
- * Parameters.
- * index :Pointer to screen index.
- * x :Specifies the new x co-ordinates of new area.
- * y :Specifies the new y co-ordinates of new area.
- * Returns :none
- *
- * Comments :none
- *
- *----------------------------------------------------------------------------
- */
-void
-GXPointerMoved(int index, int x, int y)
-{
- ScrnInfoPtr pScrni = xf86Screens[index];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- Bool frameChanged = FALSE;
-
- if (x < 0)
- x = 0;
- else if (x >= pScrni->virtualX)
- x = pScrni->virtualX - 1;
-
- if (y < 0)
- y = 0;
- else if (y >= pScrni->virtualY)
- y = pScrni->virtualY - 1;
-
- if (pScrni->frameX0 > x) {
- pScrni->frameX0 = x;
- pScrni->frameX1 = x + pGeode->HDisplay - 1;
- frameChanged = TRUE;
- }
-
- if (pScrni->frameX1 < x) {
- pScrni->frameX1 = x + 1;
- pScrni->frameX0 = x - pGeode->HDisplay + 1;
- frameChanged = TRUE;
- }
-
- if (pScrni->frameY0 > y) {
- pScrni->frameY0 = y;
- pScrni->frameY1 = y + pGeode->VDisplay - 1;
- frameChanged = TRUE;
- }
-
- if (pScrni->frameY1 < y) {
- pScrni->frameY1 = y;
- pScrni->frameY0 = y - pGeode->VDisplay + 1;
- frameChanged = TRUE;
- }
-
- if (frameChanged && pScrni->AdjustFrame != NULL)
- pScrni->AdjustFrame(pScrni->scrnIndex, pScrni->frameX0,
- pScrni->frameY0, 0);
-}
-
-void
-GXRefreshArea_Cpy(ScrnInfoPtr pScrni, int num, BoxPtr pbox)
-{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int x1, y1, x2, y2, width, height;
- unsigned long src, dst;
- int Bpp = pScrni->bitsPerPixel >> 3;
-
- gfx_set_raster_operation(0xcc); /* copy dst=src */
- for (; --num >= 0; ++pbox) {
- CLIP(pScrni, pbox, x1, y1, x2, y2);
- if ((width = x2 - x1) <= 0 || (height = y2 - y1) <= 0)
- continue;
-
- src = y1 * pGeode->ShadowPitch + x1 * Bpp;
- dst = pGeode->FBOffset + y1 * pGeode->Pitch + x1 * Bpp;
- gfx2_set_destination_stride(pGeode->Pitch);
- gfx2_color_bitmap_to_screen_blt(0, 0, dst, width, height,
- pGeode->ShadowPtr + src, pGeode->ShadowPitch);
- }
-}
-
-/*----------------------------------------------------------------------------
- * GXRefreshArea8.
- *
- * Description :This function copies the memory to be displayed from the
- * shadow pointer by 8bpp.
- * Parameters.
- * pScrni :Pointer to ScrnInfo structure.
- * num :Specifies the num of squarebox area to be displayed.
- * pbox :Points to square of memory to be displayed.
- *
- * Returns :none
- *
- * Comments :none
- *
- *----------------------------------------------------------------------------
- */
-void
-GXRefreshArea0_Cpu(ScrnInfoPtr pScrni, int num, BoxPtr pbox)
-{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int width, height, x1, y1, x2, y2;
- unsigned char *src, *dst;
- int Bpp = pScrni->bitsPerPixel >> 3;
-
- GXAccelSync(pScrni);
- for (; --num >= 0; ++pbox) {
- CLIP(pScrni, pbox, x1, y1, x2, y2);
- if ((width = x2 - x1) <= 0 || (height = y2 - y1) <= 0)
- continue;
-
- src = pGeode->ShadowPtr + y1 * pGeode->ShadowPitch + x1 * Bpp;
- dst =
- pGeode->FBBase + pGeode->FBOffset + y1 * pGeode->Pitch + x1 * Bpp;
- width *= Bpp;
- while (--height >= 0) {
- memcpy(dst, src, width);
- dst += pGeode->Pitch;
- src += pGeode->ShadowPitch;
- }
- }
-}
-
-#define RefreshArea1_Cpu(nm,typ) \
-void GXRefreshArea1_Cpu##nm(ScrnInfoPtr pScrni, int num, BoxPtr pbox) \
-{ \
- GeodeRec *pGeode = GEODEPTR(pScrni); \
- int l, width, height, x1, y1, x2, y2, newX, newY; \
- unsigned long src, dst, dp; \
- typ *sp; \
- GXAccelSync(pScrni); \
- for( ; --num>=0; ++pbox ) { \
- CLIP(pScrni,pbox,x1,y1,x2,y2); \
- if( (width=x2-x1) <=0 || (height=y2-y1) <= 0 ) \
- continue; \
- src = y1*pGeode->ShadowPitch + x1*sizeof(typ); \
- newX = pScrni->virtualY-1 - y1; \
- newY = x1; \
- dst = pGeode->FBOffset + newY*pGeode->Pitch + newX*sizeof(typ); \
- while( --height >= 0 ) { \
- sp = (typ *)(pGeode->ShadowPtr + src); \
- dp = (unsigned long)(pGeode->FBBase + dst); \
- for( l=width; --l>=0; ) { \
- *(typ *)dp = *sp++; \
- dp += pGeode->Pitch; \
- } \
- dst -= sizeof(typ); \
- src += pGeode->ShadowPitch; \
- } \
- } \
-}
-
-RefreshArea1_Cpu(8, unsigned char)
-RefreshArea1_Cpu(16, unsigned short)
-RefreshArea1_Cpu(32, unsigned int)
-#define RefreshArea2_Cpu(nm,typ) \
-void GXRefreshArea2_Cpu##nm(ScrnInfoPtr pScrni, int num, BoxPtr pbox) \
-{ \
- GeodeRec *pGeode = GEODEPTR(pScrni); \
- int l, width, height, x1, y1, x2, y2, newX, newY; \
- unsigned long src, dst, dp; \
- typ *sp; \
- GXAccelSync(pScrni); \
- for( ; --num>=0; ++pbox ) { \
- CLIP(pScrni,pbox,x1,y1,x2,y2); \
- if( (width=x2-x1) <=0 || (height=y2-y1) <= 0 ) \
- continue; \
- src = y1*pGeode->ShadowPitch + x1*sizeof(typ); \
- newX = pScrni->virtualX-1 - x1; \
- newY = pScrni->virtualY-1 - y1; \
- dst = pGeode->FBOffset + newY*pGeode->Pitch + newX*sizeof(typ); \
- while( --height >= 0 ) { \
- sp = (typ *)(pGeode->ShadowPtr + src); \
- dp = (unsigned long)(pGeode->FBBase + dst); \
- for( l=width; --l>=0; ) { \
- *(typ *)dp = *sp++; \
- dp -= sizeof(typ); \
- } \
- src += pGeode->ShadowPitch; \
- dst -= pGeode->Pitch; \
- } \
- } \
-}
-RefreshArea2_Cpu(8, unsigned char)
-RefreshArea2_Cpu(16, unsigned short)
-RefreshArea2_Cpu(32, unsigned int)
-#define RefreshArea3_Cpu(nm,typ) \
-void GXRefreshArea3_Cpu##nm(ScrnInfoPtr pScrni, int num, BoxPtr pbox) \
-{ \
- GeodeRec *pGeode = GEODEPTR(pScrni); \
- int l, width, height, x1, y1, x2, y2, newX, newY; \
- unsigned long src, dst, dp; \
- typ *sp; \
- GXAccelSync(pScrni); \
- for( ; --num>=0; ++pbox ) { \
- CLIP(pScrni,pbox,x1,y1,x2,y2); \
- if( (width=x2-x1) <=0 || (height=y2-y1) <= 0 ) \
- continue; \
- src = y1*pGeode->ShadowPitch + x1*sizeof(typ); \
- newX = y1; \
- newY = pScrni->virtualX-1 - x1; \
- dst = pGeode->FBOffset + newY*pGeode->Pitch + newX*sizeof(typ); \
- while( --height >= 0 ) { \
- sp = (typ *)(pGeode->ShadowPtr + src); \
- dp = (unsigned long)(pGeode->FBBase + dst); \
- for( l=width; --l>=0; ) { \
- *(typ *)dp = *sp++; \
- dp -= pGeode->Pitch; \
- } \
- dst += sizeof(typ); \
- src += pGeode->ShadowPitch; \
- } \
- } \
-}
-RefreshArea3_Cpu(8, unsigned char)
-RefreshArea3_Cpu(16, unsigned short)
-RefreshArea3_Cpu(32, unsigned int)
-
- void GXRotationInit(ScrnInfoPtr pScrni)
-{
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- switch (pGeode->Rotate) {
- case 1:
- pGeode->Rotation = GXRotation1;
- pGeode->RBltXlat = GXRBltXlat1;
- break;
- case 2:
- pGeode->Rotation = GXRotation2;
- pGeode->RBltXlat = GXRBltXlat2;
- break;
- case 3:
- pGeode->Rotation = GXRotation3;
- pGeode->RBltXlat = GXRBltXlat3;
- break;
- default:
- pGeode->Rotation = GXRotation0;
- pGeode->RBltXlat = GXRBltXlat0;
- break;
- }
-}
-
-void
-GXShadowFBInit(ScreenPtr pScrn, GeodeRec *pGeode, int bytpp)
-{
- RefreshAreaFuncPtr refreshArea;
-
- switch (bytpp) {
- case 2:
- switch (pGeode->Rotate) {
- case 1:
- refreshArea = GXRefreshArea1_Cpu16;
- break;
- case 2:
- refreshArea = GXRefreshArea2_Cpu16;
- break;
- case 3:
- refreshArea = GXRefreshArea3_Cpu16;
- break;
- default:
- refreshArea = GXRefreshArea0_Cpu;
- break;
- }
- break;
- case 4:
- switch (pGeode->Rotate) {
- case 1:
- refreshArea = GXRefreshArea1_Cpu32;
- break;
- case 2:
- refreshArea = GXRefreshArea2_Cpu32;
- break;
- case 3:
- refreshArea = GXRefreshArea3_Cpu32;
- break;
- default:
- refreshArea = GXRefreshArea0_Cpu;
- break;
- }
- break;
- default:
- switch (pGeode->Rotate) {
- case 1:
- refreshArea = GXRefreshArea1_Cpu8;
- break;
- case 2:
- refreshArea = GXRefreshArea2_Cpu8;
- break;
- case 3:
- refreshArea = GXRefreshArea3_Cpu8;
- break;
- default:
- refreshArea = GXRefreshArea0_Cpu;
- break;
- }
- break;
- }
- ShadowFBInit(pScrn, refreshArea);
-}
-
-/* End of file */
diff --git a/src/gx_vga.c b/src/gx_vga.c
index b46675a..e5d6427 100644
--- a/src/gx_vga.c
+++ b/src/gx_vga.c
@@ -24,7 +24,7 @@
* */
/*
- * This file contains routines to set modes using the VGA registers.
+ * This file contains routines to set modes using the VGA registers.
* Since this file is for the first generation graphics unit, it interfaces
* to SoftVGA registers. It works for both VSA1 and VSA2.
* */
@@ -57,7 +57,7 @@ static unsigned int palette[256];
static unsigned int ATTRregs[32];
static unsigned char *font_data = NULL;
-#define VGA_BLOCK 0x40000 /* 256 k */
+#define VGA_BLOCK 0x40000 /* 256 k */
void gu2_vga_extcrtc(char offset, int reset);
int gu2_get_vga_active(void);
@@ -78,7 +78,7 @@ gu2_get_vga_active(void)
int data = gfx_read_reg32(MDC_GENERAL_CFG);
if (data & MDC_GCFG_VGAE)
- return 1;
+ return 1;
return 0;
}
@@ -87,17 +87,17 @@ void
gu2_vga_font_data(int flag)
{
if (flag == 0) {
- if (font_data == NULL) {
- font_data = malloc(VGA_BLOCK);
- }
+ if (font_data == NULL) {
+ font_data = malloc(VGA_BLOCK);
+ }
- DEBUGMSG(1, (0, X_NONE, "Saving VGA Data\n"));
- memcpy(font_data, gfx_virt_fbptr, VGA_BLOCK);
+ DEBUGMSG(1, (0, X_NONE, "Saving VGA Data\n"));
+ memcpy(font_data, gfx_virt_fbptr, VGA_BLOCK);
} else if (font_data) {
- DEBUGMSG(1, (0, X_NONE, "Restore VGA Data\n"));
- memcpy(gfx_virt_fbptr, font_data, VGA_BLOCK);
- free(font_data);
- font_data = NULL;
+ DEBUGMSG(1, (0, X_NONE, "Restore VGA Data\n"));
+ memcpy(gfx_virt_fbptr, font_data, VGA_BLOCK);
+ free(font_data);
+ font_data = NULL;
}
}
@@ -107,9 +107,9 @@ gu2_set_vga(int reset)
int data = gfx_read_reg32(MDC_GENERAL_CFG);
if (reset)
- data |= MDC_GCFG_VGAE;
+ data |= MDC_GCFG_VGAE;
else
- data &= ~MDC_GCFG_VGAE;
+ data &= ~MDC_GCFG_VGAE;
gfx_write_reg32(MDC_GENERAL_CFG, data);
}
@@ -137,7 +137,7 @@ gu2_vga_attr_ctrl(int reset)
tmp = gfx_inb(0x3DA);
gfx_outb(0x3C0, (unsigned char)(reset ? 0x00 : 0x20));
if (reset)
- tmp = gfx_inb(0x3DA);
+ tmp = gfx_inb(0x3DA);
return (GFX_STATUS_OK);
}
@@ -184,9 +184,9 @@ gu2_gfx_to_vga(int vga_mode)
/*---------------------------------------------------------------------------
* gfx_vga_seq_reset
*
- * This routine enables or disables SoftVGA. It is used to make SoftVGA
- * "be quiet" and not interfere with any of the direct hardware access from
- * Durango. For VSA1, the sequencer is reset to stop text redraws. VSA2 may
+ * This routine enables or disables SoftVGA. It is used to make SoftVGA
+ * "be quiet" and not interfere with any of the direct hardware access from
+ * Durango. For VSA1, the sequencer is reset to stop text redraws. VSA2 may
* provide a better way to have SoftVGA sit in the background.
*---------------------------------------------------------------------------
*/
@@ -201,8 +201,8 @@ gu2_vga_seq_reset(int reset)
/*---------------------------------------------------------------------------
* gfx_vga_save
*
- * This routine saves the state of the VGA registers into the specified
- * structure. Flags indicate what portions of the register state need to
+ * This routine saves the state of the VGA registers into the specified
+ * structure. Flags indicate what portions of the register state need to
* be saved.
*----------------------------------------------------------------------------
*/
@@ -218,65 +218,65 @@ gu2_vga_save(gfx_vga_struct * vga, int flags)
/* CHECK MISCELLANEOUS OUTPUT FLAG */
if (flags & GU2_VGA_FLAG_MISC_OUTPUT) {
- /* SAVE MISCCELLANEOUS OUTPUT REGISTER */
- vga->miscOutput = gfx_inb(0x3CC);
+ /* SAVE MISCCELLANEOUS OUTPUT REGISTER */
+ vga->miscOutput = gfx_inb(0x3CC);
}
/* CHECK SEQ */
if (flags & GU2_VGA_FLAG_SEQ) {
- /* SAVE STANDARD CRTC REGISTERS */
- for (i = 1; i < GU2_SEQ_REGS; i++) {
- gfx_outb(0x3C4, (unsigned char)i);
- SEQregs[i] = gfx_inb(0x3C5);
- }
+ /* SAVE STANDARD CRTC REGISTERS */
+ for (i = 1; i < GU2_SEQ_REGS; i++) {
+ gfx_outb(0x3C4, (unsigned char)i);
+ SEQregs[i] = gfx_inb(0x3C5);
+ }
}
/* CHECK STANDARD CRTC FLAG */
if (flags & GU2_VGA_FLAG_STD_CRTC) {
- /* SAVE STANDARD CRTC REGISTERS */
- for (i = 0; i < GU2_STD_CRTC_REGS; i++) {
- gfx_outb(crtcindex, (unsigned char)i);
- vga->stdCRTCregs[i] = gfx_inb(crtcdata);
- }
+ /* SAVE STANDARD CRTC REGISTERS */
+ for (i = 0; i < GU2_STD_CRTC_REGS; i++) {
+ gfx_outb(crtcindex, (unsigned char)i);
+ vga->stdCRTCregs[i] = gfx_inb(crtcdata);
+ }
}
/* CHECK GDC */
if (flags & GU2_VGA_FLAG_GDC) {
- /* SAVE STANDARD CRTC REGISTERS */
- for (i = 0; i < GU2_GDC_REGS; i++) {
- gfx_outb(0x3CE, (unsigned char)i);
- GDCregs[i] = gfx_inb(0x3CF);
- }
+ /* SAVE STANDARD CRTC REGISTERS */
+ for (i = 0; i < GU2_GDC_REGS; i++) {
+ gfx_outb(0x3CE, (unsigned char)i);
+ GDCregs[i] = gfx_inb(0x3CF);
+ }
}
/* CHECK EXTENDED CRTC FLAG */
if (flags & GU2_VGA_FLAG_EXT_CRTC) {
- /* SAVE EXTENDED CRTC REGISTERS */
- for (i = 0; i < GU2_EXT_CRTC_REGS; i++) {
- gfx_outb(crtcindex, (unsigned char)(0x40 + i));
- vga->extCRTCregs[i] = gfx_inb(crtcdata);
- }
+ /* SAVE EXTENDED CRTC REGISTERS */
+ for (i = 0; i < GU2_EXT_CRTC_REGS; i++) {
+ gfx_outb(crtcindex, (unsigned char)(0x40 + i));
+ vga->extCRTCregs[i] = gfx_inb(crtcdata);
+ }
}
if (flags & GU2_VGA_FLAG_PALETTE) {
- /* SAVE PALETTE DATA */
- for (i = 0; i < 0x100; i++) {
- gfx_outb(0x3C7, i);
- palette[i] = gfx_inb(0x3C9);
- }
+ /* SAVE PALETTE DATA */
+ for (i = 0; i < 0x100; i++) {
+ gfx_outb(0x3C7, i);
+ palette[i] = gfx_inb(0x3C9);
+ }
}
if (flags & GU2_VGA_FLAG_ATTR) {
- /* SAVE Attribute DATA */
- for (i = 0; i < 21; i++) {
- gfx_inb(0x3DA);
- gfx_outb(0x3C0, i);
- ATTRregs[i] = gfx_inb(0x3C1);
- }
+ /* SAVE Attribute DATA */
+ for (i = 0; i < 21; i++) {
+ gfx_inb(0x3DA);
+ gfx_outb(0x3C0, i);
+ ATTRregs[i] = gfx_inb(0x3C1);
+ }
}
/* save the VGA data */
@@ -288,7 +288,7 @@ gu2_vga_save(gfx_vga_struct * vga, int flags)
* gfx_vga_clear_extended
*
* This routine clears the extended SoftVGA register values to have SoftVGA
- * behave like standard VGA.
+ * behave like standard VGA.
*----------------------------------------------------------------------------
*/
void
@@ -304,8 +304,8 @@ gu2_vga_clear_extended(void)
gfx_outb(crtcdata, 0x57);
gfx_outb(crtcdata, 0x4C);
for (i = 0x41; i <= 0x4F; i++) {
- gfx_outb(crtcindex, (unsigned char)i);
- gfx_outb(crtcdata, 0);
+ gfx_outb(crtcindex, (unsigned char)i);
+ gfx_outb(crtcdata, 0);
}
gfx_outb(crtcindex, 0x30);
@@ -336,7 +336,7 @@ gu2_vga_extcrtc(char offset, int reset)
* gfx_vga_restore
*
* This routine restores the state of the VGA registers from the specified
- * structure. Flags indicate what portions of the register state need to
+ * structure. Flags indicate what portions of the register state need to
* be saved.
*----------------------------------------------------------------------------
*/
@@ -352,100 +352,100 @@ gu2_vga_restore(gfx_vga_struct * vga, int flags)
/* CHECK MISCELLANEOUS OUTPUT FLAG */
if (flags & GU2_VGA_FLAG_MISC_OUTPUT) {
- /* RESTORE MISCELLANEOUS OUTPUT REGISTER VALUE */
- gfx_outb(0x3C2, vga->miscOutput);
+ /* RESTORE MISCELLANEOUS OUTPUT REGISTER VALUE */
+ gfx_outb(0x3C2, vga->miscOutput);
}
/* CHECK SEQ */
if (flags & GU2_VGA_FLAG_SEQ) {
- /* RESTORE STANDARD CRTC REGISTERS */
- for (i = 1; i < GU2_SEQ_REGS; i++) {
- gfx_outb(0x3C4, (unsigned char)i);
- gfx_outb(0x3C5, SEQregs[i]);
- }
+ /* RESTORE STANDARD CRTC REGISTERS */
+ for (i = 1; i < GU2_SEQ_REGS; i++) {
+ gfx_outb(0x3C4, (unsigned char)i);
+ gfx_outb(0x3C5, SEQregs[i]);
+ }
}
/* CHECK STANDARD CRTC FLAG */
if (flags & GU2_VGA_FLAG_STD_CRTC) {
- /* UNLOCK STANDARD CRTC REGISTERS */
- gfx_outb(crtcindex, 0x11);
- gfx_outb(crtcdata, 0);
+ /* UNLOCK STANDARD CRTC REGISTERS */
+ gfx_outb(crtcindex, 0x11);
+ gfx_outb(crtcdata, 0);
- /* RESTORE STANDARD CRTC REGISTERS */
+ /* RESTORE STANDARD CRTC REGISTERS */
- for (i = 0; i < GU2_STD_CRTC_REGS; i++) {
- gfx_outb(crtcindex, (unsigned char)i);
- gfx_outb(crtcdata, vga->stdCRTCregs[i]);
- }
+ for (i = 0; i < GU2_STD_CRTC_REGS; i++) {
+ gfx_outb(crtcindex, (unsigned char)i);
+ gfx_outb(crtcdata, vga->stdCRTCregs[i]);
+ }
}
/* CHECK GDC */
if (flags & GU2_VGA_FLAG_GDC) {
- /* SAVE STANDARD CRTC REGISTERS */
- for (i = 0; i < GU2_GDC_REGS; i++) {
- gfx_outb(0x3CE, (unsigned char)i);
- gfx_outb(0x3CF, GDCregs[i]);
- }
+ /* SAVE STANDARD CRTC REGISTERS */
+ for (i = 0; i < GU2_GDC_REGS; i++) {
+ gfx_outb(0x3CE, (unsigned char)i);
+ gfx_outb(0x3CF, GDCregs[i]);
+ }
}
/* CHECK EXTENDED CRTC FLAG */
if (flags & GU2_VGA_FLAG_EXT_CRTC) {
- /* UNLOCK EXTENDED CRTC REGISTERS */
- gfx_outb(crtcindex, 0x30);
- gfx_outb(crtcdata, 0x57);
- gfx_outb(crtcdata, 0x4C);
+ /* UNLOCK EXTENDED CRTC REGISTERS */
+ gfx_outb(crtcindex, 0x30);
+ gfx_outb(crtcdata, 0x57);
+ gfx_outb(crtcdata, 0x4C);
- /* RESTORE EXTENDED CRTC REGISTERS */
+ /* RESTORE EXTENDED CRTC REGISTERS */
- for (i = 1; i < GU2_EXT_CRTC_REGS; i++) {
- gfx_outb(crtcindex, (unsigned char)(0x40 + i));
- gfx_outb(crtcdata, vga->extCRTCregs[i]);
- }
+ for (i = 1; i < GU2_EXT_CRTC_REGS; i++) {
+ gfx_outb(crtcindex, (unsigned char)(0x40 + i));
+ gfx_outb(crtcdata, vga->extCRTCregs[i]);
+ }
- /* LOCK EXTENDED CRTC REGISTERS */
+ /* LOCK EXTENDED CRTC REGISTERS */
- gfx_outb(crtcindex, 0x30);
- gfx_outb(crtcdata, 0x00);
+ gfx_outb(crtcindex, 0x30);
+ gfx_outb(crtcdata, 0x00);
- /* CHECK IF DIRECT FRAME BUFFER MODE (VESA MODE) */
+ /* CHECK IF DIRECT FRAME BUFFER MODE (VESA MODE) */
- if (vga->extCRTCregs[0x03] & 1) {
- /* SET BORDER COLOR TO BLACK */
- /* This really should be another thing saved/restored, but */
- /* Durango currently doesn't do the attr controller registers. */
+ if (vga->extCRTCregs[0x03] & 1) {
+ /* SET BORDER COLOR TO BLACK */
+ /* This really should be another thing saved/restored, but */
+ /* Durango currently doesn't do the attr controller registers. */
- gfx_inb(0x3BA); /* Reset flip-flop */
- gfx_inb(0x3DA);
- gfx_outb(0x3C0, 0x11);
- gfx_outb(0x3C0, 0x00);
- }
+ gfx_inb(0x3BA); /* Reset flip-flop */
+ gfx_inb(0x3DA);
+ gfx_outb(0x3C0, 0x11);
+ gfx_outb(0x3C0, 0x00);
+ }
}
if (flags & GU2_VGA_FLAG_PALETTE) {
- /* RESTORE PALETTE DATA */
- for (i = 0; i < 0x100; i++) {
- gfx_outb(0x3C8, i);
- gfx_outb(0x3C9, palette[i]);
- }
+ /* RESTORE PALETTE DATA */
+ for (i = 0; i < 0x100; i++) {
+ gfx_outb(0x3C8, i);
+ gfx_outb(0x3C9, palette[i]);
+ }
}
if (flags & GU2_VGA_FLAG_ATTR) {
- /* RESTORE Attribute DATA */
- for (i = 0; i < 21; i++) {
- gfx_inb(0x3DA);
- gfx_outb(0x3C0, i);
- gfx_outb(0x3C0, ATTRregs[i]);
- }
- /* SAVE Attribute DATA */
-
- for (i = 0; i < 21; i++) {
- gfx_inb(0x3DA);
- gfx_outb(0x3C0, i);
- }
+ /* RESTORE Attribute DATA */
+ for (i = 0; i < 21; i++) {
+ gfx_inb(0x3DA);
+ gfx_outb(0x3C0, i);
+ gfx_outb(0x3C0, ATTRregs[i]);
+ }
+ /* SAVE Attribute DATA */
+
+ for (i = 0; i < 21; i++) {
+ gfx_inb(0x3DA);
+ gfx_outb(0x3C0, i);
+ }
}
/* restore the VGA data */
diff --git a/src/gx_video.c b/src/gx_video.c
index 7d2f0f4..aecb0ff 100644
--- a/src/gx_video.c
+++ b/src/gx_video.c
@@ -29,8 +29,8 @@
* Project: Geode Xfree Frame buffer device driver.
* */
-/*
- * Fixes & Extensions to support Y800 greyscale modes
+/*
+ * Fixes & Extensions to support Y800 greyscale modes
* Alan Hourihane <alanh@fairlite.demon.co.uk>
* code to allocate offscreen memory from EXA - is borrowed from Radeon
@@ -128,24 +128,26 @@ static Atom xvColorKey, xvColorKeyMode, xvFilter
#define DISPLAY_CONFIG 0x008
#define MISC 0x050
-static void get_gamma_ram(unsigned long *lut) {
+static void
+get_gamma_ram(unsigned long *lut)
+{
- int i;
+ int i;
- gfx_write_vid32(PALETTE_ADDRESS, 0);
+ gfx_write_vid32(PALETTE_ADDRESS, 0);
- for(i = 0; i < 256; i++)
- lut[i] = gfx_read_vid32(PALETTE_DATA);
+ for (i = 0; i < 256; i++)
+ lut[i] = gfx_read_vid32(PALETTE_DATA);
}
/*----------------------------------------------------------------------------
* GXInitVideo
*
- * Description :This is the initialization routine.It creates a new video
+ * Description :This is the initialization routine.It creates a new video
* adapter and calls GXSetupImageVideo to initialize the adaptor
- * by filling XF86VideoAdaptorREc.Then it lists the existing
- * adaptors and adds the new one to it. Finally the list of
- * XF86VideoAdaptorPtr pointers are passed to the
+ * by filling XF86VideoAdaptorREc.Then it lists the existing
+ * adaptors and adds the new one to it. Finally the list of
+ * XF86VideoAdaptorPtr pointers are passed to the
* xf86XVScreenInit().
*
* Parameters.
@@ -165,50 +167,50 @@ GXInitVideo(ScreenPtr pScrn)
pGeode = GEODEPTR(pScrni);
if (!pGeode->NoAccel) {
- XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
- XF86VideoAdaptorPtr newAdaptor = NULL;
-
- int num_adaptors;
-
- newAdaptor = GXSetupImageVideo(pScrn);
- GXInitOffscreenImages(pScrn);
-
- num_adaptors = xf86XVListGenericAdaptors(pScrni, &adaptors);
-
- if (newAdaptor) {
- if (!num_adaptors) {
- num_adaptors = 1;
- adaptors = &newAdaptor;
- } else {
- newAdaptors = /* need to free this someplace */
- xalloc((num_adaptors +
- 1) * sizeof(XF86VideoAdaptorPtr *));
- if (newAdaptors) {
- memcpy(newAdaptors, adaptors, num_adaptors *
- sizeof(XF86VideoAdaptorPtr));
- newAdaptors[num_adaptors] = newAdaptor;
- adaptors = newAdaptors;
- num_adaptors++;
- }
- }
- }
-
- if (num_adaptors)
- xf86XVScreenInit(pScrn, adaptors, num_adaptors);
-
- if (newAdaptors)
- xfree(newAdaptors);
+ XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
+ XF86VideoAdaptorPtr newAdaptor = NULL;
+
+ int num_adaptors;
+
+ newAdaptor = GXSetupImageVideo(pScrn);
+ GXInitOffscreenImages(pScrn);
+
+ num_adaptors = xf86XVListGenericAdaptors(pScrni, &adaptors);
+
+ if (newAdaptor) {
+ if (!num_adaptors) {
+ num_adaptors = 1;
+ adaptors = &newAdaptor;
+ } else {
+ newAdaptors = /* need to free this someplace */
+ xalloc((num_adaptors +
+ 1) * sizeof(XF86VideoAdaptorPtr *));
+ if (newAdaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors *
+ sizeof(XF86VideoAdaptorPtr));
+ newAdaptors[num_adaptors] = newAdaptor;
+ adaptors = newAdaptors;
+ num_adaptors++;
+ }
+ }
+ }
+
+ if (num_adaptors)
+ xf86XVScreenInit(pScrn, adaptors, num_adaptors);
+
+ if (newAdaptors)
+ xfree(newAdaptors);
}
}
/* client libraries expect an encoding */
static XF86VideoEncodingRec DummyEncoding[1] = {
{
- 0,
- "XV_IMAGE",
- 1024, 1024,
- {1, 1}
- }
+ 0,
+ "XV_IMAGE",
+ 1024, 1024,
+ {1, 1}
+ }
};
#define NUM_FORMATS 4
@@ -290,35 +292,35 @@ GXSetColorkey(ScrnInfoPtr pScrni, GeodePortPrivRec * pPriv)
switch (pScrni->depth) {
case 8:
- GFX(get_display_palette_entry(pPriv->colorKey & 0xFF, &key));
- red = ((key >> 16) & 0xFF);
- green = ((key >> 8) & 0xFF);
- blue = (key & 0xFF);
- break;
+ GFX(get_display_palette_entry(pPriv->colorKey & 0xFF, &key));
+ red = ((key >> 16) & 0xFF);
+ green = ((key >> 8) & 0xFF);
+ blue = (key & 0xFF);
+ break;
case 16:
- red = (pPriv->colorKey & pScrni->mask.red) >>
- pScrni->offset.red << (8 - pScrni->weight.red);
- green = (pPriv->colorKey & pScrni->mask.green) >>
- pScrni->offset.green << (8 - pScrni->weight.green);
- blue = (pPriv->colorKey & pScrni->mask.blue) >>
- pScrni->offset.blue << (8 - pScrni->weight.blue);
- break;
+ red = (pPriv->colorKey & pScrni->mask.red) >>
+ pScrni->offset.red << (8 - pScrni->weight.red);
+ green = (pPriv->colorKey & pScrni->mask.green) >>
+ pScrni->offset.green << (8 - pScrni->weight.green);
+ blue = (pPriv->colorKey & pScrni->mask.blue) >>
+ pScrni->offset.blue << (8 - pScrni->weight.blue);
+ break;
default:
- /* for > 16 bpp we send in the mask in xf86SetWeight. This
- * function is providing the offset by 1 more. So we take
- * this as a special case and subtract 1 for > 16
- */
- red = (pPriv->colorKey & pScrni->mask.red) >>
- (pScrni->offset.red - 1) << (8 - pScrni->weight.red);
- green = (pPriv->colorKey & pScrni->mask.green) >>
- (pScrni->offset.green - 1) << (8 - pScrni->weight.green);
- blue = (pPriv->colorKey & pScrni->mask.blue) >>
- (pScrni->offset.blue - 1) << (8 - pScrni->weight.blue);
- break;
+ /* for > 16 bpp we send in the mask in xf86SetWeight. This
+ * function is providing the offset by 1 more. So we take
+ * this as a special case and subtract 1 for > 16
+ */
+ red = (pPriv->colorKey & pScrni->mask.red) >>
+ (pScrni->offset.red - 1) << (8 - pScrni->weight.red);
+ green = (pPriv->colorKey & pScrni->mask.green) >>
+ (pScrni->offset.green - 1) << (8 - pScrni->weight.green);
+ blue = (pPriv->colorKey & pScrni->mask.blue) >>
+ (pScrni->offset.blue - 1) << (8 - pScrni->weight.blue);
+ break;
}
GFX(set_video_color_key((blue | (green << 8) | (red << 16)), 0xFFFFFF,
- (pPriv->colorKeyMode == 0)));
+ (pPriv->colorKeyMode == 0)));
REGION_EMPTY(pScrni->pScreen, &pPriv->clip);
return 0;
}
@@ -343,18 +345,18 @@ GXResetVideo(ScrnInfoPtr pScrni)
GeodeRec *pGeode = GEODEPTR(pScrni);
if (!pGeode->NoAccel) {
- GeodePortPrivRec *pPriv = pGeode->adaptor->pPortPrivates[0].ptr;
+ GeodePortPrivRec *pPriv = pGeode->adaptor->pPortPrivates[0].ptr;
- GXAccelSync(pScrni);
- GXSetColorkey(pScrni, pPriv);
- GFX(set_video_filter(pPriv->filter, pPriv->filter));
+ GXAccelSync(pScrni);
+ GXSetColorkey(pScrni, pPriv);
+ GFX(set_video_filter(pPriv->filter, pPriv->filter));
}
}
/*----------------------------------------------------------------------------
* GXSetupImageVideo
*
- * Description : This function allocates space for a Videoadaptor and
+ * Description : This function allocates space for a Videoadaptor and
* initializes the XF86VideoAdaptorPtr record.
*
* Parameters.
@@ -374,8 +376,8 @@ GXSetupImageVideo(ScreenPtr pScrn)
GeodePortPrivRec *pPriv;
if (!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
- sizeof(GeodePortPrivRec) + sizeof(DevUnion))))
- return NULL;
+ sizeof(GeodePortPrivRec) + sizeof(DevUnion))))
+ return NULL;
adapt->type = XvWindowMask | XvInputMask | XvImageMask;
adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
@@ -396,7 +398,7 @@ GXSetupImageVideo(ScreenPtr pScrn)
adapt->PutStill = NULL;
adapt->GetVideo = NULL;
adapt->GetStill = NULL;
- adapt->StopVideo= GXStopVideo;
+ adapt->StopVideo = GXStopVideo;
adapt->SetPortAttribute = GXSetPortAttribute;
adapt->GetPortAttribute = GXGetPortAttribute;
adapt->QueryBestSize = GXQueryBestSize;
@@ -409,7 +411,7 @@ GXSetupImageVideo(ScreenPtr pScrn)
pPriv->videoStatus = 0;
#if DBUF
pPriv->doubleBuffer = TRUE;
- pPriv->currentBuffer = 0; /* init to first buffer */
+ pPriv->currentBuffer = 0; /* init to first buffer */
#endif
/* gotta uninit this someplace */
@@ -444,9 +446,9 @@ GXSetupImageVideo(ScreenPtr pScrn)
* Parameters.
* pScrni :Screen handler pointer having screen information.
* data :Pointer to the video port's private data
- * exit :Flag indicating whether the offscreen areas used for
+ * exit :Flag indicating whether the offscreen areas used for
* video to be deallocated or not.
- *
+ *
* Returns :none
*
* Comments :none
@@ -462,54 +464,54 @@ GXStopVideo(ScrnInfoPtr pScrni, pointer data, Bool exit)
GXAccelSync(pScrni);
if (exit) {
- if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
- GFX(set_video_enable(0));
+ if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
+ GFX(set_video_enable(0));
- /* If we have saved graphics LUT data - restore it */
+ /* If we have saved graphics LUT data - restore it */
/* Otherwise, turn bypass on */
if (lutflag)
GFX(set_graphics_palette(graphics_lut));
- else
- GFX(set_video_palette_bypass(1));
+ else
+ GFX(set_video_palette_bypass(1));
lutflag = 0;
}
- if (pPriv->area) {
+ if (pPriv->area) {
#ifdef XF86EXA
if (pGeode->useEXA)
- exaOffscreenFree(pScrni->pScreen, pPriv->area);
+ exaOffscreenFree(pScrni->pScreen, pPriv->area);
#endif
if (!pGeode->useEXA)
- xf86FreeOffscreenArea(pPriv->area);
+ xf86FreeOffscreenArea(pPriv->area);
- pPriv->area = NULL;
- }
+ pPriv->area = NULL;
+ }
- pPriv->videoStatus = 0;
- pGeode->OverlayON = FALSE;
+ pPriv->videoStatus = 0;
+ pGeode->OverlayON = FALSE;
} else {
- if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
- pPriv->videoStatus |= OFF_TIMER;
- pPriv->offTime = currentTime.milliseconds + OFF_DELAY;
- }
+ if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
+ pPriv->videoStatus |= OFF_TIMER;
+ pPriv->offTime = currentTime.milliseconds + OFF_DELAY;
+ }
}
}
/*----------------------------------------------------------------------------
* GXSetPortAttribute
*
- * Description :This function is used to set the attributes of a port
+ * Description :This function is used to set the attributes of a port
* like colorkeymode, double buffer support and filter.
*
* Parameters.
* pScrni :Screen handler pointer having screen information.
* data :Pointer to the video port's private data
* attribute :The port attribute to be set
- * value :Value of the attribute to be set.
- *
+ * value :Value of the attribute to be set.
+ *
* Returns :Sucess if the attribute is supported, else BadMatch
*
* Comments :none
@@ -523,25 +525,25 @@ GXSetPortAttribute(ScrnInfoPtr pScrni,
GXAccelSync(pScrni);
if (attribute == xvColorKey) {
- pPriv->colorKey = value;
- GXSetColorkey(pScrni, pPriv);
+ pPriv->colorKey = value;
+ GXSetColorkey(pScrni, pPriv);
}
#if DBUF
else if (attribute == xvDoubleBuffer) {
- if ((value < 0) || (value > 1))
- return BadValue;
- pPriv->doubleBuffer = value;
+ if ((value < 0) || (value > 1))
+ return BadValue;
+ pPriv->doubleBuffer = value;
}
#endif
else if (attribute == xvColorKeyMode) {
- pPriv->colorKeyMode = value;
- GXSetColorkey(pScrni, pPriv);
+ pPriv->colorKeyMode = value;
+ GXSetColorkey(pScrni, pPriv);
} else if (attribute == xvFilter) {
- if ((value < 0) || (value > 1))
- return BadValue;
- pPriv->filter = value;
+ if ((value < 0) || (value > 1))
+ return BadValue;
+ pPriv->filter = value;
} else
- return BadMatch;
+ return BadMatch;
return Success;
}
@@ -556,8 +558,8 @@ GXSetPortAttribute(ScrnInfoPtr pScrni,
* pScrni :Screen handler pointer having screen information.
* data :Pointer to the video port's private data
* attribute :The port attribute to be read
- * value :Pointer to the value of the attribute to be read.
- *
+ * value :Pointer to the value of the attribute to be read.
+ *
* Returns :Sucess if the attribute is supported, else BadMatch
*
* Comments :none
@@ -570,19 +572,19 @@ GXGetPortAttribute(ScrnInfoPtr pScrni,
GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
if (attribute == xvColorKey) {
- *value = pPriv->colorKey;
+ *value = pPriv->colorKey;
}
#if DBUF
else if (attribute == xvDoubleBuffer) {
- *value = (pPriv->doubleBuffer) ? 1 : 0;
+ *value = (pPriv->doubleBuffer) ? 1 : 0;
}
#endif
else if (attribute == xvColorKeyMode) {
- *value = pPriv->colorKeyMode;
+ *value = pPriv->colorKeyMode;
} else if (attribute == xvFilter) {
- *value = pPriv->filter;
+ *value = pPriv->filter;
} else
- return BadMatch;
+ return BadMatch;
return Success;
}
@@ -590,7 +592,7 @@ GXGetPortAttribute(ScrnInfoPtr pScrni,
/*----------------------------------------------------------------------------
* GXQueryBestSize
*
- * Description :This function provides a way to query what the
+ * Description :This function provides a way to query what the
* destination dimensions would end up being if they were to
* request that an area vid_w by vid_h from the video stream
* be scaled to rectangle of drw_w by drw_h on the screen.
@@ -600,8 +602,8 @@ GXGetPortAttribute(ScrnInfoPtr pScrni,
* data :Pointer to the video port's private data
* vid_w,vid_h :Width and height of the video data.
* drw_w,drw_h :Width and height of the scaled rectangle.
- * p_w,p_h :Width and height of the destination rectangle.
- *
+ * p_w,p_h :Width and height of the destination rectangle.
+ *
* Returns :None
*
* Comments :None
@@ -618,7 +620,7 @@ GXQueryBestSize(ScrnInfoPtr pScrni,
*p_h = drw_h;
if (*p_w > 16384)
- *p_w = 16384;
+ *p_w = 16384;
}
/*----------------------------------------------------------------------------
@@ -630,9 +632,9 @@ GXQueryBestSize(ScrnInfoPtr pScrni,
* src : pointer to the source data
* dst : pointer to destination data
* srcPitch : pitch of the srcdata
- * dstPitch : pitch of the destination data
+ * dstPitch : pitch of the destination data
* h & w : height and width of source data
- *
+ *
* Returns :None
*
* Comments :None
@@ -643,9 +645,9 @@ GXCopyData420(unsigned char *src, unsigned char *dst,
int srcPitch, int dstPitch, int h, int w)
{
while (h--) {
- memcpy(dst, src, w);
- src += srcPitch;
- dst += dstPitch;
+ memcpy(dst, src, w);
+ src += srcPitch;
+ dst += dstPitch;
}
}
@@ -658,9 +660,9 @@ GXCopyData420(unsigned char *src, unsigned char *dst,
* src : pointer to the source data
* dst : pointer to destination data
* srcPitch : pitch of the srcdata
- * dstPitch : pitch of the destination data
+ * dstPitch : pitch of the destination data
* h & w : height and width of source data
- *
+ *
* Returns :None
*
* Comments :None
@@ -672,85 +674,88 @@ GXCopyData422(unsigned char *src, unsigned char *dst,
{
w <<= 1;
while (h--) {
- memcpy(dst, src, w);
- src += srcPitch;
- dst += dstPitch;
+ memcpy(dst, src, w);
+ src += srcPitch;
+ dst += dstPitch;
}
}
#ifdef XF86EXA
static void
-GXVideoSave(ScreenPtr pScreen, ExaOffscreenArea *area) {
- ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
- GeodePortPrivRec *pPriv = GET_PORT_PRIVATE(pScrni);
+GXVideoSave(ScreenPtr pScreen, ExaOffscreenArea * area)
+{
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodePortPrivRec *pPriv = GET_PORT_PRIVATE(pScrni);
- if (area == pPriv->area)
- pPriv->area = NULL;
+ if (area == pPriv->area)
+ pPriv->area = NULL;
}
#endif
static int
GXAllocateMemory(ScrnInfoPtr pScrni, void **memp, int numlines)
{
- ScreenPtr pScrn = screenInfo.screens[pScrni->scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- //long displayWidth = pGeode->Pitch / ((pScrni->bitsPerPixel + 7) / 8);
- int size = numlines * pGeode->displayWidth;
+ ScreenPtr pScrn = screenInfo.screens[pScrni->scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ //long displayWidth = pGeode->Pitch / ((pScrni->bitsPerPixel + 7) / 8);
+ int size = numlines * pGeode->displayWidth;
#if XF86EXA
if (pGeode->useEXA) {
- ExaOffscreenArea *area = *memp;
+ ExaOffscreenArea *area = *memp;
- if (area != NULL) {
- if (area->size >= size)
- return area->offset;
+ if (area != NULL) {
+ if (area->size >= size)
+ return area->offset;
- exaOffscreenFree(pScrni->pScreen, area);
- }
+ exaOffscreenFree(pScrni->pScreen, area);
+ }
- area = exaOffscreenAlloc(pScrni->pScreen, size, 16,
- TRUE, GXVideoSave, NULL);
- *memp = area;
+ area = exaOffscreenAlloc(pScrni->pScreen, size, 16,
+ TRUE, GXVideoSave, NULL);
+ *memp = area;
- return area == NULL ? 0 : area->offset;
+ return area == NULL ? 0 : area->offset;
}
#endif
if (!pGeode->useEXA) {
- FBAreaPtr area = *memp;
- FBAreaPtr new_area;
+ FBAreaPtr area = *memp;
+ FBAreaPtr new_area;
- if (area) {
- if ((area->box.y2 - area->box.y1) >= numlines)
+ if (area) {
+ if ((area->box.y2 - area->box.y1) >= numlines)
return (area->box.y1 * pGeode->Pitch);
-
- if (xf86ResizeOffscreenArea(area, pGeode->displayWidth, numlines))
+ if (xf86ResizeOffscreenArea(area, pGeode->displayWidth, numlines))
return (area->box.y1 * pGeode->Pitch);
- xf86FreeOffscreenArea(area);
- }
+ xf86FreeOffscreenArea(area);
+ }
- new_area = xf86AllocateOffscreenArea(pScrn, pGeode->displayWidth,
- numlines, 0, NULL, NULL, NULL);
+ new_area = xf86AllocateOffscreenArea(pScrn, pGeode->displayWidth,
+ numlines, 0, NULL, NULL, NULL);
- if (!new_area) {
- int max_w, max_h;
+ if (!new_area) {
+ int max_w, max_h;
- xf86QueryLargestOffscreenArea(pScrn, &max_w, &max_h, 0,
- FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME);
+ xf86QueryLargestOffscreenArea(pScrn, &max_w, &max_h, 0,
+ FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME);
- if ((max_w < pGeode->displayWidth) || (max_h < numlines)) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No room - how sad %x, %x, %x, %x\n", max_w, pGeode->displayWidth, max_h, numlines);
- return 0;
- }
+ if ((max_w < pGeode->displayWidth) || (max_h < numlines)) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "No room - how sad %x, %x, %x, %x\n", max_w,
+ pGeode->displayWidth, max_h, numlines);
+ return 0;
+ }
- xf86PurgeUnlockedOffscreenAreas(pScrn);
- new_area = xf86AllocateOffscreenArea(pScrn, pGeode->displayWidth,
- numlines, 0, NULL, NULL, NULL);
- }
+ xf86PurgeUnlockedOffscreenAreas(pScrn);
+ new_area = xf86AllocateOffscreenArea(pScrn, pGeode->displayWidth,
+ numlines, 0, NULL, NULL, NULL);
+ }
- return (new_area->box.y1 * pGeode->Pitch);
+ return (new_area->box.y1 * pGeode->Pitch);
}
return 0;
@@ -772,12 +777,12 @@ RegionsIntersect(BoxPtr pRcl1, BoxPtr pRcl2, BoxPtr pRclResult)
pRclResult->x2 = min(pRcl1->x2, pRcl2->x2);
if (pRclResult->x1 <= pRclResult->x2) {
- pRclResult->y1 = max(pRcl1->y1, pRcl2->y1);
- pRclResult->y2 = min(pRcl1->y2, pRcl2->y2);
+ pRclResult->y1 = max(pRcl1->y1, pRcl2->y1);
+ pRclResult->y2 = min(pRcl1->y2, pRcl2->y2);
- if (pRclResult->y1 <= pRclResult->y2) {
- return (TRUE);
- }
+ if (pRclResult->y1 <= pRclResult->y2) {
+ return (TRUE);
+ }
}
return (FALSE);
@@ -794,6 +799,7 @@ GXSetVideoPosition(int x, int y, int width, int height,
unsigned long lines = 0;
unsigned long y_extra, uv_extra = 0;
unsigned long startAddress;
+
#if 0
BoxRec ovly, display, result;
#endif
@@ -812,49 +818,49 @@ GXSetVideoPosition(int x, int y, int width, int height,
/* Thhis code is pretty dang broken - comment it out for now */
if (pGeode->Panel) {
- ovly.x1 = x;
- ovly.x2 = x + pGeode->video_dstw;
- ovly.y1 = y;
- ovly.y2 = y + pGeode->video_dsth;
-
- display.x1 = DeltaX;
- display.x2 = DeltaX + pGeode->FPBX;
- display.y1 = DeltaY;
- display.y2 = DeltaY + pGeode->FPBY;
- x = xend = 0;
- if (RegionsIntersect(&display, &ovly, &result)) {
- x = ovly.x1 - DeltaX;
- xend = ovly.x2 - DeltaX;
- y = ovly.y1 - DeltaY;
- yend = ovly.y2 - DeltaY;
- }
+ ovly.x1 = x;
+ ovly.x2 = x + pGeode->video_dstw;
+ ovly.y1 = y;
+ ovly.y2 = y + pGeode->video_dsth;
+
+ display.x1 = DeltaX;
+ display.x2 = DeltaX + pGeode->FPBX;
+ display.y1 = DeltaY;
+ display.y2 = DeltaY + pGeode->FPBY;
+ x = xend = 0;
+ if (RegionsIntersect(&display, &ovly, &result)) {
+ x = ovly.x1 - DeltaX;
+ xend = ovly.x2 - DeltaX;
+ y = ovly.y1 - DeltaY;
+ yend = ovly.y2 - DeltaY;
+ }
}
#endif
/* TOP CLIPPING */
if (y < 0) {
- if (src_h < drw_h)
- lines = (-y) * src_h / drw_h;
- else
- lines = (-y);
- ystart = 0;
- drw_h += y;
- y_extra = lines * dstPitch;
- uv_extra = (lines >> 1) * (dstPitch2);
+ if (src_h < drw_h)
+ lines = (-y) * src_h / drw_h;
+ else
+ lines = (-y);
+ ystart = 0;
+ drw_h += y;
+ y_extra = lines * dstPitch;
+ uv_extra = (lines >> 1) * (dstPitch2);
} else {
- ystart = y;
- lines = 0;
- y_extra = 0;
+ ystart = y;
+ lines = 0;
+ y_extra = 0;
}
GFX(set_video_window(x, ystart, xend - x, yend - ystart));
if ((id == FOURCC_Y800) || (id == FOURCC_I420) || (id == FOURCC_YV12)) {
- GFX(set_video_yuv_offsets(offset + y_extra,
- offset + d3offset + uv_extra, offset + d2offset + uv_extra));
+ GFX(set_video_yuv_offsets(offset + y_extra,
+ offset + d3offset + uv_extra, offset + d2offset + uv_extra));
} else {
- GFX(set_video_offset(offset + y_extra));
+ GFX(set_video_offset(offset + y_extra));
}
}
@@ -862,11 +868,11 @@ GXSetVideoPosition(int x, int y, int width, int height,
* GXDisplayVideo
*
* Description :This function sets up the video registers for playing video
- * It sets up the video format,width, height & position of the
+ * It sets up the video format,width, height & position of the
* video window ,video offsets( y,u,v) and video pitches(y,u,v)
- *
- * Parameters
- *
+ *
+ * Parameters
+ *
* Returns :None
*
* Comments :None
@@ -891,76 +897,75 @@ GXDisplayVideo(ScrnInfoPtr pScrni,
* off
*/
-
if (id != FOURCC_RGB565) {
- dcfg = gfx_read_vid32(DISPLAY_CONFIG);
- misc = gfx_read_vid32(MISC);
+ dcfg = gfx_read_vid32(DISPLAY_CONFIG);
+ misc = gfx_read_vid32(MISC);
- lutflag = (!(misc & 1) && (dcfg & (1 << 21)));
+ lutflag = (!(misc & 1) && (dcfg & (1 << 21)));
- if (lutflag)
- get_gamma_ram(graphics_lut);
+ if (lutflag)
+ get_gamma_ram(graphics_lut);
- /* Set the video gamma ram */
- GFX(set_video_palette(NULL));
+ /* Set the video gamma ram */
+ GFX(set_video_palette(NULL));
}
GFX(set_video_enable(1));
switch (id) {
- case FOURCC_UYVY: /* UYVY */
- GFX(set_video_format(VIDEO_FORMAT_UYVY));
- GFX(set_video_size(width, height));
- break;
- case FOURCC_Y800: /* Y800 - greyscale - we munge it! */
- case FOURCC_YV12: /* YV12 */
- case FOURCC_I420: /* I420 */
- GFX(set_video_format(VIDEO_FORMAT_Y0Y1Y2Y3));
- GFX(set_video_size(width, height));
- GFX(set_video_yuv_pitch(dstPitch, dstPitch2));
- break;
- case FOURCC_YUY2: /* YUY2 */
- GFX(set_video_format(VIDEO_FORMAT_YUYV));
- GFX(set_video_size(width, height));
- break;
- case FOURCC_Y2YU: /* Y2YU */
- GFX(set_video_format(VIDEO_FORMAT_Y2YU));
- GFX(set_video_size(width, height));
- break;
- case FOURCC_YVYU: /* YVYU */
- GFX(set_video_format(VIDEO_FORMAT_YVYU));
- GFX(set_video_size(width, height));
- break;
+ case FOURCC_UYVY: /* UYVY */
+ GFX(set_video_format(VIDEO_FORMAT_UYVY));
+ GFX(set_video_size(width, height));
+ break;
+ case FOURCC_Y800: /* Y800 - greyscale - we munge it! */
+ case FOURCC_YV12: /* YV12 */
+ case FOURCC_I420: /* I420 */
+ GFX(set_video_format(VIDEO_FORMAT_Y0Y1Y2Y3));
+ GFX(set_video_size(width, height));
+ GFX(set_video_yuv_pitch(dstPitch, dstPitch2));
+ break;
+ case FOURCC_YUY2: /* YUY2 */
+ GFX(set_video_format(VIDEO_FORMAT_YUYV));
+ GFX(set_video_size(width, height));
+ break;
+ case FOURCC_Y2YU: /* Y2YU */
+ GFX(set_video_format(VIDEO_FORMAT_Y2YU));
+ GFX(set_video_size(width, height));
+ break;
+ case FOURCC_YVYU: /* YVYU */
+ GFX(set_video_format(VIDEO_FORMAT_YVYU));
+ GFX(set_video_size(width, height));
+ break;
case FOURCC_RGB565:
- GFX(set_video_format(VIDEO_FORMAT_RGB));
- GFX(set_video_size(width, height));
- break;
+ GFX(set_video_format(VIDEO_FORMAT_RGB));
+ GFX(set_video_size(width, height));
+ break;
}
if (pGeode->Panel) {
- pGeode->video_x = dstBox->x1;
- pGeode->video_y = dstBox->y1;
- pGeode->video_w = width;
- pGeode->video_h = height;
- pGeode->video_srcw = src_w;
- pGeode->video_srch = src_h;
- pGeode->video_dstw = drw_w;
- pGeode->video_dsth = drw_h;
- pGeode->video_offset = offset;
- pGeode->video_id = id;
- pGeode->video_scrnptr = pScrni;
+ pGeode->video_x = dstBox->x1;
+ pGeode->video_y = dstBox->y1;
+ pGeode->video_w = width;
+ pGeode->video_h = height;
+ pGeode->video_srcw = src_w;
+ pGeode->video_srch = src_h;
+ pGeode->video_dstw = drw_w;
+ pGeode->video_dsth = drw_h;
+ pGeode->video_offset = offset;
+ pGeode->video_id = id;
+ pGeode->video_scrnptr = pScrni;
}
if ((drw_w >= src_w) && (drw_h >= src_h))
- GFX(set_video_scale(width, height, drw_w, drw_h));
+ GFX(set_video_scale(width, height, drw_w, drw_h));
else if (drw_w < src_w)
- GFX(set_video_scale(drw_w, height, drw_w, drw_h));
+ GFX(set_video_scale(drw_w, height, drw_w, drw_h));
else if (drw_h < src_h)
- GFX(set_video_scale(width, drw_h, drw_w, drw_h));
+ GFX(set_video_scale(width, drw_h, drw_w, drw_h));
GXSetVideoPosition(dstBox->x1, dstBox->y1, width, height, src_w,
- src_h, drw_w, drw_h, id, offset, pScrni);
+ src_h, drw_w, drw_h, id, offset, pScrni);
}
/* Used by LX as well */
@@ -973,43 +978,43 @@ RegionsEqual(RegionPtr A, RegionPtr B)
num = REGION_NUM_RECTS(A);
if (num != REGION_NUM_RECTS(B)) {
- return FALSE;
+ return FALSE;
}
if ((A->extents.x1 != B->extents.x1) ||
- (A->extents.x2 != B->extents.x2) ||
- (A->extents.y1 != B->extents.y1) || (A->extents.y2 != B->extents.y2))
- return FALSE;
+ (A->extents.x2 != B->extents.x2) ||
+ (A->extents.y1 != B->extents.y1) || (A->extents.y2 != B->extents.y2))
+ return FALSE;
dataA = (int *)REGION_RECTS(A);
dataB = (int *)REGION_RECTS(B);
while (num--) {
- if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
- return FALSE;
+ if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
+ return FALSE;
- dataA += 2;
- dataB += 2;
+ dataA += 2;
+ dataB += 2;
}
return TRUE;
}
/*----------------------------------------------------------------------------
- * GXPutImage :This function writes a single frame of video into a
- * drawable. The position and size of the source rectangle is
+ * GXPutImage :This function writes a single frame of video into a
+ * drawable. The position and size of the source rectangle is
* specified by src_x,src_y, src_w and src_h. This data is
- * stored in a system memory buffer at buf. The position and
- * size of the destination rectangle is specified by drw_x,
- * drw_y,drw_w,drw_h.The data is in the format indicated by the
- * image descriptor and represents a source of size width by
- * height. If sync is TRUE the driver should not return from
+ * stored in a system memory buffer at buf. The position and
+ * size of the destination rectangle is specified by drw_x,
+ * drw_y,drw_w,drw_h.The data is in the format indicated by the
+ * image descriptor and represents a source of size width by
+ * height. If sync is TRUE the driver should not return from
* this function until it is through reading the data from buf.
* Returning when sync is TRUE indicates that it is safe for the
* data at buf to be replaced,freed, or modified.
*
* Parameters.
- *
+ *
* Returns :None
*
* Comments :None
@@ -1023,7 +1028,8 @@ GXPutImage(ScrnInfoPtr pScrni,
short src_w, short src_h,
short drw_w, short drw_h,
int id, unsigned char *buf,
- short width, short height, Bool sync, RegionPtr clipBoxes, pointer data, DrawablePtr pDraw)
+ short width, short height, Bool sync, RegionPtr clipBoxes, pointer data,
+ DrawablePtr pDraw)
{
GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
GeodeRec *pGeode = GEODEPTR(pScrni);
@@ -1044,172 +1050,173 @@ GXPutImage(ScrnInfoPtr pScrni,
#if REINIT
/* update cliplist */
if (!RegionsEqual(&pPriv->clip, clipBoxes)) {
- ReInitVideo = TRUE;
+ ReInitVideo = TRUE;
}
if (DoReinitAgain)
- ReInitVideo = TRUE;
+ ReInitVideo = TRUE;
if (ReInitVideo) {
- DEBUGMSG(1, (0, X_NONE, "Regional Not Equal - Init\n"));
+ DEBUGMSG(1, (0, X_NONE, "Regional Not Equal - Init\n"));
#endif
- DoReinitAgain = ~DoReinitAgain;
- if (drw_w > 16384)
- drw_w = 16384;
-
- /* Clip */
- Bx1 = src_x;
- Bx2 = src_x + src_w;
- By1 = src_y;
- By2 = src_y + src_h;
-
- if ((Bx1 >= Bx2) || (By1 >= By2))
- return Success;
-
- dstBox.x1 = drw_x;
- dstBox.x2 = drw_x + drw_w;
- dstBox.y1 = drw_y;
- dstBox.y2 = drw_y + drw_h;
-
- dstBox.x1 -= pScrni->frameX0;
- dstBox.x2 -= pScrni->frameX0;
- dstBox.y1 -= pScrni->frameY0;
- dstBox.y2 -= pScrni->frameY0;
-
- switch (id) {
- case FOURCC_YV12:
- case FOURCC_I420:
- srcPitch = (width + 3) & ~3; /* of luma */
- dstPitch = (width + 31) & ~31;
-
- s2offset = srcPitch * height;
- d2offset = dstPitch * height;
-
- srcPitch2 = ((width >> 1) + 3) & ~3;
- dstPitch2 = ((width >> 1) + 15) & ~15;
-
- s3offset = (srcPitch2 * (height >> 1)) + s2offset;
- d3offset = (dstPitch2 * (height >> 1)) + d2offset;
-
- new_h = dstPitch * height; /* Y */
- new_h += (dstPitch2 * height); /* U+V */
- new_h += pGeode->Pitch - 1;
- new_h /= pGeode->Pitch;
- break;
- case FOURCC_UYVY:
- case FOURCC_YUY2:
- case FOURCC_Y800:
+ DoReinitAgain = ~DoReinitAgain;
+ if (drw_w > 16384)
+ drw_w = 16384;
+
+ /* Clip */
+ Bx1 = src_x;
+ Bx2 = src_x + src_w;
+ By1 = src_y;
+ By2 = src_y + src_h;
+
+ if ((Bx1 >= Bx2) || (By1 >= By2))
+ return Success;
+
+ dstBox.x1 = drw_x;
+ dstBox.x2 = drw_x + drw_w;
+ dstBox.y1 = drw_y;
+ dstBox.y2 = drw_y + drw_h;
+
+ dstBox.x1 -= pScrni->frameX0;
+ dstBox.x2 -= pScrni->frameX0;
+ dstBox.y1 -= pScrni->frameY0;
+ dstBox.y2 -= pScrni->frameY0;
+
+ switch (id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ srcPitch = (width + 3) & ~3; /* of luma */
+ dstPitch = (width + 31) & ~31;
+
+ s2offset = srcPitch * height;
+ d2offset = dstPitch * height;
+
+ srcPitch2 = ((width >> 1) + 3) & ~3;
+ dstPitch2 = ((width >> 1) + 15) & ~15;
+
+ s3offset = (srcPitch2 * (height >> 1)) + s2offset;
+ d3offset = (dstPitch2 * (height >> 1)) + d2offset;
+
+ new_h = dstPitch * height; /* Y */
+ new_h += (dstPitch2 * height); /* U+V */
+ new_h += pGeode->Pitch - 1;
+ new_h /= pGeode->Pitch;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ case FOURCC_Y800:
case FOURCC_RGB565:
- default:
- dstPitch = ((width << 1) + 3) & ~3;
- srcPitch = (width << 1);
- new_h = ((dstPitch * height) + pGeode->Pitch - 1) / pGeode->Pitch;
- break;
- }
+ default:
+ dstPitch = ((width << 1) + 3) & ~3;
+ srcPitch = (width << 1);
+ new_h = ((dstPitch * height) + pGeode->Pitch - 1) / pGeode->Pitch;
+ break;
+ }
#if DBUF
- if (pPriv->doubleBuffer)
- new_h <<= 1;
+ if (pPriv->doubleBuffer)
+ new_h <<= 1;
#endif
if (!(pPriv->offset = GXAllocateMemory(pScrni, &pPriv->area, new_h))) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Could not allocate area of size %d\n", new_h);
- return BadAlloc;
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Could not allocate area of size %d\n", new_h);
+ return BadAlloc;
}
- /* copy data */
- top = By1;
- left = Bx1 & ~1;
- npixels = ((Bx2 + 1) & ~1) - left;
+ /* copy data */
+ top = By1;
+ left = Bx1 & ~1;
+ npixels = ((Bx2 + 1) & ~1) - left;
- switch (id) {
- case FOURCC_YV12:
- case FOURCC_I420:
- {
- int tmp;
+ switch (id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ {
+ int tmp;
- top &= ~1;
+ top &= ~1;
offset = pPriv->offset + (top * dstPitch);
#if DBUF
- if (pPriv->doubleBuffer && pPriv->currentBuffer)
- offset += (new_h >> 1) * pGeode->Pitch;
+ if (pPriv->doubleBuffer && pPriv->currentBuffer)
+ offset += (new_h >> 1) * pGeode->Pitch;
#endif
- dst_start = pGeode->FBBase + offset + left;
- tmp = ((top >> 1) * srcPitch2) + (left >> 1);
- s2offset += tmp;
- s3offset += tmp;
- if (id == FOURCC_I420) {
- tmp = s2offset;
- s2offset = s3offset;
- s3offset = tmp;
- }
- nlines = ((By2 + 1) & ~1) - top;
- }
- break;
- case FOURCC_UYVY:
- case FOURCC_YUY2:
- case FOURCC_Y800:
+ dst_start = pGeode->FBBase + offset + left;
+ tmp = ((top >> 1) * srcPitch2) + (left >> 1);
+ s2offset += tmp;
+ s3offset += tmp;
+ if (id == FOURCC_I420) {
+ tmp = s2offset;
+ s2offset = s3offset;
+ s3offset = tmp;
+ }
+ nlines = ((By2 + 1) & ~1) - top;
+ }
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ case FOURCC_Y800:
case FOURCC_RGB565:
- default:
- left <<= 1;
- buf += (top * srcPitch) + left;
- nlines = By2 - top;
+ default:
+ left <<= 1;
+ buf += (top * srcPitch) + left;
+ nlines = By2 - top;
offset = (pPriv->offset) + (top * dstPitch);
#if DBUF
- if (pPriv->doubleBuffer && pPriv->currentBuffer)
- offset += (new_h >> 1) * pGeode->Pitch;
+ if (pPriv->doubleBuffer && pPriv->currentBuffer)
+ offset += (new_h >> 1) * pGeode->Pitch;
#endif
- dst_start = pGeode->FBBase + offset + left;
- break;
- }
- s1offset = (top * srcPitch) + left;
+ dst_start = pGeode->FBBase + offset + left;
+ break;
+ }
+ s1offset = (top * srcPitch) + left;
#if REINIT
- /* update cliplist */
- REGION_COPY(pScrni->pScreen, &pPriv->clip, clipBoxes);
+ /* update cliplist */
+ REGION_COPY(pScrni->pScreen, &pPriv->clip, clipBoxes);
- if (pPriv->colorKeyMode == 0) {
+ if (pPriv->colorKeyMode == 0) {
xf86XVFillKeyHelper(pScrni->pScreen, pPriv->colorKey, clipBoxes);
- }
+ }
- GXDisplayVideo(pScrni, id, offset, width, height, dstPitch,
- Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, drw_h);
+ GXDisplayVideo(pScrni, id, offset, width, height, dstPitch,
+ Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, drw_h);
}
#endif
switch (id) {
case FOURCC_Y800:
- /* This is shared between LX and GX, so it lives in amd_common.c */
- GeodeCopyGreyscale(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
- break;
+ /* This is shared between LX and GX, so it lives in amd_common.c */
+ GeodeCopyGreyscale(buf, dst_start, srcPitch, dstPitch, nlines,
+ npixels);
+ break;
case FOURCC_YV12:
case FOURCC_I420:
- GXCopyData420(buf + s1offset, dst_start, srcPitch, dstPitch, nlines,
- npixels);
- GXCopyData420(buf + s2offset, dst_start + d2offset, srcPitch2,
- dstPitch2, nlines >> 1, npixels >> 1);
- GXCopyData420(buf + s3offset, dst_start + d3offset, srcPitch2,
- dstPitch2, nlines >> 1, npixels >> 1);
- break;
+ GXCopyData420(buf + s1offset, dst_start, srcPitch, dstPitch, nlines,
+ npixels);
+ GXCopyData420(buf + s2offset, dst_start + d2offset, srcPitch2,
+ dstPitch2, nlines >> 1, npixels >> 1);
+ GXCopyData420(buf + s3offset, dst_start + d3offset, srcPitch2,
+ dstPitch2, nlines >> 1, npixels >> 1);
+ break;
case FOURCC_UYVY:
case FOURCC_YUY2:
case FOURCC_RGB565:
default:
- GXCopyData422(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
- break;
+ GXCopyData422(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
+ break;
}
#if !REINIT
/* update cliplist */
REGION_COPY(pScrni->pScreen, &pPriv->clip, clipBoxes);
if (pPriv->colorKeyMode == 0) {
- /* draw these */
- XAAFillSolidRects(pScrni, pPriv->colorKey, GXcopy, ~0,
- REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes));
+ /* draw these */
+ XAAFillSolidRects(pScrni, pPriv->colorKey, GXcopy, ~0,
+ REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes));
}
GXDisplayVideo(pScrni, id, offset, width, height, dstPitch,
- Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, drw_h);
+ Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, drw_h);
#endif
#if XV_PROFILE
@@ -1231,14 +1238,14 @@ GXPutImage(ScrnInfoPtr pScrni,
* GXQueryImageAttributes
*
* Description :This function is called to let the driver specify how data
- * for a particular image of size width by height should be
- * stored.
+ * for a particular image of size width by height should be
+ * stored.
*
* Parameters.
* pScrni :Screen handler pointer having screen information.
* id :Id for the video format
- * width :width of the image (can be modified by the driver)
- * height :height of the image (can be modified by the driver)
+ * width :width of the image (can be modified by the driver)
+ * height :height of the image (can be modified by the driver)
* Returns : Size of the memory required for storing this image
*
* Comments :None
@@ -1256,47 +1263,47 @@ GeodeQueryImageAttributes(ScrnInfoPtr pScrni,
DEBUGMSG(0, (0, X_NONE, "QueryImageAttributes %X\n", id));
if (*w > 1024)
- *w = 1024;
+ *w = 1024;
if (*h > 1024)
- *h = 1024;
+ *h = 1024;
*w = (*w + 1) & ~1;
if (offsets)
- offsets[0] = 0;
+ offsets[0] = 0;
switch (id) {
case FOURCC_YV12:
case FOURCC_I420:
- *h = (*h + 1) & ~1;
- size = (*w + 3) & ~3;
- if (pitches)
- pitches[0] = size;
-
- size *= *h;
- if (offsets)
- offsets[1] = size;
-
- tmp = ((*w >> 1) + 3) & ~3;
- if (pitches)
- pitches[1] = pitches[2] = tmp;
-
- tmp *= (*h >> 1);
- size += tmp;
- if (offsets)
- offsets[2] = size;
-
- size += tmp;
- break;
+ *h = (*h + 1) & ~1;
+ size = (*w + 3) & ~3;
+ if (pitches)
+ pitches[0] = size;
+
+ size *= *h;
+ if (offsets)
+ offsets[1] = size;
+
+ tmp = ((*w >> 1) + 3) & ~3;
+ if (pitches)
+ pitches[1] = pitches[2] = tmp;
+
+ tmp *= (*h >> 1);
+ size += tmp;
+ if (offsets)
+ offsets[2] = size;
+
+ size += tmp;
+ break;
case FOURCC_UYVY:
case FOURCC_YUY2:
case FOURCC_Y800:
default:
- size = *w << 1;
- if (pitches)
- pitches[0] = size;
+ size = *w << 1;
+ if (pitches)
+ pitches[0] = size;
- size *= *h;
- break;
+ size *= *h;
+ break;
}
return size;
}
@@ -1314,42 +1321,42 @@ GXBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask)
pScrn->BlockHandler = GXBlockHandler;
if (pPriv->videoStatus & TIMER_MASK) {
- GXAccelSync(pScrni);
- UpdateCurrentTime();
- if (pPriv->videoStatus & OFF_TIMER) {
- if (pPriv->offTime < currentTime.milliseconds) {
- GFX(set_video_enable(0));
+ GXAccelSync(pScrni);
+ UpdateCurrentTime();
+ if (pPriv->videoStatus & OFF_TIMER) {
+ if (pPriv->offTime < currentTime.milliseconds) {
+ GFX(set_video_enable(0));
/* If we have saved graphics LUT data - restore it */
/* Otherwise, turn bypass on */
if (lutflag)
- GFX(set_graphics_palette(graphics_lut));
+ GFX(set_graphics_palette(graphics_lut));
else
- GFX(set_video_palette_bypass(1));
+ GFX(set_video_palette_bypass(1));
lutflag = 0;
- pPriv->videoStatus = FREE_TIMER;
- pPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
- }
- } else { /* FREE_TIMER */
- if (pPriv->freeTime < currentTime.milliseconds) {
+ pPriv->videoStatus = FREE_TIMER;
+ pPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
+ }
+ } else { /* FREE_TIMER */
+ if (pPriv->freeTime < currentTime.milliseconds) {
- if (pPriv->area) {
+ if (pPriv->area) {
#ifdef XF86EXA
- if (pGeode->useEXA)
- exaOffscreenFree(pScrn, pPriv->area);
+ if (pGeode->useEXA)
+ exaOffscreenFree(pScrn, pPriv->area);
#endif
- if (!pGeode->useEXA)
- xf86FreeOffscreenArea(pPriv->area);
+ if (!pGeode->useEXA)
+ xf86FreeOffscreenArea(pPriv->area);
- pPriv->area = NULL;
- }
+ pPriv->area = NULL;
+ }
- pPriv->videoStatus = 0;
- }
- }
+ pPriv->videoStatus = 0;
+ }
+ }
}
}
@@ -1357,7 +1364,7 @@ GXBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask)
typedef struct
{
- void * area;
+ void *area;
int offset;
Bool isOn;
} OffscreenPrivRec, *OffscreenPrivPtr;
@@ -1369,7 +1376,7 @@ typedef struct
*
* Parameters.
* pScrni :Screen handler pointer having screen information.
- *
+ *
* Returns :None
*
* Comments :None
@@ -1379,12 +1386,12 @@ static int
GXAllocateSurface(ScrnInfoPtr pScrni,
int id, unsigned short w, unsigned short h, XF86SurfacePtr surface)
{
- void * area = NULL;
+ void *area = NULL;
int pitch, fbpitch, numlines;
OffscreenPrivRec *pPriv;
if ((w > 1024) || (h > 1024))
- return BadAlloc;
+ return BadAlloc;
w = (w + 1) & ~1;
pitch = ((w << 1) + 15) & ~15;
@@ -1392,23 +1399,23 @@ GXAllocateSurface(ScrnInfoPtr pScrni,
numlines = ((pitch * h) + fbpitch - 1) / fbpitch;
if (!(offset = GXAllocateMemory(pScrni, &area, numlines)))
- return BadAlloc;
+ return BadAlloc;
surface->width = w;
surface->height = h;
if (!(surface->pitches = xalloc(sizeof(int))))
- return BadAlloc;
+ return BadAlloc;
if (!(surface->offsets = xalloc(sizeof(int)))) {
- xfree(surface->pitches);
- return BadAlloc;
+ xfree(surface->pitches);
+ return BadAlloc;
}
if (!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) {
- xfree(surface->pitches);
- xfree(surface->offsets);
- return BadAlloc;
+ xfree(surface->pitches);
+ xfree(surface->offsets);
+ return BadAlloc;
}
pPriv->area = area;
@@ -1431,7 +1438,7 @@ GXStopSurface(XF86SurfacePtr surface)
OffscreenPrivRec *pPriv = (OffscreenPrivRec *) surface->devPrivate.ptr;
if (pPriv->isOn) {
- pPriv->isOn = FALSE;
+ pPriv->isOn = FALSE;
}
return Success;
@@ -1443,7 +1450,7 @@ GXFreeSurface(XF86SurfacePtr surface)
OffscreenPrivRec *pPriv = (OffscreenPrivRec *) surface->devPrivate.ptr;
if (pPriv->isOn)
- GXStopSurface(surface);
+ GXStopSurface(surface);
xf86FreeOffscreenArea(pPriv->area);
xfree(surface->pitches);
@@ -1457,14 +1464,14 @@ static int
GXGetSurfaceAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 * value)
{
return GXGetPortAttribute(pScrni, attribute, value,
- (pointer) (GET_PORT_PRIVATE(pScrni)));
+ (pointer) (GET_PORT_PRIVATE(pScrni)));
}
static int
GXSetSurfaceAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 value)
{
return GXSetPortAttribute(pScrni, attribute, value,
- (pointer) (GET_PORT_PRIVATE(pScrni)));
+ (pointer) (GET_PORT_PRIVATE(pScrni)));
}
static int
@@ -1491,7 +1498,7 @@ GXDisplaySurface(XF86SurfacePtr surface,
dstBox.y2 = drw_y + drw_h;
if ((x1 >= x2) || (y1 >= y2))
- return Success;
+ return Success;
dstBox.x1 -= pScrni->frameX0;
dstBox.x2 -= pScrni->frameX0;
@@ -1501,15 +1508,15 @@ GXDisplaySurface(XF86SurfacePtr surface,
xf86XVFillKeyHelper(pScrni->pScreen, portPriv->colorKey, clipBoxes);
GXDisplayVideo(pScrni, surface->id, surface->offsets[0],
- surface->width, surface->height, surface->pitches[0],
- x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
+ surface->width, surface->height, surface->pitches[0],
+ x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
pPriv->isOn = TRUE;
if (portPriv->videoStatus & CLIENT_VIDEO_ON) {
- REGION_EMPTY(pScrni->pScreen, &portPriv->clip);
- UpdateCurrentTime();
- portPriv->videoStatus = FREE_TIMER;
- portPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
+ REGION_EMPTY(pScrni->pScreen, &portPriv->clip);
+ UpdateCurrentTime();
+ portPriv->videoStatus = FREE_TIMER;
+ portPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
}
return Success;
@@ -1518,13 +1525,13 @@ GXDisplaySurface(XF86SurfacePtr surface,
/*----------------------------------------------------------------------------
* GXInitOffscreenImages
*
- * Description :This function sets up the offscreen memory management. It
+ * Description :This function sets up the offscreen memory management. It
* fills in the XF86OffscreenImagePtr structure with functions to
- * handle offscreen memory operations.
+ * handle offscreen memory operations.
*
* Parameters.
* pScrn :Screen handler pointer having screen information.
- *
+ *
* Returns : None
*
* Comments :None
@@ -1537,7 +1544,7 @@ GXInitOffscreenImages(ScreenPtr pScrn)
/* need to free this someplace */
if (!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))
- return;
+ return;
offscreenImages[0].image = &Images[0];
offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
diff --git a/src/lx_cursor.c b/src/lx_cursor.c
index ccc7d6c..f97c271 100644
--- a/src/lx_cursor.c
+++ b/src/lx_cursor.c
@@ -50,15 +50,15 @@ LXHWCursorInit(ScreenPtr pScrn)
infoPtr = xf86CreateCursorInfoRec();
if (!infoPtr)
- return FALSE;
+ return FALSE;
/* the geode structure is intiallized with the cursor infoRec */
pGeode->CursorInfo = infoPtr;
infoPtr->MaxWidth = 32;
infoPtr->MaxHeight = 32;
/* seeting up the cursor flags */
infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
- HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
- HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
+ HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
infoPtr->SetCursorColors = LXSetCursorColors;
infoPtr->SetCursorPosition = LXSetCursorPosition;
@@ -73,7 +73,7 @@ LXHWCursorInit(ScreenPtr pScrn)
static void
LXSetCursorColors(ScrnInfoPtr pScrni, int bg, int fg)
{
- vg_set_mono_cursor_colors(bg, fg);
+ vg_set_mono_cursor_colors(bg, fg);
}
static void
@@ -89,40 +89,47 @@ LXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y)
savex = x + pScrni->frameX0;
savey = y + pScrni->frameY0;
- switch(pGeode->rotation) {
+ switch (pGeode->rotation) {
default:
- ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__, pGeode->rotation);
+ ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__,
+ pGeode->rotation);
case RR_Rotate_0:
- newX = savex; newY = savey;
- hsx= 31; hsy = 31;
- break;
+ newX = savex;
+ newY = savey;
+ hsx = 31;
+ hsy = 31;
+ break;
case RR_Rotate_270:
- newX = savey;
- newY = pScrni->pScreen->width - savex;
- hsx= 31; hsy = 0;
- break;
+ newX = savey;
+ newY = pScrni->pScreen->width - savex;
+ hsx = 31;
+ hsy = 0;
+ break;
case RR_Rotate_180:
- newX = pScrni->pScreen->width - savex;
- newY = pScrni->pScreen->height - savey;
- hsx = 0; hsy = 0;
- break;
+ newX = pScrni->pScreen->width - savex;
+ newY = pScrni->pScreen->height - savey;
+ hsx = 0;
+ hsy = 0;
+ break;
case RR_Rotate_90:
- newX = pScrni->pScreen->height - savey;
- newY = savex;
- hsx= 0; hsy= 31;
- break;
+ newX = pScrni->pScreen->height - savey;
+ newY = savex;
+ hsx = 0;
+ hsy = 31;
+ break;
}
newX -= pScrni->frameX0;
newY -= pScrni->frameY0;
{
- VG_PANNING_COORDINATES panning;
- vg_set_cursor_position(newX + hsx, newY + hsy, &panning);
- }
+ VG_PANNING_COORDINATES panning;
+
+ vg_set_cursor_position(newX + hsx, newY + hsy, &panning);
+ }
vg_set_cursor_enable(1);
@@ -140,54 +147,55 @@ LXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src)
unsigned char *mskp = &src[128];
if (src != NULL) {
- mskb = rowb = 0;
- for (y = 32; --y >= 0;)
- andMask[y] = xorMask[y] = 0;
- for (y = 0; y < 32; ++y) {
- for (x = 0; x < 32; ++x) {
- if ((i = x & 7) == 0) {
- rowb = (*rowp & *mskp);
- mskb = ~(*mskp);
- ++rowp;
- ++mskp;
- }
-
- switch(pGeode->rotation) {
+ mskb = rowb = 0;
+ for (y = 32; --y >= 0;)
+ andMask[y] = xorMask[y] = 0;
+ for (y = 0; y < 32; ++y) {
+ for (x = 0; x < 32; ++x) {
+ if ((i = x & 7) == 0) {
+ rowb = (*rowp & *mskp);
+ mskb = ~(*mskp);
+ ++rowp;
+ ++mskp;
+ }
+
+ switch (pGeode->rotation) {
default:
- ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__,
- pGeode->rotation);
+ ErrorF("%s:%d invalid rotation %d\n", __func__, __LINE__,
+ pGeode->rotation);
case RR_Rotate_0:
- newX = x;
- newY = y;
- break;
+ newX = x;
+ newY = y;
+ break;
case RR_Rotate_270:
- newX = y;
- newY = 31 - x;
- break;
+ newX = y;
+ newY = 31 - x;
+ break;
case RR_Rotate_180:
- newX = 31 - x;
- newY = 31 - y;
- break;
+ newX = 31 - x;
+ newY = 31 - y;
+ break;
case RR_Rotate_90:
- newX = 31 - y;
- newY = x;
- break;
+ newX = 31 - y;
+ newY = x;
+ break;
}
- i = 7 - i;
- n = 31 - newX;
- andMask[newY] |= (((mskb >> i) & 1) << n);
- xorMask[newY] |= (((rowb >> i) & 1) << n);
- }
- }
+ i = 7 - i;
+ n = 31 - newX;
+ andMask[newY] |= (((mskb >> i) & 1) << n);
+ xorMask[newY] |= (((rowb >> i) & 1) << n);
+ }
+ }
} else {
- for (y = 32; --y >= 0;) {
- andMask[y] = ~0;
- xorMask[y] = 0;
- }
+ for (y = 32; --y >= 0;) {
+ andMask[y] = ~0;
+ xorMask[y] = 0;
+ }
}
- vg_set_mono_cursor_shape32(pGeode->CursorStartOffset,&andMask[0],&xorMask[0],31,31);
+ vg_set_mono_cursor_shape32(pGeode->CursorStartOffset, &andMask[0],
+ &xorMask[0], 31, 31);
}
void
diff --git a/src/lx_driver.c b/src/lx_driver.c
index aa8145e..d77a682 100644
--- a/src/lx_driver.c
+++ b/src/lx_driver.c
@@ -55,7 +55,7 @@
#include "xf86cmap.h"
#include "compiler.h"
#include "mipointer.h"
-#include <shadow.h> /* setupShadow() */
+#include <shadow.h> /* setupShadow() */
#include <X11/extensions/randr.h>
#include "fb.h"
#include "miscstruct.h"
@@ -98,7 +98,7 @@ unsigned char *XpressROMPtr;
/* Reference: Video Graphics Suite Specification:
* VG Config Register (0x00) page 16
- * VG FP Register (0x02) page 18
+ * VG FP Register (0x02) page 18
*/
#define LX_READ_VG(reg) \
@@ -107,137 +107,145 @@ unsigned char *XpressROMPtr;
static inline void
lx_enable_dac_power(ScrnInfoPtr pScrni, int option)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- df_set_crt_enable(DF_CRT_ENABLE);
+ df_set_crt_enable(DF_CRT_ENABLE);
- /* Turn off the DAC if we don't need the CRT */
+ /* Turn off the DAC if we don't need the CRT */
- if (option && (!(pGeode->Output & OUTPUT_CRT))) {
- unsigned int misc = READ_VID32(DF_VID_MISC);
- misc |= DF_DAC_POWER_DOWN;
- WRITE_VID32(DF_VID_MISC, misc);
- }
+ if (option && (!(pGeode->Output & OUTPUT_CRT))) {
+ unsigned int misc = READ_VID32(DF_VID_MISC);
- if (pGeode->Output & OUTPUT_PANEL)
- df_set_panel_enable(1);
+ misc |= DF_DAC_POWER_DOWN;
+ WRITE_VID32(DF_VID_MISC, misc);
+ }
+
+ if (pGeode->Output & OUTPUT_PANEL)
+ df_set_panel_enable(1);
}
static inline void
lx_disable_dac_power(ScrnInfoPtr pScrni, int option)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (pGeode->Output & OUTPUT_PANEL)
- df_set_panel_enable(0);
+ if (pGeode->Output & OUTPUT_PANEL)
+ df_set_panel_enable(0);
- if (pGeode->Output & OUTPUT_CRT) {
+ if (pGeode->Output & OUTPUT_CRT) {
- /* Wait for the panel to finish its procedure */
+ /* Wait for the panel to finish its procedure */
- if (pGeode->Output & OUTPUT_PANEL)
- while ((READ_VID32(DF_POWER_MANAGEMENT) & 2) == 0);
- df_set_crt_enable(option);
- }
+ if (pGeode->Output & OUTPUT_PANEL)
+ while ((READ_VID32(DF_POWER_MANAGEMENT) & 2) == 0) ;
+ df_set_crt_enable(option);
+ }
}
static int
lx_get_panel(int *xres, int *yres)
{
- static struct {
- int xres, yres;
- } fpres[] = {
- { 320, 240 }, { 640, 480 }, { 800, 600 }, { 1024, 768 },
- { 1152, 864 }, { 1280, 1024 }, { 1600, 1200 } };
-
- unsigned short reg = LX_READ_VG(0x00);
- unsigned char ret = (reg >> 8) & 0x07;
-
- if ((ret == 1 || ret == 5)) {
-
- reg = LX_READ_VG(0x02);
- ret = (reg >> 3) & 0x07;
-
- /* 7 is a "reserved" value - if we get it, we can only assume that
- a panel doesn't exist (or it hasn't been configured in the BIOS)
- */
-
- if (ret < 7) {
- *xres = fpres[ret].xres;
- *yres = fpres[ret].yres;
-
- return TRUE;
+ static struct
+ {
+ int xres, yres;
+ } fpres[] = {
+ {
+ 320, 240}, {
+ 640, 480}, {
+ 800, 600}, {
+ 1024, 768}, {
+ 1152, 864}, {
+ 1280, 1024}, {
+ 1600, 1200}};
+
+ unsigned short reg = LX_READ_VG(0x00);
+ unsigned char ret = (reg >> 8) & 0x07;
+
+ if ((ret == 1 || ret == 5)) {
+
+ reg = LX_READ_VG(0x02);
+ ret = (reg >> 3) & 0x07;
+
+ /* 7 is a "reserved" value - if we get it, we can only assume that
+ * a panel doesn't exist (or it hasn't been configured in the BIOS)
+ */
+
+ if (ret < 7) {
+ *xres = fpres[ret].xres;
+ *yres = fpres[ret].yres;
+
+ return TRUE;
+ }
}
- }
- return FALSE;
+ return FALSE;
}
static int
-lx_set_custom_mode(GeodeRec *pGeode, DisplayModePtr pMode, int bpp)
+lx_set_custom_mode(GeodeRec * pGeode, DisplayModePtr pMode, int bpp)
{
- VG_DISPLAY_MODE mode;
- int hsync, vsync;
+ VG_DISPLAY_MODE mode;
+ int hsync, vsync;
- memset(&mode, 0, sizeof(mode));
+ memset(&mode, 0, sizeof(mode));
- /* Cimarron purposely swaps the sync when panels are enabled -this is
- * presumably to allow for "default" panels which are normally active
- * low, so we need to swizzle the flags
- */
+ /* Cimarron purposely swaps the sync when panels are enabled -this is
+ * presumably to allow for "default" panels which are normally active
+ * low, so we need to swizzle the flags
+ */
- hsync = (pMode->Flags & V_NHSYNC) ? 1 : 0;
- vsync = (pMode->Flags & V_NVSYNC) ? 1 : 0;
+ hsync = (pMode->Flags & V_NHSYNC) ? 1 : 0;
+ vsync = (pMode->Flags & V_NVSYNC) ? 1 : 0;
- if (pGeode->Output & OUTPUT_PANEL) {
+ if (pGeode->Output & OUTPUT_PANEL) {
hsync = !vsync;
vsync = !vsync;
- }
+ }
- mode.flags |= (hsync) ? VG_MODEFLAG_NEG_HSYNC : 0;
- mode.flags |= (vsync) ? VG_MODEFLAG_NEG_VSYNC : 0;
+ mode.flags |= (hsync) ? VG_MODEFLAG_NEG_HSYNC : 0;
+ mode.flags |= (vsync) ? VG_MODEFLAG_NEG_VSYNC : 0;
- mode.flags |= pGeode->Output & OUTPUT_CRT ? VG_MODEFLAG_CRT_AND_FP : 0;
+ mode.flags |= pGeode->Output & OUTPUT_CRT ? VG_MODEFLAG_CRT_AND_FP : 0;
- if (pGeode->Output & OUTPUT_PANEL) {
- mode.panel_width = mode.mode_width = pGeode->PanelX;
- mode.panel_height = mode.mode_height = pGeode->PanelY;
+ if (pGeode->Output & OUTPUT_PANEL) {
+ mode.panel_width = mode.mode_width = pGeode->PanelX;
+ mode.panel_height = mode.mode_height = pGeode->PanelY;
- mode.flags |= VG_MODEFLAG_PANELOUT;
- mode.flags |= pGeode->Output & OUTPUT_CRT ? VG_MODEFLAG_CRT_AND_FP : 0;
- }
- else {
- mode.mode_width = pMode->CrtcHDisplay;
- mode.mode_height = pMode->CrtcVDisplay;
- }
+ mode.flags |= VG_MODEFLAG_PANELOUT;
+ mode.flags |=
+ pGeode->Output & OUTPUT_CRT ? VG_MODEFLAG_CRT_AND_FP : 0;
+ } else {
+ mode.mode_width = pMode->CrtcHDisplay;
+ mode.mode_height = pMode->CrtcVDisplay;
+ }
- mode.src_width = pMode->CrtcHDisplay;
- mode.src_height = pMode->CrtcVDisplay;
-
- mode.hactive = pMode->CrtcHDisplay;
- mode.hblankstart = pMode->CrtcHBlankStart;
- mode.hsyncstart = pMode->CrtcHSyncStart;
- mode.hsyncend = pMode->CrtcHSyncEnd;
- mode.hblankend = pMode->CrtcHBlankEnd;
- mode.htotal = pMode->CrtcHTotal;
-
- mode.vactive = pMode->CrtcVDisplay;
- mode.vblankstart = pMode->CrtcVBlankStart;
- mode.vsyncstart = pMode->CrtcVSyncStart;
- mode.vsyncend = pMode->CrtcVSyncEnd;
- mode.vblankend = pMode->CrtcVBlankEnd;
- mode.vtotal = pMode->CrtcVTotal;
-
- mode.vactive_even = pMode->CrtcVDisplay;
- mode.vblankstart_even = pMode->CrtcVBlankStart;
- mode.vsyncstart_even = pMode->CrtcVSyncStart;
- mode.vsyncend_even = pMode->CrtcVSyncEnd;
- mode.vblankend_even = pMode->CrtcVBlankEnd;
- mode.vtotal_even = pMode->CrtcVTotal;
-
- mode.frequency = (int)((pMode->SynthClock / 1000.0) * 0x10000);
-
- return vg_set_custom_mode(&mode, bpp);
+ mode.src_width = pMode->CrtcHDisplay;
+ mode.src_height = pMode->CrtcVDisplay;
+
+ mode.hactive = pMode->CrtcHDisplay;
+ mode.hblankstart = pMode->CrtcHBlankStart;
+ mode.hsyncstart = pMode->CrtcHSyncStart;
+ mode.hsyncend = pMode->CrtcHSyncEnd;
+ mode.hblankend = pMode->CrtcHBlankEnd;
+ mode.htotal = pMode->CrtcHTotal;
+
+ mode.vactive = pMode->CrtcVDisplay;
+ mode.vblankstart = pMode->CrtcVBlankStart;
+ mode.vsyncstart = pMode->CrtcVSyncStart;
+ mode.vsyncend = pMode->CrtcVSyncEnd;
+ mode.vblankend = pMode->CrtcVBlankEnd;
+ mode.vtotal = pMode->CrtcVTotal;
+
+ mode.vactive_even = pMode->CrtcVDisplay;
+ mode.vblankstart_even = pMode->CrtcVBlankStart;
+ mode.vsyncstart_even = pMode->CrtcVSyncStart;
+ mode.vsyncend_even = pMode->CrtcVSyncEnd;
+ mode.vblankend_even = pMode->CrtcVBlankEnd;
+ mode.vtotal_even = pMode->CrtcVTotal;
+
+ mode.frequency = (int)((pMode->SynthClock / 1000.0) * 0x10000);
+
+ return vg_set_custom_mode(&mode, bpp);
}
static Bool
@@ -259,7 +267,6 @@ LXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate)
pGeode->displayWidth = pGeode->displayPitch / bytpp;
-
/* Sets pGeode->Pitch and pScrni->displayWidth based on the rotate settings */
LXSetRotatePitch(pScrni);
@@ -275,13 +282,13 @@ LXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate)
size = pScrni->virtualY * LX_CB_PITCH;
if (size <= fbavail) {
- pGeode->CBData.compression_offset = fboffset;
- pGeode->CBData.size = LX_CB_PITCH;
- pGeode->CBData.pitch = LX_CB_PITCH;
- fboffset += size;
- fbavail -= size;
+ pGeode->CBData.compression_offset = fboffset;
+ pGeode->CBData.size = LX_CB_PITCH;
+ pGeode->CBData.pitch = LX_CB_PITCH;
+ fboffset += size;
+ fbavail -= size;
- pGeode->Compression = TRUE;
+ pGeode->Compression = TRUE;
} else {
xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
"Not enough memory for compression\n");
@@ -309,18 +316,18 @@ LXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate)
pGeode->exaBfrOffset = 0;
if (!pGeode->NoAccel) {
- if (pGeode->exaBfrSz > 0 && pGeode->exaBfrSz <= fbavail) {
- pGeode->exaBfrOffset = fboffset;
- fboffset += pGeode->exaBfrSz;
- fbavail -= pGeode->exaBfrSz;
- }
+ if (pGeode->exaBfrSz > 0 && pGeode->exaBfrSz <= fbavail) {
+ pGeode->exaBfrOffset = fboffset;
+ fboffset += pGeode->exaBfrSz;
+ fbavail -= pGeode->exaBfrSz;
+ }
}
/* Adjust the available EXA offscreen space to account for the buffer */
if (!pGeode->NoAccel && pGeode->pExa) {
- pGeode->pExa->offScreenBase = fboffset;
- pGeode->pExa->memorySize = fboffset + fbavail;
+ pGeode->pExa->offScreenBase = fboffset;
+ pGeode->pExa->memorySize = fboffset + fbavail;
}
return ret;
@@ -375,41 +382,41 @@ LXSaveScreen(ScreenPtr pScrn, int mode)
static void
LXReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
{
- if (GeodeReadMSR(addr, lo, hi) == -1) {
- unsigned int l, h;
+ if (GeodeReadMSR(addr, lo, hi) == -1) {
+ unsigned int l, h;
- LX_MSR_READ(addr, l, h);
- *lo = l;
- *hi = h;
- }
+ LX_MSR_READ(addr, l, h);
+ *lo = l;
+ *hi = h;
+ }
}
static void
LXWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
{
- if (GeodeWriteMSR(addr, lo, hi) == -1)
- LX_MSR_WRITE(addr, lo, hi);
+ if (GeodeWriteMSR(addr, lo, hi) == -1)
+ LX_MSR_WRITE(addr, lo, hi);
}
#ifdef XSERVER_LIBPCIACCESS
-static inline void * map_pci_mem(ScrnInfoPtr pScrni, int vram,
- struct pci_device *dev,
- int bar, int size)
+static inline void *
+map_pci_mem(ScrnInfoPtr pScrni, int vram,
+ struct pci_device *dev, int bar, int size)
{
- void *ptr;
- void** result = (void**)&ptr;
- int map_size = size ? size : dev->regions[bar].size;
-
- int err = pci_device_map_range(dev,
- dev->regions[bar].base_addr,
- map_size,
- PCI_DEV_MAP_FLAG_WRITABLE |
- (vram ? PCI_DEV_MAP_FLAG_WRITE_COMBINE : 0),
- result);
-
- if (err)
- return NULL;
- return ptr;
+ void *ptr;
+ void **result = (void **)&ptr;
+ int map_size = size ? size : dev->regions[bar].size;
+
+ int err = pci_device_map_range(dev,
+ dev->regions[bar].base_addr,
+ map_size,
+ PCI_DEV_MAP_FLAG_WRITABLE |
+ (vram ? PCI_DEV_MAP_FLAG_WRITE_COMBINE : 0),
+ result);
+
+ if (err)
+ return NULL;
+ return ptr;
}
#endif
@@ -428,39 +435,40 @@ LXMapMem(ScrnInfoPtr pScrni)
tag = pciTag(pci->bus, pci->device, pci->func);
cim_gp_ptr = (unsigned char *)xf86MapPciMem(index, VIDMEM_MMIO,
- tag, pci->memBase[1], LX_GP_REG_SIZE);
+ tag, pci->memBase[1], LX_GP_REG_SIZE);
cim_vg_ptr = (unsigned char *)xf86MapPciMem(index, VIDMEM_MMIO,
- tag, pci->memBase[2], LX_VG_REG_SIZE);
+ tag, pci->memBase[2], LX_VG_REG_SIZE);
cim_vid_ptr = (unsigned char *)xf86MapPciMem(index, VIDMEM_MMIO,
- tag, pci->memBase[3], LX_VID_REG_SIZE);
-
+ tag, pci->memBase[3], LX_VID_REG_SIZE);
+
cim_vip_ptr = (unsigned char *)xf86MapPciMem(index, VIDMEM_MMIO,
- tag, pci->memBase[4], LX_VIP_REG_SIZE);
+ tag, pci->memBase[4], LX_VIP_REG_SIZE);
cim_fb_ptr = (unsigned char *)xf86MapPciMem(index, VIDMEM_FRAMEBUFFER,
- tag, pci->memBase[0], pGeode->FBAvail + CIM_CMD_BFR_SZ);
+ tag, pci->memBase[0], pGeode->FBAvail + CIM_CMD_BFR_SZ);
#else
cim_gp_ptr = map_pci_mem(pScrni, 0, pci, 1, LX_GP_REG_SIZE);
cim_vg_ptr = map_pci_mem(pScrni, 0, pci, 2, LX_VG_REG_SIZE);
cim_vid_ptr = map_pci_mem(pScrni, 0, pci, 3, LX_VID_REG_SIZE);
cim_vip_ptr = map_pci_mem(pScrni, 0, pci, 4, LX_VIP_REG_SIZE);
- cim_fb_ptr = map_pci_mem(pScrni, 1, pci, 0, pGeode->FBAvail + CIM_CMD_BFR_SZ);
+ cim_fb_ptr =
+ map_pci_mem(pScrni, 1, pci, 0, pGeode->FBAvail + CIM_CMD_BFR_SZ);
#endif
if (pScrni->memPhysBase == 0)
- pScrni->memPhysBase = PCI_REGION_BASE(pci, 0, REGION_MEM);
-
+ pScrni->memPhysBase = PCI_REGION_BASE(pci, 0, REGION_MEM);
cmd_bfr_phys = PCI_REGION_BASE(pci, 0, REGION_MEM) + pGeode->CmdBfrOffset;
cim_cmd_base_ptr = cim_fb_ptr + pGeode->CmdBfrOffset;
if (!cim_gp_ptr || !cim_vg_ptr || !cim_vid_ptr || !cim_fb_ptr ||
!cim_vip_ptr)
- return FALSE;
+ return FALSE;
- gp_set_frame_buffer_base(PCI_REGION_BASE(pci, 0, REGION_MEM), pGeode->FBAvail);
+ gp_set_frame_buffer_base(PCI_REGION_BASE(pci, 0, REGION_MEM),
+ pGeode->FBAvail);
gp_set_command_buffer_base(cmd_bfr_phys, 0, pGeode->CmdBfrSize);
XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
@@ -468,7 +476,7 @@ LXMapMem(ScrnInfoPtr pScrni)
pGeode->FBBase = cim_fb_ptr;
if (!pGeode->NoAccel)
- pGeode->pExa->memoryBase = pGeode->FBBase;
+ pGeode->pExa->memoryBase = pGeode->FBBase;
xf86DrvMsg(index, X_INFO, "Geode LX video memory %x bytes at %p\n",
pGeode->FBAvail, pGeode->FBBase);
@@ -481,21 +489,24 @@ LXMapMem(ScrnInfoPtr pScrni)
*/
static Bool
-LXCheckVGA(ScrnInfoPtr pScrni) {
+LXCheckVGA(ScrnInfoPtr pScrni)
+{
- unsigned char *ptr;
- const char *vgasig = "IBM VGA Compatible";
- int ret;
+ unsigned char *ptr;
+ const char *vgasig = "IBM VGA Compatible";
+ int ret;
- ptr = xf86MapVidMem(pScrni->scrnIndex, VIDMEM_FRAMEBUFFER, 0xC001E, strlen(vgasig));
+ ptr =
+ xf86MapVidMem(pScrni->scrnIndex, VIDMEM_FRAMEBUFFER, 0xC001E,
+ strlen(vgasig));
- if (ptr == NULL)
- return FALSE;
+ if (ptr == NULL)
+ return FALSE;
- ret = memcmp(ptr, vgasig, strlen(vgasig));
- xf86UnMapVidMem(pScrni->scrnIndex, (pointer) ptr, strlen(vgasig));
+ ret = memcmp(ptr, vgasig, strlen(vgasig));
+ xf86UnMapVidMem(pScrni->scrnIndex, (pointer) ptr, strlen(vgasig));
- return ret ? FALSE : TRUE;
+ return ret ? FALSE : TRUE;
}
static Bool
@@ -511,18 +522,18 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
Bool useVGA;
if (pScrni->numEntities != 1)
- return FALSE;
+ return FALSE;
pEnt = xf86GetEntityInfo(pScrni->entityList[0]);
if (pEnt->resources)
- return FALSE;
+ return FALSE;
useVGA = LXCheckVGA(pScrni);
if (flags & PROBE_DETECT) {
if (useVGA)
- GeodeProbeDDC(pScrni, pEnt->index);
+ GeodeProbeDDC(pScrni, pEnt->index);
return TRUE;
}
@@ -530,18 +541,17 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
pGeode = pScrni->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1);
if (pGeode == NULL)
- return FALSE;
+ return FALSE;
pGeode->useVGA = useVGA;
pGeode->VGAActive = FALSE;
pGeode->pEnt = pEnt;
if (pGeode->useVGA) {
- if (!xf86LoadSubModule(pScrni, "vgahw") ||
- !vgaHWGetHWRec(pScrni))
- pGeode->useVGA = FALSE;
+ if (!xf86LoadSubModule(pScrni, "vgahw") || !vgaHWGetHWRec(pScrni))
+ pGeode->useVGA = FALSE;
- pGeode->vesa = xcalloc(sizeof(VESARec), 1);
+ pGeode->vesa = xcalloc(sizeof(VESARec), 1);
}
cim_rdmsr = LXReadMSR;
@@ -588,11 +598,11 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
* here.
*/
{
- Gamma zeros = { 0.0, 0.0, 0.0 };
+ Gamma zeros = { 0.0, 0.0, 0.0 };
- if (!xf86SetGamma(pScrni, zeros)) {
- return FALSE;
- }
+ if (!xf86SetGamma(pScrni, zeros)) {
+ return FALSE;
+ }
}
pScrni->progClock = TRUE;
@@ -609,11 +619,11 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
#if (EXA_VERSION_MAJOR < 2)
pGeode->NoAccel = TRUE;
xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "*** This driver was compiled with EXA version %d\n");
+ "*** This driver was compiled with EXA version %d\n");
xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "*** we need version 2 or greater\n");
+ "*** we need version 2 or greater\n");
xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "*** All accelerations are being turned off.\n");
+ "*** All accelerations are being turned off.\n");
#else
pGeode->NoAccel = FALSE;
#endif
@@ -624,7 +634,7 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
&pGeode->tryHWCursor);
if (!xf86GetOptValInteger(GeodeOptions, LX_OPTION_FBSIZE,
- &(pGeode->FBAvail)))
+ &(pGeode->FBAvail)))
pGeode->FBAvail = 0;
/* For compatability - allow SWCursor too */
@@ -642,15 +652,15 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
if ((s = xf86GetOptValString(GeodeOptions, LX_OPTION_ROTATE))) {
- if (!xf86NameCmp(s, "LEFT"))
- pGeode->rotation = RR_Rotate_90;
- else if (!xf86NameCmp(s, "INVERT"))
- pGeode->rotation = RR_Rotate_180;
- else if (!xf86NameCmp(s, "CCW"))
- pGeode->rotation = RR_Rotate_270;
- else
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Invalid rotation %s.\n", s);
+ if (!xf86NameCmp(s, "LEFT"))
+ pGeode->rotation = RR_Rotate_90;
+ else if (!xf86NameCmp(s, "INVERT"))
+ pGeode->rotation = RR_Rotate_180;
+ else if (!xf86NameCmp(s, "CCW"))
+ pGeode->rotation = RR_Rotate_270;
+ else
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Invalid rotation %s.\n", s);
}
xf86GetOptValInteger(GeodeOptions, LX_OPTION_EXA_SCRATCH_BFRSZ,
@@ -660,8 +670,8 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
pGeode->exaBfrSz = 0;
if (pGeode->Output & OUTPUT_PANEL) {
- if (xf86ReturnOptValBool(GeodeOptions, LX_OPTION_NOPANEL, FALSE))
- pGeode->Output &= ~OUTPUT_PANEL;
+ if (xf86ReturnOptValBool(GeodeOptions, LX_OPTION_NOPANEL, FALSE))
+ pGeode->Output &= ~OUTPUT_PANEL;
}
panelgeo = xf86GetOptValString(GeodeOptions, LX_OPTION_PANEL_GEOMETRY);
@@ -675,13 +685,14 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
if (dcon_init(pScrni)) {
pGeode->Output = OUTPUT_PANEL;
} else if (pGeode->Output & OUTPUT_PANEL) {
- if (panelgeo != NULL)
- GeodeGetFPGeometry(panelgeo, &pGeode->PanelX, &pGeode->PanelY);
- else {
- Bool ret = lx_get_panel(&pGeode->PanelX, &pGeode->PanelY);
- if (ret == FALSE)
- pGeode->Output &= ~OUTPUT_PANEL;
- }
+ if (panelgeo != NULL)
+ GeodeGetFPGeometry(panelgeo, &pGeode->PanelX, &pGeode->PanelY);
+ else {
+ Bool ret = lx_get_panel(&pGeode->PanelX, &pGeode->PanelY);
+
+ if (ret == FALSE)
+ pGeode->Output &= ~OUTPUT_PANEL;
+ }
}
xf86DrvMsg(pScrni->scrnIndex, X_INFO, "LX output options:\n");
@@ -696,37 +707,38 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
/* Set up VGA */
if (pGeode->useVGA) {
- xf86LoaderReqSymLists(amdVgahwSymbols, NULL);
+ xf86LoaderReqSymLists(amdVgahwSymbols, NULL);
- VESARec *pVesa;
-
- if (!xf86LoadSubModule(pScrni, "int10"))
- return FALSE;
-
- xf86LoaderReqSymLists(amdInt10Symbols, NULL);
+ VESARec *pVesa;
- pVesa = pGeode->vesa;
+ if (!xf86LoadSubModule(pScrni, "int10"))
+ return FALSE;
- if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Unable to initialize 1NT10 support\n");
- pGeode->useVGA = FALSE;
- }
+ xf86LoaderReqSymLists(amdInt10Symbols, NULL);
+
+ pVesa = pGeode->vesa;
+
+ if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Unable to initialize 1NT10 support\n");
+ pGeode->useVGA = FALSE;
+ }
}
/* Read the amount of framebuffer memory */
/* First try to read it from the framebuffer, and if that fails,
* do it the legacy way
*/
-
- if (pGeode->FBAvail == 0) {
- if (GeodeGetSizeFromFB(&pGeode->FBAvail)) {
- unsigned long value;
- cim_outw(0xAC1C, 0xFC53);
- cim_outw(0xAC1C, 0x0200);
-
- value = (unsigned long)(cim_inw(0xAC1E)) & 0xFE;
- pGeode->FBAvail = value << 20;
+
+ if (pGeode->FBAvail == 0) {
+ if (GeodeGetSizeFromFB(&pGeode->FBAvail)) {
+ unsigned long value;
+
+ cim_outw(0xAC1C, 0xFC53);
+ cim_outw(0xAC1C, 0x0200);
+
+ value = (unsigned long)(cim_inw(0xAC1E)) & 0xFE;
+ pGeode->FBAvail = value << 20;
}
}
@@ -745,7 +757,7 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
pGeode->FBAvail -= CIM_CMD_BFR_SZ;
pGeode->CmdBfrOffset = pGeode->FBAvail;
-
+
pGeode->maxWidth = LX_MAX_WIDTH;
pGeode->maxHeight = LX_MAX_HEIGHT;
@@ -800,10 +812,10 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
xf86LoaderReqSymLists(amdFbSymbols, NULL);
if (!pGeode->NoAccel) {
- if (!xf86LoadSubModule(pScrni, "exa"))
- return FALSE;
-
- xf86LoaderReqSymLists(&amdExaSymbols[0], NULL);
+ if (!xf86LoadSubModule(pScrni, "exa"))
+ return FALSE;
+
+ xf86LoaderReqSymLists(&amdExaSymbols[0], NULL);
}
if (pGeode->tryHWCursor == TRUE) {
@@ -844,8 +856,10 @@ LXUnmapMem(ScrnInfoPtr pScrni)
xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_gp_ptr, LX_GP_REG_SIZE);
xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_vg_ptr, LX_VG_REG_SIZE);
- xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_vid_ptr, LX_VID_REG_SIZE);
- xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_vip_ptr, LX_VIP_REG_SIZE);
+ xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_vid_ptr,
+ LX_VID_REG_SIZE);
+ xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_vip_ptr,
+ LX_VIP_REG_SIZE);
xf86UnMapVidMem(pScrni->scrnIndex, cim_fb_ptr, pGeode->FBAvail);
xf86UnMapVidMem(pScrni->scrnIndex, XpressROMPtr, 0x10000);
@@ -862,12 +876,12 @@ LXAdjustFrame(int scrnIndex, int x, int y, int flags)
GeodeRec *pGeode = GEODEPTR(pScrni);
unsigned long offset;
-
+
/* XXX: Is pitch correct here? */
offset = pGeode->FBOffset + (y * pGeode->Pitch);
offset += x * (pScrni->bitsPerPixel >> 3);
-
+
vg_set_display_offset(offset);
}
@@ -883,7 +897,7 @@ LXSetVideoMode(ScrnInfoPtr pScrni, DisplayModePtr pMode)
df_get_video_enable(&video_enable, &video_flags);
if (video_enable != 0)
- df_set_video_enable(0, 0);
+ df_set_video_enable(0, 0);
df_get_video_source_configuration(&vs_odd, &vs_even);
lx_disable_dac_power(pScrni, DF_CRT_DISABLE);
@@ -893,38 +907,36 @@ LXSetVideoMode(ScrnInfoPtr pScrni, DisplayModePtr pMode)
* tables */
if ((pMode->type & M_T_BUILTIN) || (pMode->type & M_T_DEFAULT)) {
- if (pMode->Flags & V_NHSYNC)
- flags |= VG_MODEFLAG_NEG_HSYNC;
- if (pMode->Flags & V_NVSYNC)
- flags |= VG_MODEFLAG_NEG_VSYNC;
-
- if (pGeode->Output & OUTPUT_PANEL) {
- int activex = pGeode->PanelX;
- int activey = pGeode->PanelY;
-
- flags = pGeode->Output & OUTPUT_CRT ? VG_MODEFLAG_CRT_AND_FP : 0;
-
- if (pMode->CrtcHDisplay > 1024 &&
- pMode->CrtcHDisplay != pGeode->PanelX) {
- ErrorF("The source is greater then 1024 - scaling is disabled.\n");
- activex = pMode->CrtcHDisplay;
- activey = pMode->CrtcVDisplay;
-
- vg_set_border_color(0);
- }
+ if (pMode->Flags & V_NHSYNC)
+ flags |= VG_MODEFLAG_NEG_HSYNC;
+ if (pMode->Flags & V_NVSYNC)
+ flags |= VG_MODEFLAG_NEG_VSYNC;
- vg_set_panel_mode(pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- activex, activey, activex, activey,
- pScrni->bitsPerPixel, flags);
- }
- else {
- vg_set_display_mode(pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel, GeodeGetRefreshRate(pMode),
- 0);
- }
- }
- else {
+ if (pGeode->Output & OUTPUT_PANEL) {
+ int activex = pGeode->PanelX;
+ int activey = pGeode->PanelY;
+
+ flags = pGeode->Output & OUTPUT_CRT ? VG_MODEFLAG_CRT_AND_FP : 0;
+
+ if (pMode->CrtcHDisplay > 1024 &&
+ pMode->CrtcHDisplay != pGeode->PanelX) {
+ ErrorF
+ ("The source is greater then 1024 - scaling is disabled.\n");
+ activex = pMode->CrtcHDisplay;
+ activey = pMode->CrtcVDisplay;
+
+ vg_set_border_color(0);
+ }
+
+ vg_set_panel_mode(pMode->CrtcHDisplay, pMode->CrtcVDisplay,
+ activex, activey, activex, activey,
+ pScrni->bitsPerPixel, flags);
+ } else {
+ vg_set_display_mode(pMode->CrtcHDisplay, pMode->CrtcVDisplay,
+ pMode->CrtcHDisplay, pMode->CrtcVDisplay,
+ pScrni->bitsPerPixel, GeodeGetRefreshRate(pMode), 0);
+ }
+ } else {
/* For anything other then a default mode - use the passed in
* timings */
@@ -932,30 +944,31 @@ LXSetVideoMode(ScrnInfoPtr pScrni, DisplayModePtr pMode)
}
if (pGeode->Output & OUTPUT_PANEL)
- df_set_output_path((pGeode->Output & OUTPUT_CRT) ? DF_DISPLAY_CRT_FP : DF_DISPLAY_FP);
+ df_set_output_path((pGeode->
+ Output & OUTPUT_CRT) ? DF_DISPLAY_CRT_FP : DF_DISPLAY_FP);
else
- df_set_output_path(DF_DISPLAY_CRT);
-
+ df_set_output_path(DF_DISPLAY_CRT);
+
vg_set_display_pitch(pGeode->Pitch);
gp_set_bpp(pScrni->bitsPerPixel);
-
+
vg_set_display_offset(0);
vg_wait_vertical_blank();
- if (pGeode->Compression) {
- vg_configure_compression(&(pGeode->CBData));
- vg_set_compression_enable(1);
+ if (pGeode->Compression) {
+ vg_configure_compression(&(pGeode->CBData));
+ vg_set_compression_enable(1);
}
if (pGeode->HWCursor && !(pMode->Flags & V_DBLSCAN)) {
- VG_PANNING_COORDINATES panning;
+ VG_PANNING_COORDINATES panning;
- LXLoadCursorImage(pScrni, NULL);
- vg_set_cursor_position(0, 0, &panning);
- LXShowCursor(pScrni);
+ LXLoadCursorImage(pScrni, NULL);
+ vg_set_cursor_position(0, 0, &panning);
+ LXShowCursor(pScrni);
} else {
- vg_set_cursor_enable(0);
- pGeode->HWCursor = FALSE;
+ vg_set_cursor_enable(0);
+ pGeode->HWCursor = FALSE;
}
LXAdjustFrame(pScrni->scrnIndex, pScrni->frameX0, pScrni->frameY0, 0);
@@ -963,7 +976,7 @@ LXSetVideoMode(ScrnInfoPtr pScrni, DisplayModePtr pMode)
df_configure_video_source(&vs_odd, &vs_even);
if (video_enable != 0)
- df_set_video_enable(video_enable, video_flags);
+ df_set_video_enable(video_enable, video_flags);
lx_enable_dac_power(pScrni, 1);
@@ -1008,44 +1021,43 @@ LXSwitchMode(int index, DisplayModePtr pMode, int flags)
static void
LXLeaveGraphics(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- VG_PANNING_COORDINATES panning;
-
- gp_wait_until_idle();
-
- lx_disable_dac_power(pScrni, DF_CRT_DISABLE);
-
- vg_set_custom_mode(&(pGeode->FBcimdisplaytiming.vgDisplayMode),
- pGeode->FBcimdisplaytiming.wBpp);
-
- vg_set_compression_enable(0);
-
- /* Restore the previous Compression state */
- if (pGeode->FBCompressionEnable) {
- vg_configure_compression(&(pGeode->FBCBData));
- vg_set_compression_enable(1);
- }
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ VG_PANNING_COORDINATES panning;
- vg_set_display_pitch(pGeode->FBcimdisplaytiming.wPitch);
- vg_set_display_offset(pGeode->FBDisplayOffset);
-
- /* Restore Cursor */
- vg_set_cursor_position(pGeode->FBCursor.cursor_x,
- pGeode->FBCursor.cursor_y, &panning);
-
- LXRestore(pScrni);
-
- if (pGeode->useVGA && pGeode->VGAActive) {
- pGeode->vesa->pInt->num = 0x10;
- pGeode->vesa->pInt->ax = 0x0 | pGeode->FBBIOSMode;
- pGeode->vesa->pInt->bx = 0;
- xf86ExecX86int10(pGeode->vesa->pInt);
- vg_delay_milliseconds(3);
- }
-
+ gp_wait_until_idle();
- lx_enable_dac_power(pScrni, 1);
- pScrni->vtSema = FALSE;
+ lx_disable_dac_power(pScrni, DF_CRT_DISABLE);
+
+ vg_set_custom_mode(&(pGeode->FBcimdisplaytiming.vgDisplayMode),
+ pGeode->FBcimdisplaytiming.wBpp);
+
+ vg_set_compression_enable(0);
+
+ /* Restore the previous Compression state */
+ if (pGeode->FBCompressionEnable) {
+ vg_configure_compression(&(pGeode->FBCBData));
+ vg_set_compression_enable(1);
+ }
+
+ vg_set_display_pitch(pGeode->FBcimdisplaytiming.wPitch);
+ vg_set_display_offset(pGeode->FBDisplayOffset);
+
+ /* Restore Cursor */
+ vg_set_cursor_position(pGeode->FBCursor.cursor_x,
+ pGeode->FBCursor.cursor_y, &panning);
+
+ LXRestore(pScrni);
+
+ if (pGeode->useVGA && pGeode->VGAActive) {
+ pGeode->vesa->pInt->num = 0x10;
+ pGeode->vesa->pInt->ax = 0x0 | pGeode->FBBIOSMode;
+ pGeode->vesa->pInt->bx = 0;
+ xf86ExecX86int10(pGeode->vesa->pInt);
+ vg_delay_milliseconds(3);
+ }
+
+ lx_enable_dac_power(pScrni, 1);
+ pScrni->vtSema = FALSE;
}
static Bool
@@ -1058,21 +1070,21 @@ LXCloseScreen(int scrnIndex, ScreenPtr pScrn)
LXLeaveGraphics(pScrni);
if (pGeode->pExa) {
- exaDriverFini(pScrn);
- xfree(pGeode->pExa);
- pGeode->pExa = NULL;
+ exaDriverFini(pScrn);
+ xfree(pGeode->pExa);
+ pGeode->pExa = NULL;
}
LXUnmapMem(pScrni);
if (pGeode->useVGA)
- vgaHWUnmapMem(pScrni);
+ vgaHWUnmapMem(pScrni);
pScrni->PointerMoved = pGeode->PointerMoved;
pScrn->CloseScreen = pGeode->CloseScreen;
if (pScrn->CloseScreen)
- return (*pScrn->CloseScreen)(scrnIndex, pScrn);
+ return (*pScrn->CloseScreen) (scrnIndex, pScrn);
return TRUE;
}
@@ -1080,83 +1092,85 @@ LXCloseScreen(int scrnIndex, ScreenPtr pScrn)
static Bool
LXEnterGraphics(ScreenPtr pScrn, ScrnInfoPtr pScrni)
{
- int bpp;
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ int bpp;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- pGeode->curMode = NULL;
+ pGeode->curMode = NULL;
- pGeode->VGAActive = gu3_get_vga_active();
+ pGeode->VGAActive = gu3_get_vga_active();
- gp_wait_until_idle();
-
- //lx_disable_dac_power(pScrni, DF_CRT_DISABLE);
-
- vg_get_current_display_mode(&pGeode->FBcimdisplaytiming.vgDisplayMode, &bpp);
-
- //dump_previous(&pGeode->FBcimdisplaytiming.vgDisplayMode);
+ gp_wait_until_idle();
- pGeode->FBcimdisplaytiming.wBpp = bpp;
- pGeode->FBcimdisplaytiming.wPitch = vg_get_display_pitch();
+ //lx_disable_dac_power(pScrni, DF_CRT_DISABLE);
- pGeode->FBDisplayOffset = vg_get_display_offset();
+ vg_get_current_display_mode(&pGeode->FBcimdisplaytiming.vgDisplayMode,
+ &bpp);
+
+ //dump_previous(&pGeode->FBcimdisplaytiming.vgDisplayMode);
+
+ pGeode->FBcimdisplaytiming.wBpp = bpp;
+ pGeode->FBcimdisplaytiming.wPitch = vg_get_display_pitch();
+
+ pGeode->FBDisplayOffset = vg_get_display_offset();
+
+ if (pGeode->useVGA && pGeode->VGAActive) {
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
+
+ pGeode->FBBIOSMode = pvgaHW->readCrtc(pvgaHW, 0x040);
+ }
+
+ pGeode->FBCompressionEnable = vg_get_compression_enable();
+ vg_get_compression_info(&(pGeode->FBCBData));
+
+ /* Save Cursor offset */
+ vg_get_cursor_info(&pGeode->FBCursor);
+
+ /* Turn off the VGA */
+
+ if (pGeode->useVGA) {
+ unsigned short sequencer;
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
+
+ /* Unlock VGA registers */
+ vgaHWUnlock(pvgaHW);
- if (pGeode->useVGA && pGeode->VGAActive) {
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- pGeode->FBBIOSMode = pvgaHW->readCrtc(pvgaHW, 0x040);
- }
-
- pGeode->FBCompressionEnable = vg_get_compression_enable();
- vg_get_compression_info(&(pGeode->FBCBData));
-
- /* Save Cursor offset */
- vg_get_cursor_info(&pGeode->FBCursor);
-
- /* Turn off the VGA */
-
- if (pGeode->useVGA) {
- unsigned short sequencer;
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
-
- /* Unlock VGA registers */
- vgaHWUnlock(pvgaHW);
-
/* Save the current state and setup the current mode */
- vgaHWSave(pScrni, &VGAHWPTR(pScrni)->SavedReg, VGA_SR_ALL);
-
- /* DISABLE VGA SEQUENCER */
- /* This allows the VGA state machine to terminate. We must delay */
- /* such that there are no pending MBUS requests. */
-
- cim_outb(DC3_SEQUENCER_INDEX, DC3_SEQUENCER_CLK_MODE);
- sequencer = cim_inb(DC3_SEQUENCER_DATA);
- sequencer |= DC3_CLK_MODE_SCREEN_OFF;
- cim_outb(DC3_SEQUENCER_DATA, sequencer);
-
- vg_delay_milliseconds(1);
-
- /* BLANK THE VGA DISPLAY */
- cim_outw(DC3_SEQUENCER_INDEX, DC3_SEQUENCER_RESET);
- sequencer = cim_inb(DC3_SEQUENCER_DATA);
- sequencer &= ~DC3_RESET_VGA_DISP_ENABLE;
- cim_outb(DC3_SEQUENCER_DATA, sequencer);
-
- vg_delay_milliseconds(1);
- }
-
- /* Set up the memory */
- /* XXX - FIXME - when we alow inital rotation, it should be here */
- LXAllocateMemory(pScrn, pScrni, pGeode->rotation);
-
- /* Clear the framebuffer */
- memset(pGeode->FBBase + pGeode->displayOffset, 0, pGeode->displaySize);
+ vgaHWSave(pScrni, &VGAHWPTR(pScrni)->SavedReg, VGA_SR_ALL);
+
+ /* DISABLE VGA SEQUENCER */
+ /* This allows the VGA state machine to terminate. We must delay */
+ /* such that there are no pending MBUS requests. */
- /* Set the video mode */
- LXSetVideoMode(pScrni, pScrni->currentMode);
+ cim_outb(DC3_SEQUENCER_INDEX, DC3_SEQUENCER_CLK_MODE);
+ sequencer = cim_inb(DC3_SEQUENCER_DATA);
+ sequencer |= DC3_CLK_MODE_SCREEN_OFF;
+ cim_outb(DC3_SEQUENCER_DATA, sequencer);
- pGeode->curMode = pScrni->currentMode;
- pScrni->vtSema = TRUE;
+ vg_delay_milliseconds(1);
- return TRUE;
+ /* BLANK THE VGA DISPLAY */
+ cim_outw(DC3_SEQUENCER_INDEX, DC3_SEQUENCER_RESET);
+ sequencer = cim_inb(DC3_SEQUENCER_DATA);
+ sequencer &= ~DC3_RESET_VGA_DISP_ENABLE;
+ cim_outb(DC3_SEQUENCER_DATA, sequencer);
+
+ vg_delay_milliseconds(1);
+ }
+
+ /* Set up the memory */
+ /* XXX - FIXME - when we alow inital rotation, it should be here */
+ LXAllocateMemory(pScrn, pScrni, pGeode->rotation);
+
+ /* Clear the framebuffer */
+ memset(pGeode->FBBase + pGeode->displayOffset, 0, pGeode->displaySize);
+
+ /* Set the video mode */
+ LXSetVideoMode(pScrni, pScrni->currentMode);
+
+ pGeode->curMode = pScrni->currentMode;
+ pScrni->vtSema = TRUE;
+
+ return TRUE;
}
static void
@@ -1180,27 +1194,27 @@ LXLoadPalette(ScrnInfoPtr pScrni,
static void
LXDPMSSet(ScrnInfoPtr pScrni, int mode, int flags)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (!pScrni->vtSema)
+ if (!pScrni->vtSema)
return;
switch (mode) {
case DPMSModeOn:
- lx_enable_dac_power(pScrni, 1);
- break;
+ lx_enable_dac_power(pScrni, 1);
+ break;
case DPMSModeStandby:
- lx_disable_dac_power(pScrni, DF_CRT_STANDBY);
- break;
+ lx_disable_dac_power(pScrni, DF_CRT_STANDBY);
+ break;
case DPMSModeSuspend:
- lx_disable_dac_power(pScrni, DF_CRT_SUSPEND);
- break;
+ lx_disable_dac_power(pScrni, DF_CRT_SUSPEND);
+ break;
case DPMSModeOff:
- lx_disable_dac_power(pScrni, DF_CRT_DISABLE);
- break;
+ lx_disable_dac_power(pScrni, DF_CRT_DISABLE);
+ break;
}
}
@@ -1257,41 +1271,41 @@ LXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
if (pGeode->useVGA) {
- if (!vgaHWMapMem(pScrni))
- return FALSE;
+ if (!vgaHWMapMem(pScrni))
+ return FALSE;
- vgaHWGetIOBase(VGAHWPTR(pScrni));
+ vgaHWGetIOBase(VGAHWPTR(pScrni));
}
-
+
if (!pGeode->NoAccel) {
- pGeode->pExa = xnfcalloc(sizeof(ExaDriverRec), 1);
-
- if (pGeode->pExa) {
-
- /* THis is set in LXAllocMem */
- pGeode->pExa->memoryBase = 0;
-
- /* This is set in LXAllocateMemory */
- pGeode->pExa->memorySize = 0;
-
- pGeode->pExa->pixmapOffsetAlign = 32;
- pGeode->pExa->pixmapPitchAlign = 32;
- pGeode->pExa->flags = EXA_OFFSCREEN_PIXMAPS;
- pGeode->pExa->maxX = pGeode->maxWidth - 1;
- pGeode->pExa->maxY = pGeode->maxHeight - 1;
- }
- else {
- xf86DrvMsg(scrnIndex, X_ERROR, "Couldn't allocate the EXA structure.\n");
- pGeode->NoAccel = TRUE;
- }
+ pGeode->pExa = xnfcalloc(sizeof(ExaDriverRec), 1);
+
+ if (pGeode->pExa) {
+
+ /* THis is set in LXAllocMem */
+ pGeode->pExa->memoryBase = 0;
+
+ /* This is set in LXAllocateMemory */
+ pGeode->pExa->memorySize = 0;
+
+ pGeode->pExa->pixmapOffsetAlign = 32;
+ pGeode->pExa->pixmapPitchAlign = 32;
+ pGeode->pExa->flags = EXA_OFFSCREEN_PIXMAPS;
+ pGeode->pExa->maxX = pGeode->maxWidth - 1;
+ pGeode->pExa->maxY = pGeode->maxHeight - 1;
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Couldn't allocate the EXA structure.\n");
+ pGeode->NoAccel = TRUE;
+ }
}
/* Map the memory here before doing anything else */
if (!LXMapMem(pScrni))
- return FALSE;
-
+ return FALSE;
+
/* XXX FIXME - Take down any of the structures on failure? */
if (!LXEnterGraphics(pScrn, pScrni))
return FALSE;
@@ -1347,7 +1361,7 @@ LXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
fbPictureInit(pScrn, 0, 0);
if (!pGeode->NoAccel)
- pGeode->NoAccel = LXExaInit(pScrn) ? FALSE : TRUE;
+ pGeode->NoAccel = LXExaInit(pScrn) ? FALSE : TRUE;
miInitializeBackingStore(pScrn);
xf86SetBackingStore(pScrn);
@@ -1382,7 +1396,7 @@ LXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
#endif
LXInitVideo(pScrn);
-
+
/* Set up RandR */
/* We provide our own RandR goodness - disable the default */
xf86DisableRandR();
@@ -1397,17 +1411,17 @@ LXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
rotate = RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270;
shadowSetup(pScrn);
} else {
- LoaderErrorMsg(NULL, "shadow", maj, min);
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Error loading shadow - rotation not available.\n");
-
- if (pGeode->rotation != RR_Rotate_0)
+ LoaderErrorMsg(NULL, "shadow", maj, min);
xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Reverting back to normal rotation.\n");
-
- rotate = pGeode->rotation = RR_Rotate_0;
+ "Error loading shadow - rotation not available.\n");
+
+ if (pGeode->rotation != RR_Rotate_0)
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Reverting back to normal rotation.\n");
+
+ rotate = pGeode->rotation = RR_Rotate_0;
}
-
+
LXRandRInit(pScrn, rotate);
pGeode->PointerMoved = pScrni->PointerMoved;
@@ -1440,42 +1454,44 @@ LXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags)
/* For builtin and default modes, try to look up the mode in Cimarron */
if ((pMode->type & M_T_BUILTIN) || (pMode->type & M_T_DEFAULT)) {
-
- if (pGeode->Output & OUTPUT_PANEL) {
-
- /* Can't scale this mode */
-
- if ((pGeode->PanelY != pMode->CrtcHDisplay) &&
- pMode->CrtcHDisplay > 1024)
- return MODE_NOMODE;
-
- vgQueryMode.panel_width = pGeode->PanelX;
- vgQueryMode.panel_height = pGeode->PanelY;
-
- vgQueryMode.query_flags |= VG_QUERYFLAG_PANELWIDTH | VG_QUERYFLAG_PANELHEIGHT;
- }
-
- vgQueryMode.active_width = pMode->CrtcHDisplay;
- vgQueryMode.active_height = pMode->CrtcVDisplay;
- vgQueryMode.bpp = pScrni->bitsPerPixel;
- vgQueryMode.hz = GeodeGetRefreshRate(pMode);
- vgQueryMode.query_flags |= VG_QUERYFLAG_REFRESH | VG_QUERYFLAG_BPP |
- VG_QUERYFLAG_ACTIVEWIDTH | VG_QUERYFLAG_ACTIVEHEIGHT;
-
- ret = vg_get_display_mode_index(&vgQueryMode);
-
- if (ret < 0)
- return MODE_BAD;
+
+ if (pGeode->Output & OUTPUT_PANEL) {
+
+ /* Can't scale this mode */
+
+ if ((pGeode->PanelY != pMode->CrtcHDisplay) &&
+ pMode->CrtcHDisplay > 1024)
+ return MODE_NOMODE;
+
+ vgQueryMode.panel_width = pGeode->PanelX;
+ vgQueryMode.panel_height = pGeode->PanelY;
+
+ vgQueryMode.query_flags |=
+ VG_QUERYFLAG_PANELWIDTH | VG_QUERYFLAG_PANELHEIGHT;
+ }
+
+ vgQueryMode.active_width = pMode->CrtcHDisplay;
+ vgQueryMode.active_height = pMode->CrtcVDisplay;
+ vgQueryMode.bpp = pScrni->bitsPerPixel;
+ vgQueryMode.hz = GeodeGetRefreshRate(pMode);
+ vgQueryMode.query_flags |= VG_QUERYFLAG_REFRESH | VG_QUERYFLAG_BPP |
+ VG_QUERYFLAG_ACTIVEWIDTH | VG_QUERYFLAG_ACTIVEHEIGHT;
+
+ ret = vg_get_display_mode_index(&vgQueryMode);
+
+ if (ret < 0)
+ return MODE_BAD;
}
-
+
if (pGeode->tryCompression)
- p = GeodeCalculatePitchBytes(pMode->CrtcHDisplay, pScrni->bitsPerPixel);
+ p = GeodeCalculatePitchBytes(pMode->CrtcHDisplay,
+ pScrni->bitsPerPixel);
else
- p = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
-
+ p = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
+
if (p * pMode->CrtcVDisplay > pGeode->FBAvail)
- return MODE_MEM;
-
+ return MODE_MEM;
+
return MODE_OK;
}
@@ -1484,15 +1500,15 @@ LXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags)
static Bool
LXEnterVT(int scrnIndex, int flags)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- Bool ret = LXEnterGraphics(NULL, pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ Bool ret = LXEnterGraphics(NULL, pScrni);
- /* Reallocate a shadow area, if we need it */
+ /* Reallocate a shadow area, if we need it */
- if (ret == TRUE)
- ret = LXAllocShadow(pScrni);
+ if (ret == TRUE)
+ ret = LXAllocShadow(pScrni);
- return ret;
+ return ret;
}
static void
@@ -1503,13 +1519,13 @@ LXLeaveVT(int scrnIndex, int flags)
pGeode->PrevDisplayOffset = vg_get_display_offset();
LXLeaveGraphics(xf86Screens[scrnIndex]);
-
+
/* Destroy any shadow area, if we have it */
-
+
if (pGeode->shadowArea != NULL) {
- exaOffscreenFree(pScrni->pScreen, pGeode->shadowArea);
- pGeode->shadowArea = NULL;
- }
+ exaOffscreenFree(pScrni->pScreen, pGeode->shadowArea);
+ pGeode->shadowArea = NULL;
+ }
}
void
@@ -1524,5 +1540,3 @@ LXSetupChipsetFPtr(ScrnInfoPtr pScrn)
pScrn->FreeScreen = GeodeFreeScreen;
pScrn->ValidMode = LXValidMode;
}
-
-
diff --git a/src/lx_exa.c b/src/lx_exa.c
index a606da5..bd63573 100644
--- a/src/lx_exa.c
+++ b/src/lx_exa.c
@@ -43,22 +43,24 @@
#include "geode_blend.h"
-static const struct exa_format_t {
- int exa;
- int bpp;
- int fmt;
- int alphabits;
+static const struct exa_format_t
+{
+ int exa;
+ int bpp;
+ int fmt;
+ int alphabits;
} lx_exa_formats[] = {
- {PICT_a8r8g8b8, 32, CIMGP_SOURCE_FMT_8_8_8_8, 8 },
- {PICT_x8r8g8b8, 32, CIMGP_SOURCE_FMT_8_8_8_8, 0 },
- {PICT_x8b8g8r8, 32, CIMGP_SOURCE_FMT_32BPP_BGR, 0 },
- {PICT_a4r4g4b4, 16, CIMGP_SOURCE_FMT_4_4_4_4, 4 },
- {PICT_a1r5g5b5, 16, CIMGP_SOURCE_FMT_1_5_5_5, 1 },
- {PICT_r5g6b5, 16, CIMGP_SOURCE_FMT_0_5_6_5, 0 },
- {PICT_b5g6r5, 16, CIMGP_SOURCE_FMT_16BPP_BGR, 0 },
- {PICT_x1r5g5b5, 16, CIMGP_SOURCE_FMT_1_5_5_5, 0 },
- {PICT_x1b5g5r5, 16, CIMGP_SOURCE_FMT_15BPP_BGR, 0 },
- {PICT_r3g3b2, 8, CIMGP_SOURCE_FMT_3_3_2, 0 }
+ {
+ PICT_a8r8g8b8, 32, CIMGP_SOURCE_FMT_8_8_8_8, 8}, {
+ PICT_x8r8g8b8, 32, CIMGP_SOURCE_FMT_8_8_8_8, 0}, {
+ PICT_x8b8g8r8, 32, CIMGP_SOURCE_FMT_32BPP_BGR, 0}, {
+ PICT_a4r4g4b4, 16, CIMGP_SOURCE_FMT_4_4_4_4, 4}, {
+ PICT_a1r5g5b5, 16, CIMGP_SOURCE_FMT_1_5_5_5, 1}, {
+ PICT_r5g6b5, 16, CIMGP_SOURCE_FMT_0_5_6_5, 0}, {
+ PICT_b5g6r5, 16, CIMGP_SOURCE_FMT_16BPP_BGR, 0}, {
+ PICT_x1r5g5b5, 16, CIMGP_SOURCE_FMT_1_5_5_5, 0}, {
+ PICT_x1b5g5r5, 16, CIMGP_SOURCE_FMT_15BPP_BGR, 0}, {
+ PICT_r3g3b2, 8, CIMGP_SOURCE_FMT_3_3_2, 0}
};
/* This is a chunk of memory we use for scratch space */
@@ -67,22 +69,23 @@ static const struct exa_format_t {
#define COMP_TYPE_ONEPASS 1
#define COMP_TYPE_TWOPASS 3
-static struct {
- int type;
-
- unsigned int srcOffset;
- unsigned int srcPitch;
- unsigned int srcBpp;
- unsigned int srcWidth, srcHeight;
- PixmapPtr srcPixmap;
-
- unsigned int srcColor;
- int op;
- int repeat;
- unsigned int fourBpp;
- unsigned int bufferOffset;
- struct exa_format_t *srcFormat;
- struct exa_format_t *dstFormat;
+static struct
+{
+ int type;
+
+ unsigned int srcOffset;
+ unsigned int srcPitch;
+ unsigned int srcBpp;
+ unsigned int srcWidth, srcHeight;
+ PixmapPtr srcPixmap;
+
+ unsigned int srcColor;
+ int op;
+ int repeat;
+ unsigned int fourBpp;
+ unsigned int bufferOffset;
+ struct exa_format_t *srcFormat;
+ struct exa_format_t *dstFormat;
} exaScratch;
static const int SDfn[16] = {
@@ -101,44 +104,44 @@ static const int SDfn_PM[16] = {
* they have different requirements based on ROP
*/
-static int lx0 = -1, ly0 = -1, lx1 = -1, ly1 = -1;
+static int lx0 = -1, ly0 = -1, lx1 = -1, ly1 = -1;
-static int lx_fill_flags(int x0, int y0, int w, int h, int rop)
+static int
+lx_fill_flags(int x0, int y0, int w, int h, int rop)
{
- int x1 = x0 + w, y1 = y0 + h;
- int n = ((rop^(rop>>1))&0x55) == 0 || /* no dst */
- x0 >= lx1 || y0 >= ly1 || /* rght/below */
- x1 <= lx0 || y1 <= ly0 ? /* left/above */
- 0 : CIMGP_BLTFLAGS_HAZARD;
-
- lx0 = x0;
- ly0 = y0;
- lx1 = x1;
- ly1 = y1;
-
- return n;
+ int x1 = x0 + w, y1 = y0 + h;
+ int n = ((rop ^ (rop >> 1)) & 0x55) == 0 || /* no dst */
+ x0 >= lx1 || y0 >= ly1 || /* rght/below */
+ x1 <= lx0 || y1 <= ly0 ? /* left/above */
+ 0 : CIMGP_BLTFLAGS_HAZARD;
+
+ lx0 = x0;
+ ly0 = y0;
+ lx1 = x1;
+ ly1 = y1;
+
+ return n;
}
-static int lx_copy_flags(int x0, int y0, int x1, int y1, int w, int h,
- int rop)
+static int
+lx_copy_flags(int x0, int y0, int x1, int y1, int w, int h, int rop)
{
- int x2 = x1+w, y2 = y1+h;
-
- /* dst not hazzard and src not hazzard */
- int n = ( ((rop^(rop>>1))&0x55) == 0 ||
- x1 >= lx1 || y1 >= ly1 ||
- x2 <= lx0 || y2 <= ly0 ) &&
- ( ((rop^(rop>>2))&0x33) == 0 ||
- x0 >= lx1 || y0 >= ly1 ||
- x0+w <= lx0 || y0+h <= ly0 ) ?
- 0 : CIMGP_BLTFLAGS_HAZARD;
-
- lx0 = x1;
- ly0 = y1;
- lx1 = x2;
- ly1 = y2;
-
- return n;
+ int x2 = x1 + w, y2 = y1 + h;
+
+ /* dst not hazzard and src not hazzard */
+ int n = (((rop ^ (rop >> 1)) & 0x55) == 0 ||
+ x1 >= lx1 || y1 >= ly1 ||
+ x2 <= lx0 || y2 <= ly0) &&
+ (((rop ^ (rop >> 2)) & 0x33) == 0 ||
+ x0 >= lx1 || y0 >= ly1 ||
+ x0 + w <= lx0 || y0 + h <= ly0) ? 0 : CIMGP_BLTFLAGS_HAZARD;
+
+ lx0 = x1;
+ ly0 = y1;
+ lx1 = x2;
+ ly1 = y2;
+
+ return n;
}
/* These are borrowed from the exa engine - they should be made global
@@ -148,12 +151,8 @@ static int lx_copy_flags(int x0, int y0, int x1, int y1, int w, int h,
/* exaGetPixelFromRGBA (exa_render.c) */
static Bool
-_GetPixelFromRGBA(CARD32 *pixel,
- CARD16 red,
- CARD16 green,
- CARD16 blue,
- CARD16 alpha,
- CARD32 format)
+_GetPixelFromRGBA(CARD32 * pixel,
+ CARD16 red, CARD16 green, CARD16 blue, CARD16 alpha, CARD32 format)
{
int rbits, bbits, gbits, abits;
int rshift, bshift, gshift, ashift;
@@ -173,17 +172,17 @@ _GetPixelFromRGBA(CARD32 *pixel,
gshift = bbits;
rshift = gshift + gbits;
ashift = rshift + rbits;
- } else { /* PICT_TYPE_ABGR */
+ } else { /* PICT_TYPE_ABGR */
rshift = 0;
gshift = rbits;
bshift = gshift + gbits;
ashift = bshift + bbits;
}
- *pixel |= ( blue >> (16 - bbits)) << bshift;
- *pixel |= ( red >> (16 - rbits)) << rshift;
- *pixel |= (green >> (16 - gbits)) << gshift;
- *pixel |= (alpha >> (16 - abits)) << ashift;
+ *pixel |= (blue >> (16 - bbits)) << bshift;
+ *pixel |= (red >> (16 - rbits)) << rshift;
+ *pixel |= (green >> (16 - gbits)) << gshift;
+ *pixel |= (alpha >> (16 - abits)) << ashift;
return TRUE;
}
@@ -191,12 +190,9 @@ _GetPixelFromRGBA(CARD32 *pixel,
/* exaGetRGBAFromPixel (exa_render.c) */
static Bool
-_GetRGBAFromPixel(CARD32 pixel,
- CARD16 *red,
- CARD16 *green,
- CARD16 *blue,
- CARD16 *alpha,
- CARD32 format)
+_GetRGBAFromPixel(CARD32 pixel,
+ CARD16 * red,
+ CARD16 * green, CARD16 * blue, CARD16 * alpha, CARD32 format)
{
int rbits, bbits, gbits, abits;
int rshift, bshift, gshift, ashift;
@@ -214,33 +210,33 @@ _GetRGBAFromPixel(CARD32 pixel,
gshift = bbits;
rshift = gshift + gbits;
ashift = rshift + rbits;
- } else { /* PICT_TYPE_ABGR */
+ } else { /* PICT_TYPE_ABGR */
rshift = 0;
gshift = rbits;
bshift = gshift + gbits;
ashift = bshift + bbits;
}
- *red = ((pixel >> rshift ) & ((1 << rbits) - 1)) << (16 - rbits);
+ *red = ((pixel >> rshift) & ((1 << rbits) - 1)) << (16 - rbits);
while (rbits < 16) {
*red |= *red >> rbits;
rbits <<= 1;
}
- *green = ((pixel >> gshift ) & ((1 << gbits) - 1)) << (16 - gbits);
+ *green = ((pixel >> gshift) & ((1 << gbits) - 1)) << (16 - gbits);
while (gbits < 16) {
*green |= *green >> gbits;
gbits <<= 1;
}
- *blue = ((pixel >> bshift ) & ((1 << bbits) - 1)) << (16 - bbits);
+ *blue = ((pixel >> bshift) & ((1 << bbits) - 1)) << (16 - bbits);
while (bbits < 16) {
*blue |= *blue >> bbits;
bbits <<= 1;
}
if (abits) {
- *alpha = ((pixel >> ashift ) & ((1 << abits) - 1)) << (16 - abits);
+ *alpha = ((pixel >> ashift) & ((1 << abits) - 1)) << (16 - abits);
while (abits < 16) {
*alpha |= *alpha >> abits;
abits <<= 1;
@@ -251,8 +247,8 @@ _GetRGBAFromPixel(CARD32 pixel,
return TRUE;
}
-static unsigned int lx_get_source_color(PixmapPtr pSrc, int srcFormat,
- int dstFormat)
+static unsigned int
+lx_get_source_color(PixmapPtr pSrc, int srcFormat, int dstFormat)
{
CARD32 in, out;
CARD16 red, green, blue, alpha;
@@ -275,90 +271,92 @@ static unsigned int lx_get_source_color(PixmapPtr pSrc, int srcFormat,
static Bool
lx_prepare_solid(PixmapPtr pxMap, int alu, Pixel planemask, Pixel fg)
{
- int pitch = exaGetPixmapPitch(pxMap);
- int op = (planemask == ~0U) ? SDfn[alu] : SDfn_PM[alu];
+ int pitch = exaGetPixmapPitch(pxMap);
+ int op = (planemask == ~0U) ? SDfn[alu] : SDfn_PM[alu];
- gp_declare_blt(0);
- gp_set_bpp(pxMap->drawable.bitsPerPixel);
-
- gp_set_raster_operation(op);
+ gp_declare_blt(0);
+ gp_set_bpp(pxMap->drawable.bitsPerPixel);
- if (planemask != ~0U)
- gp_set_solid_pattern(planemask);
+ gp_set_raster_operation(op);
- exaScratch.op = op;
+ if (planemask != ~0U)
+ gp_set_solid_pattern(planemask);
- gp_set_solid_source(fg);
- gp_set_strides(pitch, pitch);
- gp_write_parameters();
- return TRUE;
+ exaScratch.op = op;
+
+ gp_set_solid_source(fg);
+ gp_set_strides(pitch, pitch);
+ gp_write_parameters();
+ return TRUE;
}
static void
lx_do_solid(PixmapPtr pxMap, int x1, int y1, int x2, int y2)
{
- int bpp = (pxMap->drawable.bitsPerPixel + 7) / 8;
- int pitch = exaGetPixmapPitch(pxMap);
- unsigned int offset = exaGetPixmapOffset(pxMap) + (pitch * y1) + (bpp * x1);
+ int bpp = (pxMap->drawable.bitsPerPixel + 7) / 8;
+ int pitch = exaGetPixmapPitch(pxMap);
+ unsigned int offset =
+ exaGetPixmapOffset(pxMap) + (pitch * y1) + (bpp * x1);
- gp_declare_blt(lx_fill_flags(x1, y1,x2-x1,y2-y1, exaScratch.op));
- gp_pattern_fill(offset, x2-x1, y2-y1);
+ gp_declare_blt(lx_fill_flags(x1, y1, x2 - x1, y2 - y1, exaScratch.op));
+ gp_pattern_fill(offset, x2 - x1, y2 - y1);
}
static Bool
-lx_prepare_copy( PixmapPtr pxSrc, PixmapPtr pxDst, int dx, int dy,
- int alu, Pixel planemask)
+lx_prepare_copy(PixmapPtr pxSrc, PixmapPtr pxDst, int dx, int dy,
+ int alu, Pixel planemask)
{
- int dpitch = exaGetPixmapPitch(pxDst);
- int op = (planemask == ~0U) ? SDfn[alu] : SDfn_PM[alu];
+ int dpitch = exaGetPixmapPitch(pxDst);
+ int op = (planemask == ~0U) ? SDfn[alu] : SDfn_PM[alu];
- gp_declare_blt(0);
- gp_set_bpp(pxDst->drawable.bitsPerPixel);
+ gp_declare_blt(0);
+ gp_set_bpp(pxDst->drawable.bitsPerPixel);
- gp_set_raster_operation(op);
+ gp_set_raster_operation(op);
- if (planemask != ~0U)
- gp_set_solid_pattern(planemask);
+ if (planemask != ~0U)
+ gp_set_solid_pattern(planemask);
- exaScratch.srcOffset = exaGetPixmapOffset(pxSrc);
- exaScratch.srcPitch = exaGetPixmapPitch(pxSrc);
- exaScratch.srcBpp = (pxSrc->drawable.bitsPerPixel + 7) / 8;
+ exaScratch.srcOffset = exaGetPixmapOffset(pxSrc);
+ exaScratch.srcPitch = exaGetPixmapPitch(pxSrc);
+ exaScratch.srcBpp = (pxSrc->drawable.bitsPerPixel + 7) / 8;
- exaScratch.op = op;
+ exaScratch.op = op;
- gp_set_strides(dpitch, exaScratch.srcPitch);
- gp_write_parameters();
- return TRUE;
+ gp_set_strides(dpitch, exaScratch.srcPitch);
+ gp_write_parameters();
+ return TRUE;
}
static void
lx_do_copy(PixmapPtr pxDst, int srcX, int srcY,
- int dstX, int dstY, int w, int h)
+ int dstX, int dstY, int w, int h)
{
- int dstBpp = (pxDst->drawable.bitsPerPixel + 7) / 8;
- int dstPitch = exaGetPixmapPitch(pxDst);
- unsigned int srcOffset, dstOffset;
- int flags = 0;
+ int dstBpp = (pxDst->drawable.bitsPerPixel + 7) / 8;
+ int dstPitch = exaGetPixmapPitch(pxDst);
+ unsigned int srcOffset, dstOffset;
+ int flags = 0;
- gp_declare_blt(lx_copy_flags(srcX, srcY, dstX, dstY,w,h, exaScratch.op));
+ gp_declare_blt(lx_copy_flags(srcX, srcY, dstX, dstY, w, h,
+ exaScratch.op));
- //gp_declare_blt(0);
+ //gp_declare_blt(0);
- srcOffset = exaScratch.srcOffset + (exaScratch.srcPitch * srcY) +
- (exaScratch.srcBpp) * srcX;
+ srcOffset = exaScratch.srcOffset + (exaScratch.srcPitch * srcY) +
+ (exaScratch.srcBpp) * srcX;
- dstOffset = exaGetPixmapOffset(pxDst) + (dstPitch * dstY) +
- (dstBpp * dstX);
+ dstOffset = exaGetPixmapOffset(pxDst) + (dstPitch * dstY) +
+ (dstBpp * dstX);
- flags = 0;
+ flags = 0;
- if (dstX > srcX)
- flags |= CIMGP_NEGXDIR;
+ if (dstX > srcX)
+ flags |= CIMGP_NEGXDIR;
- if (dstY > srcY)
- flags |= CIMGP_NEGYDIR;
+ if (dstY > srcY)
+ flags |= CIMGP_NEGYDIR;
- gp_screen_to_screen_blt(dstOffset, srcOffset, w, h, flags);
+ gp_screen_to_screen_blt(dstOffset, srcOffset, w, h, flags);
}
/* Composite operations
@@ -383,257 +381,277 @@ PictOpAtop
PictOpXor
*/
-struct blend_ops_t {
- int operation;
- int type;
- int channel;
+struct blend_ops_t
+{
+ int operation;
+ int type;
+ int channel;
} lx_alpha_ops[] = {
- /* PictOpClear */
- { CIMGP_ALPHA_TIMES_A, CIMGP_CONSTANT_ALPHA, CIMGP_CHANNEL_A_SOURCE }, { },
- /* PictOpSrc */
- { CIMGP_ALPHA_TIMES_A, CIMGP_ALPHA_EQUALS_ONE, CIMGP_CHANNEL_A_SOURCE }, { },
- /* PictOpDst */
- { CIMGP_ALPHA_TIMES_A, CIMGP_ALPHA_EQUALS_ONE, CIMGP_CHANNEL_A_DEST }, { },
- /* PictOpOver*/
- { CIMGP_ALPHA_A_PLUS_BETA_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE },
- { },
- /* PictOpOverReverse */
- { CIMGP_ALPHA_A_PLUS_BETA_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_DEST },
- { },
- /* PictOpIn */
- { CIMGP_ALPHA_TIMES_A, CIMGP_CHANNEL_B_ALPHA, CIMGP_CHANNEL_A_SOURCE }, { },
- /* PictOpInReverse */
- { CIMGP_ALPHA_TIMES_A, CIMGP_CHANNEL_B_ALPHA, CIMGP_CHANNEL_A_DEST }, { },
- /* PictOpOut */
- { CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE }, { },
- /* PictOpOutReverse */
- { CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_DEST }, { },
- /* SrcAtop */
- { CIMGP_ALPHA_TIMES_A, CIMGP_CHANNEL_B_ALPHA, CIMGP_CHANNEL_A_DEST },
- { CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE },
- /* SrcAtopReverse */
- { CIMGP_ALPHA_TIMES_A, CIMGP_CHANNEL_B_ALPHA, CIMGP_CHANNEL_A_SOURCE },
- { CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_DEST },
- /* Xor */
- { CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE },
- { CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE },
- /* PictOpAdd */
- { CIMGP_A_PLUS_BETA_B, CIMGP_CONSTANT_ALPHA, CIMGP_CHANNEL_A_SOURCE }, { }
+ /* PictOpClear */
+ {
+ CIMGP_ALPHA_TIMES_A, CIMGP_CONSTANT_ALPHA, CIMGP_CHANNEL_A_SOURCE}, {
+ },
+ /* PictOpSrc */
+ {
+ CIMGP_ALPHA_TIMES_A, CIMGP_ALPHA_EQUALS_ONE, CIMGP_CHANNEL_A_SOURCE}, {
+ },
+ /* PictOpDst */
+ {
+ CIMGP_ALPHA_TIMES_A, CIMGP_ALPHA_EQUALS_ONE, CIMGP_CHANNEL_A_DEST}, {
+ },
+ /* PictOpOver */
+ {
+ CIMGP_ALPHA_A_PLUS_BETA_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE},
+ {
+ },
+ /* PictOpOverReverse */
+ {
+ CIMGP_ALPHA_A_PLUS_BETA_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_DEST}, {
+ },
+ /* PictOpIn */
+ {
+ CIMGP_ALPHA_TIMES_A, CIMGP_CHANNEL_B_ALPHA, CIMGP_CHANNEL_A_SOURCE}, {
+ },
+ /* PictOpInReverse */
+ {
+ CIMGP_ALPHA_TIMES_A, CIMGP_CHANNEL_B_ALPHA, CIMGP_CHANNEL_A_DEST}, {
+ },
+ /* PictOpOut */
+ {
+ CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE}, {
+ },
+ /* PictOpOutReverse */
+ {
+ CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_DEST}, {
+ },
+ /* SrcAtop */
+ {
+ CIMGP_ALPHA_TIMES_A, CIMGP_CHANNEL_B_ALPHA, CIMGP_CHANNEL_A_DEST}, {
+ CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE},
+ /* SrcAtopReverse */
+ {
+ CIMGP_ALPHA_TIMES_A, CIMGP_CHANNEL_B_ALPHA, CIMGP_CHANNEL_A_SOURCE}, {
+ CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_DEST},
+ /* Xor */
+ {
+ CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE}, {
+ CIMGP_BETA_TIMES_B, CIMGP_CHANNEL_A_ALPHA, CIMGP_CHANNEL_A_SOURCE},
+ /* PictOpAdd */
+ {
+ CIMGP_A_PLUS_BETA_B, CIMGP_CONSTANT_ALPHA, CIMGP_CHANNEL_A_SOURCE}, {
+ }
};
-
#define ARRAY_SIZE(a) (sizeof((a)) / (sizeof(*(a))))
-static const struct exa_format_t *lx_get_format(PicturePtr p)
+static const struct exa_format_t *
+lx_get_format(PicturePtr p)
{
- int i;
- unsigned int format = p->format;
+ int i;
+ unsigned int format = p->format;
- for(i = 0; i < ARRAY_SIZE(lx_exa_formats); i++) {
+ for (i = 0; i < ARRAY_SIZE(lx_exa_formats); i++) {
- if (lx_exa_formats[i].bpp < PICT_FORMAT_BPP(format))
- break;
- else if (lx_exa_formats[i].bpp != PICT_FORMAT_BPP(format))
- continue;
+ if (lx_exa_formats[i].bpp < PICT_FORMAT_BPP(format))
+ break;
+ else if (lx_exa_formats[i].bpp != PICT_FORMAT_BPP(format))
+ continue;
- if (lx_exa_formats[i].exa == format)
- return (&lx_exa_formats[i]);
- }
+ if (lx_exa_formats[i].exa == format)
+ return (&lx_exa_formats[i]);
+ }
#if 0
- ErrorF("Couldn't match on format %x\n", format);
- ErrorF("BPP = %d, type = %d, ARGB(%d,%d,%d,%d)n",
- PICT_FORMAT_BPP(format),
- PICT_FORMAT_TYPE(format),
- PICT_FORMAT_A(format),
- PICT_FORMAT_R(format),
- PICT_FORMAT_G(format),
- PICT_FORMAT_B(format));
+ ErrorF("Couldn't match on format %x\n", format);
+ ErrorF("BPP = %d, type = %d, ARGB(%d,%d,%d,%d)n",
+ PICT_FORMAT_BPP(format),
+ PICT_FORMAT_TYPE(format),
+ PICT_FORMAT_A(format),
+ PICT_FORMAT_R(format), PICT_FORMAT_G(format), PICT_FORMAT_B(format));
#endif
- return NULL;
+ return NULL;
}
-static Bool lx_check_composite(int op, PicturePtr pSrc, PicturePtr pMsk,
- PicturePtr pDst)
+static Bool
+lx_check_composite(int op, PicturePtr pSrc, PicturePtr pMsk, PicturePtr pDst)
{
- GeodeRec *pGeode = GEODEPTR_FROM_PICTURE(pDst);
+ GeodeRec *pGeode = GEODEPTR_FROM_PICTURE(pDst);
- /* Check that the operation is supported */
+ /* Check that the operation is supported */
- if (op > PictOpAdd)
- return FALSE;
+ if (op > PictOpAdd)
+ return FALSE;
- if (usesPasses(op)) {
+ if (usesPasses(op)) {
if (pGeode->exaBfrOffset == 0 || !pMsk)
- return FALSE;
- }
-
- /* Check that the filter matches what we support */
+ return FALSE;
+ }
- switch(pSrc->filter) {
- case PictFilterNearest:
- case PictFilterFast:
- case PictFilterGood:
- case PictFilterBest:
- break;
+ /* Check that the filter matches what we support */
- default:
- ErrorF("invalid filter %d\n", pSrc->filter);
- return FALSE;
- }
+ switch (pSrc->filter) {
+ case PictFilterNearest:
+ case PictFilterFast:
+ case PictFilterGood:
+ case PictFilterBest:
+ break;
- /* We don't handle transforms */
+ default:
+ ErrorF("invalid filter %d\n", pSrc->filter);
+ return FALSE;
+ }
- if (pSrc->transform)
- return FALSE;
+ /* We don't handle transforms */
+ if (pSrc->transform)
+ return FALSE;
- /* XXX - I don't understand PICT_a8 enough - so I'm punting */
+ /* XXX - I don't understand PICT_a8 enough - so I'm punting */
- if (pSrc->format == PICT_a8 || pDst->format == PICT_a8)
- return FALSE;
+ if (pSrc->format == PICT_a8 || pDst->format == PICT_a8)
+ return FALSE;
- return TRUE;
+ return TRUE;
}
-static Bool lx_prepare_composite(int op, PicturePtr pSrc, PicturePtr pMsk,
- PicturePtr pDst, PixmapPtr pxSrc, PixmapPtr pxMsk,
- PixmapPtr pxDst)
+static Bool
+lx_prepare_composite(int op, PicturePtr pSrc, PicturePtr pMsk,
+ PicturePtr pDst, PixmapPtr pxSrc, PixmapPtr pxMsk, PixmapPtr pxDst)
{
- GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst);
- const struct exa_format_t *srcFmt, *dstFmt;
+ GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst);
+ const struct exa_format_t *srcFmt, *dstFmt;
- /* Get the formats for the source and destination */
+ /* Get the formats for the source and destination */
- if ((srcFmt = lx_get_format(pSrc)) == NULL) {
+ if ((srcFmt = lx_get_format(pSrc)) == NULL) {
ErrorF("EXA: Invalid source format %x\n", pSrc->format);
- return FALSE;
- }
+ return FALSE;
+ }
- if ((dstFmt = lx_get_format(pDst)) == NULL) {
+ if ((dstFmt = lx_get_format(pDst)) == NULL) {
ErrorF("EXA: Invalid destination format %x\n", pDst->format);
return FALSE;
- }
-
- /* Make sure operations that need alpha bits have them */
- /* If a mask is enabled, the alpha will come from there */
+ }
- if (!pMsk && (!srcFmt->alphabits && usesSrcAlpha(op))) {
- ErrorF("EXA: Source needs alpha bits\n");
- return FALSE;
- }
+ /* Make sure operations that need alpha bits have them */
+ /* If a mask is enabled, the alpha will come from there */
- if (!pMsk && (!dstFmt->alphabits && usesDstAlpha(op))) {
- ErrorF("EXA: Dest needs alpha bits\n");
- return FALSE;
- }
+ if (!pMsk && (!srcFmt->alphabits && usesSrcAlpha(op))) {
+ ErrorF("EXA: Source needs alpha bits\n");
+ return FALSE;
+ }
- /* FIXME: See a way around this! */
+ if (!pMsk && (!dstFmt->alphabits && usesDstAlpha(op))) {
+ ErrorF("EXA: Dest needs alpha bits\n");
+ return FALSE;
+ }
- if (srcFmt->alphabits == 0 && dstFmt->alphabits != 0)
- return FALSE;
+ /* FIXME: See a way around this! */
- /* Set up the scratch buffer with the information we need */
+ if (srcFmt->alphabits == 0 && dstFmt->alphabits != 0)
+ return FALSE;
- exaScratch.srcFormat = (struct exa_format_t *) srcFmt;
- exaScratch.dstFormat = (struct exa_format_t *) dstFmt;
- exaScratch.op = op;
- exaScratch.repeat = pSrc->repeat;
- exaScratch.bufferOffset = pGeode->exaBfrOffset;
+ /* Set up the scratch buffer with the information we need */
+ exaScratch.srcFormat = (struct exa_format_t *)srcFmt;
+ exaScratch.dstFormat = (struct exa_format_t *)dstFmt;
+ exaScratch.op = op;
+ exaScratch.repeat = pSrc->repeat;
+ exaScratch.bufferOffset = pGeode->exaBfrOffset;
- if (pMsk && op != PictOpClear) {
- unsigned int srcColor;
- struct blend_ops_t *opPtr = &lx_alpha_ops[op * 2];
- int direction = (opPtr->channel == CIMGP_CHANNEL_A_SOURCE) ? 0 : 1;
+ if (pMsk && op != PictOpClear) {
+ unsigned int srcColor;
+ struct blend_ops_t *opPtr = &lx_alpha_ops[op * 2];
+ int direction = (opPtr->channel == CIMGP_CHANNEL_A_SOURCE) ? 0 : 1;
- /* We can only do masks with a 8bpp or a 4bpp mask */
+ /* We can only do masks with a 8bpp or a 4bpp mask */
- if (pMsk->format != PICT_a8 && pMsk->format != PICT_a4)
- return FALSE;
+ if (pMsk->format != PICT_a8 && pMsk->format != PICT_a4)
+ return FALSE;
- /* Direction 0 indicates src->dst, 1 indiates dst->src */
+ /* Direction 0 indicates src->dst, 1 indiates dst->src */
- if (((direction == 0) && (pxSrc->drawable.bitsPerPixel < 16)) ||
- ((direction == 1) && (pxDst->drawable.bitsPerPixel < 16))) {
- ErrorF("Can't do mask blending with less then 16bpp\n");
- return FALSE;
- }
+ if (((direction == 0) && (pxSrc->drawable.bitsPerPixel < 16)) ||
+ ((direction == 1) && (pxDst->drawable.bitsPerPixel < 16))) {
+ ErrorF("Can't do mask blending with less then 16bpp\n");
+ return FALSE;
+ }
- /* Get the source color */
+ /* Get the source color */
- if (direction == 0)
- exaScratch.srcColor = lx_get_source_color(pxSrc, pSrc->format,
- pDst->format);
- else
- exaScratch.srcColor = lx_get_source_color(pxDst, pDst->format,
- pSrc->format);
+ if (direction == 0)
+ exaScratch.srcColor = lx_get_source_color(pxSrc, pSrc->format,
+ pDst->format);
+ else
+ exaScratch.srcColor = lx_get_source_color(pxDst, pDst->format,
+ pSrc->format);
- /* FIXME: What to do here? */
+ /* FIXME: What to do here? */
- if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1)
- return FALSE;
+ if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1)
+ return FALSE;
- /* Save off the info we need (reuse the source values to save space) */
+ /* Save off the info we need (reuse the source values to save space) */
- exaScratch.type = COMP_TYPE_MASK;
+ exaScratch.type = COMP_TYPE_MASK;
- exaScratch.srcOffset = exaGetPixmapOffset(pxMsk);
- exaScratch.srcPitch = exaGetPixmapPitch(pxMsk);
- exaScratch.srcBpp = (pxMsk->drawable.bitsPerPixel + 7) / 8;
+ exaScratch.srcOffset = exaGetPixmapOffset(pxMsk);
+ exaScratch.srcPitch = exaGetPixmapPitch(pxMsk);
+ exaScratch.srcBpp = (pxMsk->drawable.bitsPerPixel + 7) / 8;
- exaScratch.srcWidth = pMsk->pDrawable->width;
- exaScratch.srcHeight = pMsk->pDrawable->height;
+ exaScratch.srcWidth = pMsk->pDrawable->width;
+ exaScratch.srcHeight = pMsk->pDrawable->height;
- /* Flag to indicate if this a 8BPP or a 4BPP mask */
- exaScratch.fourBpp = (pxMsk->drawable.bitsPerPixel == 4) ? 1 : 0;
+ /* Flag to indicate if this a 8BPP or a 4BPP mask */
+ exaScratch.fourBpp = (pxMsk->drawable.bitsPerPixel == 4) ? 1 : 0;
- /* If the direction is reversed, then remember the source */
+ /* If the direction is reversed, then remember the source */
- if (direction == 1)
- exaScratch.srcPixmap = pxSrc;
- }
- else {
- if (usesPasses(op))
- exaScratch.type = COMP_TYPE_TWOPASS;
- else
- exaScratch.type = COMP_TYPE_ONEPASS;
+ if (direction == 1)
+ exaScratch.srcPixmap = pxSrc;
+ } else {
+ if (usesPasses(op))
+ exaScratch.type = COMP_TYPE_TWOPASS;
+ else
+ exaScratch.type = COMP_TYPE_ONEPASS;
- exaScratch.srcOffset = exaGetPixmapOffset(pxSrc);
- exaScratch.srcPitch = exaGetPixmapPitch(pxSrc);
- exaScratch.srcBpp = (pxSrc->drawable.bitsPerPixel + 7) / 8;
+ exaScratch.srcOffset = exaGetPixmapOffset(pxSrc);
+ exaScratch.srcPitch = exaGetPixmapPitch(pxSrc);
+ exaScratch.srcBpp = (pxSrc->drawable.bitsPerPixel + 7) / 8;
- exaScratch.srcWidth = pSrc->pDrawable->width;
- exaScratch.srcHeight = pSrc->pDrawable->height;
- }
+ exaScratch.srcWidth = pSrc->pDrawable->width;
+ exaScratch.srcHeight = pSrc->pDrawable->height;
+ }
- return TRUE;
+ return TRUE;
}
-static int lx_get_bpp_from_format(int format) {
+static int
+lx_get_bpp_from_format(int format)
+{
- switch(format) {
- case CIMGP_SOURCE_FMT_8_8_8_8:
- case CIMGP_SOURCE_FMT_32BPP_BGR:
- return 32;
+ switch (format) {
+ case CIMGP_SOURCE_FMT_8_8_8_8:
+ case CIMGP_SOURCE_FMT_32BPP_BGR:
+ return 32;
- case CIMGP_SOURCE_FMT_4_4_4_4:
- return 12;
+ case CIMGP_SOURCE_FMT_4_4_4_4:
+ return 12;
- case CIMGP_SOURCE_FMT_0_5_6_5:
- case CIMGP_SOURCE_FMT_16BPP_BGR:
- return 16;
+ case CIMGP_SOURCE_FMT_0_5_6_5:
+ case CIMGP_SOURCE_FMT_16BPP_BGR:
+ return 16;
- case CIMGP_SOURCE_FMT_1_5_5_5:
- case CIMGP_SOURCE_FMT_15BPP_BGR:
- return 15;
+ case CIMGP_SOURCE_FMT_1_5_5_5:
+ case CIMGP_SOURCE_FMT_15BPP_BGR:
+ return 15;
- case CIMGP_SOURCE_FMT_3_3_2:
- return 8;
- }
+ case CIMGP_SOURCE_FMT_3_3_2:
+ return 8;
+ }
- return 0;
+ return 0;
}
/* BGR needs to be set in the source for it to take - so adjust the source
@@ -641,14 +659,15 @@ static int lx_get_bpp_from_format(int format) {
* are the same
*/
-static void lx_set_source_format(int srcFormat, int dstFormat)
+static void
+lx_set_source_format(int srcFormat, int dstFormat)
{
- if (!(srcFormat & 0x10) && (dstFormat & 0x10))
- gp_set_source_format(srcFormat | 0x10);
- else if ((srcFormat & 0x10) && (dstFormat & 0x10))
- gp_set_source_format(srcFormat & ~0x10);
- else
- gp_set_source_format(srcFormat);
+ if (!(srcFormat & 0x10) && (dstFormat & 0x10))
+ gp_set_source_format(srcFormat | 0x10);
+ else if ((srcFormat & 0x10) && (dstFormat & 0x10))
+ gp_set_source_format(srcFormat & ~0x10);
+ else
+ gp_set_source_format(srcFormat);
}
/* If we are converting colors and we need the channel A alpha,
@@ -656,12 +675,11 @@ static void lx_set_source_format(int srcFormat, int dstFormat)
* converting the format
*/
-static inline int get_op_type(struct exa_format_t *src,
- struct exa_format_t *dst, int type)
+static inline int
+get_op_type(struct exa_format_t *src, struct exa_format_t *dst, int type)
{
- return (type == CIMGP_CHANNEL_A_ALPHA &&
- src->alphabits != dst->alphabits) ?
- CIMGP_CONVERTED_ALPHA : type;
+ return (type == CIMGP_CHANNEL_A_ALPHA &&
+ src->alphabits != dst->alphabits) ? CIMGP_CONVERTED_ALPHA : type;
}
/* Note - this is the preferred onepass method. The other will remain
@@ -672,29 +690,30 @@ static inline int get_op_type(struct exa_format_t *src,
static void
lx_composite_onepass(PixmapPtr pxDst, unsigned long dstOffset,
- unsigned long srcOffset, int width, int height)
+ unsigned long srcOffset, int width, int height)
{
- struct blend_ops_t *opPtr;
- int apply, type;
+ struct blend_ops_t *opPtr;
+ int apply, type;
- opPtr = &lx_alpha_ops[exaScratch.op * 2];
+ opPtr = &lx_alpha_ops[exaScratch.op * 2];
- apply = (exaScratch.dstFormat->alphabits != 0 &&
- exaScratch.srcFormat->alphabits != 0) ?
- CIMGP_APPLY_BLEND_TO_ALL : CIMGP_APPLY_BLEND_TO_RGB;
+ apply = (exaScratch.dstFormat->alphabits != 0 &&
+ exaScratch.srcFormat->alphabits != 0) ?
+ CIMGP_APPLY_BLEND_TO_ALL : CIMGP_APPLY_BLEND_TO_RGB;
- gp_declare_blt(0);
- gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
- gp_set_strides(exaGetPixmapPitch(pxDst), exaScratch.srcPitch);
+ gp_declare_blt(0);
+ gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
+ gp_set_strides(exaGetPixmapPitch(pxDst), exaScratch.srcPitch);
- lx_set_source_format(exaScratch.srcFormat->fmt, exaScratch.dstFormat->fmt);
+ lx_set_source_format(exaScratch.srcFormat->fmt,
+ exaScratch.dstFormat->fmt);
- type = get_op_type(exaScratch.srcFormat, exaScratch.dstFormat, opPtr->type);
+ type =
+ get_op_type(exaScratch.srcFormat, exaScratch.dstFormat, opPtr->type);
- gp_set_alpha_operation(opPtr->operation, type,
- opPtr->channel, apply, 0);
+ gp_set_alpha_operation(opPtr->operation, type, opPtr->channel, apply, 0);
- gp_screen_to_screen_convert(dstOffset, srcOffset, width, height, 0);
+ gp_screen_to_screen_convert(dstOffset, srcOffset, width, height, 0);
}
#else
@@ -703,52 +722,52 @@ lx_composite_onepass(PixmapPtr pxDst, unsigned long dstOffset,
static void
lx_composite_onepass(PixmapPtr pxDst, unsigned long dstOffset,
- unsigned long srcOffset, int width, int height)
+ unsigned long srcOffset, int width, int height)
{
- struct blend_ops_t *opPtr;
- int apply, type;
- int sbpp = lx_get_bpp_from_format(exaScratch.srcFormat->fmt);
+ struct blend_ops_t *opPtr;
+ int apply, type;
+ int sbpp = lx_get_bpp_from_format(exaScratch.srcFormat->fmt);
- /* Copy the destination into the scratch buffer */
+ /* Copy the destination into the scratch buffer */
- gp_declare_blt(0);
+ gp_declare_blt(0);
- gp_set_bpp(sbpp);
+ gp_set_bpp(sbpp);
- gp_set_source_format(exaScratch.dstFormat->fmt);
+ gp_set_source_format(exaScratch.dstFormat->fmt);
- gp_set_raster_operation(0xCC);
- gp_set_strides(exaScratch.srcPitch, exaGetPixmapPitch(pxDst));
- gp_screen_to_screen_convert(exaScratch.bufferOffset, dstOffset, width,
- height, 0);
+ gp_set_raster_operation(0xCC);
+ gp_set_strides(exaScratch.srcPitch, exaGetPixmapPitch(pxDst));
+ gp_screen_to_screen_convert(exaScratch.bufferOffset, dstOffset, width,
+ height, 0);
- /* Do the blend */
+ /* Do the blend */
- opPtr = &lx_alpha_ops[exaScratch.op * 2];
- apply = (exaScratch.srcFormat->alphabits == 0) ?
- CIMGP_APPLY_BLEND_TO_RGB : CIMGP_APPLY_BLEND_TO_ALL;
+ opPtr = &lx_alpha_ops[exaScratch.op * 2];
+ apply = (exaScratch.srcFormat->alphabits == 0) ?
+ CIMGP_APPLY_BLEND_TO_RGB : CIMGP_APPLY_BLEND_TO_ALL;
- gp_declare_blt (0);
- gp_set_bpp(sbpp);
+ gp_declare_blt(0);
+ gp_set_bpp(sbpp);
- type = get_op_type(exaScratch.srcFormat, exaScrach.dstFormat, opPtr->type);
+ type =
+ get_op_type(exaScratch.srcFormat, exaScrach.dstFormat, opPtr->type);
- gp_set_alpha_operation(opPtr->operation, type, opPtr->channel,
- apply, 0);
+ gp_set_alpha_operation(opPtr->operation, type, opPtr->channel, apply, 0);
- gp_set_strides(exaScratch.srcPitch, exaScratch.srcPitch);
- gp_screen_to_screen_blt(exaScratch.bufferOffset, srcOffset,
- width, height, 0);
+ gp_set_strides(exaScratch.srcPitch, exaScratch.srcPitch);
+ gp_screen_to_screen_blt(exaScratch.bufferOffset, srcOffset,
+ width, height, 0);
- /* And copy back */
+ /* And copy back */
- gp_declare_blt(0);
- gp_set_bpp(pxDst->drawable.bitsPerPixel);
- gp_set_source_format (exaScratch.srcFormat->fmt);
- gp_set_raster_operation(0xCC);
- gp_set_strides(exaGetPixmapPitch(pxDst), exaScratch.srcPitch);
- gp_screen_to_screen_convert(dstOffset, exaScratch.bufferOffset,
- width, height, 0);
+ gp_declare_blt(0);
+ gp_set_bpp(pxDst->drawable.bitsPerPixel);
+ gp_set_source_format(exaScratch.srcFormat->fmt);
+ gp_set_raster_operation(0xCC);
+ gp_set_strides(exaGetPixmapPitch(pxDst), exaScratch.srcPitch);
+ gp_screen_to_screen_convert(dstOffset, exaScratch.bufferOffset,
+ width, height, 0);
}
#endif
@@ -756,34 +775,36 @@ lx_composite_onepass(PixmapPtr pxDst, unsigned long dstOffset,
#if 0
lx_composite_convert(PixmapPtr pxDst, unsigned long dstOffset,
- unsigned long srcOffset, int width, int height)
+ unsigned long srcOffset, int width, int height)
{
- /* Step 1 - copy the destination into the scratch buffer */
+ /* Step 1 - copy the destination into the scratch buffer */
+
+ gp_declare_blt(0);
+ gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
- gp_declare_blt(0);
- gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
+ gp_set_raster_operation(0xCC);
+ gp_set_strides(exaGetPixmapPitch(pxDst), exaGetPixmapPitch(pxDst));
- gp_set_raster_operation(0xCC);
- gp_set_strides(exaGetPixmapPitch(pxDst), exaGetPixmapPitch(pxDst));
+ gp_screen_to_screen_blt(exaScratch.bufferOffset, dstOffset, width, height,
+ 0);
- gp_screen_to_screen_blt(exaScratch.bufferOffset, dstOffset, width, height, 0);
+ /* Step 2 - Do the original blend */
- /* Step 2 - Do the original blend */
+ lx_composite_onepass(pxDst, exaScratch.bufferOffset, srcOffset, width,
+ height);
- lx_composite_onepass(pxDst, exaScratch.bufferOffset, srcOffset, width, height);
-
- /* Step 3 - copy back and fixup the alpha */
- gp_declare_blt(0);
- gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
- gp_set_strides(exaGetPixmapPitch(pxDst), exaGetPixmapPitch(pxDst));
+ /* Step 3 - copy back and fixup the alpha */
+ gp_declare_blt(0);
+ gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
+ gp_set_strides(exaGetPixmapPitch(pxDst), exaGetPixmapPitch(pxDst));
- /* FIXME: Does this alpha value need to be changed for the mode? */
+ /* FIXME: Does this alpha value need to be changed for the mode? */
- gp_set_alpha_operation(CIMGP_ALPHA_TIMES_A, CIMGP_CONSTANT_ALPHA,
- CIMGP_CHANNEL_A_SOURCE, CIMGP_APPLY_BLEND_TO_ALPHA,
- 1);
-
- gp_screen_to_screen_blt(dstOffset, exaScratch.bufferOffset, width, height, 0);
+ gp_set_alpha_operation(CIMGP_ALPHA_TIMES_A, CIMGP_CONSTANT_ALPHA,
+ CIMGP_CHANNEL_A_SOURCE, CIMGP_APPLY_BLEND_TO_ALPHA, 1);
+
+ gp_screen_to_screen_blt(dstOffset, exaScratch.bufferOffset, width, height,
+ 0);
}
#endif
@@ -791,87 +812,89 @@ lx_composite_convert(PixmapPtr pxDst, unsigned long dstOffset,
/* This function handles the multipass blend functions */
static void
-lx_composite_multipass(PixmapPtr pxDst, unsigned long dstOffset, unsigned long srcOffset, int width, int height)
+lx_composite_multipass(PixmapPtr pxDst, unsigned long dstOffset,
+ unsigned long srcOffset, int width, int height)
{
- struct blend_ops_t *opPtr;
- int sbpp = lx_get_bpp_from_format(exaScratch.srcFormat->fmt);
- int apply, type;
+ struct blend_ops_t *opPtr;
+ int sbpp = lx_get_bpp_from_format(exaScratch.srcFormat->fmt);
+ int apply, type;
- /* Wait until the GP is idle - this will ensure that the scratch buffer
- * isn't occupied */
+ /* Wait until the GP is idle - this will ensure that the scratch buffer
+ * isn't occupied */
- gp_wait_until_idle();
+ gp_wait_until_idle();
- /* Copy the destination to the scratch buffer, and convert it to the
- * source format */
+ /* Copy the destination to the scratch buffer, and convert it to the
+ * source format */
- gp_declare_blt(0);
+ gp_declare_blt(0);
- gp_set_bpp(sbpp);
- gp_set_source_format(exaScratch.dstFormat->fmt);
- gp_set_raster_operation(0xCC);
- gp_set_strides(exaScratch.srcPitch, exaGetPixmapPitch(pxDst));
- gp_screen_to_screen_convert(exaScratch.bufferOffset, dstOffset,
- width, height, 0);
+ gp_set_bpp(sbpp);
+ gp_set_source_format(exaScratch.dstFormat->fmt);
+ gp_set_raster_operation(0xCC);
+ gp_set_strides(exaScratch.srcPitch, exaGetPixmapPitch(pxDst));
+ gp_screen_to_screen_convert(exaScratch.bufferOffset, dstOffset,
+ width, height, 0);
- /* Do the first blend from the source to the scratch buffer */
+ /* Do the first blend from the source to the scratch buffer */
- gp_declare_blt(CIMGP_BLTFLAGS_HAZARD);
- gp_set_bpp(sbpp);
- gp_set_source_format(exaScratch.srcFormat->fmt);
- gp_set_strides(exaScratch.srcPitch, exaScratch.srcPitch);
+ gp_declare_blt(CIMGP_BLTFLAGS_HAZARD);
+ gp_set_bpp(sbpp);
+ gp_set_source_format(exaScratch.srcFormat->fmt);
+ gp_set_strides(exaScratch.srcPitch, exaScratch.srcPitch);
- opPtr = &lx_alpha_ops[exaScratch.op * 2];
+ opPtr = &lx_alpha_ops[exaScratch.op * 2];
- apply = (exaScratch.srcFormat->alphabits == 0) ?
- CIMGP_APPLY_BLEND_TO_RGB : CIMGP_APPLY_BLEND_TO_ALL;
+ apply = (exaScratch.srcFormat->alphabits == 0) ?
+ CIMGP_APPLY_BLEND_TO_RGB : CIMGP_APPLY_BLEND_TO_ALL;
- /* If we're destroying the source alpha bits, then make sure we
- * use the alpha before the color conversion
- */
+ /* If we're destroying the source alpha bits, then make sure we
+ * use the alpha before the color conversion
+ */
- gp_screen_to_screen_blt(exaScratch.bufferOffset, srcOffset, width, height, 0);
+ gp_screen_to_screen_blt(exaScratch.bufferOffset, srcOffset, width, height,
+ 0);
- /* Finally, do the second blend back to the destination */
+ /* Finally, do the second blend back to the destination */
- opPtr = &lx_alpha_ops[(exaScratch.op * 2) + 1];
+ opPtr = &lx_alpha_ops[(exaScratch.op * 2) + 1];
- apply = (exaScratch.dstFormat->alphabits == 0) ?
- CIMGP_APPLY_BLEND_TO_RGB : CIMGP_APPLY_BLEND_TO_ALL;
+ apply = (exaScratch.dstFormat->alphabits == 0) ?
+ CIMGP_APPLY_BLEND_TO_RGB : CIMGP_APPLY_BLEND_TO_ALL;
- gp_declare_blt(CIMGP_BLTFLAGS_HAZARD);
- gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
+ gp_declare_blt(CIMGP_BLTFLAGS_HAZARD);
+ gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
- lx_set_source_format(exaScratch.srcFormat->fmt, exaScratch.dstFormat->fmt);
+ lx_set_source_format(exaScratch.srcFormat->fmt,
+ exaScratch.dstFormat->fmt);
- type = get_op_type(exaScratch.srcFormat, exaScratch.dstFormat, opPtr->type);
+ type =
+ get_op_type(exaScratch.srcFormat, exaScratch.dstFormat, opPtr->type);
- gp_set_alpha_operation(opPtr->operation, type, opPtr->channel,
- apply, 0);
+ gp_set_alpha_operation(opPtr->operation, type, opPtr->channel, apply, 0);
- gp_screen_to_screen_convert(dstOffset, exaScratch.bufferOffset,
- width, height, 0);
+ gp_screen_to_screen_convert(dstOffset, exaScratch.bufferOffset,
+ width, height, 0);
}
static void
lx_do_composite_mask(PixmapPtr pxDst, unsigned long dstOffset,
- unsigned int maskOffset, int width, int height)
+ unsigned int maskOffset, int width, int height)
{
- GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst);
- unsigned char *data = pGeode->FBBase + maskOffset;
+ GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst);
+ unsigned char *data = pGeode->FBBase + maskOffset;
- struct blend_ops_t *opPtr = &lx_alpha_ops[exaScratch.op * 2];
+ struct blend_ops_t *opPtr = &lx_alpha_ops[exaScratch.op * 2];
- gp_declare_blt (0);
+ gp_declare_blt(0);
- gp_set_source_format(exaScratch.srcFormat->fmt);
- gp_set_strides(exaGetPixmapPitch(pxDst), exaScratch.srcPitch);
- gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
- gp_set_solid_source (exaScratch.srcColor);
+ gp_set_source_format(exaScratch.srcFormat->fmt);
+ gp_set_strides(exaGetPixmapPitch(pxDst), exaScratch.srcPitch);
+ gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt));
+ gp_set_solid_source(exaScratch.srcColor);
- gp_blend_mask_blt(dstOffset, 0, width, height, maskOffset,
- exaScratch.srcPitch, opPtr->operation,
- exaScratch.fourBpp);
+ gp_blend_mask_blt(dstOffset, 0, width, height, maskOffset,
+ exaScratch.srcPitch, opPtr->operation, exaScratch.fourBpp);
}
#define GetPixmapOffset(px, x, y) ( exaGetPixmapOffset((px)) + \
@@ -880,112 +903,120 @@ lx_do_composite_mask(PixmapPtr pxDst, unsigned long dstOffset,
static void
lx_do_composite(PixmapPtr pxDst, int srcX, int srcY, int maskX,
- int maskY, int dstX, int dstY, int width, int height) {
-
- struct blend_ops_t *opPtr = &lx_alpha_ops[exaScratch.op * 2];
-
- unsigned int dstOffset, srcOffset;
-
- unsigned int opX = dstX;
- unsigned int opY = dstY;
- unsigned int opWidth = width;
- unsigned int opHeight = height;
-
- if (exaScratch.type == COMP_TYPE_MASK)
- srcOffset = exaScratch.srcOffset + (maskY * exaScratch.srcPitch) +
- (maskX * exaScratch.srcBpp);
- else
- srcOffset = exaScratch.srcOffset + (srcY * exaScratch.srcPitch) +
- (srcX * exaScratch.srcBpp);
-
- /* Adjust the width / height of the operation the size of the source */
-
- if (exaScratch.srcWidth < width)
- opWidth = exaScratch.srcWidth;
-
- if (exaScratch.srcHeight < height)
- opHeight = exaScratch.srcHeight;
+ int maskY, int dstX, int dstY, int width, int height)
+{
- while(1) {
- dstOffset = GetPixmapOffset(pxDst, opX, opY);
+ struct blend_ops_t *opPtr = &lx_alpha_ops[exaScratch.op * 2];
- switch(exaScratch.type) {
- case COMP_TYPE_MASK: {
- int direction = (opPtr->channel == CIMGP_CHANNEL_A_SOURCE) ? 0 : 1;
+ unsigned int dstOffset, srcOffset;
- if (direction == 1) {
- dstOffset = GetPixmapOffset(exaScratch.srcPixmap, dstX,dstY);
- lx_do_composite_mask(exaScratch.srcPixmap, dstOffset, srcOffset,
- opWidth, opHeight);
- }
- else {
- lx_do_composite_mask(pxDst, dstOffset, srcOffset, opWidth, opHeight);
- }
- }
- break;
+ unsigned int opX = dstX;
+ unsigned int opY = dstY;
+ unsigned int opWidth = width;
+ unsigned int opHeight = height;
- case COMP_TYPE_ONEPASS:
- lx_composite_onepass(pxDst, dstOffset, srcOffset, opWidth, opHeight);
- break;
+ if (exaScratch.type == COMP_TYPE_MASK)
+ srcOffset = exaScratch.srcOffset + (maskY * exaScratch.srcPitch) +
+ (maskX * exaScratch.srcBpp);
+ else
+ srcOffset = exaScratch.srcOffset + (srcY * exaScratch.srcPitch) +
+ (srcX * exaScratch.srcBpp);
+
+ /* Adjust the width / height of the operation the size of the source */
+
+ if (exaScratch.srcWidth < width)
+ opWidth = exaScratch.srcWidth;
+
+ if (exaScratch.srcHeight < height)
+ opHeight = exaScratch.srcHeight;
+
+ while (1) {
+ dstOffset = GetPixmapOffset(pxDst, opX, opY);
+
+ switch (exaScratch.type) {
+ case COMP_TYPE_MASK:{
+ int direction =
+ (opPtr->channel == CIMGP_CHANNEL_A_SOURCE) ? 0 : 1;
+
+ if (direction == 1) {
+ dstOffset =
+ GetPixmapOffset(exaScratch.srcPixmap, dstX, dstY);
+ lx_do_composite_mask(exaScratch.srcPixmap, dstOffset,
+ srcOffset, opWidth, opHeight);
+ } else {
+ lx_do_composite_mask(pxDst, dstOffset, srcOffset, opWidth,
+ opHeight);
+ }
+ }
+ break;
+
+ case COMP_TYPE_ONEPASS:
+ lx_composite_onepass(pxDst, dstOffset, srcOffset, opWidth,
+ opHeight);
+ break;
+
+ case COMP_TYPE_TWOPASS:
+ lx_composite_multipass(pxDst, dstOffset, srcOffset, opWidth,
+ opHeight);
+ break;
+ }
- case COMP_TYPE_TWOPASS:
- lx_composite_multipass(pxDst, dstOffset, srcOffset, opWidth, opHeight);
- break;
- }
+ if (!exaScratch.repeat)
+ break;
- if (!exaScratch.repeat)
- break;
+ opX += opWidth;
- opX += opWidth;
+ if (opX >= dstX + width) {
+ opX = dstX;
+ opY += opHeight;
- if (opX >= dstX + width) {
- opX = dstX;
- opY += opHeight;
+ if (opY >= dstY + height)
+ break;
+ }
- if (opY >= dstY + height)
- break;
+ opWidth = ((dstX + width) - opX) > exaScratch.srcWidth ?
+ exaScratch.srcWidth : (dstX + width) - opX;
+ opHeight = ((dstY + height) - opY) > exaScratch.srcHeight ?
+ exaScratch.srcHeight : (dstY + height) - opY;
}
-
- opWidth = ((dstX + width) - opX) > exaScratch.srcWidth ?
- exaScratch.srcWidth : (dstX + width) - opX;
- opHeight = ((dstY + height) - opY) > exaScratch.srcHeight ?
- exaScratch.srcHeight : (dstY + height) - opY;
- }
}
-static void lx_wait_marker(ScreenPtr PScreen, int marker)
+static void
+lx_wait_marker(ScreenPtr PScreen, int marker)
{
- gp_wait_until_idle();
+ gp_wait_until_idle();
}
-static void lx_done(PixmapPtr ptr)
+static void
+lx_done(PixmapPtr ptr)
{
}
-Bool LXExaInit(ScreenPtr pScreen)
+Bool
+LXExaInit(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- ExaDriverPtr pExa = pGeode->pExa;
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ ExaDriverPtr pExa = pGeode->pExa;
- pExa->exa_major = EXA_VERSION_MAJOR;
- pExa->exa_minor = EXA_VERSION_MINOR;
+ pExa->exa_major = EXA_VERSION_MAJOR;
+ pExa->exa_minor = EXA_VERSION_MINOR;
- pExa->WaitMarker = lx_wait_marker;
+ pExa->WaitMarker = lx_wait_marker;
- pExa->PrepareSolid = lx_prepare_solid;
- pExa->Solid = lx_do_solid;
- pExa->DoneSolid = lx_done;
+ pExa->PrepareSolid = lx_prepare_solid;
+ pExa->Solid = lx_do_solid;
+ pExa->DoneSolid = lx_done;
- pExa->PrepareCopy = lx_prepare_copy;
- pExa->Copy = lx_do_copy;
- pExa->DoneCopy = lx_done;
+ pExa->PrepareCopy = lx_prepare_copy;
+ pExa->Copy = lx_do_copy;
+ pExa->DoneCopy = lx_done;
- /* Composite */
- pExa->CheckComposite = lx_check_composite;
- pExa->PrepareComposite = lx_prepare_composite;
- pExa->Composite = lx_do_composite;
- pExa->DoneComposite = lx_done;
+ /* Composite */
+ pExa->CheckComposite = lx_check_composite;
+ pExa->PrepareComposite = lx_prepare_composite;
+ pExa->Composite = lx_do_composite;
+ pExa->DoneComposite = lx_done;
- return exaDriverInit(pScreen, pGeode->pExa);
+ return exaDriverInit(pScreen, pGeode->pExa);
}
diff --git a/src/lx_randr.c b/src/lx_randr.c
index df9133c..0d2a8e5 100644
--- a/src/lx_randr.c
+++ b/src/lx_randr.c
@@ -2,7 +2,7 @@
* Copyright (C) 2002 Keith Packard, member of The XFree86 Project, Inc.
* Copyright (c) 2006 Advanced Micro Devices, Inc.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
@@ -58,11 +58,13 @@ typedef struct _LXRandRInfo
#if AMD_OLDPRIV
static int LXRandRIndex;
+
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[LXRandRIndex].ptr)
#else
static DevPrivateKey LXRandRKey;
+
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
dixLookupPrivate(&(p)->devPrivates, LXRandRKey));
@@ -206,7 +208,7 @@ LXRandRSetMode(ScreenPtr pScreen,
* Get the new Screen pixmap ptr as SwitchMode might have called
* ModifyPixmapHeader and xf86EnableDisableFBAccess will put it back...
* Unfortunately.
-
+
*/
pspix = (*pScreen->GetScreenPixmap) (pScreen);
@@ -312,7 +314,6 @@ LXRandRInit(ScreenPtr pScreen, int rotation)
if (LXRandRGeneration != serverGeneration) {
LXRandRGeneration = serverGeneration;
}
-
#if AMD_OLDPRIV
LXRandRIndex = AllocateScreenPrivateIndex();
#else
diff --git a/src/lx_regacc.c b/src/lx_regacc.c
index 2acf5ce..4a5a89b 100644
--- a/src/lx_regacc.c
+++ b/src/lx_regacc.c
@@ -25,16 +25,16 @@
*/
/*
- * This is the main file used to add Cimarron graphics support to a software
+ * This is the main file used to add Cimarron graphics support to a software
* project. The main reason to have a single file include the other files
* is that it centralizes the location of the compiler options. This file
* should be tuned for a specific implementation, and then modified as needed
* for new Cimarron releases. The releases.txt file indicates any updates to
- * this main file, such as a new definition for a new hardware platform.
+ * this main file, such as a new definition for a new hardware platform.
*
* In other words, this file should be copied from the Cimarron source files
- * once when a software project starts, and then maintained as necessary.
- * It should not be recopied with new versions of Cimarron unless the
+ * once when a software project starts, and then maintained as necessary.
+ * It should not be recopied with new versions of Cimarron unless the
* developer is willing to tune the file again for the specific project.
*/
diff --git a/src/lx_rotate.c b/src/lx_rotate.c
index 16096d9..c63fb22 100644
--- a/src/lx_rotate.c
+++ b/src/lx_rotate.c
@@ -31,14 +31,14 @@
#include "shadow.h"
#include "geode.h"
-static void
-LXShadowSave(ScreenPtr pScreen, ExaOffscreenArea *area)
+static void
+LXShadowSave(ScreenPtr pScreen, ExaOffscreenArea * area)
{
- ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (area == pGeode->shadowArea)
- pGeode->shadowArea = NULL;
+ if (area == pGeode->shadowArea)
+ pGeode->shadowArea = NULL;
}
static void *
@@ -57,172 +57,175 @@ LXWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode,
static void
LXUpdateFunc(ScreenPtr pScreen, shadowBufPtr pBuf)
{
- RegionPtr damage = shadowDamage (pBuf);
-
- int nbox = REGION_NUM_RECTS (damage);
- BoxPtr pbox = REGION_RECTS (damage);
- int x, y, w, h, degrees;
- FbStride shaStride;
- FbBits *shaBits;
- int shaBpp, dx, dy,dw, dh;
- int shaXoff, shaYoff;
- unsigned int srcOffset, dstOffset;
- PixmapPtr pShadow = pBuf->pPixmap;
- ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff,
- shaYoff);
-
- /* Set up the blt */
-
- gp_wait_until_idle();
- gp_declare_blt(0);
-
- gp_set_bpp(pScrni->bitsPerPixel);
-
- switch(shaBpp) {
- case 8:
- gp_set_source_format(CIMGP_SOURCE_FMT_3_3_2);
- break;
-
- case 16:
- gp_set_source_format(CIMGP_SOURCE_FMT_0_5_6_5);
- break;
-
- case 24:
- case 32:
- gp_set_source_format(CIMGP_SOURCE_FMT_8_8_8_8);
- break;
- }
-
- gp_set_raster_operation(0xCC);
- gp_write_parameters();
-
- while(nbox--) {
- x = pbox->x1;
- y = pbox->y1;
- w = (pbox->x2 - pbox->x1);
- h = pbox->y2 - pbox->y1;
-
- srcOffset = ((unsigned long) shaBits) - ((unsigned long) pGeode->FBBase);
- srcOffset += (y * pGeode->Pitch) + (x * (shaBpp >> 3));
-
- switch(pGeode->rotation) {
- case RR_Rotate_0:
- dx = x;
- dy = y;
- dw = w;
- dh = h;
- degrees = 0;
- break;
-
- case RR_Rotate_90:
- dx = (pScrni->pScreen->height - 1) - (y + (h-1));
- dy = x;
- dw = h;
- dh = w;
- degrees = 90;
- break;
-
- case RR_Rotate_180:
- dx = (pScrni->pScreen->width - 1) - (x + (w-1));
- dy = (pScrni->pScreen->height - 1) - (y + (h-1));
- dw = w;
- dh = h;
-
- degrees = 180;
- break;
-
- case RR_Rotate_270:
- dy = (pScrni->pScreen->width - 1) - (x + (w-1));
- dx = y;
- dw = h;
- dh = w;
-
- degrees = 270;
- break;
- }
+ RegionPtr damage = shadowDamage(pBuf);
+
+ int nbox = REGION_NUM_RECTS(damage);
+ BoxPtr pbox = REGION_RECTS(damage);
+ int x, y, w, h, degrees;
+ FbStride shaStride;
+ FbBits *shaBits;
+ int shaBpp, dx, dy, dw, dh;
+ int shaXoff, shaYoff;
+ unsigned int srcOffset, dstOffset;
+ PixmapPtr pShadow = pBuf->pPixmap;
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ fbGetDrawable(&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff,
+ shaYoff);
+
+ /* Set up the blt */
- dstOffset = pGeode->displayOffset +
- (dy * pGeode->displayPitch) + (dx * (pScrni->bitsPerPixel >> 3));
+ gp_wait_until_idle();
+ gp_declare_blt(0);
- gp_declare_blt(CIMGP_BLTFLAGS_HAZARD);
- gp_set_strides(pGeode->displayPitch, pGeode->Pitch);
- gp_rotate_blt(dstOffset, srcOffset, w, h, degrees);
- pbox++;
- }
+ gp_set_bpp(pScrni->bitsPerPixel);
+
+ switch (shaBpp) {
+ case 8:
+ gp_set_source_format(CIMGP_SOURCE_FMT_3_3_2);
+ break;
+
+ case 16:
+ gp_set_source_format(CIMGP_SOURCE_FMT_0_5_6_5);
+ break;
+
+ case 24:
+ case 32:
+ gp_set_source_format(CIMGP_SOURCE_FMT_8_8_8_8);
+ break;
+ }
+
+ gp_set_raster_operation(0xCC);
+ gp_write_parameters();
+
+ while (nbox--) {
+ x = pbox->x1;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1);
+ h = pbox->y2 - pbox->y1;
+
+ srcOffset =
+ ((unsigned long)shaBits) - ((unsigned long)pGeode->FBBase);
+ srcOffset += (y * pGeode->Pitch) + (x * (shaBpp >> 3));
+
+ switch (pGeode->rotation) {
+ case RR_Rotate_0:
+ dx = x;
+ dy = y;
+ dw = w;
+ dh = h;
+ degrees = 0;
+ break;
+
+ case RR_Rotate_90:
+ dx = (pScrni->pScreen->height - 1) - (y + (h - 1));
+ dy = x;
+ dw = h;
+ dh = w;
+ degrees = 90;
+ break;
+
+ case RR_Rotate_180:
+ dx = (pScrni->pScreen->width - 1) - (x + (w - 1));
+ dy = (pScrni->pScreen->height - 1) - (y + (h - 1));
+ dw = w;
+ dh = h;
+
+ degrees = 180;
+ break;
+
+ case RR_Rotate_270:
+ dy = (pScrni->pScreen->width - 1) - (x + (w - 1));
+ dx = y;
+ dw = h;
+ dh = w;
+
+ degrees = 270;
+ break;
+ }
+
+ dstOffset = pGeode->displayOffset +
+ (dy * pGeode->displayPitch) + (dx * (pScrni->bitsPerPixel >> 3));
+
+ gp_declare_blt(CIMGP_BLTFLAGS_HAZARD);
+ gp_set_strides(pGeode->displayPitch, pGeode->Pitch);
+ gp_rotate_blt(dstOffset, srcOffset, w, h, degrees);
+ pbox++;
+ }
}
-Bool LXSetRotatePitch(ScrnInfoPtr pScrni)
+Bool
+LXSetRotatePitch(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- pScrni->displayWidth = pGeode->displayWidth;
+ pScrni->displayWidth = pGeode->displayWidth;
- if (pGeode->Compression)
- pGeode->Pitch = GeodeCalculatePitchBytes(pScrni->displayWidth,
- pScrni->bitsPerPixel);
- else
- pGeode->Pitch = (pScrni->displayWidth *
- (pScrni->bitsPerPixel >> 3));
- return TRUE;
+ if (pGeode->Compression)
+ pGeode->Pitch = GeodeCalculatePitchBytes(pScrni->displayWidth,
+ pScrni->bitsPerPixel);
+ else
+ pGeode->Pitch = (pScrni->displayWidth * (pScrni->bitsPerPixel >> 3));
+ return TRUE;
}
-Bool LXAllocShadow(ScrnInfoPtr pScrni)
+Bool
+LXAllocShadow(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- PixmapPtr pPixmap;
-
- int size;
-
- if (pGeode->rotation == RR_Rotate_0) {
-
- if (pGeode->shadowArea) {
- exaOffscreenFree(pScrni->pScreen, pGeode->shadowArea);
- pGeode->shadowArea = NULL;
- }
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ PixmapPtr pPixmap;
- pScrni->fbOffset = pGeode->displayOffset;
- }
- else {
- if (pGeode->rotation == RR_Rotate_90 || pGeode->rotation == RR_Rotate_270)
- size = pGeode->displayPitch * pScrni->virtualX;
- else
- size = pGeode->displayPitch * pScrni->virtualY;
-
- if (pGeode->shadowArea) {
+ int size;
- if (pGeode->shadowArea->size < size) {
- exaOffscreenFree(pScrni->pScreen,pGeode->shadowArea);
- pGeode->shadowArea = NULL;
- }
- }
+ if (pGeode->rotation == RR_Rotate_0) {
+
+ if (pGeode->shadowArea) {
+ exaOffscreenFree(pScrni->pScreen, pGeode->shadowArea);
+ pGeode->shadowArea = NULL;
+ }
- if (pGeode->shadowArea == NULL) {
- pGeode->shadowArea = exaOffscreenAlloc(pScrni->pScreen, size, 32, TRUE,
- LXShadowSave, pGeode);
-
- if (pGeode->shadowArea == NULL)
- return FALSE;
+ pScrni->fbOffset = pGeode->displayOffset;
+ } else {
+ if (pGeode->rotation == RR_Rotate_90
+ || pGeode->rotation == RR_Rotate_270)
+ size = pGeode->displayPitch * pScrni->virtualX;
+ else
+ size = pGeode->displayPitch * pScrni->virtualY;
+
+ if (pGeode->shadowArea) {
+
+ if (pGeode->shadowArea->size < size) {
+ exaOffscreenFree(pScrni->pScreen, pGeode->shadowArea);
+ pGeode->shadowArea = NULL;
+ }
+ }
+
+ if (pGeode->shadowArea == NULL) {
+ pGeode->shadowArea =
+ exaOffscreenAlloc(pScrni->pScreen, size, 32, TRUE,
+ LXShadowSave, pGeode);
+
+ if (pGeode->shadowArea == NULL)
+ return FALSE;
+ }
+
+ pScrni->fbOffset = pGeode->shadowArea->offset;
}
-
- pScrni->fbOffset = pGeode->shadowArea->offset;
- }
-
- pPixmap = pScrni->pScreen->GetScreenPixmap(pScrni->pScreen);
-
- pScrni->pScreen->ModifyPixmapHeader(pPixmap,
- pScrni->pScreen->width,
- pScrni->pScreen->height,
- pScrni->pScreen->rootDepth,
- pScrni->bitsPerPixel,
- PixmapBytePad(pScrni->displayWidth, pScrni->pScreen->rootDepth),
- (pointer) (pGeode->FBBase + pScrni->fbOffset));
-
- return TRUE;
+
+ pPixmap = pScrni->pScreen->GetScreenPixmap(pScrni->pScreen);
+
+ pScrni->pScreen->ModifyPixmapHeader(pPixmap,
+ pScrni->pScreen->width,
+ pScrni->pScreen->height,
+ pScrni->pScreen->rootDepth,
+ pScrni->bitsPerPixel,
+ PixmapBytePad(pScrni->displayWidth, pScrni->pScreen->rootDepth),
+ (pointer) (pGeode->FBBase + pScrni->fbOffset));
+
+ return TRUE;
}
-
+
Bool
LXRotate(ScrnInfoPtr pScrni, DisplayModePtr mode)
{
@@ -246,26 +249,26 @@ LXRotate(ScrnInfoPtr pScrni, DisplayModePtr mode)
LXSetRotatePitch(pScrni);
if (pGeode->rotation != RR_Rotate_0) {
-
- ret = shadowAdd(pScrni->pScreen, pPixmap, LXUpdateFunc,
- LXWindowLinear, pGeode->rotation, NULL);
- if (!ret)
- goto error;
+ ret = shadowAdd(pScrni->pScreen, pPixmap, LXUpdateFunc,
+ LXWindowLinear, pGeode->rotation, NULL);
+
+ if (!ret)
+ goto error;
}
if (LXAllocShadow(pScrni))
- return TRUE;
+ return TRUE;
-error:
+ error:
/* Restore the old rotation */
pScrni->displayWidth = curdw;
if (curr & (RR_Rotate_0 | RR_Rotate_180)) {
- pScrni->pScreen->width = pScrni->virtualX;
- pScrni->pScreen->height = pScrni->virtualY;
+ pScrni->pScreen->width = pScrni->virtualX;
+ pScrni->pScreen->height = pScrni->virtualY;
} else {
- pScrni->pScreen->width = pScrni->virtualY;
+ pScrni->pScreen->width = pScrni->virtualY;
pScrni->pScreen->height = pScrni->virtualX;
}
diff --git a/src/lx_vga.c b/src/lx_vga.c
index 699ca21..78317e5 100644
--- a/src/lx_vga.c
+++ b/src/lx_vga.c
@@ -38,5 +38,6 @@ int
gu3_get_vga_active(void)
{
int data = READ_REG32(DC3_GENERAL_CFG);
+
return (data & DC3_GCFG_VGAE) ? 1 : 0;
}
diff --git a/src/lx_video.c b/src/lx_video.c
index a9b3672..dbda9f9 100644
--- a/src/lx_video.c
+++ b/src/lx_video.c
@@ -26,7 +26,7 @@
/* TODO:
Add rotation
Add back in double buffering?
-
+
*/
#ifdef HAVE_CONFIG_H
@@ -65,40 +65,37 @@
#define ARRAY_SIZE(a) (sizeof((a)) / (sizeof(*(a))))
/* Local function prototypes */
-static void
-LXStopVideo(ScrnInfoPtr pScrni, pointer data, Bool exit);
+static void LXStopVideo(ScrnInfoPtr pScrni, pointer data, Bool exit);
static void
LXDisplayVideo(ScrnInfoPtr pScrni, int id, short width, short height,
- BoxPtr dstBox, short srcW, short srcH, short drawW, short drawH);
-
-static void
-LXResetVideo(ScrnInfoPtr pScrni);
+ BoxPtr dstBox, short srcW, short srcH, short drawW, short drawH);
+static void LXResetVideo(ScrnInfoPtr pScrni);
static XF86VideoEncodingRec DummyEncoding[1] = {
- { 0, "XV_IMAGE", 1024, 1024, {1, 1} }
+ {0, "XV_IMAGE", 1024, 1024, {1, 1}}
};
static XF86VideoFormatRec Formats[] = {
- {8, PseudoColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+ {8, PseudoColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
};
static XF86AttributeRec Attributes[] = {
- {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
- {XvSettable | XvGettable, 0, 1, "XV_FILTER"},
- {XvSettable | XvGettable, 0, 1, "XV_COLORKEYMODE"}
+ {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
+ {XvSettable | XvGettable, 0, 1, "XV_FILTER"},
+ {XvSettable | XvGettable, 0, 1, "XV_COLORKEYMODE"}
};
static XF86ImageRec Images[] = {
- XVIMAGE_UYVY,
- XVIMAGE_YUY2,
- XVIMAGE_Y2YU,
- XVIMAGE_YVYU,
- XVIMAGE_Y800,
- XVIMAGE_I420,
- XVIMAGE_YV12,
- XVIMAGE_RGB565
+ XVIMAGE_UYVY,
+ XVIMAGE_YUY2,
+ XVIMAGE_Y2YU,
+ XVIMAGE_YVYU,
+ XVIMAGE_Y800,
+ XVIMAGE_I420,
+ XVIMAGE_YV12,
+ XVIMAGE_RGB565
};
typedef struct
@@ -119,93 +116,92 @@ typedef struct
(GeodePortPrivRec *)((GEODEPTR(pScrni))->adaptor->pPortPrivates[0].ptr)
static void
-LXCopyFromSys(GeodeRec *pGeode, unsigned char *src, unsigned int dst,
- int dstPitch, int srcPitch, int h, int w)
+LXCopyFromSys(GeodeRec * pGeode, unsigned char *src, unsigned int dst,
+ int dstPitch, int srcPitch, int h, int w)
{
- gp_declare_blt(0);
- gp_set_bpp(16);
+ gp_declare_blt(0);
+ gp_set_bpp(16);
+
+ gp_set_raster_operation(0xCC);
+ gp_set_strides(dstPitch, srcPitch);
+ gp_set_solid_pattern(0);
- gp_set_raster_operation(0xCC);
- gp_set_strides(dstPitch, srcPitch);
- gp_set_solid_pattern(0);
-
- gp_color_bitmap_to_screen_blt(dst, 0, w, h, src, srcPitch);
+ gp_color_bitmap_to_screen_blt(dst, 0, w, h, src, srcPitch);
}
static void
-LXVideoSave(ScreenPtr pScreen, ExaOffscreenArea *area)
+LXVideoSave(ScreenPtr pScreen, ExaOffscreenArea * area)
{
- ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
-
- GeodePortPrivRec *pPriv = GET_PORT_PRIVATE(pScrni);
-
- if (area == pPriv->area)
- pPriv->area = NULL;
-
- LXStopVideo(pScrni, (void *) pPriv, TRUE);
-}
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodePortPrivRec *pPriv = GET_PORT_PRIVATE(pScrni);
+
+ if (area == pPriv->area)
+ pPriv->area = NULL;
+
+ LXStopVideo(pScrni, (void *)pPriv, TRUE);
+}
static unsigned int
LXAllocateVidMem(ScrnInfoPtr pScrni, void **memp, int size)
{
- ExaOffscreenArea *area = *memp;
-
- if (area != NULL) {
- if (area->size >= size)
- return area->offset;
-
- exaOffscreenFree(pScrni->pScreen, area);
- }
-
- area = exaOffscreenAlloc(pScrni->pScreen, size, 16, TRUE,
- LXVideoSave, NULL);
-
- *memp = area;
- return (area == NULL) ? 0 : area->offset;
+ ExaOffscreenArea *area = *memp;
+
+ if (area != NULL) {
+ if (area->size >= size)
+ return area->offset;
+
+ exaOffscreenFree(pScrni->pScreen, area);
+ }
+
+ area = exaOffscreenAlloc(pScrni->pScreen, size, 16, TRUE,
+ LXVideoSave, NULL);
+
+ *memp = area;
+ return (area == NULL) ? 0 : area->offset;
}
static void
LXSetColorkey(ScrnInfoPtr pScrni, GeodePortPrivRec * pPriv)
{
- int red, green, blue;
- unsigned long key;
-
- switch (pScrni->depth) {
- case 8:
- vg_get_display_palette_entry(pPriv->colorKey & 0xFF, &key);
- red = ((key >> 16) & 0xFF);
- green = ((key >> 8) & 0xFF);
- blue = (key & 0xFF);
- break;
- case 16:
- red = (pPriv->colorKey & pScrni->mask.red) >>
- pScrni->offset.red << (8 - pScrni->weight.red);
- green = (pPriv->colorKey & pScrni->mask.green) >>
- pScrni->offset.green << (8 - pScrni->weight.green);
- blue = (pPriv->colorKey & pScrni->mask.blue) >>
- pScrni->offset.blue << (8 - pScrni->weight.blue);
- break;
- default:
- /* for > 16 bpp we send in the mask in xf86SetWeight. This
- * function is providing the offset by 1 more. So we take
- * this as a special case and subtract 1 for > 16
- */
-
- red = (pPriv->colorKey & pScrni->mask.red) >>
- (pScrni->offset.red - 1) << (8 - pScrni->weight.red);
- green = (pPriv->colorKey & pScrni->mask.green) >>
- (pScrni->offset.green - 1) << (8 - pScrni->weight.green);
- blue = (pPriv->colorKey & pScrni->mask.blue) >>
- (pScrni->offset.blue - 1) << (8 - pScrni->weight.blue);
- break;
- }
-
- df_set_video_color_key((blue | (green << 8) | (red << 16)),
+ int red, green, blue;
+ unsigned long key;
+
+ switch (pScrni->depth) {
+ case 8:
+ vg_get_display_palette_entry(pPriv->colorKey & 0xFF, &key);
+ red = ((key >> 16) & 0xFF);
+ green = ((key >> 8) & 0xFF);
+ blue = (key & 0xFF);
+ break;
+ case 16:
+ red = (pPriv->colorKey & pScrni->mask.red) >>
+ pScrni->offset.red << (8 - pScrni->weight.red);
+ green = (pPriv->colorKey & pScrni->mask.green) >>
+ pScrni->offset.green << (8 - pScrni->weight.green);
+ blue = (pPriv->colorKey & pScrni->mask.blue) >>
+ pScrni->offset.blue << (8 - pScrni->weight.blue);
+ break;
+ default:
+ /* for > 16 bpp we send in the mask in xf86SetWeight. This
+ * function is providing the offset by 1 more. So we take
+ * this as a special case and subtract 1 for > 16
+ */
+
+ red = (pPriv->colorKey & pScrni->mask.red) >>
+ (pScrni->offset.red - 1) << (8 - pScrni->weight.red);
+ green = (pPriv->colorKey & pScrni->mask.green) >>
+ (pScrni->offset.green - 1) << (8 - pScrni->weight.green);
+ blue = (pPriv->colorKey & pScrni->mask.blue) >>
+ (pScrni->offset.blue - 1) << (8 - pScrni->weight.blue);
+ break;
+ }
+
+ df_set_video_color_key((blue | (green << 8) | (red << 16)),
0xFFFFFF, (pPriv->colorKeyMode == 0));
- REGION_EMPTY(pScrni->pScreen, &pPriv->clip);
+ REGION_EMPTY(pScrni->pScreen, &pPriv->clip);
}
/* A structure full of the scratch information that originates in the copy routines,
@@ -214,445 +210,431 @@ LXSetColorkey(ScrnInfoPtr pScrni, GeodePortPrivRec * pPriv)
the structure, and possibly cause us cache issues.
*/
-struct {
- unsigned int dstOffset;
- unsigned int dstPitch;
- unsigned int UVPitch;
- unsigned int UDstOffset;
- unsigned int VDstOffset;
+struct
+{
+ unsigned int dstOffset;
+ unsigned int dstPitch;
+ unsigned int UVPitch;
+ unsigned int UDstOffset;
+ unsigned int VDstOffset;
} videoScratch;
/* Copy planar YUV data */
static Bool
LXCopyPlanar(ScrnInfoPtr pScrni, int id, unsigned char *buf,
- short x1, short y1, short x2, short y2,
- int width, int height, pointer data)
+ short x1, short y1, short x2, short y2,
+ int width, int height, pointer data)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
-
- unsigned int YSrcPitch, YDstPitch;
- unsigned int UVSrcPitch, UVDstPitch;
- unsigned int YSrcOffset, YDstOffset;
- unsigned int USrcOffset, UDstOffset;
- unsigned int VSrcOffset, VDstOffset;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
- unsigned int size, lines, top, left, pixels;
+ unsigned int YSrcPitch, YDstPitch;
+ unsigned int UVSrcPitch, UVDstPitch;
+ unsigned int YSrcOffset, YDstOffset;
+ unsigned int USrcOffset, UDstOffset;
+ unsigned int VSrcOffset, VDstOffset;
- YSrcPitch = (width + 3) & ~3;
- YDstPitch = (width + 31) & ~31;
-
- UVSrcPitch = ((width >> 1) + 3) & ~3;
- UVDstPitch = ((width >> 1) + 15) & ~15;
+ unsigned int size, lines, top, left, pixels;
- USrcOffset = YSrcPitch * height;
- VSrcOffset = USrcOffset + (UVSrcPitch * (height >> 1));
+ YSrcPitch = (width + 3) & ~3;
+ YDstPitch = (width + 31) & ~31;
- UDstOffset = YDstPitch * height;
- VDstOffset = UDstOffset + (UVDstPitch * (height >> 1));
+ UVSrcPitch = ((width >> 1) + 3) & ~3;
+ UVDstPitch = ((width >> 1) + 15) & ~15;
-#if 0
- else {
USrcOffset = YSrcPitch * height;
VSrcOffset = USrcOffset + (UVSrcPitch * (height >> 1));
UDstOffset = YDstPitch * height;
VDstOffset = UDstOffset + (UVDstPitch * (height >> 1));
- }
-#endif
- size = YDstPitch * height;
- size += UVDstPitch * height;
+ size = YDstPitch * height;
+ size += UVDstPitch * height;
- pPriv->offset = LXAllocateVidMem(pScrni, &pPriv->area, size);
-
- if (pPriv->offset == 0) {
- ErrorF("Error allocating an offscreen region.\n");
- return FALSE;
- }
-
- /* The top of the source region we want to copy */
- top = y1 & ~1;
+ pPriv->offset = LXAllocateVidMem(pScrni, &pPriv->area, size);
- /* The left hand side of the source region, aligned on a word */
- left = x1 & ~1;
+ if (pPriv->offset == 0) {
+ ErrorF("Error allocating an offscreen region.\n");
+ return FALSE;
+ }
+
+ /* The top of the source region we want to copy */
+ top = y1 & ~1;
+
+ /* The left hand side of the source region, aligned on a word */
+ left = x1 & ~1;
- /* Number of bytes to copy, also word aligned */
- pixels = ((x2 + 1) & ~1) - left;
+ /* Number of bytes to copy, also word aligned */
+ pixels = ((x2 + 1) & ~1) - left;
- /* Calculate the source offset */
- YSrcOffset = (top * YSrcPitch) + left;
- USrcOffset += ((top >> 1) * UVSrcPitch) + (left >> 1);
- VSrcOffset += ((top >> 1) * UVSrcPitch) + (left >> 1);
+ /* Calculate the source offset */
+ YSrcOffset = (top * YSrcPitch) + left;
+ USrcOffset += ((top >> 1) * UVSrcPitch) + (left >> 1);
+ VSrcOffset += ((top >> 1) * UVSrcPitch) + (left >> 1);
- /* Calculate the destination offset */
- YDstOffset = (top * YDstPitch) + left;
- UDstOffset += ((top >> 1) * UVDstPitch) + (left >> 1);
- VDstOffset += ((top >> 1) * UVDstPitch) + (left >> 1);
+ /* Calculate the destination offset */
+ YDstOffset = (top * YDstPitch) + left;
+ UDstOffset += ((top >> 1) * UVDstPitch) + (left >> 1);
+ VDstOffset += ((top >> 1) * UVDstPitch) + (left >> 1);
- lines = ((y2 + 1) & ~1) - top;
+ lines = ((y2 + 1) & ~1) - top;
- /* Copy Y */
+ /* Copy Y */
- LXCopyFromSys(pGeode, buf + YSrcOffset, pPriv->offset + YDstOffset,
- YDstPitch, YSrcPitch, lines, pixels);
+ LXCopyFromSys(pGeode, buf + YSrcOffset, pPriv->offset + YDstOffset,
+ YDstPitch, YSrcPitch, lines, pixels);
- /* Copy U + V at the same time */
+ /* Copy U + V at the same time */
- LXCopyFromSys(pGeode, buf + USrcOffset, pPriv->offset + UDstOffset,
- UVDstPitch, UVSrcPitch, lines, pixels >> 1);
-
- videoScratch.dstOffset = pPriv->offset + YDstOffset;
- videoScratch.dstPitch = YDstPitch;
- videoScratch.UVPitch = UVDstPitch;
- videoScratch.UDstOffset = pPriv->offset + UDstOffset;
- videoScratch.VDstOffset = pPriv->offset + VDstOffset;
+ LXCopyFromSys(pGeode, buf + USrcOffset, pPriv->offset + UDstOffset,
+ UVDstPitch, UVSrcPitch, lines, pixels >> 1);
- return TRUE;
+ videoScratch.dstOffset = pPriv->offset + YDstOffset;
+ videoScratch.dstPitch = YDstPitch;
+ videoScratch.UVPitch = UVDstPitch;
+ videoScratch.UDstOffset = pPriv->offset + UDstOffset;
+ videoScratch.VDstOffset = pPriv->offset + VDstOffset;
+
+ return TRUE;
}
-static Bool
+static Bool
LXCopyPacked(ScrnInfoPtr pScrni, int id, unsigned char *buf,
- short x1, short y1, short x2, short y2,
- int width, int height, pointer data)
+ short x1, short y1, short x2, short y2,
+ int width, int height, pointer data)
{
- GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
- GeodeRec *pGeode = GEODEPTR(pScrni);
- unsigned int dstPitch, srcPitch;
- unsigned int srcOffset, dstOffset;
- unsigned int lines, top, left, pixels;
-
- dstPitch = ((width << 1) + 3) & ~3;
- srcPitch = (width << 1);
-
- lines = ((dstPitch * height) + pGeode->Pitch - 1) / pGeode->Pitch;
-
- pPriv->offset = LXAllocateVidMem(pScrni, &pPriv->area, height * dstPitch);
-
- if (pPriv->offset == 0) {
- ErrorF("Error while allocating an offscreen region.\n");
- return FALSE;
- }
-
- /* The top of the source region we want to copy */
- top = y1;
-
- /* The left hand side of the source region, aligned on a word */
- left = x1 & ~1;
-
- /* Number of bytes to copy, also word aligned */
- pixels = ((x2 + 1) & ~1) - left;
-
- /* Adjust the incoming buffer */
- srcOffset = (top * srcPitch) + left;
-
- /* Calculate the destination offset */
- dstOffset = pPriv->offset + (top * dstPitch) + left;
-
- /* Make the copy happen */
-
- if (id == FOURCC_Y800) {
-
- /* Use the shared (unaccelerated) greyscale copy - you could probably
- accelerate it using a 2 pass blit and patterns, but it doesn't really
- seem worth it
- */
-
- GeodeCopyGreyscale(buf + srcOffset, pGeode->FBBase + dstOffset, srcPitch, dstPitch,
- height, pixels >> 1);
- }
- else
- LXCopyFromSys(pGeode, buf + srcOffset, dstOffset, dstPitch, srcPitch, height, pixels);
-
- videoScratch.dstOffset = dstOffset;
- videoScratch.dstPitch = dstPitch;
-
- return TRUE;
+ GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ unsigned int dstPitch, srcPitch;
+ unsigned int srcOffset, dstOffset;
+ unsigned int lines, top, left, pixels;
+
+ dstPitch = ((width << 1) + 3) & ~3;
+ srcPitch = (width << 1);
+
+ lines = ((dstPitch * height) + pGeode->Pitch - 1) / pGeode->Pitch;
+
+ pPriv->offset = LXAllocateVidMem(pScrni, &pPriv->area, height * dstPitch);
+
+ if (pPriv->offset == 0) {
+ ErrorF("Error while allocating an offscreen region.\n");
+ return FALSE;
+ }
+
+ /* The top of the source region we want to copy */
+ top = y1;
+
+ /* The left hand side of the source region, aligned on a word */
+ left = x1 & ~1;
+
+ /* Number of bytes to copy, also word aligned */
+ pixels = ((x2 + 1) & ~1) - left;
+
+ /* Adjust the incoming buffer */
+ srcOffset = (top * srcPitch) + left;
+
+ /* Calculate the destination offset */
+ dstOffset = pPriv->offset + (top * dstPitch) + left;
+
+ /* Make the copy happen */
+
+ if (id == FOURCC_Y800) {
+
+ /* Use the shared (unaccelerated) greyscale copy - you could probably
+ * accelerate it using a 2 pass blit and patterns, but it doesn't really
+ * seem worth it
+ */
+
+ GeodeCopyGreyscale(buf + srcOffset, pGeode->FBBase + dstOffset,
+ srcPitch, dstPitch, height, pixels >> 1);
+ } else
+ LXCopyFromSys(pGeode, buf + srcOffset, dstOffset, dstPitch, srcPitch,
+ height, pixels);
+
+ videoScratch.dstOffset = dstOffset;
+ videoScratch.dstPitch = dstPitch;
+
+ return TRUE;
}
static void
LXDisplayVideo(ScrnInfoPtr pScrni, int id, short width, short height,
- BoxPtr dstBox, short srcW, short srcH, short drawW, short drawH)
+ BoxPtr dstBox, short srcW, short srcH, short drawW, short drawH)
{
- long ystart, xend, yend;
- unsigned long lines = 0;
- unsigned long yExtra, uvExtra = 0;
- DF_VIDEO_POSITION vidPos;
- DF_VIDEO_SOURCE_PARAMS vSrcParams;
- int err;
-
- memset(&vSrcParams, 0, sizeof(vSrcParams));
-
- gp_wait_until_idle();
-
- switch(id) {
- case FOURCC_UYVY:
- vSrcParams.video_format = DF_VIDFMT_UYVY;
- break;
-
- case FOURCC_Y800:
- case FOURCC_YV12:
- case FOURCC_I420:
- vSrcParams.video_format = DF_VIDFMT_Y0Y1Y2Y3;
- break;
- case FOURCC_YUY2:
- vSrcParams.video_format = DF_VIDFMT_YUYV;
- break;
- case FOURCC_Y2YU:
- vSrcParams.video_format = DF_VIDFMT_Y2YU;
- break;
- case FOURCC_YVYU:
- vSrcParams.video_format = DF_VIDFMT_YVYU;
- break;
- case FOURCC_RGB565:
- vSrcParams.video_format = DF_VIDFMT_RGB;
- break;
- }
-
- vSrcParams.width = width;
- vSrcParams.height = height;
- vSrcParams.y_pitch = videoScratch.dstPitch;
- vSrcParams.uv_pitch = videoScratch.UVPitch;
-
- /* Set up scaling */
- df_set_video_filter_coefficients(NULL, 1);
-
- err = df_set_video_scale(width, height, drawW, drawH,
- DF_SCALEFLAG_CHANGEX | DF_SCALEFLAG_CHANGEY);
- if (err != CIM_STATUS_OK) {
- /* Note the problem, but do nothing for now. */
- ErrorF("Video scale factor too large: %dx%d -> %dx%d\n",
- width, height, drawW, drawH);
- }
-
- /* Figure out clipping */
-
- xend = dstBox->x2;
- yend = dstBox->y2;
-
- if (dstBox->y1 < 0) {
- if (srcH < drawH)
- lines = ((-dstBox->y1) * srcH) / drawH;
- else
- lines = (-dstBox->y1);
-
- ystart = 0;
- drawH += dstBox->y1;
- }
- else {
- ystart = dstBox->y1;
- lines = 0;
- }
-
- yExtra = lines * videoScratch.dstPitch;
- uvExtra = (lines >> 1) * videoScratch.UVPitch;
-
- memset(&vidPos, 0, sizeof(vidPos));
-
- vidPos.x = dstBox->x1;
- vidPos.y = ystart;
- vidPos.width = xend - dstBox->x1;
- vidPos.height = yend - ystart;
-
- df_set_video_position(&vidPos);
-
- vSrcParams.y_offset = videoScratch.dstOffset + yExtra;
-
- switch(id) {
- case FOURCC_Y800:
- case FOURCC_I420:
- vSrcParams.u_offset = videoScratch.UDstOffset + uvExtra;
- vSrcParams.v_offset = videoScratch.VDstOffset + uvExtra;
- break;
- case FOURCC_YV12:
- vSrcParams.v_offset = videoScratch.UDstOffset + uvExtra;
- vSrcParams.u_offset = videoScratch.VDstOffset + uvExtra;
- break;
-
- default:
- vSrcParams.u_offset = vSrcParams.v_offset = 0;
- break;
- }
-
- vSrcParams.flags = DF_SOURCEFLAG_IMPLICITSCALING;
- df_configure_video_source(&vSrcParams, &vSrcParams);
-
- /* Turn on the video palette */
- df_set_video_palette(NULL);
- df_set_video_enable(1, 0);
+ long ystart, xend, yend;
+ unsigned long lines = 0;
+ unsigned long yExtra, uvExtra = 0;
+ DF_VIDEO_POSITION vidPos;
+ DF_VIDEO_SOURCE_PARAMS vSrcParams;
+ int err;
+
+ memset(&vSrcParams, 0, sizeof(vSrcParams));
+
+ gp_wait_until_idle();
+
+ switch (id) {
+ case FOURCC_UYVY:
+ vSrcParams.video_format = DF_VIDFMT_UYVY;
+ break;
+
+ case FOURCC_Y800:
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ vSrcParams.video_format = DF_VIDFMT_Y0Y1Y2Y3;
+ break;
+ case FOURCC_YUY2:
+ vSrcParams.video_format = DF_VIDFMT_YUYV;
+ break;
+ case FOURCC_Y2YU:
+ vSrcParams.video_format = DF_VIDFMT_Y2YU;
+ break;
+ case FOURCC_YVYU:
+ vSrcParams.video_format = DF_VIDFMT_YVYU;
+ break;
+ case FOURCC_RGB565:
+ vSrcParams.video_format = DF_VIDFMT_RGB;
+ break;
+ }
+
+ vSrcParams.width = width;
+ vSrcParams.height = height;
+ vSrcParams.y_pitch = videoScratch.dstPitch;
+ vSrcParams.uv_pitch = videoScratch.UVPitch;
+
+ /* Set up scaling */
+ df_set_video_filter_coefficients(NULL, 1);
+
+ err = df_set_video_scale(width, height, drawW, drawH,
+ DF_SCALEFLAG_CHANGEX | DF_SCALEFLAG_CHANGEY);
+ if (err != CIM_STATUS_OK) {
+ /* Note the problem, but do nothing for now. */
+ ErrorF("Video scale factor too large: %dx%d -> %dx%d\n",
+ width, height, drawW, drawH);
+ }
+
+ /* Figure out clipping */
+
+ xend = dstBox->x2;
+ yend = dstBox->y2;
+
+ if (dstBox->y1 < 0) {
+ if (srcH < drawH)
+ lines = ((-dstBox->y1) * srcH) / drawH;
+ else
+ lines = (-dstBox->y1);
+
+ ystart = 0;
+ drawH += dstBox->y1;
+ } else {
+ ystart = dstBox->y1;
+ lines = 0;
+ }
+
+ yExtra = lines * videoScratch.dstPitch;
+ uvExtra = (lines >> 1) * videoScratch.UVPitch;
+
+ memset(&vidPos, 0, sizeof(vidPos));
+
+ vidPos.x = dstBox->x1;
+ vidPos.y = ystart;
+ vidPos.width = xend - dstBox->x1;
+ vidPos.height = yend - ystart;
+
+ df_set_video_position(&vidPos);
+
+ vSrcParams.y_offset = videoScratch.dstOffset + yExtra;
+
+ switch (id) {
+ case FOURCC_Y800:
+ case FOURCC_I420:
+ vSrcParams.u_offset = videoScratch.UDstOffset + uvExtra;
+ vSrcParams.v_offset = videoScratch.VDstOffset + uvExtra;
+ break;
+ case FOURCC_YV12:
+ vSrcParams.v_offset = videoScratch.UDstOffset + uvExtra;
+ vSrcParams.u_offset = videoScratch.VDstOffset + uvExtra;
+ break;
+
+ default:
+ vSrcParams.u_offset = vSrcParams.v_offset = 0;
+ break;
+ }
+
+ vSrcParams.flags = DF_SOURCEFLAG_IMPLICITSCALING;
+ df_configure_video_source(&vSrcParams, &vSrcParams);
+
+ /* Turn on the video palette */
+ df_set_video_palette(NULL);
+ df_set_video_enable(1, 0);
}
static int
LXPutImage(ScrnInfoPtr pScrni,
- short srcX, short srcY, short drawX, short drawY,
- short srcW, short srcH, short drawW, short drawH,
- int id, unsigned char *buf,
- short width, short height, Bool sync, RegionPtr clipBoxes,
- pointer data, DrawablePtr pDraw)
+ short srcX, short srcY, short drawX, short drawY,
+ short srcW, short srcH, short drawW, short drawH,
+ int id, unsigned char *buf,
+ short width, short height, Bool sync, RegionPtr clipBoxes,
+ pointer data, DrawablePtr pDraw)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
- INT32 x1,x2,y1,y2;
- BoxRec dstBox;
-
- if (pGeode->rotation != RR_Rotate_0)
- return Success;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
+ INT32 x1, x2, y1, y2;
+ BoxRec dstBox;
- if (srcW <= 0 || srcH <= 0) {
- return Success;
- }
+ if (pGeode->rotation != RR_Rotate_0)
+ return Success;
- if (drawW <= 0 || drawH <=0) {
- return Success;
- }
-
- if (drawW > 16384)
- drawW = 16384;
-
- memset(&videoScratch, 0, sizeof(videoScratch));
-
- x1 = srcX;
- x2 = srcX + srcW;
- y1 = srcY;
- y2 = srcY + srcH;
-
- dstBox.x1 = drawX;
- dstBox.x2 = drawX + drawW;
- dstBox.y1 = drawY;
- dstBox.y2 = drawY + drawH;
-
- dstBox.x1 -= pScrni->frameX0;
- dstBox.x2 -= pScrni->frameX0;
- dstBox.y1 -= pScrni->frameY0;
- dstBox.y2 -= pScrni->frameY0;
-
- switch(id) {
- case FOURCC_YV12:
- case FOURCC_I420:
- LXCopyPlanar(pScrni, id, buf, x1, y1, x2, y2, width, height, data);
- break;
-
- case FOURCC_UYVY:
- case FOURCC_YUY2:
- case FOURCC_Y800:
- case FOURCC_RGB565:
- LXCopyPacked(pScrni, id, buf, x1, y1, x2, y2, width, height, data);
- break;
- }
-
- if (!RegionsEqual(&pPriv->clip, clipBoxes) ||
- (drawW != pPriv->pwidth || drawH != pPriv->pheight)) {
- REGION_COPY(pScrni->pScreen, &pPriv->clip, clipBoxes);
-
- if (pPriv->colorKeyMode == 0) {
- xf86XVFillKeyHelper(pScrni->pScreen, pPriv->colorKey, clipBoxes);
+ if (srcW <= 0 || srcH <= 0) {
+ return Success;
}
-
- LXDisplayVideo(pScrni, id, width, height, &dstBox,
- srcW, srcH, drawW, drawH);
- pPriv->pwidth = drawW;
- pPriv->pheight = drawH;
- }
-
- pPriv->videoStatus = CLIENT_VIDEO_ON;
- pGeode->OverlayON = TRUE;
-
- return Success;
+
+ if (drawW <= 0 || drawH <= 0) {
+ return Success;
+ }
+
+ if (drawW > 16384)
+ drawW = 16384;
+
+ memset(&videoScratch, 0, sizeof(videoScratch));
+
+ x1 = srcX;
+ x2 = srcX + srcW;
+ y1 = srcY;
+ y2 = srcY + srcH;
+
+ dstBox.x1 = drawX;
+ dstBox.x2 = drawX + drawW;
+ dstBox.y1 = drawY;
+ dstBox.y2 = drawY + drawH;
+
+ dstBox.x1 -= pScrni->frameX0;
+ dstBox.x2 -= pScrni->frameX0;
+ dstBox.y1 -= pScrni->frameY0;
+ dstBox.y2 -= pScrni->frameY0;
+
+ switch (id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ LXCopyPlanar(pScrni, id, buf, x1, y1, x2, y2, width, height, data);
+ break;
+
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ case FOURCC_Y800:
+ case FOURCC_RGB565:
+ LXCopyPacked(pScrni, id, buf, x1, y1, x2, y2, width, height, data);
+ break;
+ }
+
+ if (!RegionsEqual(&pPriv->clip, clipBoxes) ||
+ (drawW != pPriv->pwidth || drawH != pPriv->pheight)) {
+ REGION_COPY(pScrni->pScreen, &pPriv->clip, clipBoxes);
+
+ if (pPriv->colorKeyMode == 0) {
+ xf86XVFillKeyHelper(pScrni->pScreen, pPriv->colorKey, clipBoxes);
+ }
+
+ LXDisplayVideo(pScrni, id, width, height, &dstBox,
+ srcW, srcH, drawW, drawH);
+ pPriv->pwidth = drawW;
+ pPriv->pheight = drawH;
+ }
+
+ pPriv->videoStatus = CLIENT_VIDEO_ON;
+ pGeode->OverlayON = TRUE;
+
+ return Success;
}
static void
LXQueryBestSize(ScrnInfoPtr pScrni, Bool motion,
- short vidW, short vidH, short drawW, short drawH,
- unsigned int *retW, unsigned int *retH, pointer data)
+ short vidW, short vidH, short drawW, short drawH,
+ unsigned int *retW, unsigned int *retH, pointer data)
{
- *retW = drawW > 16384 ? 16384 : drawW;
- *retH = drawH;
+ *retW = drawW > 16384 ? 16384 : drawW;
+ *retH = drawH;
}
-
+
static Atom xvColorKey, xvColorKeyMode, xvFilter;
-
+
static int
LXGetPortAttribute(ScrnInfoPtr pScrni,
- Atom attribute, INT32 * value, pointer data)
+ Atom attribute, INT32 * value, pointer data)
{
- GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
-
- if (attribute == xvColorKey)
- *value = pPriv->colorKey;
- else if (attribute == xvColorKeyMode)
- *value = pPriv->colorKeyMode;
- else if (attribute == xvFilter)
- *value = pPriv->filter;
- else
- return BadMatch;
-
- return Success;
+ GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
+
+ if (attribute == xvColorKey)
+ *value = pPriv->colorKey;
+ else if (attribute == xvColorKeyMode)
+ *value = pPriv->colorKeyMode;
+ else if (attribute == xvFilter)
+ *value = pPriv->filter;
+ else
+ return BadMatch;
+
+ return Success;
}
static int
LXSetPortAttribute(ScrnInfoPtr pScrni,
- Atom attribute, INT32 value, pointer data)
+ Atom attribute, INT32 value, pointer data)
{
- GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
-
- gp_wait_until_idle();
-
- if (attribute == xvColorKey) {
- pPriv->colorKey = value;
- LXSetColorkey(pScrni, pPriv);
- }
- else if (attribute == xvColorKeyMode) {
- pPriv->colorKeyMode = value;
- LXSetColorkey(pScrni, pPriv);
- }
- else if (attribute == xvFilter) {
- if ((value < 0) || (value > 1))
- return BadValue;
- pPriv->filter = value;
- }
- else
- return BadMatch;
-
- return Success;
+ GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
+
+ gp_wait_until_idle();
+
+ if (attribute == xvColorKey) {
+ pPriv->colorKey = value;
+ LXSetColorkey(pScrni, pPriv);
+ } else if (attribute == xvColorKeyMode) {
+ pPriv->colorKeyMode = value;
+ LXSetColorkey(pScrni, pPriv);
+ } else if (attribute == xvFilter) {
+ if ((value < 0) || (value > 1))
+ return BadValue;
+ pPriv->filter = value;
+ } else
+ return BadMatch;
+
+ return Success;
}
static void
LXStopVideo(ScrnInfoPtr pScrni, pointer data, Bool exit)
{
- GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodePortPrivRec *pPriv = (GeodePortPrivRec *) data;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (pPriv->videoStatus == 0)
- return;
+ if (pPriv->videoStatus == 0)
+ return;
- REGION_EMPTY(pScrni->pScreen, &pPriv->clip);
- gp_wait_until_idle();
+ REGION_EMPTY(pScrni->pScreen, &pPriv->clip);
+ gp_wait_until_idle();
- if (exit) {
- if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
- unsigned int val;
+ if (exit) {
+ if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
+ unsigned int val;
- df_set_video_enable(0,0);
- /* Put the LUT back in bypass */
- val = READ_VID32(DF_VID_MISC);
- WRITE_VID32(DF_VID_MISC, val | DF_GAMMA_BYPASS_BOTH);
- }
-
- if (pPriv->area) {
- exaOffscreenFree(pScrni->pScreen, pPriv->area);
- pPriv->area = NULL;
- }
-
- pPriv->videoStatus = 0;
+ df_set_video_enable(0, 0);
+ /* Put the LUT back in bypass */
+ val = READ_VID32(DF_VID_MISC);
+ WRITE_VID32(DF_VID_MISC, val | DF_GAMMA_BYPASS_BOTH);
+ }
- /* Eh? */
- pGeode->OverlayON = FALSE;
- }
- else if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
- pPriv->videoStatus |= OFF_TIMER;
- pPriv->offTime = currentTime.milliseconds + OFF_DELAY;
- }
+ if (pPriv->area) {
+ exaOffscreenFree(pScrni->pScreen, pPriv->area);
+ pPriv->area = NULL;
+ }
+
+ pPriv->videoStatus = 0;
+
+ /* Eh? */
+ pGeode->OverlayON = FALSE;
+ } else if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
+ pPriv->videoStatus |= OFF_TIMER;
+ pPriv->offTime = currentTime.milliseconds + OFF_DELAY;
+ }
}
static void
@@ -661,17 +643,18 @@ LXResetVideo(ScrnInfoPtr pScrni)
GeodeRec *pGeode = GEODEPTR(pScrni);
if (!pGeode->NoAccel) {
- GeodePortPrivRec *pPriv = pGeode->adaptor->pPortPrivates[0].ptr;
+ GeodePortPrivRec *pPriv = pGeode->adaptor->pPortPrivates[0].ptr;
gp_wait_until_idle();
df_set_video_palette(NULL);
- LXSetColorkey(pScrni, pPriv);
+ LXSetColorkey(pScrni, pPriv);
}
}
static void
-LXVidBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask)
+LXVidBlockHandler(int i, pointer blockData, pointer pTimeout,
+ pointer pReadmask)
{
ScreenPtr pScrn = screenInfo.screens[i];
ScrnInfoPtr pScrni = xf86Screens[i];
@@ -683,343 +666,339 @@ LXVidBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask)
pScrn->BlockHandler = LXVidBlockHandler;
if (pPriv->videoStatus & TIMER_MASK) {
- Time now = currentTime.milliseconds;
-
- if (pPriv->videoStatus & OFF_TIMER) {
- gp_wait_until_idle();
-
- if (pPriv->offTime < now) {
- unsigned int val;
-
- df_set_video_enable(0, 0);
- pPriv->videoStatus = FREE_TIMER;
- pPriv->freeTime = now + FREE_DELAY;
-
- /* Turn off the video palette */
- val = READ_VID32(DF_VID_MISC);
- WRITE_VID32(DF_VID_MISC, val | DF_GAMMA_BYPASS_BOTH);
- }
- }
- else {
- if (pPriv->freeTime < now) {
- if (pPriv->area) {
- exaOffscreenFree(pScrni->pScreen, pPriv->area);
- pPriv->area = NULL;
- }
-
- pPriv->videoStatus = 0;
+ Time now = currentTime.milliseconds;
+
+ if (pPriv->videoStatus & OFF_TIMER) {
+ gp_wait_until_idle();
+
+ if (pPriv->offTime < now) {
+ unsigned int val;
+
+ df_set_video_enable(0, 0);
+ pPriv->videoStatus = FREE_TIMER;
+ pPriv->freeTime = now + FREE_DELAY;
+
+ /* Turn off the video palette */
+ val = READ_VID32(DF_VID_MISC);
+ WRITE_VID32(DF_VID_MISC, val | DF_GAMMA_BYPASS_BOTH);
+ }
+ } else {
+ if (pPriv->freeTime < now) {
+ if (pPriv->area) {
+ exaOffscreenFree(pScrni->pScreen, pPriv->area);
+ pPriv->area = NULL;
+ }
+
+ pPriv->videoStatus = 0;
+ }
}
- }
}
}
static XF86VideoAdaptorPtr
LXSetupImageVideo(ScreenPtr pScrn)
{
- ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- XF86VideoAdaptorPtr adapt;
- GeodePortPrivRec *pPriv;
-
- adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
- sizeof(GeodePortPrivRec) + sizeof(DevUnion));
-
- if (adapt == NULL) {
- ErrorF("Couldn't create the rec\n");
- return NULL;
- }
-
- adapt->type = XvWindowMask | XvInputMask | XvImageMask;
- adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
-
- adapt->name = "AMD Geode LX";
- adapt->nEncodings = 1;
- adapt->pEncodings = DummyEncoding;
- adapt->nFormats = ARRAY_SIZE(Formats);
- adapt->pFormats = Formats;
- adapt->nPorts = 1;
- adapt->pPortPrivates = (DevUnion *) (&adapt[1]);
- pPriv = (GeodePortPrivRec *) (&adapt->pPortPrivates[1]);
- adapt->pPortPrivates[0].ptr = (pointer) (pPriv);
- adapt->pAttributes = Attributes;
- adapt->nImages = ARRAY_SIZE(Images);
- adapt->nAttributes = ARRAY_SIZE(Attributes);
- adapt->pImages = Images;
- adapt->PutVideo = NULL;
- adapt->PutStill = NULL;
- adapt->GetVideo = NULL;
- adapt->GetStill = NULL;
- adapt->StopVideo= LXStopVideo;
- adapt->SetPortAttribute = LXSetPortAttribute;
- adapt->GetPortAttribute = LXGetPortAttribute;
- adapt->QueryBestSize = LXQueryBestSize;
- adapt->PutImage =LXPutImage;
-
- /* Use the common function */
- adapt->QueryImageAttributes = GeodeQueryImageAttributes;
-
- pPriv->filter = 0;
- pPriv->colorKey = pGeode->videoKey;
- pPriv->colorKeyMode = 0;
- pPriv->videoStatus = 0;
- pPriv->pwidth = 0;
- pPriv->pheight = 0;
-
- REGION_NULL(pScrn, &pPriv->clip);
-
- pGeode->adaptor = adapt;
-
- pGeode->BlockHandler = pScrn->BlockHandler;
- pScrn->BlockHandler = LXVidBlockHandler;
-
- xvColorKey = MAKE_ATOM("XV_COLORKEY");
- xvColorKeyMode = MAKE_ATOM("XV_COLORKEYMODE");
- xvFilter = MAKE_ATOM("XV_FILTER");
-
- LXResetVideo(pScrni);
-
- return adapt;
+ ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ XF86VideoAdaptorPtr adapt;
+ GeodePortPrivRec *pPriv;
+
+ adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
+ sizeof(GeodePortPrivRec) + sizeof(DevUnion));
+
+ if (adapt == NULL) {
+ ErrorF("Couldn't create the rec\n");
+ return NULL;
+ }
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+
+ adapt->name = "AMD Geode LX";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = DummyEncoding;
+ adapt->nFormats = ARRAY_SIZE(Formats);
+ adapt->pFormats = Formats;
+ adapt->nPorts = 1;
+ adapt->pPortPrivates = (DevUnion *) (&adapt[1]);
+ pPriv = (GeodePortPrivRec *) (&adapt->pPortPrivates[1]);
+ adapt->pPortPrivates[0].ptr = (pointer) (pPriv);
+ adapt->pAttributes = Attributes;
+ adapt->nImages = ARRAY_SIZE(Images);
+ adapt->nAttributes = ARRAY_SIZE(Attributes);
+ adapt->pImages = Images;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+ adapt->StopVideo = LXStopVideo;
+ adapt->SetPortAttribute = LXSetPortAttribute;
+ adapt->GetPortAttribute = LXGetPortAttribute;
+ adapt->QueryBestSize = LXQueryBestSize;
+ adapt->PutImage = LXPutImage;
+
+ /* Use the common function */
+ adapt->QueryImageAttributes = GeodeQueryImageAttributes;
+
+ pPriv->filter = 0;
+ pPriv->colorKey = pGeode->videoKey;
+ pPriv->colorKeyMode = 0;
+ pPriv->videoStatus = 0;
+ pPriv->pwidth = 0;
+ pPriv->pheight = 0;
+
+ REGION_NULL(pScrn, &pPriv->clip);
+
+ pGeode->adaptor = adapt;
+
+ pGeode->BlockHandler = pScrn->BlockHandler;
+ pScrn->BlockHandler = LXVidBlockHandler;
+
+ xvColorKey = MAKE_ATOM("XV_COLORKEY");
+ xvColorKeyMode = MAKE_ATOM("XV_COLORKEYMODE");
+ xvFilter = MAKE_ATOM("XV_FILTER");
+
+ LXResetVideo(pScrni);
+
+ return adapt;
}
/* Offscreen surface allocation */
struct OffscreenPrivRec
{
- void * area;
- int offset;
- Bool isOn;
+ void *area;
+ int offset;
+ Bool isOn;
};
static int
LXDisplaySurface(XF86SurfacePtr surface,
- short srcX, short srcY, short drawX, short drawY,
- short srcW, short srcH, short drawW, short drawH,
- RegionPtr clipBoxes)
+ short srcX, short srcY, short drawX, short drawY,
+ short srcW, short srcH, short drawW, short drawH, RegionPtr clipBoxes)
{
- struct OffscreenPrivRec *pPriv =
- (struct OffscreenPrivRec *) surface->devPrivate.ptr;
+ struct OffscreenPrivRec *pPriv =
+ (struct OffscreenPrivRec *)surface->devPrivate.ptr;
- ScrnInfoPtr pScrni = surface->pScrn;
- GeodePortPrivRec *portPriv = GET_PORT_PRIVATE(pScrni);
-
- BoxRec dstBox;
+ ScrnInfoPtr pScrni = surface->pScrn;
+ GeodePortPrivRec *portPriv = GET_PORT_PRIVATE(pScrni);
- dstBox.x1 = drawX;
- dstBox.x2 = drawX + drawW;
- dstBox.y1 = drawY;
- dstBox.y2 = drawY + drawH;
+ BoxRec dstBox;
- if ((drawW <= 0) | (drawH <=0))
- return Success;
+ dstBox.x1 = drawX;
+ dstBox.x2 = drawX + drawW;
+ dstBox.y1 = drawY;
+ dstBox.y2 = drawY + drawH;
+
+ if ((drawW <= 0) | (drawH <= 0))
+ return Success;
- /* Is this still valid? */
+ /* Is this still valid? */
- dstBox.x1 -= pScrni->frameX0;
- dstBox.x2 -= pScrni->frameX0;
- dstBox.y1 -= pScrni->frameY0;
- dstBox.y2 -= pScrni->frameY0;
+ dstBox.x1 -= pScrni->frameX0;
+ dstBox.x2 -= pScrni->frameX0;
+ dstBox.y1 -= pScrni->frameY0;
+ dstBox.y2 -= pScrni->frameY0;
- xf86XVFillKeyHelper(pScrni->pScreen, portPriv->colorKey, clipBoxes);
+ xf86XVFillKeyHelper(pScrni->pScreen, portPriv->colorKey, clipBoxes);
- videoScratch.dstOffset = surface->offsets[0];
- videoScratch.dstPitch = surface->pitches[0];
+ videoScratch.dstOffset = surface->offsets[0];
+ videoScratch.dstPitch = surface->pitches[0];
- LXDisplayVideo(pScrni, surface->id, surface->width, surface->height,
- &dstBox, srcW, srcH, drawW, drawH);
+ LXDisplayVideo(pScrni, surface->id, surface->width, surface->height,
+ &dstBox, srcW, srcH, drawW, drawH);
- pPriv->isOn = TRUE;
-
- if (portPriv->videoStatus & CLIENT_VIDEO_ON) {
- REGION_EMPTY(pScrni->pScreen, &portPriv->clip);
- UpdateCurrentTime();
- portPriv->videoStatus = FREE_TIMER;
- portPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
- }
+ pPriv->isOn = TRUE;
+
+ if (portPriv->videoStatus & CLIENT_VIDEO_ON) {
+ REGION_EMPTY(pScrni->pScreen, &portPriv->clip);
+ UpdateCurrentTime();
+ portPriv->videoStatus = FREE_TIMER;
+ portPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
+ }
- return Success;
+ return Success;
}
-static int
+static int
LXAllocateSurface(ScrnInfoPtr pScrni, int id, unsigned short w,
- unsigned short h, XF86SurfacePtr surface)
+ unsigned short h, XF86SurfacePtr surface)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- void * area = NULL;
- int pitch, lines;
- unsigned offset;
- struct OffscreenPrivRec *pPriv;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ void *area = NULL;
+ int pitch, lines;
+ unsigned offset;
+ struct OffscreenPrivRec *pPriv;
- if (w > 1024 || h > 1024)
- return BadAlloc;
+ if (w > 1024 || h > 1024)
+ return BadAlloc;
- /* The width needs to be word aligned */
- w = (w + 1) & ~1;
+ /* The width needs to be word aligned */
+ w = (w + 1) & ~1;
- pitch = ((w << 1) + 15) & ~15;
- lines = ((pitch * h) + (pGeode->Pitch - 1)) / pGeode->Pitch;
-
- offset = LXAllocateVidMem(pScrni, &area, lines);
+ pitch = ((w << 1) + 15) & ~15;
+ lines = ((pitch * h) + (pGeode->Pitch - 1)) / pGeode->Pitch;
- if (offset == 0) {
- ErrorF("Error while allocating an offscreen region.\n");
- return BadAlloc;
- }
+ offset = LXAllocateVidMem(pScrni, &area, lines);
- surface->width = w;
- surface->height = h;
-
- surface->pitches = xalloc(sizeof(int));
+ if (offset == 0) {
+ ErrorF("Error while allocating an offscreen region.\n");
+ return BadAlloc;
+ }
- surface->offsets = xalloc(sizeof(int));
+ surface->width = w;
+ surface->height = h;
- pPriv = xalloc(sizeof(struct OffscreenPrivRec));
+ surface->pitches = xalloc(sizeof(int));
- if (pPriv && surface->pitches && surface->offsets) {
-
- pPriv->area = area;
- pPriv->offset = offset;
-
- pPriv->isOn = FALSE;
-
- surface->pScrn = pScrni;
- surface->id = id;
- surface->pitches[0] = pitch;
- surface->offsets[0] = offset;
- surface->devPrivate.ptr = (pointer) pPriv;
-
- return Success;
- }
+ surface->offsets = xalloc(sizeof(int));
- if (surface->offsets)
- xfree(surface->offsets);
-
- if (surface->pitches)
- xfree(surface->pitches);
-
- if (area)
- exaOffscreenFree(pScrni->pScreen, area);
-
- return BadAlloc;
+ pPriv = xalloc(sizeof(struct OffscreenPrivRec));
+
+ if (pPriv && surface->pitches && surface->offsets) {
+
+ pPriv->area = area;
+ pPriv->offset = offset;
+
+ pPriv->isOn = FALSE;
+
+ surface->pScrn = pScrni;
+ surface->id = id;
+ surface->pitches[0] = pitch;
+ surface->offsets[0] = offset;
+ surface->devPrivate.ptr = (pointer) pPriv;
+
+ return Success;
+ }
+
+ if (surface->offsets)
+ xfree(surface->offsets);
+
+ if (surface->pitches)
+ xfree(surface->pitches);
+
+ if (area)
+ exaOffscreenFree(pScrni->pScreen, area);
+
+ return BadAlloc;
}
static int
-LXStopSurface(XF86SurfacePtr surface)
+LXStopSurface(XF86SurfacePtr surface)
{
- struct OffscreenPrivRec *pPriv = (struct OffscreenPrivRec *)
- surface->devPrivate.ptr;
+ struct OffscreenPrivRec *pPriv = (struct OffscreenPrivRec *)
+ surface->devPrivate.ptr;
- pPriv->isOn = FALSE;
- return Success;
+ pPriv->isOn = FALSE;
+ return Success;
}
static int
LXFreeSurface(XF86SurfacePtr surface)
{
- struct OffscreenPrivRec *pPriv = (struct OffscreenPrivRec *)
- surface->devPrivate.ptr;
- ScrnInfoPtr pScrni = surface->pScrn;
-
- if (pPriv->isOn)
- LXStopSurface(surface);
-
- if (pPriv->area) {
- exaOffscreenFree(pScrni->pScreen, pPriv->area);
- pPriv->area = NULL;
- }
-
- xfree(surface->pitches);
- xfree(surface->offsets);
- xfree(surface->devPrivate.ptr);
-
- return Success;
+ struct OffscreenPrivRec *pPriv = (struct OffscreenPrivRec *)
+ surface->devPrivate.ptr;
+ ScrnInfoPtr pScrni = surface->pScrn;
+
+ if (pPriv->isOn)
+ LXStopSurface(surface);
+
+ if (pPriv->area) {
+ exaOffscreenFree(pScrni->pScreen, pPriv->area);
+ pPriv->area = NULL;
+ }
+
+ xfree(surface->pitches);
+ xfree(surface->offsets);
+ xfree(surface->devPrivate.ptr);
+
+ return Success;
}
static int
LXGetSurfaceAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 * value)
{
return LXGetPortAttribute(pScrni, attribute, value,
- (pointer) (GET_PORT_PRIVATE(pScrni)));
+ (pointer) (GET_PORT_PRIVATE(pScrni)));
}
static int
LXSetSurfaceAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 value)
{
return LXSetPortAttribute(pScrni, attribute, value,
- (pointer) (GET_PORT_PRIVATE(pScrni)));
+ (pointer) (GET_PORT_PRIVATE(pScrni)));
}
-
static void
-LXInitOffscreenImages(ScreenPtr pScrn)
+LXInitOffscreenImages(ScreenPtr pScrn)
{
- XF86OffscreenImagePtr offscreenImages;
-
- /* need to free this someplace */
- if (!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))
- return;
-
- offscreenImages[0].image = &Images[0];
- offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
- offscreenImages[0].alloc_surface = LXAllocateSurface;
- offscreenImages[0].free_surface = LXFreeSurface;
- offscreenImages[0].display = LXDisplaySurface;
- offscreenImages[0].stop = LXStopSurface;
- offscreenImages[0].setAttribute = LXSetSurfaceAttribute;
- offscreenImages[0].getAttribute = LXGetSurfaceAttribute;
- offscreenImages[0].max_width = 1024;
- offscreenImages[0].max_height = 1024;
- offscreenImages[0].num_attributes = ARRAY_SIZE(Attributes);
- offscreenImages[0].attributes = Attributes;
-
- xf86XVRegisterOffscreenImages(pScrn, offscreenImages, 1);
+ XF86OffscreenImagePtr offscreenImages;
+
+ /* need to free this someplace */
+ if (!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))
+ return;
+
+ offscreenImages[0].image = &Images[0];
+ offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ offscreenImages[0].alloc_surface = LXAllocateSurface;
+ offscreenImages[0].free_surface = LXFreeSurface;
+ offscreenImages[0].display = LXDisplaySurface;
+ offscreenImages[0].stop = LXStopSurface;
+ offscreenImages[0].setAttribute = LXSetSurfaceAttribute;
+ offscreenImages[0].getAttribute = LXGetSurfaceAttribute;
+ offscreenImages[0].max_width = 1024;
+ offscreenImages[0].max_height = 1024;
+ offscreenImages[0].num_attributes = ARRAY_SIZE(Attributes);
+ offscreenImages[0].attributes = Attributes;
+
+ xf86XVRegisterOffscreenImages(pScrn, offscreenImages, 1);
}
-
+
void
LXInitVideo(ScreenPtr pScrn)
{
- GeodeRec *pGeode;
- ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
- XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
- XF86VideoAdaptorPtr newAdaptor = NULL;
- int num_adaptors;
-
- pGeode = GEODEPTR(pScrni);
-
- if (pGeode->NoAccel) {
- ErrorF("Cannot run Xv without accelerations!\n");
- return;
- }
-
- if (!(newAdaptor = LXSetupImageVideo(pScrn))) {
- ErrorF("Error while setting up the adaptor.\n");
- return;
- }
-
- LXInitOffscreenImages(pScrn);
-
- num_adaptors = xf86XVListGenericAdaptors(pScrni, &adaptors);
-
- if (!num_adaptors) {
- num_adaptors = 1;
- adaptors = &newAdaptor;
- } else {
- newAdaptors =
- xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr *));
-
- if (newAdaptors) {
- memcpy(newAdaptors, adaptors, num_adaptors *
- sizeof(XF86VideoAdaptorPtr));
- newAdaptors[num_adaptors] = newAdaptor;
- adaptors = newAdaptors;
- num_adaptors++;
+ GeodeRec *pGeode;
+ ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
+ XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
+ XF86VideoAdaptorPtr newAdaptor = NULL;
+ int num_adaptors;
+
+ pGeode = GEODEPTR(pScrni);
+
+ if (pGeode->NoAccel) {
+ ErrorF("Cannot run Xv without accelerations!\n");
+ return;
+ }
+
+ if (!(newAdaptor = LXSetupImageVideo(pScrn))) {
+ ErrorF("Error while setting up the adaptor.\n");
+ return;
+ }
+
+ LXInitOffscreenImages(pScrn);
+
+ num_adaptors = xf86XVListGenericAdaptors(pScrni, &adaptors);
+
+ if (!num_adaptors) {
+ num_adaptors = 1;
+ adaptors = &newAdaptor;
+ } else {
+ newAdaptors =
+ xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr *));
+
+ if (newAdaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors *
+ sizeof(XF86VideoAdaptorPtr));
+ newAdaptors[num_adaptors] = newAdaptor;
+ adaptors = newAdaptors;
+ num_adaptors++;
+ } else
+ ErrorF("Memory error while setting up the adaptor\n");
}
- else
- ErrorF("Memory error while setting up the adaptor\n");
- }
-
- if (num_adaptors)
- xf86XVScreenInit(pScrn, adaptors, num_adaptors);
-
- if (newAdaptors)
- xfree(newAdaptors);
+
+ if (num_adaptors)
+ xf86XVScreenInit(pScrn, adaptors, num_adaptors);
+
+ if (newAdaptors)
+ xfree(newAdaptors);
}
diff --git a/src/panel.c b/src/panel.c
index 4cb2cf7..b7eb88f 100644
--- a/src/panel.c
+++ b/src/panel.c
@@ -24,7 +24,7 @@
* */
/*
- * File Contents: This file contailns the panel include files and
+ * File Contents: This file contailns the panel include files and
* external pointer to the hardware.
*
* Project: Geode Xfree Frame buffer device driver.
@@ -45,11 +45,11 @@
#include "gfx_defs.h"
#include "geode.h"
-#define PLATFORM_DYNAMIC 1 /* runtime selection */
-#define PLATFORM_DRACO 0 /* Draco + 9210 */
-#define PLATFORM_CENTAURUS 1 /* Centaurus + 9211 RevA */
-#define PLATFORM_DORADO 1 /* Dorado + 9211 RevC */
-#define PLATFORM_GX2BASED 1 /* Redcloud */
+#define PLATFORM_DYNAMIC 1 /* runtime selection */
+#define PLATFORM_DRACO 0 /* Draco + 9210 */
+#define PLATFORM_CENTAURUS 1 /* Centaurus + 9211 RevA */
+#define PLATFORM_DORADO 1 /* Dorado + 9211 RevC */
+#define PLATFORM_GX2BASED 1 /* Redcloud */
unsigned char *XpressROMPtr;
diff --git a/src/z4l.c b/src/z4l.c
index 0df3d13..e5a819e 100644
--- a/src/z4l.c
+++ b/src/z4l.c
@@ -185,7 +185,7 @@ IoCtl(int fd, unsigned int fn, void *arg, int flag)
errno = 0;
ret = ioctl(fd, fn, arg);
if (ret != 0 && flag != 0)
- DBLOG(0, "ioctl(%08x)=%d\n", fn, ret);
+ DBLOG(0, "ioctl(%08x)=%d\n", fn, ret);
return ret;
}
@@ -197,15 +197,15 @@ z4l_ovly_unmap(Z4lPortPrivRec * pPriv)
nbfrs = pPriv->nbfrs;
for (i = 0; i < nbfrs; ++i) {
- if (pPriv->bfrs[i].start != NULL) {
- munmap(pPriv->bfrs[i].start, pPriv->bfrs[i].length);
- pPriv->bfrs[i].start = NULL;
- }
+ if (pPriv->bfrs[i].start != NULL) {
+ munmap(pPriv->bfrs[i].start, pPriv->bfrs[i].length);
+ pPriv->bfrs[i].start = NULL;
+ }
}
#else
if (pPriv->bfrs[0].start != NULL) {
- munmap((void *)pPriv->bfrs[0].start, pPriv->bufsz);
- pPriv->bfrs[0].start = NULL;
+ munmap((void *)pPriv->bfrs[0].start, pPriv->bufsz);
+ pPriv->bfrs[0].start = NULL;
}
#endif
pPriv->nbfrs = -1;
@@ -221,10 +221,10 @@ z4l_ovly_map(Z4lPortPrivRec * pPriv, int dir)
struct v4l2_buffer bfr;
struct v4l2_requestbuffers req;
int type = dir >= 0 ?
- V4L2_BUF_TYPE_VIDEO_CAPTURE : V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ V4L2_BUF_TYPE_VIDEO_CAPTURE : V4L2_BUF_TYPE_VIDEO_OVERLAY;
if (pPriv->run > 0) {
- DBLOG(1, "busy\n");
- return;
+ DBLOG(1, "busy\n");
+ return;
}
fd = pPriv->fd;
memset(&req, 0, sizeof(req));
@@ -232,62 +232,62 @@ z4l_ovly_map(Z4lPortPrivRec * pPriv, int dir)
req.memory = V4L2_MEMORY_MMAP;
req.count = MAX_BUFFERS;
if (ioctl(fd, VIDIOC_REQBUFS, &req) < 0)
- goto xit;
+ goto xit;
pPriv->nbfrs = req.count;
if (pPriv->nbfrs <= 0) {
- DBLOG(1, "no vidmem\n");
- return;
+ DBLOG(1, "no vidmem\n");
+ return;
}
memset(&pPriv->bfrs, 0, sizeof(pPriv->bfrs));
for (i = 0; i < pPriv->nbfrs; ++i) {
- memset(&bfr, 0, sizeof(bfr));
- bfr.type = type;
- bfr.index = i;
- if (ioctl(fd, VIDIOC_QUERYBUF, &bfr) < 0)
- goto xit;
- offset = bfr.m.offset;
- pPriv->bfrs[i].offset = offset;
- pPriv->bfrs[i].length = bfr.length;
- bsz = offset + bfr.length;
- if (pPriv->bufsz < bsz)
- pPriv->bufsz = bsz;
+ memset(&bfr, 0, sizeof(bfr));
+ bfr.type = type;
+ bfr.index = i;
+ if (ioctl(fd, VIDIOC_QUERYBUF, &bfr) < 0)
+ goto xit;
+ offset = bfr.m.offset;
+ pPriv->bfrs[i].offset = offset;
+ pPriv->bfrs[i].length = bfr.length;
+ bsz = offset + bfr.length;
+ if (pPriv->bufsz < bsz)
+ pPriv->bufsz = bsz;
}
#ifdef LINUX_2_6
for (i = 0; i < pPriv->nbfrs; ++i) {
- pPriv->bfrs[i].start = mmap(NULL, bfr.length, PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, pPriv->bfrs[i].offset);
- if (pPriv->bfrs[i].start == MAP_FAILED)
- goto xit;
+ pPriv->bfrs[i].start = mmap(NULL, bfr.length, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, pPriv->bfrs[i].offset);
+ if (pPriv->bfrs[i].start == MAP_FAILED)
+ goto xit;
}
#else
pPriv->bfrs[0].offset = 0;
pPriv->bfrs[0].start =
- mmap(NULL, pPriv->bufsz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ mmap(NULL, pPriv->bufsz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (pPriv->bfrs[0].start == MAP_FAILED) {
- pPriv->bfrs[0].start = NULL;
- goto xit;
+ pPriv->bfrs[0].start = NULL;
+ goto xit;
}
offset = (unsigned long)pPriv->bfrs[0].start;
for (i = 1; i < pPriv->nbfrs; ++i)
- pPriv->bfrs[i].start = (void *)(offset + pPriv->bfrs[i].offset);
+ pPriv->bfrs[i].start = (void *)(offset + pPriv->bfrs[i].offset);
#endif
for (i = 0; i < pPriv->nbfrs; ++i) {
- DBLOG(3, "bfr %d ofs %#lx adr %p sz %lu\n", i, pPriv->bfrs[i].offset,
- pPriv->bfrs[i].start, (unsigned long)pPriv->bfrs[i].length);
- memset(pPriv->bfrs[i].start, 0x80, pPriv->bfrs[i].length);
+ DBLOG(3, "bfr %d ofs %#lx adr %p sz %lu\n", i, pPriv->bfrs[i].offset,
+ pPriv->bfrs[i].start, (unsigned long)pPriv->bfrs[i].length);
+ memset(pPriv->bfrs[i].start, 0x80, pPriv->bfrs[i].length);
}
pPriv->last = 0;
while (pPriv->last < pPriv->nbfrs - 1) {
- bfr.index = pPriv->last++;
- bfr.type = type;
- if (ioctl(fd, VIDIOC_QBUF, &bfr) < 0)
- goto xit;
+ bfr.index = pPriv->last++;
+ bfr.type = type;
+ if (ioctl(fd, VIDIOC_QBUF, &bfr) < 0)
+ goto xit;
}
return;
@@ -311,7 +311,7 @@ z4l_ovly_dqbuf(Z4lPortPrivRec * pPriv)
tmo.tv_sec = 0;
tmo.tv_usec = 0;
if (select(fd + 1, &dqset, NULL, NULL, &tmo) <= 0)
- return -1;
+ return -1;
#endif
memset(&bfr, 0, sizeof(bfr));
bfr.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
@@ -327,15 +327,15 @@ z4l_open_device(Z4lPortPrivRec * pPriv)
int enable;
if (pPriv->fd < 0) {
- pPriv->fd = open(&pPriv->dev_path[0], O_RDWR, 0);
- DBLOG(1, "open(%s)=%d\n", &pPriv->dev_path[0], pPriv->fd);
- enable = 1;
+ pPriv->fd = open(&pPriv->dev_path[0], O_RDWR, 0);
+ DBLOG(1, "open(%s)=%d\n", &pPriv->dev_path[0], pPriv->fd);
+ enable = 1;
#ifdef NONBLK_IO
- if (IoCtl(pPriv->fd, FIONBIO, &enable, 1) != 0) {
- DBLOG(1, "open cant enable nonblocking\n");
- close(pPriv->fd);
- pPriv->fd = -1;
- }
+ if (IoCtl(pPriv->fd, FIONBIO, &enable, 1) != 0) {
+ DBLOG(1, "open cant enable nonblocking\n");
+ close(pPriv->fd);
+ pPriv->fd = -1;
+ }
#endif
}
return pPriv->fd;
@@ -347,13 +347,13 @@ z4l_close_device(Z4lPortPrivRec * pPriv)
int ret = 0;
if (pPriv->fd >= 0) {
- ret = close(pPriv->fd);
- pPriv->fd = -1;
- DBLOG(1, "close()=%d\n", ret);
+ ret = close(pPriv->fd);
+ pPriv->fd = -1;
+ DBLOG(1, "close()=%d\n", ret);
}
if (pPriv->run > 0) {
- z4l_ovly_unmap(pPriv);
- pPriv->run = -1;
+ z4l_ovly_unmap(pPriv);
+ pPriv->run = -1;
}
return ret;
@@ -365,8 +365,8 @@ z4l_ovly_reset(Z4lPortPrivRec * pPriv)
int ret = 0;
if (pPriv->run > 0) {
- z4l_close_device(pPriv);
- ret = z4l_open_device(pPriv);
+ z4l_close_device(pPriv);
+ ret = z4l_open_device(pPriv);
}
return ret;
@@ -379,18 +379,18 @@ z4l_fourcc_pixfmt(int fourcc)
switch (fourcc) {
case FOURCC_UYVY:
- pixfmt = V4L2_PIX_FMT_UYVY;
- break;
+ pixfmt = V4L2_PIX_FMT_UYVY;
+ break;
case FOURCC_YV12:
- pixfmt = V4L2_PIX_FMT_YVU420;
- break;
+ pixfmt = V4L2_PIX_FMT_YVU420;
+ break;
case FOURCC_Y800:
case FOURCC_I420:
- pixfmt = V4L2_PIX_FMT_YUV420;
- break;
+ pixfmt = V4L2_PIX_FMT_YUV420;
+ break;
case FOURCC_YUY2:
- pixfmt = V4L2_PIX_FMT_YUYV;
- break;
+ pixfmt = V4L2_PIX_FMT_YUYV;
+ break;
}
return pixfmt;
@@ -442,60 +442,60 @@ z4l_ovly_rect(Z4lPortPrivRec * pPriv,
pPriv->drw_h = drw_h;
if ((drw_x -= z4l_x_offset) < 0) {
- if ((w = pPriv->drw_w) <= 0)
- w = 1;
- x = -drw_x;
- dx = x * pPriv->src_w / w;
- src_x = pPriv->src_x + dx;
- src_w = pPriv->src_w - dx;
- drw_w = pPriv->drw_w - x;
- drw_x = 0;
+ if ((w = pPriv->drw_w) <= 0)
+ w = 1;
+ x = -drw_x;
+ dx = x * pPriv->src_w / w;
+ src_x = pPriv->src_x + dx;
+ src_w = pPriv->src_w - dx;
+ drw_w = pPriv->drw_w - x;
+ drw_x = 0;
}
if ((drw_y -= z4l_y_offset) < 0) {
- if ((h = pPriv->drw_h) <= 0)
- h = 1;
- y = -drw_y;
- dy = y * pPriv->src_h / h;
- src_y = pPriv->src_y + dy;
- src_h = pPriv->src_h - dy;
- drw_h = pPriv->drw_h - y;
- drw_y = 0;
+ if ((h = pPriv->drw_h) <= 0)
+ h = 1;
+ y = -drw_y;
+ dy = y * pPriv->src_h / h;
+ src_y = pPriv->src_y + dy;
+ src_h = pPriv->src_h - dy;
+ drw_h = pPriv->drw_h - y;
+ drw_y = 0;
}
memset(&fmt, 0, sizeof(fmt));
fmt.type = 0x100;
IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1);
if (pPriv->src_is_set != 0) {
- if (src_x != fmt.fmt.win.w.left || src_y != fmt.fmt.win.w.top ||
- src_w != fmt.fmt.win.w.width || src_h != fmt.fmt.win.w.height)
- pPriv->src_is_set = 0;
+ if (src_x != fmt.fmt.win.w.left || src_y != fmt.fmt.win.w.top ||
+ src_w != fmt.fmt.win.w.width || src_h != fmt.fmt.win.w.height)
+ pPriv->src_is_set = 0;
}
if (pPriv->src_is_set == 0) {
- pPriv->src_is_set = 1;
- fmt.fmt.win.w.left = src_x;
- fmt.fmt.win.w.top = src_y;
- fmt.fmt.win.w.width = src_w;
- fmt.fmt.win.w.height = src_h;
- IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1);
- DBLOG(3, " set src %d,%d %dx%d\n", src_x, src_y, src_w, src_h);
+ pPriv->src_is_set = 1;
+ fmt.fmt.win.w.left = src_x;
+ fmt.fmt.win.w.top = src_y;
+ fmt.fmt.win.w.width = src_w;
+ fmt.fmt.win.w.height = src_h;
+ IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1);
+ DBLOG(3, " set src %d,%d %dx%d\n", src_x, src_y, src_w, src_h);
}
memset(&fmt, 0, sizeof(fmt));
fmt.type = 0x101;
IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1);
if (pPriv->drw_is_set != 0) {
- if (drw_x != fmt.fmt.win.w.left || drw_y != fmt.fmt.win.w.top ||
- drw_w != fmt.fmt.win.w.width || drw_h != fmt.fmt.win.w.height)
- pPriv->drw_is_set = 0;
+ if (drw_x != fmt.fmt.win.w.left || drw_y != fmt.fmt.win.w.top ||
+ drw_w != fmt.fmt.win.w.width || drw_h != fmt.fmt.win.w.height)
+ pPriv->drw_is_set = 0;
}
if (pPriv->drw_is_set == 0) {
- pPriv->drw_is_set = 1;
- fmt.fmt.win.w.left = drw_x;
- fmt.fmt.win.w.top = drw_y;
- fmt.fmt.win.w.width = drw_w;
- fmt.fmt.win.w.height = drw_h;
- IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1);
- DBLOG(3, " set drw %d,%d %dx%d\n", drw_x, drw_y, drw_w, drw_h);
+ pPriv->drw_is_set = 1;
+ fmt.fmt.win.w.left = drw_x;
+ fmt.fmt.win.w.top = drw_y;
+ fmt.fmt.win.w.width = drw_w;
+ fmt.fmt.win.w.height = drw_h;
+ IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1);
+ DBLOG(3, " set drw %d,%d %dx%d\n", drw_x, drw_y, drw_w, drw_h);
}
}
@@ -510,22 +510,22 @@ z4l_ovly_pitch(unsigned int pixfmt, int w, int h, int *py_pitch,
switch (pixfmt) {
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_YUV420:
- is_420 = 1;
- y_pitch = ((w + 1) / 2) * 2;
- uv_pitch = (w + 1) / 2;
- break;
+ is_420 = 1;
+ y_pitch = ((w + 1) / 2) * 2;
+ uv_pitch = (w + 1) / 2;
+ break;
default:
- is_420 = 0;
- y_pitch = ((w + 1) / 2) * 4;
- uv_pitch = 0;
- break;
+ is_420 = 0;
+ y_pitch = ((w + 1) / 2) * 4;
+ uv_pitch = 0;
+ break;
}
offset1 = y_pitch * h;
offset2 = uv_pitch * h;
if (is_420 != 0)
- offset2 /= 2;
+ offset2 /= 2;
size = offset1 + 2 * offset2;
*py_pitch = y_pitch;
@@ -543,10 +543,10 @@ z4l_ovly_set_colorkey(Z4lPortPrivRec * pPriv, int key)
memset(&fmt, 0, sizeof(fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
if (IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1) < 0)
- return 0;
+ return 0;
fmt.fmt.win.chromakey = key;
if (IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1) < 0)
- return 0;
+ return 0;
pPriv->colorkey = key;
return 1;
@@ -560,7 +560,7 @@ z4l_ovly_get_colorkey(Z4lPortPrivRec * pPriv, int *key)
memset(&fmt, 0, sizeof(fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
if (IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1) < 0)
- return 0;
+ return 0;
*key = fmt.fmt.win.chromakey;
return 1;
@@ -573,16 +573,16 @@ z4l_ovly_set_keymode(Z4lPortPrivRec * pPriv, int enable)
memset(&fbuf, 0, sizeof(fbuf));
if (IoCtl(pPriv->fd, VIDIOC_G_FBUF, &fbuf, 1) < 0)
- return 0;
+ return 0;
if (enable != 0)
- fbuf.flags |= V4L2_FBUF_FLAG_CHROMAKEY;
+ fbuf.flags |= V4L2_FBUF_FLAG_CHROMAKEY;
else
- fbuf.flags &= ~V4L2_FBUF_FLAG_CHROMAKEY;
+ fbuf.flags &= ~V4L2_FBUF_FLAG_CHROMAKEY;
fbuf.base = NULL;
if (IoCtl(pPriv->fd, VIDIOC_S_FBUF, &fbuf, 1) < 0)
- return 0;
+ return 0;
pPriv->keymode = enable;
return 1;
@@ -595,7 +595,7 @@ z4l_ovly_get_keymode(Z4lPortPrivRec * pPriv, int *enable)
memset(&fbuf, 0, sizeof(fbuf));
if (IoCtl(pPriv->fd, VIDIOC_G_FBUF, &fbuf, 1) < 0)
- return 0;
+ return 0;
*enable = (fbuf.flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0 ? 1 : 0;
return 1;
@@ -616,7 +616,7 @@ z4l_ovly_set_encoding(Z4lPortPrivRec * pPriv, int id)
adpt = pPriv->adpt;
DBLOG(1, "z4l_ovly_set_encoding(%d)\n", id);
if (id < 0 || id >= adpt->nEncodings)
- return 0;
+ return 0;
enc = &adpt->pEncodings[id];
cp = &enc->name[0];
n = sizeof(int) - 1;
@@ -626,32 +626,32 @@ z4l_ovly_set_encoding(Z4lPortPrivRec * pPriv, int id)
inp = sp->inp;
DBLOG(1, " nm %s fmt %4.4s inp %d std %llx\n",
- cp, (char *)&sp->fmt, sp->inp, sp->std);
+ cp, (char *)&sp->fmt, sp->inp, sp->std);
if (IoCtl(pPriv->fd, VIDIOC_S_INPUT, &inp, 1) < 0)
- return 0;
+ return 0;
std = sp->std;
if (IoCtl(pPriv->fd, VIDIOC_S_STD, &std, 1) < 0)
- return 0;
+ return 0;
memset(&fmt, 0, sizeof(fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (IoCtl(pPriv->fd, VIDIOC_G_FMT, &fmt, 1) < 0)
- return 0;
+ return 0;
fmt.fmt.pix.pixelformat = sp->fmt;
if (IoCtl(pPriv->fd, VIDIOC_S_FMT, &fmt, 1) < 0)
- return 0;
+ return 0;
memset(&fbuf, 0, sizeof(fbuf));
if (IoCtl(pPriv->fd, VIDIOC_G_FBUF, &fbuf, 1) < 0)
- return 0;
+ return 0;
fbuf.fmt.pixelformat = sp->fmt;
fbuf.base = NULL;
if (IoCtl(pPriv->fd, VIDIOC_S_FBUF, &fbuf, 1) < 0)
- return 0;
+ return 0;
pPriv->pixfmt = sp->fmt;
pPriv->enc = enc;
pPriv->src_is_set = pPriv->drw_is_set = 0;
@@ -674,21 +674,21 @@ z4l_ovly_stop(Z4lPortPrivRec * pPriv)
int type, enable, fd;
if (pPriv->run < 0)
- return;
+ return;
fd = pPriv->fd;
if (pPriv->dir > 0) {
- type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- ioctl(fd, VIDIOC_STREAMOFF, &type);
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ ioctl(fd, VIDIOC_STREAMOFF, &type);
}
if (pPriv->dir <= 0) {
- enable = 0;
- ioctl(fd, VIDIOC_OVERLAY, &enable);
+ enable = 0;
+ ioctl(fd, VIDIOC_OVERLAY, &enable);
}
if (pPriv->dir != 0)
- z4l_ovly_unmap(pPriv);
+ z4l_ovly_unmap(pPriv);
pPriv->run = -1;
z4l_close_device(pPriv);
@@ -700,16 +700,16 @@ z4l_ovly_start(Z4lPortPrivRec * pPriv, int dir)
int enable;
if (pPriv->run >= 0)
- return;
+ return;
if ((pPriv->dir = dir) != 0)
- z4l_ovly_map(pPriv, dir);
+ z4l_ovly_map(pPriv, dir);
enable = 1;
if (IoCtl(pPriv->fd, VIDIOC_OVERLAY, &enable, 1) != 0) {
- z4l_ovly_stop(pPriv);
- return;
+ z4l_ovly_stop(pPriv);
+ return;
}
pPriv->run = 1;
@@ -722,26 +722,26 @@ z4l_region_equal(RegionPtr ap, RegionPtr bp)
BoxPtr abox, bbox;
if (ap == NULL && bp == NULL)
- return 1;
+ return 1;
if (ap == NULL || bp == NULL)
- return 0;
+ return 0;
if ((nboxes = REGION_NUM_RECTS(ap)) != REGION_NUM_RECTS(bp) ||
- ap->extents.x1 != bp->extents.x1 ||
- ap->extents.x2 != bp->extents.x2
- || ap->extents.y1 != bp->extents.y1
- || ap->extents.y2 != bp->extents.y2)
- return 0;
+ ap->extents.x1 != bp->extents.x1 ||
+ ap->extents.x2 != bp->extents.x2
+ || ap->extents.y1 != bp->extents.y1
+ || ap->extents.y2 != bp->extents.y2)
+ return 0;
abox = REGION_RECTS(ap);
bbox = REGION_RECTS(bp);
while (--nboxes >= 0) {
- if (abox->x1 != bbox->x1 || abox->y1 != bbox->y1 ||
- abox->x2 != bbox->x2 || abox->y2 != bbox->y2)
- return 0;
- ++abox;
- ++bbox;
+ if (abox->x1 != bbox->x1 || abox->y1 != bbox->y1 ||
+ abox->x2 != bbox->x2 || abox->y2 != bbox->y2)
+ return 0;
+ ++abox;
+ ++bbox;
}
return 1;
@@ -752,9 +752,9 @@ z4l_setup_colorkey(Z4lPortPrivRec * pPriv, ScreenPtr pScrn,
RegionPtr clipBoxes)
{
if (pPriv->run > 0 && pPriv->dir <= 0 && pPriv->keymode != 0 &&
- z4l_region_equal(&pPriv->clips, clipBoxes) == 0) {
- xf86XVFillKeyHelper(pScrn, pPriv->colorkey, clipBoxes);
- REGION_COPY(pScrn, &pPriv->clips, clipBoxes);
+ z4l_region_equal(&pPriv->clips, clipBoxes) == 0) {
+ xf86XVFillKeyHelper(pScrn, pPriv->colorkey, clipBoxes);
+ REGION_COPY(pScrn, &pPriv->clips, clipBoxes);
}
}
@@ -766,9 +766,9 @@ Z4lStopVideo(ScrnInfoPtr pScrni, pointer data, Bool exit)
DBLOG(1, "Z4lStopVideo()\n");
if (exit != 0)
- z4l_ovly_stop(pPriv);
+ z4l_ovly_stop(pPriv);
else
- pPriv->src_is_set = pPriv->drw_is_set = 0;
+ pPriv->src_is_set = pPriv->drw_is_set = 0;
REGION_EMPTY(pScrni->pScreen, &pPriv->clips);
}
@@ -779,14 +779,14 @@ Z4lQueryBestSize(ScrnInfoPtr pScrni, Bool motion,
unsigned int *p_w, unsigned int *p_h, pointer data)
{
if (drw_w > MAX_OVLY_WIDTH)
- drw_w = MAX_OVLY_WIDTH;
+ drw_w = MAX_OVLY_WIDTH;
if (drw_h > MAX_OVLY_HEIGHT)
- drw_h = MAX_OVLY_HEIGHT;
+ drw_h = MAX_OVLY_HEIGHT;
*p_w = drw_w;
*p_h = drw_h;
DBLOG(1, "Z4lQueryBestSize(%d, src %dx%d dst %dx%d)\n", motion, vid_w,
- vid_h, drw_w, drw_h);
+ vid_h, drw_w, drw_h);
}
static int
@@ -803,63 +803,63 @@ Z4lPutImage(ScrnInfoPtr pScrni, short src_x, short src_y, short drw_x,
Z4lPortPrivRec *pPriv = (Z4lPortPrivRec *) data;
if (pPriv->run > 0 && pPriv->dir >= 0)
- return BadMatch;
+ return BadMatch;
if (pPriv->fd < 0) {
- z4l_open_device(pPriv);
- if (pPriv->fd < 0)
- return BadValue;
+ z4l_open_device(pPriv);
+ if (pPriv->fd < 0)
+ return BadValue;
}
fd = pPriv->fd;
if (pPriv->run < 0) {
- DBLOG(2, "PutImg id %#x src %d,%d %dx%d drw %d,%d %dx%d bfr %p "
- "%dx%d data %p\n", id, src_x, src_y, src_w, src_h, drw_x,
- drw_y, drw_w, drw_h, buf, width, height, data);
- pPriv->pixfmt = pPriv->height = -1;
- pPriv->src_is_set = pPriv->drw_is_set = 0;
+ DBLOG(2, "PutImg id %#x src %d,%d %dx%d drw %d,%d %dx%d bfr %p "
+ "%dx%d data %p\n", id, src_x, src_y, src_w, src_h, drw_x,
+ drw_y, drw_w, drw_h, buf, width, height, data);
+ pPriv->pixfmt = pPriv->height = -1;
+ pPriv->src_is_set = pPriv->drw_is_set = 0;
}
pixfmt = z4l_fourcc_pixfmt(id);
if (pixfmt != pPriv->pixfmt) {
- z4l_ovly_reset(pPriv);
- z4l_ovly_pixfmt(pPriv, pixfmt);
+ z4l_ovly_reset(pPriv);
+ z4l_ovly_pixfmt(pPriv, pixfmt);
}
if (pPriv->width != width || pPriv->height != height) {
- z4l_ovly_reset(pPriv);
- z4l_ovly_bfr(pPriv, width, height);
+ z4l_ovly_reset(pPriv);
+ z4l_ovly_bfr(pPriv, width, height);
}
if (pPriv->src_is_set == 0 || pPriv->drw_is_set == 0 ||
- pPriv->src_x != src_x || pPriv->src_y != src_y ||
- pPriv->src_w != src_w || pPriv->src_h != src_h ||
- pPriv->drw_x != drw_x || pPriv->drw_y != drw_y ||
- pPriv->drw_w != drw_w || pPriv->drw_h != drw_h)
- z4l_ovly_rect(pPriv, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w,
- drw_h);
+ pPriv->src_x != src_x || pPriv->src_y != src_y ||
+ pPriv->src_w != src_w || pPriv->src_h != src_h ||
+ pPriv->drw_x != drw_x || pPriv->drw_y != drw_y ||
+ pPriv->drw_w != drw_w || pPriv->drw_h != drw_h)
+ z4l_ovly_rect(pPriv, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w,
+ drw_h);
if (pPriv->run < 0) {
- z4l_ovly_start(pPriv, -1);
- if (pPriv->run < 0)
- return BadValue;
+ z4l_ovly_start(pPriv, -1);
+ if (pPriv->run < 0)
+ return BadValue;
}
if (pPriv->last < 0 && (pPriv->last = z4l_ovly_dqbuf(pPriv)) < 0)
- return BadAlloc;
+ return BadAlloc;
z4l_ovly_pitch(pixfmt, width, height, &y_pitch, &uv_pitch,
- &offset1, &offset2, &size);
+ &offset1, &offset2, &size);
src = buf;
dst = (unsigned char *)pPriv->bfrs[pPriv->last].start;
DBLOG(3, "cpy %4.4s src %p dst %p yp %d uvp %d o1 %d o2 %d sz %d\n",
- (char *)&id, src, dst, y_pitch, uv_pitch, offset1, offset2, size);
+ (char *)&id, src, dst, y_pitch, uv_pitch, offset1, offset2, size);
if (id == FOURCC_Y800) {
- memcpy(dst, src, offset1);
- src += offset1;
- dst += offset1;
- memset(dst, 0x80, 2 * offset2);
+ memcpy(dst, src, offset1);
+ src += offset1;
+ dst += offset1;
+ memset(dst, 0x80, 2 * offset2);
} else
- memcpy(dst, src, size);
+ memcpy(dst, src, size);
memset(&bfr, 0, sizeof(bfr));
bfr.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
@@ -868,7 +868,7 @@ Z4lPutImage(ScrnInfoPtr pScrni, short src_x, short src_y, short drw_x,
bfr.timestamp.tv_usec = 0;
bfr.flags |= V4L2_BUF_FLAG_TIMECODE;
if (IoCtl(fd, VIDIOC_QBUF, &bfr, 1) != 0)
- return BadAccess;
+ return BadAccess;
pPriv->last = z4l_ovly_dqbuf(pPriv);
z4l_setup_colorkey(pPriv, pScrni->pScreen, clipBoxes);
@@ -887,36 +887,36 @@ Z4lQueryImageAttributes(ScrnInfoPtr pScrni, int id, unsigned short *width,
w = *width;
h = *height;
if (w > MAX_OVLY_WIDTH)
- w = MAX_OVLY_WIDTH;
+ w = MAX_OVLY_WIDTH;
if (h > MAX_OVLY_HEIGHT)
- h = MAX_OVLY_HEIGHT;
+ h = MAX_OVLY_HEIGHT;
z4l_ovly_pitch(pixfmt, w, h, &y_pitch, &uv_pitch,
- &offset1, &offset2, &size);
+ &offset1, &offset2, &size);
if (offsets != NULL)
- offsets[0] = 0;
+ offsets[0] = 0;
if (pitches != NULL)
- pitches[0] = y_pitch;
+ pitches[0] = y_pitch;
switch (pixfmt) {
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_YUV420:
- if (offsets != NULL) {
- offsets[1] = offset1;
- offsets[2] = offset1 + offset2;
- }
- if (pitches != NULL)
- pitches[1] = pitches[2] = uv_pitch;
- h = (h + 1) & ~1;
- break;
+ if (offsets != NULL) {
+ offsets[1] = offset1;
+ offsets[2] = offset1 + offset2;
+ }
+ if (pitches != NULL)
+ pitches[1] = pitches[2] = uv_pitch;
+ h = (h + 1) & ~1;
+ break;
}
w = (w + 1) & ~1;
*width = w;
*height = h;
DBLOG(1, "Z4lQueryImageAttributes(%4.4s) = %d, %dx%d %d/%d %d/%d\n",
- (char *)&id, size, w, h, y_pitch, uv_pitch, offset1, offset2);
+ (char *)&id, size, w, h, y_pitch, uv_pitch, offset1, offset2);
return size;
}
@@ -930,27 +930,27 @@ Z4lPutVideo(ScrnInfoPtr pScrni, short src_x, short src_y, short drw_x,
Z4lPortPrivRec *pPriv = (Z4lPortPrivRec *) data;
DBLOG(2, "PutVid src %d,%d %dx%d drw %d,%d %dx%d data %p\n",
- src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, data);
+ src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, data);
if (z4l_open_device(pPriv) >= 0) {
- if (pPriv->run < 0) {
- DBLOG(2, "PutVid start\n");
- z4l_ovly_get_encoding(pPriv, &id);
- z4l_ovly_set_encoding(pPriv, id);
- }
- DBLOG(2, "PutVid priv %d,%d %dx%d drw %d,%d %dx%d\n",
- pPriv->src_x, pPriv->src_y, pPriv->src_w, pPriv->src_h,
- pPriv->drw_x, pPriv->drw_y, pPriv->drw_w, pPriv->drw_h);
- if (pPriv->src_is_set == 0 || pPriv->drw_is_set == 0 ||
- pPriv->src_w != src_w || pPriv->src_h != src_h ||
- pPriv->drw_x != drw_x || pPriv->drw_y != drw_y ||
- pPriv->drw_w != drw_w || pPriv->drw_h != drw_h)
- z4l_ovly_rect(pPriv, src_x, src_y, src_w, src_h, drw_x, drw_y,
- drw_w, drw_h);
- if (pPriv->run < 0)
- z4l_ovly_start(pPriv, 0);
-
- z4l_setup_colorkey(pPriv, pScrni->pScreen, clipBoxes);
+ if (pPriv->run < 0) {
+ DBLOG(2, "PutVid start\n");
+ z4l_ovly_get_encoding(pPriv, &id);
+ z4l_ovly_set_encoding(pPriv, id);
+ }
+ DBLOG(2, "PutVid priv %d,%d %dx%d drw %d,%d %dx%d\n",
+ pPriv->src_x, pPriv->src_y, pPriv->src_w, pPriv->src_h,
+ pPriv->drw_x, pPriv->drw_y, pPriv->drw_w, pPriv->drw_h);
+ if (pPriv->src_is_set == 0 || pPriv->drw_is_set == 0 ||
+ pPriv->src_w != src_w || pPriv->src_h != src_h ||
+ pPriv->drw_x != drw_x || pPriv->drw_y != drw_y ||
+ pPriv->drw_w != drw_w || pPriv->drw_h != drw_h)
+ z4l_ovly_rect(pPriv, src_x, src_y, src_w, src_h, drw_x, drw_y,
+ drw_w, drw_h);
+ if (pPriv->run < 0)
+ z4l_ovly_start(pPriv, 0);
+
+ z4l_setup_colorkey(pPriv, pScrni->pScreen, clipBoxes);
}
return Success;
@@ -961,10 +961,10 @@ Z4lNewEncoding(XF86VideoEncodingPtr * encs, int *nencs)
{
XF86VideoEncodingPtr enc;
XF86VideoEncodingPtr tencs =
- (XF86VideoEncodingPtr) xrealloc(*encs, sizeof(*tencs) * (*nencs + 1));
+ (XF86VideoEncodingPtr) xrealloc(*encs, sizeof(*tencs) * (*nencs + 1));
if (tencs == NULL)
- return NULL;
+ return NULL;
*encs = tencs;
enc = &tencs[*nencs];
@@ -980,38 +980,38 @@ Z4lEncodingName(char *ename, int l, char *inp_name, char *std_name, char *fmt)
int i, ch;
while ((ch = *inp_name++) != 0) {
- if (isalnum(ch) == 0)
- continue;
- if (--l <= 0)
- goto xit;
- *ename++ = ch;
+ if (isalnum(ch) == 0)
+ continue;
+ if (--l <= 0)
+ goto xit;
+ *ename++ = ch;
}
if (--l <= 0)
- goto xit;
+ goto xit;
*ename++ = '-';
while ((ch = *std_name++) != 0) {
- if (isalnum(ch) == 0)
- continue;
- if (--l <= 0)
- goto xit;
- *ename++ = ch;
+ if (isalnum(ch) == 0)
+ continue;
+ if (--l <= 0)
+ goto xit;
+ *ename++ = ch;
}
if (--l <= 0)
- goto xit;
+ goto xit;
*ename++ = '-';
i = 4;
while (--i >= 0 && (ch = *fmt++) != 0) {
- if (isalnum(ch) == 0)
- continue;
- if (--l <= 0)
- goto xit;
- *ename++ = ch;
+ if (isalnum(ch) == 0)
+ continue;
+ if (--l <= 0)
+ goto xit;
+ *ename++ = ch;
}
xit:
@@ -1033,7 +1033,7 @@ Z4lAddEncoding(XF86VideoEncodingPtr enc, char *name, int id, int width,
cp = (char *)xalloc(n);
if (cp == NULL)
- return 0;
+ return 0;
sp = (t_std_data *) (cp + l);
enc->id = id;
@@ -1056,10 +1056,10 @@ Z4lNewImage(XF86ImagePtr * imgs, int *nimgs)
{
XF86ImagePtr img;
XF86ImagePtr timgs =
- (XF86ImagePtr) xrealloc(*imgs, sizeof(*timgs) * (*nimgs + 1));
+ (XF86ImagePtr) xrealloc(*imgs, sizeof(*timgs) * (*nimgs + 1));
if (timgs == NULL)
- return NULL;
+ return NULL;
*imgs = timgs;
img = &timgs[*nimgs];
@@ -1082,10 +1082,10 @@ Z4lNewAttribute(XF86AttributePtr * attrs, int *nattrs)
{
XF86AttributePtr attr;
XF86AttributePtr tattrs =
- (XF86AttributePtr) xrealloc(*attrs, sizeof(*tattrs) * (*nattrs + 1));
+ (XF86AttributePtr) xrealloc(*attrs, sizeof(*tattrs) * (*nattrs + 1));
if (tattrs == NULL)
- return NULL;
+ return NULL;
*attrs = tattrs;
attr = &tattrs[*nattrs];
@@ -1102,22 +1102,22 @@ Z4lAttributeName(char *bp, int l, char *cp)
char *atomNm = bp;
if (l > 0) {
- *bp++ = 'X';
- --l;
+ *bp++ = 'X';
+ --l;
}
if (l > 0) {
- *bp++ = 'V';
- --l;
+ *bp++ = 'V';
+ --l;
}
if (l > 0) {
- *bp++ = '_';
- --l;
+ *bp++ = '_';
+ --l;
}
while (l > 0 && (ch = *cp++) != 0) {
- if (isalnum(ch) == 0)
- continue;
- *bp++ = toupper(ch);
+ if (isalnum(ch) == 0)
+ continue;
+ *bp++ = toupper(ch);
}
*bp = 0;
@@ -1131,7 +1131,7 @@ Z4lAddAttribute(XF86AttributePtr attr, char *name,
char *cp = (char *)xalloc(strlen((char *)&name[0]) + 1);
if (cp == NULL)
- return 0;
+ return 0;
attr->name = cp;
strcpy(&attr->name[0], name);
@@ -1151,10 +1151,10 @@ Z4lNewAdaptor(XF86VideoAdaptorPtr ** adpts, int *nadpts, int nattrs)
XF86VideoAdaptorPtr adpt, *tadpts;
tadpts = (XF86VideoAdaptorPtr *) xrealloc(*adpts,
- sizeof(*tadpts) * (*nadpts + 1));
+ sizeof(*tadpts) * (*nadpts + 1));
if (tadpts == NULL)
- return NULL;
+ return NULL;
*adpts = tadpts;
n = sizeof(*adpt) + sizeof(*pPriv) + 1 * sizeof(*adpt->pPortPrivates);
@@ -1162,7 +1162,7 @@ Z4lNewAdaptor(XF86VideoAdaptorPtr ** adpts, int *nadpts, int nattrs)
adpt = (XF86VideoAdaptorPtr) xalloc(n);
if (adpt == NULL)
- return NULL;
+ return NULL;
memset(adpt, 0, n);
tadpts[*nadpts] = adpt;
@@ -1189,50 +1189,50 @@ Z4lSetPortAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 value,
int old_fd = pPriv->fd;
DBLOG(1, "Z4lSetPortAttribute(%#lx,%d) '%s'\n", (unsigned long)attribute,
- (int)value, name != NULL ? name : "_null_");
+ (int)value, name != NULL ? name : "_null_");
if (name == NULL)
- return BadImplementation;
+ return BadImplementation;
if (old_fd < 0 && z4l_open_device(pPriv) < 0)
- return BadAccess;
+ return BadAccess;
adpt = pPriv->adpt;
attr = adpt->pAttributes;
nattrs = adpt->nAttributes;
for (i = 0; i < nattrs; ++i, ++attr)
- if (strcmp(attr->name, name) == 0)
- break;
+ if (strcmp(attr->name, name) == 0)
+ break;
if (i >= nattrs)
- return BadMatch;
+ return BadMatch;
attrId = pPriv->attrIds[i];
val = value;
switch (attrId) {
case ATTR_ENCODING_ID:
- z4l_ovly_set_encoding(pPriv, val);
- break;
+ z4l_ovly_set_encoding(pPriv, val);
+ break;
case ATTR_KEYMODE_ID:
- z4l_ovly_set_keymode(pPriv, val);
- REGION_EMPTY(pScrni->pScreen, &pPriv->clips);
- z4l_setup_colorkey(pPriv, pScrni->pScreen, &pPriv->clips);
- break;
+ z4l_ovly_set_keymode(pPriv, val);
+ REGION_EMPTY(pScrni->pScreen, &pPriv->clips);
+ z4l_setup_colorkey(pPriv, pScrni->pScreen, &pPriv->clips);
+ break;
case ATTR_COLORKEY_ID:
- z4l_ovly_set_colorkey(pPriv, val);
- break;
+ z4l_ovly_set_colorkey(pPriv, val);
+ break;
default:
- memset(&ctrl, 0, sizeof(ctrl));
- ctrl.id = attrId + V4L2_CID_BASE;
- ctrl.value = val;
- if (IoCtl(pPriv->fd, VIDIOC_S_CTRL, &ctrl, 1) != 0)
- return BadMatch;
- break;
+ memset(&ctrl, 0, sizeof(ctrl));
+ ctrl.id = attrId + V4L2_CID_BASE;
+ ctrl.value = val;
+ if (IoCtl(pPriv->fd, VIDIOC_S_CTRL, &ctrl, 1) != 0)
+ return BadMatch;
+ break;
}
if (old_fd < 0)
- z4l_close_device(pPriv);
+ z4l_close_device(pPriv);
return Success;
}
@@ -1250,50 +1250,50 @@ Z4lGetPortAttribute(ScrnInfoPtr pScrni, Atom attribute, INT32 * value,
int old_fd = pPriv->fd;
DBLOG(1, "Z4lGetPortAttribute(%#lx) '%s'\n",
- (unsigned long)attribute, name != NULL ? name : "_null_");
+ (unsigned long)attribute, name != NULL ? name : "_null_");
if (name == NULL)
- return BadImplementation;
+ return BadImplementation;
if (old_fd < 0 && z4l_open_device(pPriv) < 0)
- return BadAccess;
+ return BadAccess;
adpt = pPriv->adpt;
attr = adpt->pAttributes;
nattrs = adpt->nAttributes;
for (i = 0; i < nattrs; ++i, ++attr)
- if (strcmp(attr->name, name) == 0)
- break;
+ if (strcmp(attr->name, name) == 0)
+ break;
if (i >= nattrs)
- return BadMatch;
+ return BadMatch;
attrId = pPriv->attrIds[i];
val = 0;
switch (attrId) {
case ATTR_ENCODING_ID:
- z4l_ovly_get_encoding(pPriv, &val);
- *value = val;
- break;
+ z4l_ovly_get_encoding(pPriv, &val);
+ *value = val;
+ break;
case ATTR_KEYMODE_ID:
- z4l_ovly_get_keymode(pPriv, &val);
- *value = val;
- break;
+ z4l_ovly_get_keymode(pPriv, &val);
+ *value = val;
+ break;
case ATTR_COLORKEY_ID:
- z4l_ovly_get_colorkey(pPriv, &val);
- break;
+ z4l_ovly_get_colorkey(pPriv, &val);
+ break;
default:
- memset(&ctrl, 0, sizeof(ctrl));
- ctrl.id = attrId + V4L2_CID_BASE;
- if (IoCtl(pPriv->fd, VIDIOC_G_CTRL, &ctrl, 1) != 0)
- return BadMatch;
- val = ctrl.value;
- break;
+ memset(&ctrl, 0, sizeof(ctrl));
+ ctrl.id = attrId + V4L2_CID_BASE;
+ if (IoCtl(pPriv->fd, VIDIOC_G_CTRL, &ctrl, 1) != 0)
+ return BadMatch;
+ val = ctrl.value;
+ break;
}
if (old_fd < 0)
- z4l_close_device(pPriv);
+ z4l_close_device(pPriv);
*value = val;
@@ -1316,14 +1316,14 @@ Z4lAdjustFrame(int scrnIndex, int x, int y, int flags)
/* xv adjust does not handle putvideo case */
for (i = 0; i < Z4l_nAdaptors; ++i) {
- adpt = Z4l_pAdaptors[i];
- pPriv = (Z4lPortPrivRec *) adpt->pPortPrivates[0].ptr;
- if (pPriv->run > 0) {
- pPriv->drw_is_set = 0;
- z4l_ovly_rect(pPriv,
- pPriv->src_x, pPriv->src_y, pPriv->src_w, pPriv->src_h,
- pPriv->drw_x, pPriv->drw_y, pPriv->drw_w, pPriv->drw_h);
- }
+ adpt = Z4l_pAdaptors[i];
+ pPriv = (Z4lPortPrivRec *) adpt->pPortPrivates[0].ptr;
+ if (pPriv->run > 0) {
+ pPriv->drw_is_set = 0;
+ z4l_ovly_rect(pPriv,
+ pPriv->src_x, pPriv->src_y, pPriv->src_w, pPriv->src_h,
+ pPriv->drw_x, pPriv->drw_y, pPriv->drw_w, pPriv->drw_h);
+ }
}
}
@@ -1354,8 +1354,8 @@ Z4lInit(ScrnInfoPtr pScrni, XF86VideoAdaptorPtr ** adaptors)
DBLOG(1, "Init\n");
if (oldAdjustFrame == NULL) {
- oldAdjustFrame = pScrni->AdjustFrame;
- pScrni->AdjustFrame = Z4lAdjustFrame;
+ oldAdjustFrame = pScrni->AdjustFrame;
+ pScrni->AdjustFrame = Z4lAdjustFrame;
}
fd = -1;
@@ -1374,254 +1374,254 @@ Z4lInit(ScrnInfoPtr pScrni, XF86VideoAdaptorPtr ** adaptors)
has_video = has_image = has_colorkey = 0;
for (dev = 0; z4l_dev_paths[dev] != NULL; ++dev) {
- fd = open(z4l_dev_paths[dev], O_RDWR, 0);
- if (fd < 0)
- continue;
- DBLOG(1, "%s open ok\n", z4l_dev_paths[dev]);
- msg = NULL;
- enable = 1;
- if (IoCtl(fd, VIDIOC_QUERYCAP, &capability, 1) < 0)
- msg = "bad querycap";
- else if ((capability.capabilities & V4L2_CAP_VIDEO_OVERLAY) == 0)
- msg = "no overlay";
- else if ((capability.capabilities & V4L2_CAP_STREAMING) == 0)
- msg = "no streaming";
+ fd = open(z4l_dev_paths[dev], O_RDWR, 0);
+ if (fd < 0)
+ continue;
+ DBLOG(1, "%s open ok\n", z4l_dev_paths[dev]);
+ msg = NULL;
+ enable = 1;
+ if (IoCtl(fd, VIDIOC_QUERYCAP, &capability, 1) < 0)
+ msg = "bad querycap";
+ else if ((capability.capabilities & V4L2_CAP_VIDEO_OVERLAY) == 0)
+ msg = "no overlay";
+ else if ((capability.capabilities & V4L2_CAP_STREAMING) == 0)
+ msg = "no streaming";
#ifdef NONBLK_IO
- else if (IoCtl(fd, FIONBIO, &enable, 1) != 0)
- msg = "cant enable non-blocking io";
+ else if (IoCtl(fd, FIONBIO, &enable, 1) != 0)
+ msg = "cant enable non-blocking io";
#endif
- if (msg == NULL) {
- memset(&format, 0, sizeof(format));
- format.type = 0x100;
- if (IoCtl(fd, VIDIOC_G_FMT, &format, 1) != 0)
- msg = "no src/dst ovly fmt";
- }
- if (msg != NULL) {
- DBLOG(0, "%s %s\n", z4l_dev_paths[dev], msg);
- close(fd);
- continue;
- }
-
- memset(&cfmt, 0, sizeof(cfmt));
- cfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (IoCtl(fd, VIDIOC_G_FMT, &cfmt, 1) < 0)
- goto fail;
- if (IoCtl(fd, VIDIOC_G_STD, &cstd_id, 1) < 0)
- goto fail;
- if (IoCtl(fd, VIDIOC_G_INPUT, &cinp, 1) < 0)
- goto fail;
- cpixfmt = cfmt.fmt.pix.pixelformat;
- cenc = 0;
- for (inp = 0;; ++inp) {
- memset(&input, 0, sizeof(input));
- input.index = inp;
- if (IoCtl(fd, VIDIOC_ENUMINPUT, &input, 0) < 0)
- break;
- id = inp;
- if (IoCtl(fd, VIDIOC_S_INPUT, &id, 1) < 0)
- goto fail;
- for (std = 0;; ++std) {
- memset(&standard, 0, sizeof(standard));
- standard.index = std;
- if (IoCtl(fd, VIDIOC_ENUMSTD, &standard, 0) < 0)
- break;
- std_id = standard.id;
- denom = standard.frameperiod.denominator;
- numer = standard.frameperiod.numerator;
- if (IoCtl(fd, VIDIOC_S_STD, &std_id, 1) < 0)
- continue;
- memset(&format, 0, sizeof(format));
- format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (IoCtl(fd, VIDIOC_G_FMT, &format, 1) < 0)
- continue;
- width = format.fmt.pix.width;
- height = format.fmt.pix.height;
- for (fmt = 0;; ++fmt) {
- memset(&fmtdesc, 0, sizeof(fmtdesc));
- fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- fmtdesc.index = fmt;
- if (IoCtl(fd, VIDIOC_ENUM_FMT, &fmtdesc, 0) < 0)
- break;
- pixfmt = fmtdesc.pixelformat;
- ip = &pixfmts[0];
- for (i = sizeof(pixfmts) / sizeof(pixfmts[0]); --i >= 0;
- ++ip)
- if (z4l_fourcc_pixfmt(ip->id) == pixfmt)
- break;
-
- if (i >= 0) {
- id = nencs;
- has_video = 1;
- if ((enc = Z4lNewEncoding(&encs, &nencs)) == NULL)
- goto fail;
- Z4lEncodingName(&enc_name[0], sizeof(enc_name),
- (char *)&input.name[0],
- (char *)&standard.name[0], (char *)&pixfmt);
- if (Z4lAddEncoding(enc, &enc_name[0], id, width,
- height, denom, numer, inp, std_id,
- pixfmt) == 0)
- goto fail;
- if (std_id == cstd_id && inp == cinp
- && pixfmt == cpixfmt)
- cenc = id;
- }
- }
- }
- }
-
- if (IoCtl(fd, VIDIOC_S_INPUT, &cinp, 1) < 0)
- goto fail;
- if (IoCtl(fd, VIDIOC_S_STD, &cstd_id, 1) < 0)
- goto fail;
- if (IoCtl(fd, VIDIOC_S_FMT, &cfmt, 1) < 0)
- goto fail;
-
- if (encs == NULL) {
- DBLOG(0, "no encodings\n");
- goto fail;
- }
-
- for (fmt = 0;; ++fmt) {
- memset(&fmtdesc, 0, sizeof(fmtdesc));
- fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
- fmtdesc.index = fmt;
- if (IoCtl(fd, VIDIOC_ENUM_FMT, &fmtdesc, 0) < 0)
- break;
- pixfmt = fmtdesc.pixelformat;
- ip = &pixfmts[0];
- for (i = sizeof(pixfmts) / sizeof(pixfmts[0]); --i >= 0; ++ip)
- if (z4l_fourcc_pixfmt(ip->id) == pixfmt)
- break;
-
- if (i >= 0) {
- has_image = 1;
- if ((img = Z4lNewImage(&imgs, &nimgs)) == NULL)
- goto fail;
- if (Z4lAddImage(img, ip) == 0)
- goto fail;
- }
- }
-
- if (nimgs > 0) {
- id = nencs;
- if ((enc = Z4lNewEncoding(&encs, &nencs)) == NULL)
- goto fail;
- if (Z4lAddEncoding(enc, "XV_IMAGE", id, MAX_OVLY_WIDTH,
- MAX_OVLY_HEIGHT, 0, 0, 0, 0, pixfmt) == 0)
- goto fail;
- }
-
- ctl = 0;
- for (ctl = 0; ctl < (V4L2_CID_LASTP1 - V4L2_CID_BASE); ++ctl) {
- memset(&queryctrl, 0, sizeof(queryctrl));
- queryctrl.id = V4L2_CID_BASE + ctl;
- if (IoCtl(fd, VIDIOC_QUERYCTRL, &queryctrl, 0) < 0)
- continue;
- if (queryctrl.type != V4L2_CTRL_TYPE_INTEGER &&
- queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN)
- continue;
- attrIds[nattrs] = ctl;
- if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL)
- goto fail;
- Z4lAttributeName(&attr_name[0], sizeof(attr_name),
- (char *)&queryctrl.name[0]);
- if (Z4lAddAttribute(attr, &attr_name[0],
- queryctrl.minimum, queryctrl.maximum,
- XvSettable | XvGettable) == 0)
- goto fail;
- }
- attrIds[nattrs] = ATTR_ENCODING_ID;
- if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL)
- goto fail;
- Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_ENCODING);
- if (Z4lAddAttribute(attr, &attr_name[0], 0, nencs - 1,
- XvSettable | XvGettable) == 0)
- goto fail;
- memset(&fbuf, 0, sizeof(fbuf));
- if (IoCtl(fd, VIDIOC_G_FBUF, &fbuf, 1) < 0)
- goto fail;
- opixfmt = fbuf.fmt.pixelformat;
-
- if ((fbuf.capability & V4L2_FBUF_CAP_CHROMAKEY) != 0) {
- attrIds[nattrs] = ATTR_KEYMODE_ID;
- if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL)
- goto fail;
- Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_KEYMODE);
- if (Z4lAddAttribute(attr, &attr_name[0], 0, 1,
- XvSettable | XvGettable) == 0)
- goto fail;
- attrIds[nattrs] = ATTR_COLORKEY_ID;
- if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL)
- goto fail;
- Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_COLORKEY);
- if (Z4lAddAttribute(attr, &attr_name[0], 0, 0xffffff,
- XvSettable | XvGettable) == 0)
- goto fail;
- has_colorkey = 1;
- }
-
- dp = xalloc(strlen((char *)&capability.card[0]) + 1);
- if (dp == NULL)
- goto fail;
- strcpy(dp, (char *)&capability.card[0]);
- if ((adpt = Z4lNewAdaptor(&adpts, &nadpts, nattrs)) == NULL)
- goto fail;
- adpt->type = XvWindowMask | XvInputMask;
- if (has_video != 0)
- adpt->type |= XvVideoMask;
- if (has_image != 0)
- adpt->type |= XvImageMask;
- adpt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
- adpt->name = dp;
- adpt->type = XvInputMask | XvWindowMask | XvVideoMask | XvImageMask;
- adpt->pEncodings = encs;
- adpt->nEncodings = nencs;
- adpt->pFormats = &Formats[0];
- adpt->nFormats = sizeof(Formats) / sizeof(Formats[0]);
- adpt->pAttributes = attrs;
- adpt->nAttributes = nattrs;
- attrs = NULL;
- nattrs = 0;
- adpt->pImages = imgs;
- adpt->nImages = nimgs;
- imgs = NULL;
- nimgs = 0;
- adpt->PutVideo = Z4lPutVideo;
- adpt->StopVideo = Z4lStopVideo;
- adpt->SetPortAttribute = Z4lSetPortAttribute;
- adpt->GetPortAttribute = Z4lGetPortAttribute;
- adpt->QueryBestSize = Z4lQueryBestSize;
- adpt->PutImage = Z4lPutImage;
- adpt->QueryImageAttributes = Z4lQueryImageAttributes;
- pPriv = (Z4lPortPrivRec *) adpt->pPortPrivates[0].ptr;
- pPriv->fd = fd;
- pPriv->run = -1;
- pPriv->dir = 0;
- pPriv->nbfrs = -1;
- pPriv->bufsz = -1;
- pPriv->last = -1;
- pPriv->pixfmt = opixfmt;
+ if (msg == NULL) {
+ memset(&format, 0, sizeof(format));
+ format.type = 0x100;
+ if (IoCtl(fd, VIDIOC_G_FMT, &format, 1) != 0)
+ msg = "no src/dst ovly fmt";
+ }
+ if (msg != NULL) {
+ DBLOG(0, "%s %s\n", z4l_dev_paths[dev], msg);
+ close(fd);
+ continue;
+ }
+
+ memset(&cfmt, 0, sizeof(cfmt));
+ cfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (IoCtl(fd, VIDIOC_G_FMT, &cfmt, 1) < 0)
+ goto fail;
+ if (IoCtl(fd, VIDIOC_G_STD, &cstd_id, 1) < 0)
+ goto fail;
+ if (IoCtl(fd, VIDIOC_G_INPUT, &cinp, 1) < 0)
+ goto fail;
+ cpixfmt = cfmt.fmt.pix.pixelformat;
+ cenc = 0;
+ for (inp = 0;; ++inp) {
+ memset(&input, 0, sizeof(input));
+ input.index = inp;
+ if (IoCtl(fd, VIDIOC_ENUMINPUT, &input, 0) < 0)
+ break;
+ id = inp;
+ if (IoCtl(fd, VIDIOC_S_INPUT, &id, 1) < 0)
+ goto fail;
+ for (std = 0;; ++std) {
+ memset(&standard, 0, sizeof(standard));
+ standard.index = std;
+ if (IoCtl(fd, VIDIOC_ENUMSTD, &standard, 0) < 0)
+ break;
+ std_id = standard.id;
+ denom = standard.frameperiod.denominator;
+ numer = standard.frameperiod.numerator;
+ if (IoCtl(fd, VIDIOC_S_STD, &std_id, 1) < 0)
+ continue;
+ memset(&format, 0, sizeof(format));
+ format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (IoCtl(fd, VIDIOC_G_FMT, &format, 1) < 0)
+ continue;
+ width = format.fmt.pix.width;
+ height = format.fmt.pix.height;
+ for (fmt = 0;; ++fmt) {
+ memset(&fmtdesc, 0, sizeof(fmtdesc));
+ fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmtdesc.index = fmt;
+ if (IoCtl(fd, VIDIOC_ENUM_FMT, &fmtdesc, 0) < 0)
+ break;
+ pixfmt = fmtdesc.pixelformat;
+ ip = &pixfmts[0];
+ for (i = sizeof(pixfmts) / sizeof(pixfmts[0]); --i >= 0;
+ ++ip)
+ if (z4l_fourcc_pixfmt(ip->id) == pixfmt)
+ break;
+
+ if (i >= 0) {
+ id = nencs;
+ has_video = 1;
+ if ((enc = Z4lNewEncoding(&encs, &nencs)) == NULL)
+ goto fail;
+ Z4lEncodingName(&enc_name[0], sizeof(enc_name),
+ (char *)&input.name[0],
+ (char *)&standard.name[0], (char *)&pixfmt);
+ if (Z4lAddEncoding(enc, &enc_name[0], id, width,
+ height, denom, numer, inp, std_id,
+ pixfmt) == 0)
+ goto fail;
+ if (std_id == cstd_id && inp == cinp
+ && pixfmt == cpixfmt)
+ cenc = id;
+ }
+ }
+ }
+ }
+
+ if (IoCtl(fd, VIDIOC_S_INPUT, &cinp, 1) < 0)
+ goto fail;
+ if (IoCtl(fd, VIDIOC_S_STD, &cstd_id, 1) < 0)
+ goto fail;
+ if (IoCtl(fd, VIDIOC_S_FMT, &cfmt, 1) < 0)
+ goto fail;
+
+ if (encs == NULL) {
+ DBLOG(0, "no encodings\n");
+ goto fail;
+ }
+
+ for (fmt = 0;; ++fmt) {
+ memset(&fmtdesc, 0, sizeof(fmtdesc));
+ fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ fmtdesc.index = fmt;
+ if (IoCtl(fd, VIDIOC_ENUM_FMT, &fmtdesc, 0) < 0)
+ break;
+ pixfmt = fmtdesc.pixelformat;
+ ip = &pixfmts[0];
+ for (i = sizeof(pixfmts) / sizeof(pixfmts[0]); --i >= 0; ++ip)
+ if (z4l_fourcc_pixfmt(ip->id) == pixfmt)
+ break;
+
+ if (i >= 0) {
+ has_image = 1;
+ if ((img = Z4lNewImage(&imgs, &nimgs)) == NULL)
+ goto fail;
+ if (Z4lAddImage(img, ip) == 0)
+ goto fail;
+ }
+ }
+
+ if (nimgs > 0) {
+ id = nencs;
+ if ((enc = Z4lNewEncoding(&encs, &nencs)) == NULL)
+ goto fail;
+ if (Z4lAddEncoding(enc, "XV_IMAGE", id, MAX_OVLY_WIDTH,
+ MAX_OVLY_HEIGHT, 0, 0, 0, 0, pixfmt) == 0)
+ goto fail;
+ }
+
+ ctl = 0;
+ for (ctl = 0; ctl < (V4L2_CID_LASTP1 - V4L2_CID_BASE); ++ctl) {
+ memset(&queryctrl, 0, sizeof(queryctrl));
+ queryctrl.id = V4L2_CID_BASE + ctl;
+ if (IoCtl(fd, VIDIOC_QUERYCTRL, &queryctrl, 0) < 0)
+ continue;
+ if (queryctrl.type != V4L2_CTRL_TYPE_INTEGER &&
+ queryctrl.type != V4L2_CTRL_TYPE_BOOLEAN)
+ continue;
+ attrIds[nattrs] = ctl;
+ if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL)
+ goto fail;
+ Z4lAttributeName(&attr_name[0], sizeof(attr_name),
+ (char *)&queryctrl.name[0]);
+ if (Z4lAddAttribute(attr, &attr_name[0],
+ queryctrl.minimum, queryctrl.maximum,
+ XvSettable | XvGettable) == 0)
+ goto fail;
+ }
+ attrIds[nattrs] = ATTR_ENCODING_ID;
+ if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL)
+ goto fail;
+ Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_ENCODING);
+ if (Z4lAddAttribute(attr, &attr_name[0], 0, nencs - 1,
+ XvSettable | XvGettable) == 0)
+ goto fail;
+ memset(&fbuf, 0, sizeof(fbuf));
+ if (IoCtl(fd, VIDIOC_G_FBUF, &fbuf, 1) < 0)
+ goto fail;
+ opixfmt = fbuf.fmt.pixelformat;
+
+ if ((fbuf.capability & V4L2_FBUF_CAP_CHROMAKEY) != 0) {
+ attrIds[nattrs] = ATTR_KEYMODE_ID;
+ if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL)
+ goto fail;
+ Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_KEYMODE);
+ if (Z4lAddAttribute(attr, &attr_name[0], 0, 1,
+ XvSettable | XvGettable) == 0)
+ goto fail;
+ attrIds[nattrs] = ATTR_COLORKEY_ID;
+ if ((attr = Z4lNewAttribute(&attrs, &nattrs)) == NULL)
+ goto fail;
+ Z4lAttributeName(&attr_name[0], sizeof(attr_name), ATTR_COLORKEY);
+ if (Z4lAddAttribute(attr, &attr_name[0], 0, 0xffffff,
+ XvSettable | XvGettable) == 0)
+ goto fail;
+ has_colorkey = 1;
+ }
+
+ dp = xalloc(strlen((char *)&capability.card[0]) + 1);
+ if (dp == NULL)
+ goto fail;
+ strcpy(dp, (char *)&capability.card[0]);
+ if ((adpt = Z4lNewAdaptor(&adpts, &nadpts, nattrs)) == NULL)
+ goto fail;
+ adpt->type = XvWindowMask | XvInputMask;
+ if (has_video != 0)
+ adpt->type |= XvVideoMask;
+ if (has_image != 0)
+ adpt->type |= XvImageMask;
+ adpt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ adpt->name = dp;
+ adpt->type = XvInputMask | XvWindowMask | XvVideoMask | XvImageMask;
+ adpt->pEncodings = encs;
+ adpt->nEncodings = nencs;
+ adpt->pFormats = &Formats[0];
+ adpt->nFormats = sizeof(Formats) / sizeof(Formats[0]);
+ adpt->pAttributes = attrs;
+ adpt->nAttributes = nattrs;
+ attrs = NULL;
+ nattrs = 0;
+ adpt->pImages = imgs;
+ adpt->nImages = nimgs;
+ imgs = NULL;
+ nimgs = 0;
+ adpt->PutVideo = Z4lPutVideo;
+ adpt->StopVideo = Z4lStopVideo;
+ adpt->SetPortAttribute = Z4lSetPortAttribute;
+ adpt->GetPortAttribute = Z4lGetPortAttribute;
+ adpt->QueryBestSize = Z4lQueryBestSize;
+ adpt->PutImage = Z4lPutImage;
+ adpt->QueryImageAttributes = Z4lQueryImageAttributes;
+ pPriv = (Z4lPortPrivRec *) adpt->pPortPrivates[0].ptr;
+ pPriv->fd = fd;
+ pPriv->run = -1;
+ pPriv->dir = 0;
+ pPriv->nbfrs = -1;
+ pPriv->bufsz = -1;
+ pPriv->last = -1;
+ pPriv->pixfmt = opixfmt;
#if defined(REGION_NULL)
- REGION_NULL(pScrni->pScreen, &pPriv->clips);
+ REGION_NULL(pScrni->pScreen, &pPriv->clips);
#else
- REGION_INIT(pScrni->pScreen, &pPriv->clips, NullBox, 0);
+ REGION_INIT(pScrni->pScreen, &pPriv->clips, NullBox, 0);
#endif
- strncpy(&pPriv->dev_path[0], z4l_dev_paths[dev],
- sizeof(pPriv->dev_path));
- pPriv->enc = &encs[cenc];
- for (i = 0; i < adpt->nAttributes; ++i)
- pPriv->attrIds[i] = attrIds[i];
- DBLOG(1, "adpt %s\n", dp);
- if (has_colorkey != 0) {
- z4l_ovly_set_colorkey(pPriv, DEFAULT_COLORKEY);
- z4l_ovly_set_keymode(pPriv, DEFAULT_KEYMODE);
- }
- close(fd);
- pPriv->fd = -1;
- adpt = NULL;
- cenc = 0;
- encs = NULL;
- nencs = 0;
+ strncpy(&pPriv->dev_path[0], z4l_dev_paths[dev],
+ sizeof(pPriv->dev_path));
+ pPriv->enc = &encs[cenc];
+ for (i = 0; i < adpt->nAttributes; ++i)
+ pPriv->attrIds[i] = attrIds[i];
+ DBLOG(1, "adpt %s\n", dp);
+ if (has_colorkey != 0) {
+ z4l_ovly_set_colorkey(pPriv, DEFAULT_COLORKEY);
+ z4l_ovly_set_keymode(pPriv, DEFAULT_KEYMODE);
+ }
+ close(fd);
+ pPriv->fd = -1;
+ adpt = NULL;
+ cenc = 0;
+ encs = NULL;
+ nencs = 0;
}
DBLOG(0, "init done, %d device(s) found\n", nadpts);
@@ -1633,50 +1633,50 @@ Z4lInit(ScrnInfoPtr pScrni, XF86VideoAdaptorPtr ** adaptors)
fail:
if (attrs != NULL) {
- for (i = 0; i < nattrs; ++i)
- if (attrs[i].name != NULL)
- free(attrs[i].name);
- free(attrs);
+ for (i = 0; i < nattrs; ++i)
+ if (attrs[i].name != NULL)
+ free(attrs[i].name);
+ free(attrs);
}
if (encs != NULL) {
- for (i = 0; i < nencs; ++i) {
- if (encs[i].name != NULL)
- free(encs[i].name);
- }
- free(encs);
+ for (i = 0; i < nencs; ++i) {
+ if (encs[i].name != NULL)
+ free(encs[i].name);
+ }
+ free(encs);
}
if (imgs != NULL)
- free(imgs);
+ free(imgs);
if (adpts != NULL) {
- for (i = 0; i < nadpts; ++i) {
- if ((adpt = adpts[i]) != NULL) {
- if (adpt->name != NULL)
- free(adpt->name);
- if ((attrs = adpt->pAttributes) != NULL) {
- for (i = 0; i < adpt->nAttributes; ++i)
- if (attrs[i].name != NULL)
- free(attrs[i].name);
- free(attrs);
- }
- if ((encs = adpt->pEncodings) != NULL) {
- for (i = 0; i < adpt->nEncodings; ++i, ++enc)
- if (encs[i].name != NULL)
- free(encs[i].name);
- free(encs);
- }
- if ((imgs = adpt->pImages) != NULL)
- free(imgs);
- xfree(adpt);
- }
- }
- free(adpts);
+ for (i = 0; i < nadpts; ++i) {
+ if ((adpt = adpts[i]) != NULL) {
+ if (adpt->name != NULL)
+ free(adpt->name);
+ if ((attrs = adpt->pAttributes) != NULL) {
+ for (i = 0; i < adpt->nAttributes; ++i)
+ if (attrs[i].name != NULL)
+ free(attrs[i].name);
+ free(attrs);
+ }
+ if ((encs = adpt->pEncodings) != NULL) {
+ for (i = 0; i < adpt->nEncodings; ++i, ++enc)
+ if (encs[i].name != NULL)
+ free(encs[i].name);
+ free(encs);
+ }
+ if ((imgs = adpt->pImages) != NULL)
+ free(imgs);
+ xfree(adpt);
+ }
+ }
+ free(adpts);
}
if (fd >= 0)
- close(fd);
+ close(fd);
return 0;
}
@@ -1686,7 +1686,7 @@ Z4lProbe(DriverPtr drv, int flags)
{
DBLOG(1, "Probe\n");
if (flags & PROBE_DETECT)
- return TRUE;
+ return TRUE;
xf86XVRegisterGenericAdaptorDriver(Z4lInit);
drv->refCount++;
@@ -1737,21 +1737,21 @@ z4lSetup(pointer module, pointer opts, int *errmaj, int *errmin)
static Bool setupDone = FALSE;
if (setupDone != FALSE) {
- if (errmaj != NULL)
- *errmaj = LDR_ONCEONLY;
- return NULL;
+ if (errmaj != NULL)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
}
setupDone = TRUE;
LoaderGetOS(&osname, NULL, NULL, NULL);
if (osname == NULL || strcmp(osname, "linux") != 0) {
- if (errmaj)
- *errmaj = LDR_BADOS;
- if (errmin)
- *errmin = 0;
+ if (errmaj)
+ *errmaj = LDR_BADOS;
+ if (errmin)
+ *errmin = 0;
- return NULL;
+ return NULL;
}
xf86AddDriver(&Z4l, module, 0);