diff options
174 files changed, 15644 insertions, 15461 deletions
diff --git a/libX11/include/X11/Xlib.h b/libX11/include/X11/Xlib.h index b32390894..3a73d7b83 100644 --- a/libX11/include/X11/Xlib.h +++ b/libX11/include/X11/Xlib.h @@ -1691,6 +1691,7 @@ extern XHostAddress *XListHosts( int* /* nhosts_return */, Bool* /* state_return */ ); +_X_DEPRECATED extern KeySym XKeycodeToKeysym( Display* /* display */, #if NeedWidePrototypes diff --git a/libX11/include/X11/Xutil.h b/libX11/include/X11/Xutil.h index a97f489f1..8cab50e7d 100644 --- a/libX11/include/X11/Xutil.h +++ b/libX11/include/X11/Xutil.h @@ -1,826 +1,826 @@ -
-/***********************************************************
-
-Copyright 1987, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifndef _X11_XUTIL_H_
-#define _X11_XUTIL_H_
-
-/* You must include <X11/Xlib.h> before including this file */
-#include <X11/Xlib.h>
-#include <X11/keysym.h>
-
-/*
- * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
- * value (x, y, width, height) was found in the parsed string.
- */
-#define NoValue 0x0000
-#define XValue 0x0001
-#define YValue 0x0002
-#define WidthValue 0x0004
-#define HeightValue 0x0008
-#define AllValues 0x000F
-#define XNegative 0x0010
-#define YNegative 0x0020
-
-/*
- * new version containing base_width, base_height, and win_gravity fields;
- * used with WM_NORMAL_HINTS.
- */
-typedef struct {
- long flags; /* marks which fields in this structure are defined */
- int x, y; /* obsolete for new window mgrs, but clients */
- int width, height; /* should set so old wm's don't mess up */
- int min_width, min_height;
- int max_width, max_height;
- int width_inc, height_inc;
- struct {
- int x; /* numerator */
- int y; /* denominator */
- } min_aspect, max_aspect;
- int base_width, base_height; /* added by ICCCM version 1 */
- int win_gravity; /* added by ICCCM version 1 */
-} XSizeHints;
-
-/*
- * The next block of definitions are for window manager properties that
- * clients and applications use for communication.
- */
-
-/* flags argument in size hints */
-#define USPosition (1L << 0) /* user specified x, y */
-#define USSize (1L << 1) /* user specified width, height */
-
-#define PPosition (1L << 2) /* program specified position */
-#define PSize (1L << 3) /* program specified size */
-#define PMinSize (1L << 4) /* program specified minimum size */
-#define PMaxSize (1L << 5) /* program specified maximum size */
-#define PResizeInc (1L << 6) /* program specified resize increments */
-#define PAspect (1L << 7) /* program specified min and max aspect ratios */
-#define PBaseSize (1L << 8) /* program specified base for incrementing */
-#define PWinGravity (1L << 9) /* program specified window gravity */
-
-/* obsolete */
-#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
-
-
-
-typedef struct {
- long flags; /* marks which fields in this structure are defined */
- Bool input; /* does this application rely on the window manager to
- get keyboard input? */
- int initial_state; /* see below */
- Pixmap icon_pixmap; /* pixmap to be used as icon */
- Window icon_window; /* window to be used as icon */
- int icon_x, icon_y; /* initial position of icon */
- Pixmap icon_mask; /* icon mask bitmap */
- XID window_group; /* id of related window group */
- /* this structure may be extended in the future */
-} XWMHints;
-
-/* definition for flags of XWMHints */
-
-#define InputHint (1L << 0)
-#define StateHint (1L << 1)
-#define IconPixmapHint (1L << 2)
-#define IconWindowHint (1L << 3)
-#define IconPositionHint (1L << 4)
-#define IconMaskHint (1L << 5)
-#define WindowGroupHint (1L << 6)
-#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \
-IconPositionHint|IconMaskHint|WindowGroupHint)
-#define XUrgencyHint (1L << 8)
-
-/* definitions for initial window state */
-#define WithdrawnState 0 /* for windows that are not mapped */
-#define NormalState 1 /* most applications want to start this way */
-#define IconicState 3 /* application wants to start as an icon */
-
-/*
- * Obsolete states no longer defined by ICCCM
- */
-#define DontCareState 0 /* don't know or care */
-#define ZoomState 2 /* application wants to start zoomed */
-#define InactiveState 4 /* application believes it is seldom used; */
- /* some wm's may put it on inactive menu */
-
-
-/*
- * new structure for manipulating TEXT properties; used with WM_NAME,
- * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.
- */
-typedef struct {
- unsigned char *value; /* same as Property routines */
- Atom encoding; /* prop type */
- int format; /* prop data format: 8, 16, or 32 */
- unsigned long nitems; /* number of data items in value */
-} XTextProperty;
-
-#define XNoMemory -1
-#define XLocaleNotSupported -2
-#define XConverterNotFound -3
-
-typedef enum {
- XStringStyle, /* STRING */
- XCompoundTextStyle, /* COMPOUND_TEXT */
- XTextStyle, /* text in owner's encoding (current locale)*/
- XStdICCTextStyle, /* STRING, else COMPOUND_TEXT */
- /* The following is an XFree86 extension, introduced in November 2000 */
- XUTF8StringStyle /* UTF8_STRING */
-} XICCEncodingStyle;
-
-typedef struct {
- int min_width, min_height;
- int max_width, max_height;
- int width_inc, height_inc;
-} XIconSize;
-
-typedef struct {
- char *res_name;
- char *res_class;
-} XClassHint;
-
-#ifdef XUTIL_DEFINE_FUNCTIONS
-extern int XDestroyImage(
- XImage *ximage);
-extern unsigned long XGetPixel(
- XImage *ximage,
- int x, int y);
-extern int XPutPixel(
- XImage *ximage,
- int x, int y,
- unsigned long pixel);
-extern XImage *XSubImage(
- XImage *ximage,
- int x, int y,
- unsigned int width, unsigned int height);
-extern int XAddPixel(
- XImage *ximage,
- long value);
-#else
-/*
- * These macros are used to give some sugar to the image routines so that
- * naive people are more comfortable with them.
- */
-#define XDestroyImage(ximage) \
- ((*((ximage)->f.destroy_image))((ximage)))
-#define XGetPixel(ximage, x, y) \
- ((*((ximage)->f.get_pixel))((ximage), (x), (y)))
-#define XPutPixel(ximage, x, y, pixel) \
- ((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))
-#define XSubImage(ximage, x, y, width, height) \
- ((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))
-#define XAddPixel(ximage, value) \
- ((*((ximage)->f.add_pixel))((ximage), (value)))
-#endif
-
-/*
- * Compose sequence status structure, used in calling XLookupString.
- */
-typedef struct _XComposeStatus {
- XPointer compose_ptr; /* state table pointer */
- int chars_matched; /* match state */
-} XComposeStatus;
-
-/*
- * Keysym macros, used on Keysyms to test for classes of symbols
- */
-#define IsKeypadKey(keysym) \
- (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
-
-#define IsPrivateKeypadKey(keysym) \
- (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
-
-#define IsCursorKey(keysym) \
- (((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
-
-#define IsPFKey(keysym) \
- (((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
-
-#define IsFunctionKey(keysym) \
- (((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
-
-#define IsMiscFunctionKey(keysym) \
- (((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
-
-#ifdef XK_XKB_KEYS
-#define IsModifierKey(keysym) \
- ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
- || (((KeySym)(keysym) >= XK_ISO_Lock) && \
- ((KeySym)(keysym) <= XK_ISO_Last_Group_Lock)) \
- || ((KeySym)(keysym) == XK_Mode_switch) \
- || ((KeySym)(keysym) == XK_Num_Lock))
-#else
-#define IsModifierKey(keysym) \
- ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
- || ((KeySym)(keysym) == XK_Mode_switch) \
- || ((KeySym)(keysym) == XK_Num_Lock))
-#endif
-/*
- * opaque reference to Region data type
- */
-typedef struct _XRegion *Region;
-
-/* Return values from XRectInRegion() */
-
-#define RectangleOut 0
-#define RectangleIn 1
-#define RectanglePart 2
-
-
-/*
- * Information used by the visual utility routines to find desired visual
- * type from the many visuals a display may support.
- */
-
-typedef struct {
- Visual *visual;
- VisualID visualid;
- int screen;
- int depth;
-#if defined(__cplusplus) || defined(c_plusplus)
- int c_class; /* C++ */
-#else
- int class;
-#endif
- unsigned long red_mask;
- unsigned long green_mask;
- unsigned long blue_mask;
- int colormap_size;
- int bits_per_rgb;
-} XVisualInfo;
-
-#define VisualNoMask 0x0
-#define VisualIDMask 0x1
-#define VisualScreenMask 0x2
-#define VisualDepthMask 0x4
-#define VisualClassMask 0x8
-#define VisualRedMaskMask 0x10
-#define VisualGreenMaskMask 0x20
-#define VisualBlueMaskMask 0x40
-#define VisualColormapSizeMask 0x80
-#define VisualBitsPerRGBMask 0x100
-#define VisualAllMask 0x1FF
-
-/*
- * This defines a window manager property that clients may use to
- * share standard color maps of type RGB_COLOR_MAP:
- */
-typedef struct {
- Colormap colormap;
- unsigned long red_max;
- unsigned long red_mult;
- unsigned long green_max;
- unsigned long green_mult;
- unsigned long blue_max;
- unsigned long blue_mult;
- unsigned long base_pixel;
- VisualID visualid; /* added by ICCCM version 1 */
- XID killid; /* added by ICCCM version 1 */
-} XStandardColormap;
-
-#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */
-
-
-/*
- * return codes for XReadBitmapFile and XWriteBitmapFile
- */
-#define BitmapSuccess 0
-#define BitmapOpenFailed 1
-#define BitmapFileInvalid 2
-#define BitmapNoMemory 3
-
-/****************************************************************
- *
- * Context Management
- *
- ****************************************************************/
-
-
-/* Associative lookup table return codes */
-
-#define XCSUCCESS 0 /* No error. */
-#define XCNOMEM 1 /* Out of memory */
-#define XCNOENT 2 /* No entry in table */
-
-typedef int XContext;
-
-#define XUniqueContext() ((XContext) XrmUniqueQuark())
-#define XStringToContext(string) ((XContext) XrmStringToQuark(string))
-
-_XFUNCPROTOBEGIN
-
-/* The following declarations are alphabetized. */
-
-extern XClassHint *XAllocClassHint (
- void
-);
-
-extern XIconSize *XAllocIconSize (
- void
-);
-
-extern XSizeHints *XAllocSizeHints (
- void
-);
-
-extern XStandardColormap *XAllocStandardColormap (
- void
-);
-
-extern XWMHints *XAllocWMHints (
- void
-);
-
-extern int XClipBox(
- Region /* r */,
- XRectangle* /* rect_return */
-);
-
-extern Region XCreateRegion(
- void
-);
-
-extern const char *XDefaultString (void);
-
-extern int XDeleteContext(
- Display* /* display */,
- XID /* rid */,
- XContext /* context */
-);
-
-extern int XDestroyRegion(
- Region /* r */
-);
-
-extern int XEmptyRegion(
- Region /* r */
-);
-
-extern int XEqualRegion(
- Region /* r1 */,
- Region /* r2 */
-);
-
-extern int XFindContext(
- Display* /* display */,
- XID /* rid */,
- XContext /* context */,
- XPointer* /* data_return */
-);
-
-extern Status XGetClassHint(
- Display* /* display */,
- Window /* w */,
- XClassHint* /* class_hints_return */
-);
-
-extern Status XGetIconSizes(
- Display* /* display */,
- Window /* w */,
- XIconSize** /* size_list_return */,
- int* /* count_return */
-);
-
-extern Status XGetNormalHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* hints_return */
-);
-
-extern Status XGetRGBColormaps(
- Display* /* display */,
- Window /* w */,
- XStandardColormap** /* stdcmap_return */,
- int* /* count_return */,
- Atom /* property */
-);
-
-extern Status XGetSizeHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* hints_return */,
- Atom /* property */
-);
-
-extern Status XGetStandardColormap(
- Display* /* display */,
- Window /* w */,
- XStandardColormap* /* colormap_return */,
- Atom /* property */
-);
-
-extern Status XGetTextProperty(
- Display* /* display */,
- Window /* window */,
- XTextProperty* /* text_prop_return */,
- Atom /* property */
-);
-
-extern XVisualInfo *XGetVisualInfo(
- Display* /* display */,
- long /* vinfo_mask */,
- XVisualInfo* /* vinfo_template */,
- int* /* nitems_return */
-);
-
-extern Status XGetWMClientMachine(
- Display* /* display */,
- Window /* w */,
- XTextProperty* /* text_prop_return */
-);
-
-extern XWMHints *XGetWMHints(
- Display* /* display */,
- Window /* w */
-);
-
-extern Status XGetWMIconName(
- Display* /* display */,
- Window /* w */,
- XTextProperty* /* text_prop_return */
-);
-
-extern Status XGetWMName(
- Display* /* display */,
- Window /* w */,
- XTextProperty* /* text_prop_return */
-);
-
-extern Status XGetWMNormalHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* hints_return */,
- long* /* supplied_return */
-);
-
-extern Status XGetWMSizeHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* hints_return */,
- long* /* supplied_return */,
- Atom /* property */
-);
-
-extern Status XGetZoomHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* zhints_return */
-);
-
-extern int XIntersectRegion(
- Region /* sra */,
- Region /* srb */,
- Region /* dr_return */
-);
-
-extern void XConvertCase(
- KeySym /* sym */,
- KeySym* /* lower */,
- KeySym* /* upper */
-);
-
-extern int XLookupString(
- XKeyEvent* /* event_struct */,
- char* /* buffer_return */,
- int /* bytes_buffer */,
- KeySym* /* keysym_return */,
- XComposeStatus* /* status_in_out */
-);
-
-extern Status XMatchVisualInfo(
- Display* /* display */,
- int /* screen */,
- int /* depth */,
- int /* class */,
- XVisualInfo* /* vinfo_return */
-);
-
-extern int XOffsetRegion(
- Region /* r */,
- int /* dx */,
- int /* dy */
-);
-
-extern Bool XPointInRegion(
- Region /* r */,
- int /* x */,
- int /* y */
-);
-
-extern Region XPolygonRegion(
- XPoint* /* points */,
- int /* n */,
- int /* fill_rule */
-);
-
-extern int XRectInRegion(
- Region /* r */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XSaveContext(
- Display* /* display */,
- XID /* rid */,
- XContext /* context */,
- _Xconst char* /* data */
-);
-
-extern int XSetClassHint(
- Display* /* display */,
- Window /* w */,
- XClassHint* /* class_hints */
-);
-
-extern int XSetIconSizes(
- Display* /* display */,
- Window /* w */,
- XIconSize* /* size_list */,
- int /* count */
-);
-
-extern int XSetNormalHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* hints */
-);
-
-extern void XSetRGBColormaps(
- Display* /* display */,
- Window /* w */,
- XStandardColormap* /* stdcmaps */,
- int /* count */,
- Atom /* property */
-);
-
-extern int XSetSizeHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* hints */,
- Atom /* property */
-);
-
-extern int XSetStandardProperties(
- Display* /* display */,
- Window /* w */,
- _Xconst char* /* window_name */,
- _Xconst char* /* icon_name */,
- Pixmap /* icon_pixmap */,
- char** /* argv */,
- int /* argc */,
- XSizeHints* /* hints */
-);
-
-extern void XSetTextProperty(
- Display* /* display */,
- Window /* w */,
- XTextProperty* /* text_prop */,
- Atom /* property */
-);
-
-extern void XSetWMClientMachine(
- Display* /* display */,
- Window /* w */,
- XTextProperty* /* text_prop */
-);
-
-extern int XSetWMHints(
- Display* /* display */,
- Window /* w */,
- XWMHints* /* wm_hints */
-);
-
-extern void XSetWMIconName(
- Display* /* display */,
- Window /* w */,
- XTextProperty* /* text_prop */
-);
-
-extern void XSetWMName(
- Display* /* display */,
- Window /* w */,
- XTextProperty* /* text_prop */
-);
-
-extern void XSetWMNormalHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* hints */
-);
-
-extern void XSetWMProperties(
- Display* /* display */,
- Window /* w */,
- XTextProperty* /* window_name */,
- XTextProperty* /* icon_name */,
- char** /* argv */,
- int /* argc */,
- XSizeHints* /* normal_hints */,
- XWMHints* /* wm_hints */,
- XClassHint* /* class_hints */
-);
-
-extern void XmbSetWMProperties(
- Display* /* display */,
- Window /* w */,
- _Xconst char* /* window_name */,
- _Xconst char* /* icon_name */,
- char** /* argv */,
- int /* argc */,
- XSizeHints* /* normal_hints */,
- XWMHints* /* wm_hints */,
- XClassHint* /* class_hints */
-);
-
-extern void Xutf8SetWMProperties(
- Display* /* display */,
- Window /* w */,
- _Xconst char* /* window_name */,
- _Xconst char* /* icon_name */,
- char** /* argv */,
- int /* argc */,
- XSizeHints* /* normal_hints */,
- XWMHints* /* wm_hints */,
- XClassHint* /* class_hints */
-);
-
-extern void XSetWMSizeHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* hints */,
- Atom /* property */
-);
-
-extern int XSetRegion(
- Display* /* display */,
- GC /* gc */,
- Region /* r */
-);
-
-extern void XSetStandardColormap(
- Display* /* display */,
- Window /* w */,
- XStandardColormap* /* colormap */,
- Atom /* property */
-);
-
-extern int XSetZoomHints(
- Display* /* display */,
- Window /* w */,
- XSizeHints* /* zhints */
-);
-
-extern int XShrinkRegion(
- Region /* r */,
- int /* dx */,
- int /* dy */
-);
-
-extern Status XStringListToTextProperty(
- char** /* list */,
- int /* count */,
- XTextProperty* /* text_prop_return */
-);
-
-extern int XSubtractRegion(
- Region /* sra */,
- Region /* srb */,
- Region /* dr_return */
-);
-
-extern int XmbTextListToTextProperty(
- Display* display,
- char** list,
- int count,
- XICCEncodingStyle style,
- XTextProperty* text_prop_return
-);
-
-extern int XwcTextListToTextProperty(
- Display* display,
- wchar_t** list,
- int count,
- XICCEncodingStyle style,
- XTextProperty* text_prop_return
-);
-
-extern int Xutf8TextListToTextProperty(
- Display* display,
- char** list,
- int count,
- XICCEncodingStyle style,
- XTextProperty* text_prop_return
-);
-
-extern void XwcFreeStringList(
- wchar_t** list
-);
-
-extern Status XTextPropertyToStringList(
- XTextProperty* /* text_prop */,
- char*** /* list_return */,
- int* /* count_return */
-);
-
-extern int XmbTextPropertyToTextList(
- Display* display,
- const XTextProperty* text_prop,
- char*** list_return,
- int* count_return
-);
-
-extern int XwcTextPropertyToTextList(
- Display* display,
- const XTextProperty* text_prop,
- wchar_t*** list_return,
- int* count_return
-);
-
-extern int Xutf8TextPropertyToTextList(
- Display* display,
- const XTextProperty* text_prop,
- char*** list_return,
- int* count_return
-);
-
-extern int XUnionRectWithRegion(
- XRectangle* /* rectangle */,
- Region /* src_region */,
- Region /* dest_region_return */
-);
-
-extern int XUnionRegion(
- Region /* sra */,
- Region /* srb */,
- Region /* dr_return */
-);
-
-extern int XWMGeometry(
- Display* /* display */,
- int /* screen_number */,
- _Xconst char* /* user_geometry */,
- _Xconst char* /* default_geometry */,
- unsigned int /* border_width */,
- XSizeHints* /* hints */,
- int* /* x_return */,
- int* /* y_return */,
- int* /* width_return */,
- int* /* height_return */,
- int* /* gravity_return */
-);
-
-extern int XXorRegion(
- Region /* sra */,
- Region /* srb */,
- Region /* dr_return */
-);
-
-_XFUNCPROTOEND
-
-#endif /* _X11_XUTIL_H_ */
+ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef _X11_XUTIL_H_ +#define _X11_XUTIL_H_ + +/* You must include <X11/Xlib.h> before including this file */ +#include <X11/Xlib.h> +#include <X11/keysym.h> + +/* + * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding + * value (x, y, width, height) was found in the parsed string. + */ +#define NoValue 0x0000 +#define XValue 0x0001 +#define YValue 0x0002 +#define WidthValue 0x0004 +#define HeightValue 0x0008 +#define AllValues 0x000F +#define XNegative 0x0010 +#define YNegative 0x0020 + +/* + * new version containing base_width, base_height, and win_gravity fields; + * used with WM_NORMAL_HINTS. + */ +typedef struct { + long flags; /* marks which fields in this structure are defined */ + int x, y; /* obsolete for new window mgrs, but clients */ + int width, height; /* should set so old wm's don't mess up */ + int min_width, min_height; + int max_width, max_height; + int width_inc, height_inc; + struct { + int x; /* numerator */ + int y; /* denominator */ + } min_aspect, max_aspect; + int base_width, base_height; /* added by ICCCM version 1 */ + int win_gravity; /* added by ICCCM version 1 */ +} XSizeHints; + +/* + * The next block of definitions are for window manager properties that + * clients and applications use for communication. + */ + +/* flags argument in size hints */ +#define USPosition (1L << 0) /* user specified x, y */ +#define USSize (1L << 1) /* user specified width, height */ + +#define PPosition (1L << 2) /* program specified position */ +#define PSize (1L << 3) /* program specified size */ +#define PMinSize (1L << 4) /* program specified minimum size */ +#define PMaxSize (1L << 5) /* program specified maximum size */ +#define PResizeInc (1L << 6) /* program specified resize increments */ +#define PAspect (1L << 7) /* program specified min and max aspect ratios */ +#define PBaseSize (1L << 8) /* program specified base for incrementing */ +#define PWinGravity (1L << 9) /* program specified window gravity */ + +/* obsolete */ +#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect) + + + +typedef struct { + long flags; /* marks which fields in this structure are defined */ + Bool input; /* does this application rely on the window manager to + get keyboard input? */ + int initial_state; /* see below */ + Pixmap icon_pixmap; /* pixmap to be used as icon */ + Window icon_window; /* window to be used as icon */ + int icon_x, icon_y; /* initial position of icon */ + Pixmap icon_mask; /* icon mask bitmap */ + XID window_group; /* id of related window group */ + /* this structure may be extended in the future */ +} XWMHints; + +/* definition for flags of XWMHints */ + +#define InputHint (1L << 0) +#define StateHint (1L << 1) +#define IconPixmapHint (1L << 2) +#define IconWindowHint (1L << 3) +#define IconPositionHint (1L << 4) +#define IconMaskHint (1L << 5) +#define WindowGroupHint (1L << 6) +#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \ +IconPositionHint|IconMaskHint|WindowGroupHint) +#define XUrgencyHint (1L << 8) + +/* definitions for initial window state */ +#define WithdrawnState 0 /* for windows that are not mapped */ +#define NormalState 1 /* most applications want to start this way */ +#define IconicState 3 /* application wants to start as an icon */ + +/* + * Obsolete states no longer defined by ICCCM + */ +#define DontCareState 0 /* don't know or care */ +#define ZoomState 2 /* application wants to start zoomed */ +#define InactiveState 4 /* application believes it is seldom used; */ + /* some wm's may put it on inactive menu */ + + +/* + * new structure for manipulating TEXT properties; used with WM_NAME, + * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND. + */ +typedef struct { + unsigned char *value; /* same as Property routines */ + Atom encoding; /* prop type */ + int format; /* prop data format: 8, 16, or 32 */ + unsigned long nitems; /* number of data items in value */ +} XTextProperty; + +#define XNoMemory -1 +#define XLocaleNotSupported -2 +#define XConverterNotFound -3 + +typedef enum { + XStringStyle, /* STRING */ + XCompoundTextStyle, /* COMPOUND_TEXT */ + XTextStyle, /* text in owner's encoding (current locale)*/ + XStdICCTextStyle, /* STRING, else COMPOUND_TEXT */ + /* The following is an XFree86 extension, introduced in November 2000 */ + XUTF8StringStyle /* UTF8_STRING */ +} XICCEncodingStyle; + +typedef struct { + int min_width, min_height; + int max_width, max_height; + int width_inc, height_inc; +} XIconSize; + +typedef struct { + char *res_name; + char *res_class; +} XClassHint; + +#ifdef XUTIL_DEFINE_FUNCTIONS +extern int XDestroyImage( + XImage *ximage); +extern unsigned long XGetPixel( + XImage *ximage, + int x, int y); +extern int XPutPixel( + XImage *ximage, + int x, int y, + unsigned long pixel); +extern XImage *XSubImage( + XImage *ximage, + int x, int y, + unsigned int width, unsigned int height); +extern int XAddPixel( + XImage *ximage, + long value); +#else +/* + * These macros are used to give some sugar to the image routines so that + * naive people are more comfortable with them. + */ +#define XDestroyImage(ximage) \ + ((*((ximage)->f.destroy_image))((ximage))) +#define XGetPixel(ximage, x, y) \ + ((*((ximage)->f.get_pixel))((ximage), (x), (y))) +#define XPutPixel(ximage, x, y, pixel) \ + ((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel))) +#define XSubImage(ximage, x, y, width, height) \ + ((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height))) +#define XAddPixel(ximage, value) \ + ((*((ximage)->f.add_pixel))((ximage), (value))) +#endif + +/* + * Compose sequence status structure, used in calling XLookupString. + */ +typedef struct _XComposeStatus { + XPointer compose_ptr; /* state table pointer */ + int chars_matched; /* match state */ +} XComposeStatus; + +/* + * Keysym macros, used on Keysyms to test for classes of symbols + */ +#define IsKeypadKey(keysym) \ + (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal)) + +#define IsPrivateKeypadKey(keysym) \ + (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF)) + +#define IsCursorKey(keysym) \ + (((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select)) + +#define IsPFKey(keysym) \ + (((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4)) + +#define IsFunctionKey(keysym) \ + (((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35)) + +#define IsMiscFunctionKey(keysym) \ + (((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break)) + +#ifdef XK_XKB_KEYS +#define IsModifierKey(keysym) \ + ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \ + || (((KeySym)(keysym) >= XK_ISO_Lock) && \ + ((KeySym)(keysym) <= XK_ISO_Level5_Lock)) \ + || ((KeySym)(keysym) == XK_Mode_switch) \ + || ((KeySym)(keysym) == XK_Num_Lock)) +#else +#define IsModifierKey(keysym) \ + ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \ + || ((KeySym)(keysym) == XK_Mode_switch) \ + || ((KeySym)(keysym) == XK_Num_Lock)) +#endif +/* + * opaque reference to Region data type + */ +typedef struct _XRegion *Region; + +/* Return values from XRectInRegion() */ + +#define RectangleOut 0 +#define RectangleIn 1 +#define RectanglePart 2 + + +/* + * Information used by the visual utility routines to find desired visual + * type from the many visuals a display may support. + */ + +typedef struct { + Visual *visual; + VisualID visualid; + int screen; + int depth; +#if defined(__cplusplus) || defined(c_plusplus) + int c_class; /* C++ */ +#else + int class; +#endif + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + int colormap_size; + int bits_per_rgb; +} XVisualInfo; + +#define VisualNoMask 0x0 +#define VisualIDMask 0x1 +#define VisualScreenMask 0x2 +#define VisualDepthMask 0x4 +#define VisualClassMask 0x8 +#define VisualRedMaskMask 0x10 +#define VisualGreenMaskMask 0x20 +#define VisualBlueMaskMask 0x40 +#define VisualColormapSizeMask 0x80 +#define VisualBitsPerRGBMask 0x100 +#define VisualAllMask 0x1FF + +/* + * This defines a window manager property that clients may use to + * share standard color maps of type RGB_COLOR_MAP: + */ +typedef struct { + Colormap colormap; + unsigned long red_max; + unsigned long red_mult; + unsigned long green_max; + unsigned long green_mult; + unsigned long blue_max; + unsigned long blue_mult; + unsigned long base_pixel; + VisualID visualid; /* added by ICCCM version 1 */ + XID killid; /* added by ICCCM version 1 */ +} XStandardColormap; + +#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */ + + +/* + * return codes for XReadBitmapFile and XWriteBitmapFile + */ +#define BitmapSuccess 0 +#define BitmapOpenFailed 1 +#define BitmapFileInvalid 2 +#define BitmapNoMemory 3 + +/**************************************************************** + * + * Context Management + * + ****************************************************************/ + + +/* Associative lookup table return codes */ + +#define XCSUCCESS 0 /* No error. */ +#define XCNOMEM 1 /* Out of memory */ +#define XCNOENT 2 /* No entry in table */ + +typedef int XContext; + +#define XUniqueContext() ((XContext) XrmUniqueQuark()) +#define XStringToContext(string) ((XContext) XrmStringToQuark(string)) + +_XFUNCPROTOBEGIN + +/* The following declarations are alphabetized. */ + +extern XClassHint *XAllocClassHint ( + void +); + +extern XIconSize *XAllocIconSize ( + void +); + +extern XSizeHints *XAllocSizeHints ( + void +); + +extern XStandardColormap *XAllocStandardColormap ( + void +); + +extern XWMHints *XAllocWMHints ( + void +); + +extern int XClipBox( + Region /* r */, + XRectangle* /* rect_return */ +); + +extern Region XCreateRegion( + void +); + +extern const char *XDefaultString (void); + +extern int XDeleteContext( + Display* /* display */, + XID /* rid */, + XContext /* context */ +); + +extern int XDestroyRegion( + Region /* r */ +); + +extern int XEmptyRegion( + Region /* r */ +); + +extern int XEqualRegion( + Region /* r1 */, + Region /* r2 */ +); + +extern int XFindContext( + Display* /* display */, + XID /* rid */, + XContext /* context */, + XPointer* /* data_return */ +); + +extern Status XGetClassHint( + Display* /* display */, + Window /* w */, + XClassHint* /* class_hints_return */ +); + +extern Status XGetIconSizes( + Display* /* display */, + Window /* w */, + XIconSize** /* size_list_return */, + int* /* count_return */ +); + +extern Status XGetNormalHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints_return */ +); + +extern Status XGetRGBColormaps( + Display* /* display */, + Window /* w */, + XStandardColormap** /* stdcmap_return */, + int* /* count_return */, + Atom /* property */ +); + +extern Status XGetSizeHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints_return */, + Atom /* property */ +); + +extern Status XGetStandardColormap( + Display* /* display */, + Window /* w */, + XStandardColormap* /* colormap_return */, + Atom /* property */ +); + +extern Status XGetTextProperty( + Display* /* display */, + Window /* window */, + XTextProperty* /* text_prop_return */, + Atom /* property */ +); + +extern XVisualInfo *XGetVisualInfo( + Display* /* display */, + long /* vinfo_mask */, + XVisualInfo* /* vinfo_template */, + int* /* nitems_return */ +); + +extern Status XGetWMClientMachine( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop_return */ +); + +extern XWMHints *XGetWMHints( + Display* /* display */, + Window /* w */ +); + +extern Status XGetWMIconName( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop_return */ +); + +extern Status XGetWMName( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop_return */ +); + +extern Status XGetWMNormalHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints_return */, + long* /* supplied_return */ +); + +extern Status XGetWMSizeHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints_return */, + long* /* supplied_return */, + Atom /* property */ +); + +extern Status XGetZoomHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* zhints_return */ +); + +extern int XIntersectRegion( + Region /* sra */, + Region /* srb */, + Region /* dr_return */ +); + +extern void XConvertCase( + KeySym /* sym */, + KeySym* /* lower */, + KeySym* /* upper */ +); + +extern int XLookupString( + XKeyEvent* /* event_struct */, + char* /* buffer_return */, + int /* bytes_buffer */, + KeySym* /* keysym_return */, + XComposeStatus* /* status_in_out */ +); + +extern Status XMatchVisualInfo( + Display* /* display */, + int /* screen */, + int /* depth */, + int /* class */, + XVisualInfo* /* vinfo_return */ +); + +extern int XOffsetRegion( + Region /* r */, + int /* dx */, + int /* dy */ +); + +extern Bool XPointInRegion( + Region /* r */, + int /* x */, + int /* y */ +); + +extern Region XPolygonRegion( + XPoint* /* points */, + int /* n */, + int /* fill_rule */ +); + +extern int XRectInRegion( + Region /* r */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XSaveContext( + Display* /* display */, + XID /* rid */, + XContext /* context */, + _Xconst char* /* data */ +); + +extern int XSetClassHint( + Display* /* display */, + Window /* w */, + XClassHint* /* class_hints */ +); + +extern int XSetIconSizes( + Display* /* display */, + Window /* w */, + XIconSize* /* size_list */, + int /* count */ +); + +extern int XSetNormalHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints */ +); + +extern void XSetRGBColormaps( + Display* /* display */, + Window /* w */, + XStandardColormap* /* stdcmaps */, + int /* count */, + Atom /* property */ +); + +extern int XSetSizeHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints */, + Atom /* property */ +); + +extern int XSetStandardProperties( + Display* /* display */, + Window /* w */, + _Xconst char* /* window_name */, + _Xconst char* /* icon_name */, + Pixmap /* icon_pixmap */, + char** /* argv */, + int /* argc */, + XSizeHints* /* hints */ +); + +extern void XSetTextProperty( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop */, + Atom /* property */ +); + +extern void XSetWMClientMachine( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop */ +); + +extern int XSetWMHints( + Display* /* display */, + Window /* w */, + XWMHints* /* wm_hints */ +); + +extern void XSetWMIconName( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop */ +); + +extern void XSetWMName( + Display* /* display */, + Window /* w */, + XTextProperty* /* text_prop */ +); + +extern void XSetWMNormalHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints */ +); + +extern void XSetWMProperties( + Display* /* display */, + Window /* w */, + XTextProperty* /* window_name */, + XTextProperty* /* icon_name */, + char** /* argv */, + int /* argc */, + XSizeHints* /* normal_hints */, + XWMHints* /* wm_hints */, + XClassHint* /* class_hints */ +); + +extern void XmbSetWMProperties( + Display* /* display */, + Window /* w */, + _Xconst char* /* window_name */, + _Xconst char* /* icon_name */, + char** /* argv */, + int /* argc */, + XSizeHints* /* normal_hints */, + XWMHints* /* wm_hints */, + XClassHint* /* class_hints */ +); + +extern void Xutf8SetWMProperties( + Display* /* display */, + Window /* w */, + _Xconst char* /* window_name */, + _Xconst char* /* icon_name */, + char** /* argv */, + int /* argc */, + XSizeHints* /* normal_hints */, + XWMHints* /* wm_hints */, + XClassHint* /* class_hints */ +); + +extern void XSetWMSizeHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* hints */, + Atom /* property */ +); + +extern int XSetRegion( + Display* /* display */, + GC /* gc */, + Region /* r */ +); + +extern void XSetStandardColormap( + Display* /* display */, + Window /* w */, + XStandardColormap* /* colormap */, + Atom /* property */ +); + +extern int XSetZoomHints( + Display* /* display */, + Window /* w */, + XSizeHints* /* zhints */ +); + +extern int XShrinkRegion( + Region /* r */, + int /* dx */, + int /* dy */ +); + +extern Status XStringListToTextProperty( + char** /* list */, + int /* count */, + XTextProperty* /* text_prop_return */ +); + +extern int XSubtractRegion( + Region /* sra */, + Region /* srb */, + Region /* dr_return */ +); + +extern int XmbTextListToTextProperty( + Display* display, + char** list, + int count, + XICCEncodingStyle style, + XTextProperty* text_prop_return +); + +extern int XwcTextListToTextProperty( + Display* display, + wchar_t** list, + int count, + XICCEncodingStyle style, + XTextProperty* text_prop_return +); + +extern int Xutf8TextListToTextProperty( + Display* display, + char** list, + int count, + XICCEncodingStyle style, + XTextProperty* text_prop_return +); + +extern void XwcFreeStringList( + wchar_t** list +); + +extern Status XTextPropertyToStringList( + XTextProperty* /* text_prop */, + char*** /* list_return */, + int* /* count_return */ +); + +extern int XmbTextPropertyToTextList( + Display* display, + const XTextProperty* text_prop, + char*** list_return, + int* count_return +); + +extern int XwcTextPropertyToTextList( + Display* display, + const XTextProperty* text_prop, + wchar_t*** list_return, + int* count_return +); + +extern int Xutf8TextPropertyToTextList( + Display* display, + const XTextProperty* text_prop, + char*** list_return, + int* count_return +); + +extern int XUnionRectWithRegion( + XRectangle* /* rectangle */, + Region /* src_region */, + Region /* dest_region_return */ +); + +extern int XUnionRegion( + Region /* sra */, + Region /* srb */, + Region /* dr_return */ +); + +extern int XWMGeometry( + Display* /* display */, + int /* screen_number */, + _Xconst char* /* user_geometry */, + _Xconst char* /* default_geometry */, + unsigned int /* border_width */, + XSizeHints* /* hints */, + int* /* x_return */, + int* /* y_return */, + int* /* width_return */, + int* /* height_return */, + int* /* gravity_return */ +); + +extern int XXorRegion( + Region /* sra */, + Region /* srb */, + Region /* dr_return */ +); + +_XFUNCPROTOEND + +#endif /* _X11_XUTIL_H_ */ diff --git a/libX11/modules/im/ximcp/imDefFlt.c b/libX11/modules/im/ximcp/imDefFlt.c index 3de28be4f..1e4f3895b 100644 --- a/libX11/modules/im/ximcp/imDefFlt.c +++ b/libX11/modules/im/ximcp/imDefFlt.c @@ -1,417 +1,413 @@ -/******************************************************************
-
- Copyright 1992, 1993, 1994 by FUJITSU LIMITED
-
-Permission to use, copy, modify, distribute, and sell this software
-and its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear
-in supporting documentation, and that the name of FUJITSU LIMITED
-not be used in advertising or publicity pertaining to distribution
-of the software without specific, written prior permission.
-FUJITSU LIMITED makes no representations about the suitability of
-this software for any purpose.
-It is provided "as is" without express or implied warranty.
-
-FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
-USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
- Author: Takashi Fujiwara FUJITSU LIMITED
- fujiwara@a80.tech.yk.fujitsu.co.jp
-
-******************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xatom.h>
-#include "Xlibint.h"
-#include "Xutil.h"
-#include "Xlcint.h"
-#include "Ximint.h"
-
-Private long
-_XimTriggerCheck(
- Xim im,
- XKeyEvent *ev,
- INT32 len,
- CARD32 *keylist)
-{
- register long i;
- KeySym keysym;
- CARD32 buf32[BUFSIZE/4];
- char *buf = (char *)buf32;
- int modifier;
- int modifier_mask;
- CARD32 min_len = sizeof(CARD32) /* sizeof keysym */
- + sizeof(CARD32) /* sizeof modifier */
- + sizeof(CARD32); /* sizeof modifier mask */
-
- XLookupString(ev, buf, BUFSIZE, &keysym, NULL);
- if (!keysym)
- return -1;
-
- for (i = 0; len >= min_len; i += 3, len -= min_len) {
- modifier = keylist[i + 1];
- modifier_mask = keylist[i + 2];
- if (((KeySym)keylist[i] == keysym)
- && ((ev->state & modifier_mask) == modifier))
- return i;
- }
- return -1;
-}
-
-Private long
-_XimTriggerOnCheck(
- Xim im,
- XKeyEvent *ev)
-{
- return _XimTriggerCheck(im, ev, (INT32)im->private.proto.im_onkeylist[0],
- &im->private.proto.im_onkeylist[1]);
-}
-
-Private long
-_XimTriggerOffCheck(
- Xim im,
- XKeyEvent *ev)
-{
- return _XimTriggerCheck(im, ev, (INT32)im->private.proto.im_offkeylist[0],
- &im->private.proto.im_offkeylist[1]);
-}
-
-Private Bool
-_XimOnKeysCheck(
- Xic ic,
- XKeyEvent *ev)
-{
- Xim im = (Xim)ic->core.im;
- long idx;
-
- if (IS_DYNAMIC_EVENT_FLOW(ic->core.im) &&
- im->private.proto.im_onkeylist &&
- im->private.proto.im_onkeylist[0]) {
- if ((idx = _XimTriggerOnCheck(im, ev)) >= 0) {
- (void)_XimTriggerNotify(im, ic, 0, (CARD32)idx); /* Trigger on */
- return True;
- }
- }
- return False;
-}
-
-Private Bool
-_XimOffKeysCheck(
- Xic ic,
- XKeyEvent *ev)
-{
- Xim im = (Xim)ic->core.im;
- long idx;
-
- if (IS_DYNAMIC_EVENT_FLOW(ic->core.im) &&
- im->private.proto.im_offkeylist &&
- im->private.proto.im_offkeylist[0]) {
- if ((idx = _XimTriggerOffCheck(im, ev)) >= 0) {
- _XimTriggerNotify(im, ic, 1, (CARD32)idx); /* Trigger off */
- return True;
- }
- }
- return False;
-}
-
-Private void
-_XimPendingFilter(
- Xic ic)
-{
- Xim im = (Xim)ic->core.im;
-
- if (IS_NEED_SYNC_REPLY(ic)) {
- (void)_XimProcSyncReply(im, ic);
- UNMARK_NEED_SYNC_REPLY(ic);
- }
- return;
-}
-
-Private Bool
-_XimProtoKeypressFilter(
- Xic ic,
- XKeyEvent *ev)
-{
-#ifdef XIM_CONNECTABLE
- Xim im = (Xim)ic->core.im;
-#endif
-
- if (IS_FABLICATED(ic)) {
- _XimPendingFilter(ic);
- UNMARK_FABLICATED(ic);
- return NOTFILTERD;
- }
-
- if (IS_NEGLECT_EVENT(ic, KeyPressMask))
- return FILTERD;
-
-#ifdef XIM_CONNECTABLE
- if (!IS_IC_CONNECTED(ic)) {
- if (IS_CONNECTABLE(im)) {
- if (_XimConnectServer(im)) {
- if (!_XimReCreateIC(ic)) {
- _XimDelayModeSetAttr(im);
- return NOTFILTERD;
- }
- } else {
- return NOTFILTERD;
- }
- } else {
- return NOTFILTERD;
- }
- }
-#else
- if (!IS_IC_CONNECTED(ic))
- return NOTFILTERD;
-#endif /* XIM_CONNECTABLE */
-
- if (!IS_FORWARD_EVENT(ic, KeyPressMask)) {
- if (_XimOnKeysCheck(ic, ev))
- return FILTERD;
- return NOTFILTERD;
- }
- if (_XimOffKeysCheck(ic, ev))
- return FILTERD;
-
- if (_XimForwardEvent(ic, (XEvent *)ev,
- IS_SYNCHRONOUS_EVENT(ic, KeyPressMask)))
- return FILTERD;
-
- return NOTFILTERD;
-}
-
-Private Bool
-_XimFilterKeypress(
- Display *d,
- Window w,
- XEvent *ev,
- XPointer client_data)
-{
- return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev );
-}
-
-Private Bool
-_XimProtoKeyreleaseFilter(
- Xic ic,
- XKeyEvent *ev)
-{
-#ifdef XIM_CONNECTABLE
- Xim im = (Xim)ic->core.im;
-#endif
-
- if (IS_FABLICATED(ic)) {
- _XimPendingFilter(ic);
- UNMARK_FABLICATED(ic);
- return NOTFILTERD;
- }
-
- if (IS_NEGLECT_EVENT(ic, KeyReleaseMask))
- return FILTERD;
-
-#ifdef XIM_CONNECTABLE
- if (!IS_IC_CONNECTED(ic)) {
- if (IS_CONNECTABLE(im)) {
- if (_XimConnectServer(im)) {
- if (!_XimReCreateIC(ic)) {
- _XimDelayModeSetAttr(im);
- return NOTFILTERD;
- }
- } else {
- return NOTFILTERD;
- }
- } else {
- return NOTFILTERD;
- }
- }
-#else
- if (!IS_IC_CONNECTED(ic))
- return NOTFILTERD;
-#endif /* XIM_CONNECTABLE */
-
- if (!IS_FORWARD_EVENT(ic, KeyReleaseMask)) {
- if (_XimOnKeysCheck(ic, ev))
- return FILTERD;
- return NOTFILTERD;
- }
- if (_XimOffKeysCheck(ic, ev))
- return FILTERD;
-
- if (_XimForwardEvent(ic, (XEvent *)ev,
- IS_SYNCHRONOUS_EVENT(ic, KeyPressMask)))
- return FILTERD;
-
- return NOTFILTERD;
-}
-
-Private Bool
-_XimFilterKeyrelease(
- Display *d,
- Window w,
- XEvent *ev,
- XPointer client_data)
-{
- return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev);
-}
-
-Private void
-_XimRegisterKeyPressFilter(
- Xic ic)
-{
- if (ic->core.focus_window) {
- if (!(ic->private.proto.registed_filter_event & KEYPRESS_MASK)) {
- _XRegisterFilterByType (ic->core.im->core.display,
- ic->core.focus_window,
- KeyPress, KeyPress,
- _XimFilterKeypress,
- (XPointer)ic);
- ic->private.proto.registed_filter_event |= KEYPRESS_MASK;
- }
- }
- return;
-}
-
-Private void
-_XimRegisterKeyReleaseFilter(
- Xic ic)
-{
- if (ic->core.focus_window) {
- if (!(ic->private.proto.registed_filter_event & KEYRELEASE_MASK)) {
- _XRegisterFilterByType (ic->core.im->core.display,
- ic->core.focus_window,
- KeyRelease, KeyRelease,
- _XimFilterKeyrelease,
- (XPointer)ic);
- ic->private.proto.registed_filter_event |= KEYRELEASE_MASK;
- }
- }
- return;
-}
-
-Private void
-_XimUnregisterKeyPressFilter(
- Xic ic)
-{
- if (ic->core.focus_window) {
- if (ic->private.proto.registed_filter_event & KEYPRESS_MASK) {
- _XUnregisterFilter (ic->core.im->core.display,
- ic->core.focus_window,
- _XimFilterKeypress,
- (XPointer)ic);
- ic->private.proto.registed_filter_event &= ~KEYPRESS_MASK;
- }
- }
- return;
-}
-
-Private void
-_XimUnregisterKeyReleaseFilter(
- Xic ic)
-{
- if (ic->core.focus_window) {
- if (ic->private.proto.registed_filter_event & KEYRELEASE_MASK) {
- _XUnregisterFilter (ic->core.im->core.display,
- ic->core.focus_window,
- _XimFilterKeyrelease,
- (XPointer)ic);
- ic->private.proto.registed_filter_event &= ~KEYRELEASE_MASK;
- }
- }
- return;
-}
-
-Public void
-_XimRegisterFilter(
- Xic ic)
-{
- _XimRegisterKeyPressFilter(ic);
- if (IS_FORWARD_EVENT(ic, KeyReleaseMask))
- _XimRegisterKeyReleaseFilter(ic);
- return;
-}
-
-Public void
-_XimUnregisterFilter(
- Xic ic)
-{
- _XimUnregisterKeyPressFilter(ic);
- _XimUnregisterKeyReleaseFilter(ic);
- return;
-}
-
-Public void
-_XimReregisterFilter(
- Xic ic)
-{
- if (IS_FORWARD_EVENT(ic, KeyReleaseMask))
- _XimRegisterKeyReleaseFilter(ic);
- else
- _XimUnregisterKeyReleaseFilter(ic);
-
- return;
-}
-
-Private Bool
-_XimFilterServerDestroy(
- Display *d,
- Window w,
- XEvent *ev,
- XPointer client_data)
-{
- Xim im = (Xim)client_data;
-
- if (ev->type == DestroyNotify) {
- UNMARK_SERVER_CONNECTED(im);
-#ifdef XIM_CONNECTABLE
- if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
- _XimServerReconectableDestroy();
- return True;
- }
-#endif /* XIM_CONNECTABLE */
- _XimServerDestroy(im);
- }
- return True;
-}
-
-Public void
-_XimRegisterServerFilter(
- Xim im)
-{
- if (im->private.proto.im_window) {
- if (!(im->private.proto.registed_filter_event & DESTROYNOTIFY_MASK)) {
- _XRegisterFilterByMask(im->core.display,
- im->private.proto.im_window,
- StructureNotifyMask,
- _XimFilterServerDestroy,
- (XPointer)im);
- XSelectInput(im->core.display, im->private.proto.im_window,
- StructureNotifyMask);
- im->private.proto.registed_filter_event |= DESTROYNOTIFY_MASK;
- }
- }
- return;
-}
-
-Public void
-_XimUnregisterServerFilter(
- Xim im)
-{
- if (im->private.proto.im_window) {
- if (im->private.proto.registed_filter_event & DESTROYNOTIFY_MASK) {
- _XUnregisterFilter(im->core.display,
- im->private.proto.im_window,
- _XimFilterServerDestroy,
- (XPointer)im);
- im->private.proto.registed_filter_event &= ~DESTROYNOTIFY_MASK;
- }
- }
- return;
-}
-
+/****************************************************************** + + Copyright 1992, 1993, 1994 by FUJITSU LIMITED + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of FUJITSU LIMITED +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. +FUJITSU LIMITED makes no representations about the suitability of +this software for any purpose. +It is provided "as is" without express or implied warranty. + +FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + Author: Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp + +******************************************************************/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <X11/Xatom.h> +#include "Xlibint.h" +#include "Xutil.h" +#include "Xlcint.h" +#include "Ximint.h" + +Private long +_XimTriggerCheck( + Xim im, + XKeyEvent *ev, + INT32 len, + CARD32 *keylist) +{ + register long i; + KeySym keysym; + CARD32 buf32[BUFSIZE/4]; + char *buf = (char *)buf32; + int modifier; + int modifier_mask; + CARD32 min_len = sizeof(CARD32) /* sizeof keysym */ + + sizeof(CARD32) /* sizeof modifier */ + + sizeof(CARD32); /* sizeof modifier mask */ + + XLookupString(ev, buf, BUFSIZE, &keysym, NULL); + if (!keysym) + return -1; + + for (i = 0; len >= min_len; i += 3, len -= min_len) { + modifier = keylist[i + 1]; + modifier_mask = keylist[i + 2]; + if (((KeySym)keylist[i] == keysym) + && ((ev->state & modifier_mask) == modifier)) + return i; + } + return -1; +} + +Private long +_XimTriggerOnCheck( + Xim im, + XKeyEvent *ev) +{ + return _XimTriggerCheck(im, ev, (INT32)im->private.proto.im_onkeylist[0], + &im->private.proto.im_onkeylist[1]); +} + +Private long +_XimTriggerOffCheck( + Xim im, + XKeyEvent *ev) +{ + return _XimTriggerCheck(im, ev, (INT32)im->private.proto.im_offkeylist[0], + &im->private.proto.im_offkeylist[1]); +} + +Private Bool +_XimOnKeysCheck( + Xic ic, + XKeyEvent *ev) +{ + Xim im = (Xim)ic->core.im; + long idx; + + if (IS_DYNAMIC_EVENT_FLOW(ic->core.im) && + im->private.proto.im_onkeylist && + im->private.proto.im_onkeylist[0]) { + if ((idx = _XimTriggerOnCheck(im, ev)) >= 0) { + (void)_XimTriggerNotify(im, ic, 0, (CARD32)idx); /* Trigger on */ + return True; + } + } + return False; +} + +Private Bool +_XimOffKeysCheck( + Xic ic, + XKeyEvent *ev) +{ + Xim im = (Xim)ic->core.im; + long idx; + + if (IS_DYNAMIC_EVENT_FLOW(ic->core.im) && + im->private.proto.im_offkeylist && + im->private.proto.im_offkeylist[0]) { + if ((idx = _XimTriggerOffCheck(im, ev)) >= 0) { + _XimTriggerNotify(im, ic, 1, (CARD32)idx); /* Trigger off */ + return True; + } + } + return False; +} + +Private void +_XimPendingFilter( + Xic ic) +{ + Xim im = (Xim)ic->core.im; + + if (IS_NEED_SYNC_REPLY(im)) { + (void)_XimProcSyncReply(im, ic); + UNMARK_NEED_SYNC_REPLY(im); + } + return; +} + +Private Bool +_XimProtoKeypressFilter( + Xic ic, + XKeyEvent *ev) +{ + Xim im = (Xim)ic->core.im; + + if (IS_FABRICATED(im)) { + _XimPendingFilter(ic); + UNMARK_FABRICATED(im); + return NOTFILTERD; + } + + if (IS_NEGLECT_EVENT(ic, KeyPressMask)) + return FILTERD; + +#ifdef XIM_CONNECTABLE + if (!IS_IC_CONNECTED(ic)) { + if (IS_CONNECTABLE(im)) { + if (_XimConnectServer(im)) { + if (!_XimReCreateIC(ic)) { + _XimDelayModeSetAttr(im); + return NOTFILTERD; + } + } else { + return NOTFILTERD; + } + } else { + return NOTFILTERD; + } + } +#else + if (!IS_IC_CONNECTED(ic)) + return NOTFILTERD; +#endif /* XIM_CONNECTABLE */ + + if (!IS_FORWARD_EVENT(ic, KeyPressMask)) { + if (_XimOnKeysCheck(ic, ev)) + return FILTERD; + return NOTFILTERD; + } + if (_XimOffKeysCheck(ic, ev)) + return FILTERD; + + if (_XimForwardEvent(ic, (XEvent *)ev, + IS_SYNCHRONOUS_EVENT(ic, KeyPressMask))) + return FILTERD; + + return NOTFILTERD; +} + +Private Bool +_XimFilterKeypress( + Display *d, + Window w, + XEvent *ev, + XPointer client_data) +{ + return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev ); +} + +Private Bool +_XimProtoKeyreleaseFilter( + Xic ic, + XKeyEvent *ev) +{ + Xim im = (Xim)ic->core.im; + + if (IS_FABRICATED(im)) { + _XimPendingFilter(ic); + UNMARK_FABRICATED(im); + return NOTFILTERD; + } + + if (IS_NEGLECT_EVENT(ic, KeyReleaseMask)) + return FILTERD; + +#ifdef XIM_CONNECTABLE + if (!IS_IC_CONNECTED(ic)) { + if (IS_CONNECTABLE(im)) { + if (_XimConnectServer(im)) { + if (!_XimReCreateIC(ic)) { + _XimDelayModeSetAttr(im); + return NOTFILTERD; + } + } else { + return NOTFILTERD; + } + } else { + return NOTFILTERD; + } + } +#else + if (!IS_IC_CONNECTED(ic)) + return NOTFILTERD; +#endif /* XIM_CONNECTABLE */ + + if (!IS_FORWARD_EVENT(ic, KeyReleaseMask)) { + if (_XimOnKeysCheck(ic, ev)) + return FILTERD; + return NOTFILTERD; + } + if (_XimOffKeysCheck(ic, ev)) + return FILTERD; + + if (_XimForwardEvent(ic, (XEvent *)ev, + IS_SYNCHRONOUS_EVENT(ic, KeyPressMask))) + return FILTERD; + + return NOTFILTERD; +} + +Private Bool +_XimFilterKeyrelease( + Display *d, + Window w, + XEvent *ev, + XPointer client_data) +{ + return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev); +} + +Private void +_XimRegisterKeyPressFilter( + Xic ic) +{ + if (ic->core.focus_window) { + if (!(ic->private.proto.registed_filter_event & KEYPRESS_MASK)) { + _XRegisterFilterByType (ic->core.im->core.display, + ic->core.focus_window, + KeyPress, KeyPress, + _XimFilterKeypress, + (XPointer)ic); + ic->private.proto.registed_filter_event |= KEYPRESS_MASK; + } + } + return; +} + +Private void +_XimRegisterKeyReleaseFilter( + Xic ic) +{ + if (ic->core.focus_window) { + if (!(ic->private.proto.registed_filter_event & KEYRELEASE_MASK)) { + _XRegisterFilterByType (ic->core.im->core.display, + ic->core.focus_window, + KeyRelease, KeyRelease, + _XimFilterKeyrelease, + (XPointer)ic); + ic->private.proto.registed_filter_event |= KEYRELEASE_MASK; + } + } + return; +} + +Private void +_XimUnregisterKeyPressFilter( + Xic ic) +{ + if (ic->core.focus_window) { + if (ic->private.proto.registed_filter_event & KEYPRESS_MASK) { + _XUnregisterFilter (ic->core.im->core.display, + ic->core.focus_window, + _XimFilterKeypress, + (XPointer)ic); + ic->private.proto.registed_filter_event &= ~KEYPRESS_MASK; + } + } + return; +} + +Private void +_XimUnregisterKeyReleaseFilter( + Xic ic) +{ + if (ic->core.focus_window) { + if (ic->private.proto.registed_filter_event & KEYRELEASE_MASK) { + _XUnregisterFilter (ic->core.im->core.display, + ic->core.focus_window, + _XimFilterKeyrelease, + (XPointer)ic); + ic->private.proto.registed_filter_event &= ~KEYRELEASE_MASK; + } + } + return; +} + +Public void +_XimRegisterFilter( + Xic ic) +{ + _XimRegisterKeyPressFilter(ic); + if (IS_FORWARD_EVENT(ic, KeyReleaseMask)) + _XimRegisterKeyReleaseFilter(ic); + return; +} + +Public void +_XimUnregisterFilter( + Xic ic) +{ + _XimUnregisterKeyPressFilter(ic); + _XimUnregisterKeyReleaseFilter(ic); + return; +} + +Public void +_XimReregisterFilter( + Xic ic) +{ + if (IS_FORWARD_EVENT(ic, KeyReleaseMask)) + _XimRegisterKeyReleaseFilter(ic); + else + _XimUnregisterKeyReleaseFilter(ic); + + return; +} + +Private Bool +_XimFilterServerDestroy( + Display *d, + Window w, + XEvent *ev, + XPointer client_data) +{ + Xim im = (Xim)client_data; + + if (ev->type == DestroyNotify) { + UNMARK_SERVER_CONNECTED(im); +#ifdef XIM_CONNECTABLE + if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) { + _XimServerReconectableDestroy(); + return True; + } +#endif /* XIM_CONNECTABLE */ + _XimServerDestroy(im); + } + return True; +} + +Public void +_XimRegisterServerFilter( + Xim im) +{ + if (im->private.proto.im_window) { + if (!(im->private.proto.registed_filter_event & DESTROYNOTIFY_MASK)) { + _XRegisterFilterByMask(im->core.display, + im->private.proto.im_window, + StructureNotifyMask, + _XimFilterServerDestroy, + (XPointer)im); + XSelectInput(im->core.display, im->private.proto.im_window, + StructureNotifyMask); + im->private.proto.registed_filter_event |= DESTROYNOTIFY_MASK; + } + } + return; +} + +Public void +_XimUnregisterServerFilter( + Xim im) +{ + if (im->private.proto.im_window) { + if (im->private.proto.registed_filter_event & DESTROYNOTIFY_MASK) { + _XUnregisterFilter(im->core.display, + im->private.proto.im_window, + _XimFilterServerDestroy, + (XPointer)im); + im->private.proto.registed_filter_event &= ~DESTROYNOTIFY_MASK; + } + } + return; +} + diff --git a/libX11/modules/im/ximcp/imDefIc.c b/libX11/modules/im/ximcp/imDefIc.c index a962c1b0f..a06f6a73d 100644 --- a/libX11/modules/im/ximcp/imDefIc.c +++ b/libX11/modules/im/ximcp/imDefIc.c @@ -968,8 +968,6 @@ _XimProtoSetFocus( (void)_XimWrite(im, len, (XPointer)buf); _XimFlush(im); - MARK_FOCUSED(ic); - _XimRegisterFilter(ic); return; } @@ -1015,8 +1013,6 @@ _XimProtoUnsetFocus( (void)_XimWrite(im, len, (XPointer)buf); _XimFlush(im); - UNMARK_FOCUSED(ic); - _XimUnregisterFilter(ic); return; } diff --git a/libX11/modules/im/ximcp/imDefLkup.c b/libX11/modules/im/ximcp/imDefLkup.c index 996d36aef..cf7591909 100644 --- a/libX11/modules/im/ximcp/imDefLkup.c +++ b/libX11/modules/im/ximcp/imDefLkup.c @@ -213,12 +213,8 @@ _XimRespSyncReply( Xic ic, BITMASK16 mode) { - if (mode & XimSYNCHRONUS) /* SYNC Request */ { - if (IS_FOCUSED(ic)) - MARK_NEED_SYNC_REPLY(ic); - else - _XimProcSyncReply((Xim)ic->core.im, ic); - } + if (mode & XimSYNCHRONUS) /* SYNC Request */ + MARK_NEED_SYNC_REPLY(ic->core.im); return True; } @@ -356,7 +352,7 @@ _XimProcEvent( ev->xany.serial |= serial << 16; ev->xany.send_event = False; ev->xany.display = d; - MARK_FABLICATED(ic); + MARK_FABRICATED(ic->core.im); return; } @@ -708,7 +704,7 @@ _XimCommitRecv( (void)_XimRespSyncReply(ic, flag); - MARK_FABLICATED(ic); + MARK_FABRICATED(im); ev.type = KeyPress; ev.send_event = False; diff --git a/libX11/modules/im/ximcp/imExten.c b/libX11/modules/im/ximcp/imExten.c index 97309136e..65e59bcb4 100644 --- a/libX11/modules/im/ximcp/imExten.c +++ b/libX11/modules/im/ximcp/imExten.c @@ -1,576 +1,576 @@ -/******************************************************************
-
- Copyright 1992, 1993, 1994 by FUJITSU LIMITED
-
-Permission to use, copy, modify, distribute, and sell this software
-and its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear
-in supporting documentation, and that the name of FUJITSU LIMITED
-not be used in advertising or publicity pertaining to distribution
-of the software without specific, written prior permission.
-FUJITSU LIMITED makes no representations about the suitability of
-this software for any purpose.
-It is provided "as is" without express or implied warranty.
-
-FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
-USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
- Author: Takashi Fujiwara FUJITSU LIMITED
- fujiwara@a80.tech.yk.fujitsu.co.jp
-
-******************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xatom.h>
-#include "Xlibint.h"
-#include "Xlcint.h"
-#include "Ximint.h"
-
-/*
- * index of extensions
- */
-
-#define XIM_EXT_SET_EVENT_MASK_IDX 0
-#ifdef EXT_FORWARD
-#define XIM_EXT_FORWARD_KEYEVENT_IDX 1
-#endif
-#ifdef EXT_MOVE
-#define XIM_EXT_MOVE_IDX 2
-#endif
-
-typedef struct _XIM_QueryExtRec {
- Bool is_support;
- const char *name;
- int name_len;
- CARD16 major_opcode;
- CARD16 minor_opcode;
- int idx;
-} XIM_QueryExtRec;
-
-Private XIM_QueryExtRec extensions[] = {
- {False, "XIM_EXT_SET_EVENT_MASK", 0, 0, 0,
- XIM_EXT_SET_EVENT_MASK_IDX},
-#ifdef EXT_FORWARD
- {False, "XIM_EXT_FORWARD_KEYEVENT", 0, 0, 0,
- XIM_EXT_FORWARD_KEYEVENT_IDX},
-#endif
-#ifdef EXT_MOVE
- {False, "XIM_EXT_MOVE", 0, 0, 0, XIM_EXT_MOVE_IDX},
-#endif
- {False, NULL, 0, 0, 0, 0} /* dummy */
-};
-
-Private int
-_XimIsSupportExt(
- int idx)
-{
- register int i;
- int n = XIMNumber(extensions) - 1;
-
- for (i = 0; i < n; i++) {
- if (extensions[i].idx == idx) {
- if (extensions[i].is_support)
- return i;
- else
- break;
- }
- }
- return -1;
-}
-
-Private Bool
-_XimProcExtSetEventMask(
- Xim im,
- Xic ic,
- XPointer buf)
-{
- EVENTMASK *buf_l = (EVENTMASK *)buf;
- EVENTMASK select_mask = _XimGetWindowEventmask(ic);
-
- ic->private.proto.filter_event_mask = buf_l[0];
- ic->private.proto.intercept_event_mask = buf_l[1];
- ic->private.proto.select_event_mask = buf_l[2];
- ic->private.proto.forward_event_mask = buf_l[3];
- ic->private.proto.synchronous_event_mask = buf_l[4];
-
- select_mask &= ~ic->private.proto.intercept_event_mask;
- /* deselected event mask */
- select_mask |= ic->private.proto.select_event_mask;
- /* selected event mask */
- XSelectInput(im->core.display, ic->core.focus_window, select_mask);
- _XimReregisterFilter(ic);
-
- if (!(_XimProcSyncReply(im, ic)))
- return False;
- return True;
-}
-
-Private Bool
-_XimExtSetEventMaskCallback(
- Xim xim,
- INT16 len,
- XPointer data,
- XPointer call_data)
-{
- CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
- XIMID imid = buf_s[0];
- XICID icid = buf_s[1];
- Xim im = (Xim)call_data;
- Xic ic;
-
- if ((imid == im->private.proto.imid)
- && (ic = _XimICOfXICID(im, icid))) {
- (void)_XimProcExtSetEventMask(im, ic, (XPointer)&buf_s[2]);
- return True;
- }
- return False;
-}
-
-#ifdef EXT_FORWARD
-Private Bool
-_XimProcExtForwardKeyEvent(
- Xim im,
- Xic ic,
- XPointer buf)
-{
- CARD8 *buf_b = (CARD8 *)buf;
- CARD16 *buf_s = (CARD16 *)buf;
- CARD32 *buf_l = (CARD32 *)buf;
- XEvent ev;
- XKeyEvent *kev = (XKeyEvent *)&ev;
-
- bzero(&ev, sizeof(XEvent));
- kev->send_event = False;
- kev->display = im->core.display;
- kev->serial = buf_s[1]; /* sequence number */
- kev->type = buf_b[4] & 0x7f; /* xEvent.u.u.type */
- kev->keycode = buf_b[5]; /* Keycode */
- kev->state = buf_s[3]; /* state */
- kev->time = buf_l[2]; /* time */
-
- XPutBackEvent(im->core.display, &ev);
-
- _XimRespSyncReply(ic, buf_s[0]);
- MARK_FABLICATED(ic);
-
- return True;
-}
-
-Private Bool
-_XimExtForwardKeyEventCallback(
- Xim xim,
- INT16 len,
- XPointer data,
- XPointer call_data)
-{
- CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
- XIMID imid = buf_s[0];
- XICID icid = buf_s[1];
- Xim im = (Xim)call_data;
- Xic ic;
-
- if ((imid == im->private.proto.imid)
- && (ic = _XimICOfXICID(im, icid))) {
- (void)_XimProcExtForwardKeyEvent(im, ic, (XPointer)&buf_s[2]);
- return True;
- }
- return False;
-}
-
-Private Bool
-_XimExtForwardKeyEventCheck(
- Xim im,
- INT16 len,
- XPointer data,
- XPointer arg)
-{
- Xic ic = (Xic)arg;
- CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
- CARD8 major_opcode = *((CARD8 *)data);
- CARD8 minor_opcode = *((CARD8 *)data + 1);
- XIMID imid = buf_s[0];
- XICID icid = buf_s[1];
-
- if ((major_opcode == XIM_SYNC_REPLY)
- && (minor_opcode == 0)
- && (imid == im->private.proto.imid)
- && (icid == ic->private.proto.icid))
- if ((major_opcode == XIM_ERROR)
- && (minor_opcode == 0)
- && (buf_s[2] & XIM_IMID_VALID)
- && (imid == im->private.proto.imid)
- && (buf_s[2] & XIM_ICID_VALID)
- && (icid == ic->private.proto.icid))
- return True;
- return False;
-}
-
-Public Bool
-_XimExtForwardKeyEvent(
- Xic ic,
- XKeyEvent *ev,
- Bool sync)
-{
- Xim im = (Xim) ic->core.im;
- CARD32 buf32[BUFSIZE/4];
- CARD8 *buf = (CARD8 *)buf32;
- CARD8 *buf_b = &buf[XIM_HEADER_SIZE];
- CARD16 *buf_s = (CARD16 *)buf_b;
- CARD32 *buf_l = (CARD32 *)buf_b;
- CARD32 reply32[BUFSIZE/4];
- char *reply = (char *)reply32;
- XPointer preply;
- int buf_size;
- int ret_code;
- INT16 len;
- int idx;
-
- if ((idx = _XimIsSupportExt(XIM_EXT_FORWARD_KEYEVENT_IDX)) < 0)
- return False;
-
- buf_s[0] = im->private.proto.imid; /* imid */
- buf_s[1] = ic->private.proto.icid; /* icid */
- buf_s[2] = sync ? XimSYNCHRONUS : 0; /* flag */
- buf_s[3] = (CARD16)(((XAnyEvent *)ev)->serial & ((unsigned long) 0xffff));
- /* sequence number */
- buf_b[8] = ev->type; /* xEvent.u.u.type */
- buf_b[9] = ev->keycode; /* keycode */
- buf_s[5] = ev->state; /* state */
- buf_l[3] = ev->time; /* time */
- len = sizeof(CARD16) /* sizeof imid */
- + sizeof(CARD16) /* sizeof icid */
- + sizeof(BITMASK16) /* sizeof flag */
- + sizeof(CARD16) /* sizeof sequence number */
- + sizeof(BYTE) /* sizeof xEvent.u.u.type */
- + sizeof(BYTE) /* sizeof keycode */
- + sizeof(CARD16) /* sizeof state */
- + sizeof(CARD32); /* sizeof time */
-
- _XimSetHeader((XPointer)buf,
- extensions[idx].major_opcode,
- extensions[idx].minor_opcode, &len);
- if (!(_XimWrite(im, len, (XPointer)buf)))
- return False;
- _XimFlush(im);
- if (sync) {
- buf_size = BUFSIZE;
- ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
- _XimExtForwardKeyEventCheck, (XPointer)ic);
- if(ret_code == XIM_TRUE) {
- preply = reply;
- } else if(ret_code == XIM_OVERFLOW) {
- if(len <= 0) {
- preply = reply;
- } else {
- buf_sizex = len;
- preply = (XPointer)Xmalloc(buf_size);
- ret_code = _XimRead(im, &len, preply, buf_size,
- _XimExtForwardKeyEventCheck, (XPointer)ic);
- if(ret_code != XIM_TRUE) {
- Xfree(preply);
- return False;
- }
- }
- } else
- return False;
- buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
- if (*((CARD8 *)preply) == XIM_ERROR) {
- _XimProcError(im, 0, (XPointer)&buf_s[3]);
- if(reply != preply)
- Xfree(preply);
- return False;
- }
- if(reply != preply)
- Xfree(preply);
- }
- return True;
-}
-#endif /* EXT_FORWARD */
-
-Private int
-_XimCheckExtensionListSize(void)
-{
- register int i;
- int len;
- int total = 0;
- int n = XIMNumber(extensions) - 1;
-
- for (i = 0; i < n; i++) {
- len = strlen(extensions[i].name);
- extensions[i].name_len = len;
- len += sizeof(BYTE);
- total += len;
- }
- return total;
-}
-
-Private void
-_XimSetExtensionList(
- CARD8 *buf)
-{
- register int i;
- int len;
- int n = XIMNumber(extensions) - 1;
-
- for (i = 0; i < n; i++) {
- len = extensions[i].name_len;
- buf[0] = (BYTE)len;
- (void)strcpy((char *)&buf[1], extensions[i].name);
- len += sizeof(BYTE);
- buf += len;
- }
- return;
-}
-
-Private unsigned int
-_XimCountNumberOfExtension(
- INT16 total,
- CARD8 *ext)
-{
- unsigned int n;
- INT16 len;
- INT16 min_len = sizeof(CARD8)
- + sizeof(CARD8)
- + sizeof(INT16);
-
- n = 0;
- while (total > min_len) {
- len = *((INT16 *)(&ext[2]));
- len += (min_len + XIM_PAD(len));
- total -= len;
- ext += len;
- n++;
- }
- return n;
-}
-
-Private Bool
-_XimParseExtensionList(
- Xim im,
- CARD16 *data)
-{
- int num = XIMNumber(extensions) - 1;
- unsigned int n;
- CARD8 *buf;
- register int i;
- register int j;
- INT16 len;
-
- if (!(n = _XimCountNumberOfExtension(data[0], (CARD8 *)&data[1])))
- return True;
-
- buf = (CARD8 *)&data[1];;
- for (i = 0; i < n; i++) {
- len = *((INT16 *)(&buf[2]));
- for (j = 0; j < num; j++) {
- if (!(strncmp(extensions[j].name, (char *)&buf[4], len))) {
- extensions[j].major_opcode = buf[0];
- extensions[j].minor_opcode = buf[1];
- extensions[j].is_support = True;
- break;
- }
- }
- len += sizeof(CARD8) /* sizeof major_opcode */
- + sizeof(CARD8) /* sizeof minor_opcode */
- + sizeof(INT16) /* sizeof length */
- + XIM_PAD(len); /* sizeof pad */
- buf += len;
- }
-
- return True;
-}
-
-Private Bool
-_XimQueryExtensionCheck(
- Xim im,
- INT16 len,
- XPointer data,
- XPointer arg)
-{
- CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
- CARD8 major_opcode = *((CARD8 *)data);
- CARD8 minor_opcode = *((CARD8 *)data + 1);
- XIMID imid = buf_s[0];
-
- if ((major_opcode == XIM_QUERY_EXTENSION_REPLY)
- && (minor_opcode == 0)
- && (imid == im->private.proto.imid))
- return True;
- if ((major_opcode == XIM_ERROR)
- && (minor_opcode == 0)
- && (buf_s[2] & XIM_IMID_VALID)
- && (imid == im->private.proto.imid))
- return True;
- return False;
-}
-
-Public Bool
-_XimExtension(
- Xim im)
-{
- CARD8 *buf;
- CARD16 *buf_s;
- int buf_len;
- INT16 len;
- CARD32 reply32[BUFSIZE/4];
- char *reply = (char *)reply32;
- XPointer preply;
- int buf_size;
- int ret_code;
- int idx;
-
- if (!(len = _XimCheckExtensionListSize()))
- return True;
-
- buf_len = XIM_HEADER_SIZE
- + sizeof(CARD16)
- + sizeof(INT16)
- + len
- + XIM_PAD(len);
-
- if (!(buf = (CARD8 *)Xmalloc(buf_len)))
- return False;
- buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
-
- buf_s[0] = im->private.proto.imid; /* imid */
- buf_s[1] = len; /* length of Extensions */
- _XimSetExtensionList((CARD8 *)&buf_s[2]);
- /* extensions supported */
- XIM_SET_PAD(&buf_s[2], len); /* pad */
- len += sizeof(CARD16) /* sizeof imid */
- + sizeof(INT16); /* sizeof length of extensions */
-
- _XimSetHeader((XPointer)buf, XIM_QUERY_EXTENSION, 0, &len);
- if (!(_XimWrite(im, len, (XPointer)buf))) {
- XFree(buf);
- return False;
- }
- XFree(buf);
- _XimFlush(im);
- buf_size = BUFSIZE;
- ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
- _XimQueryExtensionCheck, 0);
- if(ret_code == XIM_TRUE) {
- preply = reply;
- } else if(ret_code == XIM_OVERFLOW) {
- if(len <= 0) {
- preply = reply;
- } else {
- buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
- ret_code = _XimRead(im, &len, reply, buf_size,
- _XimQueryExtensionCheck, 0);
- if(ret_code != XIM_TRUE) {
- Xfree(preply);
- return False;
- }
- }
- } else
- return False;
- buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
- if (*((CARD8 *)preply) == XIM_ERROR) {
- _XimProcError(im, 0, (XPointer)&buf_s[3]);
- if(reply != preply)
- Xfree(preply);
- return False;
- }
-
- if (!(_XimParseExtensionList(im, &buf_s[1]))) {
- if(reply != preply)
- Xfree(preply);
- return False;
- }
- if(reply != preply)
- Xfree(preply);
-
- if ((idx = _XimIsSupportExt(XIM_EXT_SET_EVENT_MASK_IDX)) >= 0)
- _XimRegProtoIntrCallback(im,
- extensions[idx].major_opcode,
- extensions[idx].minor_opcode,
- _XimExtSetEventMaskCallback, (XPointer)im);
-#ifdef EXT_FORWARD
- if ((idx = _XimIsSupportExt(XIM_EXT_FORWARD_KEYEVENT_IDX)) >= 0)
- _XimRegProtoIntrCallback(im,
- extensions[idx].major_opcode,
- extensions[idx].minor_opcode,
- _XimExtForwardKeyEventCallback, (XPointer)im);
-#endif
-
- return True;
-}
-
-#ifdef EXT_MOVE
-/* flag of ExtenArgCheck */
-#define EXT_XNSPOTLOCATION (1L<<0)
-
-/* macro for ExtenArgCheck */
-#define SET_EXT_XNSPOTLOCATION(flag) (flag |= EXT_XNSPOTLOCATION)
-#define IS_EXT_XNSPOTLOCATION(flag) (flag & EXT_XNSPOTLOCATION)
-
-/* length of XPoint attribute */
-#define XIM_Xpoint_length 12
-
-Private Bool
-_XimExtMove(
- Xim im,
- Xic ic,
- CARD16 x,
- CARD16 y)
-{
- CARD32 buf32[BUFSIZE/4];
- CARD8 *buf = (CARD8 *)buf32;
- CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
- INT16 len;
- int idx;
-
- if ((idx = _XimIsSupportExt(XIM_EXT_MOVE_IDX)) < 0)
- return False;
-
- buf_s[0] = im->private.proto.imid; /* imid */
- buf_s[1] = ic->private.proto.icid; /* icid */
- buf_s[2] = x; /* X */
- buf_s[3] = y; /* Y */
- len = sizeof(CARD16) /* sizeof imid */
- + sizeof(CARD16) /* sizeof icid */
- + sizeof(INT16) /* sizeof X */
- + sizeof(INT16); /* sizeof Y */
-
- _XimSetHeader((XPointer)buf, extensions[idx].major_opcode,
- extensions[idx].minor_opcode, &len);
- if (!(_XimWrite(im, len, (XPointer)buf)))
- return False;
- _XimFlush(im);
- return True;
-}
-
-Public BITMASK32
-_XimExtenArgCheck(
- XIMArg *arg)
-{
- CARD32 flag = 0L;
- if (!strcmp(arg->name, XNSpotLocation))
- SET_EXT_XNSPOTLOCATION(flag);
- return flag;
-}
-
-Public Bool
-_XimExtenMove(
- Xim im,
- Xic ic,
- CARD32 flag,
- CARD16 *buf,
- INT16 length)
-{
- if ((IS_EXT_XNSPOTLOCATION(flag)) && (length == XIM_Xpoint_length))
- return _XimExtMove(im, ic, buf[4], buf[5]);
- return False;
-}
-#endif /* EXT_MOVE */
+/****************************************************************** + + Copyright 1992, 1993, 1994 by FUJITSU LIMITED + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of FUJITSU LIMITED +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. +FUJITSU LIMITED makes no representations about the suitability of +this software for any purpose. +It is provided "as is" without express or implied warranty. + +FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + Author: Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp + +******************************************************************/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <X11/Xatom.h> +#include "Xlibint.h" +#include "Xlcint.h" +#include "Ximint.h" + +/* + * index of extensions + */ + +#define XIM_EXT_SET_EVENT_MASK_IDX 0 +#ifdef EXT_FORWARD +#define XIM_EXT_FORWARD_KEYEVENT_IDX 1 +#endif +#ifdef EXT_MOVE +#define XIM_EXT_MOVE_IDX 2 +#endif + +typedef struct _XIM_QueryExtRec { + Bool is_support; + const char *name; + int name_len; + CARD16 major_opcode; + CARD16 minor_opcode; + int idx; +} XIM_QueryExtRec; + +Private XIM_QueryExtRec extensions[] = { + {False, "XIM_EXT_SET_EVENT_MASK", 0, 0, 0, + XIM_EXT_SET_EVENT_MASK_IDX}, +#ifdef EXT_FORWARD + {False, "XIM_EXT_FORWARD_KEYEVENT", 0, 0, 0, + XIM_EXT_FORWARD_KEYEVENT_IDX}, +#endif +#ifdef EXT_MOVE + {False, "XIM_EXT_MOVE", 0, 0, 0, XIM_EXT_MOVE_IDX}, +#endif + {False, NULL, 0, 0, 0, 0} /* dummy */ +}; + +Private int +_XimIsSupportExt( + int idx) +{ + register int i; + int n = XIMNumber(extensions) - 1; + + for (i = 0; i < n; i++) { + if (extensions[i].idx == idx) { + if (extensions[i].is_support) + return i; + else + break; + } + } + return -1; +} + +Private Bool +_XimProcExtSetEventMask( + Xim im, + Xic ic, + XPointer buf) +{ + EVENTMASK *buf_l = (EVENTMASK *)buf; + EVENTMASK select_mask = _XimGetWindowEventmask(ic); + + ic->private.proto.filter_event_mask = buf_l[0]; + ic->private.proto.intercept_event_mask = buf_l[1]; + ic->private.proto.select_event_mask = buf_l[2]; + ic->private.proto.forward_event_mask = buf_l[3]; + ic->private.proto.synchronous_event_mask = buf_l[4]; + + select_mask &= ~ic->private.proto.intercept_event_mask; + /* deselected event mask */ + select_mask |= ic->private.proto.select_event_mask; + /* selected event mask */ + XSelectInput(im->core.display, ic->core.focus_window, select_mask); + _XimReregisterFilter(ic); + + if (!(_XimProcSyncReply(im, ic))) + return False; + return True; +} + +Private Bool +_XimExtSetEventMaskCallback( + Xim xim, + INT16 len, + XPointer data, + XPointer call_data) +{ + CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE); + XIMID imid = buf_s[0]; + XICID icid = buf_s[1]; + Xim im = (Xim)call_data; + Xic ic; + + if ((imid == im->private.proto.imid) + && (ic = _XimICOfXICID(im, icid))) { + (void)_XimProcExtSetEventMask(im, ic, (XPointer)&buf_s[2]); + return True; + } + return False; +} + +#ifdef EXT_FORWARD +Private Bool +_XimProcExtForwardKeyEvent( + Xim im, + Xic ic, + XPointer buf) +{ + CARD8 *buf_b = (CARD8 *)buf; + CARD16 *buf_s = (CARD16 *)buf; + CARD32 *buf_l = (CARD32 *)buf; + XEvent ev; + XKeyEvent *kev = (XKeyEvent *)&ev; + + bzero(&ev, sizeof(XEvent)); + kev->send_event = False; + kev->display = im->core.display; + kev->serial = buf_s[1]; /* sequence number */ + kev->type = buf_b[4] & 0x7f; /* xEvent.u.u.type */ + kev->keycode = buf_b[5]; /* Keycode */ + kev->state = buf_s[3]; /* state */ + kev->time = buf_l[2]; /* time */ + + XPutBackEvent(im->core.display, &ev); + + _XimRespSyncReply(ic, buf_s[0]); + MARK_FABRICATED(im); + + return True; +} + +Private Bool +_XimExtForwardKeyEventCallback( + Xim xim, + INT16 len, + XPointer data, + XPointer call_data) +{ + CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE); + XIMID imid = buf_s[0]; + XICID icid = buf_s[1]; + Xim im = (Xim)call_data; + Xic ic; + + if ((imid == im->private.proto.imid) + && (ic = _XimICOfXICID(im, icid))) { + (void)_XimProcExtForwardKeyEvent(im, ic, (XPointer)&buf_s[2]); + return True; + } + return False; +} + +Private Bool +_XimExtForwardKeyEventCheck( + Xim im, + INT16 len, + XPointer data, + XPointer arg) +{ + Xic ic = (Xic)arg; + CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE); + CARD8 major_opcode = *((CARD8 *)data); + CARD8 minor_opcode = *((CARD8 *)data + 1); + XIMID imid = buf_s[0]; + XICID icid = buf_s[1]; + + if ((major_opcode == XIM_SYNC_REPLY) + && (minor_opcode == 0) + && (imid == im->private.proto.imid) + && (icid == ic->private.proto.icid)) + if ((major_opcode == XIM_ERROR) + && (minor_opcode == 0) + && (buf_s[2] & XIM_IMID_VALID) + && (imid == im->private.proto.imid) + && (buf_s[2] & XIM_ICID_VALID) + && (icid == ic->private.proto.icid)) + return True; + return False; +} + +Public Bool +_XimExtForwardKeyEvent( + Xic ic, + XKeyEvent *ev, + Bool sync) +{ + Xim im = (Xim) ic->core.im; + CARD32 buf32[BUFSIZE/4]; + CARD8 *buf = (CARD8 *)buf32; + CARD8 *buf_b = &buf[XIM_HEADER_SIZE]; + CARD16 *buf_s = (CARD16 *)buf_b; + CARD32 *buf_l = (CARD32 *)buf_b; + CARD32 reply32[BUFSIZE/4]; + char *reply = (char *)reply32; + XPointer preply; + int buf_size; + int ret_code; + INT16 len; + int idx; + + if ((idx = _XimIsSupportExt(XIM_EXT_FORWARD_KEYEVENT_IDX)) < 0) + return False; + + buf_s[0] = im->private.proto.imid; /* imid */ + buf_s[1] = ic->private.proto.icid; /* icid */ + buf_s[2] = sync ? XimSYNCHRONUS : 0; /* flag */ + buf_s[3] = (CARD16)(((XAnyEvent *)ev)->serial & ((unsigned long) 0xffff)); + /* sequence number */ + buf_b[8] = ev->type; /* xEvent.u.u.type */ + buf_b[9] = ev->keycode; /* keycode */ + buf_s[5] = ev->state; /* state */ + buf_l[3] = ev->time; /* time */ + len = sizeof(CARD16) /* sizeof imid */ + + sizeof(CARD16) /* sizeof icid */ + + sizeof(BITMASK16) /* sizeof flag */ + + sizeof(CARD16) /* sizeof sequence number */ + + sizeof(BYTE) /* sizeof xEvent.u.u.type */ + + sizeof(BYTE) /* sizeof keycode */ + + sizeof(CARD16) /* sizeof state */ + + sizeof(CARD32); /* sizeof time */ + + _XimSetHeader((XPointer)buf, + extensions[idx].major_opcode, + extensions[idx].minor_opcode, &len); + if (!(_XimWrite(im, len, (XPointer)buf))) + return False; + _XimFlush(im); + if (sync) { + buf_size = BUFSIZE; + ret_code = _XimRead(im, &len, (XPointer)reply, buf_size, + _XimExtForwardKeyEventCheck, (XPointer)ic); + if(ret_code == XIM_TRUE) { + preply = reply; + } else if(ret_code == XIM_OVERFLOW) { + if(len <= 0) { + preply = reply; + } else { + buf_sizex = len; + preply = (XPointer)Xmalloc(buf_size); + ret_code = _XimRead(im, &len, preply, buf_size, + _XimExtForwardKeyEventCheck, (XPointer)ic); + if(ret_code != XIM_TRUE) { + Xfree(preply); + return False; + } + } + } else + return False; + buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE); + if (*((CARD8 *)preply) == XIM_ERROR) { + _XimProcError(im, 0, (XPointer)&buf_s[3]); + if(reply != preply) + Xfree(preply); + return False; + } + if(reply != preply) + Xfree(preply); + } + return True; +} +#endif /* EXT_FORWARD */ + +Private int +_XimCheckExtensionListSize(void) +{ + register int i; + int len; + int total = 0; + int n = XIMNumber(extensions) - 1; + + for (i = 0; i < n; i++) { + len = strlen(extensions[i].name); + extensions[i].name_len = len; + len += sizeof(BYTE); + total += len; + } + return total; +} + +Private void +_XimSetExtensionList( + CARD8 *buf) +{ + register int i; + int len; + int n = XIMNumber(extensions) - 1; + + for (i = 0; i < n; i++) { + len = extensions[i].name_len; + buf[0] = (BYTE)len; + (void)strcpy((char *)&buf[1], extensions[i].name); + len += sizeof(BYTE); + buf += len; + } + return; +} + +Private unsigned int +_XimCountNumberOfExtension( + INT16 total, + CARD8 *ext) +{ + unsigned int n; + INT16 len; + INT16 min_len = sizeof(CARD8) + + sizeof(CARD8) + + sizeof(INT16); + + n = 0; + while (total > min_len) { + len = *((INT16 *)(&ext[2])); + len += (min_len + XIM_PAD(len)); + total -= len; + ext += len; + n++; + } + return n; +} + +Private Bool +_XimParseExtensionList( + Xim im, + CARD16 *data) +{ + int num = XIMNumber(extensions) - 1; + unsigned int n; + CARD8 *buf; + register int i; + register int j; + INT16 len; + + if (!(n = _XimCountNumberOfExtension(data[0], (CARD8 *)&data[1]))) + return True; + + buf = (CARD8 *)&data[1];; + for (i = 0; i < n; i++) { + len = *((INT16 *)(&buf[2])); + for (j = 0; j < num; j++) { + if (!(strncmp(extensions[j].name, (char *)&buf[4], len))) { + extensions[j].major_opcode = buf[0]; + extensions[j].minor_opcode = buf[1]; + extensions[j].is_support = True; + break; + } + } + len += sizeof(CARD8) /* sizeof major_opcode */ + + sizeof(CARD8) /* sizeof minor_opcode */ + + sizeof(INT16) /* sizeof length */ + + XIM_PAD(len); /* sizeof pad */ + buf += len; + } + + return True; +} + +Private Bool +_XimQueryExtensionCheck( + Xim im, + INT16 len, + XPointer data, + XPointer arg) +{ + CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE); + CARD8 major_opcode = *((CARD8 *)data); + CARD8 minor_opcode = *((CARD8 *)data + 1); + XIMID imid = buf_s[0]; + + if ((major_opcode == XIM_QUERY_EXTENSION_REPLY) + && (minor_opcode == 0) + && (imid == im->private.proto.imid)) + return True; + if ((major_opcode == XIM_ERROR) + && (minor_opcode == 0) + && (buf_s[2] & XIM_IMID_VALID) + && (imid == im->private.proto.imid)) + return True; + return False; +} + +Public Bool +_XimExtension( + Xim im) +{ + CARD8 *buf; + CARD16 *buf_s; + int buf_len; + INT16 len; + CARD32 reply32[BUFSIZE/4]; + char *reply = (char *)reply32; + XPointer preply; + int buf_size; + int ret_code; + int idx; + + if (!(len = _XimCheckExtensionListSize())) + return True; + + buf_len = XIM_HEADER_SIZE + + sizeof(CARD16) + + sizeof(INT16) + + len + + XIM_PAD(len); + + if (!(buf = (CARD8 *)Xmalloc(buf_len))) + return False; + buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE]; + + buf_s[0] = im->private.proto.imid; /* imid */ + buf_s[1] = len; /* length of Extensions */ + _XimSetExtensionList((CARD8 *)&buf_s[2]); + /* extensions supported */ + XIM_SET_PAD(&buf_s[2], len); /* pad */ + len += sizeof(CARD16) /* sizeof imid */ + + sizeof(INT16); /* sizeof length of extensions */ + + _XimSetHeader((XPointer)buf, XIM_QUERY_EXTENSION, 0, &len); + if (!(_XimWrite(im, len, (XPointer)buf))) { + XFree(buf); + return False; + } + XFree(buf); + _XimFlush(im); + buf_size = BUFSIZE; + ret_code = _XimRead(im, &len, (XPointer)reply, buf_size, + _XimQueryExtensionCheck, 0); + if(ret_code == XIM_TRUE) { + preply = reply; + } else if(ret_code == XIM_OVERFLOW) { + if(len <= 0) { + preply = reply; + } else { + buf_size = len; + preply = (XPointer)Xmalloc(buf_size); + ret_code = _XimRead(im, &len, reply, buf_size, + _XimQueryExtensionCheck, 0); + if(ret_code != XIM_TRUE) { + Xfree(preply); + return False; + } + } + } else + return False; + buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE); + if (*((CARD8 *)preply) == XIM_ERROR) { + _XimProcError(im, 0, (XPointer)&buf_s[3]); + if(reply != preply) + Xfree(preply); + return False; + } + + if (!(_XimParseExtensionList(im, &buf_s[1]))) { + if(reply != preply) + Xfree(preply); + return False; + } + if(reply != preply) + Xfree(preply); + + if ((idx = _XimIsSupportExt(XIM_EXT_SET_EVENT_MASK_IDX)) >= 0) + _XimRegProtoIntrCallback(im, + extensions[idx].major_opcode, + extensions[idx].minor_opcode, + _XimExtSetEventMaskCallback, (XPointer)im); +#ifdef EXT_FORWARD + if ((idx = _XimIsSupportExt(XIM_EXT_FORWARD_KEYEVENT_IDX)) >= 0) + _XimRegProtoIntrCallback(im, + extensions[idx].major_opcode, + extensions[idx].minor_opcode, + _XimExtForwardKeyEventCallback, (XPointer)im); +#endif + + return True; +} + +#ifdef EXT_MOVE +/* flag of ExtenArgCheck */ +#define EXT_XNSPOTLOCATION (1L<<0) + +/* macro for ExtenArgCheck */ +#define SET_EXT_XNSPOTLOCATION(flag) (flag |= EXT_XNSPOTLOCATION) +#define IS_EXT_XNSPOTLOCATION(flag) (flag & EXT_XNSPOTLOCATION) + +/* length of XPoint attribute */ +#define XIM_Xpoint_length 12 + +Private Bool +_XimExtMove( + Xim im, + Xic ic, + CARD16 x, + CARD16 y) +{ + CARD32 buf32[BUFSIZE/4]; + CARD8 *buf = (CARD8 *)buf32; + CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE]; + INT16 len; + int idx; + + if ((idx = _XimIsSupportExt(XIM_EXT_MOVE_IDX)) < 0) + return False; + + buf_s[0] = im->private.proto.imid; /* imid */ + buf_s[1] = ic->private.proto.icid; /* icid */ + buf_s[2] = x; /* X */ + buf_s[3] = y; /* Y */ + len = sizeof(CARD16) /* sizeof imid */ + + sizeof(CARD16) /* sizeof icid */ + + sizeof(INT16) /* sizeof X */ + + sizeof(INT16); /* sizeof Y */ + + _XimSetHeader((XPointer)buf, extensions[idx].major_opcode, + extensions[idx].minor_opcode, &len); + if (!(_XimWrite(im, len, (XPointer)buf))) + return False; + _XimFlush(im); + return True; +} + +Public BITMASK32 +_XimExtenArgCheck( + XIMArg *arg) +{ + CARD32 flag = 0L; + if (!strcmp(arg->name, XNSpotLocation)) + SET_EXT_XNSPOTLOCATION(flag); + return flag; +} + +Public Bool +_XimExtenMove( + Xim im, + Xic ic, + CARD32 flag, + CARD16 *buf, + INT16 length) +{ + if ((IS_EXT_XNSPOTLOCATION(flag)) && (length == XIM_Xpoint_length)) + return _XimExtMove(im, ic, buf[4], buf[5]); + return False; +} +#endif /* EXT_MOVE */ diff --git a/libX11/modules/im/ximcp/imRm.c b/libX11/modules/im/ximcp/imRm.c index 936db876a..56c470b9f 100644 --- a/libX11/modules/im/ximcp/imRm.c +++ b/libX11/modules/im/ximcp/imRm.c @@ -2251,17 +2251,17 @@ _XimSetIMValueData( for(p = values; p->name != NULL; p++) { if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { - return p->value; + return p->name; } check = _XimCheckIMMode(res, XIM_SETIMVALUES); if(check == XIM_CHECK_INVALID) { continue; } else if (check == XIM_CHECK_ERROR) { - return p->value; + return p->name; } if(!_XimEncodeLocalIMAttr(res, top, p->value)) { - return p->value; + return p->name; } } return NULL; @@ -2281,17 +2281,17 @@ _XimGetIMValueData( for(p = values; p->name != NULL; p++) { if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) { - return p->value; + return p->name; } check = _XimCheckIMMode(res, XIM_GETIMVALUES); if(check == XIM_CHECK_INVALID) { continue; } else if (check == XIM_CHECK_ERROR) { - return p->value; + return p->name; } if(!_XimDecodeLocalIMAttr(res, top, p->value)) { - return p->value; + return p->name; } } return NULL; @@ -2886,13 +2886,13 @@ _XimSetICValueData( if(mode & XIM_PREEDIT_ATTR) { if (!_XimEncodeLocalPreeditValue(ic, res, (XPointer)p)) - return False; + return p->name; } else if(mode & XIM_STATUS_ATTR) { if (!_XimEncodeLocalStatusValue(ic, res, (XPointer)p)) - return False; + return p->name; } else { if (!_XimEncodeLocalTopValue(ic, res, (XPointer)p, flag)) - return False; + return p->name; } if(_XimEncodeLocalICAttr(ic, res, top, p, mode) == False) { return p->name; diff --git a/libX11/nls/en_US.UTF-8/Compose.pre b/libX11/nls/en_US.UTF-8/Compose.pre index 907720eab..d5b01b16e 100644 --- a/libX11/nls/en_US.UTF-8/Compose.pre +++ b/libX11/nls/en_US.UTF-8/Compose.pre @@ -110,6 +110,14 @@ XCOMM Spaces <Multi_key> <O> <E> : "Œ" OE # LATIN CAPITAL LIGATURE OE <Multi_key> <a> <e> : "æ" ae # LATIN SMALL LETTER AE <Multi_key> <A> <E> : "Æ" AE # LATIN CAPITAL LETTER AE +<Multi_key> <f> <f> : "ff" Ufb00 # LATIN SMALL LIGATURE FF +<Multi_key> <f> <i> : "fi" Ufb01 # LATIN SMALL LIGATURE FI +<Multi_key> <f> <l> : "fl" Ufb02 # LATIN SMALL LIGATURE FL +<Multi_key> <F> <i> : "ffi" Ufb03 # LATIN SMALL LIGATURE FFI +<Multi_key> <F> <l> : "ffl" Ufb04 # LATIN SMALL LIGATURE FFL +<Multi_key> <I> <J> : "IJ" U0132 # LATIN CAPITAL LIGATURE IJ +<Multi_key> <I> <j> : "IJ" U0132 # LATIN CAPITAL LIGATURE IJ +<Multi_key> <i> <j> : "ij" U0133 # LATIN SMALL LIGATURE IJ <Multi_key> <o> <o> : "°" degree # DEGREE SIGN @@ -193,6 +201,8 @@ XCOMM "₵" U20b5 CEDI SIGN XCOMM Long S <Multi_key> <f> <s> : "ſ" U017f # LATIN SMALL LETTER LONG S <Multi_key> <f> <S> : "ſ" U017f # LATIN SMALL LETTER LONG S +<dead_abovedot> <Multi_key> <f> <s> : "ẛ" U1e9b # LATIN SMALL LETTER LONG S WITH DOT ABOVE +<Multi_key> <dead_abovedot> <f> <s> : "ẛ" U1e9b # LATIN SMALL LETTER LONG S WITH DOT ABOVE XCOMM Dashes <Multi_key> <minus> <minus> <period> : "–" U2013 # EN DASH @@ -4173,6 +4183,7 @@ XCOMM Part 3 <Multi_key> <less> <minus> : "←" U2190 # LEFTWARDS ARROW <Multi_key> <minus> <greater> : "→" U2192 # RIGHTWARDS ARROW <Multi_key> <U2203> <U0338> : "∄" U2204 # THERE DOES NOT EXIST +<Multi_key> <braceleft> <braceright> : "∅" U2205 # EMPTY SET <Multi_key> <U2208> <U0338> : "∉" U2209 # NOT AN ELEMENT OF <Multi_key> <U220B> <U0338> : "∌" U220C # DOES NOT CONTAIN AS MEMBER <Multi_key> <U2223> <U0338> : "∤" U2224 # DOES NOT DIVIDE @@ -4219,6 +4230,7 @@ XCOMM Part 3 <Multi_key> <U22B3> <U0338> : "⋫" U22EB # DOES NOT CONTAIN AS NORMAL SUBGROUP <Multi_key> <U22B4> <U0338> : "⋬" U22EC # NOT NORMAL SUBGROUP OF OR EQUAL TO <Multi_key> <U22B5> <U0338> : "⋭" U22ED # DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL +<Multi_key> <d> <i> : "⌀" U2300 # DIAMETER SIGN <Multi_key> <parenleft> <1> <parenright> : "①" U2460 # CIRCLED DIGIT ONE <Multi_key> <parenleft> <KP_1> <parenright> : "①" U2460 # CIRCLED DIGIT ONE <Multi_key> <parenleft> <2> <parenright> : "②" U2461 # CIRCLED DIGIT TWO @@ -4972,6 +4984,7 @@ XCOMM <dead_hook> <p> : "ƥ" U01A5 # LATIN SMALL LETTER P WITH HOOK <dead_hook> <q> : "ʠ" U02A0 # LATIN SMALL LETTER Q WITH HOOK <dead_hook> <U025C> : "ɝ" U025D # LATIN SMALL LETTER REVERSED OPEN E WITH HOOK +<dead_hook> <r> : "ɼ" U027C # LATIN SMALL LETTER R WITH LONG LEG <dead_hook> <s> : "ʂ" U0282 # LATIN SMALL LETTER S WITH HOOK <dead_hook> <schwa> : "ɚ" U025A # LATIN SMALL LETTER SCHWA WITH HOOK <dead_hook> <T> : "Ƭ" U01AC # LATIN CAPITAL LETTER T WITH HOOK diff --git a/libX11/src/xlibi18n/XimintP.h b/libX11/src/xlibi18n/XimintP.h index 214621d66..14a7e6d5a 100644 --- a/libX11/src/xlibi18n/XimintP.h +++ b/libX11/src/xlibi18n/XimintP.h @@ -1,318 +1,310 @@ -/*
- * Copyright 1991, 1992 Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-/******************************************************************
-
- Copyright 1992, 1993, 1994 by FUJITSU LIMITED
- Copyright 1993, 1994 by Sony Corporation
-
-Permission to use, copy, modify, distribute, and sell this software and
-its documentation for any purpose is hereby granted without fee, provided
-that the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation, and that the name of FUJITSU LIMITED and Sony Corporation
-not be used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission. FUJITSU LIMITED and
-Sony Corporation makes no representations about the suitability of this
-software for any purpose. It is provided "as is" without express or
-implied warranty.
-
-FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
-TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS, IN NO EVENT SHALL FUJITSU LIMITED OR SONY CORPORATION BE LIABLE
-FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
-NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
-USE OR PERFORMANCE OF THIS SOFTWARE.
-
- Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
- Takashi Fujiwara FUJITSU LIMITED
- fujiwara@a80.tech.yk.fujitsu.co.jp
- Makoto Wakamatsu Sony Corporation
- makoto@sm.sony.co.jp
- Hiroyuki Miyamoto Digital Equipment Corporation
- miyamoto@jrd.dec.com
-
-******************************************************************/
-
-#ifndef _XIMINTP_H
-#define _XIMINTP_H
-
-#include "XimProto.h"
-#include "XlcPublic.h"
-
-/*
- * for protocol layer callback function
- */
-typedef Bool (*XimProtoIntrProc)(
- Xim, INT16, XPointer, XPointer
-);
-typedef struct _XimProtoIntrRec {
- XimProtoIntrProc func;
- CARD16 major_code;
- CARD16 minor_code;
- XPointer call_data;
- struct _XimProtoIntrRec *next;
-} XimProtoIntrRec;
-
-/*
- * for transport layer methods
- */
-typedef Bool (*XimTransConnectProc)(
- Xim
-);
-typedef Bool (*XimTransShutdownProc)(
- Xim
-);
-typedef Bool (*XimTransWriteProc)(
- Xim, INT16, XPointer
-);
-typedef Bool (*XimTransReadProc)(
- Xim, XPointer, int, int *
-);
-typedef void (*XimTransFlushProc)(
- Xim
-);
-typedef Bool (*XimTransRegDispatcher)(
- Xim, Bool (*)(Xim, INT16, XPointer, XPointer), XPointer
-);
-typedef Bool (*XimTransCallDispatcher)(
- Xim, INT16, XPointer
-);
-
-/*
- * private part of IM
- */
-typedef struct _XimProtoPrivateRec {
- /* The first fields are identical with XimCommonPrivateRec. */
- XlcConv ctom_conv;
- XlcConv ctow_conv;
- XlcConv ctoutf8_conv;
- XlcConv cstomb_conv;
- XlcConv cstowc_conv;
- XlcConv cstoutf8_conv;
- XlcConv ucstoc_conv;
- XlcConv ucstoutf8_conv;
-
- Window im_window;
- XIMID imid;
- CARD16 unused;
- XIMStyles *default_styles;
- CARD32 *im_onkeylist;
- CARD32 *im_offkeylist;
- BITMASK32 flag;
-
- BITMASK32 registed_filter_event;
- EVENTMASK forward_event_mask;
- EVENTMASK synchronous_event_mask;
-
- XimProtoIntrRec *intrproto;
- XIMResourceList im_inner_resources;
- unsigned int im_num_inner_resources;
- XIMResourceList ic_inner_resources;
- unsigned int ic_num_inner_resources;
- char *hold_data;
- int hold_data_len;
- char *locale_name;
- CARD16 protocol_major_version;
- CARD16 protocol_minor_version;
- XrmQuark *saved_imvalues;
- int num_saved_imvalues;
-
- /*
- * transport specific
- */
- XimTransConnectProc connect;
- XimTransShutdownProc shutdown;
- XimTransWriteProc write;
- XimTransReadProc read;
- XimTransFlushProc flush;
- XimTransRegDispatcher register_dispatcher;
- XimTransCallDispatcher call_dispatcher;
- XPointer spec;
-} XimProtoPrivateRec;
-
-/*
- * bit mask for the flag of XIMPrivateRec
- */
-#define SERVER_CONNECTED (1L)
-#define DYNAMIC_EVENT_FLOW (1L << 1)
-#define USE_AUTHORIZATION_FUNC (1L << 2)
-#ifdef XIM_CONNECTABLE
-#define DELAYBINDABLE (1L << 3)
-#define RECONNECTABLE (1L << 4)
-#endif /* XIM_CONNECTABLE */
-
-/*
- * macro for the flag of XIMPrivateRec
- */
-#define IS_SERVER_CONNECTED(im) \
- ((((Xim)im))->private.proto.flag & SERVER_CONNECTED)
-#define MARK_SERVER_CONNECTED(im) \
- ((((Xim)im))->private.proto.flag |= SERVER_CONNECTED)
-#define UNMARK_SERVER_CONNECTED(im) \
- ((((Xim)im))->private.proto.flag &= ~SERVER_CONNECTED)
-
-#define IS_DYNAMIC_EVENT_FLOW(im) \
- (((Xim)im)->private.proto.flag & DYNAMIC_EVENT_FLOW)
-#define MARK_DYNAMIC_EVENT_FLOW(im) \
- (((Xim)im)->private.proto.flag |= DYNAMIC_EVENT_FLOW)
-
-#define IS_USE_AUTHORIZATION_FUNC(im) \
- (((Xim)im)->private.proto.flag & USE_AUTHORIZATION_FUNC)
-#define MARK_USE_AUTHORIZATION_FUNC(im) \
- (((Xim)im)->private.proto.flag |= USE_AUTHORIZATION_FUNC)
-
-#ifdef XIM_CONNECTABLE
-#define IS_DELAYBINDABLE(im) \
- (((Xim)im)->private.proto.flag & DELAYBINDABLE)
-#define MARK_DELAYBINDABLE(im) \
- (((Xim)im)->private.proto.flag |= DELAYBINDABLE)
-
-#define IS_RECONNECTABLE(im) \
- (((Xim)im)->private.proto.flag & RECONNECTABLE)
-#define MARK_RECONNECTABLE(im) \
- (((Xim)im)->private.proto.flag |= RECONNECTABLE)
-
-#define IS_CONNECTABLE(im) \
- (((Xim)im)->private.proto.flag & (DELAYBINDABLE|RECONNECTABLE))
-#define UNMAKE_CONNECTABLE(im) \
- (((Xim)im)->private.proto.flag &= ~(DELAYBINDABLE|RECONNECTABLE))
-#endif /* XIM_CONNECTABLE */
-
-/*
- * bit mask for the register_filter_event of XIMPrivateRec/XICPrivateRec
- */
-#define KEYPRESS_MASK (1L)
-#define KEYRELEASE_MASK (1L << 1)
-#define DESTROYNOTIFY_MASK (1L << 2)
-
-typedef struct _XimCommitInfoRec {
- struct _XimCommitInfoRec *next;
- char *string;
- int string_len;
- KeySym *keysym;
- int keysym_len;
-} XimCommitInfoRec, *XimCommitInfo;
-
-typedef struct _XimPendingCallback {
- int major_opcode;
- Xim im;
- Xic ic;
- char *proto;
- int proto_len;
- struct _XimPendingCallback *next;
-} XimPendingCallbackRec, *XimPendingCallback;
-
-
-/*
- * private part of IC
- */
-typedef struct _XicProtoPrivateRec {
- XICID icid; /* ICID */
- CARD16 dmy;
- BITMASK32 flag; /* Input Mode */
-
- BITMASK32 registed_filter_event; /* registed filter mask */
- EVENTMASK forward_event_mask; /* forward event mask */
- EVENTMASK synchronous_event_mask;/* sync event mask */
- EVENTMASK filter_event_mask; /* negrect event mask */
- EVENTMASK intercept_event_mask; /* deselect event mask */
- EVENTMASK select_event_mask; /* select event mask */
-
- char *preedit_font; /* Base font name list */
- int preedit_font_length; /* length of base font name */
- char *status_font; /* Base font name list */
- int status_font_length; /* length of base font name */
-
- XimCommitInfo commit_info;
- XIMResourceList ic_resources;
- unsigned int ic_num_resources;
- XIMResourceList ic_inner_resources;
- unsigned int ic_num_inner_resources;
- XrmQuark *saved_icvalues;
- int num_saved_icvalues;
- XimPendingCallback pend_cb_que;
- Bool waitCallback;
-} XicProtoPrivateRec ;
-
-/*
- * bit mask for the flag of XICPrivateRec
- */
-#define IC_CONNECTED (1L)
-#define FABLICATED (1L << 1)
-#define NEED_SYNC_REPLY (1L << 2)
-#define FOCUSED (1L << 3)
-
-/*
- * macro for the flag of XICPrivateRec
- */
-#define IS_IC_CONNECTED(ic) \
- (((Xic)ic)->private.proto.flag & IC_CONNECTED)
-#define MARK_IC_CONNECTED(ic) \
- (((Xic)ic)->private.proto.flag |= IC_CONNECTED)
-#define UNMARK_IC_CONNECTED(ic) \
- (((Xic)ic)->private.proto.flag &= ~IC_CONNECTED)
-
-#define IS_FABLICATED(ic) \
- (((Xic)ic)->private.proto.flag & FABLICATED)
-#define MARK_FABLICATED(ic) \
- (((Xic)ic)->private.proto.flag |= FABLICATED)
-#define UNMARK_FABLICATED(ic) \
- (((Xic)ic)->private.proto.flag &= ~FABLICATED)
-
-#define IS_NEED_SYNC_REPLY(ic) \
- (((Xic)ic)->private.proto.flag & NEED_SYNC_REPLY)
-#define MARK_NEED_SYNC_REPLY(ic) \
- (((Xic)ic)->private.proto.flag |= NEED_SYNC_REPLY)
-#define UNMARK_NEED_SYNC_REPLY(ic) \
- (((Xic)ic)->private.proto.flag &= ~NEED_SYNC_REPLY)
-
-#define IS_FOCUSED(ic) \
- (((Xic)ic)->private.proto.flag & FOCUSED)
-#define MARK_FOCUSED(ic) \
- (((Xic)ic)->private.proto.flag |= FOCUSED)
-#define UNMARK_FOCUSED(ic) \
- (((Xic)ic)->private.proto.flag &= ~FOCUSED)
-
-/*
- * macro for the filter_event_mask of XICPrivateRec
- */
-#define IS_NEGLECT_EVENT(ic, mask) \
- (((Xic)ic)->private.proto.filter_event_mask & (mask))
-
-/*
- * macro for the forward_event_mask of XICPrivateRec
- */
-#define IS_FORWARD_EVENT(ic, mask) \
- (((Xic)ic)->private.proto.forward_event_mask & (mask))
-
-/*
- * macro for the synchronous_event_mask of XICPrivateRec
- */
-#define IS_SYNCHRONOUS_EVENT(ic, mask) \
- ((((Xic)ic)->private.proto.synchronous_event_mask & (mask)) ? True: False)
-
-#define XIM_MAXIMNAMELEN 64
-#define XIM_MAXLCNAMELEN 64
-
-#endif /* _XIMINTP_H */
+/* + * Copyright 1991, 1992 Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +/****************************************************************** + + Copyright 1992, 1993, 1994 by FUJITSU LIMITED + Copyright 1993, 1994 by Sony Corporation + +Permission to use, copy, modify, distribute, and sell this software and +its documentation for any purpose is hereby granted without fee, provided +that the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation, and that the name of FUJITSU LIMITED and Sony Corporation +not be used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. FUJITSU LIMITED and +Sony Corporation makes no representations about the suitability of this +software for any purpose. It is provided "as is" without express or +implied warranty. + +FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD +TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL FUJITSU LIMITED OR SONY CORPORATION BE LIABLE +FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE +USE OR PERFORMANCE OF THIS SOFTWARE. + + Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. + Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp + Makoto Wakamatsu Sony Corporation + makoto@sm.sony.co.jp + Hiroyuki Miyamoto Digital Equipment Corporation + miyamoto@jrd.dec.com + +******************************************************************/ + +#ifndef _XIMINTP_H +#define _XIMINTP_H + +#include "XimProto.h" +#include "XlcPublic.h" + +/* + * for protocol layer callback function + */ +typedef Bool (*XimProtoIntrProc)( + Xim, INT16, XPointer, XPointer +); +typedef struct _XimProtoIntrRec { + XimProtoIntrProc func; + CARD16 major_code; + CARD16 minor_code; + XPointer call_data; + struct _XimProtoIntrRec *next; +} XimProtoIntrRec; + +/* + * for transport layer methods + */ +typedef Bool (*XimTransConnectProc)( + Xim +); +typedef Bool (*XimTransShutdownProc)( + Xim +); +typedef Bool (*XimTransWriteProc)( + Xim, INT16, XPointer +); +typedef Bool (*XimTransReadProc)( + Xim, XPointer, int, int * +); +typedef void (*XimTransFlushProc)( + Xim +); +typedef Bool (*XimTransRegDispatcher)( + Xim, Bool (*)(Xim, INT16, XPointer, XPointer), XPointer +); +typedef Bool (*XimTransCallDispatcher)( + Xim, INT16, XPointer +); + +/* + * private part of IM + */ +typedef struct _XimProtoPrivateRec { + /* The first fields are identical with XimCommonPrivateRec. */ + XlcConv ctom_conv; + XlcConv ctow_conv; + XlcConv ctoutf8_conv; + XlcConv cstomb_conv; + XlcConv cstowc_conv; + XlcConv cstoutf8_conv; + XlcConv ucstoc_conv; + XlcConv ucstoutf8_conv; + + Window im_window; + XIMID imid; + CARD16 unused; + XIMStyles *default_styles; + CARD32 *im_onkeylist; + CARD32 *im_offkeylist; + BITMASK32 flag; + + BITMASK32 registed_filter_event; + EVENTMASK forward_event_mask; + EVENTMASK synchronous_event_mask; + + XimProtoIntrRec *intrproto; + XIMResourceList im_inner_resources; + unsigned int im_num_inner_resources; + XIMResourceList ic_inner_resources; + unsigned int ic_num_inner_resources; + char *hold_data; + int hold_data_len; + char *locale_name; + CARD16 protocol_major_version; + CARD16 protocol_minor_version; + XrmQuark *saved_imvalues; + int num_saved_imvalues; + + /* + * transport specific + */ + XimTransConnectProc connect; + XimTransShutdownProc shutdown; + XimTransWriteProc write; + XimTransReadProc read; + XimTransFlushProc flush; + XimTransRegDispatcher register_dispatcher; + XimTransCallDispatcher call_dispatcher; + XPointer spec; +} XimProtoPrivateRec; + +/* + * bit mask for the flag of XIMPrivateRec + */ +#define SERVER_CONNECTED (1L) +#define DYNAMIC_EVENT_FLOW (1L << 1) +#define USE_AUTHORIZATION_FUNC (1L << 2) +#ifdef XIM_CONNECTABLE +#define DELAYBINDABLE (1L << 3) +#define RECONNECTABLE (1L << 4) +#endif /* XIM_CONNECTABLE */ +#define FABRICATED (1L << 5) +#define NEED_SYNC_REPLY (1L << 6) + +/* + * macro for the flag of XIMPrivateRec + */ +#define IS_SERVER_CONNECTED(im) \ + ((((Xim)im))->private.proto.flag & SERVER_CONNECTED) +#define MARK_SERVER_CONNECTED(im) \ + ((((Xim)im))->private.proto.flag |= SERVER_CONNECTED) +#define UNMARK_SERVER_CONNECTED(im) \ + ((((Xim)im))->private.proto.flag &= ~SERVER_CONNECTED) + +#define IS_DYNAMIC_EVENT_FLOW(im) \ + (((Xim)im)->private.proto.flag & DYNAMIC_EVENT_FLOW) +#define MARK_DYNAMIC_EVENT_FLOW(im) \ + (((Xim)im)->private.proto.flag |= DYNAMIC_EVENT_FLOW) + +#define IS_USE_AUTHORIZATION_FUNC(im) \ + (((Xim)im)->private.proto.flag & USE_AUTHORIZATION_FUNC) +#define MARK_USE_AUTHORIZATION_FUNC(im) \ + (((Xim)im)->private.proto.flag |= USE_AUTHORIZATION_FUNC) + +#ifdef XIM_CONNECTABLE +#define IS_DELAYBINDABLE(im) \ + (((Xim)im)->private.proto.flag & DELAYBINDABLE) +#define MARK_DELAYBINDABLE(im) \ + (((Xim)im)->private.proto.flag |= DELAYBINDABLE) + +#define IS_RECONNECTABLE(im) \ + (((Xim)im)->private.proto.flag & RECONNECTABLE) +#define MARK_RECONNECTABLE(im) \ + (((Xim)im)->private.proto.flag |= RECONNECTABLE) + +#define IS_CONNECTABLE(im) \ + (((Xim)im)->private.proto.flag & (DELAYBINDABLE|RECONNECTABLE)) +#define UNMAKE_CONNECTABLE(im) \ + (((Xim)im)->private.proto.flag &= ~(DELAYBINDABLE|RECONNECTABLE)) +#endif /* XIM_CONNECTABLE */ + +#define IS_FABRICATED(im) \ + (((Xim)im)->private.proto.flag & FABRICATED) +#define MARK_FABRICATED(im) \ + (((Xim)im)->private.proto.flag |= FABRICATED) +#define UNMARK_FABRICATED(im) \ + (((Xim)im)->private.proto.flag &= ~FABRICATED) + +#define IS_NEED_SYNC_REPLY(im) \ + (((Xim)im)->private.proto.flag & NEED_SYNC_REPLY) +#define MARK_NEED_SYNC_REPLY(im) \ + (((Xim)im)->private.proto.flag |= NEED_SYNC_REPLY) +#define UNMARK_NEED_SYNC_REPLY(im) \ + (((Xim)im)->private.proto.flag &= ~NEED_SYNC_REPLY) + +/* + * bit mask for the register_filter_event of XIMPrivateRec/XICPrivateRec + */ +#define KEYPRESS_MASK (1L) +#define KEYRELEASE_MASK (1L << 1) +#define DESTROYNOTIFY_MASK (1L << 2) + +typedef struct _XimCommitInfoRec { + struct _XimCommitInfoRec *next; + char *string; + int string_len; + KeySym *keysym; + int keysym_len; +} XimCommitInfoRec, *XimCommitInfo; + +typedef struct _XimPendingCallback { + int major_opcode; + Xim im; + Xic ic; + char *proto; + int proto_len; + struct _XimPendingCallback *next; +} XimPendingCallbackRec, *XimPendingCallback; + + +/* + * private part of IC + */ +typedef struct _XicProtoPrivateRec { + XICID icid; /* ICID */ + CARD16 dmy; + BITMASK32 flag; /* Input Mode */ + + BITMASK32 registed_filter_event; /* registed filter mask */ + EVENTMASK forward_event_mask; /* forward event mask */ + EVENTMASK synchronous_event_mask;/* sync event mask */ + EVENTMASK filter_event_mask; /* negrect event mask */ + EVENTMASK intercept_event_mask; /* deselect event mask */ + EVENTMASK select_event_mask; /* select event mask */ + + char *preedit_font; /* Base font name list */ + int preedit_font_length; /* length of base font name */ + char *status_font; /* Base font name list */ + int status_font_length; /* length of base font name */ + + XimCommitInfo commit_info; + XIMResourceList ic_resources; + unsigned int ic_num_resources; + XIMResourceList ic_inner_resources; + unsigned int ic_num_inner_resources; + XrmQuark *saved_icvalues; + int num_saved_icvalues; + XimPendingCallback pend_cb_que; + Bool waitCallback; +} XicProtoPrivateRec ; + +/* + * bit mask for the flag of XICPrivateRec + */ +#define IC_CONNECTED (1L) + +/* + * macro for the flag of XICPrivateRec + */ +#define IS_IC_CONNECTED(ic) \ + (((Xic)ic)->private.proto.flag & IC_CONNECTED) +#define MARK_IC_CONNECTED(ic) \ + (((Xic)ic)->private.proto.flag |= IC_CONNECTED) +#define UNMARK_IC_CONNECTED(ic) \ + (((Xic)ic)->private.proto.flag &= ~IC_CONNECTED) + +/* + * macro for the filter_event_mask of XICPrivateRec + */ +#define IS_NEGLECT_EVENT(ic, mask) \ + (((Xic)ic)->private.proto.filter_event_mask & (mask)) + +/* + * macro for the forward_event_mask of XICPrivateRec + */ +#define IS_FORWARD_EVENT(ic, mask) \ + (((Xic)ic)->private.proto.forward_event_mask & (mask)) + +/* + * macro for the synchronous_event_mask of XICPrivateRec + */ +#define IS_SYNCHRONOUS_EVENT(ic, mask) \ + ((((Xic)ic)->private.proto.synchronous_event_mask & (mask)) ? True: False) + +#define XIM_MAXIMNAMELEN 64 +#define XIM_MAXLCNAMELEN 64 + +#endif /* _XIMINTP_H */ diff --git a/libXext/specs/dpmslib.xml b/libXext/specs/dpmslib.xml index 60565b536..ba5682eb8 100644 --- a/libXext/specs/dpmslib.xml +++ b/libXext/specs/dpmslib.xml @@ -85,7 +85,7 @@ These are mapped onto the X DPMS Extension like this: <title>DPMS Functions</title> -<funcsynopsis id='dpmsqueryextention'> +<funcsynopsis id='DPMSQueryExtention'> <funcprototype> <funcdef>Bool <function>DPMSQueryExtention</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> @@ -120,7 +120,7 @@ return value is FALSE, and the values of <emphasis remap='I'>error_base</emphasis> are undefined. </para> -<funcsynopsis id='dpmsgetversion'> +<funcsynopsis id='DPMSGetVersion'> <funcprototype> <funcdef>Status <function>DPMSGetVersion</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> @@ -156,7 +156,7 @@ incompatible changes, and the minor version will be incremented for small, upwardly compatible changes. </para> -<funcsynopsis id='dpmscapable'> +<funcsynopsis id='DPMSCapable'> <funcprototype> <funcdef>Bool <function>DPMSCapable</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> @@ -179,7 +179,7 @@ is capable of DPMS on one head, and incapable on another, the truth value of this function is defined by the X server implementation. </para> -<funcsynopsis id='dpmssettimeouts'> +<funcsynopsis id='DPMSSetTimeouts'> <funcprototype> <funcdef>Status <function>DPMSSetTimeouts</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> @@ -255,7 +255,7 @@ or equal to the timeout values of earlier modes. If inconsistent values are supplied, a BadValue error will result. </para> -<funcsynopsis id='dpmsgettimeouts'> +<funcsynopsis id='DPMSGetTimeouts'> <funcprototype> <funcdef>Status <function>DPMSGetTimeouts</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> @@ -307,7 +307,7 @@ inactivity in seconds before the third and final level of power savings is invoked. A value of zero indicates that this mode has been disabled. </para> -<funcsynopsis id='dpmsenable'> +<funcsynopsis id='DPMSEnable'> <funcprototype> <funcdef>Status <function>DPMSEnable</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> @@ -331,7 +331,7 @@ error is returned. If DPMSEnable is invoked on a display without support for DPMS, no change is made and no error is returned. </para> -<funcsynopsis id='dpmsdisable'> +<funcsynopsis id='DPMSDisable'> <funcprototype> <funcdef>Status <function>DPMSDisable</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> @@ -353,7 +353,7 @@ and no error is returned. If DPMSDisable is invoked on a display without support for DPMS, no change is made and no error is returned. </para> -<funcsynopsis id='dpmsforcelevel'> +<funcsynopsis id='DPMSForceLevel'> <funcprototype> <funcdef>Status <function>DPMSForceLevel</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> @@ -382,7 +382,7 @@ is disabled on the display, a BadMatch protocol error will result. <para>Status DPMSInfo(<emphasis remap='I'>display, power_level, state</emphasis>)</para> -<funcsynopsis id='dpmsinfo'> +<funcsynopsis id='DPMSInfo'> <funcprototype> <funcdef>Status <function>DPMSInfo</function></funcdef> <paramdef>Display <parameter>*display</parameter></paramdef> diff --git a/libXft/configure.ac b/libXft/configure.ac index 8df0cb032..61d6c4dbe 100644 --- a/libXft/configure.ac +++ b/libXft/configure.ac @@ -67,29 +67,10 @@ AC_SUBST([XFT_LT_VERSION]) PKG_CHECK_MODULES(XRENDER, xrender >= 0.8.2 x11) # Check freetype configuration -AC_ARG_WITH(freetype-config, [ --with-freetype-config=PROG Use FreeType configuration program PROG], freetype_config=$withval, freetype_config=auto) - -if test "$freetype_config" = "auto"; then - PKG_CHECK_MODULES(FREETYPE, freetype2, - freetype_config=no, freetype_config=yes) -fi - -if test "$freetype_config" = "yes"; then - AC_PATH_PROG(ft_config,freetype-config,no) - if test "$ft_config" = "no"; then - AC_MSG_ERROR([You must have freetype installed; see http://www.freetype.org/]) - fi -else - ft_config="$freetype_config" -fi - -if test "$freetype_config" != "no"; then - FREETYPE_CFLAGS="`$ft_config --cflags`" - FREETYPE_LIBS="`$ft_config --libs`" -fi +PKG_CHECK_MODULES(FREETYPE, freetype2 >= 2.1.6) # Check fontconfig configuration -PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.2) +PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.5.92) AC_SUBST(XRENDER_CFLAGS) AC_SUBST(XRENDER_LIBS) @@ -98,22 +79,6 @@ AC_SUBST(FREETYPE_LIBS) AC_SUBST(FONTCONFIG_CFLAGS) AC_SUBST(FONTCONFIG_LIBS) -fontconfig_save_libs="$LIBS" -fontconfig_save_cflags="$CFLAGS" -LIBS="$LIBS $FREETYPE_LIBS" -CFLAGS="$CFLAGS $FREETYPE_CFLAGS" -AC_CHECK_FUNCS(FT_Get_Next_Char FT_Get_BDF_Property FT_Get_PS_Font_Info FT_Has_PS_Glyph_Names FT_GlyphSlot_Embolden) -AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem, - HAVE_FT_BITMAP_SIZE_Y_PPEM=1, - HAVE_FT_BITMAP_SIZE_Y_PPEM=0, -[#include <ft2build.h> -#include FT_FREETYPE_H]) -AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM, - [FT_Bitmap_Size structure includes y_ppem field]) - -LIBS="$fontconfig_save_libs" -CFLAGS="$fontconfig_save_cflags" - if test "$VERSION" = "" ; then VERSION=$PACKAGE_VERSION; fi diff --git a/libXft/src/xftdpy.c b/libXft/src/xftdpy.c index 8f453b30d..c5b756e25 100644 --- a/libXft/src/xftdpy.c +++ b/libXft/src/xftdpy.c @@ -369,18 +369,16 @@ _XftDefaultInit (Display *dpy) goto bail1; if (!_XftDefaultInitInteger (dpy, pat, FC_RGBA)) goto bail1; + if (!_XftDefaultInitInteger (dpy, pat, FC_LCD_FILTER)) + goto bail1; if (!_XftDefaultInitBool (dpy, pat, FC_ANTIALIAS)) goto bail1; -#ifdef FC_EMBOLDEN if (!_XftDefaultInitBool (dpy, pat, FC_EMBOLDEN)) goto bail1; -#endif if (!_XftDefaultInitBool (dpy, pat, FC_AUTOHINT)) goto bail1; -#ifdef FC_HINT_STYLE if (!_XftDefaultInitInteger (dpy, pat, FC_HINT_STYLE)) goto bail1; -#endif if (!_XftDefaultInitBool (dpy, pat, FC_HINTING)) goto bail1; if (!_XftDefaultInitBool (dpy, pat, FC_MINSPACE)) @@ -471,28 +469,24 @@ XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern) XftDefaultGetBool (dpy, FC_ANTIALIAS, screen, True)); } -#ifdef FC_EMBOLDEN if (FcPatternGet (pattern, FC_EMBOLDEN, 0, &v) == FcResultNoMatch) { FcPatternAddBool (pattern, FC_EMBOLDEN, XftDefaultGetBool (dpy, FC_EMBOLDEN, screen, False)); } -#endif if (FcPatternGet (pattern, FC_HINTING, 0, &v) == FcResultNoMatch) { FcPatternAddBool (pattern, FC_HINTING, XftDefaultGetBool (dpy, FC_HINTING, screen, True)); } -#ifdef FC_HINT_STYLE if (FcPatternGet (pattern, FC_HINT_STYLE, 0, &v) == FcResultNoMatch) { FcPatternAddInteger (pattern, FC_HINT_STYLE, XftDefaultGetInteger (dpy, FC_HINT_STYLE, screen, FC_HINT_FULL)); } -#endif if (FcPatternGet (pattern, FC_AUTOHINT, 0, &v) == FcResultNoMatch) { FcPatternAddBool (pattern, FC_AUTOHINT, @@ -521,6 +515,12 @@ XftDefaultSubstitute (Display *dpy, int screen, FcPattern *pattern) XftDefaultGetInteger (dpy, FC_RGBA, screen, subpixel)); } + if (FcPatternGet (pattern, FC_LCD_FILTER, 0, &v) == FcResultNoMatch) + { + FcPatternAddInteger (pattern, FC_LCD_FILTER, + XftDefaultGetInteger (dpy, FC_LCD_FILTER, screen, + FC_LCD_DEFAULT)); + } if (FcPatternGet (pattern, FC_MINSPACE, 0, &v) == FcResultNoMatch) { FcPatternAddBool (pattern, FC_MINSPACE, diff --git a/libXft/src/xftfreetype.c b/libXft/src/xftfreetype.c index 3f8dfef8c..a3b833299 100644 --- a/libXft/src/xftfreetype.c +++ b/libXft/src/xftfreetype.c @@ -176,13 +176,8 @@ _XftUnlockFile (XftFtFile *f) _XftLockError ("too many file unlocks"); } -#if HAVE_FT_BITMAP_SIZE_Y_PPEM #define X_SIZE(face,i) ((face)->available_sizes[i].x_ppem) #define Y_SIZE(face,i) ((face)->available_sizes[i].y_ppem) -#else -#define X_SIZE(face,i) ((face)->available_sizes[i].width << 6) -#define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6) -#endif _X_HIDDEN FcBool _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix) @@ -224,12 +219,9 @@ _XftSetFace (XftFtFile *f, FT_F26Dot6 xsize, FT_F26Dot6 ysize, FT_Matrix *matrix * files have but a single strike per file, we can * simply try both sizes. */ - if ( -#if HAVE_FT_BITMAP_SIZE_Y_PPEM - FT_Set_Char_Size (face, face->available_sizes[best].x_ppem, + if (FT_Set_Char_Size (face, face->available_sizes[best].x_ppem, face->available_sizes[best].y_ppem, 0, 0) != 0 && -#endif FT_Set_Char_Size (face, face->available_sizes[best].width << 6, face->available_sizes[best].height << 6, 0, 0) != 0) @@ -379,9 +371,7 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi) double aspect; FcMatrix *font_matrix; FcBool hinting, vertical_layout, autohint, global_advance; -#ifdef FC_HINT_STYLE int hint_style; -#endif FcChar32 hash, *hashp; FT_Face face; int nhash; @@ -470,6 +460,19 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi) } /* + * Get lcd_filter value + */ + switch (FcPatternGetInteger (pattern, FC_LCD_FILTER, 0, &fi->lcd_filter)) { + case FcResultNoMatch: + fi->lcd_filter = FC_LCD_DEFAULT; + break; + case FcResultMatch: + break; + default: + goto bail1; + } + + /* * Get matrix and transform values */ switch (FcPatternGetMatrix (pattern, FC_MATRIX, 0, &font_matrix)) { @@ -542,7 +545,6 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi) goto bail1; } -#ifdef FC_EMBOLDEN switch (FcPatternGetBool (pattern, FC_EMBOLDEN, 0, &fi->embolden)) { case FcResultNoMatch: fi->embolden = FcFalse; @@ -552,11 +554,7 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi) default: goto bail1; } -#else - fi->embolden = FcFalse; -#endif -#ifdef FC_HINT_STYLE switch (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style)) { case FcResultNoMatch: hint_style = FC_HINT_FULL; @@ -566,12 +564,9 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi) default: goto bail1; } -#endif if (!hinting -#ifdef FC_HINT_STYLE || hint_style == FC_HINT_NONE -#endif ) { fi->load_flags |= FT_LOAD_NO_HINTING; @@ -582,15 +577,11 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi) */ if (fi->antialias) { -#ifdef FC_HINT_STYLE -#ifdef FT_LOAD_TARGET_LIGHT if (FC_HINT_NONE < hint_style && hint_style < FC_HINT_FULL) { fi->load_flags |= FT_LOAD_TARGET_LIGHT; } else -#endif -#endif { /* autohinter will snap stems to integer widths, when * the LCD targets are used. @@ -598,23 +589,17 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi) switch (fi->rgba) { case FC_RGBA_RGB: case FC_RGBA_BGR: -#ifdef FT_LOAD_TARGET_LCD fi->load_flags |= FT_LOAD_TARGET_LCD; -#endif break; case FC_RGBA_VRGB: case FC_RGBA_VBGR: -#ifdef FT_LOAD_TARGET_LCD_V fi->load_flags |= FT_LOAD_TARGET_LCD_V; -#endif break; } } } -#ifdef FT_LOAD_TARGET_MONO else fi->load_flags |= FT_LOAD_TARGET_MONO; -#endif /* set vertical layout if requested */ switch (FcPatternGetBool (pattern, FC_VERTICAL_LAYOUT, 0, &vertical_layout)) { diff --git a/libXft/src/xftglyphs.c b/libXft/src/xftglyphs.c index e0cfdea8a..2639d12aa 100644 --- a/libXft/src/xftglyphs.c +++ b/libXft/src/xftglyphs.c @@ -22,27 +22,12 @@ #include "xftint.h" #include <freetype/ftoutln.h> +#include <freetype/ftlcdfil.h> #if HAVE_FT_GLYPHSLOT_EMBOLDEN #include <freetype/ftsynth.h> #endif -static const int filters[3][3] = { - /* red */ -#if 0 -{ 65538*4/7,65538*2/7,65538*1/7 }, - /* green */ -{ 65536*1/4, 65536*2/4, 65537*1/4 }, - /* blue */ -{ 65538*1/7,65538*2/7,65538*4/7 }, -#endif -{ 65538*9/13,65538*3/13,65538*1/13 }, - /* green */ -{ 65538*1/6, 65538*4/6, 65538*1/6 }, - /* blue */ -{ 65538*1/13,65538*3/13,65538*9/13 }, -}; - /* * Validate the memory info for a font */ @@ -69,6 +54,293 @@ _XftFontValidateMemory (Display *dpy, XftFont *public) font->glyph_memory, glyph_memory); } +/* we sometimes need to convert the glyph bitmap in a FT_GlyphSlot + * into a different format. For example, we want to convert a + * FT_PIXEL_MODE_LCD or FT_PIXEL_MODE_LCD_V bitmap into a 32-bit + * ARGB or ABGR bitmap. + * + * this function prepares a target descriptor for this operation. + * + * input :: target bitmap descriptor. The function will set its + * 'width', 'rows' and 'pitch' fields, and only these + * + * slot :: the glyph slot containing the source bitmap. this + * function assumes that slot->format == FT_GLYPH_FORMAT_BITMAP + * + * mode :: the requested final rendering mode. supported values are + * MONO, NORMAL (i.e. gray), LCD and LCD_V + * + * the function returns the size in bytes of the corresponding buffer, + * it's up to the caller to allocate the corresponding memory block + * before calling _fill_xrender_bitmap + * + * it also returns -1 in case of error (e.g. incompatible arguments, + * like trying to convert a gray bitmap into a monochrome one) + */ +static int +_compute_xrender_bitmap_size( FT_Bitmap* target, + FT_GlyphSlot slot, + FT_Render_Mode mode ) +{ + FT_Bitmap* ftbit; + int width, height, pitch; + + if ( slot->format != FT_GLYPH_FORMAT_BITMAP ) + return -1; + + // compute the size of the final bitmap + ftbit = &slot->bitmap; + + width = ftbit->width; + height = ftbit->rows; + pitch = (width+3) & ~3; + + switch ( ftbit->pixel_mode ) + { + case FT_PIXEL_MODE_MONO: + if ( mode == FT_RENDER_MODE_MONO ) + { + pitch = (((width+31) & ~31) >> 3); + break; + } + /* fall-through */ + + case FT_PIXEL_MODE_GRAY: + if ( mode == FT_RENDER_MODE_LCD || + mode == FT_RENDER_MODE_LCD_V ) + { + /* each pixel is replicated into a 32-bit ARGB value */ + pitch = width*4; + } + break; + + case FT_PIXEL_MODE_LCD: + if ( mode != FT_RENDER_MODE_LCD ) + return -1; + + /* horz pixel triplets are packed into 32-bit ARGB values */ + width /= 3; + pitch = width*4; + break; + + case FT_PIXEL_MODE_LCD_V: + if ( mode != FT_RENDER_MODE_LCD_V ) + return -1; + + /* vert pixel triplets are packed into 32-bit ARGB values */ + height /= 3; + pitch = width*4; + break; + + default: /* unsupported source format */ + return -1; + } + + target->width = width; + target->rows = height; + target->pitch = pitch; + target->buffer = NULL; + + return pitch * height; +} + +/* this functions converts the glyph bitmap found in a FT_GlyphSlot + * into a different format (see _compute_xrender_bitmap_size) + * + * you should call this function after _compute_xrender_bitmap_size + * + * target :: target bitmap descriptor. Note that its 'buffer' pointer + * must point to memory allocated by the caller + * + * slot :: the glyph slot containing the source bitmap + * + * mode :: the requested final rendering mode + * + * bgr :: boolean, set if BGR or VBGR pixel ordering is needed + */ +static void +_fill_xrender_bitmap( FT_Bitmap* target, + FT_GlyphSlot slot, + FT_Render_Mode mode, + int bgr ) +{ + FT_Bitmap* ftbit = &slot->bitmap; + + { + unsigned char* srcLine = ftbit->buffer; + unsigned char* dstLine = target->buffer; + int src_pitch = ftbit->pitch; + int width = target->width; + int height = target->rows; + int pitch = target->pitch; + int subpixel; + int h; + + subpixel = ( mode == FT_RENDER_MODE_LCD || + mode == FT_RENDER_MODE_LCD_V ); + + if ( src_pitch < 0 ) + srcLine -= src_pitch*(ftbit->rows-1); + + switch ( ftbit->pixel_mode ) + { + case FT_PIXEL_MODE_MONO: + if ( subpixel ) /* convert mono to ARGB32 values */ + { + for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch ) + { + int x; + + for ( x = 0; x < width; x++ ) + { + if ( srcLine[(x >> 3)] & (0x80 >> (x & 7)) ) + ((unsigned int*)dstLine)[x] = 0xffffffffU; + } + } + } + else if ( mode == FT_RENDER_MODE_NORMAL ) /* convert mono to 8-bit gray */ + { + for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch ) + { + int x; + + for ( x = 0; x < width; x++ ) + { + if ( srcLine[(x >> 3)] & (0x80 >> (x & 7)) ) + dstLine[x] = 0xff; + } + } + } + else /* copy mono to mono */ + { + int bytes = (width+7) >> 3; + + for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch ) + memcpy( dstLine, srcLine, bytes ); + } + break; + + case FT_PIXEL_MODE_GRAY: + if ( subpixel ) /* convert gray to ARGB32 values */ + { + for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch ) + { + int x; + unsigned int* dst = (unsigned int*)dstLine; + + for ( x = 0; x < width; x++ ) + { + unsigned int pix = srcLine[x]; + + pix |= (pix << 8); + pix |= (pix << 16); + + dst[x] = pix; + } + } + } + else /* copy gray into gray */ + { + for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch ) + memcpy( dstLine, srcLine, width ); + } + break; + + case FT_PIXEL_MODE_LCD: + if ( !bgr ) + { + /* convert horizontal RGB into ARGB32 */ + for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch ) + { + int x; + unsigned char* src = srcLine; + unsigned int* dst = (unsigned int*)dstLine; + + for ( x = 0; x < width; x++, src += 3 ) + { + unsigned int pix; + + pix = ((unsigned int)src[0] << 16) | + ((unsigned int)src[1] << 8) | + ((unsigned int)src[2] ) | + ((unsigned int)src[1] << 24) ; + + dst[x] = pix; + } + } + } + else + { + /* convert horizontal BGR into ARGB32 */ + for ( h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch ) + { + int x; + unsigned char* src = srcLine; + unsigned int* dst = (unsigned int*)dstLine; + + for ( x = 0; x < width; x++, src += 3 ) + { + unsigned int pix; + + pix = ((unsigned int)src[2] << 16) | + ((unsigned int)src[1] << 8) | + ((unsigned int)src[0] ) | + ((unsigned int)src[1] << 24) ; + + dst[x] = pix; + } + } + } + break; + + default: /* FT_PIXEL_MODE_LCD_V */ + /* convert vertical RGB into ARGB32 */ + if ( !bgr ) + { + for ( h = height; h > 0; h--, srcLine += 3*src_pitch, dstLine += pitch ) + { + int x; + unsigned char* src = srcLine; + unsigned int* dst = (unsigned int*)dstLine; + + for ( x = 0; x < width; x++, src += 1 ) + { + unsigned int pix; + + pix = ((unsigned int)src[0] << 16) | + ((unsigned int)src[src_pitch] << 8) | + ((unsigned int)src[src_pitch*2] ) | + ((unsigned int)src[src_pitch] << 24) ; + + dst[x] = pix; + } + } + } + else + { + for ( h = height; h > 0; h--, srcLine += 3*src_pitch, dstLine += pitch ) + { + int x; + unsigned char* src = srcLine; + unsigned int* dst = (unsigned int*)dstLine; + + for ( x = 0; x < width; x++, src += 1 ) + { + unsigned int pix; + + pix = ((unsigned int)src[src_pitch*2] << 16) | + ((unsigned int)src[src_pitch] << 8) | + ((unsigned int)src[0] ) | + ((unsigned int)src[src_pitch] << 24) ; + + dst[x] = pix; + } + } + } + } + } +} + _X_EXPORT void XftFontLoadGlyphs (Display *dpy, XftFont *pub, @@ -86,21 +358,15 @@ XftFontLoadGlyphs (Display *dpy, unsigned char bufLocal[4096]; unsigned char *bufBitmap = bufLocal; int bufSize = sizeof (bufLocal); - int size, pitch; - unsigned char bufLocalRgba[4096]; - unsigned char *bufBitmapRgba = bufLocalRgba; - int bufSizeRgba = sizeof (bufLocalRgba); - int sizergba, pitchrgba, widthrgba; + int size; int width; int height; int left, right, top, bottom; - int hmul = 1; - int vmul = 1; - FT_Bitmap ftbit; - FT_Matrix matrix; + FT_Bitmap* ftbit; + FT_Bitmap local; FT_Vector vector; - Bool subpixel = False; FT_Face face; + FT_Render_Mode mode = FT_RENDER_MODE_MONO; if (!info) return; @@ -110,24 +376,19 @@ XftFontLoadGlyphs (Display *dpy, if (!face) return; - matrix.xx = matrix.yy = 0x10000L; - matrix.xy = matrix.yx = 0; - if (font->info.antialias) { switch (font->info.rgba) { case FC_RGBA_RGB: case FC_RGBA_BGR: - matrix.xx *= 3; - subpixel = True; - hmul = 3; + mode = FT_RENDER_MODE_LCD; break; case FC_RGBA_VRGB: case FC_RGBA_VBGR: - matrix.yy *= 3; - vmul = 3; - subpixel = True; + mode = FT_RENDER_MODE_LCD_V; break; + default: + mode = FT_RENDER_MODE_NORMAL; } } @@ -148,6 +409,8 @@ XftFontLoadGlyphs (Display *dpy, if (xftg->glyph_memory) continue; + FT_Library_SetLcdFilter( _XftFTlibrary, font->info.lcd_filter); + error = FT_Load_Glyph (face, glyphindex, font->info.load_flags); if (error) { @@ -181,7 +444,7 @@ XftFontLoadGlyphs (Display *dpy, /* * Compute glyph metrics from FreeType information */ - if(font->info.transform && glyphslot->format != ft_glyph_format_bitmap) + if(font->info.transform && glyphslot->format != FT_GLYPH_FORMAT_BITMAP) { /* * calculate the true width by transforming all four corners. @@ -260,17 +523,14 @@ XftFontLoadGlyphs (Display *dpy, } } - if (font->info.antialias) - pitch = (width * hmul + 3) & ~3; - else - pitch = ((width + 31) & ~31) >> 3; - - size = pitch * height * vmul; + if ( glyphslot->format != FT_GLYPH_FORMAT_BITMAP ) + { + error = FT_Render_Glyph( face->glyph, mode ); + if (error) + continue; + } - xftg->metrics.width = width; - xftg->metrics.height = height; - xftg->metrics.x = -TRUNC(left); - xftg->metrics.y = TRUNC(top); + FT_Library_SetLcdFilter( _XftFTlibrary, FT_LCD_FILTER_NONE ); if (font->info.spacing >= FC_MONO) { @@ -310,103 +570,8 @@ XftFontLoadGlyphs (Display *dpy, xftg->metrics.yOff = -TRUNC(ROUND(glyphslot->advance.y)); } - /* - * If the glyph is relatively large (> 1% of server memory), - * don't send it until necessary - */ - if (!need_bitmaps && size > info->max_glyph_memory / 100) - continue; - - /* - * Make sure there's enough buffer space for the glyph - */ - if (size > bufSize) - { - if (bufBitmap != bufLocal) - free (bufBitmap); - bufBitmap = (unsigned char *) malloc (size); - if (!bufBitmap) - continue; - bufSize = size; - } - memset (bufBitmap, 0, size); - - /* - * Rasterize into the local buffer - */ - switch (glyphslot->format) { - case ft_glyph_format_outline: - ftbit.width = width * hmul; - ftbit.rows = height * vmul; - ftbit.pitch = pitch; - if (font->info.antialias) - ftbit.pixel_mode = ft_pixel_mode_grays; - else - ftbit.pixel_mode = ft_pixel_mode_mono; - - ftbit.buffer = bufBitmap; - - if (subpixel) - FT_Outline_Transform (&glyphslot->outline, &matrix); - - FT_Outline_Translate ( &glyphslot->outline, -left*hmul, -bottom*vmul ); - - FT_Outline_Get_Bitmap( _XftFTlibrary, &glyphslot->outline, &ftbit ); - break; - case ft_glyph_format_bitmap: - if (font->info.antialias) - { - unsigned char *srcLine, *dstLine; - int height; - int x; - int h, v; - - srcLine = glyphslot->bitmap.buffer; - dstLine = bufBitmap; - height = glyphslot->bitmap.rows; - while (height--) - { - for (x = 0; x < glyphslot->bitmap.width; x++) - { - /* always MSB bitmaps */ - unsigned char a = ((srcLine[x >> 3] & (0x80 >> (x & 7))) ? - 0xff : 0x00); - if (subpixel) - { - for (v = 0; v < vmul; v++) - for (h = 0; h < hmul; h++) - dstLine[v * pitch + x*hmul + h] = a; - } - else - dstLine[x] = a; - } - dstLine += pitch * vmul; - srcLine += glyphslot->bitmap.pitch; - } - } - else - { - unsigned char *srcLine, *dstLine; - int h, bytes; - - srcLine = glyphslot->bitmap.buffer; - dstLine = bufBitmap; - h = glyphslot->bitmap.rows; - bytes = (glyphslot->bitmap.width + 7) >> 3; - while (h--) - { - memcpy (dstLine, srcLine, bytes); - dstLine += pitch; - srcLine += glyphslot->bitmap.pitch; - } - } - break; - default: - if (XftDebug() & XFT_DBG_GLYPH) - printf ("glyph %d is not in a usable format\n", - (int) glyphindex); - continue; - } + width = ftbit->width; + height = ftbit->rows; if (XftDebug() & XFT_DBG_GLYPH) { @@ -423,29 +588,72 @@ XftFontLoadGlyphs (Display *dpy, int x, y; unsigned char *line; - line = bufBitmap; - for (y = 0; y < height * vmul; y++) + line = ftbit->buffer; + if (ftbit->pitch < 0) + line -= ftbit->pitch*(height-1); + + for (y = 0; y < height; y++) { if (font->info.antialias) { static const char den[] = { " .:;=+*#" }; - for (x = 0; x < pitch; x++) + for (x = 0; x < width; x++) printf ("%c", den[line[x] >> 5]); } else { - for (x = 0; x < pitch * 8; x++) + for (x = 0; x < width * 8; x++) { printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' '); } } printf ("|\n"); - line += pitch; + line += ftbit->pitch; } printf ("\n"); } } + size = _compute_xrender_bitmap_size( &local, glyphslot, mode ); + if ( size < 0 ) + continue; + + xftg->metrics.width = local.width; + xftg->metrics.height = local.rows; + xftg->metrics.x = - glyphslot->bitmap_left; + xftg->metrics.y = glyphslot->bitmap_top; + + /* + * If the glyph is relatively large (> 1% of server memory), + * don't send it until necessary. + */ + if (!need_bitmaps && size > info->max_glyph_memory / 100) + continue; + + /* + * Make sure there is enough buffer space for the glyph. + */ + if (size > bufSize) + { + if (bufBitmap != bufLocal) + free (bufBitmap); + bufBitmap = (unsigned char *) malloc (size); + if (!bufBitmap) + continue; + bufSize = size; + } + memset (bufBitmap, 0, size); + + local.buffer = bufBitmap; + + _fill_xrender_bitmap( &local, glyphslot, mode, + (font->info.rgba == FC_RGBA_BGR || + font->info.rgba == FC_RGBA_VBGR ) ); + + /* + * Copy or convert into local buffer. + */ + /* * Use the glyph index as the wire encoding; it * might be more efficient for some locales to map @@ -455,146 +663,51 @@ XftFontLoadGlyphs (Display *dpy, */ glyph = (Glyph) glyphindex; - if (subpixel) + xftg->glyph_memory = size + sizeof (XftGlyph); + if (font->format) { - int x, y; - unsigned char *in_line, *out_line, *in; - unsigned int *out; - unsigned int red, green, blue; - int rf, gf, bf; - int s; - int o, os; - - /* - * Filter the glyph to soften the color fringes - */ - widthrgba = width; - pitchrgba = (widthrgba * 4 + 3) & ~3; - sizergba = pitchrgba * height; - - os = 1; - switch (font->info.rgba) { - case FC_RGBA_VRGB: - os = pitch; - case FC_RGBA_RGB: - default: - rf = 0; - gf = 1; - bf = 2; - break; - case FC_RGBA_VBGR: - os = pitch; - case FC_RGBA_BGR: - bf = 0; - gf = 1; - rf = 2; - break; - } - if (sizergba > bufSizeRgba) - { - if (bufBitmapRgba != bufLocalRgba) - free (bufBitmapRgba); - bufBitmapRgba = (unsigned char *) malloc (sizergba); - if (!bufBitmapRgba) - continue; - bufSizeRgba = sizergba; - } - memset (bufBitmapRgba, 0, sizergba); - in_line = bufBitmap; - out_line = bufBitmapRgba; - for (y = 0; y < height; y++) + if (!font->glyphset) + font->glyphset = XRenderCreateGlyphSet (dpy, font->format); + if ( mode == FT_RENDER_MODE_MONO ) { - in = in_line; - out = (unsigned int *) out_line; - in_line += pitch * vmul; - out_line += pitchrgba; - for (x = 0; x < width * hmul; x += hmul) + /* swap bits in each byte */ + if (BitmapBitOrder (dpy) != MSBFirst) { - red = green = blue = 0; - o = 0; - for (s = 0; s < 3; s++) + unsigned char *line = (unsigned char*)bufBitmap; + int i = size; + + while (i--) { - red += filters[rf][s]*in[x+o]; - green += filters[gf][s]*in[x+o]; - blue += filters[bf][s]*in[x+o]; - o += os; + int c = *line; + c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55); + c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33); + c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f); + *line++ = c; } - red = red / 65536; - green = green / 65536; - blue = blue / 65536; - *out++ = (green << 24) | (red << 16) | (green << 8) | blue; } } - - xftg->glyph_memory = sizergba + sizeof (XftGlyph); - if (font->format) + else if ( mode != FT_RENDER_MODE_NORMAL ) { - if (!font->glyphset) - font->glyphset = XRenderCreateGlyphSet (dpy, font->format); + /* invert ARGB <=> BGRA */ if (ImageByteOrder (dpy) != XftNativeByteOrder ()) - XftSwapCARD32 ((CARD32 *) bufBitmapRgba, sizergba >> 2); - XRenderAddGlyphs (dpy, font->glyphset, &glyph, - &xftg->metrics, 1, - (char *) bufBitmapRgba, sizergba); - } - else - { - if (sizergba) - { - xftg->bitmap = malloc (sizergba); - if (xftg->bitmap) - memcpy (xftg->bitmap, bufBitmapRgba, sizergba); - } - else - xftg->bitmap = NULL; + XftSwapCARD32 ((CARD32 *) bufBitmap, size >> 2); } + XRenderAddGlyphs (dpy, font->glyphset, &glyph, + &xftg->metrics, 1, + (char *) bufBitmap, size); } else { - xftg->glyph_memory = size + sizeof (XftGlyph); - if (font->format) + if (size) { - /* - * swap bit order around; FreeType is always MSBFirst - */ - if (!font->info.antialias) - { - if (BitmapBitOrder (dpy) != MSBFirst) - { - unsigned char *line; - unsigned char c; - int i; - - line = (unsigned char *) bufBitmap; - i = size; - while (i--) - { - c = *line; - c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55); - c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33); - c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f); - *line++ = c; - } - } - } - if (!font->glyphset) - font->glyphset = XRenderCreateGlyphSet (dpy, font->format); - XRenderAddGlyphs (dpy, font->glyphset, &glyph, - &xftg->metrics, 1, - (char *) bufBitmap, size); + xftg->bitmap = malloc (size); + if (xftg->bitmap) + memcpy (xftg->bitmap, bufBitmap, size); } else - { - if (size) - { - xftg->bitmap = malloc (size); - if (xftg->bitmap) - memcpy (xftg->bitmap, bufBitmap, size); - } - else - xftg->bitmap = NULL; - } + xftg->bitmap = NULL; } + font->glyph_memory += xftg->glyph_memory; info->glyph_memory += xftg->glyph_memory; if (XftDebug() & XFT_DBG_CACHE) @@ -605,8 +718,6 @@ XftFontLoadGlyphs (Display *dpy, } if (bufBitmap != bufLocal) free (bufBitmap); - if (bufBitmapRgba != bufLocalRgba) - free (bufBitmapRgba); XftUnlockFace (&font->public); } diff --git a/libXft/src/xftint.h b/libXft/src/xftint.h index eb9257ea7..5cb57aeab 100644 --- a/libXft/src/xftint.h +++ b/libXft/src/xftint.h @@ -145,6 +145,7 @@ struct _XftFontInfo { FcBool antialias; /* doing antialiasing */ FcBool embolden; /* force emboldening */ int rgba; /* subpixel order */ + int lcd_filter; /* lcd filter */ FT_Matrix matrix; /* glyph transformation matrix */ FcBool transform; /* non-identify matrix? */ FT_Int load_flags; /* glyph load flags */ diff --git a/libxcb/xcb-proto/src/xtest.xml b/libxcb/xcb-proto/src/xtest.xml index e481929b7..7f0b2623c 100644 --- a/libxcb/xcb-proto/src/xtest.xml +++ b/libxcb/xcb-proto/src/xtest.xml @@ -88,8 +88,8 @@ authorization from the authors. <field type="CARD32" name="time" /> <field type="WINDOW" name="root" /> <pad bytes="8" /> - <field type="CARD16" name="rootX" /> - <field type="CARD16" name="rootY" /> + <field type="INT16" name="rootX" /> + <field type="INT16" name="rootY" /> <pad bytes="7" /> <!-- Version 2.2: XInput device --> <field type="CARD8" name="deviceid" /> diff --git a/mesalib/configs/autoconf.in b/mesalib/configs/autoconf.in index 9bbafc93a..96fe5da87 100644 --- a/mesalib/configs/autoconf.in +++ b/mesalib/configs/autoconf.in @@ -64,8 +64,8 @@ FLEX = @FLEX@ BISON = @BISON@ # Library names (base name) -GL_LIB = GL -GLU_LIB = GLU +GL_LIB = @GL_LIB@ +GLU_LIB = @GLU_LIB@ GLW_LIB = GLw OSMESA_LIB = @OSMESA_LIB@ GLESv1_CM_LIB = GLESv1_CM diff --git a/mesalib/configure.ac b/mesalib/configure.ac index 49e81ad17..0864b55af 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -172,6 +172,10 @@ if test "x$GCC" = xyes; then # Work around aliasing bugs - developers should comment this out CFLAGS="$CFLAGS -fno-strict-aliasing" + + # gcc's builtin memcmp is slower than glibc's + # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 + CFLAGS="$CFLAGS -fno-builtin-memcmp" fi if test "x$GXX" = xyes; then CXXFLAGS="$CXXFLAGS -Wall" @@ -191,6 +195,10 @@ if test "x$GXX" = xyes; then # Work around aliasing bugs - developers should comment this out CXXFLAGS="$CXXFLAGS -fno-strict-aliasing" + + # gcc's builtin memcmp is slower than glibc's + # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 + CXXFLAGS="$CXXFLAGS -fno-builtin-memcmp" fi dnl even if the compiler appears to support it, using visibility attributes isn't @@ -342,6 +350,28 @@ else fi dnl +dnl Mangled Mesa support +dnl +AC_ARG_ENABLE([mangling], + [AS_HELP_STRING([--enable-mangling], + [enable mangled symbols and library name @<:@default=disabled@:>@])], + [enable_mangling="${enableval}"], + [enable_mangling=no] +) +GL_LIB="GL" +GLU_LIB="GLU" +OSMESA_LIB="OSMesa" +if test "x${enable_mangling}" = "xyes" ; then + DEFINES="${DEFINES} -DUSE_MGL_NAMESPACE" + GL_LIB="MangledGL" + GLU_LIB="MangledGLU" + OSMESA_LIB="MangledOSMesa" +fi +AC_SUBST([GL_LIB]) +AC_SUBST([GLU_LIB]) +AC_SUBST([OSMESA_LIB]) + +dnl dnl potentially-infringing-but-nobody-knows-for-sure stuff dnl AC_ARG_ENABLE([texture-float], @@ -1280,17 +1310,16 @@ if test "x$osmesa_bits" != x8; then fi case "x$osmesa_bits" in x8) - OSMESA_LIB=OSMesa + OSMESA_LIB="${OSMESA_LIB}" ;; x16|x32) - OSMESA_LIB="OSMesa$osmesa_bits" + OSMESA_LIB="${OSMESA_LIB}$osmesa_bits" DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31" ;; *) AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option]) ;; esac -AC_SUBST([OSMESA_LIB]) if test "x$enable_osmesa" = xyes; then # only link libraries with osmesa if shared @@ -1719,7 +1748,7 @@ if test "x$enable_gallium_llvm" = xyes; then if test "x$LLVM_CONFIG" != xno; then LLVM_VERSION=`$LLVM_CONFIG --version` LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed 's/-DNDEBUG\>//g'` - LLVM_LIBS="`$LLVM_CONFIG --libs` -lstdc++" + LLVM_LIBS="`$LLVM_CONFIG --libs`" LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` DEFINES="$DEFINES -D__STDC_CONSTANT_MACROS" diff --git a/mesalib/include/GL/internal/dri_interface.h b/mesalib/include/GL/internal/dri_interface.h index 76e48a06b..5561fcb0d 100644 --- a/mesalib/include/GL/internal/dri_interface.h +++ b/mesalib/include/GL/internal/dri_interface.h @@ -84,6 +84,7 @@ typedef struct __DRIbufferRec __DRIbuffer; typedef struct __DRIdri2ExtensionRec __DRIdri2Extension; typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension; typedef struct __DRI2flushExtensionRec __DRI2flushExtension; +typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension; /*@}*/ @@ -284,6 +285,27 @@ struct __DRI2flushExtensionRec { /** + * Extension that the driver uses to request + * throttle callbacks. + */ + +#define __DRI2_THROTTLE "DRI2_Throttle" +#define __DRI2_THROTTLE_VERSION 1 + +enum __DRI2throttleReason { + __DRI2_THROTTLE_SWAPBUFFER, + __DRI2_THROTTLE_COPYSUBBUFFER, + __DRI2_THROTTLE_FLUSHFRONT +}; + +struct __DRI2throttleExtensionRec { + __DRIextension base; + void (*throttle)(__DRIcontext *ctx, + __DRIdrawable *drawable, + enum __DRI2throttleReason reason); +}; + +/** * XML document describing the configuration options supported by the * driver. */ diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py index 1c9c0ea32..c3350b3ca 100644 --- a/mesalib/scons/gallium.py +++ b/mesalib/scons/gallium.py @@ -361,6 +361,9 @@ def generate(env): ccflags += ['-O0'] else: ccflags += ['-O3'] + # gcc's builtin memcmp is slower than glibc's + # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 + ccflags += ['-fno-builtin-memcmp'] # Work around aliasing bugs - developers should comment this out ccflags += ['-fno-strict-aliasing'] ccflags += ['-g'] diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index 89dae9556..b0d538de6 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -217,25 +217,17 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) if (ctx->vertex_has_integers) { memset(&velem[0], 0, sizeof(velem[0]) * 2); - for (i = 0; i < 2; i++) { - velem[i].src_offset = i * 4 * sizeof(float); - if (i == 0) { - velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - } else { - velem[i].src_format = PIPE_FORMAT_R32G32B32A32_SINT; - } - } + velem[0].src_offset = 0; + velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velem[1].src_offset = 4 * sizeof(float); + velem[1].src_format = PIPE_FORMAT_R32G32B32A32_SINT; ctx->velem_sint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]); memset(&velem[0], 0, sizeof(velem[0]) * 2); - for (i = 0; i < 2; i++) { - velem[i].src_offset = i * 4 * sizeof(float); - if (i == 0) { - velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - } else { - velem[i].src_format = PIPE_FORMAT_R32G32B32A32_UINT; - } - } + velem[0].src_offset = 0; + velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + velem[1].src_offset = 4 * sizeof(float); + velem[1].src_format = PIPE_FORMAT_R32G32B32A32_UINT; ctx->velem_uint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]); } diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c index 730dc31ac..e07462a75 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.c +++ b/mesalib/src/gallium/auxiliary/util/u_format.c @@ -561,8 +561,8 @@ util_format_translate(enum pipe_format dst_format, tmp_z = MALLOC(width * sizeof *tmp_z); } - if (src_format_desc->unpack_s_8uscaled && - dst_format_desc->pack_s_8uscaled) { + if (src_format_desc->unpack_s_8uint && + dst_format_desc->pack_s_8uint) { tmp_s = MALLOC(width * sizeof *tmp_s); } @@ -573,8 +573,8 @@ util_format_translate(enum pipe_format dst_format, } if (tmp_s) { - src_format_desc->unpack_s_8uscaled(tmp_s, 0, src_row, src_stride, width, 1); - dst_format_desc->pack_s_8uscaled(dst_row, dst_stride, tmp_s, 0, width, 1); + src_format_desc->unpack_s_8uint(tmp_s, 0, src_row, src_stride, width, 1); + dst_format_desc->pack_s_8uint(dst_row, dst_stride, tmp_s, 0, width, 1); } dst_row += dst_step; diff --git a/mesalib/src/gallium/auxiliary/util/u_format.csv b/mesalib/src/gallium/auxiliary/util/u_format.csv index 08aa0a49d..998ac416d 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.csv +++ b/mesalib/src/gallium/auxiliary/util/u_format.csv @@ -124,18 +124,18 @@ PIPE_FORMAT_R10SG10SB10SA2U_NORM , plain, 1, 1, sn10, sn10, sn10, un2 , xyzw, r PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb # Depth-stencil formats -PIPE_FORMAT_S8_USCALED , plain, 1, 1, u8 , , , , _x__, zs +PIPE_FORMAT_S8_UINT , plain, 1, 1, up8 , , , , _x__, zs PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs -PIPE_FORMAT_Z24_UNORM_S8_USCALED , plain, 1, 1, un24, u8 , , , xy__, zs -PIPE_FORMAT_S8_USCALED_Z24_UNORM , plain, 1, 1, u8 , un24, , , yx__, zs -PIPE_FORMAT_X24S8_USCALED , plain, 1, 1, x24, u8 , , , _y__, zs -PIPE_FORMAT_S8X24_USCALED , plain, 1, 1, u8 , x24 , , , _x__, zs +PIPE_FORMAT_Z24_UNORM_S8_UINT , plain, 1, 1, un24, up8 , , , xy__, zs +PIPE_FORMAT_S8_UINT_Z24_UNORM , plain, 1, 1, up8 , un24, , , yx__, zs +PIPE_FORMAT_X24S8_UINT , plain, 1, 1, x24 , up8 , , , _y__, zs +PIPE_FORMAT_S8X24_UINT , plain, 1, 1, up8 , x24 , , , _x__, zs PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs -PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , x24 , , xy__, zs -PIPE_FORMAT_X32_S8X24_USCALED , plain, 1, 1, x32, u8 , x24 , , _y__, zs +PIPE_FORMAT_Z32_FLOAT_S8X24_UINT , plain, 1, 1, f32 , up8 , x24, , xy__, zs +PIPE_FORMAT_X32_S8X24_UINT , plain, 1, 1, x32 , up8 , x24, , _y__, zs # YUV formats # http://www.fourcc.org/yuv.php#UYVY @@ -338,4 +338,5 @@ PIPE_FORMAT_L32A32_UINT , plain, 1, 1, up32, up32, , , xxxy, rgb PIPE_FORMAT_A32_SINT , plain, 1, 1, sp32, , , , 000x, rgb PIPE_FORMAT_I32_SINT , plain, 1, 1, sp32, , , , xxxx, rgb PIPE_FORMAT_L32_SINT , plain, 1, 1, sp32, , , , xxx1, rgb -PIPE_FORMAT_L32A32_SINT , plain, 1, 1, sp32, sp32, , , xxxy, rgb
\ No newline at end of file +PIPE_FORMAT_L32A32_SINT , plain, 1, 1, sp32, sp32, , , xxxy, rgb + diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h index 215a00ab5..99ee6767e 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.h +++ b/mesalib/src/gallium/auxiliary/util/u_format.h @@ -301,26 +301,26 @@ struct util_format_description unsigned width, unsigned height); /** - * Unpack pixels to S8_USCALED. + * Unpack pixels to S8_UINT. * Note: strides are in bytes. * * Only defined for stencil formats. */ void - (*unpack_s_8uscaled)(uint8_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); + (*unpack_s_8uint)(uint8_t *dst, unsigned dst_stride, + const uint8_t *src, unsigned src_stride, + unsigned width, unsigned height); /** - * Pack pixels from S8_USCALED. + * Pack pixels from S8_UINT. * Note: strides are in bytes. * * Only defined for stencil formats. */ void - (*pack_s_8uscaled)(uint8_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); + (*pack_s_8uint)(uint8_t *dst, unsigned dst_stride, + const uint8_t *src, unsigned src_stride, + unsigned width, unsigned height); /** * Unpack pixel blocks to R32G32B32A32_UINT. diff --git a/mesalib/src/gallium/auxiliary/util/u_format_table.py b/mesalib/src/gallium/auxiliary/util/u_format_table.py index 6c00b0df3..250a53598 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_table.py +++ b/mesalib/src/gallium/auxiliary/util/u_format_table.py @@ -159,17 +159,17 @@ def write_format_table(formats): print " NULL, /* unpack_z_float */" print " NULL, /* pack_z_float */" if format.colorspace == ZS and format.swizzles[1] != SWIZZLE_NONE: - print " &util_format_%s_unpack_s_8uscaled," % format.short_name() - print " &util_format_%s_pack_s_8uscaled," % format.short_name() + print " &util_format_%s_unpack_s_8uint," % format.short_name() + print " &util_format_%s_pack_s_8uint," % format.short_name() else: - print " NULL, /* unpack_s_8uscaled */" - print " NULL, /* pack_s_8uscaled */" - if format.channels[0].pure == True and format.channels[0].type == UNSIGNED: + print " NULL, /* unpack_s_8uint */" + print " NULL, /* pack_s_8uint */" + if format.colorspace != ZS and format.channels[0].pure == True and format.channels[0].type == UNSIGNED: print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name() print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name() print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name() print " &util_format_%s_pack_signed /* pack_rgba_sint */" % format.short_name() - elif format.channels[0].pure == True and format.channels[0].type == SIGNED: + elif format.colorspace != ZS and format.channels[0].pure == True and format.channels[0].type == SIGNED: print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name() print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name() print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name() diff --git a/mesalib/src/gallium/auxiliary/util/u_format_tests.c b/mesalib/src/gallium/auxiliary/util/u_format_tests.c index 2130c49e1..fc29d8d48 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_tests.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_tests.c @@ -1,970 +1,970 @@ -/**************************************************************************
- *
- * Copyright 2009-2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "u_memory.h"
-#include "u_format_tests.h"
-
-
-/*
- * Helper macros to create the packed bytes for longer words.
- */
-
-#define PACKED_1x8(x) {x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_2x8(x, y) {x, y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_3x8(x, y, z) {x, y, z, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_4x8(x, y, z, w) {x, y, z, w, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_8x8(a, b, c, d, e, f, g, h) {a, b, c, d, e, f, g, h, 0, 0, 0, 0, 0, 0, 0, 0}
-
-#define PACKED_1x16(x) {(x) & 0xff, (x) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_2x16(x, y) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_3x16(x, y, z) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, (z) & 0xff, (z) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_4x16(x, y, z, w) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, (z) & 0xff, (z) >> 8, (w) & 0xff, (w) >> 8, 0, 0, 0, 0, 0, 0, 0, 0}
-
-#define PACKED_1x32(x) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_2x32(x, y) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, 0, 0, 0, 0, 0, 0, 0, 0}
-#define PACKED_3x32(x, y, z) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, (z) & 0xff, ((z) >> 8) & 0xff, ((z) >> 16) & 0xff, (z) >> 24, 0, 0, 0, 0}
-#define PACKED_4x32(x, y, z, w) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, (z) & 0xff, ((z) >> 8) & 0xff, ((z) >> 16) & 0xff, (z) >> 24, (w) & 0xff, ((w) >> 8) & 0xff, ((w) >> 16) & 0xff, (w) >> 24}
-
-#define UNPACKED_1x1(r, g, b, a) \
- {{{r, g, b, a}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \
- {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \
- {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \
- {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}}
-
-#define UNPACKED_2x1(r0, g0, b0, a0, r1, g1, b1, a1) \
- {{{r0, g0, b0, a0}, {r1, g1, b1, a1}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \
- {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \
- {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \
- {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}}
-
-
-/**
- * Test cases.
- *
- * These were manually entered. We could generate these
- *
- * To keep this to a we cover only the corner cases, which should produce
- * good enough coverage since that pixel format transformations are afine for
- * non SRGB formats.
- */
-const struct util_format_test_case
-util_format_test_cases[] =
-{
-
- /*
- * 32-bit rendertarget formats
- */
-
- {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000003ff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000ffc00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x3ff00000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xc0000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000003ff), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000ffc00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x3ff00000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xc0000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- /*
- * 16-bit rendertarget formats
- */
-
- {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7fff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x03e0), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x7c00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x8000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x000f), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x00f0), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x0f00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x0fff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x000f), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x00f0), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0f00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xf000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x07e0), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xf800), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- /*
- * Luminance/intensity/alpha formats
- */
-
- {PIPE_FORMAT_L8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_L8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_A8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_I8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_I8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_L4A4_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_L4A4_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x0f), UNPACKED_1x1(1.0, 1.0, 1.0, 0.0)},
- {PIPE_FORMAT_L4A4_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xf0), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_L4A4_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x00ff), UNPACKED_1x1(1.0, 1.0, 1.0, 0.0)},
- {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xff00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_L16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_L16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- /*
- * SRGB formats
- */
-
- {PIPE_FORMAT_L8_SRGB, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_L8_SRGB, PACKED_1x8(0xff), PACKED_1x8(0xbc), UNPACKED_1x1(0.502886458033, 0.502886458033, 0.502886458033, 1.0)},
- {PIPE_FORMAT_L8_SRGB, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x00bc), UNPACKED_1x1(0.502886458033, 0.502886458033, 0.502886458033, 0.0)},
- {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x00ff), UNPACKED_1x1(1.0, 1.0, 1.0, 0.0)},
- {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0xcc00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)},
- {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0xff00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xbc, 0x00, 0x00), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0x00, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xbc, 0x00), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xff, 0x00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xbc), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 1.0)},
- {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xbc, 0x00, 0x00, 0x00), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xbc, 0x00, 0x00), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xbc, 0x00), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xcc), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000bc), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xcc000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000bc), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000cc), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xbc000000), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xbc000000), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000cc), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xbc000000), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xbc000000), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- /*
- * Mixed-signed formats
- */
-
- {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x81, 0x00, 0x00, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x81, 0x00, 0x00), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000001ff), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000201), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0007fc00), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00080400), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x1ff00000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x20100000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)},
- {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xc0000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x000f), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0011), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x01e0), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0220), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0xfc00), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x7f, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x81, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x7f), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x81), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
-
- /*
- * Depth-stencil formats
- */
-
- {PIPE_FORMAT_S8_USCALED, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_S8_USCALED, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(0.0, 255.0, 0.0, 0.0)},
-
- {PIPE_FORMAT_Z16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
-
- {PIPE_FORMAT_Z32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
-
- {PIPE_FORMAT_Z32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x3f800000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
-
- {PIPE_FORMAT_Z24_UNORM_S8_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z24_UNORM_S8_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ffffff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z24_UNORM_S8_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 255.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z24_UNORM_S8_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 255.0, 0.0, 0.0)},
-
- {PIPE_FORMAT_S8_USCALED_Z24_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_S8_USCALED_Z24_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffff00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_S8_USCALED_Z24_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 255.0, 0.0, 0.0)},
- {PIPE_FORMAT_S8_USCALED_Z24_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 255.0, 0.0, 0.0)},
-
- {PIPE_FORMAT_Z24X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z24X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ffffff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
-
- {PIPE_FORMAT_X8Z24_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_X8Z24_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffff00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
-
- {PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, PACKED_2x32(0xffffffff, 0x000000ff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, PACKED_2x32(0xffffffff, 0x000000ff), PACKED_2x32(0x3f800000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, PACKED_2x32(0xffffffff, 0x000000ff), PACKED_2x32(0x00000000, 0x000000ff), UNPACKED_1x1( 0.0, 255.0, 0.0, 0.0)},
-
- /*
- * YUV formats
- */
-
- {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_2x1(1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_2x1(0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_2x1(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_2x1(1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_2x1(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)},
-
- /*
- * TODO: Exercise the UV channels as well.
- */
- {PIPE_FORMAT_UYVY, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0x10, 0x80, 0x10), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_UYVY, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0xeb, 0x80, 0x10), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_UYVY, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0x10, 0x80, 0xeb), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_YUYV, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x10, 0x80, 0x10, 0x80), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_YUYV, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xeb, 0x80, 0x10, 0x80), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_YUYV, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x10, 0x80, 0xeb, 0x80), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0)},
-
- /*
- * Compressed formats
- */
-
- {
- PIPE_FORMAT_DXT1_RGB,
- PACKED_8x8(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff),
- PACKED_8x8(0xf2, 0xd7, 0xb0, 0x20, 0xae, 0x2c, 0x6f, 0x97),
- {
- {
- {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0},
- {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0},
- {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0},
- {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0}
- },
- {
- {0xd6/255.0, 0xff/255.0, 0x94/255.0, 0xff/255.0},
- {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0},
- {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0},
- {0xd6/255.0, 0xff/255.0, 0x94/255.0, 0xff/255.0}
- },
- {
- {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0},
- {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0},
- {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0},
- {0x21/255.0, 0x14/255.0, 0x84/255.0, 0xff/255.0}
- },
- {
- {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0},
- {0x21/255.0, 0x14/255.0, 0x84/255.0, 0xff/255.0},
- {0x21/255.0, 0x14/255.0, 0x84/255.0, 0xff/255.0},
- {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0}
- }
- }
- },
- {
- PIPE_FORMAT_DXT1_RGBA,
- PACKED_8x8(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff),
- PACKED_8x8(0xff, 0x2f, 0xa4, 0x72, 0xeb, 0xb2, 0xbd, 0xbe),
- {
- {
- {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0},
- {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0},
- {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0},
- {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0}
- },
- {
- {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0},
- {0x29/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0},
- {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0},
- {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0}
- },
- {
- {0x73/255.0, 0x55/255.0, 0x21/255.0, 0xff/255.0},
- {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0},
- {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0},
- {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0}
- },
- {
- {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0},
- {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0},
- {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0},
- {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0}
- }
- }
- },
- {
- PIPE_FORMAT_DXT3_RGBA,
- {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
- {0xe7, 0x4a, 0x8f, 0x96, 0x5b, 0xc1, 0x1c, 0x84, 0xf6, 0x8f, 0xab, 0x32, 0x2a, 0x9a, 0x95, 0x5a},
- {
- {
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x77/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xee/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xaa/255.0},
- {0x8c/255.0, 0xff/255.0, 0xb5/255.0, 0x44/255.0}
- },
- {
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xff/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x88/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x66/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x99/255.0}
- },
- {
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0xbb/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x55/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x11/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xcc/255.0}
- },
- {
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xcc/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x11/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x44/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x88/255.0}
- }
- }
- },
- {
- PIPE_FORMAT_DXT5_RGBA,
- {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
- {0xf8, 0x11, 0xc5, 0x0c, 0x9a, 0x73, 0xb4, 0x9c, 0xf6, 0x8f, 0xab, 0x32, 0x2a, 0x9a, 0x95, 0x5a},
- {
- {
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x74/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xf8/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xb6/255.0},
- {0x8c/255.0, 0xff/255.0, 0xb5/255.0, 0x53/255.0}
- },
- {
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xf8/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x95/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x53/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x95/255.0}
- },
- {
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0xb6/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x53/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x11/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xd7/255.0}
- },
- {
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xb6/255.0},
- {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x11/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x32/255.0},
- {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x95/255.0}
- }
- }
- },
-
-
- /*
- * Standard 8-bit integer formats
- */
-
- {PIPE_FORMAT_R8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0xff), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0x00, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xff, 0x00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R8_USCALED, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8_USCALED, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(255.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0x00), UNPACKED_1x1(255.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0xff), UNPACKED_1x1( 0.0, 255.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0xff), UNPACKED_1x1(255.0, 255.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0x00, 0x00), UNPACKED_1x1(255.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xff, 0x00), UNPACKED_1x1( 0.0, 255.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xff), UNPACKED_1x1( 0.0, 0.0, 255.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0xff, 0xff), UNPACKED_1x1(255.0, 255.0, 255.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_1x1(255.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_1x1( 0.0, 255.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_1x1( 0.0, 0.0, 255.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_1x1( 0.0, 0.0, 0.0, 255.0)},
- {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_1x1(255.0, 255.0, 255.0, 255.0)},
-
- {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x7f), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x81), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x7f, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x81, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x7f), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x81), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x7f, 0x00, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x81, 0x00, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x7f, 0x00), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x81, 0x00), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x7f), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x81), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x81, 0x00, 0x00, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x81, 0x00, 0x00), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x7f, 0x00), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x81, 0x00), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x7f), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x81), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)},
-
- {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x7f), UNPACKED_1x1( 127.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x80), UNPACKED_1x1(-128.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x7f, 0x00), UNPACKED_1x1( 127.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x80, 0x00), UNPACKED_1x1(-128.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x7f), UNPACKED_1x1( 0.0, 127.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x80), UNPACKED_1x1( 0.0, -128.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x7f, 0x00, 0x00), UNPACKED_1x1( 127.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x80, 0x00, 0x00), UNPACKED_1x1(-128.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x7f, 0x00), UNPACKED_1x1( 0.0, 127.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x80, 0x00), UNPACKED_1x1( 0.0, -128.0, 0.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x7f), UNPACKED_1x1( 0.0, 0.0, 127.0, 1.0)},
- {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x80), UNPACKED_1x1( 0.0, 0.0, -128.0, 1.0)},
-
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), UNPACKED_1x1( 127.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0x00, 0x00, 0x00), UNPACKED_1x1(-128.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), UNPACKED_1x1( 0.0, 127.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x80, 0x00, 0x00), UNPACKED_1x1( 0.0, -128.0, 0.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x7f, 0x00), UNPACKED_1x1( 0.0, 0.0, 127.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x80, 0x00), UNPACKED_1x1( 0.0, 0.0, -128.0, 0.0)},
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x7f), UNPACKED_1x1( 0.0, 0.0, 0.0, 127.0)},
- {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x80), UNPACKED_1x1( 0.0, 0.0, 0.0, -128.0)},
-
- /*
- * Standard 16-bit integer formats
- */
-
- {PIPE_FORMAT_R16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0x0000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0xffff), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0xffff), UNPACKED_1x1(1.0, 1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0x0000, 0x0000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0xffff, 0x0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0xffff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0xffff, 0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0xffff, 0x0000, 0x0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0xffff, 0x0000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0xffff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R16_USCALED, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16_USCALED, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(65535.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0x0000), UNPACKED_1x1(65535.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0xffff), UNPACKED_1x1( 0.0, 65535.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0xffff), UNPACKED_1x1(65535.0, 65535.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0x0000, 0x0000), UNPACKED_1x1(65535.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0xffff, 0x0000), UNPACKED_1x1( 0.0, 65535.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0xffff), UNPACKED_1x1( 0.0, 0.0, 65535.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0xffff, 0xffff), UNPACKED_1x1(65535.0, 65535.0, 65535.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(65535.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0xffff, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 65535.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0xffff, 0x0000), UNPACKED_1x1( 0.0, 0.0, 65535.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0xffff), UNPACKED_1x1( 0.0, 0.0, 0.0, 65535.0)},
- {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), UNPACKED_1x1(65535.0, 65535.0, 65535.0, 65535.0)},
-
- {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x7fff), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x8001), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x7fff, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x8001, 0x0000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x7fff), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x8001), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x7fff, 0x0000, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x8001, 0x0000, 0x0000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x7fff, 0x0000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x8001, 0x0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x7fff), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x8001), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x7fff, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x8001, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( -1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x7fff, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x8001, 0x0000, 0x0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x7fff, 0x0000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x8001, 0x0000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x7fff), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x8001), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)},
-
- {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x7fff), UNPACKED_1x1( 32767.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x8000), UNPACKED_1x1(-32768.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x7fff, 0x0000), UNPACKED_1x1( 32767.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x8000, 0x0000), UNPACKED_1x1(-32768.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x7fff), UNPACKED_1x1( 0.0, 32767.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x8000), UNPACKED_1x1( 0.0, -32768.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x7fff, 0x0000, 0x0000), UNPACKED_1x1( 32767.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x8000, 0x0000, 0x0000), UNPACKED_1x1(-32768.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x7fff, 0x0000), UNPACKED_1x1( 0.0, 32767.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x8000, 0x0000), UNPACKED_1x1( 0.0, -32768.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x7fff), UNPACKED_1x1( 0.0, 0.0, 32767.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x8000), UNPACKED_1x1( 0.0, 0.0, -32768.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x7fff, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 32767.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x8000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(-32768.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x7fff, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 32767.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x8000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, -32768.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x7fff, 0x0000), UNPACKED_1x1( 0.0, 0.0, 32767.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x8000, 0x0000), UNPACKED_1x1( 0.0, 0.0, -32768.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x7fff), UNPACKED_1x1( 0.0, 0.0, 0.0, 32767.0)},
- {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x8000), UNPACKED_1x1( 0.0, 0.0, 0.0, -32768.0)},
-
- /*
- * Standard 32-bit integer formats
- *
- * NOTE: We can't accurately represent integers larger than +/-0x1000000
- * with single precision floats, so that's as far as we test.
- */
-
- {PIPE_FORMAT_R32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xffffffff, 0x00000000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xffffffff), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xffffffff, 0xffffffff), UNPACKED_1x1(1.0, 1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xffffffff, 0x00000000, 0x00000000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xffffffff, 0x00000000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xffffffff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xffffffff, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xffffffff, 0x00000000, 0x00000000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xffffffff, 0x00000000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xffffffff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R32_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x01000000), UNPACKED_1x1(16777216.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x00000000), UNPACKED_1x1(16777216.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x01000000), UNPACKED_1x1(16777216.0, 16777216.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x00000000, 0x00000000), UNPACKED_1x1(16777216.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x01000000, 0x00000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 0.0, 16777216.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x01000000, 0x01000000), UNPACKED_1x1(16777216.0, 16777216.0, 16777216.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(16777216.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x01000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x01000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 16777216.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 16777216.0)},
- {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x01000000, 0x01000000, 0x01000000), UNPACKED_1x1(16777216.0, 16777216.0, 16777216.0, 16777216.0)},
-
- {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x7fffffff), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x80000001), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x7fffffff, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x80000001, 0x00000000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x7fffffff), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x80000001), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x7fffffff, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x80000001, 0x00000000, 0x00000000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x7fffffff, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x80000001, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x7fffffff), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x80000001), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x7fffffff, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x80000001, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( -1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x7fffffff, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x80000001, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x7fffffff, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x80000001, 0x00000000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x7fffffff), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x80000001), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)},
-
- {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x01000000), UNPACKED_1x1( 16777216.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(-16777216.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x00000000), UNPACKED_1x1( 16777216.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xff000000, 0x00000000), UNPACKED_1x1(-16777216.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xff000000), UNPACKED_1x1( 0.0, -16777216.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x00000000, 0x00000000), UNPACKED_1x1( 16777216.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xff000000, 0x00000000, 0x00000000), UNPACKED_1x1(-16777216.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x01000000, 0x00000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xff000000, 0x00000000), UNPACKED_1x1( 0.0, -16777216.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 0.0, 16777216.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xff000000), UNPACKED_1x1( 0.0, 0.0, -16777216.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 16777216.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xff000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(-16777216.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x01000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xff000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, -16777216.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x01000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 16777216.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xff000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, -16777216.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 16777216.0)},
- {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xff000000), UNPACKED_1x1( 0.0, 0.0, 0.0, -16777216.0)},
-
- /*
- * Standard 32-bit float formats
- */
-
- {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x3f800000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0xbf800000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x3f800000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xbf800000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x3f800000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xbf800000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x3f800000, 0x3f800000), UNPACKED_1x1( 1.0, 1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x3f800000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xbf800000, 0x00000000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x3f800000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xbf800000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x3f800000), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xbf800000), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x3f800000, 0x3f800000, 0x3f800000), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x3f800000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xbf800000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x3f800000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xbf800000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x3f800000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xbf800000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x3f800000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xbf800000), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)},
- {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)},
-
- /*
- * Half float formats
- */
-
- {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x3c00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0xbc00), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x3c00, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xbc00, 0x0000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x3c00), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0xbc00), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x3c00, 0x3c00), UNPACKED_1x1( 1.0, 1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x3c00, 0x0000, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xbc00, 0x0000, 0x0000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x3c00, 0x0000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0xbc00, 0x0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x3c00), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0xbc00), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)},
- {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x3c00, 0x3c00, 0x3c00), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x3c00, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xbc00, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x3c00, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0xbc00, 0x0000, 0x0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x3c00, 0x0000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0xbc00, 0x0000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x3c00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0xbc00), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)},
- {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x3c00, 0x3c00, 0x3c00, 0x3c00), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)},
-
- /*
- * 32-bit fixed point formats
- */
-
- {PIPE_FORMAT_R32_FIXED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_FIXED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00010000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32_FIXED, PACKED_1x32(0xffffffff), PACKED_1x32(0xffff0000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00010000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xffff0000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00010000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xffff0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00010000, 0x00010000), UNPACKED_1x1( 1.0, 1.0, 0.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00010000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xffff0000, 0x00000000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00010000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xffff0000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00010000), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xffff0000), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)},
- {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00010000, 0x00010000, 0x00010000), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)},
-
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00010000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xffff0000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00010000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xffff0000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00010000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xffff0000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00010000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xffff0000), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)},
- {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00010000, 0x00010000, 0x00010000, 0x00010000), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)},
-
- /*
- * D3D9 specific vertex formats
- */
-
- {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x000003ff), UNPACKED_1x1(1023.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x000ffc00), UNPACKED_1x1( 0.0, 1023.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x3ff00000), UNPACKED_1x1( 0.0, 0.0, 1023.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x3fffffff), UNPACKED_1x1(1023.0, 1023.0, 1023.0, 1.0)},
-
- {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x000001ff), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x00000201), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x0007fc00), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x00080400), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x1ff00000), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)},
- {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x20100000), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)},
-
- /*
- * Special formats that not fit anywhere else
- */
-
-};
-
-
-const unsigned util_format_nr_test_cases = Elements(util_format_test_cases);
+/************************************************************************** + * + * Copyright 2009-2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "u_memory.h" +#include "u_format_tests.h" + + +/* + * Helper macros to create the packed bytes for longer words. + */ + +#define PACKED_1x8(x) {x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_2x8(x, y) {x, y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_3x8(x, y, z) {x, y, z, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_4x8(x, y, z, w) {x, y, z, w, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_8x8(a, b, c, d, e, f, g, h) {a, b, c, d, e, f, g, h, 0, 0, 0, 0, 0, 0, 0, 0} + +#define PACKED_1x16(x) {(x) & 0xff, (x) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_2x16(x, y) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_3x16(x, y, z) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, (z) & 0xff, (z) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_4x16(x, y, z, w) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, (z) & 0xff, (z) >> 8, (w) & 0xff, (w) >> 8, 0, 0, 0, 0, 0, 0, 0, 0} + +#define PACKED_1x32(x) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_2x32(x, y) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_3x32(x, y, z) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, (z) & 0xff, ((z) >> 8) & 0xff, ((z) >> 16) & 0xff, (z) >> 24, 0, 0, 0, 0} +#define PACKED_4x32(x, y, z, w) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, (z) & 0xff, ((z) >> 8) & 0xff, ((z) >> 16) & 0xff, (z) >> 24, (w) & 0xff, ((w) >> 8) & 0xff, ((w) >> 16) & 0xff, (w) >> 24} + +#define UNPACKED_1x1(r, g, b, a) \ + {{{r, g, b, a}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \ + {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \ + {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \ + {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}} + +#define UNPACKED_2x1(r0, g0, b0, a0, r1, g1, b1, a1) \ + {{{r0, g0, b0, a0}, {r1, g1, b1, a1}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \ + {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \ + {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, \ + {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}} + + +/** + * Test cases. + * + * These were manually entered. We could generate these + * + * To keep this to a we cover only the corner cases, which should produce + * good enough coverage since that pixel format transformations are afine for + * non SRGB formats. + */ +const struct util_format_test_case +util_format_test_cases[] = +{ + + /* + * 32-bit rendertarget formats + */ + + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000003ff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000ffc00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x3ff00000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xc0000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000003ff), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000ffc00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x3ff00000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xc0000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B10G10R10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + /* + * 16-bit rendertarget formats + */ + + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7fff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x03e0), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x7c00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x8000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x000f), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x00f0), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x0f00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B4G4R4X4_UNORM, PACKED_1x16(0x0fff), PACKED_1x16(0x0fff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x000f), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x00f0), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0f00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xf000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x07e0), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xf800), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + /* + * Luminance/intensity/alpha formats + */ + + {PIPE_FORMAT_L8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_L8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_A8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_I8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_I8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_L4A4_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_L4A4_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x0f), UNPACKED_1x1(1.0, 1.0, 1.0, 0.0)}, + {PIPE_FORMAT_L4A4_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xf0), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_L4A4_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x00ff), UNPACKED_1x1(1.0, 1.0, 1.0, 0.0)}, + {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xff00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_L16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_L16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + /* + * SRGB formats + */ + + {PIPE_FORMAT_L8_SRGB, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_L8_SRGB, PACKED_1x8(0xff), PACKED_1x8(0xbc), UNPACKED_1x1(0.502886458033, 0.502886458033, 0.502886458033, 1.0)}, + {PIPE_FORMAT_L8_SRGB, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x00bc), UNPACKED_1x1(0.502886458033, 0.502886458033, 0.502886458033, 0.0)}, + {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0x00ff), UNPACKED_1x1(1.0, 1.0, 1.0, 0.0)}, + {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0xcc00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)}, + {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0xff00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_L8A8_SRGB, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xbc, 0x00, 0x00), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0x00, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xbc, 0x00), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xff, 0x00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xbc), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 1.0)}, + {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SRGB, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xbc, 0x00, 0x00, 0x00), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xbc, 0x00, 0x00), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xbc, 0x00), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xcc), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8A8_SRGB, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000bc), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xcc000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8A8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000bc), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_B8G8R8X8_SRGB, PACKED_1x32(0x00ffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000cc), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xbc000000), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_A8R8G8B8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xbc000000), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_X8R8G8B8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000cc), UNPACKED_1x1(0.0, 0.0, 0.0, 0.8)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xbc000000), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_A8B8G8R8_SRGB, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000bc00), UNPACKED_1x1(0.0, 0.0, 0.502886458033, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00bc0000), UNPACKED_1x1(0.0, 0.502886458033, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xbc000000), UNPACKED_1x1(0.502886458033, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_X8B8G8R8_SRGB, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + /* + * Mixed-signed formats + */ + + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x81, 0x00, 0x00, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x81, 0x00, 0x00), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000001ff), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000201), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0007fc00), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00080400), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x1ff00000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x20100000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)}, + {PIPE_FORMAT_R10SG10SB10SA2U_NORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xc0000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x000f), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0011), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x01e0), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0220), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0xfc00), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x7f, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x81, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x7f), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8Bx_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x81), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + + /* + * Depth-stencil formats + */ + + {PIPE_FORMAT_S8_UINT, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_S8_UINT, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(0.0, 255.0, 0.0, 0.0)}, + + {PIPE_FORMAT_Z16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + + {PIPE_FORMAT_Z32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + + {PIPE_FORMAT_Z32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x3f800000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + + {PIPE_FORMAT_Z24_UNORM_S8_UINT, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z24_UNORM_S8_UINT, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ffffff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z24_UNORM_S8_UINT, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(0.0, 255.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z24_UNORM_S8_UINT, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 255.0, 0.0, 0.0)}, + + {PIPE_FORMAT_S8_UINT_Z24_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_S8_UINT_Z24_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffff00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_S8_UINT_Z24_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), UNPACKED_1x1(0.0, 255.0, 0.0, 0.0)}, + {PIPE_FORMAT_S8_UINT_Z24_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 255.0, 0.0, 0.0)}, + + {PIPE_FORMAT_Z24X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z24X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ffffff), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + + {PIPE_FORMAT_X8Z24_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_X8Z24_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffff00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + + {PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, PACKED_2x32(0xffffffff, 0x000000ff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, PACKED_2x32(0xffffffff, 0x000000ff), PACKED_2x32(0x3f800000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, PACKED_2x32(0xffffffff, 0x000000ff), PACKED_2x32(0x00000000, 0x000000ff), UNPACKED_1x1( 0.0, 255.0, 0.0, 0.0)}, + + /* + * YUV formats + */ + + {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_2x1(1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_2x1(0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_2x1(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_B8G8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_2x1(0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_2x1(1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_2x1(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_G8R8_G8B8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)}, + + /* + * TODO: Exercise the UV channels as well. + */ + {PIPE_FORMAT_UYVY, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0x10, 0x80, 0x10), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_UYVY, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0xeb, 0x80, 0x10), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_UYVY, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0x10, 0x80, 0xeb), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_YUYV, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x10, 0x80, 0x10, 0x80), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_YUYV, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xeb, 0x80, 0x10, 0x80), UNPACKED_2x1(1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_YUYV, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x10, 0x80, 0xeb, 0x80), UNPACKED_2x1(0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0)}, + + /* + * Compressed formats + */ + + { + PIPE_FORMAT_DXT1_RGB, + PACKED_8x8(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), + PACKED_8x8(0xf2, 0xd7, 0xb0, 0x20, 0xae, 0x2c, 0x6f, 0x97), + { + { + {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0}, + {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0}, + {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0}, + {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0} + }, + { + {0xd6/255.0, 0xff/255.0, 0x94/255.0, 0xff/255.0}, + {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0}, + {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0}, + {0xd6/255.0, 0xff/255.0, 0x94/255.0, 0xff/255.0} + }, + { + {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0}, + {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0}, + {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0}, + {0x21/255.0, 0x14/255.0, 0x84/255.0, 0xff/255.0} + }, + { + {0x5d/255.0, 0x62/255.0, 0x89/255.0, 0xff/255.0}, + {0x21/255.0, 0x14/255.0, 0x84/255.0, 0xff/255.0}, + {0x21/255.0, 0x14/255.0, 0x84/255.0, 0xff/255.0}, + {0x99/255.0, 0xb0/255.0, 0x8e/255.0, 0xff/255.0} + } + } + }, + { + PIPE_FORMAT_DXT1_RGBA, + PACKED_8x8(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), + PACKED_8x8(0xff, 0x2f, 0xa4, 0x72, 0xeb, 0xb2, 0xbd, 0xbe), + { + { + {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0}, + {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0}, + {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0}, + {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0} + }, + { + {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0}, + {0x29/255.0, 0xff/255.0, 0xff/255.0, 0xff/255.0}, + {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0}, + {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0} + }, + { + {0x73/255.0, 0x55/255.0, 0x21/255.0, 0xff/255.0}, + {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0}, + {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0}, + {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0} + }, + { + {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0}, + {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0}, + {0x00/255.0, 0x00/255.0, 0x00/255.0, 0x00/255.0}, + {0x4e/255.0, 0xaa/255.0, 0x90/255.0, 0xff/255.0} + } + } + }, + { + PIPE_FORMAT_DXT3_RGBA, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0xe7, 0x4a, 0x8f, 0x96, 0x5b, 0xc1, 0x1c, 0x84, 0xf6, 0x8f, 0xab, 0x32, 0x2a, 0x9a, 0x95, 0x5a}, + { + { + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x77/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xee/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xaa/255.0}, + {0x8c/255.0, 0xff/255.0, 0xb5/255.0, 0x44/255.0} + }, + { + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xff/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x88/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x66/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x99/255.0} + }, + { + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0xbb/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x55/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x11/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xcc/255.0} + }, + { + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xcc/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x11/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x44/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x88/255.0} + } + } + }, + { + PIPE_FORMAT_DXT5_RGBA, + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + {0xf8, 0x11, 0xc5, 0x0c, 0x9a, 0x73, 0xb4, 0x9c, 0xf6, 0x8f, 0xab, 0x32, 0x2a, 0x9a, 0x95, 0x5a}, + { + { + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x74/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xf8/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xb6/255.0}, + {0x8c/255.0, 0xff/255.0, 0xb5/255.0, 0x53/255.0} + }, + { + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xf8/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x95/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x53/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x95/255.0} + }, + { + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0xb6/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x53/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x11/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xd7/255.0} + }, + { + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0xb6/255.0}, + {0x6d/255.0, 0xc6/255.0, 0x96/255.0, 0x11/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x32/255.0}, + {0x31/255.0, 0x55/255.0, 0x5a/255.0, 0x95/255.0} + } + } + }, + + + /* + * Standard 8-bit integer formats + */ + + {PIPE_FORMAT_R8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0xff), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0x00, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xff, 0x00), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R8_USCALED, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8_USCALED, PACKED_1x8(0xff), PACKED_1x8(0xff), UNPACKED_1x1(255.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0x00), UNPACKED_1x1(255.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0xff), UNPACKED_1x1( 0.0, 255.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0xff), UNPACKED_1x1(255.0, 255.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0x00, 0x00), UNPACKED_1x1(255.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xff, 0x00), UNPACKED_1x1( 0.0, 255.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xff), UNPACKED_1x1( 0.0, 0.0, 255.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0xff, 0xff), UNPACKED_1x1(255.0, 255.0, 255.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), UNPACKED_1x1(255.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), UNPACKED_1x1( 0.0, 255.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), UNPACKED_1x1( 0.0, 0.0, 255.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), UNPACKED_1x1( 0.0, 0.0, 0.0, 255.0)}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), UNPACKED_1x1(255.0, 255.0, 255.0, 255.0)}, + + {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x7f), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x81), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x7f, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x81, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x7f), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x81), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x7f, 0x00, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x81, 0x00, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x7f, 0x00), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x81, 0x00), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x7f), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x81), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x81, 0x00, 0x00, 0x00), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x81, 0x00, 0x00), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x7f, 0x00), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x81, 0x00), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x7f), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x81), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)}, + + {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x7f), UNPACKED_1x1( 127.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x80), UNPACKED_1x1(-128.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x7f, 0x00), UNPACKED_1x1( 127.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x80, 0x00), UNPACKED_1x1(-128.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x7f), UNPACKED_1x1( 0.0, 127.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x80), UNPACKED_1x1( 0.0, -128.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x7f, 0x00, 0x00), UNPACKED_1x1( 127.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x80, 0x00, 0x00), UNPACKED_1x1(-128.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x7f, 0x00), UNPACKED_1x1( 0.0, 127.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x80, 0x00), UNPACKED_1x1( 0.0, -128.0, 0.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x7f), UNPACKED_1x1( 0.0, 0.0, 127.0, 1.0)}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x80), UNPACKED_1x1( 0.0, 0.0, -128.0, 1.0)}, + + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), UNPACKED_1x1( 127.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0x00, 0x00, 0x00), UNPACKED_1x1(-128.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), UNPACKED_1x1( 0.0, 127.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x80, 0x00, 0x00), UNPACKED_1x1( 0.0, -128.0, 0.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x7f, 0x00), UNPACKED_1x1( 0.0, 0.0, 127.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x80, 0x00), UNPACKED_1x1( 0.0, 0.0, -128.0, 0.0)}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x7f), UNPACKED_1x1( 0.0, 0.0, 0.0, 127.0)}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x80), UNPACKED_1x1( 0.0, 0.0, 0.0, -128.0)}, + + /* + * Standard 16-bit integer formats + */ + + {PIPE_FORMAT_R16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0x0000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0xffff), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0xffff), UNPACKED_1x1(1.0, 1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0x0000, 0x0000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0xffff, 0x0000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0xffff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0xffff, 0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0xffff, 0x0000, 0x0000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0xffff, 0x0000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0xffff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R16_USCALED, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_USCALED, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1(65535.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0x0000), UNPACKED_1x1(65535.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0xffff), UNPACKED_1x1( 0.0, 65535.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0xffff), UNPACKED_1x1(65535.0, 65535.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0x0000, 0x0000), UNPACKED_1x1(65535.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0xffff, 0x0000), UNPACKED_1x1( 0.0, 65535.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0xffff), UNPACKED_1x1( 0.0, 0.0, 65535.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0xffff, 0xffff), UNPACKED_1x1(65535.0, 65535.0, 65535.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(65535.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0xffff, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 65535.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0xffff, 0x0000), UNPACKED_1x1( 0.0, 0.0, 65535.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0xffff), UNPACKED_1x1( 0.0, 0.0, 0.0, 65535.0)}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), UNPACKED_1x1(65535.0, 65535.0, 65535.0, 65535.0)}, + + {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x7fff), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x8001), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x7fff, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x8001, 0x0000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x7fff), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x8001), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x7fff, 0x0000, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x8001, 0x0000, 0x0000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x7fff, 0x0000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x8001, 0x0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x7fff), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x8001), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x7fff, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x8001, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( -1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x7fff, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x8001, 0x0000, 0x0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x7fff, 0x0000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x8001, 0x0000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x7fff), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x8001), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)}, + + {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x7fff), UNPACKED_1x1( 32767.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x8000), UNPACKED_1x1(-32768.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x7fff, 0x0000), UNPACKED_1x1( 32767.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x8000, 0x0000), UNPACKED_1x1(-32768.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x7fff), UNPACKED_1x1( 0.0, 32767.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x8000), UNPACKED_1x1( 0.0, -32768.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x7fff, 0x0000, 0x0000), UNPACKED_1x1( 32767.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x8000, 0x0000, 0x0000), UNPACKED_1x1(-32768.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x7fff, 0x0000), UNPACKED_1x1( 0.0, 32767.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x8000, 0x0000), UNPACKED_1x1( 0.0, -32768.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x7fff), UNPACKED_1x1( 0.0, 0.0, 32767.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x8000), UNPACKED_1x1( 0.0, 0.0, -32768.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x7fff, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 32767.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x8000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(-32768.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x7fff, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 32767.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x8000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, -32768.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x7fff, 0x0000), UNPACKED_1x1( 0.0, 0.0, 32767.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x8000, 0x0000), UNPACKED_1x1( 0.0, 0.0, -32768.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x7fff), UNPACKED_1x1( 0.0, 0.0, 0.0, 32767.0)}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x8000), UNPACKED_1x1( 0.0, 0.0, 0.0, -32768.0)}, + + /* + * Standard 32-bit integer formats + * + * NOTE: We can't accurately represent integers larger than +/-0x1000000 + * with single precision floats, so that's as far as we test. + */ + + {PIPE_FORMAT_R32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xffffffff, 0x00000000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xffffffff), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xffffffff, 0xffffffff), UNPACKED_1x1(1.0, 1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xffffffff, 0x00000000, 0x00000000), UNPACKED_1x1(1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xffffffff, 0x00000000), UNPACKED_1x1(0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xffffffff), UNPACKED_1x1(0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xffffffff, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xffffffff, 0x00000000, 0x00000000), UNPACKED_1x1(0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xffffffff, 0x00000000), UNPACKED_1x1(0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xffffffff), UNPACKED_1x1(0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), UNPACKED_1x1(1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R32_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x01000000), UNPACKED_1x1(16777216.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x00000000), UNPACKED_1x1(16777216.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x01000000), UNPACKED_1x1(16777216.0, 16777216.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x00000000, 0x00000000), UNPACKED_1x1(16777216.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x01000000, 0x00000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 0.0, 16777216.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x01000000, 0x01000000), UNPACKED_1x1(16777216.0, 16777216.0, 16777216.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(16777216.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x01000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x01000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 16777216.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 16777216.0)}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x01000000, 0x01000000, 0x01000000), UNPACKED_1x1(16777216.0, 16777216.0, 16777216.0, 16777216.0)}, + + {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x7fffffff), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x80000001), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x7fffffff, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x80000001, 0x00000000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x7fffffff), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x80000001), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x7fffffff, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x80000001, 0x00000000, 0x00000000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x7fffffff, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x80000001, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x7fffffff), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x80000001), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x7fffffff, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x80000001, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( -1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x7fffffff, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x80000001, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x7fffffff, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x80000001, 0x00000000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x7fffffff), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x80000001), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)}, + + {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x01000000), UNPACKED_1x1( 16777216.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), UNPACKED_1x1(-16777216.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x00000000), UNPACKED_1x1( 16777216.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xff000000, 0x00000000), UNPACKED_1x1(-16777216.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xff000000), UNPACKED_1x1( 0.0, -16777216.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x00000000, 0x00000000), UNPACKED_1x1( 16777216.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xff000000, 0x00000000, 0x00000000), UNPACKED_1x1(-16777216.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x01000000, 0x00000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xff000000, 0x00000000), UNPACKED_1x1( 0.0, -16777216.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 0.0, 16777216.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xff000000), UNPACKED_1x1( 0.0, 0.0, -16777216.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 16777216.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xff000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(-16777216.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x01000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 16777216.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xff000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, -16777216.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x01000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 16777216.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xff000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, -16777216.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x01000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 16777216.0)}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xff000000), UNPACKED_1x1( 0.0, 0.0, 0.0, -16777216.0)}, + + /* + * Standard 32-bit float formats + */ + + {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x3f800000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0xbf800000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x3f800000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xbf800000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x3f800000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xbf800000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x3f800000, 0x3f800000), UNPACKED_1x1( 1.0, 1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x3f800000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xbf800000, 0x00000000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x3f800000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xbf800000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x3f800000), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xbf800000), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x3f800000, 0x3f800000, 0x3f800000), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x3f800000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xbf800000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x3f800000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xbf800000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x3f800000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xbf800000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x3f800000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xbf800000), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)}, + + /* + * Half float formats + */ + + {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x3c00), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0xbc00), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x3c00, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xbc00, 0x0000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x3c00), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0xbc00), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16_FLOAT, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x3c00, 0x3c00), UNPACKED_1x1( 1.0, 1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x3c00, 0x0000, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xbc00, 0x0000, 0x0000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x3c00, 0x0000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0xbc00, 0x0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x3c00), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0xbc00), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)}, + {PIPE_FORMAT_R16G16B16_FLOAT, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x3c00, 0x3c00, 0x3c00), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x3c00, 0x0000, 0x0000, 0x0000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xbc00, 0x0000, 0x0000, 0x0000), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x3c00, 0x0000, 0x0000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0xbc00, 0x0000, 0x0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x3c00, 0x0000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0xbc00, 0x0000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x3c00), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0xbc00), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)}, + {PIPE_FORMAT_R16G16B16A16_FLOAT, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x3c00, 0x3c00, 0x3c00, 0x3c00), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)}, + + /* + * 32-bit fixed point formats + */ + + {PIPE_FORMAT_R32_FIXED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_FIXED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00010000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32_FIXED, PACKED_1x32(0xffffffff), PACKED_1x32(0xffff0000), UNPACKED_1x1( -1.0, 0.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00010000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xffff0000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00010000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xffff0000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32_FIXED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00010000, 0x00010000), UNPACKED_1x1( 1.0, 1.0, 0.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00010000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xffff0000, 0x00000000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00010000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xffff0000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00010000), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xffff0000), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)}, + {PIPE_FORMAT_R32G32B32_FIXED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00010000, 0x00010000, 0x00010000), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)}, + + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00010000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1( 1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xffff0000, 0x00000000, 0x00000000, 0x00000000), UNPACKED_1x1(-1.0, 0.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00010000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, 1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xffff0000, 0x00000000, 0x00000000), UNPACKED_1x1( 0.0, -1.0, 0.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00010000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, 1.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xffff0000, 0x00000000), UNPACKED_1x1( 0.0, 0.0, -1.0, 0.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00010000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xffff0000), UNPACKED_1x1( 0.0, 0.0, 0.0, -1.0)}, + {PIPE_FORMAT_R32G32B32A32_FIXED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00010000, 0x00010000, 0x00010000, 0x00010000), UNPACKED_1x1( 1.0, 1.0, 1.0, 1.0)}, + + /* + * D3D9 specific vertex formats + */ + + {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x000003ff), UNPACKED_1x1(1023.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x000ffc00), UNPACKED_1x1( 0.0, 1023.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x3ff00000), UNPACKED_1x1( 0.0, 0.0, 1023.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_USCALED, PACKED_1x32(0x3fffffff), PACKED_1x32(0x3fffffff), UNPACKED_1x1(1023.0, 1023.0, 1023.0, 1.0)}, + + {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x00000000), UNPACKED_1x1( 0.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x000001ff), UNPACKED_1x1( 1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x00000201), UNPACKED_1x1(-1.0, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x0007fc00), UNPACKED_1x1( 0.0, 1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x00080400), UNPACKED_1x1( 0.0, -1.0, 0.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x1ff00000), UNPACKED_1x1( 0.0, 0.0, 1.0, 1.0)}, + {PIPE_FORMAT_R10G10B10X2_SNORM, PACKED_1x32(0x3fffffff), PACKED_1x32(0x20100000), UNPACKED_1x1( 0.0, 0.0, -1.0, 1.0)}, + + /* + * Special formats that not fit anywhere else + */ + +}; + + +const unsigned util_format_nr_test_cases = Elements(util_format_test_cases); diff --git a/mesalib/src/gallium/auxiliary/util/u_format_zs.c b/mesalib/src/gallium/auxiliary/util/u_format_zs.c index 7fdaf626e..816ef1420 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_zs.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_zs.c @@ -1,973 +1,973 @@ -/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- **************************************************************************/
-
-
-#include "u_debug.h"
-#include "u_math.h"
-#include "u_format_zs.h"
-
-
-/*
- * z32_unorm conversion functions
- */
-
-static INLINE uint16_t
-z32_unorm_to_z16_unorm(uint32_t z)
-{
- /* z * 0xffff / 0xffffffff */
- return z >> 16;
-}
-
-static INLINE uint32_t
-z16_unorm_to_z32_unorm(uint16_t z)
-{
- /* z * 0xffffffff / 0xffff */
- return (z << 16) | z;
-}
-
-static INLINE uint32_t
-z32_unorm_to_z24_unorm(uint32_t z)
-{
- /* z * 0xffffff / 0xffffffff */
- return z >> 8;
-}
-
-static INLINE uint32_t
-z24_unorm_to_z32_unorm(uint32_t z)
-{
- /* z * 0xffffffff / 0xffffff */
- return (z << 8) | (z >> 16);
-}
-
-
-/*
- * z32_float conversion functions
- */
-
-static INLINE uint16_t
-z32_float_to_z16_unorm(float z)
-{
- const float scale = 0xffff;
- return (uint16_t)(z * scale);
-}
-
-static INLINE float
-z16_unorm_to_z32_float(uint16_t z)
-{
- const float scale = 1.0 / 0xffff;
- return (float)(z * scale);
-}
-
-static INLINE uint32_t
-z32_float_to_z24_unorm(float z)
-{
- const double scale = 0xffffff;
- return (uint32_t)(z * scale) & 0xffffff;
-}
-
-static INLINE float
-z24_unorm_to_z32_float(uint32_t z)
-{
- const double scale = 1.0 / 0xffffff;
- return (float)(z * scale);
-}
-
-static INLINE uint32_t
-z32_float_to_z32_unorm(float z)
-{
- const double scale = 0xffffffff;
- return (uint32_t)(z * scale);
-}
-
-static INLINE float
-z32_unorm_to_z32_float(uint32_t z)
-{
- const double scale = 1.0 / 0xffffffff;
- return (float)(z * scale);
-}
-
-
-void
-util_format_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned y;
- for(y = 0; y < height; ++y) {
- memcpy(dst_row, src_row, width);
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned y;
- for(y = 0; y < height; ++y) {
- memcpy(dst_row, src_row, width);
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- float *dst = dst_row;
- const uint16_t *src = (const uint16_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint16_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
- *dst++ = z16_unorm_to_z32_float(value);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const float *src = src_row;
- uint16_t *dst = (uint16_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint16_t value;
- value = z32_float_to_z16_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint32_t *dst = dst_row;
- const uint16_t *src = (const uint16_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint16_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
- *dst++ = z16_unorm_to_z32_unorm(value);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint32_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint32_t *src = src_row;
- uint16_t *dst = (uint16_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint16_t value;
- value = z32_unorm_to_z16_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- float *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z32_unorm_to_z32_float(value);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value;
- value = z32_float_to_z32_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned y;
- for(y = 0; y < height; ++y) {
- memcpy(dst_row, src_row, width * 4);
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint32_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned y;
- for(y = 0; y < height; ++y) {
- memcpy(dst_row, src_row, width * 4);
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned y;
- for(y = 0; y < height; ++y) {
- memcpy(dst_row, src_row, width * 4);
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned y;
- for(y = 0; y < height; ++y) {
- memcpy(dst_row, src_row, width * 4);
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint32_t *dst = dst_row;
- const float *src = (const float *)src_row;
- for(x = 0; x < width; ++x) {
- *dst++ = z32_float_to_z32_unorm(*src++);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint32_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint32_t *src = src_row;
- float *dst = (float *)dst_row;
- for(x = 0; x < width; ++x) {
- *dst++ = z32_unorm_to_z32_float(*src++);
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z24_unorm_s8_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- float *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z24_unorm_to_z32_float(value & 0xffffff);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z24_unorm_s8_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- value &= 0xff000000;
- value |= z32_float_to_z24_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z24_unorm_s8_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint32_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z24_unorm_s8_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint32_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint32_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value= *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- value &= 0xff000000;
- value |= z32_unorm_to_z24_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z24_unorm_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint8_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value >> 24;
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z24_unorm_s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint8_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- value &= 0x00ffffff;
- value |= *src++ << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_s8_uscaled_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- float *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z24_unorm_to_z32_float(value >> 8);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_s8_uscaled_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- value &= 0x000000ff;
- value |= z32_float_to_z24_unorm(*src++) << 8;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_s8_uscaled_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint32_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z24_unorm_to_z32_unorm(value >> 8);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_s8_uscaled_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint32_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint32_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- value &= 0x000000ff;
- value |= *src++ & 0xffffff00;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_s8_uscaled_z24_unorm_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint8_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value & 0xff;
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_s8_uscaled_z24_unorm_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint8_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- value &= 0xffffff00;
- value |= *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- float *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z24_unorm_to_z32_float(value & 0xffffff);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value;
- value = z32_float_to_z24_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint32_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint32_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint32_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value;
- value = z32_unorm_to_z24_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- float *dst = dst_row;
- const uint32_t *src = (uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z24_unorm_to_z32_float(value >> 8);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const float *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value;
- value = z32_float_to_z24_unorm(*src++) << 8;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint32_t *dst = dst_row;
- const uint32_t *src = (const uint32_t *)src_row;
- for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = z24_unorm_to_z32_unorm(value >> 8);
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint32_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint32_t *src = src_row;
- uint32_t *dst = (uint32_t *)dst_row;
- for(x = 0; x < width; ++x) {
- uint32_t value;
- value = z32_unorm_to_z24_unorm(*src++) << 8;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z32_float_s8x24_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- float *dst = dst_row;
- const float *src = (const float *)src_row;
- for(x = 0; x < width; ++x) {
- *dst = *src;
- src += 2;
- dst += 1;
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_float_s8x24_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
- const float *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const float *src = src_row;
- float *dst = (float *)dst_row;
- for(x = 0; x < width; ++x) {
- *dst = *src;
- src += 1;
- dst += 2;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z32_float_s8x24_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint32_t *dst = dst_row;
- const float *src = (const float *)src_row;
- for(x = 0; x < width; ++x) {
- *dst = z32_float_to_z32_unorm(*src);
- src += 2;
- dst += 1;
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_float_s8x24_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
- const uint32_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint32_t *src = src_row;
- float *dst = (float *)dst_row;
- for(x = 0; x < width; ++x) {
- *dst++ = z32_unorm_to_z32_float(*src++);
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-void
-util_format_z32_float_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- uint8_t *dst = dst_row;
- const uint8_t *src = src_row + 4;
- for(x = 0; x < width; ++x) {
- *dst = *src;
- src += 8;
- dst += 1;
- }
- src_row += src_stride/sizeof(*src_row);
- dst_row += dst_stride/sizeof(*dst_row);
- }
-}
-
-void
-util_format_z32_float_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- unsigned x, y;
- for(y = 0; y < height; ++y) {
- const uint8_t *src = src_row;
- uint8_t *dst = dst_row + 4;
- for(x = 0; x < width; ++x) {
- *dst = *src;
- src += 1;
- dst += 8;
- }
- dst_row += dst_stride/sizeof(*dst_row);
- src_row += src_stride/sizeof(*src_row);
- }
-}
-
-
-void
-util_format_x24s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
-{
- util_format_z24_unorm_s8_uscaled_unpack_s_8uscaled(dst_row, dst_stride,
- src_row, src_stride,
- width, height);
-}
-
-void
-util_format_x24s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
-{
- util_format_z24_unorm_s8_uscaled_pack_s_8uscaled(dst_row, dst_stride,
- src_row, src_stride,
- width, height);
-}
-
-void
-util_format_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
-{
- util_format_s8_uscaled_z24_unorm_unpack_s_8uscaled(dst_row, dst_stride,
- src_row, src_stride,
- width, height);
-}
-
-void
-util_format_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
-{
- util_format_s8_uscaled_z24_unorm_pack_s_8uscaled(dst_row, dst_stride,
- src_row, src_stride,
- width, height);
-}
-
-void
-util_format_x32_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- util_format_z32_float_s8x24_uscaled_unpack_s_8uscaled(dst_row, dst_stride,
- src_row, src_stride,
- width, height);
-
-}
-
-void
-util_format_x32_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride,
- const uint8_t *src_row, unsigned src_stride,
- unsigned width, unsigned height)
-{
- util_format_z32_float_s8x24_uscaled_pack_s_8uscaled(dst_row, dst_stride,
- src_row, src_stride,
- width, height);
-}
+/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#include "u_debug.h" +#include "u_math.h" +#include "u_format_zs.h" + + +/* + * z32_unorm conversion functions + */ + +static INLINE uint16_t +z32_unorm_to_z16_unorm(uint32_t z) +{ + /* z * 0xffff / 0xffffffff */ + return z >> 16; +} + +static INLINE uint32_t +z16_unorm_to_z32_unorm(uint16_t z) +{ + /* z * 0xffffffff / 0xffff */ + return (z << 16) | z; +} + +static INLINE uint32_t +z32_unorm_to_z24_unorm(uint32_t z) +{ + /* z * 0xffffff / 0xffffffff */ + return z >> 8; +} + +static INLINE uint32_t +z24_unorm_to_z32_unorm(uint32_t z) +{ + /* z * 0xffffffff / 0xffffff */ + return (z << 8) | (z >> 16); +} + + +/* + * z32_float conversion functions + */ + +static INLINE uint16_t +z32_float_to_z16_unorm(float z) +{ + const float scale = 0xffff; + return (uint16_t)(z * scale); +} + +static INLINE float +z16_unorm_to_z32_float(uint16_t z) +{ + const float scale = 1.0 / 0xffff; + return (float)(z * scale); +} + +static INLINE uint32_t +z32_float_to_z24_unorm(float z) +{ + const double scale = 0xffffff; + return (uint32_t)(z * scale) & 0xffffff; +} + +static INLINE float +z24_unorm_to_z32_float(uint32_t z) +{ + const double scale = 1.0 / 0xffffff; + return (float)(z * scale); +} + +static INLINE uint32_t +z32_float_to_z32_unorm(float z) +{ + const double scale = 0xffffffff; + return (uint32_t)(z * scale); +} + +static INLINE float +z32_unorm_to_z32_float(uint32_t z) +{ + const double scale = 1.0 / 0xffffffff; + return (float)(z * scale); +} + + +void +util_format_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned y; + for(y = 0; y < height; ++y) { + memcpy(dst_row, src_row, width); + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned y; + for(y = 0; y < height; ++y) { + memcpy(dst_row, src_row, width); + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + float *dst = dst_row; + const uint16_t *src = (const uint16_t *)src_row; + for(x = 0; x < width; ++x) { + uint16_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *dst++ = z16_unorm_to_z32_float(value); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const float *src = src_row; + uint16_t *dst = (uint16_t *)dst_row; + for(x = 0; x < width; ++x) { + uint16_t value; + value = z32_float_to_z16_unorm(*src++); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint32_t *dst = dst_row; + const uint16_t *src = (const uint16_t *)src_row; + for(x = 0; x < width; ++x) { + uint16_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *dst++ = z16_unorm_to_z32_unorm(value); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, + const uint32_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint32_t *src = src_row; + uint16_t *dst = (uint16_t *)dst_row; + for(x = 0; x < width; ++x) { + uint16_t value; + value = z32_unorm_to_z16_unorm(*src++); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + float *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z32_unorm_to_z32_float(value); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const float *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value; + value = z32_float_to_z32_unorm(*src++); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned y; + for(y = 0; y < height; ++y) { + memcpy(dst_row, src_row, width * 4); + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, + const uint32_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned y; + for(y = 0; y < height; ++y) { + memcpy(dst_row, src_row, width * 4); + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned y; + for(y = 0; y < height; ++y) { + memcpy(dst_row, src_row, width * 4); + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned y; + for(y = 0; y < height; ++y) { + memcpy(dst_row, src_row, width * 4); + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint32_t *dst = dst_row; + const float *src = (const float *)src_row; + for(x = 0; x < width; ++x) { + *dst++ = z32_float_to_z32_unorm(*src++); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, + const uint32_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint32_t *src = src_row; + float *dst = (float *)dst_row; + for(x = 0; x < width; ++x) { + *dst++ = z32_unorm_to_z32_float(*src++); + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + float *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z24_unorm_to_z32_float(value & 0xffffff); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const float *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value = *dst; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + value &= 0xff000000; + value |= z32_float_to_z24_unorm(*src++); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint32_t *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, + const uint32_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint32_t *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value= *dst; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + value &= 0xff000000; + value |= z32_unorm_to_z24_unorm(*src++); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint8_t *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value >> 24; + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint8_t *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value = *dst; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + value &= 0x00ffffff; + value |= *src++ << 24; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + float *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z24_unorm_to_z32_float(value >> 8); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const float *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value = *dst; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + value &= 0x000000ff; + value |= z32_float_to_z24_unorm(*src++) << 8; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint32_t *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z24_unorm_to_z32_unorm(value >> 8); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, + const uint32_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint32_t *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value = *dst; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + value &= 0x000000ff; + value |= *src++ & 0xffffff00; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint8_t *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value & 0xff; + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint8_t *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value = *dst; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + value &= 0xffffff00; + value |= *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + float *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z24_unorm_to_z32_float(value & 0xffffff); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const float *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value; + value = z32_float_to_z24_unorm(*src++); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint32_t *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, + const uint32_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint32_t *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value; + value = z32_unorm_to_z24_unorm(*src++); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + float *dst = dst_row; + const uint32_t *src = (uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z24_unorm_to_z32_float(value >> 8); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const float *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value; + value = z32_float_to_z24_unorm(*src++) << 8; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint32_t *dst = dst_row; + const uint32_t *src = (const uint32_t *)src_row; + for(x = 0; x < width; ++x) { + uint32_t value = *src++; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = z24_unorm_to_z32_unorm(value >> 8); + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, + const uint32_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint32_t *src = src_row; + uint32_t *dst = (uint32_t *)dst_row; + for(x = 0; x < width; ++x) { + uint32_t value; + value = z32_unorm_to_z24_unorm(*src++) << 8; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + *dst++ = value; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + float *dst = dst_row; + const float *src = (const float *)src_row; + for(x = 0; x < width; ++x) { + *dst = *src; + src += 2; + dst += 1; + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, + const float *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const float *src = src_row; + float *dst = (float *)dst_row; + for(x = 0; x < width; ++x) { + *dst = *src; + src += 1; + dst += 2; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint32_t *dst = dst_row; + const float *src = (const float *)src_row; + for(x = 0; x < width; ++x) { + *dst = z32_float_to_z32_unorm(*src); + src += 2; + dst += 1; + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, + const uint32_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint32_t *src = src_row; + float *dst = (float *)dst_row; + for(x = 0; x < width; ++x) { + *dst++ = z32_unorm_to_z32_float(*src++); + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + +void +util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + uint8_t *dst = dst_row; + const uint8_t *src = src_row + 4; + for(x = 0; x < width; ++x) { + *dst = *src; + src += 8; + dst += 1; + } + src_row += src_stride/sizeof(*src_row); + dst_row += dst_stride/sizeof(*dst_row); + } +} + +void +util_format_z32_float_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + unsigned x, y; + for(y = 0; y < height; ++y) { + const uint8_t *src = src_row; + uint8_t *dst = dst_row + 4; + for(x = 0; x < width; ++x) { + *dst = *src; + src += 1; + dst += 8; + } + dst_row += dst_stride/sizeof(*dst_row); + src_row += src_stride/sizeof(*src_row); + } +} + + +void +util_format_x24s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_z24_unorm_s8_uint_unpack_s_8uint(dst_row, dst_stride, + src_row, src_stride, + width, height); +} + +void +util_format_x24s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_z24_unorm_s8_uint_pack_s_8uint(dst_row, dst_stride, + src_row, src_stride, + width, height); +} + +void +util_format_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_s8_uint_z24_unorm_unpack_s_8uint(dst_row, dst_stride, + src_row, src_stride, + width, height); +} + +void +util_format_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) +{ + util_format_s8_uint_z24_unorm_pack_s_8uint(dst_row, dst_stride, + src_row, src_stride, + width, height); +} + +void +util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + util_format_z32_float_s8x24_uint_unpack_s_8uint(dst_row, dst_stride, + src_row, src_stride, + width, height); + +} + +void +util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, + const uint8_t *src_row, unsigned src_stride, + unsigned width, unsigned height) +{ + util_format_z32_float_s8x24_uint_pack_s_8uint(dst_row, dst_stride, + src_row, src_stride, + width, height); +} diff --git a/mesalib/src/gallium/auxiliary/util/u_format_zs.h b/mesalib/src/gallium/auxiliary/util/u_format_zs.h index c3d9f484f..adddfaf3a 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_zs.h +++ b/mesalib/src/gallium/auxiliary/util/u_format_zs.h @@ -1,212 +1,212 @@ -/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- **************************************************************************/
-
-
-#ifndef U_FORMAT_ZS_H_
-#define U_FORMAT_ZS_H_
-
-
-#include "pipe/p_compiler.h"
-
-
-void
-util_format_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24_unorm_s8_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24_unorm_s8_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24_unorm_s8_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24_unorm_s8_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24_unorm_s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24_unorm_s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_s8_uscaled_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_s8_uscaled_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_s8_uscaled_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_s8_uscaled_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_s8_uscaled_z24_unorm_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_s8_uscaled_z24_unorm_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_s8x24_uscaled_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_s8x24_uscaled_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_s8x24_uscaled_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_s8x24_uscaled_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-
-void
-util_format_z32_float_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-void
-util_format_x24s8_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-void
-util_format_x24s8_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-void
-util_format_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-void
-util_format_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-void
-util_format_x32_s8x24_uscaled_unpack_s_8uscaled(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-
-void
-util_format_x32_s8x24_uscaled_pack_s_8uscaled(uint8_t *dst_row, unsigned dst_sride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
-#endif /* U_FORMAT_ZS_H_ */
+/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#ifndef U_FORMAT_ZS_H_ +#define U_FORMAT_ZS_H_ + + +#include "pipe/p_compiler.h" + + +void +util_format_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + + +void +util_format_z32_float_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_x24s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_x24s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); + +void +util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_sride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); +#endif /* U_FORMAT_ZS_H_ */ diff --git a/mesalib/src/gallium/auxiliary/util/u_pack_color.h b/mesalib/src/gallium/auxiliary/util/u_pack_color.h index 9391f1b80..0bbf769a4 100644 --- a/mesalib/src/gallium/auxiliary/util/u_pack_color.h +++ b/mesalib/src/gallium/auxiliary/util/u_pack_color.h @@ -443,13 +443,13 @@ util_pack_mask_z(enum pipe_format format, uint32_t z) case PIPE_FORMAT_Z32_UNORM: case PIPE_FORMAT_Z32_FLOAT: return z; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: case PIPE_FORMAT_Z24X8_UNORM: return z & 0xffffff; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: return (z & 0xffffff) << 8; - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: return 0; default: debug_print_format("gallium: unhandled format in util_pack_mask_z()", format); @@ -463,7 +463,7 @@ static INLINE uint64_t util_pack64_mask_z(enum pipe_format format, uint32_t z) { switch (format) { - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: return z; default: return util_pack_mask_z(format, z); @@ -477,13 +477,13 @@ util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) uint32_t packed = util_pack_mask_z(format, z); switch (format) { - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: packed |= (uint32_t)s << 24; break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: packed |= s; break; - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: packed |= s; break; default: @@ -500,7 +500,7 @@ util_pack64_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) uint64_t packed; switch (format) { - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: packed = util_pack64_mask_z(format, z); packed |= (uint64_t)s << 32ull; return packed; @@ -534,17 +534,17 @@ util_pack_z(enum pipe_format format, double z) case PIPE_FORMAT_Z32_FLOAT: fui.f = (float)z; return fui.ui; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: case PIPE_FORMAT_Z24X8_UNORM: if (z == 1.0) return 0xffffff; return (uint32_t) (z * 0xffffff); - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: if (z == 1.0) return 0xffffff00; return ((uint32_t) (z * 0xffffff)) << 8; - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: /* this case can get it via util_pack_z_stencil() */ return 0; default: @@ -564,7 +564,7 @@ util_pack64_z(enum pipe_format format, double z) return 0; switch (format) { - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: fui.f = (float)z; return fui.ui; default: @@ -583,13 +583,13 @@ util_pack_z_stencil(enum pipe_format format, double z, uint8_t s) uint32_t packed = util_pack_z(format, z); switch (format) { - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: packed |= (uint32_t)s << 24; break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: packed |= s; break; - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: packed |= s; break; default: @@ -606,7 +606,7 @@ util_pack64_z_stencil(enum pipe_format format, double z, uint8_t s) uint64_t packed; switch (format) { - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: packed = util_pack64_z(format, z); packed |= (uint64_t)s << 32ull; break; diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.c b/mesalib/src/gallium/auxiliary/util/u_surface.c index 308511b33..c7fbd3657 100644 --- a/mesalib/src/gallium/auxiliary/util/u_surface.c +++ b/mesalib/src/gallium/auxiliary/util/u_surface.c @@ -311,7 +311,7 @@ util_clear_depth_stencil(struct pipe_context *pipe, switch (util_format_get_blocksize(dst->format)) { case 1: - assert(dst->format == PIPE_FORMAT_S8_USCALED); + assert(dst->format == PIPE_FORMAT_S8_UINT); if(dst_stride == width) memset(dst_map, (ubyte) zstencil, height * width); else { @@ -341,10 +341,10 @@ util_clear_depth_stencil(struct pipe_context *pipe, } else { uint32_t dst_mask; - if (dst->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED) + if (dst->format == PIPE_FORMAT_Z24_UNORM_S8_UINT) dst_mask = 0xffffff00; else { - assert(dst->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM); + assert(dst->format == PIPE_FORMAT_S8_UINT_Z24_UNORM); dst_mask = 0xffffff; } if (clear_flags & PIPE_CLEAR_DEPTH) @@ -364,7 +364,7 @@ util_clear_depth_stencil(struct pipe_context *pipe, uint64_t zstencil = util_pack64_z_stencil(dst->texture->format, depth, stencil); - assert(dst->format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED); + assert(dst->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT); if (!need_rmw) { for (i = 0; i < height; i++) { diff --git a/mesalib/src/gallium/auxiliary/util/u_tile.c b/mesalib/src/gallium/auxiliary/util/u_tile.c index 6342bfbfc..02bdb731d 100644 --- a/mesalib/src/gallium/auxiliary/util/u_tile.c +++ b/mesalib/src/gallium/auxiliary/util/u_tile.c @@ -164,7 +164,7 @@ z32_get_tile_rgba(const unsigned *src, } -/*** PIPE_FORMAT_Z24_UNORM_S8_USCALED ***/ +/*** PIPE_FORMAT_Z24_UNORM_S8_UINT ***/ /** * Return Z component as four float in [0,1]. Stencil part ignored. @@ -191,7 +191,7 @@ s8z24_get_tile_rgba(const unsigned *src, } -/*** PIPE_FORMAT_S8_USCALED_Z24_UNORM ***/ +/*** PIPE_FORMAT_S8_UINT_Z24_UNORM ***/ /** * Return Z component as four float in [0,1]. Stencil part ignored. @@ -217,7 +217,7 @@ z24s8_get_tile_rgba(const unsigned *src, } } -/*** PIPE_FORMAT_S8X24_USCALED ***/ +/*** PIPE_FORMAT_S8X24_UINT ***/ /** * Return S component as four uint32_t in [0..255]. Z part ignored. @@ -244,7 +244,7 @@ s8x24_get_tile_rgba(const unsigned *src, } } -/*** PIPE_FORMAT_X24S8_USCALED ***/ +/*** PIPE_FORMAT_X24S8_UINT ***/ /** * Return S component as four uint32_t in [0..255]. Z part ignored. @@ -318,7 +318,7 @@ z32f_get_tile_rgba(const float *src, } } -/*** PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED ***/ +/*** PIPE_FORMAT_Z32_FLOAT_S8X24_UINT ***/ /** * Return each Z value as four floats in [0,1]. @@ -358,27 +358,27 @@ pipe_tile_raw_to_rgba(enum pipe_format format, case PIPE_FORMAT_Z32_UNORM: z32_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: case PIPE_FORMAT_Z24X8_UNORM: s8z24_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: s8_get_tile_rgba((unsigned char *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_X24S8_USCALED: + case PIPE_FORMAT_X24S8_UINT: s8x24_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: z24s8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_S8X24_USCALED: + case PIPE_FORMAT_S8X24_UINT: x24s8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; case PIPE_FORMAT_Z32_FLOAT: z32f_get_tile_rgba((float *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: z32f_x24s8_get_tile_rgba((float *) src, w, h, dst, dst_stride); break; default: @@ -489,18 +489,18 @@ pipe_put_tile_rgba_format(struct pipe_context *pipe, case PIPE_FORMAT_Z32_UNORM: /*z32_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: case PIPE_FORMAT_Z24X8_UNORM: /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; case PIPE_FORMAT_Z32_FLOAT: /*z32f_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: /*z32f_s8x24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; default: @@ -607,7 +607,7 @@ pipe_get_tile_z(struct pipe_context *pipe, } } break; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: case PIPE_FORMAT_Z24X8_UNORM: { const uint *ptrc @@ -622,7 +622,7 @@ pipe_get_tile_z(struct pipe_context *pipe, } } break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: { const uint *ptrc @@ -691,7 +691,7 @@ pipe_put_tile_z(struct pipe_context *pipe, } } break; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: { uint *pDest = (uint *) (map + y * pt->stride + x*4); /*assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);*/ @@ -718,7 +718,7 @@ pipe_put_tile_z(struct pipe_context *pipe, } } break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: { uint *pDest = (uint *) (map + y * pt->stride + x*4); /*assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);*/ diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp index c1befa95c..9adf47050 100644 --- a/mesalib/src/glsl/ir_clone.cpp +++ b/mesalib/src/glsl/ir_clone.cpp @@ -25,9 +25,7 @@ #include "main/compiler.h" #include "ir.h" #include "glsl_types.h" -extern "C" { #include "program/hash_table.h" -} /** * Duplicate an IR variable diff --git a/mesalib/src/glsl/ir_print_visitor.cpp b/mesalib/src/glsl/ir_print_visitor.cpp index ea7858224..b713bd03b 100644 --- a/mesalib/src/glsl/ir_print_visitor.cpp +++ b/mesalib/src/glsl/ir_print_visitor.cpp @@ -24,10 +24,7 @@ #include "ir_print_visitor.h" #include "glsl_types.h" #include "glsl_parser_extras.h" - -extern "C" { #include "program/hash_table.h" -} static void print_type(const glsl_type *t); diff --git a/mesalib/src/glsl/ir_set_program_inouts.cpp b/mesalib/src/glsl/ir_set_program_inouts.cpp index 3b10b9097..ae3ef74c7 100644 --- a/mesalib/src/glsl/ir_set_program_inouts.cpp +++ b/mesalib/src/glsl/ir_set_program_inouts.cpp @@ -34,10 +34,8 @@ * from the GLSL IR. */ -extern "C" { #include "main/core.h" /* for struct gl_program */ #include "program/hash_table.h" -} #include "ir.h" #include "ir_visitor.h" #include "glsl_types.h" diff --git a/mesalib/src/glsl/ir_variable.cpp b/mesalib/src/glsl/ir_variable.cpp index 58be64bfa..6ae3b1f9e 100644 --- a/mesalib/src/glsl/ir_variable.cpp +++ b/mesalib/src/glsl/ir_variable.cpp @@ -178,6 +178,14 @@ static struct gl_builtin_uniform_element gl_MESAFogParamsOptimized_elements[] = {NULL, {STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED}, SWIZZLE_XYZW}, }; +static struct gl_builtin_uniform_element gl_CurrentAttribVertMESA_elements[] = { + {NULL, {STATE_INTERNAL, STATE_CURRENT_ATTRIB, 0}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_CurrentAttribFragMESA_elements[] = { + {NULL, {STATE_INTERNAL, STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, 0}, SWIZZLE_XYZW}, +}; + #define MATRIX(name, statevar, modifier) \ static struct gl_builtin_uniform_element name ## _elements[] = { \ { NULL, { statevar, 0, 0, 0, modifier}, SWIZZLE_XYZW }, \ @@ -284,6 +292,8 @@ const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { STATEVAR(gl_MESABumpRotMatrix0), STATEVAR(gl_MESABumpRotMatrix1), STATEVAR(gl_MESAFogParamsOptimized), + STATEVAR(gl_CurrentAttribVertMESA), + STATEVAR(gl_CurrentAttribFragMESA), {NULL, NULL, 0} }; @@ -355,7 +365,12 @@ add_uniform(exec_list *instructions, glsl_symbol_table *symtab, memcpy(slots->tokens, element->tokens, sizeof(element->tokens)); if (type->is_array()) { - slots->tokens[1] = a; + if (strcmp(name, "gl_CurrentAttribVertMESA") == 0 || + strcmp(name, "gl_CurrentAttribFragMESA") == 0) { + slots->tokens[2] = a; + } else { + slots->tokens[1] = a; + } } slots->swizzle = element->swizzle; @@ -518,6 +533,14 @@ generate_110_uniforms(exec_list *instructions, add_uniform(instructions, symtab, "gl_Fog", symtab->get_type("gl_FogParameters")); + + /* Mesa-internal current attrib state */ + const glsl_type *const vert_attribs = + glsl_type::get_array_instance(glsl_type::vec4_type, VERT_ATTRIB_MAX); + add_uniform(instructions, symtab, "gl_CurrentAttribVertMESA", vert_attribs); + const glsl_type *const frag_attribs = + glsl_type::get_array_instance(glsl_type::vec4_type, FRAG_ATTRIB_MAX); + add_uniform(instructions, symtab, "gl_CurrentAttribFragMESA", frag_attribs); } /* This function should only be called for ES, not desktop GL. */ diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp index 9463f5305..a7c38a342 100644 --- a/mesalib/src/glsl/linker.cpp +++ b/mesalib/src/glsl/linker.cpp @@ -1342,7 +1342,10 @@ assign_attribute_or_color_locations(gl_shader_program *prog, } } - /* The location was explicitly assigned, nothing to do here. + /* If the variable is not a built-in and has a location statically + * assigned in the shader (presumably via a layout qualifier), make sure + * that it doesn't collide with other assigned locations. Otherwise, + * add it to the list of variables that need linker-assigned locations. */ const unsigned slots = count_attribute_slots(var->type); if (var->location != -1) { @@ -1802,7 +1805,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) * present in a linked program. By checking for use of shading language * version 1.00, we also catch the GL_ARB_ES2_compatibility case. */ - if (ctx->API == API_OPENGLES2 || prog->Version == 100) { + if (!prog->InternalSeparateShader && + (ctx->API == API_OPENGLES2 || prog->Version == 100)) { if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) { linker_error(prog, "program lacks a vertex shader\n"); } else if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) { diff --git a/mesalib/src/glsl/opt_tree_grafting.cpp b/mesalib/src/glsl/opt_tree_grafting.cpp index 22a1749b9..d32d14e88 100644 --- a/mesalib/src/glsl/opt_tree_grafting.cpp +++ b/mesalib/src/glsl/opt_tree_grafting.cpp @@ -76,6 +76,8 @@ public: virtual ir_visitor_status visit_enter(class ir_swizzle *); virtual ir_visitor_status visit_enter(class ir_texture *); + ir_visitor_status check_graft(ir_instruction *ir, ir_variable *var); + bool do_graft(ir_rvalue **rvalue); bool progress; @@ -148,18 +150,17 @@ ir_tree_grafting_visitor::visit_enter(ir_loop *ir) return visit_stop; } +/** + * Check if we can continue grafting after writing to a variable. If the + * expression we're trying to graft references the variable, we must stop. + * + * \param ir An instruction that writes to a variable. + * \param var The variable being updated. + */ ir_visitor_status -ir_tree_grafting_visitor::visit_leave(ir_assignment *ir) +ir_tree_grafting_visitor::check_graft(ir_instruction *ir, ir_variable *var) { - if (do_graft(&ir->rhs) || - do_graft(&ir->condition)) - return visit_stop; - - /* If this assignment updates a variable used in the assignment - * we're trying to graft, then we're done. - */ - if (dereferences_variable(this->graft_assign->rhs, - ir->lhs->variable_referenced())) { + if (dereferences_variable(this->graft_assign->rhs, var)) { if (debug) { printf("graft killed by: "); ir->print(); @@ -172,6 +173,19 @@ ir_tree_grafting_visitor::visit_leave(ir_assignment *ir) } ir_visitor_status +ir_tree_grafting_visitor::visit_leave(ir_assignment *ir) +{ + if (do_graft(&ir->rhs) || + do_graft(&ir->condition)) + return visit_stop; + + /* If this assignment updates a variable used in the assignment + * we're trying to graft, then we're done. + */ + return check_graft(ir, ir->lhs->variable_referenced()); +} + +ir_visitor_status ir_tree_grafting_visitor::visit_enter(ir_function *ir) { (void) ir; @@ -195,8 +209,11 @@ ir_tree_grafting_visitor::visit_enter(ir_call *ir) ir_rvalue *ir = (ir_rvalue *)iter.get(); ir_rvalue *new_ir = ir; - if (sig_param->mode != ir_var_in && sig_param->mode != ir_var_const_in) + if (sig_param->mode != ir_var_in && sig_param->mode != ir_var_const_in) { + if (check_graft(ir, sig_param) == visit_stop) + return visit_stop; continue; + } if (do_graft(&new_ir)) { ir->replace_with(new_ir); diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index 9f142bf08..45414bcde 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -129,6 +129,7 @@ main_sources = [ 'main/texstore.c', 'main/texturebarrier.c', 'main/transformfeedback.c', + 'main/uniform_query.cpp', 'main/uniforms.c', 'main/varray.c', 'main/version.c', diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c index 33da9346c..263d4025f 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.c +++ b/mesalib/src/mesa/drivers/common/driverfuncs.c @@ -208,6 +208,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->ProgramStringNotify = _tnl_program_string; driver->FlushVertices = NULL; driver->SaveFlushVertices = NULL; + driver->PrepareExecBegin = NULL; driver->NotifySaveBegin = NULL; driver->LightingSpaceChange = NULL; diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 5b73dcdfb..c7bb93380 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -44,6 +44,7 @@ #include "main/depth.h" #include "main/enable.h" #include "main/fbobject.h" +#include "main/feedback.h" #include "main/formats.h" #include "main/image.h" #include "main/macros.h" @@ -172,6 +173,11 @@ struct save_state struct gl_query_object *CondRenderQuery; GLenum CondRenderMode; + /** MESA_META_SELECT_FEEDBACK */ + GLenum RenderMode; + struct gl_selection Select; + struct gl_feedback Feedback; + /** Miscellaneous (always disabled) */ GLboolean Lighting; }; @@ -273,7 +279,7 @@ struct decompress_state }; -#define MAX_META_OPS_DEPTH 2 +#define MAX_META_OPS_DEPTH 8 /** * All per-context meta state. */ @@ -464,7 +470,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) _mesa_reference_shader_program(ctx, &save->FragmentShader, ctx->Shader.CurrentFragmentProgram); _mesa_reference_shader_program(ctx, &save->ActiveShader, - ctx->Shader.CurrentFragmentProgram); + ctx->Shader.ActiveProgram); _mesa_UseProgramObjectARB(0); } @@ -608,6 +614,17 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) _mesa_EndConditionalRender(); } + if (state & MESA_META_SELECT_FEEDBACK) { + save->RenderMode = ctx->RenderMode; + if (ctx->RenderMode == GL_SELECT) { + save->Select = ctx->Select; /* struct copy */ + _mesa_RenderMode(GL_RENDER); + } else if (ctx->RenderMode == GL_FEEDBACK) { + save->Feedback = ctx->Feedback; /* struct copy */ + _mesa_RenderMode(GL_RENDER); + } + } + /* misc */ { save->Lighting = ctx->Light.Enabled; @@ -893,6 +910,16 @@ _mesa_meta_end(struct gl_context *ctx) save->CondRenderMode); } + if (state & MESA_META_SELECT_FEEDBACK) { + if (save->RenderMode == GL_SELECT) { + _mesa_RenderMode(GL_SELECT); + ctx->Select = save->Select; + } else if (save->RenderMode == GL_FEEDBACK) { + _mesa_RenderMode(GL_FEEDBACK); + ctx->Feedback = save->Feedback; + } + } + /* misc */ if (save->Lighting) { _mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE); @@ -2942,7 +2969,7 @@ get_temp_image_type(struct gl_context *ctx, GLenum baseFormat) case GL_INTENSITY: if (ctx->DrawBuffer->Visual.redBits <= 8) return GL_UNSIGNED_BYTE; - else if (ctx->DrawBuffer->Visual.redBits <= 8) + else if (ctx->DrawBuffer->Visual.redBits <= 16) return GL_UNSIGNED_SHORT; else return GL_FLOAT; diff --git a/mesalib/src/mesa/drivers/common/meta.h b/mesalib/src/mesa/drivers/common/meta.h index 7ec568388..e0435a822 100644 --- a/mesalib/src/mesa/drivers/common/meta.h +++ b/mesalib/src/mesa/drivers/common/meta.h @@ -54,6 +54,7 @@ #define MESA_META_CLAMP_VERTEX_COLOR 0x10000 #define MESA_META_CONDITIONAL_RENDER 0x20000 #define MESA_META_CLIP 0x40000 +#define MESA_META_SELECT_FEEDBACK 0x80000 /**\}*/ extern void diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index fc52e8c15..e0af6ee67 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -1833,8 +1833,6 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentFragmentProgram; for (i = 0; i < MESA_SHADER_TYPES; i++) { - struct gl_shader *sh; - if (shProg[i] == NULL || shProg[i]->_Used || shProg[i]->_LinkedShaders[i] == NULL) continue; @@ -1842,27 +1840,13 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) /* This is the first time this shader is being used. * Append shader's constants/uniforms to log file. * - * The logic is a little odd here. We only want to log data for each - * shader target that will actually be used, and we only want to log - * it once. It's possible to have a program bound to the vertex + * Only log data for the program target that matches the shader + * target. It's possible to have a program bound to the vertex * shader target that also supplied a fragment shader. If that * program isn't also bound to the fragment shader target we don't * want to log its fragment data. */ - sh = shProg[i]->_LinkedShaders[i]; - switch (sh->Type) { - case GL_VERTEX_SHADER: - _mesa_append_uniforms_to_file(sh, sh->Program); - break; - - case GL_GEOMETRY_SHADER_ARB: - _mesa_append_uniforms_to_file(sh, sh->Program); - break; - - case GL_FRAGMENT_SHADER: - _mesa_append_uniforms_to_file(sh, sh->Program); - break; - } + _mesa_append_uniforms_to_file(shProg[i]->_LinkedShaders[i]); } for (i = 0; i < MESA_SHADER_TYPES; i++) { diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index 4e017ae38..8607008de 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -861,6 +861,14 @@ struct dd_function_table { void (*SaveFlushVertices)( struct gl_context *ctx ); /** + * \brief Hook for drivers to prepare for a glBegin/glEnd block + * + * This hook is called in vbo_exec_Begin() before any action, including + * state updates, occurs. + */ + void (*PrepareExecBegin)( struct gl_context *ctx ); + + /** * Give the driver the opportunity to hook in its own vtxfmt for * compiling optimized display lists. This is called on each valid * glBegin() during list compilation. diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c index 343feec6f..625649e9d 100644 --- a/mesalib/src/mesa/main/dlist.c +++ b/mesalib/src/mesa/main/dlist.c @@ -875,7 +875,7 @@ translate_id(GLsizei n, GLenum type, const GLvoid * list) /**********************************************************************/ /** - * Wrapper for _mesa_unpack_image() that handles pixel buffer objects. + * Wrapper for _mesa_unpack_image/bitmap() that handles pixel buffer objects. * If width < 0 or height < 0 or format or type are invalid we'll just * return NULL. We will not generate an error since OpenGL command * arguments aren't error-checked until the command is actually executed @@ -899,8 +899,13 @@ unpack_image(struct gl_context *ctx, GLuint dimensions, if (!_mesa_is_bufferobj(unpack->BufferObj)) { /* no PBO */ - GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, pixels, unpack); + GLvoid *image; + + if (type == GL_BITMAP) + image = _mesa_unpack_bitmap(width, height, pixels, unpack); + else + image = _mesa_unpack_image(dimensions, width, height, depth, + format, type, pixels, unpack); if (pixels && !image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); } @@ -921,8 +926,11 @@ unpack_image(struct gl_context *ctx, GLuint dimensions, } src = ADD_POINTERS(map, pixels); - image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, src, unpack); + if (type == GL_BITMAP) + image = _mesa_unpack_bitmap(width, height, src, unpack); + else + image = _mesa_unpack_image(dimensions, width, height, depth, + format, type, src, unpack); ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); @@ -935,7 +943,6 @@ unpack_image(struct gl_context *ctx, GLuint dimensions, return NULL; } - /** * Allocate space for a display list instruction (opcode + payload space). * \param opcode the instruction opcode (OPCODE_* value) @@ -1121,7 +1128,8 @@ save_Bitmap(GLsizei width, GLsizei height, n[4].f = yorig; n[5].f = xmove; n[6].f = ymove; - n[7].data = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack); + n[7].data = unpack_image(ctx, 2, width, height, 1, GL_COLOR_INDEX, + GL_BITMAP, pixels, &ctx->Unpack); } if (ctx->ExecuteFlag) { CALL_Bitmap(ctx->Exec, (width, height, @@ -4509,6 +4517,24 @@ save_MultTransposeMatrixfARB(const GLfloat m[16]) save_MultMatrixf(tm); } +static GLvoid *copy_data(const GLvoid *data, GLsizei size, const char *func) +{ + GET_CURRENT_CONTEXT(ctx); + GLvoid *image; + + if (!data) + return NULL; + + image = malloc(size); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func); + return NULL; + } + memcpy(image, data, size); + + return image; +} + /* GL_ARB_texture_compression */ static void GLAPIENTRY @@ -4526,15 +4552,8 @@ save_CompressedTexImage1DARB(GLenum target, GLint level, } else { Node *n; - GLvoid *image; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); - return; - } - memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7); if (n) { n[1].e = target; @@ -4543,10 +4562,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level, n[4].i = (GLint) width; n[5].i = border; n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); + n[7].data = copy_data(data, imageSize, "glCompressedTexImage1DARB"); } if (ctx->ExecuteFlag) { CALL_CompressedTexImage1DARB(ctx->Exec, @@ -4572,15 +4588,8 @@ save_CompressedTexImage2DARB(GLenum target, GLint level, } else { Node *n; - GLvoid *image; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); - return; - } - memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8); if (n) { n[1].e = target; @@ -4590,10 +4599,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level, n[5].i = (GLint) height; n[6].i = border; n[7].i = imageSize; - n[8].data = image; - } - else if (image) { - free(image); + n[8].data = copy_data(data, imageSize, "glCompressedTexImage2DARB"); } if (ctx->ExecuteFlag) { CALL_CompressedTexImage2DARB(ctx->Exec, @@ -4619,15 +4625,8 @@ save_CompressedTexImage3DARB(GLenum target, GLint level, } else { Node *n; - GLvoid *image; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); - return; - } - memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9); if (n) { n[1].e = target; @@ -4638,10 +4637,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level, n[6].i = (GLint) depth; n[7].i = border; n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); + n[9].data = copy_data(data, imageSize, "glCompressedTexImage3DARB"); } if (ctx->ExecuteFlag) { CALL_CompressedTexImage3DARB(ctx->Exec, @@ -4659,18 +4655,9 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei imageSize, const GLvoid * data) { Node *n; - GLvoid *image; - GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); - return; - } - memcpy(image, data, imageSize); n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7); if (n) { n[1].e = target; @@ -4679,10 +4666,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, n[4].i = (GLint) width; n[5].e = format; n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); + n[7].data = copy_data(data, imageSize, "glCompressedTexSubImage1DARB"); } if (ctx->ExecuteFlag) { CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, @@ -4699,18 +4683,9 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, const GLvoid * data) { Node *n; - GLvoid *image; - GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); - return; - } - memcpy(image, data, imageSize); n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9); if (n) { n[1].e = target; @@ -4721,10 +4696,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, n[6].i = (GLint) height; n[7].e = format; n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); + n[9].data = copy_data(data, imageSize, "glCompressedTexSubImage2DARB"); } if (ctx->ExecuteFlag) { CALL_CompressedTexSubImage2DARB(ctx->Exec, @@ -4741,18 +4713,9 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLsizei imageSize, const GLvoid * data) { Node *n; - GLvoid *image; - GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); - return; - } - memcpy(image, data, imageSize); n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11); if (n) { n[1].e = target; @@ -4765,10 +4728,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, n[8].i = (GLint) depth; n[9].e = format; n[10].i = imageSize; - n[11].data = image; - } - else if (image) { - free(image); + n[11].data = copy_data(data, imageSize, "glCompressedTexSubImage3DARB"); } if (ctx->ExecuteFlag) { CALL_CompressedTexSubImage3DARB(ctx->Exec, diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index 757115584..f9da54e73 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -254,14 +254,8 @@ _mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, if (ctx->API != API_OPENGL) return NULL; /* fall-through */ - case GL_DEPTH_BUFFER: - /* fall-through / new in GL 3.0 */ case GL_DEPTH_ATTACHMENT_EXT: return &fb->Attachment[BUFFER_DEPTH]; - case GL_STENCIL_BUFFER: - if (ctx->API != API_OPENGL) - return NULL; - /* fall-through / new in GL 3.0 */ case GL_STENCIL_ATTACHMENT_EXT: return &fb->Attachment[BUFFER_STENCIL]; default: @@ -294,13 +288,34 @@ _mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, return &fb->Attachment[BUFFER_AUX0]; } return NULL; - case GL_DEPTH_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_DEPTH_ATTACHMENT_EXT: + + /* Page 336 (page 352 of the PDF) of the OpenGL 3.0 spec says: + * + * "If the default framebuffer is bound to target, then attachment must + * be one of FRONT LEFT, FRONT RIGHT, BACK LEFT, BACK RIGHT, or AUXi, + * identifying a color buffer; DEPTH, identifying the depth buffer; or + * STENCIL, identifying the stencil buffer." + * + * Revision #34 of the ARB_framebuffer_object spec has essentially the same + * language. However, revision #33 of the ARB_framebuffer_object spec + * says: + * + * "If the default framebuffer is bound to <target>, then <attachment> + * must be one of FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, AUXi, + * DEPTH_BUFFER, or STENCIL_BUFFER, identifying a color buffer, the + * depth buffer, or the stencil buffer, and <pname> may be + * FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE or + * FRAMEBUFFER_ATTACHMENT_OBJECT_NAME." + * + * The enum values for DEPTH_BUFFER and STENCIL_BUFFER have been removed + * from glext.h, so shipping apps should not use those values. + * + * Note that neither EXT_framebuffer_object nor OES_framebuffer_object + * support queries of the window system FBO. + */ + case GL_DEPTH: return &fb->Attachment[BUFFER_DEPTH]; - case GL_STENCIL_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_STENCIL_ATTACHMENT_EXT: + case GL_STENCIL: return &fb->Attachment[BUFFER_STENCIL]; default: return NULL; @@ -2261,6 +2276,21 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, } if (is_winsys_fbo(buffer)) { + /* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec + * says: + * + * "If the framebuffer currently bound to target is zero, then + * INVALID_OPERATION is generated." + * + * The EXT_framebuffer_object spec has the same wording, and the + * OES_framebuffer_object spec refers to the EXT_framebuffer_object + * spec. + */ + if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetFramebufferAttachmentParameteriv(bound FBO = 0)"); + return; + } /* the default / window-system FBO */ att = _mesa_get_fb0_attachment(ctx, buffer, attachment); } diff --git a/mesalib/src/mesa/main/feedback.c b/mesalib/src/mesa/main/feedback.c index cb5f49f67..f95e3b5d4 100644 --- a/mesalib/src/mesa/main/feedback.c +++ b/mesalib/src/mesa/main/feedback.c @@ -418,7 +418,7 @@ _mesa_PopName( void ) * __struct gl_contextRec::RenderMode and notifies the driver via the * dd_function_table::RenderMode callback. */ -static GLint GLAPIENTRY +GLint GLAPIENTRY _mesa_RenderMode( GLenum mode ) { GET_CURRENT_CONTEXT(ctx); diff --git a/mesalib/src/mesa/main/feedback.h b/mesalib/src/mesa/main/feedback.h index 6d256ee8f..c64db3134 100644 --- a/mesalib/src/mesa/main/feedback.h +++ b/mesalib/src/mesa/main/feedback.h @@ -33,6 +33,9 @@ #if FEATURE_feedback +extern GLint GLAPIENTRY +_mesa_RenderMode( GLenum mode ); + extern void _mesa_feedback_vertex( struct gl_context *ctx, const GLfloat win[4], diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index e6451c98b..160a97c0c 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -3,6 +3,7 @@ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * Copyright 2009 VMware, Inc. All Rights Reserved. + * Copyright © 2010-2011 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -30,6 +31,8 @@ extern "C" { #include "glheader.h" #include "imports.h" #include "mtypes.h" +#include "main/uniforms.h" +#include "main/macros.h" #include "program/program.h" #include "program/prog_parameter.h" #include "program/prog_cache.h" @@ -39,6 +42,13 @@ extern "C" { #include "program/programopt.h" #include "texenvprogram.h" } +#include "../glsl/glsl_types.h" +#include "../glsl/ir.h" +#include "../glsl/glsl_symbol_table.h" +#include "../glsl/glsl_parser_extras.h" +#include "../glsl/ir_optimization.h" +#include "../glsl/ir_print_visitor.h" +#include "../program/ir_to_mesa.h" /* * Note on texture units: @@ -59,7 +69,7 @@ struct texenvprog_cache_item { GLuint hash; void *key; - struct gl_fragment_program *data; + struct gl_shader_program *data; struct texenvprog_cache_item *next; }; @@ -76,13 +86,6 @@ texenv_doing_secondary_color(struct gl_context *ctx) return GL_FALSE; } -/** - * Up to nine instructions per tex unit, plus fog, specular color. - */ -#define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12) - -#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM) - struct mode_opt { #ifdef __GNUC__ __extension__ GLubyte Source:4; /**< SRC_x */ @@ -116,8 +119,6 @@ struct state_key { GLuint NumArgsA:3; /**< up to MAX_COMBINER_TERMS */ GLuint ModeA:5; /**< MODE_x */ - GLuint texture_cyl_wrap:1; /**< For gallium test/debug only */ - struct mode_opt OptRGB[MAX_COMBINER_TERMS]; struct mode_opt OptA[MAX_COMBINER_TERMS]; } unit[MAX_TEXTURE_UNITS]; @@ -470,10 +471,6 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) key->unit[i].OptRGB[1].Operand = OPR_SRC_COLOR; key->unit[i].OptRGB[1].Source = texUnit->BumpTarget - GL_TEXTURE0 + SRC_TEXTURE0; } - - /* this is a back-door for enabling cylindrical texture wrap mode */ - if (texObj->Priority == 0.125) - key->unit[i].texture_cyl_wrap = 1; } /* _NEW_LIGHT | _NEW_FOG */ @@ -502,40 +499,15 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) } -/** - * Use uregs to represent registers internally, translate to Mesa's - * expected formats on emit. - * - * NOTE: These are passed by value extensively in this file rather - * than as usual by pointer reference. If this disturbs you, try - * remembering they are just 32bits in size. - * - * GCC is smart enough to deal with these dword-sized structures in - * much the same way as if I had defined them as dwords and was using - * macros to access and set the fields. This is much nicer and easier - * to evolve. - */ -struct ureg { - GLuint file:4; - GLuint idx:8; - GLuint negatebase:1; - GLuint swz:12; - GLuint pad:7; -}; - -static const struct ureg undef = { - PROGRAM_UNDEFINED, - 255, - 0, - 0, - 0 -}; - - /** State used to build the fragment program: */ struct texenv_fragment_program { + struct gl_shader_program *shader_program; + struct gl_shader *shader; struct gl_fragment_program *program; + exec_list *instructions; + exec_list *top_instructions; + void *mem_ctx; struct state_key *state; GLbitfield alu_temps; /**< Track texture indirections, see spec. */ @@ -543,386 +515,60 @@ struct texenv_fragment_program { GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */ GLboolean error; - struct ureg src_texture[MAX_TEXTURE_COORD_UNITS]; + ir_variable *src_texture[MAX_TEXTURE_COORD_UNITS]; /* Reg containing each texture unit's sampled texture color, * else undef. */ - struct ureg texcoord_tex[MAX_TEXTURE_COORD_UNITS]; + /* Texcoord override from bumpmapping. */ + struct ir_variable *texcoord_tex[MAX_TEXTURE_COORD_UNITS]; + /* Reg containing texcoord for a texture unit, * needed for bump mapping, else undef. */ - struct ureg src_previous; /**< Reg containing color from previous + ir_rvalue *src_previous; /**< Reg containing color from previous * stage. May need to be decl'd. */ GLuint last_tex_stage; /**< Number of last enabled texture unit */ - - struct ureg half; - struct ureg one; - struct ureg zero; }; - - -static struct ureg make_ureg(GLuint file, GLuint idx) +static ir_rvalue * +get_current_attrib(struct texenv_fragment_program *p, GLuint attrib) { - struct ureg reg; - reg.file = file; - reg.idx = idx; - reg.negatebase = 0; - reg.swz = SWIZZLE_NOOP; - reg.pad = 0; - return reg; + ir_variable *current; + ir_rvalue *val; + + current = p->shader->symbols->get_variable("gl_CurrentAttribFragMESA"); + current->max_array_access = MAX2(current->max_array_access, attrib); + val = new(p->mem_ctx) ir_dereference_variable(current); + ir_rvalue *index = new(p->mem_ctx) ir_constant(attrib); + return new(p->mem_ctx) ir_dereference_array(val, index); } -static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) +static ir_rvalue * +get_gl_Color(struct texenv_fragment_program *p) { - reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x), - GET_SWZ(reg.swz, y), - GET_SWZ(reg.swz, z), - GET_SWZ(reg.swz, w)); - - return reg; -} - -static struct ureg swizzle1( struct ureg reg, int x ) -{ - return swizzle(reg, x, x, x, x); -} - -static struct ureg negate( struct ureg reg ) -{ - reg.negatebase ^= 1; - return reg; -} - -static GLboolean is_undef( struct ureg reg ) -{ - return reg.file == PROGRAM_UNDEFINED; -} - - -static struct ureg get_temp( struct texenv_fragment_program *p ) -{ - GLint bit; - - /* First try and reuse temps which have been used already: - */ - bit = _mesa_ffs( ~p->temp_in_use & p->alu_temps ); - - /* Then any unused temporary: - */ - if (!bit) - bit = _mesa_ffs( ~p->temp_in_use ); - - if (!bit) { - _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); - exit(1); + if (p->state->inputs_available & FRAG_BIT_COL0) { + ir_variable *var = p->shader->symbols->get_variable("gl_Color"); + assert(var); + return new(p->mem_ctx) ir_dereference_variable(var); + } else { + return get_current_attrib(p, VERT_ATTRIB_COLOR0); } - - if ((GLuint) bit > p->program->Base.NumTemporaries) - p->program->Base.NumTemporaries = bit; - - p->temp_in_use |= 1<<(bit-1); - return make_ureg(PROGRAM_TEMPORARY, (bit-1)); } -static struct ureg get_tex_temp( struct texenv_fragment_program *p ) +static ir_rvalue * +get_source(struct texenv_fragment_program *p, + GLuint src, GLuint unit) { - int bit; - - /* First try to find available temp not previously used (to avoid - * starting a new texture indirection). According to the spec, the - * ~p->temps_output isn't necessary, but will keep it there for - * now: - */ - bit = _mesa_ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output ); - - /* Then any unused temporary: - */ - if (!bit) - bit = _mesa_ffs( ~p->temp_in_use ); - - if (!bit) { - _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); - exit(1); - } + ir_variable *var; + ir_dereference *deref; - if ((GLuint) bit > p->program->Base.NumTemporaries) - p->program->Base.NumTemporaries = bit; - - p->temp_in_use |= 1<<(bit-1); - return make_ureg(PROGRAM_TEMPORARY, (bit-1)); -} - - -/** Mark a temp reg as being no longer allocatable. */ -static void reserve_temp( struct texenv_fragment_program *p, struct ureg r ) -{ - if (r.file == PROGRAM_TEMPORARY) - p->temps_output |= (1 << r.idx); -} - - -static void release_temps(struct gl_context *ctx, struct texenv_fragment_program *p ) -{ - GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps; - - /* KW: To support tex_env_crossbar, don't release the registers in - * temps_output. - */ - if (max_temp >= sizeof(int) * 8) - p->temp_in_use = p->temps_output; - else - p->temp_in_use = ~((1<<max_temp)-1) | p->temps_output; -} - - -static struct ureg register_param5( struct texenv_fragment_program *p, - GLint s0, - GLint s1, - GLint s2, - GLint s3, - GLint s4) -{ - int tokens[STATE_LENGTH]; - GLuint idx; - tokens[0] = s0; - tokens[1] = s1; - tokens[2] = s2; - tokens[3] = s3; - tokens[4] = s4; - idx = _mesa_add_state_reference(p->program->Base.Parameters, - (gl_state_index *)tokens); - return make_ureg(PROGRAM_STATE_VAR, idx); -} - - -#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) -#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) -#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) -#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) - -static GLuint frag_to_vert_attrib( GLuint attrib ) -{ - switch (attrib) { - case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0; - case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1; - default: - assert(attrib >= FRAG_ATTRIB_TEX0); - assert(attrib <= FRAG_ATTRIB_TEX7); - return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0; - } -} - - -static struct ureg register_input( struct texenv_fragment_program *p, GLuint input ) -{ - if (p->state->inputs_available & (1<<input)) { - p->program->Base.InputsRead |= (1 << input); - return make_ureg(PROGRAM_INPUT, input); - } - else { - GLuint idx = frag_to_vert_attrib( input ); - return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, idx ); - } -} - - -static void emit_arg( struct prog_src_register *reg, - struct ureg ureg ) -{ - reg->File = ureg.file; - reg->Index = ureg.idx; - reg->Swizzle = ureg.swz; - reg->Negate = ureg.negatebase ? NEGATE_XYZW : NEGATE_NONE; - reg->Abs = GL_FALSE; -} - -static void emit_dst( struct prog_dst_register *dst, - struct ureg ureg, GLuint mask ) -{ - dst->File = ureg.file; - dst->Index = ureg.idx; - dst->WriteMask = mask; - dst->CondMask = COND_TR; /* always pass cond test */ - dst->CondSwizzle = SWIZZLE_NOOP; -} - -static struct prog_instruction * -emit_op(struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint mask, - GLboolean saturate, - struct ureg src0, - struct ureg src1, - struct ureg src2 ) -{ - const GLuint nr = p->program->Base.NumInstructions++; - struct prog_instruction *inst = &p->program->Base.Instructions[nr]; - - assert(nr < MAX_INSTRUCTIONS); - - _mesa_init_instructions(inst, 1); - inst->Opcode = op; - - emit_arg( &inst->SrcReg[0], src0 ); - emit_arg( &inst->SrcReg[1], src1 ); - emit_arg( &inst->SrcReg[2], src2 ); - - inst->SaturateMode = saturate ? SATURATE_ZERO_ONE : SATURATE_OFF; - - emit_dst( &inst->DstReg, dest, mask ); - -#if 0 - /* Accounting for indirection tracking: - */ - if (dest.file == PROGRAM_TEMPORARY) - p->temps_output |= 1 << dest.idx; -#endif - - return inst; -} - - -static struct ureg emit_arith( struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint mask, - GLboolean saturate, - struct ureg src0, - struct ureg src1, - struct ureg src2 ) -{ - emit_op(p, op, dest, mask, saturate, src0, src1, src2); - - /* Accounting for indirection tracking: - */ - if (src0.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src0.idx; - - if (!is_undef(src1) && src1.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src1.idx; - - if (!is_undef(src2) && src2.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src2.idx; - - if (dest.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << dest.idx; - - p->program->Base.NumAluInstructions++; - return dest; -} - -static struct ureg emit_texld( struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint destmask, - GLuint tex_unit, - GLuint tex_idx, - GLuint tex_shadow, - struct ureg coord ) -{ - struct prog_instruction *inst = emit_op( p, op, - dest, destmask, - GL_FALSE, /* don't saturate? */ - coord, /* arg 0? */ - undef, - undef); - - inst->TexSrcTarget = tex_idx; - inst->TexSrcUnit = tex_unit; - inst->TexShadow = tex_shadow; - - p->program->Base.NumTexInstructions++; - - /* Accounting for indirection tracking: - */ - reserve_temp(p, dest); - -#if 0 - /* Is this a texture indirection? - */ - if ((coord.file == PROGRAM_TEMPORARY && - (p->temps_output & (1<<coord.idx))) || - (dest.file == PROGRAM_TEMPORARY && - (p->alu_temps & (1<<dest.idx)))) { - p->program->Base.NumTexIndirections++; - p->temps_output = 1<<coord.idx; - p->alu_temps = 0; - assert(0); /* KW: texture env crossbar */ - } -#endif - - return dest; -} - - -static struct ureg register_const4f( struct texenv_fragment_program *p, - GLfloat s0, - GLfloat s1, - GLfloat s2, - GLfloat s3) -{ - GLfloat values[4]; - GLuint idx, swizzle; - struct ureg r; - values[0] = s0; - values[1] = s1; - values[2] = s2; - values[3] = s3; - idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, - (gl_constant_value *) values, 4, - &swizzle ); - r = make_ureg(PROGRAM_CONSTANT, idx); - r.swz = swizzle; - return r; -} - -#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) -#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) -#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) -#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) - - -static struct ureg get_one( struct texenv_fragment_program *p ) -{ - if (is_undef(p->one)) - p->one = register_scalar_const(p, 1.0); - return p->one; -} - -static struct ureg get_half( struct texenv_fragment_program *p ) -{ - if (is_undef(p->half)) - p->half = register_scalar_const(p, 0.5); - return p->half; -} - -static struct ureg get_zero( struct texenv_fragment_program *p ) -{ - if (is_undef(p->zero)) - p->zero = register_scalar_const(p, 0.0); - return p->zero; -} - - -static void program_error( struct texenv_fragment_program *p, const char *msg ) -{ - _mesa_problem(NULL, "%s", msg); - p->error = 1; -} - -static struct ureg get_source( struct texenv_fragment_program *p, - GLuint src, GLuint unit ) -{ switch (src) { case SRC_TEXTURE: - assert(!is_undef(p->src_texture[unit])); - return p->src_texture[unit]; + return new(p->mem_ctx) ir_dereference_variable(p->src_texture[unit]); case SRC_TEXTURE0: case SRC_TEXTURE1: @@ -932,66 +578,67 @@ static struct ureg get_source( struct texenv_fragment_program *p, case SRC_TEXTURE5: case SRC_TEXTURE6: case SRC_TEXTURE7: - assert(!is_undef(p->src_texture[src - SRC_TEXTURE0])); - return p->src_texture[src - SRC_TEXTURE0]; + return new(p->mem_ctx) + ir_dereference_variable(p->src_texture[src - SRC_TEXTURE0]); case SRC_CONSTANT: - return register_param2(p, STATE_TEXENV_COLOR, unit); + var = p->shader->symbols->get_variable("gl_TextureEnvColor"); + assert(var); + deref = new(p->mem_ctx) ir_dereference_variable(var); + var->max_array_access = MAX2(var->max_array_access, unit); + return new(p->mem_ctx) ir_dereference_array(deref, + new(p->mem_ctx) ir_constant(unit)); case SRC_PRIMARY_COLOR: - return register_input(p, FRAG_ATTRIB_COL0); + var = p->shader->symbols->get_variable("gl_Color"); + assert(var); + return new(p->mem_ctx) ir_dereference_variable(var); case SRC_ZERO: - return get_zero(p); + return new(p->mem_ctx) ir_constant(0.0f); case SRC_PREVIOUS: - if (is_undef(p->src_previous)) - return register_input(p, FRAG_ATTRIB_COL0); - else - return p->src_previous; + if (!p->src_previous) { + return get_gl_Color(p); + } else { + return p->src_previous->clone(p->mem_ctx, NULL); + } default: assert(0); - return undef; + return NULL; } } -static struct ureg emit_combine_source( struct texenv_fragment_program *p, - GLuint mask, - GLuint unit, - GLuint source, - GLuint operand ) +static ir_rvalue * +emit_combine_source(struct texenv_fragment_program *p, + GLuint unit, + GLuint source, + GLuint operand) { - struct ureg arg, src, one; + ir_rvalue *src; src = get_source(p, source, unit); switch (operand) { case OPR_ONE_MINUS_SRC_COLOR: - /* Get unused tmp, - * Emit tmp = 1.0 - arg.xyzw - */ - arg = get_temp( p ); - one = get_one( p ); - return emit_arith( p, OPCODE_SUB, arg, mask, 0, one, src, undef); + return new(p->mem_ctx) ir_expression(ir_binop_sub, + new(p->mem_ctx) ir_constant(1.0f), + src); case OPR_SRC_ALPHA: - if (mask == WRITEMASK_W) - return src; - else - return swizzle1( src, SWIZZLE_W ); + return new(p->mem_ctx) ir_swizzle(src, 3, 3, 3, 3, 1); + case OPR_ONE_MINUS_SRC_ALPHA: - /* Get unused tmp, - * Emit tmp = 1.0 - arg.wwww - */ - arg = get_temp(p); - one = get_one(p); - return emit_arith(p, OPCODE_SUB, arg, mask, 0, - one, swizzle1(src, SWIZZLE_W), undef); + return new(p->mem_ctx) ir_expression(ir_binop_sub, + new(p->mem_ctx) ir_constant(1.0f), + new(p->mem_ctx) ir_swizzle(src, + 3, 3, + 3, 3, 1)); case OPR_ZERO: - return get_zero(p); + return new(p->mem_ctx) ir_constant(0.0f); case OPR_ONE: - return get_one(p); + return new(p->mem_ctx) ir_constant(1.0f); case OPR_SRC_COLOR: return src; default: @@ -1040,112 +687,104 @@ static GLboolean args_match( const struct state_key *key, GLuint unit ) return GL_TRUE; } -static struct ureg emit_combine( struct texenv_fragment_program *p, - struct ureg dest, - GLuint mask, - GLboolean saturate, - GLuint unit, - GLuint nr, - GLuint mode, - const struct mode_opt *opt) +static ir_rvalue * +smear(struct texenv_fragment_program *p, ir_rvalue *val) { - struct ureg src[MAX_COMBINER_TERMS]; - struct ureg tmp, half; + if (!val->type->is_scalar()) + return val; + + return new(p->mem_ctx) ir_swizzle(val, 0, 0, 0, 0, 4); +} + +static ir_rvalue * +emit_combine(struct texenv_fragment_program *p, + GLuint unit, + GLuint nr, + GLuint mode, + const struct mode_opt *opt) +{ + ir_rvalue *src[MAX_COMBINER_TERMS]; + ir_rvalue *tmp0, *tmp1; GLuint i; assert(nr <= MAX_COMBINER_TERMS); for (i = 0; i < nr; i++) - src[i] = emit_combine_source( p, mask, unit, opt[i].Source, opt[i].Operand ); + src[i] = emit_combine_source( p, unit, opt[i].Source, opt[i].Operand ); switch (mode) { case MODE_REPLACE: - if (mask == WRITEMASK_XYZW && !saturate) - return src[0]; - else - return emit_arith( p, OPCODE_MOV, dest, mask, saturate, src[0], undef, undef ); + return src[0]; + case MODE_MODULATE: - return emit_arith( p, OPCODE_MUL, dest, mask, saturate, - src[0], src[1], undef ); + return new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[1]); + case MODE_ADD: - return emit_arith( p, OPCODE_ADD, dest, mask, saturate, - src[0], src[1], undef ); + return new(p->mem_ctx) ir_expression(ir_binop_add, src[0], src[1]); + case MODE_ADD_SIGNED: - /* tmp = arg0 + arg1 - * result = tmp - .5 - */ - half = get_half(p); - tmp = get_temp( p ); - emit_arith( p, OPCODE_ADD, tmp, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp, half, undef ); - return dest; + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, src[0], src[1]); + return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, + new(p->mem_ctx) ir_constant(-0.5f)); + case MODE_INTERPOLATE: - /* Arg0 * (Arg2) + Arg1 * (1-Arg2) -- note arguments are reordered: - */ - return emit_arith( p, OPCODE_LRP, dest, mask, saturate, src[2], src[0], src[1] ); + /* Arg0 * (Arg2) + Arg1 * (1-Arg2) */ + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[2]); + + tmp1 = new(p->mem_ctx) ir_expression(ir_binop_sub, + new(p->mem_ctx) ir_constant(1.0f), + src[2]->clone(p->mem_ctx, NULL)); + tmp1 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[1], tmp1); + + return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, tmp1); case MODE_SUBTRACT: - return emit_arith( p, OPCODE_SUB, dest, mask, saturate, src[0], src[1], undef ); + return new(p->mem_ctx) ir_expression(ir_binop_sub, src[0], src[1]); case MODE_DOT3_RGBA: case MODE_DOT3_RGBA_EXT: case MODE_DOT3_RGB_EXT: case MODE_DOT3_RGB: { - struct ureg tmp0 = get_temp( p ); - struct ureg tmp1 = get_temp( p ); - struct ureg neg1 = register_scalar_const(p, -1); - struct ureg two = register_scalar_const(p, 2); - - /* tmp0 = 2*src0 - 1 - * tmp1 = 2*src1 - 1 - * - * dst = tmp0 dot3 tmp1 - */ - emit_arith( p, OPCODE_MAD, tmp0, WRITEMASK_XYZW, 0, - two, src[0], neg1); - - if (memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0) - tmp1 = tmp0; - else - emit_arith( p, OPCODE_MAD, tmp1, WRITEMASK_XYZW, 0, - two, src[1], neg1); - emit_arith( p, OPCODE_DP3, dest, mask, saturate, tmp0, tmp1, undef); - return dest; + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], + new(p->mem_ctx) ir_constant(2.0f)); + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, + new(p->mem_ctx) ir_constant(-1.0f)); + tmp0 = new(p->mem_ctx) ir_swizzle(smear(p, tmp0), 0, 1, 2, 3, 3); + + tmp1 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[1], + new(p->mem_ctx) ir_constant(2.0f)); + tmp1 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp1, + new(p->mem_ctx) ir_constant(-1.0f)); + tmp1 = new(p->mem_ctx) ir_swizzle(smear(p, tmp1), 0, 1, 2, 3, 3); + + return new(p->mem_ctx) ir_expression(ir_binop_dot, tmp0, tmp1); } case MODE_MODULATE_ADD_ATI: - /* Arg0 * Arg2 + Arg1 */ - return emit_arith( p, OPCODE_MAD, dest, mask, saturate, - src[0], src[2], src[1] ); - case MODE_MODULATE_SIGNED_ADD_ATI: { - /* Arg0 * Arg2 + Arg1 - 0.5 */ - struct ureg tmp0 = get_temp(p); - half = get_half(p); - emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[0], src[2], src[1] ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); - return dest; - } + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[2]); + return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, src[1]); + + case MODE_MODULATE_SIGNED_ADD_ATI: + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[2]); + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, src[1]); + return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, + new(p->mem_ctx) ir_constant(-0.5f)); + case MODE_MODULATE_SUBTRACT_ATI: - /* Arg0 * Arg2 - Arg1 */ - emit_arith( p, OPCODE_MAD, dest, mask, 0, src[0], src[2], negate(src[1]) ); - return dest; + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[2]); + return new(p->mem_ctx) ir_expression(ir_binop_sub, tmp0, src[1]); + case MODE_ADD_PRODUCTS: - /* Arg0 * Arg1 + Arg2 * Arg3 */ - { - struct ureg tmp0 = get_temp(p); - emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_MAD, dest, mask, saturate, src[2], src[3], tmp0 ); - } - return dest; + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[1]); + tmp1 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[2], src[3]); + return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, tmp1); + case MODE_ADD_PRODUCTS_SIGNED: - /* Arg0 * Arg1 + Arg2 * Arg3 - 0.5 */ - { - struct ureg tmp0 = get_temp(p); - half = get_half(p); - emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[2], src[3], tmp0 ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); - } - return dest; + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[0], src[1]); + tmp1 = new(p->mem_ctx) ir_expression(ir_binop_mul, src[2], src[3]); + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, tmp1); + return new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, + new(p->mem_ctx) ir_constant(-0.5f)); + case MODE_BUMP_ENVMAP_ATI: /* special - not handled here */ assert(0); @@ -1156,17 +795,24 @@ static struct ureg emit_combine( struct texenv_fragment_program *p, } } +static ir_rvalue * +saturate(struct texenv_fragment_program *p, ir_rvalue *val) +{ + val = new(p->mem_ctx) ir_expression(ir_binop_min, val, + new(p->mem_ctx) ir_constant(1.0f)); + return new(p->mem_ctx) ir_expression(ir_binop_max, val, + new(p->mem_ctx) ir_constant(0.0f)); +} /** * Generate instructions for one texture unit's env/combiner mode. */ -static struct ureg +static ir_rvalue * emit_texenv(struct texenv_fragment_program *p, GLuint unit) { const struct state_key *key = p->state; GLboolean rgb_saturate, alpha_saturate; GLuint rgb_shift, alpha_shift; - struct ureg out, dest; if (!key->unit[unit].enabled) { return get_source(p, SRC_PREVIOUS, 0); @@ -1208,74 +854,99 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit) else alpha_saturate = GL_FALSE; - /* If this is the very last calculation (and various other conditions - * are met), emit directly to the color output register. Otherwise, - * emit to a temporary register. - */ - if (key->separate_specular || - unit != p->last_tex_stage || - alpha_shift || - key->num_draw_buffers != 1 || - rgb_shift) - dest = get_temp( p ); - else - dest = make_ureg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR); + ir_variable *temp_var = new(p->mem_ctx) ir_variable(glsl_type::vec4_type, + "texenv_combine", + ir_var_temporary); + p->instructions->push_tail(temp_var); + + ir_dereference *deref; + ir_assignment *assign; + ir_rvalue *val; /* Emit the RGB and A combine ops */ if (key->unit[unit].ModeRGB == key->unit[unit].ModeA && args_match(key, unit)) { - out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); + val = emit_combine(p, unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + val = smear(p, val); + if (rgb_saturate) + val = saturate(p, val); + + deref = new(p->mem_ctx) ir_dereference_variable(temp_var); + assign = new(p->mem_ctx) ir_assignment(deref, val); + p->instructions->push_tail(assign); } else if (key->unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT || key->unit[unit].ModeRGB == MODE_DOT3_RGBA) { - out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); + ir_rvalue *val = emit_combine(p, unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + val = smear(p, val); + if (rgb_saturate) + val = saturate(p, val); + deref = new(p->mem_ctx) ir_dereference_variable(temp_var); + assign = new(p->mem_ctx) ir_assignment(deref, val); + p->instructions->push_tail(assign); } else { /* Need to do something to stop from re-emitting identical * argument calculations here: */ - out = emit_combine( p, dest, WRITEMASK_XYZ, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); - out = emit_combine( p, dest, WRITEMASK_W, alpha_saturate, - unit, - key->unit[unit].NumArgsA, - key->unit[unit].ModeA, - key->unit[unit].OptA); + val = emit_combine(p, unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + val = smear(p, val); + val = new(p->mem_ctx) ir_swizzle(val, 0, 1, 2, 3, 3); + if (rgb_saturate) + val = saturate(p, val); + deref = new(p->mem_ctx) ir_dereference_variable(temp_var); + assign = new(p->mem_ctx) ir_assignment(deref, val, NULL, WRITEMASK_XYZ); + p->instructions->push_tail(assign); + + val = emit_combine(p, unit, + key->unit[unit].NumArgsA, + key->unit[unit].ModeA, + key->unit[unit].OptA); + val = smear(p, val); + val = new(p->mem_ctx) ir_swizzle(val, 3, 3, 3, 3, 1); + if (alpha_saturate) + val = saturate(p, val); + deref = new(p->mem_ctx) ir_dereference_variable(temp_var); + assign = new(p->mem_ctx) ir_assignment(deref, val, NULL, WRITEMASK_W); + p->instructions->push_tail(assign); } + deref = new(p->mem_ctx) ir_dereference_variable(temp_var); + /* Deal with the final shift: */ if (alpha_shift || rgb_shift) { - struct ureg shift; - GLboolean saturate = GL_TRUE; /* always saturate at this point */ + ir_constant *shift; if (rgb_shift == alpha_shift) { - shift = register_scalar_const(p, (GLfloat)(1<<rgb_shift)); + shift = new(p->mem_ctx) ir_constant((float)(1 << rgb_shift)); } else { - shift = register_const4f(p, - (GLfloat)(1<<rgb_shift), - (GLfloat)(1<<rgb_shift), - (GLfloat)(1<<rgb_shift), - (GLfloat)(1<<alpha_shift)); + float const_data[4] = { + 1 << rgb_shift, + 1 << rgb_shift, + 1 << rgb_shift, + 1 << alpha_shift + }; + shift = new(p->mem_ctx) ir_constant(glsl_type::vec4_type, + (ir_constant_data *)const_data); } - return emit_arith( p, OPCODE_MUL, dest, WRITEMASK_XYZW, - saturate, out, shift, undef ); + + return saturate(p, new(p->mem_ctx) ir_expression(ir_binop_mul, + deref, shift)); } else - return out; + return deref; } @@ -1284,53 +955,131 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit) */ static void load_texture( struct texenv_fragment_program *p, GLuint unit ) { - if (is_undef(p->src_texture[unit])) { - const GLuint texTarget = p->state->unit[unit].source_index; - struct ureg texcoord; - struct ureg tmp = get_tex_temp( p ); + ir_dereference *deref; + ir_assignment *assign; - if (is_undef(p->texcoord_tex[unit])) { - texcoord = register_input(p, FRAG_ATTRIB_TEX0+unit); - } - else { - /* might want to reuse this reg for tex output actually */ - texcoord = p->texcoord_tex[unit]; - } + if (p->src_texture[unit]) + return; - /* TODO: Use D0_MASK_XY where possible. - */ - if (p->state->unit[unit].enabled) { - GLboolean shadow = GL_FALSE; - - if (p->state->unit[unit].shadow) { - p->program->Base.ShadowSamplers |= 1 << unit; - shadow = GL_TRUE; - } - - p->src_texture[unit] = emit_texld( p, OPCODE_TXP, - tmp, WRITEMASK_XYZW, - unit, texTarget, shadow, - texcoord ); - - p->program->Base.SamplersUsed |= (1 << unit); - /* This identity mapping should already be in place - * (see _mesa_init_program_struct()) but let's be safe. - */ - p->program->Base.SamplerUnits[unit] = unit; - } + const GLuint texTarget = p->state->unit[unit].source_index; + ir_rvalue *texcoord; + + if (!(p->state->inputs_available & (FRAG_BIT_TEX0 << unit))) { + texcoord = get_current_attrib(p, VERT_ATTRIB_TEX0 + unit); + } else if (p->texcoord_tex[unit]) { + texcoord = new(p->mem_ctx) ir_dereference_variable(p->texcoord_tex[unit]); + } else { + ir_variable *tc_array = p->shader->symbols->get_variable("gl_TexCoord"); + assert(tc_array); + texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array); + ir_rvalue *index = new(p->mem_ctx) ir_constant(unit); + texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index); + tc_array->max_array_access = MAX2(tc_array->max_array_access, unit); + } + + if (!p->state->unit[unit].enabled) { + p->src_texture[unit] = new(p->mem_ctx) ir_variable(glsl_type::vec4_type, + "dummy_tex", + ir_var_temporary); + p->instructions->push_tail(p->src_texture[unit]); + + deref = new(p->mem_ctx) ir_dereference_variable(p->src_texture[unit]); + assign = new(p->mem_ctx) ir_assignment(deref, + new(p->mem_ctx) ir_constant(0.0f)); + p->instructions->push_tail(assign); + return ; + } + + const glsl_type *sampler_type = NULL; + int coords = 0; + + switch (texTarget) { + case TEXTURE_1D_INDEX: + if (p->state->unit[unit].shadow) + sampler_type = p->shader->symbols->get_type("sampler1DShadow"); + else + sampler_type = p->shader->symbols->get_type("sampler1D"); + coords = 1; + break; + case TEXTURE_1D_ARRAY_INDEX: + if (p->state->unit[unit].shadow) + sampler_type = p->shader->symbols->get_type("sampler1DArrayShadow"); else - p->src_texture[unit] = get_zero(p); + sampler_type = p->shader->symbols->get_type("sampler1DArray"); + coords = 2; + break; + case TEXTURE_2D_INDEX: + if (p->state->unit[unit].shadow) + sampler_type = p->shader->symbols->get_type("sampler2DShadow"); + else + sampler_type = p->shader->symbols->get_type("sampler2D"); + coords = 2; + break; + case TEXTURE_2D_ARRAY_INDEX: + if (p->state->unit[unit].shadow) + sampler_type = p->shader->symbols->get_type("sampler2DArrayShadow"); + else + sampler_type = p->shader->symbols->get_type("sampler2DArray"); + coords = 3; + break; + case TEXTURE_RECT_INDEX: + if (p->state->unit[unit].shadow) + sampler_type = p->shader->symbols->get_type("sampler2DRectShadow"); + else + sampler_type = p->shader->symbols->get_type("sampler2DRect"); + coords = 2; + break; + case TEXTURE_3D_INDEX: + assert(!p->state->unit[unit].shadow); + sampler_type = p->shader->symbols->get_type("sampler3D"); + coords = 3; + break; + case TEXTURE_CUBE_INDEX: + if (p->state->unit[unit].shadow) + sampler_type = p->shader->symbols->get_type("samplerCubeShadow"); + else + sampler_type = p->shader->symbols->get_type("samplerCube"); + coords = 3; + break; + } + + p->src_texture[unit] = new(p->mem_ctx) ir_variable(glsl_type::vec4_type, + "tex", + ir_var_temporary); + p->instructions->push_tail(p->src_texture[unit]); + + ir_texture *tex = new(p->mem_ctx) ir_texture(ir_tex); - if (p->state->unit[unit].texture_cyl_wrap) { - /* set flag which is checked by Mesa->Gallium program translation */ - p->program->Base.InputFlags[0] |= PROG_PARAM_BIT_CYL_WRAP; - } + char *sampler_name = ralloc_asprintf(p->mem_ctx, "sampler_%d", unit); + ir_variable *sampler = new(p->mem_ctx) ir_variable(sampler_type, + sampler_name, + ir_var_uniform); + p->top_instructions->push_head(sampler); + deref = new(p->mem_ctx) ir_dereference_variable(sampler); + tex->set_sampler(deref, glsl_type::vec4_type); + + tex->coordinate = new(p->mem_ctx) ir_swizzle(texcoord, 0, 1, 2, 3, coords); + + if (p->state->unit[unit].shadow) { + texcoord = texcoord->clone(p->mem_ctx, NULL); + tex->shadow_comparitor = new(p->mem_ctx) ir_swizzle(texcoord, + coords, 0, 0, 0, + 1); + coords++; } + + texcoord = texcoord->clone(p->mem_ctx, NULL); + tex->projector = new(p->mem_ctx) ir_swizzle(texcoord, 3, 0, 0, 0, 1); + + deref = new(p->mem_ctx) ir_dereference_variable(p->src_texture[unit]); + assign = new(p->mem_ctx) ir_assignment(deref, tex); + p->instructions->push_tail(assign); } -static GLboolean load_texenv_source( struct texenv_fragment_program *p, - GLuint src, GLuint unit ) +static void +load_texenv_source(struct texenv_fragment_program *p, + GLuint src, GLuint unit) { switch (src) { case SRC_TEXTURE: @@ -1352,8 +1101,6 @@ static GLboolean load_texenv_source( struct texenv_fragment_program *p, /* not a texture src - do nothing */ break; } - - return GL_TRUE; } @@ -1380,108 +1127,214 @@ load_texunit_sources( struct texenv_fragment_program *p, GLuint unit ) /** * Generate instructions for loading bump map textures. */ -static GLboolean +static void load_texunit_bumpmap( struct texenv_fragment_program *p, GLuint unit ) { const struct state_key *key = p->state; GLuint bumpedUnitNr = key->unit[unit].OptRGB[1].Source - SRC_TEXTURE0; - struct ureg texcDst, bumpMapRes; - struct ureg constdudvcolor = register_const4f(p, 0.0, 0.0, 0.0, 1.0); - struct ureg texcSrc = register_input(p, FRAG_ATTRIB_TEX0 + bumpedUnitNr); - struct ureg rotMat0 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_0, unit ); - struct ureg rotMat1 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_1, unit ); + ir_rvalue *bump; + ir_rvalue *texcoord; + ir_variable *rot_mat_0_var, *rot_mat_1_var; + ir_dereference_variable *rot_mat_0, *rot_mat_1; + + rot_mat_0_var = p->shader->symbols->get_variable("gl_MESABumpRotMatrix0"); + rot_mat_1_var = p->shader->symbols->get_variable("gl_MESABumpRotMatrix1"); + rot_mat_0 = new(p->mem_ctx) ir_dereference_variable(rot_mat_0_var); + rot_mat_1 = new(p->mem_ctx) ir_dereference_variable(rot_mat_1_var); + + ir_variable *tc_array = p->shader->symbols->get_variable("gl_TexCoord"); + assert(tc_array); + texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array); + ir_rvalue *index = new(p->mem_ctx) ir_constant(bumpedUnitNr); + texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index); + tc_array->max_array_access = MAX2(tc_array->max_array_access, unit); load_texenv_source( p, unit + SRC_TEXTURE0, unit ); - bumpMapRes = get_source(p, key->unit[unit].OptRGB[0].Source, unit); - texcDst = get_tex_temp( p ); - p->texcoord_tex[bumpedUnitNr] = texcDst; - /* Apply rot matrix and add coords to be available in next phase. - * dest = (Arg0.xxxx * rotMat0 + Arg1) + (Arg0.yyyy * rotMat1) + * dest = Arg1 + (Arg0.xx * rotMat0) + (Arg0.yy * rotMat1) * note only 2 coords are affected the rest are left unchanged (mul by 0) */ - emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, - swizzle1(bumpMapRes, SWIZZLE_X), rotMat0, texcSrc ); - emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, - swizzle1(bumpMapRes, SWIZZLE_Y), rotMat1, texcDst ); - - /* Move 0,0,0,1 into bumpmap src if someone (crossbar) is foolish - * enough to access this later, should optimize away. - */ - emit_arith( p, OPCODE_MOV, bumpMapRes, WRITEMASK_XYZW, 0, - constdudvcolor, undef, undef ); - - return GL_TRUE; + ir_dereference *deref; + ir_assignment *assign; + ir_rvalue *bump_x, *bump_y; + + texcoord = smear(p, texcoord); + + /* bump_texcoord = texcoord */ + ir_variable *bumped = new(p->mem_ctx) ir_variable(texcoord->type, + "bump_texcoord", + ir_var_temporary); + p->instructions->push_tail(bumped); + + deref = new(p->mem_ctx) ir_dereference_variable(bumped); + assign = new(p->mem_ctx) ir_assignment(deref, texcoord); + p->instructions->push_tail(assign); + + /* bump_texcoord.xy += arg0.x * rotmat0 + arg0.y * rotmat1 */ + bump = get_source(p, key->unit[unit].OptRGB[0].Source, unit); + bump_x = new(p->mem_ctx) ir_swizzle(bump, 0, 0, 0, 0, 1); + bump = bump->clone(p->mem_ctx, NULL); + bump_y = new(p->mem_ctx) ir_swizzle(bump, 1, 0, 0, 0, 1); + + bump_x = new(p->mem_ctx) ir_expression(ir_binop_mul, bump_x, rot_mat_0); + bump_y = new(p->mem_ctx) ir_expression(ir_binop_mul, bump_y, rot_mat_1); + + ir_expression *expr; + expr = new(p->mem_ctx) ir_expression(ir_binop_add, bump_x, bump_y); + + deref = new(p->mem_ctx) ir_dereference_variable(bumped); + expr = new(p->mem_ctx) ir_expression(ir_binop_add, + new(p->mem_ctx) ir_swizzle(deref, + 0, 1, 1, 1, + 2), + expr); + + deref = new(p->mem_ctx) ir_dereference_variable(bumped); + assign = new(p->mem_ctx) ir_assignment(deref, expr, NULL, WRITEMASK_XY); + p->instructions->push_tail(assign); + + p->texcoord_tex[bumpedUnitNr] = bumped; } /** - * Generate a new fragment program which implements the context's - * current texture env/combine mode. + * Applies the fog calculations. + * + * This is basically like the ARB_fragment_prorgam fog options. Note + * that ffvertex_prog.c produces fogcoord for us when + * GL_FOG_COORDINATE_EXT is set to GL_FRAGMENT_DEPTH_EXT. */ -static void -create_new_program(struct gl_context *ctx, struct state_key *key, - struct gl_fragment_program *program) +static ir_rvalue * +emit_fog_instructions(struct texenv_fragment_program *p, + ir_rvalue *fragcolor) { - struct prog_instruction instBuffer[MAX_INSTRUCTIONS]; - struct texenv_fragment_program p; - GLuint unit; - struct ureg cf, out; - int i; - - memset(&p, 0, sizeof(p)); - p.state = key; - p.program = program; - - /* During code generation, use locally-allocated instruction buffer, - * then alloc dynamic storage below. + struct state_key *key = p->state; + ir_rvalue *f, *temp; + ir_variable *params, *oparams; + ir_variable *fogcoord; + ir_assignment *assign; + + /* Temporary storage for the whole fog result. Fog calculations + * only affect rgb so we're hanging on to the .a value of fragcolor + * this way. */ - p.program->Base.Instructions = instBuffer; - p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB; - p.program->Base.String = NULL; - p.program->Base.NumTexIndirections = 1; /* is this right? */ - p.program->Base.NumTexInstructions = 0; - p.program->Base.NumAluInstructions = 0; - p.program->Base.NumInstructions = 0; - p.program->Base.NumTemporaries = 0; - p.program->Base.NumParameters = 0; - p.program->Base.NumAttributes = 0; - p.program->Base.NumAddressRegs = 0; - p.program->Base.Parameters = _mesa_new_parameter_list(); - p.program->Base.InputsRead = 0x0; - - if (key->num_draw_buffers == 1) - p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR; - else { - for (i = 0; i < key->num_draw_buffers; i++) - p.program->Base.OutputsWritten |= (1 << (FRAG_RESULT_DATA0 + i)); - } + ir_variable *fog_result = new(p->mem_ctx) ir_variable(glsl_type::vec4_type, + "fog_result", + ir_var_auto); + p->instructions->push_tail(fog_result); + temp = new(p->mem_ctx) ir_dereference_variable(fog_result); + assign = new(p->mem_ctx) ir_assignment(temp, fragcolor); + p->instructions->push_tail(assign); + + temp = new(p->mem_ctx) ir_dereference_variable(fog_result); + fragcolor = new(p->mem_ctx) ir_swizzle(temp, 0, 1, 2, 3, 3); + + oparams = p->shader->symbols->get_variable("gl_MESAFogParamsOptimized"); + fogcoord = p->shader->symbols->get_variable("gl_FogFragCoord"); + params = p->shader->symbols->get_variable("gl_Fog"); + f = new(p->mem_ctx) ir_dereference_variable(fogcoord); + + ir_variable *f_var = new(p->mem_ctx) ir_variable(glsl_type::float_type, + "fog_factor", ir_var_auto); + p->instructions->push_tail(f_var); + + switch (key->fog_mode) { + case FOG_LINEAR: + /* f = (end - z) / (end - start) + * + * gl_MesaFogParamsOptimized gives us (-1 / (end - start)) and + * (end / (end - start)) so we can generate a single MAD. + */ + temp = new(p->mem_ctx) ir_dereference_variable(oparams); + temp = new(p->mem_ctx) ir_swizzle(temp, 0, 0, 0, 0, 1); + f = new(p->mem_ctx) ir_expression(ir_binop_mul, f, temp); - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - p.src_texture[unit] = undef; - p.texcoord_tex[unit] = undef; + temp = new(p->mem_ctx) ir_dereference_variable(oparams); + temp = new(p->mem_ctx) ir_swizzle(temp, 1, 0, 0, 0, 1); + f = new(p->mem_ctx) ir_expression(ir_binop_add, f, temp); + break; + case FOG_EXP: + /* f = e^(-(density * fogcoord)) + * + * gl_MesaFogParamsOptimized gives us density/ln(2) so we can + * use EXP2 which is generally the native instruction without + * having to do any further math on the fog density uniform. + */ + temp = new(p->mem_ctx) ir_dereference_variable(oparams); + temp = new(p->mem_ctx) ir_swizzle(temp, 2, 0, 0, 0, 1); + f = new(p->mem_ctx) ir_expression(ir_binop_mul, f, temp); + f = new(p->mem_ctx) ir_expression(ir_unop_neg, f); + f = new(p->mem_ctx) ir_expression(ir_unop_exp2, f); + break; + case FOG_EXP2: + /* f = e^(-(density * fogcoord)^2) + * + * gl_MesaFogParamsOptimized gives us density/sqrt(ln(2)) so we + * can do this like FOG_EXP but with a squaring after the + * multiply by density. + */ + ir_variable *temp_var = new(p->mem_ctx) ir_variable(glsl_type::float_type, + "fog_temp", + ir_var_auto); + p->instructions->push_tail(temp_var); + + temp = new(p->mem_ctx) ir_dereference_variable(oparams); + temp = new(p->mem_ctx) ir_swizzle(temp, 3, 0, 0, 0, 1); + f = new(p->mem_ctx) ir_expression(ir_binop_mul, + f, temp); + + temp = new(p->mem_ctx) ir_dereference_variable(temp_var); + ir_assignment *assign = new(p->mem_ctx) ir_assignment(temp, f); + p->instructions->push_tail(assign); + + f = new(p->mem_ctx) ir_dereference_variable(temp_var); + temp = new(p->mem_ctx) ir_dereference_variable(temp_var); + f = new(p->mem_ctx) ir_expression(ir_binop_mul, f, temp); + f = new(p->mem_ctx) ir_expression(ir_unop_neg, f); + f = new(p->mem_ctx) ir_expression(ir_unop_exp2, f); + break; } - p.src_previous = undef; - p.half = undef; - p.zero = undef; - p.one = undef; + f = saturate(p, f); - p.last_tex_stage = 0; - release_temps(ctx, &p); + temp = new(p->mem_ctx) ir_dereference_variable(f_var); + assign = new(p->mem_ctx) ir_assignment(temp, f); + p->instructions->push_tail(assign); + + f = new(p->mem_ctx) ir_dereference_variable(f_var); + f = new(p->mem_ctx) ir_expression(ir_binop_sub, + new(p->mem_ctx) ir_constant(1.0f), + f); + temp = new(p->mem_ctx) ir_dereference_variable(params); + temp = new(p->mem_ctx) ir_dereference_record(temp, "color"); + temp = new(p->mem_ctx) ir_swizzle(temp, 0, 1, 2, 3, 3); + temp = new(p->mem_ctx) ir_expression(ir_binop_mul, temp, f); - if (key->enabled_units && key->num_draw_buffers) { - GLboolean needbumpstage = GL_FALSE; + f = new(p->mem_ctx) ir_dereference_variable(f_var); + f = new(p->mem_ctx) ir_expression(ir_binop_mul, fragcolor, f); + f = new(p->mem_ctx) ir_expression(ir_binop_add, temp, f); + ir_dereference *deref = new(p->mem_ctx) ir_dereference_variable(fog_result); + assign = new(p->mem_ctx) ir_assignment(deref, f, NULL, WRITEMASK_XYZ); + p->instructions->push_tail(assign); + + return new(p->mem_ctx) ir_dereference_variable(fog_result); +} + +static void +emit_instructions(struct texenv_fragment_program *p) +{ + struct state_key *key = p->state; + GLuint unit; + + if (key->enabled_units) { /* Zeroth pass - bump map textures first */ - for (unit = 0; unit < key->nr_enabled_units; unit++) + for (unit = 0; unit < key->nr_enabled_units; unit++) { if (key->unit[unit].enabled && key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { - needbumpstage = GL_TRUE; - load_texunit_bumpmap( &p, unit ); + load_texunit_bumpmap(p, unit); } - if (needbumpstage) - p.program->Base.NumTexIndirections++; + } /* First pass - to support texture_env_crossbar, first identify * all referenced texture sources and emit texld instructions @@ -1489,98 +1342,172 @@ create_new_program(struct gl_context *ctx, struct state_key *key, */ for (unit = 0; unit < key->nr_enabled_units; unit++) if (key->unit[unit].enabled) { - load_texunit_sources( &p, unit ); - p.last_tex_stage = unit; + load_texunit_sources(p, unit); + p->last_tex_stage = unit; } /* Second pass - emit combine instructions to build final color: */ - for (unit = 0; unit < key->nr_enabled_units; unit++) + for (unit = 0; unit < key->nr_enabled_units; unit++) { if (key->unit[unit].enabled) { - p.src_previous = emit_texenv( &p, unit ); - reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */ - release_temps(ctx, &p); /* release all temps */ + p->src_previous = emit_texenv(p, unit); } + } } - cf = get_source( &p, SRC_PREVIOUS, 0 ); - - for (i = 0; i < key->num_draw_buffers; i++) { - if (key->num_draw_buffers == 1) - out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_COLOR ); - else { - out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i ); + ir_rvalue *cf = get_source(p, SRC_PREVIOUS, 0); + ir_dereference_variable *deref; + ir_assignment *assign; + + if (key->separate_specular) { + ir_rvalue *tmp0; + ir_variable *spec_result = new(p->mem_ctx) ir_variable(glsl_type::vec4_type, + "specular_add", + ir_var_temporary); + + p->instructions->push_tail(spec_result); + + deref = new(p->mem_ctx) ir_dereference_variable(spec_result); + assign = new(p->mem_ctx) ir_assignment(deref, cf); + p->instructions->push_tail(assign); + + deref = new(p->mem_ctx) ir_dereference_variable(spec_result); + tmp0 = new(p->mem_ctx) ir_swizzle(deref, 0, 1, 2, 3, 3); + + ir_rvalue *secondary; + if (p->state->inputs_available & FRAG_BIT_COL1) { + ir_variable *var = + p->shader->symbols->get_variable("gl_SecondaryColor"); + assert(var); + secondary = new(p->mem_ctx) ir_dereference_variable(var); + } else { + secondary = get_current_attrib(p, VERT_ATTRIB_COLOR1); } + secondary = new(p->mem_ctx) ir_swizzle(secondary, 0, 1, 2, 3, 3); - if (key->separate_specular) { - /* Emit specular add. - */ - struct ureg s = register_input(&p, FRAG_ATTRIB_COL1); - emit_arith( &p, OPCODE_ADD, out, WRITEMASK_XYZ, 0, cf, s, undef ); - emit_arith( &p, OPCODE_MOV, out, WRITEMASK_W, 0, cf, undef, undef ); - } - else if (memcmp(&cf, &out, sizeof(cf)) != 0) { - /* Will wind up in here if no texture enabled or a couple of - * other scenarios (GL_REPLACE for instance). - */ - emit_arith( &p, OPCODE_MOV, out, WRITEMASK_XYZW, 0, cf, undef, undef ); - } + tmp0 = new(p->mem_ctx) ir_expression(ir_binop_add, tmp0, secondary); + + deref = new(p->mem_ctx) ir_dereference_variable(spec_result); + assign = new(p->mem_ctx) ir_assignment(deref, tmp0, NULL, WRITEMASK_XYZ); + p->instructions->push_tail(assign); + + cf = new(p->mem_ctx) ir_dereference_variable(spec_result); } - /* Finish up: - */ - emit_arith( &p, OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef); - /* Allocate final instruction array. This has to be done before calling - * _mesa_append_fog_code because that function frees the Base.Instructions. - * At this point, Base.Instructions points to stack data, so it's a really - * bad idea to free it. - */ - p.program->Base.Instructions - = _mesa_alloc_instructions(p.program->Base.NumInstructions); - if (!p.program->Base.Instructions) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "generating tex env program"); - return; + if (key->fog_enabled) { + cf = emit_fog_instructions(p, cf); } - _mesa_copy_instructions(p.program->Base.Instructions, instBuffer, - p.program->Base.NumInstructions); - /* Append fog code. This must be done before checking the program against - * the limits becuase it will potentially add some instructions. + ir_variable *frag_color = p->shader->symbols->get_variable("gl_FragColor"); + assert(frag_color); + deref = new(p->mem_ctx) ir_dereference_variable(frag_color); + assign = new(p->mem_ctx) ir_assignment(deref, cf); + p->instructions->push_tail(assign); +} + +/** + * Generate a new fragment program which implements the context's + * current texture env/combine mode. + */ +static struct gl_shader_program * +create_new_program(struct gl_context *ctx, struct state_key *key) +{ + struct texenv_fragment_program p; + unsigned int unit; + _mesa_glsl_parse_state *state; + + memset(&p, 0, sizeof(p)); + p.mem_ctx = ralloc_context(NULL); + p.shader = ctx->Driver.NewShader(ctx, 0, GL_FRAGMENT_SHADER); + p.shader->ir = new(p.shader) exec_list; + state = new(p.shader) _mesa_glsl_parse_state(ctx, GL_FRAGMENT_SHADER, + p.shader); + p.shader->symbols = state->symbols; + p.top_instructions = p.shader->ir; + p.instructions = p.shader->ir; + p.state = key; + p.shader_program = ctx->Driver.NewShaderProgram(ctx, 0); + + /* Tell the linker to ignore the fact that we're building a + * separate shader, in case we're in a GLES2 context that would + * normally reject that. The real problem is that we're building a + * fixed function program in a GLES2 context at all, but that's a + * big mess to clean up. */ - if (key->fog_enabled) { - _mesa_append_fog_code(ctx, p.program, ctx->Fog.Mode, GL_FALSE); + p.shader_program->InternalSeparateShader = GL_TRUE; + + state->language_version = 130; + _mesa_glsl_initialize_types(state); + _mesa_glsl_initialize_variables(p.instructions, state); + + for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { + p.src_texture[unit] = NULL; + p.texcoord_tex[unit] = NULL; } - if (p.program->Base.NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections) - program_error(&p, "Exceeded max nr indirect texture lookups"); + p.src_previous = NULL; + + p.last_tex_stage = 0; + + ir_function *main_f = new(p.mem_ctx) ir_function("main"); + p.instructions->push_tail(main_f); + state->symbols->add_function(main_f); - if (p.program->Base.NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions) - program_error(&p, "Exceeded max TEX instructions"); + ir_function_signature *main_sig = + new(p.mem_ctx) ir_function_signature(p.shader->symbols->get_type("void")); + main_sig->is_defined = true; + main_f->add_signature(main_sig); - if (p.program->Base.NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions) - program_error(&p, "Exceeded max ALU instructions"); + p.instructions = &main_sig->body; + if (key->num_draw_buffers) + emit_instructions(&p); - ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS); + validate_ir_tree(p.shader->ir); - /* Notify driver the fragment program has (actually) changed. + while (do_common_optimization(p.shader->ir, false, 32)) + ; + reparent_ir(p.shader->ir, p.shader->ir); + + p.shader->CompileStatus = true; + p.shader->Version = state->language_version; + p.shader->num_builtins_to_link = state->num_builtins_to_link; + p.shader_program->Shaders = + (gl_shader **)malloc(sizeof(*p.shader_program->Shaders)); + p.shader_program->Shaders[0] = p.shader; + p.shader_program->NumShaders = 1; + + _mesa_glsl_link_shader(ctx, p.shader_program); + + /* Set the sampler uniforms, and relink to get them into the linked + * program. */ - if (ctx->Driver.ProgramStringNotify) { - GLboolean ok = ctx->Driver.ProgramStringNotify(ctx, - GL_FRAGMENT_PROGRAM_ARB, - &p.program->Base); - /* Driver should be able to handle any texenv programs as long as - * the driver correctly reported max number of texture units correctly, - * etc. - */ - ASSERT(ok); - (void) ok; /* silence unused var warning */ - } + struct gl_program *fp; + fp = p.shader_program->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program; + + for (unsigned int i = 0; i < MAX_TEXTURE_UNITS; i++) { + char *name = ralloc_asprintf(p.mem_ctx, "sampler_%d", i); + int loc = _mesa_get_uniform_location(ctx, p.shader_program, name); + if (loc != -1) { + /* Avoid using _mesa_uniform() because it flags state + * updates, so if we're generating this shader_program in a + * state update, we end up recursing. Instead, just set the + * value, which is picked up at re-link. + */ + loc = (loc & 0xffff) + (loc >> 16); + int sampler = fp->Parameters->ParameterValues[loc][0].f; - if (DISASSEM) { - _mesa_print_program(&p.program->Base); - printf("\n"); + fp->SamplerUnits[sampler] = i; + } } + _mesa_update_shader_textures_used(fp); + (void) ctx->Driver.ProgramStringNotify(ctx, fp->Target, fp); + + if (!p.shader_program->LinkStatus) + _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n", + p.shader_program->InfoLog); + + ralloc_free(p.mem_ctx); + return p.shader_program; } extern "C" { @@ -1589,30 +1516,27 @@ extern "C" { * Return a fragment program which implements the current * fixed-function texture, fog and color-sum operations. */ -struct gl_fragment_program * +struct gl_shader_program * _mesa_get_fixed_func_fragment_program(struct gl_context *ctx) { - struct gl_fragment_program *prog; + struct gl_shader_program *shader_program; struct state_key key; GLuint keySize; - + keySize = make_state_key(ctx, &key); - - prog = (struct gl_fragment_program *) + + shader_program = (struct gl_shader_program *) _mesa_search_program_cache(ctx->FragmentProgram.Cache, &key, keySize); - if (!prog) { - prog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); - - create_new_program(ctx, &key, prog); + if (!shader_program) { + shader_program = create_new_program(ctx, &key); - _mesa_program_cache_insert(ctx, ctx->FragmentProgram.Cache, - &key, keySize, &prog->Base); + _mesa_shader_cache_insert(ctx, ctx->FragmentProgram.Cache, + &key, keySize, shader_program); } - return prog; + return shader_program; } } diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c index 42da17678..8d0763db3 100644 --- a/mesalib/src/mesa/main/framebuffer.c +++ b/mesalib/src/mesa/main/framebuffer.c @@ -608,19 +608,12 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx, * create and install a depth wrapper/adaptor. * * \param fb the framebuffer whose _DepthBuffer field to update - * \param attIndex indicates the renderbuffer to possibly wrap */ -void -_mesa_update_depth_buffer(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLuint attIndex) +static void +update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) { - struct gl_renderbuffer *depthRb; - - /* only one possiblity for now */ - ASSERT(attIndex == BUFFER_DEPTH); - - depthRb = fb->Attachment[attIndex].Renderbuffer; + struct gl_renderbuffer *depthRb = + fb->Attachment[BUFFER_DEPTH].Renderbuffer; if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) { /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */ @@ -655,19 +648,12 @@ _mesa_update_depth_buffer(struct gl_context *ctx, * create and install a stencil wrapper/adaptor. * * \param fb the framebuffer whose _StencilBuffer field to update - * \param attIndex indicates the renderbuffer to possibly wrap */ -void -_mesa_update_stencil_buffer(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLuint attIndex) +static void +update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) { - struct gl_renderbuffer *stencilRb; - - ASSERT(attIndex == BUFFER_DEPTH || - attIndex == BUFFER_STENCIL); - - stencilRb = fb->Attachment[attIndex].Renderbuffer; + struct gl_renderbuffer *stencilRb = + fb->Attachment[BUFFER_STENCIL].Renderbuffer; if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) { /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */ @@ -826,8 +812,8 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) */ update_color_draw_buffers(ctx, fb); update_color_read_buffer(ctx, fb); - _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); - _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); + update_depth_buffer(ctx, fb); + update_stencil_buffer(ctx, fb); compute_depth_max(fb); } @@ -853,23 +839,27 @@ _mesa_update_framebuffer(struct gl_context *ctx) /** - * Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, - * glCopyTex[Sub]Image, etc) exists. + * Check if the renderbuffer for a read/draw operation exists. * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL. + * \param reading if TRUE, we're going to read from the buffer, + if FALSE, we're going to write to the buffer. * \return GL_TRUE if buffer exists, GL_FALSE otherwise */ -GLboolean -_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) +static GLboolean +renderbuffer_exists(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLenum format, + GLboolean reading) { - const struct gl_renderbuffer_attachment *att = ctx->ReadBuffer->Attachment; + const struct gl_renderbuffer_attachment *att = fb->Attachment; /* If we don't know the framebuffer status, update it now */ - if (ctx->ReadBuffer->_Status == 0) { - _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + if (fb->_Status == 0) { + _mesa_test_framebuffer_completeness(ctx, fb); } - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { return GL_FALSE; } @@ -898,42 +888,44 @@ _mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) case GL_BGRA_INTEGER_EXT: case GL_LUMINANCE_INTEGER_EXT: case GL_LUMINANCE_ALPHA_INTEGER_EXT: - if (ctx->ReadBuffer->_ColorReadBuffer == NULL) { - return GL_FALSE; + if (reading) { + /* about to read from a color buffer */ + const struct gl_renderbuffer *readBuf = fb->_ColorReadBuffer; + if (!readBuf) { + return GL_FALSE; + } + ASSERT(_mesa_get_format_bits(readBuf->Format, GL_RED_BITS) > 0 || + _mesa_get_format_bits(readBuf->Format, GL_ALPHA_BITS) > 0 || + _mesa_get_format_bits(readBuf->Format, GL_TEXTURE_LUMINANCE_SIZE) > 0 || + _mesa_get_format_bits(readBuf->Format, GL_TEXTURE_INTENSITY_SIZE) > 0 || + _mesa_get_format_bits(readBuf->Format, GL_INDEX_BITS) > 0); + } + else { + /* about to draw to zero or more color buffers (none is OK) */ + return GL_TRUE; } - ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_ALPHA_BITS) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_TEXTURE_LUMINANCE_SIZE) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_TEXTURE_INTENSITY_SIZE) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0); break; case GL_DEPTH: case GL_DEPTH_COMPONENT: - if (!att[BUFFER_DEPTH].Renderbuffer) { + if (att[BUFFER_DEPTH].Type == GL_NONE) { return GL_FALSE; } - /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ break; case GL_STENCIL: case GL_STENCIL_INDEX: - if (!att[BUFFER_STENCIL].Renderbuffer) { + if (att[BUFFER_STENCIL].Type == GL_NONE) { return GL_FALSE; } - /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ break; case GL_DEPTH_STENCIL_EXT: - if (!att[BUFFER_DEPTH].Renderbuffer || - !att[BUFFER_STENCIL].Renderbuffer) { + if (att[BUFFER_DEPTH].Type == GL_NONE || + att[BUFFER_STENCIL].Type == GL_NONE) { return GL_FALSE; } - /* - ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); - ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); - */ break; default: _mesa_problem(ctx, - "Unexpected format 0x%x in _mesa_source_buffer_exists", + "Unexpected format 0x%x in renderbuffer_exists", format); return GL_FALSE; } @@ -944,83 +936,27 @@ _mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) /** + * Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, + * glCopyTex[Sub]Image, etc) exists. + * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, + * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL. + * \return GL_TRUE if buffer exists, GL_FALSE otherwise + */ +GLboolean +_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) +{ + return renderbuffer_exists(ctx, ctx->ReadBuffer, format, GL_TRUE); +} + + +/** * As above, but for drawing operations. * XXX could do some code merging w/ above function. */ GLboolean _mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format) { - const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; - - /* If we don't know the framebuffer status, update it now */ - if (ctx->DrawBuffer->_Status == 0) { - _mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer); - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - return GL_FALSE; - } - - switch (format) { - case GL_COLOR: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - /* Nothing special since GL_DRAW_BUFFER could be GL_NONE. */ - /* Could assert that colorbuffer has RedBits > 0 */ - break; - case GL_DEPTH: - case GL_DEPTH_COMPONENT: - if (!att[BUFFER_DEPTH].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ - break; - case GL_STENCIL: - case GL_STENCIL_INDEX: - if (!att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ - break; - case GL_DEPTH_STENCIL_EXT: - if (!att[BUFFER_DEPTH].Renderbuffer || - !att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /* - ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); - ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); - */ - break; - default: - _mesa_problem(ctx, - "Unexpected format 0x%x in _mesa_dest_buffer_exists", - format); - return GL_FALSE; - } - - /* OK */ - return GL_TRUE; + return renderbuffer_exists(ctx, ctx->DrawBuffer, format, GL_FALSE); } diff --git a/mesalib/src/mesa/main/framebuffer.h b/mesalib/src/mesa/main/framebuffer.h index 7aef3e02b..ad53d8cbe 100644 --- a/mesalib/src/mesa/main/framebuffer.h +++ b/mesalib/src/mesa/main/framebuffer.h @@ -82,14 +82,6 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx, struct gl_framebuffer *fb); extern void -_mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint attIndex); - -extern void -_mesa_update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint attIndex); - -extern void _mesa_update_framebuffer(struct gl_context *ctx); extern GLboolean diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 160a4f218..3c388e56e 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -138,6 +138,7 @@ enum value_extra { EXTRA_VALID_TEXTURE_UNIT, EXTRA_VALID_CLIP_DISTANCE, EXTRA_FLUSH_CURRENT, + EXTRA_GLSL_130, }; #define NO_EXTRA NULL @@ -277,8 +278,8 @@ static const int extra_EXT_texture_integer[] = { EXTRA_END }; -static const int extra_EXT_gpu_shader4[] = { - EXT(EXT_gpu_shader4), +static const int extra_GLSL_130[] = { + EXTRA_GLSL_130, EXTRA_END }; @@ -1234,13 +1235,13 @@ static const struct value_desc values[] = { /* GL_ARB_color_buffer_float */ { GL_RGBA_FLOAT_MODE_ARB, BUFFER_FIELD(Visual.floatMode, TYPE_BOOLEAN), 0 }, - /* GL_EXT_gpu_shader4 / GL 3.0 */ + /* GL_EXT_gpu_shader4 / GLSL 1.30 */ { GL_MIN_PROGRAM_TEXEL_OFFSET, CONTEXT_INT(Const.MinProgramTexelOffset), - extra_EXT_gpu_shader4 }, + extra_GLSL_130 }, { GL_MAX_PROGRAM_TEXEL_OFFSET, CONTEXT_INT(Const.MaxProgramTexelOffset), - extra_EXT_gpu_shader4 }, + extra_GLSL_130 }, /* GL_ARB_texture_buffer_object */ { GL_MAX_TEXTURE_BUFFER_SIZE_ARB, CONTEXT_INT(Const.MaxTextureBufferSize), @@ -1817,6 +1818,12 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d return GL_FALSE; } break; + case EXTRA_GLSL_130: + if (ctx->Const.GLSLVersion >= 130) { + total++; + enabled++; + } + break; case EXTRA_END: break; default: /* *e is a offset into the extension struct */ diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 749324d76..17c645a7e 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1311,9 +1311,6 @@ struct gl_sampler_object /* deprecated sampler state */ GLenum DepthMode; /**< GL_ARB_depth_texture */ - - /** Is the texture object complete with respect to this sampler? */ - GLboolean _CompleteTexture; }; @@ -2138,6 +2135,17 @@ struct gl_shader_program GLint RefCount; /**< Reference count */ GLboolean DeletePending; + /** + * Flags that the linker should not reject the program if it lacks + * a vertex or fragment shader. GLES2 doesn't allow separate + * shader objects, and would reject them. However, we internally + * build separate shader objects for fixed function programs, which + * we use for drivers/common/meta.c and for handling + * _mesa_update_state with no program bound (for example in + * glClear()). + */ + GLboolean InternalSeparateShader; + GLuint NumShaders; /**< number of attached shaders */ struct gl_shader **Shaders; /**< List of attached the shaders */ diff --git a/mesalib/src/mesa/main/pbo.c b/mesalib/src/mesa/main/pbo.c index 4e7e6f925..41ff2ff44 100644 --- a/mesalib/src/mesa/main/pbo.c +++ b/mesalib/src/mesa/main/pbo.c @@ -82,6 +82,19 @@ _mesa_validate_pbo_access(GLuint dimensions, } else { offset = ptr; sizeAddr = ((const GLubyte *) 0) + pack->BufferObj->Size; + /* The ARB_pixel_buffer_object spec says: + * "INVALID_OPERATION is generated by ColorTable, ColorSubTable, + * ConvolutionFilter2D, ConvolutionFilter1D, SeparableFilter2D, + * TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, + * TexSubImage2D, TexSubImage3D, and DrawPixels if the current + * PIXEL_UNPACK_BUFFER_BINDING_ARB value is non-zero and the data + * parameter is not evenly divisible into the number of basic machine + * units needed to store in memory a datum indicated by the type + * parameter." + */ + if (type != GL_BITMAP && + ((GLintptr)offset % _mesa_sizeof_packed_type(type))) + return GL_FALSE; } if (sizeAddr == 0) diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index c3aabe43f..6868dfab0 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -390,10 +390,12 @@ delete_shader_program(struct gl_context *ctx, GLuint name) if (!shProg) return; - shProg->DeletePending = GL_TRUE; + if (!shProg->DeletePending) { + shProg->DeletePending = GL_TRUE; - /* effectively, decr shProg's refcount */ - _mesa_reference_shader_program(ctx, &shProg, NULL); + /* effectively, decr shProg's refcount */ + _mesa_reference_shader_program(ctx, &shProg, NULL); + } } diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c index bbe90a32e..98ca733c0 100644 --- a/mesalib/src/mesa/main/state.c +++ b/mesalib/src/mesa/main/state.c @@ -260,10 +260,11 @@ update_program(struct gl_context *ctx) } else if (ctx->FragmentProgram._MaintainTexEnvProgram) { /* Use fragment program generated from fixed-function state */ + struct gl_shader_program *f = _mesa_get_fixed_func_fragment_program(ctx); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - _mesa_get_fixed_func_fragment_program(ctx)); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - ctx->FragmentProgram._Current); + (struct gl_fragment_program *) + f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); } else { /* No fragment program */ diff --git a/mesalib/src/mesa/main/texenvprogram.h b/mesalib/src/mesa/main/texenvprogram.h index 0895ebacb..3d9cb8546 100644 --- a/mesalib/src/mesa/main/texenvprogram.h +++ b/mesalib/src/mesa/main/texenvprogram.h @@ -1,35 +1,35 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef TEXENVPROGRAM_H
-#define TEXENVPROGRAM_H
-
-
-struct gl_context;
-
-extern struct gl_fragment_program *
-_mesa_get_fixed_func_fragment_program(struct gl_context *ctx);
-
-#endif
+/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef TEXENVPROGRAM_H +#define TEXENVPROGRAM_H + + +struct gl_context; + +extern struct gl_shader_program * +_mesa_get_fixed_func_fragment_program(struct gl_context *ctx); + +#endif diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index f9118860b..06e032396 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -884,7 +884,7 @@ _mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize, return; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj) && !img) { + if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !img) { /* not an error, do nothing */ return; } diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 8efe715fe..2d06f84bf 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -1893,7 +1893,7 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, const GLenum proxyTarget = get_proxy_target(target); const GLenum type = GL_FLOAT; GLboolean sizeOK; - GLint format; + GLint baseFormat; /* check target */ if (!legal_texsubimage_target(ctx, dimensions, target)) { @@ -1928,14 +1928,14 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - format = _mesa_base_tex_format(ctx, internalFormat); - if (format < 0) { + baseFormat = _mesa_base_tex_format(ctx, internalFormat); + if (baseFormat < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glCopyTexImage%dD(internalFormat)", dimensions); return GL_TRUE; } - if (!_mesa_source_buffer_exists(ctx, format)) { + if (!_mesa_source_buffer_exists(ctx, baseFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexImage%dD(missing readbuffer)", dimensions); return GL_TRUE; @@ -1946,7 +1946,7 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, ? (width == height) : 1; sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - internalFormat, format, + internalFormat, baseFormat, type, width, height, 1, border); @@ -1975,22 +1975,6 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } } - else if (_mesa_is_depth_format(internalFormat)) { - /* make sure we have depth/stencil buffers */ - if (!ctx->ReadBuffer->_DepthBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(no depth)", dimensions); - return GL_TRUE; - } - } - else if (_mesa_is_depthstencil_format(internalFormat)) { - /* make sure we have depth/stencil buffers */ - if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(no depth/stencil buffer)", dimensions); - return GL_TRUE; - } - } /* if we get here, the parameters are OK */ return GL_FALSE; @@ -2149,23 +2133,6 @@ copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) { - if (!ctx->ReadBuffer->_DepthBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(no depth buffer)", - dimensions); - return GL_TRUE; - } - } - else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { - if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(no depth/stencil buffer)", - dimensions); - return GL_TRUE; - } - } - /* If copying into an integer texture, the source buffer must also be * integer-valued. */ diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp new file mode 100644 index 000000000..ba7d7591f --- /dev/null +++ b/mesalib/src/mesa/main/uniform_query.cpp @@ -0,0 +1,80 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. + * Copyright © 2010, 2011 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include "main/core.h" +#include "ir.h" +#include "../glsl/program.h" + +extern "C" { +#include "main/shaderapi.h" +#include "main/shaderobj.h" +#include "uniforms.h" +} + +extern "C" void GLAPIENTRY +_mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, + GLsizei maxLength, GLsizei *length, GLint *size, + GLenum *type, GLcharARB *nameOut) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg = + _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform"); + const struct gl_program_parameter *param; + + if (!shProg) + return; + + if (!shProg->Uniforms || index >= shProg->Uniforms->NumUniforms) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)"); + return; + } + + param = get_uniform_parameter(shProg, index); + if (!param) + return; + + const struct gl_uniform *const uni = &shProg->Uniforms->Uniforms[index]; + + if (nameOut) { + _mesa_copy_string(nameOut, maxLength, length, param->Name); + } + + if (size) { + GLint typeSize = _mesa_sizeof_glsl_type(uni->Type->gl_type); + if ((GLint) param->Size > typeSize) { + /* This is an array. + * Array elements are placed on vector[4] boundaries so they're + * a multiple of four floats. We round typeSize up to next multiple + * of four to get the right size below. + */ + typeSize = (typeSize + 3) & ~3; + } + /* Note that the returned size is in units of the <type>, not bytes */ + *size = param->Size / typeSize; + } + + if (type) { + *type = uni->Type->gl_type; + } +} diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index 7252c099a..ccaedf9f1 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -211,7 +211,7 @@ find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index, * \param index the uniform index in [0, NumUniforms-1] * \return gl_program_parameter point or NULL if index is invalid */ -static const struct gl_program_parameter * +const struct gl_program_parameter * get_uniform_parameter(struct gl_shader_program *shProg, GLint index) { struct gl_program *prog; @@ -224,54 +224,6 @@ get_uniform_parameter(struct gl_shader_program *shProg, GLint index) } -/** - * Called by glGetActiveUniform(). - */ -static void -_mesa_get_active_uniform(struct gl_context *ctx, GLuint program, GLuint index, - GLsizei maxLength, GLsizei *length, GLint *size, - GLenum *type, GLchar *nameOut) -{ - struct gl_shader_program *shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform"); - const struct gl_program_parameter *param; - - if (!shProg) - return; - - if (!shProg->Uniforms || index >= shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)"); - return; - } - - param = get_uniform_parameter(shProg, index); - if (!param) - return; - - if (nameOut) { - _mesa_copy_string(nameOut, maxLength, length, param->Name); - } - - if (size) { - GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); - if ((GLint) param->Size > typeSize) { - /* This is an array. - * Array elements are placed on vector[4] boundaries so they're - * a multiple of four floats. We round typeSize up to next multiple - * of four to get the right size below. - */ - typeSize = (typeSize + 3) & ~3; - } - /* Note that the returned size is in units of the <type>, not bytes */ - *size = param->Size / typeSize; - } - - if (type) { - *type = param->DataType; - } -} - - static unsigned get_vector_elements(GLenum type) { @@ -1479,17 +1431,6 @@ _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) } -void GLAPIENTRY -_mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, - GLsizei maxLength, GLsizei * length, GLint * size, - GLenum * type, GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_get_active_uniform(ctx, program, index, maxLength, length, size, - type, name); -} - - /** * Plug in shader uniform-related functions into API dispatch table. */ diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h index b024cb30b..77f55d47d 100644 --- a/mesalib/src/mesa/main/uniforms.h +++ b/mesalib/src/mesa/main/uniforms.h @@ -191,6 +191,9 @@ _mesa_update_shader_textures_used(struct gl_program *prog); extern void _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec); +extern const struct gl_program_parameter * +get_uniform_parameter(struct gl_shader_program *shProg, GLint index); + struct gl_builtin_uniform_element { const char *field; int tokens[STATE_LENGTH]; diff --git a/mesalib/src/mesa/program/hash_table.h b/mesalib/src/mesa/program/hash_table.h index bfe221b24..941d28a4c 100644 --- a/mesalib/src/mesa/program/hash_table.h +++ b/mesalib/src/mesa/program/hash_table.h @@ -32,6 +32,7 @@ #define HASH_TABLE_H #include <string.h> +#include <stdlib.h> #include <stdint.h> #include <limits.h> #include <assert.h> @@ -100,6 +101,10 @@ extern void *hash_table_find(struct hash_table *ht, const void *key); * calls to \c hash_table_find and \c hash_table_remove will return or remove, * repsectively, the most recently added instance of \c key. * + * \warning + * The value passed by \c key is kept in the hash table and is used by later + * calls to \c hash_table_find. + * * \sa hash_table_replace */ extern void hash_table_insert(struct hash_table *ht, void *data, @@ -204,6 +209,7 @@ public: ~string_to_uint_map() { + hash_table_call_foreach(this->ht, delete_key, NULL); hash_table_dtor(this->ht); } @@ -243,10 +249,20 @@ public: * because UINT_MAX+1 = 0. */ assert(value != UINT_MAX); - hash_table_replace(ht, (void *) (intptr_t) (value + 1), key); + hash_table_replace(this->ht, + (void *) (intptr_t) (value + 1), + strdup(key)); } private: + static void delete_key(const void *key, void *data, void *closure) + { + (void) data; + (void) closure; + + free((char *)key); + } + struct hash_table *ht; }; diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index 5be44bc51..fecab50f7 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -41,12 +41,13 @@ #include "ir_optimization.h" #include "ast.h" -extern "C" { #include "main/mtypes.h" -#include "main/shaderapi.h" #include "main/shaderobj.h" -#include "main/uniforms.h" #include "program/hash_table.h" + +extern "C" { +#include "main/shaderapi.h" +#include "main/uniforms.h" #include "program/prog_instruction.h" #include "program/prog_optimize.h" #include "program/prog_print.h" @@ -2587,121 +2588,83 @@ check_resources(const struct gl_context *ctx, } - -struct uniform_sort { - struct gl_uniform *u; - int pos; -}; - -/* The shader_program->Uniforms list is almost sorted in increasing - * uniform->{Frag,Vert}Pos locations, but not quite when there are - * uniforms shared between targets. We need to add parameters in - * increasing order for the targets. - */ static int -sort_uniforms(const void *a, const void *b) +add_uniform_to_shader(ir_variable *var, + struct gl_program_parameter_list *params, + unsigned int &next_sampler) { - struct uniform_sort *u1 = (struct uniform_sort *)a; - struct uniform_sort *u2 = (struct uniform_sort *)b; - - return u1->pos - u2->pos; -} + const glsl_type *type = var->type; + unsigned int size; -/* Add the uniforms to the parameters. The linker chose locations - * in our parameters lists (which weren't created yet), which the - * uniforms code will use to poke values into our parameters list - * when uniforms are updated. - */ -static void -add_uniforms_to_parameters_list(struct gl_shader_program *shader_program, - struct gl_shader *shader, - struct gl_program *prog) -{ - unsigned int i; - unsigned int next_sampler = 0, num_uniforms = 0; - struct uniform_sort *sorted_uniforms; + if (type->is_vector() || type->is_scalar()) { + size = type->vector_elements; + } else { + size = type_size(type) * 4; + } - sorted_uniforms = ralloc_array(NULL, struct uniform_sort, - shader_program->Uniforms->NumUniforms); + gl_register_file file; + if (type->is_sampler() || + (type->is_array() && type->fields.array->is_sampler())) { + file = PROGRAM_SAMPLER; + } else { + file = PROGRAM_UNIFORM; + } - for (i = 0; i < shader_program->Uniforms->NumUniforms; i++) { - struct gl_uniform *uniform = shader_program->Uniforms->Uniforms + i; - int parameter_index = -1; + int index = _mesa_lookup_parameter_index(params, -1, var->name); + if (index < 0) { + index = _mesa_add_parameter(params, file, + var->name, size, type->gl_type, + NULL, NULL, 0x0); - switch (shader->Type) { - case GL_VERTEX_SHADER: - parameter_index = uniform->VertPos; - break; - case GL_FRAGMENT_SHADER: - parameter_index = uniform->FragPos; - break; - case GL_GEOMETRY_SHADER: - parameter_index = uniform->GeomPos; - break; - } - - /* Only add uniforms used in our target. */ - if (parameter_index != -1) { - sorted_uniforms[num_uniforms].pos = parameter_index; - sorted_uniforms[num_uniforms].u = uniform; - num_uniforms++; + /* Sampler uniform values are stored in prog->SamplerUnits, + * and the entry in that array is selected by this index we + * store in ParameterValues[]. + */ + if (file == PROGRAM_SAMPLER) { + for (unsigned int j = 0; j < size / 4; j++) + params->ParameterValues[index + j][0].f = next_sampler++; } } - qsort(sorted_uniforms, num_uniforms, sizeof(struct uniform_sort), - sort_uniforms); - - for (i = 0; i < num_uniforms; i++) { - struct gl_uniform *uniform = sorted_uniforms[i].u; - int parameter_index = sorted_uniforms[i].pos; - const glsl_type *type = uniform->Type; - unsigned int size; - - if (type->is_vector() || - type->is_scalar()) { - size = type->vector_elements; - } else { - size = type_size(type) * 4; - } + return index; +} - gl_register_file file; - if (type->is_sampler() || - (type->is_array() && type->fields.array->is_sampler())) { - file = PROGRAM_SAMPLER; - } else { - file = PROGRAM_UNIFORM; - } +/** + * Generate the program parameters list for the user uniforms in a shader + * + * \param shader_program Linked shader program. This is only used to + * emit possible link errors to the info log. + * \param sh Shader whose uniforms are to be processed. + * \param params Parameter list to be filled in. + */ +void +_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program + *shader_program, + struct gl_shader *sh, + struct gl_program_parameter_list + *params) +{ + unsigned int next_sampler = 0; - GLint index = _mesa_lookup_parameter_index(prog->Parameters, -1, - uniform->Name); + foreach_list(node, sh->ir) { + ir_variable *var = ((ir_instruction *) node)->as_variable(); - if (index < 0) { - index = _mesa_add_parameter(prog->Parameters, file, - uniform->Name, size, type->gl_type, - NULL, NULL, 0x0); + if ((var == NULL) || (var->mode != ir_var_uniform) + || (strncmp(var->name, "gl_", 3) == 0)) + continue; - /* Sampler uniform values are stored in prog->SamplerUnits, - * and the entry in that array is selected by this index we - * store in ParameterValues[]. - */ - if (file == PROGRAM_SAMPLER) { - for (unsigned int j = 0; j < size / 4; j++) - prog->Parameters->ParameterValues[index + j][0].f = next_sampler++; - } + int loc = add_uniform_to_shader(var, params, next_sampler); - /* The location chosen in the Parameters list here (returned - * from _mesa_add_uniform) has to match what the linker chose. - */ - if (index != parameter_index) { - linker_error(shader_program, - "Allocation of uniform `%s' to target failed " - "(%d vs %d)\n", - uniform->Name, index, parameter_index); - } + /* The location chosen in the Parameters list here (returned from + * _mesa_add_parameter) has to match what the linker chose. + */ + if (var->location != loc) { + linker_error(shader_program, + "Allocation of uniform `%s' to target failed " + "(%d vs %d)\n", + var->name, loc, var->location); } } - - ralloc_free(sorted_uniforms); } static void @@ -3045,7 +3008,8 @@ get_mesa_program(struct gl_context *ctx, v.shader_program = shader_program; v.options = options; - add_uniforms_to_parameters_list(shader_program, shader, prog); + _mesa_generate_parameters_list_for_uniforms(shader_program, shader, + prog->Parameters); /* Emit Mesa IR for main(). */ visit_exec_list(shader->ir, &v); diff --git a/mesalib/src/mesa/program/ir_to_mesa.h b/mesalib/src/mesa/program/ir_to_mesa.h index e708bb769..d046b0fcf 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.h +++ b/mesalib/src/mesa/program/ir_to_mesa.h @@ -1,41 +1,48 @@ -/*
- * Copyright © 2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "main/glheader.h"
-
-struct gl_context;
-struct gl_shader;
-struct gl_shader_program;
-
-void _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *sh);
-void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
-GLboolean _mesa_ir_compile_shader(struct gl_context *ctx, struct gl_shader *shader);
-GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
-
-#ifdef __cplusplus
-}
-#endif
+/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "main/glheader.h" + +struct gl_context; +struct gl_shader; +struct gl_shader_program; + +#ifdef __cplusplus +extern "C" { +#endif + +void _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *sh); +void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); +GLboolean _mesa_ir_compile_shader(struct gl_context *ctx, struct gl_shader *shader); +GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); + +#ifdef __cplusplus +} + +void +_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program + *shader_program, + struct gl_shader *sh, + struct gl_program_parameter_list + *params); +#endif diff --git a/mesalib/src/mesa/program/prog_print.c b/mesalib/src/mesa/program/prog_print.c index 70412b1fa..dfccc60f6 100644 --- a/mesalib/src/mesa/program/prog_print.c +++ b/mesalib/src/mesa/program/prog_print.c @@ -1068,9 +1068,9 @@ _mesa_write_shader_to_file(const struct gl_shader *shader) * _mesa_write_shader_to_file function. */ void -_mesa_append_uniforms_to_file(const struct gl_shader *shader, - const struct gl_program *prog) +_mesa_append_uniforms_to_file(const struct gl_shader *shader) { + const struct gl_program *const prog = shader->Program; const char *type; char filename[100]; FILE *f; diff --git a/mesalib/src/mesa/program/prog_print.h b/mesalib/src/mesa/program/prog_print.h index caeedb779..b95ec2be5 100644 --- a/mesalib/src/mesa/program/prog_print.h +++ b/mesalib/src/mesa/program/prog_print.h @@ -1,120 +1,119 @@ -/*
- * Mesa 3-D graphics library
- * Version: 6.5.3
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef PROG_PRINT_H
-#define PROG_PRINT_H
-
-#include <stdio.h>
-
-#include "main/glheader.h"
-#include "main/mtypes.h"
-
-struct gl_program;
-struct gl_program_parameter_list;
-struct gl_shader;
-struct prog_instruction;
-
-
-/**
- * The output style to use when printing programs.
- */
-typedef enum {
- PROG_PRINT_ARB,
- PROG_PRINT_NV,
- PROG_PRINT_DEBUG
-} gl_prog_print_mode;
-
-
-extern const char *
-_mesa_register_file_name(gl_register_file f);
-
-extern void
-_mesa_print_vp_inputs(GLbitfield inputs);
-
-extern void
-_mesa_print_fp_inputs(GLbitfield inputs);
-
-extern const char *
-_mesa_condcode_string(GLuint condcode);
-
-extern const char *
-_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended);
-
-const char *
-_mesa_writemask_string(GLuint writeMask);
-
-extern void
-_mesa_print_swizzle(GLuint swizzle);
-
-extern void
-_mesa_fprint_alu_instruction(FILE *f,
- const struct prog_instruction *inst,
- const char *opcode_string, GLuint numRegs,
- gl_prog_print_mode mode,
- const struct gl_program *prog);
-
-extern void
-_mesa_print_alu_instruction(const struct prog_instruction *inst,
- const char *opcode_string, GLuint numRegs);
-
-extern void
-_mesa_print_instruction(const struct prog_instruction *inst);
-
-extern GLint
-_mesa_fprint_instruction_opt(FILE *f,
- const struct prog_instruction *inst,
- GLint indent,
- gl_prog_print_mode mode,
- const struct gl_program *prog);
-
-extern GLint
-_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent,
- gl_prog_print_mode mode,
- const struct gl_program *prog);
-
-extern void
-_mesa_print_program(const struct gl_program *prog);
-
-extern void
-_mesa_fprint_program_opt(FILE *f,
- const struct gl_program *prog, gl_prog_print_mode mode,
- GLboolean lineNumbers);
-
-extern void
-_mesa_print_program_parameters(struct gl_context *ctx, const struct gl_program *prog);
-
-extern void
-_mesa_print_parameter_list(const struct gl_program_parameter_list *list);
-
-
-extern void
-_mesa_write_shader_to_file(const struct gl_shader *shader);
-
-extern void
-_mesa_append_uniforms_to_file(const struct gl_shader *shader,
- const struct gl_program *prog);
-
-
-#endif /* PROG_PRINT_H */
+/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef PROG_PRINT_H +#define PROG_PRINT_H + +#include <stdio.h> + +#include "main/glheader.h" +#include "main/mtypes.h" + +struct gl_program; +struct gl_program_parameter_list; +struct gl_shader; +struct prog_instruction; + + +/** + * The output style to use when printing programs. + */ +typedef enum { + PROG_PRINT_ARB, + PROG_PRINT_NV, + PROG_PRINT_DEBUG +} gl_prog_print_mode; + + +extern const char * +_mesa_register_file_name(gl_register_file f); + +extern void +_mesa_print_vp_inputs(GLbitfield inputs); + +extern void +_mesa_print_fp_inputs(GLbitfield inputs); + +extern const char * +_mesa_condcode_string(GLuint condcode); + +extern const char * +_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended); + +const char * +_mesa_writemask_string(GLuint writeMask); + +extern void +_mesa_print_swizzle(GLuint swizzle); + +extern void +_mesa_fprint_alu_instruction(FILE *f, + const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs, + gl_prog_print_mode mode, + const struct gl_program *prog); + +extern void +_mesa_print_alu_instruction(const struct prog_instruction *inst, + const char *opcode_string, GLuint numRegs); + +extern void +_mesa_print_instruction(const struct prog_instruction *inst); + +extern GLint +_mesa_fprint_instruction_opt(FILE *f, + const struct prog_instruction *inst, + GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog); + +extern GLint +_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, + gl_prog_print_mode mode, + const struct gl_program *prog); + +extern void +_mesa_print_program(const struct gl_program *prog); + +extern void +_mesa_fprint_program_opt(FILE *f, + const struct gl_program *prog, gl_prog_print_mode mode, + GLboolean lineNumbers); + +extern void +_mesa_print_program_parameters(struct gl_context *ctx, const struct gl_program *prog); + +extern void +_mesa_print_parameter_list(const struct gl_program_parameter_list *list); + + +extern void +_mesa_write_shader_to_file(const struct gl_shader *shader); + +extern void +_mesa_append_uniforms_to_file(const struct gl_shader *shader); + + +#endif /* PROG_PRINT_H */ diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c index 4d6c60b9d..736652529 100644 --- a/mesalib/src/mesa/program/program.c +++ b/mesalib/src/mesa/program/program.c @@ -140,7 +140,7 @@ _mesa_free_program_data(struct gl_context *ctx) #endif #if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL); - _mesa_delete_program_cache(ctx, ctx->FragmentProgram.Cache); + _mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache); #endif #if FEATURE_ARB_geometry_shader4 _mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, NULL); diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak index f29213ec0..aedee3d1c 100644 --- a/mesalib/src/mesa/sources.mak +++ b/mesalib/src/mesa/sources.mak @@ -105,7 +105,8 @@ MAIN_SOURCES = \ MAIN_CXX_SOURCES = \ main/ff_fragment_shader.cpp \ - main/shader_query.cpp + main/shader_query.cpp \ + main/uniform_query.cpp MATH_SOURCES = \ math/m_debug_clip.c \ diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 74e87f0e4..89e0a73f1 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -871,7 +871,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, if (format == GL_DEPTH_STENCIL) { GLenum ztype = - pt->resource->format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED ? + pt->resource->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT ? GL_FLOAT : GL_UNSIGNED_INT; _mesa_unpack_depth_span(ctx, spanWidth, ztype, zValues, @@ -896,14 +896,14 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, /* now pack the stencil (and Z) values in the dest format */ switch (pt->resource->format) { - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: { ubyte *dest = stmap + spanY * pt->stride + spanX; assert(usage == PIPE_TRANSFER_WRITE); memcpy(dest, sValues, spanWidth); } break; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; @@ -921,7 +921,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; @@ -939,7 +939,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLfloat *destf = (GLfloat*)dest; @@ -1112,20 +1112,20 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y, enum pipe_format stencil_format = PIPE_FORMAT_NONE; switch (pt->format) { - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: - case PIPE_FORMAT_X24S8_USCALED: - stencil_format = PIPE_FORMAT_X24S8_USCALED; + case PIPE_FORMAT_Z24_UNORM_S8_UINT: + case PIPE_FORMAT_X24S8_UINT: + stencil_format = PIPE_FORMAT_X24S8_UINT; break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: - case PIPE_FORMAT_S8X24_USCALED: - stencil_format = PIPE_FORMAT_S8X24_USCALED; + case PIPE_FORMAT_S8_UINT_Z24_UNORM: + case PIPE_FORMAT_S8X24_UINT: + stencil_format = PIPE_FORMAT_S8X24_UINT; break; - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: - case PIPE_FORMAT_X32_S8X24_USCALED: - stencil_format = PIPE_FORMAT_X32_S8X24_USCALED; + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: + case PIPE_FORMAT_X32_S8X24_UINT: + stencil_format = PIPE_FORMAT_X32_S8X24_UINT; break; - case PIPE_FORMAT_S8_USCALED: - stencil_format = PIPE_FORMAT_S8_USCALED; + case PIPE_FORMAT_S8_UINT: + stencil_format = PIPE_FORMAT_S8_UINT; break; default: assert(0); @@ -1241,7 +1241,7 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, src = buffer + i * width; switch (ptDraw->resource->format) { - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: { uint *dst4 = (uint *) dst; int j; @@ -1252,7 +1252,7 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, } } break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: { uint *dst4 = (uint *) dst; int j; @@ -1263,11 +1263,11 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, } } break; - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: assert(usage == PIPE_TRANSFER_WRITE); memcpy(dst, src, width); break; - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: { uint *dst4 = (uint *) dst; int j; diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c index 531296fb3..37c20ebe3 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c +++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c @@ -53,7 +53,7 @@ st_pipe_format_to_base_format(enum pipe_format format) base_format = GL_DEPTH_STENCIL; } else { - if (format == PIPE_FORMAT_S8_USCALED) + if (format == PIPE_FORMAT_S8_UINT) base_format = GL_STENCIL_INDEX; else base_format = GL_DEPTH_COMPONENT; diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c index 4d321587f..6da65d7b9 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c @@ -259,13 +259,13 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) case PIPE_FORMAT_Z32_UNORM: strb->Base.InternalFormat = GL_DEPTH_COMPONENT32; break; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: case PIPE_FORMAT_Z24X8_UNORM: case PIPE_FORMAT_X8Z24_UNORM: strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT; break; - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT; break; case PIPE_FORMAT_R16G16B16A16_SNORM: diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c index 7fa1672fd..bd73f3bf0 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c @@ -109,13 +109,13 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, /* get stencil (and Z) values */ switch (pt->resource->format) { - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: { const ubyte *src = stmap + srcY * pt->stride; memcpy(sValues, src, width); } break; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat scale = 1.0f / (0xffffff); @@ -133,7 +133,7 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat scale = 1.0f / (0xffffff); @@ -151,7 +151,7 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat *srcf = (const GLfloat*)src; @@ -502,7 +502,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width, format, type); - if (pformat == PIPE_FORMAT_Z24_UNORM_S8_USCALED || + if (pformat == PIPE_FORMAT_Z24_UNORM_S8_UINT || pformat == PIPE_FORMAT_Z24X8_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { @@ -534,7 +534,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h } } } - else if (pformat == PIPE_FORMAT_S8_USCALED_Z24_UNORM || + else if (pformat == PIPE_FORMAT_S8_UINT_Z24_UNORM || pformat == PIPE_FORMAT_X8Z24_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { @@ -601,7 +601,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h dst += dstStride; } } - else if (pformat == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) { + else if (pformat == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) { assert(format == GL_DEPTH_COMPONENT); for (i = 0; i < height; i++) { GLfloat zfloat[MAX_WIDTH]; /* Z32 */ diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 6707fcae1..a1f029089 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -368,18 +368,18 @@ void st_init_extensions(struct st_context *st) /* GL_EXT_packed_depth_stencil requires both the ability to render to * a depth/stencil buffer and texture from depth/stencil source. */ - if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, + if (screen->is_format_supported(screen, PIPE_FORMAT_S8_UINT_Z24_UNORM, PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL) && - screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, + screen->is_format_supported(screen, PIPE_FORMAT_S8_UINT_Z24_UNORM, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } - else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, + else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_UINT, PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL) && - screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, + screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_UINT, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; @@ -650,7 +650,7 @@ void st_init_extensions(struct st_context *st) PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW) && - screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, + screen->is_format_supported(screen, PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW)) { diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 6e8ab94f4..196433d5e 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -89,13 +89,13 @@ st_format_datatype(enum pipe_format format) format == PIPE_FORMAT_R9G9B9E5_FLOAT) { return GL_FLOAT; } - else if (format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || - format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || + else if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT || + format == PIPE_FORMAT_S8_UINT_Z24_UNORM || format == PIPE_FORMAT_Z24X8_UNORM || format == PIPE_FORMAT_X8Z24_UNORM) { return GL_UNSIGNED_INT_24_8; } - else if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED) { + else if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) { return GL_FLOAT_32_UNSIGNED_INT_24_8_REV; } else { @@ -199,19 +199,19 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_Z32: return PIPE_FORMAT_Z32_UNORM; case MESA_FORMAT_Z24_S8: - return PIPE_FORMAT_S8_USCALED_Z24_UNORM; + return PIPE_FORMAT_S8_UINT_Z24_UNORM; case MESA_FORMAT_S8_Z24: - return PIPE_FORMAT_Z24_UNORM_S8_USCALED; + return PIPE_FORMAT_Z24_UNORM_S8_UINT; case MESA_FORMAT_Z24_X8: return PIPE_FORMAT_X8Z24_UNORM; case MESA_FORMAT_X8_Z24: return PIPE_FORMAT_Z24X8_UNORM; case MESA_FORMAT_S8: - return PIPE_FORMAT_S8_USCALED; + return PIPE_FORMAT_S8_UINT; case MESA_FORMAT_Z32_FLOAT: return PIPE_FORMAT_Z32_FLOAT; case MESA_FORMAT_Z32_FLOAT_X24S8: - return PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED; + return PIPE_FORMAT_Z32_FLOAT_S8X24_UINT; case MESA_FORMAT_YCBCR: return PIPE_FORMAT_UYVY; #if FEATURE_texture_s3tc @@ -508,7 +508,7 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_I8; case PIPE_FORMAT_I16_UNORM: return MESA_FORMAT_I16; - case PIPE_FORMAT_S8_USCALED: + case PIPE_FORMAT_S8_UINT: return MESA_FORMAT_S8; case PIPE_FORMAT_R16G16B16A16_UNORM: @@ -518,17 +518,17 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_Z16; case PIPE_FORMAT_Z32_UNORM: return MESA_FORMAT_Z32; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_S8_UINT_Z24_UNORM: return MESA_FORMAT_Z24_S8; case PIPE_FORMAT_X8Z24_UNORM: return MESA_FORMAT_Z24_X8; case PIPE_FORMAT_Z24X8_UNORM: return MESA_FORMAT_X8_Z24; - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: return MESA_FORMAT_S8_Z24; case PIPE_FORMAT_Z32_FLOAT: return MESA_FORMAT_Z32_FLOAT; - case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: return MESA_FORMAT_Z32_FLOAT_X24S8; case PIPE_FORMAT_UYVY: @@ -818,8 +818,8 @@ struct format_mapping PIPE_FORMAT_Z24X8_UNORM, \ PIPE_FORMAT_X8Z24_UNORM, \ PIPE_FORMAT_Z16_UNORM, \ - PIPE_FORMAT_Z24_UNORM_S8_USCALED, \ - PIPE_FORMAT_S8_USCALED_Z24_UNORM, \ + PIPE_FORMAT_Z24_UNORM_S8_UINT, \ + PIPE_FORMAT_S8_UINT_Z24_UNORM, \ 0 /** @@ -988,19 +988,19 @@ static const struct format_mapping format_map[] = { { GL_STENCIL_INDEX, GL_STENCIL_INDEX1_EXT, GL_STENCIL_INDEX4_EXT, GL_STENCIL_INDEX8_EXT, GL_STENCIL_INDEX16_EXT, 0 }, { - PIPE_FORMAT_S8_USCALED, PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_FORMAT_S8_USCALED_Z24_UNORM, 0 + PIPE_FORMAT_S8_UINT, PIPE_FORMAT_Z24_UNORM_S8_UINT, + PIPE_FORMAT_S8_UINT_Z24_UNORM, 0 } }, /* Depth / Stencil formats */ { { GL_DEPTH_STENCIL_EXT, GL_DEPTH24_STENCIL8_EXT, 0 }, - { PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_FORMAT_S8_USCALED_Z24_UNORM, 0 } + { PIPE_FORMAT_Z24_UNORM_S8_UINT, PIPE_FORMAT_S8_UINT_Z24_UNORM, 0 } }, { { GL_DEPTH32F_STENCIL8, 0 }, - { PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, 0 } + { PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, 0 } }, /* sRGB formats */ diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index fe65ae539..18e8a1db4 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -42,12 +42,13 @@ #include "ir_optimization.h" #include "ast.h" -extern "C" { #include "main/mtypes.h" -#include "main/shaderapi.h" #include "main/shaderobj.h" -#include "main/uniforms.h" #include "program/hash_table.h" + +extern "C" { +#include "main/shaderapi.h" +#include "main/uniforms.h" #include "program/prog_instruction.h" #include "program/prog_optimize.h" #include "program/prog_print.h" @@ -2913,122 +2914,6 @@ check_resources(const struct gl_context *ctx, } - -struct uniform_sort { - struct gl_uniform *u; - int pos; -}; - -/* The shader_program->Uniforms list is almost sorted in increasing - * uniform->{Frag,Vert}Pos locations, but not quite when there are - * uniforms shared between targets. We need to add parameters in - * increasing order for the targets. - */ -static int -sort_uniforms(const void *a, const void *b) -{ - struct uniform_sort *u1 = (struct uniform_sort *)a; - struct uniform_sort *u2 = (struct uniform_sort *)b; - - return u1->pos - u2->pos; -} - -/* Add the uniforms to the parameters. The linker chose locations - * in our parameters lists (which weren't created yet), which the - * uniforms code will use to poke values into our parameters list - * when uniforms are updated. - */ -static void -add_uniforms_to_parameters_list(struct gl_shader_program *shader_program, - struct gl_shader *shader, - struct gl_program *prog) -{ - unsigned int i; - unsigned int next_sampler = 0, num_uniforms = 0; - struct uniform_sort *sorted_uniforms; - - sorted_uniforms = ralloc_array(NULL, struct uniform_sort, - shader_program->Uniforms->NumUniforms); - - for (i = 0; i < shader_program->Uniforms->NumUniforms; i++) { - struct gl_uniform *uniform = shader_program->Uniforms->Uniforms + i; - int parameter_index = -1; - - switch (shader->Type) { - case GL_VERTEX_SHADER: - parameter_index = uniform->VertPos; - break; - case GL_FRAGMENT_SHADER: - parameter_index = uniform->FragPos; - break; - case GL_GEOMETRY_SHADER: - parameter_index = uniform->GeomPos; - break; - } - - /* Only add uniforms used in our target. */ - if (parameter_index != -1) { - sorted_uniforms[num_uniforms].pos = parameter_index; - sorted_uniforms[num_uniforms].u = uniform; - num_uniforms++; - } - } - - qsort(sorted_uniforms, num_uniforms, sizeof(struct uniform_sort), - sort_uniforms); - - for (i = 0; i < num_uniforms; i++) { - struct gl_uniform *uniform = sorted_uniforms[i].u; - int parameter_index = sorted_uniforms[i].pos; - const glsl_type *type = uniform->Type; - unsigned int size; - - if (type->is_vector() || - type->is_scalar()) { - size = type->vector_elements; - } else { - size = type_size(type) * 4; - } - - gl_register_file file; - if (type->is_sampler() || - (type->is_array() && type->fields.array->is_sampler())) { - file = PROGRAM_SAMPLER; - } else { - file = PROGRAM_UNIFORM; - } - - GLint index = _mesa_lookup_parameter_index(prog->Parameters, -1, - uniform->Name); - - if (index < 0) { - index = _mesa_add_parameter(prog->Parameters, file, - uniform->Name, size, type->gl_type, - NULL, NULL, 0x0); - - /* Sampler uniform values are stored in prog->SamplerUnits, - * and the entry in that array is selected by this index we - * store in ParameterValues[]. - */ - if (file == PROGRAM_SAMPLER) { - for (unsigned int j = 0; j < size / 4; j++) - prog->Parameters->ParameterValues[index + j][0].f = next_sampler++; - } - - /* The location chosen in the Parameters list here (returned - * from _mesa_add_uniform) has to match what the linker chose. - */ - if (index != parameter_index) { - fail_link(shader_program, "Allocation of uniform `%s' to target " - "failed (%d vs %d)\n", - uniform->Name, index, parameter_index); - } - } - } - - ralloc_free(sorted_uniforms); -} - static void set_uniform_initializer(struct gl_context *ctx, void *mem_ctx, struct gl_shader_program *shader_program, @@ -3772,7 +3657,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void) if (!inst->dead_mask || !inst->dst.writemask) continue; - else if (inst->dead_mask == inst->dst.writemask) { + else if ((inst->dst.writemask & ~inst->dead_mask) == 0) { iter.remove(); delete inst; removed++; @@ -4964,7 +4849,8 @@ get_mesa_program(struct gl_context *ctx, v->glsl_version = ctx->Const.GLSLVersion; v->native_integers = ctx->Const.NativeIntegers; - add_uniforms_to_parameters_list(shader_program, shader, prog); + _mesa_generate_parameters_list_for_uniforms(shader_program, shader, + prog->Parameters); /* Emit intermediate IR for main(). */ visit_exec_list(shader->ir, v); diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index acd3b56b9..c419c4066 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -1154,7 +1154,8 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData) } for (i = 0; i < Elements(shProg->_LinkedShaders); i++) { - destroy_program_variants(st, shProg->_LinkedShaders[i]->Program); + if (shProg->_LinkedShaders[i]) + destroy_program_variants(st, shProg->_LinkedShaders[i]->Program); } } break; diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c index 63bfa79b5..20bf4d626 100644 --- a/mesalib/src/mesa/swrast/s_drawpix.c +++ b/mesalib/src/mesa/swrast/s_drawpix.c @@ -590,8 +590,11 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, ASSERT(stencilRb); if (depthRb->_BaseFormat == GL_DEPTH_STENCIL_EXT && - stencilRb->_BaseFormat == GL_DEPTH_STENCIL_EXT && + depthRb->Format == MESA_FORMAT_Z24_S8 && + type == GL_UNSIGNED_INT_24_8 && depthRb == stencilRb && + depthRb->GetRow && /* May be null if depthRb is a wrapper around + * separate depth and stencil buffers. */ !scaleOrBias && !zoom && ctx->Depth.Mask && diff --git a/mesalib/src/mesa/swrast/s_readpix.c b/mesalib/src/mesa/swrast/s_readpix.c index 6eec2fc78..0d2e63f72 100644 --- a/mesalib/src/mesa/swrast/s_readpix.c +++ b/mesalib/src/mesa/swrast/s_readpix.c @@ -391,8 +391,11 @@ read_depth_stencil_pixels(struct gl_context *ctx, stencilRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; if (depthRb->_BaseFormat == GL_DEPTH_STENCIL_EXT && - stencilRb->_BaseFormat == GL_DEPTH_STENCIL_EXT && + depthRb->Format == MESA_FORMAT_Z24_S8 && + type == GL_UNSIGNED_INT_24_8 && depthRb == stencilRb && + depthRb->GetRow && /* May be null if depthRb is a wrapper around + * separate depth and stencil buffers. */ !scaleOrBias && !stencilTransfer) { /* This is the ideal case. diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 1aa20f9d7..e517c9ae1 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -707,11 +707,13 @@ clip_span( struct gl_context *ctx, SWspan *span ) const GLint n = span->end; GLubyte *mask = span->array->mask; GLint i; + GLuint passed = 0; if (span->arrayMask & SPAN_MASK) { /* note: using & intead of && to reduce branches */ for (i = 0; i < n; i++) { mask[i] &= (x[i] >= xmin) & (x[i] < xmax) & (y[i] >= ymin) & (y[i] < ymax); + passed += mask[i]; } } else { @@ -719,9 +721,10 @@ clip_span( struct gl_context *ctx, SWspan *span ) for (i = 0; i < n; i++) { mask[i] = (x[i] >= xmin) & (x[i] < xmax) & (y[i] >= ymin) & (y[i] < ymax); + passed += mask[i]; } } - return GL_TRUE; /* some pixels visible */ + return passed > 0; } else { /* horizontal span of pixels */ diff --git a/mesalib/src/mesa/vbo/vbo.h b/mesalib/src/mesa/vbo/vbo.h index 26c3d4e0a..9fbb07f3d 100644 --- a/mesalib/src/mesa/vbo/vbo.h +++ b/mesalib/src/mesa/vbo/vbo.h @@ -133,6 +133,7 @@ void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func); void vbo_check_buffers_are_unmapped(struct gl_context *ctx); +void vbo_bind_arrays(struct gl_context *ctx); void GLAPIENTRY _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c index 150589bec..5f3ed9d5d 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_api.c +++ b/mesalib/src/mesa/vbo/vbo_exec_api.c @@ -570,6 +570,9 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) return; } + if (ctx->Driver.PrepareExecBegin) + ctx->Driver.PrepareExecBegin(ctx); + if (ctx->NewState) { _mesa_update_state( ctx ); diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index 18719d5f5..4e4f2c947 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -538,7 +538,7 @@ recalculate_input_bindings(struct gl_context *ctx) } } - for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) { + for (i = 1; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) { if (exec->array.generic_array[i]->Enabled) inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i]; else { @@ -547,6 +547,7 @@ recalculate_input_bindings(struct gl_context *ctx) } } + inputs[VERT_ATTRIB_GENERIC0] = inputs[0]; ctx->NewState |= _NEW_ARRAY; break; } @@ -562,8 +563,8 @@ recalculate_input_bindings(struct gl_context *ctx) * Note that this might set the _NEW_ARRAY dirty flag so state validation * must be done after this call. */ -static void -bind_arrays(struct gl_context *ctx) +void +vbo_bind_arrays(struct gl_context *ctx) { if (!ctx->Array.RebindArrays) { return; @@ -589,7 +590,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start, struct vbo_exec_context *exec = &vbo->exec; struct _mesa_prim prim[2]; - bind_arrays(ctx); + vbo_bind_arrays(ctx); /* Again... because we may have changed the bitmask of per-vertex varying * attributes. If we regenerate the fixed-function vertex program now @@ -803,7 +804,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, return; } - bind_arrays( ctx ); + vbo_bind_arrays( ctx ); /* check for dirty state again */ if (ctx->NewState) @@ -1128,7 +1129,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, * same index buffer, or if we have to reset the index pointer per * primitive. */ - bind_arrays( ctx ); + vbo_bind_arrays( ctx ); /* check for dirty state again */ if (ctx->NewState) diff --git a/mkfontscale/data.h b/mkfontscale/data.h index bb5b170d5..6fb43ae79 100644 --- a/mkfontscale/data.h +++ b/mkfontscale/data.h @@ -26,7 +26,7 @@ /* Order is significant. For example, some B&H fonts are hinted by URW++, and both strings appear in the notice. */ -static char *notice_foundries[][2] = +static const char *notice_foundries[][2] = {{"Bigelow", "b&h"}, {"Adobe", "adobe"}, {"Bitstream", "bitstream"}, @@ -42,14 +42,16 @@ static char *notice_foundries[][2] = {"Microsoft", "microsoft"}, {"Omega", "omega"}, {"Font21", "hwan"}, - {"HanYang System", "hanyang"}}; + {"HanYang System", "hanyang"}, + {"Iorsh", "culmus"}, + {"Gnat", "culmus"}}; /* This table is partly taken from ttmkfdir by Joerg Pommnitz. */ /* It should not contain useless entries (such as UNKN) nor duplicate entries for padding both with spaces and NULs. */ -static char *vendor_foundries[][2] = +static const char *vendor_foundries[][2] = {{"ADBE", "adobe"}, {"AGFA", "agfa"}, {"ALTS", "altsys"}, @@ -59,6 +61,7 @@ static char *vendor_foundries[][2] = {"B&H", "b&h"}, {"BITS", "bitstream"}, {"CANO", "cannon"}, + {"CLM", "culmus"}, {"DYNA", "dynalab"}, {"EPSN", "epson"}, {"FJ", "fujitsu"}, diff --git a/mkfontscale/hash.c b/mkfontscale/hash.c index 313d5b6c1..135380bff 100644 --- a/mkfontscale/hash.c +++ b/mkfontscale/hash.c @@ -31,7 +31,7 @@ #define NUMBUCKETS (1 << LOG2_NUMBUCKETS) static unsigned -hash(char *string) +hash(const char *string) { int i; unsigned u = 0; @@ -41,7 +41,7 @@ hash(char *string) } static void -strcpy_lwr(char *dst, char *src) +strcpy_lwr(char *dst, const char *src) { while(1) { *dst = tolower(*src); @@ -77,7 +77,7 @@ destroyHashTable(HashTablePtr table) } char * -getHash(HashTablePtr table, char *key) +getHash(HashTablePtr table, const char *key) { int i = hash(key); HashBucketPtr bp; @@ -173,7 +173,7 @@ hashArray(HashTablePtr table, int value_first) { int i, j, n; HashBucketPtr *dst; - + n = hashElements(table); dst = malloc((n + 1) * sizeof(HashBucketPtr)); if(dst == NULL) diff --git a/mkfontscale/hash.h b/mkfontscale/hash.h index 631004e63..df0feeb71 100644 --- a/mkfontscale/hash.h +++ b/mkfontscale/hash.h @@ -38,7 +38,7 @@ typedef HashBucketPtr* HashTablePtr; HashTablePtr makeHashTable(void); void destroyHashTable(HashTablePtr table); -char *getHash(HashTablePtr table, char *key); +char *getHash(HashTablePtr table, const char *key); int putHash(HashTablePtr table, char *key, char *value, int prio); int hashElements(HashTablePtr table); HashBucketPtr *hashArray(HashTablePtr table, int value_first); diff --git a/mkfontscale/list.c b/mkfontscale/list.c index 2854e181c..1614d9537 100644 --- a/mkfontscale/list.c +++ b/mkfontscale/list.c @@ -27,7 +27,7 @@ #include "list.h" int -listMember(char *elt, ListPtr list) +listMember(const char *elt, ListPtr list) { while(list != NULL) { if(strcmp(elt, list->value) == 0) @@ -84,10 +84,10 @@ dsprintf(const char *f, ...) } } } - + ListPtr -listConsF(ListPtr cdr, char *f, ...) +listConsF(ListPtr cdr, const char *f, ...) { va_list args; char *string; @@ -114,7 +114,7 @@ listConsF(ListPtr cdr, char *f, ...) } ListPtr -listAdjoinF(ListPtr cdr, char *f, ...) +listAdjoinF(ListPtr cdr, const char *f, ...) { va_list args; char *string; @@ -151,7 +151,7 @@ listLength(ListPtr list) return n; } -ListPtr +ListPtr appendList(ListPtr first, ListPtr second) { ListPtr current; diff --git a/mkfontscale/list.h b/mkfontscale/list.h index 7403bc0f8..c68a78d4d 100644 --- a/mkfontscale/list.h +++ b/mkfontscale/list.h @@ -32,11 +32,11 @@ typedef struct _List { struct _List *next; } ListRec, *ListPtr; -int listMember(char *elt, ListPtr list); +int listMember(const char *elt, ListPtr list); ListPtr listCons(char *car, ListPtr cdr); ListPtr listAdjoin(char *car, ListPtr cdr); -ListPtr listConsF(ListPtr cdr, char *f, ...) _X_ATTRIBUTE_PRINTF(2,3); -ListPtr listAdjoinF(ListPtr cdr, char *f, ...) _X_ATTRIBUTE_PRINTF(2,3); +ListPtr listConsF(ListPtr cdr, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3); +ListPtr listAdjoinF(ListPtr cdr, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3); int listLength(ListPtr list); ListPtr appendList(ListPtr first, ListPtr second); ListPtr makeList(char **a, int n, ListPtr old, int begin); diff --git a/mkfontscale/mkfontscale.c b/mkfontscale/mkfontscale.c index 49bbe77a3..53c53031b 100644 --- a/mkfontscale/mkfontscale.c +++ b/mkfontscale/mkfontscale.c @@ -60,7 +60,7 @@ #define QUOTE(x) #x #define STRINGIFY(x) QUOTE(x) -static char *encodings_array[] = +static const char *encodings_array[] = { "ascii-0", "iso8859-1", "iso8859-2", "iso8859-3", "iso8859-4", "iso8859-5", "iso8859-6", "iso8859-6.8", "iso8859-6.8x", "iso8859-6.16", @@ -79,20 +79,20 @@ static char *encodings_array[] = "gb2312.1980-0", "gb18030.2000-0", "gb18030.2000-1", "ksc5601.1987-0", "ksc5601.1992-3"}; -static char *extra_encodings_array[] = +static const char *extra_encodings_array[] = { "iso10646-1", "adobe-fontspecific", "microsoft-symbol" }; static ListPtr encodings, extra_encodings; -static char *outfilename; +static const char *outfilename; #define countof(_a) (sizeof(_a)/sizeof((_a)[0])) -static int doDirectory(char*, int, ListPtr); +static int doDirectory(const char*, int, ListPtr); static int checkEncoding(FT_Face face, char *encoding_name); static int checkExtraEncoding(FT_Face face, char *encoding_name, int found); static int find_cmap(int type, int pid, int eid, FT_Face face); -static char* notice_foundry(char *notice); -static char* vendor_foundry(signed char *vendor); +static const char* notice_foundry(const char *notice); +static const char* vendor_foundry(const signed char *vendor); static int readFontScale(HashTablePtr entries, char *dirname); ListPtr makeXLFD(char *filename, FT_Face face, int); static int readEncodings(ListPtr encodings, char *dirname); @@ -113,7 +113,7 @@ static char *exclusionSuffix; static void usage(void) { - fprintf(stderr, + fprintf(stderr, "mkfontscale [ -b ] [ -s ] [ -o filename ] [-x suffix ]\n" " [ -a encoding ] [ -f fuzz ] [ -l ] " " [ -e directory ] [ -p prefix ] [ -n ] [ -r ] \n" @@ -143,7 +143,7 @@ main(int argc, char **argv) encodings = makeList(encodings_array, countof(encodings_array), NULL, 0); - extra_encodings = makeList(extra_encodings_array, + extra_encodings = makeList(extra_encodings_array, countof(extra_encodings_array), NULL, 0); doBitmaps = 0; @@ -204,7 +204,7 @@ main(int argc, char **argv) argn++; } else if(strcmp(argv[argn], "-U") == 0) { doISO10646_1_encoding = 1; - argn++; + argn++; } else if(strcmp(argv[argn], "-s") == 0) { doScalable = 0; argn++; @@ -244,7 +244,7 @@ main(int argc, char **argv) if(outfilename == NULL) { if(doBitmaps) outfilename = "fonts.dir"; - else + else outfilename = "fonts.scale"; } @@ -313,9 +313,9 @@ getName(FT_Face face, int nid) char *string; int i; - if(getNameHelper(face, nid, + if(getNameHelper(face, nid, TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, &name) || - getNameHelper(face, nid, + getNameHelper(face, nid, TT_PLATFORM_APPLE_UNICODE, -1, &name)) { string = malloc(name.string_len / 2 + 1); if(string == NULL) { @@ -348,7 +348,7 @@ getName(FT_Face face, int nid) return NULL; } -static char* +static const char* os2Weight(int weight) { if(weight < 150) @@ -367,11 +367,11 @@ os2Weight(int weight) return "bold"; else if(weight < 850) return "extrabold"; - else + else return "black"; } -static char* +static const char* os2Width(int width) { if(width <= 1) @@ -394,15 +394,15 @@ os2Width(int width) return "ultraexpanded"; } -static char *widths[] = { +static const char *widths[] = { "ultracondensed", "extracondensed", "condensed", "semicondensed", - "normal", "semiexpanded", "expanded", "extraexpanded", "ultraexpanded" + "normal", "semiexpanded", "expanded", "extraexpanded", "ultraexpanded" }; #define NUMWIDTHS (sizeof(widths) / sizeof(widths[0])) -static char* -nameWidth(char *name) +static const char* +nameWidth(const char *name) { char buf[500]; int i; @@ -419,8 +419,8 @@ nameWidth(char *name) return NULL; } -static char* -t1Weight(char *weight) +static const char* +t1Weight(const char *weight) { if(!weight) return NULL; @@ -461,13 +461,13 @@ t1Weight(char *weight) static int unsafe(char c) { - return + return c < 0x20 || c > 0x7E || c == '[' || c == ']' || c == '(' || c == ')' || c == '\\' || c == '-'; } -static char * -safe(char* s) +static const char * +safe(const char* s) { int i, len, safe_flag = 1; char *t; @@ -502,7 +502,7 @@ ListPtr makeXLFD(char *filename, FT_Face face, int isBitmap) { ListPtr xlfd = NULL; - char *foundry, *family, *weight, *slant, *sWidth, *adstyle, + const char *foundry, *family, *weight, *slant, *sWidth, *adstyle, *spacing, *full_name; TT_Header *head; TT_HoriHeader *hhea; @@ -530,7 +530,7 @@ makeXLFD(char *filename, FT_Face face, int isBitmap) t1info = &t1info_rec; else t1info = NULL; - + if(!family) family = getName(face, TT_NAME_ID_FONT_FAMILY); if(!family) @@ -568,7 +568,7 @@ makeXLFD(char *filename, FT_Face face, int isBitmap) } } } - + if(t1info) { if(!family) family = t1info->family_name; @@ -754,7 +754,7 @@ filePrio(char *filename) } static int -doDirectory(char *dirname_given, int numEncodings, ListPtr encodingsToDo) +doDirectory(const char *dirname_given, int numEncodings, ListPtr encodingsToDo) { char *dirname, *fontscale_name, *filename, *encdir; FILE *fontscale, *encfile; @@ -784,9 +784,9 @@ doDirectory(char *dirname_given, int numEncodings, ListPtr encodingsToDo) exit(1); } - if (onlyEncodings) + if (onlyEncodings) goto encodings; - + entries = makeHashTable(); if(doBitmaps && !doScalable) { readFontScale(entries, dirname); @@ -862,7 +862,7 @@ doDirectory(char *dirname_given, int numEncodings, ListPtr encodingsToDo) isBitmap = 1; } } - + if(isBitmap) { if(!doBitmaps) goto done; @@ -933,7 +933,7 @@ doDirectory(char *dirname_given, int numEncodings, ListPtr encodingsToDo) putHash(entries, buf, entry->d_name, filePrio(entry->d_name)); } } - for(encoding = extra_encodings; encoding; + for(encoding = extra_encodings; encoding; encoding = encoding->next) { if(checkExtraEncoding(face, encoding->value, found)) { /* Do not set found! */ @@ -994,7 +994,7 @@ doDirectory(char *dirname_given, int numEncodings, ListPtr encodingsToDo) #define CODE_IGNORED(c) ((c) < 0x20 || \ ((c) >= 0x7F && (c) <= 0xA0) || \ (c) == 0xAD || (c) == 0xF71B) - + static int checkEncoding(FT_Face face, char *encoding_name) { @@ -1010,7 +1010,7 @@ checkEncoding(FT_Face face, char *encoding_name) /* An encoding is ``small'' if one of the following is true: - it is linear and has no more than 256 codepoints; or - it is a matrix encoding and has no more than one column. - + For small encodings using Unicode indices, we require perfect coverage except for CODE_IGNORED and KOI-8 IBM-PC compatibility. @@ -1025,8 +1025,8 @@ checkEncoding(FT_Face face, char *encoding_name) if(mapping->type == FONT_ENCODING_POSTSCRIPT) { if(encoding->row_size > 0) { for(i = encoding->first; i < encoding->size; i++) { - for(j = encoding->first_col; - j < encoding->row_size; + for(j = encoding->first_col; + j < encoding->row_size; j++) { n = FontEncName((i<<8) | j, mapping); if(n && FT_Get_Name_Index(face, n) == 0) { @@ -1052,12 +1052,12 @@ checkEncoding(FT_Face face, char *encoding_name) if(find_cmap(mapping->type, mapping->pid, mapping->eid, face)) { int total = 0, failed = 0; if(encoding->row_size > 0) { - int estimate = + int estimate = (encoding->size - encoding->first) * (encoding->row_size - encoding->first_col); for(i = encoding->first; i < encoding->size; i++) { - for(j = encoding->first_col; - j < encoding->row_size; + for(j = encoding->first_col; + j < encoding->row_size; j++) { c = FontEncRecode((i<<8) | j, mapping); if(CODE_IGNORED(c)) { @@ -1112,7 +1112,7 @@ checkEncoding(FT_Face face, char *encoding_name) return 0; } -static int +static int find_cmap(int type, int pid, int eid, FT_Face face) { int i, n, rc; @@ -1135,7 +1135,7 @@ find_cmap(int type, int pid, int eid, FT_Face face) /* prefer Microsoft Unicode */ for(i=0; i<n; i++) { cmap = face->charmaps[i]; - if(cmap->platform_id == TT_PLATFORM_MICROSOFT && + if(cmap->platform_id == TT_PLATFORM_MICROSOFT && cmap->encoding_id == TT_MS_ID_UNICODE_CS) { rc = FT_Set_Charmap(face, cmap); if(rc == 0) @@ -1209,8 +1209,8 @@ checkExtraEncoding(FT_Face face, char *encoding_name, int found) } } -static char* -notice_foundry(char *notice) +static const char* +notice_foundry(const char *notice) { int i; for(i = 0; i < countof(notice_foundries); i++) @@ -1220,7 +1220,7 @@ notice_foundry(char *notice) } static int -vendor_match(signed char *vendor, char *vendor_string) +vendor_match(const signed char *vendor, const char *vendor_string) { /* vendor is not necessarily NUL-terminated. */ int i, len; @@ -1233,8 +1233,8 @@ vendor_match(signed char *vendor, char *vendor_string) return 1; } -static char* -vendor_foundry(signed char *vendor) +static const char* +vendor_foundry(const signed char *vendor) { int i; for(i = 0; i < countof(vendor_foundries); i++) @@ -1267,7 +1267,7 @@ readEncodings(ListPtr encodings, char *dirname) closedir(dirp); return -1; } - + names = FontEncIdentify(fullname); if(!names) continue; @@ -1284,7 +1284,7 @@ readEncodings(ListPtr encodings, char *dirname) encodingsToDo = listConsF(encodingsToDo, "%s %s", *name, n); free(n); } else { - encodingsToDo = + encodingsToDo = listConsF(encodingsToDo, "%s %s", *name, fullname); } if(encodingsToDo == NULL) { diff --git a/pixman/configure.ac b/pixman/configure.ac index 6f5aef562..6c88c84f5 100644 --- a/pixman/configure.ac +++ b/pixman/configure.ac @@ -26,8 +26,8 @@ AC_PREREQ([2.57]) # # - The version in git has an odd MICRO version number # -# - Released versions both development and stable have an even MICRO -# version number +# - Released versions, both development and stable, have an +# even MICRO version number # # - Released development versions have an odd MINOR number # @@ -54,7 +54,7 @@ AC_PREREQ([2.57]) m4_define([pixman_major], 0) m4_define([pixman_minor], 23) -m4_define([pixman_micro], 5) +m4_define([pixman_micro], 7) m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro]) diff --git a/pixman/pixman/pixman-arm-neon-asm-bilinear.S b/pixman/pixman/pixman-arm-neon-asm-bilinear.S index 3c7fe0fea..f7913adb7 100644 --- a/pixman/pixman/pixman-arm-neon-asm-bilinear.S +++ b/pixman/pixman/pixman-arm-neon-asm-bilinear.S @@ -44,10 +44,6 @@ * All temp registers can be used freely outside the code block. * Assume that symbol(register .req) OUT and MASK are defined at caller of these macro blocks. * - * TODOs - * Support 0565 pixel format - * Optimization for two and last pixel cases - * * Remarks * There can be lots of pipeline stalls inside code block and between code blocks. * Further optimizations will be done by new macro templates using head/tail_head/tail scheme. @@ -92,21 +88,19 @@ fname: */ .macro bilinear_load_8888 reg1, reg2, tmp - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #2 - add TMP2, BOTTOM, TMP2, asl #2 - vld1.32 {reg1}, [TMP1] - vld1.32 {reg2}, [TMP2] + add TMP1, TOP, TMP1, asl #2 + vld1.32 {reg1}, [TMP1], STRIDE + vld1.32 {reg2}, [TMP1] .endm .macro bilinear_load_0565 reg1, reg2, tmp - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #1 - add TMP2, BOTTOM, TMP2, asl #1 - vld1.32 {reg2[0]}, [TMP1] - vld1.32 {reg2[1]}, [TMP2] + add TMP1, TOP, TMP1, asl #1 + vld1.32 {reg2[0]}, [TMP1], STRIDE + vld1.32 {reg2[1]}, [TMP1] convert_four_0565_to_x888_packed reg2, reg1, reg2, tmp .endm @@ -134,18 +128,16 @@ fname: .macro bilinear_load_and_vertical_interpolate_two_0565 \ acc1, acc2, reg1, reg2, reg3, reg4, acc2lo, acc2hi - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - mov TMP4, X, asr #16 + add TMP1, TOP, TMP1, asl #1 + mov TMP2, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #1 - add TMP2, BOTTOM, TMP2, asl #1 - add TMP3, TOP, TMP4, asl #1 - add TMP4, BOTTOM, TMP4, asl #1 - vld1.32 {acc2lo[0]}, [TMP1] - vld1.32 {acc2hi[0]}, [TMP3] - vld1.32 {acc2lo[1]}, [TMP2] - vld1.32 {acc2hi[1]}, [TMP4] + add TMP2, TOP, TMP2, asl #1 + vld1.32 {acc2lo[0]}, [TMP1], STRIDE + vld1.32 {acc2hi[0]}, [TMP2], STRIDE + vld1.32 {acc2lo[1]}, [TMP1] + vld1.32 {acc2hi[1]}, [TMP2] convert_0565_to_x888 acc2, reg3, reg2, reg1 vzip.u8 reg1, reg3 vzip.u8 reg2, reg4 @@ -161,34 +153,30 @@ fname: xacc1, xacc2, xreg1, xreg2, xreg3, xreg4, xacc2lo, xacc2hi \ yacc1, yacc2, yreg1, yreg2, yreg3, yreg4, yacc2lo, yacc2hi - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - mov TMP4, X, asr #16 + add TMP1, TOP, TMP1, asl #1 + mov TMP2, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #1 - add TMP2, BOTTOM, TMP2, asl #1 - add TMP3, TOP, TMP4, asl #1 - add TMP4, BOTTOM, TMP4, asl #1 - vld1.32 {xacc2lo[0]}, [TMP1] - vld1.32 {xacc2hi[0]}, [TMP3] - vld1.32 {xacc2lo[1]}, [TMP2] - vld1.32 {xacc2hi[1]}, [TMP4] + add TMP2, TOP, TMP2, asl #1 + vld1.32 {xacc2lo[0]}, [TMP1], STRIDE + vld1.32 {xacc2hi[0]}, [TMP2], STRIDE + vld1.32 {xacc2lo[1]}, [TMP1] + vld1.32 {xacc2hi[1]}, [TMP2] convert_0565_to_x888 xacc2, xreg3, xreg2, xreg1 - mov TMP2, X, asr #16 + mov TMP1, X, asr #16 add X, X, UX - mov TMP4, X, asr #16 + add TMP1, TOP, TMP1, asl #1 + mov TMP2, X, asr #16 add X, X, UX - add TMP1, TOP, TMP2, asl #1 - add TMP2, BOTTOM, TMP2, asl #1 - add TMP3, TOP, TMP4, asl #1 - add TMP4, BOTTOM, TMP4, asl #1 - vld1.32 {yacc2lo[0]}, [TMP1] + add TMP2, TOP, TMP2, asl #1 + vld1.32 {yacc2lo[0]}, [TMP1], STRIDE vzip.u8 xreg1, xreg3 - vld1.32 {yacc2hi[0]}, [TMP3] + vld1.32 {yacc2hi[0]}, [TMP2], STRIDE vzip.u8 xreg2, xreg4 - vld1.32 {yacc2lo[1]}, [TMP2] + vld1.32 {yacc2lo[1]}, [TMP1] vzip.u8 xreg3, xreg4 - vld1.32 {yacc2hi[1]}, [TMP4] + vld1.32 {yacc2hi[1]}, [TMP2] vzip.u8 xreg1, xreg2 convert_0565_to_x888 yacc2, yreg3, yreg2, yreg1 vmull.u8 xacc1, xreg1, d28 @@ -252,6 +240,7 @@ fname: .else .error bilinear_load_mask_8 numpix is unsupported .endif + pld [MASK, #prefetch_offset] .endm .macro bilinear_load_mask mask_fmt, numpix, mask @@ -279,6 +268,7 @@ fname: .else .error bilinear_load_dst_8888 numpix is unsupported .endif + pld [OUT, #(prefetch_offset * 4)] .endm .macro bilinear_load_dst_8888_over numpix, dst0, dst1, dst01 @@ -303,7 +293,7 @@ fname: * For two pixel case * (r0, r1, x, x, g0, g1, x, x) x (m0, m1, m0, m1, m0, m1, m0, m1) * (b0, b1, x, x, a0, a1, x, x) x (m0, m1, m0, m1, m0, m1, m0, m1) - * We can do some optimizations for this including one pixel cases. + * We can do some optimizations for this including last pixel cases. */ .macro bilinear_duplicate_mask_x numpix, mask .endm @@ -497,8 +487,7 @@ fname: bilinear_load_dst dst_fmt, op, 1, d18, d19, q9 vmull.u8 q1, d0, d28 vmlal.u8 q1, d1, d29 - vshr.u16 d30, d24, #8 - /* 4 cycles bubble */ + /* 5 cycles bubble */ vshll.u16 q0, d2, #8 vmlsl.u16 q0, d2, d30 vmlal.u16 q0, d3, d30 @@ -525,18 +514,18 @@ fname: q1, q11, d0, d1, d20, d21, d22, d23 bilinear_load_mask mask_fmt, 2, d4 bilinear_load_dst dst_fmt, op, 2, d18, d19, q9 - vshr.u16 q15, q12, #8 - vadd.u16 q12, q12, q13 vshll.u16 q0, d2, #8 vmlsl.u16 q0, d2, d30 vmlal.u16 q0, d3, d30 vshll.u16 q10, d22, #8 vmlsl.u16 q10, d22, d31 vmlal.u16 q10, d23, d31 - vshrn.u32 d30, q0, #16 - vshrn.u32 d31, q10, #16 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q10, #16 bilinear_duplicate_mask mask_fmt, 2, d4 - vmovn.u16 d0, q15 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + vmovn.u16 d0, q0 bilinear_interleave_src_dst \ mask_fmt, op, 2, d0, d1, q0, d18, d19, q9 bilinear_apply_mask_to_src \ @@ -554,8 +543,7 @@ fname: q1, q11, d0, d1, d20, d21, d22, d23 \ q3, q9, d4, d5, d16, d17, d18, d19 pld [TMP1, PF_OFFS] - vshr.u16 q15, q12, #8 - vadd.u16 q12, q12, q13 + sub TMP1, TMP1, STRIDE vshll.u16 q0, d2, #8 vmlsl.u16 q0, d2, d30 vmlal.u16 q0, d3, d30 @@ -567,9 +555,9 @@ fname: vmlsl.u16 q2, d6, d30 vmlal.u16 q2, d7, d30 vshll.u16 q8, d18, #8 - bilinear_load_mask mask_fmt, 4, d30 + bilinear_load_mask mask_fmt, 4, d22 bilinear_load_dst dst_fmt, op, 4, d2, d3, q1 - pld [TMP2, PF_OFFS] + pld [TMP1, PF_OFFS] vmlsl.u16 q8, d18, d31 vmlal.u16 q8, d19, d31 vadd.u16 q12, q12, q13 @@ -577,97 +565,88 @@ fname: vshrn.u32 d1, q10, #16 vshrn.u32 d4, q2, #16 vshrn.u32 d5, q8, #16 - bilinear_duplicate_mask mask_fmt, 4, d30 + bilinear_duplicate_mask mask_fmt, 4, d22 + vshr.u16 q15, q12, #8 vmovn.u16 d0, q0 vmovn.u16 d1, q2 + vadd.u16 q12, q12, q13 bilinear_interleave_src_dst \ mask_fmt, op, 4, d0, d1, q0, d2, d3, q1 bilinear_apply_mask_to_src \ - mask_fmt, 4, d0, d1, q0, d30, \ + mask_fmt, 4, d0, d1, q0, d22, \ q3, q8, q9, q10 bilinear_combine \ op, 4, d0, d1, q0, d2, d3, q1, \ - q3, q8, q9, q10, d22 + q3, q8, q9, q10, d23 bilinear_deinterleave_dst mask_fmt, op, 4, d0, d1, q0 bilinear_store_&dst_fmt 4, q2, q3 .endm -.macro generate_bilinear_scanline_func_src_dst \ - fname, src_fmt, dst_fmt, op, \ - bpp_shift, prefetch_distance - -pixman_asm_function fname - OUT .req r0 - TOP .req r1 - BOTTOM .req r2 - WT .req r3 - WB .req r4 - X .req r5 - UX .req r6 - WIDTH .req ip - TMP1 .req r3 - TMP2 .req r4 - PF_OFFS .req r7 - TMP3 .req r8 - TMP4 .req r9 - - mov ip, sp - push {r4, r5, r6, r7, r8, r9} - mov PF_OFFS, #prefetch_distance - ldmia ip, {WB, X, UX, WIDTH} - mul PF_OFFS, PF_OFFS, UX - - cmp WIDTH, #0 - ble 3f - - vdup.u16 q12, X - vdup.u16 q13, UX - vdup.u8 d28, WT - vdup.u8 d29, WB - vadd.u16 d25, d25, d26 - vadd.u16 q13, q13, q13 - - subs WIDTH, WIDTH, #4 - blt 1f - mov PF_OFFS, PF_OFFS, asr #(16 - bpp_shift) -0: - bilinear_interpolate_four_pixels src_fmt, x, dst_fmt, op - subs WIDTH, WIDTH, #4 - bge 0b -1: - tst WIDTH, #2 - beq 2f - bilinear_interpolate_two_pixels src_fmt, x, dst_fmt, op -2: - tst WIDTH, #1 - beq 3f - bilinear_interpolate_last_pixel src_fmt, x, dst_fmt, op -3: - pop {r4, r5, r6, r7, r8, r9} - bx lr +.set BILINEAR_FLAG_USE_MASK, 1 +.set BILINEAR_FLAG_USE_ALL_NEON_REGS, 2 - .unreq OUT - .unreq TOP - .unreq BOTTOM - .unreq WT - .unreq WB - .unreq X - .unreq UX - .unreq WIDTH - .unreq TMP1 - .unreq TMP2 - .unreq PF_OFFS - .unreq TMP3 - .unreq TMP4 -.endfunc - -.endm +/* + * Main template macro for generating NEON optimized bilinear scanline functions. + * + * Bilinear scanline generator macro take folling arguments: + * fname - name of the function to generate + * src_fmt - source color format (8888 or 0565) + * dst_fmt - destination color format (8888 or 0565) + * src/dst_bpp_shift - (1 << bpp_shift) is the size of src/dst pixel in bytes + * process_last_pixel - code block that interpolate one pixel and does not + * update horizontal weight + * process_two_pixels - code block that interpolate two pixels and update + * horizontal weight + * process_four_pixels - code block that interpolate four pixels and update + * horizontal weight + * process_pixblock_head - head part of middle loop + * process_pixblock_tail - tail part of middle loop + * process_pixblock_tail_head - tail_head of middle loop + * pixblock_size - number of pixels processed in a single middle loop + * prefetch_distance - prefetch in the source image by that many pixels ahead + */ -.macro generate_bilinear_scanline_func_src_a8_dst \ - fname, src_fmt, dst_fmt, op, \ - bpp_shift, prefetch_distance +.macro generate_bilinear_scanline_func \ + fname, \ + src_fmt, dst_fmt, src_bpp_shift, dst_bpp_shift, \ + bilinear_process_last_pixel, \ + bilinear_process_two_pixels, \ + bilinear_process_four_pixels, \ + bilinear_process_pixblock_head, \ + bilinear_process_pixblock_tail, \ + bilinear_process_pixblock_tail_head, \ + pixblock_size, \ + prefetch_distance, \ + flags pixman_asm_function fname +.if pixblock_size == 8 +.elseif pixblock_size == 4 +.else + .error unsupported pixblock size +.endif + +.if ((flags) & BILINEAR_FLAG_USE_MASK) == 0 + OUT .req r0 + TOP .req r1 + BOTTOM .req r2 + WT .req r3 + WB .req r4 + X .req r5 + UX .req r6 + WIDTH .req ip + TMP1 .req r3 + TMP2 .req r4 + PF_OFFS .req r7 + TMP3 .req r8 + TMP4 .req r9 + STRIDE .req r2 + + mov ip, sp + push {r4, r5, r6, r7, r8, r9} + mov PF_OFFS, #prefetch_distance + ldmia ip, {WB, X, UX, WIDTH} +.else OUT .req r0 MASK .req r1 TOP .req r2 @@ -682,13 +661,25 @@ pixman_asm_function fname PF_OFFS .req r8 TMP3 .req r9 TMP4 .req r10 + STRIDE .req r3 + + .set prefetch_offset, prefetch_distance mov ip, sp push {r4, r5, r6, r7, r8, r9, r10, ip} mov PF_OFFS, #prefetch_distance ldmia ip, {WT, WB, X, UX, WIDTH} +.endif + mul PF_OFFS, PF_OFFS, UX +.if ((flags) & BILINEAR_FLAG_USE_ALL_NEON_REGS) != 0 + vpush {d8-d15} +.endif + + sub STRIDE, BOTTOM, TOP + .unreq BOTTOM + cmp WIDTH, #0 ble 3f @@ -697,73 +688,680 @@ pixman_asm_function fname vdup.u8 d28, WT vdup.u8 d29, WB vadd.u16 d25, d25, d26 + + /* ensure good destination alignment */ + cmp WIDTH, #1 + blt 0f + tst OUT, #(1 << dst_bpp_shift) + beq 0f + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + bilinear_process_last_pixel + sub WIDTH, WIDTH, #1 +0: vadd.u16 q13, q13, q13 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 - subs WIDTH, WIDTH, #4 + cmp WIDTH, #2 + blt 0f + tst OUT, #(1 << (dst_bpp_shift + 1)) + beq 0f + bilinear_process_two_pixels + sub WIDTH, WIDTH, #2 +0: +.if pixblock_size == 8 + cmp WIDTH, #4 + blt 0f + tst OUT, #(1 << (dst_bpp_shift + 2)) + beq 0f + bilinear_process_four_pixels + sub WIDTH, WIDTH, #4 +0: +.endif + subs WIDTH, WIDTH, #pixblock_size blt 1f - mov PF_OFFS, PF_OFFS, asr #(16 - bpp_shift) + mov PF_OFFS, PF_OFFS, asr #(16 - src_bpp_shift) + bilinear_process_pixblock_head + subs WIDTH, WIDTH, #pixblock_size + blt 5f 0: - bilinear_interpolate_four_pixels src_fmt, 8, dst_fmt, op - subs WIDTH, WIDTH, #4 + bilinear_process_pixblock_tail_head + subs WIDTH, WIDTH, #pixblock_size bge 0b +5: + bilinear_process_pixblock_tail 1: +.if pixblock_size == 8 + tst WIDTH, #4 + beq 2f + bilinear_process_four_pixels +2: +.endif + /* handle the remaining trailing pixels */ tst WIDTH, #2 beq 2f - bilinear_interpolate_two_pixels src_fmt, 8, dst_fmt, op + bilinear_process_two_pixels 2: tst WIDTH, #1 beq 3f - bilinear_interpolate_last_pixel src_fmt, 8, dst_fmt, op + bilinear_process_last_pixel 3: +.if ((flags) & BILINEAR_FLAG_USE_ALL_NEON_REGS) != 0 + vpop {d8-d15} +.endif + +.if ((flags) & BILINEAR_FLAG_USE_MASK) == 0 + pop {r4, r5, r6, r7, r8, r9} +.else pop {r4, r5, r6, r7, r8, r9, r10, ip} +.endif bx lr .unreq OUT .unreq TOP - .unreq BOTTOM .unreq WT .unreq WB .unreq X .unreq UX .unreq WIDTH - .unreq MASK .unreq TMP1 .unreq TMP2 .unreq PF_OFFS .unreq TMP3 .unreq TMP4 + .unreq STRIDE +.if ((flags) & BILINEAR_FLAG_USE_MASK) != 0 + .unreq MASK +.endif + .endfunc .endm -generate_bilinear_scanline_func_src_dst \ - pixman_scaled_bilinear_scanline_8888_8888_OVER_asm_neon, \ - 8888, 8888, over, 2, 28 +/* src_8888_8_8888 */ +.macro bilinear_src_8888_8_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, 8, 8888, src +.endm -generate_bilinear_scanline_func_src_dst \ - pixman_scaled_bilinear_scanline_8888_8888_ADD_asm_neon, \ - 8888, 8888, add, 2, 28 +.macro bilinear_src_8888_8_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, 8, 8888, src +.endm -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_8888_8_8888_SRC_asm_neon, \ - 8888, 8888, src, 2, 28 +.macro bilinear_src_8888_8_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, 8, 8888, src +.endm -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_8888_8_0565_SRC_asm_neon, \ - 8888, 0565, src, 2, 28 +.macro bilinear_src_8888_8_8888_process_pixblock_head + bilinear_src_8888_8_8888_process_four_pixels +.endm -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_0565_8_x888_SRC_asm_neon, \ - 0565, 8888, src, 1, 28 +.macro bilinear_src_8888_8_8888_process_pixblock_tail +.endm -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_0565_8_0565_SRC_asm_neon, \ - 0565, 0565, src, 1, 28 +.macro bilinear_src_8888_8_8888_process_pixblock_tail_head + bilinear_src_8888_8_8888_process_pixblock_tail + bilinear_src_8888_8_8888_process_pixblock_head +.endm -generate_bilinear_scanline_func_src_a8_dst \ - pixman_scaled_bilinear_scanline_8888_8_8888_OVER_asm_neon, \ - 8888, 8888, over, 2, 28 +/* src_8888_8_0565 */ +.macro bilinear_src_8888_8_0565_process_last_pixel + bilinear_interpolate_last_pixel 8888, 8, 0565, src +.endm + +.macro bilinear_src_8888_8_0565_process_two_pixels + bilinear_interpolate_two_pixels 8888, 8, 0565, src +.endm + +.macro bilinear_src_8888_8_0565_process_four_pixels + bilinear_interpolate_four_pixels 8888, 8, 0565, src +.endm + +.macro bilinear_src_8888_8_0565_process_pixblock_head + bilinear_src_8888_8_0565_process_four_pixels +.endm + +.macro bilinear_src_8888_8_0565_process_pixblock_tail +.endm + +.macro bilinear_src_8888_8_0565_process_pixblock_tail_head + bilinear_src_8888_8_0565_process_pixblock_tail + bilinear_src_8888_8_0565_process_pixblock_head +.endm + +/* src_0565_8_x888 */ +.macro bilinear_src_0565_8_x888_process_last_pixel + bilinear_interpolate_last_pixel 0565, 8, 8888, src +.endm + +.macro bilinear_src_0565_8_x888_process_two_pixels + bilinear_interpolate_two_pixels 0565, 8, 8888, src +.endm + +.macro bilinear_src_0565_8_x888_process_four_pixels + bilinear_interpolate_four_pixels 0565, 8, 8888, src +.endm + +.macro bilinear_src_0565_8_x888_process_pixblock_head + bilinear_src_0565_8_x888_process_four_pixels +.endm + +.macro bilinear_src_0565_8_x888_process_pixblock_tail +.endm + +.macro bilinear_src_0565_8_x888_process_pixblock_tail_head + bilinear_src_0565_8_x888_process_pixblock_tail + bilinear_src_0565_8_x888_process_pixblock_head +.endm + +/* src_0565_8_0565 */ +.macro bilinear_src_0565_8_0565_process_last_pixel + bilinear_interpolate_last_pixel 0565, 8, 0565, src +.endm + +.macro bilinear_src_0565_8_0565_process_two_pixels + bilinear_interpolate_two_pixels 0565, 8, 0565, src +.endm + +.macro bilinear_src_0565_8_0565_process_four_pixels + bilinear_interpolate_four_pixels 0565, 8, 0565, src +.endm + +.macro bilinear_src_0565_8_0565_process_pixblock_head + bilinear_src_0565_8_0565_process_four_pixels +.endm + +.macro bilinear_src_0565_8_0565_process_pixblock_tail +.endm + +.macro bilinear_src_0565_8_0565_process_pixblock_tail_head + bilinear_src_0565_8_0565_process_pixblock_tail + bilinear_src_0565_8_0565_process_pixblock_head +.endm + +/* over_8888_8888 */ +.macro bilinear_over_8888_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, x, 8888, over +.endm + +.macro bilinear_over_8888_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, x, 8888, over +.endm -generate_bilinear_scanline_func_src_a8_dst \ +.macro bilinear_over_8888_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, x, 8888, over +.endm + +.macro bilinear_over_8888_8888_process_pixblock_head + mov TMP1, X, asr #16 + add X, X, UX + add TMP1, TOP, TMP1, asl #2 + mov TMP2, X, asr #16 + add X, X, UX + add TMP2, TOP, TMP2, asl #2 + + vld1.32 {d22}, [TMP1], STRIDE + vld1.32 {d23}, [TMP1] + mov TMP3, X, asr #16 + add X, X, UX + add TMP3, TOP, TMP3, asl #2 + vmull.u8 q8, d22, d28 + vmlal.u8 q8, d23, d29 + + vld1.32 {d22}, [TMP2], STRIDE + vld1.32 {d23}, [TMP2] + mov TMP4, X, asr #16 + add X, X, UX + add TMP4, TOP, TMP4, asl #2 + vmull.u8 q9, d22, d28 + vmlal.u8 q9, d23, d29 + + vld1.32 {d22}, [TMP3], STRIDE + vld1.32 {d23}, [TMP3] + vmull.u8 q10, d22, d28 + vmlal.u8 q10, d23, d29 + + vshll.u16 q0, d16, #8 + vmlsl.u16 q0, d16, d30 + vmlal.u16 q0, d17, d30 + + pld [TMP4, PF_OFFS] + vld1.32 {d16}, [TMP4], STRIDE + vld1.32 {d17}, [TMP4] + pld [TMP4, PF_OFFS] + vmull.u8 q11, d16, d28 + vmlal.u8 q11, d17, d29 + + vshll.u16 q1, d18, #8 + vmlsl.u16 q1, d18, d31 + vmlal.u16 q1, d19, d31 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 +.endm + +.macro bilinear_over_8888_8888_process_pixblock_tail + vshll.u16 q2, d20, #8 + vmlsl.u16 q2, d20, d30 + vmlal.u16 q2, d21, d30 + vshll.u16 q3, d22, #8 + vmlsl.u16 q3, d22, d31 + vmlal.u16 q3, d23, d31 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q1, #16 + vld1.32 {d2, d3}, [OUT, :128] + pld [OUT, #(prefetch_offset * 4)] + vshrn.u32 d4, q2, #16 + vshr.u16 q15, q12, #8 + vshrn.u32 d5, q3, #16 + vmovn.u16 d6, q0 + vmovn.u16 d7, q2 + vuzp.8 d6, d7 + vuzp.8 d2, d3 + vuzp.8 d6, d7 + vuzp.8 d2, d3 + vdup.32 d4, d7[1] + vmvn.8 d4, d4 + vmull.u8 q11, d2, d4 + vmull.u8 q2, d3, d4 + vrshr.u16 q1, q11, #8 + vrshr.u16 q10, q2, #8 + vraddhn.u16 d2, q1, q11 + vraddhn.u16 d3, q10, q2 + vqadd.u8 q3, q1, q3 + vuzp.8 d6, d7 + vuzp.8 d6, d7 + vadd.u16 q12, q12, q13 + vst1.32 {d6, d7}, [OUT, :128]! +.endm + +.macro bilinear_over_8888_8888_process_pixblock_tail_head + vshll.u16 q2, d20, #8 + mov TMP1, X, asr #16 + add X, X, UX + add TMP1, TOP, TMP1, asl #2 + vmlsl.u16 q2, d20, d30 + mov TMP2, X, asr #16 + add X, X, UX + add TMP2, TOP, TMP2, asl #2 + vmlal.u16 q2, d21, d30 + vshll.u16 q3, d22, #8 + vld1.32 {d20}, [TMP1], STRIDE + vmlsl.u16 q3, d22, d31 + vmlal.u16 q3, d23, d31 + vld1.32 {d21}, [TMP1] + vmull.u8 q8, d20, d28 + vmlal.u8 q8, d21, d29 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q1, #16 + vld1.32 {d2, d3}, [OUT, :128] + pld [OUT, PF_OFFS] + vshrn.u32 d4, q2, #16 + vshr.u16 q15, q12, #8 + vld1.32 {d22}, [TMP2], STRIDE + vshrn.u32 d5, q3, #16 + vmovn.u16 d6, q0 + vld1.32 {d23}, [TMP2] + vmull.u8 q9, d22, d28 + mov TMP3, X, asr #16 + add X, X, UX + add TMP3, TOP, TMP3, asl #2 + mov TMP4, X, asr #16 + add X, X, UX + add TMP4, TOP, TMP4, asl #2 + vmlal.u8 q9, d23, d29 + vmovn.u16 d7, q2 + vld1.32 {d22}, [TMP3], STRIDE + vuzp.8 d6, d7 + vuzp.8 d2, d3 + vuzp.8 d6, d7 + vuzp.8 d2, d3 + vdup.32 d4, d7[1] + vld1.32 {d23}, [TMP3] + vmvn.8 d4, d4 + vmull.u8 q10, d22, d28 + vmlal.u8 q10, d23, d29 + vmull.u8 q11, d2, d4 + vmull.u8 q2, d3, d4 + vshll.u16 q0, d16, #8 + vmlsl.u16 q0, d16, d30 + vrshr.u16 q1, q11, #8 + vmlal.u16 q0, d17, d30 + vrshr.u16 q8, q2, #8 + vraddhn.u16 d2, q1, q11 + vraddhn.u16 d3, q8, q2 + pld [TMP4, PF_OFFS] + vld1.32 {d16}, [TMP4], STRIDE + vqadd.u8 q3, q1, q3 + vld1.32 {d17}, [TMP4] + pld [TMP4, PF_OFFS] + vmull.u8 q11, d16, d28 + vmlal.u8 q11, d17, d29 + vuzp.8 d6, d7 + vshll.u16 q1, d18, #8 + vuzp.8 d6, d7 + vmlsl.u16 q1, d18, d31 + vadd.u16 q12, q12, q13 + vmlal.u16 q1, d19, d31 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + vst1.32 {d6, d7}, [OUT, :128]! +.endm + +/* over_8888_8_8888 */ +.macro bilinear_over_8888_8_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, 8, 8888, over +.endm + +.macro bilinear_over_8888_8_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, 8, 8888, over +.endm + +.macro bilinear_over_8888_8_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, 8, 8888, over +.endm + +.macro bilinear_over_8888_8_8888_process_pixblock_head + mov TMP1, X, asr #16 + add X, X, UX + add TMP1, TOP, TMP1, asl #2 + vld1.32 {d0}, [TMP1], STRIDE + mov TMP2, X, asr #16 + add X, X, UX + add TMP2, TOP, TMP2, asl #2 + vld1.32 {d1}, [TMP1] + mov TMP3, X, asr #16 + add X, X, UX + add TMP3, TOP, TMP3, asl #2 + vld1.32 {d2}, [TMP2], STRIDE + mov TMP4, X, asr #16 + add X, X, UX + add TMP4, TOP, TMP4, asl #2 + vld1.32 {d3}, [TMP2] + vmull.u8 q2, d0, d28 + vmull.u8 q3, d2, d28 + vmlal.u8 q2, d1, d29 + vmlal.u8 q3, d3, d29 + vshll.u16 q0, d4, #8 + vshll.u16 q1, d6, #8 + vmlsl.u16 q0, d4, d30 + vmlsl.u16 q1, d6, d31 + vmlal.u16 q0, d5, d30 + vmlal.u16 q1, d7, d31 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q1, #16 + vld1.32 {d2}, [TMP3], STRIDE + vld1.32 {d3}, [TMP3] + pld [TMP4, PF_OFFS] + vld1.32 {d4}, [TMP4], STRIDE + vld1.32 {d5}, [TMP4] + pld [TMP4, PF_OFFS] + vmull.u8 q3, d2, d28 + vmlal.u8 q3, d3, d29 + vmull.u8 q1, d4, d28 + vmlal.u8 q1, d5, d29 + vshr.u16 q15, q12, #8 + vld1.32 {d22[0]}, [MASK]! + pld [MASK, #prefetch_offset] + vadd.u16 q12, q12, q13 + vmovn.u16 d16, q0 +.endm + +.macro bilinear_over_8888_8_8888_process_pixblock_tail + vshll.u16 q9, d6, #8 + vshll.u16 q10, d2, #8 + vmlsl.u16 q9, d6, d30 + vmlsl.u16 q10, d2, d31 + vmlal.u16 q9, d7, d30 + vmlal.u16 q10, d3, d31 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + vdup.32 d22, d22[0] + vshrn.u32 d18, q9, #16 + vshrn.u32 d19, q10, #16 + vmovn.u16 d17, q9 + vld1.32 {d18, d19}, [OUT, :128] + pld [OUT, PF_OFFS] + vuzp.8 d16, d17 + vuzp.8 d18, d19 + vuzp.8 d16, d17 + vuzp.8 d18, d19 + vmull.u8 q10, d16, d22 + vmull.u8 q11, d17, d22 + vrsra.u16 q10, q10, #8 + vrsra.u16 q11, q11, #8 + vrshrn.u16 d16, q10, #8 + vrshrn.u16 d17, q11, #8 + vdup.32 d22, d17[1] + vmvn.8 d22, d22 + vmull.u8 q10, d18, d22 + vmull.u8 q11, d19, d22 + vrshr.u16 q9, q10, #8 + vrshr.u16 q0, q11, #8 + vraddhn.u16 d18, q9, q10 + vraddhn.u16 d19, q0, q11 + vqadd.u8 q9, q8, q9 + vuzp.8 d18, d19 + vuzp.8 d18, d19 + vst1.32 {d18, d19}, [OUT, :128]! +.endm + +.macro bilinear_over_8888_8_8888_process_pixblock_tail_head + vshll.u16 q9, d6, #8 + mov TMP1, X, asr #16 + add X, X, UX + add TMP1, TOP, TMP1, asl #2 + vshll.u16 q10, d2, #8 + vld1.32 {d0}, [TMP1], STRIDE + mov TMP2, X, asr #16 + add X, X, UX + add TMP2, TOP, TMP2, asl #2 + vmlsl.u16 q9, d6, d30 + vmlsl.u16 q10, d2, d31 + vld1.32 {d1}, [TMP1] + mov TMP3, X, asr #16 + add X, X, UX + add TMP3, TOP, TMP3, asl #2 + vmlal.u16 q9, d7, d30 + vmlal.u16 q10, d3, d31 + vld1.32 {d2}, [TMP2], STRIDE + mov TMP4, X, asr #16 + add X, X, UX + add TMP4, TOP, TMP4, asl #2 + vshr.u16 q15, q12, #8 + vadd.u16 q12, q12, q13 + vld1.32 {d3}, [TMP2] + vdup.32 d22, d22[0] + vshrn.u32 d18, q9, #16 + vshrn.u32 d19, q10, #16 + vmull.u8 q2, d0, d28 + vmull.u8 q3, d2, d28 + vmovn.u16 d17, q9 + vld1.32 {d18, d19}, [OUT, :128] + pld [OUT, #(prefetch_offset * 4)] + vmlal.u8 q2, d1, d29 + vmlal.u8 q3, d3, d29 + vuzp.8 d16, d17 + vuzp.8 d18, d19 + vshll.u16 q0, d4, #8 + vshll.u16 q1, d6, #8 + vuzp.8 d16, d17 + vuzp.8 d18, d19 + vmlsl.u16 q0, d4, d30 + vmlsl.u16 q1, d6, d31 + vmull.u8 q10, d16, d22 + vmull.u8 q11, d17, d22 + vmlal.u16 q0, d5, d30 + vmlal.u16 q1, d7, d31 + vrsra.u16 q10, q10, #8 + vrsra.u16 q11, q11, #8 + vshrn.u32 d0, q0, #16 + vshrn.u32 d1, q1, #16 + vrshrn.u16 d16, q10, #8 + vrshrn.u16 d17, q11, #8 + vld1.32 {d2}, [TMP3], STRIDE + vdup.32 d22, d17[1] + vld1.32 {d3}, [TMP3] + vmvn.8 d22, d22 + pld [TMP4, PF_OFFS] + vld1.32 {d4}, [TMP4], STRIDE + vmull.u8 q10, d18, d22 + vmull.u8 q11, d19, d22 + vld1.32 {d5}, [TMP4] + pld [TMP4, PF_OFFS] + vmull.u8 q3, d2, d28 + vrshr.u16 q9, q10, #8 + vrshr.u16 q15, q11, #8 + vmlal.u8 q3, d3, d29 + vmull.u8 q1, d4, d28 + vraddhn.u16 d18, q9, q10 + vraddhn.u16 d19, q15, q11 + vmlal.u8 q1, d5, d29 + vshr.u16 q15, q12, #8 + vqadd.u8 q9, q8, q9 + vld1.32 {d22[0]}, [MASK]! + vuzp.8 d18, d19 + vadd.u16 q12, q12, q13 + vuzp.8 d18, d19 + vmovn.u16 d16, q0 + vst1.32 {d18, d19}, [OUT, :128]! +.endm + +/* add_8888_8888 */ +.macro bilinear_add_8888_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, x, 8888, add +.endm + +.macro bilinear_add_8888_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, x, 8888, add +.endm + +.macro bilinear_add_8888_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, x, 8888, add +.endm + +.macro bilinear_add_8888_8888_process_pixblock_head + bilinear_add_8888_8888_process_four_pixels +.endm + +.macro bilinear_add_8888_8888_process_pixblock_tail +.endm + +.macro bilinear_add_8888_8888_process_pixblock_tail_head + bilinear_add_8888_8888_process_pixblock_tail + bilinear_add_8888_8888_process_pixblock_head +.endm + +/* add_8888_8_8888 */ +.macro bilinear_add_8888_8_8888_process_last_pixel + bilinear_interpolate_last_pixel 8888, 8, 8888, add +.endm + +.macro bilinear_add_8888_8_8888_process_two_pixels + bilinear_interpolate_two_pixels 8888, 8, 8888, add +.endm + +.macro bilinear_add_8888_8_8888_process_four_pixels + bilinear_interpolate_four_pixels 8888, 8, 8888, add +.endm + +.macro bilinear_add_8888_8_8888_process_pixblock_head + bilinear_add_8888_8_8888_process_four_pixels +.endm + +.macro bilinear_add_8888_8_8888_process_pixblock_tail +.endm + +.macro bilinear_add_8888_8_8888_process_pixblock_tail_head + bilinear_add_8888_8_8888_process_pixblock_tail + bilinear_add_8888_8_8888_process_pixblock_head +.endm + + +/* Bilinear scanline functions */ +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8_8888_SRC_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_src_8888_8_8888_process_last_pixel, \ + bilinear_src_8888_8_8888_process_two_pixels, \ + bilinear_src_8888_8_8888_process_four_pixels, \ + bilinear_src_8888_8_8888_process_pixblock_head, \ + bilinear_src_8888_8_8888_process_pixblock_tail, \ + bilinear_src_8888_8_8888_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8_0565_SRC_asm_neon, \ + 8888, 0565, 2, 1, \ + bilinear_src_8888_8_0565_process_last_pixel, \ + bilinear_src_8888_8_0565_process_two_pixels, \ + bilinear_src_8888_8_0565_process_four_pixels, \ + bilinear_src_8888_8_0565_process_pixblock_head, \ + bilinear_src_8888_8_0565_process_pixblock_tail, \ + bilinear_src_8888_8_0565_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_0565_8_x888_SRC_asm_neon, \ + 0565, 8888, 1, 2, \ + bilinear_src_0565_8_x888_process_last_pixel, \ + bilinear_src_0565_8_x888_process_two_pixels, \ + bilinear_src_0565_8_x888_process_four_pixels, \ + bilinear_src_0565_8_x888_process_pixblock_head, \ + bilinear_src_0565_8_x888_process_pixblock_tail, \ + bilinear_src_0565_8_x888_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_0565_8_0565_SRC_asm_neon, \ + 0565, 0565, 1, 1, \ + bilinear_src_0565_8_0565_process_last_pixel, \ + bilinear_src_0565_8_0565_process_two_pixels, \ + bilinear_src_0565_8_0565_process_four_pixels, \ + bilinear_src_0565_8_0565_process_pixblock_head, \ + bilinear_src_0565_8_0565_process_pixblock_tail, \ + bilinear_src_0565_8_0565_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8888_OVER_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_over_8888_8888_process_last_pixel, \ + bilinear_over_8888_8888_process_two_pixels, \ + bilinear_over_8888_8888_process_four_pixels, \ + bilinear_over_8888_8888_process_pixblock_head, \ + bilinear_over_8888_8888_process_pixblock_tail, \ + bilinear_over_8888_8888_process_pixblock_tail_head, \ + 4, 28, 0 + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8_8888_OVER_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_over_8888_8_8888_process_last_pixel, \ + bilinear_over_8888_8_8888_process_two_pixels, \ + bilinear_over_8888_8_8888_process_four_pixels, \ + bilinear_over_8888_8_8888_process_pixblock_head, \ + bilinear_over_8888_8_8888_process_pixblock_tail, \ + bilinear_over_8888_8_8888_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK + +generate_bilinear_scanline_func \ + pixman_scaled_bilinear_scanline_8888_8888_ADD_asm_neon, \ + 8888, 8888, 2, 2, \ + bilinear_add_8888_8888_process_last_pixel, \ + bilinear_add_8888_8888_process_two_pixels, \ + bilinear_add_8888_8888_process_four_pixels, \ + bilinear_add_8888_8888_process_pixblock_head, \ + bilinear_add_8888_8888_process_pixblock_tail, \ + bilinear_add_8888_8888_process_pixblock_tail_head, \ + 4, 28, 0 + +generate_bilinear_scanline_func \ pixman_scaled_bilinear_scanline_8888_8_8888_ADD_asm_neon, \ - 8888, 8888, add, 2, 28 + 8888, 8888, 2, 2, \ + bilinear_add_8888_8_8888_process_last_pixel, \ + bilinear_add_8888_8_8888_process_two_pixels, \ + bilinear_add_8888_8_8888_process_four_pixels, \ + bilinear_add_8888_8_8888_process_pixblock_head, \ + bilinear_add_8888_8_8888_process_pixblock_tail, \ + bilinear_add_8888_8_8888_process_pixblock_tail_head, \ + 4, 28, BILINEAR_FLAG_USE_MASK diff --git a/pixman/pixman/pixman-arm-neon-asm.S b/pixman/pixman/pixman-arm-neon-asm.S index 3fcd07dc3..87aae1d55 100644 --- a/pixman/pixman/pixman-arm-neon-asm.S +++ b/pixman/pixman/pixman-arm-neon-asm.S @@ -1219,6 +1219,145 @@ generate_composite_function \ /******************************************************************************/ +.macro pixman_composite_src_n_8_8888_process_pixblock_head + /* expecting solid source in {d0, d1, d2, d3} */ + /* mask is in d24 (d25, d26, d27 are unused) */ + + /* in */ + vmull.u8 q8, d24, d0 + vmull.u8 q9, d24, d1 + vmull.u8 q10, d24, d2 + vmull.u8 q11, d24, d3 + vrsra.u16 q8, q8, #8 + vrsra.u16 q9, q9, #8 + vrsra.u16 q10, q10, #8 + vrsra.u16 q11, q11, #8 +.endm + +.macro pixman_composite_src_n_8_8888_process_pixblock_tail + vrshrn.u16 d28, q8, #8 + vrshrn.u16 d29, q9, #8 + vrshrn.u16 d30, q10, #8 + vrshrn.u16 d31, q11, #8 +.endm + +.macro pixman_composite_src_n_8_8888_process_pixblock_tail_head + fetch_mask_pixblock + PF add PF_X, PF_X, #8 + vrshrn.u16 d28, q8, #8 + PF tst PF_CTL, #0x0F + vrshrn.u16 d29, q9, #8 + PF addne PF_X, PF_X, #8 + vrshrn.u16 d30, q10, #8 + PF subne PF_CTL, PF_CTL, #1 + vrshrn.u16 d31, q11, #8 + PF cmp PF_X, ORIG_W + vmull.u8 q8, d24, d0 + PF pld, [PF_MASK, PF_X, lsl #mask_bpp_shift] + vmull.u8 q9, d24, d1 + PF subge PF_X, PF_X, ORIG_W + vmull.u8 q10, d24, d2 + PF subges PF_CTL, PF_CTL, #0x10 + vmull.u8 q11, d24, d3 + PF ldrgeb DUMMY, [PF_MASK, MASK_STRIDE, lsl #mask_bpp_shift]! + vst4.8 {d28, d29, d30, d31}, [DST_W, :128]! + vrsra.u16 q8, q8, #8 + vrsra.u16 q9, q9, #8 + vrsra.u16 q10, q10, #8 + vrsra.u16 q11, q11, #8 +.endm + +.macro pixman_composite_src_n_8_8888_init + add DUMMY, sp, #ARGS_STACK_OFFSET + vld1.32 {d3[0]}, [DUMMY] + vdup.8 d0, d3[0] + vdup.8 d1, d3[1] + vdup.8 d2, d3[2] + vdup.8 d3, d3[3] +.endm + +.macro pixman_composite_src_n_8_8888_cleanup +.endm + +generate_composite_function \ + pixman_composite_src_n_8_8888_asm_neon, 0, 8, 32, \ + FLAG_DST_WRITEONLY | FLAG_DEINTERLEAVE_32BPP, \ + 8, /* number of pixels, processed in a single block */ \ + 5, /* prefetch distance */ \ + pixman_composite_src_n_8_8888_init, \ + pixman_composite_src_n_8_8888_cleanup, \ + pixman_composite_src_n_8_8888_process_pixblock_head, \ + pixman_composite_src_n_8_8888_process_pixblock_tail, \ + pixman_composite_src_n_8_8888_process_pixblock_tail_head, \ + +/******************************************************************************/ + +.macro pixman_composite_src_n_8_8_process_pixblock_head + vmull.u8 q0, d24, d16 + vmull.u8 q1, d25, d16 + vmull.u8 q2, d26, d16 + vmull.u8 q3, d27, d16 + vrsra.u16 q0, q0, #8 + vrsra.u16 q1, q1, #8 + vrsra.u16 q2, q2, #8 + vrsra.u16 q3, q3, #8 +.endm + +.macro pixman_composite_src_n_8_8_process_pixblock_tail + vrshrn.u16 d28, q0, #8 + vrshrn.u16 d29, q1, #8 + vrshrn.u16 d30, q2, #8 + vrshrn.u16 d31, q3, #8 +.endm + +.macro pixman_composite_src_n_8_8_process_pixblock_tail_head + fetch_mask_pixblock + PF add PF_X, PF_X, #8 + vrshrn.u16 d28, q0, #8 + PF tst PF_CTL, #0x0F + vrshrn.u16 d29, q1, #8 + PF addne PF_X, PF_X, #8 + vrshrn.u16 d30, q2, #8 + PF subne PF_CTL, PF_CTL, #1 + vrshrn.u16 d31, q3, #8 + PF cmp PF_X, ORIG_W + vmull.u8 q0, d24, d16 + PF pld, [PF_MASK, PF_X, lsl #mask_bpp_shift] + vmull.u8 q1, d25, d16 + PF subge PF_X, PF_X, ORIG_W + vmull.u8 q2, d26, d16 + PF subges PF_CTL, PF_CTL, #0x10 + vmull.u8 q3, d27, d16 + PF ldrgeb DUMMY, [PF_MASK, MASK_STRIDE, lsl #mask_bpp_shift]! + vst1.8 {d28, d29, d30, d31}, [DST_W, :128]! + vrsra.u16 q0, q0, #8 + vrsra.u16 q1, q1, #8 + vrsra.u16 q2, q2, #8 + vrsra.u16 q3, q3, #8 +.endm + +.macro pixman_composite_src_n_8_8_init + add DUMMY, sp, #ARGS_STACK_OFFSET + vld1.32 {d16[0]}, [DUMMY] + vdup.8 d16, d16[3] +.endm + +.macro pixman_composite_src_n_8_8_cleanup +.endm + +generate_composite_function \ + pixman_composite_src_n_8_8_asm_neon, 0, 8, 8, \ + FLAG_DST_WRITEONLY, \ + 32, /* number of pixels, processed in a single block */ \ + 5, /* prefetch distance */ \ + pixman_composite_src_n_8_8_init, \ + pixman_composite_src_n_8_8_cleanup, \ + pixman_composite_src_n_8_8_process_pixblock_head, \ + pixman_composite_src_n_8_8_process_pixblock_tail, \ + pixman_composite_src_n_8_8_process_pixblock_tail_head + +/******************************************************************************/ + .macro pixman_composite_over_n_8_8888_process_pixblock_head /* expecting deinterleaved source data in {d8, d9, d10, d11} */ /* d8 - blue, d9 - green, d10 - red, d11 - alpha */ diff --git a/pixman/pixman/pixman-arm-neon.c b/pixman/pixman/pixman-arm-neon.c index effb50b4f..ca139de0b 100644 --- a/pixman/pixman/pixman-arm-neon.c +++ b/pixman/pixman/pixman-arm-neon.c @@ -90,6 +90,10 @@ PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, neon, add_n_8_8, uint8_t, 1, uint8_t, 1) PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (SKIP_ZERO_SRC, neon, add_n_8_8888, uint8_t, 1, uint32_t, 1) +PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (0, neon, src_n_8_8888, + uint8_t, 1, uint32_t, 1) +PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST (0, neon, src_n_8_8, + uint8_t, 1, uint8_t, 1) PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST (SKIP_ZERO_MASK, neon, over_8888_n_8888, uint32_t, 1, uint32_t, 1) @@ -289,6 +293,12 @@ static const pixman_fast_path_t arm_neon_fast_paths[] = PIXMAN_STD_FAST_PATH (SRC, pixbuf, pixbuf, a8b8g8r8, neon_composite_src_rpixbuf_8888), PIXMAN_STD_FAST_PATH (SRC, rpixbuf, rpixbuf, a8r8g8b8, neon_composite_src_rpixbuf_8888), PIXMAN_STD_FAST_PATH (SRC, rpixbuf, rpixbuf, a8b8g8r8, neon_composite_src_pixbuf_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8r8g8b8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, x8r8g8b8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8b8g8r8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, x8b8g8r8, neon_composite_src_n_8_8888), + PIXMAN_STD_FAST_PATH (SRC, solid, a8, a8, neon_composite_src_n_8_8), + PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8, neon_composite_over_n_8_8), PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, neon_composite_over_n_8_0565), PIXMAN_STD_FAST_PATH (OVER, solid, a8, b5g6r5, neon_composite_over_n_8_0565), diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac index 67a683620..4bfa82c24 100644 --- a/xorg-server/configure.ac +++ b/xorg-server/configure.ac @@ -638,6 +638,7 @@ AC_ARG_ENABLE(int10-module, AS_HELP_STRING([--enable-int10-module], [Build X AC_ARG_ENABLE(windowswm, AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no]) AC_ARG_ENABLE(libdrm, AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes]) AC_ARG_ENABLE(clientids, AS_HELP_STRING([--disable-clientids], [Build Xorg with client ID tracking (default: enabled)]), [CLIENTIDS=$enableval], [CLIENTIDS=yes]) +AC_ARG_ENABLE(pciaccess, AS_HELP_STRING([--enable-pciaccess], [Build Xorg with pciaccess library (default: enabled)]), [PCI=$enableval], [PCI=yes]) dnl DDXes. AC_ARG_ENABLE(xorg, AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto]) @@ -718,6 +719,11 @@ case $host_os in XV=no ;; darwin*) + PCI=no + INT10MODULE=no + VGAHW=no + VBE=no + DRM=no DRI2=no if test x$XQUARTZ = xauto; then @@ -778,11 +784,6 @@ VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1" WINDOWSWMPROTO="windowswmproto" APPLEWMPROTO="applewmproto >= 1.4" -dnl Core modules for most extensions, et al. -SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto" -# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc -AC_SUBST(SDK_REQUIRED_MODULES) - dnl List of libraries that require a specific version LIBAPPLEWM="applewm >= 1.4" LIBDMX="dmx >= 1.0.99.1" @@ -793,7 +794,7 @@ LIBXEXT="xext >= 1.0.99.4" LIBXFONT="xfont >= 1.4.2" LIBXI="xi >= 1.2.99.1" LIBXTST="xtst >= 1.0.99.2" -LIBPCIACCESS="pciaccess >= 0.8.0" +LIBPCIACCESS="pciaccess >= 0.12.901" LIBUDEV="libudev >= 143" LIBSELINUX="libselinux >= 2.0.86" LIBDBUS="dbus-1 >= 1.0" @@ -804,6 +805,11 @@ dnl specific modules against it PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN) REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN $LIBXFONT xau" +dnl Core modules for most extensions, et al. +SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto $LIBPIXMAN" +# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc +AC_SUBST(SDK_REQUIRED_MODULES) + REQUIRED_MODULES="[fixesproto >= 5.0] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $SDK_REQUIRED_MODULES" if test "x$CONFIG_UDEV" = xyes && @@ -1270,7 +1276,6 @@ if test "x$XDMAUTH" = xyes; then fi AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path]) -AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path]) AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path]) AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path]) dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri` @@ -1521,10 +1526,6 @@ if test "x$XORG" = xauto; then fi AC_MSG_RESULT([$XORG]) -xorg_bus_linuxpci=no -xorg_bus_bsdpci=no -xorg_bus_sparc=no - if test "x$XORG" = xyes; then XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common' XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os' @@ -1572,37 +1573,51 @@ if test "x$XORG" = xyes; then AC_SUBST([symbol_visibility]) dnl =================================================================== + dnl =================================================================== + dnl ================= beginning of PCI configuration ================== + dnl =================================================================== + xorg_bus_bsdpci=no + xorg_bus_sparc=no + + AC_MSG_CHECKING([whether to build Xorg PCI functions]) + if test "x$PCI" = xyes; then + PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS) - SAVE_LIBS=$LIBS - SAVE_CFLAGS=$CFLAGS - CFLAGS=$PCIACCESS_CFLAGS - LIBS=$PCIACCESS_LIBS - AC_CHECK_FUNCS([pci_system_init_dev_mem]) - AC_CHECK_FUNCS([pci_device_enable]) - AC_CHECK_FUNCS([pci_device_is_boot_vga]) - AC_CHECK_FUNCS([pci_device_vgaarb_init]) - LIBS=$SAVE_LIBS - CFLAGS=$SAVE_CFLAGS + SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $LIBPCIACCESS" XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS" XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" + AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation]) + AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path]) + case $host_os in + gnu* | freebsd* | kfreebsd*-gnu | netbsd* | openbsd* | solaris* | dragonfly*) + xorg_bus_bsdpci="yes" + ;; + esac + case $host_cpu in + sparc*) + xorg_bus_sparc="yes" + ;; + esac + fi + AC_MSG_RESULT([$PCI]) + + dnl =================================================================== + dnl ==================== end of PCI configuration ===================== + dnl =================================================================== + case $host_os in linux*) if test "x$LNXAPM" = xyes; then XORG_CFLAGS="$XORG_CFLAGS -DXF86PM" fi XORG_OS_SUBDIR="linux" - xorg_bus_linuxpci="yes" linux_acpi="no" case $host_cpu in - ia64*) - linux_ia64=yes - linux_acpi="yes" - ;; alpha*) linux_alpha=yes ;; - i*86|amd64*|x86_64*) + i*86|amd64*|x86_64*|ia64*) linux_acpi="yes" ;; *) @@ -1611,11 +1626,9 @@ if test "x$XORG" = xyes; then ;; freebsd* | kfreebsd*-gnu | dragonfly*) XORG_OS_SUBDIR="bsd" - xorg_bus_bsdpci="yes" ;; netbsd*) XORG_OS_SUBDIR="bsd" - xorg_bus_bsdpci="yes" ;; openbsd*) if test "x$ac_cv_BSD_APM" = xyes \ @@ -1623,14 +1636,10 @@ if test "x$XORG" = xyes; then XORG_CFLAGS="$XORG_CFLAGS -DXF86PM" fi XORG_OS_SUBDIR="bsd" - xorg_bus_bsdpci="yes" ;; solaris*) XORG_OS_SUBDIR="solaris" XORG_CFLAGS="$XORG_CFLAGS -DXF86PM" - # Use the same stubs as BSD for old functions, since we now - # use libpciaccess for PCI - xorg_bus_bsdpci="yes" AC_CHECK_HEADERS([sys/kd.h]) AC_CHECK_HEADERS([sys/vt.h], [solaris_vt=yes], [solaris_vt=no]) # Check for minimum supported release @@ -1675,13 +1684,10 @@ if test "x$XORG" = xyes; then ;; gnu*) XORG_OS_SUBDIR="hurd" - # Use the same stubs as BSD for old functions, since we now - # use libpciaccess for PCI - xorg_bus_bsdpci="yes" ;; *) - XORG_OS_SUBDIR="unknown" - AC_MSG_ERROR([m4_text_wrap(m4_join([ ], + XORG_OS_SUBDIR="stub" + AC_MSG_NOTICE([m4_text_wrap(m4_join([ ], [Your OS is unknown. Xorg currently only supports Linux,], [Free/Open/Net/DragonFlyBSD, Solaris/OpenSolaris, & GNU Hurd.], [If you are interested in porting Xorg to your platform,], @@ -1690,9 +1696,6 @@ if test "x$XORG" = xyes; then esac case $host_cpu in - sparc*) - xorg_bus_sparc="yes" - ;; i*86) ;; esac @@ -1749,7 +1752,6 @@ if test "x$XORG" = xyes; then AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path]) AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location]) AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support]) - AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation]) if test "x$VGAHW" = xyes; then AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module]) fi @@ -1779,10 +1781,9 @@ if test "x$XORG" = xyes; then AC_SUBST([abi_extension]) fi AM_CONDITIONAL([XORG], [test "x$XORG" = xyes]) -AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes]) +AM_CONDITIONAL([XORG_BUS_PCI], [test "x$PCI" = xyes]) AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes]) AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes]) -AM_CONDITIONAL([LINUX_IA64], [test "x$linux_ia64" = xyes]) AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes]) AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes]) AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes]) @@ -2184,6 +2185,7 @@ hw/xfree86/os-support/hurd/Makefile hw/xfree86/os-support/misc/Makefile hw/xfree86/os-support/linux/Makefile hw/xfree86/os-support/solaris/Makefile +hw/xfree86/os-support/stub/Makefile hw/xfree86/parser/Makefile hw/xfree86/ramdac/Makefile hw/xfree86/shadowfb/Makefile diff --git a/xorg-server/dix/eventconvert.c b/xorg-server/dix/eventconvert.c index 47108fd70..5269e53bc 100644 --- a/xorg-server/dix/eventconvert.c +++ b/xorg-server/dix/eventconvert.c @@ -667,6 +667,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi) raw->length = bytes_to_int32(len - sizeof(xEvent)); raw->detail = ev->detail.button; raw->deviceid = ev->deviceid; + raw->sourceid = ev->sourceid; raw->valuators_len = vallen; raw->flags = ev->flags; diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c index c5f435c11..587724e16 100644 --- a/xorg-server/dix/events.c +++ b/xorg-server/dix/events.c @@ -525,13 +525,6 @@ SyntheticMotion(DeviceIntPtr dev, int x, int y) { static void PostNewCursor(DeviceIntPtr pDev); static Bool -pointOnScreen(ScreenPtr pScreen, int x, int y) -{ - return x >= pScreen->x && x < pScreen->x + pScreen->width && - y >= pScreen->y && y < pScreen->y + pScreen->height; -} - -static Bool XineramaSetCursorPosition( DeviceIntPtr pDev, int x, @@ -550,13 +543,13 @@ XineramaSetCursorPosition( x += screenInfo.screens[0]->x; y += screenInfo.screens[0]->y; - if(!pointOnScreen(pScreen, x, y)) + if(!point_on_screen(pScreen, x, y)) { FOR_NSCREENS(i) { if(i == pScreen->myNum) continue; - if(pointOnScreen(screenInfo.screens[i], x, y)) + if(point_on_screen(screenInfo.screens[i], x, y)) { pScreen = screenInfo.screens[i]; break; @@ -3366,7 +3359,11 @@ WindowHasNewCursor(WindowPtr pWin) void NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) { - SpritePtr pSprite = pDev->spriteInfo->sprite; + DeviceIntPtr ptr; + SpritePtr pSprite; + + ptr = IsFloating(pDev) ? pDev : GetXTestDevice(GetMaster(pDev, MASTER_POINTER)); + pSprite = ptr->spriteInfo->sprite; pSprite->hotPhys.x = x; pSprite->hotPhys.y = y; @@ -3378,15 +3375,15 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) pSprite->screen = newScreen; /* Make sure we tell the DDX to update its copy of the screen */ if(pSprite->confineWin) - XineramaConfineCursorToWindow(pDev, + XineramaConfineCursorToWindow(ptr, pSprite->confineWin, TRUE); else - XineramaConfineCursorToWindow(pDev, screenInfo.screens[0]->root, TRUE); + XineramaConfineCursorToWindow(ptr, screenInfo.screens[0]->root, TRUE); /* if the pointer wasn't confined, the DDX won't get told of the pointer warp so we reposition it here */ if(!syncEvents.playingEvents) (*pSprite->screen->SetCursorPosition)( - pDev, + ptr, pSprite->screen, pSprite->hotPhys.x + screenInfo.screens[0]->x - pSprite->screen->x, @@ -3396,7 +3393,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) } else #endif if (newScreen != pSprite->hotPhys.pScreen) - ConfineCursorToWindow(pDev, newScreen->root, TRUE, FALSE); + ConfineCursorToWindow(ptr, newScreen->root, TRUE, FALSE); } #ifdef PANORAMIX diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c index 374843f68..f000620e3 100644 --- a/xorg-server/dix/getevents.c +++ b/xorg-server/dix/getevents.c @@ -708,7 +708,7 @@ UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_eve * @param mask Valuator data for this event. */ static void -moveAbsolute(DeviceIntPtr dev, ValuatorMask *mask) +clipAbsolute(DeviceIntPtr dev, ValuatorMask *mask) { int i; @@ -728,7 +728,7 @@ moveAbsolute(DeviceIntPtr dev, ValuatorMask *mask) * Move the device's pointer by the values given in @valuators. * * @param dev The device whose pointer is to be moved. - * @param mask Valuator data for this event. + * @param[in,out] mask Valuator data for this event, modified in-place. */ static void moveRelative(DeviceIntPtr dev, ValuatorMask *mask) @@ -768,6 +768,37 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms) } /** + * Scale from absolute screen coordinates to absolute coordinates in the + * device's coordinate range. + * + * @param dev The device to scale for. + * @param[in, out] mask The mask in sceen coordinates, modified in place to + * contain device coordinate range. + */ +static void +scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask) +{ + double scaled; + ScreenPtr scr = miPointerGetScreen(dev); + + if (valuator_mask_isset(mask, 0)) + { + scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 0), + NULL, dev->valuator->axes + 0, + scr->width); + valuator_mask_set_double(mask, 0, scaled); + } + if (valuator_mask_isset(mask, 1)) + { + scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 1), + NULL, dev->valuator->axes + 1, + scr->height); + valuator_mask_set_double(mask, 1, scaled); + } +} + + +/** * If we have HW cursors, this actually moves the visible sprite. If not, we * just do all the screen crossing, etc. * @@ -775,25 +806,26 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms) * miPointerSetPosition() and then scale back into device coordinates (if * needed). miPSP will change x/y if the screen was crossed. * - * The coordinates provided are always absolute. The parameter mode whether - * it was relative or absolute movement that landed us at those coordinates. + * The coordinates provided are always absolute. The parameter mode + * specifies whether it was relative or absolute movement that landed us at + * those coordinates. * * @param dev The device to be moved. * @param mode Movement mode (Absolute or Relative) - * @param scr Screen the device's sprite is currently on. * @param mask Mask of axis values for this event * @param screenx Screen x coordinate the sprite is on after the update. * @param screeny Screen y coordinate the sprite is on after the update. */ -static void -positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask, +static ScreenPtr +positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask, double *screenx, double *screeny) { - int isx, isy; /* screen {x, y}, in int */ double x, y; + double tmpx, tmpy; + ScreenPtr scr = miPointerGetScreen(dev); if (!dev->valuator || dev->valuator->numAxes < 2) - return; + return scr; if (valuator_mask_isset(mask, 0)) x = valuator_mask_get_double(mask, 0); @@ -810,38 +842,30 @@ positionSprite(DeviceIntPtr dev, int mode, ScreenPtr scr, ValuatorMask *mask, *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL, scr->height); + tmpx = *screenx; + tmpy = *screeny; /* miPointerSetPosition takes care of crossing screens for us, as well as - * clipping to the current screen. In the event we actually change screen, - * we just drop the float component on the floor, then convert from - * screenx back into device co-ordinates. */ - isx = trunc(*screenx); - isy = trunc(*screeny); - miPointerSetPosition(dev, mode, &isx, &isy); - scr = miPointerGetScreen(dev); - if (isx != trunc(*screenx)) - { - *screenx -= trunc(*screenx) - isx; + * clipping to the current screen. */ + scr = miPointerSetPosition(dev, mode, screenx, screeny); + + /* If we were constrained, rescale x/y from the screen coordinates so + * the device valuators reflect the correct position. For screen + * crossing this doesn't matter much, the coords would be 0 or max. + */ + if (tmpx != *screenx) x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0, scr->width); - } - if (isy != trunc(*screeny)) - { - *screeny -= trunc(*screeny) - isy; + if (tmpy != *screeny) y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1, scr->height); - } - /* Update the MD's co-ordinates, which are always in screen space. */ - if (!IsMaster(dev) || !IsFloating(dev)) { - DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); - master->last.valuators[0] = *screenx; - master->last.valuators[1] = *screeny; - } if (valuator_mask_isset(mask, 0)) valuator_mask_set_double(mask, 0, x); if (valuator_mask_isset(mask, 1)) valuator_mask_set_double(mask, 1, y); + + return scr; } /** @@ -874,6 +898,15 @@ queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents) mieqEnqueue(device, &events[i]); } +static void +event_set_root_coordinates(DeviceEvent* event, double x, double y) +{ + event->root_x = trunc(x); + event->root_y = trunc(y); + event->root_x_frac = x - trunc(x); + event->root_y_frac = y - trunc(y); +} + /** * Generate internal events representing this keyboard event and enqueue * them on the event queue. @@ -925,6 +958,11 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type, (key_code < 8 || key_code > 255)) return 0; + if (mask_in && valuator_mask_size(mask_in) > 1) { + ErrorF("[dix] the server does not handle valuator masks with " + "keyboard events. This is a bug. You may fix it.\n"); + } + num_events = 1; events = UpdateFromMaster(events, pDev, DEVCHANGE_KEYBOARD_EVENT, &num_events); @@ -971,6 +1009,13 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type, set_valuators(pDev, event, &mask); + if (!IsFloating(pDev)) { + DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER); + event_set_root_coordinates(event, + master->last.valuators[0], + master->last.valuators[1]); + } + return num_events; } @@ -1020,6 +1065,14 @@ transform(struct pixman_f_transform *m, double *x, double *y) *y = p.v[1]; } +/** + * Apply the device's transformation matrix to the valuator mask and replace + * the scaled values in mask. This transformation only applies to valuators + * 0 and 1, others will be untouched. + * + * @param dev The device the valuators came from + * @param[in,out] mask The valuator mask. + */ static void transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask) { @@ -1084,12 +1137,16 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, DeviceEvent *event; RawDeviceEvent *raw; double screenx = 0.0, screeny = 0.0; - ScreenPtr scr = miPointerGetScreen(pDev); ValuatorMask mask; switch (type) { case MotionNotify: + if (!pDev->valuator) + { + ErrorF("[dix] motion events from device %d without valuators\n", pDev->id); + return 0; + } if (!mask_in || valuator_mask_num_valuators(mask_in) <= 0) return 0; break; @@ -1097,6 +1154,11 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, case ButtonRelease: if (!pDev->button || !buttons) return 0; + if (mask_in && valuator_mask_size(mask_in) > 0 && !pDev->valuator) + { + ErrorF("[dix] button event with valuator from device %d without valuators\n", pDev->id); + return 0; + } break; default: return 0; @@ -1117,27 +1179,10 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, if (flags & POINTER_ABSOLUTE) { if (flags & POINTER_SCREEN) /* valuators are in screen coords */ - { - double scaled; - - if (valuator_mask_isset(&mask, 0)) - { - scaled = rescaleValuatorAxis(valuator_mask_get_double(&mask, 0), - NULL, pDev->valuator->axes + 0, - scr->width); - valuator_mask_set_double(&mask, 0, scaled); - } - if (valuator_mask_isset(&mask, 1)) - { - scaled = rescaleValuatorAxis(valuator_mask_get_double(&mask, 1), - NULL, pDev->valuator->axes + 1, - scr->height); - valuator_mask_set_double(&mask, 1, scaled); - } - } + scale_from_screen(pDev, &mask); transformAbsolute(pDev, &mask); - moveAbsolute(pDev, &mask); + clipAbsolute(pDev, &mask); } else { if (flags & POINTER_ACCELERATE) accelPointer(pDev, &mask, ms); @@ -1147,7 +1192,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, if ((flags & POINTER_NORAW) == 0) set_raw_valuators(raw, &mask, raw->valuators.data); - positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, scr, + positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative, &mask, &screenx, &screeny); updateHistory(pDev, &mask, ms); @@ -1159,6 +1204,13 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, pDev->last.valuators[i] = valuator_mask_get_double(&mask, i); } + /* Update the MD's co-ordinates, which are always in screen space. */ + if (!IsMaster(pDev) || !IsFloating(pDev)) { + DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER); + master->last.valuators[0] = screenx; + master->last.valuators[1] = screeny; + } + event = &events->device_event; init_device_event(event, pDev, ms); @@ -1179,10 +1231,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type, } /* root_x and root_y must be in screen co-ordinates */ - event->root_x = trunc(screenx); - event->root_y = trunc(screeny); - event->root_x_frac = screenx - trunc(screenx); - event->root_y_frac = screeny - trunc(screeny); + event_set_root_coordinates(event, screenx, screeny); if (flags & POINTER_EMULATED) { raw->flags = XIPointerEmulated; @@ -1333,21 +1382,22 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, double val, adj; int axis; + /* Up is negative on valuators, down positive */ switch (buttons) { case 4: - adj = 1.0; + adj = -1.0; axis = v_scroll_axis; break; case 5: - adj = -1.0; + adj = 1.0; axis = v_scroll_axis; break; case 6: - adj = 1.0; + adj = -1.0; axis = h_scroll_axis; break; case 7: - adj = -1.0; + adj = 1.0; axis = h_scroll_axis; break; default: diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c index 0a3d3d8b4..5c76361b3 100644 --- a/xorg-server/dix/inpututils.c +++ b/xorg-server/dix/inpututils.c @@ -37,6 +37,7 @@ #include "xkbstr.h" #include "inpututils.h" #include "eventstr.h" +#include "scrnintstr.h" /* Check if a button map change is okay with the device. * Returns -1 for BadValue, as it collides with MappingBusy. */ @@ -619,6 +620,13 @@ void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms) event->sourceid = dev->id; } +Bool +point_on_screen(ScreenPtr pScreen, int x, int y) +{ + return x >= pScreen->x && x < pScreen->x + pScreen->width && + y >= pScreen->y && y < pScreen->y + pScreen->height; +} + /** * Delete the element with the key from the list, freeing all memory * associated with the element.. @@ -759,3 +767,66 @@ input_option_set_value(InputOption *opt, const char *value) if (value) opt->value = strdup(value); } + + +/* FP1616/FP3232 conversion functions. + * Fixed point types are encoded as signed integral and unsigned frac. So any + * negative number -n.m is encoded as floor(n) + (1 - 0.m). + */ +double +fp1616_to_double(FP1616 in) +{ + double ret; + + ret = (double)(in >> 16); + ret += (double)(in & 0xffff) * (1.0 / (1UL << 16)); /* Optimized: ldexp((double)(in & 0xffff), -16); */ + return ret; +} + +double +fp3232_to_double(FP3232 in) +{ + double ret; + ret = (double)in.integral; + ret += (double)in.frac * (1.0 / (1ULL << 32)); /* Optimized: ldexp((double)in.frac, -32); */ + return ret; +} + + +FP1616 +double_to_fp1616(double in) +{ + FP1616 ret; + int32_t integral; + double tmp; + uint32_t frac_d; + + tmp = floor(in); + integral = (int32_t)tmp; + + tmp = (in - integral) * (1UL << 16); /* Optimized: ldexp(in - integral, 16) */ + frac_d = (uint16_t)tmp; + + ret = integral << 16; + ret |= frac_d & 0xffff; + return ret; +} + +FP3232 +double_to_fp3232(double in) +{ + FP3232 ret; + int32_t integral; + double tmp; + uint32_t frac_d; + + tmp = floor(in); + integral = (int32_t)tmp; + + tmp = (in - integral) * (1ULL << 32); /* Optimized: ldexp(in - integral, 32) */ + frac_d = (uint32_t)tmp; + + ret.integral = integral; + ret.frac = frac_d; + return ret; +} diff --git a/xorg-server/doc/Xserver-spec.xml b/xorg-server/doc/Xserver-spec.xml index 37fd2b29a..2bf4fb3b7 100644 --- a/xorg-server/doc/Xserver-spec.xml +++ b/xorg-server/doc/Xserver-spec.xml @@ -1324,10 +1324,6 @@ This re-enables X request processing for the specified client. void FatalError(char *f, ...) - - void - Error(str) - char *str; </programlisting></blockquote> You should write these three routines to provide for diagnostic output from the dix and ddx layers, although implementing them to produce no @@ -1335,11 +1331,7 @@ output will not affect the correctness of your server. ErrorF() and FatalError() take a printf() type of format specification in the first argument and an implementation-dependent number of arguments following that. Normally, the formats passed to ErrorF() and FatalError() -should be terminated with a newline. Error() provides an os interface -for printing out the string passed as an argument followed by a -meaningful explanation of the last system error. Normally the string -does not contain a newline, and it is only called by the ddx layer. -In the sample implementation, Error() uses the perror() function. +should be terminated with a newline. </para> <para> After printing the message arguments, FatalError() must be implemented diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c index 1def0e87b..0f1ee8f4a 100644 --- a/xorg-server/hw/kdrive/ephyr/hostx.c +++ b/xorg-server/hw/kdrive/ephyr/hostx.c @@ -45,6 +45,7 @@ #include <stdio.h> #include <unistd.h> #include <string.h> /* for memset */ +#include <errno.h> #include <time.h> #ifndef _MSC_VER @@ -337,6 +338,14 @@ hostx_set_title (char *title) ephyrTitle = title; } +static int _X_NORETURN +x_io_error_handler (Display *dpy) { + ErrorF("Lost connection to X server: %s\n", strerror(errno)); + CloseWellKnownConnections(); + OsCleanup(1); + exit(1); +} + int hostx_init (void) { @@ -364,6 +373,8 @@ hostx_init (void) exit(1); } + XSetIOErrorHandler(x_io_error_handler); + HostX.screen = DefaultScreen(HostX.dpy); HostX.winroot = RootWindow(HostX.dpy, HostX.screen); HostX.gc = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL); diff --git a/xorg-server/hw/kdrive/ephyr/man/Xephyr.man b/xorg-server/hw/kdrive/ephyr/man/Xephyr.man index 12c9f58bc..ca88ab240 100644 --- a/xorg-server/hw/kdrive/ephyr/man/Xephyr.man +++ b/xorg-server/hw/kdrive/ephyr/man/Xephyr.man @@ -1,18 +1,18 @@ -." -." Copyright (c) Matthieu Herrb <matthieu@herrb.eu> -." -." Permission to use, copy, modify, and distribute this software for any -." purpose with or without fee is hereby granted, provided that the above -." copyright notice and this permission notice appear in all copies. -." -." THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -." WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -." MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -." ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -." WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -." ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -." OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -." +.\" +.\" Copyright (c) Matthieu Herrb <matthieu@herrb.eu> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" .TH Xephyr __appmansuffix__ __vendorversion__ .SH NAME Xephyr - X server outputting to a window on a pre-existing X display @@ -81,7 +81,7 @@ build flags are causing this. I haven't figured as yet how to work round it. It doesn't appear to break anything however. .IP \(bu 2 Keyboard handling is basic but works. -.TP \(bu 2 +.IP \(bu 2 Mouse button 5 probably won't work. .SH "SEE ALSO" X(__miscmansuffix__), Xserver(__appmansuffix__) diff --git a/xorg-server/hw/xfree86/common/Makefile.am b/xorg-server/hw/xfree86/common/Makefile.am index 23ddb5c34..a27372103 100644 --- a/xorg-server/hw/xfree86/common/Makefile.am +++ b/xorg-server/hw/xfree86/common/Makefile.am @@ -1,5 +1,10 @@ noinst_LTLIBRARIES = libcommon.la +if XORG_BUS_PCI +PCI_SOURCES = xf86pciBus.c xf86VGAarbiter.c xf86VGAarbiter.h \ + xf86VGAarbiterPriv.h +endif + if XORG_BUS_SPARC SBUS_SOURCES = xf86sbusBus.c endif @@ -19,7 +24,7 @@ endif RANDRSOURCES = xf86RandR.c -BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES) +BUSSOURCES = xf86fbBus.c xf86noBus.c $(PCI_SOURCES) $(SBUS_SOURCES) MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes @@ -33,7 +38,7 @@ AM_LDFLAGS = -r libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \ xf86Cursor.c $(DGASOURCES) xf86DPMS.c \ xf86Events.c xf86Globals.c xf86AutoConfig.c \ - xf86Option.c xf86Init.c xf86VGAarbiter.c \ + xf86Option.c xf86Init.c \ xf86VidMode.c xf86fbman.c xf86cmap.c \ xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \ xf86Mode.c xorgHelper.c \ diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h index 1b6c9984c..3185baf3a 100644 --- a/xorg-server/hw/xfree86/common/xf86.h +++ b/xorg-server/hw/xfree86/common/xf86.h @@ -92,6 +92,7 @@ extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */ #ifndef _NO_XF86_PROTOTYPES /* PCI related */ +#ifdef XSERVER_LIBPCIACCESS #include <pciaccess.h> extern _X_EXPORT Bool pciSlotClaimed; @@ -118,6 +119,15 @@ extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init, EntityProc enter, EntityProc leave, pointer private); +#else +#define xf86VGAarbiterInit() do {} while (0) +#define xf86VGAarbiterFini() do {} while (0) +#define xf86VGAarbiterLock(x) do {} while (0) +#define xf86VGAarbiterUnlock(x) do {} while (0) +#define xf86VGAarbiterScrnInit(x) do {} while (0) +#define xf86VGAarbiterDeviceDecodes() do {} while (0) +#define xf86VGAarbiterWrapFunctions() do {} while (0) +#endif /* xf86Bus.c */ @@ -239,12 +249,6 @@ extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from); extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips); extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist); -extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, - Bool (*ClockFunc)(ScrnInfoPtr, int), - void (*ProtectRegs)(ScrnInfoPtr, Bool), - void (*BlankScreen)(ScrnInfoPtr, Bool), - IOADDRESS vertsyncreg, int maskval, - int knownclkindex, int knownclkvalue); extern _X_EXPORT const char *xf86GetVisualName(int visual); extern _X_EXPORT int xf86GetVerbosity(void); extern _X_EXPORT Pix24Flags xf86GetPix24(void); diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c index 1b9253269..7fc6518d3 100644 --- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c +++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c @@ -1,403 +1,403 @@ -/*
- * Copyright 2003 by David H. Dawes.
- * Copyright 2003 by X-Oz Technologies.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- *
- * Author: David Dawes <dawes@XFree86.Org>.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "xf86Config.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86pciBus.h"
-#ifdef __sparc__
-# include "xf86sbusBus.h"
-#endif
-
-#ifdef sun
-# include <sys/visual_io.h>
-# include <ctype.h>
-#endif
-
-/* Sections for the default built-in configuration. */
-
-#define BUILTIN_DEVICE_NAME \
- "\"Builtin Default %s Device %d\""
-
-#define BUILTIN_DEVICE_SECTION_PRE \
- "Section \"Device\"\n" \
- "\tIdentifier\t" BUILTIN_DEVICE_NAME "\n" \
- "\tDriver\t\"%s\"\n"
-
-#define BUILTIN_DEVICE_SECTION_POST \
- "EndSection\n\n"
-
-#define BUILTIN_DEVICE_SECTION \
- BUILTIN_DEVICE_SECTION_PRE \
- BUILTIN_DEVICE_SECTION_POST
-
-#define BUILTIN_SCREEN_NAME \
- "\"Builtin Default %s Screen %d\""
-
-#define BUILTIN_SCREEN_SECTION \
- "Section \"Screen\"\n" \
- "\tIdentifier\t" BUILTIN_SCREEN_NAME "\n" \
- "\tDevice\t" BUILTIN_DEVICE_NAME "\n" \
- "EndSection\n\n"
-
-#define BUILTIN_LAYOUT_SECTION_PRE \
- "Section \"ServerLayout\"\n" \
- "\tIdentifier\t\"Builtin Default Layout\"\n"
-
-#define BUILTIN_LAYOUT_SCREEN_LINE \
- "\tScreen\t" BUILTIN_SCREEN_NAME "\n"
-
-#define BUILTIN_LAYOUT_SECTION_POST \
- "EndSection\n\n"
-
-static const char **builtinConfig = NULL;
-static int builtinLines = 0;
-
-static void listPossibleVideoDrivers(char *matches[], int nmatches);
-
-/*
- * A built-in config file is stored as an array of strings, with each string
- * representing a single line. AppendToConfig() breaks up the string "s"
- * into lines, and appends those lines it to builtinConfig.
- */
-
-static void
-AppendToList(const char *s, const char ***list, int *lines)
-{
- char *str, *newstr, *p;
-
- str = xnfstrdup(s);
- for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) {
- (*lines)++;
- *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list));
- newstr = xnfalloc(strlen(p) + 2);
- strcpy(newstr, p);
- strcat(newstr, "\n");
- (*list)[*lines - 1] = newstr;
- (*list)[*lines] = NULL;
- }
- free(str);
-}
-
-static void
-FreeList(const char ***list, int *lines)
-{
- int i;
-
- for (i = 0; i < *lines; i++) {
- free((char *)((*list)[i]));
- }
- free(*list);
- *list = NULL;
- *lines = 0;
-}
-
-static void
-FreeConfig(void)
-{
- FreeList(&builtinConfig, &builtinLines);
-}
-
-static void
-AppendToConfig(const char *s)
-{
- AppendToList(s, &builtinConfig, &builtinLines);
-}
-
-Bool
-xf86AutoConfig(void)
-{
- char *deviceList[20];
- char **p;
- const char **cp;
- char buf[1024];
- ConfigStatus ret;
-
- listPossibleVideoDrivers(deviceList, 20);
-
- for (p = deviceList; *p; p++) {
- snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p);
- AppendToConfig(buf);
- snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0);
- AppendToConfig(buf);
- }
-
- AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE);
- for (p = deviceList; *p; p++) {
- snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0);
- AppendToConfig(buf);
- }
- AppendToConfig(BUILTIN_LAYOUT_SECTION_POST);
-
- for (p = deviceList; *p; p++) {
- free(*p);
- }
-
- xf86MsgVerb(X_DEFAULT, 0,
- "Using default built-in configuration (%d lines)\n",
- builtinLines);
-
- xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n");
- for (cp = builtinConfig; *cp; cp++)
- xf86ErrorFVerb(3, "\t%s", *cp);
- xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
-
- xf86initConfigFiles();
- xf86setBuiltinConfig(builtinConfig);
- ret = xf86HandleConfigFile(TRUE);
- FreeConfig();
-
- if (ret != CONFIG_OK)
- xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
-
- return ret == CONFIG_OK;
-}
-
-static void
-listPossibleVideoDrivers(char *matches[], int nmatches)
-{
- int i;
-
- for (i = 0 ; i < nmatches ; i++) {
- matches[i] = NULL;
- }
- i = 0;
-
-#ifdef sun
- /* Check for driver type based on /dev/fb type and if valid, use
- it instead of PCI bus probe results */
- if (xf86Info.consoleFd >= 0) {
- struct vis_identifier visid;
- const char *cp;
- extern char xf86SolarisFbDev[PATH_MAX];
- int iret;
-
- SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid));
- if (iret < 0) {
- int fbfd;
-
- fbfd = open(xf86SolarisFbDev, O_RDONLY);
- if (fbfd >= 0) {
- SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid));
- close(fbfd);
- }
- }
-
- if (iret < 0) {
- xf86Msg(X_WARNING,
- "could not get frame buffer identifier from %s\n",
- xf86SolarisFbDev);
- } else {
- xf86Msg(X_PROBED, "console driver: %s\n", visid.name);
-
- /* Special case from before the general case was set */
- if (strcmp(visid.name, "NVDAnvda") == 0) {
- matches[i++] = xnfstrdup("nvidia");
- }
-
- /* General case - split into vendor name (initial all-caps
- prefix) & driver name (rest of the string). */
- if (strcmp(visid.name, "SUNWtext") != 0) {
- for (cp = visid.name; (*cp != '\0') && isupper(*cp); cp++) {
- /* find end of all uppercase vendor section */
- }
- if ((cp != visid.name) && (*cp != '\0')) {
- char *driverName = xnfstrdup(cp);
- char *vendorName = xnfstrdup(visid.name);
- vendorName[cp - visid.name] = '\0';
-
- matches[i++] = vendorName;
- matches[i++] = driverName;
- }
- }
- }
- }
-#endif
-#ifdef __sparc__
- {
- char *sbusDriver = sparcDriverName();
- if (sbusDriver)
- matches[i++] = xnfstrdup(sbusDriver);
- }
-#endif
-
- i = xf86PciMatchDriver(matches, nmatches);
-
- /* Fallback to platform default hardware */
- if (i < (nmatches - 1)) {
-#if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
- matches[i++] = xnfstrdup("vesa");
-#elif defined(__sparc__) && !defined(sun)
- matches[i++] = xnfstrdup("sunffb");
-#endif
- }
-
- /* Fallback to platform default frame buffer driver */
- if (i < (nmatches - 1)) {
-#if !defined(__linux__) && defined(__sparc__)
- matches[i++] = xnfstrdup("wsfb");
-#else
- matches[i++] = xnfstrdup("fbdev");
-#endif
- }
-}
-
-/* copy a screen section and enter the desired driver
- * and insert it at i in the list of screens */
-static Bool
-copyScreen(confScreenPtr oscreen, GDevPtr odev, int i, char *driver)
-{
- confScreenPtr nscreen;
- GDevPtr cptr = NULL;
-
- nscreen = malloc(sizeof(confScreenRec));
- if (!nscreen)
- return FALSE;
- memcpy(nscreen, oscreen, sizeof(confScreenRec));
-
- cptr = malloc(sizeof(GDevRec));
- if (!cptr) {
- free(nscreen);
- return FALSE;
- }
- memcpy(cptr, odev, sizeof(GDevRec));
-
- if (asprintf(&cptr->identifier, "Autoconfigured Video Device %s", driver)
- == -1) {
- free(cptr);
- free(nscreen);
- return FALSE;
- }
- cptr->driver = driver;
-
- xf86ConfigLayout.screens[i].screen = nscreen;
-
- /* now associate the new driver entry with the new screen entry */
- xf86ConfigLayout.screens[i].screen->device = cptr;
- cptr->myScreenSection = xf86ConfigLayout.screens[i].screen;
-
- return TRUE;
-}
-
-GDevPtr
-autoConfigDevice(GDevPtr preconf_device)
-{
- GDevPtr ptr = NULL;
- char *matches[20]; /* If we have more than 20 drivers we're in trouble */
- int num_matches = 0, num_screens = 0, i;
- screenLayoutPtr slp;
-
- if (!xf86configptr) {
- return NULL;
- }
-
- /* If there's a configured section with no driver chosen, use it */
- if (preconf_device) {
- ptr = preconf_device;
- } else {
- ptr = calloc(1, sizeof(GDevRec));
- if (!ptr) {
- return NULL;
- }
- ptr->chipID = -1;
- ptr->chipRev = -1;
- ptr->irq = -1;
-
- ptr->active = TRUE;
- ptr->claimed = FALSE;
- ptr->identifier = "Autoconfigured Video Device";
- ptr->driver = NULL;
- }
- if (!ptr->driver) {
- /* get all possible video drivers and count them */
- listPossibleVideoDrivers(matches, 20);
- for (; matches[num_matches]; num_matches++) {
- xf86Msg(X_DEFAULT, "Matched %s as autoconfigured driver %d\n",
- matches[num_matches], num_matches);
- }
-
- slp = xf86ConfigLayout.screens;
- if (slp) {
- /* count the number of screens and make space for
- * a new screen for each additional possible driver
- * minus one for the already existing first one
- * plus one for the terminating NULL */
- for (; slp[num_screens].screen; num_screens++);
- xf86ConfigLayout.screens = xnfcalloc(num_screens + num_matches,
- sizeof(screenLayoutRec));
- xf86ConfigLayout.screens[0] = slp[0];
-
- /* do the first match and set that for the original first screen */
- ptr->driver = matches[0];
- if (!xf86ConfigLayout.screens[0].screen->device) {
- xf86ConfigLayout.screens[0].screen->device = ptr;
- ptr->myScreenSection = xf86ConfigLayout.screens[0].screen;
- }
-
- /* for each other driver found, copy the first screen, insert it
- * into the list of screens and set the driver */
- i = 0;
- while (i++ < num_matches) {
- if (!copyScreen(slp[0].screen, ptr, i, matches[i]))
- return NULL;
- }
-
- /* shift the rest of the original screen list
- * to the end of the current screen list
- *
- * TODO Handle rest of multiple screen sections */
- for (i = 1; i < num_screens; i++) {
- xf86ConfigLayout.screens[i+num_matches] = slp[i];
- }
- xf86ConfigLayout.screens[num_screens+num_matches-1].screen = NULL;
- free(slp);
- } else {
- /* layout does not have any screens, not much to do */
- ptr->driver = matches[0];
- for (i = 1; matches[i] ; i++) {
- if (matches[i] != matches[0]) {
- free(matches[i]);
- }
- }
- }
- }
-
- xf86Msg(X_DEFAULT, "Assigned the driver to the xf86ConfigLayout\n");
-
- return ptr;
-}
+/* + * Copyright 2003 by David H. Dawes. + * Copyright 2003 by X-Oz Technologies. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + * + * Author: David Dawes <dawes@XFree86.Org>. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "xf86Config.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86pciBus.h" +#ifdef __sparc__ +# include "xf86sbusBus.h" +#endif + +#ifdef sun +# include <sys/visual_io.h> +# include <ctype.h> +#endif + +/* Sections for the default built-in configuration. */ + +#define BUILTIN_DEVICE_NAME \ + "\"Builtin Default %s Device %d\"" + +#define BUILTIN_DEVICE_SECTION_PRE \ + "Section \"Device\"\n" \ + "\tIdentifier\t" BUILTIN_DEVICE_NAME "\n" \ + "\tDriver\t\"%s\"\n" + +#define BUILTIN_DEVICE_SECTION_POST \ + "EndSection\n\n" + +#define BUILTIN_DEVICE_SECTION \ + BUILTIN_DEVICE_SECTION_PRE \ + BUILTIN_DEVICE_SECTION_POST + +#define BUILTIN_SCREEN_NAME \ + "\"Builtin Default %s Screen %d\"" + +#define BUILTIN_SCREEN_SECTION \ + "Section \"Screen\"\n" \ + "\tIdentifier\t" BUILTIN_SCREEN_NAME "\n" \ + "\tDevice\t" BUILTIN_DEVICE_NAME "\n" \ + "EndSection\n\n" + +#define BUILTIN_LAYOUT_SECTION_PRE \ + "Section \"ServerLayout\"\n" \ + "\tIdentifier\t\"Builtin Default Layout\"\n" + +#define BUILTIN_LAYOUT_SCREEN_LINE \ + "\tScreen\t" BUILTIN_SCREEN_NAME "\n" + +#define BUILTIN_LAYOUT_SECTION_POST \ + "EndSection\n\n" + +static const char **builtinConfig = NULL; +static int builtinLines = 0; + +static void listPossibleVideoDrivers(char *matches[], int nmatches); + +/* + * A built-in config file is stored as an array of strings, with each string + * representing a single line. AppendToConfig() breaks up the string "s" + * into lines, and appends those lines it to builtinConfig. + */ + +static void +AppendToList(const char *s, const char ***list, int *lines) +{ + char *str, *newstr, *p; + + str = xnfstrdup(s); + for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) { + (*lines)++; + *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list)); + newstr = xnfalloc(strlen(p) + 2); + strcpy(newstr, p); + strcat(newstr, "\n"); + (*list)[*lines - 1] = newstr; + (*list)[*lines] = NULL; + } + free(str); +} + +static void +FreeList(const char ***list, int *lines) +{ + int i; + + for (i = 0; i < *lines; i++) { + free((char *)((*list)[i])); + } + free(*list); + *list = NULL; + *lines = 0; +} + +static void +FreeConfig(void) +{ + FreeList(&builtinConfig, &builtinLines); +} + +static void +AppendToConfig(const char *s) +{ + AppendToList(s, &builtinConfig, &builtinLines); +} + +Bool +xf86AutoConfig(void) +{ + char *deviceList[20]; + char **p; + const char **cp; + char buf[1024]; + ConfigStatus ret; + + listPossibleVideoDrivers(deviceList, 20); + + for (p = deviceList; *p; p++) { + snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p); + AppendToConfig(buf); + snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0); + AppendToConfig(buf); + } + + AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE); + for (p = deviceList; *p; p++) { + snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0); + AppendToConfig(buf); + } + AppendToConfig(BUILTIN_LAYOUT_SECTION_POST); + + for (p = deviceList; *p; p++) { + free(*p); + } + + xf86MsgVerb(X_DEFAULT, 0, + "Using default built-in configuration (%d lines)\n", + builtinLines); + + xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n"); + for (cp = builtinConfig; *cp; cp++) + xf86ErrorFVerb(3, "\t%s", *cp); + xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n"); + + xf86initConfigFiles(); + xf86setBuiltinConfig(builtinConfig); + ret = xf86HandleConfigFile(TRUE); + FreeConfig(); + + if (ret != CONFIG_OK) + xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n"); + + return ret == CONFIG_OK; +} + +static void +listPossibleVideoDrivers(char *matches[], int nmatches) +{ + int i; + + for (i = 0 ; i < nmatches ; i++) { + matches[i] = NULL; + } + i = 0; + +#ifdef sun + /* Check for driver type based on /dev/fb type and if valid, use + it instead of PCI bus probe results */ + if (xf86Info.consoleFd >= 0) { + struct vis_identifier visid; + const char *cp; + extern char xf86SolarisFbDev[PATH_MAX]; + int iret; + + SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid)); + if (iret < 0) { + int fbfd; + + fbfd = open(xf86SolarisFbDev, O_RDONLY); + if (fbfd >= 0) { + SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid)); + close(fbfd); + } + } + + if (iret < 0) { + xf86Msg(X_WARNING, + "could not get frame buffer identifier from %s\n", + xf86SolarisFbDev); + } else { + xf86Msg(X_PROBED, "console driver: %s\n", visid.name); + + /* Special case from before the general case was set */ + if (strcmp(visid.name, "NVDAnvda") == 0) { + matches[i++] = xnfstrdup("nvidia"); + } + + /* General case - split into vendor name (initial all-caps + prefix) & driver name (rest of the string). */ + if (strcmp(visid.name, "SUNWtext") != 0) { + for (cp = visid.name; (*cp != '\0') && isupper(*cp); cp++) { + /* find end of all uppercase vendor section */ + } + if ((cp != visid.name) && (*cp != '\0')) { + char *driverName = xnfstrdup(cp); + char *vendorName = xnfstrdup(visid.name); + vendorName[cp - visid.name] = '\0'; + + matches[i++] = vendorName; + matches[i++] = driverName; + } + } + } + } +#endif +#ifdef __sparc__ + { + char *sbusDriver = sparcDriverName(); + if (sbusDriver) + matches[i++] = xnfstrdup(sbusDriver); + } +#endif +#ifdef XSERVER_LIBPCIACCESS + i = xf86PciMatchDriver(matches, nmatches); +#endif + /* Fallback to platform default hardware */ + if (i < (nmatches - 1)) { +#if defined(__i386__) || defined(__amd64__) || defined(__hurd__) + matches[i++] = xnfstrdup("vesa"); +#elif defined(__sparc__) && !defined(sun) + matches[i++] = xnfstrdup("sunffb"); +#endif + } + + /* Fallback to platform default frame buffer driver */ + if (i < (nmatches - 1)) { +#if !defined(__linux__) && defined(__sparc__) + matches[i++] = xnfstrdup("wsfb"); +#else + matches[i++] = xnfstrdup("fbdev"); +#endif + } +} + +/* copy a screen section and enter the desired driver + * and insert it at i in the list of screens */ +static Bool +copyScreen(confScreenPtr oscreen, GDevPtr odev, int i, char *driver) +{ + confScreenPtr nscreen; + GDevPtr cptr = NULL; + + nscreen = malloc(sizeof(confScreenRec)); + if (!nscreen) + return FALSE; + memcpy(nscreen, oscreen, sizeof(confScreenRec)); + + cptr = malloc(sizeof(GDevRec)); + if (!cptr) { + free(nscreen); + return FALSE; + } + memcpy(cptr, odev, sizeof(GDevRec)); + + if (asprintf(&cptr->identifier, "Autoconfigured Video Device %s", driver) + == -1) { + free(cptr); + free(nscreen); + return FALSE; + } + cptr->driver = driver; + + xf86ConfigLayout.screens[i].screen = nscreen; + + /* now associate the new driver entry with the new screen entry */ + xf86ConfigLayout.screens[i].screen->device = cptr; + cptr->myScreenSection = xf86ConfigLayout.screens[i].screen; + + return TRUE; +} + +GDevPtr +autoConfigDevice(GDevPtr preconf_device) +{ + GDevPtr ptr = NULL; + char *matches[20]; /* If we have more than 20 drivers we're in trouble */ + int num_matches = 0, num_screens = 0, i; + screenLayoutPtr slp; + + if (!xf86configptr) { + return NULL; + } + + /* If there's a configured section with no driver chosen, use it */ + if (preconf_device) { + ptr = preconf_device; + } else { + ptr = calloc(1, sizeof(GDevRec)); + if (!ptr) { + return NULL; + } + ptr->chipID = -1; + ptr->chipRev = -1; + ptr->irq = -1; + + ptr->active = TRUE; + ptr->claimed = FALSE; + ptr->identifier = "Autoconfigured Video Device"; + ptr->driver = NULL; + } + if (!ptr->driver) { + /* get all possible video drivers and count them */ + listPossibleVideoDrivers(matches, 20); + for (; matches[num_matches]; num_matches++) { + xf86Msg(X_DEFAULT, "Matched %s as autoconfigured driver %d\n", + matches[num_matches], num_matches); + } + + slp = xf86ConfigLayout.screens; + if (slp) { + /* count the number of screens and make space for + * a new screen for each additional possible driver + * minus one for the already existing first one + * plus one for the terminating NULL */ + for (; slp[num_screens].screen; num_screens++); + xf86ConfigLayout.screens = xnfcalloc(num_screens + num_matches, + sizeof(screenLayoutRec)); + xf86ConfigLayout.screens[0] = slp[0]; + + /* do the first match and set that for the original first screen */ + ptr->driver = matches[0]; + if (!xf86ConfigLayout.screens[0].screen->device) { + xf86ConfigLayout.screens[0].screen->device = ptr; + ptr->myScreenSection = xf86ConfigLayout.screens[0].screen; + } + + /* for each other driver found, copy the first screen, insert it + * into the list of screens and set the driver */ + i = 0; + while (i++ < num_matches) { + if (!copyScreen(slp[0].screen, ptr, i, matches[i])) + return NULL; + } + + /* shift the rest of the original screen list + * to the end of the current screen list + * + * TODO Handle rest of multiple screen sections */ + for (i = 1; i < num_screens; i++) { + xf86ConfigLayout.screens[i+num_matches] = slp[i]; + } + xf86ConfigLayout.screens[num_screens+num_matches-1].screen = NULL; + free(slp); + } else { + /* layout does not have any screens, not much to do */ + ptr->driver = matches[0]; + for (i = 1; matches[i] ; i++) { + if (matches[i] != matches[0]) { + free(matches[i]); + } + } + } + } + + xf86Msg(X_DEFAULT, "Assigned the driver to the xf86ConfigLayout\n"); + + return ptr; +} diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c index 3b0896863..c665a2019 100644 --- a/xorg-server/hw/xfree86/common/xf86Bus.c +++ b/xorg-server/hw/xfree86/common/xf86Bus.c @@ -47,8 +47,9 @@ #define XF86_OS_PRIVS #include "xf86_OSproc.h" +#ifdef XSERVER_LIBPCIACCESS #include "xf86VGAarbiter.h" - +#endif /* Entity data */ EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */ int xf86NumEntities = 0; @@ -75,7 +76,7 @@ Bool xf86CallDriverProbe( DriverPtr drv, Bool detect_only ) { Bool foundScreen = FALSE; - +#ifdef XSERVER_LIBPCIACCESS if (drv->PciProbe != NULL) { if (xf86DoConfigure && xf86DoConfigurePass1) { assert(detect_only); @@ -86,7 +87,7 @@ xf86CallDriverProbe( DriverPtr drv, Bool detect_only ) foundScreen = xf86PciProbeDev(drv); } } - +#endif if (!foundScreen && (drv->Probe != NULL)) { xf86Msg( X_WARNING, "Falling back to old probe method for %s\n", drv->driverName); @@ -195,7 +196,9 @@ xf86BusConfig(void) void xf86BusProbe(void) { +#ifdef XSERVER_LIBPCIACCESS xf86PciProbe(); +#endif #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) xf86SbusProbe(); #endif @@ -308,7 +311,6 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex) pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList, pScrn->numEntities * sizeof(int)); pScrn->entityInstanceList[pScrn->numEntities - 1] = 0; - pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO; } void @@ -505,9 +507,14 @@ xf86PostProbe(void) { int i; - if (fbSlotClaimed && (pciSlotClaimed + if (fbSlotClaimed && ( #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) - || sbusSlotClaimed + sbusSlotClaimed || +#endif +#ifdef XSERVER_LIBPCIACCESS + pciSlotClaimed +#else + TRUE #endif )) FatalError("Cannot run in framebuffer mode. Please specify busIDs " diff --git a/xorg-server/hw/xfree86/common/xf86Bus.h b/xorg-server/hw/xfree86/common/xf86Bus.h index 4e3d7d7cb..0b2ebdb44 100644 --- a/xorg-server/hw/xfree86/common/xf86Bus.h +++ b/xorg-server/hw/xfree86/common/xf86Bus.h @@ -1,75 +1,74 @@ -/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains definitions of the bus-related data structures/types.
- * Everything contained here is private to xf86Bus.c. In particular the
- * video drivers must not include this file.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _XF86_BUS_H
-#define _XF86_BUS_H
-
-#include "xf86pciBus.h"
-#if defined(__sparc__) || defined(__sparc)
-#include "xf86sbusBus.h"
-#endif
-
-typedef struct {
- DriverPtr driver;
- int chipset;
- int entityProp;
- EntityProc entityInit;
- EntityProc entityEnter;
- EntityProc entityLeave;
- pointer private;
- Bool active;
- Bool inUse;
- BusRec bus;
- int lastScrnFlag;
- DevUnion * entityPrivates;
- int numInstances;
- GDevPtr * devices;
- IOADDRESS domainIO;
-} EntityRec, *EntityPtr;
-
-#define ACCEL_IS_SHARABLE 0x100
-#define IS_SHARED_ACCEL 0x200
-#define SA_PRIM_INIT_DONE 0x400
-
-extern EntityPtr *xf86Entities;
-extern int xf86NumEntities;
-extern BusRec primaryBus;
-
-int xf86AllocateEntity(void);
-BusType StringToBusType(const char* busID, const char **retID);
-
-#endif /* _XF86_BUS_H */
+/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains definitions of the bus-related data structures/types. + * Everything contained here is private to xf86Bus.c. In particular the + * video drivers must not include this file. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _XF86_BUS_H +#define _XF86_BUS_H + +#include "xf86pciBus.h" +#if defined(__sparc__) || defined(__sparc) +#include "xf86sbusBus.h" +#endif + +typedef struct { + DriverPtr driver; + int chipset; + int entityProp; + EntityProc entityInit; + EntityProc entityEnter; + EntityProc entityLeave; + pointer private; + Bool active; + Bool inUse; + BusRec bus; + int lastScrnFlag; + DevUnion * entityPrivates; + int numInstances; + GDevPtr * devices; +} EntityRec, *EntityPtr; + +#define ACCEL_IS_SHARABLE 0x100 +#define IS_SHARED_ACCEL 0x200 +#define SA_PRIM_INIT_DONE 0x400 + +extern EntityPtr *xf86Entities; +extern int xf86NumEntities; +extern BusRec primaryBus; + +int xf86AllocateEntity(void); +BusType StringToBusType(const char* busID, const char **retID); + +#endif /* _XF86_BUS_H */ diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c index f8c1b6567..5c46152b2 100644 --- a/xorg-server/hw/xfree86/common/xf86Config.c +++ b/xorg-server/hw/xfree86/common/xf86Config.c @@ -2398,7 +2398,7 @@ xf86HandleConfigFile(Bool autoconfig) } xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions); - +#ifdef XSERVER_LIBPCIACCESS if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) { ; /* IsolateDevice specified; overrides SingleCard */ } else { @@ -2413,7 +2413,7 @@ xf86HandleConfigFile(Bool autoconfig) } else xf86PciIsolateDevice(scanptr); } - +#endif /* Now process everything else */ if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){ ErrorF ("Problem when converting the config data structures\n"); diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c index ab0751507..99b8b48d7 100644 --- a/xorg-server/hw/xfree86/common/xf86Configure.c +++ b/xorg-server/hw/xfree86/common/xf86Configure.c @@ -87,9 +87,11 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int /* Check for duplicates */ for (i = 0; i < nDevToConfig; i++) { switch (bus) { +#ifdef XSERVER_LIBPCIACCESS case BUS_PCI: ret = xf86PciConfigure(busData, DevToConfig[i].pVideo); - break; + break; +#endif #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo); @@ -118,10 +120,12 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++); switch (bus) { +#ifdef XSERVER_LIBPCIACCESS case BUS_PCI: xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo, &DevToConfig[i].GDev, &chipset); break; +#endif #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo, diff --git a/xorg-server/hw/xfree86/common/xf86DPMS.c b/xorg-server/hw/xfree86/common/xf86DPMS.c index 1a8aed306..613c7cf73 100644 --- a/xorg-server/hw/xfree86/common/xf86DPMS.c +++ b/xorg-server/hw/xfree86/common/xf86DPMS.c @@ -1,197 +1,198 @@ -/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains the DPMS functions required by the extension.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "globals.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-#include "xf86VGAarbiter.h"
-
-
-#ifdef DPMSExtension
-static DevPrivateKeyRec DPMSKeyRec;
-static DevPrivateKey DPMSKey;
-static Bool DPMSClose(int i, ScreenPtr pScreen);
-static int DPMSCount = 0;
-#endif
-
-
-Bool
-xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
-{
-#ifdef DPMSExtension
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- DPMSPtr pDPMS;
- pointer DPMSOpt;
- MessageType enabled_from;
-
- DPMSKey = &DPMSKeyRec;
-
- if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof (DPMSRec)))
- return FALSE;
-
- pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
- pScrn->DPMSSet = set;
- pDPMS->Flags = flags;
- DPMSOpt = xf86FindOption(pScrn->options, "dpms");
- if (DPMSDisabledSwitch) {
- enabled_from = X_CMDLINE;
- DPMSEnabled = FALSE;
- }
- else if (DPMSOpt) {
- enabled_from = X_CONFIG;
- DPMSEnabled = xf86CheckBoolOption(pScrn->options, "dpms", FALSE);
- xf86MarkOptionUsed(DPMSOpt);
- }
- else {
- enabled_from = X_DEFAULT;
- DPMSEnabled = TRUE;
- }
- if (DPMSEnabled)
- xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n");
- pDPMS->Enabled = DPMSEnabled;
- pDPMS->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = DPMSClose;
- DPMSCount++;
- return TRUE;
-#else
- return FALSE;
-#endif
-}
-
-
-#ifdef DPMSExtension
-
-static Bool
-DPMSClose(int i, ScreenPtr pScreen)
-{
- DPMSPtr pDPMS;
-
- /* This shouldn't happen */
- if (DPMSKey == NULL)
- return FALSE;
-
- pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
-
- /* This shouldn't happen */
- if (!pDPMS)
- return FALSE;
-
- pScreen->CloseScreen = pDPMS->CloseScreen;
-
- /*
- * Turn on DPMS when shutting down. If this function can be used
- * depends on the order the driver wraps things. If this is called
- * after the driver has shut down everything the driver will have
- * to deal with this internally.
- */
- if (xf86Screens[i]->vtSema && xf86Screens[i]->DPMSSet) {
- xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0);
- }
-
- if (--DPMSCount == 0)
- DPMSKey = NULL;
- return pScreen->CloseScreen(i, pScreen);
-}
-
-
-/*
- * DPMSSet --
- * Device dependent DPMS mode setting hook. This is called whenever
- * the DPMS mode is to be changed.
- */
-int
-DPMSSet(ClientPtr client, int level)
-{
- int rc, i;
- DPMSPtr pDPMS;
- ScrnInfoPtr pScrn;
-
- DPMSPowerLevel = level;
-
- if (DPMSKey == NULL)
- return Success;
-
- if (level != DPMSModeOn) {
- rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive);
- if (rc != Success)
- return rc;
- }
-
- /* For each screen, set the DPMS level */
- for (i = 0; i < xf86NumScreens; i++) {
- pScrn = xf86Screens[i];
- pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey);
- if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) {
- xf86VGAarbiterLock(pScrn);
- pScrn->DPMSSet(pScrn, level, 0);
- xf86VGAarbiterUnlock(pScrn);
- }
- }
- return Success;
-}
-
-
-/*
- * DPMSSupported --
- * Return TRUE if any screen supports DPMS.
- */
-Bool
-DPMSSupported(void)
-{
- int i;
- DPMSPtr pDPMS;
- ScrnInfoPtr pScrn;
-
- if (DPMSKey == NULL) {
- return FALSE;
- }
-
- /* For each screen, check if DPMS is supported */
- for (i = 0; i < xf86NumScreens; i++) {
- pScrn = xf86Screens[i];
- pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey);
- if (pDPMS && pScrn->DPMSSet)
- return TRUE;
- }
- return FALSE;
-}
-
-#endif /* DPMSExtension */
+/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the DPMS functions required by the extension. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "globals.h" +#include "xf86.h" +#include "xf86Priv.h" +#ifdef DPMSExtension +#include <X11/extensions/dpmsconst.h> +#include "dpmsproc.h" +#endif +#ifdef XSERVER_LIBPCIACCESS +#include "xf86VGAarbiter.h" +#endif + +#ifdef DPMSExtension +static DevPrivateKeyRec DPMSKeyRec; +static DevPrivateKey DPMSKey; +static Bool DPMSClose(int i, ScreenPtr pScreen); +static int DPMSCount = 0; +#endif + + +Bool +xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) +{ +#ifdef DPMSExtension + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + DPMSPtr pDPMS; + pointer DPMSOpt; + MessageType enabled_from; + + DPMSKey = &DPMSKeyRec; + + if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof (DPMSRec))) + return FALSE; + + pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey); + pScrn->DPMSSet = set; + pDPMS->Flags = flags; + DPMSOpt = xf86FindOption(pScrn->options, "dpms"); + if (DPMSDisabledSwitch) { + enabled_from = X_CMDLINE; + DPMSEnabled = FALSE; + } + else if (DPMSOpt) { + enabled_from = X_CONFIG; + DPMSEnabled = xf86CheckBoolOption(pScrn->options, "dpms", FALSE); + xf86MarkOptionUsed(DPMSOpt); + } + else { + enabled_from = X_DEFAULT; + DPMSEnabled = TRUE; + } + if (DPMSEnabled) + xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n"); + pDPMS->Enabled = DPMSEnabled; + pDPMS->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = DPMSClose; + DPMSCount++; + return TRUE; +#else + return FALSE; +#endif +} + + +#ifdef DPMSExtension + +static Bool +DPMSClose(int i, ScreenPtr pScreen) +{ + DPMSPtr pDPMS; + + /* This shouldn't happen */ + if (DPMSKey == NULL) + return FALSE; + + pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey); + + /* This shouldn't happen */ + if (!pDPMS) + return FALSE; + + pScreen->CloseScreen = pDPMS->CloseScreen; + + /* + * Turn on DPMS when shutting down. If this function can be used + * depends on the order the driver wraps things. If this is called + * after the driver has shut down everything the driver will have + * to deal with this internally. + */ + if (xf86Screens[i]->vtSema && xf86Screens[i]->DPMSSet) { + xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0); + } + + if (--DPMSCount == 0) + DPMSKey = NULL; + return pScreen->CloseScreen(i, pScreen); +} + + +/* + * DPMSSet -- + * Device dependent DPMS mode setting hook. This is called whenever + * the DPMS mode is to be changed. + */ +int +DPMSSet(ClientPtr client, int level) +{ + int rc, i; + DPMSPtr pDPMS; + ScrnInfoPtr pScrn; + + DPMSPowerLevel = level; + + if (DPMSKey == NULL) + return Success; + + if (level != DPMSModeOn) { + rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive); + if (rc != Success) + return rc; + } + + /* For each screen, set the DPMS level */ + for (i = 0; i < xf86NumScreens; i++) { + pScrn = xf86Screens[i]; + pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey); + if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) { + xf86VGAarbiterLock(pScrn); + pScrn->DPMSSet(pScrn, level, 0); + xf86VGAarbiterUnlock(pScrn); + } + } + return Success; +} + + +/* + * DPMSSupported -- + * Return TRUE if any screen supports DPMS. + */ +Bool +DPMSSupported(void) +{ + int i; + DPMSPtr pDPMS; + ScrnInfoPtr pScrn; + + if (DPMSKey == NULL) { + return FALSE; + } + + /* For each screen, check if DPMS is supported */ + for (i = 0; i < xf86NumScreens; i++) { + pScrn = xf86Screens[i]; + pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey); + if (pDPMS && pScrn->DPMSSet) + return TRUE; + } + return FALSE; +} + +#endif /* DPMSExtension */ diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c index a8aa316ae..cf577522a 100644 --- a/xorg-server/hw/xfree86/common/xf86Helper.c +++ b/xorg-server/hw/xfree86/common/xf86Helper.c @@ -1353,96 +1353,6 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist) return i; } -/* - * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ... - */ -void -xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), - void (*ProtectRegs)(ScrnInfoPtr, Bool), - void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg, - int maskval, int knownclkindex, int knownclkvalue) -{ - register int status = vertsyncreg; - unsigned long i, cnt, rcnt, sync; - - /* First save registers that get written on */ - (*ClockFunc)(pScrn, CLK_REG_SAVE); - - if (num > MAXCLOCKS) - num = MAXCLOCKS; - - for (i = 0; i < num; i++) - { - if (ProtectRegs) - (*ProtectRegs)(pScrn, TRUE); - if (!(*ClockFunc)(pScrn, i)) - { - pScrn->clock[i] = -1; - continue; - } - if (ProtectRegs) - (*ProtectRegs)(pScrn, FALSE); - if (BlankScreen) - (*BlankScreen)(pScrn, FALSE); - - usleep(50000); /* let VCO stabilise */ - - cnt = 0; - sync = 200000; - - while ((inb(status) & maskval) == 0x00) - if (sync-- == 0) goto finish; - /* Something appears to be happening, so reset sync count */ - sync = 200000; - while ((inb(status) & maskval) == maskval) - if (sync-- == 0) goto finish; - /* Something appears to be happening, so reset sync count */ - sync = 200000; - while ((inb(status) & maskval) == 0x00) - if (sync-- == 0) goto finish; - - for (rcnt = 0; rcnt < 5; rcnt++) - { - while (!(inb(status) & maskval)) - cnt++; - while ((inb(status) & maskval)) - cnt++; - } - -finish: - pScrn->clock[i] = cnt ? cnt : -1; - if (BlankScreen) - (*BlankScreen)(pScrn, TRUE); - } - - for (i = 0; i < num; i++) - { - if (i != knownclkindex) - { - if (pScrn->clock[i] == -1) - { - pScrn->clock[i] = 0; - } - else - { - pScrn->clock[i] = (int)(0.5 + - (((float)knownclkvalue) * pScrn->clock[knownclkindex]) / - (pScrn->clock[i])); - /* Round to nearest 10KHz */ - pScrn->clock[i] += 5; - pScrn->clock[i] /= 10; - pScrn->clock[i] *= 10; - } - } - } - - pScrn->clock[knownclkindex] = knownclkvalue; - pScrn->numClocks = num; - - /* Restore registers that were written on */ - (*ClockFunc)(pScrn, CLK_REG_RESTORE); -} - const char * xf86GetVisualName(int visual) { diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c index 350918dfe..74e0bc220 100644 --- a/xorg-server/hw/xfree86/common/xf86Init.c +++ b/xorg-server/hw/xfree86/common/xf86Init.c @@ -78,7 +78,9 @@ #include "picturestr.h" #include "xf86Bus.h" +#ifdef XSERVER_LIBPCIACCESS #include "xf86VGAarbiter.h" +#endif #include "globals.h" #include "xserver-properties.h" @@ -88,7 +90,6 @@ #endif #include <hotplug.h> - #ifdef XF86PM void (*xf86OSPMClose)(void) = NULL; #endif @@ -1355,6 +1356,7 @@ ddxProcessArgument(int argc, char **argv, int i) xf86DoShowOptions = TRUE; return 1; } +#ifdef XSERVER_LIBPCIACCESS if (!strcmp(argv[i], "-isolateDevice")) { CHECK_FOR_REQUIRED_ARGUMENT(); @@ -1364,6 +1366,7 @@ ddxProcessArgument(int argc, char **argv, int i) xf86PciIsolateDevice(argv[i]); return 2; } +#endif /* Notice cmdline xkbdir, but pass to dix as well */ if (!strcmp(argv[i], "-xkbdir")) { @@ -1432,7 +1435,9 @@ ddxUseMsg(void) #endif ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n"); ErrorF("-ignoreABI make module ABI mismatches non-fatal\n"); +#ifdef XSERVER_LIBPCIACCESS ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n"); +#endif ErrorF("-version show the server version\n"); ErrorF("-showDefaultModulePath show the server default module path\n"); ErrorF("-showDefaultLibPath show the server default library path\n"); diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h index 330d87ae8..a9645e77b 100644 --- a/xorg-server/hw/xfree86/common/xf86Module.h +++ b/xorg-server/hw/xfree86/common/xf86Module.h @@ -82,7 +82,7 @@ typedef enum { * mask is 0xFFFF0000. */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) -#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(11, 0) +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(12, 0) #define ABI_XINPUT_VERSION SET_ABI_VERSION(14, 0) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(6, 0) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 6) diff --git a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c index 0aa6f2cf4..819ad6e7c 100644 --- a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c +++ b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c @@ -1,1127 +1,1112 @@ -/*
- * This code was stolen from RAC and adapted to control the legacy vga
- * interface.
- *
- *
- * Copyright (c) 2007 Paulo R. Zanoni, Tiago Vignatti
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include "xorg-config.h"
-
-#include "xf86VGAarbiter.h"
-
-#ifdef HAVE_PCI_DEVICE_VGAARB_INIT
-#include "xf86VGAarbiterPriv.h"
-#include "xf86Bus.h"
-#include "xf86Priv.h"
-#include "pciaccess.h"
-
-
-static GCFuncs VGAarbiterGCFuncs = {
- VGAarbiterValidateGC, VGAarbiterChangeGC, VGAarbiterCopyGC,
- VGAarbiterDestroyGC, VGAarbiterChangeClip, VGAarbiterDestroyClip,
- VGAarbiterCopyClip
-};
-
-static GCOps VGAarbiterGCOps = {
- VGAarbiterFillSpans, VGAarbiterSetSpans, VGAarbiterPutImage,
- VGAarbiterCopyArea, VGAarbiterCopyPlane, VGAarbiterPolyPoint,
- VGAarbiterPolylines, VGAarbiterPolySegment, VGAarbiterPolyRectangle,
- VGAarbiterPolyArc, VGAarbiterFillPolygon, VGAarbiterPolyFillRect,
- VGAarbiterPolyFillArc, VGAarbiterPolyText8, VGAarbiterPolyText16,
- VGAarbiterImageText8, VGAarbiterImageText16, VGAarbiterImageGlyphBlt,
- VGAarbiterPolyGlyphBlt, VGAarbiterPushPixels,
-};
-
-static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = {
- VGAarbiterSpriteRealizeCursor, VGAarbiterSpriteUnrealizeCursor,
- VGAarbiterSpriteSetCursor, VGAarbiterSpriteMoveCursor,
- VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup
-};
-
-static DevPrivateKeyRec VGAarbiterScreenKeyRec;
-#define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
-static DevPrivateKeyRec VGAarbiterGCKeyRec;
-#define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
-
-static int vga_no_arb = 0;
-void
-xf86VGAarbiterInit(void)
-{
- if (pci_device_vgaarb_init() != 0) {
- vga_no_arb = 1;
- xf86Msg(X_WARNING, "VGA arbiter: cannot open kernel arbiter, no multi-card support\n");
- }
-}
-
-void
-xf86VGAarbiterFini(void)
-{
- if (vga_no_arb)
- return;
- pci_device_vgaarb_fini();
-}
-
-void
-xf86VGAarbiterLock(ScrnInfoPtr pScrn)
-{
- if (vga_no_arb)
- return;
- pci_device_vgaarb_set_target(pScrn->vgaDev);
- pci_device_vgaarb_lock();
-}
-
-void
-xf86VGAarbiterUnlock(ScrnInfoPtr pScrn)
-{
- if (vga_no_arb)
- return;
- pci_device_vgaarb_unlock();
-}
-
-Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
-{
- int vga_count;
- int rsrc_decodes;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- if (vga_no_arb)
- return TRUE;
-
- pci_device_vgaarb_get_info(pScrn->vgaDev, &vga_count, &rsrc_decodes);
- if (vga_count > 1) {
- if (rsrc_decodes) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-void
-xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn)
-{
- struct pci_device *dev;
- EntityPtr pEnt;
-
- if (vga_no_arb)
- return;
-
- pEnt = xf86Entities[pScrn->entityList[0]];
- if (pEnt->bus.type != BUS_PCI)
- return;
-
- dev = pEnt->bus.id.pci;
- pScrn->vgaDev = dev;
-}
-
-void
-xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc)
-{
- if (vga_no_arb)
- return;
- pci_device_vgaarb_set_target(pScrn->vgaDev);
- pci_device_vgaarb_decodes(rsrc);
-}
-
-Bool
-xf86VGAarbiterWrapFunctions(void)
-{
- ScrnInfoPtr pScrn;
- VGAarbiterScreenPtr pScreenPriv;
- miPointerScreenPtr PointPriv;
- PictureScreenPtr ps;
- ScreenPtr pScreen;
- int vga_count, i;
-
- if (vga_no_arb)
- return FALSE;
-
- /*
- * we need to wrap the arbiter if we have more than
- * one VGA card - hotplug cries.
- */
- pci_device_vgaarb_get_info(NULL, &vga_count, NULL);
- if (vga_count < 2 || !xf86Screens)
- return FALSE;
-
- xf86Msg(X_INFO,"Found %d VGA devices: arbiter wrapping enabled\n",
- vga_count);
-
- for (i = 0; i < xf86NumScreens; i++) {
- pScreen = xf86Screens[i]->pScreen;
- ps = GetPictureScreenIfSet(pScreen);
- pScrn = xf86Screens[pScreen->myNum];
- PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
-
- if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec))))
- return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv);
-
- WRAP_SCREEN(CloseScreen, VGAarbiterCloseScreen);
- WRAP_SCREEN(SaveScreen, VGAarbiterSaveScreen);
- WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler);
- WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler);
- WRAP_SCREEN(CreateGC, VGAarbiterCreateGC);
- WRAP_SCREEN(GetImage, VGAarbiterGetImage);
- WRAP_SCREEN(GetSpans, VGAarbiterGetSpans);
- WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate);
- WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow);
- WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground);
- WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap);
- WRAP_SCREEN(StoreColors, VGAarbiterStoreColors);
- WRAP_SCREEN(DisplayCursor, VGAarbiterDisplayCursor);
- WRAP_SCREEN(RealizeCursor, VGAarbiterRealizeCursor);
- WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor);
- WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor);
- WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition);
- WRAP_PICT(Composite,VGAarbiterComposite);
- WRAP_PICT(Glyphs,VGAarbiterGlyphs);
- WRAP_PICT(CompositeRects,VGAarbiterCompositeRects);
- WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame);
- WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode);
- WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT);
- WRAP_SCREEN_INFO(LeaveVT, VGAarbiterLeaveVT);
- WRAP_SCREEN_INFO(FreeScreen, VGAarbiterFreeScreen);
- WRAP_SPRITE;
- }
-
- return TRUE;
-}
-
-/* Screen funcs */
-static Bool
-VGAarbiterCloseScreen (int i, ScreenPtr pScreen)
-{
- Bool val;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
- miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, miPointerScreenKey);
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-
- UNWRAP_SCREEN(CreateGC);
- UNWRAP_SCREEN(CloseScreen);
- UNWRAP_SCREEN(GetImage);
- UNWRAP_SCREEN(GetSpans);
- UNWRAP_SCREEN(SourceValidate);
- UNWRAP_SCREEN(CopyWindow);
- UNWRAP_SCREEN(ClearToBackground);
- UNWRAP_SCREEN(SaveScreen);
- UNWRAP_SCREEN(StoreColors);
- UNWRAP_SCREEN(DisplayCursor);
- UNWRAP_SCREEN(RealizeCursor);
- UNWRAP_SCREEN(UnrealizeCursor);
- UNWRAP_SCREEN(RecolorCursor);
- UNWRAP_SCREEN(SetCursorPosition);
- UNWRAP_PICT(Composite);
- UNWRAP_PICT(Glyphs);
- UNWRAP_PICT(CompositeRects);
- UNWRAP_SCREEN_INFO(AdjustFrame);
- UNWRAP_SCREEN_INFO(SwitchMode);
- UNWRAP_SCREEN_INFO(EnterVT);
- UNWRAP_SCREEN_INFO(LeaveVT);
- UNWRAP_SCREEN_INFO(FreeScreen);
- UNWRAP_SPRITE;
-
- free((pointer) pScreenPriv);
- xf86VGAarbiterLock(xf86Screens[i]);
- val = (*pScreen->CloseScreen) (i, pScreen);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- return val;
-}
-
-static void
-VGAarbiterBlockHandler(int i,
- pointer blockData, pointer pTimeout, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[i];
- SCREEN_PROLOG(BlockHandler);
- VGAGet(pScreen);
- pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
- VGAPut();
- SCREEN_EPILOG(BlockHandler, VGAarbiterBlockHandler);
-}
-
-static void
-VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[i];
- SCREEN_PROLOG(WakeupHandler);
- VGAGet(pScreen);
- pScreen->WakeupHandler(i, blockData, result, pReadmask);
- VGAPut();
- SCREEN_EPILOG(WakeupHandler, VGAarbiterWakeupHandler);
-}
-
-static void
-VGAarbiterGetImage (
- DrawablePtr pDrawable,
- int sx, int sy, int w, int h,
- unsigned int format,
- unsigned long planemask,
- char *pdstLine
- )
-{
- ScreenPtr pScreen = pDrawable->pScreen;
- SCREEN_PROLOG(GetImage);
-// if (xf86Screens[pScreen->myNum]->vtSema) {
- VGAGet(pScreen);
-// }
- (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
- format, planemask, pdstLine);
- VGAPut();
- SCREEN_EPILOG (GetImage, VGAarbiterGetImage);
-}
-
-static void
-VGAarbiterGetSpans (
- DrawablePtr pDrawable,
- int wMax,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- char *pdstStart
- )
-{
- ScreenPtr pScreen = pDrawable->pScreen;
-
- SCREEN_PROLOG (GetSpans);
- VGAGet(pScreen);
- (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
- VGAPut();
- SCREEN_EPILOG (GetSpans, VGAarbiterGetSpans);
-}
-
-static void
-VGAarbiterSourceValidate (
- DrawablePtr pDrawable,
- int x, int y, int width, int height,
- unsigned int subWindowMode )
-{
- ScreenPtr pScreen = pDrawable->pScreen;
- SCREEN_PROLOG (SourceValidate);
- VGAGet(pScreen);
- if (pScreen->SourceValidate)
- (*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode);
- VGAPut();
- SCREEN_EPILOG (SourceValidate, VGAarbiterSourceValidate);
-}
-
-static void
-VGAarbiterCopyWindow(
- WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc )
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- SCREEN_PROLOG (CopyWindow);
- VGAGet(pScreen);
- (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
- VGAPut();
- SCREEN_EPILOG (CopyWindow, VGAarbiterCopyWindow);
-}
-
-static void
-VGAarbiterClearToBackground (
- WindowPtr pWin,
- int x, int y,
- int w, int h,
- Bool generateExposures )
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- SCREEN_PROLOG ( ClearToBackground);
- VGAGet(pScreen);
- (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures);
- VGAPut();
- SCREEN_EPILOG (ClearToBackground, VGAarbiterClearToBackground);
-}
-
-static PixmapPtr
-VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
-{
- PixmapPtr pPix;
-
- SCREEN_PROLOG ( CreatePixmap);
- VGAGet(pScreen);
- pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
- VGAPut();
- SCREEN_EPILOG (CreatePixmap, VGAarbiterCreatePixmap);
-
- return pPix;
-}
-
-static Bool
-VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank)
-{
- Bool val;
-
- SCREEN_PROLOG (SaveScreen);
- VGAGet(pScreen);
- val = (*pScreen->SaveScreen) (pScreen, unblank);
- VGAPut();
- SCREEN_EPILOG (SaveScreen, VGAarbiterSaveScreen);
-
- return val;
-}
-
-static void
-VGAarbiterStoreColors (
- ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs)
-{
- ScreenPtr pScreen = pmap->pScreen;
-
- SCREEN_PROLOG (StoreColors);
- VGAGet(pScreen);
- (*pScreen->StoreColors) (pmap,ndef,pdefs);
- VGAPut();
- SCREEN_EPILOG ( StoreColors, VGAarbiterStoreColors);
-}
-
-static void
-VGAarbiterRecolorCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCurs,
- Bool displayed
- )
-{
- SCREEN_PROLOG (RecolorCursor);
- VGAGet(pScreen);
- (*pScreen->RecolorCursor) (pDev, pScreen, pCurs, displayed);
- VGAPut();
- SCREEN_EPILOG ( RecolorCursor, VGAarbiterRecolorCursor);
-}
-
-static Bool
-VGAarbiterRealizeCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
-{
- Bool val;
-
- SCREEN_PROLOG (RealizeCursor);
- VGAGet(pScreen);
- val = (*pScreen->RealizeCursor) (pDev, pScreen,pCursor);
- VGAPut();
- SCREEN_EPILOG ( RealizeCursor, VGAarbiterRealizeCursor);
- return val;
-}
-
-static Bool
-VGAarbiterUnrealizeCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
-{
- Bool val;
-
- SCREEN_PROLOG (UnrealizeCursor);
- VGAGet(pScreen);
- val = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
- VGAPut();
- SCREEN_EPILOG ( UnrealizeCursor, VGAarbiterUnrealizeCursor);
- return val;
-}
-
-static Bool
-VGAarbiterDisplayCursor (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor
- )
-{
- Bool val;
-
- SCREEN_PROLOG (DisplayCursor);
- VGAGet(pScreen);
- val = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
- VGAPut();
- SCREEN_EPILOG ( DisplayCursor, VGAarbiterDisplayCursor);
- return val;
-}
-
-static Bool
-VGAarbiterSetCursorPosition (
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- int x, int y,
- Bool generateEvent)
-{
- Bool val;
-
- SCREEN_PROLOG (SetCursorPosition);
- VGAGet(pScreen);
- val = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
- VGAPut();
- SCREEN_EPILOG ( SetCursorPosition, VGAarbiterSetCursorPosition);
- return val;
-}
-
-static void
-VGAarbiterAdjustFrame(int index, int x, int y, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- (*pScreenPriv->AdjustFrame)(index, x, y, flags);
- VGAPut();
-}
-
-static Bool
-VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags)
-{
- Bool val;
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- val = (*pScreenPriv->SwitchMode)(index, mode, flags);
- VGAPut();
- return val;
-}
-
-static Bool
-VGAarbiterEnterVT(int index, int flags)
-{
- Bool val;
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- pScrn->EnterVT = pScreenPriv->EnterVT;
- val = (*pScrn->EnterVT)(index, flags);
- pScreenPriv->EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = VGAarbiterEnterVT;
- VGAPut();
- return val;
-}
-
-static void
-VGAarbiterLeaveVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- pScrn->LeaveVT = pScreenPriv->LeaveVT;
- (*pScreenPriv->LeaveVT)(index, flags);
- pScreenPriv->LeaveVT = pScrn->LeaveVT;
- pScrn->LeaveVT = VGAarbiterLeaveVT;
- VGAPut();
-}
-
-static void
-VGAarbiterFreeScreen(int index, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[index];
- VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, VGAarbiterScreenKey);
-
- VGAGet(pScreen);
- (*pScreenPriv->FreeScreen)(index, flags);
- VGAPut();
-}
-
-static Bool
-VGAarbiterCreateGC(GCPtr pGC)
-{
- ScreenPtr pScreen = pGC->pScreen;
- VGAarbiterGCPtr pGCPriv = (VGAarbiterGCPtr)dixLookupPrivate(&pGC->devPrivates, VGAarbiterGCKey);
- Bool ret;
-
- SCREEN_PROLOG(CreateGC);
- ret = (*pScreen->CreateGC)(pGC);
- GC_WRAP(pGC);
- SCREEN_EPILOG(CreateGC,VGAarbiterCreateGC);
-
- return ret;
-}
-
-/* GC funcs */
-static void
-VGAarbiterValidateGC(
- GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDraw )
-{
- GC_UNWRAP(pGC);
- (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
- GC_WRAP(pGC);
-}
-
-
-static void
-VGAarbiterDestroyGC(GCPtr pGC)
-{
- GC_UNWRAP (pGC);
- (*pGC->funcs->DestroyGC)(pGC);
- GC_WRAP (pGC);
-}
-
-static void
-VGAarbiterChangeGC (
- GCPtr pGC,
- unsigned long mask)
-{
- GC_UNWRAP (pGC);
- (*pGC->funcs->ChangeGC) (pGC, mask);
- GC_WRAP (pGC);
-}
-
-static void
-VGAarbiterCopyGC (
- GCPtr pGCSrc,
- unsigned long mask,
- GCPtr pGCDst)
-{
- GC_UNWRAP (pGCDst);
- (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
- GC_WRAP (pGCDst);
-}
-
-static void
-VGAarbiterChangeClip (
- GCPtr pGC,
- int type,
- pointer pvalue,
- int nrects )
-{
- GC_UNWRAP (pGC);
- (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
- GC_WRAP (pGC);
-}
-
-static void
-VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
- GC_UNWRAP (pgcDst);
- (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
- GC_WRAP (pgcDst);
-}
-
-static void
-VGAarbiterDestroyClip(GCPtr pGC)
-{
- GC_UNWRAP (pGC);
- (* pGC->funcs->DestroyClip)(pGC);
- GC_WRAP (pGC);
-}
-
-/* GC Ops */
-static void
-VGAarbiterFillSpans(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit,
- DDXPointPtr pptInit,
- int *pwidthInit,
- int fSorted )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterSetSpans(
- DrawablePtr pDraw,
- GCPtr pGC,
- char *pcharsrc,
- register DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPutImage(
- DrawablePtr pDraw,
- GCPtr pGC,
- int depth,
- int x, int y, int w, int h,
- int leftPad,
- int format,
- char *pImage )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
- leftPad, format, pImage);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static RegionPtr
-VGAarbiterCopyArea(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GC *pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty )
-{
- RegionPtr ret;
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- ret = (*pGC->ops->CopyArea)(pSrc, pDst,
- pGC, srcx, srcy, width, height, dstx, dsty);
- VGAPut();
- GC_WRAP(pGC);
- return ret;
-}
-
-static RegionPtr
-VGAarbiterCopyPlane(
- DrawablePtr pSrc,
- DrawablePtr pDst,
- GCPtr pGC,
- int srcx, int srcy,
- int width, int height,
- int dstx, int dsty,
- unsigned long bitPlane )
-{
- RegionPtr ret;
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy,
- width, height, dstx, dsty, bitPlane);
- VGAPut();
- GC_WRAP(pGC);
- return ret;
-}
-
-static void
-VGAarbiterPolyPoint(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- xPoint *pptInit )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-
-static void
-VGAarbiterPolylines(
- DrawablePtr pDraw,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pptInit )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolySegment(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyRectangle(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterFillPolygon(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill,
- xRectangle *prectInit)
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyFillArc(
- DrawablePtr pDraw,
- GCPtr pGC,
- int narcs,
- xArc *parcs )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static int
-VGAarbiterPolyText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
-{
- int ret;
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
- VGAPut();
- GC_WRAP(pGC);
- return ret;
-}
-
-static int
-VGAarbiterPolyText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
-{
- int ret;
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
- VGAPut();
- GC_WRAP(pGC);
- return ret;
-}
-
-static void
-VGAarbiterImageText8(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- char *chars )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterImageText16(
- DrawablePtr pDraw,
- GCPtr pGC,
- int x,
- int y,
- int count,
- unsigned short *chars )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-
-static void
-VGAarbiterImageGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit,
- nglyph, ppci, pglyphBase);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPolyGlyphBlt(
- DrawablePtr pDraw,
- GCPtr pGC,
- int xInit, int yInit,
- unsigned int nglyph,
- CharInfoPtr *ppci,
- pointer pglyphBase )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit,
- nglyph, ppci, pglyphBase);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-static void
-VGAarbiterPushPixels(
- GCPtr pGC,
- PixmapPtr pBitMap,
- DrawablePtr pDraw,
- int dx, int dy, int xOrg, int yOrg )
-{
- ScreenPtr pScreen = pGC->pScreen;
- GC_UNWRAP(pGC);
- VGAGet(pScreen);
- (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
- VGAPut();
- GC_WRAP(pGC);
-}
-
-
-/* miSpriteFuncs */
-static Bool
-VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur)
-{
- Bool val;
- SPRITE_PROLOG;
- VGAGet(pScreen);
- val = PointPriv->spriteFuncs->RealizeCursor(pDev, pScreen, pCur);
- VGAPut();
- SPRITE_EPILOG;
- return val;
-}
-
-static Bool
-VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur)
-{
- Bool val;
- SPRITE_PROLOG;
- VGAGet(pScreen);
- val = PointPriv->spriteFuncs->UnrealizeCursor(pDev, pScreen, pCur);
- VGAPut();
- SPRITE_EPILOG;
- return val;
-}
-
-static void
-VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur, int x, int y)
-{
- SPRITE_PROLOG;
- VGAGet(pScreen);
- PointPriv->spriteFuncs->SetCursor(pDev, pScreen, pCur, x, y);
- VGAPut();
- SPRITE_EPILOG;
-}
-
-static void
-VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- SPRITE_PROLOG;
- VGAGet(pScreen);
- PointPriv->spriteFuncs->MoveCursor(pDev, pScreen, x, y);
- VGAPut();
- SPRITE_EPILOG;
-}
-
-static Bool
-VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
- Bool val;
- SPRITE_PROLOG;
- VGAGet(pScreen);
- val = PointPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
- VGAPut();
- SPRITE_EPILOG;
- return val;
-}
-
-static void
-VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
- SPRITE_PROLOG;
- VGAGet(pScreen);
- PointPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen);
- VGAPut();
- SPRITE_EPILOG;
-}
-
-static void
-VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
- PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask,
- INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width,
- CARD16 height)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-
- PICTURE_PROLOGUE(Composite);
-
- VGAGet(pScreen);
- (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst,
- yDst, width, height);
- VGAPut();
- PICTURE_EPILOGUE(Composite, VGAarbiterComposite);
-}
-
-static void
-VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
- PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
- GlyphListPtr list, GlyphPtr *glyphs)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-
- PICTURE_PROLOGUE(Glyphs);
-
- VGAGet(pScreen);
- (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
- VGAPut();
- PICTURE_EPILOGUE (Glyphs, VGAarbiterGlyphs);
-}
-
-static void
-VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect,
- xRectangle *rects)
-{
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
- PictureScreenPtr ps = GetPictureScreen(pScreen);
-
- PICTURE_PROLOGUE(CompositeRects);
-
- VGAGet(pScreen);
- (*ps->CompositeRects)(op, pDst, color, nRect, rects);
- VGAPut();
- PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
-}
-#else
-/* dummy functions */
-void xf86VGAarbiterInit(void) {}
-void xf86VGAarbiterFini(void) {}
-
-void xf86VGAarbiterLock(ScrnInfoPtr pScrn) {}
-void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) {}
-Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen) { return TRUE; }
-void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) {}
-void xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc) {}
-Bool xf86VGAarbiterWrapFunctions(void) { return FALSE; }
-
-#endif
+/* + * This code was stolen from RAC and adapted to control the legacy vga + * interface. + * + * + * Copyright (c) 2007 Paulo R. Zanoni, Tiago Vignatti + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include "xorg-config.h" + +#include "xf86VGAarbiter.h" +#include "xf86VGAarbiterPriv.h" +#include "xf86Bus.h" +#include "xf86Priv.h" +#include "pciaccess.h" + + +static GCFuncs VGAarbiterGCFuncs = { + VGAarbiterValidateGC, VGAarbiterChangeGC, VGAarbiterCopyGC, + VGAarbiterDestroyGC, VGAarbiterChangeClip, VGAarbiterDestroyClip, + VGAarbiterCopyClip +}; + +static GCOps VGAarbiterGCOps = { + VGAarbiterFillSpans, VGAarbiterSetSpans, VGAarbiterPutImage, + VGAarbiterCopyArea, VGAarbiterCopyPlane, VGAarbiterPolyPoint, + VGAarbiterPolylines, VGAarbiterPolySegment, VGAarbiterPolyRectangle, + VGAarbiterPolyArc, VGAarbiterFillPolygon, VGAarbiterPolyFillRect, + VGAarbiterPolyFillArc, VGAarbiterPolyText8, VGAarbiterPolyText16, + VGAarbiterImageText8, VGAarbiterImageText16, VGAarbiterImageGlyphBlt, + VGAarbiterPolyGlyphBlt, VGAarbiterPushPixels, +}; + +static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = { + VGAarbiterSpriteRealizeCursor, VGAarbiterSpriteUnrealizeCursor, + VGAarbiterSpriteSetCursor, VGAarbiterSpriteMoveCursor, + VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup +}; + +static DevPrivateKeyRec VGAarbiterScreenKeyRec; +#define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec) +static DevPrivateKeyRec VGAarbiterGCKeyRec; +#define VGAarbiterGCKey (&VGAarbiterGCKeyRec) + +static int vga_no_arb = 0; +void +xf86VGAarbiterInit(void) +{ + if (pci_device_vgaarb_init() != 0) { + vga_no_arb = 1; + xf86Msg(X_WARNING, "VGA arbiter: cannot open kernel arbiter, no multi-card support\n"); + } +} + +void +xf86VGAarbiterFini(void) +{ + if (vga_no_arb) + return; + pci_device_vgaarb_fini(); +} + +void +xf86VGAarbiterLock(ScrnInfoPtr pScrn) +{ + if (vga_no_arb) + return; + pci_device_vgaarb_set_target(pScrn->vgaDev); + pci_device_vgaarb_lock(); +} + +void +xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) +{ + if (vga_no_arb) + return; + pci_device_vgaarb_unlock(); +} + +Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen) +{ + int vga_count; + int rsrc_decodes; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if (vga_no_arb) + return TRUE; + + pci_device_vgaarb_get_info(pScrn->vgaDev, &vga_count, &rsrc_decodes); + if (vga_count > 1) { + if (rsrc_decodes) { + return FALSE; + } + } + return TRUE; +} + +void +xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) +{ + struct pci_device *dev; + EntityPtr pEnt; + + if (vga_no_arb) + return; + + pEnt = xf86Entities[pScrn->entityList[0]]; + if (pEnt->bus.type != BUS_PCI) + return; + + dev = pEnt->bus.id.pci; + pScrn->vgaDev = dev; +} + +void +xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc) +{ + if (vga_no_arb) + return; + pci_device_vgaarb_set_target(pScrn->vgaDev); + pci_device_vgaarb_decodes(rsrc); +} + +Bool +xf86VGAarbiterWrapFunctions(void) +{ + ScrnInfoPtr pScrn; + VGAarbiterScreenPtr pScreenPriv; + miPointerScreenPtr PointPriv; + PictureScreenPtr ps; + ScreenPtr pScreen; + int vga_count, i; + + if (vga_no_arb) + return FALSE; + + /* + * we need to wrap the arbiter if we have more than + * one VGA card - hotplug cries. + */ + pci_device_vgaarb_get_info(NULL, &vga_count, NULL); + if (vga_count < 2 || !xf86Screens) + return FALSE; + + xf86Msg(X_INFO,"Found %d VGA devices: arbiter wrapping enabled\n", + vga_count); + + for (i = 0; i < xf86NumScreens; i++) { + pScreen = xf86Screens[i]->pScreen; + ps = GetPictureScreenIfSet(pScreen); + pScrn = xf86Screens[pScreen->myNum]; + PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); + + if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec))) + return FALSE; + + if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec)))) + return FALSE; + + dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv); + + WRAP_SCREEN(CloseScreen, VGAarbiterCloseScreen); + WRAP_SCREEN(SaveScreen, VGAarbiterSaveScreen); + WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler); + WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler); + WRAP_SCREEN(CreateGC, VGAarbiterCreateGC); + WRAP_SCREEN(GetImage, VGAarbiterGetImage); + WRAP_SCREEN(GetSpans, VGAarbiterGetSpans); + WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate); + WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow); + WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground); + WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap); + WRAP_SCREEN(StoreColors, VGAarbiterStoreColors); + WRAP_SCREEN(DisplayCursor, VGAarbiterDisplayCursor); + WRAP_SCREEN(RealizeCursor, VGAarbiterRealizeCursor); + WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor); + WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor); + WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition); + WRAP_PICT(Composite,VGAarbiterComposite); + WRAP_PICT(Glyphs,VGAarbiterGlyphs); + WRAP_PICT(CompositeRects,VGAarbiterCompositeRects); + WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame); + WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode); + WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT); + WRAP_SCREEN_INFO(LeaveVT, VGAarbiterLeaveVT); + WRAP_SCREEN_INFO(FreeScreen, VGAarbiterFreeScreen); + WRAP_SPRITE; + } + + return TRUE; +} + +/* Screen funcs */ +static Bool +VGAarbiterCloseScreen (int i, ScreenPtr pScreen) +{ + Bool val; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, VGAarbiterScreenKey); + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); + + UNWRAP_SCREEN(CreateGC); + UNWRAP_SCREEN(CloseScreen); + UNWRAP_SCREEN(GetImage); + UNWRAP_SCREEN(GetSpans); + UNWRAP_SCREEN(SourceValidate); + UNWRAP_SCREEN(CopyWindow); + UNWRAP_SCREEN(ClearToBackground); + UNWRAP_SCREEN(SaveScreen); + UNWRAP_SCREEN(StoreColors); + UNWRAP_SCREEN(DisplayCursor); + UNWRAP_SCREEN(RealizeCursor); + UNWRAP_SCREEN(UnrealizeCursor); + UNWRAP_SCREEN(RecolorCursor); + UNWRAP_SCREEN(SetCursorPosition); + UNWRAP_PICT(Composite); + UNWRAP_PICT(Glyphs); + UNWRAP_PICT(CompositeRects); + UNWRAP_SCREEN_INFO(AdjustFrame); + UNWRAP_SCREEN_INFO(SwitchMode); + UNWRAP_SCREEN_INFO(EnterVT); + UNWRAP_SCREEN_INFO(LeaveVT); + UNWRAP_SCREEN_INFO(FreeScreen); + UNWRAP_SPRITE; + + free((pointer) pScreenPriv); + xf86VGAarbiterLock(xf86Screens[i]); + val = (*pScreen->CloseScreen) (i, pScreen); + xf86VGAarbiterUnlock(xf86Screens[i]); + return val; +} + +static void +VGAarbiterBlockHandler(int i, + pointer blockData, pointer pTimeout, pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[i]; + SCREEN_PROLOG(BlockHandler); + VGAGet(pScreen); + pScreen->BlockHandler(i, blockData, pTimeout, pReadmask); + VGAPut(); + SCREEN_EPILOG(BlockHandler, VGAarbiterBlockHandler); +} + +static void +VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[i]; + SCREEN_PROLOG(WakeupHandler); + VGAGet(pScreen); + pScreen->WakeupHandler(i, blockData, result, pReadmask); + VGAPut(); + SCREEN_EPILOG(WakeupHandler, VGAarbiterWakeupHandler); +} + +static void +VGAarbiterGetImage ( + DrawablePtr pDrawable, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planemask, + char *pdstLine + ) +{ + ScreenPtr pScreen = pDrawable->pScreen; + SCREEN_PROLOG(GetImage); +// if (xf86Screens[pScreen->myNum]->vtSema) { + VGAGet(pScreen); +// } + (*pScreen->GetImage) (pDrawable, sx, sy, w, h, + format, planemask, pdstLine); + VGAPut(); + SCREEN_EPILOG (GetImage, VGAarbiterGetImage); +} + +static void +VGAarbiterGetSpans ( + DrawablePtr pDrawable, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, + char *pdstStart + ) +{ + ScreenPtr pScreen = pDrawable->pScreen; + + SCREEN_PROLOG (GetSpans); + VGAGet(pScreen); + (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); + VGAPut(); + SCREEN_EPILOG (GetSpans, VGAarbiterGetSpans); +} + +static void +VGAarbiterSourceValidate ( + DrawablePtr pDrawable, + int x, int y, int width, int height, + unsigned int subWindowMode ) +{ + ScreenPtr pScreen = pDrawable->pScreen; + SCREEN_PROLOG (SourceValidate); + VGAGet(pScreen); + if (pScreen->SourceValidate) + (*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode); + VGAPut(); + SCREEN_EPILOG (SourceValidate, VGAarbiterSourceValidate); +} + +static void +VGAarbiterCopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc ) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + SCREEN_PROLOG (CopyWindow); + VGAGet(pScreen); + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); + VGAPut(); + SCREEN_EPILOG (CopyWindow, VGAarbiterCopyWindow); +} + +static void +VGAarbiterClearToBackground ( + WindowPtr pWin, + int x, int y, + int w, int h, + Bool generateExposures ) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + SCREEN_PROLOG ( ClearToBackground); + VGAGet(pScreen); + (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures); + VGAPut(); + SCREEN_EPILOG (ClearToBackground, VGAarbiterClearToBackground); +} + +static PixmapPtr +VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint) +{ + PixmapPtr pPix; + + SCREEN_PROLOG ( CreatePixmap); + VGAGet(pScreen); + pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint); + VGAPut(); + SCREEN_EPILOG (CreatePixmap, VGAarbiterCreatePixmap); + + return pPix; +} + +static Bool +VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank) +{ + Bool val; + + SCREEN_PROLOG (SaveScreen); + VGAGet(pScreen); + val = (*pScreen->SaveScreen) (pScreen, unblank); + VGAPut(); + SCREEN_EPILOG (SaveScreen, VGAarbiterSaveScreen); + + return val; +} + +static void +VGAarbiterStoreColors ( + ColormapPtr pmap, + int ndef, + xColorItem *pdefs) +{ + ScreenPtr pScreen = pmap->pScreen; + + SCREEN_PROLOG (StoreColors); + VGAGet(pScreen); + (*pScreen->StoreColors) (pmap,ndef,pdefs); + VGAPut(); + SCREEN_EPILOG ( StoreColors, VGAarbiterStoreColors); +} + +static void +VGAarbiterRecolorCursor ( + DeviceIntPtr pDev, + ScreenPtr pScreen, + CursorPtr pCurs, + Bool displayed + ) +{ + SCREEN_PROLOG (RecolorCursor); + VGAGet(pScreen); + (*pScreen->RecolorCursor) (pDev, pScreen, pCurs, displayed); + VGAPut(); + SCREEN_EPILOG ( RecolorCursor, VGAarbiterRecolorCursor); +} + +static Bool +VGAarbiterRealizeCursor ( + DeviceIntPtr pDev, + ScreenPtr pScreen, + CursorPtr pCursor + ) +{ + Bool val; + + SCREEN_PROLOG (RealizeCursor); + VGAGet(pScreen); + val = (*pScreen->RealizeCursor) (pDev, pScreen,pCursor); + VGAPut(); + SCREEN_EPILOG ( RealizeCursor, VGAarbiterRealizeCursor); + return val; +} + +static Bool +VGAarbiterUnrealizeCursor ( + DeviceIntPtr pDev, + ScreenPtr pScreen, + CursorPtr pCursor + ) +{ + Bool val; + + SCREEN_PROLOG (UnrealizeCursor); + VGAGet(pScreen); + val = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor); + VGAPut(); + SCREEN_EPILOG ( UnrealizeCursor, VGAarbiterUnrealizeCursor); + return val; +} + +static Bool +VGAarbiterDisplayCursor ( + DeviceIntPtr pDev, + ScreenPtr pScreen, + CursorPtr pCursor + ) +{ + Bool val; + + SCREEN_PROLOG (DisplayCursor); + VGAGet(pScreen); + val = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor); + VGAPut(); + SCREEN_EPILOG ( DisplayCursor, VGAarbiterDisplayCursor); + return val; +} + +static Bool +VGAarbiterSetCursorPosition ( + DeviceIntPtr pDev, + ScreenPtr pScreen, + int x, int y, + Bool generateEvent) +{ + Bool val; + + SCREEN_PROLOG (SetCursorPosition); + VGAGet(pScreen); + val = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent); + VGAPut(); + SCREEN_EPILOG ( SetCursorPosition, VGAarbiterSetCursorPosition); + return val; +} + +static void +VGAarbiterAdjustFrame(int index, int x, int y, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, VGAarbiterScreenKey); + + VGAGet(pScreen); + (*pScreenPriv->AdjustFrame)(index, x, y, flags); + VGAPut(); +} + +static Bool +VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags) +{ + Bool val; + ScreenPtr pScreen = screenInfo.screens[index]; + VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, VGAarbiterScreenKey); + + VGAGet(pScreen); + val = (*pScreenPriv->SwitchMode)(index, mode, flags); + VGAPut(); + return val; +} + +static Bool +VGAarbiterEnterVT(int index, int flags) +{ + Bool val; + ScrnInfoPtr pScrn = xf86Screens[index]; + ScreenPtr pScreen = screenInfo.screens[index]; + VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, VGAarbiterScreenKey); + + VGAGet(pScreen); + pScrn->EnterVT = pScreenPriv->EnterVT; + val = (*pScrn->EnterVT)(index, flags); + pScreenPriv->EnterVT = pScrn->EnterVT; + pScrn->EnterVT = VGAarbiterEnterVT; + VGAPut(); + return val; +} + +static void +VGAarbiterLeaveVT(int index, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + ScreenPtr pScreen = screenInfo.screens[index]; + VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, VGAarbiterScreenKey); + + VGAGet(pScreen); + pScrn->LeaveVT = pScreenPriv->LeaveVT; + (*pScreenPriv->LeaveVT)(index, flags); + pScreenPriv->LeaveVT = pScrn->LeaveVT; + pScrn->LeaveVT = VGAarbiterLeaveVT; + VGAPut(); +} + +static void +VGAarbiterFreeScreen(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, VGAarbiterScreenKey); + + VGAGet(pScreen); + (*pScreenPriv->FreeScreen)(index, flags); + VGAPut(); +} + +static Bool +VGAarbiterCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + VGAarbiterGCPtr pGCPriv = (VGAarbiterGCPtr)dixLookupPrivate(&pGC->devPrivates, VGAarbiterGCKey); + Bool ret; + + SCREEN_PROLOG(CreateGC); + ret = (*pScreen->CreateGC)(pGC); + GC_WRAP(pGC); + SCREEN_EPILOG(CreateGC,VGAarbiterCreateGC); + + return ret; +} + +/* GC funcs */ +static void +VGAarbiterValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + GC_UNWRAP(pGC); + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + GC_WRAP(pGC); +} + + +static void +VGAarbiterDestroyGC(GCPtr pGC) +{ + GC_UNWRAP (pGC); + (*pGC->funcs->DestroyGC)(pGC); + GC_WRAP (pGC); +} + +static void +VGAarbiterChangeGC ( + GCPtr pGC, + unsigned long mask) +{ + GC_UNWRAP (pGC); + (*pGC->funcs->ChangeGC) (pGC, mask); + GC_WRAP (pGC); +} + +static void +VGAarbiterCopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst) +{ + GC_UNWRAP (pGCDst); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + GC_WRAP (pGCDst); +} + +static void +VGAarbiterChangeClip ( + GCPtr pGC, + int type, + pointer pvalue, + int nrects ) +{ + GC_UNWRAP (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + GC_WRAP (pGC); +} + +static void +VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + GC_UNWRAP (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + GC_WRAP (pgcDst); +} + +static void +VGAarbiterDestroyClip(GCPtr pGC) +{ + GC_UNWRAP (pGC); + (* pGC->funcs->DestroyClip)(pGC); + GC_WRAP (pGC); +} + +/* GC Ops */ +static void +VGAarbiterFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterSetSpans( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + register DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + VGAPut(); + GC_WRAP(pGC); +} + +static RegionPtr +VGAarbiterCopyArea( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty ) +{ + RegionPtr ret; + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + VGAPut(); + GC_WRAP(pGC); + return ret; +} + +static RegionPtr +VGAarbiterCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane ) +{ + RegionPtr ret; + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy, + width, height, dstx, dsty, bitPlane); + VGAPut(); + GC_WRAP(pGC); + return ret; +} + +static void +VGAarbiterPolyPoint( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + VGAPut(); + GC_WRAP(pGC); +} + + +static void +VGAarbiterPolylines( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterPolySegment( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterPolyRectangle( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterPolyArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterFillPolygon( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterPolyFillArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + VGAPut(); + GC_WRAP(pGC); +} + +static int +VGAarbiterPolyText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars ) +{ + int ret; + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + VGAPut(); + GC_WRAP(pGC); + return ret; +} + +static int +VGAarbiterPolyText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars ) +{ + int ret; + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + VGAPut(); + GC_WRAP(pGC); + return ret; +} + +static void +VGAarbiterImageText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterImageText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + VGAPut(); + GC_WRAP(pGC); +} + + +static void +VGAarbiterImageGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, + nglyph, ppci, pglyphBase); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterPolyGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, + nglyph, ppci, pglyphBase); + VGAPut(); + GC_WRAP(pGC); +} + +static void +VGAarbiterPushPixels( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg ) +{ + ScreenPtr pScreen = pGC->pScreen; + GC_UNWRAP(pGC); + VGAGet(pScreen); + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + VGAPut(); + GC_WRAP(pGC); +} + + +/* miSpriteFuncs */ +static Bool +VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur) +{ + Bool val; + SPRITE_PROLOG; + VGAGet(pScreen); + val = PointPriv->spriteFuncs->RealizeCursor(pDev, pScreen, pCur); + VGAPut(); + SPRITE_EPILOG; + return val; +} + +static Bool +VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur) +{ + Bool val; + SPRITE_PROLOG; + VGAGet(pScreen); + val = PointPriv->spriteFuncs->UnrealizeCursor(pDev, pScreen, pCur); + VGAPut(); + SPRITE_EPILOG; + return val; +} + +static void +VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur, int x, int y) +{ + SPRITE_PROLOG; + VGAGet(pScreen); + PointPriv->spriteFuncs->SetCursor(pDev, pScreen, pCur, x, y); + VGAPut(); + SPRITE_EPILOG; +} + +static void +VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) +{ + SPRITE_PROLOG; + VGAGet(pScreen); + PointPriv->spriteFuncs->MoveCursor(pDev, pScreen, x, y); + VGAPut(); + SPRITE_EPILOG; +} + +static Bool +VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) +{ + Bool val; + SPRITE_PROLOG; + VGAGet(pScreen); + val = PointPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen); + VGAPut(); + SPRITE_EPILOG; + return val; +} + +static void +VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) +{ + SPRITE_PROLOG; + VGAGet(pScreen); + PointPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen); + VGAPut(); + SPRITE_EPILOG; +} + +static void +VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, + PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, + INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, + CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + + PICTURE_PROLOGUE(Composite); + + VGAGet(pScreen); + (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, + yDst, width, height); + VGAPut(); + PICTURE_EPILOGUE(Composite, VGAarbiterComposite); +} + +static void +VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, + GlyphListPtr list, GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + + PICTURE_PROLOGUE(Glyphs); + + VGAGet(pScreen); + (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); + VGAPut(); + PICTURE_EPILOGUE (Glyphs, VGAarbiterGlyphs); +} + +static void +VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect, + xRectangle *rects) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + + PICTURE_PROLOGUE(CompositeRects); + + VGAGet(pScreen); + (*ps->CompositeRects)(op, pDst, color, nRect, rects); + VGAPut(); + PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects); +} diff --git a/xorg-server/hw/xfree86/common/xf86fbBus.c b/xorg-server/hw/xfree86/common/xf86fbBus.c index 059e378e3..45929804f 100644 --- a/xorg-server/hw/xfree86/common/xf86fbBus.c +++ b/xorg-server/hw/xfree86/common/xf86fbBus.c @@ -54,8 +54,10 @@ xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active) EntityPtr p; int num; +#ifdef XSERVER_LIBPCIACCESS if (pciSlotClaimed) return -1; +#endif #if defined(__sparc__) || defined (__sparc64__) if (sbusSlotClaimed) return -1; diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c index 2f04ac12f..eb5323cf0 100644 --- a/xorg-server/hw/xfree86/common/xf86pciBus.c +++ b/xorg-server/hw/xfree86/common/xf86pciBus.c @@ -1,1359 +1,1364 @@ -/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains the interfaces to the bus-specific code
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <X11/X.h>
-#include <pciaccess.h>
-#include "os.h"
-#include "Pci.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "dirent.h" /* DIR, FILE type definitions */
-
-/* Bus-specific headers */
-#include "xf86Bus.h"
-
-#define XF86_OS_PRIVS
-#include "xf86_OSproc.h"
-
-
-/* Bus-specific globals */
-Bool pciSlotClaimed = FALSE;
-
-#define PCIINFOCLASSES(c) \
- ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
- || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
- || ((((c) & 0x00ffff00) \
- == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \
- || ((((c) & 0x00ffff00) \
- == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) )
-
-/*
- * PCI classes that have messages printed always. The others are only
- * have a message printed when the vendor/dev IDs are recognised.
- */
-#define PCIALWAYSPRINTCLASSES(c) \
- ( (((c) & 0x00ffff00) \
- == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \
- || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \
- || ((((c) & 0x00ffff00) \
- == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) )
-
-#define IS_VGA(c) \
- (((c) & 0x00ffff00) \
- == ((PCI_CLASS_DISPLAY << 16) | (PCI_SUBCLASS_DISPLAY_VGA << 8)))
-
-
-static struct pci_slot_match xf86IsolateDevice = {
- PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0
-};
-
-void
-xf86FormatPciBusNumber(int busnum, char *buffer)
-{
- /* 'buffer' should be at least 8 characters long */
- if (busnum < 256)
- sprintf(buffer, "%d", busnum);
- else
- sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8);
-}
-
-/*
- * xf86Bus.c interface
- */
-
-void
-xf86PciProbe(void)
-{
- int i = 0, k;
- int num = 0;
- struct pci_device *info;
- struct pci_device_iterator *iter;
- struct pci_device ** xf86PciVideoInfo = NULL;
-
-
- if (!xf86scanpci()) {
- xf86PciVideoInfo = NULL;
- return;
- }
-
- iter = pci_slot_match_iterator_create(& xf86IsolateDevice);
- while ((info = pci_device_next(iter)) != NULL) {
- if (PCIINFOCLASSES(info->device_class)) {
- num++;
- xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
- (sizeof(struct pci_device *)
- * (num + 1)));
- xf86PciVideoInfo[num] = NULL;
- xf86PciVideoInfo[num - 1] = info;
-
- pci_device_probe(info);
-#ifdef HAVE_PCI_DEVICE_IS_BOOT_VGA
- if (pci_device_is_boot_vga(info)) {
- primaryBus.type = BUS_PCI;
- primaryBus.id.pci = info;
- }
-#endif
- info->user_data = 0;
- }
- }
- free(iter);
-
- /* If we haven't found a primary device try a different heuristic */
- if (primaryBus.type == BUS_NONE && num) {
- for (i = 0; i < num; i++) {
- uint16_t command;
-
- info = xf86PciVideoInfo[i];
- pci_device_cfg_read_u16(info, & command, 4);
-
- if ((command & PCI_CMD_MEM_ENABLE)
- && ((num == 1) || IS_VGA(info->device_class))) {
- if (primaryBus.type == BUS_NONE) {
- primaryBus.type = BUS_PCI;
- primaryBus.id.pci = info;
- } else {
- xf86Msg(X_NOTICE,
- "More than one possible primary device found\n");
- primaryBus.type ^= (BusType)(-1);
- }
- }
- }
- }
-
- /* Print a summary of the video devices found */
- for (k = 0; k < num; k++) {
- const char *prim = " ";
- Bool memdone = FALSE, iodone = FALSE;
-
-
- info = xf86PciVideoInfo[k];
-
- if (!PCIALWAYSPRINTCLASSES(info->device_class))
- continue;
-
- if (xf86IsPrimaryPci(info))
- prim = "*";
-
- xf86Msg(X_PROBED, "PCI:%s(%u:%u:%u:%u) %04x:%04x:%04x:%04x ", prim,
- info->domain, info->bus, info->dev, info->func,
- info->vendor_id, info->device_id,
- info->subvendor_id, info->subdevice_id);
-
- xf86ErrorF("rev %d", info->revision);
-
- for (i = 0; i < 6; i++) {
- struct pci_mem_region * r = & info->regions[i];
-
- if ( r->size && ! r->is_IO ) {
- if (!memdone) {
- xf86ErrorF(", Mem @ ");
- memdone = TRUE;
- } else
- xf86ErrorF(", ");
- xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size);
- }
- }
-
- for (i = 0; i < 6; i++) {
- struct pci_mem_region * r = & info->regions[i];
-
- if ( r->size && r->is_IO ) {
- if (!iodone) {
- xf86ErrorF(", I/O @ ");
- iodone = TRUE;
- } else
- xf86ErrorF(", ");
- xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size);
- }
- }
-
- if ( info->rom_size ) {
- xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", (long)info->rom_size);
- }
-
- xf86ErrorF("\n");
- }
- free(xf86PciVideoInfo);
-}
-
-/*
- * If the slot requested is already in use, return -1.
- * Otherwise, claim the slot for the screen requesting it.
- */
-
-int
-xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
- int chipset, GDevPtr dev, Bool active)
-{
- EntityPtr p = NULL;
- int num;
-
- if (xf86CheckPciSlot(d)) {
- num = xf86AllocateEntity();
- p = xf86Entities[num];
- p->driver = drvp;
- p->chipset = chipset;
- p->bus.type = BUS_PCI;
- p->bus.id.pci = d;
- p->active = active;
- p->inUse = FALSE;
- if (dev)
- xf86AddDevToEntity(num, dev);
- pciSlotClaimed = TRUE;
-
- if (active) {
- /* Map in this domain's I/O space */
- p->domainIO = xf86MapLegacyIO(d);
- }
-
- return num;
- } else
- return -1;
-}
-
-/*
- * Unclaim PCI slot, e.g. if probing failed, so that a different driver can claim.
- */
-void
-xf86UnclaimPciSlot(struct pci_device *d)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++) {
- const EntityPtr p = xf86Entities[i];
-
- if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
- /* Probably the slot should be deallocated? */
- p->bus.type = BUS_NONE;
- return;
- }
- }
-}
-
-/*
- * Parse a BUS ID string, and return the PCI bus parameters if it was
- * in the correct format for a PCI bus id.
- */
-
-Bool
-xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func)
-{
- /*
- * The format is assumed to be "bus[@domain]:device[:func]", where domain,
- * bus, device and func are decimal integers. domain and func may be
- * omitted and assumed to be zero, although doing this isn't encouraged.
- */
-
- char *p, *s, *d;
- const char *id;
- int i;
-
- if (StringToBusType(busID, &id) != BUS_PCI)
- return FALSE;
-
- s = xstrdup(id);
- p = strtok(s, ":");
- if (p == NULL || *p == 0) {
- free(s);
- return FALSE;
- }
- d = strpbrk(p, "@");
- if (d != NULL) {
- *(d++) = 0;
- for (i = 0; d[i] != 0; i++) {
- if (!isdigit(d[i])) {
- free(s);
- return FALSE;
- }
- }
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
- }
- *bus = atoi(p);
- if (d != NULL && *d != 0)
- *bus += atoi(d) << 8;
- p = strtok(NULL, ":");
- if (p == NULL || *p == 0) {
- free(s);
- return FALSE;
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
- }
- *device = atoi(p);
- *func = 0;
- p = strtok(NULL, ":");
- if (p == NULL || *p == 0) {
- free(s);
- return TRUE;
- }
- for (i = 0; p[i] != 0; i++) {
- if (!isdigit(p[i])) {
- free(s);
- return FALSE;
- }
- }
- *func = atoi(p);
- free(s);
- return TRUE;
-}
-
-/*
- * Compare a BUS ID string with a PCI bus id. Return TRUE if they match.
- */
-
-Bool
-xf86ComparePciBusString(const char *busID, int bus, int device, int func)
-{
- int ibus, idevice, ifunc;
-
- if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) {
- return bus == ibus && device == idevice && func == ifunc;
- } else {
- return FALSE;
- }
-}
-
-/*
- * xf86IsPrimaryPci() -- return TRUE if primary device
- * is PCI and bus, dev and func numbers match.
- */
-
-Bool
-xf86IsPrimaryPci(struct pci_device *pPci)
-{
- return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.id.pci));
-}
-
-/*
- * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity.
- */
-struct pci_device *
-xf86GetPciInfoForEntity(int entityIndex)
-{
- EntityPtr p;
-
- if (entityIndex >= xf86NumEntities)
- return NULL;
-
- p = xf86Entities[entityIndex];
- return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL;
-}
-
-/*
- * xf86CheckPciMemBase() checks that the memory base value matches one of the
- * PCI base address register values for the given PCI device.
- */
-Bool
-xf86CheckPciMemBase( struct pci_device * pPci, memType base )
-{
- int i;
-
- for (i = 0; i < 6; i++)
- if (base == pPci->regions[i].base_addr)
- return TRUE;
- return FALSE;
-}
-
-/*
- * Check if the slot requested is free. If it is already in use, return FALSE.
- */
-
-Bool
-xf86CheckPciSlot(const struct pci_device *d)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++) {
- const EntityPtr p = xf86Entities[i];
-
- if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-#define END_OF_MATCHES(m) \
- (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0))
-
-Bool
-xf86PciAddMatchingDev(DriverPtr drvp)
-{
- const struct pci_id_match * const devices = drvp->supported_devices;
- int j;
- struct pci_device *pPci;
- struct pci_device_iterator *iter;
- int numFound = 0;
-
-
- iter = pci_id_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- /* Determine if this device is supported by the driver. If it is,
- * add it to the list of devices to configure.
- */
- for (j = 0 ; ! END_OF_MATCHES(devices[j]) ; j++) {
- if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
- && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id )
- && ((devices[j].device_class_mask & pPci->device_class)
- == devices[j].device_class) ) {
- if (xf86CheckPciSlot(pPci)) {
- GDevPtr pGDev = xf86AddBusDeviceToConfigure(
- drvp->driverName, BUS_PCI, pPci, -1);
- if (pGDev != NULL) {
- /* After configure pass 1, chipID and chipRev are
- * treated as over-rides, so clobber them here.
- */
- pGDev->chipID = -1;
- pGDev->chipRev = -1;
- }
-
- numFound++;
- }
-
- break;
- }
- }
- }
-
- pci_iterator_destroy(iter);
-
- return numFound != 0;
-}
-
-Bool
-xf86PciProbeDev(DriverPtr drvp)
-{
- int i, j;
- struct pci_device * pPci;
- Bool foundScreen = FALSE;
- const struct pci_id_match * const devices = drvp->supported_devices;
- GDevPtr *devList;
- const unsigned numDevs = xf86MatchDevice(drvp->driverName, & devList);
-
- for ( i = 0 ; i < numDevs ; i++ ) {
- struct pci_device_iterator *iter;
- unsigned device_id;
-
-
- /* Find the pciVideoRec associated with this device section.
- */
- iter = pci_id_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- if (devList[i]->busID && *devList[i]->busID) {
- if (xf86ComparePciBusString(devList[i]->busID,
- ((pPci->domain << 8)
- | pPci->bus),
- pPci->dev,
- pPci->func)) {
- break;
- }
- }
- else if (xf86IsPrimaryPci(pPci)) {
- break;
- }
- }
-
- pci_iterator_destroy(iter);
-
- if (pPci == NULL) {
- continue;
- }
- device_id = (devList[i]->chipID > 0)
- ? devList[i]->chipID : pPci->device_id;
-
-
- /* Once the pciVideoRec is found, determine if the device is supported
- * by the driver. If it is, probe it!
- */
- for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) {
- if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id )
- && PCI_ID_COMPARE( devices[j].device_id, device_id )
- && ((devices[j].device_class_mask & pPci->device_class)
- == devices[j].device_class) ) {
- int entry;
-
- /* Allow the same entity to be used more than once for
- * devices with multiple screens per entity. This assumes
- * implicitly that there will be a screen == 0 instance.
- *
- * FIXME Need to make sure that two different drivers don't
- * FIXME claim the same screen > 0 instance.
- */
- if ((devList[i]->screen == 0) && !xf86CheckPciSlot(pPci))
- continue;
-
- DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
- drvp->driverName, pPci->bus, pPci->dev, pPci->func);
-
- /* Allocate an entry in the lists to be returned */
- entry = xf86ClaimPciSlot(pPci, drvp, device_id,
- devList[i], devList[i]->active);
-
- if ((entry == -1) && (devList[i]->screen > 0)) {
- unsigned k;
-
- for (k = 0; k < xf86NumEntities; k++ ) {
- EntityPtr pEnt = xf86Entities[k];
- if (pEnt->bus.type != BUS_PCI)
- continue;
- if (pEnt->bus.id.pci == pPci) {
- entry = k;
- xf86AddDevToEntity(k, devList[i]);
- break;
- }
- }
- }
-
- if (entry != -1) {
- if ((*drvp->PciProbe)(drvp, entry, pPci,
- devices[j].match_data)) {
- foundScreen = TRUE;
- } else
- xf86UnclaimPciSlot(pPci);
- }
-
- break;
- }
- }
- }
- free(devList);
-
- return foundScreen;
-}
-
-void
-xf86PciIsolateDevice(char *argument)
-{
- int bus, device, func;
-
- if (sscanf(argument, "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
- xf86IsolateDevice.domain = PCI_DOM_FROM_BUS(bus);
- xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus);
- xf86IsolateDevice.dev = device;
- xf86IsolateDevice.func = func;
- } else
- FatalError("Invalid isolated device specification\n");
-}
-
-static Bool
-pciDeviceHasBars(struct pci_device *pci)
-{
- int i;
-
- for (i = 0; i < 6; i++)
- if (pci->regions[i].size)
- return TRUE;
-
- if (pci->rom_size)
- return TRUE;
-
- return FALSE;
-}
-
-struct Inst {
- struct pci_device * pci;
- GDevPtr dev;
- Bool foundHW; /* PCIid in list of supported chipsets */
- Bool claimed; /* BusID matches with a device section */
- int chip;
- int screen;
-};
-
-
-/**
- * Find set of unclaimed devices matching a given vendor ID.
- *
- * Used by drivers to find as yet unclaimed devices matching the specified
- * vendor ID.
- *
- * \param driverName Name of the driver. This is used to find Device
- * sections in the config file.
- * \param vendorID PCI vendor ID of associated devices. If zero, then
- * the true vendor ID must be encoded in the \c PCIid
- * fields of the \c PCIchipsets entries.
- * \param chipsets Symbol table used to associate chipset names with
- * PCI IDs.
- * \param devList List of Device sections parsed from the config file.
- * \param numDevs Number of entries in \c devList.
- * \param drvp Pointer the driver's control structure.
- * \param foundEntities Returned list of entity indicies associated with the
- * driver.
- *
- * \returns
- * The number of elements in returned in \c foundEntities on success or zero
- * on failure.
- *
- * \todo
- * This function does a bit more than short description says. Fill in some
- * more of the details of its operation.
- *
- * \todo
- * The \c driverName parameter is redundant. It is the same as
- * \c DriverRec::driverName. In a future version of this function, remove
- * that parameter.
- */
-int
-xf86MatchPciInstances(const char *driverName, int vendorID,
- SymTabPtr chipsets, PciChipsets *PCIchipsets,
- GDevPtr *devList, int numDevs, DriverPtr drvp,
- int **foundEntities)
-{
- int i,j;
- struct pci_device * pPci;
- struct pci_device_iterator *iter;
- struct Inst *instances = NULL;
- int numClaimedInstances = 0;
- int allocatedInstances = 0;
- int numFound = 0;
- SymTabRec *c;
- PciChipsets *id;
- int *retEntities = NULL;
-
- *foundEntities = NULL;
-
-
- /* Each PCI device will contribute at least one entry. Each device
- * section can contribute at most one entry. The sum of the two is
- * guaranteed to be larger than the maximum possible number of entries.
- * Do this calculation and memory allocation once now to eliminate the
- * need for realloc calls inside the loop.
- */
- if (!(xf86DoConfigure && xf86DoConfigurePass1)) {
- unsigned max_entries = numDevs;
-
- iter = pci_slot_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- max_entries++;
- }
-
- pci_iterator_destroy(iter);
- instances = xnfalloc(max_entries * sizeof(struct Inst));
- }
-
- iter = pci_slot_match_iterator_create(NULL);
- while ((pPci = pci_device_next(iter)) != NULL) {
- unsigned device_class = pPci->device_class;
- Bool foundVendor = FALSE;
-
-
- /* Convert the pre-PCI 2.0 device class for a VGA adapter to the
- * 2.0 version of the same class.
- */
- if ( device_class == 0x00000101 ) {
- device_class = 0x00030000;
- }
-
-
- /* Find PCI devices that match the given vendor ID. The vendor ID is
- * either specified explicitly as a parameter to the function or
- * implicitly encoded in the high bits of id->PCIid.
- *
- * The first device with a matching vendor is recorded, even if the
- * device ID doesn't match. This is done because the Device section
- * in the xorg.conf file can over-ride the device ID. A matching PCI
- * ID might not be found now, but after the device ID over-ride is
- * applied there /might/ be a match.
- */
- for (id = PCIchipsets; id->PCIid != -1; id++) {
- const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16)
- | vendorID;
- const unsigned device_id = (id->PCIid & 0x0000FFFF);
- const unsigned match_class = 0x00030000 | id->PCIid;
-
- if ((vendor_id == pPci->vendor_id)
- || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) {
- if (!foundVendor && (instances != NULL)) {
- ++allocatedInstances;
- instances[allocatedInstances - 1].pci = pPci;
- instances[allocatedInstances - 1].dev = NULL;
- instances[allocatedInstances - 1].claimed = FALSE;
- instances[allocatedInstances - 1].foundHW = FALSE;
- instances[allocatedInstances - 1].screen = 0;
- }
-
- foundVendor = TRUE;
-
- if ( (device_id == pPci->device_id)
- || ((vendorID == PCI_VENDOR_GENERIC)
- && (match_class == device_class)) ) {
- if ( instances != NULL ) {
- instances[allocatedInstances - 1].foundHW = TRUE;
- instances[allocatedInstances - 1].chip = id->numChipset;
- }
-
-
- if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
- if (xf86CheckPciSlot(pPci)) {
- GDevPtr pGDev =
- xf86AddBusDeviceToConfigure(drvp->driverName,
- BUS_PCI, pPci, -1);
- if (pGDev) {
- /* After configure pass 1, chipID and chipRev
- * are treated as over-rides, so clobber them
- * here.
- */
- pGDev->chipID = -1;
- pGDev->chipRev = -1;
- }
-
- numFound++;
- }
- }
- else {
- numFound++;
- }
-
- break;
- }
- }
- }
- }
-
- pci_iterator_destroy(iter);
-
-
- /* In "probe only" or "configure" mode (signaled by instances being NULL),
- * our work is done. Return the number of detected devices.
- */
- if ( instances == NULL ) {
- return numFound;
- }
-
-
- /*
- * This may be debatable, but if no PCI devices with a matching vendor
- * type is found, return zero now. It is probably not desirable to
- * allow the config file to override this.
- */
- if (allocatedInstances <= 0) {
- free(instances);
- return 0;
- }
-
-
- DebugF("%s instances found: %d\n", driverName, allocatedInstances);
-
- /*
- * Check for devices that need duplicated instances. This is required
- * when there is more than one screen per entity.
- *
- * XXX This currently doesn't work for cases where the BusID isn't
- * specified explicitly in the config file.
- */
-
- for (j = 0; j < numDevs; j++) {
- if (devList[j]->screen > 0 && devList[j]->busID
- && *devList[j]->busID) {
- for (i = 0; i < allocatedInstances; i++) {
- pPci = instances[i].pci;
- if (xf86ComparePciBusString(devList[j]->busID,
- PCI_MAKE_BUS( pPci->domain, pPci->bus ),
- pPci->dev,
- pPci->func)) {
- allocatedInstances++;
- instances[allocatedInstances - 1] = instances[i];
- instances[allocatedInstances - 1].screen = devList[j]->screen;
- numFound++;
- break;
- }
- }
- }
- }
-
- for (i = 0; i < allocatedInstances; i++) {
- GDevPtr dev = NULL;
- GDevPtr devBus = NULL;
-
- pPci = instances[i].pci;
- for (j = 0; j < numDevs; j++) {
- if (devList[j]->busID && *devList[j]->busID) {
- if (xf86ComparePciBusString(devList[j]->busID,
- PCI_MAKE_BUS( pPci->domain, pPci->bus ),
- pPci->dev,
- pPci->func) &&
- devList[j]->screen == instances[i].screen) {
-
- if (devBus)
- xf86MsgVerb(X_WARNING,0,
- "%s: More than one matching Device section for "
- "instances\n\t(BusID: %s) found: %s\n",
- driverName, devList[j]->busID,
- devList[j]->identifier);
- else
- devBus = devList[j];
- }
- } else {
- /*
- * if device section without BusID is found
- * only assign to it to the primary device.
- */
- if (xf86IsPrimaryPci(pPci)) {
- xf86Msg(X_PROBED, "Assigning device section with no busID"
- " to primary device\n");
- if (dev || devBus)
- xf86MsgVerb(X_WARNING, 0,
- "%s: More than one matching Device section "
- "found: %s\n", driverName, devList[j]->identifier);
- else
- dev = devList[j];
- }
- }
- }
- if (devBus) dev = devBus; /* busID preferred */
- if (!dev) {
- if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) {
- xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
- "for instance (BusID PCI:%u@%u:%u:%u) found\n",
- driverName, pPci->domain, pPci->bus, pPci->dev,
- pPci->func);
- }
- } else {
- numClaimedInstances++;
- instances[i].claimed = TRUE;
- instances[i].dev = dev;
- }
- }
- DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
- /*
- * Now check that a chipset or chipID override in the device section
- * is valid. Chipset has precedence over chipID.
- * If chipset is not valid ignore BusSlot completely.
- */
- for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
- MessageType from = X_PROBED;
-
- if (!instances[i].claimed) {
- continue;
- }
- if (instances[i].dev->chipset) {
- for (c = chipsets; c->token >= 0; c++) {
- if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0)
- break;
- }
- if (c->token == -1) {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
- "section \"%s\" isn't valid for this driver\n",
- driverName, instances[i].dev->chipset,
- instances[i].dev->identifier);
- } else {
- instances[i].chip = c->token;
-
- for (id = PCIchipsets; id->numChipset >= 0; id++) {
- if (id->numChipset == instances[i].chip)
- break;
- }
- if(id->numChipset >=0){
- xf86Msg(X_CONFIG,"Chipset override: %s\n",
- instances[i].dev->chipset);
- from = X_CONFIG;
- } else {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
- "section \"%s\" isn't a valid PCI chipset\n",
- driverName, instances[i].dev->chipset,
- instances[i].dev->identifier);
- }
- }
- } else if (instances[i].dev->chipID > 0) {
- for (id = PCIchipsets; id->numChipset >= 0; id++) {
- if (id->PCIid == instances[i].dev->chipID)
- break;
- }
- if (id->numChipset == -1) {
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device "
- "section \"%s\" isn't valid for this driver\n",
- driverName, instances[i].dev->chipID,
- instances[i].dev->identifier);
- } else {
- instances[i].chip = id->numChipset;
-
- xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n",
- instances[i].dev->chipID);
- from = X_CONFIG;
- }
- } else if (!instances[i].foundHW) {
- /*
- * This means that there was no override and the PCI chipType
- * doesn't match one that is supported
- */
- instances[i].claimed = FALSE;
- numClaimedInstances--;
- }
- if (instances[i].claimed == TRUE){
- for (c = chipsets; c->token >= 0; c++) {
- if (c->token == instances[i].chip)
- break;
- }
- xf86Msg(from,"Chipset %s found\n",
- c->name);
- }
- }
-
- /*
- * Of the claimed instances, check that another driver hasn't already
- * claimed its slot.
- */
- numFound = 0;
- for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
- if (!instances[i].claimed)
- continue;
- pPci = instances[i].pci;
-
-
- /*
- * Allow the same entity to be used more than once for devices with
- * multiple screens per entity. This assumes implicitly that there
- * will be a screen == 0 instance.
- *
- * XXX Need to make sure that two different drivers don't claim
- * the same screen > 0 instance.
- */
- if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci ))
- continue;
-
- DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
- driverName, pPci->bus, pPci->dev, pPci->func);
-
- /* Allocate an entry in the lists to be returned */
- numFound++;
- retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
- retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp,
- instances[i].chip,
- instances[i].dev,
- instances[i].dev->active);
- if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
- for (j = 0; j < xf86NumEntities; j++) {
- EntityPtr pEnt = xf86Entities[j];
- if (pEnt->bus.type != BUS_PCI)
- continue;
- if (pEnt->bus.id.pci == pPci) {
- retEntities[numFound - 1] = j;
- xf86AddDevToEntity(j, instances[i].dev);
- break;
- }
- }
- }
- }
- free(instances);
- if (numFound > 0) {
- *foundEntities = retEntities;
- }
-
- return numFound;
-}
-
-/*
- * xf86ConfigPciEntityInactive() -- This function can be used
- * to configure an inactive entity as well as to reconfigure an
- * previously active entity inactive. If the entity has been
- * assigned to a screen before it will be removed. If p_chip is
- * non-NULL all static resources listed there will be registered.
- */
-static void
-xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
- EntityProc init, EntityProc enter,
- EntityProc leave, pointer private)
-{
- ScrnInfoPtr pScrn;
-
- if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
- xf86RemoveEntityFromScreen(pScrn,pEnt->index);
-
- /* shared resources are only needed when entity is active: remove */
- xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
-}
-
-ScrnInfoPtr
-xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
- PciChipsets *p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private)
-{
- EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
- if (!pEnt) return pScrn;
-
- if (!(pEnt->location.type == BUS_PCI)
- || !xf86GetPciInfoForEntity(entityIndex)) {
- free(pEnt);
- return pScrn;
- }
- if (!pEnt->active) {
- xf86ConfigPciEntityInactive(pEnt, p_chip, init, enter,
- leave, private);
- free(pEnt);
- return pScrn;
- }
-
- if (!pScrn)
- pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
- if (xf86IsEntitySharable(entityIndex)) {
- xf86SetEntityShared(entityIndex);
- }
- xf86AddEntityToScreen(pScrn,entityIndex);
- if (xf86IsEntityShared(entityIndex)) {
- return pScrn;
- }
- free(pEnt);
-
- xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
-
- return pScrn;
-}
-
-/*
- * OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function.
- * It is likely to be removed. Don't use!
- */
-Bool
-xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
- PciChipsets *p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private)
-{
- EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
- if (!pEnt) return FALSE;
-
- if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
- free(pEnt);
- return FALSE;
- }
- xf86AddEntityToScreen(pScrn,entityIndex);
-
- free(pEnt);
- if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
- return FALSE;
-
- return TRUE;
-}
-
-static int
-videoPtrToDriverList(struct pci_device *dev,
- char *returnList[], int returnListMax)
-{
- int i;
- /* Add more entries here if we ever return more than 4 drivers for
- any device */
- char *driverList[5] = { NULL, NULL, NULL, NULL, NULL };
-
- switch (dev->vendor_id)
- {
- /* AMD Geode LX */
- case 0x1022:
- if (dev->device_id == 0x2081)
- driverList[0] = "geode";
- break;
- /* older Geode products acquired by AMD still carry an NSC vendor_id */
- case 0x100b:
- if (dev->device_id == 0x0030) {
- /* NSC Geode GX2 specifically */
- driverList[0] = "geode";
- /* GX2 support started its life in the NSC tree and was later
- forked by AMD for GEODE so we keep it as a backup */
- driverList[1] = "nsc";
- } else
- /* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */
- driverList[0] = "nsc";
- break;
- /* Cyrix Geode GX1 */
- case 0x1078:
- if (dev->device_id == 0x0104)
- driverList[0] = "cyrix";
- break;
- case 0x1142: driverList[0] = "apm"; break;
- case 0xedd8: driverList[0] = "ark"; break;
- case 0x1a03: driverList[0] = "ast"; break;
- case 0x1002: driverList[0] = "ati"; break;
- case 0x102c: driverList[0] = "chips"; break;
- case 0x1013: driverList[0] = "cirrus"; break;
- case 0x3d3d: driverList[0] = "glint"; break;
- case 0x105d: driverList[0] = "i128"; break;
- case 0x8086:
- if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) {
- driverList[0] = "i740";
- } else if (dev->device_id == 0x8108) {
- break; /* "hooray" for poulsbo */
- } else {
- driverList[0] = "intel";
- }
- break;
- case 0x102b: driverList[0] = "mga"; break;
- case 0x10c8: driverList[0] = "neomagic"; break;
- case 0x10de: case 0x12d2: driverList[0] = "nv"; break;
- case 0x1106: driverList[0] = "openchrome"; break;
- case 0x1b36: driverList[0] = "qxl"; break;
- case 0x1163: driverList[0] = "rendition"; break;
- case 0x5333:
- switch (dev->device_id)
- {
- case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811:
- case 0x8812: case 0x8814: case 0x8901:
- driverList[0] = "s3"; break;
- case 0x5631: case 0x883d: case 0x8a01: case 0x8a10:
- case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13:
- driverList[0] = "s3virge"; break;
- default:
- driverList[0] = "savage"; break;
- }
- break;
- case 0x1039: driverList[0] = "sis"; break;
- case 0x126f: driverList[0] = "siliconmotion"; break;
- case 0x121a:
- if (dev->device_id < 0x0003)
- driverList[0] = "voodoo";
- else
- driverList[0] = "tdfx";
- break;
- case 0x1011: driverList[0] = "tga"; break;
- case 0x1023: driverList[0] = "trident"; break;
- case 0x100c: driverList[0] = "tseng"; break;
- case 0x80ee: driverList[0] = "vboxvideo"; break;
- case 0x15ad: driverList[0] = "vmware"; break;
- case 0x18ca:
- if (dev->device_id == 0x47)
- driverList[0] = "xgixp";
- else
- driverList[0] = "xgi";
- break;
- default: break;
- }
- for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) {
- returnList[i] = xnfstrdup(driverList[i]);
- }
- return i; /* Number of entries added */
-}
-
-#ifdef __linux__
-static int
-xchomp(char *line)
-{
- size_t len = 0;
-
- if (!line) {
- return 1;
- }
-
- len = strlen(line);
- if (line[len - 1] == '\n' && len > 0) {
- line[len - 1] = '\0';
- }
- return 0;
-}
-
-/* This function is used to provide a workaround for binary drivers that
- * don't export their PCI ID's properly. If distros don't end up using this
- * feature it can and should be removed because the symbol-based resolution
- * scheme should be the primary one */
-static void
-matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip)
-{
- DIR *idsdir;
- FILE *fp;
- struct dirent *direntry;
- char *line = NULL;
- size_t len;
- ssize_t read;
- char path_name[256], vendor_str[5], chip_str[5];
- uint16_t vendor, chip;
- int i, j;
-
- idsdir = opendir(PCI_TXT_IDS_PATH);
- if (!idsdir)
- return;
-
- xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
- direntry = readdir(idsdir);
- /* Read the directory */
- while (direntry) {
- if (direntry->d_name[0] == '.') {
- direntry = readdir(idsdir);
- continue;
- }
- len = strlen(direntry->d_name);
- /* A tiny bit of sanity checking. We should probably do better */
- if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
- /* We need the full path name to open the file */
- strncpy(path_name, PCI_TXT_IDS_PATH, 256);
- strncat(path_name, "/", 1);
- strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
- fp = fopen(path_name, "r");
- if (fp == NULL) {
- xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
- goto end;
- }
- /* Read the file */
-#ifdef __GLIBC__
- while ((read = getline(&line, &len, fp)) != -1) {
-#else
- while ((line = fgetln(fp, &len)) != (char *)NULL) {
-#endif /* __GLIBC __ */
- xchomp(line);
- if (isdigit(line[0])) {
- strncpy(vendor_str, line, 4);
- vendor_str[4] = '\0';
- vendor = (int)strtol(vendor_str, NULL, 16);
- if ((strlen(&line[4])) == 0) {
- chip_str[0] = '\0';
- chip = -1;
- } else {
- /* Handle trailing whitespace */
- if (isspace(line[4])) {
- chip_str[0] = '\0';
- chip = -1;
- } else {
- /* Ok, it's a real ID */
- strncpy(chip_str, &line[4], 4);
- chip_str[4] = '\0';
- chip = (int)strtol(chip_str, NULL, 16);
- }
- }
- if (vendor == match_vendor && chip == match_chip ) {
- i = 0;
- while (matches[i]) {
- i++;
- }
- matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) - 3);
- if (!matches[i]) {
- xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
- goto end;
- }
- /* hack off the .ids suffix. This should guard
- * against other problems, but it will end up
- * taking off anything after the first '.' */
- for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
- if (direntry->d_name[j] == '.') {
- matches[i][j] = '\0';
- break;
- } else {
- matches[i][j] = direntry->d_name[j];
- }
- }
- xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
- }
- } else {
- /* TODO Handle driver overrides here */
- }
- }
- fclose(fp);
- }
- direntry = readdir(idsdir);
- }
- end:
- free(line);
- closedir(idsdir);
-}
-#endif /* __linux__ */
-
-/**
- * @return The numbers of found devices that match with the current system
- * drivers.
- */
-int
-xf86PciMatchDriver(char* matches[], int nmatches) {
- int i;
- struct pci_device * info = NULL;
- struct pci_device_iterator *iter;
-
- /* Find the primary device, and get some information about it. */
- iter = pci_slot_match_iterator_create(NULL);
- while ((info = pci_device_next(iter)) != NULL) {
- if (xf86IsPrimaryPci(info)) {
- break;
- }
- }
-
- pci_iterator_destroy(iter);
-#ifdef __linux__
- if (info)
- matchDriverFromFiles(matches, info->vendor_id, info->device_id);
-#endif
-
- for (i = 0; (i < nmatches) && (matches[i]); i++) {
- /* find end of matches list */
- }
-
- if ((info != NULL) && (i < nmatches)) {
- i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
- }
-
- return i;
-}
-
-Bool
-xf86PciConfigure(void *busData, struct pci_device *pDev)
-{
- struct pci_device * pVideo = NULL;
-
- pVideo = (struct pci_device *) busData;
- if (pDev &&
- (pDev->domain == pVideo->domain) &&
- (pDev->bus == pVideo->bus) &&
- (pDev->dev == pVideo->dev) &&
- (pDev->func == pVideo->func))
- return 0;
-
- return 1;
-}
-
-void
-xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
- GDevRec *GDev, int *chipset)
-{
- char busnum[8];
-
- pVideo = (struct pci_device *) busData;
-
- xf86FormatPciBusNumber(pVideo->bus, busnum);
- XNFasprintf(&GDev->busID, "PCI:%s:%d:%d",
- busnum, pVideo->dev, pVideo->func);
-
- GDev->chipID = pVideo->device_id;
- GDev->chipRev = pVideo->revision;
-
- if (*chipset < 0)
- *chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
-}
+/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the interfaces to the bus-specific code + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <ctype.h> +#include <stdlib.h> +#include <unistd.h> +#include <X11/X.h> +#include <pciaccess.h> +#include "os.h" +#include "Pci.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "dirent.h" /* DIR, FILE type definitions */ + +/* Bus-specific headers */ +#include "xf86Bus.h" + +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" + + +/* Bus-specific globals */ +Bool pciSlotClaimed = FALSE; + +#define PCIINFOCLASSES(c) \ + ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \ + || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) ) + +/* + * PCI classes that have messages printed always. The others are only + * have a message printed when the vendor/dev IDs are recognised. + */ +#define PCIALWAYSPRINTCLASSES(c) \ + ( (((c) & 0x00ffff00) \ + == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \ + || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) ) + +#define IS_VGA(c) \ + (((c) & 0x00ffff00) \ + == ((PCI_CLASS_DISPLAY << 16) | (PCI_SUBCLASS_DISPLAY_VGA << 8))) + + +static struct pci_slot_match xf86IsolateDevice = { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0 +}; + +void +xf86FormatPciBusNumber(int busnum, char *buffer) +{ + /* 'buffer' should be at least 8 characters long */ + if (busnum < 256) + sprintf(buffer, "%d", busnum); + else + sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8); +} + +/* + * xf86Bus.c interface + */ + +void +xf86PciProbe(void) +{ + int i = 0, k; + int num = 0; + struct pci_device *info; + struct pci_device_iterator *iter; + struct pci_device ** xf86PciVideoInfo = NULL; + + + if (!xf86scanpci()) { + xf86PciVideoInfo = NULL; + return; + } + + iter = pci_slot_match_iterator_create(& xf86IsolateDevice); + while ((info = pci_device_next(iter)) != NULL) { + if (PCIINFOCLASSES(info->device_class)) { + num++; + xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, + (sizeof(struct pci_device *) + * (num + 1))); + xf86PciVideoInfo[num] = NULL; + xf86PciVideoInfo[num - 1] = info; + + pci_device_probe(info); + if (pci_device_is_boot_vga(info)) { + primaryBus.type = BUS_PCI; + primaryBus.id.pci = info; + } + info->user_data = 0; + } + } + free(iter); + + /* If we haven't found a primary device try a different heuristic */ + if (primaryBus.type == BUS_NONE && num) { + for (i = 0; i < num; i++) { + uint16_t command; + + info = xf86PciVideoInfo[i]; + pci_device_cfg_read_u16(info, & command, 4); + + if ((command & PCI_CMD_MEM_ENABLE) + && ((num == 1) || IS_VGA(info->device_class))) { + if (primaryBus.type == BUS_NONE) { + primaryBus.type = BUS_PCI; + primaryBus.id.pci = info; + } else { + xf86Msg(X_NOTICE, + "More than one possible primary device found\n"); + primaryBus.type ^= (BusType)(-1); + } + } + } + } + + /* Print a summary of the video devices found */ + for (k = 0; k < num; k++) { + const char *prim = " "; + Bool memdone = FALSE, iodone = FALSE; + + + info = xf86PciVideoInfo[k]; + + if (!PCIALWAYSPRINTCLASSES(info->device_class)) + continue; + + if (xf86IsPrimaryPci(info)) + prim = "*"; + + xf86Msg(X_PROBED, "PCI:%s(%u:%u:%u:%u) %04x:%04x:%04x:%04x ", prim, + info->domain, info->bus, info->dev, info->func, + info->vendor_id, info->device_id, + info->subvendor_id, info->subdevice_id); + + xf86ErrorF("rev %d", info->revision); + + for (i = 0; i < 6; i++) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && ! r->is_IO ) { + if (!memdone) { + xf86ErrorF(", Mem @ "); + memdone = TRUE; + } else + xf86ErrorF(", "); + xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size); + } + } + + for (i = 0; i < 6; i++) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && r->is_IO ) { + if (!iodone) { + xf86ErrorF(", I/O @ "); + iodone = TRUE; + } else + xf86ErrorF(", "); + xf86ErrorF("0x%08lx/%ld", (long)r->base_addr, (long)r->size); + } + } + + if ( info->rom_size ) { + xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", (long)info->rom_size); + } + + xf86ErrorF("\n"); + } + free(xf86PciVideoInfo); +} + +/* + * If the slot requested is already in use, return -1. + * Otherwise, claim the slot for the screen requesting it. + */ + +int +xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp, + int chipset, GDevPtr dev, Bool active) +{ + EntityPtr p = NULL; + int num; + + if (xf86CheckPciSlot(d)) { + num = xf86AllocateEntity(); + p = xf86Entities[num]; + p->driver = drvp; + p->chipset = chipset; + p->bus.type = BUS_PCI; + p->bus.id.pci = d; + p->active = active; + p->inUse = FALSE; + if (dev) + xf86AddDevToEntity(num, dev); + pciSlotClaimed = TRUE; + + return num; + } else + return -1; +} + +/* + * Unclaim PCI slot, e.g. if probing failed, so that a different driver can claim. + */ +void +xf86UnclaimPciSlot(struct pci_device *d) +{ + int i; + + for (i = 0; i < xf86NumEntities; i++) { + const EntityPtr p = xf86Entities[i]; + + if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) { + /* Probably the slot should be deallocated? */ + p->bus.type = BUS_NONE; + return; + } + } +} + +/* + * Parse a BUS ID string, and return the PCI bus parameters if it was + * in the correct format for a PCI bus id. + */ + +Bool +xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func) +{ + /* + * The format is assumed to be "bus[@domain]:device[:func]", where domain, + * bus, device and func are decimal integers. domain and func may be + * omitted and assumed to be zero, although doing this isn't encouraged. + */ + + char *p, *s, *d; + const char *id; + int i; + + if (StringToBusType(busID, &id) != BUS_PCI) + return FALSE; + + s = xstrdup(id); + p = strtok(s, ":"); + if (p == NULL || *p == 0) { + free(s); + return FALSE; + } + d = strpbrk(p, "@"); + if (d != NULL) { + *(d++) = 0; + for (i = 0; d[i] != 0; i++) { + if (!isdigit(d[i])) { + free(s); + return FALSE; + } + } + } + for (i = 0; p[i] != 0; i++) { + if (!isdigit(p[i])) { + free(s); + return FALSE; + } + } + *bus = atoi(p); + if (d != NULL && *d != 0) + *bus += atoi(d) << 8; + p = strtok(NULL, ":"); + if (p == NULL || *p == 0) { + free(s); + return FALSE; + } + for (i = 0; p[i] != 0; i++) { + if (!isdigit(p[i])) { + free(s); + return FALSE; + } + } + *device = atoi(p); + *func = 0; + p = strtok(NULL, ":"); + if (p == NULL || *p == 0) { + free(s); + return TRUE; + } + for (i = 0; p[i] != 0; i++) { + if (!isdigit(p[i])) { + free(s); + return FALSE; + } + } + *func = atoi(p); + free(s); + return TRUE; +} + +/* + * Compare a BUS ID string with a PCI bus id. Return TRUE if they match. + */ + +Bool +xf86ComparePciBusString(const char *busID, int bus, int device, int func) +{ + int ibus, idevice, ifunc; + + if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) { + return bus == ibus && device == idevice && func == ifunc; + } else { + return FALSE; + } +} + +/* + * xf86IsPrimaryPci() -- return TRUE if primary device + * is PCI and bus, dev and func numbers match. + */ + +Bool +xf86IsPrimaryPci(struct pci_device *pPci) +{ + return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.id.pci)); +} + +/* + * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity. + */ +struct pci_device * +xf86GetPciInfoForEntity(int entityIndex) +{ + EntityPtr p; + + if (entityIndex >= xf86NumEntities) + return NULL; + + p = xf86Entities[entityIndex]; + return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL; +} + +/* + * xf86CheckPciMemBase() checks that the memory base value matches one of the + * PCI base address register values for the given PCI device. + */ +Bool +xf86CheckPciMemBase( struct pci_device * pPci, memType base ) +{ + int i; + + for (i = 0; i < 6; i++) + if (base == pPci->regions[i].base_addr) + return TRUE; + return FALSE; +} + +/* + * Check if the slot requested is free. If it is already in use, return FALSE. + */ + +Bool +xf86CheckPciSlot(const struct pci_device *d) +{ + int i; + + for (i = 0; i < xf86NumEntities; i++) { + const EntityPtr p = xf86Entities[i]; + + if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) { + return FALSE; + } + } + return TRUE; +} + +#define END_OF_MATCHES(m) \ + (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0)) + +Bool +xf86PciAddMatchingDev(DriverPtr drvp) +{ + const struct pci_id_match * const devices = drvp->supported_devices; + int j; + struct pci_device *pPci; + struct pci_device_iterator *iter; + int numFound = 0; + + + iter = pci_id_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + /* Determine if this device is supported by the driver. If it is, + * add it to the list of devices to configure. + */ + for (j = 0 ; ! END_OF_MATCHES(devices[j]) ; j++) { + if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id ) + && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + if (xf86CheckPciSlot(pPci)) { + GDevPtr pGDev = xf86AddBusDeviceToConfigure( + drvp->driverName, BUS_PCI, pPci, -1); + if (pGDev != NULL) { + /* After configure pass 1, chipID and chipRev are + * treated as over-rides, so clobber them here. + */ + pGDev->chipID = -1; + pGDev->chipRev = -1; + } + + numFound++; + } + + break; + } + } + } + + pci_iterator_destroy(iter); + + return numFound != 0; +} + +Bool +xf86PciProbeDev(DriverPtr drvp) +{ + int i, j; + struct pci_device * pPci; + Bool foundScreen = FALSE; + const struct pci_id_match * const devices = drvp->supported_devices; + GDevPtr *devList; + const unsigned numDevs = xf86MatchDevice(drvp->driverName, & devList); + + for ( i = 0 ; i < numDevs ; i++ ) { + struct pci_device_iterator *iter; + unsigned device_id; + + + /* Find the pciVideoRec associated with this device section. + */ + iter = pci_id_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + if (devList[i]->busID && *devList[i]->busID) { + if (xf86ComparePciBusString(devList[i]->busID, + ((pPci->domain << 8) + | pPci->bus), + pPci->dev, + pPci->func)) { + break; + } + } + else if (xf86IsPrimaryPci(pPci)) { + break; + } + } + + pci_iterator_destroy(iter); + + if (pPci == NULL) { + continue; + } + device_id = (devList[i]->chipID > 0) + ? devList[i]->chipID : pPci->device_id; + + + /* Once the pciVideoRec is found, determine if the device is supported + * by the driver. If it is, probe it! + */ + for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) { + if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id ) + && PCI_ID_COMPARE( devices[j].device_id, device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + int entry; + + /* Allow the same entity to be used more than once for + * devices with multiple screens per entity. This assumes + * implicitly that there will be a screen == 0 instance. + * + * FIXME Need to make sure that two different drivers don't + * FIXME claim the same screen > 0 instance. + */ + if ((devList[i]->screen == 0) && !xf86CheckPciSlot(pPci)) + continue; + + DebugF("%s: card at %d:%d:%d is claimed by a Device section\n", + drvp->driverName, pPci->bus, pPci->dev, pPci->func); + + /* Allocate an entry in the lists to be returned */ + entry = xf86ClaimPciSlot(pPci, drvp, device_id, + devList[i], devList[i]->active); + + if ((entry == -1) && (devList[i]->screen > 0)) { + unsigned k; + + for (k = 0; k < xf86NumEntities; k++ ) { + EntityPtr pEnt = xf86Entities[k]; + if (pEnt->bus.type != BUS_PCI) + continue; + if (pEnt->bus.id.pci == pPci) { + entry = k; + xf86AddDevToEntity(k, devList[i]); + break; + } + } + } + + if (entry != -1) { + if ((*drvp->PciProbe)(drvp, entry, pPci, + devices[j].match_data)) { + foundScreen = TRUE; + } else + xf86UnclaimPciSlot(pPci); + } + + break; + } + } + } + free(devList); + + return foundScreen; +} + +void +xf86PciIsolateDevice(char *argument) +{ + int bus, device, func; + + if (sscanf(argument, "PCI:%d:%d:%d", &bus, &device, &func) == 3) { + xf86IsolateDevice.domain = PCI_DOM_FROM_BUS(bus); + xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus); + xf86IsolateDevice.dev = device; + xf86IsolateDevice.func = func; + } else + FatalError("Invalid isolated device specification\n"); +} + +static Bool +pciDeviceHasBars(struct pci_device *pci) +{ + int i; + + for (i = 0; i < 6; i++) + if (pci->regions[i].size) + return TRUE; + + if (pci->rom_size) + return TRUE; + + return FALSE; +} + +struct Inst { + struct pci_device * pci; + GDevPtr dev; + Bool foundHW; /* PCIid in list of supported chipsets */ + Bool claimed; /* BusID matches with a device section */ + int chip; + int screen; +}; + + +/** + * Find set of unclaimed devices matching a given vendor ID. + * + * Used by drivers to find as yet unclaimed devices matching the specified + * vendor ID. + * + * \param driverName Name of the driver. This is used to find Device + * sections in the config file. + * \param vendorID PCI vendor ID of associated devices. If zero, then + * the true vendor ID must be encoded in the \c PCIid + * fields of the \c PCIchipsets entries. + * \param chipsets Symbol table used to associate chipset names with + * PCI IDs. + * \param devList List of Device sections parsed from the config file. + * \param numDevs Number of entries in \c devList. + * \param drvp Pointer the driver's control structure. + * \param foundEntities Returned list of entity indicies associated with the + * driver. + * + * \returns + * The number of elements in returned in \c foundEntities on success or zero + * on failure. + * + * \todo + * This function does a bit more than short description says. Fill in some + * more of the details of its operation. + * + * \todo + * The \c driverName parameter is redundant. It is the same as + * \c DriverRec::driverName. In a future version of this function, remove + * that parameter. + */ +int +xf86MatchPciInstances(const char *driverName, int vendorID, + SymTabPtr chipsets, PciChipsets *PCIchipsets, + GDevPtr *devList, int numDevs, DriverPtr drvp, + int **foundEntities) +{ + int i,j; + struct pci_device * pPci; + struct pci_device_iterator *iter; + struct Inst *instances = NULL; + int numClaimedInstances = 0; + int allocatedInstances = 0; + int numFound = 0; + SymTabRec *c; + PciChipsets *id; + int *retEntities = NULL; + + *foundEntities = NULL; + + + /* Each PCI device will contribute at least one entry. Each device + * section can contribute at most one entry. The sum of the two is + * guaranteed to be larger than the maximum possible number of entries. + * Do this calculation and memory allocation once now to eliminate the + * need for realloc calls inside the loop. + */ + if (!(xf86DoConfigure && xf86DoConfigurePass1)) { + unsigned max_entries = numDevs; + + iter = pci_slot_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + max_entries++; + } + + pci_iterator_destroy(iter); + instances = xnfalloc(max_entries * sizeof(struct Inst)); + } + + iter = pci_slot_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + unsigned device_class = pPci->device_class; + Bool foundVendor = FALSE; + + + /* Convert the pre-PCI 2.0 device class for a VGA adapter to the + * 2.0 version of the same class. + */ + if ( device_class == 0x00000101 ) { + device_class = 0x00030000; + } + + + /* Find PCI devices that match the given vendor ID. The vendor ID is + * either specified explicitly as a parameter to the function or + * implicitly encoded in the high bits of id->PCIid. + * + * The first device with a matching vendor is recorded, even if the + * device ID doesn't match. This is done because the Device section + * in the xorg.conf file can over-ride the device ID. A matching PCI + * ID might not be found now, but after the device ID over-ride is + * applied there /might/ be a match. + */ + for (id = PCIchipsets; id->PCIid != -1; id++) { + const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16) + | vendorID; + const unsigned device_id = (id->PCIid & 0x0000FFFF); + const unsigned match_class = 0x00030000 | id->PCIid; + + if ((vendor_id == pPci->vendor_id) + || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) { + if (!foundVendor && (instances != NULL)) { + ++allocatedInstances; + instances[allocatedInstances - 1].pci = pPci; + instances[allocatedInstances - 1].dev = NULL; + instances[allocatedInstances - 1].claimed = FALSE; + instances[allocatedInstances - 1].foundHW = FALSE; + instances[allocatedInstances - 1].screen = 0; + } + + foundVendor = TRUE; + + if ( (device_id == pPci->device_id) + || ((vendorID == PCI_VENDOR_GENERIC) + && (match_class == device_class)) ) { + if ( instances != NULL ) { + instances[allocatedInstances - 1].foundHW = TRUE; + instances[allocatedInstances - 1].chip = id->numChipset; + } + + + if ( xf86DoConfigure && xf86DoConfigurePass1 ) { + if (xf86CheckPciSlot(pPci)) { + GDevPtr pGDev = + xf86AddBusDeviceToConfigure(drvp->driverName, + BUS_PCI, pPci, -1); + if (pGDev) { + /* After configure pass 1, chipID and chipRev + * are treated as over-rides, so clobber them + * here. + */ + pGDev->chipID = -1; + pGDev->chipRev = -1; + } + + numFound++; + } + } + else { + numFound++; + } + + break; + } + } + } + } + + pci_iterator_destroy(iter); + + + /* In "probe only" or "configure" mode (signaled by instances being NULL), + * our work is done. Return the number of detected devices. + */ + if ( instances == NULL ) { + return numFound; + } + + + /* + * This may be debatable, but if no PCI devices with a matching vendor + * type is found, return zero now. It is probably not desirable to + * allow the config file to override this. + */ + if (allocatedInstances <= 0) { + free(instances); + return 0; + } + + + DebugF("%s instances found: %d\n", driverName, allocatedInstances); + + /* + * Check for devices that need duplicated instances. This is required + * when there is more than one screen per entity. + * + * XXX This currently doesn't work for cases where the BusID isn't + * specified explicitly in the config file. + */ + + for (j = 0; j < numDevs; j++) { + if (devList[j]->screen > 0 && devList[j]->busID + && *devList[j]->busID) { + for (i = 0; i < allocatedInstances; i++) { + pPci = instances[i].pci; + if (xf86ComparePciBusString(devList[j]->busID, + PCI_MAKE_BUS( pPci->domain, pPci->bus ), + pPci->dev, + pPci->func)) { + allocatedInstances++; + instances[allocatedInstances - 1] = instances[i]; + instances[allocatedInstances - 1].screen = devList[j]->screen; + numFound++; + break; + } + } + } + } + + for (i = 0; i < allocatedInstances; i++) { + GDevPtr dev = NULL; + GDevPtr devBus = NULL; + + pPci = instances[i].pci; + for (j = 0; j < numDevs; j++) { + if (devList[j]->busID && *devList[j]->busID) { + if (xf86ComparePciBusString(devList[j]->busID, + PCI_MAKE_BUS( pPci->domain, pPci->bus ), + pPci->dev, + pPci->func) && + devList[j]->screen == instances[i].screen) { + + if (devBus) + xf86MsgVerb(X_WARNING,0, + "%s: More than one matching Device section for " + "instances\n\t(BusID: %s) found: %s\n", + driverName, devList[j]->busID, + devList[j]->identifier); + else + devBus = devList[j]; + } + } else { + /* + * if device section without BusID is found + * only assign to it to the primary device. + */ + if (xf86IsPrimaryPci(pPci)) { + xf86Msg(X_PROBED, "Assigning device section with no busID" + " to primary device\n"); + if (dev || devBus) + xf86MsgVerb(X_WARNING, 0, + "%s: More than one matching Device section " + "found: %s\n", driverName, devList[j]->identifier); + else + dev = devList[j]; + } + } + } + if (devBus) dev = devBus; /* busID preferred */ + if (!dev) { + if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) { + xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " + "for instance (BusID PCI:%u@%u:%u:%u) found\n", + driverName, pPci->domain, pPci->bus, pPci->dev, + pPci->func); + } + } else { + numClaimedInstances++; + instances[i].claimed = TRUE; + instances[i].dev = dev; + } + } + DebugF("%s instances found: %d\n", driverName, numClaimedInstances); + /* + * Now check that a chipset or chipID override in the device section + * is valid. Chipset has precedence over chipID. + * If chipset is not valid ignore BusSlot completely. + */ + for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { + MessageType from = X_PROBED; + + if (!instances[i].claimed) { + continue; + } + if (instances[i].dev->chipset) { + for (c = chipsets; c->token >= 0; c++) { + if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0) + break; + } + if (c->token == -1) { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " + "section \"%s\" isn't valid for this driver\n", + driverName, instances[i].dev->chipset, + instances[i].dev->identifier); + } else { + instances[i].chip = c->token; + + for (id = PCIchipsets; id->numChipset >= 0; id++) { + if (id->numChipset == instances[i].chip) + break; + } + if(id->numChipset >=0){ + xf86Msg(X_CONFIG,"Chipset override: %s\n", + instances[i].dev->chipset); + from = X_CONFIG; + } else { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " + "section \"%s\" isn't a valid PCI chipset\n", + driverName, instances[i].dev->chipset, + instances[i].dev->identifier); + } + } + } else if (instances[i].dev->chipID > 0) { + for (id = PCIchipsets; id->numChipset >= 0; id++) { + if (id->PCIid == instances[i].dev->chipID) + break; + } + if (id->numChipset == -1) { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device " + "section \"%s\" isn't valid for this driver\n", + driverName, instances[i].dev->chipID, + instances[i].dev->identifier); + } else { + instances[i].chip = id->numChipset; + + xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n", + instances[i].dev->chipID); + from = X_CONFIG; + } + } else if (!instances[i].foundHW) { + /* + * This means that there was no override and the PCI chipType + * doesn't match one that is supported + */ + instances[i].claimed = FALSE; + numClaimedInstances--; + } + if (instances[i].claimed == TRUE){ + for (c = chipsets; c->token >= 0; c++) { + if (c->token == instances[i].chip) + break; + } + xf86Msg(from,"Chipset %s found\n", + c->name); + } + } + + /* + * Of the claimed instances, check that another driver hasn't already + * claimed its slot. + */ + numFound = 0; + for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { + if (!instances[i].claimed) + continue; + pPci = instances[i].pci; + + + /* + * Allow the same entity to be used more than once for devices with + * multiple screens per entity. This assumes implicitly that there + * will be a screen == 0 instance. + * + * XXX Need to make sure that two different drivers don't claim + * the same screen > 0 instance. + */ + if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci )) + continue; + + DebugF("%s: card at %d:%d:%d is claimed by a Device section\n", + driverName, pPci->bus, pPci->dev, pPci->func); + + /* Allocate an entry in the lists to be returned */ + numFound++; + retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); + retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp, + instances[i].chip, + instances[i].dev, + instances[i].dev->active); + if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) { + for (j = 0; j < xf86NumEntities; j++) { + EntityPtr pEnt = xf86Entities[j]; + if (pEnt->bus.type != BUS_PCI) + continue; + if (pEnt->bus.id.pci == pPci) { + retEntities[numFound - 1] = j; + xf86AddDevToEntity(j, instances[i].dev); + break; + } + } + } + } + free(instances); + if (numFound > 0) { + *foundEntities = retEntities; + } + + return numFound; +} + +/* + * xf86ConfigPciEntityInactive() -- This function can be used + * to configure an inactive entity as well as to reconfigure an + * previously active entity inactive. If the entity has been + * assigned to a screen before it will be removed. If p_chip is + * non-NULL all static resources listed there will be registered. + */ +static void +xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip, + EntityProc init, EntityProc enter, + EntityProc leave, pointer private) +{ + ScrnInfoPtr pScrn; + + if ((pScrn = xf86FindScreenForEntity(pEnt->index))) + xf86RemoveEntityFromScreen(pScrn,pEnt->index); + + /* shared resources are only needed when entity is active: remove */ + xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); +} + +ScrnInfoPtr +xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, + PciChipsets *p_chip, void *dummy, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return pScrn; + + if (!(pEnt->location.type == BUS_PCI) + || !xf86GetPciInfoForEntity(entityIndex)) { + free(pEnt); + return pScrn; + } + if (!pEnt->active) { + xf86ConfigPciEntityInactive(pEnt, p_chip, init, enter, + leave, private); + free(pEnt); + return pScrn; + } + + if (!pScrn) + pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); + if (xf86IsEntitySharable(entityIndex)) { + xf86SetEntityShared(entityIndex); + } + xf86AddEntityToScreen(pScrn,entityIndex); + if (xf86IsEntityShared(entityIndex)) { + return pScrn; + } + free(pEnt); + + xf86SetEntityFuncs(entityIndex,init,enter,leave,private); + + return pScrn; +} + +/* + * OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function. + * It is likely to be removed. Don't use! + */ +Bool +xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex, + PciChipsets *p_chip, void *dummy, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return FALSE; + + if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) { + free(pEnt); + return FALSE; + } + xf86AddEntityToScreen(pScrn,entityIndex); + + free(pEnt); + if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private)) + return FALSE; + + return TRUE; +} + +static int +videoPtrToDriverList(struct pci_device *dev, + char *returnList[], int returnListMax) +{ + int i; + /* Add more entries here if we ever return more than 4 drivers for + any device */ + char *driverList[5] = { NULL, NULL, NULL, NULL, NULL }; + + switch (dev->vendor_id) + { + /* AMD Geode LX */ + case 0x1022: + if (dev->device_id == 0x2081) + driverList[0] = "geode"; + break; + /* older Geode products acquired by AMD still carry an NSC vendor_id */ + case 0x100b: + if (dev->device_id == 0x0030) { + /* NSC Geode GX2 specifically */ + driverList[0] = "geode"; + /* GX2 support started its life in the NSC tree and was later + forked by AMD for GEODE so we keep it as a backup */ + driverList[1] = "nsc"; + } else + /* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */ + driverList[0] = "nsc"; + break; + /* Cyrix Geode GX1 */ + case 0x1078: + if (dev->device_id == 0x0104) + driverList[0] = "cyrix"; + break; + case 0x1142: driverList[0] = "apm"; break; + case 0xedd8: driverList[0] = "ark"; break; + case 0x1a03: driverList[0] = "ast"; break; + case 0x1002: driverList[0] = "ati"; break; + case 0x102c: driverList[0] = "chips"; break; + case 0x1013: driverList[0] = "cirrus"; break; + case 0x3d3d: driverList[0] = "glint"; break; + case 0x105d: driverList[0] = "i128"; break; + case 0x8086: + if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) { + driverList[0] = "i740"; + } else if (dev->device_id == 0x8108) { + break; /* "hooray" for poulsbo */ + } else { + driverList[0] = "intel"; + } + break; + case 0x102b: driverList[0] = "mga"; break; + case 0x10c8: driverList[0] = "neomagic"; break; + case 0x10de: case 0x12d2: driverList[0] = "nv"; break; + case 0x1106: driverList[0] = "openchrome"; break; + case 0x1b36: driverList[0] = "qxl"; break; + case 0x1163: driverList[0] = "rendition"; break; + case 0x5333: + switch (dev->device_id) + { + case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811: + case 0x8812: case 0x8814: case 0x8901: + driverList[0] = "s3"; break; + case 0x5631: case 0x883d: case 0x8a01: case 0x8a10: + case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13: + driverList[0] = "s3virge"; break; + default: + driverList[0] = "savage"; break; + } + break; + case 0x1039: driverList[0] = "sis"; break; + case 0x126f: driverList[0] = "siliconmotion"; break; + case 0x121a: + if (dev->device_id < 0x0003) + driverList[0] = "voodoo"; + else + driverList[0] = "tdfx"; + break; + case 0x1011: driverList[0] = "tga"; break; + case 0x1023: driverList[0] = "trident"; break; + case 0x100c: driverList[0] = "tseng"; break; + case 0x80ee: driverList[0] = "vboxvideo"; break; + case 0x15ad: driverList[0] = "vmware"; break; + case 0x18ca: + if (dev->device_id == 0x47) + driverList[0] = "xgixp"; + else + driverList[0] = "xgi"; + break; + default: break; + } + for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) { + returnList[i] = xnfstrdup(driverList[i]); + } + return i; /* Number of entries added */ +} + +#ifdef __linux__ +static int +xchomp(char *line) +{ + size_t len = 0; + + if (!line) { + return 1; + } + + len = strlen(line); + if (line[len - 1] == '\n' && len > 0) { + line[len - 1] = '\0'; + } + return 0; +} + +/* This function is used to provide a workaround for binary drivers that + * don't export their PCI ID's properly. If distros don't end up using this + * feature it can and should be removed because the symbol-based resolution + * scheme should be the primary one */ +static void +matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip) +{ + DIR *idsdir; + FILE *fp; + struct dirent *direntry; + char *line = NULL; + size_t len; + ssize_t read; + char path_name[256], vendor_str[5], chip_str[5]; + uint16_t vendor, chip; + int i, j; + + idsdir = opendir(PCI_TXT_IDS_PATH); + if (!idsdir) + return; + + xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH); + direntry = readdir(idsdir); + /* Read the directory */ + while (direntry) { + if (direntry->d_name[0] == '.') { + direntry = readdir(idsdir); + continue; + } + len = strlen(direntry->d_name); + /* A tiny bit of sanity checking. We should probably do better */ + if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) { + /* We need the full path name to open the file */ + strncpy(path_name, PCI_TXT_IDS_PATH, 256); + strncat(path_name, "/", 1); + strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1)); + fp = fopen(path_name, "r"); + if (fp == NULL) { + xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name); + goto end; + } + /* Read the file */ +#ifdef __GLIBC__ + while ((read = getline(&line, &len, fp)) != -1) { +#else + while ((line = fgetln(fp, &len)) != (char *)NULL) { +#endif /* __GLIBC __ */ + xchomp(line); + if (isdigit(line[0])) { + strncpy(vendor_str, line, 4); + vendor_str[4] = '\0'; + vendor = (int)strtol(vendor_str, NULL, 16); + if ((strlen(&line[4])) == 0) { + chip_str[0] = '\0'; + chip = -1; + } else { + /* Handle trailing whitespace */ + if (isspace(line[4])) { + chip_str[0] = '\0'; + chip = -1; + } else { + /* Ok, it's a real ID */ + strncpy(chip_str, &line[4], 4); + chip_str[4] = '\0'; + chip = (int)strtol(chip_str, NULL, 16); + } + } + if (vendor == match_vendor && chip == match_chip ) { + i = 0; + while (matches[i]) { + i++; + } + matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) - 3); + if (!matches[i]) { + xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n"); + goto end; + } + /* hack off the .ids suffix. This should guard + * against other problems, but it will end up + * taking off anything after the first '.' */ + for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) { + if (direntry->d_name[j] == '.') { + matches[i][j] = '\0'; + break; + } else { + matches[i][j] = direntry->d_name[j]; + } + } + xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name); + } + } else { + /* TODO Handle driver overrides here */ + } + } + fclose(fp); + } + direntry = readdir(idsdir); + } + end: + free(line); + closedir(idsdir); +} +#endif /* __linux__ */ + +/** + * @return The numbers of found devices that match with the current system + * drivers. + */ +int +xf86PciMatchDriver(char* matches[], int nmatches) { + int i; + struct pci_device * info = NULL; + struct pci_device_iterator *iter; + + /* Find the primary device, and get some information about it. */ + iter = pci_slot_match_iterator_create(NULL); + while ((info = pci_device_next(iter)) != NULL) { + if (xf86IsPrimaryPci(info)) { + break; + } + } + + pci_iterator_destroy(iter); +#ifdef __linux__ + if (info) + matchDriverFromFiles(matches, info->vendor_id, info->device_id); +#endif + + for (i = 0; (i < nmatches) && (matches[i]); i++) { + /* find end of matches list */ + } + + if ((info != NULL) && (i < nmatches)) { + i += videoPtrToDriverList(info, &(matches[i]), nmatches - i); + } + + return i; +} + +Bool +xf86PciConfigure(void *busData, struct pci_device *pDev) +{ + struct pci_device * pVideo = NULL; + + pVideo = (struct pci_device *) busData; + if (pDev && + (pDev->domain == pVideo->domain) && + (pDev->bus == pVideo->bus) && + (pDev->dev == pVideo->dev) && + (pDev->func == pVideo->func)) + return 0; + + return 1; +} + +void +xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo, + GDevRec *GDev, int *chipset) +{ + char busnum[8]; + + pVideo = (struct pci_device *) busData; + + xf86FormatPciBusNumber(pVideo->bus, busnum); + XNFasprintf(&GDev->busID, "PCI:%s:%d:%d", + busnum, pVideo->dev, pVideo->func); + + GDev->chipID = pVideo->device_id; + GDev->chipRev = pVideo->revision; + + if (*chipset < 0) + *chipset = (pVideo->vendor_id << 16) | pVideo->device_id; +} + +struct pci_io_handle * +xf86MapLegacyIO(struct pci_device *dev) +{ + return pci_legacy_open_io(dev, 0, 64 * 1024); +} + +void +xf86UnmapLegacyIO(struct pci_device *dev, struct pci_io_handle *handle) +{ + pci_device_close_io(dev, handle); +} diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h index 0493dc53c..e2ca55875 100644 --- a/xorg-server/hw/xfree86/common/xf86str.h +++ b/xorg-server/hw/xfree86/common/xf86str.h @@ -41,9 +41,6 @@ #include "colormapst.h" #include "xf86Module.h" #include "xf86Opt.h" -#include "xf86Pci.h" - -#include <pciaccess.h> /** * Integer type that is of the size of the addressable memory (machine size). @@ -309,6 +306,8 @@ typedef struct { struct _SymTabRec; struct _PciChipsets; +struct pci_device; + typedef struct _DriverRec { int driverVersion; char * driverName; @@ -350,8 +349,6 @@ typedef enum { BUS_last /* Keep last */ } BusType; -struct pci_device; - typedef struct { int fbNum; } SbusBusId; @@ -742,7 +739,6 @@ typedef struct _ScrnInfoRec { unsigned long biosBase; /* Base address of video BIOS */ unsigned long memPhysBase; /* Physical address of FB */ unsigned long fbOffset; /* Offset of FB in the above */ - IOADDRESS domainIOBase; /* Domain I/O base address */ int memClk; /* memory clock */ int textClockFreq; /* clock of text mode */ Bool flipPixels; /* swap default black/white */ diff --git a/xorg-server/hw/xfree86/dixmods/Makefile.am b/xorg-server/hw/xfree86/dixmods/Makefile.am index 68111631c..b6eb54f16 100644 --- a/xorg-server/hw/xfree86/dixmods/Makefile.am +++ b/xorg-server/hw/xfree86/dixmods/Makefile.am @@ -1,68 +1,68 @@ -noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la
-
-SUBDIRS = extmod
-
-if GLX
-GLXMODS = libglx.la
-endif
-
-if DBE
-DBEMOD = libdbe.la
-endif
-
-if RECORD
-RECORDMOD = librecord.la
-endif
-
-module_LTLIBRARIES = libfb.la \
- libwfb.la \
- libshadow.la
-
-extsmoduledir = $(moduledir)/extensions
-extsmodule_LTLIBRARIES = $(RECORDMOD) \
- $(DBEMOD) \
- $(GLXMODS)
-
-AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
-INCLUDES = @XORG_INCS@ \
- -I$(top_srcdir)/dbe \
- -I$(top_srcdir)/hw/xfree86/loader \
- -I$(top_srcdir)/miext/shadow \
- -I$(top_srcdir)/glx
-
-libdbe_la_LDFLAGS = -avoid-version
-libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la
-libdbe_la_SOURCES = dbemodule.c
-
-libfb_la_LDFLAGS = -avoid-version
-libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
-libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
-libfb_la_CFLAGS = $(AM_CFLAGS)
-
-libwfb_la_LDFLAGS = -avoid-version
-libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
-libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
-libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
-
-libglx_la_LDFLAGS = -avoid-version
-if AIGLX_DRI_LOADER
-GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la
-endif
-libglx_la_LIBADD = \
- $(top_builddir)/glx/libglx.la \
- $(GLXDRI_LIBRARY)
-libglx_la_SOURCES = glxmodule.c
-
-librecord_la_LDFLAGS = -avoid-version
-librecord_la_LIBADD = $(top_builddir)/record/librecord.la
-librecord_la_SOURCES = recordmod.c
-
-libshadow_la_LDFLAGS = -avoid-version
-libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la
-libshadow_la_SOURCES = shmodule.c
-
-libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c
-libdixmods_la_CFLAGS = -DXFree86LOADER $(AM_CFLAGS)
-
-libxorgxkb_la_SOURCES = xkbVT.c xkbPrivate.c xkbKillSrv.c
-libxorgxkb_la_LIBADD = $(top_builddir)/dix/libdix.la
+noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la + +SUBDIRS = extmod + +if GLX +GLXMODS = libglx.la +endif + +if DBE +DBEMOD = libdbe.la +endif + +if RECORD +RECORDMOD = librecord.la +endif + +module_LTLIBRARIES = libfb.la \ + libwfb.la \ + libshadow.la + +extsmoduledir = $(moduledir)/extensions +extsmodule_LTLIBRARIES = $(RECORDMOD) \ + $(DBEMOD) \ + $(GLXMODS) + +AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@ +INCLUDES = @XORG_INCS@ \ + -I$(top_srcdir)/dbe \ + -I$(top_srcdir)/hw/xfree86/loader \ + -I$(top_srcdir)/miext/shadow \ + -I$(top_srcdir)/glx + +libdbe_la_LDFLAGS = -module -avoid-version +libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la +libdbe_la_SOURCES = dbemodule.c + +libfb_la_LDFLAGS = -module -avoid-version +libfb_la_LIBADD = $(top_builddir)/fb/libfb.la +libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c +libfb_la_CFLAGS = $(AM_CFLAGS) + +libwfb_la_LDFLAGS = -module -avoid-version +libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la +libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c +libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER + +libglx_la_LDFLAGS = -module -avoid-version +if AIGLX_DRI_LOADER +GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la +endif +libglx_la_LIBADD = \ + $(top_builddir)/glx/libglx.la \ + $(GLXDRI_LIBRARY) +libglx_la_SOURCES = glxmodule.c + +librecord_la_LDFLAGS = -module -avoid-version +librecord_la_LIBADD = $(top_builddir)/record/librecord.la +librecord_la_SOURCES = recordmod.c + +libshadow_la_LDFLAGS = -module -avoid-version +libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la +libshadow_la_SOURCES = shmodule.c + +libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c +libdixmods_la_CFLAGS = -DXFree86LOADER $(AM_CFLAGS) + +libxorgxkb_la_SOURCES = xkbVT.c xkbPrivate.c xkbKillSrv.c +libxorgxkb_la_LIBADD = $(top_builddir)/dix/libdix.la diff --git a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am index c0b7ddc02..87c28a421 100644 --- a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am +++ b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am @@ -1,30 +1,30 @@ -sdk_HEADERS = dgaproc.h
-
-extsmoduledir = $(moduledir)/extensions
-extsmodule_LTLIBRARIES = libextmod.la
-
-if DGA
-DGA_SRCS = xf86dga2.c dgaproc.h
-endif
-
-if XV
-XV_SRCS = xvmod.c xvmodproc.h
-endif
-
-if XF86VIDMODE
-XF86VMODE_SRCS = xf86vmode.c
-endif
-
-AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@
-INCLUDES = @XORG_INCS@ \
- -I$(top_srcdir)/dbe \
- -I$(top_srcdir)/hw/xfree86/loader \
- -I$(top_srcdir)/miext/shadow
-
-libextmod_la_LDFLAGS = -avoid-version
-libextmod_la_SOURCES = modinit.c \
- modinit.h \
- $(DGA_SRCS) \
- $(XF86VMODE_SRCS) \
- $(XV_SRCS)
-libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la
+sdk_HEADERS = dgaproc.h + +extsmoduledir = $(moduledir)/extensions +extsmodule_LTLIBRARIES = libextmod.la + +if DGA +DGA_SRCS = xf86dga2.c dgaproc.h +endif + +if XV +XV_SRCS = xvmod.c xvmodproc.h +endif + +if XF86VIDMODE +XF86VMODE_SRCS = xf86vmode.c +endif + +AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@ +INCLUDES = @XORG_INCS@ \ + -I$(top_srcdir)/dbe \ + -I$(top_srcdir)/hw/xfree86/loader \ + -I$(top_srcdir)/miext/shadow + +libextmod_la_LDFLAGS = -module -avoid-version +libextmod_la_SOURCES = modinit.c \ + modinit.h \ + $(DGA_SRCS) \ + $(XF86VMODE_SRCS) \ + $(XV_SRCS) +libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la diff --git a/xorg-server/hw/xfree86/exa/Makefile.am b/xorg-server/hw/xfree86/exa/Makefile.am index 39f7a9057..3ced531fa 100644 --- a/xorg-server/hw/xfree86/exa/Makefile.am +++ b/xorg-server/hw/xfree86/exa/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS = man module_LTLIBRARIES = libexa.la -libexa_la_LDFLAGS = -avoid-version +libexa_la_LDFLAGS = -module -avoid-version INCLUDES = \ $(XORG_INCS) \ diff --git a/xorg-server/hw/xfree86/fbdevhw/Makefile.am b/xorg-server/hw/xfree86/fbdevhw/Makefile.am index 2a038905e..4472acd91 100644 --- a/xorg-server/hw/xfree86/fbdevhw/Makefile.am +++ b/xorg-server/hw/xfree86/fbdevhw/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS = man module_LTLIBRARIES = libfbdevhw.la -libfbdevhw_la_LDFLAGS = -avoid-version +libfbdevhw_la_LDFLAGS = -module -avoid-version if FBDEVHW libfbdevhw_la_SOURCES = fbdevhw.c diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h index bc46b9c4f..34870c27d 100644 --- a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h +++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h @@ -5,8 +5,6 @@ #include "xf86str.h" #include "colormapst.h" -#include <pciaccess.h> - #define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */ #define FBDEVHW_PLANES 1 /* Non interleaved planes */ #define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */ diff --git a/xorg-server/hw/xfree86/int10/generic.c b/xorg-server/hw/xfree86/int10/generic.c index 994085493..fbc9b8507 100644 --- a/xorg-server/hw/xfree86/int10/generic.c +++ b/xorg-server/hw/xfree86/int10/generic.c @@ -62,62 +62,6 @@ static void UnmapVRam(xf86Int10InfoPtr pInt); static void *sysMem = NULL; -/** - * Read legacy VGA video BIOS associated with specified domain. - * - * Attempts to read up to 128KiB of legacy VGA video BIOS. - * - * \return - * The number of bytes read on success or -1 on failure. - * - * \bug - * PCI ROMs can contain multiple BIOS images (e.g., OpenFirmware, x86 VGA, - * etc.). How do we know that \c pci_device_read_rom will return the - * legacy VGA BIOS image? - */ -#ifndef _PC -static int -read_legacy_video_BIOS(struct pci_device *dev, unsigned char *Buf) -{ - const ADDRESS Base = 0xC0000; - const int Len = 0x10000 * 2; - const int pagemask = getpagesize() - 1; - const ADDRESS offset = Base & ~pagemask; - const unsigned long size = ((Base + Len + pagemask) & ~pagemask) - offset; - unsigned char *ptr, *src; - int len; - - - /* Try to use the civilized PCI interface first. - */ - if (pci_device_read_rom(dev, Buf) == 0) { - return dev->rom_size; - } - - ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, dev, offset, size); - - if (!ptr) - return -1; - - /* Using memcpy() here can hang the system */ - src = ptr + (Base - offset); - for (len = 0; len < (Len / 2); len++) { - Buf[len] = src[len]; - } - - if ((Buf[0] == 0x55) && (Buf[1] == 0xAA) && (Buf[2] > 0x80)) { - for ( /* empty */ ; len < Len; len++) { - Buf[len] = src[len]; - } - } - - xf86UnMapVidMem(-1, ptr, size); - - return Len; -} -#endif /* _PC */ - - xf86Int10InfoPtr xf86ExtendedInitInt10(int entityIndex, int Flags) { @@ -159,8 +103,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) MapVRam(pInt); #ifdef _PC if (!sysMem) - sysMem = xf86MapVidMem(screen, VIDMEM_MMIO, V_BIOS, - BIOS_SIZE + SYS_BIOS - V_BIOS); + pci_device_map_legacy(pInt->dev, V_BIOS, BIOS_SIZE + SYS_BIOS - V_BIOS, + PCI_DEV_MAP_FLAG_WRITABLE, &sysMem); INTPriv(pInt)->sysMem = sysMem; if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) { @@ -232,7 +176,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) */ vbiosMem = (char *)base + V_BIOS; memset(vbiosMem, 0, 2 * V_BIOS_SIZE); - if (read_legacy_video_BIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) { + if (pci_device_read_rom(pInt->dev, vbiosMem) < V_BIOS_SIZE) { xf86DrvMsg(screen, X_WARNING, "Unable to retrieve all of segment 0x0C0000.\n"); } @@ -294,10 +238,8 @@ MapVRam(xf86Int10InfoPtr pInt) int pagesize = getpagesize(); int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize; - INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO, - pInt->dev, V_RAM, size); - - pInt->ioBase = xf86Screens[pInt->scrnIndex]->domainIOBase; + pci_device_map_legacy(pInt->dev, V_RAM, size, PCI_DEV_MAP_FLAG_WRITABLE, &(INTPriv(pInt)->vRam)); + pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024); } static void @@ -307,7 +249,9 @@ UnmapVRam(xf86Int10InfoPtr pInt) int pagesize = getpagesize(); int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize; - xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size); + pci_device_unmap_legacy(pInt->dev, INTPriv(pInt)->vRam, size); + pci_device_close_io(pInt->dev, pInt->io); + pInt->io = NULL; } Bool diff --git a/xorg-server/hw/xfree86/int10/helper_exec.c b/xorg-server/hw/xfree86/int10/helper_exec.c index 44d8a7fcd..638f5668b 100644 --- a/xorg-server/hw/xfree86/int10/helper_exec.c +++ b/xorg-server/hw/xfree86/int10/helper_exec.c @@ -331,7 +331,7 @@ x_inb(CARD16 port) } #endif /* __NOT_YET__ */ } else if (!pciCfg1inb(port, &val)) { - val = inb(Int10Current->ioBase + port); + val = pci_io_read8(Int10Current->io, port); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" inb(%#x) = %2.2x\n", port, val); } @@ -353,7 +353,7 @@ x_inw(CARD16 port) X_GETTIMEOFDAY(&tv); val = (CARD16)(tv.tv_usec / 3); } else if (!pciCfg1inw(port, &val)) { - val = inw(Int10Current->ioBase + port); + val = pci_io_read16(Int10Current->io, port); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" inw(%#x) = %4.4x\n", port, val); } @@ -387,7 +387,7 @@ x_outb(CARD16 port, CARD8 val) } else if (!pciCfg1outb(port, val)) { if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" outb(%#x, %2.2x)\n", port, val); - outb(Int10Current->ioBase + port, val); + pci_io_write8(Int10Current->io, port, val); } } @@ -398,7 +398,7 @@ x_outw(CARD16 port, CARD16 val) if (!pciCfg1outw(port, val)) { if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" outw(%#x, %4.4x)\n", port, val); - outw(Int10Current->ioBase + port, val); + pci_io_write16(Int10Current->io, port, val); } } @@ -408,7 +408,7 @@ x_inl(CARD16 port) CARD32 val; if (!pciCfg1in(port, &val)) { - val = inl(Int10Current->ioBase + port); + val = pci_io_read32(Int10Current->io, port); if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" inl(%#x) = %8.8" PRIx32 "\n", port, val); } @@ -421,7 +421,7 @@ x_outl(CARD16 port, CARD32 val) if (!pciCfg1out(port, val)) { if (PRINT_PORT && DEBUG_IO_TRACE()) ErrorF(" outl(%#x, %8.8" PRIx32 ")\n", port, val); - outl(Int10Current->ioBase + port, val); + pci_io_write32(Int10Current->io, port, val); } } @@ -475,7 +475,7 @@ static struct pci_device* pci_device_for_cfg_address (CARD32 addr) { struct pci_device *dev = NULL; - PCITAG tag = PCI_TAG(addr); + CARD32 tag = PCI_TAG(addr); struct pci_slot_match slot_match = { .domain = PCI_DOM_FROM_TAG(tag), .bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)), @@ -650,29 +650,29 @@ bios_checksum(const CARD8 *start, int size) void LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga) { - vga->save_msr = inb(pInt->ioBase + 0x03CC); - vga->save_vse = inb(pInt->ioBase + 0x03C3); + vga->save_msr = pci_io_read8(pInt->io, 0x03CC); + vga->save_vse = pci_io_read8(pInt->io, 0x03C3); #ifndef __ia64__ - vga->save_46e8 = inb(pInt->ioBase + 0x46E8); + vga->save_46e8 = pci_io_read8(pInt->io, 0x46E8); #endif - vga->save_pos102 = inb(pInt->ioBase + 0x0102); - outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr); - outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse); + vga->save_pos102 = pci_io_read8(pInt->io, 0x0102); + pci_io_write8(pInt->io, 0x03C2, ~(CARD8)0x03 & vga->save_msr); + pci_io_write8(pInt->io, 0x03C3, ~(CARD8)0x01 & vga->save_vse); #ifndef __ia64__ - outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8); + pci_io_write8(pInt->io, 0x46E8, ~(CARD8)0x08 & vga->save_46e8); #endif - outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102); + pci_io_write8(pInt->io, 0x0102, ~(CARD8)0x01 & vga->save_pos102); } void UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga) { - outb(pInt->ioBase + 0x0102, vga->save_pos102); + pci_io_write8(pInt->io, 0x0102, vga->save_pos102); #ifndef __ia64__ - outb(pInt->ioBase + 0x46E8, vga->save_46e8); + pci_io_write8(pInt->io, 0x46E8, vga->save_46e8); #endif - outb(pInt->ioBase + 0x03C3, vga->save_vse); - outb(pInt->ioBase + 0x03C2, vga->save_msr); + pci_io_write8(pInt->io, 0x03C3, vga->save_vse); + pci_io_write8(pInt->io, 0x03C2, vga->save_msr); } #if defined (_PC) @@ -680,10 +680,12 @@ static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set) { int pagesize = getpagesize(); - unsigned char* base = xf86MapVidMem(pInt->scrnIndex, - VIDMEM_MMIO, 0, pagesize); + unsigned char* base; int i; + if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base)) + return; /* eek */ + if (set) { for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++) MEM_WW(pInt, i, *(base + i)); @@ -692,7 +694,7 @@ SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set) *(base + i) = MEM_RW(pInt, i); } - xf86UnMapVidMem(pInt->scrnIndex,base,pagesize); + pci_device_unmap_legacy(pInt->dev, base, pagesize); } void @@ -706,7 +708,9 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save) || (!save && !pInt->BIOSScratch)) return; - base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize); + if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base)) + return; /* eek */ + base += BIOS_SCRATCH_OFF; if (save) { if ((pInt->BIOSScratch @@ -722,7 +726,7 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save) } } - xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize); + pci_device_unmap_legacy(pInt->dev, base, pagesize); } #endif diff --git a/xorg-server/hw/xfree86/int10/xf86int10.c b/xorg-server/hw/xfree86/int10/xf86int10.c index 51eb91fbb..dd00e5465 100644 --- a/xorg-server/hw/xfree86/int10/xf86int10.c +++ b/xorg-server/hw/xfree86/int10/xf86int10.c @@ -84,7 +84,7 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented (except for clearing the screen) */ { /* Localise */ - IOADDRESS ioport; + unsigned int ioport; int i; CARD16 int1d, regvals, tmp; CARD8 mode, cgamode, cgacolour; @@ -172,18 +172,15 @@ int42_handler(xf86Int10InfoPtr pInt) /* Rows */ MEM_WB(pInt, 0x0484, (25 - 1)); - /* Remap I/O port number into its domain */ - ioport += pInt->ioBase; - - /* Programme the mode */ - outb(ioport + 4, cgamode & 0x37); /* Turn off screen */ + /* Program the mode */ + pci_io_write8(pInt->io, ioport + 4, cgamode & 0x37); /* Turn off screen */ for (i = 0; i < 0x10; i++) { tmp = MEM_RB(pInt, regvals + i); - outb(ioport, i); - outb(ioport + 1, tmp); + pci_io_write8(pInt->io, ioport, i); + pci_io_write8(pInt->io, ioport + 1, tmp); } - outb(ioport + 5, cgacolour); /* Select colour mode */ - outb(ioport + 4, cgamode); /* Turn on screen */ + pci_io_write8(pInt->io, ioport + 5, cgacolour); /* Select colour mode */ + pci_io_write8(pInt->io, ioport + 4, cgamode); /* Turn on screen */ } break; @@ -194,15 +191,15 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented */ { /* Localise */ - IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; + unsigned int ioport = MEM_RW(pInt, 0x0463); MEM_WB(pInt, 0x0460, X86_CL); MEM_WB(pInt, 0x0461, X86_CH); - outb(ioport, 0x0A); - outb(ioport + 1, X86_CH); - outb(ioport, 0x0B); - outb(ioport + 1, X86_CL); + pci_io_write8(pInt->io, ioport, 0x0A); + pci_io_write8(pInt->io, ioport + 1, X86_CH); + pci_io_write8(pInt->io, ioport, 0x0B); + pci_io_write8(pInt->io, ioport + 1, X86_CL); } break; @@ -214,7 +211,7 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented */ { /* Localise */ - IOADDRESS ioport; + unsigned int ioport; CARD16 offset; MEM_WB(pInt, (X86_BH << 1) + 0x0450, X86_DL); @@ -226,11 +223,11 @@ int42_handler(xf86Int10InfoPtr pInt) offset = (X86_DH * MEM_RW(pInt, 0x044A)) + X86_DL; offset += MEM_RW(pInt, 0x044E) << 1; - ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; - outb(ioport, 0x0E); - outb(ioport + 1, offset >> 8); - outb(ioport, 0x0F); - outb(ioport + 1, offset & 0xFF); + ioport = MEM_RW(pInt, 0x0463); + pci_io_write8(pInt->io, ioport, 0x0E); + pci_io_write8(pInt->io, ioport + 1, offset >> 8); + pci_io_write8(pInt->io, ioport, 0x0F); + pci_io_write8(pInt->io, ioport + 1, offset & 0xFF); } break; @@ -276,7 +273,7 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented */ { /* Localise */ - IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; + unsigned int ioport = MEM_RW(pInt, 0x0463); CARD16 start; CARD8 x, y; @@ -287,10 +284,10 @@ int42_handler(xf86Int10InfoPtr pInt) start <<= 1; /* Update start address */ - outb(ioport, 0x0C); - outb(ioport + 1, start >> 8); - outb(ioport, 0x0D); - outb(ioport + 1, start & 0xFF); + pci_io_write8(pInt->io, ioport, 0x0C); + pci_io_write8(pInt->io, ioport + 1, start >> 8); + pci_io_write8(pInt->io, ioport, 0x0D); + pci_io_write8(pInt->io, ioport + 1, start & 0xFF); /* Switch cursor position */ y = MEM_RB(pInt, (X86_AL << 1) + 0x0450); @@ -298,10 +295,10 @@ int42_handler(xf86Int10InfoPtr pInt) start += (y * MEM_RW(pInt, 0x044A)) + x; /* Update cursor position */ - outb(ioport, 0x0E); - outb(ioport + 1, start >> 8); - outb(ioport, 0x0F); - outb(ioport + 1, start & 0xFF); + pci_io_write8(pInt->io, ioport, 0x0E); + pci_io_write8(pInt->io, ioport + 1, start >> 8); + pci_io_write8(pInt->io, ioport, 0x0F); + pci_io_write8(pInt->io, ioport + 1, start & 0xFF); } break; @@ -426,7 +423,7 @@ int42_handler(xf86Int10InfoPtr pInt) /* Leave: Nothing */ /* Implemented */ { /* Localise */ - IOADDRESS ioport = MEM_RW(pInt, 0x0463) + 5 + pInt->ioBase; + unsigned int ioport = MEM_RW(pInt, 0x0463) + 5; CARD8 cgacolour = MEM_RB(pInt, 0x0466); if (X86_BH) { @@ -438,7 +435,7 @@ int42_handler(xf86Int10InfoPtr pInt) } MEM_WB(pInt, 0x0466, cgacolour); - outb(ioport, cgacolour); + pci_io_write8(pInt->io, ioport, cgacolour); } break; diff --git a/xorg-server/hw/xfree86/int10/xf86int10.h b/xorg-server/hw/xfree86/int10/xf86int10.h index ba9ee5276..5bf326e78 100644 --- a/xorg-server/hw/xfree86/int10/xf86int10.h +++ b/xorg-server/hw/xfree86/int10/xf86int10.h @@ -41,7 +41,7 @@ typedef struct { int flags; int stackseg; struct pci_device *dev; - IOADDRESS ioBase; + struct pci_io_handle *io; } xf86Int10InfoRec, *xf86Int10InfoPtr; typedef struct _int10Mem { diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c index 3fae039ed..cbe0b5cf6 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.c +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c @@ -3090,6 +3090,7 @@ xf86_crtc_box_area(BoxPtr box) return (int) (box->x2 - box->x1) * (int) (box->y2 - box->y1); } +#ifdef XV /* * Return the crtc covering 'box'. If two crtcs cover a portion of * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc @@ -3178,6 +3179,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, return ret; } +#endif xf86_crtc_notify_proc_ptr xf86_wrap_crtc_notify (ScreenPtr screen, xf86_crtc_notify_proc_ptr new) diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h index ffb2efff4..716499f8d 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.h +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h @@ -956,6 +956,7 @@ xf86_cursors_fini (ScreenPtr screen); extern _X_EXPORT void xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y); +#ifdef XV /* * For overlay video, compute the relevant CRTC and * clip video to that. @@ -974,6 +975,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, RegionPtr reg, INT32 width, INT32 height); +#endif extern _X_EXPORT xf86_crtc_notify_proc_ptr xf86_wrap_crtc_notify (ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new); diff --git a/xorg-server/hw/xfree86/modes/xf86Cursors.c b/xorg-server/hw/xfree86/modes/xf86Cursors.c index 4a03428ea..669da0d5b 100644 --- a/xorg-server/hw/xfree86/modes/xf86Cursors.c +++ b/xorg-server/hw/xfree86/modes/xf86Cursors.c @@ -33,6 +33,7 @@ #include <string.h> #include <stdio.h> +#include <X11/Xarch.h> #include "xf86.h" #include "xf86DDC.h" #include "xf86Crtc.h" diff --git a/xorg-server/hw/xfree86/os-support/Makefile.am b/xorg-server/hw/xfree86/os-support/Makefile.am index 348b7ffec..a0140a16d 100644 --- a/xorg-server/hw/xfree86/os-support/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/Makefile.am @@ -1,5 +1,5 @@ SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS) -DIST_SUBDIRS = bsd bus misc linux solaris hurd +DIST_SUBDIRS = bsd bus misc linux solaris stub hurd sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h @@ -16,6 +16,3 @@ libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \ AM_CFLAGS = $(DIX_CFLAGS) -# FIXME: These don't seem to be used anywhere -EXTRA_DIST += \ - shared/bios_devmem.c diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c index 525bfb607..20dbde86a 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c @@ -202,10 +202,8 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) pVidMem->mapMem = mapVidMem; pVidMem->unmapMem = unmapVidMem; -#if HAVE_PCI_SYSTEM_INIT_DEV_MEM if (useDevMem) pci_system_init_dev_mem(devMemFd); -#endif #ifdef HAS_MTRR_SUPPORT if (useDevMem) { diff --git a/xorg-server/hw/xfree86/os-support/bus/Makefile.am b/xorg-server/hw/xfree86/os-support/bus/Makefile.am index 41d8875fb..e09d4d21f 100644 --- a/xorg-server/hw/xfree86/os-support/bus/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/bus/Makefile.am @@ -1,25 +1,24 @@ -noinst_LTLIBRARIES = libbus.la
-sdk_HEADERS = xf86Pci.h
-
-PCI_SOURCES = Pci.c Pci.h
-
-if XORG_BUS_LINUXPCI
-PCI_SOURCES += linuxPci.c
-endif
-
-if XORG_BUS_BSDPCI
-PCI_SOURCES += bsd_pci.c
-endif
-
-if XORG_BUS_SPARC
-PLATFORM_SOURCES = Sbus.c
-sdk_HEADERS += xf86Sbus.h
-endif
-
-libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES)
-
-INCLUDES = $(XORG_INCS)
-
-AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
-
-EXTRA_DIST = $(sdk_HEADERS)
+noinst_LTLIBRARIES = libbus.la +sdk_HEADERS = xf86Pci.h + +PCI_SOURCES = +if XORG_BUS_PCI +PCI_SOURCES += Pci.c Pci.h +endif + +if XORG_BUS_BSDPCI +PCI_SOURCES += bsd_pci.c +endif + +if XORG_BUS_SPARC +PLATFORM_SOURCES = Sbus.c +sdk_HEADERS += xf86Sbus.h +endif + +libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES) nobus.c + +INCLUDES = $(XORG_INCS) + +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) + +EXTRA_DIST = $(sdk_HEADERS) diff --git a/xorg-server/hw/xfree86/os-support/bus/Pci.c b/xorg-server/hw/xfree86/os-support/bus/Pci.c index 8da149d16..0362a00e3 100644 --- a/xorg-server/hw/xfree86/os-support/bus/Pci.c +++ b/xorg-server/hw/xfree86/os-support/bus/Pci.c @@ -1,146 +1,140 @@ -/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Copyright 1998 by Metro Link Incorporated
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * This software is derived from the original XFree86 PCI code
- * which includes the following copyright notices as well:
- *
- * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of the above listed copyright holder(s)
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. The above listed
- * copyright holder(s) make(s) no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * This code is also based heavily on the code in FreeBSD-current, which was
- * written by Wolfgang Stanglmeier, and contains the following copyright:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-/*
- * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "Pci.h"
-
-PCITAG
-pciTag(int busnum, int devnum, int funcnum)
-{
- return(PCI_MAKE_TAG(busnum,devnum,funcnum));
-}
-
-Bool
-xf86scanpci(void)
-{
- Bool success = FALSE;
-
- success = (pci_system_init() == 0);
-
- /* choose correct platform/OS specific PCI init routine */
- ARCH_PCI_INIT();
-
- return success;
-}
+/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This software is derived from the original XFree86 PCI code + * which includes the following copyright notices as well: + * + * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * This code is also based heavily on the code in FreeBSD-current, which was + * written by Wolfgang Stanglmeier, and contains the following copyright: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "Pci.h" + +Bool +xf86scanpci(void) +{ + Bool success = FALSE; + + success = (pci_system_init() == 0); + + /* choose correct platform/OS specific PCI init routine */ + osPciInit(); + + return success; +} diff --git a/xorg-server/hw/xfree86/os-support/bus/Pci.h b/xorg-server/hw/xfree86/os-support/bus/Pci.h index fb0ad41f6..88560ecdc 100644 --- a/xorg-server/hw/xfree86/os-support/bus/Pci.h +++ b/xorg-server/hw/xfree86/os-support/bus/Pci.h @@ -1,156 +1,150 @@ -/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Copyright 1998 by Metro Link Incorporated
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * This file is derived in part from the original xf86_PCI.h that included
- * following copyright message:
- *
- * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of the above listed copyright holder(s)
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. The above listed
- * copyright holder(s) make(s) no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-/*
- * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/*
- * This file has the private Pci definitions. The public ones are imported
- * from xf86Pci.h. Drivers should not use this file.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _PCI_H
-#define _PCI_H 1
-
-#include "xf86Pci.h"
-#include "xf86PciInfo.h"
-
-/*
- * Global Definitions
- */
-#if (defined(__alpha__) || defined(__ia64__)) && defined (linux)
-#define PCI_DOM_MASK 0x01fful
-#else
-#define PCI_DOM_MASK 0x0ffu
-#endif
-
-#ifndef PCI_DOM_MASK
-# define PCI_DOM_MASK 0x0ffu
-#endif
-#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
-
-/*
- * "b" contains an optional domain number.
- */
-#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
- (((d) & 0x00001fu) << 11) | \
- (((f) & 0x000007u) << 8))
-
-#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
-
-#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
-#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
-#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
- defined(__OpenBSD__) || defined(__NetBSD__) || \
- defined(__DragonFly__) || defined(__sun) || defined(__GNU__)
-#define ARCH_PCI_INIT bsdPciInit
-#endif
-
-#if defined(linux)
-#define ARCH_PCI_INIT linuxPciInit
-#endif /* defined(linux) */
-
-#ifndef ARCH_PCI_INIT
-#error No PCI support available for this architecture/OS combination
-#endif
-
-extern void ARCH_PCI_INIT(void);
-
-#endif /* _PCI_H */
+/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This file is derived in part from the original xf86_PCI.h that included + * following copyright message: + * + * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* + * This file has the private Pci definitions. The public ones are imported + * from xf86Pci.h. Drivers should not use this file. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _PCI_H +#define _PCI_H 1 + +#include "xf86Pci.h" +#include "xf86PciInfo.h" + +/* + * Global Definitions + */ +#if (defined(__alpha__) || defined(__ia64__)) && defined (linux) +#define PCI_DOM_MASK 0x01fful +#else +#define PCI_DOM_MASK 0x0ffu +#endif + +#ifndef PCI_DOM_MASK +# define PCI_DOM_MASK 0x0ffu +#endif +#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) + +/* + * "b" contains an optional domain number. + */ +#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ + (((d) & 0x00001fu) << 11) | \ + (((f) & 0x000007u) << 8)) + +#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu)) + +#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK)) +#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) +#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u) + +#if defined(linux) +#define osPciInit(x) do {} while (0) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(__DragonFly__) || defined(__sun) || defined(__GNU__) +extern void osPciInit(void); +#else +#error No PCI support available for this architecture/OS combination +#endif + +#endif /* _PCI_H */ diff --git a/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c b/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c index 17b52db49..7a5dbbb01 100644 --- a/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c +++ b/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c @@ -48,22 +48,8 @@ #include "pciaccess.h" -pointer -xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size) -{ - return xf86MapVidMem(ScreenNum, Flags, Base, Size); -} - -IOADDRESS -xf86MapLegacyIO(struct pci_device *dev) -{ - (void)dev; - return 0; -} - void -bsdPciInit(void) +osPciInit(void) { xf86InitVidMem(); } diff --git a/xorg-server/hw/xfree86/os-support/bus/linuxPci.c b/xorg-server/hw/xfree86/os-support/bus/linuxPci.c deleted file mode 100644 index 77f724bf1..000000000 --- a/xorg-server/hw/xfree86/os-support/bus/linuxPci.c +++ /dev/null @@ -1,450 +0,0 @@ -/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
- * Copyright 1998 by Metro Link Incorporated
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdio.h>
-#include "xf86_OSlib.h"
-#include "Pci.h"
-
-static const struct pci_id_match match_host_bridge = {
- PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
- (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_HOST << 8),
- 0x0000ffff00, 0
-};
-
-#define MAX_DOMAINS 257
-static pointer DomainMmappedIO[MAX_DOMAINS];
-
-void
-linuxPciInit(void)
-{
- memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO));
-}
-
-/**
- * \bug
- * The generation of the procfs file name for the domain != 0 case may not be
- * correct.
- */
-static int
-linuxPciOpenFile(struct pci_device *dev, Bool write)
-{
- static struct pci_device *last_dev = NULL;
- static int fd = -1,is_write = 0;
- char file[64];
- struct stat ignored;
- static int is26 = -1;
-
- if (dev == NULL) {
- return -1;
- }
-
- if (is26 == -1) {
- is26 = (stat("/sys/bus/pci", &ignored) < 0) ? 0 : 1;
- }
-
- if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) {
- if (fd != -1) {
- close(fd);
- fd = -1;
- }
-
- if (is26) {
- sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config",
- dev->domain, dev->bus, dev->dev, dev->func);
- } else {
- if (dev->domain == 0) {
- sprintf(file,"/proc/bus/pci/%02x", dev->bus);
- if (stat(file, &ignored) < 0) {
- sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x",
- dev->bus, dev->dev, dev->func);
- } else {
- sprintf(file, "/proc/bus/pci/%02x/%02x.%1x",
- dev->bus, dev->dev, dev->func);
- }
- } else {
- sprintf(file,"/proc/bus/pci/%02x%02x", dev->domain, dev->bus);
- if (stat(file, &ignored) < 0) {
- sprintf(file, "/proc/bus/pci/%04x:%04x/%02x.%1x",
- dev->domain, dev->bus, dev->dev, dev->func);
- } else {
- sprintf(file, "/proc/bus/pci/%02x%02x/%02x.%1x",
- dev->domain, dev->bus, dev->dev, dev->func);
- }
- }
- }
-
- if (write) {
- fd = open(file,O_RDWR);
- if (fd != -1) is_write = TRUE;
- } else {
- switch (is_write) {
- case TRUE:
- fd = open(file,O_RDWR);
- if (fd > -1)
- break;
- default:
- fd = open(file,O_RDONLY);
- is_write = FALSE;
- }
- }
-
- last_dev = dev;
- }
-
- return fd;
-}
-
-/*
- * Compiling the following simply requires the presence of <linux/pci.c>.
- * Actually running this is another matter altogether...
- *
- * This scheme requires that the kernel allow mmap()'ing of a host bridge's I/O
- * and memory spaces through its /proc/bus/pci/BUS/DFN entry. Which one is
- * determined by a prior ioctl().
- *
- * For the sparc64 port, this means 2.4.12 or later. For ppc, this
- * functionality is almost, but not quite there yet. Alpha and other kernel
- * ports to multi-domain architectures still need to implement this.
- *
- * This scheme is also predicated on the use of an IOADDRESS compatible type to
- * designate I/O addresses. Although IOADDRESS is defined as an unsigned
- * integral type, it is actually the virtual address of, i.e. a pointer to, the
- * I/O port to access. And so, the inX/outX macros in "compiler.h" need to be
- * #define'd appropriately (as is done on SPARC's).
- *
- * Another requirement to port this scheme to another multi-domain architecture
- * is to add the appropriate entries in the pciControllerSizes array below.
- *
- * TO DO: Address the deleterious reaction some host bridges have to master
- * aborts. This is already done for secondary PCI buses, but not yet
- * for accesses to primary buses (except for the SPARC port, where
- * master aborts are avoided during PCI scans).
- */
-
-#include <linux/pci.h>
-
-#ifndef PCIIOC_BASE /* Ioctls for /proc/bus/pci/X/Y nodes. */
-#define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8)
-
-/* Get controller for PCI device. */
-#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00)
-/* Set mmap state to I/O space. */
-#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01)
-/* Set mmap state to MEM space. */
-#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02)
-/* Enable/disable write-combining. */
-#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03)
-
-#endif
-
-/* This probably shouldn't be Linux-specific */
-static struct pci_device *
-get_parent_bridge(struct pci_device *dev)
-{
- struct pci_id_match bridge_match = {
- PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
- (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8),
- 0
- };
- struct pci_device *bridge;
- struct pci_device_iterator *iter;
-
- if (dev == NULL) {
- return NULL;
- }
-
- iter = pci_id_match_iterator_create(& bridge_match);
- if (iter == NULL) {
- return NULL;
- }
-
- while ((bridge = pci_device_next(iter)) != NULL) {
- if (bridge->domain == dev->domain) {
- const struct pci_bridge_info *info =
- pci_device_get_bridge_info(bridge);
-
- if (info != NULL) {
- if (info->secondary_bus == dev->bus) {
- break;
- }
- }
- }
- }
-
- pci_iterator_destroy(iter);
-
- return bridge;
-}
-
-/*
- * This is ugly, but until I can extract this information from the kernel,
- * it'll have to do. The default I/O space size is 64K, and 4G for memory.
- * Anything else needs to go in this table. (PowerPC folk take note.)
- *
- * Note that Linux/SPARC userland is 32-bit, so 4G overflows to zero here.
- *
- * Please keep this table in ascending vendor/device order.
- */
-static const struct pciSizes {
- unsigned short vendor, device;
- unsigned long io_size, mem_size;
-} pciControllerSizes[] = {
- {
- PCI_VENDOR_SUN, PCI_CHIP_PSYCHO,
- 1U << 16, 1U << 31
- },
- {
- PCI_VENDOR_SUN, PCI_CHIP_SCHIZO,
- 1U << 24, 1U << 31 /* ??? */
- },
- {
- PCI_VENDOR_SUN, PCI_CHIP_SABRE,
- 1U << 24, (unsigned long)(1ULL << 32)
- },
- {
- PCI_VENDOR_SUN, PCI_CHIP_HUMMINGBIRD,
- 1U << 24, (unsigned long)(1ULL << 32)
- }
-};
-#define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0]))
-
-static const struct pciSizes *
-linuxGetSizesStruct(const struct pci_device *dev)
-{
- static const struct pciSizes default_size = {
- 0, 0, 1U << 16, (unsigned long)(1ULL << 32)
- };
- int i;
-
- /* Look up vendor/device */
- if (dev != NULL) {
- for (i = 0; i < NUM_SIZES; i++) {
- if ((dev->vendor_id == pciControllerSizes[i].vendor)
- && (dev->device_id == pciControllerSizes[i].device)) {
- return & pciControllerSizes[i];
- }
- }
- }
-
- /* Default to 64KB I/O and 4GB memory. */
- return & default_size;
-}
-
-static __inline__ unsigned long
-linuxGetIOSize(const struct pci_device *dev)
-{
- const struct pciSizes * const sizes = linuxGetSizesStruct(dev);
- return sizes->io_size;
-}
-
-static pointer
-linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev,
- ADDRESS Base, unsigned long Size, int mmap_ioctl)
-{
- /* Align to page boundary */
- const ADDRESS realBase = Base & ~(getpagesize() - 1);
- const ADDRESS Offset = Base - realBase;
-
- do {
- unsigned char *result;
- int fd, mmapflags, prot;
-
- xf86InitVidMem();
-
- /* If dev is NULL, linuxPciOpenFile will return -1, and this routine
- * will fail gracefully.
- */
- prot = ((Flags & VIDMEM_READONLY) == 0);
- if (((fd = linuxPciOpenFile(dev, prot)) < 0) ||
- (ioctl(fd, mmap_ioctl, 0) < 0))
- break;
-
-/* Note: IA-64 doesn't compile this and doesn't need to */
-#ifdef __ia64__
-
-# ifndef MAP_WRITECOMBINED
-# define MAP_WRITECOMBINED 0x00010000
-# endif
-# ifndef MAP_NONCACHED
-# define MAP_NONCACHED 0x00020000
-# endif
-
- if (Flags & VIDMEM_FRAMEBUFFER)
- mmapflags = MAP_SHARED | MAP_WRITECOMBINED;
- else
- mmapflags = MAP_SHARED | MAP_NONCACHED;
-
-#else /* !__ia64__ */
-
- mmapflags = (Flags & VIDMEM_FRAMEBUFFER) / VIDMEM_FRAMEBUFFER;
-
- if (ioctl(fd, PCIIOC_WRITE_COMBINE, mmapflags) < 0)
- break;
-
- mmapflags = MAP_SHARED;
-
-#endif /* ?__ia64__ */
-
-
- if (Flags & VIDMEM_READONLY)
- prot = PROT_READ;
- else
- prot = PROT_READ | PROT_WRITE;
-
- result = mmap(NULL, Size + Offset, prot, mmapflags, fd, realBase);
-
- if (!result || ((pointer)result == MAP_FAILED))
- return NULL;
-
- xf86MakeNewMapping(ScreenNum, Flags, realBase, Size + Offset, result);
-
- return result + Offset;
- } while (0);
-
- if (mmap_ioctl == PCIIOC_MMAP_IS_MEM)
- return xf86MapVidMem(ScreenNum, Flags, Base, Size);
-
- return NULL;
-}
-
-static int
-linuxOpenLegacy(struct pci_device *dev, char *name)
-{
- static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/%s";
- char path[sizeof(PREFIX) + 10];
- int fd = -1;
-
- while (dev != NULL) {
- snprintf(path, sizeof(path) - 1, PREFIX, dev->domain, dev->bus, name);
- fd = open(path, O_RDWR);
- if (fd >= 0) {
- return fd;
- }
-
- dev = get_parent_bridge(dev);
- }
-
- return fd;
-}
-
-/*
- * xf86MapDomainMemory - memory map PCI domain memory
- *
- * This routine maps the memory region in the domain specified by Tag and
- * returns a pointer to it. The pointer is saved for future use if it's in
- * the legacy ISA memory space (memory in a domain between 0 and 1MB).
- */
-pointer
-xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
- ADDRESS Base, unsigned long Size)
-{
- int fd = -1;
- pointer addr;
-
- /*
- * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs
- * legacy_mem interface is unavailable.
- */
- if ((Base > 1024*1024) || ((fd = linuxOpenLegacy(dev, "legacy_mem")) < 0))
- return linuxMapPci(ScreenNum, Flags, dev, Base, Size,
- PCIIOC_MMAP_IS_MEM);
- else
- addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base);
-
- if (fd >= 0)
- close(fd);
- if (addr == NULL || addr == MAP_FAILED) {
- perror("mmap failure");
- FatalError("xf86MapDomainMem(): mmap() failure\n");
- }
- return addr;
-}
-
-/**
- * Map I/O space in this domain
- *
- * Each domain has a legacy ISA I/O space. This routine will try to
- * map it using the Linux sysfs legacy_io interface. If that fails,
- * it'll fall back to using /proc/bus/pci.
- *
- * If the legacy_io interface \b does exist, the file descriptor (\c fd below)
- * will be saved in the \c DomainMmappedIO array in the upper bits of the
- * pointer. Callers will do I/O with small port numbers (<64k values), so
- * the platform I/O code can extract the port number and the \c fd, \c lseek
- * to the port number in the legacy_io file, and issue the read or write.
- *
- * This has no means of returning failure, so all errors are fatal
- */
-IOADDRESS
-xf86MapLegacyIO(struct pci_device *dev)
-{
- const int domain = dev->domain;
- struct pci_device *bridge = get_parent_bridge(dev);
- int fd;
-
- if (domain >= MAX_DOMAINS)
- FatalError("xf86MapLegacyIO(): domain out of range\n");
-
- if (DomainMmappedIO[domain] == NULL) {
- /* Permanently map all of I/O space */
- fd = linuxOpenLegacy(bridge, "legacy_io");
- if (fd < 0) {
- DomainMmappedIO[domain] = linuxMapPci(-1, VIDMEM_MMIO, bridge,
- 0, linuxGetIOSize(bridge),
- PCIIOC_MMAP_IS_IO);
- }
- else { /* legacy_io file exists, encode fd */
- DomainMmappedIO[domain] = (pointer)(intptr_t)(fd << 24);
- }
- }
-
- return (IOADDRESS)DomainMmappedIO[domain];
-}
-
diff --git a/xorg-server/hw/xfree86/os-support/bus/nobus.c b/xorg-server/hw/xfree86/os-support/bus/nobus.c new file mode 100644 index 000000000..ad23f5288 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/nobus.c @@ -0,0 +1 @@ +static void __noop_to_appease_ar__() { return; } diff --git a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h index ce1336bf2..74ead201e 100644 --- a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h +++ b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h @@ -235,8 +235,8 @@ /* Primitive Types */ typedef unsigned long ADDRESS; /* Memory/PCI address */ -typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */ -typedef unsigned long PCITAG; +typedef unsigned long IOADDRESS _X_DEPRECATED; /* Must be large enough for a pointer */ +typedef CARD32 PCITAG _X_DEPRECATED; typedef enum { PCI_MEM, @@ -251,12 +251,10 @@ typedef enum { /* Public PCI access functions */ -extern _X_EXPORT PCITAG pciTag(int busnum, int devnum, int funcnum); extern _X_EXPORT Bool xf86scanpci(void); /* Domain access functions. Some of these probably shouldn't be public */ -extern _X_EXPORT pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size); -extern _X_EXPORT IOADDRESS xf86MapLegacyIO(struct pci_device *dev); +extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev); +extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *, struct pci_io_handle *); #endif /* _XF86PCI_H */ diff --git a/xorg-server/hw/xfree86/os-support/linux/Makefile.am b/xorg-server/hw/xfree86/os-support/linux/Makefile.am index 7a82627fd..36748df2c 100644 --- a/xorg-server/hw/xfree86/os-support/linux/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/linux/Makefile.am @@ -1,9 +1,5 @@ noinst_LTLIBRARIES = liblinux.la -if LINUX_IA64 -PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c -PLATFORM_INCLUDES = -I$(srcdir)/../shared -endif if LINUX_ALPHA noinst_LTLIBRARIES += liblinuxev56.la PLATFORM_PCI_SUPPORT = \ diff --git a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c index e3c8a984d..564447ff6 100644 --- a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c +++ b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c @@ -1,544 +1,541 @@ -/*
- * linux specific part of the int10 module
- * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2008 Egbert Eich
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "xf86Pci.h"
-#include "compiler.h"
-#define _INT10_PRIVATE
-#include "xf86int10.h"
-#ifdef __sparc__
-#define DEV_MEM "/dev/fb"
-#else
-#define DEV_MEM "/dev/mem"
-#endif
-#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1)
-#define SHMERRORPTR (pointer)(-1)
-
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <unistd.h>
-#include <string.h>
-
-static int counter = 0;
-static unsigned long int10Generation = 0;
-
-static CARD8 read_b(xf86Int10InfoPtr pInt, int addr);
-static CARD16 read_w(xf86Int10InfoPtr pInt, int addr);
-static CARD32 read_l(xf86Int10InfoPtr pInt, int addr);
-static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val);
-static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val);
-static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val);
-
-int10MemRec linuxMem = {
- read_b,
- read_w,
- read_l,
- write_b,
- write_w,
- write_l
-};
-
-typedef struct {
- int lowMem;
- int highMem;
- char* base;
- char* base_high;
- int screen;
- char* alloc;
-} linuxInt10Priv;
-
-#if defined DoSubModules
-
-typedef enum {
- INT10_NOT_LOADED,
- INT10_LOADED_VM86,
- INT10_LOADED_X86EMU,
- INT10_LOAD_FAILED
-} Int10LinuxSubModuleState;
-
-static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED;
-
-static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn);
-
-#endif /* DoSubModules */
-
-xf86Int10InfoPtr
-xf86ExtendedInitInt10(int entityIndex, int Flags)
-{
- xf86Int10InfoPtr pInt = NULL;
- int screen;
- int fd;
- static void* vidMem = NULL;
- static void* sysMem = NULL;
- void* vMem = NULL;
- void *options = NULL;
- int low_mem;
- int high_mem = -1;
- char *base = SHMERRORPTR;
- char *base_high = SHMERRORPTR;
- int pagesize;
- memType cs;
- legacyVGARec vga;
- Bool videoBiosMapped = FALSE;
-
- if (int10Generation != serverGeneration) {
- counter = 0;
- int10Generation = serverGeneration;
- }
-
- screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
-
- options = xf86HandleInt10Options(xf86Screens[screen],entityIndex);
-
- if (int10skip(options)) {
- free(options);
- return NULL;
- }
-
-#if defined DoSubModules
- if (loadedSubModule == INT10_NOT_LOADED)
- loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]);
-
- if (loadedSubModule == INT10_LOAD_FAILED)
- return NULL;
-#endif
-
- if ((!vidMem) || (!sysMem)) {
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if (!sysMem) {
- DebugF("Mapping sys bios area\n");
- if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE,
- PROT_READ | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, SYS_BIOS))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n");
- close(fd);
- goto error0;
- }
- }
- if (!vidMem) {
- DebugF("Mapping VRAM area\n");
- if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_RAM))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n");
- close(fd);
- goto error0;
- }
- }
- close(fd);
- } else {
- xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM);
- goto error0;
- }
- }
-
- pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec));
- pInt->scrnIndex = screen;
- pInt->entityIndex = entityIndex;
- pInt->dev = xf86GetPciInfoForEntity(entityIndex);
-
- if (!xf86Int10ExecSetup(pInt))
- goto error0;
- pInt->mem = &linuxMem;
- pagesize = getpagesize();
- pInt->private = (pointer)xnfcalloc(1, sizeof(linuxInt10Priv));
- ((linuxInt10Priv*)pInt->private)->screen = screen;
- ((linuxInt10Priv*)pInt->private)->alloc =
- (pointer)xnfcalloc(1, ALLOC_ENTRIES(pagesize));
-
- if (!xf86IsEntityPrimary(entityIndex)) {
- DebugF("Mapping high memory area\n");
- if ((high_mem = shmget(counter++, HIGH_MEM_SIZE,
- IPC_CREAT | SHM_R | SHM_W)) == -1) {
- if (errno == ENOSYS)
- xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure"
- " your kernel to include System V IPC support\n");
- else
- xf86DrvMsg(screen, X_ERROR,
- "shmget(highmem) error: %s\n",strerror(errno));
- goto error1;
- }
- } else {
- DebugF("Mapping Video BIOS\n");
- videoBiosMapped = TRUE;
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if ((vMem = mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_BIOS))
- == MAP_FAILED) {
- xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n");
- close(fd);
- goto error1;
- }
- close (fd);
- } else
- goto error1;
- }
- ((linuxInt10Priv*)pInt->private)->highMem = high_mem;
-
- DebugF("Mapping 640kB area\n");
- if ((low_mem = shmget(counter++, V_RAM,
- IPC_CREAT | SHM_R | SHM_W)) == -1) {
- xf86DrvMsg(screen, X_ERROR,
- "shmget(lowmem) error: %s\n",strerror(errno));
- goto error2;
- }
-
- ((linuxInt10Priv*)pInt->private)->lowMem = low_mem;
- base = shmat(low_mem, 0, 0);
- if (base == SHMERRORPTR) {
- xf86DrvMsg(screen, X_ERROR,
- "shmat(low_mem) error: %s\n",strerror(errno));
- goto error3;
- }
- ((linuxInt10Priv *)pInt->private)->base = base;
- if (high_mem > -1) {
- base_high = shmat(high_mem, 0, 0);
- if (base_high == SHMERRORPTR) {
- xf86DrvMsg(screen, X_ERROR,
- "shmat(high_mem) error: %s\n",strerror(errno));
- goto error3;
- }
- ((linuxInt10Priv*)pInt->private)->base_high = base_high;
- } else
- ((linuxInt10Priv*)pInt->private)->base_high = NULL;
-
- if (!MapCurrentInt10(pInt))
- goto error3;
-
- Int10Current = pInt;
-
- DebugF("Mapping int area\n");
- if (xf86ReadBIOS(0, 0, (unsigned char *)0, LOW_PAGE_SIZE) < 0) {
- xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
- goto error3;
- }
- DebugF("done\n");
- /*
- * Read in everything between V_BIOS and SYS_BIOS as some system BIOSes
- * have executable code there. Note that xf86ReadBIOS() can only bring in
- * 64K bytes at a time.
- */
- if (!videoBiosMapped) {
- memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS);
- DebugF("Reading BIOS\n");
- for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
- if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE)
- xf86DrvMsg(screen, X_WARNING,
- "Unable to retrieve all of segment 0x%06lX.\n",
- (long)cs);
- DebugF("done\n");
- }
-
- if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) {
- if (!xf86int10GetBiosSegment(pInt, NULL))
- goto error3;
-
- set_return_trap(pInt);
-#ifdef _PC
- pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH);
- if (! (pInt->Flags & SET_BIOS_SCRATCH))
- pInt->Flags &= ~RESTORE_BIOS_SCRATCH;
- xf86Int10SaveRestoreBIOSVars(pInt, TRUE);
-#endif
- } else {
- const BusType location_type = xf86int10GetBiosLocationType(pInt);
-
- switch (location_type) {
- case BUS_PCI: {
- int err;
- struct pci_device *rom_device =
- xf86GetPciInfoForEntity(pInt->entityIndex);
-
-#if HAVE_PCI_DEVICE_ENABLE
- pci_device_enable(rom_device);
-#endif
-
- err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS));
- if (err) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n",
- strerror(err));
- goto error3;
- }
-
- pInt->BIOSseg = V_BIOS >> 4;
- break;
- }
- default:
- goto error3;
- }
-
- pInt->num = 0xe6;
- reset_int_vect(pInt);
- set_return_trap(pInt);
- LockLegacyVGA(pInt, &vga);
- xf86ExecX86int10(pInt);
- UnlockLegacyVGA(pInt, &vga);
- }
-#ifdef DEBUG
- dprint(0xc0000, 0x20);
-#endif
-
- free(options);
- return pInt;
-
-error3:
- if (base_high)
- shmdt(base_high);
- shmdt(base);
- shmdt(0);
- if (base_high)
- shmdt((char*)HIGH_MEM);
- shmctl(low_mem, IPC_RMID, NULL);
- Int10Current = NULL;
-error2:
- if (high_mem > -1)
- shmctl(high_mem, IPC_RMID,NULL);
-error1:
- if (vMem)
- munmap(vMem, SYS_BIOS - V_BIOS);
- free(((linuxInt10Priv*)pInt->private)->alloc);
- free(pInt->private);
-error0:
- free(options);
- free(pInt);
- return NULL;
-}
-
-Bool
-MapCurrentInt10(xf86Int10InfoPtr pInt)
-{
- pointer addr;
- int fd = -1;
-
- if (Int10Current) {
- shmdt(0);
- if (((linuxInt10Priv*)Int10Current->private)->highMem >= 0)
- shmdt((char*)HIGH_MEM);
- else
- munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
- }
- addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND);
- if (addr == SHMERRORPTR) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n");
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "shmat(low_mem) error: %s\n",strerror(errno));
- return FALSE;
- }
- if (mprotect((void*)0, V_RAM, PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot set EXEC bit on low memory: %s\n", strerror(errno));
-
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0) {
- addr = shmat(((linuxInt10Priv*)pInt->private)->highMem,
- (char*)HIGH_MEM, 0);
- if (addr == SHMERRORPTR) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot shmat() high memory\n");
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "shmget error: %s\n",strerror(errno));
- return FALSE;
- }
- if (mprotect((void*)HIGH_MEM, HIGH_MEM_SIZE,
- PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
- xf86DrvMsg(pInt->scrnIndex, X_ERROR,
- "Cannot set EXEC bit on high memory: %s\n",
- strerror(errno));
- } else {
- if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) {
- if (mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_SHARED | MAP_FIXED, fd, V_BIOS)
- == MAP_FAILED) {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n");
- close (fd);
- return FALSE;
- }
- } else {
- xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n",DEV_MEM);
- return FALSE;
- }
- close (fd);
- }
-
- return TRUE;
-}
-
-void
-xf86FreeInt10(xf86Int10InfoPtr pInt)
-{
- if (!pInt)
- return;
-
-#ifdef _PC
- xf86Int10SaveRestoreBIOSVars(pInt, FALSE);
-#endif
- if (Int10Current == pInt) {
- shmdt(0);
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
- shmdt((char*)HIGH_MEM);
- else
- munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS));
- Int10Current = NULL;
- }
-
- if (((linuxInt10Priv*)pInt->private)->base_high)
- shmdt(((linuxInt10Priv*)pInt->private)->base_high);
- shmdt(((linuxInt10Priv*)pInt->private)->base);
- shmctl(((linuxInt10Priv*)pInt->private)->lowMem, IPC_RMID, NULL);
- if (((linuxInt10Priv*)pInt->private)->highMem >= 0)
- shmctl(((linuxInt10Priv*)pInt->private)->highMem, IPC_RMID, NULL);
- free(((linuxInt10Priv*)pInt->private)->alloc);
- free(pInt->private);
- free(pInt);
-}
-
-void *
-xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off)
-{
- int pagesize = getpagesize();
- int num_pages = ALLOC_ENTRIES(pagesize);
- int i, j;
-
- for (i = 0; i < (num_pages - num); i++) {
- if (((linuxInt10Priv*)pInt->private)->alloc[i] == 0) {
- for (j = i; j < (num + i); j++)
- if ((((linuxInt10Priv*)pInt->private)->alloc[j] != 0))
- break;
- if (j == (num + i))
- break;
- else
- i = i + num;
- }
- }
- if (i == (num_pages - num))
- return NULL;
-
- for (j = i; j < (i + num); j++)
- ((linuxInt10Priv*)pInt->private)->alloc[j] = 1;
-
- *off = (i + 1) * pagesize;
-
- return ((linuxInt10Priv*)pInt->private)->base + ((i + 1) * pagesize);
-}
-
-void
-xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
-{
- int pagesize = getpagesize();
- int first = (((unsigned long)pbase
- - (unsigned long)((linuxInt10Priv*)pInt->private)->base)
- / pagesize) - 1;
- int i;
-
- for (i = first; i < (first + num); i++)
- ((linuxInt10Priv*)pInt->private)->alloc[i] = 0;
-}
-
-static CARD8
-read_b(xf86Int10InfoPtr pInt, int addr)
-{
- return *((CARD8 *)(memType)addr);
-}
-
-static CARD16
-read_w(xf86Int10InfoPtr pInt, int addr)
-{
- return *((CARD16 *)(memType)addr);
-}
-
-static CARD32
-read_l(xf86Int10InfoPtr pInt, int addr)
-{
- return *((CARD32 *)(memType)addr);
-}
-
-static void
-write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
-{
- *((CARD8 *)(memType)addr) = val;
-}
-
-static void
-write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
-{
- *((CARD16 *)(memType)addr) = val;
-}
-
-static
-void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
-{
- *((CARD32 *)(memType) addr) = val;
-}
-
-pointer
-xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
-{
- if (addr < V_RAM)
- return ((linuxInt10Priv*)pInt->private)->base + addr;
- else if (addr < V_BIOS)
- return (pointer)(memType)addr;
- else if (addr < SYS_BIOS) {
- if (((linuxInt10Priv*)pInt->private)->base_high)
- return (pointer)(((linuxInt10Priv*)pInt->private)->base_high
- - V_BIOS + addr);
- else
- return (pointer) (memType)addr;
- } else
- return (pointer) (memType)addr;
-}
-
-#if defined DoSubModules
-
-static Bool
-vm86_tst(void)
-{
- int __res;
-
-#ifdef __PIC__
- /* When compiling with -fPIC, we can't use asm constraint "b" because
- %ebx is already taken by gcc. */
- __asm__ __volatile__("pushl %%ebx\n\t"
- "movl %2,%%ebx\n\t"
- "movl %1,%%eax\n\t"
- "int $0x80\n\t"
- "popl %%ebx"
- :"=a" (__res)
- :"n" ((int)113), "r" (NULL));
-#else
- __asm__ __volatile__("int $0x80\n\t"
- :"=a" (__res):"a" ((int)113),
- "b" ((struct vm86_struct *)NULL));
-#endif
-
- if (__res < 0 && __res == -ENOSYS)
- return FALSE;
-
- return TRUE;
-}
-
-static Int10LinuxSubModuleState
-int10LinuxLoadSubModule(ScrnInfoPtr pScrn)
-{
- if (vm86_tst()) {
- if (xf86LoadSubModule(pScrn,"vm86"))
- return INT10_LOADED_VM86;
- }
- if (xf86LoadSubModule(pScrn,"x86emu"))
- return INT10_LOADED_X86EMU;
-
- return INT10_LOAD_FAILED;
-}
-
-#endif /* DoSubModules */
+/* + * linux specific part of the int10 module + * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2008 Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Pci.h" +#include "compiler.h" +#define _INT10_PRIVATE +#include "xf86int10.h" +#ifdef __sparc__ +#define DEV_MEM "/dev/fb" +#else +#define DEV_MEM "/dev/mem" +#endif +#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1) +#define SHMERRORPTR (pointer)(-1) + +#include <fcntl.h> +#include <errno.h> +#include <sys/mman.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <unistd.h> +#include <string.h> + +static int counter = 0; +static unsigned long int10Generation = 0; + +static CARD8 read_b(xf86Int10InfoPtr pInt, int addr); +static CARD16 read_w(xf86Int10InfoPtr pInt, int addr); +static CARD32 read_l(xf86Int10InfoPtr pInt, int addr); +static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val); +static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val); +static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val); + +int10MemRec linuxMem = { + read_b, + read_w, + read_l, + write_b, + write_w, + write_l +}; + +typedef struct { + int lowMem; + int highMem; + char* base; + char* base_high; + int screen; + char* alloc; +} linuxInt10Priv; + +#if defined DoSubModules + +typedef enum { + INT10_NOT_LOADED, + INT10_LOADED_VM86, + INT10_LOADED_X86EMU, + INT10_LOAD_FAILED +} Int10LinuxSubModuleState; + +static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED; + +static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn); + +#endif /* DoSubModules */ + +xf86Int10InfoPtr +xf86ExtendedInitInt10(int entityIndex, int Flags) +{ + xf86Int10InfoPtr pInt = NULL; + int screen; + int fd; + static void* vidMem = NULL; + static void* sysMem = NULL; + void* vMem = NULL; + void *options = NULL; + int low_mem; + int high_mem = -1; + char *base = SHMERRORPTR; + char *base_high = SHMERRORPTR; + int pagesize; + memType cs; + legacyVGARec vga; + Bool videoBiosMapped = FALSE; + + if (int10Generation != serverGeneration) { + counter = 0; + int10Generation = serverGeneration; + } + + screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex; + + options = xf86HandleInt10Options(xf86Screens[screen],entityIndex); + + if (int10skip(options)) { + free(options); + return NULL; + } + +#if defined DoSubModules + if (loadedSubModule == INT10_NOT_LOADED) + loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]); + + if (loadedSubModule == INT10_LOAD_FAILED) + return NULL; +#endif + + if ((!vidMem) || (!sysMem)) { + if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { + if (!sysMem) { + DebugF("Mapping sys bios area\n"); + if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE, + PROT_READ | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, SYS_BIOS)) + == MAP_FAILED) { + xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n"); + close(fd); + goto error0; + } + } + if (!vidMem) { + DebugF("Mapping VRAM area\n"); + if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, V_RAM)) + == MAP_FAILED) { + xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n"); + close(fd); + goto error0; + } + } + close(fd); + } else { + xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM); + goto error0; + } + } + + pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec)); + pInt->scrnIndex = screen; + pInt->entityIndex = entityIndex; + pInt->dev = xf86GetPciInfoForEntity(entityIndex); + + if (!xf86Int10ExecSetup(pInt)) + goto error0; + pInt->mem = &linuxMem; + pagesize = getpagesize(); + pInt->private = (pointer)xnfcalloc(1, sizeof(linuxInt10Priv)); + ((linuxInt10Priv*)pInt->private)->screen = screen; + ((linuxInt10Priv*)pInt->private)->alloc = + (pointer)xnfcalloc(1, ALLOC_ENTRIES(pagesize)); + + if (!xf86IsEntityPrimary(entityIndex)) { + DebugF("Mapping high memory area\n"); + if ((high_mem = shmget(counter++, HIGH_MEM_SIZE, + IPC_CREAT | SHM_R | SHM_W)) == -1) { + if (errno == ENOSYS) + xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure" + " your kernel to include System V IPC support\n"); + else + xf86DrvMsg(screen, X_ERROR, + "shmget(highmem) error: %s\n",strerror(errno)); + goto error1; + } + } else { + DebugF("Mapping Video BIOS\n"); + videoBiosMapped = TRUE; + if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { + if ((vMem = mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, V_BIOS)) + == MAP_FAILED) { + xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n"); + close(fd); + goto error1; + } + close (fd); + } else + goto error1; + } + ((linuxInt10Priv*)pInt->private)->highMem = high_mem; + + DebugF("Mapping 640kB area\n"); + if ((low_mem = shmget(counter++, V_RAM, + IPC_CREAT | SHM_R | SHM_W)) == -1) { + xf86DrvMsg(screen, X_ERROR, + "shmget(lowmem) error: %s\n",strerror(errno)); + goto error2; + } + + ((linuxInt10Priv*)pInt->private)->lowMem = low_mem; + base = shmat(low_mem, 0, 0); + if (base == SHMERRORPTR) { + xf86DrvMsg(screen, X_ERROR, + "shmat(low_mem) error: %s\n",strerror(errno)); + goto error3; + } + ((linuxInt10Priv *)pInt->private)->base = base; + if (high_mem > -1) { + base_high = shmat(high_mem, 0, 0); + if (base_high == SHMERRORPTR) { + xf86DrvMsg(screen, X_ERROR, + "shmat(high_mem) error: %s\n",strerror(errno)); + goto error3; + } + ((linuxInt10Priv*)pInt->private)->base_high = base_high; + } else + ((linuxInt10Priv*)pInt->private)->base_high = NULL; + + if (!MapCurrentInt10(pInt)) + goto error3; + + Int10Current = pInt; + + DebugF("Mapping int area\n"); + if (xf86ReadBIOS(0, 0, (unsigned char *)0, LOW_PAGE_SIZE) < 0) { + xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n"); + goto error3; + } + DebugF("done\n"); + /* + * Read in everything between V_BIOS and SYS_BIOS as some system BIOSes + * have executable code there. Note that xf86ReadBIOS() can only bring in + * 64K bytes at a time. + */ + if (!videoBiosMapped) { + memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS); + DebugF("Reading BIOS\n"); + for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE) + if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE) + xf86DrvMsg(screen, X_WARNING, + "Unable to retrieve all of segment 0x%06lX.\n", + (long)cs); + DebugF("done\n"); + } + + if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) { + if (!xf86int10GetBiosSegment(pInt, NULL)) + goto error3; + + set_return_trap(pInt); +#ifdef _PC + pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH); + if (! (pInt->Flags & SET_BIOS_SCRATCH)) + pInt->Flags &= ~RESTORE_BIOS_SCRATCH; + xf86Int10SaveRestoreBIOSVars(pInt, TRUE); +#endif + } else { + const BusType location_type = xf86int10GetBiosLocationType(pInt); + + switch (location_type) { + case BUS_PCI: { + int err; + struct pci_device *rom_device = + xf86GetPciInfoForEntity(pInt->entityIndex); + + pci_device_enable(rom_device); + err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS)); + if (err) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n", + strerror(err)); + goto error3; + } + + pInt->BIOSseg = V_BIOS >> 4; + break; + } + default: + goto error3; + } + + pInt->num = 0xe6; + reset_int_vect(pInt); + set_return_trap(pInt); + LockLegacyVGA(pInt, &vga); + xf86ExecX86int10(pInt); + UnlockLegacyVGA(pInt, &vga); + } +#ifdef DEBUG + dprint(0xc0000, 0x20); +#endif + + free(options); + return pInt; + +error3: + if (base_high) + shmdt(base_high); + shmdt(base); + shmdt(0); + if (base_high) + shmdt((char*)HIGH_MEM); + shmctl(low_mem, IPC_RMID, NULL); + Int10Current = NULL; +error2: + if (high_mem > -1) + shmctl(high_mem, IPC_RMID,NULL); +error1: + if (vMem) + munmap(vMem, SYS_BIOS - V_BIOS); + free(((linuxInt10Priv*)pInt->private)->alloc); + free(pInt->private); +error0: + free(options); + free(pInt); + return NULL; +} + +Bool +MapCurrentInt10(xf86Int10InfoPtr pInt) +{ + pointer addr; + int fd = -1; + + if (Int10Current) { + shmdt(0); + if (((linuxInt10Priv*)Int10Current->private)->highMem >= 0) + shmdt((char*)HIGH_MEM); + else + munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS)); + } + addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND); + if (addr == SHMERRORPTR) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n"); + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "shmat(low_mem) error: %s\n",strerror(errno)); + return FALSE; + } + if (mprotect((void*)0, V_RAM, PROT_READ|PROT_WRITE|PROT_EXEC) != 0) + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "Cannot set EXEC bit on low memory: %s\n", strerror(errno)); + + if (((linuxInt10Priv*)pInt->private)->highMem >= 0) { + addr = shmat(((linuxInt10Priv*)pInt->private)->highMem, + (char*)HIGH_MEM, 0); + if (addr == SHMERRORPTR) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "Cannot shmat() high memory\n"); + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "shmget error: %s\n",strerror(errno)); + return FALSE; + } + if (mprotect((void*)HIGH_MEM, HIGH_MEM_SIZE, + PROT_READ|PROT_WRITE|PROT_EXEC) != 0) + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "Cannot set EXEC bit on high memory: %s\n", + strerror(errno)); + } else { + if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { + if (mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, V_BIOS) + == MAP_FAILED) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n"); + close (fd); + return FALSE; + } + } else { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n",DEV_MEM); + return FALSE; + } + close (fd); + } + + return TRUE; +} + +void +xf86FreeInt10(xf86Int10InfoPtr pInt) +{ + if (!pInt) + return; + +#ifdef _PC + xf86Int10SaveRestoreBIOSVars(pInt, FALSE); +#endif + if (Int10Current == pInt) { + shmdt(0); + if (((linuxInt10Priv*)pInt->private)->highMem >= 0) + shmdt((char*)HIGH_MEM); + else + munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS)); + Int10Current = NULL; + } + + if (((linuxInt10Priv*)pInt->private)->base_high) + shmdt(((linuxInt10Priv*)pInt->private)->base_high); + shmdt(((linuxInt10Priv*)pInt->private)->base); + shmctl(((linuxInt10Priv*)pInt->private)->lowMem, IPC_RMID, NULL); + if (((linuxInt10Priv*)pInt->private)->highMem >= 0) + shmctl(((linuxInt10Priv*)pInt->private)->highMem, IPC_RMID, NULL); + free(((linuxInt10Priv*)pInt->private)->alloc); + free(pInt->private); + free(pInt); +} + +void * +xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off) +{ + int pagesize = getpagesize(); + int num_pages = ALLOC_ENTRIES(pagesize); + int i, j; + + for (i = 0; i < (num_pages - num); i++) { + if (((linuxInt10Priv*)pInt->private)->alloc[i] == 0) { + for (j = i; j < (num + i); j++) + if ((((linuxInt10Priv*)pInt->private)->alloc[j] != 0)) + break; + if (j == (num + i)) + break; + else + i = i + num; + } + } + if (i == (num_pages - num)) + return NULL; + + for (j = i; j < (i + num); j++) + ((linuxInt10Priv*)pInt->private)->alloc[j] = 1; + + *off = (i + 1) * pagesize; + + return ((linuxInt10Priv*)pInt->private)->base + ((i + 1) * pagesize); +} + +void +xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num) +{ + int pagesize = getpagesize(); + int first = (((unsigned long)pbase + - (unsigned long)((linuxInt10Priv*)pInt->private)->base) + / pagesize) - 1; + int i; + + for (i = first; i < (first + num); i++) + ((linuxInt10Priv*)pInt->private)->alloc[i] = 0; +} + +static CARD8 +read_b(xf86Int10InfoPtr pInt, int addr) +{ + return *((CARD8 *)(memType)addr); +} + +static CARD16 +read_w(xf86Int10InfoPtr pInt, int addr) +{ + return *((CARD16 *)(memType)addr); +} + +static CARD32 +read_l(xf86Int10InfoPtr pInt, int addr) +{ + return *((CARD32 *)(memType)addr); +} + +static void +write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val) +{ + *((CARD8 *)(memType)addr) = val; +} + +static void +write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val) +{ + *((CARD16 *)(memType)addr) = val; +} + +static +void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val) +{ + *((CARD32 *)(memType) addr) = val; +} + +pointer +xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr) +{ + if (addr < V_RAM) + return ((linuxInt10Priv*)pInt->private)->base + addr; + else if (addr < V_BIOS) + return (pointer)(memType)addr; + else if (addr < SYS_BIOS) { + if (((linuxInt10Priv*)pInt->private)->base_high) + return (pointer)(((linuxInt10Priv*)pInt->private)->base_high + - V_BIOS + addr); + else + return (pointer) (memType)addr; + } else + return (pointer) (memType)addr; +} + +#if defined DoSubModules + +static Bool +vm86_tst(void) +{ + int __res; + +#ifdef __PIC__ + /* When compiling with -fPIC, we can't use asm constraint "b" because + %ebx is already taken by gcc. */ + __asm__ __volatile__("pushl %%ebx\n\t" + "movl %2,%%ebx\n\t" + "movl %1,%%eax\n\t" + "int $0x80\n\t" + "popl %%ebx" + :"=a" (__res) + :"n" ((int)113), "r" (NULL)); +#else + __asm__ __volatile__("int $0x80\n\t" + :"=a" (__res):"a" ((int)113), + "b" ((struct vm86_struct *)NULL)); +#endif + + if (__res < 0 && __res == -ENOSYS) + return FALSE; + + return TRUE; +} + +static Int10LinuxSubModuleState +int10LinuxLoadSubModule(ScrnInfoPtr pScrn) +{ + if (vm86_tst()) { + if (xf86LoadSubModule(pScrn,"vm86")) + return INT10_LOADED_VM86; + } + if (xf86LoadSubModule(pScrn,"x86emu")) + return INT10_LOADED_X86EMU; + + return INT10_LOAD_FAILED; +} + +#endif /* DoSubModules */ diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c deleted file mode 100644 index 4699fcb88..000000000 --- a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c +++ /dev/null @@ -1,75 +0,0 @@ -/*
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of David Wexelblat not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. David Wexelblat makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include <string.h>
-
-/*
- * Read BIOS via /dev/mem.
- */
-
-#ifndef DEV_MEM
-# define DEV_MEM "/dev/mem"
-#endif
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- int fd;
-
-#ifdef __ia64__
- if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0)
-#else
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
-#endif
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return -1;
- }
-
- if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return -1;
- }
- if (read(fd, Buf, Len) != Len)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return -1;
- }
- close(fd);
- return Len;
-}
diff --git a/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c b/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c deleted file mode 100644 index c93c74c4a..000000000 --- a/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -/* - * This file contains the glue needed to support various IA-64 chipsets. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <fcntl.h> -#include <unistd.h> -#include <signal.h> -#include <dirent.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <linux/pci.h> - -#include "compiler.h" -#include "Pci.h" - -/* - * We use special in/out routines here since Altix platforms require the - * use of the sysfs legacy_io interface. The legacy_io file maps to the I/O - * space of a given PCI domain; reads and writes are used to do port I/O. - * The file descriptor for the file is stored in the upper bits of the - * value passed in by the caller, and is created and populated by - * xf86MapLegacyIO. - * - * If the legacy_io interface doesn't exist, we fall back to the glibc in/out - * routines, which are prefixed by an underscore (e.g. _outb). - */ -static int ia64_port_to_fd(unsigned long port) -{ - return (port >> 24) & 0xffffffff; -} - -void outb(unsigned long port, unsigned char val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outb(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 1) != 1) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -void outw(unsigned long port, unsigned short val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outw(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 2) != 2) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -void outl(unsigned long port, unsigned int val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outl(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 4) != 4) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -unsigned int inb(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned char val; - - if (!fd) - return _inb(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 1) != 1) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - -unsigned int inw(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned short val; - - if (!fd) - return _inw(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 2) != 2) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - -unsigned int inl(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned int val; - - if (!fd) - return _inl(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 4) != 4) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - diff --git a/xorg-server/hw/xfree86/os-support/shared/vidmem.c b/xorg-server/hw/xfree86/os-support/shared/vidmem.c index 6358138d8..54f6c6497 100644 --- a/xorg-server/hw/xfree86/os-support/shared/vidmem.c +++ b/xorg-server/hw/xfree86/os-support/shared/vidmem.c @@ -1,296 +1,290 @@ -/*
- * Copyright (c) 1993-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-
-/*
- * This file contains the common part of the video memory mapping functions
- */
-
-/*
- * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold
- * the MTRR option information, but it is likely to be expanded if we do
- * auto unmapping of memory at VT switch.
- *
- */
-
-typedef struct {
- unsigned long physBase;
- unsigned long size;
- pointer virtBase;
- pointer mtrrInfo;
- int flags;
-} MappingRec, *MappingPtr;
-
-typedef struct {
- int numMappings;
- MappingPtr * mappings;
- Bool mtrrEnabled;
- MessageType mtrrFrom;
- Bool mtrrOptChecked;
- ScrnInfoPtr pScrn;
-} VidMapRec, *VidMapPtr;
-
-static int vidMapIndex = -1;
-
-#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
-
-static VidMemInfo vidMemInfo = {FALSE, };
-static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL};
-
-static VidMapPtr
-getVidMapRec(int scrnIndex)
-{
- VidMapPtr vp;
- ScrnInfoPtr pScrn;
-
- if ((scrnIndex < 0) ||
- !(pScrn = xf86Screens[scrnIndex]))
- return &vidMapRec;
-
- if (vidMapIndex < 0)
- vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
-
- if (VIDMAPPTR(pScrn) != NULL)
- return VIDMAPPTR(pScrn);
-
- vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
- vp->mtrrEnabled = TRUE; /* default to enabled */
- vp->mtrrFrom = X_DEFAULT;
- vp->mtrrOptChecked = FALSE;
- vp->pScrn = pScrn;
- return vp;
-}
-
-static MappingPtr
-newMapping(VidMapPtr vp)
-{
- vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
- (vp->numMappings + 1));
- vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
- return vp->mappings[vp->numMappings++];
-}
-
-static MappingPtr
-findMapping(VidMapPtr vp, pointer vbase, unsigned long size)
-{
- int i;
-
- for (i = 0; i < vp->numMappings; i++) {
- if (vp->mappings[i]->virtBase == vbase &&
- vp->mappings[i]->size == size)
- return vp->mappings[i];
- }
- return NULL;
-}
-
-static void
-removeMapping(VidMapPtr vp, MappingPtr mp)
-{
- int i, found = 0;
-
- for (i = 0; i < vp->numMappings; i++) {
- if (vp->mappings[i] == mp) {
- found = 1;
- free(vp->mappings[i]);
- } else if (found) {
- vp->mappings[i - 1] = vp->mappings[i];
- }
- }
- vp->numMappings--;
- vp->mappings[vp->numMappings] = NULL;
-}
-
-enum { OPTION_MTRR };
-static const OptionInfoRec opts[] =
-{
- { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
-};
-
-static void
-checkMtrrOption(VidMapPtr vp)
-{
- if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
- OptionInfoPtr options;
-
- options = xnfalloc(sizeof(opts));
- (void)memcpy(options, opts, sizeof(opts));
- xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options,
- options);
- if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
- vp->mtrrFrom = X_CONFIG;
- free(options);
- vp->mtrrOptChecked = TRUE;
- }
-}
-
-void
-xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase)
-{
- VidMapPtr vp;
- MappingPtr mp;
-
- vp = getVidMapRec(ScreenNum);
- mp = newMapping(vp);
- mp->physBase = Base;
- mp->size = Size;
- mp->virtBase = Vbase;
- mp->flags = Flags;
-}
-
-void
-xf86InitVidMem(void)
-{
- if (!vidMemInfo.initialised) {
- memset(&vidMemInfo, 0, sizeof(VidMemInfo));
- xf86OSInitVidMem(&vidMemInfo);
- }
-}
-
-pointer
-xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
-{
- pointer vbase = NULL;
- VidMapPtr vp;
- MappingPtr mp;
-
- if (((Flags & VIDMEM_FRAMEBUFFER) &&
- (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
- FatalError("Mapping memory with more than one type\n");
-
- xf86InitVidMem();
- if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
- return NULL;
-
- vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
-
- if (!vbase || vbase == (pointer)-1)
- return NULL;
-
- vp = getVidMapRec(ScreenNum);
- mp = newMapping(vp);
- mp->physBase = Base;
- mp->size = Size;
- mp->virtBase = vbase;
- mp->flags = Flags;
-
- /*
- * Check the "mtrr" option even when MTRR isn't supported to avoid
- * warnings about unrecognised options.
- */
- checkMtrrOption(vp);
-
- if (vp->mtrrEnabled && vidMemInfo.setWC) {
- if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
- mp->mtrrInfo =
- vidMemInfo.setWC(ScreenNum, Base, Size, FALSE,
- vp->mtrrFrom);
- else if (Flags & VIDMEM_FRAMEBUFFER)
- mp->mtrrInfo =
- vidMemInfo.setWC(ScreenNum, Base, Size, TRUE,
- vp->mtrrFrom);
- }
- return vbase;
-}
-
-void
-xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
- VidMapPtr vp;
- MappingPtr mp;
-
- if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
- xf86DrvMsg(ScreenNum, X_WARNING,
- "xf86UnMapVidMem() called before xf86MapVidMem()\n");
- return;
- }
-
- vp = getVidMapRec(ScreenNum);
- mp = findMapping(vp, Base, Size);
- if (!mp) {
- xf86DrvMsg(ScreenNum, X_WARNING,
- "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
- Base, Size);
- return;
- }
- if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
- vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
-
- vidMemInfo.unmapMem(ScreenNum, Base, Size);
- removeMapping(vp, mp);
-}
-
-Bool
-xf86CheckMTRR(int ScreenNum)
-{
- VidMapPtr vp = getVidMapRec(ScreenNum);
-
- /*
- * Check the "mtrr" option even when MTRR isn't supported to avoid
- * warnings about unrecognised options.
- */
- checkMtrrOption(vp);
-
- if (vp->mtrrEnabled && vidMemInfo.setWC)
- return TRUE;
-
- return FALSE;
-}
-
-Bool
-xf86LinearVidMem(void)
-{
- xf86InitVidMem();
- return vidMemInfo.linearSupported;
-}
-
-void
-xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base,
- unsigned long Size)
-{
- if (!(Flags & VIDMEM_READSIDEEFFECT))
- return;
-
- if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects)
- return;
-
- vidMemInfo.readSideEffects(ScreenNum, base, Size);
-}
-
+/* + * Copyright (c) 1993-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +/* + * This file contains the common part of the video memory mapping functions + */ + +/* + * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold + * the MTRR option information, but it is likely to be expanded if we do + * auto unmapping of memory at VT switch. + * + */ + +typedef struct { + unsigned long size; + pointer virtBase; + pointer mtrrInfo; +} MappingRec, *MappingPtr; + +typedef struct { + int numMappings; + MappingPtr * mappings; + Bool mtrrEnabled; + MessageType mtrrFrom; + Bool mtrrOptChecked; + ScrnInfoPtr pScrn; +} VidMapRec, *VidMapPtr; + +static int vidMapIndex = -1; + +#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr)) + +static VidMemInfo vidMemInfo = {FALSE, }; +static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL}; + +static VidMapPtr +getVidMapRec(int scrnIndex) +{ + VidMapPtr vp; + ScrnInfoPtr pScrn; + + if ((scrnIndex < 0) || + !(pScrn = xf86Screens[scrnIndex])) + return &vidMapRec; + + if (vidMapIndex < 0) + vidMapIndex = xf86AllocateScrnInfoPrivateIndex(); + + if (VIDMAPPTR(pScrn) != NULL) + return VIDMAPPTR(pScrn); + + vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1); + vp->mtrrEnabled = TRUE; /* default to enabled */ + vp->mtrrFrom = X_DEFAULT; + vp->mtrrOptChecked = FALSE; + vp->pScrn = pScrn; + return vp; +} + +static MappingPtr +newMapping(VidMapPtr vp) +{ + vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) * + (vp->numMappings + 1)); + vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1); + return vp->mappings[vp->numMappings++]; +} + +static MappingPtr +findMapping(VidMapPtr vp, pointer vbase, unsigned long size) +{ + int i; + + for (i = 0; i < vp->numMappings; i++) { + if (vp->mappings[i]->virtBase == vbase && + vp->mappings[i]->size == size) + return vp->mappings[i]; + } + return NULL; +} + +static void +removeMapping(VidMapPtr vp, MappingPtr mp) +{ + int i, found = 0; + + for (i = 0; i < vp->numMappings; i++) { + if (vp->mappings[i] == mp) { + found = 1; + free(vp->mappings[i]); + } else if (found) { + vp->mappings[i - 1] = vp->mappings[i]; + } + } + vp->numMappings--; + vp->mappings[vp->numMappings] = NULL; +} + +enum { OPTION_MTRR }; +static const OptionInfoRec opts[] = +{ + { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +static void +checkMtrrOption(VidMapPtr vp) +{ + if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) { + OptionInfoPtr options; + + options = xnfalloc(sizeof(opts)); + (void)memcpy(options, opts, sizeof(opts)); + xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, + options); + if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled)) + vp->mtrrFrom = X_CONFIG; + free(options); + vp->mtrrOptChecked = TRUE; + } +} + +void +xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase) +{ + VidMapPtr vp; + MappingPtr mp; + + vp = getVidMapRec(ScreenNum); + mp = newMapping(vp); + mp->size = Size; + mp->virtBase = Vbase; +} + +void +xf86InitVidMem(void) +{ + if (!vidMemInfo.initialised) { + memset(&vidMemInfo, 0, sizeof(VidMemInfo)); + xf86OSInitVidMem(&vidMemInfo); + } +} + +pointer +xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) +{ + pointer vbase = NULL; + VidMapPtr vp; + MappingPtr mp; + + if (((Flags & VIDMEM_FRAMEBUFFER) && + (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)))) + FatalError("Mapping memory with more than one type\n"); + + xf86InitVidMem(); + if (!vidMemInfo.initialised || !vidMemInfo.mapMem) + return NULL; + + vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags); + + if (!vbase || vbase == (pointer)-1) + return NULL; + + vp = getVidMapRec(ScreenNum); + mp = newMapping(vp); + mp->size = Size; + mp->virtBase = vbase; + + /* + * Check the "mtrr" option even when MTRR isn't supported to avoid + * warnings about unrecognised options. + */ + checkMtrrOption(vp); + + if (vp->mtrrEnabled && vidMemInfo.setWC) { + if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)) + mp->mtrrInfo = + vidMemInfo.setWC(ScreenNum, Base, Size, FALSE, + vp->mtrrFrom); + else if (Flags & VIDMEM_FRAMEBUFFER) + mp->mtrrInfo = + vidMemInfo.setWC(ScreenNum, Base, Size, TRUE, + vp->mtrrFrom); + } + return vbase; +} + +void +xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + VidMapPtr vp; + MappingPtr mp; + + if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) { + xf86DrvMsg(ScreenNum, X_WARNING, + "xf86UnMapVidMem() called before xf86MapVidMem()\n"); + return; + } + + vp = getVidMapRec(ScreenNum); + mp = findMapping(vp, Base, Size); + if (!mp) { + xf86DrvMsg(ScreenNum, X_WARNING, + "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n", + Base, Size); + return; + } + if (vp->mtrrEnabled && vidMemInfo.undoWC && mp) + vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo); + + vidMemInfo.unmapMem(ScreenNum, Base, Size); + removeMapping(vp, mp); +} + +Bool +xf86CheckMTRR(int ScreenNum) +{ + VidMapPtr vp = getVidMapRec(ScreenNum); + + /* + * Check the "mtrr" option even when MTRR isn't supported to avoid + * warnings about unrecognised options. + */ + checkMtrrOption(vp); + + if (vp->mtrrEnabled && vidMemInfo.setWC) + return TRUE; + + return FALSE; +} + +Bool +xf86LinearVidMem(void) +{ + xf86InitVidMem(); + return vidMemInfo.linearSupported; +} + +void +xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base, + unsigned long Size) +{ + if (!(Flags & VIDMEM_READSIDEEFFECT)) + return; + + if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects) + return; + + vidMemInfo.readSideEffects(ScreenNum, base, Size); +} + diff --git a/xorg-server/hw/xfree86/os-support/stub/Makefile.am b/xorg-server/hw/xfree86/os-support/stub/Makefile.am new file mode 100644 index 000000000..a1156ef1b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/stub/Makefile.am @@ -0,0 +1,19 @@ +noinst_LTLIBRARIES = libstub.la + +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) + +INCLUDES = $(XORG_INCS) + +libstub_la_SOURCES = \ + $(srcdir)/../shared/VTsw_noop.c \ + $(srcdir)/../shared/agp_noop.c \ + $(srcdir)/../shared/ioperm_noop.c \ + $(srcdir)/../shared/kmod_noop.c \ + $(srcdir)/../shared/pm_noop.c \ + $(srcdir)/../shared/vidmem.c \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c \ + stub_bell.c \ + stub_bios.c \ + stub_init.c \ + stub_video.c diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_bell.c b/xorg-server/hw/xfree86/os-support/stub/stub_bell.c new file mode 100644 index 000000000..48625928f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/stub/stub_bell.c @@ -0,0 +1,10 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSlib.h" + +void +xf86OSRingBell(int loudness, int pitch, int duration) +{ +} diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_bios.c b/xorg-server/hw/xfree86/os-support/stub/stub_bios.c new file mode 100644 index 000000000..8628316dd --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/stub/stub_bios.c @@ -0,0 +1,12 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSlib.h" + +int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + return -1; +} diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_init.c b/xorg-server/hw/xfree86/os-support/stub/stub_init.c new file mode 100644 index 000000000..36fd2b818 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/stub/stub_init.c @@ -0,0 +1,26 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSlib.h" + +void +xf86OpenConsole() +{ +} + +void +xf86CloseConsole() +{ +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + return 0; +} + +void +xf86UseMsg() +{ +} diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_video.c b/xorg-server/hw/xfree86/os-support/stub/stub_video.c new file mode 100644 index 000000000..327496839 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/stub/stub_video.c @@ -0,0 +1,13 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->initialised = TRUE; + return; +} diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h index 6a29fbdc9..78ea6e660 100644 --- a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h +++ b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h @@ -132,10 +132,10 @@ _XFUNCPROTOBEGIN /* public functions */ extern _X_EXPORT Bool xf86LinearVidMem(void); -extern _X_EXPORT Bool xf86CheckMTRR(int); -extern _X_EXPORT pointer xf86MapVidMem(int, int, unsigned long, unsigned long); -extern _X_EXPORT void xf86UnMapVidMem(int, pointer, unsigned long); -extern _X_EXPORT void xf86MapReadSideEffects(int, int, pointer, unsigned long); +extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int); +extern _X_EXPORT _X_DEPRECATED pointer xf86MapVidMem(int, int, unsigned long, unsigned long); +extern _X_EXPORT _X_DEPRECATED void xf86UnMapVidMem(int, pointer, unsigned long); +extern _X_EXPORT _X_DEPRECATED void xf86MapReadSideEffects(int, int, pointer, unsigned long); extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int); extern _X_EXPORT Bool xf86EnableIO(void); extern _X_EXPORT void xf86DisableIO(void); @@ -209,7 +209,7 @@ extern _X_EXPORT int xf86ProcessArgument(int, char **, int); extern _X_EXPORT void xf86UseMsg(void); extern _X_EXPORT PMClose xf86OSPMOpen(void); -extern _X_EXPORT void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer); +extern _X_EXPORT _X_DEPRECATED void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer); extern _X_EXPORT void xf86InitVidMem(void); #endif /* XF86_OS_PRIVS */ diff --git a/xorg-server/hw/xfree86/sdksyms.sh b/xorg-server/hw/xfree86/sdksyms.sh index 18bb73523..b8e7023f3 100644 --- a/xorg-server/hw/xfree86/sdksyms.sh +++ b/xorg-server/hw/xfree86/sdksyms.sh @@ -52,7 +52,9 @@ cat > sdksyms.c << EOF */ #include "geext.h" #include "geint.h" +#ifdef MITSHM #include "shmint.h" +#endif #include "syncsdk.h" #if XINERAMA # include "panoramiXsrv.h" @@ -118,14 +120,16 @@ cat > sdksyms.c << EOF #include "xf86.h" #include "xf86Module.h" #include "xf86Opt.h" -#include "xf86PciInfo.h" +#ifdef XSERVER_LIBPCIACCESS + #include "xf86PciInfo.h" + #include "xf86VGAarbiter.h" +#endif #include "xf86Priv.h" #include "xf86Privstr.h" #include "xf86cmap.h" #include "xf86fbman.h" #include "xf86str.h" #include "xf86Xinput.h" -#include "xf86VGAarbiter.h" #include "xisb.h" #if XV # include "xf86xv.h" @@ -170,7 +174,9 @@ cat > sdksyms.c << EOF /* hw/xfree86/os-support/bus/Makefile.am */ -#include "xf86Pci.h" +#ifdef XSERVER_LIBPCIACCESS +# include "xf86Pci.h" +#endif #if defined(__sparc__) || defined(__sparc) # include "xf86Sbus.h" #endif diff --git a/xorg-server/hw/xfree86/shadowfb/Makefile.am b/xorg-server/hw/xfree86/shadowfb/Makefile.am index 02d2dd4ea..39c66109e 100644 --- a/xorg-server/hw/xfree86/shadowfb/Makefile.am +++ b/xorg-server/hw/xfree86/shadowfb/Makefile.am @@ -1,5 +1,5 @@ module_LTLIBRARIES = libshadowfb.la -libshadowfb_la_LDFLAGS = -avoid-version +libshadowfb_la_LDFLAGS = -module -avoid-version libshadowfb_la_SOURCES = sfbmodule.c shadow.c sdk_HEADERS = shadowfb.h diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.c b/xorg-server/hw/xfree86/utils/cvt/cvt.c index 1ff38118b..0de5ffea4 100644 --- a/xorg-server/hw/xfree86/utils/cvt/cvt.c +++ b/xorg-server/hw/xfree86/utils/cvt/cvt.c @@ -1,300 +1,293 @@ -/*
- * Copyright 2005-2006 Luc Verhaegen.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-/* Standalone VESA CVT standard timing modelines generator. */
-
-#include "xf86.h"
-
-/* Error implementation used by the server code we built in */
-void
-Error(const char *str)
-{
- perror(str);
-}
-
-/* FatalError implementation used by the server code we built in */
-void
-FatalError(const char *f, ...)
-{
- va_list args;
- va_start(args, f);
- vfprintf(stderr, f, args);
- va_end(args);
- exit(1);
-}
-
-/* xnfalloc implementation used by the server code we built in */
-pointer
-XNFalloc(unsigned long n)
-{
- pointer r;
-
- r = malloc(n);
- if (!r) {
- perror("malloc failed");
- exit(1);
- }
- return r;
-}
-
-/* xnfcalloc implementation used by the server code we built in */
-pointer
-XNFcalloc(unsigned long n)
-{
- pointer r;
-
- r = calloc(1, n);
- if (!r) {
- perror("calloc failed");
- exit(1);
- }
- return r;
-}
-
-/*
- * Quickly check wether this is a CVT standard mode.
- */
-static Bool
-CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
- Bool Verbose)
-{
- Bool IsCVT = TRUE;
-
- if ((!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) ||
- (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) ||
- (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) ||
- (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) ||
- (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)))
- ;
- else {
- if (Verbose)
- fprintf(stderr, "Warning: Aspect Ratio is not CVT standard.\n");
- IsCVT = FALSE;
- }
-
- if ((VRefresh != 50.0) && (VRefresh != 60.0) &&
- (VRefresh != 75.0) && (VRefresh != 85.0)) {
- if (Verbose)
- fprintf(stderr, "Warning: Refresh Rate is not CVT standard "
- "(50, 60, 75 or 85Hz).\n");
- IsCVT = FALSE;
- }
-
- return IsCVT;
-}
-
-
-/*
- * I'm not documenting --interlaced for obvious reasons, even though I did
- * implement it. I also can't deny having looked at gtf here.
- */
-static void
-PrintUsage(char *Name)
-{
- fprintf(stderr, "\n");
- fprintf(stderr, "usage: %s [-v|--verbose] [-r|--reduced] X Y [refresh]\n",
- Name);
- fprintf(stderr, "\n");
- fprintf(stderr, " -v|--verbose : Warn about CVT standard adherance.\n");
- fprintf(stderr, " -r|--reduced : Create a mode with reduced blanking "
- "(default: normal blanking).\n");
- fprintf(stderr, " X : Desired horizontal resolution "
- "(multiple of 8, required).\n");
- fprintf(stderr, " Y : Desired vertical resolution (required).\n");
- fprintf(stderr, " refresh : Desired refresh rate (default: 60.0Hz).\n");
- fprintf(stderr, "\n");
-
- fprintf(stderr, "Calculates VESA CVT (Coordinated Video Timing) modelines"
- " for use with X.\n");
-}
-
-
-/*
- *
- */
-static void
-PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced)
-{
- printf("# %dx%d %.2f Hz ", Mode->HDisplay, Mode->VDisplay, Mode->VRefresh);
-
- if (CVT) {
- printf("(CVT %.2fM",
- ((float) Mode->HDisplay * Mode->VDisplay) / 1000000.0);
-
- if (!(Mode->VDisplay % 3) &&
- ((Mode->VDisplay * 4 / 3) == Mode->HDisplay))
- printf("3");
- else if (!(Mode->VDisplay % 9) &&
- ((Mode->VDisplay * 16 / 9) == Mode->HDisplay))
- printf("9");
- else if (!(Mode->VDisplay % 10) &&
- ((Mode->VDisplay * 16 / 10) == Mode->HDisplay))
- printf("A");
- else if (!(Mode->VDisplay % 4) &&
- ((Mode->VDisplay * 5 / 4) == Mode->HDisplay))
- printf("4");
- else if (!(Mode->VDisplay % 9) &&
- ((Mode->VDisplay * 15 / 9) == Mode->HDisplay))
- printf("9");
-
- if (Reduced)
- printf("-R");
-
- printf(") ");
- } else
- printf("(CVT) ");
-
- printf("hsync: %.2f kHz; ", Mode->HSync);
- printf("pclk: %.2f MHz", ((float ) Mode->Clock) / 1000.0);
-
- printf("\n");
-}
-
-
-/*
- * Originally grabbed from xf86Mode.c.
- *
- * Ignoring the actual Mode->name, as the user will want something solid
- * to grab hold of.
- */
-static void
-PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh,
- Bool Reduced)
-{
- if (Reduced)
- printf("Modeline \"%dx%dR\" ", HDisplay, VDisplay);
- else
- printf("Modeline \"%dx%d_%.2f\" ", HDisplay, VDisplay, VRefresh);
-
- printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock/1000., Mode->HDisplay,
- Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal, Mode->VDisplay,
- Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal);
-
- if (Mode->Flags & V_INTERLACE)
- printf(" interlace");
- if (Mode->Flags & V_PHSYNC)
- printf(" +hsync");
- if (Mode->Flags & V_NHSYNC)
- printf(" -hsync");
- if (Mode->Flags & V_PVSYNC)
- printf(" +vsync");
- if (Mode->Flags & V_NVSYNC)
- printf(" -vsync");
-
- printf("\n");
-}
-
-
-/*
- *
- */
-int
-main (int argc, char *argv[])
-{
- DisplayModeRec *Mode;
- int HDisplay = 0, VDisplay = 0;
- float VRefresh = 0.0;
- Bool Reduced = FALSE, Verbose = FALSE, IsCVT;
- Bool Interlaced = FALSE;
- int n;
-
- if ((argc < 3) || (argc > 7)) {
- PrintUsage(argv[0]);
- return 1;
- }
-
- /* This doesn't filter out bad flags properly. Bad flags get passed down
- * to atoi/atof, which then return 0, so that these variables can get
- * filled next time round. So this is just a cosmetic problem.
- */
- for (n = 1; n < argc; n++) {
- if (!strcmp(argv[n], "-r") || !strcmp(argv[n], "--reduced"))
- Reduced = TRUE;
- else if (!strcmp(argv[n], "-i") || !strcmp(argv[n], "--interlaced"))
- Interlaced = TRUE;
- else if (!strcmp(argv[n], "-v") || !strcmp(argv[n], "--verbose"))
- Verbose = TRUE;
- else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) {
- PrintUsage(argv[0]);
- return 0;
- } else if (!HDisplay) {
- HDisplay = atoi(argv[n]);
- if (!HDisplay) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
- else if (!VDisplay) {
- VDisplay = atoi(argv[n]);
- if (!VDisplay) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
- else if (!VRefresh) {
- VRefresh = atof(argv[n]);
- if (!VRefresh) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
- else {
- PrintUsage(argv[0]);
- return 1;
- }
- }
-
- if (!HDisplay || !VDisplay) {
- PrintUsage(argv[0]);
- return 0;
- }
-
- /* Default to 60.0Hz */
- if (!VRefresh)
- VRefresh = 60.0;
-
- /* Horizontal timing is always a multiple of 8: round up. */
- if (HDisplay & 0x07) {
- HDisplay &= ~0x07;
- HDisplay += 8;
- }
-
- if (Reduced) {
- if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
- fprintf(stderr,
- "\nERROR: Multiple of 60Hz refresh rate required for "
- " reduced blanking.\n");
- PrintUsage(argv[0]);
- return 0;
- }
- }
-
- IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose);
-
- Mode = xf86CVTMode(HDisplay, VDisplay, VRefresh, Reduced, Interlaced);
-
- PrintComment(Mode, IsCVT, Reduced);
- PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced);
-
- return 0;
-}
+/* + * Copyright 2005-2006 Luc Verhaegen. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +/* Standalone VESA CVT standard timing modelines generator. */ + +#include "xf86.h" + +/* FatalError implementation used by the server code we built in */ +void +FatalError(const char *f, ...) +{ + va_list args; + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); + exit(1); +} + +/* xnfalloc implementation used by the server code we built in */ +pointer +XNFalloc(unsigned long n) +{ + pointer r; + + r = malloc(n); + if (!r) { + perror("malloc failed"); + exit(1); + } + return r; +} + +/* xnfcalloc implementation used by the server code we built in */ +pointer +XNFcalloc(unsigned long n) +{ + pointer r; + + r = calloc(1, n); + if (!r) { + perror("calloc failed"); + exit(1); + } + return r; +} + +/* + * Quickly check wether this is a CVT standard mode. + */ +static Bool +CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, + Bool Verbose) +{ + Bool IsCVT = TRUE; + + if ((!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) || + (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) || + (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) || + (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) || + (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay))) + ; + else { + if (Verbose) + fprintf(stderr, "Warning: Aspect Ratio is not CVT standard.\n"); + IsCVT = FALSE; + } + + if ((VRefresh != 50.0) && (VRefresh != 60.0) && + (VRefresh != 75.0) && (VRefresh != 85.0)) { + if (Verbose) + fprintf(stderr, "Warning: Refresh Rate is not CVT standard " + "(50, 60, 75 or 85Hz).\n"); + IsCVT = FALSE; + } + + return IsCVT; +} + + +/* + * I'm not documenting --interlaced for obvious reasons, even though I did + * implement it. I also can't deny having looked at gtf here. + */ +static void +PrintUsage(char *Name) +{ + fprintf(stderr, "\n"); + fprintf(stderr, "usage: %s [-v|--verbose] [-r|--reduced] X Y [refresh]\n", + Name); + fprintf(stderr, "\n"); + fprintf(stderr, " -v|--verbose : Warn about CVT standard adherance.\n"); + fprintf(stderr, " -r|--reduced : Create a mode with reduced blanking " + "(default: normal blanking).\n"); + fprintf(stderr, " X : Desired horizontal resolution " + "(multiple of 8, required).\n"); + fprintf(stderr, " Y : Desired vertical resolution (required).\n"); + fprintf(stderr, " refresh : Desired refresh rate (default: 60.0Hz).\n"); + fprintf(stderr, "\n"); + + fprintf(stderr, "Calculates VESA CVT (Coordinated Video Timing) modelines" + " for use with X.\n"); +} + + +/* + * + */ +static void +PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced) +{ + printf("# %dx%d %.2f Hz ", Mode->HDisplay, Mode->VDisplay, Mode->VRefresh); + + if (CVT) { + printf("(CVT %.2fM", + ((float) Mode->HDisplay * Mode->VDisplay) / 1000000.0); + + if (!(Mode->VDisplay % 3) && + ((Mode->VDisplay * 4 / 3) == Mode->HDisplay)) + printf("3"); + else if (!(Mode->VDisplay % 9) && + ((Mode->VDisplay * 16 / 9) == Mode->HDisplay)) + printf("9"); + else if (!(Mode->VDisplay % 10) && + ((Mode->VDisplay * 16 / 10) == Mode->HDisplay)) + printf("A"); + else if (!(Mode->VDisplay % 4) && + ((Mode->VDisplay * 5 / 4) == Mode->HDisplay)) + printf("4"); + else if (!(Mode->VDisplay % 9) && + ((Mode->VDisplay * 15 / 9) == Mode->HDisplay)) + printf("9"); + + if (Reduced) + printf("-R"); + + printf(") "); + } else + printf("(CVT) "); + + printf("hsync: %.2f kHz; ", Mode->HSync); + printf("pclk: %.2f MHz", ((float ) Mode->Clock) / 1000.0); + + printf("\n"); +} + + +/* + * Originally grabbed from xf86Mode.c. + * + * Ignoring the actual Mode->name, as the user will want something solid + * to grab hold of. + */ +static void +PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh, + Bool Reduced) +{ + if (Reduced) + printf("Modeline \"%dx%dR\" ", HDisplay, VDisplay); + else + printf("Modeline \"%dx%d_%.2f\" ", HDisplay, VDisplay, VRefresh); + + printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock/1000., Mode->HDisplay, + Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal, Mode->VDisplay, + Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal); + + if (Mode->Flags & V_INTERLACE) + printf(" interlace"); + if (Mode->Flags & V_PHSYNC) + printf(" +hsync"); + if (Mode->Flags & V_NHSYNC) + printf(" -hsync"); + if (Mode->Flags & V_PVSYNC) + printf(" +vsync"); + if (Mode->Flags & V_NVSYNC) + printf(" -vsync"); + + printf("\n"); +} + + +/* + * + */ +int +main (int argc, char *argv[]) +{ + DisplayModeRec *Mode; + int HDisplay = 0, VDisplay = 0; + float VRefresh = 0.0; + Bool Reduced = FALSE, Verbose = FALSE, IsCVT; + Bool Interlaced = FALSE; + int n; + + if ((argc < 3) || (argc > 7)) { + PrintUsage(argv[0]); + return 1; + } + + /* This doesn't filter out bad flags properly. Bad flags get passed down + * to atoi/atof, which then return 0, so that these variables can get + * filled next time round. So this is just a cosmetic problem. + */ + for (n = 1; n < argc; n++) { + if (!strcmp(argv[n], "-r") || !strcmp(argv[n], "--reduced")) + Reduced = TRUE; + else if (!strcmp(argv[n], "-i") || !strcmp(argv[n], "--interlaced")) + Interlaced = TRUE; + else if (!strcmp(argv[n], "-v") || !strcmp(argv[n], "--verbose")) + Verbose = TRUE; + else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) { + PrintUsage(argv[0]); + return 0; + } else if (!HDisplay) { + HDisplay = atoi(argv[n]); + if (!HDisplay) { + PrintUsage(argv[0]); + return 1; + } + } + else if (!VDisplay) { + VDisplay = atoi(argv[n]); + if (!VDisplay) { + PrintUsage(argv[0]); + return 1; + } + } + else if (!VRefresh) { + VRefresh = atof(argv[n]); + if (!VRefresh) { + PrintUsage(argv[0]); + return 1; + } + } + else { + PrintUsage(argv[0]); + return 1; + } + } + + if (!HDisplay || !VDisplay) { + PrintUsage(argv[0]); + return 0; + } + + /* Default to 60.0Hz */ + if (!VRefresh) + VRefresh = 60.0; + + /* Horizontal timing is always a multiple of 8: round up. */ + if (HDisplay & 0x07) { + HDisplay &= ~0x07; + HDisplay += 8; + } + + if (Reduced) { + if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) { + fprintf(stderr, + "\nERROR: Multiple of 60Hz refresh rate required for " + " reduced blanking.\n"); + PrintUsage(argv[0]); + return 0; + } + } + + IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose); + + Mode = xf86CVTMode(HDisplay, VDisplay, VRefresh, Reduced, Interlaced); + + PrintComment(Mode, IsCVT, Reduced); + PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced); + + return 0; +} diff --git a/xorg-server/hw/xfree86/vbe/Makefile.am b/xorg-server/hw/xfree86/vbe/Makefile.am index 85c6fd82a..4b794e647 100644 --- a/xorg-server/hw/xfree86/vbe/Makefile.am +++ b/xorg-server/hw/xfree86/vbe/Makefile.am @@ -1,5 +1,5 @@ module_LTLIBRARIES = libvbe.la -libvbe_la_LDFLAGS = -avoid-version +libvbe_la_LDFLAGS = -module -avoid-version libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c sdk_HEADERS = vbe.h vbeModes.h diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.c b/xorg-server/hw/xfree86/vgahw/vgaHW.c index 7b1c95e62..4036a01f5 100644 --- a/xorg-server/hw/xfree86/vgahw/vgaHW.c +++ b/xorg-server/hw/xfree86/vgahw/vgaHW.c @@ -1,1994 +1,2080 @@ -
-/*
- *
- * Copyright 1991-1999 by The XFree86 Project, Inc.
- *
- * Loosely based on code bearing the following copyright:
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- */
-
-#define _NEED_SYSI86
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <X11/X.h>
-#include "misc.h"
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "vgaHW.h"
-
-#include "compiler.h"
-
-#include "xf86cmap.h"
-
-#include "Pci.h"
-
-#ifndef SAVE_FONT1
-#define SAVE_FONT1 1
-#endif
-
-/*
- * These used to be OS-specific, which made this module have an undesirable
- * OS dependency. Define them by default for all platforms.
- */
-#ifndef NEED_SAVED_CMAP
-#define NEED_SAVED_CMAP
-#endif
-#ifndef SAVE_TEXT
-#define SAVE_TEXT 1
-#endif
-#ifndef SAVE_FONT2
-#define SAVE_FONT2 1
-#endif
-
-/* bytes per plane to save for text */
-#define TEXT_AMOUNT 16384
-
-/* bytes per plane to save for font data */
-#define FONT_AMOUNT (8*8192)
-
-#if 0
-/* Override all of these for now */
-#undef SAVE_FONT1
-#define SAVE_FONT1 1
-#undef SAVE_FONT2
-#define SAVE_FONT2 1
-#undef SAVE_TEST
-#define SAVE_TEST 1
-#undef FONT_AMOUNT
-#define FONT_AMOUNT 65536
-#undef TEXT_AMOUNT
-#define TEXT_AMOUNT 65536
-#endif
-
-/* DAC indices for white and black */
-#define WHITE_VALUE 0x3F
-#define BLACK_VALUE 0x00
-#define OVERSCAN_VALUE 0x01
-
-
-/* Use a private definition of this here */
-#undef VGAHWPTR
-#define VGAHWPTRLVAL(p) (p)->privates[vgaHWPrivateIndex].ptr
-#define VGAHWPTR(p) ((vgaHWPtr)(VGAHWPTRLVAL(p)))
-
-static int vgaHWPrivateIndex = -1;
-
-#define DAC_TEST_MASK 0x3F
-
-#ifdef NEED_SAVED_CMAP
-/* This default colourmap is used only when it can't be read from the VGA */
-
-static CARD8 defaultDAC[768] =
-{
- 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42,
- 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42,
- 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63,
- 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63,
- 0, 0, 0, 5, 5, 5, 8, 8, 8, 11, 11, 11,
- 14, 14, 14, 17, 17, 17, 20, 20, 20, 24, 24, 24,
- 28, 28, 28, 32, 32, 32, 36, 36, 36, 40, 40, 40,
- 45, 45, 45, 50, 50, 50, 56, 56, 56, 63, 63, 63,
- 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, 63,
- 63, 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16,
- 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0,
- 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, 0,
- 0, 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47,
- 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63,
- 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, 63,
- 63, 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39,
- 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31,
- 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, 31,
- 31, 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55,
- 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63,
- 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, 63,
- 63, 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49,
- 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45,
- 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, 45,
- 45, 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58,
- 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63,
- 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, 28,
- 28, 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7,
- 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0,
- 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, 0,
- 0, 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21,
- 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28,
- 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, 28,
- 28, 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17,
- 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14,
- 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, 14,
- 14, 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24,
- 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28,
- 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, 28,
- 28, 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22,
- 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20,
- 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, 20,
- 20, 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26,
- 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28,
- 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, 16,
- 16, 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4,
- 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0,
- 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, 0,
- 0, 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12,
- 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16,
- 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, 16,
- 16, 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10,
- 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8,
- 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, 8,
- 8, 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14,
- 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16,
- 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, 16,
- 16, 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12,
- 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11,
- 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, 11,
- 11, 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15,
- 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-#endif /* NEED_SAVED_CMAP */
-
-/*
- * Standard VGA versions of the register access functions.
- */
-static void
-stdWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
- outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET, value);
-}
-
-static CARD8
-stdReadCrtc(vgaHWPtr hwp, CARD8 index)
-{
- outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
- return inb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET);
-}
-
-static void
-stdWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
- outb(hwp->PIOOffset + VGA_GRAPH_DATA, value);
-}
-
-static CARD8
-stdReadGr(vgaHWPtr hwp, CARD8 index)
-{
- outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
- return inb(hwp->PIOOffset + VGA_GRAPH_DATA);
-}
-
-static void
-stdWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_SEQ_INDEX, index);
- outb(hwp->PIOOffset + VGA_SEQ_DATA, value);
-}
-
-static CARD8
-stdReadSeq(vgaHWPtr hwp, CARD8 index)
-{
- outb(hwp->PIOOffset + VGA_SEQ_INDEX, index);
- return inb(hwp->PIOOffset + VGA_SEQ_DATA);
-}
-
-static CARD8
-stdReadST00(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_IN_STAT_0);
-}
-
-static CARD8
-stdReadST01(vgaHWPtr hwp)
-{
- return inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-}
-
-static CARD8
-stdReadFCR(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_FEATURE_R);
-}
-
-static void
-stdWriteFCR(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->IOBase + hwp->PIOOffset + VGA_FEATURE_W_OFFSET,value);
-}
-
-static void
-stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- if (hwp->paletteEnabled)
- index &= ~0x20;
- else
- index |= 0x20;
-
- (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
- outb(hwp->PIOOffset + VGA_ATTR_INDEX, index);
- outb(hwp->PIOOffset + VGA_ATTR_DATA_W, value);
-}
-
-static CARD8
-stdReadAttr(vgaHWPtr hwp, CARD8 index)
-{
- if (hwp->paletteEnabled)
- index &= ~0x20;
- else
- index |= 0x20;
-
- (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
- outb(hwp->PIOOffset + VGA_ATTR_INDEX, index);
- return inb(hwp->PIOOffset + VGA_ATTR_DATA_R);
-}
-
-static void
-stdWriteMiscOut(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_MISC_OUT_W, value);
-}
-
-static CARD8
-stdReadMiscOut(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_MISC_OUT_R);
-}
-
-static void
-stdEnablePalette(vgaHWPtr hwp)
-{
- (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
- outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x00);
- hwp->paletteEnabled = TRUE;
-}
-
-static void
-stdDisablePalette(vgaHWPtr hwp)
-{
- (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
- outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x20);
- hwp->paletteEnabled = FALSE;
-}
-
-static void
-stdWriteDacMask(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_DAC_MASK, value);
-}
-
-static CARD8
-stdReadDacMask(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_DAC_MASK);
-}
-
-static void
-stdWriteDacReadAddr(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_DAC_READ_ADDR, value);
-}
-
-static void
-stdWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_DAC_WRITE_ADDR, value);
-}
-
-static void
-stdWriteDacData(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_DAC_DATA, value);
-}
-
-static CARD8
-stdReadDacData(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_DAC_DATA);
-}
-
-static CARD8
-stdReadEnable(vgaHWPtr hwp)
-{
- return inb(hwp->PIOOffset + VGA_ENABLE);
-}
-
-static void
-stdWriteEnable(vgaHWPtr hwp, CARD8 value)
-{
- outb(hwp->PIOOffset + VGA_ENABLE, value);
-}
-
-void
-vgaHWSetStdFuncs(vgaHWPtr hwp)
-{
- hwp->writeCrtc = stdWriteCrtc;
- hwp->readCrtc = stdReadCrtc;
- hwp->writeGr = stdWriteGr;
- hwp->readGr = stdReadGr;
- hwp->readST00 = stdReadST00;
- hwp->readST01 = stdReadST01;
- hwp->readFCR = stdReadFCR;
- hwp->writeFCR = stdWriteFCR;
- hwp->writeAttr = stdWriteAttr;
- hwp->readAttr = stdReadAttr;
- hwp->writeSeq = stdWriteSeq;
- hwp->readSeq = stdReadSeq;
- hwp->writeMiscOut = stdWriteMiscOut;
- hwp->readMiscOut = stdReadMiscOut;
- hwp->enablePalette = stdEnablePalette;
- hwp->disablePalette = stdDisablePalette;
- hwp->writeDacMask = stdWriteDacMask;
- hwp->readDacMask = stdReadDacMask;
- hwp->writeDacWriteAddr = stdWriteDacWriteAddr;
- hwp->writeDacReadAddr = stdWriteDacReadAddr;
- hwp->writeDacData = stdWriteDacData;
- hwp->readDacData = stdReadDacData;
- hwp->PIOOffset = 0;
- hwp->readEnable = stdReadEnable;
- hwp->writeEnable = stdWriteEnable;
-}
-
-/*
- * MMIO versions of the register access functions. These require
- * hwp->MemBase to be set in such a way that when the standard VGA port
- * adderss is added the correct memory address results.
- */
-
-#define minb(p) MMIO_IN8(hwp->MMIOBase, (hwp->MMIOOffset + (p)))
-#define moutb(p,v) MMIO_OUT8(hwp->MMIOBase, (hwp->MMIOOffset + (p)),(v))
-
-static void
-mmioWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
- moutb(hwp->IOBase + VGA_CRTC_DATA_OFFSET, value);
-}
-
-static CARD8
-mmioReadCrtc(vgaHWPtr hwp, CARD8 index)
-{
- moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
- return minb(hwp->IOBase + VGA_CRTC_DATA_OFFSET);
-}
-
-static void
-mmioWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- moutb(VGA_GRAPH_INDEX, index);
- moutb(VGA_GRAPH_DATA, value);
-}
-
-static CARD8
-mmioReadGr(vgaHWPtr hwp, CARD8 index)
-{
- moutb(VGA_GRAPH_INDEX, index);
- return minb(VGA_GRAPH_DATA);
-}
-
-static void
-mmioWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- moutb(VGA_SEQ_INDEX, index);
- moutb(VGA_SEQ_DATA, value);
-}
-
-static CARD8
-mmioReadSeq(vgaHWPtr hwp, CARD8 index)
-{
- moutb(VGA_SEQ_INDEX, index);
- return minb(VGA_SEQ_DATA);
-}
-
-static CARD8
-mmioReadST00(vgaHWPtr hwp)
-{
- return minb(VGA_IN_STAT_0);
-}
-
-static CARD8
-mmioReadST01(vgaHWPtr hwp)
-{
- return minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
-}
-
-static CARD8
-mmioReadFCR(vgaHWPtr hwp)
-{
- return minb(VGA_FEATURE_R);
-}
-
-static void
-mmioWriteFCR(vgaHWPtr hwp, CARD8 value)
-{
- moutb(hwp->IOBase + VGA_FEATURE_W_OFFSET,value);
-}
-
-static void
-mmioWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
-{
- if (hwp->paletteEnabled)
- index &= ~0x20;
- else
- index |= 0x20;
-
- (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
- moutb(VGA_ATTR_INDEX, index);
- moutb(VGA_ATTR_DATA_W, value);
-}
-
-static CARD8
-mmioReadAttr(vgaHWPtr hwp, CARD8 index)
-{
- if (hwp->paletteEnabled)
- index &= ~0x20;
- else
- index |= 0x20;
-
- (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
- moutb(VGA_ATTR_INDEX, index);
- return minb(VGA_ATTR_DATA_R);
-}
-
-static void
-mmioWriteMiscOut(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_MISC_OUT_W, value);
-}
-
-static CARD8
-mmioReadMiscOut(vgaHWPtr hwp)
-{
- return minb(VGA_MISC_OUT_R);
-}
-
-static void
-mmioEnablePalette(vgaHWPtr hwp)
-{
- (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
- moutb(VGA_ATTR_INDEX, 0x00);
- hwp->paletteEnabled = TRUE;
-}
-
-static void
-mmioDisablePalette(vgaHWPtr hwp)
-{
- (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET);
- moutb(VGA_ATTR_INDEX, 0x20);
- hwp->paletteEnabled = FALSE;
-}
-
-static void
-mmioWriteDacMask(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_DAC_MASK, value);
-}
-
-static CARD8
-mmioReadDacMask(vgaHWPtr hwp)
-{
- return minb(VGA_DAC_MASK);
-}
-
-static void
-mmioWriteDacReadAddr(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_DAC_READ_ADDR, value);
-}
-
-static void
-mmioWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_DAC_WRITE_ADDR, value);
-}
-
-static void
-mmioWriteDacData(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_DAC_DATA, value);
-}
-
-static CARD8
-mmioReadDacData(vgaHWPtr hwp)
-{
- return minb(VGA_DAC_DATA);
-}
-
-static CARD8
-mmioReadEnable(vgaHWPtr hwp)
-{
- return minb(VGA_ENABLE);
-}
-
-static void
-mmioWriteEnable(vgaHWPtr hwp, CARD8 value)
-{
- moutb(VGA_ENABLE, value);
-}
-
-void
-vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset)
-{
- hwp->writeCrtc = mmioWriteCrtc;
- hwp->readCrtc = mmioReadCrtc;
- hwp->writeGr = mmioWriteGr;
- hwp->readGr = mmioReadGr;
- hwp->readST00 = mmioReadST00;
- hwp->readST01 = mmioReadST01;
- hwp->readFCR = mmioReadFCR;
- hwp->writeFCR = mmioWriteFCR;
- hwp->writeAttr = mmioWriteAttr;
- hwp->readAttr = mmioReadAttr;
- hwp->writeSeq = mmioWriteSeq;
- hwp->readSeq = mmioReadSeq;
- hwp->writeMiscOut = mmioWriteMiscOut;
- hwp->readMiscOut = mmioReadMiscOut;
- hwp->enablePalette = mmioEnablePalette;
- hwp->disablePalette = mmioDisablePalette;
- hwp->writeDacMask = mmioWriteDacMask;
- hwp->readDacMask = mmioReadDacMask;
- hwp->writeDacWriteAddr = mmioWriteDacWriteAddr;
- hwp->writeDacReadAddr = mmioWriteDacReadAddr;
- hwp->writeDacData = mmioWriteDacData;
- hwp->readDacData = mmioReadDacData;
- hwp->MMIOBase = base;
- hwp->MMIOOffset = offset;
- hwp->readEnable = mmioReadEnable;
- hwp->writeEnable = mmioWriteEnable;
-}
-
-/*
- * vgaHWProtect --
- * Protect VGA registers and memory from corruption during loads.
- */
-
-void
-vgaHWProtect(ScrnInfoPtr pScrn, Bool on)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- unsigned char tmp;
-
- if (pScrn->vtSema) {
- if (on) {
- /*
- * Turn off screen and disable sequencer.
- */
- tmp = hwp->readSeq(hwp, 0x01);
-
- vgaHWSeqReset(hwp, TRUE); /* start synchronous reset */
- hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */
-
- hwp->enablePalette(hwp);
- } else {
- /*
- * Reenable sequencer, then turn on screen.
- */
-
- tmp = hwp->readSeq(hwp, 0x01);
-
- hwp->writeSeq(hwp, 0x01, tmp & ~0x20); /* reenable display */
- vgaHWSeqReset(hwp, FALSE); /* clear synchronousreset */
-
- hwp->disablePalette(hwp);
- }
- }
-}
-
-vgaHWProtectProc *vgaHWProtectWeak(void) {
- return vgaHWProtect;
-}
-
-/*
- * vgaHWBlankScreen -- blank the screen.
- */
-
-void
-vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- unsigned char scrn;
-
- scrn = hwp->readSeq(hwp, 0x01);
-
- if (on) {
- scrn &= ~0x20; /* enable screen */
- } else {
- scrn |= 0x20; /* blank screen */
- }
-
- vgaHWSeqReset(hwp, TRUE);
- hwp->writeSeq(hwp, 0x01, scrn); /* change mode */
- vgaHWSeqReset(hwp, FALSE);
-}
-
-vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void) {
- return vgaHWBlankScreen;
-}
-
-/*
- * vgaHWSaveScreen -- blank the screen.
- */
-
-Bool
-vgaHWSaveScreen(ScreenPtr pScreen, int mode)
-{
- ScrnInfoPtr pScrn = NULL;
- Bool on;
-
- if (pScreen != NULL)
- pScrn = xf86Screens[pScreen->myNum];
-
- on = xf86IsUnblank(mode);
-
-#if 0
- if (on)
- SetTimeSinceLastInputEvent();
-#endif
-
- if ((pScrn != NULL) && pScrn->vtSema) {
- vgaHWBlankScreen(pScrn, on);
- }
- return TRUE;
-}
-
-
-/*
- * vgaHWDPMSSet -- Sets VESA Display Power Management Signaling (DPMS) Mode
- *
- * This generic VGA function can only set the Off and On modes. If the
- * Standby and Suspend modes are to be supported, a chip specific replacement
- * for this function must be written.
- */
-
-void
-vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
-{
- unsigned char seq1 = 0, crtc17 = 0;
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- if (!pScrn->vtSema) return;
-
- switch (PowerManagementMode) {
- case DPMSModeOn:
- /* Screen: On; HSync: On, VSync: On */
- seq1 = 0x00;
- crtc17 = 0x80;
- break;
- case DPMSModeStandby:
- /* Screen: Off; HSync: Off, VSync: On -- Not Supported */
- seq1 = 0x20;
- crtc17 = 0x80;
- break;
- case DPMSModeSuspend:
- /* Screen: Off; HSync: On, VSync: Off -- Not Supported */
- seq1 = 0x20;
- crtc17 = 0x80;
- break;
- case DPMSModeOff:
- /* Screen: Off; HSync: Off, VSync: Off */
- seq1 = 0x20;
- crtc17 = 0x00;
- break;
- }
- hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
- seq1 |= hwp->readSeq(hwp, 0x01) & ~0x20;
- hwp->writeSeq(hwp, 0x01, seq1);
- crtc17 |= hwp->readCrtc(hwp, 0x17) & ~0x80;
- usleep(10000);
- hwp->writeCrtc(hwp, 0x17, crtc17);
- hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
-}
-
-
-/*
- * vgaHWSeqReset
- * perform a sequencer reset.
- */
-
-void
-vgaHWSeqReset(vgaHWPtr hwp, Bool start)
-{
- if (start)
- hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */
- else
- hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */
-}
-
-
-void
-vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
-{
-#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int savedIOBase;
- unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4;
- Bool doMap = FALSE;
-
- /* If nothing to do, return now */
- if (!hwp->FontInfo1 && !hwp->FontInfo2 && !hwp->TextInfo)
- return;
-
- if (hwp->Base == NULL) {
- doMap = TRUE;
- if (!vgaHWMapMem(scrninfp)) {
- xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
- "vgaHWRestoreFonts: vgaHWMapMem() failed\n");
- return;
- }
- }
-
- /* save the registers that are needed here */
- miscOut = hwp->readMiscOut(hwp);
- attr10 = hwp->readAttr(hwp, 0x10);
- gr1 = hwp->readGr(hwp, 0x01);
- gr3 = hwp->readGr(hwp, 0x03);
- gr4 = hwp->readGr(hwp, 0x04);
- gr5 = hwp->readGr(hwp, 0x05);
- gr6 = hwp->readGr(hwp, 0x06);
- gr8 = hwp->readGr(hwp, 0x08);
- seq2 = hwp->readSeq(hwp, 0x02);
- seq4 = hwp->readSeq(hwp, 0x04);
-
- /* save hwp->IOBase and temporarily set it for colour mode */
- savedIOBase = hwp->IOBase;
- hwp->IOBase = VGA_IOBASE_COLOR;
-
- /* Force into colour mode */
- hwp->writeMiscOut(hwp, miscOut | 0x01);
-
- vgaHWBlankScreen(scrninfp, FALSE);
-
- /*
- * here we temporarily switch to 16 colour planar mode, to simply
- * copy the font-info and saved text.
- *
- * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
- */
-#if 0
- hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
-#endif
-
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
-
- if (scrninfp->depth == 4) {
- /* GJA */
- hwp->writeGr(hwp, 0x03, 0x00); /* don't rotate, write unmodified */
- hwp->writeGr(hwp, 0x08, 0xFF); /* write all bits in a byte */
- hwp->writeGr(hwp, 0x01, 0x00); /* all planes come from CPU */
- }
-
-#if SAVE_FONT1
- if (hwp->FontInfo1) {
- hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
- hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
- slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT);
- }
-#endif
-
-#if SAVE_FONT2
- if (hwp->FontInfo2) {
- hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
- hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
- slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT);
- }
-#endif
-
-#if SAVE_TEXT
- if (hwp->TextInfo) {
- hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
- hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
- slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT);
- hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
- hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
- slowbcopy_tobus((unsigned char *)hwp->TextInfo + TEXT_AMOUNT,
- hwp->Base, TEXT_AMOUNT);
- }
-#endif
-
- vgaHWBlankScreen(scrninfp, TRUE);
-
- /* restore the registers that were changed */
- hwp->writeMiscOut(hwp, miscOut);
- hwp->writeAttr(hwp, 0x10, attr10);
- hwp->writeGr(hwp, 0x01, gr1);
- hwp->writeGr(hwp, 0x03, gr3);
- hwp->writeGr(hwp, 0x04, gr4);
- hwp->writeGr(hwp, 0x05, gr5);
- hwp->writeGr(hwp, 0x06, gr6);
- hwp->writeGr(hwp, 0x08, gr8);
- hwp->writeSeq(hwp, 0x02, seq2);
- hwp->writeSeq(hwp, 0x04, seq4);
- hwp->IOBase = savedIOBase;
-
- if (doMap)
- vgaHWUnmapMem(scrninfp);
-
-#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
-}
-
-
-void
-vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore)
-{
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int i;
-
- if (restore->MiscOutReg & 0x01)
- hwp->IOBase = VGA_IOBASE_COLOR;
- else
- hwp->IOBase = VGA_IOBASE_MONO;
-
- hwp->writeMiscOut(hwp, restore->MiscOutReg);
-
- for (i = 1; i < restore->numSequencer; i++)
- hwp->writeSeq(hwp, i, restore->Sequencer[i]);
-
- /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */
- hwp->writeCrtc(hwp, 17, restore->CRTC[17] & ~0x80);
-
- for (i = 0; i < restore->numCRTC; i++)
- hwp->writeCrtc(hwp, i, restore->CRTC[i]);
-
- for (i = 0; i < restore->numGraphics; i++)
- hwp->writeGr(hwp, i, restore->Graphics[i]);
-
- hwp->enablePalette(hwp);
- for (i = 0; i < restore->numAttribute; i++)
- hwp->writeAttr(hwp, i, restore->Attribute[i]);
- hwp->disablePalette(hwp);
-}
-
-
-void
-vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore)
-{
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int i;
-
-#if 0
- hwp->enablePalette(hwp);
-#endif
-
- hwp->writeDacMask(hwp, 0xFF);
- hwp->writeDacWriteAddr(hwp, 0x00);
- for (i = 0; i < 768; i++) {
- hwp->writeDacData(hwp, restore->DAC[i]);
- DACDelay(hwp);
- }
-
- hwp->disablePalette(hwp);
-}
-
-
-/*
- * vgaHWRestore --
- * restore the VGA state
- */
-
-void
-vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags)
-{
- if (flags & VGA_SR_MODE)
- vgaHWRestoreMode(scrninfp, restore);
-
- if (flags & VGA_SR_FONTS)
- vgaHWRestoreFonts(scrninfp, restore);
-
- if (flags & VGA_SR_CMAP)
- vgaHWRestoreColormap(scrninfp, restore);
-}
-
-void
-vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
-{
-#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int savedIOBase;
- unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4;
- Bool doMap = FALSE;
-
- if (hwp->Base == NULL) {
- doMap = TRUE;
- if (!vgaHWMapMem(scrninfp)) {
- xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
- "vgaHWSaveFonts: vgaHWMapMem() failed\n");
- return;
- }
- }
-
- /* If in graphics mode, don't save anything */
- attr10 = hwp->readAttr(hwp, 0x10);
- if (attr10 & 0x01)
- return;
-
- /* save the registers that are needed here */
- miscOut = hwp->readMiscOut(hwp);
- gr4 = hwp->readGr(hwp, 0x04);
- gr5 = hwp->readGr(hwp, 0x05);
- gr6 = hwp->readGr(hwp, 0x06);
- seq2 = hwp->readSeq(hwp, 0x02);
- seq4 = hwp->readSeq(hwp, 0x04);
-
- /* save hwp->IOBase and temporarily set it for colour mode */
- savedIOBase = hwp->IOBase;
- hwp->IOBase = VGA_IOBASE_COLOR;
-
- /* Force into colour mode */
- hwp->writeMiscOut(hwp, miscOut | 0x01);
-
- vgaHWBlankScreen(scrninfp, FALSE);
-
- /*
- * get the character sets, and text screen if required
- */
- /*
- * Here we temporarily switch to 16 colour planar mode, to simply
- * copy the font-info
- *
- * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
- */
-#if 0
- hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
-#endif
-
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
-
-#if SAVE_FONT1
- if (hwp->FontInfo1 || (hwp->FontInfo1 = malloc(FONT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
- hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
- slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT);
- }
-#endif /* SAVE_FONT1 */
-#if SAVE_FONT2
- if (hwp->FontInfo2 || (hwp->FontInfo2 = malloc(FONT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
- hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
- slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT);
- }
-#endif /* SAVE_FONT2 */
-#if SAVE_TEXT
- if (hwp->TextInfo || (hwp->TextInfo = malloc(2 * TEXT_AMOUNT))) {
- hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
- hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
- slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT);
- hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
- hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
- slowbcopy_frombus(hwp->Base,
- (unsigned char *)hwp->TextInfo + TEXT_AMOUNT, TEXT_AMOUNT);
- }
-#endif /* SAVE_TEXT */
-
- /* Restore clobbered registers */
- hwp->writeAttr(hwp, 0x10, attr10);
- hwp->writeSeq(hwp, 0x02, seq2);
- hwp->writeSeq(hwp, 0x04, seq4);
- hwp->writeGr(hwp, 0x04, gr4);
- hwp->writeGr(hwp, 0x05, gr5);
- hwp->writeGr(hwp, 0x06, gr6);
- hwp->writeMiscOut(hwp, miscOut);
- hwp->IOBase = savedIOBase;
-
- vgaHWBlankScreen(scrninfp, TRUE);
-
- if (doMap)
- vgaHWUnmapMem(scrninfp);
-
-#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */
-}
-
-void
-vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save)
-{
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- int i;
-
- save->MiscOutReg = hwp->readMiscOut(hwp);
- if (save->MiscOutReg & 0x01)
- hwp->IOBase = VGA_IOBASE_COLOR;
- else
- hwp->IOBase = VGA_IOBASE_MONO;
-
- for (i = 0; i < save->numCRTC; i++) {
- save->CRTC[i] = hwp->readCrtc(hwp, i);
- DebugF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]);
- }
-
- hwp->enablePalette(hwp);
- for (i = 0; i < save->numAttribute; i++) {
- save->Attribute[i] = hwp->readAttr(hwp, i);
- DebugF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]);
- }
- hwp->disablePalette(hwp);
-
- for (i = 0; i < save->numGraphics; i++) {
- save->Graphics[i] = hwp->readGr(hwp, i);
- DebugF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]);
- }
-
- for (i = 1; i < save->numSequencer; i++) {
- save->Sequencer[i] = hwp->readSeq(hwp, i);
- DebugF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]);
- }
-}
-
-
-void
-vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save)
-{
- vgaHWPtr hwp = VGAHWPTR(scrninfp);
- Bool readError = FALSE;
- int i;
-
-#ifdef NEED_SAVED_CMAP
- /*
- * Some ET4000 chips from 1991 have a HW bug that prevents the reading
- * of the color lookup table. Mask rev 9042EAI is known to have this bug.
- *
- * If the colourmap is not readable, we set the saved map to a default
- * map (taken from Ferraro's "Programmer's Guide to the EGA and VGA
- * Cards" 2nd ed).
- */
-
- /* Only save it once */
- if (hwp->cmapSaved)
- return;
-
-#if 0
- hwp->enablePalette(hwp);
-#endif
-
- hwp->writeDacMask(hwp, 0xFF);
-
- /*
- * check if we can read the lookup table
- */
- hwp->writeDacReadAddr(hwp, 0x00);
- for (i = 0; i < 6; i++) {
- save->DAC[i] = hwp->readDacData(hwp);
- switch (i % 3) {
- case 0:
- DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
- break;
- case 1:
- DebugF("0x%02x, ", save->DAC[i]);
- break;
- case 2:
- DebugF("0x%02x\n", save->DAC[i]);
- }
- }
-
- /*
- * Check if we can read the palette -
- * use foreground color to prevent flashing.
- */
- hwp->writeDacWriteAddr(hwp, 0x01);
- for (i = 3; i < 6; i++)
- hwp->writeDacData(hwp, ~save->DAC[i] & DAC_TEST_MASK);
- hwp->writeDacReadAddr(hwp, 0x01);
- for (i = 3; i < 6; i++) {
- if (hwp->readDacData(hwp) != (~save->DAC[i] & DAC_TEST_MASK))
- readError = TRUE;
- }
- hwp->writeDacWriteAddr(hwp, 0x01);
- for (i = 3; i < 6; i++)
- hwp->writeDacData(hwp, save->DAC[i]);
-
- if (readError) {
- /*
- * save the default lookup table
- */
- memmove(save->DAC, defaultDAC, 768);
- xf86DrvMsg(scrninfp->scrnIndex, X_WARNING,
- "Cannot read colourmap from VGA. Will restore with default\n");
- } else {
- /* save the colourmap */
- hwp->writeDacReadAddr(hwp, 0x02);
- for (i = 6; i < 768; i++) {
- save->DAC[i] = hwp->readDacData(hwp);
- DACDelay(hwp);
- switch (i % 3) {
- case 0:
- DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]);
- break;
- case 1:
- DebugF("0x%02x, ", save->DAC[i]);
- break;
- case 2:
- DebugF("0x%02x\n", save->DAC[i]);
- }
- }
- }
-
- hwp->disablePalette(hwp);
- hwp->cmapSaved = TRUE;
-#endif
-}
-
-/*
- * vgaHWSave --
- * save the current VGA state
- */
-
-void
-vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags)
-{
- if (save == NULL)
- return;
-
- if (flags & VGA_SR_CMAP)
- vgaHWSaveColormap(scrninfp, save);
-
- if (flags & VGA_SR_MODE)
- vgaHWSaveMode(scrninfp, save);
-
- if (flags & VGA_SR_FONTS)
- vgaHWSaveFonts(scrninfp, save);
-}
-
-
-/*
- * vgaHWInit --
- * Handle the initialization, etc. of a screen.
- * Return FALSE on failure.
- */
-
-Bool
-vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
-{
- unsigned int i;
- vgaHWPtr hwp;
- vgaRegPtr regp;
- int depth = scrninfp->depth;
-
- /*
- * make sure the vgaHWRec is allocated
- */
- if (!vgaHWGetHWRec(scrninfp))
- return FALSE;
- hwp = VGAHWPTR(scrninfp);
- regp = &hwp->ModeReg;
-
- /*
- * compute correct Hsync & Vsync polarity
- */
- if ((mode->Flags & (V_PHSYNC | V_NHSYNC))
- && (mode->Flags & (V_PVSYNC | V_NVSYNC)))
- {
- regp->MiscOutReg = 0x23;
- if (mode->Flags & V_NHSYNC) regp->MiscOutReg |= 0x40;
- if (mode->Flags & V_NVSYNC) regp->MiscOutReg |= 0x80;
- }
- else
- {
- int VDisplay = mode->VDisplay;
- if (mode->Flags & V_DBLSCAN)
- VDisplay *= 2;
- if (mode->VScan > 1)
- VDisplay *= mode->VScan;
- if (VDisplay < 400)
- regp->MiscOutReg = 0xA3; /* +hsync -vsync */
- else if (VDisplay < 480)
- regp->MiscOutReg = 0x63; /* -hsync +vsync */
- else if (VDisplay < 768)
- regp->MiscOutReg = 0xE3; /* -hsync -vsync */
- else
- regp->MiscOutReg = 0x23; /* +hsync +vsync */
- }
-
- regp->MiscOutReg |= (mode->ClockIndex & 0x03) << 2;
-
- /*
- * Time Sequencer
- */
- if (depth == 4)
- regp->Sequencer[0] = 0x02;
- else
- regp->Sequencer[0] = 0x00;
- if (mode->Flags & V_CLKDIV2)
- regp->Sequencer[1] = 0x09;
- else
- regp->Sequencer[1] = 0x01;
- if (depth == 1)
- regp->Sequencer[2] = 1 << BIT_PLANE;
- else
- regp->Sequencer[2] = 0x0F;
- regp->Sequencer[3] = 0x00; /* Font select */
- if (depth < 8)
- regp->Sequencer[4] = 0x06; /* Misc */
- else
- regp->Sequencer[4] = 0x0E; /* Misc */
-
- /*
- * CRTC Controller
- */
- regp->CRTC[0] = (mode->CrtcHTotal >> 3) - 5;
- regp->CRTC[1] = (mode->CrtcHDisplay >> 3) - 1;
- regp->CRTC[2] = (mode->CrtcHBlankStart >> 3) - 1;
- regp->CRTC[3] = (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F) | 0x80;
- i = (((mode->CrtcHSkew << 2) + 0x10) & ~0x1F);
- if (i < 0x80)
- regp->CRTC[3] |= i;
- regp->CRTC[4] = (mode->CrtcHSyncStart >> 3);
- regp->CRTC[5] = ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2)
- | (((mode->CrtcHSyncEnd >> 3)) & 0x1F);
- regp->CRTC[6] = (mode->CrtcVTotal - 2) & 0xFF;
- regp->CRTC[7] = (((mode->CrtcVTotal - 2) & 0x100) >> 8)
- | (((mode->CrtcVDisplay - 1) & 0x100) >> 7)
- | ((mode->CrtcVSyncStart & 0x100) >> 6)
- | (((mode->CrtcVBlankStart - 1) & 0x100) >> 5)
- | 0x10
- | (((mode->CrtcVTotal - 2) & 0x200) >> 4)
- | (((mode->CrtcVDisplay - 1) & 0x200) >> 3)
- | ((mode->CrtcVSyncStart & 0x200) >> 2);
- regp->CRTC[8] = 0x00;
- regp->CRTC[9] = (((mode->CrtcVBlankStart - 1) & 0x200) >> 4) | 0x40;
- if (mode->Flags & V_DBLSCAN)
- regp->CRTC[9] |= 0x80;
- if (mode->VScan >= 32)
- regp->CRTC[9] |= 0x1F;
- else if (mode->VScan > 1)
- regp->CRTC[9] |= mode->VScan - 1;
- regp->CRTC[10] = 0x00;
- regp->CRTC[11] = 0x00;
- regp->CRTC[12] = 0x00;
- regp->CRTC[13] = 0x00;
- regp->CRTC[14] = 0x00;
- regp->CRTC[15] = 0x00;
- regp->CRTC[16] = mode->CrtcVSyncStart & 0xFF;
- regp->CRTC[17] = (mode->CrtcVSyncEnd & 0x0F) | 0x20;
- regp->CRTC[18] = (mode->CrtcVDisplay - 1) & 0xFF;
- regp->CRTC[19] = scrninfp->displayWidth >> 4; /* just a guess */
- regp->CRTC[20] = 0x00;
- regp->CRTC[21] = (mode->CrtcVBlankStart - 1) & 0xFF;
- regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF;
- if (depth < 8)
- regp->CRTC[23] = 0xE3;
- else
- regp->CRTC[23] = 0xC3;
- regp->CRTC[24] = 0xFF;
-
- vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
- vgaHWVBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
-
- /*
- * Theory resumes here....
- */
-
- /*
- * Graphics Display Controller
- */
- regp->Graphics[0] = 0x00;
- regp->Graphics[1] = 0x00;
- regp->Graphics[2] = 0x00;
- regp->Graphics[3] = 0x00;
- if (depth == 1) {
- regp->Graphics[4] = BIT_PLANE;
- regp->Graphics[5] = 0x00;
- } else {
- regp->Graphics[4] = 0x00;
- if (depth == 4)
- regp->Graphics[5] = 0x02;
- else
- regp->Graphics[5] = 0x40;
- }
- regp->Graphics[6] = 0x05; /* only map 64k VGA memory !!!! */
- regp->Graphics[7] = 0x0F;
- regp->Graphics[8] = 0xFF;
-
- if (depth == 1) {
- /* Initialise the Mono map according to which bit-plane gets used */
-
- Bool flipPixels = xf86GetFlipPixels();
-
- for (i=0; i<16; i++)
- if (((i & (1 << BIT_PLANE)) != 0) != flipPixels)
- regp->Attribute[i] = WHITE_VALUE;
- else
- regp->Attribute[i] = BLACK_VALUE;
-
- regp->Attribute[16] = 0x01; /* -VGA2- */ /* wrong for the ET4000 */
- if (!hwp->ShowOverscan)
- regp->Attribute[OVERSCAN] = OVERSCAN_VALUE; /* -VGA2- */
- } else {
- regp->Attribute[0] = 0x00; /* standard colormap translation */
- regp->Attribute[1] = 0x01;
- regp->Attribute[2] = 0x02;
- regp->Attribute[3] = 0x03;
- regp->Attribute[4] = 0x04;
- regp->Attribute[5] = 0x05;
- regp->Attribute[6] = 0x06;
- regp->Attribute[7] = 0x07;
- regp->Attribute[8] = 0x08;
- regp->Attribute[9] = 0x09;
- regp->Attribute[10] = 0x0A;
- regp->Attribute[11] = 0x0B;
- regp->Attribute[12] = 0x0C;
- regp->Attribute[13] = 0x0D;
- regp->Attribute[14] = 0x0E;
- regp->Attribute[15] = 0x0F;
- if (depth == 4)
- regp->Attribute[16] = 0x81; /* wrong for the ET4000 */
- else
- regp->Attribute[16] = 0x41; /* wrong for the ET4000 */
- /* Attribute[17] (overscan) initialised in vgaHWGetHWRec() */
- }
- regp->Attribute[18] = 0x0F;
- regp->Attribute[19] = 0x00;
- regp->Attribute[20] = 0x00;
-
- return TRUE;
-}
-
- /*
- * OK, so much for theory. Now, let's deal with the >real< world...
- *
- * The above CRTC settings are precise in theory, except that many, if not
- * most, VGA clones fail to reset the blanking signal when the character or
- * line counter reaches [HV]Total. In this case, the signal is only
- * unblanked when the counter reaches [HV]BlankEnd (mod 64, 128 or 256 as
- * the case may be) at the start of the >next< scanline or frame, which
- * means only part of the screen shows. This affects how null overscans
- * are to be implemented on such adapters.
- *
- * Henceforth, VGA cores that implement this broken, but unfortunately
- * common, behaviour are to be designated as KGA's, in honour of Koen
- * Gadeyne, whose zeal to eliminate overscans (read: fury) set in motion
- * a series of events that led to the discovery of this problem.
- *
- * Some VGA's are KGA's only in the horizontal, or only in the vertical,
- * some in both, others in neither. Don't let anyone tell you there is
- * such a thing as a VGA "standard"... And, thank the Creator for the fact
- * that Hilbert spaces are not yet implemented in this industry.
- *
- * The following implements a trick suggested by David Dawes. This sets
- * [HV]BlankEnd to zero if the blanking interval does not already contain a
- * 0-point, and decrements it by one otherwise. In the latter case, this
- * will produce a left and/or top overscan which the colourmap code will
- * (still) need to ensure is as close to black as possible. This will make
- * the behaviour consistent across all chipsets, while allowing all
- * chipsets to display the entire screen. Non-KGA drivers can ignore the
- * following in their own copy of this code.
- *
- * -- TSI @ UQV, 1998.08.21
- */
-
-CARD32
-vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags)
-{
- int nExtBits = (nBits < 6) ? 0 : nBits - 6;
- CARD32 ExtBits;
- CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 6;
-
- regp->CRTC[3] = (regp->CRTC[3] & ~0x1F)
- | (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F);
- regp->CRTC[5] = (regp->CRTC[5] & ~0x80)
- | ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2);
- ExtBits = ((mode->CrtcHBlankEnd >> 3) - 1) & ExtBitMask;
-
- /* First the horizontal case */
- if ((Flags & KGA_FIX_OVERSCAN)
- && ((mode->CrtcHBlankEnd >> 3) == (mode->CrtcHTotal >> 3)))
- {
- int i = (regp->CRTC[3] & 0x1F)
- | ((regp->CRTC[5] & 0x80) >> 2)
- | ExtBits;
- if (Flags & KGA_ENABLE_ON_ZERO) {
- if ((i-- > (((mode->CrtcHBlankStart >> 3) - 1)
- & (0x3F | ExtBitMask)))
- && (mode->CrtcHBlankEnd == mode->CrtcHTotal))
- i = 0;
- } else if (Flags & KGA_BE_TOT_DEC)
- i--;
- regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) | (i & 0x1F);
- regp->CRTC[5] = (regp->CRTC[5] & ~0x80) | ((i << 2) & 0x80);
- ExtBits = i & ExtBitMask;
- }
- return ExtBits >> 6;
-}
-
- /*
- * The vertical case is a little trickier. Some VGA's ignore bit 0x80 of
- * CRTC[22]. Also, in some cases, a zero CRTC[22] will still blank the
- * very first scanline in a double- or multi-scanned mode. This last case
- * needs further investigation.
- */
-CARD32
-vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags)
-{
- CARD32 ExtBits;
- CARD32 nExtBits = (nBits < 8) ? 0 : (nBits - 8);
- CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 8;
- /* If width is not known nBits should be 0. In this
- * case BitMask is set to 0 so we can check for it. */
- CARD32 BitMask = (nBits < 7) ? 0 : ((1 << nExtBits) - 1);
- int VBlankStart = (mode->CrtcVBlankStart - 1) & 0xFF;
- regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF;
- ExtBits = (mode->CrtcVBlankEnd - 1) & ExtBitMask;
-
- if ((Flags & KGA_FIX_OVERSCAN)
- && (mode->CrtcVBlankEnd == mode->CrtcVTotal))
- /* Null top overscan */
- {
- int i = regp->CRTC[22] | ExtBits;
- if (Flags & KGA_ENABLE_ON_ZERO) {
- if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask)))
- || ((i > VBlankStart) && /* 8-bit case */
- ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */
- !(regp->CRTC[9] & 0x9F)) /* 1 scanline/row */
- i = 0;
- else
- i = (i - 1);
- } else if (Flags & KGA_BE_TOT_DEC)
- i = (i - 1);
-
- regp->CRTC[22] = i & 0xFF;
- ExtBits = i & 0xFF00;
- }
- return ExtBits >> 8;
-}
-
-/*
- * these are some more hardware specific helpers, formerly in vga.c
- */
-static void
-vgaHWGetHWRecPrivate(void)
-{
- if (vgaHWPrivateIndex < 0)
- vgaHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
- return;
-}
-
-
-static void
-vgaHWFreeRegs(vgaRegPtr regp)
-{
- free(regp->CRTC);
-
- regp->CRTC =
- regp->Sequencer =
- regp->Graphics =
- regp->Attribute = NULL;
-
- regp->numCRTC =
- regp->numSequencer =
- regp->numGraphics =
- regp->numAttribute = 0;
-}
-
-
-
-static Bool
-vgaHWAllocRegs(vgaRegPtr regp)
-{
- unsigned char *buf;
-
- if ((regp->numCRTC + regp->numSequencer + regp->numGraphics +
- regp->numAttribute) == 0)
- return FALSE;
-
- buf = calloc(regp->numCRTC +
- regp->numSequencer +
- regp->numGraphics +
- regp->numAttribute, 1);
- if (!buf)
- return FALSE;
-
- regp->CRTC = buf;
- regp->Sequencer = regp->CRTC + regp->numCRTC;
- regp->Graphics = regp->Sequencer + regp->numSequencer;
- regp->Attribute = regp->Graphics + regp->numGraphics;
-
- return TRUE;
-}
-
-
-Bool
-vgaHWAllocDefaultRegs(vgaRegPtr regp)
-{
- regp->numCRTC = VGA_NUM_CRTC;
- regp->numSequencer = VGA_NUM_SEQ;
- regp->numGraphics = VGA_NUM_GFX;
- regp->numAttribute = VGA_NUM_ATTR;
-
- return vgaHWAllocRegs(regp);
-}
-
-
-Bool
-vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
- int numGraphics, int numAttribute)
-{
-#define VGAHWMINNUM(regtype) \
- ((newMode.num##regtype < regp->num##regtype) ? \
- (newMode.num##regtype) : (regp->num##regtype))
-#define VGAHWCOPYREGSET(regtype) \
- memcpy (newMode.regtype, regp->regtype, VGAHWMINNUM(regtype))
-
- vgaRegRec newMode, newSaved;
- vgaRegPtr regp;
-
- regp = &VGAHWPTR(scrp)->ModeReg;
- memcpy (&newMode, regp, sizeof(vgaRegRec));
-
- /* allocate space for new registers */
-
- regp = &newMode;
- regp->numCRTC = numCRTC;
- regp->numSequencer = numSequencer;
- regp->numGraphics = numGraphics;
- regp->numAttribute = numAttribute;
- if (!vgaHWAllocRegs(regp))
- return FALSE;
-
- regp = &VGAHWPTR(scrp)->SavedReg;
- memcpy (&newSaved, regp, sizeof(vgaRegRec));
-
- regp = &newSaved;
- regp->numCRTC = numCRTC;
- regp->numSequencer = numSequencer;
- regp->numGraphics = numGraphics;
- regp->numAttribute = numAttribute;
- if (!vgaHWAllocRegs(regp)) {
- vgaHWFreeRegs(&newMode);
- return FALSE;
- }
-
- /* allocations succeeded, copy register data into new space */
-
- regp = &VGAHWPTR(scrp)->ModeReg;
- VGAHWCOPYREGSET(CRTC);
- VGAHWCOPYREGSET(Sequencer);
- VGAHWCOPYREGSET(Graphics);
- VGAHWCOPYREGSET(Attribute);
-
- regp = &VGAHWPTR(scrp)->SavedReg;
- VGAHWCOPYREGSET(CRTC);
- VGAHWCOPYREGSET(Sequencer);
- VGAHWCOPYREGSET(Graphics);
- VGAHWCOPYREGSET(Attribute);
-
- /* free old register arrays */
-
- regp = &VGAHWPTR(scrp)->ModeReg;
- vgaHWFreeRegs(regp);
- memcpy(regp, &newMode, sizeof(vgaRegRec));
-
- regp = &VGAHWPTR(scrp)->SavedReg;
- vgaHWFreeRegs(regp);
- memcpy(regp, &newSaved, sizeof(vgaRegRec));
-
- return TRUE;
-
-#undef VGAHWMINNUM
-#undef VGAHWCOPYREGSET
-}
-
-
-Bool
-vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src)
-{
- vgaHWFreeRegs(dst);
-
- memcpy(dst, src, sizeof(vgaRegRec));
-
- if (!vgaHWAllocRegs(dst))
- return FALSE;
-
- memcpy(dst->CRTC, src->CRTC, src->numCRTC);
- memcpy(dst->Sequencer, src->Sequencer, src->numSequencer);
- memcpy(dst->Graphics, src->Graphics, src->numGraphics);
- memcpy(dst->Attribute, src->Attribute, src->numAttribute);
-
- return TRUE;
-}
-
-
-Bool
-vgaHWGetHWRec(ScrnInfoPtr scrp)
-{
- vgaRegPtr regp;
- vgaHWPtr hwp;
- int i;
-
- /*
- * Let's make sure that the private exists and allocate one.
- */
- vgaHWGetHWRecPrivate();
- /*
- * New privates are always set to NULL, so we can check if the allocation
- * has already been done.
- */
- if (VGAHWPTR(scrp))
- return TRUE;
- hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(sizeof(vgaHWRec), 1);
- regp = &VGAHWPTR(scrp)->ModeReg;
-
- if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) ||
- (!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->ModeReg))) {
- free(hwp);
- return FALSE;
- }
-
- if (scrp->bitsPerPixel == 1) {
- rgb blackColour = scrp->display->blackColour,
- whiteColour = scrp->display->whiteColour;
-
- if (blackColour.red > 0x3F) blackColour.red = 0x3F;
- if (blackColour.green > 0x3F) blackColour.green = 0x3F;
- if (blackColour.blue > 0x3F) blackColour.blue = 0x3F;
-
- if (whiteColour.red > 0x3F) whiteColour.red = 0x3F;
- if (whiteColour.green > 0x3F) whiteColour.green = 0x3F;
- if (whiteColour.blue > 0x3F) whiteColour.blue = 0x3F;
-
- if ((blackColour.red == whiteColour.red ) &&
- (blackColour.green == whiteColour.green) &&
- (blackColour.blue == whiteColour.blue )) {
- blackColour.red ^= 0x3F;
- blackColour.green ^= 0x3F;
- blackColour.blue ^= 0x3F;
- }
-
- /*
- * initialize default colormap for monochrome
- */
- for (i=0; i<3; i++) regp->DAC[i] = 0x00;
- for (i=3; i<768; i++) regp->DAC[i] = 0x3F;
- i = BLACK_VALUE * 3;
- regp->DAC[i++] = blackColour.red;
- regp->DAC[i++] = blackColour.green;
- regp->DAC[i] = blackColour.blue;
- i = WHITE_VALUE * 3;
- regp->DAC[i++] = whiteColour.red;
- regp->DAC[i++] = whiteColour.green;
- regp->DAC[i] = whiteColour.blue;
- i = OVERSCAN_VALUE * 3;
- regp->DAC[i++] = 0x00;
- regp->DAC[i++] = 0x00;
- regp->DAC[i] = 0x00;
- } else {
- /* Set all colours to black */
- for (i=0; i<768; i++) regp->DAC[i] = 0x00;
- /* ... and the overscan */
- if (scrp->depth >= 4)
- regp->Attribute[OVERSCAN] = 0xFF;
- }
- if (xf86FindOption(scrp->confScreen->options, "ShowOverscan")) {
- xf86MarkOptionUsedByName(scrp->confScreen->options, "ShowOverscan");
- xf86DrvMsg(scrp->scrnIndex, X_CONFIG, "Showing overscan area\n");
- regp->DAC[765] = 0x3F;
- regp->DAC[766] = 0x00;
- regp->DAC[767] = 0x3F;
- regp->Attribute[OVERSCAN] = 0xFF;
- hwp->ShowOverscan = TRUE;
- } else
- hwp->ShowOverscan = FALSE;
-
- hwp->paletteEnabled = FALSE;
- hwp->cmapSaved = FALSE;
- hwp->MapSize = 0;
- hwp->pScrn = scrp;
-
- /* Initialise the function pointers with the standard VGA versions */
- vgaHWSetStdFuncs(hwp);
-
- hwp->PIOOffset = scrp->domainIOBase;
- hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]);
-
- return TRUE;
-}
-
-
-void
-vgaHWFreeHWRec(ScrnInfoPtr scrp)
-{
- if (vgaHWPrivateIndex >= 0) {
- vgaHWPtr hwp = VGAHWPTR(scrp);
-
- if (!hwp)
- return;
-
- free(hwp->FontInfo1);
- free(hwp->FontInfo2);
- free(hwp->TextInfo);
-
- vgaHWFreeRegs (&hwp->ModeReg);
- vgaHWFreeRegs (&hwp->SavedReg);
-
- free(hwp);
- VGAHWPTRLVAL(scrp) = NULL;
- }
-}
-
-
-Bool
-vgaHWMapMem(ScrnInfoPtr scrp)
-{
- vgaHWPtr hwp = VGAHWPTR(scrp);
- int scr_index = scrp->scrnIndex;
-
- if (hwp->Base)
- return TRUE;
-
- /* If not set, initialise with the defaults */
- if (hwp->MapSize == 0)
- hwp->MapSize = VGA_DEFAULT_MEM_SIZE;
- if (hwp->MapPhys == 0)
- hwp->MapPhys = VGA_DEFAULT_PHYS_ADDR;
-
- /*
- * Map as VIDMEM_MMIO_32BIT because WC
- * is bad when there is page flipping.
- * XXX This is not correct but we do it
- * for now.
- */
- DebugF("Mapping VGAMem\n");
- hwp->Base = xf86MapDomainMemory(scr_index, VIDMEM_MMIO_32BIT, hwp->dev,
- hwp->MapPhys, hwp->MapSize);
- return hwp->Base != NULL;
-}
-
-
-void
-vgaHWUnmapMem(ScrnInfoPtr scrp)
-{
- vgaHWPtr hwp = VGAHWPTR(scrp);
- int scr_index = scrp->scrnIndex;
-
- if (hwp->Base == NULL)
- return;
-
- DebugF("Unmapping VGAMem\n");
- xf86UnMapVidMem(scr_index, hwp->Base, hwp->MapSize);
- hwp->Base = NULL;
-}
-
-int
-vgaHWGetIndex(void)
-{
- return vgaHWPrivateIndex;
-}
-
-
-void
-vgaHWGetIOBase(vgaHWPtr hwp)
-{
- hwp->IOBase = (hwp->readMiscOut(hwp) & 0x01) ?
- VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
- xf86DrvMsgVerb(hwp->pScrn->scrnIndex, X_INFO, 3,
- "vgaHWGetIOBase: hwp->IOBase is 0x%04x, hwp->PIOOffset is 0x%04lx\n",
- hwp->IOBase, hwp->PIOOffset);
-}
-
-
-void
-vgaHWLock(vgaHWPtr hwp)
-{
- /* Protect CRTC[0-7] */
- hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) | 0x80);
-}
-
-void
-vgaHWUnlock(vgaHWPtr hwp)
-{
- /* Unprotect CRTC[0-7] */
- hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) & ~0x80);
-}
-
-
-void
-vgaHWEnable(vgaHWPtr hwp)
-{
- hwp->writeEnable(hwp, hwp->readEnable(hwp) | 0x01);
-}
-
-
-void
-vgaHWDisable(vgaHWPtr hwp)
-{
- hwp->writeEnable(hwp, hwp->readEnable(hwp) & ~0x01);
-}
-
-
-static void
-vgaHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
- VisualPtr pVisual)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- int i, index;
-
- for (i = 0; i < numColors; i++) {
- index = indices[i];
- hwp->writeDacWriteAddr(hwp, index);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].red);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].green);
- DACDelay(hwp);
- hwp->writeDacData(hwp, colors[index].blue);
- DACDelay(hwp);
- }
-
- /* This shouldn't be necessary, but we'll play safe. */
- hwp->disablePalette(hwp);
-}
-
-
-static void
-vgaHWSetOverscan(ScrnInfoPtr pScrn, int overscan)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
-
- if (overscan < 0 || overscan > 255)
- return;
-
- hwp->enablePalette(hwp);
- hwp->writeAttr(hwp, OVERSCAN, overscan);
-
-#ifdef DEBUGOVERSCAN
- {
- int ov = hwp->readAttr(hwp, OVERSCAN);
- int red, green, blue;
-
- hwp->writeDacReadAddr(hwp, ov);
- red = hwp->readDacData(hwp);
- green = hwp->readDacData(hwp);
- blue = hwp->readDacData(hwp);
- ErrorF("Overscan index is 0x%02x, colours are #%02x%02x%02x\n",
- ov, red, green, blue);
- }
-#endif
-
- hwp->disablePalette(hwp);
-}
-
-
-Bool
-vgaHWHandleColormaps(ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- if (pScrn->depth > 1 && pScrn->depth <= 8) {
- return xf86HandleColormaps(pScreen, 1 << pScrn->depth,
- pScrn->rgbBits, vgaHWLoadPalette,
- pScrn->depth > 4 ? vgaHWSetOverscan : NULL,
- CMAP_RELOAD_ON_MODE_SWITCH);
- }
- return TRUE;
-}
-
-/* ----------------------- DDC support ------------------------*/
-/*
- * Adjust v_active, v_blank, v_sync, v_sync_end, v_blank_end, v_total
- * to read out EDID at a faster rate. Allowed maximum is 25kHz with
- * 20 usec v_sync active. Set positive v_sync polarity, turn off lightpen
- * readback, enable access to cr00-cr07.
- */
-
-/* vertical timings */
-#define DISPLAY_END 0x04
-#define BLANK_START DISPLAY_END
-#define SYNC_START BLANK_START
-#define SYNC_END 0x09
-#define BLANK_END SYNC_END
-#define V_TOTAL BLANK_END
-/* this function doesn't have to be reentrant for our purposes */
-struct _vgaDdcSave {
- unsigned char cr03;
- unsigned char cr06;
- unsigned char cr07;
- unsigned char cr09;
- unsigned char cr10;
- unsigned char cr11;
- unsigned char cr12;
- unsigned char cr15;
- unsigned char cr16;
- unsigned char msr;
-};
-
-void
-vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- unsigned char tmp;
- struct _vgaDdcSave* save;
- switch (speed) {
- case DDC_FAST:
-
- if (hwp->ddc != NULL) break;
- hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave),1);
- save = (struct _vgaDdcSave *)hwp->ddc;
- /* Lightpen register disable - allow access to cr10 & 11; just in case */
- save->cr03 = hwp->readCrtc(hwp, 0x03);
- hwp->writeCrtc(hwp,0x03,(save->cr03 |0x80));
- save->cr12 = hwp->readCrtc(hwp, 0x12);
- hwp->writeCrtc(hwp,0x12,DISPLAY_END);
- save->cr15 = hwp->readCrtc(hwp, 0x15);
- hwp->writeCrtc(hwp,0x15,BLANK_START);
- save->cr10 = hwp->readCrtc(hwp, 0x10);
- hwp->writeCrtc(hwp,0x10,SYNC_START);
- save->cr11 = hwp->readCrtc(hwp, 0x11);
- /* unprotect group 1 registers; just in case ...*/
- hwp->writeCrtc(hwp,0x11,((save->cr11 & 0x70) | SYNC_END));
- save->cr16 = hwp->readCrtc(hwp, 0x16);
- hwp->writeCrtc(hwp,0x16,BLANK_END);
- save->cr06 = hwp->readCrtc(hwp, 0x06);
- hwp->writeCrtc(hwp,0x06,V_TOTAL);
- /* all values have less than 8 bit - mask out 9th and 10th bits */
- save->cr09 = hwp->readCrtc(hwp, 0x09);
- hwp->writeCrtc(hwp,0x09,(save->cr09 &0xDF));
- save->cr07 = hwp->readCrtc(hwp, 0x07);
- hwp->writeCrtc(hwp,0x07,(save->cr07 &0x10));
- /* vsync polarity negativ & ensure a 25MHz clock */
- save->msr = hwp->readMiscOut(hwp);
- hwp->writeMiscOut(hwp,((save->msr & 0xF3) | 0x80));
- break;
- case DDC_SLOW:
- if (hwp->ddc == NULL) break;
- save = (struct _vgaDdcSave *)hwp->ddc;
- hwp->writeMiscOut(hwp,save->msr);
- hwp->writeCrtc(hwp,0x07,save->cr07);
- tmp = hwp->readCrtc(hwp, 0x09);
- hwp->writeCrtc(hwp,0x09,((save->cr09 & 0x20) | (tmp & 0xDF)));
- hwp->writeCrtc(hwp,0x06,save->cr06);
- hwp->writeCrtc(hwp,0x16,save->cr16);
- hwp->writeCrtc(hwp,0x11,save->cr11);
- hwp->writeCrtc(hwp,0x10,save->cr10);
- hwp->writeCrtc(hwp,0x15,save->cr15);
- hwp->writeCrtc(hwp,0x12,save->cr12);
- hwp->writeCrtc(hwp,0x03,save->cr03);
- free(save);
- hwp->ddc = NULL;
- break;
- default:
- break;
- }
-}
-
-DDC1SetSpeedProc
-vgaHWddc1SetSpeedWeak(void)
-{
- return vgaHWddc1SetSpeed;
-}
-
-SaveScreenProcPtr vgaHWSaveScreenWeak(void)
-{
- return vgaHWSaveScreen;
-}
+ +/* + * + * Copyright 1991-1999 by The XFree86 Project, Inc. + * + * Loosely based on code bearing the following copyright: + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + */ + +#define _NEED_SYSI86 + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <X11/X.h> +#include "misc.h" + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "vgaHW.h" + +#include "compiler.h" + +#include "xf86cmap.h" + +#include "Pci.h" + +#ifndef SAVE_FONT1 +#define SAVE_FONT1 1 +#endif + +/* + * These used to be OS-specific, which made this module have an undesirable + * OS dependency. Define them by default for all platforms. + */ +#ifndef NEED_SAVED_CMAP +#define NEED_SAVED_CMAP +#endif +#ifndef SAVE_TEXT +#define SAVE_TEXT 1 +#endif +#ifndef SAVE_FONT2 +#define SAVE_FONT2 1 +#endif + +/* bytes per plane to save for text */ +#define TEXT_AMOUNT 16384 + +/* bytes per plane to save for font data */ +#define FONT_AMOUNT (8*8192) + +#if 0 +/* Override all of these for now */ +#undef SAVE_FONT1 +#define SAVE_FONT1 1 +#undef SAVE_FONT2 +#define SAVE_FONT2 1 +#undef SAVE_TEST +#define SAVE_TEST 1 +#undef FONT_AMOUNT +#define FONT_AMOUNT 65536 +#undef TEXT_AMOUNT +#define TEXT_AMOUNT 65536 +#endif + +/* DAC indices for white and black */ +#define WHITE_VALUE 0x3F +#define BLACK_VALUE 0x00 +#define OVERSCAN_VALUE 0x01 + + +/* Use a private definition of this here */ +#undef VGAHWPTR +#define VGAHWPTRLVAL(p) (p)->privates[vgaHWPrivateIndex].ptr +#define VGAHWPTR(p) ((vgaHWPtr)(VGAHWPTRLVAL(p))) + +static int vgaHWPrivateIndex = -1; + +#define DAC_TEST_MASK 0x3F + +#ifdef NEED_SAVED_CMAP +/* This default colourmap is used only when it can't be read from the VGA */ + +static CARD8 defaultDAC[768] = +{ + 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42, + 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42, + 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63, + 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63, + 0, 0, 0, 5, 5, 5, 8, 8, 8, 11, 11, 11, + 14, 14, 14, 17, 17, 17, 20, 20, 20, 24, 24, 24, + 28, 28, 28, 32, 32, 32, 36, 36, 36, 40, 40, 40, + 45, 45, 45, 50, 50, 50, 56, 56, 56, 63, 63, 63, + 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, 63, + 63, 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, + 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, + 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, 0, + 0, 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, + 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, + 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, 63, + 63, 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, + 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, + 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, 31, + 31, 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, + 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, + 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, 63, + 63, 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, + 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, + 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, 45, + 45, 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, + 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, + 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, 28, + 28, 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, + 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, + 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, 0, + 0, 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, + 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, + 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, 28, + 28, 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, + 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, + 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, 14, + 14, 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, + 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, + 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, 28, + 28, 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, + 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, + 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, 20, + 20, 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, + 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, + 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, 16, + 16, 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, + 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, + 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, 0, + 0, 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, + 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, + 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, 16, + 16, 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, + 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, + 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, 8, + 8, 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, + 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, + 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, 16, + 16, 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, + 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, + 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, 11, + 11, 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, + 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +#endif /* NEED_SAVED_CMAP */ + +/* + * Standard VGA versions of the register access functions. + */ +static void +stdWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index); + pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_DATA_OFFSET, value); +} + +static CARD8 +stdReadCrtc(vgaHWPtr hwp, CARD8 index) +{ + pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index); + return pci_io_read8(hwp->io, hwp->IOBase + VGA_CRTC_DATA_OFFSET); +} + +static void +stdWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + pci_io_write8(hwp->io, VGA_GRAPH_INDEX, index); + pci_io_write8(hwp->io, VGA_GRAPH_DATA, value); +} + +static CARD8 +stdReadGr(vgaHWPtr hwp, CARD8 index) +{ + pci_io_write8(hwp->io, VGA_GRAPH_INDEX, index); + return pci_io_read8(hwp->io, VGA_GRAPH_DATA); +} + +static void +stdWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + pci_io_write8(hwp->io, VGA_SEQ_INDEX, index); + pci_io_write8(hwp->io, VGA_SEQ_DATA, value); +} + +static CARD8 +stdReadSeq(vgaHWPtr hwp, CARD8 index) +{ + pci_io_write8(hwp->io, VGA_SEQ_INDEX, index); + return pci_io_read8(hwp->io, VGA_SEQ_DATA); +} + +static CARD8 +stdReadST00(vgaHWPtr hwp) +{ + return pci_io_read8(hwp->io, VGA_IN_STAT_0); +} + +static CARD8 +stdReadST01(vgaHWPtr hwp) +{ + return pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); +} + +static CARD8 +stdReadFCR(vgaHWPtr hwp) +{ + return pci_io_read8(hwp->io, VGA_FEATURE_R); +} + +static void +stdWriteFCR(vgaHWPtr hwp, CARD8 value) +{ + pci_io_write8(hwp->io, hwp->IOBase + VGA_FEATURE_W_OFFSET,value); +} + +static void +stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + if (hwp->paletteEnabled) + index &= ~0x20; + else + index |= 0x20; + + (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); + pci_io_write8(hwp->io, VGA_ATTR_INDEX, index); + pci_io_write8(hwp->io, VGA_ATTR_DATA_W, value); +} + +static CARD8 +stdReadAttr(vgaHWPtr hwp, CARD8 index) +{ + if (hwp->paletteEnabled) + index &= ~0x20; + else + index |= 0x20; + + (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); + pci_io_write8(hwp->io, VGA_ATTR_INDEX, index); + return pci_io_read8(hwp->io, VGA_ATTR_DATA_R); +} + +static void +stdWriteMiscOut(vgaHWPtr hwp, CARD8 value) +{ + pci_io_write8(hwp->io, VGA_MISC_OUT_W, value); +} + +static CARD8 +stdReadMiscOut(vgaHWPtr hwp) +{ + return pci_io_read8(hwp->io, VGA_MISC_OUT_R); +} + +static void +stdEnablePalette(vgaHWPtr hwp) +{ + (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); + pci_io_write8(hwp->io, VGA_ATTR_INDEX, 0x00); + hwp->paletteEnabled = TRUE; +} + +static void +stdDisablePalette(vgaHWPtr hwp) +{ + (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET); + pci_io_write8(hwp->io, VGA_ATTR_INDEX, 0x20); + hwp->paletteEnabled = FALSE; +} + +static void +stdWriteDacMask(vgaHWPtr hwp, CARD8 value) +{ + pci_io_write8(hwp->io, VGA_DAC_MASK, value); +} + +static CARD8 +stdReadDacMask(vgaHWPtr hwp) +{ + return pci_io_read8(hwp->io, VGA_DAC_MASK); +} + +static void +stdWriteDacReadAddr(vgaHWPtr hwp, CARD8 value) +{ + pci_io_write8(hwp->io, VGA_DAC_READ_ADDR, value); +} + +static void +stdWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value) +{ + pci_io_write8(hwp->io, VGA_DAC_WRITE_ADDR, value); +} + +static void +stdWriteDacData(vgaHWPtr hwp, CARD8 value) +{ + pci_io_write8(hwp->io, VGA_DAC_DATA, value); +} + +static CARD8 +stdReadDacData(vgaHWPtr hwp) +{ + return pci_io_read8(hwp->io, VGA_DAC_DATA); +} + +static CARD8 +stdReadEnable(vgaHWPtr hwp) +{ + return pci_io_read8(hwp->io, VGA_ENABLE); +} + +static void +stdWriteEnable(vgaHWPtr hwp, CARD8 value) +{ + pci_io_write8(hwp->io, VGA_ENABLE, value); +} + +void +vgaHWSetStdFuncs(vgaHWPtr hwp) +{ + hwp->writeCrtc = stdWriteCrtc; + hwp->readCrtc = stdReadCrtc; + hwp->writeGr = stdWriteGr; + hwp->readGr = stdReadGr; + hwp->readST00 = stdReadST00; + hwp->readST01 = stdReadST01; + hwp->readFCR = stdReadFCR; + hwp->writeFCR = stdWriteFCR; + hwp->writeAttr = stdWriteAttr; + hwp->readAttr = stdReadAttr; + hwp->writeSeq = stdWriteSeq; + hwp->readSeq = stdReadSeq; + hwp->writeMiscOut = stdWriteMiscOut; + hwp->readMiscOut = stdReadMiscOut; + hwp->enablePalette = stdEnablePalette; + hwp->disablePalette = stdDisablePalette; + hwp->writeDacMask = stdWriteDacMask; + hwp->readDacMask = stdReadDacMask; + hwp->writeDacWriteAddr = stdWriteDacWriteAddr; + hwp->writeDacReadAddr = stdWriteDacReadAddr; + hwp->writeDacData = stdWriteDacData; + hwp->readDacData = stdReadDacData; + hwp->readEnable = stdReadEnable; + hwp->writeEnable = stdWriteEnable; + + hwp->io = pci_legacy_open_io(hwp->dev, 0, 64 * 1024); +} + +/* + * MMIO versions of the register access functions. These require + * hwp->MemBase to be set in such a way that when the standard VGA port + * adderss is added the correct memory address results. + */ + +#define minb(p) MMIO_IN8(hwp->MMIOBase, (hwp->MMIOOffset + (p))) +#define moutb(p,v) MMIO_OUT8(hwp->MMIOBase, (hwp->MMIOOffset + (p)),(v)) + +static void +mmioWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index); + moutb(hwp->IOBase + VGA_CRTC_DATA_OFFSET, value); +} + +static CARD8 +mmioReadCrtc(vgaHWPtr hwp, CARD8 index) +{ + moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index); + return minb(hwp->IOBase + VGA_CRTC_DATA_OFFSET); +} + +static void +mmioWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + moutb(VGA_GRAPH_INDEX, index); + moutb(VGA_GRAPH_DATA, value); +} + +static CARD8 +mmioReadGr(vgaHWPtr hwp, CARD8 index) +{ + moutb(VGA_GRAPH_INDEX, index); + return minb(VGA_GRAPH_DATA); +} + +static void +mmioWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + moutb(VGA_SEQ_INDEX, index); + moutb(VGA_SEQ_DATA, value); +} + +static CARD8 +mmioReadSeq(vgaHWPtr hwp, CARD8 index) +{ + moutb(VGA_SEQ_INDEX, index); + return minb(VGA_SEQ_DATA); +} + +static CARD8 +mmioReadST00(vgaHWPtr hwp) +{ + return minb(VGA_IN_STAT_0); +} + +static CARD8 +mmioReadST01(vgaHWPtr hwp) +{ + return minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); +} + +static CARD8 +mmioReadFCR(vgaHWPtr hwp) +{ + return minb(VGA_FEATURE_R); +} + +static void +mmioWriteFCR(vgaHWPtr hwp, CARD8 value) +{ + moutb(hwp->IOBase + VGA_FEATURE_W_OFFSET,value); +} + +static void +mmioWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + if (hwp->paletteEnabled) + index &= ~0x20; + else + index |= 0x20; + + (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); + moutb(VGA_ATTR_INDEX, index); + moutb(VGA_ATTR_DATA_W, value); +} + +static CARD8 +mmioReadAttr(vgaHWPtr hwp, CARD8 index) +{ + if (hwp->paletteEnabled) + index &= ~0x20; + else + index |= 0x20; + + (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); + moutb(VGA_ATTR_INDEX, index); + return minb(VGA_ATTR_DATA_R); +} + +static void +mmioWriteMiscOut(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_MISC_OUT_W, value); +} + +static CARD8 +mmioReadMiscOut(vgaHWPtr hwp) +{ + return minb(VGA_MISC_OUT_R); +} + +static void +mmioEnablePalette(vgaHWPtr hwp) +{ + (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); + moutb(VGA_ATTR_INDEX, 0x00); + hwp->paletteEnabled = TRUE; +} + +static void +mmioDisablePalette(vgaHWPtr hwp) +{ + (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); + moutb(VGA_ATTR_INDEX, 0x20); + hwp->paletteEnabled = FALSE; +} + +static void +mmioWriteDacMask(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_DAC_MASK, value); +} + +static CARD8 +mmioReadDacMask(vgaHWPtr hwp) +{ + return minb(VGA_DAC_MASK); +} + +static void +mmioWriteDacReadAddr(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_DAC_READ_ADDR, value); +} + +static void +mmioWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_DAC_WRITE_ADDR, value); +} + +static void +mmioWriteDacData(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_DAC_DATA, value); +} + +static CARD8 +mmioReadDacData(vgaHWPtr hwp) +{ + return minb(VGA_DAC_DATA); +} + +static CARD8 +mmioReadEnable(vgaHWPtr hwp) +{ + return minb(VGA_ENABLE); +} + +static void +mmioWriteEnable(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_ENABLE, value); +} + +void +vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset) +{ + hwp->writeCrtc = mmioWriteCrtc; + hwp->readCrtc = mmioReadCrtc; + hwp->writeGr = mmioWriteGr; + hwp->readGr = mmioReadGr; + hwp->readST00 = mmioReadST00; + hwp->readST01 = mmioReadST01; + hwp->readFCR = mmioReadFCR; + hwp->writeFCR = mmioWriteFCR; + hwp->writeAttr = mmioWriteAttr; + hwp->readAttr = mmioReadAttr; + hwp->writeSeq = mmioWriteSeq; + hwp->readSeq = mmioReadSeq; + hwp->writeMiscOut = mmioWriteMiscOut; + hwp->readMiscOut = mmioReadMiscOut; + hwp->enablePalette = mmioEnablePalette; + hwp->disablePalette = mmioDisablePalette; + hwp->writeDacMask = mmioWriteDacMask; + hwp->readDacMask = mmioReadDacMask; + hwp->writeDacWriteAddr = mmioWriteDacWriteAddr; + hwp->writeDacReadAddr = mmioWriteDacReadAddr; + hwp->writeDacData = mmioWriteDacData; + hwp->readDacData = mmioReadDacData; + hwp->MMIOBase = base; + hwp->MMIOOffset = offset; + hwp->readEnable = mmioReadEnable; + hwp->writeEnable = mmioWriteEnable; +} + +/* + * vgaHWProtect -- + * Protect VGA registers and memory from corruption during loads. + */ + +void +vgaHWProtect(ScrnInfoPtr pScrn, Bool on) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + + unsigned char tmp; + + if (pScrn->vtSema) { + if (on) { + /* + * Turn off screen and disable sequencer. + */ + tmp = hwp->readSeq(hwp, 0x01); + + vgaHWSeqReset(hwp, TRUE); /* start synchronous reset */ + hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */ + + hwp->enablePalette(hwp); + } else { + /* + * Reenable sequencer, then turn on screen. + */ + + tmp = hwp->readSeq(hwp, 0x01); + + hwp->writeSeq(hwp, 0x01, tmp & ~0x20); /* reenable display */ + vgaHWSeqReset(hwp, FALSE); /* clear synchronousreset */ + + hwp->disablePalette(hwp); + } + } +} + +vgaHWProtectProc *vgaHWProtectWeak(void) { + return vgaHWProtect; +} + +/* + * vgaHWBlankScreen -- blank the screen. + */ + +void +vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + unsigned char scrn; + + scrn = hwp->readSeq(hwp, 0x01); + + if (on) { + scrn &= ~0x20; /* enable screen */ + } else { + scrn |= 0x20; /* blank screen */ + } + + vgaHWSeqReset(hwp, TRUE); + hwp->writeSeq(hwp, 0x01, scrn); /* change mode */ + vgaHWSeqReset(hwp, FALSE); +} + +vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void) { + return vgaHWBlankScreen; +} + +/* + * vgaHWSaveScreen -- blank the screen. + */ + +Bool +vgaHWSaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = NULL; + Bool on; + + if (pScreen != NULL) + pScrn = xf86Screens[pScreen->myNum]; + + on = xf86IsUnblank(mode); + +#if 0 + if (on) + SetTimeSinceLastInputEvent(); +#endif + + if ((pScrn != NULL) && pScrn->vtSema) { + vgaHWBlankScreen(pScrn, on); + } + return TRUE; +} + + +/* + * vgaHWDPMSSet -- Sets VESA Display Power Management Signaling (DPMS) Mode + * + * This generic VGA function can only set the Off and On modes. If the + * Standby and Suspend modes are to be supported, a chip specific replacement + * for this function must be written. + */ + +void +vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) +{ + unsigned char seq1 = 0, crtc17 = 0; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + if (!pScrn->vtSema) return; + + switch (PowerManagementMode) { + case DPMSModeOn: + /* Screen: On; HSync: On, VSync: On */ + seq1 = 0x00; + crtc17 = 0x80; + break; + case DPMSModeStandby: + /* Screen: Off; HSync: Off, VSync: On -- Not Supported */ + seq1 = 0x20; + crtc17 = 0x80; + break; + case DPMSModeSuspend: + /* Screen: Off; HSync: On, VSync: Off -- Not Supported */ + seq1 = 0x20; + crtc17 = 0x80; + break; + case DPMSModeOff: + /* Screen: Off; HSync: Off, VSync: Off */ + seq1 = 0x20; + crtc17 = 0x00; + break; + } + hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */ + seq1 |= hwp->readSeq(hwp, 0x01) & ~0x20; + hwp->writeSeq(hwp, 0x01, seq1); + crtc17 |= hwp->readCrtc(hwp, 0x17) & ~0x80; + usleep(10000); + hwp->writeCrtc(hwp, 0x17, crtc17); + hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */ +} + + +/* + * vgaHWSeqReset + * perform a sequencer reset. + */ + +void +vgaHWSeqReset(vgaHWPtr hwp, Bool start) +{ + if (start) + hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */ + else + hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */ +} + + +void +vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore) +{ +#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int savedIOBase; + unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4; + Bool doMap = FALSE; + + /* If nothing to do, return now */ + if (!hwp->FontInfo1 && !hwp->FontInfo2 && !hwp->TextInfo) + return; + + if (hwp->Base == NULL) { + doMap = TRUE; + if (!vgaHWMapMem(scrninfp)) { + xf86DrvMsg(scrninfp->scrnIndex, X_ERROR, + "vgaHWRestoreFonts: vgaHWMapMem() failed\n"); + return; + } + } + + /* save the registers that are needed here */ + miscOut = hwp->readMiscOut(hwp); + attr10 = hwp->readAttr(hwp, 0x10); + gr1 = hwp->readGr(hwp, 0x01); + gr3 = hwp->readGr(hwp, 0x03); + gr4 = hwp->readGr(hwp, 0x04); + gr5 = hwp->readGr(hwp, 0x05); + gr6 = hwp->readGr(hwp, 0x06); + gr8 = hwp->readGr(hwp, 0x08); + seq2 = hwp->readSeq(hwp, 0x02); + seq4 = hwp->readSeq(hwp, 0x04); + + /* save hwp->IOBase and temporarily set it for colour mode */ + savedIOBase = hwp->IOBase; + hwp->IOBase = VGA_IOBASE_COLOR; + + /* Force into colour mode */ + hwp->writeMiscOut(hwp, miscOut | 0x01); + + vgaHWBlankScreen(scrninfp, FALSE); + + /* + * here we temporarily switch to 16 colour planar mode, to simply + * copy the font-info and saved text. + * + * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly! + */ +#if 0 + hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */ +#endif + + hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */ + hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */ + hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */ + + if (scrninfp->depth == 4) { + /* GJA */ + hwp->writeGr(hwp, 0x03, 0x00); /* don't rotate, write unmodified */ + hwp->writeGr(hwp, 0x08, 0xFF); /* write all bits in a byte */ + hwp->writeGr(hwp, 0x01, 0x00); /* all planes come from CPU */ + } + +#if SAVE_FONT1 + if (hwp->FontInfo1) { + hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */ + hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */ + slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT); + } +#endif + +#if SAVE_FONT2 + if (hwp->FontInfo2) { + hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */ + hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */ + slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT); + } +#endif + +#if SAVE_TEXT + if (hwp->TextInfo) { + hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */ + hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */ + slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT); + hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */ + hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */ + slowbcopy_tobus((unsigned char *)hwp->TextInfo + TEXT_AMOUNT, + hwp->Base, TEXT_AMOUNT); + } +#endif + + vgaHWBlankScreen(scrninfp, TRUE); + + /* restore the registers that were changed */ + hwp->writeMiscOut(hwp, miscOut); + hwp->writeAttr(hwp, 0x10, attr10); + hwp->writeGr(hwp, 0x01, gr1); + hwp->writeGr(hwp, 0x03, gr3); + hwp->writeGr(hwp, 0x04, gr4); + hwp->writeGr(hwp, 0x05, gr5); + hwp->writeGr(hwp, 0x06, gr6); + hwp->writeGr(hwp, 0x08, gr8); + hwp->writeSeq(hwp, 0x02, seq2); + hwp->writeSeq(hwp, 0x04, seq4); + hwp->IOBase = savedIOBase; + + if (doMap) + vgaHWUnmapMem(scrninfp); + +#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */ +} + + +void +vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore) +{ + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int i; + + if (restore->MiscOutReg & 0x01) + hwp->IOBase = VGA_IOBASE_COLOR; + else + hwp->IOBase = VGA_IOBASE_MONO; + + hwp->writeMiscOut(hwp, restore->MiscOutReg); + + for (i = 1; i < restore->numSequencer; i++) + hwp->writeSeq(hwp, i, restore->Sequencer[i]); + + /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */ + hwp->writeCrtc(hwp, 17, restore->CRTC[17] & ~0x80); + + for (i = 0; i < restore->numCRTC; i++) + hwp->writeCrtc(hwp, i, restore->CRTC[i]); + + for (i = 0; i < restore->numGraphics; i++) + hwp->writeGr(hwp, i, restore->Graphics[i]); + + hwp->enablePalette(hwp); + for (i = 0; i < restore->numAttribute; i++) + hwp->writeAttr(hwp, i, restore->Attribute[i]); + hwp->disablePalette(hwp); +} + + +void +vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore) +{ + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int i; + +#if 0 + hwp->enablePalette(hwp); +#endif + + hwp->writeDacMask(hwp, 0xFF); + hwp->writeDacWriteAddr(hwp, 0x00); + for (i = 0; i < 768; i++) { + hwp->writeDacData(hwp, restore->DAC[i]); + DACDelay(hwp); + } + + hwp->disablePalette(hwp); +} + + +/* + * vgaHWRestore -- + * restore the VGA state + */ + +void +vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags) +{ + if (flags & VGA_SR_MODE) + vgaHWRestoreMode(scrninfp, restore); + + if (flags & VGA_SR_FONTS) + vgaHWRestoreFonts(scrninfp, restore); + + if (flags & VGA_SR_CMAP) + vgaHWRestoreColormap(scrninfp, restore); +} + +void +vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save) +{ +#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int savedIOBase; + unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4; + Bool doMap = FALSE; + + if (hwp->Base == NULL) { + doMap = TRUE; + if (!vgaHWMapMem(scrninfp)) { + xf86DrvMsg(scrninfp->scrnIndex, X_ERROR, + "vgaHWSaveFonts: vgaHWMapMem() failed\n"); + return; + } + } + + /* If in graphics mode, don't save anything */ + attr10 = hwp->readAttr(hwp, 0x10); + if (attr10 & 0x01) + return; + + /* save the registers that are needed here */ + miscOut = hwp->readMiscOut(hwp); + gr4 = hwp->readGr(hwp, 0x04); + gr5 = hwp->readGr(hwp, 0x05); + gr6 = hwp->readGr(hwp, 0x06); + seq2 = hwp->readSeq(hwp, 0x02); + seq4 = hwp->readSeq(hwp, 0x04); + + /* save hwp->IOBase and temporarily set it for colour mode */ + savedIOBase = hwp->IOBase; + hwp->IOBase = VGA_IOBASE_COLOR; + + /* Force into colour mode */ + hwp->writeMiscOut(hwp, miscOut | 0x01); + + vgaHWBlankScreen(scrninfp, FALSE); + + /* + * get the character sets, and text screen if required + */ + /* + * Here we temporarily switch to 16 colour planar mode, to simply + * copy the font-info + * + * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly! + */ +#if 0 + hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */ +#endif + + hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */ + hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */ + hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */ + +#if SAVE_FONT1 + if (hwp->FontInfo1 || (hwp->FontInfo1 = malloc(FONT_AMOUNT))) { + hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */ + hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */ + slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT); + } +#endif /* SAVE_FONT1 */ +#if SAVE_FONT2 + if (hwp->FontInfo2 || (hwp->FontInfo2 = malloc(FONT_AMOUNT))) { + hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */ + hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */ + slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT); + } +#endif /* SAVE_FONT2 */ +#if SAVE_TEXT + if (hwp->TextInfo || (hwp->TextInfo = malloc(2 * TEXT_AMOUNT))) { + hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */ + hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */ + slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT); + hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */ + hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */ + slowbcopy_frombus(hwp->Base, + (unsigned char *)hwp->TextInfo + TEXT_AMOUNT, TEXT_AMOUNT); + } +#endif /* SAVE_TEXT */ + + /* Restore clobbered registers */ + hwp->writeAttr(hwp, 0x10, attr10); + hwp->writeSeq(hwp, 0x02, seq2); + hwp->writeSeq(hwp, 0x04, seq4); + hwp->writeGr(hwp, 0x04, gr4); + hwp->writeGr(hwp, 0x05, gr5); + hwp->writeGr(hwp, 0x06, gr6); + hwp->writeMiscOut(hwp, miscOut); + hwp->IOBase = savedIOBase; + + vgaHWBlankScreen(scrninfp, TRUE); + + if (doMap) + vgaHWUnmapMem(scrninfp); + +#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */ +} + +void +vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save) +{ + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int i; + + save->MiscOutReg = hwp->readMiscOut(hwp); + if (save->MiscOutReg & 0x01) + hwp->IOBase = VGA_IOBASE_COLOR; + else + hwp->IOBase = VGA_IOBASE_MONO; + + for (i = 0; i < save->numCRTC; i++) { + save->CRTC[i] = hwp->readCrtc(hwp, i); + DebugF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]); + } + + hwp->enablePalette(hwp); + for (i = 0; i < save->numAttribute; i++) { + save->Attribute[i] = hwp->readAttr(hwp, i); + DebugF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]); + } + hwp->disablePalette(hwp); + + for (i = 0; i < save->numGraphics; i++) { + save->Graphics[i] = hwp->readGr(hwp, i); + DebugF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]); + } + + for (i = 1; i < save->numSequencer; i++) { + save->Sequencer[i] = hwp->readSeq(hwp, i); + DebugF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]); + } +} + + +void +vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save) +{ + vgaHWPtr hwp = VGAHWPTR(scrninfp); + Bool readError = FALSE; + int i; + +#ifdef NEED_SAVED_CMAP + /* + * Some ET4000 chips from 1991 have a HW bug that prevents the reading + * of the color lookup table. Mask rev 9042EAI is known to have this bug. + * + * If the colourmap is not readable, we set the saved map to a default + * map (taken from Ferraro's "Programmer's Guide to the EGA and VGA + * Cards" 2nd ed). + */ + + /* Only save it once */ + if (hwp->cmapSaved) + return; + +#if 0 + hwp->enablePalette(hwp); +#endif + + hwp->writeDacMask(hwp, 0xFF); + + /* + * check if we can read the lookup table + */ + hwp->writeDacReadAddr(hwp, 0x00); + for (i = 0; i < 6; i++) { + save->DAC[i] = hwp->readDacData(hwp); + switch (i % 3) { + case 0: + DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]); + break; + case 1: + DebugF("0x%02x, ", save->DAC[i]); + break; + case 2: + DebugF("0x%02x\n", save->DAC[i]); + } + } + + /* + * Check if we can read the palette - + * use foreground color to prevent flashing. + */ + hwp->writeDacWriteAddr(hwp, 0x01); + for (i = 3; i < 6; i++) + hwp->writeDacData(hwp, ~save->DAC[i] & DAC_TEST_MASK); + hwp->writeDacReadAddr(hwp, 0x01); + for (i = 3; i < 6; i++) { + if (hwp->readDacData(hwp) != (~save->DAC[i] & DAC_TEST_MASK)) + readError = TRUE; + } + hwp->writeDacWriteAddr(hwp, 0x01); + for (i = 3; i < 6; i++) + hwp->writeDacData(hwp, save->DAC[i]); + + if (readError) { + /* + * save the default lookup table + */ + memmove(save->DAC, defaultDAC, 768); + xf86DrvMsg(scrninfp->scrnIndex, X_WARNING, + "Cannot read colourmap from VGA. Will restore with default\n"); + } else { + /* save the colourmap */ + hwp->writeDacReadAddr(hwp, 0x02); + for (i = 6; i < 768; i++) { + save->DAC[i] = hwp->readDacData(hwp); + DACDelay(hwp); + switch (i % 3) { + case 0: + DebugF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]); + break; + case 1: + DebugF("0x%02x, ", save->DAC[i]); + break; + case 2: + DebugF("0x%02x\n", save->DAC[i]); + } + } + } + + hwp->disablePalette(hwp); + hwp->cmapSaved = TRUE; +#endif +} + +/* + * vgaHWSave -- + * save the current VGA state + */ + +void +vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags) +{ + if (save == NULL) + return; + + if (flags & VGA_SR_CMAP) + vgaHWSaveColormap(scrninfp, save); + + if (flags & VGA_SR_MODE) + vgaHWSaveMode(scrninfp, save); + + if (flags & VGA_SR_FONTS) + vgaHWSaveFonts(scrninfp, save); +} + + +/* + * vgaHWInit -- + * Handle the initialization, etc. of a screen. + * Return FALSE on failure. + */ + +Bool +vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode) +{ + unsigned int i; + vgaHWPtr hwp; + vgaRegPtr regp; + int depth = scrninfp->depth; + + /* + * make sure the vgaHWRec is allocated + */ + if (!vgaHWGetHWRec(scrninfp)) + return FALSE; + hwp = VGAHWPTR(scrninfp); + regp = &hwp->ModeReg; + + /* + * compute correct Hsync & Vsync polarity + */ + if ((mode->Flags & (V_PHSYNC | V_NHSYNC)) + && (mode->Flags & (V_PVSYNC | V_NVSYNC))) + { + regp->MiscOutReg = 0x23; + if (mode->Flags & V_NHSYNC) regp->MiscOutReg |= 0x40; + if (mode->Flags & V_NVSYNC) regp->MiscOutReg |= 0x80; + } + else + { + int VDisplay = mode->VDisplay; + if (mode->Flags & V_DBLSCAN) + VDisplay *= 2; + if (mode->VScan > 1) + VDisplay *= mode->VScan; + if (VDisplay < 400) + regp->MiscOutReg = 0xA3; /* +hsync -vsync */ + else if (VDisplay < 480) + regp->MiscOutReg = 0x63; /* -hsync +vsync */ + else if (VDisplay < 768) + regp->MiscOutReg = 0xE3; /* -hsync -vsync */ + else + regp->MiscOutReg = 0x23; /* +hsync +vsync */ + } + + regp->MiscOutReg |= (mode->ClockIndex & 0x03) << 2; + + /* + * Time Sequencer + */ + if (depth == 4) + regp->Sequencer[0] = 0x02; + else + regp->Sequencer[0] = 0x00; + if (mode->Flags & V_CLKDIV2) + regp->Sequencer[1] = 0x09; + else + regp->Sequencer[1] = 0x01; + if (depth == 1) + regp->Sequencer[2] = 1 << BIT_PLANE; + else + regp->Sequencer[2] = 0x0F; + regp->Sequencer[3] = 0x00; /* Font select */ + if (depth < 8) + regp->Sequencer[4] = 0x06; /* Misc */ + else + regp->Sequencer[4] = 0x0E; /* Misc */ + + /* + * CRTC Controller + */ + regp->CRTC[0] = (mode->CrtcHTotal >> 3) - 5; + regp->CRTC[1] = (mode->CrtcHDisplay >> 3) - 1; + regp->CRTC[2] = (mode->CrtcHBlankStart >> 3) - 1; + regp->CRTC[3] = (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F) | 0x80; + i = (((mode->CrtcHSkew << 2) + 0x10) & ~0x1F); + if (i < 0x80) + regp->CRTC[3] |= i; + regp->CRTC[4] = (mode->CrtcHSyncStart >> 3); + regp->CRTC[5] = ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2) + | (((mode->CrtcHSyncEnd >> 3)) & 0x1F); + regp->CRTC[6] = (mode->CrtcVTotal - 2) & 0xFF; + regp->CRTC[7] = (((mode->CrtcVTotal - 2) & 0x100) >> 8) + | (((mode->CrtcVDisplay - 1) & 0x100) >> 7) + | ((mode->CrtcVSyncStart & 0x100) >> 6) + | (((mode->CrtcVBlankStart - 1) & 0x100) >> 5) + | 0x10 + | (((mode->CrtcVTotal - 2) & 0x200) >> 4) + | (((mode->CrtcVDisplay - 1) & 0x200) >> 3) + | ((mode->CrtcVSyncStart & 0x200) >> 2); + regp->CRTC[8] = 0x00; + regp->CRTC[9] = (((mode->CrtcVBlankStart - 1) & 0x200) >> 4) | 0x40; + if (mode->Flags & V_DBLSCAN) + regp->CRTC[9] |= 0x80; + if (mode->VScan >= 32) + regp->CRTC[9] |= 0x1F; + else if (mode->VScan > 1) + regp->CRTC[9] |= mode->VScan - 1; + regp->CRTC[10] = 0x00; + regp->CRTC[11] = 0x00; + regp->CRTC[12] = 0x00; + regp->CRTC[13] = 0x00; + regp->CRTC[14] = 0x00; + regp->CRTC[15] = 0x00; + regp->CRTC[16] = mode->CrtcVSyncStart & 0xFF; + regp->CRTC[17] = (mode->CrtcVSyncEnd & 0x0F) | 0x20; + regp->CRTC[18] = (mode->CrtcVDisplay - 1) & 0xFF; + regp->CRTC[19] = scrninfp->displayWidth >> 4; /* just a guess */ + regp->CRTC[20] = 0x00; + regp->CRTC[21] = (mode->CrtcVBlankStart - 1) & 0xFF; + regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF; + if (depth < 8) + regp->CRTC[23] = 0xE3; + else + regp->CRTC[23] = 0xC3; + regp->CRTC[24] = 0xFF; + + vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO); + vgaHWVBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO); + + /* + * Theory resumes here.... + */ + + /* + * Graphics Display Controller + */ + regp->Graphics[0] = 0x00; + regp->Graphics[1] = 0x00; + regp->Graphics[2] = 0x00; + regp->Graphics[3] = 0x00; + if (depth == 1) { + regp->Graphics[4] = BIT_PLANE; + regp->Graphics[5] = 0x00; + } else { + regp->Graphics[4] = 0x00; + if (depth == 4) + regp->Graphics[5] = 0x02; + else + regp->Graphics[5] = 0x40; + } + regp->Graphics[6] = 0x05; /* only map 64k VGA memory !!!! */ + regp->Graphics[7] = 0x0F; + regp->Graphics[8] = 0xFF; + + if (depth == 1) { + /* Initialise the Mono map according to which bit-plane gets used */ + + Bool flipPixels = xf86GetFlipPixels(); + + for (i=0; i<16; i++) + if (((i & (1 << BIT_PLANE)) != 0) != flipPixels) + regp->Attribute[i] = WHITE_VALUE; + else + regp->Attribute[i] = BLACK_VALUE; + + regp->Attribute[16] = 0x01; /* -VGA2- */ /* wrong for the ET4000 */ + if (!hwp->ShowOverscan) + regp->Attribute[OVERSCAN] = OVERSCAN_VALUE; /* -VGA2- */ + } else { + regp->Attribute[0] = 0x00; /* standard colormap translation */ + regp->Attribute[1] = 0x01; + regp->Attribute[2] = 0x02; + regp->Attribute[3] = 0x03; + regp->Attribute[4] = 0x04; + regp->Attribute[5] = 0x05; + regp->Attribute[6] = 0x06; + regp->Attribute[7] = 0x07; + regp->Attribute[8] = 0x08; + regp->Attribute[9] = 0x09; + regp->Attribute[10] = 0x0A; + regp->Attribute[11] = 0x0B; + regp->Attribute[12] = 0x0C; + regp->Attribute[13] = 0x0D; + regp->Attribute[14] = 0x0E; + regp->Attribute[15] = 0x0F; + if (depth == 4) + regp->Attribute[16] = 0x81; /* wrong for the ET4000 */ + else + regp->Attribute[16] = 0x41; /* wrong for the ET4000 */ + /* Attribute[17] (overscan) initialised in vgaHWGetHWRec() */ + } + regp->Attribute[18] = 0x0F; + regp->Attribute[19] = 0x00; + regp->Attribute[20] = 0x00; + + return TRUE; +} + + /* + * OK, so much for theory. Now, let's deal with the >real< world... + * + * The above CRTC settings are precise in theory, except that many, if not + * most, VGA clones fail to reset the blanking signal when the character or + * line counter reaches [HV]Total. In this case, the signal is only + * unblanked when the counter reaches [HV]BlankEnd (mod 64, 128 or 256 as + * the case may be) at the start of the >next< scanline or frame, which + * means only part of the screen shows. This affects how null overscans + * are to be implemented on such adapters. + * + * Henceforth, VGA cores that implement this broken, but unfortunately + * common, behaviour are to be designated as KGA's, in honour of Koen + * Gadeyne, whose zeal to eliminate overscans (read: fury) set in motion + * a series of events that led to the discovery of this problem. + * + * Some VGA's are KGA's only in the horizontal, or only in the vertical, + * some in both, others in neither. Don't let anyone tell you there is + * such a thing as a VGA "standard"... And, thank the Creator for the fact + * that Hilbert spaces are not yet implemented in this industry. + * + * The following implements a trick suggested by David Dawes. This sets + * [HV]BlankEnd to zero if the blanking interval does not already contain a + * 0-point, and decrements it by one otherwise. In the latter case, this + * will produce a left and/or top overscan which the colourmap code will + * (still) need to ensure is as close to black as possible. This will make + * the behaviour consistent across all chipsets, while allowing all + * chipsets to display the entire screen. Non-KGA drivers can ignore the + * following in their own copy of this code. + * + * -- TSI @ UQV, 1998.08.21 + */ + +CARD32 +vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, + unsigned int Flags) +{ + int nExtBits = (nBits < 6) ? 0 : nBits - 6; + CARD32 ExtBits; + CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 6; + + regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) + | (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F); + regp->CRTC[5] = (regp->CRTC[5] & ~0x80) + | ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2); + ExtBits = ((mode->CrtcHBlankEnd >> 3) - 1) & ExtBitMask; + + /* First the horizontal case */ + if ((Flags & KGA_FIX_OVERSCAN) + && ((mode->CrtcHBlankEnd >> 3) == (mode->CrtcHTotal >> 3))) + { + int i = (regp->CRTC[3] & 0x1F) + | ((regp->CRTC[5] & 0x80) >> 2) + | ExtBits; + if (Flags & KGA_ENABLE_ON_ZERO) { + if ((i-- > (((mode->CrtcHBlankStart >> 3) - 1) + & (0x3F | ExtBitMask))) + && (mode->CrtcHBlankEnd == mode->CrtcHTotal)) + i = 0; + } else if (Flags & KGA_BE_TOT_DEC) + i--; + regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) | (i & 0x1F); + regp->CRTC[5] = (regp->CRTC[5] & ~0x80) | ((i << 2) & 0x80); + ExtBits = i & ExtBitMask; + } + return ExtBits >> 6; +} + + /* + * The vertical case is a little trickier. Some VGA's ignore bit 0x80 of + * CRTC[22]. Also, in some cases, a zero CRTC[22] will still blank the + * very first scanline in a double- or multi-scanned mode. This last case + * needs further investigation. + */ +CARD32 +vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, + unsigned int Flags) +{ + CARD32 ExtBits; + CARD32 nExtBits = (nBits < 8) ? 0 : (nBits - 8); + CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 8; + /* If width is not known nBits should be 0. In this + * case BitMask is set to 0 so we can check for it. */ + CARD32 BitMask = (nBits < 7) ? 0 : ((1 << nExtBits) - 1); + int VBlankStart = (mode->CrtcVBlankStart - 1) & 0xFF; + regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF; + ExtBits = (mode->CrtcVBlankEnd - 1) & ExtBitMask; + + if ((Flags & KGA_FIX_OVERSCAN) + && (mode->CrtcVBlankEnd == mode->CrtcVTotal)) + /* Null top overscan */ + { + int i = regp->CRTC[22] | ExtBits; + if (Flags & KGA_ENABLE_ON_ZERO) { + if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask))) + || ((i > VBlankStart) && /* 8-bit case */ + ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */ + !(regp->CRTC[9] & 0x9F)) /* 1 scanline/row */ + i = 0; + else + i = (i - 1); + } else if (Flags & KGA_BE_TOT_DEC) + i = (i - 1); + + regp->CRTC[22] = i & 0xFF; + ExtBits = i & 0xFF00; + } + return ExtBits >> 8; +} + +/* + * these are some more hardware specific helpers, formerly in vga.c + */ +static void +vgaHWGetHWRecPrivate(void) +{ + if (vgaHWPrivateIndex < 0) + vgaHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + return; +} + + +static void +vgaHWFreeRegs(vgaRegPtr regp) +{ + free(regp->CRTC); + + regp->CRTC = + regp->Sequencer = + regp->Graphics = + regp->Attribute = NULL; + + regp->numCRTC = + regp->numSequencer = + regp->numGraphics = + regp->numAttribute = 0; +} + + + +static Bool +vgaHWAllocRegs(vgaRegPtr regp) +{ + unsigned char *buf; + + if ((regp->numCRTC + regp->numSequencer + regp->numGraphics + + regp->numAttribute) == 0) + return FALSE; + + buf = calloc(regp->numCRTC + + regp->numSequencer + + regp->numGraphics + + regp->numAttribute, 1); + if (!buf) + return FALSE; + + regp->CRTC = buf; + regp->Sequencer = regp->CRTC + regp->numCRTC; + regp->Graphics = regp->Sequencer + regp->numSequencer; + regp->Attribute = regp->Graphics + regp->numGraphics; + + return TRUE; +} + + +Bool +vgaHWAllocDefaultRegs(vgaRegPtr regp) +{ + regp->numCRTC = VGA_NUM_CRTC; + regp->numSequencer = VGA_NUM_SEQ; + regp->numGraphics = VGA_NUM_GFX; + regp->numAttribute = VGA_NUM_ATTR; + + return vgaHWAllocRegs(regp); +} + + +Bool +vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer, + int numGraphics, int numAttribute) +{ +#define VGAHWMINNUM(regtype) \ + ((newMode.num##regtype < regp->num##regtype) ? \ + (newMode.num##regtype) : (regp->num##regtype)) +#define VGAHWCOPYREGSET(regtype) \ + memcpy (newMode.regtype, regp->regtype, VGAHWMINNUM(regtype)) + + vgaRegRec newMode, newSaved; + vgaRegPtr regp; + + regp = &VGAHWPTR(scrp)->ModeReg; + memcpy (&newMode, regp, sizeof(vgaRegRec)); + + /* allocate space for new registers */ + + regp = &newMode; + regp->numCRTC = numCRTC; + regp->numSequencer = numSequencer; + regp->numGraphics = numGraphics; + regp->numAttribute = numAttribute; + if (!vgaHWAllocRegs(regp)) + return FALSE; + + regp = &VGAHWPTR(scrp)->SavedReg; + memcpy (&newSaved, regp, sizeof(vgaRegRec)); + + regp = &newSaved; + regp->numCRTC = numCRTC; + regp->numSequencer = numSequencer; + regp->numGraphics = numGraphics; + regp->numAttribute = numAttribute; + if (!vgaHWAllocRegs(regp)) { + vgaHWFreeRegs(&newMode); + return FALSE; + } + + /* allocations succeeded, copy register data into new space */ + + regp = &VGAHWPTR(scrp)->ModeReg; + VGAHWCOPYREGSET(CRTC); + VGAHWCOPYREGSET(Sequencer); + VGAHWCOPYREGSET(Graphics); + VGAHWCOPYREGSET(Attribute); + + regp = &VGAHWPTR(scrp)->SavedReg; + VGAHWCOPYREGSET(CRTC); + VGAHWCOPYREGSET(Sequencer); + VGAHWCOPYREGSET(Graphics); + VGAHWCOPYREGSET(Attribute); + + /* free old register arrays */ + + regp = &VGAHWPTR(scrp)->ModeReg; + vgaHWFreeRegs(regp); + memcpy(regp, &newMode, sizeof(vgaRegRec)); + + regp = &VGAHWPTR(scrp)->SavedReg; + vgaHWFreeRegs(regp); + memcpy(regp, &newSaved, sizeof(vgaRegRec)); + + return TRUE; + +#undef VGAHWMINNUM +#undef VGAHWCOPYREGSET +} + + +Bool +vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src) +{ + vgaHWFreeRegs(dst); + + memcpy(dst, src, sizeof(vgaRegRec)); + + if (!vgaHWAllocRegs(dst)) + return FALSE; + + memcpy(dst->CRTC, src->CRTC, src->numCRTC); + memcpy(dst->Sequencer, src->Sequencer, src->numSequencer); + memcpy(dst->Graphics, src->Graphics, src->numGraphics); + memcpy(dst->Attribute, src->Attribute, src->numAttribute); + + return TRUE; +} + + +Bool +vgaHWGetHWRec(ScrnInfoPtr scrp) +{ + vgaRegPtr regp; + vgaHWPtr hwp; + int i; + + /* + * Let's make sure that the private exists and allocate one. + */ + vgaHWGetHWRecPrivate(); + /* + * New privates are always set to NULL, so we can check if the allocation + * has already been done. + */ + if (VGAHWPTR(scrp)) + return TRUE; + hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(sizeof(vgaHWRec), 1); + regp = &VGAHWPTR(scrp)->ModeReg; + + if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) || + (!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->ModeReg))) { + free(hwp); + return FALSE; + } + + if (scrp->bitsPerPixel == 1) { + rgb blackColour = scrp->display->blackColour, + whiteColour = scrp->display->whiteColour; + + if (blackColour.red > 0x3F) blackColour.red = 0x3F; + if (blackColour.green > 0x3F) blackColour.green = 0x3F; + if (blackColour.blue > 0x3F) blackColour.blue = 0x3F; + + if (whiteColour.red > 0x3F) whiteColour.red = 0x3F; + if (whiteColour.green > 0x3F) whiteColour.green = 0x3F; + if (whiteColour.blue > 0x3F) whiteColour.blue = 0x3F; + + if ((blackColour.red == whiteColour.red ) && + (blackColour.green == whiteColour.green) && + (blackColour.blue == whiteColour.blue )) { + blackColour.red ^= 0x3F; + blackColour.green ^= 0x3F; + blackColour.blue ^= 0x3F; + } + + /* + * initialize default colormap for monochrome + */ + for (i=0; i<3; i++) regp->DAC[i] = 0x00; + for (i=3; i<768; i++) regp->DAC[i] = 0x3F; + i = BLACK_VALUE * 3; + regp->DAC[i++] = blackColour.red; + regp->DAC[i++] = blackColour.green; + regp->DAC[i] = blackColour.blue; + i = WHITE_VALUE * 3; + regp->DAC[i++] = whiteColour.red; + regp->DAC[i++] = whiteColour.green; + regp->DAC[i] = whiteColour.blue; + i = OVERSCAN_VALUE * 3; + regp->DAC[i++] = 0x00; + regp->DAC[i++] = 0x00; + regp->DAC[i] = 0x00; + } else { + /* Set all colours to black */ + for (i=0; i<768; i++) regp->DAC[i] = 0x00; + /* ... and the overscan */ + if (scrp->depth >= 4) + regp->Attribute[OVERSCAN] = 0xFF; + } + if (xf86FindOption(scrp->confScreen->options, "ShowOverscan")) { + xf86MarkOptionUsedByName(scrp->confScreen->options, "ShowOverscan"); + xf86DrvMsg(scrp->scrnIndex, X_CONFIG, "Showing overscan area\n"); + regp->DAC[765] = 0x3F; + regp->DAC[766] = 0x00; + regp->DAC[767] = 0x3F; + regp->Attribute[OVERSCAN] = 0xFF; + hwp->ShowOverscan = TRUE; + } else + hwp->ShowOverscan = FALSE; + + hwp->paletteEnabled = FALSE; + hwp->cmapSaved = FALSE; + hwp->MapSize = 0; + hwp->pScrn = scrp; + + hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]); + + return TRUE; +} + + +void +vgaHWFreeHWRec(ScrnInfoPtr scrp) +{ + if (vgaHWPrivateIndex >= 0) { + vgaHWPtr hwp = VGAHWPTR(scrp); + + if (!hwp) + return; + + pci_device_close_io(hwp->dev, hwp->io); + + free(hwp->FontInfo1); + free(hwp->FontInfo2); + free(hwp->TextInfo); + + vgaHWFreeRegs (&hwp->ModeReg); + vgaHWFreeRegs (&hwp->SavedReg); + + free(hwp); + VGAHWPTRLVAL(scrp) = NULL; + } +} + + +Bool +vgaHWMapMem(ScrnInfoPtr scrp) +{ + vgaHWPtr hwp = VGAHWPTR(scrp); + + if (hwp->Base) + return TRUE; + + /* If not set, initialise with the defaults */ + if (hwp->MapSize == 0) + hwp->MapSize = VGA_DEFAULT_MEM_SIZE; + if (hwp->MapPhys == 0) + hwp->MapPhys = VGA_DEFAULT_PHYS_ADDR; + + /* + * Map as VIDMEM_MMIO_32BIT because WC + * is bad when there is page flipping. + * XXX This is not correct but we do it + * for now. + */ + DebugF("Mapping VGAMem\n"); + pci_device_map_legacy(hwp->dev, hwp->MapPhys, hwp->MapSize, PCI_DEV_MAP_FLAG_WRITABLE, &hwp->Base); + return hwp->Base != NULL; +} + + +void +vgaHWUnmapMem(ScrnInfoPtr scrp) +{ + vgaHWPtr hwp = VGAHWPTR(scrp); + + if (hwp->Base == NULL) + return; + + DebugF("Unmapping VGAMem\n"); + pci_device_unmap_legacy(hwp->dev, hwp->Base, hwp->MapSize); + hwp->Base = NULL; +} + +int +vgaHWGetIndex(void) +{ + return vgaHWPrivateIndex; +} + + +void +vgaHWGetIOBase(vgaHWPtr hwp) +{ + hwp->IOBase = (hwp->readMiscOut(hwp) & 0x01) ? + VGA_IOBASE_COLOR : VGA_IOBASE_MONO; + xf86DrvMsgVerb(hwp->pScrn->scrnIndex, X_INFO, 3, + "vgaHWGetIOBase: hwp->IOBase is 0x%04x\n", hwp->IOBase); +} + + +void +vgaHWLock(vgaHWPtr hwp) +{ + /* Protect CRTC[0-7] */ + hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) | 0x80); +} + +void +vgaHWUnlock(vgaHWPtr hwp) +{ + /* Unprotect CRTC[0-7] */ + hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) & ~0x80); +} + + +void +vgaHWEnable(vgaHWPtr hwp) +{ + hwp->writeEnable(hwp, hwp->readEnable(hwp) | 0x01); +} + + +void +vgaHWDisable(vgaHWPtr hwp) +{ + hwp->writeEnable(hwp, hwp->readEnable(hwp) & ~0x01); +} + + +static void +vgaHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, + VisualPtr pVisual) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + int i, index; + + for (i = 0; i < numColors; i++) { + index = indices[i]; + hwp->writeDacWriteAddr(hwp, index); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].red); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].green); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].blue); + DACDelay(hwp); + } + + /* This shouldn't be necessary, but we'll play safe. */ + hwp->disablePalette(hwp); +} + + +static void +vgaHWSetOverscan(ScrnInfoPtr pScrn, int overscan) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + + if (overscan < 0 || overscan > 255) + return; + + hwp->enablePalette(hwp); + hwp->writeAttr(hwp, OVERSCAN, overscan); + +#ifdef DEBUGOVERSCAN + { + int ov = hwp->readAttr(hwp, OVERSCAN); + int red, green, blue; + + hwp->writeDacReadAddr(hwp, ov); + red = hwp->readDacData(hwp); + green = hwp->readDacData(hwp); + blue = hwp->readDacData(hwp); + ErrorF("Overscan index is 0x%02x, colours are #%02x%02x%02x\n", + ov, red, green, blue); + } +#endif + + hwp->disablePalette(hwp); +} + + +Bool +vgaHWHandleColormaps(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if (pScrn->depth > 1 && pScrn->depth <= 8) { + return xf86HandleColormaps(pScreen, 1 << pScrn->depth, + pScrn->rgbBits, vgaHWLoadPalette, + pScrn->depth > 4 ? vgaHWSetOverscan : NULL, + CMAP_RELOAD_ON_MODE_SWITCH); + } + return TRUE; +} + +/* ----------------------- DDC support ------------------------*/ +/* + * Adjust v_active, v_blank, v_sync, v_sync_end, v_blank_end, v_total + * to read out EDID at a faster rate. Allowed maximum is 25kHz with + * 20 usec v_sync active. Set positive v_sync polarity, turn off lightpen + * readback, enable access to cr00-cr07. + */ + +/* vertical timings */ +#define DISPLAY_END 0x04 +#define BLANK_START DISPLAY_END +#define SYNC_START BLANK_START +#define SYNC_END 0x09 +#define BLANK_END SYNC_END +#define V_TOTAL BLANK_END +/* this function doesn't have to be reentrant for our purposes */ +struct _vgaDdcSave { + unsigned char cr03; + unsigned char cr06; + unsigned char cr07; + unsigned char cr09; + unsigned char cr10; + unsigned char cr11; + unsigned char cr12; + unsigned char cr15; + unsigned char cr16; + unsigned char msr; +}; + +void +vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + unsigned char tmp; + struct _vgaDdcSave* save; + switch (speed) { + case DDC_FAST: + + if (hwp->ddc != NULL) break; + hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave),1); + save = (struct _vgaDdcSave *)hwp->ddc; + /* Lightpen register disable - allow access to cr10 & 11; just in case */ + save->cr03 = hwp->readCrtc(hwp, 0x03); + hwp->writeCrtc(hwp,0x03,(save->cr03 |0x80)); + save->cr12 = hwp->readCrtc(hwp, 0x12); + hwp->writeCrtc(hwp,0x12,DISPLAY_END); + save->cr15 = hwp->readCrtc(hwp, 0x15); + hwp->writeCrtc(hwp,0x15,BLANK_START); + save->cr10 = hwp->readCrtc(hwp, 0x10); + hwp->writeCrtc(hwp,0x10,SYNC_START); + save->cr11 = hwp->readCrtc(hwp, 0x11); + /* unprotect group 1 registers; just in case ...*/ + hwp->writeCrtc(hwp,0x11,((save->cr11 & 0x70) | SYNC_END)); + save->cr16 = hwp->readCrtc(hwp, 0x16); + hwp->writeCrtc(hwp,0x16,BLANK_END); + save->cr06 = hwp->readCrtc(hwp, 0x06); + hwp->writeCrtc(hwp,0x06,V_TOTAL); + /* all values have less than 8 bit - mask out 9th and 10th bits */ + save->cr09 = hwp->readCrtc(hwp, 0x09); + hwp->writeCrtc(hwp,0x09,(save->cr09 &0xDF)); + save->cr07 = hwp->readCrtc(hwp, 0x07); + hwp->writeCrtc(hwp,0x07,(save->cr07 &0x10)); + /* vsync polarity negativ & ensure a 25MHz clock */ + save->msr = hwp->readMiscOut(hwp); + hwp->writeMiscOut(hwp,((save->msr & 0xF3) | 0x80)); + break; + case DDC_SLOW: + if (hwp->ddc == NULL) break; + save = (struct _vgaDdcSave *)hwp->ddc; + hwp->writeMiscOut(hwp,save->msr); + hwp->writeCrtc(hwp,0x07,save->cr07); + tmp = hwp->readCrtc(hwp, 0x09); + hwp->writeCrtc(hwp,0x09,((save->cr09 & 0x20) | (tmp & 0xDF))); + hwp->writeCrtc(hwp,0x06,save->cr06); + hwp->writeCrtc(hwp,0x16,save->cr16); + hwp->writeCrtc(hwp,0x11,save->cr11); + hwp->writeCrtc(hwp,0x10,save->cr10); + hwp->writeCrtc(hwp,0x15,save->cr15); + hwp->writeCrtc(hwp,0x12,save->cr12); + hwp->writeCrtc(hwp,0x03,save->cr03); + free(save); + hwp->ddc = NULL; + break; + default: + break; + } +} + +DDC1SetSpeedProc +vgaHWddc1SetSpeedWeak(void) +{ + return vgaHWddc1SetSpeed; +} + +SaveScreenProcPtr vgaHWSaveScreenWeak(void) +{ + return vgaHWSaveScreen; +} + +/* + * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ... + */ +void +xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), + void (*ProtectRegs)(ScrnInfoPtr, Bool), + void (*BlankScreen)(ScrnInfoPtr, Bool), unsigned long vertsyncreg, + int maskval, int knownclkindex, int knownclkvalue) +{ + register int status = vertsyncreg; + unsigned long i, cnt, rcnt, sync; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + /* First save registers that get written on */ + (*ClockFunc)(pScrn, CLK_REG_SAVE); + + if (num > MAXCLOCKS) + num = MAXCLOCKS; + + for (i = 0; i < num; i++) + { + if (ProtectRegs) + (*ProtectRegs)(pScrn, TRUE); + if (!(*ClockFunc)(pScrn, i)) + { + pScrn->clock[i] = -1; + continue; + } + if (ProtectRegs) + (*ProtectRegs)(pScrn, FALSE); + if (BlankScreen) + (*BlankScreen)(pScrn, FALSE); + + usleep(50000); /* let VCO stabilise */ + + cnt = 0; + sync = 200000; + + while ((pci_io_read8(hwp->io, status) & maskval) == 0x00) + if (sync-- == 0) goto finish; + /* Something appears to be happening, so reset sync count */ + sync = 200000; + while ((pci_io_read8(hwp->io, status) & maskval) == maskval) + if (sync-- == 0) goto finish; + /* Something appears to be happening, so reset sync count */ + sync = 200000; + while ((pci_io_read8(hwp->io, status) & maskval) == 0x00) + if (sync-- == 0) goto finish; + + for (rcnt = 0; rcnt < 5; rcnt++) + { + while (!(pci_io_read8(hwp->io, status) & maskval)) + cnt++; + while ((pci_io_read8(hwp->io, status) & maskval)) + cnt++; + } + +finish: + pScrn->clock[i] = cnt ? cnt : -1; + if (BlankScreen) + (*BlankScreen)(pScrn, TRUE); + } + + for (i = 0; i < num; i++) + { + if (i != knownclkindex) + { + if (pScrn->clock[i] == -1) + { + pScrn->clock[i] = 0; + } + else + { + pScrn->clock[i] = (int)(0.5 + + (((float)knownclkvalue) * pScrn->clock[knownclkindex]) / + (pScrn->clock[i])); + /* Round to nearest 10KHz */ + pScrn->clock[i] += 5; + pScrn->clock[i] /= 10; + pScrn->clock[i] *= 10; + } + } + } + + pScrn->clock[knownclkindex] = knownclkvalue; + pScrn->numClocks = num; + + /* Restore registers that were written on */ + (*ClockFunc)(pScrn, CLK_REG_RESTORE); +} diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.h b/xorg-server/hw/xfree86/vgahw/vgaHW.h index d7ac3cc62..e943aa391 100644 --- a/xorg-server/hw/xfree86/vgahw/vgaHW.h +++ b/xorg-server/hw/xfree86/vgahw/vgaHW.h @@ -1,235 +1,233 @@ -
-
-/*
- * Copyright (c) 1997,1998 The XFree86 Project, Inc.
- *
- * Loosely based on code bearing the following copyright:
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * Author: Dirk Hohndel
- */
-
-#ifndef _VGAHW_H
-#define _VGAHW_H
-
-#include <X11/X.h>
-#include "misc.h"
-#include "input.h"
-#include "scrnintstr.h"
-#include "colormapst.h"
-
-#include "xf86str.h"
-#include "xf86Pci.h"
-
-#include "xf86DDC.h"
-
-#include "globals.h"
-#include <X11/extensions/dpmsconst.h>
-
-extern _X_EXPORT int vgaHWGetIndex(void);
-
-/*
- * access macro
- */
-#define VGAHWPTR(p) ((vgaHWPtr)((p)->privates[vgaHWGetIndex()].ptr))
-
-/* Standard VGA registers */
-#define VGA_ATTR_INDEX 0x3C0
-#define VGA_ATTR_DATA_W 0x3C0
-#define VGA_ATTR_DATA_R 0x3C1
-#define VGA_IN_STAT_0 0x3C2 /* read */
-#define VGA_MISC_OUT_W 0x3C2 /* write */
-#define VGA_ENABLE 0x3C3
-#define VGA_SEQ_INDEX 0x3C4
-#define VGA_SEQ_DATA 0x3C5
-#define VGA_DAC_MASK 0x3C6
-#define VGA_DAC_READ_ADDR 0x3C7
-#define VGA_DAC_WRITE_ADDR 0x3C8
-#define VGA_DAC_DATA 0x3C9
-#define VGA_FEATURE_R 0x3CA /* read */
-#define VGA_MISC_OUT_R 0x3CC /* read */
-#define VGA_GRAPH_INDEX 0x3CE
-#define VGA_GRAPH_DATA 0x3CF
-
-#define VGA_IOBASE_MONO 0x3B0
-#define VGA_IOBASE_COLOR 0x3D0
-
-#define VGA_CRTC_INDEX_OFFSET 0x04
-#define VGA_CRTC_DATA_OFFSET 0x05
-#define VGA_IN_STAT_1_OFFSET 0x0A /* read */
-#define VGA_FEATURE_W_OFFSET 0x0A /* write */
-
-/* default number of VGA registers stored internally */
-#define VGA_NUM_CRTC 25
-#define VGA_NUM_SEQ 5
-#define VGA_NUM_GFX 9
-#define VGA_NUM_ATTR 21
-
-/* Flags for vgaHWSave() and vgaHWRestore() */
-#define VGA_SR_MODE 0x01
-#define VGA_SR_FONTS 0x02
-#define VGA_SR_CMAP 0x04
-#define VGA_SR_ALL (VGA_SR_MODE | VGA_SR_FONTS | VGA_SR_CMAP)
-
-/* Defaults for the VGA memory window */
-#define VGA_DEFAULT_PHYS_ADDR 0xA0000
-#define VGA_DEFAULT_MEM_SIZE (64 * 1024)
-
-/*
- * vgaRegRec contains settings of standard VGA registers.
- */
-typedef struct {
- unsigned char MiscOutReg; /* */
- unsigned char *CRTC; /* Crtc Controller */
- unsigned char *Sequencer; /* Video Sequencer */
- unsigned char *Graphics; /* Video Graphics */
- unsigned char *Attribute; /* Video Atribute */
- unsigned char DAC[768]; /* Internal Colorlookuptable */
- unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */
- unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */
- unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */
- unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */
-} vgaRegRec, *vgaRegPtr;
-
-typedef struct _vgaHWRec *vgaHWPtr;
-
-typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value);
-typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx);
-typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value);
-typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp);
-typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp);
-
-
-/*
- * vgaHWRec contains per-screen information required by the vgahw module.
- *
- * Note, the palette referred to by the paletteEnabled, enablePalette and
- * disablePalette is the 16-entry (+overscan) EGA-compatible palette accessed
- * via the first 17 attribute registers and not the main 8-bit palette.
- */
-typedef struct _vgaHWRec {
- pointer Base; /* Address of "VGA" memory */
- int MapSize; /* Size of "VGA" memory */
- unsigned long MapPhys; /* phys location of VGA mem */
- int IOBase; /* I/O Base address */
- CARD8 * MMIOBase; /* Pointer to MMIO start */
- int MMIOOffset; /* base + offset + vgareg
- = mmioreg */
- pointer FontInfo1; /* save area for fonts in
- plane 2 */
- pointer FontInfo2; /* save area for fonts in
- plane 3 */
- pointer TextInfo; /* save area for text */
- vgaRegRec SavedReg; /* saved registers */
- vgaRegRec ModeReg; /* register settings for
- current mode */
- Bool ShowOverscan;
- Bool paletteEnabled;
- Bool cmapSaved;
- ScrnInfoPtr pScrn;
- vgaHWWriteIndexProcPtr writeCrtc;
- vgaHWReadIndexProcPtr readCrtc;
- vgaHWWriteIndexProcPtr writeGr;
- vgaHWReadIndexProcPtr readGr;
- vgaHWReadProcPtr readST00;
- vgaHWReadProcPtr readST01;
- vgaHWReadProcPtr readFCR;
- vgaHWWriteProcPtr writeFCR;
- vgaHWWriteIndexProcPtr writeAttr;
- vgaHWReadIndexProcPtr readAttr;
- vgaHWWriteIndexProcPtr writeSeq;
- vgaHWReadIndexProcPtr readSeq;
- vgaHWWriteProcPtr writeMiscOut;
- vgaHWReadProcPtr readMiscOut;
- vgaHWMiscProcPtr enablePalette;
- vgaHWMiscProcPtr disablePalette;
- vgaHWWriteProcPtr writeDacMask;
- vgaHWReadProcPtr readDacMask;
- vgaHWWriteProcPtr writeDacWriteAddr;
- vgaHWWriteProcPtr writeDacReadAddr;
- vgaHWWriteProcPtr writeDacData;
- vgaHWReadProcPtr readDacData;
- pointer ddc;
- IOADDRESS PIOOffset; /* offset + vgareg
- = pioreg */
- vgaHWReadProcPtr readEnable;
- vgaHWWriteProcPtr writeEnable;
- struct pci_device *dev;
-} vgaHWRec;
-
-/* Some macros that VGA drivers can use in their ChipProbe() function */
-#define VGAHW_GET_IOBASE() ((inb(VGA_MISC_OUT_R) & 0x01) ? \
- VGA_IOBASE_COLOR : VGA_IOBASE_MONO)
-
-#define OVERSCAN 0x11 /* Index of OverScan register */
-
-/* Flags that define how overscan correction should take place */
-#define KGA_FIX_OVERSCAN 1 /* overcan correction required */
-#define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */
- /* of next scanline/frame */
-#define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */
- /* to total - 1 */
-#define BIT_PLANE 3 /* Which plane we write to in mono mode */
-#define BITS_PER_GUN 6
-#define COLORMAP_SIZE 256
-
-#if defined(__powerpc__) || defined(__arm__) || defined(__s390__) || defined(__nds32__)
-#define DACDelay(hw) /* No legacy VGA support */
-#else
-#define DACDelay(hw) \
- do { \
- (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
- (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
- } while (0)
-#endif
-
-/* Function Prototypes */
-
-/* vgaHW.c */
-
-typedef void vgaHWProtectProc(ScrnInfoPtr, Bool);
-typedef void vgaHWBlankScreenProc(ScrnInfoPtr, Bool);
-
-extern _X_EXPORT void vgaHWSetStdFuncs(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset);
-extern _X_EXPORT void vgaHWProtect(ScrnInfoPtr pScrn, Bool on);
-extern _X_EXPORT vgaHWProtectProc *vgaHWProtectWeak(void);
-extern _X_EXPORT Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
-extern _X_EXPORT void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
-extern _X_EXPORT vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void);
-extern _X_EXPORT void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
-extern _X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore);
-extern _X_EXPORT void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore);
-extern _X_EXPORT void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore);
-extern _X_EXPORT void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags);
-extern _X_EXPORT void vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save);
-extern _X_EXPORT void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save);
-extern _X_EXPORT void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save);
-extern _X_EXPORT void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags);
-extern _X_EXPORT Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode);
-extern _X_EXPORT Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer,
- int numGraphics, int numAttribute);
-extern _X_EXPORT Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
-extern _X_EXPORT Bool vgaHWGetHWRec(ScrnInfoPtr scrp);
-extern _X_EXPORT void vgaHWFreeHWRec(ScrnInfoPtr scrp);
-extern _X_EXPORT Bool vgaHWMapMem(ScrnInfoPtr scrp);
-extern _X_EXPORT void vgaHWUnmapMem(ScrnInfoPtr scrp);
-extern _X_EXPORT void vgaHWGetIOBase(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWLock(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWUnlock(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWDisable(vgaHWPtr hwp);
-extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
-extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen);
-extern _X_EXPORT void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed);
-extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags);
-extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
- unsigned int Flags);
-extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp);
-
-extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void);
-extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void);
-
-#endif /* _VGAHW_H */
+ + +/* + * Copyright (c) 1997,1998 The XFree86 Project, Inc. + * + * Loosely based on code bearing the following copyright: + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Author: Dirk Hohndel + */ + +#ifndef _VGAHW_H +#define _VGAHW_H + +#include <X11/X.h> +#include "misc.h" +#include "input.h" +#include "scrnintstr.h" +#include "colormapst.h" + +#include "xf86str.h" +#include "xf86Pci.h" + +#include "xf86DDC.h" + +#include "globals.h" +#include <X11/extensions/dpmsconst.h> + +extern _X_EXPORT int vgaHWGetIndex(void); + +/* + * access macro + */ +#define VGAHWPTR(p) ((vgaHWPtr)((p)->privates[vgaHWGetIndex()].ptr)) + +/* Standard VGA registers */ +#define VGA_ATTR_INDEX 0x3C0 +#define VGA_ATTR_DATA_W 0x3C0 +#define VGA_ATTR_DATA_R 0x3C1 +#define VGA_IN_STAT_0 0x3C2 /* read */ +#define VGA_MISC_OUT_W 0x3C2 /* write */ +#define VGA_ENABLE 0x3C3 +#define VGA_SEQ_INDEX 0x3C4 +#define VGA_SEQ_DATA 0x3C5 +#define VGA_DAC_MASK 0x3C6 +#define VGA_DAC_READ_ADDR 0x3C7 +#define VGA_DAC_WRITE_ADDR 0x3C8 +#define VGA_DAC_DATA 0x3C9 +#define VGA_FEATURE_R 0x3CA /* read */ +#define VGA_MISC_OUT_R 0x3CC /* read */ +#define VGA_GRAPH_INDEX 0x3CE +#define VGA_GRAPH_DATA 0x3CF + +#define VGA_IOBASE_MONO 0x3B0 +#define VGA_IOBASE_COLOR 0x3D0 + +#define VGA_CRTC_INDEX_OFFSET 0x04 +#define VGA_CRTC_DATA_OFFSET 0x05 +#define VGA_IN_STAT_1_OFFSET 0x0A /* read */ +#define VGA_FEATURE_W_OFFSET 0x0A /* write */ + +/* default number of VGA registers stored internally */ +#define VGA_NUM_CRTC 25 +#define VGA_NUM_SEQ 5 +#define VGA_NUM_GFX 9 +#define VGA_NUM_ATTR 21 + +/* Flags for vgaHWSave() and vgaHWRestore() */ +#define VGA_SR_MODE 0x01 +#define VGA_SR_FONTS 0x02 +#define VGA_SR_CMAP 0x04 +#define VGA_SR_ALL (VGA_SR_MODE | VGA_SR_FONTS | VGA_SR_CMAP) + +/* Defaults for the VGA memory window */ +#define VGA_DEFAULT_PHYS_ADDR 0xA0000 +#define VGA_DEFAULT_MEM_SIZE (64 * 1024) + +/* + * vgaRegRec contains settings of standard VGA registers. + */ +typedef struct { + unsigned char MiscOutReg; /* */ + unsigned char *CRTC; /* Crtc Controller */ + unsigned char *Sequencer; /* Video Sequencer */ + unsigned char *Graphics; /* Video Graphics */ + unsigned char *Attribute; /* Video Atribute */ + unsigned char DAC[768]; /* Internal Colorlookuptable */ + unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */ + unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */ + unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */ + unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */ +} vgaRegRec, *vgaRegPtr; + +typedef struct _vgaHWRec *vgaHWPtr; + +typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value); +typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx); +typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value); +typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp); +typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp); + + +/* + * vgaHWRec contains per-screen information required by the vgahw module. + * + * Note, the palette referred to by the paletteEnabled, enablePalette and + * disablePalette is the 16-entry (+overscan) EGA-compatible palette accessed + * via the first 17 attribute registers and not the main 8-bit palette. + */ +typedef struct _vgaHWRec { + pointer Base; /* Address of "VGA" memory */ + int MapSize; /* Size of "VGA" memory */ + unsigned long MapPhys; /* phys location of VGA mem */ + int IOBase; /* I/O Base address */ + CARD8 * MMIOBase; /* Pointer to MMIO start */ + int MMIOOffset; /* base + offset + vgareg + = mmioreg */ + pointer FontInfo1; /* save area for fonts in + plane 2 */ + pointer FontInfo2; /* save area for fonts in + plane 3 */ + pointer TextInfo; /* save area for text */ + vgaRegRec SavedReg; /* saved registers */ + vgaRegRec ModeReg; /* register settings for + current mode */ + Bool ShowOverscan; + Bool paletteEnabled; + Bool cmapSaved; + ScrnInfoPtr pScrn; + vgaHWWriteIndexProcPtr writeCrtc; + vgaHWReadIndexProcPtr readCrtc; + vgaHWWriteIndexProcPtr writeGr; + vgaHWReadIndexProcPtr readGr; + vgaHWReadProcPtr readST00; + vgaHWReadProcPtr readST01; + vgaHWReadProcPtr readFCR; + vgaHWWriteProcPtr writeFCR; + vgaHWWriteIndexProcPtr writeAttr; + vgaHWReadIndexProcPtr readAttr; + vgaHWWriteIndexProcPtr writeSeq; + vgaHWReadIndexProcPtr readSeq; + vgaHWWriteProcPtr writeMiscOut; + vgaHWReadProcPtr readMiscOut; + vgaHWMiscProcPtr enablePalette; + vgaHWMiscProcPtr disablePalette; + vgaHWWriteProcPtr writeDacMask; + vgaHWReadProcPtr readDacMask; + vgaHWWriteProcPtr writeDacWriteAddr; + vgaHWWriteProcPtr writeDacReadAddr; + vgaHWWriteProcPtr writeDacData; + vgaHWReadProcPtr readDacData; + pointer ddc; + struct pci_io_handle *io; + vgaHWReadProcPtr readEnable; + vgaHWWriteProcPtr writeEnable; + struct pci_device *dev; +} vgaHWRec; + +/* Some macros that VGA drivers can use in their ChipProbe() function */ +#define OVERSCAN 0x11 /* Index of OverScan register */ + +/* Flags that define how overscan correction should take place */ +#define KGA_FIX_OVERSCAN 1 /* overcan correction required */ +#define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */ + /* of next scanline/frame */ +#define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */ + /* to total - 1 */ +#define BIT_PLANE 3 /* Which plane we write to in mono mode */ +#define BITS_PER_GUN 6 +#define COLORMAP_SIZE 256 + +#define DACDelay(hw) \ + do { \ + pci_io_read8((hw)->io, (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ + pci_io_read8((hw)->io, (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ + } while (0) + +/* Function Prototypes */ + +/* vgaHW.c */ + +typedef void vgaHWProtectProc(ScrnInfoPtr, Bool); +typedef void vgaHWBlankScreenProc(ScrnInfoPtr, Bool); + +extern _X_EXPORT void vgaHWSetStdFuncs(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset); +extern _X_EXPORT void vgaHWProtect(ScrnInfoPtr pScrn, Bool on); +extern _X_EXPORT vgaHWProtectProc *vgaHWProtectWeak(void); +extern _X_EXPORT Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode); +extern _X_EXPORT void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on); +extern _X_EXPORT vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void); +extern _X_EXPORT void vgaHWSeqReset(vgaHWPtr hwp, Bool start); +extern _X_EXPORT void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore); +extern _X_EXPORT void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore); +extern _X_EXPORT void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore); +extern _X_EXPORT void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags); +extern _X_EXPORT void vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save); +extern _X_EXPORT void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save); +extern _X_EXPORT void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save); +extern _X_EXPORT void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags); +extern _X_EXPORT Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode); +extern _X_EXPORT Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer, + int numGraphics, int numAttribute); +extern _X_EXPORT Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src); +extern _X_EXPORT Bool vgaHWGetHWRec(ScrnInfoPtr scrp); +extern _X_EXPORT void vgaHWFreeHWRec(ScrnInfoPtr scrp); +extern _X_EXPORT Bool vgaHWMapMem(ScrnInfoPtr scrp); +extern _X_EXPORT void vgaHWUnmapMem(ScrnInfoPtr scrp); +extern _X_EXPORT void vgaHWGetIOBase(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWLock(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWUnlock(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWDisable(vgaHWPtr hwp); +extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); +extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen); +extern _X_EXPORT void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed); +extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, + unsigned int Flags); +extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, + unsigned int Flags); +extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp); + +extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void); +extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void); +extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, + Bool (*ClockFunc)(ScrnInfoPtr, int), + void (*ProtectRegs)(ScrnInfoPtr, Bool), + void (*BlankScreen)(ScrnInfoPtr, Bool), + unsigned long vertsyncreg, int maskval, + int knownclkindex, int knownclkvalue); + +#endif /* _VGAHW_H */ diff --git a/xorg-server/hw/xfree86/xaa/Makefile.am b/xorg-server/hw/xfree86/xaa/Makefile.am index fcbc53a73..7ebe0b91e 100644 --- a/xorg-server/hw/xfree86/xaa/Makefile.am +++ b/xorg-server/hw/xfree86/xaa/Makefile.am @@ -1,74 +1,74 @@ -LSB_FIRST = l-xaaBitmap.c l-xaaStipple.c l-xaaTEGlyph.c
-LSB_3_FIRST = l3-xaaBitmap.c l3-xaaStipple.c
-MSB_FIRST = m-xaaBitmap.c m-xaaStipple.c m-xaaTEGlyph.c
-MSB_3_FIRST = m3-xaaBitmap.c m3-xaaStipple.c
-LSB_FIXED = lf-xaaBitmap.c lf-xaaStipple.c lf-xaaTEGlyph.c
-LSB_3_FIXED = lf3-xaaBitmap.c lf3-xaaStipple.c
-MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c
-MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c
-POLYSEG = s-xaaLine.c s-xaaDashLine.c
-
-libxaa_la_LDFLAGS = -avoid-version
-if COMPOSITE
-libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la
-endif
-
-module_LTLIBRARIES = libxaa.la
-libxaa_la_SOURCES = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c \
- xaaBitBlt.c xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c \
- xaaCpyPlane.c xaaFillRect.c xaaTEText.c xaaNonTEText.c \
- xaaPCache.c xaaSpans.c xaaROP.c xaaImage.c \
- xaaRect.c xaaLineMisc.c xaaBitOrder.c \
- xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c \
- xaaLine.c xaaDashLine.c xaaOverlay.c xaaOffscreen.c \
- xaaOverlayDF.c xaaStateChange.c xaaPict.c $(POLYSEG) \
- $(LSB_FIRST) $(MSB_FIRST) $(LSB_FIXED) $(MSB_FIXED) \
- $(LSB_3_FIRST) $(MSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIXED)
-${POLYSEG}:
- $(AM_V_GEN)echo "#define POLYSEGMENT" > $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:s-%=%}"' >> $@
-${LSB_FIRST}:
- $(AM_V_GEN)echo "#define LSBFIRST" > $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:l-%=%}"' >> $@
-${LSB_3_FIRST}:
- $(AM_V_GEN)echo "#define LSBFIRST" > $@
- $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:l3-%=%}"' >> $@
-${LSB_FIXED}:
- $(AM_V_GEN)echo "#define LSBFIRST" > $@
- $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:lf-%=%}"' >> $@
-${LSB_3_FIXED}:
- $(AM_V_GEN)echo "#define LSBFIRST" > $@
- $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
- $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:lf3-%=%}"' >> $@
-${MSB_FIRST}:
- $(AM_V_GEN)echo "#define MSBFIRST" > $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:m-%=%}"' >> $@
-${MSB_3_FIRST}:
- $(AM_V_GEN)echo "#define MSBFIRST" > $@
- $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:m3-%=%}"' >> $@
-${MSB_FIXED}:
- $(AM_V_GEN)echo "#define MSBFIRST" > $@
- $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:mf-%=%}"' >> $@
-${MSB_3_FIXED}:
- $(AM_V_GEN)echo "#define MSBFIRST" > $@
- $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
- $(AM_V_GEN)echo "#define FIXEDBASE" >> $@
- $(AM_V_GEN)echo '#include "$(srcdir)/${@:mf3-%=%}"' >> $@
-
-DISTCLEANFILES = $(POLYSEG) \
- $(LSB_FIRST) $(LSB_FIXED) $(MSB_FIRST) $(MSB_FIXED) \
- $(LSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIRST) $(MSB_3_FIXED)
-
-sdk_HEADERS = xaa.h xaalocal.h xaarop.h
-EXTRA_DIST = xaacexp.h xaawrap.h xaaLine.c xaaDashLine.c \
- xaaStipple.c xaaTEGlyph.c xaaNonTEGlyph.c xaaBitmap.c \
- XAA.HOWTO
-
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../../../miext/cw
-
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
+LSB_FIRST = l-xaaBitmap.c l-xaaStipple.c l-xaaTEGlyph.c +LSB_3_FIRST = l3-xaaBitmap.c l3-xaaStipple.c +MSB_FIRST = m-xaaBitmap.c m-xaaStipple.c m-xaaTEGlyph.c +MSB_3_FIRST = m3-xaaBitmap.c m3-xaaStipple.c +LSB_FIXED = lf-xaaBitmap.c lf-xaaStipple.c lf-xaaTEGlyph.c +LSB_3_FIXED = lf3-xaaBitmap.c lf3-xaaStipple.c +MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c +MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c +POLYSEG = s-xaaLine.c s-xaaDashLine.c + +libxaa_la_LDFLAGS = -module -avoid-version +if COMPOSITE +libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la +endif + +module_LTLIBRARIES = libxaa.la +libxaa_la_SOURCES = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c \ + xaaBitBlt.c xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c \ + xaaCpyPlane.c xaaFillRect.c xaaTEText.c xaaNonTEText.c \ + xaaPCache.c xaaSpans.c xaaROP.c xaaImage.c \ + xaaRect.c xaaLineMisc.c xaaBitOrder.c \ + xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c \ + xaaLine.c xaaDashLine.c xaaOverlay.c xaaOffscreen.c \ + xaaOverlayDF.c xaaStateChange.c xaaPict.c $(POLYSEG) \ + $(LSB_FIRST) $(MSB_FIRST) $(LSB_FIXED) $(MSB_FIXED) \ + $(LSB_3_FIRST) $(MSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIXED) +${POLYSEG}: + $(AM_V_GEN)echo "#define POLYSEGMENT" > $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:s-%=%}"' >> $@ +${LSB_FIRST}: + $(AM_V_GEN)echo "#define LSBFIRST" > $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:l-%=%}"' >> $@ +${LSB_3_FIRST}: + $(AM_V_GEN)echo "#define LSBFIRST" > $@ + $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:l3-%=%}"' >> $@ +${LSB_FIXED}: + $(AM_V_GEN)echo "#define LSBFIRST" > $@ + $(AM_V_GEN)echo "#define FIXEDBASE" >> $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:lf-%=%}"' >> $@ +${LSB_3_FIXED}: + $(AM_V_GEN)echo "#define LSBFIRST" > $@ + $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@ + $(AM_V_GEN)echo "#define FIXEDBASE" >> $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:lf3-%=%}"' >> $@ +${MSB_FIRST}: + $(AM_V_GEN)echo "#define MSBFIRST" > $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:m-%=%}"' >> $@ +${MSB_3_FIRST}: + $(AM_V_GEN)echo "#define MSBFIRST" > $@ + $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:m3-%=%}"' >> $@ +${MSB_FIXED}: + $(AM_V_GEN)echo "#define MSBFIRST" > $@ + $(AM_V_GEN)echo "#define FIXEDBASE" >> $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:mf-%=%}"' >> $@ +${MSB_3_FIXED}: + $(AM_V_GEN)echo "#define MSBFIRST" > $@ + $(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@ + $(AM_V_GEN)echo "#define FIXEDBASE" >> $@ + $(AM_V_GEN)echo '#include "$(srcdir)/${@:mf3-%=%}"' >> $@ + +DISTCLEANFILES = $(POLYSEG) \ + $(LSB_FIRST) $(LSB_FIXED) $(MSB_FIRST) $(MSB_FIXED) \ + $(LSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIRST) $(MSB_3_FIXED) + +sdk_HEADERS = xaa.h xaalocal.h xaarop.h +EXTRA_DIST = xaacexp.h xaawrap.h xaaLine.c xaaDashLine.c \ + xaaStipple.c xaaTEGlyph.c xaaNonTEGlyph.c xaaBitmap.c \ + XAA.HOWTO + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../../../miext/cw + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/xorg-server/hw/xnest/Display.c b/xorg-server/hw/xnest/Display.c index 72c640186..7acad755c 100644 --- a/xorg-server/hw/xnest/Display.c +++ b/xorg-server/hw/xnest/Display.c @@ -1,193 +1,206 @@ -/*
-
-Copyright 1993 by Davor Matic
-
-Permission to use, copy, modify, distribute, and sell this software
-and its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation. Davor Matic makes no representations about
-the suitability of this software for any purpose. It is provided "as
-is" without express or implied warranty.
-
-*/
-
-
-#ifdef HAVE_XNEST_CONFIG_H
-#include <xnest-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "screenint.h"
-#include "input.h"
-#include "misc.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-
-#include "Xnest.h"
-
-#include "Display.h"
-#include "Init.h"
-#include "Args.h"
-
-#include "icon"
-#include "screensaver"
-
-Display *xnestDisplay = NULL;
-XVisualInfo *xnestVisuals;
-int xnestNumVisuals;
-int xnestDefaultVisualIndex;
-Colormap *xnestDefaultColormaps;
-static int xnestNumDefaultColormaps;
-int *xnestDepths;
-int xnestNumDepths;
-XPixmapFormatValues *xnestPixmapFormats;
-int xnestNumPixmapFormats;
-Pixel xnestBlackPixel;
-Pixel xnestWhitePixel;
-Drawable xnestDefaultDrawables[MAXDEPTH + 1];
-Pixmap xnestIconBitmap;
-Pixmap xnestScreenSaverPixmap;
-XlibGC xnestBitmapGC;
-unsigned long xnestEventMask;
-
-void
-xnestOpenDisplay(int argc, char *argv[])
-{
- XVisualInfo vi;
- long mask;
- int i, j;
-
- if (!xnestDoFullGeneration) return;
-
- xnestCloseDisplay();
-
- xnestDisplay = XOpenDisplay(xnestDisplayName);
- if (xnestDisplay == NULL)
- FatalError("Unable to open display \"%s\".\n",
- XDisplayName(xnestDisplayName));
-
- if (xnestSynchronize)
- XSynchronize(xnestDisplay, True);
-
- mask = VisualScreenMask;
- vi.screen = DefaultScreen(xnestDisplay);
- xnestVisuals = XGetVisualInfo(xnestDisplay, mask, &vi, &xnestNumVisuals);
- if (xnestNumVisuals == 0 || xnestVisuals == NULL)
- FatalError("Unable to find any visuals.\n");
-
- if (xnestUserDefaultClass || xnestUserDefaultDepth) {
- xnestDefaultVisualIndex = UNDEFINED;
- for (i = 0; i < xnestNumVisuals; i++)
- if ((!xnestUserDefaultClass ||
- xnestVisuals[i].class == xnestDefaultClass)
- &&
- (!xnestUserDefaultDepth ||
- xnestVisuals[i].depth == xnestDefaultDepth)) {
- xnestDefaultVisualIndex = i;
- break;
- }
- if (xnestDefaultVisualIndex == UNDEFINED)
- FatalError("Unable to find desired default visual.\n");
- }
- else {
- vi.visualid = XVisualIDFromVisual(DefaultVisual(xnestDisplay,
- DefaultScreen(xnestDisplay)));
- xnestDefaultVisualIndex = 0;
- for (i = 0; i < xnestNumVisuals; i++)
- if (vi.visualid == xnestVisuals[i].visualid)
- xnestDefaultVisualIndex = i;
- }
-
- xnestNumDefaultColormaps = xnestNumVisuals;
- xnestDefaultColormaps = (Colormap *)malloc(xnestNumDefaultColormaps *
- sizeof(Colormap));
- for (i = 0; i < xnestNumDefaultColormaps; i++)
- xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay,
- DefaultRootWindow(xnestDisplay),
- xnestVisuals[i].visual,
- AllocNone);
-
- xnestDepths = XListDepths(xnestDisplay, DefaultScreen(xnestDisplay),
- &xnestNumDepths);
-
- xnestPixmapFormats = XListPixmapFormats(xnestDisplay,
- &xnestNumPixmapFormats);
-
- xnestBlackPixel = BlackPixel(xnestDisplay, DefaultScreen(xnestDisplay));
- xnestWhitePixel = WhitePixel(xnestDisplay, DefaultScreen(xnestDisplay));
-
- if (xnestParentWindow != (Window) 0)
- xnestEventMask = StructureNotifyMask;
- else
- xnestEventMask = 0L;
-
- for (i = 0; i <= MAXDEPTH; i++)
- xnestDefaultDrawables[i] = None;
-
- for (i = 0; i < xnestNumPixmapFormats; i++)
- for (j = 0; j < xnestNumDepths; j++)
- if (xnestPixmapFormats[i].depth == 1 ||
- xnestPixmapFormats[i].depth == xnestDepths[j]) {
- xnestDefaultDrawables[xnestPixmapFormats[i].depth] =
- XCreatePixmap(xnestDisplay, DefaultRootWindow(xnestDisplay),
- 1, 1, xnestPixmapFormats[i].depth);
- }
-
- xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL);
-
- if (!(xnestUserGeometry & XValue))
- xnestX = 0;
-
- if (!(xnestUserGeometry & YValue))
- xnestY = 0;
-
- if (xnestParentWindow == 0) {
- if (!(xnestUserGeometry & WidthValue))
- xnestWidth = 3 * DisplayWidth(xnestDisplay,
- DefaultScreen(xnestDisplay)) / 4;
-
- if (!(xnestUserGeometry & HeightValue))
- xnestHeight = 3 * DisplayHeight(xnestDisplay,
- DefaultScreen(xnestDisplay)) / 4;
- }
-
- if (!xnestUserBorderWidth)
- xnestBorderWidth = 1;
-
- xnestIconBitmap =
- XCreateBitmapFromData(xnestDisplay,
- DefaultRootWindow(xnestDisplay),
- (char *)icon_bits,
- icon_width,
- icon_height);
-
- xnestScreenSaverPixmap =
- XCreatePixmapFromBitmapData(xnestDisplay,
- DefaultRootWindow(xnestDisplay),
- (char *)screensaver_bits,
- screensaver_width,
- screensaver_height,
- xnestWhitePixel,
- xnestBlackPixel,
- DefaultDepth(xnestDisplay,
- DefaultScreen(xnestDisplay)));
-}
-
-void
-xnestCloseDisplay(void)
-{
- if (!xnestDoFullGeneration || !xnestDisplay) return;
-
- /*
- If xnestDoFullGeneration all x resources will be destroyed upon closing
- the display connection. There is no need to generate extra protocol.
- */
-
- free(xnestDefaultColormaps);
- XFree(xnestVisuals);
- XFree(xnestDepths);
- XFree(xnestPixmapFormats);
- XCloseDisplay(xnestDisplay);
-}
+/* + +Copyright 1993 by Davor Matic + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation. Davor Matic makes no representations about +the suitability of this software for any purpose. It is provided "as +is" without express or implied warranty. + +*/ + + +#ifdef HAVE_XNEST_CONFIG_H +#include <xnest-config.h> +#endif + +#include <string.h> +#include <errno.h> + +#include <X11/X.h> +#include <X11/Xproto.h> +#include "screenint.h" +#include "input.h" +#include "misc.h" +#include "scrnintstr.h" +#include "servermd.h" + +#include "Xnest.h" + +#include "Display.h" +#include "Init.h" +#include "Args.h" + +#include "icon" +#include "screensaver" + +Display *xnestDisplay = NULL; +XVisualInfo *xnestVisuals; +int xnestNumVisuals; +int xnestDefaultVisualIndex; +Colormap *xnestDefaultColormaps; +static int xnestNumDefaultColormaps; +int *xnestDepths; +int xnestNumDepths; +XPixmapFormatValues *xnestPixmapFormats; +int xnestNumPixmapFormats; +Pixel xnestBlackPixel; +Pixel xnestWhitePixel; +Drawable xnestDefaultDrawables[MAXDEPTH + 1]; +Pixmap xnestIconBitmap; +Pixmap xnestScreenSaverPixmap; +XlibGC xnestBitmapGC; +unsigned long xnestEventMask; + +static int _X_NORETURN +x_io_error_handler (Display *dpy) { + ErrorF("Lost connection to X server: %s\n", strerror(errno)); + CloseWellKnownConnections(); + OsCleanup(1); + exit(1); +} + +void +xnestOpenDisplay(int argc, char *argv[]) +{ + XVisualInfo vi; + long mask; + int i, j; + + if (!xnestDoFullGeneration) return; + + XSetIOErrorHandler(x_io_error_handler); + + xnestCloseDisplay(); + + xnestDisplay = XOpenDisplay(xnestDisplayName); + if (xnestDisplay == NULL) + FatalError("Unable to open display \"%s\".\n", + XDisplayName(xnestDisplayName)); + + if (xnestSynchronize) + XSynchronize(xnestDisplay, True); + + mask = VisualScreenMask; + vi.screen = DefaultScreen(xnestDisplay); + xnestVisuals = XGetVisualInfo(xnestDisplay, mask, &vi, &xnestNumVisuals); + if (xnestNumVisuals == 0 || xnestVisuals == NULL) + FatalError("Unable to find any visuals.\n"); + + if (xnestUserDefaultClass || xnestUserDefaultDepth) { + xnestDefaultVisualIndex = UNDEFINED; + for (i = 0; i < xnestNumVisuals; i++) + if ((!xnestUserDefaultClass || + xnestVisuals[i].class == xnestDefaultClass) + && + (!xnestUserDefaultDepth || + xnestVisuals[i].depth == xnestDefaultDepth)) { + xnestDefaultVisualIndex = i; + break; + } + if (xnestDefaultVisualIndex == UNDEFINED) + FatalError("Unable to find desired default visual.\n"); + } + else { + vi.visualid = XVisualIDFromVisual(DefaultVisual(xnestDisplay, + DefaultScreen(xnestDisplay))); + xnestDefaultVisualIndex = 0; + for (i = 0; i < xnestNumVisuals; i++) + if (vi.visualid == xnestVisuals[i].visualid) + xnestDefaultVisualIndex = i; + } + + xnestNumDefaultColormaps = xnestNumVisuals; + xnestDefaultColormaps = (Colormap *)malloc(xnestNumDefaultColormaps * + sizeof(Colormap)); + for (i = 0; i < xnestNumDefaultColormaps; i++) + xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay, + DefaultRootWindow(xnestDisplay), + xnestVisuals[i].visual, + AllocNone); + + xnestDepths = XListDepths(xnestDisplay, DefaultScreen(xnestDisplay), + &xnestNumDepths); + + xnestPixmapFormats = XListPixmapFormats(xnestDisplay, + &xnestNumPixmapFormats); + + xnestBlackPixel = BlackPixel(xnestDisplay, DefaultScreen(xnestDisplay)); + xnestWhitePixel = WhitePixel(xnestDisplay, DefaultScreen(xnestDisplay)); + + if (xnestParentWindow != (Window) 0) + xnestEventMask = StructureNotifyMask; + else + xnestEventMask = 0L; + + for (i = 0; i <= MAXDEPTH; i++) + xnestDefaultDrawables[i] = None; + + for (i = 0; i < xnestNumPixmapFormats; i++) + for (j = 0; j < xnestNumDepths; j++) + if (xnestPixmapFormats[i].depth == 1 || + xnestPixmapFormats[i].depth == xnestDepths[j]) { + xnestDefaultDrawables[xnestPixmapFormats[i].depth] = + XCreatePixmap(xnestDisplay, DefaultRootWindow(xnestDisplay), + 1, 1, xnestPixmapFormats[i].depth); + } + + xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL); + + if (!(xnestUserGeometry & XValue)) + xnestX = 0; + + if (!(xnestUserGeometry & YValue)) + xnestY = 0; + + if (xnestParentWindow == 0) { + if (!(xnestUserGeometry & WidthValue)) + xnestWidth = 3 * DisplayWidth(xnestDisplay, + DefaultScreen(xnestDisplay)) / 4; + + if (!(xnestUserGeometry & HeightValue)) + xnestHeight = 3 * DisplayHeight(xnestDisplay, + DefaultScreen(xnestDisplay)) / 4; + } + + if (!xnestUserBorderWidth) + xnestBorderWidth = 1; + + xnestIconBitmap = + XCreateBitmapFromData(xnestDisplay, + DefaultRootWindow(xnestDisplay), + (char *)icon_bits, + icon_width, + icon_height); + + xnestScreenSaverPixmap = + XCreatePixmapFromBitmapData(xnestDisplay, + DefaultRootWindow(xnestDisplay), + (char *)screensaver_bits, + screensaver_width, + screensaver_height, + xnestWhitePixel, + xnestBlackPixel, + DefaultDepth(xnestDisplay, + DefaultScreen(xnestDisplay))); +} + +void +xnestCloseDisplay(void) +{ + if (!xnestDoFullGeneration || !xnestDisplay) return; + + /* + If xnestDoFullGeneration all x resources will be destroyed upon closing + the display connection. There is no need to generate extra protocol. + */ + + free(xnestDefaultColormaps); + XFree(xnestVisuals); + XFree(xnestDepths); + XFree(xnestPixmapFormats); + XCloseDisplay(xnestDisplay); +} diff --git a/xorg-server/hw/xnest/Events.c b/xorg-server/hw/xnest/Events.c index 619427ded..2399313c6 100644 --- a/xorg-server/hw/xnest/Events.c +++ b/xorg-server/hw/xnest/Events.c @@ -198,6 +198,8 @@ xnestCollectEvents(void) case DestroyNotify: if (xnestParentWindow != (Window) 0 && X.xdestroywindow.window == xnestParentWindow) + CloseWellKnownConnections(); + OsCleanup(1); exit (0); break; diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h index 6ba1ab200..b7de5ca3d 100644 --- a/xorg-server/include/input.h +++ b/xorg-server/include/input.h @@ -608,4 +608,6 @@ extern _X_EXPORT const char* input_option_get_value(const InputOption *opt); extern _X_EXPORT void input_option_set_key(InputOption *opt, const char* key); extern _X_EXPORT void input_option_set_value(InputOption *opt, const char* value); +extern _X_HIDDEN Bool point_on_screen(ScreenPtr pScreen, int x, int y); + #endif /* INPUT_H */ diff --git a/xorg-server/include/inpututils.h b/xorg-server/include/inpututils.h index 47e242d87..2832ed5b1 100644 --- a/xorg-server/include/inpututils.h +++ b/xorg-server/include/inpututils.h @@ -30,6 +30,7 @@ #define INPUTUTILS_H #include "input.h" +#include <X11/extensions/XI2proto.h> struct _ValuatorMask { int8_t last_bit; /* highest bit set in mask */ @@ -40,4 +41,9 @@ struct _ValuatorMask { extern void verify_internal_event(const InternalEvent *ev); extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms); +FP3232 double_to_fp3232(double in); +FP1616 double_to_fp1616(double in); +double fp1616_to_double(FP1616 in); +double fp3232_to_double(FP3232 in); + #endif diff --git a/xorg-server/include/os.h b/xorg-server/include/os.h index 578c5d894..642caeb99 100644 --- a/xorg-server/include/os.h +++ b/xorg-server/include/os.h @@ -563,7 +563,6 @@ extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X extern _X_EXPORT void VErrorF(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1,0); extern SERVEXTERN void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); -extern _X_EXPORT void Error(const char *str); extern _X_EXPORT void LogPrintMarkers(void); extern _X_EXPORT void xorg_backtrace(void); diff --git a/xorg-server/include/xorg-config.h.in b/xorg-server/include/xorg-config.h.in index 0d1ea9142..6b9230f3c 100644 --- a/xorg-server/include/xorg-config.h.in +++ b/xorg-server/include/xorg-config.h.in @@ -118,18 +118,6 @@ /* Have execinfo.h */ #undef HAVE_EXECINFO_H -/* Have pci_system_init_dev_mem() */ -#undef HAVE_PCI_SYSTEM_INIT_DEV_MEM - -/* Define to 1 if you have the `pci_device_is_boot_vga' function. */ -#undef HAVE_PCI_DEVICE_IS_BOOT_VGA - -/* Have pci_enable_device */ -#undef HAVE_PCI_DEVICE_ENABLE - -/* Define to 1 if you have the `pci_device_vgaarb_init' function. */ -#undef HAVE_PCI_DEVICE_VGAARB_INIT - /* Path to text files containing PCI IDs */ #undef PCI_TXT_IDS_PATH @@ -139,4 +127,7 @@ /* Build with libdrm support */ #undef WITH_LIBDRM +/* Use libpciaccess */ +#undef XSERVER_LIBPCIACCESS + #endif /* _XORG_CONFIG_H_ */ diff --git a/xorg-server/man/Xserver.man b/xorg-server/man/Xserver.man index 1a36b0956..02cca5263 100644 --- a/xorg-server/man/Xserver.man +++ b/xorg-server/man/Xserver.man @@ -143,12 +143,12 @@ is platform and configuration specific. disables named extension. If an unknown extension name is specified, a list of accepted extension names is printed. .TP 8 -.BI \+extension extensionName +.BI +extension extensionName enables named extension. If an unknown extension name is specified, a list of accepted extension names is printed. .TP 8 .B \-f \fIvolume\fP -sets feep (bell) volume (allowable range: 0-100). +sets beep (bell) volume (allowable range: 0-100). .TP 8 .B \-fc \fIcursorFont\fP sets default cursor font. @@ -524,8 +524,8 @@ An example configuration: .fi This will add /usr/share/X11/fonts/misc as the first FPE with the attribute -'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with -the attribute unscaled etc. This is functionally equivalent to setting +\N'39'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with +the attribute 'unscaled' etc. This is functionally equivalent to setting the following font path: .nf diff --git a/xorg-server/mi/mipointer.c b/xorg-server/mi/mipointer.c index 670f63b6e..55e4081f2 100644 --- a/xorg-server/mi/mipointer.c +++ b/xorg-server/mi/mipointer.c @@ -569,35 +569,37 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, * * @param pDev The device to move * @param mode Movement mode (Absolute or Relative) - * @param[in,out] x The x coordinate in screen coordinates (in regards to total - * desktop size) - * @param[in,out] y The y coordinate in screen coordinates (in regards to total - * desktop size) + * @param[in,out] screenx The x coordinate in screen coordinates + * @param[in,out] screeny The y coordinate in screen coordinates */ -void -miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) +ScreenPtr +miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, double *screeny) { miPointerScreenPtr pScreenPriv; ScreenPtr pScreen; ScreenPtr newScreen; + int x, y; miPointerPtr pPointer; if (!pDev || !pDev->coreEvents) - return; + return NULL; pPointer = MIPOINTER(pDev); pScreen = pPointer->pScreen; if (!pScreen) - return; /* called before ready */ + return NULL; /* called before ready */ + + x = trunc(*screenx); + y = trunc(*screeny); - if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height) + if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height) { pScreenPriv = GetScreenPrivate (pScreen); if (!pPointer->confined) { newScreen = pScreen; - (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, x, y); + (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y); if (newScreen != pScreen) { pScreen = newScreen; @@ -610,23 +612,32 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, int *x, int *y) } } /* Constrain the sprite to the current limits. */ - if (*x < pPointer->limits.x1) - *x = pPointer->limits.x1; - if (*x >= pPointer->limits.x2) - *x = pPointer->limits.x2 - 1; - if (*y < pPointer->limits.y1) - *y = pPointer->limits.y1; - if (*y >= pPointer->limits.y2) - *y = pPointer->limits.y2 - 1; + if (x < pPointer->limits.x1) + x = pPointer->limits.x1; + if (x >= pPointer->limits.x2) + x = pPointer->limits.x2 - 1; + if (y < pPointer->limits.y1) + y = pPointer->limits.y1; + if (y >= pPointer->limits.y2) + y = pPointer->limits.y2 - 1; if (pScreen->ConstrainCursorHarder) - pScreen->ConstrainCursorHarder(pDev, pScreen, mode, x, y); + pScreen->ConstrainCursorHarder(pDev, pScreen, mode, &x, &y); - if (pPointer->x == *x && pPointer->y == *y && - pPointer->pScreen == pScreen) - return; + if (pPointer->x != x || pPointer->y != y || + pPointer->pScreen != pScreen) + miPointerMoveNoEvent(pDev, pScreen, x, y); + + /* In the event we actually change screen or we get confined, we just + * drop the float component on the floor + * FIXME: only drop remainder for ConstrainCursorHarder, not for screen + * crossings */ + if (x != trunc(*screenx)) + *screenx = x; + if (y != trunc(*screeny)) + *screeny = y; - miPointerMoveNoEvent(pDev, pScreen, *x, *y); + return pScreen; } /** diff --git a/xorg-server/mi/mipointer.h b/xorg-server/mi/mipointer.h index c4265f9d8..45abb5b56 100644 --- a/xorg-server/mi/mipointer.h +++ b/xorg-server/mi/mipointer.h @@ -131,11 +131,11 @@ extern _X_EXPORT void miPointerGetPosition( /* Moves the cursor to the specified position. May clip the co-ordinates: * x and y are modified in-place. */ -extern _X_EXPORT void miPointerSetPosition( +extern _X_EXPORT ScreenPtr miPointerSetPosition( DeviceIntPtr pDev, int mode, - int *x, - int *y); + double *x, + double *y); extern _X_EXPORT void miPointerUpdateSprite( DeviceIntPtr pDev); diff --git a/xorg-server/os/backtrace.c b/xorg-server/os/backtrace.c index 7ca6dab6d..58b4b1f34 100644 --- a/xorg-server/os/backtrace.c +++ b/xorg-server/os/backtrace.c @@ -27,6 +27,8 @@ #include "os.h" #include "misc.h" +#include <errno.h> +#include <string.h> #ifdef HAVE_BACKTRACE #ifndef _GNU_SOURCE @@ -199,9 +201,8 @@ void xorg_backtrace(void) { walkcontext(&u, xorg_backtrace_frame, &depth); else # endif - Error("Failed to get backtrace info"); + ErrorF("Failed to get backtrace info: %s\n", strerror(errno)); } - ErrorF("\n"); } # else diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c index 77a389a43..cf0e01518 100644 --- a/xorg-server/os/log.c +++ b/xorg-server/os/log.c @@ -87,7 +87,6 @@ OR PERFORMANCE OF THIS SOFTWARE. #include <sys/stat.h> #include <stdarg.h> #include <stdlib.h> /* for malloc() */ -#include <errno.h> #include "input.h" #include "site.h" @@ -650,19 +649,6 @@ ErrorF(const char * f, ...) va_end(args); } -/* A perror() workalike. */ - -void -Error(const char *str) -{ - const char *err = strerror(errno); - - if (str) - LogWrite(-1, "%s: %s", str, err); - else - LogWrite(-1, "%s", err); -} - void LogPrintMarkers(void) { diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index 8fd034af7..30ffb4373 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -318,7 +318,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); - (void) chmod(tmp, 0444); + (void) fchmod(lfd, 0444); (void) close(lfd); /* @@ -339,7 +339,7 @@ LockServer(void) /* * Read the pid from the existing file */ - lfd = open(LockFile, O_RDONLY); + lfd = open(LockFile, O_RDONLY|O_NOFOLLOW); if (lfd < 0) { unlink(tmp); FatalError("Can't read lock file %s\n", LockFile); diff --git a/xorg-server/os/xprintf.c b/xorg-server/os/xprintf.c index cc5a9b355..fecaa1443 100644 --- a/xorg-server/os/xprintf.c +++ b/xorg-server/os/xprintf.c @@ -64,6 +64,8 @@ #include "os.h" #include <stdarg.h> #include <stdio.h> +#include <errno.h> +#include <string.h> #ifdef asprintf # undef asprintf @@ -161,8 +163,7 @@ XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va) { int size = vasprintf(ret, format, va); if ((size == -1) || (*ret == NULL)) { - Error("XNFvasprintf"); - FatalError("XNFvasprintf failed"); + FatalError("XNFvasprintf failed: %s", strerror(errno)); } return size; } diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c index afc4d4d99..bc41c226d 100644 --- a/xorg-server/test/input.c +++ b/xorg-server/test/input.c @@ -1309,17 +1309,17 @@ static void dix_get_master(void) SpriteInfoRec ptr_sprite, kbd_sprite; SpriteInfoRec floating_sprite; - memset(&vcp, 0, sizeof(DeviceIntRec)); - memset(&vck, 0, sizeof(DeviceIntRec)); - memset(&ptr, 0, sizeof(DeviceIntRec)); - memset(&kbd, 0, sizeof(DeviceIntRec)); - memset(&floating, 0, sizeof(DeviceIntRec)); - - memset(&vcp_sprite, 0, sizeof(DeviceIntRec)); - memset(&vck_sprite, 0, sizeof(DeviceIntRec)); - memset(&ptr_sprite, 0, sizeof(DeviceIntRec)); - memset(&kbd_sprite, 0, sizeof(DeviceIntRec)); - memset(&floating_sprite, 0, sizeof(DeviceIntRec)); + memset(&vcp, 0, sizeof(vcp)); + memset(&vck, 0, sizeof(vck)); + memset(&ptr, 0, sizeof(ptr)); + memset(&kbd, 0, sizeof(kbd)); + memset(&floating, 0, sizeof(floating)); + + memset(&vcp_sprite, 0, sizeof(vcp_sprite)); + memset(&vck_sprite, 0, sizeof(vck_sprite)); + memset(&ptr_sprite, 0, sizeof(ptr_sprite)); + memset(&kbd_sprite, 0, sizeof(kbd_sprite)); + memset(&floating_sprite, 0, sizeof(floating_sprite)); vcp.type = MASTER_POINTER; vck.type = MASTER_KEYBOARD; @@ -1462,9 +1462,137 @@ static void input_option_test(void) assert(list == NULL); } +static void +_test_double_fp16_values(double orig_d) +{ + FP1616 first_fp16, final_fp16; + double final_d; + char first_fp16_s[64]; + char final_fp16_s[64]; + + if (orig_d > 0x7FFF) { + printf("Test out of range\n"); + assert(0); + } + + first_fp16 = double_to_fp1616(orig_d); + final_d = fp1616_to_double(first_fp16); + final_fp16 = double_to_fp1616(final_d); + + snprintf(first_fp16_s, sizeof(first_fp16_s), "%d + %u * 2^-16", (first_fp16 & 0xffff0000) >> 16, first_fp16 & 0xffff); + snprintf(final_fp16_s, sizeof(final_fp16_s), "%d + %u * 2^-16", (final_fp16 & 0xffff0000) >> 16, final_fp16 & 0xffff); + + printf("FP16: original double: %f first fp16: %s, re-encoded double: %f, final fp16: %s\n", orig_d, first_fp16_s, final_d, final_fp16_s); + + /* since we lose precision, we only do rough range testing */ + assert(final_d > orig_d - 0.1); + assert(final_d < orig_d + 0.1); + + assert(memcmp(&first_fp16, &final_fp16, sizeof(FP1616)) == 0); + + if (orig_d > 0) + _test_double_fp16_values(-orig_d); +} + +static void +_test_double_fp32_values(double orig_d) +{ + FP3232 first_fp32, final_fp32; + double final_d; + + if (orig_d > 0x7FFFFFFF) { + printf("Test out of range\n"); + assert(0); + } + + first_fp32 = double_to_fp3232(orig_d); + final_d = fp3232_to_double(first_fp32); + final_fp32 = double_to_fp3232(final_d); + + /* { + * char first_fp32_s[64]; + * char final_fp32_s[64]; + * snprintf(first_fp32_s, sizeof(first_fp32_s), "%d + %u * 2^-32", first_fp32.integral, first_fp32.frac); + * snprintf(final_fp32_s, sizeof(final_fp32_s), "%d + %u * 2^-32", first_fp32.integral, final_fp32.frac); + * + * printf("FP32: original double: %f first fp32: %s, re-encoded double: %f, final fp32: %s\n", orig_d, first_fp32_s, final_d, final_fp32_s); + * } + */ + + /* since we lose precision, we only do rough range testing */ + assert(final_d > orig_d - 0.1); + assert(final_d < orig_d + 0.1); + + assert(memcmp(&first_fp32, &final_fp32, sizeof(FP3232)) == 0); + + if (orig_d > 0) + _test_double_fp32_values(-orig_d); +} + +static void +dix_double_fp_conversion(void) +{ + uint32_t i; + printf("Testing double to FP1616/FP3232 conversions\n"); + + _test_double_fp16_values(0); + for (i = 1; i < 0x7FFF; i <<= 1) { + double val; + + val = i; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + /* and some pseudo-random floating points */ + val = i - 0.00382; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.00382; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.05234; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.12342; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.27583; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.50535; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.72342; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + + val = i + 0.80408; + _test_double_fp16_values(val); + _test_double_fp32_values(val); + } + + for (i = 0x7FFFF; i < 0x7FFFFFFF; i <<= 1) { + _test_double_fp32_values(i); + /* and a few more random floating points, obtained + * by faceplanting into the numpad repeatedly */ + _test_double_fp32_values(i + 0.010177); + _test_double_fp32_values(i + 0.213841); + _test_double_fp32_values(i + 0.348720); + _test_double_fp32_values(i + 0.472020); + _test_double_fp32_values(i + 0.572020); + _test_double_fp32_values(i + 0.892929); + } +} int main(int argc, char** argv) { + dix_double_fp_conversion(); dix_input_valuator_masks(); dix_input_attributes(); dix_init_valuators(); diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in index 6814a6b72..5279521a6 100644 --- a/xorg-server/xkeyboard-config/rules/base.xml.in +++ b/xorg-server/xkeyboard-config/rules/base.xml.in @@ -6209,7 +6209,7 @@ <option> <configItem> <name>numpad:mac</name> - <_description>Numeric keypad keys work as with Macintosh</_description> + <_description>Numeric keypad keys always enter digits (as in Mac OS)</_description> </configItem> </option> <option> @@ -6339,6 +6339,7 @@ <_description>Right Win chooses 5th level, locks when pressed together with another 5th-level-chooser</_description> </configItem> </option> +<!-- <option> <configItem> <name>lv5:lsgt_switch_lock_cancel</name> @@ -6375,6 +6376,7 @@ <_description>Right Alt chooses 5th level, acts as onetime lock when pressed together with another 5th-level-chooser</_description> </configItem> </option> +--> </group> <group allowMultipleSelection="false"> <!-- Let space output NBSP, NNBSP, ZWNJ, and ZWJ for the desired level --> diff --git a/xorg-server/xkeyboard-config/symbols/gb b/xorg-server/xkeyboard-config/symbols/gb index d460d3d61..58e966fc7 100644 --- a/xorg-server/xkeyboard-config/symbols/gb +++ b/xorg-server/xkeyboard-config/symbols/gb @@ -169,10 +169,12 @@ xkb_symbols "mac" { key <AE02> { [ 2, at, EuroSign ] }; key <AE03> { [ 3, sterling, numbersign ] }; + key <LSGT> { [ grave, asciitilde ] }; // End alphanumeric section include "level3(ralt_switch)" + include "level3(enter_switch)" }; diff --git a/xorg-server/xkeyboard-config/symbols/macintosh_vndr/apple b/xorg-server/xkeyboard-config/symbols/macintosh_vndr/apple index cbbf110d3..551eabc33 100644 --- a/xorg-server/xkeyboard-config/symbols/macintosh_vndr/apple +++ b/xorg-server/xkeyboard-config/symbols/macintosh_vndr/apple @@ -1,141 +1,141 @@ -//
-// Keyboard modification for Apple keyboards
-//
-
-partial default modifier_keys
-xkb_symbols "extended" {
-
- key <KPEQ> { [ KP_Equal ] };
-
-// The key in the PC's Insert position is sometimes engraved Help (at least
-// in Switzerland and Great Britain), with Insert sometimes above. But in the
-// US and Canada, it remains Insert. So this should probably be an XkbOption,
-// but I have to do more research.
-// Perhaps Help should be the primary symbol with Insert in the 1st shift-level
-// key <INS> { [ Help, Insert ] };
-// The keys next to F12, labeled F13, F14, & F15 generate codes that XFree86
-// claims not to generate. I think they should be equivalent to the PC keys
-// Print Screen / SysRq, Scroll Lock, and Pause. Linux kernel bug?
-// key <PRSC> { [ F13 ] }; // should be keycode 93 or
-// key <FK13> { [ F13 ] }; // should be keycode 118
-// key <SCLK> { [ F14 ] }; // should be keycode 123 or
-// key <FK14> { [ F14 ] }; // should be keycode 119
-// key <PAUS> { [ F15 ] }; // should be keycode 127 or
-// key <FK15> { [ F15 ] }; // should be keycode 120
-};
-
-partial modifier_keys
-xkb_symbols "laptop" {
-
- include "macintosh_vndr/apple(extended)"
-
- // The real numlock key on the iBook (shared with F5) works internally to
- // the keyboard. It illuminates the Num_Lock led and locks the fn-key to
- // type only the keypad keys on the letter keys (U=4, I=5, O=6, P=*, etc.).
- // The key in the Num_lock position is engraved with Clear.
- override key <NMLK> { [ Clear ] };
- // The key engraved Delete sends BKSP. To get Delete, use Shift-Delete
- override key <BKSP> { [ BackSpace, Delete ] };
- // These keyboards only generate a <RALT> when pressing fn+Alt. This makes
- // it impossible to get to the third shift level on keys that are on
- // the fn-keypad, so use the Enter key (right of <SPC>) for Mode_switch,
- // and use fn+Enter (Apple's code for Menu) for KP_Enter.
- replace key <KPEN> { [ ISO_Level3_Shift ] };
- modifier_map Mod5 { ISO_Level3_Shift };
- // Linux kernel bug with Menu on macs means this doesn't work yet
-// replace key <MENU> { [ KP_Enter ] }; // should be keycode 117
-};
-
-partial modifier_keys
-xkb_symbols "laptop_bad_switch" {
- // Kept for backward compatibility
- include "macintosh_vndr/apple(laptop)"
-};
-
-// Long Aluminium Keyboards
-partial function_keys
-xkb_symbols "alukbd" {
- // The base is a inet PC keyboard
- include "pc"
-
- // Additional Fxx keys
- key <FK13> { [ F13 ] };
- key <FK14> { [ F14 ] };
- key <FK15> { [ F15 ] };
- key <FK16> { [ F16 ] };
- key <FK17> { [ F17 ] };
- key <FK18> { [ F18 ] };
- key <FK19> { [ F19 ] };
-
- // On aluminium keyboards, Num_Lock is replace by Clear
- replace key <NMLK> { [ XF86Clear ] };
- // CAPS key is always Caps_Lock, even for JIS keyboards
- replace key <CAPS> { [ Caps_Lock ] };
-
- // F1..F12 are multimedia keys when used with the 'Fn' key
- // Make those multimedia actions available via ISO_Level3_Shift too,
- // it is useful when the Fn key is remapped to something else (e.g. Insert)
- key <FK01> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, XF86KbdBrightnessDown, NoSymbol, XF86_Switch_VT_1 ]
- };
- key <FK02> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, XF86KbdBrightnessUp, NoSymbol, XF86_Switch_VT_2 ]
- };
- key <FK03> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, NoSymbol, NoSymbol, XF86_Switch_VT_3 ]
- };
- key <FK04> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, NoSymbol, NoSymbol, XF86_Switch_VT_4 ]
- };
- key <FK05> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, NoSymbol, NoSymbol, XF86_Switch_VT_5 ]
- };
- key <FK06> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, NoSymbol, NoSymbol, XF86_Switch_VT_6 ]
- };
- key <FK07> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, XF86AudioPrev, NoSymbol, XF86_Switch_VT_7 ]
- };
- key <FK08> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, XF86AudioPlay, NoSymbol, XF86_Switch_VT_8 ]
- };
- key <FK09> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, XF86AudioNext, NoSymbol, XF86_Switch_VT_9 ]
- };
- key <FK10> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, XF86AudioMute, NoSymbol, XF86_Switch_VT_10 ]
- };
- key <FK11> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, XF86AudioLowerVolume, NoSymbol, XF86_Switch_VT_11 ]
- };
- key <FK12> {
- type= "FOUR_LEVEL_X",
- symbols[Group1]= [ NoSymbol, XF86AudioRaiseVolume, NoSymbol, XF86_Switch_VT_12 ]
- };
-};
-
-// Aluminium Keyboard: make F13, F14, F15 PC-ish (Print, Scroll_Lock, Pause)
-partial function_keys keypad_keys
-xkb_symbols "alupckeys" {
- key <FK13> {
- type= "PC_ALT_LEVEL2",
- symbols[Group1]= [ Print, Sys_Req ]
- };
- key <FK14> { [ Scroll_Lock ] };
- key <FK15> {
- type= "PC_CONTROL_LEVEL2",
- symbols[Group1]= [ Pause, Break ]
- };
- override key <NMLK> { [ Num_Lock, Pointer_EnableKeys ] };
-};
+// +// Keyboard modification for Apple keyboards +// + +partial default modifier_keys +xkb_symbols "extended" { + + key <KPEQ> { [ KP_Equal ] }; + +// The key in the PC's Insert position is sometimes engraved Help (at least +// in Switzerland and Great Britain), with Insert sometimes above. But in the +// US and Canada, it remains Insert. So this should probably be an XkbOption, +// but I have to do more research. +// Perhaps Help should be the primary symbol with Insert in the 1st shift-level +// key <INS> { [ Help, Insert ] }; +// The keys next to F12, labeled F13, F14, & F15 generate codes that XFree86 +// claims not to generate. I think they should be equivalent to the PC keys +// Print Screen / SysRq, Scroll Lock, and Pause. Linux kernel bug? +// key <PRSC> { [ F13 ] }; // should be keycode 93 or +// key <FK13> { [ F13 ] }; // should be keycode 118 +// key <SCLK> { [ F14 ] }; // should be keycode 123 or +// key <FK14> { [ F14 ] }; // should be keycode 119 +// key <PAUS> { [ F15 ] }; // should be keycode 127 or +// key <FK15> { [ F15 ] }; // should be keycode 120 +}; + +partial modifier_keys +xkb_symbols "laptop" { + + include "macintosh_vndr/apple(extended)" + + // The real numlock key on the iBook (shared with F5) works internally to + // the keyboard. It illuminates the Num_Lock led and locks the fn-key to + // type only the keypad keys on the letter keys (U=4, I=5, O=6, P=*, etc.). + // The key in the Num_lock position is engraved with Clear. + override key <NMLK> { [ Clear ] }; + // The key engraved Delete sends BKSP. To get Delete, use Shift-Delete + override key <BKSP> { [ BackSpace, Delete ] }; + // These keyboards only generate a <RALT> when pressing fn+Alt. This makes + // it impossible to get to the third shift level on keys that are on + // the fn-keypad, so use the Enter key (right of <SPC>) for Mode_switch, + // and use fn+Enter (Apple's code for Menu) for KP_Enter. + replace key <KPEN> { [ ISO_Level3_Shift ] }; + modifier_map Mod5 { ISO_Level3_Shift }; + // Linux kernel bug with Menu on macs means this doesn't work yet +// replace key <MENU> { [ KP_Enter ] }; // should be keycode 117 +}; + +partial modifier_keys +xkb_symbols "laptop_bad_switch" { + // Kept for backward compatibility + include "macintosh_vndr/apple(laptop)" +}; + +// Long Aluminium Keyboards +partial function_keys +xkb_symbols "alukbd" { + // The base is a inet PC keyboard + include "pc" + + // Additional Fxx keys + key <FK13> { [ F13 ] }; + key <FK14> { [ F14 ] }; + key <FK15> { [ F15 ] }; + key <FK16> { [ F16 ] }; + key <FK17> { [ F17 ] }; + key <FK18> { [ F18 ] }; + key <FK19> { [ F19 ] }; + + // On aluminium keyboards, Num_Lock is replace by Clear + replace key <NMLK> { [ Clear ] }; + // CAPS key is always Caps_Lock, even for JIS keyboards + replace key <CAPS> { [ Caps_Lock ] }; + + // F1..F12 are multimedia keys when used with the 'Fn' key + // Make those multimedia actions available via ISO_Level3_Shift too, + // it is useful when the Fn key is remapped to something else (e.g. Insert) + key <FK01> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, XF86KbdBrightnessDown, NoSymbol, XF86_Switch_VT_1 ] + }; + key <FK02> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, XF86KbdBrightnessUp, NoSymbol, XF86_Switch_VT_2 ] + }; + key <FK03> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, NoSymbol, NoSymbol, XF86_Switch_VT_3 ] + }; + key <FK04> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, NoSymbol, NoSymbol, XF86_Switch_VT_4 ] + }; + key <FK05> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, NoSymbol, NoSymbol, XF86_Switch_VT_5 ] + }; + key <FK06> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, NoSymbol, NoSymbol, XF86_Switch_VT_6 ] + }; + key <FK07> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, XF86AudioPrev, NoSymbol, XF86_Switch_VT_7 ] + }; + key <FK08> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, XF86AudioPlay, NoSymbol, XF86_Switch_VT_8 ] + }; + key <FK09> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, XF86AudioNext, NoSymbol, XF86_Switch_VT_9 ] + }; + key <FK10> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, XF86AudioMute, NoSymbol, XF86_Switch_VT_10 ] + }; + key <FK11> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, XF86AudioLowerVolume, NoSymbol, XF86_Switch_VT_11 ] + }; + key <FK12> { + type= "FOUR_LEVEL_X", + symbols[Group1]= [ NoSymbol, XF86AudioRaiseVolume, NoSymbol, XF86_Switch_VT_12 ] + }; +}; + +// Aluminium Keyboard: make F13, F14, F15 PC-ish (Print, Scroll_Lock, Pause) +partial function_keys keypad_keys +xkb_symbols "alupckeys" { + key <FK13> { + type= "PC_ALT_LEVEL2", + symbols[Group1]= [ Print, Sys_Req ] + }; + key <FK14> { [ Scroll_Lock ] }; + key <FK15> { + type= "PC_CONTROL_LEVEL2", + symbols[Group1]= [ Pause, Break ] + }; + override key <NMLK> { [ Num_Lock, Pointer_EnableKeys ] }; +}; diff --git a/xorg-server/xkeyboard-config/types/extra b/xorg-server/xkeyboard-config/types/extra index 06b1fec78..465796b53 100644 --- a/xorg-server/xkeyboard-config/types/extra +++ b/xorg-server/xkeyboard-config/types/extra @@ -1,183 +1,161 @@ -partial default xkb_types "default" {
- // Definition for a key type used for the czech keymap, for instance.
- // Defines style a with four level shift. It is similar to three_level
- // type used for iso9995 but it lets the shift key behave "normally".
-
- virtual_modifiers LevelThree;
-
- type "FOUR_LEVEL" {
- modifiers = Shift+LevelThree;
- map[None] = Level1;
- map[Shift] = Level2;
- map[LevelThree] = Level3;
- map[Shift+LevelThree] = Level4;
- level_name[Level1] = "Base";
- level_name[Level2] = "Shift";
- level_name[Level3] = "Alt Base";
- level_name[Level4] = "Shift Alt";
- };
-
- type "FOUR_LEVEL_ALPHABETIC" {
- modifiers = Shift+Lock+LevelThree;
- map[None] = Level1;
- map[Shift] = Level2;
- map[Lock] = Level2;
- map[LevelThree] = Level3;
- map[Shift+LevelThree] = Level4;
- map[Lock+LevelThree] = Level4;
- map[Lock+Shift+LevelThree] = Level3;
- level_name[Level1] = "Base";
- level_name[Level2] = "Shift";
- level_name[Level3] = "Alt Base";
- level_name[Level4] = "Shift Alt";
- };
-
- type "FOUR_LEVEL_SEMIALPHABETIC" {
- modifiers = Shift+Lock+LevelThree;
- map[None] = Level1;
- map[Shift] = Level2;
- map[Lock] = Level2;
- map[LevelThree] = Level3;
- map[Shift+LevelThree] = Level4;
- map[Lock+LevelThree] = Level3;
- map[Lock+Shift+LevelThree] = Level4;
- preserve[Lock+LevelThree] = Lock;
- preserve[Lock+Shift+LevelThree] = Lock;
- level_name[Level1] = "Base";
- level_name[Level2] = "Shift";
- level_name[Level3] = "Alt Base";
- level_name[Level4] = "Shift Alt";
- };
-
- // Another four level keypad variant
- // First two levels are controled by NumLock (with active Shift-ing like
- // in KEYPAD). LevelThree overrides this mode, with two additional
- // Shift-ed levels
- // NumLock state is intentionnaly ignored when LevelThree is active
- type "FOUR_LEVEL_MIXED_KEYPAD" {
- modifiers = Shift+NumLock+LevelThree;
- map[None] = Level1;
- map[Shift+NumLock] = Level1;
- map[NumLock] = Level2;
- map[Shift] = Level2;
- map[LevelThree] = Level3;
- map[NumLock+LevelThree] = Level3;
- map[Shift+LevelThree] = Level4;
- map[Shift+NumLock+LevelThree] = Level4;
- level_name[Level1] = "Base";
- level_name[Level2] = "Number";
- level_name[Level3] = "Alt Base";
- level_name[Level4] = "Shift Alt";
- };
-
- // Base level, two Shift-ed LevelThree levels, one Ctrl+Alt command level
- type "FOUR_LEVEL_X" {
- modifiers = Shift+LevelThree+Control+Alt;
- map[None] = Level1;
- map[LevelThree] = Level2;
- map[Shift+LevelThree] = Level3;
- map[Control+Alt] = Level4;
- level_name[Level1] = "Base";
- level_name[Level2] = "Alt Base";
- level_name[Level3] = "Shift Alt";
- level_name[Level4] = "Ctrl+Alt";
- };
-
-// Special type for keys used in Serbian Latin Unicode map
-// It makes it possible to use all three forms of latin letters
-// present in Unicode that are made up of two separate letters
-// (forms like LJ, Lj, and lj; NJ, Nj, and nj; etc)
-
- type "SEPARATE_CAPS_AND_SHIFT_ALPHABETIC" {
- modifiers = Shift+Lock+LevelThree;
- map[None] = Level1;
- map[Shift] = Level2;
- map[Lock] = Level4;
- map[LevelThree] = Level3;
- map[Shift+LevelThree] = Level4;
- map[Lock+LevelThree] = Level3;
- map[Lock+Shift+LevelThree] = Level3;
- preserve[Lock]= Lock;
- preserve[Lock+LevelThree]= Lock;
- level_name[Level1] = "Base";
- level_name[Level2] = "Shift";
- level_name[Level3] = "AltGr Base";
- level_name[Level4] = "Shift AltGr";
- };
-
-// type for e.g. german ssharp which is capitalized SS.
-// CHARACTERISTICS:
-// It is FOUR_LEVEL with the exception that the fifth level
-// is mapped to the Lock modifier.
-// If other modifiers are used, the Lock state is ignored.
-// DETAILS ABOUT GERMAN:
-// The capital form of ssharp (called sharp s) only exists for
-// completely capitalized Text, not at the beginning of sentences
-// or nouns (nouns have a captial letter at the beginning in german).
-// The ssharp key, to the right of the zero key, takes this into
-// account and has a questionmark mapped on shift-ssharp since
-// normally no capital version is needed.
-// When typing with active capsLock, this key type is needed to
-// output two capital letters S because this is the only german key
-// whose capital letter is not the same as the one typed with shift.
-
- type "FOUR_LEVEL_PLUS_LOCK" {
- modifiers = Shift+Lock+LevelThree;
- map[None] = Level1;
- map[Shift] = Level2;
- map[LevelThree] = Level3;
- map[Shift+LevelThree] = Level4;
- map[Lock] = Level5;
- map[Lock+Shift] = Level2;
- map[Lock+LevelThree] = Level3;
- map[Lock+Shift+LevelThree] = Level4;
- level_name[Level1] = "Base";
- level_name[Level2] = "Shift";
- level_name[Level3] = "Alt Base";
- level_name[Level4] = "Shift Alt";
- level_name[Level5] = "Lock";
- };
-};
-
-// This enables the four level shifting also for the keypad.
-partial xkb_types "keypad" {
- virtual_modifiers LevelThree;
-
- type "FOUR_LEVEL_KEYPAD" {
- modifiers = Shift+NumLock+LevelThree;
- map[None] = Level1;
- map[Shift] = Level2;
- map[NumLock] = Level2;
- map[Shift+NumLock] = Level1;
- map[LevelThree] = Level3;
- map[Shift+LevelThree] = Level4;
- map[NumLock+LevelThree] = Level4;
- map[Shift+NumLock+LevelThree] = Level3;
- level_name[Level1] = "Base";
- level_name[Level2] = "Number";
- level_name[Level3] = "Alt Base";
- level_name[Level4] = "Alt Number";
- };
-};
-
-// This enables the four level shifting also for the keypad,
-// but levels 1 and 2, and 3 and 4 are swapped on Mac keypads.
-partial xkb_types "mac_keypad" {
- virtual_modifiers LevelThree;
-
- type "FOUR_LEVEL_KEYPAD" {
- modifiers = Shift+NumLock+LevelThree;
- map[None] = Level2;
- map[Shift] = Level1;
- map[NumLock] = Level1;
- map[Shift+NumLock] = Level2;
- map[LevelThree] = Level4;
- map[Shift+LevelThree] = Level3;
- map[NumLock+LevelThree] = Level3;
- map[Shift+NumLock+LevelThree] = Level4;
- level_name[Level2] = "Base";
- level_name[Level1] = "Number";
- level_name[Level4] = "Alt Base";
- level_name[Level3] = "Alt Number";
- };
-};
+partial default xkb_types "default" { + // Definition for a key type used for the czech keymap, for instance. + // Defines style a with four level shift. It is similar to three_level + // type used for iso9995 but it lets the shift key behave "normally". + + virtual_modifiers LevelThree; + + type "FOUR_LEVEL" { + modifiers = Shift+LevelThree; + map[None] = Level1; + map[Shift] = Level2; + map[LevelThree] = Level3; + map[Shift+LevelThree] = Level4; + level_name[Level1] = "Base"; + level_name[Level2] = "Shift"; + level_name[Level3] = "Alt Base"; + level_name[Level4] = "Shift Alt"; + }; + + type "FOUR_LEVEL_ALPHABETIC" { + modifiers = Shift+Lock+LevelThree; + map[None] = Level1; + map[Shift] = Level2; + map[Lock] = Level2; + map[LevelThree] = Level3; + map[Shift+LevelThree] = Level4; + map[Lock+LevelThree] = Level4; + map[Lock+Shift+LevelThree] = Level3; + level_name[Level1] = "Base"; + level_name[Level2] = "Shift"; + level_name[Level3] = "Alt Base"; + level_name[Level4] = "Shift Alt"; + }; + + type "FOUR_LEVEL_SEMIALPHABETIC" { + modifiers = Shift+Lock+LevelThree; + map[None] = Level1; + map[Shift] = Level2; + map[Lock] = Level2; + map[LevelThree] = Level3; + map[Shift+LevelThree] = Level4; + map[Lock+LevelThree] = Level3; + map[Lock+Shift+LevelThree] = Level4; + preserve[Lock+LevelThree] = Lock; + preserve[Lock+Shift+LevelThree] = Lock; + level_name[Level1] = "Base"; + level_name[Level2] = "Shift"; + level_name[Level3] = "Alt Base"; + level_name[Level4] = "Shift Alt"; + }; + + // Another four level keypad variant + // First two levels are controled by NumLock (with active Shift-ing like + // in KEYPAD). LevelThree overrides this mode, with two additional + // Shift-ed levels + // NumLock state is intentionnaly ignored when LevelThree is active + type "FOUR_LEVEL_MIXED_KEYPAD" { + modifiers = Shift+NumLock+LevelThree; + map[None] = Level1; + map[Shift+NumLock] = Level1; + map[NumLock] = Level2; + map[Shift] = Level2; + map[LevelThree] = Level3; + map[NumLock+LevelThree] = Level3; + map[Shift+LevelThree] = Level4; + map[Shift+NumLock+LevelThree] = Level4; + level_name[Level1] = "Base"; + level_name[Level2] = "Number"; + level_name[Level3] = "Alt Base"; + level_name[Level4] = "Shift Alt"; + }; + + // Base level, two Shift-ed LevelThree levels, one Ctrl+Alt command level + type "FOUR_LEVEL_X" { + modifiers = Shift+LevelThree+Control+Alt; + map[None] = Level1; + map[LevelThree] = Level2; + map[Shift+LevelThree] = Level3; + map[Control+Alt] = Level4; + level_name[Level1] = "Base"; + level_name[Level2] = "Alt Base"; + level_name[Level3] = "Shift Alt"; + level_name[Level4] = "Ctrl+Alt"; + }; + +// Special type for keys used in Serbian Latin Unicode map +// It makes it possible to use all three forms of latin letters +// present in Unicode that are made up of two separate letters +// (forms like LJ, Lj, and lj; NJ, Nj, and nj; etc) + + type "SEPARATE_CAPS_AND_SHIFT_ALPHABETIC" { + modifiers = Shift+Lock+LevelThree; + map[None] = Level1; + map[Shift] = Level2; + map[Lock] = Level4; + map[LevelThree] = Level3; + map[Shift+LevelThree] = Level4; + map[Lock+LevelThree] = Level3; + map[Lock+Shift+LevelThree] = Level3; + preserve[Lock]= Lock; + preserve[Lock+LevelThree]= Lock; + level_name[Level1] = "Base"; + level_name[Level2] = "Shift"; + level_name[Level3] = "AltGr Base"; + level_name[Level4] = "Shift AltGr"; + }; + +// type for e.g. german ssharp which is capitalized SS. +// CHARACTERISTICS: +// It is FOUR_LEVEL with the exception that the fifth level +// is mapped to the Lock modifier. +// If other modifiers are used, the Lock state is ignored. +// DETAILS ABOUT GERMAN: +// The capital form of ssharp (called sharp s) only exists for +// completely capitalized Text, not at the beginning of sentences +// or nouns (nouns have a captial letter at the beginning in german). +// The ssharp key, to the right of the zero key, takes this into +// account and has a questionmark mapped on shift-ssharp since +// normally no capital version is needed. +// When typing with active capsLock, this key type is needed to +// output two capital letters S because this is the only german key +// whose capital letter is not the same as the one typed with shift. + + type "FOUR_LEVEL_PLUS_LOCK" { + modifiers = Shift+Lock+LevelThree; + map[None] = Level1; + map[Shift] = Level2; + map[LevelThree] = Level3; + map[Shift+LevelThree] = Level4; + map[Lock] = Level5; + map[Lock+Shift] = Level2; + map[Lock+LevelThree] = Level3; + map[Lock+Shift+LevelThree] = Level4; + level_name[Level1] = "Base"; + level_name[Level2] = "Shift"; + level_name[Level3] = "Alt Base"; + level_name[Level4] = "Shift Alt"; + level_name[Level5] = "Lock"; + }; +}; + +// This enables the four level shifting also for the keypad. +partial xkb_types "keypad" { + virtual_modifiers LevelThree; + + type "FOUR_LEVEL_KEYPAD" { + modifiers = Shift+NumLock+LevelThree; + map[None] = Level1; + map[Shift] = Level2; + map[NumLock] = Level2; + map[Shift+NumLock] = Level1; + map[LevelThree] = Level3; + map[Shift+LevelThree] = Level4; + map[NumLock+LevelThree] = Level4; + map[Shift+NumLock+LevelThree] = Level3; + level_name[Level1] = "Base"; + level_name[Level2] = "Number"; + level_name[Level3] = "Alt Base"; + level_name[Level4] = "Alt Number"; + }; +}; diff --git a/xorg-server/xkeyboard-config/types/numpad b/xorg-server/xkeyboard-config/types/numpad index 82c22a917..7888d7db1 100644 --- a/xorg-server/xkeyboard-config/types/numpad +++ b/xorg-server/xkeyboard-config/types/numpad @@ -1,71 +1,67 @@ -partial default xkb_types "pc" {
- type "KEYPAD" {
- modifiers = Shift+NumLock;
- map[None] = Level1;
- map[Shift] = Level2;
- map[NumLock] = Level2;
- map[Shift+NumLock] = Level1;
- level_name[Level1] = "Base";
- level_name[Level2] = "Number";
- };
- include "extra(keypad)"
-};
-
-// On Mac keypads, level 1 and 2 are swapped
-partial xkb_types "mac" {
- type "KEYPAD" {
- modifiers = Shift+NumLock;
- map[None] = Level2;
- map[Shift] = Level1;
- map[NumLock] = Level1;
- map[Shift+NumLock] = Level2;
- level_name[Level2] = "Base";
- level_name[Level1] = "Number";
- };
- include "extra(mac_keypad)"
-};
-
-partial xkb_types "microsoft" {
- type "KEYPAD" {
- modifiers = Shift+NumLock;
- map[None] = Level1;
- preserve[Shift] = Shift;
- map[NumLock] = Level2;
- level_name[Level1] = "Base";
- level_name[Level2] = "Number";
- };
- include "extra(keypad)"
-};
-
-// Swiss-German style numeric keypad: Shift and NumLock operates as
-// two independent modifiers; however, since we want shift state for
-// the cursor keys, only three levels are used from the key mappings.
-// Closest type is actually FOUR_LEVEL_X, but most numpad layouts uses
-// FOUR_LEVEL_MIXED_KEYPAD so that's the one we are going to override.
-partial xkb_types "shift3" {
- type "FOUR_LEVEL_MIXED_KEYPAD" {
- modifiers = Shift+NumLock+Control+Alt;
-
- // NumLock Off => navigate using cursor keys
- map[None] = Level1;
-
- // NumLock Off + Shift pressed => select using cursor keys
- preserve[Shift] = Shift;
-
- // NumLock On => decimal digits
- map[NumLock] = Level2;
-
- // NumLock On + Shift pressed => auxiliary symbols,
- // e.g. hexadecimal digits
- map[Shift+NumLock] = Level3;
-
- // Ctrl + Alt, regardless of NumLock and Shift => command keys
- map[Control+Alt] = Level4;
-
- // reverse map from levels to modifiers
- level_name[Level1] = "Base";
- level_name[Level2] = "NumLock";
- level_name[Level3] = "Shift+NumLock";
- level_name[Level4] = "Ctrl+Alt";
- };
-};
+partial default xkb_types "pc" { + type "KEYPAD" { + modifiers = Shift+NumLock; + map[None] = Level1; + map[Shift] = Level2; + map[NumLock] = Level2; + map[Shift+NumLock] = Level1; + level_name[Level1] = "Base"; + level_name[Level2] = "Number"; + }; + include "extra(keypad)" +}; + +// On Mac keypads, level 1 and 2 are swapped +partial xkb_types "mac" { + type "KEYPAD" { + modifiers = None; + map[None] = Level2; + level_name[Level2] = "Number"; + }; + include "extra(keypad)" +}; + +partial xkb_types "microsoft" { + type "KEYPAD" { + modifiers = Shift+NumLock; + map[None] = Level1; + preserve[Shift] = Shift; + map[NumLock] = Level2; + level_name[Level1] = "Base"; + level_name[Level2] = "Number"; + }; + include "extra(keypad)" +}; + +// Swiss-German style numeric keypad: Shift and NumLock operates as +// two independent modifiers; however, since we want shift state for +// the cursor keys, only three levels are used from the key mappings. +// Closest type is actually FOUR_LEVEL_X, but most numpad layouts uses +// FOUR_LEVEL_MIXED_KEYPAD so that's the one we are going to override. +partial xkb_types "shift3" { + type "FOUR_LEVEL_MIXED_KEYPAD" { + modifiers = Shift+NumLock+Control+Alt; + + // NumLock Off => navigate using cursor keys + map[None] = Level1; + + // NumLock Off + Shift pressed => select using cursor keys + preserve[Shift] = Shift; + + // NumLock On => decimal digits + map[NumLock] = Level2; + + // NumLock On + Shift pressed => auxiliary symbols, + // e.g. hexadecimal digits + map[Shift+NumLock] = Level3; + + // Ctrl + Alt, regardless of NumLock and Shift => command keys + map[Control+Alt] = Level4; + + // reverse map from levels to modifiers + level_name[Level1] = "Base"; + level_name[Level2] = "NumLock"; + level_name[Level3] = "Shift+NumLock"; + level_name[Level4] = "Ctrl+Alt"; + }; +}; diff --git a/xorg-server/xorg-server.pc.in b/xorg-server/xorg-server.pc.in index 643da1542..a98eca8f9 100644 --- a/xorg-server/xorg-server.pc.in +++ b/xorg-server/xorg-server.pc.in @@ -1,21 +1,20 @@ -prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-datarootdir=@datarootdir@
-moduledir=@moduledir@
-sdkdir=@sdkdir@
-sysconfigdir=@sysconfigdir@
-
-abi_ansic=@abi_ansic@
-abi_videodrv=@abi_videodrv@
-abi_xinput=@abi_xinput@
-abi_extension=@abi_extension@
-
-Name: xorg-server
-Description: Modular X.Org X Server
-Version: @PACKAGE_VERSION@
-Requires: pixman-1 pciaccess
-Requires.private: @SDK_REQUIRED_MODULES@
-Cflags: -I${sdkdir} @symbol_visibility@
-Libs: -L${libdir}
+prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +moduledir=@moduledir@ +sdkdir=@sdkdir@ +sysconfigdir=@sysconfigdir@ + +abi_ansic=@abi_ansic@ +abi_videodrv=@abi_videodrv@ +abi_xinput=@abi_xinput@ +abi_extension=@abi_extension@ + +Name: xorg-server +Description: Modular X.Org X Server +Version: @PACKAGE_VERSION@ +Requires.private: @SDK_REQUIRED_MODULES@ +Cflags: -I${sdkdir} @symbol_visibility@ +Libs: -L${libdir} |