diff options
author | Martin-Éric Racine <martin-eric.racine@iki.fi> | 2012-07-11 15:45:24 +0300 |
---|---|---|
committer | Martin-Éric Racine <martin-eric.racine@iki.fi> | 2012-07-11 15:45:24 +0300 |
commit | 921635f34aa4be45a5efbb8d8b11e2e295b2b46c (patch) | |
tree | 5ce30b158059d4828021c21332ee148caebd3697 | |
parent | 1a658ae0d991d38956466a0174dd9de543d9cd2d (diff) |
Whitespace cleanup using ../modular/x-indent.sh
78 files changed, 28573 insertions, 28604 deletions
diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 9095e7b..0000000 --- a/ChangeLog +++ /dev/null @@ -1,84 +0,0 @@ -2006-04-07 Adam Jackson <ajax@freedesktop.org> - - * configure.ac: - * src/nsc_driver.c: - Bump to 2.8.1 for Xv changes. - -2006-04-07 Aaron Plattner <aplattner@nvidia.com> - - * src/nsc_gx1_video.c: (GX1PutImage): - * src/nsc_gx2_video.c: (GX2PutImage): - Add a DrawablePtr argument to the XV functions to pave the way for - redirected video. - -2006-04-07 Adam Jackson <ajax@freedesktop.org> - - * configure.ac: - * src/durango.c: - * src/nsc.h: - * src/nsc_driver.c: - * src/nsc_galstub.c: - * src/nsc_gx1_accel.c: - * src/nsc_gx1_cursor.c: - * src/nsc_gx1_dga.c: - * src/nsc_gx1_driver.c: - * src/nsc_gx1_shadow.c: - * src/nsc_gx1_video.c: - * src/nsc_gx2_accel.c: - * src/nsc_gx2_cursor.c: - * src/nsc_gx2_dga.c: - * src/nsc_gx2_driver.c: - * src/nsc_gx2_shadow.c: - * src/nsc_gx2_video.c: - Unlibcwrap. Bump server version requirement. Bump to 2.8.0. - -2006-02-27 Alan Coopersmith <alan.coopersmith@sun.com> - - * man/nsc.man: - Typo fix (Nicholas Joly, XFree86 bugzilla #1658) - -2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org> - - * configure.ac: - Update package version for X11R7 release. - -2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org> - - * configure.ac: - Update package version number for final X11R7 release candidate. - -2005-12-06 Kevin E. Martin <kem-at-freedesktop-dot-org> - - * man/Makefile.am: - Change *man_SOURCES ==> *man_PRE to fix autotools warnings. - -2005-12-03 Kevin E. Martin <kem-at-freedesktop-dot-org> - - * configure.ac: - Update package version number for X11R7 RC3 release. - -2005-12-01 Kevin E. Martin <kem-at-freedesktop-dot-org> - - * configure.ac: - Remove extraneous AC_MSG_RESULT. - -2005-11-29 Adam Jackson <ajax@freedesktop.org> - - * configure.ac: - Only build dlloader modules by default. - -2005-11-15 Kevin E. Martin <kem-at-freedesktop-dot-org> - - * configure.ac: - Add check for DGA extension to fix issues when building with - separate build roots. - -2005-11-09 Kevin E. Martin <kem-at-freedesktop-dot-org> - - * configure.ac: - Update package version number for X11R7 RC2 release. - -2005-11-01 Kevin E. Martin <kem-at-freedesktop-dot-org> - - * configure.ac: - Update pkgcheck dependencies to work with separate build roots. diff --git a/src/assyntax.h b/src/assyntax.h index 718312c..dcee42e 100644 --- a/src/assyntax.h +++ b/src/assyntax.h @@ -50,48 +50,48 @@ */ /* - * assyntax.h - * - * Select the syntax appropriate to the 386 assembler being used - * To add support for more assemblers add more columns to the CHOICE - * macro. Note that register names must also have uppercase names - * to avoid macro recursion. e.g., #define ah %ah recurses! - * - * NB 1. Some of the macros for certain assemblers imply that the code is to - * run in protected mode!! Caveat emptor. - * - * NB 2. 486 specific instructions are not included. This is to discourage - * their accidental use in code that is intended to run on 386 and 486 - * systems. - * - * Supported assemblers: - * - * (a) AT&T SysVr4 as(1): default - * (b) GNU Assembler gas: define USE_GAS or GNU_ASSEMBLER - * (c) Amsterdam Compiler kit: define ACK_ASSEMBLER - * - * The following naming conventions have been used to identify the various - * data types: - * _SR = segment register version - * Integer: - * _Q = quadword = 64 bits - * _L = long = 32 bits - * _W = short = 16 bits - * _B = byte = 8 bits - * Floating-point: - * _X = m80real = 80 bits - * _D = double = 64 bits - * _S = single = 32 bits - * - * Author: Gregory J. Sharp, Sept 1992 - * Vrije Universiteit, Amsterdam, The Netherlands - */ + * assyntax.h + * + * Select the syntax appropriate to the 386 assembler being used + * To add support for more assemblers add more columns to the CHOICE + * macro. Note that register names must also have uppercase names + * to avoid macro recursion. e.g., #define ah %ah recurses! + * + * NB 1. Some of the macros for certain assemblers imply that the code is to + * run in protected mode!! Caveat emptor. + * + * NB 2. 486 specific instructions are not included. This is to discourage + * their accidental use in code that is intended to run on 386 and 486 + * systems. + * + * Supported assemblers: + * + * (a) AT&T SysVr4 as(1): default + * (b) GNU Assembler gas: define USE_GAS or GNU_ASSEMBLER + * (c) Amsterdam Compiler kit: define ACK_ASSEMBLER + * + * The following naming conventions have been used to identify the various + * data types: + * _SR = segment register version + * Integer: + * _Q = quadword = 64 bits + * _L = long = 32 bits + * _W = short = 16 bits + * _B = byte = 8 bits + * Floating-point: + * _X = m80real = 80 bits + * _D = double = 64 bits + * _S = single = 32 bits + * + * Author: Gregory J. Sharp, Sept 1992 + * Vrije Universiteit, Amsterdam, The Netherlands + */ #if defined(USE_GAS) && !defined(GNU_ASSEMBLER) #define GNU_ASSEMBLER #endif -#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__)) +#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__)) #define CONCAT(x, y) x ## y #else #define CONCAT(x, y) x/**/y @@ -151,9 +151,8 @@ #define AS_BEGIN .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text - -#define _WTOG o16 /* word toggle for _W instructions */ -#define _LTOG /* long toggle for _L instructions */ +#define _WTOG o16 /* word toggle for _W instructions */ +#define _LTOG /* long toggle for _L instructions */ #define ADDR_TOGGLE a16 #define OPSZ_TOGGLE o16 #define USE16 .use16 @@ -161,7 +160,7 @@ #define CHOICE(a,b,c) c -#else /* AT&T or GAS */ +#else /* AT&T or GAS */ /* Redefine register names for GAS & AT&T assemblers */ #define AL %al @@ -232,9 +231,8 @@ #define ADDR_TOGGLE addr16 #define OPSZ_TOGGLE data16 -#endif /* GNU_ASSEMBLER */ -#endif /* ACK_ASSEMBLER */ - +#endif /* GNU_ASSEMBLER */ +#endif /* ACK_ASSEMBLER */ #if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) #define GLNAME(a) a @@ -242,13 +240,11 @@ #define GLNAME(a) CONCAT(_,a) #endif - - /****************************************/ - /* */ - /* Select the various choices */ - /* */ - /****************************************/ - + /****************************************/ + /* */ + /* Select the various choices */ + /* */ + /****************************************/ /* Redefine assembler directives */ /*********************************/ @@ -284,8 +280,8 @@ #define CONST(a) CHOICE(CONCAT($,a), CONCAT($,a), a) /* Indirect Mode */ -#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */ -#define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */ +#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */ +#define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */ /* Register b indirect plus displacement a */ #define REGOFF(a, b) CHOICE(a(b), a(b), a(b)) /* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode @@ -629,7 +625,6 @@ #define XOR_W(a, b) CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a)) #define XOR_B(a, b) CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a)) - /* Floating Point Instructions */ #define F2XM1 CHOICE(f2xm1, f2xm1, f2xm1) #define FABS CHOICE(fabs, fabs, fabs) @@ -681,7 +676,7 @@ #define FISTP_Q(a) CHOICE(fistpll a, fistpq a, fistpq a) #define FISTP_L(a) CHOICE(fistpl a, fistpl a, fistpl a) #define FISTP_W(a) CHOICE(fistp a, fistps a, fistps a) -#define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */ +#define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */ #define FLD_D(a) CHOICE(fldl a, fldl a, fldd a) #define FLD_S(a) CHOICE(flds a, flds a, flds a) #define FLD1 CHOICE(fld1, fld1, fld1) @@ -746,4 +741,4 @@ #define FYL2X CHOICE(fyl2x, fyl2x, fyl2x) #define FYL2XP1 CHOICE(fyl2xp1, fyl2xp1, fyl2xp1) -#endif /* __ASSYNTAX_H__ */ +#endif /* __ASSYNTAX_H__ */ diff --git a/src/durango.c b/src/durango.c index 12f3b46..9e9a969 100644 --- a/src/durango.c +++ b/src/durango.c @@ -157,59 +157,59 @@ #include "config.h" #endif -#define GFX_DISPLAY_DYNAMIC 1 /* runtime selection */ -#define GFX_DISPLAY_GU1 1 /* 1st generation display controller */ -#define GFX_DISPLAY_GU2 1 /* 2nd generation display controller */ +#define GFX_DISPLAY_DYNAMIC 1 /* runtime selection */ +#define GFX_DISPLAY_GU1 1 /* 1st generation display controller */ +#define GFX_DISPLAY_GU2 1 /* 2nd generation display controller */ -#define GFX_INIT_DYNAMIC 1 /* runtime selection */ -#define GFX_INIT_GU1 1 /* Geode family */ -#define GFX_INIT_GU2 1 /* Redcloud */ +#define GFX_INIT_DYNAMIC 1 /* runtime selection */ +#define GFX_INIT_GU1 1 /* Geode family */ +#define GFX_INIT_GU2 1 /* Redcloud */ -#define GFX_MSR_DYNAMIC 1 /* runtime selection */ -#define GFX_MSR_REDCLOUD 1 /* Redcloud */ +#define GFX_MSR_DYNAMIC 1 /* runtime selection */ +#define GFX_MSR_REDCLOUD 1 /* Redcloud */ -#define GFX_2DACCEL_DYNAMIC 1 /* runtime selection */ -#define GFX_2DACCEL_GU1 1 /* 1st generation 2D accelerator */ -#define GFX_2DACCEL_GU2 1 /* 2nd generation 2D accelerator */ +#define GFX_2DACCEL_DYNAMIC 1 /* runtime selection */ +#define GFX_2DACCEL_GU1 1 /* 1st generation 2D accelerator */ +#define GFX_2DACCEL_GU2 1 /* 2nd generation 2D accelerator */ -#define GFX_VIDEO_DYNAMIC 1 /* runtime selection */ -#define GFX_VIDEO_CS5530 1 /* support for CS5530 */ -#define GFX_VIDEO_SC1200 1 /* support for SC1200 */ -#define GFX_VIDEO_REDCLOUD 1 /* support for Redcloud */ +#define GFX_VIDEO_DYNAMIC 1 /* runtime selection */ +#define GFX_VIDEO_CS5530 1 /* support for CS5530 */ +#define GFX_VIDEO_SC1200 1 /* support for SC1200 */ +#define GFX_VIDEO_REDCLOUD 1 /* support for Redcloud */ -#define GFX_VIP_DYNAMIC 1 /* runtime selection */ -#define GFX_VIP_SC1200 1 /* support for SC1200 */ +#define GFX_VIP_DYNAMIC 1 /* runtime selection */ +#define GFX_VIP_SC1200 1 /* support for SC1200 */ -#define GFX_DECODER_DYNAMIC 1 /* runtime selection */ -#define GFX_DECODER_SAA7114 1 /* Philips SAA7114 decoder */ +#define GFX_DECODER_DYNAMIC 1 /* runtime selection */ +#define GFX_DECODER_SAA7114 1 /* Philips SAA7114 decoder */ -#define GFX_TV_DYNAMIC 1 /* runtime selection */ -#define GFX_TV_FS451 0 /* Focus Enhancements FS450 */ -#define GFX_TV_SC1200 1 /* SC1200 integrated TV encoder */ +#define GFX_TV_DYNAMIC 1 /* runtime selection */ +#define GFX_TV_FS451 0 /* Focus Enhancements FS450 */ +#define GFX_TV_SC1200 1 /* SC1200 integrated TV encoder */ -#define GFX_I2C_DYNAMIC 1 /* runtime selection */ -#define GFX_I2C_ACCESS 1 /* support for ACCESS.BUS */ -#define GFX_I2C_GPIO 1 /* support for CS5530 GPIOs */ +#define GFX_I2C_DYNAMIC 1 /* runtime selection */ +#define GFX_I2C_ACCESS 1 /* support for ACCESS.BUS */ +#define GFX_I2C_GPIO 1 /* support for CS5530 GPIOs */ -#define GFX_VGA_DYNAMIC 1 /* runtime selection */ -#define GFX_VGA_GU1 1 /* 1st generation graphics unit */ +#define GFX_VGA_DYNAMIC 1 /* runtime selection */ +#define GFX_VGA_GU1 1 /* 1st generation graphics unit */ -#define FB4MB 1 /* Set to use 4Mb video ram for Pyramid */ +#define FB4MB 1 /* Set to use 4Mb video ram for Pyramid */ -#define GFX_NO_IO_IN_WAIT_MACROS 1 /* Set to remove I/O accesses in GP bit testing */ +#define GFX_NO_IO_IN_WAIT_MACROS 1 /* Set to remove I/O accesses in GP bit testing */ /* ROUTINES TO READ VALUES * These are routines used by Darwin or other diagnostics to read the * current state of the hardware. Display drivers or embedded applications can * reduce the size of the Durango code by not including these routines. */ -#define GFX_READ_ROUTINES 1 /* add routines to read values */ +#define GFX_READ_ROUTINES 1 /* add routines to read values */ /* HEADER FILE FOR DURANGO ROUTINE DEFINITIONS * Needed since some of the Durango routines call other Durango routines. * Also defines the size of chipset array (GFX_CSPTR_SIZE). */ -#include "gfx_rtns.h" /* routine definitions */ +#include "gfx_rtns.h" /* routine definitions */ /* VARIABLES USED FOR RUNTIME SELECTION * If part of the graphics subsystem is declared as dynamic, then the @@ -276,25 +276,25 @@ int gfx_vga_type = 0; /* the WRITE_REG* macros are modified to subtract 0x8000 from */ /* the offset. */ -unsigned char *gfx_virt_regptr = (unsigned char *)0x40000000; -unsigned char *gfx_virt_fbptr = (unsigned char *)0x40800000; -unsigned char *gfx_virt_vidptr = (unsigned char *)0x40010000; -unsigned char *gfx_virt_vipptr = (unsigned char *)0x40015000; -unsigned char *gfx_virt_spptr = (unsigned char *)0x40000000; -unsigned char *gfx_virt_gpptr = (unsigned char *)0x40000000; +unsigned char *gfx_virt_regptr = (unsigned char *) 0x40000000; +unsigned char *gfx_virt_fbptr = (unsigned char *) 0x40800000; +unsigned char *gfx_virt_vidptr = (unsigned char *) 0x40010000; +unsigned char *gfx_virt_vipptr = (unsigned char *) 0x40015000; +unsigned char *gfx_virt_spptr = (unsigned char *) 0x40000000; +unsigned char *gfx_virt_gpptr = (unsigned char *) 0x40000000; /* DEFINE PHYSICAL ADDRESSES */ -unsigned char *gfx_phys_regptr = (unsigned char *)0x40000000; -unsigned char *gfx_phys_fbptr = (unsigned char *)0x40800000; -unsigned char *gfx_phys_vidptr = (unsigned char *)0x40010000; -unsigned char *gfx_phys_vipptr = (unsigned char *)0x40015000; +unsigned char *gfx_phys_regptr = (unsigned char *) 0x40000000; +unsigned char *gfx_phys_fbptr = (unsigned char *) 0x40800000; +unsigned char *gfx_phys_vidptr = (unsigned char *) 0x40010000; +unsigned char *gfx_phys_vipptr = (unsigned char *) 0x40015000; /* HEADER FILE FOR GRAPHICS REGISTER DEFINITIONS * This contains only constant definitions, so it should be able to be * included in any software project as is. */ -#include "gfx_regs.h" /* graphics register definitions */ +#include "gfx_regs.h" /* graphics register definitions */ /* HEADER FILE FOR REGISTER ACCESS MACROS * This file contains the definitions of the WRITE_REG32 and similar macros @@ -304,7 +304,7 @@ unsigned char *gfx_phys_vipptr = (unsigned char *)0x40015000; * should not be included and the project must define the macros itself. * (A project may define WRITE_REG32 to call a routine, for example). */ -#include "gfx_defs.h" /* register access macros */ +#include "gfx_defs.h" /* register access macros */ /* IO MACROS AND ROUTINES * These macros must be defined before the initialization or I2C @@ -329,71 +329,71 @@ void gfx_outd(unsigned short port, unsigned long data); unsigned char gfx_inb(unsigned short port) { - return inb(port); + return inb(port); } unsigned short gfx_inw(unsigned short port) { - return inw(port); + return inw(port); } unsigned long gfx_ind(unsigned short port) { - return inl(port); + return inl(port); } void gfx_outb(unsigned short port, unsigned char data) { - outb(port, data); + outb(port, data); } void gfx_outw(unsigned short port, unsigned short data) { - outw(port, data); + outw(port, data); } void gfx_outd(unsigned short port, unsigned long data) { - outl(port, data); + outl(port, data); } #ifdef __i386__ extern unsigned long nsc_asm_msr_vsa_rd(unsigned long, unsigned long *, - unsigned long *); + unsigned long *); extern unsigned long nsc_asm_msr_vsa_wr(unsigned long, unsigned long, - unsigned long); + unsigned long); #endif void gfx_msr_asm_read(unsigned short msrReg, unsigned long msrAddr, - unsigned long *ptrHigh, unsigned long *ptrLow) + unsigned long *ptrHigh, unsigned long *ptrLow) { #ifdef __i386__ - unsigned long addr, val1, val2; + unsigned long addr, val1, val2; - addr = msrAddr | (unsigned long)msrReg; - nsc_asm_msr_vsa_rd(addr, &val2, &val1); - *ptrHigh = val2; - *ptrLow = val1; + addr = msrAddr | (unsigned long) msrReg; + nsc_asm_msr_vsa_rd(addr, &val2, &val1); + *ptrHigh = val2; + *ptrLow = val1; #endif } void gfx_msr_asm_write(unsigned short msrReg, unsigned long msrAddr, - unsigned long *ptrHigh, unsigned long *ptrLow) + unsigned long *ptrHigh, unsigned long *ptrLow) { #ifdef __i386__ - unsigned long addr, val1, val2; + unsigned long addr, val1, val2; - val2 = *ptrHigh; - val1 = *ptrLow; - addr = (msrAddr & 0xFFFF0000) | (unsigned long)msrReg; - nsc_asm_msr_vsa_wr(addr, val2, val1); + val2 = *ptrHigh; + val1 = *ptrLow; + addr = (msrAddr & 0xFFFF0000) | (unsigned long) msrReg; + nsc_asm_msr_vsa_wr(addr, val2, val1); #endif } @@ -416,43 +416,43 @@ gfx_msr_asm_write(unsigned short msrReg, unsigned long msrAddr, * the project does not use graphics acceleration (direct frame buffer * access only), then this file does not need to be included. */ -#include "gfx_rndr.c" /* graphics engine routines */ +#include "gfx_rndr.c" /* graphics engine routines */ /* INCLUDE DISPLAY CONTROLLER ROUTINES * These routines are used if the display mode is set directly. If the * project uses VGA registers to set a display mode, then these files * do not need to be included. */ -#include "gfx_mode.h" /* display mode tables */ -#include "gfx_disp.c" /* display controller routines */ +#include "gfx_mode.h" /* display mode tables */ +#include "gfx_disp.c" /* display controller routines */ /* INCLUDE VIDEO OVERLAY ROUTINES * These routines control the video overlay hardware. */ -#include "gfx_vid.c" /* video overlay routines */ +#include "gfx_vid.c" /* video overlay routines */ /* VIDEO PORT AND VIDEO DECODER ROUTINES * These routines rely on the I2C routines. */ -#include "gfx_vip.c" /* video port routines */ -#include "gfx_dcdr.c" /* video decoder routines */ +#include "gfx_vip.c" /* video port routines */ +#include "gfx_dcdr.c" /* video decoder routines */ /* I2C BUS ACCESS ROUTINES * These routines are used by the video decoder and possibly an * external TV encoer. */ -#include "gfx_i2c.c" /* I2C bus access routines */ +#include "gfx_i2c.c" /* I2C bus access routines */ /* TV ENCODER ROUTINES * This file does not need to be included if the system does not * support TV output. */ -#include "gfx_tv.c" /* TV encoder routines */ +#include "gfx_tv.c" /* TV encoder routines */ /* VGA ROUTINES * This file is used if setting display modes using VGA registers. */ -#include "gfx_vga.c" /* VGA routines */ +#include "gfx_vga.c" /* VGA routines */ /* Hardware Register reading functions */ #include "nsc_regacc.c" diff --git a/src/gfx/disp_gu1.c b/src/gfx/disp_gu1.c index b177264..680cba5 100644 --- a/src/gfx/disp_gu1.c +++ b/src/gfx/disp_gu1.c @@ -128,27 +128,27 @@ * * END_NSC_LIC_GPL */ -void gu1_enable_compression(void); /* private routine definition */ -void gu1_disable_compression(void); /* private routine definition */ -void gfx_reset_video(void); /* private routine definition */ -int gfx_set_display_control(int sync_polarities); /* private routine definition */ +void gu1_enable_compression(void); /* private routine definition */ +void gu1_disable_compression(void); /* private routine definition */ +void gfx_reset_video(void); /* private routine definition */ +int gfx_set_display_control(int sync_polarities); /* private routine definition */ void gu1_delay_approximate(unsigned long milliseconds); void gu1_delay_precise(unsigned long milliseconds); int gu1_set_display_bpp(unsigned short bpp); int gu1_is_display_mode_supported(int xres, int yres, int bpp, int hz); int gu1_set_display_mode(int xres, int yres, int bpp, int hz); int gu1_set_display_timings(unsigned short bpp, unsigned short flags, - unsigned short hactive, - unsigned short hblank_start, - unsigned short hsync_start, - unsigned short hsync_end, - unsigned short hblank_end, unsigned short htotal, - unsigned short vactive, - unsigned short vblank_start, - unsigned short vsync_start, - unsigned short vsync_end, - unsigned short vblank_end, unsigned short vtotal, - unsigned long frequency); + unsigned short hactive, + unsigned short hblank_start, + unsigned short hsync_start, + unsigned short hsync_end, + unsigned short hblank_end, unsigned short htotal, + unsigned short vactive, + unsigned short vblank_start, + unsigned short vsync_start, + unsigned short vsync_end, + unsigned short vblank_end, unsigned short vtotal, + unsigned long frequency); int gu1_set_vtotal(unsigned short vtotal); void gu1_set_display_pitch(unsigned short pitch); void gu1_set_display_offset(unsigned long offset); @@ -160,19 +160,18 @@ int gu1_set_crt_enable(int enable); void gu1_set_cursor_enable(int enable); void gu1_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor); void gu1_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, - unsigned short yhotspot); + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, unsigned short yhotspot); void gu1_set_cursor_shape32(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask); + unsigned long *xormask); void gu1_set_cursor_shape64(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask); + unsigned long *xormask); void gu1_set_icon_enable(int enable); void gu1_set_icon_colors(unsigned long color0, unsigned long color1, - unsigned long color2); + unsigned long color2); void gu1_set_icon_position(unsigned long memoffset, unsigned short xpos); void gu1_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask, unsigned int lines); + unsigned long *xormask, unsigned int lines); int gu1_set_compression_enable(int enable); int gu1_set_compression_offset(unsigned long offset); @@ -186,9 +185,9 @@ void gu1_delay_milliseconds(unsigned long milliseconds); void gu1_delay_microseconds(unsigned long microseconds); void gu1_enable_panning(int x, int y); int gu1_set_fixed_timings(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp); + unsigned short height, unsigned short bpp); int gu1_set_panel_present(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp); + unsigned short height, unsigned short bpp); void gu1_reset_timing_lock(void); int gu1_get_display_details(unsigned int mode, int *xres, int *yres, int *hz); @@ -198,13 +197,13 @@ int gu1_get_sync_polarities(void); unsigned long gu1_get_clock_frequency(void); unsigned long gu1_get_max_supported_pixel_clock(void); int gu1_mode_frequency_supported(int xres, int yres, int bpp, - unsigned long frequency); + unsigned long frequency); int gu1_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, - unsigned long frequency); + unsigned long frequency); int gu1_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, - unsigned long frequency); + unsigned long frequency); int gu1_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, - int *frequency); + int *frequency); int gu1_get_display_mode_count(void); int gu1_get_display_mode(int *xres, int *yres, int *bpp, int *hz); unsigned long gu1_get_frame_buffer_line_size(void); @@ -223,8 +222,7 @@ unsigned short gu1_get_vblank_end(void); unsigned short gu1_get_vtotal(void); unsigned short gu1_get_display_bpp(void); unsigned long gu1_get_display_offset(void); -int gu1_get_display_palette_entry(unsigned long index, - unsigned long *palette); +int gu1_get_display_palette_entry(unsigned long index, unsigned long *palette); void gu1_get_display_palette(unsigned long *palette); unsigned long gu1_get_cursor_enable(void); unsigned long gu1_get_cursor_offset(void); @@ -262,16 +260,16 @@ int vid_enabled = 0; void gu1_delay_approximate(unsigned long milliseconds) { - /* ASSUME 300 MHz, 5 CLOCKS PER READ */ + /* ASSUME 300 MHz, 5 CLOCKS PER READ */ # define READS_PER_MILLISECOND 60000L - unsigned long loop; + unsigned long loop; - loop = milliseconds * READS_PER_MILLISECOND; - while (loop-- > 0) { - READ_REG32(DC_UNLOCK); - } + loop = milliseconds * READS_PER_MILLISECOND; + while (loop-- > 0) { + READ_REG32(DC_UNLOCK); + } } /*----------------------------------------------------------------------------- @@ -286,45 +284,45 @@ gu1_delay_precise(unsigned long milliseconds) #if GFX_VIDEO_SC1200 #define LOOP 1000 - unsigned long i, timer_start, timer_end, total_ticks, previous_ticks, - temp_ticks; - - /* Get current time */ - timer_start = IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE); - - /* Calculate expected end time */ - if (INB(SC1200_CB_BASE_ADDR + SC1200_CB_TMCNFG) & SC1200_TMCLKSEL_27MHZ) - total_ticks = 27000 * milliseconds; /* timer resolution is 27 MHz */ - else - total_ticks = 1000 * milliseconds; /* timer resolution is 1 MHz */ - - if (total_ticks > ((unsigned long)0xffffffff - timer_start)) /* wrap-around */ - timer_end = total_ticks - ((unsigned long)0xffffffff - timer_start); - else - timer_end = timer_start + total_ticks; - - /* in case of wrap around */ - if (timer_end < timer_start) { - previous_ticks = timer_start; - while (1) { - temp_ticks = IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE); - if (temp_ticks < previous_ticks) - break; - else - previous_ticks = temp_ticks; - for (i = 0; i < LOOP; i++) - READ_REG32(DC_UNLOCK); - } - } - /* now the non-wrap around part */ - while (1) { - for (i = 0; i < LOOP; i++) - READ_REG32(DC_UNLOCK); - if (IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE) > timer_end) - break; - } - -#endif /* GFX_VIDEO_SC1200 */ + unsigned long i, timer_start, timer_end, total_ticks, previous_ticks, + temp_ticks; + + /* Get current time */ + timer_start = IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE); + + /* Calculate expected end time */ + if (INB(SC1200_CB_BASE_ADDR + SC1200_CB_TMCNFG) & SC1200_TMCLKSEL_27MHZ) + total_ticks = 27000 * milliseconds; /* timer resolution is 27 MHz */ + else + total_ticks = 1000 * milliseconds; /* timer resolution is 1 MHz */ + + if (total_ticks > ((unsigned long) 0xffffffff - timer_start)) /* wrap-around */ + timer_end = total_ticks - ((unsigned long) 0xffffffff - timer_start); + else + timer_end = timer_start + total_ticks; + + /* in case of wrap around */ + if (timer_end < timer_start) { + previous_ticks = timer_start; + while (1) { + temp_ticks = IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE); + if (temp_ticks < previous_ticks) + break; + else + previous_ticks = temp_ticks; + for (i = 0; i < LOOP; i++) + READ_REG32(DC_UNLOCK); + } + } + /* now the non-wrap around part */ + while (1) { + for (i = 0; i < LOOP; i++) + READ_REG32(DC_UNLOCK); + if (IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE) > timer_end) + break; + } + +#endif /* GFX_VIDEO_SC1200 */ } /*----------------------------------------------------------------------------- @@ -358,17 +356,17 @@ gfx_delay_milliseconds(unsigned long milliseconds) #if GFX_VIDEO_SC1200 #if GFX_VIDEO_DYNAMIC - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) { + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) { #endif - gu1_delay_precise(milliseconds); - return; + gu1_delay_precise(milliseconds); + return; #if GFX_VIDEO_DYNAMIC - } + } #endif -#endif /* GFX_VIDEO_SC1200 */ +#endif /* GFX_VIDEO_SC1200 */ - gu1_delay_approximate(milliseconds); + gu1_delay_approximate(milliseconds); } #if GFX_DISPLAY_DYNAMIC @@ -379,13 +377,13 @@ void gfx_delay_microseconds(unsigned long microseconds) #endif { - /* ASSUME 300 MHz, 2 CLOCKS PER INCREMENT */ + /* ASSUME 300 MHz, 2 CLOCKS PER INCREMENT */ - unsigned long loop_count = microseconds * 150; + unsigned long loop_count = microseconds * 150; - while (loop_count-- > 0) { - ; - } + while (loop_count-- > 0) { + ; + } } /*----------------------------------------------------------------------------- @@ -397,46 +395,46 @@ gfx_delay_microseconds(unsigned long microseconds) void gu1_video_shutdown(void) { - unsigned long unlock; - unsigned long gcfg, tcfg; + unsigned long unlock; + unsigned long gcfg, tcfg; - /* DISABLE COMPRESSION */ + /* DISABLE COMPRESSION */ - gu1_disable_compression(); + gu1_disable_compression(); - /* ALSO DISABLE VIDEO */ - /* Use private "reset video" routine to do all that is needed. */ - /* SC1200, for example, also disables the alpha blending regions. */ + /* ALSO DISABLE VIDEO */ + /* Use private "reset video" routine to do all that is needed. */ + /* SC1200, for example, also disables the alpha blending regions. */ - gfx_reset_video(); + gfx_reset_video(); - /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ + /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ - unlock = READ_REG32(DC_UNLOCK); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + unlock = READ_REG32(DC_UNLOCK); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - /* READ THE CURRENT GX VALUES */ + /* READ THE CURRENT GX VALUES */ - gcfg = READ_REG32(DC_GENERAL_CFG); - tcfg = READ_REG32(DC_TIMING_CFG); + gcfg = READ_REG32(DC_GENERAL_CFG); + tcfg = READ_REG32(DC_TIMING_CFG); - /* BLANK THE GX DISPLAY AND DISABLE THE TIMING GENERATOR */ + /* BLANK THE GX DISPLAY AND DISABLE THE TIMING GENERATOR */ - tcfg &= ~((unsigned long)DC_TCFG_BLKE | (unsigned long)DC_TCFG_TGEN); - WRITE_REG32(DC_TIMING_CFG, tcfg); + tcfg &= ~((unsigned long) DC_TCFG_BLKE | (unsigned long) DC_TCFG_TGEN); + WRITE_REG32(DC_TIMING_CFG, tcfg); - /* DELAY: WAIT FOR PENDING MEMORY REQUESTS */ - /* This delay is used to make sure that all pending requests to the */ - /* memory controller have completed before disabling the FIFO load. */ + /* DELAY: WAIT FOR PENDING MEMORY REQUESTS */ + /* This delay is used to make sure that all pending requests to the */ + /* memory controller have completed before disabling the FIFO load. */ - gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); - /* DISABLE DISPLAY FIFO LOAD AND DISABLE COMPRESSION */ + /* DISABLE DISPLAY FIFO LOAD AND DISABLE COMPRESSION */ - gcfg &= ~(unsigned long)(DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE); - WRITE_REG32(DC_GENERAL_CFG, gcfg); - WRITE_REG32(DC_UNLOCK, unlock); - return; + gcfg &= ~(unsigned long) (DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE); + WRITE_REG32(DC_GENERAL_CFG, gcfg); + WRITE_REG32(DC_UNLOCK, unlock); + return; } /*----------------------------------------------------------------------------- @@ -453,29 +451,29 @@ int gfx_set_display_bpp(unsigned short bpp) #endif { - unsigned long ocfg, lock; + unsigned long ocfg, lock; - lock = READ_REG32(DC_UNLOCK); - ocfg = READ_REG32(DC_OUTPUT_CFG) & ~(DC_OCFG_8BPP | DC_OCFG_555); + lock = READ_REG32(DC_UNLOCK); + ocfg = READ_REG32(DC_OUTPUT_CFG) & ~(DC_OCFG_8BPP | DC_OCFG_555); - /* SET DC PIXEL FORMAT */ + /* SET DC PIXEL FORMAT */ - if (bpp == 8) - ocfg |= DC_OCFG_8BPP; - else if (bpp == 15) - ocfg |= DC_OCFG_555; - else if (bpp != 16) - return GFX_STATUS_BAD_PARAMETER; + if (bpp == 8) + ocfg |= DC_OCFG_8BPP; + else if (bpp == 15) + ocfg |= DC_OCFG_555; + else if (bpp != 16) + return GFX_STATUS_BAD_PARAMETER; - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_OUTPUT_CFG, ocfg); - WRITE_REG32(DC_UNLOCK, lock); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_OUTPUT_CFG, ocfg); + WRITE_REG32(DC_UNLOCK, lock); - /* SET BPP IN GRAPHICS PIPELINE */ + /* SET BPP IN GRAPHICS PIPELINE */ - gfx_set_bpp(bpp); + gfx_set_bpp(bpp); - return 0; + return 0; } /*----------------------------------------------------------------------------- @@ -487,298 +485,298 @@ gfx_set_display_bpp(unsigned short bpp) int gu1_set_specified_mode(DISPLAYMODE * pMode, int bpp) { - unsigned long unlock, value; - unsigned long gcfg, tcfg, ocfg; - unsigned long size, pitch; - unsigned long vid_buffer_size; - unsigned long hactive, vactive; + unsigned long unlock, value; + unsigned long gcfg, tcfg, ocfg; + unsigned long size, pitch; + unsigned long vid_buffer_size; + unsigned long hactive, vactive; - gbpp = bpp; + gbpp = bpp; - /* CHECK WHETHER TIMING CHANGE IS ALLOWED */ - /* Flag used for locking also overrides timing change restriction */ + /* CHECK WHETHER TIMING CHANGE IS ALLOWED */ + /* Flag used for locking also overrides timing change restriction */ - if (gfx_timing_lock && !(pMode->flags & GFX_MODE_LOCK_TIMING)) - return GFX_STATUS_ERROR; + if (gfx_timing_lock && !(pMode->flags & GFX_MODE_LOCK_TIMING)) + return GFX_STATUS_ERROR; - /* SET GLOBAL FLAG */ + /* SET GLOBAL FLAG */ - if (pMode->flags & GFX_MODE_LOCK_TIMING) - gfx_timing_lock = 1; + if (pMode->flags & GFX_MODE_LOCK_TIMING) + gfx_timing_lock = 1; - /* DISABLE COMPRESSION */ + /* DISABLE COMPRESSION */ - gu1_disable_compression(); + gu1_disable_compression(); - /* ALSO DISABLE VIDEO */ - /* Use private "reset video" routine to do all that is needed. */ - /* SC1200, for example, also disables the alpha blending regions. */ + /* ALSO DISABLE VIDEO */ + /* Use private "reset video" routine to do all that is needed. */ + /* SC1200, for example, also disables the alpha blending regions. */ - gfx_reset_video(); + gfx_reset_video(); - /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ + /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ - unlock = READ_REG32(DC_UNLOCK); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + unlock = READ_REG32(DC_UNLOCK); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - /* READ THE CURRENT GX VALUES */ + /* READ THE CURRENT GX VALUES */ - gcfg = READ_REG32(DC_GENERAL_CFG); - tcfg = READ_REG32(DC_TIMING_CFG); + gcfg = READ_REG32(DC_GENERAL_CFG); + tcfg = READ_REG32(DC_TIMING_CFG); - /* BLANK THE GX DISPLAY AND DISABLE THE TIMING GENERATOR */ + /* BLANK THE GX DISPLAY AND DISABLE THE TIMING GENERATOR */ - tcfg &= ~((unsigned long)DC_TCFG_BLKE | (unsigned long)DC_TCFG_TGEN); - WRITE_REG32(DC_TIMING_CFG, tcfg); + tcfg &= ~((unsigned long) DC_TCFG_BLKE | (unsigned long) DC_TCFG_TGEN); + WRITE_REG32(DC_TIMING_CFG, tcfg); - /* DELAY: WAIT FOR PENDING MEMORY REQUESTS - * This delay is used to make sure that all pending requests to the - * memory controller have completed before disabling the FIFO load. - */ + /* DELAY: WAIT FOR PENDING MEMORY REQUESTS + * This delay is used to make sure that all pending requests to the + * memory controller have completed before disabling the FIFO load. + */ - gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); - /* DISABLE DISPLAY FIFO LOAD AND DISABLE COMPRESSION */ + /* DISABLE DISPLAY FIFO LOAD AND DISABLE COMPRESSION */ - gcfg &= ~(unsigned long)(DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE); - WRITE_REG32(DC_GENERAL_CFG, gcfg); + gcfg &= ~(unsigned long) (DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE); + WRITE_REG32(DC_GENERAL_CFG, gcfg); - /* CLEAR THE "DCLK_MUL" FIELD */ + /* CLEAR THE "DCLK_MUL" FIELD */ - gcfg &= ~(unsigned long)(DC_GCFG_DDCK | DC_GCFG_DPCK | DC_GCFG_DFCK); - gcfg &= ~(unsigned long)DC_GCFG_DCLK_MASK; - WRITE_REG32(DC_GENERAL_CFG, gcfg); + gcfg &= ~(unsigned long) (DC_GCFG_DDCK | DC_GCFG_DPCK | DC_GCFG_DFCK); + gcfg &= ~(unsigned long) DC_GCFG_DCLK_MASK; + WRITE_REG32(DC_GENERAL_CFG, gcfg); - /* SET THE DOT CLOCK FREQUENCY */ - /* Mask off the divide by two bit (bit 31) */ + /* SET THE DOT CLOCK FREQUENCY */ + /* Mask off the divide by two bit (bit 31) */ - gfx_set_clock_frequency(pMode->frequency & 0x7FFFFFFF); + gfx_set_clock_frequency(pMode->frequency & 0x7FFFFFFF); - /* DELAY: WAIT FOR THE PLL TO SETTLE */ - /* This allows the dot clock frequency that was just set to settle. */ + /* DELAY: WAIT FOR THE PLL TO SETTLE */ + /* This allows the dot clock frequency that was just set to settle. */ - gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); - /* SET THE "DCLK_MUL" FIELD OF DC_GENERAL_CFG */ - /* The GX hardware divides the dot clock, so 2x really means that the */ - /* internal dot clock equals the external dot clock. */ + /* SET THE "DCLK_MUL" FIELD OF DC_GENERAL_CFG */ + /* The GX hardware divides the dot clock, so 2x really means that the */ + /* internal dot clock equals the external dot clock. */ - if (pMode->frequency & 0x80000000) - gcfg |= 0x0040; - else - gcfg |= 0x0080; - WRITE_REG32(DC_GENERAL_CFG, gcfg); + if (pMode->frequency & 0x80000000) + gcfg |= 0x0040; + else + gcfg |= 0x0080; + WRITE_REG32(DC_GENERAL_CFG, gcfg); - /* DELAY: WAIT FOR THE ADL TO LOCK */ - /* This allows the clock generatation within GX to settle. This is */ - /* needed since some of the register writes that follow require that */ - /* clock to be present. */ + /* DELAY: WAIT FOR THE ADL TO LOCK */ + /* This allows the clock generatation within GX to settle. This is */ + /* needed since some of the register writes that follow require that */ + /* clock to be present. */ - /* We do a few to ensure we're synced */ - gfx_delay_milliseconds(1); - gfx_delay_milliseconds(1); - gfx_delay_milliseconds(1); - gfx_delay_milliseconds(1); - gfx_delay_milliseconds(1); - gfx_delay_milliseconds(1); + /* We do a few to ensure we're synced */ + gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); - /* SET THE GX DISPLAY CONTROLLER PARAMETERS */ + /* SET THE GX DISPLAY CONTROLLER PARAMETERS */ - WRITE_REG32(DC_FB_ST_OFFSET, 0); - WRITE_REG32(DC_CB_ST_OFFSET, 0); - WRITE_REG32(DC_CURS_ST_OFFSET, 0); + WRITE_REG32(DC_FB_ST_OFFSET, 0); + WRITE_REG32(DC_CB_ST_OFFSET, 0); + WRITE_REG32(DC_CURS_ST_OFFSET, 0); - /* SET LINE SIZE AND PITCH */ - /* Flat panels use the current flat panel line size to */ - /* calculate the pitch, but load the true line size */ - /* for the mode into the "Frame Buffer Line Size" field */ - /* of DC_BUF_SIZE. */ + /* SET LINE SIZE AND PITCH */ + /* Flat panels use the current flat panel line size to */ + /* calculate the pitch, but load the true line size */ + /* for the mode into the "Frame Buffer Line Size" field */ + /* of DC_BUF_SIZE. */ - if (PanelEnable) - size = ModeWidth; - else - size = pMode->hactive; + if (PanelEnable) + size = ModeWidth; + else + size = pMode->hactive; - if (bpp > 8) - size <<= 1; + if (bpp > 8) + size <<= 1; - /* ONLY PYRAMID SUPPORTS 4K LINE SIZE */ + /* ONLY PYRAMID SUPPORTS 4K LINE SIZE */ - if (size <= 1024) { - pitch = 1024; + if (size <= 1024) { + pitch = 1024; - /* SPECIAL CASE */ - /* Graphics acceleration in 16-bit pixel line double modes */ - /* requires a pitch of 2048. */ + /* SPECIAL CASE */ + /* Graphics acceleration in 16-bit pixel line double modes */ + /* requires a pitch of 2048. */ - if ((pMode->flags & GFX_MODE_LINE_DOUBLE) && bpp > 8) - pitch <<= 1; - } else { - if (gfx_cpu_version == GFX_CPU_PYRAMID) - pitch = (size <= 2048) ? 2048 : 4096; - else - pitch = 2048; - } - WRITE_REG32(DC_LINE_DELTA, pitch >> 2); + if ((pMode->flags & GFX_MODE_LINE_DOUBLE) && bpp > 8) + pitch <<= 1; + } + else { + if (gfx_cpu_version == GFX_CPU_PYRAMID) + pitch = (size <= 2048) ? 2048 : 4096; + else + pitch = 2048; + } + WRITE_REG32(DC_LINE_DELTA, pitch >> 2); - if (PanelEnable) { - size = pMode->hactive; - if (bpp > 8) - size <<= 1; - } + if (PanelEnable) { + size = pMode->hactive; + if (bpp > 8) + size <<= 1; + } - /* SAVE PREVIOUSLY STORED VIDEO BUFFER SIZE */ + /* SAVE PREVIOUSLY STORED VIDEO BUFFER SIZE */ - vid_buffer_size = READ_REG32(DC_BUF_SIZE) & 0x3FFF0000; + vid_buffer_size = READ_REG32(DC_BUF_SIZE) & 0x3FFF0000; - /* ADD 2 TO SIZE FOR POSSIBLE START ADDRESS ALIGNMENTS */ + /* ADD 2 TO SIZE FOR POSSIBLE START ADDRESS ALIGNMENTS */ - WRITE_REG32(DC_BUF_SIZE, ((size >> 3) + 2) | vid_buffer_size); + WRITE_REG32(DC_BUF_SIZE, ((size >> 3) + 2) | vid_buffer_size); - /* ALWAYS ENABLE "PANEL" DATA FROM MEDIAGX */ - /* That is really just the 18 BPP data bus to the companion chip */ + /* ALWAYS ENABLE "PANEL" DATA FROM MEDIAGX */ + /* That is really just the 18 BPP data bus to the companion chip */ - ocfg = DC_OCFG_PCKE | DC_OCFG_PDEL | DC_OCFG_PDEH; + ocfg = DC_OCFG_PCKE | DC_OCFG_PDEL | DC_OCFG_PDEH; + + /* SET PIXEL FORMAT */ - /* SET PIXEL FORMAT */ + if (bpp == 8) + ocfg |= DC_OCFG_8BPP; + else if (bpp == 15) + ocfg |= DC_OCFG_555; + + /* ENABLE TIMING GENERATOR, SYNCS, AND FP DATA */ + + tcfg = DC_TCFG_FPPE | DC_TCFG_HSYE | DC_TCFG_VSYE | DC_TCFG_BLKE | + DC_TCFG_TGEN; + + /* SET FIFO PRIORITY, DCLK MULTIPLIER, AND FIFO ENABLE */ + /* Default 6/5 for FIFO, 2x for DCLK multiplier. */ + + gcfg = (6 << DC_GCFG_DFHPEL_POS) | (5 << DC_GCFG_DFHPSL_POS) | DC_GCFG_DFLE; + + /* INCREASE FIFO PRIORITY FOR LARGE MODES */ + + if (pMode->hactive == 1280 && pMode->vactive == 1024) { + if ((bpp == 8) && (pMode->flags & GFX_MODE_85HZ)) + gcfg = (8l << DC_GCFG_DFHPEL_POS) | (7l << DC_GCFG_DFHPSL_POS) | + DC_GCFG_DFLE; + if ((bpp > 8) && (pMode->flags & GFX_MODE_75HZ)) + gcfg = (7l << DC_GCFG_DFHPEL_POS) | (6l << DC_GCFG_DFHPSL_POS) | + DC_GCFG_DFLE; + if ((bpp > 8) && (pMode->flags & GFX_MODE_85HZ)) + gcfg = (9l << DC_GCFG_DFHPEL_POS) | (8l << DC_GCFG_DFHPSL_POS) | + DC_GCFG_DFLE; + } + + /* SET DOT CLOCK MULTIPLIER */ + /* Bit 31 of frequency indicates divide frequency by two */ + + if (pMode->frequency & 0x80000000) + gcfg |= (1l << DC_GCFG_DCLK_POS); + else + gcfg |= (2l << DC_GCFG_DCLK_POS); - if (bpp == 8) - ocfg |= DC_OCFG_8BPP; - else if (bpp == 15) - ocfg |= DC_OCFG_555; - - /* ENABLE TIMING GENERATOR, SYNCS, AND FP DATA */ - - tcfg = DC_TCFG_FPPE | DC_TCFG_HSYE | DC_TCFG_VSYE | DC_TCFG_BLKE | - DC_TCFG_TGEN; - - /* SET FIFO PRIORITY, DCLK MULTIPLIER, AND FIFO ENABLE */ - /* Default 6/5 for FIFO, 2x for DCLK multiplier. */ - - gcfg = (6 << DC_GCFG_DFHPEL_POS) | (5 << DC_GCFG_DFHPSL_POS) | - DC_GCFG_DFLE; - - /* INCREASE FIFO PRIORITY FOR LARGE MODES */ - - if (pMode->hactive == 1280 && pMode->vactive == 1024) { - if ((bpp == 8) && (pMode->flags & GFX_MODE_85HZ)) - gcfg = (8l << DC_GCFG_DFHPEL_POS) | (7l << DC_GCFG_DFHPSL_POS) | - DC_GCFG_DFLE; - if ((bpp > 8) && (pMode->flags & GFX_MODE_75HZ)) - gcfg = (7l << DC_GCFG_DFHPEL_POS) | (6l << DC_GCFG_DFHPSL_POS) | - DC_GCFG_DFLE; - if ((bpp > 8) && (pMode->flags & GFX_MODE_85HZ)) - gcfg = (9l << DC_GCFG_DFHPEL_POS) | (8l << DC_GCFG_DFHPSL_POS) | - DC_GCFG_DFLE; - } - - /* SET DOT CLOCK MULTIPLIER */ - /* Bit 31 of frequency indicates divide frequency by two */ - - if (pMode->frequency & 0x80000000) - gcfg |= (1l << DC_GCFG_DCLK_POS); - else - gcfg |= (2l << DC_GCFG_DCLK_POS); + /* DIVIDE VIDEO CLOCK */ + /* CPU core frequencies above 266 MHz will divide the video */ + /* clock by 4 to ensure that we are running below 150 MHz. */ - /* DIVIDE VIDEO CLOCK */ - /* CPU core frequencies above 266 MHz will divide the video */ - /* clock by 4 to ensure that we are running below 150 MHz. */ + if (gfx_cpu_frequency > 266) + gcfg |= DC_GCFG_VCLK_DIV; - if (gfx_cpu_frequency > 266) - gcfg |= DC_GCFG_VCLK_DIV; + /* SET THE PIXEL AND LINE DOUBLE BITS IF NECESSARY */ + + hactive = pMode->hactive; + vactive = pMode->vactive; + gfx_line_double = 0; + gfx_pixel_double = 0; - /* SET THE PIXEL AND LINE DOUBLE BITS IF NECESSARY */ - - hactive = pMode->hactive; - vactive = pMode->vactive; - gfx_line_double = 0; - gfx_pixel_double = 0; + if (pMode->flags & GFX_MODE_LINE_DOUBLE) { + gcfg |= DC_GCFG_LDBL; + hactive <<= 1; - if (pMode->flags & GFX_MODE_LINE_DOUBLE) { - gcfg |= DC_GCFG_LDBL; - hactive <<= 1; + /* SET GLOBAL FLAG */ - /* SET GLOBAL FLAG */ + gfx_line_double = 1; + } - gfx_line_double = 1; - } + if (pMode->flags & GFX_MODE_PIXEL_DOUBLE) { + tcfg |= DC_TCFG_PXDB; + vactive <<= 1; - if (pMode->flags & GFX_MODE_PIXEL_DOUBLE) { - tcfg |= DC_TCFG_PXDB; - vactive <<= 1; + /* SET GLOBAL FLAG */ + + gfx_pixel_double = 1; + } + + /* COMBINE AND SET TIMING VALUES */ - /* SET GLOBAL FLAG */ - - gfx_pixel_double = 1; - } - - /* COMBINE AND SET TIMING VALUES */ - - value = (unsigned long)(hactive - 1) | - (((unsigned long)(pMode->htotal - 1)) << 16); - WRITE_REG32(DC_H_TIMING_1, value); - value = (unsigned long)(pMode->hblankstart - 1) | - (((unsigned long)(pMode->hblankend - 1)) << 16); - WRITE_REG32(DC_H_TIMING_2, value); - value = (unsigned long)(pMode->hsyncstart - 1) | - (((unsigned long)(pMode->hsyncend - 1)) << 16); - WRITE_REG32(DC_H_TIMING_3, value); - WRITE_REG32(DC_FP_H_TIMING, value); - value = (unsigned long)(vactive - 1) | - (((unsigned long)(pMode->vtotal - 1)) << 16); - WRITE_REG32(DC_V_TIMING_1, value); - value = (unsigned long)(pMode->vblankstart - 1) | - (((unsigned long)(pMode->vblankend - 1)) << 16); - WRITE_REG32(DC_V_TIMING_2, value); - value = (unsigned long)(pMode->vsyncstart - 1) | - (((unsigned long)(pMode->vsyncend - 1)) << 16); - WRITE_REG32(DC_V_TIMING_3, value); - value = (unsigned long)(pMode->vsyncstart - 2) | - (((unsigned long)(pMode->vsyncend - 2)) << 16); - WRITE_REG32(DC_FP_V_TIMING, value); - - WRITE_REG32(DC_OUTPUT_CFG, ocfg); - WRITE_REG32(DC_TIMING_CFG, tcfg); - gfx_delay_milliseconds(1); /* delay after TIMING_CFG */ - WRITE_REG32(DC_GENERAL_CFG, gcfg); - - /* ENABLE FLAT PANEL CENTERING */ - /* For 640x480 modes displayed with the 9211 within a 800x600 */ - /* flat panel display, turn on flat panel centering. */ - - if (PanelEnable) { - if (ModeWidth < PanelWidth) { - tcfg = READ_REG32(DC_TIMING_CFG); - tcfg = tcfg | DC_TCFG_FCEN; - WRITE_REG32(DC_TIMING_CFG, tcfg); - gfx_delay_milliseconds(1); /* delay after TIMING_CFG */ - } - } - - /* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */ - - gfx_set_display_control(((pMode->flags & GFX_MODE_NEG_HSYNC) ? 1 : 0) | - ((pMode->flags & GFX_MODE_NEG_VSYNC) ? 2 : 0)); - - /* RESTORE VALUE OF DC_UNLOCK */ - - WRITE_REG32(DC_UNLOCK, unlock); - - /* ALSO WRITE GP_BLIT_STATUS FOR PITCH AND 8/18 BPP */ - /* Remember, only Pyramid supports 4K line pitch */ - - value = 0; - if (bpp > 8) - value |= BC_16BPP; - if ((gfx_cpu_version == GFX_CPU_PYRAMID) && (pitch > 2048)) - value |= BC_FB_WIDTH_4096; - else if (pitch > 1024) - value |= BC_FB_WIDTH_2048; - WRITE_REG16(GP_BLIT_STATUS, (unsigned short)value); - - return GFX_STATUS_OK; - -} /* end gfx_set_specified_mode() */ + value = (unsigned long) (hactive - 1) | + (((unsigned long) (pMode->htotal - 1)) << 16); + WRITE_REG32(DC_H_TIMING_1, value); + value = (unsigned long) (pMode->hblankstart - 1) | + (((unsigned long) (pMode->hblankend - 1)) << 16); + WRITE_REG32(DC_H_TIMING_2, value); + value = (unsigned long) (pMode->hsyncstart - 1) | + (((unsigned long) (pMode->hsyncend - 1)) << 16); + WRITE_REG32(DC_H_TIMING_3, value); + WRITE_REG32(DC_FP_H_TIMING, value); + value = (unsigned long) (vactive - 1) | + (((unsigned long) (pMode->vtotal - 1)) << 16); + WRITE_REG32(DC_V_TIMING_1, value); + value = (unsigned long) (pMode->vblankstart - 1) | + (((unsigned long) (pMode->vblankend - 1)) << 16); + WRITE_REG32(DC_V_TIMING_2, value); + value = (unsigned long) (pMode->vsyncstart - 1) | + (((unsigned long) (pMode->vsyncend - 1)) << 16); + WRITE_REG32(DC_V_TIMING_3, value); + value = (unsigned long) (pMode->vsyncstart - 2) | + (((unsigned long) (pMode->vsyncend - 2)) << 16); + WRITE_REG32(DC_FP_V_TIMING, value); + + WRITE_REG32(DC_OUTPUT_CFG, ocfg); + WRITE_REG32(DC_TIMING_CFG, tcfg); + gfx_delay_milliseconds(1); /* delay after TIMING_CFG */ + WRITE_REG32(DC_GENERAL_CFG, gcfg); + + /* ENABLE FLAT PANEL CENTERING */ + /* For 640x480 modes displayed with the 9211 within a 800x600 */ + /* flat panel display, turn on flat panel centering. */ + + if (PanelEnable) { + if (ModeWidth < PanelWidth) { + tcfg = READ_REG32(DC_TIMING_CFG); + tcfg = tcfg | DC_TCFG_FCEN; + WRITE_REG32(DC_TIMING_CFG, tcfg); + gfx_delay_milliseconds(1); /* delay after TIMING_CFG */ + } + } + + /* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */ + + gfx_set_display_control(((pMode->flags & GFX_MODE_NEG_HSYNC) ? 1 : 0) | + ((pMode->flags & GFX_MODE_NEG_VSYNC) ? 2 : 0)); + + /* RESTORE VALUE OF DC_UNLOCK */ + + WRITE_REG32(DC_UNLOCK, unlock); + + /* ALSO WRITE GP_BLIT_STATUS FOR PITCH AND 8/18 BPP */ + /* Remember, only Pyramid supports 4K line pitch */ + + value = 0; + if (bpp > 8) + value |= BC_16BPP; + if ((gfx_cpu_version == GFX_CPU_PYRAMID) && (pitch > 2048)) + value |= BC_FB_WIDTH_4096; + else if (pitch > 1024) + value |= BC_FB_WIDTH_2048; + WRITE_REG16(GP_BLIT_STATUS, (unsigned short) value); + + return GFX_STATUS_OK; + +} /* end gfx_set_specified_mode() */ /*---------------------------------------------------------------------------- * GFX_IS_DISPLAY_MODE_SUPPORTED @@ -797,58 +795,58 @@ int gfx_is_display_mode_supported(int xres, int yres, int bpp, int hz) #endif { - unsigned int mode = 0; - unsigned long hz_flag = 0, bpp_flag = 0; + unsigned int mode = 0; + unsigned long hz_flag = 0, bpp_flag = 0; - /* SET FLAGS TO MATCH REFRESH RATE */ + /* SET FLAGS TO MATCH REFRESH RATE */ - if (hz == 56) - hz_flag = GFX_MODE_56HZ; - else if (hz == 60) - hz_flag = GFX_MODE_60HZ; - else if (hz == 70) - hz_flag = GFX_MODE_70HZ; - else if (hz == 72) - hz_flag = GFX_MODE_72HZ; - else if (hz == 75) - hz_flag = GFX_MODE_75HZ; - else if (hz == 85) - hz_flag = GFX_MODE_85HZ; - else - return -1; + if (hz == 56) + hz_flag = GFX_MODE_56HZ; + else if (hz == 60) + hz_flag = GFX_MODE_60HZ; + else if (hz == 70) + hz_flag = GFX_MODE_70HZ; + else if (hz == 72) + hz_flag = GFX_MODE_72HZ; + else if (hz == 75) + hz_flag = GFX_MODE_75HZ; + else if (hz == 85) + hz_flag = GFX_MODE_85HZ; + else + return -1; - /* SET BPP FLAGS TO LIMIT MODE SELECTION */ + /* SET BPP FLAGS TO LIMIT MODE SELECTION */ - if (bpp == 8) - bpp_flag = GFX_MODE_8BPP; - else if (bpp == 15) - bpp_flag = GFX_MODE_15BPP; - else if (bpp == 16) - bpp_flag = GFX_MODE_16BPP; - else - return -1; + if (bpp == 8) + bpp_flag = GFX_MODE_8BPP; + else if (bpp == 15) + bpp_flag = GFX_MODE_15BPP; + else if (bpp == 16) + bpp_flag = GFX_MODE_16BPP; + else + return -1; - /* ONLY PYRAMID SUPPORTS 4K PITCH */ + /* ONLY PYRAMID SUPPORTS 4K PITCH */ - if (gfx_cpu_version != GFX_CPU_PYRAMID && xres > 1024) { - if (bpp > 8) - return (-1); /* return with mode not found */ - } + if (gfx_cpu_version != GFX_CPU_PYRAMID && xres > 1024) { + if (bpp > 8) + return (-1); /* return with mode not found */ + } - /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ + /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ - for (mode = 0; mode < NUM_GX_DISPLAY_MODES; mode++) { - if ((DisplayParams[mode].hactive == (unsigned short)xres) && - (DisplayParams[mode].vactive == (unsigned short)yres) && - (DisplayParams[mode].flags & hz_flag) && - (DisplayParams[mode].flags & bpp_flag)) { + for (mode = 0; mode < NUM_GX_DISPLAY_MODES; mode++) { + if ((DisplayParams[mode].hactive == (unsigned short) xres) && + (DisplayParams[mode].vactive == (unsigned short) yres) && + (DisplayParams[mode].flags & hz_flag) && + (DisplayParams[mode].flags & bpp_flag)) { - /* SET THE DISPLAY CONTROLLER FOR THE SELECTED MODE */ + /* SET THE DISPLAY CONTROLLER FOR THE SELECTED MODE */ - return (mode); - } - } - return (-1); + return (mode); + } + } + return (-1); } /*---------------------------------------------------------------------------- @@ -867,20 +865,20 @@ int gfx_set_display_mode(int xres, int yres, int bpp, int hz) #endif { - int mode; + int mode; - /* DISABLE FLAT PANEL */ - /* Flat Panel settings are enabled by the function gfx_set_fixed_timings */ - /* and disabled by gfx_set_display_mode. */ + /* DISABLE FLAT PANEL */ + /* Flat Panel settings are enabled by the function gfx_set_fixed_timings */ + /* and disabled by gfx_set_display_mode. */ - PanelEnable = 0; + PanelEnable = 0; - mode = gfx_is_display_mode_supported(xres, yres, bpp, hz); - if (mode >= 0) { - if (gu1_set_specified_mode(&DisplayParams[mode], bpp) == GFX_STATUS_OK) - return (1); - } - return (0); + mode = gfx_is_display_mode_supported(xres, yres, bpp, hz); + if (mode >= 0) { + if (gu1_set_specified_mode(&DisplayParams[mode], bpp) == GFX_STATUS_OK) + return (1); + } + return (0); } /*---------------------------------------------------------------------------- @@ -895,51 +893,51 @@ gfx_set_display_mode(int xres, int yres, int bpp, int hz) #if GFX_DISPLAY_DYNAMIC int gu1_set_display_timings(unsigned short bpp, unsigned short flags, - unsigned short hactive, unsigned short hblankstart, - unsigned short hsyncstart, unsigned short hsyncend, - unsigned short hblankend, unsigned short htotal, - unsigned short vactive, unsigned short vblankstart, - unsigned short vsyncstart, unsigned short vsyncend, - unsigned short vblankend, unsigned short vtotal, - unsigned long frequency) + unsigned short hactive, unsigned short hblankstart, + unsigned short hsyncstart, unsigned short hsyncend, + unsigned short hblankend, unsigned short htotal, + unsigned short vactive, unsigned short vblankstart, + unsigned short vsyncstart, unsigned short vsyncend, + unsigned short vblankend, unsigned short vtotal, + unsigned long frequency) #else int gfx_set_display_timings(unsigned short bpp, unsigned short flags, - unsigned short hactive, unsigned short hblankstart, - unsigned short hsyncstart, unsigned short hsyncend, - unsigned short hblankend, unsigned short htotal, - unsigned short vactive, unsigned short vblankstart, - unsigned short vsyncstart, unsigned short vsyncend, - unsigned short vblankend, unsigned short vtotal, - unsigned long frequency) -#endif -{ - /* SET MODE STRUCTURE WITH SPECIFIED VALUES */ - - gfx_display_mode.flags = 0; - if (flags & 1) - gfx_display_mode.flags |= GFX_MODE_NEG_HSYNC; - if (flags & 2) - gfx_display_mode.flags |= GFX_MODE_NEG_VSYNC; - if (flags & 0x1000) - gfx_display_mode.flags |= GFX_MODE_LOCK_TIMING; - gfx_display_mode.hactive = hactive; - gfx_display_mode.hblankstart = hblankstart; - gfx_display_mode.hsyncstart = hsyncstart; - gfx_display_mode.hsyncend = hsyncend; - gfx_display_mode.hblankend = hblankend; - gfx_display_mode.htotal = htotal; - gfx_display_mode.vactive = vactive; - gfx_display_mode.vblankstart = vblankstart; - gfx_display_mode.vsyncstart = vsyncstart; - gfx_display_mode.vsyncend = vsyncend; - gfx_display_mode.vblankend = vblankend; - gfx_display_mode.vtotal = vtotal; - gfx_display_mode.frequency = frequency; - - /* CALL ROUTINE TO SET MODE */ - - return (gu1_set_specified_mode(&gfx_display_mode, bpp)); + unsigned short hactive, unsigned short hblankstart, + unsigned short hsyncstart, unsigned short hsyncend, + unsigned short hblankend, unsigned short htotal, + unsigned short vactive, unsigned short vblankstart, + unsigned short vsyncstart, unsigned short vsyncend, + unsigned short vblankend, unsigned short vtotal, + unsigned long frequency) +#endif +{ + /* SET MODE STRUCTURE WITH SPECIFIED VALUES */ + + gfx_display_mode.flags = 0; + if (flags & 1) + gfx_display_mode.flags |= GFX_MODE_NEG_HSYNC; + if (flags & 2) + gfx_display_mode.flags |= GFX_MODE_NEG_VSYNC; + if (flags & 0x1000) + gfx_display_mode.flags |= GFX_MODE_LOCK_TIMING; + gfx_display_mode.hactive = hactive; + gfx_display_mode.hblankstart = hblankstart; + gfx_display_mode.hsyncstart = hsyncstart; + gfx_display_mode.hsyncend = hsyncend; + gfx_display_mode.hblankend = hblankend; + gfx_display_mode.htotal = htotal; + gfx_display_mode.vactive = vactive; + gfx_display_mode.vblankstart = vblankstart; + gfx_display_mode.vsyncstart = vsyncstart; + gfx_display_mode.vsyncend = vsyncend; + gfx_display_mode.vblankend = vblankend; + gfx_display_mode.vtotal = vtotal; + gfx_display_mode.frequency = frequency; + + /* CALL ROUTINE TO SET MODE */ + + return (gu1_set_specified_mode(&gfx_display_mode, bpp)); } /*---------------------------------------------------------------------------- @@ -965,36 +963,36 @@ int gfx_set_vtotal(unsigned short vtotal) #endif { - unsigned long unlock, tcfg, timing1, timing2; + unsigned long unlock, tcfg, timing1, timing2; - /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ + /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ - unlock = READ_REG32(DC_UNLOCK); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + unlock = READ_REG32(DC_UNLOCK); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - /* READ THE CURRENT GX VALUES */ + /* READ THE CURRENT GX VALUES */ - tcfg = READ_REG32(DC_TIMING_CFG); - timing1 = READ_REG32(DC_V_TIMING_1); - timing2 = READ_REG32(DC_V_TIMING_2); + tcfg = READ_REG32(DC_TIMING_CFG); + timing1 = READ_REG32(DC_V_TIMING_1); + timing2 = READ_REG32(DC_V_TIMING_2); - /* DISABLE THE TIMING GENERATOR */ + /* DISABLE THE TIMING GENERATOR */ - WRITE_REG32(DC_TIMING_CFG, tcfg & ~(unsigned long)DC_TCFG_TGEN); + WRITE_REG32(DC_TIMING_CFG, tcfg & ~(unsigned long) DC_TCFG_TGEN); - /* WRITE NEW TIMING VALUES */ + /* WRITE NEW TIMING VALUES */ - WRITE_REG32(DC_V_TIMING_1, - (timing1 & 0xffff) | (unsigned long)(vtotal - 1) << 16); - WRITE_REG32(DC_V_TIMING_2, - (timing2 & 0xffff) | (unsigned long)(vtotal - 1) << 16); + WRITE_REG32(DC_V_TIMING_1, + (timing1 & 0xffff) | (unsigned long) (vtotal - 1) << 16); + WRITE_REG32(DC_V_TIMING_2, + (timing2 & 0xffff) | (unsigned long) (vtotal - 1) << 16); - /* RESTORE GX VALUES */ + /* RESTORE GX VALUES */ - WRITE_REG32(DC_TIMING_CFG, tcfg); - WRITE_REG32(DC_UNLOCK, unlock); + WRITE_REG32(DC_TIMING_CFG, tcfg); + WRITE_REG32(DC_UNLOCK, unlock); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -1011,29 +1009,29 @@ void gfx_set_display_pitch(unsigned short pitch) #endif { - unsigned long value = 0; - unsigned long lock = READ_REG32(DC_UNLOCK); + unsigned long value = 0; + unsigned long lock = READ_REG32(DC_UNLOCK); - value = READ_REG32(DC_LINE_DELTA) & 0xFFFFF000; - value |= (pitch >> 2); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_LINE_DELTA, value); - WRITE_REG32(DC_UNLOCK, lock); + value = READ_REG32(DC_LINE_DELTA) & 0xFFFFF000; + value |= (pitch >> 2); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_LINE_DELTA, value); + WRITE_REG32(DC_UNLOCK, lock); - /* ALSO UPDATE PITCH IN GRAPHICS ENGINE */ - /* Pyramid alone supports 4K line pitch */ + /* ALSO UPDATE PITCH IN GRAPHICS ENGINE */ + /* Pyramid alone supports 4K line pitch */ - value = (unsigned long)READ_REG16(GP_BLIT_STATUS); - value &= ~(BC_FB_WIDTH_2048 | BC_FB_WIDTH_4096); + value = (unsigned long) READ_REG16(GP_BLIT_STATUS); + value &= ~(BC_FB_WIDTH_2048 | BC_FB_WIDTH_4096); - if ((gfx_cpu_version == GFX_CPU_PYRAMID) && (pitch > 2048)) - value |= BC_FB_WIDTH_4096; + if ((gfx_cpu_version == GFX_CPU_PYRAMID) && (pitch > 2048)) + value |= BC_FB_WIDTH_4096; - else if (pitch > 1024) - value |= BC_FB_WIDTH_2048; + else if (pitch > 1024) + value |= BC_FB_WIDTH_2048; - WRITE_REG16(GP_BLIT_STATUS, (unsigned short)value); - return; + WRITE_REG16(GP_BLIT_STATUS, (unsigned short) value); + return; } /*--------------------------------------------------------------------------- @@ -1052,37 +1050,38 @@ void gfx_set_display_offset(unsigned long offset) #endif { - /* UPDATE FRAME BUFFER OFFSET */ + /* UPDATE FRAME BUFFER OFFSET */ - unsigned long lock; + unsigned long lock; - lock = READ_REG32(DC_UNLOCK); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + lock = READ_REG32(DC_UNLOCK); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - /* START ADDRESS EFFECTS DISPLAY COMPRESSION */ - /* Disable compression for non-zero start addresss values. */ - /* Enable compression if offset is zero and comression is intended to */ - /* be enabled from a previous call to "gfx_set_compression_enable". */ - /* Compression should be disabled BEFORE the offset is changed */ - /* and enabled AFTER the offset is changed. */ + /* START ADDRESS EFFECTS DISPLAY COMPRESSION */ + /* Disable compression for non-zero start addresss values. */ + /* Enable compression if offset is zero and comression is intended to */ + /* be enabled from a previous call to "gfx_set_compression_enable". */ + /* Compression should be disabled BEFORE the offset is changed */ + /* and enabled AFTER the offset is changed. */ - if (offset == 0) { - WRITE_REG32(DC_FB_ST_OFFSET, offset); - if (gfx_compression_enabled) { - /* WAIT FOR THE OFFSET TO BE LATCHED */ - gfx_wait_vertical_blank(); - gu1_enable_compression(); - } - } else { - /* ONLY DISABLE COMPRESSION ONCE */ + if (offset == 0) { + WRITE_REG32(DC_FB_ST_OFFSET, offset); + if (gfx_compression_enabled) { + /* WAIT FOR THE OFFSET TO BE LATCHED */ + gfx_wait_vertical_blank(); + gu1_enable_compression(); + } + } + else { + /* ONLY DISABLE COMPRESSION ONCE */ - if (gfx_compression_active) - gu1_disable_compression(); + if (gfx_compression_active) + gu1_disable_compression(); - WRITE_REG32(DC_FB_ST_OFFSET, offset); - } + WRITE_REG32(DC_FB_ST_OFFSET, offset); + } - WRITE_REG32(DC_UNLOCK, lock); + WRITE_REG32(DC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1100,17 +1099,17 @@ int gfx_set_display_palette_entry(unsigned long index, unsigned long palette) #endif { - unsigned long data; + unsigned long data; - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - WRITE_REG32(DC_PAL_ADDRESS, index); - data = ((palette >> 2) & 0x0003F) | - ((palette >> 4) & 0x00FC0) | ((palette >> 6) & 0x3F000); - WRITE_REG32(DC_PAL_DATA, data); + WRITE_REG32(DC_PAL_ADDRESS, index); + data = ((palette >> 2) & 0x0003F) | + ((palette >> 4) & 0x00FC0) | ((palette >> 6) & 0x3F000); + WRITE_REG32(DC_PAL_DATA, data); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -1131,19 +1130,19 @@ int gfx_set_display_palette(unsigned long *palette) #endif { - unsigned long data, i; + unsigned long data, i; - WRITE_REG32(DC_PAL_ADDRESS, 0); - if (palette) { - for (i = 0; i < 256; i++) { - /* CONVERT 24 BPP COLOR DATA TO 18 BPP COLOR DATA */ + WRITE_REG32(DC_PAL_ADDRESS, 0); + if (palette) { + for (i = 0; i < 256; i++) { + /* CONVERT 24 BPP COLOR DATA TO 18 BPP COLOR DATA */ - data = ((palette[i] >> 2) & 0x0003F) | - ((palette[i] >> 4) & 0x00FC0) | ((palette[i] >> 6) & 0x3F000); - WRITE_REG32(DC_PAL_DATA, data); - } - } - return (0); + data = ((palette[i] >> 2) & 0x0003F) | + ((palette[i] >> 4) & 0x00FC0) | ((palette[i] >> 6) & 0x3F000); + WRITE_REG32(DC_PAL_DATA, data); + } + } + return (0); } /*--------------------------------------------------------------------------- @@ -1164,22 +1163,22 @@ void gfx_set_cursor_enable(int enable) #endif { - unsigned long unlock, gcfg; + unsigned long unlock, gcfg; - /* SET OR CLEAR CURSOR ENABLE BIT */ + /* SET OR CLEAR CURSOR ENABLE BIT */ - unlock = READ_REG32(DC_UNLOCK); - gcfg = READ_REG32(DC_GENERAL_CFG); - if (enable) - gcfg |= DC_GCFG_CURE; - else - gcfg &= ~(DC_GCFG_CURE); + unlock = READ_REG32(DC_UNLOCK); + gcfg = READ_REG32(DC_GENERAL_CFG); + if (enable) + gcfg |= DC_GCFG_CURE; + else + gcfg &= ~(DC_GCFG_CURE); - /* WRITE NEW REGISTER VALUE */ + /* WRITE NEW REGISTER VALUE */ - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_GENERAL_CFG, gcfg); - WRITE_REG32(DC_UNLOCK, unlock); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_GENERAL_CFG, gcfg); + WRITE_REG32(DC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1199,28 +1198,28 @@ void gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor) #endif { - unsigned long value; + unsigned long value; - /* If genlock is enabled DCLK might be disabled in vertical blank. */ - /* Due to SC1200 Issue #748 in Notes DB this would fail the cursor color settings */ - /* So Wait for vertical blank to end */ + /* If genlock is enabled DCLK might be disabled in vertical blank. */ + /* Due to SC1200 Issue #748 in Notes DB this would fail the cursor color settings */ + /* So Wait for vertical blank to end */ #if GFX_VIDEO_SC1200 - if (gfx_test_timing_active()) - while ((gfx_get_vline()) > gfx_get_vactive()) ; + if (gfx_test_timing_active()) + while ((gfx_get_vline()) > gfx_get_vactive()); #endif - /* SET CURSOR COLORS */ + /* SET CURSOR COLORS */ - WRITE_REG32(DC_PAL_ADDRESS, 0x100); - value = ((bkcolor & 0x000000FC) >> 2) | - ((bkcolor & 0x0000FC00) >> (2 + 8 - 6)) | - ((bkcolor & 0x00FC0000) >> (2 + 16 - 12)); - WRITE_REG32(DC_PAL_DATA, value); - value = ((fgcolor & 0x000000FC) >> 2) | - ((fgcolor & 0x0000FC00) >> (2 + 8 - 6)) | - ((fgcolor & 0x00FC0000) >> (2 + 16 - 12)); - WRITE_REG32(DC_PAL_DATA, value); + WRITE_REG32(DC_PAL_ADDRESS, 0x100); + value = ((bkcolor & 0x000000FC) >> 2) | + ((bkcolor & 0x0000FC00) >> (2 + 8 - 6)) | + ((bkcolor & 0x00FC0000) >> (2 + 16 - 12)); + WRITE_REG32(DC_PAL_DATA, value); + value = ((fgcolor & 0x000000FC) >> 2) | + ((fgcolor & 0x0000FC00) >> (2 + 8 - 6)) | + ((fgcolor & 0x00FC0000) >> (2 + 16 - 12)); + WRITE_REG32(DC_PAL_DATA, value); } /*--------------------------------------------------------------------------- @@ -1234,63 +1233,63 @@ gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor) #if GFX_DISPLAY_DYNAMIC void gu1_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, unsigned short yhotspot) + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, unsigned short yhotspot) #else void gfx_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, unsigned short yhotspot) -#endif -{ - unsigned long unlock; - - short x, y; - short xoffset = 0; - short yoffset = 0; - - /* SUPPORT CURSOR IN EMULATED VGA MODES */ - /* Timings are for twice the resolution */ - - if (gfx_pixel_double) - xpos <<= 1; - if (gfx_line_double) - ypos <<= 1; - - x = (short)xpos - (short)xhotspot; - y = (short)ypos - (short)yhotspot; - if (x < -31) - return; - if (y < -31) - return; - if (x < 0) { - xoffset = -x; - x = 0; - } - if (y < 0) { - yoffset = -y; - y = 0; - } - memoffset += (unsigned long)yoffset << 3; - - if (PanelEnable) { - if ((ModeWidth > PanelWidth) || (ModeHeight > PanelHeight)) { - gfx_enable_panning(xpos, ypos); - x = x - (short)panelLeft; - y = y - (short)panelTop; - } - } - - /* SET CURSOR POSITION */ - - unlock = READ_REG32(DC_UNLOCK); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_CURS_ST_OFFSET, memoffset); - WRITE_REG32(DC_CURSOR_X, (unsigned long)x | - (((unsigned long)xoffset) << 11)); - WRITE_REG32(DC_CURSOR_Y, (unsigned long)y | - (((unsigned long)yoffset) << 11)); - WRITE_REG32(DC_UNLOCK, unlock); + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, unsigned short yhotspot) +#endif +{ + unsigned long unlock; + + short x, y; + short xoffset = 0; + short yoffset = 0; + + /* SUPPORT CURSOR IN EMULATED VGA MODES */ + /* Timings are for twice the resolution */ + + if (gfx_pixel_double) + xpos <<= 1; + if (gfx_line_double) + ypos <<= 1; + + x = (short) xpos - (short) xhotspot; + y = (short) ypos - (short) yhotspot; + if (x < -31) + return; + if (y < -31) + return; + if (x < 0) { + xoffset = -x; + x = 0; + } + if (y < 0) { + yoffset = -y; + y = 0; + } + memoffset += (unsigned long) yoffset << 3; + + if (PanelEnable) { + if ((ModeWidth > PanelWidth) || (ModeHeight > PanelHeight)) { + gfx_enable_panning(xpos, ypos); + x = x - (short) panelLeft; + y = y - (short) panelTop; + } + } + + /* SET CURSOR POSITION */ + + unlock = READ_REG32(DC_UNLOCK); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_CURS_ST_OFFSET, memoffset); + WRITE_REG32(DC_CURSOR_X, (unsigned long) x | + (((unsigned long) xoffset) << 11)); + WRITE_REG32(DC_CURSOR_Y, (unsigned long) y | + (((unsigned long) yoffset) << 11)); + WRITE_REG32(DC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1303,26 +1302,26 @@ gfx_set_cursor_position(unsigned long memoffset, #if GFX_DISPLAY_DYNAMIC void gu1_set_cursor_shape32(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) #else void gfx_set_cursor_shape32(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) #endif { - int i; - unsigned long value; + int i; + unsigned long value; - for (i = 0; i < 32; i++) { - /* CONVERT TO 16 BITS AND MASK, 16 BITS XOR MASK PER DWORD */ + for (i = 0; i < 32; i++) { + /* CONVERT TO 16 BITS AND MASK, 16 BITS XOR MASK PER DWORD */ - value = (andmask[i] & 0xFFFF0000) | (xormask[i] >> 16); - WRITE_FB32(memoffset, value); - memoffset += 4; - value = (andmask[i] << 16) | (xormask[i] & 0x0000FFFF); - WRITE_FB32(memoffset, value); - memoffset += 4; - } + value = (andmask[i] & 0xFFFF0000) | (xormask[i] >> 16); + WRITE_FB32(memoffset, value); + memoffset += 4; + value = (andmask[i] << 16) | (xormask[i] & 0x0000FFFF); + WRITE_FB32(memoffset, value); + memoffset += 4; + } } /*--------------------------------------------------------------------------- @@ -1335,41 +1334,41 @@ gfx_set_cursor_shape32(unsigned long memoffset, void gu1_enable_compression(void) { - int i; - unsigned long unlock, gcfg, offset; + int i; + unsigned long unlock, gcfg, offset; - /* DO NOT ENABLE IF START ADDRESS IS NOT ZERO */ + /* DO NOT ENABLE IF START ADDRESS IS NOT ZERO */ - offset = READ_REG32(DC_FB_ST_OFFSET) & 0x003FFFFF; - if (offset != 0) - return; + offset = READ_REG32(DC_FB_ST_OFFSET) & 0x003FFFFF; + if (offset != 0) + return; - /* DO NOT ENABLE IF WE ARE WITHIN AN EMULATED VGA MODE */ + /* DO NOT ENABLE IF WE ARE WITHIN AN EMULATED VGA MODE */ - if (gfx_line_double || gfx_pixel_double) - return; + if (gfx_line_double || gfx_pixel_double) + return; - /* SET GLOBAL INDICATOR */ + /* SET GLOBAL INDICATOR */ - gfx_compression_active = 1; + gfx_compression_active = 1; - /* CLEAR DIRTY/VALID BITS IN MEMORY CONTROLLER */ - /* Software is required to do this before enabling compression. */ - /* Don't want controller to think that old lines are still valid. */ + /* CLEAR DIRTY/VALID BITS IN MEMORY CONTROLLER */ + /* Software is required to do this before enabling compression. */ + /* Don't want controller to think that old lines are still valid. */ - for (i = 0; i < 1024; i++) { - WRITE_REG32(MC_DR_ADD, i); - WRITE_REG32(MC_DR_ACC, 0); - } + for (i = 0; i < 1024; i++) { + WRITE_REG32(MC_DR_ADD, i); + WRITE_REG32(MC_DR_ACC, 0); + } - /* TURN ON COMPRESSION CONTROL BITS */ + /* TURN ON COMPRESSION CONTROL BITS */ - unlock = READ_REG32(DC_UNLOCK); - gcfg = READ_REG32(DC_GENERAL_CFG); - gcfg |= DC_GCFG_CMPE | DC_GCFG_DECE; - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_GENERAL_CFG, gcfg); - WRITE_REG32(DC_UNLOCK, unlock); + unlock = READ_REG32(DC_UNLOCK); + gcfg = READ_REG32(DC_GENERAL_CFG); + gcfg |= DC_GCFG_CMPE | DC_GCFG_DECE; + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_GENERAL_CFG, gcfg); + WRITE_REG32(DC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1382,20 +1381,20 @@ gu1_enable_compression(void) void gu1_disable_compression(void) { - unsigned long unlock, gcfg; + unsigned long unlock, gcfg; - /* SET GLOBAL INDICATOR */ + /* SET GLOBAL INDICATOR */ - gfx_compression_active = 0; + gfx_compression_active = 0; - /* TURN OFF COMPRESSION CONTROL BITS */ + /* TURN OFF COMPRESSION CONTROL BITS */ - unlock = READ_REG32(DC_UNLOCK); - gcfg = READ_REG32(DC_GENERAL_CFG); - gcfg &= ~(DC_GCFG_CMPE | DC_GCFG_DECE); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_GENERAL_CFG, gcfg); - WRITE_REG32(DC_UNLOCK, unlock); + unlock = READ_REG32(DC_UNLOCK); + gcfg = READ_REG32(DC_GENERAL_CFG); + gcfg &= ~(DC_GCFG_CMPE | DC_GCFG_DECE); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_GENERAL_CFG, gcfg); + WRITE_REG32(DC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1412,16 +1411,16 @@ int gfx_set_compression_enable(int enable) #endif { - /* SET GLOBAL VARIABLE FOR INTENDED STATE */ - /* Compression can only be enabled for non-zero start address values. */ - /* Keep state to enable compression on start address changes. */ + /* SET GLOBAL VARIABLE FOR INTENDED STATE */ + /* Compression can only be enabled for non-zero start address values. */ + /* Keep state to enable compression on start address changes. */ - gfx_compression_enabled = enable; - if (enable) - gu1_enable_compression(); - else - gu1_disable_compression(); - return (0); + gfx_compression_enabled = enable; + if (enable) + gu1_enable_compression(); + else + gu1_disable_compression(); + return (0); } /*--------------------------------------------------------------------------- @@ -1438,20 +1437,20 @@ int gfx_set_compression_offset(unsigned long offset) #endif { - unsigned long lock; + unsigned long lock; - /* MUST BE 16-BYTE ALIGNED FOR GXLV */ + /* MUST BE 16-BYTE ALIGNED FOR GXLV */ - if (offset & 0x0F) - return (1); + if (offset & 0x0F) + return (1); - /* SET REGISTER VALUE */ + /* SET REGISTER VALUE */ - lock = READ_REG32(DC_UNLOCK); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_CB_ST_OFFSET, offset); - WRITE_REG32(DC_UNLOCK, lock); - return (0); + lock = READ_REG32(DC_UNLOCK); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_CB_ST_OFFSET, offset); + WRITE_REG32(DC_UNLOCK, lock); + return (0); } /*--------------------------------------------------------------------------- @@ -1468,17 +1467,17 @@ int gfx_set_compression_pitch(unsigned short pitch) #endif { - unsigned long lock, line_delta; + unsigned long lock, line_delta; - /* SET REGISTER VALUE */ + /* SET REGISTER VALUE */ - lock = READ_REG32(DC_UNLOCK); - line_delta = READ_REG32(DC_LINE_DELTA) & 0xFF800FFF; - line_delta |= ((unsigned long)pitch << 10l) & 0x007FF000; - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_LINE_DELTA, line_delta); - WRITE_REG32(DC_UNLOCK, lock); - return (0); + lock = READ_REG32(DC_UNLOCK); + line_delta = READ_REG32(DC_LINE_DELTA) & 0xFF800FFF; + line_delta |= ((unsigned long) pitch << 10l) & 0x007FF000; + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_LINE_DELTA, line_delta); + WRITE_REG32(DC_UNLOCK, lock); + return (0); } /*--------------------------------------------------------------------------- @@ -1496,25 +1495,25 @@ int gfx_set_compression_size(unsigned short size) #endif { - unsigned long lock, buf_size; + unsigned long lock, buf_size; - /* SUBTRACT 16 FROM SIZE */ - /* The display controller will actually write */ - /* 2 extra QWords. So, if we assume that "size" */ - /* refers to the allocated size, we must subtract */ - /* 16 bytes. */ + /* SUBTRACT 16 FROM SIZE */ + /* The display controller will actually write */ + /* 2 extra QWords. So, if we assume that "size" */ + /* refers to the allocated size, we must subtract */ + /* 16 bytes. */ - size -= 16; + size -= 16; - /* SET REGISTER VALUE */ + /* SET REGISTER VALUE */ - lock = READ_REG32(DC_UNLOCK); - buf_size = READ_REG32(DC_BUF_SIZE) & 0xFFFF01FF; - buf_size |= (((size >> 2) + 1) & 0x7F) << 9; - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - WRITE_REG32(DC_BUF_SIZE, buf_size); - WRITE_REG32(DC_UNLOCK, lock); - return (0); + lock = READ_REG32(DC_UNLOCK); + buf_size = READ_REG32(DC_BUF_SIZE) & 0xFFFF01FF; + buf_size |= (((size >> 2) + 1) & 0x7F) << 9; + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_BUF_SIZE, buf_size); + WRITE_REG32(DC_UNLOCK, lock); + return (0); } /*--------------------------------------------------------------------------- @@ -1531,38 +1530,38 @@ void gfx_set_display_video_enable(int enable) #endif { - unsigned long lock, gcfg, buf_size; + unsigned long lock, gcfg, buf_size; - lock = READ_REG32(DC_UNLOCK); - gcfg = READ_REG32(DC_GENERAL_CFG); - buf_size = READ_REG32(DC_BUF_SIZE); + lock = READ_REG32(DC_UNLOCK); + gcfg = READ_REG32(DC_GENERAL_CFG); + buf_size = READ_REG32(DC_BUF_SIZE); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - vid_enabled = enable; + vid_enabled = enable; - /* SET THE BUFFER SIZE TO A NON-ZERO VALUE ONLY WHEN */ - /* ENABLING VIDEO */ + /* SET THE BUFFER SIZE TO A NON-ZERO VALUE ONLY WHEN */ + /* ENABLING VIDEO */ - if (enable) { - gcfg |= (DC_GCFG_VIDE | DC_GCFG_VRDY); - WRITE_REG32(DC_GENERAL_CFG, gcfg); + if (enable) { + gcfg |= (DC_GCFG_VIDE | DC_GCFG_VRDY); + WRITE_REG32(DC_GENERAL_CFG, gcfg); - WRITE_REG32(DC_BUF_SIZE, (buf_size & 0x0000FFFFl) | vid_buf_size); - } + WRITE_REG32(DC_BUF_SIZE, (buf_size & 0x0000FFFFl) | vid_buf_size); + } - /* CLEAR THE VIDEO BUFFER SIZE WHEN DISABLING VIDEO */ + /* CLEAR THE VIDEO BUFFER SIZE WHEN DISABLING VIDEO */ - else { - gcfg &= ~(DC_GCFG_VIDE); - WRITE_REG32(DC_GENERAL_CFG, gcfg); + else { + gcfg &= ~(DC_GCFG_VIDE); + WRITE_REG32(DC_GENERAL_CFG, gcfg); - vid_buf_size = buf_size & 0xFFFF0000l; - WRITE_REG32(DC_BUF_SIZE, buf_size & 0x0000FFFFl); - } + vid_buf_size = buf_size & 0xFFFF0000l; + WRITE_REG32(DC_BUF_SIZE, buf_size & 0x0000FFFFl); + } - WRITE_REG32(DC_UNLOCK, lock); - return; + WRITE_REG32(DC_UNLOCK, lock); + return; } /*--------------------------------------------------------------------------- @@ -1580,25 +1579,25 @@ void gfx_set_display_video_size(unsigned short width, unsigned short height) #endif { - unsigned long lock, size, value; + unsigned long lock, size, value; - size = (unsigned long)(width << 1) * (unsigned long)height; + size = (unsigned long) (width << 1) * (unsigned long) height; - /* STORE THE VIDEO BUFFER SIZE AS A GLOBAL */ + /* STORE THE VIDEO BUFFER SIZE AS A GLOBAL */ - vid_buf_size = ((size + 63) >> 6) << 16; + vid_buf_size = ((size + 63) >> 6) << 16; - /* DO NOT SET THE VIDEO SIZE IF VIDEO IS DISABLED */ + /* DO NOT SET THE VIDEO SIZE IF VIDEO IS DISABLED */ - if (!vid_enabled) - return; + if (!vid_enabled) + return; - lock = READ_REG32(DC_UNLOCK); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - value = READ_REG32(DC_BUF_SIZE) & 0x0000FFFF; - value |= vid_buf_size; - WRITE_REG32(DC_BUF_SIZE, value); - WRITE_REG32(DC_UNLOCK, lock); + lock = READ_REG32(DC_UNLOCK); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + value = READ_REG32(DC_BUF_SIZE) & 0x0000FFFF; + value |= vid_buf_size; + WRITE_REG32(DC_BUF_SIZE, value); + WRITE_REG32(DC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1616,13 +1615,13 @@ void gfx_set_display_video_offset(unsigned long offset) #endif { - unsigned long lock; + unsigned long lock; - lock = READ_REG32(DC_UNLOCK); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - offset &= 0x003FFFFF; - WRITE_REG32(DC_VID_ST_OFFSET, offset); - WRITE_REG32(DC_UNLOCK, lock); + lock = READ_REG32(DC_UNLOCK); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + offset &= 0x003FFFFF; + WRITE_REG32(DC_VID_ST_OFFSET, offset); + WRITE_REG32(DC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1642,18 +1641,18 @@ void gfx_set_display_priority_high(int enable) #endif { - unsigned long lock, control; + unsigned long lock, control; - lock = READ_REG32(DC_UNLOCK); - control = READ_REG32(MC_MEM_CNTRL1); - WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); - if (enable) - control |= MC_XBUSARB; - else - control &= ~(MC_XBUSARB); - WRITE_REG32(MC_MEM_CNTRL1, control); - WRITE_REG32(DC_UNLOCK, lock); - return; + lock = READ_REG32(DC_UNLOCK); + control = READ_REG32(MC_MEM_CNTRL1); + WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE); + if (enable) + control |= MC_XBUSARB; + else + control &= ~(MC_XBUSARB); + WRITE_REG32(MC_MEM_CNTRL1, control); + WRITE_REG32(DC_UNLOCK, lock); + return; } /*--------------------------------------------------------------------------- @@ -1668,10 +1667,10 @@ int gfx_test_timing_active(void) #endif { - if (READ_REG32(DC_TIMING_CFG) & DC_TCFG_TGEN) - return (1); - else - return (0); + if (READ_REG32(DC_TIMING_CFG) & DC_TCFG_TGEN) + return (1); + else + return (0); } /*--------------------------------------------------------------------------- @@ -1686,10 +1685,10 @@ int gfx_test_vertical_active(void) #endif { - if (READ_REG32(DC_TIMING_CFG) & DC_TCFG_VNA) - return (0); - else - return (1); + if (READ_REG32(DC_TIMING_CFG) & DC_TCFG_VNA) + return (0); + else + return (1); } /*--------------------------------------------------------------------------- @@ -1704,11 +1703,11 @@ int gfx_wait_vertical_blank(void) #endif { - if (gfx_test_timing_active()) { - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - } - return (0); + if (gfx_test_timing_active()) { + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + } + return (0); } /*--------------------------------------------------------------------------- @@ -1726,53 +1725,53 @@ void gfx_enable_panning(int x, int y) #endif { - unsigned long modeBytesPerPixel; - unsigned long modeBytesPerScanline = 0; - unsigned long startAddress = 0; + unsigned long modeBytesPerPixel; + unsigned long modeBytesPerScanline = 0; + unsigned long startAddress = 0; - modeBytesPerPixel = (gbpp + 7) / 8; - modeBytesPerScanline = - (((ModeWidth + 1023) / 1024) * 1024) * modeBytesPerPixel; + modeBytesPerPixel = (gbpp + 7) / 8; + modeBytesPerScanline = + (((ModeWidth + 1023) / 1024) * 1024) * modeBytesPerPixel; - /* TEST FOR NO-WORK */ + /* TEST FOR NO-WORK */ - if (x >= DeltaX && (unsigned short)x < (PanelWidth + DeltaX) && - y >= DeltaY && (unsigned short)y < (PanelHeight + DeltaY)) - return; + if (x >= DeltaX && (unsigned short) x < (PanelWidth + DeltaX) && + y >= DeltaY && (unsigned short) y < (PanelHeight + DeltaY)) + return; - /* ADJUST PANNING VARIABLES WHEN CURSOR EXCEEDS BOUNDARY */ - /* Test the boundary conditions for each coordinate and update */ - /* all variables and the starting offset accordingly. */ + /* ADJUST PANNING VARIABLES WHEN CURSOR EXCEEDS BOUNDARY */ + /* Test the boundary conditions for each coordinate and update */ + /* all variables and the starting offset accordingly. */ - if (x < DeltaX) - DeltaX = x; + if (x < DeltaX) + DeltaX = x; - else if ((unsigned short)x >= (DeltaX + PanelWidth)) - DeltaX = x - PanelWidth + 1; + else if ((unsigned short) x >= (DeltaX + PanelWidth)) + DeltaX = x - PanelWidth + 1; - if (y < DeltaY) - DeltaY = y; + if (y < DeltaY) + DeltaY = y; - else if ((unsigned short)y >= (DeltaY + PanelHeight)) - DeltaY = y - PanelHeight + 1; + else if ((unsigned short) y >= (DeltaY + PanelHeight)) + DeltaY = y - PanelHeight + 1; - /* CALCULATE THE START OFFSET */ + /* CALCULATE THE START OFFSET */ - startAddress = - (DeltaX * modeBytesPerPixel) + (DeltaY * modeBytesPerScanline); + startAddress = + (DeltaX * modeBytesPerPixel) + (DeltaY * modeBytesPerScanline); - gfx_set_display_offset(startAddress); + gfx_set_display_offset(startAddress); - /* SET PANEL COORDINATES */ - /* Panel's x position must be DWORD aligned */ + /* SET PANEL COORDINATES */ + /* Panel's x position must be DWORD aligned */ - panelTop = DeltaY; - panelLeft = DeltaX * modeBytesPerPixel; + panelTop = DeltaY; + panelLeft = DeltaX * modeBytesPerPixel; - if (panelLeft & 3) - panelLeft = (panelLeft & 0xFFFFFFFC) + 4; + if (panelLeft & 3) + panelLeft = (panelLeft & 0xFFFFFFFC) + 4; - panelLeft /= modeBytesPerPixel; + panelLeft /= modeBytesPerPixel; } @@ -1783,44 +1782,44 @@ gfx_enable_panning(int x, int y) #if GFX_DISPLAY_DYNAMIC int gu1_set_fixed_timings(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) #else int gfx_set_fixed_timings(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) #endif { - unsigned int mode; + unsigned int mode; - ModeWidth = width; - ModeHeight = height; - PanelWidth = (unsigned short)panelResX; - PanelHeight = (unsigned short)panelResY; - PanelEnable = 1; + ModeWidth = width; + ModeHeight = height; + PanelWidth = (unsigned short) panelResX; + PanelHeight = (unsigned short) panelResY; + PanelEnable = 1; - /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ - for (mode = 0; mode < NUM_FIXED_TIMINGS_MODES; mode++) { - if ((FixedParams[mode].xres == width) && - (FixedParams[mode].yres == height) && - (FixedParams[mode].panelresx == panelResX) && - (FixedParams[mode].panelresy == panelResY)) { + /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ + for (mode = 0; mode < NUM_FIXED_TIMINGS_MODES; mode++) { + if ((FixedParams[mode].xres == width) && + (FixedParams[mode].yres == height) && + (FixedParams[mode].panelresx == panelResX) && + (FixedParams[mode].panelresy == panelResY)) { - /* SET THE 92xx FOR THE SELECTED MODE */ - FIXEDTIMINGS *fmode = &FixedParams[mode]; + /* SET THE 92xx FOR THE SELECTED MODE */ + FIXEDTIMINGS *fmode = &FixedParams[mode]; - gfx_set_display_timings(bpp, 3, fmode->hactive, fmode->hblankstart, - fmode->hsyncstart, fmode->hsyncend, - fmode->hblankend, fmode->htotal, - fmode->vactive, fmode->vblankstart, - fmode->vsyncstart, fmode->vsyncend, - fmode->vblankend, fmode->vtotal, - fmode->frequency); + gfx_set_display_timings(bpp, 3, fmode->hactive, fmode->hblankstart, + fmode->hsyncstart, fmode->hsyncend, + fmode->hblankend, fmode->htotal, + fmode->vactive, fmode->vblankstart, + fmode->vsyncstart, fmode->vsyncend, + fmode->vblankend, fmode->vtotal, + fmode->frequency); - return (1); - } /* end if() */ - } /* end for() */ + return (1); + } /* end if() */ + } /* end for() */ - return (-1); + return (-1); } /*--------------------------------------------------------------------------- @@ -1830,37 +1829,37 @@ gfx_set_fixed_timings(int panelResX, int panelResY, unsigned short width, #if GFX_DISPLAY_DYNAMIC int gu1_set_panel_present(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) #else int gfx_set_panel_present(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) #endif { - /* SET VALID BPP */ - /* 16BPP is the default. */ + /* SET VALID BPP */ + /* 16BPP is the default. */ - if (bpp != 8 && bpp != 15 && bpp != 16) - bpp = 16; + if (bpp != 8 && bpp != 15 && bpp != 16) + bpp = 16; - /* RECORD PANEL PARAMETERS */ - /* This routine does not touch any panel timings. It is used when custom panel */ - /* settings are set up in advance by the BIOS or an application, but the */ - /* application still requires access to other panel functionality provided by */ - /* Durango (i.e. panning). */ + /* RECORD PANEL PARAMETERS */ + /* This routine does not touch any panel timings. It is used when custom panel */ + /* settings are set up in advance by the BIOS or an application, but the */ + /* application still requires access to other panel functionality provided by */ + /* Durango (i.e. panning). */ - ModeWidth = width; - ModeHeight = height; - PanelWidth = (unsigned short)panelResX; - PanelHeight = (unsigned short)panelResY; - PanelEnable = 1; - gbpp = bpp; + ModeWidth = width; + ModeHeight = height; + PanelWidth = (unsigned short) panelResX; + PanelHeight = (unsigned short) panelResY; + PanelEnable = 1; + gbpp = bpp; - /* PROGRAM THE BPP IN THE DISPLAY CONTROLLER */ + /* PROGRAM THE BPP IN THE DISPLAY CONTROLLER */ - gfx_set_display_bpp(bpp); + gfx_set_display_bpp(bpp); - return (GFX_STATUS_OK); + return (GFX_STATUS_OK); } /*-----------------------------------------------------------------------* @@ -1888,15 +1887,16 @@ unsigned short gfx_get_display_pitch(void) #endif { - unsigned long value; + unsigned long value; - if (gfx_cpu_version == GFX_CPU_PYRAMID) { /* Pyramid update for 4KB line pitch */ - value = (READ_REG32(DC_LINE_DELTA) & 0x07FF) << 2; - } else { - value = (READ_REG32(DC_LINE_DELTA) & 0x03FF) << 2; - } + if (gfx_cpu_version == GFX_CPU_PYRAMID) { /* Pyramid update for 4KB line pitch */ + value = (READ_REG32(DC_LINE_DELTA) & 0x07FF) << 2; + } + else { + value = (READ_REG32(DC_LINE_DELTA) & 0x03FF) << 2; + } - return ((unsigned short)value); + return ((unsigned short) value); } /*---------------------------------------------------------------------------- @@ -1915,26 +1915,26 @@ int gfx_get_display_details(unsigned int mode, int *xres, int *yres, int *hz) #endif { - if (mode < NUM_GX_DISPLAY_MODES) { - if (DisplayParams[mode].flags & GFX_MODE_56HZ) - *hz = 56; - else if (DisplayParams[mode].flags & GFX_MODE_60HZ) - *hz = 60; - else if (DisplayParams[mode].flags & GFX_MODE_70HZ) - *hz = 70; - else if (DisplayParams[mode].flags & GFX_MODE_72HZ) - *hz = 72; - else if (DisplayParams[mode].flags & GFX_MODE_75HZ) - *hz = 75; - else if (DisplayParams[mode].flags & GFX_MODE_85HZ) - *hz = 85; + if (mode < NUM_GX_DISPLAY_MODES) { + if (DisplayParams[mode].flags & GFX_MODE_56HZ) + *hz = 56; + else if (DisplayParams[mode].flags & GFX_MODE_60HZ) + *hz = 60; + else if (DisplayParams[mode].flags & GFX_MODE_70HZ) + *hz = 70; + else if (DisplayParams[mode].flags & GFX_MODE_72HZ) + *hz = 72; + else if (DisplayParams[mode].flags & GFX_MODE_75HZ) + *hz = 75; + else if (DisplayParams[mode].flags & GFX_MODE_85HZ) + *hz = 85; - *xres = DisplayParams[mode].hactive; - *yres = DisplayParams[mode].vactive; + *xres = DisplayParams[mode].hactive; + *yres = DisplayParams[mode].vactive; - return (1); - } - return (0); + return (1); + } + return (0); } /*---------------------------------------------------------------------------- @@ -1951,7 +1951,7 @@ int gfx_get_display_mode_count(void) #endif { - return (NUM_GX_DISPLAY_MODES); + return (NUM_GX_DISPLAY_MODES); } /*---------------------------------------------------------------------------- @@ -1968,7 +1968,7 @@ unsigned long gfx_get_frame_buffer_line_size(void) #endif { - return ((READ_REG32(DC_BUF_SIZE) & 0x1FF) << 3); + return ((READ_REG32(DC_BUF_SIZE) & 0x1FF) << 3); } /*---------------------------------------------------------------------------- @@ -1982,44 +1982,44 @@ gfx_get_frame_buffer_line_size(void) #if GFX_DISPLAY_DYNAMIC int gu1_mode_frequency_supported(int xres, int yres, int bpp, - unsigned long frequency) + unsigned long frequency) #else int gfx_mode_frequency_supported(int xres, int yres, int bpp, - unsigned long frequency) -#endif -{ - unsigned int index; - unsigned long value; - unsigned long bpp_flag = 0; - - bpp_flag = GFX_MODE_8BPP; - if (bpp > 8) - bpp_flag = GFX_MODE_16BPP; - - for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) { - if ((DisplayParams[index].hactive == (unsigned short)xres) && - (DisplayParams[index].vactive == (unsigned short)yres) && - (DisplayParams[index].flags & bpp_flag) && - (DisplayParams[index].frequency == frequency)) { - int hz = 0; - - value = DisplayParams[index].flags; - - if (value & GFX_MODE_60HZ) - hz = 60; - else if (value & GFX_MODE_70HZ) - hz = 70; - else if (value & GFX_MODE_72HZ) - hz = 72; - else if (value & GFX_MODE_75HZ) - hz = 75; - else if (value & GFX_MODE_85HZ) - hz = 85; - return (hz); - } - } - return (-1); + unsigned long frequency) +#endif +{ + unsigned int index; + unsigned long value; + unsigned long bpp_flag = 0; + + bpp_flag = GFX_MODE_8BPP; + if (bpp > 8) + bpp_flag = GFX_MODE_16BPP; + + for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) { + if ((DisplayParams[index].hactive == (unsigned short) xres) && + (DisplayParams[index].vactive == (unsigned short) yres) && + (DisplayParams[index].flags & bpp_flag) && + (DisplayParams[index].frequency == frequency)) { + int hz = 0; + + value = DisplayParams[index].flags; + + if (value & GFX_MODE_60HZ) + hz = 60; + else if (value & GFX_MODE_70HZ) + hz = 70; + else if (value & GFX_MODE_72HZ) + hz = 72; + else if (value & GFX_MODE_75HZ) + hz = 75; + else if (value & GFX_MODE_85HZ) + hz = 85; + return (hz); + } + } + return (-1); } /*---------------------------------------------------------------------------- @@ -2033,57 +2033,57 @@ gfx_mode_frequency_supported(int xres, int yres, int bpp, #if GFX_DISPLAY_DYNAMIC int gu1_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) #else int gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) #endif { - unsigned int index, closematch = 0; - unsigned long value; - unsigned long bpp_flag = 0; - long min, diff; + unsigned int index, closematch = 0; + unsigned long value; + unsigned long bpp_flag = 0; + long min, diff; - *hz = 60; + *hz = 60; - bpp_flag = GFX_MODE_8BPP; - if (bpp > 8) - bpp_flag = GFX_MODE_16BPP; + bpp_flag = GFX_MODE_8BPP; + if (bpp > 8) + bpp_flag = GFX_MODE_16BPP; - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ - min = 0x7fffffff; - for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) { - if ((DisplayParams[index].htotal == (unsigned short)xres) && - (DisplayParams[index].vtotal == (unsigned short)yres) && - (DisplayParams[index].flags & bpp_flag)) { - diff = (long)frequency - (long)DisplayParams[index].frequency; - if (diff < 0) - diff = -diff; + min = 0x7fffffff; + for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) { + if ((DisplayParams[index].htotal == (unsigned short) xres) && + (DisplayParams[index].vtotal == (unsigned short) yres) && + (DisplayParams[index].flags & bpp_flag)) { + diff = (long) frequency - (long) DisplayParams[index].frequency; + if (diff < 0) + diff = -diff; - if (diff < min) { - min = diff; - closematch = index; - } - } - } + if (diff < min) { + min = diff; + closematch = index; + } + } + } - value = DisplayParams[closematch].flags; + value = DisplayParams[closematch].flags; - if (value & GFX_MODE_60HZ) - *hz = 60; - else if (value & GFX_MODE_70HZ) - *hz = 70; - else if (value & GFX_MODE_72HZ) - *hz = 72; - else if (value & GFX_MODE_75HZ) - *hz = 75; - else if (value & GFX_MODE_85HZ) - *hz = 85; + if (value & GFX_MODE_60HZ) + *hz = 60; + else if (value & GFX_MODE_70HZ) + *hz = 70; + else if (value & GFX_MODE_72HZ) + *hz = 72; + else if (value & GFX_MODE_75HZ) + *hz = 75; + else if (value & GFX_MODE_85HZ) + *hz = 85; - return (1); + return (1); } /*---------------------------------------------------------------------------- @@ -2099,57 +2099,57 @@ gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, #if GFX_DISPLAY_DYNAMIC int gu1_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) #else int gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) #endif { - unsigned int index, closematch = 0; - unsigned long value; - unsigned long bpp_flag = 0; - long min, diff; + unsigned int index, closematch = 0; + unsigned long value; + unsigned long bpp_flag = 0; + long min, diff; - *hz = 60; + *hz = 60; - bpp_flag = GFX_MODE_8BPP; - if (bpp > 8) - bpp_flag = GFX_MODE_16BPP; + bpp_flag = GFX_MODE_8BPP; + if (bpp > 8) + bpp_flag = GFX_MODE_16BPP; - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ - min = 0x7fffffff; - for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) { - if ((DisplayParams[index].hactive == (unsigned short)xres) && - (DisplayParams[index].vactive == (unsigned short)yres) && - (DisplayParams[index].flags & bpp_flag)) { - diff = (long)frequency - (long)DisplayParams[index].frequency; - if (diff < 0) - diff = -diff; + min = 0x7fffffff; + for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) { + if ((DisplayParams[index].hactive == (unsigned short) xres) && + (DisplayParams[index].vactive == (unsigned short) yres) && + (DisplayParams[index].flags & bpp_flag)) { + diff = (long) frequency - (long) DisplayParams[index].frequency; + if (diff < 0) + diff = -diff; - if (diff < min) { - min = diff; - closematch = index; - } - } - } + if (diff < min) { + min = diff; + closematch = index; + } + } + } - value = DisplayParams[closematch].flags; + value = DisplayParams[closematch].flags; - if (value & GFX_MODE_60HZ) - *hz = 60; - else if (value & GFX_MODE_70HZ) - *hz = 70; - else if (value & GFX_MODE_72HZ) - *hz = 72; - else if (value & GFX_MODE_75HZ) - *hz = 75; - else if (value & GFX_MODE_85HZ) - *hz = 85; + if (value & GFX_MODE_60HZ) + *hz = 60; + else if (value & GFX_MODE_70HZ) + *hz = 70; + else if (value & GFX_MODE_72HZ) + *hz = 72; + else if (value & GFX_MODE_75HZ) + *hz = 75; + else if (value & GFX_MODE_85HZ) + *hz = 85; - return (1); + return (1); } /*---------------------------------------------------------------------------- @@ -2161,46 +2161,46 @@ gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, #if GFX_DISPLAY_DYNAMIC int gu1_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, - int *frequency) + int *frequency) #else int gfx_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, - int *frequency) + int *frequency) #endif { - int retval = -1; - unsigned long hz_flag = 0; - unsigned long index, bpp_flag = 0; + int retval = -1; + unsigned long hz_flag = 0; + unsigned long index, bpp_flag = 0; - *frequency = 0; + *frequency = 0; - if (hz == 60) - hz_flag = GFX_MODE_60HZ; - else if (hz == 70) - hz_flag = GFX_MODE_70HZ; - else if (hz == 72) - hz_flag = GFX_MODE_72HZ; - else if (hz == 75) - hz_flag = GFX_MODE_75HZ; - else if (hz == 85) - hz_flag = GFX_MODE_85HZ; + if (hz == 60) + hz_flag = GFX_MODE_60HZ; + else if (hz == 70) + hz_flag = GFX_MODE_70HZ; + else if (hz == 72) + hz_flag = GFX_MODE_72HZ; + else if (hz == 75) + hz_flag = GFX_MODE_75HZ; + else if (hz == 85) + hz_flag = GFX_MODE_85HZ; - bpp_flag = GFX_MODE_8BPP; - if (bpp > 8) - bpp_flag = GFX_MODE_16BPP; + bpp_flag = GFX_MODE_8BPP; + if (bpp > 8) + bpp_flag = GFX_MODE_16BPP; - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) { - if ((DisplayParams[index].hactive == (unsigned short)xres) && - (DisplayParams[index].vactive == (unsigned short)yres) && - (DisplayParams[index].flags & bpp_flag) && - (DisplayParams[index].flags & hz_flag)) { - *frequency = DisplayParams[index].frequency; - retval = 1; - } - } - return retval; + for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) { + if ((DisplayParams[index].hactive == (unsigned short) xres) && + (DisplayParams[index].vactive == (unsigned short) yres) && + (DisplayParams[index].flags & bpp_flag) && + (DisplayParams[index].flags & hz_flag)) { + *frequency = DisplayParams[index].frequency; + retval = 1; + } + } + return retval; } /*--------------------------------------------------------------------------- @@ -2219,9 +2219,9 @@ unsigned long gfx_get_max_supported_pixel_clock(void) #endif { - /* ALL CHIPS CAN HANDLE 1280X1024@85HZ - 157.5 MHz */ + /* ALL CHIPS CAN HANDLE 1280X1024@85HZ - 157.5 MHz */ - return 157500; + return 157500; } /*---------------------------------------------------------------------------- @@ -2240,53 +2240,53 @@ int gfx_get_display_mode(int *xres, int *yres, int *bpp, int *hz) #endif { - unsigned int mode = 0; - unsigned long pll_freq = 0, bpp_flag = 0; + unsigned int mode = 0; + unsigned long pll_freq = 0, bpp_flag = 0; - *xres = gfx_get_hactive(); - *yres = gfx_get_vactive(); - *bpp = gfx_get_display_bpp(); - pll_freq = gfx_get_clock_frequency(); + *xres = gfx_get_hactive(); + *yres = gfx_get_vactive(); + *bpp = gfx_get_display_bpp(); + pll_freq = gfx_get_clock_frequency(); - /* SUPPORT EMULATED VGA MODES */ + /* SUPPORT EMULATED VGA MODES */ - if (gfx_pixel_double) - *xres >>= 1; + if (gfx_pixel_double) + *xres >>= 1; - if (gfx_line_double) - *yres >>= 1; + if (gfx_line_double) + *yres >>= 1; - /* SET BPP FLAGS TO LIMIT MODE SELECTION */ + /* SET BPP FLAGS TO LIMIT MODE SELECTION */ - bpp_flag = GFX_MODE_8BPP; - if (*bpp > 8) - bpp_flag = GFX_MODE_16BPP; + bpp_flag = GFX_MODE_8BPP; + if (*bpp > 8) + bpp_flag = GFX_MODE_16BPP; - for (mode = 0; mode < NUM_GX_DISPLAY_MODES; mode++) { - if ((DisplayParams[mode].hactive == (unsigned short)*xres) && - (DisplayParams[mode].vactive == (unsigned short)*yres) && - (DisplayParams[mode].frequency == pll_freq) && - (DisplayParams[mode].flags & bpp_flag)) { + for (mode = 0; mode < NUM_GX_DISPLAY_MODES; mode++) { + if ((DisplayParams[mode].hactive == (unsigned short) *xres) && + (DisplayParams[mode].vactive == (unsigned short) *yres) && + (DisplayParams[mode].frequency == pll_freq) && + (DisplayParams[mode].flags & bpp_flag)) { - pll_freq = DisplayParams[mode].flags; + pll_freq = DisplayParams[mode].flags; - if (pll_freq & GFX_MODE_56HZ) - *hz = 56; - else if (pll_freq & GFX_MODE_60HZ) - *hz = 60; - else if (pll_freq & GFX_MODE_70HZ) - *hz = 70; - else if (pll_freq & GFX_MODE_72HZ) - *hz = 72; - else if (pll_freq & GFX_MODE_75HZ) - *hz = 75; - else if (pll_freq & GFX_MODE_85HZ) - *hz = 85; + if (pll_freq & GFX_MODE_56HZ) + *hz = 56; + else if (pll_freq & GFX_MODE_60HZ) + *hz = 60; + else if (pll_freq & GFX_MODE_70HZ) + *hz = 70; + else if (pll_freq & GFX_MODE_72HZ) + *hz = 72; + else if (pll_freq & GFX_MODE_75HZ) + *hz = 75; + else if (pll_freq & GFX_MODE_85HZ) + *hz = 85; - return (1); - } - } - return (-1); + return (1); + } + } + return (-1); } /*--------------------------------------------------------------------------- @@ -2301,7 +2301,7 @@ unsigned short gfx_get_hactive(void) #endif { - return ((unsigned short)((READ_REG32(DC_H_TIMING_1) & 0x07F8) + 8)); + return ((unsigned short) ((READ_REG32(DC_H_TIMING_1) & 0x07F8) + 8)); } /*--------------------------------------------------------------------------- @@ -2316,7 +2316,7 @@ unsigned short gfx_get_hsync_start(void) #endif { - return ((unsigned short)((READ_REG32(DC_H_TIMING_3) & 0x07F8) + 8)); + return ((unsigned short) ((READ_REG32(DC_H_TIMING_3) & 0x07F8) + 8)); } /*--------------------------------------------------------------------------- @@ -2331,8 +2331,8 @@ unsigned short gfx_get_hsync_end(void) #endif { - return ((unsigned short)(((READ_REG32(DC_H_TIMING_3) >> 16) & 0x07F8) + - 8)); + return ((unsigned short) (((READ_REG32(DC_H_TIMING_3) >> 16) & 0x07F8) + + 8)); } /*--------------------------------------------------------------------------- @@ -2347,8 +2347,8 @@ unsigned short gfx_get_htotal(void) #endif { - return ((unsigned short)(((READ_REG32(DC_H_TIMING_1) >> 16) & 0x07F8) + - 8)); + return ((unsigned short) (((READ_REG32(DC_H_TIMING_1) >> 16) & 0x07F8) + + 8)); } /*--------------------------------------------------------------------------- @@ -2363,7 +2363,7 @@ unsigned short gfx_get_vactive(void) #endif { - return ((unsigned short)((READ_REG32(DC_V_TIMING_1) & 0x07FF) + 1)); + return ((unsigned short) ((READ_REG32(DC_V_TIMING_1) & 0x07FF) + 1)); } /*--------------------------------------------------------------------------- @@ -2378,8 +2378,8 @@ unsigned short gfx_get_vsync_end(void) #endif { - return ((unsigned short)(((READ_REG32(DC_V_TIMING_3) >> 16) & 0x07FF) + - 1)); + return ((unsigned short) (((READ_REG32(DC_V_TIMING_3) >> 16) & 0x07FF) + + 1)); } /*--------------------------------------------------------------------------- @@ -2394,8 +2394,8 @@ unsigned short gfx_get_vtotal(void) #endif { - return ((unsigned short)(((READ_REG32(DC_V_TIMING_1) >> 16) & 0x07FF) + - 1)); + return ((unsigned short) (((READ_REG32(DC_V_TIMING_1) >> 16) & 0x07FF) + + 1)); } /*----------------------------------------------------------------------------- @@ -2412,13 +2412,13 @@ unsigned short gfx_get_display_bpp(void) #endif { - switch (READ_REG32(DC_OUTPUT_CFG) & 3) { - case 0: - return (16); - case 2: - return (15); - } - return (8); + switch (READ_REG32(DC_OUTPUT_CFG) & 3) { + case 0: + return (16); + case 2: + return (15); + } + return (8); } /*--------------------------------------------------------------------------- @@ -2433,16 +2433,16 @@ unsigned short gfx_get_vline(void) #endif { - unsigned short current_scan_line; + unsigned short current_scan_line; - /* Read similar value twice to ensure that the value is not transitioning */ + /* Read similar value twice to ensure that the value is not transitioning */ - do - current_scan_line = (unsigned short)READ_REG32(DC_V_LINE_CNT) & 0x07FF; - while (current_scan_line != - (unsigned short)(READ_REG32(DC_V_LINE_CNT) & 0x07FF)); + do + current_scan_line = (unsigned short) READ_REG32(DC_V_LINE_CNT) & 0x07FF; + while (current_scan_line != + (unsigned short) (READ_REG32(DC_V_LINE_CNT) & 0x07FF)); - return (current_scan_line); + return (current_scan_line); } /*----------------------------------------------------------------------------- @@ -2457,7 +2457,7 @@ unsigned long gfx_get_display_offset(void) #endif { - return (READ_REG32(DC_FB_ST_OFFSET) & 0x003FFFFF); + return (READ_REG32(DC_FB_ST_OFFSET) & 0x003FFFFF); } /*----------------------------------------------------------------------------- @@ -2472,7 +2472,7 @@ unsigned long gfx_get_cursor_offset(void) #endif { - return (READ_REG32(DC_CURS_ST_OFFSET) & 0x003FFFFF); + return (READ_REG32(DC_CURS_ST_OFFSET) & 0x003FFFFF); } #if GFX_READ_ROUTINES @@ -2493,7 +2493,7 @@ unsigned short gfx_get_hblank_start(void) #endif { - return ((unsigned short)((READ_REG32(DC_H_TIMING_2) & 0x07F8) + 8)); + return ((unsigned short) ((READ_REG32(DC_H_TIMING_2) & 0x07F8) + 8)); } /*--------------------------------------------------------------------------- @@ -2508,8 +2508,8 @@ unsigned short gfx_get_hblank_end(void) #endif { - return ((unsigned short)(((READ_REG32(DC_H_TIMING_2) >> 16) & 0x07F8) + - 8)); + return ((unsigned short) (((READ_REG32(DC_H_TIMING_2) >> 16) & 0x07F8) + + 8)); } /*--------------------------------------------------------------------------- @@ -2524,7 +2524,7 @@ unsigned short gfx_get_vblank_start(void) #endif { - return ((unsigned short)((READ_REG32(DC_V_TIMING_2) & 0x07FF) + 1)); + return ((unsigned short) ((READ_REG32(DC_V_TIMING_2) & 0x07FF) + 1)); } /*--------------------------------------------------------------------------- @@ -2539,7 +2539,7 @@ unsigned short gfx_get_vsync_start(void) #endif { - return ((unsigned short)((READ_REG32(DC_V_TIMING_3) & 0x07FF) + 1)); + return ((unsigned short) ((READ_REG32(DC_V_TIMING_3) & 0x07FF) + 1)); } /*--------------------------------------------------------------------------- @@ -2554,8 +2554,8 @@ unsigned short gfx_get_vblank_end(void) #endif { - return ((unsigned short)(((READ_REG32(DC_V_TIMING_2) >> 16) & 0x07FF) + - 1)); + return ((unsigned short) (((READ_REG32(DC_V_TIMING_2) >> 16) & 0x07FF) + + 1)); } /*----------------------------------------------------------------------------- @@ -2570,19 +2570,19 @@ int gfx_get_display_palette_entry(unsigned long index, unsigned long *palette) #endif { - unsigned long data; + unsigned long data; - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - WRITE_REG32(DC_PAL_ADDRESS, index); - data = READ_REG32(DC_PAL_DATA); - data = ((data << 2) & 0x000000FC) | - ((data << 4) & 0x0000FC00) | ((data << 6) & 0x00FC0000); + WRITE_REG32(DC_PAL_ADDRESS, index); + data = READ_REG32(DC_PAL_DATA); + data = ((data << 2) & 0x000000FC) | + ((data << 4) & 0x0000FC00) | ((data << 6) & 0x00FC0000); - *palette = data; + *palette = data; - return 0; + return 0; } /*----------------------------------------------------------------------------- @@ -2597,15 +2597,15 @@ void gfx_get_display_palette(unsigned long *palette) #endif { - unsigned long i, data; + unsigned long i, data; - WRITE_REG32(DC_PAL_ADDRESS, 0); - for (i = 0; i < 256; i++) { - data = READ_REG32(DC_PAL_DATA); - data = ((data << 2) & 0x000000FC) | - ((data << 4) & 0x0000FC00) | ((data << 6) & 0x00FC0000); - palette[i] = data; - } + WRITE_REG32(DC_PAL_ADDRESS, 0); + for (i = 0; i < 256; i++) { + data = READ_REG32(DC_PAL_DATA); + data = ((data << 2) & 0x000000FC) | + ((data << 4) & 0x0000FC00) | ((data << 6) & 0x00FC0000); + palette[i] = data; + } } /*----------------------------------------------------------------------------- @@ -2620,7 +2620,7 @@ unsigned long gfx_get_cursor_enable(void) #endif { - return (READ_REG32(DC_GENERAL_CFG) & DC_GCFG_CURE); + return (READ_REG32(DC_GENERAL_CFG) & DC_GCFG_CURE); } /*----------------------------------------------------------------------------- @@ -2635,8 +2635,8 @@ unsigned long gfx_get_cursor_position(void) #endif { - return ((READ_REG32(DC_CURSOR_X) & 0x07FF) | - ((READ_REG32(DC_CURSOR_Y) << 16) & 0x03FF0000)); + return ((READ_REG32(DC_CURSOR_X) & 0x07FF) | + ((READ_REG32(DC_CURSOR_Y) << 16) & 0x03FF0000)); } /*----------------------------------------------------------------------------- @@ -2651,8 +2651,8 @@ unsigned long gfx_get_cursor_clip(void) #endif { - return (((READ_REG32(DC_CURSOR_X) >> 11) & 0x01F) | - ((READ_REG32(DC_CURSOR_Y) << 5) & 0x1F0000)); + return (((READ_REG32(DC_CURSOR_X) >> 11) & 0x01F) | + ((READ_REG32(DC_CURSOR_Y) << 5) & 0x1F0000)); } /*----------------------------------------------------------------------------- @@ -2667,17 +2667,18 @@ unsigned long gfx_get_cursor_color(int color) #endif { - unsigned long data; + unsigned long data; - if (color) { - WRITE_REG32(DC_PAL_ADDRESS, 0x101); - } else { - WRITE_REG32(DC_PAL_ADDRESS, 0x100); - } - data = READ_REG32(DC_PAL_DATA); - data = ((data << 6) & 0x00FC0000) | - ((data << 4) & 0x0000FC00) | ((data << 2) & 0x000000FC); - return (data); + if (color) { + WRITE_REG32(DC_PAL_ADDRESS, 0x101); + } + else { + WRITE_REG32(DC_PAL_ADDRESS, 0x100); + } + data = READ_REG32(DC_PAL_DATA); + data = ((data << 6) & 0x00FC0000) | + ((data << 4) & 0x0000FC00) | ((data << 2) & 0x000000FC); + return (data); } /*----------------------------------------------------------------------------- @@ -2692,13 +2693,13 @@ int gfx_get_compression_enable(void) #endif { - unsigned long gcfg; + unsigned long gcfg; - gcfg = READ_REG32(DC_GENERAL_CFG); - if (gcfg & DC_GCFG_CMPE) - return (1); - else - return (0); + gcfg = READ_REG32(DC_GENERAL_CFG); + if (gcfg & DC_GCFG_CMPE) + return (1); + else + return (0); } /*----------------------------------------------------------------------------- @@ -2713,10 +2714,10 @@ unsigned long gfx_get_compression_offset(void) #endif { - unsigned long offset; + unsigned long offset; - offset = READ_REG32(DC_CB_ST_OFFSET) & 0x003FFFFF; - return (offset); + offset = READ_REG32(DC_CB_ST_OFFSET) & 0x003FFFFF; + return (offset); } /*----------------------------------------------------------------------------- @@ -2731,10 +2732,10 @@ unsigned short gfx_get_compression_pitch(void) #endif { - unsigned short pitch; + unsigned short pitch; - pitch = (unsigned short)(READ_REG32(DC_LINE_DELTA) >> 12) & 0x07FF; - return (pitch << 2); + pitch = (unsigned short) (READ_REG32(DC_LINE_DELTA) >> 12) & 0x07FF; + return (pitch << 2); } /*----------------------------------------------------------------------------- @@ -2749,10 +2750,10 @@ unsigned short gfx_get_compression_size(void) #endif { - unsigned short size; + unsigned short size; - size = (unsigned short)((READ_REG32(DC_BUF_SIZE) >> 9) & 0x7F) - 1; - return ((size << 2) + 16); + size = (unsigned short) ((READ_REG32(DC_BUF_SIZE) >> 9) & 0x7F) - 1; + return ((size << 2) + 16); } /*----------------------------------------------------------------------------- @@ -2767,11 +2768,11 @@ int gfx_get_valid_bit(int line) #endif { - int valid; + int valid; - WRITE_REG32(MC_DR_ADD, line); - valid = (int)READ_REG32(MC_DR_ACC) & 1; - return (valid); + WRITE_REG32(MC_DR_ADD, line); + valid = (int) READ_REG32(MC_DR_ACC) & 1; + return (valid); } /*--------------------------------------------------------------------------- @@ -2789,7 +2790,7 @@ unsigned long gfx_get_display_video_offset(void) #endif { - return (READ_REG32(DC_VID_ST_OFFSET) & 0x003FFFFF); + return (READ_REG32(DC_VID_ST_OFFSET) & 0x003FFFFF); } /*--------------------------------------------------------------------------- @@ -2807,9 +2808,9 @@ unsigned long gfx_get_display_video_size(void) #endif { - /* RETURN TOTAL SIZE, IN BYTES */ + /* RETURN TOTAL SIZE, IN BYTES */ - return ((READ_REG32(DC_BUF_SIZE) >> 10) & 0x000FFFC0); + return ((READ_REG32(DC_BUF_SIZE) >> 10) & 0x000FFFC0); } /*----------------------------------------------------------------------------- @@ -2824,12 +2825,12 @@ int gfx_get_display_priority_high(void) #endif { - if (READ_REG32(MC_MEM_CNTRL1) & MC_XBUSARB) - return (1); - else - return (0); + if (READ_REG32(MC_MEM_CNTRL1) & MC_XBUSARB) + return (1); + else + return (0); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ diff --git a/src/gfx/disp_gu2.c b/src/gfx/disp_gu2.c index ba72e88..a713234 100644 --- a/src/gfx/disp_gu2.c +++ b/src/gfx/disp_gu2.c @@ -128,23 +128,23 @@ * * END_NSC_LIC_GPL */ -void gu2_enable_compression(void); /* private routine definition */ -void gu2_disable_compression(void); /* private routine definition */ +void gu2_enable_compression(void); /* private routine definition */ +void gu2_disable_compression(void); /* private routine definition */ int gu2_set_display_bpp(unsigned short bpp); int gu2_is_display_mode_supported(int xres, int yres, int bpp, int hz); int gu2_set_display_mode(int xres, int yres, int bpp, int hz); int gu2_set_display_timings(unsigned short bpp, unsigned short flags, - unsigned short hactive, - unsigned short hblank_start, - unsigned short hsync_start, - unsigned short hsync_end, - unsigned short hblank_end, unsigned short htotal, - unsigned short vactive, - unsigned short vblank_start, - unsigned short vsync_start, - unsigned short vsync_end, - unsigned short vblank_end, unsigned short vtotal, - unsigned long frequency); + unsigned short hactive, + unsigned short hblank_start, + unsigned short hsync_start, + unsigned short hsync_end, + unsigned short hblank_end, unsigned short htotal, + unsigned short vactive, + unsigned short vblank_start, + unsigned short vsync_start, + unsigned short vsync_end, + unsigned short vblank_end, unsigned short vtotal, + unsigned long frequency); int gu2_set_vtotal(unsigned short vtotal); void gu2_set_display_pitch(unsigned short pitch); void gu2_set_display_offset(unsigned long offset); @@ -156,19 +156,18 @@ int gu2_set_crt_enable(int enable); void gu2_set_cursor_enable(int enable); void gu2_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor); void gu2_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, - unsigned short yhotspot); + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, unsigned short yhotspot); void gu2_set_cursor_shape32(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask); + unsigned long *xormask); void gu2_set_cursor_shape64(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask); + unsigned long *xormask); void gu2_set_icon_enable(int enable); void gu2_set_icon_colors(unsigned long color0, unsigned long color1, - unsigned long color2); + unsigned long color2); void gu2_set_icon_position(unsigned long memoffset, unsigned short xpos); void gu2_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask, unsigned int lines); + unsigned long *xormask, unsigned int lines); int gu2_set_compression_enable(int enable); int gu2_set_compression_offset(unsigned long offset); @@ -182,9 +181,9 @@ void gu2_delay_milliseconds(unsigned long milliseconds); void gu2_delay_microseconds(unsigned long microseconds); void gu2_enable_panning(int x, int y); int gu2_set_fixed_timings(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp); + unsigned short height, unsigned short bpp); int gu2_set_panel_present(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp); + unsigned short height, unsigned short bpp); void gu2_reset_timing_lock(void); int gu2_get_display_details(unsigned int mode, int *xres, int *yres, int *hz); @@ -194,13 +193,13 @@ int gu2_get_sync_polarities(void); unsigned long gu2_get_clock_frequency(void); unsigned long gu2_get_max_supported_pixel_clock(void); int gu2_mode_frequency_supported(int xres, int yres, int bpp, - unsigned long frequency); + unsigned long frequency); int gu2_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, - unsigned long frequency); + unsigned long frequency); int gu2_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, - unsigned long frequency); + unsigned long frequency); int gu2_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, - int *frequency); + int *frequency); int gu2_get_display_mode_count(void); int gu2_get_display_mode(int *xres, int *yres, int *bpp, int *hz); unsigned long gu2_get_frame_buffer_line_size(void); @@ -219,8 +218,7 @@ unsigned short gu2_get_vblank_end(void); unsigned short gu2_get_vtotal(void); unsigned short gu2_get_display_bpp(void); unsigned long gu2_get_display_offset(void); -int gu2_get_display_palette_entry(unsigned long index, - unsigned long *palette); +int gu2_get_display_palette_entry(unsigned long index, unsigned long *palette); void gu2_get_display_palette(unsigned long *palette); unsigned long gu2_get_cursor_enable(void); unsigned long gu2_get_cursor_offset(void); @@ -243,21 +241,20 @@ void gu2_set_display_video_offset(unsigned long offset); unsigned long gu2_get_display_video_offset(void); unsigned long gu2_get_display_video_size(void); void gu2_get_display_video_yuv_pitch(unsigned long *ypitch, - unsigned long *uvpitch); + unsigned long *uvpitch); int gu2_get_display_video_downscale_enable(void); void gu2_set_display_video_format(unsigned long format); void gu2_set_display_video_enable(int enable); void gu2_set_display_video_yuv_offsets(unsigned long yoffset, - unsigned long uoffset, - unsigned long voffset); + unsigned long uoffset, + unsigned long voffset); void gu2_set_display_video_yuv_pitch(unsigned long ypitch, - unsigned long uvpitch); -void gu2_set_display_video_downscale(unsigned short srch, - unsigned short dsth); + unsigned long uvpitch); +void gu2_set_display_video_downscale(unsigned short srch, unsigned short dsth); void gu2_set_display_video_vertical_downscale_enable(int enable); void gu2_get_display_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset); + unsigned long *uoffset, + unsigned long *voffset); unsigned long gu2_get_display_video_downscale_delta(void); /*----------------------------------------------------------------------------- @@ -279,16 +276,16 @@ void gfx_delay_milliseconds(unsigned long milliseconds) #endif { - /* ASSUME 300 MHZ 20 CLOCKS PER READ */ + /* ASSUME 300 MHZ 20 CLOCKS PER READ */ # define RC_READS_PER_MILLISECOND 15000L - unsigned long loop; + unsigned long loop; - loop = milliseconds * RC_READS_PER_MILLISECOND; - while (loop-- > 0) { - READ_REG32(MDC_UNLOCK); - } + loop = milliseconds * RC_READS_PER_MILLISECOND; + while (loop-- > 0) { + READ_REG32(MDC_UNLOCK); + } } #if GFX_DISPLAY_DYNAMIC @@ -299,13 +296,13 @@ void gfx_delay_microseconds(unsigned long microseconds) #endif { - /* ASSUME 400 MHz, 2 CLOCKS PER INCREMENT */ + /* ASSUME 400 MHz, 2 CLOCKS PER INCREMENT */ - unsigned long loop_count = microseconds * 15; + unsigned long loop_count = microseconds * 15; - while (loop_count-- > 0) { - READ_REG32(MDC_UNLOCK); - } + while (loop_count-- > 0) { + READ_REG32(MDC_UNLOCK); + } } /*----------------------------------------------------------------------------- @@ -322,41 +319,41 @@ int gfx_set_display_bpp(unsigned short bpp) #endif { - unsigned long dcfg, lock; + unsigned long dcfg, lock; - dcfg = READ_REG32(MDC_DISPLAY_CFG) & ~(MDC_DCFG_DISP_MODE_MASK | - MDC_DCFG_16BPP_MODE_MASK); - lock = READ_REG32(MDC_UNLOCK); + dcfg = READ_REG32(MDC_DISPLAY_CFG) & ~(MDC_DCFG_DISP_MODE_MASK | + MDC_DCFG_16BPP_MODE_MASK); + lock = READ_REG32(MDC_UNLOCK); - switch (bpp) { - case 12: - dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_12BPP); - break; - case 15: - dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_15BPP); - break; - case 16: - dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_16BPP); - break; - case 32: - dcfg |= (MDC_DCFG_DISP_MODE_24BPP); - break; - case 8: - dcfg |= (MDC_DCFG_DISP_MODE_8BPP); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } + switch (bpp) { + case 12: + dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_12BPP); + break; + case 15: + dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_15BPP); + break; + case 16: + dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_16BPP); + break; + case 32: + dcfg |= (MDC_DCFG_DISP_MODE_24BPP); + break; + case 8: + dcfg |= (MDC_DCFG_DISP_MODE_8BPP); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_DISPLAY_CFG, dcfg); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_DISPLAY_CFG, dcfg); + WRITE_REG32(MDC_UNLOCK, lock); - /* SET BPP IN GRAPHICS PIPELINE */ + /* SET BPP IN GRAPHICS PIPELINE */ - gfx_set_bpp(bpp); + gfx_set_bpp(bpp); - return 0; + return 0; } /*----------------------------------------------------------------------------- @@ -368,251 +365,251 @@ gfx_set_display_bpp(unsigned short bpp) int gu2_set_specified_mode(DISPLAYMODE * pMode, int bpp) { - unsigned long unlock, value; - unsigned long gcfg, dcfg; - unsigned long size, pitch; - unsigned long vid_buf_size; - unsigned long bpp_mask, temp, dv_size; + unsigned long unlock, value; + unsigned long gcfg, dcfg; + unsigned long size, pitch; + unsigned long vid_buf_size; + unsigned long bpp_mask, temp, dv_size; - /* CHECK WHETHER TIMING CHANGE IS ALLOWED */ - /* Flag used for locking also overrides timing change restriction */ + /* CHECK WHETHER TIMING CHANGE IS ALLOWED */ + /* Flag used for locking also overrides timing change restriction */ - if (gfx_timing_lock && !(pMode->flags & GFX_MODE_LOCK_TIMING)) - return GFX_STATUS_ERROR; + if (gfx_timing_lock && !(pMode->flags & GFX_MODE_LOCK_TIMING)) + return GFX_STATUS_ERROR; - /* CLEAR PANNING OFFSETS */ + /* CLEAR PANNING OFFSETS */ - DeltaX = 0; - DeltaY = 0; - panelLeft = 0; - panelTop = 0; + DeltaX = 0; + DeltaY = 0; + panelLeft = 0; + panelTop = 0; - /* SET GLOBAL FLAG */ + /* SET GLOBAL FLAG */ - if (pMode->flags & GFX_MODE_LOCK_TIMING) - gfx_timing_lock = 1; + if (pMode->flags & GFX_MODE_LOCK_TIMING) + gfx_timing_lock = 1; - /* CHECK FOR VALID BPP */ - /* As this function can be called directly from */ - /* gfx_set_display_timings, we must correct any */ - /* invalid bpp settings. */ + /* CHECK FOR VALID BPP */ + /* As this function can be called directly from */ + /* gfx_set_display_timings, we must correct any */ + /* invalid bpp settings. */ - switch (bpp) { - case 12: - bpp_mask = 0x00000900; - break; - case 15: - bpp_mask = 0x00000500; - break; - case 16: - bpp_mask = 0x00000100; - break; - case 32: - bpp_mask = 0x00000200; - break; - default: - bpp_mask = 0x00000000; - bpp = 8; - break; - } + switch (bpp) { + case 12: + bpp_mask = 0x00000900; + break; + case 15: + bpp_mask = 0x00000500; + break; + case 16: + bpp_mask = 0x00000100; + break; + case 32: + bpp_mask = 0x00000200; + break; + default: + bpp_mask = 0x00000000; + bpp = 8; + break; + } - gbpp = bpp; + gbpp = bpp; - /* DISABLE COMPRESSION */ + /* DISABLE COMPRESSION */ - gu2_disable_compression(); + gu2_disable_compression(); - /* ALSO DISABLE VIDEO */ - /* Use private "reset video" routine to do all that is needed. */ - /* SC1200, for example, also disables the alpha blending regions. */ + /* ALSO DISABLE VIDEO */ + /* Use private "reset video" routine to do all that is needed. */ + /* SC1200, for example, also disables the alpha blending regions. */ - gfx_reset_video(); + gfx_reset_video(); - /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ + /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ - unlock = READ_REG32(MDC_UNLOCK); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + unlock = READ_REG32(MDC_UNLOCK); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - /* READ THE CURRENT REGISTER VALUES */ + /* READ THE CURRENT REGISTER VALUES */ - gcfg = READ_REG32(MDC_GENERAL_CFG); - dcfg = READ_REG32(MDC_DISPLAY_CFG); + gcfg = READ_REG32(MDC_GENERAL_CFG); + dcfg = READ_REG32(MDC_DISPLAY_CFG); - /* BLANK THE DISPLAY IN THE DISPLAY FILTER */ + /* BLANK THE DISPLAY IN THE DISPLAY FILTER */ - gfx_set_crt_enable(0); + gfx_set_crt_enable(0); - /* DISABLE THE TIMING GENERATOR */ + /* DISABLE THE TIMING GENERATOR */ - dcfg &= ~(unsigned long)MDC_DCFG_TGEN; - WRITE_REG32(MDC_DISPLAY_CFG, dcfg); + dcfg &= ~(unsigned long) MDC_DCFG_TGEN; + WRITE_REG32(MDC_DISPLAY_CFG, dcfg); - /* DELAY: WAIT FOR PENDING MEMORY REQUESTS */ - /* This delay is used to make sure that all pending requests to the */ - /* memory controller have completed before disabling the FIFO load. */ + /* DELAY: WAIT FOR PENDING MEMORY REQUESTS */ + /* This delay is used to make sure that all pending requests to the */ + /* memory controller have completed before disabling the FIFO load. */ - gfx_delay_milliseconds(5); + gfx_delay_milliseconds(5); - /* DISABLE DISPLAY FIFO LOAD */ + /* DISABLE DISPLAY FIFO LOAD */ - gcfg &= ~(unsigned long)MDC_GCFG_DFLE; - WRITE_REG32(MDC_GENERAL_CFG, gcfg); + gcfg &= ~(unsigned long) MDC_GCFG_DFLE; + WRITE_REG32(MDC_GENERAL_CFG, gcfg); - /* PRESERVE VIDEO INFORMATION */ + /* PRESERVE VIDEO INFORMATION */ - gcfg &= (unsigned long)(MDC_GCFG_YUVM | MDC_GCFG_VDSE); - dcfg = 0; + gcfg &= (unsigned long) (MDC_GCFG_YUVM | MDC_GCFG_VDSE); + dcfg = 0; - /* SET THE DOT CLOCK FREQUENCY */ - /* Mask off the divide by two bit (bit 31) */ + /* SET THE DOT CLOCK FREQUENCY */ + /* Mask off the divide by two bit (bit 31) */ - gfx_set_clock_frequency(pMode->frequency & 0x7FFFFFFF); + gfx_set_clock_frequency(pMode->frequency & 0x7FFFFFFF); - /* DELAY: WAIT FOR THE PLL TO SETTLE */ - /* This allows the dot clock frequency that was just set to settle. */ + /* DELAY: WAIT FOR THE PLL TO SETTLE */ + /* This allows the dot clock frequency that was just set to settle. */ - gfx_delay_milliseconds(10); + gfx_delay_milliseconds(10); - /* SET THE GX DISPLAY CONTROLLER PARAMETERS */ + /* SET THE GX DISPLAY CONTROLLER PARAMETERS */ - WRITE_REG32(MDC_FB_ST_OFFSET, 0); - WRITE_REG32(MDC_CB_ST_OFFSET, 0); - WRITE_REG32(MDC_CURS_ST_OFFSET, 0); - WRITE_REG32(MDC_ICON_ST_OFFSET, 0); + WRITE_REG32(MDC_FB_ST_OFFSET, 0); + WRITE_REG32(MDC_CB_ST_OFFSET, 0); + WRITE_REG32(MDC_CURS_ST_OFFSET, 0); + WRITE_REG32(MDC_ICON_ST_OFFSET, 0); - /* SET LINE SIZE AND PITCH */ - /* 1. Flat Panels must use the mode width and not */ - /* the timing width to set the pitch. */ - /* 2. Mode sets will use a pitch that is aligned */ - /* on a 1K boundary to preserve legacy. The */ - /* pitch can be overridden by a subsequent call */ - /* to gfx_set_display_pitch. */ + /* SET LINE SIZE AND PITCH */ + /* 1. Flat Panels must use the mode width and not */ + /* the timing width to set the pitch. */ + /* 2. Mode sets will use a pitch that is aligned */ + /* on a 1K boundary to preserve legacy. The */ + /* pitch can be overridden by a subsequent call */ + /* to gfx_set_display_pitch. */ - if (PanelEnable) - size = ModeWidth; - else - size = pMode->hactive; + if (PanelEnable) + size = ModeWidth; + else + size = pMode->hactive; - if (bpp > 8) - size <<= 1; - if (bpp > 16) - size <<= 1; + if (bpp > 8) + size <<= 1; + if (bpp > 16) + size <<= 1; - pitch = 1024; - dv_size = MDC_DV_LINE_SIZE_1024; + pitch = 1024; + dv_size = MDC_DV_LINE_SIZE_1024; - if (size > 1024) { - pitch = 2048; - dv_size = MDC_DV_LINE_SIZE_2048; - } - if (size > 2048) { - pitch = 4096; - dv_size = MDC_DV_LINE_SIZE_4096; - } - if (size > 4096) { - pitch = 8192; - dv_size = MDC_DV_LINE_SIZE_8192; - } - WRITE_REG32(MDC_GFX_PITCH, pitch >> 3); + if (size > 1024) { + pitch = 2048; + dv_size = MDC_DV_LINE_SIZE_2048; + } + if (size > 2048) { + pitch = 4096; + dv_size = MDC_DV_LINE_SIZE_4096; + } + if (size > 4096) { + pitch = 8192; + dv_size = MDC_DV_LINE_SIZE_8192; + } + WRITE_REG32(MDC_GFX_PITCH, pitch >> 3); - /* WRITE DIRTY/VALID CONTROL WITH LINE LENGTH */ + /* 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); + temp = READ_REG32(MDC_DV_CTL); + WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size); - if (PanelEnable) { - size = pMode->hactive; - if (bpp > 8) - size <<= 1; - if (bpp > 16) - size <<= 1; - } + if (PanelEnable) { + size = pMode->hactive; + if (bpp > 8) + size <<= 1; + if (bpp > 16) + size <<= 1; + } - /* SAVE PREVIOUSLY STORED VIDEO LINE SIZE */ + /* SAVE PREVIOUSLY STORED VIDEO LINE SIZE */ - vid_buf_size = READ_REG32(MDC_LINE_SIZE) & 0xFF000000; + vid_buf_size = READ_REG32(MDC_LINE_SIZE) & 0xFF000000; - /* ADD 2 TO SIZE FOR POSSIBLE START ADDRESS ALIGNMENTS */ + /* ADD 2 TO SIZE FOR POSSIBLE START ADDRESS ALIGNMENTS */ - WRITE_REG32(MDC_LINE_SIZE, ((size >> 3) + 2) | vid_buf_size); + WRITE_REG32(MDC_LINE_SIZE, ((size >> 3) + 2) | vid_buf_size); - /* ALWAYS ENABLE VIDEO AND GRAPHICS DATA */ - /* These bits are relics from a previous design and */ - /* should always be enabled. */ + /* ALWAYS ENABLE VIDEO AND GRAPHICS DATA */ + /* These bits are relics from a previous design and */ + /* should always be enabled. */ - dcfg |= (unsigned long)(MDC_DCFG_VDEN | MDC_DCFG_GDEN); + dcfg |= (unsigned long) (MDC_DCFG_VDEN | MDC_DCFG_GDEN); - /* SET PIXEL FORMAT */ + /* SET PIXEL FORMAT */ - dcfg |= bpp_mask; + dcfg |= bpp_mask; - /* ENABLE TIMING GENERATOR, TIM. REG. UPDATES, PALETTE BYPASS */ - /* AND VERT. INT. SELECT */ + /* ENABLE TIMING GENERATOR, TIM. REG. UPDATES, PALETTE BYPASS */ + /* AND VERT. INT. SELECT */ - dcfg |= - (unsigned long)(MDC_DCFG_TGEN | MDC_DCFG_TRUP | MDC_DCFG_PALB | - MDC_DCFG_VISL); + dcfg |= + (unsigned long) (MDC_DCFG_TGEN | MDC_DCFG_TRUP | MDC_DCFG_PALB | + MDC_DCFG_VISL); - /* DISABLE ADDRESS MASKS */ + /* DISABLE ADDRESS MASKS */ - dcfg |= MDC_DCFG_A20M; - dcfg |= MDC_DCFG_A18M; + dcfg |= MDC_DCFG_A20M; + dcfg |= MDC_DCFG_A18M; - /* SET FIFO PRIORITIES AND DISPLAY FIFO LOAD ENABLE */ - /* Set the priorities higher for high resolution modes. */ + /* SET FIFO PRIORITIES AND DISPLAY FIFO LOAD ENABLE */ + /* Set the priorities higher for high resolution modes. */ - if (pMode->hactive > 1024 || bpp == 32) - gcfg |= 0x000A901; - else - gcfg |= 0x0006501; + if (pMode->hactive > 1024 || bpp == 32) + gcfg |= 0x000A901; + else + gcfg |= 0x0006501; - /* ENABLE FLAT PANEL CENTERING */ - /* For panel modes having a resolution smaller than the */ - /* panel resolution, turn on data centering. */ + /* ENABLE FLAT PANEL CENTERING */ + /* For panel modes having a resolution smaller than the */ + /* panel resolution, turn on data centering. */ - if (PanelEnable && ModeWidth < PanelWidth) - dcfg |= MDC_DCFG_DCEN; + if (PanelEnable && ModeWidth < PanelWidth) + dcfg |= MDC_DCFG_DCEN; - /* COMBINE AND SET TIMING VALUES */ + /* COMBINE AND SET TIMING VALUES */ - value = (unsigned long)(pMode->hactive - 1) | - (((unsigned long)(pMode->htotal - 1)) << 16); - WRITE_REG32(MDC_H_ACTIVE_TIMING, value); - value = (unsigned long)(pMode->hblankstart - 1) | - (((unsigned long)(pMode->hblankend - 1)) << 16); - WRITE_REG32(MDC_H_BLANK_TIMING, value); - value = (unsigned long)(pMode->hsyncstart - 1) | - (((unsigned long)(pMode->hsyncend - 1)) << 16); - WRITE_REG32(MDC_H_SYNC_TIMING, value); - value = (unsigned long)(pMode->vactive - 1) | - (((unsigned long)(pMode->vtotal - 1)) << 16); - WRITE_REG32(MDC_V_ACTIVE_TIMING, value); - value = (unsigned long)(pMode->vblankstart - 1) | - (((unsigned long)(pMode->vblankend - 1)) << 16); - WRITE_REG32(MDC_V_BLANK_TIMING, value); - value = (unsigned long)(pMode->vsyncstart - 1) | - (((unsigned long)(pMode->vsyncend - 1)) << 16); - WRITE_REG32(MDC_V_SYNC_TIMING, value); + value = (unsigned long) (pMode->hactive - 1) | + (((unsigned long) (pMode->htotal - 1)) << 16); + WRITE_REG32(MDC_H_ACTIVE_TIMING, value); + value = (unsigned long) (pMode->hblankstart - 1) | + (((unsigned long) (pMode->hblankend - 1)) << 16); + WRITE_REG32(MDC_H_BLANK_TIMING, value); + value = (unsigned long) (pMode->hsyncstart - 1) | + (((unsigned long) (pMode->hsyncend - 1)) << 16); + WRITE_REG32(MDC_H_SYNC_TIMING, value); + value = (unsigned long) (pMode->vactive - 1) | + (((unsigned long) (pMode->vtotal - 1)) << 16); + WRITE_REG32(MDC_V_ACTIVE_TIMING, value); + value = (unsigned long) (pMode->vblankstart - 1) | + (((unsigned long) (pMode->vblankend - 1)) << 16); + WRITE_REG32(MDC_V_BLANK_TIMING, value); + value = (unsigned long) (pMode->vsyncstart - 1) | + (((unsigned long) (pMode->vsyncend - 1)) << 16); + WRITE_REG32(MDC_V_SYNC_TIMING, value); - WRITE_REG32(MDC_DISPLAY_CFG, dcfg); - WRITE_REG32(MDC_GENERAL_CFG, gcfg); + WRITE_REG32(MDC_DISPLAY_CFG, dcfg); + WRITE_REG32(MDC_GENERAL_CFG, gcfg); - /* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */ + /* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */ - gfx_set_display_control(((pMode->flags & GFX_MODE_NEG_HSYNC) ? 1 : 0) | - ((pMode->flags & GFX_MODE_NEG_VSYNC) ? 2 : 0)); + gfx_set_display_control(((pMode->flags & GFX_MODE_NEG_HSYNC) ? 1 : 0) | + ((pMode->flags & GFX_MODE_NEG_VSYNC) ? 2 : 0)); - /* RESTORE VALUE OF MDC_UNLOCK */ + /* RESTORE VALUE OF MDC_UNLOCK */ - WRITE_REG32(MDC_UNLOCK, unlock); + WRITE_REG32(MDC_UNLOCK, unlock); - /* RESET THE PITCH VALUES IN THE GP */ + /* RESET THE PITCH VALUES IN THE GP */ - gfx_reset_pitch((unsigned short)pitch); + gfx_reset_pitch((unsigned short) pitch); - gfx_set_bpp((unsigned short)bpp); + gfx_set_bpp((unsigned short) bpp); - return GFX_STATUS_OK; + return GFX_STATUS_OK; } /*---------------------------------------------------------------------------- @@ -631,66 +628,66 @@ int gfx_is_display_mode_supported(int xres, int yres, int bpp, int hz) #endif { - unsigned int mode; - unsigned long hz_flag = 0, bpp_flag = 0; - - /* SET FLAGS TO MATCH REFRESH RATE */ - - if (hz == 56) - hz_flag = GFX_MODE_56HZ; - if (hz == 60) - hz_flag = GFX_MODE_60HZ; - if (hz == 70) - hz_flag = GFX_MODE_70HZ; - if (hz == 72) - hz_flag = GFX_MODE_72HZ; - if (hz == 75) - hz_flag = GFX_MODE_75HZ; - if (hz == 85) - hz_flag = GFX_MODE_85HZ; - - /* SET BPP FLAGS TO LIMIT MODE SELECTION */ - - switch (bpp) { - case 8: - bpp_flag = GFX_MODE_8BPP; - break; - case 12: - bpp_flag = GFX_MODE_12BPP; - break; - case 15: - bpp_flag = GFX_MODE_15BPP; - break; - case 16: - bpp_flag = GFX_MODE_16BPP; - break; - case 32: - bpp_flag = GFX_MODE_24BPP; - break; - default: - return (-1); - } - - /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ - - for (mode = 0; mode < NUM_RC_DISPLAY_MODES; mode++) { - if ((DisplayParams[mode].hactive == (unsigned short)xres) && - (DisplayParams[mode].vactive == (unsigned short)yres) && - (DisplayParams[mode].flags & hz_flag) && - (DisplayParams[mode].flags & bpp_flag)) { - - /* REDCLOUD DOES NOT SUPPORT EMULATED VGA MODES */ - - if ((DisplayParams[mode].flags & GFX_MODE_PIXEL_DOUBLE) || - (DisplayParams[mode].flags & GFX_MODE_LINE_DOUBLE)) - continue; - - /* SET THE DISPLAY CONTROLLER FOR THE SELECTED MODE */ - - return (mode); - } - } - return (-1); + unsigned int mode; + unsigned long hz_flag = 0, bpp_flag = 0; + + /* SET FLAGS TO MATCH REFRESH RATE */ + + if (hz == 56) + hz_flag = GFX_MODE_56HZ; + if (hz == 60) + hz_flag = GFX_MODE_60HZ; + if (hz == 70) + hz_flag = GFX_MODE_70HZ; + if (hz == 72) + hz_flag = GFX_MODE_72HZ; + if (hz == 75) + hz_flag = GFX_MODE_75HZ; + if (hz == 85) + hz_flag = GFX_MODE_85HZ; + + /* SET BPP FLAGS TO LIMIT MODE SELECTION */ + + switch (bpp) { + case 8: + bpp_flag = GFX_MODE_8BPP; + break; + case 12: + bpp_flag = GFX_MODE_12BPP; + break; + case 15: + bpp_flag = GFX_MODE_15BPP; + break; + case 16: + bpp_flag = GFX_MODE_16BPP; + break; + case 32: + bpp_flag = GFX_MODE_24BPP; + break; + default: + return (-1); + } + + /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ + + for (mode = 0; mode < NUM_RC_DISPLAY_MODES; mode++) { + if ((DisplayParams[mode].hactive == (unsigned short) xres) && + (DisplayParams[mode].vactive == (unsigned short) yres) && + (DisplayParams[mode].flags & hz_flag) && + (DisplayParams[mode].flags & bpp_flag)) { + + /* REDCLOUD DOES NOT SUPPORT EMULATED VGA MODES */ + + if ((DisplayParams[mode].flags & GFX_MODE_PIXEL_DOUBLE) || + (DisplayParams[mode].flags & GFX_MODE_LINE_DOUBLE)) + continue; + + /* SET THE DISPLAY CONTROLLER FOR THE SELECTED MODE */ + + return (mode); + } + } + return (-1); } /*---------------------------------------------------------------------------- @@ -709,20 +706,20 @@ int gfx_set_display_mode(int xres, int yres, int bpp, int hz) #endif { - int mode; + int mode; - /* DISABLE FLAT PANEL */ - /* Flat Panel settings are enabled by the function gfx_set_fixed_timings */ - /* and disabled by gfx_set_display_mode. */ + /* DISABLE FLAT PANEL */ + /* Flat Panel settings are enabled by the function gfx_set_fixed_timings */ + /* and disabled by gfx_set_display_mode. */ - PanelEnable = 0; + PanelEnable = 0; - mode = gfx_is_display_mode_supported(xres, yres, bpp, hz); - if (mode >= 0) { - if (gu2_set_specified_mode(&DisplayParams[mode], bpp) == GFX_STATUS_OK) - return (1); - } - return (0); + mode = gfx_is_display_mode_supported(xres, yres, bpp, hz); + if (mode >= 0) { + if (gu2_set_specified_mode(&DisplayParams[mode], bpp) == GFX_STATUS_OK) + return (1); + } + return (0); } /*---------------------------------------------------------------------------- @@ -737,51 +734,51 @@ gfx_set_display_mode(int xres, int yres, int bpp, int hz) #if GFX_DISPLAY_DYNAMIC int gu2_set_display_timings(unsigned short bpp, unsigned short flags, - unsigned short hactive, unsigned short hblankstart, - unsigned short hsyncstart, unsigned short hsyncend, - unsigned short hblankend, unsigned short htotal, - unsigned short vactive, unsigned short vblankstart, - unsigned short vsyncstart, unsigned short vsyncend, - unsigned short vblankend, unsigned short vtotal, - unsigned long frequency) + unsigned short hactive, unsigned short hblankstart, + unsigned short hsyncstart, unsigned short hsyncend, + unsigned short hblankend, unsigned short htotal, + unsigned short vactive, unsigned short vblankstart, + unsigned short vsyncstart, unsigned short vsyncend, + unsigned short vblankend, unsigned short vtotal, + unsigned long frequency) #else int gfx_set_display_timings(unsigned short bpp, unsigned short flags, - unsigned short hactive, unsigned short hblankstart, - unsigned short hsyncstart, unsigned short hsyncend, - unsigned short hblankend, unsigned short htotal, - unsigned short vactive, unsigned short vblankstart, - unsigned short vsyncstart, unsigned short vsyncend, - unsigned short vblankend, unsigned short vtotal, - unsigned long frequency) -#endif -{ - /* SET MODE STRUCTURE WITH SPECIFIED VALUES */ - - gfx_display_mode.flags = 0; - if (flags & 1) - gfx_display_mode.flags |= GFX_MODE_NEG_HSYNC; - if (flags & 2) - gfx_display_mode.flags |= GFX_MODE_NEG_VSYNC; - if (flags & 0x1000) - gfx_display_mode.flags |= GFX_MODE_LOCK_TIMING; - gfx_display_mode.hactive = hactive; - gfx_display_mode.hblankstart = hblankstart; - gfx_display_mode.hsyncstart = hsyncstart; - gfx_display_mode.hsyncend = hsyncend; - gfx_display_mode.hblankend = hblankend; - gfx_display_mode.htotal = htotal; - gfx_display_mode.vactive = vactive; - gfx_display_mode.vblankstart = vblankstart; - gfx_display_mode.vsyncstart = vsyncstart; - gfx_display_mode.vsyncend = vsyncend; - gfx_display_mode.vblankend = vblankend; - gfx_display_mode.vtotal = vtotal; - gfx_display_mode.frequency = frequency; - - /* CALL ROUTINE TO SET MODE */ - - return (gu2_set_specified_mode(&gfx_display_mode, bpp)); + unsigned short hactive, unsigned short hblankstart, + unsigned short hsyncstart, unsigned short hsyncend, + unsigned short hblankend, unsigned short htotal, + unsigned short vactive, unsigned short vblankstart, + unsigned short vsyncstart, unsigned short vsyncend, + unsigned short vblankend, unsigned short vtotal, + unsigned long frequency) +#endif +{ + /* SET MODE STRUCTURE WITH SPECIFIED VALUES */ + + gfx_display_mode.flags = 0; + if (flags & 1) + gfx_display_mode.flags |= GFX_MODE_NEG_HSYNC; + if (flags & 2) + gfx_display_mode.flags |= GFX_MODE_NEG_VSYNC; + if (flags & 0x1000) + gfx_display_mode.flags |= GFX_MODE_LOCK_TIMING; + gfx_display_mode.hactive = hactive; + gfx_display_mode.hblankstart = hblankstart; + gfx_display_mode.hsyncstart = hsyncstart; + gfx_display_mode.hsyncend = hsyncend; + gfx_display_mode.hblankend = hblankend; + gfx_display_mode.htotal = htotal; + gfx_display_mode.vactive = vactive; + gfx_display_mode.vblankstart = vblankstart; + gfx_display_mode.vsyncstart = vsyncstart; + gfx_display_mode.vsyncend = vsyncend; + gfx_display_mode.vblankend = vblankend; + gfx_display_mode.vtotal = vtotal; + gfx_display_mode.frequency = frequency; + + /* CALL ROUTINE TO SET MODE */ + + return (gu2_set_specified_mode(&gfx_display_mode, bpp)); } /*---------------------------------------------------------------------------- @@ -807,38 +804,38 @@ int gfx_set_vtotal(unsigned short vtotal) #endif { - unsigned long unlock, dcfg, vactive, vblank; + unsigned long unlock, dcfg, vactive, vblank; - /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ + /* UNLOCK THE DISPLAY CONTROLLER REGISTERS */ - unlock = READ_REG32(MDC_UNLOCK); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + unlock = READ_REG32(MDC_UNLOCK); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - /* READ THE CURRENT RC VALUES */ + /* READ THE CURRENT RC VALUES */ - dcfg = READ_REG32(MDC_DISPLAY_CFG); - vactive = READ_REG32(MDC_V_ACTIVE_TIMING); - vblank = READ_REG32(MDC_V_BLANK_TIMING); + dcfg = READ_REG32(MDC_DISPLAY_CFG); + vactive = READ_REG32(MDC_V_ACTIVE_TIMING); + vblank = READ_REG32(MDC_V_BLANK_TIMING); - /* DISABLE TIMING REGISTER UPDATES */ + /* DISABLE TIMING REGISTER UPDATES */ - WRITE_REG32(MDC_DISPLAY_CFG, dcfg & ~(unsigned long)MDC_DCFG_TRUP); + WRITE_REG32(MDC_DISPLAY_CFG, dcfg & ~(unsigned long) MDC_DCFG_TRUP); - /* WRITE NEW TIMING VALUES */ + /* WRITE NEW TIMING VALUES */ - WRITE_REG32(MDC_V_ACTIVE_TIMING, - (vactive & MDC_VAT_VA_MASK) | (unsigned long)(vtotal - - 1) << 16); - WRITE_REG32(MDC_V_BLANK_TIMING, - (vblank & MDC_VBT_VBS_MASK) | (unsigned long)(vtotal - - 1) << 16); + WRITE_REG32(MDC_V_ACTIVE_TIMING, + (vactive & MDC_VAT_VA_MASK) | (unsigned long) (vtotal - + 1) << 16); + WRITE_REG32(MDC_V_BLANK_TIMING, + (vblank & MDC_VBT_VBS_MASK) | (unsigned long) (vtotal - + 1) << 16); - /* RESTORE OLD RC VALUES */ + /* RESTORE OLD RC VALUES */ - WRITE_REG32(MDC_DISPLAY_CFG, dcfg); - WRITE_REG32(MDC_UNLOCK, unlock); + WRITE_REG32(MDC_DISPLAY_CFG, dcfg); + WRITE_REG32(MDC_UNLOCK, unlock); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -855,33 +852,33 @@ void gfx_set_display_pitch(unsigned short pitch) #endif { - unsigned long value = 0; - unsigned long lock = READ_REG32(MDC_UNLOCK); + unsigned long value = 0; + unsigned long lock = READ_REG32(MDC_UNLOCK); - value = READ_REG32(MDC_GFX_PITCH) & 0xFFFF0000; - value |= (pitch >> 3); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GFX_PITCH, value); + value = READ_REG32(MDC_GFX_PITCH) & 0xFFFF0000; + value |= (pitch >> 3); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GFX_PITCH, value); - /* SET RENDERING PITCHES TO MATCH */ + /* SET RENDERING PITCHES TO MATCH */ - gfx_reset_pitch(pitch); + gfx_reset_pitch(pitch); - /* SET THE FRAME DIRTY MODE */ - /* Non-standard pitches, i.e. pitches that */ - /* are not 1K, 2K or 4K must mark the entire */ - /* frame as dirty when writing to the frame */ - /* buffer. */ + /* SET THE FRAME DIRTY MODE */ + /* Non-standard pitches, i.e. pitches that */ + /* are not 1K, 2K or 4K must mark the entire */ + /* frame as dirty when writing to the frame */ + /* buffer. */ - value = READ_REG32(MDC_GENERAL_CFG); + value = READ_REG32(MDC_GENERAL_CFG); - if (pitch == 1024 || pitch == 2048 || pitch == 4096 || pitch == 8192) - value &= ~(unsigned long)(MDC_GCFG_FDTY); - else - value |= (unsigned long)(MDC_GCFG_FDTY); + if (pitch == 1024 || pitch == 2048 || pitch == 4096 || pitch == 8192) + value &= ~(unsigned long) (MDC_GCFG_FDTY); + else + value |= (unsigned long) (MDC_GCFG_FDTY); - WRITE_REG32(MDC_GENERAL_CFG, value); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_GENERAL_CFG, value); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -900,36 +897,37 @@ void gfx_set_display_offset(unsigned long offset) #endif { - /* UPDATE FRAME BUFFER OFFSET */ - unsigned long lock; + /* UPDATE FRAME BUFFER OFFSET */ + unsigned long lock; - lock = READ_REG32(MDC_UNLOCK); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + lock = READ_REG32(MDC_UNLOCK); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - /* START ADDRESS EFFECTS DISPLAY COMPRESSION */ - /* Disable compression for non-zero start addresss values. */ - /* Enable compression if offset is zero and comression is intended to */ - /* be enabled from a previous call to "gfx_set_compression_enable". */ - /* Compression should be disabled BEFORE the offset is changed */ - /* and enabled AFTER the offset is changed. */ + /* START ADDRESS EFFECTS DISPLAY COMPRESSION */ + /* Disable compression for non-zero start addresss values. */ + /* Enable compression if offset is zero and comression is intended to */ + /* be enabled from a previous call to "gfx_set_compression_enable". */ + /* Compression should be disabled BEFORE the offset is changed */ + /* and enabled AFTER the offset is changed. */ - if (offset == 0) { - WRITE_REG32(MDC_FB_ST_OFFSET, offset); - if (gfx_compression_enabled) { - /* WAIT FOR THE OFFSET TO BE LATCHED */ - gfx_wait_vertical_blank(); - gu2_enable_compression(); - } - } else { - /* ONLY DISABLE COMPRESSION ONCE */ + if (offset == 0) { + WRITE_REG32(MDC_FB_ST_OFFSET, offset); + if (gfx_compression_enabled) { + /* WAIT FOR THE OFFSET TO BE LATCHED */ + gfx_wait_vertical_blank(); + gu2_enable_compression(); + } + } + else { + /* ONLY DISABLE COMPRESSION ONCE */ - if (gfx_compression_active) - gu2_disable_compression(); + if (gfx_compression_active) + gu2_disable_compression(); - WRITE_REG32(MDC_FB_ST_OFFSET, offset); - } + WRITE_REG32(MDC_FB_ST_OFFSET, offset); + } - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -947,13 +945,13 @@ int gfx_set_display_palette_entry(unsigned long index, unsigned long palette) #endif { - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - WRITE_REG32(MDC_PAL_ADDRESS, index); - WRITE_REG32(MDC_PAL_DATA, palette); + WRITE_REG32(MDC_PAL_ADDRESS, index); + WRITE_REG32(MDC_PAL_DATA, palette); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -971,16 +969,16 @@ int gfx_set_display_palette(unsigned long *palette) #endif { - unsigned long i; + unsigned long i; - WRITE_REG32(MDC_PAL_ADDRESS, 0); + WRITE_REG32(MDC_PAL_ADDRESS, 0); - if (palette) { - for (i = 0; i < 256; i++) { - WRITE_REG32(MDC_PAL_DATA, palette[i]); - } - } - return (0); + if (palette) { + for (i = 0; i < 256; i++) { + WRITE_REG32(MDC_PAL_DATA, palette[i]); + } + } + return (0); } /*--------------------------------------------------------------------------- @@ -1001,22 +999,22 @@ void gfx_set_cursor_enable(int enable) #endif { - unsigned long unlock, gcfg; + unsigned long unlock, gcfg; - /* SET OR CLEAR CURSOR ENABLE BIT */ + /* SET OR CLEAR CURSOR ENABLE BIT */ - unlock = READ_REG32(MDC_UNLOCK); - gcfg = READ_REG32(MDC_GENERAL_CFG); - if (enable) - gcfg |= MDC_GCFG_CURE; - else - gcfg &= ~(MDC_GCFG_CURE); + unlock = READ_REG32(MDC_UNLOCK); + gcfg = READ_REG32(MDC_GENERAL_CFG); + if (enable) + gcfg |= MDC_GCFG_CURE; + else + gcfg &= ~(MDC_GCFG_CURE); - /* WRITE NEW REGISTER VALUE */ + /* WRITE NEW REGISTER VALUE */ - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GENERAL_CFG, gcfg); - WRITE_REG32(MDC_UNLOCK, unlock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GENERAL_CFG, gcfg); + WRITE_REG32(MDC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1033,11 +1031,11 @@ void gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor) #endif { - /* SET CURSOR COLORS */ + /* SET CURSOR COLORS */ - WRITE_REG32(MDC_PAL_ADDRESS, 0x100); - WRITE_REG32(MDC_PAL_DATA, bkcolor); - WRITE_REG32(MDC_PAL_DATA, fgcolor); + WRITE_REG32(MDC_PAL_ADDRESS, 0x100); + WRITE_REG32(MDC_PAL_DATA, bkcolor); + WRITE_REG32(MDC_PAL_DATA, fgcolor); } /*--------------------------------------------------------------------------- @@ -1051,61 +1049,61 @@ gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor) #if GFX_DISPLAY_DYNAMIC void gu2_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, unsigned short yhotspot) + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, unsigned short yhotspot) #else void gfx_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, unsigned short yhotspot) -#endif -{ - unsigned long unlock; - - short x = (short)xpos - (short)xhotspot; - short y = (short)ypos - (short)yhotspot; - short xoffset = 0; - short yoffset = 0; - - if (x < -63) - return; - if (y < -63) - return; - - if (PanelEnable) { - if ((ModeWidth > PanelWidth) || (ModeHeight > PanelHeight)) { - gfx_enable_panning(xpos, ypos); - x = x - (unsigned short)panelLeft; - y = y - (unsigned short)panelTop; - } - } - - /* ADJUST OFFSETS */ - /* Cursor movement and panning work as follows: The cursor position */ - /* refers to where the hotspot of the cursor is located. However, for */ - /* non-zero hotspots, the cursor buffer actually begins before the */ - /* specified position. */ - - if (x < 0) { - xoffset = -x; - x = 0; - } - if (y < 0) { - yoffset = -y; - y = 0; - } - memoffset += (unsigned long)yoffset << 4; - - /* SET CURSOR POSITION */ - - unlock = READ_REG32(MDC_UNLOCK); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_CURS_ST_OFFSET, memoffset); - WRITE_REG32(MDC_CURSOR_X, (unsigned long)x | - (((unsigned long)xoffset) << 11)); - WRITE_REG32(MDC_CURSOR_Y, (unsigned long)y | - (((unsigned long)yoffset) << 11)); - WRITE_REG32(MDC_UNLOCK, unlock); + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, unsigned short yhotspot) +#endif +{ + unsigned long unlock; + + short x = (short) xpos - (short) xhotspot; + short y = (short) ypos - (short) yhotspot; + short xoffset = 0; + short yoffset = 0; + + if (x < -63) + return; + if (y < -63) + return; + + if (PanelEnable) { + if ((ModeWidth > PanelWidth) || (ModeHeight > PanelHeight)) { + gfx_enable_panning(xpos, ypos); + x = x - (unsigned short) panelLeft; + y = y - (unsigned short) panelTop; + } + } + + /* ADJUST OFFSETS */ + /* Cursor movement and panning work as follows: The cursor position */ + /* refers to where the hotspot of the cursor is located. However, for */ + /* non-zero hotspots, the cursor buffer actually begins before the */ + /* specified position. */ + + if (x < 0) { + xoffset = -x; + x = 0; + } + if (y < 0) { + yoffset = -y; + y = 0; + } + memoffset += (unsigned long) yoffset << 4; + + /* SET CURSOR POSITION */ + + unlock = READ_REG32(MDC_UNLOCK); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_CURS_ST_OFFSET, memoffset); + WRITE_REG32(MDC_CURSOR_X, (unsigned long) x | + (((unsigned long) xoffset) << 11)); + WRITE_REG32(MDC_CURSOR_Y, (unsigned long) y | + (((unsigned long) yoffset) << 11)); + WRITE_REG32(MDC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1119,39 +1117,39 @@ gfx_set_cursor_position(unsigned long memoffset, #if GFX_DISPLAY_DYNAMIC void gu2_set_cursor_shape32(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) #else void gfx_set_cursor_shape32(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) #endif { - int i; + int i; - for (i = 0; i < 32; i++) { - /* EVEN QWORDS CONTAIN THE AND MASK */ + for (i = 0; i < 32; i++) { + /* EVEN QWORDS CONTAIN THE AND MASK */ - WRITE_FB32(memoffset, 0xFFFFFFFF); - WRITE_FB32(memoffset + 4, andmask[i]); + WRITE_FB32(memoffset, 0xFFFFFFFF); + WRITE_FB32(memoffset + 4, andmask[i]); - /* ODD QWORDS CONTAIN THE XOR MASK */ + /* ODD QWORDS CONTAIN THE XOR MASK */ - WRITE_FB32(memoffset + 8, 0x00000000); - WRITE_FB32(memoffset + 12, xormask[i]); + WRITE_FB32(memoffset + 8, 0x00000000); + WRITE_FB32(memoffset + 12, xormask[i]); - memoffset += 16; - } + memoffset += 16; + } - /* FILL THE LOWER HALF OF THE BUFFER WITH TRANSPARENT PIXELS */ + /* FILL THE LOWER HALF OF THE BUFFER WITH TRANSPARENT PIXELS */ - for (i = 0; i < 32; i++) { - WRITE_FB32(memoffset, 0xFFFFFFFF); - WRITE_FB32(memoffset + 4, 0xFFFFFFFF); - WRITE_FB32(memoffset + 8, 0x00000000); - WRITE_FB32(memoffset + 12, 0x00000000); + for (i = 0; i < 32; i++) { + WRITE_FB32(memoffset, 0xFFFFFFFF); + WRITE_FB32(memoffset + 4, 0xFFFFFFFF); + WRITE_FB32(memoffset + 8, 0x00000000); + WRITE_FB32(memoffset + 12, 0x00000000); - memoffset += 16; - } + memoffset += 16; + } } /*--------------------------------------------------------------------------- @@ -1163,32 +1161,32 @@ gfx_set_cursor_shape32(unsigned long memoffset, #if GFX_DISPLAY_DYNAMIC void gu2_set_cursor_shape64(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) #else void gfx_set_cursor_shape64(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) #endif { - int i; + int i; - for (i = 0; i < 128; i += 2) { - /* EVEN QWORDS CONTAIN THE AND MASK */ - /* We invert the dwords to prevent the calling */ - /* application from having to think in terms of Qwords. */ - /* The hardware data order is actually 63:0, or 31:0 of */ - /* the second dword followed by 31:0 of the first dword. */ + for (i = 0; i < 128; i += 2) { + /* EVEN QWORDS CONTAIN THE AND MASK */ + /* We invert the dwords to prevent the calling */ + /* application from having to think in terms of Qwords. */ + /* The hardware data order is actually 63:0, or 31:0 of */ + /* the second dword followed by 31:0 of the first dword. */ - WRITE_FB32(memoffset, andmask[i + 1]); - WRITE_FB32(memoffset + 4, andmask[i]); + WRITE_FB32(memoffset, andmask[i + 1]); + WRITE_FB32(memoffset + 4, andmask[i]); - /* ODD QWORDS CONTAIN THE XOR MASK */ + /* ODD QWORDS CONTAIN THE XOR MASK */ - WRITE_FB32(memoffset + 8, xormask[i + 1]); - WRITE_FB32(memoffset + 12, xormask[i]); + WRITE_FB32(memoffset + 8, xormask[i + 1]); + WRITE_FB32(memoffset + 12, xormask[i]); - memoffset += 16; - } + memoffset += 16; + } } /*--------------------------------------------------------------------------- @@ -1207,22 +1205,22 @@ void gfx_set_icon_enable(int enable) #endif { - unsigned long unlock, gcfg; + unsigned long unlock, gcfg; - /* SET OR CLEAR ICON ENABLE BIT */ + /* SET OR CLEAR ICON ENABLE BIT */ - unlock = READ_REG32(MDC_UNLOCK); - gcfg = READ_REG32(MDC_GENERAL_CFG); - if (enable) - gcfg |= MDC_GCFG_ICNE; - else - gcfg &= ~(MDC_GCFG_ICNE); + unlock = READ_REG32(MDC_UNLOCK); + gcfg = READ_REG32(MDC_GENERAL_CFG); + if (enable) + gcfg |= MDC_GCFG_ICNE; + else + gcfg &= ~(MDC_GCFG_ICNE); - /* WRITE NEW REGISTER VALUE */ + /* WRITE NEW REGISTER VALUE */ - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GENERAL_CFG, gcfg); - WRITE_REG32(MDC_UNLOCK, unlock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GENERAL_CFG, gcfg); + WRITE_REG32(MDC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1234,20 +1232,20 @@ gfx_set_icon_enable(int enable) #if GFX_DISPLAY_DYNAMIC void gu2_set_icon_colors(unsigned long color0, unsigned long color1, - unsigned long color2) + unsigned long color2) #else void gfx_set_icon_colors(unsigned long color0, unsigned long color1, - unsigned long color2) + unsigned long color2) #endif { - /* ICON COLORS LOCATED AT PALETTE INDEXES 102-104h */ + /* ICON COLORS LOCATED AT PALETTE INDEXES 102-104h */ - WRITE_REG32(MDC_PAL_ADDRESS, 0x102); + WRITE_REG32(MDC_PAL_ADDRESS, 0x102); - WRITE_REG32(MDC_PAL_DATA, color0); - WRITE_REG32(MDC_PAL_DATA, color1); - WRITE_REG32(MDC_PAL_DATA, color2); + WRITE_REG32(MDC_PAL_DATA, color0); + WRITE_REG32(MDC_PAL_DATA, color1); + WRITE_REG32(MDC_PAL_DATA, color2); } /*--------------------------------------------------------------------------- @@ -1265,19 +1263,19 @@ void gfx_set_icon_position(unsigned long memoffset, unsigned short xpos) #endif { - unsigned long lock = READ_REG32(MDC_UNLOCK); + unsigned long lock = READ_REG32(MDC_UNLOCK); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - /* PROGRAM THE MEMORY OFFSET */ + /* PROGRAM THE MEMORY OFFSET */ - WRITE_REG32(MDC_ICON_ST_OFFSET, memoffset & 0x0FFFFFFF); + WRITE_REG32(MDC_ICON_ST_OFFSET, memoffset & 0x0FFFFFFF); - /* PROGRAM THE XCOORDINATE */ + /* PROGRAM THE XCOORDINATE */ - WRITE_REG32(MDC_ICON_X, (unsigned long)(xpos & 0x07FF)); + WRITE_REG32(MDC_ICON_X, (unsigned long) (xpos & 0x07FF)); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1289,31 +1287,31 @@ gfx_set_icon_position(unsigned long memoffset, unsigned short xpos) #if GFX_DISPLAY_DYNAMIC void gu2_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask, unsigned int lines) + unsigned long *xormask, unsigned int lines) #else void gfx_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask, unsigned int lines) + unsigned long *xormask, unsigned int lines) #endif { - unsigned short i, height; + unsigned short i, height; - height = lines << 1; + height = lines << 1; - for (i = 0; i < height; i += 2) { - /* EVEN QWORDS CONTAIN THE AND MASK */ - /* Swap dwords to hide qword constraint */ + for (i = 0; i < height; i += 2) { + /* EVEN QWORDS CONTAIN THE AND MASK */ + /* Swap dwords to hide qword constraint */ - WRITE_FB32(memoffset, andmask[i + 1]); - WRITE_FB32(memoffset + 4, andmask[i]); + WRITE_FB32(memoffset, andmask[i + 1]); + WRITE_FB32(memoffset + 4, andmask[i]); - /* ODD QWORDS CONTAIN THE XOR MASK */ + /* ODD QWORDS CONTAIN THE XOR MASK */ - WRITE_FB32(memoffset + 8, xormask[i + 1]); - WRITE_FB32(memoffset + 12, xormask[i]); + WRITE_FB32(memoffset + 8, xormask[i + 1]); + WRITE_FB32(memoffset + 12, xormask[i]); - memoffset += 16; - } + memoffset += 16; + } } /*--------------------------------------------------------------------------- @@ -1326,34 +1324,34 @@ gfx_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, void gu2_enable_compression(void) { - unsigned long unlock, gcfg, temp; + unsigned long unlock, gcfg, temp; - /* DO NOT ENABLE IF START ADDRESS IS NOT ZERO */ + /* DO NOT ENABLE IF START ADDRESS IS NOT ZERO */ - if (READ_REG32(MDC_FB_ST_OFFSET) & 0x0FFFFFFF) - return; + if (READ_REG32(MDC_FB_ST_OFFSET) & 0x0FFFFFFF) + return; - /* SET GLOBAL INDICATOR */ + /* SET GLOBAL INDICATOR */ - gfx_compression_active = 1; + gfx_compression_active = 1; - /* CLEAR DIRTY/VALID BITS IN MEMORY CONTROLLER */ - /* Software is required to do this before enabling compression. */ - /* Don't want controller to think that old lines are still valid. */ - /* Writing a 1 to bit 0 of the DV Control register will force the */ - /* hardware to clear all the valid bits. */ + /* CLEAR DIRTY/VALID BITS IN MEMORY CONTROLLER */ + /* Software is required to do this before enabling compression. */ + /* Don't want controller to think that old lines are still valid. */ + /* Writing a 1 to bit 0 of the DV Control register will force the */ + /* hardware to clear all the valid bits. */ - temp = READ_REG32(MDC_DV_CTL); - WRITE_REG32(MDC_DV_CTL, temp | 0x00000001); + temp = READ_REG32(MDC_DV_CTL); + WRITE_REG32(MDC_DV_CTL, temp | 0x00000001); - /* TURN ON COMPRESSION CONTROL BITS */ + /* TURN ON COMPRESSION CONTROL BITS */ - unlock = READ_REG32(MDC_UNLOCK); - gcfg = READ_REG32(MDC_GENERAL_CFG); - gcfg |= MDC_GCFG_CMPE | MDC_GCFG_DECE; - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GENERAL_CFG, gcfg); - WRITE_REG32(MDC_UNLOCK, unlock); + unlock = READ_REG32(MDC_UNLOCK); + gcfg = READ_REG32(MDC_GENERAL_CFG); + gcfg |= MDC_GCFG_CMPE | MDC_GCFG_DECE; + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GENERAL_CFG, gcfg); + WRITE_REG32(MDC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1366,20 +1364,20 @@ gu2_enable_compression(void) void gu2_disable_compression(void) { - unsigned long unlock, gcfg; + unsigned long unlock, gcfg; - /* SET GLOBAL INDICATOR */ + /* SET GLOBAL INDICATOR */ - gfx_compression_active = 0; + gfx_compression_active = 0; - /* TURN OFF COMPRESSION CONTROL BITS */ + /* TURN OFF COMPRESSION CONTROL BITS */ - unlock = READ_REG32(MDC_UNLOCK); - gcfg = READ_REG32(MDC_GENERAL_CFG); - gcfg &= ~(MDC_GCFG_CMPE | MDC_GCFG_DECE); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GENERAL_CFG, gcfg); - WRITE_REG32(MDC_UNLOCK, unlock); + unlock = READ_REG32(MDC_UNLOCK); + gcfg = READ_REG32(MDC_GENERAL_CFG); + gcfg &= ~(MDC_GCFG_CMPE | MDC_GCFG_DECE); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GENERAL_CFG, gcfg); + WRITE_REG32(MDC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1396,16 +1394,16 @@ int gfx_set_compression_enable(int enable) #endif { - /* SET GLOBAL VARIABLE FOR INDENDED STATE */ - /* Compression can only be enabled for non-zero start address values. */ - /* Keep state to enable compression on start address changes. */ + /* SET GLOBAL VARIABLE FOR INDENDED STATE */ + /* Compression can only be enabled for non-zero start address values. */ + /* Keep state to enable compression on start address changes. */ - gfx_compression_enabled = enable; - if (enable) - gu2_enable_compression(); - else - gu2_disable_compression(); - return (0); + gfx_compression_enabled = enable; + if (enable) + gu2_enable_compression(); + else + gu2_disable_compression(); + return (0); } /*--------------------------------------------------------------------------- @@ -1422,21 +1420,21 @@ int gfx_set_compression_offset(unsigned long offset) #endif { - unsigned long lock; + unsigned long lock; - /* MUST BE 16-BYTE ALIGNED FOR REDCLOUD */ + /* MUST BE 16-BYTE ALIGNED FOR REDCLOUD */ - if (offset & 0x0F) - return (1); + if (offset & 0x0F) + return (1); - /* SET REGISTER VALUE */ + /* SET REGISTER VALUE */ - lock = READ_REG32(MDC_UNLOCK); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_CB_ST_OFFSET, offset & 0x0FFFFFFF); - WRITE_REG32(MDC_UNLOCK, lock); + lock = READ_REG32(MDC_UNLOCK); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_CB_ST_OFFSET, offset & 0x0FFFFFFF); + WRITE_REG32(MDC_UNLOCK, lock); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -1453,18 +1451,18 @@ int gfx_set_compression_pitch(unsigned short pitch) #endif { - unsigned long lock, line_delta; + unsigned long lock, line_delta; - lock = READ_REG32(MDC_UNLOCK); + lock = READ_REG32(MDC_UNLOCK); - /* SET REGISTER VALUE */ + /* SET REGISTER VALUE */ - line_delta = READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF; - line_delta |= (((unsigned long)pitch << 13) & 0xFFFF0000); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GFX_PITCH, line_delta); - WRITE_REG32(MDC_UNLOCK, lock); - return (0); + line_delta = READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF; + line_delta |= (((unsigned long) pitch << 13) & 0xFFFF0000); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GFX_PITCH, line_delta); + WRITE_REG32(MDC_UNLOCK, lock); + return (0); } /*--------------------------------------------------------------------------- @@ -1482,25 +1480,25 @@ int gfx_set_compression_size(unsigned short size) #endif { - unsigned long lock, buf_size; + unsigned long lock, buf_size; - /* SUBTRACT 32 FROM SIZE */ - /* The display controller will actually write */ - /* 4 extra QWords. So, if we assume that "size" */ - /* refers to the allocated size, we must subtract */ - /* 32 bytes. */ + /* SUBTRACT 32 FROM SIZE */ + /* The display controller will actually write */ + /* 4 extra QWords. So, if we assume that "size" */ + /* refers to the allocated size, we must subtract */ + /* 32 bytes. */ - size -= 32; + size -= 32; - /* SET REGISTER VALUE */ + /* SET REGISTER VALUE */ - lock = READ_REG32(MDC_UNLOCK); - buf_size = READ_REG32(MDC_LINE_SIZE) & 0xFF80FFFF; - buf_size |= ((((unsigned long)size >> 3) + 1) & 0x7F) << 16; - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_LINE_SIZE, buf_size); - WRITE_REG32(MDC_UNLOCK, lock); - return (0); + lock = READ_REG32(MDC_UNLOCK); + buf_size = READ_REG32(MDC_LINE_SIZE) & 0xFF80FFFF; + buf_size |= ((((unsigned long) size >> 3) + 1) & 0x7F) << 16; + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_LINE_SIZE, buf_size); + WRITE_REG32(MDC_UNLOCK, lock); + return (0); } /*--------------------------------------------------------------------------- @@ -1518,29 +1516,29 @@ void gfx_set_display_video_format(unsigned long format) #endif { - unsigned long gcfg, lock; + unsigned long gcfg, lock; - lock = READ_REG32(MDC_UNLOCK); - gcfg = READ_REG32(MDC_GENERAL_CFG); + lock = READ_REG32(MDC_UNLOCK); + gcfg = READ_REG32(MDC_GENERAL_CFG); - switch (format) { - case VIDEO_FORMAT_Y0Y1Y2Y3: - case VIDEO_FORMAT_Y3Y2Y1Y0: - case VIDEO_FORMAT_Y1Y0Y3Y2: - case VIDEO_FORMAT_Y1Y2Y3Y0: + switch (format) { + case VIDEO_FORMAT_Y0Y1Y2Y3: + case VIDEO_FORMAT_Y3Y2Y1Y0: + case VIDEO_FORMAT_Y1Y0Y3Y2: + case VIDEO_FORMAT_Y1Y2Y3Y0: - gcfg |= MDC_GCFG_YUVM; - break; + gcfg |= MDC_GCFG_YUVM; + break; - default: + default: - gcfg &= ~MDC_GCFG_YUVM; - break; - } + gcfg &= ~MDC_GCFG_YUVM; + break; + } - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GENERAL_CFG, gcfg); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GENERAL_CFG, gcfg); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1558,26 +1556,26 @@ void gfx_set_display_video_enable(int enable) #endif { - unsigned long lock, gcfg, dcfg; + unsigned long lock, gcfg, dcfg; - /* READ CURRENT VALUES */ + /* READ CURRENT VALUES */ - lock = READ_REG32(MDC_UNLOCK); - gcfg = READ_REG32(MDC_GENERAL_CFG); - dcfg = READ_REG32(MDC_DISPLAY_CFG); + lock = READ_REG32(MDC_UNLOCK); + gcfg = READ_REG32(MDC_GENERAL_CFG); + dcfg = READ_REG32(MDC_DISPLAY_CFG); - /* SET OR CLEAR VIDEO ENABLE IN GENERAL_CFG */ + /* SET OR CLEAR VIDEO ENABLE IN GENERAL_CFG */ - if (enable) - gcfg |= MDC_GCFG_VIDE; - else - gcfg &= ~MDC_GCFG_VIDE; + if (enable) + gcfg |= MDC_GCFG_VIDE; + else + gcfg &= ~MDC_GCFG_VIDE; - /* WRITE REGISTER */ + /* WRITE REGISTER */ - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GENERAL_CFG, gcfg); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GENERAL_CFG, gcfg); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1595,34 +1593,35 @@ void gfx_set_display_video_size(unsigned short width, unsigned short height) #endif { - unsigned long lock, value, yuv_420; + unsigned long lock, value, yuv_420; - /* READ CURRENT VALUES */ + /* READ CURRENT VALUES */ - lock = READ_REG32(MDC_UNLOCK); - value = READ_REG32(MDC_LINE_SIZE) & 0x00FFFFFF; - yuv_420 = READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_YUVM; + lock = READ_REG32(MDC_UNLOCK); + value = READ_REG32(MDC_LINE_SIZE) & 0x00FFFFFF; + yuv_420 = READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_YUVM; - /* LINE WIDTH IS 1/4 FOR 4:2:0 VIDEO */ - /* All data must be 32-byte aligned. */ + /* LINE WIDTH IS 1/4 FOR 4:2:0 VIDEO */ + /* All data must be 32-byte aligned. */ - if (yuv_420) { - width >>= 1; - width = (width + 7) & 0xFFF8; - } else { - width <<= 1; - width = (width + 31) & 0xFFE0; - } + if (yuv_420) { + width >>= 1; + width = (width + 7) & 0xFFF8; + } + else { + width <<= 1; + width = (width + 31) & 0xFFE0; + } - /* ONLY THE LINE SIZE IS PROGRAMMED IN THE DISPLAY CONTROLLER */ + /* ONLY THE LINE SIZE IS PROGRAMMED IN THE DISPLAY CONTROLLER */ - value |= ((unsigned long)width << 21); + value |= ((unsigned long) width << 21); - /* WRITE THE REGISTER */ + /* WRITE THE REGISTER */ - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_LINE_SIZE, value); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_LINE_SIZE, value); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1640,13 +1639,13 @@ void gfx_set_display_video_offset(unsigned long offset) #endif { - unsigned long lock; + unsigned long lock; - lock = READ_REG32(MDC_UNLOCK); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - offset &= 0x0FFFFFF0; - WRITE_REG32(MDC_VID_Y_ST_OFFSET, offset); - WRITE_REG32(MDC_UNLOCK, lock); + lock = READ_REG32(MDC_UNLOCK); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + offset &= 0x0FFFFFF0; + WRITE_REG32(MDC_VID_Y_ST_OFFSET, offset); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1659,28 +1658,26 @@ gfx_set_display_video_offset(unsigned long offset) #if GFX_DISPLAY_DYNAMIC void gu2_set_display_video_yuv_offsets(unsigned long yoffset, - unsigned long uoffset, - unsigned long voffset) + unsigned long uoffset, unsigned long voffset) #else void gfx_set_display_video_yuv_offsets(unsigned long yoffset, - unsigned long uoffset, - unsigned long voffset) + unsigned long uoffset, unsigned long voffset) #endif { - unsigned long lock; + unsigned long lock; - lock = READ_REG32(MDC_UNLOCK); + lock = READ_REG32(MDC_UNLOCK); - yoffset &= 0x0FFFFFF0; - uoffset &= 0x0FFFFFF8; - voffset &= 0x0FFFFFF8; + yoffset &= 0x0FFFFFF0; + uoffset &= 0x0FFFFFF8; + voffset &= 0x0FFFFFF8; - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_VID_Y_ST_OFFSET, yoffset); - WRITE_REG32(MDC_VID_U_ST_OFFSET, uoffset); - WRITE_REG32(MDC_VID_V_ST_OFFSET, voffset); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_VID_Y_ST_OFFSET, yoffset); + WRITE_REG32(MDC_VID_U_ST_OFFSET, uoffset); + WRITE_REG32(MDC_VID_V_ST_OFFSET, voffset); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1698,15 +1695,15 @@ void gfx_set_display_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch) #endif { - unsigned long lock, pitch; + unsigned long lock, pitch; - lock = READ_REG32(MDC_UNLOCK); + lock = READ_REG32(MDC_UNLOCK); - pitch = ((uvpitch << 13) & 0xFFFF0000) | ((ypitch >> 3) & 0xFFFF); + pitch = ((uvpitch << 13) & 0xFFFF0000) | ((ypitch >> 3) & 0xFFFF); - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_VID_YUV_PITCH, pitch); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_VID_YUV_PITCH, pitch); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1724,22 +1721,22 @@ void gfx_set_display_video_downscale(unsigned short srch, unsigned short dsth) #endif { - unsigned long lock, delta; + unsigned long lock, delta; - lock = READ_REG32(MDC_UNLOCK); + lock = READ_REG32(MDC_UNLOCK); - /* CLIP SCALING LIMITS */ - /* Upscaling is performed in a separate function. */ - /* Maximum scale ratio is 1/2. */ + /* CLIP SCALING LIMITS */ + /* Upscaling is performed in a separate function. */ + /* Maximum scale ratio is 1/2. */ - if (dsth > srch || dsth <= (srch >> 1)) - delta = 0; - else - delta = (((unsigned long)srch << 14) / (unsigned long)dsth) << 18; + if (dsth > srch || dsth <= (srch >> 1)) + delta = 0; + else + delta = (((unsigned long) srch << 14) / (unsigned long) dsth) << 18; - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_VID_DS_DELTA, delta); - WRITE_REG32(MDC_UNLOCK, lock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_VID_DS_DELTA, delta); + WRITE_REG32(MDC_UNLOCK, lock); } /*--------------------------------------------------------------------------- @@ -1757,19 +1754,19 @@ void gfx_set_display_video_vertical_downscale_enable(int enable) #endif { - unsigned long gcfg, unlock; + unsigned long gcfg, unlock; - unlock = READ_REG32(MDC_UNLOCK); - gcfg = READ_REG32(MDC_GENERAL_CFG); + unlock = READ_REG32(MDC_UNLOCK); + gcfg = READ_REG32(MDC_GENERAL_CFG); - if (enable) - gcfg |= MDC_GCFG_VDSE; - else - gcfg &= ~MDC_GCFG_VDSE; + if (enable) + gcfg |= MDC_GCFG_VDSE; + else + gcfg &= ~MDC_GCFG_VDSE; - WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); - WRITE_REG32(MDC_GENERAL_CFG, gcfg); - WRITE_REG32(MDC_UNLOCK, unlock); + WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE); + WRITE_REG32(MDC_GENERAL_CFG, gcfg); + WRITE_REG32(MDC_UNLOCK, unlock); } /*--------------------------------------------------------------------------- @@ -1784,10 +1781,10 @@ int gfx_test_timing_active(void) #endif { - if (READ_REG32(MDC_DISPLAY_CFG) & MDC_DCFG_TGEN) - return (1); - else - return (0); + if (READ_REG32(MDC_DISPLAY_CFG) & MDC_DCFG_TGEN) + return (1); + else + return (0); } /*--------------------------------------------------------------------------- @@ -1802,10 +1799,10 @@ int gfx_test_vertical_active(void) #endif { - if (READ_REG32(MDC_LINE_CNT_STATUS) & MDC_LNCNT_VNA) - return (0); + if (READ_REG32(MDC_LINE_CNT_STATUS) & MDC_LNCNT_VNA) + return (0); - return (1); + return (1); } /*--------------------------------------------------------------------------- @@ -1820,11 +1817,11 @@ int gfx_wait_vertical_blank(void) #endif { - if (gfx_test_timing_active()) { - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - } - return (0); + if (gfx_test_timing_active()) { + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + } + return (0); } /*--------------------------------------------------------------------------- @@ -1843,52 +1840,52 @@ void gfx_enable_panning(int x, int y) #endif { - unsigned long modeBytesPerPixel; - unsigned long modeBytesPerScanline = 0; - unsigned long startAddress = 0; + unsigned long modeBytesPerPixel; + unsigned long modeBytesPerScanline = 0; + unsigned long startAddress = 0; - modeBytesPerPixel = (gbpp + 7) / 8; - modeBytesPerScanline = (READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF) << 3; + modeBytesPerPixel = (gbpp + 7) / 8; + modeBytesPerScanline = (READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF) << 3; - /* TEST FOR NO-WORK */ + /* TEST FOR NO-WORK */ - if (x >= DeltaX && x < ((int)PanelWidth + DeltaX) && - y >= DeltaY && y < ((int)PanelHeight + DeltaY)) - return; + if (x >= DeltaX && x < ((int) PanelWidth + DeltaX) && + y >= DeltaY && y < ((int) PanelHeight + DeltaY)) + return; - /* ADJUST PANNING VARIABLES WHEN CURSOR EXCEEDS BOUNDARY */ - /* Test the boundary conditions for each coordinate and update */ - /* all variables and the starting offset accordingly. */ + /* ADJUST PANNING VARIABLES WHEN CURSOR EXCEEDS BOUNDARY */ + /* Test the boundary conditions for each coordinate and update */ + /* all variables and the starting offset accordingly. */ - if (x < DeltaX) - DeltaX = x; + if (x < DeltaX) + DeltaX = x; - else if (x >= (DeltaX + (int)PanelWidth)) - DeltaX = x - (int)PanelWidth + 1; + else if (x >= (DeltaX + (int) PanelWidth)) + DeltaX = x - (int) PanelWidth + 1; - if (y < DeltaY) - DeltaY = y; + if (y < DeltaY) + DeltaY = y; - else if (y >= (DeltaY + (int)PanelHeight)) - DeltaY = y - (int)PanelHeight + 1; + else if (y >= (DeltaY + (int) PanelHeight)) + DeltaY = y - (int) PanelHeight + 1; - /* CALCULATE THE START OFFSET */ + /* CALCULATE THE START OFFSET */ - startAddress = - (DeltaX * modeBytesPerPixel) + (DeltaY * modeBytesPerScanline); + startAddress = + (DeltaX * modeBytesPerPixel) + (DeltaY * modeBytesPerScanline); - gfx_set_display_offset(startAddress); + gfx_set_display_offset(startAddress); - /* SET PANEL COORDINATES */ - /* Panel's x position must be DWORD aligned */ + /* SET PANEL COORDINATES */ + /* Panel's x position must be DWORD aligned */ - panelTop = DeltaY; - panelLeft = DeltaX * modeBytesPerPixel; + panelTop = DeltaY; + panelLeft = DeltaX * modeBytesPerPixel; - if (panelLeft & 3) - panelLeft = (panelLeft & 0xFFFFFFFC) + 4; + if (panelLeft & 3) + panelLeft = (panelLeft & 0xFFFFFFFC) + 4; - panelLeft /= modeBytesPerPixel; + panelLeft /= modeBytesPerPixel; } /*--------------------------------------------------------------------------- @@ -1899,44 +1896,44 @@ gfx_enable_panning(int x, int y) #if GFX_DISPLAY_DYNAMIC int gu2_set_fixed_timings(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) #else int gfx_set_fixed_timings(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) #endif { - unsigned int mode; + unsigned int mode; - ModeWidth = width; - ModeHeight = height; - PanelWidth = (unsigned short)panelResX; - PanelHeight = (unsigned short)panelResY; - PanelEnable = 1; + ModeWidth = width; + ModeHeight = height; + PanelWidth = (unsigned short) panelResX; + PanelHeight = (unsigned short) panelResY; + PanelEnable = 1; - /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ - for (mode = 0; mode < NUM_FIXED_TIMINGS_MODES; mode++) { - if ((FixedParams[mode].xres == width) && - (FixedParams[mode].yres == height) && - (FixedParams[mode].panelresx == panelResX) && - (FixedParams[mode].panelresy == panelResY)) { + /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ + for (mode = 0; mode < NUM_FIXED_TIMINGS_MODES; mode++) { + if ((FixedParams[mode].xres == width) && + (FixedParams[mode].yres == height) && + (FixedParams[mode].panelresx == panelResX) && + (FixedParams[mode].panelresy == panelResY)) { - /* SET THE 92xx FOR THE SELECTED MODE */ - FIXEDTIMINGS *fmode = &FixedParams[mode]; + /* SET THE 92xx FOR THE SELECTED MODE */ + FIXEDTIMINGS *fmode = &FixedParams[mode]; - gfx_set_display_timings(bpp, 3, fmode->hactive, fmode->hblankstart, - fmode->hsyncstart, fmode->hsyncend, - fmode->hblankend, fmode->htotal, - fmode->vactive, fmode->vblankstart, - fmode->vsyncstart, fmode->vsyncend, - fmode->vblankend, fmode->vtotal, - fmode->frequency); + gfx_set_display_timings(bpp, 3, fmode->hactive, fmode->hblankstart, + fmode->hsyncstart, fmode->hsyncend, + fmode->hblankend, fmode->htotal, + fmode->vactive, fmode->vblankstart, + fmode->vsyncstart, fmode->vsyncend, + fmode->vblankend, fmode->vtotal, + fmode->frequency); - return (1); - } /* end if() */ - } /* end for() */ + return (1); + } /* end if() */ + } /* end for() */ - return (-1); + return (-1); } /*--------------------------------------------------------------------------- @@ -1946,37 +1943,37 @@ gfx_set_fixed_timings(int panelResX, int panelResY, unsigned short width, #if GFX_DISPLAY_DYNAMIC int gu2_set_panel_present(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) #else int gfx_set_panel_present(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) #endif { - /* SET VALID BPP */ - /* 16BPP is the default. */ + /* SET VALID BPP */ + /* 16BPP is the default. */ - if (bpp != 8 && bpp != 12 && bpp != 15 && bpp != 16 && bpp != 32) - bpp = 16; + if (bpp != 8 && bpp != 12 && bpp != 15 && bpp != 16 && bpp != 32) + bpp = 16; - /* RECORD PANEL PARAMETERS */ - /* This routine does not touch any panel timings. It is used when custom panel */ - /* settings are set up in advance by the BIOS or an application, but the */ - /* application still requires access to other panel functionality provided by */ - /* Durango (i.e. panning). */ + /* RECORD PANEL PARAMETERS */ + /* This routine does not touch any panel timings. It is used when custom panel */ + /* settings are set up in advance by the BIOS or an application, but the */ + /* application still requires access to other panel functionality provided by */ + /* Durango (i.e. panning). */ - ModeWidth = width; - ModeHeight = height; - PanelWidth = (unsigned short)panelResX; - PanelHeight = (unsigned short)panelResY; - PanelEnable = 1; - gbpp = bpp; + ModeWidth = width; + ModeHeight = height; + PanelWidth = (unsigned short) panelResX; + PanelHeight = (unsigned short) panelResY; + PanelEnable = 1; + gbpp = bpp; - /* PROGRAM THE BPP IN THE DISPLAY CONTROLLER */ + /* PROGRAM THE BPP IN THE DISPLAY CONTROLLER */ - gfx_set_display_bpp(bpp); + gfx_set_display_bpp(bpp); - return (GFX_STATUS_OK); + return (GFX_STATUS_OK); } /* THE FOLLOWING READ ROUTINES ARE ALWAYS INCLUDED: */ @@ -1995,7 +1992,7 @@ unsigned short gfx_get_display_pitch(void) #endif { - return ((unsigned short)(READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF) << 3); + return ((unsigned short) (READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF) << 3); } /*---------------------------------------------------------------------------- @@ -2009,62 +2006,62 @@ gfx_get_display_pitch(void) #if GFX_DISPLAY_DYNAMIC int gu2_mode_frequency_supported(int xres, int yres, int bpp, - unsigned long frequency) + unsigned long frequency) #else int gfx_mode_frequency_supported(int xres, int yres, int bpp, - unsigned long frequency) -#endif -{ - unsigned int index; - unsigned long value; - unsigned long bpp_flag = 0; - - switch (bpp) { - case 8: - bpp_flag = GFX_MODE_8BPP; - break; - case 12: - bpp_flag = GFX_MODE_12BPP; - break; - case 15: - bpp_flag = GFX_MODE_15BPP; - break; - case 16: - bpp_flag = GFX_MODE_16BPP; - break; - case 32: - bpp_flag = GFX_MODE_24BPP; - break; - default: - bpp_flag = GFX_MODE_8BPP; - break; - } - - for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) { - if ((DisplayParams[index].hactive == (unsigned int)xres) && - (DisplayParams[index].vactive == (unsigned int)yres) && - (DisplayParams[index].flags & bpp_flag) && - (DisplayParams[index].frequency == frequency)) { - int hz = 0; - - value = DisplayParams[index].flags; - - if (value & GFX_MODE_60HZ) - hz = 60; - else if (value & GFX_MODE_70HZ) - hz = 70; - else if (value & GFX_MODE_72HZ) - hz = 72; - else if (value & GFX_MODE_75HZ) - hz = 75; - else if (value & GFX_MODE_85HZ) - hz = 85; - return (hz); - } - } - - return (-1); + unsigned long frequency) +#endif +{ + unsigned int index; + unsigned long value; + unsigned long bpp_flag = 0; + + switch (bpp) { + case 8: + bpp_flag = GFX_MODE_8BPP; + break; + case 12: + bpp_flag = GFX_MODE_12BPP; + break; + case 15: + bpp_flag = GFX_MODE_15BPP; + break; + case 16: + bpp_flag = GFX_MODE_16BPP; + break; + case 32: + bpp_flag = GFX_MODE_24BPP; + break; + default: + bpp_flag = GFX_MODE_8BPP; + break; + } + + for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) { + if ((DisplayParams[index].hactive == (unsigned int) xres) && + (DisplayParams[index].vactive == (unsigned int) yres) && + (DisplayParams[index].flags & bpp_flag) && + (DisplayParams[index].frequency == frequency)) { + int hz = 0; + + value = DisplayParams[index].flags; + + if (value & GFX_MODE_60HZ) + hz = 60; + else if (value & GFX_MODE_70HZ) + hz = 70; + else if (value & GFX_MODE_72HZ) + hz = 72; + else if (value & GFX_MODE_75HZ) + hz = 75; + else if (value & GFX_MODE_85HZ) + hz = 85; + return (hz); + } + } + + return (-1); } /*---------------------------------------------------------------------------- @@ -2078,76 +2075,76 @@ gfx_mode_frequency_supported(int xres, int yres, int bpp, #if GFX_DISPLAY_DYNAMIC int gu2_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) #else int gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, - unsigned long frequency) -#endif -{ - unsigned int index, closematch = 0; - unsigned long value; - unsigned long bpp_flag = 0; - long min, diff; - - *hz = 60; - - switch (bpp) { - case 8: - bpp_flag = GFX_MODE_8BPP; - break; - case 12: - bpp_flag = GFX_MODE_12BPP; - break; - case 15: - bpp_flag = GFX_MODE_15BPP; - break; - case 16: - bpp_flag = GFX_MODE_16BPP; - break; - case 32: - bpp_flag = GFX_MODE_24BPP; - break; - default: - bpp_flag = GFX_MODE_8BPP; - break; - } - - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ - - min = 0x7fffffff; - for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) { - if ((DisplayParams[index].htotal == (unsigned int)xres) && - (DisplayParams[index].vtotal == (unsigned int)yres) && - (DisplayParams[index].flags & bpp_flag)) { - diff = (long)frequency - (long)DisplayParams[index].frequency; - if (diff < 0) - diff = -diff; - - if (diff < min) { - min = diff; - closematch = index; - } - } - } - - value = DisplayParams[closematch].flags; - - if (value & GFX_MODE_56HZ) - *hz = 56; - else if (value & GFX_MODE_60HZ) - *hz = 60; - else if (value & GFX_MODE_70HZ) - *hz = 70; - else if (value & GFX_MODE_72HZ) - *hz = 72; - else if (value & GFX_MODE_75HZ) - *hz = 75; - else if (value & GFX_MODE_85HZ) - *hz = 85; - - return (1); + unsigned long frequency) +#endif +{ + unsigned int index, closematch = 0; + unsigned long value; + unsigned long bpp_flag = 0; + long min, diff; + + *hz = 60; + + switch (bpp) { + case 8: + bpp_flag = GFX_MODE_8BPP; + break; + case 12: + bpp_flag = GFX_MODE_12BPP; + break; + case 15: + bpp_flag = GFX_MODE_15BPP; + break; + case 16: + bpp_flag = GFX_MODE_16BPP; + break; + case 32: + bpp_flag = GFX_MODE_24BPP; + break; + default: + bpp_flag = GFX_MODE_8BPP; + break; + } + + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ + + min = 0x7fffffff; + for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) { + if ((DisplayParams[index].htotal == (unsigned int) xres) && + (DisplayParams[index].vtotal == (unsigned int) yres) && + (DisplayParams[index].flags & bpp_flag)) { + diff = (long) frequency - (long) DisplayParams[index].frequency; + if (diff < 0) + diff = -diff; + + if (diff < min) { + min = diff; + closematch = index; + } + } + } + + value = DisplayParams[closematch].flags; + + if (value & GFX_MODE_56HZ) + *hz = 56; + else if (value & GFX_MODE_60HZ) + *hz = 60; + else if (value & GFX_MODE_70HZ) + *hz = 70; + else if (value & GFX_MODE_72HZ) + *hz = 72; + else if (value & GFX_MODE_75HZ) + *hz = 75; + else if (value & GFX_MODE_85HZ) + *hz = 85; + + return (1); } /*---------------------------------------------------------------------------- @@ -2163,76 +2160,76 @@ gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, #if GFX_DISPLAY_DYNAMIC int gu2_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) #else int gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, - unsigned long frequency) -#endif -{ - unsigned int index, closematch = 0; - unsigned long value; - unsigned long bpp_flag = 0; - long min, diff; - - *hz = 60; - - switch (bpp) { - case 8: - bpp_flag = GFX_MODE_8BPP; - break; - case 12: - bpp_flag = GFX_MODE_12BPP; - break; - case 15: - bpp_flag = GFX_MODE_15BPP; - break; - case 16: - bpp_flag = GFX_MODE_16BPP; - break; - case 32: - bpp_flag = GFX_MODE_24BPP; - break; - default: - bpp_flag = GFX_MODE_8BPP; - break; - } - - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ - - min = 0x7fffffff; - for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) { - if ((DisplayParams[index].hactive == (unsigned int)xres) && - (DisplayParams[index].vactive == (unsigned int)yres) && - (DisplayParams[index].flags & bpp_flag)) { - diff = (long)frequency - (long)DisplayParams[index].frequency; - if (diff < 0) - diff = -diff; - - if (diff < min) { - min = diff; - closematch = index; - } - } - } - - value = DisplayParams[closematch].flags; - - if (value & GFX_MODE_56HZ) - *hz = 56; - else if (value & GFX_MODE_60HZ) - *hz = 60; - else if (value & GFX_MODE_70HZ) - *hz = 70; - else if (value & GFX_MODE_72HZ) - *hz = 72; - else if (value & GFX_MODE_75HZ) - *hz = 75; - else if (value & GFX_MODE_85HZ) - *hz = 85; - - return (1); + unsigned long frequency) +#endif +{ + unsigned int index, closematch = 0; + unsigned long value; + unsigned long bpp_flag = 0; + long min, diff; + + *hz = 60; + + switch (bpp) { + case 8: + bpp_flag = GFX_MODE_8BPP; + break; + case 12: + bpp_flag = GFX_MODE_12BPP; + break; + case 15: + bpp_flag = GFX_MODE_15BPP; + break; + case 16: + bpp_flag = GFX_MODE_16BPP; + break; + case 32: + bpp_flag = GFX_MODE_24BPP; + break; + default: + bpp_flag = GFX_MODE_8BPP; + break; + } + + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ + + min = 0x7fffffff; + for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) { + if ((DisplayParams[index].hactive == (unsigned int) xres) && + (DisplayParams[index].vactive == (unsigned int) yres) && + (DisplayParams[index].flags & bpp_flag)) { + diff = (long) frequency - (long) DisplayParams[index].frequency; + if (diff < 0) + diff = -diff; + + if (diff < min) { + min = diff; + closematch = index; + } + } + } + + value = DisplayParams[closematch].flags; + + if (value & GFX_MODE_56HZ) + *hz = 56; + else if (value & GFX_MODE_60HZ) + *hz = 60; + else if (value & GFX_MODE_70HZ) + *hz = 70; + else if (value & GFX_MODE_72HZ) + *hz = 72; + else if (value & GFX_MODE_75HZ) + *hz = 75; + else if (value & GFX_MODE_85HZ) + *hz = 85; + + return (1); } /*---------------------------------------------------------------------------- @@ -2244,64 +2241,64 @@ gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, #if GFX_DISPLAY_DYNAMIC int gu2_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, - int *frequency) + int *frequency) #else int gfx_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, - int *frequency) -#endif -{ - int retval = -1; - unsigned long hz_flag = 0; - unsigned long index, bpp_flag = 0; - - *frequency = 0; - - if (hz == 60) - hz_flag = GFX_MODE_60HZ; - else if (hz == 70) - hz_flag = GFX_MODE_70HZ; - else if (hz == 72) - hz_flag = GFX_MODE_72HZ; - else if (hz == 75) - hz_flag = GFX_MODE_75HZ; - else if (hz == 85) - hz_flag = GFX_MODE_85HZ; - - switch (bpp) { - case 8: - bpp_flag = GFX_MODE_8BPP; - break; - case 12: - bpp_flag = GFX_MODE_12BPP; - break; - case 15: - bpp_flag = GFX_MODE_15BPP; - break; - case 16: - bpp_flag = GFX_MODE_16BPP; - break; - case 32: - bpp_flag = GFX_MODE_24BPP; - break; - default: - bpp_flag = GFX_MODE_8BPP; - break; - } - - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ - - for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) { - if ((DisplayParams[index].hactive == (unsigned short)xres) && - (DisplayParams[index].vactive == (unsigned short)yres) && - (DisplayParams[index].flags & bpp_flag) && - (DisplayParams[index].flags & hz_flag)) { - *frequency = DisplayParams[index].frequency; - retval = 1; - } - } - return retval; + int *frequency) +#endif +{ + int retval = -1; + unsigned long hz_flag = 0; + unsigned long index, bpp_flag = 0; + + *frequency = 0; + + if (hz == 60) + hz_flag = GFX_MODE_60HZ; + else if (hz == 70) + hz_flag = GFX_MODE_70HZ; + else if (hz == 72) + hz_flag = GFX_MODE_72HZ; + else if (hz == 75) + hz_flag = GFX_MODE_75HZ; + else if (hz == 85) + hz_flag = GFX_MODE_85HZ; + + switch (bpp) { + case 8: + bpp_flag = GFX_MODE_8BPP; + break; + case 12: + bpp_flag = GFX_MODE_12BPP; + break; + case 15: + bpp_flag = GFX_MODE_15BPP; + break; + case 16: + bpp_flag = GFX_MODE_16BPP; + break; + case 32: + bpp_flag = GFX_MODE_24BPP; + break; + default: + bpp_flag = GFX_MODE_8BPP; + break; + } + + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ + + for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) { + if ((DisplayParams[index].hactive == (unsigned short) xres) && + (DisplayParams[index].vactive == (unsigned short) yres) && + (DisplayParams[index].flags & bpp_flag) && + (DisplayParams[index].flags & hz_flag)) { + *frequency = DisplayParams[index].frequency; + retval = 1; + } + } + return retval; } /*--------------------------------------------------------------------------- @@ -2320,7 +2317,7 @@ unsigned long gfx_get_max_supported_pixel_clock(void) #endif { - return 229500; + return 229500; } /*---------------------------------------------------------------------------- @@ -2339,62 +2336,62 @@ int gfx_get_display_mode(int *xres, int *yres, int *bpp, int *hz) #endif { - unsigned int mode = 0; - unsigned long pll_freq = 0, bpp_flag = 0; - - *xres = gfx_get_hactive(); - *yres = gfx_get_vactive(); - *bpp = gfx_get_display_bpp(); - pll_freq = gfx_get_clock_frequency(); - - /* SET BPP FLAGS TO LIMIT MODE SELECTION */ - - switch (*bpp) { - case 8: - bpp_flag = GFX_MODE_8BPP; - break; - case 12: - bpp_flag = GFX_MODE_12BPP; - break; - case 15: - bpp_flag = GFX_MODE_15BPP; - break; - case 16: - bpp_flag = GFX_MODE_16BPP; - break; - case 32: - bpp_flag = GFX_MODE_24BPP; - break; - default: - bpp_flag = GFX_MODE_8BPP; - break; - } - - for (mode = 0; mode < NUM_RC_DISPLAY_MODES; mode++) { - if ((DisplayParams[mode].hactive == (unsigned int)*xres) && - (DisplayParams[mode].vactive == (unsigned int)*yres) && - (DisplayParams[mode].frequency == pll_freq) && - (DisplayParams[mode].flags & bpp_flag)) { - - pll_freq = DisplayParams[mode].flags; - - if (pll_freq & GFX_MODE_56HZ) - *hz = 56; - else if (pll_freq & GFX_MODE_60HZ) - *hz = 60; - else if (pll_freq & GFX_MODE_70HZ) - *hz = 70; - else if (pll_freq & GFX_MODE_72HZ) - *hz = 72; - else if (pll_freq & GFX_MODE_75HZ) - *hz = 75; - else if (pll_freq & GFX_MODE_85HZ) - *hz = 85; - - return (1); - } - } - return (-1); + unsigned int mode = 0; + unsigned long pll_freq = 0, bpp_flag = 0; + + *xres = gfx_get_hactive(); + *yres = gfx_get_vactive(); + *bpp = gfx_get_display_bpp(); + pll_freq = gfx_get_clock_frequency(); + + /* SET BPP FLAGS TO LIMIT MODE SELECTION */ + + switch (*bpp) { + case 8: + bpp_flag = GFX_MODE_8BPP; + break; + case 12: + bpp_flag = GFX_MODE_12BPP; + break; + case 15: + bpp_flag = GFX_MODE_15BPP; + break; + case 16: + bpp_flag = GFX_MODE_16BPP; + break; + case 32: + bpp_flag = GFX_MODE_24BPP; + break; + default: + bpp_flag = GFX_MODE_8BPP; + break; + } + + for (mode = 0; mode < NUM_RC_DISPLAY_MODES; mode++) { + if ((DisplayParams[mode].hactive == (unsigned int) *xres) && + (DisplayParams[mode].vactive == (unsigned int) *yres) && + (DisplayParams[mode].frequency == pll_freq) && + (DisplayParams[mode].flags & bpp_flag)) { + + pll_freq = DisplayParams[mode].flags; + + if (pll_freq & GFX_MODE_56HZ) + *hz = 56; + else if (pll_freq & GFX_MODE_60HZ) + *hz = 60; + else if (pll_freq & GFX_MODE_70HZ) + *hz = 70; + else if (pll_freq & GFX_MODE_72HZ) + *hz = 72; + else if (pll_freq & GFX_MODE_75HZ) + *hz = 75; + else if (pll_freq & GFX_MODE_85HZ) + *hz = 85; + + return (1); + } + } + return (-1); } /*---------------------------------------------------------------------------- @@ -2413,31 +2410,31 @@ int gfx_get_display_details(unsigned int mode, int *xres, int *yres, int *hz) #endif { - if (mode < NUM_RC_DISPLAY_MODES) { - if (DisplayParams[mode].flags & GFX_MODE_56HZ) - *hz = 56; - else if (DisplayParams[mode].flags & GFX_MODE_60HZ) - *hz = 60; - else if (DisplayParams[mode].flags & GFX_MODE_70HZ) - *hz = 70; - else if (DisplayParams[mode].flags & GFX_MODE_72HZ) - *hz = 72; - else if (DisplayParams[mode].flags & GFX_MODE_75HZ) - *hz = 75; - else if (DisplayParams[mode].flags & GFX_MODE_85HZ) - *hz = 85; + if (mode < NUM_RC_DISPLAY_MODES) { + if (DisplayParams[mode].flags & GFX_MODE_56HZ) + *hz = 56; + else if (DisplayParams[mode].flags & GFX_MODE_60HZ) + *hz = 60; + else if (DisplayParams[mode].flags & GFX_MODE_70HZ) + *hz = 70; + else if (DisplayParams[mode].flags & GFX_MODE_72HZ) + *hz = 72; + else if (DisplayParams[mode].flags & GFX_MODE_75HZ) + *hz = 75; + else if (DisplayParams[mode].flags & GFX_MODE_85HZ) + *hz = 85; - *xres = DisplayParams[mode].hactive; - *yres = DisplayParams[mode].vactive; + *xres = DisplayParams[mode].hactive; + *yres = DisplayParams[mode].vactive; - if (DisplayParams[mode].flags & GFX_MODE_PIXEL_DOUBLE) - *xres >>= 1; - if (DisplayParams[mode].flags & GFX_MODE_LINE_DOUBLE) - *yres >>= 1; + if (DisplayParams[mode].flags & GFX_MODE_PIXEL_DOUBLE) + *xres >>= 1; + if (DisplayParams[mode].flags & GFX_MODE_LINE_DOUBLE) + *yres >>= 1; - return (1); - } - return (0); + return (1); + } + return (0); } /*---------------------------------------------------------------------------- @@ -2454,7 +2451,7 @@ int gfx_get_display_mode_count(void) #endif { - return (NUM_RC_DISPLAY_MODES); + return (NUM_RC_DISPLAY_MODES); } /*---------------------------------------------------------------------------- @@ -2471,7 +2468,7 @@ unsigned long gfx_get_frame_buffer_line_size(void) #endif { - return ((READ_REG32(MDC_LINE_SIZE) & 0x7FF) << 3); + return ((READ_REG32(MDC_LINE_SIZE) & 0x7FF) << 3); } /*--------------------------------------------------------------------------- @@ -2486,7 +2483,7 @@ unsigned short gfx_get_hactive(void) #endif { - return ((unsigned short)((READ_REG32(MDC_H_ACTIVE_TIMING) & 0x0FF8) + 8)); + return ((unsigned short) ((READ_REG32(MDC_H_ACTIVE_TIMING) & 0x0FF8) + 8)); } /*--------------------------------------------------------------------------- @@ -2501,7 +2498,7 @@ unsigned short gfx_get_hsync_start(void) #endif { - return ((unsigned short)((READ_REG32(MDC_H_SYNC_TIMING) & 0x0FF8) + 8)); + return ((unsigned short) ((READ_REG32(MDC_H_SYNC_TIMING) & 0x0FF8) + 8)); } /*--------------------------------------------------------------------------- @@ -2516,8 +2513,8 @@ unsigned short gfx_get_hsync_end(void) #endif { - return ((unsigned short)(((READ_REG32(MDC_H_SYNC_TIMING) >> 16) & 0x0FF8) + - 8)); + return ((unsigned short) (((READ_REG32(MDC_H_SYNC_TIMING) >> 16) & 0x0FF8) + + 8)); } /*--------------------------------------------------------------------------- @@ -2532,8 +2529,8 @@ unsigned short gfx_get_htotal(void) #endif { - return ((unsigned short)(((READ_REG32(MDC_H_ACTIVE_TIMING) >> 16) & 0x0FF8) - + 8)); + return ((unsigned short) (((READ_REG32(MDC_H_ACTIVE_TIMING) >> 16) & 0x0FF8) + + 8)); } /*--------------------------------------------------------------------------- @@ -2548,7 +2545,7 @@ unsigned short gfx_get_vactive(void) #endif { - return ((unsigned short)((READ_REG32(MDC_V_ACTIVE_TIMING) & 0x07FF) + 1)); + return ((unsigned short) ((READ_REG32(MDC_V_ACTIVE_TIMING) & 0x07FF) + 1)); } /*--------------------------------------------------------------------------- @@ -2563,8 +2560,8 @@ unsigned short gfx_get_vsync_end(void) #endif { - return ((unsigned short)(((READ_REG32(MDC_V_SYNC_TIMING) >> 16) & 0x07FF) + - 1)); + return ((unsigned short) (((READ_REG32(MDC_V_SYNC_TIMING) >> 16) & 0x07FF) + + 1)); } /*--------------------------------------------------------------------------- @@ -2579,8 +2576,8 @@ unsigned short gfx_get_vtotal(void) #endif { - return ((unsigned short)(((READ_REG32(MDC_V_ACTIVE_TIMING) >> 16) & 0x07FF) - + 1)); + return ((unsigned short) (((READ_REG32(MDC_V_ACTIVE_TIMING) >> 16) & 0x07FF) + + 1)); } /*----------------------------------------------------------------------------- @@ -2597,31 +2594,31 @@ unsigned short gfx_get_display_bpp(void) #endif { - unsigned long dcfg = READ_REG32(MDC_DISPLAY_CFG); + unsigned long dcfg = READ_REG32(MDC_DISPLAY_CFG); - switch ((dcfg & MDC_DCFG_DISP_MODE_MASK) >> 8) { - case 0: - return (8); - case 2: - return (32); + switch ((dcfg & MDC_DCFG_DISP_MODE_MASK) >> 8) { + case 0: + return (8); + case 2: + return (32); - case 1: + case 1: - switch ((dcfg & MDC_DCFG_16BPP_MODE_MASK) >> 10) { - case 0: - return (16); - case 1: - return (15); - case 2: - return (12); - default: - return (0); - } - } + switch ((dcfg & MDC_DCFG_16BPP_MODE_MASK) >> 10) { + case 0: + return (16); + case 1: + return (15); + case 2: + return (12); + default: + return (0); + } + } - /* INVALID SETTING */ + /* INVALID SETTING */ - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -2636,19 +2633,19 @@ unsigned short gfx_get_vline(void) #endif { - unsigned short current_scan_line; + unsigned short current_scan_line; - /* Read similar value twice to ensure that the value is not transitioning */ + /* Read similar value twice to ensure that the value is not transitioning */ - do - current_scan_line = - (unsigned short)(READ_REG32(MDC_LINE_CNT_STATUS) & - MDC_LNCNT_V_LINE_CNT); - while (current_scan_line != - (unsigned short)(READ_REG32(MDC_LINE_CNT_STATUS) & - MDC_LNCNT_V_LINE_CNT)); + do + current_scan_line = + (unsigned short) (READ_REG32(MDC_LINE_CNT_STATUS) & + MDC_LNCNT_V_LINE_CNT); + while (current_scan_line != + (unsigned short) (READ_REG32(MDC_LINE_CNT_STATUS) & + MDC_LNCNT_V_LINE_CNT)); - return (current_scan_line >> 16); + return (current_scan_line >> 16); } /*----------------------------------------------------------------------------- @@ -2663,7 +2660,7 @@ unsigned long gfx_get_display_offset(void) #endif { - return (READ_REG32(MDC_FB_ST_OFFSET) & 0x0FFFFFFF); + return (READ_REG32(MDC_FB_ST_OFFSET) & 0x0FFFFFFF); } /*----------------------------------------------------------------------------- @@ -2678,7 +2675,7 @@ unsigned long gfx_get_cursor_offset(void) #endif { - return (READ_REG32(MDC_CURS_ST_OFFSET) & 0x0FFFFFFF); + return (READ_REG32(MDC_CURS_ST_OFFSET) & 0x0FFFFFFF); } #if GFX_READ_ROUTINES @@ -2699,7 +2696,7 @@ unsigned short gfx_get_hblank_start(void) #endif { - return ((unsigned short)((READ_REG32(MDC_H_BLANK_TIMING) & 0x0FF8) + 8)); + return ((unsigned short) ((READ_REG32(MDC_H_BLANK_TIMING) & 0x0FF8) + 8)); } /*--------------------------------------------------------------------------- @@ -2714,8 +2711,8 @@ unsigned short gfx_get_hblank_end(void) #endif { - return ((unsigned short)(((READ_REG32(MDC_H_BLANK_TIMING) >> 16) & 0x0FF8) - + 8)); + return ((unsigned short) (((READ_REG32(MDC_H_BLANK_TIMING) >> 16) & 0x0FF8) + + 8)); } /*--------------------------------------------------------------------------- @@ -2730,7 +2727,7 @@ unsigned short gfx_get_vblank_start(void) #endif { - return ((unsigned short)((READ_REG32(MDC_V_BLANK_TIMING) & 0x07FF) + 1)); + return ((unsigned short) ((READ_REG32(MDC_V_BLANK_TIMING) & 0x07FF) + 1)); } /*--------------------------------------------------------------------------- @@ -2745,7 +2742,7 @@ unsigned short gfx_get_vsync_start(void) #endif { - return ((unsigned short)((READ_REG32(MDC_V_SYNC_TIMING) & 0x07FF) + 1)); + return ((unsigned short) ((READ_REG32(MDC_V_SYNC_TIMING) & 0x07FF) + 1)); } /*--------------------------------------------------------------------------- @@ -2760,8 +2757,8 @@ unsigned short gfx_get_vblank_end(void) #endif { - return ((unsigned short)(((READ_REG32(MDC_V_BLANK_TIMING) >> 16) & 0x07FF) - + 1)); + return ((unsigned short) (((READ_REG32(MDC_V_BLANK_TIMING) >> 16) & 0x07FF) + + 1)); } /*----------------------------------------------------------------------------- @@ -2776,13 +2773,13 @@ int gfx_get_display_palette_entry(unsigned long index, unsigned long *palette) #endif { - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - WRITE_REG32(MDC_PAL_ADDRESS, index); - *palette = READ_REG32(MDC_PAL_DATA); + WRITE_REG32(MDC_PAL_ADDRESS, index); + *palette = READ_REG32(MDC_PAL_DATA); - return 0; + return 0; } /*----------------------------------------------------------------------------- @@ -2797,12 +2794,12 @@ void gfx_get_display_palette(unsigned long *palette) #endif { - unsigned long i; + unsigned long i; - WRITE_REG32(MDC_PAL_ADDRESS, 0); - for (i = 0; i < 256; i++) { - palette[i] = READ_REG32(MDC_PAL_DATA); - } + WRITE_REG32(MDC_PAL_ADDRESS, 0); + for (i = 0; i < 256; i++) { + palette[i] = READ_REG32(MDC_PAL_DATA); + } } /*----------------------------------------------------------------------------- @@ -2817,7 +2814,7 @@ unsigned long gfx_get_cursor_enable(void) #endif { - return (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_CURE); + return (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_CURE); } /*----------------------------------------------------------------------------- @@ -2832,8 +2829,8 @@ unsigned long gfx_get_cursor_position(void) #endif { - return ((READ_REG32(MDC_CURSOR_X) & 0x07FF) | - ((READ_REG32(MDC_CURSOR_Y) << 16) & 0x03FF0000)); + return ((READ_REG32(MDC_CURSOR_X) & 0x07FF) | + ((READ_REG32(MDC_CURSOR_Y) << 16) & 0x03FF0000)); } /*----------------------------------------------------------------------------- @@ -2848,8 +2845,8 @@ unsigned long gfx_get_cursor_clip(void) #endif { - return (((READ_REG32(MDC_CURSOR_X) >> 11) & 0x03F) | - ((READ_REG32(MDC_CURSOR_Y) << 5) & 0x3F0000)); + return (((READ_REG32(MDC_CURSOR_X) >> 11) & 0x03F) | + ((READ_REG32(MDC_CURSOR_Y) << 5) & 0x3F0000)); } /*----------------------------------------------------------------------------- @@ -2864,12 +2861,13 @@ unsigned long gfx_get_cursor_color(int color) #endif { - if (color) { - WRITE_REG32(MDC_PAL_ADDRESS, 0x101); - } else { - WRITE_REG32(MDC_PAL_ADDRESS, 0x100); - } - return READ_REG32(MDC_PAL_DATA); + if (color) { + WRITE_REG32(MDC_PAL_ADDRESS, 0x101); + } + else { + WRITE_REG32(MDC_PAL_ADDRESS, 0x100); + } + return READ_REG32(MDC_PAL_DATA); } /*----------------------------------------------------------------------------- @@ -2884,7 +2882,7 @@ unsigned long gfx_get_icon_enable(void) #endif { - return (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_ICNE); + return (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_ICNE); } /*----------------------------------------------------------------------------- @@ -2899,7 +2897,7 @@ unsigned long gfx_get_icon_offset(void) #endif { - return (READ_REG32(MDC_ICON_ST_OFFSET) & 0x0FFFFFFF); + return (READ_REG32(MDC_ICON_ST_OFFSET) & 0x0FFFFFFF); } /*----------------------------------------------------------------------------- @@ -2914,7 +2912,7 @@ unsigned long gfx_get_icon_position(void) #endif { - return (READ_REG32(MDC_ICON_X) & 0x07FF); + return (READ_REG32(MDC_ICON_X) & 0x07FF); } /*----------------------------------------------------------------------------- @@ -2929,12 +2927,12 @@ unsigned long gfx_get_icon_color(int color) #endif { - if (color >= 3) - return 0; + if (color >= 3) + return 0; - WRITE_REG32(MDC_PAL_ADDRESS, 0x102 + color); + WRITE_REG32(MDC_PAL_ADDRESS, 0x102 + color); - return READ_REG32(MDC_PAL_DATA); + return READ_REG32(MDC_PAL_DATA); } /*----------------------------------------------------------------------------- @@ -2949,10 +2947,10 @@ int gfx_get_compression_enable(void) #endif { - if (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_CMPE) - return (1); + if (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_CMPE) + return (1); - return (0); + return (0); } /*----------------------------------------------------------------------------- @@ -2967,7 +2965,7 @@ unsigned long gfx_get_compression_offset(void) #endif { - return (READ_REG32(MDC_CB_ST_OFFSET) & 0x007FFFFF); + return (READ_REG32(MDC_CB_ST_OFFSET) & 0x007FFFFF); } /*----------------------------------------------------------------------------- @@ -2982,10 +2980,10 @@ unsigned short gfx_get_compression_pitch(void) #endif { - unsigned short pitch; + unsigned short pitch; - pitch = (unsigned short)(READ_REG32(MDC_GFX_PITCH) >> 16); - return (pitch << 3); + pitch = (unsigned short) (READ_REG32(MDC_GFX_PITCH) >> 16); + return (pitch << 3); } /*----------------------------------------------------------------------------- @@ -3000,10 +2998,10 @@ unsigned short gfx_get_compression_size(void) #endif { - unsigned short size; + unsigned short size; - size = (unsigned short)((READ_REG32(MDC_LINE_SIZE) >> 16) & 0x7F) - 1; - return ((size << 3) + 32); + size = (unsigned short) ((READ_REG32(MDC_LINE_SIZE) >> 16) & 0x7F) - 1; + return ((size << 3) + 32); } /*----------------------------------------------------------------------------- @@ -3018,18 +3016,18 @@ int gfx_get_valid_bit(int line) #endif { - unsigned long offset; - int valid; + unsigned long offset; + int valid; - offset = READ_REG32(MDC_PHY_MEM_OFFSET) & 0xFF000000; - offset |= line; + offset = READ_REG32(MDC_PHY_MEM_OFFSET) & 0xFF000000; + offset |= line; - WRITE_REG32(MDC_PHY_MEM_OFFSET, offset); - valid = (int)READ_REG32(MDC_DV_ACC) & 2; + WRITE_REG32(MDC_PHY_MEM_OFFSET, offset); + valid = (int) READ_REG32(MDC_DV_ACC) & 2; - if (valid) - return 1; - return 0; + if (valid) + return 1; + return 0; } /*--------------------------------------------------------------------------- @@ -3047,7 +3045,7 @@ unsigned long gfx_get_display_video_offset(void) #endif { - return (READ_REG32(MDC_VID_Y_ST_OFFSET) & 0x0FFFFFFF); + return (READ_REG32(MDC_VID_Y_ST_OFFSET) & 0x0FFFFFFF); } /*--------------------------------------------------------------------------- @@ -3060,18 +3058,18 @@ gfx_get_display_video_offset(void) #if GFX_DISPLAY_DYNAMIC void gu2_get_display_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset) + unsigned long *uoffset, + unsigned long *voffset) #else void gfx_get_display_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset) + unsigned long *uoffset, + unsigned long *voffset) #endif { - *yoffset = (READ_REG32(MDC_VID_Y_ST_OFFSET) & 0x0FFFFFFF); - *uoffset = (READ_REG32(MDC_VID_U_ST_OFFSET) & 0x0FFFFFFF); - *voffset = (READ_REG32(MDC_VID_V_ST_OFFSET) & 0x0FFFFFFF); + *yoffset = (READ_REG32(MDC_VID_Y_ST_OFFSET) & 0x0FFFFFFF); + *uoffset = (READ_REG32(MDC_VID_U_ST_OFFSET) & 0x0FFFFFFF); + *voffset = (READ_REG32(MDC_VID_V_ST_OFFSET) & 0x0FFFFFFF); } /*--------------------------------------------------------------------------- @@ -3089,10 +3087,10 @@ void gfx_get_display_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch) #endif { - unsigned long pitch = READ_REG32(MDC_VID_YUV_PITCH); + unsigned long pitch = READ_REG32(MDC_VID_YUV_PITCH); - *ypitch = ((pitch & 0xFFFF) << 3); - *uvpitch = (pitch >> 13) & 0x7FFF8; + *ypitch = ((pitch & 0xFFFF) << 3); + *uvpitch = (pitch >> 13) & 0x7FFF8; } /*--------------------------------------------------------------------------- @@ -3110,7 +3108,7 @@ unsigned long gfx_get_display_video_downscale_delta(void) #endif { - return (READ_REG32(MDC_VID_DS_DELTA) >> 18); + return (READ_REG32(MDC_VID_DS_DELTA) >> 18); } /*--------------------------------------------------------------------------- @@ -3128,7 +3126,7 @@ int gfx_get_display_video_downscale_enable(void) #endif { - return ((int)((READ_REG32(MDC_GENERAL_CFG) >> 19) & 1)); + return ((int) ((READ_REG32(MDC_GENERAL_CFG) >> 19) & 1)); } /*--------------------------------------------------------------------------- @@ -3146,11 +3144,11 @@ unsigned long gfx_get_display_video_size(void) #endif { - /* RETURN THE LINE SIZE, AS THIS IS ALL THAT IS AVAILABLE */ + /* RETURN THE LINE SIZE, AS THIS IS ALL THAT IS AVAILABLE */ - return ((READ_REG32(MDC_LINE_SIZE) >> 21) & 0x000007FF); + return ((READ_REG32(MDC_LINE_SIZE) >> 21) & 0x000007FF); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ diff --git a/src/gfx/durango.c b/src/gfx/durango.c index 56bc65a..83c5cf2 100644 --- a/src/gfx/durango.c +++ b/src/gfx/durango.c @@ -149,53 +149,53 @@ * of chipsets. */ -#define GFX_DISPLAY_DYNAMIC 1 /* runtime selection */ -#define GFX_DISPLAY_GU1 1 /* 1st generation display controller */ -#define GFX_DISPLAY_GU2 1 /* 2nd generation display controller */ +#define GFX_DISPLAY_DYNAMIC 1 /* runtime selection */ +#define GFX_DISPLAY_GU1 1 /* 1st generation display controller */ +#define GFX_DISPLAY_GU2 1 /* 2nd generation display controller */ -#define GFX_INIT_DYNAMIC 1 /* runtime selection */ -#define GFX_INIT_GU1 1 /* Geode family */ -#define GFX_INIT_GU2 1 /* Redcloud */ +#define GFX_INIT_DYNAMIC 1 /* runtime selection */ +#define GFX_INIT_GU1 1 /* Geode family */ +#define GFX_INIT_GU2 1 /* Redcloud */ -#define GFX_MSR_DYNAMIC 1 /* runtime selection */ -#define GFX_MSR_REDCLOUD 1 /* Redcloud */ +#define GFX_MSR_DYNAMIC 1 /* runtime selection */ +#define GFX_MSR_REDCLOUD 1 /* Redcloud */ -#define GFX_2DACCEL_DYNAMIC 1 /* runtime selection */ -#define GFX_2DACCEL_GU1 1 /* 1st generation 2D accelerator */ -#define GFX_2DACCEL_GU2 1 /* 2nd generation 2D accelerator */ +#define GFX_2DACCEL_DYNAMIC 1 /* runtime selection */ +#define GFX_2DACCEL_GU1 1 /* 1st generation 2D accelerator */ +#define GFX_2DACCEL_GU2 1 /* 2nd generation 2D accelerator */ -#define GFX_VIDEO_DYNAMIC 1 /* runtime selection */ -#define GFX_VIDEO_CS5530 1 /* support for CS5530 */ -#define GFX_VIDEO_SC1200 1 /* support for SC1200 */ -#define GFX_VIDEO_REDCLOUD 1 /* support for Redcloud */ +#define GFX_VIDEO_DYNAMIC 1 /* runtime selection */ +#define GFX_VIDEO_CS5530 1 /* support for CS5530 */ +#define GFX_VIDEO_SC1200 1 /* support for SC1200 */ +#define GFX_VIDEO_REDCLOUD 1 /* support for Redcloud */ -#define GFX_VIP_DYNAMIC 1 /* runtime selection */ -#define GFX_VIP_SC1200 1 /* support for SC1200 */ +#define GFX_VIP_DYNAMIC 1 /* runtime selection */ +#define GFX_VIP_SC1200 1 /* support for SC1200 */ -#define GFX_DECODER_DYNAMIC 1 /* runtime selection */ -#define GFX_DECODER_SAA7114 1 /* Philips SAA7114 decoder */ +#define GFX_DECODER_DYNAMIC 1 /* runtime selection */ +#define GFX_DECODER_SAA7114 1 /* Philips SAA7114 decoder */ -#define GFX_TV_DYNAMIC 1 /* runtime selection */ -#define GFX_TV_FS451 1 /* Focus Enhancements FS450 */ -#define GFX_TV_SC1200 1 /* SC1200 integrated TV encoder */ +#define GFX_TV_DYNAMIC 1 /* runtime selection */ +#define GFX_TV_FS451 1 /* Focus Enhancements FS450 */ +#define GFX_TV_SC1200 1 /* SC1200 integrated TV encoder */ -#define GFX_I2C_DYNAMIC 1 /* runtime selection */ -#define GFX_I2C_ACCESS 1 /* support for ACCESS.BUS */ -#define GFX_I2C_GPIO 1 /* support for CS5530 GPIOs */ +#define GFX_I2C_DYNAMIC 1 /* runtime selection */ +#define GFX_I2C_ACCESS 1 /* support for ACCESS.BUS */ +#define GFX_I2C_GPIO 1 /* support for CS5530 GPIOs */ -#define GFX_VGA_DYNAMIC 1 /* runtime selection */ -#define GFX_VGA_GU1 1 /* 1st generation graphics unit */ +#define GFX_VGA_DYNAMIC 1 /* runtime selection */ +#define GFX_VGA_GU1 1 /* 1st generation graphics unit */ -#define FB4MB 1 /* Set to use 4Mb video ram for Pyramid */ +#define FB4MB 1 /* Set to use 4Mb video ram for Pyramid */ -#define GFX_NO_IO_IN_WAIT_MACROS 0 /* Set to remove I/O accesses in GP bit testing */ +#define GFX_NO_IO_IN_WAIT_MACROS 0 /* Set to remove I/O accesses in GP bit testing */ /* ROUTINES TO READ VALUES * These are routines used by Darwin or other diagnostics to read the * current state of the hardware. Display drivers or embedded applications can * reduce the size of the Durango code by not including these routines. */ -#define GFX_READ_ROUTINES 1 /* add routines to read values */ +#define GFX_READ_ROUTINES 1 /* add routines to read values */ /* VARIABLES USED FOR RUNTIME SELECTION * If part of the graphics subsystem is declared as dynamic, then the @@ -248,7 +248,7 @@ int gfx_vga_type = 0; * Needed since some of the Durango routines call other Durango routines. * Also defines the size of chipset array (GFX_CSPTR_SIZE). */ -#include "gfx_rtns.h" /* routine definitions */ +#include "gfx_rtns.h" /* routine definitions */ /* DEFINE POINTERS TO MEMORY MAPPED REGIONS * These pointers are used by the Durango routines to access the hardware. @@ -268,25 +268,25 @@ int gfx_vga_type = 0; /* the WRITE_REG* macros are modified to subtract 0x8000 from */ /* the offset. */ -unsigned char *gfx_virt_regptr = (unsigned char *)0x40000000; -unsigned char *gfx_virt_fbptr = (unsigned char *)0x40800000; -unsigned char *gfx_virt_vidptr = (unsigned char *)0x40010000; -unsigned char *gfx_virt_vipptr = (unsigned char *)0x40015000; -unsigned char *gfx_virt_spptr = (unsigned char *)0x40000000; -unsigned char *gfx_virt_gpptr = (unsigned char *)0x40000000; +unsigned char *gfx_virt_regptr = (unsigned char *) 0x40000000; +unsigned char *gfx_virt_fbptr = (unsigned char *) 0x40800000; +unsigned char *gfx_virt_vidptr = (unsigned char *) 0x40010000; +unsigned char *gfx_virt_vipptr = (unsigned char *) 0x40015000; +unsigned char *gfx_virt_spptr = (unsigned char *) 0x40000000; +unsigned char *gfx_virt_gpptr = (unsigned char *) 0x40000000; /* DEFINE PHYSICAL ADDRESSES */ -unsigned char *gfx_phys_regptr = (unsigned char *)0x40000000; -unsigned char *gfx_phys_fbptr = (unsigned char *)0x40800000; -unsigned char *gfx_phys_vidptr = (unsigned char *)0x40010000; -unsigned char *gfx_phys_vipptr = (unsigned char *)0x40015000; +unsigned char *gfx_phys_regptr = (unsigned char *) 0x40000000; +unsigned char *gfx_phys_fbptr = (unsigned char *) 0x40800000; +unsigned char *gfx_phys_vidptr = (unsigned char *) 0x40010000; +unsigned char *gfx_phys_vipptr = (unsigned char *) 0x40015000; /* HEADER FILE FOR GRAPHICS REGISTER DEFINITIONS * This contains only constant definitions, so it should be able to be * included in any software project as is. */ -#include "gfx_regs.h" /* graphics register definitions */ +#include "gfx_regs.h" /* graphics register definitions */ /* HEADER FILE FOR REGISTER ACCESS MACROS * This file contains the definitions of the WRITE_REG32 and similar macros @@ -296,152 +296,101 @@ unsigned char *gfx_phys_vipptr = (unsigned char *)0x40015000; * should not be included and the project must define the macros itself. * (A project may define WRITE_REG32 to call a routine, for example). */ -#include "gfx_defs.h" /* register access macros */ +#include "gfx_defs.h" /* register access macros */ /* IO MACROS AND ROUTINES * These macros must be defined before the initialization or I2C * routines will work properly. */ -#if defined(OS_WIN32) /* For Windows */ +#if defined(OS_WIN32) /* For Windows */ /* VSA II CALL */ void gfx_msr_asm_read(unsigned short msrReg, unsigned long msrAddr, - unsigned long *ptrHigh, unsigned long *ptrLow) + unsigned long *ptrHigh, unsigned long *ptrLow) { - unsigned long temp1, temp2; - - _asm { - mov dx, 0x0AC1C - mov eax, 0x0FC530007 - out dx, eax - add dl, 2 - mov ecx, msrAddr - mov cx, msrReg - in ax, dx; - ;EDX:EAX will contain MSR contents. - mov temp1, edx - mov temp2, eax - } - - *ptrHigh = temp1; - *ptrLow = temp2; + unsigned long temp1, temp2; + + _asm { + mov dx, 0x0AC1C + mov eax, 0x0FC530007 + out dx, eax add dl, 2 mov ecx, msrAddr mov cx, msrReg in ax, dx; + ; + EDX:EAX will contain MSR contents.mov temp1, edx mov temp2, eax} + + *ptrHigh = temp1; + *ptrLow = temp2; } void gfx_msr_asm_write(unsigned short msrReg, unsigned long msrAddr, - unsigned long *ptrHigh, unsigned long *ptrLow) + unsigned long *ptrHigh, unsigned long *ptrLow) { - unsigned long temp1 = *ptrHigh; - unsigned long temp2 = *ptrLow; - - _asm { - mov dx, 0x0AC1C - mov eax, 0x0FC530007 - out dx, eax i - add dl, 2 - ;ECX contains msrAddr | msrReg - mov ecx, msrAddr - mov cx, msrReg - ;<OR_mask_hi > - mov ebx, temp1 - - ;<OR_mask_hi > - mov eax, temp2 - ;<AND_mask_hi > - mov esi, 0 - ;<AND_mask_lo > - mov edi, 0 - ;MSR is written at this point - out dx, ax - } -} - -unsigned char + unsigned long temp1 = *ptrHigh; + unsigned long temp2 = *ptrLow; + + _asm { + mov dx, 0x0AC1C mov eax, 0x0FC530007 out dx, eax i add dl, 2; + ECX contains msrAddr | msrReg mov ecx, msrAddr mov cx, msrReg; + + <OR_mask_hi > mov ebx, temp1; + <OR_mask_hi > mov eax, temp2; + <AND_mask_hi > mov esi, 0; + <AND_mask_lo > mov edi, 0; +MSR is written at this point out dx, ax}} unsigned char gfx_inb(unsigned short port) { - unsigned char data; - - _asm { - pushf - mov dx, port - in al, dx - mov data, al - popf - } - return (data); + unsigned char data; + + _asm { + pushf mov dx, port in al, dx mov data, al popf} + return (data); } unsigned short gfx_inw(unsigned short port) { - unsigned short data; - - _asm { - pushf - mov dx, port - in ax, dx - mov data, ax - popf - } - return (data); + unsigned short data; + + _asm { + pushf mov dx, port in ax, dx mov data, ax popf} + return (data); } unsigned long gfx_ind(unsigned short port) { - unsigned long data; - - _asm { - pushf - mov dx, port - in eax, dx - mov data, eax - popf - } - return (data); + unsigned long data; + + _asm { + pushf mov dx, port in eax, dx mov data, eax popf} + return (data); } void gfx_outb(unsigned short port, unsigned char data) { - _asm { - pushf - mov al, data - mov dx, port - out dx, al - popf - } + _asm { + pushf mov al, data mov dx, port out dx, al popf} } void gfx_outw(unsigned short port, unsigned short data) { - _asm { - pushf - mov ax, data - mov dx, port - out dx, ax - popf - } + _asm { + pushf mov ax, data mov dx, port out dx, ax popf} } void gfx_outd(unsigned short port, unsigned long data) { - _asm { - pushf - mov eax, data - mov dx, port - out dx, eax - popf - } + _asm { + pushf mov eax, data mov dx, port out dx, eax popf} } - -#elif defined(OS_VXWORKS) || defined (OS_LINUX) /* VxWorks and Linux */ +#elif defined(OS_VXWORKS) || defined (OS_LINUX) /* VxWorks and Linux */ #if defined(OS_LINUX) #include "asm/msr.h" @@ -449,114 +398,114 @@ gfx_outd(unsigned short port, unsigned long data) void gfx_msr_asm_read(unsigned short msrReg, unsigned long msrAddr, - unsigned long *ptrHigh, unsigned long *ptrLow) + unsigned long *ptrHigh, unsigned long *ptrLow) { - unsigned long addr, val1, val2; + unsigned long addr, val1, val2; - addr = msrAddr | (unsigned long)msrReg; - rdmsr(addr, val1, val2); + addr = msrAddr | (unsigned long) msrReg; + rdmsr(addr, val1, val2); - *ptrHigh = val2; - *ptrLow = val1; + *ptrHigh = val2; + *ptrLow = val1; } void gfx_msr_asm_write(unsigned short msrReg, unsigned long msrAddr, - unsigned long *ptrHigh, unsigned long *ptrLow) + unsigned long *ptrHigh, unsigned long *ptrLow) { - unsigned long addr, val1, val2; + unsigned long addr, val1, val2; - val2 = *ptrHigh; - val1 = *ptrLow; + val2 = *ptrHigh; + val1 = *ptrLow; - addr = (msrAddr & 0xFFFF0000) | (unsigned long)msrReg; - wrmsr(addr, val1, val2); + addr = (msrAddr & 0xFFFF0000) | (unsigned long) msrReg; + wrmsr(addr, val1, val2); } unsigned char gfx_inb(unsigned short port) { - unsigned char value; - __asm__ volatile ("inb %1,%0":"=a" (value):"d"(port)); + unsigned char value; + __asm__ volatile ("inb %1,%0":"=a" (value):"d"(port)); - return value; + return value; } unsigned short gfx_inw(unsigned short port) { - unsigned short value; - __asm__ volatile ("in %1,%0":"=a" (value):"d"(port)); + unsigned short value; + __asm__ volatile ("in %1,%0":"=a" (value):"d"(port)); - return value; + return value; } unsigned long gfx_ind(unsigned short port) { - unsigned long value; - __asm__ volatile ("inl %1,%0":"=a" (value):"d"(port)); + unsigned long value; + __asm__ volatile ("inl %1,%0":"=a" (value):"d"(port)); - return value; + return value; } void gfx_outb(unsigned short port, unsigned char data) { - __asm__ volatile ("outb %0,%1"::"a" (data), "d"(port)); + __asm__ volatile ("outb %0,%1"::"a" (data), "d"(port)); } void gfx_outw(unsigned short port, unsigned short data) { - __asm__ volatile ("out %0,%1"::"a" (data), "d"(port)); + __asm__ volatile ("out %0,%1"::"a" (data), "d"(port)); } void gfx_outd(unsigned short port, unsigned long data) { - __asm__ volatile ("outl %0,%1"::"a" (data), "d"(port)); + __asm__ volatile ("outl %0,%1"::"a" (data), "d"(port)); } -#else /* else nothing */ +#else /* else nothing */ unsigned char gfx_inb(unsigned short port) { - /* ADD OS SPECIFIC IMPLEMENTATION */ - return (0); + /* ADD OS SPECIFIC IMPLEMENTATION */ + return (0); } unsigned short gfx_inw(unsigned short port) { - /* ADD OS SPECIFIC IMPLEMENTATION */ - return (0); + /* ADD OS SPECIFIC IMPLEMENTATION */ + return (0); } unsigned long gfx_ind(unsigned short port) { - /* ADD OS SPECIFIC IMPLEMENTATION */ - return (0); + /* ADD OS SPECIFIC IMPLEMENTATION */ + return (0); } void gfx_outb(unsigned short port, unsigned char data) { - /* ADD OS SPECIFIC IMPLEMENTATION */ + /* ADD OS SPECIFIC IMPLEMENTATION */ } void gfx_outw(unsigned short port, unsigned short data) { - /* ADD OS SPECIFIC IMPLEMENTATION */ + /* ADD OS SPECIFIC IMPLEMENTATION */ } void gfx_outd(unsigned short port, unsigned long data) { - /* ADD OS SPECIFIC IMPLEMENTATION */ + /* ADD OS SPECIFIC IMPLEMENTATION */ } #endif @@ -586,42 +535,42 @@ gfx_outd(unsigned short port, unsigned long data) * the project does not use graphics acceleration (direct frame buffer * access only), then this file does not need to be included. */ -#include "gfx_rndr.c" /* graphics engine routines */ +#include "gfx_rndr.c" /* graphics engine routines */ /* INCLUDE DISPLAY CONTROLLER ROUTINES * These routines are used if the display mode is set directly. If the * project uses VGA registers to set a display mode, then these files * do not need to be included. */ -#include "gfx_mode.h" /* display mode tables */ -#include "gfx_disp.c" /* display controller routines */ +#include "gfx_mode.h" /* display mode tables */ +#include "gfx_disp.c" /* display controller routines */ /* INCLUDE VIDEO OVERLAY ROUTINES * These routines control the video overlay hardware. */ -#include "gfx_vid.c" /* video overlay routines */ +#include "gfx_vid.c" /* video overlay routines */ /* VIDEO PORT AND VIDEO DECODER ROUTINES * These routines rely on the I2C routines. */ -#include "gfx_vip.c" /* video port routines */ -#include "gfx_dcdr.c" /* video decoder routines */ +#include "gfx_vip.c" /* video port routines */ +#include "gfx_dcdr.c" /* video decoder routines */ /* I2C BUS ACCESS ROUTINES * These routines are used by the video decoder and possibly an * external TV encoer. */ -#include "gfx_i2c.c" /* I2C bus access routines */ +#include "gfx_i2c.c" /* I2C bus access routines */ /* TV ENCODER ROUTINES * This file does not need to be included if the system does not * support TV output. */ -#include "gfx_tv.c" /* TV encoder routines */ +#include "gfx_tv.c" /* TV encoder routines */ /* VGA ROUTINES * This file is used if setting display modes using VGA registers. */ -#include "gfx_vga.c" /* VGA routines */ +#include "gfx_vga.c" /* VGA routines */ /* END OF FILE */ diff --git a/src/gfx/gfx_dcdr.c b/src/gfx/gfx_dcdr.c index 187b440..6139404 100644 --- a/src/gfx/gfx_dcdr.c +++ b/src/gfx/gfx_dcdr.c @@ -177,13 +177,13 @@ int gfx_set_decoder_defaults(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_defaults(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_defaults(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -193,13 +193,13 @@ gfx_set_decoder_defaults(void) int gfx_set_decoder_analog_input(unsigned char input) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_analog_input(input); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_analog_input(input); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -209,13 +209,13 @@ gfx_set_decoder_analog_input(unsigned char input) int gfx_set_decoder_brightness(unsigned char brightness) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_brightness(brightness); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_brightness(brightness); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -225,13 +225,13 @@ gfx_set_decoder_brightness(unsigned char brightness) int gfx_set_decoder_contrast(unsigned char contrast) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_contrast(contrast); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_contrast(contrast); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -241,13 +241,13 @@ gfx_set_decoder_contrast(unsigned char contrast) int gfx_set_decoder_hue(char hue) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_hue(hue); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_hue(hue); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -257,13 +257,13 @@ gfx_set_decoder_hue(char hue) int gfx_set_decoder_saturation(unsigned char saturation) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_saturation(saturation); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_saturation(saturation); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -273,13 +273,13 @@ gfx_set_decoder_saturation(unsigned char saturation) int gfx_set_decoder_input_offset(unsigned short x, unsigned short y) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_input_offset(x, y); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_input_offset(x, y); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -289,13 +289,13 @@ gfx_set_decoder_input_offset(unsigned short x, unsigned short y) int gfx_set_decoder_input_size(unsigned short width, unsigned short height) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_input_size(width, height); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_input_size(width, height); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -305,13 +305,13 @@ gfx_set_decoder_input_size(unsigned short width, unsigned short height) int gfx_set_decoder_output_size(unsigned short width, unsigned short height) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_output_size(width, height); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_output_size(width, height); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -320,15 +320,15 @@ gfx_set_decoder_output_size(unsigned short width, unsigned short height) */ int gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_scale(srcw, srch, dstw, dsth); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_scale(srcw, srch, dstw, dsth); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -338,13 +338,13 @@ gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, int gfx_set_decoder_vbi_format(int start, int end, int format) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_vbi_format(start, end, format); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_vbi_format(start, end, format); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -354,13 +354,13 @@ gfx_set_decoder_vbi_format(int start, int end, int format) int gfx_set_decoder_vbi_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_vbi_enable(enable); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_vbi_enable(enable); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -370,13 +370,13 @@ gfx_set_decoder_vbi_enable(int enable) int gfx_set_decoder_vbi_upscale(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_vbi_upscale(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_vbi_upscale(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -386,13 +386,13 @@ gfx_set_decoder_vbi_upscale(void) int gfx_set_decoder_TV_standard(TVStandardType TVStandard) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_TV_standard(TVStandard); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_TV_standard(TVStandard); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -402,13 +402,13 @@ gfx_set_decoder_TV_standard(TVStandardType TVStandard) int gfx_set_decoder_luminance_filter(unsigned char lufi) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_set_decoder_luminance_filter(lufi); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_set_decoder_luminance_filter(lufi); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -418,13 +418,13 @@ gfx_set_decoder_luminance_filter(unsigned char lufi) int gfx_decoder_software_reset(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_decoder_software_reset(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_decoder_software_reset(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -434,13 +434,13 @@ gfx_decoder_software_reset(void) int gfx_decoder_detect_macrovision(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_decoder_detect_macrovision(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_decoder_detect_macrovision(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -450,13 +450,13 @@ gfx_decoder_detect_macrovision(void) int gfx_decoder_detect_video(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - status = saa7114_decoder_detect_video(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + status = saa7114_decoder_detect_video(); # endif - return (status); + return (status); } /*************************************************************/ @@ -472,13 +472,13 @@ gfx_decoder_detect_video(void) unsigned char gfx_get_decoder_brightness(void) { - unsigned char brightness = 0; + unsigned char brightness = 0; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - brightness = saa7114_get_decoder_brightness(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + brightness = saa7114_get_decoder_brightness(); # endif - return (brightness); + return (brightness); } /*----------------------------------------------------------------------------- @@ -488,13 +488,13 @@ gfx_get_decoder_brightness(void) unsigned char gfx_get_decoder_contrast(void) { - unsigned char contrast = 0; + unsigned char contrast = 0; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - contrast = saa7114_get_decoder_contrast(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + contrast = saa7114_get_decoder_contrast(); # endif - return (contrast); + return (contrast); } /*----------------------------------------------------------------------------- @@ -504,13 +504,13 @@ gfx_get_decoder_contrast(void) char gfx_get_decoder_hue(void) { - unsigned char hue = 0; + unsigned char hue = 0; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - hue = saa7114_get_decoder_hue(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + hue = saa7114_get_decoder_hue(); # endif - return ((char)hue); + return ((char) hue); } /*----------------------------------------------------------------------------- @@ -520,13 +520,13 @@ gfx_get_decoder_hue(void) unsigned char gfx_get_decoder_saturation(void) { - unsigned char saturation = 0; + unsigned char saturation = 0; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - saturation = saa7114_get_decoder_saturation(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + saturation = saa7114_get_decoder_saturation(); # endif - return (saturation); + return (saturation); } /*----------------------------------------------------------------------------- @@ -536,13 +536,13 @@ gfx_get_decoder_saturation(void) unsigned long gfx_get_decoder_input_offset() { - unsigned long offset = 0; + unsigned long offset = 0; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - offset = saa7114_get_decoder_input_offset(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + offset = saa7114_get_decoder_input_offset(); # endif - return (offset); + return (offset); } /*----------------------------------------------------------------------------- @@ -552,13 +552,13 @@ gfx_get_decoder_input_offset() unsigned long gfx_get_decoder_input_size() { - unsigned long size = 0; + unsigned long size = 0; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - size = saa7114_get_decoder_input_size(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + size = saa7114_get_decoder_input_size(); # endif - return (size); + return (size); } /*----------------------------------------------------------------------------- @@ -568,13 +568,13 @@ gfx_get_decoder_input_size() unsigned long gfx_get_decoder_output_size() { - unsigned long size = 0; + unsigned long size = 0; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - size = saa7114_get_decoder_output_size(); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + size = saa7114_get_decoder_output_size(); # endif - return (size); + return (size); } /*----------------------------------------------------------------------------- @@ -584,17 +584,17 @@ gfx_get_decoder_output_size() int gfx_get_decoder_vbi_format(int line) { - int format = 0; + int format = 0; # if GFX_DECODER_SAA7114 - if (gfx_decoder_type == GFX_DECODER_SAA7114) - format = saa7114_get_decoder_vbi_format(line); + if (gfx_decoder_type == GFX_DECODER_SAA7114) + format = saa7114_get_decoder_vbi_format(line); # endif - return (format); + return (format); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ -#endif /* GFX_DECODER_DYNAMIC */ +#endif /* GFX_DECODER_DYNAMIC */ /* END OF FILE */ diff --git a/src/gfx/gfx_defs.h b/src/gfx/gfx_defs.h index 8847e5b..f189abe 100644 --- a/src/gfx/gfx_defs.h +++ b/src/gfx/gfx_defs.h @@ -216,9 +216,9 @@ /* ACCESS TO MSRS */ void gfx_msr_asm_write(unsigned short msrReg, unsigned long msrAddr, - unsigned long *ptrHigh, unsigned long *ptrLow); + unsigned long *ptrHigh, unsigned long *ptrLow); void gfx_msr_asm_read(unsigned short msrReg, unsigned long msrAddr, - unsigned long *ptrHigh, unsigned long *ptrLow); + unsigned long *ptrHigh, unsigned long *ptrLow); #define MSR_READ( MBD_MSR_CAP, address, valueHigh_ptr, valueLow_ptr ) \ gfx_msr_asm_read( ((unsigned short)(MBD_MSR_CAP)), address, valueHigh_ptr, valueLow_ptr ) @@ -430,6 +430,6 @@ void gfx_msr_asm_read(unsigned short msrReg, unsigned long msrAddr, WRITE_GP32 (regoffset, temp2); \ } \ } -#endif /* _gfx_defs_h */ +#endif /* _gfx_defs_h */ /* END OF FILE */ diff --git a/src/gfx/gfx_disp.c b/src/gfx/gfx_disp.c index 54adcb3..f97c7a6 100644 --- a/src/gfx/gfx_disp.c +++ b/src/gfx/gfx_disp.c @@ -223,205 +223,205 @@ DISPLAYMODE DisplayParams[] = { /* 320 x 200 */ - {GFX_MODE_70HZ | /* refresh rate = 60 */ - GFX_MODE_8BPP | GFX_MODE_16BPP | /* 8 and 16 BPP valid */ - GFX_MODE_NEG_HSYNC | /* negative HSYNC */ - GFX_MODE_PIXEL_DOUBLE | /* Double width */ - GFX_MODE_LINE_DOUBLE, /* Double height */ - 0x140, 0x288, 0x290, 0x2F0, 0x318, 0x320, /* horizontal timings */ - 0x0C8, 0x197, 0x19C, 0x19E, 0x1BA, 0x1C1, /* vertical timings */ - 0x00192CCC, /* freq = 25.175 MHz */ - }, + {GFX_MODE_70HZ | /* refresh rate = 60 */ + GFX_MODE_8BPP | GFX_MODE_16BPP | /* 8 and 16 BPP valid */ + GFX_MODE_NEG_HSYNC | /* negative HSYNC */ + GFX_MODE_PIXEL_DOUBLE | /* Double width */ + GFX_MODE_LINE_DOUBLE, /* Double height */ + 0x140, 0x288, 0x290, 0x2F0, 0x318, 0x320, /* horizontal timings */ + 0x0C8, 0x197, 0x19C, 0x19E, 0x1BA, 0x1C1, /* vertical timings */ + 0x00192CCC, /* freq = 25.175 MHz */ + }, /* 320 x 240 */ - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_16BPP | /* 8 and 16 BPP valid */ - GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC | /* negative syncs */ - GFX_MODE_PIXEL_DOUBLE | /* Double width */ - GFX_MODE_LINE_DOUBLE, /* Double height */ - 0x0140, 0x0280, 0x0290, 0x02D0, 0x0348, 0x0348, /* horizontal timings */ - 0x00F0, 0x01E0, 0x01E1, 0x01E4, 0x01F4, 0x01F4, /* vertical timings */ - 0x001F8000, /* freq = 31.5 MHz */ - }, + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_16BPP | /* 8 and 16 BPP valid */ + GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC | /* negative syncs */ + GFX_MODE_PIXEL_DOUBLE | /* Double width */ + GFX_MODE_LINE_DOUBLE, /* Double height */ + 0x0140, 0x0280, 0x0290, 0x02D0, 0x0348, 0x0348, /* horizontal timings */ + 0x00F0, 0x01E0, 0x01E1, 0x01E4, 0x01F4, 0x01F4, /* vertical timings */ + 0x001F8000, /* freq = 31.5 MHz */ + }, /* 400 x 300 */ - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_16BPP | /* 8 and 16 BPP valid */ - GFX_MODE_PIXEL_DOUBLE | /* Double width */ - GFX_MODE_LINE_DOUBLE, /* Double height */ - 0x0190, 0x0320, 0x0330, 0x0380, 0x0420, 0x0420, /* horizontal timings */ - 0x012C, 0x0258, 0x0259, 0x025C, 0x0271, 0x0271, /* vertical timings */ - 0x00318000, /* freq = 49.5 MHz */ - }, + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_16BPP | /* 8 and 16 BPP valid */ + GFX_MODE_PIXEL_DOUBLE | /* Double width */ + GFX_MODE_LINE_DOUBLE, /* Double height */ + 0x0190, 0x0320, 0x0330, 0x0380, 0x0420, 0x0420, /* horizontal timings */ + 0x012C, 0x0258, 0x0259, 0x025C, 0x0271, 0x0271, /* vertical timings */ + 0x00318000, /* freq = 49.5 MHz */ + }, /* 512 x 384 */ - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_16BPP | /* 8 and 16 BPP valid */ - GFX_MODE_PIXEL_DOUBLE | /* Double width */ - GFX_MODE_LINE_DOUBLE, /* Double height */ - 0x0200, 0x0400, 0x0410, 0x0470, 0x0520, 0x0520, /* horizontal timings */ - 0x0180, 0x0300, 0x0301, 0x0304, 0x0320, 0x0320, /* vertical timings */ - 0x004EC000, /* freq = 78.75 MHz */ - }, + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_16BPP | /* 8 and 16 BPP valid */ + GFX_MODE_PIXEL_DOUBLE | /* Double width */ + GFX_MODE_LINE_DOUBLE, /* Double height */ + 0x0200, 0x0400, 0x0410, 0x0470, 0x0520, 0x0520, /* horizontal timings */ + 0x0180, 0x0300, 0x0301, 0x0304, 0x0320, 0x0320, /* vertical timings */ + 0x004EC000, /* freq = 78.75 MHz */ + }, /* 640 x 400 */ - {GFX_MODE_70HZ | /* refresh rate = 60 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC, /* negative HSYNC */ - 0x280, 0x288, 0x290, 0x2F0, 0x318, 0x320, /* horizontal timings */ - 0x190, 0x197, 0x19C, 0x19E, 0x1BA, 0x1C1, /* vertical timings */ - 0x00192CCC, /* freq = 25.175 MHz */ - }, + {GFX_MODE_70HZ | /* refresh rate = 60 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC, /* negative HSYNC */ + 0x280, 0x288, 0x290, 0x2F0, 0x318, 0x320, /* horizontal timings */ + 0x190, 0x197, 0x19C, 0x19E, 0x1BA, 0x1C1, /* vertical timings */ + 0x00192CCC, /* freq = 25.175 MHz */ + }, /* 640x480 */ - {GFX_MODE_60HZ | /* refresh rate = 60 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ - 0x0280, 0x0288, 0x0290, 0x02E8, 0x0318, 0x0320, /* horizontal timings */ - 0x01E0, 0x01E8, 0x01EA, 0x01EC, 0x0205, 0x020D, /* vertical timings */ - 0x00192CCC, /* freq = 25.175 MHz */ - }, - - {GFX_MODE_72HZ | /* refresh rate = 72 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ - 0x0280, 0x0288, 0x0298, 0x02c0, 0x0338, 0x0340, /* horizontal timings */ - 0x01e0, 0x01e8, 0x01e9, 0x01ec, 0x0200, 0x0208, /* vertical timings */ - 0x001F8000, /* freq = 31.5 MHz */ - }, - - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ - 0x0280, 0x0280, 0x0290, 0x02D0, 0x0348, 0x0348, /* horizontal timings */ - 0x01E0, 0x01E0, 0x01E1, 0x01E4, 0x01F4, 0x01F4, /* vertical timings */ - 0x001F8000, /* freq = 31.5 MHz */ - }, - - {GFX_MODE_85HZ | /* refresh rate = 85 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ - 0x0280, 0x0280, 0x02B8, 0x02F0, 0x0340, 0x0340, /* horizontal timings */ - 0x01E0, 0x01E0, 0x01E1, 0x01E4, 0x01FD, 0x01FD, /* vertical timings */ - 0x00240000, /* freq = 36.0 MHz */ - }, + {GFX_MODE_60HZ | /* refresh rate = 60 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ + 0x0280, 0x0288, 0x0290, 0x02E8, 0x0318, 0x0320, /* horizontal timings */ + 0x01E0, 0x01E8, 0x01EA, 0x01EC, 0x0205, 0x020D, /* vertical timings */ + 0x00192CCC, /* freq = 25.175 MHz */ + }, + + {GFX_MODE_72HZ | /* refresh rate = 72 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ + 0x0280, 0x0288, 0x0298, 0x02c0, 0x0338, 0x0340, /* horizontal timings */ + 0x01e0, 0x01e8, 0x01e9, 0x01ec, 0x0200, 0x0208, /* vertical timings */ + 0x001F8000, /* freq = 31.5 MHz */ + }, + + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ + 0x0280, 0x0280, 0x0290, 0x02D0, 0x0348, 0x0348, /* horizontal timings */ + 0x01E0, 0x01E0, 0x01E1, 0x01E4, 0x01F4, 0x01F4, /* vertical timings */ + 0x001F8000, /* freq = 31.5 MHz */ + }, + + {GFX_MODE_85HZ | /* refresh rate = 85 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ + 0x0280, 0x0280, 0x02B8, 0x02F0, 0x0340, 0x0340, /* horizontal timings */ + 0x01E0, 0x01E0, 0x01E1, 0x01E4, 0x01FD, 0x01FD, /* vertical timings */ + 0x00240000, /* freq = 36.0 MHz */ + }, /* 800x600 */ - {GFX_MODE_56HZ | /* refresh rate = 56 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0320, 0x0328, 0x0348, 0x03D0, 0x0418, 0x0420, /* horizontal timings */ - 0x0258, 0x0258, 0x0259, 0x025D, 0x0274, 0x0274, /* vertical timings */ - 0x00240000, /* freq = 36.00 MHz */ - }, - - {GFX_MODE_60HZ | /* refresh rate = 60 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0320, 0x0328, 0x0348, 0x03D0, 0x0418, 0x0420, /* horizontal timings */ - 0x0258, 0x0258, 0x0259, 0x025D, 0x0274, 0x0274, /* vertical timings */ - 0x00280000, /* freq = 40.00 MHz */ - }, - - {GFX_MODE_72HZ | /* refresh rate = 72 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0320, 0x0320, 0x0358, 0x03D0, 0x0410, 0x0410, /* horizontal timings */ - 0x0258, 0x0258, 0x027D, 0x0283, 0x029A, 0x029A, /* vertical timings */ - 0x00320000, /* freq = 49.5 MHz */ - }, - - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0320, 0x0320, 0x0330, 0x0380, 0x0420, 0x0420, /* horizontal timings */ - 0x0258, 0x0258, 0x0259, 0x025C, 0x0271, 0x0271, /* vertical timings */ - 0x00318000, /* freq = 49.5 MHz */ - }, - - {GFX_MODE_85HZ | /* refresh rate = 85 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0320, 0x0320, 0x0340, 0x0380, 0x0418, 0x0418, /* horizontal timings */ - 0x0258, 0x0258, 0x0259, 0x025C, 0x0277, 0x0277, /* vertical timings */ - 0x00384000, /* freq = 56.25 MHz */ - }, + {GFX_MODE_56HZ | /* refresh rate = 56 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0320, 0x0328, 0x0348, 0x03D0, 0x0418, 0x0420, /* horizontal timings */ + 0x0258, 0x0258, 0x0259, 0x025D, 0x0274, 0x0274, /* vertical timings */ + 0x00240000, /* freq = 36.00 MHz */ + }, + + {GFX_MODE_60HZ | /* refresh rate = 60 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0320, 0x0328, 0x0348, 0x03D0, 0x0418, 0x0420, /* horizontal timings */ + 0x0258, 0x0258, 0x0259, 0x025D, 0x0274, 0x0274, /* vertical timings */ + 0x00280000, /* freq = 40.00 MHz */ + }, + + {GFX_MODE_72HZ | /* refresh rate = 72 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0320, 0x0320, 0x0358, 0x03D0, 0x0410, 0x0410, /* horizontal timings */ + 0x0258, 0x0258, 0x027D, 0x0283, 0x029A, 0x029A, /* vertical timings */ + 0x00320000, /* freq = 49.5 MHz */ + }, + + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0320, 0x0320, 0x0330, 0x0380, 0x0420, 0x0420, /* horizontal timings */ + 0x0258, 0x0258, 0x0259, 0x025C, 0x0271, 0x0271, /* vertical timings */ + 0x00318000, /* freq = 49.5 MHz */ + }, + + {GFX_MODE_85HZ | /* refresh rate = 85 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0320, 0x0320, 0x0340, 0x0380, 0x0418, 0x0418, /* horizontal timings */ + 0x0258, 0x0258, 0x0259, 0x025C, 0x0277, 0x0277, /* vertical timings */ + 0x00384000, /* freq = 56.25 MHz */ + }, /* 1024x768 */ - {GFX_MODE_60HZ | /* refresh rate = 60 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ - 0x0400, 0x0400, 0x0418, 0x04A0, 0x0540, 0x0540, /* horizontal timings */ - 0x0300, 0x0300, 0x0303, 0x0309, 0x0326, 0x0326, /* vertical timings */ - 0x00410000, /* freq = 65.00 MHz */ - }, - - {GFX_MODE_70HZ | /* refresh rate = 70 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ - 0x0400, 0x0400, 0x0418, 0x04A0, 0x0530, 0x0530, /* horizontal timings */ - 0x0300, 0x0300, 0x0303, 0x0309, 0x0326, 0x0326, /* vertical timings */ - 0x004B0000, /* freq = 78.75 MHz */ - }, - - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0400, 0x0400, 0x0410, 0x0470, 0x0520, 0x0520, /* horizontal timings */ - 0x0300, 0x0300, 0x0301, 0x0304, 0x0320, 0x0320, /* vertical timings */ - 0x004EC000, /* freq = 78.75 MHz */ - }, - - {GFX_MODE_85HZ | /* refresh rate = 85 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0400, 0x0400, 0x0430, 0x0490, 0x0560, 0x0560, /* horizontal timings */ - 0x0300, 0x0300, 0x0301, 0x0304, 0x0328, 0x0328, /* vertical timings */ - 0x005E8000, /* freq = 94.50 MHz */ - }, + {GFX_MODE_60HZ | /* refresh rate = 60 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ + 0x0400, 0x0400, 0x0418, 0x04A0, 0x0540, 0x0540, /* horizontal timings */ + 0x0300, 0x0300, 0x0303, 0x0309, 0x0326, 0x0326, /* vertical timings */ + 0x00410000, /* freq = 65.00 MHz */ + }, + + {GFX_MODE_70HZ | /* refresh rate = 70 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP | GFX_MODE_NEG_HSYNC | GFX_MODE_NEG_VSYNC, /* negative syncs */ + 0x0400, 0x0400, 0x0418, 0x04A0, 0x0530, 0x0530, /* horizontal timings */ + 0x0300, 0x0300, 0x0303, 0x0309, 0x0326, 0x0326, /* vertical timings */ + 0x004B0000, /* freq = 78.75 MHz */ + }, + + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0400, 0x0400, 0x0410, 0x0470, 0x0520, 0x0520, /* horizontal timings */ + 0x0300, 0x0300, 0x0301, 0x0304, 0x0320, 0x0320, /* vertical timings */ + 0x004EC000, /* freq = 78.75 MHz */ + }, + + {GFX_MODE_85HZ | /* refresh rate = 85 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0400, 0x0400, 0x0430, 0x0490, 0x0560, 0x0560, /* horizontal timings */ + 0x0300, 0x0300, 0x0301, 0x0304, 0x0328, 0x0328, /* vertical timings */ + 0x005E8000, /* freq = 94.50 MHz */ + }, /* 1152x864 */ - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0480, 0x0480, 0x04C0, 0x0540, 0x0640, 0x0640, /* horizontal timings */ - 0x0360, 0x0360, 0x0361, 0x0364, 0x0384, 0x0384, /* vertical timings */ - 0x006C0000, /* freq = 108.00 MHz */ - }, + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* all BPP valid */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0480, 0x0480, 0x04C0, 0x0540, 0x0640, 0x0640, /* horizontal timings */ + 0x0360, 0x0360, 0x0361, 0x0364, 0x0384, 0x0384, /* vertical timings */ + 0x006C0000, /* freq = 108.00 MHz */ + }, /* 1280x1024 */ - {GFX_MODE_60HZ | /* refresh rate = 60 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 16 bpp */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0500, 0x0500, 0x0530, 0x05A0, 0x0698, 0x0698, /* horizontal timings */ - 0x0400, 0x0400, 0x0401, 0x0404, 0x042A, 0x042A, /* vertical timings */ - 0x006C0000, /* freq = 108.0 MHz */ - }, - - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 16 bpp */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0500, 0x0500, 0x0510, 0x05A0, 0x0698, 0x0698, /* horizontal timings */ - 0x0400, 0x0400, 0x0401, 0x0404, 0x042A, 0x042A, /* vertical timings */ - 0x00870000, /* freq = 135.0 MHz */ - }, - - {GFX_MODE_85HZ | /* refresh rate = 85 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 16 bpp */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0500, 0x0500, 0x0540, 0x05E0, 0x06C0, 0x06C0, /* horizontal timings */ - 0x0400, 0x0400, 0x0401, 0x0404, 0x0430, 0x0430, /* vertical timings */ - 0x009D8000, /* freq = 157.5 MHz */ - }, + {GFX_MODE_60HZ | /* refresh rate = 60 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 16 bpp */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0500, 0x0500, 0x0530, 0x05A0, 0x0698, 0x0698, /* horizontal timings */ + 0x0400, 0x0400, 0x0401, 0x0404, 0x042A, 0x042A, /* vertical timings */ + 0x006C0000, /* freq = 108.0 MHz */ + }, + + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 16 bpp */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0500, 0x0500, 0x0510, 0x05A0, 0x0698, 0x0698, /* horizontal timings */ + 0x0400, 0x0400, 0x0401, 0x0404, 0x042A, 0x042A, /* vertical timings */ + 0x00870000, /* freq = 135.0 MHz */ + }, + + {GFX_MODE_85HZ | /* refresh rate = 85 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 16 bpp */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0500, 0x0500, 0x0540, 0x05E0, 0x06C0, 0x06C0, /* horizontal timings */ + 0x0400, 0x0400, 0x0401, 0x0404, 0x0430, 0x0430, /* vertical timings */ + 0x009D8000, /* freq = 157.5 MHz */ + }, /*********************************/ /* BEGIN REDCLOUD-SPECIFIC MODES */ @@ -429,37 +429,37 @@ DISPLAYMODE DisplayParams[] = { /* 1600 x 1200 */ - {GFX_MODE_60HZ | /* refresh rate = 60 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 32 bpp */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0640, 0x0640, 0x0680, 0x0740, 0x0870, 0x0870, /* horizontal timings */ - 0x04B0, 0x04B0, 0x04B1, 0x04B4, 0x04E2, 0x04E2, /* vertical timings */ - 0x00A20000, /* freq = 162.0 MHz */ - }, - - {GFX_MODE_70HZ | /* refresh rate = 70 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 32 bpp */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0640, 0x0640, 0x0680, 0x0740, 0x0870, 0x0870, /* horizontal timings */ - 0x04B0, 0x04B0, 0x04B1, 0x04B4, 0x04E2, 0x04E2, /* vertical timings */ - 0x00BD0000, /* freq = 189.0 MHz */ - }, - - {GFX_MODE_75HZ | /* refresh rate = 75 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 32 bpp */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0640, 0x0640, 0x0680, 0x0740, 0x0870, 0x0870, /* horizontal timings */ - 0x04B0, 0x04B0, 0x04B1, 0x04B4, 0x04E2, 0x04E2, /* vertical timings */ - 0x00CA8000, /* freq = 202.5 MHz */ - }, - - {GFX_MODE_85HZ | /* refresh rate = 85 */ - GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 32 bpp */ - GFX_MODE_16BPP | GFX_MODE_24BPP, - 0x0640, 0x0640, 0x0680, 0x0740, 0x0870, 0x0870, /* horizontal timings */ - 0x04B0, 0x04B0, 0x04B1, 0x04B4, 0x04E2, 0x04E2, /* vertical timings */ - 0x00E58000, /* freq = 229.5 MHz */ - }, + {GFX_MODE_60HZ | /* refresh rate = 60 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 32 bpp */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0640, 0x0640, 0x0680, 0x0740, 0x0870, 0x0870, /* horizontal timings */ + 0x04B0, 0x04B0, 0x04B1, 0x04B4, 0x04E2, 0x04E2, /* vertical timings */ + 0x00A20000, /* freq = 162.0 MHz */ + }, + + {GFX_MODE_70HZ | /* refresh rate = 70 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 32 bpp */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0640, 0x0640, 0x0680, 0x0740, 0x0870, 0x0870, /* horizontal timings */ + 0x04B0, 0x04B0, 0x04B1, 0x04B4, 0x04E2, 0x04E2, /* vertical timings */ + 0x00BD0000, /* freq = 189.0 MHz */ + }, + + {GFX_MODE_75HZ | /* refresh rate = 75 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 32 bpp */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0640, 0x0640, 0x0680, 0x0740, 0x0870, 0x0870, /* horizontal timings */ + 0x04B0, 0x04B0, 0x04B1, 0x04B4, 0x04E2, 0x04E2, /* vertical timings */ + 0x00CA8000, /* freq = 202.5 MHz */ + }, + + {GFX_MODE_85HZ | /* refresh rate = 85 */ + GFX_MODE_8BPP | GFX_MODE_12BPP | GFX_MODE_15BPP | /* Up to 32 bpp */ + GFX_MODE_16BPP | GFX_MODE_24BPP, + 0x0640, 0x0640, 0x0680, 0x0740, 0x0870, 0x0870, /* horizontal timings */ + 0x04B0, 0x04B0, 0x04B1, 0x04B4, 0x04E2, 0x04E2, /* vertical timings */ + 0x00E58000, /* freq = 229.5 MHz */ + }, }; /* UPDATE THIS VARIABLE WHENEVER NEW REDCLOUD-SPECIFIC MODES ARE ADDED */ @@ -471,115 +471,115 @@ DISPLAYMODE DisplayParams[] = { FIXEDTIMINGS FixedParams[] = { /* 640x480 Panel */ - {640, 480, 640, 480, - 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, - 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, - 0x00192CCC, - }, - - {640, 480, 800, 600, - 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, - 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, - 0x00192CCC, - }, - - {640, 480, 1024, 768, - 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, - 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, - 0x00192CCC, - }, - - {640, 480, 1152, 864, - 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, - 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, - 0x00192CCC, - }, - - {640, 480, 1280, 1024, - 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, - 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, - 0x00192CCC, - }, - - {640, 480, 1600, 1200, - 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, - 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, - 0x00192CCC, - }, + {640, 480, 640, 480, + 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, + 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, + 0x00192CCC, + }, + + {640, 480, 800, 600, + 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, + 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, + 0x00192CCC, + }, + + {640, 480, 1024, 768, + 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, + 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, + 0x00192CCC, + }, + + {640, 480, 1152, 864, + 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, + 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, + 0x00192CCC, + }, + + {640, 480, 1280, 1024, + 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, + 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, + 0x00192CCC, + }, + + {640, 480, 1600, 1200, + 0x0280, 0x280, 0x2a8, 0x328, 0x380, 0x380, + 0x1e0, 0x1e0, 0x1e1, 0x1e5, 0x1fc, 0x1fc, + 0x00192CCC, + }, /* 800x600 Panel */ - {800, 600, 640, 480, - 0x0280, 0x2d0, 0x2f8, 0x378, 0x3d0, 0x420, - 0x1e0, 0x21c, 0x21d, 0x221, 0x238, 0x274, - 0x00280000, - }, - - {800, 600, 800, 600, - 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, - 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, - 0x00280000, - }, - - {800, 600, 1024, 768, - 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, - 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, - 0x00280000, - }, - - {800, 600, 1152, 864, - 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, - 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, - 0x00280000, - }, - - {800, 600, 1280, 1024, - 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, - 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, - 0x00280000, - }, - - {800, 600, 1600, 1200, - 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, - 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, - 0x00280000, - }, + {800, 600, 640, 480, + 0x0280, 0x2d0, 0x2f8, 0x378, 0x3d0, 0x420, + 0x1e0, 0x21c, 0x21d, 0x221, 0x238, 0x274, + 0x00280000, + }, + + {800, 600, 800, 600, + 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, + 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, + 0x00280000, + }, + + {800, 600, 1024, 768, + 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, + 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, + 0x00280000, + }, + + {800, 600, 1152, 864, + 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, + 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, + 0x00280000, + }, + + {800, 600, 1280, 1024, + 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, + 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, + 0x00280000, + }, + + {800, 600, 1600, 1200, + 0x320, 0x320, 0x348, 0x3c8, 0x420, 0x420, + 0x258, 0x258, 0x259, 0x25d, 0x274, 0x274, + 0x00280000, + }, /* 1024x768 panel */ - {1024, 768, 640, 480, - 0x0280, 0x340, 0x368, 0x3e8, 0x440, 0x500, - 0x1e0, 0x270, 0x271, 0x275, 0x28c, 0x31c, - 0x00410000, - }, - - {1024, 768, 800, 600, - 0x0320, 0x390, 0x3b8, 0x438, 0x490, 0x500, - 0x258, 0x2ac, 0x2ad, 0x2b1, 0x2c8, 0x31c, - 0x00410000, - }, - - {1024, 768, 1024, 768, - 0x0400, 0x400, 0x428, 0x4a8, 0x500, 0x500, - 0x300, 0x300, 0x301, 0x305, 0x31c, 0x31c, - 0x00410000, - }, - - {1024, 768, 1152, 864, - 0x0400, 0x400, 0x428, 0x4a8, 0x500, 0x500, - 0x300, 0x300, 0x301, 0x305, 0x31c, 0x31c, - 0x00410000, - }, - - {1024, 768, 1280, 1024, - 0x0400, 0x400, 0x428, 0x4a8, 0x500, 0x500, - 0x300, 0x300, 0x301, 0x305, 0x31c, 0x31c, - 0x00410000, - }, - - {1024, 768, 1600, 1200, - 0x0400, 0x400, 0x428, 0x4a8, 0x500, 0x500, - 0x300, 0x300, 0x301, 0x305, 0x31c, 0x31c, - 0x00410000, - }, + {1024, 768, 640, 480, + 0x0280, 0x340, 0x368, 0x3e8, 0x440, 0x500, + 0x1e0, 0x270, 0x271, 0x275, 0x28c, 0x31c, + 0x00410000, + }, + + {1024, 768, 800, 600, + 0x0320, 0x390, 0x3b8, 0x438, 0x490, 0x500, + 0x258, 0x2ac, 0x2ad, 0x2b1, 0x2c8, 0x31c, + 0x00410000, + }, + + {1024, 768, 1024, 768, + 0x0400, 0x400, 0x428, 0x4a8, 0x500, 0x500, + 0x300, 0x300, 0x301, 0x305, 0x31c, 0x31c, + 0x00410000, + }, + + {1024, 768, 1152, 864, + 0x0400, 0x400, 0x428, 0x4a8, 0x500, 0x500, + 0x300, 0x300, 0x301, 0x305, 0x31c, 0x31c, + 0x00410000, + }, + + {1024, 768, 1280, 1024, + 0x0400, 0x400, 0x428, 0x4a8, 0x500, 0x500, + 0x300, 0x300, 0x301, 0x305, 0x31c, 0x31c, + 0x00410000, + }, + + {1024, 768, 1600, 1200, + 0x0400, 0x400, 0x428, 0x4a8, 0x500, 0x500, + 0x300, 0x300, 0x301, 0x305, 0x31c, 0x31c, + 0x00410000, + }, }; @@ -600,18 +600,17 @@ FIXEDTIMINGS FixedParams[] = { void gfx_set_display_video_format(unsigned long format); void gfx_set_display_video_enable(int enable); void gfx_set_display_video_yuv_offsets(unsigned long yoffset, - unsigned long uoffset, - unsigned long voffset); + unsigned long uoffset, + unsigned long voffset); void gfx_set_display_video_yuv_pitch(unsigned long ypitch, - unsigned long uvpitch); -void gfx_set_display_video_downscale(unsigned short srch, - unsigned short dsth); + unsigned long uvpitch); +void gfx_set_display_video_downscale(unsigned short srch, unsigned short dsth); void gfx_set_display_video_vertical_downscale_enable(int enable); void gfx_get_display_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset); + unsigned long *uoffset, + unsigned long *voffset); void gfx_get_display_video_yuv_pitch(unsigned long *ypitch, - unsigned long *uvpitch); + unsigned long *uvpitch); unsigned long gfx_get_display_video_downscale_delta(void); int gfx_get_display_video_downscale_enable(void); unsigned long gfx_get_display_video_size(void); @@ -629,7 +628,7 @@ unsigned long gfx_get_display_video_offset(void); void gfx_reset_timing_lock(void) { - gfx_timing_lock = 0; + gfx_timing_lock = 0; } /* WRAPPERS IF DYNAMIC SELECTION */ @@ -644,17 +643,17 @@ gfx_reset_timing_lock(void) int gfx_set_display_bpp(unsigned short bpp) { - int retval = 0; + int retval = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_set_display_bpp(bpp); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_set_display_bpp(bpp); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_set_display_bpp(bpp); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_set_display_bpp(bpp); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -666,17 +665,17 @@ gfx_set_display_bpp(unsigned short bpp) int gfx_is_display_mode_supported(int xres, int yres, int bpp, int hz) { - int retval = -1; + int retval = -1; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_is_display_mode_supported(xres, yres, bpp, hz); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_is_display_mode_supported(xres, yres, bpp, hz); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_is_display_mode_supported(xres, yres, bpp, hz); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_is_display_mode_supported(xres, yres, bpp, hz); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -686,17 +685,17 @@ gfx_is_display_mode_supported(int xres, int yres, int bpp, int hz) int gfx_set_display_mode(int xres, int yres, int bpp, int hz) { - int retval = 0; + int retval = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_set_display_mode(xres, yres, bpp, hz); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_set_display_mode(xres, yres, bpp, hz); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_set_display_mode(xres, yres, bpp, hz); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_set_display_mode(xres, yres, bpp, hz); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -705,33 +704,33 @@ gfx_set_display_mode(int xres, int yres, int bpp, int hz) */ int gfx_set_display_timings(unsigned short bpp, unsigned short flags, - unsigned short hactive, unsigned short hblankstart, - unsigned short hsyncstart, unsigned short hsyncend, - unsigned short hblankend, unsigned short htotal, - unsigned short vactive, unsigned short vblankstart, - unsigned short vsyncstart, unsigned short vsyncend, - unsigned short vblankend, unsigned short vtotal, - unsigned long frequency) + unsigned short hactive, unsigned short hblankstart, + unsigned short hsyncstart, unsigned short hsyncend, + unsigned short hblankend, unsigned short htotal, + unsigned short vactive, unsigned short vblankstart, + unsigned short vsyncstart, unsigned short vsyncend, + unsigned short vblankend, unsigned short vtotal, + unsigned long frequency) { - int retval = 0; + int retval = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_set_display_timings(bpp, flags, - hactive, hblankstart, hsyncstart, - hsyncend, hblankend, htotal, vactive, - vblankstart, vsyncstart, vsyncend, - vblankend, vtotal, frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_set_display_timings(bpp, flags, + hactive, hblankstart, hsyncstart, + hsyncend, hblankend, htotal, vactive, + vblankstart, vsyncstart, vsyncend, + vblankend, vtotal, frequency); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_set_display_timings(bpp, flags, - hactive, hblankstart, hsyncstart, - hsyncend, hblankend, htotal, vactive, - vblankstart, vsyncstart, vsyncend, - vblankend, vtotal, frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_set_display_timings(bpp, flags, + hactive, hblankstart, hsyncstart, + hsyncend, hblankend, htotal, vactive, + vblankstart, vsyncstart, vsyncend, + vblankend, vtotal, frequency); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -742,12 +741,12 @@ void gfx_set_display_pitch(unsigned short pitch) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_display_pitch(pitch); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_display_pitch(pitch); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_pitch(pitch); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_pitch(pitch); # endif } @@ -759,12 +758,12 @@ void gfx_set_display_offset(unsigned long offset) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_display_offset(offset); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_display_offset(offset); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_offset(offset); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_offset(offset); # endif } @@ -775,17 +774,17 @@ gfx_set_display_offset(unsigned long offset) int gfx_set_display_palette_entry(unsigned long index, unsigned long palette) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_set_display_palette_entry(index, palette); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_set_display_palette_entry(index, palette); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_set_display_palette_entry(index, palette); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_set_display_palette_entry(index, palette); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -795,17 +794,17 @@ gfx_set_display_palette_entry(unsigned long index, unsigned long palette) int gfx_set_display_palette(unsigned long *palette) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_set_display_palette(palette); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_set_display_palette(palette); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_set_display_palette(palette); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_set_display_palette(palette); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -816,12 +815,12 @@ void gfx_set_cursor_enable(int enable) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_cursor_enable(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_cursor_enable(enable); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_cursor_enable(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_cursor_enable(enable); # endif } @@ -833,12 +832,12 @@ void gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_cursor_colors(bkcolor, fgcolor); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_cursor_colors(bkcolor, fgcolor); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_cursor_colors(bkcolor, fgcolor); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_cursor_colors(bkcolor, fgcolor); # endif } @@ -848,16 +847,16 @@ gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor) */ void gfx_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, unsigned short yhotspot) + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, unsigned short yhotspot) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_cursor_position(memoffset, xpos, ypos, xhotspot, yhotspot); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_cursor_position(memoffset, xpos, ypos, xhotspot, yhotspot); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_cursor_position(memoffset, xpos, ypos, xhotspot, yhotspot); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_cursor_position(memoffset, xpos, ypos, xhotspot, yhotspot); # endif } @@ -867,15 +866,15 @@ gfx_set_cursor_position(unsigned long memoffset, */ void gfx_set_cursor_shape32(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_cursor_shape32(memoffset, andmask, xormask); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_cursor_shape32(memoffset, andmask, xormask); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_cursor_shape32(memoffset, andmask, xormask); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_cursor_shape32(memoffset, andmask, xormask); # endif } @@ -885,11 +884,11 @@ gfx_set_cursor_shape32(unsigned long memoffset, */ void gfx_set_cursor_shape64(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_cursor_shape64(memoffset, andmask, xormask); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_cursor_shape64(memoffset, andmask, xormask); # endif } @@ -901,8 +900,8 @@ void gfx_set_icon_enable(int enable) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_icon_enable(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_icon_enable(enable); # endif } @@ -912,11 +911,11 @@ gfx_set_icon_enable(int enable) */ void gfx_set_icon_colors(unsigned long color0, unsigned long color1, - unsigned long color2) + unsigned long color2) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_icon_colors(color0, color1, color2); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_icon_colors(color0, color1, color2); # endif } @@ -928,8 +927,8 @@ void gfx_set_icon_position(unsigned long memoffset, unsigned short xpos) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_icon_position(memoffset, xpos); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_icon_position(memoffset, xpos); # endif } @@ -939,12 +938,12 @@ gfx_set_icon_position(unsigned long memoffset, unsigned short xpos) */ void gfx_set_icon_shape64(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask, - unsigned int lines) + unsigned long *andmask, unsigned long *xormask, + unsigned int lines) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_icon_shape64(memoffset, andmask, xormask, lines); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_icon_shape64(memoffset, andmask, xormask, lines); # endif } @@ -955,17 +954,17 @@ gfx_set_icon_shape64(unsigned long memoffset, int gfx_set_compression_enable(int enable) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_set_compression_enable(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_set_compression_enable(enable); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_set_compression_enable(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_set_compression_enable(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -975,17 +974,17 @@ gfx_set_compression_enable(int enable) int gfx_set_compression_offset(unsigned long offset) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_set_compression_offset(offset); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_set_compression_offset(offset); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_set_compression_offset(offset); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_set_compression_offset(offset); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -995,17 +994,17 @@ gfx_set_compression_offset(unsigned long offset) int gfx_set_compression_pitch(unsigned short pitch) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_set_compression_pitch(pitch); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_set_compression_pitch(pitch); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_set_compression_pitch(pitch); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_set_compression_pitch(pitch); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1015,17 +1014,17 @@ gfx_set_compression_pitch(unsigned short pitch) int gfx_set_compression_size(unsigned short size) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_set_compression_size(size); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_set_compression_size(size); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_set_compression_size(size); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_set_compression_size(size); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1036,8 +1035,8 @@ void gfx_set_display_priority_high(int enable) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_display_priority_high(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_display_priority_high(enable); # endif } @@ -1052,8 +1051,8 @@ void gfx_set_display_video_format(unsigned long format) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_video_format(format); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_video_format(format); # endif } @@ -1068,14 +1067,14 @@ void gfx_set_display_video_enable(int enable) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_display_video_enable(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_display_video_enable(enable); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_video_enable(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_video_enable(enable); # endif - return; + return; } /*--------------------------------------------------------------------------- @@ -1089,12 +1088,12 @@ void gfx_set_display_video_size(unsigned short width, unsigned short height) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_display_video_size(width, height); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_display_video_size(width, height); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_video_size(width, height); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_video_size(width, height); # endif } @@ -1109,12 +1108,12 @@ void gfx_set_display_video_offset(unsigned long offset) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_set_display_video_offset(offset); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_set_display_video_offset(offset); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_video_offset(offset); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_video_offset(offset); # endif } @@ -1127,12 +1126,11 @@ gfx_set_display_video_offset(unsigned long offset) */ void gfx_set_display_video_yuv_offsets(unsigned long yoffset, - unsigned long uoffset, - unsigned long voffset) + unsigned long uoffset, unsigned long voffset) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_video_yuv_offsets(yoffset, uoffset, voffset); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_video_yuv_offsets(yoffset, uoffset, voffset); # endif } @@ -1147,8 +1145,8 @@ void gfx_set_display_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_video_yuv_pitch(ypitch, uvpitch); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_video_yuv_pitch(ypitch, uvpitch); # endif } @@ -1163,8 +1161,8 @@ void gfx_set_display_video_downscale(unsigned short srch, unsigned short dsth) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_video_downscale(srch, dsth); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_video_downscale(srch, dsth); # endif } @@ -1179,8 +1177,8 @@ void gfx_set_display_video_vertical_downscale_enable(int enable) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_set_display_video_vertical_downscale_enable(enable); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_set_display_video_vertical_downscale_enable(enable); # endif } @@ -1191,17 +1189,17 @@ gfx_set_display_video_vertical_downscale_enable(int enable) int gfx_test_timing_active(void) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_test_timing_active(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_test_timing_active(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_test_timing_active(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_test_timing_active(); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1211,17 +1209,17 @@ gfx_test_timing_active(void) int gfx_test_vertical_active(void) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_test_vertical_active(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_test_vertical_active(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_test_vertical_active(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_test_vertical_active(); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1231,17 +1229,17 @@ gfx_test_vertical_active(void) int gfx_wait_vertical_blank(void) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_wait_vertical_blank(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_wait_vertical_blank(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_wait_vertical_blank(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_wait_vertical_blank(); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1252,12 +1250,12 @@ void gfx_delay_milliseconds(unsigned long milliseconds) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_delay_milliseconds(milliseconds); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_delay_milliseconds(milliseconds); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_delay_milliseconds(milliseconds); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_delay_milliseconds(milliseconds); # endif } @@ -1269,12 +1267,12 @@ void gfx_delay_microseconds(unsigned long microseconds) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_delay_microseconds(microseconds); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_delay_microseconds(microseconds); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_delay_microseconds(microseconds); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_delay_microseconds(microseconds); # endif } @@ -1289,12 +1287,12 @@ void gfx_enable_panning(int x, int y) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_enable_panning(x, y); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_enable_panning(x, y); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_enable_panning(x, y); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_enable_panning(x, y); # endif } @@ -1304,21 +1302,21 @@ gfx_enable_panning(int x, int y) */ int gfx_set_fixed_timings(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = - gu1_set_fixed_timings(panelResX, panelResY, width, height, bpp); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = + gu1_set_fixed_timings(panelResX, panelResY, width, height, bpp); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = - gu2_set_fixed_timings(panelResX, panelResY, width, height, bpp); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = + gu2_set_fixed_timings(panelResX, panelResY, width, height, bpp); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1327,21 +1325,21 @@ gfx_set_fixed_timings(int panelResX, int panelResY, unsigned short width, */ int gfx_set_panel_present(int panelResX, int panelResY, unsigned short width, - unsigned short height, unsigned short bpp) + unsigned short height, unsigned short bpp) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = - gu1_set_panel_present(panelResX, panelResY, width, height, bpp); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = + gu1_set_panel_present(panelResX, panelResY, width, height, bpp); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = - gu2_set_panel_present(panelResX, panelResY, width, height, bpp); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = + gu2_set_panel_present(panelResX, panelResY, width, height, bpp); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1351,17 +1349,17 @@ gfx_set_panel_present(int panelResX, int panelResY, unsigned short width, int gfx_set_vtotal(unsigned short vtotal) { - int retval = 0; + int retval = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_set_vtotal(vtotal); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_set_vtotal(vtotal); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_set_vtotal(vtotal); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_set_vtotal(vtotal); # endif - return (retval); + return (retval); } /*-----------------------------------------------------------------------* @@ -1381,19 +1379,19 @@ gfx_set_vtotal(unsigned short vtotal) */ int gfx_mode_frequency_supported(int xres, int yres, int bpp, - unsigned long frequency) + unsigned long frequency) { - int freq = 0; + int freq = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - freq = gu1_mode_frequency_supported(xres, yres, bpp, frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + freq = gu1_mode_frequency_supported(xres, yres, bpp, frequency); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - freq = gu2_mode_frequency_supported(xres, yres, bpp, frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + freq = gu2_mode_frequency_supported(xres, yres, bpp, frequency); # endif - return (freq); + return (freq); } /*---------------------------------------------------------------------------- @@ -1402,18 +1400,18 @@ gfx_mode_frequency_supported(int xres, int yres, int bpp, */ int gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_get_refreshrate_from_frequency(xres, yres, bpp, hz, frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_get_refreshrate_from_frequency(xres, yres, bpp, hz, frequency); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_get_refreshrate_from_frequency(xres, yres, bpp, hz, frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_get_refreshrate_from_frequency(xres, yres, bpp, hz, frequency); # endif - return (1); + return (1); } /*---------------------------------------------------------------------------- @@ -1422,18 +1420,18 @@ gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz, */ int gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_get_refreshrate_from_mode(xres, yres, bpp, hz, frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_get_refreshrate_from_mode(xres, yres, bpp, hz, frequency); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_get_refreshrate_from_mode(xres, yres, bpp, hz, frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_get_refreshrate_from_mode(xres, yres, bpp, hz, frequency); # endif - return (1); + return (1); } /*---------------------------------------------------------------------------- @@ -1442,24 +1440,22 @@ gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, */ int gfx_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, - int *frequency) + int *frequency) { - int retval = -1; + int retval = -1; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = - gu1_get_frequency_from_refreshrate(xres, yres, bpp, hz, - frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = + gu1_get_frequency_from_refreshrate(xres, yres, bpp, hz, frequency); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = - gu2_get_frequency_from_refreshrate(xres, yres, bpp, hz, - frequency); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = + gu2_get_frequency_from_refreshrate(xres, yres, bpp, hz, frequency); # endif - return retval; + return retval; } /*--------------------------------------------------------------------------- @@ -1469,17 +1465,17 @@ gfx_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, unsigned long gfx_get_max_supported_pixel_clock(void) { - unsigned long status = 0; + unsigned long status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_get_max_supported_pixel_clock(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_get_max_supported_pixel_clock(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_get_max_supported_pixel_clock(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_get_max_supported_pixel_clock(); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1489,17 +1485,17 @@ gfx_get_max_supported_pixel_clock(void) unsigned short gfx_get_display_pitch(void) { - unsigned short pitch = 0; + unsigned short pitch = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - pitch = gu1_get_display_pitch(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + pitch = gu1_get_display_pitch(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - pitch = gu2_get_display_pitch(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + pitch = gu2_get_display_pitch(); # endif - return (pitch); + return (pitch); } /*--------------------------------------------------------------------------- @@ -1510,17 +1506,17 @@ gfx_get_display_pitch(void) int gfx_get_display_mode_count(void) { - int retval = 0; + int retval = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_get_display_mode_count(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_get_display_mode_count(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_get_display_mode_count(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_get_display_mode_count(); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -1530,17 +1526,17 @@ gfx_get_display_mode_count(void) unsigned long gfx_get_frame_buffer_line_size(void) { - unsigned long retval = 0; + unsigned long retval = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_get_frame_buffer_line_size(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_get_frame_buffer_line_size(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_get_frame_buffer_line_size(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_get_frame_buffer_line_size(); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -1552,17 +1548,17 @@ gfx_get_frame_buffer_line_size(void) int gfx_get_display_mode(int *xres, int *yres, int *bpp, int *hz) { - int retval = -1; + int retval = -1; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_get_display_mode(xres, yres, bpp, hz); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_get_display_mode(xres, yres, bpp, hz); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_get_display_mode(xres, yres, bpp, hz); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_get_display_mode(xres, yres, bpp, hz); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -1573,17 +1569,17 @@ gfx_get_display_mode(int *xres, int *yres, int *bpp, int *hz) int gfx_get_display_details(unsigned int mode, int *xres, int *yres, int *hz) { - int retval = -1; + int retval = -1; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - retval = gu1_get_display_details(mode, xres, yres, hz); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + retval = gu1_get_display_details(mode, xres, yres, hz); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - retval = gu2_get_display_details(mode, xres, yres, hz); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + retval = gu2_get_display_details(mode, xres, yres, hz); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -1593,17 +1589,17 @@ gfx_get_display_details(unsigned int mode, int *xres, int *yres, int *hz) unsigned short gfx_get_hactive(void) { - unsigned short hactive = 0; + unsigned short hactive = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - hactive = gu1_get_hactive(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + hactive = gu1_get_hactive(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - hactive = gu2_get_hactive(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + hactive = gu2_get_hactive(); # endif - return (hactive); + return (hactive); } /*--------------------------------------------------------------------------- @@ -1613,17 +1609,17 @@ gfx_get_hactive(void) unsigned short gfx_get_hsync_start(void) { - unsigned short hsync_start = 0; + unsigned short hsync_start = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - hsync_start = gu1_get_hsync_start(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + hsync_start = gu1_get_hsync_start(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - hsync_start = gu2_get_hsync_start(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + hsync_start = gu2_get_hsync_start(); # endif - return (hsync_start); + return (hsync_start); } /*--------------------------------------------------------------------------- @@ -1633,17 +1629,17 @@ gfx_get_hsync_start(void) unsigned short gfx_get_hsync_end(void) { - unsigned short hsync_end = 0; + unsigned short hsync_end = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - hsync_end = gu1_get_hsync_end(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + hsync_end = gu1_get_hsync_end(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - hsync_end = gu2_get_hsync_end(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + hsync_end = gu2_get_hsync_end(); # endif - return (hsync_end); + return (hsync_end); } /*--------------------------------------------------------------------------- @@ -1653,17 +1649,17 @@ gfx_get_hsync_end(void) unsigned short gfx_get_htotal(void) { - unsigned short htotal = 0; + unsigned short htotal = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - htotal = gu1_get_htotal(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + htotal = gu1_get_htotal(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - htotal = gu2_get_htotal(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + htotal = gu2_get_htotal(); # endif - return (htotal); + return (htotal); } /*--------------------------------------------------------------------------- @@ -1673,17 +1669,17 @@ gfx_get_htotal(void) unsigned short gfx_get_vactive(void) { - unsigned short vactive = 0; + unsigned short vactive = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - vactive = gu1_get_vactive(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + vactive = gu1_get_vactive(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - vactive = gu2_get_vactive(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + vactive = gu2_get_vactive(); # endif - return (vactive); + return (vactive); } /*--------------------------------------------------------------------------- @@ -1693,17 +1689,17 @@ gfx_get_vactive(void) unsigned short gfx_get_vsync_end(void) { - unsigned short vsync_end = 0; + unsigned short vsync_end = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - vsync_end = gu1_get_vsync_end(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + vsync_end = gu1_get_vsync_end(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - vsync_end = gu2_get_vsync_end(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + vsync_end = gu2_get_vsync_end(); # endif - return (vsync_end); + return (vsync_end); } /*--------------------------------------------------------------------------- @@ -1713,17 +1709,17 @@ gfx_get_vsync_end(void) unsigned short gfx_get_vtotal(void) { - unsigned short vtotal = 0; + unsigned short vtotal = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - vtotal = gu1_get_vtotal(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + vtotal = gu1_get_vtotal(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - vtotal = gu2_get_vtotal(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + vtotal = gu2_get_vtotal(); # endif - return (vtotal); + return (vtotal); } /*--------------------------------------------------------------------------- @@ -1733,17 +1729,17 @@ gfx_get_vtotal(void) unsigned short gfx_get_display_bpp(void) { - unsigned short bpp = 0; + unsigned short bpp = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - bpp = gu1_get_display_bpp(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + bpp = gu1_get_display_bpp(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - bpp = gu2_get_display_bpp(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + bpp = gu2_get_display_bpp(); # endif - return (bpp); + return (bpp); } /*--------------------------------------------------------------------------- @@ -1753,17 +1749,17 @@ gfx_get_display_bpp(void) unsigned short gfx_get_vline(void) { - unsigned short vline = 0; + unsigned short vline = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - vline = gu1_get_vline(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + vline = gu1_get_vline(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - vline = gu2_get_vline(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + vline = gu2_get_vline(); # endif - return (vline); + return (vline); } /*--------------------------------------------------------------------------- @@ -1773,17 +1769,17 @@ gfx_get_vline(void) unsigned long gfx_get_display_offset(void) { - unsigned long offset = 0; + unsigned long offset = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - offset = gu1_get_display_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + offset = gu1_get_display_offset(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - offset = gu2_get_display_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + offset = gu2_get_display_offset(); # endif - return (offset); + return (offset); } /*--------------------------------------------------------------------------- @@ -1793,17 +1789,17 @@ gfx_get_display_offset(void) unsigned long gfx_get_cursor_offset(void) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - base = gu1_get_cursor_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + base = gu1_get_cursor_offset(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - base = gu2_get_cursor_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + base = gu2_get_cursor_offset(); # endif - return (base); + return (base); } /*************************************************************/ @@ -1819,17 +1815,17 @@ gfx_get_cursor_offset(void) unsigned short gfx_get_hblank_start(void) { - unsigned short hblank_start = 0; + unsigned short hblank_start = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - hblank_start = gu1_get_hblank_start(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + hblank_start = gu1_get_hblank_start(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - hblank_start = gu2_get_hblank_start(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + hblank_start = gu2_get_hblank_start(); # endif - return (hblank_start); + return (hblank_start); } /*--------------------------------------------------------------------------- @@ -1839,17 +1835,17 @@ gfx_get_hblank_start(void) unsigned short gfx_get_hblank_end(void) { - unsigned short hblank_end = 0; + unsigned short hblank_end = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - hblank_end = gu1_get_hblank_end(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + hblank_end = gu1_get_hblank_end(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - hblank_end = gu2_get_hblank_end(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + hblank_end = gu2_get_hblank_end(); # endif - return (hblank_end); + return (hblank_end); } /*--------------------------------------------------------------------------- @@ -1859,17 +1855,17 @@ gfx_get_hblank_end(void) unsigned short gfx_get_vblank_start(void) { - unsigned short vblank_start = 0; + unsigned short vblank_start = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - vblank_start = gu1_get_vblank_start(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + vblank_start = gu1_get_vblank_start(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - vblank_start = gu2_get_vblank_start(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + vblank_start = gu2_get_vblank_start(); # endif - return (vblank_start); + return (vblank_start); } /*--------------------------------------------------------------------------- @@ -1879,17 +1875,17 @@ gfx_get_vblank_start(void) unsigned short gfx_get_vsync_start(void) { - unsigned short vsync_start = 0; + unsigned short vsync_start = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - vsync_start = gu1_get_vsync_start(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + vsync_start = gu1_get_vsync_start(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - vsync_start = gu2_get_vsync_start(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + vsync_start = gu2_get_vsync_start(); # endif - return (vsync_start); + return (vsync_start); } /*--------------------------------------------------------------------------- @@ -1899,17 +1895,17 @@ gfx_get_vsync_start(void) unsigned short gfx_get_vblank_end(void) { - unsigned short vblank_end = 0; + unsigned short vblank_end = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - vblank_end = gu1_get_vblank_end(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + vblank_end = gu1_get_vblank_end(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - vblank_end = gu2_get_vblank_end(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + vblank_end = gu2_get_vblank_end(); # endif - return (vblank_end); + return (vblank_end); } /*--------------------------------------------------------------------------- @@ -1919,18 +1915,18 @@ gfx_get_vblank_end(void) int gfx_get_display_palette_entry(unsigned long index, unsigned long *palette) { - int status = 0; + int status = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - status = gu1_get_display_palette_entry(index, palette); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + status = gu1_get_display_palette_entry(index, palette); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - status = gu2_get_display_palette_entry(index, palette); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + status = gu2_get_display_palette_entry(index, palette); # endif - return status; + return status; } /*--------------------------------------------------------------------------- @@ -1941,12 +1937,12 @@ void gfx_get_display_palette(unsigned long *palette) { # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - gu1_get_display_palette(palette); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + gu1_get_display_palette(palette); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_get_display_palette(palette); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_get_display_palette(palette); # endif } @@ -1957,17 +1953,17 @@ gfx_get_display_palette(unsigned long *palette) unsigned long gfx_get_cursor_enable(void) { - unsigned long enable = 0; + unsigned long enable = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - enable = gu1_get_cursor_enable(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + enable = gu1_get_cursor_enable(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - enable = gu2_get_cursor_enable(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + enable = gu2_get_cursor_enable(); # endif - return (enable); + return (enable); } /*--------------------------------------------------------------------------- @@ -1977,17 +1973,17 @@ gfx_get_cursor_enable(void) unsigned long gfx_get_cursor_position(void) { - unsigned long position = 0; + unsigned long position = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - position = gu1_get_cursor_position(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + position = gu1_get_cursor_position(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - position = gu2_get_cursor_position(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + position = gu2_get_cursor_position(); # endif - return (position); + return (position); } /*--------------------------------------------------------------------------- @@ -1997,17 +1993,17 @@ gfx_get_cursor_position(void) unsigned long gfx_get_cursor_clip(void) { - unsigned long offset = 0; + unsigned long offset = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - offset = gu1_get_cursor_clip(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + offset = gu1_get_cursor_clip(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - offset = gu2_get_cursor_clip(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + offset = gu2_get_cursor_clip(); # endif - return (offset); + return (offset); } /*--------------------------------------------------------------------------- @@ -2017,17 +2013,17 @@ gfx_get_cursor_clip(void) unsigned long gfx_get_cursor_color(int index) { - unsigned long color = 0; + unsigned long color = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - color = gu1_get_cursor_color(index); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + color = gu1_get_cursor_color(index); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - color = gu2_get_cursor_color(index); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + color = gu2_get_cursor_color(index); # endif - return (color); + return (color); } /*--------------------------------------------------------------------------- @@ -2037,13 +2033,13 @@ gfx_get_cursor_color(int index) unsigned long gfx_get_icon_enable(void) { - unsigned long enable = 0; + unsigned long enable = 0; # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - enable = gu2_get_icon_enable(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + enable = gu2_get_icon_enable(); # endif - return (enable); + return (enable); } /*--------------------------------------------------------------------------- @@ -2053,14 +2049,14 @@ gfx_get_icon_enable(void) unsigned long gfx_get_icon_offset(void) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - base = gu2_get_icon_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + base = gu2_get_icon_offset(); # endif - return (base); + return (base); } /*--------------------------------------------------------------------------- @@ -2070,14 +2066,14 @@ gfx_get_icon_offset(void) unsigned long gfx_get_icon_position(void) { - unsigned long position = 0; + unsigned long position = 0; # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - position = gu2_get_icon_position(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + position = gu2_get_icon_position(); # endif - return (position); + return (position); } /*--------------------------------------------------------------------------- @@ -2087,14 +2083,14 @@ gfx_get_icon_position(void) unsigned long gfx_get_icon_color(int index) { - unsigned long color = 0; + unsigned long color = 0; # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - color = gu2_get_icon_color(index); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + color = gu2_get_icon_color(index); # endif - return (color); + return (color); } /*--------------------------------------------------------------------------- @@ -2104,17 +2100,17 @@ gfx_get_icon_color(int index) int gfx_get_compression_enable(void) { - int enable = 0; + int enable = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - enable = gu1_get_compression_enable(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + enable = gu1_get_compression_enable(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - enable = gu2_get_compression_enable(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + enable = gu2_get_compression_enable(); # endif - return (enable); + return (enable); } /*--------------------------------------------------------------------------- @@ -2124,17 +2120,17 @@ gfx_get_compression_enable(void) unsigned long gfx_get_compression_offset(void) { - unsigned long offset = 0; + unsigned long offset = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - offset = gu1_get_compression_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + offset = gu1_get_compression_offset(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - offset = gu2_get_compression_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + offset = gu2_get_compression_offset(); # endif - return (offset); + return (offset); } /*--------------------------------------------------------------------------- @@ -2144,17 +2140,17 @@ gfx_get_compression_offset(void) unsigned short gfx_get_compression_pitch(void) { - unsigned short pitch = 0; + unsigned short pitch = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - pitch = gu1_get_compression_pitch(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + pitch = gu1_get_compression_pitch(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - pitch = gu2_get_compression_pitch(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + pitch = gu2_get_compression_pitch(); # endif - return (pitch); + return (pitch); } /*--------------------------------------------------------------------------- @@ -2164,17 +2160,17 @@ gfx_get_compression_pitch(void) unsigned short gfx_get_compression_size(void) { - unsigned short size = 0; + unsigned short size = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - size = gu1_get_compression_size(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + size = gu1_get_compression_size(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - size = gu2_get_compression_size(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + size = gu2_get_compression_size(); # endif - return (size); + return (size); } /*--------------------------------------------------------------------------- @@ -2184,13 +2180,13 @@ gfx_get_compression_size(void) int gfx_get_display_priority_high(void) { - int high = GFX_STATUS_UNSUPPORTED; + int high = GFX_STATUS_UNSUPPORTED; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - high = gu1_get_display_priority_high(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + high = gu1_get_display_priority_high(); # endif - return (high); + return (high); } /*--------------------------------------------------------------------------- @@ -2200,17 +2196,17 @@ gfx_get_display_priority_high(void) int gfx_get_valid_bit(int line) { - int valid = 0; + int valid = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - valid = gu1_get_valid_bit(line); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + valid = gu1_get_valid_bit(line); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - valid = gu2_get_valid_bit(line); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + valid = gu2_get_valid_bit(line); # endif - return (valid); + return (valid); } /*--------------------------------------------------------------------------- @@ -2220,17 +2216,17 @@ gfx_get_valid_bit(int line) unsigned long gfx_get_display_video_offset(void) { - unsigned long offset = 0; + unsigned long offset = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - offset = gu1_get_display_video_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + offset = gu1_get_display_video_offset(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - offset = gu2_get_display_video_offset(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + offset = gu2_get_display_video_offset(); # endif - return (offset); + return (offset); } /*--------------------------------------------------------------------------- @@ -2239,12 +2235,12 @@ gfx_get_display_video_offset(void) */ void gfx_get_display_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset) + unsigned long *uoffset, + unsigned long *voffset) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_get_display_video_yuv_offsets(yoffset, uoffset, voffset); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_get_display_video_yuv_offsets(yoffset, uoffset, voffset); # endif } @@ -2256,8 +2252,8 @@ void gfx_get_display_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch) { # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - gu2_get_display_video_yuv_pitch(ypitch, uvpitch); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + gu2_get_display_video_yuv_pitch(ypitch, uvpitch); # endif } @@ -2268,14 +2264,14 @@ gfx_get_display_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch) unsigned long gfx_get_display_video_downscale_delta(void) { - unsigned long ret_value = 0; + unsigned long ret_value = 0; # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - ret_value = gu2_get_display_video_downscale_delta(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + ret_value = gu2_get_display_video_downscale_delta(); # endif - return ret_value; + return ret_value; } /*--------------------------------------------------------------------------- @@ -2285,14 +2281,14 @@ gfx_get_display_video_downscale_delta(void) int gfx_get_display_video_downscale_enable(void) { - int ret_value = 0; + int ret_value = 0; # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - ret_value = gu2_get_display_video_downscale_enable(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + ret_value = gu2_get_display_video_downscale_enable(); # endif - return ret_value; + return ret_value; } /*--------------------------------------------------------------------------- @@ -2302,21 +2298,21 @@ gfx_get_display_video_downscale_enable(void) unsigned long gfx_get_display_video_size(void) { - unsigned long size = 0; + unsigned long size = 0; # if GFX_DISPLAY_GU1 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) - size = gu1_get_display_video_size(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU1) + size = gu1_get_display_video_size(); # endif # if GFX_DISPLAY_GU2 - if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) - size = gu2_get_display_video_size(); + if (gfx_display_type & GFX_DISPLAY_TYPE_GU2) + size = gu2_get_display_video_size(); # endif - return (size); + return (size); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ -#endif /* GFX_DISPLAY_DYNAMIC */ +#endif /* GFX_DISPLAY_DYNAMIC */ /* END OF FILE */ diff --git a/src/gfx/gfx_i2c.c b/src/gfx/gfx_i2c.c index 385ee9f..4bfad0e 100644 --- a/src/gfx/gfx_i2c.c +++ b/src/gfx/gfx_i2c.c @@ -154,17 +154,17 @@ int gfx_i2c_reset(unsigned char busnum, short adr, char freq) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; #if GFX_I2C_ACCESS - if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) - status = acc_i2c_reset(busnum, adr, freq); + if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) + status = acc_i2c_reset(busnum, adr, freq); #endif #if GFX_I2C_GPIO - if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) - status = gpio_i2c_reset(busnum, adr, freq); + if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) + status = gpio_i2c_reset(busnum, adr, freq); #endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -175,14 +175,14 @@ int gfx_i2c_select_gpio(int clock, int data) { #if GFX_I2C_ACCESS - if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) - acc_i2c_select_gpio(clock, data); + if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) + acc_i2c_select_gpio(clock, data); #endif #if GFX_I2C_GPIO - if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) - gpio_i2c_select_gpio(clock, data); + if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) + gpio_i2c_select_gpio(clock, data); #endif - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -191,19 +191,19 @@ gfx_i2c_select_gpio(int clock, int data) */ int gfx_i2c_write(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, unsigned char *data) + unsigned char subadr, unsigned char bytes, unsigned char *data) { - int status = -1; + int status = -1; #if GFX_I2C_ACCESS - if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) - status = acc_i2c_write(busnum, chipadr, subadr, bytes, data); + if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) + status = acc_i2c_write(busnum, chipadr, subadr, bytes, data); #endif #if GFX_I2C_GPIO - if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) - status = gpio_i2c_write(busnum, chipadr, subadr, bytes, data); + if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) + status = gpio_i2c_write(busnum, chipadr, subadr, bytes, data); #endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -212,19 +212,19 @@ gfx_i2c_write(unsigned char busnum, unsigned char chipadr, */ int gfx_i2c_read(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, unsigned char *data) + unsigned char subadr, unsigned char bytes, unsigned char *data) { - int status = -1; + int status = -1; #if GFX_I2C_ACCESS - if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) - status = acc_i2c_read(busnum, chipadr, subadr, bytes, data); + if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) + status = acc_i2c_read(busnum, chipadr, subadr, bytes, data); #endif #if GFX_I2C_GPIO - if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) - status = gpio_i2c_read(busnum, chipadr, subadr, bytes, data); + if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) + status = gpio_i2c_read(busnum, chipadr, subadr, bytes, data); #endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -234,17 +234,17 @@ gfx_i2c_read(unsigned char busnum, unsigned char chipadr, int gfx_i2c_init(void) { - int status = -1; + int status = -1; #if GFX_I2C_ACCESS - if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) - status = acc_i2c_init(); + if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) + status = acc_i2c_init(); #endif #if GFX_I2C_GPIO - if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) - status = gpio_i2c_init(); + if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) + status = gpio_i2c_init(); #endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -255,15 +255,15 @@ void gfx_i2c_cleanup(void) { #if GFX_I2C_ACCESS - if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) - acc_i2c_cleanup(); + if (gfx_i2c_type & GFX_I2C_TYPE_ACCESS) + acc_i2c_cleanup(); #endif #if GFX_I2C_GPIO - if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) - gpio_i2c_cleanup(); + if (gfx_i2c_type & GFX_I2C_TYPE_GPIO) + gpio_i2c_cleanup(); #endif } -#endif /* GFX_I2C_DYNAMIC */ +#endif /* GFX_I2C_DYNAMIC */ /* END OF FILE */ diff --git a/src/gfx/gfx_init.c b/src/gfx/gfx_init.c index 2aa93d5..fbc5556 100644 --- a/src/gfx/gfx_init.c +++ b/src/gfx/gfx_init.c @@ -190,44 +190,45 @@ ChipType gfx_detect_chip(void); ChipType gfx_detect_chip(void) { - unsigned char pid = INB(SC1200_CB_BASE_ADDR + SC1200_CB_PID); - unsigned char rev = INB(SC1200_CB_BASE_ADDR + SC1200_CB_REV); - - gfx_chip_revision = CHIP_NOT_DETECTED; - - if (pid == 0x4) { - switch (rev) { - case 0: - gfx_chip_revision = SC1200_REV_A; - break; - case 1: - gfx_chip_revision = SC1200_REV_B1_B2; - break; - case 2: - gfx_chip_revision = SC1200_REV_B3; - break; - case 3: - gfx_chip_revision = SC1200_REV_C1; - break; - case 4: - gfx_chip_revision = SC1200_REV_D1; - break; - case 5: - gfx_chip_revision = SC1200_REV_D1_1; - break; - case 6: - gfx_chip_revision = SC1200_REV_D2_MVD; - break; - } - if (rev > 0x6) - gfx_chip_revision = SC1200_FUTURE_REV; - } else if (pid == 0x5) { - if (rev == 0x6) - gfx_chip_revision = SC1200_REV_D2_MVE; - else if (rev > 0x6) - gfx_chip_revision = SC1200_FUTURE_REV; - } - return (gfx_chip_revision); + unsigned char pid = INB(SC1200_CB_BASE_ADDR + SC1200_CB_PID); + unsigned char rev = INB(SC1200_CB_BASE_ADDR + SC1200_CB_REV); + + gfx_chip_revision = CHIP_NOT_DETECTED; + + if (pid == 0x4) { + switch (rev) { + case 0: + gfx_chip_revision = SC1200_REV_A; + break; + case 1: + gfx_chip_revision = SC1200_REV_B1_B2; + break; + case 2: + gfx_chip_revision = SC1200_REV_B3; + break; + case 3: + gfx_chip_revision = SC1200_REV_C1; + break; + case 4: + gfx_chip_revision = SC1200_REV_D1; + break; + case 5: + gfx_chip_revision = SC1200_REV_D1_1; + break; + case 6: + gfx_chip_revision = SC1200_REV_D2_MVD; + break; + } + if (rev > 0x6) + gfx_chip_revision = SC1200_FUTURE_REV; + } + else if (pid == 0x5) { + if (rev == 0x6) + gfx_chip_revision = SC1200_REV_D2_MVE; + else if (rev > 0x6) + gfx_chip_revision = SC1200_FUTURE_REV; + } + return (gfx_chip_revision); } /*----------------------------------------------------------------------------- @@ -248,236 +249,238 @@ unsigned long gfx_detect_cpu(void) { - unsigned long value = 0; - unsigned long version = 0; + unsigned long value = 0; + unsigned long version = 0; - /* initialize core freq. to 0 */ - gfx_cpu_frequency = 0; + /* initialize core freq. to 0 */ + gfx_cpu_frequency = 0; #if GFX_INIT_GU1 - value = gfx_pci_config_read(0x80000000); + value = gfx_pci_config_read(0x80000000); - if (value == PCI_VENDOR_DEVICE_GXM) { - unsigned char dir0 = gfx_gxm_config_read(GXM_CONFIG_DIR0) & 0xF0; - unsigned char dir1 = gfx_gxm_config_read(GXM_CONFIG_DIR1); + if (value == PCI_VENDOR_DEVICE_GXM) { + unsigned char dir0 = gfx_gxm_config_read(GXM_CONFIG_DIR0) & 0xF0; + unsigned char dir1 = gfx_gxm_config_read(GXM_CONFIG_DIR1); - if (dir0 == 0x40) { - /* CHECK FOR GXLV (and GXm) (DIR1 = 0x30 THROUGH 0x82) */ + if (dir0 == 0x40) { + /* CHECK FOR GXLV (and GXm) (DIR1 = 0x30 THROUGH 0x82) */ - if ((dir1 >= 0x30) && (dir1 <= 0x82)) { - /* Major version is one less than what appears in DIR1 */ - if ((dir1 & 0xF0) < 0x70) { + if ((dir1 >= 0x30) && (dir1 <= 0x82)) { + /* Major version is one less than what appears in DIR1 */ + if ((dir1 & 0xF0) < 0x70) { - version = GFX_CPU_GXLV | (((((unsigned long)dir1 >> 4) - 1) << 8)) | /* major - 1 */ - ((((unsigned long)dir1 & 0x0F)) << 16); /* minor */ - } else { - version = GFX_CPU_GXLV | ((((unsigned long)dir1 >> 4)) << 8) | /* major */ - ((((unsigned long)dir1 & 0x0F)) << 16); /* minor */ + version = GFX_CPU_GXLV | (((((unsigned long) dir1 >> 4) - 1) << 8)) | /* major - 1 */ + ((((unsigned long) dir1 & 0x0F)) << 16); /* minor */ + } + else { + version = GFX_CPU_GXLV | ((((unsigned long) dir1 >> 4)) << 8) | /* major */ + ((((unsigned long) dir1 & 0x0F)) << 16); /* minor */ - } - /* Currently always CS5530 for video overlay. */ + } + /* Currently always CS5530 for video overlay. */ # if GFX_VIDEO_DYNAMIC - gfx_video_type = GFX_VIDEO_TYPE_CS5530; + gfx_video_type = GFX_VIDEO_TYPE_CS5530; # endif - /* Currently always CS5530 GPIOs for I2C access. */ + /* Currently always CS5530 GPIOs for I2C access. */ # if GFX_I2C_DYNAMIC - gfx_i2c_type = GFX_I2C_TYPE_GPIO; + gfx_i2c_type = GFX_I2C_TYPE_GPIO; # endif # if GFX_TV_DYNAMIC - gfx_tv_type = GFX_TV_TYPE_FS451; + gfx_tv_type = GFX_TV_TYPE_FS451; # endif - } - } else if (dir0 == 0xB0) { - /* CHECK FOR SC1200 */ + } + } + else if (dir0 == 0xB0) { + /* CHECK FOR SC1200 */ - if ((dir1 == 0x70) || (dir1 == 0x81)) { - version = GFX_CPU_SC1200 | ((((unsigned long)dir1 >> 4)) << 8) | /* major */ - ((((unsigned long)dir1 & 0x0F)) << 16); /* minor */ + if ((dir1 == 0x70) || (dir1 == 0x81)) { + version = GFX_CPU_SC1200 | ((((unsigned long) dir1 >> 4)) << 8) | /* major */ + ((((unsigned long) dir1 & 0x0F)) << 16); /* minor */ - /* Detect SC1200 revision */ + /* Detect SC1200 revision */ - gfx_detect_chip(); + gfx_detect_chip(); - /* SC1200 for video overlay and VIP. */ + /* SC1200 for video overlay and VIP. */ # if GFX_VIDEO_DYNAMIC - gfx_video_type = GFX_VIDEO_TYPE_SC1200; + gfx_video_type = GFX_VIDEO_TYPE_SC1200; # endif # if GFX_VIP_DYNAMIC - gfx_vip_type = GFX_VIP_TYPE_SC1200; + gfx_vip_type = GFX_VIP_TYPE_SC1200; # endif - /* Currently always SAA7114 decoder. */ + /* Currently always SAA7114 decoder. */ # if GFX_DECODER_DYNAMIC - gfx_decoder_type = GFX_DECODER_TYPE_SAA7114; + gfx_decoder_type = GFX_DECODER_TYPE_SAA7114; # endif - /* SC1200 for TV encoder */ + /* SC1200 for TV encoder */ # if GFX_TV_DYNAMIC - gfx_tv_type = GFX_TV_TYPE_SC1200; + gfx_tv_type = GFX_TV_TYPE_SC1200; # endif - /* Currently always ACCESS.bus for I2C access. */ + /* Currently always ACCESS.bus for I2C access. */ # if GFX_I2C_DYNAMIC - gfx_i2c_type = GFX_I2C_TYPE_ACCESS; + gfx_i2c_type = GFX_I2C_TYPE_ACCESS; # endif - } - } + } + } - if (version) { - /* ALWAYS FIRST GENERATION GRAPHICS UNIT */ + if (version) { + /* ALWAYS FIRST GENERATION GRAPHICS UNIT */ # if GFX_DISPLAY_DYNAMIC - gfx_display_type = GFX_DISPLAY_TYPE_GU1; + gfx_display_type = GFX_DISPLAY_TYPE_GU1; # endif # if GFX_2DACCEL_DYNAMIC - gfx_2daccel_type = GFX_2DACCEL_TYPE_GU1; + gfx_2daccel_type = GFX_2DACCEL_TYPE_GU1; # endif # if GFX_INIT_DYNAMIC - gfx_init_type = GFX_INIT_TYPE_GU1; + gfx_init_type = GFX_INIT_TYPE_GU1; # endif - /* READ THE CORE FREQUENCY */ + /* READ THE CORE FREQUENCY */ - gfx_cpu_frequency = gfx_get_core_freq(); - } - } + gfx_cpu_frequency = gfx_get_core_freq(); + } + } #endif #if GFX_INIT_GU2 - value = gfx_pci_config_read(0x80000800); + value = gfx_pci_config_read(0x80000800); - if (value == PCI_VENDOR_DEVICE_REDCLOUD) { - Q_WORD msr_value; - int valid, i; + if (value == PCI_VENDOR_DEVICE_REDCLOUD) { + Q_WORD msr_value; + int valid, i; - /* CHECK FOR SOFT VG */ - /* If SoftVG is not present, the base addresses for all devices */ - /* will not be allocated. Essentially, it is as if no Redcloud */ - /* video hardware is present. */ + /* CHECK FOR SOFT VG */ + /* If SoftVG is not present, the base addresses for all devices */ + /* will not be allocated. Essentially, it is as if no Redcloud */ + /* video hardware is present. */ - value = gfx_pci_config_read(0x80000900); + value = gfx_pci_config_read(0x80000900); - if (value == REDCLOUD_VIDEO_PCI_VENDOR_DEVICE) { - valid = 1; + if (value == REDCLOUD_VIDEO_PCI_VENDOR_DEVICE) { + valid = 1; - /* BAR0 - BAR3 HOLD THE PERIPHERAL BASE ADDRESSES */ + /* BAR0 - BAR3 HOLD THE PERIPHERAL BASE ADDRESSES */ - for (i = 0; i < 4; i++) { - value = gfx_pci_config_read(0x80000910 + (i << 2)); - if (value == 0x00000000 || value == 0xFFFFFFFF) { - valid = 0; - break; - } - } + for (i = 0; i < 4; i++) { + value = gfx_pci_config_read(0x80000910 + (i << 2)); + if (value == 0x00000000 || value == 0xFFFFFFFF) { + valid = 0; + break; + } + } - if (valid) { - /* REDCLOUD INTEGRATED VIDEO */ + if (valid) { + /* REDCLOUD INTEGRATED VIDEO */ # if GFX_VIDEO_DYNAMIC - gfx_video_type = GFX_VIDEO_TYPE_REDCLOUD; + gfx_video_type = GFX_VIDEO_TYPE_REDCLOUD; # endif - /* CURRENTLY, ALWAYS GPIO FOR I2C ACCESS */ + /* CURRENTLY, ALWAYS GPIO FOR I2C ACCESS */ # if GFX_I2C_DYNAMIC - gfx_i2c_type = GFX_I2C_TYPE_GPIO; + gfx_i2c_type = GFX_I2C_TYPE_GPIO; # endif - /* SECOND-GENERATION DISPLAY CONTROLLER */ + /* SECOND-GENERATION DISPLAY CONTROLLER */ # if GFX_DISPLAY_DYNAMIC - gfx_display_type = GFX_DISPLAY_TYPE_GU2; + gfx_display_type = GFX_DISPLAY_TYPE_GU2; # endif - /* SECOND-GENERATION GRAPHICS UNIT */ + /* SECOND-GENERATION GRAPHICS UNIT */ # if GFX_2DACCEL_DYNAMIC - gfx_2daccel_type = GFX_2DACCEL_TYPE_GU2; + gfx_2daccel_type = GFX_2DACCEL_TYPE_GU2; # endif - /* SECOND-GENERATION INITIALIZATION */ + /* SECOND-GENERATION INITIALIZATION */ # if GFX_INIT_DYNAMIC - gfx_init_type = GFX_INIT_TYPE_GU2; + gfx_init_type = GFX_INIT_TYPE_GU2; # endif - /* MBUS MSR ACCESSES */ + /* MBUS MSR ACCESSES */ # if GFX_MSR_DYNAMIC - gfx_msr_type = GFX_MSR_TYPE_REDCLOUD; + gfx_msr_type = GFX_MSR_TYPE_REDCLOUD; # endif - /* CS5530 GPIO I2C */ + /* CS5530 GPIO I2C */ # if GFX_I2C_DYNAMIC - gfx_i2c_type = GFX_I2C_TYPE_GPIO; + gfx_i2c_type = GFX_I2C_TYPE_GPIO; # endif - /* READ VERSION */ + /* READ VERSION */ - gfx_msr_init(); + gfx_msr_init(); - gfx_msr_read(RC_ID_MCP, MCP_RC_REVID, &msr_value); + gfx_msr_read(RC_ID_MCP, MCP_RC_REVID, &msr_value); - /* SUBTRACT 1 FROM REV ID */ - /* REDCLOUD 1.X rev id is 1 less than the reported value */ + /* SUBTRACT 1 FROM REV ID */ + /* REDCLOUD 1.X rev id is 1 less than the reported value */ - if ((msr_value.low & 0xF0) == 0x10) - msr_value.low--; + if ((msr_value.low & 0xF0) == 0x10) + msr_value.low--; - version = GFX_CPU_REDCLOUD | ((msr_value.low & 0xF0) << 4) | /* MAJOR */ - ((msr_value.low & 0x0F) << 16); /* MINOR */ + version = GFX_CPU_REDCLOUD | ((msr_value.low & 0xF0) << 4) | /* MAJOR */ + ((msr_value.low & 0x0F) << 16); /* MINOR */ - /* READ THE CORE FREQUENCY */ + /* READ THE CORE FREQUENCY */ - gfx_cpu_frequency = gfx_get_core_freq(); + gfx_cpu_frequency = gfx_get_core_freq(); - /* SET THE GP SCRATCH AREA */ - /* Color bitmap BLTs use the last 16K of frame buffer space */ + /* SET THE GP SCRATCH AREA */ + /* Color bitmap BLTs use the last 16K of frame buffer space */ - gfx_gx2_scratch_base = gfx_get_frame_buffer_size() - 0x4000; - } - } - } + gfx_gx2_scratch_base = gfx_get_frame_buffer_size() - 0x4000; + } + } + } #endif - if (!version) { - /* ALWAYS SECOND GENERATION IF SIMULATING */ - /* For now, that is. This could change. */ + if (!version) { + /* ALWAYS SECOND GENERATION IF SIMULATING */ + /* For now, that is. This could change. */ # if GFX_DISPLAY_DYNAMIC - gfx_display_type = GFX_DISPLAY_TYPE_GU2; + gfx_display_type = GFX_DISPLAY_TYPE_GU2; # endif # if GFX_2DACCEL_DYNAMIC - gfx_2daccel_type = GFX_2DACCEL_TYPE_GU2; + gfx_2daccel_type = GFX_2DACCEL_TYPE_GU2; # endif # if GFX_INIT_DYNAMIC - gfx_init_type = GFX_INIT_TYPE_GU2; + gfx_init_type = GFX_INIT_TYPE_GU2; # endif # if GFX_MSR_DYNAMIC - gfx_msr_type = GFX_MSR_TYPE_REDCLOUD; + gfx_msr_type = GFX_MSR_TYPE_REDCLOUD; # endif # if GFX_VIDEO_DYNAMIC - gfx_video_type = GFX_VIDEO_TYPE_REDCLOUD; + gfx_video_type = GFX_VIDEO_TYPE_REDCLOUD; # endif # if GFX_I2C_DYNAMIC - gfx_i2c_type = GFX_I2C_TYPE_GPIO; + gfx_i2c_type = GFX_I2C_TYPE_GPIO; # endif - } - gfx_cpu_version = version; + } + gfx_cpu_version = version; - return (version); + return (version); } /*----------------------------------------------------------------------------- @@ -495,16 +498,16 @@ gfx_detect_cpu(void) unsigned long gfx_detect_video(void) { - unsigned long version = 0; - - if ((gfx_cpu_version & 0xFF) == GFX_CPU_GXLV) - version = GFX_VID_CS5530; - else if ((gfx_cpu_version & 0xFF) == GFX_CPU_SC1200) - version = GFX_VID_SC1200; - else if ((gfx_cpu_version & 0xFF) == GFX_CPU_REDCLOUD) - version = GFX_VID_REDCLOUD; - gfx_vid_version = version; - return (version); + unsigned long version = 0; + + if ((gfx_cpu_version & 0xFF) == GFX_CPU_GXLV) + version = GFX_VID_CS5530; + else if ((gfx_cpu_version & 0xFF) == GFX_CPU_SC1200) + version = GFX_VID_SC1200; + else if ((gfx_cpu_version & 0xFF) == GFX_CPU_REDCLOUD) + version = GFX_VID_REDCLOUD; + gfx_vid_version = version; + return (version); } /*----------------------------------------------------------------------------- @@ -517,11 +520,11 @@ gfx_detect_video(void) unsigned long gfx_pci_config_read(unsigned long address) { - unsigned long value = 0xFFFFFFFF; + unsigned long value = 0xFFFFFFFF; - OUTD(PCI_CONFIG_ADDR, address); - value = IND(PCI_CONFIG_DATA); - return (value); + OUTD(PCI_CONFIG_ADDR, address); + value = IND(PCI_CONFIG_DATA); + return (value); } /*----------------------------------------------------------------------------- @@ -534,9 +537,9 @@ gfx_pci_config_read(unsigned long address) void gfx_pci_config_write(unsigned long address, unsigned long data) { - OUTD(PCI_CONFIG_ADDR, address); - OUTD(PCI_CONFIG_DATA, data); - return; + OUTD(PCI_CONFIG_ADDR, address); + OUTD(PCI_CONFIG_DATA, data); + return; } /* WRAPPERS IF DYNAMIC SELECTION */ @@ -551,17 +554,17 @@ gfx_pci_config_write(unsigned long address, unsigned long data) unsigned long gfx_get_core_freq(void) { - unsigned long freq = 0; + unsigned long freq = 0; # if GFX_INIT_GU1 - if (gfx_init_type & GFX_INIT_TYPE_GU1) - freq = gu1_get_core_freq(); + if (gfx_init_type & GFX_INIT_TYPE_GU1) + freq = gu1_get_core_freq(); # endif # if GFX_INIT_GU2 - if (gfx_init_type & GFX_INIT_TYPE_GU2) - freq = gu2_get_core_freq(); + if (gfx_init_type & GFX_INIT_TYPE_GU2) + freq = gu2_get_core_freq(); # endif - return freq; + return freq; } /*----------------------------------------------------------------------------- @@ -571,18 +574,18 @@ gfx_get_core_freq(void) unsigned long gfx_get_cpu_register_base(void) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_INIT_GU1 - if (gfx_init_type & GFX_INIT_TYPE_GU1) - base = gu1_get_cpu_register_base(); + if (gfx_init_type & GFX_INIT_TYPE_GU1) + base = gu1_get_cpu_register_base(); # endif # if GFX_INIT_GU2 - if (gfx_init_type & GFX_INIT_TYPE_GU2) - base = gu2_get_cpu_register_base(); + if (gfx_init_type & GFX_INIT_TYPE_GU2) + base = gu2_get_cpu_register_base(); # endif - return (base); + return (base); } /*----------------------------------------------------------------------------- @@ -592,14 +595,14 @@ gfx_get_cpu_register_base(void) unsigned long gfx_get_graphics_register_base(void) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_INIT_GU2 - if (gfx_init_type & GFX_INIT_TYPE_GU2) - base = gu2_get_graphics_register_base(); + if (gfx_init_type & GFX_INIT_TYPE_GU2) + base = gu2_get_graphics_register_base(); # endif - return (base); + return (base); } /*----------------------------------------------------------------------------- @@ -609,18 +612,18 @@ gfx_get_graphics_register_base(void) unsigned long gfx_get_frame_buffer_base(void) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_INIT_GU1 - if (gfx_init_type & GFX_INIT_TYPE_GU1) - base = gu1_get_frame_buffer_base(); + if (gfx_init_type & GFX_INIT_TYPE_GU1) + base = gu1_get_frame_buffer_base(); # endif # if GFX_INIT_GU2 - if (gfx_init_type & GFX_INIT_TYPE_GU2) - base = gu2_get_frame_buffer_base(); + if (gfx_init_type & GFX_INIT_TYPE_GU2) + base = gu2_get_frame_buffer_base(); # endif - return (base); + return (base); } /*----------------------------------------------------------------------------- @@ -630,18 +633,18 @@ gfx_get_frame_buffer_base(void) unsigned long gfx_get_frame_buffer_size(void) { - unsigned long size = 0; + unsigned long size = 0; # if GFX_INIT_GU1 - if (gfx_init_type & GFX_INIT_TYPE_GU1) - size = gu1_get_frame_buffer_size(); + if (gfx_init_type & GFX_INIT_TYPE_GU1) + size = gu1_get_frame_buffer_size(); # endif # if GFX_INIT_GU2 - if (gfx_init_type & GFX_INIT_TYPE_GU2) - size = gu2_get_frame_buffer_size(); + if (gfx_init_type & GFX_INIT_TYPE_GU2) + size = gu2_get_frame_buffer_size(); # endif - return size; + return size; } /*----------------------------------------------------------------------------- @@ -651,18 +654,18 @@ gfx_get_frame_buffer_size(void) unsigned long gfx_get_vid_register_base(void) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_INIT_GU1 - if (gfx_init_type & GFX_INIT_TYPE_GU1) - base = gu1_get_vid_register_base(); + if (gfx_init_type & GFX_INIT_TYPE_GU1) + base = gu1_get_vid_register_base(); # endif # if GFX_INIT_GU2 - if (gfx_init_type & GFX_INIT_TYPE_GU2) - base = gu2_get_vid_register_base(); + if (gfx_init_type & GFX_INIT_TYPE_GU2) + base = gu2_get_vid_register_base(); # endif - return (base); + return (base); } /*----------------------------------------------------------------------------- @@ -672,17 +675,16 @@ gfx_get_vid_register_base(void) unsigned long gfx_get_vip_register_base(void) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_INIT_GU1 - if (gfx_init_type & GFX_INIT_TYPE_GU1) - base = gu1_get_vip_register_base(); + if (gfx_init_type & GFX_INIT_TYPE_GU1) + base = gu1_get_vip_register_base(); # endif - return (base); + return (base); } #endif /* END OF FILE */ - diff --git a/src/gfx/gfx_mode.h b/src/gfx/gfx_mode.h index 100b36c..3f82eb8 100644 --- a/src/gfx/gfx_mode.h +++ b/src/gfx/gfx_mode.h @@ -156,71 +156,66 @@ /* STRUCTURE DEFINITION */ -typedef struct tagDISPLAYMODE -{ - /* DISPLAY MODE FLAGS */ - /* Specify valid color depths and the refresh rate. */ +typedef struct tagDISPLAYMODE { + /* DISPLAY MODE FLAGS */ + /* Specify valid color depths and the refresh rate. */ - unsigned long flags; + unsigned long flags; - /* TIMINGS */ + /* TIMINGS */ - unsigned short hactive; - unsigned short hblankstart; - unsigned short hsyncstart; - unsigned short hsyncend; - unsigned short hblankend; - unsigned short htotal; + unsigned short hactive; + unsigned short hblankstart; + unsigned short hsyncstart; + unsigned short hsyncend; + unsigned short hblankend; + unsigned short htotal; - unsigned short vactive; - unsigned short vblankstart; - unsigned short vsyncstart; - unsigned short vsyncend; - unsigned short vblankend; - unsigned short vtotal; + unsigned short vactive; + unsigned short vblankstart; + unsigned short vsyncstart; + unsigned short vsyncend; + unsigned short vblankend; + unsigned short vtotal; - /* CLOCK FREQUENCY */ + /* CLOCK FREQUENCY */ - unsigned long frequency; + unsigned long frequency; -} -DISPLAYMODE; +} DISPLAYMODE; /* For Fixed timings */ -typedef struct tagFIXEDTIMINGS -{ - /* DISPLAY MODE FLAGS */ - /* Specify valid color depths and the refresh rate. */ +typedef struct tagFIXEDTIMINGS { + /* DISPLAY MODE FLAGS */ + /* Specify valid color depths and the refresh rate. */ - int panelresx; - int panelresy; - unsigned short xres; - unsigned short yres; + int panelresx; + int panelresy; + unsigned short xres; + unsigned short yres; - /* TIMINGS */ + /* TIMINGS */ - unsigned short hactive; - unsigned short hblankstart; - unsigned short hsyncstart; - unsigned short hsyncend; - unsigned short hblankend; - unsigned short htotal; + unsigned short hactive; + unsigned short hblankstart; + unsigned short hsyncstart; + unsigned short hsyncend; + unsigned short hblankend; + unsigned short htotal; - unsigned short vactive; - unsigned short vblankstart; - unsigned short vsyncstart; - unsigned short vsyncend; - unsigned short vblankend; - unsigned short vtotal; + unsigned short vactive; + unsigned short vblankstart; + unsigned short vsyncstart; + unsigned short vsyncend; + unsigned short vblankend; + unsigned short vtotal; - /* CLOCK FREQUENCY */ + /* CLOCK FREQUENCY */ - unsigned long frequency; + unsigned long frequency; -} -FIXEDTIMINGS; +} FIXEDTIMINGS; -#endif /* !_gfx_mode_h */ +#endif /* !_gfx_mode_h */ /* END OF FILE */ - diff --git a/src/gfx/gfx_msr.c b/src/gfx/gfx_msr.c index c6b1caf..a9dc548 100644 --- a/src/gfx/gfx_msr.c +++ b/src/gfx/gfx_msr.c @@ -154,14 +154,14 @@ int gfx_msr_init() { - int ret_value = 0; + int ret_value = 0; # if GFX_MSR_REDCLOUD - if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) - ret_value = redcloud_msr_init(); + if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) + ret_value = redcloud_msr_init(); # endif - return ret_value; + return ret_value; } /*----------------------------------------------------------------------------- @@ -171,14 +171,14 @@ gfx_msr_init() DEV_STATUS gfx_id_msr_device(MSR * pDev, unsigned long address) { - DEV_STATUS ret_value = NOT_KNOWN; + DEV_STATUS ret_value = NOT_KNOWN; # if GFX_MSR_REDCLOUD - if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) - ret_value = redcloud_id_msr_device(pDev, address); + if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) + ret_value = redcloud_id_msr_device(pDev, address); # endif - return ret_value; + return ret_value; } /*----------------------------------------------------------------------------- @@ -188,14 +188,14 @@ gfx_id_msr_device(MSR * pDev, unsigned long address) DEV_STATUS gfx_get_msr_dev_address(unsigned int device, unsigned long *address) { - DEV_STATUS ret_value = NOT_KNOWN; + DEV_STATUS ret_value = NOT_KNOWN; # if GFX_MSR_REDCLOUD - if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) - ret_value = redcloud_get_msr_dev_address(device, address); + if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) + ret_value = redcloud_get_msr_dev_address(device, address); # endif - return ret_value; + return ret_value; } /*----------------------------------------------------------------------------- @@ -205,14 +205,14 @@ gfx_get_msr_dev_address(unsigned int device, unsigned long *address) DEV_STATUS gfx_get_glink_id_at_address(unsigned int *device, unsigned long address) { - DEV_STATUS ret_value = NOT_KNOWN; + DEV_STATUS ret_value = NOT_KNOWN; # if GFX_MSR_REDCLOUD - if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) - ret_value = redcloud_get_glink_id_at_address(device, address); + if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) + ret_value = redcloud_get_glink_id_at_address(device, address); # endif - return ret_value; + return ret_value; } /*----------------------------------------------------------------------------- @@ -222,14 +222,14 @@ gfx_get_glink_id_at_address(unsigned int *device, unsigned long address) DEV_STATUS gfx_msr_read(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue) { - DEV_STATUS ret_value = NOT_KNOWN; + DEV_STATUS ret_value = NOT_KNOWN; # if GFX_MSR_REDCLOUD - if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) - ret_value = redcloud_msr_read(device, msrRegister, msrValue); + if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) + ret_value = redcloud_msr_read(device, msrRegister, msrValue); # endif - return ret_value; + return ret_value; } /*----------------------------------------------------------------------------- @@ -237,17 +237,16 @@ gfx_msr_read(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue) *----------------------------------------------------------------------------- */ DEV_STATUS -gfx_msr_write(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue) +gfx_msr_write(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue) { - DEV_STATUS ret_value = NOT_KNOWN; + DEV_STATUS ret_value = NOT_KNOWN; # if GFX_MSR_REDCLOUD - if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) - ret_value = redcloud_msr_write(device, msrRegister, msrValue); + if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) + ret_value = redcloud_msr_write(device, msrRegister, msrValue); # endif - return ret_value; + return ret_value; } #endif diff --git a/src/gfx/gfx_regs.h b/src/gfx/gfx_regs.h index 7b11887..9135065 100644 --- a/src/gfx/gfx_regs.h +++ b/src/gfx/gfx_regs.h @@ -132,136 +132,136 @@ /* FIRST GENERATION GRAPHICS UNIT */ /*----------------------------------*/ -#define GP_DST_XCOOR 0x8100 /* x destination origin */ -#define GP_DST_YCOOR 0x8102 /* y destination origin */ -#define GP_WIDTH 0x8104 /* pixel width */ -#define GP_HEIGHT 0x8106 /* pixel height */ -#define GP_SRC_XCOOR 0x8108 /* x source origin */ -#define GP_SRC_YCOOR 0x810A /* y source origin */ - -#define GP_VECTOR_LENGTH 0x8104 /* vector length */ -#define GP_INIT_ERROR 0x8106 /* vector initial error */ -#define GP_AXIAL_ERROR 0x8108 /* axial error increment */ -#define GP_DIAG_ERROR 0x810A /* diagonal error increment */ - -#define GP_SRC_COLOR_0 0x810C /* source color 0 */ -#define GP_SRC_COLOR_1 0x810E /* source color 1 */ -#define GP_PAT_COLOR_0 0x8110 /* pattern color 0 */ -#define GP_PAT_COLOR_1 0x8112 /* pattern color 1 */ -#define GP_PAT_COLOR_2 0x8114 /* pattern color 2 */ -#define GP_PAT_COLOR_3 0x8116 /* pattern color 3 */ -#define GP_PAT_DATA_0 0x8120 /* bits 31:0 of pattern */ -#define GP_PAT_DATA_1 0x8124 /* bits 63:32 of pattern */ -#define GP_PAT_DATA_2 0x8128 /* bits 95:64 of pattern */ -#define GP_PAT_DATA_3 0x812C /* bits 127:96 of pattern */ - -#define GP_VGA_WRITE 0x8140 /* VGA write path control */ -#define GP_VGA_READ 0x8144 /* VGA read path control */ - -#define GP_RASTER_MODE 0x8200 /* raster operation */ -#define GP_VECTOR_MODE 0x8204 /* vector mode register */ -#define GP_BLIT_MODE 0x8208 /* blit mode register */ -#define GP_BLIT_STATUS 0x820C /* blit status register */ - -#define GP_VGA_BASE 0x8210 /* VGA memory offset (x64K) */ -#define GP_VGA_LATCH 0x8214 /* VGA display latch */ +#define GP_DST_XCOOR 0x8100 /* x destination origin */ +#define GP_DST_YCOOR 0x8102 /* y destination origin */ +#define GP_WIDTH 0x8104 /* pixel width */ +#define GP_HEIGHT 0x8106 /* pixel height */ +#define GP_SRC_XCOOR 0x8108 /* x source origin */ +#define GP_SRC_YCOOR 0x810A /* y source origin */ + +#define GP_VECTOR_LENGTH 0x8104 /* vector length */ +#define GP_INIT_ERROR 0x8106 /* vector initial error */ +#define GP_AXIAL_ERROR 0x8108 /* axial error increment */ +#define GP_DIAG_ERROR 0x810A /* diagonal error increment */ + +#define GP_SRC_COLOR_0 0x810C /* source color 0 */ +#define GP_SRC_COLOR_1 0x810E /* source color 1 */ +#define GP_PAT_COLOR_0 0x8110 /* pattern color 0 */ +#define GP_PAT_COLOR_1 0x8112 /* pattern color 1 */ +#define GP_PAT_COLOR_2 0x8114 /* pattern color 2 */ +#define GP_PAT_COLOR_3 0x8116 /* pattern color 3 */ +#define GP_PAT_DATA_0 0x8120 /* bits 31:0 of pattern */ +#define GP_PAT_DATA_1 0x8124 /* bits 63:32 of pattern */ +#define GP_PAT_DATA_2 0x8128 /* bits 95:64 of pattern */ +#define GP_PAT_DATA_3 0x812C /* bits 127:96 of pattern */ + +#define GP_VGA_WRITE 0x8140 /* VGA write path control */ +#define GP_VGA_READ 0x8144 /* VGA read path control */ + +#define GP_RASTER_MODE 0x8200 /* raster operation */ +#define GP_VECTOR_MODE 0x8204 /* vector mode register */ +#define GP_BLIT_MODE 0x8208 /* blit mode register */ +#define GP_BLIT_STATUS 0x820C /* blit status register */ + +#define GP_VGA_BASE 0x8210 /* VGA memory offset (x64K) */ +#define GP_VGA_LATCH 0x8214 /* VGA display latch */ /* "GP_VECTOR_MODE" BIT DEFINITIONS */ -#define VM_X_MAJOR 0x0000 /* X major vector */ -#define VM_Y_MAJOR 0x0001 /* Y major vector */ -#define VM_MAJOR_INC 0x0002 /* positive major axis step */ -#define VM_MINOR_INC 0x0004 /* positive minor axis step */ -#define VM_READ_DST_FB 0x0008 /* read destination data */ +#define VM_X_MAJOR 0x0000 /* X major vector */ +#define VM_Y_MAJOR 0x0001 /* Y major vector */ +#define VM_MAJOR_INC 0x0002 /* positive major axis step */ +#define VM_MINOR_INC 0x0004 /* positive minor axis step */ +#define VM_READ_DST_FB 0x0008 /* read destination data */ /* "GP_RASTER_MODE" BIT DEFINITIONS */ -#define RM_PAT_DISABLE 0x0000 /* pattern is disabled */ -#define RM_PAT_MONO 0x0100 /* 1BPP pattern expansion */ -#define RM_PAT_DITHER 0x0200 /* 2BPP pattern expansion */ -#define RM_PAT_COLOR 0x0300 /* 8BPP or 16BPP pattern */ -#define RM_PAT_MASK 0x0300 /* mask for pattern mode */ -#define RM_PAT_TRANSPARENT 0x0400 /* transparent 1BPP pattern */ -#define RM_SRC_TRANSPARENT 0x0800 /* transparent 1BPP source */ +#define RM_PAT_DISABLE 0x0000 /* pattern is disabled */ +#define RM_PAT_MONO 0x0100 /* 1BPP pattern expansion */ +#define RM_PAT_DITHER 0x0200 /* 2BPP pattern expansion */ +#define RM_PAT_COLOR 0x0300 /* 8BPP or 16BPP pattern */ +#define RM_PAT_MASK 0x0300 /* mask for pattern mode */ +#define RM_PAT_TRANSPARENT 0x0400 /* transparent 1BPP pattern */ +#define RM_SRC_TRANSPARENT 0x0800 /* transparent 1BPP source */ /* "GP_BLIT_STATUS" BIT DEFINITIONS */ -#define BS_BLIT_BUSY 0x0001 /* blit engine is busy */ -#define BS_PIPELINE_BUSY 0x0002 /* graphics pipeline is busy */ -#define BS_BLIT_PENDING 0x0004 /* blit pending */ -#define BC_FLUSH 0x0080 /* flush pipeline requests */ -#define BC_8BPP 0x0000 /* 8BPP mode */ -#define BC_16BPP 0x0100 /* 16BPP mode */ -#define BC_FB_WIDTH_1024 0x0000 /* framebuffer width = 1024 */ -#define BC_FB_WIDTH_2048 0x0200 /* framebuffer width = 2048 */ -#define BC_FB_WIDTH_4096 0x0400 /* framebuffer width = 4096 */ +#define BS_BLIT_BUSY 0x0001 /* blit engine is busy */ +#define BS_PIPELINE_BUSY 0x0002 /* graphics pipeline is busy */ +#define BS_BLIT_PENDING 0x0004 /* blit pending */ +#define BC_FLUSH 0x0080 /* flush pipeline requests */ +#define BC_8BPP 0x0000 /* 8BPP mode */ +#define BC_16BPP 0x0100 /* 16BPP mode */ +#define BC_FB_WIDTH_1024 0x0000 /* framebuffer width = 1024 */ +#define BC_FB_WIDTH_2048 0x0200 /* framebuffer width = 2048 */ +#define BC_FB_WIDTH_4096 0x0400 /* framebuffer width = 4096 */ /* "GP_BLIT_MODE" BIT DEFINITIONS */ -#define BM_READ_SRC_NONE 0x0000 /* source foreground color */ -#define BM_READ_SRC_FB 0x0001 /* read source from FB */ -#define BM_READ_SRC_BB0 0x0002 /* read source from BB0 */ -#define BM_READ_SRC_BB1 0x0003 /* read source from BB1 */ -#define BM_READ_SRC_MASK 0x0003 /* read source mask */ +#define BM_READ_SRC_NONE 0x0000 /* source foreground color */ +#define BM_READ_SRC_FB 0x0001 /* read source from FB */ +#define BM_READ_SRC_BB0 0x0002 /* read source from BB0 */ +#define BM_READ_SRC_BB1 0x0003 /* read source from BB1 */ +#define BM_READ_SRC_MASK 0x0003 /* read source mask */ -#define BM_READ_DST_NONE 0x0000 /* no destination data */ -#define BM_READ_DST_BB0 0x0008 /* destination from BB0 */ -#define BM_READ_DST_BB1 0x000C /* destination from BB1 */ -#define BM_READ_DST_FB0 0x0010 /* dest from FB (store BB0) */ -#define BM_READ_DST_FB1 0x0014 /* dest from FB (store BB1) */ -#define BM_READ_DST_MASK 0x001C /* read destination mask */ +#define BM_READ_DST_NONE 0x0000 /* no destination data */ +#define BM_READ_DST_BB0 0x0008 /* destination from BB0 */ +#define BM_READ_DST_BB1 0x000C /* destination from BB1 */ +#define BM_READ_DST_FB0 0x0010 /* dest from FB (store BB0) */ +#define BM_READ_DST_FB1 0x0014 /* dest from FB (store BB1) */ +#define BM_READ_DST_MASK 0x001C /* read destination mask */ -#define BM_WRITE_FB 0x0000 /* write to framebuffer */ -#define BM_WRITE_MEM 0x0020 /* write to memory */ -#define BM_WRITE_MASK 0x0020 /* write mask */ +#define BM_WRITE_FB 0x0000 /* write to framebuffer */ +#define BM_WRITE_MEM 0x0020 /* write to memory */ +#define BM_WRITE_MASK 0x0020 /* write mask */ -#define BM_SOURCE_COLOR 0x0000 /* source is 8BPP or 16BPP */ -#define BM_SOURCE_EXPAND 0x0040 /* source is 1BPP */ -#define BM_SOURCE_TEXT 0x00C0 /* source is 1BPP text */ -#define BM_SOURCE_MASK 0x00C0 /* source mask */ +#define BM_SOURCE_COLOR 0x0000 /* source is 8BPP or 16BPP */ +#define BM_SOURCE_EXPAND 0x0040 /* source is 1BPP */ +#define BM_SOURCE_TEXT 0x00C0 /* source is 1BPP text */ +#define BM_SOURCE_MASK 0x00C0 /* source mask */ -#define BM_REVERSE_Y 0x0100 /* reverse Y direction */ +#define BM_REVERSE_Y 0x0100 /* reverse Y direction */ /*---------------------------------------*/ /* FIRST GENERATION DISPLAY CONTROLLER */ /*---------------------------------------*/ -#define DC_UNLOCK 0x8300 /* lock register */ -#define DC_GENERAL_CFG 0x8304 /* config registers... */ +#define DC_UNLOCK 0x8300 /* lock register */ +#define DC_GENERAL_CFG 0x8304 /* config registers... */ #define DC_TIMING_CFG 0x8308 #define DC_OUTPUT_CFG 0x830C -#define DC_FB_ST_OFFSET 0x8310 /* framebuffer start offset */ -#define DC_CB_ST_OFFSET 0x8314 /* compression start offset */ -#define DC_CURS_ST_OFFSET 0x8318 /* cursor start offset */ -#define DC_ICON_ST_OFFSET 0x831C /* icon start offset */ -#define DC_VID_ST_OFFSET 0x8320 /* video start offset */ -#define DC_LINE_DELTA 0x8324 /* fb and cb skip counts */ -#define DC_BUF_SIZE 0x8328 /* fb and cb line size */ +#define DC_FB_ST_OFFSET 0x8310 /* framebuffer start offset */ +#define DC_CB_ST_OFFSET 0x8314 /* compression start offset */ +#define DC_CURS_ST_OFFSET 0x8318 /* cursor start offset */ +#define DC_ICON_ST_OFFSET 0x831C /* icon start offset */ +#define DC_VID_ST_OFFSET 0x8320 /* video start offset */ +#define DC_LINE_DELTA 0x8324 /* fb and cb skip counts */ +#define DC_BUF_SIZE 0x8328 /* fb and cb line size */ -#define DC_H_TIMING_1 0x8330 /* horizontal timing... */ +#define DC_H_TIMING_1 0x8330 /* horizontal timing... */ #define DC_H_TIMING_2 0x8334 #define DC_H_TIMING_3 0x8338 #define DC_FP_H_TIMING 0x833C -#define DC_V_TIMING_1 0x8340 /* vertical timing... */ +#define DC_V_TIMING_1 0x8340 /* vertical timing... */ #define DC_V_TIMING_2 0x8344 #define DC_V_TIMING_3 0x8348 #define DC_FP_V_TIMING 0x834C -#define DC_CURSOR_X 0x8350 /* cursor x position */ -#define DC_ICON_X 0x8354 /* HACK - 1.3 definition */ -#define DC_V_LINE_CNT 0x8354 /* vertical line counter */ -#define DC_CURSOR_Y 0x8358 /* cursor y position */ -#define DC_ICON_Y 0x835C /* HACK - 1.3 definition */ -#define DC_SS_LINE_CMP 0x835C /* line compare value */ -#define DC_CURSOR_COLOR 0x8360 /* cursor colors */ -#define DC_ICON_COLOR 0x8364 /* icon colors */ -#define DC_BORDER_COLOR 0x8368 /* border color */ -#define DC_PAL_ADDRESS 0x8370 /* palette address */ -#define DC_PAL_DATA 0x8374 /* palette data */ -#define DC_DFIFO_DIAG 0x8378 /* display FIFO diagnostic */ -#define DC_CFIFO_DIAG 0x837C /* compression FIF0 diagnostic */ +#define DC_CURSOR_X 0x8350 /* cursor x position */ +#define DC_ICON_X 0x8354 /* HACK - 1.3 definition */ +#define DC_V_LINE_CNT 0x8354 /* vertical line counter */ +#define DC_CURSOR_Y 0x8358 /* cursor y position */ +#define DC_ICON_Y 0x835C /* HACK - 1.3 definition */ +#define DC_SS_LINE_CMP 0x835C /* line compare value */ +#define DC_CURSOR_COLOR 0x8360 /* cursor colors */ +#define DC_ICON_COLOR 0x8364 /* icon colors */ +#define DC_BORDER_COLOR 0x8368 /* border color */ +#define DC_PAL_ADDRESS 0x8370 /* palette address */ +#define DC_PAL_DATA 0x8374 /* palette data */ +#define DC_DFIFO_DIAG 0x8378 /* display FIFO diagnostic */ +#define DC_CFIFO_DIAG 0x837C /* compression FIF0 diagnostic */ /* PALETTE LOCATIONS */ @@ -273,86 +273,86 @@ /* UNLOCK VALUE */ -#define DC_UNLOCK_VALUE 0x00004758 /* used to unlock DC regs */ +#define DC_UNLOCK_VALUE 0x00004758 /* used to unlock DC regs */ /* "DC_GENERAL_CFG" BIT DEFINITIONS */ -#define DC_GCFG_DFLE 0x00000001 /* display FIFO load enable */ -#define DC_GCFG_CURE 0x00000002 /* cursor enable */ -#define DC_GCFG_VCLK_DIV 0x00000004 /* vid clock divisor */ -#define DC_GCFG_PLNO 0x00000004 /* planar offset LSB */ -#define DC_GCFG_PPC 0x00000008 /* pixel pan compatibility */ -#define DC_GCFG_CMPE 0x00000010 /* compression enable */ -#define DC_GCFG_DECE 0x00000020 /* decompression enable */ -#define DC_GCFG_DCLK_MASK 0x000000C0 /* dotclock multiplier */ -#define DC_GCFG_DCLK_POS 6 /* dotclock multiplier */ -#define DC_GCFG_DFHPSL_MASK 0x00000F00 /* FIFO high-priority start */ -#define DC_GCFG_DFHPSL_POS 8 /* FIFO high-priority start */ -#define DC_GCFG_DFHPEL_MASK 0x0000F000 /* FIFO high-priority end */ -#define DC_GCFG_DFHPEL_POS 12 /* FIFO high-priority end */ -#define DC_GCFG_CIM_MASK 0x00030000 /* compressor insert mode */ -#define DC_GCFG_CIM_POS 16 /* compressor insert mode */ -#define DC_GCFG_FDTY 0x00040000 /* frame dirty mode */ -#define DC_GCFG_RTPM 0x00080000 /* real-time perf. monitor */ -#define DC_GCFG_DAC_RS_MASK 0x00700000 /* DAC register selects */ -#define DC_GCFG_DAC_RS_POS 20 /* DAC register selects */ -#define DC_GCFG_CKWR 0x00800000 /* clock write */ -#define DC_GCFG_LDBL 0x01000000 /* line double */ -#define DC_GCFG_DIAG 0x02000000 /* FIFO diagnostic mode */ -#define DC_GCFG_CH4S 0x04000000 /* sparse refresh mode */ -#define DC_GCFG_SSLC 0x08000000 /* enable line compare */ -#define DC_GCFG_VIDE 0x10000000 /* video enable */ -#define DC_GCFG_DFCK 0x20000000 /* divide flat-panel clock - rev 2.3 down */ -#define DC_GCFG_VRDY 0x20000000 /* video port speed - rev 2.4 up */ -#define DC_GCFG_DPCK 0x40000000 /* divide pixel clock */ -#define DC_GCFG_DDCK 0x80000000 /* divide dot clock */ +#define DC_GCFG_DFLE 0x00000001 /* display FIFO load enable */ +#define DC_GCFG_CURE 0x00000002 /* cursor enable */ +#define DC_GCFG_VCLK_DIV 0x00000004 /* vid clock divisor */ +#define DC_GCFG_PLNO 0x00000004 /* planar offset LSB */ +#define DC_GCFG_PPC 0x00000008 /* pixel pan compatibility */ +#define DC_GCFG_CMPE 0x00000010 /* compression enable */ +#define DC_GCFG_DECE 0x00000020 /* decompression enable */ +#define DC_GCFG_DCLK_MASK 0x000000C0 /* dotclock multiplier */ +#define DC_GCFG_DCLK_POS 6 /* dotclock multiplier */ +#define DC_GCFG_DFHPSL_MASK 0x00000F00 /* FIFO high-priority start */ +#define DC_GCFG_DFHPSL_POS 8 /* FIFO high-priority start */ +#define DC_GCFG_DFHPEL_MASK 0x0000F000 /* FIFO high-priority end */ +#define DC_GCFG_DFHPEL_POS 12 /* FIFO high-priority end */ +#define DC_GCFG_CIM_MASK 0x00030000 /* compressor insert mode */ +#define DC_GCFG_CIM_POS 16 /* compressor insert mode */ +#define DC_GCFG_FDTY 0x00040000 /* frame dirty mode */ +#define DC_GCFG_RTPM 0x00080000 /* real-time perf. monitor */ +#define DC_GCFG_DAC_RS_MASK 0x00700000 /* DAC register selects */ +#define DC_GCFG_DAC_RS_POS 20 /* DAC register selects */ +#define DC_GCFG_CKWR 0x00800000 /* clock write */ +#define DC_GCFG_LDBL 0x01000000 /* line double */ +#define DC_GCFG_DIAG 0x02000000 /* FIFO diagnostic mode */ +#define DC_GCFG_CH4S 0x04000000 /* sparse refresh mode */ +#define DC_GCFG_SSLC 0x08000000 /* enable line compare */ +#define DC_GCFG_VIDE 0x10000000 /* video enable */ +#define DC_GCFG_DFCK 0x20000000 /* divide flat-panel clock - rev 2.3 down */ +#define DC_GCFG_VRDY 0x20000000 /* video port speed - rev 2.4 up */ +#define DC_GCFG_DPCK 0x40000000 /* divide pixel clock */ +#define DC_GCFG_DDCK 0x80000000 /* divide dot clock */ /* "DC_TIMING_CFG" BIT DEFINITIONS */ -#define DC_TCFG_FPPE 0x00000001 /* flat-panel power enable */ -#define DC_TCFG_HSYE 0x00000002 /* horizontal sync enable */ -#define DC_TCFG_VSYE 0x00000004 /* vertical sync enable */ -#define DC_TCFG_BLKE 0x00000008 /* blank enable */ -#define DC_TCFG_DDCK 0x00000010 /* DDC clock */ -#define DC_TCFG_TGEN 0x00000020 /* timing generator enable */ -#define DC_TCFG_VIEN 0x00000040 /* vertical interrupt enable */ -#define DC_TCFG_BLNK 0x00000080 /* blink enable */ -#define DC_TCFG_CHSP 0x00000100 /* horizontal sync polarity */ -#define DC_TCFG_CVSP 0x00000200 /* vertical sync polarity */ -#define DC_TCFG_FHSP 0x00000400 /* panel horz sync polarity */ -#define DC_TCFG_FVSP 0x00000800 /* panel vert sync polarity */ -#define DC_TCFG_FCEN 0x00001000 /* flat-panel centering */ -#define DC_TCFG_CDCE 0x00002000 /* HACK - 1.3 definition */ -#define DC_TCFG_PLNR 0x00002000 /* planar mode enable */ -#define DC_TCFG_INTL 0x00004000 /* interlace scan */ -#define DC_TCFG_PXDB 0x00008000 /* pixel double */ -#define DC_TCFG_BKRT 0x00010000 /* blink rate */ -#define DC_TCFG_PSD_MASK 0x000E0000 /* power sequence delay */ -#define DC_TCFG_PSD_POS 17 /* power sequence delay */ -#define DC_TCFG_DDCI 0x08000000 /* DDC input (RO) */ -#define DC_TCFG_SENS 0x10000000 /* monitor sense (RO) */ -#define DC_TCFG_DNA 0x20000000 /* display not active (RO) */ -#define DC_TCFG_VNA 0x40000000 /* vertical not active (RO) */ -#define DC_TCFG_VINT 0x80000000 /* vertical interrupt (RO) */ +#define DC_TCFG_FPPE 0x00000001 /* flat-panel power enable */ +#define DC_TCFG_HSYE 0x00000002 /* horizontal sync enable */ +#define DC_TCFG_VSYE 0x00000004 /* vertical sync enable */ +#define DC_TCFG_BLKE 0x00000008 /* blank enable */ +#define DC_TCFG_DDCK 0x00000010 /* DDC clock */ +#define DC_TCFG_TGEN 0x00000020 /* timing generator enable */ +#define DC_TCFG_VIEN 0x00000040 /* vertical interrupt enable */ +#define DC_TCFG_BLNK 0x00000080 /* blink enable */ +#define DC_TCFG_CHSP 0x00000100 /* horizontal sync polarity */ +#define DC_TCFG_CVSP 0x00000200 /* vertical sync polarity */ +#define DC_TCFG_FHSP 0x00000400 /* panel horz sync polarity */ +#define DC_TCFG_FVSP 0x00000800 /* panel vert sync polarity */ +#define DC_TCFG_FCEN 0x00001000 /* flat-panel centering */ +#define DC_TCFG_CDCE 0x00002000 /* HACK - 1.3 definition */ +#define DC_TCFG_PLNR 0x00002000 /* planar mode enable */ +#define DC_TCFG_INTL 0x00004000 /* interlace scan */ +#define DC_TCFG_PXDB 0x00008000 /* pixel double */ +#define DC_TCFG_BKRT 0x00010000 /* blink rate */ +#define DC_TCFG_PSD_MASK 0x000E0000 /* power sequence delay */ +#define DC_TCFG_PSD_POS 17 /* power sequence delay */ +#define DC_TCFG_DDCI 0x08000000 /* DDC input (RO) */ +#define DC_TCFG_SENS 0x10000000 /* monitor sense (RO) */ +#define DC_TCFG_DNA 0x20000000 /* display not active (RO) */ +#define DC_TCFG_VNA 0x40000000 /* vertical not active (RO) */ +#define DC_TCFG_VINT 0x80000000 /* vertical interrupt (RO) */ /* "DC_OUTPUT_CFG" BIT DEFINITIONS */ -#define DC_OCFG_8BPP 0x00000001 /* 8/16 bpp select */ -#define DC_OCFG_555 0x00000002 /* 16 bpp format */ -#define DC_OCFG_PCKE 0x00000004 /* PCLK enable */ -#define DC_OCFG_FRME 0x00000008 /* frame rate mod enable */ -#define DC_OCFG_DITE 0x00000010 /* dither enable */ -#define DC_OCFG_2PXE 0x00000020 /* 2 pixel enable */ -#define DC_OCFG_2XCK 0x00000040 /* 2 x pixel clock */ -#define DC_OCFG_2IND 0x00000080 /* 2 index enable */ -#define DC_OCFG_34ADD 0x00000100 /* 3- or 4-bit add */ -#define DC_OCFG_FRMS 0x00000200 /* frame rate mod select */ -#define DC_OCFG_CKSL 0x00000400 /* clock select */ -#define DC_OCFG_PRMP 0x00000800 /* palette re-map */ -#define DC_OCFG_PDEL 0x00001000 /* panel data enable low */ -#define DC_OCFG_PDEH 0x00002000 /* panel data enable high */ -#define DC_OCFG_CFRW 0x00004000 /* comp line buffer r/w sel */ -#define DC_OCFG_DIAG 0x00008000 /* comp line buffer diag */ +#define DC_OCFG_8BPP 0x00000001 /* 8/16 bpp select */ +#define DC_OCFG_555 0x00000002 /* 16 bpp format */ +#define DC_OCFG_PCKE 0x00000004 /* PCLK enable */ +#define DC_OCFG_FRME 0x00000008 /* frame rate mod enable */ +#define DC_OCFG_DITE 0x00000010 /* dither enable */ +#define DC_OCFG_2PXE 0x00000020 /* 2 pixel enable */ +#define DC_OCFG_2XCK 0x00000040 /* 2 x pixel clock */ +#define DC_OCFG_2IND 0x00000080 /* 2 index enable */ +#define DC_OCFG_34ADD 0x00000100 /* 3- or 4-bit add */ +#define DC_OCFG_FRMS 0x00000200 /* frame rate mod select */ +#define DC_OCFG_CKSL 0x00000400 /* clock select */ +#define DC_OCFG_PRMP 0x00000800 /* palette re-map */ +#define DC_OCFG_PDEL 0x00001000 /* panel data enable low */ +#define DC_OCFG_PDEH 0x00002000 /* panel data enable high */ +#define DC_OCFG_CFRW 0x00004000 /* comp line buffer r/w sel */ +#define DC_OCFG_DIAG 0x00008000 /* comp line buffer diag */ #define MC_MEM_CNTRL1 0x00008400 #define MC_DR_ADD 0x00008418 @@ -360,9 +360,9 @@ /* MC_MEM_CNTRL1 BIT DEFINITIONS */ -#define MC_XBUSARB 0x00000008 /* 0 = GP priority < CPU priority */ - /* 1 = GP priority = CPU priority */ - /* GXm databook V2.0 is wrong ! */ +#define MC_XBUSARB 0x00000008 /* 0 = GP priority < CPU priority */ + /* 1 = GP priority = CPU priority */ + /* GXm databook V2.0 is wrong ! */ /*----------*/ /* CS5530 */ /*----------*/ @@ -478,8 +478,8 @@ #define SC1200_TVOUT_HORZ_SYNC 0x804 #define SC1200_TVOUT_VERT_SYNC 0x808 #define SC1200_TVOUT_LINE_END 0x80C -#define SC1200_TVOUT_VERT_DOWNSCALE 0x810 /* REV. A & B */ -#define SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE 0x810 /* REV. C */ +#define SC1200_TVOUT_VERT_DOWNSCALE 0x810 /* REV. A & B */ +#define SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE 0x810 /* REV. C */ #define SC1200_TVOUT_HORZ_SCALING 0x814 #define SC1200_TVOUT_DEBUG 0x818 #define SC1200_TVENC_TIM_CTRL_1 0xC00 @@ -578,7 +578,7 @@ #define SC1200_CURSOR_COLOR_KEY_OFFSET_POS 24 #define SC1200_CURSOR_COLOR_BITS 23 -#define SC1200_COLOR_MASK 0x00FFFFFF /* 24 significant bits */ +#define SC1200_COLOR_MASK 0x00FFFFFF /* 24 significant bits */ /* ALPHA COLOR BIT DEFINITION (REGISTERS 0x68, 0x78, AND 0x88) */ @@ -847,80 +847,80 @@ /* SECOND GENERATION GRAPHICS UNIT (REDCLOUD) */ /*----------------------------------------------*/ -#define MGP_DST_OFFSET 0x0000 /* dst address */ -#define MGP_SRC_OFFSET 0x0004 /* src address */ -#define MGP_VEC_ERR 0x0004 /* vector diag/axial errors */ -#define MGP_STRIDE 0x0008 /* src and dst strides */ -#define MGP_WID_HEIGHT 0x000C /* width and height of BLT */ -#define MGP_VEC_LEN 0x000C /* vector length/init error */ -#define MGP_SRC_COLOR_FG 0x0010 /* src mono data fgcolor */ -#define MGP_SRC_COLOR_BG 0x0014 /* src mono data bkcolor */ -#define MGP_PAT_COLOR_0 0x0018 /* pattern color 0 */ -#define MGP_PAT_COLOR_1 0x001C /* pattern color 1 */ -#define MGP_PAT_COLOR_2 0x0020 /* pattern color 2 */ -#define MGP_PAT_COLOR_3 0x0024 /* pattern color 3 */ -#define MGP_PAT_COLOR_4 0x0028 /* pattern color 4 */ -#define MGP_PAT_COLOR_5 0x002C /* pattern color 5 */ -#define MGP_PAT_DATA_0 0x0030 /* pattern data 0 */ -#define MGP_PAT_DATA_1 0x0034 /* pattern data 1 */ -#define MGP_RASTER_MODE 0x0038 /* raster operation */ -#define MGP_VECTOR_MODE 0x003C /* render vector */ -#define MGP_BLT_MODE 0x0040 /* render BLT */ -#define MGP_BLT_STATUS 0x0044 /* BLT status register */ -#define MGP_RESET 0x0044 /* reset register (write) */ -#define MGP_HST_SOURCE 0x0048 /* host src data (bitmap) */ -#define MGP_BASE_OFFSET 0x004C /* base render offset */ +#define MGP_DST_OFFSET 0x0000 /* dst address */ +#define MGP_SRC_OFFSET 0x0004 /* src address */ +#define MGP_VEC_ERR 0x0004 /* vector diag/axial errors */ +#define MGP_STRIDE 0x0008 /* src and dst strides */ +#define MGP_WID_HEIGHT 0x000C /* width and height of BLT */ +#define MGP_VEC_LEN 0x000C /* vector length/init error */ +#define MGP_SRC_COLOR_FG 0x0010 /* src mono data fgcolor */ +#define MGP_SRC_COLOR_BG 0x0014 /* src mono data bkcolor */ +#define MGP_PAT_COLOR_0 0x0018 /* pattern color 0 */ +#define MGP_PAT_COLOR_1 0x001C /* pattern color 1 */ +#define MGP_PAT_COLOR_2 0x0020 /* pattern color 2 */ +#define MGP_PAT_COLOR_3 0x0024 /* pattern color 3 */ +#define MGP_PAT_COLOR_4 0x0028 /* pattern color 4 */ +#define MGP_PAT_COLOR_5 0x002C /* pattern color 5 */ +#define MGP_PAT_DATA_0 0x0030 /* pattern data 0 */ +#define MGP_PAT_DATA_1 0x0034 /* pattern data 1 */ +#define MGP_RASTER_MODE 0x0038 /* raster operation */ +#define MGP_VECTOR_MODE 0x003C /* render vector */ +#define MGP_BLT_MODE 0x0040 /* render BLT */ +#define MGP_BLT_STATUS 0x0044 /* BLT status register */ +#define MGP_RESET 0x0044 /* reset register (write) */ +#define MGP_HST_SOURCE 0x0048 /* host src data (bitmap) */ +#define MGP_BASE_OFFSET 0x004C /* base render offset */ /* MGP_RASTER_MODE DEFINITIONS */ -#define MGP_RM_BPPFMT_332 0x00000000 /* 8 BPP, 3:3:2 */ -#define MGP_RM_BPPFMT_4444 0x40000000 /* 16 BPP, 4:4:4:4 */ -#define MGP_RM_BPPFMT_1555 0x50000000 /* 16 BPP, 1:5:5:5 */ -#define MGP_RM_BPPFMT_565 0x60000000 /* 16 BPP, 5:6:5 */ -#define MGP_RM_BPPFMT_8888 0x80000000 /* 32 BPP, 8:8:8:8 */ -#define MGP_RM_ALPHA_EN_MASK 0x00C00000 /* Alpha enable */ -#define MGP_RM_ALPHA_TO_RGB 0x00400000 /* Alpha applies to RGB */ -#define MGP_RM_ALPHA_TO_ALPHA 0x00800000 /* Alpha applies to alpha */ -#define MGP_RM_ALPHA_OP_MASK 0x00300000 /* Alpha operation */ -#define MGP_RM_ALPHA_TIMES_A 0x00000000 /* Alpha * A */ -#define MGP_RM_BETA_TIMES_B 0x00100000 /* (1-alpha) * B */ -#define MGP_RM_A_PLUS_BETA_B 0x00200000 /* A + (1-alpha) * B */ -#define MGP_RM_ALPHA_A_PLUS_BETA_B 0x00300000 /* alpha * A + (1 - alpha)B */ -#define MGP_RM_ALPHA_SELECT 0x000E0000 /* Alpha Select */ -#define MGP_RM_SELECT_ALPHA_A 0x00000000 /* Alpha from channel A */ -#define MGP_RM_SELECT_ALPHA_B 0x00020000 /* Alpha from channel B */ -#define MGP_RM_SELECT_ALPHA_R 0x00040000 /* Registered alpha */ -#define MGP_RM_SELECT_ALPHA_1 0x00060000 /* Constant 1 */ -#define MGP_RM_SELECT_ALPHA_CHAN_A 0x00080000 /* RGB Values from A */ -#define MGP_RM_SELECT_ALPHA_CHAN_B 0x000A0000 /* RGB Values from B */ -#define MGP_RM_DEST_FROM_CHAN_A 0x00010000 /* Alpha channel select */ -#define MGP_RM_PAT_FLAGS 0x00000700 /* pattern related bits */ -#define MGP_RM_PAT_MONO 0x00000100 /* monochrome pattern */ -#define MGP_RM_PAT_COLOR 0x00000200 /* color pattern */ -#define MGP_RM_PAT_TRANS 0x00000400 /* pattern transparency */ -#define MGP_RM_SRC_TRANS 0x00000800 /* source transparency */ +#define MGP_RM_BPPFMT_332 0x00000000 /* 8 BPP, 3:3:2 */ +#define MGP_RM_BPPFMT_4444 0x40000000 /* 16 BPP, 4:4:4:4 */ +#define MGP_RM_BPPFMT_1555 0x50000000 /* 16 BPP, 1:5:5:5 */ +#define MGP_RM_BPPFMT_565 0x60000000 /* 16 BPP, 5:6:5 */ +#define MGP_RM_BPPFMT_8888 0x80000000 /* 32 BPP, 8:8:8:8 */ +#define MGP_RM_ALPHA_EN_MASK 0x00C00000 /* Alpha enable */ +#define MGP_RM_ALPHA_TO_RGB 0x00400000 /* Alpha applies to RGB */ +#define MGP_RM_ALPHA_TO_ALPHA 0x00800000 /* Alpha applies to alpha */ +#define MGP_RM_ALPHA_OP_MASK 0x00300000 /* Alpha operation */ +#define MGP_RM_ALPHA_TIMES_A 0x00000000 /* Alpha * A */ +#define MGP_RM_BETA_TIMES_B 0x00100000 /* (1-alpha) * B */ +#define MGP_RM_A_PLUS_BETA_B 0x00200000 /* A + (1-alpha) * B */ +#define MGP_RM_ALPHA_A_PLUS_BETA_B 0x00300000 /* alpha * A + (1 - alpha)B */ +#define MGP_RM_ALPHA_SELECT 0x000E0000 /* Alpha Select */ +#define MGP_RM_SELECT_ALPHA_A 0x00000000 /* Alpha from channel A */ +#define MGP_RM_SELECT_ALPHA_B 0x00020000 /* Alpha from channel B */ +#define MGP_RM_SELECT_ALPHA_R 0x00040000 /* Registered alpha */ +#define MGP_RM_SELECT_ALPHA_1 0x00060000 /* Constant 1 */ +#define MGP_RM_SELECT_ALPHA_CHAN_A 0x00080000 /* RGB Values from A */ +#define MGP_RM_SELECT_ALPHA_CHAN_B 0x000A0000 /* RGB Values from B */ +#define MGP_RM_DEST_FROM_CHAN_A 0x00010000 /* Alpha channel select */ +#define MGP_RM_PAT_FLAGS 0x00000700 /* pattern related bits */ +#define MGP_RM_PAT_MONO 0x00000100 /* monochrome pattern */ +#define MGP_RM_PAT_COLOR 0x00000200 /* color pattern */ +#define MGP_RM_PAT_TRANS 0x00000400 /* pattern transparency */ +#define MGP_RM_SRC_TRANS 0x00000800 /* source transparency */ /* MGP_VECTOR_MODE DEFINITIONS */ -#define MGP_VM_DST_REQ 0x00000008 /* dst data required */ -#define MGP_VM_THROTTLE 0x00000010 /* sync to VBLANK */ +#define MGP_VM_DST_REQ 0x00000008 /* dst data required */ +#define MGP_VM_THROTTLE 0x00000010 /* sync to VBLANK */ /* MGP_BLT_MODE DEFINITIONS */ -#define MGP_BM_SRC_FB 0x00000001 /* src = frame buffer */ -#define MGP_BM_SRC_HOST 0x00000002 /* src = host register */ -#define MGP_BM_DST_REQ 0x00000004 /* dst data required */ -#define MGP_BM_SRC_MONO 0x00000040 /* monochrome source data */ -#define MGP_BM_SRC_BP_MONO 0x00000080 /* Byte-packed monochrome */ -#define MGP_BM_NEG_YDIR 0x00000100 /* negative Y direction */ -#define MGP_BM_NEG_XDIR 0x00000200 /* negative X direction */ -#define MGP_BM_THROTTLE 0x00000400 /* sync to VBLANK */ +#define MGP_BM_SRC_FB 0x00000001 /* src = frame buffer */ +#define MGP_BM_SRC_HOST 0x00000002 /* src = host register */ +#define MGP_BM_DST_REQ 0x00000004 /* dst data required */ +#define MGP_BM_SRC_MONO 0x00000040 /* monochrome source data */ +#define MGP_BM_SRC_BP_MONO 0x00000080 /* Byte-packed monochrome */ +#define MGP_BM_NEG_YDIR 0x00000100 /* negative Y direction */ +#define MGP_BM_NEG_XDIR 0x00000200 /* negative X direction */ +#define MGP_BM_THROTTLE 0x00000400 /* sync to VBLANK */ /* MGP_BLT_STATUS DEFINITIONS */ -#define MGP_BS_BLT_BUSY 0x00000001 /* GP is not idle */ -#define MGP_BS_BLT_PENDING 0x00000004 /* second BLT is pending */ -#define MGP_BS_HALF_EMPTY 0x00000008 /* src FIFO half empty */ +#define MGP_BS_BLT_BUSY 0x00000001 /* GP is not idle */ +#define MGP_BS_BLT_PENDING 0x00000004 /* second BLT is pending */ +#define MGP_BS_HALF_EMPTY 0x00000008 /* src FIFO half empty */ /* ALPHA BLENDING MODES */ @@ -930,48 +930,48 @@ /* SECOND GENERATION DISPLAY CONTROLLER (REDCLOUD) */ /*---------------------------------------------------*/ -#define MDC_UNLOCK 0x00000000 /* Unlock register */ -#define MDC_GENERAL_CFG 0x00000004 /* Config registers */ +#define MDC_UNLOCK 0x00000000 /* Unlock register */ +#define MDC_GENERAL_CFG 0x00000004 /* Config registers */ #define MDC_DISPLAY_CFG 0x00000008 -#define MDC_GFX_SCL 0x0000000C /* Graphics scaling */ - -#define MDC_FB_ST_OFFSET 0x00000010 /* Frame buffer start offset */ -#define MDC_CB_ST_OFFSET 0x00000014 /* Compression start offset */ -#define MDC_CURS_ST_OFFSET 0x00000018 /* Cursor buffer start offset */ -#define MDC_ICON_ST_OFFSET 0x0000001C /* Icon buffer start offset */ -#define MDC_VID_Y_ST_OFFSET 0x00000020 /* Video Y Buffer start offset */ -#define MDC_VID_U_ST_OFFSET 0x00000024 /* Video U Buffer start offset */ -#define MDC_VID_V_ST_OFFSET 0x00000028 /* Video V Buffer start offset */ -#define MDC_LINE_SIZE 0x00000030 /* Video, CB, and FB line sizes */ -#define MDC_GFX_PITCH 0x00000034 /* FB and DB skip counts */ -#define MDC_VID_YUV_PITCH 0x00000038 /* Y, U and V buffer skip counts */ - -#define MDC_H_ACTIVE_TIMING 0x00000040 /* Horizontal timings */ +#define MDC_GFX_SCL 0x0000000C /* Graphics scaling */ + +#define MDC_FB_ST_OFFSET 0x00000010 /* Frame buffer start offset */ +#define MDC_CB_ST_OFFSET 0x00000014 /* Compression start offset */ +#define MDC_CURS_ST_OFFSET 0x00000018 /* Cursor buffer start offset */ +#define MDC_ICON_ST_OFFSET 0x0000001C /* Icon buffer start offset */ +#define MDC_VID_Y_ST_OFFSET 0x00000020 /* Video Y Buffer start offset */ +#define MDC_VID_U_ST_OFFSET 0x00000024 /* Video U Buffer start offset */ +#define MDC_VID_V_ST_OFFSET 0x00000028 /* Video V Buffer start offset */ +#define MDC_LINE_SIZE 0x00000030 /* Video, CB, and FB line sizes */ +#define MDC_GFX_PITCH 0x00000034 /* FB and DB skip counts */ +#define MDC_VID_YUV_PITCH 0x00000038 /* Y, U and V buffer skip counts */ + +#define MDC_H_ACTIVE_TIMING 0x00000040 /* Horizontal timings */ #define MDC_H_BLANK_TIMING 0x00000044 #define MDC_H_SYNC_TIMING 0x00000048 -#define MDC_V_ACTIVE_TIMING 0x00000050 /* Vertical Timings */ +#define MDC_V_ACTIVE_TIMING 0x00000050 /* Vertical Timings */ #define MDC_V_BLANK_TIMING 0x00000054 #define MDC_V_SYNC_TIMING 0x00000058 -#define MDC_CURSOR_X 0x00000060 /* Cursor X position */ -#define MDC_CURSOR_Y 0x00000064 /* Cursor Y Position */ -#define MDC_ICON_X 0x00000068 /* Icon X Position */ -#define MDC_LINE_CNT_STATUS 0x0000006C /* Icon Y Position */ +#define MDC_CURSOR_X 0x00000060 /* Cursor X position */ +#define MDC_CURSOR_Y 0x00000064 /* Cursor Y Position */ +#define MDC_ICON_X 0x00000068 /* Icon X Position */ +#define MDC_LINE_CNT_STATUS 0x0000006C /* Icon Y Position */ -#define MDC_PAL_ADDRESS 0x00000070 /* Palette Address */ -#define MDC_PAL_DATA 0x00000074 /* Palette Data */ -#define MDC_DFIFO_DIAG 0x00000078 /* Display FIFO diagnostic */ -#define MDC_CFIFO_DIAG 0x0000007C /* Compression FIFO diagnostic */ +#define MDC_PAL_ADDRESS 0x00000070 /* Palette Address */ +#define MDC_PAL_DATA 0x00000074 /* Palette Data */ +#define MDC_DFIFO_DIAG 0x00000078 /* Display FIFO diagnostic */ +#define MDC_CFIFO_DIAG 0x0000007C /* Compression FIFO diagnostic */ -#define MDC_VID_DS_DELTA 0x00000080 /* Vertical Downscaling fraction */ +#define MDC_VID_DS_DELTA 0x00000080 /* Vertical Downscaling fraction */ -#define MDC_PHY_MEM_OFFSET 0x00000084 /* VG Base Address Register */ -#define MDC_DV_CTL 0x00000088 /* Dirty-Valid Control Register */ -#define MDC_DV_ACC 0x0000008C /* Dirty-Valid RAM Access */ +#define MDC_PHY_MEM_OFFSET 0x00000084 /* VG Base Address Register */ +#define MDC_DV_CTL 0x00000088 /* Dirty-Valid Control Register */ +#define MDC_DV_ACC 0x0000008C /* Dirty-Valid RAM Access */ /* UNLOCK VALUE */ -#define MDC_UNLOCK_VALUE 0x00004758 /* used to unlock DC regs */ +#define MDC_UNLOCK_VALUE 0x00004758 /* used to unlock DC regs */ /* VG MBUS DEVICE SMI MSR FIELDS */ @@ -1267,7 +1267,7 @@ #define RCDF_CURSOR_COLOR_KEY_ENABLE 0x20000000 #define RCDF_CURSOR_COLOR_KEY_OFFSET_POS 24 #define RCDF_CURSOR_COLOR_BITS 23 -#define RCDF_COLOR_MASK 0x00FFFFFF /* 24 significant bits */ +#define RCDF_COLOR_MASK 0x00FFFFFF /* 24 significant bits */ /* ALPHA COLOR BIT DEFINITION (REGISTERS 0x68, 0x78, AND 0x88) */ @@ -1286,23 +1286,23 @@ /* GEODELINK DEVICE MSR REGISTER SUMMARY */ -#define MBD_MSR_CAP 0x2000 /* Device Capabilities */ -#define MBD_MSR_CONFIG 0x2001 /* Device Master Configuration Register */ -#define MBD_MSR_SMI 0x2002 /* MBus Device SMI Register */ -#define MBD_MSR_ERROR 0x2003 /* MBus Device Error */ -#define MBD_MSR_PM 0x2004 /* MBus Device Power Management Register */ -#define MBD_MSR_DIAG 0x2005 /* Mbus Device Diagnostic Register */ +#define MBD_MSR_CAP 0x2000 /* Device Capabilities */ +#define MBD_MSR_CONFIG 0x2001 /* Device Master Configuration Register */ +#define MBD_MSR_SMI 0x2002 /* MBus Device SMI Register */ +#define MBD_MSR_ERROR 0x2003 /* MBus Device Error */ +#define MBD_MSR_PM 0x2004 /* MBus Device Power Management Register */ +#define MBD_MSR_DIAG 0x2005 /* Mbus Device Diagnostic Register */ /* DISPLAY FILTER MBD_MSR_DIAG DEFINITIONS */ -#define RCDF_MBD_DIAG_SEL0 0x00007FFF /* Lower 32-bits of Diag Bus Select */ -#define RCDF_MBD_DIAG_EN0 0x00008000 /* Enable for lower 32-bits of diag bus */ -#define RCDF_MBD_DIAG_SEL1 0x7FFF0000 /* Upper 32-bits of Diag Bus Select */ -#define RCDF_MBD_DIAG_EN1 0x80000000 /* Enable for upper 32-bits of diag bus */ +#define RCDF_MBD_DIAG_SEL0 0x00007FFF /* Lower 32-bits of Diag Bus Select */ +#define RCDF_MBD_DIAG_EN0 0x00008000 /* Enable for lower 32-bits of diag bus */ +#define RCDF_MBD_DIAG_SEL1 0x7FFF0000 /* Upper 32-bits of Diag Bus Select */ +#define RCDF_MBD_DIAG_EN1 0x80000000 /* Enable for upper 32-bits of diag bus */ /* DISPLAY FILTER MBD_MSR_CONFIG DEFINITIONS */ -#define RCDF_CONFIG_FMT_MASK 0x00000038 /* Output Format */ +#define RCDF_CONFIG_FMT_MASK 0x00000038 /* Output Format */ #define RCDF_CONFIG_FMT_CRT 0x00000000 #define RCDF_CONFIG_FMT_FP 0x00000008 @@ -1355,4 +1355,3 @@ #define MCP_DOTPLL_BYPASS 0x00008000 /* END OF FILE */ - diff --git a/src/gfx/gfx_rndr.c b/src/gfx/gfx_rndr.c index 5b6b881..a7f574c 100644 --- a/src/gfx/gfx_rndr.c +++ b/src/gfx/gfx_rndr.c @@ -186,8 +186,8 @@ void gfx_reset_pitch(unsigned short pitch) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_reset_pitch(pitch); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_reset_pitch(pitch); # endif } @@ -199,12 +199,12 @@ void gfx_set_bpp(unsigned short bpp) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_set_bpp(bpp); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_set_bpp(bpp); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_set_bpp(bpp); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_set_bpp(bpp); # endif } @@ -216,12 +216,12 @@ void gfx_set_solid_source(unsigned long color) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_set_solid_source(color); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_set_solid_source(color); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_set_solid_source(color); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_set_solid_source(color); # endif } @@ -231,22 +231,22 @@ gfx_set_solid_source(unsigned long color) */ void gfx_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned short transparent) + unsigned short transparent) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_set_mono_source(bgcolor, fgcolor, transparent); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_set_mono_source(bgcolor, fgcolor, transparent); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_set_mono_source(bgcolor, fgcolor, transparent); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_set_mono_source(bgcolor, fgcolor, transparent); # endif } void gfx_set_pattern_flags(unsigned short flags) { - GFXpatternFlags |= flags; + GFXpatternFlags |= flags; } /*--------------------------------------------------------------------------- @@ -257,12 +257,12 @@ void gfx_set_solid_pattern(unsigned long color) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_set_solid_pattern(color); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_set_solid_pattern(color); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_set_solid_pattern(color); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_set_solid_pattern(color); # endif } @@ -272,16 +272,16 @@ gfx_set_solid_pattern(unsigned long color) */ void gfx_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned char transparent) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_set_mono_pattern(bgcolor, fgcolor, data0, data1, transparent); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_set_mono_pattern(bgcolor, fgcolor, data0, data1, transparent); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_set_mono_pattern(bgcolor, fgcolor, data0, data1, transparent); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_set_mono_pattern(bgcolor, fgcolor, data0, data1, transparent); # endif } @@ -291,19 +291,19 @@ gfx_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, */ void gfx_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned long data2, unsigned long data3, + unsigned char transparent) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_set_color_pattern(bgcolor, fgcolor, data0, data1, data2, data3, - transparent); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_set_color_pattern(bgcolor, fgcolor, data0, data1, data2, data3, + transparent); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_set_color_pattern(bgcolor, fgcolor, data0, data1, data2, data3, - transparent); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_set_color_pattern(bgcolor, fgcolor, data0, data1, data2, data3, + transparent); # endif } @@ -315,12 +315,12 @@ void gfx_load_color_pattern_line(short y, unsigned long *pattern_8x8) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_load_color_pattern_line(y, pattern_8x8); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_load_color_pattern_line(y, pattern_8x8); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_load_color_pattern_line(y, pattern_8x8); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_load_color_pattern_line(y, pattern_8x8); # endif } @@ -332,12 +332,12 @@ void gfx_set_raster_operation(unsigned char rop) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_set_raster_operation(rop); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_set_raster_operation(rop); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_set_raster_operation(rop); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_set_raster_operation(rop); # endif } @@ -347,15 +347,15 @@ gfx_set_raster_operation(unsigned char rop) */ void gfx_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_pattern_fill(x, y, width, height); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_pattern_fill(x, y, width, height); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_pattern_fill(x, y, width, height); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_pattern_fill(x, y, width, height); # endif } @@ -365,16 +365,16 @@ gfx_pattern_fill(unsigned short x, unsigned short y, */ void gfx_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long *pattern) + unsigned short width, unsigned short height, + unsigned long *pattern) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_color_pattern_fill(x, y, width, height, pattern); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_color_pattern_fill(x, y, width, height, pattern); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_color_pattern_fill(x, y, width, height, pattern); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_color_pattern_fill(x, y, width, height, pattern); # endif } @@ -384,16 +384,16 @@ gfx_color_pattern_fill(unsigned short x, unsigned short y, */ void gfx_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_screen_to_screen_blt(srcx, srcy, dstx, dsty, width, height); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_screen_to_screen_blt(srcx, srcy, dstx, dsty, width, height); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_screen_to_screen_blt(srcx, srcy, dstx, dsty, width, height); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_screen_to_screen_blt(srcx, srcy, dstx, dsty, width, height); # endif } @@ -403,17 +403,17 @@ gfx_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, */ void gfx_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_screen_to_screen_xblt(srcx, srcy, dstx, dsty, width, height, color); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_screen_to_screen_xblt(srcx, srcy, dstx, dsty, width, height, color); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_screen_to_screen_xblt(srcx, srcy, dstx, dsty, width, height, color); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_screen_to_screen_xblt(srcx, srcy, dstx, dsty, width, height, color); # endif } @@ -423,19 +423,19 @@ gfx_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, */ void gfx_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_color_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, - data, pitch); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_color_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, + data, pitch); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_color_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, - data, pitch); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_color_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, + data, pitch); # endif } @@ -445,20 +445,20 @@ gfx_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, */ void gfx_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch, + unsigned long color) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_color_bitmap_to_screen_xblt(srcx, srcy, dstx, dsty, width, height, - data, pitch, color); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_color_bitmap_to_screen_xblt(srcx, srcy, dstx, dsty, width, height, + data, pitch, color); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_color_bitmap_to_screen_xblt(srcx, srcy, dstx, dsty, width, height, - data, pitch, color); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_color_bitmap_to_screen_xblt(srcx, srcy, dstx, dsty, width, height, + data, pitch, color); # endif } @@ -468,19 +468,19 @@ gfx_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, */ void gfx_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, short pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, short pitch) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_mono_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, - data, pitch); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_mono_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, + data, pitch); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_mono_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, - data, pitch); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_mono_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, + data, pitch); # endif } @@ -490,15 +490,15 @@ gfx_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, */ void gfx_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, - unsigned short height, unsigned char *data) + unsigned short height, unsigned char *data) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_text_blt(dstx, dsty, width, height, data); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_text_blt(dstx, dsty, width, height, data); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_text_blt(dstx, dsty, width, height, data); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_text_blt(dstx, dsty, width, height, data); # endif } @@ -508,17 +508,17 @@ gfx_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, */ void gfx_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_bresenham_line(x, y, length, initerr, axialerr, diagerr, flags); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_bresenham_line(x, y, length, initerr, axialerr, diagerr, flags); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_bresenham_line(x, y, length, initerr, axialerr, diagerr, flags); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_bresenham_line(x, y, length, initerr, axialerr, diagerr, flags); # endif } @@ -530,12 +530,12 @@ void gfx_wait_until_idle(void) { # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - gu1_wait_until_idle(); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + gu1_wait_until_idle(); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu2_wait_until_idle(); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu2_wait_until_idle(); # endif } @@ -546,17 +546,17 @@ gfx_wait_until_idle(void) int gfx_test_blt_pending(void) { - int retval = 0; + int retval = 0; # if GFX_2DACCEL_GU1 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) - retval = gu1_test_blt_pending(); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU1) + retval = gu1_test_blt_pending(); # endif # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - retval = gu2_test_blt_pending(); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + retval = gu2_test_blt_pending(); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -572,8 +572,8 @@ void gfx2_set_source_stride(unsigned short stride) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_set_source_stride(stride); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_set_source_stride(stride); # endif } @@ -585,8 +585,8 @@ void gfx2_set_destination_stride(unsigned short stride) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_set_destination_stride(stride); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_set_destination_stride(stride); # endif } @@ -598,8 +598,8 @@ void gfx2_set_pattern_origin(int x, int y) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_set_pattern_origin(x, y); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_set_pattern_origin(x, y); # endif } @@ -611,8 +611,8 @@ void gfx2_set_source_transparency(unsigned long color, unsigned long mask) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_set_source_transparency(color, mask); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_set_source_transparency(color, mask); # endif } @@ -624,8 +624,8 @@ void gfx2_set_alpha_mode(int mode) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_set_alpha_mode(mode); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_set_alpha_mode(mode); # endif } @@ -637,8 +637,8 @@ void gfx2_set_alpha_value(unsigned char value) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_set_alpha_value(value); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_set_alpha_value(value); # endif } @@ -648,11 +648,11 @@ gfx2_set_alpha_value(unsigned char value) */ void gfx2_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height) + unsigned short height) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_pattern_fill(dstoffset, width, height); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_pattern_fill(dstoffset, width, height); # endif } @@ -662,11 +662,11 @@ gfx2_pattern_fill(unsigned long dstoffset, unsigned short width, */ void gfx2_color_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned long *pattern) + unsigned short height, unsigned long *pattern) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_color_pattern_fill(dstoffset, width, height, pattern); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_color_pattern_fill(dstoffset, width, height, pattern); # endif } @@ -676,12 +676,12 @@ gfx2_color_pattern_fill(unsigned long dstoffset, unsigned short width, */ void gfx2_screen_to_screen_blt(unsigned long srcoffset, unsigned long dstoffset, - unsigned short width, unsigned short height, - int flags) + unsigned short width, unsigned short height, + int flags) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_screen_to_screen_blt(srcoffset, dstoffset, width, height, flags); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_screen_to_screen_blt(srcoffset, dstoffset, width, height, flags); # endif } @@ -691,14 +691,14 @@ gfx2_screen_to_screen_blt(unsigned long srcoffset, unsigned long dstoffset, */ void gfx2_mono_expand_blt(unsigned long srcbase, unsigned short srcx, - unsigned short srcy, unsigned long dstoffset, - unsigned short width, unsigned short height, - int byte_packed) + unsigned short srcy, unsigned long dstoffset, + unsigned short width, unsigned short height, + int byte_packed) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_mono_expand_blt(srcbase, srcx, srcy, dstoffset, width, height, - byte_packed); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_mono_expand_blt(srcbase, srcx, srcy, dstoffset, width, height, + byte_packed); # endif } @@ -708,14 +708,14 @@ gfx2_mono_expand_blt(unsigned long srcbase, unsigned short srcx, */ void gfx2_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data, - short pitch) + unsigned long dstoffset, unsigned short width, + unsigned short height, unsigned char *data, + short pitch) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_color_bitmap_to_screen_blt(srcx, srcy, dstoffset, width, height, - data, pitch); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_color_bitmap_to_screen_blt(srcx, srcy, dstoffset, width, height, + data, pitch); # endif } @@ -725,11 +725,11 @@ gfx2_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, */ void gfx2_text_blt(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data) + unsigned short height, unsigned char *data) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_text_blt(dstoffset, width, height, data); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_text_blt(dstoffset, width, height, data); # endif } @@ -739,14 +739,14 @@ gfx2_text_blt(unsigned long dstoffset, unsigned short width, */ void gfx2_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data, - short pitch) + unsigned long dstoffset, unsigned short width, + unsigned short height, unsigned char *data, + short pitch) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_mono_bitmap_to_screen_blt(srcx, srcy, dstoffset, width, height, - data, pitch); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_mono_bitmap_to_screen_blt(srcx, srcy, dstoffset, width, height, + data, pitch); # endif } @@ -756,14 +756,14 @@ gfx2_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, */ void gfx2_bresenham_line(unsigned long dstoffset, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_bresenham_line(dstoffset, length, initerr, axialerr, diagerr, - flags); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_bresenham_line(dstoffset, length, initerr, axialerr, diagerr, + flags); # endif } @@ -775,12 +775,11 @@ void gfx2_sync_to_vblank(void) { # if GFX_2DACCEL_GU2 - if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) - gu22_sync_to_vblank(); + if (gfx_2daccel_type & GFX_2DACCEL_TYPE_GU2) + gu22_sync_to_vblank(); # endif } -#endif /* GFX_2DACCEL_DYNAMIC */ +#endif /* GFX_2DACCEL_DYNAMIC */ /* END OF FILE */ - diff --git a/src/gfx/gfx_rtns.h b/src/gfx/gfx_rtns.h index aefd6c0..db60ac3 100644 --- a/src/gfx/gfx_rtns.h +++ b/src/gfx/gfx_rtns.h @@ -144,595 +144,583 @@ /* COMPILER OPTION FOR C++ PROGRAMS */ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif /* DURANGO MEMORY POINTERS */ - extern unsigned char *gfx_virt_regptr; - extern unsigned char *gfx_virt_fbptr; - extern unsigned char *gfx_virt_vidptr; - extern unsigned char *gfx_virt_vipptr; - extern unsigned char *gfx_virt_spptr; - extern unsigned char *gfx_virt_gpptr; + extern unsigned char *gfx_virt_regptr; + extern unsigned char *gfx_virt_fbptr; + extern unsigned char *gfx_virt_vidptr; + extern unsigned char *gfx_virt_vipptr; + extern unsigned char *gfx_virt_spptr; + extern unsigned char *gfx_virt_gpptr; - extern unsigned char *gfx_phys_regptr; - extern unsigned char *gfx_phys_fbptr; - extern unsigned char *gfx_phys_vidptr; - extern unsigned char *gfx_phys_vipptr; - extern unsigned char *gfx_phys_spptr; - extern unsigned char *gfx_phys_gpptr; + extern unsigned char *gfx_phys_regptr; + extern unsigned char *gfx_phys_fbptr; + extern unsigned char *gfx_phys_vidptr; + extern unsigned char *gfx_phys_vipptr; + extern unsigned char *gfx_phys_spptr; + extern unsigned char *gfx_phys_gpptr; /* DURANGO VARIBLES FOR RUNTIME SELECTION AND POSSIBLE VALUES */ - extern int gfx_display_type; + extern int gfx_display_type; #define GFX_DISPLAY_TYPE_GU1 0x0001 #define GFX_DISPLAY_TYPE_GU2 0x0002 - extern int gfx_init_type; + extern int gfx_init_type; #define GFX_INIT_TYPE_GU1 0x0001 #define GFX_INIT_TYPE_GU2 0x0002 - extern int gfx_msr_type; + extern int gfx_msr_type; #define GFX_MSR_TYPE_REDCLOUD 0x0001 - extern int gfx_2daccel_type; + extern int gfx_2daccel_type; #define GFX_2DACCEL_TYPE_GU1 0x0001 #define GFX_2DACCEL_TYPE_GU2 0x0002 - extern int gfx_video_type; + extern int gfx_video_type; #define GFX_VIDEO_TYPE_CS5530 0x0001 #define GFX_VIDEO_TYPE_SC1200 0x0002 #define GFX_VIDEO_TYPE_REDCLOUD 0x0004 - extern int gfx_vip_type; + extern int gfx_vip_type; #define GFX_VIP_TYPE_SC1200 0x0001 - extern int gfx_decoder_type; + extern int gfx_decoder_type; #define GFX_DECODER_TYPE_SAA7114 0x0001 - extern int gfx_tv_type; + extern int gfx_tv_type; #define GFX_TV_TYPE_SC1200 0x0001 #define GFX_TV_TYPE_FS451 0x0002 - extern int gfx_i2c_type; + extern int gfx_i2c_type; #define GFX_I2C_TYPE_ACCESS 0x0001 #define GFX_I2C_TYPE_GPIO 0x0002 /* GLOBAL CPU INFORMATION */ - extern unsigned long gfx_cpu_version; - extern unsigned long gfx_cpu_frequency; - extern unsigned long gfx_vid_version; - extern ChipType gfx_chip_revision; + extern unsigned long gfx_cpu_version; + extern unsigned long gfx_cpu_frequency; + extern unsigned long gfx_vid_version; + extern ChipType gfx_chip_revision; /* ROUTINES IN GFX_INIT.C */ - unsigned long gfx_pci_config_read(unsigned long address); - void gfx_pci_config_write(unsigned long address, unsigned long data); - unsigned long gfx_get_core_freq(void); - unsigned long gfx_detect_cpu(void); - unsigned long gfx_detect_video(void); - unsigned long gfx_get_cpu_register_base(void); - unsigned long gfx_get_graphics_register_base(void); - unsigned long gfx_get_frame_buffer_base(void); - unsigned long gfx_get_frame_buffer_size(void); - unsigned long gfx_get_vid_register_base(void); - unsigned long gfx_get_vip_register_base(void); + unsigned long gfx_pci_config_read(unsigned long address); + void gfx_pci_config_write(unsigned long address, unsigned long data); + unsigned long gfx_get_core_freq(void); + unsigned long gfx_detect_cpu(void); + unsigned long gfx_detect_video(void); + unsigned long gfx_get_cpu_register_base(void); + unsigned long gfx_get_graphics_register_base(void); + unsigned long gfx_get_frame_buffer_base(void); + unsigned long gfx_get_frame_buffer_size(void); + unsigned long gfx_get_vid_register_base(void); + unsigned long gfx_get_vip_register_base(void); /* ROUTINES IN GFX_MSR.C */ - int gfx_msr_init(void); - DEV_STATUS gfx_id_msr_device(MSR * pDev, unsigned long address); - DEV_STATUS gfx_get_msr_dev_address(unsigned int device, - unsigned long *address); - DEV_STATUS gfx_get_glink_id_at_address(unsigned int *device, - unsigned long address); - DEV_STATUS gfx_msr_read(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue); - DEV_STATUS gfx_msr_write(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue); + int gfx_msr_init(void); + DEV_STATUS gfx_id_msr_device(MSR * pDev, unsigned long address); + DEV_STATUS gfx_get_msr_dev_address(unsigned int device, + unsigned long *address); + DEV_STATUS gfx_get_glink_id_at_address(unsigned int *device, + unsigned long address); + DEV_STATUS gfx_msr_read(unsigned int device, unsigned int msrRegister, + Q_WORD * msrValue); + DEV_STATUS gfx_msr_write(unsigned int device, unsigned int msrRegister, + Q_WORD * msrValue); /* ROUTINES IN GFX_DISP.C */ - int gfx_set_display_bpp(unsigned short bpp); - int gfx_is_display_mode_supported(int xres, int yres, int bpp, int hz); - int gfx_set_display_mode(int xres, int yres, int bpp, int hz); - int gfx_set_display_timings(unsigned short bpp, unsigned short flags, - unsigned short hactive, - unsigned short hblank_start, - unsigned short hsync_start, - unsigned short hsync_end, - unsigned short hblank_end, - unsigned short htotal, unsigned short vactive, - unsigned short vblank_start, - unsigned short vsync_start, - unsigned short vsync_end, - unsigned short vblank_end, - unsigned short vtotal, - unsigned long frequency); - int gfx_set_vtotal(unsigned short vtotal); - void gfx_set_display_pitch(unsigned short pitch); - void gfx_set_display_offset(unsigned long offset); - int gfx_set_display_palette_entry(unsigned long index, - unsigned long palette); - int gfx_set_display_palette(unsigned long *palette); - void gfx_video_shutdown(void); - void gfx_set_clock_frequency(unsigned long frequency); - int gfx_set_crt_enable(int enable); - void gfx_set_cursor_enable(int enable); - void gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor); - void gfx_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, - unsigned short yhotspot); - void gfx_set_cursor_shape32(unsigned long memoffset, - unsigned long *andmask, - unsigned long *xormask); - void gfx_set_cursor_shape64(unsigned long memoffset, - unsigned long *andmask, - unsigned long *xormask); - void gfx_set_icon_enable(int enable); - void gfx_set_icon_colors(unsigned long color0, unsigned long color1, - unsigned long color2); - void gfx_set_icon_position(unsigned long memoffset, unsigned short xpos); - void gfx_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask, unsigned int lines); - - int gfx_set_compression_enable(int enable); - int gfx_set_compression_offset(unsigned long offset); - int gfx_set_compression_pitch(unsigned short pitch); - int gfx_set_compression_size(unsigned short size); - void gfx_set_display_priority_high(int enable); - int gfx_test_timing_active(void); - int gfx_test_vertical_active(void); - int gfx_wait_vertical_blank(void); - void gfx_delay_milliseconds(unsigned long milliseconds); - void gfx_delay_microseconds(unsigned long microseconds); - void gfx_enable_panning(int x, int y); - int gfx_set_fixed_timings(int panelResX, int panelResY, - unsigned short width, unsigned short height, - unsigned short bpp); - int gfx_set_panel_present(int panelResX, int panelResY, - unsigned short width, unsigned short height, - unsigned short bpp); - void gfx_reset_timing_lock(void); + int gfx_set_display_bpp(unsigned short bpp); + int gfx_is_display_mode_supported(int xres, int yres, int bpp, int hz); + int gfx_set_display_mode(int xres, int yres, int bpp, int hz); + int gfx_set_display_timings(unsigned short bpp, unsigned short flags, + unsigned short hactive, + unsigned short hblank_start, + unsigned short hsync_start, + unsigned short hsync_end, + unsigned short hblank_end, + unsigned short htotal, unsigned short vactive, + unsigned short vblank_start, + unsigned short vsync_start, + unsigned short vsync_end, + unsigned short vblank_end, + unsigned short vtotal, unsigned long frequency); + int gfx_set_vtotal(unsigned short vtotal); + void gfx_set_display_pitch(unsigned short pitch); + void gfx_set_display_offset(unsigned long offset); + int gfx_set_display_palette_entry(unsigned long index, + unsigned long palette); + int gfx_set_display_palette(unsigned long *palette); + void gfx_video_shutdown(void); + void gfx_set_clock_frequency(unsigned long frequency); + int gfx_set_crt_enable(int enable); + void gfx_set_cursor_enable(int enable); + void gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor); + void gfx_set_cursor_position(unsigned long memoffset, + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, + unsigned short yhotspot); + void gfx_set_cursor_shape32(unsigned long memoffset, + unsigned long *andmask, unsigned long *xormask); + void gfx_set_cursor_shape64(unsigned long memoffset, + unsigned long *andmask, unsigned long *xormask); + void gfx_set_icon_enable(int enable); + void gfx_set_icon_colors(unsigned long color0, unsigned long color1, + unsigned long color2); + void gfx_set_icon_position(unsigned long memoffset, unsigned short xpos); + void gfx_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, + unsigned long *xormask, unsigned int lines); + + int gfx_set_compression_enable(int enable); + int gfx_set_compression_offset(unsigned long offset); + int gfx_set_compression_pitch(unsigned short pitch); + int gfx_set_compression_size(unsigned short size); + void gfx_set_display_priority_high(int enable); + int gfx_test_timing_active(void); + int gfx_test_vertical_active(void); + int gfx_wait_vertical_blank(void); + void gfx_delay_milliseconds(unsigned long milliseconds); + void gfx_delay_microseconds(unsigned long microseconds); + void gfx_enable_panning(int x, int y); + int gfx_set_fixed_timings(int panelResX, int panelResY, + unsigned short width, unsigned short height, + unsigned short bpp); + int gfx_set_panel_present(int panelResX, int panelResY, + unsigned short width, unsigned short height, + unsigned short bpp); + void gfx_reset_timing_lock(void); /* "READ" ROUTINES IN GFX_DISP.C */ - int gfx_get_display_details(unsigned int mode, int *xres, int *yres, - int *hz); - unsigned short gfx_get_display_pitch(void); - int gfx_get_vsa2_softvga_enable(void); - int gfx_get_sync_polarities(void); - unsigned long gfx_get_clock_frequency(void); - unsigned long gfx_get_max_supported_pixel_clock(void); - int gfx_mode_frequency_supported(int xres, int yres, int bpp, - unsigned long frequency); - int gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, - int *hz, unsigned long frequency); - int gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, - unsigned long frequency); - int gfx_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, - int *frequency); - int gfx_get_display_mode_count(void); - int gfx_get_display_mode(int *xres, int *yres, int *bpp, int *hz); - unsigned long gfx_get_frame_buffer_line_size(void); - unsigned short gfx_get_hactive(void); - unsigned short gfx_get_hblank_start(void); - unsigned short gfx_get_hsync_start(void); - unsigned short gfx_get_hsync_end(void); - unsigned short gfx_get_hblank_end(void); - unsigned short gfx_get_htotal(void); - unsigned short gfx_get_vactive(void); - unsigned short gfx_get_vline(void); - unsigned short gfx_get_vblank_start(void); - unsigned short gfx_get_vsync_start(void); - unsigned short gfx_get_vsync_end(void); - unsigned short gfx_get_vblank_end(void); - unsigned short gfx_get_vtotal(void); - unsigned short gfx_get_display_bpp(void); - unsigned long gfx_get_display_offset(void); - int gfx_get_display_palette_entry(unsigned long index, - unsigned long *palette); - void gfx_get_display_palette(unsigned long *palette); - unsigned long gfx_get_cursor_enable(void); - unsigned long gfx_get_cursor_offset(void); - unsigned long gfx_get_cursor_position(void); - unsigned long gfx_get_cursor_clip(void); - unsigned long gfx_get_cursor_color(int color); - unsigned long gfx_get_icon_enable(void); - unsigned long gfx_get_icon_offset(void); - unsigned long gfx_get_icon_position(void); - unsigned long gfx_get_icon_color(int color); - int gfx_get_compression_enable(void); - unsigned long gfx_get_compression_offset(void); - unsigned short gfx_get_compression_pitch(void); - unsigned short gfx_get_compression_size(void); - int gfx_get_display_priority_high(void); - int gfx_get_valid_bit(int line); + int gfx_get_display_details(unsigned int mode, int *xres, int *yres, + int *hz); + unsigned short gfx_get_display_pitch(void); + int gfx_get_vsa2_softvga_enable(void); + int gfx_get_sync_polarities(void); + unsigned long gfx_get_clock_frequency(void); + unsigned long gfx_get_max_supported_pixel_clock(void); + int gfx_mode_frequency_supported(int xres, int yres, int bpp, + unsigned long frequency); + int gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, + int *hz, unsigned long frequency); + int gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz, + unsigned long frequency); + int gfx_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz, + int *frequency); + int gfx_get_display_mode_count(void); + int gfx_get_display_mode(int *xres, int *yres, int *bpp, int *hz); + unsigned long gfx_get_frame_buffer_line_size(void); + unsigned short gfx_get_hactive(void); + unsigned short gfx_get_hblank_start(void); + unsigned short gfx_get_hsync_start(void); + unsigned short gfx_get_hsync_end(void); + unsigned short gfx_get_hblank_end(void); + unsigned short gfx_get_htotal(void); + unsigned short gfx_get_vactive(void); + unsigned short gfx_get_vline(void); + unsigned short gfx_get_vblank_start(void); + unsigned short gfx_get_vsync_start(void); + unsigned short gfx_get_vsync_end(void); + unsigned short gfx_get_vblank_end(void); + unsigned short gfx_get_vtotal(void); + unsigned short gfx_get_display_bpp(void); + unsigned long gfx_get_display_offset(void); + int gfx_get_display_palette_entry(unsigned long index, + unsigned long *palette); + void gfx_get_display_palette(unsigned long *palette); + unsigned long gfx_get_cursor_enable(void); + unsigned long gfx_get_cursor_offset(void); + unsigned long gfx_get_cursor_position(void); + unsigned long gfx_get_cursor_clip(void); + unsigned long gfx_get_cursor_color(int color); + unsigned long gfx_get_icon_enable(void); + unsigned long gfx_get_icon_offset(void); + unsigned long gfx_get_icon_position(void); + unsigned long gfx_get_icon_color(int color); + int gfx_get_compression_enable(void); + unsigned long gfx_get_compression_offset(void); + unsigned short gfx_get_compression_pitch(void); + unsigned short gfx_get_compression_size(void); + int gfx_get_display_priority_high(void); + int gfx_get_valid_bit(int line); /* ROUTINES IN GFX_RNDR.C */ - void gfx_set_bpp(unsigned short bpp); - void gfx_set_solid_pattern(unsigned long color); - void gfx_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparency); - void gfx_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned char transparency); - void gfx_load_color_pattern_line(short y, unsigned long *pattern_8x8); - void gfx_set_solid_source(unsigned long color); - void gfx_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned short transparent); - void gfx_set_pattern_flags(unsigned short flags); - void gfx_set_raster_operation(unsigned char rop); - void gfx_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height); - void gfx_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long *pattern); - void gfx_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height); - void gfx_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color); - void gfx_color_bitmap_to_screen_blt(unsigned short srcx, - unsigned short srcy, - unsigned short dstx, - unsigned short dsty, - unsigned short width, - unsigned short height, - unsigned char *data, long pitch); - void gfx_color_bitmap_to_screen_xblt(unsigned short srcx, - unsigned short srcy, - unsigned short dstx, - unsigned short dsty, - unsigned short width, - unsigned short height, - unsigned char *data, long pitch, - unsigned long color); - void gfx_mono_bitmap_to_screen_blt(unsigned short srcx, - unsigned short srcy, - unsigned short dstx, - unsigned short dsty, - unsigned short width, - unsigned short height, - unsigned char *data, short pitch); - void gfx_text_blt(unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data); - void gfx_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags); - void gfx_wait_until_idle(void); - int gfx_test_blt_pending(void); + void gfx_set_bpp(unsigned short bpp); + void gfx_set_solid_pattern(unsigned long color); + void gfx_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, + unsigned long data0, unsigned long data1, + unsigned char transparency); + void gfx_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, + unsigned long data0, unsigned long data1, + unsigned long data2, unsigned long data3, + unsigned char transparency); + void gfx_load_color_pattern_line(short y, unsigned long *pattern_8x8); + void gfx_set_solid_source(unsigned long color); + void gfx_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, + unsigned short transparent); + void gfx_set_pattern_flags(unsigned short flags); + void gfx_set_raster_operation(unsigned char rop); + void gfx_pattern_fill(unsigned short x, unsigned short y, + unsigned short width, unsigned short height); + void gfx_color_pattern_fill(unsigned short x, unsigned short y, + unsigned short width, unsigned short height, + unsigned long *pattern); + void gfx_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height); + void gfx_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color); + void gfx_color_bitmap_to_screen_blt(unsigned short srcx, + unsigned short srcy, + unsigned short dstx, + unsigned short dsty, + unsigned short width, + unsigned short height, + unsigned char *data, long pitch); + void gfx_color_bitmap_to_screen_xblt(unsigned short srcx, + unsigned short srcy, + unsigned short dstx, + unsigned short dsty, + unsigned short width, + unsigned short height, + unsigned char *data, long pitch, + unsigned long color); + void gfx_mono_bitmap_to_screen_blt(unsigned short srcx, + unsigned short srcy, + unsigned short dstx, + unsigned short dsty, + unsigned short width, + unsigned short height, + unsigned char *data, short pitch); + void gfx_text_blt(unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data); + void gfx_bresenham_line(unsigned short x, unsigned short y, + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags); + void gfx_wait_until_idle(void); + int gfx_test_blt_pending(void); /* SECOND GENERATION RENDERING ROUTINES */ - void gfx2_set_source_stride(unsigned short stride); - void gfx2_set_destination_stride(unsigned short stride); - void gfx2_set_pattern_origin(int x, int y); - void gfx2_set_source_transparency(unsigned long color, unsigned long mask); - void gfx2_set_alpha_mode(int mode); - void gfx2_set_alpha_value(unsigned char value); - void gfx2_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height); - void gfx2_color_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height, - unsigned long *pattern); - void gfx2_screen_to_screen_blt(unsigned long srcoffset, - unsigned long dstoffset, - unsigned short width, unsigned short height, - int flags); - void gfx2_mono_expand_blt(unsigned long srcbase, unsigned short srcx, - unsigned short srcy, unsigned long dstoffset, - unsigned short width, unsigned short height, - int byte_packed); - void gfx2_color_bitmap_to_screen_blt(unsigned short srcx, - unsigned short srcy, - unsigned long dstoffset, - unsigned short width, - unsigned short height, - unsigned char *data, short pitch); - void gfx2_mono_bitmap_to_screen_blt(unsigned short srcx, - unsigned short srcy, - unsigned long dstoffset, - unsigned short width, - unsigned short height, - unsigned char *data, short pitch); - void gfx2_text_blt(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data); - void gfx2_bresenham_line(unsigned long dstoffset, unsigned short length, - unsigned short initerr, unsigned short axialerr, - unsigned short diagerr, unsigned short flags); - void gfx2_sync_to_vblank(void); + void gfx2_set_source_stride(unsigned short stride); + void gfx2_set_destination_stride(unsigned short stride); + void gfx2_set_pattern_origin(int x, int y); + void gfx2_set_source_transparency(unsigned long color, unsigned long mask); + void gfx2_set_alpha_mode(int mode); + void gfx2_set_alpha_value(unsigned char value); + void gfx2_pattern_fill(unsigned long dstoffset, unsigned short width, + unsigned short height); + void gfx2_color_pattern_fill(unsigned long dstoffset, unsigned short width, + unsigned short height, unsigned long *pattern); + void gfx2_screen_to_screen_blt(unsigned long srcoffset, + unsigned long dstoffset, + unsigned short width, unsigned short height, + int flags); + void gfx2_mono_expand_blt(unsigned long srcbase, unsigned short srcx, + unsigned short srcy, unsigned long dstoffset, + unsigned short width, unsigned short height, + int byte_packed); + void gfx2_color_bitmap_to_screen_blt(unsigned short srcx, + unsigned short srcy, + unsigned long dstoffset, + unsigned short width, + unsigned short height, + unsigned char *data, short pitch); + void gfx2_mono_bitmap_to_screen_blt(unsigned short srcx, + unsigned short srcy, + unsigned long dstoffset, + unsigned short width, + unsigned short height, + unsigned char *data, short pitch); + void gfx2_text_blt(unsigned long dstoffset, unsigned short width, + unsigned short height, unsigned char *data); + void gfx2_bresenham_line(unsigned long dstoffset, unsigned short length, + unsigned short initerr, unsigned short axialerr, + unsigned short diagerr, unsigned short flags); + void gfx2_sync_to_vblank(void); /* ROUTINES IN GFX_VID.C */ - int gfx_set_video_enable(int enable); - int gfx_set_video_format(unsigned long format); - int gfx_set_video_size(unsigned short width, unsigned short height); - int gfx_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch); - int gfx_set_video_offset(unsigned long offset); - int gfx_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset, - unsigned long voffset); - int gfx_set_video_window(short x, short y, unsigned short w, - unsigned short h); - int gfx_set_video_left_crop(unsigned short x); - int gfx_set_video_upscale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); - int gfx_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); - int gfx_set_video_vertical_downscale(unsigned short srch, - unsigned short dsth); - void gfx_set_video_vertical_downscale_enable(int enable); - int gfx_set_video_downscale_config(unsigned short type, unsigned short m); - int gfx_set_video_color_key(unsigned long key, unsigned long mask, - int bluescreen); - int gfx_set_video_filter(int xfilter, int yfilter); - int gfx_set_video_palette(unsigned long *palette); - int gfx_set_video_palette_entry(unsigned long index, unsigned long color); - int gfx_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4); - int gfx_set_video_downscale_enable(int enable); - int gfx_set_video_source(VideoSourceType source); - int gfx_set_vbi_source(VbiSourceType source); - int gfx_set_vbi_lines(unsigned long even, unsigned long odd); - int gfx_set_vbi_total(unsigned long even, unsigned long odd); - int gfx_set_video_interlaced(int enable); - int gfx_set_color_space_YUV(int enable); - int gfx_set_vertical_scaler_offset(char offset); - int gfx_set_top_line_in_odd(int enable); - int gfx_set_genlock_delay(unsigned long delay); - int gfx_set_genlock_enable(int flags); - int gfx_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, - unsigned long color1, unsigned long color2); - int gfx_set_video_cursor_enable(int enable); - int gfx_set_video_request(short x, short y); - - int gfx_select_alpha_region(int region); - int gfx_set_alpha_enable(int enable); - int gfx_set_alpha_window(short x, short y, - unsigned short width, unsigned short height); - int gfx_set_alpha_value(unsigned char alpha, char delta); - int gfx_set_alpha_priority(int priority); - int gfx_set_alpha_color(unsigned long color); - int gfx_set_alpha_color_enable(int enable); - int gfx_set_no_ck_outside_alpha(int enable); - int gfx_disable_softvga(void); - int gfx_enable_softvga(void); - int gfx_set_macrovision_enable(int enable); + int gfx_set_video_enable(int enable); + int gfx_set_video_format(unsigned long format); + int gfx_set_video_size(unsigned short width, unsigned short height); + int gfx_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch); + int gfx_set_video_offset(unsigned long offset); + int gfx_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset, + unsigned long voffset); + int gfx_set_video_window(short x, short y, unsigned short w, + unsigned short h); + int gfx_set_video_left_crop(unsigned short x); + int gfx_set_video_upscale(unsigned short srcw, unsigned short srch, + unsigned short dstw, unsigned short dsth); + int gfx_set_video_scale(unsigned short srcw, unsigned short srch, + unsigned short dstw, unsigned short dsth); + int gfx_set_video_vertical_downscale(unsigned short srch, + unsigned short dsth); + void gfx_set_video_vertical_downscale_enable(int enable); + int gfx_set_video_downscale_config(unsigned short type, unsigned short m); + int gfx_set_video_color_key(unsigned long key, unsigned long mask, + int bluescreen); + int gfx_set_video_filter(int xfilter, int yfilter); + int gfx_set_video_palette(unsigned long *palette); + int gfx_set_video_palette_entry(unsigned long index, unsigned long color); + int gfx_set_video_downscale_coefficients(unsigned short coef1, + unsigned short coef2, + unsigned short coef3, + unsigned short coef4); + int gfx_set_video_downscale_enable(int enable); + int gfx_set_video_source(VideoSourceType source); + int gfx_set_vbi_source(VbiSourceType source); + int gfx_set_vbi_lines(unsigned long even, unsigned long odd); + int gfx_set_vbi_total(unsigned long even, unsigned long odd); + int gfx_set_video_interlaced(int enable); + int gfx_set_color_space_YUV(int enable); + int gfx_set_vertical_scaler_offset(char offset); + int gfx_set_top_line_in_odd(int enable); + int gfx_set_genlock_delay(unsigned long delay); + int gfx_set_genlock_enable(int flags); + int gfx_set_video_cursor(unsigned long key, unsigned long mask, + unsigned short select_color2, + unsigned long color1, unsigned long color2); + int gfx_set_video_cursor_enable(int enable); + int gfx_set_video_request(short x, short y); + + int gfx_select_alpha_region(int region); + int gfx_set_alpha_enable(int enable); + int gfx_set_alpha_window(short x, short y, + unsigned short width, unsigned short height); + int gfx_set_alpha_value(unsigned char alpha, char delta); + int gfx_set_alpha_priority(int priority); + int gfx_set_alpha_color(unsigned long color); + int gfx_set_alpha_color_enable(int enable); + int gfx_set_no_ck_outside_alpha(int enable); + int gfx_disable_softvga(void); + int gfx_enable_softvga(void); + int gfx_set_macrovision_enable(int enable); /* READ ROUTINES IN GFX_VID.C */ - int gfx_get_video_enable(void); - int gfx_get_video_format(void); - unsigned long gfx_get_video_src_size(void); - unsigned long gfx_get_video_line_size(void); - unsigned long gfx_get_video_xclip(void); - unsigned long gfx_get_video_offset(void); - void gfx_get_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset); - void gfx_get_video_yuv_pitch(unsigned long *ypitch, - unsigned long *uvpitch); - unsigned long gfx_get_video_upscale(void); - unsigned long gfx_get_video_scale(void); - unsigned long gfx_get_video_downscale_delta(void); - int gfx_get_video_vertical_downscale_enable(void); - int gfx_get_video_downscale_config(unsigned short *type, - unsigned short *m); - void gfx_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4); - void gfx_get_video_downscale_enable(int *enable); - unsigned long gfx_get_video_dst_size(void); - unsigned long gfx_get_video_position(void); - unsigned long gfx_get_video_color_key(void); - unsigned long gfx_get_video_color_key_mask(void); - int gfx_get_video_palette_entry(unsigned long index, - unsigned long *palette); - int gfx_get_video_color_key_src(void); - int gfx_get_video_filter(void); - int gfx_get_video_request(short *x, short *y); - int gfx_get_video_source(VideoSourceType * source); - int gfx_get_vbi_source(VbiSourceType * source); - unsigned long gfx_get_vbi_lines(int odd); - unsigned long gfx_get_vbi_total(int odd); - int gfx_get_video_interlaced(void); - int gfx_get_color_space_YUV(void); - int gfx_get_vertical_scaler_offset(char *offset); - unsigned long gfx_get_genlock_delay(void); - int gfx_get_genlock_enable(void); - int gfx_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, - unsigned long *color1, unsigned short *color2); - unsigned long gfx_read_crc(void); - unsigned long gfx_read_crc32(void); - unsigned long gfx_read_window_crc(int source, unsigned short x, - unsigned short y, unsigned short width, - unsigned short height, int crc32); - int gfx_get_macrovision_enable(void); - - void gfx_get_alpha_enable(int *enable); - void gfx_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height); - void gfx_get_alpha_value(unsigned char *alpha, char *delta); - void gfx_get_alpha_priority(int *priority); - void gfx_get_alpha_color(unsigned long *color); + int gfx_get_video_enable(void); + int gfx_get_video_format(void); + unsigned long gfx_get_video_src_size(void); + unsigned long gfx_get_video_line_size(void); + unsigned long gfx_get_video_xclip(void); + unsigned long gfx_get_video_offset(void); + void gfx_get_video_yuv_offsets(unsigned long *yoffset, + unsigned long *uoffset, + unsigned long *voffset); + void gfx_get_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch); + unsigned long gfx_get_video_upscale(void); + unsigned long gfx_get_video_scale(void); + unsigned long gfx_get_video_downscale_delta(void); + int gfx_get_video_vertical_downscale_enable(void); + int gfx_get_video_downscale_config(unsigned short *type, unsigned short *m); + void gfx_get_video_downscale_coefficients(unsigned short *coef1, + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4); + void gfx_get_video_downscale_enable(int *enable); + unsigned long gfx_get_video_dst_size(void); + unsigned long gfx_get_video_position(void); + unsigned long gfx_get_video_color_key(void); + unsigned long gfx_get_video_color_key_mask(void); + int gfx_get_video_palette_entry(unsigned long index, + unsigned long *palette); + int gfx_get_video_color_key_src(void); + int gfx_get_video_filter(void); + int gfx_get_video_request(short *x, short *y); + int gfx_get_video_source(VideoSourceType * source); + int gfx_get_vbi_source(VbiSourceType * source); + unsigned long gfx_get_vbi_lines(int odd); + unsigned long gfx_get_vbi_total(int odd); + int gfx_get_video_interlaced(void); + int gfx_get_color_space_YUV(void); + int gfx_get_vertical_scaler_offset(char *offset); + unsigned long gfx_get_genlock_delay(void); + int gfx_get_genlock_enable(void); + int gfx_get_video_cursor(unsigned long *key, unsigned long *mask, + unsigned short *select_color2, + unsigned long *color1, unsigned short *color2); + unsigned long gfx_read_crc(void); + unsigned long gfx_read_crc32(void); + unsigned long gfx_read_window_crc(int source, unsigned short x, + unsigned short y, unsigned short width, + unsigned short height, int crc32); + int gfx_get_macrovision_enable(void); + + void gfx_get_alpha_enable(int *enable); + void gfx_get_alpha_size(unsigned short *x, unsigned short *y, + unsigned short *width, unsigned short *height); + void gfx_get_alpha_value(unsigned char *alpha, char *delta); + void gfx_get_alpha_priority(int *priority); + void gfx_get_alpha_color(unsigned long *color); /* ROUTINES IN GFX_VIP.C */ - int gfx_set_vip_enable(int enable); - int gfx_set_vip_capture_run_mode(int mode); - int gfx_set_vip_base(unsigned long even, unsigned long odd); - int gfx_set_vip_pitch(unsigned long pitch); - int gfx_set_vip_mode(int mode); - int gfx_set_vbi_enable(int enable); - int gfx_set_vbi_mode(int mode); - int gfx_set_vbi_base(unsigned long even, unsigned long odd); - int gfx_set_vbi_pitch(unsigned long pitch); - int gfx_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines); - int gfx_set_vbi_interrupt(int enable); - int gfx_set_vip_bus_request_threshold_high(int enable); - int gfx_set_vip_last_line(int last_line); - int gfx_test_vip_odd_field(void); - int gfx_test_vip_bases_updated(void); - int gfx_test_vip_fifo_overflow(void); - int gfx_get_vip_line(void); + int gfx_set_vip_enable(int enable); + int gfx_set_vip_capture_run_mode(int mode); + int gfx_set_vip_base(unsigned long even, unsigned long odd); + int gfx_set_vip_pitch(unsigned long pitch); + int gfx_set_vip_mode(int mode); + int gfx_set_vbi_enable(int enable); + int gfx_set_vbi_mode(int mode); + int gfx_set_vbi_base(unsigned long even, unsigned long odd); + int gfx_set_vbi_pitch(unsigned long pitch); + int gfx_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines); + int gfx_set_vbi_interrupt(int enable); + int gfx_set_vip_bus_request_threshold_high(int enable); + int gfx_set_vip_last_line(int last_line); + int gfx_test_vip_odd_field(void); + int gfx_test_vip_bases_updated(void); + int gfx_test_vip_fifo_overflow(void); + int gfx_get_vip_line(void); /* READ ROUTINES IN GFX_VIP.C */ - int gfx_get_vip_enable(void); - unsigned long gfx_get_vip_base(int odd); - unsigned long gfx_get_vip_pitch(void); - int gfx_get_vip_mode(void); - int gfx_get_vbi_enable(void); - int gfx_get_vbi_mode(void); - unsigned long gfx_get_vbi_base(int odd); - unsigned long gfx_get_vbi_pitch(void); - unsigned long gfx_get_vbi_direct(int odd); - int gfx_get_vbi_interrupt(void); - int gfx_get_vip_bus_request_threshold_high(void); + int gfx_get_vip_enable(void); + unsigned long gfx_get_vip_base(int odd); + unsigned long gfx_get_vip_pitch(void); + int gfx_get_vip_mode(void); + int gfx_get_vbi_enable(void); + int gfx_get_vbi_mode(void); + unsigned long gfx_get_vbi_base(int odd); + unsigned long gfx_get_vbi_pitch(void); + unsigned long gfx_get_vbi_direct(int odd); + int gfx_get_vbi_interrupt(void); + int gfx_get_vip_bus_request_threshold_high(void); /* ROUTINES IN GFX_DCDR.C */ - int gfx_set_decoder_defaults(void); - int gfx_set_decoder_analog_input(unsigned char input); - int gfx_set_decoder_brightness(unsigned char brightness); - int gfx_set_decoder_contrast(unsigned char contrast); - int gfx_set_decoder_hue(char hue); - int gfx_set_decoder_saturation(unsigned char saturation); - int gfx_set_decoder_input_offset(unsigned short x, unsigned short y); - int gfx_set_decoder_input_size(unsigned short width, - unsigned short height); - int gfx_set_decoder_output_size(unsigned short width, - unsigned short height); - int gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); - int gfx_set_decoder_vbi_format(int start, int end, int format); - int gfx_set_decoder_vbi_enable(int enable); - int gfx_set_decoder_vbi_upscale(void); - int gfx_set_decoder_TV_standard(TVStandardType TVStandard); - int gfx_set_decoder_luminance_filter(unsigned char lufi); - int gfx_decoder_software_reset(void); - int gfx_decoder_detect_macrovision(void); - int gfx_decoder_detect_video(void); + int gfx_set_decoder_defaults(void); + int gfx_set_decoder_analog_input(unsigned char input); + int gfx_set_decoder_brightness(unsigned char brightness); + int gfx_set_decoder_contrast(unsigned char contrast); + int gfx_set_decoder_hue(char hue); + int gfx_set_decoder_saturation(unsigned char saturation); + int gfx_set_decoder_input_offset(unsigned short x, unsigned short y); + int gfx_set_decoder_input_size(unsigned short width, unsigned short height); + int gfx_set_decoder_output_size(unsigned short width, + unsigned short height); + int gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, + unsigned short dstw, unsigned short dsth); + int gfx_set_decoder_vbi_format(int start, int end, int format); + int gfx_set_decoder_vbi_enable(int enable); + int gfx_set_decoder_vbi_upscale(void); + int gfx_set_decoder_TV_standard(TVStandardType TVStandard); + int gfx_set_decoder_luminance_filter(unsigned char lufi); + int gfx_decoder_software_reset(void); + int gfx_decoder_detect_macrovision(void); + int gfx_decoder_detect_video(void); /* READ ROUTINES IN GFX_DCDR.C */ - unsigned char gfx_get_decoder_brightness(void); - unsigned char gfx_get_decoder_contrast(void); - char gfx_get_decoder_hue(void); - unsigned char gfx_get_decoder_saturation(void); - unsigned long gfx_get_decoder_input_offset(void); - unsigned long gfx_get_decoder_input_size(void); - unsigned long gfx_get_decoder_output_size(void); - int gfx_get_decoder_vbi_format(int line); + unsigned char gfx_get_decoder_brightness(void); + unsigned char gfx_get_decoder_contrast(void); + char gfx_get_decoder_hue(void); + unsigned char gfx_get_decoder_saturation(void); + unsigned long gfx_get_decoder_input_offset(void); + unsigned long gfx_get_decoder_input_size(void); + unsigned long gfx_get_decoder_output_size(void); + int gfx_get_decoder_vbi_format(int line); /* ROUTINES IN GFX_I2C.C */ - int gfx_i2c_reset(unsigned char busnum, short adr, char freq); - int gfx_i2c_write(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, - unsigned char *data); - int gfx_i2c_read(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, - unsigned char *data); - int gfx_i2c_select_gpio(int clock, int data); - int gfx_i2c_init(void); - void gfx_i2c_cleanup(void); + int gfx_i2c_reset(unsigned char busnum, short adr, char freq); + int gfx_i2c_write(unsigned char busnum, unsigned char chipadr, + unsigned char subadr, unsigned char bytes, + unsigned char *data); + int gfx_i2c_read(unsigned char busnum, unsigned char chipadr, + unsigned char subadr, unsigned char bytes, + unsigned char *data); + int gfx_i2c_select_gpio(int clock, int data); + int gfx_i2c_init(void); + void gfx_i2c_cleanup(void); /* ROUTINES IN GFX_TV.C */ - int gfx_set_tv_format(TVStandardType format, GfxOnTVType resolution); - int gfx_set_tv_output(int output); - int gfx_set_tv_enable(int enable); - int gfx_set_tv_flicker_filter(int ff); - int gfx_set_tv_sub_carrier_reset(int screset); - int gfx_set_tv_vphase(int vphase); - int gfx_set_tv_YC_delay(int delay); - int gfx_set_tvenc_reset_interval(int interval); - int gfx_set_tv_cc_enable(int enable); - int gfx_set_tv_cc_data(unsigned char data1, unsigned char data2); - int gfx_set_tv_display(int width, int height); - int gfx_test_tvout_odd_field(void); - int gfx_test_tvenc_odd_field(void); - int gfx_set_tv_field_status_invert(int enable); - int gfx_get_tv_vphase(void); - int gfx_get_tv_enable(unsigned int *p_on); - int gfx_get_tv_output(void); - int gfx_get_tv_mode_count(TVStandardType format); - int gfx_get_tv_display_mode(int *width, int *height, int *bpp, int *hz); - int gfx_get_tv_display_mode_frequency(unsigned short width, - unsigned short height, - TVStandardType format, - int *frequency); - int gfx_is_tv_display_mode_supported(unsigned short width, - unsigned short height, - TVStandardType format); - - int gfx_get_tv_standard(unsigned long *p_standard); - int gfx_get_available_tv_standards(unsigned long *p_standards); - int gfx_set_tv_standard(unsigned long standard); - int gfx_get_tv_vga_mode(unsigned long *p_vga_mode); - int gfx_get_available_tv_vga_modes(unsigned long *p_vga_modes); - int gfx_set_tv_vga_mode(unsigned long vga_mode); - int gfx_get_tvout_mode(unsigned long *p_tvout_mode); - int gfx_set_tvout_mode(unsigned long tvout_mode); - int gfx_get_sharpness(int *p_sharpness); - int gfx_set_sharpness(int sharpness); - int gfx_get_flicker_filter(int *p_flicker); - int gfx_set_flicker_filter(int flicker); - int gfx_get_overscan(int *p_x, int *p_y); - int gfx_set_overscan(int x, int y); - int gfx_get_position(int *p_x, int *p_y); - int gfx_set_position(int x, int y); - int gfx_get_color(int *p_color); - int gfx_set_color(int color); - int gfx_get_brightness(int *p_brightness); - int gfx_set_brightness(int brightness); - int gfx_get_contrast(int *p_contrast); - int gfx_set_contrast(int constrast); - int gfx_get_yc_filter(unsigned int *p_yc_filter); - int gfx_set_yc_filter(unsigned int yc_filter); - int gfx_get_aps_trigger_bits(unsigned int *p_trigger_bits); - int gfx_set_aps_trigger_bits(unsigned int trigger_bits); + int gfx_set_tv_format(TVStandardType format, GfxOnTVType resolution); + int gfx_set_tv_output(int output); + int gfx_set_tv_enable(int enable); + int gfx_set_tv_flicker_filter(int ff); + int gfx_set_tv_sub_carrier_reset(int screset); + int gfx_set_tv_vphase(int vphase); + int gfx_set_tv_YC_delay(int delay); + int gfx_set_tvenc_reset_interval(int interval); + int gfx_set_tv_cc_enable(int enable); + int gfx_set_tv_cc_data(unsigned char data1, unsigned char data2); + int gfx_set_tv_display(int width, int height); + int gfx_test_tvout_odd_field(void); + int gfx_test_tvenc_odd_field(void); + int gfx_set_tv_field_status_invert(int enable); + int gfx_get_tv_vphase(void); + int gfx_get_tv_enable(unsigned int *p_on); + int gfx_get_tv_output(void); + int gfx_get_tv_mode_count(TVStandardType format); + int gfx_get_tv_display_mode(int *width, int *height, int *bpp, int *hz); + int gfx_get_tv_display_mode_frequency(unsigned short width, + unsigned short height, + TVStandardType format, + int *frequency); + int gfx_is_tv_display_mode_supported(unsigned short width, + unsigned short height, + TVStandardType format); + + int gfx_get_tv_standard(unsigned long *p_standard); + int gfx_get_available_tv_standards(unsigned long *p_standards); + int gfx_set_tv_standard(unsigned long standard); + int gfx_get_tv_vga_mode(unsigned long *p_vga_mode); + int gfx_get_available_tv_vga_modes(unsigned long *p_vga_modes); + int gfx_set_tv_vga_mode(unsigned long vga_mode); + int gfx_get_tvout_mode(unsigned long *p_tvout_mode); + int gfx_set_tvout_mode(unsigned long tvout_mode); + int gfx_get_sharpness(int *p_sharpness); + int gfx_set_sharpness(int sharpness); + int gfx_get_flicker_filter(int *p_flicker); + int gfx_set_flicker_filter(int flicker); + int gfx_get_overscan(int *p_x, int *p_y); + int gfx_set_overscan(int x, int y); + int gfx_get_position(int *p_x, int *p_y); + int gfx_set_position(int x, int y); + int gfx_get_color(int *p_color); + int gfx_set_color(int color); + int gfx_get_brightness(int *p_brightness); + int gfx_set_brightness(int brightness); + int gfx_get_contrast(int *p_contrast); + int gfx_set_contrast(int constrast); + int gfx_get_yc_filter(unsigned int *p_yc_filter); + int gfx_set_yc_filter(unsigned int yc_filter); + int gfx_get_aps_trigger_bits(unsigned int *p_trigger_bits); + int gfx_set_aps_trigger_bits(unsigned int trigger_bits); /* ROUTINES IN GFX_VGA.C */ - int gfx_get_softvga_active(void); - int gfx_vga_test_pci(void); - unsigned char gfx_vga_get_pci_command(void); - int gfx_vga_set_pci_command(unsigned char command); - int gfx_vga_seq_reset(int reset); - int gfx_vga_set_graphics_bits(void); - int gfx_vga_mode(gfx_vga_struct * vga, int xres, int yres, int bpp, - int hz); - int gfx_vga_pitch(gfx_vga_struct * vga, unsigned short pitch); - int gfx_vga_save(gfx_vga_struct * vga, int flags); - int gfx_vga_restore(gfx_vga_struct * vga, int flags); - int gfx_vga_mode_switch(int active); - void gfx_vga_clear_extended(void); + int gfx_get_softvga_active(void); + int gfx_vga_test_pci(void); + unsigned char gfx_vga_get_pci_command(void); + int gfx_vga_set_pci_command(unsigned char command); + int gfx_vga_seq_reset(int reset); + int gfx_vga_set_graphics_bits(void); + int gfx_vga_mode(gfx_vga_struct * vga, int xres, int yres, int bpp, int hz); + int gfx_vga_pitch(gfx_vga_struct * vga, unsigned short pitch); + int gfx_vga_save(gfx_vga_struct * vga, int flags); + int gfx_vga_restore(gfx_vga_struct * vga, int flags); + int gfx_vga_mode_switch(int active); + void gfx_vga_clear_extended(void); /* CLOSE BRACKET FOR C++ COMPLILATION */ #ifdef __cplusplus } #endif - -#endif /* !_gfx_rtns_h */ - +#endif /* !_gfx_rtns_h */ /* END OF FILE */ - diff --git a/src/gfx/gfx_tv.c b/src/gfx/gfx_tv.c index 6cb825d..6296347 100644 --- a/src/gfx/gfx_tv.c +++ b/src/gfx/gfx_tv.c @@ -151,42 +151,42 @@ DISPLAYMODE TVTimings[] = { /* NTSC resolution */ - {0x3 | /* negative syncs */ - GFX_MODE_TV_NTSC, /* NTSC format */ - 640, 640, 656, 744, 792, 792, /* horizontal timings */ - 480, 480, 490, 492, 517, 525, /* vertical timings */ - 0x0018EC4D, /* freq = 24.923052 MHz */ - } - , + {0x3 | /* negative syncs */ + GFX_MODE_TV_NTSC, /* NTSC format */ + 640, 640, 656, 744, 792, 792, /* horizontal timings */ + 480, 480, 490, 492, 517, 525, /* vertical timings */ + 0x0018EC4D, /* freq = 24.923052 MHz */ + } + , /* PAL resolution */ - {0x3 | /* negative syncs */ - GFX_MODE_TV_PAL, /* PAL format */ - 768, 768, 800, 848, 864, 864, /* horizontal timings */ - 576, 576, 586, 588, 625, 625, /* vertical timings */ - 0x001B0000, /* freq = 27.00 MHz */ - } - , + {0x3 | /* negative syncs */ + GFX_MODE_TV_PAL, /* PAL format */ + 768, 768, 800, 848, 864, 864, /* horizontal timings */ + 576, 576, 586, 588, 625, 625, /* vertical timings */ + 0x001B0000, /* freq = 27.00 MHz */ + } + , /* NTSC resolution non-square pixels */ - {0x3 | /* negative syncs */ - GFX_MODE_TV_NTSC, /* NTSC format */ - 720, 720, 736, 752, 792, 792, /* horizontal timings */ - 480, 480, 490, 492, 517, 525, /* vertical timings */ - 0x0018EC4D, /* freq = 24.923052 MHz */ - } - , + {0x3 | /* negative syncs */ + GFX_MODE_TV_NTSC, /* NTSC format */ + 720, 720, 736, 752, 792, 792, /* horizontal timings */ + 480, 480, 490, 492, 517, 525, /* vertical timings */ + 0x0018EC4D, /* freq = 24.923052 MHz */ + } + , /* PAL resolution non-square pixels */ - {0x3 | /* negative syncs */ - GFX_MODE_TV_PAL, /* PAL format */ - 720, 720, 752, 816, 864, 864, /* horizontal timings */ - 576, 576, 586, 588, 625, 625, /* vertical timings */ - 0x001B0000, /* freq = 27.00 MHz */ - } + {0x3 | /* negative syncs */ + GFX_MODE_TV_PAL, /* PAL format */ + 720, 720, 752, 816, 864, 864, /* horizontal timings */ + 576, 576, 586, 588, 625, 625, /* vertical timings */ + 0x001B0000, /* freq = 27.00 MHz */ + } }; #define NUM_TV_MODES sizeof(TVTimings)/sizeof(DISPLAYMODE) @@ -215,17 +215,17 @@ DISPLAYMODE TVTimings[] = { int gfx_set_tv_format(TVStandardType format, GfxOnTVType resolution) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_format(format, resolution); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_format(format, resolution); #endif #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_tv_format(format, resolution); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_tv_format(format, resolution); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -235,17 +235,17 @@ gfx_set_tv_format(TVStandardType format, GfxOnTVType resolution) int gfx_set_tv_output(int output) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_output(output); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_output(output); #endif #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_tv_output(output); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_tv_output(output); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -255,17 +255,17 @@ gfx_set_tv_output(int output) int gfx_set_tv_enable(int enable) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_enable(enable); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_enable(enable); #endif #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_tv_enable(enable); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_tv_enable(enable); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -275,13 +275,13 @@ gfx_set_tv_enable(int enable) int gfx_set_tv_flicker_filter(int ff) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_flicker_filter(ff); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_flicker_filter(ff); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -291,13 +291,13 @@ gfx_set_tv_flicker_filter(int ff) int gfx_set_tv_sub_carrier_reset(int screset) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_sub_carrier_reset(screset); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_sub_carrier_reset(screset); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -307,13 +307,13 @@ gfx_set_tv_sub_carrier_reset(int screset) int gfx_set_tv_vphase(int vphase) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_vphase(vphase); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_vphase(vphase); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -323,13 +323,13 @@ gfx_set_tv_vphase(int vphase) int gfx_set_tv_YC_delay(int delay) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_YC_delay(delay); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_YC_delay(delay); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -339,13 +339,13 @@ gfx_set_tv_YC_delay(int delay) int gfx_set_tvenc_reset_interval(int interval) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tvenc_reset_interval(interval); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tvenc_reset_interval(interval); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -355,13 +355,13 @@ gfx_set_tvenc_reset_interval(int interval) int gfx_set_tv_cc_enable(int enable) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_cc_enable(enable); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_cc_enable(enable); #endif - return (retval); + return (retval); } /*----------------------------------------------------------------------------- @@ -374,13 +374,13 @@ gfx_set_tv_cc_enable(int enable) int gfx_set_tv_cc_data(unsigned char data1, unsigned char data2) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_cc_data(data1, data2); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_cc_data(data1, data2); #endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -392,13 +392,13 @@ gfx_set_tv_cc_data(unsigned char data1, unsigned char data2) int gfx_set_tv_display(int width, int height) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - status = sc1200_set_tv_display(width, height); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + status = sc1200_set_tv_display(width, height); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -408,13 +408,13 @@ gfx_set_tv_display(int width, int height) int gfx_test_tvout_odd_field(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - status = sc1200_test_tvout_odd_field(); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + status = sc1200_test_tvout_odd_field(); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -424,13 +424,13 @@ gfx_test_tvout_odd_field(void) int gfx_test_tvenc_odd_field(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - status = sc1200_test_tvenc_odd_field(); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + status = sc1200_test_tvenc_odd_field(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -440,13 +440,13 @@ gfx_test_tvenc_odd_field(void) int gfx_set_tv_field_status_invert(int enable) { - int retval = GFX_STATUS_UNSUPPORTED; + int retval = GFX_STATUS_UNSUPPORTED; #if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_set_tv_field_status_invert(enable); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_set_tv_field_status_invert(enable); #endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -456,13 +456,13 @@ gfx_set_tv_field_status_invert(int enable) int gfx_get_tv_vphase(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - status = sc1200_get_tv_vphase(); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + status = sc1200_get_tv_vphase(); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -472,17 +472,17 @@ gfx_get_tv_vphase(void) int gfx_get_tv_enable(unsigned int *p_on) { - int retval = -1; + int retval = -1; # if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_tv_enable(p_on); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_tv_enable(p_on); # endif # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_get_tv_enable(p_on); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_get_tv_enable(p_on); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -492,13 +492,13 @@ gfx_get_tv_enable(unsigned int *p_on) int gfx_get_tv_output() { - int retval = -1; + int retval = -1; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_get_tv_output(); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_get_tv_output(); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -508,13 +508,13 @@ gfx_get_tv_output() int gfx_get_tv_mode_count(TVStandardType format) { - int retval = -1; + int retval = -1; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_get_tv_mode_count(format); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_get_tv_mode_count(format); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -524,13 +524,13 @@ gfx_get_tv_mode_count(TVStandardType format) int gfx_get_tv_display_mode(int *width, int *height, int *bpp, int *hz) { - int retval = -1; + int retval = -1; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_get_tv_display_mode(width, height, bpp, hz); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_get_tv_display_mode(width, height, bpp, hz); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -539,17 +539,17 @@ gfx_get_tv_display_mode(int *width, int *height, int *bpp, int *hz) */ int gfx_get_tv_display_mode_frequency(unsigned short width, unsigned short height, - TVStandardType format, int *frequency) + TVStandardType format, int *frequency) { - int retval = -1; + int retval = -1; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = - sc1200_get_tv_display_mode_frequency(width, height, format, - frequency); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = + sc1200_get_tv_display_mode_frequency(width, height, format, + frequency); # endif - return (retval); + return (retval); } /*--------------------------------------------------------------------------- @@ -558,15 +558,15 @@ gfx_get_tv_display_mode_frequency(unsigned short width, unsigned short height, */ int gfx_is_tv_display_mode_supported(unsigned short width, unsigned short height, - TVStandardType format) + TVStandardType format) { - int retval = -1; + int retval = -1; # if GFX_TV_SC1200 - if (gfx_tv_type & GFX_TV_TYPE_SC1200) - retval = sc1200_is_tv_display_mode_supported(width, height, format); + if (gfx_tv_type & GFX_TV_TYPE_SC1200) + retval = sc1200_is_tv_display_mode_supported(width, height, format); # endif - return (retval); + return (retval); } /*------------------------------------------ @@ -584,37 +584,37 @@ gfx_is_tv_display_mode_supported(unsigned short width, unsigned short height, int gfx_get_tv_standard(unsigned long *p_standard) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_tv_standard(p_standard); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_tv_standard(p_standard); #endif - return (retval); + return (retval); } int gfx_get_available_tv_standards(unsigned long *p_standards) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_available_tv_standards(p_standards); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_available_tv_standards(p_standards); #endif - return (retval); + return (retval); } int gfx_set_tv_standard(unsigned long standard) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_tv_standard(standard); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_tv_standard(standard); #endif - return (retval); + return (retval); } /* @@ -626,37 +626,37 @@ gfx_set_tv_standard(unsigned long standard) int gfx_get_tv_vga_mode(unsigned long *p_vga_mode) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_tv_vga_mode(p_vga_mode); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_tv_vga_mode(p_vga_mode); #endif - return (retval); + return (retval); } int gfx_get_available_tv_vga_modes(unsigned long *p_vga_modes) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_available_tv_vga_modes(p_vga_modes); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_available_tv_vga_modes(p_vga_modes); #endif - return (retval); + return (retval); } int gfx_set_tv_vga_mode(unsigned long vga_mode) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_tv_vga_mode(vga_mode); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_tv_vga_mode(vga_mode); #endif - return (retval); + return (retval); } /* @@ -668,25 +668,25 @@ gfx_set_tv_vga_mode(unsigned long vga_mode) int gfx_get_tvout_mode(unsigned long *p_tvout_mode) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_tvout_mode(p_tvout_mode); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_tvout_mode(p_tvout_mode); #endif - return (retval); + return (retval); } int gfx_set_tvout_mode(unsigned long tvout_mode) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_tvout_mode(tvout_mode); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_tvout_mode(tvout_mode); #endif - return (retval); + return (retval); } /* @@ -697,25 +697,25 @@ gfx_set_tvout_mode(unsigned long tvout_mode) int gfx_get_sharpness(int *p_sharpness) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_sharpness(p_sharpness); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_sharpness(p_sharpness); #endif - return (retval); + return (retval); } int gfx_set_sharpness(int sharpness) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_sharpness(sharpness); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_sharpness(sharpness); #endif - return (retval); + return (retval); } /* @@ -727,25 +727,25 @@ gfx_set_sharpness(int sharpness) int gfx_get_flicker_filter(int *p_flicker) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_flicker_filter(p_flicker); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_flicker_filter(p_flicker); #endif - return (retval); + return (retval); } int gfx_set_flicker_filter(int flicker) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_flicker_filter(flicker); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_flicker_filter(flicker); #endif - return (retval); + return (retval); } /* @@ -757,50 +757,50 @@ gfx_set_flicker_filter(int flicker) int gfx_get_overscan(int *p_x, int *p_y) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_overscan(p_x, p_y); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_overscan(p_x, p_y); #endif - return (retval); + return (retval); } int gfx_set_overscan(int x, int y) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_overscan(x, y); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_overscan(x, y); #endif - return (retval); + return (retval); } int gfx_get_position(int *p_x, int *p_y) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_position(p_x, p_y); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_position(p_x, p_y); #endif - return (retval); + return (retval); } int gfx_set_position(int x, int y) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_position(x, y); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_position(x, y); #endif - return (retval); + return (retval); } /* @@ -812,73 +812,73 @@ gfx_set_position(int x, int y) int gfx_get_color(int *p_color) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_color(p_color); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_color(p_color); #endif - return (retval); + return (retval); } int gfx_set_color(int color) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_color(color); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_color(color); #endif - return (retval); + return (retval); } int gfx_get_brightness(int *p_brightness) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_brightness(p_brightness); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_brightness(p_brightness); #endif - return (retval); + return (retval); } int gfx_set_brightness(int brightness) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_brightness(brightness); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_brightness(brightness); #endif - return (retval); + return (retval); } int gfx_get_contrast(int *p_contrast) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_contrast(p_contrast); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_contrast(p_contrast); #endif - return (retval); + return (retval); } int gfx_set_contrast(int contrast) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_contrast(contrast); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_contrast(contrast); #endif - return (retval); + return (retval); } /* @@ -890,51 +890,51 @@ gfx_set_contrast(int contrast) int gfx_get_yc_filter(unsigned int *p_yc_filter) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_yc_filter(p_yc_filter); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_yc_filter(p_yc_filter); #endif - return (retval); + return (retval); } int gfx_set_yc_filter(unsigned int yc_filter) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_yc_filter(yc_filter); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_yc_filter(yc_filter); #endif - return (retval); + return (retval); } int gfx_get_aps_trigger_bits(unsigned int *p_trigger_bits) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_get_aps_trigger_bits(p_trigger_bits); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_get_aps_trigger_bits(p_trigger_bits); #endif - return (retval); + return (retval); } int gfx_set_aps_trigger_bits(unsigned int trigger_bits) { - int retval = -1; + int retval = -1; #if GFX_TV_FS451 - if (gfx_tv_type & GFX_TV_TYPE_FS451) - retval = fs450_set_aps_trigger_bits(trigger_bits); + if (gfx_tv_type & GFX_TV_TYPE_FS451) + retval = fs450_set_aps_trigger_bits(trigger_bits); #endif - return (retval); + return (retval); } -#endif /* GFX_TV_DYNAMIC */ +#endif /* GFX_TV_DYNAMIC */ /* END OF FILE */ diff --git a/src/gfx/gfx_tv.h b/src/gfx/gfx_tv.h index 430c8a5..339c935 100644 --- a/src/gfx/gfx_tv.h +++ b/src/gfx/gfx_tv.h @@ -1,60 +1,58 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/gfx_tv.h,v 1.1 2002/12/10 15:12:26 alanh Exp $ */ -typedef struct tagTVDISPLAYMODE -{ - /* DISPLAY MODE FLAGS */ - /* Specify valid color depths and the refresh rate. */ +typedef struct tagTVDISPLAYMODE { + /* DISPLAY MODE FLAGS */ + /* Specify valid color depths and the refresh rate. */ - unsigned short flags; + unsigned short flags; - /* TIMINGS */ + /* TIMINGS */ - unsigned short hactive; - unsigned short hblankstart; - unsigned short hsyncstart; - unsigned short hsyncend; - unsigned short hblankend; - unsigned short htotal; + unsigned short hactive; + unsigned short hblankstart; + unsigned short hsyncstart; + unsigned short hsyncend; + unsigned short hblankend; + unsigned short htotal; - unsigned short vactive; - unsigned short vblankstart; - unsigned short vsyncstart; - unsigned short vsyncend; - unsigned short vblankend; - unsigned short vtotal; + unsigned short vactive; + unsigned short vblankstart; + unsigned short vsyncstart; + unsigned short vsyncend; + unsigned short vblankend; + unsigned short vtotal; - /* CLOCK FREQUENCY */ + /* CLOCK FREQUENCY */ - unsigned long frequency; + unsigned long frequency; -} -TVDISPLAYMODE; +} TVDISPLAYMODE; TVDISPLAYMODE TVTimings[] = { /* NTSC resolution */ - { - 0x3, /* negative syncs */ - 0x0280, 0x0280, 0x0290, 0x02E8, 0x0318, 0x0318, /* horizontal timings */ - 0x01E0, 0x01E0, 0x01EA, 0x01EC, 0x0205, 0x020D, /* vertical timings */ - 0x0018EC4D, /* freq = 24.923052 MHz */ - }, + { + 0x3, /* negative syncs */ + 0x0280, 0x0280, 0x0290, 0x02E8, 0x0318, 0x0318, /* horizontal timings */ + 0x01E0, 0x01E0, 0x01EA, 0x01EC, 0x0205, 0x020D, /* vertical timings */ + 0x0018EC4D, /* freq = 24.923052 MHz */ + }, /* PAL resolution */ - { - 0x3, /* positive syncs */ - 0x0300, 0x0300, 0x0320, 0x0350, 0x0360, 0x0360, /* horizontal timings */ - 0x0240, 0x0240, 0x024A, 0x024C, 0x0271, 0x0271, /* vertical timings */ - 0x001B0000, /* freq = 27.00 MHz */ - }, + { + 0x3, /* positive syncs */ + 0x0300, 0x0300, 0x0320, 0x0350, 0x0360, 0x0360, /* horizontal timings */ + 0x0240, 0x0240, 0x024A, 0x024C, 0x0271, 0x0271, /* vertical timings */ + 0x001B0000, /* freq = 27.00 MHz */ + }, /* PAL resolution non-square pixels */ - { - 0x3, /* positive syncs */ - 0x02C0, 0x02C0, 0x02F0, 0x0330, 0x0360, 0x0360, /* horizontal timings */ - 0x0240, 0x0240, 0x024A, 0x024C, 0x0271, 0x0271, /* vertical timings */ - 0x001B0000, /* freq = 27.00 MHz */ - } + { + 0x3, /* positive syncs */ + 0x02C0, 0x02C0, 0x02F0, 0x0330, 0x0360, 0x0360, /* horizontal timings */ + 0x0240, 0x0240, 0x024A, 0x024C, 0x0271, 0x0271, /* vertical timings */ + 0x001B0000, /* freq = 27.00 MHz */ + } }; #define NUM_TV_MODES sizeof(TVTimings)/sizeof(TVDISPLAYMODE) diff --git a/src/gfx/gfx_type.h b/src/gfx/gfx_type.h index a50d5bd..802cdda 100644 --- a/src/gfx/gfx_type.h +++ b/src/gfx/gfx_type.h @@ -135,31 +135,24 @@ /* MSR DEFINITIONS */ typedef enum DevStatus -{ FOUND, NOT_KNOWN, REQ_NOT_FOUND, REQ_NOT_INSTALLED } -DEV_STATUS; - -typedef struct msr -{ - DEV_STATUS Present; /* Node enumeration status */ - unsigned char Id; /* Device ID (from MSR specs) */ - unsigned long Address; /* Address - 32-bit MBus address at which 'Id' is found */ -} -MSR; - -typedef struct mValue -{ - unsigned long high; - unsigned long low; -} -Q_WORD; - -typedef struct mbusNode -{ - unsigned long address; - unsigned int deviceId; - unsigned int claimed; -} -MBUS_NODE; + { FOUND, NOT_KNOWN, REQ_NOT_FOUND, REQ_NOT_INSTALLED } DEV_STATUS; + +typedef struct msr { + DEV_STATUS Present; /* Node enumeration status */ + unsigned char Id; /* Device ID (from MSR specs) */ + unsigned long Address; /* Address - 32-bit MBus address at which 'Id' is found */ +} MSR; + +typedef struct mValue { + unsigned long high; + unsigned long low; +} Q_WORD; + +typedef struct mbusNode { + unsigned long address; + unsigned int deviceId; + unsigned int claimed; +} MBUS_NODE; /* MSR ARRAY INDEXES */ /* These are indexes into the array of MBus devices. These */ @@ -230,19 +223,15 @@ MBUS_NODE; /* TV DEFINITIONS */ -typedef enum TVStandardType -{ - TV_STANDARD_NTSC = 1, - TV_STANDARD_PAL -} -TVStandardType; +typedef enum TVStandardType { + TV_STANDARD_NTSC = 1, + TV_STANDARD_PAL +} TVStandardType; -typedef enum GfxOnTVType -{ - GFX_ON_TV_SQUARE_PIXELS = 1, - GFX_ON_TV_NO_SCALING -} -GfxOnTVType; +typedef enum GfxOnTVType { + GFX_ON_TV_SQUARE_PIXELS = 1, + GFX_ON_TV_NO_SCALING +} GfxOnTVType; #define CRT_DISABLE 0x00 #define CRT_ENABLE 0x01 @@ -301,19 +290,15 @@ GfxOnTVType; #define VIDEO_DOWNSCALE_KEEP_1_OF 0x1 #define VIDEO_DOWNSCALE_DROP_1_OF 0x2 -typedef enum VideoSourceType -{/* The source from which the video processor shows full screen video */ - VIDEO_SOURCE_MEMORY = 1, - VIDEO_SOURCE_DVIP -} -VideoSourceType; +typedef enum VideoSourceType { /* The source from which the video processor shows full screen video */ + VIDEO_SOURCE_MEMORY = 1, + VIDEO_SOURCE_DVIP +} VideoSourceType; -typedef enum VbiSourceType -{/* The source from which the video processor takes VBI */ - VBI_SOURCE_MEMORY = 1, - VBI_SOURCE_DVIP -} -VbiSourceType; +typedef enum VbiSourceType { /* The source from which the video processor takes VBI */ + VBI_SOURCE_MEMORY = 1, + VBI_SOURCE_DVIP +} VbiSourceType; /* GENLOCK DEFINITIONS */ @@ -389,17 +374,15 @@ VbiSourceType; #define GFX_APS_TRIGGER_AGC_2_LINE 2 #define GFX_APS_TRIGGER_AGC_4_LINE 3 -typedef struct -{ - int xsize; - int ysize; - int hz; - int clock; - unsigned char miscOutput; - unsigned char stdCRTCregs[GFX_STD_CRTC_REGS]; - unsigned char extCRTCregs[GFX_EXT_CRTC_REGS]; -} -gfx_vga_struct; +typedef struct { + int xsize; + int ysize; + int hz; + int clock; + unsigned char miscOutput; + unsigned char stdCRTCregs[GFX_STD_CRTC_REGS]; + unsigned char extCRTCregs[GFX_EXT_CRTC_REGS]; +} gfx_vga_struct; /* POSSIBLE STATUS VALUES */ @@ -421,19 +404,17 @@ gfx_vga_struct; /* CHIP NAME AND REVISION */ -typedef enum ChipType -{ - CHIP_NOT_DETECTED, - SC1200_REV_A, - SC1200_REV_B1_B2, - SC1200_REV_B3, - SC1200_REV_C1, - SC1200_REV_D1, - SC1200_REV_D1_1, - SC1200_REV_D2_MVD, /* Macrovision disabled */ - SC1200_REV_D2_MVE, /* Macrovision enabled */ - SC1200_FUTURE_REV -} -ChipType; - -#endif /* !_gfx_type_h */ +typedef enum ChipType { + CHIP_NOT_DETECTED, + SC1200_REV_A, + SC1200_REV_B1_B2, + SC1200_REV_B3, + SC1200_REV_C1, + SC1200_REV_D1, + SC1200_REV_D1_1, + SC1200_REV_D2_MVD, /* Macrovision disabled */ + SC1200_REV_D2_MVE, /* Macrovision enabled */ + SC1200_FUTURE_REV +} ChipType; + +#endif /* !_gfx_type_h */ diff --git a/src/gfx/gfx_vga.c b/src/gfx/gfx_vga.c index a2c0dd6..9995492 100644 --- a/src/gfx/gfx_vga.c +++ b/src/gfx/gfx_vga.c @@ -141,6 +141,6 @@ #if GFX_VGA_DYNAMIC -#endif /* GFX_DISPLAY_DYNAMIC */ +#endif /* GFX_DISPLAY_DYNAMIC */ /* END OF FILE */ diff --git a/src/gfx/gfx_vid.c b/src/gfx/gfx_vid.c index 9ddde27..976f506 100644 --- a/src/gfx/gfx_vid.c +++ b/src/gfx/gfx_vid.c @@ -225,21 +225,21 @@ /* STATIC VARIABLES FOR VIDEO OVERLAY CONTROL */ /* These are saved to allow these routines to do clipping. */ -unsigned long gfx_vid_offset = 0; /* copy from last gfx_set_video_offset */ -unsigned long gfx_vid_uoffset = 0; /* copy from last gfx_set_video_yuv_offsets */ -unsigned long gfx_vid_voffset = 0; /* copy from last gfx_set_video_yuv_offsets */ -unsigned long gfx_vid_srcw = 300; /* copy from last gfx_set_video_scale */ -unsigned long gfx_vid_srch = 300; /* copy from last gfx_set_video_scale */ -unsigned long gfx_vid_dstw = 300; /* copy from last gfx_set_video_scale */ -unsigned long gfx_vid_dsth = 300; /* copy from last gfx_set_video_scale */ -short gfx_vid_xpos = 0; /* copy from last gfx_set_video_window */ -short gfx_vid_ypos = 0; /* copy from last gfx_set_video_window */ -unsigned short gfx_vid_width = 0; /* copy from last gfx_set_video_window */ -unsigned short gfx_vid_height = 0; /* copy from last gfx_set_video_window */ - -int gfx_alpha_select = 0; /* currently selected alpha region */ - -int gfx_set_screen_enable(int enable); /* forward declaration */ +unsigned long gfx_vid_offset = 0; /* copy from last gfx_set_video_offset */ +unsigned long gfx_vid_uoffset = 0; /* copy from last gfx_set_video_yuv_offsets */ +unsigned long gfx_vid_voffset = 0; /* copy from last gfx_set_video_yuv_offsets */ +unsigned long gfx_vid_srcw = 300; /* copy from last gfx_set_video_scale */ +unsigned long gfx_vid_srch = 300; /* copy from last gfx_set_video_scale */ +unsigned long gfx_vid_dstw = 300; /* copy from last gfx_set_video_scale */ +unsigned long gfx_vid_dsth = 300; /* copy from last gfx_set_video_scale */ +short gfx_vid_xpos = 0; /* copy from last gfx_set_video_window */ +short gfx_vid_ypos = 0; /* copy from last gfx_set_video_window */ +unsigned short gfx_vid_width = 0; /* copy from last gfx_set_video_window */ +unsigned short gfx_vid_height = 0; /* copy from last gfx_set_video_window */ + +int gfx_alpha_select = 0; /* currently selected alpha region */ + +int gfx_set_screen_enable(int enable); /* forward declaration */ /* INCLUDE SUPPORT FOR CS5530, IF SPECIFIED. */ @@ -270,11 +270,11 @@ int gfx_set_screen_enable(int enable); /* forward declaration */ int gfx_select_alpha_region(int region) { - if (region > 2) - return (GFX_STATUS_BAD_PARAMETER); + if (region > 2) + return (GFX_STATUS_BAD_PARAMETER); - gfx_alpha_select = region; - return (GFX_STATUS_OK); + gfx_alpha_select = region; + return (GFX_STATUS_OK); } /* WRAPPERS IF DYNAMIC SELECTION */ @@ -293,16 +293,16 @@ void gfx_reset_video(void) { # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - cs5530_reset_video(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + cs5530_reset_video(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_reset_video(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_reset_video(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_reset_video(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_reset_video(); # endif } @@ -315,21 +315,21 @@ gfx_reset_video(void) int gfx_set_display_control(int sync_polarities) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_display_control(sync_polarities); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_display_control(sync_polarities); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_display_control(sync_polarities); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_display_control(sync_polarities); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_display_control(sync_polarities); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_display_control(sync_polarities); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -340,16 +340,16 @@ void gfx_set_clock_frequency(unsigned long frequency) { # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - cs5530_set_clock_frequency(frequency); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + cs5530_set_clock_frequency(frequency); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_set_clock_frequency(frequency); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_set_clock_frequency(frequency); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_set_clock_frequency(frequency); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_set_clock_frequency(frequency); # endif } @@ -360,21 +360,21 @@ gfx_set_clock_frequency(unsigned long frequency) int gfx_set_crt_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_crt_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_crt_enable(enable); # endif # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_crt_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_crt_enable(enable); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_crt_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_crt_enable(enable); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -384,21 +384,21 @@ gfx_set_crt_enable(int enable) int gfx_set_video_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_enable(enable); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_enable(enable); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_enable(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -410,13 +410,13 @@ gfx_set_video_enable(int enable) int gfx_set_screen_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_screen_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_screen_enable(enable); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -426,21 +426,21 @@ gfx_set_screen_enable(int enable) int gfx_set_video_format(unsigned long format) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_format(format); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_format(format); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_format(format); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_format(format); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_format(format); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_format(format); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -450,21 +450,21 @@ gfx_set_video_format(unsigned long format) int gfx_set_video_size(unsigned short width, unsigned short height) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_size(width, height); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_size(width, height); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_size(width, height); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_size(width, height); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_size(width, height); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_size(width, height); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -474,13 +474,13 @@ gfx_set_video_size(unsigned short width, unsigned short height) int gfx_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_yuv_pitch(ypitch, uvpitch); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_yuv_pitch(ypitch, uvpitch); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -490,21 +490,21 @@ gfx_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch) int gfx_set_video_offset(unsigned long offset) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_offset(offset); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_offset(offset); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_offset(offset); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_offset(offset); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_offset(offset); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_offset(offset); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -513,15 +513,15 @@ gfx_set_video_offset(unsigned long offset) */ int gfx_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset, - unsigned long voffset) + unsigned long voffset) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_yuv_offsets(yoffset, uoffset, voffset); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_yuv_offsets(yoffset, uoffset, voffset); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -530,23 +530,23 @@ gfx_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset, */ int gfx_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_scale(srcw, srch, dstw, dsth); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_scale(srcw, srch, dstw, dsth); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_scale(srcw, srch, dstw, dsth); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_scale(srcw, srch, dstw, dsth); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_scale(srcw, srch, dstw, dsth); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_scale(srcw, srch, dstw, dsth); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -555,15 +555,15 @@ gfx_set_video_scale(unsigned short srcw, unsigned short srch, */ int gfx_set_video_upscale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_upscale(srcw, srch, dstw, dsth); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_upscale(srcw, srch, dstw, dsth); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -573,13 +573,13 @@ gfx_set_video_upscale(unsigned short srcw, unsigned short srch, int gfx_set_video_vertical_downscale(unsigned short srch, unsigned short dsth) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_vertical_downscale(srch, dsth); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_vertical_downscale(srch, dsth); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -590,8 +590,8 @@ void gfx_set_video_vertical_downscale_enable(int enable) { # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_set_video_vertical_downscale_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_set_video_vertical_downscale_enable(enable); # endif } @@ -602,17 +602,17 @@ gfx_set_video_vertical_downscale_enable(int enable) int gfx_set_video_downscale_config(unsigned short type, unsigned short m) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_downscale_config(type, m); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_downscale_config(type, m); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_downscale_config(type, m); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_downscale_config(type, m); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -621,25 +621,23 @@ gfx_set_video_downscale_config(unsigned short type, unsigned short m) */ int gfx_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4) + unsigned short coef2, + unsigned short coef3, unsigned short coef4) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = - sc1200_set_video_downscale_coefficients(coef1, coef2, coef3, - coef4); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = + sc1200_set_video_downscale_coefficients(coef1, coef2, coef3, coef4); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = - redcloud_set_video_downscale_coefficients(coef1, coef2, coef3, - coef4); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = + redcloud_set_video_downscale_coefficients(coef1, coef2, coef3, + coef4); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -649,17 +647,17 @@ gfx_set_video_downscale_coefficients(unsigned short coef1, int gfx_set_video_downscale_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_downscale_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_downscale_enable(enable); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_downscale_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_downscale_enable(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -669,21 +667,21 @@ gfx_set_video_downscale_enable(int enable) int gfx_set_video_window(short x, short y, unsigned short w, unsigned short h) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_window(x, y, w, h); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_window(x, y, w, h); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_window(x, y, w, h); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_window(x, y, w, h); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_window(x, y, w, h); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_window(x, y, w, h); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -693,21 +691,21 @@ gfx_set_video_window(short x, short y, unsigned short w, unsigned short h) int gfx_set_video_left_crop(unsigned short x) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_left_crop(x); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_left_crop(x); # endif # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_left_crop(x); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_left_crop(x); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_left_crop(x); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_left_crop(x); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -717,21 +715,21 @@ gfx_set_video_left_crop(unsigned short x) int gfx_set_video_color_key(unsigned long key, unsigned long mask, int graphics) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_color_key(key, mask, graphics); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_color_key(key, mask, graphics); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_color_key(key, mask, graphics); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_color_key(key, mask, graphics); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_color_key(key, mask, graphics); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_color_key(key, mask, graphics); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -741,21 +739,21 @@ gfx_set_video_color_key(unsigned long key, unsigned long mask, int graphics) int gfx_set_video_filter(int xfilter, int yfilter) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_filter(xfilter, yfilter); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_filter(xfilter, yfilter); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_filter(xfilter, yfilter); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_filter(xfilter, yfilter); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_filter(xfilter, yfilter); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_filter(xfilter, yfilter); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -765,21 +763,21 @@ gfx_set_video_filter(int xfilter, int yfilter) int gfx_set_video_palette(unsigned long *palette) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_palette(palette); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_palette(palette); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_palette(palette); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_palette(palette); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_palette(palette); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_palette(palette); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -789,21 +787,21 @@ gfx_set_video_palette(unsigned long *palette) int gfx_set_video_palette_entry(unsigned long index, unsigned long palette) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_set_video_palette_entry(index, palette); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_set_video_palette_entry(index, palette); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_palette_entry(index, palette); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_palette_entry(index, palette); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_palette_entry(index, palette); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_palette_entry(index, palette); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -813,17 +811,17 @@ gfx_set_video_palette_entry(unsigned long index, unsigned long palette) int gfx_set_video_request(short x, short y) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_request(x, y); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_request(x, y); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_request(x, y); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_request(x, y); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -833,13 +831,13 @@ gfx_set_video_request(short x, short y) int gfx_set_video_source(VideoSourceType source) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_source(source); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_source(source); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -849,13 +847,13 @@ gfx_set_video_source(VideoSourceType source) int gfx_set_vbi_source(VbiSourceType source) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_vbi_source(source); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_vbi_source(source); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -865,13 +863,13 @@ gfx_set_vbi_source(VbiSourceType source) int gfx_set_vbi_lines(unsigned long even, unsigned long odd) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_vbi_lines(even, odd); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_vbi_lines(even, odd); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -881,13 +879,13 @@ gfx_set_vbi_lines(unsigned long even, unsigned long odd) int gfx_set_vbi_total(unsigned long even, unsigned long odd) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_vbi_total(even, odd); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_vbi_total(even, odd); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -897,13 +895,13 @@ gfx_set_vbi_total(unsigned long even, unsigned long odd) int gfx_set_video_interlaced(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_video_interlaced(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_video_interlaced(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -913,13 +911,13 @@ gfx_set_video_interlaced(int enable) int gfx_set_color_space_YUV(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_color_space_YUV(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_color_space_YUV(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -929,13 +927,13 @@ gfx_set_color_space_YUV(int enable) int gfx_set_vertical_scaler_offset(char offset) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_vertical_scaler_offset(offset); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_vertical_scaler_offset(offset); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -945,13 +943,13 @@ gfx_set_vertical_scaler_offset(char offset) int gfx_set_top_line_in_odd(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_top_line_in_odd(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_top_line_in_odd(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -961,13 +959,13 @@ gfx_set_top_line_in_odd(int enable) int gfx_set_genlock_delay(unsigned long delay) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_genlock_delay(delay); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_genlock_delay(delay); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -977,13 +975,13 @@ gfx_set_genlock_delay(unsigned long delay) int gfx_set_genlock_enable(int flags) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_genlock_enable(flags); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_genlock_enable(flags); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -992,23 +990,22 @@ gfx_set_genlock_enable(int flags) */ int gfx_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, unsigned long color1, - unsigned long color2) + unsigned short select_color2, unsigned long color1, + unsigned long color2) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = - sc1200_set_video_cursor(key, mask, select_color2, color1, color2); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = + sc1200_set_video_cursor(key, mask, select_color2, color1, color2); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = - redcloud_set_video_cursor(key, mask, select_color2, color1, - color2); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = + redcloud_set_video_cursor(key, mask, select_color2, color1, color2); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1018,13 +1015,13 @@ gfx_set_video_cursor(unsigned long key, unsigned long mask, int gfx_set_video_cursor_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_video_cursor_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_video_cursor_enable(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1034,17 +1031,17 @@ gfx_set_video_cursor_enable(int enable) int gfx_set_alpha_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_alpha_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_alpha_enable(enable); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_alpha_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_alpha_enable(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1053,19 +1050,19 @@ gfx_set_alpha_enable(int enable) */ int gfx_set_alpha_window(short x, short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_alpha_window(x, y, width, height); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_alpha_window(x, y, width, height); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_alpha_window(x, y, width, height); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_alpha_window(x, y, width, height); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1075,17 +1072,17 @@ gfx_set_alpha_window(short x, short y, int gfx_set_alpha_value(unsigned char alpha, char delta) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_alpha_value(alpha, delta); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_alpha_value(alpha, delta); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_alpha_value(alpha, delta); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_alpha_value(alpha, delta); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1095,17 +1092,17 @@ gfx_set_alpha_value(unsigned char alpha, char delta) int gfx_set_alpha_priority(int priority) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_alpha_priority(priority); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_alpha_priority(priority); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_alpha_priority(priority); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_alpha_priority(priority); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1115,17 +1112,17 @@ gfx_set_alpha_priority(int priority) int gfx_set_alpha_color(unsigned long color) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_alpha_color(color); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_alpha_color(color); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_alpha_color(color); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_alpha_color(color); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1135,17 +1132,17 @@ gfx_set_alpha_color(unsigned long color) int gfx_set_alpha_color_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_alpha_color_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_alpha_color_enable(enable); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_alpha_color_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_alpha_color_enable(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1155,17 +1152,17 @@ gfx_set_alpha_color_enable(int enable) int gfx_set_no_ck_outside_alpha(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_no_ck_outside_alpha(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_no_ck_outside_alpha(enable); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_set_no_ck_outside_alpha(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_set_no_ck_outside_alpha(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1175,13 +1172,13 @@ gfx_set_no_ck_outside_alpha(int enable) int gfx_set_macrovision_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_set_macrovision_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_set_macrovision_enable(enable); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1191,17 +1188,17 @@ gfx_set_macrovision_enable(int enable) int gfx_disable_softvga(void) { - int status = 0; + int status = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_disable_softvga(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_disable_softvga(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_disable_softvga(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_disable_softvga(); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1211,17 +1208,17 @@ gfx_disable_softvga(void) int gfx_enable_softvga(void) { - int status = 0; + int status = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_enable_softvga(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_enable_softvga(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_enable_softvga(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_enable_softvga(); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1231,21 +1228,21 @@ gfx_enable_softvga(void) unsigned long gfx_get_clock_frequency(void) { - unsigned long frequency = 0; + unsigned long frequency = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - frequency = cs5530_get_clock_frequency(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + frequency = cs5530_get_clock_frequency(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - frequency = sc1200_get_clock_frequency(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + frequency = sc1200_get_clock_frequency(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - frequency = redcloud_get_clock_frequency(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + frequency = redcloud_get_clock_frequency(); # endif - return (frequency); + return (frequency); } /*************************************************************/ @@ -1261,17 +1258,17 @@ gfx_get_clock_frequency(void) int gfx_get_vsa2_softvga_enable(void) { - int enable = 0; + int enable = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - enable = cs5530_get_vsa2_softvga_enable(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + enable = cs5530_get_vsa2_softvga_enable(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - enable = sc1200_get_vsa2_softvga_enable(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + enable = sc1200_get_vsa2_softvga_enable(); # endif - return enable; + return enable; } @@ -1282,21 +1279,21 @@ gfx_get_vsa2_softvga_enable(void) int gfx_get_sync_polarities(void) { - int polarities = 0; + int polarities = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - polarities = cs5530_get_sync_polarities(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + polarities = cs5530_get_sync_polarities(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - polarities = sc1200_get_sync_polarities(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + polarities = sc1200_get_sync_polarities(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - polarities = redcloud_get_sync_polarities(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + polarities = redcloud_get_sync_polarities(); # endif - return (polarities); + return (polarities); } /*--------------------------------------------------------------------------- @@ -1306,21 +1303,21 @@ gfx_get_sync_polarities(void) int gfx_get_video_palette_entry(unsigned long index, unsigned long *palette) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - status = cs5530_get_video_palette_entry(index, palette); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + status = cs5530_get_video_palette_entry(index, palette); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_get_video_palette_entry(index, palette); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_get_video_palette_entry(index, palette); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_get_video_palette_entry(index, palette); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_get_video_palette_entry(index, palette); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -1330,21 +1327,21 @@ gfx_get_video_palette_entry(unsigned long index, unsigned long *palette) int gfx_get_video_enable(void) { - int enable = 0; + int enable = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - enable = cs5530_get_video_enable(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + enable = cs5530_get_video_enable(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - enable = sc1200_get_video_enable(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + enable = sc1200_get_video_enable(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - enable = redcloud_get_video_enable(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + enable = redcloud_get_video_enable(); # endif - return (enable); + return (enable); } /*----------------------------------------------------------------------------- @@ -1354,21 +1351,21 @@ gfx_get_video_enable(void) int gfx_get_video_format(void) { - int format = 0; + int format = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - format = cs5530_get_video_format(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + format = cs5530_get_video_format(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - format = sc1200_get_video_format(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + format = sc1200_get_video_format(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - format = redcloud_get_video_format(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + format = redcloud_get_video_format(); # endif - return (format); + return (format); } /*----------------------------------------------------------------------------- @@ -1378,21 +1375,21 @@ gfx_get_video_format(void) unsigned long gfx_get_video_src_size(void) { - unsigned long size = 0; + unsigned long size = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - size = cs5530_get_video_src_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + size = cs5530_get_video_src_size(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - size = sc1200_get_video_src_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + size = sc1200_get_video_src_size(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - size = redcloud_get_video_src_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + size = redcloud_get_video_src_size(); # endif - return (size); + return (size); } /*----------------------------------------------------------------------------- @@ -1402,21 +1399,21 @@ gfx_get_video_src_size(void) unsigned long gfx_get_video_line_size(void) { - unsigned long size = 0; + unsigned long size = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - size = cs5530_get_video_line_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + size = cs5530_get_video_line_size(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - size = sc1200_get_video_line_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + size = sc1200_get_video_line_size(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - size = redcloud_get_video_line_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + size = redcloud_get_video_line_size(); # endif - return (size); + return (size); } /*----------------------------------------------------------------------------- @@ -1426,21 +1423,21 @@ gfx_get_video_line_size(void) unsigned long gfx_get_video_xclip(void) { - unsigned long size = 0; + unsigned long size = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - size = cs5530_get_video_xclip(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + size = cs5530_get_video_xclip(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - size = sc1200_get_video_xclip(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + size = sc1200_get_video_xclip(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - size = redcloud_get_video_xclip(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + size = redcloud_get_video_xclip(); # endif - return (size); + return (size); } /*----------------------------------------------------------------------------- @@ -1450,21 +1447,21 @@ gfx_get_video_xclip(void) unsigned long gfx_get_video_offset(void) { - unsigned long offset = 0; + unsigned long offset = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - offset = cs5530_get_video_offset(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + offset = cs5530_get_video_offset(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - offset = sc1200_get_video_offset(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + offset = sc1200_get_video_offset(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - offset = redcloud_get_video_offset(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + offset = redcloud_get_video_offset(); # endif - return (offset); + return (offset); } /*----------------------------------------------------------------------------- @@ -1473,11 +1470,11 @@ gfx_get_video_offset(void) */ void gfx_get_video_yuv_offsets(unsigned long *yoffset, unsigned long *uoffset, - unsigned long *voffset) + unsigned long *voffset) { # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_video_yuv_offsets(yoffset, uoffset, voffset); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_video_yuv_offsets(yoffset, uoffset, voffset); # endif } @@ -1489,8 +1486,8 @@ void gfx_get_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch) { # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_video_yuv_pitch(ypitch, uvpitch); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_video_yuv_pitch(ypitch, uvpitch); # endif } @@ -1501,13 +1498,13 @@ gfx_get_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch) unsigned long gfx_get_video_upscale(void) { - unsigned long scale = 0; + unsigned long scale = 0; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - scale = sc1200_get_video_upscale(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + scale = sc1200_get_video_upscale(); # endif - return (scale); + return (scale); } /*--------------------------------------------------------------------------- @@ -1517,21 +1514,21 @@ gfx_get_video_upscale(void) unsigned long gfx_get_video_scale(void) { - unsigned long scale = 0; + unsigned long scale = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - scale = cs5530_get_video_scale(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + scale = cs5530_get_video_scale(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - scale = sc1200_get_video_scale(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + scale = sc1200_get_video_scale(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - scale = redcloud_get_video_scale(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + scale = redcloud_get_video_scale(); # endif - return (scale); + return (scale); } /*--------------------------------------------------------------------------- @@ -1541,13 +1538,13 @@ gfx_get_video_scale(void) unsigned long gfx_get_video_downscale_delta(void) { - unsigned long delta = 0; + unsigned long delta = 0; # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - delta = redcloud_get_video_downscale_delta(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + delta = redcloud_get_video_downscale_delta(); # endif - return (delta); + return (delta); } /*--------------------------------------------------------------------------- @@ -1557,13 +1554,13 @@ gfx_get_video_downscale_delta(void) int gfx_get_video_vertical_downscale_enable(void) { - int enable = 0; + int enable = 0; # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - enable = redcloud_get_video_vertical_downscale_enable(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + enable = redcloud_get_video_vertical_downscale_enable(); # endif - return (enable); + return (enable); } /*--------------------------------------------------------------------------- @@ -1573,17 +1570,17 @@ gfx_get_video_vertical_downscale_enable(void) int gfx_get_video_downscale_config(unsigned short *type, unsigned short *m) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_get_video_downscale_config(type, m); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_get_video_downscale_config(type, m); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_get_video_downscale_config(type, m); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_get_video_downscale_config(type, m); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1592,17 +1589,17 @@ gfx_get_video_downscale_config(unsigned short *type, unsigned short *m) */ void gfx_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4) + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4) { # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_get_video_downscale_coefficients(coef1, coef2, coef3, coef4); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_get_video_downscale_coefficients(coef1, coef2, coef3, coef4); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_video_downscale_coefficients(coef1, coef2, coef3, coef4); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_video_downscale_coefficients(coef1, coef2, coef3, coef4); # endif } @@ -1614,12 +1611,12 @@ void gfx_get_video_downscale_enable(int *enable) { # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_get_video_downscale_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_get_video_downscale_enable(enable); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_video_downscale_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_video_downscale_enable(enable); # endif } @@ -1630,21 +1627,21 @@ gfx_get_video_downscale_enable(int *enable) unsigned long gfx_get_video_dst_size(void) { - unsigned long size = 0; + unsigned long size = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - size = cs5530_get_video_dst_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + size = cs5530_get_video_dst_size(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - size = sc1200_get_video_dst_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + size = sc1200_get_video_dst_size(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - size = redcloud_get_video_dst_size(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + size = redcloud_get_video_dst_size(); # endif - return (size); + return (size); } /*--------------------------------------------------------------------------- @@ -1654,21 +1651,21 @@ gfx_get_video_dst_size(void) unsigned long gfx_get_video_position(void) { - unsigned long position = 0; + unsigned long position = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - position = cs5530_get_video_position(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + position = cs5530_get_video_position(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - position = sc1200_get_video_position(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + position = sc1200_get_video_position(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - position = redcloud_get_video_position(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + position = redcloud_get_video_position(); # endif - return (position); + return (position); } /*--------------------------------------------------------------------------- @@ -1678,21 +1675,21 @@ gfx_get_video_position(void) unsigned long gfx_get_video_color_key(void) { - unsigned long key = 0; + unsigned long key = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - key = cs5530_get_video_color_key(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + key = cs5530_get_video_color_key(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - key = sc1200_get_video_color_key(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + key = sc1200_get_video_color_key(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - key = redcloud_get_video_color_key(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + key = redcloud_get_video_color_key(); # endif - return (key); + return (key); } /*--------------------------------------------------------------------------- @@ -1702,21 +1699,21 @@ gfx_get_video_color_key(void) unsigned long gfx_get_video_color_key_mask(void) { - unsigned long mask = 0; + unsigned long mask = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - mask = cs5530_get_video_color_key_mask(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + mask = cs5530_get_video_color_key_mask(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - mask = sc1200_get_video_color_key_mask(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + mask = sc1200_get_video_color_key_mask(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - mask = redcloud_get_video_color_key_mask(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + mask = redcloud_get_video_color_key_mask(); # endif - return (mask); + return (mask); } /*--------------------------------------------------------------------------- @@ -1726,21 +1723,21 @@ gfx_get_video_color_key_mask(void) int gfx_get_video_color_key_src(void) { - int src = 0; + int src = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - src = cs5530_get_video_color_key_src(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + src = cs5530_get_video_color_key_src(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - src = sc1200_get_video_color_key_src(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + src = sc1200_get_video_color_key_src(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - src = redcloud_get_video_color_key_src(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + src = redcloud_get_video_color_key_src(); # endif - return (src); + return (src); } /*--------------------------------------------------------------------------- @@ -1750,21 +1747,21 @@ gfx_get_video_color_key_src(void) int gfx_get_video_filter(void) { - int filter = 0; + int filter = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - filter = cs5530_get_video_filter(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + filter = cs5530_get_video_filter(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - filter = sc1200_get_video_filter(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + filter = sc1200_get_video_filter(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - filter = redcloud_get_video_filter(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + filter = redcloud_get_video_filter(); # endif - return (filter); + return (filter); } /*--------------------------------------------------------------------------- @@ -1774,17 +1771,17 @@ gfx_get_video_filter(void) int gfx_get_video_request(short *x, short *y) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_get_video_request(x, y); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_get_video_request(x, y); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - status = redcloud_get_video_request(x, y); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + status = redcloud_get_video_request(x, y); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1794,13 +1791,13 @@ gfx_get_video_request(short *x, short *y) int gfx_get_video_source(VideoSourceType * source) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_get_video_source(source); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_get_video_source(source); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1810,13 +1807,13 @@ gfx_get_video_source(VideoSourceType * source) int gfx_get_vbi_source(VbiSourceType * source) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_get_vbi_source(source); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_get_vbi_source(source); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1826,13 +1823,13 @@ gfx_get_vbi_source(VbiSourceType * source) unsigned long gfx_get_vbi_lines(int odd) { - unsigned long lines = (unsigned long)GFX_STATUS_UNSUPPORTED; + unsigned long lines = (unsigned long) GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - lines = sc1200_get_vbi_lines(odd); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + lines = sc1200_get_vbi_lines(odd); # endif - return (lines); + return (lines); } /*--------------------------------------------------------------------------- @@ -1842,13 +1839,13 @@ gfx_get_vbi_lines(int odd) unsigned long gfx_get_vbi_total(int odd) { - unsigned long total = (unsigned long)GFX_STATUS_UNSUPPORTED; + unsigned long total = (unsigned long) GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - total = sc1200_get_vbi_total(odd); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + total = sc1200_get_vbi_total(odd); # endif - return (total); + return (total); } /*--------------------------------------------------------------------------- @@ -1858,13 +1855,13 @@ gfx_get_vbi_total(int odd) int gfx_get_video_interlaced(void) { - int interlaced = GFX_STATUS_UNSUPPORTED; + int interlaced = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - interlaced = sc1200_get_video_interlaced(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + interlaced = sc1200_get_video_interlaced(); # endif - return (interlaced); + return (interlaced); } /*--------------------------------------------------------------------------- @@ -1874,13 +1871,13 @@ gfx_get_video_interlaced(void) int gfx_get_color_space_YUV(void) { - int color_space = GFX_STATUS_UNSUPPORTED; + int color_space = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - color_space = sc1200_get_color_space_YUV(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + color_space = sc1200_get_color_space_YUV(); # endif - return (color_space); + return (color_space); } /*--------------------------------------------------------------------------- @@ -1890,13 +1887,13 @@ gfx_get_color_space_YUV(void) int gfx_get_vertical_scaler_offset(char *offset) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - status = sc1200_get_vertical_scaler_offset(offset); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + status = sc1200_get_vertical_scaler_offset(offset); # endif - return (status); + return (status); } /*--------------------------------------------------------------------------- @@ -1906,13 +1903,13 @@ gfx_get_vertical_scaler_offset(char *offset) unsigned long gfx_get_genlock_delay(void) { - unsigned long delay = (unsigned long)GFX_STATUS_UNSUPPORTED; + unsigned long delay = (unsigned long) GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - delay = sc1200_get_genlock_delay(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + delay = sc1200_get_genlock_delay(); # endif - return (delay); + return (delay); } /*--------------------------------------------------------------------------- @@ -1922,13 +1919,13 @@ gfx_get_genlock_delay(void) int gfx_get_genlock_enable(void) { - int enable = GFX_STATUS_UNSUPPORTED; + int enable = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - enable = sc1200_get_genlock_enable(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + enable = sc1200_get_genlock_enable(); # endif - return (enable); + return (enable); } /*--------------------------------------------------------------------------- @@ -1937,23 +1934,22 @@ gfx_get_genlock_enable(void) */ int gfx_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, unsigned long *color1, - unsigned short *color2) + unsigned short *select_color2, unsigned long *color1, + unsigned short *color2) { - int enable = GFX_STATUS_UNSUPPORTED; + int enable = GFX_STATUS_UNSUPPORTED; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - enable = - sc1200_get_video_cursor(key, mask, select_color2, color1, color2); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + enable = + sc1200_get_video_cursor(key, mask, select_color2, color1, color2); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - enable = - redcloud_get_video_cursor(key, mask, select_color2, color1, - color2); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + enable = + redcloud_get_video_cursor(key, mask, select_color2, color1, color2); # endif - return (enable); + return (enable); } /*--------------------------------------------------------------------------- @@ -1963,21 +1959,21 @@ gfx_get_video_cursor(unsigned long *key, unsigned long *mask, unsigned long gfx_read_crc(void) { - unsigned long crc = 0; + unsigned long crc = 0; # if GFX_VIDEO_CS5530 - if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) - crc = cs5530_read_crc(); + if (gfx_video_type == GFX_VIDEO_TYPE_CS5530) + crc = cs5530_read_crc(); # endif # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - crc = sc1200_read_crc(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + crc = sc1200_read_crc(); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - crc = redcloud_read_crc(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + crc = redcloud_read_crc(); # endif - return (crc); + return (crc); } /*--------------------------------------------------------------------------- @@ -1987,13 +1983,13 @@ gfx_read_crc(void) unsigned long gfx_read_crc32(void) { - unsigned long crc = 0; + unsigned long crc = 0; # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - crc = redcloud_read_crc32(); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + crc = redcloud_read_crc32(); # endif - return (crc); + return (crc); } /*--------------------------------------------------------------------------- @@ -2002,15 +1998,15 @@ gfx_read_crc32(void) */ unsigned long gfx_read_window_crc(int source, unsigned short x, unsigned short y, - unsigned short width, unsigned short height, int crc32) + unsigned short width, unsigned short height, int crc32) { - unsigned long crc = 0; + unsigned long crc = 0; # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - crc = redcloud_read_window_crc(source, x, y, width, height, crc32); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + crc = redcloud_read_window_crc(source, x, y, width, height, crc32); # endif - return (crc); + return (crc); } /*----------------------------------------------------------------------------- @@ -2020,13 +2016,13 @@ gfx_read_window_crc(int source, unsigned short x, unsigned short y, int gfx_get_macrovision_enable(void) { - int enable = 0; + int enable = 0; # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - enable = sc1200_get_video_enable(); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + enable = sc1200_get_video_enable(); # endif - return (enable); + return (enable); } /*--------------------------------------------------------------------------- @@ -2037,14 +2033,14 @@ void gfx_get_alpha_enable(int *enable) { # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_get_alpha_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_get_alpha_enable(enable); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_alpha_enable(enable); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_alpha_enable(enable); # endif - return; + return; } /*--------------------------------------------------------------------------- @@ -2053,17 +2049,17 @@ gfx_get_alpha_enable(int *enable) */ void gfx_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height) + unsigned short *width, unsigned short *height) { # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_get_alpha_size(x, y, width, height); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_get_alpha_size(x, y, width, height); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_alpha_size(x, y, width, height); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_alpha_size(x, y, width, height); # endif - return; + return; } /*--------------------------------------------------------------------------- @@ -2074,14 +2070,14 @@ void gfx_get_alpha_value(unsigned char *alpha, char *delta) { # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_get_alpha_value(alpha, delta); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_get_alpha_value(alpha, delta); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_alpha_value(alpha, delta); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_alpha_value(alpha, delta); # endif - return; + return; } /*--------------------------------------------------------------------------- @@ -2092,14 +2088,14 @@ void gfx_get_alpha_priority(int *priority) { # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_get_alpha_priority(priority); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_get_alpha_priority(priority); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_alpha_priority(priority); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_alpha_priority(priority); # endif - return; + return; } /*--------------------------------------------------------------------------- @@ -2110,18 +2106,18 @@ void gfx_get_alpha_color(unsigned long *color) { # if GFX_VIDEO_SC1200 - if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) - sc1200_get_alpha_color(color); + if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) + sc1200_get_alpha_color(color); # endif # if GFX_VIDEO_REDCLOUD - if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) - redcloud_get_alpha_color(color); + if (gfx_video_type == GFX_VIDEO_TYPE_REDCLOUD) + redcloud_get_alpha_color(color); # endif - return; + return; } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ -#endif /* GFX_VIDEO_DYNAMIC */ +#endif /* GFX_VIDEO_DYNAMIC */ /* END OF FILE */ diff --git a/src/gfx/gfx_vip.c b/src/gfx/gfx_vip.c index 1f506ae..f108f9f 100644 --- a/src/gfx/gfx_vip.c +++ b/src/gfx/gfx_vip.c @@ -178,13 +178,13 @@ int gfx_set_vip_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vip_enable(enable); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vip_enable(enable); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -194,13 +194,13 @@ gfx_set_vip_enable(int enable) int gfx_set_vip_capture_run_mode(int mode) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vip_capture_run_mode(mode); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vip_capture_run_mode(mode); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -210,13 +210,13 @@ gfx_set_vip_capture_run_mode(int mode) int gfx_set_vip_base(unsigned long even, unsigned long odd) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vip_base(even, odd); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vip_base(even, odd); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -226,13 +226,13 @@ gfx_set_vip_base(unsigned long even, unsigned long odd) int gfx_set_vip_pitch(unsigned long pitch) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vip_pitch(pitch); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vip_pitch(pitch); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -242,13 +242,13 @@ gfx_set_vip_pitch(unsigned long pitch) int gfx_set_vip_mode(int mode) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vip_mode(mode); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vip_mode(mode); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -258,13 +258,13 @@ gfx_set_vip_mode(int mode) int gfx_set_vbi_enable(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vbi_enable(enable); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vbi_enable(enable); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -274,13 +274,13 @@ gfx_set_vbi_enable(int enable) int gfx_set_vbi_mode(int mode) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vbi_mode(mode); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vbi_mode(mode); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -290,13 +290,13 @@ gfx_set_vbi_mode(int mode) int gfx_set_vbi_base(unsigned long even, unsigned long odd) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vbi_base(even, odd); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vbi_base(even, odd); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -306,13 +306,13 @@ gfx_set_vbi_base(unsigned long even, unsigned long odd) int gfx_set_vbi_pitch(unsigned long pitch) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vbi_pitch(pitch); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vbi_pitch(pitch); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -322,13 +322,13 @@ gfx_set_vbi_pitch(unsigned long pitch) int gfx_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vbi_direct(even_lines, odd_lines); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vbi_direct(even_lines, odd_lines); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -338,13 +338,13 @@ gfx_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines) int gfx_set_vbi_interrupt(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vbi_interrupt(enable); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vbi_interrupt(enable); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -354,13 +354,13 @@ gfx_set_vbi_interrupt(int enable) int gfx_set_vip_bus_request_threshold_high(int enable) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vip_bus_request_threshold_high(enable); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vip_bus_request_threshold_high(enable); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -370,13 +370,13 @@ gfx_set_vip_bus_request_threshold_high(int enable) int gfx_set_vip_last_line(int last_line) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_set_vip_last_line(last_line); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_set_vip_last_line(last_line); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -386,13 +386,13 @@ gfx_set_vip_last_line(int last_line) int gfx_test_vip_odd_field(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_test_vip_odd_field(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_test_vip_odd_field(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -402,13 +402,13 @@ gfx_test_vip_odd_field(void) int gfx_test_vip_bases_updated(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_test_vip_bases_updated(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_test_vip_bases_updated(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -418,13 +418,13 @@ gfx_test_vip_bases_updated(void) int gfx_test_vip_fifo_overflow(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_test_vip_fifo_overflow(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_test_vip_fifo_overflow(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -434,13 +434,13 @@ gfx_test_vip_fifo_overflow(void) int gfx_get_vip_line(void) { - int status = GFX_STATUS_UNSUPPORTED; + int status = GFX_STATUS_UNSUPPORTED; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - status = sc1200_get_vip_line(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + status = sc1200_get_vip_line(); # endif - return (status); + return (status); } /*----------------------------------------------------------------------------- @@ -450,13 +450,13 @@ gfx_get_vip_line(void) unsigned long gfx_get_vip_base(int odd) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - base = sc1200_get_vip_base(odd); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + base = sc1200_get_vip_base(odd); # endif - return (base); + return (base); } /*----------------------------------------------------------------------------- @@ -466,13 +466,13 @@ gfx_get_vip_base(int odd) unsigned long gfx_get_vbi_pitch(void) { - unsigned long pitch = 0; + unsigned long pitch = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - pitch = sc1200_get_vbi_pitch(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + pitch = sc1200_get_vbi_pitch(); # endif - return (pitch); + return (pitch); } /*************************************************************/ @@ -488,13 +488,13 @@ gfx_get_vbi_pitch(void) int gfx_get_vip_enable(void) { - int enable = 0; + int enable = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - enable = sc1200_get_vip_enable(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + enable = sc1200_get_vip_enable(); # endif - return (enable); + return (enable); } /*----------------------------------------------------------------------------- @@ -504,13 +504,13 @@ gfx_get_vip_enable(void) unsigned long gfx_get_vip_pitch(void) { - unsigned long pitch = 0; + unsigned long pitch = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - pitch = sc1200_get_vip_pitch(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + pitch = sc1200_get_vip_pitch(); # endif - return (pitch); + return (pitch); } /*----------------------------------------------------------------------------- @@ -520,13 +520,13 @@ gfx_get_vip_pitch(void) int gfx_get_vip_mode(void) { - int mode = 0; + int mode = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - mode = sc1200_get_vip_mode(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + mode = sc1200_get_vip_mode(); # endif - return (mode); + return (mode); } /*----------------------------------------------------------------------------- @@ -536,13 +536,13 @@ gfx_get_vip_mode(void) int gfx_get_vbi_enable(void) { - int enable = 0; + int enable = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - enable = sc1200_get_vbi_enable(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + enable = sc1200_get_vbi_enable(); # endif - return (enable); + return (enable); } /*----------------------------------------------------------------------------- @@ -552,13 +552,13 @@ gfx_get_vbi_enable(void) int gfx_get_vbi_mode(void) { - int mode = 0; + int mode = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - mode = sc1200_get_vbi_mode(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + mode = sc1200_get_vbi_mode(); # endif - return (mode); + return (mode); } /*----------------------------------------------------------------------------- @@ -568,13 +568,13 @@ gfx_get_vbi_mode(void) unsigned long gfx_get_vbi_base(int odd) { - unsigned long base = 0; + unsigned long base = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - base = sc1200_get_vbi_base(odd); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + base = sc1200_get_vbi_base(odd); # endif - return (base); + return (base); } /*----------------------------------------------------------------------------- @@ -584,13 +584,13 @@ gfx_get_vbi_base(int odd) unsigned long gfx_get_vbi_direct(int odd) { - unsigned long vbi_direct_lines = 0; + unsigned long vbi_direct_lines = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - vbi_direct_lines = sc1200_get_vbi_direct(odd); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + vbi_direct_lines = sc1200_get_vbi_direct(odd); # endif - return (vbi_direct_lines); + return (vbi_direct_lines); } /*----------------------------------------------------------------------------- @@ -600,13 +600,13 @@ gfx_get_vbi_direct(int odd) int gfx_get_vbi_interrupt(void) { - int enable = 0; + int enable = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - enable = sc1200_get_vbi_interrupt(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + enable = sc1200_get_vbi_interrupt(); # endif - return (enable); + return (enable); } /*----------------------------------------------------------------------------- @@ -616,17 +616,17 @@ gfx_get_vbi_interrupt(void) int gfx_get_vip_bus_request_threshold_high(void) { - int enable = 0; + int enable = 0; # if GFX_VIP_SC1200 - if (gfx_vip_type == GFX_VIP_TYPE_SC1200) - enable = sc1200_get_vip_bus_request_threshold_high(); + if (gfx_vip_type == GFX_VIP_TYPE_SC1200) + enable = sc1200_get_vip_bus_request_threshold_high(); # endif - return (enable); + return (enable); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ -#endif /* GFX_VIP_DYNAMIC */ +#endif /* GFX_VIP_DYNAMIC */ /* END OF FILE */ diff --git a/src/gfx/history.h b/src/gfx/history.h index 36f7fb9..eec942f 100644 --- a/src/gfx/history.h +++ b/src/gfx/history.h @@ -127,7 +127,6 @@ * * END_NSC_LIC_GPL */ - /* Version is in the format of MMmmpp * where in MM is the Major version, mm is the minor version * and pp is the patch number (0 - 99) @@ -137,9 +136,7 @@ #if 0 -This file contains specific revision info SINCE THE LAST RELEASE. It is not meant to -be a comprehensive record of all additions. - +This file contains specific revision info SINCE THE LAST RELEASE. + It is not meant to be a comprehensive record of all additions. #endif /* END OF FILE */ - diff --git a/src/gfx/i2c_acc.c b/src/gfx/i2c_acc.c index 894a10d..f50865b 100644 --- a/src/gfx/i2c_acc.c +++ b/src/gfx/i2c_acc.c @@ -131,14 +131,14 @@ /* SUPER IO DEFINITIONS */ -#define INDEX_1 0x15C /* base address 1 selected */ +#define INDEX_1 0x15C /* base address 1 selected */ #define DATA_1 0x15D -#define INDEX_2 0x2E /* base address 2 selected */ +#define INDEX_2 0x2E /* base address 2 selected */ #define DATA_2 0x2F -#define PCI_INDEX 0xCF8 /* PCI configuration space INDEX */ -#define PCI_DATA 0xCFC /* PCI configuration space DATA */ -#define BASE_ADR_MSB_REG 0x60 /* base address MSB register */ -#define BASE_ADR_LSB_REG 0x61 /* base address LSB register */ +#define PCI_INDEX 0xCF8 /* PCI configuration space INDEX */ +#define PCI_DATA 0xCFC /* PCI configuration space DATA */ +#define BASE_ADR_MSB_REG 0x60 /* base address MSB register */ +#define BASE_ADR_LSB_REG 0x61 /* base address LSB register */ #define SIO_BASE_ADR_15C_15D 0x6000000 #define SIO_BASE_ADR_2E_2F 0x4000000 @@ -149,22 +149,23 @@ unsigned short index_reg, data_reg; /* ACCESS BUS DEFINITIONS */ -#define ACC_I2C_TIMEOUT 1000000 /* Number of reads before timing out */ -#define ACB1_BASE 0x810 /* ACCESS.bus base addresses */ +#define ACC_I2C_TIMEOUT 1000000 /* Number of reads before timing out */ +#define ACB1_BASE 0x810 /* ACCESS.bus base addresses */ #define ACB2_BASE 0x820 -#define ACBSDA 0 /* ACB serial data */ -#define ACBST 1 /* ACB status */ -#define ACBCST 2 /* ACB control status */ -#define ACBCTL1 3 /* ACB control 1 */ -#define ACBADDR 4 /* ACB own address */ -#define ACBCTL2 5 /* ACB control 2 */ -#define LDN 0x7 /* Logical Device Numbers */ +#define ACBSDA 0 /* ACB serial data */ +#define ACBST 1 /* ACB status */ +#define ACBCST 2 /* ACB control status */ +#define ACBCTL1 3 /* ACB control 1 */ +#define ACBADDR 4 /* ACB own address */ +#define ACBCTL2 5 /* ACB control 2 */ +#define LDN 0x7 /* Logical Device Numbers */ #define ACB1_LDN 0x5 #define ACB2_LDN 0x6 /* INITIAL ACCESS.bus BASE ADDRESS VALUES */ unsigned short base_address_array[3] = { 0, ACB1_BASE, ACB2_BASE }; + char Freq = 0x71; /* LOCAL ACCESS.bus FUNCTION DECLARATIONS */ @@ -189,18 +190,18 @@ unsigned short acc_i2c_set_base_address(unsigned char busnum, short adr); /* LOCAL HELPER ROUTINES */ void OsPciReadDWord(int bus, int dev, int func, int address, - unsigned long *data); + unsigned long *data); int sio_set_index_data_reg(void); void sio_write_reg(unsigned char reg, unsigned char data); unsigned char sio_read_reg(unsigned char reg); int acc_i2c_reset(unsigned char busnum, short adr, char freq); int acc_i2c_write(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, - unsigned char *data); + unsigned char subadr, unsigned char bytes, + unsigned char *data); int acc_i2c_read(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, - unsigned char *data); + unsigned char subadr, unsigned char bytes, + unsigned char *data); int acc_i2c_select_gpio(int clock, int data); int acc_i2c_init(void); void acc_i2c_cleanup(void); @@ -218,17 +219,16 @@ void acc_i2c_cleanup(void); void OsPciReadDWord(int bus, int dev, int func, int address, unsigned long *data) { - /* - * The address of a double word in the Configuration Header is built in - * the following way : - * {10000000,bus[23:16],device[15:11],function[10:8],address[7:2],00} - */ - long addr = (0x80000000 | - ((bus & 0xff) << 16) | - ((dev & 0x1f) << 11) | - ((func & 0x7) << 8) | (address & 0xff)); - OUTD(PCI_INDEX, addr); - *data = IND(PCI_DATA); + /* + * The address of a double word in the Configuration Header is built in + * the following way : + * {10000000,bus[23:16],device[15:11],function[10:8],address[7:2],00} + */ + long addr = (0x80000000 | + ((bus & 0xff) << 16) | + ((dev & 0x1f) << 11) | ((func & 0x7) << 8) | (address & 0xff)); + OUTD(PCI_INDEX, addr); + *data = IND(PCI_DATA); } /*--------------------------------------------------------------------------- @@ -245,25 +245,25 @@ OsPciReadDWord(int bus, int dev, int func, int address, unsigned long *data) int sio_set_index_data_reg(void) { - unsigned long xbus_expention_bar, io_control_reg1; + unsigned long xbus_expention_bar, io_control_reg1; - OsPciReadDWord(0, 0x12, 5, 0x10, &xbus_expention_bar); - xbus_expention_bar = xbus_expention_bar & 0xfffffffe; - io_control_reg1 = IND((unsigned short)xbus_expention_bar); + OsPciReadDWord(0, 0x12, 5, 0x10, &xbus_expention_bar); + xbus_expention_bar = xbus_expention_bar & 0xfffffffe; + io_control_reg1 = IND((unsigned short) xbus_expention_bar); - if ((io_control_reg1) & (SIO_BASE_ADR_15C_15D)) { - index_reg = INDEX_1; - data_reg = DATA_1; - return (1); - } + if ((io_control_reg1) & (SIO_BASE_ADR_15C_15D)) { + index_reg = INDEX_1; + data_reg = DATA_1; + return (1); + } - if ((io_control_reg1) & (SIO_BASE_ADR_2E_2F)) { - index_reg = INDEX_2; - data_reg = DATA_2; - return (1); - } + if ((io_control_reg1) & (SIO_BASE_ADR_2E_2F)) { + index_reg = INDEX_2; + data_reg = DATA_2; + return (1); + } - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -277,8 +277,8 @@ sio_set_index_data_reg(void) void sio_write_reg(unsigned char reg, unsigned char data) { - OUTB(index_reg, reg); - OUTB(data_reg, data); + OUTB(index_reg, reg); + OUTB(data_reg, data); } /*--------------------------------------------------------------------------- @@ -292,8 +292,8 @@ sio_write_reg(unsigned char reg, unsigned char data) unsigned char sio_read_reg(unsigned char reg) { - OUTB(index_reg, reg); - return INB(data_reg); + OUTB(index_reg, reg); + return INB(data_reg); } /*--------------------------------------------------------------------------- @@ -316,13 +316,13 @@ int gfx_i2c_reset(unsigned char busnum, short adr, char freq) #endif { - if ((busnum != 1) && (busnum != 2)) - return GFX_STATUS_BAD_PARAMETER; - acc_i2c_config(busnum, adr, freq); - if (base_address_array[busnum] == 0) - return GFX_STATUS_ERROR; - acc_i2c_reset_bus(busnum); - return GFX_STATUS_OK; + if ((busnum != 1) && (busnum != 2)) + return GFX_STATUS_BAD_PARAMETER; + acc_i2c_config(busnum, adr, freq); + if (base_address_array[busnum] == 0) + return GFX_STATUS_ERROR; + acc_i2c_reset_bus(busnum); + return GFX_STATUS_OK; } /*--------------------------------------------------------------------------- @@ -339,9 +339,9 @@ int gfx_i2c_select_gpio(int clock, int data) #endif { - /* THIS ROUTINE DOES NOT APPLY TO THE ACCESS.bus IMPLEMENTATION. */ + /* THIS ROUTINE DOES NOT APPLY TO THE ACCESS.bus IMPLEMENTATION. */ - return (GFX_STATUS_OK); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -354,51 +354,51 @@ gfx_i2c_select_gpio(int clock, int data) #if GFX_I2C_DYNAMIC int acc_i2c_write(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, unsigned char *data) + unsigned char subadr, unsigned char bytes, unsigned char *data) #else int gfx_i2c_write(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, unsigned char *data) + unsigned char subadr, unsigned char bytes, unsigned char *data) #endif { - int loop = 0; + int loop = 0; - if ((busnum != 1) && (busnum != 2)) - return GFX_STATUS_BAD_PARAMETER; + if ((busnum != 1) && (busnum != 2)) + return GFX_STATUS_BAD_PARAMETER; - /* REQUEST MASTER */ + /* REQUEST MASTER */ - if (!acc_i2c_request_master(busnum)) - return (GFX_STATUS_ERROR); + if (!acc_i2c_request_master(busnum)) + return (GFX_STATUS_ERROR); - /* WRITE ADDRESS COMMAND */ + /* WRITE ADDRESS COMMAND */ - acc_i2c_ack(busnum, 1, 0); - acc_i2c_stall_after_start(busnum, 1); - acc_i2c_send_address(busnum, (unsigned char)(chipadr & 0xFE)); - acc_i2c_stall_after_start(busnum, 0); - if (!acc_i2c_ack(busnum, 0, 0)) - return (GFX_STATUS_ERROR); + acc_i2c_ack(busnum, 1, 0); + acc_i2c_stall_after_start(busnum, 1); + acc_i2c_send_address(busnum, (unsigned char) (chipadr & 0xFE)); + acc_i2c_stall_after_start(busnum, 0); + if (!acc_i2c_ack(busnum, 0, 0)) + return (GFX_STATUS_ERROR); - /* WRITE COMMAND */ + /* WRITE COMMAND */ - acc_i2c_write_byte(busnum, subadr); - if (!acc_i2c_ack(busnum, 0, 0)) - return (GFX_STATUS_ERROR); + acc_i2c_write_byte(busnum, subadr); + if (!acc_i2c_ack(busnum, 0, 0)) + return (GFX_STATUS_ERROR); - /* WRITE DATA */ + /* WRITE DATA */ - for (loop = 0; loop < bytes; loop++) { - acc_i2c_write_byte(busnum, *data); - if (loop < (bytes - 1)) - data += sizeof(unsigned char); - if (!acc_i2c_ack(busnum, 0, 0)) - return (GFX_STATUS_ERROR); - } - data -= (bytes - 1); - acc_i2c_stop(busnum); + for (loop = 0; loop < bytes; loop++) { + acc_i2c_write_byte(busnum, *data); + if (loop < (bytes - 1)) + data += sizeof(unsigned char); + if (!acc_i2c_ack(busnum, 0, 0)) + return (GFX_STATUS_ERROR); + } + data -= (bytes - 1); + acc_i2c_stop(busnum); - return GFX_STATUS_OK; + return GFX_STATUS_OK; } /*--------------------------------------------------------------------------- @@ -411,86 +411,88 @@ gfx_i2c_write(unsigned char busnum, unsigned char chipadr, #if GFX_I2C_DYNAMIC int acc_i2c_read(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, unsigned char *data) + unsigned char subadr, unsigned char bytes, unsigned char *data) #else int gfx_i2c_read(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, unsigned char *data) + unsigned char subadr, unsigned char bytes, unsigned char *data) #endif { - unsigned char bytesRead; + unsigned char bytesRead; - if ((busnum != 1) && (busnum != 2)) - return GFX_STATUS_BAD_PARAMETER; + if ((busnum != 1) && (busnum != 2)) + return GFX_STATUS_BAD_PARAMETER; - if (bytes == 0) - return GFX_STATUS_OK; + if (bytes == 0) + return GFX_STATUS_OK; - /* REQUEST MASTER */ + /* REQUEST MASTER */ - if (!acc_i2c_request_master(busnum)) - return (GFX_STATUS_ERROR); + if (!acc_i2c_request_master(busnum)) + return (GFX_STATUS_ERROR); - /* WRITE ADDRESS COMMAND */ + /* WRITE ADDRESS COMMAND */ - acc_i2c_ack(busnum, 1, 0); - acc_i2c_stall_after_start(busnum, 1); - acc_i2c_send_address(busnum, (unsigned char)(chipadr & 0xFE)); - acc_i2c_stall_after_start(busnum, 0); - if (!acc_i2c_ack(busnum, 0, 0)) - return (GFX_STATUS_ERROR); + acc_i2c_ack(busnum, 1, 0); + acc_i2c_stall_after_start(busnum, 1); + acc_i2c_send_address(busnum, (unsigned char) (chipadr & 0xFE)); + acc_i2c_stall_after_start(busnum, 0); + if (!acc_i2c_ack(busnum, 0, 0)) + return (GFX_STATUS_ERROR); - /* WRITE COMMAND */ + /* WRITE COMMAND */ - acc_i2c_write_byte(busnum, subadr); - if (!acc_i2c_ack(busnum, 0, 0)) - return (GFX_STATUS_ERROR); + acc_i2c_write_byte(busnum, subadr); + if (!acc_i2c_ack(busnum, 0, 0)) + return (GFX_STATUS_ERROR); - /* START THE READ */ + /* START THE READ */ - acc_i2c_start(busnum); + acc_i2c_start(busnum); - /* WRITE ADDRESS COMMAND */ + /* WRITE ADDRESS COMMAND */ - acc_i2c_ack(busnum, 1, 1); - acc_i2c_stall_after_start(busnum, 1); - acc_i2c_send_address(busnum, (unsigned char)(chipadr | 0x01)); + acc_i2c_ack(busnum, 1, 1); + acc_i2c_stall_after_start(busnum, 1); + acc_i2c_send_address(busnum, (unsigned char) (chipadr | 0x01)); - /* IF LAST BYTE */ + /* IF LAST BYTE */ - if (bytes == 1) - acc_i2c_ack(busnum, 1, 1); - else - acc_i2c_ack(busnum, 1, 0); + if (bytes == 1) + acc_i2c_ack(busnum, 1, 1); + else + acc_i2c_ack(busnum, 1, 0); - acc_i2c_stall_after_start(busnum, 0); + acc_i2c_stall_after_start(busnum, 0); - if (!acc_i2c_ack(busnum, 0, 0)) - return (GFX_STATUS_ERROR); + if (!acc_i2c_ack(busnum, 0, 0)) + return (GFX_STATUS_ERROR); - /* READ COMMAND */ + /* READ COMMAND */ - for (bytesRead = 0; bytesRead < bytes; bytesRead += 1) { - if (bytesRead < (bytes - 2)) { - data[bytesRead] = acc_i2c_read_byte(busnum, 0); - acc_i2c_ack(busnum, 1, 0); - } else if (bytesRead == (bytes - 2)) { /* TWO BYTES LEFT */ - acc_i2c_ack(busnum, 1, 1); - data[bytesRead] = acc_i2c_read_byte(busnum, 0); - acc_i2c_ack(busnum, 1, 1); - } else { /* LAST BYTE */ + for (bytesRead = 0; bytesRead < bytes; bytesRead += 1) { + if (bytesRead < (bytes - 2)) { + data[bytesRead] = acc_i2c_read_byte(busnum, 0); + acc_i2c_ack(busnum, 1, 0); + } + else if (bytesRead == (bytes - 2)) { /* TWO BYTES LEFT */ + acc_i2c_ack(busnum, 1, 1); + data[bytesRead] = acc_i2c_read_byte(busnum, 0); + acc_i2c_ack(busnum, 1, 1); + } + else { /* LAST BYTE */ - data[bytesRead] = acc_i2c_read_byte(busnum, 1); - acc_i2c_stop(busnum); - } + data[bytesRead] = acc_i2c_read_byte(busnum, 1); + acc_i2c_stop(busnum); + } - /* WHILE NOT LAST BYTE */ + /* WHILE NOT LAST BYTE */ - if ((!(bytesRead == (bytes - 1))) && (!acc_i2c_ack(busnum, 0, 0))) - return (bytesRead); - } + if ((!(bytesRead == (bytes - 1))) && (!acc_i2c_ack(busnum, 0, 0))) + return (bytesRead); + } - return GFX_STATUS_OK; + return GFX_STATUS_OK; } /*--------------------------------------------------------------------------- @@ -507,8 +509,8 @@ int gfx_i2c_init(void) #endif { - /* ### ADD ### THIS ROUTINE IS NOT YET IMPLEMENTED FOR ACCESS.bus */ - return (GFX_STATUS_OK); + /* ### ADD ### THIS ROUTINE IS NOT YET IMPLEMENTED FOR ACCESS.bus */ + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -525,7 +527,7 @@ void gfx_i2c_cleanup(void) #endif { - /* ### ADD ### THIS ROUTINE IS NOT YET IMPLEMENTED FOR ACCESS.bus */ + /* ### ADD ### THIS ROUTINE IS NOT YET IMPLEMENTED FOR ACCESS.bus */ } /*--------------------------------------------------------*/ @@ -541,37 +543,37 @@ gfx_i2c_cleanup(void) void acc_i2c_reset_bus(unsigned char busnum) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; - /* Disable the ACCESS.bus device and */ - /* Configure the SCL frequency */ - OUTB((unsigned short)(bus_base_address + ACBCTL2), - (unsigned char)(Freq & 0xFE)); + /* Disable the ACCESS.bus device and */ + /* Configure the SCL frequency */ + OUTB((unsigned short) (bus_base_address + ACBCTL2), + (unsigned char) (Freq & 0xFE)); - /* Configure no interrupt mode (polling) and */ - /* Disable global call address */ - OUTB((unsigned short)(bus_base_address + ACBCTL1), 0x0); + /* Configure no interrupt mode (polling) and */ + /* Disable global call address */ + OUTB((unsigned short) (bus_base_address + ACBCTL1), 0x0); - /* Disable slave address */ - OUTB((unsigned short)(bus_base_address + ACBADDR), 0x0); + /* Disable slave address */ + OUTB((unsigned short) (bus_base_address + ACBADDR), 0x0); - /* Enable the ACCESS.bus device */ - reg = INB((unsigned short)(bus_base_address + ACBCTL2)); - reg |= 0x01; - OUTB((unsigned short)(bus_base_address + ACBCTL2), reg); + /* Enable the ACCESS.bus device */ + reg = INB((unsigned short) (bus_base_address + ACBCTL2)); + reg |= 0x01; + OUTB((unsigned short) (bus_base_address + ACBCTL2), reg); - /* Issue STOP event */ + /* Issue STOP event */ - acc_i2c_stop(busnum); + acc_i2c_stop(busnum); - /* Clear NEGACK, STASTR and BER bits */ - OUTB((unsigned short)(bus_base_address + ACBST), 0x38); + /* Clear NEGACK, STASTR and BER bits */ + OUTB((unsigned short) (bus_base_address + ACBST), 0x38); - /* Clear BB (BUS BUSY) bit */ - reg = INB((unsigned short)(bus_base_address + ACBCST)); - reg |= 0x02; - OUTB((unsigned short)(bus_base_address + ACBCST), reg); + /* Clear BB (BUS BUSY) bit */ + reg = INB((unsigned short) (bus_base_address + ACBCST)); + reg |= 0x02; + OUTB((unsigned short) (bus_base_address + ACBCST), reg); } /*--------------------------------------------------------------------------- @@ -583,12 +585,12 @@ acc_i2c_reset_bus(unsigned char busnum) void acc_i2c_start(unsigned char busnum) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; - reg = INB((unsigned short)(bus_base_address + ACBCTL1)); - reg |= 0x01; - OUTB((unsigned short)(bus_base_address + ACBCTL1), reg); + reg = INB((unsigned short) (bus_base_address + ACBCTL1)); + reg |= 0x01; + OUTB((unsigned short) (bus_base_address + ACBCTL1), reg); } /*--------------------------------------------------------------------------- @@ -600,12 +602,12 @@ acc_i2c_start(unsigned char busnum) void acc_i2c_stop(unsigned char busnum) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; - reg = INB((unsigned short)(bus_base_address + ACBCTL1)); - reg |= 0x02; - OUTB((unsigned short)(bus_base_address + ACBCTL1), reg); + reg = INB((unsigned short) (bus_base_address + ACBCTL1)); + reg |= 0x02; + OUTB((unsigned short) (bus_base_address + ACBCTL1), reg); } /*--------------------------------------------------------------------------- @@ -615,13 +617,13 @@ acc_i2c_stop(unsigned char busnum) void acc_i2c_abort_data(unsigned char busnum) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; - acc_i2c_stop(busnum); - reg = INB((unsigned short)(bus_base_address + ACBCTL1)); - reg |= 0x10; - OUTB((unsigned short)(bus_base_address + ACBCTL1), reg); + acc_i2c_stop(busnum); + reg = INB((unsigned short) (bus_base_address + ACBCTL1)); + reg |= 0x10; + OUTB((unsigned short) (bus_base_address + ACBCTL1), reg); } /*--------------------------------------------------------------------------- @@ -631,8 +633,8 @@ acc_i2c_abort_data(unsigned char busnum) void acc_i2c_bus_recovery(unsigned char busnum) { - acc_i2c_abort_data(busnum); - acc_i2c_reset_bus(busnum); + acc_i2c_abort_data(busnum); + acc_i2c_reset_bus(busnum); } /*--------------------------------------------------------------------------- @@ -642,21 +644,21 @@ acc_i2c_bus_recovery(unsigned char busnum) void acc_i2c_stall_after_start(unsigned char busnum, int state) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; - - reg = INB((unsigned short)(bus_base_address + ACBCTL1)); - if (state) - reg |= 0x80; - else - reg &= 0x7F; - OUTB((unsigned short)(bus_base_address + ACBCTL1), reg); - - if (!state) { - reg = INB((unsigned short)(bus_base_address + ACBST)); - reg |= 0x08; - OUTB((unsigned short)(bus_base_address + ACBST), reg); - } + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; + + reg = INB((unsigned short) (bus_base_address + ACBCTL1)); + if (state) + reg |= 0x80; + else + reg &= 0x7F; + OUTB((unsigned short) (bus_base_address + ACBCTL1), reg); + + if (!state) { + reg = INB((unsigned short) (bus_base_address + ACBST)); + reg |= 0x08; + OUTB((unsigned short) (bus_base_address + ACBST), reg); + } } /*--------------------------------------------------------------------------- @@ -666,36 +668,36 @@ acc_i2c_stall_after_start(unsigned char busnum, int state) void acc_i2c_send_address(unsigned char busnum, unsigned char cData) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; - unsigned long timeout = 0; + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; + unsigned long timeout = 0; - /* WRITE THE DATA */ + /* WRITE THE DATA */ - OUTB((unsigned short)(bus_base_address + ACBSDA), cData); - while (1) { - reg = INB((unsigned short)(bus_base_address + ACBST)); - if ((reg & 0x38) != 0) /* check STASTR, BER and NEGACK */ - break; - if (timeout++ == ACC_I2C_TIMEOUT) { - acc_i2c_bus_recovery(busnum); - return; - } - } + OUTB((unsigned short) (bus_base_address + ACBSDA), cData); + while (1) { + reg = INB((unsigned short) (bus_base_address + ACBST)); + if ((reg & 0x38) != 0) /* check STASTR, BER and NEGACK */ + break; + if (timeout++ == ACC_I2C_TIMEOUT) { + acc_i2c_bus_recovery(busnum); + return; + } + } - /* CHECK FOR BUS ERROR */ + /* CHECK FOR BUS ERROR */ - if (reg & 0x20) { - acc_i2c_bus_recovery(busnum); - return; - } + if (reg & 0x20) { + acc_i2c_bus_recovery(busnum); + return; + } - /* CHECK NEGATIVE ACKNOWLEDGE */ + /* CHECK NEGATIVE ACKNOWLEDGE */ - if (reg & 0x10) { - acc_i2c_abort_data(busnum); - return; - } + if (reg & 0x10) { + acc_i2c_abort_data(busnum); + return; + } } @@ -708,49 +710,51 @@ acc_i2c_send_address(unsigned char busnum, unsigned char cData) int acc_i2c_ack(unsigned char busnum, int fPut, int negAck) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; - unsigned long timeout = 0; - - if (fPut) { /* read operation */ - if (!negAck) { - /* Push Ack onto I2C bus */ - reg = INB((unsigned short)(bus_base_address + ACBCTL1)); - reg &= 0xE7; - OUTB((unsigned short)(bus_base_address + ACBCTL1), reg); - } else { - /* Push negAck onto I2C bus */ - reg = INB((unsigned short)(bus_base_address + ACBCTL1)); - reg |= 0x10; - OUTB((unsigned short)(bus_base_address + ACBCTL1), reg); - } - } else { /* write operation */ - /* Receive Ack from I2C bus */ - while (1) { - reg = INB((unsigned short)(bus_base_address + ACBST)); - if ((reg & 0x70) != 0) /* check SDAST, BER and NEGACK */ - break; - if (timeout++ == ACC_I2C_TIMEOUT) { - acc_i2c_bus_recovery(busnum); - return (0); - } - } - - /* CHECK FOR BUS ERROR */ - - if (reg & 0x20) { - acc_i2c_bus_recovery(busnum); - return (0); - } - - /* CHECK NEGATIVE ACKNOWLEDGE */ - - if (reg & 0x10) { - acc_i2c_abort_data(busnum); - return (0); - } - } - return (1); + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; + unsigned long timeout = 0; + + if (fPut) { /* read operation */ + if (!negAck) { + /* Push Ack onto I2C bus */ + reg = INB((unsigned short) (bus_base_address + ACBCTL1)); + reg &= 0xE7; + OUTB((unsigned short) (bus_base_address + ACBCTL1), reg); + } + else { + /* Push negAck onto I2C bus */ + reg = INB((unsigned short) (bus_base_address + ACBCTL1)); + reg |= 0x10; + OUTB((unsigned short) (bus_base_address + ACBCTL1), reg); + } + } + else { /* write operation */ + /* Receive Ack from I2C bus */ + while (1) { + reg = INB((unsigned short) (bus_base_address + ACBST)); + if ((reg & 0x70) != 0) /* check SDAST, BER and NEGACK */ + break; + if (timeout++ == ACC_I2C_TIMEOUT) { + acc_i2c_bus_recovery(busnum); + return (0); + } + } + + /* CHECK FOR BUS ERROR */ + + if (reg & 0x20) { + acc_i2c_bus_recovery(busnum); + return (0); + } + + /* CHECK NEGATIVE ACKNOWLEDGE */ + + if (reg & 0x10) { + acc_i2c_abort_data(busnum); + return (0); + } + } + return (1); } /*--------------------------------------------------------------------------- @@ -762,12 +766,12 @@ acc_i2c_ack(unsigned char busnum, int fPut, int negAck) void acc_i2c_stop_clock(unsigned char busnum) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; - reg = INB((unsigned short)(bus_base_address + ACBCTL2)); - reg &= ~0x01; - OUTB((unsigned short)(bus_base_address + ACBCTL2), reg); + reg = INB((unsigned short) (bus_base_address + ACBCTL2)); + reg &= ~0x01; + OUTB((unsigned short) (bus_base_address + ACBCTL2), reg); } /*--------------------------------------------------------------------------- @@ -779,12 +783,12 @@ acc_i2c_stop_clock(unsigned char busnum) void acc_i2c_activate_clock(unsigned char busnum) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; - reg = INB((unsigned short)(bus_base_address + ACBCTL2)); - reg |= 0x01; - OUTB((unsigned short)(bus_base_address + ACBCTL2), reg); + reg = INB((unsigned short) (bus_base_address + ACBCTL2)); + reg |= 0x01; + OUTB((unsigned short) (bus_base_address + ACBCTL2), reg); } /*--------------------------------------------------------------------------- @@ -796,37 +800,37 @@ acc_i2c_activate_clock(unsigned char busnum) void acc_i2c_write_byte(unsigned char busnum, unsigned char cData) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; - unsigned long timeout = 0; + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; + unsigned long timeout = 0; - while (1) { - reg = INB((unsigned short)(bus_base_address + ACBST)); - if (reg & 0x70) - break; - if (timeout++ == ACC_I2C_TIMEOUT) { - acc_i2c_bus_recovery(busnum); - return; - } - } + while (1) { + reg = INB((unsigned short) (bus_base_address + ACBST)); + if (reg & 0x70) + break; + if (timeout++ == ACC_I2C_TIMEOUT) { + acc_i2c_bus_recovery(busnum); + return; + } + } - /* CHECK FOR BUS ERROR */ + /* CHECK FOR BUS ERROR */ - if (reg & 0x20) { - acc_i2c_bus_recovery(busnum); - return; - } + if (reg & 0x20) { + acc_i2c_bus_recovery(busnum); + return; + } - /* CHECK NEGATIVE ACKNOWLEDGE */ + /* CHECK NEGATIVE ACKNOWLEDGE */ - if (reg & 0x10) { - acc_i2c_abort_data(busnum); - return; - } + if (reg & 0x10) { + acc_i2c_abort_data(busnum); + return; + } - /* WRITE THE DATA */ + /* WRITE THE DATA */ - OUTB((unsigned short)(bus_base_address + ACBSDA), cData); + OUTB((unsigned short) (bus_base_address + ACBSDA), cData); } /*--------------------------------------------------------------------------- @@ -838,35 +842,35 @@ acc_i2c_write_byte(unsigned char busnum, unsigned char cData) unsigned char acc_i2c_read_byte(unsigned char busnum, int last_byte) { - unsigned char cData, reg; - unsigned short bus_base_address = base_address_array[busnum]; - unsigned long timeout = 0; - - while (1) { - reg = INB((unsigned short)(bus_base_address + ACBST)); - if (reg & 0x60) - break; - if (timeout++ == ACC_I2C_TIMEOUT) { - acc_i2c_bus_recovery(busnum); - return (0xEF); - } - } - - /* CHECK FOR BUS ERROR */ - - if (reg & 0x20) { - acc_i2c_bus_recovery(busnum); - return (0xEE); - } - - /* READ DATA */ - if (last_byte) - acc_i2c_stop_clock(busnum); - cData = INB((unsigned short)(bus_base_address + ACBSDA)); - if (last_byte) - acc_i2c_activate_clock(busnum); - - return (cData); + unsigned char cData, reg; + unsigned short bus_base_address = base_address_array[busnum]; + unsigned long timeout = 0; + + while (1) { + reg = INB((unsigned short) (bus_base_address + ACBST)); + if (reg & 0x60) + break; + if (timeout++ == ACC_I2C_TIMEOUT) { + acc_i2c_bus_recovery(busnum); + return (0xEF); + } + } + + /* CHECK FOR BUS ERROR */ + + if (reg & 0x20) { + acc_i2c_bus_recovery(busnum); + return (0xEE); + } + + /* READ DATA */ + if (last_byte) + acc_i2c_stop_clock(busnum); + cData = INB((unsigned short) (bus_base_address + ACBSDA)); + if (last_byte) + acc_i2c_activate_clock(busnum); + + return (cData); } /*--------------------------------------------------------------------------- @@ -876,35 +880,35 @@ acc_i2c_read_byte(unsigned char busnum, int last_byte) int acc_i2c_request_master(unsigned char busnum) { - unsigned char reg; - unsigned short bus_base_address = base_address_array[busnum]; - unsigned long timeout = 0; - - acc_i2c_start(busnum); - while (1) { - reg = INB((unsigned short)(bus_base_address + ACBST)); - if (reg & 0x60) - break; - if (timeout++ == ACC_I2C_TIMEOUT) { - acc_i2c_bus_recovery(busnum); - return (0); - } - } - - /* CHECK FOR BUS ERROR */ - - if (reg & 0x20) { - acc_i2c_abort_data(busnum); - return (0); - } - - /* CHECK NEGATIVE ACKNOWLEDGE */ - - if (reg & 0x10) { - acc_i2c_abort_data(busnum); - return (0); - } - return (1); + unsigned char reg; + unsigned short bus_base_address = base_address_array[busnum]; + unsigned long timeout = 0; + + acc_i2c_start(busnum); + while (1) { + reg = INB((unsigned short) (bus_base_address + ACBST)); + if (reg & 0x60) + break; + if (timeout++ == ACC_I2C_TIMEOUT) { + acc_i2c_bus_recovery(busnum); + return (0); + } + } + + /* CHECK FOR BUS ERROR */ + + if (reg & 0x20) { + acc_i2c_abort_data(busnum); + return (0); + } + + /* CHECK NEGATIVE ACKNOWLEDGE */ + + if (reg & 0x10) { + acc_i2c_abort_data(busnum); + return (0); + } + return (1); } /*--------------------------------------------------------*/ @@ -920,8 +924,8 @@ acc_i2c_request_master(unsigned char busnum) void acc_i2c_config(unsigned char busnum, short adr, char freq) { - base_address_array[busnum] = acc_i2c_set_base_address(busnum, adr); - Freq = acc_i2c_set_freq(busnum, freq); + base_address_array[busnum] = acc_i2c_set_base_address(busnum, adr); + Freq = acc_i2c_set_freq(busnum, freq); } /*---------------------------------------------------------------------------- @@ -933,19 +937,19 @@ acc_i2c_config(unsigned char busnum, short adr, char freq) char acc_i2c_set_freq(unsigned char busnum, char freq) { - unsigned short bus_base_address = base_address_array[busnum]; + unsigned short bus_base_address = base_address_array[busnum]; - OUTB((unsigned short)(bus_base_address + ACBCTL2), 0x0); + OUTB((unsigned short) (bus_base_address + ACBCTL2), 0x0); - if (freq == (char)(-1)) - freq = 0x71; - else { - freq = freq << 1; - freq |= 0x01; - } + if (freq == (char) (-1)) + freq = 0x71; + else { + freq = freq << 1; + freq |= 0x01; + } - OUTB((unsigned short)(bus_base_address + ACBCTL2), freq); - return (freq); + OUTB((unsigned short) (bus_base_address + ACBCTL2), freq); + return (freq); } /*--------------------------------------------------------------------------- @@ -957,34 +961,34 @@ acc_i2c_set_freq(unsigned char busnum, char freq) unsigned short acc_i2c_set_base_address(unsigned char busnum, short adr) { - unsigned short ab_base_addr; - - /* Get Super I/O Index and Data registers */ - if (!sio_set_index_data_reg()) - return (0); - - /* Configure LDN to current ACB */ - if (busnum == 1) - sio_write_reg(LDN, ACB1_LDN); - if (busnum == 2) - sio_write_reg(LDN, ACB2_LDN); - - if (adr == -1) { - /* Get ACCESS.bus base address */ - ab_base_addr = sio_read_reg(BASE_ADR_MSB_REG); - ab_base_addr = ab_base_addr << 8; - ab_base_addr |= sio_read_reg(BASE_ADR_LSB_REG); - if (ab_base_addr != 0) - return ab_base_addr; - else - adr = (busnum == 1 ? ACB1_BASE : ACB2_BASE); - } - - /* Set ACCESS.bus base address */ - sio_write_reg(BASE_ADR_LSB_REG, (unsigned char)(adr & 0xFF)); - sio_write_reg(BASE_ADR_MSB_REG, (unsigned char)(adr >> 8)); - - return adr; + unsigned short ab_base_addr; + + /* Get Super I/O Index and Data registers */ + if (!sio_set_index_data_reg()) + return (0); + + /* Configure LDN to current ACB */ + if (busnum == 1) + sio_write_reg(LDN, ACB1_LDN); + if (busnum == 2) + sio_write_reg(LDN, ACB2_LDN); + + if (adr == -1) { + /* Get ACCESS.bus base address */ + ab_base_addr = sio_read_reg(BASE_ADR_MSB_REG); + ab_base_addr = ab_base_addr << 8; + ab_base_addr |= sio_read_reg(BASE_ADR_LSB_REG); + if (ab_base_addr != 0) + return ab_base_addr; + else + adr = (busnum == 1 ? ACB1_BASE : ACB2_BASE); + } + + /* Set ACCESS.bus base address */ + sio_write_reg(BASE_ADR_LSB_REG, (unsigned char) (adr & 0xFF)); + sio_write_reg(BASE_ADR_MSB_REG, (unsigned char) (adr >> 8)); + + return adr; } /* END OF FILE */ diff --git a/src/gfx/i2c_gpio.c b/src/gfx/i2c_gpio.c index 096750d..c6ee51b 100644 --- a/src/gfx/i2c_gpio.c +++ b/src/gfx/i2c_gpio.c @@ -136,11 +136,11 @@ int gpio_data = 0; static int g_initialized = 0; -#define I2CWRITE 0x00 /* Write address */ -#define I2CREAD 0x01 /* Read address */ +#define I2CWRITE 0x00 /* Write address */ +#define I2CREAD 0x01 /* Read address */ -#define I2CACK 0x00 /* Ack value */ -#define I2CNACK 0x01 /* Not - ack value */ +#define I2CACK 0x00 /* Ack value */ +#define I2CNACK 0x01 /* Not - ack value */ #define CS5530_ID (0x80000000 | (0x00<<16) | (0x12<<11) | (0<<8) | 0x00) #define CS5530_GPIO (0x80000000 | (0x00<<16) | (0x12<<11) | (0<<8) | 0x90) @@ -153,9 +153,9 @@ int I2C_init(void); void I2C_cleanup(void); int I2C_Read(unsigned char address, unsigned int reg, unsigned long *p_value, - unsigned int bytes); + unsigned int bytes); int I2C_Write(unsigned char address, unsigned int reg, unsigned long value, - unsigned int bytes); + unsigned int bytes); int I2CAL_init(void); void I2CAL_cleanup(void); @@ -177,11 +177,11 @@ unsigned char ReceiveI2CData(void); int gpio_i2c_reset(unsigned char busnum, short adr, char freq); int gpio_i2c_write(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, - unsigned char *data); + unsigned char subadr, unsigned char bytes, + unsigned char *data); int gpio_i2c_read(unsigned char busnum, unsigned char chipadr, - unsigned char subadr, unsigned char bytes, - unsigned char *data); + unsigned char subadr, unsigned char bytes, + unsigned char *data); int gpio_i2c_select_gpio(int clock, int data); int gpio_i2c_init(void); void gpio_i2c_cleanup(void); @@ -203,8 +203,8 @@ int gfx_i2c_reset(unsigned char busnum, short adr, char freq) #endif { - /* ### ADD ### Any code needed to reset the state of the GPIOs. */ - return GFX_STATUS_OK; + /* ### ADD ### Any code needed to reset the state of the GPIOs. */ + return GFX_STATUS_OK; } /*--------------------------------------------------------------------------- @@ -221,9 +221,9 @@ int gfx_i2c_select_gpio(int clock, int data) #endif { - gpio_clock = clock; - gpio_data = data; - return (0); + gpio_clock = clock; + gpio_data = data; + return (0); } /*--------------------------------------------------------------------------- @@ -235,59 +235,59 @@ gfx_i2c_select_gpio(int clock, int data) #if GFX_I2C_DYNAMIC int gpio_i2c_write(unsigned char busnum, unsigned char address, unsigned char reg, - unsigned char bytes, unsigned char *value) + unsigned char bytes, unsigned char *value) #else int gfx_i2c_write(unsigned char busnum, unsigned char address, unsigned char reg, - unsigned char bytes, unsigned char *value) + unsigned char bytes, unsigned char *value) #endif { - /* ### ADD ### CODE TO WRITE BYTE TO I2B BUS */ - - int restart_count = 0; - - while (restart_count++ < 5) { - /* set the access pointer register. */ - /* The address is shifted left by one to make room for Read/Write bit */ - SendI2CStart(); - SendI2CData((char)((address << 1) | I2CWRITE)); - if (!ReceiveI2CAck()) { - SendI2CStop(); - gfx_delay_milliseconds(10); - continue; - } - SendI2CData((unsigned char)reg); - if (!ReceiveI2CAck()) { - SendI2CStop(); - gfx_delay_milliseconds(10); - continue; - } - - /* write the first byte */ - SendI2CData(*value); - if (!ReceiveI2CAck()) { - SendI2CStop(); - gfx_delay_milliseconds(10); - continue; - } - - /* write the second byte. */ - if (bytes == 2) { - SendI2CData(*(value + 1)); - if (!ReceiveI2CAck()) { - SendI2CStop(); - gfx_delay_milliseconds(10); - continue; - } - } - - /* done. */ - SendI2CStop(); - - return 0; - } - - return (0); + /* ### ADD ### CODE TO WRITE BYTE TO I2B BUS */ + + int restart_count = 0; + + while (restart_count++ < 5) { + /* set the access pointer register. */ + /* The address is shifted left by one to make room for Read/Write bit */ + SendI2CStart(); + SendI2CData((char) ((address << 1) | I2CWRITE)); + if (!ReceiveI2CAck()) { + SendI2CStop(); + gfx_delay_milliseconds(10); + continue; + } + SendI2CData((unsigned char) reg); + if (!ReceiveI2CAck()) { + SendI2CStop(); + gfx_delay_milliseconds(10); + continue; + } + + /* write the first byte */ + SendI2CData(*value); + if (!ReceiveI2CAck()) { + SendI2CStop(); + gfx_delay_milliseconds(10); + continue; + } + + /* write the second byte. */ + if (bytes == 2) { + SendI2CData(*(value + 1)); + if (!ReceiveI2CAck()) { + SendI2CStop(); + gfx_delay_milliseconds(10); + continue; + } + } + + /* done. */ + SendI2CStop(); + + return 0; + } + + return (0); } @@ -300,58 +300,58 @@ gfx_i2c_write(unsigned char busnum, unsigned char address, unsigned char reg, #if GFX_I2C_DYNAMIC int gpio_i2c_read(unsigned char busnum, unsigned char address, unsigned char reg, - unsigned char bytes, unsigned char *p_value) + unsigned char bytes, unsigned char *p_value) #else int gfx_i2c_read(unsigned char busnum, unsigned char address, unsigned char reg, - unsigned char bytes, unsigned char *p_value) + unsigned char bytes, unsigned char *p_value) #endif { - /* ### ADD ### CODE TO WRITE BYTE TO I2B BUS */ - /* For now return clock and data pins */ - - int restart_count = 0; - - if (!p_value) - return (1); - - while (restart_count++ < 5) { - /* set the access pointer register. */ - /* The address is shifted left by one to make room for Read/Write bit */ - SendI2CStart(); - SendI2CData((char)((address << 1) | I2CWRITE)); - if (!ReceiveI2CAck()) { - SendI2CStop(); - gfx_delay_milliseconds(10); - continue; - } - SendI2CData((unsigned char)(reg & 0xFF)); - SendI2CNack(); - - /* read the first data byte. */ - SendI2CStart(); - SendI2CData((char)((address << 1) | I2CREAD)); - if (!ReceiveI2CAck()) { - SendI2CStop(); - gfx_delay_milliseconds(10); - continue; - } - *p_value = ReceiveI2CData(); - - /* read the second byte. */ - if (bytes == 2) { - SendI2CAck(); - *(p_value + 1) = ReceiveI2CData(); - } - - /* done. */ - SendI2CNack(); - SendI2CStop(); - - return 0; - } - - return (1); + /* ### ADD ### CODE TO WRITE BYTE TO I2B BUS */ + /* For now return clock and data pins */ + + int restart_count = 0; + + if (!p_value) + return (1); + + while (restart_count++ < 5) { + /* set the access pointer register. */ + /* The address is shifted left by one to make room for Read/Write bit */ + SendI2CStart(); + SendI2CData((char) ((address << 1) | I2CWRITE)); + if (!ReceiveI2CAck()) { + SendI2CStop(); + gfx_delay_milliseconds(10); + continue; + } + SendI2CData((unsigned char) (reg & 0xFF)); + SendI2CNack(); + + /* read the first data byte. */ + SendI2CStart(); + SendI2CData((char) ((address << 1) | I2CREAD)); + if (!ReceiveI2CAck()) { + SendI2CStop(); + gfx_delay_milliseconds(10); + continue; + } + *p_value = ReceiveI2CData(); + + /* read the second byte. */ + if (bytes == 2) { + SendI2CAck(); + *(p_value + 1) = ReceiveI2CData(); + } + + /* done. */ + SendI2CNack(); + SendI2CStop(); + + return 0; + } + + return (1); } /* Added i2c/gpio code to test fs451 chip. */ @@ -368,10 +368,10 @@ gfx_i2c_read(unsigned char busnum, unsigned char address, unsigned char reg, void SendI2CStart(void) { - I2CAL_output_data(1); - I2CAL_output_clock(1); - I2CAL_output_data(0); - I2CAL_output_clock(0); + I2CAL_output_data(1); + I2CAL_output_clock(1); + I2CAL_output_data(0); + I2CAL_output_clock(0); } /* @@ -386,9 +386,9 @@ SendI2CStart(void) void SendI2CStop(void) { - I2CAL_output_data(0); - I2CAL_output_clock(1); - I2CAL_output_data(1); + I2CAL_output_data(0); + I2CAL_output_clock(1); + I2CAL_output_data(1); } /* @@ -403,9 +403,9 @@ SendI2CStop(void) void SendI2CAck(void) { - I2CAL_output_data(0); - I2CAL_output_clock(1); - I2CAL_output_clock(0); + I2CAL_output_data(0); + I2CAL_output_clock(1); + I2CAL_output_clock(0); } /* @@ -420,9 +420,9 @@ SendI2CAck(void) void SendI2CNack(void) { - I2CAL_output_data(1); - I2CAL_output_clock(1); - I2CAL_output_clock(0); + I2CAL_output_data(1); + I2CAL_output_clock(1); + I2CAL_output_clock(0); } /* @@ -441,18 +441,18 @@ SendI2CNack(void) void SendI2CData(unsigned char inData) { - unsigned char bit; - - /* Send all 8 bits of data byte, MSB to LSB */ - for (bit = 0x80; bit != 0; bit >>= 1) { - if (inData & bit) - I2CAL_output_data(1); - else - I2CAL_output_data(0); - - I2CAL_output_clock(1); - I2CAL_output_clock(0); - } + unsigned char bit; + + /* Send all 8 bits of data byte, MSB to LSB */ + for (bit = 0x80; bit != 0; bit >>= 1) { + if (inData & bit) + I2CAL_output_data(1); + else + I2CAL_output_data(0); + + I2CAL_output_clock(1); + I2CAL_output_clock(0); + } } /* @@ -469,16 +469,16 @@ SendI2CData(unsigned char inData) unsigned char ReceiveI2CAck(void) { - unsigned char bit; - - /* Test for Ack/Nack */ - I2CAL_set_data_for_input(); - I2CAL_output_data(1); - I2CAL_output_clock(1); - bit = I2CAL_input_data(); - I2CAL_output_clock(0); - I2CAL_set_data_for_output(); - return !bit; + unsigned char bit; + + /* Test for Ack/Nack */ + I2CAL_set_data_for_input(); + I2CAL_output_data(1); + I2CAL_output_clock(1); + bit = I2CAL_input_data(); + I2CAL_output_clock(0); + I2CAL_set_data_for_output(); + return !bit; } /* @@ -495,25 +495,25 @@ ReceiveI2CAck(void) unsigned char ReceiveI2CData(void) { - unsigned char data = 0; - unsigned char x; - - /* make sure the data line is released */ - I2CAL_set_data_for_input(); - I2CAL_output_data(1); - - /* shift in the data */ - for (x = 0; x < 8; x++) { - /* shift the data left */ - I2CAL_output_clock(1); - data <<= 1; - data |= I2CAL_input_data(); - I2CAL_output_clock(0); - } - - I2CAL_set_data_for_output(); - I2CAL_output_data(1); - return data; + unsigned char data = 0; + unsigned char x; + + /* make sure the data line is released */ + I2CAL_set_data_for_input(); + I2CAL_output_data(1); + + /* shift in the data */ + for (x = 0; x < 8; x++) { + /* shift the data left */ + I2CAL_output_clock(1); + data <<= 1; + data |= I2CAL_input_data(); + I2CAL_output_clock(0); + } + + I2CAL_set_data_for_output(); + I2CAL_output_data(1); + return data; } /* @@ -535,25 +535,25 @@ int gfx_i2c_init(void) #endif { - int errc; + int errc; - /* init I2CAL */ - errc = I2CAL_init(); - if (errc) - return errc; + /* init I2CAL */ + errc = I2CAL_init(); + if (errc) + return errc; - /* set the clock and data lines to the proper states */ - I2CAL_output_clock(1); - I2CAL_output_data(1); - I2CAL_set_data_for_output(); + /* set the clock and data lines to the proper states */ + I2CAL_output_clock(1); + I2CAL_output_data(1); + I2CAL_set_data_for_output(); - SendI2CStart(); - SendI2CStop(); - SendI2CStop(); + SendI2CStart(); + SendI2CStop(); + SendI2CStop(); - g_initialized = 1; + g_initialized = 1; - return 0; + return 0; } /* @@ -575,50 +575,50 @@ void gfx_i2c_cleanup(void) #endif { - if (g_initialized) { + if (g_initialized) { - /* set the clock and data lines to a harmless state */ - I2CAL_output_clock(1); - I2CAL_output_data(1); + /* set the clock and data lines to a harmless state */ + I2CAL_output_clock(1); + I2CAL_output_data(1); - g_initialized = 0; - } + g_initialized = 0; + } - I2CAL_cleanup(); + I2CAL_cleanup(); } int I2CAL_init(void) { - unsigned long l_reg; - unsigned short reg; + unsigned long l_reg; + unsigned short reg; - /* initialize the i2c port. */ - l_reg = gfx_pci_config_read(CS5530_GPIO); + /* initialize the i2c port. */ + l_reg = gfx_pci_config_read(CS5530_GPIO); - if (l_reg != 0x01001078) - return 1; + if (l_reg != 0x01001078) + return 1; - l_reg = gfx_pci_config_read(CS5530_GPIO); - reg = (unsigned short)l_reg; + l_reg = gfx_pci_config_read(CS5530_GPIO); + reg = (unsigned short) l_reg; - /* both outputs, both high. */ - reg |= (SDADIR | SCLDIR | SDA | SCL); - l_reg = reg; - gfx_pci_config_write(CS5530_GPIO, l_reg); + /* both outputs, both high. */ + reg |= (SDADIR | SCLDIR | SDA | SCL); + l_reg = reg; + gfx_pci_config_write(CS5530_GPIO, l_reg); - g_initialized = 1; + g_initialized = 1; - return 0; + return 0; } void I2CAL_cleanup(void) { - if (g_initialized) { + if (g_initialized) { - g_initialized = 0; - } + g_initialized = 0; + } } /* @@ -631,23 +631,24 @@ I2CAL_cleanup(void) void I2CAL_output_clock(int inState) { - unsigned short reg; - unsigned long value; + unsigned short reg; + unsigned long value; - value = gfx_pci_config_read(CS5530_GPIO); - reg = (unsigned short)value; + value = gfx_pci_config_read(CS5530_GPIO); + reg = (unsigned short) value; - if (inState) { /* write a 1. */ - reg |= SCL; - } else { /* write a 0. */ - reg &= ~SCL; - } + if (inState) { /* write a 1. */ + reg |= SCL; + } + else { /* write a 0. */ + reg &= ~SCL; + } - value = reg; - gfx_pci_config_write(CS5530_GPIO, value); + value = reg; + gfx_pci_config_write(CS5530_GPIO, value); - /* hold it for a minimum of 4.7us */ - gfx_delay_microseconds(5); + /* hold it for a minimum of 4.7us */ + gfx_delay_microseconds(5); } /* @@ -660,23 +661,24 @@ I2CAL_output_clock(int inState) void I2CAL_output_data(int inState) { - unsigned short reg; - unsigned long value; - - value = gfx_pci_config_read(CS5530_GPIO); - reg = (unsigned short)value; - - if (inState) { /* write a 1. */ - reg |= SDA; - } else { - /* write a 0. */ - reg &= ~SDA; - } - value = reg; - gfx_pci_config_write(CS5530_GPIO, value); - - /* 250 ns setup time */ - gfx_delay_microseconds(1); + unsigned short reg; + unsigned long value; + + value = gfx_pci_config_read(CS5530_GPIO); + reg = (unsigned short) value; + + if (inState) { /* write a 1. */ + reg |= SDA; + } + else { + /* write a 0. */ + reg &= ~SDA; + } + value = reg; + gfx_pci_config_write(CS5530_GPIO, value); + + /* 250 ns setup time */ + gfx_delay_microseconds(1); } /* @@ -689,16 +691,16 @@ I2CAL_output_data(int inState) unsigned char I2CAL_input_data(void) { - unsigned short reg; - unsigned long value; + unsigned short reg; + unsigned long value; - value = gfx_pci_config_read(CS5530_GPIO); - reg = (unsigned short)value; + value = gfx_pci_config_read(CS5530_GPIO); + reg = (unsigned short) value; - if (reg & SDA) - return 1; - else - return 0; + if (reg & SDA) + return 1; + else + return 0; } /* @@ -711,17 +713,17 @@ I2CAL_input_data(void) void I2CAL_set_data_for_input(void) { - unsigned short reg; - unsigned long value; + unsigned short reg; + unsigned long value; - value = gfx_pci_config_read(CS5530_GPIO); - reg = (unsigned short)value; + value = gfx_pci_config_read(CS5530_GPIO); + reg = (unsigned short) value; - reg &= ~SDADIR; + reg &= ~SDADIR; - value = reg; + value = reg; - gfx_pci_config_write(CS5530_GPIO, value); + gfx_pci_config_write(CS5530_GPIO, value); } /* @@ -734,15 +736,15 @@ I2CAL_set_data_for_input(void) void I2CAL_set_data_for_output(void) { - unsigned short reg; - unsigned long value; + unsigned short reg; + unsigned long value; - value = gfx_pci_config_read(CS5530_GPIO); - reg = (unsigned short)value; - reg |= SDADIR; - value = reg; + value = gfx_pci_config_read(CS5530_GPIO); + reg = (unsigned short) value; + reg |= SDADIR; + value = reg; - gfx_pci_config_write(CS5530_GPIO, value); + gfx_pci_config_write(CS5530_GPIO, value); } diff --git a/src/gfx/init_gu1.c b/src/gfx/init_gu1.c index 09fb79c..424ee86 100644 --- a/src/gfx/init_gu1.c +++ b/src/gfx/init_gu1.c @@ -149,18 +149,18 @@ unsigned long gu1_get_vip_register_base(void); unsigned char gfx_gxm_config_read(unsigned char index) { - unsigned char value = 0xFF; - unsigned char lock; + unsigned char value = 0xFF; + unsigned char lock; - OUTB(0x22, GXM_CONFIG_CCR3); - lock = INB(0x23); - OUTB(0x22, GXM_CONFIG_CCR3); - OUTB(0x23, (unsigned char)(lock | 0x10)); - OUTB(0x22, index); - value = INB(0x23); - OUTB(0x22, GXM_CONFIG_CCR3); - OUTB(0x23, lock); - return (value); + OUTB(0x22, GXM_CONFIG_CCR3); + lock = INB(0x23); + OUTB(0x22, GXM_CONFIG_CCR3); + OUTB(0x23, (unsigned char) (lock | 0x10)); + OUTB(0x22, index); + value = INB(0x23); + OUTB(0x22, GXM_CONFIG_CCR3); + OUTB(0x23, lock); + return (value); } /*----------------------------------------------------------------------------- @@ -178,58 +178,59 @@ unsigned long gfx_get_core_freq(void) #endif { - unsigned char dir0, dir1; + unsigned char dir0, dir1; - dir0 = gfx_gxm_config_read(GXM_CONFIG_DIR0) & 0x0F; - dir1 = gfx_gxm_config_read(GXM_CONFIG_DIR1); + dir0 = gfx_gxm_config_read(GXM_CONFIG_DIR0) & 0x0F; + dir1 = gfx_gxm_config_read(GXM_CONFIG_DIR1); - /* REVISION 4.0 AND UP */ + /* REVISION 4.0 AND UP */ - if (dir1 >= 0x50) { - switch (dir0) { - case 0: - case 2: - return 133; + if (dir1 >= 0x50) { + switch (dir0) { + case 0: + case 2: + return 133; - case 5: - return 166; - case 3: - return 200; - case 6: - return 233; - case 7: - return 266; - case 4: - return 300; - case 1: - return 333; - default: - return (0); - } - } else { - switch (dir0) { - case 0: - case 2: - return 133; + case 5: + return 166; + case 3: + return 200; + case 6: + return 233; + case 7: + return 266; + case 4: + return 300; + case 1: + return 333; + default: + return (0); + } + } + else { + switch (dir0) { + case 0: + case 2: + return 133; - case 7: - return 166; + case 7: + return 166; - case 1: - case 3: - return 200; + case 1: + case 3: + return 200; - case 4: - case 6: - return 233; + case 4: + case 6: + return 233; - case 5: - return 266; - default: - return (0); - } - } - return (0); + case 5: + return 266; + default: + return (0); + } + } + return (0); } /*----------------------------------------------------------------------------- @@ -246,11 +247,11 @@ unsigned long gfx_get_cpu_register_base(void) #endif { - unsigned long base; + unsigned long base; - base = (unsigned long)gfx_gxm_config_read(GXM_CONFIG_GCR); - base = (base & 0x03) << 30; - return (base); + base = (unsigned long) gfx_gxm_config_read(GXM_CONFIG_GCR); + base = (base & 0x03) << 30; + return (base); } /*----------------------------------------------------------------------------- @@ -271,13 +272,13 @@ unsigned long gfx_get_frame_buffer_base(void) #endif { - unsigned long base; + unsigned long base; - base = (unsigned long)gfx_gxm_config_read(GXM_CONFIG_GCR); - base = (base & 0x03) << 30; - if (base) - base |= 0x00800000; - return (base); + base = (unsigned long) gfx_gxm_config_read(GXM_CONFIG_GCR); + base = (base & 0x03) << 30; + if (base) + base |= 0x00800000; + return (base); } /*----------------------------------------------------------------------------- @@ -297,9 +298,9 @@ gfx_get_frame_buffer_size(void) #endif { #if FB4MB - return (0x00400000); + return (0x00400000); #else - return (0x00200000); + return (0x00200000); #endif } @@ -321,13 +322,13 @@ unsigned long gfx_get_vid_register_base(void) #endif { - unsigned long base; + unsigned long base; - base = (unsigned long)gfx_gxm_config_read(GXM_CONFIG_GCR); - base = (base & 0x03) << 30; - if (base) - base |= 0x00010000; - return (base); + base = (unsigned long) gfx_gxm_config_read(GXM_CONFIG_GCR); + base = (base & 0x03) << 30; + if (base) + base |= 0x00010000; + return (base); } /*----------------------------------------------------------------------------- @@ -349,15 +350,15 @@ unsigned long gfx_get_vip_register_base(void) #endif { - unsigned long base = 0; + unsigned long base = 0; - if ((gfx_cpu_version & 0xFF) == GFX_CPU_SC1200) { - base = (unsigned long)gfx_gxm_config_read(GXM_CONFIG_GCR); - base = (base & 0x03) << 30; - if (base) - base |= 0x00015000; - } - return (base); + if ((gfx_cpu_version & 0xFF) == GFX_CPU_SC1200) { + base = (unsigned long) gfx_gxm_config_read(GXM_CONFIG_GCR); + base = (base & 0x03) << 30; + if (base) + base |= 0x00015000; + } + return (base); } /* END OF FILE */ diff --git a/src/gfx/init_gu2.c b/src/gfx/init_gu2.c index 143ce52..97cc7e0 100644 --- a/src/gfx/init_gu2.c +++ b/src/gfx/init_gu2.c @@ -154,18 +154,18 @@ unsigned long gfx_get_core_freq(void) #endif { - unsigned long value; + unsigned long value; - /* CPU SPEED IS REPORTED BY A VSM IN VSA II */ - /* Virtual Register Class = 0x12 (Sysinfo) */ - /* CPU Speed Register = 0x01 */ + /* CPU SPEED IS REPORTED BY A VSM IN VSA II */ + /* Virtual Register Class = 0x12 (Sysinfo) */ + /* CPU Speed Register = 0x01 */ - OUTW(0xAC1C, 0xFC53); - OUTW(0xAC1C, 0x1201); + OUTW(0xAC1C, 0xFC53); + OUTW(0xAC1C, 0x1201); - value = (unsigned long)(INW(0xAC1E)); + value = (unsigned long) (INW(0xAC1E)); - return (value); + return (value); } /*----------------------------------------------------------------------------- @@ -182,7 +182,7 @@ unsigned long gfx_get_cpu_register_base(void) #endif { - return gfx_pci_config_read(0x80000918); + return gfx_pci_config_read(0x80000918); } /*----------------------------------------------------------------------------- @@ -199,7 +199,7 @@ unsigned long gfx_get_graphics_register_base(void) #endif { - return gfx_pci_config_read(0x80000914); + return gfx_pci_config_read(0x80000914); } /*----------------------------------------------------------------------------- @@ -216,7 +216,7 @@ unsigned long gfx_get_frame_buffer_base(void) #endif { - return gfx_pci_config_read(0x80000910); + return gfx_pci_config_read(0x80000910); } /*----------------------------------------------------------------------------- @@ -233,18 +233,18 @@ unsigned long gfx_get_frame_buffer_size(void) #endif { - unsigned long value; + unsigned long value; - /* FRAME BUFFER SIZE IS REPORTED BY A VSM IN VSA II */ - /* Virtual Register Class = 0x02 */ - /* VG_MEM_SIZE (512KB units) = 0x00 */ + /* FRAME BUFFER SIZE IS REPORTED BY A VSM IN VSA II */ + /* Virtual Register Class = 0x02 */ + /* VG_MEM_SIZE (512KB units) = 0x00 */ - OUTW(0xAC1C, 0xFC53); - OUTW(0xAC1C, 0x0200); + OUTW(0xAC1C, 0xFC53); + OUTW(0xAC1C, 0x0200); - value = (unsigned long)(INW(0xAC1E)) & 0xFFl; + value = (unsigned long) (INW(0xAC1E)) & 0xFFl; - return (value << 19); + return (value << 19); } /*----------------------------------------------------------------------------- @@ -261,7 +261,7 @@ unsigned long gfx_get_vid_register_base(void) #endif { - return gfx_pci_config_read(0x8000091C); + return gfx_pci_config_read(0x8000091C); } /* END OF FILE */ diff --git a/src/gfx/msr_rdcl.c b/src/gfx/msr_rdcl.c index ce3ce05..57489bb 100644 --- a/src/gfx/msr_rdcl.c +++ b/src/gfx/msr_rdcl.c @@ -131,17 +131,17 @@ int redcloud_msr_init(void); DEV_STATUS redcloud_id_msr_device(MSR * pDev, unsigned long address); DEV_STATUS redcloud_get_msr_dev_address(unsigned int device, - unsigned long *address); + unsigned long *address); DEV_STATUS redcloud_get_glink_id_at_address(unsigned int *device, - unsigned long address); + unsigned long address); DEV_STATUS redcloud_msr_read(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue); + Q_WORD * msrValue); DEV_STATUS redcloud_msr_write(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue); + Q_WORD * msrValue); -void redcloud_build_mbus_tree(void); /* private routine definition */ -int redcloud_init_msr_devices(MSR aDev[], unsigned int array_size); /* private routine definition */ -DEV_STATUS redcloud_find_msr_device(MSR * pDev); /* private routine definition */ +void redcloud_build_mbus_tree(void); /* private routine definition */ +int redcloud_init_msr_devices(MSR aDev[], unsigned int array_size); /* private routine definition */ +DEV_STATUS redcloud_find_msr_device(MSR * pDev); /* private routine definition */ /* REDCLOUD MSR BITMASKS */ @@ -158,24 +158,24 @@ DEV_STATUS redcloud_find_msr_device(MSR * pDev); /* private routine definition * /* REDCLOUD and CS5535 MSR DEVICES */ MSR msrDev[] = { - {FOUND, RC_CC_MBIU, RC_MB0_MBIU0}, - {FOUND, RC_CC_MBIU, RC_MB0_MBIU1}, - {NOT_KNOWN, RC_CC_MCP, FAKE_ADDRESS}, - {NOT_KNOWN, RC_CC_MPCI, FAKE_ADDRESS}, - {NOT_KNOWN, RC_CC_MC, FAKE_ADDRESS}, - {NOT_KNOWN, RC_CC_GP, FAKE_ADDRESS}, - {NOT_KNOWN, RC_CC_VG, FAKE_ADDRESS}, - {NOT_KNOWN, RC_CC_DF, FAKE_ADDRESS}, - {NOT_KNOWN, RC_CC_FG, FAKE_ADDRESS}, - {FOUND, RC_CC_VA, RC_MB0_CPU}, - {FOUND, CP_CC_MBIU, CP_MB0_MBIU0}, - {NOT_KNOWN, CP_CC_MPCI, FAKE_ADDRESS}, - {NOT_KNOWN, CP_CC_USB2, FAKE_ADDRESS}, - {NOT_KNOWN, CP_CC_ATAC, FAKE_ADDRESS}, - {NOT_KNOWN, CP_CC_MDD, FAKE_ADDRESS}, - {NOT_KNOWN, CP_CC_ACC, FAKE_ADDRESS}, - {NOT_KNOWN, CP_CC_USB1, FAKE_ADDRESS}, - {NOT_KNOWN, CP_CC_MCP, FAKE_ADDRESS}, + {FOUND, RC_CC_MBIU, RC_MB0_MBIU0}, + {FOUND, RC_CC_MBIU, RC_MB0_MBIU1}, + {NOT_KNOWN, RC_CC_MCP, FAKE_ADDRESS}, + {NOT_KNOWN, RC_CC_MPCI, FAKE_ADDRESS}, + {NOT_KNOWN, RC_CC_MC, FAKE_ADDRESS}, + {NOT_KNOWN, RC_CC_GP, FAKE_ADDRESS}, + {NOT_KNOWN, RC_CC_VG, FAKE_ADDRESS}, + {NOT_KNOWN, RC_CC_DF, FAKE_ADDRESS}, + {NOT_KNOWN, RC_CC_FG, FAKE_ADDRESS}, + {FOUND, RC_CC_VA, RC_MB0_CPU}, + {FOUND, CP_CC_MBIU, CP_MB0_MBIU0}, + {NOT_KNOWN, CP_CC_MPCI, FAKE_ADDRESS}, + {NOT_KNOWN, CP_CC_USB2, FAKE_ADDRESS}, + {NOT_KNOWN, CP_CC_ATAC, FAKE_ADDRESS}, + {NOT_KNOWN, CP_CC_MDD, FAKE_ADDRESS}, + {NOT_KNOWN, CP_CC_ACC, FAKE_ADDRESS}, + {NOT_KNOWN, CP_CC_USB1, FAKE_ADDRESS}, + {NOT_KNOWN, CP_CC_MCP, FAKE_ADDRESS}, }; #define NUM_DEVS sizeof(msrDev) / sizeof(struct msr) @@ -215,44 +215,44 @@ int gfx_msr_init(void) #endif { - Q_WORD msrValue; - int return_value = 1; + Q_WORD msrValue; + int return_value = 1; - /* CHECK FOR VALID MBUS CONFIGURATION */ - /* The CPU and the two MBIUs are assumed to be at known static addresses, so */ - /* we will check the device IDs at these addresses as proof of a valid mbus */ - /* configuration. */ + /* CHECK FOR VALID MBUS CONFIGURATION */ + /* The CPU and the two MBIUs are assumed to be at known static addresses, so */ + /* we will check the device IDs at these addresses as proof of a valid mbus */ + /* configuration. */ - MSR_READ(MBD_MSR_CAP, RC_MB0_CPU, &(msrValue.high), &(msrValue.low)); - if (GET_DEVICE_ID(msrValue.high, msrValue.low) != RC_CC_VA) - return_value = 0; + MSR_READ(MBD_MSR_CAP, RC_MB0_CPU, &(msrValue.high), &(msrValue.low)); + if (GET_DEVICE_ID(msrValue.high, msrValue.low) != RC_CC_VA) + return_value = 0; - MSR_READ(MBD_MSR_CAP, RC_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); - if (GET_DEVICE_ID(msrValue.high, msrValue.low) != RC_CC_MBIU) - return_value = 0; + MSR_READ(MBD_MSR_CAP, RC_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); + if (GET_DEVICE_ID(msrValue.high, msrValue.low) != RC_CC_MBIU) + return_value = 0; - MSR_READ(MBD_MSR_CAP, RC_MB0_MBIU1, &(msrValue.high), &(msrValue.low)); - if (GET_DEVICE_ID(msrValue.high, msrValue.low) != RC_CC_MBIU) - return_value = 0; + MSR_READ(MBD_MSR_CAP, RC_MB0_MBIU1, &(msrValue.high), &(msrValue.low)); + if (GET_DEVICE_ID(msrValue.high, msrValue.low) != RC_CC_MBIU) + return_value = 0; - /* ENUMERATE VALID BUS */ - /* If all static devices were identified, continue with the enumeration */ + /* ENUMERATE VALID BUS */ + /* If all static devices were identified, continue with the enumeration */ - if (return_value) { - /* OPTIMIZATION */ - /* Build a local copy of the MBUS topology. This allows us to */ - /* quickly search the entire MBUS for a given device ID without */ - /* repeated MSR accesses. */ + if (return_value) { + /* OPTIMIZATION */ + /* Build a local copy of the MBUS topology. This allows us to */ + /* quickly search the entire MBUS for a given device ID without */ + /* repeated MSR accesses. */ - redcloud_build_mbus_tree(); + redcloud_build_mbus_tree(); - /* INITIALIZE MSR DEVICES */ + /* INITIALIZE MSR DEVICES */ - return_value = redcloud_init_msr_devices(msrDev, NUM_DEVS); + return_value = redcloud_init_msr_devices(msrDev, NUM_DEVS); - } + } - return return_value; + return return_value; } @@ -270,157 +270,159 @@ gfx_msr_init(void) void redcloud_build_mbus_tree(void) { - unsigned long mbiu_port_count, reflective; - unsigned long port; - Q_WORD msrValue; + unsigned long mbiu_port_count, reflective; + unsigned long port; + Q_WORD msrValue; - /* */ - /* ENUMERATE MBIU0 */ - /* */ + /* */ + /* ENUMERATE MBIU0 */ + /* */ - /* COUNT MBIU PORTS */ + /* COUNT MBIU PORTS */ - MSR_READ(MBIU_CAP, RC_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); - mbiu_port_count = GET_NUM_PORTS(msrValue.high, msrValue.low); + MSR_READ(MBIU_CAP, RC_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); + mbiu_port_count = GET_NUM_PORTS(msrValue.high, msrValue.low); - /* FIND REFLECTIVE PORT */ - /* Query the MBIU for the port through which we are communicating. */ - /* We will avoid accesses to this port to avoid a self-reference. */ + /* FIND REFLECTIVE PORT */ + /* Query the MBIU for the port through which we are communicating. */ + /* We will avoid accesses to this port to avoid a self-reference. */ - MSR_READ(MBIU_WHOAMI, RC_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); - reflective = msrValue.low & WHOAMI_MASK; + MSR_READ(MBIU_WHOAMI, RC_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); + reflective = msrValue.low & WHOAMI_MASK; - /* ENUMERATE ALL PORTS */ - /* For every possible port, set the MBIU.deviceId to something. */ + /* ENUMERATE ALL PORTS */ + /* For every possible port, set the MBIU.deviceId to something. */ - for (port = 0; port < 8; port++) { - /* FILL IN CLAIMED FIELD */ - /* All MBIU ports can only be assigned to one device from the */ - /* Durango table */ + for (port = 0; port < 8; port++) { + /* FILL IN CLAIMED FIELD */ + /* All MBIU ports can only be assigned to one device from the */ + /* Durango table */ - MBIU0[port].claimed = 0; + MBIU0[port].claimed = 0; - /* MBIU0 PORT NUMBERS ARE IN ADDRESS BITS 31:29 */ + /* MBIU0 PORT NUMBERS ARE IN ADDRESS BITS 31:29 */ - MBIU0[port].address = port << 29; + MBIU0[port].address = port << 29; - /* SPECIAL CASE FOR MBIU0 */ - /* MBIU0 port 0 is a special case, as it points back to MBIU0. MBIU0 */ - /* responds at address 0x40000xxx, which does not equal 0 << 29. */ + /* SPECIAL CASE FOR MBIU0 */ + /* MBIU0 port 0 is a special case, as it points back to MBIU0. MBIU0 */ + /* responds at address 0x40000xxx, which does not equal 0 << 29. */ - if (port == 0) - MBIU0[port].deviceId = RC_CC_MBIU; - else if (port == reflective) - MBIU0[port].deviceId = REFLECTIVE; - else if (port > mbiu_port_count) - MBIU0[port].deviceId = NOT_POPULATED; - else { - MSR_READ(MBD_MSR_CAP, MBIU0[port].address, &(msrValue.high), - &(msrValue.low)); - MBIU0[port].deviceId = GET_DEVICE_ID(msrValue.high, msrValue.low); - } - } - - /* */ - /* ENUMERATE MBIU1 */ - /* */ - - /* COUNT MBIU PORTS */ - - MSR_READ(MBIU_CAP, RC_MB0_MBIU1, &(msrValue.high), &(msrValue.low)); - mbiu_port_count = GET_NUM_PORTS(msrValue.high, msrValue.low); - - /* FIND REFLECTIVE PORT */ - /* Query the MBIU for the port through which we are communicating. */ - /* We will avoid accesses to this port to avoid a self-reference. */ - - MSR_READ(MBIU_WHOAMI, RC_MB0_MBIU1, &(msrValue.high), &(msrValue.low)); - reflective = msrValue.low & WHOAMI_MASK; - - /* ENUMERATE ALL PORTS */ - /* For every possible port, set the MBIU.deviceId to something. */ - - for (port = 0; port < 8; port++) { - /* FILL IN CLAIMED FIELD */ - /* All MBIU ports can only be assigned to one device from the */ - /* Durango table */ - - MBIU1[port].claimed = 0; - - /* MBIU1 PORT NUMBERS ARE IN 28:26 AND 31:29 = 010B */ - - MBIU1[port].address = (0x02l << 29) + (port << 26); - - if (port == reflective) - MBIU1[port].deviceId = REFLECTIVE; - else if (port > mbiu_port_count) - MBIU1[port].deviceId = NOT_POPULATED; - else { - MSR_READ(MBD_MSR_CAP, MBIU1[port].address, &(msrValue.high), - &(msrValue.low)); - MBIU1[port].deviceId = GET_DEVICE_ID(msrValue.high, msrValue.low); - } - } - - /* */ - /* ENUMERATE MBIU2 (CS5535) */ - /* (if present) */ - - MSR_READ(MBD_MSR_CAP, CP_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); - if (GET_DEVICE_ID(msrValue.high, msrValue.low) == CP_CC_MBIU) { - /* COUNT MBIU PORTS */ - - MSR_READ(MBIU_CAP, CP_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); - mbiu_port_count = GET_NUM_PORTS(msrValue.high, msrValue.low); - - /* FIND REFLECTIVE PORT */ - /* Query the MBIU for the port through which we are communicating. */ - /* We will avoid accesses to this port to avoid a self-reference. */ - - MSR_READ(MBIU_WHOAMI, CP_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); - reflective = msrValue.low & WHOAMI_MASK; - - /* ENUMERATE ALL PORTS */ - /* For every possible port, set the MBIU.deviceId to something. */ - - for (port = 0; port < 8; port++) { - /* FILL IN CLAIMED FIELD */ - /* All MBIU ports can only be assigned to one device from the */ - /* Durango table */ - - MBIU2[port].claimed = 0; - - /* MBIU2 PORT NUMBERS ARE IN 22:20 AND 31:23 = 010100010B */ - - MBIU2[port].address = - (0x02l << 29) + (0x04l << 26) + (0x02l << 23) + (port << 20); - - if (port == reflective) - MBIU2[port].deviceId = REFLECTIVE; - else if (port > mbiu_port_count) - MBIU2[port].deviceId = NOT_POPULATED; - else { - MSR_READ(MBD_MSR_CAP, MBIU2[port].address, &(msrValue.high), - &(msrValue.low)); - MBIU2[port].deviceId = GET_DEVICE_ID(msrValue.high, msrValue.low); - } - } - } else { - /* NO 5535 */ - /* If the CS5535 is not installed, fill in the cached table */ - /* with the 'NOT_INSTALLED' flag. Also, fill in the device */ - /* status from NOT_KNOWN to REQ_NOT_INSTALLED. */ - - for (port = 0; port < 8; port++) { - MBIU2[port].claimed = 0; - MBIU2[port].deviceId = NOT_INSTALLED; - MBIU2[port].address = - (0x02l << 29) + (0x04l << 26) + (0x02l << 23) + (port << 20); - } - for (port = CP_INDEX_START; port <= CP_INDEX_STOP; port++) { - msrDev[port].Present = REQ_NOT_INSTALLED; - } - } + if (port == 0) + MBIU0[port].deviceId = RC_CC_MBIU; + else if (port == reflective) + MBIU0[port].deviceId = REFLECTIVE; + else if (port > mbiu_port_count) + MBIU0[port].deviceId = NOT_POPULATED; + else { + MSR_READ(MBD_MSR_CAP, MBIU0[port].address, &(msrValue.high), + &(msrValue.low)); + MBIU0[port].deviceId = GET_DEVICE_ID(msrValue.high, msrValue.low); + } + } + + /* */ + /* ENUMERATE MBIU1 */ + /* */ + + /* COUNT MBIU PORTS */ + + MSR_READ(MBIU_CAP, RC_MB0_MBIU1, &(msrValue.high), &(msrValue.low)); + mbiu_port_count = GET_NUM_PORTS(msrValue.high, msrValue.low); + + /* FIND REFLECTIVE PORT */ + /* Query the MBIU for the port through which we are communicating. */ + /* We will avoid accesses to this port to avoid a self-reference. */ + + MSR_READ(MBIU_WHOAMI, RC_MB0_MBIU1, &(msrValue.high), &(msrValue.low)); + reflective = msrValue.low & WHOAMI_MASK; + + /* ENUMERATE ALL PORTS */ + /* For every possible port, set the MBIU.deviceId to something. */ + + for (port = 0; port < 8; port++) { + /* FILL IN CLAIMED FIELD */ + /* All MBIU ports can only be assigned to one device from the */ + /* Durango table */ + + MBIU1[port].claimed = 0; + + /* MBIU1 PORT NUMBERS ARE IN 28:26 AND 31:29 = 010B */ + + MBIU1[port].address = (0x02l << 29) + (port << 26); + + if (port == reflective) + MBIU1[port].deviceId = REFLECTIVE; + else if (port > mbiu_port_count) + MBIU1[port].deviceId = NOT_POPULATED; + else { + MSR_READ(MBD_MSR_CAP, MBIU1[port].address, &(msrValue.high), + &(msrValue.low)); + MBIU1[port].deviceId = GET_DEVICE_ID(msrValue.high, msrValue.low); + } + } + + /* */ + /* ENUMERATE MBIU2 (CS5535) */ + /* (if present) */ + + MSR_READ(MBD_MSR_CAP, CP_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); + if (GET_DEVICE_ID(msrValue.high, msrValue.low) == CP_CC_MBIU) { + /* COUNT MBIU PORTS */ + + MSR_READ(MBIU_CAP, CP_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); + mbiu_port_count = GET_NUM_PORTS(msrValue.high, msrValue.low); + + /* FIND REFLECTIVE PORT */ + /* Query the MBIU for the port through which we are communicating. */ + /* We will avoid accesses to this port to avoid a self-reference. */ + + MSR_READ(MBIU_WHOAMI, CP_MB0_MBIU0, &(msrValue.high), &(msrValue.low)); + reflective = msrValue.low & WHOAMI_MASK; + + /* ENUMERATE ALL PORTS */ + /* For every possible port, set the MBIU.deviceId to something. */ + + for (port = 0; port < 8; port++) { + /* FILL IN CLAIMED FIELD */ + /* All MBIU ports can only be assigned to one device from the */ + /* Durango table */ + + MBIU2[port].claimed = 0; + + /* MBIU2 PORT NUMBERS ARE IN 22:20 AND 31:23 = 010100010B */ + + MBIU2[port].address = + (0x02l << 29) + (0x04l << 26) + (0x02l << 23) + (port << 20); + + if (port == reflective) + MBIU2[port].deviceId = REFLECTIVE; + else if (port > mbiu_port_count) + MBIU2[port].deviceId = NOT_POPULATED; + else { + MSR_READ(MBD_MSR_CAP, MBIU2[port].address, &(msrValue.high), + &(msrValue.low)); + MBIU2[port].deviceId = + GET_DEVICE_ID(msrValue.high, msrValue.low); + } + } + } + else { + /* NO 5535 */ + /* If the CS5535 is not installed, fill in the cached table */ + /* with the 'NOT_INSTALLED' flag. Also, fill in the device */ + /* status from NOT_KNOWN to REQ_NOT_INSTALLED. */ + + for (port = 0; port < 8; port++) { + MBIU2[port].claimed = 0; + MBIU2[port].deviceId = NOT_INSTALLED; + MBIU2[port].address = + (0x02l << 29) + (0x04l << 26) + (0x02l << 23) + (port << 20); + } + for (port = CP_INDEX_START; port <= CP_INDEX_STOP; port++) { + msrDev[port].Present = REQ_NOT_INSTALLED; + } + } } /*------------------------------------------------------------------ @@ -444,28 +446,28 @@ redcloud_build_mbus_tree(void) int redcloud_init_msr_devices(MSR aDev[], unsigned int array_size) { - unsigned int i, issues = 0; + unsigned int i, issues = 0; - /* TRY TO FIND EACH ITEM IN THE ARRAY */ + /* TRY TO FIND EACH ITEM IN THE ARRAY */ - for (i = 0; i < array_size; i++) { - /* IGNORE DEVICES THAT ARE ALREADY FOUND */ - /* The addresses for "found" devices are already known. */ + for (i = 0; i < array_size; i++) { + /* IGNORE DEVICES THAT ARE ALREADY FOUND */ + /* The addresses for "found" devices are already known. */ - if (aDev[i].Present == FOUND || aDev[i].Present == REQ_NOT_INSTALLED) - continue; + if (aDev[i].Present == FOUND || aDev[i].Present == REQ_NOT_INSTALLED) + continue; - /* TRY TO FIND THE DEVICE ON THE MBUS */ + /* TRY TO FIND THE DEVICE ON THE MBUS */ - aDev[i].Present = redcloud_find_msr_device(&aDev[i]); + aDev[i].Present = redcloud_find_msr_device(&aDev[i]); - /* INCREMENT ERROR COUNT IF DEVICE NOT FOUND */ + /* INCREMENT ERROR COUNT IF DEVICE NOT FOUND */ - if (aDev[i].Present != FOUND) - issues++; - } + if (aDev[i].Present != FOUND) + issues++; + } - return (issues == 0); + return (issues == 0); } /*------------------------------------------------------------------ @@ -485,54 +487,54 @@ redcloud_init_msr_devices(MSR aDev[], unsigned int array_size) DEV_STATUS redcloud_find_msr_device(MSR * pDev) { - unsigned int i; - - /* SEARCH DURANGO'S CACHED MBUS TOPOLOGY */ - /* This gets a little tricky. As the only identifier we have for each */ - /* device is the device ID and we have multiple devices of the same type */ - /* MCP, MPCI, USB, etc. we need to make some assumptions based on table */ - /* order. These are as follows: */ - /* 1. All Redcloud nodes are searched first, as we assume that they */ - /* are first in the table. */ - /* 2. If two devices have the same device ID and are found on the same */ - /* device (GX2, CS5535, etc.) we assume that they are listed such */ - /* that the first device in the table with this device ID has a lower */ - /* port address. */ - /* 3. After a device ID has been matched, the port is marked as */ - /* 'claimed', such that future enumerations continue searching the */ - /* GeodeLink topology. */ - - /* SEARCH MBIU0 */ - - for (i = 0; i < 8; i++) { - if (MBIU0[i].deviceId == pDev->Id && !(MBIU0[i].claimed)) { - MBIU0[i].claimed = 1; - pDev->Address = MBIU0[i].address; - return FOUND; - } - } - - /* SEARCH MBIU1 */ - - for (i = 0; i < 8; i++) { - if (MBIU1[i].deviceId == pDev->Id && !(MBIU1[i].claimed)) { - MBIU1[i].claimed = 1; - pDev->Address = MBIU1[i].address; - return FOUND; - } - } - - /* SEARCH MBIU2 */ - - for (i = 0; i < 8; i++) { - if (MBIU2[i].deviceId == pDev->Id && !(MBIU2[i].claimed)) { - MBIU2[i].claimed = 1; - pDev->Address = MBIU2[i].address; - return FOUND; - } - } - - return REQ_NOT_FOUND; + unsigned int i; + + /* SEARCH DURANGO'S CACHED MBUS TOPOLOGY */ + /* This gets a little tricky. As the only identifier we have for each */ + /* device is the device ID and we have multiple devices of the same type */ + /* MCP, MPCI, USB, etc. we need to make some assumptions based on table */ + /* order. These are as follows: */ + /* 1. All Redcloud nodes are searched first, as we assume that they */ + /* are first in the table. */ + /* 2. If two devices have the same device ID and are found on the same */ + /* device (GX2, CS5535, etc.) we assume that they are listed such */ + /* that the first device in the table with this device ID has a lower */ + /* port address. */ + /* 3. After a device ID has been matched, the port is marked as */ + /* 'claimed', such that future enumerations continue searching the */ + /* GeodeLink topology. */ + + /* SEARCH MBIU0 */ + + for (i = 0; i < 8; i++) { + if (MBIU0[i].deviceId == pDev->Id && !(MBIU0[i].claimed)) { + MBIU0[i].claimed = 1; + pDev->Address = MBIU0[i].address; + return FOUND; + } + } + + /* SEARCH MBIU1 */ + + for (i = 0; i < 8; i++) { + if (MBIU1[i].deviceId == pDev->Id && !(MBIU1[i].claimed)) { + MBIU1[i].claimed = 1; + pDev->Address = MBIU1[i].address; + return FOUND; + } + } + + /* SEARCH MBIU2 */ + + for (i = 0; i < 8; i++) { + if (MBIU2[i].deviceId == pDev->Id && !(MBIU2[i].claimed)) { + MBIU2[i].claimed = 1; + pDev->Address = MBIU2[i].address; + return FOUND; + } + } + + return REQ_NOT_FOUND; } /*-------------------------------------------------------------------- @@ -561,14 +563,14 @@ DEV_STATUS gfx_id_msr_device(MSR * pDev, unsigned long address) #endif { - Q_WORD msrValue; + Q_WORD msrValue; - MSR_READ(MBD_MSR_CAP, address, &(msrValue.high), &(msrValue.low)); + MSR_READ(MBD_MSR_CAP, address, &(msrValue.high), &(msrValue.low)); - if (GET_DEVICE_ID(msrValue.high, msrValue.low) == pDev->Id) - return FOUND; - else - return REQ_NOT_FOUND; + if (GET_DEVICE_ID(msrValue.high, msrValue.low) == pDev->Id) + return FOUND; + else + return REQ_NOT_FOUND; } /*-------------------------------------------------------------------- @@ -601,13 +603,13 @@ DEV_STATUS gfx_get_msr_dev_address(unsigned int device, unsigned long *address) #endif { - if (device < NUM_DEVS) { - if (msrDev[device].Present == FOUND) - *address = msrDev[device].Address; + if (device < NUM_DEVS) { + if (msrDev[device].Present == FOUND) + *address = msrDev[device].Address; - return msrDev[device].Present; - } - return NOT_KNOWN; + return msrDev[device].Present; + } + return NOT_KNOWN; } @@ -639,22 +641,24 @@ DEV_STATUS gfx_get_glink_id_at_address(unsigned int *device, unsigned long address) #endif { - int port; - - for (port = 0; port < 8; port++) { - if (MBIU0[port].address == address) { - *device = MBIU0[port].deviceId; - return FOUND; - } else if (MBIU1[port].address == address) { - *device = MBIU1[port].deviceId; - return FOUND; - } else if (MBIU2[port].address == address) { - *device = MBIU2[port].deviceId; - return FOUND; - } - } - - return NOT_KNOWN; + int port; + + for (port = 0; port < 8; port++) { + if (MBIU0[port].address == address) { + *device = MBIU0[port].deviceId; + return FOUND; + } + else if (MBIU1[port].address == address) { + *device = MBIU1[port].deviceId; + return FOUND; + } + else if (MBIU2[port].address == address) { + *device = MBIU2[port].deviceId; + return FOUND; + } + } + + return NOT_KNOWN; } @@ -676,20 +680,20 @@ gfx_get_glink_id_at_address(unsigned int *device, unsigned long address) #if GFX_MSR_DYNAMIC DEV_STATUS redcloud_msr_read(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue) + Q_WORD * msrValue) #else DEV_STATUS gfx_msr_read(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue) #endif { - if (device < NUM_DEVS) { - if (msrDev[device].Present == FOUND) - MSR_READ(msrRegister, msrDev[device].Address, &(msrValue->high), - &(msrValue->low)); - - return msrDev[device].Present; - } - return NOT_KNOWN; + if (device < NUM_DEVS) { + if (msrDev[device].Present == FOUND) + MSR_READ(msrRegister, msrDev[device].Address, &(msrValue->high), + &(msrValue->low)); + + return msrDev[device].Present; + } + return NOT_KNOWN; } /*-------------------------------------------------------------------- @@ -711,19 +715,18 @@ gfx_msr_read(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue) #if GFX_MSR_DYNAMIC DEV_STATUS redcloud_msr_write(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue) + Q_WORD * msrValue) #else DEV_STATUS -gfx_msr_write(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue) +gfx_msr_write(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue) #endif { - if (device < NUM_DEVS) { - if (msrDev[device].Present == FOUND) - MSR_WRITE(msrRegister, msrDev[device].Address, &(msrValue->high), - &(msrValue->low)); - - return msrDev[device].Present; - } - return NOT_KNOWN; + if (device < NUM_DEVS) { + if (msrDev[device].Present == FOUND) + MSR_WRITE(msrRegister, msrDev[device].Address, &(msrValue->high), + &(msrValue->low)); + + return msrDev[device].Present; + } + return NOT_KNOWN; } diff --git a/src/gfx/rndr_gu1.c b/src/gfx/rndr_gu1.c index 6d71f59..49480df 100644 --- a/src/gfx/rndr_gu1.c +++ b/src/gfx/rndr_gu1.c @@ -148,53 +148,53 @@ void gu1_set_bpp(unsigned short bpp); void gu1_set_solid_pattern(unsigned long color); void gu1_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparency); + unsigned long data0, unsigned long data1, + unsigned char transparency); void gu1_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned char transparency); + unsigned long data0, unsigned long data1, + unsigned long data2, unsigned long data3, + unsigned char transparency); void gu1_load_color_pattern_line(short y, unsigned long *pattern_8x8); void gu1_set_solid_source(unsigned long color); void gu1_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned short transparent); + unsigned short transparent); void gu1_set_pattern_flags(unsigned short flags); void gu1_set_raster_operation(unsigned char rop); void gu1_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height); + unsigned short width, unsigned short height); void gu1_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long *pattern); + unsigned short width, unsigned short height, + unsigned long *pattern); void gu1_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height); + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height); void gu1_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color); + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color); void gu1_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, - unsigned short height, - unsigned char *data, long pitch); + unsigned short dstx, unsigned short dsty, + unsigned short width, + unsigned short height, + unsigned char *data, long pitch); void gu1_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, - unsigned short height, - unsigned char *data, long pitch, - unsigned long color); + unsigned short dstx, unsigned short dsty, + unsigned short width, + unsigned short height, + unsigned char *data, long pitch, + unsigned long color); void gu1_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, - unsigned short height, unsigned char *data, - short pitch); + unsigned short dstx, unsigned short dsty, + unsigned short width, + unsigned short height, unsigned char *data, + short pitch); void gu1_text_blt(unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data); + unsigned short width, unsigned short height, + unsigned char *data); void gu1_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags); + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags); void gu1_wait_until_idle(void); #if GFX_NO_IO_IN_WAIT_MACROS @@ -210,8 +210,8 @@ void gu1_wait_until_idle(void); void gu1_detect_blt_buffer_base(void); int gu1_test_blt_pending(void); void gu1_solid_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long color); + unsigned short width, unsigned short height, + unsigned long color); /*--------------------------------------------------------------------------- * GFX_SET_BPP @@ -229,37 +229,38 @@ void gfx_set_bpp(unsigned short bpp) #endif { - int control = 0; - unsigned short pitch = gfx_get_display_pitch(); - - GFXbpp = bpp; - - /* DETECT BASE ADDRESSES FOR BLT BUFFERS */ - /* Different for 2K or 3K of scratchpad. Also need to calculate */ - /* the number of pixels that can fit in a BLT buffer - need to */ - /* subtract 16 for alignment considerations. The 2K case, for */ - /* example, is 816 bytes wide, allowing 800 pixels in 8 BPP, which */ - /* means rendering operations won't be split for 800x600. */ - - gu1_detect_blt_buffer_base(); - GFXbufferWidthPixels = GFXbb1Base - GFXbb0Base - 16; - if (bpp > 8) { - /* If 16bpp, divide GFXbufferWidthPixels by 2 */ - GFXbufferWidthPixels >>= 1; - } - - /* SET THE GRAPHICS CONTROLLER BPP AND PITCH */ - if (bpp > 8) { - /* Set the 16bpp bit if necessary */ - control = BC_16BPP; - } - if ((gfx_cpu_version == GFX_CPU_PYRAMID) && (pitch > 2048)) { - control |= BC_FB_WIDTH_4096; - } else if (pitch > 1024) { - control |= BC_FB_WIDTH_2048; - } - GFX_WAIT_BUSY; - WRITE_REG32(GP_BLIT_STATUS, control); + int control = 0; + unsigned short pitch = gfx_get_display_pitch(); + + GFXbpp = bpp; + + /* DETECT BASE ADDRESSES FOR BLT BUFFERS */ + /* Different for 2K or 3K of scratchpad. Also need to calculate */ + /* the number of pixels that can fit in a BLT buffer - need to */ + /* subtract 16 for alignment considerations. The 2K case, for */ + /* example, is 816 bytes wide, allowing 800 pixels in 8 BPP, which */ + /* means rendering operations won't be split for 800x600. */ + + gu1_detect_blt_buffer_base(); + GFXbufferWidthPixels = GFXbb1Base - GFXbb0Base - 16; + if (bpp > 8) { + /* If 16bpp, divide GFXbufferWidthPixels by 2 */ + GFXbufferWidthPixels >>= 1; + } + + /* SET THE GRAPHICS CONTROLLER BPP AND PITCH */ + if (bpp > 8) { + /* Set the 16bpp bit if necessary */ + control = BC_16BPP; + } + if ((gfx_cpu_version == GFX_CPU_PYRAMID) && (pitch > 2048)) { + control |= BC_FB_WIDTH_4096; + } + else if (pitch > 1024) { + control |= BC_FB_WIDTH_2048; + } + GFX_WAIT_BUSY; + WRITE_REG32(GP_BLIT_STATUS, control); } /* @@ -279,23 +280,23 @@ void gfx_set_solid_source(unsigned long color) #endif { - /* CLEAR TRANSPARENCY FLAG */ + /* CLEAR TRANSPARENCY FLAG */ - GFXsourceFlags = 0; + GFXsourceFlags = 0; - /* FORMAT 8 BPP COLOR */ - /* GX requires 8BPP color data be duplicated into bits [15:8]. */ + /* FORMAT 8 BPP COLOR */ + /* GX requires 8BPP color data be duplicated into bits [15:8]. */ - if (GFXbpp == 8) { - color &= 0x00FF; - color |= (color << 8); - } + if (GFXbpp == 8) { + color &= 0x00FF; + color |= (color << 8); + } - /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */ + /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_SRC_COLOR_0, (unsigned short)color); - WRITE_REG16(GP_SRC_COLOR_1, (unsigned short)color); + GFX_WAIT_PENDING; + WRITE_REG16(GP_SRC_COLOR_0, (unsigned short) color); + WRITE_REG16(GP_SRC_COLOR_1, (unsigned short) color); } /* @@ -310,32 +311,32 @@ gfx_set_solid_source(unsigned long color) #if GFX_2DACCEL_DYNAMIC void gu1_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned short transparent) + unsigned short transparent) #else void gfx_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned short transparent) + unsigned short transparent) #endif { - /* SET TRANSPARENCY FLAG */ + /* SET TRANSPARENCY FLAG */ - GFXsourceFlags = transparent ? RM_SRC_TRANSPARENT : 0; + GFXsourceFlags = transparent ? RM_SRC_TRANSPARENT : 0; - /* FORMAT 8 BPP COLOR */ - /* GX requires 8BPP color data be duplicated into bits [15:8]. */ + /* FORMAT 8 BPP COLOR */ + /* GX requires 8BPP color data be duplicated into bits [15:8]. */ - if (GFXbpp == 8) { - bgcolor &= 0x00FF; - bgcolor |= (bgcolor << 8); - fgcolor &= 0x00FF; - fgcolor |= (fgcolor << 8); - } + if (GFXbpp == 8) { + bgcolor &= 0x00FF; + bgcolor |= (bgcolor << 8); + fgcolor &= 0x00FF; + fgcolor |= (fgcolor << 8); + } - /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */ + /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_SRC_COLOR_0, (unsigned short)bgcolor); - WRITE_REG16(GP_SRC_COLOR_1, (unsigned short)fgcolor); + GFX_WAIT_PENDING; + WRITE_REG16(GP_SRC_COLOR_0, (unsigned short) bgcolor); + WRITE_REG16(GP_SRC_COLOR_1, (unsigned short) fgcolor); } /* @@ -358,31 +359,31 @@ void gfx_set_solid_pattern(unsigned long color) #endif { - /* CLEAR TRANSPARENCY FLAG */ + /* CLEAR TRANSPARENCY FLAG */ - GFXsourceFlags = 0; + GFXsourceFlags = 0; - /* SET PATTERN FLAGS */ + /* SET PATTERN FLAGS */ - GFXpatternFlags = 0; + GFXpatternFlags = 0; - /* FORMAT 8 BPP COLOR */ - /* GX requires 8BPP color data be duplicated into bits [15:8]. */ + /* FORMAT 8 BPP COLOR */ + /* GX requires 8BPP color data be duplicated into bits [15:8]. */ - if (GFXbpp == 8) { - color &= 0x00FF; - color |= (color << 8); - } + if (GFXbpp == 8) { + color &= 0x00FF; + color |= (color << 8); + } - /* SAVE THE REFORMATTED COLOR FOR LATER */ - /* Used to call the "GFX_solid_fill" routine for special cases. */ + /* SAVE THE REFORMATTED COLOR FOR LATER */ + /* Used to call the "GFX_solid_fill" routine for special cases. */ - GFXsavedColor = color; + GFXsavedColor = color; - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)color); + GFX_WAIT_PENDING; + WRITE_REG16(GP_PAT_COLOR_0, (unsigned short) color); } /* @@ -395,41 +396,41 @@ gfx_set_solid_pattern(unsigned long color) #if GFX_2DACCEL_DYNAMIC void gu1_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned char transparent) #else void gfx_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned char transparent) #endif { - /* CLEAR TRANSPARENCY FLAG */ + /* CLEAR TRANSPARENCY FLAG */ - GFXsourceFlags = 0; + GFXsourceFlags = 0; - /* SET PATTERN FLAGS */ + /* SET PATTERN FLAGS */ - GFXpatternFlags = transparent ? RM_PAT_MONO | RM_PAT_TRANSPARENT : - RM_PAT_MONO; + GFXpatternFlags = transparent ? RM_PAT_MONO | RM_PAT_TRANSPARENT : + RM_PAT_MONO; - /* FORMAT 8 BPP COLOR */ - /* GXm requires 8BPP color data be duplicated into bits [15:8]. */ + /* FORMAT 8 BPP COLOR */ + /* GXm requires 8BPP color data be duplicated into bits [15:8]. */ - if (GFXbpp == 8) { - bgcolor &= 0x00FF; - bgcolor |= (bgcolor << 8); - fgcolor &= 0x00FF; - fgcolor |= (fgcolor << 8); - } + if (GFXbpp == 8) { + bgcolor &= 0x00FF; + bgcolor |= (bgcolor << 8); + fgcolor &= 0x00FF; + fgcolor |= (fgcolor << 8); + } - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLORS AND DATA */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLORS AND DATA */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)bgcolor); - WRITE_REG16(GP_PAT_COLOR_1, (unsigned short)fgcolor); - WRITE_REG32(GP_PAT_DATA_0, data0); - WRITE_REG32(GP_PAT_DATA_1, data1); + GFX_WAIT_PENDING; + WRITE_REG16(GP_PAT_COLOR_0, (unsigned short) bgcolor); + WRITE_REG16(GP_PAT_COLOR_1, (unsigned short) fgcolor); + WRITE_REG32(GP_PAT_DATA_0, data0); + WRITE_REG32(GP_PAT_DATA_1, data1); } /* @@ -442,48 +443,48 @@ gfx_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, #if GFX_2DACCEL_DYNAMIC void gu1_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned long data2, unsigned long data3, + unsigned char transparent) #else void gfx_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned long data2, unsigned long data3, + unsigned char transparent) #endif { - /* CLEAR TRANSPARENCY FLAG */ + /* CLEAR TRANSPARENCY FLAG */ - GFXsourceFlags = 0; + GFXsourceFlags = 0; - /* SET PATTERN FLAGS */ + /* SET PATTERN FLAGS */ - GFXpatternFlags = transparent ? RM_PAT_MONO | RM_PAT_TRANSPARENT : - RM_PAT_MONO; + GFXpatternFlags = transparent ? RM_PAT_MONO | RM_PAT_TRANSPARENT : + RM_PAT_MONO; - GFXpatternFlags |= RM_PAT_COLOR; - /* FORMAT 8 BPP COLOR */ - /* GXm requires 8BPP color data be duplicated into bits [15:8]. */ + GFXpatternFlags |= RM_PAT_COLOR; + /* FORMAT 8 BPP COLOR */ + /* GXm requires 8BPP color data be duplicated into bits [15:8]. */ - if (GFXbpp == 8) { - bgcolor &= 0x00FF; - bgcolor |= (bgcolor << 8); - fgcolor &= 0x00FF; - fgcolor |= (fgcolor << 8); - } + if (GFXbpp == 8) { + bgcolor &= 0x00FF; + bgcolor |= (bgcolor << 8); + fgcolor &= 0x00FF; + fgcolor |= (fgcolor << 8); + } - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLORS AND DATA */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLORS AND DATA */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)bgcolor); - WRITE_REG16(GP_PAT_COLOR_1, (unsigned short)fgcolor); - WRITE_REG32(GP_PAT_DATA_0, data0); - WRITE_REG32(GP_PAT_DATA_1, data1); - if (GFXbpp > 8) { - WRITE_REG32(GP_PAT_DATA_2, data2); - WRITE_REG32(GP_PAT_DATA_3, data3); - } + GFX_WAIT_PENDING; + WRITE_REG16(GP_PAT_COLOR_0, (unsigned short) bgcolor); + WRITE_REG16(GP_PAT_COLOR_1, (unsigned short) fgcolor); + WRITE_REG32(GP_PAT_DATA_0, data0); + WRITE_REG32(GP_PAT_DATA_1, data1); + if (GFXbpp > 8) { + WRITE_REG32(GP_PAT_DATA_2, data2); + WRITE_REG32(GP_PAT_DATA_3, data3); + } } /* @@ -501,30 +502,30 @@ void gfx_load_color_pattern_line(short y, unsigned long *pattern_8x8) #endif { - /* CLEAR TRANSPARENCY FLAG */ + /* CLEAR TRANSPARENCY FLAG */ - GFXsourceFlags = 0; + GFXsourceFlags = 0; - /* SET PATTERN FLAGS */ + /* SET PATTERN FLAGS */ - GFXpatternFlags = RM_PAT_COLOR; + GFXpatternFlags = RM_PAT_COLOR; - y &= 7; + y &= 7; - if (GFXbpp > 8) - pattern_8x8 += (y << 2); - else - pattern_8x8 += (y << 1); + if (GFXbpp > 8) + pattern_8x8 += (y << 2); + else + pattern_8x8 += (y << 1); - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLORS AND DATA */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLORS AND DATA */ - GFX_WAIT_PENDING; - WRITE_REG32(GP_PAT_DATA_0, pattern_8x8[0]); - WRITE_REG32(GP_PAT_DATA_1, pattern_8x8[1]); - if (GFXbpp > 8) { - WRITE_REG32(GP_PAT_DATA_2, pattern_8x8[2]); - WRITE_REG32(GP_PAT_DATA_3, pattern_8x8[3]); - } + GFX_WAIT_PENDING; + WRITE_REG32(GP_PAT_DATA_0, pattern_8x8[0]); + WRITE_REG32(GP_PAT_DATA_1, pattern_8x8[1]); + if (GFXbpp > 8) { + WRITE_REG32(GP_PAT_DATA_2, pattern_8x8[2]); + WRITE_REG32(GP_PAT_DATA_3, pattern_8x8[3]); + } } /* @@ -543,30 +544,30 @@ void gfx_set_raster_operation(unsigned char rop) #endif { - unsigned short rop16; + unsigned short rop16; - /* GENERATE 16-BIT VERSION OF ROP WITH PATTERN FLAGS */ + /* GENERATE 16-BIT VERSION OF ROP WITH PATTERN FLAGS */ - rop16 = (unsigned short)rop | GFXpatternFlags; - if ((rop & 0x33) ^ ((rop >> 2) & 0x33)) - rop16 |= GFXsourceFlags; + rop16 = (unsigned short) rop | GFXpatternFlags; + if ((rop & 0x33) ^ ((rop >> 2) & 0x33)) + rop16 |= GFXsourceFlags; - /* SAVE ROP FOR LATER COMPARISONS */ - /* Need to have the pattern flags included */ + /* SAVE ROP FOR LATER COMPARISONS */ + /* Need to have the pattern flags included */ - GFXsavedRop = rop16; + GFXsavedRop = rop16; - /* SET FLAG INDICATING ROP REQUIRES DESTINATION DATA */ - /* True if even bits (0:2:4:6) do not equal the correspinding */ - /* even bits (1:3:5:7). */ + /* SET FLAG INDICATING ROP REQUIRES DESTINATION DATA */ + /* True if even bits (0:2:4:6) do not equal the correspinding */ + /* even bits (1:3:5:7). */ - GFXusesDstData = ((rop & 0x55) ^ ((rop >> 1) & 0x55)); + GFXusesDstData = ((rop & 0x55) ^ ((rop >> 1) & 0x55)); - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - /* Only one operation can be pending at a time. */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + /* Only one operation can be pending at a time. */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_RASTER_MODE, rop16); + GFX_WAIT_PENDING; + WRITE_REG16(GP_RASTER_MODE, rop16); } /* @@ -595,47 +596,47 @@ gfx_set_raster_operation(unsigned char rop) */ void gu1_solid_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long color) + unsigned short width, unsigned short height, unsigned long color) { - unsigned short section; + unsigned short section; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Only one operation can be pending at a time. */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Only one operation can be pending at a time. */ - GFX_WAIT_PENDING; + GFX_WAIT_PENDING; - /* SET REGISTERS TO DRAW RECTANGLE */ + /* SET REGISTERS TO DRAW RECTANGLE */ - WRITE_REG16(GP_DST_XCOOR, x); - WRITE_REG16(GP_DST_YCOOR, y); - WRITE_REG16(GP_HEIGHT, height); - WRITE_REG16(GP_RASTER_MODE, 0x00F0); /* PATCOPY */ - WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)color); + WRITE_REG16(GP_DST_XCOOR, x); + WRITE_REG16(GP_DST_YCOOR, y); + WRITE_REG16(GP_HEIGHT, height); + WRITE_REG16(GP_RASTER_MODE, 0x00F0); /* PATCOPY */ + WRITE_REG16(GP_PAT_COLOR_0, (unsigned short) color); - /* CHECK WIDTH FOR GX BUG WORKAROUND */ + /* CHECK WIDTH FOR GX BUG WORKAROUND */ - if (width <= 16) { - /* OK TO DRAW SMALL RECTANGLE IN ONE PASS */ + if (width <= 16) { + /* OK TO DRAW SMALL RECTANGLE IN ONE PASS */ - WRITE_REG16(GP_WIDTH, width); - WRITE_REG16(GP_BLIT_MODE, 0); - } else { - /* DRAW FIRST PART OF RECTANGLE */ - /* Get to a 16 pixel boundary. */ + WRITE_REG16(GP_WIDTH, width); + WRITE_REG16(GP_BLIT_MODE, 0); + } + else { + /* DRAW FIRST PART OF RECTANGLE */ + /* Get to a 16 pixel boundary. */ - section = 0x10 - (x & 0x0F); - WRITE_REG16(GP_WIDTH, section); - WRITE_REG16(GP_BLIT_MODE, 0); + section = 0x10 - (x & 0x0F); + WRITE_REG16(GP_WIDTH, section); + WRITE_REG16(GP_BLIT_MODE, 0); - /* POLL UNTIL ABLE TO LOAD THE SECOND RECTANGLE */ + /* POLL UNTIL ABLE TO LOAD THE SECOND RECTANGLE */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_DST_XCOOR, x + section); - WRITE_REG16(GP_DST_YCOOR, y); - WRITE_REG16(GP_WIDTH, width - section); - WRITE_REG16(GP_BLIT_MODE, 0); - } + GFX_WAIT_PENDING; + WRITE_REG16(GP_DST_XCOOR, x + section); + WRITE_REG16(GP_DST_YCOOR, y); + WRITE_REG16(GP_WIDTH, width - section); + WRITE_REG16(GP_BLIT_MODE, 0); + } } /* @@ -656,90 +657,90 @@ gu1_solid_fill(unsigned short x, unsigned short y, #if GFX_2DACCEL_DYNAMIC void gu1_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) #else void gfx_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) #endif { - unsigned short section, buffer_width, blit_mode; + unsigned short section, buffer_width, blit_mode; - /* CHECK IF OPTIMIZED SOLID CASES */ - /* Check all 16 bits of the ROP to include solid pattern flags. */ + /* CHECK IF OPTIMIZED SOLID CASES */ + /* Check all 16 bits of the ROP to include solid pattern flags. */ - switch (GFXsavedRop) { - /* CHECK FOR SPECIAL CASES WITHOUT DESTINATION DATA */ - /* Need hardware workaround for fast "burst write" cases. */ + switch (GFXsavedRop) { + /* CHECK FOR SPECIAL CASES WITHOUT DESTINATION DATA */ + /* Need hardware workaround for fast "burst write" cases. */ - case 0x00F0: - gu1_solid_fill(x, y, width, height, (unsigned short)GFXsavedColor); - break; - case 0x000F: - gu1_solid_fill(x, y, width, height, (unsigned short)~GFXsavedColor); - break; - case 0x0000: - gu1_solid_fill(x, y, width, height, 0x0000); - break; - case 0x00FF: - gu1_solid_fill(x, y, width, height, 0xFFFF); - break; + case 0x00F0: + gu1_solid_fill(x, y, width, height, (unsigned short) GFXsavedColor); + break; + case 0x000F: + gu1_solid_fill(x, y, width, height, (unsigned short) ~GFXsavedColor); + break; + case 0x0000: + gu1_solid_fill(x, y, width, height, 0x0000); + break; + case 0x00FF: + gu1_solid_fill(x, y, width, height, 0xFFFF); + break; - /* REMAINING CASES REQUIRE DESTINATION DATA OR NOT SOLID COLOR */ + /* REMAINING CASES REQUIRE DESTINATION DATA OR NOT SOLID COLOR */ - default: + default: - /* DETERMINE BLT MODE VALUE */ - /* Still here for non-solid patterns without destination data. */ + /* DETERMINE BLT MODE VALUE */ + /* Still here for non-solid patterns without destination data. */ - blit_mode = GFXusesDstData ? BM_READ_DST_FB0 : 0; + blit_mode = GFXusesDstData ? BM_READ_DST_FB0 : 0; - /* SET SOURCE EXPANSION MODE */ - /* If the ROP requires source data, then the source data is all 1's */ - /* and then expanded into the desired color in GP_SRC_COLOR_1. */ + /* SET SOURCE EXPANSION MODE */ + /* If the ROP requires source data, then the source data is all 1's */ + /* and then expanded into the desired color in GP_SRC_COLOR_1. */ - blit_mode |= BM_SOURCE_EXPAND; + blit_mode |= BM_SOURCE_EXPAND; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Write the registers that do not change for each section. */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Write the registers that do not change for each section. */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, height); + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, height); - /* SINCE ONLY DESTINATION DATA, WE CAN USE BOTH BB0 AND BB1. */ - /* Therefore, width available = BLT buffer width * 2. */ + /* SINCE ONLY DESTINATION DATA, WE CAN USE BOTH BB0 AND BB1. */ + /* Therefore, width available = BLT buffer width * 2. */ - buffer_width = GFXbufferWidthPixels << 1; + buffer_width = GFXbufferWidthPixels << 1; - /* REPEAT UNTIL FINISHED WITH RECTANGLE */ - /* Perform BLT in vertical sections, as wide as the BLT buffer */ - /* allows. Hardware does not split the operations, so */ - /* software must do it to avoid large scanlines that would */ - /* overflow the BLT buffers. */ + /* REPEAT UNTIL FINISHED WITH RECTANGLE */ + /* Perform BLT in vertical sections, as wide as the BLT buffer */ + /* allows. Hardware does not split the operations, so */ + /* software must do it to avoid large scanlines that would */ + /* overflow the BLT buffers. */ - while (width > 0) { - /* DETERMINE WIDTH OF SECTION */ + while (width > 0) { + /* DETERMINE WIDTH OF SECTION */ - if (width > buffer_width) - section = buffer_width; - else - section = width; + if (width > buffer_width) + section = buffer_width; + else + section = width; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_DST_XCOOR, x); - WRITE_REG16(GP_DST_YCOOR, y); - WRITE_REG16(GP_WIDTH, section); - WRITE_REG16(GP_BLIT_MODE, blit_mode); + GFX_WAIT_PENDING; + WRITE_REG16(GP_DST_XCOOR, x); + WRITE_REG16(GP_DST_YCOOR, y); + WRITE_REG16(GP_WIDTH, section); + WRITE_REG16(GP_BLIT_MODE, blit_mode); - /* ADJUST PARAMETERS FOR NEXT SECTION */ + /* ADJUST PARAMETERS FOR NEXT SECTION */ - width -= section; - x += section; - } - break; - } + width -= section; + x += section; + } + break; + } } /* @@ -761,113 +762,115 @@ gfx_pattern_fill(unsigned short x, unsigned short y, #if GFX_2DACCEL_DYNAMIC void gu1_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long *pattern) + unsigned short width, unsigned short height, + unsigned long *pattern) #else void gfx_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long *pattern) + unsigned short width, unsigned short height, + unsigned long *pattern) #endif { - unsigned short blit_mode, passes, cur_y, pat_y, i; - unsigned short buffer_width, line_width; - unsigned short bpp_shift, section, cur_x; + unsigned short blit_mode, passes, cur_y, pat_y, i; + unsigned short buffer_width, line_width; + unsigned short bpp_shift, section, cur_x; - /* SET APPROPRIATE INCREMENT */ + /* SET APPROPRIATE INCREMENT */ - bpp_shift = (GFXbpp > 8) ? 2 : 1; + bpp_shift = (GFXbpp > 8) ? 2 : 1; - /* SET DESTINATION REQUIRED */ + /* SET DESTINATION REQUIRED */ - blit_mode = GFXusesDstData ? BM_READ_DST_FB0 : 0; + blit_mode = GFXusesDstData ? BM_READ_DST_FB0 : 0; - /* SET SOURCE EXPANSION */ + /* SET SOURCE EXPANSION */ - blit_mode |= BM_SOURCE_EXPAND; + blit_mode |= BM_SOURCE_EXPAND; - /* OVERRIDE RASTER MODE TO FORCE A COLOR PATTERN */ + /* OVERRIDE RASTER MODE TO FORCE A COLOR PATTERN */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_RASTER_MODE, - (GFXsavedRop & ~RM_PAT_MASK & ~RM_PAT_TRANSPARENT) | - RM_PAT_COLOR); + GFX_WAIT_PENDING; + WRITE_REG16(GP_RASTER_MODE, + (GFXsavedRop & ~RM_PAT_MASK & ~RM_PAT_TRANSPARENT) | + RM_PAT_COLOR); - /* WRITE THE REGISTERS THAT DO NOT CHANGE */ - /* If destination data is required, the width and */ - /* x position will be overwritten. */ + /* WRITE THE REGISTERS THAT DO NOT CHANGE */ + /* If destination data is required, the width and */ + /* x position will be overwritten. */ - WRITE_REG16(GP_HEIGHT, 1); - WRITE_REG16(GP_WIDTH, width); - WRITE_REG16(GP_DST_XCOOR, x); + WRITE_REG16(GP_HEIGHT, 1); + WRITE_REG16(GP_WIDTH, width); + WRITE_REG16(GP_DST_XCOOR, x); - /* THE ENTIRE PATTERN WILL NOT BE DRAWN IF THE HEIGHT IS LESS THAN 8 */ + /* THE ENTIRE PATTERN WILL NOT BE DRAWN IF THE HEIGHT IS LESS THAN 8 */ - passes = (height < 8) ? height : 8; + passes = (height < 8) ? height : 8; - /* SINCE ONLY DESTINATION DATA, WE CAN USE BOTH BB0 AND BB1. */ - /* Therefore, width available = BLT buffer width * 2. */ + /* SINCE ONLY DESTINATION DATA, WE CAN USE BOTH BB0 AND BB1. */ + /* Therefore, width available = BLT buffer width * 2. */ - buffer_width = GFXbufferWidthPixels << 1; + buffer_width = GFXbufferWidthPixels << 1; - for (i = 0; i < passes; i++) { - pat_y = ((y + i) & 7) << bpp_shift; - cur_y = y + i; + for (i = 0; i < passes; i++) { + pat_y = ((y + i) & 7) << bpp_shift; + cur_y = y + i; - /* WRITE THE PATTERN DATA FOR THE ACTIVE LINE */ + /* WRITE THE PATTERN DATA FOR THE ACTIVE LINE */ - GFX_WAIT_PENDING; - WRITE_REG32(GP_PAT_DATA_0, pattern[pat_y]); - WRITE_REG32(GP_PAT_DATA_1, pattern[pat_y + 1]); + GFX_WAIT_PENDING; + WRITE_REG32(GP_PAT_DATA_0, pattern[pat_y]); + WRITE_REG32(GP_PAT_DATA_1, pattern[pat_y + 1]); - if (GFXbpp > 8) { - WRITE_REG32(GP_PAT_DATA_2, pattern[pat_y + 2]); - WRITE_REG32(GP_PAT_DATA_3, pattern[pat_y + 3]); - } + if (GFXbpp > 8) { + WRITE_REG32(GP_PAT_DATA_2, pattern[pat_y + 2]); + WRITE_REG32(GP_PAT_DATA_3, pattern[pat_y + 3]); + } - /* SPLIT BLT LINE INTO SECTIONS IF REQUIRED */ - /* If no destination data is required, we can ignore */ - /* the BLT buffers. Otherwise, we must separate the BLT */ - /* so as not to overflow the buffers */ + /* SPLIT BLT LINE INTO SECTIONS IF REQUIRED */ + /* If no destination data is required, we can ignore */ + /* the BLT buffers. Otherwise, we must separate the BLT */ + /* so as not to overflow the buffers */ - if (blit_mode & BM_READ_DST_BB0) { - line_width = width; - cur_x = x; + if (blit_mode & BM_READ_DST_BB0) { + line_width = width; + cur_x = x; - while (line_width) { - section = (line_width > buffer_width) ? buffer_width : line_width; - cur_y = y + i; + while (line_width) { + section = + (line_width > buffer_width) ? buffer_width : line_width; + cur_y = y + i; - GFX_WAIT_PENDING; - WRITE_REG16(GP_DST_XCOOR, cur_x); - WRITE_REG16(GP_WIDTH, section); + GFX_WAIT_PENDING; + WRITE_REG16(GP_DST_XCOOR, cur_x); + WRITE_REG16(GP_WIDTH, section); - while (cur_y < y + height) { - GFX_WAIT_PENDING; - WRITE_REG16(GP_DST_YCOOR, cur_y); - WRITE_REG16(GP_BLIT_MODE, blit_mode); - cur_y += 8; - } + while (cur_y < y + height) { + GFX_WAIT_PENDING; + WRITE_REG16(GP_DST_YCOOR, cur_y); + WRITE_REG16(GP_BLIT_MODE, blit_mode); + cur_y += 8; + } - cur_x += section; - line_width -= section; - } + cur_x += section; + line_width -= section; + } - } else { - while (cur_y < y + height) { - GFX_WAIT_PENDING; - WRITE_REG16(GP_DST_YCOOR, cur_y); - WRITE_REG16(GP_BLIT_MODE, blit_mode); - cur_y += 8; - } - } + } + else { + while (cur_y < y + height) { + GFX_WAIT_PENDING; + WRITE_REG16(GP_DST_YCOOR, cur_y); + WRITE_REG16(GP_BLIT_MODE, blit_mode); + cur_y += 8; + } + } - } + } - /* RESTORE ORIGINAL ROP AND FLAGS */ + /* RESTORE ORIGINAL ROP AND FLAGS */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_RASTER_MODE, GFXsavedRop); + GFX_WAIT_PENDING; + WRITE_REG16(GP_RASTER_MODE, GFXsavedRop); } @@ -889,97 +892,98 @@ gfx_color_pattern_fill(unsigned short x, unsigned short y, #if GFX_2DACCEL_DYNAMIC void gu1_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height) #else void gfx_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height) #endif { - unsigned short section, buffer_width; - unsigned short blit_mode; - - /* CHECK IF RASTER OPERATION REQUIRES DESTINATION DATA */ - - blit_mode = GFXusesDstData ? BM_READ_DST_FB1 | BM_READ_SRC_FB : - BM_READ_SRC_FB; - - /* CHECK Y DIRECTION */ - /* Hardware has support for negative Y direction. */ - - if (dsty > srcy) { - blit_mode |= BM_REVERSE_Y; - srcy += height - 1; - dsty += height - 1; - } - - /* CHECK X DIRECTION */ - /* Hardware does not support negative X direction since at the time */ - /* of development all supported resolutions could fit a scanline of */ - /* data at once into the BLT buffers (using both BB0 and BB1). This */ - /* code is more generic to allow for any size BLT buffer. */ - - if (dstx > srcx) { - srcx += width; - dstx += width; - } - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Write the registers that do not change for each section. */ - - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, height); - - /* CHECK AVAILABLE BLT BUFFER SIZE */ - /* Can use both BLT buffers if no destination data is required. */ - - buffer_width = GFXusesDstData ? GFXbufferWidthPixels : - GFXbufferWidthPixels << 1; - - /* REPEAT UNTIL FINISHED WITH RECTANGLE */ - /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */ - /* Hardware does not split the operations, so software must do it to */ - /* avoid large scanlines that would overflow the BLT buffers. */ - - while (width > 0) { - /* CHECK WIDTH OF CURRENT SECTION */ - - if (width > buffer_width) - section = buffer_width; - else - section = width; - - /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */ - - GFX_WAIT_PENDING; - WRITE_REG16(GP_SRC_YCOOR, srcy); - WRITE_REG16(GP_DST_YCOOR, dsty); - WRITE_REG16(GP_WIDTH, section); - - /* CHECK X DIRECTION */ - - if (dstx > srcx) { - /* NEGATIVE X DIRECTION */ - /* Still positive X direction within the section. */ - - srcx -= section; - dstx -= section; - WRITE_REG16(GP_SRC_XCOOR, srcx); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_BLIT_MODE, blit_mode); - } else { - /* POSITIVE X DIRECTION */ - - WRITE_REG16(GP_SRC_XCOOR, srcx); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_BLIT_MODE, blit_mode); - dstx += section; - srcx += section; - } - width -= section; - } + unsigned short section, buffer_width; + unsigned short blit_mode; + + /* CHECK IF RASTER OPERATION REQUIRES DESTINATION DATA */ + + blit_mode = GFXusesDstData ? BM_READ_DST_FB1 | BM_READ_SRC_FB : + BM_READ_SRC_FB; + + /* CHECK Y DIRECTION */ + /* Hardware has support for negative Y direction. */ + + if (dsty > srcy) { + blit_mode |= BM_REVERSE_Y; + srcy += height - 1; + dsty += height - 1; + } + + /* CHECK X DIRECTION */ + /* Hardware does not support negative X direction since at the time */ + /* of development all supported resolutions could fit a scanline of */ + /* data at once into the BLT buffers (using both BB0 and BB1). This */ + /* code is more generic to allow for any size BLT buffer. */ + + if (dstx > srcx) { + srcx += width; + dstx += width; + } + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Write the registers that do not change for each section. */ + + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, height); + + /* CHECK AVAILABLE BLT BUFFER SIZE */ + /* Can use both BLT buffers if no destination data is required. */ + + buffer_width = GFXusesDstData ? GFXbufferWidthPixels : + GFXbufferWidthPixels << 1; + + /* REPEAT UNTIL FINISHED WITH RECTANGLE */ + /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */ + /* Hardware does not split the operations, so software must do it to */ + /* avoid large scanlines that would overflow the BLT buffers. */ + + while (width > 0) { + /* CHECK WIDTH OF CURRENT SECTION */ + + if (width > buffer_width) + section = buffer_width; + else + section = width; + + /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */ + + GFX_WAIT_PENDING; + WRITE_REG16(GP_SRC_YCOOR, srcy); + WRITE_REG16(GP_DST_YCOOR, dsty); + WRITE_REG16(GP_WIDTH, section); + + /* CHECK X DIRECTION */ + + if (dstx > srcx) { + /* NEGATIVE X DIRECTION */ + /* Still positive X direction within the section. */ + + srcx -= section; + dstx -= section; + WRITE_REG16(GP_SRC_XCOOR, srcx); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_BLIT_MODE, blit_mode); + } + else { + /* POSITIVE X DIRECTION */ + + WRITE_REG16(GP_SRC_XCOOR, srcx); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_BLIT_MODE, blit_mode); + dstx += section; + srcx += section; + } + width -= section; + } } /* @@ -1001,123 +1005,124 @@ gfx_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu1_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color) #else void gfx_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color) #endif { - unsigned short section, buffer_width; - unsigned short blit_mode = BM_READ_SRC_FB; - - /* CHECK Y DIRECTION */ - /* Hardware has support for negative Y direction. */ - - if (dsty > srcy) { - blit_mode |= BM_REVERSE_Y; - srcy += height - 1; - dsty += height - 1; - } - - /* CHECK X DIRECTION */ - /* Hardware does not support negative X direction since at the time */ - /* of development all supported resolutions could fit a scanline of */ - /* data at once into the BLT buffers (using both BB0 and BB1). This */ - /* code is more generic to allow for any size BLT buffer. */ - - if (dstx > srcx) { - srcx += width; - dstx += width; - } - - /* CALCULATE BLT BUFFER SIZE */ - /* Need to use BB1 to store the BLT buffer data. */ - - buffer_width = GFXbufferWidthPixels; - - /* WRITE TRANSPARENCY COLOR TO BLT BUFFER 1 */ - - if (GFXbpp == 8) { - color &= 0x00FF; - color |= (color << 8); - } - color = (color & 0x0000FFFF) | (color << 16); - - /* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */ - /* Need to make sure any previous BLT using BB1 is complete. */ - /* Only need to load 32 bits of BB1 for the 1 pixel BLT that follows. */ - - GFX_WAIT_BUSY; - WRITE_SCRATCH32(GFXbb1Base, color); - - /* DO BOGUS BLT TO LATCH DATA FROM BB1 */ - /* Already know graphics pipeline is idle. */ - /* Only need to latch data into the holding registers for the current */ - /* data from BB1. A 1 pixel wide BLT will suffice. */ - - WRITE_REG32(GP_DST_XCOOR, 0); - WRITE_REG32(GP_SRC_XCOOR, 0); - WRITE_REG32(GP_WIDTH, 0x00010001); - WRITE_REG16(GP_RASTER_MODE, 0x00CC); - WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1); - - /* WRITE REGISTERS FOR REAL SCREEN TO SCREEN BLT */ - - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, height); - WRITE_REG16(GP_RASTER_MODE, 0x10C6); - WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF); - - /* REPEAT UNTIL FINISHED WITH RECTANGLE */ - /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */ - /* Hardware does not split the operations, so software must do it to */ - /* avoid large scanlines that would overflow the BLT buffers. */ - - while (width > 0) { - /* CHECK WIDTH OF CURRENT SECTION */ - - if (width > buffer_width) - section = buffer_width; - else - section = width; - - /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */ - - GFX_WAIT_PENDING; - WRITE_REG16(GP_SRC_YCOOR, srcy); - WRITE_REG16(GP_DST_YCOOR, dsty); - WRITE_REG16(GP_WIDTH, section); - - /* CHECK X DIRECTION */ - /* Again, this must be done in software, and can be removed if the */ - /* display driver knows that the BLT buffers will always be large */ - /* enough to contain an entire scanline of a screen to screen BLT. */ - - if (dstx > srcx) { - /* NEGATIVE X DIRECTION */ - /* Still positive X direction within the section. */ - - srcx -= section; - dstx -= section; - WRITE_REG16(GP_SRC_XCOOR, srcx); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_BLIT_MODE, blit_mode); - } else { - /* POSITIVE X DIRECTION */ - - WRITE_REG16(GP_SRC_XCOOR, srcx); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_BLIT_MODE, blit_mode); - dstx += section; - srcx += section; - } - width -= section; - } + unsigned short section, buffer_width; + unsigned short blit_mode = BM_READ_SRC_FB; + + /* CHECK Y DIRECTION */ + /* Hardware has support for negative Y direction. */ + + if (dsty > srcy) { + blit_mode |= BM_REVERSE_Y; + srcy += height - 1; + dsty += height - 1; + } + + /* CHECK X DIRECTION */ + /* Hardware does not support negative X direction since at the time */ + /* of development all supported resolutions could fit a scanline of */ + /* data at once into the BLT buffers (using both BB0 and BB1). This */ + /* code is more generic to allow for any size BLT buffer. */ + + if (dstx > srcx) { + srcx += width; + dstx += width; + } + + /* CALCULATE BLT BUFFER SIZE */ + /* Need to use BB1 to store the BLT buffer data. */ + + buffer_width = GFXbufferWidthPixels; + + /* WRITE TRANSPARENCY COLOR TO BLT BUFFER 1 */ + + if (GFXbpp == 8) { + color &= 0x00FF; + color |= (color << 8); + } + color = (color & 0x0000FFFF) | (color << 16); + + /* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */ + /* Need to make sure any previous BLT using BB1 is complete. */ + /* Only need to load 32 bits of BB1 for the 1 pixel BLT that follows. */ + + GFX_WAIT_BUSY; + WRITE_SCRATCH32(GFXbb1Base, color); + + /* DO BOGUS BLT TO LATCH DATA FROM BB1 */ + /* Already know graphics pipeline is idle. */ + /* Only need to latch data into the holding registers for the current */ + /* data from BB1. A 1 pixel wide BLT will suffice. */ + + WRITE_REG32(GP_DST_XCOOR, 0); + WRITE_REG32(GP_SRC_XCOOR, 0); + WRITE_REG32(GP_WIDTH, 0x00010001); + WRITE_REG16(GP_RASTER_MODE, 0x00CC); + WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1); + + /* WRITE REGISTERS FOR REAL SCREEN TO SCREEN BLT */ + + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, height); + WRITE_REG16(GP_RASTER_MODE, 0x10C6); + WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF); + + /* REPEAT UNTIL FINISHED WITH RECTANGLE */ + /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */ + /* Hardware does not split the operations, so software must do it to */ + /* avoid large scanlines that would overflow the BLT buffers. */ + + while (width > 0) { + /* CHECK WIDTH OF CURRENT SECTION */ + + if (width > buffer_width) + section = buffer_width; + else + section = width; + + /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */ + + GFX_WAIT_PENDING; + WRITE_REG16(GP_SRC_YCOOR, srcy); + WRITE_REG16(GP_DST_YCOOR, dsty); + WRITE_REG16(GP_WIDTH, section); + + /* CHECK X DIRECTION */ + /* Again, this must be done in software, and can be removed if the */ + /* display driver knows that the BLT buffers will always be large */ + /* enough to contain an entire scanline of a screen to screen BLT. */ + + if (dstx > srcx) { + /* NEGATIVE X DIRECTION */ + /* Still positive X direction within the section. */ + + srcx -= section; + dstx -= section; + WRITE_REG16(GP_SRC_XCOOR, srcx); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_BLIT_MODE, blit_mode); + } + else { + /* POSITIVE X DIRECTION */ + + WRITE_REG16(GP_SRC_XCOOR, srcx); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_BLIT_MODE, blit_mode); + dstx += section; + srcx += section; + } + width -= section; + } } /* @@ -1145,91 +1150,91 @@ gfx_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu1_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch) #else void gfx_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch) #endif { - unsigned short section, buffer_width; - unsigned short blit_mode = BM_READ_SRC_BB0; - unsigned short temp_height; - unsigned long dword_bytes_needed, bytes_extra; - unsigned long bpp_shift; - long array_offset; + unsigned short section, buffer_width; + unsigned short blit_mode = BM_READ_SRC_BB0; + unsigned short temp_height; + unsigned long dword_bytes_needed, bytes_extra; + unsigned long bpp_shift; + long array_offset; - /* CHECK SIZE OF BLT BUFFER */ + /* CHECK SIZE OF BLT BUFFER */ - buffer_width = GFXbufferWidthPixels; + buffer_width = GFXbufferWidthPixels; - /* CHECK IF RASTER OPERATION REQUIRES DESTINATION DATA */ - /* If no destination data, we have twice the room for */ - /* source data. */ + /* CHECK IF RASTER OPERATION REQUIRES DESTINATION DATA */ + /* If no destination data, we have twice the room for */ + /* source data. */ - if (GFXusesDstData) - blit_mode |= BM_READ_DST_FB1; - else - buffer_width <<= 1; + if (GFXusesDstData) + blit_mode |= BM_READ_DST_FB1; + else + buffer_width <<= 1; - /* SET THE SCRATCHPAD BASE */ + /* SET THE SCRATCHPAD BASE */ - SET_SCRATCH_BASE(GFXbb0Base); + SET_SCRATCH_BASE(GFXbb0Base); - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Write the registers that do not change for each section. */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Write the registers that do not change for each section. */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, 1); + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, 1); - bpp_shift = (GFXbpp + 7) >> 4; + bpp_shift = (GFXbpp + 7) >> 4; - while (width > 0) { - if (width > buffer_width) - section = buffer_width; - else - section = width; + while (width > 0) { + if (width > buffer_width) + section = buffer_width; + else + section = width; - dword_bytes_needed = (section << bpp_shift) & ~3l; - bytes_extra = (section << bpp_shift) & 3l; + dword_bytes_needed = (section << bpp_shift) & ~3l; + bytes_extra = (section << bpp_shift) & 3l; - temp_height = height; + temp_height = height; - /* WRITE THE REGISTERS FOR EACH SECTION */ - /* The GX hardware will auto-increment the Y coordinate, meaning */ - /* that we don't have to. */ + /* WRITE THE REGISTERS FOR EACH SECTION */ + /* The GX hardware will auto-increment the Y coordinate, meaning */ + /* that we don't have to. */ - WRITE_REG16(GP_WIDTH, section); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_DST_YCOOR, dsty); + WRITE_REG16(GP_WIDTH, section); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_DST_YCOOR, dsty); - /* CALCULATE THE BITMAP OFFSET */ + /* CALCULATE THE BITMAP OFFSET */ - array_offset = - (unsigned long)srcy *(long)pitch + ((long)srcx << bpp_shift); + array_offset = + (unsigned long) srcy *(long) pitch + ((long) srcx << bpp_shift); - while (temp_height--) { - GFX_WAIT_PIPELINE; + while (temp_height--) { + GFX_WAIT_PIPELINE; - /* WRITE ALL DATA TO THE BLT BUFFERS */ - /* The WRITE_SCRATCH_STRING macro assumes that the data begins at the */ - /* scratchpad offset set by the SET_SCRATCH_BASE macro. */ + /* WRITE ALL DATA TO THE BLT BUFFERS */ + /* The WRITE_SCRATCH_STRING macro assumes that the data begins at the */ + /* scratchpad offset set by the SET_SCRATCH_BASE macro. */ - WRITE_SCRATCH_STRING(dword_bytes_needed, bytes_extra, data, - array_offset); - WRITE_REG16(GP_BLIT_MODE, blit_mode); + WRITE_SCRATCH_STRING(dword_bytes_needed, bytes_extra, data, + array_offset); + WRITE_REG16(GP_BLIT_MODE, blit_mode); - array_offset += pitch; - } + array_offset += pitch; + } - width -= section; - srcx += section; - dstx += section; - } + width -= section; + srcx += section; + dstx += section; + } } /* @@ -1255,112 +1260,112 @@ gfx_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu1_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch, + unsigned long color) #else void gfx_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch, + unsigned long color) #endif { - unsigned short section, buffer_width; - unsigned short temp_height; - unsigned long dword_bytes_needed, bytes_extra; - unsigned long bpp_shift; - long array_offset; + unsigned short section, buffer_width; + unsigned short temp_height; + unsigned long dword_bytes_needed, bytes_extra; + unsigned long bpp_shift; + long array_offset; - /* CHECK SIZE OF BLT BUFFER */ + /* CHECK SIZE OF BLT BUFFER */ - buffer_width = GFXbufferWidthPixels; + buffer_width = GFXbufferWidthPixels; - /* WRITE TRANSPARENCY COLOR TO BLT BUFFER 1 */ + /* WRITE TRANSPARENCY COLOR TO BLT BUFFER 1 */ - if (GFXbpp == 8) { - color &= 0x00FF; - color |= (color << 8); - } - color = (color & 0x0000FFFF) | (color << 16); + if (GFXbpp == 8) { + color &= 0x00FF; + color |= (color << 8); + } + color = (color & 0x0000FFFF) | (color << 16); - /* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */ - /* Need to make sure any previous BLT using BB1 is complete. */ - /* Only need to load 32 bits of BB1 for the 1 pixel BLT that follows. */ + /* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */ + /* Need to make sure any previous BLT using BB1 is complete. */ + /* Only need to load 32 bits of BB1 for the 1 pixel BLT that follows. */ - GFX_WAIT_PIPELINE; - GFX_WAIT_PENDING; - WRITE_SCRATCH32(GFXbb1Base, color); + GFX_WAIT_PIPELINE; + GFX_WAIT_PENDING; + WRITE_SCRATCH32(GFXbb1Base, color); - /* DO BOGUS BLT TO LATCH DATA FROM BB1 */ - /* Already know graphics pipeline is idle. */ - /* Only need to latch data into the holding registers for the current */ - /* data from BB1. A 1 pixel wide BLT will suffice. */ + /* DO BOGUS BLT TO LATCH DATA FROM BB1 */ + /* Already know graphics pipeline is idle. */ + /* Only need to latch data into the holding registers for the current */ + /* data from BB1. A 1 pixel wide BLT will suffice. */ - WRITE_REG32(GP_DST_XCOOR, 0); - WRITE_REG32(GP_SRC_XCOOR, 0); - WRITE_REG32(GP_WIDTH, 0x00010001); - WRITE_REG16(GP_RASTER_MODE, 0x00CC); - WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1); + WRITE_REG32(GP_DST_XCOOR, 0); + WRITE_REG32(GP_SRC_XCOOR, 0); + WRITE_REG32(GP_WIDTH, 0x00010001); + WRITE_REG16(GP_RASTER_MODE, 0x00CC); + WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1); - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Write the registers that do not change for each section. */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Write the registers that do not change for each section. */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, 1); - WRITE_REG16(GP_RASTER_MODE, 0x10C6); - WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF); + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, 1); + WRITE_REG16(GP_RASTER_MODE, 0x10C6); + WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF); - bpp_shift = (GFXbpp + 7) >> 4; + bpp_shift = (GFXbpp + 7) >> 4; - /* SET THE SCRATCHPAD BASE */ + /* SET THE SCRATCHPAD BASE */ - SET_SCRATCH_BASE(GFXbb0Base); + SET_SCRATCH_BASE(GFXbb0Base); - while (width > 0) { - if (width > buffer_width) - section = buffer_width; - else - section = width; + while (width > 0) { + if (width > buffer_width) + section = buffer_width; + else + section = width; - dword_bytes_needed = (section << bpp_shift) & ~3l; - bytes_extra = (section << bpp_shift) & 3l; + dword_bytes_needed = (section << bpp_shift) & ~3l; + bytes_extra = (section << bpp_shift) & 3l; - temp_height = height; + temp_height = height; - /* WRITE THE REGISTERS FOR EACH SECTION */ - /* The GX hardware will auto-increment the Y coordinate, meaning */ - /* that we don't have to. */ + /* WRITE THE REGISTERS FOR EACH SECTION */ + /* The GX hardware will auto-increment the Y coordinate, meaning */ + /* that we don't have to. */ - WRITE_REG16(GP_WIDTH, section); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_DST_YCOOR, dsty); + WRITE_REG16(GP_WIDTH, section); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_DST_YCOOR, dsty); - /* CALCULATE THE BITMAP OFFSET */ + /* CALCULATE THE BITMAP OFFSET */ - array_offset = - (unsigned long)srcy *(long)pitch + ((long)srcx << bpp_shift); + array_offset = + (unsigned long) srcy *(long) pitch + ((long) srcx << bpp_shift); - while (temp_height--) { - GFX_WAIT_PIPELINE; + while (temp_height--) { + GFX_WAIT_PIPELINE; - /* WRITE ALL DATA TO THE BLT BUFFERS */ - /* The WRITE_SCRATCH_STRING macro assumes that the data begins at the */ - /* scratchpad offset set by the SET_SCRATCH_BASE macro. */ + /* WRITE ALL DATA TO THE BLT BUFFERS */ + /* The WRITE_SCRATCH_STRING macro assumes that the data begins at the */ + /* scratchpad offset set by the SET_SCRATCH_BASE macro. */ - WRITE_SCRATCH_STRING(dword_bytes_needed, bytes_extra, data, - array_offset); - WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_BB0); + WRITE_SCRATCH_STRING(dword_bytes_needed, bytes_extra, data, + array_offset); + WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_BB0); - array_offset += pitch; - } + array_offset += pitch; + } - width -= section; - srcx += section; - dstx += section; - } + width -= section; + srcx += section; + dstx += section; + } } /* @@ -1382,106 +1387,107 @@ gfx_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu1_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, short pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, short pitch) #else void gfx_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, short pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, short pitch) #endif { - unsigned short section, buffer_width; - unsigned short blit_mode = BM_READ_SRC_BB0 | BM_SOURCE_EXPAND; - unsigned short temp_height; - unsigned long dword_bytes_needed, bytes_extra; - long array_offset; - - /* CHECK IF RASTER OPERATION REQUIRES DESTINATION DATA */ - /* If no destination data, the source data will always fit. */ - /* So, in that event we will set the buffer width to a */ - /* fictitiously large value such that the BLT is never split. */ - - if (GFXusesDstData) { - buffer_width = GFXbufferWidthPixels; - blit_mode |= BM_READ_DST_FB1; - } else - buffer_width = 3200; - - /* CHECK IF DATA ALREADY IN BLIT BUFFER */ - /* If the pointer is NULL, data for the full BLT is already there */ - /* WARNING: This could cause problems if destination data is */ - /* involved and it overflows the BLT buffer. Need to remove */ - /* this option and change the drivers to use a temporary buffer. */ - - if (!data) { - GFX_WAIT_PENDING; - WRITE_REG16(GP_SRC_XCOOR, srcx & 7); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_DST_YCOOR, dsty); - WRITE_REG16(GP_WIDTH, width); - WRITE_REG16(GP_HEIGHT, height); - WRITE_REG16(GP_BLIT_MODE, blit_mode); - return; - } - - /* SET THE SCRATCHPAD BASE */ - - SET_SCRATCH_BASE(GFXbb0Base); - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Write the registers that do not change for each section. */ - - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, 1); - - while (width > 0) { - if (width > buffer_width) - section = buffer_width; - else - section = width; - - /* CALCULATE BYTES NEEDED */ - /* Add 1 for possible alignment issues. */ - - dword_bytes_needed = ((section + 7 + (srcx & 7)) >> 3) & ~3l; - bytes_extra = ((section + 7 + (srcx & 7)) >> 3) & 3l; - - temp_height = height; - - /* WRITE THE REGISTERS FOR EACH SECTION */ - /* The GX hardware will auto-increment the Y coordinate, meaning */ - /* that we don't have to. */ - - WRITE_REG16(GP_WIDTH, section); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_DST_YCOOR, dsty); - WRITE_REG16(GP_SRC_XCOOR, srcx & 7); - - /* CALCULATE THE BITMAP OFFSET */ - - array_offset = (unsigned long)srcy *(long)pitch + ((long)srcx >> 3); - - while (temp_height--) { - GFX_WAIT_PIPELINE; - - /* WRITE ALL DATA TO THE BLT BUFFERS */ - /* The WRITE_SCRATCH_STRING macro assumes that the data begins at the */ - /* scratchpad offset set by the SET_SCRATCH_BASE macro. */ - - WRITE_SCRATCH_STRING(dword_bytes_needed, bytes_extra, data, - array_offset); - WRITE_REG16(GP_BLIT_MODE, blit_mode); - - array_offset += pitch; - } - - width -= section; - srcx += section; - dstx += section; - } + unsigned short section, buffer_width; + unsigned short blit_mode = BM_READ_SRC_BB0 | BM_SOURCE_EXPAND; + unsigned short temp_height; + unsigned long dword_bytes_needed, bytes_extra; + long array_offset; + + /* CHECK IF RASTER OPERATION REQUIRES DESTINATION DATA */ + /* If no destination data, the source data will always fit. */ + /* So, in that event we will set the buffer width to a */ + /* fictitiously large value such that the BLT is never split. */ + + if (GFXusesDstData) { + buffer_width = GFXbufferWidthPixels; + blit_mode |= BM_READ_DST_FB1; + } + else + buffer_width = 3200; + + /* CHECK IF DATA ALREADY IN BLIT BUFFER */ + /* If the pointer is NULL, data for the full BLT is already there */ + /* WARNING: This could cause problems if destination data is */ + /* involved and it overflows the BLT buffer. Need to remove */ + /* this option and change the drivers to use a temporary buffer. */ + + if (!data) { + GFX_WAIT_PENDING; + WRITE_REG16(GP_SRC_XCOOR, srcx & 7); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_DST_YCOOR, dsty); + WRITE_REG16(GP_WIDTH, width); + WRITE_REG16(GP_HEIGHT, height); + WRITE_REG16(GP_BLIT_MODE, blit_mode); + return; + } + + /* SET THE SCRATCHPAD BASE */ + + SET_SCRATCH_BASE(GFXbb0Base); + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Write the registers that do not change for each section. */ + + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, 1); + + while (width > 0) { + if (width > buffer_width) + section = buffer_width; + else + section = width; + + /* CALCULATE BYTES NEEDED */ + /* Add 1 for possible alignment issues. */ + + dword_bytes_needed = ((section + 7 + (srcx & 7)) >> 3) & ~3l; + bytes_extra = ((section + 7 + (srcx & 7)) >> 3) & 3l; + + temp_height = height; + + /* WRITE THE REGISTERS FOR EACH SECTION */ + /* The GX hardware will auto-increment the Y coordinate, meaning */ + /* that we don't have to. */ + + WRITE_REG16(GP_WIDTH, section); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_DST_YCOOR, dsty); + WRITE_REG16(GP_SRC_XCOOR, srcx & 7); + + /* CALCULATE THE BITMAP OFFSET */ + + array_offset = (unsigned long) srcy *(long) pitch + ((long) srcx >> 3); + + while (temp_height--) { + GFX_WAIT_PIPELINE; + + /* WRITE ALL DATA TO THE BLT BUFFERS */ + /* The WRITE_SCRATCH_STRING macro assumes that the data begins at the */ + /* scratchpad offset set by the SET_SCRATCH_BASE macro. */ + + WRITE_SCRATCH_STRING(dword_bytes_needed, bytes_extra, data, + array_offset); + WRITE_REG16(GP_BLIT_MODE, blit_mode); + + array_offset += pitch; + } + + width -= section; + srcx += section; + dstx += section; + } } /* @@ -1500,61 +1506,61 @@ gfx_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu1_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, - unsigned short height, unsigned char *data) + unsigned short height, unsigned char *data) #else void gfx_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, - unsigned short height, unsigned char *data) + unsigned short height, unsigned char *data) #endif { - unsigned long dword_bytes_needed, bytes_extra; - long pitch, buffer_bytes, data_bytes; + unsigned long dword_bytes_needed, bytes_extra; + long pitch, buffer_bytes, data_bytes; - /* CALCULATE DATA SIZE */ + /* CALCULATE DATA SIZE */ - pitch = (width + 7) >> 3; - data_bytes = (long)height *pitch; + pitch = (width + 7) >> 3; + data_bytes = (long) height *pitch; - /* CHECK FOR SIMPLE CASE */ - /* This routine is designed to render a source copy text glyph. If destination */ - /* data is required or the source data will not fit, we will punt the operation */ - /* to the more versatile (and slow) mono bitmap routine. */ + /* CHECK FOR SIMPLE CASE */ + /* This routine is designed to render a source copy text glyph. If destination */ + /* data is required or the source data will not fit, we will punt the operation */ + /* to the more versatile (and slow) mono bitmap routine. */ - if (GFXbpp > 8) - buffer_bytes = GFXbufferWidthPixels << 1; - else - buffer_bytes = GFXbufferWidthPixels; + if (GFXbpp > 8) + buffer_bytes = GFXbufferWidthPixels << 1; + else + buffer_bytes = GFXbufferWidthPixels; - if (GFXusesDstData || data_bytes > buffer_bytes) { - gfx_mono_bitmap_to_screen_blt(0, 0, dstx, dsty, width, height, data, - (short)pitch); - return; - } + if (GFXusesDstData || data_bytes > buffer_bytes) { + gfx_mono_bitmap_to_screen_blt(0, 0, dstx, dsty, width, height, data, + (short) pitch); + return; + } - /* SET THE SCRATCHPAD BASE */ + /* SET THE SCRATCHPAD BASE */ - SET_SCRATCH_BASE(GFXbb0Base); + SET_SCRATCH_BASE(GFXbb0Base); - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - dword_bytes_needed = data_bytes & ~3l; - bytes_extra = data_bytes & 3l; + dword_bytes_needed = data_bytes & ~3l; + bytes_extra = data_bytes & 3l; - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, height); - WRITE_REG16(GP_WIDTH, width); - WRITE_REG16(GP_DST_XCOOR, dstx); - WRITE_REG16(GP_DST_YCOOR, dsty); - WRITE_REG16(GP_SRC_XCOOR, 0); + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, height); + WRITE_REG16(GP_WIDTH, width); + WRITE_REG16(GP_DST_XCOOR, dstx); + WRITE_REG16(GP_DST_YCOOR, dsty); + WRITE_REG16(GP_SRC_XCOOR, 0); - /* WRITE ALL DATA TO THE BLT BUFFERS */ - /* The WRITE_SCRATCH_STRING macro assumes that the data begins at the */ - /* scratchpad offset set by the SET_SCRATCH_BASE macro. */ + /* WRITE ALL DATA TO THE BLT BUFFERS */ + /* The WRITE_SCRATCH_STRING macro assumes that the data begins at the */ + /* scratchpad offset set by the SET_SCRATCH_BASE macro. */ - GFX_WAIT_PIPELINE; + GFX_WAIT_PIPELINE; - WRITE_SCRATCH_STRING(dword_bytes_needed, bytes_extra, data, 0); - WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_BB0 | BM_SOURCE_TEXT); + WRITE_SCRATCH_STRING(dword_bytes_needed, bytes_extra, data, 0); + WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_BB0 | BM_SOURCE_TEXT); } /* @@ -1579,37 +1585,37 @@ gfx_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, #if GFX_2DACCEL_DYNAMIC void gu1_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) #else void gfx_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) #endif { - unsigned short vector_mode = flags; + unsigned short vector_mode = flags; - if (GFXusesDstData) - vector_mode |= VM_READ_DST_FB; + if (GFXusesDstData) + vector_mode |= VM_READ_DST_FB; - /* CHECK NULL LENGTH */ + /* CHECK NULL LENGTH */ - if (!length) - return; + if (!length) + return; - /* LOAD THE REGISTERS FOR THE VECTOR */ + /* LOAD THE REGISTERS FOR THE VECTOR */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_DST_XCOOR, x); - WRITE_REG16(GP_DST_YCOOR, y); - WRITE_REG16(GP_VECTOR_LENGTH, length); - WRITE_REG16(GP_INIT_ERROR, initerr); - WRITE_REG16(GP_AXIAL_ERROR, axialerr); - WRITE_REG16(GP_DIAG_ERROR, diagerr); - WRITE_REG16(GP_VECTOR_MODE, vector_mode); + GFX_WAIT_PENDING; + WRITE_REG16(GP_DST_XCOOR, x); + WRITE_REG16(GP_DST_YCOOR, y); + WRITE_REG16(GP_VECTOR_LENGTH, length); + WRITE_REG16(GP_INIT_ERROR, initerr); + WRITE_REG16(GP_AXIAL_ERROR, axialerr); + WRITE_REG16(GP_DIAG_ERROR, diagerr); + WRITE_REG16(GP_VECTOR_MODE, vector_mode); } /*--------------------------------------------------------------------------- @@ -1627,7 +1633,7 @@ void gfx_wait_until_idle(void) #endif { - GFX_WAIT_BUSY; + GFX_WAIT_BUSY; } /*--------------------------------------------------------------------------- @@ -1648,10 +1654,10 @@ int gfx_test_blt_pending(void) #endif { - if (READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING) - return (1); - else - return (0); + if (READ_REG16(GP_BLIT_STATUS) & BS_BLIT_PENDING) + return (1); + else + return (0); } /*--------------------------------------------------------------------------- @@ -1715,36 +1721,36 @@ gfx_test_blt_pending(void) void gu1_detect_blt_buffer_base(void) { - /* ASSUME 2K */ + /* ASSUME 2K */ - GFXbb0Base = BB0_BASE_2K; - GFXbb1Base = BB1_BASE_2K; + GFXbb0Base = BB0_BASE_2K; + GFXbb1Base = BB1_BASE_2K; - /* CHECK IF SCRATCHPAD IS SET TO 3K OR 4K */ - /* Boot code should still set 3K values for 4K. */ + /* CHECK IF SCRATCHPAD IS SET TO 3K OR 4K */ + /* Boot code should still set 3K values for 4K. */ - if (gfx_gxm_config_read(GXM_CONFIG_GCR) & 0x08) { - /* WRITE DATA TO 3K LOCATION */ + if (gfx_gxm_config_read(GXM_CONFIG_GCR) & 0x08) { + /* WRITE DATA TO 3K LOCATION */ - GFX_WAIT_BUSY; - WRITE_SCRATCH32(BB0_BASE_3K, 0xFEEDFACE); + GFX_WAIT_BUSY; + WRITE_SCRATCH32(BB0_BASE_3K, 0xFEEDFACE); - /* HAVE THE GRAPHICS UNIT STORE SOMETHING IN BB0 */ + /* HAVE THE GRAPHICS UNIT STORE SOMETHING IN BB0 */ - WRITE_REG32(GP_DST_XCOOR, 0x00000000); /* AT (0,0) */ - WRITE_REG32(GP_WIDTH, 0x00010004); /* 4x1 BLT */ - WRITE_REG16(GP_RASTER_MODE, 0x00AA); /* KEEP DST */ - WRITE_REG16(GP_BLIT_MODE, BM_READ_DST_FB0); /* STORE IN BB0 */ + WRITE_REG32(GP_DST_XCOOR, 0x00000000); /* AT (0,0) */ + WRITE_REG32(GP_WIDTH, 0x00010004); /* 4x1 BLT */ + WRITE_REG16(GP_RASTER_MODE, 0x00AA); /* KEEP DST */ + WRITE_REG16(GP_BLIT_MODE, BM_READ_DST_FB0); /* STORE IN BB0 */ - /* CHECK 3K LOCATION */ - /* Breaks if data happened to be 0xFEEDFACE - unlikely. */ + /* CHECK 3K LOCATION */ + /* Breaks if data happened to be 0xFEEDFACE - unlikely. */ - GFX_WAIT_BUSY; - if (READ_SCRATCH32(BB0_BASE_3K) != 0xFEEDFACE) { - GFXbb0Base = BB0_BASE_3K; - GFXbb1Base = BB1_BASE_3K; - } - } + GFX_WAIT_BUSY; + if (READ_SCRATCH32(BB0_BASE_3K) != 0xFEEDFACE) { + GFXbb0Base = BB0_BASE_3K; + GFXbb1Base = BB1_BASE_3K; + } + } } /* END OF FILE */ diff --git a/src/gfx/rndr_gu2.c b/src/gfx/rndr_gu2.c index 9378328..671d7a9 100644 --- a/src/gfx/rndr_gu2.c +++ b/src/gfx/rndr_gu2.c @@ -166,53 +166,53 @@ void gu2_set_bpp(unsigned short bpp); void gu2_set_solid_pattern(unsigned long color); void gu2_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparency); + unsigned long data0, unsigned long data1, + unsigned char transparency); void gu2_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned char transparency); + unsigned long data0, unsigned long data1, + unsigned long data2, unsigned long data3, + unsigned char transparency); void gu2_load_color_pattern_line(short y, unsigned long *pattern_8x8); void gu2_set_solid_source(unsigned long color); void gu2_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned short transparent); + unsigned short transparent); void gu2_set_pattern_flags(unsigned short flags); void gu2_set_raster_operation(unsigned char rop); void gu2_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height); + unsigned short width, unsigned short height); void gu2_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long *pattern); + unsigned short width, unsigned short height, + unsigned long *pattern); void gu2_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height); + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height); void gu2_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color); + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color); void gu2_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, - unsigned short height, - unsigned char *data, long pitch); + unsigned short dstx, unsigned short dsty, + unsigned short width, + unsigned short height, + unsigned char *data, long pitch); void gu2_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, - unsigned short height, - unsigned char *data, long pitch, - unsigned long color); + unsigned short dstx, unsigned short dsty, + unsigned short width, + unsigned short height, + unsigned char *data, long pitch, + unsigned long color); void gu2_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, - unsigned short height, unsigned char *data, - short pitch); + unsigned short dstx, unsigned short dsty, + unsigned short width, + unsigned short height, unsigned char *data, + short pitch); void gu2_text_blt(unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data); + unsigned short width, unsigned short height, + unsigned char *data); void gu2_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags); + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags); void gu2_wait_until_idle(void); int gu2_test_blt_pending(void); @@ -225,31 +225,31 @@ void gu22_set_source_transparency(unsigned long color, unsigned long mask); void gu22_set_alpha_mode(int mode); void gu22_set_alpha_value(unsigned char value); void gu22_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height); + unsigned short height); void gu22_color_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned long *pattern); + unsigned short height, unsigned long *pattern); void gu22_screen_to_screen_blt(unsigned long srcoffset, - unsigned long dstoffset, unsigned short width, - unsigned short height, int flags); + unsigned long dstoffset, unsigned short width, + unsigned short height, int flags); void gu22_mono_expand_blt(unsigned long srcbase, unsigned short srcx, - unsigned short srcy, unsigned long dstoffset, - unsigned short width, unsigned short height, - int byte_packed); + unsigned short srcy, unsigned long dstoffset, + unsigned short width, unsigned short height, + int byte_packed); void gu22_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned long dstoffset, - unsigned short width, - unsigned short height, - unsigned char *data, short pitch); + unsigned long dstoffset, + unsigned short width, + unsigned short height, + unsigned char *data, short pitch); void gu22_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned long dstoffset, - unsigned short width, - unsigned short height, - unsigned char *data, short pitch); + unsigned long dstoffset, + unsigned short width, + unsigned short height, + unsigned char *data, short pitch); void gu22_text_blt(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data); + unsigned short height, unsigned char *data); void gu22_bresenham_line(unsigned long dstoffset, unsigned short length, - unsigned short initerr, unsigned short axialerr, - unsigned short diagerr, unsigned short flags); + unsigned short initerr, unsigned short axialerr, + unsigned short diagerr, unsigned short flags); void gu22_sync_to_vblank(void); void gu2_reset_pitch(unsigned short pitch); @@ -297,9 +297,9 @@ void gfx_reset_pitch(unsigned short pitch) #endif { - gu2_pitch = pitch; - gu2_dst_pitch = pitch; - gu2_src_pitch = pitch; + gu2_pitch = pitch; + gu2_dst_pitch = pitch; + gu2_src_pitch = pitch; } /*--------------------------------------------------------------------------- @@ -319,44 +319,44 @@ void gfx_set_bpp(unsigned short bpp) #endif { - GFXbpp = bpp; - - /* COVERT TO BPP/FORMAT VALUE */ - /* Save in global to combine with ROP later. */ - /* Could write register here and then use byte access for */ - /* the ROP, but would need to set other 24 bits to make */ - /* sure all are set to their appropriate values. */ - - switch (bpp) { - case 8: - gu2_bpp = MGP_RM_BPPFMT_332; - gu2_xshift = 0; - break; - case 12: - gu2_bpp = MGP_RM_BPPFMT_4444; - gu2_xshift = 1; - break; - case 15: - gu2_bpp = MGP_RM_BPPFMT_1555; - gu2_xshift = 1; - break; - case 16: - gu2_bpp = MGP_RM_BPPFMT_565; - gu2_xshift = 1; - break; - case 32: - gu2_bpp = MGP_RM_BPPFMT_8888; - gu2_xshift = 2; - break; - } - - /* SET INITIAL ROP BASED ONLY ON BPP */ - /* Needs to be set before loading any pattern or source colors. */ - /* We must wait for BUSY because these bits are not pipelined */ - /* in the hardware. */ - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_RASTER_MODE, gu2_bpp); + GFXbpp = bpp; + + /* COVERT TO BPP/FORMAT VALUE */ + /* Save in global to combine with ROP later. */ + /* Could write register here and then use byte access for */ + /* the ROP, but would need to set other 24 bits to make */ + /* sure all are set to their appropriate values. */ + + switch (bpp) { + case 8: + gu2_bpp = MGP_RM_BPPFMT_332; + gu2_xshift = 0; + break; + case 12: + gu2_bpp = MGP_RM_BPPFMT_4444; + gu2_xshift = 1; + break; + case 15: + gu2_bpp = MGP_RM_BPPFMT_1555; + gu2_xshift = 1; + break; + case 16: + gu2_bpp = MGP_RM_BPPFMT_565; + gu2_xshift = 1; + break; + case 32: + gu2_bpp = MGP_RM_BPPFMT_8888; + gu2_xshift = 2; + break; + } + + /* SET INITIAL ROP BASED ONLY ON BPP */ + /* Needs to be set before loading any pattern or source colors. */ + /* We must wait for BUSY because these bits are not pipelined */ + /* in the hardware. */ + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_RASTER_MODE, gu2_bpp); } /* @@ -376,14 +376,14 @@ void gfx_set_solid_source(unsigned long color) #endif { - /* CLEAR TRANSPARENCY FLAG */ + /* CLEAR TRANSPARENCY FLAG */ - GFXsourceFlags = 0; + GFXsourceFlags = 0; - /* WRITE REGISTERS TO SPECIFY SOURCE COLOR */ + /* WRITE REGISTERS TO SPECIFY SOURCE COLOR */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_COLOR_FG, color); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_COLOR_FG, color); } /* @@ -398,22 +398,22 @@ gfx_set_solid_source(unsigned long color) #if GFX_2DACCEL_DYNAMIC void gu2_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned short transparent) + unsigned short transparent) #else void gfx_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned short transparent) + unsigned short transparent) #endif { - /* SET TRANSPARENCY FLAG */ + /* SET TRANSPARENCY FLAG */ - GFXsourceFlags = transparent ? MGP_RM_SRC_TRANS : 0; + GFXsourceFlags = transparent ? MGP_RM_SRC_TRANS : 0; - /* WRITE COLOR VALUES */ + /* WRITE COLOR VALUES */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_COLOR_FG, fgcolor); - WRITE_GP32(MGP_SRC_COLOR_BG, bgcolor); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_COLOR_FG, fgcolor); + WRITE_GP32(MGP_SRC_COLOR_BG, bgcolor); } /* @@ -436,19 +436,19 @@ void gfx_set_solid_pattern(unsigned long color) #endif { - /* CLEAR TRANSPARENCY FLAG */ + /* CLEAR TRANSPARENCY FLAG */ - GFXsourceFlags = 0; + GFXsourceFlags = 0; - /* SET PATTERN FLAGS */ + /* SET PATTERN FLAGS */ - GFXpatternFlags = 0; + GFXpatternFlags = 0; - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_bpp); - WRITE_GP32(MGP_PAT_COLOR_0, color); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_bpp); + WRITE_GP32(MGP_PAT_COLOR_0, color); } /* @@ -461,34 +461,34 @@ gfx_set_solid_pattern(unsigned long color) #if GFX_2DACCEL_DYNAMIC void gu2_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned char transparent) #else void gfx_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned char transparent) #endif { - /* CLEAR TRANSPARENCY FLAG */ + /* CLEAR TRANSPARENCY FLAG */ - GFXsourceFlags = 0; + GFXsourceFlags = 0; - /* SET PATTERN FLAGS */ + /* SET PATTERN FLAGS */ - if (transparent) - GFXpatternFlags = MGP_RM_PAT_MONO | MGP_RM_PAT_TRANS; - else - GFXpatternFlags = MGP_RM_PAT_MONO; + if (transparent) + GFXpatternFlags = MGP_RM_PAT_MONO | MGP_RM_PAT_TRANS; + else + GFXpatternFlags = MGP_RM_PAT_MONO; - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GFXpatternFlags); - WRITE_GP32(MGP_PAT_COLOR_0, bgcolor); - WRITE_GP32(MGP_PAT_COLOR_1, fgcolor); - WRITE_GP32(MGP_PAT_DATA_0, data0); - WRITE_GP32(MGP_PAT_DATA_1, data1); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GFXpatternFlags); + WRITE_GP32(MGP_PAT_COLOR_0, bgcolor); + WRITE_GP32(MGP_PAT_COLOR_1, fgcolor); + WRITE_GP32(MGP_PAT_DATA_0, data0); + WRITE_GP32(MGP_PAT_DATA_1, data1); } /* @@ -501,18 +501,18 @@ gfx_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, #if GFX_2DACCEL_DYNAMIC void gu2_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned long data2, unsigned long data3, + unsigned char transparent) #else void gfx_set_color_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned long data2, unsigned long data3, - unsigned char transparent) + unsigned long data0, unsigned long data1, + unsigned long data2, unsigned long data3, + unsigned char transparent) #endif { - /* REMOVE */ + /* REMOVE */ } /* @@ -530,80 +530,82 @@ void gfx_load_color_pattern_line(short y, unsigned long *pattern_8x8) #endif { - unsigned long temp1, temp2, temp3, temp4; - - /* CLEAR TRANSPARENCY FLAG */ - - GFXsourceFlags = 0; - - /* SET PATTERN FLAGS */ - - GFXpatternFlags = MGP_RM_PAT_COLOR; - - /* OVERRIDE THE RASTER MODE REGISTER */ - /* If the pattern format is set to anything but color */ - /* before loading the registers, some of the data will */ - /* be duplicated according to the current mode. */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, - (gu2_rop32 & ~MGP_RM_PAT_FLAGS) | MGP_RM_PAT_COLOR); - - /* LOAD THE PATTERN DATA */ - /* This routine is designed to work in tandem with gfx_pattern_fill. */ - /* It is used for cases when multiple BLTs with color pattern data */ - /* are desired on the same line. It would be inefficient to */ - /* repeatedly call gfx_color_pattern_fill for each single-line BLT. */ - /* So, we will simply replicate the pattern data across all available */ - /* lines such that the pattern y origin plays no part in the BLT. */ - - /* 8 BPP */ - - if (gu2_xshift == 0) { - pattern_8x8 += (y & 7) << 1; - temp1 = BYTE_SWIZZLE(pattern_8x8[0]); - temp2 = BYTE_SWIZZLE(pattern_8x8[1]); - WRITE_GP32(MGP_PAT_DATA_1, temp1); - WRITE_GP32(MGP_PAT_DATA_0, temp2); - WRITE_GP32(MGP_PAT_COLOR_1, temp1); - WRITE_GP32(MGP_PAT_COLOR_0, temp2); - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_3, temp1); - WRITE_GP32(MGP_PAT_COLOR_2, temp2); - WRITE_GP32(MGP_PAT_COLOR_5, temp1); - WRITE_GP32(MGP_PAT_COLOR_4, temp2); - } else if (gu2_xshift == 1) { - pattern_8x8 += (y & 7) << 2; - temp1 = WORD_SWIZZLE(pattern_8x8[0]); - temp2 = WORD_SWIZZLE(pattern_8x8[1]); - temp3 = WORD_SWIZZLE(pattern_8x8[2]); - temp4 = WORD_SWIZZLE(pattern_8x8[3]); - - WRITE_GP32(MGP_PAT_COLOR_1, temp1); - WRITE_GP32(MGP_PAT_COLOR_0, temp2); - WRITE_GP32(MGP_PAT_DATA_1, temp3); - WRITE_GP32(MGP_PAT_DATA_0, temp4); - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_5, temp1); - WRITE_GP32(MGP_PAT_COLOR_4, temp2); - WRITE_GP32(MGP_PAT_COLOR_3, temp3); - WRITE_GP32(MGP_PAT_COLOR_2, temp4); - } else { - pattern_8x8 += (y & 7) << 3; - - WRITE_GP32(MGP_PAT_COLOR_1, pattern_8x8[4]); - WRITE_GP32(MGP_PAT_COLOR_0, pattern_8x8[5]); - WRITE_GP32(MGP_PAT_DATA_1, pattern_8x8[6]); - WRITE_GP32(MGP_PAT_DATA_0, pattern_8x8[7]); - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_5, pattern_8x8[0]); - WRITE_GP32(MGP_PAT_COLOR_4, pattern_8x8[1]); - WRITE_GP32(MGP_PAT_COLOR_3, pattern_8x8[2]); - WRITE_GP32(MGP_PAT_COLOR_2, pattern_8x8[3]); - } + unsigned long temp1, temp2, temp3, temp4; + + /* CLEAR TRANSPARENCY FLAG */ + + GFXsourceFlags = 0; + + /* SET PATTERN FLAGS */ + + GFXpatternFlags = MGP_RM_PAT_COLOR; + + /* OVERRIDE THE RASTER MODE REGISTER */ + /* If the pattern format is set to anything but color */ + /* before loading the registers, some of the data will */ + /* be duplicated according to the current mode. */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, + (gu2_rop32 & ~MGP_RM_PAT_FLAGS) | MGP_RM_PAT_COLOR); + + /* LOAD THE PATTERN DATA */ + /* This routine is designed to work in tandem with gfx_pattern_fill. */ + /* It is used for cases when multiple BLTs with color pattern data */ + /* are desired on the same line. It would be inefficient to */ + /* repeatedly call gfx_color_pattern_fill for each single-line BLT. */ + /* So, we will simply replicate the pattern data across all available */ + /* lines such that the pattern y origin plays no part in the BLT. */ + + /* 8 BPP */ + + if (gu2_xshift == 0) { + pattern_8x8 += (y & 7) << 1; + temp1 = BYTE_SWIZZLE(pattern_8x8[0]); + temp2 = BYTE_SWIZZLE(pattern_8x8[1]); + WRITE_GP32(MGP_PAT_DATA_1, temp1); + WRITE_GP32(MGP_PAT_DATA_0, temp2); + WRITE_GP32(MGP_PAT_COLOR_1, temp1); + WRITE_GP32(MGP_PAT_COLOR_0, temp2); + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_3, temp1); + WRITE_GP32(MGP_PAT_COLOR_2, temp2); + WRITE_GP32(MGP_PAT_COLOR_5, temp1); + WRITE_GP32(MGP_PAT_COLOR_4, temp2); + } + else if (gu2_xshift == 1) { + pattern_8x8 += (y & 7) << 2; + temp1 = WORD_SWIZZLE(pattern_8x8[0]); + temp2 = WORD_SWIZZLE(pattern_8x8[1]); + temp3 = WORD_SWIZZLE(pattern_8x8[2]); + temp4 = WORD_SWIZZLE(pattern_8x8[3]); + + WRITE_GP32(MGP_PAT_COLOR_1, temp1); + WRITE_GP32(MGP_PAT_COLOR_0, temp2); + WRITE_GP32(MGP_PAT_DATA_1, temp3); + WRITE_GP32(MGP_PAT_DATA_0, temp4); + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_5, temp1); + WRITE_GP32(MGP_PAT_COLOR_4, temp2); + WRITE_GP32(MGP_PAT_COLOR_3, temp3); + WRITE_GP32(MGP_PAT_COLOR_2, temp4); + } + else { + pattern_8x8 += (y & 7) << 3; + + WRITE_GP32(MGP_PAT_COLOR_1, pattern_8x8[4]); + WRITE_GP32(MGP_PAT_COLOR_0, pattern_8x8[5]); + WRITE_GP32(MGP_PAT_DATA_1, pattern_8x8[6]); + WRITE_GP32(MGP_PAT_DATA_0, pattern_8x8[7]); + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_5, pattern_8x8[0]); + WRITE_GP32(MGP_PAT_COLOR_4, pattern_8x8[1]); + WRITE_GP32(MGP_PAT_COLOR_3, pattern_8x8[2]); + WRITE_GP32(MGP_PAT_COLOR_2, pattern_8x8[3]); + } } /* @@ -622,33 +624,34 @@ void gfx_set_raster_operation(unsigned char rop) #endif { - gu2_blt_mode = 0; + gu2_blt_mode = 0; - /* DISABLE ALPHA BLENDING */ + /* DISABLE ALPHA BLENDING */ - gu2_alpha_active = 0; + gu2_alpha_active = 0; - /* GENERATE 32-BIT VERSION OF ROP WITH PATTERN FLAGS */ + /* GENERATE 32-BIT VERSION OF ROP WITH PATTERN FLAGS */ - gu2_rop32 = (unsigned long)rop | GFXpatternFlags | gu2_bpp; + gu2_rop32 = (unsigned long) rop | GFXpatternFlags | gu2_bpp; - /* CHECK IF SOURCE FLAGS SHOULD BE MERGED */ + /* CHECK IF SOURCE FLAGS SHOULD BE MERGED */ - if ((rop & 0x33) ^ ((rop >> 2) & 0x33)) - gu2_rop32 |= GFXsourceFlags; - else - gu2_blt_mode = 0x40; + if ((rop & 0x33) ^ ((rop >> 2) & 0x33)) + gu2_rop32 |= GFXsourceFlags; + else + gu2_blt_mode = 0x40; - /* SET FLAG INDICATING ROP REQUIRES DESTINATION DATA */ - /* True if even bits (0:2:4:6) do not equal the corresponding */ - /* even bits (1:3:5:7). */ + /* SET FLAG INDICATING ROP REQUIRES DESTINATION DATA */ + /* True if even bits (0:2:4:6) do not equal the corresponding */ + /* even bits (1:3:5:7). */ - if ((rop & 0x55) ^ ((rop >> 1) & 0x55)) { - gu2_blt_mode |= MGP_BM_DST_REQ; - gu2_vector_mode = MGP_VM_DST_REQ; - } else { - gu2_vector_mode = 0; - } + if ((rop & 0x55) ^ ((rop >> 1) & 0x55)) { + gu2_blt_mode |= MGP_BM_DST_REQ; + gu2_vector_mode = MGP_VM_DST_REQ; + } + else { + gu2_vector_mode = 0; + } } /* @@ -669,39 +672,39 @@ gfx_set_raster_operation(unsigned char rop) #if GFX_2DACCEL_DYNAMIC void gu2_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) #else void gfx_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) #endif { - unsigned long offset = 0, size; + unsigned long offset = 0, size; - size = (((unsigned long)width) << 16) | height; + size = (((unsigned long) width) << 16) | height; - /* CALCULATE STARTING OFFSET */ + /* CALCULATE STARTING OFFSET */ - offset = (unsigned long)y *gu2_pitch + (((unsigned long)x) << gu2_xshift); + offset = (unsigned long) y *gu2_pitch + (((unsigned long) x) << gu2_xshift); - /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ + /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ - if (GFXpatternFlags) { - /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ + if (GFXpatternFlags) { + /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ - offset |= ((unsigned long)(x & 7)) << 26; - offset |= ((unsigned long)(y & 7)) << 29; - } + offset |= ((unsigned long) (x & 7)) << 26; + offset |= ((unsigned long) (y & 7)) << 29; + } - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_DST_OFFSET, offset); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_pitch); - WRITE_GP32(MGP_BLT_MODE, gu2_blt_mode); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_DST_OFFSET, offset); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_pitch); + WRITE_GP32(MGP_BLT_MODE, gu2_blt_mode); } /* @@ -723,30 +726,30 @@ gfx_pattern_fill(unsigned short x, unsigned short y, #if GFX_2DACCEL_DYNAMIC void gu2_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long *pattern) + unsigned short width, unsigned short height, + unsigned long *pattern) #else void gfx_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long *pattern) + unsigned short width, unsigned short height, + unsigned long *pattern) #endif { - /* CALL GFX2 ROUTINE TO AVOID DUPLICATION OF CODE */ + /* CALL GFX2 ROUTINE TO AVOID DUPLICATION OF CODE */ - unsigned long offset = (unsigned long)y * gu2_pitch + - (((unsigned long)x) << gu2_xshift); - unsigned long origin = gu2_pattern_origin; - unsigned long pitch = gu2_dst_pitch; + unsigned long offset = (unsigned long) y * gu2_pitch + + (((unsigned long) x) << gu2_xshift); + unsigned long origin = gu2_pattern_origin; + unsigned long pitch = gu2_dst_pitch; - gfx2_set_pattern_origin(x, y); - gfx2_set_destination_stride((unsigned short)gu2_pitch); - gfx2_color_pattern_fill(offset, width, height, pattern); + gfx2_set_pattern_origin(x, y); + gfx2_set_destination_stride((unsigned short) gu2_pitch); + gfx2_color_pattern_fill(offset, width, height, pattern); - /* RESTORE GFX2 VALUES */ + /* RESTORE GFX2 VALUES */ - gu2_pattern_origin = origin; - gu2_dst_pitch = pitch; + gu2_pattern_origin = origin; + gu2_dst_pitch = pitch; } /* @@ -767,70 +770,70 @@ gfx_color_pattern_fill(unsigned short x, unsigned short y, #if GFX_2DACCEL_DYNAMIC void gu2_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height) #else void gfx_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height) #endif { - unsigned long srcoffset, dstoffset, size; - unsigned short blt_mode; - - size = (((unsigned long)width) << 16) | height; - - /* CALCULATE THE DIRECTION OF THE BLT */ - - blt_mode = gu2_blt_mode | MGP_BM_SRC_FB; - if (dstx > srcx) { - blt_mode |= MGP_BM_NEG_XDIR; - srcx += width - 1; - dstx += width - 1; - } - if (dsty > srcy) { - blt_mode |= MGP_BM_NEG_YDIR; - srcy += height - 1; - dsty += height - 1; - } - - /* CALCULATE STARTING OFFSETS */ - - srcoffset = (unsigned long)srcy *gu2_pitch + - (((unsigned long)srcx) << gu2_xshift); - dstoffset = ((unsigned long)dsty * gu2_pitch + - (((unsigned long)dstx) << gu2_xshift)) & 0xFFFFFF; - - /* MERGE PATTERN INFORMATION */ - /* This must be done after the x and y coordinates have been updated, */ - /* as the x and y pattern origins correspond to the first ROPed pixel. */ - - if (GFXpatternFlags) { - /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ - - dstoffset |= ((unsigned long)(dstx & 7)) << 26; - dstoffset |= ((unsigned long)(dsty & 7)) << 29; - } - - /* TURN INTO BYTE ADDRESS IF NEGATIVE X DIRECTION */ - /* This is a quirk of the hardware. */ - - if (blt_mode & MGP_BM_NEG_XDIR) { - srcoffset += (1 << gu2_xshift) - 1; - dstoffset += (1 << gu2_xshift) - 1; - } - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_SRC_OFFSET, srcoffset); - WRITE_GP32(MGP_DST_OFFSET, dstoffset); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_pitch | (gu2_pitch << 16)); - WRITE_GP16(MGP_BLT_MODE, blt_mode); + unsigned long srcoffset, dstoffset, size; + unsigned short blt_mode; + + size = (((unsigned long) width) << 16) | height; + + /* CALCULATE THE DIRECTION OF THE BLT */ + + blt_mode = gu2_blt_mode | MGP_BM_SRC_FB; + if (dstx > srcx) { + blt_mode |= MGP_BM_NEG_XDIR; + srcx += width - 1; + dstx += width - 1; + } + if (dsty > srcy) { + blt_mode |= MGP_BM_NEG_YDIR; + srcy += height - 1; + dsty += height - 1; + } + + /* CALCULATE STARTING OFFSETS */ + + srcoffset = (unsigned long) srcy *gu2_pitch + + (((unsigned long) srcx) << gu2_xshift); + dstoffset = ((unsigned long) dsty * gu2_pitch + + (((unsigned long) dstx) << gu2_xshift)) & 0xFFFFFF; + + /* MERGE PATTERN INFORMATION */ + /* This must be done after the x and y coordinates have been updated, */ + /* as the x and y pattern origins correspond to the first ROPed pixel. */ + + if (GFXpatternFlags) { + /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ + + dstoffset |= ((unsigned long) (dstx & 7)) << 26; + dstoffset |= ((unsigned long) (dsty & 7)) << 29; + } + + /* TURN INTO BYTE ADDRESS IF NEGATIVE X DIRECTION */ + /* This is a quirk of the hardware. */ + + if (blt_mode & MGP_BM_NEG_XDIR) { + srcoffset += (1 << gu2_xshift) - 1; + dstoffset += (1 << gu2_xshift) - 1; + } + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_SRC_OFFSET, srcoffset); + WRITE_GP32(MGP_DST_OFFSET, dstoffset); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_pitch | (gu2_pitch << 16)); + WRITE_GP16(MGP_BLT_MODE, blt_mode); } /* @@ -852,43 +855,43 @@ gfx_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu2_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color) #else void gfx_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color) #endif { - unsigned long rop32; + unsigned long rop32; - /* SAVE ORIGINAL RASTER MODE SETTINGS */ + /* SAVE ORIGINAL RASTER MODE SETTINGS */ - rop32 = gu2_rop32; + rop32 = gu2_rop32; - /* WRITE REGISTERS TO SPECIFY COLOR TRANSPARENCY */ - /* Match GU1 implementation that only allows SRCCOPY for the ROP. */ + /* WRITE REGISTERS TO SPECIFY COLOR TRANSPARENCY */ + /* Match GU1 implementation that only allows SRCCOPY for the ROP. */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_COLOR_FG, color); - WRITE_GP32(MGP_SRC_COLOR_BG, 0xFFFFFFFF); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_COLOR_FG, color); + WRITE_GP32(MGP_SRC_COLOR_BG, 0xFFFFFFFF); - /* SET GLOBAL RASTER SETTINGS */ - /* This is needed, as the screen-to-screen BLT */ - /* routine will overwrite the raster mode register. */ + /* SET GLOBAL RASTER SETTINGS */ + /* This is needed, as the screen-to-screen BLT */ + /* routine will overwrite the raster mode register. */ - gu2_rop32 = gu2_bpp | MGP_RM_SRC_TRANS | 0xCC; + gu2_rop32 = gu2_bpp | MGP_RM_SRC_TRANS | 0xCC; - /* CALL NORMAL SCREEN TO SCREEN BLT ROUTINE */ + /* CALL NORMAL SCREEN TO SCREEN BLT ROUTINE */ - gfx_screen_to_screen_blt(srcx, srcy, dstx, dsty, width, height); + gfx_screen_to_screen_blt(srcx, srcy, dstx, dsty, width, height); - /* RESTORE GLOBAL RASTER SETTINGS */ + /* RESTORE GLOBAL RASTER SETTINGS */ - gu2_rop32 = rop32; + gu2_rop32 = rop32; } /* @@ -913,85 +916,85 @@ gfx_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu2_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch) #else void gfx_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch) #endif { - unsigned long dstoffset, srcoffset, size, bytes; - unsigned long offset, temp_offset; - unsigned long dword_bytes, bytes_extra; - unsigned short blt_mode; - - blt_mode = gu2_blt_mode | MGP_BM_SRC_FB; - size = (((unsigned long)width) << 16) | 1; - - /* CALCULATE STARTING OFFSETS */ - - offset = (unsigned long)srcy *pitch + ((unsigned long)srcx << gu2_xshift); - - dstoffset = (unsigned long)dsty *gu2_pitch + - (((unsigned long)dstx) << gu2_xshift); - - /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ - - if (GFXpatternFlags) { - /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ - - dstoffset |= ((unsigned long)(dstx & 7)) << 26; - dstoffset |= ((unsigned long)(dsty & 7)) << 29; - } - - bytes = width << gu2_xshift; - dword_bytes = bytes & ~0x3L; - bytes_extra = bytes & 0x3L; - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ - /* The source offset is always 0 since we allow misaligned dword reads. */ - /* We must wait for BLT busy because the GP may be executing a screen */ - /* to screen BLT from the scratchpad area. */ - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_pitch); - - /* WRITE DATA ONE LINE AT A TIME */ - /* For speed reasons, data is written to an offscreen scratch area and then */ - /* BLTed using a screen to screen BLT. This is similar to the GX1 BLT buffers, but */ - /* slightly more efficient in that we can queue up data while the GP is rendering */ - /* a line. */ - - while (height--) { - temp_offset = offset; - srcoffset = gfx_gx2_scratch_base; - if (gu2_current_line) - srcoffset += 8192; - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_OFFSET, srcoffset); - WRITE_GP32(MGP_DST_OFFSET, dstoffset); - dstoffset += gu2_pitch; - dstoffset += 0x20000000; - - WRITE_FRAME_BUFFER_STRING32(srcoffset, dword_bytes, data, temp_offset); - if (bytes_extra) { - temp_offset += dword_bytes; - srcoffset += dword_bytes; - WRITE_FRAME_BUFFER_STRING8(srcoffset, bytes_extra, data, - temp_offset); - } - WRITE_GP16(MGP_BLT_MODE, blt_mode); - offset += pitch; - gu2_current_line = 1 - gu2_current_line; - } + unsigned long dstoffset, srcoffset, size, bytes; + unsigned long offset, temp_offset; + unsigned long dword_bytes, bytes_extra; + unsigned short blt_mode; + + blt_mode = gu2_blt_mode | MGP_BM_SRC_FB; + size = (((unsigned long) width) << 16) | 1; + + /* CALCULATE STARTING OFFSETS */ + + offset = (unsigned long) srcy *pitch + ((unsigned long) srcx << gu2_xshift); + + dstoffset = (unsigned long) dsty *gu2_pitch + + (((unsigned long) dstx) << gu2_xshift); + + /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ + + if (GFXpatternFlags) { + /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ + + dstoffset |= ((unsigned long) (dstx & 7)) << 26; + dstoffset |= ((unsigned long) (dsty & 7)) << 29; + } + + bytes = width << gu2_xshift; + dword_bytes = bytes & ~0x3L; + bytes_extra = bytes & 0x3L; + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ + /* The source offset is always 0 since we allow misaligned dword reads. */ + /* We must wait for BLT busy because the GP may be executing a screen */ + /* to screen BLT from the scratchpad area. */ + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_pitch); + + /* WRITE DATA ONE LINE AT A TIME */ + /* For speed reasons, data is written to an offscreen scratch area and then */ + /* BLTed using a screen to screen BLT. This is similar to the GX1 BLT buffers, but */ + /* slightly more efficient in that we can queue up data while the GP is rendering */ + /* a line. */ + + while (height--) { + temp_offset = offset; + srcoffset = gfx_gx2_scratch_base; + if (gu2_current_line) + srcoffset += 8192; + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_OFFSET, srcoffset); + WRITE_GP32(MGP_DST_OFFSET, dstoffset); + dstoffset += gu2_pitch; + dstoffset += 0x20000000; + + WRITE_FRAME_BUFFER_STRING32(srcoffset, dword_bytes, data, temp_offset); + if (bytes_extra) { + temp_offset += dword_bytes; + srcoffset += dword_bytes; + WRITE_FRAME_BUFFER_STRING8(srcoffset, bytes_extra, data, + temp_offset); + } + WRITE_GP16(MGP_BLT_MODE, blt_mode); + offset += pitch; + gu2_current_line = 1 - gu2_current_line; + } } /* @@ -1017,46 +1020,46 @@ gfx_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu2_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch, + unsigned long color) #else void gfx_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, long pitch, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, long pitch, + unsigned long color) #endif { - unsigned long rop32; + unsigned long rop32; - /* SAVE EXISTING RASTER MODE SETTINGS */ + /* SAVE EXISTING RASTER MODE SETTINGS */ - rop32 = gu2_rop32; + rop32 = gu2_rop32; - /* WRITE REGISTERS TO SPECIFY COLOR TRANSPARENCY */ - /* Match GU1 implementation that only allows SRCCOPY for the ROP. */ + /* WRITE REGISTERS TO SPECIFY COLOR TRANSPARENCY */ + /* Match GU1 implementation that only allows SRCCOPY for the ROP. */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_COLOR_FG, color); - WRITE_GP32(MGP_SRC_COLOR_BG, 0xFFFFFFFF); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_COLOR_FG, color); + WRITE_GP32(MGP_SRC_COLOR_BG, 0xFFFFFFFF); - /* SET GLOBAL RASTER SETTINGS */ - /* This is needed, as the screen-to-screen BLT */ - /* routine will overwrite the raster mode register. */ + /* SET GLOBAL RASTER SETTINGS */ + /* This is needed, as the screen-to-screen BLT */ + /* routine will overwrite the raster mode register. */ - gu2_rop32 = gu2_bpp | MGP_RM_SRC_TRANS | 0xCC; + gu2_rop32 = gu2_bpp | MGP_RM_SRC_TRANS | 0xCC; - /* CALL NORMAL COLOR BITMAP TO SCREEN BLT ROUTINE */ + /* CALL NORMAL COLOR BITMAP TO SCREEN BLT ROUTINE */ - gfx_color_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, - data, pitch); + gfx_color_bitmap_to_screen_blt(srcx, srcy, dstx, dsty, width, height, + data, pitch); - /* RESTORE RASTER SETTINGS */ + /* RESTORE RASTER SETTINGS */ - gu2_rop32 = rop32; + gu2_rop32 = rop32; } /* @@ -1078,94 +1081,95 @@ gfx_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu2_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, short pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, short pitch) #else void gfx_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, short pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, short pitch) #endif { - unsigned long dstoffset, size, bytes; - unsigned long offset, temp_offset, temp1 = 0, temp2 = 0; - unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; - unsigned long shift = 0; + unsigned long dstoffset, size, bytes; + unsigned long offset, temp_offset, temp1 = 0, temp2 = 0; + unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; + unsigned long shift = 0; - size = (((unsigned long)width) << 16) | height; + size = (((unsigned long) width) << 16) | height; - /* CALCULATE STARTING OFFSETS */ + /* CALCULATE STARTING OFFSETS */ - offset = (unsigned long)srcy *pitch + ((unsigned long)srcx >> 3); + offset = (unsigned long) srcy *pitch + ((unsigned long) srcx >> 3); - dstoffset = (unsigned long)dsty *gu2_pitch + - (((unsigned long)dstx) << gu2_xshift); + dstoffset = (unsigned long) dsty *gu2_pitch + + (((unsigned long) dstx) << gu2_xshift); - /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ + /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ - if (GFXpatternFlags) { - /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ + if (GFXpatternFlags) { + /* 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; - fifo_lines = bytes >> 5; - dwords_extra = (bytes & 0x0000001Cl) >> 2; - bytes_extra = bytes & 0x00000003l; + bytes = ((srcx & 7) + width + 7) >> 3; + fifo_lines = bytes >> 5; + dwords_extra = (bytes & 0x0000001Cl) >> 2; + bytes_extra = bytes & 0x00000003l; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ - /* The source offset is always 0 since we allow misaligned dword reads. */ - /* Need to wait for busy instead of pending, since hardware clears */ - /* the host data FIFO at the beginning of a BLT. */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ + /* The source offset is always 0 since we allow misaligned dword reads. */ + /* Need to wait for busy instead of pending, since hardware clears */ + /* the host data FIFO at the beginning of a BLT. */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_SRC_OFFSET, ((unsigned long)srcx & 7) << 26); - WRITE_GP32(MGP_DST_OFFSET, dstoffset); - 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_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_SRC_OFFSET, ((unsigned long) srcx & 7) << 26); + WRITE_GP32(MGP_DST_OFFSET, dstoffset); + 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); - /* WAIT FOR BLT TO BE LATCHED */ + /* WAIT FOR BLT TO BE LATCHED */ - GU2_WAIT_PENDING; + GU2_WAIT_PENDING; - /* WRITE ALL OF THE DATA TO THE HOST SOURCE REGISTER */ + /* WRITE ALL OF THE DATA TO THE HOST SOURCE REGISTER */ - while (height--) { - temp_offset = offset; + while (height--) { + 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(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(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(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(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; + } } /*--------------------------------------------------------------------------- @@ -1178,77 +1182,77 @@ gfx_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu2_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, - unsigned short height, unsigned char *data) + unsigned short height, unsigned char *data) #else void gfx_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, - unsigned short height, unsigned char *data) + unsigned short height, unsigned char *data) #endif { - unsigned long size, bytes; - unsigned long dstoffset, temp1 = 0, temp2 = 0, temp_offset = 0; - unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; - unsigned long shift; - - size = (((unsigned long)width) << 16) | height; - - dstoffset = (unsigned long)dsty *gu2_pitch + - (((unsigned long)dstx) << gu2_xshift); - - /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ - - if (GFXpatternFlags) { - /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ - - dstoffset |= ((unsigned long)(dstx & 7)) << 26; - dstoffset |= ((unsigned long)(dsty & 7)) << 29; - } - - /* CALCULATE STARTING OFFSETS */ - - bytes = ((width + 7) >> 3) * height; - fifo_lines = bytes >> 5; - dwords_extra = (bytes & 0x0000001Cl) >> 2; - bytes_extra = bytes & 0x00000003l; - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_SRC_OFFSET, 0); - WRITE_GP32(MGP_DST_OFFSET, dstoffset); - 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_BP_MONO); - - /* WAIT FOR BLT TO BE LATCHED */ - - GU2_WAIT_PENDING; - - /* WRITE ALL FULL FIFO LINES */ - - for (i = 0; i < fifo_lines; i++) { - GU2_WAIT_HALF_EMPTY; - WRITE_GPREG_STRING32(MGP_HST_SOURCE, 8, j, data, temp_offset, temp1); - temp_offset += 32; - } - - /* WRITE ALL FULL DWORDS */ - - if (dwords_extra || bytes_extra) { - GU2_WAIT_HALF_EMPTY; - if (dwords_extra) { - WRITE_GPREG_STRING32(MGP_HST_SOURCE, dwords_extra, i, data, - temp_offset, temp1); - temp_offset += (dwords_extra << 2); - } - if (bytes_extra) { - shift = 0; - WRITE_GPREG_STRING8(MGP_HST_SOURCE, bytes_extra, shift, i, data, - temp_offset, temp1, temp2); - } - } + unsigned long size, bytes; + unsigned long dstoffset, temp1 = 0, temp2 = 0, temp_offset = 0; + unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; + unsigned long shift; + + size = (((unsigned long) width) << 16) | height; + + dstoffset = (unsigned long) dsty *gu2_pitch + + (((unsigned long) dstx) << gu2_xshift); + + /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ + + if (GFXpatternFlags) { + /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ + + dstoffset |= ((unsigned long) (dstx & 7)) << 26; + dstoffset |= ((unsigned long) (dsty & 7)) << 29; + } + + /* CALCULATE STARTING OFFSETS */ + + bytes = ((width + 7) >> 3) * height; + fifo_lines = bytes >> 5; + dwords_extra = (bytes & 0x0000001Cl) >> 2; + bytes_extra = bytes & 0x00000003l; + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_SRC_OFFSET, 0); + WRITE_GP32(MGP_DST_OFFSET, dstoffset); + 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_BP_MONO); + + /* WAIT FOR BLT TO BE LATCHED */ + + GU2_WAIT_PENDING; + + /* WRITE ALL FULL FIFO LINES */ + + for (i = 0; i < fifo_lines; i++) { + GU2_WAIT_HALF_EMPTY; + WRITE_GPREG_STRING32(MGP_HST_SOURCE, 8, j, data, temp_offset, temp1); + temp_offset += 32; + } + + /* WRITE ALL FULL DWORDS */ + + if (dwords_extra || bytes_extra) { + GU2_WAIT_HALF_EMPTY; + if (dwords_extra) { + WRITE_GPREG_STRING32(MGP_HST_SOURCE, dwords_extra, i, data, + temp_offset, temp1); + temp_offset += (dwords_extra << 2); + } + if (bytes_extra) { + shift = 0; + WRITE_GPREG_STRING8(MGP_HST_SOURCE, bytes_extra, shift, i, data, + temp_offset, temp1, temp2); + } + } } /* @@ -1273,41 +1277,41 @@ gfx_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, #if GFX_2DACCEL_DYNAMIC void gu2_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) #else void gfx_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) #endif { - unsigned long offset; - unsigned long data1 = (((unsigned long)axialerr) << 16) | diagerr; - unsigned long data2 = (((unsigned long)length) << 16) | initerr; - unsigned short vector_mode = gu2_vector_mode | flags; + unsigned long offset; + unsigned long data1 = (((unsigned long) axialerr) << 16) | diagerr; + unsigned long data2 = (((unsigned long) length) << 16) | initerr; + unsigned short vector_mode = gu2_vector_mode | flags; - /* CALCULATE STARTING OFFSET */ + /* CALCULATE STARTING OFFSET */ - offset = (unsigned long)y *gu2_pitch + (((unsigned long)x) << gu2_xshift); + offset = (unsigned long) y *gu2_pitch + (((unsigned long) x) << gu2_xshift); - /* CHECK NULL LENGTH */ + /* CHECK NULL LENGTH */ - if (!length) - return; + if (!length) + return; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_DST_OFFSET, offset); - WRITE_GP32(MGP_VEC_ERR, data1); - WRITE_GP32(MGP_VEC_LEN, data2); - WRITE_GP32(MGP_STRIDE, gu2_pitch); - WRITE_GP32(MGP_VECTOR_MODE, vector_mode); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_DST_OFFSET, offset); + WRITE_GP32(MGP_VEC_ERR, data1); + WRITE_GP32(MGP_VEC_LEN, data2); + WRITE_GP32(MGP_STRIDE, gu2_pitch); + WRITE_GP32(MGP_VECTOR_MODE, vector_mode); } /*--------------------------------------------------------------------------- @@ -1325,7 +1329,7 @@ void gfx_wait_until_idle(void) #endif { - while (READ_GP32(MGP_BLT_STATUS) & MGP_BS_BLT_BUSY) ; + while (READ_GP32(MGP_BLT_STATUS) & MGP_BS_BLT_BUSY); } /*--------------------------------------------------------------------------- @@ -1346,9 +1350,9 @@ int gfx_test_blt_pending(void) #endif { - if (READ_GP32(MGP_BLT_STATUS) & MGP_BS_BLT_PENDING) - return (1); - return (0); + if (READ_GP32(MGP_BLT_STATUS) & MGP_BS_BLT_PENDING) + return (1); + return (0); } /*--------------------------------------------------------------------------- @@ -1371,9 +1375,9 @@ void gfx2_set_source_stride(unsigned short stride) #endif { - /* SAVE STRIDE TO BE USED LATER */ + /* SAVE STRIDE TO BE USED LATER */ - gu2_src_pitch = (unsigned long)stride; + gu2_src_pitch = (unsigned long) stride; } /*--------------------------------------------------------------------------- @@ -1390,9 +1394,9 @@ void gfx2_set_destination_stride(unsigned short stride) #endif { - /* SAVE STRIDE TO BE USED LATER */ + /* SAVE STRIDE TO BE USED LATER */ - gu2_dst_pitch = (unsigned long)stride; + gu2_dst_pitch = (unsigned long) stride; } /*--------------------------------------------------------------------------- @@ -1410,10 +1414,10 @@ void gfx2_set_pattern_origin(int x, int y) #endif { - /* STORE IN FORMAT THAT CAN BE COMBINED WITH THE DESTINATION OFFSET */ + /* STORE IN FORMAT THAT CAN BE COMBINED WITH THE DESTINATION OFFSET */ - gu2_pattern_origin = (((unsigned long)(x & 7)) << 26) | - (((unsigned long)(y & 7)) << 29); + gu2_pattern_origin = (((unsigned long) (x & 7)) << 26) | + (((unsigned long) (y & 7)) << 29); } /*--------------------------------------------------------------------------- @@ -1433,15 +1437,15 @@ void gfx2_set_source_transparency(unsigned long color, unsigned long mask) #endif { - /* WRITE REGISTERS TO SPECIFY COLOR TRANSPARENCY */ + /* WRITE REGISTERS TO SPECIFY COLOR TRANSPARENCY */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_COLOR_FG, color); - WRITE_GP32(MGP_SRC_COLOR_BG, mask); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_COLOR_FG, color); + WRITE_GP32(MGP_SRC_COLOR_BG, mask); - /* SET TRANSPARENCY FLAG */ + /* SET TRANSPARENCY FLAG */ - GFXsourceFlags = (color || mask) ? MGP_RM_SRC_TRANS : 0; + GFXsourceFlags = (color || mask) ? MGP_RM_SRC_TRANS : 0; } /*--------------------------------------------------------------------------- @@ -1459,9 +1463,9 @@ void gfx2_set_alpha_mode(int mode) #endif { - /* SAVE ALPHA MODE FOR LATER */ + /* SAVE ALPHA MODE FOR LATER */ - gu2_alpha_mode = mode; + gu2_alpha_mode = mode; } /*--------------------------------------------------------------------------- @@ -1479,82 +1483,82 @@ void gfx2_set_alpha_value(unsigned char value) #endif { - /* SAVE ALPHA VALUE TO BE USED LATER */ + /* SAVE ALPHA VALUE TO BE USED LATER */ - gu2_alpha_value = (unsigned long)value; + gu2_alpha_value = (unsigned long) value; - /* SET GLOBAL FLAG */ - /* gfx2_* routines will use this flag to program alpha values */ - /* appropriately. Normal gfx_* routines will always write */ - /* the current ROP settings. In this way, the alpha mode */ - /* affects only second generation routines. */ + /* SET GLOBAL FLAG */ + /* gfx2_* routines will use this flag to program alpha values */ + /* appropriately. Normal gfx_* routines will always write */ + /* the current ROP settings. In this way, the alpha mode */ + /* affects only second generation routines. */ - gu2_alpha_active = 1; + gu2_alpha_active = 1; - switch (gu2_alpha_mode) { - case ALPHA_MODE_BLEND: + switch (gu2_alpha_mode) { + case ALPHA_MODE_BLEND: - /* GENERATE 32-BIT VERSION OF RASTER MODE REGISTER */ - /* Pattern data is not involved in the operation. */ + /* GENERATE 32-BIT VERSION OF RASTER MODE REGISTER */ + /* Pattern data is not involved in the operation. */ - gu2_alpha32 = gu2_alpha_value | gu2_bpp; + gu2_alpha32 = gu2_alpha_value | gu2_bpp; - /* HANDLE SPECIAL CASES FOR ENDPOINTS */ - /* The 8-bit hardware alpha value is always */ - /* interpreted as a fraction. Consequently, there */ - /* is no way to use values of 255 or 0 to exclude */ - /* one of the inputs. */ + /* HANDLE SPECIAL CASES FOR ENDPOINTS */ + /* The 8-bit hardware alpha value is always */ + /* interpreted as a fraction. Consequently, there */ + /* is no way to use values of 255 or 0 to exclude */ + /* one of the inputs. */ - switch (gu2_alpha_value) { - /* DESTINATION ONLY */ - /* Operation is alpha * A, where A is destination */ - /* and alpha is 1. */ + switch (gu2_alpha_value) { + /* DESTINATION ONLY */ + /* Operation is alpha * A, where A is destination */ + /* and alpha is 1. */ - case 0: + case 0: - gu2_alpha32 |= MGP_RM_SELECT_ALPHA_1 | - MGP_RM_ALPHA_TIMES_A | - MGP_RM_ALPHA_TO_RGB | MGP_RM_DEST_FROM_CHAN_A; - break; + gu2_alpha32 |= MGP_RM_SELECT_ALPHA_1 | + MGP_RM_ALPHA_TIMES_A | + MGP_RM_ALPHA_TO_RGB | MGP_RM_DEST_FROM_CHAN_A; + break; - /* SOURCE ONLY */ - /* Operation is alpha * A, where A is source and */ - /* alpha is 1. */ + /* SOURCE ONLY */ + /* Operation is alpha * A, where A is source and */ + /* alpha is 1. */ - case 255: + case 255: - gu2_alpha32 |= MGP_RM_SELECT_ALPHA_1 | - MGP_RM_ALPHA_TO_RGB | MGP_RM_ALPHA_TIMES_A; - break; + gu2_alpha32 |= MGP_RM_SELECT_ALPHA_1 | + MGP_RM_ALPHA_TO_RGB | MGP_RM_ALPHA_TIMES_A; + break; - /* DEFAULT */ - /* Operation is alpha * A + (1 - alpha) * B; */ - /* A is source, B is destination and alpha is the */ - /* programmed 8-bit value. */ + /* DEFAULT */ + /* Operation is alpha * A + (1 - alpha) * B; */ + /* A is source, B is destination and alpha is the */ + /* programmed 8-bit value. */ - default: + default: - gu2_alpha32 |= MGP_RM_SELECT_ALPHA_R | - MGP_RM_ALPHA_TO_RGB | MGP_RM_ALPHA_A_PLUS_BETA_B; + gu2_alpha32 |= MGP_RM_SELECT_ALPHA_R | + MGP_RM_ALPHA_TO_RGB | MGP_RM_ALPHA_A_PLUS_BETA_B; - } + } - /* CHECK IF SOURCE INFORMATION SHOULD BE MERGED */ - /* Alpha value of 0 indicates destination only. */ + /* CHECK IF SOURCE INFORMATION SHOULD BE MERGED */ + /* Alpha value of 0 indicates destination only. */ - if (gu2_alpha_value != 0) - gu2_alpha32 |= GFXsourceFlags; + if (gu2_alpha_value != 0) + gu2_alpha32 |= GFXsourceFlags; - /* SET FLAG FOR DESTINATION DATA IF NECESSARY */ - /* Alpha value of 255 indicates no destination */ + /* SET FLAG FOR DESTINATION DATA IF NECESSARY */ + /* Alpha value of 255 indicates no destination */ - if (gu2_alpha_value != 255) { - gu2_alpha_blt_mode = MGP_BM_DST_REQ; - gu2_alpha_vec_mode = MGP_VM_DST_REQ; - } + if (gu2_alpha_value != 255) { + gu2_alpha_blt_mode = MGP_BM_DST_REQ; + gu2_alpha_vec_mode = MGP_VM_DST_REQ; + } - break; - } + break; + } } /*--------------------------------------------------------------------------- @@ -1568,28 +1572,28 @@ gfx2_set_alpha_value(unsigned char value) #if GFX_2DACCEL_DYNAMIC void gu22_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height) + unsigned short height) #else void gfx2_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height) + unsigned short height) #endif { - unsigned long size; + unsigned long size; - size = (((unsigned long)width) << 16) | height; + size = (((unsigned long) width) << 16) | height; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); - WRITE_GP32(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); + WRITE_GP32(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; } /*--------------------------------------------------------------------------- @@ -1604,275 +1608,296 @@ gfx2_pattern_fill(unsigned long dstoffset, unsigned short width, #if GFX_2DACCEL_DYNAMIC void gu22_color_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned long *pattern) + unsigned short height, unsigned long *pattern) #else void gfx2_color_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned long *pattern) + unsigned short height, unsigned long *pattern) #endif { - int pass; - unsigned long lines, size, patxorigin, patoffset; - - /* ONLY USE HW PATTERN ORIGIN FOR THE X DIRECTION */ - /* Y direction handled by referencing proper location in pattern data. */ - - patxorigin = (gu2_pattern_origin) & 0x1C000000; - - /* OVERRIDE PATTERN FLAGS IN ROP TO FORCE COLOR PATTERN */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, - (gu2_rop32 & ~MGP_RM_PAT_FLAGS) | MGP_RM_PAT_COLOR); - - /* ATTEMPT TO OPTIMIZE */ - /* If possible, we can perform the pattern fill in only a few passes */ - /* This is performed by multiplying the pitch by an appropriate amount. */ - /* Consequently, if the multiplied pitch exceeds 16 bits, this */ - /* optimization is impossible. */ - - if ((gu2_dst_pitch << (gu2_xshift + 1)) <= 0xFFFF) { - /* HANDLE VARIOUS COLOR DEPTHS DIFFERENTLY */ - - switch (gu2_xshift) { - case 0: /* 8 BPP */ - - /* TWO PASSES FOR 8 BPP */ - /* Render every other line per pass by doubling the pitch. */ - - patoffset = (gu2_pattern_origin >> 28) & 0x0E; - for (pass = 0; pass < 2; pass++) { - /* CAN WRITE SOME PATTERN REGISTERS WHILE "PENDING" */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); - lines = (height + 1 - pass) >> 1; - if (!lines) - break; - size = (((unsigned long)width) << 16) | lines; - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch << 1); - WRITE_GP32(MGP_PAT_DATA_1, BYTE_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_DATA_0, BYTE_SWIZZLE(pattern[patoffset + 1])); - patoffset = (patoffset + 4) & 0x0E; - WRITE_GP32(MGP_PAT_COLOR_1, BYTE_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_0, BYTE_SWIZZLE(pattern[patoffset + 1])); - patoffset = (patoffset + 4) & 0x0E; - - /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ - /* Those registers are not pipelined. */ - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_3, BYTE_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_2, BYTE_SWIZZLE(pattern[patoffset + 1])); - patoffset = (patoffset + 4) & 0x0E; - WRITE_GP32(MGP_PAT_COLOR_5, BYTE_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_4, BYTE_SWIZZLE(pattern[patoffset + 1])); - WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; - - /* ADJUST FOR NEXT PASS */ - - dstoffset += gu2_dst_pitch; - patoffset = (patoffset + 6) & 0x0E; - } - break; - - case 1: /* 12, 15, OR 16 BPP */ - - /* FOUR PASSES FOR 16 BPP */ - /* Render every 4th line per pass by quadrupling the pitch. */ - - patoffset = (gu2_pattern_origin >> 27) & 0x1C; - for (pass = 0; pass < 4; pass++) { - /* CAN WRITE SOME PATTERN REGISTERS WHILE "PENDING" */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); - lines = (height + 3 - pass) >> 2; - if (!lines) - break; - size = (((unsigned long)width) << 16) | lines; - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch << 2); - WRITE_GP32(MGP_PAT_COLOR_1, WORD_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_0, WORD_SWIZZLE(pattern[patoffset + 1])); - WRITE_GP32(MGP_PAT_DATA_1, WORD_SWIZZLE(pattern[patoffset + 2])); - WRITE_GP32(MGP_PAT_DATA_0, WORD_SWIZZLE(pattern[patoffset + 3])); - patoffset = (patoffset + 16) & 0x1C; - - /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ - /* Those registers are not pipelined. */ - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_5, WORD_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_4, WORD_SWIZZLE(pattern[patoffset + 1])); - WRITE_GP32(MGP_PAT_COLOR_3, WORD_SWIZZLE(pattern[patoffset + 2])); - WRITE_GP32(MGP_PAT_COLOR_2, WORD_SWIZZLE(pattern[patoffset + 3])); - WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; - - /* ADJUST FOR NEXT PASS */ - - dstoffset += gu2_dst_pitch; - patoffset = (patoffset + 20) & 0x1C; - } - break; - - case 2: /* 32 BPP */ - - /* EIGHT PASSES FOR 32 BPP */ - /* Render every 8th line per pass by setting pitch * 8. */ - - patoffset = (gu2_pattern_origin >> 26) & 0x38; - for (pass = 0; pass < 8; pass++) { - /* CAN WRITE SOME PATTERN REGISTERS WHILE "PENDING" */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); - lines = (height + 7 - pass) >> 3; - if (!lines) - break; - size = (((unsigned long)width) << 16) | lines; - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch << 3); - WRITE_GP32(MGP_PAT_COLOR_1, pattern[patoffset + 4]); - WRITE_GP32(MGP_PAT_COLOR_0, pattern[patoffset + 5]); - WRITE_GP32(MGP_PAT_DATA_1, pattern[patoffset + 6]); - WRITE_GP32(MGP_PAT_DATA_0, pattern[patoffset + 7]); - - /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ - /* Those registers are not pipelined. */ - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_5, pattern[patoffset]); - WRITE_GP32(MGP_PAT_COLOR_4, pattern[patoffset + 1]); - WRITE_GP32(MGP_PAT_COLOR_3, pattern[patoffset + 2]); - WRITE_GP32(MGP_PAT_COLOR_2, pattern[patoffset + 3]); - WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; - - /* ADJUST FOR NEXT PASS */ - - dstoffset += gu2_dst_pitch; - patoffset = (patoffset + 8) & 0x38; - } - break; - } - } - - else { - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); - - switch (gu2_xshift) { - case 0: /* 8 BPP - 4 LINES PER PASS */ - - patoffset = (gu2_pattern_origin >> 28) & 0x0E; - while (height) { - lines = height > 4 ? 4 : height; - - /* CAN WRITE SOME REGISTERS WHILE PENDING */ - - WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); - WRITE_GP32(MGP_WID_HEIGHT, - (((unsigned long)width) << 16) | lines); - WRITE_GP32(MGP_PAT_DATA_1, BYTE_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_DATA_0, BYTE_SWIZZLE(pattern[patoffset + 1])); - patoffset = (patoffset + 2) & 0x0E; - WRITE_GP32(MGP_PAT_COLOR_1, BYTE_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_0, BYTE_SWIZZLE(pattern[patoffset + 1])); - patoffset = (patoffset + 2) & 0x0E; - - /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ - /* Those registers are not pipelined. */ - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_3, BYTE_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_2, BYTE_SWIZZLE(pattern[patoffset + 1])); - patoffset = (patoffset + 2) & 0x0E; - WRITE_GP32(MGP_PAT_COLOR_5, BYTE_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_4, BYTE_SWIZZLE(pattern[patoffset + 1])); - patoffset = (patoffset + 2) & 0x0E; - WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); - - /* ADJUST FOR NEXT PASS */ - - dstoffset += gu2_dst_pitch << 2; - height -= (unsigned short)lines; - } - break; - - case 1: /* 12, 15 AND 16 BPP - 2 LINES PER PASS */ - - patoffset = (gu2_pattern_origin >> 27) & 0x1C; - while (height) { - lines = height > 2 ? 2 : height; - - /* CAN WRITE SOME REGISTERS WHILE PENDING */ - - WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); - WRITE_GP32(MGP_WID_HEIGHT, - (((unsigned long)width) << 16) | lines); - WRITE_GP32(MGP_PAT_COLOR_1, WORD_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_0, WORD_SWIZZLE(pattern[patoffset + 1])); - WRITE_GP32(MGP_PAT_DATA_1, WORD_SWIZZLE(pattern[patoffset + 2])); - WRITE_GP32(MGP_PAT_DATA_0, WORD_SWIZZLE(pattern[patoffset + 3])); - patoffset = (patoffset + 4) & 0x1C; - - /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ - /* Those registers are not pipelined. */ - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_5, WORD_SWIZZLE(pattern[patoffset])); - WRITE_GP32(MGP_PAT_COLOR_4, WORD_SWIZZLE(pattern[patoffset + 1])); - WRITE_GP32(MGP_PAT_COLOR_3, WORD_SWIZZLE(pattern[patoffset + 2])); - WRITE_GP32(MGP_PAT_COLOR_2, WORD_SWIZZLE(pattern[patoffset + 3])); - patoffset = (patoffset + 4) & 0x1C; - WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); - - /* ADJUST FOR NEXT PASS */ - - dstoffset += gu2_dst_pitch << 1; - height -= (unsigned short)lines; - } - break; - - case 2: /* 32 BPP - 1 LINE PER PASS */ - - patoffset = (gu2_pattern_origin >> 26) & 0x38; - while (height) { - /* CAN WRITE SOME REGISTERS WHILE PENDING */ - - WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); - WRITE_GP32(MGP_WID_HEIGHT, (((unsigned long)width) << 16) | 1l); - WRITE_GP32(MGP_PAT_COLOR_1, pattern[patoffset + 4]); - WRITE_GP32(MGP_PAT_COLOR_0, pattern[patoffset + 5]); - WRITE_GP32(MGP_PAT_DATA_1, pattern[patoffset + 6]); - WRITE_GP32(MGP_PAT_DATA_0, pattern[patoffset + 7]); - - /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ - /* Those registers are not pipelined. */ - - GU2_WAIT_BUSY; - WRITE_GP32(MGP_PAT_COLOR_5, pattern[patoffset]); - WRITE_GP32(MGP_PAT_COLOR_4, pattern[patoffset + 1]); - WRITE_GP32(MGP_PAT_COLOR_3, pattern[patoffset + 2]); - WRITE_GP32(MGP_PAT_COLOR_2, pattern[patoffset + 3]); - patoffset = (patoffset + 8) & 0x38; - WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); - - /* ADJUST FOR NEXT PASS */ - - dstoffset += gu2_dst_pitch; - height--; - } - break; - } - - } + int pass; + unsigned long lines, size, patxorigin, patoffset; + + /* ONLY USE HW PATTERN ORIGIN FOR THE X DIRECTION */ + /* Y direction handled by referencing proper location in pattern data. */ + + patxorigin = (gu2_pattern_origin) & 0x1C000000; + + /* OVERRIDE PATTERN FLAGS IN ROP TO FORCE COLOR PATTERN */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, + (gu2_rop32 & ~MGP_RM_PAT_FLAGS) | MGP_RM_PAT_COLOR); + + /* ATTEMPT TO OPTIMIZE */ + /* If possible, we can perform the pattern fill in only a few passes */ + /* This is performed by multiplying the pitch by an appropriate amount. */ + /* Consequently, if the multiplied pitch exceeds 16 bits, this */ + /* optimization is impossible. */ + + if ((gu2_dst_pitch << (gu2_xshift + 1)) <= 0xFFFF) { + /* HANDLE VARIOUS COLOR DEPTHS DIFFERENTLY */ + + switch (gu2_xshift) { + case 0: /* 8 BPP */ + + /* TWO PASSES FOR 8 BPP */ + /* Render every other line per pass by doubling the pitch. */ + + patoffset = (gu2_pattern_origin >> 28) & 0x0E; + for (pass = 0; pass < 2; pass++) { + /* CAN WRITE SOME PATTERN REGISTERS WHILE "PENDING" */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); + lines = (height + 1 - pass) >> 1; + if (!lines) + break; + size = (((unsigned long) width) << 16) | lines; + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch << 1); + WRITE_GP32(MGP_PAT_DATA_1, BYTE_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_DATA_0, + BYTE_SWIZZLE(pattern[patoffset + 1])); + patoffset = (patoffset + 4) & 0x0E; + WRITE_GP32(MGP_PAT_COLOR_1, BYTE_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_0, + BYTE_SWIZZLE(pattern[patoffset + 1])); + patoffset = (patoffset + 4) & 0x0E; + + /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ + /* Those registers are not pipelined. */ + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_3, BYTE_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_2, + BYTE_SWIZZLE(pattern[patoffset + 1])); + patoffset = (patoffset + 4) & 0x0E; + WRITE_GP32(MGP_PAT_COLOR_5, BYTE_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_4, + BYTE_SWIZZLE(pattern[patoffset + 1])); + WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; + + /* ADJUST FOR NEXT PASS */ + + dstoffset += gu2_dst_pitch; + patoffset = (patoffset + 6) & 0x0E; + } + break; + + case 1: /* 12, 15, OR 16 BPP */ + + /* FOUR PASSES FOR 16 BPP */ + /* Render every 4th line per pass by quadrupling the pitch. */ + + patoffset = (gu2_pattern_origin >> 27) & 0x1C; + for (pass = 0; pass < 4; pass++) { + /* CAN WRITE SOME PATTERN REGISTERS WHILE "PENDING" */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); + lines = (height + 3 - pass) >> 2; + if (!lines) + break; + size = (((unsigned long) width) << 16) | lines; + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch << 2); + WRITE_GP32(MGP_PAT_COLOR_1, WORD_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_0, + WORD_SWIZZLE(pattern[patoffset + 1])); + WRITE_GP32(MGP_PAT_DATA_1, + WORD_SWIZZLE(pattern[patoffset + 2])); + WRITE_GP32(MGP_PAT_DATA_0, + WORD_SWIZZLE(pattern[patoffset + 3])); + patoffset = (patoffset + 16) & 0x1C; + + /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ + /* Those registers are not pipelined. */ + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_5, WORD_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_4, + WORD_SWIZZLE(pattern[patoffset + 1])); + WRITE_GP32(MGP_PAT_COLOR_3, + WORD_SWIZZLE(pattern[patoffset + 2])); + WRITE_GP32(MGP_PAT_COLOR_2, + WORD_SWIZZLE(pattern[patoffset + 3])); + WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; + + /* ADJUST FOR NEXT PASS */ + + dstoffset += gu2_dst_pitch; + patoffset = (patoffset + 20) & 0x1C; + } + break; + + case 2: /* 32 BPP */ + + /* EIGHT PASSES FOR 32 BPP */ + /* Render every 8th line per pass by setting pitch * 8. */ + + patoffset = (gu2_pattern_origin >> 26) & 0x38; + for (pass = 0; pass < 8; pass++) { + /* CAN WRITE SOME PATTERN REGISTERS WHILE "PENDING" */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); + lines = (height + 7 - pass) >> 3; + if (!lines) + break; + size = (((unsigned long) width) << 16) | lines; + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch << 3); + WRITE_GP32(MGP_PAT_COLOR_1, pattern[patoffset + 4]); + WRITE_GP32(MGP_PAT_COLOR_0, pattern[patoffset + 5]); + WRITE_GP32(MGP_PAT_DATA_1, pattern[patoffset + 6]); + WRITE_GP32(MGP_PAT_DATA_0, pattern[patoffset + 7]); + + /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ + /* Those registers are not pipelined. */ + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_5, pattern[patoffset]); + WRITE_GP32(MGP_PAT_COLOR_4, pattern[patoffset + 1]); + WRITE_GP32(MGP_PAT_COLOR_3, pattern[patoffset + 2]); + WRITE_GP32(MGP_PAT_COLOR_2, pattern[patoffset + 3]); + WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; + + /* ADJUST FOR NEXT PASS */ + + dstoffset += gu2_dst_pitch; + patoffset = (patoffset + 8) & 0x38; + } + break; + } + } + + else { + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); + + switch (gu2_xshift) { + case 0: /* 8 BPP - 4 LINES PER PASS */ + + patoffset = (gu2_pattern_origin >> 28) & 0x0E; + while (height) { + lines = height > 4 ? 4 : height; + + /* CAN WRITE SOME REGISTERS WHILE PENDING */ + + WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); + WRITE_GP32(MGP_WID_HEIGHT, + (((unsigned long) width) << 16) | lines); + WRITE_GP32(MGP_PAT_DATA_1, BYTE_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_DATA_0, + BYTE_SWIZZLE(pattern[patoffset + 1])); + patoffset = (patoffset + 2) & 0x0E; + WRITE_GP32(MGP_PAT_COLOR_1, BYTE_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_0, + BYTE_SWIZZLE(pattern[patoffset + 1])); + patoffset = (patoffset + 2) & 0x0E; + + /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ + /* Those registers are not pipelined. */ + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_3, BYTE_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_2, + BYTE_SWIZZLE(pattern[patoffset + 1])); + patoffset = (patoffset + 2) & 0x0E; + WRITE_GP32(MGP_PAT_COLOR_5, BYTE_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_4, + BYTE_SWIZZLE(pattern[patoffset + 1])); + patoffset = (patoffset + 2) & 0x0E; + WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); + + /* ADJUST FOR NEXT PASS */ + + dstoffset += gu2_dst_pitch << 2; + height -= (unsigned short) lines; + } + break; + + case 1: /* 12, 15 AND 16 BPP - 2 LINES PER PASS */ + + patoffset = (gu2_pattern_origin >> 27) & 0x1C; + while (height) { + lines = height > 2 ? 2 : height; + + /* CAN WRITE SOME REGISTERS WHILE PENDING */ + + WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); + WRITE_GP32(MGP_WID_HEIGHT, + (((unsigned long) width) << 16) | lines); + WRITE_GP32(MGP_PAT_COLOR_1, WORD_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_0, + WORD_SWIZZLE(pattern[patoffset + 1])); + WRITE_GP32(MGP_PAT_DATA_1, + WORD_SWIZZLE(pattern[patoffset + 2])); + WRITE_GP32(MGP_PAT_DATA_0, + WORD_SWIZZLE(pattern[patoffset + 3])); + patoffset = (patoffset + 4) & 0x1C; + + /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ + /* Those registers are not pipelined. */ + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_5, WORD_SWIZZLE(pattern[patoffset])); + WRITE_GP32(MGP_PAT_COLOR_4, + WORD_SWIZZLE(pattern[patoffset + 1])); + WRITE_GP32(MGP_PAT_COLOR_3, + WORD_SWIZZLE(pattern[patoffset + 2])); + WRITE_GP32(MGP_PAT_COLOR_2, + WORD_SWIZZLE(pattern[patoffset + 3])); + patoffset = (patoffset + 4) & 0x1C; + WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); + + /* ADJUST FOR NEXT PASS */ + + dstoffset += gu2_dst_pitch << 1; + height -= (unsigned short) lines; + } + break; + + case 2: /* 32 BPP - 1 LINE PER PASS */ + + patoffset = (gu2_pattern_origin >> 26) & 0x38; + while (height) { + /* CAN WRITE SOME REGISTERS WHILE PENDING */ + + WRITE_GP32(MGP_DST_OFFSET, dstoffset | patxorigin); + WRITE_GP32(MGP_WID_HEIGHT, + (((unsigned long) width) << 16) | 1l); + WRITE_GP32(MGP_PAT_COLOR_1, pattern[patoffset + 4]); + WRITE_GP32(MGP_PAT_COLOR_0, pattern[patoffset + 5]); + WRITE_GP32(MGP_PAT_DATA_1, pattern[patoffset + 6]); + WRITE_GP32(MGP_PAT_DATA_0, pattern[patoffset + 7]); + + /* NEED TO WAIT UNTIL IDLE FOR COLORS 2 THROUGH 5 */ + /* Those registers are not pipelined. */ + + GU2_WAIT_BUSY; + WRITE_GP32(MGP_PAT_COLOR_5, pattern[patoffset]); + WRITE_GP32(MGP_PAT_COLOR_4, pattern[patoffset + 1]); + WRITE_GP32(MGP_PAT_COLOR_3, pattern[patoffset + 2]); + WRITE_GP32(MGP_PAT_COLOR_2, pattern[patoffset + 3]); + patoffset = (patoffset + 8) & 0x38; + WRITE_GP16(MGP_BLT_MODE, gu2_blt_mode | gu2_bm_throttle); + + /* ADJUST FOR NEXT PASS */ + + dstoffset += gu2_dst_pitch; + height--; + } + break; + } + + } } @@ -1887,69 +1912,70 @@ gfx2_color_pattern_fill(unsigned long dstoffset, unsigned short width, #if GFX_2DACCEL_DYNAMIC void gu22_screen_to_screen_blt(unsigned long srcoffset, unsigned long dstoffset, - unsigned short width, unsigned short height, - int flags) + unsigned short width, unsigned short height, + int flags) #else void gfx2_screen_to_screen_blt(unsigned long srcoffset, unsigned long dstoffset, - unsigned short width, unsigned short height, - int flags) + unsigned short width, unsigned short height, + int flags) #endif { - unsigned long size, xbytes; - unsigned short blt_mode; - - size = (((unsigned long)width) << 16) | height; - - /* USE ALPHA SETTINGS, IF REQUESTED */ - - if (gu2_alpha_active) - blt_mode = gu2_alpha_blt_mode | MGP_BM_SRC_FB; - - else - blt_mode = gu2_blt_mode | MGP_BM_SRC_FB; - - /* CALCULATE THE DIRECTION OF THE BLT */ - /* Using offsets, so flags from the calling routine are needed. */ - - if (flags & 1) { - xbytes = (width - 1) << gu2_xshift; - srcoffset += xbytes; - dstoffset += xbytes; - blt_mode |= MGP_BM_NEG_XDIR; - } - if (flags & 2) { - srcoffset += (height - 1) * gu2_src_pitch; - dstoffset += (height - 1) * gu2_dst_pitch; - blt_mode |= MGP_BM_NEG_YDIR; - } - - /* TURN INTO BYTE ADDRESS IF NEGATIVE X DIRECTION */ - /* This is a quirk of the hardware. */ - - if (blt_mode & MGP_BM_NEG_XDIR) { - srcoffset += (1 << gu2_xshift) - 1; - dstoffset += (1 << gu2_xshift) - 1; - } - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ - - GU2_WAIT_PENDING; - - if (gu2_alpha_active) { - WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); - } else { - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - } - - WRITE_GP32(MGP_SRC_OFFSET, srcoffset); - WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch | (gu2_src_pitch << 16)); - WRITE_GP16(MGP_BLT_MODE, blt_mode | gu2_bm_throttle); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; + unsigned long size, xbytes; + unsigned short blt_mode; + + size = (((unsigned long) width) << 16) | height; + + /* USE ALPHA SETTINGS, IF REQUESTED */ + + if (gu2_alpha_active) + blt_mode = gu2_alpha_blt_mode | MGP_BM_SRC_FB; + + else + blt_mode = gu2_blt_mode | MGP_BM_SRC_FB; + + /* CALCULATE THE DIRECTION OF THE BLT */ + /* Using offsets, so flags from the calling routine are needed. */ + + if (flags & 1) { + xbytes = (width - 1) << gu2_xshift; + srcoffset += xbytes; + dstoffset += xbytes; + blt_mode |= MGP_BM_NEG_XDIR; + } + if (flags & 2) { + srcoffset += (height - 1) * gu2_src_pitch; + dstoffset += (height - 1) * gu2_dst_pitch; + blt_mode |= MGP_BM_NEG_YDIR; + } + + /* TURN INTO BYTE ADDRESS IF NEGATIVE X DIRECTION */ + /* This is a quirk of the hardware. */ + + if (blt_mode & MGP_BM_NEG_XDIR) { + srcoffset += (1 << gu2_xshift) - 1; + dstoffset += (1 << gu2_xshift) - 1; + } + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ + + GU2_WAIT_PENDING; + + if (gu2_alpha_active) { + WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); + } + else { + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + } + + WRITE_GP32(MGP_SRC_OFFSET, srcoffset); + WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch | (gu2_src_pitch << 16)); + WRITE_GP16(MGP_BLT_MODE, blt_mode | gu2_bm_throttle); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; } /*--------------------------------------------------------------------------- @@ -1964,56 +1990,57 @@ gfx2_screen_to_screen_blt(unsigned long srcoffset, unsigned long dstoffset, #if GFX_2DACCEL_DYNAMIC void gu22_mono_expand_blt(unsigned long srcbase, unsigned short srcx, - unsigned short srcy, unsigned long dstoffset, - unsigned short width, unsigned short height, - int byte_packed) + unsigned short srcy, unsigned long dstoffset, + unsigned short width, unsigned short height, + int byte_packed) #else void gfx2_mono_expand_blt(unsigned long srcbase, unsigned short srcx, - unsigned short srcy, unsigned long dstoffset, - unsigned short width, unsigned short height, - int byte_packed) + unsigned short srcy, unsigned long dstoffset, + unsigned short width, unsigned short height, + int byte_packed) #endif { - unsigned long size, srcoffset; - unsigned short blt_mode; + unsigned long size, srcoffset; + unsigned short blt_mode; - size = (((unsigned long)width) << 16) | height; + size = (((unsigned long) width) << 16) | height; - /* CALCULATE SOURCE OFFSET */ + /* CALCULATE SOURCE OFFSET */ - srcoffset = srcbase + (unsigned long)srcy *gu2_src_pitch; + srcoffset = srcbase + (unsigned long) srcy *gu2_src_pitch; - srcoffset += srcx >> 3; - srcoffset |= ((unsigned long)srcx & 7) << 26; + srcoffset += srcx >> 3; + srcoffset |= ((unsigned long) srcx & 7) << 26; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ - GU2_WAIT_PENDING; + GU2_WAIT_PENDING; - if (gu2_alpha_active) { - blt_mode = gu2_alpha_blt_mode; + if (gu2_alpha_active) { + blt_mode = gu2_alpha_blt_mode; - WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); - } else { - blt_mode = gu2_blt_mode; + WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); + } + else { + blt_mode = gu2_blt_mode; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - } + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + } - if (byte_packed) - blt_mode |= MGP_BM_SRC_FB | MGP_BM_SRC_BP_MONO | gu2_bm_throttle; - else - blt_mode |= MGP_BM_SRC_FB | MGP_BM_SRC_MONO | gu2_bm_throttle; + if (byte_packed) + blt_mode |= MGP_BM_SRC_FB | MGP_BM_SRC_BP_MONO | gu2_bm_throttle; + else + blt_mode |= MGP_BM_SRC_FB | MGP_BM_SRC_MONO | gu2_bm_throttle; - WRITE_GP32(MGP_SRC_OFFSET, srcoffset); - WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch | (gu2_src_pitch << 16)); - WRITE_GP16(MGP_BLT_MODE, blt_mode); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; + WRITE_GP32(MGP_SRC_OFFSET, srcoffset); + WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch | (gu2_src_pitch << 16)); + WRITE_GP16(MGP_BLT_MODE, blt_mode); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; } /*--------------------------------------------------------------------------- @@ -2027,86 +2054,87 @@ gfx2_mono_expand_blt(unsigned long srcbase, unsigned short srcx, #if GFX_2DACCEL_DYNAMIC void gu22_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data, - short pitch) + unsigned long dstoffset, unsigned short width, + unsigned short height, unsigned char *data, + short pitch) #else void gfx2_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data, - short pitch) + unsigned long dstoffset, unsigned short width, + unsigned short height, unsigned char *data, + short pitch) #endif { - unsigned long size, bytes; - unsigned long offset, temp_offset; - unsigned long srcoffset, dword_bytes, bytes_extra; - unsigned short blt_mode; - - size = (((unsigned long)width) << 16) | 1; - - /* CALCULATE STARTING OFFSETS */ - - offset = (unsigned long)srcy *pitch + ((unsigned long)srcx << gu2_xshift); - - dstoffset |= gu2_pattern_origin; - - bytes = width << gu2_xshift; - dword_bytes = bytes & ~0x3L; - bytes_extra = bytes & 0x3L; - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ - /* The source offset is always 0 since we allow misaligned dword reads. */ - /* We must wait for BLT busy because the GP may be executing a screen */ - /* to screen BLT from the scratchpad area. */ - - GU2_WAIT_BUSY; - - if (gu2_alpha_active) { - blt_mode = gu2_alpha_blt_mode; - - WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); - } else { - blt_mode = gu2_blt_mode; - - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - } - blt_mode |= MGP_BM_SRC_FB | gu2_bm_throttle; - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; - - WRITE_GP32(MGP_WID_HEIGHT, size); - - /* WRITE DATA ONE LINE AT A TIME */ - /* For speed reasons, data is written to an offscreen scratch area and then */ - /* BLTed using a screen to screen BLT. This is similar to the GX1 BLT buffers, but */ - /* slightly more efficient in that we can queue up data while the GP is rendering */ - /* a line. */ - - while (height--) { - temp_offset = offset; - srcoffset = gfx_gx2_scratch_base; - if (gu2_current_line) - srcoffset += 8192; - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_OFFSET, srcoffset); - WRITE_GP32(MGP_DST_OFFSET, dstoffset); - dstoffset += gu2_dst_pitch; - dstoffset += 0x20000000; - - WRITE_FRAME_BUFFER_STRING32(srcoffset, dword_bytes, data, temp_offset); - if (bytes_extra) { - temp_offset += dword_bytes; - srcoffset += dword_bytes; - WRITE_FRAME_BUFFER_STRING8(srcoffset, bytes_extra, data, - temp_offset); - } - WRITE_GP16(MGP_BLT_MODE, blt_mode); - offset += pitch; - gu2_current_line = 1 - gu2_current_line; - } + unsigned long size, bytes; + unsigned long offset, temp_offset; + unsigned long srcoffset, dword_bytes, bytes_extra; + unsigned short blt_mode; + + size = (((unsigned long) width) << 16) | 1; + + /* CALCULATE STARTING OFFSETS */ + + offset = (unsigned long) srcy *pitch + ((unsigned long) srcx << gu2_xshift); + + dstoffset |= gu2_pattern_origin; + + bytes = width << gu2_xshift; + dword_bytes = bytes & ~0x3L; + bytes_extra = bytes & 0x3L; + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ + /* The source offset is always 0 since we allow misaligned dword reads. */ + /* We must wait for BLT busy because the GP may be executing a screen */ + /* to screen BLT from the scratchpad area. */ + + GU2_WAIT_BUSY; + + if (gu2_alpha_active) { + blt_mode = gu2_alpha_blt_mode; + + WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); + } + else { + blt_mode = gu2_blt_mode; + + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + } + blt_mode |= MGP_BM_SRC_FB | gu2_bm_throttle; + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; + + WRITE_GP32(MGP_WID_HEIGHT, size); + + /* WRITE DATA ONE LINE AT A TIME */ + /* For speed reasons, data is written to an offscreen scratch area and then */ + /* BLTed using a screen to screen BLT. This is similar to the GX1 BLT buffers, but */ + /* slightly more efficient in that we can queue up data while the GP is rendering */ + /* a line. */ + + while (height--) { + temp_offset = offset; + srcoffset = gfx_gx2_scratch_base; + if (gu2_current_line) + srcoffset += 8192; + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_OFFSET, srcoffset); + WRITE_GP32(MGP_DST_OFFSET, dstoffset); + dstoffset += gu2_dst_pitch; + dstoffset += 0x20000000; + + WRITE_FRAME_BUFFER_STRING32(srcoffset, dword_bytes, data, temp_offset); + if (bytes_extra) { + temp_offset += dword_bytes; + srcoffset += dword_bytes; + WRITE_FRAME_BUFFER_STRING8(srcoffset, bytes_extra, data, + temp_offset); + } + WRITE_GP16(MGP_BLT_MODE, blt_mode); + offset += pitch; + gu2_current_line = 1 - gu2_current_line; + } } /*--------------------------------------------------------------------------- @@ -2119,78 +2147,79 @@ gfx2_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu22_text_blt(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data) + unsigned short height, unsigned char *data) #else void gfx2_text_blt(unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data) + unsigned short height, unsigned char *data) #endif { - unsigned long size, bytes; - unsigned long temp1 = 0, temp2 = 0, temp_offset = 0; - unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; - unsigned long shift; - unsigned short blt_mode; - - size = (((unsigned long)width) << 16) | height; - - /* CALCULATE STARTING OFFSETS */ - - bytes = ((width + 7) >> 3) * height; - fifo_lines = bytes >> 5; - dwords_extra = (bytes & 0x0000001Cl) >> 2; - bytes_extra = bytes & 0x00000003l; - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - - GU2_WAIT_PENDING; - - if (gu2_alpha_active) { - blt_mode = gu2_alpha_blt_mode; - - WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); - } else { - blt_mode = gu2_blt_mode; - - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - } - - WRITE_GP32(MGP_SRC_OFFSET, 0); - WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); - WRITE_GP16(MGP_BLT_MODE, blt_mode | MGP_BM_SRC_HOST | - MGP_BM_SRC_BP_MONO | gu2_bm_throttle); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; - - /* WAIT FOR BLT TO BE LATCHED */ - - GU2_WAIT_PENDING; - - /* WRITE ALL FULL FIFO LINES */ - - for (i = 0; i < fifo_lines; i++) { - GU2_WAIT_HALF_EMPTY; - WRITE_GPREG_STRING32(MGP_HST_SOURCE, 8, j, data, temp_offset, temp1); - temp_offset += 32; - } - - /* WRITE ALL FULL DWORDS */ - - if (dwords_extra || bytes_extra) { - GU2_WAIT_HALF_EMPTY; - if (dwords_extra) { - WRITE_GPREG_STRING32(MGP_HST_SOURCE, dwords_extra, i, data, - temp_offset, temp1); - temp_offset += (dwords_extra << 2); - } - if (bytes_extra) { - shift = 0; - WRITE_GPREG_STRING8(MGP_HST_SOURCE, bytes_extra, shift, i, data, - temp_offset, temp1, temp2); - } - } + unsigned long size, bytes; + unsigned long temp1 = 0, temp2 = 0, temp_offset = 0; + unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; + unsigned long shift; + unsigned short blt_mode; + + size = (((unsigned long) width) << 16) | height; + + /* CALCULATE STARTING OFFSETS */ + + bytes = ((width + 7) >> 3) * height; + fifo_lines = bytes >> 5; + dwords_extra = (bytes & 0x0000001Cl) >> 2; + bytes_extra = bytes & 0x00000003l; + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + + GU2_WAIT_PENDING; + + if (gu2_alpha_active) { + blt_mode = gu2_alpha_blt_mode; + + WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); + } + else { + blt_mode = gu2_blt_mode; + + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + } + + WRITE_GP32(MGP_SRC_OFFSET, 0); + WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); + WRITE_GP16(MGP_BLT_MODE, blt_mode | MGP_BM_SRC_HOST | + MGP_BM_SRC_BP_MONO | gu2_bm_throttle); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; + + /* WAIT FOR BLT TO BE LATCHED */ + + GU2_WAIT_PENDING; + + /* WRITE ALL FULL FIFO LINES */ + + for (i = 0; i < fifo_lines; i++) { + GU2_WAIT_HALF_EMPTY; + WRITE_GPREG_STRING32(MGP_HST_SOURCE, 8, j, data, temp_offset, temp1); + temp_offset += 32; + } + + /* WRITE ALL FULL DWORDS */ + + if (dwords_extra || bytes_extra) { + GU2_WAIT_HALF_EMPTY; + if (dwords_extra) { + WRITE_GPREG_STRING32(MGP_HST_SOURCE, dwords_extra, i, data, + temp_offset, temp1); + temp_offset += (dwords_extra << 2); + } + if (bytes_extra) { + shift = 0; + WRITE_GPREG_STRING8(MGP_HST_SOURCE, bytes_extra, shift, i, data, + temp_offset, temp1, temp2); + } + } } /*--------------------------------------------------------------------------- @@ -2203,91 +2232,93 @@ gfx2_text_blt(unsigned long dstoffset, unsigned short width, #if GFX_2DACCEL_DYNAMIC void gu22_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data, - short pitch) + unsigned long dstoffset, unsigned short width, + unsigned short height, unsigned char *data, + short pitch) #else void gfx2_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned long dstoffset, unsigned short width, - unsigned short height, unsigned char *data, - short pitch) + unsigned long dstoffset, unsigned short width, + unsigned short height, unsigned char *data, + short pitch) #endif { - unsigned long size, bytes; - unsigned long offset, temp_offset, temp1 = 0, temp2 = 0; - unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; - unsigned long shift = 0; - unsigned short blt_mode; + unsigned long size, bytes; + unsigned long offset, temp_offset, temp1 = 0, temp2 = 0; + unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; + unsigned long shift = 0; + unsigned short blt_mode; - size = (((unsigned long)width) << 16) | height; + size = (((unsigned long) width) << 16) | height; - /* CALCULATE STARTING OFFSETS */ + /* CALCULATE STARTING OFFSETS */ - offset = (unsigned long)srcy *pitch + ((unsigned long)srcx >> 3); + offset = (unsigned long) srcy *pitch + ((unsigned long) srcx >> 3); - bytes = ((srcx & 7) + width + 7) >> 3; - fifo_lines = bytes >> 5; - dwords_extra = (bytes & 0x0000001Cl) >> 2; - bytes_extra = bytes & 0x00000003l; + bytes = ((srcx & 7) + width + 7) >> 3; + fifo_lines = bytes >> 5; + dwords_extra = (bytes & 0x0000001Cl) >> 2; + bytes_extra = bytes & 0x00000003l; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - GU2_WAIT_PENDING; + GU2_WAIT_PENDING; - if (gu2_alpha_active) { - blt_mode = gu2_alpha_blt_mode; + if (gu2_alpha_active) { + blt_mode = gu2_alpha_blt_mode; - WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); - } else { - blt_mode = gu2_blt_mode; + WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); + } + else { + blt_mode = gu2_blt_mode; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - } + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + } - WRITE_GP32(MGP_SRC_OFFSET, ((unsigned long)srcx & 7) << 26); - WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); - WRITE_GP16(MGP_BLT_MODE, blt_mode | MGP_BM_SRC_HOST | - MGP_BM_SRC_MONO | gu2_bm_throttle); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; + WRITE_GP32(MGP_SRC_OFFSET, ((unsigned long) srcx & 7) << 26); + WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); + WRITE_GP16(MGP_BLT_MODE, blt_mode | MGP_BM_SRC_HOST | + MGP_BM_SRC_MONO | gu2_bm_throttle); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; - /* WAIT FOR BLT TO BE LATCHED */ + /* WAIT FOR BLT TO BE LATCHED */ - GU2_WAIT_PENDING; + GU2_WAIT_PENDING; - /* WRITE ALL OF THE DATA TO THE HOST SOURCE REGISTER */ + /* WRITE ALL OF THE DATA TO THE HOST SOURCE REGISTER */ - while (height--) { - temp_offset = offset; + while (height--) { + 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(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(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(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(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; + } } /*--------------------------------------------------------------------------- @@ -2300,45 +2331,46 @@ gfx2_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, #if GFX_2DACCEL_DYNAMIC void gu22_bresenham_line(unsigned long dstoffset, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) #else void gfx2_bresenham_line(unsigned long dstoffset, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) #endif { - unsigned long vector_mode = gu2_vector_mode | flags; - unsigned long data1 = (((unsigned long)axialerr) << 16) | diagerr; - unsigned long data2 = (((unsigned long)length) << 16) | initerr; + unsigned long vector_mode = gu2_vector_mode | flags; + unsigned long data1 = (((unsigned long) axialerr) << 16) | diagerr; + unsigned long data2 = (((unsigned long) length) << 16) | initerr; - /* CHECK NULL LENGTH */ + /* CHECK NULL LENGTH */ - if (!length) - return; + if (!length) + return; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ - GU2_WAIT_PENDING; + GU2_WAIT_PENDING; - if (gu2_alpha_active) { - vector_mode = gu2_alpha_vec_mode | flags; + if (gu2_alpha_active) { + vector_mode = gu2_alpha_vec_mode | flags; - WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); - } else - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_RASTER_MODE, gu2_alpha32); + } + else + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); - WRITE_GP32(MGP_VEC_ERR, data1); - WRITE_GP32(MGP_VEC_LEN, data2); - WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); - WRITE_GP32(MGP_VECTOR_MODE, vector_mode | gu2_vm_throttle); - gu2_bm_throttle = 0; - gu2_vm_throttle = 0; + WRITE_GP32(MGP_DST_OFFSET, dstoffset | gu2_pattern_origin); + WRITE_GP32(MGP_VEC_ERR, data1); + WRITE_GP32(MGP_VEC_LEN, data2); + WRITE_GP32(MGP_STRIDE, gu2_dst_pitch); + WRITE_GP32(MGP_VECTOR_MODE, vector_mode | gu2_vm_throttle); + gu2_bm_throttle = 0; + gu2_vm_throttle = 0; } /*--------------------------------------------------------------------------- @@ -2356,10 +2388,10 @@ void gfx2_sync_to_vblank(void) #endif { - /* SET FLAGS TO THROTTLE NEXT RENDERING ROUTINE */ + /* SET FLAGS TO THROTTLE NEXT RENDERING ROUTINE */ - gu2_bm_throttle = MGP_BM_THROTTLE; - gu2_vm_throttle = MGP_VM_THROTTLE; + gu2_bm_throttle = MGP_BM_THROTTLE; + gu2_vm_throttle = MGP_VM_THROTTLE; } /* END OF FILE */ diff --git a/src/gfx/saa7114.c b/src/gfx/saa7114.c index 885e65f..c894647 100644 --- a/src/gfx/saa7114.c +++ b/src/gfx/saa7114.c @@ -132,62 +132,60 @@ /* TABLE OF DEFAULT VALUES */ /*---------------------------*/ -typedef struct tagGFX_SAA7114_INIT -{ - unsigned char index; - unsigned char value; -} -GFX_SAA7114_INIT; +typedef struct tagGFX_SAA7114_INIT { + unsigned char index; + unsigned char value; +} GFX_SAA7114_INIT; /* Task A is for VBI raw data and task B is for video */ GFX_SAA7114_INIT gfx_saa7114_init_values[] = { - {0x01, 0x08}, {0x02, 0xC0}, {0x03, 0x00}, {0x04, 0x90}, - {0x05, 0x90}, {0x06, 0xEB}, {0x07, 0xE0}, {0x08, 0x88}, - {0x09, 0x40}, {0x0A, 0x80}, {0x0B, 0x44}, {0x0C, 0x40}, - {0x0D, 0x00}, {0x0E, 0x89}, {0x0F, 0x2E}, {0x10, 0x0E}, - {0x11, 0x00}, {0x12, 0x05}, {0x13, 0x00}, {0x14, 0x08}, - {0x15, 0x11}, {0x16, 0xFE}, {0x17, 0x00}, {0x18, 0x40}, - {0x19, 0x80}, {0x30, 0xBC}, {0x31, 0xDF}, {0x32, 0x02}, - {0x34, 0xCD}, {0x35, 0xCC}, {0x36, 0x3A}, {0x38, 0x03}, - {0x39, 0x10}, {0x3A, 0x00}, {0x40, 0x00}, {0x41, 0xFF}, - {0x42, 0xFF}, {0x43, 0xFF}, {0x44, 0xFF}, {0x45, 0xFF}, - {0x46, 0xFF}, {0x47, 0xFF}, {0x48, 0xFF}, {0x49, 0xFF}, - {0x4A, 0xFF}, {0x4B, 0xFF}, {0x4C, 0xFF}, {0x4D, 0xFF}, - {0x4E, 0xFF}, {0x4F, 0xFF}, {0x50, 0xFF}, {0x51, 0xFF}, - {0x52, 0xFF}, {0x53, 0xFF}, {0x54, 0xFF}, {0x55, 0xFF}, - {0x56, 0xFF}, {0x57, 0xFF}, {0x58, 0x00}, {0x59, 0x47}, - {0x5A, 0x06}, {0x5B, 0x43}, {0x5D, 0x3E}, {0x5E, 0x00}, - {0x80, 0x30}, {0x83, 0x00}, {0x84, 0x60}, {0x85, 0x00}, - {0x86, 0xE5}, {0x87, 0x01}, {0x88, 0xF8}, - - /* VBI task */ - - {0x90, 0x01}, {0x91, 0xC8}, {0x92, 0x08}, {0x93, 0x84}, - {0x94, 0x10}, {0x95, 0x00}, {0x96, 0xD0}, {0x97, 0x02}, - {0x98, 0x05}, {0x99, 0x00}, {0x9A, 0x0B}, {0x9B, 0x00}, - {0x9C, 0xA0}, {0x9D, 0x05}, {0x9E, 0x0B}, {0x9F, 0x00}, - {0xA0, 0x01}, {0xA1, 0x00}, {0xA2, 0x00}, {0xA4, 0x80}, - {0xA5, 0x40}, {0xA6, 0x40}, {0xA8, 0x00}, {0xA9, 0x02}, - {0xAA, 0x00}, {0xAC, 0x00}, {0xAD, 0x01}, {0xAE, 0x00}, - {0xB0, 0x00}, {0xB1, 0x04}, {0xB2, 0x00}, {0xB3, 0x04}, - {0xB4, 0x00}, {0xB8, 0x00}, {0xB9, 0x00}, {0xBA, 0x00}, - {0xBB, 0x00}, {0xBC, 0x00}, {0xBD, 0x00}, {0xBE, 0x00}, - {0xBF, 0x00}, - - /* Video task */ - - {0xC0, 0x80}, {0xC1, 0x08}, {0xC2, 0x00}, {0xC3, 0x80}, - {0xC4, 0x10}, {0xC5, 0x00}, {0xC6, 0xD0}, {0xC7, 0x02}, - {0xC8, 0x11}, {0xC9, 0x00}, {0xCA, 0xF1}, {0xCB, 0x00}, - {0xCC, 0xD0}, {0xCD, 0x02}, {0xCE, 0xF1}, {0xCF, 0x00}, - {0xD0, 0x01}, {0xD1, 0x00}, {0xD2, 0x00}, {0xD4, 0x80}, - {0xD5, 0x40}, {0xD6, 0x40}, {0xD8, 0x00}, {0xD9, 0x04}, - {0xDA, 0x00}, {0xDC, 0x00}, {0xDD, 0x02}, {0xDE, 0x00}, - {0xE0, 0x00}, {0xE1, 0x04}, {0xE2, 0x00}, {0xE3, 0x04}, - {0xE4, 0x00}, {0xE8, 0x00}, {0xE9, 0x00}, {0xEA, 0x00}, - {0xEB, 0x00}, {0xEC, 0x00}, {0xED, 0x00}, {0xEE, 0x00}, - {0xEF, 0x00}, + {0x01, 0x08}, {0x02, 0xC0}, {0x03, 0x00}, {0x04, 0x90}, + {0x05, 0x90}, {0x06, 0xEB}, {0x07, 0xE0}, {0x08, 0x88}, + {0x09, 0x40}, {0x0A, 0x80}, {0x0B, 0x44}, {0x0C, 0x40}, + {0x0D, 0x00}, {0x0E, 0x89}, {0x0F, 0x2E}, {0x10, 0x0E}, + {0x11, 0x00}, {0x12, 0x05}, {0x13, 0x00}, {0x14, 0x08}, + {0x15, 0x11}, {0x16, 0xFE}, {0x17, 0x00}, {0x18, 0x40}, + {0x19, 0x80}, {0x30, 0xBC}, {0x31, 0xDF}, {0x32, 0x02}, + {0x34, 0xCD}, {0x35, 0xCC}, {0x36, 0x3A}, {0x38, 0x03}, + {0x39, 0x10}, {0x3A, 0x00}, {0x40, 0x00}, {0x41, 0xFF}, + {0x42, 0xFF}, {0x43, 0xFF}, {0x44, 0xFF}, {0x45, 0xFF}, + {0x46, 0xFF}, {0x47, 0xFF}, {0x48, 0xFF}, {0x49, 0xFF}, + {0x4A, 0xFF}, {0x4B, 0xFF}, {0x4C, 0xFF}, {0x4D, 0xFF}, + {0x4E, 0xFF}, {0x4F, 0xFF}, {0x50, 0xFF}, {0x51, 0xFF}, + {0x52, 0xFF}, {0x53, 0xFF}, {0x54, 0xFF}, {0x55, 0xFF}, + {0x56, 0xFF}, {0x57, 0xFF}, {0x58, 0x00}, {0x59, 0x47}, + {0x5A, 0x06}, {0x5B, 0x43}, {0x5D, 0x3E}, {0x5E, 0x00}, + {0x80, 0x30}, {0x83, 0x00}, {0x84, 0x60}, {0x85, 0x00}, + {0x86, 0xE5}, {0x87, 0x01}, {0x88, 0xF8}, + + /* VBI task */ + + {0x90, 0x01}, {0x91, 0xC8}, {0x92, 0x08}, {0x93, 0x84}, + {0x94, 0x10}, {0x95, 0x00}, {0x96, 0xD0}, {0x97, 0x02}, + {0x98, 0x05}, {0x99, 0x00}, {0x9A, 0x0B}, {0x9B, 0x00}, + {0x9C, 0xA0}, {0x9D, 0x05}, {0x9E, 0x0B}, {0x9F, 0x00}, + {0xA0, 0x01}, {0xA1, 0x00}, {0xA2, 0x00}, {0xA4, 0x80}, + {0xA5, 0x40}, {0xA6, 0x40}, {0xA8, 0x00}, {0xA9, 0x02}, + {0xAA, 0x00}, {0xAC, 0x00}, {0xAD, 0x01}, {0xAE, 0x00}, + {0xB0, 0x00}, {0xB1, 0x04}, {0xB2, 0x00}, {0xB3, 0x04}, + {0xB4, 0x00}, {0xB8, 0x00}, {0xB9, 0x00}, {0xBA, 0x00}, + {0xBB, 0x00}, {0xBC, 0x00}, {0xBD, 0x00}, {0xBE, 0x00}, + {0xBF, 0x00}, + + /* Video task */ + + {0xC0, 0x80}, {0xC1, 0x08}, {0xC2, 0x00}, {0xC3, 0x80}, + {0xC4, 0x10}, {0xC5, 0x00}, {0xC6, 0xD0}, {0xC7, 0x02}, + {0xC8, 0x11}, {0xC9, 0x00}, {0xCA, 0xF1}, {0xCB, 0x00}, + {0xCC, 0xD0}, {0xCD, 0x02}, {0xCE, 0xF1}, {0xCF, 0x00}, + {0xD0, 0x01}, {0xD1, 0x00}, {0xD2, 0x00}, {0xD4, 0x80}, + {0xD5, 0x40}, {0xD6, 0x40}, {0xD8, 0x00}, {0xD9, 0x04}, + {0xDA, 0x00}, {0xDC, 0x00}, {0xDD, 0x02}, {0xDE, 0x00}, + {0xE0, 0x00}, {0xE1, 0x04}, {0xE2, 0x00}, {0xE3, 0x04}, + {0xE4, 0x00}, {0xE8, 0x00}, {0xE9, 0x00}, {0xEA, 0x00}, + {0xEB, 0x00}, {0xEC, 0x00}, {0xED, 0x00}, {0xEE, 0x00}, + {0xEF, 0x00}, }; #define GFX_NUM_SAA7114_INIT_VALUES sizeof(gfx_saa7114_init_values)/sizeof(GFX_SAA7114_INIT) @@ -198,35 +196,33 @@ GFX_SAA7114_INIT gfx_saa7114_init_values[] = { int optimize_for_aliasing = 0; -typedef struct tagGFX_SAA7114_FIR_PREFILTER -{ - unsigned char prescaler; - unsigned char acl_low; - unsigned char prefilter_low; - unsigned char acl_high; - unsigned char prefilter_high; -} -GFX_SAA7114_FIR_PREFILTER; +typedef struct tagGFX_SAA7114_FIR_PREFILTER { + unsigned char prescaler; + unsigned char acl_low; + unsigned char prefilter_low; + unsigned char acl_high; + unsigned char prefilter_high; +} GFX_SAA7114_FIR_PREFILTER; GFX_SAA7114_FIR_PREFILTER gfx_saa7114_fir_values[] = { - {0x01, 0x00, 0x00, 0x00, 0x00}, {0x02, 0x02, 0x5A, 0x01, 0x51}, - {0x03, 0x04, 0xAB, 0x03, 0xA2}, {0x04, 0x07, 0xA3, 0x04, 0xAB}, - {0x05, 0x08, 0xAC, 0x07, 0xA3}, {0x06, 0x08, 0xFC, 0x07, 0xF3}, - {0x07, 0x08, 0xFC, 0x07, 0xF3}, {0x08, 0x0F, 0xF4, 0x08, 0xFC}, - {0x09, 0x0F, 0xF4, 0x08, 0xFC}, {0x0A, 0x10, 0xFD, 0x08, 0xFC}, - {0x0B, 0x10, 0xFD, 0x08, 0xFC}, {0x0C, 0x10, 0xFD, 0x08, 0xFC}, - {0x0D, 0x10, 0xFD, 0x10, 0xFD}, {0x0E, 0x10, 0xFD, 0x10, 0xFD}, - {0x0F, 0x1F, 0xF5, 0x10, 0xFD}, {0x10, 0x20, 0xFE, 0x10, 0xFD}, - {0x11, 0x20, 0xFE, 0x10, 0xFD}, {0x12, 0x20, 0xFE, 0x10, 0xFD}, - {0x13, 0x20, 0xFE, 0x20, 0xFE}, {0x14, 0x20, 0xFE, 0x20, 0xFE}, - {0x15, 0x20, 0xFE, 0x20, 0xFE}, {0x16, 0x20, 0xFE, 0x20, 0xFE}, - {0x17, 0x20, 0xFE, 0x20, 0xFE}, {0x18, 0x20, 0xFE, 0x20, 0xFE}, - {0x19, 0x20, 0xFE, 0x20, 0xFE}, {0x1A, 0x20, 0xFE, 0x20, 0xFE}, - {0x1B, 0x20, 0xFE, 0x20, 0xFE}, {0x1C, 0x20, 0xFE, 0x20, 0xFE}, - {0x1D, 0x20, 0xFE, 0x20, 0xFE}, {0x1E, 0x20, 0xFE, 0x20, 0xFE}, - {0x1F, 0x20, 0xFE, 0x20, 0xFE}, {0x20, 0x3F, 0xFF, 0x20, 0xFE}, - {0x21, 0x3F, 0xFF, 0x20, 0xFE}, {0x22, 0x3F, 0xFF, 0x20, 0xFE}, - {0x23, 0x3F, 0xFF, 0x20, 0xFF} + {0x01, 0x00, 0x00, 0x00, 0x00}, {0x02, 0x02, 0x5A, 0x01, 0x51}, + {0x03, 0x04, 0xAB, 0x03, 0xA2}, {0x04, 0x07, 0xA3, 0x04, 0xAB}, + {0x05, 0x08, 0xAC, 0x07, 0xA3}, {0x06, 0x08, 0xFC, 0x07, 0xF3}, + {0x07, 0x08, 0xFC, 0x07, 0xF3}, {0x08, 0x0F, 0xF4, 0x08, 0xFC}, + {0x09, 0x0F, 0xF4, 0x08, 0xFC}, {0x0A, 0x10, 0xFD, 0x08, 0xFC}, + {0x0B, 0x10, 0xFD, 0x08, 0xFC}, {0x0C, 0x10, 0xFD, 0x08, 0xFC}, + {0x0D, 0x10, 0xFD, 0x10, 0xFD}, {0x0E, 0x10, 0xFD, 0x10, 0xFD}, + {0x0F, 0x1F, 0xF5, 0x10, 0xFD}, {0x10, 0x20, 0xFE, 0x10, 0xFD}, + {0x11, 0x20, 0xFE, 0x10, 0xFD}, {0x12, 0x20, 0xFE, 0x10, 0xFD}, + {0x13, 0x20, 0xFE, 0x20, 0xFE}, {0x14, 0x20, 0xFE, 0x20, 0xFE}, + {0x15, 0x20, 0xFE, 0x20, 0xFE}, {0x16, 0x20, 0xFE, 0x20, 0xFE}, + {0x17, 0x20, 0xFE, 0x20, 0xFE}, {0x18, 0x20, 0xFE, 0x20, 0xFE}, + {0x19, 0x20, 0xFE, 0x20, 0xFE}, {0x1A, 0x20, 0xFE, 0x20, 0xFE}, + {0x1B, 0x20, 0xFE, 0x20, 0xFE}, {0x1C, 0x20, 0xFE, 0x20, 0xFE}, + {0x1D, 0x20, 0xFE, 0x20, 0xFE}, {0x1E, 0x20, 0xFE, 0x20, 0xFE}, + {0x1F, 0x20, 0xFE, 0x20, 0xFE}, {0x20, 0x3F, 0xFF, 0x20, 0xFE}, + {0x21, 0x3F, 0xFF, 0x20, 0xFE}, {0x22, 0x3F, 0xFF, 0x20, 0xFE}, + {0x23, 0x3F, 0xFF, 0x20, 0xFF} }; int saa7114_set_decoder_defaults(void); @@ -236,12 +232,11 @@ int saa7114_set_decoder_contrast(unsigned char contrast); int saa7114_set_decoder_hue(char hue); int saa7114_set_decoder_saturation(unsigned char saturation); int saa7114_set_decoder_input_offset(unsigned short x, unsigned short y); -int saa7114_set_decoder_input_size(unsigned short width, - unsigned short height); +int saa7114_set_decoder_input_size(unsigned short width, unsigned short height); int saa7114_set_decoder_output_size(unsigned short width, - unsigned short height); + unsigned short height); int saa7114_set_decoder_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); + unsigned short dstw, unsigned short dsth); int saa7114_set_decoder_vbi_format(int start, int end, int format); int saa7114_set_decoder_vbi_enable(int enable); int saa7114_set_decoder_vbi_upscale(void); @@ -267,13 +262,13 @@ int saa7114_read_reg(unsigned char reg, unsigned char *val); int saa7114_write_reg(unsigned char reg, unsigned char val) { - return gfx_i2c_write(2, SAA7114_CHIPADDR, reg, 1, &val); + return gfx_i2c_write(2, SAA7114_CHIPADDR, reg, 1, &val); } int saa7114_read_reg(unsigned char reg, unsigned char *val) { - return gfx_i2c_read(2, SAA7114_CHIPADDR, reg, 1, val); + return gfx_i2c_read(2, SAA7114_CHIPADDR, reg, 1, val); } /*----------------------------------------------------------------------------- @@ -292,19 +287,19 @@ int gfx_set_decoder_vbi_upscale(void) #endif { - /* Set horizontal output length to 1528 (720 * 2 * 14.318 / 13.5) */ - saa7114_write_reg(SAA7114_TASK_A_HORZ_OUTPUT_LO, 0xF8); - saa7114_write_reg(SAA7114_TASK_A_HORZ_OUTPUT_HI, 0x05); + /* Set horizontal output length to 1528 (720 * 2 * 14.318 / 13.5) */ + saa7114_write_reg(SAA7114_TASK_A_HORZ_OUTPUT_LO, 0xF8); + saa7114_write_reg(SAA7114_TASK_A_HORZ_OUTPUT_HI, 0x05); - /* Set horizontal luminance scaling increment to 484 (1024 * 13.5 / 28.636) */ - saa7114_write_reg(SAA7114_TASK_A_HSCALE_LUMA_LO, 0xE4); - saa7114_write_reg(SAA7114_TASK_A_HSCALE_LUMA_HI, 0x01); + /* Set horizontal luminance scaling increment to 484 (1024 * 13.5 / 28.636) */ + saa7114_write_reg(SAA7114_TASK_A_HSCALE_LUMA_LO, 0xE4); + saa7114_write_reg(SAA7114_TASK_A_HSCALE_LUMA_HI, 0x01); - /* Set horizontal chrominance scaling increment to 242 */ - saa7114_write_reg(SAA7114_TASK_A_HSCALE_CHROMA_LO, 0xF2); - saa7114_write_reg(SAA7114_TASK_A_HSCALE_CHROMA_HI, 0x00); + /* Set horizontal chrominance scaling increment to 242 */ + saa7114_write_reg(SAA7114_TASK_A_HSCALE_CHROMA_LO, 0xF2); + saa7114_write_reg(SAA7114_TASK_A_HSCALE_CHROMA_HI, 0x00); - return GFX_STATUS_OK; + return GFX_STATUS_OK; } /*----------------------------------------------------------------------------- @@ -321,11 +316,11 @@ int gfx_decoder_software_reset(void) #endif { - saa7114_write_reg(0x88, 0xC0); - /* I2C-bus latency should be sufficient for resetting the internal state machine. */ - /* gfx_delay_milliseconds(10); */ - saa7114_write_reg(0x88, 0xF0); - return GFX_STATUS_OK; + saa7114_write_reg(0x88, 0xC0); + /* I2C-bus latency should be sufficient for resetting the internal state machine. */ + /* gfx_delay_milliseconds(10); */ + saa7114_write_reg(0x88, 0xF0); + return GFX_STATUS_OK; } /*----------------------------------------------------------------------------- @@ -342,10 +337,10 @@ int gfx_decoder_detect_macrovision(void) #endif { - unsigned char macrovision = 0xff; + unsigned char macrovision = 0xff; - saa7114_read_reg(SAA7114_STATUS, ¯ovision); - return ((macrovision & 0x02) >> 1); + saa7114_read_reg(SAA7114_STATUS, ¯ovision); + return ((macrovision & 0x02) >> 1); } /*----------------------------------------------------------------------------- @@ -362,10 +357,10 @@ int gfx_decoder_detect_video(void) #endif { - unsigned char video = 0xff; + unsigned char video = 0xff; - saa7114_read_reg(SAA7114_STATUS, &video); - return !((video & 0x40) >> 6); + saa7114_read_reg(SAA7114_STATUS, &video); + return !((video & 0x40) >> 6); } /*----------------------------------------------------------------------------- @@ -383,17 +378,17 @@ int gfx_set_decoder_defaults(void) #endif { - unsigned int i; + unsigned int i; - /* LOOP THROUGH INDEX/DATA PAIRS IN THE TABLE */ + /* LOOP THROUGH INDEX/DATA PAIRS IN THE TABLE */ - for (i = 0; i < GFX_NUM_SAA7114_INIT_VALUES; i++) { - saa7114_write_reg(gfx_saa7114_init_values[i].index, - gfx_saa7114_init_values[i].value); - } + for (i = 0; i < GFX_NUM_SAA7114_INIT_VALUES; i++) { + saa7114_write_reg(gfx_saa7114_init_values[i].index, + gfx_saa7114_init_values[i].value); + } - gfx_decoder_software_reset(); - return (0); + gfx_decoder_software_reset(); + return (0); } /*----------------------------------------------------------------------------- @@ -410,8 +405,8 @@ int gfx_set_decoder_analog_input(unsigned char input) #endif { - saa7114_write_reg(SAA7114_ANALOG_INPUT_CTRL1, input); - return (0); + saa7114_write_reg(SAA7114_ANALOG_INPUT_CTRL1, input); + return (0); } /*----------------------------------------------------------------------------- @@ -428,8 +423,8 @@ int gfx_set_decoder_brightness(unsigned char brightness) #endif { - saa7114_write_reg(SAA7114_BRIGHTNESS, brightness); - return (0); + saa7114_write_reg(SAA7114_BRIGHTNESS, brightness); + return (0); } /*----------------------------------------------------------------------------- @@ -446,8 +441,8 @@ int gfx_set_decoder_contrast(unsigned char contrast) #endif { - saa7114_write_reg(SAA7114_CONTRAST, (unsigned char)(contrast >> 1)); - return (0); + saa7114_write_reg(SAA7114_CONTRAST, (unsigned char) (contrast >> 1)); + return (0); } /*----------------------------------------------------------------------------- @@ -464,8 +459,8 @@ int gfx_set_decoder_hue(char hue) #endif { - saa7114_write_reg(SAA7114_HUE, (unsigned char)hue); - return (0); + saa7114_write_reg(SAA7114_HUE, (unsigned char) hue); + return (0); } /*----------------------------------------------------------------------------- @@ -482,8 +477,8 @@ int gfx_set_decoder_saturation(unsigned char saturation) #endif { - saa7114_write_reg(SAA7114_SATURATION, (unsigned char)(saturation >> 1)); - return (0); + saa7114_write_reg(SAA7114_SATURATION, (unsigned char) (saturation >> 1)); + return (0); } /*----------------------------------------------------------------------------- @@ -500,15 +495,15 @@ int gfx_set_decoder_input_offset(unsigned short x, unsigned short y) #endif { - /* SET THE INPUT WINDOW OFFSET */ + /* SET THE INPUT WINDOW OFFSET */ - saa7114_write_reg(SAA7114_HORZ_OFFSET_LO, (unsigned char)(x & 0x00FF)); - saa7114_write_reg(SAA7114_HORZ_OFFSET_HI, (unsigned char)(x >> 8)); - saa7114_write_reg(SAA7114_VERT_OFFSET_LO, (unsigned char)(y & 0x00FF)); - saa7114_write_reg(SAA7114_VERT_OFFSET_HI, (unsigned char)(y >> 8)); + saa7114_write_reg(SAA7114_HORZ_OFFSET_LO, (unsigned char) (x & 0x00FF)); + saa7114_write_reg(SAA7114_HORZ_OFFSET_HI, (unsigned char) (x >> 8)); + saa7114_write_reg(SAA7114_VERT_OFFSET_LO, (unsigned char) (y & 0x00FF)); + saa7114_write_reg(SAA7114_VERT_OFFSET_HI, (unsigned char) (y >> 8)); - gfx_decoder_software_reset(); - return (0); + gfx_decoder_software_reset(); + return (0); } /*----------------------------------------------------------------------------- @@ -525,19 +520,19 @@ int gfx_set_decoder_input_size(unsigned short width, unsigned short height) #endif { - /* DIVIDE HEIGHT BY TWO FOR INTERLACING */ + /* DIVIDE HEIGHT BY TWO FOR INTERLACING */ - height = (height + 1) >> 1; + height = (height + 1) >> 1; - /* SET THE INPUT WINDOW SIZE */ + /* SET THE INPUT WINDOW SIZE */ - saa7114_write_reg(SAA7114_HORZ_INPUT_LO, (unsigned char)(width & 0x00FF)); - saa7114_write_reg(SAA7114_HORZ_INPUT_HI, (unsigned char)(width >> 8)); - saa7114_write_reg(SAA7114_VERT_INPUT_LO, (unsigned char)(height & 0x00FF)); - saa7114_write_reg(SAA7114_VERT_INPUT_HI, (unsigned char)(height >> 8)); + saa7114_write_reg(SAA7114_HORZ_INPUT_LO, (unsigned char) (width & 0x00FF)); + saa7114_write_reg(SAA7114_HORZ_INPUT_HI, (unsigned char) (width >> 8)); + saa7114_write_reg(SAA7114_VERT_INPUT_LO, (unsigned char) (height & 0x00FF)); + saa7114_write_reg(SAA7114_VERT_INPUT_HI, (unsigned char) (height >> 8)); - gfx_decoder_software_reset(); - return (0); + gfx_decoder_software_reset(); + return (0); } /*----------------------------------------------------------------------------- @@ -554,24 +549,24 @@ int gfx_set_decoder_output_size(unsigned short width, unsigned short height) #endif { - /* ROUND WIDTH UP TO EVEN NUMBER TO PREVENT DECODER BECOMING STUCK */ + /* ROUND WIDTH UP TO EVEN NUMBER TO PREVENT DECODER BECOMING STUCK */ - width = ((width + 1) >> 1) << 1; + width = ((width + 1) >> 1) << 1; - /* DIVIDE HEIGHT BY TWO FOR INTERLACING */ + /* DIVIDE HEIGHT BY TWO FOR INTERLACING */ - height = (height + 1) >> 1; + height = (height + 1) >> 1; - /* SET THE OUTPUT WINDOW SIZE */ + /* SET THE OUTPUT WINDOW SIZE */ - saa7114_write_reg(SAA7114_HORZ_OUTPUT_LO, (unsigned char)(width & 0x00FF)); - saa7114_write_reg(SAA7114_HORZ_OUTPUT_HI, (unsigned char)(width >> 8)); - saa7114_write_reg(SAA7114_VERT_OUTPUT_LO, - (unsigned char)(height & 0x00FF)); - saa7114_write_reg(SAA7114_VERT_OUTPUT_HI, (unsigned char)(height >> 8)); + saa7114_write_reg(SAA7114_HORZ_OUTPUT_LO, (unsigned char) (width & 0x00FF)); + saa7114_write_reg(SAA7114_HORZ_OUTPUT_HI, (unsigned char) (width >> 8)); + saa7114_write_reg(SAA7114_VERT_OUTPUT_LO, + (unsigned char) (height & 0x00FF)); + saa7114_write_reg(SAA7114_VERT_OUTPUT_HI, (unsigned char) (height >> 8)); - gfx_decoder_software_reset(); - return (0); + gfx_decoder_software_reset(); + return (0); } /*----------------------------------------------------------------------------- @@ -583,143 +578,147 @@ gfx_set_decoder_output_size(unsigned short width, unsigned short height) #if GFX_DECODER_DYNAMIC int saa7114_set_decoder_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #else int gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #endif { - unsigned char prescale = 0; - int scale = 0; - - /* SET THE HORIZONTAL PRESCALE */ - /* Downscale from 1 to 1/63 source size. */ - - if (dstw) - prescale = (unsigned char)(srcw / dstw); - if (!prescale) - prescale = 1; - if (prescale > 63) - return (1); - saa7114_write_reg(SAA7114_HORZ_PRESCALER, prescale); - - /* USE FIR PREFILTER FUNCTIONALITY (OPTIMISATION) */ - - if (prescale < 36) { - if (optimize_for_aliasing) { - saa7114_write_reg(SAA7114_HORZ_ACL, - gfx_saa7114_fir_values[prescale - 1].acl_low); - saa7114_write_reg(SAA7114_HORZ_FIR_PREFILTER, - gfx_saa7114_fir_values[prescale - - 1].prefilter_low); - } else { - saa7114_write_reg(SAA7114_HORZ_ACL, - gfx_saa7114_fir_values[prescale - 1].acl_high); - saa7114_write_reg(SAA7114_HORZ_FIR_PREFILTER, - gfx_saa7114_fir_values[prescale - - 1].prefilter_high); - } - } else { - /* SAME SETTINGS FOR RATIO 1/35 DOWNTO 1/63 */ - if (optimize_for_aliasing) { - saa7114_write_reg(SAA7114_HORZ_ACL, - gfx_saa7114_fir_values[34].acl_low); - saa7114_write_reg(SAA7114_HORZ_FIR_PREFILTER, - gfx_saa7114_fir_values[34].prefilter_low); - } else { - saa7114_write_reg(SAA7114_HORZ_ACL, - gfx_saa7114_fir_values[34].acl_high); - saa7114_write_reg(SAA7114_HORZ_FIR_PREFILTER, - gfx_saa7114_fir_values[34].prefilter_high); - } - } - - /* SET THE HORIZONTAL SCALING */ - - if (!dstw) - return (1); - scale = ((1024 * srcw * 1000) / (dstw * prescale)) / 1000; - if ((scale > 8191) || (scale < 300)) - return (1); - saa7114_write_reg(SAA7114_HSCALE_LUMA_LO, (unsigned char)(scale & 0x00FF)); - saa7114_write_reg(SAA7114_HSCALE_LUMA_HI, (unsigned char)(scale >> 8)); - scale >>= 1; - saa7114_write_reg(SAA7114_HSCALE_CHROMA_LO, - (unsigned char)(scale & 0x00FF)); - saa7114_write_reg(SAA7114_HSCALE_CHROMA_HI, (unsigned char)(scale >> 8)); - - /* SET THE VERTICAL SCALING (INTERPOLATION MODE) */ - - if (!dsth) - return (1); - - /* ROUND DESTINATION HEIGHT UP TO EVEN NUMBER TO PREVENT DECODER BECOMING STUCK */ - - dsth = ((dsth + 1) >> 1) << 1; - - scale = (int)((1024 * srch) / dsth); - saa7114_write_reg(SAA7114_VSCALE_LUMA_LO, (unsigned char)(scale & 0x00FF)); - saa7114_write_reg(SAA7114_VSCALE_LUMA_HI, (unsigned char)(scale >> 8)); - saa7114_write_reg(SAA7114_VSCALE_CHROMA_LO, - (unsigned char)(scale & 0x00FF)); - saa7114_write_reg(SAA7114_VSCALE_CHROMA_HI, (unsigned char)(scale >> 8)); - - if (dsth >= (srch >> 1)) { - /* USE INTERPOLATION MODE FOR SCALE FACTOR ABOVE 0.5 */ - - saa7114_write_reg(SAA7114_VSCALE_CONTROL, 0x00); - - /* SET VERTICAL PHASE REGISTER FOR CORRECT SCALED INTERLACED OUTPUT (OPTIMISATION) */ - /* THE OPTIMISATION IS BASED ON OFIDC = 0 (REG 90h[6] = 0 ) */ - saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS0, SAA7114_VSCALE_PHO); - saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS1, SAA7114_VSCALE_PHO); - saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS2, - (unsigned char)(SAA7114_VSCALE_PHO + scale / 64 - - 16)); - saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS3, - (unsigned char)(SAA7114_VSCALE_PHO + scale / 64 - - 16)); - - saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS0, SAA7114_VSCALE_PHO); - saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS1, SAA7114_VSCALE_PHO); - saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS2, - (unsigned char)(SAA7114_VSCALE_PHO + scale / 64 - - 16)); - saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS3, - (unsigned char)(SAA7114_VSCALE_PHO + scale / 64 - - 16)); - - /* RESTORE CONTRAST AND SATURATION FOR INTERPOLATION MODE */ - - saa7114_write_reg(SAA7114_FILTER_CONTRAST, (unsigned char)0x40); - saa7114_write_reg(SAA7114_FILTER_SATURATION, (unsigned char)0x40); - } else { - /* USE ACCUMULATION MODE FOR DOWNSCALING BY MORE THAN 2x */ - - saa7114_write_reg(SAA7114_VSCALE_CONTROL, 0x01); - - /* SET VERTICAL PHASE OFFSETS OFF (OPTIMISATION) */ - saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS0, 0x00); - saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS1, 0x00); - saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS2, 0x00); - saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS3, 0x00); - - saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS0, 0x00); - saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS1, 0x00); - saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS2, 0x00); - saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS3, 0x00); - - /* ADJUST CONTRAST AND SATURATION FOR ACCUMULATION MODE */ - - if (srch) - scale = (64 * dsth) / srch; - saa7114_write_reg(SAA7114_FILTER_CONTRAST, (unsigned char)scale); - saa7114_write_reg(SAA7114_FILTER_SATURATION, (unsigned char)scale); - } - - gfx_decoder_software_reset(); - return (0); + unsigned char prescale = 0; + int scale = 0; + + /* SET THE HORIZONTAL PRESCALE */ + /* Downscale from 1 to 1/63 source size. */ + + if (dstw) + prescale = (unsigned char) (srcw / dstw); + if (!prescale) + prescale = 1; + if (prescale > 63) + return (1); + saa7114_write_reg(SAA7114_HORZ_PRESCALER, prescale); + + /* USE FIR PREFILTER FUNCTIONALITY (OPTIMISATION) */ + + if (prescale < 36) { + if (optimize_for_aliasing) { + saa7114_write_reg(SAA7114_HORZ_ACL, + gfx_saa7114_fir_values[prescale - 1].acl_low); + saa7114_write_reg(SAA7114_HORZ_FIR_PREFILTER, + gfx_saa7114_fir_values[prescale - + 1].prefilter_low); + } + else { + saa7114_write_reg(SAA7114_HORZ_ACL, + gfx_saa7114_fir_values[prescale - 1].acl_high); + saa7114_write_reg(SAA7114_HORZ_FIR_PREFILTER, + gfx_saa7114_fir_values[prescale - + 1].prefilter_high); + } + } + else { + /* SAME SETTINGS FOR RATIO 1/35 DOWNTO 1/63 */ + if (optimize_for_aliasing) { + saa7114_write_reg(SAA7114_HORZ_ACL, + gfx_saa7114_fir_values[34].acl_low); + saa7114_write_reg(SAA7114_HORZ_FIR_PREFILTER, + gfx_saa7114_fir_values[34].prefilter_low); + } + else { + saa7114_write_reg(SAA7114_HORZ_ACL, + gfx_saa7114_fir_values[34].acl_high); + saa7114_write_reg(SAA7114_HORZ_FIR_PREFILTER, + gfx_saa7114_fir_values[34].prefilter_high); + } + } + + /* SET THE HORIZONTAL SCALING */ + + if (!dstw) + return (1); + scale = ((1024 * srcw * 1000) / (dstw * prescale)) / 1000; + if ((scale > 8191) || (scale < 300)) + return (1); + saa7114_write_reg(SAA7114_HSCALE_LUMA_LO, (unsigned char) (scale & 0x00FF)); + saa7114_write_reg(SAA7114_HSCALE_LUMA_HI, (unsigned char) (scale >> 8)); + scale >>= 1; + saa7114_write_reg(SAA7114_HSCALE_CHROMA_LO, + (unsigned char) (scale & 0x00FF)); + saa7114_write_reg(SAA7114_HSCALE_CHROMA_HI, (unsigned char) (scale >> 8)); + + /* SET THE VERTICAL SCALING (INTERPOLATION MODE) */ + + if (!dsth) + return (1); + + /* ROUND DESTINATION HEIGHT UP TO EVEN NUMBER TO PREVENT DECODER BECOMING STUCK */ + + dsth = ((dsth + 1) >> 1) << 1; + + scale = (int) ((1024 * srch) / dsth); + saa7114_write_reg(SAA7114_VSCALE_LUMA_LO, (unsigned char) (scale & 0x00FF)); + saa7114_write_reg(SAA7114_VSCALE_LUMA_HI, (unsigned char) (scale >> 8)); + saa7114_write_reg(SAA7114_VSCALE_CHROMA_LO, + (unsigned char) (scale & 0x00FF)); + saa7114_write_reg(SAA7114_VSCALE_CHROMA_HI, (unsigned char) (scale >> 8)); + + if (dsth >= (srch >> 1)) { + /* USE INTERPOLATION MODE FOR SCALE FACTOR ABOVE 0.5 */ + + saa7114_write_reg(SAA7114_VSCALE_CONTROL, 0x00); + + /* SET VERTICAL PHASE REGISTER FOR CORRECT SCALED INTERLACED OUTPUT (OPTIMISATION) */ + /* THE OPTIMISATION IS BASED ON OFIDC = 0 (REG 90h[6] = 0 ) */ + saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS0, SAA7114_VSCALE_PHO); + saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS1, SAA7114_VSCALE_PHO); + saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS2, + (unsigned char) (SAA7114_VSCALE_PHO + scale / 64 - + 16)); + saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS3, + (unsigned char) (SAA7114_VSCALE_PHO + scale / 64 - + 16)); + + saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS0, SAA7114_VSCALE_PHO); + saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS1, SAA7114_VSCALE_PHO); + saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS2, + (unsigned char) (SAA7114_VSCALE_PHO + scale / 64 - + 16)); + saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS3, + (unsigned char) (SAA7114_VSCALE_PHO + scale / 64 - + 16)); + + /* RESTORE CONTRAST AND SATURATION FOR INTERPOLATION MODE */ + + saa7114_write_reg(SAA7114_FILTER_CONTRAST, (unsigned char) 0x40); + saa7114_write_reg(SAA7114_FILTER_SATURATION, (unsigned char) 0x40); + } + else { + /* USE ACCUMULATION MODE FOR DOWNSCALING BY MORE THAN 2x */ + + saa7114_write_reg(SAA7114_VSCALE_CONTROL, 0x01); + + /* SET VERTICAL PHASE OFFSETS OFF (OPTIMISATION) */ + saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS0, 0x00); + saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS1, 0x00); + saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS2, 0x00); + saa7114_write_reg(SAA7114_VSCALE_CHROMA_OFFS3, 0x00); + + saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS0, 0x00); + saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS1, 0x00); + saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS2, 0x00); + saa7114_write_reg(SAA7114_VSCALE_LUMINA_OFFS3, 0x00); + + /* ADJUST CONTRAST AND SATURATION FOR ACCUMULATION MODE */ + + if (srch) + scale = (64 * dsth) / srch; + saa7114_write_reg(SAA7114_FILTER_CONTRAST, (unsigned char) scale); + saa7114_write_reg(SAA7114_FILTER_SATURATION, (unsigned char) scale); + } + + gfx_decoder_software_reset(); + return (0); } /*----------------------------------------------------------------------------- @@ -737,29 +736,29 @@ int gfx_set_decoder_vbi_format(int start, int end, int format) #endif { - int i; - unsigned char data; - - for (i = start; i <= end; i++) { - switch (format) { - case VBI_FORMAT_VIDEO: - data = 0xFF; - break; /* Active video */ - case VBI_FORMAT_RAW: - data = 0x77; - break; /* Raw VBI data */ - case VBI_FORMAT_CC: - data = 0x55; - break; /* US CC */ - case VBI_FORMAT_NABTS: - data = 0xCC; - break; /* US NABTS */ - default: - return GFX_STATUS_BAD_PARAMETER; - } - saa7114_write_reg((unsigned char)(0x3F + i), data); - } - return GFX_STATUS_OK; + int i; + unsigned char data; + + for (i = start; i <= end; i++) { + switch (format) { + case VBI_FORMAT_VIDEO: + data = 0xFF; + break; /* Active video */ + case VBI_FORMAT_RAW: + data = 0x77; + break; /* Raw VBI data */ + case VBI_FORMAT_CC: + data = 0x55; + break; /* US CC */ + case VBI_FORMAT_NABTS: + data = 0xCC; + break; /* US NABTS */ + default: + return GFX_STATUS_BAD_PARAMETER; + } + saa7114_write_reg((unsigned char) (0x3F + i), data); + } + return GFX_STATUS_OK; } /*----------------------------------------------------------------------------- @@ -776,15 +775,15 @@ int gfx_set_decoder_vbi_enable(int enable) #endif { - unsigned char data; - - saa7114_read_reg(SAA7114_IPORT_CONTROL, &data); - if (enable) - data |= 0x80; - else - data &= ~0x80; - saa7114_write_reg(SAA7114_IPORT_CONTROL, data); - return GFX_STATUS_OK; + unsigned char data; + + saa7114_read_reg(SAA7114_IPORT_CONTROL, &data); + if (enable) + data |= 0x80; + else + data &= ~0x80; + saa7114_write_reg(SAA7114_IPORT_CONTROL, data); + return GFX_STATUS_OK; } /*----------------------------------------------------------------------------- @@ -801,20 +800,20 @@ int gfx_set_decoder_TV_standard(TVStandardType TVStandard) #endif { - switch (TVStandard) { - case TV_STANDARD_NTSC: - saa7114_write_reg(0x0E, 0x89); - saa7114_write_reg(0x5A, 0x06); - break; - case TV_STANDARD_PAL: - saa7114_write_reg(0x0E, 0x81); - saa7114_write_reg(0x5A, 0x03); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - gfx_decoder_software_reset(); - return GFX_STATUS_OK; + switch (TVStandard) { + case TV_STANDARD_NTSC: + saa7114_write_reg(0x0E, 0x89); + saa7114_write_reg(0x5A, 0x06); + break; + case TV_STANDARD_PAL: + saa7114_write_reg(0x0E, 0x81); + saa7114_write_reg(0x5A, 0x03); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + gfx_decoder_software_reset(); + return GFX_STATUS_OK; } /*----------------------------------------------------------------------------- @@ -831,12 +830,12 @@ int gfx_set_decoder_luminance_filter(unsigned char lufi) #endif { - unsigned char data; + unsigned char data; - saa7114_read_reg(SAA7114_LUMINANCE_CONTROL, &data); - saa7114_write_reg(SAA7114_LUMINANCE_CONTROL, - (unsigned char)((data & ~0x0F) | (lufi & 0x0F))); - return (0); + saa7114_read_reg(SAA7114_LUMINANCE_CONTROL, &data); + saa7114_write_reg(SAA7114_LUMINANCE_CONTROL, + (unsigned char) ((data & ~0x0F) | (lufi & 0x0F))); + return (0); } /*************************************************************/ @@ -859,10 +858,10 @@ unsigned char gfx_get_decoder_brightness(void) #endif { - unsigned char brightness = 0; + unsigned char brightness = 0; - saa7114_read_reg(SAA7114_BRIGHTNESS, &brightness); - return (brightness); + saa7114_read_reg(SAA7114_BRIGHTNESS, &brightness); + return (brightness); } /*----------------------------------------------------------------------------- @@ -879,11 +878,11 @@ unsigned char gfx_get_decoder_contrast(void) #endif { - unsigned char contrast = 0; + unsigned char contrast = 0; - saa7114_read_reg(SAA7114_CONTRAST, &contrast); - contrast <<= 1; - return (contrast); + saa7114_read_reg(SAA7114_CONTRAST, &contrast); + contrast <<= 1; + return (contrast); } /*----------------------------------------------------------------------------- @@ -900,10 +899,10 @@ char gfx_get_decoder_hue(void) #endif { - unsigned char hue = 0; + unsigned char hue = 0; - saa7114_read_reg(SAA7114_HUE, &hue); - return ((char)hue); + saa7114_read_reg(SAA7114_HUE, &hue); + return ((char) hue); } /*----------------------------------------------------------------------------- @@ -920,11 +919,11 @@ unsigned char gfx_get_decoder_saturation(void) #endif { - unsigned char saturation = 0; + unsigned char saturation = 0; - saa7114_read_reg(SAA7114_SATURATION, &saturation); - saturation <<= 1; - return (saturation); + saa7114_read_reg(SAA7114_SATURATION, &saturation); + saturation <<= 1; + return (saturation); } /*----------------------------------------------------------------------------- @@ -941,18 +940,18 @@ unsigned long gfx_get_decoder_input_offset(void) #endif { - unsigned long value = 0; - unsigned char data; - - saa7114_read_reg(SAA7114_HORZ_OFFSET_LO, &data); - value = (unsigned long)data; - saa7114_read_reg(SAA7114_HORZ_OFFSET_HI, &data); - value |= ((unsigned long)data) << 8; - saa7114_read_reg(SAA7114_VERT_OFFSET_LO, &data); - value |= ((unsigned long)data) << 16; - saa7114_read_reg(SAA7114_VERT_OFFSET_HI, &data); - value |= ((unsigned long)data) << 24; - return (value); + unsigned long value = 0; + unsigned char data; + + saa7114_read_reg(SAA7114_HORZ_OFFSET_LO, &data); + value = (unsigned long) data; + saa7114_read_reg(SAA7114_HORZ_OFFSET_HI, &data); + value |= ((unsigned long) data) << 8; + saa7114_read_reg(SAA7114_VERT_OFFSET_LO, &data); + value |= ((unsigned long) data) << 16; + saa7114_read_reg(SAA7114_VERT_OFFSET_HI, &data); + value |= ((unsigned long) data) << 24; + return (value); } /*----------------------------------------------------------------------------- @@ -969,18 +968,18 @@ unsigned long gfx_get_decoder_input_size(void) #endif { - unsigned long value = 0; - unsigned char data; - - saa7114_read_reg(SAA7114_HORZ_INPUT_LO, &data); - value = (unsigned long)data; - saa7114_read_reg(SAA7114_HORZ_INPUT_HI, &data); - value |= ((unsigned long)data) << 8; - saa7114_read_reg(SAA7114_VERT_INPUT_LO, &data); - value |= ((unsigned long)data) << 17; - saa7114_read_reg(SAA7114_VERT_INPUT_HI, &data); - value |= ((unsigned long)data) << 25; - return (value); + unsigned long value = 0; + unsigned char data; + + saa7114_read_reg(SAA7114_HORZ_INPUT_LO, &data); + value = (unsigned long) data; + saa7114_read_reg(SAA7114_HORZ_INPUT_HI, &data); + value |= ((unsigned long) data) << 8; + saa7114_read_reg(SAA7114_VERT_INPUT_LO, &data); + value |= ((unsigned long) data) << 17; + saa7114_read_reg(SAA7114_VERT_INPUT_HI, &data); + value |= ((unsigned long) data) << 25; + return (value); } /*----------------------------------------------------------------------------- @@ -997,18 +996,18 @@ unsigned long gfx_get_decoder_output_size(void) #endif { - unsigned long value = 0; - unsigned char data; - - saa7114_read_reg(SAA7114_HORZ_OUTPUT_LO, &data); - value = (unsigned long)data; - saa7114_read_reg(SAA7114_HORZ_OUTPUT_HI, &data); - value |= ((unsigned long)data) << 8; - saa7114_read_reg(SAA7114_VERT_OUTPUT_LO, &data); - value |= ((unsigned long)data) << 17; - saa7114_read_reg(SAA7114_VERT_OUTPUT_HI, &data); - value |= ((unsigned long)data) << 25; - return (value); + unsigned long value = 0; + unsigned char data; + + saa7114_read_reg(SAA7114_HORZ_OUTPUT_LO, &data); + value = (unsigned long) data; + saa7114_read_reg(SAA7114_HORZ_OUTPUT_HI, &data); + value |= ((unsigned long) data) << 8; + saa7114_read_reg(SAA7114_VERT_OUTPUT_LO, &data); + value |= ((unsigned long) data) << 17; + saa7114_read_reg(SAA7114_VERT_OUTPUT_HI, &data); + value |= ((unsigned long) data) << 25; + return (value); } /*----------------------------------------------------------------------------- @@ -1025,26 +1024,26 @@ int gfx_get_decoder_vbi_format(int line) #endif { - unsigned char format = 0, data; - - saa7114_read_reg((unsigned char)(0x3F + line), &data); - switch (data) { - case 0xFF: - format = VBI_FORMAT_VIDEO; - break; /* Active video */ - case 0x77: - format = VBI_FORMAT_RAW; - break; /* Raw VBI data */ - case 0x55: - format = VBI_FORMAT_CC; - break; /* US CC */ - case 0xCC: - format = VBI_FORMAT_NABTS; - break; /* US NABTS */ - } - return (format); + unsigned char format = 0, data; + + saa7114_read_reg((unsigned char) (0x3F + line), &data); + switch (data) { + case 0xFF: + format = VBI_FORMAT_VIDEO; + break; /* Active video */ + case 0x77: + format = VBI_FORMAT_RAW; + break; /* Raw VBI data */ + case 0x55: + format = VBI_FORMAT_CC; + break; /* US CC */ + case 0xCC: + format = VBI_FORMAT_NABTS; + break; /* US NABTS */ + } + return (format); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ diff --git a/src/gfx/tv_1200.c b/src/gfx/tv_1200.c index 512b28e..86351bf 100644 --- a/src/gfx/tv_1200.c +++ b/src/gfx/tv_1200.c @@ -148,12 +148,11 @@ int sc1200_get_tv_output(void); int sc1200_get_tv_mode_count(TVStandardType format); int sc1200_get_tv_display_mode(int *width, int *height, int *bpp, int *hz); int sc1200_get_tv_display_mode_frequency(unsigned short width, - unsigned short height, - TVStandardType format, - int *frequency); + unsigned short height, + TVStandardType format, int *frequency); int sc1200_is_tv_display_mode_supported(unsigned short width, - unsigned short height, - TVStandardType format); + unsigned short height, + TVStandardType format); int sc1200_get_tv_standard(unsigned long *p_standard); int sc1200_get_available_tv_standards(unsigned long *p_standards); @@ -198,192 +197,194 @@ int gfx_set_tv_format(TVStandardType format, GfxOnTVType resolution) #endif { - unsigned long ctrl2, mode; - - /* Save TV output mode */ - ctrl2 = - READ_VID32(SC1200_TVENC_TIM_CTRL_2) & (SC1200_TVENC_OUTPUT_YCBCR | - SC1200_TVENC_CFS_MASK); - /* Save flicker filter setting */ - mode = READ_VID32(SC1200_TVOUT_HORZ_SCALING) & - SC1200_TVOUT_FLICKER_FILTER_MASK; - - switch (format) { - case TV_STANDARD_NTSC: - /* Horizontal Sync Start is 848 */ - /* Horizontal Sync End is 856 */ - WRITE_VID32(SC1200_TVOUT_HORZ_SYNC, 0x03580350); - /* Vertical Sync Start is 0 */ - /* Vertical Sync End is 1 */ - /* Vertical Display Start Skew is 1 */ - /* Vertical Display End Skew is 1 */ - WRITE_VID32(SC1200_TVOUT_VERT_SYNC, 0x05001000); - /* Disable vertical down scaling, take all lines */ - if (gfx_chip_revision <= SC1200_REV_B3) - WRITE_VID32(SC1200_TVOUT_VERT_DOWNSCALE, 0xffffffff); - /* Enable video timing */ - /* Reset sub carrier every two frames */ - /* Disable BLANK */ - /* Enable color burst */ - /* Add the IRE offset */ - /* NTSC color encoding */ - /* Video generator timing is 525 lines / 60Hz */ - /* Horizontal and Vertical counters are initialized to HPHASE & VPHASE */ - /* VPHASE is 2, HPHASE is 0x50 */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, 0xa2a01050); - /* Increase horizontal blanking interval */ - /* Low Water Mark for Y is 0x1F */ - /* Low Water Mark for Cb is 0xF */ - /* HUE is 0 */ - /* SCPHASE is 0xF9 */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, 0x9ff000f9 | ctrl2); - /* Subcarrier Frequency is 3.579545 MHz */ - WRITE_VID32(SC1200_TVENC_SUB_FREQ, 0x21f07c1f); - /* VSTART is 18, HSTART is 113 */ - WRITE_VID32(SC1200_TVENC_DISP_POS, 0x00120071); - /* Display size: HEIGHT is 239, WIDTH is 719 */ - WRITE_VID32(SC1200_TVENC_DISP_SIZE, 0x00ef02cf); - switch (resolution) { - case GFX_ON_TV_SQUARE_PIXELS: - if (gfx_chip_revision <= SC1200_REV_B3) { - /* Horizontal Display start is 116 */ - /* Total number of pixels per line is 857 */ - WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x00740359); - /* HSYNC generated in the TV Encoder module */ - /* Interval between resets of TV Encoder is once every odd field */ - /* Enable Horizontal interpolation */ - /* Enable Horizontal up scaling 9/8 */ - /* Disable Horizontal downscale */ - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020700 | mode); - /* Horizontal display end is 919, i.e. 720 active pixels */ - /* Total number of display lines per field is 240 */ - WRITE_VID32(SC1200_TVOUT_LINE_END, 0x039700f0); - } else { /* Use new scaler available in Rev. C */ - /* Horizontal Display start is 111 */ - /* Total number of pixels per line is 857 */ - WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x006f0359); - /* HSYNC generated in the TV Encoder module */ - /* Interval between resets of TV Encoder is once every odd field */ - /* Enable Horizontal interpolation */ - /* Disable Horizontal up scaling 9/8 */ - /* Disable Horizontal downscale */ - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020500 | mode); - /* Set Horizontal upscaling to 64/58 (~ 11/10) */ - WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, 0x3A000000); - /* Horizontal display end is 900, i.e. 706 active pixels */ - /* Total number of display lines per field is 240 */ - WRITE_VID32(SC1200_TVOUT_LINE_END, 0x038400f0); - } - break; - case GFX_ON_TV_NO_SCALING: - /* Horizontal Display start is 116 */ - /* Total number of pixels per line is 857 */ - WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x00740359); - /* HSYNC generated in the TV Encoder module */ - /* Interval between resets of TV Encoder is once every odd field */ - /* Enable Horizontal interpolation */ - /* Disable Horizontal up scaling 9/8 */ - /* Disable Horizontal downscale */ - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020500 | mode); - /* Disable Horizontal scaling (set to 64/64) */ - if (gfx_chip_revision >= SC1200_REV_C1) - WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, 0x40000000); - /* Horizontal display end is 919, i.e. 720 active pixels */ - /* Total number of display lines per field is 240 */ - WRITE_VID32(SC1200_TVOUT_LINE_END, 0x039700f0); - break; - default: - return (GFX_STATUS_BAD_PARAMETER); - } - break; - case TV_STANDARD_PAL: - /* Horizontal Sync Start is 854 */ - /* Horizontal Sync End is 862 */ - WRITE_VID32(SC1200_TVOUT_HORZ_SYNC, 0x035e0356); - /* Vertical Sync Start is 0 */ - /* Vertical Sync End is 1 */ - /* Vertical Display Start Skew is 1 */ - /* Vertical Display End Skew is 1 */ - WRITE_VID32(SC1200_TVOUT_VERT_SYNC, 0x05001000); - /* Disable vertical down scaling, take all lines */ - if (gfx_chip_revision <= SC1200_REV_B3) - WRITE_VID32(SC1200_TVOUT_VERT_DOWNSCALE, 0xffffffff); - /* Enable video timing */ - /* Never reset sub carrier (should be every 4 frames but doesn't work with genlock) */ - /* Disable BLANK */ - /* Enable color burst */ - /* Do not add the IRE offset */ - /* NTSC color encoding */ - /* Video generator timing is 625 lines / 50Hz */ - /* Horizontal and Vertical counters are initialized to HPHASE & VPHASE */ - /* VPHASE is 2, HPHASE is 50 */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, 0xB1201050); - /* Increase horizontal blanking interval */ - /* Low Water Mark for Y is 0x1F */ - /* Low Water Mark for Cb is 0xF */ - /* HUE is 0 */ - /* SCPHASE is 0xD9 */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, 0x9ff000d9 | ctrl2); - /* Subcarrier Frequency is 4.43361875 MHz */ - WRITE_VID32(SC1200_TVENC_SUB_FREQ, 0x2a098acb); - /* VSTART is 22, HSTART is 123 */ - WRITE_VID32(SC1200_TVENC_DISP_POS, 0x0016007b); - /* Display size: HEIGHT is 287, WIDTH is 719 */ - WRITE_VID32(SC1200_TVENC_DISP_SIZE, 0x011f02cf); - switch (resolution) { - case GFX_ON_TV_NO_SCALING: - /* Horizontal Display start is 124 */ - /* Total number of pixels per line is 863 */ - WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x007c035f); - /* HSYNC generated in the TV Encoder module */ - /* Interval between resets of TV Encoder is once every odd field */ - /* Enable Horizontal interpolation */ - /* Disable Horizontal up scaling 9/8 */ - /* Disable Horizontal downscale */ - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020500 | mode); - /* Disable Horizontal scaling (set to 64/64) */ - if (gfx_chip_revision >= SC1200_REV_C1) - WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, 0x40000000); - /* Horizontal display end is 924, i.e. 720 active pixels */ - /* Total number of display lines per field is 288 */ - WRITE_VID32(SC1200_TVOUT_LINE_END, 0x039c0120); - break; - case GFX_ON_TV_SQUARE_PIXELS: - /* Horizontal Display start is 122 */ - /* Total number of pixels per line is 863 */ - WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x007a035f); - if (gfx_chip_revision <= SC1200_REV_B3) { - /* HSYNC generated in the TV Encoder module */ - /* Interval between resets of TV Encoder is once every odd field */ - /* Enable Horizontal interpolation */ - /* Disable Horizontal up scaling 9/8 */ - /* Horizontal downscale m/(m+1), m = 11, (i.e. 11/12 - closest possible to 54/59) */ - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x1002040b | mode); - /* Horizontal display end is 906, i.e. 704 active pixels */ - /* Total number of display lines per field is 288 */ - WRITE_VID32(SC1200_TVOUT_LINE_END, 0x038a0120); - } else { - /* HSYNC generated in the TV Encoder module */ - /* Interval between resets of TV Encoder is once every odd field */ - /* Enable Horizontal interpolation */ - /* Disable Horizontal up scaling 9/8 */ - /* Disable Horizontal downscale */ - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020500 | mode); - /* Set Horizontal down scaling to 64/70 (closest possible to 54/59) */ - WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, 0x46000000); - /* Horizontal display end is 904, i.e. 702 active pixels */ - /* Total number of display lines per field is 288 */ - WRITE_VID32(SC1200_TVOUT_LINE_END, 0x03880120); - } - break; - default: - return (GFX_STATUS_BAD_PARAMETER); - } - break; - default: - return (GFX_STATUS_BAD_PARAMETER); - } - return (GFX_STATUS_OK); + unsigned long ctrl2, mode; + + /* Save TV output mode */ + ctrl2 = + READ_VID32(SC1200_TVENC_TIM_CTRL_2) & (SC1200_TVENC_OUTPUT_YCBCR | + SC1200_TVENC_CFS_MASK); + /* Save flicker filter setting */ + mode = READ_VID32(SC1200_TVOUT_HORZ_SCALING) & + SC1200_TVOUT_FLICKER_FILTER_MASK; + + switch (format) { + case TV_STANDARD_NTSC: + /* Horizontal Sync Start is 848 */ + /* Horizontal Sync End is 856 */ + WRITE_VID32(SC1200_TVOUT_HORZ_SYNC, 0x03580350); + /* Vertical Sync Start is 0 */ + /* Vertical Sync End is 1 */ + /* Vertical Display Start Skew is 1 */ + /* Vertical Display End Skew is 1 */ + WRITE_VID32(SC1200_TVOUT_VERT_SYNC, 0x05001000); + /* Disable vertical down scaling, take all lines */ + if (gfx_chip_revision <= SC1200_REV_B3) + WRITE_VID32(SC1200_TVOUT_VERT_DOWNSCALE, 0xffffffff); + /* Enable video timing */ + /* Reset sub carrier every two frames */ + /* Disable BLANK */ + /* Enable color burst */ + /* Add the IRE offset */ + /* NTSC color encoding */ + /* Video generator timing is 525 lines / 60Hz */ + /* Horizontal and Vertical counters are initialized to HPHASE & VPHASE */ + /* VPHASE is 2, HPHASE is 0x50 */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, 0xa2a01050); + /* Increase horizontal blanking interval */ + /* Low Water Mark for Y is 0x1F */ + /* Low Water Mark for Cb is 0xF */ + /* HUE is 0 */ + /* SCPHASE is 0xF9 */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, 0x9ff000f9 | ctrl2); + /* Subcarrier Frequency is 3.579545 MHz */ + WRITE_VID32(SC1200_TVENC_SUB_FREQ, 0x21f07c1f); + /* VSTART is 18, HSTART is 113 */ + WRITE_VID32(SC1200_TVENC_DISP_POS, 0x00120071); + /* Display size: HEIGHT is 239, WIDTH is 719 */ + WRITE_VID32(SC1200_TVENC_DISP_SIZE, 0x00ef02cf); + switch (resolution) { + case GFX_ON_TV_SQUARE_PIXELS: + if (gfx_chip_revision <= SC1200_REV_B3) { + /* Horizontal Display start is 116 */ + /* Total number of pixels per line is 857 */ + WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x00740359); + /* HSYNC generated in the TV Encoder module */ + /* Interval between resets of TV Encoder is once every odd field */ + /* Enable Horizontal interpolation */ + /* Enable Horizontal up scaling 9/8 */ + /* Disable Horizontal downscale */ + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020700 | mode); + /* Horizontal display end is 919, i.e. 720 active pixels */ + /* Total number of display lines per field is 240 */ + WRITE_VID32(SC1200_TVOUT_LINE_END, 0x039700f0); + } + else { /* Use new scaler available in Rev. C */ + /* Horizontal Display start is 111 */ + /* Total number of pixels per line is 857 */ + WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x006f0359); + /* HSYNC generated in the TV Encoder module */ + /* Interval between resets of TV Encoder is once every odd field */ + /* Enable Horizontal interpolation */ + /* Disable Horizontal up scaling 9/8 */ + /* Disable Horizontal downscale */ + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020500 | mode); + /* Set Horizontal upscaling to 64/58 (~ 11/10) */ + WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, 0x3A000000); + /* Horizontal display end is 900, i.e. 706 active pixels */ + /* Total number of display lines per field is 240 */ + WRITE_VID32(SC1200_TVOUT_LINE_END, 0x038400f0); + } + break; + case GFX_ON_TV_NO_SCALING: + /* Horizontal Display start is 116 */ + /* Total number of pixels per line is 857 */ + WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x00740359); + /* HSYNC generated in the TV Encoder module */ + /* Interval between resets of TV Encoder is once every odd field */ + /* Enable Horizontal interpolation */ + /* Disable Horizontal up scaling 9/8 */ + /* Disable Horizontal downscale */ + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020500 | mode); + /* Disable Horizontal scaling (set to 64/64) */ + if (gfx_chip_revision >= SC1200_REV_C1) + WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, 0x40000000); + /* Horizontal display end is 919, i.e. 720 active pixels */ + /* Total number of display lines per field is 240 */ + WRITE_VID32(SC1200_TVOUT_LINE_END, 0x039700f0); + break; + default: + return (GFX_STATUS_BAD_PARAMETER); + } + break; + case TV_STANDARD_PAL: + /* Horizontal Sync Start is 854 */ + /* Horizontal Sync End is 862 */ + WRITE_VID32(SC1200_TVOUT_HORZ_SYNC, 0x035e0356); + /* Vertical Sync Start is 0 */ + /* Vertical Sync End is 1 */ + /* Vertical Display Start Skew is 1 */ + /* Vertical Display End Skew is 1 */ + WRITE_VID32(SC1200_TVOUT_VERT_SYNC, 0x05001000); + /* Disable vertical down scaling, take all lines */ + if (gfx_chip_revision <= SC1200_REV_B3) + WRITE_VID32(SC1200_TVOUT_VERT_DOWNSCALE, 0xffffffff); + /* Enable video timing */ + /* Never reset sub carrier (should be every 4 frames but doesn't work with genlock) */ + /* Disable BLANK */ + /* Enable color burst */ + /* Do not add the IRE offset */ + /* NTSC color encoding */ + /* Video generator timing is 625 lines / 50Hz */ + /* Horizontal and Vertical counters are initialized to HPHASE & VPHASE */ + /* VPHASE is 2, HPHASE is 50 */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, 0xB1201050); + /* Increase horizontal blanking interval */ + /* Low Water Mark for Y is 0x1F */ + /* Low Water Mark for Cb is 0xF */ + /* HUE is 0 */ + /* SCPHASE is 0xD9 */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, 0x9ff000d9 | ctrl2); + /* Subcarrier Frequency is 4.43361875 MHz */ + WRITE_VID32(SC1200_TVENC_SUB_FREQ, 0x2a098acb); + /* VSTART is 22, HSTART is 123 */ + WRITE_VID32(SC1200_TVENC_DISP_POS, 0x0016007b); + /* Display size: HEIGHT is 287, WIDTH is 719 */ + WRITE_VID32(SC1200_TVENC_DISP_SIZE, 0x011f02cf); + switch (resolution) { + case GFX_ON_TV_NO_SCALING: + /* Horizontal Display start is 124 */ + /* Total number of pixels per line is 863 */ + WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x007c035f); + /* HSYNC generated in the TV Encoder module */ + /* Interval between resets of TV Encoder is once every odd field */ + /* Enable Horizontal interpolation */ + /* Disable Horizontal up scaling 9/8 */ + /* Disable Horizontal downscale */ + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020500 | mode); + /* Disable Horizontal scaling (set to 64/64) */ + if (gfx_chip_revision >= SC1200_REV_C1) + WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, 0x40000000); + /* Horizontal display end is 924, i.e. 720 active pixels */ + /* Total number of display lines per field is 288 */ + WRITE_VID32(SC1200_TVOUT_LINE_END, 0x039c0120); + break; + case GFX_ON_TV_SQUARE_PIXELS: + /* Horizontal Display start is 122 */ + /* Total number of pixels per line is 863 */ + WRITE_VID32(SC1200_TVOUT_HORZ_TIM, 0x007a035f); + if (gfx_chip_revision <= SC1200_REV_B3) { + /* HSYNC generated in the TV Encoder module */ + /* Interval between resets of TV Encoder is once every odd field */ + /* Enable Horizontal interpolation */ + /* Disable Horizontal up scaling 9/8 */ + /* Horizontal downscale m/(m+1), m = 11, (i.e. 11/12 - closest possible to 54/59) */ + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x1002040b | mode); + /* Horizontal display end is 906, i.e. 704 active pixels */ + /* Total number of display lines per field is 288 */ + WRITE_VID32(SC1200_TVOUT_LINE_END, 0x038a0120); + } + else { + /* HSYNC generated in the TV Encoder module */ + /* Interval between resets of TV Encoder is once every odd field */ + /* Enable Horizontal interpolation */ + /* Disable Horizontal up scaling 9/8 */ + /* Disable Horizontal downscale */ + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, 0x10020500 | mode); + /* Set Horizontal down scaling to 64/70 (closest possible to 54/59) */ + WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, 0x46000000); + /* Horizontal display end is 904, i.e. 702 active pixels */ + /* Total number of display lines per field is 288 */ + WRITE_VID32(SC1200_TVOUT_LINE_END, 0x03880120); + } + break; + default: + return (GFX_STATUS_BAD_PARAMETER); + } + break; + default: + return (GFX_STATUS_BAD_PARAMETER); + } + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -401,61 +402,61 @@ int gfx_set_tv_output(int output) #endif { - unsigned long ctrl2, ctrl3; - - ctrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); - ctrl3 = READ_VID32(SC1200_TVENC_TIM_CTRL_3); - ctrl2 &= ~(SC1200_TVENC_OUTPUT_YCBCR | SC1200_TVENC_CFS_MASK); - ctrl3 &= ~(SC1200_TVENC_CM | SC1200_TVENC_SYNCMODE_MASK | SC1200_TVENC_CS); - switch (output) { - case TV_OUTPUT_COMPOSITE: - /* Analog outputs provide Y, C and CVBS */ - /* Chrominance Lowpass filter is 1.3MHz (for composite video output) */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, ctrl2 | SC1200_TVENC_CFS_CVBS); - WRITE_VID32(SC1200_TVENC_TIM_CTRL_3, ctrl3); - break; - case TV_OUTPUT_S_VIDEO: - /* Analog outputs provide Y, C and CVBS */ - /* Chrominance Lowpass filter is 1.8MHz (for S-video output) */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, ctrl2 | SC1200_TVENC_CFS_SVIDEO); - WRITE_VID32(SC1200_TVENC_TIM_CTRL_3, ctrl3); - break; - case TV_OUTPUT_YUV: - /* Analog outputs provide Y, Cb and Cr */ - /* A 7.5 IRE setup is applied to the output */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, - ctrl2 | SC1200_TVENC_OUTPUT_YCBCR | - SC1200_TVENC_CFS_BYPASS); - WRITE_VID32(SC1200_TVENC_TIM_CTRL_3, - ctrl3 | SC1200_TVENC_CM | SC1200_TVENC_CS); - break; - case TV_OUTPUT_SCART: - /* Analog outputs provide SCART (RGB and CVBS) */ - /* Sync is added to green signal */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, ctrl2 | SC1200_TVENC_CFS_CVBS); - WRITE_VID32(SC1200_TVENC_TIM_CTRL_3, - ctrl3 | SC1200_TVENC_CM | SC1200_TVENC_SYNC_ON_GREEN); - break; - default: - return (GFX_STATUS_BAD_PARAMETER); - } - - /* Adjusts the internal voltage reference */ - ctrl2 = READ_VID32(SC1200_TVENC_DAC_CONTROL); - ctrl2 &= ~SC1200_TVENC_TRIM_MASK; - - /* Bypass for issue #926 : Inadequate chroma level of S-Video output */ - if ((gfx_chip_revision == SC1200_REV_B3) && (output == TV_OUTPUT_S_VIDEO)) - ctrl2 |= 0x7; - else - ctrl2 |= 0x5; - - WRITE_VID32(SC1200_TVENC_DAC_CONTROL, ctrl2); - - /* Disable 4:2:2 to 4:4:4 converter interpolation */ - WRITE_VID32(SC1200_TVOUT_DEBUG, SC1200_TVOUT_CONVERTER_INTERPOLATION); - - return (GFX_STATUS_OK); + unsigned long ctrl2, ctrl3; + + ctrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); + ctrl3 = READ_VID32(SC1200_TVENC_TIM_CTRL_3); + ctrl2 &= ~(SC1200_TVENC_OUTPUT_YCBCR | SC1200_TVENC_CFS_MASK); + ctrl3 &= ~(SC1200_TVENC_CM | SC1200_TVENC_SYNCMODE_MASK | SC1200_TVENC_CS); + switch (output) { + case TV_OUTPUT_COMPOSITE: + /* Analog outputs provide Y, C and CVBS */ + /* Chrominance Lowpass filter is 1.3MHz (for composite video output) */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, ctrl2 | SC1200_TVENC_CFS_CVBS); + WRITE_VID32(SC1200_TVENC_TIM_CTRL_3, ctrl3); + break; + case TV_OUTPUT_S_VIDEO: + /* Analog outputs provide Y, C and CVBS */ + /* Chrominance Lowpass filter is 1.8MHz (for S-video output) */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, ctrl2 | SC1200_TVENC_CFS_SVIDEO); + WRITE_VID32(SC1200_TVENC_TIM_CTRL_3, ctrl3); + break; + case TV_OUTPUT_YUV: + /* Analog outputs provide Y, Cb and Cr */ + /* A 7.5 IRE setup is applied to the output */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, + ctrl2 | SC1200_TVENC_OUTPUT_YCBCR | + SC1200_TVENC_CFS_BYPASS); + WRITE_VID32(SC1200_TVENC_TIM_CTRL_3, + ctrl3 | SC1200_TVENC_CM | SC1200_TVENC_CS); + break; + case TV_OUTPUT_SCART: + /* Analog outputs provide SCART (RGB and CVBS) */ + /* Sync is added to green signal */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, ctrl2 | SC1200_TVENC_CFS_CVBS); + WRITE_VID32(SC1200_TVENC_TIM_CTRL_3, + ctrl3 | SC1200_TVENC_CM | SC1200_TVENC_SYNC_ON_GREEN); + break; + default: + return (GFX_STATUS_BAD_PARAMETER); + } + + /* Adjusts the internal voltage reference */ + ctrl2 = READ_VID32(SC1200_TVENC_DAC_CONTROL); + ctrl2 &= ~SC1200_TVENC_TRIM_MASK; + + /* Bypass for issue #926 : Inadequate chroma level of S-Video output */ + if ((gfx_chip_revision == SC1200_REV_B3) && (output == TV_OUTPUT_S_VIDEO)) + ctrl2 |= 0x7; + else + ctrl2 |= 0x5; + + WRITE_VID32(SC1200_TVENC_DAC_CONTROL, ctrl2); + + /* Disable 4:2:2 to 4:4:4 converter interpolation */ + WRITE_VID32(SC1200_TVOUT_DEBUG, SC1200_TVOUT_CONVERTER_INTERPOLATION); + + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -472,26 +473,27 @@ int gfx_set_tv_enable(int enable) #endif { - unsigned long value_tim, value_dac; - - value_tim = READ_VID32(SC1200_TVENC_TIM_CTRL_1); - value_dac = READ_VID32(SC1200_TVENC_DAC_CONTROL); - - if (enable) { - value_tim |= SC1200_TVENC_VIDEO_TIMING_ENABLE; - value_dac &= ~SC1200_TVENC_POWER_DOWN; - /* ENABLE GRAPHICS DISPLAY LOGIC IN VIDEO PROCESSOR */ - gfx_set_screen_enable(1); - } else { - value_tim &= ~SC1200_TVENC_VIDEO_TIMING_ENABLE; - value_dac |= SC1200_TVENC_POWER_DOWN; - /* Do not disable the graphics display logic because it might be needed for CRT */ - } - - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, value_tim); - WRITE_VID32(SC1200_TVENC_DAC_CONTROL, value_dac); - - return (GFX_STATUS_OK); + unsigned long value_tim, value_dac; + + value_tim = READ_VID32(SC1200_TVENC_TIM_CTRL_1); + value_dac = READ_VID32(SC1200_TVENC_DAC_CONTROL); + + if (enable) { + value_tim |= SC1200_TVENC_VIDEO_TIMING_ENABLE; + value_dac &= ~SC1200_TVENC_POWER_DOWN; + /* ENABLE GRAPHICS DISPLAY LOGIC IN VIDEO PROCESSOR */ + gfx_set_screen_enable(1); + } + else { + value_tim &= ~SC1200_TVENC_VIDEO_TIMING_ENABLE; + value_dac |= SC1200_TVENC_POWER_DOWN; + /* Do not disable the graphics display logic because it might be needed for CRT */ + } + + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, value_tim); + WRITE_VID32(SC1200_TVENC_DAC_CONTROL, value_dac); + + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -508,27 +510,27 @@ int gfx_set_tv_flicker_filter(int ff) #endif { - unsigned long mode; - - mode = READ_VID32(SC1200_TVOUT_HORZ_SCALING); - mode &= ~SC1200_TVOUT_FLICKER_FILTER_MASK; - switch (ff) { - case TV_FLICKER_FILTER_NONE: - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, - mode | SC1200_TVOUT_FLICKER_FILTER_DISABLED); - break; - case TV_FLICKER_FILTER_NORMAL: - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, - mode | SC1200_TVOUT_FLICKER_FILTER_FOURTH_HALF_FOURTH); - break; - case TV_FLICKER_FILTER_INTERLACED: - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, - mode | SC1200_TVOUT_FLICKER_FILTER_HALF_ONE_HALF); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - return (GFX_STATUS_OK); + unsigned long mode; + + mode = READ_VID32(SC1200_TVOUT_HORZ_SCALING); + mode &= ~SC1200_TVOUT_FLICKER_FILTER_MASK; + switch (ff) { + case TV_FLICKER_FILTER_NONE: + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, + mode | SC1200_TVOUT_FLICKER_FILTER_DISABLED); + break; + case TV_FLICKER_FILTER_NORMAL: + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, + mode | SC1200_TVOUT_FLICKER_FILTER_FOURTH_HALF_FOURTH); + break; + case TV_FLICKER_FILTER_INTERLACED: + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, + mode | SC1200_TVOUT_FLICKER_FILTER_HALF_ONE_HALF); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -545,31 +547,31 @@ int gfx_set_tv_sub_carrier_reset(int screset) #endif { - unsigned long mode; - - mode = READ_VID32(SC1200_TVENC_TIM_CTRL_1); - mode &= ~SC1200_TVENC_SUB_CARRIER_RESET_MASK; - switch (screset) { - case TV_SUB_CARRIER_RESET_NEVER: - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, - mode | SC1200_TVENC_SUB_CARRIER_RESET_NEVER); - break; - case TV_SUB_CARRIER_RESET_EVERY_TWO_LINES: - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, - mode | SC1200_TVENC_SUB_CARRIER_RESET_EVERY_TWO_LINES); - break; - case TV_SUB_CARRIER_RESET_EVERY_TWO_FRAMES: - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, - mode | SC1200_TVENC_SUB_CARRIER_RESET_EVERY_TWO_FRAMES); - break; - case TV_SUB_CARRIER_RESET_EVERY_FOUR_FRAMES: - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, - mode | SC1200_TVENC_SUB_CARRIER_RESET_EVERY_FOUR_FRAMES); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - return (GFX_STATUS_OK); + unsigned long mode; + + mode = READ_VID32(SC1200_TVENC_TIM_CTRL_1); + mode &= ~SC1200_TVENC_SUB_CARRIER_RESET_MASK; + switch (screset) { + case TV_SUB_CARRIER_RESET_NEVER: + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, + mode | SC1200_TVENC_SUB_CARRIER_RESET_NEVER); + break; + case TV_SUB_CARRIER_RESET_EVERY_TWO_LINES: + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, + mode | SC1200_TVENC_SUB_CARRIER_RESET_EVERY_TWO_LINES); + break; + case TV_SUB_CARRIER_RESET_EVERY_TWO_FRAMES: + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, + mode | SC1200_TVENC_SUB_CARRIER_RESET_EVERY_TWO_FRAMES); + break; + case TV_SUB_CARRIER_RESET_EVERY_FOUR_FRAMES: + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, + mode | SC1200_TVENC_SUB_CARRIER_RESET_EVERY_FOUR_FRAMES); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -586,12 +588,12 @@ int gfx_set_tv_vphase(int vphase) #endif { - unsigned long mode = READ_VID32(SC1200_TVENC_TIM_CTRL_1); + unsigned long mode = READ_VID32(SC1200_TVENC_TIM_CTRL_1); - mode &= ~SC1200_TVENC_VPHASE_MASK; - mode |= (vphase << SC1200_TVENC_VPHASE_POS) & SC1200_TVENC_VPHASE_MASK; - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, mode); - return (GFX_STATUS_OK); + mode &= ~SC1200_TVENC_VPHASE_MASK; + mode |= (vphase << SC1200_TVENC_VPHASE_POS) & SC1200_TVENC_VPHASE_MASK; + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, mode); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -608,35 +610,35 @@ int gfx_set_tv_YC_delay(int delay) #endif { - unsigned long mode; - - /* This feature is implemented in Rev C1 */ - if (gfx_chip_revision < SC1200_REV_C1) - return (GFX_STATUS_OK); - - mode = READ_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE); - mode &= ~SC1200_TVOUT_YC_DELAY_MASK; - switch (delay) { - case TV_YC_DELAY_NONE: - WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, - mode | SC1200_TVOUT_YC_DELAY_NONE); - break; - case TV_Y_DELAY_ONE_PIXEL: - WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, - mode | SC1200_TVOUT_Y_DELAY_ONE_PIXEL); - break; - case TV_C_DELAY_ONE_PIXEL: - WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, - mode | SC1200_TVOUT_C_DELAY_ONE_PIXEL); - break; - case TV_C_DELAY_TWO_PIXELS: - WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, - mode | SC1200_TVOUT_C_DELAY_TWO_PIXELS); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - return (GFX_STATUS_OK); + unsigned long mode; + + /* This feature is implemented in Rev C1 */ + if (gfx_chip_revision < SC1200_REV_C1) + return (GFX_STATUS_OK); + + mode = READ_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE); + mode &= ~SC1200_TVOUT_YC_DELAY_MASK; + switch (delay) { + case TV_YC_DELAY_NONE: + WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, + mode | SC1200_TVOUT_YC_DELAY_NONE); + break; + case TV_Y_DELAY_ONE_PIXEL: + WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, + mode | SC1200_TVOUT_Y_DELAY_ONE_PIXEL); + break; + case TV_C_DELAY_ONE_PIXEL: + WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, + mode | SC1200_TVOUT_C_DELAY_ONE_PIXEL); + break; + case TV_C_DELAY_TWO_PIXELS: + WRITE_VID32(SC1200_TVOUT_HORZ_PRE_ENCODER_SCALE, + mode | SC1200_TVOUT_C_DELAY_TWO_PIXELS); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -654,38 +656,38 @@ int gfx_set_tvenc_reset_interval(int interval) #endif { - unsigned long value; - - value = READ_VID32(SC1200_TVOUT_HORZ_SCALING); - value &= ~SC1200_TVENC_EXTERNAL_RESET_INTERVAL_MASK; - switch (interval) { - case TVENC_RESET_EVERY_ODD_FIELD: - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, - value | SC1200_TVENC_EXTERNAL_RESET_EVERY_ODD_FIELD); - break; - case TVENC_RESET_EVERY_EVEN_FIELD: - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, - value | SC1200_TVENC_EXTERNAL_RESET_EVERY_EVEN_FIELD); - break; - case TVENC_RESET_NEXT_ODD_FIELD: - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, - value | SC1200_TVENC_EXTERNAL_RESET_NEXT_ODD_FIELD); - break; - case TVENC_RESET_NEXT_EVEN_FIELD: - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, - value | SC1200_TVENC_EXTERNAL_RESET_NEXT_EVEN_FIELD); - break; - case TVENC_RESET_EVERY_FIELD: - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, - value | SC1200_TVENC_EXTERNAL_RESET_EVERY_FIELD); - break; - case TVENC_RESET_EVERY_X_ODD_FIELDS: - case TVENC_RESET_EVERY_X_EVEN_FIELDS: - return GFX_STATUS_UNSUPPORTED; - default: - return GFX_STATUS_BAD_PARAMETER; - } - return (GFX_STATUS_OK); + unsigned long value; + + value = READ_VID32(SC1200_TVOUT_HORZ_SCALING); + value &= ~SC1200_TVENC_EXTERNAL_RESET_INTERVAL_MASK; + switch (interval) { + case TVENC_RESET_EVERY_ODD_FIELD: + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, + value | SC1200_TVENC_EXTERNAL_RESET_EVERY_ODD_FIELD); + break; + case TVENC_RESET_EVERY_EVEN_FIELD: + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, + value | SC1200_TVENC_EXTERNAL_RESET_EVERY_EVEN_FIELD); + break; + case TVENC_RESET_NEXT_ODD_FIELD: + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, + value | SC1200_TVENC_EXTERNAL_RESET_NEXT_ODD_FIELD); + break; + case TVENC_RESET_NEXT_EVEN_FIELD: + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, + value | SC1200_TVENC_EXTERNAL_RESET_NEXT_EVEN_FIELD); + break; + case TVENC_RESET_EVERY_FIELD: + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, + value | SC1200_TVENC_EXTERNAL_RESET_EVERY_FIELD); + break; + case TVENC_RESET_EVERY_X_ODD_FIELDS: + case TVENC_RESET_EVERY_X_EVEN_FIELDS: + return GFX_STATUS_UNSUPPORTED; + default: + return GFX_STATUS_BAD_PARAMETER; + } + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -703,14 +705,14 @@ int gfx_set_tv_cc_enable(int enable) #endif { - unsigned long value; - - value = READ_VID32(SC1200_TVENC_CC_CONTROL); - value &= ~(0x0005F); - if (enable) - value |= 0x51; - WRITE_VID32(SC1200_TVENC_CC_CONTROL, value); - return (0); + unsigned long value; + + value = READ_VID32(SC1200_TVENC_CC_CONTROL); + value &= ~(0x0005F); + if (enable) + value |= 0x51; + WRITE_VID32(SC1200_TVENC_CC_CONTROL, value); + return (0); } /*--------------------------------------------------------------------------- @@ -728,28 +730,28 @@ int gfx_set_tv_display(int width, int height) #endif { - DISPLAYMODE *pMode; - unsigned int i; - - for (i = 0; i < NUM_TV_MODES; i++) { - pMode = &TVTimings[i]; - if ((unsigned)width == pMode->hactive - && (unsigned)height == pMode->vactive) - break; - } - - if (i == NUM_TV_MODES) - return 0; - - gfx_set_display_timings(gfx_get_display_bpp(), - (unsigned short)pMode->flags, pMode->hactive, - pMode->hblankstart, pMode->hsyncstart, - pMode->hsyncend, pMode->hblankend, pMode->htotal, - pMode->vactive, pMode->vblankstart, - pMode->vsyncstart, pMode->vsyncend, - pMode->vblankend, pMode->vtotal, pMode->frequency); - - return 1; + DISPLAYMODE *pMode; + unsigned int i; + + for (i = 0; i < NUM_TV_MODES; i++) { + pMode = &TVTimings[i]; + if ((unsigned) width == pMode->hactive + && (unsigned) height == pMode->vactive) + break; + } + + if (i == NUM_TV_MODES) + return 0; + + gfx_set_display_timings(gfx_get_display_bpp(), + (unsigned short) pMode->flags, pMode->hactive, + pMode->hblankstart, pMode->hsyncstart, + pMode->hsyncend, pMode->hblankend, pMode->htotal, + pMode->vactive, pMode->vblankstart, + pMode->vsyncstart, pMode->vsyncend, + pMode->vblankend, pMode->vtotal, pMode->frequency); + + return 1; } /*----------------------------------------------------------------------------- @@ -761,18 +763,18 @@ gfx_set_tv_display(int width, int height) unsigned char cc_add_parity_bit(unsigned char data) { - int i, num = 0; - unsigned char d = data; - - for (i = 0; i < 7; i++) { - if (d & 0x1) - num++; - d >>= 1; - } - if (num & 0x1) - return (data & ~0x80); - else - return (data | 0x80); + int i, num = 0; + unsigned char d = data; + + for (i = 0; i < 7; i++) { + if (d & 0x1) + num++; + d >>= 1; + } + if (num & 0x1) + return (data & ~0x80); + else + return (data | 0x80); } /*----------------------------------------------------------------------------- @@ -790,11 +792,11 @@ int gfx_set_tv_cc_data(unsigned char data1, unsigned char data2) #endif { - unsigned long value; + unsigned long value; - value = cc_add_parity_bit(data1) | (cc_add_parity_bit(data2) << 8); - WRITE_VID32(SC1200_TVENC_CC_DATA, value); - return (0); + value = cc_add_parity_bit(data1) | (cc_add_parity_bit(data2) << 8); + WRITE_VID32(SC1200_TVENC_CC_DATA, value); + return (0); } /*--------------------------------------------------------------------------- @@ -811,13 +813,13 @@ int gfx_test_tvout_odd_field(void) #endif { - unsigned long debug = READ_VID32(SC1200_TVOUT_DEBUG); + unsigned long debug = READ_VID32(SC1200_TVOUT_DEBUG); - WRITE_VID32(SC1200_TVOUT_DEBUG, debug | SC1200_TVOUT_FIELD_STATUS_TV); - if (READ_VID32(SC1200_TVOUT_DEBUG) & SC1200_TVOUT_FIELD_STATUS_EVEN) - return (0); - else - return (1); + WRITE_VID32(SC1200_TVOUT_DEBUG, debug | SC1200_TVOUT_FIELD_STATUS_TV); + if (READ_VID32(SC1200_TVOUT_DEBUG) & SC1200_TVOUT_FIELD_STATUS_EVEN) + return (0); + else + return (1); } /*--------------------------------------------------------------------------- @@ -834,13 +836,13 @@ int gfx_test_tvenc_odd_field(void) #endif { - unsigned long debug = READ_VID32(SC1200_TVOUT_DEBUG); + unsigned long debug = READ_VID32(SC1200_TVOUT_DEBUG); - WRITE_VID32(SC1200_TVOUT_DEBUG, debug & ~SC1200_TVOUT_FIELD_STATUS_TV); - if (READ_VID32(SC1200_TVOUT_DEBUG) & SC1200_TVOUT_FIELD_STATUS_EVEN) - return (0); - else - return (1); + WRITE_VID32(SC1200_TVOUT_DEBUG, debug & ~SC1200_TVOUT_FIELD_STATUS_TV); + if (READ_VID32(SC1200_TVOUT_DEBUG) & SC1200_TVOUT_FIELD_STATUS_EVEN) + return (0); + else + return (1); } /*----------------------------------------------------------------------------- @@ -858,19 +860,20 @@ int gfx_set_tv_field_status_invert(int enable) #endif { - unsigned long value; + unsigned long value; - value = READ_VID32(SC1200_TVOUT_DEBUG); + value = READ_VID32(SC1200_TVOUT_DEBUG); - if (enable) { - value |= SC1200_TVOUT_FIELD_STATUS_INVERT; - } else { - value &= ~(SC1200_TVOUT_FIELD_STATUS_INVERT); - } + if (enable) { + value |= SC1200_TVOUT_FIELD_STATUS_INVERT; + } + else { + value &= ~(SC1200_TVOUT_FIELD_STATUS_INVERT); + } - WRITE_VID32(SC1200_TVOUT_DEBUG, value); + WRITE_VID32(SC1200_TVOUT_DEBUG, value); - return (GFX_STATUS_OK); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -887,9 +890,9 @@ int gfx_get_tv_vphase(void) #endif { - unsigned long mode = READ_VID32(SC1200_TVENC_TIM_CTRL_1); + unsigned long mode = READ_VID32(SC1200_TVENC_TIM_CTRL_1); - return (int)((mode & SC1200_TVENC_VPHASE_MASK) >> SC1200_TVENC_VPHASE_POS); + return (int) ((mode & SC1200_TVENC_VPHASE_MASK) >> SC1200_TVENC_VPHASE_POS); } /*--------------------------------------------------------------------------- @@ -906,11 +909,11 @@ int gfx_get_tv_enable(unsigned int *p_on) #endif { - unsigned long control = READ_VID32(SC1200_TVENC_DAC_CONTROL); + unsigned long control = READ_VID32(SC1200_TVENC_DAC_CONTROL); - *p_on = (unsigned int)(!(control & SC1200_TVENC_POWER_DOWN)); + *p_on = (unsigned int) (!(control & SC1200_TVENC_POWER_DOWN)); - return GFX_STATUS_OK; + return GFX_STATUS_OK; } /*--------------------------------------------------------------------------- @@ -928,24 +931,24 @@ int gfx_get_tv_output(void) #endif { - unsigned long ctrl2, ctrl3; - int format = 0; - - ctrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); - ctrl3 = READ_VID32(SC1200_TVENC_TIM_CTRL_3); - - if ((ctrl2 & SC1200_TVENC_CFS_MASK) == SC1200_TVENC_CFS_SVIDEO) - format = TV_OUTPUT_S_VIDEO; - else if (ctrl2 & SC1200_TVENC_OUTPUT_YCBCR) - format = TV_OUTPUT_YUV; - else if ((ctrl2 & SC1200_TVENC_CFS_MASK) == SC1200_TVENC_CFS_CVBS) { - if (ctrl3 & SC1200_TVENC_CM) - format = TV_OUTPUT_SCART; - else - format = TV_OUTPUT_COMPOSITE; - } - - return format; + unsigned long ctrl2, ctrl3; + int format = 0; + + ctrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); + ctrl3 = READ_VID32(SC1200_TVENC_TIM_CTRL_3); + + if ((ctrl2 & SC1200_TVENC_CFS_MASK) == SC1200_TVENC_CFS_SVIDEO) + format = TV_OUTPUT_S_VIDEO; + else if (ctrl2 & SC1200_TVENC_OUTPUT_YCBCR) + format = TV_OUTPUT_YUV; + else if ((ctrl2 & SC1200_TVENC_CFS_MASK) == SC1200_TVENC_CFS_CVBS) { + if (ctrl3 & SC1200_TVENC_CM) + format = TV_OUTPUT_SCART; + else + format = TV_OUTPUT_COMPOSITE; + } + + return format; } /*--------------------------------------------------------------------------- @@ -962,26 +965,26 @@ int gfx_get_tv_mode_count(TVStandardType format) #endif { - unsigned int mode, count = 0; - unsigned long flag; - - switch (format) { - case TV_STANDARD_NTSC: - flag = GFX_MODE_TV_NTSC; - break; - case TV_STANDARD_PAL: - flag = GFX_MODE_TV_PAL; - break; - default: - return 0; - } - - for (mode = 0; mode < NUM_TV_MODES; mode++) { - if (TVTimings[mode].flags & flag) - count++; - } - - return count; + unsigned int mode, count = 0; + unsigned long flag; + + switch (format) { + case TV_STANDARD_NTSC: + flag = GFX_MODE_TV_NTSC; + break; + case TV_STANDARD_PAL: + flag = GFX_MODE_TV_PAL; + break; + default: + return 0; + } + + for (mode = 0; mode < NUM_TV_MODES; mode++) { + if (TVTimings[mode].flags & flag) + count++; + } + + return count; } /*--------------------------------------------------------------------------- @@ -998,31 +1001,31 @@ int gfx_get_tv_display_mode(int *width, int *height, int *bpp, int *hz) #endif { - unsigned long frequency; - unsigned long mode, flags; - - *width = gfx_get_hactive(); - *height = gfx_get_vactive(); - *bpp = gfx_get_display_bpp(); - frequency = gfx_get_clock_frequency(); - - for (mode = 0; mode < NUM_TV_MODES; mode++) { - if (TVTimings[mode].hactive == (unsigned short)(*width) && - TVTimings[mode].vactive == (unsigned short)(*height) && - TVTimings[mode].frequency == frequency) { - flags = TVTimings[mode].flags; - - if (flags & GFX_MODE_TV_NTSC) - *hz = 60; - else if (flags & GFX_MODE_TV_PAL) - *hz = 50; - else - *hz = 0; - return (1); - } - } - - return -1; + unsigned long frequency; + unsigned long mode, flags; + + *width = gfx_get_hactive(); + *height = gfx_get_vactive(); + *bpp = gfx_get_display_bpp(); + frequency = gfx_get_clock_frequency(); + + for (mode = 0; mode < NUM_TV_MODES; mode++) { + if (TVTimings[mode].hactive == (unsigned short) (*width) && + TVTimings[mode].vactive == (unsigned short) (*height) && + TVTimings[mode].frequency == frequency) { + flags = TVTimings[mode].flags; + + if (flags & GFX_MODE_TV_NTSC) + *hz = 60; + else if (flags & GFX_MODE_TV_PAL) + *hz = 50; + else + *hz = 0; + return (1); + } + } + + return -1; } /*--------------------------------------------------------------------------- @@ -1034,39 +1037,39 @@ gfx_get_tv_display_mode(int *width, int *height, int *bpp, int *hz) #if GFX_TV_DYNAMIC int sc1200_get_tv_display_mode_frequency(unsigned short width, - unsigned short height, - TVStandardType format, int *frequency) + unsigned short height, + TVStandardType format, int *frequency) #else int gfx_get_tv_display_mode_frequency(unsigned short width, unsigned short height, - TVStandardType format, int *frequency) + TVStandardType format, int *frequency) #endif { - unsigned long mode, flag; - int retval = -1; - - *frequency = 0; - - switch (format) { - case TV_STANDARD_NTSC: - flag = GFX_MODE_TV_NTSC; - break; - case TV_STANDARD_PAL: - flag = GFX_MODE_TV_PAL; - break; - default: - return -1; - } - - for (mode = 0; mode < NUM_TV_MODES; mode++) { - if ((TVTimings[mode].hactive == width) && - (TVTimings[mode].vactive == height) && - (TVTimings[mode].flags & flag)) { - *frequency = TVTimings[mode].frequency; - retval = 1; - } - } - return retval; + unsigned long mode, flag; + int retval = -1; + + *frequency = 0; + + switch (format) { + case TV_STANDARD_NTSC: + flag = GFX_MODE_TV_NTSC; + break; + case TV_STANDARD_PAL: + flag = GFX_MODE_TV_PAL; + break; + default: + return -1; + } + + for (mode = 0; mode < NUM_TV_MODES; mode++) { + if ((TVTimings[mode].hactive == width) && + (TVTimings[mode].vactive == height) && + (TVTimings[mode].flags & flag)) { + *frequency = TVTimings[mode].frequency; + retval = 1; + } + } + return retval; } /*--------------------------------------------------------------------------- @@ -1078,36 +1081,36 @@ gfx_get_tv_display_mode_frequency(unsigned short width, unsigned short height, #if GFX_TV_DYNAMIC int sc1200_is_tv_display_mode_supported(unsigned short width, - unsigned short height, - TVStandardType format) + unsigned short height, + TVStandardType format) #else int gfx_is_tv_display_mode_supported(unsigned short width, unsigned short height, - TVStandardType format) + TVStandardType format) #endif { - unsigned long mode, flag; - - switch (format) { - case TV_STANDARD_NTSC: - flag = GFX_MODE_TV_NTSC; - break; - case TV_STANDARD_PAL: - flag = GFX_MODE_TV_PAL; - break; - default: - return -1; - } - - for (mode = 0; mode < NUM_TV_MODES; mode++) { - if (TVTimings[mode].hactive == width && - TVTimings[mode].vactive == height && - (TVTimings[mode].flags & flag)) { - return ((int)mode); - } - } - - return -1; + unsigned long mode, flag; + + switch (format) { + case TV_STANDARD_NTSC: + flag = GFX_MODE_TV_NTSC; + break; + case TV_STANDARD_PAL: + flag = GFX_MODE_TV_PAL; + break; + default: + return -1; + } + + for (mode = 0; mode < NUM_TV_MODES; mode++) { + if (TVTimings[mode].hactive == width && + TVTimings[mode].vactive == height && + (TVTimings[mode].flags & flag)) { + return ((int) mode); + } + } + + return -1; } /* END OF FILE */ diff --git a/src/gfx/tv_fs450.c b/src/gfx/tv_fs450.c index b14bc16..0fc52d2 100644 --- a/src/gfx/tv_fs450.c +++ b/src/gfx/tv_fs450.c @@ -161,24 +161,20 @@ #define WRITE 2 #define READ_WRITE (READ | WRITE) -typedef struct -{ - char *name; - unsigned long offset; - unsigned char bit_length; - unsigned char valid_bits; - unsigned char read_write; - char *bitfield_names[MAX_BITS]; -} -S_REGISTER_DESCRIP; - -typedef struct -{ - int source; - char *name; - S_REGISTER_DESCRIP registers[MAX_REGISTERS]; -} -S_SET_DESCRIP; +typedef struct { + char *name; + unsigned long offset; + unsigned char bit_length; + unsigned char valid_bits; + unsigned char read_write; + char *bitfield_names[MAX_BITS]; +} S_REGISTER_DESCRIP; + +typedef struct { + int source; + char *name; + S_REGISTER_DESCRIP registers[MAX_REGISTERS]; +} S_SET_DESCRIP; const S_SET_DESCRIP *houston_regs(void); const S_SET_DESCRIP *encoder_regs(void); @@ -192,26 +188,26 @@ const S_SET_DESCRIP *gcc_regs(void); *========================================================================== */ -#define HOUSTON_IHO 0x00 /*Input Horizontal Offset */ -#define HOUSTON_IVO 0x02 /*Input Vertical Offset */ -#define HOUSTON_IHA 0x04 /*Input Horizontal Active Width */ -#define HOUSTON_VSC 0x06 /*Vertical Scaling Coeficient */ -#define HOUSTON_HSC 0x08 /*Horizontal Scaling Coeficient */ -#define HOUSTON_BYP 0x0A /*Bypass Register */ -#define HOUSTON_CR 0x0C /*Control Register */ -#define HOUSTON_SP 0x0E /*Status */ -#define HOUSTON_NCONL 0x10 /*NCO numerator low word */ -#define HOUSTON_NCONH 0x12 /*NCO numerator high word */ -#define HOUSTON_NCODL 0x14 /*NCO denominator low word */ -#define HOUSTON_NCODH 0x16 /*NCO denominator high word */ +#define HOUSTON_IHO 0x00 /*Input Horizontal Offset */ +#define HOUSTON_IVO 0x02 /*Input Vertical Offset */ +#define HOUSTON_IHA 0x04 /*Input Horizontal Active Width */ +#define HOUSTON_VSC 0x06 /*Vertical Scaling Coeficient */ +#define HOUSTON_HSC 0x08 /*Horizontal Scaling Coeficient */ +#define HOUSTON_BYP 0x0A /*Bypass Register */ +#define HOUSTON_CR 0x0C /*Control Register */ +#define HOUSTON_SP 0x0E /*Status */ +#define HOUSTON_NCONL 0x10 /*NCO numerator low word */ +#define HOUSTON_NCONH 0x12 /*NCO numerator high word */ +#define HOUSTON_NCODL 0x14 /*NCO denominator low word */ +#define HOUSTON_NCODH 0x16 /*NCO denominator high word */ #define HOUSTON_APO 0x18 /**/ #define HOUSTON_ALO 0x1A /**/ #define HOUSTON_AFO 0x1C /**/ #define HOUSTON_HSOUTWID 0x1E /**/ #define HOUSTON_HSOUTST 0x20 /**/ #define HOUSTON_HSOUTEND 0x22 /**/ -#define HOUSTON_SHP 0x24 /*Sharpness */ -#define HOUSTON_FLK 0x26 /*Flicker Filter */ +#define HOUSTON_SHP 0x24 /*Sharpness */ +#define HOUSTON_FLK 0x26 /*Flicker Filter */ #define HOUSTON_BCONTL 0x28 /**/ #define HOUSTON_BCONTH 0x2A /**/ #define HOUSTON_BDONE 0x2C /**/ @@ -375,18 +371,16 @@ const S_SET_DESCRIP *gcc_regs(void); /****/ /*// GCC timing structure.*/ /****/ - typedef struct _S_TIMING_SPECS -{ - int vga_width; - int vga_lines; - int tv_width; - int tv_lines; - int h_total; - int h_sync; - int v_total; - int v_sync; -} -S_TIMING_SPECS; + typedef struct _S_TIMING_SPECS { + int vga_width; + int vga_lines; + int tv_width; + int tv_lines; + int h_total; + int h_sync; + int v_total; + int v_sync; +} S_TIMING_SPECS; /****/ /*// Revision of Houston chip*/ @@ -424,15 +418,15 @@ static int PLAL_FinalEnableTVout(unsigned long vga_mode); static int DMAL_ReadUInt32(unsigned long phys_addr, unsigned long *p_data) { - *p_data = READ_REG32(phys_addr); - return 0; + *p_data = READ_REG32(phys_addr); + return 0; } static int DMAL_WriteUInt32(unsigned long phys_addr, unsigned long data) { - WRITE_REG32(phys_addr, data); - return 0; + WRITE_REG32(phys_addr, data); + return 0; } /****/ @@ -441,15 +435,15 @@ DMAL_WriteUInt32(unsigned long phys_addr, unsigned long data) static int houston_ReadReg(unsigned int reg, unsigned long *p_value, unsigned int bytes) { - return gfx_i2c_read(1, PLAL_FS450_i2c_address(), (unsigned char)reg, - (unsigned char)bytes, (unsigned char *)p_value); + return gfx_i2c_read(1, PLAL_FS450_i2c_address(), (unsigned char) reg, + (unsigned char) bytes, (unsigned char *) p_value); } static int houston_WriteReg(unsigned int reg, unsigned long value, unsigned int bytes) { - return gfx_i2c_write(1, PLAL_FS450_i2c_address(), (unsigned char)reg, - (unsigned char)bytes, (unsigned char *)&value); + return gfx_i2c_write(1, PLAL_FS450_i2c_address(), (unsigned char) reg, + (unsigned char) bytes, (unsigned char *) &value); } /****/ @@ -465,8 +459,8 @@ static unsigned long supported_standards(void); static void config_tvout_mode(unsigned long tvout_mode); static void conget_tvout_mode(unsigned long *p_tvout_mode); static void config_overscan_xy(unsigned long tv_std, unsigned long vga_mode, - int overscan_x, int overscan_y, int pos_x, - int pos_y); + int overscan_x, int overscan_y, int pos_x, + int pos_y); static void config_nco(unsigned long tv_std, unsigned long vga_mode); static void config_sharpness(int sharpness); static void conget_sharpness(int *p_sharpness); @@ -475,42 +469,40 @@ static void conget_flicker(int *p_flicker); static void config_color(int color); static void conget_color(int *p_color); static void config_brightness_contrast(unsigned long tv_std, - unsigned int trigger_bits, - int brightness, int contrast); + unsigned int trigger_bits, + int brightness, int contrast); static void conget_brightness_contrast(unsigned long tv_std, - unsigned int trigger_bits, - int *p_brightness, int *p_contrast); + unsigned int trigger_bits, + int *p_brightness, int *p_contrast); static void config_yc_filter(unsigned long tv_std, int luma_filter, - int chroma_filter); + int chroma_filter); static void conget_yc_filter(int *p_luma_filter, int *p_chroma_filter); static void config_macrovision(unsigned long tv_std, - unsigned int cp_trigger_bits); + unsigned int cp_trigger_bits); static void conget_macrovision(unsigned long tv_std, - unsigned int *p_cp_trigger_bits); + unsigned int *p_cp_trigger_bits); /****/ /*Device settings.*/ /****/ -typedef struct _S_DEVICE_SETTINGS -{ - int tv_on; - unsigned long vga_mode; - unsigned long tv_std; - unsigned long tvout_mode; - int overscan_x; - int overscan_y; - int position_x; - int position_y; - int sharpness; - int flicker; - int color; - int brightness; - int contrast; - unsigned char yc_filter; - unsigned int aps_trigger_bits; - int last_overscan_y; -} -S_DEVICE_SETTINGS; +typedef struct _S_DEVICE_SETTINGS { + int tv_on; + unsigned long vga_mode; + unsigned long tv_std; + unsigned long tvout_mode; + int overscan_x; + int overscan_y; + int position_x; + int position_y; + int sharpness; + int flicker; + int color; + int brightness; + int contrast; + unsigned char yc_filter; + unsigned int aps_trigger_bits; + int last_overscan_y; +} S_DEVICE_SETTINGS; static S_DEVICE_SETTINGS d; @@ -520,434 +512,428 @@ static S_DEVICE_SETTINGS d; /****/ /*//==========================================================================*/ -static const struct -{ - unsigned long chroma_freq[5]; - unsigned short chroma_phase[5]; - unsigned short cphase_rst[5]; - unsigned short color[5]; - unsigned short cr_burst_level[5]; - unsigned short cb_burst_level[5]; - unsigned short sys625_50[5]; - unsigned short vsync5[5]; - unsigned short pal_mode[5]; - unsigned short hsync_width[5]; - unsigned short burst_width[5]; - unsigned short back_porch[5]; - unsigned short front_porch[5]; - unsigned short breeze_way[5]; - unsigned short activeline[5]; - unsigned short blank_level[5]; - unsigned short vbi_blank_level[5]; - unsigned short black_level[5]; - unsigned short white_level[5]; - unsigned short hamp_offset[5]; - unsigned short sync_level[5]; - unsigned short tv_lines[5]; - unsigned short tv_width[5]; - unsigned short tv_active_lines[5]; - unsigned short tv_active_width[5]; - unsigned char notch_filter[5]; - unsigned short houston_cr[5]; - unsigned short houston_ncodl[5]; - unsigned short houston_ncodh[5]; -} -tvsetup = -{ - /* ntsc, pal, ntsc-eij, pal-m, pal-n */ - { - 0x1f7cf021, 0xcb8a092a, 0x1f7cf021, 0xe3efe621, 0xcb8a092a} - , /*chroma_freq */ - { - 0, 0, 0, 0, 0} - , /*chroma_phase */ - { - 2, 0, 2, 0, 0} - , /*cphase_rst */ - { - 54, 43, 54, 43, 43} - , /*color */ - { - 0, 31, 0, 29, 29} - , /*cr_burst_level */ - { - 59, 44, 59, 41, 41} - , /*cb_burst_level */ - { - 0, 1, 0, 0, 1} - , /*sys625_50 */ - { - 0, 1, 0, 0, 0} - , /*vsync5 */ - { - 0, 1, 0, 1, 1} - , /*pal_mode */ - { - 0x7a, 0x7a, 0x7a, 0x7a, 0x7a} - , /*hsync_width */ - { - 0x40, 0x3c, 0x40, 0x40, 0x3c} - , /*burst_width */ - { - 0x80, 0x9a, 0x80, 0x80, 0x9a} - , /*back_porch */ - { - 0x24, 0x1e, 0x24, 0x24, 0x1e} - , /*front_porch */ - { - 0x19, 0x1a, 0x19, 0x12, 0x1a} - , /*breeze_way */ - { - 0xb4, 0xb4, 0xb4, 0xb4, 0xb4} - , /*active_line */ - { - 240, 251, 240, 240, 240} - , /*blank_level */ - { - 240, 251, 240, 240, 240} - , /*vbi_blank_level */ - { - 284, 252, 240, 252, 252} - , /*black_level */ - { - 823, 821, 823, 821, 821} - , /*white_level */ - { - 60, 48, 60, 48, 48} - , /*hamp_offset */ - { - 0x08, 0x08, 0x08, 0x08, 0x08} - , /*sync_level */ - { - 525, 625, 525, 525, 625} - , /*tv_lines */ - { - 858, 864, 858, 858, 864} - , /*tv_width */ - { - 487, 576, 487, 487, 576} - , /*tv_active_lines */ - { - 800, 800, 800, 800, 800} - , /*tv_active_width */ - { - 0x1a, 0x1d, 0x1a, 0x1d, 0x1d} - , /*notch filter enabled */ - { - 0x0000, 0x0100, 0x0000, 0x0000, 0x0100} - , /*houston cr pal */ - { - 0x7e48, 0xf580, 0x7e48, 0x7e48, 0xf580} - , /*houston ncodl */ - { - 0x001b, 0x0020, 0x001b, 0x001b, 0x0020} /*houston ncodh */ +static const struct { + unsigned long chroma_freq[5]; + unsigned short chroma_phase[5]; + unsigned short cphase_rst[5]; + unsigned short color[5]; + unsigned short cr_burst_level[5]; + unsigned short cb_burst_level[5]; + unsigned short sys625_50[5]; + unsigned short vsync5[5]; + unsigned short pal_mode[5]; + unsigned short hsync_width[5]; + unsigned short burst_width[5]; + unsigned short back_porch[5]; + unsigned short front_porch[5]; + unsigned short breeze_way[5]; + unsigned short activeline[5]; + unsigned short blank_level[5]; + unsigned short vbi_blank_level[5]; + unsigned short black_level[5]; + unsigned short white_level[5]; + unsigned short hamp_offset[5]; + unsigned short sync_level[5]; + unsigned short tv_lines[5]; + unsigned short tv_width[5]; + unsigned short tv_active_lines[5]; + unsigned short tv_active_width[5]; + unsigned char notch_filter[5]; + unsigned short houston_cr[5]; + unsigned short houston_ncodl[5]; + unsigned short houston_ncodh[5]; +} tvsetup = { + /* ntsc, pal, ntsc-eij, pal-m, pal-n */ + { + 0x1f7cf021, 0xcb8a092a, 0x1f7cf021, 0xe3efe621, 0xcb8a092a} + , /*chroma_freq */ + { + 0, 0, 0, 0, 0} + , /*chroma_phase */ + { + 2, 0, 2, 0, 0} + , /*cphase_rst */ + { + 54, 43, 54, 43, 43} + , /*color */ + { + 0, 31, 0, 29, 29} + , /*cr_burst_level */ + { + 59, 44, 59, 41, 41} + , /*cb_burst_level */ + { + 0, 1, 0, 0, 1} + , /*sys625_50 */ + { + 0, 1, 0, 0, 0} + , /*vsync5 */ + { + 0, 1, 0, 1, 1} + , /*pal_mode */ + { + 0x7a, 0x7a, 0x7a, 0x7a, 0x7a} + , /*hsync_width */ + { + 0x40, 0x3c, 0x40, 0x40, 0x3c} + , /*burst_width */ + { + 0x80, 0x9a, 0x80, 0x80, 0x9a} + , /*back_porch */ + { + 0x24, 0x1e, 0x24, 0x24, 0x1e} + , /*front_porch */ + { + 0x19, 0x1a, 0x19, 0x12, 0x1a} + , /*breeze_way */ + { + 0xb4, 0xb4, 0xb4, 0xb4, 0xb4} + , /*active_line */ + { + 240, 251, 240, 240, 240} + , /*blank_level */ + { + 240, 251, 240, 240, 240} + , /*vbi_blank_level */ + { + 284, 252, 240, 252, 252} + , /*black_level */ + { + 823, 821, 823, 821, 821} + , /*white_level */ + { + 60, 48, 60, 48, 48} + , /*hamp_offset */ + { + 0x08, 0x08, 0x08, 0x08, 0x08} + , /*sync_level */ + { + 525, 625, 525, 525, 625} + , /*tv_lines */ + { + 858, 864, 858, 858, 864} + , /*tv_width */ + { + 487, 576, 487, 487, 576} + , /*tv_active_lines */ + { + 800, 800, 800, 800, 800} + , /*tv_active_width */ + { + 0x1a, 0x1d, 0x1a, 0x1d, 0x1d} + , /*notch filter enabled */ + { + 0x0000, 0x0100, 0x0000, 0x0000, 0x0100} + , /*houston cr pal */ + { + 0x7e48, 0xf580, 0x7e48, 0x7e48, 0xf580} + , /*houston ncodl */ + { + 0x001b, 0x0020, 0x001b, 0x001b, 0x0020} /*houston ncodh */ }; /****/ /*MediaGX default underscan and centered position setups.*/ /****/ #define SCANTABLE_ENTRIES 5 -struct _scantable -{ - unsigned long mode; - unsigned short v_total[5]; - unsigned short v_sync[5]; - unsigned short iha[5]; - signed short iho[5]; - signed short hsc[5]; +struct _scantable { + unsigned long mode; + unsigned short v_total[5]; + unsigned short v_sync[5]; + unsigned short iha[5]; + signed short iho[5]; + signed short hsc[5]; }; static struct _scantable scantable[SCANTABLE_ENTRIES] = { - { - GFX_VGA_MODE_640X480, - {617, 624, 617, 624, 624}, /*v_total */ - {69, 88, 69, 88, 88}, /*v_sync */ - {720, 720, 720, 720, 720}, /*iha */ - {0, 0, 0, 0, 0}, /*iho */ - {-12, 0, -6, 0, 0} /*hsc */ - }, - { - GFX_VGA_MODE_800X600, - {740, 740, 740, 740, 740}, /*v_total */ - {90, 88, 90, 88, 88}, /*v_sync */ - {720, 720, 508, 720, 720}, /*iha */ - {-8, 11, -8, -8, 11}, /*iho */ - {-27, -27, -27, -27, -27} /*hsc */ - }, - { - GFX_VGA_MODE_720X487, - {525, 720, 525, 720, 720}, /*v_total */ - {23, 230, 23, 230, 230}, /*v_sync */ - {720, 720, 720, 720, 720}, /*iha */ - {0xa2, 0xa2, 0xa2, 0xa2, 0xa2}, /*iho */ - {0, 0, 0, 0, 0} /*hsc */ - }, - { - GFX_VGA_MODE_720X576, - {720, 625, 720, 625, 625}, /*v_total */ - {129, 25, 129, 25, 25}, /*v_sync */ - {720, 720, 720, 720, 720}, /*iha */ - {0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, /*iho */ - {0, 0, 0, 0, 0} /*hsc */ - }, - { - GFX_VGA_MODE_1024X768, - {933, 942, 933, 806, 806}, /*v_total */ - {121, 112, 121, 88, 88}, /*v_sync */ - {600, 600, 600, 600, 600}, /*iha */ - {0x3c, 0x23, 0x3c, 0x65, 0x65}, /*iho */ - {35, 26, 35, 26, 26} /*hsc */ - }, + { + GFX_VGA_MODE_640X480, + {617, 624, 617, 624, 624}, /*v_total */ + {69, 88, 69, 88, 88}, /*v_sync */ + {720, 720, 720, 720, 720}, /*iha */ + {0, 0, 0, 0, 0}, /*iho */ + {-12, 0, -6, 0, 0} /*hsc */ + }, + { + GFX_VGA_MODE_800X600, + {740, 740, 740, 740, 740}, /*v_total */ + {90, 88, 90, 88, 88}, /*v_sync */ + {720, 720, 508, 720, 720}, /*iha */ + {-8, 11, -8, -8, 11}, /*iho */ + {-27, -27, -27, -27, -27} /*hsc */ + }, + { + GFX_VGA_MODE_720X487, + {525, 720, 525, 720, 720}, /*v_total */ + {23, 230, 23, 230, 230}, /*v_sync */ + {720, 720, 720, 720, 720}, /*iha */ + {0xa2, 0xa2, 0xa2, 0xa2, 0xa2}, /*iho */ + {0, 0, 0, 0, 0} /*hsc */ + }, + { + GFX_VGA_MODE_720X576, + {720, 625, 720, 625, 625}, /*v_total */ + {129, 25, 129, 25, 25}, /*v_sync */ + {720, 720, 720, 720, 720}, /*iha */ + {0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, /*iho */ + {0, 0, 0, 0, 0} /*hsc */ + }, + { + GFX_VGA_MODE_1024X768, + {933, 942, 933, 806, 806}, /*v_total */ + {121, 112, 121, 88, 88}, /*v_sync */ + {600, 600, 600, 600, 600}, /*iha */ + {0x3c, 0x23, 0x3c, 0x65, 0x65}, /*iho */ + {35, 26, 35, 26, 26} /*hsc */ + }, }; /****/ /*Houston fifo configuration constants.*/ /****/ -struct _ffolat -{ - int v_total; - unsigned short ffolat; +struct _ffolat { + int v_total; + unsigned short ffolat; }; -struct _ffolativo -{ - int v_total; - unsigned short ivo; - unsigned short ffolat; +struct _ffolativo { + int v_total; + unsigned short ivo; + unsigned short ffolat; }; /*h_total=832, ivo=40, tv_width=858, tv_lines=525, vga_lines=480*/ #define SIZE6X4NTSC 66 static struct _ffolat ffo6x4ntsc[SIZE6X4NTSC + 1] = { - {541, 0x40}, {545, 0x40}, {549, 0x40}, {553, 0x40}, - {557, 0x58}, {561, 0x40}, {565, 0x40}, {569, 0x40}, - {573, 0x48}, {577, 0x40}, {581, 0x40}, {585, 0x40}, - {589, 0x40}, {593, 0x48}, {597, 0x40}, {601, 0x40}, - {605, 0x40}, {609, 0x40}, {613, 0x5b}, {617, 0x48}, - {621, 0x60}, {625, 0x48}, {629, 0x48}, {633, 0x40}, - {637, 0x5e}, {641, 0x40}, {645, 0x50}, {649, 0x56}, - {653, 0x58}, {657, 0x6c}, {661, 0x40}, {665, 0x40}, - {669, 0x40}, {673, 0x40}, {677, 0x40}, {681, 0x40}, - {685, 0x40}, {689, 0x40}, {693, 0x40}, {697, 0x40}, - {701, 0x40}, {705, 0x40}, {709, 0x40}, {713, 0x40}, - {717, 0x40}, {721, 0x40}, {725, 0x40}, {729, 0x40}, - {733, 0x40}, {737, 0x40}, {741, 0x40}, {745, 0x40}, - {749, 0x40}, {753, 0x40}, {757, 0x40}, {761, 0x40}, - {765, 0x40}, {769, 0x40}, {773, 0x40}, {777, 0x40}, - {781, 0x40}, {785, 0x40}, {789, 0x40}, {793, 0x40}, - {797, 0x30}, {801, 0x40}, - {-1, 0} + {541, 0x40}, {545, 0x40}, {549, 0x40}, {553, 0x40}, + {557, 0x58}, {561, 0x40}, {565, 0x40}, {569, 0x40}, + {573, 0x48}, {577, 0x40}, {581, 0x40}, {585, 0x40}, + {589, 0x40}, {593, 0x48}, {597, 0x40}, {601, 0x40}, + {605, 0x40}, {609, 0x40}, {613, 0x5b}, {617, 0x48}, + {621, 0x60}, {625, 0x48}, {629, 0x48}, {633, 0x40}, + {637, 0x5e}, {641, 0x40}, {645, 0x50}, {649, 0x56}, + {653, 0x58}, {657, 0x6c}, {661, 0x40}, {665, 0x40}, + {669, 0x40}, {673, 0x40}, {677, 0x40}, {681, 0x40}, + {685, 0x40}, {689, 0x40}, {693, 0x40}, {697, 0x40}, + {701, 0x40}, {705, 0x40}, {709, 0x40}, {713, 0x40}, + {717, 0x40}, {721, 0x40}, {725, 0x40}, {729, 0x40}, + {733, 0x40}, {737, 0x40}, {741, 0x40}, {745, 0x40}, + {749, 0x40}, {753, 0x40}, {757, 0x40}, {761, 0x40}, + {765, 0x40}, {769, 0x40}, {773, 0x40}, {777, 0x40}, + {781, 0x40}, {785, 0x40}, {789, 0x40}, {793, 0x40}, + {797, 0x30}, {801, 0x40}, + {-1, 0} }; #define SIZE6X4PAL 45 static struct _ffolat ffo6x4pal[SIZE6X4PAL + 1] = { - {625, 0x60}, {629, 0x60}, {633, 0x60}, {637, 0x60}, - {641, 0x50}, {645, 0x60}, {649, 0x60}, {653, 0x60}, - {657, 0x60}, {661, 0x60}, {665, 0x60}, {669, 0x60}, - {673, 0x60}, {677, 0x60}, {681, 0x60}, {685, 0x60}, - {689, 0x60}, {693, 0x60}, {697, 0x60}, {701, 0x60}, - {705, 0x60}, {709, 0x60}, {713, 0x60}, {717, 0x60}, - {721, 0x60}, {725, 0x60}, {729, 0x60}, {733, 0x60}, - {737, 0x60}, {741, 0x60}, {745, 0x60}, {749, 0x60}, - {753, 0x60}, {757, 0x60}, {761, 0x60}, {765, 0x60}, - {769, 0x60}, {773, 0x60}, {777, 0x60}, {781, 0x60}, - {785, 0x60}, {789, 0x60}, {793, 0x60}, {797, 0x60}, - {801, 0x60}, - {-1, 0} + {625, 0x60}, {629, 0x60}, {633, 0x60}, {637, 0x60}, + {641, 0x50}, {645, 0x60}, {649, 0x60}, {653, 0x60}, + {657, 0x60}, {661, 0x60}, {665, 0x60}, {669, 0x60}, + {673, 0x60}, {677, 0x60}, {681, 0x60}, {685, 0x60}, + {689, 0x60}, {693, 0x60}, {697, 0x60}, {701, 0x60}, + {705, 0x60}, {709, 0x60}, {713, 0x60}, {717, 0x60}, + {721, 0x60}, {725, 0x60}, {729, 0x60}, {733, 0x60}, + {737, 0x60}, {741, 0x60}, {745, 0x60}, {749, 0x60}, + {753, 0x60}, {757, 0x60}, {761, 0x60}, {765, 0x60}, + {769, 0x60}, {773, 0x60}, {777, 0x60}, {781, 0x60}, + {785, 0x60}, {789, 0x60}, {793, 0x60}, {797, 0x60}, + {801, 0x60}, + {-1, 0} }; #define SIZE7X4NTSC 40 static struct _ffolat ffo7x4ntsc[SIZE7X4NTSC + 1] = { - {525, 0x52}, {529, 0x52}, {533, 0x52}, {537, 0x52}, - {541, 0x52}, {545, 0x40}, {549, 0x40}, {553, 0x40}, - {557, 0x58}, {561, 0x40}, {565, 0x58}, {569, 0x40}, - {573, 0x48}, {577, 0x40}, {581, 0x40}, {585, 0x40}, - {589, 0x40}, {593, 0x48}, {597, 0x40}, {601, 0x40}, - {605, 0x40}, {609, 0x40}, {613, 0x5b}, {617, 0x48}, - {621, 0x60}, {625, 0x48}, {629, 0x48}, {633, 0x40}, - {637, 0x5e}, {641, 0x40}, {645, 0x50}, {649, 0x56}, - {653, 0x58}, {657, 0x6c}, {661, 0x40}, {665, 0x40}, - {669, 0x40}, {673, 0x40}, {677, 0x40}, {681, 0x40}, - {-1, 0} + {525, 0x52}, {529, 0x52}, {533, 0x52}, {537, 0x52}, + {541, 0x52}, {545, 0x40}, {549, 0x40}, {553, 0x40}, + {557, 0x58}, {561, 0x40}, {565, 0x58}, {569, 0x40}, + {573, 0x48}, {577, 0x40}, {581, 0x40}, {585, 0x40}, + {589, 0x40}, {593, 0x48}, {597, 0x40}, {601, 0x40}, + {605, 0x40}, {609, 0x40}, {613, 0x5b}, {617, 0x48}, + {621, 0x60}, {625, 0x48}, {629, 0x48}, {633, 0x40}, + {637, 0x5e}, {641, 0x40}, {645, 0x50}, {649, 0x56}, + {653, 0x58}, {657, 0x6c}, {661, 0x40}, {665, 0x40}, + {669, 0x40}, {673, 0x40}, {677, 0x40}, {681, 0x40}, + {-1, 0} }; #define SIZE7X4PAL 24 static struct _ffolat ffo7x4pal[SIZE7X4PAL + 1] = { - {625, 0x60}, {629, 0x60}, {633, 0x60}, {637, 0x60}, - {641, 0x50}, {645, 0x60}, {649, 0x60}, {653, 0x60}, - {657, 0x60}, {661, 0x60}, {665, 0x60}, {669, 0x60}, - {673, 0x60}, {677, 0x60}, {681, 0x60}, {685, 0x60}, - {689, 0x60}, {693, 0x60}, {697, 0x60}, {701, 0x60}, - {705, 0x60}, {709, 0x60}, {713, 0x60}, {717, 0x60}, - {-1, 0} + {625, 0x60}, {629, 0x60}, {633, 0x60}, {637, 0x60}, + {641, 0x50}, {645, 0x60}, {649, 0x60}, {653, 0x60}, + {657, 0x60}, {661, 0x60}, {665, 0x60}, {669, 0x60}, + {673, 0x60}, {677, 0x60}, {681, 0x60}, {685, 0x60}, + {689, 0x60}, {693, 0x60}, {697, 0x60}, {701, 0x60}, + {705, 0x60}, {709, 0x60}, {713, 0x60}, {717, 0x60}, + {-1, 0} }; #define SIZE7X5NTSC 54 static struct _ffolat ffo7x5ntsc[SIZE7X5NTSC + 1] = { - {590, 0x40}, {594, 0x48}, {598, 0x40}, {602, 0x40}, - {606, 0x40}, {610, 0x40}, {614, 0x5b}, {618, 0x48}, - {622, 0x60}, {626, 0x48}, {630, 0x48}, {634, 0x40}, - {638, 0x5e}, {642, 0x40}, {646, 0x50}, {650, 0x56}, - {654, 0x58}, {658, 0x6c}, {662, 0x40}, {666, 0x40}, - {670, 0x40}, {674, 0x40}, {678, 0x40}, {682, 0x40}, - {686, 0x40}, {690, 0x40}, {694, 0x40}, {698, 0x40}, - {702, 0x40}, {706, 0x40}, {710, 0x40}, {714, 0x40}, - {718, 0x40}, {722, 0x40}, {726, 0x40}, {730, 0x40}, - {734, 0x40}, {738, 0x40}, {742, 0x40}, {746, 0x40}, - {750, 0x40}, {754, 0x40}, {758, 0x40}, {762, 0x40}, - {766, 0x40}, {770, 0x40}, {774, 0x40}, {778, 0x40}, - {782, 0x40}, {786, 0x40}, {790, 0x40}, {794, 0x40}, - {798, 0x30}, {802, 0x40}, - {-1, 0} + {590, 0x40}, {594, 0x48}, {598, 0x40}, {602, 0x40}, + {606, 0x40}, {610, 0x40}, {614, 0x5b}, {618, 0x48}, + {622, 0x60}, {626, 0x48}, {630, 0x48}, {634, 0x40}, + {638, 0x5e}, {642, 0x40}, {646, 0x50}, {650, 0x56}, + {654, 0x58}, {658, 0x6c}, {662, 0x40}, {666, 0x40}, + {670, 0x40}, {674, 0x40}, {678, 0x40}, {682, 0x40}, + {686, 0x40}, {690, 0x40}, {694, 0x40}, {698, 0x40}, + {702, 0x40}, {706, 0x40}, {710, 0x40}, {714, 0x40}, + {718, 0x40}, {722, 0x40}, {726, 0x40}, {730, 0x40}, + {734, 0x40}, {738, 0x40}, {742, 0x40}, {746, 0x40}, + {750, 0x40}, {754, 0x40}, {758, 0x40}, {762, 0x40}, + {766, 0x40}, {770, 0x40}, {774, 0x40}, {778, 0x40}, + {782, 0x40}, {786, 0x40}, {790, 0x40}, {794, 0x40}, + {798, 0x30}, {802, 0x40}, + {-1, 0} }; #define SIZE7X5PAL 45 static struct _ffolat ffo7x5pal[SIZE7X5PAL + 1] = { - {625, 0x60}, {629, 0x60}, {633, 0x60}, {637, 0x60}, - {641, 0x50}, {645, 0x60}, {649, 0x60}, {653, 0x60}, - {657, 0x60}, {661, 0x60}, {665, 0x60}, {669, 0x60}, - {673, 0x60}, {677, 0x60}, {681, 0x60}, {685, 0x60}, - {689, 0x60}, {693, 0x60}, {697, 0x60}, {701, 0x60}, - {705, 0x60}, {709, 0x60}, {713, 0x60}, {717, 0x60}, - {721, 0x60}, {725, 0x60}, {729, 0x60}, {733, 0x60}, - {737, 0x60}, {741, 0x60}, {745, 0x60}, {749, 0x60}, - {753, 0x60}, {757, 0x60}, {761, 0x60}, {765, 0x60}, - {769, 0x60}, {773, 0x60}, {777, 0x60}, {781, 0x60}, - {785, 0x60}, {789, 0x60}, {793, 0x60}, {797, 0x60}, - {801, 0x60}, - {-1, 0} + {625, 0x60}, {629, 0x60}, {633, 0x60}, {637, 0x60}, + {641, 0x50}, {645, 0x60}, {649, 0x60}, {653, 0x60}, + {657, 0x60}, {661, 0x60}, {665, 0x60}, {669, 0x60}, + {673, 0x60}, {677, 0x60}, {681, 0x60}, {685, 0x60}, + {689, 0x60}, {693, 0x60}, {697, 0x60}, {701, 0x60}, + {705, 0x60}, {709, 0x60}, {713, 0x60}, {717, 0x60}, + {721, 0x60}, {725, 0x60}, {729, 0x60}, {733, 0x60}, + {737, 0x60}, {741, 0x60}, {745, 0x60}, {749, 0x60}, + {753, 0x60}, {757, 0x60}, {761, 0x60}, {765, 0x60}, + {769, 0x60}, {773, 0x60}, {777, 0x60}, {781, 0x60}, + {785, 0x60}, {789, 0x60}, {793, 0x60}, {797, 0x60}, + {801, 0x60}, + {-1, 0} }; /*h_total=1056, vga_lines=600*/ #define SIZE8X6NTSC 37 static struct _ffolat ffo8x6ntsc[SIZE8X6NTSC + 1] = { - {620, 0x40}, /*v_total_min >= vsync+10 >= vga_lines+10 = 610 */ - {625, 0x58}, {630, 0x40}, {635, 0x40}, {640, 0x40}, - {645, 0x46}, {650, 0x46}, {655, 0x4f}, {660, 0x4c}, - {665, 0x4a}, {670, 0x50}, {675, 0x2f}, {680, 0x48}, - {685, 0x38}, {690, 0x31}, {695, 0x40}, {700, 0x21}, - {705, 0x25}, {710, 0x40}, {715, 0x48}, {720, 0x50}, - {725, 0x30}, {730, 0x50}, {735, 0x50}, {740, 0x50}, - {745, 0x40}, {750, 0x38}, {755, 0x50}, {760, 0x50}, - {765, 0x40}, {770, 0x38}, {775, 0x40}, {780, 0x40}, - {785, 0x40}, {790, 0x38}, {795, 0x50}, {800, 0x50}, - {-1, 0} + {620, 0x40}, /*v_total_min >= vsync+10 >= vga_lines+10 = 610 */ + {625, 0x58}, {630, 0x40}, {635, 0x40}, {640, 0x40}, + {645, 0x46}, {650, 0x46}, {655, 0x4f}, {660, 0x4c}, + {665, 0x4a}, {670, 0x50}, {675, 0x2f}, {680, 0x48}, + {685, 0x38}, {690, 0x31}, {695, 0x40}, {700, 0x21}, + {705, 0x25}, {710, 0x40}, {715, 0x48}, {720, 0x50}, + {725, 0x30}, {730, 0x50}, {735, 0x50}, {740, 0x50}, + {745, 0x40}, {750, 0x38}, {755, 0x50}, {760, 0x50}, + {765, 0x40}, {770, 0x38}, {775, 0x40}, {780, 0x40}, + {785, 0x40}, {790, 0x38}, {795, 0x50}, {800, 0x50}, + {-1, 0} }; /*h_total=1056, vga_lines=600*/ #define SIZE8X6PAL 36 static struct _ffolat ffo8x6pal[SIZE8X6PAL + 1] = { - {625, 0x80}, {630, 0x80}, {635, 0x5a}, {640, 0x55}, - {645, 0x48}, {650, 0x65}, {655, 0x65}, {660, 0x50}, - {665, 0x80}, {670, 0x70}, {675, 0x56}, {680, 0x80}, - {685, 0x58}, {690, 0x31}, {695, 0x80}, {700, 0x60}, - {705, 0x45}, {710, 0x4a}, {715, 0x50}, {720, 0x50}, - {725, 0x50}, {730, 0x45}, {735, 0x50}, {740, 0x50}, - {745, 0x50}, {750, 0x50}, {755, 0x50}, {760, 0x50}, - {765, 0x50}, {770, 0x50}, {775, 0x50}, {780, 0x50}, - {785, 0x50}, {790, 0x50}, {795, 0x50}, {800, 0x50}, - {-1, 0} + {625, 0x80}, {630, 0x80}, {635, 0x5a}, {640, 0x55}, + {645, 0x48}, {650, 0x65}, {655, 0x65}, {660, 0x50}, + {665, 0x80}, {670, 0x70}, {675, 0x56}, {680, 0x80}, + {685, 0x58}, {690, 0x31}, {695, 0x80}, {700, 0x60}, + {705, 0x45}, {710, 0x4a}, {715, 0x50}, {720, 0x50}, + {725, 0x50}, {730, 0x45}, {735, 0x50}, {740, 0x50}, + {745, 0x50}, {750, 0x50}, {755, 0x50}, {760, 0x50}, + {765, 0x50}, {770, 0x50}, {775, 0x50}, {780, 0x50}, + {785, 0x50}, {790, 0x50}, {795, 0x50}, {800, 0x50}, + {-1, 0} }; /*h_total=1344, vga_lines=768*/ #define SIZE10X7NTSC 45 static struct _ffolativo ffo10x7ntsc[SIZE10X7NTSC] = { - {783, 0x4d, 0x40}, - {789, 0x47, 0x14}, - {795, 0x47, 0x7f}, - {801, 0x47, 0x53}, - {807, 0x47, 0x11}, - {813, 0x47, 0x78}, - {819, 0x47, 0x54}, - {825, 0x47, 0x40}, - {831, 0x47, 0x0f}, - {837, 0x4d, 0x40}, - {843, 0x47, 0x5a}, - {849, 0x4d, 0x40}, - {855, 0x47, 0x4b}, - {861, 0x4d, 0x40}, - {867, 0x47, 0x4b}, - {873, 0x4d, 0x40}, - {879, 0x47, 0x07}, - {885, 0x48, 0x20}, - {891, 0x47, 0x82}, - {897, 0x47, 0x60}, - {903, 0x47, 0x7f}, - {909, 0x4d, 0x40}, - {915, 0x48, 0x40}, - {921, 0x4c, 0x40}, - {927, 0x49, 0x40}, - {933, 0x48, 0x40}, - {939, 0x4a, 0x40}, - {945, 0x46, 0x40}, - {951, 0x4a, 0x40}, - {957, 0x4a, 0x40}, - {963, 0x4b, 0x40}, - {969, 0x4b, 0x40}, - {975, 0x48, 0x40}, - {981, 0x47, 0x40}, - {987, 0x47, 0x40}, - {993, 0x47, 0x40}, - {999, 0x48, 0x40}, - {1005, 0x48, 0x40}, - {1011, 0x47, 0x40}, - {1017, 0x47, 0x40}, - {1023, 0x48, 0x40}, - {1029, 0x48, 0x40}, - {1035, 0x46, 0x40}, - {1041, 0x47, 0x40}, - {1047, 0x47, 0x40} + {783, 0x4d, 0x40}, + {789, 0x47, 0x14}, + {795, 0x47, 0x7f}, + {801, 0x47, 0x53}, + {807, 0x47, 0x11}, + {813, 0x47, 0x78}, + {819, 0x47, 0x54}, + {825, 0x47, 0x40}, + {831, 0x47, 0x0f}, + {837, 0x4d, 0x40}, + {843, 0x47, 0x5a}, + {849, 0x4d, 0x40}, + {855, 0x47, 0x4b}, + {861, 0x4d, 0x40}, + {867, 0x47, 0x4b}, + {873, 0x4d, 0x40}, + {879, 0x47, 0x07}, + {885, 0x48, 0x20}, + {891, 0x47, 0x82}, + {897, 0x47, 0x60}, + {903, 0x47, 0x7f}, + {909, 0x4d, 0x40}, + {915, 0x48, 0x40}, + {921, 0x4c, 0x40}, + {927, 0x49, 0x40}, + {933, 0x48, 0x40}, + {939, 0x4a, 0x40}, + {945, 0x46, 0x40}, + {951, 0x4a, 0x40}, + {957, 0x4a, 0x40}, + {963, 0x4b, 0x40}, + {969, 0x4b, 0x40}, + {975, 0x48, 0x40}, + {981, 0x47, 0x40}, + {987, 0x47, 0x40}, + {993, 0x47, 0x40}, + {999, 0x48, 0x40}, + {1005, 0x48, 0x40}, + {1011, 0x47, 0x40}, + {1017, 0x47, 0x40}, + {1023, 0x48, 0x40}, + {1029, 0x48, 0x40}, + {1035, 0x46, 0x40}, + {1041, 0x47, 0x40}, + {1047, 0x47, 0x40} }; /*h_total=1344, vga_lines=768*/ #define SIZE10X7PAL 46 static struct _ffolativo ffo10x7pal[SIZE10X7PAL] = { - {781, 0x49, 0x40}, - {787, 0x46, 0x40}, - {793, 0x48, 0x40}, - {799, 0x46, 0x40}, - {805, 0x49, 0x40}, - {811, 0x47, 0x40}, - {817, 0x46, 0x40}, - {823, 0x46, 0x56}, - {829, 0x46, 0x2d}, - {835, 0x46, 0x40}, - {841, 0x46, 0x2d}, - {847, 0x46, 0x3f}, - {853, 0x46, 0x10}, - {859, 0x46, 0x86}, - {865, 0x46, 0xc9}, - {871, 0x46, 0x83}, - {877, 0x46, 0xa8}, - {883, 0x46, 0x81}, - {889, 0x46, 0xa5}, - {895, 0x46, 0xa9}, - {901, 0x46, 0x81}, - {907, 0x46, 0xa4}, - {913, 0x46, 0xa5}, - {919, 0x46, 0x7f}, - {925, 0x46, 0xa2}, - {931, 0x46, 0x9d}, - {937, 0x46, 0xc1}, - {943, 0x46, 0x96}, - {949, 0x46, 0xb7}, - {955, 0x46, 0xb1}, - {961, 0x46, 0x8a}, - {967, 0x46, 0xa9}, - {973, 0x46, 0xa0}, - {979, 0x46, 0x40}, - {985, 0x46, 0x97}, - {991, 0x46, 0xb5}, - {997, 0x46, 0xaa}, - {1003, 0x46, 0x83}, - {1009, 0x46, 0x9f}, - {1015, 0x47, 0x40}, - {1021, 0x46, 0xad}, - {1027, 0x46, 0x87}, - {1033, 0x46, 0xa2}, - {1039, 0x47, 0x40}, - {1045, 0x46, 0xac}, - {1051, 0x46, 0x86} + {781, 0x49, 0x40}, + {787, 0x46, 0x40}, + {793, 0x48, 0x40}, + {799, 0x46, 0x40}, + {805, 0x49, 0x40}, + {811, 0x47, 0x40}, + {817, 0x46, 0x40}, + {823, 0x46, 0x56}, + {829, 0x46, 0x2d}, + {835, 0x46, 0x40}, + {841, 0x46, 0x2d}, + {847, 0x46, 0x3f}, + {853, 0x46, 0x10}, + {859, 0x46, 0x86}, + {865, 0x46, 0xc9}, + {871, 0x46, 0x83}, + {877, 0x46, 0xa8}, + {883, 0x46, 0x81}, + {889, 0x46, 0xa5}, + {895, 0x46, 0xa9}, + {901, 0x46, 0x81}, + {907, 0x46, 0xa4}, + {913, 0x46, 0xa5}, + {919, 0x46, 0x7f}, + {925, 0x46, 0xa2}, + {931, 0x46, 0x9d}, + {937, 0x46, 0xc1}, + {943, 0x46, 0x96}, + {949, 0x46, 0xb7}, + {955, 0x46, 0xb1}, + {961, 0x46, 0x8a}, + {967, 0x46, 0xa9}, + {973, 0x46, 0xa0}, + {979, 0x46, 0x40}, + {985, 0x46, 0x97}, + {991, 0x46, 0xb5}, + {997, 0x46, 0xaa}, + {1003, 0x46, 0x83}, + {1009, 0x46, 0x9f}, + {1015, 0x47, 0x40}, + {1021, 0x46, 0xad}, + {1027, 0x46, 0x87}, + {1033, 0x46, 0xa2}, + {1039, 0x47, 0x40}, + {1045, 0x46, 0xac}, + {1051, 0x46, 0x86} }; /*//==========================================================================*/ @@ -962,133 +948,133 @@ static struct _ffolativo ffo10x7pal[SIZE10X7PAL] = { static void initialize_houston_static_registers(void) { - houston_WriteReg(HOUSTON_BYP, 0, 2); - houston_WriteReg(HOUSTON_APO, 0, 2); - houston_WriteReg(HOUSTON_ALO, 0, 2); - houston_WriteReg(HOUSTON_AFO, 0, 2); - houston_WriteReg(HOUSTON_BCONTL, 0, 2); - houston_WriteReg(HOUSTON_BCONTH, 0, 2); - houston_WriteReg(HOUSTON_BDONE, 0, 2); - houston_WriteReg(HOUSTON_BDIAGL, 0, 2); - houston_WriteReg(HOUSTON_BDIAGH, 0, 2); - houston_WriteReg(HOUSTON_MISC, 0, 2); + houston_WriteReg(HOUSTON_BYP, 0, 2); + houston_WriteReg(HOUSTON_APO, 0, 2); + houston_WriteReg(HOUSTON_ALO, 0, 2); + houston_WriteReg(HOUSTON_AFO, 0, 2); + houston_WriteReg(HOUSTON_BCONTL, 0, 2); + houston_WriteReg(HOUSTON_BCONTH, 0, 2); + houston_WriteReg(HOUSTON_BDONE, 0, 2); + houston_WriteReg(HOUSTON_BDIAGL, 0, 2); + houston_WriteReg(HOUSTON_BDIAGH, 0, 2); + houston_WriteReg(HOUSTON_MISC, 0, 2); } int FS450_init(void) { - int err; + int err; - TRACE(("FS450_Init()\n")) + TRACE(("FS450_Init()\n")) - err = houston_init(); - if (err) - return err; + err = houston_init(); + if (err) + return err; - initialize_houston_static_registers(); + initialize_houston_static_registers(); #if 1 - d.tv_on = PLAL_IsTVOn()? 1 : 0; + d.tv_on = PLAL_IsTVOn()? 1 : 0; #else - d.tv_on = 0; + d.tv_on = 0; #endif #if 1 - /*get the current tv standard */ - conget_tv_std(&d.tv_std); + /*get the current tv standard */ + conget_tv_std(&d.tv_std); #else - /*default to VP_TV_STANDARD_NTSC_M */ - d.tv_std = VP_TV_STANDARD_NTSC_M; - config_tv_std(d.tv_std); + /*default to VP_TV_STANDARD_NTSC_M */ + d.tv_std = VP_TV_STANDARD_NTSC_M; + config_tv_std(d.tv_std); #endif - d.vga_mode = 0; + d.vga_mode = 0; #if 0 - /*get the current tvout mode */ - conget_tvout_mode(&d.tvout_mode); + /*get the current tvout mode */ + conget_tvout_mode(&d.tvout_mode); #else - /*default to VP_TVOUT_MODE_CVBS_YC */ - d.tvout_mode = GFX_TVOUT_MODE_CVBS_YC; + /*default to VP_TVOUT_MODE_CVBS_YC */ + d.tvout_mode = GFX_TVOUT_MODE_CVBS_YC; #endif #if 0 - /*get the current sharpness */ - conget_sharpness(d.sharpness); + /*get the current sharpness */ + conget_sharpness(d.sharpness); #else - /*default to 1000 out of 1000 */ - d.sharpness = 1000; - config_sharpness(d.sharpness); + /*default to 1000 out of 1000 */ + d.sharpness = 1000; + config_sharpness(d.sharpness); #endif #if 0 - /*get the current flicker */ - conget_flicker(d.flicker); + /*get the current flicker */ + conget_flicker(d.flicker); #else - /*default to 800 out of 1000 */ - d.flicker = 800; - config_flicker(d.flicker); + /*default to 800 out of 1000 */ + d.flicker = 800; + config_flicker(d.flicker); #endif #if 0 - /*get the current size and position */ + /*get the current size and position */ #else - /*default to zeros */ - d.overscan_x = 0; - d.overscan_y = 0; - d.position_x = 0; - d.position_y = 0; + /*default to zeros */ + d.overscan_x = 0; + d.overscan_y = 0; + d.position_x = 0; + d.position_y = 0; #endif #if 0 - /*get the current color */ - conget_color(d.color); + /*get the current color */ + conget_color(d.color); #else - d.color = 50; - /*//d.color = tvsetup.color[k]; */ - config_color(d.color); + d.color = 50; + /*//d.color = tvsetup.color[k]; */ + config_color(d.color); #endif #if 0 - /*get the current brightness and contrast */ - conget_brightness_contrast(d.tv_std, d.aps_trigger_bits, d.brightness, - d.contrast); + /*get the current brightness and contrast */ + conget_brightness_contrast(d.tv_std, d.aps_trigger_bits, d.brightness, + d.contrast); #else - /*default */ - d.brightness = 50; - d.contrast = 60; - config_brightness_contrast(d.tv_std, d.aps_trigger_bits, d.brightness, - d.contrast); + /*default */ + d.brightness = 50; + d.contrast = 60; + config_brightness_contrast(d.tv_std, d.aps_trigger_bits, d.brightness, + d.contrast); #endif #if 1 - /*get the current yc filtering */ - { - int luma_filter, chroma_filter; - - conget_yc_filter(&luma_filter, &chroma_filter); - d.yc_filter = 0; - if (luma_filter) - d.yc_filter |= GFX_LUMA_FILTER; - if (chroma_filter) - d.yc_filter |= GFX_CHROMA_FILTER; - } + /*get the current yc filtering */ + { + int luma_filter, chroma_filter; + + conget_yc_filter(&luma_filter, &chroma_filter); + d.yc_filter = 0; + if (luma_filter) + d.yc_filter |= GFX_LUMA_FILTER; + if (chroma_filter) + d.yc_filter |= GFX_CHROMA_FILTER; + } #else - /*default */ - d.yc_filter = GFX_LUMA_FILTER + GFX_CHROMA_FILTER; + /*default */ + d.yc_filter = GFX_LUMA_FILTER + GFX_CHROMA_FILTER; #endif #if 0 - /*get the current cp settings */ - conget_macrovision(d.tv_std, &d.aps_trigger_bits); + /*get the current cp settings */ + conget_macrovision(d.tv_std, &d.aps_trigger_bits); #else - d.aps_trigger_bits = 0; - config_macrovision(d.tv_std, d.aps_trigger_bits); + d.aps_trigger_bits = 0; + config_macrovision(d.tv_std, d.aps_trigger_bits); #endif - d.last_overscan_y = -10000; + d.last_overscan_y = -10000; - return 0; + return 0; } void @@ -1128,73 +1114,73 @@ FS450_cleanup(void) static int write_config(int req) { - unsigned long reg, reg_encoder_reset = 0; - int reset; + unsigned long reg, reg_encoder_reset = 0; + int reset; - /*if we're changing the nco, and the vertical scaling has changed... */ - reset = ((REQ_NCO_BIT & req) && (d.overscan_y != d.last_overscan_y)); - if (reset) { - /*put the encoder into reset while making changes */ - houston_ReadReg(ENC_RESET, ®, 1); - houston_WriteReg(ENC_RESET, reg | 0x01, 1); - reg_encoder_reset = reg & 0x01; - } + /*if we're changing the nco, and the vertical scaling has changed... */ + reset = ((REQ_NCO_BIT & req) && (d.overscan_y != d.last_overscan_y)); + if (reset) { + /*put the encoder into reset while making changes */ + houston_ReadReg(ENC_RESET, ®, 1); + houston_WriteReg(ENC_RESET, reg | 0x01, 1); + reg_encoder_reset = reg & 0x01; + } - if (REQ_TV_STANDARD_BIT & req) - config_tv_std(d.tv_std, d.aps_trigger_bits); + if (REQ_TV_STANDARD_BIT & req) + config_tv_std(d.tv_std, d.aps_trigger_bits); - if (REQ_VGA_MODE_BIT & req) - config_vga_mode(d.vga_mode); + if (REQ_VGA_MODE_BIT & req) + config_vga_mode(d.vga_mode); - if (REQ_TVOUT_MODE_BIT & req) - config_tvout_mode(d.tvout_mode); + if (REQ_TVOUT_MODE_BIT & req) + config_tvout_mode(d.tvout_mode); - if (REQ_OVERSCAN_POSITION_BIT & req) { - config_overscan_xy(d.tv_std, - d.vga_mode, - d.overscan_x, - d.overscan_y, d.position_x, d.position_y); + if (REQ_OVERSCAN_POSITION_BIT & req) { + config_overscan_xy(d.tv_std, + d.vga_mode, + d.overscan_x, + d.overscan_y, d.position_x, d.position_y); - /*h_timing and v_timing and syncs. */ - if (PLAL_IsTVOn()) - PLAL_SetTVTimingRegisters(p_specs()); - } + /*h_timing and v_timing and syncs. */ + if (PLAL_IsTVOn()) + PLAL_SetTVTimingRegisters(p_specs()); + } - if (REQ_NCO_BIT & req) - config_nco(d.tv_std, d.vga_mode); + if (REQ_NCO_BIT & req) + config_nco(d.tv_std, d.vga_mode); - if (REQ_SHARPNESS_BIT & req) - config_sharpness(d.sharpness); + if (REQ_SHARPNESS_BIT & req) + config_sharpness(d.sharpness); - if (REQ_FLICKER_BIT & req) - config_flicker(d.flicker); + if (REQ_FLICKER_BIT & req) + config_flicker(d.flicker); - if (REQ_COLOR_BIT & req) - config_color(d.color); + if (REQ_COLOR_BIT & req) + config_color(d.color); - if (REQ_BRIGHTNESS_CONTRAST_BIT & req) { - config_brightness_contrast(d.tv_std, - d.aps_trigger_bits, - d.brightness, d.contrast); - } + if (REQ_BRIGHTNESS_CONTRAST_BIT & req) { + config_brightness_contrast(d.tv_std, + d.aps_trigger_bits, + d.brightness, d.contrast); + } - if (REQ_YC_FILTER_BIT & req) { - config_yc_filter(d.tv_std, - (d.yc_filter & GFX_LUMA_FILTER), - (d.yc_filter & GFX_CHROMA_FILTER)); - } + if (REQ_YC_FILTER_BIT & req) { + config_yc_filter(d.tv_std, + (d.yc_filter & GFX_LUMA_FILTER), + (d.yc_filter & GFX_CHROMA_FILTER)); + } - if (REQ_MACROVISION_BIT & req) - config_macrovision(d.tv_std, d.aps_trigger_bits); + if (REQ_MACROVISION_BIT & req) + config_macrovision(d.tv_std, d.aps_trigger_bits); - /*if we decided to put the encoder into reset, put it back */ - if (reset) { - houston_ReadReg(ENC_RESET, ®, 1); - houston_WriteReg(ENC_RESET, reg_encoder_reset | (reg & ~0x01), 1); + /*if we decided to put the encoder into reset, put it back */ + if (reset) { + houston_ReadReg(ENC_RESET, ®, 1); + houston_WriteReg(ENC_RESET, reg_encoder_reset | (reg & ~0x01), 1); - d.last_overscan_y = d.overscan_y; - } - return 0; + d.last_overscan_y = d.overscan_y; + } + return 0; } /*==========================================================================*/ @@ -1209,12 +1195,12 @@ int gfx_get_tv_enable(unsigned int *p_on) #endif { - if (!p_on) - return ERR_INVALID_PARAMETER; + if (!p_on) + return ERR_INVALID_PARAMETER; - *p_on = d.tv_on; + *p_on = d.tv_on; - return 0; + return 0; } /*//int FS450_set_tv_on(unsigned int on)*/ @@ -1226,75 +1212,75 @@ int gfx_set_tv_enable(int on) #endif { - unsigned long reg; + unsigned long reg; - /*if not mode change, just return */ - if ((d.tv_on && on) || (!d.tv_on && !on)) - return 0; + /*if not mode change, just return */ + if ((d.tv_on && on) || (!d.tv_on && !on)) + return 0; - /*if turning off... */ - if (!on) { - /*reenable vga. */ - PLAL_EnableVga(); + /*if turning off... */ + if (!on) { + /*reenable vga. */ + PLAL_EnableVga(); - /*power down houston */ - config_power(0); + /*power down houston */ + config_power(0); - d.tv_on = 0; + d.tv_on = 0; - return 0; - } + return 0; + } - /*turning on... */ + /*turning on... */ - /*power up houston */ - config_power(1); + /*power up houston */ + config_power(1); - /*assert encoder reset. */ - houston_WriteReg(ENC_RESET, 0x01, 1); + /*assert encoder reset. */ + houston_WriteReg(ENC_RESET, 0x01, 1); - /*initial platform preparation */ - PLAL_PrepForTVout(); + /*initial platform preparation */ + PLAL_PrepForTVout(); - /*configure encoder and nco. */ - write_config(REQ_VGA_MODE | - REQ_TV_STANDARD | - REQ_TVOUT_MODE | - REQ_OVERSCAN_POSITION | REQ_YC_FILTER | REQ_MACROVISION); + /*configure encoder and nco. */ + write_config(REQ_VGA_MODE | + REQ_TV_STANDARD | + REQ_TVOUT_MODE | + REQ_OVERSCAN_POSITION | REQ_YC_FILTER | REQ_MACROVISION); - /*set LP_EN and UIM */ - houston_ReadReg(HOUSTON_CR, ®, 2); - reg |= CR_LP_EN; - reg &= ~(CR_UIM_MOD0 | CR_UIM_MOD1); - reg |= (PLAL_FS450_UIM_mode() << 14); - houston_WriteReg(HOUSTON_CR, reg, 2); + /*set LP_EN and UIM */ + houston_ReadReg(HOUSTON_CR, ®, 2); + reg |= CR_LP_EN; + reg &= ~(CR_UIM_MOD0 | CR_UIM_MOD1); + reg |= (PLAL_FS450_UIM_mode() << 14); + houston_WriteReg(HOUSTON_CR, reg, 2); - /*set platform timing registers */ - PLAL_SetTVTimingRegisters(p_specs()); + /*set platform timing registers */ + PLAL_SetTVTimingRegisters(p_specs()); - PLAL_FinalEnableTVout(d.vga_mode); + PLAL_FinalEnableTVout(d.vga_mode); - /*sync bridge */ - { - int retry_count = 0; + /*sync bridge */ + { + int retry_count = 0; - /*sync 50 times */ - while (retry_count++ < 50) { - /*sync bridge. */ - houston_ReadReg(HOUSTON_MISC, ®, 2); - reg |= MISC_BRIDGE_SYNC; - houston_WriteReg(HOUSTON_MISC, reg, 2); - reg &= ~MISC_BRIDGE_SYNC; - houston_WriteReg(HOUSTON_MISC, reg, 2); - } - } + /*sync 50 times */ + while (retry_count++ < 50) { + /*sync bridge. */ + houston_ReadReg(HOUSTON_MISC, ®, 2); + reg |= MISC_BRIDGE_SYNC; + houston_WriteReg(HOUSTON_MISC, reg, 2); + reg &= ~MISC_BRIDGE_SYNC; + houston_WriteReg(HOUSTON_MISC, reg, 2); + } + } - /*deassert encoder reset. */ - houston_WriteReg(ENC_RESET, 0x00, 1); + /*deassert encoder reset. */ + houston_WriteReg(ENC_RESET, 0x00, 1); - d.tv_on = 1; + d.tv_on = 1; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1305,7 +1291,7 @@ int gfx_set_tv_defaults(int format) #endif { - return 0; + return 0; } /*==========================================================================*/ @@ -1320,12 +1306,12 @@ int gfx_get_tv_standard(unsigned long *p_standard) #endif { - if (!p_standard) - return ERR_INVALID_PARAMETER; + if (!p_standard) + return ERR_INVALID_PARAMETER; - *p_standard = d.tv_std; + *p_standard = d.tv_std; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1336,12 +1322,12 @@ int gfx_get_available_tv_standards(unsigned long *p_standards) #endif { - if (!p_standards) - return ERR_INVALID_PARAMETER; + if (!p_standards) + return ERR_INVALID_PARAMETER; - *p_standards = supported_standards(); + *p_standards = supported_standards(); - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1352,18 +1338,18 @@ int gfx_set_tv_standard(unsigned long standard) #endif { - /*verify supported standard. */ - if (!(standard & supported_standards())) - return ERR_INVALID_PARAMETER; + /*verify supported standard. */ + if (!(standard & supported_standards())) + return ERR_INVALID_PARAMETER; - /*disallow if tv is on */ - if (d.tv_on) - return ERR_CANNOT_CHANGE_WHILE_TV_ON; + /*disallow if tv is on */ + if (d.tv_on) + return ERR_CANNOT_CHANGE_WHILE_TV_ON; - d.tv_std = standard; + d.tv_std = standard; /*// d.color = tvsetup.color[k];*/ - return write_config(REQ_TV_STANDARD); + return write_config(REQ_TV_STANDARD); } /*==========================================================================*/ @@ -1377,12 +1363,12 @@ int gfx_get_tv_vga_mode(unsigned long *p_vga_mode) #endif { - if (!p_vga_mode) - return ERR_INVALID_PARAMETER; + if (!p_vga_mode) + return ERR_INVALID_PARAMETER; - *p_vga_mode = d.vga_mode; + *p_vga_mode = d.vga_mode; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1393,16 +1379,16 @@ int gfx_get_available_tv_vga_modes(unsigned long *p_vga_modes) #endif { - if (!p_vga_modes) - return ERR_INVALID_PARAMETER; + if (!p_vga_modes) + return ERR_INVALID_PARAMETER; - *p_vga_modes = - GFX_VGA_MODE_640X480 | - GFX_VGA_MODE_720X487 | GFX_VGA_MODE_720X576 | GFX_VGA_MODE_800X600; - if (houston_Rev() >= HOUSTON_REV_B) - *p_vga_modes |= GFX_VGA_MODE_1024X768; + *p_vga_modes = + GFX_VGA_MODE_640X480 | + GFX_VGA_MODE_720X487 | GFX_VGA_MODE_720X576 | GFX_VGA_MODE_800X600; + if (houston_Rev() >= HOUSTON_REV_B) + *p_vga_modes |= GFX_VGA_MODE_1024X768; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1413,31 +1399,31 @@ int gfx_set_tv_vga_mode(unsigned long vga_mode) #endif { - /*reject if not a single valid VGA mode */ - switch (vga_mode) { - default: - return ERR_INVALID_PARAMETER; + /*reject if not a single valid VGA mode */ + switch (vga_mode) { + default: + return ERR_INVALID_PARAMETER; - case GFX_VGA_MODE_640X480: - case GFX_VGA_MODE_720X487: - case GFX_VGA_MODE_720X576: - case GFX_VGA_MODE_800X600: - break; + case GFX_VGA_MODE_640X480: + case GFX_VGA_MODE_720X487: + case GFX_VGA_MODE_720X576: + case GFX_VGA_MODE_800X600: + break; - case GFX_VGA_MODE_1024X768: - if (houston_Rev() >= HOUSTON_REV_B) - break; - return ERR_INVALID_PARAMETER; - } + case GFX_VGA_MODE_1024X768: + if (houston_Rev() >= HOUSTON_REV_B) + break; + return ERR_INVALID_PARAMETER; + } - /*if the mode has changed... */ - if (vga_mode != d.vga_mode) { - d.vga_mode = vga_mode; + /*if the mode has changed... */ + if (vga_mode != d.vga_mode) { + d.vga_mode = vga_mode; - return write_config(REQ_VGA_MODE); - } + return write_config(REQ_VGA_MODE); + } - return 0; + return 0; } /*==========================================================================*/ @@ -1452,12 +1438,12 @@ int gfx_get_tvout_mode(unsigned long *p_tvout_mode) #endif { - if (!p_tvout_mode) - return ERR_INVALID_PARAMETER; + if (!p_tvout_mode) + return ERR_INVALID_PARAMETER; - *p_tvout_mode = d.tvout_mode; + *p_tvout_mode = d.tvout_mode; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1468,9 +1454,9 @@ int gfx_set_tvout_mode(unsigned long tvout_mode) #endif { - d.tvout_mode = tvout_mode; + d.tvout_mode = tvout_mode; - return write_config(REQ_TVOUT_MODE); + return write_config(REQ_TVOUT_MODE); } /*==========================================================================*/ @@ -1485,12 +1471,12 @@ int gfx_get_sharpness(int *p_sharpness) #endif { - if (!p_sharpness) - return ERR_INVALID_PARAMETER; + if (!p_sharpness) + return ERR_INVALID_PARAMETER; - *p_sharpness = d.sharpness; + *p_sharpness = d.sharpness; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1501,9 +1487,9 @@ int gfx_set_sharpness(int sharpness) #endif { - d.sharpness = range_limit(sharpness, 0, 1000); + d.sharpness = range_limit(sharpness, 0, 1000); - return write_config(REQ_SHARPNESS); + return write_config(REQ_SHARPNESS); } /*==========================================================================*/ @@ -1518,12 +1504,12 @@ int gfx_get_flicker_filter(int *p_flicker) #endif { - if (!p_flicker) - return ERR_INVALID_PARAMETER; + if (!p_flicker) + return ERR_INVALID_PARAMETER; - *p_flicker = d.flicker; + *p_flicker = d.flicker; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1534,9 +1520,9 @@ int gfx_set_flicker_filter(int flicker) #endif { - d.flicker = range_limit(flicker, 0, 1000); + d.flicker = range_limit(flicker, 0, 1000); - return write_config(REQ_FLICKER); + return write_config(REQ_FLICKER); } /*==========================================================================*/ @@ -1551,13 +1537,13 @@ int gfx_get_overscan(int *p_x, int *p_y) #endif { - if (!p_x || !p_y) - return ERR_INVALID_PARAMETER; + if (!p_x || !p_y) + return ERR_INVALID_PARAMETER; - *p_x = d.overscan_x; - *p_y = d.overscan_y; + *p_x = d.overscan_x; + *p_y = d.overscan_y; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1568,10 +1554,10 @@ int gfx_set_overscan(int x, int y) #endif { - d.overscan_x = range_limit(x, -1000, 1000); - d.overscan_y = range_limit(y, -1000, 1000); + d.overscan_x = range_limit(x, -1000, 1000); + d.overscan_y = range_limit(y, -1000, 1000); - return write_config(REQ_OVERSCAN_POSITION); + return write_config(REQ_OVERSCAN_POSITION); } #if GFX_TV_DYNAMIC @@ -1582,13 +1568,13 @@ int gfx_get_position(int *p_x, int *p_y) #endif { - if (!p_x || !p_y) - return ERR_INVALID_PARAMETER; + if (!p_x || !p_y) + return ERR_INVALID_PARAMETER; - *p_x = d.position_x; - *p_y = d.position_y; + *p_x = d.position_x; + *p_y = d.position_y; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1599,10 +1585,10 @@ int gfx_set_position(int x, int y) #endif { - d.position_x = range_limit(x, -1000, 1000); - d.position_y = range_limit(y, -1000, 1000); + d.position_x = range_limit(x, -1000, 1000); + d.position_y = range_limit(y, -1000, 1000); - return write_config(REQ_OVERSCAN_POSITION); + return write_config(REQ_OVERSCAN_POSITION); } /*==========================================================================*/ @@ -1617,12 +1603,12 @@ int gfx_get_color(int *p_color) #endif { - if (!p_color) - return ERR_INVALID_PARAMETER; + if (!p_color) + return ERR_INVALID_PARAMETER; - *p_color = d.color; + *p_color = d.color; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1633,9 +1619,9 @@ int gfx_set_color(int color) #endif { - d.color = range_limit(color, 0, 100); + d.color = range_limit(color, 0, 100); - return write_config(REQ_COLOR); + return write_config(REQ_COLOR); } #if GFX_TV_DYNAMIC @@ -1646,12 +1632,12 @@ int gfx_get_brightness(int *p_brightness) #endif { - if (!p_brightness) - return ERR_INVALID_PARAMETER; + if (!p_brightness) + return ERR_INVALID_PARAMETER; - *p_brightness = d.brightness; + *p_brightness = d.brightness; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1662,9 +1648,9 @@ int gfx_set_brightness(int brightness) #endif { - d.brightness = range_limit(brightness, 0, 100); + d.brightness = range_limit(brightness, 0, 100); - return write_config(REQ_BRIGHTNESS_CONTRAST); + return write_config(REQ_BRIGHTNESS_CONTRAST); } #if GFX_TV_DYNAMIC @@ -1675,12 +1661,12 @@ int gfx_get_contrast(int *p_contrast) #endif { - if (!p_contrast) - return ERR_INVALID_PARAMETER; + if (!p_contrast) + return ERR_INVALID_PARAMETER; - *p_contrast = d.contrast; + *p_contrast = d.contrast; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1691,9 +1677,9 @@ int gfx_set_contrast(int constrast) #endif { - d.contrast = range_limit(constrast, 0, 100); + d.contrast = range_limit(constrast, 0, 100); - return write_config(REQ_BRIGHTNESS_CONTRAST); + return write_config(REQ_BRIGHTNESS_CONTRAST); } /*==========================================================================*/ @@ -1708,15 +1694,15 @@ int gfx_get_yc_filter(unsigned int *p_yc_filter) #endif { - if (!p_yc_filter) - return ERR_INVALID_PARAMETER; + if (!p_yc_filter) + return ERR_INVALID_PARAMETER; - if (houston_Rev() < HOUSTON_REV_B) - return ERR_NOT_SUPPORTED; + if (houston_Rev() < HOUSTON_REV_B) + return ERR_NOT_SUPPORTED; - *p_yc_filter = d.yc_filter; + *p_yc_filter = d.yc_filter; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1727,22 +1713,22 @@ int gfx_set_yc_filter(unsigned int yc_filter) #endif { - if (houston_Rev() < HOUSTON_REV_B) - return ERR_NOT_SUPPORTED; + if (houston_Rev() < HOUSTON_REV_B) + return ERR_NOT_SUPPORTED; - /*luma filter. */ - if (yc_filter & GFX_LUMA_FILTER) - d.yc_filter |= GFX_LUMA_FILTER; - else - d.yc_filter &= ~GFX_LUMA_FILTER; + /*luma filter. */ + if (yc_filter & GFX_LUMA_FILTER) + d.yc_filter |= GFX_LUMA_FILTER; + else + d.yc_filter &= ~GFX_LUMA_FILTER; - /*chroma filter. */ - if (yc_filter & GFX_CHROMA_FILTER) - d.yc_filter |= GFX_CHROMA_FILTER; - else - d.yc_filter &= ~GFX_CHROMA_FILTER; + /*chroma filter. */ + if (yc_filter & GFX_CHROMA_FILTER) + d.yc_filter |= GFX_CHROMA_FILTER; + else + d.yc_filter &= ~GFX_CHROMA_FILTER; - return write_config(REQ_YC_FILTER); + return write_config(REQ_YC_FILTER); } #if GFX_TV_DYNAMIC @@ -1753,12 +1739,12 @@ int gfx_get_aps_trigger_bits(unsigned int *p_trigger_bits) #endif { - if (!p_trigger_bits) - return ERR_INVALID_PARAMETER; + if (!p_trigger_bits) + return ERR_INVALID_PARAMETER; - *p_trigger_bits = d.aps_trigger_bits; + *p_trigger_bits = d.aps_trigger_bits; - return 0; + return 0; } #if GFX_TV_DYNAMIC @@ -1769,9 +1755,9 @@ int gfx_set_aps_trigger_bits(unsigned int trigger_bits) #endif { - d.aps_trigger_bits = trigger_bits; + d.aps_trigger_bits = trigger_bits; - return write_config(REQ_MACROVISION); + return write_config(REQ_MACROVISION); } /*----------------------------------------------------------------------------- @@ -1790,8 +1776,8 @@ int gfx_set_tv_format(TVStandardType format, GfxOnTVType resolution) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /*----------------------------------------------------------------------------- @@ -1809,8 +1795,8 @@ int gfx_set_tv_output(int output) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /*----------------------------------------------------------------------------- @@ -1828,8 +1814,8 @@ int gfx_set_tv_cc_enable(int enable) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /*----------------------------------------------------------------------------- @@ -1847,8 +1833,8 @@ int gfx_set_tv_cc_data(unsigned char data1, unsigned char data2) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } #ifdef FS450_DIRECTREG @@ -1860,49 +1846,49 @@ gfx_set_tv_cc_data(unsigned char data1, unsigned char data2) int FS450_ReadRegister(S_REG_INFO * p_reg) { - unsigned long tmp; + unsigned long tmp; - if (PLAL_ReadRegister(p_reg)) - return 0; + if (PLAL_ReadRegister(p_reg)) + return 0; - if (SOURCE_HOUSTON == p_reg->source) { - switch (p_reg->size) { - case 1: - case 2: - { - houston_ReadReg((int)p_reg->offset, &tmp, (int)p_reg->size); - p_reg->value = tmp; - } - return 0; + if (SOURCE_HOUSTON == p_reg->source) { + switch (p_reg->size) { + case 1: + case 2: + { + houston_ReadReg((int) p_reg->offset, &tmp, (int) p_reg->size); + p_reg->value = tmp; + } + return 0; - case 4: - { - houston_ReadReg((unsigned int)p_reg->offset, &tmp, 2); - p_reg->value = (tmp << 16); - houston_ReadReg((unsigned int)(p_reg->offset + 2), &tmp, 2); - p_reg->value |= tmp; - } - return 0; - } - } + case 4: + { + houston_ReadReg((unsigned int) p_reg->offset, &tmp, 2); + p_reg->value = (tmp << 16); + houston_ReadReg((unsigned int) (p_reg->offset + 2), &tmp, 2); + p_reg->value |= tmp; + } + return 0; + } + } - return ERR_INVALID_PARAMETER; + return ERR_INVALID_PARAMETER; } int FS450_WriteRegister(S_REG_INFO * p_reg) { - if (PLAL_WriteRegister(p_reg)) - return 0; + if (PLAL_WriteRegister(p_reg)) + return 0; - if (SOURCE_HOUSTON == p_reg->source) { - houston_WriteReg((unsigned int)p_reg->offset, p_reg->value, - p_reg->size); + if (SOURCE_HOUSTON == p_reg->source) { + houston_WriteReg((unsigned int) p_reg->offset, p_reg->value, + p_reg->size); - return 0; - } + return 0; + } - return ERR_INVALID_PARAMETER; + return ERR_INVALID_PARAMETER; } #endif @@ -1915,49 +1901,49 @@ static int g_houston_rev = -1; static int houston_init(void) { - /*//int errc; */ - unsigned long write, read; - - TRACE(("houston_init()\n")) - - /*initialize I2C */ - /*errc = I2C_init(); - * if (errc) - * return errc; - */ - /*Before we begin, we must enable power to the TFT */ - read = READ_VID32(CS5530_DISPLAY_CONFIG); - read |= CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN; - WRITE_VID32(CS5530_DISPLAY_CONFIG, read); - - /*simple w/r test. */ - write = 0x0055; - read = 0; - - houston_WriteReg(HOUSTON_IHO, write, 2); - houston_ReadReg(HOUSTON_IHO, &read, 2); - if (read != write) { - houston_WriteReg(HOUSTON_IHO, write, 2); - houston_ReadReg(HOUSTON_IHO, &read, 2); - if (read != write) { - /*chip is not there, do something appropriate? */ - TRACE(("wrote HOUSTON_IHO=0x0055, read 0x%04x\n", read)) - return ERR_DEVICE_NOT_FOUND; - } - } - - /*read chip revision. */ - houston_ReadReg(HOUSTON_REV, &read, 2); - g_houston_rev = (int)read; - - /*ok. */ - return 0; + /*//int errc; */ + unsigned long write, read; + + TRACE(("houston_init()\n")) + + /*initialize I2C */ + /*errc = I2C_init(); + * if (errc) + * return errc; + */ + /*Before we begin, we must enable power to the TFT */ + read = READ_VID32(CS5530_DISPLAY_CONFIG); + read |= CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN; + WRITE_VID32(CS5530_DISPLAY_CONFIG, read); + + /*simple w/r test. */ + write = 0x0055; + read = 0; + + houston_WriteReg(HOUSTON_IHO, write, 2); + houston_ReadReg(HOUSTON_IHO, &read, 2); + if (read != write) { + houston_WriteReg(HOUSTON_IHO, write, 2); + houston_ReadReg(HOUSTON_IHO, &read, 2); + if (read != write) { + /*chip is not there, do something appropriate? */ + TRACE(("wrote HOUSTON_IHO=0x0055, read 0x%04x\n", read)) + return ERR_DEVICE_NOT_FOUND; + } + } + + /*read chip revision. */ + houston_ReadReg(HOUSTON_REV, &read, 2); + g_houston_rev = (int) read; + + /*ok. */ + return 0; } static int houston_Rev(void) { - return g_houston_rev; + return g_houston_rev; } static S_TIMING_SPECS g_specs; @@ -1965,7 +1951,7 @@ static S_TIMING_SPECS g_specs; static const S_TIMING_SPECS * p_specs(void) { - return &g_specs; + return &g_specs; } /*//==========================================================================*/ @@ -1976,15 +1962,15 @@ p_specs(void) static int config_init(void) { - int err; + int err; - TRACE(("config_init()\n")) + TRACE(("config_init()\n")) - err = houston_init(); - if (err) - return err; + err = houston_init(); + if (err) + return err; - return 0; + return 0; } /*==========================================================================*/ @@ -1994,71 +1980,68 @@ config_init(void) static unsigned short w10bit2z(unsigned short w) { - return (w >> 2) | ((w & 0x03) << 8); + return (w >> 2) | ((w & 0x03) << 8); } static unsigned short z2w10bit(unsigned short z) { - return (0x03 & (z >> 8)) | ((0xFF & z) << 2); + return (0x03 & (z >> 8)) | ((0xFF & z) << 2); } /*==========================================================================*/ /****/ /*// TV Standards*/ -static const struct -{ - unsigned long standard; - int tvsetup_index; -} -g_tv_standards[] = -{ - { - GFX_TV_STANDARD_NTSC_M, 0} - , { - GFX_TV_STANDARD_NTSC_M_J, 2} - , { - GFX_TV_STANDARD_PAL_B, 1} - , { - GFX_TV_STANDARD_PAL_D, 1} - , { - GFX_TV_STANDARD_PAL_H, 1} - , { - GFX_TV_STANDARD_PAL_I, 1} - , { - GFX_TV_STANDARD_PAL_M, 3} - , { - GFX_TV_STANDARD_PAL_N, 4} - , { - GFX_TV_STANDARD_PAL_G, 1} +static const struct { + unsigned long standard; + int tvsetup_index; +} g_tv_standards[] = { + { + GFX_TV_STANDARD_NTSC_M, 0} + , { + GFX_TV_STANDARD_NTSC_M_J, 2} + , { + GFX_TV_STANDARD_PAL_B, 1} + , { + GFX_TV_STANDARD_PAL_D, 1} + , { + GFX_TV_STANDARD_PAL_H, 1} + , { + GFX_TV_STANDARD_PAL_I, 1} + , { + GFX_TV_STANDARD_PAL_M, 3} + , { + GFX_TV_STANDARD_PAL_N, 4} + , { + GFX_TV_STANDARD_PAL_G, 1} ,}; static int map_tvstd_to_index(unsigned long tv_std) { - unsigned int i; + unsigned int i; - for (i = 0; i < sizeof(g_tv_standards) / sizeof(*g_tv_standards); i++) { - if (tv_std == g_tv_standards[i].standard) - return g_tv_standards[i].tvsetup_index; - } + for (i = 0; i < sizeof(g_tv_standards) / sizeof(*g_tv_standards); i++) { + if (tv_std == g_tv_standards[i].standard) + return g_tv_standards[i].tvsetup_index; + } - return -1; + return -1; } static unsigned long supported_standards(void) { - unsigned long standards = 0; - unsigned int i; + unsigned long standards = 0; + unsigned int i; - for (i = 0; i < sizeof(g_tv_standards) / sizeof(*g_tv_standards); i++) { - if (g_tv_standards[i].tvsetup_index >= 0) - standards |= g_tv_standards[i].standard; - } + for (i = 0; i < sizeof(g_tv_standards) / sizeof(*g_tv_standards); i++) { + if (g_tv_standards[i].tvsetup_index >= 0) + standards |= g_tv_standards[i].standard; + } - return standards; + return standards; } /*==========================================================================*/ @@ -2066,53 +2049,55 @@ supported_standards(void) static void config_power(int on) { - unsigned long reg; - - if (houston_Rev() < HOUSTON_REV_B) { - /*no power down supported, but still turn of clock in off mode */ - if (on) { - houston_ReadReg(HOUSTON_CR, ®, 2); - reg &= ~(CR_CLKOFF | CR_RESET); - houston_WriteReg(HOUSTON_CR, reg, 2); - reg |= CR_RESET; - houston_WriteReg(HOUSTON_CR, reg, 2); - reg &= ~CR_RESET; - houston_WriteReg(HOUSTON_CR, reg, 2); - } else { - houston_ReadReg(HOUSTON_CR, ®, 2); - reg |= CR_CLKOFF; - houston_WriteReg(HOUSTON_CR, reg, 2); - } - - return; - } - - if (on) { - /*!CLKOFF, !COMPOFF, !YCOFF */ - /*and reset Houston */ - houston_ReadReg(HOUSTON_CR, ®, 2); - reg &= ~(CR_CLKOFF | CR_RESET | CR_COMPOFF | CR_YCOFF); - houston_WriteReg(HOUSTON_CR, reg, 2); - reg |= CR_RESET; - houston_WriteReg(HOUSTON_CR, reg, 2); - reg &= ~CR_RESET; - houston_WriteReg(HOUSTON_CR, reg, 2); - - /*!GTLIO_PD */ - houston_ReadReg(HOUSTON_MISC, ®, 2); - reg &= ~MISC_GTLIO_PD; - houston_WriteReg(HOUSTON_MISC, reg, 2); - } else { - /*CLKOFF, COMPOFF, YCOFF */ - houston_ReadReg(HOUSTON_CR, ®, 2); - reg |= (CR_CLKOFF | CR_COMPOFF | CR_YCOFF); - houston_WriteReg(HOUSTON_CR, reg, 2); - - /*GTLIO_PD */ - houston_ReadReg(HOUSTON_MISC, ®, 2); - reg |= MISC_GTLIO_PD; - houston_WriteReg(HOUSTON_MISC, reg, 2); - } + unsigned long reg; + + if (houston_Rev() < HOUSTON_REV_B) { + /*no power down supported, but still turn of clock in off mode */ + if (on) { + houston_ReadReg(HOUSTON_CR, ®, 2); + reg &= ~(CR_CLKOFF | CR_RESET); + houston_WriteReg(HOUSTON_CR, reg, 2); + reg |= CR_RESET; + houston_WriteReg(HOUSTON_CR, reg, 2); + reg &= ~CR_RESET; + houston_WriteReg(HOUSTON_CR, reg, 2); + } + else { + houston_ReadReg(HOUSTON_CR, ®, 2); + reg |= CR_CLKOFF; + houston_WriteReg(HOUSTON_CR, reg, 2); + } + + return; + } + + if (on) { + /*!CLKOFF, !COMPOFF, !YCOFF */ + /*and reset Houston */ + houston_ReadReg(HOUSTON_CR, ®, 2); + reg &= ~(CR_CLKOFF | CR_RESET | CR_COMPOFF | CR_YCOFF); + houston_WriteReg(HOUSTON_CR, reg, 2); + reg |= CR_RESET; + houston_WriteReg(HOUSTON_CR, reg, 2); + reg &= ~CR_RESET; + houston_WriteReg(HOUSTON_CR, reg, 2); + + /*!GTLIO_PD */ + houston_ReadReg(HOUSTON_MISC, ®, 2); + reg &= ~MISC_GTLIO_PD; + houston_WriteReg(HOUSTON_MISC, reg, 2); + } + else { + /*CLKOFF, COMPOFF, YCOFF */ + houston_ReadReg(HOUSTON_CR, ®, 2); + reg |= (CR_CLKOFF | CR_COMPOFF | CR_YCOFF); + houston_WriteReg(HOUSTON_CR, reg, 2); + + /*GTLIO_PD */ + houston_ReadReg(HOUSTON_MISC, ®, 2); + reg |= MISC_GTLIO_PD; + houston_WriteReg(HOUSTON_MISC, reg, 2); + } } /*==========================================================================*/ @@ -2122,66 +2107,64 @@ config_power(int on) static void config_vga_mode(unsigned long vga_mode) { - /*h_total must be evenly divisible by 32? */ - - static struct - { - unsigned long mode; - int width; - int lines; - int h_total; - } - vgaparams[] = - { - { - GFX_VGA_MODE_640X480, 640, 480, 1056} - , { - GFX_VGA_MODE_720X487, 720, 487, 1056} - , { - GFX_VGA_MODE_720X576, 720, 576, 1056} - , { - GFX_VGA_MODE_800X600, 800, 600, 1056} - , { - GFX_VGA_MODE_1024X768, 1024, 768, 1344} - ,}; - - unsigned long cr, misc, byp; - unsigned int i; - - g_specs.vga_width = 0; - g_specs.vga_lines = 0; - g_specs.h_total = 0; - - for (i = 0; i < sizeof(vgaparams) / sizeof(*vgaparams); i++) { - if (vga_mode == vgaparams[i].mode) { - g_specs.vga_width = vgaparams[i].width; - g_specs.vga_lines = vgaparams[i].lines; - g_specs.h_total = vgaparams[i].h_total; - break; - } - } - if (!g_specs.h_total) - return; - - /*clock mux decimator and vga dual. */ - houston_ReadReg(HOUSTON_CR, &cr, 2); - houston_ReadReg(HOUSTON_MISC, &misc, 2); - houston_ReadReg(HOUSTON_BYP, &byp, 2); - - if (vga_mode == GFX_VGA_MODE_1024X768) { - /*XGA*/ cr |= CR_UIM_DEC; - misc |= MISC_VGACKDIV; - byp |= (BYP_HDS_BYPASS | BYP_CAC_BYPASS); - } else { - /*VGA,SVGA */ - cr &= ~CR_UIM_DEC; - misc &= ~MISC_VGACKDIV; - byp &= ~(BYP_HDS_BYPASS | BYP_CAC_BYPASS); - } - - houston_WriteReg(HOUSTON_CR, cr, 2); - houston_WriteReg(HOUSTON_MISC, misc, 2); - houston_WriteReg(HOUSTON_BYP, byp, 2); + /*h_total must be evenly divisible by 32? */ + + static struct { + unsigned long mode; + int width; + int lines; + int h_total; + } vgaparams[] = { + { + GFX_VGA_MODE_640X480, 640, 480, 1056} + , { + GFX_VGA_MODE_720X487, 720, 487, 1056} + , { + GFX_VGA_MODE_720X576, 720, 576, 1056} + , { + GFX_VGA_MODE_800X600, 800, 600, 1056} + , { + GFX_VGA_MODE_1024X768, 1024, 768, 1344} + ,}; + + unsigned long cr, misc, byp; + unsigned int i; + + g_specs.vga_width = 0; + g_specs.vga_lines = 0; + g_specs.h_total = 0; + + for (i = 0; i < sizeof(vgaparams) / sizeof(*vgaparams); i++) { + if (vga_mode == vgaparams[i].mode) { + g_specs.vga_width = vgaparams[i].width; + g_specs.vga_lines = vgaparams[i].lines; + g_specs.h_total = vgaparams[i].h_total; + break; + } + } + if (!g_specs.h_total) + return; + + /*clock mux decimator and vga dual. */ + houston_ReadReg(HOUSTON_CR, &cr, 2); + houston_ReadReg(HOUSTON_MISC, &misc, 2); + houston_ReadReg(HOUSTON_BYP, &byp, 2); + + if (vga_mode == GFX_VGA_MODE_1024X768) { + /*XGA*/ cr |= CR_UIM_DEC; + misc |= MISC_VGACKDIV; + byp |= (BYP_HDS_BYPASS | BYP_CAC_BYPASS); + } + else { + /*VGA,SVGA */ + cr &= ~CR_UIM_DEC; + misc &= ~MISC_VGACKDIV; + byp &= ~(BYP_HDS_BYPASS | BYP_CAC_BYPASS); + } + + houston_WriteReg(HOUSTON_CR, cr, 2); + houston_WriteReg(HOUSTON_MISC, misc, 2); + houston_WriteReg(HOUSTON_BYP, byp, 2); } /*==========================================================================*/ @@ -2191,88 +2174,88 @@ config_vga_mode(unsigned long vga_mode) static void config_tv_std(unsigned long tv_std, unsigned int trigger_bits) { - int k; - unsigned short reg34; - unsigned long cr, w; - unsigned long l; - - /*verify supported standard. */ - k = map_tvstd_to_index(tv_std); - if (k < 0) - return; - - /*store tv width and lines */ - g_specs.tv_width = tvsetup.tv_width[k]; - g_specs.tv_lines = tvsetup.tv_lines[k]; - - /*houston CR register. */ - houston_ReadReg(HOUSTON_CR, &cr, 2); - cr &= ~CR_656_PAL_NTSC; - cr |= tvsetup.houston_cr[k]; - houston_WriteReg(HOUSTON_CR, cr, 2); - - /*setup the encoder. */ - l = tvsetup.chroma_freq[k]; - houston_WriteReg(ENC_CHROMA_FREQ, (int)(l & 0x00ff), 1); - houston_WriteReg(ENC_CHROMA_FREQ + 1, (int)((l >> 8) & 0x00ff), 1); - houston_WriteReg(ENC_CHROMA_FREQ + 2, (int)((l >> 16) & 0x00ff), 1); - houston_WriteReg(ENC_CHROMA_FREQ + 3, (int)((l >> 24) & 0x00ff), 1); - - houston_WriteReg(ENC_CHROMA_PHASE, tvsetup.chroma_phase[k], 1); - houston_WriteReg(ENC_REG05, 0x00, 1); /*reg 0x05 */ - houston_WriteReg(ENC_REG06, 0x89, 1); /*reg 0x06 */ - houston_WriteReg(ENC_REG07, 0x00, 1); /*reg 0x07 */ - houston_WriteReg(ENC_HSYNC_WIDTH, tvsetup.hsync_width[k], 1); - houston_WriteReg(ENC_BURST_WIDTH, tvsetup.burst_width[k], 1); - houston_WriteReg(ENC_BACK_PORCH, tvsetup.back_porch[k], 1); - houston_WriteReg(ENC_CB_BURST_LEVEL, tvsetup.cb_burst_level[k], 1); - houston_WriteReg(ENC_CR_BURST_LEVEL, tvsetup.cr_burst_level[k], 1); - houston_WriteReg(ENC_SLAVE_MODE, 0x01, 1); /*slave mode */ - if (trigger_bits == 0) - w = w10bit2z(tvsetup.blank_level[k]); /*blank level */ - else - w = w10bit2z((unsigned short)(tvsetup.blank_level[k] - - tvsetup.hamp_offset[k])); - houston_WriteReg(ENC_BLANK_LEVEL, w & 0x00ff, 1); - houston_WriteReg(ENC_BLANK_LEVEL + 1, w >> 8, 1); - w = w10bit2z(tvsetup.tv_lines[k]); /*num_lines */ - houston_WriteReg(ENC_NUM_LINES, w & 0x00ff, 1); - houston_WriteReg(ENC_NUM_LINES + 1, w >> 8, 1); - - houston_WriteReg(ENC_TINT, 0x00, 1); /*tint */ - houston_WriteReg(ENC_BREEZE_WAY, tvsetup.breeze_way[k], 1); - houston_WriteReg(ENC_FRONT_PORCH, tvsetup.front_porch[k], 1); - houston_WriteReg(ENC_ACTIVELINE, tvsetup.activeline[k], 1); - houston_WriteReg(ENC_FIRST_LINE, 0x15, 1); /*firstvideoline */ - reg34 = - 0x80 | - (tvsetup.pal_mode[k] << 6) | - (tvsetup.sys625_50[k] << 3) | - (tvsetup.cphase_rst[k] << 1) | (tvsetup.vsync5[k]); - houston_WriteReg(ENC_REG34, reg34, 1); /*reg 0x34 */ - houston_WriteReg(ENC_SYNC_LEVEL, tvsetup.sync_level[k], 1); - if (trigger_bits == 0) - w = w10bit2z(tvsetup.vbi_blank_level[k]); /*blank level */ - else - w = w10bit2z((unsigned short)(tvsetup.vbi_blank_level[k] - 1)); - houston_WriteReg(ENC_VBI_BLANK_LEVEL, w & 0x00ff, 1); - houston_WriteReg(ENC_VBI_BLANK_LEVEL + 1, w >> 8, 1); + int k; + unsigned short reg34; + unsigned long cr, w; + unsigned long l; + + /*verify supported standard. */ + k = map_tvstd_to_index(tv_std); + if (k < 0) + return; + + /*store tv width and lines */ + g_specs.tv_width = tvsetup.tv_width[k]; + g_specs.tv_lines = tvsetup.tv_lines[k]; + + /*houston CR register. */ + houston_ReadReg(HOUSTON_CR, &cr, 2); + cr &= ~CR_656_PAL_NTSC; + cr |= tvsetup.houston_cr[k]; + houston_WriteReg(HOUSTON_CR, cr, 2); + + /*setup the encoder. */ + l = tvsetup.chroma_freq[k]; + houston_WriteReg(ENC_CHROMA_FREQ, (int) (l & 0x00ff), 1); + houston_WriteReg(ENC_CHROMA_FREQ + 1, (int) ((l >> 8) & 0x00ff), 1); + houston_WriteReg(ENC_CHROMA_FREQ + 2, (int) ((l >> 16) & 0x00ff), 1); + houston_WriteReg(ENC_CHROMA_FREQ + 3, (int) ((l >> 24) & 0x00ff), 1); + + houston_WriteReg(ENC_CHROMA_PHASE, tvsetup.chroma_phase[k], 1); + houston_WriteReg(ENC_REG05, 0x00, 1); /*reg 0x05 */ + houston_WriteReg(ENC_REG06, 0x89, 1); /*reg 0x06 */ + houston_WriteReg(ENC_REG07, 0x00, 1); /*reg 0x07 */ + houston_WriteReg(ENC_HSYNC_WIDTH, tvsetup.hsync_width[k], 1); + houston_WriteReg(ENC_BURST_WIDTH, tvsetup.burst_width[k], 1); + houston_WriteReg(ENC_BACK_PORCH, tvsetup.back_porch[k], 1); + houston_WriteReg(ENC_CB_BURST_LEVEL, tvsetup.cb_burst_level[k], 1); + houston_WriteReg(ENC_CR_BURST_LEVEL, tvsetup.cr_burst_level[k], 1); + houston_WriteReg(ENC_SLAVE_MODE, 0x01, 1); /*slave mode */ + if (trigger_bits == 0) + w = w10bit2z(tvsetup.blank_level[k]); /*blank level */ + else + w = w10bit2z((unsigned short) (tvsetup.blank_level[k] - + tvsetup.hamp_offset[k])); + houston_WriteReg(ENC_BLANK_LEVEL, w & 0x00ff, 1); + houston_WriteReg(ENC_BLANK_LEVEL + 1, w >> 8, 1); + w = w10bit2z(tvsetup.tv_lines[k]); /*num_lines */ + houston_WriteReg(ENC_NUM_LINES, w & 0x00ff, 1); + houston_WriteReg(ENC_NUM_LINES + 1, w >> 8, 1); + + houston_WriteReg(ENC_TINT, 0x00, 1); /*tint */ + houston_WriteReg(ENC_BREEZE_WAY, tvsetup.breeze_way[k], 1); + houston_WriteReg(ENC_FRONT_PORCH, tvsetup.front_porch[k], 1); + houston_WriteReg(ENC_ACTIVELINE, tvsetup.activeline[k], 1); + houston_WriteReg(ENC_FIRST_LINE, 0x15, 1); /*firstvideoline */ + reg34 = + 0x80 | + (tvsetup.pal_mode[k] << 6) | + (tvsetup.sys625_50[k] << 3) | + (tvsetup.cphase_rst[k] << 1) | (tvsetup.vsync5[k]); + houston_WriteReg(ENC_REG34, reg34, 1); /*reg 0x34 */ + houston_WriteReg(ENC_SYNC_LEVEL, tvsetup.sync_level[k], 1); + if (trigger_bits == 0) + w = w10bit2z(tvsetup.vbi_blank_level[k]); /*blank level */ + else + w = w10bit2z((unsigned short) (tvsetup.vbi_blank_level[k] - 1)); + houston_WriteReg(ENC_VBI_BLANK_LEVEL, w & 0x00ff, 1); + houston_WriteReg(ENC_VBI_BLANK_LEVEL + 1, w >> 8, 1); } static void conget_tv_std(unsigned long *p_tv_standard) { - unsigned long cr; + unsigned long cr; - if (!p_tv_standard) - return; + if (!p_tv_standard) + return; - /*just pick between NTSC and PAL */ - houston_ReadReg(HOUSTON_CR, &cr, 2); - if (CR_656_PAL_NTSC & cr) - *p_tv_standard = GFX_TV_STANDARD_PAL_B; - else - *p_tv_standard = GFX_TV_STANDARD_NTSC_M; + /*just pick between NTSC and PAL */ + houston_ReadReg(HOUSTON_CR, &cr, 2); + if (CR_656_PAL_NTSC & cr) + *p_tv_standard = GFX_TV_STANDARD_PAL_B; + else + *p_tv_standard = GFX_TV_STANDARD_NTSC_M; } /*==========================================================================*/ @@ -2282,47 +2265,47 @@ conget_tv_std(unsigned long *p_tv_standard) static void config_tvout_mode(unsigned long tvout_mode) { - unsigned long cr; + unsigned long cr; - houston_ReadReg(HOUSTON_CR, &cr, 2); + houston_ReadReg(HOUSTON_CR, &cr, 2); - /*all dacs off */ - cr |= (CR_COMPOFF | CR_YCOFF); - /*not rgb */ - cr &= ~CR_OFMT; + /*all dacs off */ + cr |= (CR_COMPOFF | CR_YCOFF); + /*not rgb */ + cr &= ~CR_OFMT; - /*turn on requested output */ - if (GFX_TVOUT_MODE_CVBS & tvout_mode) - cr &= ~CR_COMPOFF; - if (GFX_TVOUT_MODE_YC & tvout_mode) - cr &= ~CR_YCOFF; - if (GFX_TVOUT_MODE_RGB & tvout_mode) { - cr &= ~(CR_COMPOFF | CR_YCOFF); - cr |= CR_OFMT; - } + /*turn on requested output */ + if (GFX_TVOUT_MODE_CVBS & tvout_mode) + cr &= ~CR_COMPOFF; + if (GFX_TVOUT_MODE_YC & tvout_mode) + cr &= ~CR_YCOFF; + if (GFX_TVOUT_MODE_RGB & tvout_mode) { + cr &= ~(CR_COMPOFF | CR_YCOFF); + cr |= CR_OFMT; + } - houston_WriteReg(HOUSTON_CR, cr, 2); + houston_WriteReg(HOUSTON_CR, cr, 2); } static void conget_tvout_mode(unsigned long *p_tvout_mode) { - unsigned long cr; + unsigned long cr; - if (!p_tvout_mode) - return; + if (!p_tvout_mode) + return; - houston_ReadReg(HOUSTON_CR, &cr, 2); + houston_ReadReg(HOUSTON_CR, &cr, 2); - if (CR_OFMT & cr) - *p_tvout_mode = GFX_TVOUT_MODE_RGB; - else { - *p_tvout_mode = 0; - if (!(CR_YCOFF & cr)) - *p_tvout_mode |= GFX_TVOUT_MODE_YC; - if (!(CR_COMPOFF & cr)) - *p_tvout_mode |= GFX_TVOUT_MODE_CVBS; - } + if (CR_OFMT & cr) + *p_tvout_mode = GFX_TVOUT_MODE_RGB; + else { + *p_tvout_mode = 0; + if (!(CR_YCOFF & cr)) + *p_tvout_mode |= GFX_TVOUT_MODE_YC; + if (!(CR_COMPOFF & cr)) + *p_tvout_mode |= GFX_TVOUT_MODE_CVBS; + } } /*==========================================================================*/ @@ -2345,306 +2328,314 @@ conget_tvout_mode(unsigned long *p_tvout_mode) static void get_ffolat_ivo(unsigned long vga_mode, - unsigned long tv_std, - long i, unsigned short *ffolat, unsigned short *ivo) -{ - switch (vga_mode) { - case GFX_VGA_MODE_640X480: - if (IS_NTSC(tv_std)) { - if (i > SIZE6X4NTSC - 1) - i = SIZE6X4NTSC - 1; - *ffolat = ffo6x4ntsc[i].ffolat; - *ivo = 0x20; - } else { - if (i > SIZE6X4PAL - 1) - i = SIZE6X4PAL - 1; - *ffolat = ffo6x4pal[i].ffolat; - *ivo = 0x28; - } - break; - - case GFX_VGA_MODE_800X600: - if (IS_NTSC(tv_std)) { - if (i > SIZE8X6NTSC - 1) - i = SIZE8X6NTSC - 1; - *ffolat = ffo8x6ntsc[i].ffolat; - *ivo = 0x3a; - } else { - if (i > SIZE8X6PAL - 1) - i = SIZE8X6PAL - 1; - *ffolat = ffo8x6pal[i].ffolat; - *ivo = 0x39; - } - break; - - case GFX_VGA_MODE_720X487: - *ffolat = 0x40; /*//FFO7x4; */ - *ivo = 0x1a; - break; - - case GFX_VGA_MODE_720X576: - *ffolat = 0x40; /*//FFO7x5; */ - *ivo = 0x1a; - break; - - case GFX_VGA_MODE_1024X768: - default: - if (IS_NTSC(tv_std)) { - if (i > SIZE10X7NTSC - 1) - i = SIZE10X7NTSC - 1; - *ffolat = ffo10x7ntsc[i].ffolat; - *ivo = ffo10x7ntsc[i].ivo; - } else { - if (i > SIZE10X7PAL - 1) - i = SIZE10X7PAL - 1; - *ffolat = ffo10x7pal[i].ffolat; - *ivo = ffo10x7pal[i].ivo; - } - break; - } + unsigned long tv_std, + long i, unsigned short *ffolat, unsigned short *ivo) +{ + switch (vga_mode) { + case GFX_VGA_MODE_640X480: + if (IS_NTSC(tv_std)) { + if (i > SIZE6X4NTSC - 1) + i = SIZE6X4NTSC - 1; + *ffolat = ffo6x4ntsc[i].ffolat; + *ivo = 0x20; + } + else { + if (i > SIZE6X4PAL - 1) + i = SIZE6X4PAL - 1; + *ffolat = ffo6x4pal[i].ffolat; + *ivo = 0x28; + } + break; + + case GFX_VGA_MODE_800X600: + if (IS_NTSC(tv_std)) { + if (i > SIZE8X6NTSC - 1) + i = SIZE8X6NTSC - 1; + *ffolat = ffo8x6ntsc[i].ffolat; + *ivo = 0x3a; + } + else { + if (i > SIZE8X6PAL - 1) + i = SIZE8X6PAL - 1; + *ffolat = ffo8x6pal[i].ffolat; + *ivo = 0x39; + } + break; + + case GFX_VGA_MODE_720X487: + *ffolat = 0x40; /*//FFO7x4; */ + *ivo = 0x1a; + break; + + case GFX_VGA_MODE_720X576: + *ffolat = 0x40; /*//FFO7x5; */ + *ivo = 0x1a; + break; + + case GFX_VGA_MODE_1024X768: + default: + if (IS_NTSC(tv_std)) { + if (i > SIZE10X7NTSC - 1) + i = SIZE10X7NTSC - 1; + *ffolat = ffo10x7ntsc[i].ffolat; + *ivo = ffo10x7ntsc[i].ivo; + } + else { + if (i > SIZE10X7PAL - 1) + i = SIZE10X7PAL - 1; + *ffolat = ffo10x7pal[i].ffolat; + *ivo = ffo10x7pal[i].ivo; + } + break; + } } /*get vertical line min and max for mode and std.*/ static void get_vtotal_min_max(unsigned long vga_mode, - unsigned long tv_std, - int *v_total_min, int *v_total_max, int *v_step) -{ - int k = map_tvstd_to_index(tv_std); - - switch (vga_mode) { - case GFX_VGA_MODE_640X480: - if (IS_NTSC(tv_std)) { - *v_total_min = ffo6x4ntsc[0].v_total; - *v_total_max = ffo6x4ntsc[SIZE6X4NTSC - 1].v_total; - } else { - *v_total_min = ffo6x4pal[0].v_total; - *v_total_max = ffo6x4pal[SIZE6X4PAL - 1].v_total; - } - *v_step = 4; - break; - - case GFX_VGA_MODE_800X600: - if (IS_NTSC(tv_std)) { - *v_total_min = ffo8x6ntsc[0].v_total; - *v_total_max = ffo8x6ntsc[SIZE8X6NTSC - 1].v_total; - } else { - *v_total_min = ffo8x6pal[0].v_total; - *v_total_max = ffo8x6pal[SIZE8X6PAL - 1].v_total; - } - *v_step = 5; - break; - - case GFX_VGA_MODE_720X487: - case GFX_VGA_MODE_720X576: - *v_total_min = tvsetup.tv_lines[k]; - *v_total_max = tvsetup.tv_lines[k]; - *v_step = 4; - break; - - case GFX_VGA_MODE_1024X768: - if (IS_NTSC(tv_std)) { - *v_total_min = ffo10x7ntsc[0].v_total; - *v_total_max = ffo10x7ntsc[SIZE10X7NTSC - 1].v_total; - } else { - *v_total_min = ffo10x7pal[0].v_total; - *v_total_max = ffo10x7pal[SIZE10X7PAL - 1].v_total; - } - *v_step = 6; - break; - } + unsigned long tv_std, + int *v_total_min, int *v_total_max, int *v_step) +{ + int k = map_tvstd_to_index(tv_std); + + switch (vga_mode) { + case GFX_VGA_MODE_640X480: + if (IS_NTSC(tv_std)) { + *v_total_min = ffo6x4ntsc[0].v_total; + *v_total_max = ffo6x4ntsc[SIZE6X4NTSC - 1].v_total; + } + else { + *v_total_min = ffo6x4pal[0].v_total; + *v_total_max = ffo6x4pal[SIZE6X4PAL - 1].v_total; + } + *v_step = 4; + break; + + case GFX_VGA_MODE_800X600: + if (IS_NTSC(tv_std)) { + *v_total_min = ffo8x6ntsc[0].v_total; + *v_total_max = ffo8x6ntsc[SIZE8X6NTSC - 1].v_total; + } + else { + *v_total_min = ffo8x6pal[0].v_total; + *v_total_max = ffo8x6pal[SIZE8X6PAL - 1].v_total; + } + *v_step = 5; + break; + + case GFX_VGA_MODE_720X487: + case GFX_VGA_MODE_720X576: + *v_total_min = tvsetup.tv_lines[k]; + *v_total_max = tvsetup.tv_lines[k]; + *v_step = 4; + break; + + case GFX_VGA_MODE_1024X768: + if (IS_NTSC(tv_std)) { + *v_total_min = ffo10x7ntsc[0].v_total; + *v_total_max = ffo10x7ntsc[SIZE10X7NTSC - 1].v_total; + } + else { + *v_total_min = ffo10x7pal[0].v_total; + *v_total_max = ffo10x7pal[SIZE10X7PAL - 1].v_total; + } + *v_step = 6; + break; + } } static void config_overscan_xy(unsigned long tv_std, - unsigned long vga_mode, - int overscan_x, int overscan_y, int pos_x, int pos_y) -{ - unsigned int vga_index; - unsigned long reg; - double vsc; - int k; - unsigned short ffolat, ivo; - int base_v_total, range, v_offset; - int v_total_min, v_total_max, v_step; - float r, f; - int vga_pixels, pre_pixels; - float hscale, hscale_min, hscale_max; - int hsc; - int iho, iho_max, ihw; - - /*tv_std is valid. */ - k = map_tvstd_to_index(tv_std); - - /*store tv width and lines */ - g_specs.tv_width = tvsetup.tv_width[k]; - g_specs.tv_lines = tvsetup.tv_lines[k]; - - /*determine vga mode index */ - for (vga_index = 0; vga_index < SCANTABLE_ENTRIES; vga_index++) { - if (scantable[vga_index].mode == vga_mode) - break; - } - if (vga_index >= SCANTABLE_ENTRIES) - return; - - /****/ - /*vertical scaling (v_total setup). */ - /****/ - /*calculate vertical range. */ - get_vtotal_min_max(vga_mode, tv_std, &v_total_min, &v_total_max, &v_step); - TRACE(("v_total min=%d, max=%d\n", v_total_min, v_total_max)) - base_v_total = scantable[vga_index].v_total[k]; - range = fsmax(base_v_total - v_total_min, v_total_max - base_v_total); - TRACE(("v_total range = %d\n", range)) - - /*map +/-1000 overscan y into +/-range. */ - v_offset = (int)((((float)overscan_y * range) / 1000.f) + .5f); - TRACE(("v_offset = %d\n", v_offset)) - - /*range limit v_total. */ - g_specs.v_total = - range_limit(base_v_total + v_offset, v_total_min, v_total_max); - - /*round to calibrated value. */ - v_offset = (g_specs.v_total - v_total_min + (v_step / 2)) / v_step; - g_specs.v_total = v_total_min + v_offset * v_step; - TRACE(("desired v_total=%d\n", g_specs.v_total)) - - /****/ - /*vertical positioning (vsync setup). */ - /****/ - get_ffolat_ivo(vga_mode, tv_std, v_offset, &ffolat, &ivo); - houston_WriteReg(HOUSTON_IVO, ivo, 2); - - /*scale base sync offset by scaling ratio. */ - r = (float)g_specs.v_total / (float)base_v_total; - v_offset = (int)(r * (float)scantable[vga_index].v_sync[k]); - - /*scale ivo. */ - f = (float)ivo; - v_offset -= (int)(f - f / r); - - /*compensate for center screen. */ - f = (float)tvsetup.tv_active_lines[k] / 2.f; - v_offset += (int)(f * r - f); - - /*calculate vsync. */ - g_specs.v_sync = g_specs.v_total - v_offset + pos_y; - TRACE(("desired v_total=%d, desired v_sync=%d\n", g_specs.v_total, - g_specs.v_sync)) - if (g_specs.v_sync < g_specs.vga_lines + 10) { - TRACE(("vsync too low\n")) - /*//d.v_total += d.vga_lines+10-d.v_sync; */ - g_specs.v_sync = g_specs.vga_lines + 10; - } else if (g_specs.v_sync > g_specs.v_total - 10) { - TRACE(("vsync too high\n")) - g_specs.v_sync = g_specs.v_total - 10; - } - TRACE(("v_total=%d v_sync=%d\n", g_specs.v_total, g_specs.v_sync)) - - /*FFOLAT. */ - houston_WriteReg(HOUSTON_FFO_LAT, ffolat, 2); - - /*VSC. */ - vsc = (65536.0f * - (1.0f - (double)g_specs.tv_lines / (double)g_specs.v_total)) + 0.5f; - reg = ((unsigned long)-vsc) & 0xffff; - TRACE(("vsc=%04x, tv_lines=%d, v_total=%d\n", reg, g_specs.tv_lines, - g_specs.v_total)) - houston_WriteReg(HOUSTON_VSC, (int)reg, 2); - - /****/ - /*horizontal scaling. */ - /****/ - - /*vga pixels is vga width, except in 1024x768, where it's half that. */ - vga_pixels = g_specs.vga_width; - if (1024 == vga_pixels) - vga_pixels /= 2; - - /*maximum scaling coefficient is tv_width / vga_pixels */ - /*minimum is about 1/2, but that is quite small. arbitrarily set minimum at 75% maximum. */ - hscale_max = (720.0f / vga_pixels); - hscale_min = fsmax((0.75f * hscale_max), (1.0f - (63.0f / 128.0f))); - TRACE(("hscale_min = %u.%u, hscale_max = %u.%u\n", - (int)hscale_min, - (int)((hscale_min - (int)hscale_min) * 1000), - (int)hscale_max, (int)((hscale_max - (int)hscale_max) * 1000))) - - /*map overscan_x into min to max. */ - hscale = - hscale_min + ((overscan_x + 1000.0f) / 2000.0f) * (hscale_max - - hscale_min); - TRACE(("hscale = %u.%u\n", (int)hscale, - (int)((hscale - (int)hscale) * 1000))) - - /*determine hsc where hscale = (1 + hsc/128) */ - if (hscale >= 1.0f) - hsc = (int)(128.f * (hscale - 1.0f) + .5f); - else - hsc = (int)(128.f * (hscale - 1.0f) - .5f); - TRACE(("hsc = %d\n", hsc)) - if (hsc >= 0) - houston_WriteReg(HOUSTON_HSC, hsc << 8, 2); - else - houston_WriteReg(HOUSTON_HSC, hsc & 0xFF, 2); - - /*recalculate hscale for future formulas */ - hscale = 1.0f + (hsc / 128.0f); - TRACE(("recalculated hscale = %u.%u\n", (int)hscale, - (int)((hscale - (int)hscale) * 1000))) - - /****/ - /*horizontal offset. */ - /****/ - /*place hsync 40 before halfway from vga_width to htotal */ - /*but not less than vga_width + 10 */ - g_specs.h_sync = - fsmax((g_specs.h_total + g_specs.vga_width) / 2 - 40, - g_specs.vga_width + 10); - /*also, make it even */ - g_specs.h_sync &= ~1; - TRACE(("hsync = %u\n", g_specs.h_sync)) - - /*iho range is 0 to iho_max. */ - /*iho_max is 2 * iho_center. */ - /*iho_center is pre_pixels - (tvwidth / hscale - vga pixels) / 2. */ - /*pre_pixels = (htotal - hsync) * (vga_pixels / vga_width) */ - /*note that the range is inverted also, because it specifies the number of pixels */ - /*to skip, or subtract. iho=0 maps to farthest right. */ - /*map -pos_x = +/-1000 into (0 to iho_max) */ - pre_pixels = - (int)((long)(g_specs.h_total - g_specs.h_sync) * vga_pixels / - g_specs.vga_width); - iho_max = (2 * pre_pixels) - ((int)(720.0f / hscale + 0.5f) - vga_pixels); - TRACE(("iho_max = %u\n", iho_max)) - iho = - (int)range_limit(((long)(1000 - pos_x) * iho_max / 2000) + - scantable[vga_index].iho[k], 0, iho_max); - TRACE(("iho = %u\n", iho)) - houston_WriteReg(HOUSTON_IHO, iho, 2); - - /****/ - /*input horizontal width. */ - /****/ - - /*input horizontal width is vga pixels + pre_pixels - iho */ - /*additionally, ihw cannot exceed tv width / hscale */ - /*and if hsc is negative, (ihw)(-hsc/128) cannot exceed ~250. */ - /*and ihw should be even. */ - ihw = fsmin(vga_pixels + pre_pixels - iho, (int)(720.0f / hscale)); - if (hsc < 0) - ihw = (int)fsmin(ihw, 253L * 128 / (-hsc)); - ihw &= ~1; - TRACE(("ihw = %u\n", ihw)) - houston_WriteReg(HOUSTON_IHA, ihw, 2); - - f = (((float)g_specs.h_total * g_specs.v_total) * 27.f) / - ((float)g_specs.tv_width * g_specs.tv_lines); - - TRACE(("freq=%u.%uMHz\n", (int)f, (int)((f - (int)f) * 1000))) + unsigned long vga_mode, + int overscan_x, int overscan_y, int pos_x, int pos_y) +{ + unsigned int vga_index; + unsigned long reg; + double vsc; + int k; + unsigned short ffolat, ivo; + int base_v_total, range, v_offset; + int v_total_min, v_total_max, v_step; + float r, f; + int vga_pixels, pre_pixels; + float hscale, hscale_min, hscale_max; + int hsc; + int iho, iho_max, ihw; + + /*tv_std is valid. */ + k = map_tvstd_to_index(tv_std); + + /*store tv width and lines */ + g_specs.tv_width = tvsetup.tv_width[k]; + g_specs.tv_lines = tvsetup.tv_lines[k]; + + /*determine vga mode index */ + for (vga_index = 0; vga_index < SCANTABLE_ENTRIES; vga_index++) { + if (scantable[vga_index].mode == vga_mode) + break; + } + if (vga_index >= SCANTABLE_ENTRIES) + return; + + /****/ + /*vertical scaling (v_total setup). */ + /****/ + /*calculate vertical range. */ + get_vtotal_min_max(vga_mode, tv_std, &v_total_min, &v_total_max, &v_step); + TRACE(("v_total min=%d, max=%d\n", v_total_min, v_total_max)) + base_v_total = scantable[vga_index].v_total[k]; + range = fsmax(base_v_total - v_total_min, v_total_max - base_v_total); + TRACE(("v_total range = %d\n", range)) + + /*map +/-1000 overscan y into +/-range. */ + v_offset = (int) ((((float) overscan_y * range) / 1000.f) + .5f); + TRACE(("v_offset = %d\n", v_offset)) + + /*range limit v_total. */ + g_specs.v_total = + range_limit(base_v_total + v_offset, v_total_min, v_total_max); + + /*round to calibrated value. */ + v_offset = (g_specs.v_total - v_total_min + (v_step / 2)) / v_step; + g_specs.v_total = v_total_min + v_offset * v_step; + TRACE(("desired v_total=%d\n", g_specs.v_total)) + + /****/ + /*vertical positioning (vsync setup). */ + /****/ + get_ffolat_ivo(vga_mode, tv_std, v_offset, &ffolat, &ivo); + houston_WriteReg(HOUSTON_IVO, ivo, 2); + + /*scale base sync offset by scaling ratio. */ + r = (float) g_specs.v_total / (float) base_v_total; + v_offset = (int) (r * (float) scantable[vga_index].v_sync[k]); + + /*scale ivo. */ + f = (float) ivo; + v_offset -= (int) (f - f / r); + + /*compensate for center screen. */ + f = (float) tvsetup.tv_active_lines[k] / 2.f; + v_offset += (int) (f * r - f); + + /*calculate vsync. */ + g_specs.v_sync = g_specs.v_total - v_offset + pos_y; + TRACE(("desired v_total=%d, desired v_sync=%d\n", g_specs.v_total, + g_specs.v_sync)) + if (g_specs.v_sync < g_specs.vga_lines + 10) { + TRACE(("vsync too low\n")) + /*//d.v_total += d.vga_lines+10-d.v_sync; */ + g_specs.v_sync = g_specs.vga_lines + 10; + } + else if (g_specs.v_sync > g_specs.v_total - 10) { + TRACE(("vsync too high\n")) + g_specs.v_sync = g_specs.v_total - 10; + } + TRACE(("v_total=%d v_sync=%d\n", g_specs.v_total, g_specs.v_sync)) + + /*FFOLAT. */ + houston_WriteReg(HOUSTON_FFO_LAT, ffolat, 2); + + /*VSC. */ + vsc = (65536.0f * + (1.0f - (double) g_specs.tv_lines / (double) g_specs.v_total)) + + 0.5f; + reg = ((unsigned long) -vsc) & 0xffff; + TRACE(("vsc=%04x, tv_lines=%d, v_total=%d\n", reg, g_specs.tv_lines, + g_specs.v_total)) + houston_WriteReg(HOUSTON_VSC, (int) reg, 2); + + /****/ + /*horizontal scaling. */ + /****/ + + /*vga pixels is vga width, except in 1024x768, where it's half that. */ + vga_pixels = g_specs.vga_width; + if (1024 == vga_pixels) + vga_pixels /= 2; + + /*maximum scaling coefficient is tv_width / vga_pixels */ + /*minimum is about 1/2, but that is quite small. arbitrarily set minimum at 75% maximum. */ + hscale_max = (720.0f / vga_pixels); + hscale_min = fsmax((0.75f * hscale_max), (1.0f - (63.0f / 128.0f))); + TRACE(("hscale_min = %u.%u, hscale_max = %u.%u\n", + (int) hscale_min, + (int) ((hscale_min - (int) hscale_min) * 1000), + (int) hscale_max, (int) ((hscale_max - (int) hscale_max) * 1000))) + + /*map overscan_x into min to max. */ + hscale = + hscale_min + ((overscan_x + 1000.0f) / 2000.0f) * (hscale_max - + hscale_min); + TRACE(("hscale = %u.%u\n", (int) hscale, + (int) ((hscale - (int) hscale) * 1000))) + + /*determine hsc where hscale = (1 + hsc/128) */ + if (hscale >= 1.0f) + hsc = (int) (128.f * (hscale - 1.0f) + .5f); + else + hsc = (int) (128.f * (hscale - 1.0f) - .5f); + TRACE(("hsc = %d\n", hsc)) + if (hsc >= 0) + houston_WriteReg(HOUSTON_HSC, hsc << 8, 2); + else + houston_WriteReg(HOUSTON_HSC, hsc & 0xFF, 2); + + /*recalculate hscale for future formulas */ + hscale = 1.0f + (hsc / 128.0f); + TRACE(("recalculated hscale = %u.%u\n", (int) hscale, + (int) ((hscale - (int) hscale) * 1000))) + + /****/ + /*horizontal offset. */ + /****/ + /*place hsync 40 before halfway from vga_width to htotal */ + /*but not less than vga_width + 10 */ + g_specs.h_sync = + fsmax((g_specs.h_total + g_specs.vga_width) / 2 - 40, + g_specs.vga_width + 10); + /*also, make it even */ + g_specs.h_sync &= ~1; + TRACE(("hsync = %u\n", g_specs.h_sync)) + + /*iho range is 0 to iho_max. */ + /*iho_max is 2 * iho_center. */ + /*iho_center is pre_pixels - (tvwidth / hscale - vga pixels) / 2. */ + /*pre_pixels = (htotal - hsync) * (vga_pixels / vga_width) */ + /*note that the range is inverted also, because it specifies the number of pixels */ + /*to skip, or subtract. iho=0 maps to farthest right. */ + /*map -pos_x = +/-1000 into (0 to iho_max) */ + pre_pixels = + (int) ((long) (g_specs.h_total - g_specs.h_sync) * vga_pixels / + g_specs.vga_width); + iho_max = (2 * pre_pixels) - ((int) (720.0f / hscale + 0.5f) - vga_pixels); + TRACE(("iho_max = %u\n", iho_max)) + iho = + (int) range_limit(((long) (1000 - pos_x) * iho_max / 2000) + + scantable[vga_index].iho[k], 0, iho_max); + TRACE(("iho = %u\n", iho)) + houston_WriteReg(HOUSTON_IHO, iho, 2); + + /****/ + /*input horizontal width. */ + /****/ + + /*input horizontal width is vga pixels + pre_pixels - iho */ + /*additionally, ihw cannot exceed tv width / hscale */ + /*and if hsc is negative, (ihw)(-hsc/128) cannot exceed ~250. */ + /*and ihw should be even. */ + ihw = fsmin(vga_pixels + pre_pixels - iho, (int) (720.0f / hscale)); + if (hsc < 0) + ihw = (int) fsmin(ihw, 253L * 128 / (-hsc)); + ihw &= ~1; + TRACE(("ihw = %u\n", ihw)) + houston_WriteReg(HOUSTON_IHA, ihw, 2); + + f = (((float) g_specs.h_total * g_specs.v_total) * 27.f) / + ((float) g_specs.tv_width * g_specs.tv_lines); + + TRACE(("freq=%u.%uMHz\n", (int) f, (int) ((f - (int) f) * 1000))) } /*==========================================================================*/ @@ -2654,77 +2645,78 @@ config_overscan_xy(unsigned long tv_std, static void config_nco(unsigned long tv_std, unsigned long vga_mode) { - unsigned long cr, misc; - unsigned long reg; - int k = map_tvstd_to_index(tv_std); - - /*read and store CR. */ - houston_ReadReg(HOUSTON_CR, &cr, 2); - - /*make sure NCO_EN (enable latch) bit is clear */ - cr &= ~CR_NCO_EN; - houston_WriteReg(HOUSTON_CR, cr, 2); - - /*clear NCO_LOADX. */ - houston_ReadReg(HOUSTON_MISC, &misc, 2); - misc &= ~(MISC_NCO_LOAD1 + MISC_NCO_LOAD0); - houston_WriteReg(HOUSTON_MISC, misc, 2); - - if (vga_mode == GFX_VGA_MODE_1024X768) { - /*setup for M and N load (Nco_load=1). */ - misc |= (MISC_NCO_LOAD0); - houston_WriteReg(HOUSTON_MISC, misc, 2); - - /*M and N. */ - houston_WriteReg(HOUSTON_NCONL, 1024 - 2, 2); - houston_WriteReg(HOUSTON_NCODL, 128 - 1, 2); - - /*latch M/N in. */ - cr |= CR_NCO_EN; - houston_WriteReg(HOUSTON_CR, cr, 2); - cr &= ~CR_NCO_EN; - houston_WriteReg(HOUSTON_CR, cr, 2); - - /*setup ncon and ncod load (Nco_load=0). */ - misc &= ~(MISC_NCO_LOAD1 + MISC_NCO_LOAD0); - houston_WriteReg(HOUSTON_MISC, misc, 2); - - /*NCON. */ - reg = ((unsigned long)g_specs.v_total * g_specs.h_total) / 2; - houston_WriteReg(HOUSTON_NCONH, reg >> 16, 2); - houston_WriteReg(HOUSTON_NCONL, reg & 0xffff, 2); - - /*NCOD. */ - houston_WriteReg(HOUSTON_NCODL, tvsetup.houston_ncodl[k], 2); - houston_WriteReg(HOUSTON_NCODH, tvsetup.houston_ncodh[k], 2); - } else { - /*setup for M and N load (Nco_load=2). */ - misc |= (MISC_NCO_LOAD1); - houston_WriteReg(HOUSTON_MISC, misc, 2); - - /*NCON. */ - reg = (unsigned long)g_specs.v_total * g_specs.h_total; - houston_WriteReg(HOUSTON_NCONH, reg >> 16, 2); - houston_WriteReg(HOUSTON_NCONL, reg & 0xffff, 2); - - /*NCOD. */ - houston_WriteReg(HOUSTON_NCODL, tvsetup.houston_ncodl[k], 2); - houston_WriteReg(HOUSTON_NCODH, tvsetup.houston_ncodh[k], 2); - - TRACE(("NCON = %lu (0x%08lx), NCOD = %lu (0x%08lx)\n", - reg, - reg, - ((unsigned long)tvsetup.houston_ncodh[k] << 16) + - tvsetup.houston_ncodl[k], - ((unsigned long)tvsetup.houston_ncodh[k] << 16) + - tvsetup.houston_ncodl[k])) - } - - /*latch M/N and NCON/NCOD in. */ - cr |= CR_NCO_EN; - houston_WriteReg(HOUSTON_CR, cr, 2); - cr &= ~CR_NCO_EN; - houston_WriteReg(HOUSTON_CR, cr, 2); + unsigned long cr, misc; + unsigned long reg; + int k = map_tvstd_to_index(tv_std); + + /*read and store CR. */ + houston_ReadReg(HOUSTON_CR, &cr, 2); + + /*make sure NCO_EN (enable latch) bit is clear */ + cr &= ~CR_NCO_EN; + houston_WriteReg(HOUSTON_CR, cr, 2); + + /*clear NCO_LOADX. */ + houston_ReadReg(HOUSTON_MISC, &misc, 2); + misc &= ~(MISC_NCO_LOAD1 + MISC_NCO_LOAD0); + houston_WriteReg(HOUSTON_MISC, misc, 2); + + if (vga_mode == GFX_VGA_MODE_1024X768) { + /*setup for M and N load (Nco_load=1). */ + misc |= (MISC_NCO_LOAD0); + houston_WriteReg(HOUSTON_MISC, misc, 2); + + /*M and N. */ + houston_WriteReg(HOUSTON_NCONL, 1024 - 2, 2); + houston_WriteReg(HOUSTON_NCODL, 128 - 1, 2); + + /*latch M/N in. */ + cr |= CR_NCO_EN; + houston_WriteReg(HOUSTON_CR, cr, 2); + cr &= ~CR_NCO_EN; + houston_WriteReg(HOUSTON_CR, cr, 2); + + /*setup ncon and ncod load (Nco_load=0). */ + misc &= ~(MISC_NCO_LOAD1 + MISC_NCO_LOAD0); + houston_WriteReg(HOUSTON_MISC, misc, 2); + + /*NCON. */ + reg = ((unsigned long) g_specs.v_total * g_specs.h_total) / 2; + houston_WriteReg(HOUSTON_NCONH, reg >> 16, 2); + houston_WriteReg(HOUSTON_NCONL, reg & 0xffff, 2); + + /*NCOD. */ + houston_WriteReg(HOUSTON_NCODL, tvsetup.houston_ncodl[k], 2); + houston_WriteReg(HOUSTON_NCODH, tvsetup.houston_ncodh[k], 2); + } + else { + /*setup for M and N load (Nco_load=2). */ + misc |= (MISC_NCO_LOAD1); + houston_WriteReg(HOUSTON_MISC, misc, 2); + + /*NCON. */ + reg = (unsigned long) g_specs.v_total * g_specs.h_total; + houston_WriteReg(HOUSTON_NCONH, reg >> 16, 2); + houston_WriteReg(HOUSTON_NCONL, reg & 0xffff, 2); + + /*NCOD. */ + houston_WriteReg(HOUSTON_NCODL, tvsetup.houston_ncodl[k], 2); + houston_WriteReg(HOUSTON_NCODH, tvsetup.houston_ncodh[k], 2); + + TRACE(("NCON = %lu (0x%08lx), NCOD = %lu (0x%08lx)\n", + reg, + reg, + ((unsigned long) tvsetup.houston_ncodh[k] << 16) + + tvsetup.houston_ncodl[k], + ((unsigned long) tvsetup.houston_ncodh[k] << 16) + + tvsetup.houston_ncodl[k])) + } + + /*latch M/N and NCON/NCOD in. */ + cr |= CR_NCO_EN; + houston_WriteReg(HOUSTON_CR, cr, 2); + cr &= ~CR_NCO_EN; + houston_WriteReg(HOUSTON_CR, cr, 2); } /*==========================================================================*/ @@ -2734,27 +2726,27 @@ config_nco(unsigned long tv_std, unsigned long vga_mode) static void config_sharpness(int sharpness) { - unsigned int shp; + unsigned int shp; - /*map 0-1000 to 0-20. */ - shp = (unsigned int)(0.5f + ((float)sharpness * 20.0f / 1000.0f)); - shp = range_limit(shp, 0, 20); + /*map 0-1000 to 0-20. */ + shp = (unsigned int) (0.5f + ((float) sharpness * 20.0f / 1000.0f)); + shp = range_limit(shp, 0, 20); - houston_WriteReg(HOUSTON_SHP, shp, 2); + houston_WriteReg(HOUSTON_SHP, shp, 2); } static void conget_sharpness(int *p_sharpness) { - unsigned long shp; + unsigned long shp; - if (!p_sharpness) - return; + if (!p_sharpness) + return; - houston_ReadReg(HOUSTON_SHP, &shp, 2); + houston_ReadReg(HOUSTON_SHP, &shp, 2); - /*map 0-20 to 0-1000. */ - *p_sharpness = (int)(0.5f + ((float)shp * 1000.0f / 20.0f)); + /*map 0-20 to 0-1000. */ + *p_sharpness = (int) (0.5f + ((float) shp * 1000.0f / 20.0f)); } /*==========================================================================*/ @@ -2764,27 +2756,27 @@ conget_sharpness(int *p_sharpness) static void config_flicker(int flicker) { - unsigned int flk; + unsigned int flk; - /*map 0-1000 to 0-16. */ - flk = (unsigned int)(0.5f + ((float)flicker * 16.0f / 1000.0f)); - flk = range_limit(flk, 0, 16); + /*map 0-1000 to 0-16. */ + flk = (unsigned int) (0.5f + ((float) flicker * 16.0f / 1000.0f)); + flk = range_limit(flk, 0, 16); - houston_WriteReg(HOUSTON_FLK, flk, 2); + houston_WriteReg(HOUSTON_FLK, flk, 2); } static void conget_flicker(int *p_flicker) { - unsigned long flk; + unsigned long flk; - if (!p_flicker) - return; + if (!p_flicker) + return; - houston_ReadReg(HOUSTON_FLK, &flk, 2); + houston_ReadReg(HOUSTON_FLK, &flk, 2); - /*map 0-16 to 0-1000. */ - *p_flicker = (int)(0.5f + ((float)flk * 1000.0f / 16.0f)); + /*map 0-16 to 0-1000. */ + *p_flicker = (int) (0.5f + ((float) flk * 1000.0f / 16.0f)); } /*==========================================================================*/ @@ -2794,31 +2786,31 @@ conget_flicker(int *p_flicker) static void config_color(int color) { - unsigned long clr; + unsigned long clr; - /*map 0-100 to 0-255. */ - /*montreal production test needs 169 to be mappable, so */ - /*use .8 rounding factor, 169=(int)(66.*2.55+.8). */ - clr = (unsigned long)(0.8f + ((float)color * 255.0f / 100.0f)); - clr = range_limit(clr, 0, 255); + /*map 0-100 to 0-255. */ + /*montreal production test needs 169 to be mappable, so */ + /*use .8 rounding factor, 169=(int)(66.*2.55+.8). */ + clr = (unsigned long) (0.8f + ((float) color * 255.0f / 100.0f)); + clr = range_limit(clr, 0, 255); - houston_WriteReg(ENC_CR_GAIN, clr, 1); - houston_WriteReg(ENC_CB_GAIN, clr, 1); + houston_WriteReg(ENC_CR_GAIN, clr, 1); + houston_WriteReg(ENC_CB_GAIN, clr, 1); } static void conget_color(int *p_color) { - unsigned long cr_gain; + unsigned long cr_gain; - if (!p_color) - return; + if (!p_color) + return; - /*just get CR GAIN, CB GAIN should match. */ - houston_ReadReg(ENC_CR_GAIN, &cr_gain, 1); + /*just get CR GAIN, CB GAIN should match. */ + houston_ReadReg(ENC_CR_GAIN, &cr_gain, 1); - /*map 0-255 to 0-100. */ - *p_color = (int)(0.5f + ((float)cr_gain * 100.0f / 255.0f)); + /*map 0-255 to 0-100. */ + *p_color = (int) (0.5f + ((float) cr_gain * 100.0f / 255.0f)); } /*==========================================================================*/ @@ -2832,90 +2824,89 @@ static const int max_white_level = 1023; static void config_brightness_contrast(unsigned long tv_std, unsigned int trigger_bits, - int brightness, int contrast) + int brightness, int contrast) { - int brightness_off; - float contrast_mult; - int black, white; - unsigned short w; - int k = map_tvstd_to_index(tv_std); + int brightness_off; + float contrast_mult; + int black, white; + unsigned short w; + int k = map_tvstd_to_index(tv_std); - /*0-100 maps to +/-220. */ - brightness_off = (int)(0.5f + ((float)brightness * 440.0f / 100.0f)) - 220; + /*0-100 maps to +/-220. */ + brightness_off = + (int) (0.5f + ((float) brightness * 440.0f / 100.0f)) - 220; - /*0-100 maps to .75-1.25. */ - contrast_mult = ((float)contrast * 0.5f / 100.0f) + 0.75f; + /*0-100 maps to .75-1.25. */ + contrast_mult = ((float) contrast * 0.5f / 100.0f) + 0.75f; - black = tvsetup.black_level[k]; - if (trigger_bits != 0) - black -= tvsetup.hamp_offset[k]; + black = tvsetup.black_level[k]; + if (trigger_bits != 0) + black -= tvsetup.hamp_offset[k]; - white = tvsetup.white_level[k]; - if (trigger_bits != 0) - white -= tvsetup.hamp_offset[k]; + white = tvsetup.white_level[k]; + if (trigger_bits != 0) + white -= tvsetup.hamp_offset[k]; - black = (int)((float)(black + brightness_off) * contrast_mult); - white = (int)((float)(white + brightness_off) * contrast_mult); - if (black < min_black_level) - black = min_black_level; - if (white > max_white_level) - white = max_white_level; + black = (int) ((float) (black + brightness_off) * contrast_mult); + white = (int) ((float) (white + brightness_off) * contrast_mult); + if (black < min_black_level) + black = min_black_level; + if (white > max_white_level) + white = max_white_level; - w = w10bit2z((unsigned short)black); - houston_WriteReg(ENC_BLACK_LEVEL, w & 0x00ff, 1); - houston_WriteReg(ENC_BLACK_LEVEL + 1, w >> 8, 1); - w = w10bit2z((unsigned short)white); - houston_WriteReg(ENC_WHITE_LEVEL, w & 0x00ff, 1); - houston_WriteReg(ENC_WHITE_LEVEL + 1, w >> 8, 1); + w = w10bit2z((unsigned short) black); + houston_WriteReg(ENC_BLACK_LEVEL, w & 0x00ff, 1); + houston_WriteReg(ENC_BLACK_LEVEL + 1, w >> 8, 1); + w = w10bit2z((unsigned short) white); + houston_WriteReg(ENC_WHITE_LEVEL, w & 0x00ff, 1); + houston_WriteReg(ENC_WHITE_LEVEL + 1, w >> 8, 1); } static void conget_brightness_contrast(unsigned long tv_std, unsigned int trigger_bits, - int *p_brightness, int *p_contrast) -{ - int brightness_off; - float contrast_mult; - unsigned short black, white; - unsigned long zh, zl; - int k; - - if (!p_brightness || !p_contrast) - return; - - k = map_tvstd_to_index(tv_std); - - houston_ReadReg(ENC_BLACK_LEVEL, &zl, 1); - houston_ReadReg(ENC_BLACK_LEVEL + 1, &zh, 1); - black = z2w10bit((unsigned short)(zl + (zh << 8))); - if (trigger_bits != 0) - black += tvsetup.hamp_offset[k]; - houston_ReadReg(ENC_WHITE_LEVEL, &zl, 1); - houston_ReadReg(ENC_WHITE_LEVEL + 1, &zh, 1); - white = z2w10bit((unsigned short)(zl + (zh << 8))); - if (trigger_bits != 0) - white += tvsetup.hamp_offset[k]; - - /*this reverse computation does not account for clipping, but should */ - /*provide somewhat reasonable numbers */ - contrast_mult = - ((float)white - (float)black) / ((float)tvsetup.white_level[k] - - (float)tvsetup.black_level[k]); - brightness_off = - (int)(((float)black / contrast_mult) - tvsetup.black_level[k]); - - /*+/-220 maps to 0-100. */ - *p_brightness = - range_limit((int) - (0.5f + - ((float)(brightness_off + 220) * 100.0f / 440.0f)), 0, - 100); - - /*.75-1.25 maps to 0-100. */ - *p_contrast = - range_limit((int) - (0.5f + - ((float)(contrast_mult - 0.75f) * 100.0f / 0.5f)), 0, - 100); + int *p_brightness, int *p_contrast) +{ + int brightness_off; + float contrast_mult; + unsigned short black, white; + unsigned long zh, zl; + int k; + + if (!p_brightness || !p_contrast) + return; + + k = map_tvstd_to_index(tv_std); + + houston_ReadReg(ENC_BLACK_LEVEL, &zl, 1); + houston_ReadReg(ENC_BLACK_LEVEL + 1, &zh, 1); + black = z2w10bit((unsigned short) (zl + (zh << 8))); + if (trigger_bits != 0) + black += tvsetup.hamp_offset[k]; + houston_ReadReg(ENC_WHITE_LEVEL, &zl, 1); + houston_ReadReg(ENC_WHITE_LEVEL + 1, &zh, 1); + white = z2w10bit((unsigned short) (zl + (zh << 8))); + if (trigger_bits != 0) + white += tvsetup.hamp_offset[k]; + + /*this reverse computation does not account for clipping, but should */ + /*provide somewhat reasonable numbers */ + contrast_mult = + ((float) white - (float) black) / ((float) tvsetup.white_level[k] - + (float) tvsetup.black_level[k]); + brightness_off = + (int) (((float) black / contrast_mult) - tvsetup.black_level[k]); + + /*+/-220 maps to 0-100. */ + *p_brightness = range_limit((int) + (0.5f + + ((float) (brightness_off + 220) * 100.0f / + 440.0f)), 0, 100); + + /*.75-1.25 maps to 0-100. */ + *p_contrast = range_limit((int) + (0.5f + + ((float) (contrast_mult - 0.75f) * 100.0f / + 0.5f)), 0, 100); } /*==========================================================================*/ @@ -2925,54 +2916,55 @@ conget_brightness_contrast(unsigned long tv_std, unsigned int trigger_bits, static void config_yc_filter(unsigned long tv_std, int luma_filter, int chroma_filter) { - unsigned long reg, reg07, reg34; - - if (houston_Rev() < HOUSTON_REV_B) - return; - - /*luma filter. */ - if (luma_filter) - reg = tvsetup.notch_filter[map_tvstd_to_index(tv_std)]; - else - reg = 0; - houston_WriteReg(ENC_NOTCH_FILTER, reg, 1); - - /*chroma filter. */ - houston_ReadReg(ENC_REG07, ®07, 1); - houston_ReadReg(ENC_REG34, ®34, 1); - if (chroma_filter) { - reg07 &= ~0x08; - reg34 &= ~0x20; - } else { - reg07 |= 0x08; - reg34 |= 0x20; - } - houston_WriteReg(ENC_REG07, reg07, 1); - houston_WriteReg(ENC_REG34, reg34, 1); + unsigned long reg, reg07, reg34; + + if (houston_Rev() < HOUSTON_REV_B) + return; + + /*luma filter. */ + if (luma_filter) + reg = tvsetup.notch_filter[map_tvstd_to_index(tv_std)]; + else + reg = 0; + houston_WriteReg(ENC_NOTCH_FILTER, reg, 1); + + /*chroma filter. */ + houston_ReadReg(ENC_REG07, ®07, 1); + houston_ReadReg(ENC_REG34, ®34, 1); + if (chroma_filter) { + reg07 &= ~0x08; + reg34 &= ~0x20; + } + else { + reg07 |= 0x08; + reg34 |= 0x20; + } + houston_WriteReg(ENC_REG07, reg07, 1); + houston_WriteReg(ENC_REG34, reg34, 1); } static void conget_yc_filter(int *p_luma_filter, int *p_chroma_filter) { - unsigned long reg, reg07, reg34; + unsigned long reg, reg07, reg34; - if (!p_luma_filter || !p_chroma_filter) - return; + if (!p_luma_filter || !p_chroma_filter) + return; - if (houston_Rev() < HOUSTON_REV_B) { - *p_luma_filter = 0; - *p_chroma_filter = 0; - return; - } + if (houston_Rev() < HOUSTON_REV_B) { + *p_luma_filter = 0; + *p_chroma_filter = 0; + return; + } - /*luma filter. */ - houston_ReadReg(ENC_NOTCH_FILTER, ®, 1); - *p_luma_filter = (reg ? 1 : 0); + /*luma filter. */ + houston_ReadReg(ENC_NOTCH_FILTER, ®, 1); + *p_luma_filter = (reg ? 1 : 0); - /*chroma filter. */ - houston_ReadReg(ENC_REG07, ®07, 1); - houston_ReadReg(ENC_REG34, ®34, 1); - *p_chroma_filter = !((0x08 & reg07) || (0x20 & reg34)); + /*chroma filter. */ + houston_ReadReg(ENC_REG07, ®07, 1); + houston_ReadReg(ENC_REG34, ®34, 1); + *p_chroma_filter = !((0x08 & reg07) || (0x20 & reg34)); } /*==========================================================================*/ @@ -2985,250 +2977,252 @@ config_macrovision(unsigned long tv_std, unsigned int trigger_bits) /****/ /*Constants to index into mvsetup columns.*/ /****/ -#define nNTSC_APS00 0 /*ntsc mv off. */ -#define nNTSC_APS01 1 /*ntsc AGC only. */ -#define nNTSC_APS10 2 /*ntsc AGC + 2-line CS. */ -#define nNTSC_APS11 3 /*ntsc AGC + 4-line CS. */ -#define nPAL_APS00 4 /*pal mv off. */ -#define nPAL_APSXX 5 /*pal mv on. */ +#define nNTSC_APS00 0 /*ntsc mv off. */ +#define nNTSC_APS01 1 /*ntsc AGC only. */ +#define nNTSC_APS10 2 /*ntsc AGC + 2-line CS. */ +#define nNTSC_APS11 3 /*ntsc AGC + 4-line CS. */ +#define nPAL_APS00 4 /*pal mv off. */ +#define nPAL_APSXX 5 /*pal mv on. */ #define nMVModes 6 /****/ /*Macrovision setup table.*/ /****/ - static const struct mvparms - { - unsigned short n0[nMVModes]; - unsigned short n1[nMVModes]; - unsigned short n2[nMVModes]; - unsigned short n3[nMVModes]; - unsigned short n4[nMVModes]; - unsigned short n5[nMVModes]; - unsigned short n6[nMVModes]; - unsigned short n7[nMVModes]; - unsigned short n8[nMVModes]; - unsigned short n9[nMVModes]; - unsigned short n10[nMVModes]; - unsigned short n11[nMVModes]; - unsigned short n12[nMVModes]; - unsigned short n13[nMVModes]; - unsigned short n14[nMVModes]; - unsigned short n15[nMVModes]; - unsigned short n16[nMVModes]; - unsigned short n17[nMVModes]; - unsigned short n18[nMVModes]; - unsigned short n19[nMVModes]; - unsigned short n20[nMVModes]; - unsigned short n21[nMVModes]; - unsigned short n22[nMVModes]; - unsigned short agc_pulse_level[nMVModes]; - unsigned short bp_pulse_level[nMVModes]; - } - - mvsetup = - { /*// ntsc ntsc ntsc ntsc pal pal */ - /*// MV AGC AGC + AGC + MV MV */ - /*// off. only 2-line 4-line off. on. */ - /*// CS. CS. */ - { - 0x00, 0x36, 0x3e, 0x3e, 0x00, 0x3e} - , /*n0 */ - { - 0x1d, 0x1d, 0x1d, 0x17, 0x1a, 0x1a} - , /*n1 */ - { - 0x11, 0x11, 0x11, 0x15, 0x22, 0x22} - , /*n2 */ - { - 0x25, 0x25, 0x25, 0x21, 0x2a, 0x2a} - , /*n3 */ - { - 0x11, 0x11, 0x11, 0x15, 0x22, 0x22} - , /*n4 */ - { - 0x01, 0x01, 0x01, 0x05, 0x05, 0x05} - , /*n5 */ - { - 0x07, 0x07, 0x07, 0x05, 0x02, 0x02} - , /*n6 */ - { - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00} - , /*n7 */ - { - 0x1b, 0x1b, 0x1b, 0x1b, 0x1c, 0x1c} - , /*n8 */ - { - 0x1b, 0x1b, 0x1b, 0x1b, 0x3d, 0x3d} - , /*n9 */ - { - 0x24, 0x24, 0x24, 0x24, 0x14, 0x14} - , /*n10 */ - { - 0x780f, 0x780f, 0x780f, 0x780f, 0x7e07, 0x7e07} - , /*n11 */ - { - 0x0000, 0x0000, 0x0000, 0x0000, 0x5402, 0x5402} - , /*n12 */ - { - 0x0f, 0x0f, 0x0f, 0x0f, 0xfe, 0xfe} - , /*n13 */ - { - 0x0f, 0x0f, 0x0f, 0x0f, 0x7e, 0x7e} - , /*n14 */ - { - 0x60, 0x60, 0x60, 0x60, 0x60, 0x60} - , /*n15 */ - { - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00} - , /*n16 */ - { - 0x0a, 0x0a, 0x0a, 0x0a, 0x08, 0x08} - , /*n17 */ - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - , /*n18 */ - { - 0x05, 0x05, 0x05, 0x05, 0x04, 0x04} - , /*n19 */ - { - 0x04, 0x04, 0x04, 0x04, 0x07, 0x07} - , /*n20 */ - { - 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x0155, 0x0155} - , /*n21 */ - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - , /*n22 */ - { - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3} - , /*agc_pulse_level */ - { - 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8} - , /*bp_pulse_level */ - }; - - int nMode; - unsigned long misc; - unsigned short n0; - - trigger_bits &= 0x3; - - /*Determine the OEM Macrovision Program Mode and Register 0 Data. */ - if (IS_NTSC(tv_std)) { - /*NTSC TV Standard. */ - if (trigger_bits == 0) { - /*turn Macrovision OFF. */ - nMode = nNTSC_APS00; - } else if (trigger_bits == 1) { - /*AGC Only. */ - nMode = nNTSC_APS01; - } else if (trigger_bits == 2) { - /*AGC + 2-line CS. */ - nMode = nNTSC_APS10; - } else { - /*AGC + 4-line CS. */ - nMode = nNTSC_APS11; - } - } else { - /*PAL TV Standard. */ - if (trigger_bits == 0) { - /*turn Macrovision OFF. */ - nMode = nPAL_APS00; - } else { - /*APS 01, 10, or 11. */ - nMode = nPAL_APSXX; - } - } - - /*Retrieve the Macrovision Program Mode Data */ - if (tv_std != GFX_TV_STANDARD_PAL_M) - n0 = mvsetup.n0[nMode]; - else { - /*PAL-M sets up like NTSC except for n0. */ - if ((trigger_bits & 0x03) == 0) - n0 = mvsetup.n0[nPAL_APS00]; - else - n0 = mvsetup.n0[nPAL_APSXX]; - } - - /*download settings now. */ - houston_WriteReg(MV_N0, n0, 1); - houston_WriteReg(MV_N1, mvsetup.n1[nMode], 1); - houston_WriteReg(MV_N2, mvsetup.n2[nMode], 1); - houston_WriteReg(MV_N3, mvsetup.n3[nMode], 1); - houston_WriteReg(MV_N4, mvsetup.n4[nMode], 1); - houston_WriteReg(MV_N5, mvsetup.n5[nMode], 1); - houston_WriteReg(MV_N6, mvsetup.n6[nMode], 1); - houston_WriteReg(MV_N7, mvsetup.n7[nMode], 1); - houston_WriteReg(MV_N8, mvsetup.n8[nMode], 1); - houston_WriteReg(MV_N9, mvsetup.n9[nMode], 1); - houston_WriteReg(MV_N10, mvsetup.n10[nMode], 1); - houston_WriteReg(MV_N11, mvsetup.n11[nMode] & 0xff, 1); - houston_WriteReg(MV_N11 + 1, mvsetup.n11[nMode] >> 8, 1); - houston_WriteReg(MV_N12, mvsetup.n12[nMode] & 0xff, 1); - houston_WriteReg(MV_N12 + 1, mvsetup.n12[nMode] >> 8, 1); - houston_WriteReg(MV_N13, mvsetup.n13[nMode], 1); - houston_WriteReg(MV_N14, mvsetup.n14[nMode], 1); - houston_WriteReg(MV_N15, mvsetup.n15[nMode], 1); - houston_WriteReg(MV_N16, mvsetup.n16[nMode], 1); - houston_WriteReg(MV_N17, mvsetup.n17[nMode], 1); - houston_WriteReg(MV_N18, mvsetup.n18[nMode], 1); - houston_WriteReg(MV_N19, mvsetup.n19[nMode], 1); - houston_WriteReg(MV_N20, mvsetup.n20[nMode], 1); - houston_WriteReg(MV_N21, mvsetup.n21[nMode] & 0xff, 1); - houston_WriteReg(MV_N21 + 1, mvsetup.n21[nMode] >> 8, 1); - houston_WriteReg(MV_N22, mvsetup.n22[nMode], 1); - houston_WriteReg(MV_AGC_PULSE_LEVEL, mvsetup.agc_pulse_level[nMode], 1); - houston_WriteReg(MV_BP_PULSE_LEVEL, mvsetup.bp_pulse_level[nMode], 1); - - houston_ReadReg(HOUSTON_MISC, &misc, 2); - if (trigger_bits == 0) - misc &= ~MISC_MV_SOFT_EN; - else - misc |= MISC_MV_SOFT_EN; - houston_WriteReg(HOUSTON_MISC, misc, 2); + static const struct mvparms { + unsigned short n0[nMVModes]; + unsigned short n1[nMVModes]; + unsigned short n2[nMVModes]; + unsigned short n3[nMVModes]; + unsigned short n4[nMVModes]; + unsigned short n5[nMVModes]; + unsigned short n6[nMVModes]; + unsigned short n7[nMVModes]; + unsigned short n8[nMVModes]; + unsigned short n9[nMVModes]; + unsigned short n10[nMVModes]; + unsigned short n11[nMVModes]; + unsigned short n12[nMVModes]; + unsigned short n13[nMVModes]; + unsigned short n14[nMVModes]; + unsigned short n15[nMVModes]; + unsigned short n16[nMVModes]; + unsigned short n17[nMVModes]; + unsigned short n18[nMVModes]; + unsigned short n19[nMVModes]; + unsigned short n20[nMVModes]; + unsigned short n21[nMVModes]; + unsigned short n22[nMVModes]; + unsigned short agc_pulse_level[nMVModes]; + unsigned short bp_pulse_level[nMVModes]; + } mvsetup = { /*// ntsc ntsc ntsc ntsc pal pal */ + /*// MV AGC AGC + AGC + MV MV */ + /*// off. only 2-line 4-line off. on. */ + /*// CS. CS. */ + { + 0x00, 0x36, 0x3e, 0x3e, 0x00, 0x3e} + , /*n0 */ + { + 0x1d, 0x1d, 0x1d, 0x17, 0x1a, 0x1a} + , /*n1 */ + { + 0x11, 0x11, 0x11, 0x15, 0x22, 0x22} + , /*n2 */ + { + 0x25, 0x25, 0x25, 0x21, 0x2a, 0x2a} + , /*n3 */ + { + 0x11, 0x11, 0x11, 0x15, 0x22, 0x22} + , /*n4 */ + { + 0x01, 0x01, 0x01, 0x05, 0x05, 0x05} + , /*n5 */ + { + 0x07, 0x07, 0x07, 0x05, 0x02, 0x02} + , /*n6 */ + { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00} + , /*n7 */ + { + 0x1b, 0x1b, 0x1b, 0x1b, 0x1c, 0x1c} + , /*n8 */ + { + 0x1b, 0x1b, 0x1b, 0x1b, 0x3d, 0x3d} + , /*n9 */ + { + 0x24, 0x24, 0x24, 0x24, 0x14, 0x14} + , /*n10 */ + { + 0x780f, 0x780f, 0x780f, 0x780f, 0x7e07, 0x7e07} + , /*n11 */ + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x5402, 0x5402} + , /*n12 */ + { + 0x0f, 0x0f, 0x0f, 0x0f, 0xfe, 0xfe} + , /*n13 */ + { + 0x0f, 0x0f, 0x0f, 0x0f, 0x7e, 0x7e} + , /*n14 */ + { + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60} + , /*n15 */ + { + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00} + , /*n16 */ + { + 0x0a, 0x0a, 0x0a, 0x0a, 0x08, 0x08} + , /*n17 */ + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + , /*n18 */ + { + 0x05, 0x05, 0x05, 0x05, 0x04, 0x04} + , /*n19 */ + { + 0x04, 0x04, 0x04, 0x04, 0x07, 0x07} + , /*n20 */ + { + 0x03ff, 0x03ff, 0x03ff, 0x03ff, 0x0155, 0x0155} + , /*n21 */ + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + , /*n22 */ + { + 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3} + , /*agc_pulse_level */ + { + 0xc8, 0xc8, 0xc8, 0xc8, 0xc8, 0xc8} + , /*bp_pulse_level */ + }; + + int nMode; + unsigned long misc; + unsigned short n0; + + trigger_bits &= 0x3; + + /*Determine the OEM Macrovision Program Mode and Register 0 Data. */ + if (IS_NTSC(tv_std)) { + /*NTSC TV Standard. */ + if (trigger_bits == 0) { + /*turn Macrovision OFF. */ + nMode = nNTSC_APS00; + } + else if (trigger_bits == 1) { + /*AGC Only. */ + nMode = nNTSC_APS01; + } + else if (trigger_bits == 2) { + /*AGC + 2-line CS. */ + nMode = nNTSC_APS10; + } + else { + /*AGC + 4-line CS. */ + nMode = nNTSC_APS11; + } + } + else { + /*PAL TV Standard. */ + if (trigger_bits == 0) { + /*turn Macrovision OFF. */ + nMode = nPAL_APS00; + } + else { + /*APS 01, 10, or 11. */ + nMode = nPAL_APSXX; + } + } + + /*Retrieve the Macrovision Program Mode Data */ + if (tv_std != GFX_TV_STANDARD_PAL_M) + n0 = mvsetup.n0[nMode]; + else { + /*PAL-M sets up like NTSC except for n0. */ + if ((trigger_bits & 0x03) == 0) + n0 = mvsetup.n0[nPAL_APS00]; + else + n0 = mvsetup.n0[nPAL_APSXX]; + } + + /*download settings now. */ + houston_WriteReg(MV_N0, n0, 1); + houston_WriteReg(MV_N1, mvsetup.n1[nMode], 1); + houston_WriteReg(MV_N2, mvsetup.n2[nMode], 1); + houston_WriteReg(MV_N3, mvsetup.n3[nMode], 1); + houston_WriteReg(MV_N4, mvsetup.n4[nMode], 1); + houston_WriteReg(MV_N5, mvsetup.n5[nMode], 1); + houston_WriteReg(MV_N6, mvsetup.n6[nMode], 1); + houston_WriteReg(MV_N7, mvsetup.n7[nMode], 1); + houston_WriteReg(MV_N8, mvsetup.n8[nMode], 1); + houston_WriteReg(MV_N9, mvsetup.n9[nMode], 1); + houston_WriteReg(MV_N10, mvsetup.n10[nMode], 1); + houston_WriteReg(MV_N11, mvsetup.n11[nMode] & 0xff, 1); + houston_WriteReg(MV_N11 + 1, mvsetup.n11[nMode] >> 8, 1); + houston_WriteReg(MV_N12, mvsetup.n12[nMode] & 0xff, 1); + houston_WriteReg(MV_N12 + 1, mvsetup.n12[nMode] >> 8, 1); + houston_WriteReg(MV_N13, mvsetup.n13[nMode], 1); + houston_WriteReg(MV_N14, mvsetup.n14[nMode], 1); + houston_WriteReg(MV_N15, mvsetup.n15[nMode], 1); + houston_WriteReg(MV_N16, mvsetup.n16[nMode], 1); + houston_WriteReg(MV_N17, mvsetup.n17[nMode], 1); + houston_WriteReg(MV_N18, mvsetup.n18[nMode], 1); + houston_WriteReg(MV_N19, mvsetup.n19[nMode], 1); + houston_WriteReg(MV_N20, mvsetup.n20[nMode], 1); + houston_WriteReg(MV_N21, mvsetup.n21[nMode] & 0xff, 1); + houston_WriteReg(MV_N21 + 1, mvsetup.n21[nMode] >> 8, 1); + houston_WriteReg(MV_N22, mvsetup.n22[nMode], 1); + houston_WriteReg(MV_AGC_PULSE_LEVEL, mvsetup.agc_pulse_level[nMode], 1); + houston_WriteReg(MV_BP_PULSE_LEVEL, mvsetup.bp_pulse_level[nMode], 1); + + houston_ReadReg(HOUSTON_MISC, &misc, 2); + if (trigger_bits == 0) + misc &= ~MISC_MV_SOFT_EN; + else + misc |= MISC_MV_SOFT_EN; + houston_WriteReg(HOUSTON_MISC, misc, 2); } static void conget_macrovision(unsigned long tv_std, unsigned int *p_cp_trigger_bits) { - unsigned long n0, n1; - - if (!p_cp_trigger_bits) - return; - - houston_ReadReg(MV_N0, &n0, 1); - houston_ReadReg(MV_N1, &n1, 1); - - *p_cp_trigger_bits = 0; - - if (IS_NTSC(tv_std)) { - switch (n0) { - case 0: - *p_cp_trigger_bits = 0; - break; - - case 0x36: - *p_cp_trigger_bits = 1; - break; - - case 0x3E: - { - if (0x1D == n1) - *p_cp_trigger_bits = 2; - else - *p_cp_trigger_bits = 3; - } - break; - } - } else if (IS_PAL(tv_std)) { - if (0 == n0) - *p_cp_trigger_bits = 0; - else { - /*don't know here what the non-zero trigger bits were */ - *p_cp_trigger_bits = 1; - } - } + unsigned long n0, n1; + + if (!p_cp_trigger_bits) + return; + + houston_ReadReg(MV_N0, &n0, 1); + houston_ReadReg(MV_N1, &n1, 1); + + *p_cp_trigger_bits = 0; + + if (IS_NTSC(tv_std)) { + switch (n0) { + case 0: + *p_cp_trigger_bits = 0; + break; + + case 0x36: + *p_cp_trigger_bits = 1; + break; + + case 0x3E: + { + if (0x1D == n1) + *p_cp_trigger_bits = 2; + else + *p_cp_trigger_bits = 3; + } + break; + } + } + else if (IS_PAL(tv_std)) { + if (0 == n0) + *p_cp_trigger_bits = 0; + else { + /*don't know here what the non-zero trigger bits were */ + *p_cp_trigger_bits = 1; + } + } } /*// PLAL_MediaGX.cpp*/ @@ -3301,7 +3295,7 @@ conget_macrovision(unsigned long tv_std, unsigned int *p_cp_trigger_bits) static unsigned char PLAL_FS450_i2c_address(void) { - return FS450_I2C_ADDRESS; + return FS450_I2C_ADDRESS; } /*//==========================================================================*/ @@ -3314,7 +3308,7 @@ PLAL_FS450_i2c_address(void) static int PLAL_FS450_UIM_mode(void) { - return 3; + return 3; } /*//==========================================================================*/ @@ -3324,46 +3318,46 @@ PLAL_FS450_UIM_mode(void) static unsigned long ReadGx(unsigned long inRegAddr) { - unsigned long data; + unsigned long data; - DMAL_ReadUInt32(inRegAddr, &data); + DMAL_ReadUInt32(inRegAddr, &data); - return data; + return data; } static void WriteGx(unsigned long inRegAddr, unsigned long inData) { - int is_timing_register; - unsigned long reg_timing_cfg; + int is_timing_register; + unsigned long reg_timing_cfg; - /*because the unlock register for the MediaGx video registers may not */ - /*persist, we will write the unlock code before every write. */ - DMAL_WriteUInt32(DC_UNLOCK, 0x4758); + /*because the unlock register for the MediaGx video registers may not */ + /*persist, we will write the unlock code before every write. */ + DMAL_WriteUInt32(DC_UNLOCK, 0x4758); - /*see if register is a timing register */ - is_timing_register = - (DC_H_TIMING_1 == inRegAddr) || - (DC_H_TIMING_2 == inRegAddr) || - (DC_H_TIMING_3 == inRegAddr) || - (DC_FP_H_TIMING == inRegAddr) || - (DC_V_TIMING_1 == inRegAddr) || - (DC_V_TIMING_2 == inRegAddr) || - (DC_V_TIMING_3 == inRegAddr) || (DC_FP_V_TIMING == inRegAddr); + /*see if register is a timing register */ + is_timing_register = + (DC_H_TIMING_1 == inRegAddr) || + (DC_H_TIMING_2 == inRegAddr) || + (DC_H_TIMING_3 == inRegAddr) || + (DC_FP_H_TIMING == inRegAddr) || + (DC_V_TIMING_1 == inRegAddr) || + (DC_V_TIMING_2 == inRegAddr) || + (DC_V_TIMING_3 == inRegAddr) || (DC_FP_V_TIMING == inRegAddr); - /*if the register is a timing register, clear the TGEN bit to allow modification */ - if (is_timing_register) { - DMAL_ReadUInt32(DC_TIMING_CFG, ®_timing_cfg); - DMAL_WriteUInt32(DC_TIMING_CFG, reg_timing_cfg & ~GX_TGEN); - } + /*if the register is a timing register, clear the TGEN bit to allow modification */ + if (is_timing_register) { + DMAL_ReadUInt32(DC_TIMING_CFG, ®_timing_cfg); + DMAL_WriteUInt32(DC_TIMING_CFG, reg_timing_cfg & ~GX_TGEN); + } - /*write the requested register */ - DMAL_WriteUInt32(inRegAddr, inData); + /*write the requested register */ + DMAL_WriteUInt32(inRegAddr, inData); - /*reset the TGEN bit to previous state */ - if (is_timing_register) { - DMAL_WriteUInt32(DC_TIMING_CFG, reg_timing_cfg); - } + /*reset the TGEN bit to previous state */ + if (is_timing_register) { + DMAL_WriteUInt32(DC_TIMING_CFG, reg_timing_cfg); + } } #ifdef FS450_DIRECTREG @@ -3377,31 +3371,31 @@ WriteGx(unsigned long inRegAddr, unsigned long inData) static int PLAL_ReadRegister(S_REG_INFO * p_reg) { - if (!p_reg) - return 0; + if (!p_reg) + return 0; - if (SOURCE_GCC == p_reg->source) { - p_reg->value = ReadGx(p_reg->offset); + if (SOURCE_GCC == p_reg->source) { + p_reg->value = ReadGx(p_reg->offset); - return 1; - } + return 1; + } - return 0; + return 0; } static int PLAL_WriteRegister(const S_REG_INFO * p_reg) { - if (!p_reg) - return 0; + if (!p_reg) + return 0; - if (SOURCE_GCC == p_reg->source) { - WriteGx(p_reg->offset, p_reg->value); + if (SOURCE_GCC == p_reg->source) { + WriteGx(p_reg->offset, p_reg->value); - return 1; - } + return 1; + } - return 0; + return 0; } #endif @@ -3413,11 +3407,11 @@ PLAL_WriteRegister(const S_REG_INFO * p_reg) static int PLAL_IsTVOn(void) { - unsigned long reg; + unsigned long reg; - /*check Cx5530 dot clock */ - reg = ReadGx(CX_DOT_CLK); - return (reg & CX_TVCLK_SELECT) ? 1 : 0; + /*check Cx5530 dot clock */ + reg = ReadGx(CX_DOT_CLK); + return (reg & CX_TVCLK_SELECT) ? 1 : 0; } /*//==========================================================================*/ @@ -3427,32 +3421,32 @@ PLAL_IsTVOn(void) static int PLAL_EnableVga(void) { - unsigned long reg; + unsigned long reg; - /*2 x dclk */ - reg = ReadGx(DC_GENERAL_CFG); - reg &= ~GX_DCLK_MUL; - reg |= GX_DCLKx2; - WriteGx(DC_GENERAL_CFG, reg); + /*2 x dclk */ + reg = ReadGx(DC_GENERAL_CFG); + reg &= ~GX_DCLK_MUL; + reg |= GX_DCLKx2; + WriteGx(DC_GENERAL_CFG, reg); - /*select pll dot clock. */ - reg = ReadGx(CX_DOT_CLK); - reg &= ~CX_TVCLK_SELECT; - WriteGx(CX_DOT_CLK, reg); + /*select pll dot clock. */ + reg = ReadGx(CX_DOT_CLK); + reg &= ~CX_TVCLK_SELECT; + WriteGx(CX_DOT_CLK, reg); - /*timing config, reset everything on dclk. */ - reg = ReadGx(DC_TIMING_CFG); - reg &= ~GX_TGEN; - WriteGx(DC_TIMING_CFG, reg); - reg |= GX_TGEN; - WriteGx(DC_TIMING_CFG, reg); + /*timing config, reset everything on dclk. */ + reg = ReadGx(DC_TIMING_CFG); + reg &= ~GX_TGEN; + WriteGx(DC_TIMING_CFG, reg); + reg |= GX_TGEN; + WriteGx(DC_TIMING_CFG, reg); - /*un-invert FP clock */ - reg = ReadGx(CX_TV_CONFIG); - reg &= ~CX_INVERT_FPCLK; - WriteGx(CX_TV_CONFIG, reg); + /*un-invert FP clock */ + reg = ReadGx(CX_TV_CONFIG); + reg &= ~CX_INVERT_FPCLK; + WriteGx(CX_TV_CONFIG, reg); - return 0; + return 0; } /*//==========================================================================*/ @@ -3462,101 +3456,101 @@ PLAL_EnableVga(void) static int PLAL_PrepForTVout(void) { - unsigned int reg; + unsigned int reg; - /*Cx5530 tv config. */ - reg = 0; - WriteGx(CX_TV_CONFIG, reg); + /*Cx5530 tv config. */ + reg = 0; + WriteGx(CX_TV_CONFIG, reg); - /*invert FP clock */ - reg = (int)ReadGx(CX_TV_CONFIG); - reg |= CX_INVERT_FPCLK; - WriteGx(CX_TV_CONFIG, reg); + /*invert FP clock */ + reg = (int) ReadGx(CX_TV_CONFIG); + reg |= CX_INVERT_FPCLK; + WriteGx(CX_TV_CONFIG, reg); - return 0; + return 0; } static int PLAL_SetTVTimingRegisters(const S_TIMING_SPECS * p_specs) { - unsigned long reg; + unsigned long reg; - /*timing config, reset everything on dclk. */ - reg = ReadGx(DC_TIMING_CFG); - reg &= ~GX_TGEN; - WriteGx(DC_TIMING_CFG, reg); + /*timing config, reset everything on dclk. */ + reg = ReadGx(DC_TIMING_CFG); + reg &= ~GX_TGEN; + WriteGx(DC_TIMING_CFG, reg); - /*htotal and hactive. */ - reg = ((p_specs->h_total - 1) << 16) | (p_specs->vga_width - 1); - WriteGx(DC_H_TIMING_1, reg); + /*htotal and hactive. */ + reg = ((p_specs->h_total - 1) << 16) | (p_specs->vga_width - 1); + WriteGx(DC_H_TIMING_1, reg); - /*hblank. */ - reg = ((p_specs->h_total - 1) << 16) | (p_specs->vga_width - 1); - WriteGx(DC_H_TIMING_2, reg); + /*hblank. */ + reg = ((p_specs->h_total - 1) << 16) | (p_specs->vga_width - 1); + WriteGx(DC_H_TIMING_2, reg); - /*hsync. */ - reg = ((p_specs->h_sync + 63) << 16) | p_specs->h_sync; - WriteGx(DC_H_TIMING_3, reg); + /*hsync. */ + reg = ((p_specs->h_sync + 63) << 16) | p_specs->h_sync; + WriteGx(DC_H_TIMING_3, reg); - /*fp hsync. */ - WriteGx(DC_FP_H_TIMING, reg); + /*fp hsync. */ + WriteGx(DC_FP_H_TIMING, reg); - /*vtotal and vactive. */ - reg = ((p_specs->v_total - 1) << 16) | (p_specs->vga_lines - 1); - WriteGx(DC_V_TIMING_1, reg); + /*vtotal and vactive. */ + reg = ((p_specs->v_total - 1) << 16) | (p_specs->vga_lines - 1); + WriteGx(DC_V_TIMING_1, reg); - /*vblank. */ - reg = ((p_specs->v_total - 1) << 16) | (p_specs->vga_lines - 1); - WriteGx(DC_V_TIMING_2, reg); + /*vblank. */ + reg = ((p_specs->v_total - 1) << 16) | (p_specs->vga_lines - 1); + WriteGx(DC_V_TIMING_2, reg); - /*vsync. */ - reg = ((p_specs->v_sync) << 16) | (p_specs->v_sync - 1); - WriteGx(DC_V_TIMING_3, reg); + /*vsync. */ + reg = ((p_specs->v_sync) << 16) | (p_specs->v_sync - 1); + WriteGx(DC_V_TIMING_3, reg); - /*fp vsync. */ - reg = ((p_specs->v_sync - 1) << 16) | (p_specs->v_sync - 2); - WriteGx(DC_FP_V_TIMING, reg); + /*fp vsync. */ + reg = ((p_specs->v_sync - 1) << 16) | (p_specs->v_sync - 2); + WriteGx(DC_FP_V_TIMING, reg); - /*timing config, reenable all dclk stuff. */ - reg = ReadGx(DC_TIMING_CFG); - reg |= GX_TGEN; - WriteGx(DC_TIMING_CFG, reg); + /*timing config, reenable all dclk stuff. */ + reg = ReadGx(DC_TIMING_CFG); + reg |= GX_TGEN; + WriteGx(DC_TIMING_CFG, reg); - return 0; + return 0; } static int PLAL_FinalEnableTVout(unsigned long vga_mode) { - unsigned int reg; + unsigned int reg; - /*Cx5530 select tv dot clock. */ - reg = (int)ReadGx(CX_DOT_CLK); - reg |= CX_TVCLK_SELECT; - WriteGx(CX_DOT_CLK, reg); + /*Cx5530 select tv dot clock. */ + reg = (int) ReadGx(CX_DOT_CLK); + reg |= CX_TVCLK_SELECT; + WriteGx(CX_DOT_CLK, reg); - /*2 x dclk (actually 1x) */ - reg = (int)ReadGx(DC_GENERAL_CFG); - reg &= ~GX_DCLK_MUL; - WriteGx(DC_GENERAL_CFG, reg); + /*2 x dclk (actually 1x) */ + reg = (int) ReadGx(DC_GENERAL_CFG); + reg &= ~GX_DCLK_MUL; + WriteGx(DC_GENERAL_CFG, reg); - reg |= GX_DCLKx2; - WriteGx(DC_GENERAL_CFG, reg); + reg |= GX_DCLKx2; + WriteGx(DC_GENERAL_CFG, reg); - /*Cx5530 display configuration register. */ - reg = (int)ReadGx(CX_DISPLAY_CONFIG); - reg |= (CX_FPVSYNC_POL | CX_FPHSYNC_POL | CX_FPDATA_ENB | CX_FPPOWER_ENB); - WriteGx(CX_DISPLAY_CONFIG, reg); + /*Cx5530 display configuration register. */ + reg = (int) ReadGx(CX_DISPLAY_CONFIG); + reg |= (CX_FPVSYNC_POL | CX_FPHSYNC_POL | CX_FPDATA_ENB | CX_FPPOWER_ENB); + WriteGx(CX_DISPLAY_CONFIG, reg); /*disable, shouldn't be necessary*/ #if 0 - /*kick MediaGX clock multiplier to clean up clock */ - reg = ReadGx(DC_GENERAL_CFG); - reg &= ~GX_DCLK_MUL; - WriteGx(DC_GENERAL_CFG, reg); - reg |= GX_DCLKx2; - WriteGx(DC_GENERAL_CFG, reg); + /*kick MediaGX clock multiplier to clean up clock */ + reg = ReadGx(DC_GENERAL_CFG); + reg &= ~GX_DCLK_MUL; + WriteGx(DC_GENERAL_CFG, reg); + reg |= GX_DCLKx2; + WriteGx(DC_GENERAL_CFG, reg); #endif - return 0; + return 0; } diff --git a/src/gfx/tv_fs450.h b/src/gfx/tv_fs450.h index 2b87710..74ba80e 100644 --- a/src/gfx/tv_fs450.h +++ b/src/gfx/tv_fs450.h @@ -132,33 +132,32 @@ #define __FS450_H__ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif /* ==========================================================================*/ /* Init and cleanup functions*/ - int FS450_init(void); - void FS450_cleanup(void); - /* call FS450_init at startup to probe for and initialize FS450. */ - /* returns 0 if successful. */ + int FS450_init(void); + void FS450_cleanup(void); + /* call FS450_init at startup to probe for and initialize FS450. */ + /* returns 0 if successful. */ /* ==========================================================================*/ /* TV output on or off*/ - int FS450_get_tv_enable(unsigned int *p_on); - int FS450_set_tv_enable(unsigned int on); - /* on is 1 for TV on, 0 for off */ + int FS450_get_tv_enable(unsigned int *p_on); + int FS450_set_tv_enable(unsigned int on); + /* on is 1 for TV on, 0 for off */ /* ==========================================================================*/ /* TV standard*/ - int FS450_get_tv_standard(unsigned long *p_standard); - int FS450_get_available_tv_standards(unsigned long *p_standards); - int FS450_set_tv_standard(unsigned long standard); - /* standard is one of the FS450_TV_STANDARD constants */ - /* standards is a bitmask of zero or more FS450_TV_STANDARD constants */ + int FS450_get_tv_standard(unsigned long *p_standard); + int FS450_get_available_tv_standards(unsigned long *p_standards); + int FS450_set_tv_standard(unsigned long standard); + /* standard is one of the FS450_TV_STANDARD constants */ + /* standards is a bitmask of zero or more FS450_TV_STANDARD constants */ /* FS450 TV Standard flags*/ #define FS450_TV_STANDARD_NTSC_M 0x0001 @@ -174,11 +173,11 @@ extern "C" /* ==========================================================================*/ /* VGA mode assumed by FS450*/ - int FS450_get_vga_mode(unsigned long *p_vga_mode); - int FS450_get_available_vga_modes(unsigned long *p_vga_modes); - int FS450_set_vga_mode(unsigned long vga_mode); - /* vga_mode is one of the FS450_VGA_MODE constants */ - /* vga_modes is a bitmask of zero or more FS450_VGA_MODE constants */ + int FS450_get_vga_mode(unsigned long *p_vga_mode); + int FS450_get_available_vga_modes(unsigned long *p_vga_modes); + int FS450_set_vga_mode(unsigned long vga_mode); + /* vga_mode is one of the FS450_VGA_MODE constants */ + /* vga_modes is a bitmask of zero or more FS450_VGA_MODE constants */ /* FS450 VGA Mode flags*/ #define FS450_VGA_MODE_UNKNOWN 0 @@ -191,9 +190,9 @@ extern "C" /* ==========================================================================*/ /* TVout mode*/ - int FS450_get_tvout_mode(unsigned long *p_tvout_mode); - int FS450_set_tvout_mode(unsigned long tvout_mode); - /* tvout_mode is a bitmask of FS450_TVOUT_MODE constants */ + int FS450_get_tvout_mode(unsigned long *p_tvout_mode); + int FS450_set_tvout_mode(unsigned long tvout_mode); + /* tvout_mode is a bitmask of FS450_TVOUT_MODE constants */ /* FS450 TVout mode flags*/ #define FS450_TVOUT_MODE_CVBS 0x0001 @@ -204,44 +203,44 @@ extern "C" /* ==========================================================================*/ /* Flicker control*/ - int FS450_get_sharpness(int *p_sharpness); - int FS450_set_sharpness(int sharpness); - /* sharpness is a percentage in tenths of a percent, 0 to 1000 */ + int FS450_get_sharpness(int *p_sharpness); + int FS450_set_sharpness(int sharpness); + /* sharpness is a percentage in tenths of a percent, 0 to 1000 */ - int FS450_get_flicker_filter(int *p_flicker); - int FS450_set_flicker_filter(int flicker); - /* flicker_filter is a percentage in tenths of a percent, 0 to 1000 */ + int FS450_get_flicker_filter(int *p_flicker); + int FS450_set_flicker_filter(int flicker); + /* flicker_filter is a percentage in tenths of a percent, 0 to 1000 */ /* ==========================================================================*/ /* Size and Position*/ - int FS450_get_overscan(int *p_x, int *p_y); - int FS450_set_overscan(int x, int y); - int FS450_get_position(int *p_x, int *p_y); - int FS450_set_position(int x, int y); - /* x and y are horizontal and vertical adjustments, -1000 to +1000 */ + int FS450_get_overscan(int *p_x, int *p_y); + int FS450_set_overscan(int x, int y); + int FS450_get_position(int *p_x, int *p_y); + int FS450_set_position(int x, int y); + /* x and y are horizontal and vertical adjustments, -1000 to +1000 */ /* ==========================================================================*/ /* Visual adjustments*/ - int FS450_get_color(int *p_color); - int FS450_set_color(int color); - /* color is a percentage, 0 to 100 */ + int FS450_get_color(int *p_color); + int FS450_set_color(int color); + /* color is a percentage, 0 to 100 */ - int FS450_get_brightness(int *p_brightness); - int FS450_set_brightness(int brightness); - /* brightness is a percentage, 0 to 100 */ + int FS450_get_brightness(int *p_brightness); + int FS450_set_brightness(int brightness); + /* brightness is a percentage, 0 to 100 */ - int FS450_get_contrast(int *p_contrast); - int FS450_set_contrast(int constrast); - /* contrast is a percentage, 0 to 100 */ + int FS450_get_contrast(int *p_contrast); + int FS450_set_contrast(int constrast); + /* contrast is a percentage, 0 to 100 */ /* ==========================================================================*/ /* Luma and Chroma filter*/ - int FS450_get_yc_filter(unsigned int *p_yc_filter); - int FS450_set_yc_filter(unsigned int yc_filter); - /* yc_filter is a bitmask of FS450_LUMA_FILTER and/or FS450_CHROMA_FILTER */ + int FS450_get_yc_filter(unsigned int *p_yc_filter); + int FS450_set_yc_filter(unsigned int yc_filter); + /* yc_filter is a bitmask of FS450_LUMA_FILTER and/or FS450_CHROMA_FILTER */ /* FS450 Luma and Chroma Filters*/ #define FS450_LUMA_FILTER 0x0001 @@ -250,9 +249,9 @@ extern "C" /* ==========================================================================*/ /* Macrovision*/ - int FS450_get_aps_trigger_bits(unsigned int *p_trigger_bits); - int FS450_set_aps_trigger_bits(unsigned int trigger_bits); - /* trigger_bits is one of the FS450_APS_TRIGGER constants */ + int FS450_get_aps_trigger_bits(unsigned int *p_trigger_bits); + int FS450_set_aps_trigger_bits(unsigned int trigger_bits); + /* trigger_bits is one of the FS450_APS_TRIGGER constants */ /* APS Trigger Bits*/ #define FS450_APS_TRIGGER_OFF 0 @@ -271,17 +270,15 @@ extern "C" #define SOURCE_HOUSTON 0 #define SOURCE_GCC 1 - typedef struct _S_REG_INFO - { - int source; - unsigned int size; - unsigned long offset; - unsigned long value; - } - S_REG_INFO; + typedef struct _S_REG_INFO { + int source; + unsigned int size; + unsigned long offset; + unsigned long value; + } S_REG_INFO; - int FS450_ReadRegister(S_REG_INFO * p_reg); - int FS450_WriteRegister(S_REG_INFO * p_reg); + int FS450_ReadRegister(S_REG_INFO * p_reg); + int FS450_WriteRegister(S_REG_INFO * p_reg); #endif @@ -303,5 +300,4 @@ extern "C" #ifdef __cplusplus } #endif - #endif diff --git a/src/gfx/tv_fs451.c b/src/gfx/tv_fs451.c index 29b74f2..b574c67 100644 --- a/src/gfx/tv_fs451.c +++ b/src/gfx/tv_fs451.c @@ -145,8 +145,8 @@ int gfx_set_tv_format(TVStandardType format, GfxOnTVType resolution) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /*----------------------------------------------------------------------------- @@ -164,8 +164,8 @@ int gfx_set_tv_output(int output) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /*----------------------------------------------------------------------------- @@ -183,8 +183,8 @@ int gfx_set_tv_defaults(int format) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /*----------------------------------------------------------------------------- @@ -201,8 +201,8 @@ int gfx_set_tv_enable(int enable) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /*----------------------------------------------------------------------------- @@ -220,8 +220,8 @@ int gfx_set_tv_cc_enable(int enable) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /*----------------------------------------------------------------------------- @@ -239,8 +239,8 @@ int gfx_set_tv_cc_data(unsigned char data1, unsigned char data2) #endif { - /* ### ADD ### IMPLEMENTATION */ - return (0); + /* ### ADD ### IMPLEMENTATION */ + return (0); } /* END OF FILE */ diff --git a/src/gfx/tv_geode.c b/src/gfx/tv_geode.c index 1938083..ff42ef1 100644 --- a/src/gfx/tv_geode.c +++ b/src/gfx/tv_geode.c @@ -30,24 +30,24 @@ int gfx_set_tv_defaults(int format) #endif { - /* SET DEFAULTS FOR NTSC */ + /* SET DEFAULTS FOR NTSC */ - WRITE_VID32(SC1400_TVOUT_HORZ_TIM, 0x00790359); - WRITE_VID32(SC1400_TVOUT_HORZ_SYNC, 0x03580350); - WRITE_VID32(SC1400_TVOUT_VERT_SYNC, 0x0A002001); - WRITE_VID32(SC1400_TVOUT_LINE_END, 0x039C00F0); - WRITE_VID32(SC1400_TVOUT_VERT_DOWNSCALE, 0xFFFFFFFF); - WRITE_VID32(SC1400_TVOUT_HORZ_SCALING, 0x10220700); - WRITE_VID32(SC1400_TVOUT_EMMA_BYPASS, 0x0002D0F0); - WRITE_VID32(SC1400_TVENC_TIM_CTRL_1, 0xA2E03000); - WRITE_VID32(SC1400_TVENC_TIM_CTRL_2, 0x1FF20000); - WRITE_VID32(SC1400_TVENC_TIM_CTRL_3, 0x00000000); - WRITE_VID32(SC1400_TVENC_SUB_FREQ, 0x21F12000); - WRITE_VID32(SC1400_TVENC_DISP_POS, 0x00030071); - WRITE_VID32(SC1400_TVENC_DISP_SIZE, 0x00EF02CF); + WRITE_VID32(SC1400_TVOUT_HORZ_TIM, 0x00790359); + WRITE_VID32(SC1400_TVOUT_HORZ_SYNC, 0x03580350); + WRITE_VID32(SC1400_TVOUT_VERT_SYNC, 0x0A002001); + WRITE_VID32(SC1400_TVOUT_LINE_END, 0x039C00F0); + WRITE_VID32(SC1400_TVOUT_VERT_DOWNSCALE, 0xFFFFFFFF); + WRITE_VID32(SC1400_TVOUT_HORZ_SCALING, 0x10220700); + WRITE_VID32(SC1400_TVOUT_EMMA_BYPASS, 0x0002D0F0); + WRITE_VID32(SC1400_TVENC_TIM_CTRL_1, 0xA2E03000); + WRITE_VID32(SC1400_TVENC_TIM_CTRL_2, 0x1FF20000); + WRITE_VID32(SC1400_TVENC_TIM_CTRL_3, 0x00000000); + WRITE_VID32(SC1400_TVENC_SUB_FREQ, 0x21F12000); + WRITE_VID32(SC1400_TVENC_DISP_POS, 0x00030071); + WRITE_VID32(SC1400_TVENC_DISP_SIZE, 0x00EF02CF); - /* ### ADD ### DEFAULTS FOR PAL */ - return (0); + /* ### ADD ### DEFAULTS FOR PAL */ + return (0); } /*----------------------------------------------------------------------------- @@ -64,15 +64,15 @@ int gfx_set_tv_enable(int enable) #endif { - unsigned long value; + unsigned long value; - value = READ_VID32(SC1400_DISPLAY_CONFIG); - if (enable) - value |= SC1400_DCFG_TVOUT_EN; - else - value &= ~(SC1400_DCFG_TVOUT_EN); - WRITE_VID32(SC1400_DISPLAY_CONFIG, value); - return (0); + value = READ_VID32(SC1400_DISPLAY_CONFIG); + if (enable) + value |= SC1400_DCFG_TVOUT_EN; + else + value &= ~(SC1400_DCFG_TVOUT_EN); + WRITE_VID32(SC1400_DISPLAY_CONFIG, value); + return (0); } /*----------------------------------------------------------------------------- @@ -90,14 +90,14 @@ int gfx_set_tv_cc_enable(int enable) #endif { - unsigned long value; + unsigned long value; - value = READ_VID32(SC1400_TVENC_CC_CONTROL); - value &= ~(0x0005F); - if (enable) - value |= 0x51; - WRITE_VID32(SC1400_TVENC_CC_CONTROL, value); - return (0); + value = READ_VID32(SC1400_TVENC_CC_CONTROL); + value &= ~(0x0005F); + if (enable) + value |= 0x51; + WRITE_VID32(SC1400_TVENC_CC_CONTROL, value); + return (0); } /*----------------------------------------------------------------------------- @@ -115,11 +115,11 @@ int gfx_set_tv_cc_data(unsigned char data1, unsigned char data2) #endif { - unsigned long value; + unsigned long value; - value = data1 | (((unsigned long)data2) << 8); - WRITE_VID32(SC1400_TVENC_CC_DATA, value); - return (0); + value = data1 | (((unsigned long) data2) << 8); + WRITE_VID32(SC1400_TVENC_CC_DATA, value); + return (0); } /* END OF FILE */ diff --git a/src/gfx/vga_gu1.c b/src/gfx/vga_gu1.c index d5fa263..1195bae 100644 --- a/src/gfx/vga_gu1.c +++ b/src/gfx/vga_gu1.c @@ -160,113 +160,113 @@ int gu1_detect_vsa2(void); gfx_vga_struct gfx_vga_modes[] = { /*------------------------------------------------------------------------------*/ - {640, 480, 60, /* 640x480 */ - 25, /* 25 MHz clock = 60 Hz refresh rate */ - 0xE3, /* miscOutput register */ - {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, /* standard CRTC */ - 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xEA, 0x0C, 0xDF, 0x50, 0x00, 0xE7, 0x04, 0xE3, 0xFF}, - {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00}}, + {640, 480, 60, /* 640x480 */ + 25, /* 25 MHz clock = 60 Hz refresh rate */ + 0xE3, /* miscOutput register */ + {0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, /* standard CRTC */ + 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xEA, 0x0C, 0xDF, 0x50, 0x00, 0xE7, 0x04, 0xE3, 0xFF}, + {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00}}, /*------------------------------------------------------------------------------*/ - {640, 480, 72, /* 640x480 */ - 29, /* 29 MHz clock = 72 Hz refresh rate */ - 0xE3, /* miscOutput register */ - {0x63, 0x4f, 0x50, 0x86, 0x55, 0x99, 0x06, 0x3e, /* standard CRTC */ - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xe9, 0x0c, 0xdf, 0x00, 0x00, 0xe7, 0x00, 0xe3, 0xff}, - {0x6D, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x01, 0x08, 0x80, 0x1F, 0x00, 0x4B}}, + {640, 480, 72, /* 640x480 */ + 29, /* 29 MHz clock = 72 Hz refresh rate */ + 0xE3, /* miscOutput register */ + {0x63, 0x4f, 0x50, 0x86, 0x55, 0x99, 0x06, 0x3e, /* standard CRTC */ + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe9, 0x0c, 0xdf, 0x00, 0x00, 0xe7, 0x00, 0xe3, 0xff}, + {0x6D, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x01, 0x08, 0x80, 0x1F, 0x00, 0x4B}}, /*------------------------------------------------------------------------------*/ - {640, 480, 75, /* 640x480 */ - 31, /* 31.5 MHz clock = 75 Hz refresh rate */ - 0xE3, /* miscOutput register */ - {0x64, 0x4F, 0x4F, 0x88, 0x54, 0x9B, 0xF2, 0x1F, /* standard CRTC */ - 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xE1, 0x04, 0xDF, 0x50, 0x00, 0xDF, 0xF3, 0xE3, 0xFF}, - {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x00, 0x03, 0x80, 0x1F, 0x00, 0x00}}, + {640, 480, 75, /* 640x480 */ + 31, /* 31.5 MHz clock = 75 Hz refresh rate */ + 0xE3, /* miscOutput register */ + {0x64, 0x4F, 0x4F, 0x88, 0x54, 0x9B, 0xF2, 0x1F, /* standard CRTC */ + 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xE1, 0x04, 0xDF, 0x50, 0x00, 0xDF, 0xF3, 0xE3, 0xFF}, + {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x00, 0x03, 0x80, 0x1F, 0x00, 0x00}}, /*------------------------------------------------------------------------------*/ - {800, 600, 60, /* 800x600 */ - 40, /* 40 MHz clock = 60 Hz refresh rate */ - 0x23, /* miscOutput register */ - {0x7F, 0x63, 0x64, 0x82, 0x6B, 0x1B, 0x72, 0xF0, /* standard CRTC */ - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x59, 0x0D, 0x57, 0x64, 0x00, 0x57, 0x73, 0xE3, 0xFF}, - {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x00, 0x03, 0x80, 0x28, 0x00, 0x00}}, + {800, 600, 60, /* 800x600 */ + 40, /* 40 MHz clock = 60 Hz refresh rate */ + 0x23, /* miscOutput register */ + {0x7F, 0x63, 0x64, 0x82, 0x6B, 0x1B, 0x72, 0xF0, /* standard CRTC */ + 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x59, 0x0D, 0x57, 0x64, 0x00, 0x57, 0x73, 0xE3, 0xFF}, + {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x00, 0x03, 0x80, 0x28, 0x00, 0x00}}, /*------------------------------------------------------------------------------*/ - {800, 600, 72, /* 800x600 */ - 47, /* 47 MHz clock = 72 Hz refresh rate */ - 0x2B, /* miscOutput register */ - {0x7D, 0x63, 0x63, 0x81, 0x6D, 0x1B, 0x98, 0xF0, /* standard CRTC */ - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7D, 0x03, 0x57, 0x00, 0x00, 0x57, 0x9A, 0xE3, 0xFF}, - {0x6F, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x01, 0x08, 0x80, 0x32, 0x00, 0x4B}}, + {800, 600, 72, /* 800x600 */ + 47, /* 47 MHz clock = 72 Hz refresh rate */ + 0x2B, /* miscOutput register */ + {0x7D, 0x63, 0x63, 0x81, 0x6D, 0x1B, 0x98, 0xF0, /* standard CRTC */ + 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7D, 0x03, 0x57, 0x00, 0x00, 0x57, 0x9A, 0xE3, 0xFF}, + {0x6F, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x01, 0x08, 0x80, 0x32, 0x00, 0x4B}}, /*------------------------------------------------------------------------------*/ - {800, 600, 75, /* 800x600 */ - 49, /* 49.5 MHz clock = 75 Hz refresh rate */ - 0x23, /* miscOutput register */ - {0x7F, 0x63, 0x63, 0x83, 0x68, 0x11, 0x6F, 0xF0, /* standard CRTC */ - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x59, 0x1C, 0x57, 0x64, 0x00, 0x57, 0x70, 0xE3, 0xFF}, - {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x00, 0x03, 0x80, 0x31, 0x00, 0x00}}, + {800, 600, 75, /* 800x600 */ + 49, /* 49.5 MHz clock = 75 Hz refresh rate */ + 0x23, /* miscOutput register */ + {0x7F, 0x63, 0x63, 0x83, 0x68, 0x11, 0x6F, 0xF0, /* standard CRTC */ + 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x59, 0x1C, 0x57, 0x64, 0x00, 0x57, 0x70, 0xE3, 0xFF}, + {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x00, 0x03, 0x80, 0x31, 0x00, 0x00}}, /*------------------------------------------------------------------------------*/ - {1024, 768, 60, /* 1024x768 */ - 65, /* 65 MHz clock = 60 Hz refresh rate */ - 0xE3, /* miscOutput register */ - {0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xF5, /* standard CRTC */ - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x0A, 0xFF, 0x80, 0x00, 0xFF, 0x25, 0xE3, 0xFF}, - {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x00, 0x03, 0x80, 0x41, 0x00, 0x00}}, + {1024, 768, 60, /* 1024x768 */ + 65, /* 65 MHz clock = 60 Hz refresh rate */ + 0xE3, /* miscOutput register */ + {0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xF5, /* standard CRTC */ + 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x0A, 0xFF, 0x80, 0x00, 0xFF, 0x25, 0xE3, 0xFF}, + {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x00, 0x03, 0x80, 0x41, 0x00, 0x00}}, /*------------------------------------------------------------------------------*/ - {1024, 768, 70, /* 1024x768 */ - 76, /* 76 MHz clock = 70 Hz refresh rate */ - 0x2B, /* miscOutput register */ - {0xA1, 0x7F, 0x7F, 0x85, 0x85, 0x95, 0x24, 0xF5, /* standard CRTC */ - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x09, 0xFF, 0x00, 0x00, 0xFF, 0x26, 0xE3, 0xFF}, - {0x62, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x01, 0x02, 0x80, 0x4B, 0x00, 0x4B}}, + {1024, 768, 70, /* 1024x768 */ + 76, /* 76 MHz clock = 70 Hz refresh rate */ + 0x2B, /* miscOutput register */ + {0xA1, 0x7F, 0x7F, 0x85, 0x85, 0x95, 0x24, 0xF5, /* standard CRTC */ + 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x09, 0xFF, 0x00, 0x00, 0xFF, 0x26, 0xE3, 0xFF}, + {0x62, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x01, 0x02, 0x80, 0x4B, 0x00, 0x4B}}, /*------------------------------------------------------------------------------*/ - {1024, 768, 75, /* 1024x768 */ - 79, /* 79 MHz clock = 75 Hz refresh rate */ - 0xE3, /* miscOutput register */ - {0x9F, 0x7F, 0x7F, 0x83, 0x84, 0x8F, 0x1E, 0xF5, /* standard CRTC */ - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x04, 0xFF, 0x80, 0x00, 0xFF, 0x1F, 0xE3, 0xFF}, - {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x00, 0x03, 0x80, 0x4F, 0x00, 0x00}}, + {1024, 768, 75, /* 1024x768 */ + 79, /* 79 MHz clock = 75 Hz refresh rate */ + 0xE3, /* miscOutput register */ + {0x9F, 0x7F, 0x7F, 0x83, 0x84, 0x8F, 0x1E, 0xF5, /* standard CRTC */ + 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x04, 0xFF, 0x80, 0x00, 0xFF, 0x1F, 0xE3, 0xFF}, + {0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x00, 0x03, 0x80, 0x4F, 0x00, 0x00}}, /*------------------------------------------------------------------------------*/ - {1280, 1024, 60, /* 1280x1024 */ - 108, /* 108 MHz clock = 60 Hz refresh rate */ - 0x23, /* miscOutput register */ - {0xCF, 0x9F, 0xA0, 0x92, 0xAA, 0x19, 0x28, 0x52, /* standard CRTC */ - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x04, 0xFF, 0xA0, 0x00, 0x00, 0x29, 0xE3, 0xFF}, - {0x00, 0x51, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x00, 0x03, 0x80, 0x6C, 0x00, 0x00}}, + {1280, 1024, 60, /* 1280x1024 */ + 108, /* 108 MHz clock = 60 Hz refresh rate */ + 0x23, /* miscOutput register */ + {0xCF, 0x9F, 0xA0, 0x92, 0xAA, 0x19, 0x28, 0x52, /* standard CRTC */ + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x04, 0xFF, 0xA0, 0x00, 0x00, 0x29, 0xE3, 0xFF}, + {0x00, 0x51, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x00, 0x03, 0x80, 0x6C, 0x00, 0x00}}, /*------------------------------------------------------------------------------*/ - {1280, 1024, 75, /* 1280x1024 */ - 135, /* 135 MHz clock = 75 Hz refresh rate */ - 0x23, /* miscOutput register */ - {0xCE, 0x9F, 0x9F, 0x92, 0xA4, 0x15, 0x28, 0x52, /* standard CRTC */ - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x04, 0xFF, 0xA0, 0x00, 0x00, 0x29, 0xE3, 0xFF}, - {0x00, 0x51, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x00, 0x03, 0x80, 0x87, 0x00, 0x00}}, + {1280, 1024, 75, /* 1280x1024 */ + 135, /* 135 MHz clock = 75 Hz refresh rate */ + 0x23, /* miscOutput register */ + {0xCE, 0x9F, 0x9F, 0x92, 0xA4, 0x15, 0x28, 0x52, /* standard CRTC */ + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x04, 0xFF, 0xA0, 0x00, 0x00, 0x29, 0xE3, 0xFF}, + {0x00, 0x51, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x00, 0x03, 0x80, 0x87, 0x00, 0x00}}, /*------------------------------------------------------------------------------*/ - {1280, 1024, 85, /* 1280x1024 */ - 159, /* 159 MHz clock = 85 Hz refresh rate */ - 0x2B, /* miscOutput register */ - {0xD3, 0x9F, 0xA0, 0x98, 0xA8, 0x9C, 0x2E, 0x5A, /* standard CRTC */ - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x04, 0xFF, 0x00, 0x00, 0xFF, 0x30, 0xE3, 0xFF}, - {0x6B, 0x41, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, /* extended CRTC */ - 0x00, 0x00, 0x01, 0x00, 0x80, 0x9D, 0x00, 0x4B}}, + {1280, 1024, 85, /* 1280x1024 */ + 159, /* 159 MHz clock = 85 Hz refresh rate */ + 0x2B, /* miscOutput register */ + {0xD3, 0x9F, 0xA0, 0x98, 0xA8, 0x9C, 0x2E, 0x5A, /* standard CRTC */ + 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x04, 0xFF, 0x00, 0x00, 0xFF, 0x30, 0xE3, 0xFF}, + {0x6B, 0x41, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, /* extended CRTC */ + 0x00, 0x00, 0x01, 0x00, 0x80, 0x9D, 0x00, 0x4B}}, /*------------------------------------------------------------------------------*/ }; @@ -282,16 +282,16 @@ gfx_vga_struct gfx_vga_modes[] = { int gfx_get_softvga_active(void) { - unsigned short crtcindex, crtcdata; + unsigned short crtcindex, crtcdata; - if (gu1_detect_vsa2()) - return (gfx_get_vsa2_softvga_enable()); + if (gu1_detect_vsa2()) + return (gfx_get_vsa2_softvga_enable()); - crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; + crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; - OUTB(crtcindex, CRTC_MODE_SWITCH_CONTROL); - return (INB(crtcdata) & 0x1); + OUTB(crtcindex, CRTC_MODE_SWITCH_CONTROL); + return (INB(crtcdata) & 0x1); } /*----------------------------------------------------------------------------- @@ -311,20 +311,20 @@ gfx_get_softvga_active(void) int gfx_vga_test_pci(void) { - int softvga = 1; - unsigned long value; - - value = gfx_pci_config_read(0x80009400); - if ((value & 0x0000FFFF) != 0x1078) - softvga = 0; - else { - value = gfx_pci_config_read(0x80009404); - gfx_pci_config_write(0x80009404, value | 0x02); - if (!(gfx_pci_config_read(0x80009404) & 0x02)) - softvga = 0; - gfx_pci_config_write(0x80009404, value); - } - return (softvga); + int softvga = 1; + unsigned long value; + + value = gfx_pci_config_read(0x80009400); + if ((value & 0x0000FFFF) != 0x1078) + softvga = 0; + else { + value = gfx_pci_config_read(0x80009404); + gfx_pci_config_write(0x80009404, value | 0x02); + if (!(gfx_pci_config_read(0x80009404) & 0x02)) + softvga = 0; + gfx_pci_config_write(0x80009404, value); + } + return (softvga); } /*----------------------------------------------------------------------------- @@ -336,10 +336,10 @@ gfx_vga_test_pci(void) unsigned char gfx_vga_get_pci_command(void) { - unsigned long value; + unsigned long value; - value = gfx_pci_config_read(0x80009404); - return ((unsigned char)value); + value = gfx_pci_config_read(0x80009404); + return ((unsigned char) value); } /*----------------------------------------------------------------------------- @@ -355,12 +355,12 @@ gfx_vga_get_pci_command(void) int gfx_vga_set_pci_command(unsigned char command) { - unsigned long value; + unsigned long value; - value = gfx_pci_config_read(0x80009404) & 0xFFFFFF00; - value |= (unsigned long)command; - gfx_pci_config_write(0x80009404, value); - return (GFX_STATUS_OK); + value = gfx_pci_config_read(0x80009404) & 0xFFFFFF00; + value |= (unsigned long) command; + gfx_pci_config_write(0x80009404, value); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -375,9 +375,9 @@ gfx_vga_set_pci_command(unsigned char command) int gfx_vga_seq_reset(int reset) { - OUTB(0x3C4, 0); - OUTB(0x3C5, (unsigned char)(reset ? 0x00 : 0x03)); - return (GFX_STATUS_OK); + OUTB(0x3C4, 0); + OUTB(0x3C5, (unsigned char) (reset ? 0x00 : 0x03)); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -395,18 +395,18 @@ gfx_vga_seq_reset(int reset) int gfx_vga_set_graphics_bits(void) { - /* SET GRAPHICS BIT IN GRAPHICS CONTROLLER REG 0x06 */ + /* SET GRAPHICS BIT IN GRAPHICS CONTROLLER REG 0x06 */ - OUTB(0x3CE, 0x06); - OUTB(0x3CF, 0x01); + OUTB(0x3CE, 0x06); + OUTB(0x3CF, 0x01); - /* SET GRAPHICS BIT IN ATTRIBUTE CONTROLLER REG 0x10 */ + /* SET GRAPHICS BIT IN ATTRIBUTE CONTROLLER REG 0x10 */ - INB(0x3BA); /* Reset flip-flop */ - INB(0x3DA); - OUTB(0x3C0, 0x10); - OUTB(0x3C0, 0x01); - return (GFX_STATUS_OK); + INB(0x3BA); /* Reset flip-flop */ + INB(0x3DA); + OUTB(0x3C0, 0x10); + OUTB(0x3C0, 0x01); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -421,47 +421,47 @@ gfx_vga_set_graphics_bits(void) int gfx_vga_mode(gfx_vga_struct * vga, int xres, int yres, int bpp, int hz) { - unsigned int i; - unsigned short pitch; - - for (i = 0; i < GFX_VGA_MODES; i++) { - if ((gfx_vga_modes[i].xsize == xres) && - (gfx_vga_modes[i].ysize == yres) && (gfx_vga_modes[i].hz == hz)) { - /* COPY ENTIRE STRUCTURE FROM THE TABLE */ - - *vga = gfx_vga_modes[i]; - - /* SET PITCH TO 1K OR 2K */ - /* CRTC_EXTENDED_OFFSET index is 0x45, so offset = 0x05 */ - - pitch = (unsigned short)xres; - if (bpp > 8) - pitch <<= 1; - if (pitch <= 1024) - pitch = 1024 >> 3; - else - pitch = 2048 >> 3; - vga->stdCRTCregs[0x13] = (unsigned char)pitch; - vga->extCRTCregs[0x05] = (unsigned char)((pitch >> 8) & 0x03); - - /* SET PROPER COLOR DEPTH VALUE */ - /* CRTC_EXTENDED_COLOR_CONTROL index is 0x46, so offset = 0x06 */ - - switch (bpp) { - case 15: - vga->extCRTCregs[0x06] = CRTC_BIT_16BPP | CRTC_BIT_555; - break; - case 16: - vga->extCRTCregs[0x06] = CRTC_BIT_16BPP; - break; - default: - vga->extCRTCregs[0x06] = 0; - break; - } - return (GFX_STATUS_OK); - } - } - return (GFX_STATUS_UNSUPPORTED); + unsigned int i; + unsigned short pitch; + + for (i = 0; i < GFX_VGA_MODES; i++) { + if ((gfx_vga_modes[i].xsize == xres) && + (gfx_vga_modes[i].ysize == yres) && (gfx_vga_modes[i].hz == hz)) { + /* COPY ENTIRE STRUCTURE FROM THE TABLE */ + + *vga = gfx_vga_modes[i]; + + /* SET PITCH TO 1K OR 2K */ + /* CRTC_EXTENDED_OFFSET index is 0x45, so offset = 0x05 */ + + pitch = (unsigned short) xres; + if (bpp > 8) + pitch <<= 1; + if (pitch <= 1024) + pitch = 1024 >> 3; + else + pitch = 2048 >> 3; + vga->stdCRTCregs[0x13] = (unsigned char) pitch; + vga->extCRTCregs[0x05] = (unsigned char) ((pitch >> 8) & 0x03); + + /* SET PROPER COLOR DEPTH VALUE */ + /* CRTC_EXTENDED_COLOR_CONTROL index is 0x46, so offset = 0x06 */ + + switch (bpp) { + case 15: + vga->extCRTCregs[0x06] = CRTC_BIT_16BPP | CRTC_BIT_555; + break; + case 16: + vga->extCRTCregs[0x06] = CRTC_BIT_16BPP; + break; + default: + vga->extCRTCregs[0x06] = 0; + break; + } + return (GFX_STATUS_OK); + } + } + return (GFX_STATUS_UNSUPPORTED); } /*----------------------------------------------------------------------------- @@ -474,10 +474,10 @@ gfx_vga_mode(gfx_vga_struct * vga, int xres, int yres, int bpp, int hz) int gfx_vga_pitch(gfx_vga_struct * vga, unsigned short pitch) { - pitch >>= 3; - vga->stdCRTCregs[0x13] = (unsigned char)pitch; - vga->extCRTCregs[0x05] = (unsigned char)((pitch >> 8) & 0x03); - return (0); + pitch >>= 3; + vga->stdCRTCregs[0x13] = (unsigned char) pitch; + vga->extCRTCregs[0x05] = (unsigned char) ((pitch >> 8) & 0x03); + return (0); } /*----------------------------------------------------------------------------- @@ -491,42 +491,42 @@ gfx_vga_pitch(gfx_vga_struct * vga, unsigned short pitch) int gfx_vga_save(gfx_vga_struct * vga, int flags) { - int i; - unsigned short crtcindex, crtcdata; + int i; + unsigned short crtcindex, crtcdata; - crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; + crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; - /* CHECK MISCELLANEOUS OUTPUT FLAG */ + /* CHECK MISCELLANEOUS OUTPUT FLAG */ - if (flags & GFX_VGA_FLAG_MISC_OUTPUT) { - /* SAVE MISCCELLANEOUS OUTPUT REGISTER */ + if (flags & GFX_VGA_FLAG_MISC_OUTPUT) { + /* SAVE MISCCELLANEOUS OUTPUT REGISTER */ - vga->miscOutput = INB(0x3CC); - } + vga->miscOutput = INB(0x3CC); + } - /* CHECK STANDARD CRTC FLAG */ + /* CHECK STANDARD CRTC FLAG */ - if (flags & GFX_VGA_FLAG_STD_CRTC) { - /* SAVE STANDARD CRTC REGISTERS */ + if (flags & GFX_VGA_FLAG_STD_CRTC) { + /* SAVE STANDARD CRTC REGISTERS */ - for (i = 0; i < GFX_STD_CRTC_REGS; i++) { - OUTB(crtcindex, (unsigned char)i); - vga->stdCRTCregs[i] = INB(crtcdata); - } - } + for (i = 0; i < GFX_STD_CRTC_REGS; i++) { + OUTB(crtcindex, (unsigned char) i); + vga->stdCRTCregs[i] = INB(crtcdata); + } + } - /* CHECK EXTENDED CRTC FLAG */ + /* CHECK EXTENDED CRTC FLAG */ - if (flags & GFX_VGA_FLAG_EXT_CRTC) { - /* SAVE EXTENDED CRTC REGISTERS */ + if (flags & GFX_VGA_FLAG_EXT_CRTC) { + /* SAVE EXTENDED CRTC REGISTERS */ - for (i = 0; i < GFX_EXT_CRTC_REGS; i++) { - OUTB(crtcindex, (unsigned char)(0x40 + i)); - vga->extCRTCregs[i] = INB(crtcdata); - } - } - return (0); + for (i = 0; i < GFX_EXT_CRTC_REGS; i++) { + OUTB(crtcindex, (unsigned char) (0x40 + i)); + vga->extCRTCregs[i] = INB(crtcdata); + } + } + return (0); } /*----------------------------------------------------------------------------- @@ -539,21 +539,21 @@ gfx_vga_save(gfx_vga_struct * vga, int flags) void gfx_vga_clear_extended(void) { - int i; - unsigned short crtcindex, crtcdata; - - crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; - - OUTB(crtcindex, 0x30); - OUTB(crtcdata, 0x57); - OUTB(crtcdata, 0x4C); - for (i = 0x40; i <= 0x4F; i++) { - OUTB(crtcindex, (unsigned char)i); - OUTB(crtcdata, 0); - } - OUTB(crtcindex, 0x30); - OUTB(crtcdata, 0x00); + int i; + unsigned short crtcindex, crtcdata; + + crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; + + OUTB(crtcindex, 0x30); + OUTB(crtcdata, 0x57); + OUTB(crtcdata, 0x4C); + for (i = 0x40; i <= 0x4F; i++) { + OUTB(crtcindex, (unsigned char) i); + OUTB(crtcdata, 0); + } + OUTB(crtcindex, 0x30); + OUTB(crtcdata, 0x00); } /*----------------------------------------------------------------------------- @@ -567,71 +567,71 @@ gfx_vga_clear_extended(void) int gfx_vga_restore(gfx_vga_struct * vga, int flags) { - int i; - unsigned short crtcindex, crtcdata; + int i; + unsigned short crtcindex, crtcdata; - crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; + crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; - /* CHECK MISCELLANEOUS OUTPUT FLAG */ + /* CHECK MISCELLANEOUS OUTPUT FLAG */ - if (flags & GFX_VGA_FLAG_MISC_OUTPUT) { - /* RESTORE MISCELLANEOUS OUTPUT REGISTER VALUE */ + if (flags & GFX_VGA_FLAG_MISC_OUTPUT) { + /* RESTORE MISCELLANEOUS OUTPUT REGISTER VALUE */ - OUTB(0x3C2, vga->miscOutput); - } + OUTB(0x3C2, vga->miscOutput); + } - /* CHECK STANDARD CRTC FLAG */ + /* CHECK STANDARD CRTC FLAG */ - if (flags & GFX_VGA_FLAG_STD_CRTC) { - /* UNLOCK STANDARD CRTC REGISTERS */ + if (flags & GFX_VGA_FLAG_STD_CRTC) { + /* UNLOCK STANDARD CRTC REGISTERS */ - OUTB(crtcindex, 0x11); - OUTB(crtcdata, 0); + OUTB(crtcindex, 0x11); + OUTB(crtcdata, 0); - /* RESTORE STANDARD CRTC REGISTERS */ + /* RESTORE STANDARD CRTC REGISTERS */ - for (i = 0; i < GFX_STD_CRTC_REGS; i++) { - OUTB(crtcindex, (unsigned char)i); - OUTB(crtcdata, vga->stdCRTCregs[i]); - } - } + for (i = 0; i < GFX_STD_CRTC_REGS; i++) { + OUTB(crtcindex, (unsigned char) i); + OUTB(crtcdata, vga->stdCRTCregs[i]); + } + } - /* CHECK EXTENDED CRTC FLAG */ + /* CHECK EXTENDED CRTC FLAG */ - if (flags & GFX_VGA_FLAG_EXT_CRTC) { - /* UNLOCK EXTENDED CRTC REGISTERS */ + if (flags & GFX_VGA_FLAG_EXT_CRTC) { + /* UNLOCK EXTENDED CRTC REGISTERS */ - OUTB(crtcindex, 0x30); - OUTB(crtcdata, 0x57); - OUTB(crtcdata, 0x4C); + OUTB(crtcindex, 0x30); + OUTB(crtcdata, 0x57); + OUTB(crtcdata, 0x4C); - /* RESTORE EXTENDED CRTC REGISTERS */ + /* RESTORE EXTENDED CRTC REGISTERS */ - for (i = 0; i < GFX_EXT_CRTC_REGS; i++) { - OUTB(crtcindex, (unsigned char)(0x40 + i)); - OUTB(crtcdata, vga->extCRTCregs[i]); - } + for (i = 0; i < GFX_EXT_CRTC_REGS; i++) { + OUTB(crtcindex, (unsigned char) (0x40 + i)); + OUTB(crtcdata, vga->extCRTCregs[i]); + } - /* LOCK EXTENDED CRTC REGISTERS */ + /* LOCK EXTENDED CRTC REGISTERS */ - OUTB(crtcindex, 0x30); - OUTB(crtcdata, 0x00); + OUTB(crtcindex, 0x30); + 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. */ - INB(0x3BA); /* Reset flip-flop */ - INB(0x3DA); - OUTB(0x3C0, 0x11); - OUTB(0x3C0, 0x00); - } - } - return (0); + INB(0x3BA); /* Reset flip-flop */ + INB(0x3DA); + OUTB(0x3C0, 0x11); + OUTB(0x3C0, 0x00); + } + } + return (0); } /*----------------------------------------------------------------------------- @@ -645,38 +645,38 @@ gfx_vga_restore(gfx_vga_struct * vga, int flags) int gfx_vga_mode_switch(int active) { - unsigned short crtcindex, crtcdata; + unsigned short crtcindex, crtcdata; - crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; + crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; - /* UNLOCK EXTENDED CRTC REGISTERS */ + /* UNLOCK EXTENDED CRTC REGISTERS */ - OUTB(crtcindex, CRTC_EXTENDED_REGISTER_LOCK); - OUTB(crtcdata, 0x57); - OUTB(crtcdata, 0x4C); + OUTB(crtcindex, CRTC_EXTENDED_REGISTER_LOCK); + OUTB(crtcdata, 0x57); + OUTB(crtcdata, 0x4C); - /* SIGNAL THE BEGINNING OR END OF THE MODE SWITCH */ - /* SoftVGA will hold off validating the back end hardware. */ + /* SIGNAL THE BEGINNING OR END OF THE MODE SWITCH */ + /* SoftVGA will hold off validating the back end hardware. */ - OUTB(crtcindex, CRTC_MODE_SWITCH_CONTROL); - active = active ? 1 : 0; - OUTB(crtcdata, (unsigned char)active); + OUTB(crtcindex, CRTC_MODE_SWITCH_CONTROL); + active = active ? 1 : 0; + OUTB(crtcdata, (unsigned char) active); - /* WAIT UNTIL SOFTVGA HAS VALIDATED MODE IF ENDING MODE SWITCH */ - /* This is for VSA1 only, where SoftVGA waits until the next */ - /* vertical blank to validate the hardware state. */ + /* WAIT UNTIL SOFTVGA HAS VALIDATED MODE IF ENDING MODE SWITCH */ + /* This is for VSA1 only, where SoftVGA waits until the next */ + /* vertical blank to validate the hardware state. */ - if ((!active) && (!(gu1_detect_vsa2()))) { - OUTB(crtcindex, 0x33); - while (INB(crtcdata) & 0x80) ; - } + if ((!active) && (!(gu1_detect_vsa2()))) { + OUTB(crtcindex, 0x33); + while (INB(crtcdata) & 0x80); + } - /* LOCK EXTENDED CRTC REGISTERS */ + /* LOCK EXTENDED CRTC REGISTERS */ - OUTB(crtcindex, CRTC_EXTENDED_REGISTER_LOCK); - OUTB(crtcdata, 0x00); - return (0); + OUTB(crtcindex, CRTC_EXTENDED_REGISTER_LOCK); + OUTB(crtcdata, 0x00); + return (0); } /*----------------------------------------------------------------------------- @@ -689,17 +689,17 @@ gfx_vga_mode_switch(int active) int gu1_detect_vsa2(void) { - unsigned short crtcindex, crtcdata; - - crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; - OUTB(crtcindex, 0x35); - if (INB(crtcdata) != 'C') - return (0); - OUTB(crtcindex, 0x36); - if (INB(crtcdata) != 'X') - return (0); - return (1); + unsigned short crtcindex, crtcdata; + + crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; + OUTB(crtcindex, 0x35); + if (INB(crtcdata) != 'C') + return (0); + OUTB(crtcindex, 0x36); + if (INB(crtcdata) != 'X') + return (0); + return (1); } /* END OF FILE */ diff --git a/src/gfx/vid_1200.c b/src/gfx/vid_1200.c index f52d02b..bc290a5 100644 --- a/src/gfx/vid_1200.c +++ b/src/gfx/vid_1200.c @@ -133,68 +133,66 @@ *---------------------------------------------------------------------------- */ -typedef struct tagSC1200PLL -{ - long frequency; /* 16.16 fixed point frequency */ - unsigned long clock_select; /* clock select register (0x2C) */ -} -SC1200PLL; +typedef struct tagSC1200PLL { + long frequency; /* 16.16 fixed point frequency */ + unsigned long clock_select; /* clock select register (0x2C) */ +} SC1200PLL; SC1200PLL gfx_sc1200_clock_table[] = { - {(25L << 16) | ((1750L * 65536L) / 10000L), 0x0070E00C}, /* 25.1750 (sc=24.9231) */ - {(27L << 16) | ((0000L * 65536L) / 10000L), 0x00300100}, /* 27.0000 */ - {(28L << 16) | ((3220L * 65536L) / 10000L), 0x0070EC0C}, /* 28.3220 (SC=27.000) */ - {(31L << 16) | ((5000L * 65536L) / 10000L), 0x00500D02}, /* 31.5000 */ - {(36L << 16) | ((0000L * 65536L) / 10000L), 0x00500F02}, /* 36.0000 */ - {(37L << 16) | ((5000L * 65536L) / 10000L), 0x0050B108}, /* 37.5000 */ - {(40L << 16) | ((0000L * 65536L) / 10000L), 0x0050D20D}, /* 40.0000 */ - {(44L << 16) | ((9000L * 65536L) / 10000L), 0x0050DC0D}, /* 44.9000 */ - {(49L << 16) | ((5000L * 65536L) / 10000L), 0x00501502}, /* 49.5000 */ - {(50L << 16) | ((0000L * 65536L) / 10000L), 0x0050A404}, /* 50.0000 */ - {(50L << 16) | ((3500L * 65536L) / 10000L), 0x0050E00C}, /* 50.3500 */ - {(54L << 16) | ((0000L * 65536L) / 10000L), 0x00300300}, /* 54.0000 */ - {(56L << 16) | ((3916L * 65536L) / 10000L), 0x0050F40D}, /* 56.3916 */ - {(56L << 16) | ((6440L * 65536L) / 10000L), 0x0050EC0C}, /* 56.6440 */ - {(59L << 16) | ((0000L * 65536L) / 10000L), 0x0030A207}, /* 59.0000 */ - {(63L << 16) | ((0000L * 65536L) / 10000L), 0x00300D02}, /* 63.0000 */ - {(65L << 16) | ((0000L * 65536L) / 10000L), 0x0030CC0F}, /* 65.0000 */ - {(67L << 16) | ((5000L * 65536L) / 10000L), 0x00300400}, /* 67.5000 */ - {(70L << 16) | ((8000L * 65536L) / 10000L), 0x00301403}, /* 70.8000 */ - {(72L << 16) | ((0000L * 65536L) / 10000L), 0x00300F02}, /* 72.0000 */ - {(75L << 16) | ((0000L * 65536L) / 10000L), 0x0030B108}, /* 75.0000 */ - {(78L << 16) | ((7500L * 65536L) / 10000L), 0x0030A205}, /* 78.7500 */ - {(80L << 16) | ((0000L * 65536L) / 10000L), 0x0030D20D}, /* 80.0000 */ - {(87L << 16) | ((2728L * 65536L) / 10000L), 0x0030E00E}, /* 87.2728 */ - {(89L << 16) | ((8000L * 65536L) / 10000L), 0x0030DC0D}, /* 89.8000 */ - {(94L << 16) | ((5000L * 65536L) / 10000L), 0x00300600}, /* 99.0000 */ - {(99L << 16) | ((0000L * 65536L) / 10000L), 0x00301502}, /* 99.0000 */ - {(100L << 16) | ((0000L * 65536L) / 10000L), 0x0030A404}, /* 100.00 */ - {(108L << 16) | ((0000L * 65536L) / 10000L), 0x00100300}, /* 108.00 */ - {(112L << 16) | ((5000L * 65536L) / 10000L), 0x00301802}, /* 108.00 */ - {(130L << 16) | ((0000L * 65536L) / 10000L), 0x0010CC0F}, /* 130.00 */ - {(135L << 16) | ((0000L * 65536L) / 10000L), 0x00100400}, /* 135.00 */ - {(157L << 16) | ((5000L * 65536L) / 10000L), 0x0010A205}, /* 157.50 */ - {(162L << 16) | ((0000L * 65536L) / 10000L), 0x00100500}, /* 162.00 */ - {(175L << 16) | ((0000L * 65536L) / 10000L), 0x0010E00E}, /* 175.50 */ - {(189L << 16) | ((0000L * 65536L) / 10000L), 0x00100600}, /* 189.00 */ - {(202L << 16) | ((0000L * 65536L) / 10000L), 0x0010EF0E}, /* 202.50 */ - {(232L << 16) | ((0000L * 65536L) / 10000L), 0x0010AA04}, /* 232.50 */ - - /* Precomputed inidces in the hardware */ - {0x0018EC4D, 0x000F0000}, /* 24.923052 */ - {0x00192CCC, 0x00000000}, /* 25.1750 */ - {0x001B0000, 0x00300100}, /* 27.0000 */ - {0x001F8000, 0x00010000}, /* 31.5000 */ - {0x00240000, 0x00020000}, /* 36.0000 */ - {0x00280000, 0x00030000}, /* 40.0000 */ - {0x00318000, 0x00050000}, /* 49.5000 */ - {0x00320000, 0x00040000}, /* 50.0000 */ - {0x00384000, 0x00060000}, /* 56.2500 */ - {0x00410000, 0x00080000}, /* 65.0000 */ - {0x004E8000, 0x000A0000}, /* 78.5000 */ - {0x005E8000, 0x000B0000}, /* 94.5000 */ - {0x006C0000, 0x000C0000}, /* 108.0000 */ - {0x00870000, 0x000D0000}, /* 135.0000 */ + {(25L << 16) | ((1750L * 65536L) / 10000L), 0x0070E00C}, /* 25.1750 (sc=24.9231) */ + {(27L << 16) | ((0000L * 65536L) / 10000L), 0x00300100}, /* 27.0000 */ + {(28L << 16) | ((3220L * 65536L) / 10000L), 0x0070EC0C}, /* 28.3220 (SC=27.000) */ + {(31L << 16) | ((5000L * 65536L) / 10000L), 0x00500D02}, /* 31.5000 */ + {(36L << 16) | ((0000L * 65536L) / 10000L), 0x00500F02}, /* 36.0000 */ + {(37L << 16) | ((5000L * 65536L) / 10000L), 0x0050B108}, /* 37.5000 */ + {(40L << 16) | ((0000L * 65536L) / 10000L), 0x0050D20D}, /* 40.0000 */ + {(44L << 16) | ((9000L * 65536L) / 10000L), 0x0050DC0D}, /* 44.9000 */ + {(49L << 16) | ((5000L * 65536L) / 10000L), 0x00501502}, /* 49.5000 */ + {(50L << 16) | ((0000L * 65536L) / 10000L), 0x0050A404}, /* 50.0000 */ + {(50L << 16) | ((3500L * 65536L) / 10000L), 0x0050E00C}, /* 50.3500 */ + {(54L << 16) | ((0000L * 65536L) / 10000L), 0x00300300}, /* 54.0000 */ + {(56L << 16) | ((3916L * 65536L) / 10000L), 0x0050F40D}, /* 56.3916 */ + {(56L << 16) | ((6440L * 65536L) / 10000L), 0x0050EC0C}, /* 56.6440 */ + {(59L << 16) | ((0000L * 65536L) / 10000L), 0x0030A207}, /* 59.0000 */ + {(63L << 16) | ((0000L * 65536L) / 10000L), 0x00300D02}, /* 63.0000 */ + {(65L << 16) | ((0000L * 65536L) / 10000L), 0x0030CC0F}, /* 65.0000 */ + {(67L << 16) | ((5000L * 65536L) / 10000L), 0x00300400}, /* 67.5000 */ + {(70L << 16) | ((8000L * 65536L) / 10000L), 0x00301403}, /* 70.8000 */ + {(72L << 16) | ((0000L * 65536L) / 10000L), 0x00300F02}, /* 72.0000 */ + {(75L << 16) | ((0000L * 65536L) / 10000L), 0x0030B108}, /* 75.0000 */ + {(78L << 16) | ((7500L * 65536L) / 10000L), 0x0030A205}, /* 78.7500 */ + {(80L << 16) | ((0000L * 65536L) / 10000L), 0x0030D20D}, /* 80.0000 */ + {(87L << 16) | ((2728L * 65536L) / 10000L), 0x0030E00E}, /* 87.2728 */ + {(89L << 16) | ((8000L * 65536L) / 10000L), 0x0030DC0D}, /* 89.8000 */ + {(94L << 16) | ((5000L * 65536L) / 10000L), 0x00300600}, /* 99.0000 */ + {(99L << 16) | ((0000L * 65536L) / 10000L), 0x00301502}, /* 99.0000 */ + {(100L << 16) | ((0000L * 65536L) / 10000L), 0x0030A404}, /* 100.00 */ + {(108L << 16) | ((0000L * 65536L) / 10000L), 0x00100300}, /* 108.00 */ + {(112L << 16) | ((5000L * 65536L) / 10000L), 0x00301802}, /* 108.00 */ + {(130L << 16) | ((0000L * 65536L) / 10000L), 0x0010CC0F}, /* 130.00 */ + {(135L << 16) | ((0000L * 65536L) / 10000L), 0x00100400}, /* 135.00 */ + {(157L << 16) | ((5000L * 65536L) / 10000L), 0x0010A205}, /* 157.50 */ + {(162L << 16) | ((0000L * 65536L) / 10000L), 0x00100500}, /* 162.00 */ + {(175L << 16) | ((0000L * 65536L) / 10000L), 0x0010E00E}, /* 175.50 */ + {(189L << 16) | ((0000L * 65536L) / 10000L), 0x00100600}, /* 189.00 */ + {(202L << 16) | ((0000L * 65536L) / 10000L), 0x0010EF0E}, /* 202.50 */ + {(232L << 16) | ((0000L * 65536L) / 10000L), 0x0010AA04}, /* 232.50 */ + + /* Precomputed inidces in the hardware */ + {0x0018EC4D, 0x000F0000}, /* 24.923052 */ + {0x00192CCC, 0x00000000}, /* 25.1750 */ + {0x001B0000, 0x00300100}, /* 27.0000 */ + {0x001F8000, 0x00010000}, /* 31.5000 */ + {0x00240000, 0x00020000}, /* 36.0000 */ + {0x00280000, 0x00030000}, /* 40.0000 */ + {0x00318000, 0x00050000}, /* 49.5000 */ + {0x00320000, 0x00040000}, /* 50.0000 */ + {0x00384000, 0x00060000}, /* 56.2500 */ + {0x00410000, 0x00080000}, /* 65.0000 */ + {0x004E8000, 0x000A0000}, /* 78.5000 */ + {0x005E8000, 0x000B0000}, /* 94.5000 */ + {0x006C0000, 0x000C0000}, /* 108.0000 */ + {0x00870000, 0x000D0000}, /* 135.0000 */ }; #define NUM_SC1200_FREQUENCIES sizeof(gfx_sc1200_clock_table)/sizeof(SC1200PLL) @@ -205,27 +203,27 @@ int sc1200_set_video_size(unsigned short width, unsigned short height); int sc1200_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch); int sc1200_set_video_offset(unsigned long offset); int sc1200_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset, - unsigned long voffset); + unsigned long voffset); int sc1200_set_video_window(short x, short y, unsigned short w, - unsigned short h); + unsigned short h); int sc1200_set_video_left_crop(unsigned short x); int sc1200_set_video_upscale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); + unsigned short dstw, unsigned short dsth); int sc1200_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); + unsigned short dstw, unsigned short dsth); int sc1200_set_video_vertical_downscale(unsigned short srch, - unsigned short dsth); + unsigned short dsth); void sc1200_set_video_vertical_downscale_enable(int enable); int sc1200_set_video_downscale_config(unsigned short type, unsigned short m); int sc1200_set_video_color_key(unsigned long key, unsigned long mask, - int bluescreen); + int bluescreen); int sc1200_set_video_filter(int xfilter, int yfilter); int sc1200_set_video_palette(unsigned long *palette); int sc1200_set_video_palette_entry(unsigned long index, unsigned long color); int sc1200_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4); + unsigned short coef2, + unsigned short coef3, + unsigned short coef4); int sc1200_set_video_downscale_enable(int enable); int sc1200_set_video_source(VideoSourceType source); int sc1200_set_vbi_source(VbiSourceType source); @@ -238,15 +236,15 @@ int sc1200_set_top_line_in_odd(int enable); int sc1200_set_genlock_delay(unsigned long delay); int sc1200_set_genlock_enable(int flags); int sc1200_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, - unsigned long color1, unsigned long color2); + unsigned short select_color2, + unsigned long color1, unsigned long color2); int sc1200_set_video_cursor_enable(int enable); int sc1200_set_video_request(short x, short y); int sc1200_select_alpha_region(int region); int sc1200_set_alpha_enable(int enable); int sc1200_set_alpha_window(short x, short y, - unsigned short width, unsigned short height); + unsigned short width, unsigned short height); int sc1200_set_alpha_value(unsigned char alpha, char delta); int sc1200_set_alpha_priority(int priority); int sc1200_set_alpha_color(unsigned long color); @@ -270,27 +268,24 @@ unsigned long sc1200_get_video_line_size(void); unsigned long sc1200_get_video_xclip(void); unsigned long sc1200_get_video_offset(void); void sc1200_get_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset); -void sc1200_get_video_yuv_pitch(unsigned long *ypitch, - unsigned long *uvpitch); + unsigned long *uoffset, + unsigned long *voffset); +void sc1200_get_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch); unsigned long sc1200_get_video_upscale(void); unsigned long sc1200_get_video_scale(void); unsigned long sc1200_get_video_downscale_delta(void); int sc1200_get_video_vertical_downscale_enable(void); -int sc1200_get_video_downscale_config(unsigned short *type, - unsigned short *m); +int sc1200_get_video_downscale_config(unsigned short *type, unsigned short *m); void sc1200_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4); + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4); void sc1200_get_video_downscale_enable(int *enable); unsigned long sc1200_get_video_dst_size(void); unsigned long sc1200_get_video_position(void); unsigned long sc1200_get_video_color_key(void); unsigned long sc1200_get_video_color_key_mask(void); -int sc1200_get_video_palette_entry(unsigned long index, - unsigned long *palette); +int sc1200_get_video_palette_entry(unsigned long index, unsigned long *palette); int sc1200_get_video_color_key_src(void); int sc1200_get_video_filter(void); int sc1200_get_video_request(short *x, short *y); @@ -304,18 +299,18 @@ int sc1200_get_vertical_scaler_offset(char *offset); unsigned long sc1200_get_genlock_delay(void); int sc1200_get_genlock_enable(void); int sc1200_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, - unsigned long *color1, unsigned short *color2); + unsigned short *select_color2, + unsigned long *color1, unsigned short *color2); unsigned long sc1200_read_crc(void); unsigned long sc1200_read_crc32(void); unsigned long sc1200_read_window_crc(int source, unsigned short x, - unsigned short y, unsigned short width, - unsigned short height, int crc32); + unsigned short y, unsigned short width, + unsigned short height, int crc32); int sc1200_get_macrovision_enable(void); void sc1200_get_alpha_enable(int *enable); void sc1200_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height); + unsigned short *width, unsigned short *height); void sc1200_get_alpha_value(unsigned char *alpha, char *delta); void sc1200_get_alpha_priority(int *priority); void sc1200_get_alpha_color(unsigned long *color); @@ -338,17 +333,17 @@ void gfx_reset_video(void) #endif { - int i; + int i; - gfx_set_video_enable(0); + gfx_set_video_enable(0); - /* SET WINDOW 0 AFTER RESET */ + /* SET WINDOW 0 AFTER RESET */ - for (i = 2; i >= 0; i--) { - gfx_select_alpha_region(i); - gfx_set_alpha_enable(0); - gfx_set_alpha_color_enable(0); - } + for (i = 2; i >= 0; i--) { + gfx_select_alpha_region(i); + gfx_set_alpha_enable(0); + gfx_set_alpha_color_enable(0); + } } /*----------------------------------------------------------------------------- @@ -374,31 +369,31 @@ int gfx_set_display_control(int sync_polarities) #endif { - unsigned long dcfg; + unsigned long dcfg; - /* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */ + /* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */ - dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); - dcfg &= ~(SC1200_DCFG_CRT_SYNC_SKW_MASK | SC1200_DCFG_PWR_SEQ_DLY_MASK | - SC1200_DCFG_CRT_HSYNC_POL | SC1200_DCFG_CRT_VSYNC_POL | - SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); + dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); + dcfg &= ~(SC1200_DCFG_CRT_SYNC_SKW_MASK | SC1200_DCFG_PWR_SEQ_DLY_MASK | + SC1200_DCFG_CRT_HSYNC_POL | SC1200_DCFG_CRT_VSYNC_POL | + SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); - dcfg |= (SC1200_DCFG_CRT_SYNC_SKW_INIT | - SC1200_DCFG_PWR_SEQ_DLY_INIT | SC1200_DCFG_GV_PAL_BYP); + dcfg |= (SC1200_DCFG_CRT_SYNC_SKW_INIT | + SC1200_DCFG_PWR_SEQ_DLY_INIT | SC1200_DCFG_GV_PAL_BYP); - if (PanelEnable) - dcfg |= SC1200_DCFG_FP_PWR_EN; + if (PanelEnable) + dcfg |= SC1200_DCFG_FP_PWR_EN; - /* SET APPROPRIATE SYNC POLARITIES */ + /* SET APPROPRIATE SYNC POLARITIES */ - if (sync_polarities & 0x1) - dcfg |= SC1200_DCFG_CRT_HSYNC_POL; - if (sync_polarities & 0x2) - dcfg |= SC1200_DCFG_CRT_VSYNC_POL; + if (sync_polarities & 0x1) + dcfg |= SC1200_DCFG_CRT_HSYNC_POL; + if (sync_polarities & 0x2) + dcfg |= SC1200_DCFG_CRT_VSYNC_POL; - WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); + WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -417,33 +412,33 @@ void gfx_set_clock_frequency(unsigned long frequency) #endif { - unsigned int index; - unsigned long value, pll; - long min, diff; + unsigned int index; + unsigned long value, pll; + long min, diff; - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ - value = gfx_sc1200_clock_table[0].clock_select; - min = (long)gfx_sc1200_clock_table[0].frequency - frequency; - if (min < 0L) - min = -min; - for (index = 1; index < NUM_SC1200_FREQUENCIES; index++) { - diff = (long)gfx_sc1200_clock_table[index].frequency - frequency; - if (diff < 0L) - diff = -diff; - if (diff < min) { - min = diff; - value = gfx_sc1200_clock_table[index].clock_select; - } - } + value = gfx_sc1200_clock_table[0].clock_select; + min = (long) gfx_sc1200_clock_table[0].frequency - frequency; + if (min < 0L) + min = -min; + for (index = 1; index < NUM_SC1200_FREQUENCIES; index++) { + diff = (long) gfx_sc1200_clock_table[index].frequency - frequency; + if (diff < 0L) + diff = -diff; + if (diff < min) { + min = diff; + value = gfx_sc1200_clock_table[index].clock_select; + } + } - /* SET THE DOT CLOCK REGISTER */ + /* SET THE DOT CLOCK REGISTER */ - pll = READ_VID32(SC1200_VID_MISC); - WRITE_VID32(SC1200_VID_MISC, pll | SC1200_PLL_POWER_NORMAL); - WRITE_VID32(SC1200_VID_CLOCK_SELECT, value); - return; + pll = READ_VID32(SC1200_VID_MISC); + WRITE_VID32(SC1200_VID_MISC, pll | SC1200_PLL_POWER_NORMAL); + WRITE_VID32(SC1200_VID_CLOCK_SELECT, value); + return; } /*--------------------------------------------------------------------------- @@ -460,14 +455,14 @@ int gfx_set_screen_enable(int enable) #endif { - unsigned long config; + unsigned long config; - config = READ_VID32(SC1200_DISPLAY_CONFIG); - if (enable) - WRITE_VID32(SC1200_DISPLAY_CONFIG, config | SC1200_DCFG_DIS_EN); - else - WRITE_VID32(SC1200_DISPLAY_CONFIG, config & ~SC1200_DCFG_DIS_EN); - return (GFX_STATUS_OK); + config = READ_VID32(SC1200_DISPLAY_CONFIG); + if (enable) + WRITE_VID32(SC1200_DISPLAY_CONFIG, config | SC1200_DCFG_DIS_EN); + else + WRITE_VID32(SC1200_DISPLAY_CONFIG, config & ~SC1200_DCFG_DIS_EN); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -484,47 +479,47 @@ int gfx_set_crt_enable(int enable) #endif { - unsigned long config, misc; - - config = READ_VID32(SC1200_DISPLAY_CONFIG); - misc = READ_VID32(SC1200_VID_MISC); - - /* - * IMPORTANT: For all modes do NOT disable the graphics display logic - * because it might be needed for TV - */ - - switch (enable) { - case CRT_DISABLE: /* HSync:Off VSync:Off */ - WRITE_VID32(SC1200_DISPLAY_CONFIG, config & ~(SC1200_DCFG_HSYNC_EN - | SC1200_DCFG_VSYNC_EN - | SC1200_DCFG_DAC_BL_EN)); - WRITE_VID32(SC1200_VID_MISC, misc | SC1200_DAC_POWER_DOWN); - break; - case CRT_ENABLE: /* Enable CRT display, including display logic */ - WRITE_VID32(SC1200_DISPLAY_CONFIG, config | SC1200_DCFG_HSYNC_EN - | SC1200_DCFG_VSYNC_EN | SC1200_DCFG_DAC_BL_EN); - WRITE_VID32(SC1200_VID_MISC, misc & ~SC1200_DAC_POWER_DOWN); - - /* ENABLE GRAPHICS DISPLAY LOGIC */ - gfx_set_screen_enable(1); - break; - case CRT_STANDBY: /* HSync:Off VSync:On */ - WRITE_VID32(SC1200_DISPLAY_CONFIG, (config & ~(SC1200_DCFG_HSYNC_EN - | SC1200_DCFG_DAC_BL_EN)) - | SC1200_DCFG_VSYNC_EN); - WRITE_VID32(SC1200_VID_MISC, misc | SC1200_DAC_POWER_DOWN); - break; - case CRT_SUSPEND: /* HSync:On VSync:Off */ - WRITE_VID32(SC1200_DISPLAY_CONFIG, (config & ~(SC1200_DCFG_VSYNC_EN - | SC1200_DCFG_DAC_BL_EN)) - | SC1200_DCFG_HSYNC_EN); - WRITE_VID32(SC1200_VID_MISC, misc | SC1200_DAC_POWER_DOWN); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - return (GFX_STATUS_OK); + unsigned long config, misc; + + config = READ_VID32(SC1200_DISPLAY_CONFIG); + misc = READ_VID32(SC1200_VID_MISC); + + /* + * IMPORTANT: For all modes do NOT disable the graphics display logic + * because it might be needed for TV + */ + + switch (enable) { + case CRT_DISABLE: /* HSync:Off VSync:Off */ + WRITE_VID32(SC1200_DISPLAY_CONFIG, config & ~(SC1200_DCFG_HSYNC_EN + | SC1200_DCFG_VSYNC_EN + | SC1200_DCFG_DAC_BL_EN)); + WRITE_VID32(SC1200_VID_MISC, misc | SC1200_DAC_POWER_DOWN); + break; + case CRT_ENABLE: /* Enable CRT display, including display logic */ + WRITE_VID32(SC1200_DISPLAY_CONFIG, config | SC1200_DCFG_HSYNC_EN + | SC1200_DCFG_VSYNC_EN | SC1200_DCFG_DAC_BL_EN); + WRITE_VID32(SC1200_VID_MISC, misc & ~SC1200_DAC_POWER_DOWN); + + /* ENABLE GRAPHICS DISPLAY LOGIC */ + gfx_set_screen_enable(1); + break; + case CRT_STANDBY: /* HSync:Off VSync:On */ + WRITE_VID32(SC1200_DISPLAY_CONFIG, (config & ~(SC1200_DCFG_HSYNC_EN + | SC1200_DCFG_DAC_BL_EN)) + | SC1200_DCFG_VSYNC_EN); + WRITE_VID32(SC1200_VID_MISC, misc | SC1200_DAC_POWER_DOWN); + break; + case CRT_SUSPEND: /* HSync:On VSync:Off */ + WRITE_VID32(SC1200_DISPLAY_CONFIG, (config & ~(SC1200_DCFG_VSYNC_EN + | SC1200_DCFG_DAC_BL_EN)) + | SC1200_DCFG_HSYNC_EN); + WRITE_VID32(SC1200_VID_MISC, misc | SC1200_DAC_POWER_DOWN); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -541,41 +536,42 @@ int gfx_set_video_enable(int enable) #endif { - unsigned long vcfg; + unsigned long vcfg; - /* WAIT FOR VERTICAL BLANK TO START */ - /* Otherwise a glitch can be observed. */ + /* WAIT FOR VERTICAL BLANK TO START */ + /* Otherwise a glitch can be observed. */ - if (gfx_test_timing_active()) { - if (!gfx_test_vertical_active()) { - while (!gfx_test_vertical_active()) ; - } - while (gfx_test_vertical_active()) ; - } + if (gfx_test_timing_active()) { + if (!gfx_test_vertical_active()) { + while (!gfx_test_vertical_active()); + } + while (gfx_test_vertical_active()); + } - vcfg = READ_VID32(SC1200_VIDEO_CONFIG); - if (enable) { - /* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + vcfg = READ_VID32(SC1200_VIDEO_CONFIG); + if (enable) { + /* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_enable(1); + gfx_set_display_video_enable(1); - /* ENABLE SC1200 VIDEO OVERLAY */ + /* ENABLE SC1200 VIDEO OVERLAY */ - vcfg |= SC1200_VCFG_VID_EN; - WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); - } else { - /* DISABLE SC1200 VIDEO OVERLAY */ + vcfg |= SC1200_VCFG_VID_EN; + WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); + } + else { + /* DISABLE SC1200 VIDEO OVERLAY */ - vcfg &= ~SC1200_VCFG_VID_EN; - WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); + vcfg &= ~SC1200_VCFG_VID_EN; + WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); - /* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_enable(0); - } - return (0); + gfx_set_display_video_enable(0); + } + return (0); } /*----------------------------------------------------------------------------- @@ -592,78 +588,78 @@ int gfx_set_video_format(unsigned long format) #endif { - unsigned long ctrl, vcfg = 0; - - /* SET THE SC1200 VIDEO INPUT FORMAT */ - - vcfg = READ_VID32(SC1200_VIDEO_CONFIG); - ctrl = READ_VID32(SC1200_VID_ALPHA_CONTROL); - ctrl &= ~(SC1200_VIDEO_INPUT_IS_RGB); - vcfg &= ~(SC1200_VCFG_VID_INP_FORMAT | SC1200_VCFG_4_2_0_MODE); - switch (format) { - case VIDEO_FORMAT_UYVY: - vcfg |= SC1200_VCFG_UYVY_FORMAT; - break; - case VIDEO_FORMAT_YUYV: - vcfg |= SC1200_VCFG_YUYV_FORMAT; - break; - case VIDEO_FORMAT_Y2YU: - vcfg |= SC1200_VCFG_Y2YU_FORMAT; - break; - case VIDEO_FORMAT_YVYU: - vcfg |= SC1200_VCFG_YVYU_FORMAT; - break; - case VIDEO_FORMAT_Y0Y1Y2Y3: - vcfg |= SC1200_VCFG_UYVY_FORMAT; - vcfg |= SC1200_VCFG_4_2_0_MODE; - break; - case VIDEO_FORMAT_Y3Y2Y1Y0: - vcfg |= SC1200_VCFG_Y2YU_FORMAT; - vcfg |= SC1200_VCFG_4_2_0_MODE; - break; - case VIDEO_FORMAT_Y1Y0Y3Y2: - vcfg |= SC1200_VCFG_YUYV_FORMAT; - vcfg |= SC1200_VCFG_4_2_0_MODE; - break; - case VIDEO_FORMAT_Y1Y2Y3Y0: - vcfg |= SC1200_VCFG_YVYU_FORMAT; - vcfg |= SC1200_VCFG_4_2_0_MODE; - break; - case VIDEO_FORMAT_RGB: - ctrl |= SC1200_VIDEO_INPUT_IS_RGB; - vcfg |= SC1200_VCFG_UYVY_FORMAT; - break; - case VIDEO_FORMAT_P2M_P2L_P1M_P1L: - ctrl |= SC1200_VIDEO_INPUT_IS_RGB; - vcfg |= SC1200_VCFG_Y2YU_FORMAT; - break; - case VIDEO_FORMAT_P1M_P1L_P2M_P2L: - ctrl |= SC1200_VIDEO_INPUT_IS_RGB; - vcfg |= SC1200_VCFG_YUYV_FORMAT; - break; - case VIDEO_FORMAT_P1M_P2L_P2M_P1L: - ctrl |= SC1200_VIDEO_INPUT_IS_RGB; - vcfg |= SC1200_VCFG_YVYU_FORMAT; - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - - /* ALWAYS DISABLE GRAPHICS CSC */ - /* This is enabled in the function gfx_set_color_space_YUV for */ - /* YUV blending on TV. */ - - ctrl &= ~SC1200_CSC_GFX_RGB_TO_YUV; - - if (ctrl & SC1200_VIDEO_INPUT_IS_RGB) - ctrl &= ~SC1200_CSC_VIDEO_YUV_TO_RGB; - else - ctrl |= SC1200_CSC_VIDEO_YUV_TO_RGB; - - WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, ctrl); - - return (0); + unsigned long ctrl, vcfg = 0; + + /* SET THE SC1200 VIDEO INPUT FORMAT */ + + vcfg = READ_VID32(SC1200_VIDEO_CONFIG); + ctrl = READ_VID32(SC1200_VID_ALPHA_CONTROL); + ctrl &= ~(SC1200_VIDEO_INPUT_IS_RGB); + vcfg &= ~(SC1200_VCFG_VID_INP_FORMAT | SC1200_VCFG_4_2_0_MODE); + switch (format) { + case VIDEO_FORMAT_UYVY: + vcfg |= SC1200_VCFG_UYVY_FORMAT; + break; + case VIDEO_FORMAT_YUYV: + vcfg |= SC1200_VCFG_YUYV_FORMAT; + break; + case VIDEO_FORMAT_Y2YU: + vcfg |= SC1200_VCFG_Y2YU_FORMAT; + break; + case VIDEO_FORMAT_YVYU: + vcfg |= SC1200_VCFG_YVYU_FORMAT; + break; + case VIDEO_FORMAT_Y0Y1Y2Y3: + vcfg |= SC1200_VCFG_UYVY_FORMAT; + vcfg |= SC1200_VCFG_4_2_0_MODE; + break; + case VIDEO_FORMAT_Y3Y2Y1Y0: + vcfg |= SC1200_VCFG_Y2YU_FORMAT; + vcfg |= SC1200_VCFG_4_2_0_MODE; + break; + case VIDEO_FORMAT_Y1Y0Y3Y2: + vcfg |= SC1200_VCFG_YUYV_FORMAT; + vcfg |= SC1200_VCFG_4_2_0_MODE; + break; + case VIDEO_FORMAT_Y1Y2Y3Y0: + vcfg |= SC1200_VCFG_YVYU_FORMAT; + vcfg |= SC1200_VCFG_4_2_0_MODE; + break; + case VIDEO_FORMAT_RGB: + ctrl |= SC1200_VIDEO_INPUT_IS_RGB; + vcfg |= SC1200_VCFG_UYVY_FORMAT; + break; + case VIDEO_FORMAT_P2M_P2L_P1M_P1L: + ctrl |= SC1200_VIDEO_INPUT_IS_RGB; + vcfg |= SC1200_VCFG_Y2YU_FORMAT; + break; + case VIDEO_FORMAT_P1M_P1L_P2M_P2L: + ctrl |= SC1200_VIDEO_INPUT_IS_RGB; + vcfg |= SC1200_VCFG_YUYV_FORMAT; + break; + case VIDEO_FORMAT_P1M_P2L_P2M_P1L: + ctrl |= SC1200_VIDEO_INPUT_IS_RGB; + vcfg |= SC1200_VCFG_YVYU_FORMAT; + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + + /* ALWAYS DISABLE GRAPHICS CSC */ + /* This is enabled in the function gfx_set_color_space_YUV for */ + /* YUV blending on TV. */ + + ctrl &= ~SC1200_CSC_GFX_RGB_TO_YUV; + + if (ctrl & SC1200_VIDEO_INPUT_IS_RGB) + ctrl &= ~SC1200_CSC_VIDEO_YUV_TO_RGB; + else + ctrl |= SC1200_CSC_VIDEO_YUV_TO_RGB; + + WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, ctrl); + + return (0); } /*----------------------------------------------------------------------------- @@ -682,24 +678,24 @@ int gfx_set_video_size(unsigned short width, unsigned short height) #endif { - unsigned long size, vcfg; + unsigned long size, vcfg; - /* SET THE SC1200 VIDEO LINE SIZE */ + /* SET THE SC1200 VIDEO LINE SIZE */ - vcfg = READ_VID32(SC1200_VIDEO_CONFIG); - vcfg &= ~(SC1200_VCFG_LINE_SIZE_LOWER_MASK | SC1200_VCFG_LINE_SIZE_UPPER); - size = (width >> 1); - vcfg |= (size & 0x00FF) << 8; - if (size & 0x0100) - vcfg |= SC1200_VCFG_LINE_SIZE_UPPER; - WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); + vcfg = READ_VID32(SC1200_VIDEO_CONFIG); + vcfg &= ~(SC1200_VCFG_LINE_SIZE_LOWER_MASK | SC1200_VCFG_LINE_SIZE_UPPER); + size = (width >> 1); + vcfg |= (size & 0x00FF) << 8; + if (size & 0x0100) + vcfg |= SC1200_VCFG_LINE_SIZE_UPPER; + WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); - /* SET TOTAL VIDEO BUFFER SIZE IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET TOTAL VIDEO BUFFER SIZE IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - /* Add 1 line to bypass issue #803 */ - gfx_set_display_video_size(width, (unsigned short)(height + 2)); - return (0); + /* Add 1 line to bypass issue #803 */ + gfx_set_display_video_size(width, (unsigned short) (height + 2)); + return (0); } /*----------------------------------------------------------------------------- @@ -717,15 +713,15 @@ int gfx_set_video_offset(unsigned long offset) #endif { - /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ + /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ - gfx_vid_offset = offset; + gfx_vid_offset = offset; - /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_offset(offset); - return (0); + gfx_set_display_video_offset(offset); + return (0); } /*--------------------------------------------------------------------------- @@ -738,57 +734,57 @@ gfx_set_video_offset(unsigned long offset) #if GFX_VIDEO_DYNAMIC int sc1200_set_video_upscale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #else int gfx_set_video_upscale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #endif { - unsigned long xscale, yscale; + unsigned long xscale, yscale; - /* SAVE PARAMETERS (unless don't-care zero destination arguments are used) */ - /* These are needed for clipping the video window later. */ + /* SAVE PARAMETERS (unless don't-care zero destination arguments are used) */ + /* These are needed for clipping the video window later. */ - if (dstw != 0) { - gfx_vid_srcw = srcw; - gfx_vid_dstw = dstw; - } - if (dsth != 0) { - gfx_vid_srch = srch; - gfx_vid_dsth = dsth; - } + if (dstw != 0) { + gfx_vid_srcw = srcw; + gfx_vid_dstw = dstw; + } + if (dsth != 0) { + gfx_vid_srch = srch; + gfx_vid_dsth = dsth; + } - /* CALCULATE SC1200 SCALE FACTORS */ + /* CALCULATE SC1200 SCALE FACTORS */ - if (dstw == 0) - xscale = READ_VID32(SC1200_VIDEO_UPSCALE) & 0xffff; /* keep previous if don't-care argument */ - else if (dstw <= srcw) - xscale = 0x2000l; /* horizontal downscaling is currently done in a separate function */ - else if ((srcw == 1) || (dstw == 1)) - return GFX_STATUS_BAD_PARAMETER; - else - xscale = (0x2000l * (srcw - 1l)) / (dstw - 1l); + if (dstw == 0) + xscale = READ_VID32(SC1200_VIDEO_UPSCALE) & 0xffff; /* keep previous if don't-care argument */ + else if (dstw <= srcw) + xscale = 0x2000l; /* horizontal downscaling is currently done in a separate function */ + else if ((srcw == 1) || (dstw == 1)) + return GFX_STATUS_BAD_PARAMETER; + else + xscale = (0x2000l * (srcw - 1l)) / (dstw - 1l); - if (dsth == 0) - yscale = (READ_VID32(SC1200_VIDEO_UPSCALE) & 0xffff0000) >> 16; /* keep previous if don't-care argument */ - else if (dsth <= srch) - yscale = 0x2000l; /* No vertical downscaling in SC1200 so force to 1x if attempted */ - else if ((srch == 1) || (dsth == 1)) - return GFX_STATUS_BAD_PARAMETER; - else - yscale = (0x2000l * (srch - 1l)) / (dsth - 1l); + if (dsth == 0) + yscale = (READ_VID32(SC1200_VIDEO_UPSCALE) & 0xffff0000) >> 16; /* keep previous if don't-care argument */ + else if (dsth <= srch) + yscale = 0x2000l; /* No vertical downscaling in SC1200 so force to 1x if attempted */ + else if ((srch == 1) || (dsth == 1)) + return GFX_STATUS_BAD_PARAMETER; + else + yscale = (0x2000l * (srch - 1l)) / (dsth - 1l); - WRITE_VID32(SC1200_VIDEO_UPSCALE, (yscale << 16) | xscale); + WRITE_VID32(SC1200_VIDEO_UPSCALE, (yscale << 16) | xscale); - /* CALL ROUTINE TO UPDATE WINDOW POSITION */ - /* This is required because the scale values effect the number of */ - /* source data pixels that need to be clipped, as well as the */ - /* amount of data that needs to be transferred. */ + /* CALL ROUTINE TO UPDATE WINDOW POSITION */ + /* This is required because the scale values effect the number of */ + /* source data pixels that need to be clipped, as well as the */ + /* amount of data that needs to be transferred. */ - gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width, - gfx_vid_height); - return (0); + gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width, + gfx_vid_height); + return (0); } /*--------------------------------------------------------------------------- @@ -801,14 +797,14 @@ gfx_set_video_upscale(unsigned short srcw, unsigned short srch, #if GFX_VIDEO_DYNAMIC int sc1200_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #else int gfx_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #endif { - return gfx_set_video_upscale(srcw, srch, dstw, dsth); + return gfx_set_video_upscale(srcw, srch, dstw, dsth); } /*--------------------------------------------------------------------------- @@ -826,28 +822,28 @@ int gfx_set_video_downscale_config(unsigned short type, unsigned short m) #endif { - unsigned long downscale; + unsigned long downscale; - if ((m < 1) || (m > 16)) - return GFX_STATUS_BAD_PARAMETER; + if ((m < 1) || (m > 16)) + return GFX_STATUS_BAD_PARAMETER; - downscale = READ_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL); - downscale &= - ~(SC1200_VIDEO_DOWNSCALE_FACTOR_MASK | - SC1200_VIDEO_DOWNSCALE_TYPE_MASK); - downscale |= ((m - 1l) << SC1200_VIDEO_DOWNSCALE_FACTOR_POS); - switch (type) { - case VIDEO_DOWNSCALE_KEEP_1_OF: - downscale |= SC1200_VIDEO_DOWNSCALE_TYPE_A; - break; - case VIDEO_DOWNSCALE_DROP_1_OF: - downscale |= SC1200_VIDEO_DOWNSCALE_TYPE_B; - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - WRITE_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL, downscale); - return (0); + downscale = READ_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL); + downscale &= + ~(SC1200_VIDEO_DOWNSCALE_FACTOR_MASK | + SC1200_VIDEO_DOWNSCALE_TYPE_MASK); + downscale |= ((m - 1l) << SC1200_VIDEO_DOWNSCALE_FACTOR_POS); + switch (type) { + case VIDEO_DOWNSCALE_KEEP_1_OF: + downscale |= SC1200_VIDEO_DOWNSCALE_TYPE_A; + break; + case VIDEO_DOWNSCALE_DROP_1_OF: + downscale |= SC1200_VIDEO_DOWNSCALE_TYPE_B; + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + WRITE_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL, downscale); + return (0); } /*--------------------------------------------------------------------------- @@ -859,26 +855,25 @@ gfx_set_video_downscale_config(unsigned short type, unsigned short m) #if GFX_VIDEO_DYNAMIC int sc1200_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4) + unsigned short coef2, + unsigned short coef3, + unsigned short coef4) #else int gfx_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4) + unsigned short coef2, + unsigned short coef3, unsigned short coef4) #endif { - if ((coef1 + coef2 + coef3 + coef4) != 16) - return GFX_STATUS_BAD_PARAMETER; + if ((coef1 + coef2 + coef3 + coef4) != 16) + return GFX_STATUS_BAD_PARAMETER; - WRITE_VID32(SC1200_VIDEO_DOWNSCALER_COEFFICIENTS, - ((unsigned long)coef1 << SC1200_VIDEO_DOWNSCALER_COEF1_POS) | - ((unsigned long)coef2 << SC1200_VIDEO_DOWNSCALER_COEF2_POS) | - ((unsigned long)coef3 << SC1200_VIDEO_DOWNSCALER_COEF3_POS) | - ((unsigned long)coef4 << SC1200_VIDEO_DOWNSCALER_COEF4_POS)); - return (0); + WRITE_VID32(SC1200_VIDEO_DOWNSCALER_COEFFICIENTS, + ((unsigned long) coef1 << SC1200_VIDEO_DOWNSCALER_COEF1_POS) | + ((unsigned long) coef2 << SC1200_VIDEO_DOWNSCALER_COEF2_POS) | + ((unsigned long) coef3 << SC1200_VIDEO_DOWNSCALER_COEF3_POS) | + ((unsigned long) coef4 << SC1200_VIDEO_DOWNSCALER_COEF4_POS)); + return (0); } /*--------------------------------------------------------------------------- @@ -895,14 +890,14 @@ int gfx_set_video_downscale_enable(int enable) #endif { - unsigned long downscale; + unsigned long downscale; - downscale = READ_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL); - downscale &= ~SC1200_VIDEO_DOWNSCALE_ENABLE; - if (enable) - downscale |= SC1200_VIDEO_DOWNSCALE_ENABLE; - WRITE_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL, downscale); - return (0); + downscale = READ_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL); + downscale &= ~SC1200_VIDEO_DOWNSCALE_ENABLE; + if (enable) + downscale |= SC1200_VIDEO_DOWNSCALE_ENABLE; + WRITE_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL, downscale); + return (0); } /*--------------------------------------------------------------------------- @@ -924,69 +919,69 @@ int gfx_set_video_window(short x, short y, unsigned short w, unsigned short h) #endif { - unsigned long control; - unsigned long hadjust, vadjust; - unsigned long xstart, ystart, xend, yend; + unsigned long control; + unsigned long hadjust, vadjust; + unsigned long xstart, ystart, xend, yend; - /* For left cropping call the function gfx_set_video_left_crop() */ + /* For left cropping call the function gfx_set_video_left_crop() */ - if (x < 0) - return GFX_STATUS_BAD_PARAMETER; + if (x < 0) + return GFX_STATUS_BAD_PARAMETER; - /* SAVE PARAMETERS */ - /* These are needed to call this routine if the scale value changes. */ - /* In the case of SC1200 they are also needed for restoring when video is re-enabled */ + /* SAVE PARAMETERS */ + /* These are needed to call this routine if the scale value changes. */ + /* In the case of SC1200 they are also needed for restoring when video is re-enabled */ - gfx_vid_xpos = x; - gfx_vid_ypos = y; - gfx_vid_width = w; - gfx_vid_height = h; + gfx_vid_xpos = x; + gfx_vid_ypos = y; + gfx_vid_width = w; + gfx_vid_height = h; - /* GET ADJUSTMENT VALUES */ - /* Use routines to abstract version of display controller. */ + /* GET ADJUSTMENT VALUES */ + /* Use routines to abstract version of display controller. */ - hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 14l; - vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l; + hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 14l; + vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l; - /* HORIZONTAL START */ + /* HORIZONTAL START */ - xstart = (unsigned long)x + hadjust; + xstart = (unsigned long) x + hadjust; - /* HORIZONTAL END */ - /* End positions in register are non-inclusive (one more than the actual end) */ + /* HORIZONTAL END */ + /* End positions in register are non-inclusive (one more than the actual end) */ - if ((x + w) < gfx_get_hactive()) - xend = (unsigned long)x + (unsigned long)w + hadjust; - else /* right clipping needed */ - xend = (unsigned long)gfx_get_hactive() + hadjust; + if ((x + w) < gfx_get_hactive()) + xend = (unsigned long) x + (unsigned long) w + hadjust; + else /* right clipping needed */ + xend = (unsigned long) gfx_get_hactive() + hadjust; - /* VERTICAL START */ + /* VERTICAL START */ - ystart = (unsigned long)y + vadjust; + ystart = (unsigned long) y + vadjust; - /* VERTICAL END */ + /* VERTICAL END */ - if ((y + h) < gfx_get_vactive()) - yend = (unsigned long)y + (unsigned long)h + vadjust; - else /* bottom clipping needed */ - yend = (unsigned long)gfx_get_vactive() + vadjust; + if ((y + h) < gfx_get_vactive()) + yend = (unsigned long) y + (unsigned long) h + vadjust; + else /* bottom clipping needed */ + yend = (unsigned long) gfx_get_vactive() + vadjust; - /* SET VIDEO LINE INVERT BIT */ + /* SET VIDEO LINE INVERT BIT */ - control = READ_VID32(SC1200_VID_ALPHA_CONTROL); - if (y & 0x1) - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, - control | SC1200_VIDEO_LINE_OFFSET_ODD); - else - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, - control & ~SC1200_VIDEO_LINE_OFFSET_ODD); + control = READ_VID32(SC1200_VID_ALPHA_CONTROL); + if (y & 0x1) + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, + control | SC1200_VIDEO_LINE_OFFSET_ODD); + else + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, + control & ~SC1200_VIDEO_LINE_OFFSET_ODD); - /* SET VIDEO POSITION */ + /* SET VIDEO POSITION */ - WRITE_VID32(SC1200_VIDEO_X_POS, (xend << 16) | xstart); - WRITE_VID32(SC1200_VIDEO_Y_POS, (yend << 16) | ystart); + WRITE_VID32(SC1200_VIDEO_X_POS, (xend << 16) | xstart); + WRITE_VID32(SC1200_VIDEO_Y_POS, (yend << 16) | ystart); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -1006,24 +1001,24 @@ int gfx_set_video_left_crop(unsigned short x) #endif { - unsigned long vcfg, initread; + unsigned long vcfg, initread; - /* CLIPPING ON LEFT */ - /* Adjust initial read for scale, checking for divide by zero */ + /* CLIPPING ON LEFT */ + /* Adjust initial read for scale, checking for divide by zero */ - if (gfx_vid_dstw) - initread = (unsigned long)x *gfx_vid_srcw / gfx_vid_dstw; + if (gfx_vid_dstw) + initread = (unsigned long) x *gfx_vid_srcw / gfx_vid_dstw; - else - initread = 0l; + else + initread = 0l; - /* SET INITIAL READ ADDRESS */ + /* SET INITIAL READ ADDRESS */ - vcfg = READ_VID32(SC1200_VIDEO_CONFIG); - vcfg &= ~SC1200_VCFG_INIT_READ_MASK; - vcfg |= (initread << 15) & SC1200_VCFG_INIT_READ_MASK; - WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); - return (0); + vcfg = READ_VID32(SC1200_VIDEO_CONFIG); + vcfg &= ~SC1200_VCFG_INIT_READ_MASK; + vcfg |= (initread << 15) & SC1200_VCFG_INIT_READ_MASK; + WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -1042,29 +1037,28 @@ gfx_set_video_left_crop(unsigned short x) */ #if GFX_VIDEO_DYNAMIC int -sc1200_set_video_color_key(unsigned long key, unsigned long mask, - int graphics) +sc1200_set_video_color_key(unsigned long key, unsigned long mask, int graphics) #else int gfx_set_video_color_key(unsigned long key, unsigned long mask, int graphics) #endif { - unsigned long dcfg = 0; + unsigned long dcfg = 0; - /* SET SC1200 COLOR KEY VALUE */ + /* SET SC1200 COLOR KEY VALUE */ - WRITE_VID32(SC1200_VIDEO_COLOR_KEY, key); - WRITE_VID32(SC1200_VIDEO_COLOR_MASK, mask); + WRITE_VID32(SC1200_VIDEO_COLOR_KEY, key); + WRITE_VID32(SC1200_VIDEO_COLOR_MASK, mask); - /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */ + /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */ - dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); - if (graphics & 0x01) - dcfg &= ~SC1200_DCFG_VG_CK; - else - dcfg |= SC1200_DCFG_VG_CK; - WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); - return (0); + dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); + if (graphics & 0x01) + dcfg &= ~SC1200_DCFG_VG_CK; + else + dcfg |= SC1200_DCFG_VG_CK; + WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -1081,18 +1075,18 @@ int gfx_set_video_filter(int xfilter, int yfilter) #endif { - unsigned long vcfg = 0; + unsigned long vcfg = 0; - /* ENABLE OR DISABLE SC1200 VIDEO OVERLAY FILTERS */ + /* ENABLE OR DISABLE SC1200 VIDEO OVERLAY FILTERS */ - vcfg = READ_VID32(SC1200_VIDEO_CONFIG); - vcfg &= ~(SC1200_VCFG_X_FILTER_EN | SC1200_VCFG_Y_FILTER_EN); - if (xfilter) - vcfg |= SC1200_VCFG_X_FILTER_EN; - if (yfilter) - vcfg |= SC1200_VCFG_Y_FILTER_EN; - WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); - return (0); + vcfg = READ_VID32(SC1200_VIDEO_CONFIG); + vcfg &= ~(SC1200_VCFG_X_FILTER_EN | SC1200_VCFG_Y_FILTER_EN); + if (xfilter) + vcfg |= SC1200_VCFG_X_FILTER_EN; + if (yfilter) + vcfg |= SC1200_VCFG_Y_FILTER_EN; + WRITE_VID32(SC1200_VIDEO_CONFIG, vcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -1111,29 +1105,29 @@ int gfx_set_video_palette(unsigned long *palette) #endif { - unsigned long i, entry; + unsigned long i, entry; - /* WAIT FOR VERTICAL BLANK TO END */ - /* Otherwise palette will not be written properly. */ + /* WAIT FOR VERTICAL BLANK TO END */ + /* Otherwise palette will not be written properly. */ - if (gfx_test_timing_active()) { - if (gfx_test_vertical_active()) { - while (gfx_test_vertical_active()) ; - } - while (!gfx_test_vertical_active()) ; - } + if (gfx_test_timing_active()) { + if (gfx_test_vertical_active()) { + while (gfx_test_vertical_active()); + } + while (!gfx_test_vertical_active()); + } - /* LOAD SC1200 VIDEO PALETTE */ + /* LOAD SC1200 VIDEO PALETTE */ - WRITE_VID32(SC1200_PALETTE_ADDRESS, 0); - for (i = 0; i < 256; i++) { - if (palette) - entry = palette[i]; - else - entry = (i << 8) | (i << 16) | (i << 24); - WRITE_VID32(SC1200_PALETTE_DATA, entry); - } - return (0); + WRITE_VID32(SC1200_PALETTE_ADDRESS, 0); + for (i = 0; i < 256; i++) { + if (palette) + entry = palette[i]; + else + entry = (i << 8) | (i << 16) | (i << 24); + WRITE_VID32(SC1200_PALETTE_DATA, entry); + } + return (0); } /*--------------------------------------------------------------------------- @@ -1150,25 +1144,25 @@ int gfx_set_video_palette_entry(unsigned long index, unsigned long palette) #endif { - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - /* WAIT FOR VERTICAL BLANK TO END */ - /* Otherwise palette will not be written properly. */ + /* WAIT FOR VERTICAL BLANK TO END */ + /* Otherwise palette will not be written properly. */ - if (gfx_test_timing_active()) { - if (gfx_test_vertical_active()) { - while (gfx_test_vertical_active()) ; - } - while (!gfx_test_vertical_active()) ; - } + if (gfx_test_timing_active()) { + if (gfx_test_vertical_active()) { + while (gfx_test_vertical_active()); + } + while (!gfx_test_vertical_active()); + } - /* SET A SINGLE ENTRY */ + /* SET A SINGLE ENTRY */ - WRITE_VID32(SC1200_PALETTE_ADDRESS, index); - WRITE_VID32(SC1200_PALETTE_DATA, palette); + WRITE_VID32(SC1200_PALETTE_ADDRESS, index); + WRITE_VID32(SC1200_PALETTE_DATA, palette); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -1186,19 +1180,19 @@ int gfx_set_video_request(short x, short y) #endif { - /* SET SC1200 VIDEO REQUEST */ + /* SET SC1200 VIDEO REQUEST */ - x += gfx_get_htotal() - gfx_get_hsync_end() - 2; - y += gfx_get_vtotal() - gfx_get_vsync_end() + 1; + x += gfx_get_htotal() - gfx_get_hsync_end() - 2; + y += gfx_get_vtotal() - gfx_get_vsync_end() + 1; - if ((x < 0) || (x > SC1200_VIDEO_REQUEST_MASK) || - (y < 0) || (y > SC1200_VIDEO_REQUEST_MASK)) - return GFX_STATUS_BAD_PARAMETER; + if ((x < 0) || (x > SC1200_VIDEO_REQUEST_MASK) || + (y < 0) || (y > SC1200_VIDEO_REQUEST_MASK)) + return GFX_STATUS_BAD_PARAMETER; - WRITE_VID32(SC1200_VIDEO_REQUEST, - ((unsigned long)x << SC1200_VIDEO_X_REQUEST_POS) | - ((unsigned long)y << SC1200_VIDEO_Y_REQUEST_POS)); - return (0); + WRITE_VID32(SC1200_VIDEO_REQUEST, + ((unsigned long) x << SC1200_VIDEO_X_REQUEST_POS) | + ((unsigned long) y << SC1200_VIDEO_Y_REQUEST_POS)); + return (0); } /*--------------------------------------------------------------------------- @@ -1215,26 +1209,26 @@ int gfx_set_video_source(VideoSourceType source) #endif { - unsigned long display_mode; + unsigned long display_mode; - display_mode = READ_VID32(SC1200_VIDEO_DISPLAY_MODE); + display_mode = READ_VID32(SC1200_VIDEO_DISPLAY_MODE); - /* SET SC1200 VIDEO SOURCE */ - switch (source) { - case VIDEO_SOURCE_MEMORY: - WRITE_VID32(SC1200_VIDEO_DISPLAY_MODE, - (display_mode & ~SC1200_VIDEO_SOURCE_MASK) | - SC1200_VIDEO_SOURCE_GX1); - break; - case VIDEO_SOURCE_DVIP: - WRITE_VID32(SC1200_VIDEO_DISPLAY_MODE, - (display_mode & ~SC1200_VIDEO_SOURCE_MASK) | - SC1200_VIDEO_SOURCE_DVIP); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - return (0); + /* SET SC1200 VIDEO SOURCE */ + switch (source) { + case VIDEO_SOURCE_MEMORY: + WRITE_VID32(SC1200_VIDEO_DISPLAY_MODE, + (display_mode & ~SC1200_VIDEO_SOURCE_MASK) | + SC1200_VIDEO_SOURCE_GX1); + break; + case VIDEO_SOURCE_DVIP: + WRITE_VID32(SC1200_VIDEO_DISPLAY_MODE, + (display_mode & ~SC1200_VIDEO_SOURCE_MASK) | + SC1200_VIDEO_SOURCE_DVIP); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + return (0); } /*--------------------------------------------------------------------------- @@ -1251,26 +1245,26 @@ int gfx_set_vbi_source(VbiSourceType source) #endif { - unsigned long display_mode; + unsigned long display_mode; - display_mode = READ_VID32(SC1200_VIDEO_DISPLAY_MODE); + display_mode = READ_VID32(SC1200_VIDEO_DISPLAY_MODE); - /* SET SC1200 VBI SOURCE */ - switch (source) { - case VBI_SOURCE_MEMORY: - WRITE_VID32(SC1200_VIDEO_DISPLAY_MODE, - (display_mode & ~SC1200_VBI_SOURCE_MASK) | - SC1200_VBI_SOURCE_GX1); - break; - case VBI_SOURCE_DVIP: - WRITE_VID32(SC1200_VIDEO_DISPLAY_MODE, - (display_mode & ~SC1200_VBI_SOURCE_MASK) | - SC1200_VBI_SOURCE_DVIP); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - return (0); + /* SET SC1200 VBI SOURCE */ + switch (source) { + case VBI_SOURCE_MEMORY: + WRITE_VID32(SC1200_VIDEO_DISPLAY_MODE, + (display_mode & ~SC1200_VBI_SOURCE_MASK) | + SC1200_VBI_SOURCE_GX1); + break; + case VBI_SOURCE_DVIP: + WRITE_VID32(SC1200_VIDEO_DISPLAY_MODE, + (display_mode & ~SC1200_VBI_SOURCE_MASK) | + SC1200_VBI_SOURCE_DVIP); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + return (0); } /*--------------------------------------------------------------------------- @@ -1287,12 +1281,12 @@ int gfx_set_vbi_lines(unsigned long even, unsigned long odd) #endif { - /* SET SC1200 VBI LINES */ - WRITE_VID32(SC1200_VIDEO_EVEN_VBI_LINE_ENABLE, - even & SC1200_VIDEO_VBI_LINE_ENABLE_MASK); - WRITE_VID32(SC1200_VIDEO_ODD_VBI_LINE_ENABLE, - odd & SC1200_VIDEO_VBI_LINE_ENABLE_MASK); - return (0); + /* SET SC1200 VBI LINES */ + WRITE_VID32(SC1200_VIDEO_EVEN_VBI_LINE_ENABLE, + even & SC1200_VIDEO_VBI_LINE_ENABLE_MASK); + WRITE_VID32(SC1200_VIDEO_ODD_VBI_LINE_ENABLE, + odd & SC1200_VIDEO_VBI_LINE_ENABLE_MASK); + return (0); } /*--------------------------------------------------------------------------- @@ -1310,12 +1304,12 @@ int gfx_set_vbi_total(unsigned long even, unsigned long odd) #endif { - /* SET SC1200 VBI TOTAL */ - WRITE_VID32(SC1200_VIDEO_EVEN_VBI_TOTAL_COUNT, - even & SC1200_VIDEO_VBI_TOTAL_COUNT_MASK); - WRITE_VID32(SC1200_VIDEO_ODD_VBI_TOTAL_COUNT, - odd & SC1200_VIDEO_VBI_TOTAL_COUNT_MASK); - return (0); + /* SET SC1200 VBI TOTAL */ + WRITE_VID32(SC1200_VIDEO_EVEN_VBI_TOTAL_COUNT, + even & SC1200_VIDEO_VBI_TOTAL_COUNT_MASK); + WRITE_VID32(SC1200_VIDEO_ODD_VBI_TOTAL_COUNT, + odd & SC1200_VIDEO_VBI_TOTAL_COUNT_MASK); + return (0); } /*--------------------------------------------------------------------------- @@ -1333,17 +1327,17 @@ int gfx_set_video_interlaced(int enable) #endif { - unsigned long control; + unsigned long control; - control = READ_VID32(SC1200_VID_ALPHA_CONTROL); - /* SET INTERLACED VIDEO */ - if (enable) - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, - control | SC1200_VIDEO_IS_INTERLACED); - else - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, - control & ~SC1200_VIDEO_IS_INTERLACED); - return (0); + control = READ_VID32(SC1200_VID_ALPHA_CONTROL); + /* SET INTERLACED VIDEO */ + if (enable) + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, + control | SC1200_VIDEO_IS_INTERLACED); + else + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, + control & ~SC1200_VIDEO_IS_INTERLACED); + return (0); } /*--------------------------------------------------------------------------- @@ -1364,32 +1358,33 @@ int gfx_set_color_space_YUV(int enable) #endif { - unsigned long control; + unsigned long control; - control = READ_VID32(SC1200_VID_ALPHA_CONTROL); + control = READ_VID32(SC1200_VID_ALPHA_CONTROL); - /* SET SC1200 VIDEO COLOR SPACE TO YUV OR RGB */ + /* SET SC1200 VIDEO COLOR SPACE TO YUV OR RGB */ - if (enable) { - /* ENABLE YUV BLENDING */ - /* YUV blending cannot be enabled in RGB video formats */ + if (enable) { + /* ENABLE YUV BLENDING */ + /* YUV blending cannot be enabled in RGB video formats */ - control |= SC1200_CSC_GFX_RGB_TO_YUV; /* Convert graphics to YUV */ - control &= ~SC1200_CSC_VIDEO_YUV_TO_RGB; /* Leave video in YUV */ + control |= SC1200_CSC_GFX_RGB_TO_YUV; /* Convert graphics to YUV */ + control &= ~SC1200_CSC_VIDEO_YUV_TO_RGB; /* Leave video in YUV */ - if (control & SC1200_VIDEO_INPUT_IS_RGB) - return (GFX_STATUS_UNSUPPORTED); /* Can't convert video from RGB to YUV */ - } else { - /* RGB BLENDING */ + if (control & SC1200_VIDEO_INPUT_IS_RGB) + return (GFX_STATUS_UNSUPPORTED); /* Can't convert video from RGB to YUV */ + } + else { + /* RGB BLENDING */ - control &= ~SC1200_CSC_GFX_RGB_TO_YUV; /* Leave graphics in RGB */ - if (control & SC1200_VIDEO_INPUT_IS_RGB) - control &= ~SC1200_CSC_VIDEO_YUV_TO_RGB; /* Leave video in RGB */ - else - control |= SC1200_CSC_VIDEO_YUV_TO_RGB; /* Convert video to RGB */ - } - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, control); - return (0); + control &= ~SC1200_CSC_GFX_RGB_TO_YUV; /* Leave graphics in RGB */ + if (control & SC1200_VIDEO_INPUT_IS_RGB) + control &= ~SC1200_CSC_VIDEO_YUV_TO_RGB; /* Leave video in RGB */ + else + control |= SC1200_CSC_VIDEO_YUV_TO_RGB; /* Convert video to RGB */ + } + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, control); + return (0); } /*--------------------------------------------------------------------------- @@ -1409,20 +1404,22 @@ int gfx_set_vertical_scaler_offset(char offset) #endif { - unsigned long control; + unsigned long control; - control = READ_VID32(SC1200_VID_ALPHA_CONTROL); - if (offset == 1) { - control &= ~SC1200_VERTICAL_SCALER_SHIFT_MASK; /* Clear shifting value */ - control |= SC1200_VERTICAL_SCALER_SHIFT_INIT; /* Set shifting value */ - control |= SC1200_VERTICAL_SCALER_SHIFT_EN; /* Enable odd frame shifting */ - } else if (offset == 0) { - control &= ~SC1200_VERTICAL_SCALER_SHIFT_EN; /* No shifting occurs */ - control &= ~SC1200_VERTICAL_SCALER_SHIFT_MASK; /* Clear shifting value */ - } else - return (GFX_STATUS_BAD_PARAMETER); /* TODO: how to program other values ? */ - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, control); - return (0); + control = READ_VID32(SC1200_VID_ALPHA_CONTROL); + if (offset == 1) { + control &= ~SC1200_VERTICAL_SCALER_SHIFT_MASK; /* Clear shifting value */ + control |= SC1200_VERTICAL_SCALER_SHIFT_INIT; /* Set shifting value */ + control |= SC1200_VERTICAL_SCALER_SHIFT_EN; /* Enable odd frame shifting */ + } + else if (offset == 0) { + control &= ~SC1200_VERTICAL_SCALER_SHIFT_EN; /* No shifting occurs */ + control &= ~SC1200_VERTICAL_SCALER_SHIFT_MASK; /* Clear shifting value */ + } + else + return (GFX_STATUS_BAD_PARAMETER); /* TODO: how to program other values ? */ + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, control); + return (0); } /*--------------------------------------------------------------------------- @@ -1447,15 +1444,15 @@ int gfx_set_top_line_in_odd(int enable) #endif { - unsigned long control; + unsigned long control; - control = READ_VID32(SC1200_VID_ALPHA_CONTROL); - if (enable) - control |= SC1200_TOP_LINE_IN_ODD; /* Set shifting value */ - else - control &= ~SC1200_TOP_LINE_IN_ODD; /* No shifting occurs */ - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, control); - return (0); + control = READ_VID32(SC1200_VID_ALPHA_CONTROL); + if (enable) + control |= SC1200_TOP_LINE_IN_ODD; /* Set shifting value */ + else + control &= ~SC1200_TOP_LINE_IN_ODD; /* No shifting occurs */ + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, control); + return (0); } /*--------------------------------------------------------------------------- @@ -1473,9 +1470,9 @@ int gfx_set_genlock_delay(unsigned long delay) #endif { - /* SET SC1200 GENLOCK DELAY */ - WRITE_VID32(SC1200_GENLOCK_DELAY, delay & SC1200_GENLOCK_DELAY_MASK); - return (0); + /* SET SC1200 GENLOCK DELAY */ + WRITE_VID32(SC1200_GENLOCK_DELAY, delay & SC1200_GENLOCK_DELAY_MASK); + return (0); } /*--------------------------------------------------------------------------- @@ -1493,33 +1490,33 @@ int gfx_set_genlock_enable(int flags) #endif { - unsigned long genlock = 0; - - if (flags) { - /* SET SC1200 GENLOCK CONFIGURATION */ - if (flags & GENLOCK_SINGLE) - genlock |= SC1200_GENLOCK_SINGLE_ENABLE; - if (flags & GENLOCK_FIELD_SYNC) - genlock |= SC1200_GENLOCK_FIELD_SYNC_ENABLE; - if (flags & GENLOCK_CONTINUOUS) - genlock |= SC1200_GENLOCK_CONTINUOUS_ENABLE; - if (flags & GENLOCK_SYNCED_EDGE_FALLING) - genlock |= SC1200_GENLOCK_GX_VSYNC_FALLING_EDGE; - if (flags & GENLOCK_SYNCING_EDGE_FALLING) - genlock |= SC1200_GENLOCK_VIP_VSYNC_FALLING_EDGE; - if (flags & GENLOCK_TIMEOUT) - genlock |= SC1200_GENLOCK_TIMEOUT_ENABLE; - if (flags & GENLOCK_TVENC_RESET_EVEN_FIELD) - genlock |= SC1200_GENLOCK_TVENC_RESET_EVEN_FIELD; - if (flags & GENLOCK_TVENC_RESET_BEFORE_DELAY) - genlock |= SC1200_GENLOCK_TVENC_RESET_BEFORE_DELAY; - if (flags & GENLOCK_TVENC_RESET) - genlock |= SC1200_GENLOCK_TVENC_RESET_ENABLE; - if (flags & GENLOCK_SYNC_TO_TVENC) - genlock |= SC1200_GENLOCK_SYNC_TO_TVENC; - } - WRITE_VID32(SC1200_GENLOCK, genlock); - return (0); + unsigned long genlock = 0; + + if (flags) { + /* SET SC1200 GENLOCK CONFIGURATION */ + if (flags & GENLOCK_SINGLE) + genlock |= SC1200_GENLOCK_SINGLE_ENABLE; + if (flags & GENLOCK_FIELD_SYNC) + genlock |= SC1200_GENLOCK_FIELD_SYNC_ENABLE; + if (flags & GENLOCK_CONTINUOUS) + genlock |= SC1200_GENLOCK_CONTINUOUS_ENABLE; + if (flags & GENLOCK_SYNCED_EDGE_FALLING) + genlock |= SC1200_GENLOCK_GX_VSYNC_FALLING_EDGE; + if (flags & GENLOCK_SYNCING_EDGE_FALLING) + genlock |= SC1200_GENLOCK_VIP_VSYNC_FALLING_EDGE; + if (flags & GENLOCK_TIMEOUT) + genlock |= SC1200_GENLOCK_TIMEOUT_ENABLE; + if (flags & GENLOCK_TVENC_RESET_EVEN_FIELD) + genlock |= SC1200_GENLOCK_TVENC_RESET_EVEN_FIELD; + if (flags & GENLOCK_TVENC_RESET_BEFORE_DELAY) + genlock |= SC1200_GENLOCK_TVENC_RESET_BEFORE_DELAY; + if (flags & GENLOCK_TVENC_RESET) + genlock |= SC1200_GENLOCK_TVENC_RESET_ENABLE; + if (flags & GENLOCK_SYNC_TO_TVENC) + genlock |= SC1200_GENLOCK_SYNC_TO_TVENC; + } + WRITE_VID32(SC1200_GENLOCK, genlock); + return (0); } /*--------------------------------------------------------------------------- @@ -1549,24 +1546,24 @@ gfx_set_genlock_enable(int flags) #if GFX_VIDEO_DYNAMIC int sc1200_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, unsigned long color1, - unsigned long color2) + unsigned short select_color2, unsigned long color1, + unsigned long color2) #else int gfx_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, unsigned long color1, - unsigned long color2) + unsigned short select_color2, unsigned long color1, + unsigned long color2) #endif { - if (select_color2 > SC1200_CURSOR_COLOR_BITS) - return GFX_STATUS_BAD_PARAMETER; - key = (key & SC1200_COLOR_MASK) | ((unsigned long)select_color2 << - SC1200_CURSOR_COLOR_KEY_OFFSET_POS); - WRITE_VID32(SC1200_CURSOR_COLOR_KEY, key); - WRITE_VID32(SC1200_CURSOR_COLOR_MASK, mask); - WRITE_VID32(SC1200_CURSOR_COLOR_1, color1); - WRITE_VID32(SC1200_CURSOR_COLOR_2, color2); - return (0); + if (select_color2 > SC1200_CURSOR_COLOR_BITS) + return GFX_STATUS_BAD_PARAMETER; + key = (key & SC1200_COLOR_MASK) | ((unsigned long) select_color2 << + SC1200_CURSOR_COLOR_KEY_OFFSET_POS); + WRITE_VID32(SC1200_CURSOR_COLOR_KEY, key); + WRITE_VID32(SC1200_CURSOR_COLOR_MASK, mask); + WRITE_VID32(SC1200_CURSOR_COLOR_1, color1); + WRITE_VID32(SC1200_CURSOR_COLOR_2, color2); + return (0); } /*--------------------------------------------------------------------------- @@ -1583,18 +1580,18 @@ int gfx_set_alpha_enable(int enable) #endif { - unsigned long address = 0, value = 0; + unsigned long address = 0, value = 0; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = SC1200_ALPHA_CONTROL_1 + ((unsigned long)gfx_alpha_select << 4); - value = READ_VID32(address); - if (enable) - value |= (SC1200_ACTRL_WIN_ENABLE | SC1200_ACTRL_LOAD_ALPHA); - else - value &= ~(SC1200_ACTRL_WIN_ENABLE); - WRITE_VID32(address, value); - return (GFX_STATUS_OK); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = SC1200_ALPHA_CONTROL_1 + ((unsigned long) gfx_alpha_select << 4); + value = READ_VID32(address); + if (enable) + value |= (SC1200_ACTRL_WIN_ENABLE | SC1200_ACTRL_LOAD_ALPHA); + else + value &= ~(SC1200_ACTRL_WIN_ENABLE); + WRITE_VID32(address, value); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1608,38 +1605,38 @@ gfx_set_alpha_enable(int enable) #if GFX_VIDEO_DYNAMIC int sc1200_set_alpha_window(short x, short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) #else int gfx_set_alpha_window(short x, short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) #endif { - unsigned long address = 0; + unsigned long address = 0; - /* CHECK FOR CLIPPING */ + /* CHECK FOR CLIPPING */ - if ((x + width) > gfx_get_hactive()) - width = gfx_get_hactive() - x; - if ((y + height) > gfx_get_vactive()) - height = gfx_get_vactive() - y; + if ((x + width) > gfx_get_hactive()) + width = gfx_get_hactive() - x; + if ((y + height) > gfx_get_vactive()) + height = gfx_get_vactive() - y; - /* ADJUST POSITIONS */ + /* ADJUST POSITIONS */ - x += gfx_get_htotal() - gfx_get_hsync_end() - 2; - y += gfx_get_vtotal() - gfx_get_vsync_end() + 1; + x += gfx_get_htotal() - gfx_get_hsync_end() - 2; + y += gfx_get_vtotal() - gfx_get_vsync_end() + 1; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = SC1200_ALPHA_XPOS_1 + ((unsigned long)gfx_alpha_select << 4); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = SC1200_ALPHA_XPOS_1 + ((unsigned long) gfx_alpha_select << 4); - /* End positions in register are non-inclusive (one more than the actual end) */ + /* End positions in register are non-inclusive (one more than the actual end) */ - WRITE_VID32(address, (unsigned long)x | - ((unsigned long)(x + width) << 16)); - WRITE_VID32(address + 4l, (unsigned long)y | - ((unsigned long)(y + height) << 16)); - return (GFX_STATUS_OK); + WRITE_VID32(address, (unsigned long) x | + ((unsigned long) (x + width) << 16)); + WRITE_VID32(address + 4l, (unsigned long) y | + ((unsigned long) (y + height) << 16)); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1657,40 +1654,40 @@ int gfx_set_alpha_value(unsigned char alpha, char delta) #endif { - unsigned long address = 0, value = 0; - unsigned char new_value = 0; - int loop = 1; - - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = SC1200_ALPHA_CONTROL_1 + ((unsigned long)gfx_alpha_select << 4); - value = READ_VID32(address); - value &= SC1200_ACTRL_WIN_ENABLE; /* keep only enable bit */ - value |= (unsigned long)alpha; - value |= (((unsigned long)delta) & 0xff) << 8; - value |= SC1200_ACTRL_LOAD_ALPHA; - WRITE_VID32(address, value); - - /* WORKAROUND FOR ISSUE #1187 */ - /* Need to verify that the alpha operation succeeded */ - - while (1) { - /* WAIT FOR VERTICAL BLANK TO END */ - if (gfx_test_timing_active()) { - if (gfx_test_vertical_active()) - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - } - new_value = - (unsigned - char)((READ_VID32(SC1200_ALPHA_WATCH) >> (gfx_alpha_select << 3)) - & 0xff); - if (new_value == alpha) - return GFX_STATUS_OK; - if (++loop > 10) - return GFX_STATUS_ERROR; - WRITE_VID32(address, value); - } + unsigned long address = 0, value = 0; + unsigned char new_value = 0; + int loop = 1; + + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = SC1200_ALPHA_CONTROL_1 + ((unsigned long) gfx_alpha_select << 4); + value = READ_VID32(address); + value &= SC1200_ACTRL_WIN_ENABLE; /* keep only enable bit */ + value |= (unsigned long) alpha; + value |= (((unsigned long) delta) & 0xff) << 8; + value |= SC1200_ACTRL_LOAD_ALPHA; + WRITE_VID32(address, value); + + /* WORKAROUND FOR ISSUE #1187 */ + /* Need to verify that the alpha operation succeeded */ + + while (1) { + /* WAIT FOR VERTICAL BLANK TO END */ + if (gfx_test_timing_active()) { + if (gfx_test_vertical_active()) + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + } + new_value = + (unsigned + char) ((READ_VID32(SC1200_ALPHA_WATCH) >> (gfx_alpha_select << 3)) + & 0xff); + if (new_value == alpha) + return GFX_STATUS_OK; + if (++loop > 10) + return GFX_STATUS_ERROR; + WRITE_VID32(address, value); + } } /*--------------------------------------------------------------------------- @@ -1709,18 +1706,18 @@ int gfx_set_alpha_priority(int priority) #endif { - unsigned long pos = 0, value = 0; + unsigned long pos = 0, value = 0; - if (priority > 3) - return (GFX_STATUS_BAD_PARAMETER); - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - value = READ_VID32(SC1200_VID_ALPHA_CONTROL); - pos = 16 + (gfx_alpha_select << 1); - value &= ~(0x03l << pos); - value |= (unsigned long)priority << pos; - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, value); - return (GFX_STATUS_OK); + if (priority > 3) + return (GFX_STATUS_BAD_PARAMETER); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + value = READ_VID32(SC1200_VID_ALPHA_CONTROL); + pos = 16 + (gfx_alpha_select << 1); + value &= ~(0x03l << pos); + value |= (unsigned long) priority << pos; + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, value); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1741,18 +1738,18 @@ int gfx_set_alpha_color(unsigned long color) #endif { - unsigned long address = 0; + unsigned long address = 0; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = SC1200_ALPHA_COLOR_1 + ((unsigned long)gfx_alpha_select << 4); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = SC1200_ALPHA_COLOR_1 + ((unsigned long) gfx_alpha_select << 4); - /* ONLY 24 VALID BITS */ - color &= 0xffffffl; + /* ONLY 24 VALID BITS */ + color &= 0xffffffl; - /* KEEP UPPER BYTE UNCHANGED */ - WRITE_VID32(address, (color | (READ_VID32(address) & ~0xffffffl))); - return (GFX_STATUS_OK); + /* KEEP UPPER BYTE UNCHANGED */ + WRITE_VID32(address, (color | (READ_VID32(address) & ~0xffffffl))); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1769,19 +1766,19 @@ int gfx_set_alpha_color_enable(int enable) #endif { - unsigned long color; - unsigned long address = 0; + unsigned long color; + unsigned long address = 0; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = SC1200_ALPHA_COLOR_1 + ((unsigned long)gfx_alpha_select << 4); - color = READ_VID32(address); - if (enable) - color |= SC1200_ALPHA_COLOR_ENABLE; - else - color &= ~SC1200_ALPHA_COLOR_ENABLE; - WRITE_VID32(address, color); - return (GFX_STATUS_OK); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = SC1200_ALPHA_COLOR_1 + ((unsigned long) gfx_alpha_select << 4); + color = READ_VID32(address); + if (enable) + color |= SC1200_ALPHA_COLOR_ENABLE; + else + color &= ~SC1200_ALPHA_COLOR_ENABLE; + WRITE_VID32(address, color); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1805,16 +1802,16 @@ int gfx_set_no_ck_outside_alpha(int enable) #endif { - unsigned long value; + unsigned long value; - value = READ_VID32(SC1200_VID_ALPHA_CONTROL); - if (enable) - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, - value | SC1200_NO_CK_OUTSIDE_ALPHA); - else - WRITE_VID32(SC1200_VID_ALPHA_CONTROL, - value & ~SC1200_NO_CK_OUTSIDE_ALPHA); - return (0); + value = READ_VID32(SC1200_VID_ALPHA_CONTROL); + if (enable) + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, + value | SC1200_NO_CK_OUTSIDE_ALPHA); + else + WRITE_VID32(SC1200_VID_ALPHA_CONTROL, + value & ~SC1200_NO_CK_OUTSIDE_ALPHA); + return (0); } /*--------------------------------------------------------------------------- @@ -1831,11 +1828,11 @@ int gfx_set_macrovision_enable(int enable) #endif { - if (enable) - WRITE_VID32(SC1200_TVENC_MV_CONTROL, SC1200_TVENC_MV_ENABLE); - else - WRITE_VID32(SC1200_TVENC_MV_CONTROL, 0); - return (GFX_STATUS_OK); + if (enable) + WRITE_VID32(SC1200_TVENC_MV_CONTROL, SC1200_TVENC_MV_ENABLE); + else + WRITE_VID32(SC1200_TVENC_MV_CONTROL, 0); + return (GFX_STATUS_OK); } #define SC1200_VIDEO_PCI_44 0x80009444 @@ -1855,20 +1852,20 @@ int gfx_disable_softvga(void) #endif { - unsigned long reg_val; + unsigned long reg_val; - /* get the current value */ - reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); - /* setting video PCI register 44 bit 0 to 1 disables SoftVga */ - reg_val |= 0x1; - gfx_pci_config_write(SC1200_VIDEO_PCI_44, reg_val); + /* get the current value */ + reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); + /* setting video PCI register 44 bit 0 to 1 disables SoftVga */ + reg_val |= 0x1; + gfx_pci_config_write(SC1200_VIDEO_PCI_44, reg_val); - /* see if we set the bit and return the appropriate value */ - reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); - if ((reg_val & 0x1) == 0x1) - return (1); - else - return (0); + /* see if we set the bit and return the appropriate value */ + reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); + if ((reg_val & 0x1) == 0x1) + return (1); + else + return (0); } /*--------------------------------------------------------------------------- @@ -1886,19 +1883,19 @@ int gfx_enable_softvga(void) #endif { - unsigned long reg_val; + unsigned long reg_val; - /* get the current value */ - reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); - /* clearing video PCI register 44 bit 0 enables SoftVga */ - gfx_pci_config_write(SC1200_VIDEO_PCI_44, reg_val & 0xfffffffel); + /* get the current value */ + reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); + /* clearing video PCI register 44 bit 0 enables SoftVga */ + gfx_pci_config_write(SC1200_VIDEO_PCI_44, reg_val & 0xfffffffel); - /* see if we cleared the bit and return the appropriate value */ - reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); - if ((reg_val & 0x1) == 0) - return (1); - else - return (0); + /* see if we cleared the bit and return the appropriate value */ + reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); + if ((reg_val & 0x1) == 0) + return (1); + else + return (0); } /*--------------------------------------------------------------------------- @@ -1917,16 +1914,16 @@ unsigned long gfx_get_clock_frequency(void) #endif { - unsigned int index; - unsigned long value, mask; + unsigned int index; + unsigned long value, mask; - mask = 0x007FFF0F; - value = READ_VID32(SC1200_VID_CLOCK_SELECT) & mask; - for (index = 0; index < NUM_SC1200_FREQUENCIES; index++) { - if ((gfx_sc1200_clock_table[index].clock_select & mask) == value) - return (gfx_sc1200_clock_table[index].frequency); - } - return (0); + mask = 0x007FFF0F; + value = READ_VID32(SC1200_VID_CLOCK_SELECT) & mask; + for (index = 0; index < NUM_SC1200_FREQUENCIES; index++) { + if ((gfx_sc1200_clock_table[index].clock_select & mask) == value) + return (gfx_sc1200_clock_table[index].frequency); + } + return (0); } /*************************************************************/ @@ -1950,13 +1947,13 @@ int gfx_get_vsa2_softvga_enable(void) #endif { - unsigned long reg_val; + unsigned long reg_val; - reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); - if ((reg_val & 0x1) == 0) - return (1); - else - return (0); + reg_val = gfx_pci_config_read(SC1200_VIDEO_PCI_44); + if ((reg_val & 0x1) == 0) + return (1); + else + return (0); } @@ -1976,13 +1973,13 @@ int gfx_get_sync_polarities(void) #endif { - int polarities = 0; + int polarities = 0; - if (READ_VID32(SC1200_DISPLAY_CONFIG) & SC1200_DCFG_CRT_HSYNC_POL) - polarities |= 1; - if (READ_VID32(SC1200_DISPLAY_CONFIG) & SC1200_DCFG_CRT_VSYNC_POL) - polarities |= 2; - return (polarities); + if (READ_VID32(SC1200_DISPLAY_CONFIG) & SC1200_DCFG_CRT_HSYNC_POL) + polarities |= 1; + if (READ_VID32(SC1200_DISPLAY_CONFIG) & SC1200_DCFG_CRT_VSYNC_POL) + polarities |= 2; + return (polarities); } /*--------------------------------------------------------------------------- @@ -1999,15 +1996,15 @@ int gfx_get_video_palette_entry(unsigned long index, unsigned long *palette) #endif { - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - /* READ A SINGLE ENTRY */ + /* READ A SINGLE ENTRY */ - WRITE_VID32(SC1200_PALETTE_ADDRESS, index); - *palette = READ_VID32(SC1200_PALETTE_DATA); + WRITE_VID32(SC1200_PALETTE_ADDRESS, index); + *palette = READ_VID32(SC1200_PALETTE_DATA); - return (GFX_STATUS_OK); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -2025,9 +2022,9 @@ int gfx_get_video_enable(void) #endif { - if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_VID_EN) - return (1); - return (0); + if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_VID_EN) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -2044,48 +2041,49 @@ int gfx_get_video_format(void) #endif { - unsigned long ctrl, vcfg; - - ctrl = READ_VID32(SC1200_VID_ALPHA_CONTROL); - vcfg = READ_VID32(SC1200_VIDEO_CONFIG); - - if (ctrl & SC1200_VIDEO_INPUT_IS_RGB) { - switch (vcfg & SC1200_VCFG_VID_INP_FORMAT) { - case SC1200_VCFG_UYVY_FORMAT: - return VIDEO_FORMAT_RGB; - case SC1200_VCFG_Y2YU_FORMAT: - return VIDEO_FORMAT_P2M_P2L_P1M_P1L; - case SC1200_VCFG_YUYV_FORMAT: - return VIDEO_FORMAT_P1M_P1L_P2M_P2L; - case SC1200_VCFG_YVYU_FORMAT: - return VIDEO_FORMAT_P1M_P2L_P2M_P1L; - } - } - - if (vcfg & SC1200_VCFG_4_2_0_MODE) { - switch (vcfg & SC1200_VCFG_VID_INP_FORMAT) { - case SC1200_VCFG_UYVY_FORMAT: - return VIDEO_FORMAT_Y0Y1Y2Y3; - case SC1200_VCFG_Y2YU_FORMAT: - return VIDEO_FORMAT_Y3Y2Y1Y0; - case SC1200_VCFG_YUYV_FORMAT: - return VIDEO_FORMAT_Y1Y0Y3Y2; - case SC1200_VCFG_YVYU_FORMAT: - return VIDEO_FORMAT_Y1Y2Y3Y0; - } - } else { - switch (vcfg & SC1200_VCFG_VID_INP_FORMAT) { - case SC1200_VCFG_UYVY_FORMAT: - return VIDEO_FORMAT_UYVY; - case SC1200_VCFG_Y2YU_FORMAT: - return VIDEO_FORMAT_Y2YU; - case SC1200_VCFG_YUYV_FORMAT: - return VIDEO_FORMAT_YUYV; - case SC1200_VCFG_YVYU_FORMAT: - return VIDEO_FORMAT_YVYU; - } - } - return (GFX_STATUS_ERROR); + unsigned long ctrl, vcfg; + + ctrl = READ_VID32(SC1200_VID_ALPHA_CONTROL); + vcfg = READ_VID32(SC1200_VIDEO_CONFIG); + + if (ctrl & SC1200_VIDEO_INPUT_IS_RGB) { + switch (vcfg & SC1200_VCFG_VID_INP_FORMAT) { + case SC1200_VCFG_UYVY_FORMAT: + return VIDEO_FORMAT_RGB; + case SC1200_VCFG_Y2YU_FORMAT: + return VIDEO_FORMAT_P2M_P2L_P1M_P1L; + case SC1200_VCFG_YUYV_FORMAT: + return VIDEO_FORMAT_P1M_P1L_P2M_P2L; + case SC1200_VCFG_YVYU_FORMAT: + return VIDEO_FORMAT_P1M_P2L_P2M_P1L; + } + } + + if (vcfg & SC1200_VCFG_4_2_0_MODE) { + switch (vcfg & SC1200_VCFG_VID_INP_FORMAT) { + case SC1200_VCFG_UYVY_FORMAT: + return VIDEO_FORMAT_Y0Y1Y2Y3; + case SC1200_VCFG_Y2YU_FORMAT: + return VIDEO_FORMAT_Y3Y2Y1Y0; + case SC1200_VCFG_YUYV_FORMAT: + return VIDEO_FORMAT_Y1Y0Y3Y2; + case SC1200_VCFG_YVYU_FORMAT: + return VIDEO_FORMAT_Y1Y2Y3Y0; + } + } + else { + switch (vcfg & SC1200_VCFG_VID_INP_FORMAT) { + case SC1200_VCFG_UYVY_FORMAT: + return VIDEO_FORMAT_UYVY; + case SC1200_VCFG_Y2YU_FORMAT: + return VIDEO_FORMAT_Y2YU; + case SC1200_VCFG_YUYV_FORMAT: + return VIDEO_FORMAT_YUYV; + case SC1200_VCFG_YVYU_FORMAT: + return VIDEO_FORMAT_YVYU; + } + } + return (GFX_STATUS_ERROR); } /*----------------------------------------------------------------------------- @@ -2103,21 +2101,21 @@ unsigned long gfx_get_video_src_size(void) #endif { - unsigned long width = 0, height = 0; + unsigned long width = 0, height = 0; - /* DETERMINE SOURCE WIDTH FROM THE SC1200 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE SC1200 VIDEO LINE SIZE */ - width = (READ_VID32(SC1200_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_LINE_SIZE_UPPER) - width += 512l; + width = (READ_VID32(SC1200_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_LINE_SIZE_UPPER) + width += 512l; - if (width) { - /* DETERMINE HEIGHT BY DIVIDING TOTAL SIZE BY WIDTH */ - /* Get total size from display controller - abtracted. */ + if (width) { + /* DETERMINE HEIGHT BY DIVIDING TOTAL SIZE BY WIDTH */ + /* Get total size from display controller - abtracted. */ - height = gfx_get_display_video_size() / (width << 1); - } - return ((height << 16) | width); + height = gfx_get_display_video_size() / (width << 1); + } + return ((height << 16) | width); } /*----------------------------------------------------------------------------- @@ -2135,14 +2133,14 @@ unsigned long gfx_get_video_line_size(void) #endif { - unsigned long width = 0; + unsigned long width = 0; - /* DETERMINE SOURCE WIDTH FROM THE SC1200 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE SC1200 VIDEO LINE SIZE */ - width = (READ_VID32(SC1200_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_LINE_SIZE_UPPER) - width += 512l; - return (width); + width = (READ_VID32(SC1200_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_LINE_SIZE_UPPER) + width += 512l; + return (width); } /*----------------------------------------------------------------------------- @@ -2160,12 +2158,12 @@ unsigned long gfx_get_video_xclip(void) #endif { - unsigned long clip = 0; + unsigned long clip = 0; - /* DETERMINE SOURCE WIDTH FROM THE SC1200 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE SC1200 VIDEO LINE SIZE */ - clip = (READ_VID32(SC1200_VIDEO_CONFIG) >> 14) & 0x000007FC; - return (clip); + clip = (READ_VID32(SC1200_VIDEO_CONFIG) >> 14) & 0x000007FC; + return (clip); } /*----------------------------------------------------------------------------- @@ -2182,7 +2180,7 @@ unsigned long gfx_get_video_offset(void) #endif { - return (gfx_get_display_video_offset()); + return (gfx_get_display_video_offset()); } /*--------------------------------------------------------------------------- @@ -2199,7 +2197,7 @@ unsigned long gfx_get_video_upscale(void) #endif { - return (READ_VID32(SC1200_VIDEO_UPSCALE)); + return (READ_VID32(SC1200_VIDEO_UPSCALE)); } /*--------------------------------------------------------------------------- @@ -2216,7 +2214,7 @@ unsigned long gfx_get_video_scale(void) #endif { - return gfx_get_video_upscale(); + return gfx_get_video_upscale(); } /*--------------------------------------------------------------------------- @@ -2233,24 +2231,24 @@ int gfx_get_video_downscale_config(unsigned short *type, unsigned short *m) #endif { - unsigned long downscale; + unsigned long downscale; - downscale = READ_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL); - *m = (unsigned short)((downscale & SC1200_VIDEO_DOWNSCALE_FACTOR_MASK) >> - SC1200_VIDEO_DOWNSCALE_FACTOR_POS) + 1; + downscale = READ_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL); + *m = (unsigned short) ((downscale & SC1200_VIDEO_DOWNSCALE_FACTOR_MASK) >> + SC1200_VIDEO_DOWNSCALE_FACTOR_POS) + 1; - switch (downscale & SC1200_VIDEO_DOWNSCALE_TYPE_MASK) { - case SC1200_VIDEO_DOWNSCALE_TYPE_A: - *type = VIDEO_DOWNSCALE_KEEP_1_OF; - break; - case SC1200_VIDEO_DOWNSCALE_TYPE_B: - *type = VIDEO_DOWNSCALE_DROP_1_OF; - break; - default: - return GFX_STATUS_ERROR; - break; - } - return (0); + switch (downscale & SC1200_VIDEO_DOWNSCALE_TYPE_MASK) { + case SC1200_VIDEO_DOWNSCALE_TYPE_A: + *type = VIDEO_DOWNSCALE_KEEP_1_OF; + break; + case SC1200_VIDEO_DOWNSCALE_TYPE_B: + *type = VIDEO_DOWNSCALE_DROP_1_OF; + break; + default: + return GFX_STATUS_ERROR; + break; + } + return (0); } /*--------------------------------------------------------------------------- @@ -2262,33 +2260,33 @@ gfx_get_video_downscale_config(unsigned short *type, unsigned short *m) #if GFX_VIDEO_DYNAMIC void sc1200_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4) + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4) #else void gfx_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4) + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4) #endif { - unsigned long coef; + unsigned long coef; - coef = READ_VID32(SC1200_VIDEO_DOWNSCALER_COEFFICIENTS); - *coef1 = - (unsigned short)((coef >> SC1200_VIDEO_DOWNSCALER_COEF1_POS) & - SC1200_VIDEO_DOWNSCALER_COEF_MASK); - *coef2 = - (unsigned short)((coef >> SC1200_VIDEO_DOWNSCALER_COEF2_POS) & - SC1200_VIDEO_DOWNSCALER_COEF_MASK); - *coef3 = - (unsigned short)((coef >> SC1200_VIDEO_DOWNSCALER_COEF3_POS) & - SC1200_VIDEO_DOWNSCALER_COEF_MASK); - *coef4 = - (unsigned short)((coef >> SC1200_VIDEO_DOWNSCALER_COEF4_POS) & - SC1200_VIDEO_DOWNSCALER_COEF_MASK); - return; + coef = READ_VID32(SC1200_VIDEO_DOWNSCALER_COEFFICIENTS); + *coef1 = + (unsigned short) ((coef >> SC1200_VIDEO_DOWNSCALER_COEF1_POS) & + SC1200_VIDEO_DOWNSCALER_COEF_MASK); + *coef2 = + (unsigned short) ((coef >> SC1200_VIDEO_DOWNSCALER_COEF2_POS) & + SC1200_VIDEO_DOWNSCALER_COEF_MASK); + *coef3 = + (unsigned short) ((coef >> SC1200_VIDEO_DOWNSCALER_COEF3_POS) & + SC1200_VIDEO_DOWNSCALER_COEF_MASK); + *coef4 = + (unsigned short) ((coef >> SC1200_VIDEO_DOWNSCALER_COEF4_POS) & + SC1200_VIDEO_DOWNSCALER_COEF_MASK); + return; } /*--------------------------------------------------------------------------- @@ -2306,12 +2304,12 @@ void gfx_get_video_downscale_enable(int *enable) #endif { - if (READ_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL) & - SC1200_VIDEO_DOWNSCALE_ENABLE) - *enable = 1; - else - *enable = 0; - return; + if (READ_VID32(SC1200_VIDEO_DOWNSCALER_CONTROL) & + SC1200_VIDEO_DOWNSCALE_ENABLE) + *enable = 1; + else + *enable = 0; + return; } /*--------------------------------------------------------------------------- @@ -2328,13 +2326,13 @@ unsigned long gfx_get_video_dst_size(void) #endif { - unsigned long xsize, ysize; + unsigned long xsize, ysize; - xsize = READ_VID32(SC1200_VIDEO_X_POS); - xsize = ((xsize >> 16) & 0x7FF) - (xsize & 0x7FF); - ysize = READ_VID32(SC1200_VIDEO_Y_POS); - ysize = ((ysize >> 16) & 0x7FF) - (ysize & 0x7FF); - return ((ysize << 16) | xsize); + xsize = READ_VID32(SC1200_VIDEO_X_POS); + xsize = ((xsize >> 16) & 0x7FF) - (xsize & 0x7FF); + ysize = READ_VID32(SC1200_VIDEO_Y_POS); + ysize = ((ysize >> 16) & 0x7FF) - (ysize & 0x7FF); + return ((ysize << 16) | xsize); } /*--------------------------------------------------------------------------- @@ -2352,26 +2350,26 @@ unsigned long gfx_get_video_position(void) #endif { - unsigned long hadjust, vadjust; - unsigned long xpos, ypos; + unsigned long hadjust, vadjust; + unsigned long xpos, ypos; - /* READ HARDWARE POSITION */ + /* READ HARDWARE POSITION */ - xpos = READ_VID32(SC1200_VIDEO_X_POS) & 0x000007FF; - ypos = READ_VID32(SC1200_VIDEO_Y_POS) & 0x000007FF; + xpos = READ_VID32(SC1200_VIDEO_X_POS) & 0x000007FF; + ypos = READ_VID32(SC1200_VIDEO_Y_POS) & 0x000007FF; - /* GET ADJUSTMENT VALUES */ - /* Use routines to abstract version of display controller. */ + /* GET ADJUSTMENT VALUES */ + /* Use routines to abstract version of display controller. */ - hadjust = - (unsigned long)gfx_get_htotal() - - (unsigned long)gfx_get_hsync_end() - 14l; - vadjust = - (unsigned long)gfx_get_vtotal() - - (unsigned long)gfx_get_vsync_end() + 1l; - xpos -= hadjust; - ypos -= vadjust; - return ((ypos << 16) | (xpos & 0x0000FFFF)); + hadjust = + (unsigned long) gfx_get_htotal() - + (unsigned long) gfx_get_hsync_end() - 14l; + vadjust = + (unsigned long) gfx_get_vtotal() - + (unsigned long) gfx_get_vsync_end() + 1l; + xpos -= hadjust; + ypos -= vadjust; + return ((ypos << 16) | (xpos & 0x0000FFFF)); } /*--------------------------------------------------------------------------- @@ -2388,7 +2386,7 @@ unsigned long gfx_get_video_color_key(void) #endif { - return (READ_VID32(SC1200_VIDEO_COLOR_KEY)); + return (READ_VID32(SC1200_VIDEO_COLOR_KEY)); } /*--------------------------------------------------------------------------- @@ -2405,7 +2403,7 @@ unsigned long gfx_get_video_color_key_mask(void) #endif { - return (READ_VID32(SC1200_VIDEO_COLOR_MASK)); + return (READ_VID32(SC1200_VIDEO_COLOR_MASK)); } /*--------------------------------------------------------------------------- @@ -2422,9 +2420,9 @@ int gfx_get_video_color_key_src(void) #endif { - if (READ_VID32(SC1200_DISPLAY_CONFIG) & SC1200_DCFG_VG_CK) - return (0); - return (1); + if (READ_VID32(SC1200_DISPLAY_CONFIG) & SC1200_DCFG_VG_CK) + return (0); + return (1); } /*--------------------------------------------------------------------------- @@ -2441,13 +2439,13 @@ int gfx_get_video_filter(void) #endif { - int retval = 0; + int retval = 0; - if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_X_FILTER_EN) - retval |= 1; - if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_Y_FILTER_EN) - retval |= 2; - return (retval); + if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_X_FILTER_EN) + retval |= 1; + if (READ_VID32(SC1200_VIDEO_CONFIG) & SC1200_VCFG_Y_FILTER_EN) + retval |= 2; + return (retval); } /*--------------------------------------------------------------------------- @@ -2465,16 +2463,16 @@ int gfx_get_video_request(short *x, short *y) #endif { - int request = 0; + int request = 0; - request = (int)(READ_VID32(SC1200_VIDEO_REQUEST)); - *x = (request >> SC1200_VIDEO_X_REQUEST_POS) & SC1200_VIDEO_REQUEST_MASK; - *y = (request >> SC1200_VIDEO_Y_REQUEST_POS) & SC1200_VIDEO_REQUEST_MASK; + request = (int) (READ_VID32(SC1200_VIDEO_REQUEST)); + *x = (request >> SC1200_VIDEO_X_REQUEST_POS) & SC1200_VIDEO_REQUEST_MASK; + *y = (request >> SC1200_VIDEO_Y_REQUEST_POS) & SC1200_VIDEO_REQUEST_MASK; - *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2; - *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1; + *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2; + *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1; - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -2491,17 +2489,17 @@ int gfx_get_video_source(VideoSourceType * source) #endif { - switch (READ_VID32(SC1200_VIDEO_DISPLAY_MODE) & SC1200_VIDEO_SOURCE_MASK) { - case SC1200_VIDEO_SOURCE_GX1: - *source = VIDEO_SOURCE_MEMORY; - break; - case SC1200_VIDEO_SOURCE_DVIP: - *source = VIDEO_SOURCE_DVIP; - break; - default: - return GFX_STATUS_ERROR; - } - return (0); + switch (READ_VID32(SC1200_VIDEO_DISPLAY_MODE) & SC1200_VIDEO_SOURCE_MASK) { + case SC1200_VIDEO_SOURCE_GX1: + *source = VIDEO_SOURCE_MEMORY; + break; + case SC1200_VIDEO_SOURCE_DVIP: + *source = VIDEO_SOURCE_DVIP; + break; + default: + return GFX_STATUS_ERROR; + } + return (0); } /*--------------------------------------------------------------------------- @@ -2518,17 +2516,17 @@ int gfx_get_vbi_source(VbiSourceType * source) #endif { - switch (READ_VID32(SC1200_VIDEO_DISPLAY_MODE) & SC1200_VBI_SOURCE_MASK) { - case SC1200_VBI_SOURCE_GX1: - *source = VBI_SOURCE_MEMORY; - break; - case SC1200_VBI_SOURCE_DVIP: - *source = VBI_SOURCE_DVIP; - break; - default: - return GFX_STATUS_ERROR; - } - return (0); + switch (READ_VID32(SC1200_VIDEO_DISPLAY_MODE) & SC1200_VBI_SOURCE_MASK) { + case SC1200_VBI_SOURCE_GX1: + *source = VBI_SOURCE_MEMORY; + break; + case SC1200_VBI_SOURCE_DVIP: + *source = VBI_SOURCE_DVIP; + break; + default: + return GFX_STATUS_ERROR; + } + return (0); } /*--------------------------------------------------------------------------- @@ -2545,11 +2543,11 @@ unsigned long gfx_get_vbi_lines(int odd) #endif { - if (odd) - return (READ_VID32(SC1200_VIDEO_ODD_VBI_LINE_ENABLE) & - SC1200_VIDEO_VBI_LINE_ENABLE_MASK); - return (READ_VID32(SC1200_VIDEO_EVEN_VBI_LINE_ENABLE) & - SC1200_VIDEO_VBI_LINE_ENABLE_MASK); + if (odd) + return (READ_VID32(SC1200_VIDEO_ODD_VBI_LINE_ENABLE) & + SC1200_VIDEO_VBI_LINE_ENABLE_MASK); + return (READ_VID32(SC1200_VIDEO_EVEN_VBI_LINE_ENABLE) & + SC1200_VIDEO_VBI_LINE_ENABLE_MASK); } /*--------------------------------------------------------------------------- @@ -2566,11 +2564,11 @@ unsigned long gfx_get_vbi_total(int odd) #endif { - if (odd) - return (READ_VID32(SC1200_VIDEO_ODD_VBI_TOTAL_COUNT) & - SC1200_VIDEO_VBI_TOTAL_COUNT_MASK); - return (READ_VID32(SC1200_VIDEO_EVEN_VBI_TOTAL_COUNT) & - SC1200_VIDEO_VBI_TOTAL_COUNT_MASK); + if (odd) + return (READ_VID32(SC1200_VIDEO_ODD_VBI_TOTAL_COUNT) & + SC1200_VIDEO_VBI_TOTAL_COUNT_MASK); + return (READ_VID32(SC1200_VIDEO_EVEN_VBI_TOTAL_COUNT) & + SC1200_VIDEO_VBI_TOTAL_COUNT_MASK); } /*--------------------------------------------------------------------------- @@ -2588,10 +2586,10 @@ int gfx_get_video_interlaced(void) #endif { - if (READ_VID32(SC1200_VID_ALPHA_CONTROL) & SC1200_VIDEO_IS_INTERLACED) - return (1); - else - return (0); + if (READ_VID32(SC1200_VID_ALPHA_CONTROL) & SC1200_VIDEO_IS_INTERLACED) + return (1); + else + return (0); } /*--------------------------------------------------------------------------- @@ -2609,16 +2607,16 @@ int gfx_get_color_space_YUV(void) #endif { - unsigned long control; + unsigned long control; - control = READ_VID32(SC1200_VID_ALPHA_CONTROL); + control = READ_VID32(SC1200_VID_ALPHA_CONTROL); - /* IS SC1200 VIDEO COLOR SPACE RGB OR CONVERTED TO RGB */ - if ((control & SC1200_VIDEO_INPUT_IS_RGB) - || (control & SC1200_CSC_VIDEO_YUV_TO_RGB)) - return (0); - else - return (1); + /* IS SC1200 VIDEO COLOR SPACE RGB OR CONVERTED TO RGB */ + if ((control & SC1200_VIDEO_INPUT_IS_RGB) + || (control & SC1200_CSC_VIDEO_YUV_TO_RGB)) + return (0); + else + return (1); } /*--------------------------------------------------------------------------- @@ -2636,18 +2634,19 @@ int gfx_get_vertical_scaler_offset(char *offset) #endif { - unsigned long control; + unsigned long control; - control = READ_VID32(SC1200_VID_ALPHA_CONTROL); - if (control & SC1200_VERTICAL_SCALER_SHIFT_EN) { - if ((control & SC1200_VERTICAL_SCALER_SHIFT_MASK) == - SC1200_VERTICAL_SCALER_SHIFT_INIT) - *offset = 1; - else - return GFX_STATUS_ERROR; /* TODO: find the interpretation of other values */ - } else - *offset = 0; - return (0); + control = READ_VID32(SC1200_VID_ALPHA_CONTROL); + if (control & SC1200_VERTICAL_SCALER_SHIFT_EN) { + if ((control & SC1200_VERTICAL_SCALER_SHIFT_MASK) == + SC1200_VERTICAL_SCALER_SHIFT_INIT) + *offset = 1; + else + return GFX_STATUS_ERROR; /* TODO: find the interpretation of other values */ + } + else + *offset = 0; + return (0); } /*--------------------------------------------------------------------------- @@ -2664,7 +2663,7 @@ unsigned long gfx_get_genlock_delay(void) #endif { - return (READ_VID32(SC1200_GENLOCK_DELAY) & SC1200_GENLOCK_DELAY_MASK); + return (READ_VID32(SC1200_GENLOCK_DELAY) & SC1200_GENLOCK_DELAY_MASK); } /*--------------------------------------------------------------------------- @@ -2681,11 +2680,11 @@ int gfx_get_genlock_enable(void) #endif { - if (READ_VID32(SC1200_GENLOCK) & - (SC1200_GENLOCK_SINGLE_ENABLE | SC1200_GENLOCK_CONTINUOUS_ENABLE)) - return (1); - else - return (0); + if (READ_VID32(SC1200_GENLOCK) & + (SC1200_GENLOCK_SINGLE_ENABLE | SC1200_GENLOCK_CONTINUOUS_ENABLE)) + return (1); + else + return (0); } /*--------------------------------------------------------------------------- @@ -2700,25 +2699,25 @@ gfx_get_genlock_enable(void) #if GFX_VIDEO_DYNAMIC int sc1200_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, unsigned long *color1, - unsigned short *color2) + unsigned short *select_color2, unsigned long *color1, + unsigned short *color2) #else int gfx_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, unsigned long *color1, - unsigned short *color2) + unsigned short *select_color2, unsigned long *color1, + unsigned short *color2) #endif { - *select_color2 = - (unsigned short)(READ_VID32(SC1200_CURSOR_COLOR_KEY) >> - SC1200_CURSOR_COLOR_KEY_OFFSET_POS); - *key = READ_VID32(SC1200_CURSOR_COLOR_KEY) & SC1200_COLOR_MASK; - *mask = READ_VID32(SC1200_CURSOR_COLOR_MASK) & SC1200_COLOR_MASK; - *color1 = READ_VID32(SC1200_CURSOR_COLOR_1) & SC1200_COLOR_MASK; - *color2 = - (unsigned short)(READ_VID32(SC1200_CURSOR_COLOR_2) & - SC1200_COLOR_MASK); - return (0); + *select_color2 = + (unsigned short) (READ_VID32(SC1200_CURSOR_COLOR_KEY) >> + SC1200_CURSOR_COLOR_KEY_OFFSET_POS); + *key = READ_VID32(SC1200_CURSOR_COLOR_KEY) & SC1200_COLOR_MASK; + *mask = READ_VID32(SC1200_CURSOR_COLOR_MASK) & SC1200_COLOR_MASK; + *color1 = READ_VID32(SC1200_CURSOR_COLOR_1) & SC1200_COLOR_MASK; + *color2 = + (unsigned short) (READ_VID32(SC1200_CURSOR_COLOR_2) & + SC1200_COLOR_MASK); + return (0); } /*--------------------------------------------------------------------------- @@ -2737,27 +2736,27 @@ unsigned long gfx_read_crc(void) #endif { - unsigned long crc = 0xFFFFFFFF; + unsigned long crc = 0xFFFFFFFF; - if (gfx_test_timing_active()) { - /* WAIT UNTIL ACTIVE DISPLAY */ + if (gfx_test_timing_active()) { + /* WAIT UNTIL ACTIVE DISPLAY */ - while (!gfx_test_vertical_active()) ; + while (!gfx_test_vertical_active()); - /* RESET CRC DURING ACTIVE DISPLAY */ + /* RESET CRC DURING ACTIVE DISPLAY */ - WRITE_VID32(SC1200_VID_CRC, 0); - WRITE_VID32(SC1200_VID_CRC, 1); + WRITE_VID32(SC1200_VID_CRC, 0); + WRITE_VID32(SC1200_VID_CRC, 1); - /* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */ + /* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */ - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - crc = READ_VID32(SC1200_VID_CRC) >> 8; - } - return (crc); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + crc = READ_VID32(SC1200_VID_CRC) >> 8; + } + return (crc); } /*----------------------------------------------------------------------------- @@ -2775,9 +2774,9 @@ int gfx_get_macrovision_enable(void) #endif { - if (READ_VID32(SC1200_TVENC_MV_CONTROL) == SC1200_TVENC_MV_ENABLE) - return (1); - return (0); + if (READ_VID32(SC1200_TVENC_MV_CONTROL) == SC1200_TVENC_MV_ENABLE) + return (1); + return (0); } /*--------------------------------------------------------------------------- @@ -2795,17 +2794,17 @@ void gfx_get_alpha_enable(int *enable) #endif { - unsigned long value = 0; + unsigned long value = 0; - *enable = 0; - if (gfx_alpha_select <= 2) { - value = - READ_VID32(SC1200_ALPHA_CONTROL_1 + - ((unsigned long)gfx_alpha_select << 4)); - if (value & SC1200_ACTRL_WIN_ENABLE) - *enable = 1; - } - return; + *enable = 0; + if (gfx_alpha_select <= 2) { + value = + READ_VID32(SC1200_ALPHA_CONTROL_1 + + ((unsigned long) gfx_alpha_select << 4)); + if (value & SC1200_ACTRL_WIN_ENABLE) + *enable = 1; + } + return; } /*--------------------------------------------------------------------------- @@ -2817,34 +2816,34 @@ gfx_get_alpha_enable(int *enable) #if GFX_VIDEO_DYNAMIC void sc1200_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height) + unsigned short *width, unsigned short *height) #else void gfx_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height) + unsigned short *width, unsigned short *height) #endif { - unsigned long value = 0; + unsigned long value = 0; - *x = 0; - *y = 0; - *width = 0; - *height = 0; - if (gfx_alpha_select <= 2) { - value = - READ_VID32(SC1200_ALPHA_XPOS_1 + - ((unsigned long)gfx_alpha_select << 4)); - *x = (unsigned short)(value & 0x000007FF); - *width = (unsigned short)((value >> 16) & 0x000007FF) - *x; - value = - READ_VID32(SC1200_ALPHA_YPOS_1 + - ((unsigned long)gfx_alpha_select << 4)); - *y = (unsigned short)(value & 0x000007FF); - *height = (unsigned short)((value >> 16) & 0x000007FF) - *y; - } - *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2; - *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1; - return; + *x = 0; + *y = 0; + *width = 0; + *height = 0; + if (gfx_alpha_select <= 2) { + value = + READ_VID32(SC1200_ALPHA_XPOS_1 + + ((unsigned long) gfx_alpha_select << 4)); + *x = (unsigned short) (value & 0x000007FF); + *width = (unsigned short) ((value >> 16) & 0x000007FF) - *x; + value = + READ_VID32(SC1200_ALPHA_YPOS_1 + + ((unsigned long) gfx_alpha_select << 4)); + *y = (unsigned short) (value & 0x000007FF); + *height = (unsigned short) ((value >> 16) & 0x000007FF) - *y; + } + *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2; + *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1; + return; } /*--------------------------------------------------------------------------- @@ -2862,18 +2861,18 @@ void gfx_get_alpha_value(unsigned char *alpha, char *delta) #endif { - unsigned long value = 0; + unsigned long value = 0; - *alpha = 0; - *delta = 0; - if (gfx_alpha_select <= 2) { - value = - READ_VID32(SC1200_ALPHA_CONTROL_1 + - ((unsigned long)gfx_alpha_select << 4)); - *alpha = (unsigned char)(value & 0x00FF); - *delta = (char)((value >> 8) & 0x00FF); - } - return; + *alpha = 0; + *delta = 0; + if (gfx_alpha_select <= 2) { + value = + READ_VID32(SC1200_ALPHA_CONTROL_1 + + ((unsigned long) gfx_alpha_select << 4)); + *alpha = (unsigned char) (value & 0x00FF); + *delta = (char) ((value >> 8) & 0x00FF); + } + return; } /*--------------------------------------------------------------------------- @@ -2890,15 +2889,15 @@ void gfx_get_alpha_priority(int *priority) #endif { - unsigned long pos = 0, value = 0; + unsigned long pos = 0, value = 0; - *priority = 0; - if (gfx_alpha_select <= 2) { - value = READ_VID32(SC1200_VID_ALPHA_CONTROL); - pos = 16 + (gfx_alpha_select << 1); - *priority = (int)((value >> pos) & 3); - } - return; + *priority = 0; + if (gfx_alpha_select <= 2) { + value = READ_VID32(SC1200_VID_ALPHA_CONTROL); + pos = 16 + (gfx_alpha_select << 1); + *priority = (int) ((value >> pos) & 3); + } + return; } /*--------------------------------------------------------------------------- @@ -2916,15 +2915,15 @@ void gfx_get_alpha_color(unsigned long *color) #endif { - *color = 0; - if (gfx_alpha_select <= 2) { - *color = - READ_VID32(SC1200_ALPHA_COLOR_1 + - ((unsigned long)gfx_alpha_select << 4)); - } - return; + *color = 0; + if (gfx_alpha_select <= 2) { + *color = + READ_VID32(SC1200_ALPHA_COLOR_1 + + ((unsigned long) gfx_alpha_select << 4)); + } + return; } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ diff --git a/src/gfx/vid_1400.c b/src/gfx/vid_1400.c index 11f9361..693394e 100644 --- a/src/gfx/vid_1400.c +++ b/src/gfx/vid_1400.c @@ -18,50 +18,48 @@ *---------------------------------------------------------------------------- */ -typedef struct tagSC1400PLL -{ - long frequency; /* 16.16 fixed point frequency */ - unsigned long clock_select; /* clock select register (0x2C) */ -} -SC1400PLL; +typedef struct tagSC1400PLL { + long frequency; /* 16.16 fixed point frequency */ + unsigned long clock_select; /* clock select register (0x2C) */ +} SC1400PLL; SC1400PLL gfx_sc1400_clock_table[] = { - {0x00192CCC, 0x00000000}, /* 25.1750 */ - {0x001C526E, 0x00010000}, /* 28.3220 */ - {0x001F8000, 0x00020000}, /* 31.5000 */ - {0x00240000, 0x000E0000}, /* 36.0000 */ - {0x00258000, 0x0010110C}, /* 37.5000 */ - {0x00280000, 0x00040000}, /* 40.0000 */ - {0x002CE666, 0x00090000}, /* 44.9000 */ - {0x00320000, 0x00100C06}, /* 50.0000 */ - {0x00325999, 0x0050600C}, /* 50.3500 */ - {0x00360000, 0x00100100}, /* 54.0000 */ - {0x0038643F, 0x0010160A}, /* 56.3916 */ - {0x0038A3D7, 0x00506C0C}, /* 56.6440 */ - {0x003B0000, 0x0010170A}, /* 59.6583 */ - {0x003BA886, 0x00100A04}, /* 59.6583 */ - {0x003F0000, 0x00100602}, /* 63.0000 */ - {0x00410000, 0x00060000}, /* 65.0000 */ - {0x00438000, 0x00100401}, /* 67.5000 */ - {0x0046CCCC, 0x00101407}, /* 70.8000 */ - {0x00480000, 0x00100702}, /* 72.0000 */ - {0x004B0000, 0x00070000}, /* 75.0000 */ - {0x004EC000, 0x0010220B}, /* 78.7500 */ - {0x00500000, 0x00304C0C}, /* 80.0000 */ - {0x00510000, 0x00100200}, /* 81.0000 */ - {0x00550000, 0x00080000}, /* 85.0000 */ - {0x0059CCCC, 0x00100902}, /* 89.8000 */ - {0x00630000, 0x00100A02}, /* 99.0000 */ - {0x00640000, 0x00102409}, /* 100.0000 */ - {0x006C0000, 0x00100300}, /* 108.0000 */ - {0x00870000, 0x00050000}, /* 135.0000 */ - {0x009D8000, 0x00102205}, /* 157.5000 */ - {0x00A20000, 0x00100500}, /* 162.0000 */ - {0x00AA0000, 0x000B0000}, /* 170.0000 */ - {0x00AF0000, 0x00100C01}, /* 175.0000 */ - {0x00BD0000, 0x00100600}, /* 189.0000 */ - {0x00CA0000, 0x00100E01}, /* 202.0000 */ - {0x00E80000, 0x00102A04}, /* 232.0000 */ + {0x00192CCC, 0x00000000}, /* 25.1750 */ + {0x001C526E, 0x00010000}, /* 28.3220 */ + {0x001F8000, 0x00020000}, /* 31.5000 */ + {0x00240000, 0x000E0000}, /* 36.0000 */ + {0x00258000, 0x0010110C}, /* 37.5000 */ + {0x00280000, 0x00040000}, /* 40.0000 */ + {0x002CE666, 0x00090000}, /* 44.9000 */ + {0x00320000, 0x00100C06}, /* 50.0000 */ + {0x00325999, 0x0050600C}, /* 50.3500 */ + {0x00360000, 0x00100100}, /* 54.0000 */ + {0x0038643F, 0x0010160A}, /* 56.3916 */ + {0x0038A3D7, 0x00506C0C}, /* 56.6440 */ + {0x003B0000, 0x0010170A}, /* 59.6583 */ + {0x003BA886, 0x00100A04}, /* 59.6583 */ + {0x003F0000, 0x00100602}, /* 63.0000 */ + {0x00410000, 0x00060000}, /* 65.0000 */ + {0x00438000, 0x00100401}, /* 67.5000 */ + {0x0046CCCC, 0x00101407}, /* 70.8000 */ + {0x00480000, 0x00100702}, /* 72.0000 */ + {0x004B0000, 0x00070000}, /* 75.0000 */ + {0x004EC000, 0x0010220B}, /* 78.7500 */ + {0x00500000, 0x00304C0C}, /* 80.0000 */ + {0x00510000, 0x00100200}, /* 81.0000 */ + {0x00550000, 0x00080000}, /* 85.0000 */ + {0x0059CCCC, 0x00100902}, /* 89.8000 */ + {0x00630000, 0x00100A02}, /* 99.0000 */ + {0x00640000, 0x00102409}, /* 100.0000 */ + {0x006C0000, 0x00100300}, /* 108.0000 */ + {0x00870000, 0x00050000}, /* 135.0000 */ + {0x009D8000, 0x00102205}, /* 157.5000 */ + {0x00A20000, 0x00100500}, /* 162.0000 */ + {0x00AA0000, 0x000B0000}, /* 170.0000 */ + {0x00AF0000, 0x00100C01}, /* 175.0000 */ + {0x00BD0000, 0x00100600}, /* 189.0000 */ + {0x00CA0000, 0x00100E01}, /* 202.0000 */ + {0x00E80000, 0x00102A04}, /* 232.0000 */ }; #define NUM_SC1400_FREQUENCIES sizeof(gfx_sc1400_clock_table)/sizeof(SC1400PLL) @@ -81,7 +79,7 @@ void gfx_reset_video(void) #endif { - gfx_set_video_enable(0); + gfx_set_video_enable(0); } /*--------------------------------------------------------------------------- @@ -100,32 +98,32 @@ void gfx_set_clock_frequency(unsigned long frequency) #endif { - int index; - unsigned long value; - long min, diff; - - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ - - value = gfx_sc1400_clock_table[0].clock_select; - min = (long)gfx_sc1400_clock_table[0].frequency - frequency; - if (min < 0L) - min = -min; - for (index = 1; index < NUM_SC1400_FREQUENCIES; index++) { - diff = (long)gfx_sc1400_clock_table[index].frequency - frequency; - if (diff < 0L) - diff = -diff; - if (diff < min) { - min = diff; - value = gfx_sc1400_clock_table[index].clock_select; - } - } - - /* SET THE DOT CLOCK REGISTER */ - - WRITE_VID32(SC1400_VID_MISC, 0x00001000); - WRITE_VID32(SC1400_VID_CLOCK_SELECT, value); - return; + int index; + unsigned long value; + long min, diff; + + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ + + value = gfx_sc1400_clock_table[0].clock_select; + min = (long) gfx_sc1400_clock_table[0].frequency - frequency; + if (min < 0L) + min = -min; + for (index = 1; index < NUM_SC1400_FREQUENCIES; index++) { + diff = (long) gfx_sc1400_clock_table[index].frequency - frequency; + if (diff < 0L) + diff = -diff; + if (diff < min) { + min = diff; + value = gfx_sc1400_clock_table[index].clock_select; + } + } + + /* SET THE DOT CLOCK REGISTER */ + + WRITE_VID32(SC1400_VID_MISC, 0x00001000); + WRITE_VID32(SC1400_VID_CLOCK_SELECT, value); + return; } /*----------------------------------------------------------------------------- @@ -142,46 +140,47 @@ int gfx_set_video_enable(int enable) #endif { - unsigned long vcfg; + unsigned long vcfg; - /* WAIT FOR VERTICAL BLANK TO START */ - /* Otherwise a glitch can be observed. */ + /* WAIT FOR VERTICAL BLANK TO START */ + /* Otherwise a glitch can be observed. */ - if (gfx_test_timing_active()) { - if (!gfx_test_vertical_active()) { - while (!gfx_test_vertical_active()) ; - } - while (gfx_test_vertical_active()) ; - } - vcfg = READ_VID32(SC1400_VIDEO_CONFIG); - if (enable) { - /* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + if (gfx_test_timing_active()) { + if (!gfx_test_vertical_active()) { + while (!gfx_test_vertical_active()); + } + while (gfx_test_vertical_active()); + } + vcfg = READ_VID32(SC1400_VIDEO_CONFIG); + if (enable) { + /* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_enable(1); + gfx_set_display_video_enable(1); - /* SET SC1400 BUS CONTROL PARAMETERS */ - /* Currently always high speed, 8-bit interface. */ + /* SET SC1400 BUS CONTROL PARAMETERS */ + /* Currently always high speed, 8-bit interface. */ - vcfg |= SC1400_VCFG_HIGH_SPD_INT; - vcfg &= ~(SC1400_VCFG_EARLY_VID_RDY | SC1400_VCFG_16_BIT_EN); + vcfg |= SC1400_VCFG_HIGH_SPD_INT; + vcfg &= ~(SC1400_VCFG_EARLY_VID_RDY | SC1400_VCFG_16_BIT_EN); - /* ENABLE SC1400 VIDEO OVERLAY */ + /* ENABLE SC1400 VIDEO OVERLAY */ - vcfg |= SC1400_VCFG_VID_EN; - WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); - } else { - /* DISABLE SC1400 VIDEO OVERLAY */ + vcfg |= SC1400_VCFG_VID_EN; + WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); + } + else { + /* DISABLE SC1400 VIDEO OVERLAY */ - vcfg &= ~SC1400_VCFG_VID_EN; - WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); + vcfg &= ~SC1400_VCFG_VID_EN; + WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); - /* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_enable(0); - } - return (0); + gfx_set_display_video_enable(0); + } + return (0); } /*----------------------------------------------------------------------------- @@ -198,19 +197,19 @@ int gfx_set_video_format(unsigned long format) #endif { - unsigned long vcfg = 0; - - /* SET THE SC1400 VIDEO INPUT FORMAT */ - - vcfg = READ_VID32(SC1400_VIDEO_CONFIG); - vcfg &= ~(SC1400_VCFG_VID_INP_FORMAT | SC1400_VCFG_4_2_0_MODE); - vcfg &= ~(SC1400_VCFG_CSC_BYPASS); - if (format < 4) - vcfg |= (format << 2); - else - vcfg |= SC1400_VCFG_CSC_BYPASS; - WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); - return (0); + unsigned long vcfg = 0; + + /* SET THE SC1400 VIDEO INPUT FORMAT */ + + vcfg = READ_VID32(SC1400_VIDEO_CONFIG); + vcfg &= ~(SC1400_VCFG_VID_INP_FORMAT | SC1400_VCFG_4_2_0_MODE); + vcfg &= ~(SC1400_VCFG_CSC_BYPASS); + if (format < 4) + vcfg |= (format << 2); + else + vcfg |= SC1400_VCFG_CSC_BYPASS; + WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); + return (0); } /*----------------------------------------------------------------------------- @@ -229,23 +228,23 @@ int gfx_set_video_size(unsigned short width, unsigned short height) #endif { - unsigned long size, vcfg; + unsigned long size, vcfg; - /* SET THE SC1400 VIDEO LINE SIZE */ + /* SET THE SC1400 VIDEO LINE SIZE */ - vcfg = READ_VID32(SC1400_VIDEO_CONFIG); - vcfg &= ~(SC1400_VCFG_LINE_SIZE_LOWER_MASK | SC1400_VCFG_LINE_SIZE_UPPER); - size = (width >> 1); - vcfg |= (size & 0x00FF) << 8; - if (size & 0x0100) - vcfg |= SC1400_VCFG_LINE_SIZE_UPPER; - WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); + vcfg = READ_VID32(SC1400_VIDEO_CONFIG); + vcfg &= ~(SC1400_VCFG_LINE_SIZE_LOWER_MASK | SC1400_VCFG_LINE_SIZE_UPPER); + size = (width >> 1); + vcfg |= (size & 0x00FF) << 8; + if (size & 0x0100) + vcfg |= SC1400_VCFG_LINE_SIZE_UPPER; + WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); - /* SET TOTAL VIDEO BUFFER SIZE IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET TOTAL VIDEO BUFFER SIZE IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_size(width, height); - return (0); + gfx_set_display_video_size(width, height); + return (0); } /*----------------------------------------------------------------------------- @@ -263,15 +262,15 @@ int gfx_set_video_offset(unsigned long offset) #endif { - /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ + /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ - gfx_vid_offset = offset; + gfx_vid_offset = offset; - /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_offset(offset); - return (0); + gfx_set_display_video_offset(offset); + return (0); } /*--------------------------------------------------------------------------- @@ -284,44 +283,44 @@ gfx_set_video_offset(unsigned long offset) #if GFX_VIDEO_DYNAMIC int sc1400_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #else int gfx_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #endif { - unsigned long xscale, yscale; - - /* SAVE PARAMETERS */ - /* These are needed for clipping the video window later. */ - - gfx_vid_srcw = srcw; - gfx_vid_srch = srch; - gfx_vid_dstw = dstw; - gfx_vid_dsth = dsth; - - /* CALCULATE SC1400 SCALE FACTORS */ - /* No downscaling in SC1400 so force to 1x if attempted. */ - - if (srcw < dstw) - xscale = (0x2000 * (srcw - 1)) / (dstw - 1); - else - xscale = 0x1FFF; - if (srch < dsth) - yscale = (0x2000 * (srch - 1)) / (dsth - 1); - else - yscale = 0x1FFF; - WRITE_VID32(SC1400_VIDEO_SCALE, (yscale << 16) | xscale); - - /* CALL ROUTINE TO UPDATE WINDOW POSITION */ - /* This is required because the scale values effect the number of */ - /* source data pixels that need to be clipped, as well as the */ - /* amount of data that needs to be transferred. */ - - gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width, - gfx_vid_height); - return (0); + unsigned long xscale, yscale; + + /* SAVE PARAMETERS */ + /* These are needed for clipping the video window later. */ + + gfx_vid_srcw = srcw; + gfx_vid_srch = srch; + gfx_vid_dstw = dstw; + gfx_vid_dsth = dsth; + + /* CALCULATE SC1400 SCALE FACTORS */ + /* No downscaling in SC1400 so force to 1x if attempted. */ + + if (srcw < dstw) + xscale = (0x2000 * (srcw - 1)) / (dstw - 1); + else + xscale = 0x1FFF; + if (srch < dsth) + yscale = (0x2000 * (srch - 1)) / (dsth - 1); + else + yscale = 0x1FFF; + WRITE_VID32(SC1400_VIDEO_SCALE, (yscale << 16) | xscale); + + /* CALL ROUTINE TO UPDATE WINDOW POSITION */ + /* This is required because the scale values effect the number of */ + /* source data pixels that need to be clipped, as well as the */ + /* amount of data that needs to be transferred. */ + + gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width, + gfx_vid_height); + return (0); } /*--------------------------------------------------------------------------- @@ -341,95 +340,97 @@ int gfx_set_video_window(short x, short y, unsigned short w, unsigned short h) #endif { - unsigned long vcfg = 0; - unsigned long hadjust, vadjust; - unsigned long initread; - unsigned long xstart, ystart, xend, yend; - unsigned long offset, line_size; - - /* SAVE PARAMETERS */ - /* These are needed to call this routine if the scale value changes. */ - - gfx_vid_xpos = x; - gfx_vid_ypos = y; - gfx_vid_width = w; - gfx_vid_height = h; - - /* GET ADJUSTMENT VALUES */ - /* Use routines to abstract version of display controller. */ - - hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13; - vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1; - - if (x > 0) { - /* NO CLIPPING ON LEFT */ - - xstart = x + hadjust; - initread = 0; - } else { - /* CLIPPING ON LEFT */ - /* Adjust initial read for scale, checking for divide by zero */ - - xstart = hadjust; - initread = -x; - if (gfx_vid_dstw) - initread = ((-x) * gfx_vid_srcw) / gfx_vid_dstw; - else - initread = 0; - } - - /* CLIPPING ON RIGHT */ - - xend = x + w; - if (xend > gfx_get_hactive()) - xend = gfx_get_hactive(); - xend += hadjust; - - /* CLIPPING ON TOP */ - - offset = gfx_vid_offset; - if (y >= 0) { - ystart = y + vadjust; - } else { - ystart = vadjust; - line_size = (READ_VID32(SC1400_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_LINE_SIZE_UPPER) - line_size += 512; - if (gfx_vid_dsth) - offset = gfx_vid_offset + (line_size << 1) * - (((-y) * gfx_vid_srch) / gfx_vid_dsth); - } - - /* CLIPPING ON BOTTOM */ - - yend = y + h; - if (yend >= gfx_get_vactive()) - yend = gfx_get_vactive(); - yend += vadjust; - - /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ - - gfx_set_display_video_offset(offset); - - /* DISABLE REGISTER UPDATES */ - - vcfg = READ_VID32(SC1400_VIDEO_CONFIG); - vcfg &= ~SC1400_VCFG_VID_REG_UPDATE; - WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); - - /* SET VIDEO POSITION */ - - WRITE_VID32(SC1400_VIDEO_X_POS, (xend << 16) | xstart); - WRITE_VID32(SC1400_VIDEO_Y_POS, (yend << 16) | ystart); - - /* SET INITIAL READ ADDRESS AND ENABLE REGISTER UPDATES */ - - vcfg &= ~SC1400_VCFG_INIT_READ_MASK; - vcfg |= (initread << 15) & SC1400_VCFG_INIT_READ_MASK; - vcfg |= SC1400_VCFG_VID_REG_UPDATE; - WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); - return (0); + unsigned long vcfg = 0; + unsigned long hadjust, vadjust; + unsigned long initread; + unsigned long xstart, ystart, xend, yend; + unsigned long offset, line_size; + + /* SAVE PARAMETERS */ + /* These are needed to call this routine if the scale value changes. */ + + gfx_vid_xpos = x; + gfx_vid_ypos = y; + gfx_vid_width = w; + gfx_vid_height = h; + + /* GET ADJUSTMENT VALUES */ + /* Use routines to abstract version of display controller. */ + + hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13; + vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1; + + if (x > 0) { + /* NO CLIPPING ON LEFT */ + + xstart = x + hadjust; + initread = 0; + } + else { + /* CLIPPING ON LEFT */ + /* Adjust initial read for scale, checking for divide by zero */ + + xstart = hadjust; + initread = -x; + if (gfx_vid_dstw) + initread = ((-x) * gfx_vid_srcw) / gfx_vid_dstw; + else + initread = 0; + } + + /* CLIPPING ON RIGHT */ + + xend = x + w; + if (xend > gfx_get_hactive()) + xend = gfx_get_hactive(); + xend += hadjust; + + /* CLIPPING ON TOP */ + + offset = gfx_vid_offset; + if (y >= 0) { + ystart = y + vadjust; + } + else { + ystart = vadjust; + line_size = (READ_VID32(SC1400_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_LINE_SIZE_UPPER) + line_size += 512; + if (gfx_vid_dsth) + offset = gfx_vid_offset + (line_size << 1) * + (((-y) * gfx_vid_srch) / gfx_vid_dsth); + } + + /* CLIPPING ON BOTTOM */ + + yend = y + h; + if (yend >= gfx_get_vactive()) + yend = gfx_get_vactive(); + yend += vadjust; + + /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ + + gfx_set_display_video_offset(offset); + + /* DISABLE REGISTER UPDATES */ + + vcfg = READ_VID32(SC1400_VIDEO_CONFIG); + vcfg &= ~SC1400_VCFG_VID_REG_UPDATE; + WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); + + /* SET VIDEO POSITION */ + + WRITE_VID32(SC1400_VIDEO_X_POS, (xend << 16) | xstart); + WRITE_VID32(SC1400_VIDEO_Y_POS, (yend << 16) | ystart); + + /* SET INITIAL READ ADDRESS AND ENABLE REGISTER UPDATES */ + + vcfg &= ~SC1400_VCFG_INIT_READ_MASK; + vcfg |= (initread << 15) & SC1400_VCFG_INIT_READ_MASK; + vcfg |= SC1400_VCFG_VID_REG_UPDATE; + WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -448,29 +449,28 @@ gfx_set_video_window(short x, short y, unsigned short w, unsigned short h) */ #if GFX_VIDEO_DYNAMIC int -sc1400_set_video_color_key(unsigned long key, unsigned long mask, - int graphics) +sc1400_set_video_color_key(unsigned long key, unsigned long mask, int graphics) #else int gfx_set_video_color_key(unsigned long key, unsigned long mask, int graphics) #endif { - unsigned long dcfg = 0; + unsigned long dcfg = 0; - /* SET SC1400 COLOR KEY VALUE */ + /* SET SC1400 COLOR KEY VALUE */ - WRITE_VID32(SC1400_VIDEO_COLOR_KEY, key); - WRITE_VID32(SC1400_VIDEO_COLOR_MASK, mask); + WRITE_VID32(SC1400_VIDEO_COLOR_KEY, key); + WRITE_VID32(SC1400_VIDEO_COLOR_MASK, mask); - /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */ + /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */ - dcfg = READ_VID32(SC1400_DISPLAY_CONFIG); - if (graphics & 0x01) - dcfg &= ~SC1400_DCFG_VG_CK; - else - dcfg |= SC1400_DCFG_VG_CK; - WRITE_VID32(SC1400_DISPLAY_CONFIG, dcfg); - return (0); + dcfg = READ_VID32(SC1400_DISPLAY_CONFIG); + if (graphics & 0x01) + dcfg &= ~SC1400_DCFG_VG_CK; + else + dcfg |= SC1400_DCFG_VG_CK; + WRITE_VID32(SC1400_DISPLAY_CONFIG, dcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -487,18 +487,18 @@ int gfx_set_video_filter(int xfilter, int yfilter) #endif { - unsigned long vcfg = 0; - - /* ENABLE OR DISABLE SC1400 VIDEO OVERLAY FILTERS */ - - vcfg = READ_VID32(SC1400_VIDEO_CONFIG); - vcfg &= ~(SC1400_VCFG_X_FILTER_EN | SC1400_VCFG_Y_FILTER_EN); - if (xfilter) - vcfg |= SC1400_VCFG_X_FILTER_EN; - if (yfilter) - vcfg |= SC1400_VCFG_Y_FILTER_EN; - WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); - return (0); + unsigned long vcfg = 0; + + /* ENABLE OR DISABLE SC1400 VIDEO OVERLAY FILTERS */ + + vcfg = READ_VID32(SC1400_VIDEO_CONFIG); + vcfg &= ~(SC1400_VCFG_X_FILTER_EN | SC1400_VCFG_Y_FILTER_EN); + if (xfilter) + vcfg |= SC1400_VCFG_X_FILTER_EN; + if (yfilter) + vcfg |= SC1400_VCFG_Y_FILTER_EN; + WRITE_VID32(SC1400_VIDEO_CONFIG, vcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -517,19 +517,19 @@ int gfx_set_video_palette(unsigned long *palette) #endif { - unsigned long i, entry; - - /* LOAD SC1400 VIDEO PALETTE */ - - WRITE_VID32(SC1400_PALETTE_ADDRESS, 0); - for (i = 0; i < 256; i++) { - if (palette) - entry = palette[i]; - else - entry = i | (i << 8) | (i << 16); - WRITE_VID32(SC1400_PALETTE_DATA, entry); - } - return (0); + unsigned long i, entry; + + /* LOAD SC1400 VIDEO PALETTE */ + + WRITE_VID32(SC1400_PALETTE_ADDRESS, 0); + for (i = 0; i < 256; i++) { + if (palette) + entry = palette[i]; + else + entry = i | (i << 8) | (i << 16); + WRITE_VID32(SC1400_PALETTE_DATA, entry); + } + return (0); } /*************************************************************/ @@ -554,13 +554,13 @@ int gfx_get_sync_polarities(void) #endif { - int polarities = 0; + int polarities = 0; - if (READ_VID32(SC1400_DISPLAY_CONFIG) & 0x00000100) - polarities |= 1; - if (READ_VID32(SC1400_DISPLAY_CONFIG) & 0x00000200) - polarities |= 2; - return (polarities); + if (READ_VID32(SC1400_DISPLAY_CONFIG) & 0x00000100) + polarities |= 1; + if (READ_VID32(SC1400_DISPLAY_CONFIG) & 0x00000200) + polarities |= 2; + return (polarities); } /*----------------------------------------------------------------------------- @@ -578,9 +578,9 @@ int gfx_get_video_enable(void) #endif { - if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_VID_EN) - return (1); - return (0); + if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_VID_EN) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -597,13 +597,13 @@ int gfx_get_video_format(void) #endif { - unsigned long vcfg; + unsigned long vcfg; - vcfg = READ_VID32(SC1400_VIDEO_CONFIG); - if (vcfg & SC1400_VCFG_CSC_BYPASS) - return (4); - else - return ((vcfg >> 2) & 3); + vcfg = READ_VID32(SC1400_VIDEO_CONFIG); + if (vcfg & SC1400_VCFG_CSC_BYPASS) + return (4); + else + return ((vcfg >> 2) & 3); } /*----------------------------------------------------------------------------- @@ -621,21 +621,21 @@ unsigned long gfx_get_video_src_size(void) #endif { - unsigned long width = 0, height = 0; + unsigned long width = 0, height = 0; - /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */ - width = (READ_VID32(SC1400_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_LINE_SIZE_UPPER) - width += 512; + width = (READ_VID32(SC1400_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_LINE_SIZE_UPPER) + width += 512; - if (width) { - /* DETERMINE HEIGHT BY DIVIDING TOTAL SIZE BY WIDTH */ - /* Get total size from display controller - abtracted. */ + if (width) { + /* DETERMINE HEIGHT BY DIVIDING TOTAL SIZE BY WIDTH */ + /* Get total size from display controller - abtracted. */ - height = gfx_get_display_video_size() / (width << 1); - } - return ((height << 16) | width); + height = gfx_get_display_video_size() / (width << 1); + } + return ((height << 16) | width); } /*----------------------------------------------------------------------------- @@ -653,14 +653,14 @@ unsigned long gfx_get_video_line_size(void) #endif { - unsigned long width = 0; + unsigned long width = 0; - /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */ - width = (READ_VID32(SC1400_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_LINE_SIZE_UPPER) - width += 512; - return (width); + width = (READ_VID32(SC1400_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_LINE_SIZE_UPPER) + width += 512; + return (width); } /*----------------------------------------------------------------------------- @@ -678,12 +678,12 @@ unsigned long gfx_get_video_xclip(void) #endif { - unsigned long clip = 0; + unsigned long clip = 0; - /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE SC1400 VIDEO LINE SIZE */ - clip = (READ_VID32(SC1400_VIDEO_CONFIG) >> 14) & 0x000007FC; - return (clip); + clip = (READ_VID32(SC1400_VIDEO_CONFIG) >> 14) & 0x000007FC; + return (clip); } /*----------------------------------------------------------------------------- @@ -700,7 +700,7 @@ unsigned long gfx_get_video_offset(void) #endif { - return (gfx_get_display_video_offset()); + return (gfx_get_display_video_offset()); } /*--------------------------------------------------------------------------- @@ -717,7 +717,7 @@ unsigned long gfx_get_video_scale(void) #endif { - return (READ_VID32(SC1400_VIDEO_SCALE)); + return (READ_VID32(SC1400_VIDEO_SCALE)); } /*--------------------------------------------------------------------------- @@ -734,13 +734,13 @@ unsigned long gfx_get_video_dst_size(void) #endif { - unsigned long xsize, ysize; + unsigned long xsize, ysize; - xsize = READ_VID32(SC1400_VIDEO_X_POS); - xsize = ((xsize >> 16) & 0x3FF) - (xsize & 0x03FF); - ysize = READ_VID32(SC1400_VIDEO_Y_POS); - ysize = ((ysize >> 16) & 0x3FF) - (ysize & 0x03FF); - return ((ysize << 16) | xsize); + xsize = READ_VID32(SC1400_VIDEO_X_POS); + xsize = ((xsize >> 16) & 0x3FF) - (xsize & 0x03FF); + ysize = READ_VID32(SC1400_VIDEO_Y_POS); + ysize = ((ysize >> 16) & 0x3FF) - (ysize & 0x03FF); + return ((ysize << 16) | xsize); } /*--------------------------------------------------------------------------- @@ -758,22 +758,22 @@ unsigned long gfx_get_video_position(void) #endif { - unsigned long hadjust, vadjust; - unsigned long xpos, ypos; + unsigned long hadjust, vadjust; + unsigned long xpos, ypos; - /* READ HARDWARE POSITION */ + /* READ HARDWARE POSITION */ - xpos = READ_VID32(SC1400_VIDEO_X_POS) & 0x000003FF; - ypos = READ_VID32(SC1400_VIDEO_Y_POS) & 0x000003FF; + xpos = READ_VID32(SC1400_VIDEO_X_POS) & 0x000003FF; + ypos = READ_VID32(SC1400_VIDEO_Y_POS) & 0x000003FF; - /* GET ADJUSTMENT VALUES */ - /* Use routines to abstract version of display controller. */ + /* GET ADJUSTMENT VALUES */ + /* Use routines to abstract version of display controller. */ - hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13; - vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1; - xpos -= hadjust; - ypos -= vadjust; - return ((ypos << 16) | (xpos & 0x0000FFFF)); + hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13; + vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1; + xpos -= hadjust; + ypos -= vadjust; + return ((ypos << 16) | (xpos & 0x0000FFFF)); } /*--------------------------------------------------------------------------- @@ -790,7 +790,7 @@ unsigned long gfx_get_video_color_key(void) #endif { - return (READ_VID32(SC1400_VIDEO_COLOR_KEY)); + return (READ_VID32(SC1400_VIDEO_COLOR_KEY)); } /*--------------------------------------------------------------------------- @@ -807,7 +807,7 @@ unsigned long gfx_get_video_color_key_mask(void) #endif { - return (READ_VID32(SC1400_VIDEO_COLOR_MASK)); + return (READ_VID32(SC1400_VIDEO_COLOR_MASK)); } /*--------------------------------------------------------------------------- @@ -824,9 +824,9 @@ int gfx_get_video_color_key_src(void) #endif { - if (READ_VID32(SC1400_DISPLAY_CONFIG) & SC1400_DCFG_VG_CK) - return (0); - return (1); + if (READ_VID32(SC1400_DISPLAY_CONFIG) & SC1400_DCFG_VG_CK) + return (0); + return (1); } /*--------------------------------------------------------------------------- @@ -843,13 +843,13 @@ int gfx_get_video_filter(void) #endif { - int retval = 0; + int retval = 0; - if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_X_FILTER_EN) - retval |= 1; - if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_Y_FILTER_EN) - retval |= 2; - return (retval); + if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_X_FILTER_EN) + retval |= 1; + if (READ_VID32(SC1400_VIDEO_CONFIG) & SC1400_VCFG_Y_FILTER_EN) + retval |= 2; + return (retval); } /*--------------------------------------------------------------------------- @@ -868,16 +868,16 @@ unsigned long gfx_get_clock_frequency(void) #endif { - int index; - unsigned long value, mask; - - mask = 0x007FFF0F; - value = READ_VID32(SC1400_VID_CLOCK_SELECT) & mask; - for (index = 0; index < NUM_SC1400_FREQUENCIES; index++) { - if ((gfx_sc1400_clock_table[index].clock_select & mask) == value) - return (gfx_sc1400_clock_table[index].frequency); - } - return (0); + int index; + unsigned long value, mask; + + mask = 0x007FFF0F; + value = READ_VID32(SC1400_VID_CLOCK_SELECT) & mask; + for (index = 0; index < NUM_SC1400_FREQUENCIES; index++) { + if ((gfx_sc1400_clock_table[index].clock_select & mask) == value) + return (gfx_sc1400_clock_table[index].frequency); + } + return (0); } /*--------------------------------------------------------------------------- @@ -896,29 +896,29 @@ unsigned long gfx_read_crc(void) #endif { - unsigned long crc = 0xFFFFFFFF; + unsigned long crc = 0xFFFFFFFF; - if (gfx_test_timing_active()) { - // WAIT UNTIL ACTIVE DISPLAY + if (gfx_test_timing_active()) { + // WAIT UNTIL ACTIVE DISPLAY - while (!gfx_test_vertical_active()) ; + while (!gfx_test_vertical_active()); - // RESET CRC DURING ACTIVE DISPLAY + // RESET CRC DURING ACTIVE DISPLAY - WRITE_VID32(SC1400_VID_CRC, 0); - WRITE_VID32(SC1400_VID_CRC, 1); + WRITE_VID32(SC1400_VID_CRC, 0); + WRITE_VID32(SC1400_VID_CRC, 1); - // WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE + // WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - crc = READ_VID32(SC1400_VID_CRC) >> 8; - } - return (crc); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + crc = READ_VID32(SC1400_VID_CRC) >> 8; + } + return (crc); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ diff --git a/src/gfx/vid_5530.c b/src/gfx/vid_5530.c index 17d5f3b..55619c0 100644 --- a/src/gfx/vid_5530.c +++ b/src/gfx/vid_5530.c @@ -132,51 +132,49 @@ * CS5530 PLL TABLE *---------------------------------------------------------------------------- */ -typedef struct tagCS5530PLLENTRY -{ - long frequency; /* 16.16 fixed point frequency */ - unsigned long pll_value; /* associated register value */ -} -CS5530PLLENTRY; +typedef struct tagCS5530PLLENTRY { + long frequency; /* 16.16 fixed point frequency */ + unsigned long pll_value; /* associated register value */ +} CS5530PLLENTRY; CS5530PLLENTRY CS5530_PLLtable[] = { - {0x00192CCC, 0x31C45801,}, /* 25.1750 */ - {0x001C526E, 0x20E36802,}, /* 28.3220 */ - {0x001F8000, 0x33915801,}, /* 31.5000 */ - {0x00240000, 0x31EC4801,}, /* 36.0000 */ - {0x00258000, 0x21E22801,}, /* 37.5000 */ - {0x00280000, 0x33088801,}, /* 40.0000 */ - {0x002CE666, 0x33E22801,}, /* 44.9000 */ - {0x00318000, 0x336C4801,}, /* 49.5000 */ - {0x00320000, 0x23088801,}, /* 50.0000 */ - {0x00325999, 0x23088801,}, /* 50.3500 */ - {0x00360000, 0x3708A801,}, /* 54.0000 */ - {0x00384000, 0x23E36802,}, /* 56.2500 */ - {0x0038643F, 0x23E36802,}, /* 56.3916 */ - {0x0038A4DD, 0x23E36802,}, /* 56.6444 */ - {0x003B0000, 0x37C45801,}, /* 59.0000 */ - {0x003F0000, 0x23EC4801,}, /* 63.0000 */ - {0x00410000, 0x37911801,}, /* 65.0000 */ - {0x00438000, 0x37963803,}, /* 67.5000 */ - {0x0046CCCC, 0x37058803,}, /* 70.8000 */ - {0x00480000, 0x3710C805,}, /* 72.0000 */ - {0x004B0000, 0x37E22801,}, /* 75.0000 */ - {0x004EC000, 0x27915801,}, /* 78.7500 */ - {0x00500000, 0x37D8D802,}, /* 80.0000 */ - {0x0059CCCC, 0x27588802,}, /* 89.8000 */ - {0x005E8000, 0x27EC4802,}, /* 94.5000 */ - {0x00630000, 0x27AC6803,}, /* 99.0000 */ - {0x00640000, 0x27088801,}, /* 100.0000 */ - {0x006C0000, 0x2710C805,}, /* 108.0000 */ - {0x00708000, 0x27E36802,}, /* 112.5000 */ - {0x00820000, 0x27C58803,}, /* 130.0000 */ - {0x00870000, 0x27316803,}, /* 135.0000 */ - {0x009D8000, 0x2F915801,}, /* 157.5000 */ - {0x00A20000, 0x2F08A801,}, /* 162.0000 */ - {0x00AF0000, 0x2FB11802,}, /* 175.0000 */ - {0x00BD0000, 0x2FEC4802,}, /* 189.0000 */ - {0x00CA0000, 0x2F963803,}, /* 202.0000 */ - {0x00E80000, 0x2FB1B802,}, /* 232.0000 */ + {0x00192CCC, 0x31C45801,}, /* 25.1750 */ + {0x001C526E, 0x20E36802,}, /* 28.3220 */ + {0x001F8000, 0x33915801,}, /* 31.5000 */ + {0x00240000, 0x31EC4801,}, /* 36.0000 */ + {0x00258000, 0x21E22801,}, /* 37.5000 */ + {0x00280000, 0x33088801,}, /* 40.0000 */ + {0x002CE666, 0x33E22801,}, /* 44.9000 */ + {0x00318000, 0x336C4801,}, /* 49.5000 */ + {0x00320000, 0x23088801,}, /* 50.0000 */ + {0x00325999, 0x23088801,}, /* 50.3500 */ + {0x00360000, 0x3708A801,}, /* 54.0000 */ + {0x00384000, 0x23E36802,}, /* 56.2500 */ + {0x0038643F, 0x23E36802,}, /* 56.3916 */ + {0x0038A4DD, 0x23E36802,}, /* 56.6444 */ + {0x003B0000, 0x37C45801,}, /* 59.0000 */ + {0x003F0000, 0x23EC4801,}, /* 63.0000 */ + {0x00410000, 0x37911801,}, /* 65.0000 */ + {0x00438000, 0x37963803,}, /* 67.5000 */ + {0x0046CCCC, 0x37058803,}, /* 70.8000 */ + {0x00480000, 0x3710C805,}, /* 72.0000 */ + {0x004B0000, 0x37E22801,}, /* 75.0000 */ + {0x004EC000, 0x27915801,}, /* 78.7500 */ + {0x00500000, 0x37D8D802,}, /* 80.0000 */ + {0x0059CCCC, 0x27588802,}, /* 89.8000 */ + {0x005E8000, 0x27EC4802,}, /* 94.5000 */ + {0x00630000, 0x27AC6803,}, /* 99.0000 */ + {0x00640000, 0x27088801,}, /* 100.0000 */ + {0x006C0000, 0x2710C805,}, /* 108.0000 */ + {0x00708000, 0x27E36802,}, /* 112.5000 */ + {0x00820000, 0x27C58803,}, /* 130.0000 */ + {0x00870000, 0x27316803,}, /* 135.0000 */ + {0x009D8000, 0x2F915801,}, /* 157.5000 */ + {0x00A20000, 0x2F08A801,}, /* 162.0000 */ + {0x00AF0000, 0x2FB11802,}, /* 175.0000 */ + {0x00BD0000, 0x2FEC4802,}, /* 189.0000 */ + {0x00CA0000, 0x2F963803,}, /* 202.0000 */ + {0x00E80000, 0x2FB1B802,}, /* 232.0000 */ }; #define NUM_CS5530_FREQUENCIES sizeof(CS5530_PLLtable)/sizeof(CS5530PLLENTRY) @@ -187,27 +185,27 @@ int cs5530_set_video_size(unsigned short width, unsigned short height); int cs5530_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch); int cs5530_set_video_offset(unsigned long offset); int cs5530_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset, - unsigned long voffset); + unsigned long voffset); int cs5530_set_video_window(short x, short y, unsigned short w, - unsigned short h); + unsigned short h); int cs5530_set_video_left_crop(unsigned short x); int cs5530_set_video_upscale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); + unsigned short dstw, unsigned short dsth); int cs5530_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); + unsigned short dstw, unsigned short dsth); int cs5530_set_video_vertical_downscale(unsigned short srch, - unsigned short dsth); + unsigned short dsth); void cs5530_set_video_vertical_downscale_enable(int enable); int cs5530_set_video_downscale_config(unsigned short type, unsigned short m); int cs5530_set_video_color_key(unsigned long key, unsigned long mask, - int bluescreen); + int bluescreen); int cs5530_set_video_filter(int xfilter, int yfilter); int cs5530_set_video_palette(unsigned long *palette); int cs5530_set_video_palette_entry(unsigned long index, unsigned long color); int cs5530_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4); + unsigned short coef2, + unsigned short coef3, + unsigned short coef4); int cs5530_set_video_downscale_enable(int enable); int cs5530_set_video_source(VideoSourceType source); int cs5530_set_vbi_source(VbiSourceType source); @@ -220,15 +218,15 @@ int cs5530_set_top_line_in_odd(int enable); int cs5530_set_genlock_delay(unsigned long delay); int cs5530_set_genlock_enable(int flags); int cs5530_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, - unsigned long color1, unsigned long color2); + unsigned short select_color2, + unsigned long color1, unsigned long color2); int cs5530_set_video_cursor_enable(int enable); int cs5530_set_video_request(short x, short y); int cs5530_select_alpha_region(int region); int cs5530_set_alpha_enable(int enable); int cs5530_set_alpha_window(short x, short y, - unsigned short width, unsigned short height); + unsigned short width, unsigned short height); int cs5530_set_alpha_value(unsigned char alpha, char delta); int cs5530_set_alpha_priority(int priority); int cs5530_set_alpha_color(unsigned long color); @@ -251,27 +249,24 @@ unsigned long cs5530_get_video_line_size(void); unsigned long cs5530_get_video_xclip(void); unsigned long cs5530_get_video_offset(void); void cs5530_get_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset); -void cs5530_get_video_yuv_pitch(unsigned long *ypitch, - unsigned long *uvpitch); + unsigned long *uoffset, + unsigned long *voffset); +void cs5530_get_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch); unsigned long cs5530_get_video_upscale(void); unsigned long cs5530_get_video_scale(void); unsigned long cs5530_get_video_downscale_delta(void); int cs5530_get_video_vertical_downscale_enable(void); -int cs5530_get_video_downscale_config(unsigned short *type, - unsigned short *m); +int cs5530_get_video_downscale_config(unsigned short *type, unsigned short *m); void cs5530_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4); + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4); void cs5530_get_video_downscale_enable(int *enable); unsigned long cs5530_get_video_dst_size(void); unsigned long cs5530_get_video_position(void); unsigned long cs5530_get_video_color_key(void); unsigned long cs5530_get_video_color_key_mask(void); -int cs5530_get_video_palette_entry(unsigned long index, - unsigned long *palette); +int cs5530_get_video_palette_entry(unsigned long index, unsigned long *palette); int cs5530_get_video_color_key_src(void); int cs5530_get_video_filter(void); int cs5530_get_video_request(short *x, short *y); @@ -285,18 +280,18 @@ int cs5530_get_vertical_scaler_offset(char *offset); unsigned long cs5530_get_genlock_delay(void); int cs5530_get_genlock_enable(void); int cs5530_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, - unsigned long *color1, unsigned short *color2); + unsigned short *select_color2, + unsigned long *color1, unsigned short *color2); unsigned long cs5530_read_crc(void); unsigned long cs5530_read_crc32(void); unsigned long cs5530_read_window_crc(int source, unsigned short x, - unsigned short y, unsigned short width, - unsigned short height, int crc32); + unsigned short y, unsigned short width, + unsigned short height, int crc32); int cs5530_get_macrovision_enable(void); void cs5530_get_alpha_enable(int *enable); void cs5530_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height); + unsigned short *width, unsigned short *height); void cs5530_get_alpha_value(unsigned char *alpha, char *delta); void cs5530_get_alpha_priority(int *priority); void cs5530_get_alpha_color(unsigned long *color); @@ -318,49 +313,49 @@ int gfx_set_crt_enable(int enable) #endif { - unsigned long config; + unsigned long config; - config = READ_VID32(CS5530_DISPLAY_CONFIG); + config = READ_VID32(CS5530_DISPLAY_CONFIG); - switch (enable) { - case CRT_DISABLE: /* Disable everything */ + switch (enable) { + case CRT_DISABLE: /* Disable everything */ - WRITE_VID32(CS5530_DISPLAY_CONFIG, - config & ~(CS5530_DCFG_DIS_EN | CS5530_DCFG_HSYNC_EN | - CS5530_DCFG_VSYNC_EN | CS5530_DCFG_DAC_BL_EN | - CS5530_DCFG_DAC_PWDNX)); - break; + WRITE_VID32(CS5530_DISPLAY_CONFIG, + config & ~(CS5530_DCFG_DIS_EN | CS5530_DCFG_HSYNC_EN | + CS5530_DCFG_VSYNC_EN | CS5530_DCFG_DAC_BL_EN | + CS5530_DCFG_DAC_PWDNX)); + break; - case CRT_ENABLE: /* Enable CRT display, including display logic */ + case CRT_ENABLE: /* Enable CRT display, including display logic */ - WRITE_VID32(CS5530_DISPLAY_CONFIG, - config | CS5530_DCFG_DIS_EN | CS5530_DCFG_HSYNC_EN | - CS5530_DCFG_VSYNC_EN | CS5530_DCFG_DAC_BL_EN | - CS5530_DCFG_DAC_PWDNX); - break; + WRITE_VID32(CS5530_DISPLAY_CONFIG, + config | CS5530_DCFG_DIS_EN | CS5530_DCFG_HSYNC_EN | + CS5530_DCFG_VSYNC_EN | CS5530_DCFG_DAC_BL_EN | + CS5530_DCFG_DAC_PWDNX); + break; - case CRT_STANDBY: /* HSync:Off VSync:On */ + case CRT_STANDBY: /* HSync:Off VSync:On */ - WRITE_VID32(CS5530_DISPLAY_CONFIG, - (config & - ~(CS5530_DCFG_DIS_EN | CS5530_DCFG_HSYNC_EN | - CS5530_DCFG_DAC_BL_EN | CS5530_DCFG_DAC_PWDNX)) - | CS5530_DCFG_VSYNC_EN); - break; + WRITE_VID32(CS5530_DISPLAY_CONFIG, + (config & + ~(CS5530_DCFG_DIS_EN | CS5530_DCFG_HSYNC_EN | + CS5530_DCFG_DAC_BL_EN | CS5530_DCFG_DAC_PWDNX)) + | CS5530_DCFG_VSYNC_EN); + break; - case CRT_SUSPEND: /* HSync:On VSync:Off */ + case CRT_SUSPEND: /* HSync:On VSync:Off */ - WRITE_VID32(CS5530_DISPLAY_CONFIG, - (config & - ~(CS5530_DCFG_DIS_EN | CS5530_DCFG_VSYNC_EN | - CS5530_DCFG_DAC_BL_EN | CS5530_DCFG_DAC_PWDNX)) - | CS5530_DCFG_HSYNC_EN); - break; + WRITE_VID32(CS5530_DISPLAY_CONFIG, + (config & + ~(CS5530_DCFG_DIS_EN | CS5530_DCFG_VSYNC_EN | + CS5530_DCFG_DAC_BL_EN | CS5530_DCFG_DAC_PWDNX)) + | CS5530_DCFG_HSYNC_EN); + break; - default: - return (GFX_STATUS_BAD_PARAMETER); - } - return (GFX_STATUS_OK); + default: + return (GFX_STATUS_BAD_PARAMETER); + } + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -378,7 +373,7 @@ void gfx_reset_video(void) #endif { - gfx_set_video_enable(0); + gfx_set_video_enable(0); } /*----------------------------------------------------------------------------- @@ -404,37 +399,37 @@ int gfx_set_display_control(int sync_polarities) #endif { - unsigned long dcfg; + unsigned long dcfg; - /* ENABLE DISPLAY OUTPUT FROM CX5530 */ + /* ENABLE DISPLAY OUTPUT FROM CX5530 */ - dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); + dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); - /* CLEAR RELEVANT FIELDS */ + /* CLEAR RELEVANT FIELDS */ - dcfg &= ~(CS5530_DCFG_CRT_SYNC_SKW_MASK | CS5530_DCFG_PWR_SEQ_DLY_MASK | - CS5530_DCFG_CRT_HSYNC_POL | CS5530_DCFG_CRT_VSYNC_POL | - CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); + dcfg &= ~(CS5530_DCFG_CRT_SYNC_SKW_MASK | CS5530_DCFG_PWR_SEQ_DLY_MASK | + CS5530_DCFG_CRT_HSYNC_POL | CS5530_DCFG_CRT_VSYNC_POL | + CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); - /* INITIALIZATION */ + /* INITIALIZATION */ - dcfg |= (CS5530_DCFG_CRT_SYNC_SKW_INIT | - CS5530_DCFG_PWR_SEQ_DLY_INIT | CS5530_DCFG_GV_PAL_BYP); + dcfg |= (CS5530_DCFG_CRT_SYNC_SKW_INIT | + CS5530_DCFG_PWR_SEQ_DLY_INIT | CS5530_DCFG_GV_PAL_BYP); - if (PanelEnable) { - dcfg |= CS5530_DCFG_FP_PWR_EN; - dcfg |= CS5530_DCFG_FP_DATA_EN; - } + if (PanelEnable) { + dcfg |= CS5530_DCFG_FP_PWR_EN; + dcfg |= CS5530_DCFG_FP_DATA_EN; + } - /* SET APPROPRIATE SYNC POLARITIES */ + /* SET APPROPRIATE SYNC POLARITIES */ - if (sync_polarities & 1) - dcfg |= CS5530_DCFG_CRT_HSYNC_POL; - if (sync_polarities & 2) - dcfg |= CS5530_DCFG_CRT_VSYNC_POL; + if (sync_polarities & 1) + dcfg |= CS5530_DCFG_CRT_HSYNC_POL; + if (sync_polarities & 2) + dcfg |= CS5530_DCFG_CRT_VSYNC_POL; - WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); - return (0); + WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -453,35 +448,35 @@ void gfx_set_clock_frequency(unsigned long frequency) #endif { - unsigned int index; - unsigned long value; - long min, diff; - - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ - - value = CS5530_PLLtable[0].pll_value; - min = (long)CS5530_PLLtable[0].frequency - frequency; - if (min < 0L) - min = -min; - for (index = 1; index < NUM_CS5530_FREQUENCIES; index++) { - diff = (long)CS5530_PLLtable[index].frequency - frequency; - if (diff < 0L) - diff = -diff; - if (diff < min) { - min = diff; - value = CS5530_PLLtable[index].pll_value; - } - } - - /* SET THE DOT CLOCK REGISTER */ - - WRITE_VID32(CS5530_DOT_CLK_CONFIG, value); - WRITE_VID32(CS5530_DOT_CLK_CONFIG, value | 0x80000100); /* set reset/bypass */ - gfx_delay_milliseconds(1); /* wait for PLL to settle */ - WRITE_VID32(CS5530_DOT_CLK_CONFIG, value & 0x7FFFFFFF); /* clear reset */ - WRITE_VID32(CS5530_DOT_CLK_CONFIG, value & 0x7FFFFEFF); /* clear bypass */ - return; + unsigned int index; + unsigned long value; + long min, diff; + + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ + + value = CS5530_PLLtable[0].pll_value; + min = (long) CS5530_PLLtable[0].frequency - frequency; + if (min < 0L) + min = -min; + for (index = 1; index < NUM_CS5530_FREQUENCIES; index++) { + diff = (long) CS5530_PLLtable[index].frequency - frequency; + if (diff < 0L) + diff = -diff; + if (diff < min) { + min = diff; + value = CS5530_PLLtable[index].pll_value; + } + } + + /* SET THE DOT CLOCK REGISTER */ + + WRITE_VID32(CS5530_DOT_CLK_CONFIG, value); + WRITE_VID32(CS5530_DOT_CLK_CONFIG, value | 0x80000100); /* set reset/bypass */ + gfx_delay_milliseconds(1); /* wait for PLL to settle */ + WRITE_VID32(CS5530_DOT_CLK_CONFIG, value & 0x7FFFFFFF); /* clear reset */ + WRITE_VID32(CS5530_DOT_CLK_CONFIG, value & 0x7FFFFEFF); /* clear bypass */ + return; } /*----------------------------------------------------------------------------- @@ -498,46 +493,47 @@ int gfx_set_video_enable(int enable) #endif { - unsigned long vcfg; + unsigned long vcfg; - /* WAIT FOR VERTICAL BLANK TO START */ - /* Otherwise a glitch can be observed. */ + /* WAIT FOR VERTICAL BLANK TO START */ + /* Otherwise a glitch can be observed. */ - if (gfx_test_timing_active()) { - if (!gfx_test_vertical_active()) { - while (!gfx_test_vertical_active()) ; - } - while (gfx_test_vertical_active()) ; - } - vcfg = READ_VID32(CS5530_VIDEO_CONFIG); - if (enable) { - /* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + if (gfx_test_timing_active()) { + if (!gfx_test_vertical_active()) { + while (!gfx_test_vertical_active()); + } + while (gfx_test_vertical_active()); + } + vcfg = READ_VID32(CS5530_VIDEO_CONFIG); + if (enable) { + /* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_enable(1); + gfx_set_display_video_enable(1); - /* SET CS5530 BUS CONTROL PARAMETERS */ - /* Currently always high speed, 8-bit interface. */ + /* SET CS5530 BUS CONTROL PARAMETERS */ + /* Currently always high speed, 8-bit interface. */ - vcfg |= CS5530_VCFG_HIGH_SPD_INT; - vcfg &= ~(CS5530_VCFG_EARLY_VID_RDY | CS5530_VCFG_16_BIT_EN); + vcfg |= CS5530_VCFG_HIGH_SPD_INT; + vcfg &= ~(CS5530_VCFG_EARLY_VID_RDY | CS5530_VCFG_16_BIT_EN); - /* ENABLE CS5530 VIDEO OVERLAY */ + /* ENABLE CS5530 VIDEO OVERLAY */ - vcfg |= CS5530_VCFG_VID_EN; - WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); - } else { - /* DISABLE CS5530 VIDEO OVERLAY */ + vcfg |= CS5530_VCFG_VID_EN; + WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); + } + else { + /* DISABLE CS5530 VIDEO OVERLAY */ - vcfg &= ~CS5530_VCFG_VID_EN; - WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); + vcfg &= ~CS5530_VCFG_VID_EN; + WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); - /* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_enable(0); - } - return (0); + gfx_set_display_video_enable(0); + } + return (0); } /*----------------------------------------------------------------------------- @@ -554,30 +550,30 @@ int gfx_set_video_format(unsigned long format) #endif { - unsigned long vcfg = 0; - - /* SET THE CS5530 VIDEO INPUT FORMAT */ - - vcfg = READ_VID32(CS5530_VIDEO_CONFIG); - vcfg &= ~(CS5530_VCFG_VID_INP_FORMAT | CS5530_VCFG_4_2_0_MODE); - vcfg &= ~(CS5530_VCFG_CSC_BYPASS); - vcfg &= ~(CS5530_VCFG_GV_SEL); - - if (format < 4) - vcfg |= (format << 2); - else { - if (format == VIDEO_FORMAT_Y0Y1Y2Y3) { - vcfg |= CS5530_VCFG_4_2_0_MODE; - vcfg |= 1 << 2; - } - if (format == VIDEO_FORMAT_RGB) { - vcfg |= CS5530_VCFG_CSC_BYPASS; - vcfg |= CS5530_VCFG_GV_SEL; - } - } - - WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); - return (0); + unsigned long vcfg = 0; + + /* SET THE CS5530 VIDEO INPUT FORMAT */ + + vcfg = READ_VID32(CS5530_VIDEO_CONFIG); + vcfg &= ~(CS5530_VCFG_VID_INP_FORMAT | CS5530_VCFG_4_2_0_MODE); + vcfg &= ~(CS5530_VCFG_CSC_BYPASS); + vcfg &= ~(CS5530_VCFG_GV_SEL); + + if (format < 4) + vcfg |= (format << 2); + else { + if (format == VIDEO_FORMAT_Y0Y1Y2Y3) { + vcfg |= CS5530_VCFG_4_2_0_MODE; + vcfg |= 1 << 2; + } + if (format == VIDEO_FORMAT_RGB) { + vcfg |= CS5530_VCFG_CSC_BYPASS; + vcfg |= CS5530_VCFG_GV_SEL; + } + } + + WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); + return (0); } /*----------------------------------------------------------------------------- @@ -596,23 +592,23 @@ int gfx_set_video_size(unsigned short width, unsigned short height) #endif { - unsigned long size, vcfg; + unsigned long size, vcfg; - /* SET THE CS5530 VIDEO LINE SIZE */ + /* SET THE CS5530 VIDEO LINE SIZE */ - vcfg = READ_VID32(CS5530_VIDEO_CONFIG); - vcfg &= ~(CS5530_VCFG_LINE_SIZE_LOWER_MASK | CS5530_VCFG_LINE_SIZE_UPPER); - size = (width >> 1); - vcfg |= (size & 0x00FF) << 8; - if (size & 0x0100) - vcfg |= CS5530_VCFG_LINE_SIZE_UPPER; - WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); + vcfg = READ_VID32(CS5530_VIDEO_CONFIG); + vcfg &= ~(CS5530_VCFG_LINE_SIZE_LOWER_MASK | CS5530_VCFG_LINE_SIZE_UPPER); + size = (width >> 1); + vcfg |= (size & 0x00FF) << 8; + if (size & 0x0100) + vcfg |= CS5530_VCFG_LINE_SIZE_UPPER; + WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); - /* SET TOTAL VIDEO BUFFER SIZE IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET TOTAL VIDEO BUFFER SIZE IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_size(width, height); - return (0); + gfx_set_display_video_size(width, height); + return (0); } /*----------------------------------------------------------------------------- @@ -630,15 +626,15 @@ int gfx_set_video_offset(unsigned long offset) #endif { - /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ + /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ - gfx_vid_offset = offset; + gfx_vid_offset = offset; - /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_offset(offset); - return (0); + gfx_set_display_video_offset(offset); + return (0); } /*--------------------------------------------------------------------------- @@ -651,48 +647,48 @@ gfx_set_video_offset(unsigned long offset) #if GFX_VIDEO_DYNAMIC int cs5530_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #else int gfx_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #endif { - unsigned long xscale, yscale; - - /* SAVE PARAMETERS */ - /* These are needed for clipping the video window later. */ - - gfx_vid_srcw = srcw; - gfx_vid_srch = srch; - gfx_vid_dstw = dstw; - gfx_vid_dsth = dsth; - - /* CALCULATE CS5530 SCALE FACTORS */ - /* No downscaling in CS5530 so force to 1x if attempted. */ - - if (dstw <= srcw) - xscale = 0x1FFF; - else if (dstw == 1 || srcw == 1) - return GFX_STATUS_BAD_PARAMETER; - else - xscale = (0x2000l * (srcw - 1l)) / (dstw - 1l); - if (dsth <= srch) - yscale = 0x1FFF; - else if (dsth == 1 || srch == 1) - return GFX_STATUS_BAD_PARAMETER; - else - yscale = (0x2000l * (srch - 1l)) / (dsth - 1l); - WRITE_VID32(CS5530_VIDEO_SCALE, (yscale << 16) | xscale); - - /* CALL ROUTINE TO UPDATE WINDOW POSITION */ - /* This is required because the scale values effect the number of */ - /* source data pixels that need to be clipped, as well as the */ - /* amount of data that needs to be transferred. */ - - gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width, - gfx_vid_height); - return (0); + unsigned long xscale, yscale; + + /* SAVE PARAMETERS */ + /* These are needed for clipping the video window later. */ + + gfx_vid_srcw = srcw; + gfx_vid_srch = srch; + gfx_vid_dstw = dstw; + gfx_vid_dsth = dsth; + + /* CALCULATE CS5530 SCALE FACTORS */ + /* No downscaling in CS5530 so force to 1x if attempted. */ + + if (dstw <= srcw) + xscale = 0x1FFF; + else if (dstw == 1 || srcw == 1) + return GFX_STATUS_BAD_PARAMETER; + else + xscale = (0x2000l * (srcw - 1l)) / (dstw - 1l); + if (dsth <= srch) + yscale = 0x1FFF; + else if (dsth == 1 || srch == 1) + return GFX_STATUS_BAD_PARAMETER; + else + yscale = (0x2000l * (srch - 1l)) / (dsth - 1l); + WRITE_VID32(CS5530_VIDEO_SCALE, (yscale << 16) | xscale); + + /* CALL ROUTINE TO UPDATE WINDOW POSITION */ + /* This is required because the scale values effect the number of */ + /* source data pixels that need to be clipped, as well as the */ + /* amount of data that needs to be transferred. */ + + gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width, + gfx_vid_height); + return (0); } /*--------------------------------------------------------------------------- @@ -712,61 +708,61 @@ int gfx_set_video_window(short x, short y, unsigned short w, unsigned short h) #endif { - unsigned long vcfg = 0; - unsigned long hadjust, vadjust; - unsigned long xstart, ystart, xend, yend; + unsigned long vcfg = 0; + unsigned long hadjust, vadjust; + unsigned long xstart, ystart, xend, yend; - /* SAVE PARAMETERS */ - /* These are needed to call this routine if the scale value changes. */ + /* SAVE PARAMETERS */ + /* These are needed to call this routine if the scale value changes. */ - gfx_vid_xpos = x; - gfx_vid_ypos = y; - gfx_vid_width = w; - gfx_vid_height = h; + gfx_vid_xpos = x; + gfx_vid_ypos = y; + gfx_vid_width = w; + gfx_vid_height = h; - /* GET ADJUSTMENT VALUES */ - /* Use routines to abstract version of display controller. */ + /* GET ADJUSTMENT VALUES */ + /* Use routines to abstract version of display controller. */ - hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13l; - vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l; + hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13l; + vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l; - /* HORIZONTAL START */ - xstart = (unsigned long)x + hadjust; + /* HORIZONTAL START */ + xstart = (unsigned long) x + hadjust; - /* HORIZONTAL END */ - /* End positions in register are non-inclusive (one more than the actual end) */ + /* HORIZONTAL END */ + /* End positions in register are non-inclusive (one more than the actual end) */ - if ((x + w) < gfx_get_hactive()) - xend = (unsigned long)x + (unsigned long)w + hadjust; - else /* right clipping needed */ - xend = (unsigned long)gfx_get_hactive() + hadjust; + if ((x + w) < gfx_get_hactive()) + xend = (unsigned long) x + (unsigned long) w + hadjust; + else /* right clipping needed */ + xend = (unsigned long) gfx_get_hactive() + hadjust; - /* VERTICAL START */ + /* VERTICAL START */ - ystart = (unsigned long)y + vadjust; + ystart = (unsigned long) y + vadjust; - /* VERTICAL END */ + /* VERTICAL END */ - if ((y + h) < gfx_get_vactive()) - yend = (unsigned long)y + (unsigned long)h + vadjust; - else /* bottom clipping needed */ - yend = (unsigned long)gfx_get_vactive() + vadjust; + if ((y + h) < gfx_get_vactive()) + yend = (unsigned long) y + (unsigned long) h + vadjust; + else /* bottom clipping needed */ + yend = (unsigned long) gfx_get_vactive() + vadjust; - /* DISABLE REGISTER UPDATES */ + /* DISABLE REGISTER UPDATES */ - vcfg = READ_VID32(CS5530_VIDEO_CONFIG); - vcfg &= ~CS5530_VCFG_VID_REG_UPDATE; - WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); + vcfg = READ_VID32(CS5530_VIDEO_CONFIG); + vcfg &= ~CS5530_VCFG_VID_REG_UPDATE; + WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); - /* SET VIDEO POSITION */ + /* SET VIDEO POSITION */ - WRITE_VID32(CS5530_VIDEO_X_POS, (xend << 16) | xstart); - WRITE_VID32(CS5530_VIDEO_Y_POS, (yend << 16) | ystart); + WRITE_VID32(CS5530_VIDEO_X_POS, (xend << 16) | xstart); + WRITE_VID32(CS5530_VIDEO_Y_POS, (yend << 16) | ystart); - vcfg |= CS5530_VCFG_VID_REG_UPDATE; - WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); + vcfg |= CS5530_VCFG_VID_REG_UPDATE; + WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -786,25 +782,25 @@ int gfx_set_video_left_crop(unsigned short x) #endif { - unsigned long vcfg, initread; + unsigned long vcfg, initread; - /* CLIPPING ON LEFT */ - /* Adjust initial read for scale, checking for divide by zero */ + /* CLIPPING ON LEFT */ + /* Adjust initial read for scale, checking for divide by zero */ - if (gfx_vid_dstw) - initread = (unsigned long)x *gfx_vid_srcw / gfx_vid_dstw; + if (gfx_vid_dstw) + initread = (unsigned long) x *gfx_vid_srcw / gfx_vid_dstw; - else - initread = 0; + else + initread = 0; - /* SET INITIAL READ ADDRESS AND ENABLE REGISTER UPDATES */ + /* SET INITIAL READ ADDRESS AND ENABLE REGISTER UPDATES */ - vcfg = READ_VID32(CS5530_VIDEO_CONFIG); - vcfg &= ~CS5530_VCFG_INIT_READ_MASK; - vcfg |= (initread << 15) & CS5530_VCFG_INIT_READ_MASK; - vcfg |= CS5530_VCFG_VID_REG_UPDATE; - WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); - return (0); + vcfg = READ_VID32(CS5530_VIDEO_CONFIG); + vcfg &= ~CS5530_VCFG_INIT_READ_MASK; + vcfg |= (initread << 15) & CS5530_VCFG_INIT_READ_MASK; + vcfg |= CS5530_VCFG_VID_REG_UPDATE; + WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -823,29 +819,28 @@ gfx_set_video_left_crop(unsigned short x) */ #if GFX_VIDEO_DYNAMIC int -cs5530_set_video_color_key(unsigned long key, unsigned long mask, - int graphics) +cs5530_set_video_color_key(unsigned long key, unsigned long mask, int graphics) #else int gfx_set_video_color_key(unsigned long key, unsigned long mask, int graphics) #endif { - unsigned long dcfg = 0; + unsigned long dcfg = 0; - /* SET CS5530 COLOR KEY VALUE */ + /* SET CS5530 COLOR KEY VALUE */ - WRITE_VID32(CS5530_VIDEO_COLOR_KEY, key); - WRITE_VID32(CS5530_VIDEO_COLOR_MASK, mask); + WRITE_VID32(CS5530_VIDEO_COLOR_KEY, key); + WRITE_VID32(CS5530_VIDEO_COLOR_MASK, mask); - /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */ + /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */ - dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); - if (graphics & 0x01) - dcfg &= ~CS5530_DCFG_VG_CK; - else - dcfg |= CS5530_DCFG_VG_CK; - WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); - return (0); + dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); + if (graphics & 0x01) + dcfg &= ~CS5530_DCFG_VG_CK; + else + dcfg |= CS5530_DCFG_VG_CK; + WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -862,19 +857,19 @@ int gfx_set_video_filter(int xfilter, int yfilter) #endif { - unsigned long vcfg = 0; + unsigned long vcfg = 0; - /* ENABLE OR DISABLE CS5530 VIDEO OVERLAY FILTERS */ + /* ENABLE OR DISABLE CS5530 VIDEO OVERLAY FILTERS */ - vcfg = READ_VID32(CS5530_VIDEO_CONFIG); - vcfg &= ~(CS5530_VCFG_X_FILTER_EN | CS5530_VCFG_Y_FILTER_EN); - if (xfilter) - vcfg |= CS5530_VCFG_X_FILTER_EN; - if (yfilter) - vcfg |= CS5530_VCFG_Y_FILTER_EN; - WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); + vcfg = READ_VID32(CS5530_VIDEO_CONFIG); + vcfg &= ~(CS5530_VCFG_X_FILTER_EN | CS5530_VCFG_Y_FILTER_EN); + if (xfilter) + vcfg |= CS5530_VCFG_X_FILTER_EN; + if (yfilter) + vcfg |= CS5530_VCFG_Y_FILTER_EN; + WRITE_VID32(CS5530_VIDEO_CONFIG, vcfg); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -893,19 +888,19 @@ int gfx_set_video_palette(unsigned long *palette) #endif { - unsigned long i, entry; - - /* LOAD CS5530 VIDEO PALETTE */ - - WRITE_VID32(CS5530_PALETTE_ADDRESS, 0); - for (i = 0; i < 256; i++) { - if (palette) - entry = palette[i]; - else - entry = i | (i << 8) | (i << 16); - WRITE_VID32(CS5530_PALETTE_DATA, entry); - } - return (0); + unsigned long i, entry; + + /* LOAD CS5530 VIDEO PALETTE */ + + WRITE_VID32(CS5530_PALETTE_ADDRESS, 0); + for (i = 0; i < 256; i++) { + if (palette) + entry = palette[i]; + else + entry = i | (i << 8) | (i << 16); + WRITE_VID32(CS5530_PALETTE_DATA, entry); + } + return (0); } /*--------------------------------------------------------------------------- @@ -922,15 +917,15 @@ int gfx_set_video_palette_entry(unsigned long index, unsigned long palette) #endif { - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - /* SET A SINGLE ENTRY */ + /* SET A SINGLE ENTRY */ - WRITE_VID32(CS5530_PALETTE_ADDRESS, index); - WRITE_VID32(CS5530_PALETTE_DATA, palette); + WRITE_VID32(CS5530_PALETTE_ADDRESS, index); + WRITE_VID32(CS5530_PALETTE_DATA, palette); - return (0); + return (0); } #define CX55xx_VIDEO_PCI_44 0x80009444 @@ -950,20 +945,20 @@ int gfx_disable_softvga(void) #endif { - unsigned long reg_val; + unsigned long reg_val; - /* get the current value */ - reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); - /* setting video PCI register 44 bit 0 to 1 disables SoftVga */ - reg_val |= 0x1; - gfx_pci_config_write(CX55xx_VIDEO_PCI_44, reg_val); + /* get the current value */ + reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); + /* setting video PCI register 44 bit 0 to 1 disables SoftVga */ + reg_val |= 0x1; + gfx_pci_config_write(CX55xx_VIDEO_PCI_44, reg_val); - /* see if we set the bit and return the appropriate value */ - reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); - if ((reg_val & 0x1) == 0x1) - return (1); - else - return (0); + /* see if we set the bit and return the appropriate value */ + reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); + if ((reg_val & 0x1) == 0x1) + return (1); + else + return (0); } @@ -982,19 +977,19 @@ int gfx_enable_softvga(void) #endif { - unsigned long reg_val; + unsigned long reg_val; - /* get the current value */ - reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); - /* clearing video PCI register 44 bit 0 enables SoftVga */ - gfx_pci_config_write(CX55xx_VIDEO_PCI_44, reg_val & 0xfffffffe); + /* get the current value */ + reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); + /* clearing video PCI register 44 bit 0 enables SoftVga */ + gfx_pci_config_write(CX55xx_VIDEO_PCI_44, reg_val & 0xfffffffe); - /* see if we cleared the bit and return the appropriate value */ - reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); - if ((reg_val & 0x1) == 0) - return (1); - else - return (0); + /* see if we cleared the bit and return the appropriate value */ + reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); + if ((reg_val & 0x1) == 0) + return (1); + else + return (0); } @@ -1014,16 +1009,16 @@ unsigned long gfx_get_clock_frequency(void) #endif { - unsigned int index; - unsigned long value, mask; - - mask = 0x7FFFFEDC; - value = READ_VID32(CS5530_DOT_CLK_CONFIG) & mask; - for (index = 0; index < NUM_CS5530_FREQUENCIES; index++) { - if ((CS5530_PLLtable[index].pll_value & mask) == value) - return (CS5530_PLLtable[index].frequency); - } - return (0); + unsigned int index; + unsigned long value, mask; + + mask = 0x7FFFFEDC; + value = READ_VID32(CS5530_DOT_CLK_CONFIG) & mask; + for (index = 0; index < NUM_CS5530_FREQUENCIES; index++) { + if ((CS5530_PLLtable[index].pll_value & mask) == value) + return (CS5530_PLLtable[index].frequency); + } + return (0); } /*************************************************************/ @@ -1047,13 +1042,13 @@ int gfx_get_vsa2_softvga_enable(void) #endif { - unsigned long reg_val; + unsigned long reg_val; - reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); - if ((reg_val & 0x1) == 0) - return (1); - else - return (0); + reg_val = gfx_pci_config_read(CX55xx_VIDEO_PCI_44); + if ((reg_val & 0x1) == 0) + return (1); + else + return (0); } @@ -1073,13 +1068,13 @@ int gfx_get_sync_polarities(void) #endif { - int polarities = 0; + int polarities = 0; - if (READ_VID32(CS5530_DISPLAY_CONFIG) & 0x00000100) - polarities |= 1; - if (READ_VID32(CS5530_DISPLAY_CONFIG) & 0x00000200) - polarities |= 2; - return (polarities); + if (READ_VID32(CS5530_DISPLAY_CONFIG) & 0x00000100) + polarities |= 1; + if (READ_VID32(CS5530_DISPLAY_CONFIG) & 0x00000200) + polarities |= 2; + return (polarities); } /*--------------------------------------------------------------------------- @@ -1096,15 +1091,15 @@ int gfx_get_video_palette_entry(unsigned long index, unsigned long *palette) #endif { - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - /* READ A SINGLE ENTRY */ + /* READ A SINGLE ENTRY */ - WRITE_VID32(CS5530_PALETTE_ADDRESS, index); - *palette = READ_VID32(CS5530_PALETTE_DATA); + WRITE_VID32(CS5530_PALETTE_ADDRESS, index); + *palette = READ_VID32(CS5530_PALETTE_DATA); - return (GFX_STATUS_OK); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -1122,9 +1117,9 @@ int gfx_get_video_enable(void) #endif { - if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_VID_EN) - return (1); - return (0); + if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_VID_EN) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -1141,15 +1136,15 @@ int gfx_get_video_format(void) #endif { - unsigned long vcfg; + unsigned long vcfg; - vcfg = READ_VID32(CS5530_VIDEO_CONFIG); - if (vcfg & CS5530_VCFG_CSC_BYPASS) - return (VIDEO_FORMAT_RGB); - if (vcfg & CS5530_VCFG_4_2_0_MODE) - return (VIDEO_FORMAT_Y0Y1Y2Y3); + vcfg = READ_VID32(CS5530_VIDEO_CONFIG); + if (vcfg & CS5530_VCFG_CSC_BYPASS) + return (VIDEO_FORMAT_RGB); + if (vcfg & CS5530_VCFG_4_2_0_MODE) + return (VIDEO_FORMAT_Y0Y1Y2Y3); - return ((int)((vcfg >> 2) & 3)); + return ((int) ((vcfg >> 2) & 3)); } /*----------------------------------------------------------------------------- @@ -1167,21 +1162,21 @@ unsigned long gfx_get_video_src_size(void) #endif { - unsigned long width = 0, height = 0; + unsigned long width = 0, height = 0; - /* DETERMINE SOURCE WIDTH FROM THE CS5530 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE CS5530 VIDEO LINE SIZE */ - width = (READ_VID32(CS5530_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_LINE_SIZE_UPPER) - width += 512l; + width = (READ_VID32(CS5530_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_LINE_SIZE_UPPER) + width += 512l; - if (width) { - /* DETERMINE HEIGHT BY DIVIDING TOTAL SIZE BY WIDTH */ - /* Get total size from display controller - abtracted. */ + if (width) { + /* DETERMINE HEIGHT BY DIVIDING TOTAL SIZE BY WIDTH */ + /* Get total size from display controller - abtracted. */ - height = gfx_get_display_video_size() / (width << 1); - } - return ((height << 16) | width); + height = gfx_get_display_video_size() / (width << 1); + } + return ((height << 16) | width); } /*----------------------------------------------------------------------------- @@ -1199,14 +1194,14 @@ unsigned long gfx_get_video_line_size(void) #endif { - unsigned long width = 0; + unsigned long width = 0; - /* DETERMINE SOURCE WIDTH FROM THE CS5530 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE CS5530 VIDEO LINE SIZE */ - width = (READ_VID32(CS5530_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_LINE_SIZE_UPPER) - width += 512l; - return (width); + width = (READ_VID32(CS5530_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_LINE_SIZE_UPPER) + width += 512l; + return (width); } /*----------------------------------------------------------------------------- @@ -1224,12 +1219,12 @@ unsigned long gfx_get_video_xclip(void) #endif { - unsigned long clip = 0; + unsigned long clip = 0; - /* DETERMINE SOURCE WIDTH FROM THE CS5530 VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE CS5530 VIDEO LINE SIZE */ - clip = (READ_VID32(CS5530_VIDEO_CONFIG) >> 14) & 0x000007FC; - return (clip); + clip = (READ_VID32(CS5530_VIDEO_CONFIG) >> 14) & 0x000007FC; + return (clip); } /*----------------------------------------------------------------------------- @@ -1246,7 +1241,7 @@ unsigned long gfx_get_video_offset(void) #endif { - return (gfx_get_display_video_offset()); + return (gfx_get_display_video_offset()); } /*--------------------------------------------------------------------------- @@ -1263,7 +1258,7 @@ unsigned long gfx_get_video_scale(void) #endif { - return (READ_VID32(CS5530_VIDEO_SCALE)); + return (READ_VID32(CS5530_VIDEO_SCALE)); } /*--------------------------------------------------------------------------- @@ -1282,13 +1277,13 @@ unsigned long gfx_get_video_dst_size(void) #endif { - unsigned long xsize, ysize; + unsigned long xsize, ysize; - xsize = READ_VID32(CS5530_VIDEO_X_POS); - xsize = ((xsize >> 16) & 0x7FF) - (xsize & 0x07FF); - ysize = READ_VID32(CS5530_VIDEO_Y_POS); - ysize = ((ysize >> 16) & 0x7FF) - (ysize & 0x07FF); - return ((ysize << 16) | xsize); + xsize = READ_VID32(CS5530_VIDEO_X_POS); + xsize = ((xsize >> 16) & 0x7FF) - (xsize & 0x07FF); + ysize = READ_VID32(CS5530_VIDEO_Y_POS); + ysize = ((ysize >> 16) & 0x7FF) - (ysize & 0x07FF); + return ((ysize << 16) | xsize); } /*--------------------------------------------------------------------------- @@ -1308,22 +1303,22 @@ unsigned long gfx_get_video_position(void) #endif { - unsigned long hadjust, vadjust; - unsigned long xpos, ypos; + unsigned long hadjust, vadjust; + unsigned long xpos, ypos; - /* READ HARDWARE POSITION */ + /* READ HARDWARE POSITION */ - xpos = READ_VID32(CS5530_VIDEO_X_POS) & 0x000007FF; - ypos = READ_VID32(CS5530_VIDEO_Y_POS) & 0x000007FF; + xpos = READ_VID32(CS5530_VIDEO_X_POS) & 0x000007FF; + ypos = READ_VID32(CS5530_VIDEO_Y_POS) & 0x000007FF; - /* GET ADJUSTMENT VALUES */ - /* Use routines to abstract version of display controller. */ + /* GET ADJUSTMENT VALUES */ + /* Use routines to abstract version of display controller. */ - hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13l; - vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l; - xpos -= hadjust; - ypos -= vadjust; - return ((ypos << 16) | (xpos & 0x0000FFFF)); + hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 13l; + vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l; + xpos -= hadjust; + ypos -= vadjust; + return ((ypos << 16) | (xpos & 0x0000FFFF)); } /*--------------------------------------------------------------------------- @@ -1340,7 +1335,7 @@ unsigned long gfx_get_video_color_key(void) #endif { - return (READ_VID32(CS5530_VIDEO_COLOR_KEY)); + return (READ_VID32(CS5530_VIDEO_COLOR_KEY)); } /*--------------------------------------------------------------------------- @@ -1357,7 +1352,7 @@ unsigned long gfx_get_video_color_key_mask(void) #endif { - return (READ_VID32(CS5530_VIDEO_COLOR_MASK)); + return (READ_VID32(CS5530_VIDEO_COLOR_MASK)); } /*--------------------------------------------------------------------------- @@ -1374,9 +1369,9 @@ int gfx_get_video_color_key_src(void) #endif { - if (READ_VID32(CS5530_DISPLAY_CONFIG) & CS5530_DCFG_VG_CK) - return (0); - return (1); + if (READ_VID32(CS5530_DISPLAY_CONFIG) & CS5530_DCFG_VG_CK) + return (0); + return (1); } /*--------------------------------------------------------------------------- @@ -1393,13 +1388,13 @@ int gfx_get_video_filter(void) #endif { - int retval = 0; + int retval = 0; - if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_X_FILTER_EN) - retval |= 1; - if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_Y_FILTER_EN) - retval |= 2; - return (retval); + if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_X_FILTER_EN) + retval |= 1; + if (READ_VID32(CS5530_VIDEO_CONFIG) & CS5530_VCFG_Y_FILTER_EN) + retval |= 2; + return (retval); } /*--------------------------------------------------------------------------- @@ -1418,29 +1413,29 @@ unsigned long gfx_read_crc(void) #endif { - unsigned long crc = 0xFFFFFFFF; + unsigned long crc = 0xFFFFFFFF; - if (gfx_test_timing_active()) { - /* WAIT UNTIL ACTIVE DISPLAY */ + if (gfx_test_timing_active()) { + /* WAIT UNTIL ACTIVE DISPLAY */ - while (!gfx_test_vertical_active()) ; + while (!gfx_test_vertical_active()); - /* RESET CRC DURING ACTIVE DISPLAY */ + /* RESET CRC DURING ACTIVE DISPLAY */ - WRITE_VID32(CS5530_CRCSIG_TFT_TV, 0); - WRITE_VID32(CS5530_CRCSIG_TFT_TV, 1); + WRITE_VID32(CS5530_CRCSIG_TFT_TV, 0); + WRITE_VID32(CS5530_CRCSIG_TFT_TV, 1); - /* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */ + /* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */ - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - crc = READ_VID32(CS5530_CRCSIG_TFT_TV) >> 8; - } - return (crc); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + crc = READ_VID32(CS5530_CRCSIG_TFT_TV) >> 8; + } + return (crc); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ diff --git a/src/gfx/vid_rdcl.c b/src/gfx/vid_rdcl.c index 8e429d8..1df8780 100644 --- a/src/gfx/vid_rdcl.c +++ b/src/gfx/vid_rdcl.c @@ -130,94 +130,92 @@ /* REDCLOUD PLL TABLE */ -typedef struct RCDFPLL -{ - long frequency; /* 16.16 fixed point frequency */ - unsigned long post_div3; /* MCP Frequency dividers and multipliers */ - unsigned long pre_mul2; - unsigned long pre_div2; - unsigned long pll_value; /* MCP DotPLL Register Upper 32(0x0015) */ -} -RCDFPLLENTRY; +typedef struct RCDFPLL { + long frequency; /* 16.16 fixed point frequency */ + unsigned long post_div3; /* MCP Frequency dividers and multipliers */ + unsigned long pre_mul2; + unsigned long pre_div2; + unsigned long pll_value; /* MCP DotPLL Register Upper 32(0x0015) */ +} RCDFPLLENTRY; RCDFPLLENTRY RCDF_PLLtable48MHz[] = { - {0x00192CCC, 0, 0, 0, 0x00000037}, /* 25.1750 */ - {0x001C526E, 1, 1, 0, 0x00000B1A}, /* 28.3220 */ - {0x001F8000, 1, 0, 0, 0x000002D2}, /* 31.5000 */ - {0x00240000, 1, 1, 0, 0x00000FE2}, /* 36.0000 */ - {0x00258000, 1, 0, 0, 0x0000057A}, /* 37.5000 */ - {0x00280000, 1, 0, 0, 0x0000030A}, /* 40.0000 */ - {0x002CE666, 0, 0, 0, 0x00000063}, /* 44.9000 */ - {0x00318000, 0, 0, 0, 0x0000054B}, /* 49.5000 */ - {0x00320000, 0, 0, 0, 0x0000026E}, /* 50.0000 */ - {0x00325999, 0, 1, 0, 0x00000037}, /* 50.3500 */ - {0x00360000, 1, 1, 0, 0x00000B0D}, /* 54.0000 */ - {0x00384000, 0, 0, 0, 0x00000577}, /* 56.2500 */ - {0x0038643F, 0, 0, 0, 0x000007F7}, /* 56.3916 */ - {0x0038A4DD, 0, 0, 0, 0x0000057B}, /* 56.6444 */ - {0x003B0000, 0, 1, 0, 0x00000707}, /* 59.0000 */ - {0x003F0000, 1, 1, 0, 0x00000B39}, /* 63.0000 */ - {0x00410000, 1, 1, 0, 0x00000B45}, /* 65.0000 */ - {0x00438000, 1, 1, 0, 0x00000FC1}, /* 67.5000 */ - {0x0046CCCC, 1, 0, 0, 0x00000561}, /* 70.8000 */ - {0x00480000, 1, 0, 0, 0x000007E1}, /* 72.0000 */ - {0x004B0000, 0, 0, 0, 0x00000052}, /* 75.0000 */ - {0x004EC000, 0, 0, 0, 0x00000056}, /* 78.7500 */ - {0x00500000, 1, 1, 0, 0x00000709}, /* 80.0000 */ - {0x0059CCCC, 0, 1, 0, 0x00000262}, /* 89.8000 */ - {0x005E8000, 0, 0, 0, 0x000002D2}, /* 94.5000 */ - {0x00630000, 0, 1, 0, 0x00000B4A}, /* 99.0000 */ - {0x00640000, 0, 1, 0, 0x00000036}, /* 100.0000 */ - {0x006C0000, 0, 0, 0, 0x000007E2}, /* 108.0000 */ - {0x00708000, 0, 0, 0, 0x000007F6}, /* 112.5000 */ - {0x00820000, 1, 1, 0, 0x00000FB0}, /* 130.0000 */ - {0x00870000, 1, 1, 0, 0x00000B50}, /* 135.0000 */ - {0x009D8000, 0, 0, 0, 0x00000055}, /* 157.5000 */ - {0x00A20000, 0, 0, 0, 0x000009C1}, /* 162.0000 */ - {0x00AF8000, 0, 0, 0, 0x000002C1}, /* 175.5000 */ - {0x00BD0000, 0, 0, 0, 0x000002D1}, /* 189.0000 */ - {0x00CA8000, 0, 0, 0, 0x00000551}, /* 202.5000 */ - {0x00E58000, 0, 0, 0, 0x0000057D}, /* 229.5000 */ + {0x00192CCC, 0, 0, 0, 0x00000037}, /* 25.1750 */ + {0x001C526E, 1, 1, 0, 0x00000B1A}, /* 28.3220 */ + {0x001F8000, 1, 0, 0, 0x000002D2}, /* 31.5000 */ + {0x00240000, 1, 1, 0, 0x00000FE2}, /* 36.0000 */ + {0x00258000, 1, 0, 0, 0x0000057A}, /* 37.5000 */ + {0x00280000, 1, 0, 0, 0x0000030A}, /* 40.0000 */ + {0x002CE666, 0, 0, 0, 0x00000063}, /* 44.9000 */ + {0x00318000, 0, 0, 0, 0x0000054B}, /* 49.5000 */ + {0x00320000, 0, 0, 0, 0x0000026E}, /* 50.0000 */ + {0x00325999, 0, 1, 0, 0x00000037}, /* 50.3500 */ + {0x00360000, 1, 1, 0, 0x00000B0D}, /* 54.0000 */ + {0x00384000, 0, 0, 0, 0x00000577}, /* 56.2500 */ + {0x0038643F, 0, 0, 0, 0x000007F7}, /* 56.3916 */ + {0x0038A4DD, 0, 0, 0, 0x0000057B}, /* 56.6444 */ + {0x003B0000, 0, 1, 0, 0x00000707}, /* 59.0000 */ + {0x003F0000, 1, 1, 0, 0x00000B39}, /* 63.0000 */ + {0x00410000, 1, 1, 0, 0x00000B45}, /* 65.0000 */ + {0x00438000, 1, 1, 0, 0x00000FC1}, /* 67.5000 */ + {0x0046CCCC, 1, 0, 0, 0x00000561}, /* 70.8000 */ + {0x00480000, 1, 0, 0, 0x000007E1}, /* 72.0000 */ + {0x004B0000, 0, 0, 0, 0x00000052}, /* 75.0000 */ + {0x004EC000, 0, 0, 0, 0x00000056}, /* 78.7500 */ + {0x00500000, 1, 1, 0, 0x00000709}, /* 80.0000 */ + {0x0059CCCC, 0, 1, 0, 0x00000262}, /* 89.8000 */ + {0x005E8000, 0, 0, 0, 0x000002D2}, /* 94.5000 */ + {0x00630000, 0, 1, 0, 0x00000B4A}, /* 99.0000 */ + {0x00640000, 0, 1, 0, 0x00000036}, /* 100.0000 */ + {0x006C0000, 0, 0, 0, 0x000007E2}, /* 108.0000 */ + {0x00708000, 0, 0, 0, 0x000007F6}, /* 112.5000 */ + {0x00820000, 1, 1, 0, 0x00000FB0}, /* 130.0000 */ + {0x00870000, 1, 1, 0, 0x00000B50}, /* 135.0000 */ + {0x009D8000, 0, 0, 0, 0x00000055}, /* 157.5000 */ + {0x00A20000, 0, 0, 0, 0x000009C1}, /* 162.0000 */ + {0x00AF8000, 0, 0, 0, 0x000002C1}, /* 175.5000 */ + {0x00BD0000, 0, 0, 0, 0x000002D1}, /* 189.0000 */ + {0x00CA8000, 0, 0, 0, 0x00000551}, /* 202.5000 */ + {0x00E58000, 0, 0, 0, 0x0000057D}, /* 229.5000 */ }; RCDFPLLENTRY RCDF_PLLtable14MHz[] = { - {0x00192CCC, 0, 0, 0, 0x00000037}, /* 25.1750 */ - {0x001C526E, 0, 0, 0, 0x00000B7B}, /* 28.3220 */ - {0x001F8000, 0, 0, 0, 0x000004D3}, /* 31.5000 */ - {0x00240000, 0, 0, 0, 0x00000BE3}, /* 36.0000 */ - {0x00258000, 0, 0, 0, 0x0000074F}, /* 37.5000 */ - {0x00280000, 0, 0, 0, 0x0000050B}, /* 40.0000 */ - {0x002CE666, 0, 0, 0, 0x00000063}, /* 44.9000 */ - {0x00318000, 0, 0, 0, 0x0000054B}, /* 49.5000 */ - {0x00320000, 0, 0, 0, 0x0000026E}, /* 50.0000 */ - {0x00325999, 0, 0, 0, 0x000007C3}, /* 50.3500 */ - {0x00360000, 0, 0, 0, 0x000007E3}, /* 54.0000 */ - {0x00384000, 0, 0, 0, 0x00000577}, /* 56.2500 */ - {0x0038643F, 0, 0, 0, 0x000002FB}, /* 56.3916 */ - {0x0038A4DD, 0, 0, 0, 0x0000057B}, /* 56.6444 */ - {0x003B0000, 0, 0, 0, 0x0000058B}, /* 59.0000 */ - {0x003F0000, 0, 0, 0, 0x0000095E}, /* 63.0000 */ - {0x00410000, 0, 0, 0, 0x0000096A}, /* 65.0000 */ - {0x00438000, 0, 0, 0, 0x00000BC2}, /* 67.5000 */ - {0x0046CCCC, 0, 0, 0, 0x0000098A}, /* 70.8000 */ - {0x00480000, 0, 0, 0, 0x00000BE2}, /* 72.0000 */ - {0x004B0000, 0, 0, 0, 0x00000052}, /* 75.0000 */ - {0x004EC000, 0, 0, 0, 0x00000056}, /* 78.7500 */ - {0x00500000, 0, 0, 0, 0x0000050A}, /* 80.0000 */ - {0x0059CCCC, 0, 0, 0, 0x0000078E}, /* 89.8000 */ - {0x005E8000, 0, 0, 0, 0x000002D2}, /* 94.5000 */ - {0x00630000, 0, 0, 0, 0x000011F6}, /* 99.0000 */ - {0x00640000, 0, 0, 0, 0x0000054E}, /* 100.0000 */ - {0x006C0000, 0, 0, 0, 0x000007E2}, /* 108.0000 */ - {0x00708000, 0, 0, 0, 0x000002FA}, /* 112.5000 */ - {0x00820000, 0, 0, 0, 0x00000BB1}, /* 130.0000 */ - {0x00870000, 0, 0, 0, 0x00000975}, /* 135.0000 */ - {0x009D8000, 0, 0, 0, 0x00000055}, /* 157.5000 */ - {0x00A20000, 0, 0, 0, 0x000009C1}, /* 162.0000 */ - {0x00AF8000, 0, 0, 0, 0x000002C1}, /* 175.5000 */ - {0x00BD0000, 0, 0, 0, 0x00000539}, /* 189.0000 */ - {0x00CA8000, 0, 0, 0, 0x00000551}, /* 202.5000 */ - {0x00E58000, 0, 0, 0, 0x0000057D}, /* 229.5000 */ + {0x00192CCC, 0, 0, 0, 0x00000037}, /* 25.1750 */ + {0x001C526E, 0, 0, 0, 0x00000B7B}, /* 28.3220 */ + {0x001F8000, 0, 0, 0, 0x000004D3}, /* 31.5000 */ + {0x00240000, 0, 0, 0, 0x00000BE3}, /* 36.0000 */ + {0x00258000, 0, 0, 0, 0x0000074F}, /* 37.5000 */ + {0x00280000, 0, 0, 0, 0x0000050B}, /* 40.0000 */ + {0x002CE666, 0, 0, 0, 0x00000063}, /* 44.9000 */ + {0x00318000, 0, 0, 0, 0x0000054B}, /* 49.5000 */ + {0x00320000, 0, 0, 0, 0x0000026E}, /* 50.0000 */ + {0x00325999, 0, 0, 0, 0x000007C3}, /* 50.3500 */ + {0x00360000, 0, 0, 0, 0x000007E3}, /* 54.0000 */ + {0x00384000, 0, 0, 0, 0x00000577}, /* 56.2500 */ + {0x0038643F, 0, 0, 0, 0x000002FB}, /* 56.3916 */ + {0x0038A4DD, 0, 0, 0, 0x0000057B}, /* 56.6444 */ + {0x003B0000, 0, 0, 0, 0x0000058B}, /* 59.0000 */ + {0x003F0000, 0, 0, 0, 0x0000095E}, /* 63.0000 */ + {0x00410000, 0, 0, 0, 0x0000096A}, /* 65.0000 */ + {0x00438000, 0, 0, 0, 0x00000BC2}, /* 67.5000 */ + {0x0046CCCC, 0, 0, 0, 0x0000098A}, /* 70.8000 */ + {0x00480000, 0, 0, 0, 0x00000BE2}, /* 72.0000 */ + {0x004B0000, 0, 0, 0, 0x00000052}, /* 75.0000 */ + {0x004EC000, 0, 0, 0, 0x00000056}, /* 78.7500 */ + {0x00500000, 0, 0, 0, 0x0000050A}, /* 80.0000 */ + {0x0059CCCC, 0, 0, 0, 0x0000078E}, /* 89.8000 */ + {0x005E8000, 0, 0, 0, 0x000002D2}, /* 94.5000 */ + {0x00630000, 0, 0, 0, 0x000011F6}, /* 99.0000 */ + {0x00640000, 0, 0, 0, 0x0000054E}, /* 100.0000 */ + {0x006C0000, 0, 0, 0, 0x000007E2}, /* 108.0000 */ + {0x00708000, 0, 0, 0, 0x000002FA}, /* 112.5000 */ + {0x00820000, 0, 0, 0, 0x00000BB1}, /* 130.0000 */ + {0x00870000, 0, 0, 0, 0x00000975}, /* 135.0000 */ + {0x009D8000, 0, 0, 0, 0x00000055}, /* 157.5000 */ + {0x00A20000, 0, 0, 0, 0x000009C1}, /* 162.0000 */ + {0x00AF8000, 0, 0, 0, 0x000002C1}, /* 175.5000 */ + {0x00BD0000, 0, 0, 0, 0x00000539}, /* 189.0000 */ + {0x00CA8000, 0, 0, 0, 0x00000551}, /* 202.5000 */ + {0x00E58000, 0, 0, 0, 0x0000057D}, /* 229.5000 */ }; #define NUM_RCDF_FREQUENCIES sizeof(RCDF_PLLtable14MHz)/sizeof(RCDFPLLENTRY) @@ -228,30 +226,28 @@ int redcloud_set_video_size(unsigned short width, unsigned short height); int redcloud_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch); int redcloud_set_video_offset(unsigned long offset); int redcloud_set_video_yuv_offsets(unsigned long yoffset, - unsigned long uoffset, - unsigned long voffset); + unsigned long uoffset, + unsigned long voffset); int redcloud_set_video_window(short x, short y, unsigned short w, - unsigned short h); + unsigned short h); int redcloud_set_video_left_crop(unsigned short x); int redcloud_set_video_upscale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); + unsigned short dstw, unsigned short dsth); int redcloud_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth); + unsigned short dstw, unsigned short dsth); int redcloud_set_video_vertical_downscale(unsigned short srch, - unsigned short dsth); + unsigned short dsth); void redcloud_set_video_vertical_downscale_enable(int enable); -int redcloud_set_video_downscale_config(unsigned short type, - unsigned short m); +int redcloud_set_video_downscale_config(unsigned short type, unsigned short m); int redcloud_set_video_color_key(unsigned long key, unsigned long mask, - int bluescreen); + int bluescreen); int redcloud_set_video_filter(int xfilter, int yfilter); int redcloud_set_video_palette(unsigned long *palette); -int redcloud_set_video_palette_entry(unsigned long index, - unsigned long color); +int redcloud_set_video_palette_entry(unsigned long index, unsigned long color); int redcloud_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4); + unsigned short coef2, + unsigned short coef3, + unsigned short coef4); int redcloud_set_video_downscale_enable(int enable); int redcloud_set_video_source(VideoSourceType source); int redcloud_set_vbi_source(VbiSourceType source); @@ -264,15 +260,15 @@ int redcloud_set_top_line_in_odd(int enable); int redcloud_set_genlock_delay(unsigned long delay); int redcloud_set_genlock_enable(int flags); int redcloud_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, - unsigned long color1, unsigned long color2); + unsigned short select_color2, + unsigned long color1, unsigned long color2); int redcloud_set_video_cursor_enable(int enable); int redcloud_set_video_request(short x, short y); int redcloud_select_alpha_region(int region); int redcloud_set_alpha_enable(int enable); int redcloud_set_alpha_window(short x, short y, - unsigned short width, unsigned short height); + unsigned short width, unsigned short height); int redcloud_set_alpha_value(unsigned char alpha, char delta); int redcloud_set_alpha_priority(int priority); int redcloud_set_alpha_color(unsigned long color); @@ -295,27 +291,27 @@ unsigned long redcloud_get_video_line_size(void); unsigned long redcloud_get_video_xclip(void); unsigned long redcloud_get_video_offset(void); void redcloud_get_video_yuv_offsets(unsigned long *yoffset, - unsigned long *uoffset, - unsigned long *voffset); + unsigned long *uoffset, + unsigned long *voffset); void redcloud_get_video_yuv_pitch(unsigned long *ypitch, - unsigned long *uvpitch); + unsigned long *uvpitch); unsigned long redcloud_get_video_upscale(void); unsigned long redcloud_get_video_scale(void); unsigned long redcloud_get_video_downscale_delta(void); int redcloud_get_video_vertical_downscale_enable(void); int redcloud_get_video_downscale_config(unsigned short *type, - unsigned short *m); + unsigned short *m); void redcloud_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4); + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4); void redcloud_get_video_downscale_enable(int *enable); unsigned long redcloud_get_video_dst_size(void); unsigned long redcloud_get_video_position(void); unsigned long redcloud_get_video_color_key(void); unsigned long redcloud_get_video_color_key_mask(void); int redcloud_get_video_palette_entry(unsigned long index, - unsigned long *palette); + unsigned long *palette); int redcloud_get_video_color_key_src(void); int redcloud_get_video_filter(void); int redcloud_get_video_request(short *x, short *y); @@ -329,18 +325,18 @@ int redcloud_get_vertical_scaler_offset(char *offset); unsigned long redcloud_get_genlock_delay(void); int redcloud_get_genlock_enable(void); int redcloud_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, - unsigned long *color1, unsigned short *color2); + unsigned short *select_color2, + unsigned long *color1, unsigned short *color2); unsigned long redcloud_read_crc(void); unsigned long redcloud_read_crc32(void); unsigned long redcloud_read_window_crc(int source, unsigned short x, - unsigned short y, unsigned short width, - unsigned short height, int crc32); + unsigned short y, unsigned short width, + unsigned short height, int crc32); int redcloud_get_macrovision_enable(void); void redcloud_get_alpha_enable(int *enable); void redcloud_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height); + unsigned short *width, unsigned short *height); void redcloud_get_alpha_value(unsigned char *alpha, char *delta); void redcloud_get_alpha_priority(int *priority); void redcloud_get_alpha_color(unsigned long *color); @@ -362,16 +358,16 @@ void gfx_reset_video(void) #endif { - gfx_set_video_enable(0); - gfx_select_alpha_region(1); - gfx_set_alpha_enable(0); - gfx_select_alpha_region(2); - gfx_set_alpha_enable(0); + gfx_set_video_enable(0); + gfx_select_alpha_region(1); + gfx_set_alpha_enable(0); + gfx_select_alpha_region(2); + gfx_set_alpha_enable(0); - /* SET REGION 0 AFTER RESET */ + /* SET REGION 0 AFTER RESET */ - gfx_select_alpha_region(0); - gfx_set_alpha_enable(0); + gfx_select_alpha_region(0); + gfx_set_alpha_enable(0); } /*----------------------------------------------------------------------------- @@ -397,35 +393,35 @@ int gfx_set_display_control(int sync_polarities) #endif { - unsigned long power; - unsigned long dcfg; + unsigned long power; + unsigned long dcfg; - /* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */ + /* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */ - dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); - dcfg &= ~(RCDF_DCFG_CRT_SYNC_SKW_MASK | RCDF_DCFG_PWR_SEQ_DLY_MASK | - RCDF_DCFG_CRT_HSYNC_POL | RCDF_DCFG_CRT_VSYNC_POL | - RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); + dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); + dcfg &= ~(RCDF_DCFG_CRT_SYNC_SKW_MASK | RCDF_DCFG_PWR_SEQ_DLY_MASK | + RCDF_DCFG_CRT_HSYNC_POL | RCDF_DCFG_CRT_VSYNC_POL | + RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); - dcfg |= (RCDF_DCFG_CRT_SYNC_SKW_INIT | - RCDF_DCFG_PWR_SEQ_DLY_INIT | RCDF_DCFG_GV_PAL_BYP); + dcfg |= (RCDF_DCFG_CRT_SYNC_SKW_INIT | + RCDF_DCFG_PWR_SEQ_DLY_INIT | RCDF_DCFG_GV_PAL_BYP); - if (PanelEnable) { - power = READ_VID32(RCDF_POWER_MANAGEMENT); - power |= RCDF_PM_PANEL_POWER_ON; - WRITE_VID32(RCDF_POWER_MANAGEMENT, power); - } + if (PanelEnable) { + power = READ_VID32(RCDF_POWER_MANAGEMENT); + power |= RCDF_PM_PANEL_POWER_ON; + WRITE_VID32(RCDF_POWER_MANAGEMENT, power); + } - /* SET APPROPRIATE SYNC POLARITIES */ + /* SET APPROPRIATE SYNC POLARITIES */ - if (sync_polarities & 0x1) - dcfg |= RCDF_DCFG_CRT_HSYNC_POL; - if (sync_polarities & 0x2) - dcfg |= RCDF_DCFG_CRT_VSYNC_POL; + if (sync_polarities & 0x1) + dcfg |= RCDF_DCFG_CRT_HSYNC_POL; + if (sync_polarities & 0x2) + dcfg |= RCDF_DCFG_CRT_VSYNC_POL; - WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); + WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -444,76 +440,76 @@ void gfx_set_clock_frequency(unsigned long frequency) #endif { - Q_WORD msr_value; - unsigned int i, index = 0; - unsigned long value; - long timeout = 1000; - long min, diff; - RCDFPLLENTRY *PllTable; - - /* READ PLL REFERENCE FREQUENCY */ - /* The reference frequency of GX2 1.x is different from 2.x and above. */ - - if ((gfx_cpu_version & 0xFF00) >= 0x0200) - PllTable = RCDF_PLLtable48MHz; - else - PllTable = RCDF_PLLtable14MHz; - - /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ - /* Search the table for the closest frequency (16.16 format). */ - - value = PllTable[0].pll_value; - min = (long)PllTable[0].frequency - frequency; - if (min < 0L) - min = -min; - for (i = 1; i < NUM_RCDF_FREQUENCIES; i++) { - diff = (long)PllTable[i].frequency - frequency; - if (diff < 0L) - diff = -diff; - if (diff < min) { - min = diff; - index = i; - } - } - - /* PROGRAM THE SETTINGS WITH THE RESET BIT SET */ - /* Clear the bypass bit to ensure that the programmed */ - /* M, N and P values are being used. */ - - gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value); - msr_value.high = PllTable[index].pll_value; - msr_value.low |= 0x00000001; - msr_value.low &= ~MCP_DOTPLL_BYPASS; - gfx_msr_write(RC_ID_MCP, MCP_DOTPLL, &msr_value); - - /* PROGRAM THE MCP DIVIDER VALUES */ - - gfx_msr_read(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value); - if (PllTable[index].post_div3) - msr_value.low |= MCP_DOTPOSTDIV3; - else - msr_value.low &= ~MCP_DOTPOSTDIV3; - if (PllTable[index].pre_div2) - msr_value.low |= MCP_DOTPREDIV2; - else - msr_value.low &= ~MCP_DOTPREDIV2; - if (PllTable[index].pre_mul2) - msr_value.low |= MCP_DOTPREMULT2; - else - msr_value.low &= ~MCP_DOTPREMULT2; - gfx_msr_write(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value); - - /* CLEAR THE RESET BIT */ - - gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value); - msr_value.low &= 0xFFFFFFFE; - gfx_msr_write(RC_ID_MCP, MCP_DOTPLL, &msr_value); - - /* WAIT FOR LOCK BIT */ - - do { - gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value); - } while (timeout-- && !(msr_value.low & MCP_DOTPLL_LOCK)); + Q_WORD msr_value; + unsigned int i, index = 0; + unsigned long value; + long timeout = 1000; + long min, diff; + RCDFPLLENTRY *PllTable; + + /* READ PLL REFERENCE FREQUENCY */ + /* The reference frequency of GX2 1.x is different from 2.x and above. */ + + if ((gfx_cpu_version & 0xFF00) >= 0x0200) + PllTable = RCDF_PLLtable48MHz; + else + PllTable = RCDF_PLLtable14MHz; + + /* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */ + /* Search the table for the closest frequency (16.16 format). */ + + value = PllTable[0].pll_value; + min = (long) PllTable[0].frequency - frequency; + if (min < 0L) + min = -min; + for (i = 1; i < NUM_RCDF_FREQUENCIES; i++) { + diff = (long) PllTable[i].frequency - frequency; + if (diff < 0L) + diff = -diff; + if (diff < min) { + min = diff; + index = i; + } + } + + /* PROGRAM THE SETTINGS WITH THE RESET BIT SET */ + /* Clear the bypass bit to ensure that the programmed */ + /* M, N and P values are being used. */ + + gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value); + msr_value.high = PllTable[index].pll_value; + msr_value.low |= 0x00000001; + msr_value.low &= ~MCP_DOTPLL_BYPASS; + gfx_msr_write(RC_ID_MCP, MCP_DOTPLL, &msr_value); + + /* PROGRAM THE MCP DIVIDER VALUES */ + + gfx_msr_read(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value); + if (PllTable[index].post_div3) + msr_value.low |= MCP_DOTPOSTDIV3; + else + msr_value.low &= ~MCP_DOTPOSTDIV3; + if (PllTable[index].pre_div2) + msr_value.low |= MCP_DOTPREDIV2; + else + msr_value.low &= ~MCP_DOTPREDIV2; + if (PllTable[index].pre_mul2) + msr_value.low |= MCP_DOTPREMULT2; + else + msr_value.low &= ~MCP_DOTPREMULT2; + gfx_msr_write(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value); + + /* CLEAR THE RESET BIT */ + + gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value); + msr_value.low &= 0xFFFFFFFE; + gfx_msr_write(RC_ID_MCP, MCP_DOTPLL, &msr_value); + + /* WAIT FOR LOCK BIT */ + + do { + gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value); + } while (timeout-- && !(msr_value.low & MCP_DOTPLL_LOCK)); } /*--------------------------------------------------------------------------- @@ -530,51 +526,51 @@ int gfx_set_crt_enable(int enable) #endif { - unsigned long config, misc; + unsigned long config, misc; - config = READ_VID32(RCDF_DISPLAY_CONFIG); - misc = READ_VID32(RCDF_VID_MISC); + config = READ_VID32(RCDF_DISPLAY_CONFIG); + misc = READ_VID32(RCDF_VID_MISC); - switch (enable) { - case CRT_DISABLE: /* DISABLE EVERYTHING */ + switch (enable) { + case CRT_DISABLE: /* DISABLE EVERYTHING */ - WRITE_VID32(RCDF_DISPLAY_CONFIG, - config & ~(RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN | - RCDF_DCFG_VSYNC_EN | RCDF_DCFG_DAC_BL_EN)); - WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN); - break; + WRITE_VID32(RCDF_DISPLAY_CONFIG, + config & ~(RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN | + RCDF_DCFG_VSYNC_EN | RCDF_DCFG_DAC_BL_EN)); + WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN); + break; - case CRT_ENABLE: /* ENABLE CRT DISPLAY, INCLUDING DISPLAY LOGIC */ + case CRT_ENABLE: /* ENABLE CRT DISPLAY, INCLUDING DISPLAY LOGIC */ - WRITE_VID32(RCDF_DISPLAY_CONFIG, - config | RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN | - RCDF_DCFG_VSYNC_EN | RCDF_DCFG_DAC_BL_EN); - WRITE_VID32(RCDF_VID_MISC, - misc & ~RCDF_DAC_POWER_DOWN & ~RCDF_ANALOG_POWER_DOWN); - break; + WRITE_VID32(RCDF_DISPLAY_CONFIG, + config | RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN | + RCDF_DCFG_VSYNC_EN | RCDF_DCFG_DAC_BL_EN); + WRITE_VID32(RCDF_VID_MISC, + misc & ~RCDF_DAC_POWER_DOWN & ~RCDF_ANALOG_POWER_DOWN); + break; - case CRT_STANDBY: /* HSYNC:OFF VSYNC:ON */ + case CRT_STANDBY: /* HSYNC:OFF VSYNC:ON */ - WRITE_VID32(RCDF_DISPLAY_CONFIG, - (config & - ~(RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN | - RCDF_DCFG_DAC_BL_EN)) | RCDF_DCFG_VSYNC_EN); - WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN); - break; + WRITE_VID32(RCDF_DISPLAY_CONFIG, + (config & + ~(RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN | + RCDF_DCFG_DAC_BL_EN)) | RCDF_DCFG_VSYNC_EN); + WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN); + break; - case CRT_SUSPEND: /* HSYNC:ON VSYNC:OFF */ + case CRT_SUSPEND: /* HSYNC:ON VSYNC:OFF */ - WRITE_VID32(RCDF_DISPLAY_CONFIG, - (config & - ~(RCDF_DCFG_DIS_EN | RCDF_DCFG_VSYNC_EN | - RCDF_DCFG_DAC_BL_EN)) | RCDF_DCFG_HSYNC_EN); - WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN); - break; + WRITE_VID32(RCDF_DISPLAY_CONFIG, + (config & + ~(RCDF_DCFG_DIS_EN | RCDF_DCFG_VSYNC_EN | + RCDF_DCFG_DAC_BL_EN)) | RCDF_DCFG_HSYNC_EN); + WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN); + break; - default: - return (GFX_STATUS_BAD_PARAMETER); - } - return (GFX_STATUS_OK); + default: + return (GFX_STATUS_BAD_PARAMETER); + } + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -591,41 +587,42 @@ int gfx_set_video_enable(int enable) #endif { - unsigned long vcfg; + unsigned long vcfg; - /* WAIT FOR VERTICAL BLANK TO START */ - /* Otherwise a glitch can be observed. */ + /* WAIT FOR VERTICAL BLANK TO START */ + /* Otherwise a glitch can be observed. */ - if (gfx_test_timing_active()) { - if (!gfx_test_vertical_active()) { - while (!gfx_test_vertical_active()) ; - } - while (gfx_test_vertical_active()) ; - } + if (gfx_test_timing_active()) { + if (!gfx_test_vertical_active()) { + while (!gfx_test_vertical_active()); + } + while (gfx_test_vertical_active()); + } - vcfg = READ_VID32(RCDF_VIDEO_CONFIG); - if (enable) { - /* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + vcfg = READ_VID32(RCDF_VIDEO_CONFIG); + if (enable) { + /* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_enable(1); + gfx_set_display_video_enable(1); - /* ENABLE DISPLAY FILTER VIDEO OVERLAY */ + /* ENABLE DISPLAY FILTER VIDEO OVERLAY */ - vcfg |= RCDF_VCFG_VID_EN; - WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); - } else { - /* DISABLE DISPLAY FILTER VIDEO OVERLAY */ + vcfg |= RCDF_VCFG_VID_EN; + WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); + } + else { + /* DISABLE DISPLAY FILTER VIDEO OVERLAY */ - vcfg &= ~RCDF_VCFG_VID_EN; - WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); + vcfg &= ~RCDF_VCFG_VID_EN; + WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); - /* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_enable(0); - } - return (0); + gfx_set_display_video_enable(0); + } + return (0); } /*----------------------------------------------------------------------------- @@ -642,78 +639,78 @@ int gfx_set_video_format(unsigned long format) #endif { - unsigned long ctrl, vcfg = 0; - - /* SET THE DISPLAY FILTER VIDEO INPUT FORMAT */ - - vcfg = READ_VID32(RCDF_VIDEO_CONFIG); - ctrl = READ_VID32(RCDF_VID_ALPHA_CONTROL); - ctrl &= ~(RCDF_VIDEO_INPUT_IS_RGB | RCDF_CSC_VIDEO_YUV_TO_RGB); - vcfg &= ~(RCDF_VCFG_VID_INP_FORMAT | RCDF_VCFG_4_2_0_MODE); - switch (format) { - case VIDEO_FORMAT_UYVY: - vcfg |= RCDF_VCFG_UYVY_FORMAT; - ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; - break; - case VIDEO_FORMAT_YUYV: - vcfg |= RCDF_VCFG_YUYV_FORMAT; - ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; - break; - case VIDEO_FORMAT_Y2YU: - vcfg |= RCDF_VCFG_Y2YU_FORMAT; - ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; - break; - case VIDEO_FORMAT_YVYU: - vcfg |= RCDF_VCFG_YVYU_FORMAT; - ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; - break; - case VIDEO_FORMAT_Y0Y1Y2Y3: - vcfg |= RCDF_VCFG_UYVY_FORMAT; - ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; - vcfg |= RCDF_VCFG_4_2_0_MODE; - break; - case VIDEO_FORMAT_Y3Y2Y1Y0: - vcfg |= RCDF_VCFG_Y2YU_FORMAT; - ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; - vcfg |= RCDF_VCFG_4_2_0_MODE; - break; - case VIDEO_FORMAT_Y1Y0Y3Y2: - vcfg |= RCDF_VCFG_YUYV_FORMAT; - ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; - vcfg |= RCDF_VCFG_4_2_0_MODE; - break; - case VIDEO_FORMAT_Y1Y2Y3Y0: - vcfg |= RCDF_VCFG_YVYU_FORMAT; - ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; - vcfg |= RCDF_VCFG_4_2_0_MODE; - break; - case VIDEO_FORMAT_RGB: - ctrl |= RCDF_VIDEO_INPUT_IS_RGB; - vcfg |= RCDF_VCFG_UYVY_FORMAT; - break; - case VIDEO_FORMAT_P2M_P2L_P1M_P1L: - ctrl |= RCDF_VIDEO_INPUT_IS_RGB; - vcfg |= RCDF_VCFG_Y2YU_FORMAT; - break; - case VIDEO_FORMAT_P1M_P1L_P2M_P2L: - ctrl |= RCDF_VIDEO_INPUT_IS_RGB; - vcfg |= RCDF_VCFG_YUYV_FORMAT; - break; - case VIDEO_FORMAT_P1M_P2L_P2M_P1L: - ctrl |= RCDF_VIDEO_INPUT_IS_RGB; - vcfg |= RCDF_VCFG_YVYU_FORMAT; - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); - WRITE_VID32(RCDF_VID_ALPHA_CONTROL, ctrl); - - /* SET THE VIDEO FORMAT IN THE DISPLAY CONTROLLER */ - /* Use private routine to abstract display controller. */ - - gfx_set_display_video_format(format); - return (0); + unsigned long ctrl, vcfg = 0; + + /* SET THE DISPLAY FILTER VIDEO INPUT FORMAT */ + + vcfg = READ_VID32(RCDF_VIDEO_CONFIG); + ctrl = READ_VID32(RCDF_VID_ALPHA_CONTROL); + ctrl &= ~(RCDF_VIDEO_INPUT_IS_RGB | RCDF_CSC_VIDEO_YUV_TO_RGB); + vcfg &= ~(RCDF_VCFG_VID_INP_FORMAT | RCDF_VCFG_4_2_0_MODE); + switch (format) { + case VIDEO_FORMAT_UYVY: + vcfg |= RCDF_VCFG_UYVY_FORMAT; + ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; + break; + case VIDEO_FORMAT_YUYV: + vcfg |= RCDF_VCFG_YUYV_FORMAT; + ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; + break; + case VIDEO_FORMAT_Y2YU: + vcfg |= RCDF_VCFG_Y2YU_FORMAT; + ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; + break; + case VIDEO_FORMAT_YVYU: + vcfg |= RCDF_VCFG_YVYU_FORMAT; + ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; + break; + case VIDEO_FORMAT_Y0Y1Y2Y3: + vcfg |= RCDF_VCFG_UYVY_FORMAT; + ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; + vcfg |= RCDF_VCFG_4_2_0_MODE; + break; + case VIDEO_FORMAT_Y3Y2Y1Y0: + vcfg |= RCDF_VCFG_Y2YU_FORMAT; + ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; + vcfg |= RCDF_VCFG_4_2_0_MODE; + break; + case VIDEO_FORMAT_Y1Y0Y3Y2: + vcfg |= RCDF_VCFG_YUYV_FORMAT; + ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; + vcfg |= RCDF_VCFG_4_2_0_MODE; + break; + case VIDEO_FORMAT_Y1Y2Y3Y0: + vcfg |= RCDF_VCFG_YVYU_FORMAT; + ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB; + vcfg |= RCDF_VCFG_4_2_0_MODE; + break; + case VIDEO_FORMAT_RGB: + ctrl |= RCDF_VIDEO_INPUT_IS_RGB; + vcfg |= RCDF_VCFG_UYVY_FORMAT; + break; + case VIDEO_FORMAT_P2M_P2L_P1M_P1L: + ctrl |= RCDF_VIDEO_INPUT_IS_RGB; + vcfg |= RCDF_VCFG_Y2YU_FORMAT; + break; + case VIDEO_FORMAT_P1M_P1L_P2M_P2L: + ctrl |= RCDF_VIDEO_INPUT_IS_RGB; + vcfg |= RCDF_VCFG_YUYV_FORMAT; + break; + case VIDEO_FORMAT_P1M_P2L_P2M_P1L: + ctrl |= RCDF_VIDEO_INPUT_IS_RGB; + vcfg |= RCDF_VCFG_YVYU_FORMAT; + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); + WRITE_VID32(RCDF_VID_ALPHA_CONTROL, ctrl); + + /* SET THE VIDEO FORMAT IN THE DISPLAY CONTROLLER */ + /* Use private routine to abstract display controller. */ + + gfx_set_display_video_format(format); + return (0); } /*----------------------------------------------------------------------------- @@ -732,44 +729,44 @@ int gfx_set_video_size(unsigned short width, unsigned short height) #endif { - unsigned long size, vcfg, vid_420, pitch; + unsigned long size, vcfg, vid_420, pitch; - /* SET THE DISPLAY FILTER VIDEO LINE SIZE */ - /* Match the DC hardware alignment requirement. The line size must */ - /* always be 32-byte aligned. However, we can manage smaller */ - /* alignments by decreasing the pitch and clipping the video window. */ - /* The VG will fetch extra data for each line, but the decreased */ - /* pitch will ensure that it always begins fetching at the start of */ - /* the video line. */ + /* SET THE DISPLAY FILTER VIDEO LINE SIZE */ + /* Match the DC hardware alignment requirement. The line size must */ + /* always be 32-byte aligned. However, we can manage smaller */ + /* alignments by decreasing the pitch and clipping the video window. */ + /* The VG will fetch extra data for each line, but the decreased */ + /* pitch will ensure that it always begins fetching at the start of */ + /* the video line. */ - vcfg = READ_VID32(RCDF_VIDEO_CONFIG); + vcfg = READ_VID32(RCDF_VIDEO_CONFIG); - vid_420 = vcfg & RCDF_VCFG_4_2_0_MODE; + vid_420 = vcfg & RCDF_VCFG_4_2_0_MODE; - vcfg &= ~(RCDF_VCFG_LINE_SIZE_LOWER_MASK | RCDF_VCFG_LINE_SIZE_UPPER); + vcfg &= ~(RCDF_VCFG_LINE_SIZE_LOWER_MASK | RCDF_VCFG_LINE_SIZE_UPPER); - size = ((width >> 1) + 7) & 0xFFF8; - pitch = ((width << 1) + 7) & 0xFFF8; + size = ((width >> 1) + 7) & 0xFFF8; + pitch = ((width << 1) + 7) & 0xFFF8; - vcfg |= (size & 0x00FF) << 8; - if (size & 0x0100) - vcfg |= RCDF_VCFG_LINE_SIZE_UPPER; - WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); + vcfg |= (size & 0x00FF) << 8; + if (size & 0x0100) + vcfg |= RCDF_VCFG_LINE_SIZE_UPPER; + WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); - /* SET VIDEO BUFFER LINE SIZE IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET VIDEO BUFFER LINE SIZE IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_size(width, height); + gfx_set_display_video_size(width, height); - /* SET VIDEO PITCH */ - /* We are only maintaining legacy for 4:2:2 video formats. */ - /* 4:2:0 video in previous chips was inadequate for most */ - /* common video formats. */ + /* SET VIDEO PITCH */ + /* We are only maintaining legacy for 4:2:2 video formats. */ + /* 4:2:0 video in previous chips was inadequate for most */ + /* common video formats. */ - if (!vid_420) - gfx_set_video_yuv_pitch(pitch, pitch << 1); + if (!vid_420) + gfx_set_video_yuv_pitch(pitch, pitch << 1); - return (0); + return (0); } /*----------------------------------------------------------------------------- @@ -787,15 +784,15 @@ int gfx_set_video_offset(unsigned long offset) #endif { - /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ + /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ - gfx_vid_offset = offset; + gfx_vid_offset = offset; - /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_offset(offset); - return (0); + gfx_set_display_video_offset(offset); + return (0); } /*----------------------------------------------------------------------------- @@ -808,25 +805,25 @@ gfx_set_video_offset(unsigned long offset) #if GFX_VIDEO_DYNAMIC int redcloud_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset, - unsigned long voffset) + unsigned long voffset) #else int gfx_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset, - unsigned long voffset) + unsigned long voffset) #endif { - /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ + /* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */ - gfx_vid_offset = yoffset; - gfx_vid_uoffset = uoffset; - gfx_vid_voffset = voffset; + gfx_vid_offset = yoffset; + gfx_vid_uoffset = uoffset; + gfx_vid_voffset = voffset; - /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_yuv_offsets(yoffset, uoffset, voffset); + gfx_set_display_video_yuv_offsets(yoffset, uoffset, voffset); - return (0); + return (0); } /*----------------------------------------------------------------------------- @@ -843,12 +840,12 @@ int gfx_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch) #endif { - /* SET VIDEO PITCH IN DISPLAY CONTROLLER */ - /* Use private routine to abstract the display controller. */ + /* SET VIDEO PITCH IN DISPLAY CONTROLLER */ + /* Use private routine to abstract the display controller. */ - gfx_set_display_video_yuv_pitch(ypitch, uvpitch); + gfx_set_display_video_yuv_pitch(ypitch, uvpitch); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -861,59 +858,59 @@ gfx_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch) #if GFX_VIDEO_DYNAMIC int redcloud_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #else int gfx_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) #endif { - unsigned long xscale, yscale; + unsigned long xscale, yscale; - /* SAVE PARAMETERS (unless don't-care zero destination arguments are used) */ - /* These are needed for clipping the video window later. */ + /* SAVE PARAMETERS (unless don't-care zero destination arguments are used) */ + /* These are needed for clipping the video window later. */ - if (dstw != 0) { - gfx_vid_srcw = srcw; - gfx_vid_dstw = dstw; - } - if (dsth != 0) { - gfx_vid_srch = srch; - gfx_vid_dsth = dsth; - } + if (dstw != 0) { + gfx_vid_srcw = srcw; + gfx_vid_dstw = dstw; + } + if (dsth != 0) { + gfx_vid_srch = srch; + gfx_vid_dsth = dsth; + } - /* CALCULATE DISPLAY FILTER SCALE FACTORS */ - /* Zero width and height indicate don't care conditions */ - /* Downscaling is performed in a separate function. */ + /* CALCULATE DISPLAY FILTER SCALE FACTORS */ + /* Zero width and height indicate don't care conditions */ + /* Downscaling is performed in a separate function. */ - if (dstw == 0) - xscale = READ_VID32(RCDF_VIDEO_SCALE) & 0xffff; /* keep previous if don't-care argument */ - else if (dstw <= srcw) - xscale = 0x2000; /* horizontal downscaling is currently done in a separate function */ - else if ((srcw == 1) || (dstw == 1)) - return GFX_STATUS_BAD_PARAMETER; - else - xscale = (0x2000l * (srcw - 1l)) / (dstw - 1l); + if (dstw == 0) + xscale = READ_VID32(RCDF_VIDEO_SCALE) & 0xffff; /* keep previous if don't-care argument */ + else if (dstw <= srcw) + xscale = 0x2000; /* horizontal downscaling is currently done in a separate function */ + else if ((srcw == 1) || (dstw == 1)) + return GFX_STATUS_BAD_PARAMETER; + else + xscale = (0x2000l * (srcw - 1l)) / (dstw - 1l); - if (dsth == 0) - yscale = (READ_VID32(RCDF_VIDEO_SCALE) & 0xffff0000) >> 16; /* keep previous if don't-care argument */ - else if (dsth <= srch) - yscale = 0x2000; /* vertical downscaling is handled in a separate function */ - else if ((srch == 1) || (dsth == 1)) - return GFX_STATUS_BAD_PARAMETER; - else - yscale = (0x2000l * (srch - 1l)) / (dsth - 1l); + if (dsth == 0) + yscale = (READ_VID32(RCDF_VIDEO_SCALE) & 0xffff0000) >> 16; /* keep previous if don't-care argument */ + else if (dsth <= srch) + yscale = 0x2000; /* vertical downscaling is handled in a separate function */ + else if ((srch == 1) || (dsth == 1)) + return GFX_STATUS_BAD_PARAMETER; + else + yscale = (0x2000l * (srch - 1l)) / (dsth - 1l); - WRITE_VID32(RCDF_VIDEO_SCALE, (yscale << 16) | xscale); + WRITE_VID32(RCDF_VIDEO_SCALE, (yscale << 16) | xscale); - /* CALL ROUTINE TO UPDATE WINDOW POSITION */ - /* This is required because the scale values affect the number of */ - /* source data pixels that need to be clipped, as well as the */ - /* amount of data that needs to be transferred. */ + /* CALL ROUTINE TO UPDATE WINDOW POSITION */ + /* This is required because the scale values affect the number of */ + /* source data pixels that need to be clipped, as well as the */ + /* amount of data that needs to be transferred. */ - gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width, - gfx_vid_height); - return (0); + gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width, + gfx_vid_height); + return (0); } /*--------------------------------------------------------------------------- @@ -925,18 +922,17 @@ gfx_set_video_scale(unsigned short srcw, unsigned short srch, */ #if GFX_VIDEO_DYNAMIC int -redcloud_set_video_vertical_downscale(unsigned short srch, - unsigned short dsth) +redcloud_set_video_vertical_downscale(unsigned short srch, unsigned short dsth) #else int gfx_set_video_vertical_downscale(unsigned short srch, unsigned short dsth) #endif { - /* SET VIDEO SCALE IN DISPLAY CONTROLLER */ - /* Use private routine to abstract hardware */ + /* SET VIDEO SCALE IN DISPLAY CONTROLLER */ + /* Use private routine to abstract hardware */ - gfx_set_display_video_downscale(srch, dsth); - return 0; + gfx_set_display_video_downscale(srch, dsth); + return 0; } /*--------------------------------------------------------------------------- @@ -953,10 +949,10 @@ void gfx_set_video_vertical_downscale_enable(int enable) #endif { - /* SET VIDEO SCALE IN DISPLAY CONTROLLER */ - /* Use private routine to abstract hardware */ + /* SET VIDEO SCALE IN DISPLAY CONTROLLER */ + /* Use private routine to abstract hardware */ - gfx_set_display_video_vertical_downscale_enable(enable); + gfx_set_display_video_vertical_downscale_enable(enable); } /*--------------------------------------------------------------------------- @@ -974,27 +970,27 @@ int gfx_set_video_downscale_config(unsigned short type, unsigned short m) #endif { - unsigned long downscale; + unsigned long downscale; - if ((m < 1) || (m > 16)) - return GFX_STATUS_BAD_PARAMETER; + if ((m < 1) || (m > 16)) + return GFX_STATUS_BAD_PARAMETER; - downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL); - downscale &= - ~(RCDF_VIDEO_DOWNSCALE_FACTOR_MASK | RCDF_VIDEO_DOWNSCALE_TYPE_MASK); - downscale |= ((unsigned long)(m - 1) << RCDF_VIDEO_DOWNSCALE_FACTOR_POS); - switch (type) { - case VIDEO_DOWNSCALE_KEEP_1_OF: - downscale |= RCDF_VIDEO_DOWNSCALE_TYPE_A; - break; - case VIDEO_DOWNSCALE_DROP_1_OF: - downscale |= RCDF_VIDEO_DOWNSCALE_TYPE_B; - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - WRITE_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL, downscale); - return (0); + downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL); + downscale &= + ~(RCDF_VIDEO_DOWNSCALE_FACTOR_MASK | RCDF_VIDEO_DOWNSCALE_TYPE_MASK); + downscale |= ((unsigned long) (m - 1) << RCDF_VIDEO_DOWNSCALE_FACTOR_POS); + switch (type) { + case VIDEO_DOWNSCALE_KEEP_1_OF: + downscale |= RCDF_VIDEO_DOWNSCALE_TYPE_A; + break; + case VIDEO_DOWNSCALE_DROP_1_OF: + downscale |= RCDF_VIDEO_DOWNSCALE_TYPE_B; + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + WRITE_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL, downscale); + return (0); } /*--------------------------------------------------------------------------- @@ -1006,26 +1002,25 @@ gfx_set_video_downscale_config(unsigned short type, unsigned short m) #if GFX_VIDEO_DYNAMIC int redcloud_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4) + unsigned short coef2, + unsigned short coef3, + unsigned short coef4) #else int gfx_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4) + unsigned short coef2, + unsigned short coef3, unsigned short coef4) #endif { - if ((coef1 + coef2 + coef3 + coef4) != 16) - return GFX_STATUS_BAD_PARAMETER; + if ((coef1 + coef2 + coef3 + coef4) != 16) + return GFX_STATUS_BAD_PARAMETER; - WRITE_VID32(RCDF_VIDEO_DOWNSCALER_COEFFICIENTS, - ((unsigned long)coef1 << RCDF_VIDEO_DOWNSCALER_COEF1_POS) | - ((unsigned long)coef2 << RCDF_VIDEO_DOWNSCALER_COEF2_POS) | - ((unsigned long)coef3 << RCDF_VIDEO_DOWNSCALER_COEF3_POS) | - ((unsigned long)coef4 << RCDF_VIDEO_DOWNSCALER_COEF4_POS)); - return (0); + WRITE_VID32(RCDF_VIDEO_DOWNSCALER_COEFFICIENTS, + ((unsigned long) coef1 << RCDF_VIDEO_DOWNSCALER_COEF1_POS) | + ((unsigned long) coef2 << RCDF_VIDEO_DOWNSCALER_COEF2_POS) | + ((unsigned long) coef3 << RCDF_VIDEO_DOWNSCALER_COEF3_POS) | + ((unsigned long) coef4 << RCDF_VIDEO_DOWNSCALER_COEF4_POS)); + return (0); } /*--------------------------------------------------------------------------- @@ -1042,15 +1037,15 @@ int gfx_set_video_downscale_enable(int enable) #endif { - unsigned long downscale; + unsigned long downscale; - downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL); - if (enable) - downscale |= RCDF_VIDEO_DOWNSCALE_ENABLE; - else - downscale &= ~RCDF_VIDEO_DOWNSCALE_ENABLE; - WRITE_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL, downscale); - return (0); + downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL); + if (enable) + downscale |= RCDF_VIDEO_DOWNSCALE_ENABLE; + else + downscale &= ~RCDF_VIDEO_DOWNSCALE_ENABLE; + WRITE_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL, downscale); + return (0); } /*--------------------------------------------------------------------------- @@ -1064,62 +1059,61 @@ gfx_set_video_downscale_enable(int enable) */ #if GFX_VIDEO_DYNAMIC int -redcloud_set_video_window(short x, short y, unsigned short w, - unsigned short h) +redcloud_set_video_window(short x, short y, unsigned short w, unsigned short h) #else int gfx_set_video_window(short x, short y, unsigned short w, unsigned short h) #endif { - unsigned long hadjust, vadjust; - unsigned long xstart, ystart, xend, yend; + unsigned long hadjust, vadjust; + unsigned long xstart, ystart, xend, yend; - /* SAVE PARAMETERS */ - /* These are needed to call this routine if the scale value changes. */ + /* SAVE PARAMETERS */ + /* These are needed to call this routine if the scale value changes. */ - gfx_vid_xpos = x; - gfx_vid_ypos = y; - gfx_vid_width = w; - gfx_vid_height = h; + gfx_vid_xpos = x; + gfx_vid_ypos = y; + gfx_vid_width = w; + gfx_vid_height = h; - /* GET ADJUSTMENT VALUES */ - /* Use routines to abstract version of display controller. */ + /* GET ADJUSTMENT VALUES */ + /* Use routines to abstract version of display controller. */ - hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 14l; - vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l; + hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 14l; + vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l; - /* HORIZONTAL START */ - xstart = (unsigned long)x + hadjust; + /* HORIZONTAL START */ + xstart = (unsigned long) x + hadjust; - /* HORIZONTAL END */ - /* End positions in register are non-inclusive (one more than the actual end) */ + /* HORIZONTAL END */ + /* End positions in register are non-inclusive (one more than the actual end) */ - if ((x + w) < gfx_get_hactive()) - xend = (unsigned long)x + (unsigned long)w + hadjust; + if ((x + w) < gfx_get_hactive()) + xend = (unsigned long) x + (unsigned long) w + hadjust; - /* RIGHT-CLIPPING */ - else - xend = (unsigned long)gfx_get_hactive() + hadjust; + /* RIGHT-CLIPPING */ + else + xend = (unsigned long) gfx_get_hactive() + hadjust; - /* VERTICAL START */ + /* VERTICAL START */ - ystart = (unsigned long)y + vadjust; + ystart = (unsigned long) y + vadjust; - /* VERTICAL END */ + /* VERTICAL END */ - if ((y + h) < gfx_get_vactive()) - yend = (unsigned long)y + (unsigned long)h + vadjust; + if ((y + h) < gfx_get_vactive()) + yend = (unsigned long) y + (unsigned long) h + vadjust; - /* BOTTOM-CLIPPING */ - else - yend = (unsigned long)gfx_get_vactive() + vadjust; + /* BOTTOM-CLIPPING */ + else + yend = (unsigned long) gfx_get_vactive() + vadjust; - /* SET VIDEO POSITION */ + /* SET VIDEO POSITION */ - WRITE_VID32(RCDF_VIDEO_X_POS, (xend << 16) | xstart); - WRITE_VID32(RCDF_VIDEO_Y_POS, (yend << 16) | ystart); + WRITE_VID32(RCDF_VIDEO_X_POS, (xend << 16) | xstart); + WRITE_VID32(RCDF_VIDEO_Y_POS, (yend << 16) | ystart); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -1139,32 +1133,33 @@ int gfx_set_video_left_crop(unsigned short x) #endif { - unsigned long vcfg, initread; + unsigned long vcfg, initread; - vcfg = READ_VID32(RCDF_VIDEO_CONFIG); + vcfg = READ_VID32(RCDF_VIDEO_CONFIG); - /* CLIPPING ON LEFT */ - /* Adjust initial read for scale, checking for divide by zero. Mask the */ - /* lower three bits when clipping 4:2:0 video. By masking the bits instead */ - /* of rounding up we ensure that we always clip less than or equal to the */ - /* desired number of pixels. This prevents visual artifacts from */ - /* over-clipping. We mask three bits to meet the HW requirement that 4:2:0 */ - /* clipping be 16-byte or 8-pixel aligned. */ + /* CLIPPING ON LEFT */ + /* Adjust initial read for scale, checking for divide by zero. Mask the */ + /* lower three bits when clipping 4:2:0 video. By masking the bits instead */ + /* of rounding up we ensure that we always clip less than or equal to the */ + /* desired number of pixels. This prevents visual artifacts from */ + /* over-clipping. We mask three bits to meet the HW requirement that 4:2:0 */ + /* clipping be 16-byte or 8-pixel aligned. */ - if (gfx_vid_dstw) { - initread = (unsigned long)x *gfx_vid_srcw / gfx_vid_dstw; + if (gfx_vid_dstw) { + initread = (unsigned long) x *gfx_vid_srcw / gfx_vid_dstw; - if (vcfg & RCDF_VCFG_4_2_0_MODE) - initread &= 0xFFF8; - } else - initread = 0; + if (vcfg & RCDF_VCFG_4_2_0_MODE) + initread &= 0xFFF8; + } + else + initread = 0; - /* SET INITIAL READ ADDRESS */ + /* SET INITIAL READ ADDRESS */ - vcfg &= ~RCDF_VCFG_INIT_READ_MASK; - vcfg |= (initread << 15) & RCDF_VCFG_INIT_READ_MASK; - WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); - return (0); + vcfg &= ~RCDF_VCFG_INIT_READ_MASK; + vcfg |= (initread << 15) & RCDF_VCFG_INIT_READ_MASK; + WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -1184,28 +1179,28 @@ gfx_set_video_left_crop(unsigned short x) #if GFX_VIDEO_DYNAMIC int redcloud_set_video_color_key(unsigned long key, unsigned long mask, - int graphics) + int graphics) #else int gfx_set_video_color_key(unsigned long key, unsigned long mask, int graphics) #endif { - unsigned long dcfg = 0; + unsigned long dcfg = 0; - /* SET RCDF COLOR KEY VALUE */ + /* SET RCDF COLOR KEY VALUE */ - WRITE_VID32(RCDF_VIDEO_COLOR_KEY, key); - WRITE_VID32(RCDF_VIDEO_COLOR_MASK, mask); + WRITE_VID32(RCDF_VIDEO_COLOR_KEY, key); + WRITE_VID32(RCDF_VIDEO_COLOR_MASK, mask); - /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */ + /* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */ - dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); - if (graphics & 0x01) - dcfg &= ~RCDF_DCFG_VG_CK; - else - dcfg |= RCDF_DCFG_VG_CK; - WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); - return (0); + dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); + if (graphics & 0x01) + dcfg &= ~RCDF_DCFG_VG_CK; + else + dcfg |= RCDF_DCFG_VG_CK; + WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -1222,18 +1217,18 @@ int gfx_set_video_filter(int xfilter, int yfilter) #endif { - unsigned long vcfg = 0; + unsigned long vcfg = 0; - /* ENABLE OR DISABLE DISPLAY FILTER VIDEO OVERLAY FILTERS */ + /* ENABLE OR DISABLE DISPLAY FILTER VIDEO OVERLAY FILTERS */ - vcfg = READ_VID32(RCDF_VIDEO_CONFIG); - vcfg &= ~(RCDF_VCFG_X_FILTER_EN | RCDF_VCFG_Y_FILTER_EN); - if (xfilter) - vcfg |= RCDF_VCFG_X_FILTER_EN; - if (yfilter) - vcfg |= RCDF_VCFG_Y_FILTER_EN; - WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); - return (0); + vcfg = READ_VID32(RCDF_VIDEO_CONFIG); + vcfg &= ~(RCDF_VCFG_X_FILTER_EN | RCDF_VCFG_Y_FILTER_EN); + if (xfilter) + vcfg |= RCDF_VCFG_X_FILTER_EN; + if (yfilter) + vcfg |= RCDF_VCFG_Y_FILTER_EN; + WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg); + return (0); } /*--------------------------------------------------------------------------- @@ -1252,19 +1247,19 @@ int gfx_set_video_palette(unsigned long *palette) #endif { - unsigned long i, entry; + unsigned long i, entry; - /* LOAD REDCLOUD VIDEO PALETTE */ + /* LOAD REDCLOUD VIDEO PALETTE */ - WRITE_VID32(RCDF_PALETTE_ADDRESS, 0); - for (i = 0; i < 256; i++) { - if (palette) - entry = palette[i]; - else - entry = i | (i << 8) | (i << 16); - WRITE_VID32(RCDF_PALETTE_DATA, entry); - } - return (0); + WRITE_VID32(RCDF_PALETTE_ADDRESS, 0); + for (i = 0; i < 256; i++) { + if (palette) + entry = palette[i]; + else + entry = i | (i << 8) | (i << 16); + WRITE_VID32(RCDF_PALETTE_DATA, entry); + } + return (0); } /*--------------------------------------------------------------------------- @@ -1281,15 +1276,15 @@ int gfx_set_video_palette_entry(unsigned long index, unsigned long palette) #endif { - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - /* SET A SINGLE ENTRY */ + /* SET A SINGLE ENTRY */ - WRITE_VID32(RCDF_PALETTE_ADDRESS, index); - WRITE_VID32(RCDF_PALETTE_DATA, palette); + WRITE_VID32(RCDF_PALETTE_ADDRESS, index); + WRITE_VID32(RCDF_PALETTE_DATA, palette); - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -1307,19 +1302,19 @@ int gfx_set_video_request(short x, short y) #endif { - /* SET DISPLAY FILTER VIDEO REQUEST */ + /* SET DISPLAY FILTER VIDEO REQUEST */ - x += gfx_get_htotal() - gfx_get_hsync_end() - 2; - y += gfx_get_vtotal() - gfx_get_vsync_end() + 1; + x += gfx_get_htotal() - gfx_get_hsync_end() - 2; + y += gfx_get_vtotal() - gfx_get_vsync_end() + 1; - if ((x < 0) || (x > RCDF_VIDEO_REQUEST_MASK) || - (y < 0) || (y > RCDF_VIDEO_REQUEST_MASK)) - return GFX_STATUS_BAD_PARAMETER; + if ((x < 0) || (x > RCDF_VIDEO_REQUEST_MASK) || + (y < 0) || (y > RCDF_VIDEO_REQUEST_MASK)) + return GFX_STATUS_BAD_PARAMETER; - WRITE_VID32(RCDF_VIDEO_REQUEST, - ((unsigned long)x << RCDF_VIDEO_X_REQUEST_POS) | - ((unsigned long)y << RCDF_VIDEO_Y_REQUEST_POS)); - return (0); + WRITE_VID32(RCDF_VIDEO_REQUEST, + ((unsigned long) x << RCDF_VIDEO_X_REQUEST_POS) | + ((unsigned long) y << RCDF_VIDEO_Y_REQUEST_POS)); + return (0); } /*--------------------------------------------------------------------------- @@ -1349,24 +1344,24 @@ gfx_set_video_request(short x, short y) #if GFX_VIDEO_DYNAMIC int redcloud_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, unsigned long color1, - unsigned long color2) + unsigned short select_color2, unsigned long color1, + unsigned long color2) #else int gfx_set_video_cursor(unsigned long key, unsigned long mask, - unsigned short select_color2, unsigned long color1, - unsigned long color2) + unsigned short select_color2, unsigned long color1, + unsigned long color2) #endif { - if (select_color2 > RCDF_CURSOR_COLOR_BITS) - return GFX_STATUS_BAD_PARAMETER; - key = (key & RCDF_COLOR_MASK) | ((unsigned long)select_color2 << - RCDF_CURSOR_COLOR_KEY_OFFSET_POS); - WRITE_VID32(RCDF_CURSOR_COLOR_KEY, key); - WRITE_VID32(RCDF_CURSOR_COLOR_MASK, mask); - WRITE_VID32(RCDF_CURSOR_COLOR_1, color1); - WRITE_VID32(RCDF_CURSOR_COLOR_2, color2); - return (0); + if (select_color2 > RCDF_CURSOR_COLOR_BITS) + return GFX_STATUS_BAD_PARAMETER; + key = (key & RCDF_COLOR_MASK) | ((unsigned long) select_color2 << + RCDF_CURSOR_COLOR_KEY_OFFSET_POS); + WRITE_VID32(RCDF_CURSOR_COLOR_KEY, key); + WRITE_VID32(RCDF_CURSOR_COLOR_MASK, mask); + WRITE_VID32(RCDF_CURSOR_COLOR_1, color1); + WRITE_VID32(RCDF_CURSOR_COLOR_2, color2); + return (0); } /*--------------------------------------------------------------------------- @@ -1401,15 +1396,15 @@ int gfx_set_video_cursor_enable(int enable) #endif { - unsigned long temp = READ_VID32(RCDF_CURSOR_COLOR_KEY); + unsigned long temp = READ_VID32(RCDF_CURSOR_COLOR_KEY); - if (enable) - temp |= RCDF_CURSOR_COLOR_KEY_ENABLE; - else - temp &= ~RCDF_CURSOR_COLOR_KEY_ENABLE; + if (enable) + temp |= RCDF_CURSOR_COLOR_KEY_ENABLE; + else + temp &= ~RCDF_CURSOR_COLOR_KEY_ENABLE; - WRITE_VID32(RCDF_CURSOR_COLOR_KEY, temp); - return (0); + WRITE_VID32(RCDF_CURSOR_COLOR_KEY, temp); + return (0); } /*--------------------------------------------------------------------------- @@ -1426,18 +1421,18 @@ int gfx_set_alpha_enable(int enable) #endif { - unsigned long address = 0, value = 0; + unsigned long address = 0, value = 0; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = RCDF_ALPHA_CONTROL_1 + ((unsigned long)gfx_alpha_select << 5); - value = READ_VID32(address); - if (enable) - value |= RCDF_ACTRL_WIN_ENABLE; - else - value &= ~(RCDF_ACTRL_WIN_ENABLE); - WRITE_VID32(address, value); - return (GFX_STATUS_OK); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = RCDF_ALPHA_CONTROL_1 + ((unsigned long) gfx_alpha_select << 5); + value = READ_VID32(address); + if (enable) + value |= RCDF_ACTRL_WIN_ENABLE; + else + value &= ~(RCDF_ACTRL_WIN_ENABLE); + WRITE_VID32(address, value); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1451,38 +1446,38 @@ gfx_set_alpha_enable(int enable) #if GFX_VIDEO_DYNAMIC int redcloud_set_alpha_window(short x, short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) #else int gfx_set_alpha_window(short x, short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) #endif { - unsigned long address = 0; + unsigned long address = 0; - /* CHECK FOR CLIPPING */ + /* CHECK FOR CLIPPING */ - if ((x + width) > gfx_get_hactive()) - width = gfx_get_hactive() - x; - if ((y + height) > gfx_get_vactive()) - height = gfx_get_vactive() - y; + if ((x + width) > gfx_get_hactive()) + width = gfx_get_hactive() - x; + if ((y + height) > gfx_get_vactive()) + height = gfx_get_vactive() - y; - /* ADJUST POSITIONS */ + /* ADJUST POSITIONS */ - x += gfx_get_htotal() - gfx_get_hsync_end() - 2; - y += gfx_get_vtotal() - gfx_get_vsync_end() + 1; + x += gfx_get_htotal() - gfx_get_hsync_end() - 2; + y += gfx_get_vtotal() - gfx_get_vsync_end() + 1; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = RCDF_ALPHA_XPOS_1 + ((unsigned long)gfx_alpha_select << 5); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = RCDF_ALPHA_XPOS_1 + ((unsigned long) gfx_alpha_select << 5); - /* END POSITIONS IN REGISTERS ARE NON-INCLUSIVE (ONE MORE THAN ACTUAL END) */ + /* END POSITIONS IN REGISTERS ARE NON-INCLUSIVE (ONE MORE THAN ACTUAL END) */ - WRITE_VID32(address, (unsigned long)x | - ((unsigned long)(x + width) << 16)); - WRITE_VID32(address + 8, (unsigned long)y | - ((unsigned long)(y + height) << 16)); - return (GFX_STATUS_OK); + WRITE_VID32(address, (unsigned long) x | + ((unsigned long) (x + width) << 16)); + WRITE_VID32(address + 8, (unsigned long) y | + ((unsigned long) (y + height) << 16)); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1500,18 +1495,18 @@ int gfx_set_alpha_value(unsigned char alpha, char delta) #endif { - unsigned long address = 0, value = 0; + unsigned long address = 0, value = 0; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = RCDF_ALPHA_CONTROL_1 + ((unsigned long)gfx_alpha_select << 5); - value = READ_VID32(address); - value &= RCDF_ACTRL_WIN_ENABLE; /* keep only enable bit */ - value |= (unsigned long)alpha; - value |= (((unsigned long)delta) & 0xff) << 8; - value |= RCDF_ACTRL_LOAD_ALPHA; - WRITE_VID32(address, value); - return (GFX_STATUS_OK); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = RCDF_ALPHA_CONTROL_1 + ((unsigned long) gfx_alpha_select << 5); + value = READ_VID32(address); + value &= RCDF_ACTRL_WIN_ENABLE; /* keep only enable bit */ + value |= (unsigned long) alpha; + value |= (((unsigned long) delta) & 0xff) << 8; + value |= RCDF_ACTRL_LOAD_ALPHA; + WRITE_VID32(address, value); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1530,18 +1525,18 @@ int gfx_set_alpha_priority(int priority) #endif { - unsigned long pos = 0, value = 0; + unsigned long pos = 0, value = 0; - if (priority > 3) - return (GFX_STATUS_BAD_PARAMETER); - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - value = READ_VID32(RCDF_VID_ALPHA_CONTROL); - pos = 16 + (gfx_alpha_select << 1); - value &= ~(0x03l << pos); - value |= (unsigned long)priority << pos; - WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value); - return (GFX_STATUS_OK); + if (priority > 3) + return (GFX_STATUS_BAD_PARAMETER); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + value = READ_VID32(RCDF_VID_ALPHA_CONTROL); + pos = 16 + (gfx_alpha_select << 1); + value &= ~(0x03l << pos); + value |= (unsigned long) priority << pos; + WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1562,13 +1557,13 @@ int gfx_set_alpha_color(unsigned long color) #endif { - unsigned long address = 0; + unsigned long address = 0; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = RCDF_ALPHA_COLOR_1 + ((unsigned long)gfx_alpha_select << 5); - WRITE_VID32(address, color); - return (GFX_STATUS_OK); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = RCDF_ALPHA_COLOR_1 + ((unsigned long) gfx_alpha_select << 5); + WRITE_VID32(address, color); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1585,19 +1580,19 @@ int gfx_set_alpha_color_enable(int enable) #endif { - unsigned long color; - unsigned long address = 0; + unsigned long color; + unsigned long address = 0; - if (gfx_alpha_select > 2) - return (GFX_STATUS_UNSUPPORTED); - address = RCDF_ALPHA_COLOR_1 + ((unsigned long)gfx_alpha_select << 5); - color = READ_VID32(address); - if (enable) - color |= RCDF_ALPHA_COLOR_ENABLE; - else - color &= ~RCDF_ALPHA_COLOR_ENABLE; - WRITE_VID32(address, color); - return (GFX_STATUS_OK); + if (gfx_alpha_select > 2) + return (GFX_STATUS_UNSUPPORTED); + address = RCDF_ALPHA_COLOR_1 + ((unsigned long) gfx_alpha_select << 5); + color = READ_VID32(address); + if (enable) + color |= RCDF_ALPHA_COLOR_ENABLE; + else + color &= ~RCDF_ALPHA_COLOR_ENABLE; + WRITE_VID32(address, color); + return (GFX_STATUS_OK); } /*--------------------------------------------------------------------------- @@ -1621,14 +1616,14 @@ int gfx_set_no_ck_outside_alpha(int enable) #endif { - unsigned long value; + unsigned long value; - value = READ_VID32(RCDF_VID_ALPHA_CONTROL); - if (enable) - WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value | RCDF_NO_CK_OUTSIDE_ALPHA); - else - WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value & ~RCDF_NO_CK_OUTSIDE_ALPHA); - return (0); + value = READ_VID32(RCDF_VID_ALPHA_CONTROL); + if (enable) + WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value | RCDF_NO_CK_OUTSIDE_ALPHA); + else + WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value & ~RCDF_NO_CK_OUTSIDE_ALPHA); + return (0); } /*--------------------------------------------------------------------------- @@ -1647,37 +1642,38 @@ unsigned long gfx_get_clock_frequency(void) #endif { - Q_WORD msr_value; - RCDFPLLENTRY *PLLTable; - unsigned int index; - unsigned long value, mask = 0x00001FFF; - unsigned long post_div3 = 0, pre_mult2 = 0; + Q_WORD msr_value; + RCDFPLLENTRY *PLLTable; + unsigned int index; + unsigned long value, mask = 0x00001FFF; + unsigned long post_div3 = 0, pre_mult2 = 0; - /* READ PLL SETTING */ + /* READ PLL SETTING */ - gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value); - value = msr_value.high & mask; + gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value); + value = msr_value.high & mask; - /* READ DIVISOR SETTINGS */ + /* READ DIVISOR SETTINGS */ - if ((gfx_cpu_version & 0xFF00) == 0x200) { - PLLTable = RCDF_PLLtable48MHz; + if ((gfx_cpu_version & 0xFF00) == 0x200) { + PLLTable = RCDF_PLLtable48MHz; - gfx_msr_read(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value); - post_div3 = (msr_value.low & MCP_DOTPOSTDIV3) ? 1 : 0; - pre_mult2 = (msr_value.low & MCP_DOTPREMULT2) ? 1 : 0; - } else - PLLTable = RCDF_PLLtable14MHz; + gfx_msr_read(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value); + post_div3 = (msr_value.low & MCP_DOTPOSTDIV3) ? 1 : 0; + pre_mult2 = (msr_value.low & MCP_DOTPREMULT2) ? 1 : 0; + } + else + PLLTable = RCDF_PLLtable14MHz; - /* SEARCH FOR A MATCH */ + /* SEARCH FOR A MATCH */ - for (index = 0; index < NUM_RCDF_FREQUENCIES; index++) { - if ((PLLTable[index].pll_value & mask) == value && - post_div3 == PLLTable[index].post_div3 && - pre_mult2 == PLLTable[index].pre_mul2) - return (PLLTable[index].frequency); - } - return (0); + for (index = 0; index < NUM_RCDF_FREQUENCIES; index++) { + if ((PLLTable[index].pll_value & mask) == value && + post_div3 == PLLTable[index].post_div3 && + pre_mult2 == PLLTable[index].pre_mul2) + return (PLLTable[index].frequency); + } + return (0); } /*************************************************************/ @@ -1702,13 +1698,13 @@ int gfx_get_sync_polarities(void) #endif { - int polarities = 0; + int polarities = 0; - if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_CRT_HSYNC_POL) - polarities |= 1; - if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_CRT_VSYNC_POL) - polarities |= 2; - return (polarities); + if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_CRT_HSYNC_POL) + polarities |= 1; + if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_CRT_VSYNC_POL) + polarities |= 2; + return (polarities); } /*--------------------------------------------------------------------------- @@ -1725,15 +1721,15 @@ int gfx_get_video_palette_entry(unsigned long index, unsigned long *palette) #endif { - if (index > 0xFF) - return GFX_STATUS_BAD_PARAMETER; + if (index > 0xFF) + return GFX_STATUS_BAD_PARAMETER; - /* READ A SINGLE ENTRY */ + /* READ A SINGLE ENTRY */ - WRITE_VID32(RCDF_PALETTE_ADDRESS, index); - *palette = READ_VID32(RCDF_PALETTE_DATA); + WRITE_VID32(RCDF_PALETTE_ADDRESS, index); + *palette = READ_VID32(RCDF_PALETTE_DATA); - return (GFX_STATUS_OK); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -1751,9 +1747,9 @@ int gfx_get_video_enable(void) #endif { - if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_VID_EN) - return (1); - return (0); + if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_VID_EN) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -1770,48 +1766,49 @@ int gfx_get_video_format(void) #endif { - unsigned long ctrl, vcfg; - - ctrl = READ_VID32(RCDF_VID_ALPHA_CONTROL); - vcfg = READ_VID32(RCDF_VIDEO_CONFIG); - - if (ctrl & RCDF_VIDEO_INPUT_IS_RGB) { - switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) { - case RCDF_VCFG_UYVY_FORMAT: - return VIDEO_FORMAT_RGB; - case RCDF_VCFG_Y2YU_FORMAT: - return VIDEO_FORMAT_P2M_P2L_P1M_P1L; - case RCDF_VCFG_YUYV_FORMAT: - return VIDEO_FORMAT_P1M_P1L_P2M_P2L; - case RCDF_VCFG_YVYU_FORMAT: - return VIDEO_FORMAT_P1M_P2L_P2M_P1L; - } - } - - if (vcfg & RCDF_VCFG_4_2_0_MODE) { - switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) { - case RCDF_VCFG_UYVY_FORMAT: - return VIDEO_FORMAT_Y0Y1Y2Y3; - case RCDF_VCFG_Y2YU_FORMAT: - return VIDEO_FORMAT_Y3Y2Y1Y0; - case RCDF_VCFG_YUYV_FORMAT: - return VIDEO_FORMAT_Y1Y0Y3Y2; - case RCDF_VCFG_YVYU_FORMAT: - return VIDEO_FORMAT_Y1Y2Y3Y0; - } - } else { - switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) { - case RCDF_VCFG_UYVY_FORMAT: - return VIDEO_FORMAT_UYVY; - case RCDF_VCFG_Y2YU_FORMAT: - return VIDEO_FORMAT_Y2YU; - case RCDF_VCFG_YUYV_FORMAT: - return VIDEO_FORMAT_YUYV; - case RCDF_VCFG_YVYU_FORMAT: - return VIDEO_FORMAT_YVYU; - } - } - return (GFX_STATUS_ERROR); + unsigned long ctrl, vcfg; + + ctrl = READ_VID32(RCDF_VID_ALPHA_CONTROL); + vcfg = READ_VID32(RCDF_VIDEO_CONFIG); + + if (ctrl & RCDF_VIDEO_INPUT_IS_RGB) { + switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) { + case RCDF_VCFG_UYVY_FORMAT: + return VIDEO_FORMAT_RGB; + case RCDF_VCFG_Y2YU_FORMAT: + return VIDEO_FORMAT_P2M_P2L_P1M_P1L; + case RCDF_VCFG_YUYV_FORMAT: + return VIDEO_FORMAT_P1M_P1L_P2M_P2L; + case RCDF_VCFG_YVYU_FORMAT: + return VIDEO_FORMAT_P1M_P2L_P2M_P1L; + } + } + + if (vcfg & RCDF_VCFG_4_2_0_MODE) { + switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) { + case RCDF_VCFG_UYVY_FORMAT: + return VIDEO_FORMAT_Y0Y1Y2Y3; + case RCDF_VCFG_Y2YU_FORMAT: + return VIDEO_FORMAT_Y3Y2Y1Y0; + case RCDF_VCFG_YUYV_FORMAT: + return VIDEO_FORMAT_Y1Y0Y3Y2; + case RCDF_VCFG_YVYU_FORMAT: + return VIDEO_FORMAT_Y1Y2Y3Y0; + } + } + else { + switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) { + case RCDF_VCFG_UYVY_FORMAT: + return VIDEO_FORMAT_UYVY; + case RCDF_VCFG_Y2YU_FORMAT: + return VIDEO_FORMAT_Y2YU; + case RCDF_VCFG_YUYV_FORMAT: + return VIDEO_FORMAT_YUYV; + case RCDF_VCFG_YVYU_FORMAT: + return VIDEO_FORMAT_YVYU; + } + } + return (GFX_STATUS_ERROR); } /*----------------------------------------------------------------------------- @@ -1829,43 +1826,43 @@ unsigned long gfx_get_video_src_size(void) #endif { - unsigned long width, height, scale, delta; - int down_enable; + unsigned long width, height, scale, delta; + int down_enable; - /* DETERMINE SOURCE WIDTH FROM THE DISPLAY FILTER VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE DISPLAY FILTER VIDEO LINE SIZE */ - width = (READ_VID32(RCDF_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_LINE_SIZE_UPPER) - width += 512l; + width = (READ_VID32(RCDF_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_LINE_SIZE_UPPER) + width += 512l; - /* DETERMINE SOURCE HEIGHT FROM THE DISPLAY FILTER HEIGHT AND SCALE VALUES */ - /* There is no true "source buffer size" in Redcloud. Instead, the VG module */ - /* provides video data as needed on a per-line basis. The source buffer size */ - /* is always assumed to equal the amount of required video data. The returned */ - /* height is equal to the height of the required video buffer data (before all */ - /* scaling.) */ + /* DETERMINE SOURCE HEIGHT FROM THE DISPLAY FILTER HEIGHT AND SCALE VALUES */ + /* There is no true "source buffer size" in Redcloud. Instead, the VG module */ + /* provides video data as needed on a per-line basis. The source buffer size */ + /* is always assumed to equal the amount of required video data. The returned */ + /* height is equal to the height of the required video buffer data (before all */ + /* scaling.) */ - scale = (READ_VID32(RCDF_VIDEO_SCALE) >> 16) & 0x3FFF; - height = ((READ_VID32(RCDF_VIDEO_Y_POS) >> 16) & 0x7FF) - - (READ_VID32(RCDF_VIDEO_Y_POS) & 0x7FF); - delta = gfx_get_video_downscale_delta(); - down_enable = gfx_get_video_vertical_downscale_enable(); + scale = (READ_VID32(RCDF_VIDEO_SCALE) >> 16) & 0x3FFF; + height = ((READ_VID32(RCDF_VIDEO_Y_POS) >> 16) & 0x7FF) - + (READ_VID32(RCDF_VIDEO_Y_POS) & 0x7FF); + delta = gfx_get_video_downscale_delta(); + down_enable = gfx_get_video_vertical_downscale_enable(); - /* REVERSE UPSCALING */ + /* REVERSE UPSCALING */ - if (height) - height = ((scale * (height - 1l)) / 0x2000l) + 2l; + if (height) + height = ((scale * (height - 1l)) / 0x2000l) + 2l; - /* REVERSE DOWNSCALING */ - /* Original lines = height * (0x3FFF + delta) / 0x3FFF */ - /* As this may cause rounding errors, we add 1 to the */ - /* returned source size. The return value of this */ - /* function could thus be off by 1. */ + /* REVERSE DOWNSCALING */ + /* Original lines = height * (0x3FFF + delta) / 0x3FFF */ + /* As this may cause rounding errors, we add 1 to the */ + /* returned source size. The return value of this */ + /* function could thus be off by 1. */ - if (down_enable && height) - height = ((height * (0x3FFFl + delta)) / 0x3FFFl) + 1; + if (down_enable && height) + height = ((height * (0x3FFFl + delta)) / 0x3FFFl) + 1; - return ((height << 16) | width); + return ((height << 16) | width); } /*----------------------------------------------------------------------------- @@ -1883,14 +1880,14 @@ unsigned long gfx_get_video_line_size(void) #endif { - unsigned long width = 0; + unsigned long width = 0; - /* DETERMINE SOURCE WIDTH FROM THE RCDF VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE RCDF VIDEO LINE SIZE */ - width = (READ_VID32(RCDF_VIDEO_CONFIG) >> 7) & 0x000001FE; - if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_LINE_SIZE_UPPER) - width += 512l; - return (width); + width = (READ_VID32(RCDF_VIDEO_CONFIG) >> 7) & 0x000001FE; + if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_LINE_SIZE_UPPER) + width += 512l; + return (width); } /*----------------------------------------------------------------------------- @@ -1908,12 +1905,12 @@ unsigned long gfx_get_video_xclip(void) #endif { - unsigned long clip = 0; + unsigned long clip = 0; - /* DETERMINE SOURCE WIDTH FROM THE RCDF VIDEO LINE SIZE */ + /* DETERMINE SOURCE WIDTH FROM THE RCDF VIDEO LINE SIZE */ - clip = (READ_VID32(RCDF_VIDEO_CONFIG) >> 14) & 0x000007FC; - return (clip); + clip = (READ_VID32(RCDF_VIDEO_CONFIG) >> 14) & 0x000007FC; + return (clip); } /*----------------------------------------------------------------------------- @@ -1930,7 +1927,7 @@ unsigned long gfx_get_video_offset(void) #endif { - return (gfx_get_display_video_offset()); + return (gfx_get_display_video_offset()); } /*----------------------------------------------------------------------------- @@ -1942,14 +1939,14 @@ gfx_get_video_offset(void) #if GFX_VIDEO_DYNAMIC void redcloud_get_video_yuv_offsets(unsigned long *yoffset, unsigned long *uoffset, - unsigned long *voffset) + unsigned long *voffset) #else void gfx_get_video_yuv_offsets(unsigned long *yoffset, unsigned long *uoffset, - unsigned long *voffset) + unsigned long *voffset) #endif { - gfx_get_display_video_yuv_offsets(yoffset, uoffset, voffset); + gfx_get_display_video_yuv_offsets(yoffset, uoffset, voffset); } /*----------------------------------------------------------------------------- @@ -1966,7 +1963,7 @@ void gfx_get_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch) #endif { - gfx_get_display_video_yuv_pitch(ypitch, uvpitch); + gfx_get_display_video_yuv_pitch(ypitch, uvpitch); } /*--------------------------------------------------------------------------- @@ -1983,7 +1980,7 @@ unsigned long gfx_get_video_scale(void) #endif { - return (READ_VID32(RCDF_VIDEO_SCALE)); + return (READ_VID32(RCDF_VIDEO_SCALE)); } /*--------------------------------------------------------------------------- @@ -2000,9 +1997,9 @@ unsigned long gfx_get_video_downscale_delta(void) #endif { - /* USE PRIVATE ROUTINE TO ABSTRACT THE DIPSLAY CONTROLLER */ + /* USE PRIVATE ROUTINE TO ABSTRACT THE DIPSLAY CONTROLLER */ - return (gfx_get_display_video_downscale_delta()); + return (gfx_get_display_video_downscale_delta()); } /*--------------------------------------------------------------------------- @@ -2019,9 +2016,9 @@ int gfx_get_video_vertical_downscale_enable(void) #endif { - /* USE PRIVATE ROUTINE TO ABSTRACT THE DIPSLAY CONTROLLER */ + /* USE PRIVATE ROUTINE TO ABSTRACT THE DIPSLAY CONTROLLER */ - return (gfx_get_display_video_downscale_enable()); + return (gfx_get_display_video_downscale_enable()); } /*--------------------------------------------------------------------------- @@ -2038,24 +2035,24 @@ int gfx_get_video_downscale_config(unsigned short *type, unsigned short *m) #endif { - unsigned long downscale; + unsigned long downscale; - downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL); - *m = (unsigned short)((downscale & RCDF_VIDEO_DOWNSCALE_FACTOR_MASK) >> - RCDF_VIDEO_DOWNSCALE_FACTOR_POS) + 1; + downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL); + *m = (unsigned short) ((downscale & RCDF_VIDEO_DOWNSCALE_FACTOR_MASK) >> + RCDF_VIDEO_DOWNSCALE_FACTOR_POS) + 1; - switch (downscale & RCDF_VIDEO_DOWNSCALE_TYPE_MASK) { - case RCDF_VIDEO_DOWNSCALE_TYPE_A: - *type = VIDEO_DOWNSCALE_KEEP_1_OF; - break; - case RCDF_VIDEO_DOWNSCALE_TYPE_B: - *type = VIDEO_DOWNSCALE_DROP_1_OF; - break; - default: - return GFX_STATUS_ERROR; - break; - } - return (0); + switch (downscale & RCDF_VIDEO_DOWNSCALE_TYPE_MASK) { + case RCDF_VIDEO_DOWNSCALE_TYPE_A: + *type = VIDEO_DOWNSCALE_KEEP_1_OF; + break; + case RCDF_VIDEO_DOWNSCALE_TYPE_B: + *type = VIDEO_DOWNSCALE_DROP_1_OF; + break; + default: + return GFX_STATUS_ERROR; + break; + } + return (0); } /*--------------------------------------------------------------------------- @@ -2067,33 +2064,33 @@ gfx_get_video_downscale_config(unsigned short *type, unsigned short *m) #if GFX_VIDEO_DYNAMIC void redcloud_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4) + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4) #else void gfx_get_video_downscale_coefficients(unsigned short *coef1, - unsigned short *coef2, - unsigned short *coef3, - unsigned short *coef4) + unsigned short *coef2, + unsigned short *coef3, + unsigned short *coef4) #endif { - unsigned long coef; + unsigned long coef; - coef = READ_VID32(RCDF_VIDEO_DOWNSCALER_COEFFICIENTS); - *coef1 = - (unsigned short)((coef >> RCDF_VIDEO_DOWNSCALER_COEF1_POS) & - RCDF_VIDEO_DOWNSCALER_COEF_MASK); - *coef2 = - (unsigned short)((coef >> RCDF_VIDEO_DOWNSCALER_COEF2_POS) & - RCDF_VIDEO_DOWNSCALER_COEF_MASK); - *coef3 = - (unsigned short)((coef >> RCDF_VIDEO_DOWNSCALER_COEF3_POS) & - RCDF_VIDEO_DOWNSCALER_COEF_MASK); - *coef4 = - (unsigned short)((coef >> RCDF_VIDEO_DOWNSCALER_COEF4_POS) & - RCDF_VIDEO_DOWNSCALER_COEF_MASK); - return; + coef = READ_VID32(RCDF_VIDEO_DOWNSCALER_COEFFICIENTS); + *coef1 = + (unsigned short) ((coef >> RCDF_VIDEO_DOWNSCALER_COEF1_POS) & + RCDF_VIDEO_DOWNSCALER_COEF_MASK); + *coef2 = + (unsigned short) ((coef >> RCDF_VIDEO_DOWNSCALER_COEF2_POS) & + RCDF_VIDEO_DOWNSCALER_COEF_MASK); + *coef3 = + (unsigned short) ((coef >> RCDF_VIDEO_DOWNSCALER_COEF3_POS) & + RCDF_VIDEO_DOWNSCALER_COEF_MASK); + *coef4 = + (unsigned short) ((coef >> RCDF_VIDEO_DOWNSCALER_COEF4_POS) & + RCDF_VIDEO_DOWNSCALER_COEF_MASK); + return; } /*--------------------------------------------------------------------------- @@ -2111,12 +2108,11 @@ void gfx_get_video_downscale_enable(int *enable) #endif { - if (READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL) & - RCDF_VIDEO_DOWNSCALE_ENABLE) - *enable = 1; - else - *enable = 0; - return; + if (READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL) & RCDF_VIDEO_DOWNSCALE_ENABLE) + *enable = 1; + else + *enable = 0; + return; } /*--------------------------------------------------------------------------- @@ -2133,13 +2129,13 @@ unsigned long gfx_get_video_dst_size(void) #endif { - unsigned long xsize, ysize; + unsigned long xsize, ysize; - xsize = READ_VID32(RCDF_VIDEO_X_POS); - xsize = ((xsize >> 16) & 0x7FF) - (xsize & 0x7FF); - ysize = READ_VID32(RCDF_VIDEO_Y_POS); - ysize = ((ysize >> 16) & 0x7FF) - (ysize & 0x7FF); - return ((ysize << 16) | xsize); + xsize = READ_VID32(RCDF_VIDEO_X_POS); + xsize = ((xsize >> 16) & 0x7FF) - (xsize & 0x7FF); + ysize = READ_VID32(RCDF_VIDEO_Y_POS); + ysize = ((ysize >> 16) & 0x7FF) - (ysize & 0x7FF); + return ((ysize << 16) | xsize); } /*--------------------------------------------------------------------------- @@ -2157,26 +2153,26 @@ unsigned long gfx_get_video_position(void) #endif { - unsigned long hadjust, vadjust; - unsigned long xpos, ypos; + unsigned long hadjust, vadjust; + unsigned long xpos, ypos; - /* READ HARDWARE POSITION */ + /* READ HARDWARE POSITION */ - xpos = READ_VID32(RCDF_VIDEO_X_POS) & 0x000007FF; - ypos = READ_VID32(RCDF_VIDEO_Y_POS) & 0x000007FF; + xpos = READ_VID32(RCDF_VIDEO_X_POS) & 0x000007FF; + ypos = READ_VID32(RCDF_VIDEO_Y_POS) & 0x000007FF; - /* GET ADJUSTMENT VALUES */ - /* Use routines to abstract version of display controller. */ + /* GET ADJUSTMENT VALUES */ + /* Use routines to abstract version of display controller. */ - hadjust = - (unsigned long)gfx_get_htotal() - - (unsigned long)gfx_get_hsync_end() - 14l; - vadjust = - (unsigned long)gfx_get_vtotal() - - (unsigned long)gfx_get_vsync_end() + 1l; - xpos -= hadjust; - ypos -= vadjust; - return ((ypos << 16) | (xpos & 0x0000FFFF)); + hadjust = + (unsigned long) gfx_get_htotal() - + (unsigned long) gfx_get_hsync_end() - 14l; + vadjust = + (unsigned long) gfx_get_vtotal() - + (unsigned long) gfx_get_vsync_end() + 1l; + xpos -= hadjust; + ypos -= vadjust; + return ((ypos << 16) | (xpos & 0x0000FFFF)); } /*--------------------------------------------------------------------------- @@ -2193,7 +2189,7 @@ unsigned long gfx_get_video_color_key(void) #endif { - return (READ_VID32(RCDF_VIDEO_COLOR_KEY)); + return (READ_VID32(RCDF_VIDEO_COLOR_KEY)); } /*--------------------------------------------------------------------------- @@ -2210,7 +2206,7 @@ unsigned long gfx_get_video_color_key_mask(void) #endif { - return (READ_VID32(RCDF_VIDEO_COLOR_MASK)); + return (READ_VID32(RCDF_VIDEO_COLOR_MASK)); } /*--------------------------------------------------------------------------- @@ -2227,9 +2223,9 @@ int gfx_get_video_color_key_src(void) #endif { - if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_VG_CK) - return (0); - return (1); + if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_VG_CK) + return (0); + return (1); } /*--------------------------------------------------------------------------- @@ -2246,13 +2242,13 @@ int gfx_get_video_filter(void) #endif { - int retval = 0; + int retval = 0; - if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_X_FILTER_EN) - retval |= 1; - if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_Y_FILTER_EN) - retval |= 2; - return (retval); + if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_X_FILTER_EN) + retval |= 1; + if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_Y_FILTER_EN) + retval |= 2; + return (retval); } /*--------------------------------------------------------------------------- @@ -2270,18 +2266,18 @@ int gfx_get_video_request(short *x, short *y) #endif { - unsigned long request = 0; + unsigned long request = 0; - request = (READ_VID32(RCDF_VIDEO_REQUEST)); - *x = (short)((request >> RCDF_VIDEO_X_REQUEST_POS) & - RCDF_VIDEO_REQUEST_MASK); - *y = (short)((request >> RCDF_VIDEO_Y_REQUEST_POS) & - RCDF_VIDEO_REQUEST_MASK); + request = (READ_VID32(RCDF_VIDEO_REQUEST)); + *x = (short) ((request >> RCDF_VIDEO_X_REQUEST_POS) & + RCDF_VIDEO_REQUEST_MASK); + *y = (short) ((request >> RCDF_VIDEO_Y_REQUEST_POS) & + RCDF_VIDEO_REQUEST_MASK); - *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2; - *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1; + *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2; + *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1; - return (0); + return (0); } /*--------------------------------------------------------------------------- @@ -2296,24 +2292,24 @@ gfx_get_video_request(short *x, short *y) #if GFX_VIDEO_DYNAMIC int redcloud_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, - unsigned long *color1, unsigned short *color2) + unsigned short *select_color2, + unsigned long *color1, unsigned short *color2) #else int gfx_get_video_cursor(unsigned long *key, unsigned long *mask, - unsigned short *select_color2, unsigned long *color1, - unsigned short *color2) + unsigned short *select_color2, unsigned long *color1, + unsigned short *color2) #endif { - *select_color2 = - (unsigned short)(READ_VID32(RCDF_CURSOR_COLOR_KEY) >> - RCDF_CURSOR_COLOR_KEY_OFFSET_POS); - *key = READ_VID32(RCDF_CURSOR_COLOR_KEY) & RCDF_COLOR_MASK; - *mask = READ_VID32(RCDF_CURSOR_COLOR_MASK) & RCDF_COLOR_MASK; - *color1 = READ_VID32(RCDF_CURSOR_COLOR_1) & RCDF_COLOR_MASK; - *color2 = - (unsigned short)(READ_VID32(RCDF_CURSOR_COLOR_2) & RCDF_COLOR_MASK); - return (0); + *select_color2 = + (unsigned short) (READ_VID32(RCDF_CURSOR_COLOR_KEY) >> + RCDF_CURSOR_COLOR_KEY_OFFSET_POS); + *key = READ_VID32(RCDF_CURSOR_COLOR_KEY) & RCDF_COLOR_MASK; + *mask = READ_VID32(RCDF_CURSOR_COLOR_MASK) & RCDF_COLOR_MASK; + *color1 = READ_VID32(RCDF_CURSOR_COLOR_1) & RCDF_COLOR_MASK; + *color2 = + (unsigned short) (READ_VID32(RCDF_CURSOR_COLOR_2) & RCDF_COLOR_MASK); + return (0); } /*--------------------------------------------------------------------------- @@ -2332,36 +2328,36 @@ unsigned long gfx_read_crc(void) #endif { - Q_WORD msr_value; - unsigned long crc = 0xFFFFFFFF; + Q_WORD msr_value; + unsigned long crc = 0xFFFFFFFF; - /* DISABLE 32-BIT CRCS */ - /* For GX1.x, this is a reserved bit, and is assumed to be a benign access */ + /* DISABLE 32-BIT CRCS */ + /* For GX1.x, this is a reserved bit, and is assumed to be a benign access */ - gfx_msr_read(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value); - msr_value.low &= ~RCDF_DIAG_32BIT_CRC; - gfx_msr_write(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value); + gfx_msr_read(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value); + msr_value.low &= ~RCDF_DIAG_32BIT_CRC; + gfx_msr_write(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value); - if (gfx_test_timing_active()) { - /* WAIT UNTIL ACTIVE DISPLAY */ + if (gfx_test_timing_active()) { + /* WAIT UNTIL ACTIVE DISPLAY */ - while (!gfx_test_vertical_active()) ; + while (!gfx_test_vertical_active()); - /* RESET CRC DURING ACTIVE DISPLAY */ + /* RESET CRC DURING ACTIVE DISPLAY */ - WRITE_VID32(RCDF_VID_CRC, 0); - WRITE_VID32(RCDF_VID_CRC, 1); + WRITE_VID32(RCDF_VID_CRC, 0); + WRITE_VID32(RCDF_VID_CRC, 1); - /* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */ + /* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */ - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - crc = READ_VID32(RCDF_VID_CRC) >> 8; - } - return (crc); + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + crc = READ_VID32(RCDF_VID_CRC) >> 8; + } + return (crc); } /*--------------------------------------------------------------------------- @@ -2380,36 +2376,36 @@ unsigned long gfx_read_crc32(void) #endif { - Q_WORD msr_value; - unsigned long crc = 0xFFFFFFFF; + Q_WORD msr_value; + unsigned long crc = 0xFFFFFFFF; - /* ENABLE 32-BIT CRCS */ - /* For GX1.x, this is a reserved bit, and is assumed to be a benign access */ + /* ENABLE 32-BIT CRCS */ + /* For GX1.x, this is a reserved bit, and is assumed to be a benign access */ - gfx_msr_read(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value); - msr_value.low |= RCDF_DIAG_32BIT_CRC; - gfx_msr_write(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value); + gfx_msr_read(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value); + msr_value.low |= RCDF_DIAG_32BIT_CRC; + gfx_msr_write(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value); - if (gfx_test_timing_active()) { - /* WAIT UNTIL ACTIVE DISPLAY */ + if (gfx_test_timing_active()) { + /* WAIT UNTIL ACTIVE DISPLAY */ - while (!gfx_test_vertical_active()) ; + while (!gfx_test_vertical_active()); - /* RESET CRC DURING ACTIVE DISPLAY */ + /* RESET CRC DURING ACTIVE DISPLAY */ - WRITE_VID32(RCDF_VID_CRC, 0); - WRITE_VID32(RCDF_VID_CRC, 1); + WRITE_VID32(RCDF_VID_CRC, 0); + WRITE_VID32(RCDF_VID_CRC, 1); - /* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */ + /* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */ - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - crc = READ_VID32(RCDF_VID_CRC32); - } - return (crc); + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + crc = READ_VID32(RCDF_VID_CRC32); + } + return (crc); } /*--------------------------------------------------------------------------- @@ -2422,345 +2418,347 @@ gfx_read_crc32(void) #if GFX_VIDEO_DYNAMIC unsigned long redcloud_read_window_crc(int source, unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - int crc32) + unsigned short width, unsigned short height, int crc32) #else unsigned long gfx_read_window_crc(int source, unsigned short x, unsigned short y, - unsigned short width, unsigned short height, int crc32) -#endif -{ - Q_WORD msr_value; - unsigned long xpos, ypos, crc = 0; - unsigned long old_fmt = 0; - unsigned int vsync_active_base, vsync_inactive_base, hsync_active_base; - unsigned int vsync_active_shift, vsync_inactive_shift, hsync_active_shift; - unsigned int vsync_bit, hsync_bit, sync_polarities = 0; - - /* CONFIGURE DISPLAY FILTER TO LOAD DATA ONTO LOWER 32-BITS */ - - msr_value.high = 0; - msr_value.low = - (source == CRC_SOURCE_GFX_DATA) ? (RCDF_MBD_DIAG_EN0 | 0x0000000F) - : (RCDF_MBD_DIAG_EN0 | 0x0000000B); - gfx_msr_write(RC_ID_DF, MBD_MSR_DIAG, &msr_value); - - /* CONFIGURE DISPLAY FILTER FOR APPROPRIATE OUTPUT */ - - if (source != CRC_SOURCE_GFX_DATA) { - gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msr_value); - old_fmt = msr_value.low; - msr_value.low &= ~(RCDF_CONFIG_FMT_MASK); - msr_value.low |= ((source == CRC_SOURCE_FP_DATA) ? RCDF_CONFIG_FMT_FP : - RCDF_CONFIG_FMT_CRT); - gfx_msr_write(RC_ID_DF, MBD_MSR_CONFIG, &msr_value); - } - - /* CONFIGURE MCP TO LOAD REGB DATA ONTO UPPER 32-BITS */ - - msr_value.low = MCP_MBD_DIAG_EN1 | 0x00050000; - gfx_msr_write(RC_ID_MCP, MBD_MSR_DIAG, &msr_value); - - /* ENABLE HW CLOCK GATING AND SET MCP CLOCK TO DOT CLOCK */ - - msr_value.low = 1l; - gfx_msr_write(RC_ID_MCP, MBD_MSR_PM, &msr_value); - msr_value.low = 0; - gfx_msr_write(RC_ID_MCP, MCP_DBGCLKCTL, &msr_value); - msr_value.low = 3; - gfx_msr_write(RC_ID_MCP, MCP_DBGCLKCTL, &msr_value); - - /* DISABLE MCP ACTIONS */ - - msr_value.high = 0x00000000; - msr_value.low = 0x00000000; - gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value); - - /* SET APPROPRIATE BASE ADDRESS */ - /* M-Sets use normal diag bits, while N-Sets use inverted diag bits */ - /* We thus use the M-sets when polling for a high signal and the N */ - /* sets when polling for a low signal. */ - - if (source != CRC_SOURCE_GFX_DATA) { - sync_polarities = gfx_get_sync_polarities(); - vsync_bit = 29; - hsync_bit = 30; - } else { - vsync_bit = 25; - hsync_bit = 26; - } - - if (sync_polarities & 1) { - hsync_active_base = MCP_SETM0CTL; - hsync_active_shift = 2; - } else { - hsync_active_base = MCP_SETN0CTL; - hsync_active_shift = 1; - } - if (sync_polarities & 2) { - vsync_active_base = MCP_SETM0CTL; - vsync_inactive_base = MCP_SETN0CTL; - vsync_active_shift = 2; - vsync_inactive_shift = 1; - } else { - vsync_active_base = MCP_SETN0CTL; - vsync_inactive_base = MCP_SETM0CTL; - vsync_active_shift = 1; - vsync_inactive_shift = 2; - } - - /* SET STATE TRANSITIONS */ - - /* STATE 0-1 TRANSITION (SET 0) */ - /* XState = 00 and VSync Inactive */ - /* Note: DF VSync = Diag Bus Bit 29 */ - /* VG VSync = Diag Bus Bit 25 */ - - msr_value.low = 0x000000A0; - msr_value.high = 0x00008000 | ((unsigned long)vsync_bit << 16) | - ((unsigned long)vsync_bit << 21) | ((unsigned long)vsync_bit << 26); - gfx_msr_write(RC_ID_MCP, vsync_inactive_base, &msr_value); - - /* STATE 1-2 TRANSITION (SET 4) */ - /* XState = 01 and VSync Active */ - - msr_value.low = 0x000000C0; - gfx_msr_write(RC_ID_MCP, vsync_active_base + 4, &msr_value); - - /* STATE 2-3 TRANSITION (SET 1) */ - /* XState = 10 and VSync Inactive */ - - msr_value.low = 0x00000120; - gfx_msr_write(RC_ID_MCP, vsync_inactive_base + 1, &msr_value); - - /* HORIZONTAL COUNTER (SET 5) */ - /* XState = 10 and HSync Active */ - /* Notes: DF HSync = Diag Bus Bit 30 */ - /* VG HSync = Diag Bus Bit 26 */ - - msr_value.high = 0x00008000 | ((unsigned long)hsync_bit << 16) | - ((unsigned long)hsync_bit << 21) | ((unsigned long)hsync_bit << 26); - msr_value.low = 0x00000120; - gfx_msr_write(RC_ID_MCP, hsync_active_base + 5, &msr_value); - - /* HORIZONTAL COUNTER RESET (SET 4) */ - /* XState = 10 and H. Counter = limit */ - /* Note: H. Counter is lower 16-bits of */ - /* RegB. */ - - msr_value.high = 0x00000000; - msr_value.low = 0x00000128; - gfx_msr_write(RC_ID_MCP, vsync_inactive_base + 4, &msr_value); - - /* CRC TRIGGER (SET 0) */ - /* Cmp0 <= xpos < Cmp1 */ - /* Cmp2 <= ypos < Cmp2 */ - - msr_value.high = 0x00000000; - msr_value.low = 0x10C20120; - gfx_msr_write(RC_ID_MCP, vsync_active_base, &msr_value); - - /* SET COMPARATOR VALUES */ - /* Note: The VG data outputs from the DF are delayed by one pixel clock. */ - /* In this mode, we thus add one to horizontal comparator limits. */ - - /* COMPARATOR 0 */ - /* Lower limit = xpos + (h_blank_pixels - 1) - 3 */ - /* Notes: */ - /* 1. 3 is the pipeline delay for MCP register */ - /* data to access the diag bus */ - /* 2. h_blank_pixels = HTOTAL - HSYNC_END */ - - xpos = (unsigned long)x + ((unsigned long)gfx_get_htotal() - - (unsigned long)gfx_get_hsync_end() - 1l) - 3l; - if (source == CRC_SOURCE_GFX_DATA) - xpos++; - msr_value.high = 0x00000000; - msr_value.low = xpos; - gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0, &msr_value); - - /* COMPARATOR 1 */ - /* Upper limit = xpos + width + (h_blank_pixels - 1) - 3 */ - - msr_value.low = xpos + (unsigned long)width; - gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 2, &msr_value); - - /* COMPARATOR 2 */ - /* Lower limit = ypos + v_blank_pixels */ - /* Notes: */ - /* 1. v_blank_pixels = VTOTAL - VSYNC_END */ - - ypos = (unsigned long)y + (unsigned long)gfx_get_vtotal() - - (unsigned long)gfx_get_vsync_end(); - msr_value.low = ypos << 16; - gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 4, &msr_value); - - /* COMPARATOR 3 */ - /* Upper limit = ypos + height + v_blank_pixels */ - - msr_value.low = (ypos + (unsigned long)height) << 16; - gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 6, &msr_value); - - /* SET COMPARATOR MASKS */ - - /* COMPARATORS 0 AND 1 REFER TO LOWER 16 BITS OF REGB */ - - msr_value.high = 0x00000000; - msr_value.low = 0x0000FFFF; - gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 2, &msr_value); - - /* COMPARATORS 2 AND 3 REFER TO UPPER 16 BITS OF REGB */ - - msr_value.low = 0xFFFF0000; - gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 4, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 6, &msr_value); - - /* SET REGA MASK TO CRC ONLY 24 BITS OF DATA */ - - msr_value.high = 0x00000000; - msr_value.low = 0x00FFFFFF; - gfx_msr_write(RC_ID_MCP, MCP_REGAMASK, &msr_value); - - /* SET REGB VALUE */ - /* Lower 16 bits use HTOTAL - SYNC TIME - 1 to set the counter rollover limit. */ - /* Upper 16 bits use 0xFFFF to remove auto-clear behavior. */ - - msr_value.high = 0x00000000; - msr_value.low = 0xFFFF0000 | - ((gfx_get_htotal() - (gfx_get_hsync_end() - gfx_get_hsync_start()) - - 1) & 0xFFFF); - gfx_msr_write(RC_ID_MCP, MCP_REGBVAL, &msr_value); - - /* PROGRAM ACTIONS */ - - /* GOTO STATE 01 */ - - msr_value.high = 0x00000000; - msr_value.low = 0x00000008 | (1l << vsync_inactive_shift); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 14, &msr_value); - - /* GOTO STATE 10 */ - - msr_value.low = 0x00080000 | (1l << (vsync_active_shift + 16)); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 15, &msr_value); - - /* GOTO STATE 11 */ - - msr_value.low = 0x00000080 | (1l << (vsync_inactive_shift + 4)); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 16, &msr_value); - - /* CLEAR REGB (COUNTERS) */ - /* RegB is cleared upon transitioning to state 10 */ - /* RegA is not cleared as the initial value must be 0x00000001 */ - - msr_value.low = 0x00080000 | (1l << (vsync_active_shift + 16)); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0, &msr_value); - - /* CRC INTO REGA */ - /* INCREMENT H. COUNTER */ - /* cmp0 <= xpos < cmp1 */ - /* cmp2 <= ypos < cmp3 */ - /* XState = 10 */ + unsigned short width, unsigned short height, int crc32) +#endif +{ + Q_WORD msr_value; + unsigned long xpos, ypos, crc = 0; + unsigned long old_fmt = 0; + unsigned int vsync_active_base, vsync_inactive_base, hsync_active_base; + unsigned int vsync_active_shift, vsync_inactive_shift, hsync_active_shift; + unsigned int vsync_bit, hsync_bit, sync_polarities = 0; + + /* CONFIGURE DISPLAY FILTER TO LOAD DATA ONTO LOWER 32-BITS */ + + msr_value.high = 0; + msr_value.low = + (source == CRC_SOURCE_GFX_DATA) ? (RCDF_MBD_DIAG_EN0 | 0x0000000F) + : (RCDF_MBD_DIAG_EN0 | 0x0000000B); + gfx_msr_write(RC_ID_DF, MBD_MSR_DIAG, &msr_value); + + /* CONFIGURE DISPLAY FILTER FOR APPROPRIATE OUTPUT */ + + if (source != CRC_SOURCE_GFX_DATA) { + gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msr_value); + old_fmt = msr_value.low; + msr_value.low &= ~(RCDF_CONFIG_FMT_MASK); + msr_value.low |= ((source == CRC_SOURCE_FP_DATA) ? RCDF_CONFIG_FMT_FP : + RCDF_CONFIG_FMT_CRT); + gfx_msr_write(RC_ID_DF, MBD_MSR_CONFIG, &msr_value); + } + + /* CONFIGURE MCP TO LOAD REGB DATA ONTO UPPER 32-BITS */ + + msr_value.low = MCP_MBD_DIAG_EN1 | 0x00050000; + gfx_msr_write(RC_ID_MCP, MBD_MSR_DIAG, &msr_value); + + /* ENABLE HW CLOCK GATING AND SET MCP CLOCK TO DOT CLOCK */ + + msr_value.low = 1l; + gfx_msr_write(RC_ID_MCP, MBD_MSR_PM, &msr_value); + msr_value.low = 0; + gfx_msr_write(RC_ID_MCP, MCP_DBGCLKCTL, &msr_value); + msr_value.low = 3; + gfx_msr_write(RC_ID_MCP, MCP_DBGCLKCTL, &msr_value); + + /* DISABLE MCP ACTIONS */ + + msr_value.high = 0x00000000; + msr_value.low = 0x00000000; + gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value); + + /* SET APPROPRIATE BASE ADDRESS */ + /* M-Sets use normal diag bits, while N-Sets use inverted diag bits */ + /* We thus use the M-sets when polling for a high signal and the N */ + /* sets when polling for a low signal. */ + + if (source != CRC_SOURCE_GFX_DATA) { + sync_polarities = gfx_get_sync_polarities(); + vsync_bit = 29; + hsync_bit = 30; + } + else { + vsync_bit = 25; + hsync_bit = 26; + } + + if (sync_polarities & 1) { + hsync_active_base = MCP_SETM0CTL; + hsync_active_shift = 2; + } + else { + hsync_active_base = MCP_SETN0CTL; + hsync_active_shift = 1; + } + if (sync_polarities & 2) { + vsync_active_base = MCP_SETM0CTL; + vsync_inactive_base = MCP_SETN0CTL; + vsync_active_shift = 2; + vsync_inactive_shift = 1; + } + else { + vsync_active_base = MCP_SETN0CTL; + vsync_inactive_base = MCP_SETM0CTL; + vsync_active_shift = 1; + vsync_inactive_shift = 2; + } + + /* SET STATE TRANSITIONS */ + + /* STATE 0-1 TRANSITION (SET 0) */ + /* XState = 00 and VSync Inactive */ + /* Note: DF VSync = Diag Bus Bit 29 */ + /* VG VSync = Diag Bus Bit 25 */ + + msr_value.low = 0x000000A0; + msr_value.high = 0x00008000 | ((unsigned long) vsync_bit << 16) | + ((unsigned long) vsync_bit << 21) | ((unsigned long) vsync_bit << 26); + gfx_msr_write(RC_ID_MCP, vsync_inactive_base, &msr_value); + + /* STATE 1-2 TRANSITION (SET 4) */ + /* XState = 01 and VSync Active */ + + msr_value.low = 0x000000C0; + gfx_msr_write(RC_ID_MCP, vsync_active_base + 4, &msr_value); + + /* STATE 2-3 TRANSITION (SET 1) */ + /* XState = 10 and VSync Inactive */ + + msr_value.low = 0x00000120; + gfx_msr_write(RC_ID_MCP, vsync_inactive_base + 1, &msr_value); + + /* HORIZONTAL COUNTER (SET 5) */ + /* XState = 10 and HSync Active */ + /* Notes: DF HSync = Diag Bus Bit 30 */ + /* VG HSync = Diag Bus Bit 26 */ + + msr_value.high = 0x00008000 | ((unsigned long) hsync_bit << 16) | + ((unsigned long) hsync_bit << 21) | ((unsigned long) hsync_bit << 26); + msr_value.low = 0x00000120; + gfx_msr_write(RC_ID_MCP, hsync_active_base + 5, &msr_value); + + /* HORIZONTAL COUNTER RESET (SET 4) */ + /* XState = 10 and H. Counter = limit */ + /* Note: H. Counter is lower 16-bits of */ + /* RegB. */ + + msr_value.high = 0x00000000; + msr_value.low = 0x00000128; + gfx_msr_write(RC_ID_MCP, vsync_inactive_base + 4, &msr_value); + + /* CRC TRIGGER (SET 0) */ + /* Cmp0 <= xpos < Cmp1 */ + /* Cmp2 <= ypos < Cmp2 */ + + msr_value.high = 0x00000000; + msr_value.low = 0x10C20120; + gfx_msr_write(RC_ID_MCP, vsync_active_base, &msr_value); + + /* SET COMPARATOR VALUES */ + /* Note: The VG data outputs from the DF are delayed by one pixel clock. */ + /* In this mode, we thus add one to horizontal comparator limits. */ + + /* COMPARATOR 0 */ + /* Lower limit = xpos + (h_blank_pixels - 1) - 3 */ + /* Notes: */ + /* 1. 3 is the pipeline delay for MCP register */ + /* data to access the diag bus */ + /* 2. h_blank_pixels = HTOTAL - HSYNC_END */ + + xpos = (unsigned long) x + ((unsigned long) gfx_get_htotal() - + (unsigned long) gfx_get_hsync_end() - 1l) - 3l; + if (source == CRC_SOURCE_GFX_DATA) + xpos++; + msr_value.high = 0x00000000; + msr_value.low = xpos; + gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0, &msr_value); + + /* COMPARATOR 1 */ + /* Upper limit = xpos + width + (h_blank_pixels - 1) - 3 */ + + msr_value.low = xpos + (unsigned long) width; + gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 2, &msr_value); + + /* COMPARATOR 2 */ + /* Lower limit = ypos + v_blank_pixels */ + /* Notes: */ + /* 1. v_blank_pixels = VTOTAL - VSYNC_END */ + + ypos = (unsigned long) y + (unsigned long) gfx_get_vtotal() - + (unsigned long) gfx_get_vsync_end(); + msr_value.low = ypos << 16; + gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 4, &msr_value); + + /* COMPARATOR 3 */ + /* Upper limit = ypos + height + v_blank_pixels */ + + msr_value.low = (ypos + (unsigned long) height) << 16; + gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 6, &msr_value); + + /* SET COMPARATOR MASKS */ + + /* COMPARATORS 0 AND 1 REFER TO LOWER 16 BITS OF REGB */ + + msr_value.high = 0x00000000; + msr_value.low = 0x0000FFFF; + gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 2, &msr_value); + + /* COMPARATORS 2 AND 3 REFER TO UPPER 16 BITS OF REGB */ + + msr_value.low = 0xFFFF0000; + gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 4, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 6, &msr_value); + + /* SET REGA MASK TO CRC ONLY 24 BITS OF DATA */ + + msr_value.high = 0x00000000; + msr_value.low = 0x00FFFFFF; + gfx_msr_write(RC_ID_MCP, MCP_REGAMASK, &msr_value); + + /* SET REGB VALUE */ + /* Lower 16 bits use HTOTAL - SYNC TIME - 1 to set the counter rollover limit. */ + /* Upper 16 bits use 0xFFFF to remove auto-clear behavior. */ + + msr_value.high = 0x00000000; + msr_value.low = 0xFFFF0000 | + ((gfx_get_htotal() - (gfx_get_hsync_end() - gfx_get_hsync_start()) - + 1) & 0xFFFF); + gfx_msr_write(RC_ID_MCP, MCP_REGBVAL, &msr_value); + + /* PROGRAM ACTIONS */ + + /* GOTO STATE 01 */ + + msr_value.high = 0x00000000; + msr_value.low = 0x00000008 | (1l << vsync_inactive_shift); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 14, &msr_value); + + /* GOTO STATE 10 */ + + msr_value.low = 0x00080000 | (1l << (vsync_active_shift + 16)); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 15, &msr_value); + + /* GOTO STATE 11 */ + + msr_value.low = 0x00000080 | (1l << (vsync_inactive_shift + 4)); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 16, &msr_value); + + /* CLEAR REGB (COUNTERS) */ + /* RegB is cleared upon transitioning to state 10 */ + /* RegA is not cleared as the initial value must be 0x00000001 */ + + msr_value.low = 0x00080000 | (1l << (vsync_active_shift + 16)); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0, &msr_value); + + /* CRC INTO REGA */ + /* INCREMENT H. COUNTER */ + /* cmp0 <= xpos < cmp1 */ + /* cmp2 <= ypos < cmp3 */ + /* XState = 10 */ - msr_value.low = 0x00000008 | (1l << vsync_active_shift) | - 0x00800000 | (1l << (hsync_active_shift + 20)); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 1, &msr_value); + msr_value.low = 0x00000008 | (1l << vsync_active_shift) | + 0x00800000 | (1l << (hsync_active_shift + 20)); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 1, &msr_value); - /* INCREMENT V. COUNTER */ - /* V. Counter is incremented when the H. Counter */ - /* rolls over. */ + /* INCREMENT V. COUNTER */ + /* V. Counter is incremented when the H. Counter */ + /* rolls over. */ - msr_value.low = 0x00080000 | (1l << (vsync_inactive_shift + 16)); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 2, &msr_value); + msr_value.low = 0x00080000 | (1l << (vsync_inactive_shift + 16)); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 2, &msr_value); - /* CLEAR ALL OTHER ACTIONS */ - /* This prevents side-effects from previous accesses to the MCP */ - /* debug logic. */ - msr_value.low = 0x00000000; - msr_value.high = 0x00000000; - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 3, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 4, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 5, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 6, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 7, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 8, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 9, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 10, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 11, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 12, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 13, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 17, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 18, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 19, &msr_value); - gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 20, &msr_value); + /* CLEAR ALL OTHER ACTIONS */ + /* This prevents side-effects from previous accesses to the MCP */ + /* debug logic. */ + msr_value.low = 0x00000000; + msr_value.high = 0x00000000; + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 3, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 4, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 5, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 6, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 7, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 8, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 9, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 10, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 11, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 12, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 13, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 17, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 18, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 19, &msr_value); + gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 20, &msr_value); - /* SET REGA CRC VALUE TO 1 OR 0 */ + /* SET REGA CRC VALUE TO 1 OR 0 */ - if (!crc32) - msr_value.low = 0x00000001; - gfx_msr_write(RC_ID_MCP, MCP_REGA, &msr_value); + if (!crc32) + msr_value.low = 0x00000001; + gfx_msr_write(RC_ID_MCP, MCP_REGA, &msr_value); - /* SET XSTATE TO 0 */ + /* SET XSTATE TO 0 */ - msr_value.low = 0; - msr_value.high = 0; - gfx_msr_write(RC_ID_MCP, MCP_XSTATE, &msr_value); + msr_value.low = 0; + msr_value.high = 0; + gfx_msr_write(RC_ID_MCP, MCP_XSTATE, &msr_value); - /* CONFIGURE DIAG CONTROL */ - /* Set all four comparators to watch the upper diag bus. */ - /* Set REGA action1 to legacy CRC or 32-bit CRC. */ - /* Set REGB action1 to increment lower 16 bits and clear at limit. */ - /* Set REGB action2 to increment upper 16 bits. */ - /* Enable all actions. */ + /* CONFIGURE DIAG CONTROL */ + /* Set all four comparators to watch the upper diag bus. */ + /* Set REGA action1 to legacy CRC or 32-bit CRC. */ + /* Set REGB action1 to increment lower 16 bits and clear at limit. */ + /* Set REGB action2 to increment upper 16 bits. */ + /* Enable all actions. */ - if (crc32) - msr_value.low = 0x9A820055; - else - msr_value.low = 0x9A840055; - msr_value.high = 0x00000000; - gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value); + if (crc32) + msr_value.low = 0x9A820055; + else + msr_value.low = 0x9A840055; + msr_value.high = 0x00000000; + gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value); - /* DELAY TWO FRAMES */ - - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; - while (gfx_test_vertical_active()) ; - while (!gfx_test_vertical_active()) ; + /* DELAY TWO FRAMES */ + + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); + while (gfx_test_vertical_active()); + while (!gfx_test_vertical_active()); - /* VERIFY THAT XSTATE = 11 */ + /* VERIFY THAT XSTATE = 11 */ - gfx_msr_read(RC_ID_MCP, MCP_XSTATE, &msr_value); - if ((msr_value.low & 3) == 3) { - gfx_msr_read(RC_ID_MCP, MCP_REGA, &msr_value); - - crc = msr_value.low; - if (!crc32) - crc &= 0xFFFFFF; - } - - /* DISABLE MCP AND DF DIAG BUS OUTPUTS */ - - msr_value.low = 0x00000000; - msr_value.high = 0x00000000; - gfx_msr_write(RC_ID_DF, MBD_MSR_DIAG, &msr_value); - gfx_msr_write(RC_ID_MCP, MBD_MSR_DIAG, &msr_value); - - /* DISABLE MCP ACTIONS */ - - msr_value.high = 0x00000000; - msr_value.low = 0x00000000; - gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value); - - /* RESTORE PREVIOUS OUTPUT FORMAT */ - - if (source != CRC_SOURCE_GFX_DATA) { - gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msr_value); - msr_value.low = old_fmt; - gfx_msr_write(RC_ID_DF, MBD_MSR_CONFIG, &msr_value); - } - return crc; + gfx_msr_read(RC_ID_MCP, MCP_XSTATE, &msr_value); + if ((msr_value.low & 3) == 3) { + gfx_msr_read(RC_ID_MCP, MCP_REGA, &msr_value); + + crc = msr_value.low; + if (!crc32) + crc &= 0xFFFFFF; + } + + /* DISABLE MCP AND DF DIAG BUS OUTPUTS */ + + msr_value.low = 0x00000000; + msr_value.high = 0x00000000; + gfx_msr_write(RC_ID_DF, MBD_MSR_DIAG, &msr_value); + gfx_msr_write(RC_ID_MCP, MBD_MSR_DIAG, &msr_value); + + /* DISABLE MCP ACTIONS */ + + msr_value.high = 0x00000000; + msr_value.low = 0x00000000; + gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value); + + /* RESTORE PREVIOUS OUTPUT FORMAT */ + + if (source != CRC_SOURCE_GFX_DATA) { + gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msr_value); + msr_value.low = old_fmt; + gfx_msr_write(RC_ID_DF, MBD_MSR_CONFIG, &msr_value); + } + return crc; } /*--------------------------------------------------------------------------- @@ -2778,17 +2776,17 @@ void gfx_get_alpha_enable(int *enable) #endif { - unsigned long value = 0; + unsigned long value = 0; - *enable = 0; - if (gfx_alpha_select <= 2) { - value = - READ_VID32(RCDF_ALPHA_CONTROL_1 + - ((unsigned long)gfx_alpha_select << 5)); - if (value & RCDF_ACTRL_WIN_ENABLE) - *enable = 1; - } - return; + *enable = 0; + if (gfx_alpha_select <= 2) { + value = + READ_VID32(RCDF_ALPHA_CONTROL_1 + + ((unsigned long) gfx_alpha_select << 5)); + if (value & RCDF_ACTRL_WIN_ENABLE) + *enable = 1; + } + return; } /*--------------------------------------------------------------------------- @@ -2800,34 +2798,34 @@ gfx_get_alpha_enable(int *enable) #if GFX_VIDEO_DYNAMIC void redcloud_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height) + unsigned short *width, unsigned short *height) #else void gfx_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height) -#endif -{ - unsigned long value = 0; - - *x = 0; - *y = 0; - *width = 0; - *height = 0; - if (gfx_alpha_select <= 2) { - value = - READ_VID32(RCDF_ALPHA_XPOS_1 + - ((unsigned long)gfx_alpha_select << 5)); - *x = (unsigned short)(value & 0x000007FF); - *width = (unsigned short)((value >> 16) & 0x000007FF) - *x; - value = - READ_VID32(RCDF_ALPHA_YPOS_1 + - ((unsigned long)gfx_alpha_select << 5)); - *y = (unsigned short)(value & 0x000007FF); - *height = (unsigned short)((value >> 16) & 0x000007FF) - *y; - } - *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2; - *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1; - return; + unsigned short *width, unsigned short *height) +#endif +{ + unsigned long value = 0; + + *x = 0; + *y = 0; + *width = 0; + *height = 0; + if (gfx_alpha_select <= 2) { + value = + READ_VID32(RCDF_ALPHA_XPOS_1 + + ((unsigned long) gfx_alpha_select << 5)); + *x = (unsigned short) (value & 0x000007FF); + *width = (unsigned short) ((value >> 16) & 0x000007FF) - *x; + value = + READ_VID32(RCDF_ALPHA_YPOS_1 + + ((unsigned long) gfx_alpha_select << 5)); + *y = (unsigned short) (value & 0x000007FF); + *height = (unsigned short) ((value >> 16) & 0x000007FF) - *y; + } + *x -= gfx_get_htotal() - gfx_get_hsync_end() - 2; + *y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1; + return; } /*--------------------------------------------------------------------------- @@ -2845,18 +2843,18 @@ void gfx_get_alpha_value(unsigned char *alpha, char *delta) #endif { - unsigned long value = 0; + unsigned long value = 0; - *alpha = 0; - *delta = 0; - if (gfx_alpha_select <= 2) { - value = - READ_VID32(RCDF_ALPHA_CONTROL_1 + - ((unsigned long)gfx_alpha_select << 5)); - *alpha = (unsigned char)(value & 0x00FF); - *delta = (char)((value >> 8) & 0x00FF); - } - return; + *alpha = 0; + *delta = 0; + if (gfx_alpha_select <= 2) { + value = + READ_VID32(RCDF_ALPHA_CONTROL_1 + + ((unsigned long) gfx_alpha_select << 5)); + *alpha = (unsigned char) (value & 0x00FF); + *delta = (char) ((value >> 8) & 0x00FF); + } + return; } /*--------------------------------------------------------------------------- @@ -2873,15 +2871,15 @@ void gfx_get_alpha_priority(int *priority) #endif { - unsigned long pos = 0, value = 0; + unsigned long pos = 0, value = 0; - *priority = 0; - if (gfx_alpha_select <= 2) { - value = READ_VID32(RCDF_VID_ALPHA_CONTROL); - pos = 16 + (gfx_alpha_select << 1); - *priority = (int)((value >> pos) & 3); - } - return; + *priority = 0; + if (gfx_alpha_select <= 2) { + value = READ_VID32(RCDF_VID_ALPHA_CONTROL); + pos = 16 + (gfx_alpha_select << 1); + *priority = (int) ((value >> pos) & 3); + } + return; } /*--------------------------------------------------------------------------- @@ -2899,15 +2897,15 @@ void gfx_get_alpha_color(unsigned long *color) #endif { - *color = 0; - if (gfx_alpha_select <= 2) { - *color = - READ_VID32(RCDF_ALPHA_COLOR_1 + - ((unsigned long)gfx_alpha_select << 5)); - } - return; + *color = 0; + if (gfx_alpha_select <= 2) { + *color = + READ_VID32(RCDF_ALPHA_COLOR_1 + + ((unsigned long) gfx_alpha_select << 5)); + } + return; } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ diff --git a/src/gfx/vip_1200.c b/src/gfx/vip_1200.c index f2458f6..d2b9549 100644 --- a/src/gfx/vip_1200.c +++ b/src/gfx/vip_1200.c @@ -174,15 +174,15 @@ int gfx_set_vip_enable(int enable) #endif { - unsigned long value; - - value = READ_VIP32(SC1200_VIP_CONTROL); - if (enable) - value |= SC1200_VIP_DATA_CAPTURE_EN; - else - value &= ~SC1200_VIP_DATA_CAPTURE_EN; - WRITE_VIP32(SC1200_VIP_CONTROL, value); - return (0); + unsigned long value; + + value = READ_VIP32(SC1200_VIP_CONTROL); + if (enable) + value |= SC1200_VIP_DATA_CAPTURE_EN; + else + value &= ~SC1200_VIP_DATA_CAPTURE_EN; + WRITE_VIP32(SC1200_VIP_CONTROL, value); + return (0); } /*----------------------------------------------------------------------------- @@ -199,25 +199,25 @@ int gfx_set_vip_capture_run_mode(int mode) #endif { - unsigned long value; - - value = READ_VIP32(SC1200_VIP_CONTROL); - value &= ~SC1200_CAPTURE_RUN_MODE_MASK; - switch (mode) { - case VIP_CAPTURE_STOP_LINE: - value |= SC1200_CAPTURE_RUN_MODE_STOP_LINE; - break; - case VIP_CAPTURE_STOP_FIELD: - value |= SC1200_CAPTURE_RUN_MODE_STOP_FIELD; - break; - case VIP_CAPTURE_START_FIELD: - value |= SC1200_CAPTURE_RUN_MODE_START; - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - WRITE_VIP32(SC1200_VIP_CONTROL, value); - return (0); + unsigned long value; + + value = READ_VIP32(SC1200_VIP_CONTROL); + value &= ~SC1200_CAPTURE_RUN_MODE_MASK; + switch (mode) { + case VIP_CAPTURE_STOP_LINE: + value |= SC1200_CAPTURE_RUN_MODE_STOP_LINE; + break; + case VIP_CAPTURE_STOP_FIELD: + value |= SC1200_CAPTURE_RUN_MODE_STOP_FIELD; + break; + case VIP_CAPTURE_START_FIELD: + value |= SC1200_CAPTURE_RUN_MODE_START; + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + WRITE_VIP32(SC1200_VIP_CONTROL, value); + return (0); } /*----------------------------------------------------------------------------- @@ -235,13 +235,14 @@ int gfx_set_vip_base(unsigned long even, unsigned long odd) #endif { - /* TRUE OFFSET IS SPECIFIED, NEED TO SET BIT 23 FOR HARDWARE */ - - if (even) - WRITE_VIP32(SC1200_VIP_EVEN_BASE, even + (unsigned long)gfx_phys_fbptr); - if (odd) - WRITE_VIP32(SC1200_VIP_ODD_BASE, odd + (unsigned long)gfx_phys_fbptr); - return (0); + /* TRUE OFFSET IS SPECIFIED, NEED TO SET BIT 23 FOR HARDWARE */ + + if (even) + WRITE_VIP32(SC1200_VIP_EVEN_BASE, + even + (unsigned long) gfx_phys_fbptr); + if (odd) + WRITE_VIP32(SC1200_VIP_ODD_BASE, odd + (unsigned long) gfx_phys_fbptr); + return (0); } /*----------------------------------------------------------------------------- @@ -258,8 +259,8 @@ int gfx_set_vip_pitch(unsigned long pitch) #endif { - WRITE_VIP32(SC1200_VIP_PITCH, pitch & SC1200_VIP_PITCH_MASK); - return (0); + WRITE_VIP32(SC1200_VIP_PITCH, pitch & SC1200_VIP_PITCH_MASK); + return (0); } /*----------------------------------------------------------------------------- @@ -276,18 +277,18 @@ int gfx_set_vip_mode(int mode) #endif { - unsigned long config; - - config = READ_VIP32(SC1200_VIP_CONFIG); - config &= ~SC1200_VIP_MODE_MASK; - switch (mode) { - case VIP_MODE_C: - WRITE_VIP32(SC1200_VIP_CONFIG, config | SC1200_VIP_MODE_C); - break; - default: - return GFX_STATUS_BAD_PARAMETER; - } - return (0); + unsigned long config; + + config = READ_VIP32(SC1200_VIP_CONFIG); + config &= ~SC1200_VIP_MODE_MASK; + switch (mode) { + case VIP_MODE_C: + WRITE_VIP32(SC1200_VIP_CONFIG, config | SC1200_VIP_MODE_C); + break; + default: + return GFX_STATUS_BAD_PARAMETER; + } + return (0); } /*----------------------------------------------------------------------------- @@ -304,15 +305,15 @@ int gfx_set_vbi_enable(int enable) #endif { - unsigned long value; - - value = READ_VIP32(SC1200_VIP_CONTROL); - if (enable) - value |= SC1200_VIP_VBI_CAPTURE_EN; - else - value &= ~SC1200_VIP_VBI_CAPTURE_EN; - WRITE_VIP32(SC1200_VIP_CONTROL, value); - return (0); + unsigned long value; + + value = READ_VIP32(SC1200_VIP_CONTROL); + if (enable) + value |= SC1200_VIP_VBI_CAPTURE_EN; + else + value &= ~SC1200_VIP_VBI_CAPTURE_EN; + WRITE_VIP32(SC1200_VIP_CONTROL, value); + return (0); } /*----------------------------------------------------------------------------- @@ -330,21 +331,21 @@ int gfx_set_vbi_mode(int mode) #endif { - unsigned long config; - - config = READ_VIP32(SC1200_VIP_CONFIG); - config &= - ~(SC1200_VBI_ANCILLARY_TO_MEMORY | SC1200_VBI_TASK_A_TO_MEMORY | - SC1200_VBI_TASK_B_TO_MEMORY); - - if (mode & VBI_ANCILLARY) - config |= SC1200_VBI_ANCILLARY_TO_MEMORY; - if (mode & VBI_TASK_A) - config |= SC1200_VBI_TASK_A_TO_MEMORY; - if (mode & VBI_TASK_B) - config |= SC1200_VBI_TASK_B_TO_MEMORY; - WRITE_VIP32(SC1200_VIP_CONFIG, config); - return (0); + unsigned long config; + + config = READ_VIP32(SC1200_VIP_CONFIG); + config &= + ~(SC1200_VBI_ANCILLARY_TO_MEMORY | SC1200_VBI_TASK_A_TO_MEMORY | + SC1200_VBI_TASK_B_TO_MEMORY); + + if (mode & VBI_ANCILLARY) + config |= SC1200_VBI_ANCILLARY_TO_MEMORY; + if (mode & VBI_TASK_A) + config |= SC1200_VBI_TASK_A_TO_MEMORY; + if (mode & VBI_TASK_B) + config |= SC1200_VBI_TASK_B_TO_MEMORY; + WRITE_VIP32(SC1200_VIP_CONFIG, config); + return (0); } /*----------------------------------------------------------------------------- @@ -363,14 +364,14 @@ int gfx_set_vbi_base(unsigned long even, unsigned long odd) #endif { - /* VIP HW REQUIRES THAT BASE ADDRESSES BE 16-BYTE ALIGNED */ + /* VIP HW REQUIRES THAT BASE ADDRESSES BE 16-BYTE ALIGNED */ - if (even) - WRITE_VIP32(SC1200_VBI_EVEN_BASE, even & ~0xf); - if (odd) - WRITE_VIP32(SC1200_VBI_ODD_BASE, odd & ~0xf); + if (even) + WRITE_VIP32(SC1200_VBI_EVEN_BASE, even & ~0xf); + if (odd) + WRITE_VIP32(SC1200_VBI_ODD_BASE, odd & ~0xf); - return (0); + return (0); } /*----------------------------------------------------------------------------- @@ -387,8 +388,8 @@ int gfx_set_vbi_pitch(unsigned long pitch) #endif { - WRITE_VIP32(SC1200_VBI_PITCH, pitch & SC1200_VBI_PITCH_MASK); - return (0); + WRITE_VIP32(SC1200_VBI_PITCH, pitch & SC1200_VBI_PITCH_MASK); + return (0); } /*----------------------------------------------------------------------------- @@ -405,11 +406,11 @@ int gfx_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines) #endif { - WRITE_VIP32(SC1200_EVEN_DIRECT_VBI_LINE_ENABLE, - even_lines & SC1200_DIRECT_VBI_LINE_ENABLE_MASK); - WRITE_VIP32(SC1200_ODD_DIRECT_VBI_LINE_ENABLE, - odd_lines & SC1200_DIRECT_VBI_LINE_ENABLE_MASK); - return (0); + WRITE_VIP32(SC1200_EVEN_DIRECT_VBI_LINE_ENABLE, + even_lines & SC1200_DIRECT_VBI_LINE_ENABLE_MASK); + WRITE_VIP32(SC1200_ODD_DIRECT_VBI_LINE_ENABLE, + odd_lines & SC1200_DIRECT_VBI_LINE_ENABLE_MASK); + return (0); } /*----------------------------------------------------------------------------- @@ -426,15 +427,15 @@ int gfx_set_vbi_interrupt(int enable) #endif { - unsigned long value; - - value = READ_VIP32(SC1200_VIP_CONTROL); - if (enable) - value |= SC1200_VIP_VBI_FIELD_INTERRUPT_EN; - else - value &= ~SC1200_VIP_VBI_FIELD_INTERRUPT_EN; - WRITE_VIP32(SC1200_VIP_CONTROL, value); - return (0); + unsigned long value; + + value = READ_VIP32(SC1200_VIP_CONTROL); + if (enable) + value |= SC1200_VIP_VBI_FIELD_INTERRUPT_EN; + else + value &= ~SC1200_VIP_VBI_FIELD_INTERRUPT_EN; + WRITE_VIP32(SC1200_VIP_CONTROL, value); + return (0); } /*----------------------------------------------------------------------------- @@ -453,15 +454,15 @@ int gfx_set_vip_bus_request_threshold_high(int enable) #endif { - unsigned long value; - - value = READ_VIP32(SC1200_VIP_CONFIG); - if (enable) - value &= ~SC1200_VIP_BUS_REQUEST_THRESHOLD; - else - value |= SC1200_VIP_BUS_REQUEST_THRESHOLD; - WRITE_VIP32(SC1200_VIP_CONFIG, value); - return (0); + unsigned long value; + + value = READ_VIP32(SC1200_VIP_CONFIG); + if (enable) + value &= ~SC1200_VIP_BUS_REQUEST_THRESHOLD; + else + value |= SC1200_VIP_BUS_REQUEST_THRESHOLD; + WRITE_VIP32(SC1200_VIP_CONFIG, value); + return (0); } /*----------------------------------------------------------------------------- @@ -478,17 +479,17 @@ int gfx_set_vip_last_line(int last_line) #endif { - unsigned long value; + unsigned long value; - /* This feature is implemented in Rev C1 */ - if (gfx_chip_revision < SC1200_REV_C1) - return (GFX_STATUS_OK); + /* This feature is implemented in Rev C1 */ + if (gfx_chip_revision < SC1200_REV_C1) + return (GFX_STATUS_OK); - value = READ_VIP32(SC1200_VIP_LINE_TARGET); - value &= ~SC1200_VIP_LAST_LINE_MASK; - value |= ((last_line & 0x3FF) << 16); - WRITE_VIP32(SC1200_VIP_LINE_TARGET, value); - return (GFX_STATUS_OK); + value = READ_VIP32(SC1200_VIP_LINE_TARGET); + value &= ~SC1200_VIP_LAST_LINE_MASK; + value |= ((last_line & 0x3FF) << 16); + WRITE_VIP32(SC1200_VIP_LINE_TARGET, value); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -505,10 +506,10 @@ int gfx_test_vip_odd_field(void) #endif { - if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_CURRENT_FIELD_ODD) - return (1); - else - return (0); + if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_CURRENT_FIELD_ODD) + return (1); + else + return (0); } /*----------------------------------------------------------------------------- @@ -527,10 +528,10 @@ int gfx_test_vip_bases_updated(void) #endif { - if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_BASE_NOT_UPDATED) - return (0); - else - return (1); + if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_BASE_NOT_UPDATED) + return (0); + else + return (1); } /*----------------------------------------------------------------------------- @@ -549,13 +550,14 @@ int gfx_test_vip_fifo_overflow(void) #endif { - if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_FIFO_OVERFLOW) { - /* Bits in vip status register are either read only or reset by writing 1 */ - WRITE_VIP32(SC1200_VIP_STATUS, SC1200_VIP_FIFO_OVERFLOW); - return (1); - } else { - return (0); - } + if (READ_VIP32(SC1200_VIP_STATUS) & SC1200_VIP_FIFO_OVERFLOW) { + /* Bits in vip status register are either read only or reset by writing 1 */ + WRITE_VIP32(SC1200_VIP_STATUS, SC1200_VIP_FIFO_OVERFLOW); + return (1); + } + else { + return (0); + } } /*----------------------------------------------------------------------------- @@ -573,8 +575,8 @@ int gfx_get_vip_line(void) #endif { - return (int)(READ_VIP32(SC1200_VIP_CURRENT_LINE) & - SC1200_VIP_CURRENT_LINE_MASK); + return (int) (READ_VIP32(SC1200_VIP_CURRENT_LINE) & + SC1200_VIP_CURRENT_LINE_MASK); } /*----------------------------------------------------------------------------- @@ -589,11 +591,11 @@ unsigned long gfx_get_vip_base(int odd) #endif { - /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ + /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ - if (odd) - return (READ_VIP32(SC1200_VIP_ODD_BASE)); - return (READ_VIP32(SC1200_VIP_EVEN_BASE)); + if (odd) + return (READ_VIP32(SC1200_VIP_ODD_BASE)); + return (READ_VIP32(SC1200_VIP_EVEN_BASE)); } /*----------------------------------------------------------------------------- @@ -608,7 +610,7 @@ unsigned long gfx_get_vbi_pitch(void) #endif { - return (READ_VIP32(SC1200_VBI_PITCH) & SC1200_VBI_PITCH_MASK); + return (READ_VIP32(SC1200_VBI_PITCH) & SC1200_VBI_PITCH_MASK); } /*************************************************************/ @@ -629,9 +631,9 @@ int gfx_get_vip_enable(void) #endif { - if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_DATA_CAPTURE_EN) - return (1); - return (0); + if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_DATA_CAPTURE_EN) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -646,7 +648,7 @@ unsigned long gfx_get_vip_pitch(void) #endif { - return (READ_VIP32(SC1200_VIP_PITCH) & SC1200_VIP_PITCH_MASK); + return (READ_VIP32(SC1200_VIP_PITCH) & SC1200_VIP_PITCH_MASK); } /*----------------------------------------------------------------------------- @@ -661,12 +663,12 @@ int gfx_get_vip_mode(void) #endif { - switch (READ_VIP32(SC1200_VIP_CONFIG) & SC1200_VIP_MODE_MASK) { - case SC1200_VIP_MODE_C: - return VIP_MODE_C; - default: - return (0); - } + switch (READ_VIP32(SC1200_VIP_CONFIG) & SC1200_VIP_MODE_MASK) { + case SC1200_VIP_MODE_C: + return VIP_MODE_C; + default: + return (0); + } } /*----------------------------------------------------------------------------- @@ -681,9 +683,9 @@ int gfx_get_vbi_enable(void) #endif { - if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_VBI_CAPTURE_EN) - return (1); - return (0); + if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_VBI_CAPTURE_EN) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -698,20 +700,20 @@ int gfx_get_vbi_mode(void) #endif { - int config; - int mode = 0; - - config = - (int)(READ_VIP32(SC1200_VIP_CONFIG) & - (SC1200_VBI_ANCILLARY_TO_MEMORY | SC1200_VBI_TASK_A_TO_MEMORY | - SC1200_VBI_TASK_B_TO_MEMORY)); - if (config & SC1200_VBI_ANCILLARY_TO_MEMORY) - mode |= VBI_ANCILLARY; - if (config & SC1200_VBI_TASK_A_TO_MEMORY) - mode |= VBI_TASK_A; - if (config & SC1200_VBI_TASK_B_TO_MEMORY) - mode |= VBI_TASK_B; - return mode; + int config; + int mode = 0; + + config = + (int) (READ_VIP32(SC1200_VIP_CONFIG) & + (SC1200_VBI_ANCILLARY_TO_MEMORY | SC1200_VBI_TASK_A_TO_MEMORY | + SC1200_VBI_TASK_B_TO_MEMORY)); + if (config & SC1200_VBI_ANCILLARY_TO_MEMORY) + mode |= VBI_ANCILLARY; + if (config & SC1200_VBI_TASK_A_TO_MEMORY) + mode |= VBI_TASK_A; + if (config & SC1200_VBI_TASK_B_TO_MEMORY) + mode |= VBI_TASK_B; + return mode; } /*----------------------------------------------------------------------------- @@ -726,11 +728,11 @@ unsigned long gfx_get_vbi_base(int odd) #endif { - /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ + /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ - if (odd) - return (READ_VIP32(SC1200_VBI_ODD_BASE)); - return (READ_VIP32(SC1200_VBI_EVEN_BASE)); + if (odd) + return (READ_VIP32(SC1200_VBI_ODD_BASE)); + return (READ_VIP32(SC1200_VBI_EVEN_BASE)); } /*----------------------------------------------------------------------------- @@ -745,13 +747,13 @@ unsigned long gfx_get_vbi_direct(int odd) #endif { - /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ + /* MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET */ - if (odd) - return (READ_VIP32(SC1200_ODD_DIRECT_VBI_LINE_ENABLE) & - SC1200_DIRECT_VBI_LINE_ENABLE_MASK); - return (READ_VIP32(SC1200_EVEN_DIRECT_VBI_LINE_ENABLE) & - SC1200_DIRECT_VBI_LINE_ENABLE_MASK); + if (odd) + return (READ_VIP32(SC1200_ODD_DIRECT_VBI_LINE_ENABLE) & + SC1200_DIRECT_VBI_LINE_ENABLE_MASK); + return (READ_VIP32(SC1200_EVEN_DIRECT_VBI_LINE_ENABLE) & + SC1200_DIRECT_VBI_LINE_ENABLE_MASK); } /*----------------------------------------------------------------------------- @@ -766,9 +768,9 @@ int gfx_get_vbi_interrupt(void) #endif { - if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_VBI_FIELD_INTERRUPT_EN) - return (1); - return (0); + if (READ_VIP32(SC1200_VIP_CONTROL) & SC1200_VIP_VBI_FIELD_INTERRUPT_EN) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -783,11 +785,11 @@ int gfx_get_vip_bus_request_threshold_high(void) #endif { - if (READ_VIP32(SC1200_VIP_CONFIG) & SC1200_VIP_BUS_REQUEST_THRESHOLD) - return (1); - return (0); + if (READ_VIP32(SC1200_VIP_CONFIG) & SC1200_VIP_BUS_REQUEST_THRESHOLD) + return (1); + return (0); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ diff --git a/src/gfx/vip_1400.c b/src/gfx/vip_1400.c index 7896288..4d1b7eb 100644 --- a/src/gfx/vip_1400.c +++ b/src/gfx/vip_1400.c @@ -27,31 +27,32 @@ int gfx_set_vip_enable(int enable) #endif { - unsigned long mcr, value; + unsigned long mcr, value; - value = READ_VIP32(SC1400_VIP_CONTROL); + value = READ_VIP32(SC1400_VIP_CONTROL); - if (enable) { - /* CONFIGURE MCR FOR VIDEO INPUT MODE */ + if (enable) { + /* CONFIGURE MCR FOR VIDEO INPUT MODE */ - mcr = IND(SC1400_CB_BASE_ADDR + SC1400_CB_MISC_CONFIG); - mcr |= (SC1400_MCR_VPOUT_CK_SELECT | SC1400_MCR_VPOUT_CK_SOURCE); - mcr &= ~SC1400_MCR_VPOUT_MODE; - mcr |= SC1400_MCR_VPIN_CCIR656; - mcr &= ~SC1400_MCR_GENLOCK_CONTINUE; - OUTD(SC1400_CB_BASE_ADDR + SC1400_CB_MISC_CONFIG, mcr); + mcr = IND(SC1400_CB_BASE_ADDR + SC1400_CB_MISC_CONFIG); + mcr |= (SC1400_MCR_VPOUT_CK_SELECT | SC1400_MCR_VPOUT_CK_SOURCE); + mcr &= ~SC1400_MCR_VPOUT_MODE; + mcr |= SC1400_MCR_VPIN_CCIR656; + mcr &= ~SC1400_MCR_GENLOCK_CONTINUE; + OUTD(SC1400_CB_BASE_ADDR + SC1400_CB_MISC_CONFIG, mcr); - /* ENABLE CAPTURE */ - /* Hardcode config values for now. */ + /* ENABLE CAPTURE */ + /* Hardcode config values for now. */ - WRITE_VIP32(SC1400_VIP_CONFIG, 0x30012); - value |= 0x103; - } else { - value &= ~(0x102); - } + WRITE_VIP32(SC1400_VIP_CONFIG, 0x30012); + value |= 0x103; + } + else { + value &= ~(0x102); + } - WRITE_VIP32(SC1400_VIP_CONTROL, value); - return (0); + WRITE_VIP32(SC1400_VIP_CONTROL, value); + return (0); } /*----------------------------------------------------------------------------- @@ -69,11 +70,11 @@ int gfx_set_vip_base(unsigned long even, unsigned long odd) #endif { - // TRUE OFFSET IS SPECIFIED, NEED TO SET BIT 23 FOR HARDWARE + // TRUE OFFSET IS SPECIFIED, NEED TO SET BIT 23 FOR HARDWARE - WRITE_VIP32(SC1400_VIP_EVEN_BASE, even | 0x00800000); - WRITE_VIP32(SC1400_VIP_ODD_BASE, odd | 0x00800000); - return (0); + WRITE_VIP32(SC1400_VIP_EVEN_BASE, even | 0x00800000); + WRITE_VIP32(SC1400_VIP_ODD_BASE, odd | 0x00800000); + return (0); } /*----------------------------------------------------------------------------- @@ -90,8 +91,8 @@ int gfx_set_vip_pitch(unsigned long pitch) #endif { - WRITE_VIP32(SC1400_VIP_PITCH, pitch & 0x0000FFFC); - return (0); + WRITE_VIP32(SC1400_VIP_PITCH, pitch & 0x0000FFFC); + return (0); } /*----------------------------------------------------------------------------- @@ -108,15 +109,15 @@ int gfx_set_vbi_enable(int enable) #endif { - unsigned long value; + unsigned long value; - value = READ_VIP32(SC1400_VIP_CONTROL); - if (enable) - value |= SC1400_VIP_VBI_CAPTURE_EN; - else - value &= ~SC1400_VIP_VBI_CAPTURE_EN; - WRITE_VIP32(SC1400_VIP_CONTROL, value); - return (0); + value = READ_VIP32(SC1400_VIP_CONTROL); + if (enable) + value |= SC1400_VIP_VBI_CAPTURE_EN; + else + value &= ~SC1400_VIP_VBI_CAPTURE_EN; + WRITE_VIP32(SC1400_VIP_CONTROL, value); + return (0); } /*----------------------------------------------------------------------------- @@ -133,11 +134,11 @@ int gfx_set_vbi_base(unsigned long even, unsigned long odd) #endif { - // TRUE OFFSET IS SPECIFIED, NEED TO SET BIT 23 FOR HARDWARE + // TRUE OFFSET IS SPECIFIED, NEED TO SET BIT 23 FOR HARDWARE - WRITE_VIP32(SC1400_VBI_EVEN_BASE, even | 0x00800000); - WRITE_VIP32(SC1400_VBI_ODD_BASE, odd | 0x00800000); - return (0); + WRITE_VIP32(SC1400_VBI_EVEN_BASE, even | 0x00800000); + WRITE_VIP32(SC1400_VBI_ODD_BASE, odd | 0x00800000); + return (0); } /*----------------------------------------------------------------------------- @@ -154,8 +155,8 @@ int gfx_set_vbi_pitch(unsigned long pitch) #endif { - WRITE_VIP32(SC1400_VBI_PITCH, pitch & 0x0000FFFC); - return (0); + WRITE_VIP32(SC1400_VBI_PITCH, pitch & 0x0000FFFC); + return (0); } /*************************************************************/ @@ -176,9 +177,9 @@ int gfx_get_vip_enable(void) #endif { - if (READ_VIP32(SC1400_VIP_CONTROL) & 0x00000100) - return (1); - return (0); + if (READ_VIP32(SC1400_VIP_CONTROL) & 0x00000100) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -193,11 +194,11 @@ unsigned long gfx_get_vip_base(int odd) #endif { - // MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET + // MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET - if (odd) - return (READ_VIP32(SC1400_VIP_ODD_BASE) & 0x007FFFFF); - return (READ_VIP32(SC1400_VIP_EVEN_BASE) & 0x007FFFFF); + if (odd) + return (READ_VIP32(SC1400_VIP_ODD_BASE) & 0x007FFFFF); + return (READ_VIP32(SC1400_VIP_EVEN_BASE) & 0x007FFFFF); } /*----------------------------------------------------------------------------- @@ -212,7 +213,7 @@ unsigned long gfx_get_vip_pitch(void) #endif { - return (READ_VIP32(SC1400_VIP_PITCH) & 0x0000FFFF); + return (READ_VIP32(SC1400_VIP_PITCH) & 0x0000FFFF); } /*----------------------------------------------------------------------------- @@ -227,9 +228,9 @@ int gfx_get_vbi_enable(void) #endif { - if (READ_VIP32(SC1400_VIP_CONTROL) & 0x00000200) - return (1); - return (0); + if (READ_VIP32(SC1400_VIP_CONTROL) & 0x00000200) + return (1); + return (0); } /*----------------------------------------------------------------------------- @@ -244,11 +245,11 @@ unsigned long gfx_get_vbi_base(int odd) #endif { - // MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET + // MASK BIT 23 AND ABOVE TO MAKE IT A TRUE OFFSET - if (odd) - return (READ_VIP32(SC1400_VBI_ODD_BASE) & 0x007FFFFF); - return (READ_VIP32(SC1400_VBI_EVEN_BASE) & 0x007FFFFF); + if (odd) + return (READ_VIP32(SC1400_VBI_ODD_BASE) & 0x007FFFFF); + return (READ_VIP32(SC1400_VBI_EVEN_BASE) & 0x007FFFFF); } /*----------------------------------------------------------------------------- @@ -263,9 +264,9 @@ unsigned long gfx_get_vbi_pitch(void) #endif { - return (READ_VIP32(SC1400_VBI_PITCH) & 0x0000FFFF); + return (READ_VIP32(SC1400_VBI_PITCH) & 0x0000FFFF); } -#endif /* GFX_READ_ROUTINES */ +#endif /* GFX_READ_ROUTINES */ /* END OF FILE */ @@ -159,23 +159,23 @@ #define GFX(func) Gal_##func #define GFX2(func) Gal2_##func #define OPTACCEL(func) func -#else /* STB_X */ +#else /* STB_X */ #define GFX(func) gfx_##func #define GFX2(func) gfx2_##func #if defined(OPT_ACCEL) #define OPTACCEL(func) OPT##func -#else /* OPT_ACCEL */ +#else /* OPT_ACCEL */ #define OPTACCEL(func) func -#endif /* OPT_ACCEL */ +#endif /* OPT_ACCEL */ -#endif /* STB_X */ +#endif /* STB_X */ #define GEODEPTR(p) ((GeodePtr)((p)->driverPrivate)) #define DebugPort(_Val) gfx_outb(0x84, (_Val)); -#define DEFAULT_NUM_OF_BUF 20 /* default # of buffers */ +#define DEFAULT_NUM_OF_BUF 20 /* default # of buffers */ #if defined(MYDBG) #define DEBUGMSG(cond, drv_msg) if((cond)) xf86DrvMsg drv_msg @@ -193,7 +193,7 @@ unsigned char DCount = 0; void gfx_outb(unsigned short port, unsigned char data) { - __asm__ volatile ("outb %0,%1"::"a" (data), "d"(port)); + __asm__ volatile ("outb %0,%1"::"a" (data), "d"(port)); } #endif #else @@ -227,212 +227,200 @@ extern void gfx_outd(unsigned short port, unsigned long data); #include "gfx_regs.h" #include "panel.h" -typedef struct __TVPARAMS -{ - unsigned int dwFlags; - unsigned short wWidth; - unsigned short wHeight; - unsigned short wStandard; - unsigned short wType; - unsigned short wOutput; - unsigned short wResolution; - Bool bState; -} -TVPARAMS, *PTVPARAMS; - -typedef struct __DISPLAYTIMING -{ - unsigned int dwDotClock; - unsigned short wPitch; - unsigned short wBpp; - unsigned short wHTotal; - unsigned short wHActive; - unsigned short wHSyncStart; - unsigned short wHSyncEnd; - unsigned short wHBlankStart; - unsigned short wHBlankEnd; - unsigned short wVTotal; - unsigned short wVActive; - unsigned short wVSyncStart; - unsigned short wVSyncEnd; - unsigned short wVBlankStart; - unsigned short wVBlankEnd; - unsigned short wPolarity; -} -DISPLAYTIMING, *PDISPLAYTIMING; +typedef struct __TVPARAMS { + unsigned int dwFlags; + unsigned short wWidth; + unsigned short wHeight; + unsigned short wStandard; + unsigned short wType; + unsigned short wOutput; + unsigned short wResolution; + Bool bState; +} TVPARAMS, *PTVPARAMS; + +typedef struct __DISPLAYTIMING { + unsigned int dwDotClock; + unsigned short wPitch; + unsigned short wBpp; + unsigned short wHTotal; + unsigned short wHActive; + unsigned short wHSyncStart; + unsigned short wHSyncEnd; + unsigned short wHBlankStart; + unsigned short wHBlankEnd; + unsigned short wVTotal; + unsigned short wVActive; + unsigned short wVSyncStart; + unsigned short wVSyncEnd; + unsigned short wVBlankStart; + unsigned short wVBlankEnd; + unsigned short wPolarity; +} DISPLAYTIMING, *PDISPLAYTIMING; /* TV Timings */ -typedef struct __TVTIMING -{ - unsigned long HorzTim; - unsigned long HorzSync; - unsigned long VertSync; - unsigned long LineEnd; - unsigned long VertDownscale; - unsigned long HorzScaling; - unsigned long TimCtrl1; - unsigned long TimCtrl2; - unsigned long Subfreq; - unsigned long DispPos; - unsigned long DispSize; - unsigned long Debug; - unsigned long DacCtrl; - unsigned int DotClock; -} -TVTIMING, *PTVTIMING; - -#endif /* STB_X */ - -typedef struct _VESARec -{ - xf86Int10InfoPtr pInt; -} -VESARec, *VESAPtr; - -typedef struct -{ - /* Private struct for the server */ - unsigned long cpu_version; /* [7:0] Type:1=GXLV,2=SC1400 */ - /* [15:8] Major version */ - /* [23:16] Minor version */ - unsigned long vid_version; /* [7:0] Type:1=CS5530,2=SC1400 */ - - EntityInfoPtr pEnt; - ScreenBlockHandlerProcPtr BlockHandler; /* needed for video */ - int DetectedChipSet; - int Chipset; - unsigned long FBLinearAddr; - unsigned char *FBBase; - unsigned long FBSize; - unsigned int cpu_reg_size; - unsigned int gp_reg_size; - unsigned int vid_reg_size; - int Pitch; - Bool HWCursor; - Bool NoAccel; - unsigned long VideoKey; - - Bool TVSupport; +typedef struct __TVTIMING { + unsigned long HorzTim; + unsigned long HorzSync; + unsigned long VertSync; + unsigned long LineEnd; + unsigned long VertDownscale; + unsigned long HorzScaling; + unsigned long TimCtrl1; + unsigned long TimCtrl2; + unsigned long Subfreq; + unsigned long DispPos; + unsigned long DispSize; + unsigned long Debug; + unsigned long DacCtrl; + unsigned int DotClock; +} TVTIMING, *PTVTIMING; + +#endif /* STB_X */ + +typedef struct _VESARec { + xf86Int10InfoPtr pInt; +} VESARec, *VESAPtr; + +typedef struct { + /* Private struct for the server */ + unsigned long cpu_version; /* [7:0] Type:1=GXLV,2=SC1400 */ + /* [15:8] Major version */ + /* [23:16] Minor version */ + unsigned long vid_version; /* [7:0] Type:1=CS5530,2=SC1400 */ + + EntityInfoPtr pEnt; + ScreenBlockHandlerProcPtr BlockHandler; /* needed for video */ + int DetectedChipSet; + int Chipset; + unsigned long FBLinearAddr; + unsigned char *FBBase; + unsigned long FBSize; + unsigned int cpu_reg_size; + unsigned int gp_reg_size; + unsigned int vid_reg_size; + int Pitch; + Bool HWCursor; + Bool NoAccel; + unsigned long VideoKey; + + Bool TVSupport; #if defined(STB_X) - GAL_TVPARAMS TvParam; + GAL_TVPARAMS TvParam; #else - TVPARAMS TvParam; -#endif /* STB_X */ - - int TVOx, TVOy, TVOw, TVOh; - Bool TV_Overscan_On; - - Bool Panel; - - /* Flatpanel support from Bios */ - int FPBX; /* xres */ - int FPBY; /* yres */ - int FPBB; /* bpp */ - int FPBF; /* freq */ - - int Rotate; - Bool ShadowFB; - unsigned char *ShadowPtr; - int ShadowPitch; - void (*PointerMoved) (int index, int x, int y); - /* CloseScreen function. */ - CloseScreenProcPtr CloseScreen; - - Bool Compression; - unsigned int CBOffset; - unsigned int CBPitch; - unsigned int CBSize; - unsigned long CursorStartOffset; - unsigned int CursorSize; - xf86CursorInfoPtr CursorInfo; - int CursorXHot; - int CursorYHot; - unsigned long OffscreenStartOffset; - unsigned int OffscreenSize; - - /***Image Write structures ***/ - - /* offset in video memory for ImageWrite Buffers */ - unsigned char **AccelImageWriteBufferOffsets; - int NoOfImgBuffers; - FBAreaPtr CompressionArea; - FBAreaPtr AccelImgArea; + TVPARAMS TvParam; +#endif /* STB_X */ + + int TVOx, TVOy, TVOw, TVOh; + Bool TV_Overscan_On; + + Bool Panel; + + /* Flatpanel support from Bios */ + int FPBX; /* xres */ + int FPBY; /* yres */ + int FPBB; /* bpp */ + int FPBF; /* freq */ + + int Rotate; + Bool ShadowFB; + unsigned char *ShadowPtr; + int ShadowPitch; + void (*PointerMoved) (int index, int x, int y); + /* CloseScreen function. */ + CloseScreenProcPtr CloseScreen; + + Bool Compression; + unsigned int CBOffset; + unsigned int CBPitch; + unsigned int CBSize; + unsigned long CursorStartOffset; + unsigned int CursorSize; + xf86CursorInfoPtr CursorInfo; + int CursorXHot; + int CursorYHot; + unsigned long OffscreenStartOffset; + unsigned int OffscreenSize; + + /***Image Write structures ***/ + + /* offset in video memory for ImageWrite Buffers */ + unsigned char **AccelImageWriteBufferOffsets; + int NoOfImgBuffers; + FBAreaPtr CompressionArea; + FBAreaPtr AccelImgArea; /*****************************************/ /* Saved Console State */ #if defined(STB_X) - GAL_VGAMODEDATA FBgfxVgaRegs; - GAL_DISPLAYTIMING FBgfxdisplaytiming; - GAL_TVTIMING FBgfxtvtiming; + GAL_VGAMODEDATA FBgfxVgaRegs; + GAL_DISPLAYTIMING FBgfxdisplaytiming; + GAL_TVTIMING FBgfxtvtiming; #else - gfx_vga_struct FBgfxVgaRegs; - DISPLAYTIMING FBgfxdisplaytiming; - TVTIMING FBtvtiming; -#endif /* STB_X */ - int FBVGAActive; - unsigned int FBTVActive; - unsigned int FBTVEnabled; - unsigned long FBDisplayOffset; - - VESAPtr vesa; - - /* compression */ - int FBCompressionEnable; - unsigned long FBCompressionOffset; - unsigned short FBCompressionPitch; - unsigned short FBCompressionSize; - - /* Save the Cursor offset of the FB */ - unsigned long FBCursorOffset; + gfx_vga_struct FBgfxVgaRegs; + DISPLAYTIMING FBgfxdisplaytiming; + TVTIMING FBtvtiming; +#endif /* STB_X */ + int FBVGAActive; + unsigned int FBTVActive; + unsigned int FBTVEnabled; + unsigned long FBDisplayOffset; + + VESAPtr vesa; + + /* compression */ + int FBCompressionEnable; + unsigned long FBCompressionOffset; + unsigned short FBCompressionPitch; + unsigned short FBCompressionSize; + + /* Save the Cursor offset of the FB */ + unsigned long FBCursorOffset; /*****************************************/ - XAAInfoRecPtr AccelInfoRec; + XAAInfoRecPtr AccelInfoRec; - DGAModePtr DGAModes; - int numDGAModes; - Bool DGAactive; - int DGAViewportStatus; + DGAModePtr DGAModes; + int numDGAModes; + Bool DGAactive; + int DGAViewportStatus; /*****************************************/ - 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; - XF86VideoAdaptorPtr adaptor; - int OverlaySkewX; - int OverlaySkewY; - int VideoZoomMax; -} -GeodeRec, *GeodePtr; + 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; + XF86VideoAdaptorPtr adaptor; + int OverlaySkewX; + int OverlaySkewY; + int VideoZoomMax; +} GeodeRec, *GeodePtr; /* option flags are self-explanatory */ -typedef enum -{ - OPTION_SW_CURSOR, - OPTION_HW_CURSOR, - OPTION_NOCOMPRESSION, - OPTION_NOACCEL, - OPTION_TV_SUPPORT, - OPTION_TV_OUTPUT, - OPTION_TV_OVERSCAN, - OPTION_SHADOW_FB, - OPTION_ROTATE, - OPTION_FLATPANEL, - OPTION_FLATPANEL_INFO, - OPTION_FLATPANEL_IN_BIOS, - OPTION_COLOR_KEY, - OPTION_OSM, - OPTION_OSM_IMG_BUFS, - OPTION_DONT_PROGRAM -} -GeodeOpts; - -#endif /* _NSC_GEODE_H_ */ +typedef enum { + OPTION_SW_CURSOR, + OPTION_HW_CURSOR, + OPTION_NOCOMPRESSION, + OPTION_NOACCEL, + OPTION_TV_SUPPORT, + OPTION_TV_OUTPUT, + OPTION_TV_OVERSCAN, + OPTION_SHADOW_FB, + OPTION_ROTATE, + OPTION_FLATPANEL, + OPTION_FLATPANEL_INFO, + OPTION_FLATPANEL_IN_BIOS, + OPTION_COLOR_KEY, + OPTION_OSM, + OPTION_OSM_IMG_BUFS, + OPTION_DONT_PROGRAM +} GeodeOpts; + +#endif /* _NSC_GEODE_H_ */ diff --git a/src/nsc_driver.c b/src/nsc_driver.c index a882f89..ae6b24c 100644 --- a/src/nsc_driver.c +++ b/src/nsc_driver.c @@ -186,7 +186,7 @@ #ifdef XFreeXDGA #define _XF86_DGA_SERVER_ #include <X11/extensions/xf86dgaproto.h> -#endif /* XFreeXDGA */ +#endif /* XFreeXDGA */ #include "globals.h" #include "opaque.h" @@ -234,19 +234,19 @@ extern void GX2SetupChipsetFPtr(ScrnInfoPtr pScrn); #if !defined(STB_X) extern unsigned char *XpressROMPtr; -#endif /* STB_X */ +#endif /* STB_X */ /* driver record contains the functions needed by the server after loading * the driver module. */ _X_EXPORT DriverRec NSC = { - NSC_VERSION_CURRENT, - NSC_DRIVER_NAME, - NscIdentify, - NscProbe, - NscAvailableOptions, - NULL, - 0 + NSC_VERSION_CURRENT, + NSC_DRIVER_NAME, + NscIdentify, + NscProbe, + NscAvailableOptions, + NULL, + 0 }; /* Existing Processor Models */ @@ -264,110 +264,108 @@ _X_EXPORT DriverRec NSC = { #define PCI_CHIP_REDCLOUD 0x0030 /* National Chip Models */ -typedef struct _DEVICE_MODEL -{ - int DeviceId; - int Model; -} -DeviceModel; +typedef struct _DEVICE_MODEL { + int DeviceId; + int Model; +} DeviceModel; DeviceModel ChipModel[] = { - {PCI_CHIP_5530, GX1}, - {PCI_CHIP_SC1200, GX1}, - {PCI_CHIP_SC1400, GX1}, - {PCI_CHIP_REDCLOUD, GX2}, - {-1, 0} + {PCI_CHIP_5530, GX1}, + {PCI_CHIP_SC1200, GX1}, + {PCI_CHIP_SC1400, GX1}, + {PCI_CHIP_REDCLOUD, GX2}, + {-1, 0} }; /* Supported chipsets */ SymTabRec GeodeChipsets[] = { - {PCI_CHIP_5530, "5530"}, - {PCI_CHIP_SC1200, "SC1200"}, - {PCI_CHIP_SC1400, "SC1400"}, - {PCI_CHIP_REDCLOUD, "REDCLOUD"}, - {-1, NULL} + {PCI_CHIP_5530, "5530"}, + {PCI_CHIP_SC1200, "SC1200"}, + {PCI_CHIP_SC1400, "SC1400"}, + {PCI_CHIP_REDCLOUD, "REDCLOUD"}, + {-1, NULL} }; PciChipsets GeodePCIchipsets[] = { - {PCI_CHIP_5530, PCI_CHIP_5530, RES_SHARED_VGA}, - {PCI_CHIP_SC1200, PCI_CHIP_SC1200, RES_SHARED_VGA}, - {PCI_CHIP_SC1400, PCI_CHIP_SC1400, RES_SHARED_VGA}, - {PCI_CHIP_REDCLOUD, PCI_CHIP_REDCLOUD, RES_SHARED_VGA}, - {-1, -1, RES_UNDEFINED}, + {PCI_CHIP_5530, PCI_CHIP_5530, RES_SHARED_VGA}, + {PCI_CHIP_SC1200, PCI_CHIP_SC1200, RES_SHARED_VGA}, + {PCI_CHIP_SC1400, PCI_CHIP_SC1400, RES_SHARED_VGA}, + {PCI_CHIP_REDCLOUD, PCI_CHIP_REDCLOUD, RES_SHARED_VGA}, + {-1, -1, RES_UNDEFINED}, }; OptionInfoRec GeodeOptions[] = { - {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_NOCOMPRESSION, "NoCompression", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_TV_SUPPORT, "TV", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_TV_OUTPUT, "TV_Output", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_TV_OVERSCAN, "TVOverscan", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_FLATPANEL, "FlatPanel", OPTV_BOOLEAN, {0}, FALSE}, - {OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, FALSE}, - {OPTION_OSM_IMG_BUFS, "OSMImageBuffers", OPTV_INTEGER, {0}, FALSE}, - {-1, NULL, OPTV_NONE, {0}, FALSE} + {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_NOCOMPRESSION, "NoCompression", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_TV_SUPPORT, "TV", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_TV_OUTPUT, "TV_Output", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_TV_OVERSCAN, "TVOverscan", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE}, + {OPTION_FLATPANEL, "FlatPanel", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, FALSE}, + {OPTION_OSM_IMG_BUFS, "OSMImageBuffers", OPTV_INTEGER, {0}, FALSE}, + {-1, NULL, OPTV_NONE, {0}, FALSE} }; /* List of symbols from other modules that this module references.The purpose * is that to avoid unresolved symbol warnings */ const char *nscVgahwSymbols[] = { - "vgaHWGetHWRec", - "vgaHWUnlock", - "vgaHWInit", - "vgaHWSave", - "vgaHWRestore", - "vgaHWProtect", - "vgaHWGetIOBase", - "vgaHWMapMem", - "vgaHWLock", - "vgaHWFreeHWRec", - "vgaHWSaveScreen", - NULL + "vgaHWGetHWRec", + "vgaHWUnlock", + "vgaHWInit", + "vgaHWSave", + "vgaHWRestore", + "vgaHWProtect", + "vgaHWGetIOBase", + "vgaHWMapMem", + "vgaHWLock", + "vgaHWFreeHWRec", + "vgaHWSaveScreen", + NULL }; const char *nscVbeSymbols[] = { - "VBEInit", - "vbeDoEDID", - "vbeFree", - NULL + "VBEInit", + "vbeDoEDID", + "vbeFree", + NULL }; const char *nscInt10Symbols[] = { - "xf86ExecX86int10", - "xf86InitInt10", - "xf86Int10AllocPages", - "xf86Int10Addr", - NULL + "xf86ExecX86int10", + "xf86InitInt10", + "xf86Int10AllocPages", + "xf86Int10Addr", + NULL }; const char *nscFbSymbols[] = { - "fbScreenInit", - "fbPictureInit", - NULL + "fbScreenInit", + "fbPictureInit", + NULL }; const char *nscXaaSymbols[] = { - "XAADestroyInfoRec", - "XAACreateInfoRec", - "XAAInit", - NULL + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + NULL }; const char *nscRamdacSymbols[] = { - "xf86InitCursor", - "xf86CreateCursorInfoRec", - "xf86DestroyCursorInfoRec", - NULL + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL }; const char *nscShadowSymbols[] = { - "ShadowFBInit", - NULL + "ShadowFBInit", + NULL }; #ifdef XFree86LOADER @@ -377,16 +375,16 @@ const char *nscShadowSymbols[] = { static MODULESETUPPROTO(NscSetup); static XF86ModuleVersionInfo NscVersionRec = { - "nsc", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - NSC_VERSION_MAJOR, NSC_VERSION_MINOR, NSC_PATCHLEVEL, - ABI_CLASS_VIDEODRV, /* This is a video driver */ - ABI_VIDEODRV_VERSION, - MOD_CLASS_VIDEODRV, - {0, 0, 0, 0} + "nsc", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + NSC_VERSION_MAJOR, NSC_VERSION_MINOR, NSC_PATCHLEVEL, + ABI_CLASS_VIDEODRV, /* This is a video driver */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} }; /* @@ -416,27 +414,27 @@ _X_EXPORT XF86ModuleData nscModuleData = { &NscVersionRec, NscSetup, NULL }; static pointer NscSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) { - static Bool Initialised = FALSE; - - if (!Initialised) { - Initialised = TRUE; - xf86AddDriver(&NSC, Module, 0); - /* Tell the loader about symbols from other modules that this - * module might refer to. - */ - LoaderRefSymLists(nscVgahwSymbols, nscVbeSymbols, - nscFbSymbols, - nscXaaSymbols, - nscInt10Symbols, nscRamdacSymbols, nscShadowSymbols, - NULL); - return (pointer) TRUE; - } - /*The return value must be non-NULL on success */ - if (ErrorMajor) - *ErrorMajor = LDR_ONCEONLY; - return NULL; + static Bool Initialised = FALSE; + + if (!Initialised) { + Initialised = TRUE; + xf86AddDriver(&NSC, Module, 0); + /* Tell the loader about symbols from other modules that this + * module might refer to. + */ + LoaderRefSymLists(nscVgahwSymbols, nscVbeSymbols, + nscFbSymbols, + nscXaaSymbols, + nscInt10Symbols, nscRamdacSymbols, nscShadowSymbols, + NULL); + return (pointer) TRUE; + } + /*The return value must be non-NULL on success */ + if (ErrorMajor) + *ErrorMajor = LDR_ONCEONLY; + return NULL; } -#endif /*End of XFree86Loader */ +#endif /*End of XFree86Loader */ /*------------------------------------------------------------------------- * NscIdentify. @@ -456,9 +454,9 @@ NscSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) static void NscIdentify(int flags) { - xf86PrintChipsets(NSC_NAME, - "Nsc family driver (version " NSC_VERSION_NAME ") " - "for chipsets", GeodeChipsets); + xf86PrintChipsets(NSC_NAME, + "Nsc family driver (version " NSC_VERSION_NAME ") " + "for chipsets", GeodeChipsets); } /*---------------------------------------------------------------------------- @@ -479,7 +477,7 @@ NscIdentify(int flags) static const OptionInfoRec * NscAvailableOptions(int chipid, int busid) { - return GeodeOptions; + return GeodeOptions; } /*---------------------------------------------------------------------------- @@ -504,91 +502,93 @@ NscAvailableOptions(int chipid, int busid) static Bool NscProbe(DriverPtr drv, int flags) { - Bool foundScreen = FALSE; - int numDevSections, numUsed; - GDevPtr *devSections = NULL; - int *usedChips = NULL; - int i; - - GeodeDebug(("NscProbe: Probing for supported devices!\n")); - /* - * * Find the config file Device sections that match this - * * driver, and return if there are none. - */ - if ((numDevSections = xf86MatchDevice(NSC_NAME, &devSections)) <= 0) { - GeodeDebug(("NscProbe: failed 1!\n")); - return FALSE; - } - GeodeDebug(("NscProbe: Before MatchPciInstances!\n")); - /* PCI BUS */ + Bool foundScreen = FALSE; + int numDevSections, numUsed; + GDevPtr *devSections = NULL; + int *usedChips = NULL; + int i; + + GeodeDebug(("NscProbe: Probing for supported devices!\n")); + /* + * * Find the config file Device sections that match this + * * driver, and return if there are none. + */ + if ((numDevSections = xf86MatchDevice(NSC_NAME, &devSections)) <= 0) { + GeodeDebug(("NscProbe: failed 1!\n")); + return FALSE; + } + GeodeDebug(("NscProbe: Before MatchPciInstances!\n")); + /* PCI BUS */ #ifndef XSERVER_LIBPCIACCESS - if (xf86GetPciVideoInfo()) { + if (xf86GetPciVideoInfo()) { #endif - numUsed = xf86MatchPciInstances(NSC_NAME, PCI_VENDOR_ID_NS, - GeodeChipsets, GeodePCIchipsets, - devSections, numDevSections, - drv, &usedChips); - if (numUsed <= 0) { - /* Check for old CYRIX vendor ID (5530) */ - numUsed = xf86MatchPciInstances(NSC_NAME, - PCI_VENDOR_ID_CYRIX, - GeodeChipsets, GeodePCIchipsets, - devSections, numDevSections, - drv, &usedChips); - } - - GeodeDebug(("NscProbe: MatchPCI (%d)!\n", numUsed)); - - if (numUsed > 0) { - if (flags & PROBE_DETECT) - foundScreen = TRUE; - else { - /* Durango only supports one instance, */ - /* so take the first one */ - for (i = 0; i < numUsed; i++) { - /* Allocate a ScrnInfoRec */ - ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); - - EntityInfoPtr pEnt = xf86GetEntityInfo(usedChips[i]); - PciChipsets *p_id; - - for (p_id = GeodePCIchipsets; p_id->numChipset != -1; p_id++) { - if (pEnt->chipset == p_id->numChipset) { - CPUDetected = GX1; - if (pEnt->chipset == PCI_CHIP_REDCLOUD) - CPUDetected = GX2; - break; - } - } - free(pEnt); - GeodeDebug(("NscProbe: CPUDetected %d!\n", CPUDetected)); - - pScrn->driverName = NSC_DRIVER_NAME; - pScrn->name = NSC_NAME; - pScrn->Probe = NscProbe; - - if (CPUDetected == GX1) { - GX1SetupChipsetFPtr(pScrn); - } else { /* GX2 */ - GX2SetupChipsetFPtr(pScrn); - } - - foundScreen = TRUE; - xf86ConfigActivePciEntity(pScrn, - usedChips[i], - GeodePCIchipsets, - NULL, NULL, NULL, NULL, NULL); - } - } - } + numUsed = xf86MatchPciInstances(NSC_NAME, PCI_VENDOR_ID_NS, + GeodeChipsets, GeodePCIchipsets, + devSections, numDevSections, + drv, &usedChips); + if (numUsed <= 0) { + /* Check for old CYRIX vendor ID (5530) */ + numUsed = xf86MatchPciInstances(NSC_NAME, + PCI_VENDOR_ID_CYRIX, + GeodeChipsets, GeodePCIchipsets, + devSections, numDevSections, + drv, &usedChips); + } + + GeodeDebug(("NscProbe: MatchPCI (%d)!\n", numUsed)); + + if (numUsed > 0) { + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else { + /* Durango only supports one instance, */ + /* so take the first one */ + for (i = 0; i < numUsed; i++) { + /* Allocate a ScrnInfoRec */ + ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); + + EntityInfoPtr pEnt = xf86GetEntityInfo(usedChips[i]); + PciChipsets *p_id; + + for (p_id = GeodePCIchipsets; p_id->numChipset != -1; + p_id++) { + if (pEnt->chipset == p_id->numChipset) { + CPUDetected = GX1; + if (pEnt->chipset == PCI_CHIP_REDCLOUD) + CPUDetected = GX2; + break; + } + } + free(pEnt); + GeodeDebug(("NscProbe: CPUDetected %d!\n", CPUDetected)); + + pScrn->driverName = NSC_DRIVER_NAME; + pScrn->name = NSC_NAME; + pScrn->Probe = NscProbe; + + if (CPUDetected == GX1) { + GX1SetupChipsetFPtr(pScrn); + } + else { /* GX2 */ + GX2SetupChipsetFPtr(pScrn); + } + + foundScreen = TRUE; + xf86ConfigActivePciEntity(pScrn, + usedChips[i], + GeodePCIchipsets, + NULL, NULL, NULL, NULL, NULL); + } + } + } #ifndef XSERVER_LIBPCIACCESS - } + } #endif - if (usedChips) - free(usedChips); - if (devSections) - free(devSections); - GeodeDebug(("NscProbe: result (%d)!\n", foundScreen)); - return foundScreen; + if (usedChips) + free(usedChips); + if (devSections) + free(devSections); + GeodeDebug(("NscProbe: result (%d)!\n", foundScreen)); + return foundScreen; } diff --git a/src/nsc_galfns.c b/src/nsc_galfns.c index be28673..0b5f89c 100644 --- a/src/nsc_galfns.c +++ b/src/nsc_galfns.c @@ -190,24 +190,24 @@ create_devicenode() { #if 1 - FILE *pfdevices; - char line[200], devname[200]; - int majdev; - - /* remove fails if device is open */ - remove("/dev/nscgal"); - - if ((pfdevices = fopen("/proc/devices", "r"))) { - while (fgets(line, sizeof(line), pfdevices)) { - if (sscanf(line, "%d%*[ \t]%s", &majdev, devname) == 2) { - if (strstr(devname, "nscgal")) - mknod("/dev/nscgal", S_IFCHR | S_IRUSR | S_IWUSR, - makedev(majdev, 0)); - } - } - fclose(pfdevices); - } - return 1; + FILE *pfdevices; + char line[200], devname[200]; + int majdev; + + /* remove fails if device is open */ + remove("/dev/nscgal"); + + if ((pfdevices = fopen("/proc/devices", "r"))) { + while (fgets(line, sizeof(line), pfdevices)) { + if (sscanf(line, "%d%*[ \t]%s", &majdev, devname) == 2) { + if (strstr(devname, "nscgal")) + mknod("/dev/nscgal", S_IFCHR | S_IRUSR | S_IWUSR, + makedev(majdev, 0)); + } + } + fclose(pfdevices); + } + return 1; #endif } @@ -226,10 +226,10 @@ Gal_initialize_interface() { /* create_devicenode(); */ - if ((ifbdev_handle = open("/dev/fb0", O_RDONLY)) == -1) + if ((ifbdev_handle = open("/dev/fb0", O_RDONLY)) == -1) /* if ((ifbdev_handle = open("FBDEV_NAME", O_RDONLY)) == -1) */ - return 0; - return 1; + return 0; + return 1; } /*------------------------------------------------------------------------ @@ -243,9 +243,9 @@ Gal_initialize_interface() BOOLEAN Gal_cleanup_interface() { - if (ifbdev_handle != -1) - close(ifbdev_handle); - return 1; + if (ifbdev_handle != -1) + close(ifbdev_handle); + return 1; } /*--------------------------------------------------------------------------- @@ -263,21 +263,21 @@ Gal_cleanup_interface() *-------------------------------------------------------------------------*/ BOOLEAN Gal_write_register(int type, unsigned long offset, unsigned long value, - int size) + int size) { - GAL_HWACCESS hwAccess; + GAL_HWACCESS hwAccess; - INIT_GAL(&hwAccess); - hwAccess.dwSubfunction = GALFN_WRITEREG; - hwAccess.dwType = type; - hwAccess.dwOffset = offset; - hwAccess.dwValue = value; - hwAccess.dwByteCount = size; - if (ioctl(ifbdev_handle, FBIOGAL_API, &hwAccess)) - return 0; - else { - return 1; - } + INIT_GAL(&hwAccess); + hwAccess.dwSubfunction = GALFN_WRITEREG; + hwAccess.dwType = type; + hwAccess.dwOffset = offset; + hwAccess.dwValue = value; + hwAccess.dwByteCount = size; + if (ioctl(ifbdev_handle, FBIOGAL_API, &hwAccess)) + return 0; + else { + return 1; + } } /*--------------------------------------------------------------------------- @@ -296,22 +296,22 @@ Gal_write_register(int type, unsigned long offset, unsigned long value, *-------------------------------------------------------------------------*/ BOOLEAN Gal_read_register(int type, unsigned long offset, unsigned long *value, - int size) + int size) { - GAL_HWACCESS hwAccess; + GAL_HWACCESS hwAccess; - INIT_GAL(&hwAccess); - hwAccess.dwSubfunction = GALFN_READREG; - hwAccess.dwType = type; - hwAccess.dwOffset = offset; - hwAccess.dwByteCount = size; + INIT_GAL(&hwAccess); + hwAccess.dwSubfunction = GALFN_READREG; + hwAccess.dwType = type; + hwAccess.dwOffset = offset; + hwAccess.dwByteCount = size; - if (ioctl(ifbdev_handle, FBIOGAL_API, &hwAccess)) - return 0; - else { - *value = hwAccess.dwValue; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &hwAccess)) + return 0; + else { + *value = hwAccess.dwValue; + return 1; + } } /*--------------------------------------------------------------------------- @@ -327,15 +327,15 @@ Gal_read_register(int type, unsigned long offset, unsigned long *value, BOOLEAN Gal_get_adapter_info(PGAL_ADAPTERINFO pAdapterInfo) { - INIT_GAL(pAdapterInfo); + INIT_GAL(pAdapterInfo); - pAdapterInfo->dwSubfunction = GALFN_GETADAPTERINFO; + pAdapterInfo->dwSubfunction = GALFN_GETADAPTERINFO; - if (ioctl(ifbdev_handle, FBIOGAL_API, pAdapterInfo)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pAdapterInfo)) + return 0; + else { + return 1; + } } /*--------------------------------------------------------------------------- @@ -349,15 +349,15 @@ Gal_get_adapter_info(PGAL_ADAPTERINFO pAdapterInfo) BOOLEAN Gal_set_softvga_state(BOOLEAN bEnable) { - GAL_SOFTVGASTATE sSoftVgaState; + GAL_SOFTVGASTATE sSoftVgaState; - INIT_GAL(&sSoftVgaState); - sSoftVgaState.dwSubfunction = GALFN_SETSOFTVGASTATE; - sSoftVgaState.bSoftVgaEnable = bEnable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSoftVgaState)) - return 0; - else - return 1; + INIT_GAL(&sSoftVgaState); + sSoftVgaState.dwSubfunction = GALFN_SETSOFTVGASTATE; + sSoftVgaState.bSoftVgaEnable = bEnable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSoftVgaState)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -371,16 +371,16 @@ Gal_set_softvga_state(BOOLEAN bEnable) BOOLEAN Gal_get_softvga_state(int *bState) { - GAL_SOFTVGASTATE sSoftVgaState; + GAL_SOFTVGASTATE sSoftVgaState; - INIT_GAL(&sSoftVgaState); - sSoftVgaState.dwSubfunction = GALFN_GETSOFTVGASTATE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSoftVgaState)) - return 0; - else { - *bState = sSoftVgaState.bSoftVgaEnable; - return 1; - } + INIT_GAL(&sSoftVgaState); + sSoftVgaState.dwSubfunction = GALFN_GETSOFTVGASTATE; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSoftVgaState)) + return 0; + else { + *bState = sSoftVgaState.bSoftVgaEnable; + return 1; + } } /*--------------------------------------------------------------------------- @@ -394,16 +394,16 @@ Gal_get_softvga_state(int *bState) BOOLEAN Gal_vga_test_pci(int *softvga) { - GAL_VGATESTPCI sVgatestpci; + GAL_VGATESTPCI sVgatestpci; - INIT_GAL(&sVgatestpci); - sVgatestpci.dwSubfunction = GALFN_GETSOFTVGASTATE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgatestpci)) - return 0; - else { - *softvga = sVgatestpci.softvga; - return 1; - } + INIT_GAL(&sVgatestpci); + sVgatestpci.dwSubfunction = GALFN_GETSOFTVGASTATE; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgatestpci)) + return 0; + else { + *softvga = sVgatestpci.softvga; + return 1; + } } /*--------------------------------------------------------------------------- @@ -417,16 +417,16 @@ Gal_vga_test_pci(int *softvga) BOOLEAN Gal_vga_get_pci_command(unsigned char *value) { - GAL_VGAGETPCICOMMAND sVgagetpcicommand; + GAL_VGAGETPCICOMMAND sVgagetpcicommand; - INIT_GAL(&sVgagetpcicommand); - sVgagetpcicommand.dwSubfunction = GALFN_VGAGETPCICOMMAND; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgagetpcicommand)) - return 0; - else { - *value = sVgagetpcicommand.value; - return 1; - } + INIT_GAL(&sVgagetpcicommand); + sVgagetpcicommand.dwSubfunction = GALFN_VGAGETPCICOMMAND; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgagetpcicommand)) + return 0; + else { + *value = sVgagetpcicommand.value; + return 1; + } } /*--------------------------------------------------------------------------- @@ -440,17 +440,17 @@ Gal_vga_get_pci_command(unsigned char *value) BOOLEAN Gal_vga_seq_reset(int reset) { - GAL_VGASEQRESET sVgaseqreset; + GAL_VGASEQRESET sVgaseqreset; - INIT_GAL(&sVgaseqreset); - sVgaseqreset.dwSubfunction = GALFN_VGASEQRESET; - sVgaseqreset.reset = reset; + INIT_GAL(&sVgaseqreset); + sVgaseqreset.dwSubfunction = GALFN_VGASEQRESET; + sVgaseqreset.reset = reset; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgaseqreset)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgaseqreset)) + return 0; + else { + return 1; + } } /*--------------------------------------------------------------------------- @@ -464,16 +464,16 @@ Gal_vga_seq_reset(int reset) BOOLEAN Gal_vga_set_graphics_bits(void) { - GAL_VGASETGRAPHICSBITS sVgasetgraphics; + GAL_VGASETGRAPHICSBITS sVgasetgraphics; - INIT_GAL(&sVgasetgraphics); - sVgasetgraphics.dwSubfunction = GALFN_VGASETGRAPHICSBITS; + INIT_GAL(&sVgasetgraphics); + sVgasetgraphics.dwSubfunction = GALFN_VGASETGRAPHICSBITS; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgasetgraphics)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgasetgraphics)) + return 0; + else { + return 1; + } } /*--------------------------------------------------------------------------- @@ -487,15 +487,15 @@ Gal_vga_set_graphics_bits(void) BOOLEAN Gal_set_crt_enable(int crtEnable) { - GAL_CRTENABLE sCrtEnable; + GAL_CRTENABLE sCrtEnable; - INIT_GAL(&sCrtEnable); - sCrtEnable.dwSubfunction = GALFN_SETCRTENABLE; - sCrtEnable.wCrtEnable = crtEnable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCrtEnable)) - return 0; - else - return 1; + INIT_GAL(&sCrtEnable); + sCrtEnable.dwSubfunction = GALFN_SETCRTENABLE; + sCrtEnable.wCrtEnable = crtEnable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCrtEnable)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -511,24 +511,24 @@ Gal_set_crt_enable(int crtEnable) *-------------------------------------------------------------------------*/ BOOLEAN Gal_is_display_mode_supported(int xres, int yres, int bpp, int hz, - int *supported) + int *supported) { - GAL_DISPLAYMODE sDisplayMode; + GAL_DISPLAYMODE sDisplayMode; - *supported = 0; - INIT_GAL(&sDisplayMode); - sDisplayMode.dwSubfunction = GALFN_ISDISPLAYMODESUPPORTED; - sDisplayMode.wXres = xres; - sDisplayMode.wYres = yres; - sDisplayMode.wBpp = bpp; - sDisplayMode.wRefresh = hz; + *supported = 0; + INIT_GAL(&sDisplayMode); + sDisplayMode.dwSubfunction = GALFN_ISDISPLAYMODESUPPORTED; + sDisplayMode.wXres = xres; + sDisplayMode.wYres = yres; + sDisplayMode.wBpp = bpp; + sDisplayMode.wRefresh = hz; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayMode)) - return 0; - else { - *supported = sDisplayMode.dwSupported; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayMode)) + return 0; + else { + *supported = sDisplayMode.dwSupported; + return 1; + } } /*--------------------------------------------------------------------------- @@ -545,19 +545,19 @@ Gal_is_display_mode_supported(int xres, int yres, int bpp, int hz, BOOLEAN Gal_set_display_mode(int xres, int yres, int bpp, int hz) { - GAL_DISPLAYMODE sDisplayMode; + GAL_DISPLAYMODE sDisplayMode; - INIT_GAL(&sDisplayMode); - sDisplayMode.dwSubfunction = GALFN_SETDISPLAYMODE; - sDisplayMode.wXres = xres; - sDisplayMode.wYres = yres; - sDisplayMode.wBpp = bpp; - sDisplayMode.wRefresh = hz; + INIT_GAL(&sDisplayMode); + sDisplayMode.dwSubfunction = GALFN_SETDISPLAYMODE; + sDisplayMode.wXres = xres; + sDisplayMode.wYres = yres; + sDisplayMode.wBpp = bpp; + sDisplayMode.wRefresh = hz; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayMode)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayMode)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -574,19 +574,19 @@ Gal_set_display_mode(int xres, int yres, int bpp, int hz) BOOLEAN Gal_get_display_mode(int *xres, int *yres, int *bpp, int *hz) { - GAL_DISPLAYMODE sDisplayMode; + GAL_DISPLAYMODE sDisplayMode; - INIT_GAL(&sDisplayMode); - sDisplayMode.dwSubfunction = GALFN_GETDISPLAYMODE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayMode)) - return 0; - else { - *xres = sDisplayMode.wXres; - *yres = sDisplayMode.wYres; - *bpp = sDisplayMode.wBpp; - *hz = sDisplayMode.wRefresh; - return 1; - } + INIT_GAL(&sDisplayMode); + sDisplayMode.dwSubfunction = GALFN_GETDISPLAYMODE; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayMode)) + return 0; + else { + *xres = sDisplayMode.wXres; + *yres = sDisplayMode.wYres; + *bpp = sDisplayMode.wBpp; + *hz = sDisplayMode.wRefresh; + return 1; + } } /*--------------------------------------------------------------------------- @@ -601,16 +601,16 @@ Gal_get_display_mode(int *xres, int *yres, int *bpp, int *hz) BOOLEAN Gal_set_display_bpp(unsigned short bpp) { - GAL_DISPLAYPARAMS sDisplayParams; + GAL_DISPLAYPARAMS sDisplayParams; - INIT_GAL(&sDisplayParams); - sDisplayParams.dwSubfunction = GALFN_SETDISPLAYBPP; - sDisplayParams.wBpp = bpp; + INIT_GAL(&sDisplayParams); + sDisplayParams.dwSubfunction = GALFN_SETDISPLAYBPP; + sDisplayParams.wBpp = bpp; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -625,16 +625,16 @@ Gal_set_display_bpp(unsigned short bpp) BOOLEAN Gal_set_bpp(unsigned short bpp) { - GAL_DISPLAYPARAMS sDisplayParams; + GAL_DISPLAYPARAMS sDisplayParams; - INIT_GAL(&sDisplayParams); - sDisplayParams.dwSubfunction = GALFN_SETBPP; - sDisplayParams.wBpp = bpp; + INIT_GAL(&sDisplayParams); + sDisplayParams.dwSubfunction = GALFN_SETBPP; + sDisplayParams.wBpp = bpp; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -649,17 +649,17 @@ Gal_set_bpp(unsigned short bpp) BOOLEAN Gal_get_display_bpp(unsigned short *bpp) { - GAL_DISPLAYPARAMS sDisplayParams; + GAL_DISPLAYPARAMS sDisplayParams; - INIT_GAL(&sDisplayParams); - sDisplayParams.dwSubfunction = GALFN_GETDISPLAYBPP; + INIT_GAL(&sDisplayParams); + sDisplayParams.dwSubfunction = GALFN_GETDISPLAYBPP; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) - return 0; - else { - *bpp = sDisplayParams.wBpp; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) + return 0; + else { + *bpp = sDisplayParams.wBpp; + return 1; + } } /*--------------------------------------------------------------------------- @@ -673,15 +673,15 @@ Gal_get_display_bpp(unsigned short *bpp) BOOLEAN Gal_set_display_pitch(unsigned short pitch) { - GAL_DISPLAYPARAMS sDisplayParams; + GAL_DISPLAYPARAMS sDisplayParams; - INIT_GAL(&sDisplayParams); - sDisplayParams.dwSubfunction = GALFN_SETDISPLAYPITCH; - sDisplayParams.wPitch = pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) - return 0; - else - return 1; + INIT_GAL(&sDisplayParams); + sDisplayParams.dwSubfunction = GALFN_SETDISPLAYPITCH; + sDisplayParams.wPitch = pitch; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -695,17 +695,17 @@ Gal_set_display_pitch(unsigned short pitch) BOOLEAN Gal_get_display_pitch(unsigned short *pitch) { - GAL_DISPLAYPARAMS sDisplayParams; + GAL_DISPLAYPARAMS sDisplayParams; - INIT_GAL(&sDisplayParams); - sDisplayParams.dwSubfunction = GALFN_GETDISPLAYPITCH; + INIT_GAL(&sDisplayParams); + sDisplayParams.dwSubfunction = GALFN_GETDISPLAYPITCH; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) - return 0; - else { - *pitch = sDisplayParams.wPitch; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) + return 0; + else { + *pitch = sDisplayParams.wPitch; + return 1; + } } /*--------------------------------------------------------------------------- @@ -719,16 +719,16 @@ Gal_get_display_pitch(unsigned short *pitch) BOOLEAN Gal_set_display_offset(unsigned long offset) { - GAL_DISPLAYPARAMS sDisplayParams; + GAL_DISPLAYPARAMS sDisplayParams; - INIT_GAL(&sDisplayParams); - sDisplayParams.dwSubfunction = GALFN_SETDISPLAYOFFSET; - sDisplayParams.dwOffset = offset; + INIT_GAL(&sDisplayParams); + sDisplayParams.dwSubfunction = GALFN_SETDISPLAYOFFSET; + sDisplayParams.dwOffset = offset; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -742,17 +742,17 @@ Gal_set_display_offset(unsigned long offset) BOOLEAN Gal_get_display_offset(unsigned long *offset) { - GAL_DISPLAYPARAMS sDisplayParams; + GAL_DISPLAYPARAMS sDisplayParams; - INIT_GAL(&sDisplayParams); - sDisplayParams.dwSubfunction = GALFN_GETDISPLAYOFFSET; + INIT_GAL(&sDisplayParams); + sDisplayParams.dwSubfunction = GALFN_GETDISPLAYOFFSET; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) - return 0; - else { - *offset = sDisplayParams.dwOffset; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDisplayParams)) + return 0; + else { + *offset = sDisplayParams.dwOffset; + return 1; + } } /*--------------------------------------------------------------------------- @@ -769,22 +769,22 @@ Gal_get_display_offset(unsigned long *offset) *-------------------------------------------------------------------------*/ BOOLEAN Gal_get_refreshrate_from_dotclock(int xres, int yres, int bpp, int *hz, - unsigned long frequency) + unsigned long frequency) { - GAL_DOTCLKTOREFRESH sDclkToRefresh; + GAL_DOTCLKTOREFRESH sDclkToRefresh; - INIT_GAL(&sDclkToRefresh); - sDclkToRefresh.dwSubfunction = GALFN_DOTCLKTOREFRESH; - sDclkToRefresh.wXres = xres; - sDclkToRefresh.wYres = yres; - sDclkToRefresh.wBpp = bpp; - sDclkToRefresh.dwDotClock = frequency; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sDclkToRefresh)) - return 0; - else { - *hz = sDclkToRefresh.wRefreshRate; - return 1; - } + INIT_GAL(&sDclkToRefresh); + sDclkToRefresh.dwSubfunction = GALFN_DOTCLKTOREFRESH; + sDclkToRefresh.wXres = xres; + sDclkToRefresh.wYres = yres; + sDclkToRefresh.wBpp = bpp; + sDclkToRefresh.dwDotClock = frequency; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sDclkToRefresh)) + return 0; + else { + *hz = sDclkToRefresh.wRefreshRate; + return 1; + } } /*--------------------------------------------------------------------------- @@ -798,14 +798,14 @@ Gal_get_refreshrate_from_dotclock(int xres, int yres, int bpp, int *hz, BOOLEAN Gal_get_display_timing(PGAL_DISPLAYTIMING pDisplayTiming) { - INIT_GAL(pDisplayTiming); - pDisplayTiming->dwSubfunction = GALFN_GETDISPLAYTIMINGS; + INIT_GAL(pDisplayTiming); + pDisplayTiming->dwSubfunction = GALFN_GETDISPLAYTIMINGS; - if (ioctl(ifbdev_handle, FBIOGAL_API, pDisplayTiming)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pDisplayTiming)) + return 0; + else { + return 1; + } } /*--------------------------------------------------------------------------- @@ -819,13 +819,13 @@ Gal_get_display_timing(PGAL_DISPLAYTIMING pDisplayTiming) BOOLEAN Gal_set_display_timing(PGAL_DISPLAYTIMING pDisplayTiming) { - INIT_GAL(pDisplayTiming); - pDisplayTiming->dwSubfunction = GALFN_SETDISPLAYTIMINGS; + INIT_GAL(pDisplayTiming); + pDisplayTiming->dwSubfunction = GALFN_SETDISPLAYTIMINGS; - if (ioctl(ifbdev_handle, FBIOGAL_API, pDisplayTiming)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, pDisplayTiming)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -843,22 +843,22 @@ Gal_set_display_timing(PGAL_DISPLAYTIMING pDisplayTiming) *-------------------------------------------------------------------------*/ BOOLEAN Gal_set_fixed_timings(int pnlXres, int pnlYres, int totXres, - int totYres, int bpp) + int totYres, int bpp) { - GAL_DISPLAYTIMING DisplayTiming; + GAL_DISPLAYTIMING DisplayTiming; - INIT_GAL(&DisplayTiming); - DisplayTiming.dwSubfunction = GALFN_SETFIXEDTIMINGS; - DisplayTiming.wHActive = pnlXres; /* panel Xres */ - DisplayTiming.wVActive = pnlYres; /* panel Yres */ - DisplayTiming.wHTotal = totXres; /* Total Xres */ - DisplayTiming.wVTotal = totYres; /* Total Yres */ - DisplayTiming.wBpp = bpp; + INIT_GAL(&DisplayTiming); + DisplayTiming.dwSubfunction = GALFN_SETFIXEDTIMINGS; + DisplayTiming.wHActive = pnlXres; /* panel Xres */ + DisplayTiming.wVActive = pnlYres; /* panel Yres */ + DisplayTiming.wHTotal = totXres; /* Total Xres */ + DisplayTiming.wVTotal = totYres; /* Total Yres */ + DisplayTiming.wBpp = bpp; - if (ioctl(ifbdev_handle, FBIOGAL_API, &DisplayTiming)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &DisplayTiming)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -874,17 +874,17 @@ Gal_set_fixed_timings(int pnlXres, int pnlYres, int totXres, BOOLEAN Gal_set_display_palette_entry(unsigned long index, unsigned long palette) { - GAL_PALETTE_ENTRY sPalette; + GAL_PALETTE_ENTRY sPalette; - INIT_GAL(&sPalette); - sPalette.dwSubfunction = GALFN_SETPALETTE_ENTRY; - sPalette.dwIndex = index; - sPalette.dwPalette = palette; + INIT_GAL(&sPalette); + sPalette.dwSubfunction = GALFN_SETPALETTE_ENTRY; + sPalette.dwIndex = index; + sPalette.dwPalette = palette; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sPalette)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sPalette)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -900,18 +900,18 @@ Gal_set_display_palette_entry(unsigned long index, unsigned long palette) BOOLEAN Gal_get_display_palette_entry(unsigned long index, unsigned long *palette) { - GAL_PALETTE_ENTRY sPalette; + GAL_PALETTE_ENTRY sPalette; - INIT_GAL(&sPalette); - sPalette.dwSubfunction = GALFN_GETPALETTE_ENTRY; - sPalette.dwIndex = index; + INIT_GAL(&sPalette); + sPalette.dwSubfunction = GALFN_GETPALETTE_ENTRY; + sPalette.dwIndex = index; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sPalette)) - return 0; - else { - *palette = sPalette.dwPalette; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sPalette)) + return 0; + else { + *palette = sPalette.dwPalette; + return 1; + } } /*--------------------------------------------------------------------------- @@ -926,13 +926,13 @@ Gal_get_display_palette_entry(unsigned long index, unsigned long *palette) BOOLEAN Gal_set_display_palette(PGAL_PALETTE pPalette) { - INIT_GAL(pPalette); - pPalette->dwSubfunction = GALFN_SETPALETTE; + INIT_GAL(pPalette); + pPalette->dwSubfunction = GALFN_SETPALETTE; - if (ioctl(ifbdev_handle, FBIOGAL_API, pPalette)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, pPalette)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -947,14 +947,14 @@ Gal_set_display_palette(PGAL_PALETTE pPalette) BOOLEAN Gal_get_display_palette(PGAL_PALETTE pPalette) { - INIT_GAL(pPalette); - pPalette->dwSubfunction = GALFN_GETPALETTE; + INIT_GAL(pPalette); + pPalette->dwSubfunction = GALFN_GETPALETTE; - if (ioctl(ifbdev_handle, FBIOGAL_API, pPalette)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pPalette)) + return 0; + else { + return 1; + } } /*--------------------------------------------------------------------------- @@ -967,15 +967,15 @@ Gal_get_display_palette(PGAL_PALETTE pPalette) BOOLEAN Gal_wait_until_idle(void) { - GAL_WAITUNTILIDLE sWaitIdle; + GAL_WAITUNTILIDLE sWaitIdle; - INIT_GAL(&sWaitIdle); - sWaitIdle.dwSubfunction = GALFN_WAITUNTILIDLE; + INIT_GAL(&sWaitIdle); + sWaitIdle.dwSubfunction = GALFN_WAITUNTILIDLE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sWaitIdle)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sWaitIdle)) + return 0; + else + return 1; } /*--------------------------------------------------------------------------- @@ -988,15 +988,15 @@ Gal_wait_until_idle(void) BOOLEAN Gal_wait_vertical_blank(void) { - GAL_WAITVERTICALBLANK sWaitVerticalBlank; + GAL_WAITVERTICALBLANK sWaitVerticalBlank; - INIT_GAL(&sWaitVerticalBlank); - sWaitVerticalBlank.dwSubfunction = GALFN_WAITVERTICALBLANK; + INIT_GAL(&sWaitVerticalBlank); + sWaitVerticalBlank.dwSubfunction = GALFN_WAITVERTICALBLANK; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sWaitVerticalBlank)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sWaitVerticalBlank)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1010,15 +1010,15 @@ Gal_wait_vertical_blank(void) BOOLEAN Gal_set_cursor_enable(int enable) { - GAL_CURSORENABLE sCursorEnable; + GAL_CURSORENABLE sCursorEnable; - INIT_GAL(&sCursorEnable); - sCursorEnable.dwSubfunction = GALFN_SETCURSORENABLE; - sCursorEnable.bCursorEnable = enable ? 1 : 0; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorEnable)) - return 0; - else - return 1; + INIT_GAL(&sCursorEnable); + sCursorEnable.dwSubfunction = GALFN_SETCURSORENABLE; + sCursorEnable.bCursorEnable = enable ? 1 : 0; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorEnable)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1035,22 +1035,22 @@ Gal_set_cursor_enable(int enable) *-------------------------------------------------------------------------*/ BOOLEAN Gal_set_cursor_position(unsigned long memoffset, - unsigned short xpos, unsigned short ypos, - unsigned short xhotspot, unsigned short yhotspot) + unsigned short xpos, unsigned short ypos, + unsigned short xhotspot, unsigned short yhotspot) { - GAL_CURSORPOSITION sCursorPos; + GAL_CURSORPOSITION sCursorPos; - INIT_GAL(&sCursorPos); - sCursorPos.dwSubfunction = GALFN_SETCURSORPOSITION; - sCursorPos.dwMemOffset = memoffset; - sCursorPos.wXPos = xpos; - sCursorPos.wYPos = ypos; - sCursorPos.wXHot = xhotspot; - sCursorPos.wYHot = yhotspot; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorPos)) - return 0; - else - return 1; + INIT_GAL(&sCursorPos); + sCursorPos.dwSubfunction = GALFN_SETCURSORPOSITION; + sCursorPos.dwMemOffset = memoffset; + sCursorPos.wXPos = xpos; + sCursorPos.wYPos = ypos; + sCursorPos.wXHot = xhotspot; + sCursorPos.wYHot = yhotspot; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorPos)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1067,23 +1067,23 @@ Gal_set_cursor_position(unsigned long memoffset, *-------------------------------------------------------------------------*/ BOOLEAN Gal_get_cursor_position(unsigned long *memoffset, - unsigned short *xpos, unsigned short *ypos, - unsigned short *xhotspot, unsigned short *yhotspot) + unsigned short *xpos, unsigned short *ypos, + unsigned short *xhotspot, unsigned short *yhotspot) { - GAL_CURSORPOSITION sCursorPos; + GAL_CURSORPOSITION sCursorPos; - INIT_GAL(&sCursorPos); - sCursorPos.dwSubfunction = GALFN_GETCURSORPOSITION; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorPos)) - return 0; - else { - *memoffset = sCursorPos.dwMemOffset; - *xpos = sCursorPos.wXPos; - *ypos = sCursorPos.wYPos; - *xhotspot = sCursorPos.wXHot; - *yhotspot = sCursorPos.wYHot; - return 1; - } + INIT_GAL(&sCursorPos); + sCursorPos.dwSubfunction = GALFN_GETCURSORPOSITION; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorPos)) + return 0; + else { + *memoffset = sCursorPos.dwMemOffset; + *xpos = sCursorPos.wXPos; + *ypos = sCursorPos.wYPos; + *xhotspot = sCursorPos.wXHot; + *yhotspot = sCursorPos.wYHot; + return 1; + } } /*-------------------------------------------------------------------------- @@ -1098,22 +1098,22 @@ Gal_get_cursor_position(unsigned long *memoffset, *-------------------------------------------------------------------------*/ BOOLEAN Gal_set_cursor_shape32(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) { - GAL_SETCURSORSHAPE sCursorShape; + GAL_SETCURSORSHAPE sCursorShape; - INIT_GAL(&sCursorShape); - sCursorShape.dwSubfunction = GALFN_SETCURSORSHAPE; - sCursorShape.dwMemOffset = memoffset; + INIT_GAL(&sCursorShape); + sCursorShape.dwSubfunction = GALFN_SETCURSORSHAPE; + sCursorShape.dwMemOffset = memoffset; - memcpy(sCursorShape.dwAndMask, andmask, sizeof(sCursorShape.dwAndMask)); + memcpy(sCursorShape.dwAndMask, andmask, sizeof(sCursorShape.dwAndMask)); - memcpy(sCursorShape.dwXorMask, xormask, sizeof(sCursorShape.dwXorMask)); + memcpy(sCursorShape.dwXorMask, xormask, sizeof(sCursorShape.dwXorMask)); - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorShape)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorShape)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1127,22 +1127,22 @@ Gal_set_cursor_shape32(unsigned long memoffset, * return: '1' was returned on success otherwise '0' was returned. *-------------------------------------------------------------------------*/ BOOLEAN Gal_set_cursor_shape64(unsigned long memoffset, - unsigned long *andmask, unsigned long *xormask) + unsigned long *andmask, unsigned long *xormask) { - GAL_SETCURSORSHAPE sCursorShape; + GAL_SETCURSORSHAPE sCursorShape; - INIT_GAL(&sCursorShape); - sCursorShape.dwSubfunction = GALFN_SETCURSORSHAPE_RCLD; - sCursorShape.dwMemOffset = memoffset; + INIT_GAL(&sCursorShape); + sCursorShape.dwSubfunction = GALFN_SETCURSORSHAPE_RCLD; + sCursorShape.dwMemOffset = memoffset; - memcpy(sCursorShape.dwAndMask, andmask, sizeof(sCursorShape.dwAndMask)); + memcpy(sCursorShape.dwAndMask, andmask, sizeof(sCursorShape.dwAndMask)); - memcpy(sCursorShape.dwXorMask, xormask, sizeof(sCursorShape.dwXorMask)); + memcpy(sCursorShape.dwXorMask, xormask, sizeof(sCursorShape.dwXorMask)); - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorShape)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorShape)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1157,17 +1157,17 @@ Gal_set_cursor_shape64(unsigned long memoffset, BOOLEAN Gal_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor) { - GAL_CURSORCOLORS sCursorColor; + GAL_CURSORCOLORS sCursorColor; - INIT_GAL(&sCursorColor); - sCursorColor.dwSubfunction = GALFN_SETCURSORCOLORS; - sCursorColor.dwBgColor = bkcolor; - sCursorColor.dwFgColor = fgcolor; + INIT_GAL(&sCursorColor); + sCursorColor.dwSubfunction = GALFN_SETCURSORCOLORS; + sCursorColor.dwBgColor = bkcolor; + sCursorColor.dwFgColor = fgcolor; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorColor)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorColor)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1182,18 +1182,18 @@ Gal_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor) BOOLEAN Gal_get_cursor_colors(unsigned long *bkcolor, unsigned long *fgcolor) { - GAL_CURSORCOLORS sCursorColor; + GAL_CURSORCOLORS sCursorColor; - INIT_GAL(&sCursorColor); - sCursorColor.dwSubfunction = GALFN_GETCURSORCOLORS; + INIT_GAL(&sCursorColor); + sCursorColor.dwSubfunction = GALFN_GETCURSORCOLORS; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorColor)) - return 0; - else { - *bkcolor = sCursorColor.dwBgColor; - *fgcolor = sCursorColor.dwFgColor; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCursorColor)) + return 0; + else { + *bkcolor = sCursorColor.dwBgColor; + *fgcolor = sCursorColor.dwFgColor; + return 1; + } } /*-------------------------------------------------------------------------- @@ -1208,16 +1208,16 @@ Gal_get_cursor_colors(unsigned long *bkcolor, unsigned long *fgcolor) BOOLEAN Gal_set_solid_pattern(unsigned long color) { - GAL_SETSOLIDPATTERN sSetSoildPat; + GAL_SETSOLIDPATTERN sSetSoildPat; - INIT_GAL(&sSetSoildPat); - sSetSoildPat.dwSubfunction = GALFN_SETSOLIDPATTERN; - sSetSoildPat.dwColor = color; + INIT_GAL(&sSetSoildPat); + sSetSoildPat.dwSubfunction = GALFN_SETSOLIDPATTERN; + sSetSoildPat.dwColor = color; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetSoildPat)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetSoildPat)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1233,15 +1233,15 @@ Gal_set_solid_pattern(unsigned long color) BOOLEAN Gal_set_solid_source(unsigned long color) { - GAL_SETSOLIDSOURCE sSetSolidSrc; + GAL_SETSOLIDSOURCE sSetSolidSrc; - INIT_GAL(&sSetSolidSrc); - sSetSolidSrc.dwSubfunction = GALFN_SETSOLIDSOURCE; - sSetSolidSrc.dwColor = color; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetSolidSrc)) - return 0; - else - return 1; + INIT_GAL(&sSetSolidSrc); + sSetSolidSrc.dwSubfunction = GALFN_SETSOLIDSOURCE; + sSetSolidSrc.dwColor = color; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetSolidSrc)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1256,19 +1256,19 @@ Gal_set_solid_source(unsigned long color) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, - unsigned char transparency) + unsigned char transparency) { - GAL_SETMONOSOURCE sSetMonoSrc; + GAL_SETMONOSOURCE sSetMonoSrc; - INIT_GAL(&sSetMonoSrc); - sSetMonoSrc.dwSubfunction = GALFN_SETMONOSOURCE; - sSetMonoSrc.dwFgColor = fgcolor; - sSetMonoSrc.dwBgColor = bgcolor; - sSetMonoSrc.cTransparency = transparency; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetMonoSrc)) - return 0; - else - return 1; + INIT_GAL(&sSetMonoSrc); + sSetMonoSrc.dwSubfunction = GALFN_SETMONOSOURCE; + sSetMonoSrc.dwFgColor = fgcolor; + sSetMonoSrc.dwBgColor = bgcolor; + sSetMonoSrc.cTransparency = transparency; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetMonoSrc)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1286,22 +1286,22 @@ Gal_set_mono_source(unsigned long bgcolor, unsigned long fgcolor, *------------------------------------------------------------------------*/ BOOLEAN Gal_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, - unsigned long data0, unsigned long data1, - unsigned char transparency) + unsigned long data0, unsigned long data1, + unsigned char transparency) { - GAL_SETMONOPATTERN sSetMonoPat; + GAL_SETMONOPATTERN sSetMonoPat; - INIT_GAL(&sSetMonoPat); - sSetMonoPat.dwSubfunction = GALFN_SETMONOPATTERN; - sSetMonoPat.dwFgColor = fgcolor; - sSetMonoPat.dwBgColor = bgcolor; - sSetMonoPat.dwData0 = data0; - sSetMonoPat.dwData1 = data1; - sSetMonoPat.cTransparency = transparency; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetMonoPat)) - return 0; - else - return 1; + INIT_GAL(&sSetMonoPat); + sSetMonoPat.dwSubfunction = GALFN_SETMONOPATTERN; + sSetMonoPat.dwFgColor = fgcolor; + sSetMonoPat.dwBgColor = bgcolor; + sSetMonoPat.dwData0 = data0; + sSetMonoPat.dwData1 = data1; + sSetMonoPat.cTransparency = transparency; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetMonoPat)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1317,16 +1317,16 @@ Gal_set_mono_pattern(unsigned long bgcolor, unsigned long fgcolor, BOOLEAN Gal_set_raster_operation(unsigned char rop) { - GAL_RASTEROPERATION sSetRop; + GAL_RASTEROPERATION sSetRop; - INIT_GAL(&sSetRop); - sSetRop.dwSubfunction = GALFN_SETRASTEROPERATION; - sSetRop.cRop = rop; + INIT_GAL(&sSetRop); + sSetRop.dwSubfunction = GALFN_SETRASTEROPERATION; + sSetRop.cRop = rop; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetRop)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetRop)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1343,21 +1343,21 @@ Gal_set_raster_operation(unsigned char rop) *------------------------------------------------------------------------*/ BOOLEAN Gal_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) { - GAL_PATTERNFILL sPatternFill; + GAL_PATTERNFILL sPatternFill; - INIT_GAL(&sPatternFill); - sPatternFill.dwSubfunction = GALFN_PATTERNFILL; - sPatternFill.wXPos = x; - sPatternFill.wYPos = y; - sPatternFill.wWidth = width; - sPatternFill.wHeight = height; + INIT_GAL(&sPatternFill); + sPatternFill.dwSubfunction = GALFN_PATTERNFILL; + sPatternFill.wXPos = x; + sPatternFill.wYPos = y; + sPatternFill.wWidth = width; + sPatternFill.wHeight = height; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sPatternFill)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sPatternFill)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1376,24 +1376,24 @@ Gal_pattern_fill(unsigned short x, unsigned short y, *------------------------------------------------------------------------*/ BOOLEAN Gal_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height) { - GAL_SCREENTOSCREENBLT sScreenBlt; + GAL_SCREENTOSCREENBLT sScreenBlt; - INIT_GAL(&sScreenBlt); - sScreenBlt.dwSubfunction = GALFN_SCREENTOSCREENBLT; - sScreenBlt.wXStart = srcx; - sScreenBlt.wYStart = srcy; - sScreenBlt.wXEnd = dstx; - sScreenBlt.wYEnd = dsty; - sScreenBlt.wWidth = width; - sScreenBlt.wHeight = height; + INIT_GAL(&sScreenBlt); + sScreenBlt.dwSubfunction = GALFN_SCREENTOSCREENBLT; + sScreenBlt.wXStart = srcx; + sScreenBlt.wYStart = srcy; + sScreenBlt.wXEnd = dstx; + sScreenBlt.wYEnd = dsty; + sScreenBlt.wWidth = width; + sScreenBlt.wHeight = height; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sScreenBlt)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sScreenBlt)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1413,26 +1413,26 @@ Gal_screen_to_screen_blt(unsigned short srcx, unsigned short srcy, *------------------------------------------------------------------------*/ BOOLEAN Gal_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long color) { - GAL_SCREENTOSCREENXBLT sScreenXBlt; + GAL_SCREENTOSCREENXBLT sScreenXBlt; - INIT_GAL(&sScreenXBlt); - sScreenXBlt.dwSubfunction = GALFN_SCREENTOSCREENXBLT; - sScreenXBlt.wXStart = srcx; - sScreenXBlt.wYStart = srcy; - sScreenXBlt.wXEnd = dstx; - sScreenXBlt.wYEnd = dsty; - sScreenXBlt.wWidth = width; - sScreenXBlt.wHeight = height; - sScreenXBlt.dwColor = color; + INIT_GAL(&sScreenXBlt); + sScreenXBlt.dwSubfunction = GALFN_SCREENTOSCREENXBLT; + sScreenXBlt.wXStart = srcx; + sScreenXBlt.wYStart = srcy; + sScreenXBlt.wXEnd = dstx; + sScreenXBlt.wYEnd = dsty; + sScreenXBlt.wWidth = width; + sScreenXBlt.wHeight = height; + sScreenXBlt.dwColor = color; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sScreenXBlt)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sScreenXBlt)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1454,144 +1454,144 @@ Gal_screen_to_screen_xblt(unsigned short srcx, unsigned short srcy, *------------------------------------------------------------------------*/ BOOLEAN Gal_bresenham_line(unsigned short x, unsigned short y, - unsigned short length, unsigned short initerr, - unsigned short axialerr, unsigned short diagerr, - unsigned short flags) + unsigned short length, unsigned short initerr, + unsigned short axialerr, unsigned short diagerr, + unsigned short flags) { - GAL_BRESENHAMLINE sBresenhamLine; + GAL_BRESENHAMLINE sBresenhamLine; - INIT_GAL(&sBresenhamLine); - sBresenhamLine.dwSubfunction = GALFN_BRESENHAMLINE; - sBresenhamLine.wX1 = x; - sBresenhamLine.wY1 = y; - sBresenhamLine.wLength = length; - sBresenhamLine.wErr = initerr; - sBresenhamLine.wE1 = axialerr; - sBresenhamLine.wE2 = diagerr; - sBresenhamLine.wFlags = flags; + INIT_GAL(&sBresenhamLine); + sBresenhamLine.dwSubfunction = GALFN_BRESENHAMLINE; + sBresenhamLine.wX1 = x; + sBresenhamLine.wY1 = y; + sBresenhamLine.wLength = length; + sBresenhamLine.wErr = initerr; + sBresenhamLine.wE1 = axialerr; + sBresenhamLine.wE2 = diagerr; + sBresenhamLine.wFlags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sBresenhamLine)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sBresenhamLine)) + return 0; + else + return 1; } BOOLEAN Gal_color_pattern_fill(unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - unsigned long pattern) + unsigned short width, unsigned short height, + unsigned long pattern) { - GAL_COLOR_PATTERNFILL sColorPat; + GAL_COLOR_PATTERNFILL sColorPat; - INIT_GAL(&sColorPat); - sColorPat.dwSubfunction = GALFN_COLOR_PATTERNFILL; - sColorPat.wDstx = x; - sColorPat.wDsty = y; - sColorPat.wWidth = width; - sColorPat.wHeight = height; - sColorPat.dwPattern = pattern; + INIT_GAL(&sColorPat); + sColorPat.dwSubfunction = GALFN_COLOR_PATTERNFILL; + sColorPat.wDstx = x; + sColorPat.wDsty = y; + sColorPat.wWidth = width; + sColorPat.wHeight = height; + sColorPat.dwPattern = pattern; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sColorPat)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sColorPat)) + return 0; + else + return 1; } BOOLEAN Gal_color_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long data, long pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long data, long pitch) { - GAL_COLOR_BITMAP_TO_SCREEN_BLT sBmp2Scr; + GAL_COLOR_BITMAP_TO_SCREEN_BLT sBmp2Scr; - INIT_GAL(&sBmp2Scr); - sBmp2Scr.dwSubfunction = GALFN_COLOR_BITMAP_TO_SCREEN_BLT; - sBmp2Scr.wSrcx = srcx; - sBmp2Scr.wSrcy = srcy; - sBmp2Scr.wDstx = dstx; - sBmp2Scr.wDsty = dsty; - sBmp2Scr.wWidth = width; - sBmp2Scr.wHeight = height; - sBmp2Scr.dwData = data; - sBmp2Scr.wPitch = pitch; + INIT_GAL(&sBmp2Scr); + sBmp2Scr.dwSubfunction = GALFN_COLOR_BITMAP_TO_SCREEN_BLT; + sBmp2Scr.wSrcx = srcx; + sBmp2Scr.wSrcy = srcy; + sBmp2Scr.wDstx = dstx; + sBmp2Scr.wDsty = dsty; + sBmp2Scr.wWidth = width; + sBmp2Scr.wHeight = height; + sBmp2Scr.dwData = data; + sBmp2Scr.wPitch = pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sBmp2Scr)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sBmp2Scr)) + return 0; + else + return 1; } BOOLEAN Gal_color_bitmap_to_screen_xblt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long data, long pitch, - unsigned long color) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long data, long pitch, + unsigned long color) { - GAL_COLOR_BITMAP_TO_SCREEN_XBLT sBmp2Scr; + GAL_COLOR_BITMAP_TO_SCREEN_XBLT sBmp2Scr; - INIT_GAL(&sBmp2Scr); - sBmp2Scr.dwSubfunction = GALFN_COLOR_BITMAP_TO_SCREEN_XBLT; - sBmp2Scr.wSrcx = srcx; - sBmp2Scr.wSrcy = srcy; - sBmp2Scr.wDstx = dstx; - sBmp2Scr.wDsty = dsty; - sBmp2Scr.wWidth = width; - sBmp2Scr.wHeight = height; - sBmp2Scr.dwData = data; - sBmp2Scr.wPitch = pitch; - sBmp2Scr.dwColor = color; + INIT_GAL(&sBmp2Scr); + sBmp2Scr.dwSubfunction = GALFN_COLOR_BITMAP_TO_SCREEN_XBLT; + sBmp2Scr.wSrcx = srcx; + sBmp2Scr.wSrcy = srcy; + sBmp2Scr.wDstx = dstx; + sBmp2Scr.wDsty = dsty; + sBmp2Scr.wWidth = width; + sBmp2Scr.wHeight = height; + sBmp2Scr.dwData = data; + sBmp2Scr.wPitch = pitch; + sBmp2Scr.dwColor = color; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sBmp2Scr)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sBmp2Scr)) + return 0; + else + return 1; } BOOLEAN Gal_mono_bitmap_to_screen_blt(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned long data, short pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned long data, short pitch) { - GAL_MONO_BITMAP_TO_SCREEN_BLT sBmp2Scr; + GAL_MONO_BITMAP_TO_SCREEN_BLT sBmp2Scr; - INIT_GAL(&sBmp2Scr); - sBmp2Scr.dwSubfunction = GALFN_MONO_BITMAP_TO_SCREEN_BLT; - sBmp2Scr.wSrcx = srcx; - sBmp2Scr.wSrcy = srcy; - sBmp2Scr.wDstx = dstx; - sBmp2Scr.wDsty = dsty; - sBmp2Scr.wWidth = width; - sBmp2Scr.wHeight = height; - sBmp2Scr.dwData = data; - sBmp2Scr.wPitch = pitch; + INIT_GAL(&sBmp2Scr); + sBmp2Scr.dwSubfunction = GALFN_MONO_BITMAP_TO_SCREEN_BLT; + sBmp2Scr.wSrcx = srcx; + sBmp2Scr.wSrcy = srcy; + sBmp2Scr.wDstx = dstx; + sBmp2Scr.wDsty = dsty; + sBmp2Scr.wWidth = width; + sBmp2Scr.wHeight = height; + sBmp2Scr.dwData = data; + sBmp2Scr.wPitch = pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sBmp2Scr)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sBmp2Scr)) + return 0; + else + return 1; } BOOLEAN Gal_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, - unsigned short height, unsigned long data) + unsigned short height, unsigned long data) { - GAL_TEXT_BLT sTextBlt; + GAL_TEXT_BLT sTextBlt; - INIT_GAL(&sTextBlt); - sTextBlt.dwSubfunction = GALFN_TEXT_BLT; - sTextBlt.wDstx = dstx; - sTextBlt.wDsty = dsty; - sTextBlt.wWidth = width; - sTextBlt.wHeight = height; - sTextBlt.dwData = data; + INIT_GAL(&sTextBlt); + sTextBlt.dwSubfunction = GALFN_TEXT_BLT; + sTextBlt.wDstx = dstx; + sTextBlt.wDsty = dsty; + sTextBlt.wWidth = width; + sTextBlt.wHeight = height; + sTextBlt.dwData = data; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sTextBlt)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sTextBlt)) + return 0; + else + return 1; } /*------------------------------------------------------------------------ @@ -1607,16 +1607,16 @@ Gal_text_blt(unsigned short dstx, unsigned short dsty, unsigned short width, BOOLEAN Gal_set_compression_enable(BOOLEAN bCompressionState) { - GAL_COMPRESSIONSTATE sCompState; + GAL_COMPRESSIONSTATE sCompState; - INIT_GAL(&sCompState); - sCompState.dwSubfunction = GALFN_SETCOMPRESSIONSTATE; - sCompState.bCompressionState = bCompressionState; + INIT_GAL(&sCompState); + sCompState.dwSubfunction = GALFN_SETCOMPRESSIONSTATE; + sCompState.bCompressionState = bCompressionState; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCompState)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCompState)) + return 0; + else + return 1; } /*------------------------------------------------------------------------ @@ -1632,17 +1632,17 @@ Gal_set_compression_enable(BOOLEAN bCompressionState) BOOLEAN Gal_get_compression_enable(int *bCompressionState) { - GAL_COMPRESSIONSTATE sCompState; + GAL_COMPRESSIONSTATE sCompState; - INIT_GAL(&sCompState); - sCompState.dwSubfunction = GALFN_GETCOMPRESSIONSTATE; + INIT_GAL(&sCompState); + sCompState.dwSubfunction = GALFN_GETCOMPRESSIONSTATE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCompState)) - return 0; - else { - *bCompressionState = sCompState.bCompressionState; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCompState)) + return 0; + else { + *bCompressionState = sCompState.bCompressionState; + return 1; + } } /*-------------------------------------------------------------------------- @@ -1661,22 +1661,22 @@ Gal_get_compression_enable(int *bCompressionState) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_compression_parameters(unsigned long flags, - unsigned long offset, unsigned short pitch, - unsigned short size) + unsigned long offset, unsigned short pitch, + unsigned short size) { - GAL_COMPRESSIONPARAMS sCompParams; + GAL_COMPRESSIONPARAMS sCompParams; - INIT_GAL(&sCompParams); - sCompParams.dwSubfunction = GALFN_SETCOMPRESSIONPARAMS; - sCompParams.dwFlags = flags; - sCompParams.dwCompOffset = offset; - sCompParams.dwCompPitch = pitch; - sCompParams.dwCompSize = size; + INIT_GAL(&sCompParams); + sCompParams.dwSubfunction = GALFN_SETCOMPRESSIONPARAMS; + sCompParams.dwFlags = flags; + sCompParams.dwCompOffset = offset; + sCompParams.dwCompPitch = pitch; + sCompParams.dwCompSize = size; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCompParams)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCompParams)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1695,23 +1695,23 @@ Gal_set_compression_parameters(unsigned long flags, *------------------------------------------------------------------------*/ BOOLEAN Gal_get_compression_parameters(unsigned long flags, - unsigned long *offset, - unsigned short *pitch, unsigned short *size) + unsigned long *offset, + unsigned short *pitch, unsigned short *size) { - GAL_COMPRESSIONPARAMS sCompParams; + GAL_COMPRESSIONPARAMS sCompParams; - INIT_GAL(&sCompParams); - sCompParams.dwSubfunction = GALFN_GETCOMPRESSIONPARAMS; - sCompParams.dwFlags = flags; + INIT_GAL(&sCompParams); + sCompParams.dwSubfunction = GALFN_GETCOMPRESSIONPARAMS; + sCompParams.dwFlags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sCompParams)) - return 0; - else { - *offset = sCompParams.dwCompOffset; - *pitch = sCompParams.dwCompPitch; - *size = sCompParams.dwCompSize; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sCompParams)) + return 0; + else { + *offset = sCompParams.dwCompOffset; + *pitch = sCompParams.dwCompPitch; + *size = sCompParams.dwCompSize; + return 1; + } } /*-------------------------------------------------------------------------- @@ -1726,16 +1726,16 @@ Gal_get_compression_parameters(unsigned long flags, BOOLEAN Gal_vga_mode_switch(int active) { - GAL_VGAMODEDATA sVgaData; + GAL_VGAMODEDATA sVgaData; - INIT_GAL(&sVgaData); - sVgaData.dwSubfunction = GALFN_VGAMODESWITCH; - sVgaData.dwFlags = active; + INIT_GAL(&sVgaData); + sVgaData.dwSubfunction = GALFN_VGAMODESWITCH; + sVgaData.dwFlags = active; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgaData)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgaData)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1748,15 +1748,15 @@ Gal_vga_mode_switch(int active) BOOLEAN Gal_vga_clear_extended(void) { - GAL_VGAMODEDATA sVgaData; + GAL_VGAMODEDATA sVgaData; - INIT_GAL(&sVgaData); - sVgaData.dwSubfunction = GALFN_VGACLEARCRTEXT; + INIT_GAL(&sVgaData); + sVgaData.dwSubfunction = GALFN_VGACLEARCRTEXT; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgaData)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sVgaData)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1772,15 +1772,15 @@ Gal_vga_clear_extended(void) BOOLEAN Gal_vga_pitch(PGAL_VGAMODEDATA pVgaData, unsigned short pitch) { - INIT_GAL(pVgaData); - pVgaData->dwSubfunction = GALFN_VGASETPITCH; - pVgaData->dwFlags = pitch; + INIT_GAL(pVgaData); + pVgaData->dwSubfunction = GALFN_VGASETPITCH; + pVgaData->dwFlags = pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, pVgaData)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pVgaData)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -1795,13 +1795,13 @@ Gal_vga_pitch(PGAL_VGAMODEDATA pVgaData, unsigned short pitch) BOOLEAN Gal_vga_restore(PGAL_VGAMODEDATA pVgaData) { - INIT_GAL(pVgaData); - pVgaData->dwSubfunction = GALFN_VGARESTORE; + INIT_GAL(pVgaData); + pVgaData->dwSubfunction = GALFN_VGARESTORE; - if (ioctl(ifbdev_handle, FBIOGAL_API, pVgaData)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, pVgaData)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -1816,14 +1816,14 @@ Gal_vga_restore(PGAL_VGAMODEDATA pVgaData) BOOLEAN Gal_vga_save(PGAL_VGAMODEDATA pVgaData) { - INIT_GAL(pVgaData); - pVgaData->dwSubfunction = GALFN_VGASAVE; + INIT_GAL(pVgaData); + pVgaData->dwSubfunction = GALFN_VGASAVE; - if (ioctl(ifbdev_handle, FBIOGAL_API, pVgaData)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pVgaData)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -1838,14 +1838,14 @@ Gal_vga_save(PGAL_VGAMODEDATA pVgaData) BOOLEAN Gal_vga_mode(PGAL_VGAMODEDATA pVgaData) { - INIT_GAL(pVgaData); - pVgaData->dwSubfunction = GALFN_VGASETMODE; + INIT_GAL(pVgaData); + pVgaData->dwSubfunction = GALFN_VGASETMODE; - if (ioctl(ifbdev_handle, FBIOGAL_API, pVgaData)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pVgaData)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -1860,17 +1860,17 @@ Gal_vga_mode(PGAL_VGAMODEDATA pVgaData) BOOLEAN Gal_pnl_enabled_in_bios(int *state) { - GAL_PNLBIOS pStat; + GAL_PNLBIOS pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLBIOSENABLE; + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLBIOSENABLE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else { - *state = pStat.state; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else { + *state = pStat.state; + return 1; + } } /*-------------------------------------------------------------------------- @@ -1885,20 +1885,20 @@ Gal_pnl_enabled_in_bios(int *state) BOOLEAN Gal_pnl_info_from_bios(int *xres, int *yres, int *bpp, int *hz) { - GAL_PNLBIOS pStat; + GAL_PNLBIOS pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLBIOSINFO; + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLBIOSINFO; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else { - *xres = pStat.XRes; - *yres = pStat.YRes; - *bpp = pStat.Bpp; - *hz = pStat.Freq; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else { + *xres = pStat.XRes; + *yres = pStat.YRes; + *bpp = pStat.Bpp; + *hz = pStat.Freq; + return 1; + } } /*-------------------------------------------------------------------------- @@ -1913,18 +1913,18 @@ Gal_pnl_info_from_bios(int *xres, int *yres, int *bpp, int *hz) BOOLEAN Gal_pnl_set_params(unsigned long flags, PPnl_PanelParams pParam) { - GAL_PNLPARAMS pStat; + GAL_PNLPARAMS pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLSETPARAMS; - pParam->Flags = flags; - memcpy(&(pStat.PanelParams), pParam, sizeof(Pnl_PanelParams)); + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLSETPARAMS; + pParam->Flags = flags; + memcpy(&(pStat.PanelParams), pParam, sizeof(Pnl_PanelParams)); - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -1939,19 +1939,19 @@ Gal_pnl_set_params(unsigned long flags, PPnl_PanelParams pParam) BOOLEAN Gal_pnl_get_params(unsigned long flags, PPnl_PanelParams pParam) { - GAL_PNLPARAMS pStat; + GAL_PNLPARAMS pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLGETPARAMS; - memcpy(&(pStat.PanelParams), pParam, sizeof(Pnl_PanelParams)); - pStat.PanelParams.Flags = flags; + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLGETPARAMS; + memcpy(&(pStat.PanelParams), pParam, sizeof(Pnl_PanelParams)); + pStat.PanelParams.Flags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else { - memcpy(pParam, &(pStat.PanelParams), sizeof(Pnl_PanelParams)); - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else { + memcpy(pParam, &(pStat.PanelParams), sizeof(Pnl_PanelParams)); + return 1; + } } /*-------------------------------------------------------------------------- @@ -1965,16 +1965,16 @@ Gal_pnl_get_params(unsigned long flags, PPnl_PanelParams pParam) BOOLEAN Gal_pnl_init(PPnl_PanelParams pParam) { - GAL_PNLPARAMS pStat; + GAL_PNLPARAMS pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLINITPANEL; - memcpy(&(pStat.PanelParams), pParam, sizeof(Pnl_PanelParams)); + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLINITPANEL; + memcpy(&(pStat.PanelParams), pParam, sizeof(Pnl_PanelParams)); - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else + return 1; } @@ -1988,16 +1988,16 @@ Gal_pnl_init(PPnl_PanelParams pParam) BOOLEAN Gal_pnl_save(void) { - GAL_PNLPARAMS pStat; + GAL_PNLPARAMS pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLSAVESTATE; + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLSAVESTATE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -2010,16 +2010,16 @@ Gal_pnl_save(void) BOOLEAN Gal_pnl_restore(void) { - GAL_PNLPARAMS pStat; + GAL_PNLPARAMS pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLRESTORESTATE; + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLRESTORESTATE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -2032,16 +2032,16 @@ Gal_pnl_restore(void) BOOLEAN Gal_pnl_powerup(void) { - GAL_BASE pStat; + GAL_BASE pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLPOWERUP; + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLPOWERUP; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -2054,16 +2054,16 @@ Gal_pnl_powerup(void) BOOLEAN Gal_pnl_powerdown(void) { - GAL_BASE pStat; + GAL_BASE pStat; - INIT_GAL(&pStat); - pStat.dwSubfunction = GALFN_PNLPOWERDOWN; + INIT_GAL(&pStat); + pStat.dwSubfunction = GALFN_PNLPOWERDOWN; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pStat)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -2079,15 +2079,15 @@ Gal_pnl_powerdown(void) BOOLEAN Gal_tv_set_params(unsigned long flags, PGAL_TVPARAMS pTV) { - INIT_GAL(pTV); - pTV->dwSubfunction = GALFN_SETTVPARAMS; - pTV->dwFlags = flags; + INIT_GAL(pTV); + pTV->dwSubfunction = GALFN_SETTVPARAMS; + pTV->dwFlags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -2103,14 +2103,14 @@ Gal_tv_set_params(unsigned long flags, PGAL_TVPARAMS pTV) BOOLEAN Gal_tv_get_params(unsigned long flags, PGAL_TVPARAMS pTV) { - INIT_GAL(pTV); - pTV->dwSubfunction = GALFN_GETTVPARAMS; - pTV->dwFlags = flags; + INIT_GAL(pTV); + pTV->dwSubfunction = GALFN_GETTVPARAMS; + pTV->dwFlags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) + return 0; + else + return 1; } @@ -2126,15 +2126,15 @@ Gal_tv_get_params(unsigned long flags, PGAL_TVPARAMS pTV) BOOLEAN Gal_tv_set_timings(unsigned long flags, PGAL_TVTIMING pTV) { - INIT_GAL(pTV); - pTV->dwSubfunction = GALFN_SETTVTIMING; - pTV->dwFlags = flags; + INIT_GAL(pTV); + pTV->dwSubfunction = GALFN_SETTVTIMING; + pTV->dwFlags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -2149,15 +2149,15 @@ Gal_tv_set_timings(unsigned long flags, PGAL_TVTIMING pTV) BOOLEAN Gal_tv_get_timings(unsigned long flags, PGAL_TVTIMING pTV) { - INIT_GAL(pTV); - pTV->dwSubfunction = GALFN_GETTVTIMING; - pTV->dwFlags = flags; + INIT_GAL(pTV); + pTV->dwSubfunction = GALFN_GETTVTIMING; + pTV->dwFlags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -2171,17 +2171,17 @@ Gal_tv_get_timings(unsigned long flags, PGAL_TVTIMING pTV) BOOLEAN Gal_set_tv_enable(int bState) { - GAL_TVPARAMS pTV; + GAL_TVPARAMS pTV; - INIT_GAL(&pTV); - pTV.dwSubfunction = GALFN_SETENABLE; - pTV.bState = bState; + INIT_GAL(&pTV); + pTV.dwSubfunction = GALFN_SETENABLE; + pTV.bState = bState; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pTV)) - return 0; - else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pTV)) + return 0; + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -2195,18 +2195,19 @@ Gal_set_tv_enable(int bState) BOOLEAN Gal_get_tv_enable(unsigned int *bState) { - GAL_TVPARAMS pTV; + GAL_TVPARAMS pTV; - INIT_GAL(&pTV); - pTV.dwSubfunction = GALFN_GETENABLE; + INIT_GAL(&pTV); + pTV.dwSubfunction = GALFN_GETENABLE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &pTV)) { - *bState = 0; - return 0; - } else { - *bState = pTV.bState; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &pTV)) { + *bState = 0; + return 0; + } + else { + *bState = pTV.bState; + return 1; + } } /*-------------------------------------------------------------------------- @@ -2221,16 +2222,17 @@ Gal_get_tv_enable(unsigned int *bState) BOOLEAN Gal_is_tv_mode_supported(unsigned long flags, PGAL_TVPARAMS pTV, int *bState) { - INIT_GAL(pTV); - pTV->dwSubfunction = GALFN_ISTVMODESUPPORTED; - pTV->dwFlags = flags; + INIT_GAL(pTV); + pTV->dwSubfunction = GALFN_ISTVMODESUPPORTED; + pTV->dwFlags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) { - return 0; - } else { - *bState = pTV->bState; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, pTV)) { + return 0; + } + else { + *bState = pTV->bState; + return 1; + } } /** Video **********************************************************/ @@ -2246,15 +2248,15 @@ Gal_is_tv_mode_supported(unsigned long flags, PGAL_TVPARAMS pTV, int *bState) BOOLEAN Gal_set_video_enable(int enable) { - GAL_VIDEOENABLE sSetVideo; + GAL_VIDEOENABLE sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOENABLE; - sSetVideo.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOENABLE; + sSetVideo.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2268,15 +2270,15 @@ Gal_set_video_enable(int enable) BOOLEAN Gal_set_video_format(int format) { - GAL_VIDEOFORMAT sSetVideo; + GAL_VIDEOFORMAT sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOFORMAT; - sSetVideo.format = format; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOFORMAT; + sSetVideo.format = format; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2291,16 +2293,16 @@ Gal_set_video_format(int format) BOOLEAN Gal_set_video_size(unsigned short width, unsigned short height) { - GAL_VIDEOSIZE sSetVideo; + GAL_VIDEOSIZE sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOSIZE; - sSetVideo.width = width; - sSetVideo.height = height; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOSIZE; + sSetVideo.width = width; + sSetVideo.height = height; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2314,15 +2316,15 @@ Gal_set_video_size(unsigned short width, unsigned short height) BOOLEAN Gal_set_video_offset(unsigned long offset) { - GAL_VIDEOOFFSET sSetVideo; + GAL_VIDEOOFFSET sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOOFFSET; - sSetVideo.offset = offset; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOOFFSET; + sSetVideo.offset = offset; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2339,18 +2341,18 @@ Gal_set_video_offset(unsigned long offset) BOOLEAN Gal_set_video_window(short x, short y, short w, short h) { - GAL_VIDEOWINDOW sSetVideo; + GAL_VIDEOWINDOW sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOWINDOW; - sSetVideo.x = x; - sSetVideo.y = y; - sSetVideo.w = w; - sSetVideo.h = h; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOWINDOW; + sSetVideo.x = x; + sSetVideo.y = y; + sSetVideo.w = w; + sSetVideo.h = h; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2366,20 +2368,20 @@ Gal_set_video_window(short x, short y, short w, short h) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_video_scale(unsigned short srcw, unsigned short srch, - unsigned short dstw, unsigned short dsth) + unsigned short dstw, unsigned short dsth) { - GAL_VIDEOSCALE sSetVideo; + GAL_VIDEOSCALE sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOSCALE; - sSetVideo.srcw = srcw; - sSetVideo.srch = srch; - sSetVideo.dstw = dstw; - sSetVideo.dsth = dsth; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOSCALE; + sSetVideo.srcw = srcw; + sSetVideo.srch = srch; + sSetVideo.dstw = dstw; + sSetVideo.dsth = dsth; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2394,16 +2396,16 @@ Gal_set_video_scale(unsigned short srcw, unsigned short srch, BOOLEAN Gal_set_video_filter(int xfilter, int yfilter) { - GAL_VIDEOFILTER sSetVideo; + GAL_VIDEOFILTER sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOFILTER; - sSetVideo.xfilter = xfilter; - sSetVideo.yfilter = yfilter; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOFILTER; + sSetVideo.xfilter = xfilter; + sSetVideo.yfilter = yfilter; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2419,17 +2421,17 @@ Gal_set_video_filter(int xfilter, int yfilter) BOOLEAN Gal_set_video_color_key(unsigned long key, unsigned long mask, int bluescreen) { - GAL_VIDEOCOLORKEY sSetVideo; + GAL_VIDEOCOLORKEY sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOCOLORKEY; - sSetVideo.key = key; - sSetVideo.mask = mask; - sSetVideo.bluescreen = bluescreen; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOCOLORKEY; + sSetVideo.key = key; + sSetVideo.mask = mask; + sSetVideo.bluescreen = bluescreen; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2443,15 +2445,15 @@ Gal_set_video_color_key(unsigned long key, unsigned long mask, int bluescreen) BOOLEAN Gal_set_video_downscale_enable(int enable) { - GAL_VIDEODOWNSCALEENABLE sSetVideo; + GAL_VIDEODOWNSCALEENABLE sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEODOWNSCALEENABLE; - sSetVideo.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEODOWNSCALEENABLE; + sSetVideo.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2466,16 +2468,16 @@ Gal_set_video_downscale_enable(int enable) BOOLEAN Gal_set_video_downscale_config(unsigned short type, unsigned short m) { - GAL_VIDEODOWNSCALECONFIG sSetVideo; + GAL_VIDEODOWNSCALECONFIG sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEODOWNSCALECONFIG; - sSetVideo.type = type; - sSetVideo.m = m; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEODOWNSCALECONFIG; + sSetVideo.type = type; + sSetVideo.m = m; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2491,22 +2493,21 @@ Gal_set_video_downscale_config(unsigned short type, unsigned short m) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_video_downscale_coefficients(unsigned short coef1, - unsigned short coef2, - unsigned short coef3, - unsigned short coef4) + unsigned short coef2, + unsigned short coef3, unsigned short coef4) { - GAL_VIDEODOWNSCALECOEFF sSetVideo; + GAL_VIDEODOWNSCALECOEFF sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEODOWNSCALECOEFF; - sSetVideo.coef1 = coef1; - sSetVideo.coef2 = coef2; - sSetVideo.coef3 = coef3; - sSetVideo.coef4 = coef4; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEODOWNSCALECOEFF; + sSetVideo.coef1 = coef1; + sSetVideo.coef2 = coef2; + sSetVideo.coef3 = coef3; + sSetVideo.coef4 = coef4; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2521,15 +2522,15 @@ Gal_set_video_downscale_coefficients(unsigned short coef1, BOOLEAN Gal_set_video_source(int source) { - GAL_VIDEOSOURCE sSetVideo; + GAL_VIDEOSOURCE sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOSOURCE; - sSetVideo.source = source; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOSOURCE; + sSetVideo.source = source; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2545,15 +2546,15 @@ Gal_set_video_source(int source) BOOLEAN Gal_set_video_interlaced(int enable) { - GAL_SETVIDEOINTERLACED sSetVideo; + GAL_SETVIDEOINTERLACED sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOINTERLACED; - sSetVideo.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOINTERLACED; + sSetVideo.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2569,15 +2570,15 @@ Gal_set_video_interlaced(int enable) BOOLEAN Gal_set_color_space_YUV(int colorspace) { - GAL_COLORSPACEYUV sSetVideo; + GAL_COLORSPACEYUV sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOCOLORSPACE; - sSetVideo.colorspace = colorspace; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOCOLORSPACE; + sSetVideo.colorspace = colorspace; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2596,23 +2597,23 @@ Gal_set_color_space_YUV(int colorspace) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_video_cursor(unsigned long key, - unsigned long mask, - unsigned short select_color2, - unsigned long color1, unsigned long color2) + unsigned long mask, + unsigned short select_color2, + unsigned long color1, unsigned long color2) { - GAL_VIDEOCURSOR sSetVideo; + GAL_VIDEOCURSOR sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOCURSOR; - sSetVideo.key = key; - sSetVideo.mask = mask; - sSetVideo.select_color2 = select_color2; - sSetVideo.color1 = color1; - sSetVideo.color2 = color2; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOCURSOR; + sSetVideo.key = key; + sSetVideo.mask = mask; + sSetVideo.select_color2 = select_color2; + sSetVideo.color1 = color1; + sSetVideo.color2 = color2; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2629,16 +2630,16 @@ Gal_set_video_cursor(unsigned long key, BOOLEAN Gal_set_video_request(short x, short y) { - GAL_VIDEOREQUEST sSetVideo; + GAL_VIDEOREQUEST sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOREQUEST; - sSetVideo.x = x; - sSetVideo.y = y; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOREQUEST; + sSetVideo.x = x; + sSetVideo.y = y; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2654,15 +2655,15 @@ Gal_set_video_request(short x, short y) BOOLEAN Gal_set_alpha_enable(int enable) { - GAL_ALPHAENABLE sSetVideo; + GAL_ALPHAENABLE sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETALPHAENABLE; - sSetVideo.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETALPHAENABLE; + sSetVideo.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2677,17 +2678,17 @@ Gal_set_alpha_enable(int enable) BOOLEAN Gal_get_alpha_enable(int *enable) { - GAL_ALPHAENABLE sGetalphaenable; + GAL_ALPHAENABLE sGetalphaenable; - INIT_GAL(&sGetalphaenable); - sGetalphaenable.dwSubfunction = GALFN_GETALPHAENABLE; + INIT_GAL(&sGetalphaenable); + sGetalphaenable.dwSubfunction = GALFN_GETALPHAENABLE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphaenable)) - return 0; - else + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphaenable)) + return 0; + else - *enable = sGetalphaenable.enable; - return 1; + *enable = sGetalphaenable.enable; + return 1; } /*-------------------------------------------------------------------------- @@ -2704,20 +2705,20 @@ Gal_get_alpha_enable(int *enable) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_alpha_window(short x, short y, - unsigned short width, unsigned short height) + unsigned short width, unsigned short height) { - GAL_ALPHAWINDOW sSetVideo; + GAL_ALPHAWINDOW sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETALPHAWINDOW; - sSetVideo.x = x; - sSetVideo.y = y; - sSetVideo.width = width; - sSetVideo.height = height; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETALPHAWINDOW; + sSetVideo.x = x; + sSetVideo.y = y; + sSetVideo.width = width; + sSetVideo.height = height; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2734,21 +2735,21 @@ Gal_set_alpha_window(short x, short y, *------------------------------------------------------------------------*/ BOOLEAN Gal_get_alpha_size(unsigned short *x, unsigned short *y, - unsigned short *width, unsigned short *height) + unsigned short *width, unsigned short *height) { - GAL_ALPHASIZE sGetalphasize; + GAL_ALPHASIZE sGetalphasize; - INIT_GAL(&sGetalphasize); - sGetalphasize.dwSubfunction = GALFN_GETALPHASIZE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphasize)) - return 0; - else { - *x = *(sGetalphasize.x); - *y = *(sGetalphasize.y); - *width = *(sGetalphasize.width); - *height = *(sGetalphasize.height); - return 1; - } + INIT_GAL(&sGetalphasize); + sGetalphasize.dwSubfunction = GALFN_GETALPHASIZE; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphasize)) + return 0; + else { + *x = *(sGetalphasize.x); + *y = *(sGetalphasize.y); + *width = *(sGetalphasize.width); + *height = *(sGetalphasize.height); + return 1; + } } /*-------------------------------------------------------------------------- @@ -2765,16 +2766,16 @@ Gal_get_alpha_size(unsigned short *x, unsigned short *y, BOOLEAN Gal_set_alpha_value(unsigned char alpha, char delta) { - GAL_ALPHAVALUE sSetVideo; + GAL_ALPHAVALUE sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETALPHAVALUE; - sSetVideo.alpha = alpha; - sSetVideo.delta = delta; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETALPHAVALUE; + sSetVideo.alpha = alpha; + sSetVideo.delta = delta; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2791,18 +2792,18 @@ Gal_set_alpha_value(unsigned char alpha, char delta) BOOLEAN Gal_get_alpha_value(unsigned char *alpha, char *delta) { - GAL_ALPHAVALUE sGetalphavalue; + GAL_ALPHAVALUE sGetalphavalue; - INIT_GAL(&sGetalphavalue); - sGetalphavalue.dwSubfunction = GALFN_GETALPHAVALUE; + INIT_GAL(&sGetalphavalue); + sGetalphavalue.dwSubfunction = GALFN_GETALPHAVALUE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphavalue)) - return 0; - else { - *alpha = sGetalphavalue.alpha; - *delta = sGetalphavalue.delta; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphavalue)) + return 0; + else { + *alpha = sGetalphavalue.alpha; + *delta = sGetalphavalue.delta; + return 1; + } } /*-------------------------------------------------------------------------- @@ -2817,15 +2818,15 @@ Gal_get_alpha_value(unsigned char *alpha, char *delta) BOOLEAN Gal_set_alpha_priority(int priority) { - GAL_ALPHAPRIORITY sSetVideo; + GAL_ALPHAPRIORITY sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETALPHAPRIORITY; - sSetVideo.priority = priority; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETALPHAPRIORITY; + sSetVideo.priority = priority; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2840,16 +2841,16 @@ Gal_set_alpha_priority(int priority) BOOLEAN Gal_get_alpha_priority(int *priority) { - GAL_ALPHAPRIORITY sGetalphapriority; + GAL_ALPHAPRIORITY sGetalphapriority; - INIT_GAL(&sGetalphapriority); - sGetalphapriority.dwSubfunction = GALFN_GETALPHAPRIORITY; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphapriority)) - return 0; - else { - *priority = sGetalphapriority.priority; - return 1; - } + INIT_GAL(&sGetalphapriority); + sGetalphapriority.dwSubfunction = GALFN_GETALPHAPRIORITY; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphapriority)) + return 0; + else { + *priority = sGetalphapriority.priority; + return 1; + } } /*-------------------------------------------------------------------------- @@ -2864,15 +2865,15 @@ Gal_get_alpha_priority(int *priority) BOOLEAN Gal_set_alpha_color(unsigned long color) { - GAL_ALPHACOLOR sSetVideo; + GAL_ALPHACOLOR sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETALPHACOLOR; - sSetVideo.color = color; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETALPHACOLOR; + sSetVideo.color = color; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2887,17 +2888,17 @@ Gal_set_alpha_color(unsigned long color) BOOLEAN Gal_get_alpha_color(unsigned long *color) { - GAL_ALPHACOLOR sGetalphacolor; + GAL_ALPHACOLOR sGetalphacolor; - INIT_GAL(&sGetalphacolor); - sGetalphacolor.dwSubfunction = GALFN_GETALPHACOLOR; + INIT_GAL(&sGetalphacolor); + sGetalphacolor.dwSubfunction = GALFN_GETALPHACOLOR; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphacolor)) - return 0; - else { - *color = sGetalphacolor.color; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetalphacolor)) + return 0; + else { + *color = sGetalphacolor.color; + return 1; + } } /*-------------------------------------------------------------------------- @@ -2912,15 +2913,15 @@ Gal_get_alpha_color(unsigned long *color) BOOLEAN Gal_select_alpha_region(int region) { - GAL_ALPHAREGION sSetVideo; + GAL_ALPHAREGION sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETALPHAREGION; - sSetVideo.region = region; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETALPHAREGION; + sSetVideo.region = region; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2934,15 +2935,15 @@ Gal_select_alpha_region(int region) BOOLEAN Gal_set_video_outside_alpha(int enable) { - GAL_VIDEOOUTSIDEALPHA sSetVideo; + GAL_VIDEOOUTSIDEALPHA sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOOUTSIDEALPHA; - sSetVideo.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOOUTSIDEALPHA; + sSetVideo.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -2956,22 +2957,23 @@ Gal_set_video_outside_alpha(int enable) BOOLEAN Gal_set_video_palette(unsigned long *palette) { - GAL_VIDEOPALETTE sSetVideo; + GAL_VIDEOPALETTE sSetVideo; - INIT_GAL(&sSetVideo); - sSetVideo.dwSubfunction = GALFN_SETVIDEOPALETTE; + INIT_GAL(&sSetVideo); + sSetVideo.dwSubfunction = GALFN_SETVIDEOPALETTE; - if (palette == NULL) { - sSetVideo.identity = 1; - } else { - sSetVideo.identity = 0; - memcpy(sSetVideo.palette, palette, 256 * sizeof(*palette)); - } + if (palette == NULL) { + sSetVideo.identity = 1; + } + else { + sSetVideo.identity = 0; + memcpy(sSetVideo.palette, palette, 256 * sizeof(*palette)); + } - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) - return 0; - else - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideo)) + return 0; + else + return 1; } /** Video **********************************************************/ @@ -2989,16 +2991,17 @@ Gal_set_video_palette(unsigned long *palette) BOOLEAN Gal_set_icon_enable(int enable) { - GAL_ICONENABLE sSetIconenable; + GAL_ICONENABLE sSetIconenable; - INIT_GAL(&sSetIconenable); - sSetIconenable.dwSubfunction = GALFN_SETICONENABLE; - sSetIconenable.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetIconenable)) { - return 0; - } else { - return 1; - } + INIT_GAL(&sSetIconenable); + sSetIconenable.dwSubfunction = GALFN_SETICONENABLE; + sSetIconenable.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetIconenable)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3013,20 +3016,21 @@ Gal_set_icon_enable(int enable) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_icon_colors(unsigned long color0, unsigned long color1, - unsigned long color2) + unsigned long color2) { - GAL_ICONCOLORS sSetIconcolors; + GAL_ICONCOLORS sSetIconcolors; - INIT_GAL(&sSetIconcolors); - sSetIconcolors.dwSubfunction = GALFN_SETICONCOLORS; - sSetIconcolors.color0 = color0; - sSetIconcolors.color1 = color1; - sSetIconcolors.color2 = color2; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetIconcolors)) { - return 0; - } else { - return 1; - } + INIT_GAL(&sSetIconcolors); + sSetIconcolors.dwSubfunction = GALFN_SETICONCOLORS; + sSetIconcolors.color0 = color0; + sSetIconcolors.color1 = color1; + sSetIconcolors.color2 = color2; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetIconcolors)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3041,17 +3045,18 @@ Gal_set_icon_colors(unsigned long color0, unsigned long color1, BOOLEAN Gal_set_icon_position(unsigned long memoffset, unsigned short xpos) { - GAL_ICONPOSITION sSetIconposi; + GAL_ICONPOSITION sSetIconposi; - INIT_GAL(&sSetIconposi); - sSetIconposi.dwSubfunction = GALFN_SETICONPOSITION; - sSetIconposi.memoffset = memoffset; - sSetIconposi.xpos = xpos; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetIconposi)) { - return 0; - } else { - return 1; - } + INIT_GAL(&sSetIconposi); + sSetIconposi.dwSubfunction = GALFN_SETICONPOSITION; + sSetIconposi.memoffset = memoffset; + sSetIconposi.xpos = xpos; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetIconposi)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3068,22 +3073,23 @@ Gal_set_icon_position(unsigned long memoffset, unsigned short xpos) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, - unsigned long *xormask, unsigned int lines) + unsigned long *xormask, unsigned int lines) { - GAL_ICONSHAPE64 sSetIconshape64; + GAL_ICONSHAPE64 sSetIconshape64; - INIT_GAL(&sSetIconshape64); - sSetIconshape64.dwSubfunction = GALFN_SETICONSHAPE64; - sSetIconshape64.memoffset = memoffset; - *(sSetIconshape64.andmask) = *andmask; - *(sSetIconshape64.xormask) = *xormask; - sSetIconshape64.lines = lines; + INIT_GAL(&sSetIconshape64); + sSetIconshape64.dwSubfunction = GALFN_SETICONSHAPE64; + sSetIconshape64.memoffset = memoffset; + *(sSetIconshape64.andmask) = *andmask; + *(sSetIconshape64.xormask) = *xormask; + sSetIconshape64.lines = lines; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetIconshape64)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetIconshape64)) { + return 0; + } + else { + return 1; + } } /* VIP Functions */ @@ -3102,16 +3108,17 @@ Gal_set_icon_shape64(unsigned long memoffset, unsigned long *andmask, BOOLEAN Gal_set_vip_enable(int enable) { - GAL_VIPENABLE sSetVipenable; + GAL_VIPENABLE sSetVipenable; - INIT_GAL(&sSetVipenable); - sSetVipenable.dwSubfunction = GALFN_SETVIPENABLE; - sSetVipenable.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipenable)) { - return 0; - } else { - return 1; - } + INIT_GAL(&sSetVipenable); + sSetVipenable.dwSubfunction = GALFN_SETVIPENABLE; + sSetVipenable.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipenable)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3126,17 +3133,18 @@ Gal_set_vip_enable(int enable) BOOLEAN Gal_get_vip_enable(int *enable) { - GAL_VIPENABLE sGetVipenable; + GAL_VIPENABLE sGetVipenable; - INIT_GAL(&sGetVipenable); - sGetVipenable.dwSubfunction = GALFN_GETVIPENABLE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipenable)) { - return 0; - } else { + INIT_GAL(&sGetVipenable); + sGetVipenable.dwSubfunction = GALFN_GETVIPENABLE; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipenable)) { + return 0; + } + else { - *enable = sGetVipenable.enable; - return 1; - } + *enable = sGetVipenable.enable; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3151,17 +3159,18 @@ Gal_get_vip_enable(int *enable) BOOLEAN Gal_set_vip_capture_run_mode(int mode) { - GAL_VIPCAPTURERUNMODE sSetVipcapturerunmode; + GAL_VIPCAPTURERUNMODE sSetVipcapturerunmode; - INIT_GAL(&sSetVipcapturerunmode); - sSetVipcapturerunmode.dwSubfunction = GALFN_SETVIPCAPTURERUNMODE; - sSetVipcapturerunmode.mode = mode; + INIT_GAL(&sSetVipcapturerunmode); + sSetVipcapturerunmode.dwSubfunction = GALFN_SETVIPCAPTURERUNMODE; + sSetVipcapturerunmode.mode = mode; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipcapturerunmode)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipcapturerunmode)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3177,18 +3186,19 @@ Gal_set_vip_capture_run_mode(int mode) BOOLEAN Gal_set_vip_base(unsigned long even, unsigned long odd) { - GAL_VIPBASE sSetVipBase; + GAL_VIPBASE sSetVipBase; - INIT_GAL(&sSetVipBase); - sSetVipBase.dwSubfunction = GALFN_SETVIPBASE; - sSetVipBase.even = even; - sSetVipBase.odd = odd; + INIT_GAL(&sSetVipBase); + sSetVipBase.dwSubfunction = GALFN_SETVIPBASE; + sSetVipBase.even = even; + sSetVipBase.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipBase)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipBase)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3204,18 +3214,19 @@ Gal_set_vip_base(unsigned long even, unsigned long odd) BOOLEAN Gal_get_vip_base(unsigned long *address, int odd) { - GAL_VIPBASE sGetVipBase; + GAL_VIPBASE sGetVipBase; - INIT_GAL(&sGetVipBase); - sGetVipBase.dwSubfunction = GALFN_GETVIPBASE; - sGetVipBase.odd = odd; + INIT_GAL(&sGetVipBase); + sGetVipBase.dwSubfunction = GALFN_GETVIPBASE; + sGetVipBase.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipBase)) { - return 0; - } else { - *address = sGetVipBase.address; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipBase)) { + return 0; + } + else { + *address = sGetVipBase.address; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3230,17 +3241,18 @@ Gal_get_vip_base(unsigned long *address, int odd) BOOLEAN Gal_set_vip_pitch(unsigned long pitch) { - GAL_VIPPITCH sSetVipPitch; + GAL_VIPPITCH sSetVipPitch; - INIT_GAL(&sSetVipPitch); - sSetVipPitch.dwSubfunction = GALFN_SETVIPPITCH; - sSetVipPitch.pitch = pitch; + INIT_GAL(&sSetVipPitch); + sSetVipPitch.dwSubfunction = GALFN_SETVIPPITCH; + sSetVipPitch.pitch = pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipPitch)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipPitch)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3255,18 +3267,19 @@ Gal_set_vip_pitch(unsigned long pitch) BOOLEAN Gal_get_vip_pitch(unsigned long *pitch) { - GAL_VIPPITCH sGetVipPitch; + GAL_VIPPITCH sGetVipPitch; - INIT_GAL(&sGetVipPitch); - sGetVipPitch.dwSubfunction = GALFN_GETVIPPITCH; + INIT_GAL(&sGetVipPitch); + sGetVipPitch.dwSubfunction = GALFN_GETVIPPITCH; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipPitch)) { - return 0; - } else { - *pitch = sGetVipPitch.pitch; - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipPitch)) { + return 0; + } + else { + *pitch = sGetVipPitch.pitch; + return 1; - } + } } /*-------------------------------------------------------------------------- @@ -3280,17 +3293,18 @@ Gal_get_vip_pitch(unsigned long *pitch) BOOLEAN Gal_set_vip_mode(int mode) { - GAL_VIPMODE sSetVipMode; + GAL_VIPMODE sSetVipMode; - INIT_GAL(&sSetVipMode); - sSetVipMode.dwSubfunction = GALFN_SETVIPMODE; - sSetVipMode.mode = mode; + INIT_GAL(&sSetVipMode); + sSetVipMode.dwSubfunction = GALFN_SETVIPMODE; + sSetVipMode.mode = mode; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipMode)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipMode)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3304,18 +3318,19 @@ Gal_set_vip_mode(int mode) BOOLEAN Gal_get_vip_mode(int *mode) { - GAL_VIPMODE sGetVipMode; + GAL_VIPMODE sGetVipMode; - INIT_GAL(&sGetVipMode); - sGetVipMode.dwSubfunction = GALFN_GETVIPMODE; + INIT_GAL(&sGetVipMode); + sGetVipMode.dwSubfunction = GALFN_GETVIPMODE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipMode)) { - return 0; - } else { + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipMode)) { + return 0; + } + else { - *mode = sGetVipMode.mode; - return 1; - } + *mode = sGetVipMode.mode; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3330,17 +3345,18 @@ Gal_get_vip_mode(int *mode) BOOLEAN Gal_set_vip_bus_request_threshold_high(int enable) { - GAL_VIPBUS_RTH sSetVipBRTH; + GAL_VIPBUS_RTH sSetVipBRTH; - INIT_GAL(&sSetVipBRTH); - sSetVipBRTH.dwSubfunction = GALFN_SETVIPBRTH; - sSetVipBRTH.enable = enable; + INIT_GAL(&sSetVipBRTH); + sSetVipBRTH.dwSubfunction = GALFN_SETVIPBRTH; + sSetVipBRTH.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipBRTH)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVipBRTH)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3355,18 +3371,19 @@ Gal_set_vip_bus_request_threshold_high(int enable) BOOLEAN Gal_get_vip_bus_request_threshold_high(int *enable) { - GAL_VIPBUS_RTH sGetVipBRTH; + GAL_VIPBUS_RTH sGetVipBRTH; - INIT_GAL(&sGetVipBRTH); - sGetVipBRTH.dwSubfunction = GALFN_GETVIPBRTH; + INIT_GAL(&sGetVipBRTH); + sGetVipBRTH.dwSubfunction = GALFN_GETVIPBRTH; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipBRTH)) { - return 0; - } else { + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipBRTH)) { + return 0; + } + else { - *enable = sGetVipBRTH.enable; - return 1; - } + *enable = sGetVipBRTH.enable; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3382,17 +3399,18 @@ Gal_get_vip_bus_request_threshold_high(int *enable) BOOLEAN Gal_set_vip_last_line(int last_line) { - GAL_VIPLASTLINE sSetViplastline; + GAL_VIPLASTLINE sSetViplastline; - INIT_GAL(&sSetViplastline); - sSetViplastline.dwSubfunction = GALFN_SETVIPLASTLINE; - sSetViplastline.last_line = last_line; + INIT_GAL(&sSetViplastline); + sSetViplastline.dwSubfunction = GALFN_SETVIPLASTLINE; + sSetViplastline.last_line = last_line; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetViplastline)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetViplastline)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3408,17 +3426,18 @@ Gal_set_vip_last_line(int last_line) BOOLEAN Gal_get_vip_line(int *vip_line) { - GAL_VIPLINE sGetVipline; + GAL_VIPLINE sGetVipline; - INIT_GAL(&sGetVipline); - sGetVipline.dwSubfunction = GALFN_GETVIPLINE; + INIT_GAL(&sGetVipline); + sGetVipline.dwSubfunction = GALFN_GETVIPLINE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipline)) { - return 0; - } else { - *vip_line = sGetVipline.status; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVipline)) { + return 0; + } + else { + *vip_line = sGetVipline.status; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3433,17 +3452,18 @@ Gal_get_vip_line(int *vip_line) BOOLEAN Gal_test_vip_odd_field(int *status) { - GAL_TESTVIPODDFIELD sTestVipoddfield; + GAL_TESTVIPODDFIELD sTestVipoddfield; - INIT_GAL(&sTestVipoddfield); - sTestVipoddfield.dwSubfunction = GALFN_TESTVIPODDFIELD; + INIT_GAL(&sTestVipoddfield); + sTestVipoddfield.dwSubfunction = GALFN_TESTVIPODDFIELD; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sTestVipoddfield)) { - return 0; - } else { - *status = sTestVipoddfield.status; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sTestVipoddfield)) { + return 0; + } + else { + *status = sTestVipoddfield.status; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3458,17 +3478,18 @@ Gal_test_vip_odd_field(int *status) BOOLEAN Gal_test_vip_bases_updated(int *status) { - GAL_TESTVIPBASESUPDATED sTestVipbasesupdated; + GAL_TESTVIPBASESUPDATED sTestVipbasesupdated; - INIT_GAL(&sTestVipbasesupdated); - sTestVipbasesupdated.dwSubfunction = GALFN_TESTVIPBASESUPDATED; + INIT_GAL(&sTestVipbasesupdated); + sTestVipbasesupdated.dwSubfunction = GALFN_TESTVIPBASESUPDATED; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sTestVipbasesupdated)) { - return 0; - } else { - *status = sTestVipbasesupdated.status; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sTestVipbasesupdated)) { + return 0; + } + else { + *status = sTestVipbasesupdated.status; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3483,17 +3504,18 @@ Gal_test_vip_bases_updated(int *status) BOOLEAN Gal_test_vip_fifo_overflow(int *status) { - GAL_TESTVIPOVERFLOW sTestVipoverflow; + GAL_TESTVIPOVERFLOW sTestVipoverflow; - INIT_GAL(&sTestVipoverflow); - sTestVipoverflow.dwSubfunction = GALFN_TESTVIPFIFOOVERFLOW; + INIT_GAL(&sTestVipoverflow); + sTestVipoverflow.dwSubfunction = GALFN_TESTVIPFIFOOVERFLOW; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sTestVipoverflow)) { - return 0; - } else { - *status = sTestVipoverflow.status; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sTestVipoverflow)) { + return 0; + } + else { + *status = sTestVipoverflow.status; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3508,16 +3530,17 @@ Gal_test_vip_fifo_overflow(int *status) BOOLEAN Gal_set_vbi_enable(int enable) { - GAL_VBIENABLE sSetVbienable; + GAL_VBIENABLE sSetVbienable; - INIT_GAL(&sSetVbienable); - sSetVbienable.dwSubfunction = GALFN_SETVBIENABLE; - sSetVbienable.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbienable)) { - return 0; - } else { - return 1; - } + INIT_GAL(&sSetVbienable); + sSetVbienable.dwSubfunction = GALFN_SETVBIENABLE; + sSetVbienable.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbienable)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3532,17 +3555,18 @@ Gal_set_vbi_enable(int enable) BOOLEAN Gal_get_vbi_enable(int *enable) { - GAL_VBIENABLE sGetVbienable; + GAL_VBIENABLE sGetVbienable; - INIT_GAL(&sGetVbienable); - sGetVbienable.dwSubfunction = GALFN_GETVBIENABLE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbienable)) { - return 0; - } else { + INIT_GAL(&sGetVbienable); + sGetVbienable.dwSubfunction = GALFN_GETVBIENABLE; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbienable)) { + return 0; + } + else { - *enable = sGetVbienable.enable; - return 1; - } + *enable = sGetVbienable.enable; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3558,18 +3582,19 @@ Gal_get_vbi_enable(int *enable) BOOLEAN Gal_set_vbi_base(unsigned long even, unsigned long odd) { - GAL_VBIBASE sSetVbiBase; + GAL_VBIBASE sSetVbiBase; - INIT_GAL(&sSetVbiBase); - sSetVbiBase.dwSubfunction = GALFN_SETVBIBASE; - sSetVbiBase.even = even; - sSetVbiBase.odd = odd; + INIT_GAL(&sSetVbiBase); + sSetVbiBase.dwSubfunction = GALFN_SETVBIBASE; + sSetVbiBase.even = even; + sSetVbiBase.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbiBase)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbiBase)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3585,18 +3610,19 @@ Gal_set_vbi_base(unsigned long even, unsigned long odd) BOOLEAN Gal_get_vbi_base(unsigned long *address, int odd) { - GAL_VBIBASE sGetVbiBase; + GAL_VBIBASE sGetVbiBase; - INIT_GAL(&sGetVbiBase); - sGetVbiBase.dwSubfunction = GALFN_GETVBIBASE; - sGetVbiBase.odd = odd; + INIT_GAL(&sGetVbiBase); + sGetVbiBase.dwSubfunction = GALFN_GETVBIBASE; + sGetVbiBase.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbiBase)) { - return 0; - } else { - *address = sGetVbiBase.address; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbiBase)) { + return 0; + } + else { + *address = sGetVbiBase.address; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3612,17 +3638,18 @@ Gal_get_vbi_base(unsigned long *address, int odd) BOOLEAN Gal_set_vbi_pitch(unsigned long pitch) { - GAL_VBIPITCH sSetVbiPitch; + GAL_VBIPITCH sSetVbiPitch; - INIT_GAL(&sSetVbiPitch); - sSetVbiPitch.dwSubfunction = GALFN_SETVBIPITCH; - sSetVbiPitch.pitch = pitch; + INIT_GAL(&sSetVbiPitch); + sSetVbiPitch.dwSubfunction = GALFN_SETVBIPITCH; + sSetVbiPitch.pitch = pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbiPitch)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbiPitch)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3638,18 +3665,19 @@ Gal_set_vbi_pitch(unsigned long pitch) BOOLEAN Gal_get_vbi_pitch(unsigned long *pitch) { - GAL_VBIPITCH sGetVbiPitch; + GAL_VBIPITCH sGetVbiPitch; - INIT_GAL(&sGetVbiPitch); - sGetVbiPitch.dwSubfunction = GALFN_GETVBIPITCH; + INIT_GAL(&sGetVbiPitch); + sGetVbiPitch.dwSubfunction = GALFN_GETVBIPITCH; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbiPitch)) { - return 0; - } else { - *pitch = sGetVbiPitch.pitch; - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbiPitch)) { + return 0; + } + else { + *pitch = sGetVbiPitch.pitch; + return 1; - } + } } /*-------------------------------------------------------------------------- @@ -3664,17 +3692,18 @@ Gal_get_vbi_pitch(unsigned long *pitch) BOOLEAN Gal_set_vbi_mode(int mode) { - GAL_VBIMODE sSetVbiMode; + GAL_VBIMODE sSetVbiMode; - INIT_GAL(&sSetVbiMode); - sSetVbiMode.dwSubfunction = GALFN_SETVBIMODE; - sSetVbiMode.mode = mode; + INIT_GAL(&sSetVbiMode); + sSetVbiMode.dwSubfunction = GALFN_SETVBIMODE; + sSetVbiMode.mode = mode; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbiMode)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbiMode)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3689,18 +3718,19 @@ Gal_set_vbi_mode(int mode) BOOLEAN Gal_get_vbi_mode(int *mode) { - GAL_VBIMODE sGetVbiMode; + GAL_VBIMODE sGetVbiMode; - INIT_GAL(&sGetVbiMode); - sGetVbiMode.dwSubfunction = GALFN_GETVBIMODE; + INIT_GAL(&sGetVbiMode); + sGetVbiMode.dwSubfunction = GALFN_GETVBIMODE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbiMode)) { - return 0; - } else { + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbiMode)) { + return 0; + } + else { - *mode = sGetVbiMode.mode; - return 1; - } + *mode = sGetVbiMode.mode; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3717,48 +3747,50 @@ Gal_get_vbi_mode(int *mode) BOOLEAN Gal_set_vbi_direct(unsigned long even_lines, unsigned long odd_lines) { - GAL_SETVBIDIRECT sSetVbidirect; + GAL_SETVBIDIRECT sSetVbidirect; - INIT_GAL(&sSetVbidirect); - sSetVbidirect.dwSubfunction = GALFN_SETVBIDIRECT; - sSetVbidirect.even_lines = even_lines; - sSetVbidirect.odd_lines = odd_lines; + INIT_GAL(&sSetVbidirect); + sSetVbidirect.dwSubfunction = GALFN_SETVBIDIRECT; + sSetVbidirect.even_lines = even_lines; + sSetVbidirect.odd_lines = odd_lines; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbidirect)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbidirect)) { + return 0; + } + else { + return 1; + } } + BOOLEAN Gal2_set_destination_stride(unsigned short stride) { - GAL_STRIDE sSetStride; + GAL_STRIDE sSetStride; - INIT_GAL(&sSetStride); - sSetStride.dwSubfunction = GALFN_SETDESTINATIONSTRIDE; + INIT_GAL(&sSetStride); + sSetStride.dwSubfunction = GALFN_SETDESTINATIONSTRIDE; - sSetStride.stride = stride; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetStride)) - return 0; - else - return 1; + sSetStride.stride = stride; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetStride)) + return 0; + else + return 1; } BOOLEAN Gal2_set_pattern_origin(int x, int y) { - GAL_PATTERNORIGIN sSetPatOrigin; + GAL_PATTERNORIGIN sSetPatOrigin; - INIT_GAL(&sSetPatOrigin); - sSetPatOrigin.dwSubfunction = GALFN_SETPATTERNORIGIN; + INIT_GAL(&sSetPatOrigin); + sSetPatOrigin.dwSubfunction = GALFN_SETPATTERNORIGIN; - sSetPatOrigin.x = x; - sSetPatOrigin.y = y; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetPatOrigin)) - return 0; - else - return 1; + sSetPatOrigin.x = x; + sSetPatOrigin.y = y; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetPatOrigin)) + return 0; + else + return 1; } /*-------------------------------------------------------------------------- @@ -3775,18 +3807,19 @@ Gal2_set_pattern_origin(int x, int y) BOOLEAN Gal_get_vbi_direct(int odd, unsigned long *direct_lines) { - GAL_GETVBIDIRECT sGetVbidirect; + GAL_GETVBIDIRECT sGetVbidirect; - INIT_GAL(&sGetVbidirect); - sGetVbidirect.dwSubfunction = GALFN_GETVBIDIRECT; - sGetVbidirect.odd = odd; + INIT_GAL(&sGetVbidirect); + sGetVbidirect.dwSubfunction = GALFN_GETVBIDIRECT; + sGetVbidirect.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbidirect)) { - return 0; - } else { - *direct_lines = sGetVbidirect.direct_lines; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbidirect)) { + return 0; + } + else { + *direct_lines = sGetVbidirect.direct_lines; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3801,16 +3834,17 @@ Gal_get_vbi_direct(int odd, unsigned long *direct_lines) BOOLEAN Gal_set_vbi_interrupt(int enable) { - GAL_VBIINTERRUPT sSetVbiinterrupt; + GAL_VBIINTERRUPT sSetVbiinterrupt; - INIT_GAL(&sSetVbiinterrupt); - sSetVbiinterrupt.dwSubfunction = GALFN_SETVBIINTERRUPT; - sSetVbiinterrupt.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbiinterrupt)) { - return 0; - } else { - return 1; - } + INIT_GAL(&sSetVbiinterrupt); + sSetVbiinterrupt.dwSubfunction = GALFN_SETVBIINTERRUPT; + sSetVbiinterrupt.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbiinterrupt)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3825,17 +3859,18 @@ Gal_set_vbi_interrupt(int enable) BOOLEAN Gal_get_vbi_interrupt(int *enable) { - GAL_VBIINTERRUPT sGetVbiinterrupt; + GAL_VBIINTERRUPT sGetVbiinterrupt; - INIT_GAL(&sGetVbiinterrupt); - sGetVbiinterrupt.dwSubfunction = GALFN_GETVBIINTERRUPT; + INIT_GAL(&sGetVbiinterrupt); + sGetVbiinterrupt.dwSubfunction = GALFN_GETVBIINTERRUPT; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbiinterrupt)) { - return 0; - } else { - *enable = sGetVbiinterrupt.enable; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbiinterrupt)) { + return 0; + } + else { + *enable = sGetVbiinterrupt.enable; + return 1; + } } /*-------------------------------------------------------------------------- @@ -3851,18 +3886,19 @@ Gal_get_vbi_interrupt(int *enable) BOOLEAN Gal2_set_source_stride(unsigned short stride) { - GAL_STRIDE sSetsourcestride; + GAL_STRIDE sSetsourcestride; - INIT_GAL(&sSetsourcestride); - sSetsourcestride.dwSubfunction = GALFN_SETSOURCESTRIDE; + INIT_GAL(&sSetsourcestride); + sSetsourcestride.dwSubfunction = GALFN_SETSOURCESTRIDE; - sSetsourcestride.stride = stride; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetsourcestride)) { - return 0; - } else { + sSetsourcestride.stride = stride; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetsourcestride)) { + return 0; + } + else { - return 1; - } + return 1; + } } /*-------------------------------------------------------------------------- @@ -3880,19 +3916,20 @@ Gal2_set_source_stride(unsigned short stride) BOOLEAN Gal2_set_source_transparency(unsigned long color, unsigned long mask) { - GAL_SOURCETRANSPARENCY sSetsourcetransparency; + GAL_SOURCETRANSPARENCY sSetsourcetransparency; - INIT_GAL(&sSetsourcetransparency); - sSetsourcetransparency.dwSubfunction = GALFN_SETSOURCETRANSPARENCY; + INIT_GAL(&sSetsourcetransparency); + sSetsourcetransparency.dwSubfunction = GALFN_SETSOURCETRANSPARENCY; - sSetsourcetransparency.color = color; - sSetsourcetransparency.mask = mask; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetsourcetransparency)) { - return 0; - } else { + sSetsourcetransparency.color = color; + sSetsourcetransparency.mask = mask; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetsourcetransparency)) { + return 0; + } + else { - return 1; - } + return 1; + } } /*-------------------------------------------------------------------------- @@ -3906,17 +3943,18 @@ Gal2_set_source_transparency(unsigned long color, unsigned long mask) BOOLEAN Gal2_set_alpha_mode(int mode) { - GAL_GFX2ALPHAMODE sSetalphamode; + GAL_GFX2ALPHAMODE sSetalphamode; - INIT_GAL(&sSetalphamode); - sSetalphamode.dwSubfunction = GALFN_GFX2SETALPHAMODE; + INIT_GAL(&sSetalphamode); + sSetalphamode.dwSubfunction = GALFN_GFX2SETALPHAMODE; - sSetalphamode.mode = mode; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetalphamode)) { - return 0; - } else { - return 1; - } + sSetalphamode.mode = mode; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetalphamode)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3931,17 +3969,18 @@ Gal2_set_alpha_mode(int mode) BOOLEAN Gal2_set_alpha_value(unsigned char value) { - GAL_GFX2ALPHAVALUE sSetalphavalue; + GAL_GFX2ALPHAVALUE sSetalphavalue; - INIT_GAL(&sSetalphavalue); - sSetalphavalue.dwSubfunction = GALFN_GFX2SETALPHAVALUE; + INIT_GAL(&sSetalphavalue); + sSetalphavalue.dwSubfunction = GALFN_GFX2SETALPHAVALUE; - sSetalphavalue.value = value; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetalphavalue)) { - return 0; - } else { - return 1; - } + sSetalphavalue.value = value; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetalphavalue)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3959,21 +3998,22 @@ Gal2_set_alpha_value(unsigned char value) *------------------------------------------------------------------------*/ BOOLEAN Gal_gfx2_pattern_fill(unsigned long dstoffset, unsigned short width, - unsigned short height) + unsigned short height) { - GAL_GFX2PATTERNFILL sPatternfill; + GAL_GFX2PATTERNFILL sPatternfill; - INIT_GAL(&sPatternfill); - sPatternfill.dwSubfunction = GALFN_GFX2PATTERNFILL; + INIT_GAL(&sPatternfill); + sPatternfill.dwSubfunction = GALFN_GFX2PATTERNFILL; - sPatternfill.dstoffset = dstoffset; - sPatternfill.width = width; - sPatternfill.height = height; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sPatternfill)) { - return 0; - } else { - return 1; - } + sPatternfill.dstoffset = dstoffset; + sPatternfill.width = width; + sPatternfill.height = height; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sPatternfill)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -3992,24 +4032,25 @@ Gal_gfx2_pattern_fill(unsigned long dstoffset, unsigned short width, *------------------------------------------------------------------------*/ BOOLEAN Gal2_screen_to_screen_blt(unsigned long srcoffset, - unsigned long dstoffset, unsigned short width, - unsigned short height, int flags) + unsigned long dstoffset, unsigned short width, + unsigned short height, int flags) { - GAL_GFX2SCREENTOSCREENBLT sScreentoScreenblt; + GAL_GFX2SCREENTOSCREENBLT sScreentoScreenblt; - INIT_GAL(&sScreentoScreenblt); - sScreentoScreenblt.dwSubfunction = GALFN_GFX2SCREENTOSCREENBLT; + INIT_GAL(&sScreentoScreenblt); + sScreentoScreenblt.dwSubfunction = GALFN_GFX2SCREENTOSCREENBLT; - sScreentoScreenblt.srcoffset = srcoffset; - sScreentoScreenblt.dstoffset = dstoffset; - sScreentoScreenblt.width = width; - sScreentoScreenblt.height = height; - sScreentoScreenblt.flags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sScreentoScreenblt)) { - return 0; - } else { - return 1; - } + sScreentoScreenblt.srcoffset = srcoffset; + sScreentoScreenblt.dstoffset = dstoffset; + sScreentoScreenblt.width = width; + sScreentoScreenblt.height = height; + sScreentoScreenblt.flags = flags; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sScreentoScreenblt)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4028,28 +4069,29 @@ Gal2_screen_to_screen_blt(unsigned long srcoffset, *------------------------------------------------------------------------*/ BOOLEAN Gal2_mono_expand_blt(unsigned long srcbase, unsigned short srcx, - unsigned short srcy, unsigned long dstoffset, - unsigned short width, unsigned short height, - int byte_packed) + unsigned short srcy, unsigned long dstoffset, + unsigned short width, unsigned short height, + int byte_packed) { - GAL_GFX2MONOEXPANDBLT sMonoexpandblt; + GAL_GFX2MONOEXPANDBLT sMonoexpandblt; - INIT_GAL(&sMonoexpandblt); - sMonoexpandblt.dwSubfunction = GALFN_GFX2MONOEXPANDBLT; - sMonoexpandblt.srcbase = srcbase; - sMonoexpandblt.srcx = srcx; - sMonoexpandblt.srcy = srcy; - sMonoexpandblt.dstoffset = dstoffset; - sMonoexpandblt.width = width; - sMonoexpandblt.height = height; - sMonoexpandblt.byte_packed = byte_packed; + INIT_GAL(&sMonoexpandblt); + sMonoexpandblt.dwSubfunction = GALFN_GFX2MONOEXPANDBLT; + sMonoexpandblt.srcbase = srcbase; + sMonoexpandblt.srcx = srcx; + sMonoexpandblt.srcy = srcy; + sMonoexpandblt.dstoffset = dstoffset; + sMonoexpandblt.width = width; + sMonoexpandblt.height = height; + sMonoexpandblt.byte_packed = byte_packed; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sMonoexpandblt)) { - return 0; - } else { - return 1; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sMonoexpandblt)) { + return 0; + } + else { + return 1; - } + } } /*-------------------------------------------------------------------------- @@ -4068,29 +4110,30 @@ Gal2_mono_expand_blt(unsigned long srcbase, unsigned short srcx, *------------------------------------------------------------------------*/ BOOLEAN Gal2_color_bitmap_to_screen_blt(unsigned short srcx, - unsigned short srcy, - unsigned long dstoffset, - unsigned short width, - unsigned short height, - unsigned char *data, unsigned short pitch) + unsigned short srcy, + unsigned long dstoffset, + unsigned short width, + unsigned short height, + unsigned char *data, unsigned short pitch) { - GAL_GFX2COLORBMPTOSCRBLT sColorbmptoscrblt; + GAL_GFX2COLORBMPTOSCRBLT sColorbmptoscrblt; - INIT_GAL(&sColorbmptoscrblt); - sColorbmptoscrblt.dwSubfunction = GALFN_GFX2COLORBMPTOSCRBLT; - sColorbmptoscrblt.srcx = srcx; - sColorbmptoscrblt.srcy = srcy; - sColorbmptoscrblt.dstoffset = dstoffset; - sColorbmptoscrblt.width = width; - sColorbmptoscrblt.height = height; - sColorbmptoscrblt.data = *data; - sColorbmptoscrblt.pitch = pitch; + INIT_GAL(&sColorbmptoscrblt); + sColorbmptoscrblt.dwSubfunction = GALFN_GFX2COLORBMPTOSCRBLT; + sColorbmptoscrblt.srcx = srcx; + sColorbmptoscrblt.srcy = srcy; + sColorbmptoscrblt.dstoffset = dstoffset; + sColorbmptoscrblt.width = width; + sColorbmptoscrblt.height = height; + sColorbmptoscrblt.data = *data; + sColorbmptoscrblt.pitch = pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sColorbmptoscrblt)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sColorbmptoscrblt)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4109,29 +4152,30 @@ Gal2_color_bitmap_to_screen_blt(unsigned short srcx, *------------------------------------------------------------------------*/ BOOLEAN Gal2_mono_bitmap_to_screen_blt(unsigned short srcx, - unsigned short srcy, - unsigned long dstoffset, - unsigned short width, - unsigned short height, - unsigned char *data, unsigned short pitch) + unsigned short srcy, + unsigned long dstoffset, + unsigned short width, + unsigned short height, + unsigned char *data, unsigned short pitch) { - GAL_GFX2MONOBMPTOSCRBLT sMonobmptoscrblt; + GAL_GFX2MONOBMPTOSCRBLT sMonobmptoscrblt; - INIT_GAL(&sMonobmptoscrblt); - sMonobmptoscrblt.dwSubfunction = GALFN_GFX2MONOBMPTOSCRBLT; - sMonobmptoscrblt.srcx = srcx; - sMonobmptoscrblt.srcy = srcy; - sMonobmptoscrblt.dstoffset = dstoffset; - sMonobmptoscrblt.width = width; - sMonobmptoscrblt.height = height; - sMonobmptoscrblt.data = *data; - sMonobmptoscrblt.pitch = pitch; + INIT_GAL(&sMonobmptoscrblt); + sMonobmptoscrblt.dwSubfunction = GALFN_GFX2MONOBMPTOSCRBLT; + sMonobmptoscrblt.srcx = srcx; + sMonobmptoscrblt.srcy = srcy; + sMonobmptoscrblt.dstoffset = dstoffset; + sMonobmptoscrblt.width = width; + sMonobmptoscrblt.height = height; + sMonobmptoscrblt.data = *data; + sMonobmptoscrblt.pitch = pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sMonobmptoscrblt)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sMonobmptoscrblt)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4150,25 +4194,26 @@ Gal2_mono_bitmap_to_screen_blt(unsigned short srcx, *------------------------------------------------------------------------*/ BOOLEAN Gal2_bresenham_line(unsigned long dstoffset, unsigned short length, - unsigned short initerr, unsigned short axialerr, - unsigned short diagerr, unsigned short flags) + unsigned short initerr, unsigned short axialerr, + unsigned short diagerr, unsigned short flags) { - GAL_GFX2BRESENHAMLINE sBresenhamline; + GAL_GFX2BRESENHAMLINE sBresenhamline; - INIT_GAL(&sBresenhamline); - sBresenhamline.dwSubfunction = GALFN_GFX2BRESENHAMLINE; - sBresenhamline.dstoffset = dstoffset; - sBresenhamline.length = length; - sBresenhamline.initerr = initerr; - sBresenhamline.axialerr = axialerr; - sBresenhamline.diagerr = diagerr; - sBresenhamline.flags = flags; + INIT_GAL(&sBresenhamline); + sBresenhamline.dwSubfunction = GALFN_GFX2BRESENHAMLINE; + sBresenhamline.dstoffset = dstoffset; + sBresenhamline.length = length; + sBresenhamline.initerr = initerr; + sBresenhamline.axialerr = axialerr; + sBresenhamline.diagerr = diagerr; + sBresenhamline.flags = flags; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sBresenhamline)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sBresenhamline)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4182,16 +4227,17 @@ Gal2_bresenham_line(unsigned long dstoffset, unsigned short length, BOOLEAN Gal2_sync_to_vblank(void) { - GAL_GFX2SYNCTOVBLANK sSynctovblank; + GAL_GFX2SYNCTOVBLANK sSynctovblank; - INIT_GAL(&sSynctovblank); - sSynctovblank.dwSubfunction = GALFN_GFX2SYNCTOVBLANK; + INIT_GAL(&sSynctovblank); + sSynctovblank.dwSubfunction = GALFN_GFX2SYNCTOVBLANK; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSynctovblank)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSynctovblank)) { + return 0; + } + else { + return 1; + } } /* Video routines */ @@ -4209,18 +4255,19 @@ Gal2_sync_to_vblank(void) BOOLEAN Gal_set_video_yuv_pitch(unsigned long y_pitch, unsigned long uv_pitch) { - GAL_VIDEOYUVPITCH sSetVideoyuvpitch; + GAL_VIDEOYUVPITCH sSetVideoyuvpitch; - INIT_GAL(&sSetVideoyuvpitch); - sSetVideoyuvpitch.dwSubfunction = GALFN_SETVIDEOYUVPITCH; - sSetVideoyuvpitch.y_pitch = y_pitch; - sSetVideoyuvpitch.uv_pitch = uv_pitch; + INIT_GAL(&sSetVideoyuvpitch); + sSetVideoyuvpitch.dwSubfunction = GALFN_SETVIDEOYUVPITCH; + sSetVideoyuvpitch.y_pitch = y_pitch; + sSetVideoyuvpitch.uv_pitch = uv_pitch; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideoyuvpitch)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideoyuvpitch)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4236,19 +4283,20 @@ Gal_set_video_yuv_pitch(unsigned long y_pitch, unsigned long uv_pitch) BOOLEAN Gal_get_video_yuv_pitch(unsigned long *y_pitch, unsigned long *uv_pitch) { - GAL_VIDEOYUVPITCH sGetVideoyuvpitch; + GAL_VIDEOYUVPITCH sGetVideoyuvpitch; - INIT_GAL(&sGetVideoyuvpitch); - sGetVideoyuvpitch.dwSubfunction = GALFN_GETVIDEOYUVPITCH; + INIT_GAL(&sGetVideoyuvpitch); + sGetVideoyuvpitch.dwSubfunction = GALFN_GETVIDEOYUVPITCH; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVideoyuvpitch)) { - return 0; - } else { - *y_pitch = sGetVideoyuvpitch.y_pitch; - *uv_pitch = sGetVideoyuvpitch.uv_pitch; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVideoyuvpitch)) { + return 0; + } + else { + *y_pitch = sGetVideoyuvpitch.y_pitch; + *uv_pitch = sGetVideoyuvpitch.uv_pitch; - return 1; - } + return 1; + } } /*-------------------------------------------------------------------------- @@ -4264,21 +4312,22 @@ Gal_get_video_yuv_pitch(unsigned long *y_pitch, unsigned long *uv_pitch) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_video_yuv_offsets(unsigned long y_offset, unsigned long u_offset, - unsigned long v_offset) + unsigned long v_offset) { - GAL_VIDEOYUVOFFSETS sSetVideoyuvoffsets; + GAL_VIDEOYUVOFFSETS sSetVideoyuvoffsets; - INIT_GAL(&sSetVideoyuvoffsets); - sSetVideoyuvoffsets.dwSubfunction = GALFN_SETVIDEOYUVOFFSETS; - sSetVideoyuvoffsets.dwYoffset = y_offset; - sSetVideoyuvoffsets.dwUoffset = u_offset; - sSetVideoyuvoffsets.dwVoffset = v_offset; + INIT_GAL(&sSetVideoyuvoffsets); + sSetVideoyuvoffsets.dwSubfunction = GALFN_SETVIDEOYUVOFFSETS; + sSetVideoyuvoffsets.dwYoffset = y_offset; + sSetVideoyuvoffsets.dwUoffset = u_offset; + sSetVideoyuvoffsets.dwVoffset = v_offset; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideoyuvoffsets)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideoyuvoffsets)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4293,21 +4342,22 @@ Gal_set_video_yuv_offsets(unsigned long y_offset, unsigned long u_offset, * return: '1' was returned on success otherwise '0' was returned. *------------------------------------------------------------------------*/ BOOLEAN Gal_get_video_yuv_offsets(unsigned long *y_offset, - unsigned long *u_offset, unsigned long *v_offset) + unsigned long *u_offset, unsigned long *v_offset) { - GAL_VIDEOYUVOFFSETS sGetVideoyuvoffsets; + GAL_VIDEOYUVOFFSETS sGetVideoyuvoffsets; - INIT_GAL(&sGetVideoyuvoffsets); - sGetVideoyuvoffsets.dwSubfunction = GALFN_GETVIDEOYUVOFFSETS; + INIT_GAL(&sGetVideoyuvoffsets); + sGetVideoyuvoffsets.dwSubfunction = GALFN_GETVIDEOYUVOFFSETS; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVideoyuvoffsets)) { - return 0; - } else { - *y_offset = sGetVideoyuvoffsets.dwYoffset; - *u_offset = sGetVideoyuvoffsets.dwUoffset; - *v_offset = sGetVideoyuvoffsets.dwVoffset; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVideoyuvoffsets)) { + return 0; + } + else { + *y_offset = sGetVideoyuvoffsets.dwYoffset; + *u_offset = sGetVideoyuvoffsets.dwUoffset; + *v_offset = sGetVideoyuvoffsets.dwVoffset; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4322,17 +4372,18 @@ Gal_get_video_yuv_offsets(unsigned long *y_offset, *------------------------------------------------------------------------*/ BOOLEAN Gal_set_video_left_crop(unsigned short x) { - GAL_VIDEOLEFTCROP sSetVideoleftcrop;; + GAL_VIDEOLEFTCROP sSetVideoleftcrop;; - INIT_GAL(&sSetVideoleftcrop); - sSetVideoleftcrop.dwSubfunction = GALFN_SETVIDEOLEFTCROP; - sSetVideoleftcrop.x = x; + INIT_GAL(&sSetVideoleftcrop); + sSetVideoleftcrop.dwSubfunction = GALFN_SETVIDEOLEFTCROP; + sSetVideoleftcrop.x = x; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideoleftcrop)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideoleftcrop)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4348,18 +4399,19 @@ Gal_set_video_left_crop(unsigned short x) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_video_vertical_downscale(unsigned short srch, unsigned short dsth) { - GAL_VIDEOVERTICALDOWNSCALE sSetVideoverticaldownscale; + GAL_VIDEOVERTICALDOWNSCALE sSetVideoverticaldownscale; - INIT_GAL(&sSetVideoverticaldownscale); - sSetVideoverticaldownscale.dwSubfunction = GALFN_SETVIDEOVERTICALDOWNSCALE; - sSetVideoverticaldownscale.srch = srch; - sSetVideoverticaldownscale.dsth = dsth; + INIT_GAL(&sSetVideoverticaldownscale); + sSetVideoverticaldownscale.dwSubfunction = GALFN_SETVIDEOVERTICALDOWNSCALE; + sSetVideoverticaldownscale.srch = srch; + sSetVideoverticaldownscale.dsth = dsth; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideoverticaldownscale)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVideoverticaldownscale)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4373,17 +4425,18 @@ Gal_set_video_vertical_downscale(unsigned short srch, unsigned short dsth) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_vbi_source(VbiSourceType source) { - GAL_VBISOURCE sSetVbisource; + GAL_VBISOURCE sSetVbisource; - INIT_GAL(&sSetVbisource); - sSetVbisource.dwSubfunction = GALFN_SETVBISOURCE; - sSetVbisource.source = source; + INIT_GAL(&sSetVbisource); + sSetVbisource.dwSubfunction = GALFN_SETVBISOURCE; + sSetVbisource.source = source; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbisource)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbisource)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4398,18 +4451,19 @@ Gal_set_vbi_source(VbiSourceType source) BOOLEAN Gal_get_vbi_source(VbiSourceType * source) { - GAL_VBISOURCE sGetVbisource; + GAL_VBISOURCE sGetVbisource; - INIT_GAL(&sGetVbisource); - sGetVbisource.dwSubfunction = GALFN_GETVBISOURCE; + INIT_GAL(&sGetVbisource); + sGetVbisource.dwSubfunction = GALFN_GETVBISOURCE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbisource)) { - return 0; - } else { + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbisource)) { + return 0; + } + else { - *source = sGetVbisource.source; - return 1; - } + *source = sGetVbisource.source; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4425,18 +4479,19 @@ Gal_get_vbi_source(VbiSourceType * source) BOOLEAN Gal_set_vbi_lines(unsigned long even, unsigned long odd) { - GAL_VBILINES sSetVbilines; + GAL_VBILINES sSetVbilines; - INIT_GAL(&sSetVbilines); - sSetVbilines.dwSubfunction = GALFN_SETVBILINES; - sSetVbilines.even = even; - sSetVbilines.odd = odd; + INIT_GAL(&sSetVbilines); + sSetVbilines.dwSubfunction = GALFN_SETVBILINES; + sSetVbilines.even = even; + sSetVbilines.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbilines)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbilines)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4451,18 +4506,19 @@ Gal_set_vbi_lines(unsigned long even, unsigned long odd) *------------------------------------------------------------------------*/ BOOLEAN Gal_get_vbi_lines(int odd, unsigned long *lines) { - GAL_VBILINES sGetVbilines; + GAL_VBILINES sGetVbilines; - INIT_GAL(&sGetVbilines); - sGetVbilines.dwSubfunction = GALFN_GETVBILINES; - sGetVbilines.odd = odd; + INIT_GAL(&sGetVbilines); + sGetVbilines.dwSubfunction = GALFN_GETVBILINES; + sGetVbilines.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbilines)) { - return 0; - } else { - *lines = sGetVbilines.lines; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbilines)) { + return 0; + } + else { + *lines = sGetVbilines.lines; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4479,18 +4535,19 @@ Gal_get_vbi_lines(int odd, unsigned long *lines) BOOLEAN Gal_set_vbi_total(unsigned long even, unsigned long odd) { - GAL_VBITOTAL sSetVbitotal; + GAL_VBITOTAL sSetVbitotal; - INIT_GAL(&sSetVbitotal); - sSetVbitotal.dwSubfunction = GALFN_SETVBITOTAL; - sSetVbitotal.even = even; - sSetVbitotal.odd = odd; + INIT_GAL(&sSetVbitotal); + sSetVbitotal.dwSubfunction = GALFN_SETVBITOTAL; + sSetVbitotal.even = even; + sSetVbitotal.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbitotal)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVbitotal)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4506,18 +4563,19 @@ Gal_set_vbi_total(unsigned long even, unsigned long odd) *------------------------------------------------------------------------*/ BOOLEAN Gal_get_vbi_total(int odd, unsigned long *total) { - GAL_VBITOTAL sGetVbitotal; + GAL_VBITOTAL sGetVbitotal; - INIT_GAL(&sGetVbitotal); - sGetVbitotal.dwSubfunction = GALFN_GETVBITOTAL; - sGetVbitotal.odd = odd; + INIT_GAL(&sGetVbitotal); + sGetVbitotal.dwSubfunction = GALFN_GETVBITOTAL; + sGetVbitotal.odd = odd; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbitotal)) { - return 0; - } else { - *total = sGetVbitotal.total; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVbitotal)) { + return 0; + } + else { + *total = sGetVbitotal.total; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4531,17 +4589,18 @@ Gal_get_vbi_total(int odd, unsigned long *total) *------------------------------------------------------------------------*/ BOOLEAN Gal_set_vertical_scaler_offset(char offset) { - GAL_VSCALEROFFSET sSetVscaleroffset; + GAL_VSCALEROFFSET sSetVscaleroffset; - INIT_GAL(&sSetVscaleroffset); - sSetVscaleroffset.dwSubfunction = GALFN_SETVSCALEROFFSET; - sSetVscaleroffset.offset = offset; + INIT_GAL(&sSetVscaleroffset); + sSetVscaleroffset.dwSubfunction = GALFN_SETVSCALEROFFSET; + sSetVscaleroffset.offset = offset; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVscaleroffset)) { - return 0; - } else { - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetVscaleroffset)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4555,18 +4614,19 @@ Gal_set_vertical_scaler_offset(char offset) *------------------------------------------------------------------------*/ BOOLEAN Gal_get_vertical_scaler_offset(char *offset) { - GAL_VSCALEROFFSET sGetVscaleroffset; + GAL_VSCALEROFFSET sGetVscaleroffset; - INIT_GAL(&sGetVscaleroffset); - sGetVscaleroffset.dwSubfunction = GALFN_GETVSCALEROFFSET; + INIT_GAL(&sGetVscaleroffset); + sGetVscaleroffset.dwSubfunction = GALFN_GETVSCALEROFFSET; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVscaleroffset)) { - return 0; - } else { + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetVscaleroffset)) { + return 0; + } + else { - *offset = sGetVscaleroffset.offset; - return 1; - } + *offset = sGetVscaleroffset.offset; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4580,17 +4640,18 @@ Gal_get_vertical_scaler_offset(char *offset) BOOLEAN Gal_get_video_interlaced(int *interlaced) { - GAL_GETVIDEOINTERLACED sGetvideointerlaced; + GAL_GETVIDEOINTERLACED sGetvideointerlaced; - INIT_GAL(&sGetvideointerlaced); - sGetvideointerlaced.dwSubfunction = GALFN_GETVIDEOINTERLACED; + INIT_GAL(&sGetvideointerlaced); + sGetvideointerlaced.dwSubfunction = GALFN_GETVIDEOINTERLACED; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetvideointerlaced)) { - return 0; - } else { - *interlaced = sGetvideointerlaced.interlaced; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetvideointerlaced)) { + return 0; + } + else { + *interlaced = sGetvideointerlaced.interlaced; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4604,17 +4665,18 @@ Gal_get_video_interlaced(int *interlaced) BOOLEAN Gal_get_color_space_YUV(int *colorspace) { - GAL_COLORSPACEYUV sGetcolorspaceyuv; + GAL_COLORSPACEYUV sGetcolorspaceyuv; - INIT_GAL(&sGetcolorspaceyuv); - sGetcolorspaceyuv.dwSubfunction = GALFN_GETCOLORSPACEYUV; + INIT_GAL(&sGetcolorspaceyuv); + sGetcolorspaceyuv.dwSubfunction = GALFN_GETCOLORSPACEYUV; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetcolorspaceyuv)) { - return 0; - } else { - *colorspace = sGetcolorspaceyuv.colorspace; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetcolorspaceyuv)) { + return 0; + } + else { + *colorspace = sGetcolorspaceyuv.colorspace; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4628,17 +4690,18 @@ Gal_get_color_space_YUV(int *colorspace) BOOLEAN Gal_get_genlock_enable(int *enable) { - GAL_GENLOCKENABLE sGetgenlockenable; + GAL_GENLOCKENABLE sGetgenlockenable; - INIT_GAL(&sGetgenlockenable); - sGetgenlockenable.dwSubfunction = GALFN_GETGENLOCKENABLE; + INIT_GAL(&sGetgenlockenable); + sGetgenlockenable.dwSubfunction = GALFN_GETGENLOCKENABLE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetgenlockenable)) { - return 0; - } else { - *enable = sGetgenlockenable.enable; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetgenlockenable)) { + return 0; + } + else { + *enable = sGetgenlockenable.enable; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4653,17 +4716,18 @@ Gal_get_genlock_enable(int *enable) BOOLEAN Gal_set_genlock_enable(int enable) { - GAL_GENLOCKENABLE sSetgenlockenable; + GAL_GENLOCKENABLE sSetgenlockenable; - INIT_GAL(&sSetgenlockenable); - sSetgenlockenable.dwSubfunction = GALFN_SETGENLOCKENABLE; + INIT_GAL(&sSetgenlockenable); + sSetgenlockenable.dwSubfunction = GALFN_SETGENLOCKENABLE; - sSetgenlockenable.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetgenlockenable)) { - return 0; - } else { - return 1; - } + sSetgenlockenable.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetgenlockenable)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4677,17 +4741,18 @@ Gal_set_genlock_enable(int enable) BOOLEAN Gal_get_genlock_delay(unsigned long *delay) { - GAL_GENLOCKDELAY sGetgenlockdelay; + GAL_GENLOCKDELAY sGetgenlockdelay; - INIT_GAL(&sGetgenlockdelay); - sGetgenlockdelay.dwSubfunction = GALFN_GETGENLOCKDELAY; + INIT_GAL(&sGetgenlockdelay); + sGetgenlockdelay.dwSubfunction = GALFN_GETGENLOCKDELAY; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetgenlockdelay)) { - return 0; - } else { - *delay = sGetgenlockdelay.delay; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetgenlockdelay)) { + return 0; + } + else { + *delay = sGetgenlockdelay.delay; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4701,33 +4766,35 @@ Gal_get_genlock_delay(unsigned long *delay) BOOLEAN Gal_set_genlock_delay(unsigned long delay) { - GAL_GENLOCKDELAY sSetgenlockdelay; + GAL_GENLOCKDELAY sSetgenlockdelay; - INIT_GAL(&sSetgenlockdelay); - sSetgenlockdelay.dwSubfunction = GALFN_SETGENLOCKDELAY; + INIT_GAL(&sSetgenlockdelay); + sSetgenlockdelay.dwSubfunction = GALFN_SETGENLOCKDELAY; - sSetgenlockdelay.delay = delay; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetgenlockdelay)) { - return 0; - } else { - return 1; - } + sSetgenlockdelay.delay = delay; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetgenlockdelay)) { + return 0; + } + else { + return 1; + } } BOOLEAN Gal_set_top_line_in_odd(int enable) { - GAL_TOPLINEINODD sSettoplineinodd; + GAL_TOPLINEINODD sSettoplineinodd; - INIT_GAL(&sSettoplineinodd); - sSettoplineinodd.dwSubfunction = GALFN_SETTOPLINEINODD; + INIT_GAL(&sSettoplineinodd); + sSettoplineinodd.dwSubfunction = GALFN_SETTOPLINEINODD; - sSettoplineinodd.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSettoplineinodd)) { - return 0; - } else { - return 1; - } + sSettoplineinodd.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSettoplineinodd)) { + return 0; + } + else { + return 1; + } } /*-------------------------------------------------------------------------- @@ -4745,25 +4812,26 @@ Gal_set_top_line_in_odd(int enable) *------------------------------------------------------------------------*/ BOOLEAN Gal_get_video_cursor(unsigned long *key, - unsigned long *mask, - unsigned short *select_color2, - unsigned long *color1, unsigned long *color2) + unsigned long *mask, + unsigned short *select_color2, + unsigned long *color1, unsigned long *color2) { - GAL_VIDEOCURSOR sGetvideocursor; + GAL_VIDEOCURSOR sGetvideocursor; - INIT_GAL(&sGetvideocursor); - sGetvideocursor.dwSubfunction = GALFN_GETVIDEOCURSOR; + INIT_GAL(&sGetvideocursor); + sGetvideocursor.dwSubfunction = GALFN_GETVIDEOCURSOR; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetvideocursor)) { - return 0; - } else { - *key = sGetvideocursor.key; - *mask = sGetvideocursor.mask; - *select_color2 = sGetvideocursor.select_color2; - *color1 = sGetvideocursor.color1; - *color2 = sGetvideocursor.color2; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetvideocursor)) { + return 0; + } + else { + *key = sGetvideocursor.key; + *mask = sGetvideocursor.mask; + *select_color2 = sGetvideocursor.select_color2; + *color1 = sGetvideocursor.color1; + *color2 = sGetvideocursor.color2; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4778,17 +4846,18 @@ Gal_get_video_cursor(unsigned long *key, BOOLEAN Gal_read_crc(unsigned long *crc) { - GAL_READCRC sReadcrc; + GAL_READCRC sReadcrc; - INIT_GAL(&sReadcrc); - sReadcrc.dwSubfunction = GALFN_READCRC; + INIT_GAL(&sReadcrc); + sReadcrc.dwSubfunction = GALFN_READCRC; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sReadcrc)) { - return 0; - } else { - *crc = sReadcrc.crc; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sReadcrc)) { + return 0; + } + else { + *crc = sReadcrc.crc; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4808,25 +4877,26 @@ Gal_read_crc(unsigned long *crc) *------------------------------------------------------------------------*/ BOOLEAN Gal_read_window_crc(int source, unsigned short x, unsigned short y, - unsigned short width, unsigned short height, - int crc32, unsigned long *crc) + unsigned short width, unsigned short height, + int crc32, unsigned long *crc) { - GAL_READWINDOWCRC sReadwindowcrc; + GAL_READWINDOWCRC sReadwindowcrc; - INIT_GAL(&sReadwindowcrc); - sReadwindowcrc.dwSubfunction = GALFN_READWINDOWCRC; - sReadwindowcrc.source = source; - sReadwindowcrc.x = x; - sReadwindowcrc.y = y; - sReadwindowcrc.width = width; - sReadwindowcrc.height = height; - sReadwindowcrc.crc32 = crc32; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sReadwindowcrc)) { - return 0; - } else { - *crc = sReadwindowcrc.crc; - return 1; - } + INIT_GAL(&sReadwindowcrc); + sReadwindowcrc.dwSubfunction = GALFN_READWINDOWCRC; + sReadwindowcrc.source = source; + sReadwindowcrc.x = x; + sReadwindowcrc.y = y; + sReadwindowcrc.width = width; + sReadwindowcrc.height = height; + sReadwindowcrc.crc32 = crc32; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sReadwindowcrc)) { + return 0; + } + else { + *crc = sReadwindowcrc.crc; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4841,17 +4911,18 @@ Gal_read_window_crc(int source, unsigned short x, unsigned short y, BOOLEAN Gal_get_macrovision_enable(int *enable) { - GAL_MACROVISIONENABLE sGetmacrovisionenable; + GAL_MACROVISIONENABLE sGetmacrovisionenable; - INIT_GAL(&sGetmacrovisionenable); - sGetmacrovisionenable.dwSubfunction = GALFN_GETMACROVISIONENABLE; + INIT_GAL(&sGetmacrovisionenable); + sGetmacrovisionenable.dwSubfunction = GALFN_GETMACROVISIONENABLE; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetmacrovisionenable)) { - return 0; - } else { - *enable = sGetmacrovisionenable.enable; - return 1; - } + if (ioctl(ifbdev_handle, FBIOGAL_API, &sGetmacrovisionenable)) { + return 0; + } + else { + *enable = sGetmacrovisionenable.enable; + return 1; + } } /*-------------------------------------------------------------------------- @@ -4866,15 +4937,16 @@ Gal_get_macrovision_enable(int *enable) BOOLEAN Gal_set_macrovision_enable(int enable) { - GAL_MACROVISIONENABLE sSetmacrovisionenable; + GAL_MACROVISIONENABLE sSetmacrovisionenable; - INIT_GAL(&sSetmacrovisionenable); - sSetmacrovisionenable.dwSubfunction = GALFN_SETMACROVISIONENABLE; + INIT_GAL(&sSetmacrovisionenable); + sSetmacrovisionenable.dwSubfunction = GALFN_SETMACROVISIONENABLE; - sSetmacrovisionenable.enable = enable; - if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetmacrovisionenable)) { - return 0; - } else { - return 1; - } + sSetmacrovisionenable.enable = enable; + if (ioctl(ifbdev_handle, FBIOGAL_API, &sSetmacrovisionenable)) { + return 0; + } + else { + return 1; + } } diff --git a/src/nsc_galstub.c b/src/nsc_galstub.c index d99da09..4652a30 100644 --- a/src/nsc_galstub.c +++ b/src/nsc_galstub.c @@ -151,10 +151,10 @@ #include "xf86PciInfo.h" #include "xf86Pci.h" #include "xf86cmap.h" -#include "asm/page.h" /* #define for PAGE_* */ +#include "asm/page.h" /* #define for PAGE_* */ #define makedev(major, minor) ((((unsigned int) (major)) << 8) \ | ((unsigned int) (minor))) #include "nsc_galfns.c" -#endif /* STB_X */ +#endif /* STB_X */ diff --git a/src/nsc_gx1_accel.c b/src/nsc_gx1_accel.c index 970f400..6188e72 100644 --- a/src/nsc_gx1_accel.c +++ b/src/nsc_gx1_accel.c @@ -183,6 +183,7 @@ static unsigned short Geode_vector_mode = 0; static unsigned short Geode_buffer_width = 0; #endif static unsigned int gu1_bpp = 0; + #if SCR2SCREXP static unsigned int gu1_xshift = 1; #endif @@ -208,87 +209,86 @@ static XAAInfoRecPtr localRecPtr; Bool GX1AccelInit(ScreenPtr pScreen); void GX1AccelSync(ScrnInfoPtr pScreenInfo); void GX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, int color, int rop, - unsigned int planemask); + unsigned int planemask); void GX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, - int w, int h); + int w, int h); void GX1SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, - int rop, unsigned int planemask, - int trans_color); + int patternx, int patterny, + int rop, unsigned int planemask, + int trans_color); void GX1Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int x, - int y, int w, int h); + int patternx, int patterny, int x, + int y, int w, int h); void GX1SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, int patternx, - int patterny, int fg, int bg, int rop, - unsigned int planemask); + int patterny, int fg, int bg, int rop, + unsigned int planemask); void GX1Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, int patternx, - int patterny, int x, int y, int w, - int h); + int patterny, int x, int y, int w, + int h); void GX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int xdir, - int ydir, int rop, unsigned int planemask, - int transparency_color); + int ydir, int rop, unsigned int planemask, + int transparency_color); void GX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int x1, int y1, - int x2, int y2, int w, int h); + int x2, int y2, int w, int h); void GX1SetupForSolidLine(ScrnInfoPtr pScreenInfo, int color, int rop, - unsigned int planemask); + unsigned int planemask); void GX1SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int length, - unsigned char *pattern); + unsigned int planemask, int length, + unsigned char *pattern); void GX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, int x1, int y1, - int absmaj, int absmin, int err, int len, - int octant); + int absmaj, int absmin, int err, int len, + int octant); void GX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, int x0, int y0, - int x1, int y1, int flags); + int x1, int y1, int flags); void GX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, int x, int y, int len, - int dir); + int dir); void GX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, - int depth); + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth); void GX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft); + int x, int y, int w, int h, + int skipleft); void GX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno); void GX1FillCacheBltRects(ScrnInfoPtr pScrn, int rop, unsigned int planemask, - int nBox, BoxPtr pBox, int xorg, int yorg, - XAACacheInfoPtr pCache); + int nBox, BoxPtr pBox, int xorg, int yorg, + XAACacheInfoPtr pCache); void OPTGX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, int color, int rop, - unsigned int planemask); + unsigned int planemask); void OPTGX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, - int w, int h); + int w, int h); void OPTGX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int xdir, - int ydir, int rop, - unsigned int planemask, - int transparency_color); + int ydir, int rop, + unsigned int planemask, + int transparency_color); void OPTGX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int x1, - int y1, int x2, int y2, int w, int h); + int y1, int x2, int y2, int w, int h); void OPTGX1SetupForSolidLine(ScrnInfoPtr pScreenInfo, int color, int rop, - unsigned int planemask); + unsigned int planemask); void OPTGX1SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int length, - unsigned char *pattern); + unsigned int planemask, int length, + unsigned char *pattern); void OPTGX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, int x1, int y1, - int absmaj, int absmin, int err, int len, - int octant); + int absmaj, int absmin, int err, int len, + int octant); void OPTGX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, - int x0, int y0, int x1, int y1, - int flags); -#if 0 /* disabled due to bugs */ + int x0, int y0, int x1, int y1, + int flags); +#if 0 /* disabled due to bugs */ void OPTGX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, int x, int y, - int len, int dir); + int len, int dir); #endif void OPTGX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, - int depth); + int rop, unsigned int planemask, + int transparency_color, int bpp, + int depth); void OPTGX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft); + int x, int y, int w, int h, + int skipleft); void OPTGX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno); @@ -310,7 +310,7 @@ void OPTGX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno); void GX1AccelSync(ScrnInfoPtr pScreenInfo) { - GFX(wait_until_idle()); + GFX(wait_until_idle()); } /*---------------------------------------------------------------------------- @@ -334,19 +334,20 @@ GX1AccelSync(ScrnInfoPtr pScreenInfo) */ void GX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - GFX(set_solid_pattern((unsigned long)color)); - - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ - if (planemask == 0xFFFFFFFF) { - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } else { - /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ - GFX(set_solid_source((unsigned long)planemask)); - GFX(set_raster_operation(XAAGetPatternROP_PM(rop))); - } + GFX(set_solid_pattern((unsigned long) color)); + + /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ + if (planemask == 0xFFFFFFFF) { + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } + else { + /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ + GFX(set_solid_source((unsigned long) planemask)); + GFX(set_raster_operation(XAAGetPatternROP_PM(rop))); + } } /*---------------------------------------------------------------------------- @@ -372,21 +373,20 @@ GX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, *---------------------------------------------------------------------------- */ void -GX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, int w, - int h) +GX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, int w, int h) { - /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ - GeodePtr pGeode; + /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ + GeodePtr pGeode; - pGeode = GEODEPTR(pScreenInfo); + pGeode = GEODEPTR(pScreenInfo); - if (pGeode->TV_Overscan_On) { - x += pGeode->TVOx; - y += pGeode->TVOy; - } + if (pGeode->TV_Overscan_On) { + x += pGeode->TVOx; + y += pGeode->TVOy; + } - GFX(pattern_fill((unsigned short)x, (unsigned short)y, - (unsigned short)w, (unsigned short)h)); + GFX(pattern_fill((unsigned short) x, (unsigned short) y, + (unsigned short) w, (unsigned short) h)); } /*---------------------------------------------------------------------------- @@ -409,19 +409,20 @@ GX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, int w, void GX1SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, - int rop, unsigned int planemask, - int trans_color) + int patternx, int patterny, + int rop, unsigned int planemask, + int trans_color) { - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ - if (planemask == 0xFFFFFFFF) { - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } else { - /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ - GFX(set_solid_source((unsigned int)planemask)); - GFX(set_raster_operation(XAAGetPatternROP_PM(rop))); - } + /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ + if (planemask == 0xFFFFFFFF) { + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } + else { + /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ + GFX(set_solid_source((unsigned int) planemask)); + GFX(set_raster_operation(XAAGetPatternROP_PM(rop))); + } } /*---------------------------------------------------------------------------- @@ -450,23 +451,23 @@ GX1SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, */ void GX1Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int x, int y, - int w, int h) + int patternx, int patterny, int x, int y, + int w, int h) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - DEBUGMSG(1, (0, 0, "8x8color %d %d %dx%d\n", x, y, w, h)); - if (pGeode->TV_Overscan_On) { - x += pGeode->TVOx; - y += pGeode->TVOy; - } - /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ - /* Ignores specified pattern. */ - GFX(color_pattern_fill((unsigned short)x, (unsigned short)y, - (unsigned short)w, (unsigned short)h, - ((unsigned long *)((pGeode->FBBase + - (patterny << gu1_yshift)) + - patternx)))); + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + DEBUGMSG(1, (0, 0, "8x8color %d %d %dx%d\n", x, y, w, h)); + if (pGeode->TV_Overscan_On) { + x += pGeode->TVOx; + y += pGeode->TVOy; + } + /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ + /* Ignores specified pattern. */ + GFX(color_pattern_fill((unsigned short) x, (unsigned short) y, + (unsigned short) w, (unsigned short) h, + ((unsigned long *) ((pGeode->FBBase + + (patterny << gu1_yshift)) + + patternx)))); } /*---------------------------------------------------------------------------- @@ -490,27 +491,28 @@ GX1Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, */ void GX1SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int fg, - int bg, int rop, unsigned int planemask) + int patternx, int patterny, int fg, + int bg, int rop, unsigned int planemask) { - int trans = (bg == -1); - - /* LOAD PATTERN COLORS AND DATA */ - GFX(set_mono_pattern((unsigned int)bg, (unsigned int)fg, - (unsigned int)patternx, (unsigned int)patterny, - trans)); - - GFX(set_mono_source((unsigned int)bg, (unsigned int)fg, trans)); - - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ - if (planemask == 0xFFFFFFFF) { - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } else { - /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ - GFX(set_solid_source((unsigned int)planemask)); - GFX(set_raster_operation(XAAGetPatternROP_PM(rop))); - } + int trans = (bg == -1); + + /* LOAD PATTERN COLORS AND DATA */ + GFX(set_mono_pattern((unsigned int) bg, (unsigned int) fg, + (unsigned int) patternx, (unsigned int) patterny, + trans)); + + GFX(set_mono_source((unsigned int) bg, (unsigned int) fg, trans)); + + /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ + if (planemask == 0xFFFFFFFF) { + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } + else { + /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ + GFX(set_solid_source((unsigned int) planemask)); + GFX(set_raster_operation(XAAGetPatternROP_PM(rop))); + } } /*---------------------------------------------------------------------------- @@ -538,20 +540,20 @@ GX1SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, */ void GX1Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int x, int y, - int w, int h) + int patternx, int patterny, int x, int y, + int w, int h) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); + GeodePtr pGeode = GEODEPTR(pScreenInfo); - if (pGeode->TV_Overscan_On) { - x += pGeode->TVOx; - y += pGeode->TVOy; - } + if (pGeode->TV_Overscan_On) { + x += pGeode->TVOx; + y += pGeode->TVOy; + } - /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ - /* Ignores specified pattern. */ - GFX(pattern_fill((unsigned short)x, (unsigned short)y, - (unsigned short)w, (unsigned short)h)); + /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ + /* Ignores specified pattern. */ + GFX(pattern_fill((unsigned short) x, (unsigned short) y, + (unsigned short) w, (unsigned short) h)); } /*---------------------------------------------------------------------------- @@ -575,15 +577,15 @@ GX1Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, */ void GX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, - int xdir, int ydir, int rop, - unsigned int planemask, int transparency_color) + int xdir, int ydir, int rop, + unsigned int planemask, int transparency_color) { - GFX(set_solid_pattern(planemask)); - /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ - GFX(set_raster_operation(XAAGetCopyROP(rop))); - /* SAVE TRANSPARENCY FLAG */ - GeodeTransparent = (transparency_color == -1) ? 0 : 1; - GeodeTransColor = transparency_color; + GFX(set_solid_pattern(planemask)); + /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ + GFX(set_raster_operation(XAAGetCopyROP(rop))); + /* SAVE TRANSPARENCY FLAG */ + GeodeTransparent = (transparency_color == -1) ? 0 : 1; + GeodeTransColor = transparency_color; } @@ -616,33 +618,34 @@ GX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, void GX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, - int x1, int y1, int x2, int y2, int w, int h) + int x1, int y1, int x2, int y2, int w, int h) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - if (pGeode->TV_Overscan_On) { - if ((x1 < pScreenInfo->virtualX) && (y1 < pScreenInfo->virtualY)) { - x1 += pGeode->TVOx; - y1 += pGeode->TVOy; - } - x2 += pGeode->TVOx; - y2 += pGeode->TVOy; - } - - if (GeodeTransparent) { - /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT - * * Should only be called for the "copy" raster operation. - */ - GFX(screen_to_screen_xblt((unsigned short)x1, (unsigned short)y1, - (unsigned short)x2, (unsigned short)y2, - (unsigned short)w, (unsigned short)h, - GeodeTransColor)); - } else { - /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ - GFX(screen_to_screen_blt((unsigned short)x1, (unsigned short)y1, - (unsigned short)x2, (unsigned short)y2, - (unsigned short)w, (unsigned short)h)); - } + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + if (pGeode->TV_Overscan_On) { + if ((x1 < pScreenInfo->virtualX) && (y1 < pScreenInfo->virtualY)) { + x1 += pGeode->TVOx; + y1 += pGeode->TVOy; + } + x2 += pGeode->TVOx; + y2 += pGeode->TVOy; + } + + if (GeodeTransparent) { + /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT + * * Should only be called for the "copy" raster operation. + */ + GFX(screen_to_screen_xblt((unsigned short) x1, (unsigned short) y1, + (unsigned short) x2, (unsigned short) y2, + (unsigned short) w, (unsigned short) h, + GeodeTransColor)); + } + else { + /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ + GFX(screen_to_screen_blt((unsigned short) x1, (unsigned short) y1, + (unsigned short) x2, (unsigned short) y2, + (unsigned short) w, (unsigned short) h)); + } } /*---------------------------------------------------------------------------- @@ -669,15 +672,15 @@ GX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, void GX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth) + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth) { - GFX(set_solid_pattern((unsigned int)planemask)); - /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ - GFX(set_raster_operation(XAAGetCopyROP_PM(rop))); - /* SAVE TRANSPARENCY FLAG */ - GeodeTransparent = (transparency_color == -1) ? 0 : 1; - GeodeTransColor = transparency_color; + GFX(set_solid_pattern((unsigned int) planemask)); + /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ + GFX(set_raster_operation(XAAGetCopyROP_PM(rop))); + /* SAVE TRANSPARENCY FLAG */ + GeodeTransparent = (transparency_color == -1) ? 0 : 1; + GeodeTransColor = transparency_color; } /*---------------------------------------------------------------------------- @@ -700,14 +703,14 @@ GX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, */ void GX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, int skipleft) + int x, int y, int w, int h, int skipleft) { - Geodedstx = x; - Geodedsty = y; - Geodewidth = w; - Geodeheight = h; - GeodeCounter = 0; + Geodedstx = x; + Geodedsty = y; + Geodewidth = w; + Geodeheight = h; + GeodeCounter = 0; } /*---------------------------------------------------------------------------- @@ -735,63 +738,66 @@ GX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, void GX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); - int blt_height = 0; - char blit = FALSE; - - GeodeCounter++; - - if ((Geodeheight <= pGeode->NoOfImgBuffers) && - (GeodeCounter == Geodeheight)) { - blit = TRUE; - blt_height = Geodeheight; - } else if ((Geodeheight > pGeode->NoOfImgBuffers) - && (GeodeCounter == pGeode->NoOfImgBuffers)) { - blit = TRUE; - Geodeheight -= pGeode->NoOfImgBuffers; - blt_height = pGeode->NoOfImgBuffers; - } else - return; - - if (blit) { - blit = FALSE; - - GeodeCounter = 0; - - if (GeodeTransparent) { - /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT - * * Should only be called for the "copy" raster operation. - */ - GFX(screen_to_screen_xblt((unsigned short)Geodesrcx, - (unsigned short)Geodesrcy, - (unsigned short)Geodedstx, - (unsigned short)Geodedsty, - (unsigned short)Geodewidth, - (unsigned short)blt_height, - GeodeTransColor)); - } else { - /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ - GFX(screen_to_screen_blt((unsigned short)Geodesrcx, - (unsigned short)Geodesrcy, - (unsigned short)Geodedstx, - (unsigned short)Geodedsty, - (unsigned short)Geodewidth, - (unsigned short)blt_height)); - } - Geodedsty += blt_height; - GFX(wait_until_idle()); - } + GeodePtr pGeode = GEODEPTR(pScreenInfo); + int blt_height = 0; + char blit = FALSE; + + GeodeCounter++; + + if ((Geodeheight <= pGeode->NoOfImgBuffers) && + (GeodeCounter == Geodeheight)) { + blit = TRUE; + blt_height = Geodeheight; + } + else if ((Geodeheight > pGeode->NoOfImgBuffers) + && (GeodeCounter == pGeode->NoOfImgBuffers)) { + blit = TRUE; + Geodeheight -= pGeode->NoOfImgBuffers; + blt_height = pGeode->NoOfImgBuffers; + } + else + return; + + if (blit) { + blit = FALSE; + + GeodeCounter = 0; + + if (GeodeTransparent) { + /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT + * * Should only be called for the "copy" raster operation. + */ + GFX(screen_to_screen_xblt((unsigned short) Geodesrcx, + (unsigned short) Geodesrcy, + (unsigned short) Geodedstx, + (unsigned short) Geodedsty, + (unsigned short) Geodewidth, + (unsigned short) blt_height, + GeodeTransColor)); + } + else { + /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ + GFX(screen_to_screen_blt((unsigned short) Geodesrcx, + (unsigned short) Geodesrcy, + (unsigned short) Geodedstx, + (unsigned short) Geodedsty, + (unsigned short) Geodewidth, + (unsigned short) blt_height)); + } + Geodedsty += blt_height; + GFX(wait_until_idle()); + } } static unsigned short vector_mode_table[] = { - VM_MAJOR_INC | VM_MINOR_INC | VM_X_MAJOR, - VM_MAJOR_INC | VM_MINOR_INC | VM_Y_MAJOR, - VM_MAJOR_INC | VM_X_MAJOR, - VM_MINOR_INC | VM_Y_MAJOR, - VM_MINOR_INC | VM_X_MAJOR, - VM_MAJOR_INC | VM_Y_MAJOR, - VM_X_MAJOR, - VM_Y_MAJOR, + VM_MAJOR_INC | VM_MINOR_INC | VM_X_MAJOR, + VM_MAJOR_INC | VM_MINOR_INC | VM_Y_MAJOR, + VM_MAJOR_INC | VM_X_MAJOR, + VM_MINOR_INC | VM_Y_MAJOR, + VM_MINOR_INC | VM_X_MAJOR, + VM_MAJOR_INC | VM_Y_MAJOR, + VM_X_MAJOR, + VM_Y_MAJOR, }; /*---------------------------------------------------------------------------- @@ -813,13 +819,13 @@ static unsigned short vector_mode_table[] = { */ void GX1SetupForSolidLine(ScrnInfoPtr pScreenInfo, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - /* LOAD THE SOLID PATTERN COLOR */ - GFX(set_solid_pattern((unsigned int)color)); + /* LOAD THE SOLID PATTERN COLOR */ + GFX(set_solid_pattern((unsigned int) color)); - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop))); + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetPatternROP(rop))); } /*--------------------------------------------------------------------------- @@ -849,38 +855,38 @@ GX1SetupForSolidLine(ScrnInfoPtr pScreenInfo, */ void GX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, - int x1, int y1, int absmaj, int absmin, int err, - int len, int octant) + int x1, int y1, int absmaj, int absmin, int err, + int len, int octant) { - int axial, init, diag; + int axial, init, diag; - DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", - x1, y1, absmaj, absmin, err, len, octant)); + DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", + x1, y1, absmaj, absmin, err, len, octant)); - /* DETERMINE BRESENHAM PARAMETERS */ + /* DETERMINE BRESENHAM PARAMETERS */ - axial = ((int)absmin << 1); - init = axial - (int)absmaj; - diag = init - (int)absmaj; + axial = ((int) absmin << 1); + init = axial - (int) absmaj; + diag = init - (int) absmaj; - /* ADJUST INITIAL ERROR - * * Adjust by -1 for certain directions so that the vector - * * hits the same pixels when drawn in either direction. - * * The Gamma value is assumed to account for the initial - * * error adjustment for clipped lines. - */ + /* ADJUST INITIAL ERROR + * * Adjust by -1 for certain directions so that the vector + * * hits the same pixels when drawn in either direction. + * * The Gamma value is assumed to account for the initial + * * error adjustment for clipped lines. + */ - init += err; + init += err; - /* CALL ROUTINE TO DRAW VECTOR */ + /* CALL ROUTINE TO DRAW VECTOR */ - GFX(bresenham_line((unsigned short)x1, - (unsigned short)y1, - (unsigned short)len, - (unsigned short)init, - (unsigned short)axial, - (unsigned short)diag, - (unsigned short)vector_mode_table[octant])); + GFX(bresenham_line((unsigned short) x1, + (unsigned short) y1, + (unsigned short) len, + (unsigned short) init, + (unsigned short) axial, + (unsigned short) diag, + (unsigned short) vector_mode_table[octant])); } @@ -888,43 +894,44 @@ GX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, void GX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, - int x0, int y0, int x1, int y1, int flags) + int x0, int y0, int x1, int y1, int flags) { - long dx, dy, dmaj, dmin; - long axialerr, diagerr, initerr; - unsigned short vec_flags = 0; - - dx = ABS(x1, x0); - dy = ABS(y1, y0); - if (dx >= dy) { - dmaj = dx; - dmin = dy; - vec_flags = VM_X_MAJOR; - if (x1 > x0) - vec_flags |= VM_MAJOR_INC; - if (y1 > y0) - vec_flags |= VM_MINOR_INC; - } else { - dmaj = dy; - dmin = dx; - vec_flags = VM_Y_MAJOR; - if (x1 > x0) - vec_flags |= VM_MINOR_INC; - if (y1 > y0) - vec_flags |= VM_MAJOR_INC; - } - axialerr = dmin << 1; - diagerr = (dmin - dmaj) << 1; - initerr = (dmin << 1) - dmaj; - if (!(vec_flags & VM_MINOR_INC)) - initerr--; - - GFX(bresenham_line((unsigned short)x0, - (unsigned short)y0, - (unsigned short)dmaj, - (unsigned short)initerr, - (unsigned short)axialerr, - (unsigned short)diagerr, vec_flags)); + long dx, dy, dmaj, dmin; + long axialerr, diagerr, initerr; + unsigned short vec_flags = 0; + + dx = ABS(x1, x0); + dy = ABS(y1, y0); + if (dx >= dy) { + dmaj = dx; + dmin = dy; + vec_flags = VM_X_MAJOR; + if (x1 > x0) + vec_flags |= VM_MAJOR_INC; + if (y1 > y0) + vec_flags |= VM_MINOR_INC; + } + else { + dmaj = dy; + dmin = dx; + vec_flags = VM_Y_MAJOR; + if (x1 > x0) + vec_flags |= VM_MINOR_INC; + if (y1 > y0) + vec_flags |= VM_MAJOR_INC; + } + axialerr = dmin << 1; + diagerr = (dmin - dmaj) << 1; + initerr = (dmin << 1) - dmaj; + if (!(vec_flags & VM_MINOR_INC)) + initerr--; + + GFX(bresenham_line((unsigned short) x0, + (unsigned short) y0, + (unsigned short) dmaj, + (unsigned short) initerr, + (unsigned short) axialerr, + (unsigned short) diagerr, vec_flags)); } /*--------------------------------------------------------------------------- @@ -941,73 +948,74 @@ GX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, */ void GX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, - int x, int y, int len, int dir) + int x, int y, int len, int dir) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - if (pGeode->TV_Overscan_On) { - x += pGeode->TVOx; - y += pGeode->TVOy; - } - GFX(pattern_fill((unsigned short)x, (unsigned short)y, - (unsigned short)((dir == DEGREES_0) ? len : 1), - (unsigned short)((dir == DEGREES_0) ? 1 : len))); + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + if (pGeode->TV_Overscan_On) { + x += pGeode->TVOx; + y += pGeode->TVOy; + } + GFX(pattern_fill((unsigned short) x, (unsigned short) y, + (unsigned short) ((dir == DEGREES_0) ? len : 1), + (unsigned short) ((dir == DEGREES_0) ? 1 : len))); } void GX1SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int length, - unsigned char *pattern) + unsigned int planemask, int length, + unsigned char *pattern) { - int trans = (bg == -1); - unsigned long *pat = (unsigned long *)pattern; + int trans = (bg == -1); + unsigned long *pat = (unsigned long *) pattern; - /* LOAD PATTERN COLORS AND DATA */ + /* LOAD PATTERN COLORS AND DATA */ - GFX(set_mono_pattern((unsigned long)bg, (unsigned long)fg, - (unsigned long)pat, (unsigned long)pat, - (unsigned char)trans)); + GFX(set_mono_pattern((unsigned long) bg, (unsigned long) fg, + (unsigned long) pat, (unsigned long) pat, + (unsigned char) trans)); - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ + /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ - if (planemask == (unsigned int)-1) { - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + if (planemask == (unsigned int) -1) { + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } else { - /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } + else { + /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ - GFX(set_solid_source((unsigned long)planemask)); - GFX(set_raster_operation(XAAGetPatternROP_PM(rop))); - } + GFX(set_solid_source((unsigned long) planemask)); + GFX(set_raster_operation(XAAGetPatternROP_PM(rop))); + } } #if SCR2SCREXP void GX1SetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask) + int fg, int bg, int rop, + unsigned int planemask) { - GFX(set_solid_pattern(planemask)); - GFX(set_mono_source(bg, fg, (bg == -1))); + GFX(set_solid_pattern(planemask)); + GFX(set_mono_source(bg, fg, (bg == -1))); - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F))); + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F))); - DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask)); + DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask)); } void GX1SubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int srcx, int srcy, int offset) + int x, int y, int w, int h, + int srcx, int srcy, int offset) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - GFX(mono_bitmap_to_screen_blt(offset, 0, x, y, w, h, - (unsigned char *)(pGeode->FBBase + - CALC_FBOFFSET(srcx, srcy)), - pGeode->Pitch)); + GFX(mono_bitmap_to_screen_blt(offset, 0, x, y, w, h, + (unsigned char *) (pGeode->FBBase + + CALC_FBOFFSET(srcx, srcy)), + pGeode->Pitch)); } #endif @@ -1034,41 +1042,42 @@ GX1SubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, */ void OPTGX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - unsigned short rop16; + unsigned short rop16; - if (gu1_bpp == 8) { - color &= 0x00FF; - color |= (color << 8); - } + if (gu1_bpp == 8) { + color &= 0x00FF; + color |= (color << 8); + } - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - if (planemask == 0xFFFFFFFF) { - if (gu1_bpp == 8) { - planemask &= 0x00FF; - planemask |= (planemask << 8); - } + if (planemask == 0xFFFFFFFF) { + if (gu1_bpp == 8) { + planemask &= 0x00FF; + planemask |= (planemask << 8); + } - rop16 = XAAGetPatternROP(rop); + rop16 = XAAGetPatternROP(rop); - /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */ + /* POLL UNTIL ABLE TO WRITE THE SOURCE COLOR */ - GFX_WAIT_PENDING; - WRITE_REG32(GP_SRC_COLOR_0, (planemask << 16) | planemask); - } else { - rop16 = XAAGetPatternROP_PM(rop); - } + GFX_WAIT_PENDING; + WRITE_REG32(GP_SRC_COLOR_0, (planemask << 16) | planemask); + } + else { + rop16 = XAAGetPatternROP_PM(rop); + } - Geode_blt_mode = 0; + Geode_blt_mode = 0; - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - /* Only one operation can be pending at a time. */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + /* Only one operation can be pending at a time. */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)color); - WRITE_REG16(GP_RASTER_MODE, rop16); + GFX_WAIT_PENDING; + WRITE_REG16(GP_PAT_COLOR_0, (unsigned short) color); + WRITE_REG16(GP_RASTER_MODE, rop16); } /*---------------------------------------------------------------------------- @@ -1096,49 +1105,50 @@ OPTGX1SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, */ void OPTGX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, - int x, int y, int width, int height) + int x, int y, int width, int height) { - unsigned short section; - GeodePtr pGeode = GEODEPTR(pScreenInfo); + unsigned short section; + GeodePtr pGeode = GEODEPTR(pScreenInfo); - if (pGeode->TV_Overscan_On) { - x += pGeode->TVOx; - y += pGeode->TVOy; - } + if (pGeode->TV_Overscan_On) { + x += pGeode->TVOx; + y += pGeode->TVOy; + } - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Only one operation can be pending at a time. */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Only one operation can be pending at a time. */ - GFX_WAIT_PENDING; + GFX_WAIT_PENDING; - /* SET REGISTERS TO DRAW RECTANGLE */ - WRITE_REG32(GP_DST_XCOOR, (y << 16) | x); + /* SET REGISTERS TO DRAW RECTANGLE */ + WRITE_REG32(GP_DST_XCOOR, (y << 16) | x); - WRITE_REG16(GP_HEIGHT, height); + WRITE_REG16(GP_HEIGHT, height); - /* CHECK WIDTH FOR GX BUG WORKAROUND */ + /* CHECK WIDTH FOR GX BUG WORKAROUND */ - if (width <= 16) { - /* OK TO DRAW SMALL RECTANGLE IN ONE PASS */ + if (width <= 16) { + /* OK TO DRAW SMALL RECTANGLE IN ONE PASS */ - WRITE_REG16(GP_WIDTH, width); - WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode); - } else { - /* DRAW FIRST PART OF RECTANGLE */ - /* Get to a 16 pixel boundary. */ + WRITE_REG16(GP_WIDTH, width); + WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode); + } + else { + /* DRAW FIRST PART OF RECTANGLE */ + /* Get to a 16 pixel boundary. */ - section = 0x10 - (x & 0x0F); - WRITE_REG16(GP_WIDTH, section); - WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode); + section = 0x10 - (x & 0x0F); + WRITE_REG16(GP_WIDTH, section); + WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode); - /* POLL UNTIL ABLE TO LOAD THE SECOND RECTANGLE */ + /* POLL UNTIL ABLE TO LOAD THE SECOND RECTANGLE */ - GFX_WAIT_PENDING; + GFX_WAIT_PENDING; - WRITE_REG32(GP_DST_XCOOR, (y << 16) | (x + section)); - WRITE_REG16(GP_WIDTH, width - section); - WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode); - } + WRITE_REG32(GP_DST_XCOOR, (y << 16) | (x + section)); + WRITE_REG16(GP_WIDTH, width - section); + WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode); + } } /*---------------------------------------------------------------------------- @@ -1163,46 +1173,45 @@ OPTGX1SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, */ void OPTGX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, - int xdir, int ydir, int rop, - unsigned int planemask, - int transparency_color) + int xdir, int ydir, int rop, + unsigned int planemask, int transparency_color) { - int GFXusesDstData; - unsigned short rop16 = XAAGetCopyROP(rop); + int GFXusesDstData; + unsigned short rop16 = XAAGetCopyROP(rop); - /* FORMAT 8 BPP COLOR */ - /* GX requires 8BPP color data be duplicated into bits [15:8]. */ + /* FORMAT 8 BPP COLOR */ + /* GX requires 8BPP color data be duplicated into bits [15:8]. */ - if (gu1_bpp == 8) { - planemask &= 0x00FF; - planemask |= (planemask << 8); - } + if (gu1_bpp == 8) { + planemask &= 0x00FF; + planemask |= (planemask << 8); + } - /* SET FLAG INDICATING ROP REQUIRES DESTINATION DATA */ - /* True if even bits (0:2:4:6) do not equal the correspinding */ - /* even bits (1:3:5:7). */ + /* SET FLAG INDICATING ROP REQUIRES DESTINATION DATA */ + /* True if even bits (0:2:4:6) do not equal the correspinding */ + /* even bits (1:3:5:7). */ - GFXusesDstData = ((rop & 0x55) ^ ((rop >> 1) & 0x55)); + GFXusesDstData = ((rop & 0x55) ^ ((rop >> 1) & 0x55)); - Geode_blt_mode = GFXusesDstData ? BM_READ_DST_FB1 | BM_READ_SRC_FB : - BM_READ_SRC_FB; + Geode_blt_mode = GFXusesDstData ? BM_READ_DST_FB1 | BM_READ_SRC_FB : + BM_READ_SRC_FB; - /* CHECK AVAILABLE BLT BUFFER SIZE */ - /* Can use both BLT buffers if no destination data is required. */ + /* CHECK AVAILABLE BLT BUFFER SIZE */ + /* Can use both BLT buffers if no destination data is required. */ - Geode_buffer_width = GFXusesDstData ? GeodebufferWidthPixels : - GeodebufferWidthPixels << 1; + Geode_buffer_width = GFXusesDstData ? GeodebufferWidthPixels : + GeodebufferWidthPixels << 1; - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - /* Only one operation can be pending at a time. */ + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + /* Only one operation can be pending at a time. */ - GFX_WAIT_PENDING; + GFX_WAIT_PENDING; - WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)planemask); - WRITE_REG16(GP_RASTER_MODE, rop16); + WRITE_REG16(GP_PAT_COLOR_0, (unsigned short) planemask); + WRITE_REG16(GP_RASTER_MODE, rop16); - GeodeTransparent = (transparency_color == -1) ? 0 : 1; - GeodeTransColor = transparency_color; + GeodeTransparent = (transparency_color == -1) ? 0 : 1; + GeodeTransColor = transparency_color; } /*---------------------------------------------------------------------------- @@ -1234,123 +1243,124 @@ OPTGX1SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, */ void OPTGX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, - int srcx, int srcy, int dstx, int dsty, - int width, int height) + int srcx, int srcy, int dstx, int dsty, + int width, int height) { - unsigned short section; - unsigned short blit_mode = 0; - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - if (pGeode->TV_Overscan_On) { - if ((srcx < pScreenInfo->virtualX) && (srcy < pScreenInfo->virtualY)) { - srcx += pGeode->TVOx; - srcy += pGeode->TVOy; - } - dstx += pGeode->TVOx; - dsty += pGeode->TVOy; - } - if (GeodeTransparent) { - if (gu1_bpp == 8) { - GeodeTransColor &= 0x00FF; - GeodeTransColor |= (GeodeTransColor << 8); - } - GeodeTransColor = - (GeodeTransColor & 0x0000FFFF) | (GeodeTransColor << 16); - - /* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */ - /* Need to make sure any previous BLT using BB1 is complete. */ - /* Only need to load 32 bits of BB1 for the 1 pixel BLT that follows. */ - - GFX_WAIT_BUSY; - WRITE_SCRATCH32(Geodebb1Base, GeodeTransColor); - - /* DO BOGUS BLT TO LATCH DATA FROM BB1 */ - /* Already know graphics pipeline is idle. */ - /* Only need to latch data into the holding registers for the current */ - /* data from BB1. A 1 pixel wide BLT will suffice. */ - - WRITE_REG32(GP_DST_XCOOR, 0); - WRITE_REG32(GP_SRC_XCOOR, 0); - WRITE_REG32(GP_WIDTH, 0x00010001); - WRITE_REG16(GP_RASTER_MODE, 0x00CC); - WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1); - - /* WRITE REGISTERS FOR REAL SCREEN TO SCREEN BLT */ - - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, height); - WRITE_REG16(GP_RASTER_MODE, 0x10C6); - WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF); - - } - - /* CHECK Y DIRECTION */ - /* Hardware has support for negative Y direction. */ - - if (dsty > srcy) { - blit_mode = BM_REVERSE_Y; - srcy += height - 1; - dsty += height - 1; - } - - /* CHECK X DIRECTION */ - /* Hardware does not support negative X direction since at the time */ - /* of development all supported resolutions could fit a scanline of */ - /* data at once into the BLT buffers (using both BB0 and BB1). This */ - /* code is more generic to allow for any size BLT buffer. */ - - if (dstx > srcx) { - srcx += width; - dstx += width; - } - - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Write the registers that do not change for each section. */ - - GFX_WAIT_PENDING; - WRITE_REG16(GP_HEIGHT, height); - - /* REPEAT UNTIL FINISHED WITH RECTANGLE */ - /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */ - /* Hardware does not split the operations, so software must do it to */ - /* avoid large scanlines that would overflow the BLT buffers. */ - - while (width > 0) { - /* CHECK WIDTH OF CURRENT SECTION */ - - if (width > Geode_buffer_width) - section = Geode_buffer_width; - else - section = width; - - /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */ - - GFX_WAIT_PENDING; - WRITE_REG16(GP_SRC_YCOOR, srcy); - WRITE_REG16(GP_DST_YCOOR, dsty); - WRITE_REG16(GP_WIDTH, section); - - /* CHECK X DIRECTION */ - - if (dstx > srcx) { - /* NEGATIVE X DIRECTION */ - /* Still positive X direction within the section. */ - - srcx -= section; - dstx -= section; - WRITE_REG16(GP_SRC_XCOOR, srcx); - WRITE_REG16(GP_DST_XCOOR, dstx); - } else { - /* POSITIVE X DIRECTION */ - - WRITE_REG16(GP_SRC_XCOOR, srcx); - WRITE_REG16(GP_DST_XCOOR, dstx); - dstx += section; - srcx += section; - } - WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode | blit_mode); - width -= section; - } + unsigned short section; + unsigned short blit_mode = 0; + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + if (pGeode->TV_Overscan_On) { + if ((srcx < pScreenInfo->virtualX) && (srcy < pScreenInfo->virtualY)) { + srcx += pGeode->TVOx; + srcy += pGeode->TVOy; + } + dstx += pGeode->TVOx; + dsty += pGeode->TVOy; + } + if (GeodeTransparent) { + if (gu1_bpp == 8) { + GeodeTransColor &= 0x00FF; + GeodeTransColor |= (GeodeTransColor << 8); + } + GeodeTransColor = + (GeodeTransColor & 0x0000FFFF) | (GeodeTransColor << 16); + + /* WAIT UNTIL PIPELINE IS NOT BUSY BEFORE LOADING DATA INTO BB1 */ + /* Need to make sure any previous BLT using BB1 is complete. */ + /* Only need to load 32 bits of BB1 for the 1 pixel BLT that follows. */ + + GFX_WAIT_BUSY; + WRITE_SCRATCH32(Geodebb1Base, GeodeTransColor); + + /* DO BOGUS BLT TO LATCH DATA FROM BB1 */ + /* Already know graphics pipeline is idle. */ + /* Only need to latch data into the holding registers for the current */ + /* data from BB1. A 1 pixel wide BLT will suffice. */ + + WRITE_REG32(GP_DST_XCOOR, 0); + WRITE_REG32(GP_SRC_XCOOR, 0); + WRITE_REG32(GP_WIDTH, 0x00010001); + WRITE_REG16(GP_RASTER_MODE, 0x00CC); + WRITE_REG16(GP_BLIT_MODE, BM_READ_SRC_FB | BM_READ_DST_BB1); + + /* WRITE REGISTERS FOR REAL SCREEN TO SCREEN BLT */ + + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, height); + WRITE_REG16(GP_RASTER_MODE, 0x10C6); + WRITE_REG32(GP_PAT_COLOR_0, 0xFFFFFFFF); + + } + + /* CHECK Y DIRECTION */ + /* Hardware has support for negative Y direction. */ + + if (dsty > srcy) { + blit_mode = BM_REVERSE_Y; + srcy += height - 1; + dsty += height - 1; + } + + /* CHECK X DIRECTION */ + /* Hardware does not support negative X direction since at the time */ + /* of development all supported resolutions could fit a scanline of */ + /* data at once into the BLT buffers (using both BB0 and BB1). This */ + /* code is more generic to allow for any size BLT buffer. */ + + if (dstx > srcx) { + srcx += width; + dstx += width; + } + + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Write the registers that do not change for each section. */ + + GFX_WAIT_PENDING; + WRITE_REG16(GP_HEIGHT, height); + + /* REPEAT UNTIL FINISHED WITH RECTANGLE */ + /* Perform BLT in vertical sections, as wide as the BLT buffer allows. */ + /* Hardware does not split the operations, so software must do it to */ + /* avoid large scanlines that would overflow the BLT buffers. */ + + while (width > 0) { + /* CHECK WIDTH OF CURRENT SECTION */ + + if (width > Geode_buffer_width) + section = Geode_buffer_width; + else + section = width; + + /* PROGRAM REGISTERS THAT ARE THE SAME FOR EITHER X DIRECTION */ + + GFX_WAIT_PENDING; + WRITE_REG16(GP_SRC_YCOOR, srcy); + WRITE_REG16(GP_DST_YCOOR, dsty); + WRITE_REG16(GP_WIDTH, section); + + /* CHECK X DIRECTION */ + + if (dstx > srcx) { + /* NEGATIVE X DIRECTION */ + /* Still positive X direction within the section. */ + + srcx -= section; + dstx -= section; + WRITE_REG16(GP_SRC_XCOOR, srcx); + WRITE_REG16(GP_DST_XCOOR, dstx); + } + else { + /* POSITIVE X DIRECTION */ + + WRITE_REG16(GP_SRC_XCOOR, srcx); + WRITE_REG16(GP_DST_XCOOR, dstx); + dstx += section; + srcx += section; + } + WRITE_REG16(GP_BLIT_MODE, Geode_blt_mode | blit_mode); + width -= section; + } } /*---------------------------------------------------------------------------- @@ -1373,11 +1383,11 @@ OPTGX1SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, */ void OPTGX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth) + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth) { - OPTGX1SetupForScreenToScreenCopy(pScreenInfo, - 0, 0, rop, planemask, transparency_color); + OPTGX1SetupForScreenToScreenCopy(pScreenInfo, + 0, 0, rop, planemask, transparency_color); } /*---------------------------------------------------------------------------- @@ -1399,15 +1409,14 @@ OPTGX1SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, */ void OPTGX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft) + int x, int y, int w, int h, int skipleft) { - Geodedstx = x; - Geodedsty = y; - Geodewidth = w; - Geodeheight = h; - GeodeCounter = 0; + Geodedstx = x; + Geodedsty = y; + Geodewidth = w; + Geodeheight = h; + GeodeCounter = 0; } /*---------------------------------------------------------------------------- @@ -1435,33 +1444,35 @@ OPTGX1SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, void OPTGX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); - int blt_height = 0; - char blit = FALSE; - - GeodeCounter++; - - if ((Geodeheight <= pGeode->NoOfImgBuffers) && - (GeodeCounter == Geodeheight)) { - blit = TRUE; - blt_height = Geodeheight; - } else if ((Geodeheight > pGeode->NoOfImgBuffers) - && (GeodeCounter == pGeode->NoOfImgBuffers)) { - blit = TRUE; - Geodeheight -= pGeode->NoOfImgBuffers; - blt_height = pGeode->NoOfImgBuffers; - } else - return; - - if (blit) { - blit = FALSE; - GeodeCounter = 0; - OPTGX1SubsequentScreenToScreenCopy(pScreenInfo, - Geodesrcx, Geodesrcy, Geodedstx, - Geodedsty, Geodewidth, blt_height); - Geodedsty += blt_height; - GFX_WAIT_BUSY; - } + GeodePtr pGeode = GEODEPTR(pScreenInfo); + int blt_height = 0; + char blit = FALSE; + + GeodeCounter++; + + if ((Geodeheight <= pGeode->NoOfImgBuffers) && + (GeodeCounter == Geodeheight)) { + blit = TRUE; + blt_height = Geodeheight; + } + else if ((Geodeheight > pGeode->NoOfImgBuffers) + && (GeodeCounter == pGeode->NoOfImgBuffers)) { + blit = TRUE; + Geodeheight -= pGeode->NoOfImgBuffers; + blt_height = pGeode->NoOfImgBuffers; + } + else + return; + + if (blit) { + blit = FALSE; + GeodeCounter = 0; + OPTGX1SubsequentScreenToScreenCopy(pScreenInfo, + Geodesrcx, Geodesrcy, Geodedstx, + Geodedsty, Geodewidth, blt_height); + Geodedsty += blt_height; + GFX_WAIT_BUSY; + } } /*---------------------------------------------------------------------------- @@ -1483,27 +1494,28 @@ OPTGX1SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) */ void OPTGX1SetupForSolidLine(ScrnInfoPtr pScreenInfo, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - if (gu1_bpp == 8) { - color &= 0x00FF; - color |= (color << 8); - } - - GeodeROP = XAAGetPatternROP(rop); - - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - GFX_WAIT_PENDING; - WRITE_REG16(GP_PAT_COLOR_0, (unsigned short)color); - WRITE_REG16(GP_RASTER_MODE, GeodeROP); - - if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { - Geode_vector_mode = VM_READ_DST_FB; - Geode_blt_mode = BM_READ_DST_FB1 | BM_READ_SRC_FB; - } else { - Geode_vector_mode = 0; - Geode_blt_mode = BM_READ_SRC_FB; - } + if (gu1_bpp == 8) { + color &= 0x00FF; + color |= (color << 8); + } + + GeodeROP = XAAGetPatternROP(rop); + + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + GFX_WAIT_PENDING; + WRITE_REG16(GP_PAT_COLOR_0, (unsigned short) color); + WRITE_REG16(GP_RASTER_MODE, GeodeROP); + + if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { + Geode_vector_mode = VM_READ_DST_FB; + Geode_blt_mode = BM_READ_DST_FB1 | BM_READ_SRC_FB; + } + else { + Geode_vector_mode = 0; + Geode_blt_mode = BM_READ_SRC_FB; + } } /*--------------------------------------------------------------------------- @@ -1532,87 +1544,88 @@ OPTGX1SetupForSolidLine(ScrnInfoPtr pScreenInfo, */ void OPTGX1SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, - int x1, int y1, int absmaj, int absmin, int err, - int len, int octant) + int x1, int y1, int absmaj, int absmin, int err, + int len, int octant) { - int axial, init, diag; + int axial, init, diag; - DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", - x1, y1, absmaj, absmin, err, len, octant)); + DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", + x1, y1, absmaj, absmin, err, len, octant)); - /* DETERMINE BRESENHAM PARAMETERS */ + /* DETERMINE BRESENHAM PARAMETERS */ - axial = ((int)absmin << 1); - init = axial - (int)absmaj; - diag = init - (int)absmaj; + axial = ((int) absmin << 1); + init = axial - (int) absmaj; + diag = init - (int) absmaj; - /* ADJUST INITIAL ERROR - * * Adjust by -1 for certain directions so that the vector - * * hits the same pixels when drawn in either direction. - * * The Gamma value is assumed to account for the initial - * * error adjustment for clipped lines. - */ + /* ADJUST INITIAL ERROR + * * Adjust by -1 for certain directions so that the vector + * * hits the same pixels when drawn in either direction. + * * The Gamma value is assumed to account for the initial + * * error adjustment for clipped lines. + */ - init += err; + init += err; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ - GFX_WAIT_PENDING; - WRITE_REG32(GP_DST_XCOOR, (y1 << 16) | x1); - WRITE_REG32(GP_VECTOR_LENGTH, (((unsigned long)init) << 16) | - ((unsigned short)len)); - WRITE_REG32(GP_AXIAL_ERROR, (((unsigned long)diag) << 16) | - ((unsigned short)axial)); - WRITE_REG16(GP_VECTOR_MODE, - (Geode_vector_mode | vector_mode_table[octant])); + GFX_WAIT_PENDING; + WRITE_REG32(GP_DST_XCOOR, (y1 << 16) | x1); + WRITE_REG32(GP_VECTOR_LENGTH, (((unsigned long) init) << 16) | + ((unsigned short) len)); + WRITE_REG32(GP_AXIAL_ERROR, (((unsigned long) diag) << 16) | + ((unsigned short) axial)); + WRITE_REG16(GP_VECTOR_MODE, + (Geode_vector_mode | vector_mode_table[octant])); } void OPTGX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, - int x0, int y0, int x1, int y1, int flags) + int x0, int y0, int x1, int y1, int flags) { - long dx, dy, dmaj, dmin; - long axialerr, diagerr, initerr; - unsigned short vec_flags = 0; - - dx = ABS(x1, x0); - dy = ABS(y1, y0); - if (dx >= dy) { - dmaj = dx; - dmin = dy; - vec_flags = VM_X_MAJOR; - if (x1 > x0) - vec_flags |= VM_MAJOR_INC; - if (y1 > y0) - vec_flags |= VM_MINOR_INC; - } else { - dmaj = dy; - dmin = dx; - vec_flags = VM_Y_MAJOR; - if (x1 > x0) - vec_flags |= VM_MINOR_INC; - if (y1 > y0) - vec_flags |= VM_MAJOR_INC; - } - - axialerr = dmin << 1; - diagerr = (dmin - dmaj) << 1; - initerr = (axialerr - dmaj); - - if (!(vec_flags & VM_MINOR_INC)) - initerr--; - - GFX_WAIT_PENDING; - WRITE_REG32(GP_DST_XCOOR, (y0 << 16) | x0); - WRITE_REG32(GP_VECTOR_LENGTH, (((unsigned long)initerr) << 16) | - ((unsigned short)dmaj)); - WRITE_REG32(GP_AXIAL_ERROR, (((unsigned long)diagerr) << 16) | - ((unsigned short)axialerr)); - WRITE_REG16(GP_VECTOR_MODE, (Geode_vector_mode | vec_flags)); + long dx, dy, dmaj, dmin; + long axialerr, diagerr, initerr; + unsigned short vec_flags = 0; + + dx = ABS(x1, x0); + dy = ABS(y1, y0); + if (dx >= dy) { + dmaj = dx; + dmin = dy; + vec_flags = VM_X_MAJOR; + if (x1 > x0) + vec_flags |= VM_MAJOR_INC; + if (y1 > y0) + vec_flags |= VM_MINOR_INC; + } + else { + dmaj = dy; + dmin = dx; + vec_flags = VM_Y_MAJOR; + if (x1 > x0) + vec_flags |= VM_MINOR_INC; + if (y1 > y0) + vec_flags |= VM_MAJOR_INC; + } + + axialerr = dmin << 1; + diagerr = (dmin - dmaj) << 1; + initerr = (axialerr - dmaj); + + if (!(vec_flags & VM_MINOR_INC)) + initerr--; + + GFX_WAIT_PENDING; + WRITE_REG32(GP_DST_XCOOR, (y0 << 16) | x0); + WRITE_REG32(GP_VECTOR_LENGTH, (((unsigned long) initerr) << 16) | + ((unsigned short) dmaj)); + WRITE_REG32(GP_AXIAL_ERROR, (((unsigned long) diagerr) << 16) | + ((unsigned short) axialerr)); + WRITE_REG16(GP_VECTOR_MODE, (Geode_vector_mode | vec_flags)); } -#if 0 /* disabled due to bugs - can't fallback to fillrectsolid */ +#if 0 /* disabled due to bugs - can't fallback to fillrectsolid */ /*--------------------------------------------------------------------------- * OPTGX1SubsequentHorVertLine * @@ -1627,17 +1640,17 @@ OPTGX1SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, */ void OPTGX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, - int x, int y, int len, int dir) + int x, int y, int len, int dir) { - DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir)); + DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir)); - OPTGX1SubsequentFillRectSolid(pScreenInfo, - (unsigned short)x, (unsigned short)y, - (unsigned short)((dir == DEGREES_0) ? len : - 1), - (unsigned short)((dir == DEGREES_0) ? 1 : - len)); + OPTGX1SubsequentFillRectSolid(pScreenInfo, + (unsigned short) x, (unsigned short) y, + (unsigned short) ((dir == DEGREES_0) ? len : + 1), + (unsigned short) ((dir == DEGREES_0) ? 1 : + len)); } #endif #endif @@ -1660,141 +1673,140 @@ OPTGX1SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, Bool GX1AccelInit(ScreenPtr pScreen) { - GeodePtr pGeode; - ScrnInfoPtr pScreenInfo; + GeodePtr pGeode; + ScrnInfoPtr pScreenInfo; - pScreenInfo = xf86Screens[pScreen->myNum]; - pGeode = GEODEPTR(pScreenInfo); + pScreenInfo = xf86Screens[pScreen->myNum]; + pGeode = GEODEPTR(pScreenInfo); - switch (pScreenInfo->bitsPerPixel) { - case 8: - gu1_bpp = 8; - break; - case 16: - gu1_bpp = 16; - break; - } + switch (pScreenInfo->bitsPerPixel) { + case 8: + gu1_bpp = 8; + break; + case 16: + gu1_bpp = 16; + break; + } #if SCR2SCREXP - gu1_xshift = pScreenInfo->bitsPerPixel >> 4; + gu1_xshift = pScreenInfo->bitsPerPixel >> 4; #endif - switch (pGeode->Pitch) { - case 1024: - gu1_yshift = 10; - break; - case 2048: - gu1_yshift = 11; - break; - case 4096: - gu1_yshift = 12; - break; - } - - Geodebb0Base = BB0_BASE_3K; - Geodebb1Base = BB1_BASE_3K; - GeodebufferWidthPixels = Geodebb1Base - Geodebb0Base - 16; - - if (gu1_bpp > 8) { - /* If 16bpp, divide GFXbufferWidthPixels by 2 */ - GeodebufferWidthPixels >>= 1; - } - /* Getting the pointer for acceleration Inforecord */ - pGeode->AccelInfoRec = localRecPtr = XAACreateInfoRec(); - - /* SET ACCELERATION FLAGS */ - localRecPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER; - localRecPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES; - - /* HOOK SYNCRONIZARION ROUTINE */ - localRecPtr->Sync = GX1AccelSync; - - /* HOOK FILLED RECTANGLES */ - localRecPtr->SetupForSolidFill = (GX1SetupForFillRectSolid); - localRecPtr->SubsequentSolidFillRect = (GX1SubsequentFillRectSolid); - localRecPtr->SolidFillFlags = 0; - - /* HOOK 8x8 MonoEXPAND PATTERNS */ - localRecPtr->SetupForMono8x8PatternFill = GX1SetupFor8x8PatternMonoExpand; - localRecPtr->SubsequentMono8x8PatternFillRect = - GX1Subsequent8x8PatternMonoExpand; - localRecPtr->Mono8x8PatternFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST | - HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN; - - localRecPtr->SetupForColor8x8PatternFill = - GX1SetupFor8x8PatternColorExpand; - localRecPtr->SubsequentColor8x8PatternFillRect = - GX1Subsequent8x8PatternColorExpand; - /* Color expansion */ - localRecPtr->Color8x8PatternFillFlags = - BIT_ORDER_IN_BYTE_MSBFIRST | - SCANLINE_PAD_DWORD | HARDWARE_PATTERN_SCREEN_ORIGIN; - - /* HOOK SCREEN TO SCREEN COPIES - * * Set flag to only allow copy if transparency is enabled. - */ - localRecPtr->SetupForScreenToScreenCopy = - OPTACCEL(GX1SetupForScreenToScreenCopy); - localRecPtr->SubsequentScreenToScreenCopy = - OPTACCEL(GX1SubsequentScreenToScreenCopy); - localRecPtr->ScreenToScreenCopyFlags = 0; - - /* HOOK BRESENHAM SOLID LINES */ - /* Do not hook unless flag can be set preventing use of planemask. */ - localRecPtr->SolidLineFlags = NO_PLANEMASK; - localRecPtr->SetupForSolidLine = OPTACCEL(GX1SetupForSolidLine); - localRecPtr->SubsequentSolidBresenhamLine = - OPTACCEL(GX1SubsequentBresenhamLine); + switch (pGeode->Pitch) { + case 1024: + gu1_yshift = 10; + break; + case 2048: + gu1_yshift = 11; + break; + case 4096: + gu1_yshift = 12; + break; + } + + Geodebb0Base = BB0_BASE_3K; + Geodebb1Base = BB1_BASE_3K; + GeodebufferWidthPixels = Geodebb1Base - Geodebb0Base - 16; + + if (gu1_bpp > 8) { + /* If 16bpp, divide GFXbufferWidthPixels by 2 */ + GeodebufferWidthPixels >>= 1; + } + /* Getting the pointer for acceleration Inforecord */ + pGeode->AccelInfoRec = localRecPtr = XAACreateInfoRec(); + + /* SET ACCELERATION FLAGS */ + localRecPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER; + localRecPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES; + + /* HOOK SYNCRONIZARION ROUTINE */ + localRecPtr->Sync = GX1AccelSync; + + /* HOOK FILLED RECTANGLES */ + localRecPtr->SetupForSolidFill = (GX1SetupForFillRectSolid); + localRecPtr->SubsequentSolidFillRect = (GX1SubsequentFillRectSolid); + localRecPtr->SolidFillFlags = 0; + + /* HOOK 8x8 MonoEXPAND PATTERNS */ + localRecPtr->SetupForMono8x8PatternFill = GX1SetupFor8x8PatternMonoExpand; + localRecPtr->SubsequentMono8x8PatternFillRect = + GX1Subsequent8x8PatternMonoExpand; + localRecPtr->Mono8x8PatternFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST | + HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN; + + localRecPtr->SetupForColor8x8PatternFill = GX1SetupFor8x8PatternColorExpand; + localRecPtr->SubsequentColor8x8PatternFillRect = + GX1Subsequent8x8PatternColorExpand; + /* Color expansion */ + localRecPtr->Color8x8PatternFillFlags = + BIT_ORDER_IN_BYTE_MSBFIRST | + SCANLINE_PAD_DWORD | HARDWARE_PATTERN_SCREEN_ORIGIN; + + /* HOOK SCREEN TO SCREEN COPIES + * * Set flag to only allow copy if transparency is enabled. + */ + localRecPtr->SetupForScreenToScreenCopy = + OPTACCEL(GX1SetupForScreenToScreenCopy); + localRecPtr->SubsequentScreenToScreenCopy = + OPTACCEL(GX1SubsequentScreenToScreenCopy); + localRecPtr->ScreenToScreenCopyFlags = 0; + + /* HOOK BRESENHAM SOLID LINES */ + /* Do not hook unless flag can be set preventing use of planemask. */ + localRecPtr->SolidLineFlags = NO_PLANEMASK; + localRecPtr->SetupForSolidLine = OPTACCEL(GX1SetupForSolidLine); + localRecPtr->SubsequentSolidBresenhamLine = + OPTACCEL(GX1SubsequentBresenhamLine); #if !defined(OPT_ACCEL) - localRecPtr->SubsequentSolidHorVertLine = - OPTACCEL(GX1SubsequentHorVertLine); + localRecPtr->SubsequentSolidHorVertLine = + OPTACCEL(GX1SubsequentHorVertLine); #endif - localRecPtr->SubsequentSolidTwoPointLine = - OPTACCEL(GX1SubsequentSolidTwoPointLine); - localRecPtr->SolidBresenhamLineErrorTermBits = 15; + localRecPtr->SubsequentSolidTwoPointLine = + OPTACCEL(GX1SubsequentSolidTwoPointLine); + localRecPtr->SolidBresenhamLineErrorTermBits = 15; #if SCR2SCREXP - /* Color expansion */ - localRecPtr->ScreenToScreenColorExpandFillFlags = - BIT_ORDER_IN_BYTE_MSBFIRST | NO_TRANSPARENCY; - - localRecPtr->SetupForScreenToScreenColorExpandFill = - (GX1SetupForScreenToScreenColorExpandFill); - localRecPtr->SubsequentScreenToScreenColorExpandFill = - (GX1SubsequentScreenToScreenColorExpandFill); + /* Color expansion */ + localRecPtr->ScreenToScreenColorExpandFillFlags = + BIT_ORDER_IN_BYTE_MSBFIRST | NO_TRANSPARENCY; + + localRecPtr->SetupForScreenToScreenColorExpandFill = + (GX1SetupForScreenToScreenColorExpandFill); + localRecPtr->SubsequentScreenToScreenColorExpandFill = + (GX1SubsequentScreenToScreenColorExpandFill); #endif - /* - * ImageWrite. - * - * SInce this uses off-screen scanline buffers, it is only of use when - * complex ROPs are used. But since the current XAA pixmap cache code - * only works when an ImageWrite is provided, the NO_GXCOPY flag is - * temporarily disabled. - */ - if (pGeode->AccelImageWriteBufferOffsets) { - - localRecPtr->ScanlineImageWriteFlags = - localRecPtr->ScreenToScreenCopyFlags; - localRecPtr->ScanlineImageWriteBuffers = - pGeode->AccelImageWriteBufferOffsets; - localRecPtr->NumScanlineImageWriteBuffers = pGeode->NoOfImgBuffers; - localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu1_yshift; - localRecPtr->SetupForScanlineImageWrite = - OPTACCEL(GX1SetupForScanlineImageWrite); - localRecPtr->SubsequentScanlineImageWriteRect = - OPTACCEL(GX1SubsequentScanlineImageWriteRect); - localRecPtr->SubsequentImageWriteScanline = - OPTACCEL(GX1SubsequentImageWriteScanline); - - ImgBufOffset = pGeode->AccelImageWriteBufferOffsets[0] - pGeode->FBBase; - Geodesrcy = ImgBufOffset >> gu1_yshift; - - Geodesrcx = ImgBufOffset & (pGeode->Pitch - 1); - Geodesrcx /= (pScreenInfo->bitsPerPixel >> 3); - } - - return (XAAInit(pScreen, localRecPtr)); + /* + * ImageWrite. + * + * SInce this uses off-screen scanline buffers, it is only of use when + * complex ROPs are used. But since the current XAA pixmap cache code + * only works when an ImageWrite is provided, the NO_GXCOPY flag is + * temporarily disabled. + */ + if (pGeode->AccelImageWriteBufferOffsets) { + + localRecPtr->ScanlineImageWriteFlags = + localRecPtr->ScreenToScreenCopyFlags; + localRecPtr->ScanlineImageWriteBuffers = + pGeode->AccelImageWriteBufferOffsets; + localRecPtr->NumScanlineImageWriteBuffers = pGeode->NoOfImgBuffers; + localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu1_yshift; + localRecPtr->SetupForScanlineImageWrite = + OPTACCEL(GX1SetupForScanlineImageWrite); + localRecPtr->SubsequentScanlineImageWriteRect = + OPTACCEL(GX1SubsequentScanlineImageWriteRect); + localRecPtr->SubsequentImageWriteScanline = + OPTACCEL(GX1SubsequentImageWriteScanline); + + ImgBufOffset = pGeode->AccelImageWriteBufferOffsets[0] - pGeode->FBBase; + Geodesrcy = ImgBufOffset >> gu1_yshift; + + Geodesrcx = ImgBufOffset & (pGeode->Pitch - 1); + Geodesrcx /= (pScreenInfo->bitsPerPixel >> 3); + } + + return (XAAInit(pScreen, localRecPtr)); } /* END OF FILE */ diff --git a/src/nsc_gx1_cursor.c b/src/nsc_gx1_cursor.c index 158b647..1eac717 100644 --- a/src/nsc_gx1_cursor.c +++ b/src/nsc_gx1_cursor.c @@ -159,9 +159,9 @@ void GX1HideCursor(ScrnInfoPtr pScreenInfo); void GX1ShowCursor(ScrnInfoPtr pScreenInfo); static Bool GX1UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs); extern void GX1SetVideoPosition(int x, int y, int width, int height, - short src_w, short src_h, short drw_w, - short drw_h, int id, int offset, - ScrnInfoPtr pScrn); + short src_w, short src_h, short drw_w, + short drw_h, int id, int offset, + ScrnInfoPtr pScrn); /*---------------------------------------------------------------------------- * GX1HWCursorInit. * @@ -180,31 +180,31 @@ extern void GX1SetVideoPosition(int x, int y, int width, int height, Bool GX1HWCursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; - GeodePtr pGeode = GEODEPTR(pScreenInfo); - xf86CursorInfoPtr infoPtr; + ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; + GeodePtr pGeode = GEODEPTR(pScreenInfo); + xf86CursorInfoPtr infoPtr; - infoPtr = xf86CreateCursorInfoRec(); - if (!infoPtr) - 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; - /* cursor info ptr is intiallized with the values obtained from - * * durnago calls - */ - infoPtr->SetCursorColors = GX1SetCursorColors; - infoPtr->SetCursorPosition = GX1SetCursorPosition; - infoPtr->LoadCursorImage = GX1LoadCursorImage; - infoPtr->HideCursor = GX1HideCursor; - infoPtr->ShowCursor = GX1ShowCursor; - infoPtr->UseHWCursor = GX1UseHWCursor; - return (xf86InitCursor(pScreen, infoPtr)); + infoPtr = xf86CreateCursorInfoRec(); + if (!infoPtr) + 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; + /* cursor info ptr is intiallized with the values obtained from + * * durnago calls + */ + infoPtr->SetCursorColors = GX1SetCursorColors; + infoPtr->SetCursorPosition = GX1SetCursorPosition; + infoPtr->LoadCursorImage = GX1LoadCursorImage; + infoPtr->HideCursor = GX1HideCursor; + infoPtr->ShowCursor = GX1ShowCursor; + infoPtr->UseHWCursor = GX1UseHWCursor; + return (xf86InitCursor(pScreen, infoPtr)); } /*---------------------------------------------------------------------------- @@ -225,7 +225,7 @@ GX1HWCursorInit(ScreenPtr pScreen) static void GX1SetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg) { - GFX(set_cursor_colors(bg, fg)); + GFX(set_cursor_colors(bg, fg)); } /*---------------------------------------------------------------------------- @@ -245,44 +245,44 @@ GX1SetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg) static void GX1SetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y) { - unsigned long offset; - static int panOffset = 0; - GeodePtr pGeode = GEODEPTR(pScreenInfo); + unsigned long offset; + static int panOffset = 0; + GeodePtr pGeode = GEODEPTR(pScreenInfo); - unsigned short xhot = 0, yhot = 0; + unsigned short xhot = 0, yhot = 0; - if (x < 0) { - xhot = (unsigned short)(-x); - x = 0; - } - if (y < 0) { - yhot = (unsigned short)(-y); - y = 0; - } + if (x < 0) { + xhot = (unsigned short) (-x); + x = 0; + } + if (y < 0) { + yhot = (unsigned short) (-y); + y = 0; + } - if (pGeode->TV_Overscan_On) { - x += pGeode->TVOx; - y += pGeode->TVOy; - } - GFX(set_cursor_position(pGeode->CursorStartOffset, x, y, xhot, yhot)); - GFX(set_cursor_enable(1)); + if (pGeode->TV_Overscan_On) { + x += pGeode->TVOx; + y += pGeode->TVOy; + } + GFX(set_cursor_position(pGeode->CursorStartOffset, x, y, xhot, yhot)); + GFX(set_cursor_enable(1)); - if ((pGeode->OverlayON) && (pGeode->Panel)) { + if ((pGeode->OverlayON) && (pGeode->Panel)) { #if defined(STB_X) - Gal_get_display_offset(&offset); + Gal_get_display_offset(&offset); #else - offset = gfx_get_display_offset(); + offset = gfx_get_display_offset(); #endif - if (offset != panOffset) { - GX1SetVideoPosition(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 = offset; - } - } + if (offset != panOffset) { + GX1SetVideoPosition(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 = offset; + } + } } /*---------------------------------------------------------------------------- @@ -301,33 +301,34 @@ GX1SetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y) void GX1LoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char *src) { - int i; - unsigned long shape; - unsigned long mask; - unsigned long andMask[32] = { 0, }; - unsigned long xorMask[32] = { 0, }; - GeodePtr pGeode = GEODEPTR(pScreenInfo); + int i; + unsigned long shape; + unsigned long mask; + unsigned long andMask[32] = { 0, }; + unsigned long xorMask[32] = { 0, }; + GeodePtr pGeode = GEODEPTR(pScreenInfo); - for (i = 0; i < 32; i++) { - if (src) { - shape = ((unsigned long)src[i * 4] << 24) | - ((unsigned long)src[i * 4 + 1] << 16) | - ((unsigned long)src[i * 4 + 2] << 8) | - ((unsigned long)src[i * 4 + 3] << 0); - mask = ((unsigned long)src[i * 4 + 128] << 24) | - ((unsigned long)src[i * 4 + 1 + 128] << 16) | - ((unsigned long)src[i * 4 + 2 + 128] << 8) | - ((unsigned long)src[i * 4 + 3 + 128] << 0); - } else { - mask = 0x0; - shape = 0xFFFFFFFF; - } + for (i = 0; i < 32; i++) { + if (src) { + shape = ((unsigned long) src[i * 4] << 24) | + ((unsigned long) src[i * 4 + 1] << 16) | + ((unsigned long) src[i * 4 + 2] << 8) | + ((unsigned long) src[i * 4 + 3] << 0); + mask = ((unsigned long) src[i * 4 + 128] << 24) | + ((unsigned long) src[i * 4 + 1 + 128] << 16) | + ((unsigned long) src[i * 4 + 2 + 128] << 8) | + ((unsigned long) src[i * 4 + 3 + 128] << 0); + } + else { + mask = 0x0; + shape = 0xFFFFFFFF; + } - andMask[i] = ~(mask); - xorMask[i] = shape & mask; - } + andMask[i] = ~(mask); + xorMask[i] = shape & mask; + } - GFX(set_cursor_shape32(pGeode->CursorStartOffset, andMask, xorMask)); + GFX(set_cursor_shape32(pGeode->CursorStartOffset, andMask, xorMask)); } /*---------------------------------------------------------------------------- @@ -347,7 +348,7 @@ GX1LoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char *src) void GX1HideCursor(ScrnInfoPtr pScreenInfo) { - GFX(set_cursor_enable(0)); + GFX(set_cursor_enable(0)); } /*---------------------------------------------------------------------------- @@ -367,7 +368,7 @@ GX1HideCursor(ScrnInfoPtr pScreenInfo) void GX1ShowCursor(ScrnInfoPtr pScreenInfo) { - GFX(set_cursor_enable(1)); + GFX(set_cursor_enable(1)); } /*---------------------------------------------------------------------------- @@ -388,11 +389,11 @@ GX1ShowCursor(ScrnInfoPtr pScreenInfo) static Bool GX1UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) { - ScrnInfoPtr pScreenInfo = XF86SCRNINFO(pScreen); + ScrnInfoPtr pScreenInfo = XF86SCRNINFO(pScreen); - if (pScreenInfo->currentMode->Flags & V_DBLSCAN) - return FALSE; - return TRUE; + if (pScreenInfo->currentMode->Flags & V_DBLSCAN) + return FALSE; + return TRUE; } /* End of File */ diff --git a/src/nsc_gx1_dga.c b/src/nsc_gx1_dga.c index 1ec14fb..93b369c 100644 --- a/src/nsc_gx1_dga.c +++ b/src/nsc_gx1_dga.c @@ -158,7 +158,7 @@ /* forward declarations */ static Bool GX1_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, - int *, int *, int *); + int *, int *, int *); static void GX1_CloseFramebuffer(ScrnInfoPtr pScrn); static Bool GX1_SetMode(ScrnInfoPtr, DGAModePtr); static int GX1_GetViewport(ScrnInfoPtr); @@ -173,15 +173,15 @@ extern void GX1AccelSync(ScrnInfoPtr pScreenInfo); Bool GX1DGAInit(ScreenPtr pScreen); static DGAFunctionRec GeodeDGAFuncs = { - GX1_OpenFramebuffer, - GX1_CloseFramebuffer, - GX1_SetMode, - GX1_SetViewport, - GX1_GetViewport, - GX1AccelSync, - GX1_FillRect, - GX1_BlitRect, - NULL + GX1_OpenFramebuffer, + GX1_CloseFramebuffer, + GX1_SetMode, + GX1_SetViewport, + GX1_GetViewport, + GX1AccelSync, + GX1_FillRect, + GX1_BlitRect, + NULL }; /*---------------------------------------------------------------------------- @@ -202,94 +202,96 @@ static DGAFunctionRec GeodeDGAFuncs = { Bool GX1DGAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - GeodePtr pGeode = GEODEPTR(pScrn); - DGAModePtr modes = NULL, newmodes = NULL, currentMode; - DisplayModePtr pMode, firstMode; - int Bpp = pScrn->bitsPerPixel >> 3; - int num = 0; - Bool oneMore; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + GeodePtr pGeode = GEODEPTR(pScrn); + DGAModePtr modes = NULL, newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int Bpp = pScrn->bitsPerPixel >> 3; + int num = 0; + Bool oneMore; - pMode = firstMode = pScrn->modes; - DEBUGMSG(0, (0, X_NONE, "GX1DGAInit\n")); - while (pMode) { + pMode = firstMode = pScrn->modes; + DEBUGMSG(0, (0, X_NONE, "GX1DGAInit\n")); + while (pMode) { - /* redundant but it can be used in future:if(0). */ - if (0) { /*pScrn->displayWidth != pMode->HDisplay */ - /* memory is allocated for dga to - *setup the viewport and mode parameters - */ - newmodes = realloc(modes, (num + 2) * sizeof(DGAModeRec)); - oneMore = TRUE; - } else { - /* one record is allocated here */ - newmodes = realloc(modes, (num + 1) * sizeof(DGAModeRec)); - oneMore = FALSE; - } - if (!newmodes) { - free(modes); - return FALSE; - } - modes = newmodes; + /* redundant but it can be used in future:if(0). */ + if (0) { /*pScrn->displayWidth != pMode->HDisplay */ + /* memory is allocated for dga to + *setup the viewport and mode parameters + */ + newmodes = realloc(modes, (num + 2) * sizeof(DGAModeRec)); + oneMore = TRUE; + } + else { + /* one record is allocated here */ + newmodes = realloc(modes, (num + 1) * sizeof(DGAModeRec)); + oneMore = FALSE; + } + if (!newmodes) { + free(modes); + return FALSE; + } + modes = newmodes; - SECOND_PASS: /* DGA mode flgas and viewport parametrs are set here. */ + SECOND_PASS: /* DGA mode flgas and viewport parametrs are set here. */ - currentMode = modes + num; - num++; - currentMode->mode = pMode; - currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; - currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; - if (pMode->Flags & V_DBLSCAN) - currentMode->flags |= DGA_DOUBLESCAN; - if (pMode->Flags & V_INTERLACE) - currentMode->flags |= DGA_INTERLACED; - currentMode->byteOrder = pScrn->imageByteOrder; - currentMode->depth = pScrn->depth; - currentMode->bitsPerPixel = pScrn->bitsPerPixel; - currentMode->red_mask = pScrn->mask.red; - currentMode->green_mask = pScrn->mask.green; - currentMode->blue_mask = pScrn->mask.blue; - currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; - currentMode->viewportWidth = pMode->HDisplay; - currentMode->viewportHeight = pMode->VDisplay; - currentMode->xViewportStep = 1; - currentMode->yViewportStep = 1; - currentMode->viewportFlags = DGA_FLIP_RETRACE; - currentMode->offset = 0; - currentMode->address = pGeode->FBBase; - if (oneMore) { /* first one is narrow width */ - currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; - currentMode->imageWidth = pMode->HDisplay; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - oneMore = FALSE; - goto SECOND_PASS; - } else { - currentMode->bytesPerScanline = - ((pScrn->displayWidth * Bpp) + 3) & ~3L; - currentMode->imageWidth = pScrn->displayWidth; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - } - pMode = pMode->next; - if (pMode == firstMode) - break; - } - pGeode->numDGAModes = num; - pGeode->DGAModes = modes; - return DGAInit(pScreen, &GeodeDGAFuncs, modes, num); + currentMode = modes + num; + num++; + currentMode->mode = pMode; + currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if (pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if (pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = pScrn->depth; + currentMode->bitsPerPixel = pScrn->bitsPerPixel; + currentMode->red_mask = pScrn->mask.red; + currentMode->green_mask = pScrn->mask.green; + currentMode->blue_mask = pScrn->mask.blue; + currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 1; + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = pGeode->FBBase; + if (oneMore) { /* first one is narrow width */ + currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; + currentMode->imageWidth = pMode->HDisplay; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + oneMore = FALSE; + goto SECOND_PASS; + } + else { + currentMode->bytesPerScanline = + ((pScrn->displayWidth * Bpp) + 3) & ~3L; + currentMode->imageWidth = pScrn->displayWidth; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + } + pMode = pMode->next; + if (pMode == firstMode) + break; + } + pGeode->numDGAModes = num; + pGeode->DGAModes = modes; + return DGAInit(pScreen, &GeodeDGAFuncs, modes, num); } /*---------------------------------------------------------------------------- @@ -310,41 +312,42 @@ GX1DGAInit(ScreenPtr pScreen) static Bool GX1_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) { - static int OldDisplayWidth[MAXSCREENS]; - int index = pScrn->pScreen->myNum; - GeodePtr pGeode = GEODEPTR(pScrn); + static int OldDisplayWidth[MAXSCREENS]; + int index = pScrn->pScreen->myNum; + GeodePtr pGeode = GEODEPTR(pScrn); - DEBUGMSG(0, (0, X_NONE, "GX1_SetMode\n")); - if (!pMode) { - /* restore the original mode - * * put the ScreenParameters back - */ - pScrn->displayWidth = OldDisplayWidth[index]; - GX1SwitchMode(index, pScrn->currentMode, 0); - pGeode->DGAactive = FALSE; - } else { - if (!pGeode->DGAactive) { /* save the old parameters */ - OldDisplayWidth[index] = pScrn->displayWidth; - pGeode->DGAactive = TRUE; - } - pScrn->displayWidth = pMode->bytesPerScanline / - (pMode->bitsPerPixel >> 3); - GX1SwitchMode(index, pMode->mode, 0); - } - /* enable/disable cursor */ - if (pGeode->HWCursor) { + DEBUGMSG(0, (0, X_NONE, "GX1_SetMode\n")); + if (!pMode) { + /* restore the original mode + * * put the ScreenParameters back + */ + pScrn->displayWidth = OldDisplayWidth[index]; + GX1SwitchMode(index, pScrn->currentMode, 0); + pGeode->DGAactive = FALSE; + } + else { + if (!pGeode->DGAactive) { /* save the old parameters */ + OldDisplayWidth[index] = pScrn->displayWidth; + pGeode->DGAactive = TRUE; + } + pScrn->displayWidth = pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3); + GX1SwitchMode(index, pMode->mode, 0); + } + /* enable/disable cursor */ + if (pGeode->HWCursor) { #if defined(STB_X) - Gal_set_compression_enable(((pGeode->DGAactive) ? - GAL_COMPRESSION_DISABLE : - GAL_COMPRESSION_ENABLE)); - Gal_set_cursor_enable(!pGeode->DGAactive); + Gal_set_compression_enable(((pGeode->DGAactive) ? + GAL_COMPRESSION_DISABLE : + GAL_COMPRESSION_ENABLE)); + Gal_set_cursor_enable(!pGeode->DGAactive); #else - gfx_set_cursor_enable(!pGeode->DGAactive); - gfx_set_compression_enable(!pGeode->DGAactive); -#endif /* STB_X */ - } + gfx_set_cursor_enable(!pGeode->DGAactive); + gfx_set_compression_enable(!pGeode->DGAactive); +#endif /* STB_X */ + } - return TRUE; + return TRUE; } /*---------------------------------------------------------------------------- @@ -365,9 +368,9 @@ GX1_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) static int GX1_GetViewport(ScrnInfoPtr pScrn) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - return pGeode->DGAViewportStatus; + return pGeode->DGAViewportStatus; } /*---------------------------------------------------------------------------- @@ -389,10 +392,10 @@ GX1_GetViewport(ScrnInfoPtr pScrn) static void GX1_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - GX1AdjustFrame(pScrn->pScreen->myNum, x, y, flags); - pGeode->DGAViewportStatus = 0; /*GX1AdjustFrame loops until finished */ + GX1AdjustFrame(pScrn->pScreen->myNum, x, y, flags); + pGeode->DGAViewportStatus = 0; /*GX1AdjustFrame loops until finished */ } /*---------------------------------------------------------------------------- @@ -415,16 +418,15 @@ GX1_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) *---------------------------------------------------------------------------- */ static void -GX1_FillRect(ScrnInfoPtr pScrn, int x, int y, - int w, int h, unsigned long color) +GX1_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - if (pGeode->AccelInfoRec) { - (*pGeode->AccelInfoRec->SetupForSolidFill) (pScrn, color, GXcopy, ~0); - (*pGeode->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); - SET_SYNC_FLAG(pGeode->AccelInfoRec); - } + if (pGeode->AccelInfoRec) { + (*pGeode->AccelInfoRec->SetupForSolidFill) (pScrn, color, GXcopy, ~0); + (*pGeode->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); + SET_SYNC_FLAG(pGeode->AccelInfoRec); + } } /*---------------------------------------------------------------------------- @@ -450,21 +452,21 @@ GX1_FillRect(ScrnInfoPtr pScrn, int x, int y, */ static void GX1_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, - int h, int dstx, int dsty) + int h, int dstx, int dsty) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - if (pGeode->AccelInfoRec) { - int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; - int ydir = (srcy < dsty) ? -1 : 1; + if (pGeode->AccelInfoRec) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; - (*pGeode->AccelInfoRec->SetupForScreenToScreenCopy) - (pScrn, xdir, ydir, GXcopy, ~0, -1); - (*pGeode->AccelInfoRec->SubsequentScreenToScreenCopy) (pScrn, srcx, - srcy, dstx, dsty, - w, h); - SET_SYNC_FLAG(pGeode->AccelInfoRec); - } + (*pGeode->AccelInfoRec->SetupForScreenToScreenCopy) + (pScrn, xdir, ydir, GXcopy, ~0, -1); + (*pGeode->AccelInfoRec->SubsequentScreenToScreenCopy) (pScrn, srcx, + srcy, dstx, dsty, + w, h); + SET_SYNC_FLAG(pGeode->AccelInfoRec); + } } /*---------------------------------------------------------------------------- @@ -488,17 +490,17 @@ GX1_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, */ static Bool GX1_OpenFramebuffer(ScrnInfoPtr pScrn, - char **name, unsigned char **mem, - int *size, int *offset, int *flags) + char **name, unsigned char **mem, + int *size, int *offset, int *flags) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - *name = NULL; /* no special device */ - *mem = (unsigned char *)pGeode->FBLinearAddr; - *size = pGeode->FBSize; - *offset = 0; - *flags = DGA_NEED_ROOT; - return TRUE; + *name = NULL; /* no special device */ + *mem = (unsigned char *) pGeode->FBLinearAddr; + *size = pGeode->FBSize; + *offset = 0; + *flags = DGA_NEED_ROOT; + return TRUE; } static void diff --git a/src/nsc_gx1_driver.c b/src/nsc_gx1_driver.c index 094f026..e2488d2 100644 --- a/src/nsc_gx1_driver.c +++ b/src/nsc_gx1_driver.c @@ -190,7 +190,7 @@ #ifdef XFreeXDGA #define _XF86_DGA_SERVER_ #include <X11/extensions/xf86dgaproto.h> -#endif /* XFreeXDGA */ +#endif /* XFreeXDGA */ #include "globals.h" #include "opaque.h" @@ -214,46 +214,45 @@ extern SymTabRec GeodeChipsets[]; extern OptionInfoRec GeodeOptions[]; -typedef struct _MemOffset -{ - unsigned long xres; - unsigned long yres; - unsigned long bpp; - unsigned long CBOffset; - unsigned short CBPitch; - unsigned short CBSize; - unsigned long CurOffset; - unsigned long OffScreenOffset; -} -MemOffset; +typedef struct _MemOffset { + unsigned long xres; + unsigned long yres; + unsigned long bpp; + unsigned long CBOffset; + unsigned short CBPitch; + unsigned short CBSize; + unsigned long CurOffset; + unsigned long OffScreenOffset; +} MemOffset; /* predefined memory address for compression and cursor offsets * if COMPRESSION enabled. */ MemOffset GeodeMemOffset[] = { - {640, 480, 8, 640, 1024, 272, 0x78000, 0x78100}, - {640, 480, 16, 1280, 2048, 272, 0x610, 0xF0000}, - {800, 600, 8, 800, 1024, 208, 0x96000, 0x96100}, - {800, 600, 16, 1600, 2048, 272, 0x12C000, 0x12C100}, - {1024, 768, 8, 0xC0000, 272, 272, 0xF3000, 0xF3100}, - {1024, 768, 16, 0x180000, 272, 272, 0x1B3000, 0x1B3100}, - {1152, 864, 8, 1152, 2048, 272, 0x590, 0x1B0000}, - {1152, 864, 16, 2304, 4096, 272, 0xA10, 0x360000}, - {1280, 1024, 8, 1280, 2048, 272, 0x610, 0x200000}, - {1280, 1024, 16, 2560, 4096, 272, 0xB10, 0x400000}, + {640, 480, 8, 640, 1024, 272, 0x78000, 0x78100}, + {640, 480, 16, 1280, 2048, 272, 0x610, 0xF0000}, + {800, 600, 8, 800, 1024, 208, 0x96000, 0x96100}, + {800, 600, 16, 1600, 2048, 272, 0x12C000, 0x12C100}, + {1024, 768, 8, 0xC0000, 272, 272, 0xF3000, 0xF3100}, + {1024, 768, 16, 0x180000, 272, 272, 0x1B3000, 0x1B3100}, + {1152, 864, 8, 1152, 2048, 272, 0x590, 0x1B0000}, + {1152, 864, 16, 2304, 4096, 272, 0xA10, 0x360000}, + {1280, 1024, 8, 1280, 2048, 272, 0x610, 0x200000}, + {1280, 1024, 16, 2560, 4096, 272, 0xB10, 0x400000}, - /* PAL TV modes */ + /* PAL TV modes */ - {704, 576, 16, 1408, 2048, 272, 0x690, 0x120000}, - {720, 576, 16, 1440, 2048, 272, 0x6B0, 0x120000}, - {768, 576, 16, 1536, 2048, 256, 0x700, 0x120000}, + {704, 576, 16, 1408, 2048, 272, 0x690, 0x120000}, + {720, 576, 16, 1440, 2048, 272, 0x6B0, 0x120000}, + {768, 576, 16, 1536, 2048, 256, 0x700, 0x120000}, - /* NTSC TV modes */ + /* NTSC TV modes */ - {704, 480, 16, 1408, 2048, 272, 0x690, 0xF0000}, - {720, 480, 16, 1440, 2048, 272, 0x6B0, 0xF0000} + {704, 480, 16, 1408, 2048, 272, 0x690, 0xF0000}, + {720, 480, 16, 1440, 2048, 272, 0x6B0, 0xF0000} }; + static int MemIndex = 0; static Bool GX1PreInit(ScrnInfoPtr, int); @@ -265,8 +264,8 @@ void GX1AdjustFrame(int, int, int, int); Bool GX1SwitchMode(int, DisplayModePtr, int); static ModeStatus GX1ValidMode(int, DisplayModePtr, Bool, int); static void GX1LoadPalette(ScrnInfoPtr pScreenInfo, - int numColors, int *indizes, - LOCO * colors, VisualPtr pVisual); + int numColors, int *indizes, + LOCO * colors, VisualPtr pVisual); static Bool GX1MapMem(ScrnInfoPtr); static Bool GX1UnmapMem(ScrnInfoPtr); @@ -283,15 +282,14 @@ extern Bool GX1DGAInit(ScreenPtr pScreen); extern void GX1LoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char *src); extern unsigned int GetVideoMemSize(void); -void get_tv_overscan_geom(const char *options, int *X, int *Y, int *W, - int *H); +void get_tv_overscan_geom(const char *options, int *X, int *Y, int *W, int *H); void GX1SetupChipsetFPtr(ScrnInfoPtr pScrn); GeodePtr GX1GetRec(ScrnInfoPtr pScreenInfo); void gx1_clear_screen(int width, int height); #if !defined(STB_X) extern unsigned char *XpressROMPtr; -#endif /* STB_X */ +#endif /* STB_X */ /* List of symbols from other modules that this module references.The purpose * is that to avoid unresolved symbol warnings @@ -308,16 +306,16 @@ extern const char *nscShadowSymbols[]; void GX1SetupChipsetFPtr(ScrnInfoPtr pScrn) { - GeodeDebug(("GX1SetupChipsetFPtr!\n")); - - pScrn->PreInit = GX1PreInit; - pScrn->ScreenInit = GX1ScreenInit; - pScrn->SwitchMode = GX1SwitchMode; - pScrn->AdjustFrame = GX1AdjustFrame; - pScrn->EnterVT = GX1EnterVT; - pScrn->LeaveVT = GX1LeaveVT; - pScrn->FreeScreen = GX1FreeScreen; - pScrn->ValidMode = GX1ValidMode; + GeodeDebug(("GX1SetupChipsetFPtr!\n")); + + pScrn->PreInit = GX1PreInit; + pScrn->ScreenInit = GX1ScreenInit; + pScrn->SwitchMode = GX1SwitchMode; + pScrn->AdjustFrame = GX1AdjustFrame; + pScrn->EnterVT = GX1EnterVT; + pScrn->LeaveVT = GX1LeaveVT; + pScrn->FreeScreen = GX1FreeScreen; + pScrn->ValidMode = GX1ValidMode; } /*---------------------------------------------------------------------------- @@ -338,9 +336,9 @@ GX1SetupChipsetFPtr(ScrnInfoPtr pScrn) GeodePtr GX1GetRec(ScrnInfoPtr pScreenInfo) { - if (!pScreenInfo->driverPrivate) - pScreenInfo->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1); - return GEODEPTR(pScreenInfo); + if (!pScreenInfo->driverPrivate) + pScreenInfo->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1); + return GEODEPTR(pScreenInfo); } /*---------------------------------------------------------------------------- @@ -361,11 +359,11 @@ GX1GetRec(ScrnInfoPtr pScreenInfo) static void GX1FreeRec(ScrnInfoPtr pScreenInfo) { - if (pScreenInfo->driverPrivate == NULL) { - return; - } - free(pScreenInfo->driverPrivate); - pScreenInfo->driverPrivate = NULL; + if (pScreenInfo->driverPrivate == NULL) { + return; + } + free(pScreenInfo->driverPrivate); + pScreenInfo->driverPrivate = NULL; } /*---------------------------------------------------------------------------- @@ -386,15 +384,15 @@ static Bool GX1SaveScreen(ScreenPtr pScreen, int mode) { #if !defined(STB_X) - ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; - GeodeDebug(("GX2SaveScreen!\n")); + GeodeDebug(("GX2SaveScreen!\n")); - if (!pScreenInfo->vtSema) - return vgaHWSaveScreen(pScreen, mode); + if (!pScreenInfo->vtSema) + return vgaHWSaveScreen(pScreen, mode); -#endif /* STB_X */ - return TRUE; +#endif /* STB_X */ + return TRUE; } /*---------------------------------------------------------------------------- @@ -416,28 +414,28 @@ GX1SaveScreen(ScreenPtr pScreen, int mode) void get_tv_overscan_geom(const char *options, int *X, int *Y, int *W, int *H) { - char *tv_opt; - - tv_opt = strtok((char *)options, ":"); - *X = strtoul(tv_opt, NULL, 0); - tv_opt = strtok(NULL, ":"); - *Y = strtoul(tv_opt, NULL, 0); - tv_opt = strtok(NULL, ":"); - *W = strtoul(tv_opt, NULL, 0); - tv_opt = strtok(NULL, ":"); - *H = strtoul(tv_opt, NULL, 0); + char *tv_opt; + + tv_opt = strtok((char *) options, ":"); + *X = strtoul(tv_opt, NULL, 0); + tv_opt = strtok(NULL, ":"); + *Y = strtoul(tv_opt, NULL, 0); + tv_opt = strtok(NULL, ":"); + *W = strtoul(tv_opt, NULL, 0); + tv_opt = strtok(NULL, ":"); + *H = strtoul(tv_opt, NULL, 0); } static void GX1ProbeDDC(ScrnInfoPtr pScrn, int index) { - vbeInfoPtr pVbe; + vbeInfoPtr pVbe; - if (xf86LoadSubModule(pScrn, "vbe")) { - pVbe = VBEInit(NULL, index); - ConfiguredMonitor = vbeDoEDID(pVbe, NULL); - vbeFree(pVbe); - } + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL, index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + vbeFree(pVbe); + } } /*---------------------------------------------------------------------------- @@ -457,600 +455,616 @@ GX1ProbeDDC(ScrnInfoPtr pScrn, int index) static Bool GX1PreInit(ScrnInfoPtr pScreenInfo, int flags) { - static ClockRange GeodeClockRange = - { NULL, 25175, 135000, 0, FALSE, TRUE, 1, 1, 0 }; - MessageType from; - int i = 0; - GeodePtr pGeode; + static ClockRange GeodeClockRange = + { NULL, 25175, 135000, 0, FALSE, TRUE, 1, 1, 0 }; + MessageType from; + int i = 0; + GeodePtr pGeode; #if defined(STB_X) - GAL_ADAPTERINFO sAdapterInfo; -#endif /* STB_X */ - unsigned int PitchInc = 0, minPitch = 0, maxPitch = 0; - unsigned int minHeight = 0, maxHeight = 0; - const char *s; - char **modes; - char **tvmodes_defa; - - GeodeDebug(("GX1PreInit!\n")); - /* Allocate driver private structure */ - if (!(pGeode = GX1GetRec(pScreenInfo))) - return FALSE; - - /* This is the general case */ - for (i = 0; i < pScreenInfo->numEntities; i++) { - pGeode->pEnt = xf86GetEntityInfo(pScreenInfo->entityList[i]); - #ifndef XSERVER_LIBPCIACCESS - if (pGeode->pEnt->resources) - return FALSE; - #endif - pGeode->Chipset = pGeode->pEnt->chipset; - pScreenInfo->chipset = (char *)xf86TokenToString(GeodeChipsets, - pGeode->pEnt->chipset); - } - - if (flags & PROBE_DETECT) { - GX1ProbeDDC(pScreenInfo, pGeode->pEnt->index); - return TRUE; - } - - pGeode->FBVGAActive = 0; /* KFB will Knock of VGA */ + GAL_ADAPTERINFO sAdapterInfo; +#endif /* STB_X */ + unsigned int PitchInc = 0, minPitch = 0, maxPitch = 0; + unsigned int minHeight = 0, maxHeight = 0; + const char *s; + char **modes; + char **tvmodes_defa; + + GeodeDebug(("GX1PreInit!\n")); + /* Allocate driver private structure */ + if (!(pGeode = GX1GetRec(pScreenInfo))) + return FALSE; + + /* This is the general case */ + for (i = 0; i < pScreenInfo->numEntities; i++) { + pGeode->pEnt = xf86GetEntityInfo(pScreenInfo->entityList[i]); +#ifndef XSERVER_LIBPCIACCESS + if (pGeode->pEnt->resources) + return FALSE; +#endif + pGeode->Chipset = pGeode->pEnt->chipset; + pScreenInfo->chipset = (char *) xf86TokenToString(GeodeChipsets, + pGeode->pEnt-> + chipset); + } + + if (flags & PROBE_DETECT) { + GX1ProbeDDC(pScreenInfo, pGeode->pEnt->index); + return TRUE; + } + + pGeode->FBVGAActive = 0; /* KFB will Knock of VGA */ #if !defined(STB_X) - /* If the vgahw module would be needed it would be loaded here */ - if (!xf86LoadSubModule(pScreenInfo, "vgahw")) { - return FALSE; - } + /* If the vgahw module would be needed it would be loaded here */ + if (!xf86LoadSubModule(pScreenInfo, "vgahw")) { + return FALSE; + } - xf86LoaderReqSymLists(nscVgahwSymbols, NULL); -#endif /* STB_X */ - GeodeDebug(("GX1PreInit(1)!\n")); + xf86LoaderReqSymLists(nscVgahwSymbols, NULL); +#endif /* STB_X */ + GeodeDebug(("GX1PreInit(1)!\n")); - /* Do the durango hardware detection */ + /* Do the durango hardware detection */ #if defined(STB_X) - if (!Gal_initialize_interface()) - return FALSE; - if (Gal_get_adapter_info(&sAdapterInfo)) { - pGeode->cpu_version = sAdapterInfo.dwCPUVersion; - pGeode->vid_version = sAdapterInfo.dwVideoVersion; - pGeode->FBSize = sAdapterInfo.dwFrameBufferSize; - /* update the max clock from the one system suports */ - GeodeClockRange.maxClock = sAdapterInfo.dwMaxSupportedPixelClock; - pGeode->FBLinearAddr = sAdapterInfo.dwFrameBufferBase; - - if (!GX1MapMem(pScreenInfo)) - return FALSE; - - } else { - return FALSE; - } + if (!Gal_initialize_interface()) + return FALSE; + if (Gal_get_adapter_info(&sAdapterInfo)) { + pGeode->cpu_version = sAdapterInfo.dwCPUVersion; + pGeode->vid_version = sAdapterInfo.dwVideoVersion; + pGeode->FBSize = sAdapterInfo.dwFrameBufferSize; + /* update the max clock from the one system suports */ + GeodeClockRange.maxClock = sAdapterInfo.dwMaxSupportedPixelClock; + pGeode->FBLinearAddr = sAdapterInfo.dwFrameBufferBase; + + if (!GX1MapMem(pScreenInfo)) + return FALSE; + + } + else { + return FALSE; + } #else - pGeode->cpu_version = gfx_detect_cpu(); - pGeode->vid_version = gfx_detect_video(); - pGeode->FBLinearAddr = gfx_get_frame_buffer_base(); - /* update the max clock from the one system suports */ - GeodeClockRange.maxClock = gfx_get_max_supported_pixel_clock(); - - if (!GX1MapMem(pScreenInfo)) - return FALSE; - - DEBUGMSG(1, - (0, X_INFO, - "Geode chip info: cpu:%x vid:%x size:%x base:%x, rom:%X\n", - pGeode->cpu_version, pGeode->vid_version, pGeode->FBSize, - pGeode->FBBase, XpressROMPtr)); -#endif /* STB_X */ - - /* Fill in the monitor field */ - pScreenInfo->monitor = pScreenInfo->confScreen->monitor; - GeodeDebug(("GX1PreInit(2)!\n")); - /* Determine depth, bpp, etc. */ - if (!xf86SetDepthBpp(pScreenInfo, 16, 0, 0, 0)) { - return FALSE; - - } else { - - switch (pScreenInfo->depth) { - case 8: - case 16: - break; - default: - /* Depth not supported */ - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "Given depth (%d bpp) is not supported by this driver\n", - pScreenInfo->depth)); - return FALSE; - } - } - - /*This must happen after pScreenInfo->display has been set - * * because xf86SetWeight references it. - */ - if (pScreenInfo->depth > 8) { - /* The defaults are OK for us */ - rgb zeros = { 0, 0, 0 }; - - if (!xf86SetWeight(pScreenInfo, zeros, zeros)) { - return FALSE; - } else { - /* XXX Check if the returned weight is supported */ - } - } - xf86PrintDepthBpp(pScreenInfo); - GeodeDebug(("GX1PreInit(3)!\n")); - if (!xf86SetDefaultVisual(pScreenInfo, -1)) - return FALSE; - GeodeDebug(("GX1PreInit(4)!\n")); - - /* The new cmap layer needs this to be initialized */ - if (pScreenInfo->depth > 1) { - Gamma zeros = { 0.0, 0.0, 0.0 }; - - if (!xf86SetGamma(pScreenInfo, zeros)) { - return FALSE; - } - } - GeodeDebug(("GX1PreInit(5)!\n")); - /* We use a programmable clock */ - pScreenInfo->progClock = TRUE; - - /*Collect all of the relevant option flags - * *(fill in pScreenInfo->options) - */ - xf86CollectOptions(pScreenInfo, NULL); - - /*Process the options */ - xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, - GeodeOptions); - - /*Set the bits per RGB for 8bpp mode */ - if (pScreenInfo->depth == 8) { - /* Default to 8 */ - pScreenInfo->rgbBits = 8; - } - from = X_DEFAULT; - pGeode->HWCursor = TRUE; - /* - * *The preferred method is to use the "hw cursor" option as a tri-state - * *option, with the default set above. - */ - if (xf86GetOptValBool(GeodeOptions, OPTION_HW_CURSOR, &pGeode->HWCursor)) { - from = X_CONFIG; - } - /* For compatibility, accept this too (as an override) */ - if (xf86ReturnOptValBool(GeodeOptions, OPTION_SW_CURSOR, FALSE)) { - from = X_CONFIG; - pGeode->HWCursor = FALSE; - } - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, "Using %s cursor\n", - pGeode->HWCursor ? "HW" : "SW")); - - pGeode->Compression = TRUE; - if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOCOMPRESSION, FALSE)) { - pGeode->Compression = FALSE; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "NoCompression\n")); - } - - pGeode->NoAccel = FALSE; - if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOACCEL, FALSE)) { - pGeode->NoAccel = TRUE; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Acceleration \ + pGeode->cpu_version = gfx_detect_cpu(); + pGeode->vid_version = gfx_detect_video(); + pGeode->FBLinearAddr = gfx_get_frame_buffer_base(); + /* update the max clock from the one system suports */ + GeodeClockRange.maxClock = gfx_get_max_supported_pixel_clock(); + + if (!GX1MapMem(pScreenInfo)) + return FALSE; + + DEBUGMSG(1, + (0, X_INFO, + "Geode chip info: cpu:%x vid:%x size:%x base:%x, rom:%X\n", + pGeode->cpu_version, pGeode->vid_version, pGeode->FBSize, + pGeode->FBBase, XpressROMPtr)); +#endif /* STB_X */ + + /* Fill in the monitor field */ + pScreenInfo->monitor = pScreenInfo->confScreen->monitor; + GeodeDebug(("GX1PreInit(2)!\n")); + /* Determine depth, bpp, etc. */ + if (!xf86SetDepthBpp(pScreenInfo, 16, 0, 0, 0)) { + return FALSE; + + } + else { + + switch (pScreenInfo->depth) { + case 8: + case 16: + break; + default: + /* Depth not supported */ + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "Given depth (%d bpp) is not supported by this driver\n", + pScreenInfo->depth)); + return FALSE; + } + } + + /*This must happen after pScreenInfo->display has been set + * * because xf86SetWeight references it. + */ + if (pScreenInfo->depth > 8) { + /* The defaults are OK for us */ + rgb zeros = { 0, 0, 0 }; + + if (!xf86SetWeight(pScreenInfo, zeros, zeros)) { + return FALSE; + } + else { + /* XXX Check if the returned weight is supported */ + } + } + xf86PrintDepthBpp(pScreenInfo); + GeodeDebug(("GX1PreInit(3)!\n")); + if (!xf86SetDefaultVisual(pScreenInfo, -1)) + return FALSE; + GeodeDebug(("GX1PreInit(4)!\n")); + + /* The new cmap layer needs this to be initialized */ + if (pScreenInfo->depth > 1) { + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScreenInfo, zeros)) { + return FALSE; + } + } + GeodeDebug(("GX1PreInit(5)!\n")); + /* We use a programmable clock */ + pScreenInfo->progClock = TRUE; + + /*Collect all of the relevant option flags + * *(fill in pScreenInfo->options) + */ + xf86CollectOptions(pScreenInfo, NULL); + + /*Process the options */ + xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, + GeodeOptions); + + /*Set the bits per RGB for 8bpp mode */ + if (pScreenInfo->depth == 8) { + /* Default to 8 */ + pScreenInfo->rgbBits = 8; + } + from = X_DEFAULT; + pGeode->HWCursor = TRUE; + /* + * *The preferred method is to use the "hw cursor" option as a tri-state + * *option, with the default set above. + */ + if (xf86GetOptValBool(GeodeOptions, OPTION_HW_CURSOR, &pGeode->HWCursor)) { + from = X_CONFIG; + } + /* For compatibility, accept this too (as an override) */ + if (xf86ReturnOptValBool(GeodeOptions, OPTION_SW_CURSOR, FALSE)) { + from = X_CONFIG; + pGeode->HWCursor = FALSE; + } + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, "Using %s cursor\n", + pGeode->HWCursor ? "HW" : "SW")); + + pGeode->Compression = TRUE; + if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOCOMPRESSION, FALSE)) { + pGeode->Compression = FALSE; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "NoCompression\n")); + } + + pGeode->NoAccel = FALSE; + if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOACCEL, FALSE)) { + pGeode->NoAccel = TRUE; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Acceleration \ disabled\n")); - } - - if (!xf86GetOptValInteger(GeodeOptions, OPTION_OSM_IMG_BUFS, - &(pGeode->NoOfImgBuffers))) - pGeode->NoOfImgBuffers = DEFAULT_NUM_OF_BUF; /* default # of buffers */ - if (pGeode->NoOfImgBuffers <= 0) - pGeode->NoOfImgBuffers = 0; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "No of Buffers %d\n", - pGeode->NoOfImgBuffers)); - - pGeode->TVSupport = FALSE; - - pGeode->FBTVActive = 0; - GFX(get_tv_enable(&(pGeode->FBTVActive))); - DEBUGMSG(1, (1, X_PROBED, "FB TV %d \n", pGeode->FBTVActive)); - - if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_SUPPORT))) { - - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "TV = %s\n", s)); - if (!xf86NameCmp(s, "PAL-768x576")) { - pGeode->TvParam.wStandard = TV_STANDARD_PAL; - pGeode->TvParam.wType = GFX_ON_TV_SQUARE_PIXELS; - pGeode->TvParam.wWidth = 768; - pGeode->TvParam.wHeight = 576; - pGeode->TVSupport = TRUE; - } else if (!xf86NameCmp(s, "PAL-720x576")) { - pGeode->TvParam.wStandard = TV_STANDARD_PAL; - pGeode->TvParam.wType = GFX_ON_TV_NO_SCALING; - pGeode->TvParam.wWidth = 720; - pGeode->TvParam.wHeight = 576; - pGeode->TVSupport = TRUE; - } else if (!xf86NameCmp(s, "NTSC-640x480")) { - pGeode->TvParam.wStandard = TV_STANDARD_NTSC; - pGeode->TvParam.wType = GFX_ON_TV_SQUARE_PIXELS; - pGeode->TvParam.wWidth = 640; - pGeode->TvParam.wHeight = 480; - pGeode->TVSupport = TRUE; - } else if (!xf86NameCmp(s, "NTSC-720x480")) { - pGeode->TvParam.wStandard = TV_STANDARD_NTSC; - pGeode->TvParam.wType = GFX_ON_TV_NO_SCALING; - pGeode->TvParam.wWidth = 720; - pGeode->TvParam.wHeight = 480; - pGeode->TVSupport = TRUE; - } - - if (pGeode->TVSupport == TRUE) { - pGeode->TvParam.wOutput = TV_OUTPUT_S_VIDEO; /* default */ - - /* Now find the output */ - if (pGeode->TVSupport) { - if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_OUTPUT))) { - if (!xf86NameCmp(s, "COMPOSITE")) { - pGeode->TvParam.wOutput = TV_OUTPUT_COMPOSITE; - } else if (!xf86NameCmp(s, "SVIDEO")) { - pGeode->TvParam.wOutput = TV_OUTPUT_S_VIDEO; - } else if (!xf86NameCmp(s, "YUV")) { - pGeode->TvParam.wOutput = TV_OUTPUT_YUV; - } else if (!xf86NameCmp(s, "SCART")) { - pGeode->TvParam.wOutput = TV_OUTPUT_SCART; - } - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "TVOutput = %s %d\n", s, - pGeode->TvParam.wOutput)); - } - } - } + } + + if (!xf86GetOptValInteger(GeodeOptions, OPTION_OSM_IMG_BUFS, + &(pGeode->NoOfImgBuffers))) + pGeode->NoOfImgBuffers = DEFAULT_NUM_OF_BUF; /* default # of buffers */ + if (pGeode->NoOfImgBuffers <= 0) + pGeode->NoOfImgBuffers = 0; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "No of Buffers %d\n", + pGeode->NoOfImgBuffers)); + + pGeode->TVSupport = FALSE; + + pGeode->FBTVActive = 0; + GFX(get_tv_enable(&(pGeode->FBTVActive))); + DEBUGMSG(1, (1, X_PROBED, "FB TV %d \n", pGeode->FBTVActive)); + + if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_SUPPORT))) { + + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "TV = %s\n", s)); + if (!xf86NameCmp(s, "PAL-768x576")) { + pGeode->TvParam.wStandard = TV_STANDARD_PAL; + pGeode->TvParam.wType = GFX_ON_TV_SQUARE_PIXELS; + pGeode->TvParam.wWidth = 768; + pGeode->TvParam.wHeight = 576; + pGeode->TVSupport = TRUE; + } + else if (!xf86NameCmp(s, "PAL-720x576")) { + pGeode->TvParam.wStandard = TV_STANDARD_PAL; + pGeode->TvParam.wType = GFX_ON_TV_NO_SCALING; + pGeode->TvParam.wWidth = 720; + pGeode->TvParam.wHeight = 576; + pGeode->TVSupport = TRUE; + } + else if (!xf86NameCmp(s, "NTSC-640x480")) { + pGeode->TvParam.wStandard = TV_STANDARD_NTSC; + pGeode->TvParam.wType = GFX_ON_TV_SQUARE_PIXELS; + pGeode->TvParam.wWidth = 640; + pGeode->TvParam.wHeight = 480; + pGeode->TVSupport = TRUE; + } + else if (!xf86NameCmp(s, "NTSC-720x480")) { + pGeode->TvParam.wStandard = TV_STANDARD_NTSC; + pGeode->TvParam.wType = GFX_ON_TV_NO_SCALING; + pGeode->TvParam.wWidth = 720; + pGeode->TvParam.wHeight = 480; + pGeode->TVSupport = TRUE; + } + + if (pGeode->TVSupport == TRUE) { + pGeode->TvParam.wOutput = TV_OUTPUT_S_VIDEO; /* default */ + + /* Now find the output */ + if (pGeode->TVSupport) { + if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_OUTPUT))) { + if (!xf86NameCmp(s, "COMPOSITE")) { + pGeode->TvParam.wOutput = TV_OUTPUT_COMPOSITE; + } + else if (!xf86NameCmp(s, "SVIDEO")) { + pGeode->TvParam.wOutput = TV_OUTPUT_S_VIDEO; + } + else if (!xf86NameCmp(s, "YUV")) { + pGeode->TvParam.wOutput = TV_OUTPUT_YUV; + } + else if (!xf86NameCmp(s, "SCART")) { + pGeode->TvParam.wOutput = TV_OUTPUT_SCART; + } + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "TVOutput = %s %d\n", s, + pGeode->TvParam.wOutput)); + } + } + } /* Only SC1200 can support TV modes */ - if ((pGeode->vid_version != GFX_VID_SC1200) - && (pGeode->TVSupport == TRUE)) { - pGeode->TVSupport = FALSE; - } - - /*TV can be turned on only in 16BPP mode */ - if ((pScreenInfo->depth == 8) && (pGeode->TVSupport == TRUE)) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Warning TV Disabled, TV Can't be supported in 8Bpp !!!\n")); - pGeode->TVSupport = FALSE; - } - } - - /* If TV Supported then check for TVO support */ - if (pGeode->TVSupport == TRUE) { - pGeode->TVOx = 0; - pGeode->TVOy = 0; - pGeode->TVOw = 0; - pGeode->TVOh = 0; - pGeode->TV_Overscan_On = FALSE; - if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_OVERSCAN))) { - get_tv_overscan_geom(s, &(pGeode->TVOx), - &(pGeode->TVOy), &(pGeode->TVOw), - &(pGeode->TVOh)); - - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "TVO %d %d %d %d\n", pGeode->TVOx, pGeode->TVOy, - pGeode->TVOw, pGeode->TVOh)); - - if ((pGeode->TVOx >= 0 && pGeode->TVOy >= 0) && - (pGeode->TVOh > 0 && pGeode->TVOw > 0)) { - if (((pGeode->TVOx + pGeode->TVOw) <= pGeode->TvParam.wWidth) && - ((pGeode->TVOy + pGeode->TVOh) <= pGeode->TvParam.wHeight)) { - pGeode->TV_Overscan_On = TRUE; - } - } - } - } - - /* If TV is not selected and currently TV is enabled, disable the TV out */ - if (pGeode->TVSupport == FALSE) { - unsigned int status = 0; - - GFX(get_tv_enable(&status)); - if (status) - GFX(set_tv_enable(0)); - } - - pGeode->Panel = FALSE; - if (xf86ReturnOptValBool(GeodeOptions, OPTION_FLATPANEL, FALSE)) { - DEBUGMSG(0, (pScreenInfo->scrnIndex, X_CONFIG, "FlatPanel Selected\n")); - pGeode->Panel = TRUE; - } - - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Quering FP Bios %d\n", pGeode->Panel)); - - /* if FP not supported in BIOS, then turn off user option */ - if (pGeode->Panel) { - int ret; - - /* check if bios supports FP */ + if ((pGeode->vid_version != GFX_VID_SC1200) + && (pGeode->TVSupport == TRUE)) { + pGeode->TVSupport = FALSE; + } + + /*TV can be turned on only in 16BPP mode */ + if ((pScreenInfo->depth == 8) && (pGeode->TVSupport == TRUE)) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Warning TV Disabled, TV Can't be supported in 8Bpp !!!\n")); + pGeode->TVSupport = FALSE; + } + } + + /* If TV Supported then check for TVO support */ + if (pGeode->TVSupport == TRUE) { + pGeode->TVOx = 0; + pGeode->TVOy = 0; + pGeode->TVOw = 0; + pGeode->TVOh = 0; + pGeode->TV_Overscan_On = FALSE; + if ((s = xf86GetOptValString(GeodeOptions, OPTION_TV_OVERSCAN))) { + get_tv_overscan_geom(s, &(pGeode->TVOx), + &(pGeode->TVOy), &(pGeode->TVOw), + &(pGeode->TVOh)); + + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "TVO %d %d %d %d\n", pGeode->TVOx, pGeode->TVOy, + pGeode->TVOw, pGeode->TVOh)); + + if ((pGeode->TVOx >= 0 && pGeode->TVOy >= 0) && + (pGeode->TVOh > 0 && pGeode->TVOw > 0)) { + if (((pGeode->TVOx + pGeode->TVOw) <= pGeode->TvParam.wWidth) && + ((pGeode->TVOy + pGeode->TVOh) <= + pGeode->TvParam.wHeight)) { + pGeode->TV_Overscan_On = TRUE; + } + } + } + } + + /* If TV is not selected and currently TV is enabled, disable the TV out */ + if (pGeode->TVSupport == FALSE) { + unsigned int status = 0; + + GFX(get_tv_enable(&status)); + if (status) + GFX(set_tv_enable(0)); + } + + pGeode->Panel = FALSE; + if (xf86ReturnOptValBool(GeodeOptions, OPTION_FLATPANEL, FALSE)) { + DEBUGMSG(0, (pScreenInfo->scrnIndex, X_CONFIG, "FlatPanel Selected\n")); + pGeode->Panel = TRUE; + } + + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Quering FP Bios %d\n", pGeode->Panel)); + + /* if FP not supported in BIOS, then turn off user option */ + if (pGeode->Panel) { + int ret; + + /* check if bios supports FP */ #if defined(STB_X) - Gal_get_softvga_state(&ret); - if (!ret) { - /* its time to wakeup softvga */ - Gal_set_softvga_state(TRUE); - Gal_vga_mode_switch(0); - } - Gal_pnl_enabled_in_bios(&pGeode->Panel); - - if (pGeode->Panel) { - Gal_pnl_info_from_bios(&pGeode->FPBX, &pGeode->FPBY, - &pGeode->FPBB, &pGeode->FPBF); - } - if (!ret) { - /* its time to put softvga back to sleep */ - Gal_set_softvga_state(FALSE); - Gal_vga_mode_switch(1); - } + Gal_get_softvga_state(&ret); + if (!ret) { + /* its time to wakeup softvga */ + Gal_set_softvga_state(TRUE); + Gal_vga_mode_switch(0); + } + Gal_pnl_enabled_in_bios(&pGeode->Panel); + + if (pGeode->Panel) { + Gal_pnl_info_from_bios(&pGeode->FPBX, &pGeode->FPBY, + &pGeode->FPBB, &pGeode->FPBF); + } + if (!ret) { + /* its time to put softvga back to sleep */ + Gal_set_softvga_state(FALSE); + Gal_vga_mode_switch(1); + } #else - ret = gfx_get_softvga_active(); - if (!ret) { - /* its time to wakeup softvga */ - gfx_enable_softvga(); - gfx_vga_mode_switch(0); - } - pGeode->Panel = Pnl_IsPanelEnabledInBIOS(); - if (pGeode->Panel) { - Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY, - &pGeode->FPBB, &pGeode->FPBF); - } - if (!ret) { - /* its time to put softvga back to sleep */ - gfx_disable_softvga(); - gfx_vga_mode_switch(1); - } + ret = gfx_get_softvga_active(); + if (!ret) { + /* its time to wakeup softvga */ + gfx_enable_softvga(); + gfx_vga_mode_switch(0); + } + pGeode->Panel = Pnl_IsPanelEnabledInBIOS(); + if (pGeode->Panel) { + Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY, + &pGeode->FPBB, &pGeode->FPBF); + } + if (!ret) { + /* its time to put softvga back to sleep */ + gfx_disable_softvga(); + gfx_vga_mode_switch(1); + } #endif - } - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Quering FP Bios %d %d %d %d\n", - pGeode->FPBX, pGeode->FPBY, pGeode->FPBB, pGeode->FPBF)); - - /* if panel not selected and Panel can be supported. - * Power down the panel. - */ - if (!pGeode->Panel) { + } + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Quering FP Bios %d %d %d %d\n", + pGeode->FPBX, pGeode->FPBY, pGeode->FPBB, pGeode->FPBF)); + + /* if panel not selected and Panel can be supported. + * Power down the panel. + */ + if (!pGeode->Panel) { #if defined(STB_X) - Gal_pnl_powerdown(); + Gal_pnl_powerdown(); #else - Pnl_PowerDown(); -#endif /* STB_X */ - } else { + Pnl_PowerDown(); +#endif /* STB_X */ + } + else { #if defined(STB_X) - Gal_pnl_powerup(); + Gal_pnl_powerup(); #else - Pnl_PowerUp(); -#endif /* STB_X */ - } - - pGeode->ShadowFB = FALSE; - if (xf86ReturnOptValBool(GeodeOptions, OPTION_SHADOW_FB, FALSE)) { - pGeode->ShadowFB = TRUE; - pGeode->NoAccel = TRUE; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Using \"Shadow Framebuffer\" - acceleration disabled\n")); - } - - pGeode->Rotate = 0; - if ((s = xf86GetOptValString(GeodeOptions, OPTION_ROTATE))) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Rotating - %s\n", s)); - if (!xf86NameCmp(s, "CW")) { - pGeode->ShadowFB = TRUE; - pGeode->NoAccel = TRUE; - pGeode->HWCursor = FALSE; - pGeode->Rotate = 1; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Rotating screen clockwise - acceleration disabled\n")); - } else { - if (!xf86NameCmp(s, "CCW")) { - pGeode->ShadowFB = TRUE; - pGeode->NoAccel = TRUE; - pGeode->HWCursor = FALSE; - pGeode->Rotate = -1; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Rotating screen counter clockwise - acceleration \ + Pnl_PowerUp(); +#endif /* STB_X */ + } + + pGeode->ShadowFB = FALSE; + if (xf86ReturnOptValBool(GeodeOptions, OPTION_SHADOW_FB, FALSE)) { + pGeode->ShadowFB = TRUE; + pGeode->NoAccel = TRUE; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Using \"Shadow Framebuffer\" - acceleration disabled\n")); + } + + pGeode->Rotate = 0; + if ((s = xf86GetOptValString(GeodeOptions, OPTION_ROTATE))) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Rotating - %s\n", s)); + if (!xf86NameCmp(s, "CW")) { + pGeode->ShadowFB = TRUE; + pGeode->NoAccel = TRUE; + pGeode->HWCursor = FALSE; + pGeode->Rotate = 1; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Rotating screen clockwise - acceleration disabled\n")); + } + else { + if (!xf86NameCmp(s, "CCW")) { + pGeode->ShadowFB = TRUE; + pGeode->NoAccel = TRUE; + pGeode->HWCursor = FALSE; + pGeode->Rotate = -1; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Rotating screen counter clockwise - acceleration \ disabled\n")); - } else { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "\"%s\" is not a valid value for Option \"Rotate\"\n", - s)); - DEBUGMSG(1, - (pScreenInfo->scrnIndex, X_INFO, - "Valid options are \"CW\" or \"CCW\"\n")); - } - } - } - - /* Disable Rotation when TV Over Scan is enabled */ - if (pGeode->TV_Overscan_On) - pGeode->Rotate = 0; - - /* XXX Init further private data here */ - - /* - * * This shouldn't happen because such problems should be caught in - * * GeodeProbe(), but check it just in case. - */ - if (pScreenInfo->chipset == NULL) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "ChipID 0x%04X is not recognised\n", pGeode->Chipset)); - return FALSE; - } - if (pGeode->Chipset < 0) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "Chipset \"%s\" is not recognised\n", - pScreenInfo->chipset)); - return FALSE; - } - GeodeDebug(("GX1PreInit(6)!\n")); - - /* - * * Init the screen with some values - */ + } + else { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "\"%s\" is not a valid value for Option \"Rotate\"\n", + s)); + DEBUGMSG(1, + (pScreenInfo->scrnIndex, X_INFO, + "Valid options are \"CW\" or \"CCW\"\n")); + } + } + } + + /* Disable Rotation when TV Over Scan is enabled */ + if (pGeode->TV_Overscan_On) + pGeode->Rotate = 0; + + /* XXX Init further private data here */ + + /* + * * This shouldn't happen because such problems should be caught in + * * GeodeProbe(), but check it just in case. + */ + if (pScreenInfo->chipset == NULL) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "ChipID 0x%04X is not recognised\n", pGeode->Chipset)); + return FALSE; + } + if (pGeode->Chipset < 0) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "Chipset \"%s\" is not recognised\n", + pScreenInfo->chipset)); + return FALSE; + } + GeodeDebug(("GX1PreInit(6)!\n")); + + /* + * * Init the screen with some values + */ #if !defined(STB_X) - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, - "Video I/O registers at 0x%08lX\n", - (unsigned long)VGAHW_GET_IOBASE())); -#endif /* STB_X */ + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, + "Video I/O registers at 0x%08lX\n", + (unsigned long) VGAHW_GET_IOBASE())); +#endif /* STB_X */ - if (pScreenInfo->memPhysBase == 0) { - from = X_PROBED; + if (pScreenInfo->memPhysBase == 0) { + from = X_PROBED; #if defined(STB_X) - pScreenInfo->memPhysBase = sAdapterInfo.dwFrameBufferBase; -#else /* STB_X */ - pScreenInfo->memPhysBase = gfx_get_frame_buffer_base(); -#endif /* STB_X */ - } - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, - "Linear framebuffer at 0x%08lX\n", - (unsigned long)pScreenInfo->memPhysBase)); - - if (pGeode->pEnt->device->videoRam == 0) { - from = X_PROBED; - pScreenInfo->videoRam = pGeode->FBSize / 1024; - } else { - pScreenInfo->videoRam = pGeode->pEnt->device->videoRam; - from = X_CONFIG; - } - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, - "VideoRam: %d kByte\n", - (unsigned long)pScreenInfo->videoRam)); - - GeodeDebug(("GX1PreInit(7)!\n")); - - /* - * * xf86ValidateModes will check that the mode HTotal and VTotal values - * * don't exceed the chipset's limit if pScreenInfo->maxHValue adn - * * pScreenInfo->maxVValue are set. Since our GX1ValidMode() - * * already takes care of this, we don't worry about setting them here. - */ - /* Select valid modes from those available */ - /* - * * min pitch 1024, max 2048 (Pixel count) - * * min height 480, max 1024 (Pixel count) - */ - minPitch = 1024; - maxPitch = 2048; - minHeight = 480; - maxHeight = 1024; /* Can support upto 1280x1024 16Bpp */ - if (pScreenInfo->depth == 16) { - PitchInc = 2048; - } else { - PitchInc = 1024; - } - PitchInc <<= 3; /* in bits */ - - /* by default use what user sets in the XF86Config file */ - modes = pScreenInfo->display->modes; - if (pGeode->TVSupport == TRUE) { - char str[20]; - - sprintf(str, "%dx%d-%d", - pGeode->TvParam.wWidth, - pGeode->TvParam.wHeight, - ((pGeode->TvParam.wStandard == TV_STANDARD_PAL) ? 50 : 60)); - - tvmodes_defa = (char **)malloc(sizeof(char *) * 2); - tvmodes_defa[0] = (char *)malloc(strlen(str)); - tvmodes_defa[1] = NULL; - strcpy(str, tvmodes_defa[0]); - - modes = tvmodes_defa; - } - - i = xf86ValidateModes(pScreenInfo, - pScreenInfo->monitor->Modes, - modes, - &GeodeClockRange, - NULL, minPitch, maxPitch, - PitchInc, minHeight, maxHeight, - pScreenInfo->display->virtualX, - pScreenInfo->display->virtualY, + pScreenInfo->memPhysBase = sAdapterInfo.dwFrameBufferBase; +#else /* STB_X */ + pScreenInfo->memPhysBase = gfx_get_frame_buffer_base(); +#endif /* STB_X */ + } + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, + "Linear framebuffer at 0x%08lX\n", + (unsigned long) pScreenInfo->memPhysBase)); + + if (pGeode->pEnt->device->videoRam == 0) { + from = X_PROBED; + pScreenInfo->videoRam = pGeode->FBSize / 1024; + } + else { + pScreenInfo->videoRam = pGeode->pEnt->device->videoRam; + from = X_CONFIG; + } + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, + "VideoRam: %d kByte\n", + (unsigned long) pScreenInfo->videoRam)); + + GeodeDebug(("GX1PreInit(7)!\n")); + + /* + * * xf86ValidateModes will check that the mode HTotal and VTotal values + * * don't exceed the chipset's limit if pScreenInfo->maxHValue adn + * * pScreenInfo->maxVValue are set. Since our GX1ValidMode() + * * already takes care of this, we don't worry about setting them here. + */ + /* Select valid modes from those available */ + /* + * * min pitch 1024, max 2048 (Pixel count) + * * min height 480, max 1024 (Pixel count) + */ + minPitch = 1024; + maxPitch = 2048; + minHeight = 480; + maxHeight = 1024; /* Can support upto 1280x1024 16Bpp */ + if (pScreenInfo->depth == 16) { + PitchInc = 2048; + } + else { + PitchInc = 1024; + } + PitchInc <<= 3; /* in bits */ + + /* by default use what user sets in the XF86Config file */ + modes = pScreenInfo->display->modes; + if (pGeode->TVSupport == TRUE) { + char str[20]; + + sprintf(str, "%dx%d-%d", + pGeode->TvParam.wWidth, + pGeode->TvParam.wHeight, + ((pGeode->TvParam.wStandard == TV_STANDARD_PAL) ? 50 : 60)); + + tvmodes_defa = (char **) malloc(sizeof(char *) * 2); + tvmodes_defa[0] = (char *) malloc(strlen(str)); + tvmodes_defa[1] = NULL; + strcpy(str, tvmodes_defa[0]); + + modes = tvmodes_defa; + } + + i = xf86ValidateModes(pScreenInfo, + pScreenInfo->monitor->Modes, + modes, + &GeodeClockRange, + NULL, minPitch, maxPitch, + PitchInc, minHeight, maxHeight, + pScreenInfo->display->virtualX, + pScreenInfo->display->virtualY, #if defined(STB_X) - sAdapterInfo.dwFrameBufferSize, + sAdapterInfo.dwFrameBufferSize, #else - pGeode->FBSize, -#endif /* STB_X */ - LOOKUP_BEST_REFRESH); - - DEBUGMSG(0, (pScreenInfo->scrnIndex, from, - "xf86ValidateModes: %d %d %d\n", - pScreenInfo->virtualX, - pScreenInfo->virtualY, pScreenInfo->displayWidth)); - if (i == -1) { - GX1FreeRec(pScreenInfo); - return FALSE; - } - GeodeDebug(("GX1PreInit(8)!\n")); - /* Prune the modes marked as invalid */ - xf86PruneDriverModes(pScreenInfo); - GeodeDebug(("GX1PreInit(9)!\n")); - if (i == 0 || pScreenInfo->modes == NULL) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "No valid modes found\n")); - GX1FreeRec(pScreenInfo); - return FALSE; - } - GeodeDebug(("GX1PreInit(10)!\n")); - xf86SetCrtcForModes(pScreenInfo, 0); - GeodeDebug(("GX1PreInit(11)!\n")); - /* Set the current mode to the first in the list */ - pScreenInfo->currentMode = pScreenInfo->modes; - GeodeDebug(("GX1PreInit(12)!\n")); - /* Print the list of modes being used */ - xf86PrintModes(pScreenInfo); - GeodeDebug(("GX1PreInit(13)!\n")); - /* Set the display resolution */ - xf86SetDpi(pScreenInfo, 0, 0); - GeodeDebug(("GX1PreInit(14)!\n")); - - if (xf86LoadSubModule(pScreenInfo, "fb") == NULL) { - GX1FreeRec(pScreenInfo); - return FALSE; - } - - xf86LoaderReqSymLists(nscFbSymbols, NULL); - GeodeDebug(("GX1PreInit(15)!\n")); - if (pGeode->NoAccel == FALSE) { - if (!xf86LoadSubModule(pScreenInfo, "xaa")) { - GX1FreeRec(pScreenInfo); - return FALSE; - } - xf86LoaderReqSymLists(nscXaaSymbols, NULL); - } - GeodeDebug(("GX1PreInit(16)!\n")); - if (pGeode->HWCursor == TRUE) { - if (!xf86LoadSubModule(pScreenInfo, "ramdac")) { - GX1FreeRec(pScreenInfo); - return FALSE; - } - xf86LoaderReqSymLists(nscRamdacSymbols, NULL); - } - GeodeDebug(("GX1PreInit(17)!\n")); - /* Load shadowfb if needed */ - if (pGeode->ShadowFB) { - if (!xf86LoadSubModule(pScreenInfo, "shadowfb")) { - GX1FreeRec(pScreenInfo); - return FALSE; - } - xf86LoaderReqSymLists(nscShadowSymbols, NULL); - } - GeodeDebug(("GX2PreInit(18)!\n")); - #ifndef XSERVER_LIBPCIACCESS - if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "xf86RegisterResources() found resource conflicts\n")); - GX1FreeRec(pScreenInfo); - return FALSE; - } - #endif - GX1UnmapMem(pScreenInfo); - GeodeDebug(("GX1PreInit(19)!\n")); - GeodeDebug(("GX1PreInit(20)!\n")); - GeodeDebug(("GX1PreInit ... done successfully!\n")); - (void) from; - return TRUE; + pGeode->FBSize, +#endif /* STB_X */ + LOOKUP_BEST_REFRESH); + + DEBUGMSG(0, (pScreenInfo->scrnIndex, from, + "xf86ValidateModes: %d %d %d\n", + pScreenInfo->virtualX, + pScreenInfo->virtualY, pScreenInfo->displayWidth)); + if (i == -1) { + GX1FreeRec(pScreenInfo); + return FALSE; + } + GeodeDebug(("GX1PreInit(8)!\n")); + /* Prune the modes marked as invalid */ + xf86PruneDriverModes(pScreenInfo); + GeodeDebug(("GX1PreInit(9)!\n")); + if (i == 0 || pScreenInfo->modes == NULL) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "No valid modes found\n")); + GX1FreeRec(pScreenInfo); + return FALSE; + } + GeodeDebug(("GX1PreInit(10)!\n")); + xf86SetCrtcForModes(pScreenInfo, 0); + GeodeDebug(("GX1PreInit(11)!\n")); + /* Set the current mode to the first in the list */ + pScreenInfo->currentMode = pScreenInfo->modes; + GeodeDebug(("GX1PreInit(12)!\n")); + /* Print the list of modes being used */ + xf86PrintModes(pScreenInfo); + GeodeDebug(("GX1PreInit(13)!\n")); + /* Set the display resolution */ + xf86SetDpi(pScreenInfo, 0, 0); + GeodeDebug(("GX1PreInit(14)!\n")); + + if (xf86LoadSubModule(pScreenInfo, "fb") == NULL) { + GX1FreeRec(pScreenInfo); + return FALSE; + } + + xf86LoaderReqSymLists(nscFbSymbols, NULL); + GeodeDebug(("GX1PreInit(15)!\n")); + if (pGeode->NoAccel == FALSE) { + if (!xf86LoadSubModule(pScreenInfo, "xaa")) { + GX1FreeRec(pScreenInfo); + return FALSE; + } + xf86LoaderReqSymLists(nscXaaSymbols, NULL); + } + GeodeDebug(("GX1PreInit(16)!\n")); + if (pGeode->HWCursor == TRUE) { + if (!xf86LoadSubModule(pScreenInfo, "ramdac")) { + GX1FreeRec(pScreenInfo); + return FALSE; + } + xf86LoaderReqSymLists(nscRamdacSymbols, NULL); + } + GeodeDebug(("GX1PreInit(17)!\n")); + /* Load shadowfb if needed */ + if (pGeode->ShadowFB) { + if (!xf86LoadSubModule(pScreenInfo, "shadowfb")) { + GX1FreeRec(pScreenInfo); + return FALSE; + } + xf86LoaderReqSymLists(nscShadowSymbols, NULL); + } + GeodeDebug(("GX2PreInit(18)!\n")); +#ifndef XSERVER_LIBPCIACCESS + if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "xf86RegisterResources() found resource conflicts\n")); + GX1FreeRec(pScreenInfo); + return FALSE; + } +#endif + GX1UnmapMem(pScreenInfo); + GeodeDebug(("GX1PreInit(19)!\n")); + GeodeDebug(("GX1PreInit(20)!\n")); + GeodeDebug(("GX1PreInit ... done successfully!\n")); + (void) from; + return TRUE; } /*---------------------------------------------------------------------------- @@ -1070,22 +1084,22 @@ GX1PreInit(ScrnInfoPtr pScreenInfo, int flags) static void GX1RestoreEx(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) { - GeodePtr pGeode; + GeodePtr pGeode; - GeodeDebug(("GX1RestoreEx!\n")); - /* Get driver private structure */ - if (!(pGeode = GX1GetRec(pScreenInfo))) - return; - /* Restore the extended registers */ + GeodeDebug(("GX1RestoreEx!\n")); + /* Get driver private structure */ + if (!(pGeode = GX1GetRec(pScreenInfo))) + return; + /* Restore the extended registers */ #if defined(STB_X) - pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | - GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; - Gal_vga_restore(&(pGeode->FBgfxVgaRegs)); + pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | + GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; + Gal_vga_restore(&(pGeode->FBgfxVgaRegs)); #else - gfx_vga_restore(&(pGeode->FBgfxVgaRegs), - GFX_VGA_FLAG_MISC_OUTPUT | - GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); -#endif /* STB_X */ + gfx_vga_restore(&(pGeode->FBgfxVgaRegs), + GFX_VGA_FLAG_MISC_OUTPUT | + GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); +#endif /* STB_X */ } /*---------------------------------------------------------------------------- @@ -1105,27 +1119,27 @@ GX1RestoreEx(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) static int GX1CalculatePitchBytes(unsigned int width, unsigned int bpp) { - int lineDelta = width * (bpp >> 3); - - if (width < 640) { - /* low resolutions have both pixel and line doubling */ - DEBUGMSG(1, (0, X_PROBED, "lower resolution %d %d\n", - width, lineDelta)); - lineDelta <<= 1; - } - /* needed in Rotate mode when in accel is turned off */ - if (1) { /*!pGeode->NoAccel */ - if (lineDelta > 2048) - lineDelta = 4096; - else if (lineDelta > 1024) - lineDelta = 2048; - else - lineDelta = 1024; - } - - DEBUGMSG(1, (0, X_PROBED, "pitch %d %d\n", width, lineDelta)); - - return lineDelta; + int lineDelta = width * (bpp >> 3); + + if (width < 640) { + /* low resolutions have both pixel and line doubling */ + DEBUGMSG(1, (0, X_PROBED, "lower resolution %d %d\n", + width, lineDelta)); + lineDelta <<= 1; + } + /* needed in Rotate mode when in accel is turned off */ + if (1) { /*!pGeode->NoAccel */ + if (lineDelta > 2048) + lineDelta = 4096; + else if (lineDelta > 1024) + lineDelta = 2048; + else + lineDelta = 1024; + } + + DEBUGMSG(1, (0, X_PROBED, "pitch %d %d\n", width, lineDelta)); + + return lineDelta; } /*---------------------------------------------------------------------------- @@ -1145,36 +1159,36 @@ static int GX1GetRefreshRate(DisplayModePtr pMode) { #define THRESHOLD 2 - unsigned int i; - static int validRates[] = { 50, 56, 60, 70, 72, 75, 85 }; /* Hz */ - unsigned long dotClock; - int refreshRate; - int selectedRate; - - dotClock = pMode->SynthClock * 1000; - refreshRate = dotClock / pMode->CrtcHTotal / pMode->CrtcVTotal; - - if ((pMode->CrtcHTotal < 640) && (pMode->CrtcVTotal < 480)) - refreshRate >>= 2; /* double pixel and double scan */ - - DEBUGMSG(1, (0, X_PROBED, "dotclock %d %d\n", dotClock, refreshRate)); - - selectedRate = validRates[0]; - for (i = 0; i < (sizeof(validRates) / sizeof(validRates[0])); i++) { - if (validRates[i] < (refreshRate + THRESHOLD)) { - selectedRate = validRates[i]; - } - } - return selectedRate; + unsigned int i; + static int validRates[] = { 50, 56, 60, 70, 72, 75, 85 }; /* Hz */ + unsigned long dotClock; + int refreshRate; + int selectedRate; + + dotClock = pMode->SynthClock * 1000; + refreshRate = dotClock / pMode->CrtcHTotal / pMode->CrtcVTotal; + + if ((pMode->CrtcHTotal < 640) && (pMode->CrtcVTotal < 480)) + refreshRate >>= 2; /* double pixel and double scan */ + + DEBUGMSG(1, (0, X_PROBED, "dotclock %d %d\n", dotClock, refreshRate)); + + selectedRate = validRates[0]; + for (i = 0; i < (sizeof(validRates) / sizeof(validRates[0])); i++) { + if (validRates[i] < (refreshRate + THRESHOLD)) { + selectedRate = validRates[i]; + } + } + return selectedRate; } void gx1_clear_screen(int width, int height) { - /* clean up the frame buffer memory */ - GFX(set_solid_pattern(0)); - GFX(set_raster_operation(0xF0)); - GFX(pattern_fill(0, 0, width, height)); + /* clean up the frame buffer memory */ + GFX(set_solid_pattern(0)); + GFX(set_raster_operation(0xF0)); + GFX(pattern_fill(0, 0, width, height)); } /*---------------------------------------------------------------------------- @@ -1195,114 +1209,117 @@ gx1_clear_screen(int width, int height) static Bool GX1SetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) { - GeodePtr pGeode; - - /* unsigned int compOffset, compPitch, compSize; */ - GeodeDebug(("GX1SetMode!\n")); - pGeode = GEODEPTR(pScreenInfo); - /* Set the VT semaphore */ - pScreenInfo->vtSema = TRUE; - DEBUGMSG(1, (0, X_NONE, "Set mode")); - /* The timing will be adjusted later */ - GeodeDebug(("Set display mode: %dx%d-%d (%dHz)\n", - pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, GX1GetRefreshRate(pMode))); - GeodeDebug(("Before setting the mode\n")); - if ((pMode->CrtcHDisplay >= 640) && (pMode->CrtcVDisplay >= 480)) - - GFX(set_display_bpp(pScreenInfo->bitsPerPixel)); - - if (pGeode->TVSupport == TRUE) { - pGeode->TvParam.bState = 1; /* enable */ - /* wWidth and wHeight already set in init. */ + GeodePtr pGeode; + + /* unsigned int compOffset, compPitch, compSize; */ + GeodeDebug(("GX1SetMode!\n")); + pGeode = GEODEPTR(pScreenInfo); + /* Set the VT semaphore */ + pScreenInfo->vtSema = TRUE; + DEBUGMSG(1, (0, X_NONE, "Set mode")); + /* The timing will be adjusted later */ + GeodeDebug(("Set display mode: %dx%d-%d (%dHz)\n", + pMode->CrtcHDisplay, + pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, GX1GetRefreshRate(pMode))); + GeodeDebug(("Before setting the mode\n")); + if ((pMode->CrtcHDisplay >= 640) && (pMode->CrtcVDisplay >= 480)) + + GFX(set_display_bpp(pScreenInfo->bitsPerPixel)); + + if (pGeode->TVSupport == TRUE) { + pGeode->TvParam.bState = 1; /* enable */ + /* wWidth and wHeight already set in init. */ #if defined(STB_X) - Gal_tv_set_params(GAL_TVSTATE | GAL_TVOUTPUT | - GAL_TVFORMAT | GAL_TVRESOLUTION, &(pGeode->TvParam)); + Gal_tv_set_params(GAL_TVSTATE | GAL_TVOUTPUT | + GAL_TVFORMAT | GAL_TVRESOLUTION, &(pGeode->TvParam)); #else - /* sequence might be important */ - gfx_set_tv_display(pGeode->TvParam.wWidth, pGeode->TvParam.wHeight); - gfx_set_tv_format((TVStandardType)pGeode->TvParam.wStandard, - (GfxOnTVType)pGeode->TvParam.wType); - gfx_set_tv_output(pGeode->TvParam.wOutput); - gfx_set_tv_enable(pGeode->TvParam.bState); - -#endif /* STB_X */ - } else { /* TV not selected */ - - DEBUGMSG(0, (0, X_PROBED, "Setting Display for CRT or TFT\n")); - - if (pGeode->Panel) { - DEBUGMSG(0, (0, X_PROBED, "Setting Display for TFT\n")); - DEBUGMSG(1, (0, X_PROBED, "Restore Panel %d %d %d %d %d\n", - pGeode->FPBX, pGeode->FPBY, - pMode->CrtcHDisplay, - pMode->CrtcVDisplay, pScreenInfo->bitsPerPixel)); - - GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY, - pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel)); - } else { - /* display is crt */ - DEBUGMSG(0, (0, X_PROBED, "Setting Display for CRT\n")); - GFX(set_display_mode(pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, - GX1GetRefreshRate(pMode))); - - /* adjust the pitch */ - GFX(set_display_pitch(pGeode->Pitch)); - - } - /* enable crt */ - GFX(set_crt_enable(CRT_ENABLE)); - } - - GFX(set_display_offset(0L)); - GFX(wait_vertical_blank()); - - /* enable compression if option selected */ - if (pGeode->Compression) { - /* set the compression parameters,and it will be turned on later. */ + /* sequence might be important */ + gfx_set_tv_display(pGeode->TvParam.wWidth, pGeode->TvParam.wHeight); + gfx_set_tv_format((TVStandardType) pGeode->TvParam.wStandard, + (GfxOnTVType) pGeode->TvParam.wType); + gfx_set_tv_output(pGeode->TvParam.wOutput); + gfx_set_tv_enable(pGeode->TvParam.bState); + +#endif /* STB_X */ + } + else { /* TV not selected */ + + DEBUGMSG(0, (0, X_PROBED, "Setting Display for CRT or TFT\n")); + + if (pGeode->Panel) { + DEBUGMSG(0, (0, X_PROBED, "Setting Display for TFT\n")); + DEBUGMSG(1, (0, X_PROBED, "Restore Panel %d %d %d %d %d\n", + pGeode->FPBX, pGeode->FPBY, + pMode->CrtcHDisplay, + pMode->CrtcVDisplay, pScreenInfo->bitsPerPixel)); + + GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY, + pMode->CrtcHDisplay, + pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel)); + } + else { + /* display is crt */ + DEBUGMSG(0, (0, X_PROBED, "Setting Display for CRT\n")); + GFX(set_display_mode(pMode->CrtcHDisplay, + pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, + GX1GetRefreshRate(pMode))); + + /* adjust the pitch */ + GFX(set_display_pitch(pGeode->Pitch)); + + } + /* enable crt */ + GFX(set_crt_enable(CRT_ENABLE)); + } + + GFX(set_display_offset(0L)); + GFX(wait_vertical_blank()); + + /* enable compression if option selected */ + if (pGeode->Compression) { + /* set the compression parameters,and it will be turned on later. */ #if defined(STB_X) - Gal_set_compression_parameters(GAL_COMPRESSION_ALL, - pGeode->CBOffset, - pGeode->CBPitch, pGeode->CBSize); + Gal_set_compression_parameters(GAL_COMPRESSION_ALL, + pGeode->CBOffset, + pGeode->CBPitch, pGeode->CBSize); - /* set the compression buffer, all parameters already set */ - Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); + /* set the compression buffer, all parameters already set */ + Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); #else - gfx_set_compression_offset(pGeode->CBOffset); - gfx_set_compression_pitch(pGeode->CBPitch); - gfx_set_compression_size(pGeode->CBSize); - - /* set the compression buffer, all parameters already set */ - gfx_set_compression_enable(1); -#endif /* STB_X */ - - } - if (pGeode->HWCursor) { - /* Load blank cursor */ - GX1LoadCursorImage(pScreenInfo, NULL); - GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0)); - GFX(set_cursor_enable(1)); - } else { - GeodeDebug(("GX1RestoreEx ... ")); - GX1RestoreEx(pScreenInfo, pMode); - GeodeDebug(("done.\n")); - } - - GeodeDebug(("done.\n")); - /* Reenable the hardware cursor after the mode switch */ - if (pGeode->HWCursor == TRUE) { - GeodeDebug(("GX1ShowCursor ... ")); - GX1ShowCursor(pScreenInfo); - GeodeDebug(("done.\n")); - } - /* Restore the contents in the screen info */ - GeodeDebug(("After setting the mode\n")); - return TRUE; + gfx_set_compression_offset(pGeode->CBOffset); + gfx_set_compression_pitch(pGeode->CBPitch); + gfx_set_compression_size(pGeode->CBSize); + + /* set the compression buffer, all parameters already set */ + gfx_set_compression_enable(1); +#endif /* STB_X */ + + } + if (pGeode->HWCursor) { + /* Load blank cursor */ + GX1LoadCursorImage(pScreenInfo, NULL); + GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0)); + GFX(set_cursor_enable(1)); + } + else { + GeodeDebug(("GX1RestoreEx ... ")); + GX1RestoreEx(pScreenInfo, pMode); + GeodeDebug(("done.\n")); + } + + GeodeDebug(("done.\n")); + /* Reenable the hardware cursor after the mode switch */ + if (pGeode->HWCursor == TRUE) { + GeodeDebug(("GX1ShowCursor ... ")); + GX1ShowCursor(pScreenInfo); + GeodeDebug(("done.\n")); + } + /* Restore the contents in the screen info */ + GeodeDebug(("After setting the mode\n")); + return TRUE; } /*---------------------------------------------------------------------------- @@ -1325,143 +1342,143 @@ GX1SetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) static Bool GX1EnterGraphics(ScreenPtr pScreen, ScrnInfoPtr pScreenInfo) { - GeodePtr pGeode; + GeodePtr pGeode; #if !defined(STB_X) - vgaHWPtr hwp = VGAHWPTR(pScreenInfo); + vgaHWPtr hwp = VGAHWPTR(pScreenInfo); - vgaHWUnlock(hwp); + vgaHWUnlock(hwp); #endif - GeodeDebug(("GX1EnterGraphics!\n")); + GeodeDebug(("GX1EnterGraphics!\n")); - DEBUGMSG(1, (0, X_NONE, "EnterGraphics\n")); - /* Should we re-save the text mode on each VT enter? */ - pGeode = GX1GetRec(pScreenInfo); + DEBUGMSG(1, (0, X_NONE, "EnterGraphics\n")); + /* Should we re-save the text mode on each VT enter? */ + pGeode = GX1GetRec(pScreenInfo); #if 0 - print_gxm_gfx_reg(pGeode, 0x4C); - print_gxm_vga_reg(); + print_gxm_gfx_reg(pGeode, 0x4C); + print_gxm_vga_reg(); #endif - /* This routine saves the current VGA state in Durango VGA structure */ + /* This routine saves the current VGA state in Durango VGA structure */ #if defined(STB_X) - Gal_get_softvga_state(&pGeode->FBVGAActive); - pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | - GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; - Gal_vga_save(&(pGeode->FBgfxVgaRegs)); + Gal_get_softvga_state(&pGeode->FBVGAActive); + pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | + GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; + Gal_vga_save(&(pGeode->FBgfxVgaRegs)); #else - pGeode->FBVGAActive = gfx_get_softvga_active(); - gfx_vga_save(&(pGeode->FBgfxVgaRegs), - GFX_VGA_FLAG_MISC_OUTPUT | - GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); -#endif /* STB_X */ - DEBUGMSG(1, (0, X_PROBED, "VSA = %d\n", pGeode->FBVGAActive)); + pGeode->FBVGAActive = gfx_get_softvga_active(); + gfx_vga_save(&(pGeode->FBgfxVgaRegs), + GFX_VGA_FLAG_MISC_OUTPUT | + GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); +#endif /* STB_X */ + DEBUGMSG(1, (0, X_PROBED, "VSA = %d\n", pGeode->FBVGAActive)); #if !defined(STB_X) - vgaHWSave(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); + vgaHWSave(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); #endif #if defined(STB_X) - Gal_get_display_timing(&pGeode->FBgfxdisplaytiming); - Gal_tv_get_timings(0, &pGeode->FBgfxtvtiming); + Gal_get_display_timing(&pGeode->FBgfxdisplaytiming); + Gal_tv_get_timings(0, &pGeode->FBgfxtvtiming); - /* Save Display offset */ - Gal_get_display_offset(&(pGeode->FBDisplayOffset)); + /* Save Display offset */ + Gal_get_display_offset(&(pGeode->FBDisplayOffset)); - /* Save the current Compression state */ - Gal_get_compression_enable(&(pGeode->FBCompressionEnable)); - Gal_get_compression_parameters(GAL_COMPRESSION_ALL, - &(pGeode->FBCompressionOffset), - &(pGeode->FBCompressionPitch), - &(pGeode->FBCompressionSize)); + /* Save the current Compression state */ + Gal_get_compression_enable(&(pGeode->FBCompressionEnable)); + Gal_get_compression_parameters(GAL_COMPRESSION_ALL, + &(pGeode->FBCompressionOffset), + &(pGeode->FBCompressionPitch), + &(pGeode->FBCompressionSize)); - /* Save Cursor offset */ - { - unsigned short x, y, xhot, yhot; + /* Save Cursor offset */ + { + unsigned short x, y, xhot, yhot; - Gal_get_cursor_position(&(pGeode->FBCursorOffset), - &x, &y, &xhot, &yhot); - } - /* Save the Panel state */ - Gal_pnl_save(); + Gal_get_cursor_position(&(pGeode->FBCursorOffset), + &x, &y, &xhot, &yhot); + } + /* Save the Panel state */ + Gal_pnl_save(); - /* its time to put softvga to sleep */ - Gal_set_softvga_state(FALSE); - Gal_vga_mode_switch(1); + /* its time to put softvga to sleep */ + Gal_set_softvga_state(FALSE); + Gal_vga_mode_switch(1); #else - /* Save TV State */ - gfx_get_tv_enable(&(pGeode->FBTVEnabled)); - if (pGeode->FBTVEnabled) { - /* TV Format */ - pGeode->FBtvtiming.HorzTim = READ_VID32(SC1200_TVOUT_HORZ_TIM); - pGeode->FBtvtiming.HorzSync = READ_VID32(SC1200_TVOUT_HORZ_SYNC); - pGeode->FBtvtiming.VertSync = READ_VID32(SC1200_TVOUT_VERT_SYNC); - pGeode->FBtvtiming.LineEnd = READ_VID32(SC1200_TVOUT_LINE_END); - pGeode->FBtvtiming.VertDownscale = - READ_VID32(SC1200_TVOUT_VERT_DOWNSCALE); - pGeode->FBtvtiming.HorzScaling = READ_VID32(SC1200_TVOUT_HORZ_SCALING); - pGeode->FBtvtiming.TimCtrl1 = READ_VID32(SC1200_TVENC_TIM_CTRL_1); - pGeode->FBtvtiming.TimCtrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); - pGeode->FBtvtiming.Subfreq = READ_VID32(SC1200_TVENC_SUB_FREQ); - pGeode->FBtvtiming.DispPos = READ_VID32(SC1200_TVENC_DISP_POS); - pGeode->FBtvtiming.DispSize = READ_VID32(SC1200_TVENC_DISP_SIZE); - /* TV Output */ - pGeode->FBtvtiming.TimCtrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); - pGeode->FBtvtiming.Debug = READ_VID32(SC1200_TVOUT_DEBUG); - /* TV Enable */ - pGeode->FBtvtiming.DacCtrl = READ_VID32(SC1200_TVENC_DAC_CONTROL); - } - - /* Save CRT State */ - 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(); - - /* Save Display offset */ - pGeode->FBDisplayOffset = gfx_get_display_offset(); - - /* Save the current Compression state */ - pGeode->FBCompressionEnable = gfx_get_compression_enable(); - pGeode->FBCompressionOffset = gfx_get_compression_offset(); - pGeode->FBCompressionPitch = gfx_get_compression_pitch(); - pGeode->FBCompressionSize = gfx_get_compression_size(); - - /* Save Cursor offset */ - pGeode->FBCursorOffset = gfx_get_cursor_offset(); - - /* Save the Panel state */ - Pnl_SavePanelState(); - - /* its time to put softvga to sleep */ - gfx_disable_softvga(); - gfx_vga_mode_switch(1); - -#endif /* STB_X */ - - if (!GX1SetMode(pScreenInfo, pScreenInfo->currentMode)) { - return FALSE; - } + /* Save TV State */ + gfx_get_tv_enable(&(pGeode->FBTVEnabled)); + if (pGeode->FBTVEnabled) { + /* TV Format */ + pGeode->FBtvtiming.HorzTim = READ_VID32(SC1200_TVOUT_HORZ_TIM); + pGeode->FBtvtiming.HorzSync = READ_VID32(SC1200_TVOUT_HORZ_SYNC); + pGeode->FBtvtiming.VertSync = READ_VID32(SC1200_TVOUT_VERT_SYNC); + pGeode->FBtvtiming.LineEnd = READ_VID32(SC1200_TVOUT_LINE_END); + pGeode->FBtvtiming.VertDownscale = + READ_VID32(SC1200_TVOUT_VERT_DOWNSCALE); + pGeode->FBtvtiming.HorzScaling = READ_VID32(SC1200_TVOUT_HORZ_SCALING); + pGeode->FBtvtiming.TimCtrl1 = READ_VID32(SC1200_TVENC_TIM_CTRL_1); + pGeode->FBtvtiming.TimCtrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); + pGeode->FBtvtiming.Subfreq = READ_VID32(SC1200_TVENC_SUB_FREQ); + pGeode->FBtvtiming.DispPos = READ_VID32(SC1200_TVENC_DISP_POS); + pGeode->FBtvtiming.DispSize = READ_VID32(SC1200_TVENC_DISP_SIZE); + /* TV Output */ + pGeode->FBtvtiming.TimCtrl2 = READ_VID32(SC1200_TVENC_TIM_CTRL_2); + pGeode->FBtvtiming.Debug = READ_VID32(SC1200_TVOUT_DEBUG); + /* TV Enable */ + pGeode->FBtvtiming.DacCtrl = READ_VID32(SC1200_TVENC_DAC_CONTROL); + } + + /* Save CRT State */ + 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(); + + /* Save Display offset */ + pGeode->FBDisplayOffset = gfx_get_display_offset(); + + /* Save the current Compression state */ + pGeode->FBCompressionEnable = gfx_get_compression_enable(); + pGeode->FBCompressionOffset = gfx_get_compression_offset(); + pGeode->FBCompressionPitch = gfx_get_compression_pitch(); + pGeode->FBCompressionSize = gfx_get_compression_size(); + + /* Save Cursor offset */ + pGeode->FBCursorOffset = gfx_get_cursor_offset(); + + /* Save the Panel state */ + Pnl_SavePanelState(); + + /* its time to put softvga to sleep */ + gfx_disable_softvga(); + gfx_vga_mode_switch(1); + +#endif /* STB_X */ + + if (!GX1SetMode(pScreenInfo, pScreenInfo->currentMode)) { + return FALSE; + } #if 1 - /* clear the frame buffer, for annoying noise during mode switch */ - gx1_clear_screen(pScreenInfo->currentMode->CrtcHDisplay, - pScreenInfo->currentMode->CrtcVDisplay); + /* clear the frame buffer, for annoying noise during mode switch */ + gx1_clear_screen(pScreenInfo->currentMode->CrtcHDisplay, + pScreenInfo->currentMode->CrtcVDisplay); #endif - return TRUE; + return TRUE; } /*---------------------------------------------------------------------------- @@ -1485,136 +1502,136 @@ GX1EnterGraphics(ScreenPtr pScreen, ScrnInfoPtr pScreenInfo) static void GX1LeaveGraphics(ScrnInfoPtr pScreenInfo) { - GeodePtr pGeode; + GeodePtr pGeode; - GeodeDebug(("GX1LeaveGraphics!\n")); - pGeode = GEODEPTR(pScreenInfo); + GeodeDebug(("GX1LeaveGraphics!\n")); + pGeode = GEODEPTR(pScreenInfo); - if (!pGeode->FBTVActive) { - GFX(set_tv_enable(0)); - } - /* clear the frame buffer, when leaving X */ - gx1_clear_screen(pScreenInfo->virtualX, pScreenInfo->virtualY); + if (!pGeode->FBTVActive) { + GFX(set_tv_enable(0)); + } + /* clear the frame buffer, when leaving X */ + gx1_clear_screen(pScreenInfo->virtualX, pScreenInfo->virtualY); #if defined(STB_X) - Gal_set_display_timing(&pGeode->FBgfxdisplaytiming); - Gal_tv_set_timings(0, &pGeode->FBgfxtvtiming); - Gal_set_display_offset(pGeode->FBDisplayOffset); - - /* Restore Cursor */ - Gal_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0); - - /* Restore the previous Compression state */ - if (pGeode->FBCompressionEnable) { - Gal_set_compression_parameters(GAL_COMPRESSION_ALL, - pGeode->FBCompressionOffset, - pGeode->FBCompressionPitch, - pGeode->FBCompressionSize); - - Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); - } + Gal_set_display_timing(&pGeode->FBgfxdisplaytiming); + Gal_tv_set_timings(0, &pGeode->FBgfxtvtiming); + Gal_set_display_offset(pGeode->FBDisplayOffset); + + /* Restore Cursor */ + Gal_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0); + + /* Restore the previous Compression state */ + if (pGeode->FBCompressionEnable) { + Gal_set_compression_parameters(GAL_COMPRESSION_ALL, + pGeode->FBCompressionOffset, + pGeode->FBCompressionPitch, + pGeode->FBCompressionSize); + + Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); + } #else - /* Restore TV */ - if (pGeode->FBTVEnabled) { - /* TV Format */ - WRITE_VID32(SC1200_TVOUT_HORZ_TIM, pGeode->FBtvtiming.HorzTim); - WRITE_VID32(SC1200_TVOUT_HORZ_SYNC, pGeode->FBtvtiming.HorzSync); - WRITE_VID32(SC1200_TVOUT_VERT_SYNC, pGeode->FBtvtiming.VertSync); - WRITE_VID32(SC1200_TVOUT_LINE_END, pGeode->FBtvtiming.LineEnd); - WRITE_VID32(SC1200_TVOUT_VERT_DOWNSCALE, - pGeode->FBtvtiming.VertDownscale); - WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, pGeode->FBtvtiming.HorzScaling); - WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, pGeode->FBtvtiming.TimCtrl1); - WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, pGeode->FBtvtiming.TimCtrl2); - WRITE_VID32(SC1200_TVENC_SUB_FREQ, pGeode->FBtvtiming.Subfreq); - WRITE_VID32(SC1200_TVENC_DISP_POS, pGeode->FBtvtiming.DispPos); - WRITE_VID32(SC1200_TVENC_DISP_SIZE, pGeode->FBtvtiming.DispSize); - /* TV Output */ - WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, pGeode->FBtvtiming.TimCtrl2); - /* WRITE_VID32(SC1200_TVENC_DAC_CONTROL, tmp); */ - WRITE_VID32(SC1200_TVOUT_DEBUG, pGeode->FBtvtiming.Debug); - /* TV Enable */ - WRITE_VID32(SC1200_TVENC_DAC_CONTROL, pGeode->FBtvtiming.DacCtrl); - } - - /* Restore CRT */ - 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_display_pitch(pGeode->FBgfxdisplaytiming.wPitch); - - gfx_set_display_offset(pGeode->FBDisplayOffset); - - /* Restore Cursor */ - gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 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); - } -#endif /* STB_X */ - - /* We need this to get back to vga mode when soft-vga - * * kicks in. - * * We actually need to examine the attribute Ctlr to find out - * * what kinda crap (grafix or text) we need to enter in - * * For now just lookout for 720x400 - */ + /* Restore TV */ + if (pGeode->FBTVEnabled) { + /* TV Format */ + WRITE_VID32(SC1200_TVOUT_HORZ_TIM, pGeode->FBtvtiming.HorzTim); + WRITE_VID32(SC1200_TVOUT_HORZ_SYNC, pGeode->FBtvtiming.HorzSync); + WRITE_VID32(SC1200_TVOUT_VERT_SYNC, pGeode->FBtvtiming.VertSync); + WRITE_VID32(SC1200_TVOUT_LINE_END, pGeode->FBtvtiming.LineEnd); + WRITE_VID32(SC1200_TVOUT_VERT_DOWNSCALE, + pGeode->FBtvtiming.VertDownscale); + WRITE_VID32(SC1200_TVOUT_HORZ_SCALING, pGeode->FBtvtiming.HorzScaling); + WRITE_VID32(SC1200_TVENC_TIM_CTRL_1, pGeode->FBtvtiming.TimCtrl1); + WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, pGeode->FBtvtiming.TimCtrl2); + WRITE_VID32(SC1200_TVENC_SUB_FREQ, pGeode->FBtvtiming.Subfreq); + WRITE_VID32(SC1200_TVENC_DISP_POS, pGeode->FBtvtiming.DispPos); + WRITE_VID32(SC1200_TVENC_DISP_SIZE, pGeode->FBtvtiming.DispSize); + /* TV Output */ + WRITE_VID32(SC1200_TVENC_TIM_CTRL_2, pGeode->FBtvtiming.TimCtrl2); + /* WRITE_VID32(SC1200_TVENC_DAC_CONTROL, tmp); */ + WRITE_VID32(SC1200_TVOUT_DEBUG, pGeode->FBtvtiming.Debug); + /* TV Enable */ + WRITE_VID32(SC1200_TVENC_DAC_CONTROL, pGeode->FBtvtiming.DacCtrl); + } + + /* Restore CRT */ + 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_display_pitch(pGeode->FBgfxdisplaytiming.wPitch); + + gfx_set_display_offset(pGeode->FBDisplayOffset); + + /* Restore Cursor */ + gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 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); + } +#endif /* STB_X */ + + /* We need this to get back to vga mode when soft-vga + * * kicks in. + * * We actually need to examine the attribute Ctlr to find out + * * what kinda crap (grafix or text) we need to enter in + * * For now just lookout for 720x400 + */ #if 0 - if ((pGeode->FBgfxdisplaytiming.wHActive == 720) && - (pGeode->FBgfxdisplaytiming.wVActive == 400)) + if ((pGeode->FBgfxdisplaytiming.wHActive == 720) && + (pGeode->FBgfxdisplaytiming.wVActive == 400)) #else - if (pGeode->FBVGAActive) + if (pGeode->FBVGAActive) #endif - { - /* VSA was active before we started. Since we disabled it - * we got to enable it */ + { + /* VSA was active before we started. Since we disabled it + * we got to enable it */ #if defined(STB_X) - Gal_set_softvga_state(TRUE); - Gal_vga_mode_switch(1); - Gal_vga_clear_extended(); + Gal_set_softvga_state(TRUE); + Gal_vga_mode_switch(1); + Gal_vga_clear_extended(); #else - gfx_enable_softvga(); - gfx_vga_mode_switch(1); - gfx_vga_clear_extended(); -#endif /* STB_X */ + gfx_enable_softvga(); + gfx_vga_mode_switch(1); + gfx_vga_clear_extended(); +#endif /* STB_X */ #if !defined(STB_X) - vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); + vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL); #endif #if defined(STB_X) - pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | - GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; - Gal_vga_restore(&(pGeode->FBgfxVgaRegs)); - Gal_vga_mode_switch(0); + pGeode->FBgfxVgaRegs.dwFlags = GFX_VGA_FLAG_MISC_OUTPUT | + GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC; + Gal_vga_restore(&(pGeode->FBgfxVgaRegs)); + Gal_vga_mode_switch(0); #else - gfx_vga_restore(&(pGeode->FBgfxVgaRegs), - GFX_VGA_FLAG_MISC_OUTPUT | - GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); - gfx_vga_mode_switch(0); -#endif /* STB_X */ - } + gfx_vga_restore(&(pGeode->FBgfxVgaRegs), + GFX_VGA_FLAG_MISC_OUTPUT | + GFX_VGA_FLAG_STD_CRTC | GFX_VGA_FLAG_EXT_CRTC); + gfx_vga_mode_switch(0); +#endif /* STB_X */ + } #if 0 - print_gxm_gfx_reg(pGeode, 0x4C); - print_gxm_vga_reg(); + print_gxm_gfx_reg(pGeode, 0x4C); + print_gxm_vga_reg(); #endif } @@ -1637,33 +1654,33 @@ GX1LeaveGraphics(ScrnInfoPtr pScreenInfo) static Bool GX1CloseScreen(int scrnIndex, ScreenPtr pScreen) { - ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - DEBUGMSG(1, (scrnIndex, X_PROBED, "GX1CloseScreen\n")); - GeodeDebug(("GX1CloseScreen!\n")); - GX1LeaveGraphics(pScreenInfo); - if (pGeode->AccelInfoRec) - XAADestroyInfoRec(pGeode->AccelInfoRec); - pScreenInfo->vtSema = FALSE; - if (pGeode->DGAModes) - free(pGeode->DGAModes); - pGeode->DGAModes = 0; - if (pGeode->ShadowPtr) - free(pGeode->ShadowPtr); - - if (pGeode->AccelImageWriteBufferOffsets) { - free(pGeode->AccelImageWriteBufferOffsets); - pGeode->AccelImageWriteBufferOffsets = 0x0; - } - /* free the allocated off screen area */ - xf86FreeOffscreenArea(pGeode->AccelImgArea); - xf86FreeOffscreenArea(pGeode->CompressionArea); - - GX1UnmapMem(pScreenInfo); - - pScreen->CloseScreen = pGeode->CloseScreen; - return (*pScreen->CloseScreen) (scrnIndex, pScreen); + ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + DEBUGMSG(1, (scrnIndex, X_PROBED, "GX1CloseScreen\n")); + GeodeDebug(("GX1CloseScreen!\n")); + GX1LeaveGraphics(pScreenInfo); + if (pGeode->AccelInfoRec) + XAADestroyInfoRec(pGeode->AccelInfoRec); + pScreenInfo->vtSema = FALSE; + if (pGeode->DGAModes) + free(pGeode->DGAModes); + pGeode->DGAModes = 0; + if (pGeode->ShadowPtr) + free(pGeode->ShadowPtr); + + if (pGeode->AccelImageWriteBufferOffsets) { + free(pGeode->AccelImageWriteBufferOffsets); + pGeode->AccelImageWriteBufferOffsets = 0x0; + } + /* free the allocated off screen area */ + xf86FreeOffscreenArea(pGeode->AccelImgArea); + xf86FreeOffscreenArea(pGeode->CompressionArea); + + GX1UnmapMem(pScreenInfo); + + pScreen->CloseScreen = pGeode->CloseScreen; + return (*pScreen->CloseScreen) (scrnIndex, pScreen); } @@ -1685,73 +1702,73 @@ GX1CloseScreen(int scrnIndex, ScreenPtr pScreen) static void GX1DPMSSet(ScrnInfoPtr pScreenInfo, int mode, int flags) { - GeodePtr pGeode; + GeodePtr pGeode; - pGeode = GEODEPTR(pScreenInfo); + pGeode = GEODEPTR(pScreenInfo); - GeodeDebug(("GX1DPMSSet!\n")); + GeodeDebug(("GX1DPMSSet!\n")); - /* Check if we are actively controlling the display */ - if (!pScreenInfo->vtSema) { - ErrorF("GX1DPMSSet called when we not controlling the VT!\n"); - return; - } - switch (mode) { - case DPMSModeOn: - /* Screen: On; HSync: On; VSync: On */ - GFX(set_crt_enable(CRT_ENABLE)); + /* Check if we are actively controlling the display */ + if (!pScreenInfo->vtSema) { + ErrorF("GX1DPMSSet called when we not controlling the VT!\n"); + return; + } + switch (mode) { + case DPMSModeOn: + /* Screen: On; HSync: On; VSync: On */ + GFX(set_crt_enable(CRT_ENABLE)); #if defined(STB_X) - if (pGeode->Panel) - Gal_pnl_powerup(); + if (pGeode->Panel) + Gal_pnl_powerup(); #else - if (pGeode->Panel) - Pnl_PowerUp(); -#endif /* STB_X */ - if (pGeode->TVSupport) - GFX(set_tv_enable(1)); - break; - - case DPMSModeStandby: - /* Screen: Off; HSync: Off; VSync: On */ - GFX(set_crt_enable(CRT_STANDBY)); + if (pGeode->Panel) + Pnl_PowerUp(); +#endif /* STB_X */ + if (pGeode->TVSupport) + GFX(set_tv_enable(1)); + break; + + case DPMSModeStandby: + /* Screen: Off; HSync: Off; VSync: On */ + GFX(set_crt_enable(CRT_STANDBY)); #if defined(STB_X) - if (pGeode->Panel) - Gal_pnl_powerdown(); + if (pGeode->Panel) + Gal_pnl_powerdown(); #else - if (pGeode->Panel) - Pnl_PowerDown(); -#endif /* STB_X */ - if (pGeode->TVSupport) - GFX(set_tv_enable(0)); - break; - - case DPMSModeSuspend: - /* Screen: Off; HSync: On; VSync: Off */ - GFX(set_crt_enable(CRT_SUSPEND)); + if (pGeode->Panel) + Pnl_PowerDown(); +#endif /* STB_X */ + if (pGeode->TVSupport) + GFX(set_tv_enable(0)); + break; + + case DPMSModeSuspend: + /* Screen: Off; HSync: On; VSync: Off */ + GFX(set_crt_enable(CRT_SUSPEND)); #if defined(STB_X) - if (pGeode->Panel) - Gal_pnl_powerdown(); + if (pGeode->Panel) + Gal_pnl_powerdown(); #else - if (pGeode->Panel) - Pnl_PowerDown(); -#endif /* STB_X */ - if (pGeode->TVSupport) - GFX(set_tv_enable(0)); - break; - case DPMSModeOff: - /* Screen: Off; HSync: Off; VSync: Off */ - GFX(set_crt_enable(CRT_DISABLE)); + if (pGeode->Panel) + Pnl_PowerDown(); +#endif /* STB_X */ + if (pGeode->TVSupport) + GFX(set_tv_enable(0)); + break; + case DPMSModeOff: + /* Screen: Off; HSync: Off; VSync: Off */ + GFX(set_crt_enable(CRT_DISABLE)); #if defined(STB_X) - if (pGeode->Panel) - Gal_pnl_powerdown(); + if (pGeode->Panel) + Gal_pnl_powerdown(); #else - if (pGeode->Panel) - Pnl_PowerDown(); -#endif /* STB_X */ - if (pGeode->TVSupport) - GFX(set_tv_enable(0)); - break; - } + if (pGeode->Panel) + Pnl_PowerDown(); +#endif /* STB_X */ + if (pGeode->TVSupport) + GFX(set_tv_enable(0)); + break; + } } /*---------------------------------------------------------------------------- @@ -1774,346 +1791,353 @@ GX1DPMSSet(ScrnInfoPtr pScreenInfo, int mode, int flags) static Bool GX1ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { - ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; - GeodePtr pGeode; - int i; - Bool Inited = FALSE; - unsigned char *FBStart; - unsigned int req_offscreenmem; - int width, height, displayWidth; - VisualPtr visual; - BoxRec AvailBox; - RegionRec OffscreenRegion; - - DCount = 30; - - GeodeDebug(("GX1ScreenInit!\n")); - /* Get driver private */ - pGeode = GX1GetRec(pScreenInfo); - GeodeDebug(("GX1ScreenInit(0)!\n")); + ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; + GeodePtr pGeode; + int i; + Bool Inited = FALSE; + unsigned char *FBStart; + unsigned int req_offscreenmem; + int width, height, displayWidth; + VisualPtr visual; + BoxRec AvailBox; + RegionRec OffscreenRegion; + + DCount = 30; + + GeodeDebug(("GX1ScreenInit!\n")); + /* Get driver private */ + pGeode = GX1GetRec(pScreenInfo); + GeodeDebug(("GX1ScreenInit(0)!\n")); #if !defined(STB_X) - /* - * * Allocate a vgaHWRec - */ - if (!vgaHWGetHWRec(pScreenInfo)) - return FALSE; - VGAHWPTR(pScreenInfo)->MapSize = 0x10000; /* Standard 64k VGA window */ - if (!vgaHWMapMem(pScreenInfo)) - return FALSE; + /* + * * Allocate a vgaHWRec + */ + if (!vgaHWGetHWRec(pScreenInfo)) + return FALSE; + VGAHWPTR(pScreenInfo)->MapSize = 0x10000; /* Standard 64k VGA window */ + if (!vgaHWMapMem(pScreenInfo)) + return FALSE; #endif - if (!GX1MapMem(pScreenInfo)) - return FALSE; + if (!GX1MapMem(pScreenInfo)) + return FALSE; #if !defined(STB_X) - vgaHWGetIOBase(VGAHWPTR(pScreenInfo)); + vgaHWGetIOBase(VGAHWPTR(pScreenInfo)); #endif - pGeode->Pitch = GX1CalculatePitchBytes(pScreenInfo->virtualX, - pScreenInfo->bitsPerPixel); - - /* find the index to our operating mode the offsets are located */ - for (i = 0; i < (int)((sizeof(GeodeMemOffset) / sizeof(MemOffset))); i++) { - if ((pScreenInfo->virtualX == (int)GeodeMemOffset[i].xres) && - (pScreenInfo->virtualY == (int)GeodeMemOffset[i].yres) && - (pScreenInfo->bitsPerPixel == (int)GeodeMemOffset[i].bpp)) { - MemIndex = i; - break; - } - } - if (MemIndex == -1) /* no match */ - return FALSE; - - /* SET UP GRAPHICS MEMORY AVAILABLE FOR PIXMAP CACHE */ - AvailBox.x1 = 0; - AvailBox.y1 = pScreenInfo->virtualY; - AvailBox.x2 = pScreenInfo->displayWidth; - AvailBox.y2 = (pGeode->FBSize / pGeode->Pitch); - - pGeode->CursorSize = 8 * 32; /* 32 DWORDS */ - - if (pGeode->HWCursor) { - /* Compute cursor buffer */ - /* Default cursor offset, end of the frame buffer */ - pGeode->CursorStartOffset = pGeode->FBSize - pGeode->CursorSize; - AvailBox.y2 -= 1; - } - - DEBUGMSG(1, (scrnIndex, X_PROBED, - "Memory manager initialized to (%d,%d) (%d,%d) %d %d\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2, - pGeode->Pitch, pScreenInfo->displayWidth)); - /* set the offscreen offset accordingly */ - if (pGeode->Compression) { - - pGeode->CBOffset = GeodeMemOffset[MemIndex].CBOffset; - pGeode->CBSize = GeodeMemOffset[MemIndex].CBSize - 16; - pGeode->CBPitch = GeodeMemOffset[MemIndex].CBPitch; - - if ((pScreenInfo->virtualX == 1024) && (pScreenInfo->virtualY == 768)) { - req_offscreenmem = pScreenInfo->virtualY * pGeode->CBPitch; - req_offscreenmem += pGeode->Pitch - 1; - req_offscreenmem /= pGeode->Pitch; - pGeode->CBOffset = AvailBox.y1 * pGeode->Pitch; - AvailBox.y1 += req_offscreenmem; - } - } - DEBUGMSG(1, (scrnIndex, X_PROBED, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); - - if (!pGeode->NoAccel) { - if (pGeode->NoOfImgBuffers > 0) { - if (pGeode->NoOfImgBuffers <= (AvailBox.y2 - AvailBox.y1)) { - pGeode->AccelImageWriteBufferOffsets = - malloc(sizeof(unsigned long) * pGeode->NoOfImgBuffers); - - pGeode->AccelImageWriteBufferOffsets[0] = - ((unsigned char *)pGeode->FBBase) + - (AvailBox.y1 * pGeode->Pitch); - - for (i = 1; i < pGeode->NoOfImgBuffers; i++) { - pGeode->AccelImageWriteBufferOffsets[i] = - pGeode->AccelImageWriteBufferOffsets[i - 1] + - pGeode->Pitch; - } - - for (i = 0; i < pGeode->NoOfImgBuffers; i++) { - DEBUGMSG(1, (scrnIndex, X_PROBED, - "memory %d %x\n", i, - pGeode->AccelImageWriteBufferOffsets[i])); - } - AvailBox.y1 += pGeode->NoOfImgBuffers; - } else { - xf86DrvMsg(scrnIndex, X_ERROR, - "Unable to reserve scanline area\n"); - } - } - DEBUGMSG(1, (scrnIndex, X_PROBED, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); - - REGION_INIT(pScreen, &OffscreenRegion, &AvailBox, 2); - - if (!xf86InitFBManagerRegion(pScreen, &OffscreenRegion)) { - xf86DrvMsg(scrnIndex, X_ERROR, - "Memory manager initialization to (%d,%d) (%d,%d) failed\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); - } else { - xf86DrvMsg(scrnIndex, X_INFO, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); - } - REGION_UNINIT(pScreen, &OffscreenRegion); - } - - /* Initialise graphics mode */ - if (!GX1EnterGraphics(pScreen, pScreenInfo)) - return FALSE; - - GX1AdjustFrame(scrnIndex, pScreenInfo->frameX0, pScreenInfo->frameY0, 0); - GeodeDebug(("GX1ScreenInit(1)!\n")); - - /* Reset visual list */ - miClearVisualTypes(); - GeodeDebug(("GX1ScreenInit(2)!\n")); - - /* Setup the visual we support */ - if (pScreenInfo->bitsPerPixel > 8) { - if (!miSetVisualTypes(pScreenInfo->depth, - TrueColorMask, - pScreenInfo->rgbBits, - pScreenInfo->defaultVisual)) { - return FALSE; - } - } else { - if (!miSetVisualTypes(pScreenInfo->depth, - miGetDefaultVisualMask(pScreenInfo->depth), - pScreenInfo->rgbBits, - pScreenInfo->defaultVisual)) { - return FALSE; - } - } - GeodeDebug(("GX1ScreenInit(3)!\n")); - /* Set this for RENDER extension */ - miSetPixmapDepths(); - /* Call the framebuffer layer's ScreenInit function, and fill in other - * * pScreen fields. - */ - - if (pGeode->TV_Overscan_On) { - width = pGeode->TVOw; - height = pGeode->TVOh; - GeodeDebug(("width : %d , height : %d", width, height)); - } else { - width = pScreenInfo->virtualX; - height = pScreenInfo->virtualY; - } - - displayWidth = pScreenInfo->displayWidth; - if (pGeode->Rotate) { - if (pGeode->TV_Overscan_On) { - width = pGeode->TVOh; - height = pGeode->TVOw; - } else { - width = pScreenInfo->virtualY; - height = pScreenInfo->virtualX; - } - } - if (pGeode->ShadowFB) { - pGeode->ShadowPitch = BitmapBytePad(pScreenInfo->bitsPerPixel * width); - pGeode->ShadowPtr = malloc(pGeode->ShadowPitch * height); - displayWidth = pGeode->ShadowPitch / (pScreenInfo->bitsPerPixel >> 3); - FBStart = pGeode->ShadowPtr; - } else { - pGeode->ShadowPtr = NULL; - - if (pGeode->TV_Overscan_On) { - GeodeDebug(("pGeode->Pitch (%d)!\n", pGeode->Pitch)); - FBStart = pGeode->FBBase + (pGeode->Pitch * pGeode->TVOy) + - (pGeode->TVOx << ((pScreenInfo->depth >> 3) - 1)); - } else { - FBStart = pGeode->FBBase; - } - DEBUGMSG(1, (0, X_PROBED, "FBStart %X \n", FBStart)); - } - - /* Initialise the framebuffer */ - switch (pScreenInfo->bitsPerPixel) { - case 8: - case 16: - Inited = fbScreenInit(pScreen, FBStart, width, height, - pScreenInfo->xDpi, pScreenInfo->yDpi, - displayWidth, pScreenInfo->bitsPerPixel); - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in ScreenInit\n", - pScreenInfo->bitsPerPixel); - Inited = FALSE; - break; - } - if (!Inited) - return FALSE; - - GeodeDebug(("GX1ScreenInit(4)!\n")); - - xf86SetBlackWhitePixels(pScreen); - - if (!pGeode->ShadowFB && (!pGeode->TV_Overscan_On)) { - GX1DGAInit(pScreen); - } - GeodeDebug(("GX1ScreenInit(5)!\n")); - if (pScreenInfo->bitsPerPixel > 8) { - /* Fixup RGB ordering */ - visual = pScreen->visuals + pScreen->numVisuals; - while (--visual >= pScreen->visuals) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScreenInfo->offset.red; - visual->offsetGreen = pScreenInfo->offset.green; - visual->offsetBlue = pScreenInfo->offset.blue; - visual->redMask = pScreenInfo->mask.red; - visual->greenMask = pScreenInfo->mask.green; - visual->blueMask = pScreenInfo->mask.blue; - } - } - } - /* must be after RGB ordering fixed */ - fbPictureInit(pScreen, 0, 0); - - GeodeDebug(("GX1ScreenInit(6)!\n")); - if (!pGeode->NoAccel) { - GX1AccelInit(pScreen); - } - GeodeDebug(("GX1ScreenInit(7)!\n")); - miInitializeBackingStore(pScreen); - xf86SetBackingStore(pScreen); - - GeodeDebug(("GX1ScreenInit(8)!\n")); - /* Initialise software cursor */ - miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); - /* Initialize HW cursor layer. - * * Must follow software cursor initialization - */ - if (pGeode->HWCursor) { - if (!GX1HWCursorInit(pScreen)) - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Hardware cursor initialization failed\n"); - } - GeodeDebug(("GX1ScreenInit(9)!\n")); - - /* Setup default colourmap */ - if (!miCreateDefColormap(pScreen)) { - return FALSE; - } - - GeodeDebug(("GX1ScreenInit(10)!\n")); - /* Initialize colormap layer. - * * Must follow initialization of the default colormap - */ - if (!xf86HandleColormaps(pScreen, 256, 8, - GX1LoadPalette, NULL, - CMAP_PALETTED_TRUECOLOR | - CMAP_RELOAD_ON_MODE_SWITCH)) { - return FALSE; - } - GeodeDebug(("GX1ScreenInit(11)!\n")); - - if (pGeode->ShadowFB) { - RefreshAreaFuncPtr refreshArea = GX1RefreshArea; - - if (pGeode->Rotate) { - if (!pGeode->PointerMoved) { - pGeode->PointerMoved = pScreenInfo->PointerMoved; - pScreenInfo->PointerMoved = GX1PointerMoved; - } - switch (pScreenInfo->bitsPerPixel) { - case 8: - refreshArea = GX1RefreshArea8; - break; - case 16: - refreshArea = GX1RefreshArea16; - break; - } - } - ShadowFBInit(pScreen, refreshArea); - } - xf86DPMSInit(pScreen, GX1DPMSSet, 0); - GeodeDebug(("GX1ScreenInit(12)!\n")); - - if (pGeode->TV_Overscan_On) { - GeodeDebug(("pGeode->Pitch (%d)!\n", pGeode->Pitch)); - - pScreenInfo->memPhysBase = (unsigned long)(pGeode->FBBase + - (pGeode->Pitch * - pGeode->TVOy) + - (pGeode-> - TVOx << - ((pScreenInfo->depth >> 3) - - 1))); - GeodeDebug(("->memPhysBase (%X)!\n", pScreenInfo->memPhysBase)); - } else { - pScreenInfo->memPhysBase = (unsigned long)pGeode->FBBase; - } - pScreenInfo->fbOffset = 0; - - GeodeDebug(("GX1ScreenInit(13)!\n")); - GX1InitVideo(pScreen); /* needed for video */ - /* Wrap the screen's CloseScreen vector and set its - * SaveScreen vector - */ - pGeode->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = GX1CloseScreen; - - pScreen->SaveScreen = GX1SaveScreen; - GeodeDebug(("GX1ScreenInit(14)!\n")); - /* Report any unused options */ - if (serverGeneration == 1) { - xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options); - } - GeodeDebug(("GX2ScreenInit(15)!\n")); - return TRUE; + pGeode->Pitch = GX1CalculatePitchBytes(pScreenInfo->virtualX, + pScreenInfo->bitsPerPixel); + + /* find the index to our operating mode the offsets are located */ + for (i = 0; i < (int) ((sizeof(GeodeMemOffset) / sizeof(MemOffset))); i++) { + if ((pScreenInfo->virtualX == (int) GeodeMemOffset[i].xres) && + (pScreenInfo->virtualY == (int) GeodeMemOffset[i].yres) && + (pScreenInfo->bitsPerPixel == (int) GeodeMemOffset[i].bpp)) { + MemIndex = i; + break; + } + } + if (MemIndex == -1) /* no match */ + return FALSE; + + /* SET UP GRAPHICS MEMORY AVAILABLE FOR PIXMAP CACHE */ + AvailBox.x1 = 0; + AvailBox.y1 = pScreenInfo->virtualY; + AvailBox.x2 = pScreenInfo->displayWidth; + AvailBox.y2 = (pGeode->FBSize / pGeode->Pitch); + + pGeode->CursorSize = 8 * 32; /* 32 DWORDS */ + + if (pGeode->HWCursor) { + /* Compute cursor buffer */ + /* Default cursor offset, end of the frame buffer */ + pGeode->CursorStartOffset = pGeode->FBSize - pGeode->CursorSize; + AvailBox.y2 -= 1; + } + + DEBUGMSG(1, (scrnIndex, X_PROBED, + "Memory manager initialized to (%d,%d) (%d,%d) %d %d\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2, + pGeode->Pitch, pScreenInfo->displayWidth)); + /* set the offscreen offset accordingly */ + if (pGeode->Compression) { + + pGeode->CBOffset = GeodeMemOffset[MemIndex].CBOffset; + pGeode->CBSize = GeodeMemOffset[MemIndex].CBSize - 16; + pGeode->CBPitch = GeodeMemOffset[MemIndex].CBPitch; + + if ((pScreenInfo->virtualX == 1024) && (pScreenInfo->virtualY == 768)) { + req_offscreenmem = pScreenInfo->virtualY * pGeode->CBPitch; + req_offscreenmem += pGeode->Pitch - 1; + req_offscreenmem /= pGeode->Pitch; + pGeode->CBOffset = AvailBox.y1 * pGeode->Pitch; + AvailBox.y1 += req_offscreenmem; + } + } + DEBUGMSG(1, (scrnIndex, X_PROBED, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); + + if (!pGeode->NoAccel) { + if (pGeode->NoOfImgBuffers > 0) { + if (pGeode->NoOfImgBuffers <= (AvailBox.y2 - AvailBox.y1)) { + pGeode->AccelImageWriteBufferOffsets = + malloc(sizeof(unsigned long) * pGeode->NoOfImgBuffers); + + pGeode->AccelImageWriteBufferOffsets[0] = + ((unsigned char *) pGeode->FBBase) + + (AvailBox.y1 * pGeode->Pitch); + + for (i = 1; i < pGeode->NoOfImgBuffers; i++) { + pGeode->AccelImageWriteBufferOffsets[i] = + pGeode->AccelImageWriteBufferOffsets[i - 1] + + pGeode->Pitch; + } + + for (i = 0; i < pGeode->NoOfImgBuffers; i++) { + DEBUGMSG(1, (scrnIndex, X_PROBED, + "memory %d %x\n", i, + pGeode->AccelImageWriteBufferOffsets[i])); + } + AvailBox.y1 += pGeode->NoOfImgBuffers; + } + else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Unable to reserve scanline area\n"); + } + } + DEBUGMSG(1, (scrnIndex, X_PROBED, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); + + REGION_INIT(pScreen, &OffscreenRegion, &AvailBox, 2); + + if (!xf86InitFBManagerRegion(pScreen, &OffscreenRegion)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Memory manager initialization to (%d,%d) (%d,%d) failed\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); + } + else { + xf86DrvMsg(scrnIndex, X_INFO, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); + } + REGION_UNINIT(pScreen, &OffscreenRegion); + } + + /* Initialise graphics mode */ + if (!GX1EnterGraphics(pScreen, pScreenInfo)) + return FALSE; + + GX1AdjustFrame(scrnIndex, pScreenInfo->frameX0, pScreenInfo->frameY0, 0); + GeodeDebug(("GX1ScreenInit(1)!\n")); + + /* Reset visual list */ + miClearVisualTypes(); + GeodeDebug(("GX1ScreenInit(2)!\n")); + + /* Setup the visual we support */ + if (pScreenInfo->bitsPerPixel > 8) { + if (!miSetVisualTypes(pScreenInfo->depth, + TrueColorMask, + pScreenInfo->rgbBits, + pScreenInfo->defaultVisual)) { + return FALSE; + } + } + else { + if (!miSetVisualTypes(pScreenInfo->depth, + miGetDefaultVisualMask(pScreenInfo->depth), + pScreenInfo->rgbBits, + pScreenInfo->defaultVisual)) { + return FALSE; + } + } + GeodeDebug(("GX1ScreenInit(3)!\n")); + /* Set this for RENDER extension */ + miSetPixmapDepths(); + /* Call the framebuffer layer's ScreenInit function, and fill in other + * * pScreen fields. + */ + + if (pGeode->TV_Overscan_On) { + width = pGeode->TVOw; + height = pGeode->TVOh; + GeodeDebug(("width : %d , height : %d", width, height)); + } + else { + width = pScreenInfo->virtualX; + height = pScreenInfo->virtualY; + } + + displayWidth = pScreenInfo->displayWidth; + if (pGeode->Rotate) { + if (pGeode->TV_Overscan_On) { + width = pGeode->TVOh; + height = pGeode->TVOw; + } + else { + width = pScreenInfo->virtualY; + height = pScreenInfo->virtualX; + } + } + if (pGeode->ShadowFB) { + pGeode->ShadowPitch = BitmapBytePad(pScreenInfo->bitsPerPixel * width); + pGeode->ShadowPtr = malloc(pGeode->ShadowPitch * height); + displayWidth = pGeode->ShadowPitch / (pScreenInfo->bitsPerPixel >> 3); + FBStart = pGeode->ShadowPtr; + } + else { + pGeode->ShadowPtr = NULL; + + if (pGeode->TV_Overscan_On) { + GeodeDebug(("pGeode->Pitch (%d)!\n", pGeode->Pitch)); + FBStart = pGeode->FBBase + (pGeode->Pitch * pGeode->TVOy) + + (pGeode->TVOx << ((pScreenInfo->depth >> 3) - 1)); + } + else { + FBStart = pGeode->FBBase; + } + DEBUGMSG(1, (0, X_PROBED, "FBStart %X \n", FBStart)); + } + + /* Initialise the framebuffer */ + switch (pScreenInfo->bitsPerPixel) { + case 8: + case 16: + Inited = fbScreenInit(pScreen, FBStart, width, height, + pScreenInfo->xDpi, pScreenInfo->yDpi, + displayWidth, pScreenInfo->bitsPerPixel); + break; + default: + xf86DrvMsg(scrnIndex, X_ERROR, + "Internal error: invalid bpp (%d) in ScreenInit\n", + pScreenInfo->bitsPerPixel); + Inited = FALSE; + break; + } + if (!Inited) + return FALSE; + + GeodeDebug(("GX1ScreenInit(4)!\n")); + + xf86SetBlackWhitePixels(pScreen); + + if (!pGeode->ShadowFB && (!pGeode->TV_Overscan_On)) { + GX1DGAInit(pScreen); + } + GeodeDebug(("GX1ScreenInit(5)!\n")); + if (pScreenInfo->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScreenInfo->offset.red; + visual->offsetGreen = pScreenInfo->offset.green; + visual->offsetBlue = pScreenInfo->offset.blue; + visual->redMask = pScreenInfo->mask.red; + visual->greenMask = pScreenInfo->mask.green; + visual->blueMask = pScreenInfo->mask.blue; + } + } + } + /* must be after RGB ordering fixed */ + fbPictureInit(pScreen, 0, 0); + + GeodeDebug(("GX1ScreenInit(6)!\n")); + if (!pGeode->NoAccel) { + GX1AccelInit(pScreen); + } + GeodeDebug(("GX1ScreenInit(7)!\n")); + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + + GeodeDebug(("GX1ScreenInit(8)!\n")); + /* Initialise software cursor */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + /* Initialize HW cursor layer. + * * Must follow software cursor initialization + */ + if (pGeode->HWCursor) { + if (!GX1HWCursorInit(pScreen)) + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + } + GeodeDebug(("GX1ScreenInit(9)!\n")); + + /* Setup default colourmap */ + if (!miCreateDefColormap(pScreen)) { + return FALSE; + } + + GeodeDebug(("GX1ScreenInit(10)!\n")); + /* Initialize colormap layer. + * * Must follow initialization of the default colormap + */ + if (!xf86HandleColormaps(pScreen, 256, 8, + GX1LoadPalette, NULL, + CMAP_PALETTED_TRUECOLOR | + CMAP_RELOAD_ON_MODE_SWITCH)) { + return FALSE; + } + GeodeDebug(("GX1ScreenInit(11)!\n")); + + if (pGeode->ShadowFB) { + RefreshAreaFuncPtr refreshArea = GX1RefreshArea; + + if (pGeode->Rotate) { + if (!pGeode->PointerMoved) { + pGeode->PointerMoved = pScreenInfo->PointerMoved; + pScreenInfo->PointerMoved = GX1PointerMoved; + } + switch (pScreenInfo->bitsPerPixel) { + case 8: + refreshArea = GX1RefreshArea8; + break; + case 16: + refreshArea = GX1RefreshArea16; + break; + } + } + ShadowFBInit(pScreen, refreshArea); + } + xf86DPMSInit(pScreen, GX1DPMSSet, 0); + GeodeDebug(("GX1ScreenInit(12)!\n")); + + if (pGeode->TV_Overscan_On) { + GeodeDebug(("pGeode->Pitch (%d)!\n", pGeode->Pitch)); + + pScreenInfo->memPhysBase = (unsigned long) (pGeode->FBBase + + (pGeode->Pitch * + pGeode->TVOy) + + (pGeode->TVOx << + ((pScreenInfo-> + depth >> 3) - 1))); + GeodeDebug(("->memPhysBase (%X)!\n", pScreenInfo->memPhysBase)); + } + else { + pScreenInfo->memPhysBase = (unsigned long) pGeode->FBBase; + } + pScreenInfo->fbOffset = 0; + + GeodeDebug(("GX1ScreenInit(13)!\n")); + GX1InitVideo(pScreen); /* needed for video */ + /* Wrap the screen's CloseScreen vector and set its + * SaveScreen vector + */ + pGeode->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = GX1CloseScreen; + + pScreen->SaveScreen = GX1SaveScreen; + GeodeDebug(("GX1ScreenInit(14)!\n")); + /* Report any unused options */ + if (serverGeneration == 1) { + xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options); + } + GeodeDebug(("GX2ScreenInit(15)!\n")); + return TRUE; } /*---------------------------------------------------------------------------- @@ -2134,8 +2158,8 @@ GX1ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) Bool GX1SwitchMode(int scrnIndex, DisplayModePtr pMode, int flags) { - GeodeDebug(("GX1SwitchMode!\n")); - return GX1SetMode(xf86Screens[scrnIndex], pMode); + GeodeDebug(("GX1SwitchMode!\n")); + return GX1SetMode(xf86Screens[scrnIndex], pMode); } /*---------------------------------------------------------------------------- @@ -2156,18 +2180,18 @@ GX1SwitchMode(int scrnIndex, DisplayModePtr pMode, int flags) void GX1AdjustFrame(int scrnIndex, int x, int y, int flags) { - ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; - GeodePtr pGeode; - unsigned long offset; - - pGeode = GX1GetRec(pScreenInfo); - offset = (unsigned long)y *(unsigned long)pGeode->Pitch; - - offset += x; - if (pScreenInfo->bitsPerPixel > 8) { - offset += x; - } - GFX(set_display_offset(offset)); + ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; + GeodePtr pGeode; + unsigned long offset; + + pGeode = GX1GetRec(pScreenInfo); + offset = (unsigned long) y *(unsigned long) pGeode->Pitch; + + offset += x; + if (pScreenInfo->bitsPerPixel > 8) { + offset += x; + } + GFX(set_display_offset(offset)); } /*---------------------------------------------------------------------------- @@ -2187,8 +2211,8 @@ GX1AdjustFrame(int scrnIndex, int x, int y, int flags) static Bool GX1EnterVT(int scrnIndex, int flags) { - GeodeDebug(("GX1EnterVT!\n")); - return GX1EnterGraphics(NULL, xf86Screens[scrnIndex]); + GeodeDebug(("GX1EnterVT!\n")); + return GX1EnterGraphics(NULL, xf86Screens[scrnIndex]); } /*---------------------------------------------------------------------------- @@ -2208,8 +2232,8 @@ GX1EnterVT(int scrnIndex, int flags) static void GX1LeaveVT(int scrnIndex, int flags) { - GeodeDebug(("GX1LeaveVT!\n")); - GX1LeaveGraphics(xf86Screens[scrnIndex]); + GeodeDebug(("GX1LeaveVT!\n")); + GX1LeaveGraphics(xf86Screens[scrnIndex]); } /*---------------------------------------------------------------------------- @@ -2229,13 +2253,13 @@ GX1LeaveVT(int scrnIndex, int flags) static void GX1FreeScreen(int scrnIndex, int flags) { - GeodeDebug(("GX1FreeScreen!\n")); + GeodeDebug(("GX1FreeScreen!\n")); #if !defined(STB_X) - if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) - vgaHWFreeHWRec(xf86Screens[scrnIndex]); + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(xf86Screens[scrnIndex]); #endif - GX1FreeRec(xf86Screens[scrnIndex]); + GX1FreeRec(xf86Screens[scrnIndex]); } /*---------------------------------------------------------------------------- @@ -2257,60 +2281,62 @@ GX1FreeScreen(int scrnIndex, int flags) static ModeStatus GX1ValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags) { - ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; - unsigned int total_memory_required; - int ret = -1; - GeodePtr pGeode = GX1GetRec(pScreenInfo); + ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; + unsigned int total_memory_required; + int ret = -1; + GeodePtr pGeode = GX1GetRec(pScreenInfo); - DEBUGMSG(1, (0, X_NONE, "GeodeValidateMode: %dx%d %d %d\n", - pMode->CrtcHDisplay, pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, GX1GetRefreshRate(pMode))); + DEBUGMSG(1, (0, X_NONE, "GeodeValidateMode: %dx%d %d %d\n", + pMode->CrtcHDisplay, pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, GX1GetRefreshRate(pMode))); - if (pGeode->TVSupport == TRUE) { - if ((pGeode->TvParam.wWidth == pMode->CrtcHDisplay) && - (pGeode->TvParam.wHeight == pMode->CrtcVDisplay)) { - DEBUGMSG(1, (0, X_NONE, "TV mode\n")); + if (pGeode->TVSupport == TRUE) { + if ((pGeode->TvParam.wWidth == pMode->CrtcHDisplay) && + (pGeode->TvParam.wHeight == pMode->CrtcVDisplay)) { + DEBUGMSG(1, (0, X_NONE, "TV mode\n")); #if defined(STB_X) - Gal_is_tv_mode_supported(0, &(pGeode->TvParam), &ret); + Gal_is_tv_mode_supported(0, &(pGeode->TvParam), &ret); #else - ret = gfx_is_tv_display_mode_supported(pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - (TVStandardType)pGeode->TvParam.wStandard); + ret = gfx_is_tv_display_mode_supported(pMode->CrtcHDisplay, + pMode->CrtcVDisplay, + (TVStandardType) pGeode-> + TvParam.wStandard); #endif - } - } else { - DEBUGMSG(1, (0, X_NONE, "CRT mode\n")); + } + } + else { + DEBUGMSG(1, (0, X_NONE, "CRT mode\n")); - if (pMode->Flags & V_INTERLACE) - return MODE_NO_INTERLACE; + if (pMode->Flags & V_INTERLACE) + return MODE_NO_INTERLACE; #if defined(STB_X) - Gal_is_display_mode_supported(pMode->CrtcHDisplay, pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, - GX1GetRefreshRate(pMode), &ret); + Gal_is_display_mode_supported(pMode->CrtcHDisplay, pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, + GX1GetRefreshRate(pMode), &ret); #else - ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, - GX1GetRefreshRate(pMode)); -#endif /* STB_X */ - } + ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay, + pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, + GX1GetRefreshRate(pMode)); +#endif /* STB_X */ + } - if (ret < 0) - return MODE_NOMODE; + if (ret < 0) + return MODE_NOMODE; - total_memory_required = GX1CalculatePitchBytes(pMode->CrtcHDisplay, - pScreenInfo->bitsPerPixel) * - pMode->CrtcVDisplay; + total_memory_required = GX1CalculatePitchBytes(pMode->CrtcHDisplay, + pScreenInfo->bitsPerPixel) * + pMode->CrtcVDisplay; - DEBUGMSG(0, (0, X_NONE, "Total Mem %X %X", - total_memory_required, pGeode->FBSize)); + DEBUGMSG(0, (0, X_NONE, "Total Mem %X %X", + total_memory_required, pGeode->FBSize)); - if (total_memory_required > pGeode->FBSize) - return MODE_MEM; + if (total_memory_required > pGeode->FBSize) + return MODE_MEM; - return MODE_OK; + return MODE_OK; } /*---------------------------------------------------------------------------- @@ -2333,74 +2359,74 @@ GX1ValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags) static void GX1LoadPalette(ScrnInfoPtr pScreenInfo, - int numColors, int *indizes, LOCO * colors, VisualPtr pVisual) + int numColors, int *indizes, LOCO * colors, VisualPtr pVisual) { - 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)); - DEBUGMSG(0, (0, X_NONE, "GX1LoadPalette: %d %d %X\n", - numColors, index, color)); - - GFX(set_display_palette_entry(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)); + DEBUGMSG(0, (0, X_NONE, "GX1LoadPalette: %d %d %X\n", + numColors, index, color)); + + GFX(set_display_palette_entry(index, color)); + } } static Bool GX1MapMem(ScrnInfoPtr pScreenInfo) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); + GeodePtr pGeode = GEODEPTR(pScreenInfo); #if defined(STB_X) - pGeode->FBBase = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, - pGeode->FBLinearAddr, - pGeode->FBSize); + pGeode->FBBase = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_FRAMEBUFFER, + pGeode->FBLinearAddr, + pGeode->FBSize); #else - /* SET DURANGO REGISTER POINTERS - * * The method of mapping from a physical address to a linear address - * * is operating system independent. Set variables to linear address. - */ - gfx_virt_regptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, - (unsigned int) - gfx_get_cpu_register_base - (), 0x9000); - gfx_virt_spptr = gfx_virt_regptr; - gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, - (unsigned int) - gfx_get_vid_register_base - (), 0x1000); - pGeode->FBSize = GetVideoMemSize(); - gfx_virt_fbptr = - (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, - pGeode->FBLinearAddr, pGeode->FBSize); - - /* CHECK IF REGISTERS WERE MAPPED SUCCESSFULLY */ - if ((!gfx_virt_regptr) || - (!gfx_virt_spptr) || (!gfx_virt_vidptr) || (!gfx_virt_fbptr)) { - DEBUGMSG(1, (0, X_NONE, "Could not map hardware registers.\n")); - return (FALSE); - } - - /* Map the XpressROM ptr to read what platform are we on */ - XpressROMPtr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, 0xF0000, - 0x10000); - - if (!XpressROMPtr) - return FALSE; - - pGeode->FBBase = gfx_virt_fbptr; + /* SET DURANGO REGISTER POINTERS + * * The method of mapping from a physical address to a linear address + * * is operating system independent. Set variables to linear address. + */ + gfx_virt_regptr = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_MMIO, + (unsigned int) + gfx_get_cpu_register_base + (), 0x9000); + gfx_virt_spptr = gfx_virt_regptr; + gfx_virt_vidptr = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_MMIO, + (unsigned int) + gfx_get_vid_register_base + (), 0x1000); + pGeode->FBSize = GetVideoMemSize(); + gfx_virt_fbptr = + (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_FRAMEBUFFER, + pGeode->FBLinearAddr, pGeode->FBSize); + + /* CHECK IF REGISTERS WERE MAPPED SUCCESSFULLY */ + if ((!gfx_virt_regptr) || + (!gfx_virt_spptr) || (!gfx_virt_vidptr) || (!gfx_virt_fbptr)) { + DEBUGMSG(1, (0, X_NONE, "Could not map hardware registers.\n")); + return (FALSE); + } + + /* Map the XpressROM ptr to read what platform are we on */ + XpressROMPtr = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_FRAMEBUFFER, 0xF0000, + 0x10000); + + if (!XpressROMPtr) + return FALSE; + + pGeode->FBBase = gfx_virt_fbptr; #endif - return TRUE; + return TRUE; } /* @@ -2411,16 +2437,16 @@ static Bool GX1UnmapMem(ScrnInfoPtr pScreenInfo) { #if !defined(STB_X) - GeodePtr pGeode = GEODEPTR(pScreenInfo); + GeodePtr pGeode = GEODEPTR(pScreenInfo); - /* unmap all the memory map's */ - xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_regptr, 0x9000); - xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_vidptr, 0x1000); - xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_fbptr, pGeode->FBSize); - xf86UnMapVidMem(pScreenInfo->scrnIndex, XpressROMPtr, 0x10000); -#endif /* STB_X */ + /* unmap all the memory map's */ + xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_regptr, 0x9000); + xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_vidptr, 0x1000); + xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_fbptr, pGeode->FBSize); + xf86UnMapVidMem(pScreenInfo->scrnIndex, XpressROMPtr, 0x10000); +#endif /* STB_X */ - return TRUE; + return TRUE; } /* End of file */ diff --git a/src/nsc_gx1_shadow.c b/src/nsc_gx1_shadow.c index abb40dd..7d4c463 100644 --- a/src/nsc_gx1_shadow.c +++ b/src/nsc_gx1_shadow.c @@ -181,26 +181,26 @@ void GX1RefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void GX1RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int width, height, Bpp, FBPitch; - unsigned char *src, *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int width, height, Bpp, FBPitch; + unsigned char *src, *dst; - Bpp = pScrn->bitsPerPixel >> 3; - FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); - while (num--) { - width = (pbox->x2 - pbox->x1) * Bpp; - height = pbox->y2 - pbox->y1; - src = pGeode->ShadowPtr + (pbox->y1 * pGeode->ShadowPitch) + - (pbox->x1 * Bpp); - dst = pGeode->FBBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); - while (height--) { - memcpy(dst, src, width); - dst += FBPitch; - src += pGeode->ShadowPitch; - } + Bpp = pScrn->bitsPerPixel >> 3; + FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); + while (num--) { + width = (pbox->x2 - pbox->x1) * Bpp; + height = pbox->y2 - pbox->y1; + src = pGeode->ShadowPtr + (pbox->y1 * pGeode->ShadowPitch) + + (pbox->x1 * Bpp); + dst = pGeode->FBBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); + while (height--) { + memcpy(dst, src, width); + dst += FBPitch; + src += pGeode->ShadowPitch; + } - pbox++; - } + pbox++; + } } /*---------------------------------------------------------------------------- @@ -221,18 +221,19 @@ GX1RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void GX1PointerMoved(int index, int x, int y) { - ScrnInfoPtr pScrn = xf86Screens[index]; - GeodePtr pGeode = GEODEPTR(pScrn); - int newX, newY; + ScrnInfoPtr pScrn = xf86Screens[index]; + GeodePtr pGeode = GEODEPTR(pScrn); + int newX, newY; - if (pGeode->Rotate == 1) { - newX = pScrn->pScreen->height - y - 1; - newY = x; - } else { - newX = y; - newY = pScrn->pScreen->width - x - 1; - } - (*pGeode->PointerMoved) (index, newX, newY); + if (pGeode->Rotate == 1) { + newX = pScrn->pScreen->height - y - 1; + newY = x; + } + else { + newX = y; + newY = pScrn->pScreen->width - x - 1; + } + (*pGeode->PointerMoved) (index, newX, newY); } /*---------------------------------------------------------------------------- @@ -253,46 +254,47 @@ GX1PointerMoved(int index, int x, int y) void GX1RefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2, - srcPitch3, srcPitch4; - CARD8 *dstPtr, *srcPtr, *src; - CARD32 *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2, + srcPitch3, srcPitch4; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pGeode->Rotate * pGeode->ShadowPitch; - srcPitch2 = srcPitch * 2; - srcPitch3 = srcPitch * 3; - srcPitch4 = srcPitch * 4; - while (num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~3; - y2 = (pbox->y2 + 3) & ~3; - height = (y2 - y1) >> 2; /* in dwords */ + dstPitch = pScrn->displayWidth; + srcPitch = -pGeode->Rotate * pGeode->ShadowPitch; + srcPitch2 = srcPitch * 2; + srcPitch3 = srcPitch * 3; + srcPitch4 = srcPitch * 4; + while (num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* in dwords */ - if (pGeode->Rotate == 1) { - dstPtr = pGeode->FBBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - y2; - srcPtr = pGeode->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; - } else { - dstPtr = pGeode->FBBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; - srcPtr = pGeode->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; - } - while (width--) { - src = srcPtr; - dst = (CARD32 *) dstPtr; - count = height; - while (count--) { - *(dst++) = src[0] | (src[srcPitch] << 8) | - (src[srcPitch2] << 16) | (src[srcPitch3] << 24); - src += srcPitch4; - } - srcPtr += pGeode->Rotate; - dstPtr += dstPitch; - } - pbox++; - } + if (pGeode->Rotate == 1) { + dstPtr = pGeode->FBBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = pGeode->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } + else { + dstPtr = pGeode->FBBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = pGeode->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; + } + while (width--) { + src = srcPtr; + dst = (CARD32 *) dstPtr; + count = height; + while (count--) { + *(dst++) = src[0] | (src[srcPitch] << 8) | + (src[srcPitch2] << 16) | (src[srcPitch3] << 24); + src += srcPitch4; + } + srcPtr += pGeode->Rotate; + dstPtr += dstPitch; + } + pbox++; + } } /*---------------------------------------------------------------------------- @@ -313,45 +315,46 @@ GX1RefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void GX1RefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2; - CARD16 *dstPtr, *srcPtr, *src; - CARD32 *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2; + CARD16 *dstPtr, *srcPtr, *src; + CARD32 *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pGeode->Rotate * pGeode->ShadowPitch >> 1; - srcPitch2 = srcPitch * 2; - while (num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~1; - y2 = (pbox->y2 + 1) & ~1; - height = (y2 - y1) >> 1; /* in dwords */ - if (pGeode->Rotate == 1) { - dstPtr = (CARD16 *) pGeode->FBBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - y2; - srcPtr = (CARD16 *) pGeode->ShadowPtr + - ((1 - y2) * srcPitch) + pbox->x1; - } else { - dstPtr = (CARD16 *) pGeode->FBBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; - srcPtr = (CARD16 *) pGeode->ShadowPtr + - (y1 * srcPitch) + pbox->x2 - 1; - } + dstPitch = pScrn->displayWidth; + srcPitch = -pGeode->Rotate * pGeode->ShadowPitch >> 1; + srcPitch2 = srcPitch * 2; + while (num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~1; + y2 = (pbox->y2 + 1) & ~1; + height = (y2 - y1) >> 1; /* in dwords */ + if (pGeode->Rotate == 1) { + dstPtr = (CARD16 *) pGeode->FBBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = (CARD16 *) pGeode->ShadowPtr + + ((1 - y2) * srcPitch) + pbox->x1; + } + else { + dstPtr = (CARD16 *) pGeode->FBBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = (CARD16 *) pGeode->ShadowPtr + + (y1 * srcPitch) + pbox->x2 - 1; + } - while (width--) { - src = srcPtr; - dst = (CARD32 *) dstPtr; - count = height; - while (count--) { - *(dst++) = src[0] | (src[srcPitch] << 16); - src += srcPitch2; - } - srcPtr += pGeode->Rotate; - dstPtr += dstPitch; - } + while (width--) { + src = srcPtr; + dst = (CARD32 *) dstPtr; + count = height; + while (count--) { + *(dst++) = src[0] | (src[srcPitch] << 16); + src += srcPitch2; + } + srcPtr += pGeode->Rotate; + dstPtr += dstPitch; + } - pbox++; - } + pbox++; + } } /*---------------------------------------------------------------------------- @@ -372,48 +375,49 @@ GX1RefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void GX1RefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2, srcPitch3; - CARD8 *dstPtr, *srcPtr, *src; - CARD32 *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2, srcPitch3; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; - dstPitch = BitmapBytePad(pScrn->displayWidth * 24); - srcPitch = -pGeode->Rotate * pGeode->ShadowPitch; - srcPitch2 = srcPitch * 2; - srcPitch3 = srcPitch * 3; - while (num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~3; - y2 = (pbox->y2 + 3) & ~3; - height = (y2 - y1) >> 2; /* blocks of 3 dwords */ - if (pGeode->Rotate == 1) { - dstPtr = pGeode->FBBase + - (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); - srcPtr = pGeode->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); - } else { - dstPtr = pGeode->FBBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); - srcPtr = pGeode->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; - } - while (width--) { - src = srcPtr; - dst = (CARD32 *) dstPtr; - count = height; - while (count--) { - dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | - (src[srcPitch] << 24); - dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | - (src[srcPitch2] << 16) | (src[srcPitch2 + 1] << 24); - dst[2] = src[srcPitch2 + 2] | (src[srcPitch3] << 8) | - (src[srcPitch3 + 1] << 16) | (src[srcPitch3 + 2] << 24); - dst += 3; - src += srcPitch << 2; - } - srcPtr += pGeode->Rotate * 3; - dstPtr += dstPitch; - } - pbox++; - } + dstPitch = BitmapBytePad(pScrn->displayWidth * 24); + srcPitch = -pGeode->Rotate * pGeode->ShadowPitch; + srcPitch2 = srcPitch * 2; + srcPitch3 = srcPitch * 3; + while (num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* blocks of 3 dwords */ + if (pGeode->Rotate == 1) { + dstPtr = pGeode->FBBase + + (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); + srcPtr = pGeode->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); + } + else { + dstPtr = pGeode->FBBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); + srcPtr = pGeode->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; + } + while (width--) { + src = srcPtr; + dst = (CARD32 *) dstPtr; + count = height; + while (count--) { + dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | + (src[srcPitch] << 24); + dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | + (src[srcPitch2] << 16) | (src[srcPitch2 + 1] << 24); + dst[2] = src[srcPitch2 + 2] | (src[srcPitch3] << 8) | + (src[srcPitch3 + 1] << 16) | (src[srcPitch3 + 2] << 24); + dst += 3; + src += srcPitch << 2; + } + srcPtr += pGeode->Rotate * 3; + dstPtr += dstPitch; + } + pbox++; + } } /*---------------------------------------------------------------------------- @@ -434,40 +438,41 @@ GX1RefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void GX1RefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int count, width, height, dstPitch, srcPitch; - CARD32 *dstPtr, *srcPtr, *src, *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int count, width, height, dstPitch, srcPitch; + CARD32 *dstPtr, *srcPtr, *src, *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pGeode->Rotate * pGeode->ShadowPitch >> 2; - while (num--) { - width = pbox->x2 - pbox->x1; - height = pbox->y2 - pbox->y1; + dstPitch = pScrn->displayWidth; + srcPitch = -pGeode->Rotate * pGeode->ShadowPitch >> 2; + while (num--) { + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; - if (pGeode->Rotate == 1) { - dstPtr = (CARD32 *) pGeode->FBBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; - srcPtr = (CARD32 *) pGeode->ShadowPtr + - ((1 - pbox->y2) * srcPitch) + pbox->x1; - } else { - dstPtr = (CARD32 *) pGeode->FBBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; - srcPtr = (CARD32 *) pGeode->ShadowPtr + - (pbox->y1 * srcPitch) + pbox->x2 - 1; - } - while (width--) { - src = srcPtr; - dst = dstPtr; - count = height; - while (count--) { - *(dst++) = *src; - src += srcPitch; - } - srcPtr += pGeode->Rotate; - dstPtr += dstPitch; - } - pbox++; - } + if (pGeode->Rotate == 1) { + dstPtr = (CARD32 *) pGeode->FBBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; + srcPtr = (CARD32 *) pGeode->ShadowPtr + + ((1 - pbox->y2) * srcPitch) + pbox->x1; + } + else { + dstPtr = (CARD32 *) pGeode->FBBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; + srcPtr = (CARD32 *) pGeode->ShadowPtr + + (pbox->y1 * srcPitch) + pbox->x2 - 1; + } + while (width--) { + src = srcPtr; + dst = dstPtr; + count = height; + while (count--) { + *(dst++) = *src; + src += srcPitch; + } + srcPtr += pGeode->Rotate; + dstPtr += dstPitch; + } + pbox++; + } } /* End of file */ diff --git a/src/nsc_gx1_video.c b/src/nsc_gx1_video.c index 9e58480..93ab2eb 100644 --- a/src/nsc_gx1_video.c +++ b/src/nsc_gx1_video.c @@ -167,7 +167,7 @@ #include "fourcc.h" #include "nsc_fourcc.h" -#define OFF_DELAY 200 /* milliseconds */ +#define OFF_DELAY 200 /* milliseconds */ #define FREE_DELAY 60000 #define OFF_TIMER 0x01 @@ -189,20 +189,20 @@ static void GX1StopVideo(ScrnInfoPtr, pointer, Bool); static int GX1SetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); static int GX1GetPortAttribute(ScrnInfoPtr, Atom, INT32 *, pointer); static void GX1QueryBestSize(ScrnInfoPtr, Bool, - short, short, short, short, unsigned int *, - unsigned int *, pointer); + short, short, short, short, unsigned int *, + unsigned int *, pointer); static int GX1PutImage(ScrnInfoPtr, - short, short, short, short, short, short, - short, short, int, unsigned char *, short, short, - Bool, RegionPtr, pointer, DrawablePtr); + short, short, short, short, short, short, + short, short, int, unsigned char *, short, short, + Bool, RegionPtr, pointer, DrawablePtr); static int GX1QueryImageAttributes(ScrnInfoPtr, - int, unsigned short *, unsigned short *, - int *, int *); + int, unsigned short *, unsigned short *, + int *, int *); static void GX1BlockHandler(int, pointer, pointer, pointer); void GX1SetVideoPosition(int, int, int, int, - short, short, short, short, int, int, ScrnInfoPtr); + short, short, short, short, int, int, ScrnInfoPtr); extern void GX1AccelSync(ScrnInfoPtr pScreenInfo); @@ -216,9 +216,9 @@ int DeltaX, DeltaY; static Atom xvColorKey, xvColorKeyMode, xvFilter #if DBUF - , xvDoubleBuffer +, xvDoubleBuffer #endif - ; +; /*---------------------------------------------------------------------------- * GX1InitVideo @@ -242,61 +242,61 @@ static Atom xvColorKey, xvColorKeyMode, xvFilter void GX1InitVideo(ScreenPtr pScreen) { - GeodePtr pGeode; + GeodePtr pGeode; - ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; - - int num_adaptors; - - pGeode = GEODEPTR(pScreenInfo); - - - DEBUGMSG(0, (0, X_NONE, "InitVideo\n")); - newAdaptor = GX1SetupImageVideo(pScreen); - GX1InitOffscreenImages(pScreen); - - num_adaptors = xf86XVListGenericAdaptors(pScreenInfo, &adaptors); - - if (newAdaptor) { - if (!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - malloc((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(pScreen, adaptors, num_adaptors); - - if (newAdaptors) - free(newAdaptors); + XF86VideoAdaptorPtr newAdaptor = NULL; + + int num_adaptors; + + pGeode = GEODEPTR(pScreenInfo); + + DEBUGMSG(0, (0, X_NONE, "InitVideo\n")); + newAdaptor = GX1SetupImageVideo(pScreen); + GX1InitOffscreenImages(pScreen); + + num_adaptors = xf86XVListGenericAdaptors(pScreenInfo, &adaptors); + + if (newAdaptor) { + if (!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } + else { + newAdaptors = /* need to free this someplace */ + malloc((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(pScreen, adaptors, num_adaptors); + + if (newAdaptors) + free(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 static XF86VideoFormatRec Formats[NUM_FORMATS] = { - {8, PseudoColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor} + {8, PseudoColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor} }; #if DBUF @@ -307,42 +307,40 @@ static XF86VideoFormatRec Formats[NUM_FORMATS] = { static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = { #if DBUF - {XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER"}, + {XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER"}, #endif - {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"} }; #define NUM_IMAGES 7 static XF86ImageRec Images[NUM_IMAGES] = { - XVIMAGE_UYVY, - XVIMAGE_YUY2, - XVIMAGE_Y2YU, - XVIMAGE_YVYU, - XVIMAGE_Y800, - XVIMAGE_I420, - XVIMAGE_YV12 + XVIMAGE_UYVY, + XVIMAGE_YUY2, + XVIMAGE_Y2YU, + XVIMAGE_YVYU, + XVIMAGE_Y800, + XVIMAGE_I420, + XVIMAGE_YV12 }; -typedef struct -{ - FBAreaPtr area; - FBLinearPtr linear; - RegionRec clip; - CARD32 colorKey; - CARD32 colorKeyMode; - CARD32 filter; - CARD32 videoStatus; - Time offTime; - Time freeTime; +typedef struct { + FBAreaPtr area; + FBLinearPtr linear; + RegionRec clip; + CARD32 colorKey; + CARD32 colorKeyMode; + CARD32 filter; + CARD32 videoStatus; + Time offTime; + Time freeTime; #if DBUF - Bool doubleBuffer; - int currentBuffer; + Bool doubleBuffer; + int currentBuffer; #endif -} -GeodePortPrivRec, *GeodePortPrivPtr; +} GeodePortPrivRec, *GeodePortPrivPtr; #define GET_PORT_PRIVATE(pScrn) \ (GeodePortPrivPtr)((GEODEPTR(pScrn))->adaptor->pPortPrivates[0].ptr) @@ -367,33 +365,36 @@ GeodePortPrivRec, *GeodePortPrivPtr; static INT32 GX1SetColorkey(ScrnInfoPtr pScrn, GeodePortPrivPtr pPriv) { - int red, green, blue; - unsigned long key; - - DEBUGMSG(0, (0, X_NONE, "ColorKey\n")); - switch (pScrn->depth) { - case 8: - GFX(get_display_palette_entry(pPriv->colorKey & 0xFF, &key)); - red = ((key >> 16) & 0xFF); - green = ((key >> 8) & 0xFF); - blue = (key & 0xFF); - break; - default: - red = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red << (8 - - pScrn-> - weight. - red); - green = - (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset. - green << (8 - pScrn->weight.green); - blue = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset. - blue << (8 - pScrn->weight.blue); - break; - } - GFX(set_video_color_key((blue | (green << 8) | (red << 16)), 0xFCFCFC, - (pPriv->colorKeyMode == 0))); - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - return 0; + int red, green, blue; + unsigned long key; + + DEBUGMSG(0, (0, X_NONE, "ColorKey\n")); + switch (pScrn->depth) { + case 8: + GFX(get_display_palette_entry(pPriv->colorKey & 0xFF, &key)); + red = ((key >> 16) & 0xFF); + green = ((key >> 8) & 0xFF); + blue = (key & 0xFF); + break; + default: + red = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red << (8 - + pScrn->weight.red); + green = + (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green << (8 - + pScrn-> + weight. + green); + blue = + (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue << (8 - + pScrn-> + weight. + blue); + break; + } + GFX(set_video_color_key((blue | (green << 8) | (red << 16)), 0xFCFCFC, + (pPriv->colorKeyMode == 0))); + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + return 0; } /*---------------------------------------------------------------------------- @@ -420,7 +421,8 @@ GX1ResetVideo(ScrnInfoPtr pScrn) GeodePortPrivPtr pPriv = pGeode->adaptor->pPortPrivates[0].ptr; DEBUGMSG(0, (0, X_NONE, "ResetVideo\n")); - if (!pGeode->NoAccel) GX1AccelSync(pScrn); + if (!pGeode->NoAccel) + GX1AccelSync(pScrn); GFX(set_video_palette(NULL)); GX1SetColorkey(pScrn, pPriv); GFX(set_video_filter(pPriv->filter, pPriv->filter)); @@ -446,69 +448,69 @@ GX1ResetVideo(ScrnInfoPtr pScrn) static XF86VideoAdaptorPtr GX1SetupImageVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - GeodePtr pGeode = GEODEPTR(pScrn); - XF86VideoAdaptorPtr adapt; - GeodePortPrivPtr pPriv; - - DEBUGMSG(0, (0, X_NONE, "SetupImageVideo\n")); - if (!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + - sizeof(GeodePortPrivRec) + sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adapt->name = "National Semiconductor Corporation"; - adapt->nEncodings = 1; - adapt->pEncodings = DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = Formats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion *) (&adapt[1]); - pPriv = (GeodePortPrivPtr) (&adapt->pPortPrivates[1]); - adapt->pPortPrivates[0].ptr = (pointer) (pPriv); - adapt->pAttributes = Attributes; - adapt->nImages = NUM_IMAGES; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->pImages = Images; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = GX1StopVideo; - adapt->SetPortAttribute = GX1SetPortAttribute; - adapt->GetPortAttribute = GX1GetPortAttribute; - adapt->QueryBestSize = GX1QueryBestSize; - adapt->PutImage = GX1PutImage; - adapt->QueryImageAttributes = GX1QueryImageAttributes; - - pPriv->colorKey = pGeode->videoKey; - pPriv->colorKeyMode = 0; - pPriv->filter = 0; - pPriv->videoStatus = 0; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + GeodePtr pGeode = GEODEPTR(pScrn); + XF86VideoAdaptorPtr adapt; + GeodePortPrivPtr pPriv; + + DEBUGMSG(0, (0, X_NONE, "SetupImageVideo\n")); + if (!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(GeodePortPrivRec) + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "National Semiconductor Corporation"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion *) (&adapt[1]); + pPriv = (GeodePortPrivPtr) (&adapt->pPortPrivates[1]); + adapt->pPortPrivates[0].ptr = (pointer) (pPriv); + adapt->pAttributes = Attributes; + adapt->nImages = NUM_IMAGES; + adapt->nAttributes = NUM_ATTRIBUTES; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = GX1StopVideo; + adapt->SetPortAttribute = GX1SetPortAttribute; + adapt->GetPortAttribute = GX1GetPortAttribute; + adapt->QueryBestSize = GX1QueryBestSize; + adapt->PutImage = GX1PutImage; + adapt->QueryImageAttributes = GX1QueryImageAttributes; + + pPriv->colorKey = pGeode->videoKey; + pPriv->colorKeyMode = 0; + pPriv->filter = 0; + pPriv->videoStatus = 0; #if DBUF - pPriv->doubleBuffer = TRUE; - pPriv->currentBuffer = 0; /* init to first buffer */ + pPriv->doubleBuffer = TRUE; + pPriv->currentBuffer = 0; /* init to first buffer */ #endif - /* gotta uninit this someplace */ - REGION_NULL(pScreen, &pPriv->clip); + /* gotta uninit this someplace */ + REGION_NULL(pScreen, &pPriv->clip); - pGeode->adaptor = adapt; + pGeode->adaptor = adapt; - pGeode->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = GX1BlockHandler; + pGeode->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = GX1BlockHandler; - xvColorKey = MAKE_ATOM("XV_COLORKEY"); - xvColorKeyMode = MAKE_ATOM("XV_COLORKEYMODE"); - xvFilter = MAKE_ATOM("XV_FILTER"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + xvColorKeyMode = MAKE_ATOM("XV_COLORKEYMODE"); + xvFilter = MAKE_ATOM("XV_FILTER"); #if DBUF - xvDoubleBuffer = MAKE_ATOM("XV_DOUBLE_BUFFER"); + xvDoubleBuffer = MAKE_ATOM("XV_DOUBLE_BUFFER"); #endif - GX1ResetVideo(pScrn); + GX1ResetVideo(pScrn); - return adapt; + return adapt; } /*---------------------------------------------------------------------------- @@ -531,29 +533,31 @@ GX1SetupImageVideo(ScreenPtr pScreen) static void GX1StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) { - GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; - GeodePtr pGeode = GEODEPTR(pScrn); - - DEBUGMSG(0, (0, X_NONE, "StopVideo\n")); - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - - if (!pGeode->NoAccel) GX1AccelSync(pScrn); - if (exit) { - if (pPriv->videoStatus & CLIENT_VIDEO_ON) { - GFX(set_video_enable(0)); - } - if (pPriv->area) { - xf86FreeOffscreenArea(pPriv->area); - pPriv->area = NULL; - } - pPriv->videoStatus = 0; - pGeode->OverlayON = FALSE; - } else { - if (pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus |= OFF_TIMER; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - } - } + GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; + GeodePtr pGeode = GEODEPTR(pScrn); + + DEBUGMSG(0, (0, X_NONE, "StopVideo\n")); + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if (!pGeode->NoAccel) + GX1AccelSync(pScrn); + if (exit) { + if (pPriv->videoStatus & CLIENT_VIDEO_ON) { + GFX(set_video_enable(0)); + } + if (pPriv->area) { + xf86FreeOffscreenArea(pPriv->area); + pPriv->area = NULL; + } + pPriv->videoStatus = 0; + pGeode->OverlayON = FALSE; + } + else { + if (pPriv->videoStatus & CLIENT_VIDEO_ON) { + pPriv->videoStatus |= OFF_TIMER; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + } + } } /*---------------------------------------------------------------------------- @@ -577,33 +581,36 @@ GX1StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) */ static int GX1SetPortAttribute(ScrnInfoPtr pScrn, - Atom attribute, INT32 value, pointer data) + Atom attribute, INT32 value, pointer data) { - GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; - GeodePtr pGeode = GEODEPTR(pScrn); - - if (!pGeode->NoAccel) GX1AccelSync(pScrn); - if (attribute == xvColorKey) { - pPriv->colorKey = value; - GX1SetColorkey(pScrn, pPriv); - } + GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; + GeodePtr pGeode = GEODEPTR(pScrn); + + if (!pGeode->NoAccel) + GX1AccelSync(pScrn); + if (attribute == xvColorKey) { + pPriv->colorKey = value; + GX1SetColorkey(pScrn, pPriv); + } #if DBUF - else if (attribute == xvDoubleBuffer) { - if ((value < 0) || (value > 1)) - return BadValue; - pPriv->doubleBuffer = value; - } + else if (attribute == xvDoubleBuffer) { + if ((value < 0) || (value > 1)) + return BadValue; + pPriv->doubleBuffer = value; + } #endif - else if (attribute == xvColorKeyMode) { - pPriv->colorKeyMode = value; - GX1SetColorkey(pScrn, pPriv); - } else if (attribute == xvFilter) { - pPriv->filter = value; - GFX(set_video_filter(pPriv->filter, pPriv->filter)); - } else - return BadMatch; - - return Success; + else if (attribute == xvColorKeyMode) { + pPriv->colorKeyMode = value; + GX1SetColorkey(pScrn, pPriv); + } + else if (attribute == xvFilter) { + pPriv->filter = value; + GFX(set_video_filter(pPriv->filter, pPriv->filter)); + } + else + return BadMatch; + + return Success; } /*---------------------------------------------------------------------------- @@ -627,26 +634,28 @@ GX1SetPortAttribute(ScrnInfoPtr pScrn, */ static int GX1GetPortAttribute(ScrnInfoPtr pScrn, - Atom attribute, INT32 * value, pointer data) + Atom attribute, INT32 *value, pointer data) { - GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; + GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; - if (attribute == xvColorKey) { - *value = pPriv->colorKey; - } + if (attribute == xvColorKey) { + *value = pPriv->colorKey; + } #if DBUF - else if (attribute == xvDoubleBuffer) { - *value = (pPriv->doubleBuffer) ? 1 : 0; - } + else if (attribute == xvDoubleBuffer) { + *value = (pPriv->doubleBuffer) ? 1 : 0; + } #endif - else if (attribute == xvColorKeyMode) { - *value = pPriv->colorKeyMode; - } else if (attribute == xvFilter) { - *value = pPriv->filter; - } else - return BadMatch; - - return Success; + else if (attribute == xvColorKeyMode) { + *value = pPriv->colorKeyMode; + } + else if (attribute == xvFilter) { + *value = pPriv->filter; + } + else + return BadMatch; + + return Success; } /*---------------------------------------------------------------------------- @@ -673,45 +682,46 @@ GX1GetPortAttribute(ScrnInfoPtr pScrn, */ static void GX1QueryBestSize(ScrnInfoPtr pScrn, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, pointer data) + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, pointer data) { - DEBUGMSG(0, (0, X_NONE, "QueryBestSize\n")); - *p_w = drw_w; - *p_h = drw_h; + DEBUGMSG(0, (0, X_NONE, "QueryBestSize\n")); + *p_w = drw_w; + *p_h = drw_h; - if (*p_w > 16384) - *p_w = 16384; + if (*p_w > 16384) + *p_w = 16384; } + static void GX1CopyGreyscale(unsigned char *src, - unsigned char *dst, int srcPitch, int dstPitch, int h, int w) + unsigned char *dst, int srcPitch, int dstPitch, 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 */ - } - dst2 += dstPitch; - src2 += srcPitch; - } + 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; + } } /*---------------------------------------------------------------------------- @@ -735,127 +745,127 @@ GX1CopyGreyscale(unsigned char *src, static void GX1CopyData(unsigned char *src, unsigned char *dst, - int srcPitch, int dstPitch, int h, int w) + int srcPitch, int dstPitch, int h, int w) { - w <<= 1; - while (h--) { - memcpy(dst, src, w); - src += srcPitch; - dst += dstPitch; - } + w <<= 1; + while (h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } } static void GX1CopyMungedData(unsigned char *src1, - unsigned char *src2, - unsigned char *src3, - unsigned char *dst1, - int srcPitch, int srcPitch2, int dstPitch, int h, int w) + unsigned char *src2, + unsigned char *src3, + unsigned char *dst1, + int srcPitch, int srcPitch2, int dstPitch, int h, int w) { - CARD32 *dstCur = (CARD32 *) dst1; - CARD32 *dstNext = (CARD32 *) dst1; - int i, j, k, m, n; - CARD32 crcb; + CARD32 *dstCur = (CARD32 *) dst1; + CARD32 *dstNext = (CARD32 *) dst1; + int i, j, k, m, n; + CARD32 crcb; #if XV_PROFILE - long oldtime, newtime; + long oldtime, newtime; #endif - DEBUGMSG(0, (0, X_NONE, "CopyMungedData\n")); - /* dstPitch is in byte count, but we write longs. - * so divide dstpitch by 4 - */ - dstPitch >>= 2; - /* Width is in byte but video data is 16bit - */ - w >>= 1; - /* We render 2 scanlines at one shot, handle the odd count */ - m = h & 1; - /* decrement the height since we write 2 scans */ - h -= 1; - /* we traverse by 2 bytes in src Y */ - srcPitch <<= 1; + DEBUGMSG(0, (0, X_NONE, "CopyMungedData\n")); + /* dstPitch is in byte count, but we write longs. + * so divide dstpitch by 4 + */ + dstPitch >>= 2; + /* Width is in byte but video data is 16bit + */ + w >>= 1; + /* We render 2 scanlines at one shot, handle the odd count */ + m = h & 1; + /* decrement the height since we write 2 scans */ + h -= 1; + /* we traverse by 2 bytes in src Y */ + srcPitch <<= 1; #if XV_PROFILE - UpdateCurrentTime(); - oldtime = currentTime.milliseconds; + UpdateCurrentTime(); + oldtime = currentTime.milliseconds; #endif - for (j = 0; j < h; j += 2) { - /* calc the next dest scan start */ - dstNext = dstCur + dstPitch; - for (i = 0; i < w; i++) { - /* crcb is same for the x pixel for 2 scans */ - crcb = (src3[i] << 8) | (src2[i] << 24); - - n = i << 1; - - /* write the first scan pixel DWORD */ - dstCur[i] = src1[n] | (src1[n + 1] << 16) | crcb; - - /* calc the offset of next pixel */ - k = n + srcPitch; - - /* write the 2nd scan pixel DWORD */ - dstNext[i] = src1[k] | (src1[k + 1] << 16) | crcb; - } - /* increment the offsets */ - - /* Y */ - src1 += srcPitch; - /* crcb */ - src2 += srcPitch2; - src3 += srcPitch2; - /* processed dest */ - dstCur += (dstPitch << 1); - } - - /* if any scans remaining */ - if (m) { - for (i = 0, k = 0; i < w; i++, k += 2) { - dstCur[i] = src1[k] | (src1[k + 1] << 16) | - (src3[i] << 8) | (src2[i] << 24); - } - } + for (j = 0; j < h; j += 2) { + /* calc the next dest scan start */ + dstNext = dstCur + dstPitch; + for (i = 0; i < w; i++) { + /* crcb is same for the x pixel for 2 scans */ + crcb = (src3[i] << 8) | (src2[i] << 24); + + n = i << 1; + + /* write the first scan pixel DWORD */ + dstCur[i] = src1[n] | (src1[n + 1] << 16) | crcb; + + /* calc the offset of next pixel */ + k = n + srcPitch; + + /* write the 2nd scan pixel DWORD */ + dstNext[i] = src1[k] | (src1[k + 1] << 16) | crcb; + } + /* increment the offsets */ + + /* Y */ + src1 += srcPitch; + /* crcb */ + src2 += srcPitch2; + src3 += srcPitch2; + /* processed dest */ + dstCur += (dstPitch << 1); + } + + /* if any scans remaining */ + if (m) { + for (i = 0, k = 0; i < w; i++, k += 2) { + dstCur[i] = src1[k] | (src1[k + 1] << 16) | + (src3[i] << 8) | (src2[i] << 24); + } + } #if XV_PROFILE - UpdateCurrentTime(); - newtime = currentTime.milliseconds; - DEBUGMSG(1, (0, X_NONE, "CMD %d\n", newtime - oldtime)); + UpdateCurrentTime(); + newtime = currentTime.milliseconds; + DEBUGMSG(1, (0, X_NONE, "CMD %d\n", newtime - oldtime)); #endif } static FBAreaPtr GX1AllocateMemory(ScrnInfoPtr pScrn, FBAreaPtr area, int numlines) { - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; - FBAreaPtr new_area; + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + FBAreaPtr new_area; - if (area) { - if ((area->box.y2 - area->box.y1) >= numlines) - return area; + if (area) { + if ((area->box.y2 - area->box.y1) >= numlines) + return area; - if (xf86ResizeOffscreenArea(area, pScrn->displayWidth, numlines)) - return area; + if (xf86ResizeOffscreenArea(area, pScrn->displayWidth, numlines)) + return area; - xf86FreeOffscreenArea(area); - } + xf86FreeOffscreenArea(area); + } - new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, - numlines, 0, NULL, NULL, NULL); + new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + numlines, 0, NULL, NULL, NULL); - if (!new_area) { - int max_w, max_h; + if (!new_area) { + int max_w, max_h; - xf86QueryLargestOffscreenArea(pScreen, &max_w, &max_h, 0, - FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); + xf86QueryLargestOffscreenArea(pScreen, &max_w, &max_h, 0, + FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); - if ((max_w < pScrn->displayWidth) || (max_h < numlines)) - return NULL; + if ((max_w < pScrn->displayWidth) || (max_h < numlines)) + return NULL; - xf86PurgeUnlockedOffscreenAreas(pScreen); - new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, - numlines, 0, NULL, NULL, NULL); - } - return new_area; + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + numlines, 0, NULL, NULL, NULL); + } + return new_area; } static BoxRec dstBox; @@ -869,109 +879,111 @@ static int TVOverScanX; static Bool RegionsIntersect(BoxPtr pRcl1, BoxPtr pRcl2, BoxPtr pRclResult) { - pRclResult->x1 = max(pRcl1->x1, pRcl2->x1); - pRclResult->x2 = min(pRcl1->x2, pRcl2->x2); + pRclResult->x1 = max(pRcl1->x1, pRcl2->x1); + 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); + if (pRclResult->x1 <= pRclResult->x2) { + 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); + return (FALSE); } void GX1SetVideoPosition(int x, int y, int width, int height, - short src_w, short src_h, short drw_w, short drw_h, - int id, int offset, ScrnInfoPtr pScrn) + short src_w, short src_h, short drw_w, short drw_h, + int id, int offset, ScrnInfoPtr pScrn) { - GeodePtr pGeode = GEODEPTR(pScrn); - long xstart, ystart, xend, yend; - unsigned long lines = 0; - unsigned long y_extra = 0; - unsigned short crop = 0; - BoxRec ovly, display, result; + GeodePtr pGeode = GEODEPTR(pScrn); + long xstart, ystart, xend, yend; + unsigned long lines = 0; + unsigned long y_extra = 0; + unsigned short crop = 0; + BoxRec ovly, display, result; #if defined(STB_X) - unsigned long startAddress = 0; + unsigned long startAddress = 0; #endif - xend = x + drw_w; - yend = y + drw_h; + xend = x + drw_w; + yend = y + drw_h; - /* Take care of panning when panel is present */ + /* Take care of panning when panel is present */ #if defined(STB_X) - Gal_get_display_offset(&startAddress); - DeltaY = startAddress / pGeode->Pitch; - DeltaX = startAddress & (pGeode->Pitch - 1); - DeltaX /= (pScrn->bitsPerPixel >> 3); + Gal_get_display_offset(&startAddress); + DeltaY = startAddress / pGeode->Pitch; + DeltaX = startAddress & (pGeode->Pitch - 1); + DeltaX /= (pScrn->bitsPerPixel >> 3); #endif - 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; - } - } - - /* LEFT CLIPPING */ - - if (x < 0) { - if (TVOverScanX) - xstart = TVOverScanX; - else - xstart = 0; - } else { - if (TVOverScanX) - xstart = TVOverScanX; - else - xstart = (unsigned long)x; - } - drw_w -= (xstart - x); - - /* TOP CLIPPING */ - - if (y < 0) { - lines = (-y) * src_h / drw_h; - ystart = 0; - drw_h += y; - y_extra = lines * dstPitch; - } else { - ystart = y; - lines = 0; - y_extra = 0; - } - - /* CLIP RIGHT AND BOTTOM FOR TV OVER SCAN */ - if (pGeode->TV_Overscan_On) { - crop = (pGeode->TVOw + pGeode->TVOx); - if ((xstart + drw_w) > crop) - xend = crop; - crop = (pGeode->TVOh + pGeode->TVOy); - if ((ystart + drw_h) > crop) - yend = crop; - } - GFX(set_video_window(xstart, ystart, xend - xstart, yend - ystart)); - GFX(set_video_offset(offset + y_extra)); - GFX(set_video_left_crop(xstart - x)); + 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; + } + } + + /* LEFT CLIPPING */ + + if (x < 0) { + if (TVOverScanX) + xstart = TVOverScanX; + else + xstart = 0; + } + else { + if (TVOverScanX) + xstart = TVOverScanX; + else + xstart = (unsigned long) x; + } + drw_w -= (xstart - x); + + /* TOP CLIPPING */ + + if (y < 0) { + lines = (-y) * src_h / drw_h; + ystart = 0; + drw_h += y; + y_extra = lines * dstPitch; + } + else { + ystart = y; + lines = 0; + y_extra = 0; + } + + /* CLIP RIGHT AND BOTTOM FOR TV OVER SCAN */ + if (pGeode->TV_Overscan_On) { + crop = (pGeode->TVOw + pGeode->TVOx); + if ((xstart + drw_w) > crop) + xend = crop; + crop = (pGeode->TVOh + pGeode->TVOy); + if ((ystart + drw_h) > crop) + yend = crop; + } + GFX(set_video_window(xstart, ystart, xend - xstart, yend - ystart)); + GFX(set_video_offset(offset + y_extra)); + GFX(set_video_left_crop(xstart - x)); } @@ -992,66 +1004,67 @@ GX1SetVideoPosition(int x, int y, int width, int height, static void GX1DisplayVideo(ScrnInfoPtr pScrn, - int id, - int offset, - short width, short height, - int pitch, - int x1, int y1, int x2, int y2, - BoxPtr dstBox, - short src_w, short src_h, short drw_w, short drw_h) + int id, + int offset, + short width, short height, + int pitch, + int x1, int y1, int x2, int y2, + BoxPtr dstBox, + short src_w, short src_h, short drw_w, short drw_h) { - GeodePtr pGeode = GEODEPTR(pScrn); - - /* DisplayModePtr mode = pScrn->currentMode; */ - if (!pGeode->NoAccel) GX1AccelSync(pScrn); - - GFX(set_video_enable(1)); - - switch (id) { - case FOURCC_UYVY: /* UYVY */ - GFX(set_video_format(VIDEO_FORMAT_UYVY)); - break; - case FOURCC_Y800: /* Y800 - greyscale - we munge it! */ - case FOURCC_YV12: - case FOURCC_I420: - case FOURCC_YUY2: /* YUY2 */ - GFX(set_video_format(VIDEO_FORMAT_YUYV)); - break; - case FOURCC_Y2YU: /* Y2YU */ - GFX(set_video_format(VIDEO_FORMAT_Y2YU)); - break; - case FOURCC_YVYU: /* YVYU */ - GFX(set_video_format(VIDEO_FORMAT_YVYU)); - break; - } - - if (pGeode->TV_Overscan_On) { - if (dstBox->x1 < 0) - TVOverScanX = pGeode->TVOx; - else - TVOverScanX = 0; - dstBox->x1 += pGeode->TVOx; - dstBox->y1 += pGeode->TVOy; - } - 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 = pScrn; - } - - GFX(set_video_size(width, height)); - GFX(set_video_scale(width, height, drw_w, drw_h)); - GX1SetVideoPosition(dstBox->x1, dstBox->y1, width, height, src_w, src_h, - drw_w, drw_h, id, offset, pScrn); - GFX(set_color_space_YUV(0)); + GeodePtr pGeode = GEODEPTR(pScrn); + + /* DisplayModePtr mode = pScrn->currentMode; */ + if (!pGeode->NoAccel) + GX1AccelSync(pScrn); + + GFX(set_video_enable(1)); + + switch (id) { + case FOURCC_UYVY: /* UYVY */ + GFX(set_video_format(VIDEO_FORMAT_UYVY)); + break; + case FOURCC_Y800: /* Y800 - greyscale - we munge it! */ + case FOURCC_YV12: + case FOURCC_I420: + case FOURCC_YUY2: /* YUY2 */ + GFX(set_video_format(VIDEO_FORMAT_YUYV)); + break; + case FOURCC_Y2YU: /* Y2YU */ + GFX(set_video_format(VIDEO_FORMAT_Y2YU)); + break; + case FOURCC_YVYU: /* YVYU */ + GFX(set_video_format(VIDEO_FORMAT_YVYU)); + break; + } + + if (pGeode->TV_Overscan_On) { + if (dstBox->x1 < 0) + TVOverScanX = pGeode->TVOx; + else + TVOverScanX = 0; + dstBox->x1 += pGeode->TVOx; + dstBox->y1 += pGeode->TVOy; + } + 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 = pScrn; + } + + GFX(set_video_size(width, height)); + GFX(set_video_scale(width, height, drw_w, drw_h)); + GX1SetVideoPosition(dstBox->x1, dstBox->y1, width, height, src_w, src_h, + drw_w, drw_h, id, offset, pScrn); + GFX(set_color_space_YUV(0)); } /*---------------------------------------------------------------------------- @@ -1078,197 +1091,196 @@ GX1DisplayVideo(ScrnInfoPtr pScrn, static int GX1PutImage(ScrnInfoPtr pScrn, - short src_x, short src_y, - short drw_x, short drw_y, - 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 src_x, short src_y, + short drw_x, short drw_y, + 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) { - GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; - GeodePtr pGeode = GEODEPTR(pScrn); - int pitch, new_h; + GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; + GeodePtr pGeode = GEODEPTR(pScrn); + int pitch, new_h; #if REINIT - BOOL ReInitVideo = FALSE; + BOOL ReInitVideo = FALSE; #endif #if XV_PROFILE - long oldtime, newtime; + long oldtime, newtime; - UpdateCurrentTime(); - oldtime = currentTime.milliseconds; + UpdateCurrentTime(); + oldtime = currentTime.milliseconds; #endif #if REINIT /* update cliplist */ - if (!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) { - ReInitVideo = TRUE; - } - if (ReInitVideo) { - DEBUGMSG(1, (0, X_NONE, "Regional Not Equal - Init\n")); + if (!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) { + ReInitVideo = TRUE; + } + if (ReInitVideo) { + DEBUGMSG(1, (0, X_NONE, "Regional Not Equal - Init\n")); #endif - 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 -= pScrn->frameX0; - dstBox.x2 -= pScrn->frameX0; - dstBox.y1 -= pScrn->frameY0; - dstBox.y2 -= pScrn->frameY0; - - pitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; - - dstPitch = ((width << 1) + 3) & ~3; - - switch (id) { - case FOURCC_YV12: - case FOURCC_I420: - srcPitch = (width + 3) & ~3; /* of luma */ - s2offset = srcPitch * height; - srcPitch2 = ((width >> 1) + 3) & ~3; - s3offset = (srcPitch2 * (height >> 1)) + s2offset; - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - case FOURCC_Y800: - default: - srcPitch = (width << 1); - break; - } - - /* Find how many pitch scanlines required to store the data */ - new_h = ((dstPitch * height) + pitch - 1) / pitch; + 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 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + + pitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; + + dstPitch = ((width << 1) + 3) & ~3; + + switch (id) { + case FOURCC_YV12: + case FOURCC_I420: + srcPitch = (width + 3) & ~3; /* of luma */ + s2offset = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + s3offset = (srcPitch2 * (height >> 1)) + s2offset; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + case FOURCC_Y800: + default: + srcPitch = (width << 1); + break; + } + + /* Find how many pitch scanlines required to store the data */ + new_h = ((dstPitch * height) + pitch - 1) / pitch; #if DBUF - if (pPriv->doubleBuffer) - new_h <<= 1; + if (pPriv->doubleBuffer) + new_h <<= 1; #endif - if (!(pPriv->area = GX1AllocateMemory(pScrn, pPriv->area, new_h))) - return BadAlloc; + if (!(pPriv->area = GX1AllocateMemory(pScrn, pPriv->area, 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; - offset = (pPriv->area->box.y1 * pitch) + (top * dstPitch); + top &= ~1; + offset = (pPriv->area->box.y1 * pitch) + (top * dstPitch); #if DBUF - if (pPriv->doubleBuffer && pPriv->currentBuffer) - offset += (new_h >> 1) * pitch; + if (pPriv->doubleBuffer && pPriv->currentBuffer) + offset += (new_h >> 1) * 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: - default: - left <<= 1; - buf += (top * srcPitch) + left; - nlines = By2 - top; - offset = (pPriv->area->box.y1 * pitch) + (top * dstPitch); + 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: + default: + left <<= 1; + buf += (top * srcPitch) + left; + nlines = By2 - top; + offset = (pPriv->area->box.y1 * pitch) + (top * dstPitch); #if DBUF - if (pPriv->doubleBuffer && pPriv->currentBuffer) - offset += (new_h >> 1) * pitch; + if (pPriv->doubleBuffer && pPriv->currentBuffer) + offset += (new_h >> 1) * 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(pScrn->pScreen, &pPriv->clip, clipBoxes); - if (pPriv->colorKeyMode == 0) { - /* draw these */ - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } - GX1DisplayVideo(pScrn, id, offset, width, height, dstPitch, - Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, - drw_h); - } + /* update cliplist */ + REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); + if (pPriv->colorKeyMode == 0) { + /* draw these */ + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); + } + GX1DisplayVideo(pScrn, id, offset, width, height, dstPitch, + Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, + drw_h); + } #endif - switch (id) { - - case FOURCC_Y800: - GX1CopyGreyscale(buf, dst_start, srcPitch, dstPitch, nlines, npixels); - break; - case FOURCC_YV12: - case FOURCC_I420: - GX1CopyMungedData(buf + s1offset, buf + s2offset, - buf + s3offset, dst_start, srcPitch, srcPitch2, - dstPitch, nlines, npixels); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - GX1CopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels); - break; - } + switch (id) { + + case FOURCC_Y800: + GX1CopyGreyscale(buf, dst_start, srcPitch, dstPitch, nlines, npixels); + break; + case FOURCC_YV12: + case FOURCC_I420: + GX1CopyMungedData(buf + s1offset, buf + s2offset, + buf + s3offset, dst_start, srcPitch, srcPitch2, + dstPitch, nlines, npixels); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + GX1CopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels); + break; + } #if !REINIT - /* update cliplist */ - REGION_COPY(pScreen, &pPriv->clip, clipBoxes); - if (pPriv->colorKeyMode == 0) { - /* draw these */ - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } - GX1DisplayVideo(pScrn, id, offset, width, height, dstPitch, - Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, drw_h); + /* update cliplist */ + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + if (pPriv->colorKeyMode == 0) { + /* draw these */ + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); + } + GX1DisplayVideo(pScrn, id, offset, width, height, dstPitch, + Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, drw_h); #endif #if XV_PROFILE - UpdateCurrentTime(); - newtime = currentTime.milliseconds; - DEBUGMSG(1, (0, X_NONE, "PI %d\n", newtime - oldtime)); + UpdateCurrentTime(); + newtime = currentTime.milliseconds; + DEBUGMSG(1, (0, X_NONE, "PI %d\n", newtime - oldtime)); #endif #if DBUF - pPriv->currentBuffer ^= 1; + pPriv->currentBuffer ^= 1; #endif - pPriv->videoStatus = CLIENT_VIDEO_ON; - pGeode->OverlayON = TRUE; - return Success; + pPriv->videoStatus = CLIENT_VIDEO_ON; + pGeode->OverlayON = TRUE; + return Success; } /*---------------------------------------------------------------------------- @@ -1292,99 +1304,99 @@ GX1PutImage(ScrnInfoPtr pScrn, */ static int GX1QueryImageAttributes(ScrnInfoPtr pScrn, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets) + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets) { - int size; - int tmp; - - DEBUGMSG(0, (0, X_NONE, "QueryImageAttributes %X\n", id)); - - if (*w > 1024) - *w = 1024; - if (*h > 1024) - *h = 1024; - - *w = (*w + 1) & ~1; - if (offsets) - 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; - case FOURCC_UYVY: - case FOURCC_YUY2: - case FOURCC_Y800: - default: - size = *w << 1; - if (pitches) - pitches[0] = size; - size *= *h; - break; - } - return size; + int size; + int tmp; + + DEBUGMSG(0, (0, X_NONE, "QueryImageAttributes %X\n", id)); + + if (*w > 1024) + *w = 1024; + if (*h > 1024) + *h = 1024; + + *w = (*w + 1) & ~1; + if (offsets) + 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; + case FOURCC_UYVY: + case FOURCC_YUY2: + case FOURCC_Y800: + default: + size = *w << 1; + if (pitches) + pitches[0] = size; + size *= *h; + break; + } + return size; } static void GX1BlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) { - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrn = xf86Screens[i]; - GeodePtr pGeode = GEODEPTR(pScrn); - GeodePortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); - - DEBUGMSG(0, (0, X_NONE, "BlockHandler\n")); - pScreen->BlockHandler = pGeode->BlockHandler; - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); - pScreen->BlockHandler = GX1BlockHandler; - - if (!pGeode->NoAccel) GX1AccelSync(pScrn); - if (pPriv->videoStatus & TIMER_MASK) { - UpdateCurrentTime(); - if (pPriv->videoStatus & OFF_TIMER) { - if (pPriv->offTime < currentTime.milliseconds) { - GFX(set_video_enable(0)); - pPriv->videoStatus = FREE_TIMER; - pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; - } - } else { /* FREE_TIMER */ - if (pPriv->freeTime < currentTime.milliseconds) { - if (pPriv->area) { - xf86FreeOffscreenArea(pPriv->area); - pPriv->area = NULL; - } - pPriv->videoStatus = 0; - } - } - } + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + GeodePtr pGeode = GEODEPTR(pScrn); + GeodePortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); + + DEBUGMSG(0, (0, X_NONE, "BlockHandler\n")); + pScreen->BlockHandler = pGeode->BlockHandler; + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + pScreen->BlockHandler = GX1BlockHandler; + + if (!pGeode->NoAccel) + GX1AccelSync(pScrn); + if (pPriv->videoStatus & TIMER_MASK) { + UpdateCurrentTime(); + if (pPriv->videoStatus & OFF_TIMER) { + if (pPriv->offTime < currentTime.milliseconds) { + GFX(set_video_enable(0)); + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + } + } + else { /* FREE_TIMER */ + if (pPriv->freeTime < currentTime.milliseconds) { + if (pPriv->area) { + xf86FreeOffscreenArea(pPriv->area); + pPriv->area = NULL; + } + pPriv->videoStatus = 0; + } + } + } } /****************** Offscreen stuff ***************/ -typedef struct -{ - FBAreaPtr area; - FBLinearPtr linear; - Bool isOn; -} -OffscreenPrivRec, *OffscreenPrivPtr; +typedef struct { + FBAreaPtr area; + FBLinearPtr linear; + Bool isOn; +} OffscreenPrivRec, *OffscreenPrivPtr; /*---------------------------------------------------------------------------- * GX1AllocateSurface @@ -1403,142 +1415,142 @@ OffscreenPrivRec, *OffscreenPrivPtr; static int GX1AllocateSurface(ScrnInfoPtr pScrn, - int id, - unsigned short w, unsigned short h, XF86SurfacePtr surface) + int id, + unsigned short w, unsigned short h, XF86SurfacePtr surface) { - FBAreaPtr area; - int pitch, fbpitch, numlines; - OffscreenPrivPtr pPriv; - - DEBUGMSG(0, (0, X_NONE, "AllocateSurface %x\n", id)); - if ((w > 1024) || (h > 1024)) - return BadAlloc; - - w = (w + 1) & ~1; - pitch = ((w << 1) + 15) & ~15; - fbpitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; - numlines = ((pitch * h) + fbpitch - 1) / fbpitch; - - if (!(area = GX1AllocateMemory(pScrn, NULL, numlines))) - return BadAlloc; - - surface->width = w; - surface->height = h; - - if (!(surface->pitches = malloc(sizeof(int)))) - return BadAlloc; - if (!(surface->offsets = malloc(sizeof(int)))) { - free(surface->pitches); - return BadAlloc; - } - if (!(pPriv = malloc(sizeof(OffscreenPrivRec)))) { - free(surface->pitches); - free(surface->offsets); - return BadAlloc; - } - - pPriv->area = area; - pPriv->isOn = FALSE; - - surface->pScrn = pScrn; - surface->id = id; - surface->pitches[0] = pitch; - surface->offsets[0] = area->box.y1 * fbpitch; - surface->devPrivate.ptr = (pointer) pPriv; - - return Success; + FBAreaPtr area; + int pitch, fbpitch, numlines; + OffscreenPrivPtr pPriv; + + DEBUGMSG(0, (0, X_NONE, "AllocateSurface %x\n", id)); + if ((w > 1024) || (h > 1024)) + return BadAlloc; + + w = (w + 1) & ~1; + pitch = ((w << 1) + 15) & ~15; + fbpitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; + numlines = ((pitch * h) + fbpitch - 1) / fbpitch; + + if (!(area = GX1AllocateMemory(pScrn, NULL, numlines))) + return BadAlloc; + + surface->width = w; + surface->height = h; + + if (!(surface->pitches = malloc(sizeof(int)))) + return BadAlloc; + if (!(surface->offsets = malloc(sizeof(int)))) { + free(surface->pitches); + return BadAlloc; + } + if (!(pPriv = malloc(sizeof(OffscreenPrivRec)))) { + free(surface->pitches); + free(surface->offsets); + return BadAlloc; + } + + pPriv->area = area; + pPriv->isOn = FALSE; + + surface->pScrn = pScrn; + surface->id = id; + surface->pitches[0] = pitch; + surface->offsets[0] = area->box.y1 * fbpitch; + surface->devPrivate.ptr = (pointer) pPriv; + + return Success; } static int GX1StopSurface(XF86SurfacePtr surface) { - OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; + OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; - if (pPriv->isOn) { - pPriv->isOn = FALSE; - } + if (pPriv->isOn) { + pPriv->isOn = FALSE; + } - return Success; + return Success; } static int GX1FreeSurface(XF86SurfacePtr surface) { - OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; + OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; - DEBUGMSG(0, (0, X_NONE, "FreeSurface\n")); + DEBUGMSG(0, (0, X_NONE, "FreeSurface\n")); - if (pPriv->isOn) - GX1StopSurface(surface); - xf86FreeOffscreenArea(pPriv->area); - free(surface->pitches); - free(surface->offsets); - free(surface->devPrivate.ptr); + if (pPriv->isOn) + GX1StopSurface(surface); + xf86FreeOffscreenArea(pPriv->area); + free(surface->pitches); + free(surface->offsets); + free(surface->devPrivate.ptr); - return Success; + return Success; } static int -GX1GetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 * value) +GX1GetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 *value) { - return GX1GetPortAttribute(pScrn, attribute, value, - (pointer) (GET_PORT_PRIVATE(pScrn))); + return GX1GetPortAttribute(pScrn, attribute, value, + (pointer) (GET_PORT_PRIVATE(pScrn))); } static int GX1SetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 value) { - return GX1SetPortAttribute(pScrn, attribute, value, - (pointer) (GET_PORT_PRIVATE(pScrn))); + return GX1SetPortAttribute(pScrn, attribute, value, + (pointer) (GET_PORT_PRIVATE(pScrn))); } static int GX1DisplaySurface(XF86SurfacePtr surface, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, RegionPtr clipBoxes) + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, RegionPtr clipBoxes) { - OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; - ScrnInfoPtr pScrn = surface->pScrn; - GeodePortPrivPtr portPriv = GET_PORT_PRIVATE(pScrn); - INT32 x1, y1, x2, y2; - BoxRec dstBox; - - DEBUGMSG(0, (0, X_NONE, "DisplaySuface\n")); - x1 = src_x; - x2 = src_x + src_w; - y1 = src_y; - y2 = src_y + src_h; - - dstBox.x1 = drw_x; - dstBox.x2 = drw_x + drw_w; - dstBox.y1 = drw_y; - dstBox.y2 = drw_y + drw_h; - - if ((x1 >= x2) || (y1 >= y2)) - return Success; - - dstBox.x1 -= pScrn->frameX0; - dstBox.x2 -= pScrn->frameX0; - dstBox.y1 -= pScrn->frameY0; - dstBox.y2 -= pScrn->frameY0; - - xf86XVFillKeyHelper(pScrn->pScreen, portPriv->colorKey, clipBoxes); - - GX1DisplayVideo(pScrn, 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); - - pPriv->isOn = TRUE; - if (portPriv->videoStatus & CLIENT_VIDEO_ON) { - REGION_EMPTY(pScrn->pScreen, &portPriv->clip); - UpdateCurrentTime(); - portPriv->videoStatus = FREE_TIMER; - portPriv->freeTime = currentTime.milliseconds + FREE_DELAY; - } - - return Success; + OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; + ScrnInfoPtr pScrn = surface->pScrn; + GeodePortPrivPtr portPriv = GET_PORT_PRIVATE(pScrn); + INT32 x1, y1, x2, y2; + BoxRec dstBox; + + DEBUGMSG(0, (0, X_NONE, "DisplaySuface\n")); + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + if ((x1 >= x2) || (y1 >= y2)) + return Success; + + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + + xf86XVFillKeyHelper(pScrn->pScreen, portPriv->colorKey, clipBoxes); + + GX1DisplayVideo(pScrn, 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); + + pPriv->isOn = TRUE; + if (portPriv->videoStatus & CLIENT_VIDEO_ON) { + REGION_EMPTY(pScrn->pScreen, &portPriv->clip); + UpdateCurrentTime(); + portPriv->videoStatus = FREE_TIMER; + portPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + } + + return Success; } /*---------------------------------------------------------------------------- @@ -1561,25 +1573,25 @@ GX1DisplaySurface(XF86SurfacePtr surface, static void GX1InitOffscreenImages(ScreenPtr pScreen) { - XF86OffscreenImagePtr offscreenImages; - - DEBUGMSG(0, (0, X_NONE, "InitOffscreenImages\n")); - /* need to free this someplace */ - if (!(offscreenImages = malloc(sizeof(XF86OffscreenImageRec)))) - return; - - offscreenImages[0].image = &Images[0]; - offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - offscreenImages[0].alloc_surface = GX1AllocateSurface; - offscreenImages[0].free_surface = GX1FreeSurface; - offscreenImages[0].display = GX1DisplaySurface; - offscreenImages[0].stop = GX1StopSurface; - offscreenImages[0].setAttribute = GX1SetSurfaceAttribute; - offscreenImages[0].getAttribute = GX1GetSurfaceAttribute; - offscreenImages[0].max_width = 1024; - offscreenImages[0].max_height = 1024; - offscreenImages[0].num_attributes = NUM_ATTRIBUTES; - offscreenImages[0].attributes = Attributes; - - xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); + XF86OffscreenImagePtr offscreenImages; + + DEBUGMSG(0, (0, X_NONE, "InitOffscreenImages\n")); + /* need to free this someplace */ + if (!(offscreenImages = malloc(sizeof(XF86OffscreenImageRec)))) + return; + + offscreenImages[0].image = &Images[0]; + offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + offscreenImages[0].alloc_surface = GX1AllocateSurface; + offscreenImages[0].free_surface = GX1FreeSurface; + offscreenImages[0].display = GX1DisplaySurface; + offscreenImages[0].stop = GX1StopSurface; + offscreenImages[0].setAttribute = GX1SetSurfaceAttribute; + offscreenImages[0].getAttribute = GX1GetSurfaceAttribute; + offscreenImages[0].max_width = 1024; + offscreenImages[0].max_height = 1024; + offscreenImages[0].num_attributes = NUM_ATTRIBUTES; + offscreenImages[0].attributes = Attributes; + + xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); } diff --git a/src/nsc_gx2_accel.c b/src/nsc_gx2_accel.c index 90daf2c..e7f9bf0 100644 --- a/src/nsc_gx2_accel.c +++ b/src/nsc_gx2_accel.c @@ -181,6 +181,7 @@ static unsigned int gu2_xshift = 1; static unsigned int gu2_yshift = 1; static unsigned int gu2_bpp = 1; static unsigned int SetCPUToScreen = 0; + #if IMGWRITE_SUPPORT static unsigned int SetImageWriteRect = 0; #endif @@ -207,109 +208,108 @@ static XAAInfoRecPtr localRecPtr; Bool GX2AccelInit(ScreenPtr pScreen); void GX2AccelSync(ScrnInfoPtr pScreenInfo); void GX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, int color, int rop, - unsigned int planemask); + unsigned int planemask); void GX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, - int w, int h); + int w, int h); void GX2SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, - int rop, unsigned int planemask, - int trans_color); + int patternx, int patterny, + int rop, unsigned int planemask, + int trans_color); void GX2Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int x, - int y, int w, int h); + int patternx, int patterny, int x, + int y, int w, int h); void GX2SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, int patternx, - int patterny, int fg, int bg, int rop, - unsigned int planemask); + int patterny, int fg, int bg, int rop, + unsigned int planemask); void GX2Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, int patternx, - int patterny, int x, int y, int w, - int h); + int patterny, int x, int y, int w, + int h); void GX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int xdir, - int ydir, int rop, unsigned int planemask, - int transparency_color); + int ydir, int rop, unsigned int planemask, + int transparency_color); void GX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int x1, int y1, - int x2, int y2, int w, int h); + int x2, int y2, int w, int h); void GX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, int color, int rop, - unsigned int planemask); + unsigned int planemask); void GX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int length, - unsigned char *pattern); + unsigned int planemask, int length, + unsigned char *pattern); void GX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, int x1, int y1, - int absmaj, int absmin, int err, int len, - int octant); + int absmaj, int absmin, int err, int len, + int octant); void GX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, int x0, int y0, - int x1, int y1, int flags); + int x1, int y1, int flags); void GX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, int x, int y, int len, - int dir); + int dir); void GX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, - int depth); + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth); void GX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft); + int x, int y, int w, int h, + int skipleft); void GX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno); void GX2FillCacheBltRects(ScrnInfoPtr pScrn, int rop, unsigned int planemask, - int nBox, BoxPtr pBox, int xorg, int yorg, - XAACacheInfoPtr pCache); + int nBox, BoxPtr pBox, int xorg, int yorg, + XAACacheInfoPtr pCache); void GX2SetupForImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth); + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth); void GX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, int skipleft); + int x, int y, int w, int h, int skipleft); void GX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, - int fg, int bg, int rop, - unsigned int planemask); + int fg, int bg, int rop, + unsigned int planemask); void GX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft); + int x, int y, int w, int h, + int skipleft); void OPTGX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, int color, int rop, - unsigned int planemask); + unsigned int planemask); void OPTGX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, - int w, int h); + int w, int h); void OPTGX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int xdir, - int ydir, int rop, - unsigned int planemask, - int transparency_color); + int ydir, int rop, + unsigned int planemask, + int transparency_color); void OPTGX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, int x1, - int y1, int x2, int y2, int w, int h); + int y1, int x2, int y2, int w, int h); void OPTGX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, int color, int rop, - unsigned int planemask); + unsigned int planemask); void OPTGX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int length, - unsigned char *pattern); + unsigned int planemask, int length, + unsigned char *pattern); void OPTGX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, int x1, int y1, - int absmaj, int absmin, int err, int len, - int octant); + int absmaj, int absmin, int err, int len, + int octant); void OPTGX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, - int x0, int y0, int x1, int y1, - int flags); + int x0, int y0, int x1, int y1, + int flags); void OPTGX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, int x, int y, - int len, int dir); + int len, int dir); void OPTGX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, - int depth); + int rop, unsigned int planemask, + int transparency_color, int bpp, + int depth); void OPTGX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft); + int x, int y, int w, int h, + int skipleft); void OPTGX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno); void OPTGX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, - int fg, int bg, int rop, - unsigned int planemask); + int fg, int bg, int rop, + unsigned int planemask); void OPTGX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft); + int x, int y, int w, int h, + int skipleft); void OPTGX2SetupForImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth); + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth); void OPTGX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, int skipleft); + int x, int y, int w, int h, int skipleft); /*---------------------------------------------------------------------------- * GX2AccelSync. @@ -329,36 +329,36 @@ void OPTGX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, void GX2AccelSync(ScrnInfoPtr pScreenInfo) { - if (SetCPUToScreen) { + if (SetCPUToScreen) { #if defined(OPT_ACCEL) - WRITE_GP32(MGP_BLT_MODE, Geode_blt_mode | - MGP_BM_SRC_FB | MGP_BM_SRC_MONO); + WRITE_GP32(MGP_BLT_MODE, Geode_blt_mode | + MGP_BM_SRC_FB | MGP_BM_SRC_MONO); #else - GFX(mono_bitmap_to_screen_blt(0, 0, Geodedstx, Geodedsty, - Geodewidth, Geodeheight, - localRecPtr->ColorExpandBase, - ((Geodewidth + 31) >> 5) << 2)); + GFX(mono_bitmap_to_screen_blt(0, 0, Geodedstx, Geodedsty, + Geodewidth, Geodeheight, + localRecPtr->ColorExpandBase, + ((Geodewidth + 31) >> 5) << 2)); #endif - SetCPUToScreen = 0; - } + SetCPUToScreen = 0; + } #if IMGWRITE_SUPPORT - if (SetImageWriteRect) { - unsigned long srcpitch; + if (SetImageWriteRect) { + unsigned long srcpitch; #if defined(OPT_ACCEL) - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - srcpitch = ((Geodewidth << gu2_xshift) + 3) & 0xFFFFFFFC; - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_STRIDE, (srcpitch << 16) | pGeode->Pitch); - WRITE_GP32(MGP_SRC_OFFSET, ImgBufOffset); - WRITE_GP32(MGP_DST_OFFSET, - (CALC_FBOFFSET(Geodedstx, Geodedsty)) & 0x00FFFFFF); - WRITE_GP32(MGP_WID_HEIGHT, - ((unsigned long)Geodewidth << 16) | (unsigned long) - Geodeheight); + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + srcpitch = ((Geodewidth << gu2_xshift) + 3) & 0xFFFFFFFC; + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_STRIDE, (srcpitch << 16) | pGeode->Pitch); + WRITE_GP32(MGP_SRC_OFFSET, ImgBufOffset); + WRITE_GP32(MGP_DST_OFFSET, + (CALC_FBOFFSET(Geodedstx, Geodedsty)) & 0x00FFFFFF); + WRITE_GP32(MGP_WID_HEIGHT, + ((unsigned long) Geodewidth << 16) | (unsigned long) + Geodeheight); /* ErrorF("%d %d, %d\n", Geodewidth, Geodeheight, gu2_xshift); ErrorF("%X , %X %X %X %X\n", srcpitch, ((srcpitch << 16) | @@ -367,19 +367,19 @@ GX2AccelSync(ScrnInfoPtr pScreenInfo) ((unsigned long)Geodewidth << 16) | (unsigned long)Geodeheight); */ - WRITE_GP32(MGP_BLT_MODE, Geode_blt_mode); + WRITE_GP32(MGP_BLT_MODE, Geode_blt_mode); #else - srcpitch = ((Geodewidth << gu2_xshift) + 3) & 0xFFFFFFFC; - GFX2(set_source_stride(srcpitch)); - GFX2(screen_to_screen_blt(ImgBufOffset, - CALC_FBOFFSET(Geodedstx, Geodedsty), - Geodewidth, Geodeheight, 0)); + srcpitch = ((Geodewidth << gu2_xshift) + 3) & 0xFFFFFFFC; + GFX2(set_source_stride(srcpitch)); + GFX2(screen_to_screen_blt(ImgBufOffset, + CALC_FBOFFSET(Geodedstx, Geodedsty), + Geodewidth, Geodeheight, 0)); #endif - SetImageWriteRect = 0; - } -#endif /* IMGWRITE_SUPPORT */ + SetImageWriteRect = 0; + } +#endif /* IMGWRITE_SUPPORT */ - GFX(wait_until_idle()); + GFX(wait_until_idle()); } /*---------------------------------------------------------------------------- @@ -403,19 +403,20 @@ GX2AccelSync(ScrnInfoPtr pScreenInfo) */ void GX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - GFX(set_solid_pattern((unsigned int)color)); - - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ - if (planemask == 0xFFFFFFFF) { - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } else { - /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ - GFX(set_solid_source((unsigned int)planemask)); - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } + GFX(set_solid_pattern((unsigned int) color)); + + /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ + if (planemask == 0xFFFFFFFF) { + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } + else { + /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ + GFX(set_solid_source((unsigned int) planemask)); + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } } /*---------------------------------------------------------------------------- @@ -441,15 +442,14 @@ GX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, *---------------------------------------------------------------------------- */ void -GX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, int w, - int h) +GX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, int w, int h) { - DEBUGMSG(0, (0, 0, "FillRect %d %d %dx%d\n", x, y, w, h)); + DEBUGMSG(0, (0, 0, "FillRect %d %d %dx%d\n", x, y, w, h)); - /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ + /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ - GFX(pattern_fill((unsigned short)x, (unsigned short)y, - (unsigned short)w, (unsigned short)h)); + GFX(pattern_fill((unsigned short) x, (unsigned short) y, + (unsigned short) w, (unsigned short) h)); } /*---------------------------------------------------------------------------- @@ -472,18 +472,19 @@ GX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, int x, int y, int w, void GX2SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int rop, - unsigned int planemask, int trans_color) + int patternx, int patterny, int rop, + unsigned int planemask, int trans_color) { - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ - if (planemask == 0xFFFFFFFF) { - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } else { - /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ - GFX(set_solid_source((unsigned int)planemask)); - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } + /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ + if (planemask == 0xFFFFFFFF) { + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } + else { + /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ + GFX(set_solid_source((unsigned int) planemask)); + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } } /*---------------------------------------------------------------------------- @@ -512,20 +513,20 @@ GX2SetupFor8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, */ void GX2Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int x, int y, - int w, int h) + int patternx, int patterny, int x, int y, + int w, int h) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); + GeodePtr pGeode = GEODEPTR(pScreenInfo); - DEBUGMSG(1, (0, 0, "8x8color %d %d %dx%d\n", x, y, w, h)); + DEBUGMSG(1, (0, 0, "8x8color %d %d %dx%d\n", x, y, w, h)); - /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ - /* Ignores specified pattern. */ - GFX(color_pattern_fill((unsigned short)x, (unsigned short)y, - (unsigned short)w, (unsigned short)h, - ((unsigned long *)((pGeode->FBBase + - (patterny << gu2_yshift)) + - patternx)))); + /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ + /* Ignores specified pattern. */ + GFX(color_pattern_fill((unsigned short) x, (unsigned short) y, + (unsigned short) w, (unsigned short) h, + ((unsigned long *) ((pGeode->FBBase + + (patterny << gu2_yshift)) + + patternx)))); } /*---------------------------------------------------------------------------- @@ -549,25 +550,26 @@ GX2Subsequent8x8PatternColorExpand(ScrnInfoPtr pScreenInfo, */ void GX2SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int fg, - int bg, int rop, unsigned int planemask) + int patternx, int patterny, int fg, + int bg, int rop, unsigned int planemask) { - int trans = (bg == -1); - - /* LOAD PATTERN COLORS AND DATA */ - GFX(set_mono_pattern((unsigned int)bg, (unsigned int)fg, - (unsigned int)patternx, (unsigned int)patterny, - trans)); - - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ - if (planemask == 0xFFFFFFFF) { - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } else { - /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ - GFX(set_solid_source((unsigned int)planemask)); - GFX(set_raster_operation(XAAGetPatternROP(rop))); - } + int trans = (bg == -1); + + /* LOAD PATTERN COLORS AND DATA */ + GFX(set_mono_pattern((unsigned int) bg, (unsigned int) fg, + (unsigned int) patternx, (unsigned int) patterny, + trans)); + + /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ + if (planemask == 0xFFFFFFFF) { + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } + else { + /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ + GFX(set_solid_source((unsigned int) planemask)); + GFX(set_raster_operation(XAAGetPatternROP(rop))); + } } /*---------------------------------------------------------------------------- @@ -595,15 +597,15 @@ GX2SetupFor8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, */ void GX2Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, - int patternx, int patterny, int x, int y, - int w, int h) + int patternx, int patterny, int x, int y, + int w, int h) { - DEBUGMSG(0, (0, 0, "8x8mono %d %d %dx%d\n", x, y, w, h)); + DEBUGMSG(0, (0, 0, "8x8mono %d %d %dx%d\n", x, y, w, h)); - /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ - /* Ignores specified pattern. */ - GFX(pattern_fill((unsigned short)x, (unsigned short)y, - (unsigned short)w, (unsigned short)h)); + /* SIMPLY PASS THE PARAMETERS TO THE DURANGO ROUTINE */ + /* Ignores specified pattern. */ + GFX(pattern_fill((unsigned short) x, (unsigned short) y, + (unsigned short) w, (unsigned short) h)); } /*---------------------------------------------------------------------------- @@ -627,15 +629,15 @@ GX2Subsequent8x8PatternMonoExpand(ScrnInfoPtr pScreenInfo, */ void GX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, - int xdir, int ydir, int rop, - unsigned int planemask, int transparency_color) + int xdir, int ydir, int rop, + unsigned int planemask, int transparency_color) { - GFX(set_solid_pattern(planemask)); - /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ - GFX(set_raster_operation(XAAGetCopyROP(rop))); - /* SAVE TRANSPARENCY FLAG */ - GeodeTransparent = (transparency_color == -1) ? 0 : 1; - GeodeTransColor = transparency_color; + GFX(set_solid_pattern(planemask)); + /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ + GFX(set_raster_operation(XAAGetCopyROP(rop))); + /* SAVE TRANSPARENCY FLAG */ + GeodeTransparent = (transparency_color == -1) ? 0 : 1; + GeodeTransColor = transparency_color; } @@ -667,47 +669,48 @@ GX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, */ void GX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, - int x1, int y1, int x2, int y2, int w, int h) + int x1, int y1, int x2, int y2, int w, int h) { - if (GeodeTransparent) { - /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT - * * Should only be called for the "copy" raster operation. - */ - GFX(screen_to_screen_xblt((unsigned short)x1, (unsigned short)y1, - (unsigned short)x2, (unsigned short)y2, - (unsigned short)w, (unsigned short)h, - GeodeTransColor)); - } else { - /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ - GFX(screen_to_screen_blt((unsigned short)x1, (unsigned short)y1, - (unsigned short)x2, (unsigned short)y2, - (unsigned short)w, (unsigned short)h)); - } + if (GeodeTransparent) { + /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT + * * Should only be called for the "copy" raster operation. + */ + GFX(screen_to_screen_xblt((unsigned short) x1, (unsigned short) y1, + (unsigned short) x2, (unsigned short) y2, + (unsigned short) w, (unsigned short) h, + GeodeTransColor)); + } + else { + /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ + GFX(screen_to_screen_blt((unsigned short) x1, (unsigned short) y1, + (unsigned short) x2, (unsigned short) y2, + (unsigned short) w, (unsigned short) h)); + } } void GX2SetupForImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth) + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth) { - GFX(set_solid_pattern((unsigned int)planemask)); - /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ - GFX(set_raster_operation(XAAGetCopyROP(rop))); - /* SAVE TRANSPARENCY FLAG */ - GeodeTransparent = (transparency_color == -1) ? 0 : 1; - GeodeTransColor = transparency_color; + GFX(set_solid_pattern((unsigned int) planemask)); + /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ + GFX(set_raster_operation(XAAGetCopyROP(rop))); + /* SAVE TRANSPARENCY FLAG */ + GeodeTransparent = (transparency_color == -1) ? 0 : 1; + GeodeTransColor = transparency_color; } void GX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, int skipleft) + int x, int y, int w, int h, int skipleft) { - Geodedstx = x; - Geodedsty = y; - Geodewidth = w; - Geodeheight = h; + Geodedstx = x; + Geodedsty = y; + Geodewidth = w; + Geodeheight = h; #if IMGWRITE_SUPPORT - SetImageWriteRect = 1; + SetImageWriteRect = 1; #endif } @@ -735,15 +738,15 @@ GX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, */ void GX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth) + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth) { - GFX(set_solid_pattern((unsigned int)planemask)); - /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ - GFX(set_raster_operation(XAAGetCopyROP(rop & 0x0F))); - /* SAVE TRANSPARENCY FLAG */ - GeodeTransparent = (transparency_color == -1) ? 0 : 1; - GeodeTransColor = transparency_color; + GFX(set_solid_pattern((unsigned int) planemask)); + /* SET RASTER OPERATION FOR USING PATTERN AS PLANE MASK */ + GFX(set_raster_operation(XAAGetCopyROP(rop & 0x0F))); + /* SAVE TRANSPARENCY FLAG */ + GeodeTransparent = (transparency_color == -1) ? 0 : 1; + GeodeTransColor = transparency_color; } /*---------------------------------------------------------------------------- @@ -766,13 +769,13 @@ GX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, */ void GX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, int skipleft) + int x, int y, int w, int h, int skipleft) { - Geodedstx = x; - Geodedsty = y; - Geodewidth = w; - Geodeheight = h; - GeodeCounter = 0; + Geodedstx = x; + Geodedsty = y; + Geodewidth = w; + Geodeheight = h; + GeodeCounter = 0; } /*---------------------------------------------------------------------------- @@ -799,54 +802,57 @@ GX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, void GX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) { - GeodePtr pGeode; - int blt_height = 0; - char blit = FALSE; - - pGeode = GEODEPTR(pScreenInfo); - - GeodeCounter++; - - if ((Geodeheight <= pGeode->NoOfImgBuffers) && - (GeodeCounter == Geodeheight)) { - blit = TRUE; - blt_height = Geodeheight; - } else if ((Geodeheight > pGeode->NoOfImgBuffers) - && (GeodeCounter == pGeode->NoOfImgBuffers)) { - blit = TRUE; - Geodeheight -= pGeode->NoOfImgBuffers; - blt_height = pGeode->NoOfImgBuffers; - } else - return; - - if (blit) { - blit = FALSE; - - GeodeCounter = 0; - - if (GeodeTransparent) { - /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT - * * Should only be called for the "copy" raster operation. - */ - GFX(screen_to_screen_xblt((unsigned short)Geodesrcx, - (unsigned short)Geodesrcy, - (unsigned short)Geodedstx, - (unsigned short)Geodedsty, - (unsigned short)Geodewidth, - (unsigned short)blt_height, - GeodeTransColor)); - } else { - /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ - GFX(screen_to_screen_blt((unsigned short)Geodesrcx, - (unsigned short)Geodesrcy, - (unsigned short)Geodedstx, - (unsigned short)Geodedsty, - (unsigned short)Geodewidth, - (unsigned short)blt_height)); - } - Geodedsty += blt_height; - GFX(wait_until_idle()); - } + GeodePtr pGeode; + int blt_height = 0; + char blit = FALSE; + + pGeode = GEODEPTR(pScreenInfo); + + GeodeCounter++; + + if ((Geodeheight <= pGeode->NoOfImgBuffers) && + (GeodeCounter == Geodeheight)) { + blit = TRUE; + blt_height = Geodeheight; + } + else if ((Geodeheight > pGeode->NoOfImgBuffers) + && (GeodeCounter == pGeode->NoOfImgBuffers)) { + blit = TRUE; + Geodeheight -= pGeode->NoOfImgBuffers; + blt_height = pGeode->NoOfImgBuffers; + } + else + return; + + if (blit) { + blit = FALSE; + + GeodeCounter = 0; + + if (GeodeTransparent) { + /* CALL ROUTINE FOR TRANSPARENT SCREEN TO SCREEN BLT + * * Should only be called for the "copy" raster operation. + */ + GFX(screen_to_screen_xblt((unsigned short) Geodesrcx, + (unsigned short) Geodesrcy, + (unsigned short) Geodedstx, + (unsigned short) Geodedsty, + (unsigned short) Geodewidth, + (unsigned short) blt_height, + GeodeTransColor)); + } + else { + /* CALL ROUTINE FOR NORMAL SCREEN TO SCREEN BLT */ + GFX(screen_to_screen_blt((unsigned short) Geodesrcx, + (unsigned short) Geodesrcy, + (unsigned short) Geodedstx, + (unsigned short) Geodedsty, + (unsigned short) Geodewidth, + (unsigned short) blt_height)); + } + Geodedsty += blt_height; + GFX(wait_until_idle()); + } } /*---------------------------------------------------------------------------- @@ -878,16 +884,16 @@ GX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) */ void GX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, - int fg, int bg, int rop, - unsigned int planemask) + int fg, int bg, int rop, + unsigned int planemask) { - GFX(set_solid_pattern(planemask)); - GFX(set_mono_source(bg, fg, (bg == -1))); + GFX(set_solid_pattern(planemask)); + GFX(set_mono_source(bg, fg, (bg == -1))); - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F))); + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F))); - DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask)); + DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask)); } /*------------------------------------------------------------------------------- @@ -909,54 +915,54 @@ GX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, */ void GX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft) + int x, int y, int w, int h, + int skipleft) { - Geodedstx = x; - Geodedsty = y; - Geodewidth = w; - Geodeheight = h; - SetCPUToScreen = 1; + Geodedstx = x; + Geodedsty = y; + Geodewidth = w; + Geodeheight = h; + SetCPUToScreen = 1; } #if SCR2SCREXP void GX2SetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask) + int fg, int bg, int rop, + unsigned int planemask) { - GFX(set_solid_pattern(planemask)); - GFX(set_mono_source(bg, fg, (bg == -1))); + GFX(set_solid_pattern(planemask)); + GFX(set_mono_source(bg, fg, (bg == -1))); - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F))); + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetCopyROP_PM(rop & 0x0F))); - DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask)); + DEBUGMSG(0, (0, X_NONE, "%x %x %x %x\n", fg, bg, rop, planemask)); } void GX2SubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int srcx, int srcy, int offset) + int x, int y, int w, int h, + int srcx, int srcy, int offset) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - GFX(mono_bitmap_to_screen_blt(offset, 0, x, y, w, h, - (unsigned char *)(pGeode->FBBase + - CALC_FBOFFSET(srcx, srcy)), - pGeode->Pitch)); + GFX(mono_bitmap_to_screen_blt(offset, 0, x, y, w, h, + (unsigned char *) (pGeode->FBBase + + CALC_FBOFFSET(srcx, srcy)), + pGeode->Pitch)); } #endif static unsigned short vector_mode_table[] = { - VM_MAJOR_INC | VM_MINOR_INC | VM_X_MAJOR, - VM_MAJOR_INC | VM_MINOR_INC | VM_Y_MAJOR, - VM_MAJOR_INC | VM_X_MAJOR, - VM_MINOR_INC | VM_Y_MAJOR, - VM_MINOR_INC | VM_X_MAJOR, - VM_MAJOR_INC | VM_Y_MAJOR, - VM_X_MAJOR, - VM_Y_MAJOR, + VM_MAJOR_INC | VM_MINOR_INC | VM_X_MAJOR, + VM_MAJOR_INC | VM_MINOR_INC | VM_Y_MAJOR, + VM_MAJOR_INC | VM_X_MAJOR, + VM_MINOR_INC | VM_Y_MAJOR, + VM_MINOR_INC | VM_X_MAJOR, + VM_MAJOR_INC | VM_Y_MAJOR, + VM_X_MAJOR, + VM_Y_MAJOR, }; /*---------------------------------------------------------------------------- @@ -978,13 +984,13 @@ static unsigned short vector_mode_table[] = { */ void GX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - /* LOAD THE SOLID PATTERN COLOR */ - GFX(set_solid_pattern((unsigned int)color)); + /* LOAD THE SOLID PATTERN COLOR */ + GFX(set_solid_pattern((unsigned int) color)); - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(XAAGetPatternROP(rop & 0x0F))); + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(XAAGetPatternROP(rop & 0x0F))); } /*--------------------------------------------------------------------------- @@ -1014,38 +1020,38 @@ GX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, */ void GX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, - int x1, int y1, int absmaj, int absmin, int err, - int len, int octant) + int x1, int y1, int absmaj, int absmin, int err, + int len, int octant) { - int axial, init, diag; + int axial, init, diag; - DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", - x1, y1, absmaj, absmin, err, len, octant)); + DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", + x1, y1, absmaj, absmin, err, len, octant)); - /* DETERMINE BRESENHAM PARAMETERS */ + /* DETERMINE BRESENHAM PARAMETERS */ - axial = ((int)absmin << 1); - init = axial - (int)absmaj; - diag = init - (int)absmaj; + axial = ((int) absmin << 1); + init = axial - (int) absmaj; + diag = init - (int) absmaj; - /* ADJUST INITIAL ERROR - * * Adjust by -1 for certain directions so that the vector - * * hits the same pixels when drawn in either direction. - * * The Gamma value is assumed to account for the initial - * * error adjustment for clipped lines. - */ + /* ADJUST INITIAL ERROR + * * Adjust by -1 for certain directions so that the vector + * * hits the same pixels when drawn in either direction. + * * The Gamma value is assumed to account for the initial + * * error adjustment for clipped lines. + */ - init += err; + init += err; - /* CALL ROUTINE TO DRAW VECTOR */ + /* CALL ROUTINE TO DRAW VECTOR */ - GFX(bresenham_line((unsigned short)x1, - (unsigned short)y1, - (unsigned short)len, - (unsigned short)init, - (unsigned short)axial, - (unsigned short)diag, - (unsigned short)vector_mode_table[octant])); + GFX(bresenham_line((unsigned short) x1, + (unsigned short) y1, + (unsigned short) len, + (unsigned short) init, + (unsigned short) axial, + (unsigned short) diag, + (unsigned short) vector_mode_table[octant])); } @@ -1053,43 +1059,44 @@ GX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, void GX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, - int x0, int y0, int x1, int y1, int flags) + int x0, int y0, int x1, int y1, int flags) { - long dx, dy, dmaj, dmin; - long axialerr, diagerr, initerr; - unsigned short vec_flags = 0; - - dx = ABS(x1, x0); - dy = ABS(y1, y0); - if (dx >= dy) { - dmaj = dx; - dmin = dy; - vec_flags = VM_X_MAJOR; - if (x1 > x0) - vec_flags |= VM_MAJOR_INC; - if (y1 > y0) - vec_flags |= VM_MINOR_INC; - } else { - dmaj = dy; - dmin = dx; - vec_flags = VM_Y_MAJOR; - if (x1 > x0) - vec_flags |= VM_MINOR_INC; - if (y1 > y0) - vec_flags |= VM_MAJOR_INC; - } - axialerr = dmin << 1; - diagerr = (dmin - dmaj) << 1; - initerr = (dmin << 1) - dmaj; - if (!(vec_flags & VM_MINOR_INC)) - initerr--; - - GFX(bresenham_line((unsigned short)x0, - (unsigned short)y0, - (unsigned short)dmaj, - (unsigned short)initerr, - (unsigned short)axialerr, - (unsigned short)diagerr, vec_flags)); + long dx, dy, dmaj, dmin; + long axialerr, diagerr, initerr; + unsigned short vec_flags = 0; + + dx = ABS(x1, x0); + dy = ABS(y1, y0); + if (dx >= dy) { + dmaj = dx; + dmin = dy; + vec_flags = VM_X_MAJOR; + if (x1 > x0) + vec_flags |= VM_MAJOR_INC; + if (y1 > y0) + vec_flags |= VM_MINOR_INC; + } + else { + dmaj = dy; + dmin = dx; + vec_flags = VM_Y_MAJOR; + if (x1 > x0) + vec_flags |= VM_MINOR_INC; + if (y1 > y0) + vec_flags |= VM_MAJOR_INC; + } + axialerr = dmin << 1; + diagerr = (dmin - dmaj) << 1; + initerr = (dmin << 1) - dmaj; + if (!(vec_flags & VM_MINOR_INC)) + initerr--; + + GFX(bresenham_line((unsigned short) x0, + (unsigned short) y0, + (unsigned short) dmaj, + (unsigned short) initerr, + (unsigned short) axialerr, + (unsigned short) diagerr, vec_flags)); } /*--------------------------------------------------------------------------- @@ -1106,41 +1113,41 @@ GX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, */ void GX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, - int x, int y, int len, int dir) + int x, int y, int len, int dir) { - DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir)); - GFX(pattern_fill((unsigned short)x, (unsigned short)y, - (unsigned short)((dir == DEGREES_0) ? len : 1), - (unsigned short)((dir == DEGREES_0) ? 1 : len))); + DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir)); + GFX(pattern_fill((unsigned short) x, (unsigned short) y, + (unsigned short) ((dir == DEGREES_0) ? len : 1), + (unsigned short) ((dir == DEGREES_0) ? 1 : len))); } #if DASHED_SUPPORT void -BuildPattern(CARD32 pat, int len, CARD32 * pat8x8) +BuildPattern(CARD32 pat, int len, CARD32 *pat8x8) { - unsigned long i, count; - - /* find homany can fit comfortably */ - count = 32 / len; - /* add 1 for the residue */ - count++; - /* construct the mask and knock off the unwanted data */ - i = ((CARD32) 0xFFFFFFFF) << (31 - len); - pat &= i; - /* init before the show */ - pat8x8[0] = 0; - /* loop and build the pattern aray data */ - for (i = 0; i < count; i++) { - pat8x8[0] |= (pat >> (len * i)); - } - - /* equate both the array's and then adjust */ - pat8x8[1] = pat8x8[0]; - - /* how many carried from last operation */ - i = (len * count) - 32; - pat8x8[1] >>= i; - pat8x8[1] |= (pat << (len - i)); + unsigned long i, count; + + /* find homany can fit comfortably */ + count = 32 / len; + /* add 1 for the residue */ + count++; + /* construct the mask and knock off the unwanted data */ + i = ((CARD32) 0xFFFFFFFF) << (31 - len); + pat &= i; + /* init before the show */ + pat8x8[0] = 0; + /* loop and build the pattern aray data */ + for (i = 0; i < count; i++) { + pat8x8[0] |= (pat >> (len * i)); + } + + /* equate both the array's and then adjust */ + pat8x8[1] = pat8x8[0]; + + /* how many carried from last operation */ + i = (len * count) - 32; + pat8x8[1] >>= i; + pat8x8[1] |= (pat << (len - i)); } #define PAT_SHIFT(pat,n) pat >> n @@ -1164,51 +1171,52 @@ BuildPattern(CARD32 pat, int len, CARD32 * pat8x8) */ void GX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int length, - unsigned char *pattern) + unsigned int planemask, int length, + unsigned char *pattern) { - int trans = (bg == -1); - CARD32 *pat = (CARD32 *) pattern; - CARD32 pat8x8[2]; - - pat8x8[0] = pat[0]; - switch (length) { - case 2: - pat8x8[0] |= PAT_SHIFT(pat8x8[0], 2); /* fall through */ - case 4: - pat8x8[0] |= PAT_SHIFT(pat8x8[0], 4); /* fall through */ - case 8: - pat8x8[0] |= PAT_SHIFT(pat8x8[0], 8); /* fall through */ - case 16: - pat8x8[0] |= PAT_SHIFT(pat8x8[0], 16); - case 32: - pat8x8[1] = pat8x8[0]; - break; - case 64: - pat8x8[1] = pat[1]; - break; - default: - BuildPattern(pat[0], length, pat8x8); - } + int trans = (bg == -1); + CARD32 *pat = (CARD32 *) pattern; + CARD32 pat8x8[2]; + + pat8x8[0] = pat[0]; + switch (length) { + case 2: + pat8x8[0] |= PAT_SHIFT(pat8x8[0], 2); /* fall through */ + case 4: + pat8x8[0] |= PAT_SHIFT(pat8x8[0], 4); /* fall through */ + case 8: + pat8x8[0] |= PAT_SHIFT(pat8x8[0], 8); /* fall through */ + case 16: + pat8x8[0] |= PAT_SHIFT(pat8x8[0], 16); + case 32: + pat8x8[1] = pat8x8[0]; + break; + case 64: + pat8x8[1] = pat[1]; + break; + default: + BuildPattern(pat[0], length, pat8x8); + } /* ErrorF("%X %d, %X %X\n", pat[0], length, pat8x8[0], pat8x8[1]); */ - /* LOAD PATTERN COLORS AND DATA */ + /* LOAD PATTERN COLORS AND DATA */ - GFX(set_mono_pattern((unsigned int)bg, (unsigned int)fg, - pat8x8[0], pat8x8[1], (unsigned char)trans)); + GFX(set_mono_pattern((unsigned int) bg, (unsigned int) fg, + pat8x8[0], pat8x8[1], (unsigned char) trans)); - /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ + /* CHECK IF PLANEMASK IS NOT USED (ALL PLANES ENABLED) */ - if (planemask == 0xFFFFFFFF) { - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + if (planemask == 0xFFFFFFFF) { + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(windowsROPpat[rop & 0x0F])); - } else { - /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ + GFX(set_raster_operation(windowsROPpat[rop & 0x0F])); + } + else { + /* SELECT ROP THAT USES SOURCE DATA FOR PLANEMASK */ - GFX(set_raster_operation(windowsROPsrcMask[rop & 0x0F])); - } + GFX(set_raster_operation(windowsROPsrcMask[rop & 0x0F])); + } } /*--------------------------------------------------------------------------- @@ -1238,36 +1246,36 @@ GX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, */ void GX2SubsequentDashedBresenhamLine(ScrnInfoPtr pScreenInfo, - int x1, int y1, int absmaj, int absmin, - int err, int len, int octant) + int x1, int y1, int absmaj, int absmin, + int err, int len, int octant) { - int axial, init, diag; + int axial, init, diag; - DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", - x1, y1, absmaj, absmin, err, len, octant)); + DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", + x1, y1, absmaj, absmin, err, len, octant)); - /* DETERMINE BRESENHAM PARAMETERS */ + /* DETERMINE BRESENHAM PARAMETERS */ - axial = ((int)absmin << 1); - init = axial - (int)absmaj; - diag = init - (int)absmaj; + axial = ((int) absmin << 1); + init = axial - (int) absmaj; + diag = init - (int) absmaj; - /* ADJUST INITIAL ERROR - * * Adjust by -1 for certain directions so that the vector - * * hits the same pixels when drawn in either direction. - * * The Gamma value is assumed to account for the initial - * * error adjustment for clipped lines. - */ + /* ADJUST INITIAL ERROR + * * Adjust by -1 for certain directions so that the vector + * * hits the same pixels when drawn in either direction. + * * The Gamma value is assumed to account for the initial + * * error adjustment for clipped lines. + */ - init += err; + init += err; - /* CALL ROUTINE TO DRAW VECTOR */ + /* CALL ROUTINE TO DRAW VECTOR */ - gfx2_set_pattern_origin(x1, y1); - gfx2_bresenham_line(CALC_FBOFFSET(x1, y1), - (unsigned short)len, (unsigned short)init, - (unsigned short)axial, (unsigned short)diag, - (unsigned short)vector_mode_table[octant]); + gfx2_set_pattern_origin(x1, y1); + gfx2_bresenham_line(CALC_FBOFFSET(x1, y1), + (unsigned short) len, (unsigned short) init, + (unsigned short) axial, (unsigned short) diag, + (unsigned short) vector_mode_table[octant]); } #endif @@ -1315,28 +1323,29 @@ GX2SubsequentDashedBresenhamLine(ScrnInfoPtr pScreenInfo, void OPTGX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, - int fg, int bg, int rop, - unsigned int planemask) + int fg, int bg, int rop, + unsigned int planemask) { - int trans = (bg == -1); - - GeodeROP = XAAGetCopyROP_PM(rop); - - if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { - Geode_blt_mode = MGP_BM_DST_REQ; - } else { - Geode_blt_mode = 0; - } - if (trans) - GeodeROP |= MGP_RM_SRC_TRANS; - - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_PAT_COLOR_0, (unsigned long)planemask); - WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); - WRITE_GP32(MGP_SRC_COLOR_FG, fg); - WRITE_GP32(MGP_SRC_COLOR_BG, bg); + int trans = (bg == -1); + + GeodeROP = XAAGetCopyROP_PM(rop); + + if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { + Geode_blt_mode = MGP_BM_DST_REQ; + } + else { + Geode_blt_mode = 0; + } + if (trans) + GeodeROP |= MGP_RM_SRC_TRANS; + + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_PAT_COLOR_0, (unsigned long) planemask); + WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); + WRITE_GP32(MGP_SRC_COLOR_FG, fg); + WRITE_GP32(MGP_SRC_COLOR_BG, bg); } /*------------------------------------------------------------------------------- @@ -1358,18 +1367,18 @@ OPTGX2SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, */ void OPTGX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft) + int x, int y, int w, int h, + int skipleft) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_OFFSET, ((unsigned int)(localRecPtr->ColorExpandBase - - pGeode->FBBase))); - WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x, y)); - WRITE_GP32(MGP_WID_HEIGHT, (((unsigned long)w) << 16) | h); - WRITE_GP32(MGP_STRIDE, (((w + 31) >> 5) << 18) | pGeode->Pitch); - SetCPUToScreen = 1; + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_OFFSET, ((unsigned int) (localRecPtr->ColorExpandBase - + pGeode->FBBase))); + WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x, y)); + WRITE_GP32(MGP_WID_HEIGHT, (((unsigned long) w) << 16) | h); + WRITE_GP32(MGP_STRIDE, (((w + 31) >> 5) << 18) | pGeode->Pitch); + SetCPUToScreen = 1; } /*---------------------------------------------------------------------------- @@ -1394,34 +1403,36 @@ OPTGX2SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScreenInfo, */ void OPTGX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_PAT_COLOR_0, (unsigned long)color); - - WRITE_GP32(MGP_STRIDE, pGeode->Pitch); - - if (planemask == 0xFFFFFFFF) { - GeodeROP = XAAGetPatternROP(rop); - } else { - WRITE_GP32(MGP_SRC_COLOR_FG, (unsigned long)planemask); - GeodeROP = XAAGetPatternROP(rop); - } - - WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); - - Geode_blt_mode = 0; - if (!((GeodeROP & 0x33) ^ ((GeodeROP >> 2) & 0x33))) - Geode_blt_mode = MGP_BM_SRC_MONO; - - if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { - Geode_blt_mode |= MGP_BM_DST_REQ; - Geode_vector_mode = MGP_VM_DST_REQ; - } else { - Geode_vector_mode = 0; - } + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_PAT_COLOR_0, (unsigned long) color); + + WRITE_GP32(MGP_STRIDE, pGeode->Pitch); + + if (planemask == 0xFFFFFFFF) { + GeodeROP = XAAGetPatternROP(rop); + } + else { + WRITE_GP32(MGP_SRC_COLOR_FG, (unsigned long) planemask); + GeodeROP = XAAGetPatternROP(rop); + } + + WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); + + Geode_blt_mode = 0; + if (!((GeodeROP & 0x33) ^ ((GeodeROP >> 2) & 0x33))) + Geode_blt_mode = MGP_BM_SRC_MONO; + + if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { + Geode_blt_mode |= MGP_BM_DST_REQ; + Geode_vector_mode = MGP_VM_DST_REQ; + } + else { + Geode_vector_mode = 0; + } } /*---------------------------------------------------------------------------- @@ -1449,11 +1460,11 @@ OPTGX2SetupForFillRectSolid(ScrnInfoPtr pScreenInfo, */ void OPTGX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, - int x, int y, int width, int height) + int x, int y, int width, int height) { - DEBUGMSG(0, (0, 0, "FillRect %d %d %dx%d\n", x, y, width, height)); + DEBUGMSG(0, (0, 0, "FillRect %d %d %dx%d\n", x, y, width, height)); - GFX_PATTERN_FILL(x, y, width, height); + GFX_PATTERN_FILL(x, y, width, height); } /*---------------------------------------------------------------------------- @@ -1478,31 +1489,30 @@ OPTGX2SubsequentFillRectSolid(ScrnInfoPtr pScreenInfo, */ void OPTGX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, - int xdir, int ydir, int rop, - unsigned int planemask, - int transparency_color) + int xdir, int ydir, int rop, + unsigned int planemask, int transparency_color) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); + GeodePtr pGeode = GEODEPTR(pScreenInfo); - GeodeROP = XAAGetCopyROP_PM(rop); + GeodeROP = XAAGetCopyROP_PM(rop); - Geode_blt_mode = MGP_BM_SRC_FB; + Geode_blt_mode = MGP_BM_SRC_FB; - /* CALCULATE THE DIRECTION OF THE BLT */ - if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { - Geode_blt_mode |= MGP_BM_DST_REQ; - } + /* CALCULATE THE DIRECTION OF THE BLT */ + if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { + Geode_blt_mode |= MGP_BM_DST_REQ; + } - GU2_WAIT_PENDING; + GU2_WAIT_PENDING; - if (transparency_color != -1) { - WRITE_GP32(MGP_SRC_COLOR_FG, transparency_color); - WRITE_GP32(MGP_SRC_COLOR_BG, 0xFFFFFFFF); - GeodeROP = MGP_RM_SRC_TRANS | 0xCC; - } - WRITE_GP32(MGP_PAT_COLOR_0, planemask); - WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); - WRITE_GP32(MGP_STRIDE, pGeode->Pitch | (pGeode->Pitch << 16)); + if (transparency_color != -1) { + WRITE_GP32(MGP_SRC_COLOR_FG, transparency_color); + WRITE_GP32(MGP_SRC_COLOR_BG, 0xFFFFFFFF); + GeodeROP = MGP_RM_SRC_TRANS | 0xCC; + } + WRITE_GP32(MGP_PAT_COLOR_0, planemask); + WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); + WRITE_GP32(MGP_STRIDE, pGeode->Pitch | (pGeode->Pitch << 16)); } /*---------------------------------------------------------------------------- @@ -1534,49 +1544,49 @@ OPTGX2SetupForScreenToScreenCopy(ScrnInfoPtr pScreenInfo, */ void OPTGX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, - int srcx, int srcy, int dstx, int dsty, - int width, int height) + int srcx, int srcy, int dstx, int dsty, + int width, int height) { - unsigned int srcoffset, dstoffset, blt_mode, size; - - DEBUGMSG(0, (0, 0, "Scr2scr %d %d %d %d %dx%d\n", - srcx, srcy, dstx, dsty, width, height)); - - size = (((unsigned int)width) << 16) | height; - - blt_mode = Geode_blt_mode; - - if (dstx > srcx) { - blt_mode |= MGP_BM_NEG_XDIR; - srcx += width - 1; - dstx += width - 1; - } - if (dsty > srcy) { - blt_mode |= MGP_BM_NEG_YDIR; - srcy += height - 1; - dsty += height - 1; - } - - /* CALCULATE STARTING OFFSETS */ - - srcoffset = CALC_FBOFFSET(srcx, srcy); - dstoffset = CALC_FBOFFSET(dstx, dsty) & 0xFFFFFF; - - /* TURN INTO BYTE ADDRESS IF NEGATIVE X DIRECTION */ - /* This is a quirk of the hardware. */ - - if (Geode_blt_mode & MGP_BM_NEG_XDIR) { - srcoffset += (1 << gu2_xshift) - 1; - dstoffset += (1 << gu2_xshift) - 1; - } - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_SRC_OFFSET, srcoffset); - WRITE_GP32(MGP_DST_OFFSET, dstoffset); - WRITE_GP32(MGP_WID_HEIGHT, size); - WRITE_GP32(MGP_BLT_MODE, blt_mode); + unsigned int srcoffset, dstoffset, blt_mode, size; + + DEBUGMSG(0, (0, 0, "Scr2scr %d %d %d %d %dx%d\n", + srcx, srcy, dstx, dsty, width, height)); + + size = (((unsigned int) width) << 16) | height; + + blt_mode = Geode_blt_mode; + + if (dstx > srcx) { + blt_mode |= MGP_BM_NEG_XDIR; + srcx += width - 1; + dstx += width - 1; + } + if (dsty > srcy) { + blt_mode |= MGP_BM_NEG_YDIR; + srcy += height - 1; + dsty += height - 1; + } + + /* CALCULATE STARTING OFFSETS */ + + srcoffset = CALC_FBOFFSET(srcx, srcy); + dstoffset = CALC_FBOFFSET(dstx, dsty) & 0xFFFFFF; + + /* TURN INTO BYTE ADDRESS IF NEGATIVE X DIRECTION */ + /* This is a quirk of the hardware. */ + + if (Geode_blt_mode & MGP_BM_NEG_XDIR) { + srcoffset += (1 << gu2_xshift) - 1; + dstoffset += (1 << gu2_xshift) - 1; + } + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_SRC_OFFSET, srcoffset); + WRITE_GP32(MGP_DST_OFFSET, dstoffset); + WRITE_GP32(MGP_WID_HEIGHT, size); + WRITE_GP32(MGP_BLT_MODE, blt_mode); } /*---------------------------------------------------------------------------- @@ -1599,23 +1609,23 @@ OPTGX2SubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo, */ void OPTGX2SetupForImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth) + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth) { - OPTGX2SetupForScreenToScreenCopy(pScreenInfo, - 0, 0, rop, planemask, transparency_color); + OPTGX2SetupForScreenToScreenCopy(pScreenInfo, + 0, 0, rop, planemask, transparency_color); } void OPTGX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, int skipleft) + int x, int y, int w, int h, int skipleft) { - Geodedstx = x; - Geodedsty = y; - Geodewidth = w; - Geodeheight = h; + Geodedstx = x; + Geodedsty = y; + Geodewidth = w; + Geodeheight = h; #if IMGWRITE_SUPPORT - SetImageWriteRect = 1; + SetImageWriteRect = 1; #endif } @@ -1639,11 +1649,11 @@ OPTGX2SubsequentImageWriteRect(ScrnInfoPtr pScreenInfo, */ void OPTGX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth) + int rop, unsigned int planemask, + int transparency_color, int bpp, int depth) { - OPTGX2SetupForScreenToScreenCopy(pScreenInfo, - 0, 0, rop, planemask, transparency_color); + OPTGX2SetupForScreenToScreenCopy(pScreenInfo, + 0, 0, rop, planemask, transparency_color); } /*---------------------------------------------------------------------------- @@ -1665,14 +1675,13 @@ OPTGX2SetupForScanlineImageWrite(ScrnInfoPtr pScreenInfo, */ void OPTGX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, - int x, int y, int w, int h, - int skipleft) + int x, int y, int w, int h, int skipleft) { - Geodedstx = x; - Geodedsty = y; - Geodewidth = w; - Geodeheight = h; - GeodeCounter = 0; + Geodedstx = x; + Geodedsty = y; + Geodewidth = w; + Geodeheight = h; + GeodeCounter = 0; } /*---------------------------------------------------------------------------- @@ -1700,35 +1709,37 @@ OPTGX2SubsequentScanlineImageWriteRect(ScrnInfoPtr pScreenInfo, void OPTGX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) { - GeodePtr pGeode; - - int blt_height = 0; - char blit = FALSE; - - pGeode = GEODEPTR(pScreenInfo); - GeodeCounter++; - - if ((Geodeheight <= pGeode->NoOfImgBuffers) && - (GeodeCounter == Geodeheight)) { - blit = TRUE; - blt_height = Geodeheight; - } else if ((Geodeheight > pGeode->NoOfImgBuffers) - && (GeodeCounter == pGeode->NoOfImgBuffers)) { - blit = TRUE; - Geodeheight -= pGeode->NoOfImgBuffers; - blt_height = pGeode->NoOfImgBuffers; - } else - return; - - if (blit) { - blit = FALSE; - GeodeCounter = 0; - OPTGX2SubsequentScreenToScreenCopy(pScreenInfo, - Geodesrcx, Geodesrcy, Geodedstx, - Geodedsty, Geodewidth, blt_height); - Geodedsty += blt_height; - GU2_WAIT_BUSY; - } + GeodePtr pGeode; + + int blt_height = 0; + char blit = FALSE; + + pGeode = GEODEPTR(pScreenInfo); + GeodeCounter++; + + if ((Geodeheight <= pGeode->NoOfImgBuffers) && + (GeodeCounter == Geodeheight)) { + blit = TRUE; + blt_height = Geodeheight; + } + else if ((Geodeheight > pGeode->NoOfImgBuffers) + && (GeodeCounter == pGeode->NoOfImgBuffers)) { + blit = TRUE; + Geodeheight -= pGeode->NoOfImgBuffers; + blt_height = pGeode->NoOfImgBuffers; + } + else + return; + + if (blit) { + blit = FALSE; + GeodeCounter = 0; + OPTGX2SubsequentScreenToScreenCopy(pScreenInfo, + Geodesrcx, Geodesrcy, Geodedstx, + Geodedsty, Geodewidth, blt_height); + Geodedsty += blt_height; + GU2_WAIT_BUSY; + } } /*---------------------------------------------------------------------------- @@ -1750,9 +1761,9 @@ OPTGX2SubsequentImageWriteScanline(ScrnInfoPtr pScreenInfo, int bufno) */ void OPTGX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - OPTGX2SetupForFillRectSolid(pScreenInfo, color, rop, planemask); + OPTGX2SetupForFillRectSolid(pScreenInfo, color, rop, planemask); } /*--------------------------------------------------------------------------- @@ -1781,84 +1792,85 @@ OPTGX2SetupForSolidLine(ScrnInfoPtr pScreenInfo, */ void OPTGX2SubsequentBresenhamLine(ScrnInfoPtr pScreenInfo, - int x1, int y1, int absmaj, int absmin, - int err, int len, int octant) + int x1, int y1, int absmaj, int absmin, + int err, int len, int octant) { - int axial, init, diag; + int axial, init, diag; - DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", - x1, y1, absmaj, absmin, err, len, octant)); + DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", + x1, y1, absmaj, absmin, err, len, octant)); - /* DETERMINE BRESENHAM PARAMETERS */ + /* DETERMINE BRESENHAM PARAMETERS */ - axial = ((int)absmin << 1); - init = axial - (int)absmaj; - diag = init - (int)absmaj; + axial = ((int) absmin << 1); + init = axial - (int) absmaj; + diag = init - (int) absmaj; - /* ADJUST INITIAL ERROR - * * Adjust by -1 for certain directions so that the vector - * * hits the same pixels when drawn in either direction. - * * The Gamma value is assumed to account for the initial - * * error adjustment for clipped lines. - */ + /* ADJUST INITIAL ERROR + * * Adjust by -1 for certain directions so that the vector + * * hits the same pixels when drawn in either direction. + * * The Gamma value is assumed to account for the initial + * * error adjustment for clipped lines. + */ - init += err; + init += err; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x1, y1)); - WRITE_GP32(MGP_VEC_ERR, - (((unsigned long)axial) << 16) | (unsigned short)diag); - WRITE_GP32(MGP_VEC_LEN, - (((unsigned long)len) << 16) | (unsigned short)init); - WRITE_GP32(MGP_VECTOR_MODE, - (Geode_vector_mode | vector_mode_table[octant])); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x1, y1)); + WRITE_GP32(MGP_VEC_ERR, + (((unsigned long) axial) << 16) | (unsigned short) diag); + WRITE_GP32(MGP_VEC_LEN, + (((unsigned long) len) << 16) | (unsigned short) init); + WRITE_GP32(MGP_VECTOR_MODE, + (Geode_vector_mode | vector_mode_table[octant])); } void OPTGX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, - int x0, int y0, int x1, int y1, int flags) + int x0, int y0, int x1, int y1, int flags) { - long dx, dy, dmaj, dmin; - long axialerr, diagerr, initerr; - unsigned short vec_flags = 0; - - dx = ABS(x1, x0); - dy = ABS(y1, y0); - if (dx >= dy) { - dmaj = dx; - dmin = dy; - vec_flags = VM_X_MAJOR; - if (x1 > x0) - vec_flags |= VM_MAJOR_INC; - if (y1 > y0) - vec_flags |= VM_MINOR_INC; - } else { - dmaj = dy; - dmin = dx; - vec_flags = VM_Y_MAJOR; - if (x1 > x0) - vec_flags |= VM_MINOR_INC; - if (y1 > y0) - vec_flags |= VM_MAJOR_INC; - } - - axialerr = dmin << 1; - diagerr = (dmin - dmaj) << 1; - initerr = (axialerr - dmaj); - - if (!(vec_flags & VM_MINOR_INC)) - initerr--; - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x0, y0)); - WRITE_GP32(MGP_VEC_ERR, - (((unsigned long)axialerr) << 16) | (unsigned short)diagerr); - WRITE_GP32(MGP_VEC_LEN, - (((unsigned long)dmaj) << 16) | (unsigned short)initerr); - WRITE_GP32(MGP_VECTOR_MODE, (Geode_vector_mode | vec_flags)); + long dx, dy, dmaj, dmin; + long axialerr, diagerr, initerr; + unsigned short vec_flags = 0; + + dx = ABS(x1, x0); + dy = ABS(y1, y0); + if (dx >= dy) { + dmaj = dx; + dmin = dy; + vec_flags = VM_X_MAJOR; + if (x1 > x0) + vec_flags |= VM_MAJOR_INC; + if (y1 > y0) + vec_flags |= VM_MINOR_INC; + } + else { + dmaj = dy; + dmin = dx; + vec_flags = VM_Y_MAJOR; + if (x1 > x0) + vec_flags |= VM_MINOR_INC; + if (y1 > y0) + vec_flags |= VM_MAJOR_INC; + } + + axialerr = dmin << 1; + diagerr = (dmin - dmaj) << 1; + initerr = (axialerr - dmaj); + + if (!(vec_flags & VM_MINOR_INC)) + initerr--; + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x0, y0)); + WRITE_GP32(MGP_VEC_ERR, + (((unsigned long) axialerr) << 16) | (unsigned short) diagerr); + WRITE_GP32(MGP_VEC_LEN, + (((unsigned long) dmaj) << 16) | (unsigned short) initerr); + WRITE_GP32(MGP_VECTOR_MODE, (Geode_vector_mode | vec_flags)); } /*--------------------------------------------------------------------------- @@ -1875,22 +1887,22 @@ OPTGX2SubsequentSolidTwoPointLine(ScrnInfoPtr pScreenInfo, */ void OPTGX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, - int x, int y, int len, int dir) + int x, int y, int len, int dir) { - DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir)); + DEBUGMSG(0, (0, 0, "HLine %d, %d, %d, %d\n", x, y, len, dir)); #if 1 - GFX_PATTERN_FILL(x, y, - (unsigned short)((dir == DEGREES_0) ? len : 1), - (unsigned short)((dir == DEGREES_0) ? 1 : len)); + GFX_PATTERN_FILL(x, y, + (unsigned short) ((dir == DEGREES_0) ? len : 1), + (unsigned short) ((dir == DEGREES_0) ? 1 : len)); #else - GU2_WAIT_PENDING; - WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x, y)); - WRITE_GP32(MGP_VEC_ERR, 0); - WRITE_GP32(MGP_VEC_LEN, - (((unsigned long)len) << 16) | (unsigned short)-len); - WRITE_GP32(MGP_VECTOR_MODE, - (Geode_vector_mode | - vector_mode_table[(dir == DEGREES_0) ? 2 : 5])); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_DST_OFFSET, CALC_FBOFFSET(x, y)); + WRITE_GP32(MGP_VEC_ERR, 0); + WRITE_GP32(MGP_VEC_LEN, + (((unsigned long) len) << 16) | (unsigned short) -len); + WRITE_GP32(MGP_VECTOR_MODE, + (Geode_vector_mode | + vector_mode_table[(dir == DEGREES_0) ? 2 : 5])); #endif } @@ -1905,210 +1917,214 @@ OPTGX2SubsequentHorVertLine(ScrnInfoPtr pScreenInfo, */ void OPTGX2SetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int length, - unsigned char *pattern) + unsigned int planemask, int length, + unsigned char *pattern) { - GeodePtr pGeode = GEODEPTR(pScrn); - CARD32 *pat = (CARD32 *) pattern; - CARD32 pat8x8[2]; - - pat8x8[0] = pat[0]; - switch (length) { - case 2: - pat8x8[0] |= PAT_SHIFT(pat8x8[0], 2); /* fall through */ - case 4: - pat8x8[0] |= PAT_SHIFT(pat8x8[0], 4); /* fall through */ - case 8: - pat8x8[0] |= PAT_SHIFT(pat8x8[0], 8); /* fall through */ - case 16: - pat8x8[0] |= PAT_SHIFT(pat8x8[0], 16); - case 32: - pat8x8[1] = pat8x8[0]; - break; - case 64: - pat8x8[1] = pat[1]; - break; - default: - BuildPattern(pat[0], length, pat8x8); - } - /* LOAD PATTERN COLORS AND DATA */ - - /* SET PATTERN FLAGS */ - - if (planemask == 0xFFFFFFFF) { - GeodeROP = XAAGetPatternROP(rop & 0x0F); - } else { - GeodeROP = XAAGetPatternROP_PM(rop & 0x0F); - } - if (bg == -1) - GeodeROP |= MGP_RM_PAT_MONO | MGP_RM_PAT_TRANS; - else - GeodeROP |= MGP_RM_PAT_MONO; - - if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { - Geode_blt_mode = MGP_BM_DST_REQ; - Geode_vector_mode = MGP_VM_DST_REQ; - } else { - Geode_blt_mode = MGP_BM_SRC_MONO; - Geode_vector_mode = 0; - } - - /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); - WRITE_GP32(MGP_PAT_COLOR_0, bg); - WRITE_GP32(MGP_PAT_COLOR_1, fg); - WRITE_GP32(MGP_PAT_DATA_0, pat8x8[0]); - WRITE_GP32(MGP_PAT_DATA_1, pat8x8[1]); - WRITE_GP32(MGP_STRIDE, pGeode->Pitch); + GeodePtr pGeode = GEODEPTR(pScrn); + CARD32 *pat = (CARD32 *) pattern; + CARD32 pat8x8[2]; + + pat8x8[0] = pat[0]; + switch (length) { + case 2: + pat8x8[0] |= PAT_SHIFT(pat8x8[0], 2); /* fall through */ + case 4: + pat8x8[0] |= PAT_SHIFT(pat8x8[0], 4); /* fall through */ + case 8: + pat8x8[0] |= PAT_SHIFT(pat8x8[0], 8); /* fall through */ + case 16: + pat8x8[0] |= PAT_SHIFT(pat8x8[0], 16); + case 32: + pat8x8[1] = pat8x8[0]; + break; + case 64: + pat8x8[1] = pat[1]; + break; + default: + BuildPattern(pat[0], length, pat8x8); + } + /* LOAD PATTERN COLORS AND DATA */ + + /* SET PATTERN FLAGS */ + + if (planemask == 0xFFFFFFFF) { + GeodeROP = XAAGetPatternROP(rop & 0x0F); + } + else { + GeodeROP = XAAGetPatternROP_PM(rop & 0x0F); + } + if (bg == -1) + GeodeROP |= MGP_RM_PAT_MONO | MGP_RM_PAT_TRANS; + else + GeodeROP |= MGP_RM_PAT_MONO; + + if ((GeodeROP & 0x55) ^ ((GeodeROP >> 1) & 0x55)) { + Geode_blt_mode = MGP_BM_DST_REQ; + Geode_vector_mode = MGP_VM_DST_REQ; + } + else { + Geode_blt_mode = MGP_BM_SRC_MONO; + Geode_vector_mode = 0; + } + + /* POLL UNTIL ABLE TO WRITE THE PATTERN COLOR */ + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_bpp | GeodeROP); + WRITE_GP32(MGP_PAT_COLOR_0, bg); + WRITE_GP32(MGP_PAT_COLOR_1, fg); + WRITE_GP32(MGP_PAT_DATA_0, pat8x8[0]); + WRITE_GP32(MGP_PAT_DATA_1, pat8x8[1]); + WRITE_GP32(MGP_STRIDE, pGeode->Pitch); } void OPTGX2SubsequentDashedBresenhamLine(ScrnInfoPtr pScreenInfo, - int x1, int y1, int absmaj, int absmin, - int err, int len, int octant) + int x1, int y1, int absmaj, int absmin, + int err, int len, int octant) { - int axial, init, diag; - unsigned long gu2_pattern_origin; + int axial, init, diag; + unsigned long gu2_pattern_origin; - DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", - x1, y1, absmaj, absmin, err, len, octant)); + DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n", + x1, y1, absmaj, absmin, err, len, octant)); - /* CHECK NULL LENGTH */ + /* CHECK NULL LENGTH */ - if (!len) - return; + if (!len) + return; - /* DETERMINE BRESENHAM PARAMETERS */ + /* DETERMINE BRESENHAM PARAMETERS */ - axial = ((int)absmin << 1); - init = axial - (int)absmaj; - diag = init - (int)absmaj; + axial = ((int) absmin << 1); + init = axial - (int) absmaj; + diag = init - (int) absmaj; - /* ADJUST INITIAL ERROR - * * Adjust by -1 for certain directions so that the vector - * * hits the same pixels when drawn in either direction. - * * The Gamma value is assumed to account for the initial - * * error adjustment for clipped lines. - */ + /* ADJUST INITIAL ERROR + * * Adjust by -1 for certain directions so that the vector + * * hits the same pixels when drawn in either direction. + * * The Gamma value is assumed to account for the initial + * * error adjustment for clipped lines. + */ - init += err; + init += err; - /* CALL ROUTINE TO DRAW VECTOR */ + /* CALL ROUTINE TO DRAW VECTOR */ - gu2_pattern_origin = (((unsigned long)(x1 & 7)) << 26) | - (((unsigned long)(y1 & 7)) << 29); + gu2_pattern_origin = (((unsigned long) (x1 & 7)) << 26) | + (((unsigned long) (y1 & 7)) << 29); - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_DST_OFFSET, (CALC_FBOFFSET(x1, y1) & 0x00FFFFFF) | - gu2_pattern_origin); - WRITE_GP32(MGP_VEC_ERR, - (((unsigned long)axial) << 16) | (unsigned short)diag); - WRITE_GP32(MGP_VEC_LEN, - (((unsigned long)len) << 16) | (unsigned short)init); - WRITE_GP32(MGP_VECTOR_MODE, (Geode_vector_mode | - vector_mode_table[octant])); + GU2_WAIT_PENDING; + WRITE_GP32(MGP_DST_OFFSET, (CALC_FBOFFSET(x1, y1) & 0x00FFFFFF) | + gu2_pattern_origin); + WRITE_GP32(MGP_VEC_ERR, + (((unsigned long) axial) << 16) | (unsigned short) diag); + WRITE_GP32(MGP_VEC_LEN, + (((unsigned long) len) << 16) | (unsigned short) init); + WRITE_GP32(MGP_VECTOR_MODE, (Geode_vector_mode | + vector_mode_table[octant])); } void OPTGX2SubsequentDashedTwoPointLine(ScrnInfoPtr pScreenInfo, - int x0, int y0, int x1, int y1, int flags) + int x0, int y0, int x1, int y1, int flags) { - long dx, dy, dmaj, dmin; - long axialerr, diagerr, initerr; - unsigned long gu2_pattern_origin; - unsigned short vec_flags = 0; - - dx = ABS(x1, x0); - dy = ABS(y1, y0); - if (dx >= dy) { - dmaj = dx; - dmin = dy; - vec_flags = VM_X_MAJOR; - if (x1 > x0) - vec_flags |= VM_MAJOR_INC; - if (y1 > y0) - vec_flags |= VM_MINOR_INC; - } else { - dmaj = dy; - dmin = dx; - vec_flags = VM_Y_MAJOR; - if (x1 > x0) - vec_flags |= VM_MINOR_INC; - if (y1 > y0) - vec_flags |= VM_MAJOR_INC; - } - - axialerr = dmin << 1; - diagerr = (dmin - dmaj) << 1; - initerr = (axialerr - dmaj); - - if (!(vec_flags & VM_MINOR_INC)) - initerr--; - - /* CALL ROUTINE TO DRAW VECTOR */ - - gu2_pattern_origin = (((unsigned long)(x0 & 7)) << 26) | - (((unsigned long)(y0 & 7)) << 29); - - GU2_WAIT_PENDING; - WRITE_GP32(MGP_DST_OFFSET, (CALC_FBOFFSET(x0, y0) & 0x00FFFFFF) | - gu2_pattern_origin); - WRITE_GP32(MGP_VEC_ERR, - (((unsigned long)axialerr) << 16) | (unsigned short)diagerr); - WRITE_GP32(MGP_VEC_LEN, - (((unsigned long)dmaj) << 16) | (unsigned short)initerr); - WRITE_GP16(MGP_VECTOR_MODE, (Geode_vector_mode | vec_flags)); + long dx, dy, dmaj, dmin; + long axialerr, diagerr, initerr; + unsigned long gu2_pattern_origin; + unsigned short vec_flags = 0; + + dx = ABS(x1, x0); + dy = ABS(y1, y0); + if (dx >= dy) { + dmaj = dx; + dmin = dy; + vec_flags = VM_X_MAJOR; + if (x1 > x0) + vec_flags |= VM_MAJOR_INC; + if (y1 > y0) + vec_flags |= VM_MINOR_INC; + } + else { + dmaj = dy; + dmin = dx; + vec_flags = VM_Y_MAJOR; + if (x1 > x0) + vec_flags |= VM_MINOR_INC; + if (y1 > y0) + vec_flags |= VM_MAJOR_INC; + } + + axialerr = dmin << 1; + diagerr = (dmin - dmaj) << 1; + initerr = (axialerr - dmaj); + + if (!(vec_flags & VM_MINOR_INC)) + initerr--; + + /* CALL ROUTINE TO DRAW VECTOR */ + + gu2_pattern_origin = (((unsigned long) (x0 & 7)) << 26) | + (((unsigned long) (y0 & 7)) << 29); + + GU2_WAIT_PENDING; + WRITE_GP32(MGP_DST_OFFSET, (CALC_FBOFFSET(x0, y0) & 0x00FFFFFF) | + gu2_pattern_origin); + WRITE_GP32(MGP_VEC_ERR, + (((unsigned long) axialerr) << 16) | (unsigned short) diagerr); + WRITE_GP32(MGP_VEC_LEN, + (((unsigned long) dmaj) << 16) | (unsigned short) initerr); + WRITE_GP16(MGP_VECTOR_MODE, (Geode_vector_mode | vec_flags)); } -#endif /* DASHED_SUPPORT */ -#endif /* STB_X */ +#endif /* DASHED_SUPPORT */ +#endif /* STB_X */ #if 0 void GX2WriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, - unsigned char *src, int srcwidth, int skipleft, - int fg, int bg, int rop, unsigned int planemask) + unsigned char *src, int srcwidth, int skipleft, + int fg, int bg, int rop, unsigned int planemask) { - GFX(set_solid_pattern(planemask)); - GFX(set_mono_source(bg, fg, (bg == -1))); + GFX(set_solid_pattern(planemask)); + GFX(set_mono_source(bg, fg, (bg == -1))); - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(windowsROPpatMask[rop & 0x0F])); - GFX(mono_bitmap_to_screen_blt_swp(0, 0, x, y, - srcwidth << 3, h, src, srcwidth)); + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(windowsROPpatMask[rop & 0x0F])); + GFX(mono_bitmap_to_screen_blt_swp(0, 0, x, y, + srcwidth << 3, h, src, srcwidth)); } void -GX2WritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, /* bytes */ - int rop, unsigned int planemask, int trans, int bpp, int depth) +GX2WritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, /* bytes */ + int rop, unsigned int planemask, int trans, int bpp, int depth) { - /* - * ErrorF("GX2WritePixmap %d %d %d %d %X %d %d %d, %d\n", - * x, y, w, h, src, srcwidth, bpp, depth, trans); - */ - GFX(set_solid_pattern(planemask)); - - /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ - GFX(set_raster_operation(windowsROPpatMask[rop & 0x0F])); - if (trans == -1) { - GFX(color_bitmap_to_screen_blt(0, 0, x, y, w, h, src, srcwidth)); - } else { - GFX(color_bitmap_to_screen_xblt(0, 0, x, y, w, h, src, - srcwidth, trans)); - } + /* + * ErrorF("GX2WritePixmap %d %d %d %d %X %d %d %d, %d\n", + * x, y, w, h, src, srcwidth, bpp, depth, trans); + */ + GFX(set_solid_pattern(planemask)); + + /* USE NORMAL PATTERN ROPs IF ALL PLANES ARE ENABLED */ + GFX(set_raster_operation(windowsROPpatMask[rop & 0x0F])); + if (trans == -1) { + GFX(color_bitmap_to_screen_blt(0, 0, x, y, w, h, src, srcwidth)); + } + else { + GFX(color_bitmap_to_screen_xblt(0, 0, x, y, w, h, src, + srcwidth, trans)); + } } void GX2ReadPixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, - unsigned char *dst, int dstwidth, int bpp, int depth) + unsigned char *dst, int dstwidth, int bpp, int depth) { - ErrorF("GX2ReadPixmap %d %d %d %d %X %d %d %d\n", - x, y, w, h, dst, dstwidth, bpp, depth); + ErrorF("GX2ReadPixmap %d %d %d %d %X %d %d %d\n", + x, y, w, h, dst, dstwidth, bpp, depth); } #endif /**************************************************************************/ @@ -2131,175 +2147,174 @@ GX2ReadPixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, Bool GX2AccelInit(ScreenPtr pScreen) { - GeodePtr pGeode; - ScrnInfoPtr pScreenInfo; - - pScreenInfo = xf86Screens[pScreen->myNum]; - pGeode = GEODEPTR(pScreenInfo); - - switch (pScreenInfo->bitsPerPixel) { - case 8: - gu2_bpp = MGP_RM_BPPFMT_332; - break; - case 16: - gu2_bpp = MGP_RM_BPPFMT_565; - break; - case 32: - gu2_bpp = MGP_RM_BPPFMT_8888; - break; - } - - gu2_xshift = pScreenInfo->bitsPerPixel >> 4; - - switch (pGeode->Pitch) { - case 1024: - gu2_yshift = 10; - break; - case 2048: - gu2_yshift = 11; - break; - case 4096: - gu2_yshift = 12; - break; - case 8192: - gu2_yshift = 13; - break; - } - - /* Getting the pointer for acceleration Inforecord */ - pGeode->AccelInfoRec = localRecPtr = XAACreateInfoRec(); - - /* SET ACCELERATION FLAGS */ - localRecPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER; - - /* HOOK SYNCRONIZARION ROUTINE */ - localRecPtr->Sync = GX2AccelSync; - - /* HOOK FILLED RECTANGLES */ - localRecPtr->SetupForSolidFill = OPTACCEL(GX2SetupForFillRectSolid); - localRecPtr->SubsequentSolidFillRect = - OPTACCEL(GX2SubsequentFillRectSolid); - localRecPtr->SolidFillFlags = 0; - - /* HOOK 8x8 Mono EXPAND PATTERNS */ - localRecPtr->SetupForMono8x8PatternFill = GX2SetupFor8x8PatternMonoExpand; - localRecPtr->SubsequentMono8x8PatternFillRect = - GX2Subsequent8x8PatternMonoExpand; - localRecPtr->Mono8x8PatternFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST | - HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN; - - localRecPtr->SetupForColor8x8PatternFill = - GX2SetupFor8x8PatternColorExpand; - localRecPtr->SubsequentColor8x8PatternFillRect = - GX2Subsequent8x8PatternColorExpand; - /* Color expansion */ - localRecPtr->Color8x8PatternFillFlags = - BIT_ORDER_IN_BYTE_MSBFIRST | - SCANLINE_PAD_DWORD | HARDWARE_PATTERN_SCREEN_ORIGIN; - - /* HOOK SCREEN TO SCREEN COPIES - * * Set flag to only allow copy if transparency is enabled. - */ - localRecPtr->SetupForScreenToScreenCopy = - OPTACCEL(GX2SetupForScreenToScreenCopy); - localRecPtr->SubsequentScreenToScreenCopy = - OPTACCEL(GX2SubsequentScreenToScreenCopy); - localRecPtr->ScreenToScreenCopyFlags = 0; - - /* HOOK BRESENHAM SOLID LINES */ - /* Do not hook unless flag can be set preventing use of planemask. */ - localRecPtr->SolidLineFlags = NO_PLANEMASK; - localRecPtr->SetupForSolidLine = OPTACCEL(GX2SetupForSolidLine); - localRecPtr->SubsequentSolidBresenhamLine = - OPTACCEL(GX2SubsequentBresenhamLine); - localRecPtr->SubsequentSolidHorVertLine = - OPTACCEL(GX2SubsequentHorVertLine); - localRecPtr->SubsequentSolidTwoPointLine = - OPTACCEL(GX2SubsequentSolidTwoPointLine); - localRecPtr->SolidBresenhamLineErrorTermBits = 15; + GeodePtr pGeode; + ScrnInfoPtr pScreenInfo; + + pScreenInfo = xf86Screens[pScreen->myNum]; + pGeode = GEODEPTR(pScreenInfo); + + switch (pScreenInfo->bitsPerPixel) { + case 8: + gu2_bpp = MGP_RM_BPPFMT_332; + break; + case 16: + gu2_bpp = MGP_RM_BPPFMT_565; + break; + case 32: + gu2_bpp = MGP_RM_BPPFMT_8888; + break; + } + + gu2_xshift = pScreenInfo->bitsPerPixel >> 4; + + switch (pGeode->Pitch) { + case 1024: + gu2_yshift = 10; + break; + case 2048: + gu2_yshift = 11; + break; + case 4096: + gu2_yshift = 12; + break; + case 8192: + gu2_yshift = 13; + break; + } + + /* Getting the pointer for acceleration Inforecord */ + pGeode->AccelInfoRec = localRecPtr = XAACreateInfoRec(); + + /* SET ACCELERATION FLAGS */ + localRecPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER; + + /* HOOK SYNCRONIZARION ROUTINE */ + localRecPtr->Sync = GX2AccelSync; + + /* HOOK FILLED RECTANGLES */ + localRecPtr->SetupForSolidFill = OPTACCEL(GX2SetupForFillRectSolid); + localRecPtr->SubsequentSolidFillRect = OPTACCEL(GX2SubsequentFillRectSolid); + localRecPtr->SolidFillFlags = 0; + + /* HOOK 8x8 Mono EXPAND PATTERNS */ + localRecPtr->SetupForMono8x8PatternFill = GX2SetupFor8x8PatternMonoExpand; + localRecPtr->SubsequentMono8x8PatternFillRect = + GX2Subsequent8x8PatternMonoExpand; + localRecPtr->Mono8x8PatternFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST | + HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN; + + localRecPtr->SetupForColor8x8PatternFill = GX2SetupFor8x8PatternColorExpand; + localRecPtr->SubsequentColor8x8PatternFillRect = + GX2Subsequent8x8PatternColorExpand; + /* Color expansion */ + localRecPtr->Color8x8PatternFillFlags = + BIT_ORDER_IN_BYTE_MSBFIRST | + SCANLINE_PAD_DWORD | HARDWARE_PATTERN_SCREEN_ORIGIN; + + /* HOOK SCREEN TO SCREEN COPIES + * * Set flag to only allow copy if transparency is enabled. + */ + localRecPtr->SetupForScreenToScreenCopy = + OPTACCEL(GX2SetupForScreenToScreenCopy); + localRecPtr->SubsequentScreenToScreenCopy = + OPTACCEL(GX2SubsequentScreenToScreenCopy); + localRecPtr->ScreenToScreenCopyFlags = 0; + + /* HOOK BRESENHAM SOLID LINES */ + /* Do not hook unless flag can be set preventing use of planemask. */ + localRecPtr->SolidLineFlags = NO_PLANEMASK; + localRecPtr->SetupForSolidLine = OPTACCEL(GX2SetupForSolidLine); + localRecPtr->SubsequentSolidBresenhamLine = + OPTACCEL(GX2SubsequentBresenhamLine); + localRecPtr->SubsequentSolidHorVertLine = + OPTACCEL(GX2SubsequentHorVertLine); + localRecPtr->SubsequentSolidTwoPointLine = + OPTACCEL(GX2SubsequentSolidTwoPointLine); + localRecPtr->SolidBresenhamLineErrorTermBits = 15; #if DASHED_SUPPORT - localRecPtr->SetupForDashedLine = OPTACCEL(GX2SetupForDashedLine); - localRecPtr->SubsequentDashedBresenhamLine = - OPTACCEL(GX2SubsequentDashedBresenhamLine); - localRecPtr->SubsequentSolidTwoPointLine = - OPTACCEL(GX2SubsequentDashedTwoPointLine); - localRecPtr->DashedBresenhamLineErrorTermBits = 15; - localRecPtr->DashPatternMaxLength = 64; - localRecPtr->DashedLineFlags = NO_PLANEMASK | - LINE_PATTERN_POWER_OF_2_ONLY | LINE_PATTERN_MSBFIRST_MSBJUSTIFIED; + localRecPtr->SetupForDashedLine = OPTACCEL(GX2SetupForDashedLine); + localRecPtr->SubsequentDashedBresenhamLine = + OPTACCEL(GX2SubsequentDashedBresenhamLine); + localRecPtr->SubsequentSolidTwoPointLine = + OPTACCEL(GX2SubsequentDashedTwoPointLine); + localRecPtr->DashedBresenhamLineErrorTermBits = 15; + localRecPtr->DashPatternMaxLength = 64; + localRecPtr->DashedLineFlags = NO_PLANEMASK | + LINE_PATTERN_POWER_OF_2_ONLY | LINE_PATTERN_MSBFIRST_MSBJUSTIFIED; #endif #if SCR2SCREXP - /* Color expansion */ - localRecPtr->ScreenToScreenColorExpandFillFlags = - BIT_ORDER_IN_BYTE_MSBFIRST | NO_TRANSPARENCY; - - localRecPtr->SetupForScreenToScreenColorExpandFill = - (GX2SetupForScreenToScreenColorExpandFill); - localRecPtr->SubsequentScreenToScreenColorExpandFill = - (GX2SubsequentScreenToScreenColorExpandFill); + /* Color expansion */ + localRecPtr->ScreenToScreenColorExpandFillFlags = + BIT_ORDER_IN_BYTE_MSBFIRST | NO_TRANSPARENCY; + + localRecPtr->SetupForScreenToScreenColorExpandFill = + (GX2SetupForScreenToScreenColorExpandFill); + localRecPtr->SubsequentScreenToScreenColorExpandFill = + (GX2SubsequentScreenToScreenColorExpandFill); #endif - /* - * ImageWrite. - * - * SInce this uses off-screen scanline buffers, it is only of use when - * complex ROPs are used. But since the current XAA pixmap cache code - * only works when an ImageWrite is provided, the NO_GXCOPY flag is - * temporarily disabled. - */ - if (pGeode->AccelImageWriteBufferOffsets) { - /* Color expansion */ - localRecPtr->CPUToScreenColorExpandFillFlags = - BIT_ORDER_IN_BYTE_MSBFIRST | - NO_PLANEMASK | SYNC_AFTER_COLOR_EXPAND | SCANLINE_PAD_DWORD; - localRecPtr->ColorExpandBase = pGeode->AccelImageWriteBufferOffsets[0]; - localRecPtr->ColorExpandRange = pGeode->NoOfImgBuffers << gu2_yshift; - - localRecPtr->SetupForCPUToScreenColorExpandFill = - OPTACCEL(GX2SetupForCPUToScreenColorExpandFill); - localRecPtr->SubsequentCPUToScreenColorExpandFill = - OPTACCEL(GX2SubsequentCPUToScreenColorExpandFill); + /* + * ImageWrite. + * + * SInce this uses off-screen scanline buffers, it is only of use when + * complex ROPs are used. But since the current XAA pixmap cache code + * only works when an ImageWrite is provided, the NO_GXCOPY flag is + * temporarily disabled. + */ + if (pGeode->AccelImageWriteBufferOffsets) { + /* Color expansion */ + localRecPtr->CPUToScreenColorExpandFillFlags = + BIT_ORDER_IN_BYTE_MSBFIRST | + NO_PLANEMASK | SYNC_AFTER_COLOR_EXPAND | SCANLINE_PAD_DWORD; + localRecPtr->ColorExpandBase = pGeode->AccelImageWriteBufferOffsets[0]; + localRecPtr->ColorExpandRange = pGeode->NoOfImgBuffers << gu2_yshift; + + localRecPtr->SetupForCPUToScreenColorExpandFill = + OPTACCEL(GX2SetupForCPUToScreenColorExpandFill); + localRecPtr->SubsequentCPUToScreenColorExpandFill = + OPTACCEL(GX2SubsequentCPUToScreenColorExpandFill); #if IMGWRITE_SUPPORT - localRecPtr->ImageWriteFlags = NO_PLANEMASK | - SCANLINE_PAD_DWORD | SYNC_AFTER_IMAGE_WRITE; - localRecPtr->ImageWriteBase = pGeode->AccelImageWriteBufferOffsets[0]; - localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu2_yshift; - localRecPtr->SetupForImageWrite = OPTACCEL(GX2SetupForImageWrite); - localRecPtr->SubsequentImageWriteRect = - OPTACCEL(GX2SubsequentImageWriteRect); -#endif /* IMGWRITE_SUPPORT */ - - localRecPtr->ScanlineImageWriteFlags = - localRecPtr->ScreenToScreenCopyFlags; - localRecPtr->ScanlineImageWriteBuffers = - pGeode->AccelImageWriteBufferOffsets; - localRecPtr->NumScanlineImageWriteBuffers = pGeode->NoOfImgBuffers; - localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu2_yshift; - localRecPtr->SetupForScanlineImageWrite = - OPTACCEL(GX2SetupForScanlineImageWrite); - localRecPtr->SubsequentScanlineImageWriteRect = - OPTACCEL(GX2SubsequentScanlineImageWriteRect); - localRecPtr->SubsequentImageWriteScanline = - OPTACCEL(GX2SubsequentImageWriteScanline); - - ImgBufOffset = pGeode->AccelImageWriteBufferOffsets[0] - pGeode->FBBase; - Geodesrcy = ImgBufOffset >> gu2_yshift; - - Geodesrcx = ImgBufOffset & (pGeode->Pitch - 1); - Geodesrcx /= (pScreenInfo->bitsPerPixel >> 3); - } else { - localRecPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES; - } + localRecPtr->ImageWriteFlags = NO_PLANEMASK | + SCANLINE_PAD_DWORD | SYNC_AFTER_IMAGE_WRITE; + localRecPtr->ImageWriteBase = pGeode->AccelImageWriteBufferOffsets[0]; + localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu2_yshift; + localRecPtr->SetupForImageWrite = OPTACCEL(GX2SetupForImageWrite); + localRecPtr->SubsequentImageWriteRect = + OPTACCEL(GX2SubsequentImageWriteRect); +#endif /* IMGWRITE_SUPPORT */ + + localRecPtr->ScanlineImageWriteFlags = + localRecPtr->ScreenToScreenCopyFlags; + localRecPtr->ScanlineImageWriteBuffers = + pGeode->AccelImageWriteBufferOffsets; + localRecPtr->NumScanlineImageWriteBuffers = pGeode->NoOfImgBuffers; + localRecPtr->ImageWriteRange = pGeode->NoOfImgBuffers << gu2_yshift; + localRecPtr->SetupForScanlineImageWrite = + OPTACCEL(GX2SetupForScanlineImageWrite); + localRecPtr->SubsequentScanlineImageWriteRect = + OPTACCEL(GX2SubsequentScanlineImageWriteRect); + localRecPtr->SubsequentImageWriteScanline = + OPTACCEL(GX2SubsequentImageWriteScanline); + + ImgBufOffset = pGeode->AccelImageWriteBufferOffsets[0] - pGeode->FBBase; + Geodesrcy = ImgBufOffset >> gu2_yshift; + + Geodesrcx = ImgBufOffset & (pGeode->Pitch - 1); + Geodesrcx /= (pScreenInfo->bitsPerPixel >> 3); + } + else { + localRecPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES; + } #if 0 #if !defined(STB_X) - localRecPtr->WriteBitmap = GX2WriteBitmap; + localRecPtr->WriteBitmap = GX2WriteBitmap; #endif - localRecPtr->WritePixmap = GX2WritePixmap; - localRecPtr->ReadPixmap = GX2ReadPixmap; + localRecPtr->WritePixmap = GX2WritePixmap; + localRecPtr->ReadPixmap = GX2ReadPixmap; #endif - return (XAAInit(pScreen, localRecPtr)); + return (XAAInit(pScreen, localRecPtr)); } /* END OF FILE */ diff --git a/src/nsc_gx2_cursor.c b/src/nsc_gx2_cursor.c index 6a3a828..ce1e7eb 100644 --- a/src/nsc_gx2_cursor.c +++ b/src/nsc_gx2_cursor.c @@ -159,9 +159,9 @@ void GX2HideCursor(ScrnInfoPtr pScreenInfo); void GX2ShowCursor(ScrnInfoPtr pScreenInfo); static Bool GX2UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs); extern void GX2SetVideoPosition(int x, int y, int width, int height, - short src_w, short src_h, short drw_w, - short drw_h, int id, int offset, - ScrnInfoPtr pScrn); + short src_w, short src_h, short drw_w, + short drw_h, int id, int offset, + ScrnInfoPtr pScrn); /*---------------------------------------------------------------------------- * GX2HWCursorInit. @@ -181,31 +181,31 @@ extern void GX2SetVideoPosition(int x, int y, int width, int height, Bool GX2HWCursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; - GeodePtr pGeode = GEODEPTR(pScreenInfo); - xf86CursorInfoPtr infoPtr; + ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; + GeodePtr pGeode = GEODEPTR(pScreenInfo); + xf86CursorInfoPtr infoPtr; - infoPtr = xf86CreateCursorInfoRec(); - if (!infoPtr) - 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; - /* cursor info ptr is intiallized with the values obtained from - * * durnago calls - */ - infoPtr->SetCursorColors = GX2SetCursorColors; - infoPtr->SetCursorPosition = GX2SetCursorPosition; - infoPtr->LoadCursorImage = GX2LoadCursorImage; - infoPtr->HideCursor = GX2HideCursor; - infoPtr->ShowCursor = GX2ShowCursor; - infoPtr->UseHWCursor = GX2UseHWCursor; - return (xf86InitCursor(pScreen, infoPtr)); + infoPtr = xf86CreateCursorInfoRec(); + if (!infoPtr) + 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; + /* cursor info ptr is intiallized with the values obtained from + * * durnago calls + */ + infoPtr->SetCursorColors = GX2SetCursorColors; + infoPtr->SetCursorPosition = GX2SetCursorPosition; + infoPtr->LoadCursorImage = GX2LoadCursorImage; + infoPtr->HideCursor = GX2HideCursor; + infoPtr->ShowCursor = GX2ShowCursor; + infoPtr->UseHWCursor = GX2UseHWCursor; + return (xf86InitCursor(pScreen, infoPtr)); } /*---------------------------------------------------------------------------- @@ -226,7 +226,7 @@ GX2HWCursorInit(ScreenPtr pScreen) static void GX2SetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg) { - GFX(set_cursor_colors(bg, fg)); + GFX(set_cursor_colors(bg, fg)); } /*---------------------------------------------------------------------------- @@ -246,40 +246,40 @@ GX2SetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg) static void GX2SetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y) { - unsigned long offset; - static int panOffset = 0; - GeodePtr pGeode = GEODEPTR(pScreenInfo); + unsigned long offset; + static int panOffset = 0; + GeodePtr pGeode = GEODEPTR(pScreenInfo); - unsigned short xhot = 0, yhot = 0; + unsigned short xhot = 0, yhot = 0; - if (x < 0) { - xhot = (unsigned short)(-x); - x = 0; - } - if (y < 0) { - yhot = (unsigned short)(-y); - y = 0; - } + if (x < 0) { + xhot = (unsigned short) (-x); + x = 0; + } + if (y < 0) { + yhot = (unsigned short) (-y); + y = 0; + } - GFX(set_cursor_position(pGeode->CursorStartOffset, x, y, xhot, yhot)); - GFX(set_cursor_enable(1)); + GFX(set_cursor_position(pGeode->CursorStartOffset, x, y, xhot, yhot)); + GFX(set_cursor_enable(1)); - if ((pGeode->OverlayON) && (pGeode->Panel)) { + if ((pGeode->OverlayON) && (pGeode->Panel)) { #if defined(STB_X) - Gal_get_display_offset(&offset); + Gal_get_display_offset(&offset); #else - offset = gfx_get_display_offset(); + offset = gfx_get_display_offset(); #endif - if (offset != panOffset) { - GX2SetVideoPosition(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 = offset; - } - } + if (offset != panOffset) { + GX2SetVideoPosition(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 = offset; + } + } } /*---------------------------------------------------------------------------- @@ -298,33 +298,34 @@ GX2SetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y) void GX2LoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char *src) { - int i; - unsigned long shape; - unsigned long mask; - unsigned long andMask[32] = { 0, }; - unsigned long xorMask[32] = { 0, }; - GeodePtr pGeode = GEODEPTR(pScreenInfo); + int i; + unsigned long shape; + unsigned long mask; + unsigned long andMask[32] = { 0, }; + unsigned long xorMask[32] = { 0, }; + GeodePtr pGeode = GEODEPTR(pScreenInfo); - for (i = 0; i < 32; i++) { - if (src) { - shape = ((unsigned long)src[i * 4] << 24) | - ((unsigned long)src[i * 4 + 1] << 16) | - ((unsigned long)src[i * 4 + 2] << 8) | - ((unsigned long)src[i * 4 + 3] << 0); - mask = ((unsigned long)src[i * 4 + 128] << 24) | - ((unsigned long)src[i * 4 + 1 + 128] << 16) | - ((unsigned long)src[i * 4 + 2 + 128] << 8) | - ((unsigned long)src[i * 4 + 3 + 128] << 0); - } else { - mask = 0x0; - shape = 0xFFFFFFFF; - } + for (i = 0; i < 32; i++) { + if (src) { + shape = ((unsigned long) src[i * 4] << 24) | + ((unsigned long) src[i * 4 + 1] << 16) | + ((unsigned long) src[i * 4 + 2] << 8) | + ((unsigned long) src[i * 4 + 3] << 0); + mask = ((unsigned long) src[i * 4 + 128] << 24) | + ((unsigned long) src[i * 4 + 1 + 128] << 16) | + ((unsigned long) src[i * 4 + 2 + 128] << 8) | + ((unsigned long) src[i * 4 + 3 + 128] << 0); + } + else { + mask = 0x0; + shape = 0xFFFFFFFF; + } - andMask[i] = ~(mask); - xorMask[i] = shape & mask; - } + andMask[i] = ~(mask); + xorMask[i] = shape & mask; + } - GFX(set_cursor_shape32(pGeode->CursorStartOffset, andMask, xorMask)); + GFX(set_cursor_shape32(pGeode->CursorStartOffset, andMask, xorMask)); } /*---------------------------------------------------------------------------- @@ -344,7 +345,7 @@ GX2LoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char *src) void GX2HideCursor(ScrnInfoPtr pScreenInfo) { - GFX(set_cursor_enable(0)); + GFX(set_cursor_enable(0)); } /*---------------------------------------------------------------------------- @@ -364,7 +365,7 @@ GX2HideCursor(ScrnInfoPtr pScreenInfo) void GX2ShowCursor(ScrnInfoPtr pScreenInfo) { - GFX(set_cursor_enable(1)); + GFX(set_cursor_enable(1)); } /*---------------------------------------------------------------------------- @@ -385,11 +386,11 @@ GX2ShowCursor(ScrnInfoPtr pScreenInfo) static Bool GX2UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) { - ScrnInfoPtr pScreenInfo = XF86SCRNINFO(pScreen); + ScrnInfoPtr pScreenInfo = XF86SCRNINFO(pScreen); - if (pScreenInfo->currentMode->Flags & V_DBLSCAN) - return FALSE; - return TRUE; + if (pScreenInfo->currentMode->Flags & V_DBLSCAN) + return FALSE; + return TRUE; } /* End of File */ diff --git a/src/nsc_gx2_dga.c b/src/nsc_gx2_dga.c index 581d1a3..e2debee 100644 --- a/src/nsc_gx2_dga.c +++ b/src/nsc_gx2_dga.c @@ -159,7 +159,7 @@ /* forward declarations */ Bool GX2DGAInit(ScreenPtr pScreen); static Bool GX2_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, - int *, int *, int *); + int *, int *, int *); static void GX2_CloseFramebuffer(ScrnInfoPtr pScrn); static Bool GX2_SetMode(ScrnInfoPtr, DGAModePtr); static int GX2_GetViewport(ScrnInfoPtr); @@ -172,15 +172,15 @@ extern Bool GX2SwitchMode(int, DisplayModePtr, int); extern void GX2AccelSync(ScrnInfoPtr pScreenInfo); static DGAFunctionRec GX2DGAFuncs = { - GX2_OpenFramebuffer, - GX2_CloseFramebuffer, - GX2_SetMode, - GX2_SetViewport, - GX2_GetViewport, - GX2AccelSync, - GX2_FillRect, - GX2_BlitRect, - NULL + GX2_OpenFramebuffer, + GX2_CloseFramebuffer, + GX2_SetMode, + GX2_SetViewport, + GX2_GetViewport, + GX2AccelSync, + GX2_FillRect, + GX2_BlitRect, + NULL }; /*---------------------------------------------------------------------------- @@ -201,94 +201,96 @@ static DGAFunctionRec GX2DGAFuncs = { Bool GX2DGAInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - GeodePtr pGeode = GEODEPTR(pScrn); - DGAModePtr modes = NULL, newmodes = NULL, currentMode; - DisplayModePtr pMode, firstMode; - int Bpp = pScrn->bitsPerPixel >> 3; - int num = 0; - Bool oneMore; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + GeodePtr pGeode = GEODEPTR(pScrn); + DGAModePtr modes = NULL, newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int Bpp = pScrn->bitsPerPixel >> 3; + int num = 0; + Bool oneMore; - pMode = firstMode = pScrn->modes; - DEBUGMSG(0, (0, X_NONE, "GX2DGAInit %d\n", Bpp)); - while (pMode) { + pMode = firstMode = pScrn->modes; + DEBUGMSG(0, (0, X_NONE, "GX2DGAInit %d\n", Bpp)); + while (pMode) { - /* redundant but it can be used in future:if(0). */ - if (0) { /*pScrn->displayWidth != pMode->HDisplay */ - /* memory is allocated for dga to - *setup the viewport and mode parameters - */ - newmodes = realloc(modes, (num + 2) * sizeof(DGAModeRec)); - oneMore = TRUE; - } else { - /* one record is allocated here */ - newmodes = realloc(modes, (num + 1) * sizeof(DGAModeRec)); - oneMore = FALSE; - } - if (!newmodes) { - free(modes); - return FALSE; - } - modes = newmodes; + /* redundant but it can be used in future:if(0). */ + if (0) { /*pScrn->displayWidth != pMode->HDisplay */ + /* memory is allocated for dga to + *setup the viewport and mode parameters + */ + newmodes = realloc(modes, (num + 2) * sizeof(DGAModeRec)); + oneMore = TRUE; + } + else { + /* one record is allocated here */ + newmodes = realloc(modes, (num + 1) * sizeof(DGAModeRec)); + oneMore = FALSE; + } + if (!newmodes) { + free(modes); + return FALSE; + } + modes = newmodes; - SECOND_PASS: /* DGA mode flgas and viewport parametrs are set here. */ + SECOND_PASS: /* DGA mode flgas and viewport parametrs are set here. */ - currentMode = modes + num; - num++; - currentMode->mode = pMode; - currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; - currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; - if (pMode->Flags & V_DBLSCAN) - currentMode->flags |= DGA_DOUBLESCAN; - if (pMode->Flags & V_INTERLACE) - currentMode->flags |= DGA_INTERLACED; - currentMode->byteOrder = pScrn->imageByteOrder; - currentMode->depth = pScrn->depth; - currentMode->bitsPerPixel = pScrn->bitsPerPixel; - currentMode->red_mask = pScrn->mask.red; - currentMode->green_mask = pScrn->mask.green; - currentMode->blue_mask = pScrn->mask.blue; - currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; - currentMode->viewportWidth = pMode->HDisplay; - currentMode->viewportHeight = pMode->VDisplay; - currentMode->xViewportStep = 1; - currentMode->yViewportStep = 1; - currentMode->viewportFlags = DGA_FLIP_RETRACE; - currentMode->offset = 0; - currentMode->address = pGeode->FBBase; - if (oneMore) { /* first one is narrow width */ - currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; - currentMode->imageWidth = pMode->HDisplay; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - oneMore = FALSE; - goto SECOND_PASS; - } else { - currentMode->bytesPerScanline = - ((pScrn->displayWidth * Bpp) + 3) & ~3L; - currentMode->imageWidth = pScrn->displayWidth; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - } - pMode = pMode->next; - if (pMode == firstMode) - break; - } - pGeode->numDGAModes = num; - pGeode->DGAModes = modes; - return DGAInit(pScreen, &GX2DGAFuncs, modes, num); + currentMode = modes + num; + num++; + currentMode->mode = pMode; + currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if (pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if (pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = pScrn->depth; + currentMode->bitsPerPixel = pScrn->bitsPerPixel; + currentMode->red_mask = pScrn->mask.red; + currentMode->green_mask = pScrn->mask.green; + currentMode->blue_mask = pScrn->mask.blue; + currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 1; + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = pGeode->FBBase; + if (oneMore) { /* first one is narrow width */ + currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; + currentMode->imageWidth = pMode->HDisplay; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + oneMore = FALSE; + goto SECOND_PASS; + } + else { + currentMode->bytesPerScanline = + ((pScrn->displayWidth * Bpp) + 3) & ~3L; + currentMode->imageWidth = pScrn->displayWidth; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + } + pMode = pMode->next; + if (pMode == firstMode) + break; + } + pGeode->numDGAModes = num; + pGeode->DGAModes = modes; + return DGAInit(pScreen, &GX2DGAFuncs, modes, num); } /*---------------------------------------------------------------------------- @@ -309,45 +311,46 @@ GX2DGAInit(ScreenPtr pScreen) static Bool GX2_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) { - static int OldDisplayWidth[MAXSCREENS]; - int index = pScrn->pScreen->myNum; - GeodePtr pGeode = GEODEPTR(pScrn); + static int OldDisplayWidth[MAXSCREENS]; + int index = pScrn->pScreen->myNum; + GeodePtr pGeode = GEODEPTR(pScrn); - DEBUGMSG(0, (0, X_NONE, "GX2_SetMode\n")); - if (!pMode) { - /* restore the original mode - * * put the ScreenParameters back - */ - pScrn->displayWidth = OldDisplayWidth[index]; - DEBUGMSG(0, - (0, X_NONE, "GX2_SetMode !pMode %d\n", pScrn->displayWidth)); - GX2SwitchMode(index, pScrn->currentMode, 0); - pGeode->DGAactive = FALSE; - } else { - if (!pGeode->DGAactive) { /* save the old parameters */ - OldDisplayWidth[index] = pScrn->displayWidth; - pGeode->DGAactive = TRUE; - DEBUGMSG(0, - (0, X_NONE, "GX2_SetMode pMode+ NA %d\n", - pScrn->displayWidth)); - } - pScrn->displayWidth = pMode->bytesPerScanline / - (pMode->bitsPerPixel >> 3); - DEBUGMSG(0, - (0, X_NONE, "GX2_SetMode pMode+ %d\n", pScrn->displayWidth)); - GX2SwitchMode(index, pMode->mode, 0); - } - /* enable/disable Compression */ - if (pGeode->Compression) { - GFX(set_compression_enable(!pGeode->DGAactive)); - } + DEBUGMSG(0, (0, X_NONE, "GX2_SetMode\n")); + if (!pMode) { + /* restore the original mode + * * put the ScreenParameters back + */ + pScrn->displayWidth = OldDisplayWidth[index]; + DEBUGMSG(0, + (0, X_NONE, "GX2_SetMode !pMode %d\n", pScrn->displayWidth)); + GX2SwitchMode(index, pScrn->currentMode, 0); + pGeode->DGAactive = FALSE; + } + else { + if (!pGeode->DGAactive) { /* save the old parameters */ + OldDisplayWidth[index] = pScrn->displayWidth; + pGeode->DGAactive = TRUE; + DEBUGMSG(0, + (0, X_NONE, "GX2_SetMode pMode+ NA %d\n", + pScrn->displayWidth)); + } + pScrn->displayWidth = pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3); + DEBUGMSG(0, + (0, X_NONE, "GX2_SetMode pMode+ %d\n", pScrn->displayWidth)); + GX2SwitchMode(index, pMode->mode, 0); + } + /* enable/disable Compression */ + if (pGeode->Compression) { + GFX(set_compression_enable(!pGeode->DGAactive)); + } - /* enable/disable cursor */ - if (pGeode->HWCursor) { - GFX(set_cursor_enable(!pGeode->DGAactive)); - } + /* enable/disable cursor */ + if (pGeode->HWCursor) { + GFX(set_cursor_enable(!pGeode->DGAactive)); + } - return TRUE; + return TRUE; } /*---------------------------------------------------------------------------- @@ -368,9 +371,9 @@ GX2_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) static int GX2_GetViewport(ScrnInfoPtr pScrn) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - return pGeode->DGAViewportStatus; + return pGeode->DGAViewportStatus; } /*---------------------------------------------------------------------------- @@ -392,10 +395,10 @@ GX2_GetViewport(ScrnInfoPtr pScrn) static void GX2_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - GX2AdjustFrame(pScrn->pScreen->myNum, x, y, flags); - pGeode->DGAViewportStatus = 0; /*GX2AdjustFrame loops until finished */ + GX2AdjustFrame(pScrn->pScreen->myNum, x, y, flags); + pGeode->DGAViewportStatus = 0; /*GX2AdjustFrame loops until finished */ } /*---------------------------------------------------------------------------- @@ -418,16 +421,15 @@ GX2_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) *---------------------------------------------------------------------------- */ static void -GX2_FillRect(ScrnInfoPtr pScrn, int x, int y, - int w, int h, unsigned long color) +GX2_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - if (pGeode->AccelInfoRec) { - (*pGeode->AccelInfoRec->SetupForSolidFill) (pScrn, color, GXcopy, ~0); - (*pGeode->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); - SET_SYNC_FLAG(pGeode->AccelInfoRec); - } + if (pGeode->AccelInfoRec) { + (*pGeode->AccelInfoRec->SetupForSolidFill) (pScrn, color, GXcopy, ~0); + (*pGeode->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); + SET_SYNC_FLAG(pGeode->AccelInfoRec); + } } /*---------------------------------------------------------------------------- @@ -453,21 +455,21 @@ GX2_FillRect(ScrnInfoPtr pScrn, int x, int y, */ static void GX2_BlitRect(ScrnInfoPtr pScrn, - int srcx, int srcy, int w, int h, int dstx, int dsty) + int srcx, int srcy, int w, int h, int dstx, int dsty) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - if (pGeode->AccelInfoRec) { - int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; - int ydir = (srcy < dsty) ? -1 : 1; + if (pGeode->AccelInfoRec) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; - (*pGeode->AccelInfoRec->SetupForScreenToScreenCopy) - (pScrn, xdir, ydir, GXcopy, ~0, -1); - (*pGeode->AccelInfoRec->SubsequentScreenToScreenCopy) (pScrn, srcx, - srcy, dstx, dsty, - w, h); - SET_SYNC_FLAG(pGeode->AccelInfoRec); - } + (*pGeode->AccelInfoRec->SetupForScreenToScreenCopy) + (pScrn, xdir, ydir, GXcopy, ~0, -1); + (*pGeode->AccelInfoRec->SubsequentScreenToScreenCopy) (pScrn, srcx, + srcy, dstx, dsty, + w, h); + SET_SYNC_FLAG(pGeode->AccelInfoRec); + } } /*---------------------------------------------------------------------------- @@ -491,17 +493,17 @@ GX2_BlitRect(ScrnInfoPtr pScrn, */ static Bool GX2_OpenFramebuffer(ScrnInfoPtr pScrn, - char **name, unsigned char **mem, - int *size, int *offset, int *flags) + char **name, unsigned char **mem, + int *size, int *offset, int *flags) { - GeodePtr pGeode = GEODEPTR(pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); - *name = NULL; /* no special device */ - *mem = (unsigned char *)pGeode->FBLinearAddr; - *size = pGeode->FBSize; - *offset = 0; - *flags = DGA_NEED_ROOT; - return TRUE; + *name = NULL; /* no special device */ + *mem = (unsigned char *) pGeode->FBLinearAddr; + *size = pGeode->FBSize; + *offset = 0; + *flags = DGA_NEED_ROOT; + return TRUE; } static void diff --git a/src/nsc_gx2_driver.c b/src/nsc_gx2_driver.c index 3a118e1..a5673e8 100644 --- a/src/nsc_gx2_driver.c +++ b/src/nsc_gx2_driver.c @@ -189,7 +189,7 @@ #ifdef XFreeXDGA #define _XF86_DGA_SERVER_ #include <X11/extensions/xf86dgaproto.h> -#endif /* XFreeXDGA */ +#endif /* XFreeXDGA */ #include "globals.h" #include "opaque.h" @@ -204,7 +204,7 @@ #include "nsc.h" #if !defined(STB_X) #include "nsc_gx2_vga.c" -#endif /* STB_X */ +#endif /* STB_X */ #if GEODE_TRACE /* ANSI C does not allow var arg macros */ @@ -227,8 +227,8 @@ void GX2AdjustFrame(int, int, int, int); Bool GX2SwitchMode(int, DisplayModePtr, int); static ModeStatus GX2ValidMode(int, DisplayModePtr, Bool, int); static void GX2LoadPalette(ScrnInfoPtr pScreenInfo, - int numColors, int *indizes, - LOCO * colors, VisualPtr pVisual); + int numColors, int *indizes, + LOCO * colors, VisualPtr pVisual); static Bool GX2MapMem(ScrnInfoPtr); static Bool GX2UnmapMem(ScrnInfoPtr); static void gx2_set_DvLineSize(unsigned int pitch); @@ -249,7 +249,7 @@ extern void GX2LoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char *src); #if !defined(STB_X) extern unsigned char *XpressROMPtr; -#endif /* STB_X */ +#endif /* STB_X */ /* Existing Processor Models */ #define GX1 0x1 @@ -272,7 +272,7 @@ extern const char *nscShadowSymbols[]; void GX2SetupChipsetFPtr(ScrnInfoPtr pScrn); GeodePtr GX2GetRec(ScrnInfoPtr pScreenInfo); void get_flatpanel_info(const char *options, int *W, int *H, - int *D, int *C, int *T); + int *D, int *C, int *T); void gx2_clear_screen(int width, int height); void EnableDACPower(void); void redcloud_gfx_2_vga_fix(void); @@ -280,16 +280,16 @@ void redcloud_gfx_2_vga_fix(void); void GX2SetupChipsetFPtr(ScrnInfoPtr pScrn) { - GeodeDebug(("GX2SetupChipsetFPtr!\n")); - - pScrn->PreInit = GX2PreInit; - pScrn->ScreenInit = GX2ScreenInit; - pScrn->SwitchMode = GX2SwitchMode; - pScrn->AdjustFrame = GX2AdjustFrame; - pScrn->EnterVT = GX2EnterVT; - pScrn->LeaveVT = GX2LeaveVT; - pScrn->FreeScreen = GX2FreeScreen; - pScrn->ValidMode = GX2ValidMode; + GeodeDebug(("GX2SetupChipsetFPtr!\n")); + + pScrn->PreInit = GX2PreInit; + pScrn->ScreenInit = GX2ScreenInit; + pScrn->SwitchMode = GX2SwitchMode; + pScrn->AdjustFrame = GX2AdjustFrame; + pScrn->EnterVT = GX2EnterVT; + pScrn->LeaveVT = GX2LeaveVT; + pScrn->FreeScreen = GX2FreeScreen; + pScrn->ValidMode = GX2ValidMode; } /*---------------------------------------------------------------------------- @@ -310,15 +310,15 @@ GX2SetupChipsetFPtr(ScrnInfoPtr pScrn) GeodePtr GX2GetRec(ScrnInfoPtr pScreenInfo) { - if (!pScreenInfo->driverPrivate) { - GeodePtr pGeode; + if (!pScreenInfo->driverPrivate) { + GeodePtr pGeode; - pGeode = pScreenInfo->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1); + pGeode = pScreenInfo->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1); #if INT10_SUPPORT - pGeode->vesa = calloc(sizeof(VESARec), 1); + pGeode->vesa = calloc(sizeof(VESARec), 1); #endif - } - return GEODEPTR(pScreenInfo); + } + return GEODEPTR(pScreenInfo); } /*---------------------------------------------------------------------------- @@ -339,11 +339,11 @@ GX2GetRec(ScrnInfoPtr pScreenInfo) static void GX2FreeRec(ScrnInfoPtr pScreenInfo) { - if (pScreenInfo->driverPrivate == NULL) { - return; - } - free(pScreenInfo->driverPrivate); - pScreenInfo->driverPrivate = NULL; + if (pScreenInfo->driverPrivate == NULL) { + return; + } + free(pScreenInfo->driverPrivate); + pScreenInfo->driverPrivate = NULL; } /*---------------------------------------------------------------------------- @@ -364,15 +364,15 @@ static Bool GX2SaveScreen(ScreenPtr pScreen, int mode) { #if !defined(STB_X) - ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; - GeodeDebug(("GX2SaveScreen!\n")); + GeodeDebug(("GX2SaveScreen!\n")); - if (!pScreenInfo->vtSema) - return vgaHWSaveScreen(pScreen, mode); + if (!pScreenInfo->vtSema) + return vgaHWSaveScreen(pScreen, mode); -#endif /* STB_X */ - return TRUE; +#endif /* STB_X */ + return TRUE; } /*---------------------------------------------------------------------------- @@ -393,54 +393,53 @@ GX2SaveScreen(ScreenPtr pScreen, int mode) *------------------------------------------------------------------------ */ void -get_flatpanel_info(const char *options, int *W, int *H, - int *D, int *C, int *T) +get_flatpanel_info(const char *options, int *W, int *H, int *D, int *C, int *T) { - char *pnl_opt; - - pnl_opt = strtok((char *)options, ":"); - *W = strtoul(pnl_opt, NULL, 0); - pnl_opt = strtok(NULL, ":"); - *H = strtoul(pnl_opt, NULL, 0); - pnl_opt = strtok(NULL, ":"); - *D = strtoul(pnl_opt, NULL, 0); - pnl_opt = strtok(NULL, ":"); - *C = strtoul(pnl_opt, NULL, 0); - pnl_opt = strtok(NULL, ":"); - *T = strtoul(pnl_opt, NULL, 0); - - *C = (*C) ? PNL_COLOR_PANEL : PNL_MONO_PANEL; - - switch (*T) { - case 0: - *T = PNL_SSTN; - break; - case 1: - *T = PNL_DSTN; - break; - case 2: - default: - *T = PNL_TFT; - break; - } - - if ((*W != 640) && (*W != 800) && (*W != 1024)) - *W = 640; - - if ((*H != 480) && (*H != 600) && (*H != 768)) - *H = 480; + char *pnl_opt; + + pnl_opt = strtok((char *) options, ":"); + *W = strtoul(pnl_opt, NULL, 0); + pnl_opt = strtok(NULL, ":"); + *H = strtoul(pnl_opt, NULL, 0); + pnl_opt = strtok(NULL, ":"); + *D = strtoul(pnl_opt, NULL, 0); + pnl_opt = strtok(NULL, ":"); + *C = strtoul(pnl_opt, NULL, 0); + pnl_opt = strtok(NULL, ":"); + *T = strtoul(pnl_opt, NULL, 0); + + *C = (*C) ? PNL_COLOR_PANEL : PNL_MONO_PANEL; + + switch (*T) { + case 0: + *T = PNL_SSTN; + break; + case 1: + *T = PNL_DSTN; + break; + case 2: + default: + *T = PNL_TFT; + break; + } + + if ((*W != 640) && (*W != 800) && (*W != 1024)) + *W = 640; + + if ((*H != 480) && (*H != 600) && (*H != 768)) + *H = 480; } static void GX2ProbeDDC(ScrnInfoPtr pScrn, int index) { - vbeInfoPtr pVbe; + vbeInfoPtr pVbe; - if (xf86LoadSubModule(pScrn, "vbe")) { - pVbe = VBEInit(NULL, index); - ConfiguredMonitor = vbeDoEDID(pVbe, NULL); - vbeFree(pVbe); - } + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL, index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + vbeFree(pVbe); + } } /*---------------------------------------------------------------------------- @@ -460,557 +459,568 @@ GX2ProbeDDC(ScrnInfoPtr pScrn, int index) static Bool GX2PreInit(ScrnInfoPtr pScreenInfo, int flags) { - static ClockRange GeodeClockRange = - { NULL, 25175, 229500, 0, FALSE, TRUE, 1, 1, 0 }; - MessageType from; - int i = 0; - GeodePtr pGeode; + static ClockRange GeodeClockRange = + { NULL, 25175, 229500, 0, FALSE, TRUE, 1, 1, 0 }; + MessageType from; + int i = 0; + GeodePtr pGeode; + #if defined(STB_X) - GAL_ADAPTERINFO sAdapterInfo; -#endif /* STB_X */ - unsigned int PitchInc = 0, minPitch = 0, maxPitch = 0; - unsigned int minHeight = 0, maxHeight = 0; - unsigned int SupportFlags; - const char *s; - char **modes; + GAL_ADAPTERINFO sAdapterInfo; +#endif /* STB_X */ + unsigned int PitchInc = 0, minPitch = 0, maxPitch = 0; + unsigned int minHeight = 0, maxHeight = 0; + unsigned int SupportFlags; + const char *s; + char **modes; #if INT10_SUPPORT - VESAPtr pVesa; + VESAPtr pVesa; #endif - DCount = 10; - GeodeDebug(("GX2PreInit!\n")); - /* Allocate driver private structure */ - if (!(pGeode = GX2GetRec(pScreenInfo))) - return FALSE; - - /* This is the general case */ - for (i = 0; i < pScreenInfo->numEntities; i++) { - pGeode->pEnt = xf86GetEntityInfo(pScreenInfo->entityList[i]); - #ifndef XSERVER_LIBPCIACCESS - if (pGeode->pEnt->resources) - return FALSE; - #endif - pGeode->Chipset = pGeode->pEnt->chipset; - pScreenInfo->chipset = (char *)xf86TokenToString(GeodeChipsets, - pGeode->pEnt->chipset); - } - - if (flags & PROBE_DETECT) { - GX2ProbeDDC(pScreenInfo, pGeode->pEnt->index); - return TRUE; - } + DCount = 10; + GeodeDebug(("GX2PreInit!\n")); + /* Allocate driver private structure */ + if (!(pGeode = GX2GetRec(pScreenInfo))) + return FALSE; + + /* This is the general case */ + for (i = 0; i < pScreenInfo->numEntities; i++) { + pGeode->pEnt = xf86GetEntityInfo(pScreenInfo->entityList[i]); +#ifndef XSERVER_LIBPCIACCESS + if (pGeode->pEnt->resources) + return FALSE; +#endif + pGeode->Chipset = pGeode->pEnt->chipset; + pScreenInfo->chipset = (char *) xf86TokenToString(GeodeChipsets, + pGeode->pEnt-> + chipset); + } + + if (flags & PROBE_DETECT) { + GX2ProbeDDC(pScreenInfo, pGeode->pEnt->index); + return TRUE; + } #if INT10_SUPPORT - if (!xf86LoadSubModule(pScreenInfo, "int10")) - return FALSE; - xf86LoaderReqSymLists(nscInt10Symbols, NULL); + if (!xf86LoadSubModule(pScreenInfo, "int10")) + return FALSE; + xf86LoaderReqSymLists(nscInt10Symbols, NULL); #endif - pGeode->FBVGAActive = 0; /* KFB will Knock of VGA */ + pGeode->FBVGAActive = 0; /* KFB will Knock of VGA */ #if !defined(STB_X) - /* If the vgahw module would be needed it would be loaded here */ - if (!xf86LoadSubModule(pScreenInfo, "vgahw")) { - return FALSE; - } - xf86LoaderReqSymLists(nscVgahwSymbols, NULL); -#endif /* STB_X */ - GeodeDebug(("GX2PreInit(1)!\n")); - /* Do the durango hardware detection */ + /* If the vgahw module would be needed it would be loaded here */ + if (!xf86LoadSubModule(pScreenInfo, "vgahw")) { + return FALSE; + } + xf86LoaderReqSymLists(nscVgahwSymbols, NULL); +#endif /* STB_X */ + GeodeDebug(("GX2PreInit(1)!\n")); + /* Do the durango hardware detection */ #if defined(STB_X) - if (!Gal_initialize_interface()) { - GeodeDebug(("GALintialize fail GX2PreInit(1.00)!\n")); - return FALSE; - } - - if (Gal_get_adapter_info(&sAdapterInfo)) { - pGeode->cpu_version = sAdapterInfo.dwCPUVersion; - - /* find the base chipset core. Currently there can be only one - * chip active at any time. - */ - if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) { - if (sAdapterInfo.dwCPUType) - pGeode->DetectedChipSet = GX2_TFT; - else - pGeode->DetectedChipSet = GX2_CRT; - } - - DEBUGMSG(1, - (0, X_NONE, "Detected BaseChip %d, %d\n", - pGeode->DetectedChipSet, sAdapterInfo.dwCPUType)); - - pGeode->vid_version = sAdapterInfo.dwVideoVersion; - pGeode->FBSize = sAdapterInfo.dwFrameBufferSize; - /* update the max clock from the one system suports */ - GeodeClockRange.maxClock = sAdapterInfo.dwMaxSupportedPixelClock; - pGeode->FBLinearAddr = sAdapterInfo.dwFrameBufferBase; + if (!Gal_initialize_interface()) { + GeodeDebug(("GALintialize fail GX2PreInit(1.00)!\n")); + return FALSE; + } + + if (Gal_get_adapter_info(&sAdapterInfo)) { + pGeode->cpu_version = sAdapterInfo.dwCPUVersion; + + /* find the base chipset core. Currently there can be only one + * chip active at any time. + */ + if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) { + if (sAdapterInfo.dwCPUType) + pGeode->DetectedChipSet = GX2_TFT; + else + pGeode->DetectedChipSet = GX2_CRT; + } + + DEBUGMSG(1, + (0, X_NONE, "Detected BaseChip %d, %d\n", + pGeode->DetectedChipSet, sAdapterInfo.dwCPUType)); + + pGeode->vid_version = sAdapterInfo.dwVideoVersion; + pGeode->FBSize = sAdapterInfo.dwFrameBufferSize; + /* update the max clock from the one system suports */ + GeodeClockRange.maxClock = sAdapterInfo.dwMaxSupportedPixelClock; + pGeode->FBLinearAddr = sAdapterInfo.dwFrameBufferBase; #if 0 - pGeode->FBBase = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, - pGeode->FBLinearAddr, - pGeode->FBSize); + pGeode->FBBase = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_FRAMEBUFFER, + pGeode->FBLinearAddr, + pGeode->FBSize); #endif - if (!GX2MapMem(pScreenInfo)) - return FALSE; - DEBUGMSG(1, (0, X_NONE, "CPU=%x vid %x FB %x FBAdd %X\n", - pGeode->cpu_version, pGeode->vid_version, pGeode->FBSize, - pGeode->FBLinearAddr)); - } else { - return FALSE; - } -#else /* STB */ - pGeode->cpu_version = gfx_detect_cpu(); - - /* find the base chipset core. Currently there can be only one - * chip active at any time. - */ + if (!GX2MapMem(pScreenInfo)) + return FALSE; + DEBUGMSG(1, (0, X_NONE, "CPU=%x vid %x FB %x FBAdd %X\n", + pGeode->cpu_version, pGeode->vid_version, pGeode->FBSize, + pGeode->FBLinearAddr)); + } + else { + return FALSE; + } +#else /* STB */ + pGeode->cpu_version = gfx_detect_cpu(); + + /* find the base chipset core. Currently there can be only one + * chip active at any time. + */ /* pGeode->DetectedChipSet = GX1; */ - if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) - pGeode->DetectedChipSet = GX2; - GeodeDebug(("Detected BaseChip (%d)\n", pGeode->DetectedChipSet)); - { - Q_WORD msrValue; - - /* GX2 : Can have CRT or TFT only */ - gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue); - pGeode->DetectedChipSet = - ((msrValue.low & RCDF_CONFIG_FMT_MASK) == - RCDF_CONFIG_FMT_FP) ? GX2_TFT : GX2_CRT; - GeodeDebug(("Gx2 for %s\n", - ((pGeode->DetectedChipSet == GX2_TFT) ? "TFT" : "CRT"))); - } - GeodeDebug(("GX2PreInit(1.1)!\n")); - pGeode->vid_version = gfx_detect_video(); - GeodeDebug(("GX2PreInit(1.2)!\n")); - pGeode->FBLinearAddr = gfx_get_frame_buffer_base(); - GeodeDebug(("GX2PreInit(1.3)!\n")); - pGeode->FBSize = gfx_get_frame_buffer_size(); - GeodeDebug(("GX2PreInit(1.4)!\n")); - /* update the max clock from the one system suports */ - GeodeClockRange.maxClock = gfx_get_max_supported_pixel_clock(); - - GeodeDebug(("GX2PreInit(1.5)!\n")); - /* SET DURANGO REGISTER POINTERS - * * The method of mapping from a physical address to a linear address - * * is operating system independent. Set variables to linear address. - */ - if (pGeode->DetectedChipSet & GX2) { - pGeode->cpu_reg_size = 0x4000; - pGeode->gp_reg_size = 0x4000; - pGeode->vid_reg_size = 0x4000; - } else { - pGeode->cpu_reg_size = 0x9000; - pGeode->vid_reg_size = 0x1000; - } - - if (!GX2MapMem(pScreenInfo)) - return FALSE; - - /* check if VGA is active */ - /* This routine saves the current VGA state in Durango VGA structure */ - /* check if VGA is active */ - pGeode->FBVGAActive = gu2_get_vga_active(); - -#endif /* STB_X */ - DEBUGMSG(1, (0, X_PROBED, "VGA = %d\n", pGeode->FBVGAActive)); - - /* Fill in the monitor field */ - pScreenInfo->monitor = pScreenInfo->confScreen->monitor; - GeodeDebug(("GX2PreInit(2)!\n")); - SupportFlags = Support24bppFb | Support32bppFb; - GeodeDebug(("GX2PreInit(2)!\n")); - /* Determine depth, bpp, etc. */ - if (!xf86SetDepthBpp(pScreenInfo, 0, 0, 0, SupportFlags)) { - return FALSE; - } else { - if (!((pScreenInfo->depth == 8) || - (pScreenInfo->depth == 16) || - (pScreenInfo->depth == 24))) { - /* Depth not supported */ - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "Given depth (%d bpp) is not supported by this driver\n", - pScreenInfo->depth)); - return FALSE; - } - } - - /*This must happen after pScreenInfo->display has been set - * * because xf86SetWeight references it. - */ - if (pScreenInfo->depth > 8) { - /* The defaults are OK for us */ - rgb BitsPerComponent = { 0, 0, 0 }; - rgb BitMask = { 0, 0, 0 }; - - if (pScreenInfo->depth > 16) { - /* we are operating in 24 bpp, Readcloud */ - BitsPerComponent.red = 8; - BitsPerComponent.green = 8; - BitsPerComponent.blue = 8; - - BitMask.red = 0xFF0000; - BitMask.green = 0x00FF00; - BitMask.blue = 0x0000FF; - } - if (!xf86SetWeight(pScreenInfo, BitsPerComponent, BitMask)) { - return FALSE; - } else { - /* XXX Check if the returned weight is supported */ - } - } - - xf86PrintDepthBpp(pScreenInfo); - - GeodeDebug(("GX2PreInit(3)!\n")); - - if (!xf86SetDefaultVisual(pScreenInfo, -1)) - return FALSE; - - GeodeDebug(("GX2PreInit(4)!\n")); - - /* The new cmap layer needs this to be initialized */ - if (pScreenInfo->depth > 1) { - Gamma zeros = { 0.0, 0.0, 0.0 }; - - if (!xf86SetGamma(pScreenInfo, zeros)) { - return FALSE; - } - } - GeodeDebug(("GX2PreInit(5)!\n")); - - /* We use a programmable clock */ - pScreenInfo->progClock = TRUE; - - /*Collect all of the relevant option flags - * *(fill in pScreenInfo->options) - */ - xf86CollectOptions(pScreenInfo, NULL); - - /*Process the options */ - xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, - GeodeOptions); + if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) + pGeode->DetectedChipSet = GX2; + GeodeDebug(("Detected BaseChip (%d)\n", pGeode->DetectedChipSet)); + { + Q_WORD msrValue; + + /* GX2 : Can have CRT or TFT only */ + gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue); + pGeode->DetectedChipSet = + ((msrValue.low & RCDF_CONFIG_FMT_MASK) == + RCDF_CONFIG_FMT_FP) ? GX2_TFT : GX2_CRT; + GeodeDebug(("Gx2 for %s\n", + ((pGeode->DetectedChipSet == GX2_TFT) ? "TFT" : "CRT"))); + } + GeodeDebug(("GX2PreInit(1.1)!\n")); + pGeode->vid_version = gfx_detect_video(); + GeodeDebug(("GX2PreInit(1.2)!\n")); + pGeode->FBLinearAddr = gfx_get_frame_buffer_base(); + GeodeDebug(("GX2PreInit(1.3)!\n")); + pGeode->FBSize = gfx_get_frame_buffer_size(); + GeodeDebug(("GX2PreInit(1.4)!\n")); + /* update the max clock from the one system suports */ + GeodeClockRange.maxClock = gfx_get_max_supported_pixel_clock(); + + GeodeDebug(("GX2PreInit(1.5)!\n")); + /* SET DURANGO REGISTER POINTERS + * * The method of mapping from a physical address to a linear address + * * is operating system independent. Set variables to linear address. + */ + if (pGeode->DetectedChipSet & GX2) { + pGeode->cpu_reg_size = 0x4000; + pGeode->gp_reg_size = 0x4000; + pGeode->vid_reg_size = 0x4000; + } + else { + pGeode->cpu_reg_size = 0x9000; + pGeode->vid_reg_size = 0x1000; + } + + if (!GX2MapMem(pScreenInfo)) + return FALSE; + + /* check if VGA is active */ + /* This routine saves the current VGA state in Durango VGA structure */ + /* check if VGA is active */ + pGeode->FBVGAActive = gu2_get_vga_active(); + +#endif /* STB_X */ + DEBUGMSG(1, (0, X_PROBED, "VGA = %d\n", pGeode->FBVGAActive)); + + /* Fill in the monitor field */ + pScreenInfo->monitor = pScreenInfo->confScreen->monitor; + GeodeDebug(("GX2PreInit(2)!\n")); + SupportFlags = Support24bppFb | Support32bppFb; + GeodeDebug(("GX2PreInit(2)!\n")); + /* Determine depth, bpp, etc. */ + if (!xf86SetDepthBpp(pScreenInfo, 0, 0, 0, SupportFlags)) { + return FALSE; + } + else { + if (!((pScreenInfo->depth == 8) || + (pScreenInfo->depth == 16) || (pScreenInfo->depth == 24))) { + /* Depth not supported */ + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "Given depth (%d bpp) is not supported by this driver\n", + pScreenInfo->depth)); + return FALSE; + } + } + + /*This must happen after pScreenInfo->display has been set + * * because xf86SetWeight references it. + */ + if (pScreenInfo->depth > 8) { + /* The defaults are OK for us */ + rgb BitsPerComponent = { 0, 0, 0 }; + rgb BitMask = { 0, 0, 0 }; + + if (pScreenInfo->depth > 16) { + /* we are operating in 24 bpp, Readcloud */ + BitsPerComponent.red = 8; + BitsPerComponent.green = 8; + BitsPerComponent.blue = 8; + + BitMask.red = 0xFF0000; + BitMask.green = 0x00FF00; + BitMask.blue = 0x0000FF; + } + if (!xf86SetWeight(pScreenInfo, BitsPerComponent, BitMask)) { + return FALSE; + } + else { + /* XXX Check if the returned weight is supported */ + } + } + + xf86PrintDepthBpp(pScreenInfo); + + GeodeDebug(("GX2PreInit(3)!\n")); + + if (!xf86SetDefaultVisual(pScreenInfo, -1)) + return FALSE; + + GeodeDebug(("GX2PreInit(4)!\n")); + + /* The new cmap layer needs this to be initialized */ + if (pScreenInfo->depth > 1) { + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScreenInfo, zeros)) { + return FALSE; + } + } + GeodeDebug(("GX2PreInit(5)!\n")); + + /* We use a programmable clock */ + pScreenInfo->progClock = TRUE; + + /*Collect all of the relevant option flags + * *(fill in pScreenInfo->options) + */ + xf86CollectOptions(pScreenInfo, NULL); + + /*Process the options */ + xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, + GeodeOptions); #if INT10_SUPPORT - pVesa = pGeode->vesa; - /* Initialize Vesa record */ + pVesa = pGeode->vesa; + /* Initialize Vesa record */ - if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) { - xf86DrvMsg(0, X_ERROR, "Int10 initialization failed.\n"); - return (FALSE); - } + if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) { + xf86DrvMsg(0, X_ERROR, "Int10 initialization failed.\n"); + return (FALSE); + } #endif - /*Set the bits per RGB for 8bpp mode */ - if (pScreenInfo->depth == 8) { - /* Default to 8 */ - pScreenInfo->rgbBits = 8; - } - from = X_DEFAULT; - - /* - * *The preferred method is to use the "hw cursor" option as a tri-state - * *option, with the default set above. - */ - pGeode->HWCursor = TRUE; - if (xf86GetOptValBool(GeodeOptions, OPTION_HW_CURSOR, &pGeode->HWCursor)) { - from = X_CONFIG; - } - /* For compatibility, accept this too (as an override) */ - if (xf86ReturnOptValBool(GeodeOptions, OPTION_SW_CURSOR, FALSE)) { - from = X_CONFIG; - pGeode->HWCursor = FALSE; - } - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, "Using %s cursor\n", - pGeode->HWCursor ? "HW" : "SW")); - - pGeode->Compression = TRUE; - if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOCOMPRESSION, FALSE)) { - pGeode->Compression = FALSE; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "NoCompression\n")); - } - - pGeode->NoAccel = FALSE; - if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOACCEL, FALSE)) { - pGeode->NoAccel = TRUE; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Acceleration \ + /*Set the bits per RGB for 8bpp mode */ + if (pScreenInfo->depth == 8) { + /* Default to 8 */ + pScreenInfo->rgbBits = 8; + } + from = X_DEFAULT; + + /* + * *The preferred method is to use the "hw cursor" option as a tri-state + * *option, with the default set above. + */ + pGeode->HWCursor = TRUE; + if (xf86GetOptValBool(GeodeOptions, OPTION_HW_CURSOR, &pGeode->HWCursor)) { + from = X_CONFIG; + } + /* For compatibility, accept this too (as an override) */ + if (xf86ReturnOptValBool(GeodeOptions, OPTION_SW_CURSOR, FALSE)) { + from = X_CONFIG; + pGeode->HWCursor = FALSE; + } + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, "Using %s cursor\n", + pGeode->HWCursor ? "HW" : "SW")); + + pGeode->Compression = TRUE; + if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOCOMPRESSION, FALSE)) { + pGeode->Compression = FALSE; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "NoCompression\n")); + } + + pGeode->NoAccel = FALSE; + if (xf86ReturnOptValBool(GeodeOptions, OPTION_NOACCEL, FALSE)) { + pGeode->NoAccel = TRUE; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Acceleration \ disabled\n")); - } - - if (!xf86GetOptValInteger(GeodeOptions, OPTION_OSM_IMG_BUFS, - &(pGeode->NoOfImgBuffers))) - pGeode->NoOfImgBuffers = DEFAULT_NUM_OF_BUF; /* default # of buffers */ - if (pGeode->NoOfImgBuffers <= 0) - pGeode->NoOfImgBuffers = 0; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "NoOfImgBuffers = %d\n", pGeode->NoOfImgBuffers)); - - pGeode->Panel = FALSE; - if (xf86ReturnOptValBool(GeodeOptions, OPTION_FLATPANEL, FALSE)) { - DEBUGMSG(0, (pScreenInfo->scrnIndex, X_CONFIG, "FlatPanel Selected\n")); - pGeode->Panel = TRUE; - } - - /* Force the Panel on if on a GX2 TFT part, no crt support */ - if (pGeode->DetectedChipSet == GX2_TFT) { - pGeode->Panel = TRUE; - } - - /* If on a CRT and Panel flag set, disable Panel */ - if ((pGeode->DetectedChipSet == GX2_CRT) && (pGeode->Panel)) - pGeode->Panel = FALSE; - - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Quering FP Bios %d\n", pGeode->Panel)); - - /* if FP not supported in BIOS, then turn off user option */ - if (pGeode->Panel) { - /* check if bios supports FP */ + } + + if (!xf86GetOptValInteger(GeodeOptions, OPTION_OSM_IMG_BUFS, + &(pGeode->NoOfImgBuffers))) + pGeode->NoOfImgBuffers = DEFAULT_NUM_OF_BUF; /* default # of buffers */ + if (pGeode->NoOfImgBuffers <= 0) + pGeode->NoOfImgBuffers = 0; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "NoOfImgBuffers = %d\n", pGeode->NoOfImgBuffers)); + + pGeode->Panel = FALSE; + if (xf86ReturnOptValBool(GeodeOptions, OPTION_FLATPANEL, FALSE)) { + DEBUGMSG(0, (pScreenInfo->scrnIndex, X_CONFIG, "FlatPanel Selected\n")); + pGeode->Panel = TRUE; + } + + /* Force the Panel on if on a GX2 TFT part, no crt support */ + if (pGeode->DetectedChipSet == GX2_TFT) { + pGeode->Panel = TRUE; + } + + /* If on a CRT and Panel flag set, disable Panel */ + if ((pGeode->DetectedChipSet == GX2_CRT) && (pGeode->Panel)) + pGeode->Panel = FALSE; + + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Quering FP Bios %d\n", pGeode->Panel)); + + /* if FP not supported in BIOS, then turn off user option */ + if (pGeode->Panel) { + /* check if bios supports FP */ #if defined(STB_X) - Gal_pnl_enabled_in_bios(&pGeode->Panel); - Gal_pnl_info_from_bios(&pGeode->FPBX, &pGeode->FPBY, - &pGeode->FPBB, &pGeode->FPBF); -#else /* STB_X */ - pGeode->Panel = Pnl_IsPanelEnabledInBIOS(); - Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY, - &pGeode->FPBB, &pGeode->FPBF); -#endif /* STB_X */ - } - - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Quering FP Bios %d %d %d %d\n", - pGeode->FPBX, pGeode->FPBY, pGeode->FPBB, pGeode->FPBF)); - - /* if panel not selected and Panel can be supported. - * Power down the panel. - */ - if (!pGeode->Panel) { + Gal_pnl_enabled_in_bios(&pGeode->Panel); + Gal_pnl_info_from_bios(&pGeode->FPBX, &pGeode->FPBY, + &pGeode->FPBB, &pGeode->FPBF); +#else /* STB_X */ + pGeode->Panel = Pnl_IsPanelEnabledInBIOS(); + Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY, + &pGeode->FPBB, &pGeode->FPBF); +#endif /* STB_X */ + } + + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Quering FP Bios %d %d %d %d\n", + pGeode->FPBX, pGeode->FPBY, pGeode->FPBB, pGeode->FPBF)); + + /* if panel not selected and Panel can be supported. + * Power down the panel. + */ + if (!pGeode->Panel) { #if defined(STB_X) - Gal_pnl_powerdown(); -#else /* STB_X */ - Pnl_PowerDown(); -#endif /* STB_X */ - } else { + Gal_pnl_powerdown(); +#else /* STB_X */ + Pnl_PowerDown(); +#endif /* STB_X */ + } + else { #if defined(STB_X) - Gal_pnl_powerup(); + Gal_pnl_powerup(); #else - Pnl_PowerUp(); -#endif /* STB_X */ - } - - pGeode->ShadowFB = FALSE; - if (xf86ReturnOptValBool(GeodeOptions, OPTION_SHADOW_FB, FALSE)) { - pGeode->ShadowFB = TRUE; - pGeode->NoAccel = TRUE; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Using \"Shadow Framebuffer\" - acceleration disabled\n")); - } - - pGeode->Rotate = 0; - if ((s = xf86GetOptValString(GeodeOptions, OPTION_ROTATE))) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Rotating - %s\n", s)); - if (!xf86NameCmp(s, "CW")) { - pGeode->ShadowFB = TRUE; - pGeode->NoAccel = TRUE; - pGeode->HWCursor = FALSE; - pGeode->Rotate = 1; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Rotating screen clockwise - acceleration disabled\n")); - } else { - if (!xf86NameCmp(s, "CCW")) { - pGeode->ShadowFB = TRUE; - pGeode->NoAccel = TRUE; - pGeode->HWCursor = FALSE; - pGeode->Rotate = -1; - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "Rotating screen counter clockwise - acceleration \ + Pnl_PowerUp(); +#endif /* STB_X */ + } + + pGeode->ShadowFB = FALSE; + if (xf86ReturnOptValBool(GeodeOptions, OPTION_SHADOW_FB, FALSE)) { + pGeode->ShadowFB = TRUE; + pGeode->NoAccel = TRUE; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Using \"Shadow Framebuffer\" - acceleration disabled\n")); + } + + pGeode->Rotate = 0; + if ((s = xf86GetOptValString(GeodeOptions, OPTION_ROTATE))) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "Rotating - %s\n", s)); + if (!xf86NameCmp(s, "CW")) { + pGeode->ShadowFB = TRUE; + pGeode->NoAccel = TRUE; + pGeode->HWCursor = FALSE; + pGeode->Rotate = 1; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Rotating screen clockwise - acceleration disabled\n")); + } + else { + if (!xf86NameCmp(s, "CCW")) { + pGeode->ShadowFB = TRUE; + pGeode->NoAccel = TRUE; + pGeode->HWCursor = FALSE; + pGeode->Rotate = -1; + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "Rotating screen counter clockwise - acceleration \ disabled\n")); - } else { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, - "\"%s\" is not a valid value for Option \"Rotate\"\n", - s)); - DEBUGMSG(1, - (pScreenInfo->scrnIndex, X_INFO, - "Valid options are \"CW\" or \"CCW\"\n")); - } - } - } - - /* XXX Init further private data here */ - - /* - * * This shouldn't happen because such problems should be caught in - * * GeodeProbe(), but check it just in case. - */ - if (pScreenInfo->chipset == NULL) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "ChipID 0x%04X is not recognised\n", pGeode->Chipset)); - return FALSE; - } - if (pGeode->Chipset < 0) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "Chipset \"%s\" is not recognised\n", - pScreenInfo->chipset)); - return FALSE; - } - GeodeDebug(("GX2PreInit(6)!\n")); - - /* - * * Init the screen with some values - */ + } + else { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, + "\"%s\" is not a valid value for Option \"Rotate\"\n", + s)); + DEBUGMSG(1, + (pScreenInfo->scrnIndex, X_INFO, + "Valid options are \"CW\" or \"CCW\"\n")); + } + } + } + + /* XXX Init further private data here */ + + /* + * * This shouldn't happen because such problems should be caught in + * * GeodeProbe(), but check it just in case. + */ + if (pScreenInfo->chipset == NULL) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "ChipID 0x%04X is not recognised\n", pGeode->Chipset)); + return FALSE; + } + if (pGeode->Chipset < 0) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "Chipset \"%s\" is not recognised\n", + pScreenInfo->chipset)); + return FALSE; + } + GeodeDebug(("GX2PreInit(6)!\n")); + + /* + * * Init the screen with some values + */ #if !defined(STB_X) - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, - "Video I/O registers at 0x%08lX\n", - (unsigned long)VGAHW_GET_IOBASE())); -#endif /* STB_X */ + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, + "Video I/O registers at 0x%08lX\n", + (unsigned long) VGAHW_GET_IOBASE())); +#endif /* STB_X */ - if (pScreenInfo->memPhysBase == 0) { - from = X_PROBED; + if (pScreenInfo->memPhysBase == 0) { + from = X_PROBED; #if defined(STB_X) - pScreenInfo->memPhysBase = sAdapterInfo.dwFrameBufferBase; -#else /* STB_X */ - pScreenInfo->memPhysBase = gfx_get_frame_buffer_base(); -#endif /* STB_X */ - } - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, - "Linear framebuffer at 0x%08lX\n", - (unsigned long)pScreenInfo->memPhysBase)); - - if (pGeode->pEnt->device->videoRam == 0) { - from = X_PROBED; - pScreenInfo->videoRam = pGeode->FBSize / 1024; - } else { - pScreenInfo->videoRam = pGeode->pEnt->device->videoRam; - from = X_CONFIG; - } - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, - "VideoRam: %d kByte\n", - (unsigned long)pScreenInfo->videoRam)); - - GeodeDebug(("GX2PreInit(7)!\n")); - - /* - * * xf86ValidateModes will check that the mode HTotal and VTotal values - * * don't exceed the chipset's limit if pScreenInfo->maxHValue adn - * * pScreenInfo->maxVValue are set. Since our GX2ValidMode() - * * already takes care of this, we don't worry about setting them here. - */ - /* Select valid modes from those available */ - /* - * * min pitch 1024, max 2048 (Pixel count) - * * min height 480, max 1024 (Pixel count) - */ - minPitch = 1024; - maxPitch = 4096; /* Can support upto 1600x1200 32Bpp */ - minHeight = 480; - maxHeight = 1200; /* Can support upto 1600x1200 32Bpp */ - if (pScreenInfo->depth > 16) { - PitchInc = 4096; - } else if (pScreenInfo->depth == 16) { - PitchInc = 2048; - } else { - PitchInc = 1024; - } - PitchInc <<= 3; /* in bits */ - - /* by default use what user sets in the XF86Config file */ - modes = pScreenInfo->display->modes; - - i = xf86ValidateModes(pScreenInfo, - pScreenInfo->monitor->Modes, - modes, - &GeodeClockRange, - NULL, minPitch, maxPitch, - PitchInc, minHeight, maxHeight, - pScreenInfo->display->virtualX, - pScreenInfo->display->virtualY, + pScreenInfo->memPhysBase = sAdapterInfo.dwFrameBufferBase; +#else /* STB_X */ + pScreenInfo->memPhysBase = gfx_get_frame_buffer_base(); +#endif /* STB_X */ + } + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, + "Linear framebuffer at 0x%08lX\n", + (unsigned long) pScreenInfo->memPhysBase)); + + if (pGeode->pEnt->device->videoRam == 0) { + from = X_PROBED; + pScreenInfo->videoRam = pGeode->FBSize / 1024; + } + else { + pScreenInfo->videoRam = pGeode->pEnt->device->videoRam; + from = X_CONFIG; + } + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, + "VideoRam: %d kByte\n", + (unsigned long) pScreenInfo->videoRam)); + + GeodeDebug(("GX2PreInit(7)!\n")); + + /* + * * xf86ValidateModes will check that the mode HTotal and VTotal values + * * don't exceed the chipset's limit if pScreenInfo->maxHValue adn + * * pScreenInfo->maxVValue are set. Since our GX2ValidMode() + * * already takes care of this, we don't worry about setting them here. + */ + /* Select valid modes from those available */ + /* + * * min pitch 1024, max 2048 (Pixel count) + * * min height 480, max 1024 (Pixel count) + */ + minPitch = 1024; + maxPitch = 4096; /* Can support upto 1600x1200 32Bpp */ + minHeight = 480; + maxHeight = 1200; /* Can support upto 1600x1200 32Bpp */ + if (pScreenInfo->depth > 16) { + PitchInc = 4096; + } + else if (pScreenInfo->depth == 16) { + PitchInc = 2048; + } + else { + PitchInc = 1024; + } + PitchInc <<= 3; /* in bits */ + + /* by default use what user sets in the XF86Config file */ + modes = pScreenInfo->display->modes; + + i = xf86ValidateModes(pScreenInfo, + pScreenInfo->monitor->Modes, + modes, + &GeodeClockRange, + NULL, minPitch, maxPitch, + PitchInc, minHeight, maxHeight, + pScreenInfo->display->virtualX, + pScreenInfo->display->virtualY, #if defined(STB_X) - sAdapterInfo.dwFrameBufferSize, -#else /* STB_X */ - gfx_get_frame_buffer_size(), -#endif /* STB_X */ - LOOKUP_BEST_REFRESH); - - DEBUGMSG(1, (pScreenInfo->scrnIndex, from, - "xf86ValidateModes: %d %d %d\n", - pScreenInfo->virtualX, - pScreenInfo->virtualY, pScreenInfo->displayWidth)); - if (i == -1) { - GX2FreeRec(pScreenInfo); - return FALSE; - } - GeodeDebug(("GX2PreInit(8)!\n")); - - /* Prune the modes marked as invalid */ - xf86PruneDriverModes(pScreenInfo); - - GeodeDebug(("GX2PreInit(9)!\n")); - if (i == 0 || pScreenInfo->modes == NULL) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "No valid modes found\n")); - GX2FreeRec(pScreenInfo); - return FALSE; - } - GeodeDebug(("GX2PreInit(10)!\n")); - - xf86SetCrtcForModes(pScreenInfo, 0); - GeodeDebug(("GX2PreInit(11)!\n")); - - /* Set the current mode to the first in the list */ - pScreenInfo->currentMode = pScreenInfo->modes; - GeodeDebug(("GX2PreInit(12)!\n")); - - /* Print the list of modes being used */ - xf86PrintModes(pScreenInfo); - GeodeDebug(("GX2PreInit(13)!\n")); - - /* Set the display resolution */ - xf86SetDpi(pScreenInfo, 0, 0); - GeodeDebug(("GX2PreInit(14)!\n")); - - if (xf86LoadSubModule(pScreenInfo, "fb") == NULL) { - GX2FreeRec(pScreenInfo); - return FALSE; - } - - xf86LoaderReqSymLists(nscFbSymbols, NULL); - GeodeDebug(("GX2PreInit(15)!\n")); - if (pGeode->NoAccel == FALSE) { - if (!xf86LoadSubModule(pScreenInfo, "xaa")) { - GX2FreeRec(pScreenInfo); - return FALSE; - } - xf86LoaderReqSymLists(nscXaaSymbols, NULL); - } - GeodeDebug(("GX2PreInit(16)!\n")); - if (pGeode->HWCursor == TRUE) { - if (!xf86LoadSubModule(pScreenInfo, "ramdac")) { - GX2FreeRec(pScreenInfo); - return FALSE; - } - xf86LoaderReqSymLists(nscRamdacSymbols, NULL); - } - GeodeDebug(("GX2PreInit(17)!\n")); - /* Load shadowfb if needed */ - if (pGeode->ShadowFB) { - if (!xf86LoadSubModule(pScreenInfo, "shadowfb")) { - GX2FreeRec(pScreenInfo); - return FALSE; - } - xf86LoaderReqSymLists(nscShadowSymbols, NULL); - } - GeodeDebug(("GX2PreInit(18)!\n")); - #ifndef XSERVER_LIBPCIACCESS - if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) { - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, - "xf86RegisterResources() found resource conflicts\n")); - GX2FreeRec(pScreenInfo); - return FALSE; - } - #endif - GX2UnmapMem(pScreenInfo); - GeodeDebug(("GX2PreInit ... done successfully!\n")); - (void) from; - return TRUE; + sAdapterInfo.dwFrameBufferSize, +#else /* STB_X */ + gfx_get_frame_buffer_size(), +#endif /* STB_X */ + LOOKUP_BEST_REFRESH); + + DEBUGMSG(1, (pScreenInfo->scrnIndex, from, + "xf86ValidateModes: %d %d %d\n", + pScreenInfo->virtualX, + pScreenInfo->virtualY, pScreenInfo->displayWidth)); + if (i == -1) { + GX2FreeRec(pScreenInfo); + return FALSE; + } + GeodeDebug(("GX2PreInit(8)!\n")); + + /* Prune the modes marked as invalid */ + xf86PruneDriverModes(pScreenInfo); + + GeodeDebug(("GX2PreInit(9)!\n")); + if (i == 0 || pScreenInfo->modes == NULL) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "No valid modes found\n")); + GX2FreeRec(pScreenInfo); + return FALSE; + } + GeodeDebug(("GX2PreInit(10)!\n")); + + xf86SetCrtcForModes(pScreenInfo, 0); + GeodeDebug(("GX2PreInit(11)!\n")); + + /* Set the current mode to the first in the list */ + pScreenInfo->currentMode = pScreenInfo->modes; + GeodeDebug(("GX2PreInit(12)!\n")); + + /* Print the list of modes being used */ + xf86PrintModes(pScreenInfo); + GeodeDebug(("GX2PreInit(13)!\n")); + + /* Set the display resolution */ + xf86SetDpi(pScreenInfo, 0, 0); + GeodeDebug(("GX2PreInit(14)!\n")); + + if (xf86LoadSubModule(pScreenInfo, "fb") == NULL) { + GX2FreeRec(pScreenInfo); + return FALSE; + } + + xf86LoaderReqSymLists(nscFbSymbols, NULL); + GeodeDebug(("GX2PreInit(15)!\n")); + if (pGeode->NoAccel == FALSE) { + if (!xf86LoadSubModule(pScreenInfo, "xaa")) { + GX2FreeRec(pScreenInfo); + return FALSE; + } + xf86LoaderReqSymLists(nscXaaSymbols, NULL); + } + GeodeDebug(("GX2PreInit(16)!\n")); + if (pGeode->HWCursor == TRUE) { + if (!xf86LoadSubModule(pScreenInfo, "ramdac")) { + GX2FreeRec(pScreenInfo); + return FALSE; + } + xf86LoaderReqSymLists(nscRamdacSymbols, NULL); + } + GeodeDebug(("GX2PreInit(17)!\n")); + /* Load shadowfb if needed */ + if (pGeode->ShadowFB) { + if (!xf86LoadSubModule(pScreenInfo, "shadowfb")) { + GX2FreeRec(pScreenInfo); + return FALSE; + } + xf86LoaderReqSymLists(nscShadowSymbols, NULL); + } + GeodeDebug(("GX2PreInit(18)!\n")); +#ifndef XSERVER_LIBPCIACCESS + if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) { + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_ERROR, + "xf86RegisterResources() found resource conflicts\n")); + GX2FreeRec(pScreenInfo); + return FALSE; + } +#endif + GX2UnmapMem(pScreenInfo); + GeodeDebug(("GX2PreInit ... done successfully!\n")); + (void) from; + return TRUE; } /*---------------------------------------------------------------------------- @@ -1030,19 +1040,19 @@ GX2PreInit(ScrnInfoPtr pScreenInfo, int flags) static void GX2Restore(ScrnInfoPtr pScreenInfo) { - GeodePtr pGeode; - - GeodeDebug(("GX2Restore!\n")); - /* Get driver private structure */ - if (!(pGeode = GX2GetRec(pScreenInfo))) - return; - if (pGeode->FBVGAActive) { - vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo); - - vgaHWProtect(pScreenInfo, TRUE); - vgaHWRestore(pScreenInfo, &pvgaHW->SavedReg, VGA_SR_ALL); - vgaHWProtect(pScreenInfo, FALSE); - } + GeodePtr pGeode; + + GeodeDebug(("GX2Restore!\n")); + /* Get driver private structure */ + if (!(pGeode = GX2GetRec(pScreenInfo))) + return; + if (pGeode->FBVGAActive) { + vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo); + + vgaHWProtect(pScreenInfo, TRUE); + vgaHWRestore(pScreenInfo, &pvgaHW->SavedReg, VGA_SR_ALL); + vgaHWProtect(pScreenInfo, FALSE); + } } /*---------------------------------------------------------------------------- @@ -1062,29 +1072,29 @@ GX2Restore(ScrnInfoPtr pScreenInfo) static int GX2CalculatePitchBytes(unsigned int width, unsigned int bpp) { - int lineDelta = width * (bpp >> 3); - - if (width < 640) { - /* low resolutions have both pixel and line doubling */ - DEBUGMSG(1, (0, X_PROBED, "lower resolution %d %d\n", - width, lineDelta)); - lineDelta <<= 1; - } - /* needed in Rotate mode when in accel is turned off */ - if (1) { /*!pGeode->NoAccel */ - if (lineDelta > 4096) - lineDelta = 8192; - else if (lineDelta > 2048) - lineDelta = 4096; - else if (lineDelta > 1024) - lineDelta = 2048; - else - lineDelta = 1024; - } - - DEBUGMSG(1, (0, X_PROBED, "pitch %d %d\n", width, lineDelta)); - - return lineDelta; + int lineDelta = width * (bpp >> 3); + + if (width < 640) { + /* low resolutions have both pixel and line doubling */ + DEBUGMSG(1, (0, X_PROBED, "lower resolution %d %d\n", + width, lineDelta)); + lineDelta <<= 1; + } + /* needed in Rotate mode when in accel is turned off */ + if (1) { /*!pGeode->NoAccel */ + if (lineDelta > 4096) + lineDelta = 8192; + else if (lineDelta > 2048) + lineDelta = 4096; + else if (lineDelta > 1024) + lineDelta = 2048; + else + lineDelta = 1024; + } + + DEBUGMSG(1, (0, X_PROBED, "pitch %d %d\n", width, lineDelta)); + + return lineDelta; } /*---------------------------------------------------------------------------- @@ -1104,63 +1114,63 @@ static int GX2GetRefreshRate(DisplayModePtr pMode) { #define THRESHOLD 2 - unsigned int i; - static int validRates[] = { 50, 56, 60, 70, 72, 75, 85 }; /* Hz */ - unsigned long dotClock; - int refreshRate; - int selectedRate; + unsigned int i; + static int validRates[] = { 50, 56, 60, 70, 72, 75, 85 }; /* Hz */ + unsigned long dotClock; + int refreshRate; + int selectedRate; - dotClock = pMode->SynthClock * 1000; - refreshRate = dotClock / pMode->CrtcHTotal / pMode->CrtcVTotal; + dotClock = pMode->SynthClock * 1000; + refreshRate = dotClock / pMode->CrtcHTotal / pMode->CrtcVTotal; - if ((pMode->CrtcHTotal < 640) && (pMode->CrtcVTotal < 480)) - refreshRate >>= 2; /* double pixel and double scan */ + if ((pMode->CrtcHTotal < 640) && (pMode->CrtcVTotal < 480)) + refreshRate >>= 2; /* double pixel and double scan */ - DEBUGMSG(1, (0, X_PROBED, "dotclock %d %d\n", dotClock, refreshRate)); + DEBUGMSG(1, (0, X_PROBED, "dotclock %d %d\n", dotClock, refreshRate)); - selectedRate = validRates[0]; + selectedRate = validRates[0]; - for (i = 0; i < (sizeof(validRates) / sizeof(validRates[0])); i++) { - if (validRates[i] < (refreshRate + THRESHOLD)) { - selectedRate = validRates[i]; - } - } - return selectedRate; + for (i = 0; i < (sizeof(validRates) / sizeof(validRates[0])); i++) { + if (validRates[i] < (refreshRate + THRESHOLD)) { + selectedRate = validRates[i]; + } + } + return selectedRate; } void gx2_clear_screen(int width, int height) { - /* clean up the frame buffer memory */ - GFX(set_solid_pattern(0)); - GFX(set_raster_operation(0xF0)); - GFX(pattern_fill(0, 0, width, height)); + /* clean up the frame buffer memory */ + GFX(set_solid_pattern(0)); + GFX(set_raster_operation(0xF0)); + GFX(pattern_fill(0, 0, width, height)); } void gx2_set_DvLineSize(unsigned int pitch) { - unsigned long temp, dv_size = MDC_DV_LINE_SIZE_1024; + 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; - } + 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 */ + /* WRITE DIRTY/VALID CONTROL WITH LINE LENGTH */ #if defined(STB_X) - Gal_read_register(GAL_REG, MDC_DV_CTL, &temp, 4); - temp = (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size; - Gal_write_register(GAL_REG, MDC_DV_CTL, temp, 4); + Gal_read_register(GAL_REG, MDC_DV_CTL, &temp, 4); + temp = (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size; + Gal_write_register(GAL_REG, MDC_DV_CTL, temp, 4); #else - temp = READ_REG32(MDC_DV_CTL); - WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size); + temp = READ_REG32(MDC_DV_CTL); + WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size); #endif } @@ -1182,117 +1192,117 @@ gx2_set_DvLineSize(unsigned int pitch) static Bool GX2SetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); + GeodePtr pGeode = GEODEPTR(pScreenInfo); - DCount = 50; - /* unsigned int compOffset, compPitch, compSize; */ - GeodeDebug(("GX2SetMode!\n")); + DCount = 50; + /* unsigned int compOffset, compPitch, compSize; */ + GeodeDebug(("GX2SetMode!\n")); #if !defined(STB_X) - DEBUGMSG(1, (0, X_NONE, "Set mode %X %X %X %X %X\n", - gfx_virt_regptr, - gfx_virt_gpptr, - gfx_virt_spptr, gfx_virt_vidptr, gfx_virt_fbptr)); -#endif /* STB_X */ - - /* Set the VT semaphore */ - pScreenInfo->vtSema = TRUE; - DEBUGMSG(1, (0, X_NONE, "Set mode")); - - /* The timing will be adjusted later */ - GeodeDebug(("Set display mode: %dx%d-%d (%dHz) Pitch %d\n", - pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, - GX2GetRefreshRate(pMode), pGeode->Pitch)); - - GeodeDebug(("Before setting the mode\n")); - if (1) { - { /* TV not selected */ - - DEBUGMSG(1, (0, X_PROBED, "Setting Display for CRT or TFT\n")); - - if (pGeode->Panel) { - DEBUGMSG(0, (0, X_PROBED, "Setting Display for TFT\n")); - DEBUGMSG(1, (0, X_PROBED, "Restore Panel %d %d %d %d %d\n", - pGeode->FPBX, pGeode->FPBY, - pMode->CrtcHDisplay, - pMode->CrtcVDisplay, pScreenInfo->bitsPerPixel)); - - DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "FP Bios %d\n", - pGeode->Panel)); - GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY, - pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel)); - } else { - /* display is crt */ - DEBUGMSG(1, (0, X_PROBED, "Setting Display for CRT %dx%d-%d@%d\n", - pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, - GX2GetRefreshRate(pMode))); - GFX(set_display_mode(pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, - GX2GetRefreshRate(pMode))); - - /* adjust the pitch */ - GFX(set_display_pitch(pGeode->Pitch)); - } - GFX(set_bpp(pScreenInfo->bitsPerPixel)); - /* enable crt */ - GFX(set_crt_enable(CRT_ENABLE)); - } - GFX(set_display_offset(0L)); - GFX(wait_vertical_blank()); - - DEBUGMSG(1, (0, X_PROBED, "Display mode set\n")); - /* enable compression if option selected */ - if (pGeode->Compression) { - DEBUGMSG(1, (0, X_PROBED, "Compression mode set %d\n", - pGeode->Compression)); - /* set the compression parameters,and it will be turned on later. */ - gx2_set_DvLineSize(pGeode->Pitch); + DEBUGMSG(1, (0, X_NONE, "Set mode %X %X %X %X %X\n", + gfx_virt_regptr, + gfx_virt_gpptr, + gfx_virt_spptr, gfx_virt_vidptr, gfx_virt_fbptr)); +#endif /* STB_X */ + + /* Set the VT semaphore */ + pScreenInfo->vtSema = TRUE; + DEBUGMSG(1, (0, X_NONE, "Set mode")); + + /* The timing will be adjusted later */ + GeodeDebug(("Set display mode: %dx%d-%d (%dHz) Pitch %d\n", + pMode->CrtcHDisplay, + pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, + GX2GetRefreshRate(pMode), pGeode->Pitch)); + + GeodeDebug(("Before setting the mode\n")); + if (1) { + { /* TV not selected */ + + DEBUGMSG(1, (0, X_PROBED, "Setting Display for CRT or TFT\n")); + + if (pGeode->Panel) { + DEBUGMSG(0, (0, X_PROBED, "Setting Display for TFT\n")); + DEBUGMSG(1, (0, X_PROBED, "Restore Panel %d %d %d %d %d\n", + pGeode->FPBX, pGeode->FPBY, + pMode->CrtcHDisplay, + pMode->CrtcVDisplay, pScreenInfo->bitsPerPixel)); + + DEBUGMSG(1, (pScreenInfo->scrnIndex, X_CONFIG, "FP Bios %d\n", + pGeode->Panel)); + GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY, + pMode->CrtcHDisplay, + pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel)); + } + else { + /* display is crt */ + DEBUGMSG(1, + (0, X_PROBED, "Setting Display for CRT %dx%d-%d@%d\n", + pMode->CrtcHDisplay, pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, GX2GetRefreshRate(pMode))); + GFX(set_display_mode + (pMode->CrtcHDisplay, pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, GX2GetRefreshRate(pMode))); + + /* adjust the pitch */ + GFX(set_display_pitch(pGeode->Pitch)); + } + GFX(set_bpp(pScreenInfo->bitsPerPixel)); + /* enable crt */ + GFX(set_crt_enable(CRT_ENABLE)); + } + GFX(set_display_offset(0L)); + GFX(wait_vertical_blank()); + + DEBUGMSG(1, (0, X_PROBED, "Display mode set\n")); + /* enable compression if option selected */ + if (pGeode->Compression) { + DEBUGMSG(1, (0, X_PROBED, "Compression mode set %d\n", + pGeode->Compression)); + /* set the compression parameters,and it will be turned on later. */ + gx2_set_DvLineSize(pGeode->Pitch); #if defined(STB_X) - Gal_set_compression_parameters(GAL_COMPRESSION_ALL, - pGeode->CBOffset, - pGeode->CBPitch, pGeode->CBSize); - - /* set the compression buffer, all parameters already set */ - Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); -#else /* STB_X */ - gfx_set_compression_offset(pGeode->CBOffset); - gfx_set_compression_pitch(pGeode->CBPitch); - gfx_set_compression_size(pGeode->CBSize); - - /* set the compression buffer, all parameters already set */ - gfx_set_compression_enable(1); -#endif /* STB_X */ - - } - if (pGeode->HWCursor) { - /* Load blank cursor */ - GX2LoadCursorImage(pScreenInfo, NULL); - GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0)); - GFX(set_cursor_enable(1)); - } - } else { - GeodeDebug(("GX2Restore ... ")); - GX2Restore(pScreenInfo); - GeodeDebug(("done.\n")); - } - - GeodeDebug(("done.\n")); - /* Reenable the hardware cursor after the mode switch */ - if (pGeode->HWCursor == TRUE) { - GeodeDebug(("GX2ShowCursor ... ")); - GX2ShowCursor(pScreenInfo); - GeodeDebug(("done.\n")); - } - /* Restore the contents in the screen info */ - GeodeDebug(("After setting the mode\n")); - return TRUE; + Gal_set_compression_parameters(GAL_COMPRESSION_ALL, + pGeode->CBOffset, + pGeode->CBPitch, pGeode->CBSize); + + /* set the compression buffer, all parameters already set */ + Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); +#else /* STB_X */ + gfx_set_compression_offset(pGeode->CBOffset); + gfx_set_compression_pitch(pGeode->CBPitch); + gfx_set_compression_size(pGeode->CBSize); + + /* set the compression buffer, all parameters already set */ + gfx_set_compression_enable(1); +#endif /* STB_X */ + + } + if (pGeode->HWCursor) { + /* Load blank cursor */ + GX2LoadCursorImage(pScreenInfo, NULL); + GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0)); + GFX(set_cursor_enable(1)); + } + } + else { + GeodeDebug(("GX2Restore ... ")); + GX2Restore(pScreenInfo); + GeodeDebug(("done.\n")); + } + + GeodeDebug(("done.\n")); + /* Reenable the hardware cursor after the mode switch */ + if (pGeode->HWCursor == TRUE) { + GeodeDebug(("GX2ShowCursor ... ")); + GX2ShowCursor(pScreenInfo); + GeodeDebug(("done.\n")); + } + /* Restore the contents in the screen info */ + GeodeDebug(("After setting the mode\n")); + return TRUE; } /*---------------------------------------------------------------------------- @@ -1315,165 +1325,165 @@ GX2SetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode) static Bool GX2EnterGraphics(ScreenPtr pScreen, ScrnInfoPtr pScreenInfo) { - GeodePtr pGeode = GX2GetRec(pScreenInfo); + GeodePtr pGeode = GX2GetRec(pScreenInfo); #if defined(STB_X) - Gal_get_display_timing(&pGeode->FBgfxdisplaytiming); - - /* Save Display offset */ - Gal_get_display_offset(&(pGeode->FBDisplayOffset)); - - /* Save the current Compression state */ - Gal_get_compression_enable(&(pGeode->FBCompressionEnable)); - Gal_get_compression_parameters(GAL_COMPRESSION_ALL, - &(pGeode->FBCompressionOffset), - &(pGeode->FBCompressionPitch), - &(pGeode->FBCompressionSize)); - - /* Save Cursor offset */ - { - unsigned short x, y, xhot, yhot; - - Gal_get_cursor_position(&(pGeode->FBCursorOffset), - &x, &y, &xhot, &yhot); - } - /* Save the Panel state */ - Gal_pnl_save(); -#else /* STB_X */ - /* Save CRT State */ - 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(); - - /* Save Display offset */ - pGeode->FBDisplayOffset = gfx_get_display_offset(); - - /* Save the current Compression state */ - pGeode->FBCompressionEnable = gfx_get_compression_enable(); - pGeode->FBCompressionOffset = gfx_get_compression_offset(); - pGeode->FBCompressionPitch = gfx_get_compression_pitch(); - pGeode->FBCompressionSize = gfx_get_compression_size(); - - /* Save Cursor offset */ - pGeode->FBCursorOffset = gfx_get_cursor_offset(); - - /* Save the Panel state */ - Pnl_SavePanelState(); - - /* only if comming from VGA */ - if (pGeode->FBVGAActive) { - unsigned short sequencer; - vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo); - - /* Map VGA aperture */ - if (!vgaHWMapMem(pScreenInfo)) - return FALSE; - - /* Unlock VGA registers */ - vgaHWUnlock(pvgaHW); - - /* Save the current state and setup the current mode */ - vgaHWSave(pScreenInfo, &VGAHWPTR(pScreenInfo)->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. */ - - 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); - - /* 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); - } -#endif /* STB */ - - if (!GX2SetMode(pScreenInfo, pScreenInfo->currentMode)) { - return FALSE; - } - - /* clear the frame buffer, for annoying noise during mode switch */ - gx2_clear_screen(pScreenInfo->currentMode->CrtcHDisplay, - pScreenInfo->currentMode->CrtcVDisplay); - - return TRUE; + Gal_get_display_timing(&pGeode->FBgfxdisplaytiming); + + /* Save Display offset */ + Gal_get_display_offset(&(pGeode->FBDisplayOffset)); + + /* Save the current Compression state */ + Gal_get_compression_enable(&(pGeode->FBCompressionEnable)); + Gal_get_compression_parameters(GAL_COMPRESSION_ALL, + &(pGeode->FBCompressionOffset), + &(pGeode->FBCompressionPitch), + &(pGeode->FBCompressionSize)); + + /* Save Cursor offset */ + { + unsigned short x, y, xhot, yhot; + + Gal_get_cursor_position(&(pGeode->FBCursorOffset), + &x, &y, &xhot, &yhot); + } + /* Save the Panel state */ + Gal_pnl_save(); +#else /* STB_X */ + /* Save CRT State */ + 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(); + + /* Save Display offset */ + pGeode->FBDisplayOffset = gfx_get_display_offset(); + + /* Save the current Compression state */ + pGeode->FBCompressionEnable = gfx_get_compression_enable(); + pGeode->FBCompressionOffset = gfx_get_compression_offset(); + pGeode->FBCompressionPitch = gfx_get_compression_pitch(); + pGeode->FBCompressionSize = gfx_get_compression_size(); + + /* Save Cursor offset */ + pGeode->FBCursorOffset = gfx_get_cursor_offset(); + + /* Save the Panel state */ + Pnl_SavePanelState(); + + /* only if comming from VGA */ + if (pGeode->FBVGAActive) { + unsigned short sequencer; + vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo); + + /* Map VGA aperture */ + if (!vgaHWMapMem(pScreenInfo)) + return FALSE; + + /* Unlock VGA registers */ + vgaHWUnlock(pvgaHW); + + /* Save the current state and setup the current mode */ + vgaHWSave(pScreenInfo, &VGAHWPTR(pScreenInfo)->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. */ + + 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); + + /* 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); + } +#endif /* STB */ + + if (!GX2SetMode(pScreenInfo, pScreenInfo->currentMode)) { + return FALSE; + } + + /* clear the frame buffer, for annoying noise during mode switch */ + gx2_clear_screen(pScreenInfo->currentMode->CrtcHDisplay, + pScreenInfo->currentMode->CrtcVDisplay); + + return TRUE; } #if !defined(STB_X) void EnableDACPower(void) { - /* enable the DAC POWER */ - gfx_write_vid32(RCDF_VID_MISC, - gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH); + /* enable the DAC POWER */ + gfx_write_vid32(RCDF_VID_MISC, + gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH); } void redcloud_gfx_2_vga_fix(void) { - /* enable the DAC POWER */ - EnableDACPower(); + /* enable the DAC POWER */ + EnableDACPower(); #if 0 - int i; - - /* set the character width to 9 */ - gfx_outb(0x3C4, 0x1); - gfx_outb(0x3C5, 0x2); - - /* clear the gfx mode bit in VGA Attribute controller */ - gfx_inb(0x3DA); - gfx_outb(0x3C0, 0x30); - gfx_outb(0x3C0, 0xC); - - /* Re init the EGA Palaette */ - for (i = 0; i < 16; i++) { - gfx_inb(0x3DA); - gfx_outb(0x3C0, i); - gfx_outb(0x3C0, i); - } - - /* Re init the Overscan color to black */ - gfx_inb(0x3DA); - gfx_outb(0x3C0, 0x11); - gfx_outb(0x3C0, 0x0); - - /* Re Enable all the 4 color planes */ - gfx_inb(0x3DA); - gfx_outb(0x3C0, 0x12); - gfx_outb(0x3C0, 0xF); - - /* Clear Pixel Panning in VGA Attribute controller */ - gfx_inb(0x3DA); - gfx_outb(0x3C0, 0x33); - gfx_outb(0x3C0, 0x8); - - /* ??????????????????????? */ - gfx_outb(0x3C0, 0x20); - gfx_outb(0x3C0, 0x20); + int i; + + /* set the character width to 9 */ + gfx_outb(0x3C4, 0x1); + gfx_outb(0x3C5, 0x2); + + /* clear the gfx mode bit in VGA Attribute controller */ + gfx_inb(0x3DA); + gfx_outb(0x3C0, 0x30); + gfx_outb(0x3C0, 0xC); + + /* Re init the EGA Palaette */ + for (i = 0; i < 16; i++) { + gfx_inb(0x3DA); + gfx_outb(0x3C0, i); + gfx_outb(0x3C0, i); + } + + /* Re init the Overscan color to black */ + gfx_inb(0x3DA); + gfx_outb(0x3C0, 0x11); + gfx_outb(0x3C0, 0x0); + + /* Re Enable all the 4 color planes */ + gfx_inb(0x3DA); + gfx_outb(0x3C0, 0x12); + gfx_outb(0x3C0, 0xF); + + /* Clear Pixel Panning in VGA Attribute controller */ + gfx_inb(0x3DA); + gfx_outb(0x3C0, 0x33); + gfx_outb(0x3C0, 0x8); + + /* ??????????????????????? */ + gfx_outb(0x3C0, 0x20); + gfx_outb(0x3C0, 0x20); #endif } -#endif /* STB_X */ +#endif /* STB_X */ /*---------------------------------------------------------------------------- * GX2LeaveGraphics: @@ -1496,70 +1506,70 @@ redcloud_gfx_2_vga_fix(void) static void GX2LeaveGraphics(ScrnInfoPtr pScreenInfo) { - GeodePtr pGeode = GX2GetRec(pScreenInfo); + GeodePtr pGeode = GX2GetRec(pScreenInfo); - /* Restore VG registers */ + /* Restore VG registers */ #if defined(STB_X) - Gal_set_display_timing(&pGeode->FBgfxdisplaytiming); - - Gal_set_display_offset(pGeode->FBDisplayOffset); - - /* Restore Cursor */ - Gal_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0); - - /* Restore the previous Compression state */ - if (pGeode->FBCompressionEnable) { - Gal_set_compression_parameters(GAL_COMPRESSION_ALL, - pGeode->FBCompressionOffset, - pGeode->FBCompressionPitch, - pGeode->FBCompressionSize); - - Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); - } -#else /* STB_X */ - 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); - - GeodeDebug(("FBVGAActive %d\n", pGeode->FBVGAActive)); - if (pGeode->FBVGAActive) { - pGeode->vesa->pInt->num = 0x10; - pGeode->vesa->pInt->ax = 0x3; - pGeode->vesa->pInt->bx = 0; - xf86ExecX86int10(pGeode->vesa->pInt); - gfx_delay_milliseconds(3); - EnableDACPower(); - } -#endif /* STB_X */ + Gal_set_display_timing(&pGeode->FBgfxdisplaytiming); + + Gal_set_display_offset(pGeode->FBDisplayOffset); + + /* Restore Cursor */ + Gal_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0); + + /* Restore the previous Compression state */ + if (pGeode->FBCompressionEnable) { + Gal_set_compression_parameters(GAL_COMPRESSION_ALL, + pGeode->FBCompressionOffset, + pGeode->FBCompressionPitch, + pGeode->FBCompressionSize); + + Gal_set_compression_enable(GAL_COMPRESSION_ENABLE); + } +#else /* STB_X */ + 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); + + GeodeDebug(("FBVGAActive %d\n", pGeode->FBVGAActive)); + if (pGeode->FBVGAActive) { + pGeode->vesa->pInt->num = 0x10; + pGeode->vesa->pInt->ax = 0x3; + pGeode->vesa->pInt->bx = 0; + xf86ExecX86int10(pGeode->vesa->pInt); + gfx_delay_milliseconds(3); + EnableDACPower(); + } +#endif /* STB_X */ } /*---------------------------------------------------------------------------- @@ -1581,36 +1591,36 @@ GX2LeaveGraphics(ScrnInfoPtr pScreenInfo) static Bool GX2CloseScreen(int scrnIndex, ScreenPtr pScreen) { - ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - if (pGeode->ShadowPtr) - free(pGeode->ShadowPtr); - - DEBUGMSG(0, (scrnIndex, X_PROBED, "GX2CloseScreen %d\n", - pScreenInfo->vtSema)); - if (pScreenInfo->vtSema) - GX2LeaveGraphics(pScreenInfo); - - if (pGeode->AccelInfoRec) - XAADestroyInfoRec(pGeode->AccelInfoRec); - - if (pGeode->AccelImageWriteBufferOffsets) { - free(pGeode->AccelImageWriteBufferOffsets); - pGeode->AccelImageWriteBufferOffsets = 0x0; - } - /* free the allocated off screen area */ - xf86FreeOffscreenArea(pGeode->AccelImgArea); - xf86FreeOffscreenArea(pGeode->CompressionArea); - - pScreenInfo->vtSema = FALSE; - - GX2UnmapMem(pScreenInfo); - if (pGeode && (pScreen->CloseScreen = pGeode->CloseScreen)) { - pGeode->CloseScreen = NULL; - return ((*pScreen->CloseScreen) (scrnIndex, pScreen)); - } - return TRUE; + ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + if (pGeode->ShadowPtr) + free(pGeode->ShadowPtr); + + DEBUGMSG(0, (scrnIndex, X_PROBED, "GX2CloseScreen %d\n", + pScreenInfo->vtSema)); + if (pScreenInfo->vtSema) + GX2LeaveGraphics(pScreenInfo); + + if (pGeode->AccelInfoRec) + XAADestroyInfoRec(pGeode->AccelInfoRec); + + if (pGeode->AccelImageWriteBufferOffsets) { + free(pGeode->AccelImageWriteBufferOffsets); + pGeode->AccelImageWriteBufferOffsets = 0x0; + } + /* free the allocated off screen area */ + xf86FreeOffscreenArea(pGeode->AccelImgArea); + xf86FreeOffscreenArea(pGeode->CompressionArea); + + pScreenInfo->vtSema = FALSE; + + GX2UnmapMem(pScreenInfo); + if (pGeode && (pScreen->CloseScreen = pGeode->CloseScreen)) { + pGeode->CloseScreen = NULL; + return ((*pScreen->CloseScreen) (scrnIndex, pScreen)); + } + return TRUE; } /*---------------------------------------------------------------------------- @@ -1631,65 +1641,65 @@ GX2CloseScreen(int scrnIndex, ScreenPtr pScreen) static void GX2DPMSSet(ScrnInfoPtr pScreenInfo, int mode, int flags) { - GeodePtr pGeode; + GeodePtr pGeode; - pGeode = GEODEPTR(pScreenInfo); + pGeode = GEODEPTR(pScreenInfo); - GeodeDebug(("GX2DPMSSet!\n")); + GeodeDebug(("GX2DPMSSet!\n")); - /* Check if we are actively controlling the display */ - if (!pScreenInfo->vtSema) { - ErrorF("GX2DPMSSet called when we not controlling the VT!\n"); - return; - } - switch (mode) { - case DPMSModeOn: - /* Screen: On; HSync: On; VSync: On */ - GFX(set_crt_enable(CRT_ENABLE)); + /* Check if we are actively controlling the display */ + if (!pScreenInfo->vtSema) { + ErrorF("GX2DPMSSet called when we not controlling the VT!\n"); + return; + } + switch (mode) { + case DPMSModeOn: + /* Screen: On; HSync: On; VSync: On */ + GFX(set_crt_enable(CRT_ENABLE)); #if defined(STB_X) - if (pGeode->Panel) - Gal_pnl_powerup(); -#else /* STB_X */ - if (pGeode->Panel) - Pnl_PowerUp(); -#endif /* STB_X */ - break; - - case DPMSModeStandby: - /* Screen: Off; HSync: Off; VSync: On */ - GFX(set_crt_enable(CRT_STANDBY)); + if (pGeode->Panel) + Gal_pnl_powerup(); +#else /* STB_X */ + if (pGeode->Panel) + Pnl_PowerUp(); +#endif /* STB_X */ + break; + + case DPMSModeStandby: + /* Screen: Off; HSync: Off; VSync: On */ + GFX(set_crt_enable(CRT_STANDBY)); #if defined(STB_X) - if (pGeode->Panel) - Gal_pnl_powerdown(); -#else /* STB_X */ - if (pGeode->Panel) - Pnl_PowerDown(); -#endif /* STB_X */ - break; - - case DPMSModeSuspend: - /* Screen: Off; HSync: On; VSync: Off */ - GFX(set_crt_enable(CRT_SUSPEND)); + if (pGeode->Panel) + Gal_pnl_powerdown(); +#else /* STB_X */ + if (pGeode->Panel) + Pnl_PowerDown(); +#endif /* STB_X */ + break; + + case DPMSModeSuspend: + /* Screen: Off; HSync: On; VSync: Off */ + GFX(set_crt_enable(CRT_SUSPEND)); #if defined(STB_X) - if (pGeode->Panel) - Gal_pnl_powerdown(); -#else /* STB_X */ - if (pGeode->Panel) - Pnl_PowerDown(); -#endif /* STB_X */ - break; - case DPMSModeOff: - /* Screen: Off; HSync: Off; VSync: Off */ - GFX(set_crt_enable(CRT_DISABLE)); + if (pGeode->Panel) + Gal_pnl_powerdown(); +#else /* STB_X */ + if (pGeode->Panel) + Pnl_PowerDown(); +#endif /* STB_X */ + break; + case DPMSModeOff: + /* Screen: Off; HSync: Off; VSync: Off */ + GFX(set_crt_enable(CRT_DISABLE)); #if defined(STB_X) - if (pGeode->Panel) - Gal_pnl_powerdown(); -#else /* STB_X */ - if (pGeode->Panel) - Pnl_PowerDown(); -#endif /* STB_X */ - break; - } + if (pGeode->Panel) + Gal_pnl_powerdown(); +#else /* STB_X */ + if (pGeode->Panel) + Pnl_PowerDown(); +#endif /* STB_X */ + break; + } } /*---------------------------------------------------------------------------- @@ -1712,311 +1722,315 @@ GX2DPMSSet(ScrnInfoPtr pScreenInfo, int mode, int flags) static Bool GX2ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { - ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; - GeodePtr pGeode; - int i; - Bool Inited = FALSE; - unsigned char *FBStart; - unsigned int req_offscreenmem; - int width, height, displayWidth; - VisualPtr visual; - BoxRec AvailBox; - RegionRec OffscreenRegion; - - DCount = 30; - GeodeDebug(("GX2ScreenInit!\n")); - /* Get driver private */ - pGeode = GX2GetRec(pScreenInfo); - GeodeDebug(("GX2ScreenInit(0)!\n")); - /* - * * Allocate a vgaHWRec - */ - GeodeDebug(("FBVGAActive %d\n", pGeode->FBVGAActive)); - if (pGeode->FBVGAActive) { - if (!vgaHWGetHWRec(pScreenInfo)) - return FALSE; - if (!vgaHWMapMem(pScreenInfo)) - return FALSE; - vgaHWGetIOBase(VGAHWPTR(pScreenInfo)); - } - - if (!GX2MapMem(pScreenInfo)) - return FALSE; - - pGeode->Pitch = GX2CalculatePitchBytes(pScreenInfo->virtualX, - pScreenInfo->bitsPerPixel); - - /* SET UP GRAPHICS MEMORY AVAILABLE FOR PIXMAP CACHE */ - AvailBox.x1 = 0; - AvailBox.y1 = pScreenInfo->virtualY; - AvailBox.x2 = pScreenInfo->displayWidth; - AvailBox.y2 = (pGeode->FBSize / pGeode->Pitch); - - pGeode->CursorSize = 16 * 64; /* 64x64 */ - - if (pGeode->HWCursor) { - /* Compute cursor buffer */ - /* Default cursor offset, end of the frame buffer */ - pGeode->CursorStartOffset = pGeode->FBSize - pGeode->CursorSize; - AvailBox.y2 -= 1; - } - - DEBUGMSG(1, (scrnIndex, X_PROBED, - "Memory manager initialized to (%d,%d) (%d,%d) %d %d %d\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2, - pGeode->Pitch, pScreenInfo->displayWidth, - pScreenInfo->bitsPerPixel)); - - /* set the offscreen offset accordingly */ - if (pGeode->Compression) { - - pGeode->CBPitch = 544; - pGeode->CBSize = 544; - - req_offscreenmem = pScreenInfo->virtualY * pGeode->CBPitch; - req_offscreenmem += pGeode->Pitch - 1; - req_offscreenmem /= pGeode->Pitch; - pGeode->CBOffset = AvailBox.y1 * pGeode->Pitch; - AvailBox.y1 += req_offscreenmem; - } - DEBUGMSG(1, (scrnIndex, X_PROBED, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); - - if (!pGeode->NoAccel) { - if (pGeode->NoOfImgBuffers > 0) { - if (pGeode->NoOfImgBuffers <= (AvailBox.y2 - AvailBox.y1)) { - pGeode->AccelImageWriteBufferOffsets = - malloc(sizeof(unsigned long) * pGeode->NoOfImgBuffers); - - pGeode->AccelImageWriteBufferOffsets[0] = - ((unsigned char *)pGeode->FBBase) + - (AvailBox.y1 * pGeode->Pitch); - - for (i = 1; i < pGeode->NoOfImgBuffers; i++) { - pGeode->AccelImageWriteBufferOffsets[i] = - pGeode->AccelImageWriteBufferOffsets[i - 1] + - pGeode->Pitch; - } - - for (i = 0; i < pGeode->NoOfImgBuffers; i++) { - DEBUGMSG(1, (scrnIndex, X_PROBED, - "memory %d %x\n", i, - pGeode->AccelImageWriteBufferOffsets[i])); - } - AvailBox.y1 += pGeode->NoOfImgBuffers; - } else { - xf86DrvMsg(scrnIndex, X_ERROR, - "Unable to reserve scanline area\n"); - } - } - DEBUGMSG(1, (scrnIndex, X_PROBED, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); - - REGION_INIT(pScreen, &OffscreenRegion, &AvailBox, 2); - - if (!xf86InitFBManagerRegion(pScreen, &OffscreenRegion)) { - xf86DrvMsg(scrnIndex, X_ERROR, - "Memory manager initialization to (%d,%d) (%d,%d) failed\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); - } else { - xf86DrvMsg(scrnIndex, X_INFO, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); - } - REGION_UNINIT(pScreen, &OffscreenRegion); - } - - /* Initialise graphics mode */ - if (!GX2EnterGraphics(pScreen, pScreenInfo)) - return FALSE; - - GX2AdjustFrame(scrnIndex, pScreenInfo->frameX0, pScreenInfo->frameY0, 0); - GeodeDebug(("GX2ScreenInit(1)!\n")); - - /* Reset visual list */ - miClearVisualTypes(); - GeodeDebug(("GX2ScreenInit(2)!\n")); - - /* Setup the visual we support */ - if (pScreenInfo->bitsPerPixel > 8) { - DEBUGMSG(1, (scrnIndex, X_PROBED, - "miSetVisualTypes %d %X %X %X\n", - pScreenInfo->depth, - TrueColorMask, - pScreenInfo->rgbBits, pScreenInfo->defaultVisual)); - - if (!miSetVisualTypes(pScreenInfo->depth, - TrueColorMask, - pScreenInfo->rgbBits, - pScreenInfo->defaultVisual)) { - return FALSE; - } - } else { - if (!miSetVisualTypes(pScreenInfo->depth, - miGetDefaultVisualMask(pScreenInfo->depth), - pScreenInfo->rgbBits, - pScreenInfo->defaultVisual)) { - return FALSE; - } - } - GeodeDebug(("GX2ScreenInit(3)!\n")); - - /* Set for RENDER extensions */ - miSetPixmapDepths(); - - /* Call the framebuffer layer's ScreenInit function, and fill in other - * * pScreen fields. - */ - - width = pScreenInfo->virtualX; - height = pScreenInfo->virtualY; - - displayWidth = pScreenInfo->displayWidth; - if (pGeode->Rotate) { - width = pScreenInfo->virtualY; - height = pScreenInfo->virtualX; - } - if (pGeode->ShadowFB) { - pGeode->ShadowPitch = BitmapBytePad(pScreenInfo->bitsPerPixel * width); - pGeode->ShadowPtr = malloc(pGeode->ShadowPitch * height); - displayWidth = pGeode->ShadowPitch / (pScreenInfo->bitsPerPixel >> 3); - FBStart = pGeode->ShadowPtr; - } else { - pGeode->ShadowPtr = NULL; - - FBStart = pGeode->FBBase; - DEBUGMSG(1, (0, X_PROBED, "FBStart %X \n", FBStart)); - } - - switch (pScreenInfo->bitsPerPixel) { - case 8: - case 16: - case 24: - case 32: - Inited = fbScreenInit(pScreen, FBStart, width, height, - pScreenInfo->xDpi, pScreenInfo->yDpi, - displayWidth, pScreenInfo->bitsPerPixel); - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in ScreenInit\n", - pScreenInfo->bitsPerPixel); - Inited = FALSE; - break; - } - if (!Inited) - return FALSE; - - GeodeDebug(("GX2ScreenInit(4)!\n")); - xf86SetBlackWhitePixels(pScreen); - - if (!pGeode->ShadowFB) { - GX2DGAInit(pScreen); - } - GeodeDebug(("GX2ScreenInit(5)!\n")); - if (pScreenInfo->bitsPerPixel > 8) { - /* Fixup RGB ordering */ - visual = pScreen->visuals + pScreen->numVisuals; - while (--visual >= pScreen->visuals) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScreenInfo->offset.red; - visual->offsetGreen = pScreenInfo->offset.green; - visual->offsetBlue = pScreenInfo->offset.blue; - visual->redMask = pScreenInfo->mask.red; - visual->greenMask = pScreenInfo->mask.green; - visual->blueMask = pScreenInfo->mask.blue; - } - } - } - /* must be after RGB ordering fixed */ - fbPictureInit(pScreen, 0, 0); - - GeodeDebug(("GX2ScreenInit(6)!\n")); - if (!pGeode->NoAccel) { - GX2AccelInit(pScreen); - } - GeodeDebug(("GX2ScreenInit(7)!\n")); - miInitializeBackingStore(pScreen); - xf86SetBackingStore(pScreen); - GeodeDebug(("GX2ScreenInit(8)!\n")); - /* Initialise software cursor */ - miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); - /* Initialize HW cursor layer. - * * Must follow software cursor initialization - */ - if (pGeode->HWCursor) { - if (!GX2HWCursorInit(pScreen)) - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Hardware cursor initialization failed\n"); - } - GeodeDebug(("GX2ScreenInit(9)!\n")); - /* Setup default colourmap */ - if (!miCreateDefColormap(pScreen)) { - return FALSE; - } - GeodeDebug(("GX2ScreenInit(10)!\n")); - /* Initialize colormap layer. - * * Must follow initialization of the default colormap - */ - if (!xf86HandleColormaps(pScreen, 256, 8, - GX2LoadPalette, NULL, - CMAP_PALETTED_TRUECOLOR | - CMAP_RELOAD_ON_MODE_SWITCH)) { - return FALSE; - } - - GeodeDebug(("GX2ScreenInit(11)!\n")); - - if (pGeode->ShadowFB) { - RefreshAreaFuncPtr refreshArea = GX2RefreshArea; - - if (pGeode->Rotate) { - if (!pGeode->PointerMoved) { - pGeode->PointerMoved = pScreenInfo->PointerMoved; - pScreenInfo->PointerMoved = GX2PointerMoved; - } - switch (pScreenInfo->bitsPerPixel) { - case 8: - refreshArea = GX2RefreshArea8; - break; - case 16: - refreshArea = GX2RefreshArea16; - break; - case 24: - refreshArea = GX2RefreshArea24; - break; - case 32: - refreshArea = GX2RefreshArea32; - break; - } - } - ShadowFBInit(pScreen, refreshArea); - } - xf86DPMSInit(pScreen, GX2DPMSSet, 0); - GeodeDebug(("GX2ScreenInit(12)!\n")); - - pScreenInfo->memPhysBase = (unsigned long)pGeode->FBBase; - pScreenInfo->fbOffset = 0; - - GeodeDebug(("GX2ScreenInit(13)!\n")); - GX2InitVideo(pScreen); /* needed for video */ - /* Wrap the screen's CloseScreen vector and set its - * SaveScreen vector - */ - pGeode->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = GX2CloseScreen; - - pScreen->SaveScreen = GX2SaveScreen; - GeodeDebug(("GX2ScreenInit(14)!\n")); - - /* Report any unused options */ - if (serverGeneration == 1) { - xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options); - } - GeodeDebug(("GX2ScreenInit(15)!\n")); - return TRUE; + ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; + GeodePtr pGeode; + int i; + Bool Inited = FALSE; + unsigned char *FBStart; + unsigned int req_offscreenmem; + int width, height, displayWidth; + VisualPtr visual; + BoxRec AvailBox; + RegionRec OffscreenRegion; + + DCount = 30; + GeodeDebug(("GX2ScreenInit!\n")); + /* Get driver private */ + pGeode = GX2GetRec(pScreenInfo); + GeodeDebug(("GX2ScreenInit(0)!\n")); + /* + * * Allocate a vgaHWRec + */ + GeodeDebug(("FBVGAActive %d\n", pGeode->FBVGAActive)); + if (pGeode->FBVGAActive) { + if (!vgaHWGetHWRec(pScreenInfo)) + return FALSE; + if (!vgaHWMapMem(pScreenInfo)) + return FALSE; + vgaHWGetIOBase(VGAHWPTR(pScreenInfo)); + } + + if (!GX2MapMem(pScreenInfo)) + return FALSE; + + pGeode->Pitch = GX2CalculatePitchBytes(pScreenInfo->virtualX, + pScreenInfo->bitsPerPixel); + + /* SET UP GRAPHICS MEMORY AVAILABLE FOR PIXMAP CACHE */ + AvailBox.x1 = 0; + AvailBox.y1 = pScreenInfo->virtualY; + AvailBox.x2 = pScreenInfo->displayWidth; + AvailBox.y2 = (pGeode->FBSize / pGeode->Pitch); + + pGeode->CursorSize = 16 * 64; /* 64x64 */ + + if (pGeode->HWCursor) { + /* Compute cursor buffer */ + /* Default cursor offset, end of the frame buffer */ + pGeode->CursorStartOffset = pGeode->FBSize - pGeode->CursorSize; + AvailBox.y2 -= 1; + } + + DEBUGMSG(1, (scrnIndex, X_PROBED, + "Memory manager initialized to (%d,%d) (%d,%d) %d %d %d\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2, + pGeode->Pitch, pScreenInfo->displayWidth, + pScreenInfo->bitsPerPixel)); + + /* set the offscreen offset accordingly */ + if (pGeode->Compression) { + + pGeode->CBPitch = 544; + pGeode->CBSize = 544; + + req_offscreenmem = pScreenInfo->virtualY * pGeode->CBPitch; + req_offscreenmem += pGeode->Pitch - 1; + req_offscreenmem /= pGeode->Pitch; + pGeode->CBOffset = AvailBox.y1 * pGeode->Pitch; + AvailBox.y1 += req_offscreenmem; + } + DEBUGMSG(1, (scrnIndex, X_PROBED, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); + + if (!pGeode->NoAccel) { + if (pGeode->NoOfImgBuffers > 0) { + if (pGeode->NoOfImgBuffers <= (AvailBox.y2 - AvailBox.y1)) { + pGeode->AccelImageWriteBufferOffsets = + malloc(sizeof(unsigned long) * pGeode->NoOfImgBuffers); + + pGeode->AccelImageWriteBufferOffsets[0] = + ((unsigned char *) pGeode->FBBase) + + (AvailBox.y1 * pGeode->Pitch); + + for (i = 1; i < pGeode->NoOfImgBuffers; i++) { + pGeode->AccelImageWriteBufferOffsets[i] = + pGeode->AccelImageWriteBufferOffsets[i - 1] + + pGeode->Pitch; + } + + for (i = 0; i < pGeode->NoOfImgBuffers; i++) { + DEBUGMSG(1, (scrnIndex, X_PROBED, + "memory %d %x\n", i, + pGeode->AccelImageWriteBufferOffsets[i])); + } + AvailBox.y1 += pGeode->NoOfImgBuffers; + } + else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Unable to reserve scanline area\n"); + } + } + DEBUGMSG(1, (scrnIndex, X_PROBED, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2)); + + REGION_INIT(pScreen, &OffscreenRegion, &AvailBox, 2); + + if (!xf86InitFBManagerRegion(pScreen, &OffscreenRegion)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Memory manager initialization to (%d,%d) (%d,%d) failed\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); + } + else { + xf86DrvMsg(scrnIndex, X_INFO, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2); + } + REGION_UNINIT(pScreen, &OffscreenRegion); + } + + /* Initialise graphics mode */ + if (!GX2EnterGraphics(pScreen, pScreenInfo)) + return FALSE; + + GX2AdjustFrame(scrnIndex, pScreenInfo->frameX0, pScreenInfo->frameY0, 0); + GeodeDebug(("GX2ScreenInit(1)!\n")); + + /* Reset visual list */ + miClearVisualTypes(); + GeodeDebug(("GX2ScreenInit(2)!\n")); + + /* Setup the visual we support */ + if (pScreenInfo->bitsPerPixel > 8) { + DEBUGMSG(1, (scrnIndex, X_PROBED, + "miSetVisualTypes %d %X %X %X\n", + pScreenInfo->depth, + TrueColorMask, + pScreenInfo->rgbBits, pScreenInfo->defaultVisual)); + + if (!miSetVisualTypes(pScreenInfo->depth, + TrueColorMask, + pScreenInfo->rgbBits, + pScreenInfo->defaultVisual)) { + return FALSE; + } + } + else { + if (!miSetVisualTypes(pScreenInfo->depth, + miGetDefaultVisualMask(pScreenInfo->depth), + pScreenInfo->rgbBits, + pScreenInfo->defaultVisual)) { + return FALSE; + } + } + GeodeDebug(("GX2ScreenInit(3)!\n")); + + /* Set for RENDER extensions */ + miSetPixmapDepths(); + + /* Call the framebuffer layer's ScreenInit function, and fill in other + * * pScreen fields. + */ + + width = pScreenInfo->virtualX; + height = pScreenInfo->virtualY; + + displayWidth = pScreenInfo->displayWidth; + if (pGeode->Rotate) { + width = pScreenInfo->virtualY; + height = pScreenInfo->virtualX; + } + if (pGeode->ShadowFB) { + pGeode->ShadowPitch = BitmapBytePad(pScreenInfo->bitsPerPixel * width); + pGeode->ShadowPtr = malloc(pGeode->ShadowPitch * height); + displayWidth = pGeode->ShadowPitch / (pScreenInfo->bitsPerPixel >> 3); + FBStart = pGeode->ShadowPtr; + } + else { + pGeode->ShadowPtr = NULL; + + FBStart = pGeode->FBBase; + DEBUGMSG(1, (0, X_PROBED, "FBStart %X \n", FBStart)); + } + + switch (pScreenInfo->bitsPerPixel) { + case 8: + case 16: + case 24: + case 32: + Inited = fbScreenInit(pScreen, FBStart, width, height, + pScreenInfo->xDpi, pScreenInfo->yDpi, + displayWidth, pScreenInfo->bitsPerPixel); + break; + default: + xf86DrvMsg(scrnIndex, X_ERROR, + "Internal error: invalid bpp (%d) in ScreenInit\n", + pScreenInfo->bitsPerPixel); + Inited = FALSE; + break; + } + if (!Inited) + return FALSE; + + GeodeDebug(("GX2ScreenInit(4)!\n")); + xf86SetBlackWhitePixels(pScreen); + + if (!pGeode->ShadowFB) { + GX2DGAInit(pScreen); + } + GeodeDebug(("GX2ScreenInit(5)!\n")); + if (pScreenInfo->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScreenInfo->offset.red; + visual->offsetGreen = pScreenInfo->offset.green; + visual->offsetBlue = pScreenInfo->offset.blue; + visual->redMask = pScreenInfo->mask.red; + visual->greenMask = pScreenInfo->mask.green; + visual->blueMask = pScreenInfo->mask.blue; + } + } + } + /* must be after RGB ordering fixed */ + fbPictureInit(pScreen, 0, 0); + + GeodeDebug(("GX2ScreenInit(6)!\n")); + if (!pGeode->NoAccel) { + GX2AccelInit(pScreen); + } + GeodeDebug(("GX2ScreenInit(7)!\n")); + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + GeodeDebug(("GX2ScreenInit(8)!\n")); + /* Initialise software cursor */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + /* Initialize HW cursor layer. + * * Must follow software cursor initialization + */ + if (pGeode->HWCursor) { + if (!GX2HWCursorInit(pScreen)) + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + } + GeodeDebug(("GX2ScreenInit(9)!\n")); + /* Setup default colourmap */ + if (!miCreateDefColormap(pScreen)) { + return FALSE; + } + GeodeDebug(("GX2ScreenInit(10)!\n")); + /* Initialize colormap layer. + * * Must follow initialization of the default colormap + */ + if (!xf86HandleColormaps(pScreen, 256, 8, + GX2LoadPalette, NULL, + CMAP_PALETTED_TRUECOLOR | + CMAP_RELOAD_ON_MODE_SWITCH)) { + return FALSE; + } + + GeodeDebug(("GX2ScreenInit(11)!\n")); + + if (pGeode->ShadowFB) { + RefreshAreaFuncPtr refreshArea = GX2RefreshArea; + + if (pGeode->Rotate) { + if (!pGeode->PointerMoved) { + pGeode->PointerMoved = pScreenInfo->PointerMoved; + pScreenInfo->PointerMoved = GX2PointerMoved; + } + switch (pScreenInfo->bitsPerPixel) { + case 8: + refreshArea = GX2RefreshArea8; + break; + case 16: + refreshArea = GX2RefreshArea16; + break; + case 24: + refreshArea = GX2RefreshArea24; + break; + case 32: + refreshArea = GX2RefreshArea32; + break; + } + } + ShadowFBInit(pScreen, refreshArea); + } + xf86DPMSInit(pScreen, GX2DPMSSet, 0); + GeodeDebug(("GX2ScreenInit(12)!\n")); + + pScreenInfo->memPhysBase = (unsigned long) pGeode->FBBase; + pScreenInfo->fbOffset = 0; + + GeodeDebug(("GX2ScreenInit(13)!\n")); + GX2InitVideo(pScreen); /* needed for video */ + /* Wrap the screen's CloseScreen vector and set its + * SaveScreen vector + */ + pGeode->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = GX2CloseScreen; + + pScreen->SaveScreen = GX2SaveScreen; + GeodeDebug(("GX2ScreenInit(14)!\n")); + + /* Report any unused options */ + if (serverGeneration == 1) { + xf86ShowUnusedOptions(pScreenInfo->scrnIndex, pScreenInfo->options); + } + GeodeDebug(("GX2ScreenInit(15)!\n")); + return TRUE; } /*---------------------------------------------------------------------------- @@ -2037,8 +2051,8 @@ GX2ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) Bool GX2SwitchMode(int scrnIndex, DisplayModePtr pMode, int flags) { - GeodeDebug(("GX2SwitchMode!\n")); - return GX2SetMode(xf86Screens[scrnIndex], pMode); + GeodeDebug(("GX2SwitchMode!\n")); + return GX2SetMode(xf86Screens[scrnIndex], pMode); } /*---------------------------------------------------------------------------- @@ -2059,17 +2073,17 @@ GX2SwitchMode(int scrnIndex, DisplayModePtr pMode, int flags) void GX2AdjustFrame(int scrnIndex, int x, int y, int flags) { - ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; - GeodePtr pGeode = GX2GetRec(pScreenInfo); - unsigned long offset; + ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; + GeodePtr pGeode = GX2GetRec(pScreenInfo); + unsigned long offset; - /* y offset */ - offset = (unsigned long)y *(unsigned long)pGeode->Pitch; + /* y offset */ + offset = (unsigned long) y *(unsigned long) pGeode->Pitch; - /* x offset */ - offset += x * (pScreenInfo->bitsPerPixel >> 3); + /* x offset */ + offset += x * (pScreenInfo->bitsPerPixel >> 3); - GFX(set_display_offset(offset)); + GFX(set_display_offset(offset)); } /*---------------------------------------------------------------------------- @@ -2089,8 +2103,8 @@ GX2AdjustFrame(int scrnIndex, int x, int y, int flags) static Bool GX2EnterVT(int scrnIndex, int flags) { - GeodeDebug(("GX2EnterVT!\n")); - return GX2EnterGraphics(NULL, xf86Screens[scrnIndex]); + GeodeDebug(("GX2EnterVT!\n")); + return GX2EnterGraphics(NULL, xf86Screens[scrnIndex]); } /*---------------------------------------------------------------------------- @@ -2110,8 +2124,8 @@ GX2EnterVT(int scrnIndex, int flags) static void GX2LeaveVT(int scrnIndex, int flags) { - GeodeDebug(("GX2LeaveVT!\n")); - GX2LeaveGraphics(xf86Screens[scrnIndex]); + GeodeDebug(("GX2LeaveVT!\n")); + GX2LeaveGraphics(xf86Screens[scrnIndex]); } /*---------------------------------------------------------------------------- @@ -2131,10 +2145,10 @@ GX2LeaveVT(int scrnIndex, int flags) static void GX2FreeScreen(int scrnIndex, int flags) { - GeodeDebug(("GX2FreeScreen!\n")); - if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) - vgaHWFreeHWRec(xf86Screens[scrnIndex]); - GX2FreeRec(xf86Screens[scrnIndex]); + GeodeDebug(("GX2FreeScreen!\n")); + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(xf86Screens[scrnIndex]); + GX2FreeRec(xf86Screens[scrnIndex]); } /*---------------------------------------------------------------------------- @@ -2156,44 +2170,44 @@ GX2FreeScreen(int scrnIndex, int flags) static ModeStatus GX2ValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags) { - unsigned int total_memory_required; - ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; - int ret = -1; - GeodePtr pGeode = GX2GetRec(pScreenInfo); - - DEBUGMSG(1, (0, X_NONE, "GeodeValidateMode: %dx%d %d %d\n", - pMode->CrtcHDisplay, pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, GX2GetRefreshRate(pMode))); - { - DEBUGMSG(1, (0, X_NONE, "CRT mode\n")); - if (pMode->Flags & V_INTERLACE) - return MODE_NO_INTERLACE; + unsigned int total_memory_required; + ScrnInfoPtr pScreenInfo = xf86Screens[scrnIndex]; + int ret = -1; + GeodePtr pGeode = GX2GetRec(pScreenInfo); + + DEBUGMSG(1, (0, X_NONE, "GeodeValidateMode: %dx%d %d %d\n", + pMode->CrtcHDisplay, pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, GX2GetRefreshRate(pMode))); + { + DEBUGMSG(1, (0, X_NONE, "CRT mode\n")); + if (pMode->Flags & V_INTERLACE) + return MODE_NO_INTERLACE; #if defined(STB_X) - Gal_is_display_mode_supported(pMode->CrtcHDisplay, pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, - GX2GetRefreshRate(pMode), &ret); -#else /* STB_X */ - ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay, - pMode->CrtcVDisplay, - pScreenInfo->bitsPerPixel, - GX2GetRefreshRate(pMode)); -#endif /* STB_X */ - } - if (ret < 0) - return MODE_NOMODE; - - total_memory_required = GX2CalculatePitchBytes(pMode->CrtcHDisplay, - pScreenInfo->bitsPerPixel) * - pMode->CrtcVDisplay; - - DEBUGMSG(1, (0, X_NONE, "Total Mem %X %X\n", - total_memory_required, pGeode->FBSize)); - - if (total_memory_required > pGeode->FBSize) - return MODE_MEM; - - return MODE_OK; + Gal_is_display_mode_supported(pMode->CrtcHDisplay, pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, + GX2GetRefreshRate(pMode), &ret); +#else /* STB_X */ + ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay, + pMode->CrtcVDisplay, + pScreenInfo->bitsPerPixel, + GX2GetRefreshRate(pMode)); +#endif /* STB_X */ + } + if (ret < 0) + return MODE_NOMODE; + + total_memory_required = GX2CalculatePitchBytes(pMode->CrtcHDisplay, + pScreenInfo->bitsPerPixel) * + pMode->CrtcVDisplay; + + DEBUGMSG(1, (0, X_NONE, "Total Mem %X %X\n", + total_memory_required, pGeode->FBSize)); + + if (total_memory_required > pGeode->FBSize) + return MODE_MEM; + + return MODE_OK; } /*---------------------------------------------------------------------------- @@ -2216,88 +2230,89 @@ GX2ValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags) static void GX2LoadPalette(ScrnInfoPtr pScreenInfo, - int numColors, int *indizes, LOCO * colors, VisualPtr pVisual) + int numColors, int *indizes, LOCO * colors, VisualPtr pVisual) { - 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)); - DEBUGMSG(0, (0, X_NONE, "GX2LoadPalette: %d %d %X\n", - numColors, index, color)); - - GFX(set_display_palette_entry(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)); + DEBUGMSG(0, (0, X_NONE, "GX2LoadPalette: %d %d %X\n", + numColors, index, color)); + + GFX(set_display_palette_entry(index, color)); + } } static Bool GX2MapMem(ScrnInfoPtr pScreenInfo) { - GeodePtr pGeode = GEODEPTR(pScreenInfo); + GeodePtr pGeode = GEODEPTR(pScreenInfo); #if defined(STB_X) - pGeode->FBBase = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, - pGeode->FBLinearAddr, - pGeode->FBSize); + pGeode->FBBase = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_FRAMEBUFFER, + pGeode->FBLinearAddr, + pGeode->FBSize); #else - gfx_virt_regptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, - (unsigned int) - gfx_get_cpu_register_base - (), pGeode->cpu_reg_size); - - if (pGeode->DetectedChipSet & GX2) { - gfx_virt_gpptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, - (unsigned int) - gfx_get_graphics_register_base - (), - pGeode->gp_reg_size); - } else { - gfx_virt_spptr = gfx_virt_regptr; - } - - gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, - (unsigned int) - gfx_get_vid_register_base - (), pGeode->vid_reg_size); - - gfx_virt_fbptr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, - pGeode->FBLinearAddr, - pGeode->FBSize); - - pGeode->FBBase = gfx_virt_fbptr; - - DEBUGMSG(1, (0, X_NONE, "Set mode %X %X %X %X %X\n", - gfx_virt_regptr, - gfx_virt_gpptr, - gfx_virt_spptr, gfx_virt_vidptr, gfx_virt_fbptr)); - - /* CHECK IF REGISTERS WERE MAPPED SUCCESSFULLY */ - if ((!gfx_virt_regptr) || - (!gfx_virt_gpptr) || (!gfx_virt_vidptr) || (!gfx_virt_fbptr)) { - DEBUGMSG(1, (0, X_NONE, "Could not map hardware registers.\n")); - return (FALSE); - } - - /* Map the XpressROM ptr to read what platform are we on */ - XpressROMPtr = (unsigned char *)xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, 0xF0000, - 0x10000); - - DEBUGMSG(1, (0, X_NONE, "adapter info %x %x %x %x, %X\n", - pGeode->cpu_version, - pGeode->vid_version, - pGeode->FBSize, pGeode->FBBase, XpressROMPtr)); + gfx_virt_regptr = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_MMIO, + (unsigned int) + gfx_get_cpu_register_base + (), pGeode->cpu_reg_size); + + if (pGeode->DetectedChipSet & GX2) { + gfx_virt_gpptr = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_MMIO, + (unsigned int) + gfx_get_graphics_register_base + (), + pGeode->gp_reg_size); + } + else { + gfx_virt_spptr = gfx_virt_regptr; + } + + gfx_virt_vidptr = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_MMIO, + (unsigned int) + gfx_get_vid_register_base + (), pGeode->vid_reg_size); + + gfx_virt_fbptr = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_FRAMEBUFFER, + pGeode->FBLinearAddr, + pGeode->FBSize); + + pGeode->FBBase = gfx_virt_fbptr; + + DEBUGMSG(1, (0, X_NONE, "Set mode %X %X %X %X %X\n", + gfx_virt_regptr, + gfx_virt_gpptr, + gfx_virt_spptr, gfx_virt_vidptr, gfx_virt_fbptr)); + + /* CHECK IF REGISTERS WERE MAPPED SUCCESSFULLY */ + if ((!gfx_virt_regptr) || + (!gfx_virt_gpptr) || (!gfx_virt_vidptr) || (!gfx_virt_fbptr)) { + DEBUGMSG(1, (0, X_NONE, "Could not map hardware registers.\n")); + return (FALSE); + } + + /* Map the XpressROM ptr to read what platform are we on */ + XpressROMPtr = (unsigned char *) xf86MapVidMem(pScreenInfo->scrnIndex, + VIDMEM_FRAMEBUFFER, 0xF0000, + 0x10000); + + DEBUGMSG(1, (0, X_NONE, "adapter info %x %x %x %x, %X\n", + pGeode->cpu_version, + pGeode->vid_version, + pGeode->FBSize, pGeode->FBBase, XpressROMPtr)); #endif - return TRUE; + return TRUE; } /* @@ -2308,21 +2323,21 @@ static Bool GX2UnmapMem(ScrnInfoPtr pScreenInfo) { #if !defined(STB_X) - GeodePtr pGeode = GEODEPTR(pScreenInfo); - - /* unmap all the memory map's */ - xf86UnMapVidMem(pScreenInfo->scrnIndex, - gfx_virt_regptr, pGeode->cpu_reg_size); - if (pGeode->DetectedChipSet & GX2) { - xf86UnMapVidMem(pScreenInfo->scrnIndex, - gfx_virt_gpptr, pGeode->gp_reg_size); - } - xf86UnMapVidMem(pScreenInfo->scrnIndex, - gfx_virt_vidptr, pGeode->vid_reg_size); - xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_fbptr, pGeode->FBSize); - xf86UnMapVidMem(pScreenInfo->scrnIndex, XpressROMPtr, 0x10000); -#endif /* STB_X */ - return TRUE; + GeodePtr pGeode = GEODEPTR(pScreenInfo); + + /* unmap all the memory map's */ + xf86UnMapVidMem(pScreenInfo->scrnIndex, + gfx_virt_regptr, pGeode->cpu_reg_size); + if (pGeode->DetectedChipSet & GX2) { + xf86UnMapVidMem(pScreenInfo->scrnIndex, + gfx_virt_gpptr, pGeode->gp_reg_size); + } + xf86UnMapVidMem(pScreenInfo->scrnIndex, + gfx_virt_vidptr, pGeode->vid_reg_size); + xf86UnMapVidMem(pScreenInfo->scrnIndex, gfx_virt_fbptr, pGeode->FBSize); + xf86UnMapVidMem(pScreenInfo->scrnIndex, XpressROMPtr, 0x10000); +#endif /* STB_X */ + return TRUE; } /* End of file */ diff --git a/src/nsc_gx2_shadow.c b/src/nsc_gx2_shadow.c index f190e1e..043d21a 100644 --- a/src/nsc_gx2_shadow.c +++ b/src/nsc_gx2_shadow.c @@ -181,26 +181,26 @@ void GX2RefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void GX2RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int width, height, Bpp, FBPitch; - unsigned char *src, *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int width, height, Bpp, FBPitch; + unsigned char *src, *dst; - Bpp = pScrn->bitsPerPixel >> 3; - FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); - while (num--) { - width = (pbox->x2 - pbox->x1) * Bpp; - height = pbox->y2 - pbox->y1; - src = pGeode->ShadowPtr + (pbox->y1 * pGeode->ShadowPitch) + - (pbox->x1 * Bpp); - dst = pGeode->FBBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); - while (height--) { - memcpy(dst, src, width); - dst += FBPitch; - src += pGeode->ShadowPitch; - } + Bpp = pScrn->bitsPerPixel >> 3; + FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); + while (num--) { + width = (pbox->x2 - pbox->x1) * Bpp; + height = pbox->y2 - pbox->y1; + src = pGeode->ShadowPtr + (pbox->y1 * pGeode->ShadowPitch) + + (pbox->x1 * Bpp); + dst = pGeode->FBBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); + while (height--) { + memcpy(dst, src, width); + dst += FBPitch; + src += pGeode->ShadowPitch; + } - pbox++; - } + pbox++; + } } /*---------------------------------------------------------------------------- @@ -221,18 +221,19 @@ GX2RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void GX2PointerMoved(int index, int x, int y) { - ScrnInfoPtr pScrn = xf86Screens[index]; - GeodePtr pGeode = GEODEPTR(pScrn); - int newX, newY; + ScrnInfoPtr pScrn = xf86Screens[index]; + GeodePtr pGeode = GEODEPTR(pScrn); + int newX, newY; - if (pGeode->Rotate == 1) { - newX = pScrn->pScreen->height - y - 1; - newY = x; - } else { - newX = y; - newY = pScrn->pScreen->width - x - 1; - } - (*pGeode->PointerMoved) (index, newX, newY); + if (pGeode->Rotate == 1) { + newX = pScrn->pScreen->height - y - 1; + newY = x; + } + else { + newX = y; + newY = pScrn->pScreen->width - x - 1; + } + (*pGeode->PointerMoved) (index, newX, newY); } /*---------------------------------------------------------------------------- @@ -253,46 +254,47 @@ GX2PointerMoved(int index, int x, int y) void GX2RefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2, - srcPitch3, srcPitch4; - CARD8 *dstPtr, *srcPtr, *src; - CARD32 *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2, + srcPitch3, srcPitch4; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pGeode->Rotate * pGeode->ShadowPitch; - srcPitch2 = srcPitch * 2; - srcPitch3 = srcPitch * 3; - srcPitch4 = srcPitch * 4; - while (num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~3; - y2 = (pbox->y2 + 3) & ~3; - height = (y2 - y1) >> 2; /* in dwords */ + dstPitch = pScrn->displayWidth; + srcPitch = -pGeode->Rotate * pGeode->ShadowPitch; + srcPitch2 = srcPitch * 2; + srcPitch3 = srcPitch * 3; + srcPitch4 = srcPitch * 4; + while (num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* in dwords */ - if (pGeode->Rotate == 1) { - dstPtr = pGeode->FBBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - y2; - srcPtr = pGeode->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; - } else { - dstPtr = pGeode->FBBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; - srcPtr = pGeode->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; - } - while (width--) { - src = srcPtr; - dst = (CARD32 *) dstPtr; - count = height; - while (count--) { - *(dst++) = src[0] | (src[srcPitch] << 8) | - (src[srcPitch2] << 16) | (src[srcPitch3] << 24); - src += srcPitch4; - } - srcPtr += pGeode->Rotate; - dstPtr += dstPitch; - } - pbox++; - } + if (pGeode->Rotate == 1) { + dstPtr = pGeode->FBBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = pGeode->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } + else { + dstPtr = pGeode->FBBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = pGeode->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; + } + while (width--) { + src = srcPtr; + dst = (CARD32 *) dstPtr; + count = height; + while (count--) { + *(dst++) = src[0] | (src[srcPitch] << 8) | + (src[srcPitch2] << 16) | (src[srcPitch3] << 24); + src += srcPitch4; + } + srcPtr += pGeode->Rotate; + dstPtr += dstPitch; + } + pbox++; + } } /*---------------------------------------------------------------------------- @@ -313,45 +315,46 @@ GX2RefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void GX2RefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2; - CARD16 *dstPtr, *srcPtr, *src; - CARD32 *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2; + CARD16 *dstPtr, *srcPtr, *src; + CARD32 *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pGeode->Rotate * pGeode->ShadowPitch >> 1; - srcPitch2 = srcPitch * 2; - while (num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~1; - y2 = (pbox->y2 + 1) & ~1; - height = (y2 - y1) >> 1; /* in dwords */ - if (pGeode->Rotate == 1) { - dstPtr = (CARD16 *) pGeode->FBBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - y2; - srcPtr = (CARD16 *) pGeode->ShadowPtr + - ((1 - y2) * srcPitch) + pbox->x1; - } else { - dstPtr = (CARD16 *) pGeode->FBBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; - srcPtr = (CARD16 *) pGeode->ShadowPtr + - (y1 * srcPitch) + pbox->x2 - 1; - } + dstPitch = pScrn->displayWidth; + srcPitch = -pGeode->Rotate * pGeode->ShadowPitch >> 1; + srcPitch2 = srcPitch * 2; + while (num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~1; + y2 = (pbox->y2 + 1) & ~1; + height = (y2 - y1) >> 1; /* in dwords */ + if (pGeode->Rotate == 1) { + dstPtr = (CARD16 *) pGeode->FBBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = (CARD16 *) pGeode->ShadowPtr + + ((1 - y2) * srcPitch) + pbox->x1; + } + else { + dstPtr = (CARD16 *) pGeode->FBBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = (CARD16 *) pGeode->ShadowPtr + + (y1 * srcPitch) + pbox->x2 - 1; + } - while (width--) { - src = srcPtr; - dst = (CARD32 *) dstPtr; - count = height; - while (count--) { - *(dst++) = src[0] | (src[srcPitch] << 16); - src += srcPitch2; - } - srcPtr += pGeode->Rotate; - dstPtr += dstPitch; - } + while (width--) { + src = srcPtr; + dst = (CARD32 *) dstPtr; + count = height; + while (count--) { + *(dst++) = src[0] | (src[srcPitch] << 16); + src += srcPitch2; + } + srcPtr += pGeode->Rotate; + dstPtr += dstPitch; + } - pbox++; - } + pbox++; + } } /*---------------------------------------------------------------------------- @@ -372,48 +375,49 @@ GX2RefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void GX2RefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2, srcPitch3; - CARD8 *dstPtr, *srcPtr, *src; - CARD32 *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch, srcPitch2, srcPitch3; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; - dstPitch = BitmapBytePad(pScrn->displayWidth * 24); - srcPitch = -pGeode->Rotate * pGeode->ShadowPitch; - srcPitch2 = srcPitch * 2; - srcPitch3 = srcPitch * 3; - while (num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~3; - y2 = (pbox->y2 + 3) & ~3; - height = (y2 - y1) >> 2; /* blocks of 3 dwords */ - if (pGeode->Rotate == 1) { - dstPtr = pGeode->FBBase + - (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); - srcPtr = pGeode->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); - } else { - dstPtr = pGeode->FBBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); - srcPtr = pGeode->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; - } - while (width--) { - src = srcPtr; - dst = (CARD32 *) dstPtr; - count = height; - while (count--) { - dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | - (src[srcPitch] << 24); - dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | - (src[srcPitch2] << 16) | (src[srcPitch2 + 1] << 24); - dst[2] = src[srcPitch2 + 2] | (src[srcPitch3] << 8) | - (src[srcPitch3 + 1] << 16) | (src[srcPitch3 + 2] << 24); - dst += 3; - src += srcPitch << 2; - } - srcPtr += pGeode->Rotate * 3; - dstPtr += dstPitch; - } - pbox++; - } + dstPitch = BitmapBytePad(pScrn->displayWidth * 24); + srcPitch = -pGeode->Rotate * pGeode->ShadowPitch; + srcPitch2 = srcPitch * 2; + srcPitch3 = srcPitch * 3; + while (num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* blocks of 3 dwords */ + if (pGeode->Rotate == 1) { + dstPtr = pGeode->FBBase + + (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); + srcPtr = pGeode->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); + } + else { + dstPtr = pGeode->FBBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); + srcPtr = pGeode->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; + } + while (width--) { + src = srcPtr; + dst = (CARD32 *) dstPtr; + count = height; + while (count--) { + dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | + (src[srcPitch] << 24); + dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | + (src[srcPitch2] << 16) | (src[srcPitch2 + 1] << 24); + dst[2] = src[srcPitch2 + 2] | (src[srcPitch3] << 8) | + (src[srcPitch3 + 1] << 16) | (src[srcPitch3 + 2] << 24); + dst += 3; + src += srcPitch << 2; + } + srcPtr += pGeode->Rotate * 3; + dstPtr += dstPitch; + } + pbox++; + } } /*---------------------------------------------------------------------------- @@ -434,40 +438,41 @@ GX2RefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) void GX2RefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { - GeodePtr pGeode = GEODEPTR(pScrn); - int count, width, height, dstPitch, srcPitch; - CARD32 *dstPtr, *srcPtr, *src, *dst; + GeodePtr pGeode = GEODEPTR(pScrn); + int count, width, height, dstPitch, srcPitch; + CARD32 *dstPtr, *srcPtr, *src, *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pGeode->Rotate * pGeode->ShadowPitch >> 2; - while (num--) { - width = pbox->x2 - pbox->x1; - height = pbox->y2 - pbox->y1; + dstPitch = pScrn->displayWidth; + srcPitch = -pGeode->Rotate * pGeode->ShadowPitch >> 2; + while (num--) { + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; - if (pGeode->Rotate == 1) { - dstPtr = (CARD32 *) pGeode->FBBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; - srcPtr = (CARD32 *) pGeode->ShadowPtr + - ((1 - pbox->y2) * srcPitch) + pbox->x1; - } else { - dstPtr = (CARD32 *) pGeode->FBBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; - srcPtr = (CARD32 *) pGeode->ShadowPtr + - (pbox->y1 * srcPitch) + pbox->x2 - 1; - } - while (width--) { - src = srcPtr; - dst = dstPtr; - count = height; - while (count--) { - *(dst++) = *src; - src += srcPitch; - } - srcPtr += pGeode->Rotate; - dstPtr += dstPitch; - } - pbox++; - } + if (pGeode->Rotate == 1) { + dstPtr = (CARD32 *) pGeode->FBBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; + srcPtr = (CARD32 *) pGeode->ShadowPtr + + ((1 - pbox->y2) * srcPitch) + pbox->x1; + } + else { + dstPtr = (CARD32 *) pGeode->FBBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; + srcPtr = (CARD32 *) pGeode->ShadowPtr + + (pbox->y1 * srcPitch) + pbox->x2 - 1; + } + while (width--) { + src = srcPtr; + dst = dstPtr; + count = height; + while (count--) { + *(dst++) = *src; + src += srcPitch; + } + srcPtr += pGeode->Rotate; + dstPtr += dstPitch; + } + pbox++; + } } /* End of file */ diff --git a/src/nsc_gx2_vga.c b/src/nsc_gx2_vga.c index 70ff713..0064bd0 100644 --- a/src/nsc_gx2_vga.c +++ b/src/nsc_gx2_vga.c @@ -157,7 +157,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); @@ -175,105 +175,106 @@ int gu2_vga_restore(gfx_vga_struct * vga, int flags); int gu2_get_vga_active(void) { - int data = gfx_read_reg32(MDC_GENERAL_CFG); + int data = gfx_read_reg32(MDC_GENERAL_CFG); - if (data & MDC_GCFG_VGAE) - return 1; - return 0; + if (data & MDC_GCFG_VGAE) + return 1; + return 0; } void gu2_vga_font_data(int flag) { - if (flag == 0) { - 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); - } 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; - } - } + if (flag == 0) { + 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); + } + 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; + } + } } void gu2_set_vga(int reset) { - int data = gfx_read_reg32(MDC_GENERAL_CFG); + int data = gfx_read_reg32(MDC_GENERAL_CFG); - if (reset) - data |= MDC_GCFG_VGAE; - else - data &= ~MDC_GCFG_VGAE; - gfx_write_reg32(MDC_GENERAL_CFG, data); + if (reset) + data |= MDC_GCFG_VGAE; + else + data &= ~MDC_GCFG_VGAE; + gfx_write_reg32(MDC_GENERAL_CFG, data); } int gu2_vga_seq_blanking(void) { - int tmp; + int tmp; - gfx_outb(0x3C4, 1); - tmp = gfx_inb(0x3C5); - tmp |= 0x20; - tmp |= tmp << 8; - gfx_outw(0x3C4, tmp); + gfx_outb(0x3C4, 1); + tmp = gfx_inb(0x3C5); + tmp |= 0x20; + tmp |= tmp << 8; + gfx_outw(0x3C4, tmp); - gfx_delay_milliseconds(1); - return (GFX_STATUS_OK); + gfx_delay_milliseconds(1); + return (GFX_STATUS_OK); } int gu2_vga_attr_ctrl(int reset) { - (void) gfx_inb(0x3DA); - gfx_outb(0x3C0, (unsigned char)(reset ? 0x00 : 0x20)); - if (reset) - (void) gfx_inb(0x3DA); - return (GFX_STATUS_OK); + (void) gfx_inb(0x3DA); + gfx_outb(0x3C0, (unsigned char) (reset ? 0x00 : 0x20)); + if (reset) + (void) gfx_inb(0x3DA); + return (GFX_STATUS_OK); } void gu2_vga_to_gfx(void) { - gu2_vga_attr_ctrl(0); + gu2_vga_attr_ctrl(0); - gu2_vga_seq_blanking(); - gfx_delay_milliseconds(2); + gu2_vga_seq_blanking(); + gfx_delay_milliseconds(2); - gu2_vga_extcrtc(0x3F, 1); + gu2_vga_extcrtc(0x3F, 1); } void gu2_gfx_to_vga(int vga_mode) { - char sequencer; + char sequencer; - gu2_vga_extcrtc(0x40, vga_mode); + gu2_vga_extcrtc(0x40, vga_mode); - /* clear the display blanking bit */ - gfx_outb(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_CLK_MODE); - sequencer = gfx_inb(MDC_SEQUENCER_DATA); - sequencer &= ~MDC_CLK_MODE_SCREEN_OFF; - sequencer |= 1; - gfx_outb(MDC_SEQUENCER_DATA, sequencer); + /* clear the display blanking bit */ + gfx_outb(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_CLK_MODE); + sequencer = gfx_inb(MDC_SEQUENCER_DATA); + sequencer &= ~MDC_CLK_MODE_SCREEN_OFF; + sequencer |= 1; + gfx_outb(MDC_SEQUENCER_DATA, sequencer); - gfx_delay_milliseconds(1); + gfx_delay_milliseconds(1); - /*restart the sequencer */ - gfx_outw(0x3C4, 0x300); + /*restart the sequencer */ + gfx_outw(0x3C4, 0x300); - /* turn on the attribute controler */ - (void) gfx_inb(0x3DA); - gfx_outb(0x3C0, 0x20); - (void) gfx_inb(0x3DA); + /* turn on the attribute controler */ + (void) gfx_inb(0x3DA); + gfx_outb(0x3C0, 0x20); + (void) gfx_inb(0x3DA); - gu2_vga_extcrtc(0x3F, 0); + gu2_vga_extcrtc(0x3F, 0); } /*----------------------------------------------------------------------------- @@ -288,9 +289,9 @@ gu2_gfx_to_vga(int vga_mode) int gu2_vga_seq_reset(int reset) { - gfx_outb(0x3C4, 0); - gfx_outb(0x3C5, (unsigned char)(reset ? 0x00 : 0x03)); - return (GFX_STATUS_OK); + gfx_outb(0x3C4, 0); + gfx_outb(0x3C5, (unsigned char) (reset ? 0x00 : 0x03)); + return (GFX_STATUS_OK); } /*----------------------------------------------------------------------------- @@ -304,85 +305,85 @@ gu2_vga_seq_reset(int reset) int gu2_vga_save(gfx_vga_struct * vga, int flags) { - int i; - unsigned short crtcindex, crtcdata; + int i; + unsigned short crtcindex, crtcdata; - crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; + crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; - /* CHECK MISCELLANEOUS OUTPUT FLAG */ + /* CHECK MISCELLANEOUS OUTPUT FLAG */ - if (flags & GU2_VGA_FLAG_MISC_OUTPUT) { - /* SAVE MISCCELLANEOUS OUTPUT REGISTER */ + if (flags & GU2_VGA_FLAG_MISC_OUTPUT) { + /* SAVE MISCCELLANEOUS OUTPUT REGISTER */ - vga->miscOutput = gfx_inb(0x3CC); - } + vga->miscOutput = gfx_inb(0x3CC); + } - /* CHECK SEQ */ + /* CHECK SEQ */ - if (flags & GU2_VGA_FLAG_SEQ) { - /* SAVE STANDARD CRTC REGISTERS */ + 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); - } - } + for (i = 1; i < GU2_SEQ_REGS; i++) { + gfx_outb(0x3C4, (unsigned char) i); + SEQregs[i] = gfx_inb(0x3C5); + } + } - /* CHECK STANDARD CRTC FLAG */ + /* CHECK STANDARD CRTC FLAG */ - if (flags & GU2_VGA_FLAG_STD_CRTC) { - /* SAVE STANDARD CRTC REGISTERS */ + 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); - } - } + for (i = 0; i < GU2_STD_CRTC_REGS; i++) { + gfx_outb(crtcindex, (unsigned char) i); + vga->stdCRTCregs[i] = gfx_inb(crtcdata); + } + } - /* CHECK GDC */ + /* CHECK GDC */ - if (flags & GU2_VGA_FLAG_GDC) { - /* SAVE STANDARD CRTC REGISTERS */ + 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); - } - } + for (i = 0; i < GU2_GDC_REGS; i++) { + gfx_outb(0x3CE, (unsigned char) i); + GDCregs[i] = gfx_inb(0x3CF); + } + } - /* CHECK EXTENDED CRTC FLAG */ + /* CHECK EXTENDED CRTC FLAG */ - if (flags & GU2_VGA_FLAG_EXT_CRTC) { - /* SAVE EXTENDED CRTC REGISTERS */ + 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); - } - } + 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 */ + if (flags & GU2_VGA_FLAG_PALETTE) { + /* SAVE PALETTE DATA */ - for (i = 0; i < 0x100; i++) { - gfx_outb(0x3C7, i); - palette[i] = gfx_inb(0x3C9); - } - } + for (i = 0; i < 0x100; i++) { + gfx_outb(0x3C7, i); + palette[i] = gfx_inb(0x3C9); + } + } - if (flags & GU2_VGA_FLAG_ATTR) { - /* SAVE Attribute DATA */ + 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 the VGA data */ - gu2_vga_font_data(0); - return (0); + for (i = 0; i < 21; i++) { + gfx_inb(0x3DA); + gfx_outb(0x3C0, i); + ATTRregs[i] = gfx_inb(0x3C1); + } + } + /* save the VGA data */ + gu2_vga_font_data(0); + return (0); } /*----------------------------------------------------------------------------- @@ -395,47 +396,47 @@ gu2_vga_save(gfx_vga_struct * vga, int flags) void gu2_vga_clear_extended(void) { - int i; - unsigned short crtcindex, crtcdata; - - crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; - - gfx_outb(crtcindex, 0x30); - 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, 0x30); - gfx_outb(crtcdata, 0x00); + int i; + unsigned short crtcindex, crtcdata; + + crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; + + gfx_outb(crtcindex, 0x30); + 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, 0x30); + gfx_outb(crtcdata, 0x00); } void gu2_vga_extcrtc(char offset, int reset) { - unsigned short crtcindex, crtcdata; + unsigned short crtcindex, crtcdata; - crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; + crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; - /* UNLOCK EXTENDED CRTC REGISTERS */ + /* UNLOCK EXTENDED CRTC REGISTERS */ - gfx_outb(crtcindex, 0x30); - gfx_outb(crtcdata, 0x57); - gfx_outb(crtcdata, 0x4C); + gfx_outb(crtcindex, 0x30); + gfx_outb(crtcdata, 0x57); + gfx_outb(crtcdata, 0x4C); - /* RESTORE EXTENDED CRTC REGISTERS */ + /* RESTORE EXTENDED CRTC REGISTERS */ - gfx_outb(crtcindex, offset); - gfx_outb(crtcdata, reset); + gfx_outb(crtcindex, offset); + gfx_outb(crtcdata, reset); #if 0 - /* LOCK EXTENDED CRTC REGISTERS */ + /* LOCK EXTENDED CRTC REGISTERS */ - gfx_outb(crtcindex, 0x30); - gfx_outb(crtcdata, 0x00); + gfx_outb(crtcindex, 0x30); + gfx_outb(crtcdata, 0x00); #endif } @@ -450,122 +451,122 @@ gu2_vga_extcrtc(char offset, int reset) int gu2_vga_restore(gfx_vga_struct * vga, int flags) { - int i; - unsigned short crtcindex, crtcdata; + int i; + unsigned short crtcindex, crtcdata; - crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; + crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; - /* CHECK MISCELLANEOUS OUTPUT FLAG */ + /* CHECK MISCELLANEOUS OUTPUT FLAG */ - if (flags & GU2_VGA_FLAG_MISC_OUTPUT) { - /* RESTORE MISCELLANEOUS OUTPUT REGISTER VALUE */ + if (flags & GU2_VGA_FLAG_MISC_OUTPUT) { + /* RESTORE MISCELLANEOUS OUTPUT REGISTER VALUE */ - gfx_outb(0x3C2, vga->miscOutput); - } + gfx_outb(0x3C2, vga->miscOutput); + } - /* CHECK SEQ */ + /* CHECK SEQ */ - if (flags & GU2_VGA_FLAG_SEQ) { - /* RESTORE STANDARD CRTC REGISTERS */ + 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]); - } - } + for (i = 1; i < GU2_SEQ_REGS; i++) { + gfx_outb(0x3C4, (unsigned char) i); + gfx_outb(0x3C5, SEQregs[i]); + } + } - /* CHECK STANDARD CRTC FLAG */ + /* CHECK STANDARD CRTC FLAG */ - if (flags & GU2_VGA_FLAG_STD_CRTC) { - /* UNLOCK STANDARD CRTC REGISTERS */ + if (flags & GU2_VGA_FLAG_STD_CRTC) { + /* UNLOCK STANDARD CRTC REGISTERS */ - gfx_outb(crtcindex, 0x11); - gfx_outb(crtcdata, 0); + 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 */ + /* CHECK GDC */ - if (flags & GU2_VGA_FLAG_GDC) { - /* SAVE STANDARD CRTC REGISTERS */ + 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]); - } - } + for (i = 0; i < GU2_GDC_REGS; i++) { + gfx_outb(0x3CE, (unsigned char) i); + gfx_outb(0x3CF, GDCregs[i]); + } + } - /* CHECK EXTENDED CRTC FLAG */ + /* CHECK EXTENDED CRTC FLAG */ - if (flags & GU2_VGA_FLAG_EXT_CRTC) { - /* UNLOCK EXTENDED CRTC REGISTERS */ + if (flags & GU2_VGA_FLAG_EXT_CRTC) { + /* UNLOCK EXTENDED CRTC REGISTERS */ - gfx_outb(crtcindex, 0x30); - gfx_outb(crtcdata, 0x57); - gfx_outb(crtcdata, 0x4C); + 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 */ + if (flags & GU2_VGA_FLAG_PALETTE) { + /* RESTORE PALETTE DATA */ - for (i = 0; i < 0x100; i++) { - gfx_outb(0x3C8, i); - gfx_outb(0x3C9, palette[i]); - } - } + for (i = 0; i < 0x100; i++) { + gfx_outb(0x3C8, i); + gfx_outb(0x3C9, palette[i]); + } + } - if (flags & GU2_VGA_FLAG_ATTR) { - /* RESTORE Attribute DATA */ + 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); + gfx_outb(0x3C0, ATTRregs[i]); + } + /* SAVE Attribute DATA */ - for (i = 0; i < 21; i++) { - gfx_inb(0x3DA); - gfx_outb(0x3C0, i); - } - } + for (i = 0; i < 21; i++) { + gfx_inb(0x3DA); + gfx_outb(0x3C0, i); + } + } - /* restore the VGA data */ - gu2_vga_font_data(1); + /* restore the VGA data */ + gu2_vga_font_data(1); - return (0); + return (0); } /* END OF FILE */ diff --git a/src/nsc_gx2_video.c b/src/nsc_gx2_video.c index bba73e0..55710eb 100644 --- a/src/nsc_gx2_video.c +++ b/src/nsc_gx2_video.c @@ -167,7 +167,7 @@ #include "fourcc.h" #include "nsc_fourcc.h" -#define OFF_DELAY 200 /* milliseconds */ +#define OFF_DELAY 200 /* milliseconds */ #define FREE_DELAY 60000 #define OFF_TIMER 0x01 @@ -187,18 +187,18 @@ static void GX2StopVideo(ScrnInfoPtr, pointer, Bool); static int GX2SetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); static int GX2GetPortAttribute(ScrnInfoPtr, Atom, INT32 *, pointer); static void GX2QueryBestSize(ScrnInfoPtr, Bool, - short, short, short, short, unsigned int *, - unsigned int *, pointer); + short, short, short, short, unsigned int *, + unsigned int *, pointer); static int GX2PutImage(ScrnInfoPtr, short, short, short, short, short, short, - short, short, int, unsigned char *, short, short, Bool, - RegionPtr, pointer, DrawablePtr); + short, short, int, unsigned char *, short, short, Bool, + RegionPtr, pointer, DrawablePtr); static int GX2QueryImageAttributes(ScrnInfoPtr, int, unsigned short *, - unsigned short *, int *, int *); + unsigned short *, int *, int *); static void GX2BlockHandler(int, pointer, pointer, pointer); void GX2SetVideoPosition(int x, int y, int width, int height, - short src_w, short src_h, short drw_w, - short drw_h, int id, int offset, ScrnInfoPtr pScrn); + short src_w, short src_h, short drw_w, + short drw_h, int id, int offset, ScrnInfoPtr pScrn); extern void GX2AccelSync(ScrnInfoPtr pScreenInfo); @@ -212,9 +212,9 @@ int DeltaX, DeltaY; static Atom xvColorKey, xvColorKeyMode, xvFilter #if DBUF - , xvDoubleBuffer +, xvDoubleBuffer #endif - ; +; /*---------------------------------------------------------------------------- * GX2InitVideo @@ -253,43 +253,44 @@ GX2InitVideo(ScreenPtr pScreen) num_adaptors = xf86XVListGenericAdaptors(pScreenInfo, &adaptors); if (newAdaptor) { - if (!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - malloc((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) { + num_adaptors = 1; + adaptors = &newAdaptor; + } + else { + newAdaptors = /* need to free this someplace */ + malloc((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(pScreen, adaptors, num_adaptors); + xf86XVScreenInit(pScreen, adaptors, num_adaptors); if (newAdaptors) - free(newAdaptors); + free(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 static XF86VideoFormatRec Formats[NUM_FORMATS] = { - {8, PseudoColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor} + {8, PseudoColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor} }; #if DBUF @@ -300,42 +301,40 @@ static XF86VideoFormatRec Formats[NUM_FORMATS] = { static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = { #if DBUF - {XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER"}, + {XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER"}, #endif - {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"} }; #define NUM_IMAGES 7 static XF86ImageRec Images[NUM_IMAGES] = { - XVIMAGE_UYVY, - XVIMAGE_YUY2, - XVIMAGE_Y2YU, - XVIMAGE_YVYU, - XVIMAGE_Y800, - XVIMAGE_I420, - XVIMAGE_YV12 + XVIMAGE_UYVY, + XVIMAGE_YUY2, + XVIMAGE_Y2YU, + XVIMAGE_YVYU, + XVIMAGE_Y800, + XVIMAGE_I420, + XVIMAGE_YV12 }; -typedef struct -{ - FBAreaPtr area; - FBLinearPtr linear; - RegionRec clip; - CARD32 colorKey; - CARD32 colorKeyMode; - CARD32 filter; - CARD32 videoStatus; - Time offTime; - Time freeTime; +typedef struct { + FBAreaPtr area; + FBLinearPtr linear; + RegionRec clip; + CARD32 colorKey; + CARD32 colorKeyMode; + CARD32 filter; + CARD32 videoStatus; + Time offTime; + Time freeTime; #if DBUF - Bool doubleBuffer; - int currentBuffer; + Bool doubleBuffer; + int currentBuffer; #endif -} -GeodePortPrivRec, *GeodePortPrivPtr; +} GeodePortPrivRec, *GeodePortPrivPtr; #define GET_PORT_PRIVATE(pScrn) \ (GeodePortPrivPtr)((GEODEPTR(pScrn))->adaptor->pPortPrivates[0].ptr) @@ -360,42 +359,42 @@ GeodePortPrivRec, *GeodePortPrivPtr; static INT32 GX2SetColorkey(ScrnInfoPtr pScrn, GeodePortPrivPtr pPriv) { - int red, green, blue; - unsigned long key; - - switch (pScrn->depth) { - case 8: - 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 & pScrn->mask.red) >> - pScrn->offset.red << (8 - pScrn->weight.red); - green = (pPriv->colorKey & pScrn->mask.green) >> - pScrn->offset.green << (8 - pScrn->weight.green); - blue = (pPriv->colorKey & pScrn->mask.blue) >> - pScrn->offset.blue << (8 - pScrn->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 & pScrn->mask.red) >> - (pScrn->offset.red - 1) << (8 - pScrn->weight.red); - green = (pPriv->colorKey & pScrn->mask.green) >> - (pScrn->offset.green - 1) << (8 - pScrn->weight.green); - blue = (pPriv->colorKey & pScrn->mask.blue) >> - (pScrn->offset.blue - 1) << (8 - pScrn->weight.blue); - break; - } - - GFX(set_video_color_key((blue | (green << 8) | (red << 16)), 0xFFFFFF, - (pPriv->colorKeyMode == 0))); - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - return 0; + int red, green, blue; + unsigned long key; + + switch (pScrn->depth) { + case 8: + 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 & pScrn->mask.red) >> + pScrn->offset.red << (8 - pScrn->weight.red); + green = (pPriv->colorKey & pScrn->mask.green) >> + pScrn->offset.green << (8 - pScrn->weight.green); + blue = (pPriv->colorKey & pScrn->mask.blue) >> + pScrn->offset.blue << (8 - pScrn->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 & pScrn->mask.red) >> + (pScrn->offset.red - 1) << (8 - pScrn->weight.red); + green = (pPriv->colorKey & pScrn->mask.green) >> + (pScrn->offset.green - 1) << (8 - pScrn->weight.green); + blue = (pPriv->colorKey & pScrn->mask.blue) >> + (pScrn->offset.blue - 1) << (8 - pScrn->weight.blue); + break; + } + + GFX(set_video_color_key((blue | (green << 8) | (red << 16)), 0xFFFFFF, + (pPriv->colorKeyMode == 0))); + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + return 0; } /*---------------------------------------------------------------------------- @@ -421,7 +420,8 @@ GX2ResetVideo(ScrnInfoPtr pScrn) GeodePortPrivPtr pPriv = pGeode->adaptor->pPortPrivates[0].ptr; - if (!pGeode->NoAccel) GX2AccelSync(pScrn); + if (!pGeode->NoAccel) + GX2AccelSync(pScrn); GFX(set_video_palette(NULL)); GX2SetColorkey(pScrn, pPriv); GFX(set_video_filter(pPriv->filter, pPriv->filter)); @@ -447,68 +447,68 @@ GX2ResetVideo(ScrnInfoPtr pScrn) static XF86VideoAdaptorPtr GX2SetupImageVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - GeodePtr pGeode = GEODEPTR(pScrn); - XF86VideoAdaptorPtr adapt; - GeodePortPrivPtr pPriv; - - if (!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + - sizeof(GeodePortPrivRec) + sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - adapt->name = "National Semiconductor Corporation"; - adapt->nEncodings = 1; - adapt->pEncodings = DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = Formats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion *) (&adapt[1]); - pPriv = (GeodePortPrivPtr) (&adapt->pPortPrivates[1]); - adapt->pPortPrivates[0].ptr = (pointer) (pPriv); - adapt->pAttributes = Attributes; - adapt->nImages = NUM_IMAGES; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->pImages = Images; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = GX2StopVideo; - adapt->SetPortAttribute = GX2SetPortAttribute; - adapt->GetPortAttribute = GX2GetPortAttribute; - adapt->QueryBestSize = GX2QueryBestSize; - adapt->PutImage = GX2PutImage; - adapt->QueryImageAttributes = GX2QueryImageAttributes; - - pPriv->colorKey = pGeode->videoKey; - pPriv->colorKeyMode = 0; - pPriv->filter = 0; - pPriv->videoStatus = 0; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + GeodePtr pGeode = GEODEPTR(pScrn); + XF86VideoAdaptorPtr adapt; + GeodePortPrivPtr pPriv; + + if (!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(GeodePortPrivRec) + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "National Semiconductor Corporation"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion *) (&adapt[1]); + pPriv = (GeodePortPrivPtr) (&adapt->pPortPrivates[1]); + adapt->pPortPrivates[0].ptr = (pointer) (pPriv); + adapt->pAttributes = Attributes; + adapt->nImages = NUM_IMAGES; + adapt->nAttributes = NUM_ATTRIBUTES; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = GX2StopVideo; + adapt->SetPortAttribute = GX2SetPortAttribute; + adapt->GetPortAttribute = GX2GetPortAttribute; + adapt->QueryBestSize = GX2QueryBestSize; + adapt->PutImage = GX2PutImage; + adapt->QueryImageAttributes = GX2QueryImageAttributes; + + pPriv->colorKey = pGeode->videoKey; + pPriv->colorKeyMode = 0; + pPriv->filter = 0; + pPriv->videoStatus = 0; #if DBUF - pPriv->doubleBuffer = TRUE; - pPriv->currentBuffer = 0; /* init to first buffer */ + pPriv->doubleBuffer = TRUE; + pPriv->currentBuffer = 0; /* init to first buffer */ #endif - /* gotta uninit this someplace */ - REGION_NULL(pScreen, &pPriv->clip); + /* gotta uninit this someplace */ + REGION_NULL(pScreen, &pPriv->clip); - pGeode->adaptor = adapt; + pGeode->adaptor = adapt; - pGeode->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = GX2BlockHandler; + pGeode->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = GX2BlockHandler; - xvColorKey = MAKE_ATOM("XV_COLORKEY"); - xvColorKeyMode = MAKE_ATOM("XV_COLORKEYMODE"); - xvFilter = MAKE_ATOM("XV_FILTER"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + xvColorKeyMode = MAKE_ATOM("XV_COLORKEYMODE"); + xvFilter = MAKE_ATOM("XV_FILTER"); #if DBUF - xvDoubleBuffer = MAKE_ATOM("XV_DOUBLE_BUFFER"); + xvDoubleBuffer = MAKE_ATOM("XV_DOUBLE_BUFFER"); #endif - GX2ResetVideo(pScrn); + GX2ResetVideo(pScrn); - return adapt; + return adapt; } /*---------------------------------------------------------------------------- @@ -531,28 +531,30 @@ GX2SetupImageVideo(ScreenPtr pScreen) static void GX2StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) { - GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; - GeodePtr pGeode = GEODEPTR(pScrn); - - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - - if (!pGeode->NoAccel) GX2AccelSync(pScrn); - if (exit) { - if (pPriv->videoStatus & CLIENT_VIDEO_ON) { - GFX(set_video_enable(0)); - } - if (pPriv->area) { - xf86FreeOffscreenArea(pPriv->area); - pPriv->area = NULL; - } - pPriv->videoStatus = 0; - pGeode->OverlayON = FALSE; - } else { - if (pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus |= OFF_TIMER; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - } - } + GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; + GeodePtr pGeode = GEODEPTR(pScrn); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if (!pGeode->NoAccel) + GX2AccelSync(pScrn); + if (exit) { + if (pPriv->videoStatus & CLIENT_VIDEO_ON) { + GFX(set_video_enable(0)); + } + if (pPriv->area) { + xf86FreeOffscreenArea(pPriv->area); + pPriv->area = NULL; + } + pPriv->videoStatus = 0; + pGeode->OverlayON = FALSE; + } + else { + if (pPriv->videoStatus & CLIENT_VIDEO_ON) { + pPriv->videoStatus |= OFF_TIMER; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + } + } } /*---------------------------------------------------------------------------- @@ -576,33 +578,36 @@ GX2StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) */ static int GX2SetPortAttribute(ScrnInfoPtr pScrn, - Atom attribute, INT32 value, pointer data) + Atom attribute, INT32 value, pointer data) { - GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; - GeodePtr pGeode = GEODEPTR(pScrn); - - if (!pGeode->NoAccel) GX2AccelSync(pScrn); - if (attribute == xvColorKey) { - pPriv->colorKey = value; - GX2SetColorkey(pScrn, pPriv); - } + GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; + GeodePtr pGeode = GEODEPTR(pScrn); + + if (!pGeode->NoAccel) + GX2AccelSync(pScrn); + if (attribute == xvColorKey) { + pPriv->colorKey = value; + GX2SetColorkey(pScrn, pPriv); + } #if DBUF - else if (attribute == xvDoubleBuffer) { - if ((value < 0) || (value > 1)) - return BadValue; - pPriv->doubleBuffer = value; - } + else if (attribute == xvDoubleBuffer) { + if ((value < 0) || (value > 1)) + return BadValue; + pPriv->doubleBuffer = value; + } #endif - else if (attribute == xvColorKeyMode) { - pPriv->colorKeyMode = value; - GX2SetColorkey(pScrn, pPriv); - } else if (attribute == xvFilter) { - pPriv->filter = value; - GFX(set_video_filter(pPriv->filter, pPriv->filter)); - } else - return BadMatch; - - return Success; + else if (attribute == xvColorKeyMode) { + pPriv->colorKeyMode = value; + GX2SetColorkey(pScrn, pPriv); + } + else if (attribute == xvFilter) { + pPriv->filter = value; + GFX(set_video_filter(pPriv->filter, pPriv->filter)); + } + else + return BadMatch; + + return Success; } /*---------------------------------------------------------------------------- @@ -626,26 +631,28 @@ GX2SetPortAttribute(ScrnInfoPtr pScrn, */ static int GX2GetPortAttribute(ScrnInfoPtr pScrn, - Atom attribute, INT32 * value, pointer data) + Atom attribute, INT32 *value, pointer data) { - GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; + GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; - if (attribute == xvColorKey) { - *value = pPriv->colorKey; - } + if (attribute == xvColorKey) { + *value = pPriv->colorKey; + } #if DBUF - else if (attribute == xvDoubleBuffer) { - *value = (pPriv->doubleBuffer) ? 1 : 0; - } + else if (attribute == xvDoubleBuffer) { + *value = (pPriv->doubleBuffer) ? 1 : 0; + } #endif - else if (attribute == xvColorKeyMode) { - *value = pPriv->colorKeyMode; - } else if (attribute == xvFilter) { - *value = pPriv->filter; - } else - return BadMatch; - - return Success; + else if (attribute == xvColorKeyMode) { + *value = pPriv->colorKeyMode; + } + else if (attribute == xvFilter) { + *value = pPriv->filter; + } + else + return BadMatch; + + return Success; } /*---------------------------------------------------------------------------- @@ -672,45 +679,45 @@ GX2GetPortAttribute(ScrnInfoPtr pScrn, */ static void GX2QueryBestSize(ScrnInfoPtr pScrn, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, pointer data) + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, pointer data) { - *p_w = drw_w; - *p_h = drw_h; + *p_w = drw_w; + *p_h = drw_h; - if (*p_w > 16384) - *p_w = 16384; + if (*p_w > 16384) + *p_w = 16384; } static void GX2CopyGreyscale(unsigned char *src, - unsigned char *dst, int srcPitch, int dstPitch, int h, int w) + unsigned char *dst, int srcPitch, int dstPitch, 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 */ - } - dst2 += dstPitch; - src2 += srcPitch; - } + 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; + } } /*---------------------------------------------------------------------------- @@ -734,13 +741,13 @@ GX2CopyGreyscale(unsigned char *src, static void GX2CopyData420(unsigned char *src, unsigned char *dst, - int srcPitch, int dstPitch, int h, int w) + int srcPitch, int dstPitch, int h, int w) { - while (h--) { - memcpy(dst, src, w); - src += srcPitch; - dst += dstPitch; - } + while (h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } } /*---------------------------------------------------------------------------- @@ -764,50 +771,50 @@ GX2CopyData420(unsigned char *src, unsigned char *dst, static void GX2CopyData422(unsigned char *src, unsigned char *dst, - int srcPitch, int dstPitch, int h, int w) + int srcPitch, int dstPitch, int h, int w) { - w <<= 1; - while (h--) { - memcpy(dst, src, w); - src += srcPitch; - dst += dstPitch; - } + w <<= 1; + while (h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } } static FBAreaPtr GX2AllocateMemory(ScrnInfoPtr pScrn, FBAreaPtr area, int numlines) { - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; - FBAreaPtr new_area; + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + FBAreaPtr new_area; - if (area) { - if ((area->box.y2 - area->box.y1) >= numlines) - return area; + if (area) { + if ((area->box.y2 - area->box.y1) >= numlines) + return area; - if (xf86ResizeOffscreenArea(area, pScrn->displayWidth, numlines)) - return area; + if (xf86ResizeOffscreenArea(area, pScrn->displayWidth, numlines)) + return area; - xf86FreeOffscreenArea(area); - } + xf86FreeOffscreenArea(area); + } - new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, - numlines, 0, NULL, NULL, NULL); + new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + numlines, 0, NULL, NULL, NULL); - if (!new_area) { - int max_w, max_h; + if (!new_area) { + int max_w, max_h; - xf86QueryLargestOffscreenArea(pScreen, &max_w, &max_h, 0, - FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); + xf86QueryLargestOffscreenArea(pScreen, &max_w, &max_h, 0, + FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); - if ((max_w < pScrn->displayWidth) || (max_h < numlines)) - return NULL; + if ((max_w < pScrn->displayWidth) || (max_h < numlines)) + return NULL; - xf86PurgeUnlockedOffscreenAreas(pScreen); - new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, - numlines, 0, NULL, NULL, NULL); - } + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + numlines, 0, NULL, NULL, NULL); + } - return new_area; + return new_area; } static BoxRec dstBox; @@ -820,98 +827,101 @@ static int d2offset = 0, d3offset = 0; static Bool RegionsIntersect(BoxPtr pRcl1, BoxPtr pRcl2, BoxPtr pRclResult) { - pRclResult->x1 = max(pRcl1->x1, pRcl2->x1); - pRclResult->x2 = min(pRcl1->x2, pRcl2->x2); + pRclResult->x1 = max(pRcl1->x1, pRcl2->x1); + 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); + if (pRclResult->x1 <= pRclResult->x2) { + 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); + return (FALSE); } void GX2SetVideoPosition(int x, int y, int width, int height, - short src_w, short src_h, short drw_w, short drw_h, - int id, int offset, ScrnInfoPtr pScrn) + short src_w, short src_h, short drw_w, short drw_h, + int id, int offset, ScrnInfoPtr pScrn) { - GeodePtr pGeode = GEODEPTR(pScrn); - long xstart, ystart, xend, yend; - unsigned long lines = 0; - unsigned long y_extra, uv_extra = 0; - BoxRec ovly, display, result; + GeodePtr pGeode = GEODEPTR(pScrn); + long xstart, ystart, xend, yend; + unsigned long lines = 0; + unsigned long y_extra, uv_extra = 0; + BoxRec ovly, display, result; #if defined(STB_X) - unsigned long startAddress = 0; + unsigned long startAddress = 0; #endif - xend = x + drw_w; - yend = y + drw_h; + xend = x + drw_w; + yend = y + drw_h; - /* Take care of panning when panel is present */ + /* Take care of panning when panel is present */ #if defined(STB_X) - Gal_get_display_offset(&startAddress); - DeltaY = startAddress / pGeode->Pitch; - DeltaX = startAddress & (pGeode->Pitch - 1); - DeltaX /= (pScrn->bitsPerPixel >> 3); + Gal_get_display_offset(&startAddress); + DeltaY = startAddress / pGeode->Pitch; + DeltaX = startAddress & (pGeode->Pitch - 1); + DeltaX /= (pScrn->bitsPerPixel >> 3); #endif - 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; - } - } - - /* LEFT CLIPPING */ - - if (x < 0) { - xstart = 0; - } else { - xstart = (unsigned long)x; - } - drw_w -= (xstart - x); - - /* TOP CLIPPING */ - - if (y < 0) { - lines = (-y) * src_h / drw_h; - ystart = 0; - drw_h += y; - y_extra = lines * dstPitch; - uv_extra = (lines >> 1) * (dstPitch2); - } else { - ystart = y; - lines = 0; - y_extra = 0; - } - GFX(set_video_window(xstart, ystart, xend - xstart, 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)); - } else { - GFX(set_video_offset(offset + y_extra)); - } - GFX(set_video_left_crop(xstart - x)); + 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; + } + } + + /* LEFT CLIPPING */ + + if (x < 0) { + xstart = 0; + } + else { + xstart = (unsigned long) x; + } + drw_w -= (xstart - x); + + /* TOP CLIPPING */ + + if (y < 0) { + lines = (-y) * src_h / drw_h; + ystart = 0; + drw_h += y; + y_extra = lines * dstPitch; + uv_extra = (lines >> 1) * (dstPitch2); + } + else { + ystart = y; + lines = 0; + y_extra = 0; + } + GFX(set_video_window(xstart, ystart, xend - xstart, 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)); + } + else { + GFX(set_video_offset(offset + y_extra)); + } + GFX(set_video_left_crop(xstart - x)); } /*---------------------------------------------------------------------------- @@ -931,61 +941,62 @@ GX2SetVideoPosition(int x, int y, int width, int height, static void GX2DisplayVideo(ScrnInfoPtr pScrn, - int id, - int offset, - short width, short height, - int pitch, - int x1, int y1, int x2, int y2, - BoxPtr dstBox, - short src_w, short src_h, short drw_w, short drw_h) + int id, + int offset, + short width, short height, + int pitch, + int x1, int y1, int x2, int y2, + BoxPtr dstBox, + short src_w, short src_h, short drw_w, short drw_h) { - GeodePtr pGeode = GEODEPTR(pScrn); - - if (!pGeode->NoAccel) GX2AccelSync(pScrn); - - 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; - } - 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 = pScrn; - } - GFX(set_video_scale(width, height, drw_w, drw_h)); - GX2SetVideoPosition(dstBox->x1, dstBox->y1, width, height, src_w, - src_h, drw_w, drw_h, id, offset, pScrn); + GeodePtr pGeode = GEODEPTR(pScrn); + + if (!pGeode->NoAccel) + GX2AccelSync(pScrn); + + 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; + } + 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 = pScrn; + } + GFX(set_video_scale(width, height, drw_w, drw_h)); + GX2SetVideoPosition(dstBox->x1, dstBox->y1, width, height, src_w, + src_h, drw_w, drw_h, id, offset, pScrn); } @@ -1013,207 +1024,206 @@ GX2DisplayVideo(ScrnInfoPtr pScrn, static int GX2PutImage(ScrnInfoPtr pScrn, - short src_x, short src_y, - short drw_x, short drw_y, - 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 src_x, short src_y, + short drw_x, short drw_y, + 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) { - GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; - GeodePtr pGeode = GEODEPTR(pScrn); - int new_h; + GeodePortPrivPtr pPriv = (GeodePortPrivPtr) data; + GeodePtr pGeode = GEODEPTR(pScrn); + int new_h; #if REINIT - BOOL ReInitVideo = FALSE; + BOOL ReInitVideo = FALSE; #endif #if XV_PROFILE - long oldtime, newtime; + long oldtime, newtime; - UpdateCurrentTime(); - oldtime = currentTime.milliseconds; + UpdateCurrentTime(); + oldtime = currentTime.milliseconds; #endif #if REINIT /* update cliplist */ - if (!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) { - ReInitVideo = TRUE; - } - if (ReInitVideo) { - DEBUGMSG(1, (0, X_NONE, "Regional Not Equal - Init\n")); + if (!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) { + ReInitVideo = TRUE; + } + if (ReInitVideo) { + DEBUGMSG(1, (0, X_NONE, "Regional Not Equal - Init\n")); #endif - if (drw_w > 16384) - drw_w = 16384; + if (drw_w > 16384) + drw_w = 16384; - /* Clip */ - Bx1 = src_x; - Bx2 = src_x + src_w; - By1 = src_y; - By2 = src_y + src_h; + /* Clip */ + Bx1 = src_x; + Bx2 = src_x + src_w; + By1 = src_y; + By2 = src_y + src_h; - if ((Bx1 >= Bx2) || (By1 >= By2)) - return Success; + 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 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; - dstBox.x1 -= pScrn->frameX0; - dstBox.x2 -= pScrn->frameX0; - dstBox.y1 -= pScrn->frameY0; - dstBox.y2 -= pScrn->frameY0; + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; - switch (id) { - case FOURCC_YV12: - case FOURCC_I420: + switch (id) { + case FOURCC_YV12: + case FOURCC_I420: - srcPitch = (width + 3) & ~3; /* of luma */ - dstPitch = (width + 31) & ~31; + srcPitch = (width + 3) & ~3; /* of luma */ + dstPitch = (width + 31) & ~31; - s2offset = srcPitch * height; - d2offset = dstPitch * height; + s2offset = srcPitch * height; + d2offset = dstPitch * height; - srcPitch2 = ((width >> 1) + 3) & ~3; - dstPitch2 = ((width >> 1) + 15) & ~15; + srcPitch2 = ((width >> 1) + 3) & ~3; + dstPitch2 = ((width >> 1) + 15) & ~15; - s3offset = (srcPitch2 * (height >> 1)) + s2offset; - d3offset = (dstPitch2 * (height >> 1)) + d2offset; + 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; + 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: - default: - dstPitch = ((width << 1) + 3) & ~3; - srcPitch = (width << 1); - new_h = ((dstPitch * height) + pGeode->Pitch - 1) / pGeode->Pitch; - break; - } + case FOURCC_UYVY: + case FOURCC_YUY2: + case FOURCC_Y800: + 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->area = GX2AllocateMemory(pScrn, pPriv->area, new_h))) - return BadAlloc; + if (!(pPriv->area = GX2AllocateMemory(pScrn, pPriv->area, 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; - offset = (pPriv->area->box.y1 * pGeode->Pitch) + (top * dstPitch); + top &= ~1; + offset = (pPriv->area->box.y1 * pGeode->Pitch) + (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: - default: - left <<= 1; - buf += (top * srcPitch) + left; - nlines = By2 - top; - offset = (pPriv->area->box.y1 * pGeode->Pitch) + (top * dstPitch); + 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: + default: + left <<= 1; + buf += (top * srcPitch) + left; + nlines = By2 - top; + offset = (pPriv->area->box.y1 * pGeode->Pitch) + (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(pScrn->pScreen, &pPriv->clip, clipBoxes); - if (pPriv->colorKeyMode == 0) { - /* draw these */ - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } - GX2DisplayVideo(pScrn, id, offset, width, height, dstPitch, - Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, - drw_h); - } + /* update cliplist */ + REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); + if (pPriv->colorKeyMode == 0) { + /* draw these */ + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); + } + GX2DisplayVideo(pScrn, id, offset, width, height, dstPitch, + Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, + drw_h); + } #endif - switch (id) { - - case FOURCC_Y800: - GX2CopyGreyscale(buf, dst_start, srcPitch, dstPitch, nlines, npixels); - break; - case FOURCC_YV12: - case FOURCC_I420: - GX2CopyData420(buf + s1offset, dst_start, srcPitch, dstPitch, nlines, - npixels); - GX2CopyData420(buf + s2offset, dst_start + d2offset, srcPitch2, - dstPitch2, nlines >> 1, npixels >> 1); - GX2CopyData420(buf + s3offset, dst_start + d3offset, srcPitch2, - dstPitch2, nlines >> 1, npixels >> 1); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - GX2CopyData422(buf, dst_start, srcPitch, dstPitch, nlines, npixels); - break; - } + switch (id) { + + case FOURCC_Y800: + GX2CopyGreyscale(buf, dst_start, srcPitch, dstPitch, nlines, npixels); + break; + case FOURCC_YV12: + case FOURCC_I420: + GX2CopyData420(buf + s1offset, dst_start, srcPitch, dstPitch, nlines, + npixels); + GX2CopyData420(buf + s2offset, dst_start + d2offset, srcPitch2, + dstPitch2, nlines >> 1, npixels >> 1); + GX2CopyData420(buf + s3offset, dst_start + d3offset, srcPitch2, + dstPitch2, nlines >> 1, npixels >> 1); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + GX2CopyData422(buf, dst_start, srcPitch, dstPitch, nlines, npixels); + break; + } #if !REINIT - /* update cliplist */ - REGION_COPY(pScreen, &pPriv->clip, clipBoxes); - if (pPriv->colorKeyMode == 0) { - /* draw these */ - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } - GX2DisplayVideo(pScrn, id, offset, width, height, dstPitch, - Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, drw_h); + /* update cliplist */ + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + if (pPriv->colorKeyMode == 0) { + /* draw these */ + xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); + } + GX2DisplayVideo(pScrn, id, offset, width, height, dstPitch, + Bx1, By1, Bx2, By2, &dstBox, src_w, src_h, drw_w, drw_h); #endif #if XV_PROFILE - UpdateCurrentTime(); - newtime = currentTime.milliseconds; - DEBUGMSG(1, (0, X_NONE, "PI %d\n", newtime - oldtime)); + UpdateCurrentTime(); + newtime = currentTime.milliseconds; + DEBUGMSG(1, (0, X_NONE, "PI %d\n", newtime - oldtime)); #endif #if DBUF - pPriv->currentBuffer ^= 1; + pPriv->currentBuffer ^= 1; #endif - pPriv->videoStatus = CLIENT_VIDEO_ON; - pGeode->OverlayON = TRUE; - return Success; + pPriv->videoStatus = CLIENT_VIDEO_ON; + pGeode->OverlayON = TRUE; + return Success; } /*---------------------------------------------------------------------------- @@ -1237,98 +1247,98 @@ GX2PutImage(ScrnInfoPtr pScrn, */ static int GX2QueryImageAttributes(ScrnInfoPtr pScrn, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets) + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets) { - int size; - int tmp; - - DEBUGMSG(0, (0, X_NONE, "QueryImageAttributes %X\n", id)); - - if (*w > 1024) - *w = 1024; - if (*h > 1024) - *h = 1024; - - *w = (*w + 1) & ~1; - if (offsets) - 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; - case FOURCC_UYVY: - case FOURCC_YUY2: - case FOURCC_Y800: - default: - size = *w << 1; - if (pitches) - pitches[0] = size; - size *= *h; - break; - } - return size; + int size; + int tmp; + + DEBUGMSG(0, (0, X_NONE, "QueryImageAttributes %X\n", id)); + + if (*w > 1024) + *w = 1024; + if (*h > 1024) + *h = 1024; + + *w = (*w + 1) & ~1; + if (offsets) + 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; + case FOURCC_UYVY: + case FOURCC_YUY2: + case FOURCC_Y800: + default: + size = *w << 1; + if (pitches) + pitches[0] = size; + size *= *h; + break; + } + return size; } static void GX2BlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) { - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrn = xf86Screens[i]; - GeodePtr pGeode = GEODEPTR(pScrn); - GeodePortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); - - pScreen->BlockHandler = pGeode->BlockHandler; - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); - pScreen->BlockHandler = GX2BlockHandler; - - if (!pGeode->NoAccel) GX2AccelSync(pScrn); - if (pPriv->videoStatus & TIMER_MASK) { - UpdateCurrentTime(); - if (pPriv->videoStatus & OFF_TIMER) { - if (pPriv->offTime < currentTime.milliseconds) { - GFX(set_video_enable(0)); - pPriv->videoStatus = FREE_TIMER; - pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; - } - } else { /* FREE_TIMER */ - if (pPriv->freeTime < currentTime.milliseconds) { - if (pPriv->area) { - xf86FreeOffscreenArea(pPriv->area); - pPriv->area = NULL; - } - pPriv->videoStatus = 0; - } - } - } + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + GeodePtr pGeode = GEODEPTR(pScrn); + GeodePortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); + + pScreen->BlockHandler = pGeode->BlockHandler; + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + pScreen->BlockHandler = GX2BlockHandler; + + if (!pGeode->NoAccel) + GX2AccelSync(pScrn); + if (pPriv->videoStatus & TIMER_MASK) { + UpdateCurrentTime(); + if (pPriv->videoStatus & OFF_TIMER) { + if (pPriv->offTime < currentTime.milliseconds) { + GFX(set_video_enable(0)); + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + } + } + else { /* FREE_TIMER */ + if (pPriv->freeTime < currentTime.milliseconds) { + if (pPriv->area) { + xf86FreeOffscreenArea(pPriv->area); + pPriv->area = NULL; + } + pPriv->videoStatus = 0; + } + } + } } /****************** Offscreen stuff ***************/ -typedef struct -{ - FBAreaPtr area; - FBLinearPtr linear; - Bool isOn; -} -OffscreenPrivRec, *OffscreenPrivPtr; +typedef struct { + FBAreaPtr area; + FBLinearPtr linear; + Bool isOn; +} OffscreenPrivRec, *OffscreenPrivPtr; /*---------------------------------------------------------------------------- * GX2AllocateSurface @@ -1347,139 +1357,139 @@ OffscreenPrivRec, *OffscreenPrivPtr; static int GX2AllocateSurface(ScrnInfoPtr pScrn, - int id, - unsigned short w, unsigned short h, XF86SurfacePtr surface) + int id, + unsigned short w, unsigned short h, XF86SurfacePtr surface) { - FBAreaPtr area; - int pitch, fbpitch, numlines; - OffscreenPrivPtr pPriv; - - if ((w > 1024) || (h > 1024)) - return BadAlloc; - - w = (w + 1) & ~1; - pitch = ((w << 1) + 15) & ~15; - fbpitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; - numlines = ((pitch * h) + fbpitch - 1) / fbpitch; - - if (!(area = GX2AllocateMemory(pScrn, NULL, numlines))) - return BadAlloc; - - surface->width = w; - surface->height = h; - - if (!(surface->pitches = malloc(sizeof(int)))) - return BadAlloc; - if (!(surface->offsets = malloc(sizeof(int)))) { - free(surface->pitches); - return BadAlloc; - } - if (!(pPriv = malloc(sizeof(OffscreenPrivRec)))) { - free(surface->pitches); - free(surface->offsets); - return BadAlloc; - } - - pPriv->area = area; - pPriv->isOn = FALSE; - - surface->pScrn = pScrn; - surface->id = id; - surface->pitches[0] = pitch; - surface->offsets[0] = area->box.y1 * fbpitch; - surface->devPrivate.ptr = (pointer) pPriv; - - return Success; + FBAreaPtr area; + int pitch, fbpitch, numlines; + OffscreenPrivPtr pPriv; + + if ((w > 1024) || (h > 1024)) + return BadAlloc; + + w = (w + 1) & ~1; + pitch = ((w << 1) + 15) & ~15; + fbpitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; + numlines = ((pitch * h) + fbpitch - 1) / fbpitch; + + if (!(area = GX2AllocateMemory(pScrn, NULL, numlines))) + return BadAlloc; + + surface->width = w; + surface->height = h; + + if (!(surface->pitches = malloc(sizeof(int)))) + return BadAlloc; + if (!(surface->offsets = malloc(sizeof(int)))) { + free(surface->pitches); + return BadAlloc; + } + if (!(pPriv = malloc(sizeof(OffscreenPrivRec)))) { + free(surface->pitches); + free(surface->offsets); + return BadAlloc; + } + + pPriv->area = area; + pPriv->isOn = FALSE; + + surface->pScrn = pScrn; + surface->id = id; + surface->pitches[0] = pitch; + surface->offsets[0] = area->box.y1 * fbpitch; + surface->devPrivate.ptr = (pointer) pPriv; + + return Success; } static int GX2StopSurface(XF86SurfacePtr surface) { - OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; + OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; - if (pPriv->isOn) { - pPriv->isOn = FALSE; - } + if (pPriv->isOn) { + pPriv->isOn = FALSE; + } - return Success; + return Success; } static int GX2FreeSurface(XF86SurfacePtr surface) { - OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; + OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; - if (pPriv->isOn) - GX2StopSurface(surface); - xf86FreeOffscreenArea(pPriv->area); - free(surface->pitches); - free(surface->offsets); - free(surface->devPrivate.ptr); + if (pPriv->isOn) + GX2StopSurface(surface); + xf86FreeOffscreenArea(pPriv->area); + free(surface->pitches); + free(surface->offsets); + free(surface->devPrivate.ptr); - return Success; + return Success; } static int -GX2GetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 * value) +GX2GetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 *value) { - return GX2GetPortAttribute(pScrn, attribute, value, - (pointer) (GET_PORT_PRIVATE(pScrn))); + return GX2GetPortAttribute(pScrn, attribute, value, + (pointer) (GET_PORT_PRIVATE(pScrn))); } static int GX2SetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 value) { - return GX2SetPortAttribute(pScrn, attribute, value, - (pointer) (GET_PORT_PRIVATE(pScrn))); + return GX2SetPortAttribute(pScrn, attribute, value, + (pointer) (GET_PORT_PRIVATE(pScrn))); } static int GX2DisplaySurface(XF86SurfacePtr surface, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, RegionPtr clipBoxes) + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, RegionPtr clipBoxes) { - OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; - ScrnInfoPtr pScrn = surface->pScrn; - GeodePortPrivPtr portPriv = GET_PORT_PRIVATE(pScrn); - INT32 x1, y1, x2, y2; - BoxRec dstBox; - - DEBUGMSG(0, (0, X_NONE, "DisplaySuface\n")); - x1 = src_x; - x2 = src_x + src_w; - y1 = src_y; - y2 = src_y + src_h; - - dstBox.x1 = drw_x; - dstBox.x2 = drw_x + drw_w; - dstBox.y1 = drw_y; - dstBox.y2 = drw_y + drw_h; - - if ((x1 >= x2) || (y1 >= y2)) - return Success; - - dstBox.x1 -= pScrn->frameX0; - dstBox.x2 -= pScrn->frameX0; - dstBox.y1 -= pScrn->frameY0; - dstBox.y2 -= pScrn->frameY0; - - xf86XVFillKeyHelper(pScrn->pScreen, portPriv->colorKey, clipBoxes); - - GX2DisplayVideo(pScrn, 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); - - pPriv->isOn = TRUE; - if (portPriv->videoStatus & CLIENT_VIDEO_ON) { - REGION_EMPTY(pScrn->pScreen, &portPriv->clip); - UpdateCurrentTime(); - portPriv->videoStatus = FREE_TIMER; - portPriv->freeTime = currentTime.milliseconds + FREE_DELAY; - } - - return Success; + OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr; + ScrnInfoPtr pScrn = surface->pScrn; + GeodePortPrivPtr portPriv = GET_PORT_PRIVATE(pScrn); + INT32 x1, y1, x2, y2; + BoxRec dstBox; + + DEBUGMSG(0, (0, X_NONE, "DisplaySuface\n")); + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + if ((x1 >= x2) || (y1 >= y2)) + return Success; + + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + + xf86XVFillKeyHelper(pScrn->pScreen, portPriv->colorKey, clipBoxes); + + GX2DisplayVideo(pScrn, 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); + + pPriv->isOn = TRUE; + if (portPriv->videoStatus & CLIENT_VIDEO_ON) { + REGION_EMPTY(pScrn->pScreen, &portPriv->clip); + UpdateCurrentTime(); + portPriv->videoStatus = FREE_TIMER; + portPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + } + + return Success; } /*---------------------------------------------------------------------------- @@ -1502,24 +1512,24 @@ GX2DisplaySurface(XF86SurfacePtr surface, static void GX2InitOffscreenImages(ScreenPtr pScreen) { - XF86OffscreenImagePtr offscreenImages; - - /* need to free this someplace */ - if (!(offscreenImages = malloc(sizeof(XF86OffscreenImageRec)))) - return; - - offscreenImages[0].image = &Images[0]; - offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - offscreenImages[0].alloc_surface = GX2AllocateSurface; - offscreenImages[0].free_surface = GX2FreeSurface; - offscreenImages[0].display = GX2DisplaySurface; - offscreenImages[0].stop = GX2StopSurface; - offscreenImages[0].setAttribute = GX2SetSurfaceAttribute; - offscreenImages[0].getAttribute = GX2GetSurfaceAttribute; - offscreenImages[0].max_width = 1024; - offscreenImages[0].max_height = 1024; - offscreenImages[0].num_attributes = NUM_ATTRIBUTES; - offscreenImages[0].attributes = Attributes; - - xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); + XF86OffscreenImagePtr offscreenImages; + + /* need to free this someplace */ + if (!(offscreenImages = malloc(sizeof(XF86OffscreenImageRec)))) + return; + + offscreenImages[0].image = &Images[0]; + offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + offscreenImages[0].alloc_surface = GX2AllocateSurface; + offscreenImages[0].free_surface = GX2FreeSurface; + offscreenImages[0].display = GX2DisplaySurface; + offscreenImages[0].stop = GX2StopSurface; + offscreenImages[0].setAttribute = GX2SetSurfaceAttribute; + offscreenImages[0].getAttribute = GX2GetSurfaceAttribute; + offscreenImages[0].max_width = 1024; + offscreenImages[0].max_height = 1024; + offscreenImages[0].num_attributes = NUM_ATTRIBUTES; + offscreenImages[0].attributes = Attributes; + + xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); } diff --git a/src/nsc_pcirename.h b/src/nsc_pcirename.h index e1477ee..7df95ac 100644 --- a/src/nsc_pcirename.h +++ b/src/nsc_pcirename.h @@ -77,7 +77,7 @@ enum region_type { #define PCI_WRITE_LONG(_pcidev, _value, _offset) \ pciWriteLong(PCI_CFG_TAG(_pcidev), (_offset), (_value)) -#else /* XSERVER_LIBPCIACCESS */ +#else /* XSERVER_LIBPCIACCESS */ typedef struct pci_device *pciVideoPtr; @@ -117,6 +117,6 @@ typedef struct pci_device *pciVideoPtr; #define PCI_WRITE_LONG(_pcidev, _value, _offset) \ pci_device_cfg_write_u32((_pcidev), (_value), (_offset)) -#endif /* XSERVER_LIBPCIACCESS */ +#endif /* XSERVER_LIBPCIACCESS */ -#endif /* NSC_PCIRENAME_H */ +#endif /* NSC_PCIRENAME_H */ diff --git a/src/nsc_regacc.c b/src/nsc_regacc.c index bbbb340..b378c40 100644 --- a/src/nsc_regacc.c +++ b/src/nsc_regacc.c @@ -156,77 +156,80 @@ unsigned long gfx_read_vid32(unsigned long offset); unsigned long gfx_read_vip32(unsigned long offset); void gfx_write_vip32(unsigned long offset, unsigned long value); void gfx_mono_bitmap_to_screen_blt_swp(unsigned short srcx, - unsigned short srcy, - unsigned short dstx, - unsigned short dsty, - unsigned short width, - unsigned short height, - unsigned char *data, short pitch); + unsigned short srcy, + unsigned short dstx, + unsigned short dsty, + unsigned short width, + unsigned short height, + unsigned char *data, short pitch); unsigned int GetVideoMemSize(void); /* ROUTINES added accessing hardware reg */ void gfx_write_reg8(unsigned long offset, unsigned char value) { - WRITE_REG8(offset, value); + WRITE_REG8(offset, value); } void gfx_write_reg16(unsigned long offset, unsigned short value) { - WRITE_REG16(offset, value); + WRITE_REG16(offset, value); } void gfx_write_reg32(unsigned long offset, unsigned long value) { - WRITE_REG32(offset, value); + WRITE_REG32(offset, value); } + unsigned short gfx_read_reg16(unsigned long offset) { - unsigned short value; + unsigned short value; - value = READ_REG16(offset); - return value; + value = READ_REG16(offset); + return value; } + unsigned long gfx_read_reg32(unsigned long offset) { - unsigned long value; + unsigned long value; - value = READ_REG32(offset); - return value; + value = READ_REG32(offset); + return value; } void gfx_write_vid32(unsigned long offset, unsigned long value) { - WRITE_VID32(offset, value); + WRITE_VID32(offset, value); } + unsigned long gfx_read_vid32(unsigned long offset) { - unsigned long value; + unsigned long value; - value = READ_VID32(offset); - return value; + value = READ_VID32(offset); + return value; } /*Addition for the VIP code */ unsigned long gfx_read_vip32(unsigned long offset) { - unsigned long value; + unsigned long value; - value = READ_VIP32(offset); - return value; + value = READ_VIP32(offset); + return value; } void gfx_write_vip32(unsigned long offset, unsigned long value) { - WRITE_VIP32(offset, value); + WRITE_VIP32(offset, value); } #define SWAP_BITS_IN_BYTES(v) \ @@ -244,182 +247,184 @@ gfx_write_vip32(unsigned long offset, unsigned long value) void gfx_mono_bitmap_to_screen_blt_swp(unsigned short srcx, unsigned short srcy, - unsigned short dstx, unsigned short dsty, - unsigned short width, unsigned short height, - unsigned char *data, short pitch) + unsigned short dstx, unsigned short dsty, + unsigned short width, unsigned short height, + unsigned char *data, short pitch) { - unsigned long dstoffset, size, bytes; - unsigned long offset, temp_offset, temp1 = 0, temp2 = 0; - unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; - unsigned long shift = 0; + unsigned long dstoffset, size, bytes; + unsigned long offset, temp_offset, temp1 = 0, temp2 = 0; + unsigned long i, j = 0, fifo_lines, dwords_extra, bytes_extra; + unsigned long shift = 0; - size = (((unsigned long)width) << 16) | height; + size = (((unsigned long) width) << 16) | height; - /* CALCULATE STARTING OFFSETS */ + /* CALCULATE STARTING OFFSETS */ - offset = (unsigned long)srcy *pitch + ((unsigned long)srcx >> 3); + offset = (unsigned long) srcy *pitch + ((unsigned long) srcx >> 3); - dstoffset = (unsigned long)dsty *gu2_pitch + - (((unsigned long)dstx) << gu2_xshift); + dstoffset = (unsigned long) dsty *gu2_pitch + + (((unsigned long) dstx) << gu2_xshift); - /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ + /* CHECK IF PATTERN ORIGINS NEED TO BE SET */ - if (GFXpatternFlags) { - /* COMBINE X AND Y PATTERN ORIGINS WITH OFFSET */ + if (GFXpatternFlags) { + /* 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; - fifo_lines = bytes >> 5; - dwords_extra = (bytes & 0x0000001Cl) >> 2; - bytes_extra = bytes & 0x00000003l; + bytes = ((srcx & 7) + width + 7) >> 3; + fifo_lines = bytes >> 5; + dwords_extra = (bytes & 0x0000001Cl) >> 2; + bytes_extra = bytes & 0x00000003l; - /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ - /* Put off poll for as long as possible (do most calculations first). */ - /* The source offset is always 0 since we allow misaligned dword reads. */ - /* Need to wait for busy instead of pending, since hardware clears */ - /* the host data FIFO at the beginning of a BLT. */ + /* POLL UNTIL ABLE TO WRITE TO THE REGISTERS */ + /* Put off poll for as long as possible (do most calculations first). */ + /* The source offset is always 0 since we allow misaligned dword reads. */ + /* Need to wait for busy instead of pending, since hardware clears */ + /* the host data FIFO at the beginning of a BLT. */ - GU2_WAIT_PENDING; - WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); - WRITE_GP32(MGP_SRC_OFFSET, ((unsigned long)srcx & 7) << 26); - WRITE_GP32(MGP_DST_OFFSET, dstoffset); - 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_WAIT_PENDING; + WRITE_GP32(MGP_RASTER_MODE, gu2_rop32); + WRITE_GP32(MGP_SRC_OFFSET, ((unsigned long) srcx & 7) << 26); + WRITE_GP32(MGP_DST_OFFSET, dstoffset); + 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); - /* WAIT FOR BLT TO BE LATCHED */ + /* WAIT FOR BLT TO BE LATCHED */ - GU2_WAIT_PENDING; + GU2_WAIT_PENDING; - /* WRITE ALL OF THE DATA TO THE HOST SOURCE REGISTER */ + /* WRITE ALL OF THE DATA TO THE HOST SOURCE REGISTER */ - while (height--) { - temp_offset = offset; + while (height--) { + 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; + } } + unsigned int GetVideoMemSize(void) { - unsigned int graphicsMemBaseAddr; - unsigned int totalMem = 0; - int i; - unsigned int graphicsMemMask, graphicsMemShift; - - /* Read graphics base address. */ - - graphicsMemBaseAddr = gfx_read_reg32(0x8414); - - if (1) { - unsigned int mcBankCfg = gfx_read_reg32(0x8408); - unsigned int dimmShift = 4; - - graphicsMemMask = 0x7FF; - graphicsMemShift = 19; - - /* 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; - } - } else { - unsigned int mcMemCntrl1 = gfx_read_reg32(0x8400); - unsigned int bankSizeShift = 12; - - graphicsMemMask = 0x3FF; - graphicsMemShift = 17; - - /* Calculate total memory size for GX. */ - - for (i = 0; i < 4; i++) { - switch ((mcMemCntrl1 >> bankSizeShift) & 0x7) { - case 1: - totalMem += 0x200000; - break; - case 2: - totalMem += 0x400000; - break; - case 3: - totalMem += 0x800000; - break; - case 4: - totalMem += 0x1000000; - break; - case 5: - totalMem += 0x2000000; - break; - default: - break; - } - bankSizeShift += 3; - } - } - - /* Calculate graphics memory base address */ - - graphicsMemBaseAddr &= graphicsMemMask; - graphicsMemBaseAddr <<= graphicsMemShift; - - return (totalMem - graphicsMemBaseAddr); + unsigned int graphicsMemBaseAddr; + unsigned int totalMem = 0; + int i; + unsigned int graphicsMemMask, graphicsMemShift; + + /* Read graphics base address. */ + + graphicsMemBaseAddr = gfx_read_reg32(0x8414); + + if (1) { + unsigned int mcBankCfg = gfx_read_reg32(0x8408); + unsigned int dimmShift = 4; + + graphicsMemMask = 0x7FF; + graphicsMemShift = 19; + + /* 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; + } + } + else { + unsigned int mcMemCntrl1 = gfx_read_reg32(0x8400); + unsigned int bankSizeShift = 12; + + graphicsMemMask = 0x3FF; + graphicsMemShift = 17; + + /* Calculate total memory size for GX. */ + + for (i = 0; i < 4; i++) { + switch ((mcMemCntrl1 >> bankSizeShift) & 0x7) { + case 1: + totalMem += 0x200000; + break; + case 2: + totalMem += 0x400000; + break; + case 3: + totalMem += 0x800000; + break; + case 4: + totalMem += 0x1000000; + break; + case 5: + totalMem += 0x2000000; + break; + default: + break; + } + bankSizeShift += 3; + } + } + + /* Calculate graphics memory base address */ + + graphicsMemBaseAddr &= graphicsMemMask; + graphicsMemBaseAddr <<= graphicsMemShift; + + return (totalMem - graphicsMemBaseAddr); } /* END OF FILE */ diff --git a/src/panel.c b/src/panel.c index 4bc11e1..3c03073 100644 --- a/src/panel.c +++ b/src/panel.c @@ -148,11 +148,11 @@ #include "gfx_defs.h" #include "nsc.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/panel/92xx.h b/src/panel/92xx.h index 427fc50..069268f 100644 --- a/src/panel/92xx.h +++ b/src/panel/92xx.h @@ -207,7 +207,7 @@ typedef unsigned char UCHAR; /* ram control */ -#define CS92xx_LCD_RAM_DATA CS92xx_LCD_OFFSET + 0x28 /* ram data */ +#define CS92xx_LCD_RAM_DATA CS92xx_LCD_OFFSET + 0x28 /* ram data */ #define CS92xx_LCD_PAN_CRC_SIG CS92xx_LCD_OFFSET + 0x2C @@ -215,58 +215,54 @@ typedef unsigned char UCHAR; #define CS92xx_DEV_REV_ID CS92xx_LCD_OFFSET + 0x30 /* Device and revision id */ -#define CS92xx_LCD_GPIO_DATA CS92xx_LCD_OFFSET + 0x34 /* GPIO Data */ +#define CS92xx_LCD_GPIO_DATA CS92xx_LCD_OFFSET + 0x34 /* GPIO Data */ #define CS92xx_LCD_GPIO_CNTRL CS92xx_LCD_OFFSET + 0x38 /* GPIO Control */ int Pnl_Rev_ID; -typedef struct -{ - /* DISPLAY MODE PARAMETERS */ - int xres; - int yres; - int bpp; - int panel_type; - int color_type; - /* VALUES USED TO SET THE FLAT PANEL DISPLAY CONTROLLER */ - unsigned long panel_timing1; - unsigned long panel_timing2; - unsigned long power_management; - /* the following 5 registers are prior to revision C */ - unsigned long pre_C_dither_frc; - unsigned long block_select1; - unsigned long block_select2; - unsigned long dispersion1; - unsigned long dispersion2; - /* the following 4 registers are revision C only */ - unsigned long rev_C_dither_frc; - unsigned long blue_lsfr_seed; - unsigned long red_green_lsfr_seed; - unsigned long frm_memory_index; - unsigned long frm_memory_data; - unsigned long memory_control; - -} -CS92xx_MODE; +typedef struct { + /* DISPLAY MODE PARAMETERS */ + int xres; + int yres; + int bpp; + int panel_type; + int color_type; + /* VALUES USED TO SET THE FLAT PANEL DISPLAY CONTROLLER */ + unsigned long panel_timing1; + unsigned long panel_timing2; + unsigned long power_management; + /* the following 5 registers are prior to revision C */ + unsigned long pre_C_dither_frc; + unsigned long block_select1; + unsigned long block_select2; + unsigned long dispersion1; + unsigned long dispersion2; + /* the following 4 registers are revision C only */ + unsigned long rev_C_dither_frc; + unsigned long blue_lsfr_seed; + unsigned long red_green_lsfr_seed; + unsigned long frm_memory_index; + unsigned long frm_memory_data; + unsigned long memory_control; + +} CS92xx_MODE; /* VALUES USED TO SAVE AND RESTORE 9211 REGISTERS. */ -typedef struct -{ - unsigned long panel_state; - /* VALUES USED TO SET THE FLAT PANEL DISPLAY CONTROLLER */ - unsigned long panel_timing1; - unsigned long panel_timing2; - unsigned long power_management; - unsigned long dither_frc_ctrl; - unsigned long blue_lsfr_seed; - unsigned long red_green_lsfr_seed; - unsigned long frm_memory_index; - unsigned long frm_memory_data; - unsigned long memory_control; -} -CS92xx_REGS; +typedef struct { + unsigned long panel_state; + /* VALUES USED TO SET THE FLAT PANEL DISPLAY CONTROLLER */ + unsigned long panel_timing1; + unsigned long panel_timing2; + unsigned long power_management; + unsigned long dither_frc_ctrl; + unsigned long blue_lsfr_seed; + unsigned long red_green_lsfr_seed; + unsigned long frm_memory_index; + unsigned long frm_memory_data; + unsigned long memory_control; +} CS92xx_REGS; CS92xx_REGS cs9211_regs; @@ -278,189 +274,189 @@ CS92xx_REGS cs9211_regs; */ CS92xx_MODE FPModeParams[] = { - {640, 480, 8, PNL_SSTN, PNL_COLOR_PANEL, /* display parameters */ - 0x01e00000, 0x00034000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ - 0x21446450, 0x21446450, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000000, /* memory control */ - }, - - {640, 480, 12, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ - 0x01e00000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* block select 1, block select 2 */ - 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000000, /* memory control */ - }, - - {640, 480, 18, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ - 0x01e00000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* block select 1, block select 2 */ - 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000000, /* memory control */ - }, - - {640, 480, 16, PNL_DSTN, PNL_COLOR_PANEL, /* display parameters */ - 0x01e00000, 0x00014000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x048c26ae, 0x048c26ae, /* block select 1, block select 2 */ - 0x02468ace, 0x13579bdf, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x0000004b, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000007, /* memory control */ - }, - - {640, 480, 8, PNL_DSTN, PNL_MONO_PANEL, /* display parameters */ - 0x01e00000, 0x00084000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x0000004b, /* dither and frame rate control */ - 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ - 0x21446450, 0x21446450, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000007, /* memory control */ - }, - - {640, 480, 16, PNL_DSTN, PNL_MONO_PANEL, /* display parameters */ - 0x01e00000, 0x00094000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ - 0x81a5d470, 0x29cfb63e, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000007, /* memory control */ - }, - - {800, 600, 12, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ - 0x02580000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* block select 1, block select 2 */ - 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000000, /* memory control */ - }, - - {800, 600, 18, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ - 0x02580000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* block select 1, block select 2 */ - 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000000, /* memory control */ - }, - - {800, 600, 16, PNL_DSTN, PNL_COLOR_PANEL, /* display parameters */ - 0x02580000, 0x00014000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x048c26ae, 0x048c26ae, /* block select 1, block select 2 */ - 0x02468ace, 0x13579bdf, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x0000004b, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000007, /* memory control */ - }, - - {800, 600, 8, PNL_DSTN, PNL_MONO_PANEL, /* display parameters */ - 0x02580000, 0x00084000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ - 0x21446450, 0x21446450, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x0000004b, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000007, /* memory control */ - }, - - {800, 600, 16, PNL_DSTN, PNL_MONO_PANEL, /* display parameters */ - 0x02580000, 0x00094000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /* The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ - 0x81a5d470, 0x29cfb63e, /* dispersion 1, dispersion 2 */ - /* The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000007, /* memory control */ - }, - - {1024, 768, 18, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ - 0x03000000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /*The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* block select 1, block select 2 */ - 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ - /*The next 5 values are for revision C */ - 0x00000050, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000000, /* memory control */ - }, - - {1024, 768, 24, PNL_DSTN, PNL_COLOR_PANEL, /* display parameters */ - 0x03000000, 0x80024000, /* panel timing reg 1, panel timing reg 2 */ - 0x01000000, /* power management */ - /*The next 5 values are prior to revision C */ - 0x00000050, /* dither and frame rate control */ - 0x048c26ae, 0x048c26ae, /* block select 1, block select 2 */ - 0x02468ace, 0x13579bdf, /* dispersion 1, dispersion 2 */ - /*The next 5 values are for revision C */ - 0x0000004b, /* dither and frame rate control */ - 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ - 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ - 0x00000005, /* memory control */ - } + {640, 480, 8, PNL_SSTN, PNL_COLOR_PANEL, /* display parameters */ + 0x01e00000, 0x00034000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ + 0x21446450, 0x21446450, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000000, /* memory control */ + }, + + {640, 480, 12, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ + 0x01e00000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* block select 1, block select 2 */ + 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000000, /* memory control */ + }, + + {640, 480, 18, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ + 0x01e00000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* block select 1, block select 2 */ + 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000000, /* memory control */ + }, + + {640, 480, 16, PNL_DSTN, PNL_COLOR_PANEL, /* display parameters */ + 0x01e00000, 0x00014000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x048c26ae, 0x048c26ae, /* block select 1, block select 2 */ + 0x02468ace, 0x13579bdf, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x0000004b, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000007, /* memory control */ + }, + + {640, 480, 8, PNL_DSTN, PNL_MONO_PANEL, /* display parameters */ + 0x01e00000, 0x00084000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x0000004b, /* dither and frame rate control */ + 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ + 0x21446450, 0x21446450, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000007, /* memory control */ + }, + + {640, 480, 16, PNL_DSTN, PNL_MONO_PANEL, /* display parameters */ + 0x01e00000, 0x00094000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ + 0x81a5d470, 0x29cfb63e, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000007, /* memory control */ + }, + + {800, 600, 12, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ + 0x02580000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* block select 1, block select 2 */ + 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000000, /* memory control */ + }, + + {800, 600, 18, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ + 0x02580000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* block select 1, block select 2 */ + 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000000, /* memory control */ + }, + + {800, 600, 16, PNL_DSTN, PNL_COLOR_PANEL, /* display parameters */ + 0x02580000, 0x00014000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x048c26ae, 0x048c26ae, /* block select 1, block select 2 */ + 0x02468ace, 0x13579bdf, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x0000004b, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000007, /* memory control */ + }, + + {800, 600, 8, PNL_DSTN, PNL_MONO_PANEL, /* display parameters */ + 0x02580000, 0x00084000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ + 0x21446450, 0x21446450, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x0000004b, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000007, /* memory control */ + }, + + {800, 600, 16, PNL_DSTN, PNL_MONO_PANEL, /* display parameters */ + 0x02580000, 0x00094000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /* The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x25cf3096, 0xad47b81e, /* block select 1, block select 2 */ + 0x81a5d470, 0x29cfb63e, /* dispersion 1, dispersion 2 */ + /* The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000007, /* memory control */ + }, + + {1024, 768, 18, PNL_TFT, PNL_COLOR_PANEL, /* display parameters */ + 0x03000000, 0x0f100000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /*The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* block select 1, block select 2 */ + 0x00000000, 0x00000000, /* dispersion 1, dispersion 2 */ + /*The next 5 values are for revision C */ + 0x00000050, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000000, /* memory control */ + }, + + {1024, 768, 24, PNL_DSTN, PNL_COLOR_PANEL, /* display parameters */ + 0x03000000, 0x80024000, /* panel timing reg 1, panel timing reg 2 */ + 0x01000000, /* power management */ + /*The next 5 values are prior to revision C */ + 0x00000050, /* dither and frame rate control */ + 0x048c26ae, 0x048c26ae, /* block select 1, block select 2 */ + 0x02468ace, 0x13579bdf, /* dispersion 1, dispersion 2 */ + /*The next 5 values are for revision C */ + 0x0000004b, /* dither and frame rate control */ + 0x00000000, 0x00000000, /* blue LSFR, red and green LSFR */ + 0x00000000, 0x00000000, /* FRM memory index, FRM memory data */ + 0x00000005, /* memory control */ + } }; -#endif /* !_92XX_h */ +#endif /* !_92XX_h */ /* END OF FILE */ diff --git a/src/panel/cen9211.c b/src/panel/cen9211.c index 85aecdf..ef0ca13 100644 --- a/src/panel/cen9211.c +++ b/src/panel/cen9211.c @@ -150,68 +150,68 @@ static unsigned char must_restore_97317 = FALSE; unsigned char init_Centaurus_GPIO(void) { - unsigned char reg_val; - static unsigned char first_time = TRUE; + unsigned char reg_val; + static unsigned char first_time = TRUE; - /* The Centaurus board uses ports 1 and 2 of the 97317 for GPIO. - * These ports require bank 0 to be active. The first thing we will - * do is verify that bank 0 is active and set it if it is not. - */ + /* The Centaurus board uses ports 1 and 2 of the 97317 for GPIO. + * These ports require bank 0 to be active. The first thing we will + * do is verify that bank 0 is active and set it if it is not. + */ - /* set the index for access to the configuration register */ - gfx_outb(CENT_CONFIG_INDEX, CENT_SIOC2); - reg_val = gfx_inb(CENT_CONFIG_DATA); + /* set the index for access to the configuration register */ + gfx_outb(CENT_CONFIG_INDEX, CENT_SIOC2); + reg_val = gfx_inb(CENT_CONFIG_DATA); - /* set to bank 0 */ - if (reg_val & CENT_GPIO_BANK_SELECT) { - gfx_outb(CENT_CONFIG_DATA, - (unsigned char)(reg_val & ~CENT_GPIO_BANK_SELECT)); - } + /* set to bank 0 */ + if (reg_val & CENT_GPIO_BANK_SELECT) { + gfx_outb(CENT_CONFIG_DATA, + (unsigned char) (reg_val & ~CENT_GPIO_BANK_SELECT)); + } - /* If this is the first time we have modified sioc2, we must - * save the current value (set by the BIOS) for restoration by - * the calling program, set the global flag must_restore_97317, and set - * first_time to FALSE. - */ + /* If this is the first time we have modified sioc2, we must + * save the current value (set by the BIOS) for restoration by + * the calling program, set the global flag must_restore_97317, and set + * first_time to FALSE. + */ - if (first_time == TRUE) { - sioc2_orig_val = reg_val; - must_restore_97317 = TRUE; - first_time = FALSE; - } + if (first_time == TRUE) { + sioc2_orig_val = reg_val; + must_restore_97317 = TRUE; + first_time = FALSE; + } - /* set port 1 direction */ - reg_val = gfx_inb(CENT_PORT1_DIRECTION); + /* set port 1 direction */ + reg_val = gfx_inb(CENT_PORT1_DIRECTION); - /* make GPIO 14 and 17 outputs */ - reg_val |= CENT_97317_CLOCK_MASK | CENT_97317_DATA_OUT_MASK; - gfx_outb(CENT_PORT1_DIRECTION, reg_val); + /* make GPIO 14 and 17 outputs */ + reg_val |= CENT_97317_CLOCK_MASK | CENT_97317_DATA_OUT_MASK; + gfx_outb(CENT_PORT1_DIRECTION, reg_val); - /* set port 2 direction */ - reg_val = gfx_inb(CENT_PORT2_DIRECTION); + /* set port 2 direction */ + reg_val = gfx_inb(CENT_PORT2_DIRECTION); - /* make GPIO 20 an output */ + /* make GPIO 20 an output */ - reg_val |= CENT_97317_CHIP_SEL_MASK; + reg_val |= CENT_97317_CHIP_SEL_MASK; - /* make GPIO 21 an input */ + /* make GPIO 21 an input */ - reg_val &= ~CENT_97317_DATA_IN_MASK; - gfx_outb(CENT_PORT2_DIRECTION, reg_val); + reg_val &= ~CENT_97317_DATA_IN_MASK; + gfx_outb(CENT_PORT2_DIRECTION, reg_val); - /* make GPIO 14 and 17 push-pull */ + /* make GPIO 14 and 17 push-pull */ - reg_val = gfx_inb(CENT_PORT1_OUTPUT_TYPE); - reg_val |= CENT_97317_CLOCK_MASK | CENT_97317_DATA_OUT_MASK; - gfx_outb(CENT_PORT1_OUTPUT_TYPE, reg_val); + reg_val = gfx_inb(CENT_PORT1_OUTPUT_TYPE); + reg_val |= CENT_97317_CLOCK_MASK | CENT_97317_DATA_OUT_MASK; + gfx_outb(CENT_PORT1_OUTPUT_TYPE, reg_val); - /* make GPIO 20 and 21 push-pull */ - reg_val = gfx_inb(CENT_PORT2_OUTPUT_TYPE); - reg_val |= CENT_97317_CHIP_SEL_MASK | CENT_97317_DATA_IN_MASK; - gfx_outb(CENT_PORT2_OUTPUT_TYPE, reg_val); - return CENT_PASS; + /* make GPIO 20 and 21 push-pull */ + reg_val = gfx_inb(CENT_PORT2_OUTPUT_TYPE); + reg_val |= CENT_97317_CHIP_SEL_MASK | CENT_97317_DATA_IN_MASK; + gfx_outb(CENT_PORT2_OUTPUT_TYPE, reg_val); + return CENT_PASS; -} /* end init_GPIO() */ +} /* end init_GPIO() */ /********************************************************************* * @@ -224,21 +224,21 @@ init_Centaurus_GPIO(void) unsigned char init_Centaurus_9211(void) { - unsigned char ReadData; - - /* Uses the 97317 for GPIO. - * we will use the clock port define for port 1 - */ - ReadData = gfx_inb(CENT_97317_CLOCK_PORT); - ReadData &= ~CENT_97317_CLOCK_MASK & ~CENT_97317_DATA_OUT_MASK; - gfx_outb(CENT_97317_CLOCK_PORT, ReadData); - /* we will use the chip select port define for port 2 */ - ReadData = gfx_inb(CENT_97317_CHIP_SELECT); - ReadData &= ~CENT_97317_CHIP_SEL_MASK & ~CENT_97317_DATA_IN_MASK; - gfx_outb(CENT_97317_CHIP_SELECT, ReadData); - return (CENT_PASS); - -} /*end init_9211() */ + unsigned char ReadData; + + /* Uses the 97317 for GPIO. + * we will use the clock port define for port 1 + */ + ReadData = gfx_inb(CENT_97317_CLOCK_PORT); + ReadData &= ~CENT_97317_CLOCK_MASK & ~CENT_97317_DATA_OUT_MASK; + gfx_outb(CENT_97317_CLOCK_PORT, ReadData); + /* we will use the chip select port define for port 2 */ + ReadData = gfx_inb(CENT_97317_CHIP_SELECT); + ReadData &= ~CENT_97317_CHIP_SEL_MASK & ~CENT_97317_DATA_IN_MASK; + gfx_outb(CENT_97317_CHIP_SELECT, ReadData); + return (CENT_PASS); + +} /*end init_9211() */ /****************************************************************** * @@ -252,27 +252,27 @@ init_Centaurus_9211(void) unsigned char restore_Centaurus_97317_SIOC2(void) { - /* set the global flag */ - if (must_restore_97317 == TRUE) { - unsigned char cfg; + /* set the global flag */ + if (must_restore_97317 == TRUE) { + unsigned char cfg; - /* set the index for access to the configuration register */ - gfx_outb(CENT_CONFIG_INDEX, CENT_SIOC2); + /* set the index for access to the configuration register */ + gfx_outb(CENT_CONFIG_INDEX, CENT_SIOC2); - /* restore the value */ - gfx_outb(CENT_CONFIG_DATA, sioc2_orig_val); + /* restore the value */ + gfx_outb(CENT_CONFIG_DATA, sioc2_orig_val); - /* now read and verify */ - cfg = gfx_inb(CENT_CONFIG_DATA); - if (cfg == sioc2_orig_val) - return (CENT_PASS); - else - return (CENT_FAIL); + /* now read and verify */ + cfg = gfx_inb(CENT_CONFIG_DATA); + if (cfg == sioc2_orig_val) + return (CENT_PASS); + else + return (CENT_FAIL); - } /* end if() */ - return (CENT_FAIL); + } /* end if() */ + return (CENT_FAIL); -} /* end restore_97317_SIOC2bank() */ +} /* end restore_97317_SIOC2bank() */ /* ----------------------------------------------------------------------- * @@ -288,25 +288,25 @@ restore_Centaurus_97317_SIOC2(void) unsigned char set_Centaurus_92xx_mode(Pnl_PanelStat * pstat) { - int mode; + int mode; - /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ + /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ - for (mode = 0; mode < NUM_92XX_MODES; mode++) { - if ((FPModeParams[mode].xres == pstat->XRes) && - (FPModeParams[mode].yres == pstat->YRes) && - (FPModeParams[mode].bpp == pstat->Depth) && - (FPModeParams[mode].panel_type == pstat->Type) && - (FPModeParams[mode].color_type == pstat->MonoColor)) { + for (mode = 0; mode < NUM_92XX_MODES; mode++) { + if ((FPModeParams[mode].xres == pstat->XRes) && + (FPModeParams[mode].yres == pstat->YRes) && + (FPModeParams[mode].bpp == pstat->Depth) && + (FPModeParams[mode].panel_type == pstat->Type) && + (FPModeParams[mode].color_type == pstat->MonoColor)) { - /* SET THE 92xx FOR THE SELECTED MODE */ - set_Centaurus_92xx_mode_params(mode); - return (CENT_PASS); - } /* end if() */ - } /* end for() */ - return (CENT_FAIL); + /* SET THE 92xx FOR THE SELECTED MODE */ + set_Centaurus_92xx_mode_params(mode); + return (CENT_PASS); + } /* end if() */ + } /* end for() */ + return (CENT_FAIL); -} /* end set_Centaurus_92xx_mode() */ +} /* end set_Centaurus_92xx_mode() */ /*------------------------------------------------------------------- * @@ -318,140 +318,141 @@ set_Centaurus_92xx_mode(Pnl_PanelStat * pstat) void set_Centaurus_92xx_mode_params(int mode) { - CS92xx_MODE *pMode = &FPModeParams[mode]; - unsigned long off_data = 0; + CS92xx_MODE *pMode = &FPModeParams[mode]; + unsigned long off_data = 0; - /* Turn the 92xx power off before setting any new parameters. - * Since we are going to reset all the power bit positions, we will - * force the power register to 0. - */ + /* Turn the 92xx power off before setting any new parameters. + * Since we are going to reset all the power bit positions, we will + * force the power register to 0. + */ - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data); - /* set 9211 registers using the desired panel settings */ + /* set 9211 registers using the desired panel settings */ - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_PAN_TIMING1, pMode->panel_timing1); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_PAN_TIMING1, pMode->panel_timing1); - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_PAN_TIMING2, pMode->panel_timing2); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_PAN_TIMING2, pMode->panel_timing2); - if (Pnl_Rev_ID == PNL_9211_C) { + if (Pnl_Rev_ID == PNL_9211_C) { - /* load the LSFR seeds */ - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_DITH_FR_CNTRL, pMode->rev_C_dither_frc); + /* load the LSFR seeds */ + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_DITH_FR_CNTRL, pMode->rev_C_dither_frc); - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_BLUE_LSFR_SEED, pMode->blue_lsfr_seed); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_BLUE_LSFR_SEED, pMode->blue_lsfr_seed); - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_RED_GREEN_LSFR_SEED, - pMode->red_green_lsfr_seed); - } else { + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_RED_GREEN_LSFR_SEED, + pMode->red_green_lsfr_seed); + } + else { - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_DITH_FR_CNTRL, pMode->pre_C_dither_frc); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_DITH_FR_CNTRL, pMode->pre_C_dither_frc); - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_BLOCK_SEL1, pMode->block_select1); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_BLOCK_SEL1, pMode->block_select1); - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_BLOCK_SEL2, pMode->block_select2); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_BLOCK_SEL2, pMode->block_select2); - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_DISPER1, pMode->dispersion1); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_DISPER1, pMode->dispersion1); - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_DISPER2, pMode->dispersion2); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_DISPER2, pMode->dispersion2); - CentaurusProgramFRMload(); - } + CentaurusProgramFRMload(); + } - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL, - pMode->memory_control); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL, + pMode->memory_control); - /* Set the power register last. This will turn the panel on at the 9211. */ + /* Set the power register last. This will turn the panel on at the 9211. */ - Centaurus_write_gpio(FOUR_BYTES, - CS92xx_LCD_PWR_MAN, pMode->power_management); + Centaurus_write_gpio(FOUR_BYTES, + CS92xx_LCD_PWR_MAN, pMode->power_management); -} /* end set_Centaurus_92xx_mode_params() */ +} /* end set_Centaurus_92xx_mode_params() */ void Centaurus_write_gpio(int width, ULONG address, unsigned long data) { - int num_clock_toggles; - int count; - unsigned long Addr = address; + int num_clock_toggles; + int count; + unsigned long Addr = address; - enable_Centaurus_9211_chip_select(); + enable_Centaurus_9211_chip_select(); - /* Write 1 Clock period of no valid transfer */ - write_Centaurus_CX9211_GPIO(CENT_NO_DATA); + /* Write 1 Clock period of no valid transfer */ + write_Centaurus_CX9211_GPIO(CENT_NO_DATA); - /* Write 1 control bit (the data book calls this the control bar write) */ - write_Centaurus_CX9211_GPIO(0x1); + /* Write 1 control bit (the data book calls this the control bar write) */ + write_Centaurus_CX9211_GPIO(0x1); - /* Write the 12-bit address */ - for (count = 0; count < 12; count++) { - write_Centaurus_CX9211_GPIO((unsigned char)(Addr & 0x01)); - /*the 9211 expects data LSB->MSB */ - Addr = Addr >> 1; - } + /* Write the 12-bit address */ + for (count = 0; count < 12; count++) { + write_Centaurus_CX9211_GPIO((unsigned char) (Addr & 0x01)); + /*the 9211 expects data LSB->MSB */ + Addr = Addr >> 1; + } - /* write */ - write_Centaurus_CX9211_DWdata(data); + /* write */ + write_Centaurus_CX9211_DWdata(data); - /* a write will require four toggles after disabling CS */ - num_clock_toggles = CENT_NUM_WRITE_CLOCK_TOGGLES; - disable_Centaurus_9211_chip_select(); + /* a write will require four toggles after disabling CS */ + num_clock_toggles = CENT_NUM_WRITE_CLOCK_TOGGLES; + disable_Centaurus_9211_chip_select(); - /* now toggle the clock */ - for (count = 0; count < num_clock_toggles; count++) { - toggle_Centaurus_9211_clock(); - } - return; + /* now toggle the clock */ + for (count = 0; count < num_clock_toggles; count++) { + toggle_Centaurus_9211_clock(); + } + return; -} /* end Centaurus_write_gpio() */ +} /* end Centaurus_write_gpio() */ unsigned long Centaurus_read_gpio(int width, unsigned long address) { - int num_clock_toggles; - int count; - unsigned long Addr = address; - unsigned long data; + int num_clock_toggles; + int count; + unsigned long Addr = address; + unsigned long data; - enable_Centaurus_9211_chip_select(); + enable_Centaurus_9211_chip_select(); - /* Write 1 Clock period of no valid transfer */ - write_Centaurus_CX9211_GPIO(CENT_NO_DATA); + /* Write 1 Clock period of no valid transfer */ + write_Centaurus_CX9211_GPIO(CENT_NO_DATA); - /* Write 1 control bit (the data book calls this the control bar write) */ - write_Centaurus_CX9211_GPIO(0x1); + /* Write 1 control bit (the data book calls this the control bar write) */ + write_Centaurus_CX9211_GPIO(0x1); - /* Write the 12-bit address */ - for (count = 0; count < 12; count++) { - write_Centaurus_CX9211_GPIO((unsigned char)(Addr & 0x01)); + /* Write the 12-bit address */ + for (count = 0; count < 12; count++) { + write_Centaurus_CX9211_GPIO((unsigned char) (Addr & 0x01)); - /*the 9211 expects data LSB->MSB */ - Addr = Addr >> 1; - } + /*the 9211 expects data LSB->MSB */ + Addr = Addr >> 1; + } - data = read_Centaurus_CX9211_DWdata(); + data = read_Centaurus_CX9211_DWdata(); - /* a read will require one toggle after disabling CS */ - num_clock_toggles = CENT_NUM_READ_CLOCK_TOGGLES; - disable_Centaurus_9211_chip_select(); + /* a read will require one toggle after disabling CS */ + num_clock_toggles = CENT_NUM_READ_CLOCK_TOGGLES; + disable_Centaurus_9211_chip_select(); - /* now toggle the clock */ - for (count = 0; count < num_clock_toggles; count++) { - toggle_Centaurus_9211_clock(); - } - return data; + /* now toggle the clock */ + for (count = 0; count < num_clock_toggles; count++) { + toggle_Centaurus_9211_clock(); + } + return data; -} /* end Centaurus_read_gpio() */ +} /* end Centaurus_read_gpio() */ /******************************************************************* * @@ -464,15 +465,15 @@ Centaurus_read_gpio(int width, unsigned long address) void enable_Centaurus_9211_chip_select(void) { - unsigned char cs_port_val; + unsigned char cs_port_val; - /* Set the chip select (GPIO20) high */ - cs_port_val = gfx_inb(CENT_97317_CHIP_SELECT); - gfx_outb(CENT_97317_CHIP_SELECT, - (unsigned char)(cs_port_val | CENT_97317_CHIP_SEL_MASK)); - return; + /* Set the chip select (GPIO20) high */ + cs_port_val = gfx_inb(CENT_97317_CHIP_SELECT); + gfx_outb(CENT_97317_CHIP_SELECT, + (unsigned char) (cs_port_val | CENT_97317_CHIP_SEL_MASK)); + return; -} /* end enable_Centaurus_9211_chip_select() */ +} /* end enable_Centaurus_9211_chip_select() */ /******************************************************************** * @@ -485,15 +486,15 @@ enable_Centaurus_9211_chip_select(void) void disable_Centaurus_9211_chip_select(void) { - unsigned char cs_port_val; + unsigned char cs_port_val; - /* Set the chip select (GPIO20) low */ - cs_port_val = gfx_inb(CENT_97317_CHIP_SELECT); - gfx_outb(CENT_97317_CHIP_SELECT, - (unsigned char)(cs_port_val & ~CENT_97317_CHIP_SEL_MASK)); - return; + /* Set the chip select (GPIO20) low */ + cs_port_val = gfx_inb(CENT_97317_CHIP_SELECT); + gfx_outb(CENT_97317_CHIP_SELECT, + (unsigned char) (cs_port_val & ~CENT_97317_CHIP_SEL_MASK)); + return; -} /* end disable_Centaurus_9211_chip_select() */ +} /* end disable_Centaurus_9211_chip_select() */ /********************************************************************** * @@ -508,20 +509,20 @@ disable_Centaurus_9211_chip_select(void) void toggle_Centaurus_9211_clock(void) { - unsigned char port_val; + unsigned char port_val; - /* get the 97317 GPIO port contents for the 9211 clock */ + /* get the 97317 GPIO port contents for the 9211 clock */ - port_val = gfx_inb(CENT_97317_CLOCK_PORT); - /* set the clock bit high */ - gfx_outb(CENT_97317_CLOCK_PORT, - (unsigned char)(port_val | CENT_97317_CLOCK_MASK)); + port_val = gfx_inb(CENT_97317_CLOCK_PORT); + /* set the clock bit high */ + gfx_outb(CENT_97317_CLOCK_PORT, + (unsigned char) (port_val | CENT_97317_CLOCK_MASK)); - /* set the clock bit low */ - gfx_outb(CENT_97317_CLOCK_PORT, - (unsigned char)(port_val & ~CENT_97317_CLOCK_MASK)); + /* set the clock bit low */ + gfx_outb(CENT_97317_CLOCK_PORT, + (unsigned char) (port_val & ~CENT_97317_CLOCK_MASK)); -} /* end toggle_Centaurus_9211_clock() */ +} /* end toggle_Centaurus_9211_clock() */ /******************************************************************** * @@ -536,24 +537,24 @@ toggle_Centaurus_9211_clock(void) void write_Centaurus_CX9211_GPIO(unsigned char databit) { - unsigned char data_port_val; + unsigned char data_port_val; - /* Set the data bit for (GPIO17) */ - databit <<= 7; + /* Set the data bit for (GPIO17) */ + databit <<= 7; - /* read the value of the other bits in the 97317 data port */ - data_port_val = gfx_inb(CENT_97317_DATA_OUTPORT); + /* read the value of the other bits in the 97317 data port */ + data_port_val = gfx_inb(CENT_97317_DATA_OUTPORT); - /* set the bit accordingly */ - data_port_val &= ~CENT_97317_DATA_OUT_MASK; - data_port_val |= databit; - gfx_outb(CENT_97317_DATA_OUTPORT, data_port_val); + /* set the bit accordingly */ + data_port_val &= ~CENT_97317_DATA_OUT_MASK; + data_port_val |= databit; + gfx_outb(CENT_97317_DATA_OUTPORT, data_port_val); - /* clock the data */ - toggle_Centaurus_9211_clock(); - return; + /* clock the data */ + toggle_Centaurus_9211_clock(); + return; -} /* end write_Centaurus_CX9211_GPIO() */ +} /* end write_Centaurus_CX9211_GPIO() */ /***************************************************************** * @@ -570,22 +571,22 @@ write_Centaurus_CX9211_GPIO(unsigned char databit) void write_Centaurus_CX9211_DWdata(unsigned long data) { - int count; + int count; - /* Send the read/write command to the 9211 first. */ + /* Send the read/write command to the 9211 first. */ - write_Centaurus_CX9211_GPIO(CENT_WRITE); + write_Centaurus_CX9211_GPIO(CENT_WRITE); - /* Now write the 32-bit Data */ - for (count = 0; count < 32; count++) { - write_Centaurus_CX9211_GPIO((unsigned char)(data & 0x01)); + /* Now write the 32-bit Data */ + for (count = 0; count < 32; count++) { + write_Centaurus_CX9211_GPIO((unsigned char) (data & 0x01)); - /* the 9211 expects the data LSB->MSB */ - data >>= 1; - } - return; + /* the 9211 expects the data LSB->MSB */ + data >>= 1; + } + return; -} /* end write_Centaurus_CX9211_DWdata() */ +} /* end write_Centaurus_CX9211_DWdata() */ /********************************************************************* * @@ -599,18 +600,18 @@ write_Centaurus_CX9211_DWdata(unsigned long data) unsigned char read_Centaurus_CX9211_GPIO(void) { - unsigned char data_port_val; + unsigned char data_port_val; - toggle_Centaurus_9211_clock(); + toggle_Centaurus_9211_clock(); - /* read the data */ - data_port_val = gfx_inb(CENT_97317_DATA_INPORT); + /* read the data */ + data_port_val = gfx_inb(CENT_97317_DATA_INPORT); - /* Save the data from (GPIO21) as bit 0 */ - data_port_val >>= 1; - return (data_port_val & 0x1); + /* Save the data from (GPIO21) as bit 0 */ + data_port_val >>= 1; + return (data_port_val & 0x1); -} /* end read_Centaurus_CX9211_GPIO() */ +} /* end read_Centaurus_CX9211_GPIO() */ /********************************************************************** * @@ -626,237 +627,238 @@ read_Centaurus_CX9211_GPIO(void) unsigned long read_Centaurus_CX9211_DWdata(void) { - unsigned char ReadData; - int count; - unsigned long Data; + unsigned char ReadData; + int count; + unsigned long Data; - /* Send read/write command word to the 9211 first. */ - write_Centaurus_CX9211_GPIO(CENT_READ); + /* Send read/write command word to the 9211 first. */ + write_Centaurus_CX9211_GPIO(CENT_READ); - /* The data book (revision 0.1) states 8 clock periods of no valid data. - * However, the data becomes valid on the eighth clock, making the eighth - * clock valid. Since read_Centaurus_GPIO() toggles the clock before - * reading, we will only toggle the clock 7 times here. - */ - for (count = 0; count < 7; count++) /* works */ - toggle_Centaurus_9211_clock(); + /* The data book (revision 0.1) states 8 clock periods of no valid data. + * However, the data becomes valid on the eighth clock, making the eighth + * clock valid. Since read_Centaurus_GPIO() toggles the clock before + * reading, we will only toggle the clock 7 times here. + */ + for (count = 0; count < 7; count++) /* works */ + toggle_Centaurus_9211_clock(); - /* Now read the 32-bit Data, bit by bit in a single loop. */ - Data = 0; - for (count = 0; count < 32; count++) { - ReadData = read_Centaurus_CX9211_GPIO(); - /* 9211 sends data LSB->MSB */ - Data = Data | (((unsigned long)ReadData) << count); - } /* end for() */ + /* Now read the 32-bit Data, bit by bit in a single loop. */ + Data = 0; + for (count = 0; count < 32; count++) { + ReadData = read_Centaurus_CX9211_GPIO(); + /* 9211 sends data LSB->MSB */ + Data = Data | (((unsigned long) ReadData) << count); + } /* end for() */ - return Data; + return Data; -} /* end read_Centaurus_CX9211_DWdata() */ +} /* end read_Centaurus_CX9211_DWdata() */ void Centaurus_Get_9211_Details(unsigned long flags, PPnl_PanelParams pParam) { - unsigned long PanelType; - int i; - - for (i = 0; i < 0x7fff; i++) { - } - - init_Centaurus_GPIO(); - - for (i = 0; i < 5; i++) - toggle_Centaurus_9211_clock(); - - if (flags & PNL_PANELCHIP) { - - PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x430); - PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x430); - if ((PanelType & 0xFFFF0000) == 0x92110000) { - - /* found 9211 */ - /* check the values for revision ID */ - if (PanelType >= 0x92110301) - pParam->PanelChip = PNL_9211_C; - else if ((PanelType >= 0x92110101) && (PanelType < 0x92110301)) - pParam->PanelChip = PNL_9211_A; - else - pParam->PanelChip = PNL_UNKNOWN_CHIP; - } else { /* no 9211 present */ - pParam->PanelChip = PNL_UNKNOWN_CHIP; - } - Pnl_Rev_ID = pParam->PanelChip; - } - /* if end */ - if ((pParam->PanelChip != PNL_UNKNOWN_CHIP) && (flags & PNL_PANELSTAT)) { - PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x438); - PanelType &= 0x00f8f8f8; - PanelType |= 0x00070000; - Centaurus_write_gpio(FOUR_BYTES, 0x438, PanelType); - PanelType = 0; - PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x434); - PanelType = (PanelType >> 8); - PanelType &= 0x7; - - switch (PanelType) { - case 0: - pParam->PanelStat.XRes = 800; - pParam->PanelStat.YRes = 600; - pParam->PanelStat.Depth = 18; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_TFT; - break; - case 1: - pParam->PanelStat.XRes = 640; - pParam->PanelStat.YRes = 480; - pParam->PanelStat.Depth = 8; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_SSTN; - break; - case 2: - pParam->PanelStat.XRes = 1024; - pParam->PanelStat.YRes = 768; - pParam->PanelStat.Depth = 18; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_TFT; - break; - case 3: - pParam->PanelStat.XRes = 640; - pParam->PanelStat.YRes = 480; - pParam->PanelStat.Depth = 16; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_DSTN; - break; - case 4: - pParam->PanelStat.XRes = 640; - pParam->PanelStat.YRes = 480; - pParam->PanelStat.Depth = 18; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_TFT; - break; - case 5: - pParam->PanelStat.XRes = 1024; - pParam->PanelStat.YRes = 768; - pParam->PanelStat.Depth = 24; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_DSTN; - break; - case 6: - pParam->PanelStat.XRes = 640; - pParam->PanelStat.YRes = 480; - pParam->PanelStat.Depth = 8; - pParam->PanelStat.MonoColor = PNL_MONO_PANEL; - pParam->PanelStat.Type = PNL_DSTN; - break; - case 7: - pParam->PanelStat.XRes = 800; - pParam->PanelStat.YRes = 600; - pParam->PanelStat.Depth = 16; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_DSTN; - break; - default: - break; - } - } + unsigned long PanelType; + int i; + + for (i = 0; i < 0x7fff; i++) { + } + + init_Centaurus_GPIO(); + + for (i = 0; i < 5; i++) + toggle_Centaurus_9211_clock(); + + if (flags & PNL_PANELCHIP) { + + PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x430); + PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x430); + if ((PanelType & 0xFFFF0000) == 0x92110000) { + + /* found 9211 */ + /* check the values for revision ID */ + if (PanelType >= 0x92110301) + pParam->PanelChip = PNL_9211_C; + else if ((PanelType >= 0x92110101) && (PanelType < 0x92110301)) + pParam->PanelChip = PNL_9211_A; + else + pParam->PanelChip = PNL_UNKNOWN_CHIP; + } + else { /* no 9211 present */ + pParam->PanelChip = PNL_UNKNOWN_CHIP; + } + Pnl_Rev_ID = pParam->PanelChip; + } + /* if end */ + if ((pParam->PanelChip != PNL_UNKNOWN_CHIP) && (flags & PNL_PANELSTAT)) { + PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x438); + PanelType &= 0x00f8f8f8; + PanelType |= 0x00070000; + Centaurus_write_gpio(FOUR_BYTES, 0x438, PanelType); + PanelType = 0; + PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x434); + PanelType = (PanelType >> 8); + PanelType &= 0x7; + + switch (PanelType) { + case 0: + pParam->PanelStat.XRes = 800; + pParam->PanelStat.YRes = 600; + pParam->PanelStat.Depth = 18; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_TFT; + break; + case 1: + pParam->PanelStat.XRes = 640; + pParam->PanelStat.YRes = 480; + pParam->PanelStat.Depth = 8; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_SSTN; + break; + case 2: + pParam->PanelStat.XRes = 1024; + pParam->PanelStat.YRes = 768; + pParam->PanelStat.Depth = 18; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_TFT; + break; + case 3: + pParam->PanelStat.XRes = 640; + pParam->PanelStat.YRes = 480; + pParam->PanelStat.Depth = 16; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_DSTN; + break; + case 4: + pParam->PanelStat.XRes = 640; + pParam->PanelStat.YRes = 480; + pParam->PanelStat.Depth = 18; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_TFT; + break; + case 5: + pParam->PanelStat.XRes = 1024; + pParam->PanelStat.YRes = 768; + pParam->PanelStat.Depth = 24; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_DSTN; + break; + case 6: + pParam->PanelStat.XRes = 640; + pParam->PanelStat.YRes = 480; + pParam->PanelStat.Depth = 8; + pParam->PanelStat.MonoColor = PNL_MONO_PANEL; + pParam->PanelStat.Type = PNL_DSTN; + break; + case 7: + pParam->PanelStat.XRes = 800; + pParam->PanelStat.YRes = 600; + pParam->PanelStat.Depth = 16; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_DSTN; + break; + default: + break; + } + } } void CentaurusProgramFRMload(void) { - unsigned long CentaurusFRMtable[] = { - 0x00000000, - 0x00000000, - 0x01000100, - 0x01000100, - 0x01010101, - 0x01010101, - 0x02081041, - 0x02081041, - 0x10111111, - 0x11111101, - 0x49249241, - 0x12412492, - 0x92244891, - 0x92244891, - 0x22252525, - 0x22252525, - 0x528294a5, - 0x2528494a, - 0x294a5295, - 0x294a5295, - 0x54a54a95, - 0x2952a52a, - 0x2a552a55, - 0x2a552a55, - 0x554aa955, - 0x2a9552aa, - 0x2aaa5555, - 0x2aaa5555, - 0x55555555, - 0x2aaaaaaa, - 0x55555555, - 0x55555555, - 0xaaaaaaab, - 0x55555555, - 0x5555aaab, - 0x5555aaab, - 0xaab556ab, - 0x556aad55, - 0x55ab55ab, - 0x55ab55ab, - 0xab5ab56b, - 0x56ad5ad5, - 0x56b5ad6b, - 0x56b5ad6b, - 0xad6d6b5b, - 0x5ad6b6b6, - 0x5b5b5b5b, - 0x5b5b5b5b, - 0x5F6db6db, - 0x5F6db6db, - 0xF776F776, - 0xF776F776, - 0xFBDEFBDE, - 0xFBDEFBDE, - 0x7eFFBFF7, - 0x7eFFBFF7, - 0xFF7FF7F7, - 0xFF7FF7F7, - 0xFF7FFF7F, - 0xFF7FFF7F, - 0xFFF7FFFF, - 0xFFF7FFFF, - 0xFFFFFFFF, - 0xFFFFFFFF, - }; - - unsigned char i; - unsigned short index; - unsigned long data; - - Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_INDEX, 0); - index = CS92xx_FRM_MEMORY_DATA; - for (i = 0; i < 64; i += 2) { - data = CentaurusFRMtable[i]; - Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, data); - data = CentaurusFRMtable[i + 1]; - Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, data); - } - - /* - * The first FRM location (64 bits) does not program correctly. - * This location always reads back with the last value programmed. - * ie. If 32 64-bit values are programmed, location 0 reads - * back as the 32nd If 30 locations are programmed, location 0 - * reads back as the 30th, etc. - * Fix this by re-writing location 0 after programming all 64 in - * the writeFRM loop in RevCFrmload() in CS9211. - */ - - Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_INDEX, 0); - Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, 0); - Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, 0); + unsigned long CentaurusFRMtable[] = { + 0x00000000, + 0x00000000, + 0x01000100, + 0x01000100, + 0x01010101, + 0x01010101, + 0x02081041, + 0x02081041, + 0x10111111, + 0x11111101, + 0x49249241, + 0x12412492, + 0x92244891, + 0x92244891, + 0x22252525, + 0x22252525, + 0x528294a5, + 0x2528494a, + 0x294a5295, + 0x294a5295, + 0x54a54a95, + 0x2952a52a, + 0x2a552a55, + 0x2a552a55, + 0x554aa955, + 0x2a9552aa, + 0x2aaa5555, + 0x2aaa5555, + 0x55555555, + 0x2aaaaaaa, + 0x55555555, + 0x55555555, + 0xaaaaaaab, + 0x55555555, + 0x5555aaab, + 0x5555aaab, + 0xaab556ab, + 0x556aad55, + 0x55ab55ab, + 0x55ab55ab, + 0xab5ab56b, + 0x56ad5ad5, + 0x56b5ad6b, + 0x56b5ad6b, + 0xad6d6b5b, + 0x5ad6b6b6, + 0x5b5b5b5b, + 0x5b5b5b5b, + 0x5F6db6db, + 0x5F6db6db, + 0xF776F776, + 0xF776F776, + 0xFBDEFBDE, + 0xFBDEFBDE, + 0x7eFFBFF7, + 0x7eFFBFF7, + 0xFF7FF7F7, + 0xFF7FF7F7, + 0xFF7FFF7F, + 0xFF7FFF7F, + 0xFFF7FFFF, + 0xFFF7FFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + }; + + unsigned char i; + unsigned short index; + unsigned long data; + + Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_INDEX, 0); + index = CS92xx_FRM_MEMORY_DATA; + for (i = 0; i < 64; i += 2) { + data = CentaurusFRMtable[i]; + Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, data); + data = CentaurusFRMtable[i + 1]; + Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, data); + } + + /* + * The first FRM location (64 bits) does not program correctly. + * This location always reads back with the last value programmed. + * ie. If 32 64-bit values are programmed, location 0 reads + * back as the 32nd If 30 locations are programmed, location 0 + * reads back as the 30th, etc. + * Fix this by re-writing location 0 after programming all 64 in + * the writeFRM loop in RevCFrmload() in CS9211. + */ + + Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_INDEX, 0); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, 0); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, 0); } /******************************************************************** @@ -870,12 +872,12 @@ CentaurusProgramFRMload(void) void Centaurus_Power_Up(void) { - unsigned long off_data = 0x01000000; + unsigned long off_data = 0x01000000; - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data); - return; + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data); + return; -} /* Centaurus_Disable_Power */ +} /* Centaurus_Disable_Power */ /*********************************************************************** * @@ -888,84 +890,84 @@ Centaurus_Power_Up(void) void Centaurus_Power_Down(void) { - unsigned long off_data = 0; + unsigned long off_data = 0; - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data); - return; + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data); + return; -} /* Centaurus_Disable_Power */ +} /* Centaurus_Disable_Power */ void Centaurus_9211init(Pnl_PanelStat * pstat) { - init_Centaurus_GPIO(); - init_Centaurus_9211(); - set_Centaurus_92xx_mode(pstat); - restore_Centaurus_97317_SIOC2(); + init_Centaurus_GPIO(); + init_Centaurus_9211(); + set_Centaurus_92xx_mode(pstat); + restore_Centaurus_97317_SIOC2(); } void Centaurus_Save_Panel_State(void) { - /* set 9211 registers using the desired panel settings */ - - cs9211_regs.panel_timing1 = - Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING1); - cs9211_regs.panel_timing2 = - Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING2); - cs9211_regs.dither_frc_ctrl = - Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_DITH_FR_CNTRL); - cs9211_regs.blue_lsfr_seed = - Centaurus_read_gpio(FOUR_BYTES, CS92xx_BLUE_LSFR_SEED); - - cs9211_regs.red_green_lsfr_seed = - Centaurus_read_gpio(FOUR_BYTES, CS92xx_RED_GREEN_LSFR_SEED); - /* CentaurusProgramFRMload(); */ - - cs9211_regs.memory_control = - Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL); - - /* Set the power register last. - * This will turn the panel on at the 9211. - */ - cs9211_regs.power_management = - Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN); + /* set 9211 registers using the desired panel settings */ + + cs9211_regs.panel_timing1 = + Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING1); + cs9211_regs.panel_timing2 = + Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING2); + cs9211_regs.dither_frc_ctrl = + Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_DITH_FR_CNTRL); + cs9211_regs.blue_lsfr_seed = + Centaurus_read_gpio(FOUR_BYTES, CS92xx_BLUE_LSFR_SEED); + + cs9211_regs.red_green_lsfr_seed = + Centaurus_read_gpio(FOUR_BYTES, CS92xx_RED_GREEN_LSFR_SEED); + /* CentaurusProgramFRMload(); */ + + cs9211_regs.memory_control = + Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL); + + /* Set the power register last. + * This will turn the panel on at the 9211. + */ + cs9211_regs.power_management = + Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN); } void Centaurus_Restore_Panel_State(void) { - unsigned long off_data = 0; + unsigned long off_data = 0; - /* Before restoring the 9211 registers, power off the 9211. */ - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data); + /* Before restoring the 9211 registers, power off the 9211. */ + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data); - /* set 9211 registers using the desired panel settings */ + /* set 9211 registers using the desired panel settings */ - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING1, - cs9211_regs.panel_timing1); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING1, + cs9211_regs.panel_timing1); - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING2, - cs9211_regs.panel_timing2); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING2, + cs9211_regs.panel_timing2); - /* load the LSFR seeds */ + /* load the LSFR seeds */ - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_DITH_FR_CNTRL, - cs9211_regs.dither_frc_ctrl); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_DITH_FR_CNTRL, + cs9211_regs.dither_frc_ctrl); - Centaurus_write_gpio(FOUR_BYTES, CS92xx_BLUE_LSFR_SEED, - cs9211_regs.blue_lsfr_seed); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_BLUE_LSFR_SEED, + cs9211_regs.blue_lsfr_seed); - Centaurus_write_gpio(FOUR_BYTES, CS92xx_RED_GREEN_LSFR_SEED, - cs9211_regs.red_green_lsfr_seed); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_RED_GREEN_LSFR_SEED, + cs9211_regs.red_green_lsfr_seed); - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL, - cs9211_regs.memory_control); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL, + cs9211_regs.memory_control); - /* Set the power register last. This will turn the panel on at the 9211. */ + /* Set the power register last. This will turn the panel on at the 9211. */ - Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, - cs9211_regs.power_management); + Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, + cs9211_regs.power_management); } diff --git a/src/panel/cen9211.h b/src/panel/cen9211.h index f3836c9..2c216cb 100644 --- a/src/panel/cen9211.h +++ b/src/panel/cen9211.h @@ -187,8 +187,7 @@ void disable_Centaurus_9211_chip_select(void); void toggle_Centaurus_9211_clock(void); void write_Centaurus_CX9211_GPIO(unsigned char databit); void write_Centaurus_CX9211_DWdata(unsigned long data); -void Centaurus_write_gpio(int width, unsigned long address, - unsigned long data); +void Centaurus_write_gpio(int width, unsigned long address, unsigned long data); void Centaurus_Power_Up(void); void Centaurus_Power_Down(void); unsigned long Centaurus_read_gpio(int width, unsigned long address); @@ -204,6 +203,6 @@ void Centaurus_Save_Panel_State(void); void Centaurus_Restore_Panel_State(void); void Centaurus_9211init(Pnl_PanelStat * pstat); -#endif /* !_CEN9211_h */ +#endif /* !_CEN9211_h */ /* END OF FILE */ diff --git a/src/panel/dora9211.c b/src/panel/dora9211.c index 020afe8..b914235 100644 --- a/src/panel/dora9211.c +++ b/src/panel/dora9211.c @@ -144,356 +144,358 @@ void Dorado_Get_9211_Details(unsigned long flags, PPnl_PanelParams pParam) { - unsigned long DPanelType; - int i; - - for (i = 0; i < 0x7fff; i++) { - } - - Dorado9211GpioInit(); - - for (i = 0; i < 5; i++) - toggle_Centaurus_9211_clock(); - - if (flags & PNL_PANELCHIP) { - DPanelType = Dorado9211ReadReg(0x430); - - if ((DPanelType & 0xFFFF0000) == 0x92110000) { /* found 9211 */ - /* check the values for revision ID */ - if (DPanelType >= 0x92110301) - pParam->PanelChip = PNL_9211_C; - else if ((DPanelType >= 0x92110101) && (DPanelType < 0x92110301)) - pParam->PanelChip = PNL_9211_A; - else - pParam->PanelChip = PNL_UNKNOWN_CHIP; - } else { /* no 9211 present */ - pParam->PanelChip = PNL_UNKNOWN_CHIP; - } - } - - if ((pParam->PanelChip != PNL_UNKNOWN_CHIP) && (flags & PNL_PANELSTAT)) { - unsigned long PanelTypeOrg; - unsigned char Panel_2Byte; - - DPanelType = Dorado9211ReadReg(0x438); - DPanelType &= 0x00e8e8e8; - DPanelType |= 0x00170000; - Dorado9211WriteReg(0x438, DPanelType); - DPanelType = 0; - - DPanelType = Dorado9211ReadReg(0x434); - DPanelType = (DPanelType >> (DRD_LCDRESGPIO1 + 1)); - PanelTypeOrg = DPanelType >> 8; - Panel_2Byte = (unsigned char)PanelTypeOrg; - Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO2 - DRD_LCDRESGPIO1 - 1)); - DPanelType = (DPanelType | ((unsigned int)Panel_2Byte << 8)); - DPanelType = DPanelType >> 1; - PanelTypeOrg = DPanelType >> 8; - Panel_2Byte = (unsigned char)PanelTypeOrg; - Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO3 - DRD_LCDRESGPIO2 - 1)); - DPanelType = (DPanelType | ((unsigned int)Panel_2Byte << 8)); - DPanelType = DPanelType >> 1; - PanelTypeOrg = DPanelType >> 8; - Panel_2Byte = (unsigned char)PanelTypeOrg; - Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO4 - DRD_LCDRESGPIO3 - 1)); - DPanelType = (DPanelType | ((unsigned int)Panel_2Byte << 8)); - DPanelType = DPanelType >> 5; - DPanelType &= 0xf; - - switch (DPanelType) { - case 8: - pParam->PanelStat.XRes = 800; - pParam->PanelStat.YRes = 600; - pParam->PanelStat.Depth = 18; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_TFT; - break; - - case 9: - pParam->PanelStat.XRes = 640; - pParam->PanelStat.YRes = 480; - pParam->PanelStat.Depth = 8; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_SSTN; - break; - - case 10: - pParam->PanelStat.XRes = 1024; - pParam->PanelStat.YRes = 768; - pParam->PanelStat.Depth = 18; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_TFT; - break; - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 11: - pParam->PanelStat.XRes = 640; - pParam->PanelStat.YRes = 480; - pParam->PanelStat.Depth = 16; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_DSTN; - break; - case 12: - pParam->PanelStat.XRes = 640; - pParam->PanelStat.YRes = 480; - pParam->PanelStat.Depth = 18; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_TFT; - break; - case 13: - pParam->PanelStat.XRes = 1024; - pParam->PanelStat.YRes = 768; - pParam->PanelStat.Depth = 24; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_DSTN; - break; - case 14: - pParam->PanelStat.XRes = 640; - pParam->PanelStat.YRes = 480; - pParam->PanelStat.Depth = 8; - pParam->PanelStat.MonoColor = PNL_MONO_PANEL; - pParam->PanelStat.Type = PNL_DSTN; - break; - case 15: - pParam->PanelStat.XRes = 800; - pParam->PanelStat.YRes = 600; - pParam->PanelStat.Depth = 16; - pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; - pParam->PanelStat.Type = PNL_DSTN; - break; - default: - break; - } - } - /* if block end */ + unsigned long DPanelType; + int i; + + for (i = 0; i < 0x7fff; i++) { + } + + Dorado9211GpioInit(); + + for (i = 0; i < 5; i++) + toggle_Centaurus_9211_clock(); + + if (flags & PNL_PANELCHIP) { + DPanelType = Dorado9211ReadReg(0x430); + + if ((DPanelType & 0xFFFF0000) == 0x92110000) { /* found 9211 */ + /* check the values for revision ID */ + if (DPanelType >= 0x92110301) + pParam->PanelChip = PNL_9211_C; + else if ((DPanelType >= 0x92110101) && (DPanelType < 0x92110301)) + pParam->PanelChip = PNL_9211_A; + else + pParam->PanelChip = PNL_UNKNOWN_CHIP; + } + else { /* no 9211 present */ + pParam->PanelChip = PNL_UNKNOWN_CHIP; + } + } + + if ((pParam->PanelChip != PNL_UNKNOWN_CHIP) && (flags & PNL_PANELSTAT)) { + unsigned long PanelTypeOrg; + unsigned char Panel_2Byte; + + DPanelType = Dorado9211ReadReg(0x438); + DPanelType &= 0x00e8e8e8; + DPanelType |= 0x00170000; + Dorado9211WriteReg(0x438, DPanelType); + DPanelType = 0; + + DPanelType = Dorado9211ReadReg(0x434); + DPanelType = (DPanelType >> (DRD_LCDRESGPIO1 + 1)); + PanelTypeOrg = DPanelType >> 8; + Panel_2Byte = (unsigned char) PanelTypeOrg; + Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO2 - DRD_LCDRESGPIO1 - 1)); + DPanelType = (DPanelType | ((unsigned int) Panel_2Byte << 8)); + DPanelType = DPanelType >> 1; + PanelTypeOrg = DPanelType >> 8; + Panel_2Byte = (unsigned char) PanelTypeOrg; + Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO3 - DRD_LCDRESGPIO2 - 1)); + DPanelType = (DPanelType | ((unsigned int) Panel_2Byte << 8)); + DPanelType = DPanelType >> 1; + PanelTypeOrg = DPanelType >> 8; + Panel_2Byte = (unsigned char) PanelTypeOrg; + Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO4 - DRD_LCDRESGPIO3 - 1)); + DPanelType = (DPanelType | ((unsigned int) Panel_2Byte << 8)); + DPanelType = DPanelType >> 5; + DPanelType &= 0xf; + + switch (DPanelType) { + case 8: + pParam->PanelStat.XRes = 800; + pParam->PanelStat.YRes = 600; + pParam->PanelStat.Depth = 18; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_TFT; + break; + + case 9: + pParam->PanelStat.XRes = 640; + pParam->PanelStat.YRes = 480; + pParam->PanelStat.Depth = 8; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_SSTN; + break; + + case 10: + pParam->PanelStat.XRes = 1024; + pParam->PanelStat.YRes = 768; + pParam->PanelStat.Depth = 18; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_TFT; + break; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 11: + pParam->PanelStat.XRes = 640; + pParam->PanelStat.YRes = 480; + pParam->PanelStat.Depth = 16; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_DSTN; + break; + case 12: + pParam->PanelStat.XRes = 640; + pParam->PanelStat.YRes = 480; + pParam->PanelStat.Depth = 18; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_TFT; + break; + case 13: + pParam->PanelStat.XRes = 1024; + pParam->PanelStat.YRes = 768; + pParam->PanelStat.Depth = 24; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_DSTN; + break; + case 14: + pParam->PanelStat.XRes = 640; + pParam->PanelStat.YRes = 480; + pParam->PanelStat.Depth = 8; + pParam->PanelStat.MonoColor = PNL_MONO_PANEL; + pParam->PanelStat.Type = PNL_DSTN; + break; + case 15: + pParam->PanelStat.XRes = 800; + pParam->PanelStat.YRes = 600; + pParam->PanelStat.Depth = 16; + pParam->PanelStat.MonoColor = PNL_COLOR_PANEL; + pParam->PanelStat.Type = PNL_DSTN; + break; + default: + break; + } + } + /* if block end */ } void Dorado9211Init(Pnl_PanelStat * pstat) { - int mode; - unsigned long orig_value, pm_value; - - gfx_delay_milliseconds(100); - Dorado9211GpioInit(); - - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - - gfx_delay_milliseconds(100); - - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - - Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x0); - - gfx_delay_milliseconds(100); - gfx_delay_milliseconds(100); - - /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ - for (mode = 0; mode < NUM_92XX_MODES; mode++) { - if ((FPModeParams[mode].xres == pstat->XRes) && - (FPModeParams[mode].yres == pstat->YRes) && - (FPModeParams[mode].bpp == pstat->Depth) && - (FPModeParams[mode].panel_type == pstat->Type) && - (FPModeParams[mode].color_type == pstat->MonoColor)) { - - /* SET THE 92xx FOR THE SELECTED MODE */ - CS92xx_MODE *pMode = &FPModeParams[mode]; - - Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING1, pMode->panel_timing1); - Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING2, pMode->panel_timing2); - Dorado9211WriteReg(CS92xx_LCD_DITH_FR_CNTRL, - pMode->rev_C_dither_frc); - Dorado9211WriteReg(CS92xx_BLUE_LSFR_SEED, pMode->blue_lsfr_seed); - Dorado9211WriteReg(CS92xx_RED_GREEN_LSFR_SEED, - pMode->red_green_lsfr_seed); - DoradoProgramFRMload(); - Dorado9211WriteReg(CS92xx_LCD_MEM_CNTRL, pMode->memory_control); - Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, pMode->power_management); - gfx_delay_milliseconds(100); - gfx_delay_milliseconds(100); - Dorado9211ClearCS(); - - /* This code is added to take care of Panel initialization. - * Irrespective of Xpressrom is enabling the panel or not. - */ - orig_value = READ_VID32(0X04); - WRITE_VID32(0x04, 0x00200141); - gfx_delay_milliseconds(21); - pm_value = gfx_ind(0x9030); - - pm_value |= 0x400; - gfx_outd(0x9030, pm_value); - gfx_delay_milliseconds(4); - orig_value &= 0xfff1ffff; - WRITE_VID32(0X4, orig_value); - return; - } /*end if() */ - } /*end for() */ + int mode; + unsigned long orig_value, pm_value; + + gfx_delay_milliseconds(100); + Dorado9211GpioInit(); + + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + + gfx_delay_milliseconds(100); + + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + + Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x0); + + gfx_delay_milliseconds(100); + gfx_delay_milliseconds(100); + + /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ + for (mode = 0; mode < NUM_92XX_MODES; mode++) { + if ((FPModeParams[mode].xres == pstat->XRes) && + (FPModeParams[mode].yres == pstat->YRes) && + (FPModeParams[mode].bpp == pstat->Depth) && + (FPModeParams[mode].panel_type == pstat->Type) && + (FPModeParams[mode].color_type == pstat->MonoColor)) { + + /* SET THE 92xx FOR THE SELECTED MODE */ + CS92xx_MODE *pMode = &FPModeParams[mode]; + + Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING1, pMode->panel_timing1); + Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING2, pMode->panel_timing2); + Dorado9211WriteReg(CS92xx_LCD_DITH_FR_CNTRL, + pMode->rev_C_dither_frc); + Dorado9211WriteReg(CS92xx_BLUE_LSFR_SEED, pMode->blue_lsfr_seed); + Dorado9211WriteReg(CS92xx_RED_GREEN_LSFR_SEED, + pMode->red_green_lsfr_seed); + DoradoProgramFRMload(); + Dorado9211WriteReg(CS92xx_LCD_MEM_CNTRL, pMode->memory_control); + Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, pMode->power_management); + gfx_delay_milliseconds(100); + gfx_delay_milliseconds(100); + Dorado9211ClearCS(); + + /* This code is added to take care of Panel initialization. + * Irrespective of Xpressrom is enabling the panel or not. + */ + orig_value = READ_VID32(0X04); + WRITE_VID32(0x04, 0x00200141); + gfx_delay_milliseconds(21); + pm_value = gfx_ind(0x9030); + + pm_value |= 0x400; + gfx_outd(0x9030, pm_value); + gfx_delay_milliseconds(4); + orig_value &= 0xfff1ffff; + WRITE_VID32(0X4, orig_value); + return; + } /*end if() */ + } /*end for() */ } void Dorado9211SetCS(void) { - unsigned long value; + unsigned long value; - value = gfx_ind(DRD_CSP9211IN); - gfx_outd(DRD_CSP9211OUT, value | DRD_CS9211); + value = gfx_ind(DRD_CSP9211IN); + gfx_outd(DRD_CSP9211OUT, value | DRD_CS9211); } void Dorado9211ClearCS(void) { - unsigned long value; + unsigned long value; - value = gfx_ind(DRD_CSP9211IN); - gfx_outd(DRD_CSP9211OUT, value & (~DRD_CS9211)); + value = gfx_ind(DRD_CSP9211IN); + gfx_outd(DRD_CSP9211OUT, value & (~DRD_CS9211)); } void Dorado9211SetDataOut(void) { - unsigned long value; + unsigned long value; - value = gfx_ind(DRD_DATAOUTP9211IN); - gfx_outd(DRD_DATAOUTP9211OUT, value | DRD_DATAIN9211); + value = gfx_ind(DRD_DATAOUTP9211IN); + gfx_outd(DRD_DATAOUTP9211OUT, value | DRD_DATAIN9211); } void Dorado9211ClearDataOut(void) { - unsigned long value; + unsigned long value; - value = gfx_ind(DRD_DATAOUTP9211IN); - gfx_outd(DRD_DATAOUTP9211OUT, value & (~DRD_DATAIN9211)); + value = gfx_ind(DRD_DATAOUTP9211IN); + gfx_outd(DRD_DATAOUTP9211OUT, value & (~DRD_DATAIN9211)); } unsigned char Dorado9211ReadDataIn(void) { - unsigned char readdata = 0; - unsigned long value; - - /* why to read 4 times ??? */ - value = gfx_ind(DRD_DATAINP9211IN); - value = gfx_ind(DRD_DATAINP9211IN); - value = gfx_ind(DRD_DATAINP9211IN); - value = gfx_ind(DRD_DATAINP9211IN); - if (value & DRD_DATAOUT9211) - readdata = 1; - return (readdata); + unsigned char readdata = 0; + unsigned long value; + + /* why to read 4 times ??? */ + value = gfx_ind(DRD_DATAINP9211IN); + value = gfx_ind(DRD_DATAINP9211IN); + value = gfx_ind(DRD_DATAINP9211IN); + value = gfx_ind(DRD_DATAINP9211IN); + if (value & DRD_DATAOUT9211) + readdata = 1; + return (readdata); } void Dorado9211ToggleClock(void) { - Dorado9211SetClock(); - Dorado9211ClearClock(); + Dorado9211SetClock(); + Dorado9211ClearClock(); } void Dorado9211SetClock(void) { - unsigned long value; + unsigned long value; - value = gfx_ind(DRD_CLOCKP9211IN); - gfx_outd(DRD_CLOCKP9211OUT, value | DRD_CLOCK9211); + value = gfx_ind(DRD_CLOCKP9211IN); + gfx_outd(DRD_CLOCKP9211OUT, value | DRD_CLOCK9211); } void Dorado9211ClearClock(void) { - unsigned long value; + unsigned long value; - value = gfx_ind(DRD_CLOCKP9211IN); - gfx_outd(DRD_CLOCKP9211OUT, value & (~DRD_CLOCK9211)); + value = gfx_ind(DRD_CLOCKP9211IN); + gfx_outd(DRD_CLOCKP9211OUT, value & (~DRD_CLOCK9211)); } void Dorado9211GpioInit(void) { - unsigned long value; - - /* set output enable on gpio 7, 9, 11 */ - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_CLOCK9211CFG); - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3); - /* set output enable on gpio 7, 9, 11 */ - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_CS9211CFG); - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3); - /* set output enable on gpio 7, 9, 18 */ - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_DATAIN9211CFG); - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3); - /* disable on gpio 11 - This is the output from the 9211 */ - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_DATAOUT9211CFG); - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 0); - /* Set all PINS low */ - value = gfx_ind(DRD_GEODE_GPIO_BASE + DRD_GEODE_GPDI0); - value &= ~(DRD_CS9211 | DRD_CLOCK9211 | DRD_DATAIN9211); - gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPDO0), value); + unsigned long value; + + /* set output enable on gpio 7, 9, 11 */ + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_CLOCK9211CFG); + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3); + /* set output enable on gpio 7, 9, 11 */ + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_CS9211CFG); + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3); + /* set output enable on gpio 7, 9, 18 */ + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_DATAIN9211CFG); + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3); + /* disable on gpio 11 - This is the output from the 9211 */ + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_DATAOUT9211CFG); + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 0); + /* Set all PINS low */ + value = gfx_ind(DRD_GEODE_GPIO_BASE + DRD_GEODE_GPDI0); + value &= ~(DRD_CS9211 | DRD_CLOCK9211 | DRD_DATAIN9211); + gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPDO0), value); } unsigned long Dorado9211ReadReg(unsigned short index) { - unsigned char i, readbit; - unsigned long data; + unsigned char i, readbit; + unsigned long data; - Dorado9211ClearDataOut(); + Dorado9211ClearDataOut(); - Dorado9211SetCS(); - Dorado9211ToggleClock(); + Dorado9211SetCS(); + Dorado9211ToggleClock(); - Dorado9211SetDataOut(); - Dorado9211ToggleClock(); + Dorado9211SetDataOut(); + Dorado9211ToggleClock(); - for (i = 0; i < 12; i++) { - if (index & 0x1) { - Dorado9211SetDataOut(); - } else { - Dorado9211ClearDataOut(); - } - Dorado9211ToggleClock(); - index >>= 1; - } + for (i = 0; i < 12; i++) { + if (index & 0x1) { + Dorado9211SetDataOut(); + } + else { + Dorado9211ClearDataOut(); + } + Dorado9211ToggleClock(); + index >>= 1; + } - Dorado9211ClearDataOut(); - Dorado9211ToggleClock(); + Dorado9211ClearDataOut(); + Dorado9211ToggleClock(); - /* Idle clock, 7 clocks, no data set */ + /* Idle clock, 7 clocks, no data set */ - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); - data = 0; - for (i = 0; i < 32; i++) { - Dorado9211ToggleClock(); - readbit = Dorado9211ReadDataIn(); - data |= (((unsigned long)readbit) << i); - } + data = 0; + for (i = 0; i < 32; i++) { + Dorado9211ToggleClock(); + readbit = Dorado9211ReadDataIn(); + data |= (((unsigned long) readbit) << i); + } - Dorado9211ClearCS(); - Dorado9211ToggleClock(); - return (data); + Dorado9211ClearCS(); + Dorado9211ToggleClock(); + return (data); } @@ -501,129 +503,131 @@ void Dorado9211WriteReg(unsigned short index, unsigned long data) { - unsigned char i; - - Dorado9211ClearDataOut(); - Dorado9211SetDataOut(); - Dorado9211SetCS(); - Dorado9211ToggleClock(); - Dorado9211SetDataOut(); - Dorado9211ToggleClock(); - - for (i = 0; i < 12; i++) { - if (index & 0x1) { - Dorado9211SetDataOut(); - } else { - Dorado9211ClearDataOut(); - } - Dorado9211ToggleClock(); - index >>= 1; - } - - Dorado9211SetDataOut(); - Dorado9211ToggleClock(); - - for (i = 0; i < 32; i++) { - if (data & 0x1) { - Dorado9211SetDataOut(); - } else { - Dorado9211ClearDataOut(); - } - Dorado9211ToggleClock(); - data >>= 1; - } - - Dorado9211ClearCS(); - - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); - Dorado9211ToggleClock(); + unsigned char i; + + Dorado9211ClearDataOut(); + Dorado9211SetDataOut(); + Dorado9211SetCS(); + Dorado9211ToggleClock(); + Dorado9211SetDataOut(); + Dorado9211ToggleClock(); + + for (i = 0; i < 12; i++) { + if (index & 0x1) { + Dorado9211SetDataOut(); + } + else { + Dorado9211ClearDataOut(); + } + Dorado9211ToggleClock(); + index >>= 1; + } + + Dorado9211SetDataOut(); + Dorado9211ToggleClock(); + + for (i = 0; i < 32; i++) { + if (data & 0x1) { + Dorado9211SetDataOut(); + } + else { + Dorado9211ClearDataOut(); + } + Dorado9211ToggleClock(); + data >>= 1; + } + + Dorado9211ClearCS(); + + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); + Dorado9211ToggleClock(); } void DoradoProgramFRMload(void) { - unsigned long DoradoFRMtable[] = { - - 0x00000000, - 0x00000000, - 0x01000100, - 0x01000100, - 0x01010101, - 0x01010101, - 0x02081041, - 0x02081041, - 0x10111111, - 0x11111101, - 0x49249241, - 0x12412492, - 0x92244891, - 0x92244891, - 0x22252525, - 0x22252525, - 0x528294a5, - 0x2528494a, - 0x294a5295, - 0x294a5295, - 0x54a54a95, - 0x2952a52a, - 0x2a552a55, - 0x2a552a55, - 0x554aa955, - 0x2a9552aa, - 0x2aaa5555, - 0x2aaa5555, - 0x55555555, - 0x2aaaaaaa, - 0x55555555, - 0x55555555, - 0xaaaaaaab, - 0x55555555, - 0x5555aaab, - 0x5555aaab, - 0xaab556ab, - 0x556aad55, - 0x55ab55ab, - 0x55ab55ab, - 0xab5ab56b, - 0x56ad5ad5, - 0x56b5ad6b, - 0x56b5ad6b, - 0xad6d6b5b, - 0x5ad6b6b6, - 0x5b5b5b5b, - 0x5b5b5b5b, - 0x5F6db6db, - 0x5F6db6db, - 0xF776F776, - 0xF776F776, - 0xFBDEFBDE, - 0xFBDEFBDE, - 0x7eFFBFF7, - 0x7eFFBFF7, - 0xFF7FF7F7, - 0xFF7FF7F7, - 0xFF7FFF7F, - 0xFF7FFF7F, - 0xFFF7FFFF, - 0xFFF7FFFF, - 0xFFFFFFFF, - 0xFFFFFFFF, - }; - - unsigned char i; - unsigned short index; - unsigned long data; - - Dorado9211WriteReg(CS92xx_FRM_MEMORY_INDEX, 0); - index = CS92xx_FRM_MEMORY_DATA; - for (i = 0; i < 64; i += 2) { - data = DoradoFRMtable[i]; - Dorado9211WriteReg(index, data); - data = DoradoFRMtable[i + 1]; - Dorado9211WriteReg(index, data); - } + unsigned long DoradoFRMtable[] = { + + 0x00000000, + 0x00000000, + 0x01000100, + 0x01000100, + 0x01010101, + 0x01010101, + 0x02081041, + 0x02081041, + 0x10111111, + 0x11111101, + 0x49249241, + 0x12412492, + 0x92244891, + 0x92244891, + 0x22252525, + 0x22252525, + 0x528294a5, + 0x2528494a, + 0x294a5295, + 0x294a5295, + 0x54a54a95, + 0x2952a52a, + 0x2a552a55, + 0x2a552a55, + 0x554aa955, + 0x2a9552aa, + 0x2aaa5555, + 0x2aaa5555, + 0x55555555, + 0x2aaaaaaa, + 0x55555555, + 0x55555555, + 0xaaaaaaab, + 0x55555555, + 0x5555aaab, + 0x5555aaab, + 0xaab556ab, + 0x556aad55, + 0x55ab55ab, + 0x55ab55ab, + 0xab5ab56b, + 0x56ad5ad5, + 0x56b5ad6b, + 0x56b5ad6b, + 0xad6d6b5b, + 0x5ad6b6b6, + 0x5b5b5b5b, + 0x5b5b5b5b, + 0x5F6db6db, + 0x5F6db6db, + 0xF776F776, + 0xF776F776, + 0xFBDEFBDE, + 0xFBDEFBDE, + 0x7eFFBFF7, + 0x7eFFBFF7, + 0xFF7FF7F7, + 0xFF7FF7F7, + 0xFF7FFF7F, + 0xFF7FFF7F, + 0xFFF7FFFF, + 0xFFF7FFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + }; + + unsigned char i; + unsigned short index; + unsigned long data; + + Dorado9211WriteReg(CS92xx_FRM_MEMORY_INDEX, 0); + index = CS92xx_FRM_MEMORY_DATA; + for (i = 0; i < 64; i += 2) { + data = DoradoFRMtable[i]; + Dorado9211WriteReg(index, data); + data = DoradoFRMtable[i + 1]; + Dorado9211WriteReg(index, data); + } /* * The first FRM location (64 bits) does not program correctly. @@ -634,9 +638,9 @@ DoradoProgramFRMload(void) * loop in RevCFrmload() in CS9211. */ - Dorado9211WriteReg(CS92xx_FRM_MEMORY_INDEX, 0); - Dorado9211WriteReg(CS92xx_FRM_MEMORY_DATA, 0); - Dorado9211WriteReg(CS92xx_FRM_MEMORY_DATA, 0); + Dorado9211WriteReg(CS92xx_FRM_MEMORY_INDEX, 0); + Dorado9211WriteReg(CS92xx_FRM_MEMORY_DATA, 0); + Dorado9211WriteReg(CS92xx_FRM_MEMORY_DATA, 0); } @@ -649,10 +653,10 @@ DoradoProgramFRMload(void) void Dorado_Power_Up(void) { - Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x01000000); - return; + Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x01000000); + return; -} /* disable_Centaurus_Power */ +} /* disable_Centaurus_Power */ /****************************************************************************** * void Dorado_Disable_Power((void); @@ -663,51 +667,51 @@ Dorado_Power_Up(void) void Dorado_Power_Down(void) { - Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x0); - return; + Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x0); + return; -} /* disable_Centaurus_Power */ +} /* disable_Centaurus_Power */ void Dorado_Save_Panel_State(void) { - /* set 9211 registers using the desired panel settings */ - cs9211_regs.panel_timing1 = Dorado9211ReadReg(CS92xx_LCD_PAN_TIMING1); - cs9211_regs.panel_timing2 = Dorado9211ReadReg(CS92xx_LCD_PAN_TIMING2); + /* set 9211 registers using the desired panel settings */ + cs9211_regs.panel_timing1 = Dorado9211ReadReg(CS92xx_LCD_PAN_TIMING1); + cs9211_regs.panel_timing2 = Dorado9211ReadReg(CS92xx_LCD_PAN_TIMING2); - cs9211_regs.dither_frc_ctrl = Dorado9211ReadReg(CS92xx_LCD_DITH_FR_CNTRL); - cs9211_regs.blue_lsfr_seed = Dorado9211ReadReg(CS92xx_BLUE_LSFR_SEED); - cs9211_regs.red_green_lsfr_seed = - Dorado9211ReadReg(CS92xx_RED_GREEN_LSFR_SEED); + cs9211_regs.dither_frc_ctrl = Dorado9211ReadReg(CS92xx_LCD_DITH_FR_CNTRL); + cs9211_regs.blue_lsfr_seed = Dorado9211ReadReg(CS92xx_BLUE_LSFR_SEED); + cs9211_regs.red_green_lsfr_seed = + Dorado9211ReadReg(CS92xx_RED_GREEN_LSFR_SEED); - /* CentaurusProgramFRMload(); */ - cs9211_regs.memory_control = Dorado9211ReadReg(CS92xx_LCD_MEM_CNTRL); + /* CentaurusProgramFRMload(); */ + cs9211_regs.memory_control = Dorado9211ReadReg(CS92xx_LCD_MEM_CNTRL); - /* Set the power register last. This will turn the panel on at the 9211. */ - cs9211_regs.power_management = Dorado9211ReadReg(CS92xx_LCD_PWR_MAN); - cs9211_regs.panel_state = cs9211_regs.power_management; + /* Set the power register last. This will turn the panel on at the 9211. */ + cs9211_regs.power_management = Dorado9211ReadReg(CS92xx_LCD_PWR_MAN); + cs9211_regs.panel_state = cs9211_regs.power_management; } void Dorado_Restore_Panel_State(void) { - unsigned long off_data = 0; + unsigned long off_data = 0; - /* Before restoring the 9211 registers, power off the 9211. */ + /* Before restoring the 9211 registers, power off the 9211. */ - Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, off_data); + Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, off_data); - /* set 9211 registers using the desired panel settings */ - Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING1, cs9211_regs.panel_timing1); - Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING2, cs9211_regs.panel_timing2); - /* load the LSFR seeds */ - Dorado9211WriteReg(CS92xx_LCD_DITH_FR_CNTRL, cs9211_regs.dither_frc_ctrl); - Dorado9211WriteReg(CS92xx_BLUE_LSFR_SEED, cs9211_regs.blue_lsfr_seed); - Dorado9211WriteReg(CS92xx_RED_GREEN_LSFR_SEED, - cs9211_regs.red_green_lsfr_seed); + /* set 9211 registers using the desired panel settings */ + Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING1, cs9211_regs.panel_timing1); + Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING2, cs9211_regs.panel_timing2); + /* load the LSFR seeds */ + Dorado9211WriteReg(CS92xx_LCD_DITH_FR_CNTRL, cs9211_regs.dither_frc_ctrl); + Dorado9211WriteReg(CS92xx_BLUE_LSFR_SEED, cs9211_regs.blue_lsfr_seed); + Dorado9211WriteReg(CS92xx_RED_GREEN_LSFR_SEED, + cs9211_regs.red_green_lsfr_seed); - Dorado9211WriteReg(CS92xx_LCD_MEM_CNTRL, cs9211_regs.memory_control); - /* Set the power register last. This will turn the panel on at the 9211. */ - Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, cs9211_regs.power_management); + Dorado9211WriteReg(CS92xx_LCD_MEM_CNTRL, cs9211_regs.memory_control); + /* Set the power register last. This will turn the panel on at the 9211. */ + Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, cs9211_regs.power_management); } diff --git a/src/panel/dora9211.h b/src/panel/dora9211.h index a215b86..fa05f48 100644 --- a/src/panel/dora9211.h +++ b/src/panel/dora9211.h @@ -144,13 +144,13 @@ /* GPIO Pin Configuration Registers */ -#define DRD_GEODE_GPPIN_SEL 0x20 /* GPIO Pin Configuration Select */ -#define DRD_GEODE_GPPIN_CFG 0x24 /* GPIO Pin Configuration Access */ -#define DRD_GEODE_GPPIN_RESET 0x28 /* GPIO Pin Reset */ +#define DRD_GEODE_GPPIN_SEL 0x20 /* GPIO Pin Configuration Select */ +#define DRD_GEODE_GPPIN_CFG 0x24 /* GPIO Pin Configuration Access */ +#define DRD_GEODE_GPPIN_RESET 0x28 /* GPIO Pin Reset */ -#define DRD_GEODE_GPIO_BASE 0x6400 /* F0 GPIO, IO mapped */ -#define DRD_GEODE_GPDI0 0x04 /* GPIO Data In 0 */ -#define DRD_GEODE_GPDO0 0x00 /* GPIO Data Out 0 */ +#define DRD_GEODE_GPIO_BASE 0x6400 /* F0 GPIO, IO mapped */ +#define DRD_GEODE_GPDI0 0x04 /* GPIO Data In 0 */ +#define DRD_GEODE_GPDO0 0x00 /* GPIO Data Out 0 */ /* Data Ports in */ #define DRD_CLOCKP9211IN DRD_GEODE_GPIO_BASE + DRD_GEODE_GPDI0 @@ -165,16 +165,16 @@ #define DRD_CSP9211OUT DRD_GEODE_GPIO_BASE + DRD_GEODE_GPDO0 /* Pin MASKS */ -#define DRD_CLOCK9211 0x00000080 /*;gpio 7, clock output to 9211 */ -#define DRD_DATAIN9211 0x00040000 /*;gpio 18, data output to 9211 */ -#define DRD_DATAOUT9211 0x00000800 /*;gpio 11, data input from 9211 */ -#define DRD_CS9211 0x00000200 /*;gpio 9, chip select output to 9211 */ +#define DRD_CLOCK9211 0x00000080 /*;gpio 7, clock output to 9211 */ +#define DRD_DATAIN9211 0x00040000 /*;gpio 18, data output to 9211 */ +#define DRD_DATAOUT9211 0x00000800 /*;gpio 11, data input from 9211 */ +#define DRD_CS9211 0x00000200 /*;gpio 9, chip select output to 9211 */ /* Gpio CFG values to select in */ -#define DRD_CLOCK9211CFG 0x00000007 /* ;gpio 7 */ -#define DRD_DATAIN9211CFG 0x00000012 /* ;gpio 18 */ -#define DRD_DATAOUT9211CFG 0x0000000B /* ;gpio 11 */ -#define DRD_CS9211CFG 0x00000009 /* ;gpio 9 */ +#define DRD_CLOCK9211CFG 0x00000007 /* ;gpio 7 */ +#define DRD_DATAIN9211CFG 0x00000012 /* ;gpio 18 */ +#define DRD_DATAOUT9211CFG 0x0000000B /* ;gpio 11 */ +#define DRD_CS9211CFG 0x00000009 /* ;gpio 9 */ #define DRD_LCDRESGPIO1 0x00 #define DRD_LCDRESGPIO2 0x01 @@ -200,4 +200,4 @@ void Dorado_Save_Panel_State(void); void Dorado_Restore_Panel_State(void); void Dorado9211Init(Pnl_PanelStat * pstat); -#endif /* !_DORA9211_h */ +#endif /* !_DORA9211_h */ diff --git a/src/panel/drac9210.c b/src/panel/drac9210.c index d0e108a..1f02b8f 100644 --- a/src/panel/drac9210.c +++ b/src/panel/drac9210.c @@ -141,12 +141,12 @@ #include "drac9210.h" -#define CS9210 0x40 /* Chip select pin */ +#define CS9210 0x40 /* Chip select pin */ /* 9210 on Draco */ -#define CLOCK9210 0x04 /* Clock pin */ -#define DATAIN9210 0x20 /* Data from 9210 */ -#define DATAOUT9210 0x80 /* Data to 9210 */ +#define CLOCK9210 0x04 /* Clock pin */ +#define DATAIN9210 0x20 /* Data from 9210 */ +#define DATAOUT9210 0x80 /* Data to 9210 */ static void DracoWriteData(unsigned char data); static void DracoReadData(unsigned char *data); @@ -163,602 +163,550 @@ static void Draco9210ToggleClock(void); void Draco9210Init(Pnl_PanelStat * pstat) { - unsigned char panelvalues[] = { - 0x2, 0x80, - 0x2, 0x24, - 0x03, 0x00, - 0xc0, 0x00, - 0xc1, 0x00, - 0xc2, 0x00, - 0xc3, 0x00, - 0xc4, 0x00, - 0xc5, 0x01, - 0xc6, 0xff, - 0xc7, 0xff, - 0xc8, 0x3, - 0xc9, 0xfe, - 0xca, 0x0, - 0xcb, 0x3f, - 0xcc, 0xc, - 0xcd, 0x1, - 0xce, 0xff, - 0xcf, 0xc1, - 0xd0, 0x0, - 0xd1, 0x7e, - 0xd2, 0x3, - 0xd3, 0xfe, - 0xd4, 0x3, - 0xd5, 0x81, - 0xd6, 0xfc, - 0xd7, 0x3f, - 0xd8, 0x14, - 0xd9, 0x1e, - 0xda, 0x0f, - 0xdb, 0xc7, - 0xdc, 0x29, - 0xdd, 0xe1, - 0xde, 0xf1, - 0xdf, 0xf9, - 0xe0, 0x2, - 0xe1, 0xe, - 0xe2, 0x1e, - 0xe3, 0x3e, - 0xe4, 0x04, - 0xe5, 0x71, - 0xe6, 0xe3, - 0xe7, 0xcf, - 0xe8, 0x1, - 0xe9, 0x86, - 0xea, 0x3c, - 0xeb, 0xf3, - 0xec, 0xa, - 0xed, 0x39, - 0xee, 0xc7, - 0xef, 0x3d, - - 0xf0, 0x14, - 0xf1, 0xc6, - 0xf2, 0x39, - 0xf3, 0xce, - 0xf4, 0x3, - 0xf5, 0x19, - 0xf6, 0xce, - 0xf7, 0x77, - 0xf8, 0x0, - 0xf9, 0x66, - 0xfa, 0x33, - 0xfb, 0xbb, - 0xfc, 0x2d, - 0xfd, 0x99, - 0xfe, 0xdd, - 0xff, 0xdd, - - 0x3, 0x1, - 0xc0, 0x2, - 0xc1, 0x22, - 0xc2, 0x66, - 0xc3, 0x66, - 0xc4, 0x0, - 0xc5, 0xcd, - 0xc6, 0x99, - 0xc7, 0xbb, - 0xc8, 0x5, - 0xc9, 0x32, - 0xca, 0x66, - 0xcb, 0xdd, - 0xcc, 0x1a, - 0xcd, 0x4d, - 0xce, 0x9b, - 0xcf, 0x6f, - 0xd0, 0x0, - 0xd1, 0x92, - 0xd2, 0x6d, - 0xd3, 0xb6, - 0xd4, 0x5, - 0xd5, 0x25, - 0xd6, 0xb6, - 0xd7, 0xdb, - 0xd8, 0x2, - 0xd9, 0x5a, - 0xda, 0x4b, - 0xdb, 0x6d, - 0xdc, 0x29, - 0xdd, 0xa5, - 0xde, 0xb5, - 0xdf, 0xb7, - 0xe0, 0x4, - 0xe1, 0x4a, - 0xe2, 0x5a, - 0xe3, 0xda, - 0xe4, 0x12, - 0xe5, 0x95, - 0xe6, 0xad, - 0xe7, 0x6f, - 0xe8, 0x1, - 0xe9, 0x2a, - 0xea, 0x56, - 0xeb, 0xb5, - 0xec, 0xe, - 0xed, 0x55, - 0xee, 0xab, - 0xef, 0x5f, - 0xf0, 0x0, - 0xf1, 0xaa, - 0xf2, 0x55, - 0xf3, 0xea, - 0xf4, 0x1, - 0xf5, 0x55, - 0xf6, 0xaa, - 0xf7, 0xbf, - 0xf8, 0x6, - 0xf9, 0xaa, - 0xfa, 0x55, - 0xfb, 0x55, - 0xfc, 0x39, - 0xfd, 0x55, - 0xfe, 0xff, - 0xff, 0xff, - - 0x3, 0x2, - 0xc0, 0x0, - 0xc1, 0x0, - 0xc2, 0xaa, - 0xc3, 0xaa, - 0xc4, 0x6, - 0xc5, 0xab, - 0xc6, 0x55, - 0xc7, 0x55, - 0xc8, 0x01, - 0xc9, 0x54, - 0xca, 0xaa, - 0xcb, 0xbf, - 0xcc, 0x8, - 0xcd, 0xab, - 0xce, 0x55, - 0xcf, 0xeb, - 0xd0, 0x6, - 0xd1, 0x54, - 0xd2, 0xab, - 0xd3, 0x5e, - 0xd4, 0x1, - 0xd5, 0x2b, - 0xd6, 0x56, - 0xd7, 0xb5, - 0xd8, 0x12, - 0xd9, 0x94, - 0xda, 0xad, - 0xdb, 0x6f, - 0xdc, 0x2d, - 0xdd, 0x4b, - 0xde, 0x5b, - 0xdf, 0xdb, - 0xe0, 0x0, - 0xe1, 0xa4, - 0xe2, 0xb4, - 0xe3, 0xb6, - 0xe4, 0x2, - 0xe5, 0x5b, - 0xe6, 0x4b, - 0xe7, 0x6d, - 0xe8, 0x5, - 0xe9, 0x24, - 0xea, 0xb6, - 0xeb, 0xdb, - 0xec, 0x8, - 0xed, 0x93, - 0xee, 0x6d, - 0xef, 0xb7, - 0xf0, 0x12, - 0xf1, 0x4c, - 0xf2, 0x9b, - 0xf3, 0x6e, - 0xf4, 0x5, - 0xf5, 0x33, - 0xf6, 0x66, - 0xf7, 0xdd, - 0xf8, 0x0, - 0xf9, 0xcc, - 0xfa, 0x99, - 0xfb, 0xbb, - 0xfc, 0x2b, - 0xfd, 0x33, - 0xfe, 0x77, - 0xff, 0x77, - - 0x3, 0x3, - 0xc0, 0x4, - 0xc1, 0x88, - 0xc2, 0xcc, - 0xc3, 0xcc, - 0xc4, 0x0, - 0xc5, 0x67, - 0xc6, 0x33, - 0xc7, 0xbb, - 0xc8, 0x3, - 0xc9, 0x18, - 0xca, 0xce, - 0xcb, 0x77, - 0xcc, 0x1c, - 0xcd, 0xc7, - 0xce, 0x39, - 0xcf, 0xcf, - - 0xd0, 0x2, - 0xd1, 0x38, - 0xd2, 0xc7, - 0xd3, 0x3c, - 0xd4, 0x1, - 0xd5, 0x87, - 0xd6, 0x3c, - 0xd7, 0xf3, - 0xd8, 0x4, - 0xd9, 0x70, - 0xda, 0xe3, - 0xdb, 0xcf, - 0xdc, 0x2b, - 0xdd, 0xf, - 0xde, 0x1f, - 0xdf, 0x3f, - 0xe0, 0x00, - 0xe1, 0xe0, - 0xe2, 0xf0, - 0xe3, 0xf8, - 0xe4, 0x14, - 0xe5, 0x1f, - 0xe6, 0xf, - 0xe7, 0xc7, - 0xe8, 0x3, - 0xe9, 0x80, - 0xea, 0xfc, - 0xeb, 0x3f, - 0xec, 0x8, - 0xed, 0x7f, - 0xee, 0x3, - 0xef, 0xff, - 0xf0, 0x4, - 0xf1, 0x0, - 0xf2, 0xff, - 0xf3, 0xc0, - 0xf4, 0x3, - 0xf5, 0xff, - 0xf6, 0x0, - 0xf7, 0x3f, - 0xf8, 0x0, - 0xf9, 0x0, - 0xfa, 0xff, - 0xfb, 0xff, - 0xfc, 0x3f, - 0xfd, 0xff, - 0xfe, 0xff, - 0xff, 0xff, - 0x3, 0x4, - - /* Setup the Diter to Pattern33 */ - 0x80, 0xdd, - 0x81, 0xdd, - 0x82, 0x33, - 0x83, 0x33, - 0x84, 0xdd, - 0x85, 0xdd, - 0x86, 0x33, - 0x87, 0x33, - 0x88, 0x33, - 0x89, 0x33, - 0x8a, 0x77, - 0x8b, 0x77, - 0x8c, 0x33, - 0x8d, 0x33, - 0x8e, 0x77, - 0x8f, 0x77, - 0x90, 0xdd, - 0x91, 0xdd, - 0x92, 0x33, - 0x93, 0x33, - 0x94, 0xdd, - 0x95, 0xdd, - 0x96, 0x33, - 0x97, 0x33, - 0x98, 0x33, - 0x99, 0x33, - 0x9a, 0x77, - 0x9b, 0x77, - 0x9c, 0x33, - 0x9d, 0x33, - 0x9e, 0x77, - 0x9f, 0x77, - - 0x4, 0x20, - 0x5, 0x3, - 0x6, 0x56, - 0x7, 0x2, - 0x8, 0x1c, - 0x9, 0x0, - 0xa, 0x26, - 0xb, 0x0, - 0xc, 0x15, - 0xd, 0x4, - 0xe, 0x50, - 0xf, 0x4, - 0x10, 0xfa, - 0x11, 0x0, - 0x12, 0xc8, - 0x13, 0x0, - 0x14, 0x31, - 0x15, 0x23, - 0x16, 0x0, - - /* Enable DSTN panel */ - 0x2, 0x64 - }; - unsigned char index, data; - int i; - - gfx_delay_milliseconds(100); - Draco9210GpioInit(); - Draco9210SetCS(); - Draco9210ToggleClock(); - Draco9210ToggleClock(); - Draco9210ToggleClock(); - Draco9210ToggleClock(); - Draco9210ClearCS(); - -#if defined(_WIN32) /* For Windows */ - for (i = 0; i < 10; i++) { - _asm { - out 0EDh, al} - } - -#elif defined(linux) /* Linux */ + unsigned char panelvalues[] = { + 0x2, 0x80, + 0x2, 0x24, + 0x03, 0x00, + 0xc0, 0x00, + 0xc1, 0x00, + 0xc2, 0x00, + 0xc3, 0x00, + 0xc4, 0x00, + 0xc5, 0x01, + 0xc6, 0xff, + 0xc7, 0xff, + 0xc8, 0x3, + 0xc9, 0xfe, + 0xca, 0x0, + 0xcb, 0x3f, + 0xcc, 0xc, + 0xcd, 0x1, + 0xce, 0xff, + 0xcf, 0xc1, + 0xd0, 0x0, + 0xd1, 0x7e, + 0xd2, 0x3, + 0xd3, 0xfe, + 0xd4, 0x3, + 0xd5, 0x81, + 0xd6, 0xfc, + 0xd7, 0x3f, + 0xd8, 0x14, + 0xd9, 0x1e, + 0xda, 0x0f, + 0xdb, 0xc7, + 0xdc, 0x29, + 0xdd, 0xe1, + 0xde, 0xf1, + 0xdf, 0xf9, + 0xe0, 0x2, + 0xe1, 0xe, + 0xe2, 0x1e, + 0xe3, 0x3e, + 0xe4, 0x04, + 0xe5, 0x71, + 0xe6, 0xe3, + 0xe7, 0xcf, + 0xe8, 0x1, + 0xe9, 0x86, + 0xea, 0x3c, + 0xeb, 0xf3, + 0xec, 0xa, + 0xed, 0x39, + 0xee, 0xc7, + 0xef, 0x3d, + + 0xf0, 0x14, + 0xf1, 0xc6, + 0xf2, 0x39, + 0xf3, 0xce, + 0xf4, 0x3, + 0xf5, 0x19, + 0xf6, 0xce, + 0xf7, 0x77, + 0xf8, 0x0, + 0xf9, 0x66, + 0xfa, 0x33, + 0xfb, 0xbb, + 0xfc, 0x2d, + 0xfd, 0x99, + 0xfe, 0xdd, + 0xff, 0xdd, + + 0x3, 0x1, + 0xc0, 0x2, + 0xc1, 0x22, + 0xc2, 0x66, + 0xc3, 0x66, + 0xc4, 0x0, + 0xc5, 0xcd, + 0xc6, 0x99, + 0xc7, 0xbb, + 0xc8, 0x5, + 0xc9, 0x32, + 0xca, 0x66, + 0xcb, 0xdd, + 0xcc, 0x1a, + 0xcd, 0x4d, + 0xce, 0x9b, + 0xcf, 0x6f, + 0xd0, 0x0, + 0xd1, 0x92, + 0xd2, 0x6d, + 0xd3, 0xb6, + 0xd4, 0x5, + 0xd5, 0x25, + 0xd6, 0xb6, + 0xd7, 0xdb, + 0xd8, 0x2, + 0xd9, 0x5a, + 0xda, 0x4b, + 0xdb, 0x6d, + 0xdc, 0x29, + 0xdd, 0xa5, + 0xde, 0xb5, + 0xdf, 0xb7, + 0xe0, 0x4, + 0xe1, 0x4a, + 0xe2, 0x5a, + 0xe3, 0xda, + 0xe4, 0x12, + 0xe5, 0x95, + 0xe6, 0xad, + 0xe7, 0x6f, + 0xe8, 0x1, + 0xe9, 0x2a, + 0xea, 0x56, + 0xeb, 0xb5, + 0xec, 0xe, + 0xed, 0x55, + 0xee, 0xab, + 0xef, 0x5f, + 0xf0, 0x0, + 0xf1, 0xaa, + 0xf2, 0x55, + 0xf3, 0xea, + 0xf4, 0x1, + 0xf5, 0x55, + 0xf6, 0xaa, + 0xf7, 0xbf, + 0xf8, 0x6, + 0xf9, 0xaa, + 0xfa, 0x55, + 0xfb, 0x55, + 0xfc, 0x39, + 0xfd, 0x55, + 0xfe, 0xff, + 0xff, 0xff, + + 0x3, 0x2, + 0xc0, 0x0, + 0xc1, 0x0, + 0xc2, 0xaa, + 0xc3, 0xaa, + 0xc4, 0x6, + 0xc5, 0xab, + 0xc6, 0x55, + 0xc7, 0x55, + 0xc8, 0x01, + 0xc9, 0x54, + 0xca, 0xaa, + 0xcb, 0xbf, + 0xcc, 0x8, + 0xcd, 0xab, + 0xce, 0x55, + 0xcf, 0xeb, + 0xd0, 0x6, + 0xd1, 0x54, + 0xd2, 0xab, + 0xd3, 0x5e, + 0xd4, 0x1, + 0xd5, 0x2b, + 0xd6, 0x56, + 0xd7, 0xb5, + 0xd8, 0x12, + 0xd9, 0x94, + 0xda, 0xad, + 0xdb, 0x6f, + 0xdc, 0x2d, + 0xdd, 0x4b, + 0xde, 0x5b, + 0xdf, 0xdb, + 0xe0, 0x0, + 0xe1, 0xa4, + 0xe2, 0xb4, + 0xe3, 0xb6, + 0xe4, 0x2, + 0xe5, 0x5b, + 0xe6, 0x4b, + 0xe7, 0x6d, + 0xe8, 0x5, + 0xe9, 0x24, + 0xea, 0xb6, + 0xeb, 0xdb, + 0xec, 0x8, + 0xed, 0x93, + 0xee, 0x6d, + 0xef, 0xb7, + 0xf0, 0x12, + 0xf1, 0x4c, + 0xf2, 0x9b, + 0xf3, 0x6e, + 0xf4, 0x5, + 0xf5, 0x33, + 0xf6, 0x66, + 0xf7, 0xdd, + 0xf8, 0x0, + 0xf9, 0xcc, + 0xfa, 0x99, + 0xfb, 0xbb, + 0xfc, 0x2b, + 0xfd, 0x33, + 0xfe, 0x77, + 0xff, 0x77, + + 0x3, 0x3, + 0xc0, 0x4, + 0xc1, 0x88, + 0xc2, 0xcc, + 0xc3, 0xcc, + 0xc4, 0x0, + 0xc5, 0x67, + 0xc6, 0x33, + 0xc7, 0xbb, + 0xc8, 0x3, + 0xc9, 0x18, + 0xca, 0xce, + 0xcb, 0x77, + 0xcc, 0x1c, + 0xcd, 0xc7, + 0xce, 0x39, + 0xcf, 0xcf, + + 0xd0, 0x2, + 0xd1, 0x38, + 0xd2, 0xc7, + 0xd3, 0x3c, + 0xd4, 0x1, + 0xd5, 0x87, + 0xd6, 0x3c, + 0xd7, 0xf3, + 0xd8, 0x4, + 0xd9, 0x70, + 0xda, 0xe3, + 0xdb, 0xcf, + 0xdc, 0x2b, + 0xdd, 0xf, + 0xde, 0x1f, + 0xdf, 0x3f, + 0xe0, 0x00, + 0xe1, 0xe0, + 0xe2, 0xf0, + 0xe3, 0xf8, + 0xe4, 0x14, + 0xe5, 0x1f, + 0xe6, 0xf, + 0xe7, 0xc7, + 0xe8, 0x3, + 0xe9, 0x80, + 0xea, 0xfc, + 0xeb, 0x3f, + 0xec, 0x8, + 0xed, 0x7f, + 0xee, 0x3, + 0xef, 0xff, + 0xf0, 0x4, + 0xf1, 0x0, + 0xf2, 0xff, + 0xf3, 0xc0, + 0xf4, 0x3, + 0xf5, 0xff, + 0xf6, 0x0, + 0xf7, 0x3f, + 0xf8, 0x0, + 0xf9, 0x0, + 0xfa, 0xff, + 0xfb, 0xff, + 0xfc, 0x3f, + 0xfd, 0xff, + 0xfe, 0xff, + 0xff, 0xff, + 0x3, 0x4, + + /* Setup the Diter to Pattern33 */ + 0x80, 0xdd, + 0x81, 0xdd, + 0x82, 0x33, + 0x83, 0x33, + 0x84, 0xdd, + 0x85, 0xdd, + 0x86, 0x33, + 0x87, 0x33, + 0x88, 0x33, + 0x89, 0x33, + 0x8a, 0x77, + 0x8b, 0x77, + 0x8c, 0x33, + 0x8d, 0x33, + 0x8e, 0x77, + 0x8f, 0x77, + 0x90, 0xdd, + 0x91, 0xdd, + 0x92, 0x33, + 0x93, 0x33, + 0x94, 0xdd, + 0x95, 0xdd, + 0x96, 0x33, + 0x97, 0x33, + 0x98, 0x33, + 0x99, 0x33, + 0x9a, 0x77, + 0x9b, 0x77, + 0x9c, 0x33, + 0x9d, 0x33, + 0x9e, 0x77, + 0x9f, 0x77, + + 0x4, 0x20, + 0x5, 0x3, + 0x6, 0x56, + 0x7, 0x2, + 0x8, 0x1c, + 0x9, 0x0, + 0xa, 0x26, + 0xb, 0x0, + 0xc, 0x15, + 0xd, 0x4, + 0xe, 0x50, + 0xf, 0x4, + 0x10, 0xfa, + 0x11, 0x0, + 0x12, 0xc8, + 0x13, 0x0, + 0x14, 0x31, + 0x15, 0x23, + 0x16, 0x0, + + /* Enable DSTN panel */ + 0x2, 0x64 + }; + unsigned char index, data; + int i; + + gfx_delay_milliseconds(100); + Draco9210GpioInit(); + Draco9210SetCS(); + Draco9210ToggleClock(); + Draco9210ToggleClock(); + Draco9210ToggleClock(); + Draco9210ToggleClock(); + Draco9210ClearCS(); + +#if defined(_WIN32) /* For Windows */ + for (i = 0; i < 10; i++) { + _asm { + out 0ED h, al} + } + +#elif defined(linux) /* Linux */ #endif - for (i = 0; i < 630; i += 2) { - index = panelvalues[i]; - data = panelvalues[i + 1]; - Draco9210WriteReg(index, data); - } + for (i = 0; i < 630; i += 2) { + index = panelvalues[i]; + data = panelvalues[i + 1]; + Draco9210WriteReg(index, data); + } } static void DracoWriteData(unsigned char data) { - int i; - unsigned char mask = 0x80, databit; - - for (i = 0; i < 8; i++) { - - databit = data & mask; - if (data & mask) { - Draco9210SetDataOut(); - } else { - Draco9210ClearDataOut(); - } - mask >>= 1; - Draco9210ToggleClock(); - } + int i; + unsigned char mask = 0x80, databit; + + for (i = 0; i < 8; i++) { + + databit = data & mask; + if (data & mask) { + Draco9210SetDataOut(); + } + else { + Draco9210ClearDataOut(); + } + mask >>= 1; + Draco9210ToggleClock(); + } } static void DracoReadData(unsigned char *data) { - int i; - unsigned char tmp = 0, readbit; - - Draco9210ClearDataOut(); - Draco9210ToggleClock(); - for (i = 0; i < 7; i++) { - readbit = Draco9210ReadDataIn(); - tmp |= (readbit & 0x1); - tmp <<= 1; - Draco9210ToggleClock(); - } - readbit = Draco9210ReadDataIn(); - tmp |= (readbit & 0x1); - *data = tmp; + int i; + unsigned char tmp = 0, readbit; + + Draco9210ClearDataOut(); + Draco9210ToggleClock(); + for (i = 0; i < 7; i++) { + readbit = Draco9210ReadDataIn(); + tmp |= (readbit & 0x1); + tmp <<= 1; + Draco9210ToggleClock(); + } + readbit = Draco9210ReadDataIn(); + tmp |= (readbit & 0x1); + *data = tmp; } -#if defined(_WIN32) /* For Windows */ +#if defined(_WIN32) /* For Windows */ void Draco9210GpioInit() { - _asm { - pushf - cli - mov dx, 0CF8h - mov eax, CX55x0_ID + 090h - out dx, eax - mov dx, 0CFCh - mov al, 0CFh - mov ah, 00h - out dx, ax - popf - } + _asm { + pushf + cli + mov dx, 0 CF8h + mov eax, CX55x0_ID + 090 h + out dx, eax + mov dx, 0 CFCh mov al, 0 CFh mov ah, 00 h out dx, ax popf} } void Draco9210SetCS() { - _asm { - pushf - ;Point to PCI address register - mov dx, 0CF8h - ;55 XX GPIO data register - mov eax, CX55x0_ID + 090h - out dx, eax - ;Point to PCI data register (CFCh) - mov dx, 0CFCh - - in ax, dx - and ah, 30h - mov ah, c92DataReg - or ah, CS9210 - mov c92DataReg, ah - out dx, ax - popf - } -} - -void + _asm { + pushf; + Point to PCI address register + mov dx, 0 CF8h; + 55 XX GPIO data register + mov eax, CX55x0_ID + 090 h out dx, eax; + Point to PCI data register (CFCh) +mov dx, 0 CFCh + in ax, dx + and ah, 30 h + mov ah, c92DataReg + or ah, CS9210 mov c92DataReg, ah out dx, ax popf}} void Draco9210ClearCS() { - _asm { - pushf - ;Point to PCI address register - mov dx, 0CF8h - ;55 XX GPIO data register - mov eax, CX55x0_ID + 090h - out dx, eax - ;Point to PCI data register (CFCh) - mov dx, 0CFCh - ;Set CS LOW - in ax, dx - mov ah, c92DataReg - and ah, NOT CS9210 - mov c92DataReg, ah - out dx, ax - popf - } -} - -void + _asm { + pushf; + Point to PCI address register + mov dx, 0 CF8h; + 55 XX GPIO data register + mov eax, CX55x0_ID + 090 h out dx, eax; + Point to PCI data register (CFCh) + mov dx, 0 CFCh; +Set CS LOW + in ax, dx + mov ah, c92DataReg + and ah, NOT CS9210 mov c92DataReg, ah out dx, ax popf}} void Draco9210SetDataOut() { - _asm { - pushf - ;Point to PCI address register - mov dx, 0CF8h - ;55 XX GPIO data register - mov eax, CX55x0_ID + 090h - out dx, eax - ;Point to PCI data register (CFCh) - mov dx, 0CFCh - ;Set DATA HIGH - in ax, dx - mov ah, c92DataReg - or ah, DATAOUT9210 - mov c92DataReg, ah - out dx, ax - popf - } -} - -void + _asm { + pushf; + Point to PCI address register + mov dx, 0 CF8h; + 55 XX GPIO data register + mov eax, CX55x0_ID + 090 h out dx, eax; + Point to PCI data register (CFCh) + mov dx, 0 CFCh; +Set DATA HIGH + in ax, dx + mov ah, c92DataReg + or ah, DATAOUT9210 mov c92DataReg, ah out dx, ax popf}} void Draco9210ClearDataOut() { - _asm { - pushf - ;Point to PCI address register - mov dx, 0CF8h - mov eax, CX55x0_ID + 090h; - ;55 XX GPIO data register - out dx, eax - ;Point to PCI data register (CFCh) - mov dx, 0CFCh - ;Set Data LOW - in ax, dx - mov ah, c92DataReg - and ah, NOT DATAOUT9210 - mov c92DataReg, ah - out dx, ax - popf - } -} - -unsigned char + _asm { + pushf; + Point to PCI address register + mov dx, 0 CF8h mov eax, CX55x0_ID + 090 h; + + ; + 55 XX GPIO data register + out dx, eax; + Point to PCI data register (CFCh) + mov dx, 0 CFCh; +Set Data LOW + in ax, dx + mov ah, c92DataReg + and ah, NOT DATAOUT9210 + mov c92DataReg, ah out dx, ax popf}} unsigned char Draco9210ReadDataIn() { - unsigned char readdata; - - _asm { - pushf - ;Point to PCI address register - mov dx, 0CF8h - ;55 XX GPIO data register - mov eax, CX55x0_ID + 090h - out dx, eax - ;Point to PCI data register (CFCh) - mov dx, 0FCh - - in ax, dx - ;Preserve just Data IN bit - and ah, DATAIN9210 - mov al, ah - cmp al, 0 - ;Is it LOW ? - je readDataLow - ;must be HIGH - mov al, 1 - readDataLow: - mov readdata, al - popf - } - return (readdata); + unsigned char readdata; + + _asm { + pushf; + Point to PCI address register + mov dx, 0 CF8h; + 55 XX GPIO data register + mov eax, CX55x0_ID + 090 h out dx, eax; + Point to PCI data register (CFCh) + mov dx, 0F Ch in ax, dx; + Preserve just Data IN bit and ah, DATAIN9210 mov al, ah cmp al, 0; + Is it LOW ? je readDataLow; + must be HIGH mov al, 1 readDataLow:mov readdata, al popf} return (readdata); } void Draco9210ToggleClock() { - _asm { - pushf - ;Point to PCI address register - mov dx, 0CF8h - ;55 XX GPIO data register - mov eax, CX55x0_ID + 090h - ;Point to PCI data register (CFCh) - out dx, eax - mov dx, 0CFCh - ;SET CLOCK - in ax, dx - mov ah, c92DataReg - or ah, CLOCK9210 - mov c92DataReg, ah - out dx, ax - out 0EDh, al /* IOPAUSE */ - ;Point to PCI address register - mov dx, 0CF8h - ;55 XX GPIO data register - mov eax, CX55x0_ID + 090h - out dx, eax - ;Point to PCI data register (CFCh) - mov dx, 0CFCh; - ;CLEAR CLOCK - in ax, dx - mov ah, c92DataReg - and ah, NOT CLOCK9210 - mov c92DataReg, ah - out dx, ax - popf - } -} - -#elif defined(linux) /* Linux */ + _asm { + pushf; + Point to PCI address register + mov dx, 0 CF8h; + 55 XX GPIO data register + mov eax, CX55x0_ID + 090 h; + Point to PCI data register (CFCh) + out dx, eax mov dx, 0 CFCh; + SET CLOCK in ax, dx mov ah, c92DataReg or ah, CLOCK9210 mov c92DataReg, ah out dx, ax out 0ED h, al /* IOPAUSE */ + ; + Point to PCI address register + mov dx, 0 CF8h; + 55 XX GPIO data register + mov eax, CX55x0_ID + 090 h out dx, eax; + Point to PCI data register (CFCh) + mov dx, 0 CFCh; + + ; +CLEAR CLOCK + in ax, dx + mov ah, c92DataReg + and ah, NOT CLOCK9210 mov c92DataReg, ah out dx, ax popf}} +#elif defined(linux) /* Linux */ void Draco9210GpioInit() { } + void Draco9210SetCS() { } + void Draco9210ClearCS() { } + void Draco9210SetDataOut() { } + void Draco9210ClearDataOut() { } + unsigned char Draco9210ReadDataIn() { } + void Draco9210ToggleClock() { @@ -769,52 +717,52 @@ Draco9210ToggleClock() unsigned char Draco9210ReadReg(unsigned char index) { - unsigned char data; - - Draco9210SetCS(); - Draco9210ToggleClock(); - Draco9210SetDataOut(); - Draco9210ToggleClock(); - Draco9210ClearDataOut(); - Draco9210ToggleClock(); - Draco9210ClearDataOut(); - Draco9210ToggleClock(); - Draco9210ClearDataOut(); - Draco9210ToggleClock(); - - DracoWriteData(index); - DracoReadData(&data); - - return (data); + unsigned char data; + + Draco9210SetCS(); + Draco9210ToggleClock(); + Draco9210SetDataOut(); + Draco9210ToggleClock(); + Draco9210ClearDataOut(); + Draco9210ToggleClock(); + Draco9210ClearDataOut(); + Draco9210ToggleClock(); + Draco9210ClearDataOut(); + Draco9210ToggleClock(); + + DracoWriteData(index); + DracoReadData(&data); + + return (data); } void Draco9210WriteReg(unsigned char index, unsigned char data) { - Draco9210SetCS(); - Draco9210ToggleClock(); + Draco9210SetCS(); + Draco9210ToggleClock(); - Draco9210SetDataOut(); - Draco9210ToggleClock(); + Draco9210SetDataOut(); + Draco9210ToggleClock(); - Draco9210ClearDataOut(); - Draco9210ToggleClock(); + Draco9210ClearDataOut(); + Draco9210ToggleClock(); - Draco9210ClearDataOut(); - Draco9210ToggleClock(); + Draco9210ClearDataOut(); + Draco9210ToggleClock(); - Draco9210SetDataOut(); - Draco9210ToggleClock(); + Draco9210SetDataOut(); + Draco9210ToggleClock(); - DracoWriteData(index); - DracoWriteData(data); + DracoWriteData(index); + DracoWriteData(data); - Draco9210ClearDataOut(); - Draco9210ToggleClock(); + Draco9210ClearDataOut(); + Draco9210ToggleClock(); - Draco9210ClearCS(); - Draco9210ToggleClock(); - Draco9210ToggleClock(); + Draco9210ClearCS(); + Draco9210ToggleClock(); + Draco9210ToggleClock(); } diff --git a/src/panel/drac9210.h b/src/panel/drac9210.h index ce4fceb..94a4f3e 100644 --- a/src/panel/drac9210.h +++ b/src/panel/drac9210.h @@ -269,6 +269,6 @@ #define _DRAC9210_h #define CX55x0_ID 0x80009000 static unsigned char c92DataReg = 0; -#endif /* !_DRAC9210_h */ +#endif /* !_DRAC9210_h */ /* END OF FILE */ diff --git a/src/panel/gx2_9211.c b/src/panel/gx2_9211.c index 71909f8..87d5a87 100644 --- a/src/panel/gx2_9211.c +++ b/src/panel/gx2_9211.c @@ -133,13 +133,13 @@ #include "gx2_9211.h" #include "pnl_defs.h" -#if defined(_WIN32) /*windows */ +#if defined(_WIN32) /*windows */ #include "gfx_defs.h" extern DEV_STATUS gfx_msr_read(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue); + Q_WORD * msrValue); extern DEV_STATUS gfx_msr_write(unsigned int device, unsigned int msrRegister, - Q_WORD * msrValue); + Q_WORD * msrValue); #endif static unsigned long FPBaseAddr; @@ -148,7 +148,7 @@ void SetFPBaseAddr(unsigned long addr) { - FPBaseAddr = addr; + FPBaseAddr = addr; } /**************************************************************************** @@ -170,45 +170,45 @@ SetFPBaseAddr(unsigned long addr) ****************************************************************************/ void protected_mode_access(unsigned long mode, - unsigned long width, unsigned long addr, char *pdata) + unsigned long width, unsigned long addr, char *pdata) { - void *ptr = (void *)(FPBaseAddr + addr); - - /* type specific buffer pointers */ - char *byte_data = (char *)pdata; - unsigned long *word_data = (unsigned long *)pdata; - unsigned long *dword_data = (unsigned long *)pdata; - - if (mode == GX2_READ) { - switch (width) { - case FOUR_BYTES: - *(dword_data) = (unsigned long)(*(unsigned long *)ptr); - break; - case TWO_BYTES: - *(word_data) = (unsigned long)(*(unsigned long *)ptr); - break; - default: - *(byte_data) = (char)(*(char *)ptr); - break; - } - } /* end GX2_READ */ - else if (mode == GX2_WRITE) { - switch (width) { - case FOUR_BYTES: - *(unsigned long *)ptr = *dword_data; - break; - case TWO_BYTES: - *(unsigned long *)ptr = *word_data; - break; - default: - *(char *)ptr = *byte_data; - break; - } /* end switch(mode) */ - } - /* end case GX2_WRITE */ - return; - -} /* End of protected_mode_access. */ + void *ptr = (void *) (FPBaseAddr + addr); + + /* type specific buffer pointers */ + char *byte_data = (char *) pdata; + unsigned long *word_data = (unsigned long *) pdata; + unsigned long *dword_data = (unsigned long *) pdata; + + if (mode == GX2_READ) { + switch (width) { + case FOUR_BYTES: + *(dword_data) = (unsigned long) (*(unsigned long *) ptr); + break; + case TWO_BYTES: + *(word_data) = (unsigned long) (*(unsigned long *) ptr); + break; + default: + *(byte_data) = (char) (*(char *) ptr); + break; + } + } /* end GX2_READ */ + else if (mode == GX2_WRITE) { + switch (width) { + case FOUR_BYTES: + *(unsigned long *) ptr = *dword_data; + break; + case TWO_BYTES: + *(unsigned long *) ptr = *word_data; + break; + default: + *(char *) ptr = *byte_data; + break; + } /* end switch(mode) */ + } + /* end case GX2_WRITE */ + return; + +} /* End of protected_mode_access. */ /************************************************************************* * void write_video_reg64_low( unsigned long offset, unsigned long value ) @@ -220,9 +220,9 @@ protected_mode_access(unsigned long mode, void write_video_reg64_low(unsigned long offset, unsigned long value) { - protected_mode_access(GX2_WRITE, FOUR_BYTES, - FPBaseAddr + offset, (char *)&value); -} /*end write_video_reg64_low() */ + protected_mode_access(GX2_WRITE, FOUR_BYTES, + FPBaseAddr + offset, (char *) &value); +} /*end write_video_reg64_low() */ /************************************************************************* * unsigned long read_video_reg64_low( unsigned long offset ) @@ -234,12 +234,12 @@ write_video_reg64_low(unsigned long offset, unsigned long value) unsigned long read_video_reg64_low(unsigned long offset) { - unsigned long data; + unsigned long data; - protected_mode_access(GX2_READ, FOUR_BYTES, - FPBaseAddr + offset, (char *)&data); - return (data); -} /*end read_video_reg64_low() */ + protected_mode_access(GX2_READ, FOUR_BYTES, + FPBaseAddr + offset, (char *) &data); + return (data); +} /*end read_video_reg64_low() */ /******************************************************************************* * void Redcloud_fp_reg( int mode, unsigned long address, unsigned long *data ) @@ -260,13 +260,14 @@ read_video_reg64_low(unsigned long offset) void Redcloud_fp_reg(int mode, unsigned long address, unsigned long *data) { - if (mode == GX2_READ) { - *data = read_video_reg64_low(address); - } else { - write_video_reg64_low(address, *data); - } + if (mode == GX2_READ) { + *data = read_video_reg64_low(address); + } + else { + write_video_reg64_low(address, *data); + } -} /* End of Redcloud_fp_reg() */ +} /* End of Redcloud_fp_reg() */ /*------------------------------------------------------------------- * @@ -278,66 +279,68 @@ Redcloud_fp_reg(int mode, unsigned long address, unsigned long *data) void set_Redcloud_92xx_mode_params(int mode) { - CS92xx_MODE *pMode = &FPModeParams[mode]; - unsigned long temp_data = 0; - unsigned long base_data; - Q_WORD msrValue; - - /* on a Redcloud, we need to set up the DF pad select MSR */ - if (gfx_msr_read(RC_ID_DF, GX2_VP_MSR_PAD_SELECT, &msrValue) == FOUND) { - msrValue.low &= ~GX2_VP_PAD_SELECT_MASK; - if (pMode->panel_type == PNL_TFT || pMode->panel_type == PNL_TWOP) { - msrValue.low = GX2_VP_PAD_SELECT_TFT; - } else { - msrValue.low = GX2_VP_PAD_SELECT_DSTN; - } - gfx_msr_write(RC_ID_DF, GX2_VP_MSR_PAD_SELECT, &msrValue); - } - - /* Turn the 92xx power off before setting any new parameters. */ - temp_data = pMode->power_management & ~GX2_FP_PM_PWR_ON; - Redcloud_fp_reg(GX2_WRITE, GX2_FP_PWR_MAN, (unsigned long *)&temp_data); - - /* Set 9211 registers using the desired panel settings */ - - Redcloud_fp_reg(GX2_WRITE, GX2_FP_PAN_TIMING1, - (unsigned long *)&pMode->panel_timing1); - - /* On Redcloud, bit 31 is now reserved. */ - temp_data = pMode->panel_timing2 & 0x7FFFFFFF; - Redcloud_fp_reg(GX2_WRITE, GX2_FP_PAN_TIMING2, - (unsigned long *)&temp_data); - - /* On Redcloud TFT parts, set this to 0x70 so all 8 bits per color run - * thru fp crc but only non-TFT parts. Otherwise, set it to be 0x50. - * (source: Larry G.). - */ - if (pMode->panel_type == PNL_TFT || pMode->panel_type == PNL_TWOP) { - temp_data = GX2_FP_CRC_PASS_THRU_MASK; - } else { - temp_data = pMode->rev_C_dither_frc; - } - Redcloud_fp_reg(GX2_WRITE, GX2_FP_DITH_FR_CNTRL, - (unsigned long *)&temp_data); - Redcloud_fp_reg(GX2_WRITE, GX2_FP_BLFSR, - (unsigned long *)&pMode->blue_lsfr_seed); - Redcloud_fp_reg(GX2_WRITE, GX2_FP_RLFSR, - (unsigned long *)&pMode->red_green_lsfr_seed); - - /* Set the memory information, then the power register last. - * This will turn the panel on at the 9211. - */ - - Redcloud_fp_reg(GX2_READ, GX2_FP_FBB, (unsigned long *)&base_data); - if (base_data != 0x41780000) { - base_data = 0x41780000; - Redcloud_fp_reg(GX2_WRITE, GX2_FP_FBB, (unsigned long *)&base_data); - } - - Redcloud_fp_reg(GX2_WRITE, GX2_FP_PWR_MAN, - (unsigned long *)&pMode->power_management); - -} /*end set_92xx_mode_params() */ + CS92xx_MODE *pMode = &FPModeParams[mode]; + unsigned long temp_data = 0; + unsigned long base_data; + Q_WORD msrValue; + + /* on a Redcloud, we need to set up the DF pad select MSR */ + if (gfx_msr_read(RC_ID_DF, GX2_VP_MSR_PAD_SELECT, &msrValue) == FOUND) { + msrValue.low &= ~GX2_VP_PAD_SELECT_MASK; + if (pMode->panel_type == PNL_TFT || pMode->panel_type == PNL_TWOP) { + msrValue.low = GX2_VP_PAD_SELECT_TFT; + } + else { + msrValue.low = GX2_VP_PAD_SELECT_DSTN; + } + gfx_msr_write(RC_ID_DF, GX2_VP_MSR_PAD_SELECT, &msrValue); + } + + /* Turn the 92xx power off before setting any new parameters. */ + temp_data = pMode->power_management & ~GX2_FP_PM_PWR_ON; + Redcloud_fp_reg(GX2_WRITE, GX2_FP_PWR_MAN, (unsigned long *) &temp_data); + + /* Set 9211 registers using the desired panel settings */ + + Redcloud_fp_reg(GX2_WRITE, GX2_FP_PAN_TIMING1, + (unsigned long *) &pMode->panel_timing1); + + /* On Redcloud, bit 31 is now reserved. */ + temp_data = pMode->panel_timing2 & 0x7FFFFFFF; + Redcloud_fp_reg(GX2_WRITE, GX2_FP_PAN_TIMING2, + (unsigned long *) &temp_data); + + /* On Redcloud TFT parts, set this to 0x70 so all 8 bits per color run + * thru fp crc but only non-TFT parts. Otherwise, set it to be 0x50. + * (source: Larry G.). + */ + if (pMode->panel_type == PNL_TFT || pMode->panel_type == PNL_TWOP) { + temp_data = GX2_FP_CRC_PASS_THRU_MASK; + } + else { + temp_data = pMode->rev_C_dither_frc; + } + Redcloud_fp_reg(GX2_WRITE, GX2_FP_DITH_FR_CNTRL, + (unsigned long *) &temp_data); + Redcloud_fp_reg(GX2_WRITE, GX2_FP_BLFSR, + (unsigned long *) &pMode->blue_lsfr_seed); + Redcloud_fp_reg(GX2_WRITE, GX2_FP_RLFSR, + (unsigned long *) &pMode->red_green_lsfr_seed); + + /* Set the memory information, then the power register last. + * This will turn the panel on at the 9211. + */ + + Redcloud_fp_reg(GX2_READ, GX2_FP_FBB, (unsigned long *) &base_data); + if (base_data != 0x41780000) { + base_data = 0x41780000; + Redcloud_fp_reg(GX2_WRITE, GX2_FP_FBB, (unsigned long *) &base_data); + } + + Redcloud_fp_reg(GX2_WRITE, GX2_FP_PWR_MAN, + (unsigned long *) &pMode->power_management); + +} /*end set_92xx_mode_params() */ /* ----------------------------------------------------------------------- * @@ -353,30 +356,30 @@ set_Redcloud_92xx_mode_params(int mode) unsigned char set_Redcloud_92xx_mode(Pnl_PanelStat * pstat) { - int mode; + int mode; - /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ + /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */ - for (mode = 0; mode < NUM_92XX_MODES; mode++) { - if ((FPModeParams[mode].xres == pstat->XRes) && - (FPModeParams[mode].yres == pstat->YRes) && - (FPModeParams[mode].bpp == pstat->Depth) && - (FPModeParams[mode].panel_type == pstat->Type) && - (FPModeParams[mode].color_type == pstat->MonoColor)) { + for (mode = 0; mode < NUM_92XX_MODES; mode++) { + if ((FPModeParams[mode].xres == pstat->XRes) && + (FPModeParams[mode].yres == pstat->YRes) && + (FPModeParams[mode].bpp == pstat->Depth) && + (FPModeParams[mode].panel_type == pstat->Type) && + (FPModeParams[mode].color_type == pstat->MonoColor)) { - /* SET THE 92xx FOR THE SELECTED MODE */ - set_Redcloud_92xx_mode_params(mode); - return TRUE; - } /* end if() */ - } /* end for() */ - return FALSE; + /* SET THE 92xx FOR THE SELECTED MODE */ + set_Redcloud_92xx_mode_params(mode); + return TRUE; + } /* end if() */ + } /* end for() */ + return FALSE; -} /* end set_Centaurus_92xx_mode() */ +} /* end set_Centaurus_92xx_mode() */ void Redcloud_9211init(Pnl_PanelStat * pstat) { - set_Redcloud_92xx_mode(pstat); + set_Redcloud_92xx_mode(pstat); } diff --git a/src/panel/gx2_9211.h b/src/panel/gx2_9211.h index a545cb1..3a51279 100644 --- a/src/panel/gx2_9211.h +++ b/src/panel/gx2_9211.h @@ -144,50 +144,50 @@ */ #define GX2_FP_LCD_OFFSET 0x00000400 -#define CS9211_REDCLOUD 0x0400 /* Moved 9211 Rev C3 up to next major no. */ - -#define GX2_FP_PAN_TIMING1 0x0400 /* FP timings 1 */ -#define GX2_FP_PAN_TIMING2 0x0408 /* FP timings 2 */ -#define GX2_FP_PWR_MAN 0x0410 /* FP power management */ -#define GX2_FP_DITH_FR_CNTRL 0x0418 /* FP dither and frame rate */ -#define GX2_FP_BLFSR 0x0420 /* Blue LFSR seed */ -#define GX2_FP_RLFSR 0x0428 /* Red and Green LFSR seed */ -#define GX2_FP_FMI 0x0430 /* FRM Memory Index */ -#define GX2_FP_FMD 0x0438 /* FRM Memory Data */ -#define GX2_FP_DCA 0x0448 /* Dither ram control and address */ -#define GX2_FP_DMD 0x0450 /* Dither memory data */ -#define GX2_FP_PAN_CRC_SIG 0x0458 /* FP CRC signature */ -#define GX2_FP_FBB 0x0460 /* Frame Buffer Base Address */ +#define CS9211_REDCLOUD 0x0400 /* Moved 9211 Rev C3 up to next major no. */ + +#define GX2_FP_PAN_TIMING1 0x0400 /* FP timings 1 */ +#define GX2_FP_PAN_TIMING2 0x0408 /* FP timings 2 */ +#define GX2_FP_PWR_MAN 0x0410 /* FP power management */ +#define GX2_FP_DITH_FR_CNTRL 0x0418 /* FP dither and frame rate */ +#define GX2_FP_BLFSR 0x0420 /* Blue LFSR seed */ +#define GX2_FP_RLFSR 0x0428 /* Red and Green LFSR seed */ +#define GX2_FP_FMI 0x0430 /* FRM Memory Index */ +#define GX2_FP_FMD 0x0438 /* FRM Memory Data */ +#define GX2_FP_DCA 0x0448 /* Dither ram control and address */ +#define GX2_FP_DMD 0x0450 /* Dither memory data */ +#define GX2_FP_PAN_CRC_SIG 0x0458 /* FP CRC signature */ +#define GX2_FP_FBB 0x0460 /* Frame Buffer Base Address */ /* GX2_FP_PAN_TIMING2 bits */ -#define GX2_FP_TFT_PASS_THRU 0x40000000 /* TFT pass through enable */ -#define GX2_FP_PT2_PIX_OUT_MASK 0xFFF8FFFF /* panel output bit formats */ -#define GX2_FP_PT2_PIX_OUT_TFT 0x00000000 /* 8 BIT DSTN or TFT panel */ -#define GX2_FP_PT2_COLOR_MONO 0x00080000 /* color or monochrome */ -#define GX2_FP_PT2_DSTN_TFT_MASK 0xFFCFFFFF /* panel type bits */ -#define GX2_FP_PT2_DSTN_TFT_TFT 0x00100000 /* TFT panel */ -#define GX2_FP_PT2_PSH_CLK_CTL 0x08000000 /* shift clock retrace activity control */ +#define GX2_FP_TFT_PASS_THRU 0x40000000 /* TFT pass through enable */ +#define GX2_FP_PT2_PIX_OUT_MASK 0xFFF8FFFF /* panel output bit formats */ +#define GX2_FP_PT2_PIX_OUT_TFT 0x00000000 /* 8 BIT DSTN or TFT panel */ +#define GX2_FP_PT2_COLOR_MONO 0x00080000 /* color or monochrome */ +#define GX2_FP_PT2_DSTN_TFT_MASK 0xFFCFFFFF /* panel type bits */ +#define GX2_FP_PT2_DSTN_TFT_TFT 0x00100000 /* TFT panel */ +#define GX2_FP_PT2_PSH_CLK_CTL 0x08000000 /* shift clock retrace activity control */ /* GX2_FP_PWR_MAN bits */ -#define GX2_FP_PM_SHFCLK_INVERT 0x00002000 /* Invert shfclk to panel */ -#define GX2_FP_PM_VSYNC_DELAY 0x0000C000 /* Vert Sync delay */ -#define GX2_FP_PM_HSYNC_DELAY 0x00030000 /* Horiz Sync delay */ -#define GX2_FP_PM_PWRDN_PHASE_BIT0 0x00040000 /* panel power down phase bit 0 */ -#define GX2_FP_PM_PWRDN_PHASE_BIT1 0x00080000 /* panel power down phase bit 1 */ -#define GX2_FP_PM_PWRDN_PHASE_BIT2 0x00100000 /* panel power down phase bit 2 */ -#define GX2_FP_PM_PWRUP_PHASE_BIT0 0x00200000 /* panel power up phase bit 0 */ -#define GX2_FP_PM_PWRUP_PHASE_BIT1 0x00400000 /* panel power up phase bit 1 */ -#define GX2_FP_PM_PWRUP_PHASE_BIT2 0x00800000 /* panel power up phase bit 2 */ -#define GX2_FP_PM_PWR_ON 0x01000000 /* panel power ON */ -#define GX2_FP_PM_DIS_OFF_CTL 0x02000000 /* disable the panel back light */ -#define GX2_FP_PM_EXT_PWR_SEQ 0x08000000 /* external power sequence */ +#define GX2_FP_PM_SHFCLK_INVERT 0x00002000 /* Invert shfclk to panel */ +#define GX2_FP_PM_VSYNC_DELAY 0x0000C000 /* Vert Sync delay */ +#define GX2_FP_PM_HSYNC_DELAY 0x00030000 /* Horiz Sync delay */ +#define GX2_FP_PM_PWRDN_PHASE_BIT0 0x00040000 /* panel power down phase bit 0 */ +#define GX2_FP_PM_PWRDN_PHASE_BIT1 0x00080000 /* panel power down phase bit 1 */ +#define GX2_FP_PM_PWRDN_PHASE_BIT2 0x00100000 /* panel power down phase bit 2 */ +#define GX2_FP_PM_PWRUP_PHASE_BIT0 0x00200000 /* panel power up phase bit 0 */ +#define GX2_FP_PM_PWRUP_PHASE_BIT1 0x00400000 /* panel power up phase bit 1 */ +#define GX2_FP_PM_PWRUP_PHASE_BIT2 0x00800000 /* panel power up phase bit 2 */ +#define GX2_FP_PM_PWR_ON 0x01000000 /* panel power ON */ +#define GX2_FP_PM_DIS_OFF_CTL 0x02000000 /* disable the panel back light */ +#define GX2_FP_PM_EXT_PWR_SEQ 0x08000000 /* external power sequence */ /* GX2_FP_PAN_CRC_SIG bits */ -#define GX2_FP_PAN_CRC_SIGE 0x00000001 /* CRC Sig Enable */ -#define GX2_FP_PAN_CRC_SFR 0x00000002 /* CRC Sig Free Run */ +#define GX2_FP_PAN_CRC_SIGE 0x00000001 /* CRC Sig Enable */ +#define GX2_FP_PAN_CRC_SFR 0x00000002 /* CRC Sig Free Run */ /* This define is used by the hardware CRC mechanism */ #define GX2_FP_CRC_PASS_THRU_MASK 0x00000070 @@ -198,8 +198,8 @@ void SetFPBaseAddr(unsigned long); void Redcloud_9211init(Pnl_PanelStat *); void protected_mode_access(unsigned long mode, - unsigned long width, - unsigned long addr, char *pdata); + unsigned long width, + unsigned long addr, char *pdata); void write_video_reg64_low(unsigned long offset, unsigned long value); unsigned long read_video_reg64_low(unsigned long offset); void Redcloud_fp_reg(int mode, unsigned long address, unsigned long *data); diff --git a/src/panel/panel.c b/src/panel/panel.c index 1349d31..5b9cbe9 100644 --- a/src/panel/panel.c +++ b/src/panel/panel.c @@ -148,11 +148,11 @@ extern unsigned char *gfx_virt_vidptr; extern unsigned char *gfx_virt_vipptr; extern unsigned long gfx_detect_video(void); -#define PLATFORM_DYNAMIC 1 /* runtime selection */ -#define PLATFORM_DRACO 1 /* Draco + 9210 */ -#define PLATFORM_CENTAURUS 1 /* Centaurus + 9211 RevA */ -#define PLATFORM_DORADO 1 /* Dorado + 9211 RevC */ -#define PLATFORM_REDCLOUD 1 /* GX2 */ +#define PLATFORM_DYNAMIC 1 /* runtime selection */ +#define PLATFORM_DRACO 1 /* Draco + 9210 */ +#define PLATFORM_CENTAURUS 1 /* Centaurus + 9211 RevA */ +#define PLATFORM_DORADO 1 /* Dorado + 9211 RevC */ +#define PLATFORM_REDCLOUD 1 /* GX2 */ unsigned char *XpressROMPtr; diff --git a/src/panel/panel.h b/src/panel/panel.h index e8d36dd..5d7ba9d 100644 --- a/src/panel/panel.h +++ b/src/panel/panel.h @@ -148,43 +148,40 @@ #include "pnl_defs.h" #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif /* CLOSE BRACKET FOR C++ COMPLILATION */ - void Pnl_SetPlatform(int platform); - int Pnl_GetPlatform(void); - int Pnl_IsPanelPresent(void); - void Pnl_SetPanelPresent(int present); - void Pnl_SetPanelChip(int panelChip); - int Pnl_GetPanelChip(void); - void Pnl_SetPanelParam(PPnl_PanelParams pParam); - void Pnl_GetPanelParam(PPnl_PanelParams pParam); - int Pnl_InitPanel(PPnl_PanelParams pParam); - int Detect_Platform(void); - void Pnl_SavePanelState(void); - void Pnl_RestorePanelState(void); - void Pnl_PowerUp(void); - void Pnl_PowerDown(void); + void Pnl_SetPlatform(int platform); + int Pnl_GetPlatform(void); + int Pnl_IsPanelPresent(void); + void Pnl_SetPanelPresent(int present); + void Pnl_SetPanelChip(int panelChip); + int Pnl_GetPanelChip(void); + void Pnl_SetPanelParam(PPnl_PanelParams pParam); + void Pnl_GetPanelParam(PPnl_PanelParams pParam); + int Pnl_InitPanel(PPnl_PanelParams pParam); + int Detect_Platform(void); + void Pnl_SavePanelState(void); + void Pnl_RestorePanelState(void); + void Pnl_PowerUp(void); + void Pnl_PowerDown(void); - int Pnl_IsPanelEnabledInBIOS(void); - void Pnl_GetPanelInfoFromBIOS(int *xres, int *yres, int *bpp, int *hz); + int Pnl_IsPanelEnabledInBIOS(void); + void Pnl_GetPanelInfoFromBIOS(int *xres, int *yres, int *bpp, int *hz); /* from durango */ -#if defined(_WIN32) /* windows */ - extern void gfx_delay_milliseconds(unsigned long milliseconds); - extern unsigned long gfx_ind(unsigned short port); - extern void gfx_outd(unsigned short port, unsigned long data); - extern unsigned char gfx_inb(unsigned short port); - extern void gfx_outb(unsigned short port, unsigned char data); +#if defined(_WIN32) /* windows */ + extern void gfx_delay_milliseconds(unsigned long milliseconds); + extern unsigned long gfx_ind(unsigned short port); + extern void gfx_outd(unsigned short port, unsigned long data); + extern unsigned char gfx_inb(unsigned short port); + extern void gfx_outb(unsigned short port, unsigned char data); #endif #ifdef __cplusplus } #endif - -#endif /* !_panel_h */ - +#endif /* !_panel_h */ /* END OF FILE */ diff --git a/src/panel/platform.c b/src/panel/platform.c index 68c64d2..33d268d 100644 --- a/src/panel/platform.c +++ b/src/panel/platform.c @@ -155,12 +155,10 @@ #define PLT_READ_DWORDS 7 #define PLT_UNKNOWN ((SYS_BOARD) 0xFFFF) -typedef struct -{ - char sys_board_name[SYS_BOARD_NAME_LEN]; - SYS_BOARD sys_board; -} -SYS_BOARD_INFO; +typedef struct { + char sys_board_name[SYS_BOARD_NAME_LEN]; + SYS_BOARD sys_board; +} SYS_BOARD_INFO; static SYS_BOARD_INFO Sys_info; @@ -173,15 +171,15 @@ static SYS_BOARD_INFO Sys_info; */ SYS_BOARD_INFO Sys_board_info_array[] = { - {"Marmot", MARMOT_PLATFORM}, - {"Unicorn", UNICORN_PLATFORM}, - {"Centaurus", CENTAURUS_PLATFORM}, - {"Aries", ARIES_PLATFORM}, - {"Carmel", CARMEL_PLATFORM}, - {"Hyrda", HYDRA_PLATFORM}, - {"Dorado", DORADO_PLATFORM}, - {"Redcloud", REDCLOUD_PLATFORM}, - {"Other", OTHER_PLATFORM} + {"Marmot", MARMOT_PLATFORM}, + {"Unicorn", UNICORN_PLATFORM}, + {"Centaurus", CENTAURUS_PLATFORM}, + {"Aries", ARIES_PLATFORM}, + {"Carmel", CARMEL_PLATFORM}, + {"Hyrda", HYDRA_PLATFORM}, + {"Dorado", DORADO_PLATFORM}, + {"Redcloud", REDCLOUD_PLATFORM}, + {"Other", OTHER_PLATFORM} }; #define NUM_SYS_BOARD_TYPES sizeof(Sys_board_info_array)/sizeof(SYS_BOARD_INFO) @@ -195,62 +193,65 @@ static unsigned char get_sys_board_type(SYS_BOARD_INFO *, SYS_BOARD_INFO *); int Detect_Platform(void) { - /* See if we can find the board name using Xpressrom */ - if (get_sys_board_type(&Sys_info, Sys_board_array_base) == TRUE) { + /* See if we can find the board name using Xpressrom */ + if (get_sys_board_type(&Sys_info, Sys_board_array_base) == TRUE) { #if 0 - if (Sys_info.sys_board == CENTAURUS_PLATFORM) { - printk("CENTAURUS Platform Found\n"); - } else if (Sys_info.sys_board == DORADO_PLATFORM) { - printk("DORADO Platform Found \n"); - } else { - printk("UNKNOWN Platform Found \n"); - } + if (Sys_info.sys_board == CENTAURUS_PLATFORM) { + printk("CENTAURUS Platform Found\n"); + } + else if (Sys_info.sys_board == DORADO_PLATFORM) { + printk("DORADO Platform Found \n"); + } + else { + printk("UNKNOWN Platform Found \n"); + } #endif - } + } - return (Sys_info.sys_board); + return (Sys_info.sys_board); } static int Strncmp(char *str1, char *str2, int len) { - int i; - - if ((str1 == 0x0) || (str2 == 0x0) || (len == 0)) - return (1); - for (i = 0; i < len; i++) { - if (*(str1 + i) > *(str2 + i)) { - return 1; - } else if (*(str1 + i) < *(str2 + i)) { - return -1; - } - } - return 0; + int i; + + if ((str1 == 0x0) || (str2 == 0x0) || (len == 0)) + return (1); + for (i = 0; i < len; i++) { + if (*(str1 + i) > *(str2 + i)) { + return 1; + } + else if (*(str1 + i) < *(str2 + i)) { + return -1; + } + } + return 0; } static char * Strcpy(char *dst, char *src) { - int i; - - if ((dst == 0x0) || (src == 0x0)) - return (0); - for (i = 0; src[i] != 0x0; i++) { - dst[i] = src[i]; - } - dst[i] = 0x0; /* NULL termination */ - return dst; + int i; + + if ((dst == 0x0) || (src == 0x0)) + return (0); + for (i = 0; src[i] != 0x0; i++) { + dst[i] = src[i]; + } + dst[i] = 0x0; /* NULL termination */ + return dst; } static int Strlen(char *str) { - int i; + int i; - if (str == 0x0) - return 0; - for (i = 0; str[i] != 0x0; i++) ; - return i; + if (str == 0x0) + return 0; + for (i = 0; str[i] != 0x0; i++); + return i; } /***********************************************************************/ @@ -270,37 +271,37 @@ Strlen(char *str) int FindStringInSeg(unsigned int segment_address, char *string_ptr) { - int string_length = Strlen(string_ptr); - char *psegment_buf; - unsigned long mem_ptr = (unsigned long)segment_address << 16; - char segment_buffer[SEGMENT_LENGTH + 1]; - int i, cursor = 0; - - /* silence compiler */ - (void)cursor; - (void)mem_ptr; - (void)segment_buffer; - - psegment_buf = (char *)XpressROMPtr; - - /* Now search for the first character of the string_ptr */ - for (i = 0; i < SEGMENT_LENGTH + 1; i++) { - if (*(psegment_buf + i) == *string_ptr) { - - /* If we match the first character, do a - * string compare. - */ - - if (!Strncmp(string_ptr, (psegment_buf + i), string_length)) { - /* They match! */ - return (1); - } - } - } - /* if we got this far we didn't find anything. Return NULL. */ - return (0); - -} /* end FindStringInSeg() */ + int string_length = Strlen(string_ptr); + char *psegment_buf; + unsigned long mem_ptr = (unsigned long) segment_address << 16; + char segment_buffer[SEGMENT_LENGTH + 1]; + int i, cursor = 0; + + /* silence compiler */ + (void) cursor; + (void) mem_ptr; + (void) segment_buffer; + + psegment_buf = (char *) XpressROMPtr; + + /* Now search for the first character of the string_ptr */ + for (i = 0; i < SEGMENT_LENGTH + 1; i++) { + if (*(psegment_buf + i) == *string_ptr) { + + /* If we match the first character, do a + * string compare. + */ + + if (!Strncmp(string_ptr, (psegment_buf + i), string_length)) { + /* They match! */ + return (1); + } + } + } + /* if we got this far we didn't find anything. Return NULL. */ + return (0); + +} /* end FindStringInSeg() */ /********************************************************************** @@ -319,42 +320,44 @@ FindStringInSeg(unsigned int segment_address, char *string_ptr) static unsigned char get_sys_board_type(SYS_BOARD_INFO * sys_info, - SYS_BOARD_INFO * sys_board_array_base) + SYS_BOARD_INFO * sys_board_array_base) { - int index; - char *xpress_rom_string_ptr = "XpressStart"; - unsigned int segment = LINUX_ROM_SEGMENT; - - /* See if XpressStart is present in the BIOS area. - * If it is, search for a board string. If not, Xpressrom is - * not present, set system_board information to UNKNOWN and - * return FALSE. - */ - - if (!FindStringInSeg(segment, xpress_rom_string_ptr)) { - sys_info->sys_board = PLT_UNKNOWN; - Strcpy(sys_info->sys_board_name, "Unknown"); - return (FALSE); - } else { - - /* we have Xpressrom, so look for a board */ - for (index = 0; index < Num_sys_board_type; index++) { - if (!FindStringInSeg(segment, (sys_board_array_base + - index)->sys_board_name)) { - continue; - } else { - - /* a match!! */ - sys_info->sys_board = (sys_board_array_base + index)->sys_board; - Strcpy(sys_info->sys_board_name, - (sys_board_array_base + index)->sys_board_name); - return (TRUE); - } - } /* end for() */ - } /* end else */ - - /* if we are here we have failed */ - sys_info->sys_board = PLT_UNKNOWN; - Strcpy(sys_info->sys_board_name, "Unknown"); - return (FALSE); -} /* end get_sys_board_type() */ + int index; + char *xpress_rom_string_ptr = "XpressStart"; + unsigned int segment = LINUX_ROM_SEGMENT; + + /* See if XpressStart is present in the BIOS area. + * If it is, search for a board string. If not, Xpressrom is + * not present, set system_board information to UNKNOWN and + * return FALSE. + */ + + if (!FindStringInSeg(segment, xpress_rom_string_ptr)) { + sys_info->sys_board = PLT_UNKNOWN; + Strcpy(sys_info->sys_board_name, "Unknown"); + return (FALSE); + } + else { + + /* we have Xpressrom, so look for a board */ + for (index = 0; index < Num_sys_board_type; index++) { + if (!FindStringInSeg(segment, (sys_board_array_base + + index)->sys_board_name)) { + continue; + } + else { + + /* a match!! */ + sys_info->sys_board = (sys_board_array_base + index)->sys_board; + Strcpy(sys_info->sys_board_name, + (sys_board_array_base + index)->sys_board_name); + return (TRUE); + } + } /* end for() */ + } /* end else */ + + /* if we are here we have failed */ + sys_info->sys_board = PLT_UNKNOWN; + Strcpy(sys_info->sys_board_name, "Unknown"); + return (FALSE); +} /* end get_sys_board_type() */ diff --git a/src/panel/pnl_bios.c b/src/panel/pnl_bios.c index a7ba861..6d44002 100644 --- a/src/panel/pnl_bios.c +++ b/src/panel/pnl_bios.c @@ -141,7 +141,7 @@ #include "panel.h" -#if defined(_WIN32) /* windows */ +#if defined(_WIN32) /* windows */ extern unsigned long gfx_cpu_version; extern void gfx_outw(unsigned short port, unsigned short data); extern unsigned short gfx_inw(unsigned short port); @@ -156,56 +156,56 @@ extern unsigned short gfx_inw(unsigned short port); #define VR_INDEX 0xAC1C #define VR_DATA 0xAC1E #define VR_UNLOCK 0xFC53 -#define VRC_VG 0x0002 /* SoftVG Virtual Register Class */ -#define VG_MEM_SIZE 0x0000 /* MemSize Virtual Register */ +#define VRC_VG 0x0002 /* SoftVG Virtual Register Class */ +#define VG_MEM_SIZE 0x0000 /* MemSize Virtual Register */ #define FP_DETECT_MASK 0x8000 -#define VG_FP_TYPE 0x0002 /* Flat Panel Info Virtual Register */ +#define VG_FP_TYPE 0x0002 /* Flat Panel Info Virtual Register */ -#define FP_DEV_MASK 0x0003 /* Flat Panel type */ -#define FP_TYPE_SSTN 0x0000 /* SSTN panel type value */ -#define FP_TYPE_DSTN 0x0001 /* DSTN panel type value */ -#define FP_TYPE_TFT 0x0002 /* TFT panel type value */ -#define FP_TYPE_LVDS 0x0003 /* LVDS panel type value */ +#define FP_DEV_MASK 0x0003 /* Flat Panel type */ +#define FP_TYPE_SSTN 0x0000 /* SSTN panel type value */ +#define FP_TYPE_DSTN 0x0001 /* DSTN panel type value */ +#define FP_TYPE_TFT 0x0002 /* TFT panel type value */ +#define FP_TYPE_LVDS 0x0003 /* LVDS panel type value */ #define FP_RESOLUTION_MASK 0x0038 -#define FP_RES_6X4 0x0000 /* 640x480 resolution value */ -#define FP_RES_8X6 0x0008 /* 800x600 resolution value */ -#define FP_RES_10X7 0x0010 /* 1024x768 resolution value */ -#define FP_RES_12X10 0x0018 /* 1280x1024 resolution value */ -#define FP_RES_16X12 0x0020 /* 1600x1200 resolution value */ +#define FP_RES_6X4 0x0000 /* 640x480 resolution value */ +#define FP_RES_8X6 0x0008 /* 800x600 resolution value */ +#define FP_RES_10X7 0x0010 /* 1024x768 resolution value */ +#define FP_RES_12X10 0x0018 /* 1280x1024 resolution value */ +#define FP_RES_16X12 0x0020 /* 1600x1200 resolution value */ #define FP_WIDTH_MASK 0x01C0 -#define FP_WIDTH_8 0x0000 /* 8 bit data bus width */ -#define FP_WIDTH_9 0x0040 /* 9 bit data bus width */ -#define FP_WIDTH_12 0x0080 /* 12 bit data bus width */ -#define FP_WIDTH_18 0x00C0 /* 18 bit data bus width */ -#define FP_WIDTH_24 0x0100 /* 24 bit data bus width */ -#define FP_WIDTH_16 0x0140 /* 16 bit data bus width - 16 bit Mono DSTN only */ +#define FP_WIDTH_8 0x0000 /* 8 bit data bus width */ +#define FP_WIDTH_9 0x0040 /* 9 bit data bus width */ +#define FP_WIDTH_12 0x0080 /* 12 bit data bus width */ +#define FP_WIDTH_18 0x00C0 /* 18 bit data bus width */ +#define FP_WIDTH_24 0x0100 /* 24 bit data bus width */ +#define FP_WIDTH_16 0x0140 /* 16 bit data bus width - 16 bit Mono DSTN only */ #define FP_COLOR_MASK 0x0200 -#define FP_COLOR_COLOR 0x0000 /* Color panel */ -#define FP_COLOR_MONO 0x0200 /* Mono Panel */ +#define FP_COLOR_COLOR 0x0000 /* Color panel */ +#define FP_COLOR_MONO 0x0200 /* Mono Panel */ #define FP_PPC_MASK 0x0400 -#define FP_PPC_1PPC 0x0000 /* One pixel per clock */ -#define FP_PPC_2PPC 0x0400 /* Two pixels per clock */ +#define FP_PPC_1PPC 0x0000 /* One pixel per clock */ +#define FP_PPC_2PPC 0x0400 /* Two pixels per clock */ #define FP_HPOL_MASK 0x0800 -#define FP_H_POL_LGH 0x0000 /* HSync at panel, normally low, active high */ -#define FP_H_POL_HGL 0x0800 /* HSync at panel, normally high, active low */ +#define FP_H_POL_LGH 0x0000 /* HSync at panel, normally low, active high */ +#define FP_H_POL_HGL 0x0800 /* HSync at panel, normally high, active low */ #define FP_VPOL_MASK 0x1000 -#define FP_V_POL_LGH 0x0000 /* VSync at panel, normally low, active high */ -#define FP_V_POL_HGL 0x1000 /* VSync at panel, normally high, active low */ +#define FP_V_POL_LGH 0x0000 /* VSync at panel, normally low, active high */ +#define FP_V_POL_HGL 0x1000 /* VSync at panel, normally high, active low */ #define FP_REF_MASK 0xD000 -#define FP_REF_60 0x0000 /* 60Hz refresh rate */ -#define FP_REF_65 0x2000 /* 65Hz refresh rate */ -#define FP_REF_70 0x4000 /* 70Hz refresh rate */ -#define FP_REF_72 0x6000 /* 72Hz refresh rate */ -#define FP_REF_75 0x8000 /* 75Hz refresh rate */ -#define FP_REF_85 0xA000 /* 85Hz refresh rate */ +#define FP_REF_60 0x0000 /* 60Hz refresh rate */ +#define FP_REF_65 0x2000 /* 65Hz refresh rate */ +#define FP_REF_70 0x4000 /* 70Hz refresh rate */ +#define FP_REF_72 0x6000 /* 72Hz refresh rate */ +#define FP_REF_75 0x8000 /* 75Hz refresh rate */ +#define FP_REF_85 0xA000 /* 85Hz refresh rate */ /*----------------------------------------------------------------- * Pnl_IsPanelEnabledInBIOS @@ -218,29 +218,30 @@ extern unsigned short gfx_inw(unsigned short port); int Pnl_IsPanelEnabledInBIOS(void) { - unsigned char ret = 0; + unsigned char ret = 0; - if ((gfx_cpu_version & 0xFF) == GFX_CPU_REDCLOUD) { - unsigned short data; + if ((gfx_cpu_version & 0xFF) == GFX_CPU_REDCLOUD) { + unsigned short data; - gfx_outw(VR_INDEX, VR_UNLOCK); - gfx_outw(VR_INDEX, (VRC_VG << 8) | VG_MEM_SIZE); - data = gfx_inw(VR_DATA); - if (data & FP_DETECT_MASK) - ret = 1; - } else { - unsigned short crtcindex, crtcdata; + gfx_outw(VR_INDEX, VR_UNLOCK); + gfx_outw(VR_INDEX, (VRC_VG << 8) | VG_MEM_SIZE); + data = gfx_inw(VR_DATA); + if (data & FP_DETECT_MASK) + ret = 1; + } + else { + unsigned short crtcindex, crtcdata; - crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; + crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; - /* CHECK DisplayEnable Reg in SoftVGA */ + /* CHECK DisplayEnable Reg in SoftVGA */ - gfx_outb(crtcindex, (unsigned char)SOFTVGA_DISPLAY_ENABLE); - ret = gfx_inb(crtcdata); - } + gfx_outb(crtcindex, (unsigned char) SOFTVGA_DISPLAY_ENABLE); + ret = gfx_inb(crtcdata); + } - return (ret & 0x1); + return (ret & 0x1); } /*----------------------------------------------------------------- @@ -258,120 +259,121 @@ Pnl_IsPanelEnabledInBIOS(void) void Pnl_GetPanelInfoFromBIOS(int *xres, int *yres, int *bpp, int *hz) { - unsigned short crtcindex, crtcdata; - unsigned short ret; - - if ((gfx_cpu_version & 0xFF) == GFX_CPU_REDCLOUD) { - gfx_outw(VR_INDEX, VR_UNLOCK); - gfx_outw(VR_INDEX, (VRC_VG << 8) | VG_FP_TYPE); - ret = gfx_inw(VR_DATA); - switch (ret & FP_RESOLUTION_MASK) { - case FP_RES_6X4: - *xres = 640; - *yres = 480; - break; - case FP_RES_8X6: - *xres = 800; - *yres = 600; - break; - case FP_RES_10X7: - *xres = 1024; - *yres = 768; - break; - case FP_RES_12X10: - *xres = 1280; - *yres = 1024; - break; - case FP_RES_16X12: - *xres = 1600; - *yres = 1200; - break; - } - - switch (ret & FP_WIDTH_MASK) { - case FP_WIDTH_8: - *bpp = 8; - break; - case FP_WIDTH_9: - *bpp = 9; - break; - case FP_WIDTH_12: - *bpp = 12; - break; - case FP_WIDTH_18: - *bpp = 18; - break; - case FP_WIDTH_24: - *bpp = 24; - break; - case FP_WIDTH_16: - *bpp = 16; - break; - } - - switch (ret & FP_REF_MASK) { - case FP_REF_60: - *hz = 60; - break; - case FP_REF_65: - *hz = 65; - break; - case FP_REF_70: - *hz = 70; - break; - case FP_REF_72: - *hz = 72; - break; - case FP_REF_75: - *hz = 75; - break; - case FP_REF_85: - *hz = 85; - break; - } - - } else { - crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; - crtcdata = crtcindex + 1; - - /* CHECK FPResolution Reg in SoftVGA */ - - gfx_outb(crtcindex, (unsigned char)SOFTVGA_FPRESOLUTION); - ret = gfx_inb(crtcdata); - - switch (ret & 0x3) { - case 0: - *xres = 640; - *yres = 480; - break; - case 1: - *xres = 800; - *yres = 600; - break; - case 2: - *xres = 1024; - *yres = 768; - break; - } - - switch ((ret >> 4) & 0x3) { - case 0: - *bpp = 12; - break; - case 1: - *bpp = 18; - break; - case 2: - *bpp = 16; - break; - case 3: - *bpp = 8; - break; - } - - /* CHECK FPClockFrequency Reg in SoftVGA */ - - gfx_outb(crtcindex, (unsigned char)SOFTVGA_FPCLOCKFREQUENCY); - *hz = gfx_inb(crtcdata); - } + unsigned short crtcindex, crtcdata; + unsigned short ret; + + if ((gfx_cpu_version & 0xFF) == GFX_CPU_REDCLOUD) { + gfx_outw(VR_INDEX, VR_UNLOCK); + gfx_outw(VR_INDEX, (VRC_VG << 8) | VG_FP_TYPE); + ret = gfx_inw(VR_DATA); + switch (ret & FP_RESOLUTION_MASK) { + case FP_RES_6X4: + *xres = 640; + *yres = 480; + break; + case FP_RES_8X6: + *xres = 800; + *yres = 600; + break; + case FP_RES_10X7: + *xres = 1024; + *yres = 768; + break; + case FP_RES_12X10: + *xres = 1280; + *yres = 1024; + break; + case FP_RES_16X12: + *xres = 1600; + *yres = 1200; + break; + } + + switch (ret & FP_WIDTH_MASK) { + case FP_WIDTH_8: + *bpp = 8; + break; + case FP_WIDTH_9: + *bpp = 9; + break; + case FP_WIDTH_12: + *bpp = 12; + break; + case FP_WIDTH_18: + *bpp = 18; + break; + case FP_WIDTH_24: + *bpp = 24; + break; + case FP_WIDTH_16: + *bpp = 16; + break; + } + + switch (ret & FP_REF_MASK) { + case FP_REF_60: + *hz = 60; + break; + case FP_REF_65: + *hz = 65; + break; + case FP_REF_70: + *hz = 70; + break; + case FP_REF_72: + *hz = 72; + break; + case FP_REF_75: + *hz = 75; + break; + case FP_REF_85: + *hz = 85; + break; + } + + } + else { + crtcindex = (gfx_inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4; + crtcdata = crtcindex + 1; + + /* CHECK FPResolution Reg in SoftVGA */ + + gfx_outb(crtcindex, (unsigned char) SOFTVGA_FPRESOLUTION); + ret = gfx_inb(crtcdata); + + switch (ret & 0x3) { + case 0: + *xres = 640; + *yres = 480; + break; + case 1: + *xres = 800; + *yres = 600; + break; + case 2: + *xres = 1024; + *yres = 768; + break; + } + + switch ((ret >> 4) & 0x3) { + case 0: + *bpp = 12; + break; + case 1: + *bpp = 18; + break; + case 2: + *bpp = 16; + break; + case 3: + *bpp = 8; + break; + } + + /* CHECK FPClockFrequency Reg in SoftVGA */ + + gfx_outb(crtcindex, (unsigned char) SOFTVGA_FPCLOCKFREQUENCY); + *hz = gfx_inb(crtcdata); + } } diff --git a/src/panel/pnl_defs.h b/src/panel/pnl_defs.h index 37a37c7..a9232c5 100644 --- a/src/panel/pnl_defs.h +++ b/src/panel/pnl_defs.h @@ -141,20 +141,18 @@ #ifndef _pnl_defs_h #define _pnl_defs_h -typedef enum -{ - MARMOT_PLATFORM = 0, - UNICORN_PLATFORM, - CENTAURUS_PLATFORM, - ARIES_PLATFORM, - CARMEL_PLATFORM, - HYDRA_PLATFORM, - DORADO_PLATFORM, - DRACO_PLATFORM, - REDCLOUD_PLATFORM, - OTHER_PLATFORM -} -SYS_BOARD; +typedef enum { + MARMOT_PLATFORM = 0, + UNICORN_PLATFORM, + CENTAURUS_PLATFORM, + ARIES_PLATFORM, + CARMEL_PLATFORM, + HYDRA_PLATFORM, + DORADO_PLATFORM, + DRACO_PLATFORM, + REDCLOUD_PLATFORM, + OTHER_PLATFORM +} SYS_BOARD; #define PNL_9210 0x01 #define PNL_9211_A 0x02 @@ -178,26 +176,22 @@ SYS_BOARD; #define PNL_OVERRIDE_STAT 0x10 #define PNL_OVERRIDE_ALL 0x1F -typedef struct _Pnl_PanelStat_ -{ - int Type; - int XRes; - int YRes; - int Depth; - int MonoColor; -} -Pnl_PanelStat; +typedef struct _Pnl_PanelStat_ { + int Type; + int XRes; + int YRes; + int Depth; + int MonoColor; +} Pnl_PanelStat; -typedef struct _Pnl_Params_ -{ - unsigned long Flags; - int PanelPresent; - int Platform; - int PanelChip; - Pnl_PanelStat PanelStat; -} -Pnl_PanelParams, *PPnl_PanelParams; +typedef struct _Pnl_Params_ { + unsigned long Flags; + int PanelPresent; + int Platform; + int PanelChip; + Pnl_PanelStat PanelStat; +} Pnl_PanelParams, *PPnl_PanelParams; -#endif /* _pnl_defs_h */ +#endif /* _pnl_defs_h */ /* END OF FILE */ diff --git a/src/panel/pnl_init.c b/src/panel/pnl_init.c index 23ee2aa..14438f9 100644 --- a/src/panel/pnl_init.c +++ b/src/panel/pnl_init.c @@ -153,8 +153,8 @@ Depth : 16 Mono_Color : Color */ static Pnl_PanelParams sPanelParam = { - 0, 1, CENTAURUS_PLATFORM, PNL_9211_A, - {PNL_DSTN, 800, 600, 16, PNL_COLOR_PANEL} + 0, 1, CENTAURUS_PLATFORM, PNL_9211_A, + {PNL_DSTN, 800, 600, 16, PNL_COLOR_PANEL} }; #if PLATFORM_DRACO @@ -192,8 +192,8 @@ static Pnl_PanelParams sPanelParam = { void Pnl_SetPlatform(int platform) { - /* To Be Implemented */ - sPanelParam.Platform = platform; + /* To Be Implemented */ + sPanelParam.Platform = platform; } @@ -207,9 +207,9 @@ Pnl_SetPlatform(int platform) int Pnl_GetPlatform(void) { - sPanelParam.Platform = Detect_Platform(); + sPanelParam.Platform = Detect_Platform(); - return sPanelParam.Platform; + return sPanelParam.Platform; } @@ -224,8 +224,8 @@ Pnl_GetPlatform(void) int Pnl_IsPanelPresent(void) { - /* To Be Implemented */ - return sPanelParam.PanelPresent; + /* To Be Implemented */ + return sPanelParam.PanelPresent; } /*----------------------------------------------------------------- @@ -239,8 +239,8 @@ Pnl_IsPanelPresent(void) void Pnl_SetPanelPresent(int present) { - /* To Be Implemented */ - sPanelParam.PanelPresent = present; + /* To Be Implemented */ + sPanelParam.PanelPresent = present; } /*----------------------------------------------------------------- @@ -255,22 +255,22 @@ Pnl_SetPanelPresent(int present) void Pnl_SetPanelParam(PPnl_PanelParams pParam) { - if (pParam->Flags & PNL_PANELPRESENT) { - Pnl_SetPanelPresent(pParam->PanelPresent); - } - if (pParam->Flags & PNL_PLATFORM) { - Pnl_SetPlatform(pParam->Platform); - } - if (pParam->Flags & PNL_PANELCHIP) { - Pnl_SetPanelChip(pParam->PanelChip); - } - if (pParam->Flags & PNL_PANELSTAT) { - sPanelParam.PanelStat.XRes = pParam->PanelStat.XRes; - sPanelParam.PanelStat.YRes = pParam->PanelStat.YRes; - sPanelParam.PanelStat.Depth = pParam->PanelStat.Depth; - sPanelParam.PanelStat.MonoColor = pParam->PanelStat.MonoColor; - sPanelParam.PanelStat.Type = pParam->PanelStat.Type; - } + if (pParam->Flags & PNL_PANELPRESENT) { + Pnl_SetPanelPresent(pParam->PanelPresent); + } + if (pParam->Flags & PNL_PLATFORM) { + Pnl_SetPlatform(pParam->Platform); + } + if (pParam->Flags & PNL_PANELCHIP) { + Pnl_SetPanelChip(pParam->PanelChip); + } + if (pParam->Flags & PNL_PANELSTAT) { + sPanelParam.PanelStat.XRes = pParam->PanelStat.XRes; + sPanelParam.PanelStat.YRes = pParam->PanelStat.YRes; + sPanelParam.PanelStat.Depth = pParam->PanelStat.Depth; + sPanelParam.PanelStat.MonoColor = pParam->PanelStat.MonoColor; + sPanelParam.PanelStat.Type = pParam->PanelStat.Type; + } } /*----------------------------------------------------------------- @@ -284,57 +284,59 @@ Pnl_SetPanelParam(PPnl_PanelParams pParam) void Pnl_PowerUp(void) { - int Platform; - unsigned long dcfg, hw_video; + int Platform; + unsigned long dcfg, hw_video; - Platform = Pnl_GetPlatform(); + Platform = Pnl_GetPlatform(); #if PLATFORM_CENTAURUS - if (Platform == CENTAURUS_PLATFORM) { - Centaurus_Power_Up(); - return; - } + if (Platform == CENTAURUS_PLATFORM) { + Centaurus_Power_Up(); + return; + } #endif #if PLATFORM_DORADO - if (Platform == DORADO_PLATFORM) { - Dorado_Power_Up(); - return; - } + if (Platform == DORADO_PLATFORM) { + Dorado_Power_Up(); + return; + } #endif #if PLATFORM_GX2BASED - if (Platform == REDCLOUD_PLATFORM) { - } + if (Platform == REDCLOUD_PLATFORM) { + } #endif - hw_video = gfx_detect_video(); - - if (hw_video == GFX_VID_CS5530) { - /* READ DISPLAY CONFIG FROM CX5530 */ - dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); - - /* SET RELEVANT FIELDS */ - dcfg |= (CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); - /* Enable the flatpanel power and data */ - WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); - } else if (hw_video == GFX_VID_SC1200) { - /* READ DISPLAY CONFIG FROM SC1200 */ - dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); - - /* SET RELEVANT FIELDS */ - dcfg |= (SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); - /* Enable the flatpanel power and data */ - WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); - } else if (hw_video == GFX_VID_REDCLOUD) { - /* READ DISPLAY CONFIG FROM REDCLOUD */ - dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); - - /* SET RELEVANT FIELDS */ - dcfg |= (RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); - /* Enable the flatpanel power and data */ - WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); - } + hw_video = gfx_detect_video(); + + if (hw_video == GFX_VID_CS5530) { + /* READ DISPLAY CONFIG FROM CX5530 */ + dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); + + /* SET RELEVANT FIELDS */ + dcfg |= (CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); + /* Enable the flatpanel power and data */ + WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); + } + else if (hw_video == GFX_VID_SC1200) { + /* READ DISPLAY CONFIG FROM SC1200 */ + dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); + + /* SET RELEVANT FIELDS */ + dcfg |= (SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); + /* Enable the flatpanel power and data */ + WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); + } + else if (hw_video == GFX_VID_REDCLOUD) { + /* READ DISPLAY CONFIG FROM REDCLOUD */ + dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); + + /* SET RELEVANT FIELDS */ + dcfg |= (RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); + /* Enable the flatpanel power and data */ + WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); + } } @@ -349,56 +351,58 @@ Pnl_PowerUp(void) void Pnl_PowerDown(void) { - int Platform; - unsigned long dcfg, hw_video; + int Platform; + unsigned long dcfg, hw_video; - Platform = Pnl_GetPlatform(); + Platform = Pnl_GetPlatform(); #if PLATFORM_CENTAURUS - if (Platform == CENTAURUS_PLATFORM) { - Centaurus_Power_Down(); - return; - } + if (Platform == CENTAURUS_PLATFORM) { + Centaurus_Power_Down(); + return; + } #endif #if PLATFORM_DORADO - if (Platform == DORADO_PLATFORM) { - Dorado_Power_Down(); - return; - } + if (Platform == DORADO_PLATFORM) { + Dorado_Power_Down(); + return; + } #endif #if PLATFORM_GX2BASED - if (Platform == REDCLOUD_PLATFORM) { - } + if (Platform == REDCLOUD_PLATFORM) { + } #endif - hw_video = gfx_detect_video(); - - if (hw_video == GFX_VID_CS5530) { - /* READ DISPLAY CONFIG FROM CX5530 */ - dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); - - /* CLEAR RELEVANT FIELDS */ - dcfg &= ~(CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); - /* Disable the flatpanel power and data */ - WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); - } else if (hw_video == GFX_VID_SC1200) { - /* READ DISPLAY CONFIG FROM SC1200 */ - dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); - - /* CLEAR RELEVANT FIELDS */ - dcfg &= ~(SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); - /* Disable the flatpanel power and data */ - WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); - } else if (hw_video == GFX_VID_REDCLOUD) { - /* READ DISPLAY CONFIG FROM REDCLOUD */ - dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); - - /* CLEAR RELEVANT FIELDS */ - dcfg &= ~(RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); - /* Disable the flatpanel power and data */ - WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); - } + hw_video = gfx_detect_video(); + + if (hw_video == GFX_VID_CS5530) { + /* READ DISPLAY CONFIG FROM CX5530 */ + dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); + + /* CLEAR RELEVANT FIELDS */ + dcfg &= ~(CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); + /* Disable the flatpanel power and data */ + WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); + } + else if (hw_video == GFX_VID_SC1200) { + /* READ DISPLAY CONFIG FROM SC1200 */ + dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); + + /* CLEAR RELEVANT FIELDS */ + dcfg &= ~(SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); + /* Disable the flatpanel power and data */ + WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); + } + else if (hw_video == GFX_VID_REDCLOUD) { + /* READ DISPLAY CONFIG FROM REDCLOUD */ + dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); + + /* CLEAR RELEVANT FIELDS */ + dcfg &= ~(RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); + /* Disable the flatpanel power and data */ + WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); + } } /*----------------------------------------------------------------- @@ -412,27 +416,27 @@ Pnl_PowerDown(void) void Pnl_SavePanelState(void) { - int Platform; + int Platform; - Platform = Pnl_GetPlatform(); + Platform = Pnl_GetPlatform(); #if PLATFORM_CENTAURUS - if (Platform == CENTAURUS_PLATFORM) { - Centaurus_Save_Panel_State(); - return; - } + if (Platform == CENTAURUS_PLATFORM) { + Centaurus_Save_Panel_State(); + return; + } #endif #if PLATFORM_DORADO - if (Platform == DORADO_PLATFORM) { - Dorado_Save_Panel_State(); - return; - } + if (Platform == DORADO_PLATFORM) { + Dorado_Save_Panel_State(); + return; + } #endif #if PLATFORM_GX2BASED - if (Platform == REDCLOUD_PLATFORM) { - } + if (Platform == REDCLOUD_PLATFORM) { + } #endif } @@ -447,26 +451,26 @@ Pnl_SavePanelState(void) void Pnl_RestorePanelState(void) { - int Platform; + int Platform; - Platform = Pnl_GetPlatform(); + Platform = Pnl_GetPlatform(); #if PLATFORM_CENTAURUS - if (Platform == CENTAURUS_PLATFORM) { - Centaurus_Restore_Panel_State(); - return; - } + if (Platform == CENTAURUS_PLATFORM) { + Centaurus_Restore_Panel_State(); + return; + } #endif #if PLATFORM_DORADO - if (Platform == DORADO_PLATFORM) { - Dorado_Restore_Panel_State(); - return; - } + if (Platform == DORADO_PLATFORM) { + Dorado_Restore_Panel_State(); + return; + } #endif #if PLATFORM_GX2BASED - if (Platform == REDCLOUD_PLATFORM) { - } + if (Platform == REDCLOUD_PLATFORM) { + } #endif } @@ -483,44 +487,44 @@ Pnl_RestorePanelState(void) void Pnl_GetPanelParam(PPnl_PanelParams pParam) { - if (pParam->Flags & PNL_PANELPRESENT) { - pParam->PanelPresent = Pnl_IsPanelPresent(); - } - if (pParam->Flags & PNL_PLATFORM) { - pParam->Platform = Pnl_GetPlatform(); - } - if ((pParam->Flags & PNL_PANELCHIP) || (pParam->Flags & PNL_PANELSTAT)) { + if (pParam->Flags & PNL_PANELPRESENT) { + pParam->PanelPresent = Pnl_IsPanelPresent(); + } + if (pParam->Flags & PNL_PLATFORM) { + pParam->Platform = Pnl_GetPlatform(); + } + if ((pParam->Flags & PNL_PANELCHIP) || (pParam->Flags & PNL_PANELSTAT)) { #if PLATFORM_CENTAURUS - if (pParam->Platform == CENTAURUS_PLATFORM) { - Centaurus_Get_9211_Details(pParam->Flags, pParam); - return; - } + if (pParam->Platform == CENTAURUS_PLATFORM) { + Centaurus_Get_9211_Details(pParam->Flags, pParam); + return; + } #endif #if PLATFORM_DORADO - if (pParam->Platform == DORADO_PLATFORM) { - Dorado_Get_9211_Details(pParam->Flags, pParam); - return; - } + if (pParam->Platform == DORADO_PLATFORM) { + Dorado_Get_9211_Details(pParam->Flags, pParam); + return; + } #endif #if PLATFORM_GX2BASED - if (pParam->Platform == REDCLOUD_PLATFORM) { - } + if (pParam->Platform == REDCLOUD_PLATFORM) { + } #endif - /* if unknown platform put unknown */ - if (pParam->Flags & PNL_PANELCHIP) - pParam->PanelChip = PNL_UNKNOWN_CHIP; - - if (pParam->Flags & PNL_PANELSTAT) { - pParam->PanelStat.XRes = 0; - pParam->PanelStat.YRes = 0; - pParam->PanelStat.Depth = 0; - pParam->PanelStat.MonoColor = PNL_UNKNOWN_COLOR; - pParam->PanelStat.Type = PNL_UNKNOWN_PANEL; - } - } + /* if unknown platform put unknown */ + if (pParam->Flags & PNL_PANELCHIP) + pParam->PanelChip = PNL_UNKNOWN_CHIP; + + if (pParam->Flags & PNL_PANELSTAT) { + pParam->PanelStat.XRes = 0; + pParam->PanelStat.YRes = 0; + pParam->PanelStat.Depth = 0; + pParam->PanelStat.MonoColor = PNL_UNKNOWN_COLOR; + pParam->PanelStat.Type = PNL_UNKNOWN_PANEL; + } + } } /*----------------------------------------------------------------- @@ -536,8 +540,8 @@ Pnl_GetPanelParam(PPnl_PanelParams pParam) void Pnl_SetPanelChip(int panelChip) { - /* To Be Implemented */ - sPanelParam.PanelChip = panelChip; + /* To Be Implemented */ + sPanelParam.PanelChip = panelChip; } @@ -552,8 +556,8 @@ Pnl_SetPanelChip(int panelChip) int Pnl_GetPanelChip(void) { - /* To Be Implemented */ - return sPanelParam.PanelChip; + /* To Be Implemented */ + return sPanelParam.PanelChip; } /*----------------------------------------------------------------- @@ -569,45 +573,46 @@ Pnl_GetPanelChip(void) int Pnl_InitPanel(PPnl_PanelParams pParam) { - PPnl_PanelParams pPtr; + PPnl_PanelParams pPtr; - if (pParam == 0x0) /* NULL use the static table */ - pPtr = &sPanelParam; - else - pPtr = pParam; + if (pParam == 0x0) /* NULL use the static table */ + pPtr = &sPanelParam; + else + pPtr = pParam; - if (!pPtr->PanelPresent) { - return -1; /* error */ - } else { - if ((pPtr->PanelChip < 0) || (pPtr->Platform < 0)) - return -1; /* error */ + if (!pPtr->PanelPresent) { + return -1; /* error */ + } + else { + if ((pPtr->PanelChip < 0) || (pPtr->Platform < 0)) + return -1; /* error */ #if PLATFORM_DRACO - /* check we are init. the right one */ - if ((pPtr->Platform == DRACO_PLATFORM) && (pPtr->PanelChip == PNL_9210)) { - Draco9210Init(&(pPtr->PanelStat)); - } + /* check we are init. the right one */ + if ((pPtr->Platform == DRACO_PLATFORM) && (pPtr->PanelChip == PNL_9210)) { + Draco9210Init(&(pPtr->PanelStat)); + } #endif #if PLATFORM_CENTAURUS - /* check we are init. the right one */ - if (pPtr->Platform == CENTAURUS_PLATFORM) { - Centaurus_9211init(&(pPtr->PanelStat)); - } + /* check we are init. the right one */ + if (pPtr->Platform == CENTAURUS_PLATFORM) { + Centaurus_9211init(&(pPtr->PanelStat)); + } #endif #if PLATFORM_DORADO - /* check we are init. the right one */ - if ((pPtr->Platform == DORADO_PLATFORM) && - (pPtr->PanelChip == PNL_9211_C)) { - Dorado9211Init(&(pPtr->PanelStat)); - } + /* check we are init. the right one */ + if ((pPtr->Platform == DORADO_PLATFORM) && + (pPtr->PanelChip == PNL_9211_C)) { + Dorado9211Init(&(pPtr->PanelStat)); + } #endif #if PLATFORM_GX2BASED - if (pPtr->Platform == REDCLOUD_PLATFORM) { - Redcloud_9211init(&(pPtr->PanelStat)); - } + if (pPtr->Platform == REDCLOUD_PLATFORM) { + Redcloud_9211init(&(pPtr->PanelStat)); + } #endif - } /* else end */ - return 1; + } /* else end */ + return 1; } |